home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
basic
/
library
/
tb
/
tbscreen
/
rest-tb.asm
< prev
next >
Wrap
Assembly Source File
|
1987-11-03
|
3KB
|
69 lines
;SCRNREST.ASM - restores a portion of the text screen in Turbo Basic
Code Segment Byte
Assume CS:Code
ScrnRest 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: Mov ES,BX ;set ES to the appropriate screen segment
LDS DI,[BP+12] ;get the address for LastLine
Mov AL,[DI] ;and put it into AL
Mov CL,160 ;prepare to multiple times 160
Mul CL ;now AX holds last screen address to restore
Mov BX,AX ;save it in BX for later
LDS DI,[BP+16] ;get the address for FirstLine
Mov AL,[DI] ;put it into AL
Dec AL ;adjust 1-25 to 0-24
Mul CL ;calculate actual starting address on screen
Mov DI,AX ;now DI points to the destination 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
LDS SI,[BP+08] ;get the segment and address of storage array
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
ScrnRest Endp
Code Ends
End Begin