home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / QWRITE11.ZIP / QATTR.INC < prev    next >
Encoding:
Text File  |  1986-10-30  |  5.2 KB  |  79 lines

  1. { This procedure does fast attributes changes and automatically configures
  2.   to your machine.  For compatability with other Q utilities, setting Attr<0
  3.   will just do nothing.  The upper left column is 1,1.  Cols can range from
  4.   1 to 2000 (a full screen).  An example application is changing the highlight
  5.   cusor in a pull down menu without the need of a string.  }
  6.   
  7.  
  8. procedure Qattr (Row, Col: byte; Attr, Cols: integer);
  9. begin
  10. Inline(
  11.   $31/$C0                {       XOR   AX,AX            ;Set AX=0}
  12.   /$8E/$C0               {       MOV   ES,AX            ;Set ES=0}
  13.   /$8A/$66/<ROW          {       MOV   AH,[BP+<Row]     ;Move row (Row*256)}
  14.   /$D1/$E8               {       SHR   AX,1             ;(Row*128)}
  15.   /$89/$C7               {       MOV   DI,AX            ;Save (Row*128) in DI}
  16.   /$D1/$E8               {       SHR   AX,1             ;(Row*64)}
  17.   /$D1/$E8               {       SHR   AX,1             ;(Row*32)}
  18.   /$01/$C7               {       ADD   DI,AX            ;Save (Row*160) in DI}
  19.   /$8B/$46/<COL          {       MOV   AX,[BP+<Col]     ;Move col}
  20.   /$48                   {       DEC   AX               ;Convert to 0-79 range}
  21.   /$D1/$E0               {       SHL   AX,1             ;Mult by 2}
  22.   /$01/$C7               {       ADD   DI,AX            ;Offset calc'd in DI}
  23.                          {                              ;}
  24.   /$8B/$5E/<ATTR         {       MOV   BX,[BP+<Attr]    ;Move attr to BX}
  25.   /$84/$FF               {       TEST  BH,BH            ;If Attr<0 ....}
  26.   /$78/$4F               {       JS    Exit             ;  nothing to do.}
  27.                          {                              ;}
  28.   /$8B/$4E/<COLS         {       MOV   CX,[BP+<Cols]    ;CX= number of columns}
  29.   /$85/$C9               {       TEST  CX,CX            ;Check for Cols<=0}
  30.   /$7E/$48               {       JLE   Exit             ;No columns}
  31.                          {                              ;}
  32.   /$FC                   {       CLD                    ;Set DF to increment}
  33.   /$26/$80/$3E/$49/$04/$07{      ES: CMP BY[$0449],$07  ;Check video mode}
  34.   /$75/$17               {       JNE   Color            ;  use Color routine}
  35.                          {                              ;}
  36.   /$BA/$F6/$AF           {       MOV   DX,$AFF6         ;Addr for Mono}
  37.   /$8E/$C2               {       MOV   ES,DX            ;ES:DI dest pointer}
  38.                          {                              ;}
  39.                          {; -- Mono routine; Attr Only and No Wait--}
  40.   /$47                   {EGA:   INC   DI               ;Pass up char}
  41.   /$88/$D8               {MonoA: MOV   AL,BL            ;Move attr to AL}
  42.   /$D1/$E9               {       SHR   CX,1             ;Divide counter by 2}
  43.   /$73/$04               {       JNC   MonoC            ;Jump if even}
  44.   /$41                   {       INC   CX               ;Bump CX for odd char}
  45.   /$EB/$03               {       JMP   SHORT MonoD      ;Jump into mono loop}
  46.                          {                              ;}
  47.   /$47                   {MonoB: INC   DI               ;Pass up char}
  48.   /$AA                   {MonoC: STOSB                  ;To dest & inc DI 1}
  49.   /$47                   {       INC   DI               ;Pass up char}
  50.   /$AA                   {MonoD: STOSB                  ;To dest & inc DI 1}
  51.   /$E2/$FA               {       LOOP  MonoB            ;Loop until CX=0}
  52.   /$EB/$28               {       JMP   SHORT Exit       ;Done}
  53.                          {                              ;}
  54.   /$BA/$F6/$B7           {Color: MOV   DX,$B7F6         ;Addr for Color}
  55.   /$8E/$C2               {       MOV   ES,DX            ;ES:DI dest pointer}
  56.   /$79/$E7               {       JNS   EGA              ;If EGA, do Mono}
  57.   /$BA/$DA/$03           {       MOV   DX,$03DA         ;CGA port}
  58.                          {                              ;}
  59.                          {; -- Color routine; Attr only and Wait --}
  60.   /$47                   {ColrA: INC   DI               ;Pass up char}
  61.   /$FA                   {       CLI                    ;Disable interrupts}
  62.   /$EC                   {E4in:  IN    AL,DX            ;Check CGA status}
  63.   /$A8/$08               {       TEST  AL,$08           ;If #3 bit clear ...}
  64.   /$74/$08               {       JZ    ColrB            ;  skip tests}
  65.   /$81/$F9/$90/$00       {       CMP   CX,$0090         ;If <145 Cols left,}
  66.   /$78/$D8               {       JS    MonoA            ;  do mono instead.}
  67.   /$EB/$09               {       JMP   SHORT ColrC      ;  else store direct}
  68.   /$D0/$D8               {ColrB: RCR   AL,1             ;If #0 bit set ...}
  69.   /$72/$EF               {       JC    E4in             ;  try again for $E4}
  70.   /$EC                   {E5in:  IN    AL,DX            ;Check CGA status}
  71.   /$D0/$D8               {       RCR   AL,1             ;If #0 bit clear ...}
  72.   /$73/$FB               {       JNC   E5in             ;  try again for $E5}
  73.   /$88/$D8               {ColrC: MOV   AL,BL            ;Move attr back in AL}
  74.   /$AA                   {       STOSB                  ;Put in dest & inc DI}
  75.   /$FB                   {       STI                    ;Enable interrupts}
  76.   /$E2/$E2               {       LOOP  ColrA            ;Loop till CX=0}
  77.                          {Exit:}
  78. );
  79. end;