home *** CD-ROM | disk | FTP | other *** search
- { Qwrites.inc - QwriteLV, QwriteV, Qwrite, QwriteC, QwriteCV v 2.1, 12-09-86 }
- { These five procedures do fast screen writes and automatically configure to
- your machine for Mono, CGA, and EGA. They also has the feature of leaving
- the attribute alone by setting Attr<0; then they will just overwrite the
- display using the current attributes. The upper left column is 1,1.
- You MUST read MODIFICATIONS in QWIK21.DOC for any changes in this file! }
-
- { QwriteLV - Quick screen write, specified Length, untyped VAR parameter }
- { ver 2.1, 12-09-86 }
- { Unlike other QwriteXX procedures, this one lets you specify both Length and }
- { starting index for partial strings. All other procedures assume length is }
- { the value in St[0] and the index points to St[1]. }
- procedure QwriteLV (Row, Col: byte; Attr, Length: integer; VAR St);
- begin
- Inline(
- $8B/$4E/<LENGTH { MOV CX,[BP+<Length] ;Move length in CX}
- /$85/$C9 { TEST CX,CX ;If CX<=0,}
- /$7E/$18 { JLE Exit0 ; nothing to do.}
- /$1E { PUSH DS ;Save Turbo's DS}
- /$C5/$76/<ST { LDS SI,[BP+<St] ;Place offset in SI}
- /$FC { CLD ;Set DF to increment}
- /$AC { LODSB ;Load St[i]}
- /$88/$C4 { MOV AH,AL ;Move St[i] to AH}
- /$8B/$56/<ROW { MOV DX,[BP+<Row] ;Move row in DX}
- /$8B/$7E/<COL { MOV DI,[BP+<Col] ;Move col in DI}
- /$4F { DEC DI ;Convert to 0-?? range}
- /$D1/$E7 { SHL DI,1 ;Mult by 2}
- /$8B/$5E/<ATTR { MOV BX,[BP+<Attr] ;Move attr in BX}
- /$E8/$71/$00 { CALL NEAR Qdisp ;Call Qdisp, address}
- { ; is pre-compiled!}
- /$1F { POP DS ;Restore Turbo's DS}
- {Exit0: ;}
- );
- end;
-
- { QwriteV - Quick screen write, untyped VAR parameter ver 2.0, 11-24-86 }
- procedure QwriteV (Row, Col: byte; Attr: integer; VAR St);
- begin
- Inline(
- $1E { PUSH DS ;Save Turbo's DS}
- /$C5/$76/<ST { LDS SI,[BP+<St] ;Place offset in SI}
- /$FC { CLD ;Set DF to increment}
- /$AD { LODSW ;Load St[1],St[0]}
- /$31/$C9 { XOR CX,CX ;Set CX=0}
- /$00/$C1 { ADD CL,AL ;Save length in CL}
- /$74/$0F { JZ Exit1 ;Null string}
- /$8B/$56/<ROW { MOV DX,[BP+<Row] ;Move row in DX}
- /$8B/$7E/<COL { MOV DI,[BP+<Col] ;Move col in DI}
- /$4F { DEC DI ;Convert to 0-?? range}
- /$D1/$E7 { SHL DI,1 ;Mult by 2}
- /$8B/$5E/<ATTR { MOV BX,[BP+<Attr] ;Move attr}
- /$E8/$45/$00 { CALL NEAR Qdisp ;Call Qdisp, address}
- { ; is pre-compiled!}
- /$1F {Exit1: POP DS ;Restore Turbo's DS}
- );
- end;
-
- { Qwrite - Quick screen write, value parameter ver 2.0, 11-24-86 }
- procedure Qwrite (Row, Col: byte; Attr: integer; St: Str80);
- begin
- Inline(
- $1E { PUSH DS ;Save Turbo's DS}
- /$8D/$B6/>ST { LEA SI,[BP+>St] ;Place offset in SI}
- /$8C/$D2 { MOV DX,SS ;Move SS into DS for}
- /$8E/$DA { MOV DS,DX ; use by LODS}
- /$FC { CLD ;Set DF to increment}
- /$AD { LODSW ;Load St[1],St[0]}
- /$31/$C9 { XOR CX,CX ;Set CX=0}
- /$00/$C1 { ADD CL,AL ;Save length in CL}
- /$74/$12 { JZ Exit2 ;Null string}
- /$8B/$96/>ROW { MOV DX,[BP+>Row] ;Move row in DX}
- /$8B/$BE/>COL { MOV DI,[BP+>Col] ;Move col in DI}
- /$4F { DEC DI ;Convert to 0-?? range}
- /$D1/$E7 { SHL DI,1 ;Mult by 2}
- /$8B/$9E/>ATTR { MOV BX,[BP+>Attr] ;Move attr}
- /$E8/$11/$00 { CALL NEAR Qdisp ;Call Qdisp, address}
- { ; is pre-compiled!}
- /$1F {Exit2: POP DS ;Restore Turbo's DS}
- );
- end;
-
- { QwritesDisp - Subroutine for all QwriteXX procedures ver 2.1, 12-09-86 }
- procedure QwritesDisp;
- begin
- Inline(
- $4A {Qdisp: DEC DX ;Convert to 0-?? range}
- /$88/$E6 { MOV DH,AH ;Save St[1] in DH}
- /$31/$C0 { XOR AX,AX ;Set AX=0}
- /$8E/$C0 { MOV ES,AX ;Set ES=0}
- /$26/$A1/$4A/$04 { ES: MOV AX,[$044A] ;Get CRT columns}
- /$F6/$E2 { MUL DL ;(CRT columns)*(Row-1)}
- /$D1/$E0 { SHL AX,1 ;Mult by 2}
- /$01/$C7 { ADD DI,AX ;Dest offset in DI}
- /$88/$DC { MOV AH,BL ;Move attr to AH}
- /$88/$F0 { MOV AL,DH ;Move St[1] to AL}
- /$8E/$46/$FC { MOV ES,[BP-$04] ;Copy DS in ES}
- /$26/$80/$3E/>QWAIT/$00{ ES: CMP BY[>Qwait],$00 ;Check need for wait}
- /$26/$8E/$06/>QSEG { ES: MOV ES,[>Qseg] ;ES:DI dest pointer}
- /$75/$32 { JNE Color ; use Color routine}
- { ;}
- /$84/$FF { TEST BH,BH ;If Attr<0 ...}
- /$78/$16 { JS Mono1 ; use char only}
- { ;}
- {; -- Mono routine; Attr, Char and No Wait--}
- {; Algorithm packs in an extra STOSW per LOOP}
- /$41 {Mono2: INC CX ;Bump CX for odd char}
- /$D1/$E9 { SHR CX,1 ;Divide counter by 2}
- { ; CF=0 if odd length}
- /$EB/$08 { JMP SHORT Mon2b ;Jump into mono loop}
- { ;}
- /$AD {Mon2a: LODSW ;Load TWO char}
- /$88/$E7 { MOV BH,AH ;Move Ch2 to BH}
- /$88/$DC { MOV AH,BL ;Copy attr to AH}
- /$AB { STOSW ;To dest & inc DI 2}
- /$88/$F8 { MOV AL,BH ;Move Ch2 to AL}
- /$AB {Mon2b: STOSW ;To dest & inc DI 2}
- /$E2/$F5 { LOOP Mon2a ;Loop until CX=0}
- /$73/$6C { JNC Done ;Exit if odd length}
- /$AC { LODSB ;Load last char}
- /$AB { STOSW ;To dest & inc DI 2}
- /$EB/$68 { JMP SHORT Done ;Done}
- { ;}
- {; -- Mono routine; Char Only and No Wait--}
- {; Algorithm packs in an extra STOSB per LOOP}
- /$41 {Mono1: INC CX ;Bump CX for odd char}
- /$89/$CA { MOV DX,CX ;Save CX in DX}
- /$D1/$E9 { SHR CX,1 ;Divide counter by 2}
- /$EB/$05 { JMP SHORT Mon1b ;Jump into mono loop}
- { ;}
- /$AD {Mon1a: LODSW ;Load TWO char}
- /$AA { STOSB ;To dest & inc DI 1}
- /$47 { INC DI ;Pass up attr}
- /$88/$E0 { MOV AL,AH ;Move Ch2 to AL}
- /$AA {Mon1b: STOSB ;To dest & inc DI 1}
- /$47 { INC DI ;Pass up attr}
- /$E2/$F7 { LOOP Mon1a ;Loop until CX=0}
- /$D1/$EA { SHR DX,1 ;Divide counter by 2}
- { ;CF=0 if odd length}
- /$73/$54 { JNC Done ;Exit if odd length}
- /$AC { LODSB ;Load last char}
- /$AA { STOSB ;To dest & inc DI 1}
- /$EB/$50 { JMP SHORT Done ;Done}
- { ;}
- /$BA/$DA/$03 {Color: MOV DX,$03DA ;CGA port}
- /$84/$FF { TEST BH,BH ;If Attr<0 ...}
- /$78/$29 { JS Col1b ; use char only}
- /$88/$DC { MOV AH,BL ;Move attr in AH}
- /$EB/$01 { JMP SHORT Col2b ;Attr and char}
- { ;}
- {; -- Color routine; Attr, Char and Wait --}
- /$AC {Col2a: LODSB ;Load source char}
- /$88/$C7 {Col2b: MOV BH,AL ;Save char in BH}
- /$FA { CLI ;Disable interrupts}
- /$EC {E4in2: IN AL,DX ;Check CGA status}
- /$A8/$08 { TEST AL,$08 ;If #3 bit clear ...}
- /$74/$09 { JZ Col2c ; check #0 bit.}
- /$88/$F8 { MOV AL,BH ;Move char back in AL}
- /$80/$F9/$90 { CMP CL,$90 ;If <145 Cols left,}
- /$78/$B7 { JS Mono2 ; do mono instead}
- /$EB/$0B { JMP SHORT Col2d ; else store direct}
- /$D0/$D8 {Col2c: RCR AL,1 ;If #0 bit set ...}
- /$72/$EE { JC E4in2 ; try again for $E4}
- /$EC {E5in2: IN AL,DX ;Check CGA status}
- /$D0/$D8 { RCR AL,1 ;If #0 bit clear ...}
- /$73/$FB { JNC E5in2 ; try again for $E5}
- /$88/$F8 { MOV AL,BH ;Move char back in AL}
- /$AB {Col2d: STOSW ;Put in dest & inc DI}
- /$FB { STI ;Enable interrupts}
- /$E2/$DF { LOOP Col2a ;Loop till CX=0}
- /$EB/$22 { JMP SHORT Done ;Done}
- { ;}
- {; -- Color routine; Char only and Wait --}
- /$AC {Col1a: LODSB ;Load source char}
- /$47 { INC DI ;Pass up attr}
- /$88/$C7 {Col1b: MOV BH,AL ;Save char in BH}
- /$FA { CLI ;Disable interrupts}
- /$EC {E4in1: IN AL,DX ;Check CGA status}
- /$A8/$08 { TEST AL,$08 ;If #3 bit clear ...}
- /$74/$09 { JZ Col1c ; check #0 bit.}
- /$88/$F8 { MOV AL,BH ;Move char back in AL}
- /$80/$F9/$80 { CMP CL,$80 ;If <129 Cols left,}
- /$78/$A9 { JS Mono1 ; do mono instead.}
- /$EB/$0B { JMP SHORT Col1d ; else store direct}
- /$D0/$D8 {Col1c: RCR AL,1 ;If #0 bit set ...}
- /$72/$EE { JC E4in1 ; try again for $E4}
- /$EC {E5in1: IN AL,DX ;Check CGA status}
- /$D0/$D8 { RCR AL,1 ;If #0 bit clear ...}
- /$73/$FB { JNC E5in1 ; try again for $E5}
- /$88/$F8 { MOV AL,BH ;Move char back in AL}
- /$AA {Col1d: STOSB ;Put in dest & inc DI}
- /$FB { STI ;Enable interrupts}
- /$E2/$DE { LOOP Col1a ;Loop till CX=0}
- { ;}
- /$FB {Done: STI ;Enable interrupts}
- /$C3 { RET ;Return to call}
- );
- end;
-
- { QwriteC - Quick screen write, self-centering, value param v 2.1, 12-09-86 }
- procedure QwriteC (Row, ColL, ColR: byte; Attr: integer; St: Str80);
- begin
- Inline(
- $1E { PUSH DS ;Save Turbo's DS}
- /$8D/$B6/>ST { LEA SI,[BP+>St] ;Place offset in SI}
- /$8C/$D2 { MOV DX,SS ;Move SS into DS for}
- /$8E/$DA { MOV DS,DX ; use by LODS}
- /$FC { CLD ;Set DF to increment}
- /$AD { LODSW ;Load St[1],St[0]}
- /$31/$C9 { XOR CX,CX ;Set CX=0}
- /$00/$C1 { ADD CL,AL ;Save length in CL}
- /$74/$1A { JZ Exit3 ;Null string}
- /$8B/$96/>ROW { MOV DX,[BP+>Row] ;Move row in DX}
- /$8B/$BE/>COLL { MOV DI,[BP+>ColL] ;Move col in DI}
- /$03/$BE/>COLR { ADD DI,[BP+>ColR] ;Add right col}
- /$4F { DEC DI ;Convert to 0-?? range}
- /$29/$CF { SUB DI,CX ;Offset calc'd in DI}
- /$81/$E7/$FE/$FF { AND DI,$FFFE ;Make even}
- /$8B/$9E/>ATTR { MOV BX,[BP+>Attr] ;Move attr}
- /$E8/$1E/$FF { CALL NEAR Qdisp ;Call Qdisp, address}
- { ; is pre-compiled!}
- /$1F {Exit3: POP DS ;Restore Turbo's DS}
- );
- end;
-
- { QwriteCV - Quick screen write, self-centering, untyped VAR parameter
- ver 2.1, 12-09-86 }
- procedure QwriteCV (Row, ColL, ColR: byte; Attr: integer; VAR St);
- begin
- Inline(
- $1E { PUSH DS ;Save Turbo's DS}
- /$C5/$76/<ST { LDS SI,[BP+<St] ;Place offset in SI}
- /$FC { CLD ;Set DF to increment}
- /$AD { LODSW ;Load St[1],St[0]}
- /$31/$C9 { XOR CX,CX ;Set CX=0}
- /$00/$C1 { ADD CL,AL ;Save length in CL}
- /$74/$16 { JZ Exit4 ;Null string}
- /$8B/$56/<ROW { MOV DX,[BP+<Row] ;Move row in DX}
- /$8B/$7E/<COLL { MOV DI,[BP+<ColL] ;Move col in DI}
- /$03/$7E/<COLR { ADD DI,[BP+<ColR] ;Add right col}
- /$4F { DEC DI ;Convert to 0-?? range}
- /$29/$CF { SUB DI,CX ;Offset calc'd in DI}
- /$81/$E7/$FE/$FF { AND DI,$FFFE ;Make even}
- /$8B/$5E/<ATTR { MOV BX,[BP+<Attr] ;Move attr}
- /$E8/$EB/$FE { CALL NEAR Qdisp ;Call Qdisp, address}
- { ; is pre-compiled!}
- /$1F {Exit4: POP DS ;Restore Turbo's DS}
- );
- end;
-