home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / basic / library / tb / tbscreen / save-tb.asm < prev    next >
Assembly Source File  |  1987-11-03  |  3KB  |  70 lines

  1. ;SCRNSAVE.ASM - saves a portion of the text screen in Turbo Basic
  2.  
  3. Code        Segment Byte
  4.             Assume  CS:Code
  5.  
  6. ScrnSave    Proc    Far
  7.  
  8. Begin:      Push  BP            ;save registers for BASIC
  9.             Push  DS
  10.             Mov   BP,SP         ;locate stack to get variable addresses later
  11.  
  12.             Mov   DX,0          ;look at low memory using ES
  13.             Mov   ES,DX
  14.             Mov   BX,0B000h     ;assume mono screen segment for now
  15.             Mov   AL,ES:[410h]  ;get the equipment list
  16.             And   AL,48         ;just look at the monitor type
  17.             Cmp   AL,48         ;is it mono?
  18.             JZ    Get_Params    ;yes, skip over adding 800h
  19.             Add   BX,800h       ;no, adjust for color screen memory
  20.  
  21.             Mov   AL,ES:[487h]  ;if an EGA is present, AL will not be zero
  22.             Cmp   AL,0          ;is it an EGA?
  23.             JNZ   Get_Params    ;yes, leave DX set to zero as a flag for later
  24.             Mov   DX,3DAh       ;no, specify the port to check for retrace
  25.  
  26. Get_Params: Push  BX            ;save the screen segment for later
  27.  
  28.             LES   DI,[BP+08]    ;get the segment and address of storage array
  29.  
  30.             LDS   SI,[BP+12]    ;get the address for LastLine
  31.             Mov   AL,[SI]       ;and put it into AL
  32.             Mov   CL,160        ;prepare to multiple times 160
  33.             Mul   CL            ;now AX holds the last screen address to save
  34.             Mov   BX,AX         ;save it in BX for later
  35.  
  36.             LDS   SI,[BP+16]    ;get the address for FirstLine
  37.             Mov   AL,[SI]       ;put it into AL
  38.             Dec   AL            ;adjust 1-25 to 0-24
  39.             Mul   CL            ;calculate actual starting address on screen
  40.             Mov   SI,AX         ;now SI points to the source address
  41.  
  42.             Sub   BX,AX         ;calculate the number of bytes to copy
  43.             Mov   CX,BX         ;put it into CX for Rep or Loop below
  44.             Shr   CX,1          ;divide CX by 2 to obtain the number of words
  45.  
  46.             Pop   DS            ;retrieve the screen segment saved earlier
  47.             Cld                 ;all data moves below will be forward
  48.             Cmp   DL,0          ;are we doing monochrome or EGA?
  49.             JZ    Mono          ;yes, skip over the retrace stuff
  50.  
  51. No_Retrace: In    AL,DX         ;get the video status byte
  52.             Test  AL,1          ;test just the horizontal retrace bit
  53.             JNZ   No_Retrace    ;if doing a retrace, wait until it's not
  54. Retrace:    In    AL,DX         ;get the status byte again
  55.             Test  AL,1          ;are we currently doing a retrace?
  56.             JZ    Retrace       ;no wait until we are
  57.             Lodsw               ;now get the word from the screen
  58.             Stosw               ;and put it into the array
  59.             Loop  No_Retrace    ;loop until done
  60.             Jmp   Exit          ;skip over the mono routine and exit
  61.  
  62. Mono:       Rep   Movsw         ;move the data in one operation
  63.  
  64. Exit:       Pop   DS            ;restore registers for BASIC
  65.             Pop   BP
  66.  
  67. ScrnSave    Endp
  68. Code        Ends
  69.             End   Begin
  70.