home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / QBAS / VIDBASIC.ZIP / VSAVED.ASM < prev    next >
Assembly Source File  |  1990-11-29  |  5KB  |  151 lines

  1. ;«RM82»«TS8,16,24,32,40,48,56,64»
  2. ; updated 11/20/90
  3.  
  4. ;============================================================================
  5. ;   Copyright (C) Copr. 1990 by Sidney J. Kelly
  6. ;           All Rights Reserved.
  7. ;           Sidney J. Kelly
  8. ;           150 Woodhaven Drive
  9. ;           Pittsburgh, PA 15228
  10. ;           home phone 412-561-0950 (7pm to 9:30pm EST)
  11. ;============================================================================
  12.  
  13. DOSSEG
  14. .MODEL MEDIUM
  15.  
  16.     Public  RESTSCRN, SAVESCRN
  17.  
  18. .data
  19.     ;external data so all video routines can access
  20.     EVEN
  21.     EXTRN  B$DVIDEOSEG:WORD
  22.     EXTRN  B$DVIDEOPORT:WORD
  23.     EXTRN  B$DVIDEOINSTL:BYTE
  24.  
  25. .CODE
  26. INCLUDE  NOWAIT.INC           ;add all the video macros
  27. EXTRN    Get_Adapter:FAR
  28.  
  29. ;========================================================================
  30. ;RESTSCRN.ASM - restores 80 * 25 page text screen in QuickBASIC array
  31. ;Parameters:
  32. ; DECLARE SUB RESTSCRN (BYVAL Segment%, BYVAL Offset%)
  33. ; DIM ARRAY%(2000)
  34. ; CALL RESTSCRN(VARSEG(ARRAY%(0)), VARPTR(ARRAY%(0)))
  35. ;========================================================================
  36.  
  37. EVEN
  38. RESTSCRN    Proc   FAR
  39.  
  40.     Push    BP            ;save registers for BASIC
  41.     Mov     BP,SP         ;locate stack to get variable addresses later
  42.     Push    DS
  43.     Push    SI
  44.     Push    DI
  45.  
  46.     Assume    DS:@data
  47.  
  48.     Cmp     B$DVIDEOINSTL,1 ;skip ahead if we have done this before
  49.     JE      Didit          ;if 1 then initialized, so skip ahead
  50.     Call    Get_Adapter    ;use find display routine
  51.  
  52. Didit:
  53.     Mov     DX,B$DVIDEOPORT  ;load retrace port if CGA, else 0
  54.     Mov     ES,B$DVIDEOSEG   ;set ES to the appropriate screen segment
  55.     Mov     SI,[BP+6]     ;get location of array, offset in SI
  56.     Mov     BX,[BP+8]     ;    segment in BX
  57.     Mov     DS,BX         ;MUST set DS _after_ addressing stack
  58.                        ;once adjust DS lose access to stack &
  59.                   ;DGROUP
  60.     Xor     DI,DI         ;Clear DI
  61.     Mov     CX,2000       ;Move 2000 words or 4000 bytes
  62.     Cld                   ;all data moves below will be forward
  63.     OR      DL,DL         ;monochrome/EGA (is DL=0)?
  64.     JZ      Mono          ;yes, skip over the retrace stuff
  65.  
  66. EVEN
  67. CGA:
  68.     CLI                   ;prevent interrupts
  69.     Wait_CGA_Retrace      ;wait for retrace on CGA
  70.     Movsw                 ;move the data source DS:SI, destination ES:DI
  71.     STI                   ;allow interrupts again
  72.     Loop    CGA           ;loop until done
  73.     Jmp     Short Exit    ;skip over the mono routine and exit
  74.  
  75. Mono:
  76.     Rep     Movsw         ;move the data in one operation
  77. Exit:                         ;source DS:SI, destination ES:DI
  78.  
  79.     Pop     DI
  80.     Pop     SI
  81.     Pop     DS            ;restore registers for BASIC
  82.  
  83.         Assume    DS:@data
  84.  
  85.     Pop     BP
  86.     Ret     4             ;return skipping 2 passed parameters
  87. RESTSCRN        Endp
  88.  
  89. ;========================================================================
  90. ;SAVESCRN.ASM - saves 80 * 25 text screen page in QuickBASIC array
  91. ;Parameters:
  92. ; DECLARE SUB SAVESCRN (BYVAL Segment%, BYVAL Offset%)
  93. ; DIM ARRAY%(2000)
  94. ; CALL SAVESCRN( VARSEG(ARRAY%(0)), VARPTR(ARRAY%(0)))
  95. ;========================================================================
  96.  
  97. EVEN
  98. SAVESCRN    Proc   FAR
  99.     Push    BP            ;save registers for BASIC
  100.     Mov     BP,SP         ;locate stack to get variable addresses later
  101.     Push    DS
  102.     Push    SI
  103.     Push    DI
  104.  
  105.         Assume    DS:@data
  106.  
  107.     Cmp     B$DVIDEOINSTL,1 ;skip ahead if we have done this before
  108.     JE      Didit1
  109.     Call    Get_Adapter     ;use find display routine
  110. Didit1:
  111.     Mov     DX,B$DVIDEOPORT ;load retrace port if CGA, else 0
  112.     Mov     BX,B$DVIDEOSEG  ;get appropriate screen segment
  113.                    ;for storage later in DS
  114. Get_Param1:
  115.     Mov     SI,[BP+8]     ;get location of array
  116.     Mov     ES,SI         ;    segment in ES
  117.     Mov     SI,[BP+6]     ;
  118.     Mov     DI,SI         ;    offset in DI
  119.     Mov     DS,BX         ;store screen segment in DS
  120.                        ;once adjust DS lose access to stack &
  121.                   ;DGROUP
  122.         Xor     SI,SI          ;DS:SI, so start at page 0
  123.     Cld                   ;all data moves below will be forward
  124.     Mov     CX,2000       ;load up CX for 2000 words, 4000 bytes
  125.     Or      DL,DL         ;monochrome /EGA (is DL =0)?
  126.     JZ      Mono          ;yes, skip over the retrace stuff
  127.  
  128. EVEN
  129. CGA1:
  130.     CLI                   ;prevent interrupts
  131.     Wait_CGA_Retrace      ;wait for retrace on CGA
  132.     Movsw                 ;move the data source DS:SI, destination ES:DI
  133.     STI                   ;allow interrupts again
  134.     Loop    CGA1          ;loop until done
  135.     Jmp     Short Exit1   ;skip over the mono routine and exit
  136.  
  137. Mono1:
  138.     Rep     Movsw         ;move the data in one operation
  139. Exit1:                        ;source DS:SI, destination ES:DI
  140.     Pop     DI
  141.     Pop     SI
  142.     Pop     DS            ;restore registers for BASIC
  143.  
  144.         Assume    DS:@data
  145.  
  146.     Pop     BP
  147.     Ret     4             ;return skipping 2 passed parameters
  148. SAVESCRN        Endp
  149. END
  150.  
  151.