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

  1. { This procedure does fast screen writes and automatically configures to
  2.   your machine for Mono, CGA, and EGA.  It also has the feature of suppressing
  3.   the attribute by setting Attr<0; then Qfill will just overwrite the display
  4.   using the current attributes.  The upper left column is 1,1.  Cols can range
  5.   from 1 to 2000 (a full screen).  An example application is a fast screen
  6.   clear or clear EOL. }
  7.  
  8. procedure Qfill (Row, Col: byte; Attr: integer; Ch: char; 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.   /$88/$DC               {       MOV   AH,BL            ;Move attr to AH}
  26.   /$8A/$46/<CH           {       MOV   AL,[BP+<Ch]      ;Move char to AL}
  27.                          {                              ;}
  28.   /$8B/$4E/<COLS         {       MOV   CX,[BP+<Cols]    ;Move number of cols}
  29.   /$85/$C9               {       TEST  CX,CX            ;If CX<=0 ...}
  30.   /$7E/$75               {       JLE   Exit             ;   nothing to do}
  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/$1B               {       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.   /$84/$FF               {EGA:   TEST  BH,BH            ;If Attr<0 ...}
  39.   /$78/$04               {       JS    Mono1            ;  use char only}
  40.                          {                              ;}
  41.                          {; -- Mono routine; Attr, Char and No Wait--}
  42.   /$F2/$AB               {Mono2: REP   STOSW            ;To dest & inc DI 2}
  43.   /$EB/$5F               {       JMP   SHORT Exit       ;Done}
  44.                          {                              ;}
  45.                          {; -- Mono routine; Char Only and No Wait--}
  46.                          {; Algorithm packs in an extra STOSB per LOOP}
  47.   /$41                   {Mono1: INC   CX               ;Bump CX for odd char}
  48.   /$41                   {       INC   CX               ;Bump CX for odd char}
  49.   /$D1/$E9               {       SHR   CX,1             ;Divide counter by 2}
  50.                          {                              ; CF=1 if odd count}
  51.   /$72/$02               {       JC    Mon1b            ;Jump if odd count}
  52.                          {                              ;}
  53.   /$AA                   {Mon1a: STOSB                  ;To dest & inc DI 1}
  54.   /$47                   {       INC   DI               ;Pass up attr}
  55.   /$AA                   {Mon1b: STOSB                  ;To dest & inc DI 1}
  56.   /$47                   {       INC   DI               ;Pass up attr}
  57.   /$E2/$FA               {       LOOP  Mon1a            ;Loop until CX=0}
  58.   /$EB/$51               {       JMP   SHORT Exit       ;Done}
  59.                          {                              ;}
  60.   /$BA/$F6/$B7           {Color: MOV   DX,$B7F6         ;Addr for Color}
  61.   /$8E/$C2               {       MOV   ES,DX            ;ES:DI dest pointer}
  62.   /$79/$E3               {       JNS   EGA              ;If EGA, do Mono}
  63.   /$BA/$DA/$03           {       MOV   DX,$03DA         ;CGA port}
  64.   /$88/$C3               {       MOV   BL,AL            ;Save char in BL}
  65.   /$84/$FF               {       TEST  BH,BH            ;If Attr<0 ...}
  66.   /$78/$22               {       JS    Col1b            ;  use char only}
  67.                          {                              ;}
  68.                          {; -- Color routine; Attr, Char and Wait --}
  69.   /$FA                   {Col2a: CLI                    ;Disable interrupts}
  70.   /$EC                   {E4in2: IN    AL,DX            ;Check CGA status}
  71.   /$A8/$08               {       TEST  AL,$08           ;If #3 bit clear ...}
  72.   /$74/$0A               {       JZ    Col2b            ;  skip tests}
  73.   /$88/$D8               {       MOV   AL,BL            ;Move char back in AL}
  74.   /$81/$F9/$D0/$00       {       CMP   CX,$00D0         ;If <209 Cols left,}
  75.   /$78/$D0               {       JS    Mono2            ;  do mono instead}
  76.   /$EB/$0B               {       JMP   SHORT Col2c      ;  else store direct}
  77.   /$D0/$D8               {Col2b: RCR   AL,1             ;If #0 bit set ...}
  78.   /$72/$ED               {       JC    E4in2            ;  try again for $E4}
  79.   /$EC                   {E5in2: IN    AL,DX            ;Check CGA status}
  80.   /$D0/$D8               {       RCR   AL,1             ;If #0 bit clear ...}
  81.   /$73/$FB               {       JNC   E5in2            ;  try again for $E5}
  82.   /$88/$D8               {       MOV   AL,BL            ;Move char back in AL}
  83.   /$AB                   {Col2c: STOSW                  ;Put in dest & inc DI}
  84.   /$FB                   {       STI                    ;Enable interrupts}
  85.   /$E2/$E1               {       LOOP  Col2a            ;Loop till CX=0}
  86.   /$EB/$20               {       JMP   SHORT Exit       ;Done}
  87.                          {                              ;}
  88.                          {; -- Color routine; Char only and Wait --}
  89.   /$47                   {Col1a: INC   DI               ;Pass up attr}
  90.   /$FA                   {Col1b: CLI                    ;Disable interrupts}
  91.   /$EC                   {E4in1: IN    AL,DX            ;Check CGA status}
  92.   /$A8/$08               {       TEST  AL,$08           ;If #3 bit clear ...}
  93.   /$74/$0A               {       JZ    Col1c            ;  skip tests}
  94.   /$88/$D8               {       MOV   AL,BL            ;Move char back in AL}
  95.   /$81/$F9/$90/$00       {       CMP   CX,$0090         ;If <145 Cols left,}
  96.   /$78/$B2               {       JS    Mono1            ;  do mono instead.}
  97.   /$EB/$0B               {       JMP   SHORT Col1d      ;  else store direct}
  98.   /$D0/$D8               {Col1c: RCR   AL,1             ;If #0 bit set ...}
  99.   /$72/$ED               {       JC    E4in1            ;  try again for $E4}
  100.   /$EC                   {E5in1: IN    AL,DX            ;Check CGA status}
  101.   /$D0/$D8               {       RCR   AL,1             ;If #0 bit clear ...}
  102.   /$73/$FB               {       JNC   E5in1            ;  try again for $E5}
  103.   /$88/$D8               {       MOV   AL,BL            ;Move char back in AL}
  104.   /$AA                   {Col1d: STOSB                  ;Put in dest & inc DI}
  105.   /$FB                   {       STI                    ;Enable interrupts}
  106.   /$E2/$E0               {       LOOP  Col1a            ;Loop till CX=0}
  107.                          {Exit:}
  108. );
  109. end;