home *** CD-ROM | disk | FTP | other *** search
- { This procedure does fast attributes changes and automatically configures
- to your machine. For compatability with other Q utilities, setting Attr<0
- will just do nothing. The upper left column is 1,1. Cols can range from
- 1 to 2000 (a full screen). An example application is changing the highlight
- cusor in a pull down menu without the need of a string. }
-
-
- procedure Qattr (Row, Col: byte; Attr, Cols: integer);
- begin
- Inline(
- $31/$C0 { XOR AX,AX ;Set AX=0}
- /$8E/$C0 { MOV ES,AX ;Set ES=0}
- /$8A/$66/<ROW { MOV AH,[BP+<Row] ;Move row (Row*256)}
- /$D1/$E8 { SHR AX,1 ;(Row*128)}
- /$89/$C7 { MOV DI,AX ;Save (Row*128) in DI}
- /$D1/$E8 { SHR AX,1 ;(Row*64)}
- /$D1/$E8 { SHR AX,1 ;(Row*32)}
- /$01/$C7 { ADD DI,AX ;Save (Row*160) in DI}
- /$8B/$46/<COL { MOV AX,[BP+<Col] ;Move col}
- /$48 { DEC AX ;Convert to 0-79 range}
- /$D1/$E0 { SHL AX,1 ;Mult by 2}
- /$01/$C7 { ADD DI,AX ;Offset calc'd in DI}
- { ;}
- /$8B/$5E/<ATTR { MOV BX,[BP+<Attr] ;Move attr to BX}
- /$84/$FF { TEST BH,BH ;If Attr<0 ....}
- /$78/$4F { JS Exit ; nothing to do.}
- { ;}
- /$8B/$4E/<COLS { MOV CX,[BP+<Cols] ;CX= number of columns}
- /$85/$C9 { TEST CX,CX ;Check for Cols<=0}
- /$7E/$48 { JLE Exit ;No columns}
- { ;}
- /$FC { CLD ;Set DF to increment}
- /$26/$80/$3E/$49/$04/$07{ ES: CMP BY[$0449],$07 ;Check video mode}
- /$75/$17 { JNE Color ; use Color routine}
- { ;}
- /$BA/$F6/$AF { MOV DX,$AFF6 ;Addr for Mono}
- /$8E/$C2 { MOV ES,DX ;ES:DI dest pointer}
- { ;}
- {; -- Mono routine; Attr Only and No Wait--}
- /$47 {EGA: INC DI ;Pass up char}
- /$88/$D8 {MonoA: MOV AL,BL ;Move attr to AL}
- /$D1/$E9 { SHR CX,1 ;Divide counter by 2}
- /$73/$04 { JNC MonoC ;Jump if even}
- /$41 { INC CX ;Bump CX for odd char}
- /$EB/$03 { JMP SHORT MonoD ;Jump into mono loop}
- { ;}
- /$47 {MonoB: INC DI ;Pass up char}
- /$AA {MonoC: STOSB ;To dest & inc DI 1}
- /$47 { INC DI ;Pass up char}
- /$AA {MonoD: STOSB ;To dest & inc DI 1}
- /$E2/$FA { LOOP MonoB ;Loop until CX=0}
- /$EB/$28 { JMP SHORT Exit ;Done}
- { ;}
- /$BA/$F6/$B7 {Color: MOV DX,$B7F6 ;Addr for Color}
- /$8E/$C2 { MOV ES,DX ;ES:DI dest pointer}
- /$79/$E7 { JNS EGA ;If EGA, do Mono}
- /$BA/$DA/$03 { MOV DX,$03DA ;CGA port}
- { ;}
- {; -- Color routine; Attr only and Wait --}
- /$47 {ColrA: INC DI ;Pass up char}
- /$FA { CLI ;Disable interrupts}
- /$EC {E4in: IN AL,DX ;Check CGA status}
- /$A8/$08 { TEST AL,$08 ;If #3 bit clear ...}
- /$74/$08 { JZ ColrB ; skip tests}
- /$81/$F9/$90/$00 { CMP CX,$0090 ;If <145 Cols left,}
- /$78/$D8 { JS MonoA ; do mono instead.}
- /$EB/$09 { JMP SHORT ColrC ; else store direct}
- /$D0/$D8 {ColrB: RCR AL,1 ;If #0 bit set ...}
- /$72/$EF { 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/$D8 {ColrC: MOV AL,BL ;Move attr back in AL}
- /$AA { STOSB ;Put in dest & inc DI}
- /$FB { STI ;Enable interrupts}
- /$E2/$E2 { LOOP ColrA ;Loop till CX=0}
- {Exit:}
- );
- end;