home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / QWIK21.ZIP / QFILLS.INC < prev    next >
Encoding:
Text File  |  1986-12-09  |  13.2 KB  |  207 lines

  1. { Qfills.inc - QfillC, Qfill, Qattr, QattrC                 ver 2.1, 12-09-86 }
  2. { This procedure does fast screen writes and automatically configures to
  3.   your machine for Mono, CGA, and EGA.  It also has the feature of leaving the
  4.   attribute alone by setting Attr<0; then Qfill will just overwrite the display
  5.   using the current attributes while Qattr will simply abort the procedure.
  6.   The upper left column is 1,1.  Cols can range from 1 to 80 and Rows from
  7.   1 to 25 (a full screen on 80x25), but EGA can handle more.  Example
  8.   applications for Qfill is a fast screen clear or clear EOL; for Qattr is
  9.   changing the highlighted cursor in pull down menus without the need of a
  10.   string.  Please limit Cols to the number in one row (<200).
  11.   You MUST read MODIFICATIONS in QWIK21.DOC for any changes in this file!     }
  12.  
  13. { QfillC - Quick screen repetitive fill, self-centering     ver 2.0, 11-24-86 }
  14. procedure QfillC (Row, ColL, ColR, Rows, Cols: byte; Attr: integer; Ch: char);
  15. begin
  16. Inline(
  17.    $8B/$46/<ROW          {       MOV   AX,[BP+<Row]     ;Move row}
  18.   /$8B/$7E/<COLL         {       MOV   DI,[BP+<ColL]    ;Move left col}
  19.   /$03/$7E/<COLR         {       ADD   DI,[BP+<ColR]    ;Add right col}
  20.   /$4F                   {       DEC   DI               ;Convert to 0-?? range}
  21.   /$8B/$76/<ROWS         {       MOV   SI,[BP+<Rows]    ;Move number of rows}
  22.   /$8B/$4E/<COLS         {       MOV   CX,[BP+<Cols]    ;Move number of cols}
  23.   /$29/$CF               {       SUB   DI,CX            ;Offset calc'd in DI}
  24.   /$81/$E7/$FE/$FF       {       AND   DI,$FFFE         ;Make even}
  25.   /$8B/$5E/<ATTR         {       MOV   BX,[BP+<Attr]    ;Move attr to BX}
  26.   /$8A/$6E/<CH           {       MOV   CH,[BP+<Ch]      ;Move char to CH}
  27.   /$E8/$38/$00           {       CALL  NEAR Qdisp       ;Call Qdisp, address}
  28.                          {                              ;  is pre-compiled!}
  29. );
  30. end;
  31.  
  32. { Qfill - Quick screen repetitive fill                      ver 2.0, 11-24-86 }
  33. procedure Qfill (Row, Col, Rows, Cols: byte; Attr: integer; Ch: char);
  34. begin
  35. Inline(
  36.    $8B/$46/<ROW          {       MOV   AX,[BP+<Row]     ;Move row}
  37.   /$8B/$7E/<COL          {       MOV   DI,[BP+<Col]     ;Move col}
  38.   /$4F                   {       DEC   DI               ;Convert to 0-?? range}
  39.   /$D1/$E7               {       SHL   DI,1             ;Mult by 2}
  40.   /$8B/$76/<ROWS         {       MOV   SI,[BP+<Rows]    ;Move number of rows}
  41.   /$8A/$4E/<COLS         {       MOV   CL,[BP+<Cols]    ;Move number of cols}
  42.   /$8B/$5E/<ATTR         {       MOV   BX,[BP+<Attr]    ;Move attr to BX}
  43.   /$8A/$6E/<CH           {       MOV   CH,[BP+<Ch]      ;Move char to CH}
  44.   /$E8/$10/$00           {       CALL  NEAR Qdisp       ;Call Qdisp, address}
  45.                          {                              ;  is pre-compiled!}
  46. );
  47. end;
  48.  
  49. { QfillsDisp - Subroutine for all Qfills procedures         ver 2.1, 12-09-86 }
  50. procedure QfillsDisp;
  51. begin
  52. Inline(
  53.    $48                   {Qdisp: DEC   AX               ;Convert to 0-?? range}
  54.   /$31/$D2               {       XOR   DX,DX            ;Set DX=0}
  55.   /$8E/$C2               {       MOV   ES,DX            ;Set ES=0}
  56.   /$26/$8B/$16/$4A/$04   {       ES:   MOV DX,[$044A]   ;Get CRT columns}
  57.   /$F6/$E2               {       MUL   DL               ;(CRT columns)*(Row-1)}
  58.   /$D1/$E0               {       SHL   AX,1             ;Mult by 2}
  59.   /$01/$C7               {       ADD   DI,AX            ;Dest offset in DI}
  60.   /$88/$E8               {       MOV   AL,CH            ;Move attr to AH}
  61.   /$30/$ED               {       XOR   CH,CH            ;Set CH=0}
  62.   /$29/$CA               {       SUB   DX,CX            ;Subract Cols}
  63.   /$D1/$E2               {       SHL   DX,1             ;Mult by 2}
  64.   /$52                   {       PUSH  DX               ;Save # to next row}
  65.   /$51                   {       PUSH  CX               ;Save # of Cols}
  66.                          {                              ;}
  67.   /$85/$F6               {       TEST  SI,SI            ;If Rows<=0 ...}
  68.   /$7E/$31               {       JLE   DoneS            ;   nothing to do}
  69.   /$85/$C9               {       TEST  CX,CX            ;If Cols<=0 ...}
  70.   /$7E/$2D               {       JLE   DoneS            ;   nothing to do}
  71.                          {                              ;}
  72.   /$88/$DC               {       MOV   AH,BL            ;Move attr to AH}
  73.   /$FC                   {       CLD                    ;Set DF to increment}
  74.   /$3A/$2E/>QWAIT        {       CMP   CH,[>Qwait]      ;Check need for wait}
  75.   /$8E/$06/>QSEG         {       MOV   ES,[>Qseg]       ;ES:DI dest pointer}
  76.   /$75/$29               {       JNE   Color            ;  use Color routine}
  77.   /$84/$FF               {       TEST  BH,BH            ;If Attr<0 ...}
  78.   /$78/$0E               {       JS    Mono1            ;  use char only}
  79.                          {                              ;}
  80.                          {; -- Mono routine; Attr, Char and No Wait--}
  81.   /$89/$CA               {       MOV   DX,CX            ;Save Cols in DX}
  82.   /$F2/$AB               {Mono2: REP   STOSW            ;To dest & inc DI 2}
  83.   /$4E                   {       DEC   SI               ;Decrement rows left}
  84.   /$74/$15               {       JZ    DoneS            ;If Rows=0, done}
  85.   /$89/$D1               {       MOV   CX,DX            ;Restore Cols}
  86.   /$03/$7E/$FA           {       ADD   DI,[BP-$06]      ;Dest for next row}
  87.   /$EB/$F4               {       JMP   SHORT Mono2      ;Next row}
  88.                          {                              ;}
  89.                          {; -- Mono routine; Char/Attr Only and No Wait--}
  90.                          {; Algorithm packs in an extra STOSB per LOOP}
  91.   /$41                   {Mono1: INC   CX               ;Bump CX for odd col}
  92.   /$89/$CA               {       MOV   DX,CX            ;Save Cols in DX}
  93.   /$D1/$E9               {Mon1a: SHR   CX,1             ;Divide counter by 2}
  94.                          {                              ; CF=0 if odd count}
  95.   /$73/$02               {       JNC   Mon1c            ;Jump if odd count}
  96.                          {                              ;}
  97.   /$AA                   {Mon1b: STOSB                  ;To dest & inc DI 1}
  98.   /$47                   {       INC   DI               ;Pass up attr/char}
  99.   /$AA                   {Mon1c: STOSB                  ;To dest & inc DI 1}
  100.   /$47                   {       INC   DI               ;Pass up attr/char}
  101.   /$E2/$FA               {       LOOP  Mon1b            ;Loop until CX=0}
  102.   /$4E                   {       DEC   SI               ;Decrement rows left}
  103.   /$7E/$58               {DoneS: JLE   Done             ;If Rows=0, done}
  104.   /$89/$D1               {       MOV   CX,DX            ;Restore Cols}
  105.   /$03/$7E/$FA           {       ADD   DI,[BP-$06]      ;Dest for next row}
  106.   /$EB/$EC               {       JMP   SHORT Mon1a      ;Next row}
  107.                          {                              ;}
  108.   /$BA/$DA/$03           {Color: MOV   DX,$03DA         ;CGA port}
  109.   /$88/$C3               {       MOV   BL,AL            ;Save char in BL}
  110.   /$84/$FF               {       TEST  BH,BH            ;If Attr<0 ...}
  111.   /$78/$27               {       JS    Col1a            ;  use char/attr only}
  112.                          {                              ;}
  113.                          {; -- Color routine; Attr, Char and Wait --}
  114.   /$FA                   {Col2a: CLI                    ;Disable interrupts}
  115.   /$EC                   {E4in2: IN    AL,DX            ;Check CGA status}
  116.   /$A8/$08               {       TEST  AL,$08           ;If #3 bit clear ...}
  117.   /$74/$07               {       JZ    Col2b            ;  check #0 bit.}
  118.   /$88/$D8               {       MOV   AL,BL            ;Move char back in AL}
  119.   /$F2/$AB               {       REP   STOSW            ;Quick storage}
  120.   /$FB                   {       STI                    ;Enable interrupts}
  121.   /$EB/$0F               {       JMP   SHORT Col2c      ;  finished row}
  122.   /$D0/$D8               {Col2b: RCR   AL,1             ;If #0 bit set ...}
  123.   /$72/$F0               {       JC    E4in2            ;  try again for $E4}
  124.   /$EC                   {E5in2: IN    AL,DX            ;Check CGA status}
  125.   /$D0/$D8               {       RCR   AL,1             ;If #0 bit clear ...}
  126.   /$73/$FB               {       JNC   E5in2            ;  try again for $E5}
  127.   /$88/$D8               {       MOV   AL,BL            ;Move char back in AL}
  128.   /$AB                   {       STOSW                  ;Put in dest & inc DI}
  129.   /$FB                   {       STI                    ;Enable interrupts}
  130.   /$E2/$E4               {       LOOP  Col2a            ;Loop till CX=0}
  131.   /$4E                   {Col2c: DEC   SI               ;Decrement rows left}
  132.   /$74/$29               {       JZ    Done             ;If Rows=0, done}
  133.   /$8B/$4E/$F8           {       MOV   CX,[BP-$08]      ;Restore Cols}
  134.   /$03/$7E/$FA           {       ADD   DI,[BP-$06]      ;Dest for next row}
  135.   /$EB/$D9               {       JMP   SHORT Col2a      ;Next row}
  136.                          {                              ;}
  137.                          {; -- Color routine; Char/Attr only and Wait --}
  138.   /$FA                   {Col1a: CLI                    ;Disable interrupts}
  139.   /$EC                   {E4in1: IN    AL,DX            ;Check CGA status}
  140.   /$A8/$08               {       TEST  AL,$08           ;If #3 bit set ...}
  141.   /$75/$09               {       JNZ   Col1b            ;  skip wait.}
  142.   /$D0/$D8               {       RCR   AL,1             ;If #0 bit set ...}
  143.   /$72/$F7               {       JC    E4in1            ;  try again for $E4}
  144.   /$EC                   {E5in1: IN    AL,DX            ;Check CGA status}
  145.   /$D0/$D8               {       RCR   AL,1             ;If #0 bit clear ...}
  146.   /$73/$FB               {       JNC   E5in1            ;  try again for $E5}
  147.   /$88/$D8               {Col1b: MOV   AL,BL            ;Move char/attr in AL}
  148.   /$AA                   {       STOSB                  ;Put in dest & inc DI}
  149.   /$FB                   {       STI                    ;Enable interrupts}
  150.   /$47                   {       INC   DI               ;Pass up attr/char}
  151.   /$E2/$EA               {       LOOP  Col1a            ;Loop till CX=0}
  152.   /$4E                   {       DEC   SI               ;Decrement rows left}
  153.   /$74/$08               {       JZ    Done             ;If Rows=0, done}
  154.   /$8B/$4E/$F8           {       MOV   CX,[BP-$08]      ;Restore Cols}
  155.   /$03/$7E/$FA           {       ADD   DI,[BP-$06]      ;Dest for next row}
  156.   /$EB/$DF               {       JMP   SHORT Col1a      ;Next row}
  157.                          {                              ;}
  158.   /$81/$C4/$04/$00       {Done:  ADD   SP,$0004         ;Restore stack ptr}
  159.   /$C3                   {       RET                    ;Return to call}
  160. );
  161. end;
  162.  
  163. { Qattr - Quick screen attribute change                     ver 2.1, 12-09-86 }
  164. procedure Qattr (Row, Col, Rows, Cols: byte; Attr: integer);
  165. begin
  166. Inline(
  167.    $8B/$46/<ROW          {       MOV   AX,[BP+<Row]     ;Move row}
  168.   /$8B/$7E/<COL          {       MOV   DI,[BP+<Col]     ;Move col}
  169.   /$4F                   {       DEC   DI               ;Convert to 0-?? range}
  170.   /$D1/$E7               {       SHL   DI,1             ;Mult by 2}
  171.   /$47                   {       INC   DI               ;Pass up char}
  172.   /$8B/$76/<ROWS         {       MOV   SI,[BP+<Rows]    ;Move number of rows}
  173.   /$8A/$4E/<COLS         {       MOV   CL,[BP+<Cols]    ;Move number of cols}
  174.   /$8B/$5E/<ATTR         {       MOV   BX,[BP+<Attr]    ;Move attr to BX}
  175.   /$84/$FF               {       TEST  BH,BH            ;If Attr<0 ...}
  176.   /$78/$07               {       JS    Exit1            ;  nothing to do.}
  177.   /$88/$DD               {       MOV   CH,BL            ;Move attr in CH}
  178.   /$B7/$80               {       MOV   BH,$80           ;Make BH negative}
  179.   /$E8/$26/$FF           {       CALL  NEAR Qdisp       ;Call Qdisp, address}
  180.                          {                              ;  is pre-compiled!}
  181.                          {Exit1:}
  182. );
  183. end;
  184.  
  185. { QattrC - Quick screen attribute change, self-centering    ver 2.1, 12-09-86 }
  186. procedure QattrC (Row, ColL, ColR, Rows, Cols: byte; Attr: integer);
  187. begin
  188. Inline(
  189.    $8B/$46/<ROW          {       MOV   AX,[BP+<Row]     ;Move row}
  190.   /$8B/$7E/<COLL         {       MOV   DI,[BP+<ColL]    ;Move left col}
  191.   /$03/$7E/<COLR         {       ADD   DI,[BP+<ColR]    ;Add right col}
  192.   /$4F                   {       DEC   DI               ;Convert to 0-?? range}
  193.   /$8B/$76/<ROWS         {       MOV   SI,[BP+<Rows]    ;Move number of rows}
  194.   /$8B/$4E/<COLS         {       MOV   CX,[BP+<Cols]    ;Move number of cols}
  195.   /$29/$CF               {       SUB   DI,CX            ;Offset calc'd in DI}
  196.   /$81/$CF/$01/$00       {       OR    DI,$0001         ;Make odd;pass up char}
  197.   /$8B/$5E/<ATTR         {       MOV   BX,[BP+<Attr]    ;Move attr to BX}
  198.   /$84/$FF               {       TEST  BH,BH            ;If Attr<0 ...}
  199.   /$78/$07               {       JS    Exit2            ;  nothing to do.}
  200.   /$88/$DD               {       MOV   CH,BL            ;Move attr in CH}
  201.   /$B7/$80               {       MOV   BH,$80           ;Make BH negative}
  202.   /$E8/$F2/$FE           {       CALL  NEAR Qdisp       ;Call Qdisp, address}
  203.                          {                              ;  is pre-compiled!}
  204.                          {Exit2:}
  205. );
  206. end;
  207.