home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / turbopas / qwik42.arc / QWIK42.PAS < prev    next >
Pascal/Delphi Source File  |  1988-10-01  |  9KB  |  229 lines

  1. { =========================================================================== }
  2. { QWIK42.PAS - Unit for quick, direct screen writing        ver 4.2, 10-01-88 }
  3. {  Copyright (c) 1986-1988 James H. LeMay                                     }
  4. { For documentation on this file see QWIK42.DOC and QWIKREF.DOC.              }
  5. { Only 42 bytes of global data is used.                                       }
  6. { =========================================================================== }
  7.  
  8. {$R-,S-,I-,D-,T-,F-,V-,B-,N-,L+ }
  9.  
  10. UNIT Qwik;
  11.  
  12. INTERFACE
  13.  
  14. var
  15.   VideoMode:   byte absolute $0040:$0049; { Video mode: Mono=7, Color=0-3 }
  16.   VideoPage:   byte absolute $0040:$0062; { Video page number }
  17.   EgaRows:     byte absolute $0040:$0084; { Rows on screen (0-based) }
  18.   EgaFontSize: word absolute $0040:$0085; { Character cell height (1-based) }
  19.   EgaInfo:     byte absolute $0040:$0087; { EGA info.  See QWIKREF.DOC }
  20.   CRTcolumns:  word absolute $0040:$004A; { Number of CRT columns (1-based) }
  21.  
  22.   SystemID,                   { Equipment ID.  See QWIKREF.DOC }
  23.   SubModelID,                 { Equipment ID.  See QWIKREF.DOC }
  24.   CpuID,                      { Model number of Intel CPU }
  25.   QvideoMode:        byte;    { Video mode detected by QWIK }
  26.  
  27.   { Keep the following seven variables in order for save pointers. }
  28.   CRTrows,                    { Global variable of Rows/EgaRows (1-based!)}
  29.   CRTcols:           byte;    { Global variable of CRTcolumns (1-based) }
  30.   CRTsize:           word;    { Essentially size of CRT video buffer in bytes }
  31.   Qsnow:             boolean; { Wait-for-retrace (snow) while QWIK writing }
  32.   QEosOfs,                    { End Of String offset after QWIK writing }
  33.   QScrOfs,                    { Screen offset  for QWIK writing, normally = 0 }
  34.   QScrSeg:           word;    { Screen segment for QWIK writing }
  35.  
  36.   QvideoPage,                 { Video page to which QWIK is writing }
  37.   MaxPage:           byte;    { Maximum possible page }
  38.   Page0seg:          word;    { Segment for page 0 for video card/buffer }
  39.   CardSeg:           word;    { Segment for page 0 for video card }
  40.   CardSnow,                   { Wait-for-retrace (snow) for video card }
  41.   HavePS2,                    { Using some type of IBM PS/2 equip }
  42.   Have3270:          boolean; { Using IBM 3270 PC workstation hard/software }
  43.   EgaSwitches,                { EGA card and monitor setup }
  44.   ActiveDispDev,              { Active Display Device }
  45.   ActiveDispDev3270,          { Active Display Device for IBM 3270 PC }
  46.   AltDispDev:        byte;    { Alternate Display Device }
  47.   AltDispDevPCC:     word;    { Alt Display Device for PC Convertible }
  48.   HercModel:         byte;    { Model of Hercules card. }
  49.   ScrollAttr:        integer; { Attribute used to clear row in QEosLn }
  50.  
  51. type
  52.   VScrRecType =
  53.     record
  54.       Vrows,                  { Equivalent to CRTrows }
  55.       Vcols:       byte;      { Equivalent to CRTcols }
  56.       Vsize:       word;      { Equivalent to CRTsize }
  57.       Vsnow:       boolean;   { Equivalent to Qsnow }
  58.       VEosOfs:     word;      { Equivalent to QEosOfs }
  59.       VScrPtr:     pointer;   { Equivalent to QScrPtr }
  60.     end;
  61.  
  62. var
  63.   QScrRec:  VScrRecType absolute CRTrows;
  64.   QScrPtr:  pointer     absolute QScrOfs;
  65.  
  66. const
  67.   { Constants assigned by IBM:      }   { Arbitrarily assigned constants: }
  68.   NoDisplay = $00;   VgaMono   = $07;   NoHerc       = 0;
  69.   MdaMono   = $01;   VgaColor  = $08;   HgcMono      = 1;
  70.   CgaColor  = $02;   DCC9      = $09;   HgcPlus      = 2;
  71.   DCC3      = $03;   DCC10     = $0A;   HercInColor  = 3;
  72.   EgaColor  = $04;   McgaMono  = $0B;
  73.   EgaMono   = $05;   McgaColor = $0C;
  74.   PgcColor  = $06;   Unknown   = $FF;
  75.  
  76.   Cpu8086   = $00;   Cpu80286  = $02;
  77.   Cpu80186  = $01;   Cpu80386  = $03;
  78.  
  79.   { The following duplicates the TP4 CRT unit text color constants which }
  80.   { will automatically be used if the CRT unit is not used. }
  81.   Black        = $00;       DarkGray     = $08;
  82.   Blue         = $01;       LightBlue    = $09;
  83.   Green        = $02;       LightGreen   = $0A;
  84.   Cyan         = $03;       LightCyan    = $0B;
  85.   Red          = $04;       LightRed     = $0C;
  86.   Magenta      = $05;       LightMagenta = $0D;
  87.   Brown        = $06;       Yellow       = $0E;
  88.   LightGray    = $07;       White        = $0F;
  89.   Blink        = $80;
  90.  
  91.   { These are convenient background constants: }
  92.   BlackBG      = $00;   { Only needed for source code clarity. }
  93.   BlueBG       = $10;
  94.   GreenBG      = $20;
  95.   CyanBG       = $30;
  96.   RedBG        = $40;
  97.   MagentaBG    = $50;
  98.   BrownBG      = $60;
  99.   LightGrayBG  = $70;
  100.   SameAttr     =  -1;   { Suppresses attribute changes to the screen }
  101.  
  102.   { The following are constants used in SetCursor and ModCursor }
  103.   CursorOn     = $0000; { Turns cursor on  with same shape }
  104.   CursorOff    = $2000; { Turns cursor off with same shape }
  105.   CursorBlink  = $6000; { Creates erratic blinking for MDA/CGA }
  106.  
  107. var
  108.   { These Cursor modes are set by Qinit as detected for the video card: }
  109.   CursorInitial,              { Cursor detected at startup }
  110.   CursorUnderline,            { Standard underline cursor }
  111.   CursorHalfBlock,            { Usually used for Insert editing }
  112.   CursorBlock:       word;    { For those who have to squint }
  113.  
  114. procedure  Qinit;
  115.  
  116. procedure  Qwrite   (Row,Col: byte; Attr: integer; aStr: string);
  117. procedure  QwriteC  (Row,ColL,ColR: byte; Attr: integer; aStr: string);
  118. procedure  QwriteA  (Row,Col: byte; Attr: integer; ArrayLength: word; VAR aStr);
  119. procedure  QwriteEos  (Attr: integer; aStr: string);
  120. procedure  QwriteEosA (Attr: integer; ArrayLength: word; VAR aStr);
  121.  
  122. procedure  Qfill  (Row,Col,Rows,Cols: byte; Attr: integer; Ch: char);
  123. procedure  Qattr  (Row,Col,Rows,Cols: byte; Attr: integer);
  124. procedure  QfillC (Row,ColL,ColR,Rows,Cols: byte; Attr: integer; Ch: char);
  125. procedure  QattrC (Row,ColL,ColR,Rows,Cols: byte; Attr: integer);
  126. procedure  QfillEos (Rows,Cols: byte; Attr: integer; Ch: char);
  127. procedure  QattrEos (Rows,Cols: byte; Attr: integer);
  128.  
  129. procedure  QstoreToMem (Row,Col,Rows,Cols: byte; VAR Dest);
  130. procedure  QstoreToScr (Row,Col,Rows,Cols: byte; VAR Source);
  131. procedure  QScrToVscr  (Row,Col,Rows,Cols,Vrow,Vcol,Vwidth: byte; VAR VscrPtr);
  132. procedure  QVscrToScr  (Row,Col,Rows,Cols,Vrow,Vcol,Vwidth: byte; VAR VscrPtr);
  133.  
  134. function   QreadStr  (Row,Col,Cols: byte): string;
  135. function   QreadChar (Row,Col: byte): char;
  136. function   QreadAttr (Row,Col: byte): byte;
  137.  
  138. procedure  QscrollUp   (Row,Col,Rows,Cols: byte; BlankAttr: integer);
  139. procedure  QscrollDown (Row,Col,Rows,Cols: byte; BlankAttr: integer);
  140.  
  141. procedure  QviewPage  (PageNum: byte);
  142. procedure  QwritePage (PageNum: byte);
  143.  
  144. function   GetCursor: word;
  145. procedure  SetCursor (Cursor: word);
  146. procedure  ModCursor (Bits13_14: word);
  147. procedure  GotoRC (Row,Col: byte);
  148. function   WhereR: byte;
  149. function   WhereC: byte;
  150.  
  151. procedure  GotoEos;
  152. function   EosR: byte;
  153. function   EosC: byte;
  154. procedure  EosToRC    (Row,Col: byte);
  155. procedure  EosToRCrel (Row,Col: integer);
  156. procedure  EosToCursor;
  157. procedure  EosLn;
  158. procedure  QEosLn;
  159.  
  160. procedure  GetSubModelID;  { Read docs before using! }
  161.  
  162.  
  163. IMPLEMENTATION
  164.  
  165. var
  166.   FirstQinit:  boolean;  { True if Qinit is yet to be run }
  167.  
  168. {$L qinit.obj}
  169. procedure  Qinit;          external;
  170. {$L qwrites.obj}
  171. procedure  Qwrite;         external;
  172. procedure  QwriteC;        external;
  173. procedure  QwriteA;        external;
  174. procedure  QwriteEos;      external;
  175. procedure  QwriteEosA;     external;
  176. {$L qfills.obj}
  177. procedure  Qfill;          external;
  178. procedure  Qattr;          external;
  179. procedure  QfillC;         external;
  180. procedure  QattrC;         external;
  181. procedure  QfillEos;       external;
  182. procedure  QattrEos;       external;
  183. procedure  QfillsDisp3;    external;   { for Qscroll.obj only }
  184. {$L qstores.obj}
  185. procedure  QstoreToMem;    external;
  186. procedure  QstoreToScr;    external;
  187. procedure  QScrToVscr;     external;
  188. procedure  QVscrToScr;     external;
  189. {$L qreads.obj}
  190. function   QreadStr;       external;
  191. function   QreadChar;      external;
  192. function   QreadAttr;      external;
  193. {$L qscrolls.obj}
  194. procedure  QscrollUp;      external;
  195. procedure  QscrollDown;    external;
  196. {$L qpages.obj}
  197. procedure  QviewPage;      external;
  198. procedure  QwritePage;     external;
  199. {$L cursor.obj}
  200. function   GetCursor;      external;
  201. procedure  SetCursor;      external;
  202. procedure  ModCursor;      external;
  203. procedure  GotoRC;         external;
  204. function   WhereR;         external;
  205. function   WhereC;         external;
  206. {$L eos.obj}
  207. procedure  EosRC;          external;   { for QEosLn.obj only }
  208. procedure  GotoEos;        external;
  209. function   EosR;           external;
  210. function   EosC;           external;
  211. procedure  EosToRC;        external;
  212. procedure  EosToRCrel;     external;
  213. procedure  EosToCursor;    external;
  214. procedure  EosLn;          external;
  215. {$L QEosLn.obj}
  216. procedure  QEosLn;         external;
  217. {$L cpuident.obj}
  218. procedure  GetCpuID;       external;  { Near }
  219. {$L getsubid.obj}
  220. procedure  GetSubModelID;  external;  { Read docs before using! }
  221.  
  222.  
  223. BEGIN
  224.   SubModelID := 0;    { Default to 0 }
  225.   FirstQinit := true; { True for first time to be run }
  226.   Qinit;
  227.   GetCpuID;           { Required for Qscroll.obj }
  228. END.
  229.