home *** CD-ROM | disk | FTP | other *** search
- { Qstores.inc - transfers blocks between screen and memory. ver 2.1, 12-09-86 }
- { These procedures do fast screen transfers of a Rows-by-Cols block to memory
- and vice-versa. It also automatically configures to your machine for Mono,
- CGA, and EGA in any column format. The upper left column is 1,1. Cols can
- range from 1 to 80 and Rows from 1 to 25 (a full screen on 80x25), but EGA
- can handle more. These are needed for pull down menus to save the display. }
-
- { QstoreToMem - saves screen display for later use ver 2.0, 11-24-86 }
- procedure QstoreToMem (Row, Col, Rows, Cols: byte; VAR Dest);
- begin
- Inline(
- $8B/$5E/<ROWS { MOV BX,[BP+<Rows] ;Move number of rows}
- /$8B/$4E/<COLS { MOV CX,[BP+<Cols] ;Move number of cols}
- { ;}
- /$85/$DB { TEST BX,BX ;If Rows<=0 ...}
- /$7E/$63 { JLE Exit ; nothing to do}
- /$85/$C9 { TEST CX,CX ;If Cols<=0 ...}
- /$7E/$5F { JLE Exit ; nothing to do}
- { ;}
- /$31/$D2 { XOR DX,DX ;Set DX=0}
- /$8E/$C2 { MOV ES,DX ;Set ES=0}
- /$26/$8A/$16/$4A/$04 { ES: MOV DL,[$044A] ;Get CRT columns}
- /$8B/$46/<ROW { MOV AX,[BP+<Row] ;Move row in AX}
- /$48 { DEC AX ;Convert to 0-?? range}
- /$F6/$E2 { MUL DL ;(CRT columns)*(Row-1)}
- /$89/$C6 { MOV SI,AX ;Partial offset in SI}
- /$03/$76/<COL { ADD SI,[BP+<Col] ;Add Col}
- /$4E { DEC SI ;Convert to 0-?? range}
- /$D1/$E6 { SHL SI,1 ;Source offset calc'd}
- /$29/$CA { SUB DX,CX ;DX=(CRT columns)-Cols}
- /$D1/$E2 { SHL DX,1 ;Mult by 2}
- /$52 { PUSH DX ;Save # to next row}
- /$51 { PUSH CX ;Save Cols}
- /$1E { PUSH DS ;Save Turbo's DS}
- /$FC { CLD ;Set DF to increment}
- /$C4/$7E/<DEST { LES DI,[BP+<Dest] ;ES:DI points to Dest}
- /$3A/$2E/>QWAIT { CMP CH,[>Qwait] ;Check need for wait}
- /$8E/$1E/>QSEG { MOV DS,[>Qseg] ;DS:SI source pointer}
- /$75/$0C { JNE Color ; use Color routine}
- { ;}
- {; -- Mono routine; Attr, Char and No Wait--}
- /$F2/$A5 {Mono: REP MOVSW ;To dest & inc DI 2}
- /$4B { DEC BX ;Decrement rows left}
- /$74/$29 { JZ Done ;If Rows=0, done}
- /$8B/$4E/$FA { MOV CX,[BP-$06] ;Restore Cols}
- /$01/$D6 { ADD SI,DX ;Source for next row}
- /$EB/$F4 { JMP SHORT Mono ;Next row}
- { ;}
- {; -- Color routine; Attr, Char and Wait --}
- /$BA/$DA/$03 {Color: MOV DX,$03DA ;CGA port}
- /$FA {Col1A: CLI ;Disable interrupts}
- /$EC {E4in: IN AL,DX ;Check CGA status}
- /$A8/$08 { TEST AL,$08 ;If #3 bit set ...}
- /$75/$09 { JNZ ColrB ; skip wait}
- /$D0/$D8 { RCR AL,1 ;If #0 bit set ...}
- /$72/$F7 { JC E4in ; try again for $E4}
- /$EC {E5in: IN AL,DX ;Check CGA status}
- /$D0/$D8 { RCR AL,1 ;If #0 bit clear ...}
- /$73/$FB { JNC E5in ; try again for $E5}
- /$AD {ColrB: LODSW ;Load char & attr}
- /$FB { STI ;Enable interrupts}
- /$AB { STOSW ;Put in dest & inc DI}
- /$E2/$EC { LOOP Col1A ;Loop till CX=0}
- /$4B { DEC BX ;Decrement rows left}
- /$74/$08 { JZ Done ;If Rows=0, done}
- /$8B/$4E/$FA { MOV CX,[BP-$06] ;Restore Cols}
- /$03/$76/$FC { ADD SI,[BP-$04] ;Source for next row}
- /$EB/$E1 { JMP SHORT Col1A ;Next row}
- { ;}
- /$1F {Done: POP DS ;Restore Turbo's DS}
- /$81/$C4/$04/$00 { ADD SP,$0004 ;Restore stack ptr}
- {Exit:}
- );
- end;
-
- { QstoreToScr - restores screen display ver 2.1, 12-09-86 }
- procedure QstoreToScr (Row, Col, Rows, Cols: byte; VAR Source);
- begin
- Inline(
- $8B/$5E/<ROWS { MOV BX,[BP+<Rows] ;Move number of rows}
- /$8B/$4E/<COLS { MOV CX,[BP+<Cols] ;Move number of cols}
- { ;}
- /$85/$DB { TEST BX,BX ;If Rows<=0 ...}
- /$7E/$68 { JLE Exit ; nothing to do}
- /$85/$C9 { TEST CX,CX ;If Cols<=0 ...}
- /$7E/$64 { JLE Exit ; nothing to do}
- { ;}
- /$31/$D2 { XOR DX,DX ;Set DX=0}
- /$8E/$C2 { MOV ES,DX ;Set ES=0}
- /$26/$8A/$16/$4A/$04 { ES: MOV DL,[$044A] ;Get CRT columns}
- /$8B/$46/<ROW { MOV AX,[BP+<Row] ;Move row in AX}
- /$48 { DEC AX ;Convert to 0-?? range}
- /$F6/$E2 { MUL DL ;(CRT columns)*(Row-1)}
- /$89/$C7 { MOV DI,AX ;Partial offset in DI}
- /$03/$7E/<COL { ADD DI,[BP+<Col] ;Add Col}
- /$4F { DEC DI ;Convert to 0-?? range}
- /$D1/$E7 { SHL DI,1 ;Source offset calc'd}
- /$29/$CA { SUB DX,CX ;DX=(CRT columns)-Cols}
- /$D1/$E2 { SHL DX,1 ;Mult by 2}
- /$52 { PUSH DX ;Save # to next row}
- /$51 { PUSH CX ;Save Cols}
- /$1E { PUSH DS ;Save Turbo's DS}
- /$FC { CLD ;Set DF to increment}
- /$3A/$2E/>QWAIT { CMP CH,[>Qwait] ;Check need for wait}
- /$8E/$06/>QSEG { MOV ES,[>Qseg] ;ES:DI screen pointer}
- /$C5/$76/<SOURCE { LDS SI,[BP+<Source] ;DS:SI source pointer}
- /$75/$0C { JNE Color ; use Color routine}
- { ;}
- {; -- Mono routine; Attr, Char and No Wait--}
- /$F2/$A5 {Mono: REP MOVSW ;To dest & inc DI 2}
- /$4B { DEC BX ;Decrement rows left}
- /$74/$2E { JZ Done ;If Rows=0, done}
- /$8B/$4E/$FA { MOV CX,[BP-$06] ;Restore Cols}
- /$01/$D7 { ADD DI,DX ;Dest for next row}
- /$EB/$F4 { JMP SHORT Mono ;Next row}
- { ;}
- {; -- Color routine; Attr, Char and Wait --}
- /$BA/$DA/$03 {Color: MOV DX,$03DA ;CGA port}
- /$AD {Col1A: LODSW ;Load char & attr}
- /$88/$C7 { MOV BH,AL ;Save char in BH}
- /$FA { CLI ;Disable interrupts}
- /$EC {E4in: IN AL,DX ;Check CGA status}
- /$A8/$08 { TEST AL,$08 ;If #3 bit set ...}
- /$75/$09 { JNZ ColrB ; skip wait}
- /$D0/$D8 { RCR AL,1 ;If #0 bit set ...}
- /$72/$F7 { JC E4in ; try again for $E4}
- /$EC {E5in: IN AL,DX ;Check CGA status}
- /$D0/$D8 { RCR AL,1 ;If #0 bit clear ...}
- /$73/$FB { JNC E5in ; try again for $E5}
- /$88/$F8 {ColrB: MOV AL,BH ;Move char back in AL}
- /$AB { STOSW ;Put in dest & inc DI}
- /$FB { STI ;Enable interrupts}
- /$E2/$E8 { LOOP Col1A ;Loop till CX=0}
- /$FE/$CB { DEC BL ;Decrement rows left}
- /$74/$08 { JZ Done ;If Rows=0, done}
- /$8B/$4E/$FA { MOV CX,[BP-$06] ;Restore Cols}
- /$03/$7E/$FC { ADD DI,[BP-$04] ;Dest for next row}
- /$EB/$DC { JMP SHORT Col1A ;Next row}
- { ;}
- /$1F {Done: POP DS ;Restore Turbo's DS}
- /$81/$C4/$04/$00 { ADD SP,$0004 ;Restore stack ptr}
- {Exit:}
- );
- end;
-