home *** CD-ROM | disk | FTP | other *** search
- ;SCRNSAVE.ASM - saves a portion of the text screen in Turbo Basic
-
- Code Segment Byte
- Assume CS:Code
-
- ScrnSave Proc Far
-
- Begin: Push BP ;save registers for BASIC
- Push DS
- Mov BP,SP ;locate stack to get variable addresses later
-
- Mov DX,0 ;look at low memory using ES
- Mov ES,DX
- Mov BX,0B000h ;assume mono screen segment for now
- Mov AL,ES:[410h] ;get the equipment list
- And AL,48 ;just look at the monitor type
- Cmp AL,48 ;is it mono?
- JZ Get_Params ;yes, skip over adding 800h
- Add BX,800h ;no, adjust for color screen memory
-
- Mov AL,ES:[487h] ;if an EGA is present, AL will not be zero
- Cmp AL,0 ;is it an EGA?
- JNZ Get_Params ;yes, leave DX set to zero as a flag for later
- Mov DX,3DAh ;no, specify the port to check for retrace
-
- Get_Params: Push BX ;save the screen segment for later
-
- LES DI,[BP+08] ;get the segment and address of storage array
-
- LDS SI,[BP+12] ;get the address for LastLine
- Mov AL,[SI] ;and put it into AL
- Mov CL,160 ;prepare to multiple times 160
- Mul CL ;now AX holds the last screen address to save
- Mov BX,AX ;save it in BX for later
-
- LDS SI,[BP+16] ;get the address for FirstLine
- Mov AL,[SI] ;put it into AL
- Dec AL ;adjust 1-25 to 0-24
- Mul CL ;calculate actual starting address on screen
- Mov SI,AX ;now SI points to the source address
-
- Sub BX,AX ;calculate the number of bytes to copy
- Mov CX,BX ;put it into CX for Rep or Loop below
- Shr CX,1 ;divide CX by 2 to obtain the number of words
-
- Pop DS ;retrieve the screen segment saved earlier
- Cld ;all data moves below will be forward
- Cmp DL,0 ;are we doing monochrome or EGA?
- JZ Mono ;yes, skip over the retrace stuff
-
- No_Retrace: In AL,DX ;get the video status byte
- Test AL,1 ;test just the horizontal retrace bit
- JNZ No_Retrace ;if doing a retrace, wait until it's not
- Retrace: In AL,DX ;get the status byte again
- Test AL,1 ;are we currently doing a retrace?
- JZ Retrace ;no wait until we are
- Lodsw ;now get the word from the screen
- Stosw ;and put it into the array
- Loop No_Retrace ;loop until done
- Jmp Exit ;skip over the mono routine and exit
-
- Mono: Rep Movsw ;move the data in one operation
-
- Exit: Pop DS ;restore registers for BASIC
- Pop BP
-
- ScrnSave Endp
- Code Ends
- End Begin
-