GRQRY.MOD 56 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558
  1. (******************************************************************************)
  2. (* GRQUERY.MOD - Procedure to Qualify "GrafixCard and "CommPort" *)
  3. (* *)
  4. (* Taken from GRQUERY.C by Metagraphics Software Corporation *)
  5. (* Translated to TopSpeed Modula-2 v3.00. *)
  6. (* *)
  7. (* PSW 10/31/90 01:49am *)
  8. (******************************************************************************)
  9. IMPLEMENTATION MODULE GrQry;
  10. (*
  11. * Graphix
  12. * Release 3.7
  13. * (c) Copyright 1986-1992 PMI
  14. * Green Bay, Wisconsin
  15. * (414) 468-6040
  16. * All rights reserved
  17. *
  18. *)
  19. (******************************************************************************)
  20. (* This procedure, in conjunction with QueryGrafix and QueryComm, is used to *)
  21. (* dynamically determine and set the graphics hardware configuration for *)
  22. (* MetaWINDOW use. *)
  23. (* *)
  24. (* In certain configurations it is possible to have multiple display adaptors *)
  25. (* installed in one PC, or in some cases one display adaptor supports multiple*)
  26. (* operating modes. For these cases the response from QueryGrafix() and *)
  27. (* QueryComm() cannot be used directly for the InitGrafix() or InitMouse() *)
  28. (* calls. Procedure GrQuery() qualifies the QueryGrafix() and QueryComm() *)
  29. (* responses to select the initial graphics card and comm port for MetaWINDOW *)
  30. (* use. *)
  31. (* *)
  32. (* A secondary function of this routine is to allow the operator to specify *)
  33. (* overriding graphic card and mouse settings from the program startup command*)
  34. (* line. This is useful to cover situations when working with "compatible" *)
  35. (* graphics cards which are not fully recognized by the MetaWINDOW routines. *)
  36. (* IF the hardware design of a "compatible" adaptor is not exactly the same *)
  37. (* as one of the MetaWINDOW supported cards, QueryGrafix may not return the *)
  38. (* proper expected results (this usually occurs if the adaptor supports *)
  39. (* special "extended" features, or in multiple monitor systems). Also the *)
  40. (* operator may choose to override the default mouse comm port. Selections may*)
  41. (* be made from the command line, or from the environment variable called *)
  42. (* METAPARM The logic is: *)
  43. (* *)
  44. (* Commmand line option ? *)
  45. (* | | *)
  46. (* yes no, check for environment var *)
  47. (* | | *)
  48. (* | Env var METAPARM set ? *)
  49. (* | | | *)
  50. (* | yes no, Do Queryfunctions *)
  51. (* | | | *)
  52. (* +------+--------+ *)
  53. (* | *)
  54. (* Parse result *)
  55. (* | *)
  56. (* Is a ";" present ? (ie, no wait option) *)
  57. (* | | *)
  58. (* yes no, Invoke Confirm screen, *)
  59. (* | | *)
  60. (* | D or I entered before time out ? *)
  61. (* | | | *)
  62. (* | no yes, Do menus *)
  63. (* | | | *)
  64. (* | |-----------+ *)
  65. (* | | *)
  66. (* Continue with application *)
  67. (* | *)
  68. (* v *)
  69. (* *)
  70. (* GrQuery should be included (or linked) within the code module of your *)
  71. (* main program. Variables are passed as VAR parameters to GrQuery(). *)
  72. (* *)
  73. (* VAR *)
  74. (* GrafixCard, CommPort: INTEGER; *)
  75. (* *)
  76. (* BEGIN *)
  77. (* : *)
  78. (* GrQuery(GrafixCard, CommPort); *)
  79. (* Meta.InitGrafix(-GrafixCard); *)
  80. (* Meta.InitMouse(CommPort); *)
  81. (* : *)
  82. (* END *)
  83. (* *)
  84. (******************************************************************************)
  85. IMPORT Meta;
  86. IMPORT GrConst;
  87. IMPORT Lib;
  88. IMPORT Str;
  89. IMPORT IO;
  90. CONST
  91. (*** Set GRQtrim = TRUE to remove menu selection code ***)
  92. GRQtrim = FALSE;
  93. (*** Set DOSDISP = TRUE to use very simple text output code ***)
  94. (*** Ensure that GRQtrim is TRUE if DOSDISP is TRUE. ***)
  95. DOSDISP = FALSE;
  96. (*** Set SMALLMENU = TRUE to use the smaller selection of devices available ***)
  97. (*** with MetaWINDOW 3.7c, FALSE for MetaWINDOW/Plus. ***)
  98. SMALLMENU = FALSE;
  99. THORZLINE = '-'; (* ASCII Terminal box characters *)
  100. TVERTLINE = '|';
  101. TLEFTTCORN = '*';
  102. TRIGHTTCORN = '*';
  103. TLEFTBCORN = '*';
  104. TRIGHTBCORN = '*';
  105. TLEFTTEE = '*';
  106. TRIGHTTEE = '*';
  107. HORZLINE = 205; (* Extended ansi box characters *)
  108. VERTLINE = 186;
  109. LEFTTCORN = 201;
  110. RIGHTTCORN = 187;
  111. LEFTBCORN = 200;
  112. RIGHTBCORN = 188;
  113. LEFTTEE = 204;
  114. RIGHTTEE = 185;
  115. (* Menu selection title string *)
  116. GRQTITLE = 'Confirm Graphic Devices';
  117. (* Terminated or exit message *)
  118. GRQQUITSTR = 'MetaWINDOW terminated.';
  119. (* The menu header. Insert your own message here. *)
  120. GRQHDRSTR = 'MetaWINDOW for TopSpeed Modula-2';
  121. GRQDELAY = 180; (* Time out delay in system clock *)
  122. (* ticks (18.2 per sec), 0 = forever *)
  123. GrQLines = 25; (* Maximum number of lines on the *)
  124. (* screen, when GRQtrim TRUE *)
  125. CNORMAL = 1700H; (* Attribute values for set_attr - *)
  126. CINVERSE = 7000H; (* color display. *)
  127. CHILITE = 1F00H;
  128. MNORMAL = 0700H; (* Attribute values for set_attr - *)
  129. MINVERSE = 7000H; (* mono display. *)
  130. MHILITE = 0F00H;
  131. kESC = 1BH; (* Key codes. *)
  132. kCR = 0DH;
  133. Home = 71;
  134. End = 79;
  135. PgDn = 81;
  136. PgUp = 73;
  137. UP_arr = 72;
  138. LF_arr = 75;
  139. DN_arr = 80;
  140. RT_arr = 77;
  141. TOP = -2; (* Miscellaneous. *)
  142. BOT = -3;
  143. SUP = 06H;
  144. SDOWN = 07H;
  145. GRQMAXLEN = 127;
  146. GRQLINLEN = 80;
  147. TYPE
  148. txAttr = RECORD (* Text attribute values for text *)
  149. normal: WORD; (* color vs mono screens. *)
  150. inverse: WORD;
  151. hilite: WORD;
  152. END;
  153. device = RECORD (* Device information. *)
  154. devslash: ARRAY[0..3] OF CHAR;
  155. devnum: INTEGER;
  156. devdesc: ARRAY[0..34] OF CHAR;
  157. devhres: CARDINAL;
  158. devvres: CARDINAL;
  159. devcolors:INTEGER;
  160. END;
  161. iDevTab = ARRAY[0..6] OF device; (* Input device table. *)
  162. (*%T SMALLMENU *)
  163. TYPE
  164. oDevTab = ARRAY[0..18] OF device; (* Output device table. *)
  165. CONST
  166. oDev = oDevTab (
  167. device("w:1", GrConst.WYS640x400, " Amdek 1280", 640, 400, 0),
  168. device("a:1", GrConst.ATT640x400, " Compaq Plasma & AT&T ", 640, 400, 0),
  169. device("g", GrConst.GEN640x480, " Genoa, SuperEGA 4880", 640, 480, 16),
  170. device("h", GrConst.HER720x348, " Hercules, Monographics", 720, 348, 0),
  171. device("c:1", GrConst.CGA640x200, " IBM, CGA", 640, 200, 2),
  172. device("c:2", GrConst.CGA320x200, " IBM, CGA", 320, 200, 4),
  173. device("e:1", GrConst.EGAMono, " IBM, EGA", 640, 350, 0),
  174. device("e:2", GrConst.EGA320x200, " IBM, EGA", 320, 200, 16),
  175. device("e:3", GrConst.EGA640x200, " IBM, EGA", 640, 200, 16),
  176. device("e:4", GrConst.EGA640x350, " IBM, EGA", 640, 350, 16),
  177. device("e:5", GrConst.MGA640x480, " IBM, MCGA", 640, 480, 2),
  178. device("e:6", GrConst.MGA640x350, " IBM, EGA", 640, 350, 2),
  179. device("e:7", GrConst.EGA640x480, " IBM, VGA", 640, 480, 16),
  180. device("l:2", GrConst.PAR640x480, " Paradise, Autoswitch EGA/480", 640, 480, 16),
  181. device("o", GrConst.TOS640x400, " Toshiba, 3100", 640, 400, 0),
  182. device("l:1", GrConst.EVA640x480, " Tseng Labs, EVA-480", 640, 480, 16),
  183. device("u:1", GrConst.VGA640x480, " Video Seven, VEGA/Deluxe", 640, 480, 16),
  184. device("w:1", GrConst.WYS640x400, " Wyse, WY-700", 640, 400, 0),
  185. device("", 0, "** No Graphics Device Located **", 0, 0, 0)
  186. );
  187. (*%E SMALLMENU *)
  188. (*%F SMALLMENU *)
  189. TYPE
  190. oDevTab = ARRAY[0..142] OF device; (* Output device table. *)
  191. CONST
  192. oDev = oDevTab (
  193. device("w:1", GrConst.WYS640x400, " Amdek 1280", 640, 400, 0),
  194. device("w:2", GrConst.WYS1280x400, "+ Amdek 1280", 1280, 400, 0),
  195. device("w:3", GrConst.WYS1280x800, "+ Amdek 1280", 1280, 800, 0),
  196. device("a:4", GrConst.ATI800x600, "+ ATI, VGA Wonder", 800, 600, 16),
  197. device("a:5", GrConst.ATI1024x768F, "+ ATI, VGA Wonder", 1024, 768, 16),
  198. device("a:6", GrConst.ATI640x480X, "+ ATI, VGA Wonder", 640, 480, 256),
  199. device("a:2", GrConst.DEB640x200, "+ AT&T, DEB Graphics", 640, 200, 16),
  200. device("a:3", GrConst.DEB640x400, "+ AT&T, DEB Graphics", 640, 400, 16),
  201. device("c:3", GrConst.CT640x480X, "+ CHIPS and Tech 82C45x", 640, 480, 256),
  202. device("e:9", GrConst.VESA800x600, "+ VESA standard", 800,600, 16),
  203. device("c:4", GrConst.CT1024x768, "+ CHIPS and Tech 82C45x", 1024, 768, 16),
  204. device("a:1", GrConst.ATT640x400, " Compaq Plasma & AT&T ", 640, 400, 0),
  205. device("b:1", GrConst.COR1600x1280V, "+ Cornerstone, Vista 1600", 1600, 1280, 0),
  206. device("b:2", GrConst.COR1600x1280VA, "+ Cornerstone, Vista 1600/alt", 1600, 1280, 0),
  207. device("b:3", GrConst.COR1600x1280DP, "+ Cornerstone, DualPage", 1600, 1280, 0),
  208. device("b:4", GrConst.COR1600x1280DPA, "+ Cornerstone, DualPage/noJP1", 1600, 1280, 0),
  209. device("b:5", GrConst.COR1600x1280MCA, "+ Cornerstone, DualPage-PS2", 1600, 1280, 0),
  210. device("b:6", GrConst.SP768x1008, "+ Cornerstone, SinglePage", 768, 1008, 0),
  211. device("b:7", GrConst.SP768x1008A, "+ Cornerstone, Single/noJP1", 768, 1008, 0),
  212. device("b:8", GrConst.COR1280x960, "+ Cornerstone, PC1280", 1280, 960, 0),
  213. device("b:9", GrConst.COR1280x960A, "+ Cornerstone, PC1280/noJP1", 1280, 960, 0),
  214. device("b:10", GrConst.COR1280x1024, "+ Cornerstone, PC1280", 1280, 1024, 0),
  215. device("b:11", GrConst.COR1280x1024A, "+ Cornerstone, PC1280/noJP1", 1280, 1024, 0),
  216. device("z:0", GrConst.PAR800x600, "+ Eizo, MD-B07", 800, 600, 16),
  217. device("z:1", GrConst.STB640x350X, "+ Eizo, MD-B10", 640, 350, 256),
  218. device("z:2", GrConst.STB640x480X, "+ Eizo, MD-B10", 640, 480, 256),
  219. device("z:3", GrConst.STB800x600, "+ Eizo, MD-B10", 800, 600, 16),
  220. device("z:4", GrConst.STB1024x768, "+ Eizo, MD-B10", 1024, 768, 16),
  221. device("v:1", GrConst.EVR640x200, "+ Everex, Graphics Edge", 640, 200, 16),
  222. device("v:2", GrConst.EVR640x400, "+ Everex, Graphics Edge", 640, 400, 16),
  223. device("v:3", GrConst.EVX800x600, "+ Everex, EVGA EV-673", 800,600, 16),
  224. device("f:7", GrConst.FKY1120x750m, "+ Fujitsu, FMRxx, 24 dot",1120,750, 0),
  225. device("f:8", GrConst.FKY1120x750, "+ Fujitsu, FMRxx, 24 dot",1120,750, 16),
  226. device("f:9", GrConst.FKY640x400, "+ Fujitsu, FMRxx, 16 dot", 640,400, 16),
  227. device("g", GrConst.GEN640x480, " Genoa, SuperEGA 4880", 640, 480, 16),
  228. device("g:1", GrConst.GEN800x600, "+ Genoa, SuperEGA 4880", 800, 600, 16),
  229. device("g:2", GrConst.GEN640x350X, "+ Genoa, SuperVGA 5000", 640, 350, 256),
  230. device("g:3", GrConst.GEN640x480X, "+ Genoa, SuperVGA 5000", 640, 480, 256),
  231. device("g:4", GrConst.GEN800x600, "+ Genoa, SuperVGA 5000", 800, 600, 16),
  232. device("g:5", GrConst.GEN1024x768, "+ Genoa, SuperVGA 5000",1024, 768, 16),
  233. device("g:7", GrConst.GEN640x480S, "+ Genoa, SuperVGA 6000", 640, 480, 256),
  234. device("g:8", GrConst.GEN1024x768S, "+ Genoa, SuperVGA 6000",1024, 768, 16),
  235. device("e:9", GrConst.VESA800x600, "+ Genoa, VESA standard", 800,600, 16),
  236. device("h", GrConst.HER720x348, " Hercules, Monographics", 720, 348, 0),
  237. device("x:4", GrConst.EXPL320x200, "+ HeadStart Explorer", 320, 200, 16),
  238. device("c:1", GrConst.CGA640x200, " IBM, CGA", 640, 200, 2),
  239. device("c:2", GrConst.CGA320x200, " IBM, CGA", 320, 200, 4),
  240. device("e:1", GrConst.EGAMono, " IBM, EGA", 640, 350, 0),
  241. device("e:2", GrConst.EGA320x200, " IBM, EGA", 320, 200, 16),
  242. device("e:3", GrConst.EGA640x200, " IBM, EGA", 640, 200, 16),
  243. device("e:4", GrConst.EGA640x350, " IBM, EGA", 640, 350, 16),
  244. device("e:5", GrConst.MGA640x480, " IBM, MCGA", 640, 480, 2),
  245. device("e:6", GrConst.MGA640x350, " IBM, EGA", 640, 350, 2),
  246. device("e:7", GrConst.EGA640x480, " IBM, VGA", 640, 480, 16),
  247. device("e:8", GrConst.VGA320x200, "+ IBM, VGA (analog)", 320, 200, 256),
  248. device("f:4", GrConst.EGA640x350MP, "+ IBM, EGA (planar mode)", 640,350, 16),
  249. device("f", GrConst.JRT320x200, "+ IBM, PCjr", 320, 200, 16),
  250. device("x:1", GrConst.TTS720x350, "+ IBM, 3270", 720, 350, 2),
  251. device("x:2", GrConst.TTS360x350, "+ IBM, 3270", 360, 350, 4),
  252. device("m", GrConst.MDS736x1008, "+ MDS, Genius", 736, 1008, 0),
  253. device("j:1", GrConst.NEC640x400, "+ NEC, PC-9800/VM", 640, 400, 16),
  254. device("j:2", GrConst.MEC640x400, "+ NEC, PC-9800/VM", 640, 400, 2),
  255. device("l:6", GrConst.NSI800x600, "+ NSI, Smart EGA/Plus", 800, 600, 16),
  256. device("i", GrConst.NNR512x512, "+ Number 9, Revolution", 512, 485, 256),
  257. device("i:1", GrConst.OAK800x600, "+ Oak, OTI-067 VGA", 800, 600, 16),
  258. device("i:2", GrConst.OAK1024x768, "+ Oak, OTI-067 VGA", 1024, 768, 16),
  259. device("i:3", GrConst.OAK640x480X, "+ Oak, OTI-067 VGA", 640, 480, 256),
  260. device("k:1", GrConst.OCD640x350X, "+ Orchid, Designer VGA", 640, 350, 256),
  261. device("k:2", GrConst.OCD640x480X, "+ Orchid, Designer VGA", 640, 480, 256),
  262. device("k:3", GrConst.OCD800x600, "+ Orchid, Designer VGA", 800, 600, 16),
  263. device("k:4", GrConst.OCD1024x768, "+ Orchid, Designer VGA", 1024, 768, 16),
  264. device("l:2", GrConst.PAR640x480, " Paradise, Autoswitch EGA/480", 640, 480, 16),
  265. device("l:3", GrConst.PAR800x600, "+ Paradise, VGA ", 800, 600, 16),
  266. device("l:4", GrConst.PAR640x480x, "+ Paradise, VGA Professional", 640, 480, 256),
  267. device("l:5", GrConst.PAR1024x768, "+ Paradise, VGA Professional", 1024, 768, 16),
  268. device("q:1", GrConst.STB640x350X, "+ Quadram, QuadVGA Spectra", 640, 350, 256),
  269. device("q:2", GrConst.STB640x480X, "+ Quadram, QuadVGA Spectra", 640, 480, 256),
  270. device("q:3", GrConst.STB800x600, "+ Quadram, QuadVGA Spectra", 800, 600, 16),
  271. device("q:4", GrConst.STB1024x768, "+ Quadram, QuadVGA Spectra", 1024, 768, 16),
  272. device("d:1", GrConst.SIG640x400, "+ Sigma Design, Color-400", 640, 400, 16),
  273. device("d:2", GrConst.SIG1664x1200, "+ Sigma Design, L*View", 1664, 1200, 0),
  274. device("d:3", GrConst.SIG1664x1200A, "+ Sigma Design, L*View (A000)", 1664, 1200, 0),
  275. device("d:4", GrConst.SIG1664x1200MCA, "+ Sigma Design, L*View (PS/2)", 1664, 1200, 0),
  276. device("s:1", GrConst.STB640x352, "+ STB, Graphics Plus-II", 640, 352, 0),
  277. device("s:2", GrConst.STB320x200, "+ STB, Graphics Plus-II", 320, 200, 16),
  278. device("s:3", GrConst.STB640x200, "+ STB, Graphics Plus-II", 640, 200, 4),
  279. device("s:4", GrConst.STB640x400, "+ STB, Graphics Plus-III", 640, 400, 0),
  280. device("s:5", GrConst.STB640x350X, "+ STB, VGA Extra/EM", 640, 350, 256),
  281. device("s:6", GrConst.STB640x480X, "+ STB, VGA Extra/EM", 640, 480, 256),
  282. device("s:7", GrConst.STB800x600, "+ STB, VGA Extra/EM", 800, 600, 16),
  283. device("s:8", GrConst.STB1024x768, "+ STB, VGA Extra/EM", 1024, 768, 16),
  284. device("o:1", GrConst.TS4640x350x, "+ STB, VGA EM-PLUS", 640, 350, 256),
  285. device("o:2", GrConst.TS4640x480x, "+ STB, VGA EM-PLUS", 640, 480, 256),
  286. device("o:3", GrConst.STB800x600, "+ STB, VGA EM-PLUS", 800, 600, 16),
  287. device("o:4", GrConst.TS4800x600x, "+ STB, VGA EM-PLUS", 800, 600, 256),
  288. device("o:5", GrConst.TS41024x768x, "+ STB, VGA EM-PLUS", 1024, 768, 256),
  289. device("f", GrConst.JRT320x200, "+ Tandy, 1000 EX", 320, 200, 16),
  290. device("t:1", GrConst.TEC720x352, "+ Tecmar, Graphics Master", 720, 352, 0),
  291. device("t:2", GrConst.TEC720x704, "+ Tecmar, Graphics Master", 720, 704, 0),
  292. device("t:3", GrConst.TEC640x200, "+ Tecmar, Graphics Master", 640, 200, 16),
  293. device("t:4", GrConst.TEC640x400, "+ Tecmar, Graphics Master", 640, 400, 16),
  294. device("t:5", GrConst.TEC320x200, "+ Tecmar, Graphics Master", 320, 200, 16),
  295. device("t:6", GrConst.TEC640x350X, "+ Tecmar, VGA/AD", 640, 350, 256),
  296. device("t:7", GrConst.TEC640x480X, "+ Tecmar, VGA/AD", 640, 480, 256),
  297. device("t:9", GrConst.TEC800x600, "+ Tecmar, VGA/AD", 800, 600, 16),
  298. device("t:10", GrConst.TEC1024x768, "+ Tecmar, VGA/AD", 1024, 768, 16),
  299. device("o", GrConst.TOS640x400, " Toshiba, 3100", 640, 400, 0),
  300. device("r:1", GrConst.TRI800x600, "+ Trident Impact", 800, 600, 16),
  301. device("r:2", GrConst.TRI1024x768, "+ Trident Impact", 1024, 768, 16),
  302. device("r:3", GrConst.TRI640x480x, "+ Trident Impact", 640, 480, 256),
  303. device("r:4", GrConst.TRI800x600x, "+ Trident Impact", 800, 600, 256),
  304. device("r:5", GrConst.TRI1024x768x, "+ Trident Impact", 1024, 768, 256),
  305. device("f:5", GrConst.TARG512x482, "+ Truevision, Targa M8", 512,482,256),
  306. device("l:1", GrConst.EVA640x480, " Tseng Labs, EVA-480", 640, 480, 16),
  307. device("s:5", GrConst.STB640x350X, "+ Tseng Labs 3000 chip", 640, 350, 256),
  308. device("s:6", GrConst.STB640x480X, "+ Tseng Labs 3000 chip", 640, 480, 256),
  309. device("s:7", GrConst.STB800x600, "+ Tseng Labs 3000 chip", 800, 600, 16),
  310. device("s:8", GrConst.STB1024x768, "+ Tseng Labs 3000 chip", 1024, 768, 16),
  311. device("o:1", GrConst.TS4640x350x, "+ Tseng Labs 4000 chip", 640, 350, 256),
  312. device("o:2", GrConst.TS4640x480x, "+ Tseng Labs 4000 chip", 640, 480, 256),
  313. device("o:3", GrConst.STB800x600, "+ Tseng Labs 4000 chip", 800, 600, 16),
  314. device("o:4", GrConst.TS4800x600x, "+ Tseng Labs 4000 chip", 800, 600, 256),
  315. device("o:5", GrConst.TS41024x768x, "+ Tseng Labs 4000 chip", 1024, 768, 256),
  316. device("e:9", GrConst.VESA800x600, "+ VESA, VGA", 800,600, 16),
  317. device("u:3", GrConst.VGA720x540, "+ Video Seven, FastWrite VGA", 720, 540, 16),
  318. device("u:4", GrConst.VGA800x600, "+ Video Seven, FastWrite VGA", 800, 600, 16),
  319. device("u:5", GrConst.VGA640x480X, "+ Video Seven, FastWrite VGA", 640, 480,256),
  320. device("u:1", GrConst.VGA640x480, " Video Seven, VEGA/Deluxe", 640, 480, 16),
  321. device("u:2", GrConst.VGA752x410, "+ Video Seven, VEGA/Deluxe", 752, 410, 16),
  322. device("u:3", GrConst.VGA720x540, "+ Video Seven, VEGA VGA", 720, 540, 16),
  323. device("u:4", GrConst.VGA800x600, "+ Video Seven, VEGA VGA", 800, 600, 16),
  324. device("u:5", GrConst.VGA640x480X, "+ Video Seven, VGA 1024i", 640, 480, 256),
  325. device("u:3", GrConst.VGA720x540, "+ Video Seven, VGA 1024i", 720, 540, 16),
  326. device("u:4", GrConst.VGA800x600, "+ Video Seven, VGA 1024i", 800, 600, 16),
  327. device("u:7", GrConst.VGA1024x768, "+ Video Seven, VGA 1024i", 1024, 768, 16),
  328. device("u:5", GrConst.VGA640x480X, "+ Video Seven, VRAM VGA", 640, 480,256),
  329. device("u:3", GrConst.VGA720x540, "+ Video Seven, VRAM VGA", 720, 540, 16),
  330. device("u:4", GrConst.VGA800x600, "+ Video Seven, VRAM VGA", 800, 600, 16),
  331. device("u:6", GrConst.VGA1024x768x2, "+ Video Seven, VRAM VGA", 1024, 768, 2),
  332. device("w:1", GrConst.WYS640x400, " Wyse, WY-700", 640, 400, 0),
  333. device("w:2", GrConst.WYS1280x400, "+ Wyse, WY-700", 1280, 400, 0),
  334. device("w:3", GrConst.WYS1280x800, "+ Wyse, WY-700", 1280, 800, 0),
  335. device("", 0, "** No Graphics Device Located **", 0, 0, 0)
  336. );
  337. (*%E SMALLMENU *)
  338. iDev = iDevTab (
  339. (* ("m:b", MsMouse, "Microsoft bus mouse", 0, 0, -1), *)
  340. device("m:d", GrConst.MsDriver, "MS DOS mouse driver", 0, 0, -1),
  341. device("m:1", GrConst.MsCOM1, "Microsoft mouse, COM1", 0, 0, -1),
  342. device("m:2", GrConst.MsCOM2, "Microsoft mouse, COM2", 0, 0, -1),
  343. device("1", 1, "Logitech/Mouse Systems mouse, COM1", 0, 0, -1),
  344. device("2", 2, "Logitech/Mouse Systems mouse, COM2", 0, 0, -1),
  345. device("m:f", GrConst.FKYMsDriver, "Fujitsu DOS mouse driver", 0, 0, -1),
  346. device("", 0, "** No Input Device Located **", 0, 0, 0)
  347. );
  348. VAR
  349. line: ARRAY[0..GRQMAXLEN] OF CHAR;
  350. str, buf: ARRAY[0..GRQLINLEN] OF CHAR;
  351. txtAttrVal: txAttr;
  352. PROCEDURE GrQuit(Msg: ARRAY OF CHAR; Val: SHORTCARD);
  353. VAR
  354. i: INTEGER;
  355. BEGIN
  356. i := Meta.QueryError();
  357. Meta.StopMouse();
  358. Meta.StopEvent();
  359. Meta.SetDisplay(GrConst.TextPg0);
  360. Meta.ClearText();
  361. IF (i # 0) THEN
  362. IO.WrStr('QueryError = ');
  363. IO.WrInt(i DIV 128, 3);
  364. IO.WrStr('/');
  365. IO.WrInt(i MOD 128, 3);
  366. IO.WrLn();
  367. END;
  368. IF Msg[0] = CHR(0) THEN
  369. IO.WrStr('Normal end of program.');
  370. ELSE
  371. IO.WrStr(Msg);
  372. END;
  373. Lib.SetReturnCode(Val);
  374. IO.WrLn();
  375. HALT
  376. END GrQuit;
  377. (*%F GRQtrim *)
  378. (******************************************************************************)
  379. (* PC direct BIOS calls. These routines implement the standard text *)
  380. (* functions for GotoXY, setting Attributes, scrolling text, and outputing a *)
  381. (* character. A typical 80x25 text screen has coordinates of 0, 0 (min) *)
  382. (* to 79, 24 (max). *)
  383. (******************************************************************************)
  384. (*#save,
  385. call(reg_param=>(ax, bx, cx, dx)
  386. reg_saved=>(ax, bx, cx, dx, si, di, es, ds, st1, st2),
  387. inline=>on)
  388. *)
  389. TYPE
  390. DoScrollCODE = ARRAY[0..1] OF SHORTCARD;
  391. PROCEDURE doScroll(ax, bx, cx, dx: CARDINAL) =
  392. DoScrollCODE(
  393. 0CDH, 010H (* int 10H *)
  394. );
  395. (*#restore *)
  396. PROCEDURE txtScroll(dir, sx, sy, ex, ey, dist: CARDINAL);
  397. (*** PC-BIOS scroll routine. Moves a block of text up or down. ***)
  398. BEGIN
  399. doScroll((dir << 8) + dist, txtAttrVal.normal, (sy << 8) + sy, (ey << 8) + ex);
  400. END txtScroll;
  401. (*#save,
  402. call(reg_param=>()
  403. reg_saved=>(bx, cx, dx, si, di, es, ds, st1, st2),
  404. reg_return=>(ax),
  405. near_call=>on)
  406. *)
  407. TYPE
  408. TxtMonoCODE = ARRAY[0..12] OF SHORTCARD;
  409. PROCEDURE txtMono(): BOOLEAN =
  410. TxtMonoCODE(
  411. 0CDH, 011H, (* int 11H *)
  412. 025H, 030H, 00H, (* and ax, 30H *)
  413. 0A9H, 030H, 00H, (* test ax, 30H *)
  414. 074H, 002H, (* je true *)
  415. 033H, 0C0H, (* xor ax, ax *)
  416. 0C3H (* true: ret 0 *)
  417. );
  418. (*#restore *)
  419. (*#save,
  420. call(reg_param=>(bx, cx, ax, dx)
  421. reg_saved=>(bx, si, di, es, ds, st1, st2),
  422. near_call=>on)
  423. *)
  424. TYPE
  425. TxtAttrCODE = ARRAY[0..10] OF SHORTCARD;
  426. PROCEDURE txtAttr(attrib, sx, sy, ex: CARDINAL) =
  427. TxtAttrCODE(
  428. 08AH, 0E8H, (* mov ch, al *)
  429. 08AH, 0F0H, (* mov dh, al *)
  430. 033H, 0C0H, (* xor ax, ax *)
  431. 0B4H, 006H, (* mov ah, 6H *)
  432. 0CDH, 010H, (* int 10H *)
  433. 0C3H (* ret *)
  434. );
  435. (*#restore *)
  436. (*#save,
  437. call(reg_param=>(ax),
  438. reg_saved=>(cx, dx, si, di, es, ds, st1, st2),
  439. near_call=>on)
  440. *)
  441. TYPE
  442. TxtChoutCODE = ARRAY[0..6] OF SHORTCARD;
  443. PROCEDURE txtChOut(ch: BYTE) =
  444. TxtChoutCODE(
  445. 0B4H, 00EH, (* mov ah, 0EH *)
  446. 032H, 0FFH, (* xor bh, bh *)
  447. 0CDH, 010H, (* int 10H *)
  448. 0C3H (* ret *)
  449. );
  450. (*#restore *)
  451. (*#save,
  452. call(reg_param=>(dx, ax),
  453. reg_saved=>(cx, si, di, es, ds, st1, st2),
  454. near_call=>on)
  455. *)
  456. TYPE TxtXYCODE = ARRAY[0..8] OF SHORTCARD;
  457. PROCEDURE txtXY(x, y: CARDINAL) =
  458. TxtXYCODE(
  459. 08AH, 0F0H, (* mov dh, al *)
  460. 0B4H, 002H, (* mov ah, 2H *)
  461. 032H, 0FFH, (* xor bh, bh *)
  462. 0CDH, 010H, (* int 10H *)
  463. 0C3H (* ret *)
  464. );
  465. (*#restore *)
  466. (*#save,
  467. call(reg_param=>(),
  468. reg_saved=>(bx, si, di, es, ds, st1, st2),
  469. reg_return=>(dx),
  470. near_call=>on)
  471. *)
  472. TYPE
  473. Time55CODE = ARRAY[0..4] OF SHORTCARD;
  474. PROCEDURE time55(): CARDINAL =
  475. Time55CODE(
  476. 033H, 0C0H, (* xor ax, ax *)
  477. 0CDH, 01AH, (* int 1AH *)
  478. 0C3H (* ret *)
  479. );
  480. (*#restore *)
  481. PROCEDURE txtFrame(sx, sy, ex, ey: CARDINAL);
  482. (*** Draw a text frame. ***)
  483. VAR
  484. i: CARDINAL;
  485. BEGIN
  486. (*** Draw horizontal lines. ***)
  487. FOR i := sx + 1 TO ex DO
  488. txtXY(i, sy);
  489. txtChOut(HORZLINE);
  490. txtXY(i, ey);
  491. txtChOut(HORZLINE)
  492. END;
  493. (*** Draw vertical lines. ***)
  494. FOR i := sy + 1 TO ey DO
  495. txtXY(sx, i);
  496. txtChOut(VERTLINE);
  497. txtXY(ex, i);
  498. txtChOut(VERTLINE)
  499. END;
  500. (*** Place corners. ***)
  501. txtXY(sx, sy);
  502. txtChOut(LEFTTCORN);
  503. txtXY(ex, sy);
  504. txtChOut(RIGHTTCORN);
  505. txtXY(sx, ey);
  506. txtChOut(LEFTBCORN);
  507. txtXY(ex, ey);
  508. txtChOut(RIGHTBCORN)
  509. END txtFrame;
  510. PROCEDURE txtBar(sx, sy, ex: CARDINAL);
  511. (*** Draw a horizontal bar with T connectors on each end. ***)
  512. VAR
  513. i: CARDINAL;
  514. BEGIN
  515. FOR i := sx + 1 TO ex DO
  516. txtXY(i, sy);
  517. txtChOut(HORZLINE)
  518. END;
  519. txtXY(sx, sy);
  520. txtChOut(LEFTTEE);
  521. txtXY(ex, sy);
  522. txtChOut(RIGHTTEE)
  523. END txtBar;
  524. PROCEDURE bPrint(msg: ARRAY OF CHAR);
  525. (*** Print a string of text, bypassing DOS. ***)
  526. VAR
  527. i: CARDINAL;
  528. BEGIN
  529. i := 0;
  530. WHILE (msg[i] # CHR(0)) DO
  531. txtChOut(msg[i]);
  532. INC(i)
  533. END
  534. END bPrint;
  535. PROCEDURE txtTitle(msg: ARRAY OF CHAR; y: CARDINAL);
  536. (*** Print msg - centered and hilite. ***)
  537. VAR
  538. i, x: CARDINAL;
  539. BEGIN
  540. i := Str.Length(msg);
  541. x := (GRQLINLEN - i) DIV 2;
  542. txtAttr(txtAttrVal.hilite, x, y, x + i - 1);
  543. txtXY(x, y);
  544. bPrint(msg)
  545. END txtTitle;
  546. PROCEDURE getKey(VAR s, a: CHAR);
  547. (*** Get extended keys - returns scancode and ascii value in passed ***)
  548. (*** parameters. Sets the first value with the scan code, the second ***)
  549. (*** with the ASCII code. ***)
  550. BEGIN
  551. a := IO.RdKey();
  552. IF (a # CHR(0)) THEN
  553. (*** if ASCII, null scan code ***)
  554. s := CHR(0)
  555. ELSE
  556. (*** If first code is null, there is a scan code waiting. ***)
  557. s := IO.RdKey()
  558. END
  559. END getKey;
  560. PROCEDURE Qbeep();
  561. (*** Ring da bell. ***)
  562. BEGIN
  563. IO.WrChar(CHR(7H))
  564. END Qbeep;
  565. PROCEDURE dispItem(devptr: ARRAY OF device; item, max_item: CARDINAL; line: ARRAY OF CHAR; dosout: BOOLEAN);
  566. (*** Display device line item. dosout is a flag to use dos or bypass it ***)
  567. (*** for the BIOS call. ***)
  568. VAR
  569. OK : BOOLEAN;
  570. i, j: CARDINAL;
  571. dev: device;
  572. BEGIN
  573. IF (item > max_item) OR (item < 0) THEN
  574. (*** Don't go off the end of the list. ***)
  575. RETURN
  576. END;
  577. dev := devptr[item];
  578. FOR i := 0 TO GRQLINLEN DO
  579. line[i] := ' '
  580. END;
  581. (* see if its a graphics card *)
  582. IF (dev.devcolors > -1) THEN
  583. Str.Insert(line, '-', 1);
  584. Str.Insert(line, dev.devslash, 2);
  585. Str.Insert(line, dev.devdesc, 11);
  586. Str.IntToStr(LONGINT(dev.devhres), buf, 10, OK);
  587. Str.Insert(line, buf, 45);
  588. Str.Insert(line, ' x ', 50);
  589. Str.IntToStr(LONGINT(dev.devvres), buf, 10, OK);
  590. Str.Insert(line, buf, 53);
  591. IF (dev.devcolors = 0) THEN
  592. Str.Insert(line, 'monochrome', 60)
  593. ELSE
  594. Str.IntToStr(LONGINT(dev.devcolors), buf, 10, OK);
  595. Str.Insert(line, buf, 60)
  596. END;
  597. line[71] := CHR(0)
  598. ELSE
  599. (*** Input device. ***)
  600. Str.Insert(line, '-', 1);
  601. Str.Insert(line, dev.devslash, 2);
  602. Str.Insert(line, dev.devdesc, 11);
  603. line[50] := CHR(0)
  604. END;
  605. IF (dosout) THEN
  606. IO.WrStr(line)
  607. ELSE
  608. bPrint(line)
  609. END;
  610. END dispItem;
  611. PROCEDURE viewList(devptr: ARRAY OF device; curDev: CARDINAL; mouse: BOOLEAN): CARDINAL;
  612. (*** Menu device selection - uses cursor keys to select. ***)
  613. VAR
  614. choosing, refrsh: BOOLEAN;
  615. x, y,
  616. page_head, (* top of page *)
  617. page_len, (* number of lines on page *)
  618. cur_select, (* the initial selection number *)
  619. tail_sel, (* how many selections are there *)
  620. cy, (* the cursor position *)
  621. ex: CARDINAL; (* the length of the bar (calculated) *)
  622. s, a: CHAR;
  623. i: CARDINAL;
  624. BEGIN
  625. page_head := 0;
  626. page_len := GrQLines - 6;
  627. (*** Set menu x, y position. ***)
  628. y := 4;
  629. IF (mouse) THEN
  630. x := 10;
  631. ELSE
  632. x := 5;
  633. END;
  634. (*** Clear screen. ***)
  635. txtScroll(SUP, 0, 0, 79, 24, 0);
  636. (*** Make menu screen. ***)
  637. txtFrame(1, 1, 78, GrQLines - 2);
  638. txtBar(1, 3, 78);
  639. txtAttr(txtAttrVal.hilite, 9, GrQLines - 1, 68);
  640. txtXY(9, GrQLines - 1);
  641. bPrint('Cursor keys [] -> move, [Ù] -> select, [Esc] -> Abort');
  642. IF (mouse) THEN
  643. txtTitle('Select Input Device', 0);
  644. txtXY(x - 2, y - 2);
  645. bPrint('Cmd Line Pointing Device ');
  646. (*** Set line length. ***)
  647. ex := 54
  648. ELSE
  649. txtTitle('Select Display Device/Mode', 0);
  650. txtXY(x - 2, y - 2);
  651. bPrint('Cmd Line Graphics Device Resolution Colors ');
  652. ex := 74
  653. END;
  654. (*** Find the number of entries in menu. ***)
  655. tail_sel := HIGH(devptr);
  656. (*** Set max page length - fewer items will simply shrink 'page'. ***)
  657. IF tail_sel < page_len THEN
  658. page_len := tail_sel + 1
  659. END;
  660. (*** Set current selection, ie default entry. ***)
  661. IF curDev > tail_sel THEN
  662. cur_select := 0
  663. ELSE
  664. cur_select := curDev
  665. END;
  666. (*** Set the select bar position. ***)
  667. cy := y;
  668. IF (cur_select # 0) THEN
  669. IF (cur_select > (page_len DIV 2)) THEN
  670. (*** Position cursor in the middle. ***)
  671. INC(cy, (page_len DIV 2));
  672. page_head := cur_select - (page_len DIV 2)
  673. ELSE
  674. INC(cy, cur_select)
  675. END
  676. END;
  677. choosing := TRUE;
  678. refrsh := TRUE;
  679. WHILE (choosing) DO
  680. (*** Where the bar is on the page. ***)
  681. IF (NOT refrsh) THEN
  682. txtAttr(txtAttrVal.inverse, x, cy, ex)
  683. END;
  684. (*** Rewrite entire page. ***)
  685. IF (refrsh) THEN
  686. FOR i := 0 TO page_len - 1 DO
  687. txtXY(x, y + i);
  688. IF (y + i = cy) THEN
  689. txtAttr(txtAttrVal.inverse, x, cy, ex)
  690. END;
  691. dispItem(devptr, page_head + i, tail_sel, str, FALSE)
  692. END;
  693. refrsh := FALSE;
  694. ELSE
  695. (*** Just moved bar. ***)
  696. txtXY(x, cy);
  697. dispItem(devptr, cur_select, tail_sel, str, FALSE)
  698. END;
  699. (*** Get cursor out of way. ***)
  700. txtXY(0, GrQLines - 1);
  701. getKey(s, a);
  702. (*** Escape. ***)
  703. IF (a = CHR(kESC)) THEN
  704. GrQuit(GRQQUITSTR, 9)
  705. END;
  706. (*** Made a choice. ***)
  707. IF (a = CHR(kCR)) THEN
  708. RETURN cur_select
  709. END;
  710. txtAttr(txtAttrVal.normal, x, cy, ex);
  711. txtXY(x, cy);
  712. dispItem(devptr, cur_select, tail_sel, str, FALSE);
  713. CASE s OF
  714. | CHR(UP_arr), CHR(LF_arr):
  715. IF (cur_select > 0) THEN
  716. DEC(cur_select);
  717. IF (cy > y) THEN
  718. DEC(cy)
  719. ELSE
  720. (*** Top of page; move up one line. ***)
  721. IF (page_head > 0) THEN
  722. DEC(page_head);
  723. txtScroll(SDOWN, x, y, ex, y + page_len - 1, 1)
  724. END
  725. END
  726. END;
  727. | CHR(DN_arr), CHR(RT_arr):
  728. IF (cur_select < tail_sel) THEN
  729. INC(cur_select);
  730. IF (cy < (page_len + y - 1)) THEN
  731. INC(cy)
  732. ELSE
  733. (*** Bottom of page; move down one line. ***)
  734. IF (page_head < tail_sel) THEN
  735. INC(page_head);
  736. txtScroll(SUP, x, y, ex, y+page_len-1, 1)
  737. END
  738. END
  739. END;
  740. | CHR(Home):
  741. IF (cur_select > 0) THEN
  742. (*** Set page, select, to 0 and set cursor bar. ***)
  743. page_head := 0;
  744. cur_select := 0;
  745. cy := y;
  746. refrsh := TRUE
  747. END;
  748. | CHR(End):
  749. IF (cur_select < tail_sel) THEN
  750. (*** Set page, select, and set cursor bar. ***)
  751. page_head := tail_sel - page_len + 1;
  752. cur_select := tail_sel;
  753. cy := page_len + y - 1;
  754. refrsh := TRUE
  755. END;
  756. | CHR(PgDn):
  757. IF (cur_select < tail_sel) THEN
  758. INC(page_head, page_len);
  759. INC(cur_select, page_len);
  760. IF (page_head + page_len > tail_sel + 1) OR (cur_select > tail_sel) THEN
  761. page_head := tail_sel + 1 - page_len;
  762. cur_select := tail_sel;
  763. cy := page_len + y - 1;
  764. END;
  765. refrsh := TRUE
  766. END;
  767. | CHR(PgUp):
  768. IF (cur_select > 0) THEN
  769. IF (page_head < page_len) OR (cur_select < page_len) THEN
  770. page_head := 0;
  771. cy := y;
  772. cur_select:= 0
  773. ELSE
  774. DEC(page_head, page_len);
  775. DEC(cur_select, page_len);
  776. END;
  777. refrsh := TRUE
  778. END
  779. ELSE
  780. Qbeep()
  781. END
  782. END;
  783. RETURN 0
  784. END viewList;
  785. PROCEDURE grQMenu(VAR GrafixCard, CommPort: INTEGER);
  786. (*** Allow menu selection of desired devices. ***)
  787. VAR
  788. i, inum, onum, x, y: CARDINAL;
  789. ktime: CARDINAL;
  790. z, w: CHAR;
  791. OK: BOOLEAN;
  792. BEGIN
  793. LOOP
  794. (*** Find display adapter info. ***)
  795. onum := 0;
  796. WHILE (oDev[onum].devnum # 0) AND (oDev[onum].devnum # GrafixCard) DO
  797. INC(onum)
  798. END;
  799. (*** Find input device info. ***)
  800. inum := 0;
  801. WHILE (iDev[inum].devnum # 0) AND (iDev[inum].devnum # CommPort) DO
  802. INC(inum)
  803. END;
  804. (*** Clear screen. ***)
  805. txtScroll(SUP, 0, 0, 79, 24, 0);
  806. txtFrame(1, 1, 78, GrQLines - 2);
  807. txtBar(1, 3, 78);
  808. y := 0;
  809. txtTitle(GRQHDRSTR, y);
  810. INC(y, 2);
  811. txtTitle(GRQTITLE, y);
  812. (*** Print MetaWINDOW version. ***)
  813. Str.Copy(line, '-[ ');
  814. Meta.MetaVersion(buf);
  815. Str.Append(line, buf);
  816. Str.Append(line, ' ]-');
  817. txtTitle(line, GrQLines - 1);
  818. x := 4;
  819. y := 5;
  820. txtXY(x, y);
  821. (*** Display graphics device. ***)
  822. FOR i := 0 TO GRQLINLEN DO
  823. line[i] := ' '
  824. END;
  825. IF (GrafixCard # 0) THEN
  826. bPrint('Display Device / Mode:');
  827. Str.Copy(line, oDev[onum].devdesc);
  828. Str.IntToStr(LONGINT(oDev[onum].devhres), buf, 10, OK);
  829. Str.Append(line, ', ');
  830. Str.Append(line, buf);
  831. Str.Append(line, 'x');
  832. Str.IntToStr(LONGINT(oDev[onum].devvres), buf, 10, OK);
  833. Str.Append(line, buf);
  834. IF (oDev[onum].devcolors = 0) THEN
  835. Str.Append(line, ' monochrome')
  836. ELSE
  837. Str.Append(line, ' ');
  838. Str.IntToStr(LONGINT(oDev[onum].devcolors), buf, 10, OK);
  839. Str.Append(line, buf);
  840. Str.Append(line, ' color')
  841. END;
  842. txtAttr(txtAttrVal.hilite, x + 23, y, Str.Length(line) + x + 25);
  843. txtXY(x + 23, y);
  844. bPrint(line)
  845. ELSE
  846. txtAttr(txtAttrVal.hilite, x, y, Str.Length(oDev[onum].devdesc) + x);
  847. bPrint(oDev[onum].devdesc)
  848. END;
  849. (*** Display input device. ***)
  850. INC(y, 2);
  851. txtXY(x, y);
  852. bPrint('Input Device or Mouse:');
  853. txtAttr(txtAttrVal.hilite, x + 23, y, Str.Length(iDev[inum].devdesc) + x + 25);
  854. txtXY(x + 23, y);
  855. bPrint(iDev[inum].devdesc);
  856. INC(y, 3);
  857. txtXY(x, y);
  858. txtAttr(txtAttrVal.hilite, x, y, x + 3);
  859. bPrint('[D] -> choose an alternate Display.');
  860. INC(y, 2);
  861. txtXY(x, y);
  862. txtAttr(txtAttrVal.hilite, x, y, x + 3);
  863. bPrint('[I] -> choose an alternate Input device or mouse.');
  864. INC(y, 2);
  865. txtXY(x, y);
  866. txtAttr(txtAttrVal.hilite, x, y, x + 5);
  867. bPrint('[Esc] -> Escape to DOS.');
  868. INC(y, 2);
  869. txtXY(x, y);
  870. txtAttr(txtAttrVal.hilite, x, y, x + 7);
  871. bPrint('[other] -> accept defaults');
  872. INC(y, 3);
  873. txtXY(x, y);
  874. bPrint('Choice ? [ ]');
  875. txtXY(x + 12, y);
  876. (*** Wait for a key or timeout. ***)
  877. ktime := time55();
  878. LOOP
  879. IF (time55() > ktime + GRQDELAY) THEN
  880. Meta.ClearText();
  881. txtXY(0, 0);
  882. RETURN
  883. END;
  884. IF (IO.KeyPressed()) THEN
  885. EXIT
  886. END
  887. END;
  888. (*** Get a key and process. ***)
  889. getKey(z, w);
  890. CASE w OF
  891. | CHR(kESC):
  892. (*** Escape key. ***)
  893. GrQuit(GRQQUITSTR, 9)
  894. | 'D', 'd':
  895. i := viewList(oDev, onum, FALSE);
  896. GrafixCard := oDev[i].devnum
  897. | 'I', 'i':
  898. i := viewList(iDev, inum, TRUE);
  899. CommPort := iDev[i].devnum
  900. ELSE
  901. (*** Any other key accepts choice. ***)
  902. Meta.ClearText();
  903. txtXY(0, 0);
  904. RETURN
  905. END
  906. END
  907. END grQMenu;
  908. (*%E GRQtrim = FALSE *)
  909. (*%T GRQtrim *)
  910. PROCEDURE dumpList();
  911. (*** Print the entire device list. ***)
  912. VAR
  913. i, j: CARDINAL;
  914. OK : BOOLEAN;
  915. BEGIN
  916. Meta.MetaVersion(line);
  917. IO.WrLn();
  918. IO.WrStr(line);
  919. IO.WrLn(); IO.WrLn();
  920. IO.WrStr(' Output Devices (Displays)');
  921. IO.WrLn(); IO.WrLn();
  922. IO.WrStr('Cmd Line Graphics Device Resolution Colors ');
  923. IO.WrLn();
  924. IO.WrStr('======================================================================');
  925. IO.WrLn();
  926. FOR i := 0 TO HIGH(oDev) DO
  927. FOR j := 0 TO GRQLINLEN DO
  928. line[j] := ' '
  929. END;
  930. Str.Insert(line, '-', 1);
  931. Str.Insert(line, oDev[i].devslash, 2);
  932. Str.Insert(line, oDev[i].devdesc, 11);
  933. Str.IntToStr(LONGINT(oDev[i].devhres), buf, 10, OK);
  934. Str.Insert(line, buf, 45);
  935. Str.Insert(line, ' x ', 50);
  936. Str.IntToStr(LONGINT(oDev[i].devvres), buf, 10, OK);
  937. Str.Insert(line, buf, 53);
  938. IF (oDev[i].devcolors = 0) THEN
  939. Str.Insert(line, 'monochrome', 60);
  940. ELSE
  941. Str.IntToStr(LONGINT(oDev[i].devcolors), buf, 10, OK);
  942. Str.Insert(line, buf, 60);
  943. END;
  944. line[70] := CHR(0);
  945. IO.WrStr(line);
  946. IO.WrLn();
  947. END;
  948. IO.WrLn();
  949. IO.WrStr(' Input Devices (Mouse)');
  950. IO.WrLn(); IO.WrLn();
  951. IO.WrStr('Cmd Line Pointing Device ');
  952. IO.WrLn();
  953. IO.WrStr('======================================================================');
  954. IO.WrLn();
  955. FOR i := 0 TO HIGH(iDev) DO
  956. FOR j := 0 TO GRQLINLEN DO
  957. line[j] := ' '
  958. END;
  959. Str.Insert(line, '-', 1);
  960. Str.Insert(line, iDev[i].devslash, 2);
  961. Str.Insert(line, iDev[i].devdesc, 11);
  962. line[50] := CHR(0);
  963. IO.WrStr(line);
  964. IO.WrLn();
  965. END;
  966. Lib.SetReturnCode(0);
  967. HALT
  968. END dumpList;
  969. (*%E GRQtrim = TRUE *)
  970. PROCEDURE grQParse(VAR GrafixCard, CommPort: INTEGER): BOOLEAN;
  971. (*** Parse the command line or METAPARM environment variable for options. ***)
  972. (*** Sets global GrafixCard and CommPort to selection if any. ***)
  973. (*** Returns True if the /; option present, else returns False ***)
  974. VAR
  975. pass: BOOLEAN;
  976. i, dev: CARDINAL;
  977. choice: BOOLEAN;
  978. j, k: CARDINAL;
  979. BEGIN
  980. line[0] := CHR(0);
  981. Meta.GetCmdLine(line);
  982. (*** Is there a command line choice? ***)
  983. choice := FALSE;
  984. i := 0;
  985. LOOP
  986. IF (line[i] = CHR(0)) THEN
  987. EXIT
  988. END;
  989. IF ((line[i] = '-') OR (line[i] = '/')) THEN
  990. choice := TRUE;
  991. EXIT
  992. END;
  993. INC(i)
  994. END;
  995. (*** NULL terminate line. ***)
  996. line[GRQMAXLEN] := CHR(0);
  997. (*** If no cmd line, is there an environment var? ***)
  998. IF (NOT choice) THEN
  999. Lib.EnvironmentFind("METAPARM", line)
  1000. END;
  1001. (*** Force to upper case, remove spaces. ***)
  1002. Str.Lows(line);
  1003. (*** Process each option on the line. ***)
  1004. (*** Set bypass menu to FALSE. ***)
  1005. pass := FALSE;
  1006. i := 0;
  1007. LOOP
  1008. WHILE (line[i] # CHR(0)) AND (line[i] # '/') AND (line[i] # '-') DO
  1009. INC(i)
  1010. END;
  1011. IF (line[i] = CHR(0)) THEN
  1012. EXIT
  1013. END;
  1014. INC(i);
  1015. (*%T GRQtrim *)
  1016. IF line[i] = '?' THEN
  1017. dumpList()
  1018. END;
  1019. (*%E GRQtrim = TRUE *)
  1020. IF line[i] = ';' THEN
  1021. pass := TRUE
  1022. END;
  1023. (*** Table look up for each output device. ***)
  1024. dev := 0;
  1025. WHILE (GrafixCard = 0) AND (dev <= HIGH(oDev)) DO
  1026. j := 0;
  1027. WITH oDev[dev] DO
  1028. WHILE (devslash[j] = line[i+j]) AND (devslash[j] # CHR(0)) DO
  1029. INC(j)
  1030. END;
  1031. IF (devslash[j] = CHR(0)) AND (line[i+j] # ':') THEN
  1032. GrafixCard := devnum;
  1033. INC(i, j);
  1034. END;
  1035. END;
  1036. INC(dev)
  1037. END;
  1038. (*** Table look up for each input device. ***)
  1039. dev := 0;
  1040. WHILE (CommPort = 0) AND (dev <= HIGH(iDev)) DO
  1041. j := 0;
  1042. WITH iDev[dev] DO
  1043. WHILE (devslash[j] = line[i+j]) AND (devslash[j] # CHR(0)) DO
  1044. INC(j)
  1045. END;
  1046. IF (devslash[j] = CHR(0)) AND (line[i+j] # ':') THEN
  1047. CommPort := devnum;
  1048. INC(i, j);
  1049. END;
  1050. END;
  1051. INC(dev)
  1052. END;
  1053. END;
  1054. RETURN pass
  1055. END grQParse;
  1056. PROCEDURE bitAnd(A1, A2: CARDINAL) : CARDINAL;
  1057. (*** Return the bitwise and of the two parameters. ***)
  1058. BEGIN
  1059. RETURN CARDINAL(BITSET(A1) * BITSET(A2))
  1060. END bitAnd;
  1061. PROCEDURE GrInit(VAR GrafixCard, CommPort: INTEGER);
  1062. (*** Use QueryGrafix() and QueryCom() to try and determine the devices ***)
  1063. (*** currently in use. As a safety measure GrafixCard and CommPort are ***)
  1064. (*** initialised to 0. ***)
  1065. VAR qGraf, qComm: INTEGER;
  1066. BEGIN
  1067. (*** Initialise GrafixCard and CommPort to 0. ***)
  1068. GrafixCard := 0;
  1069. CommPort := 0;
  1070. (*** Is the driver loaded ? ***)
  1071. qComm := Meta.QueryComm();
  1072. IF (qComm < 0) THEN
  1073. GrInitErr(GrafixCard, CommPort, qComm)
  1074. END;
  1075. (*** Use QueryGrafix() to determine GrafixCard. ***)
  1076. qGraf := Meta.QueryGrafix();
  1077. CASE qGraf OF
  1078. GrConst.EXPL320x200,
  1079. GrConst.SP768x1008,
  1080. GrConst.SP768x1008A,
  1081. GrConst.COR1280x960,
  1082. GrConst.COR1280x960A,
  1083. GrConst.COR1280x1024,
  1084. GrConst.COR1280x1024A,
  1085. GrConst.COR1600x1280DP,
  1086. GrConst.COR1600x1280DPA,
  1087. GrConst.COR1600x1280MCA,
  1088. GrConst.SIG1664x1200MCA,
  1089. GrConst.FKY1120x750,
  1090. GrConst.FKY640x400,
  1091. GrConst.NDI640x480x4D,
  1092. GrConst.HP1024x768x4,
  1093. GrConst.GRX1024x768x4A,
  1094. GrConst.NEC640x400: GrafixCard := qGraf
  1095. ELSE
  1096. IF (bitAnd(qGraf, GrConst.VGA640x480) = GrConst.VGA640x480) THEN
  1097. (*** Vega Deluxe. ***)
  1098. IF (bitAnd(qGraf, 0030H) = 0010H) THEN
  1099. GrafixCard := GrConst.EGAMono
  1100. ELSE
  1101. GrafixCard := GrConst.EGA640x350
  1102. END
  1103. ELSIF (bitAnd(qGraf, GrConst.EVA640x480) = GrConst.EVA640x480) THEN
  1104. (*** Tseng Labs EVA/480. ***)
  1105. IF (bitAnd(qGraf, 0030H) = 0010H) THEN
  1106. GrafixCard := GrConst.EGAMono
  1107. ELSE
  1108. GrafixCard := GrConst.EGA640x350
  1109. END
  1110. ELSIF bitAnd(qGraf, GrConst.EGAMono) # 0 THEN
  1111. IF bitAnd(qGraf, 0100H) # 0 THEN
  1112. (*** IBM PS/2 ***)
  1113. IF bitAnd(qGraf, 10H) # 0 THEN
  1114. GrafixCard := GrConst.MGA640x480
  1115. ELSE
  1116. GrafixCard := GrConst.EGA640x480
  1117. END
  1118. ELSIF (bitAnd(qGraf, 0030H) = 0010H) THEN
  1119. (*** IBM EGA ***)
  1120. GrafixCard := GrConst.EGAMono
  1121. ELSIF ((bitAnd(qGraf, 0030H) = 0030H) AND (bitAnd(qGraf, 0C0H) # 0)) THEN
  1122. GrafixCard := GrConst.EGA640x350
  1123. ELSE
  1124. GrafixCard := GrConst.EGA640x200
  1125. END
  1126. ELSIF bitAnd(qGraf, GrConst.ATT640x400) # 0 THEN
  1127. IF bitAnd(qGraf, 1) # 0 THEN
  1128. GrafixCard := GrConst.DEB640x400
  1129. ELSE
  1130. GrafixCard := GrConst.ATT640x400
  1131. END
  1132. ELSIF bitAnd(qGraf, GrConst.TOS640x400) # 0 THEN
  1133. GrafixCard := GrConst.TOS640x400
  1134. ELSIF bitAnd(qGraf, GrConst.CGA320x200) # 0 THEN
  1135. GrafixCard := GrConst.CGA640x200
  1136. ELSIF bitAnd(qGraf, GrConst.HER720x348) # 0 THEN
  1137. GrafixCard := GrConst.HER720x348
  1138. ELSIF bitAnd(qGraf, GrConst.TEC720x352) # 0 THEN
  1139. IF bitAnd(qGraf, 2) # 0 THEN
  1140. GrafixCard := GrConst.TEC640x200
  1141. ELSE
  1142. GrafixCard := GrConst.TEC720x352
  1143. END
  1144. ELSIF bitAnd(qGraf, GrConst.EVR640x200) # 0 THEN
  1145. GrafixCard := GrConst.EVR640x200
  1146. ELSIF bitAnd(qGraf, GrConst.STB640x352) # 0 THEN
  1147. GrafixCard := GrConst.STB640x352
  1148. ELSIF bitAnd(qGraf, GrConst.TTS720x350) # 0 THEN
  1149. IF bitAnd(qGraf, 1) # 0 THEN
  1150. GrafixCard := GrConst.TTS360x350
  1151. ELSE
  1152. GrafixCard := GrConst.TTS720x350
  1153. END
  1154. ELSIF bitAnd(qGraf, GrConst.SIG640x400) # 0 THEN
  1155. GrafixCard := GrConst.SIG640x400
  1156. ELSIF bitAnd(qGraf, GrConst.TOS640x400) # 0 THEN
  1157. GrafixCard := GrConst.TOS640x400
  1158. ELSIF bitAnd(qGraf, GrConst.WYS640x400) # 0 THEN
  1159. GrafixCard := GrConst.WYS640x400
  1160. ELSIF bitAnd(qGraf, GrConst.MDS736x1008) # 0 THEN
  1161. GrafixCard := GrConst.MDS736x1008
  1162. END
  1163. END;
  1164. (*** Use the result from QueryCom() to determine CommPort. ***)
  1165. IF bitAnd(qComm, GrConst.FKYMsDriver) # 0 THEN
  1166. CommPort := GrConst.FKYMsDriver
  1167. ELSIF bitAnd(qComm, GrConst.MsDriver) # 0 THEN
  1168. CommPort := GrConst.MsDriver
  1169. (***
  1170. ELSIF bitAnd(qComm, GrConst.MsMouse) # 0 THEN
  1171. CommPort := GrConst.MsMouse
  1172. ***)
  1173. ELSIF bitAnd(qComm, 2) # 0 THEN
  1174. CommPort := GrConst.MsCOM2
  1175. ELSIF bitAnd(qComm, 1) # 0 THEN
  1176. CommPort := GrConst.MsCOM1
  1177. END
  1178. END GrInit;
  1179. PROCEDURE GrInitErr(GrafixCard, CommPort, val: INTEGER);
  1180. (*** Print an initialisation error message. ***)
  1181. VAR i: CARDINAL;
  1182. BEGIN
  1183. IO.WrLn();
  1184. IO.WrStr('MetaWINDOW SYSTEM ERROR: ');
  1185. IF (val = -1) THEN
  1186. IO.WrLn(); IO.WrLn();
  1187. IO.WrStr('The Metagraphics Driver (METASHEL.EXE) is not installed.');
  1188. IO.WrLn()
  1189. ELSIF (val = -2) THEN
  1190. IO.WrStr('The InitGrafix(');
  1191. IO.WrInt(GrafixCard, 6);
  1192. IO.WrStr(') call is invalid.');
  1193. IO.WrLn(); IO.WrLn();
  1194. IO.WrStr('REASON: ');
  1195. IF (GrafixCard = 0) THEN
  1196. IO.WrStr('MetaWINDOW was unable to find a default adaptor, ');
  1197. IO.WrLn();
  1198. IO.WrStr(' and you did not select one.')
  1199. ELSE
  1200. i := 0;
  1201. WHILE (GrafixCard # oDev[i].devnum) AND (i # HIGH(oDev)) DO
  1202. INC(i)
  1203. END;
  1204. IF (GrafixCard = oDev[i].devnum) THEN
  1205. Str.Copy(buf, oDev[i].devdesc);
  1206. ELSE
  1207. Str.Copy(buf, '*** No graphics adaptor ***');
  1208. END;
  1209. IF (buf[0] = '+') THEN
  1210. (*** MetaWINDOW Plus device. ***)
  1211. buf[0] := ' ';
  1212. IO.WrStr('The');
  1213. IO.WrStr(buf);
  1214. IO.WrStr(' system is supported in');
  1215. IO.WrLn();
  1216. IO.WrStr(' MetaWINDOW/PLUS and MetaWINDOW/Premium only.');
  1217. IO.WrLn()
  1218. ELSIF (buf[0] = '*') THEN
  1219. (*** MetaWINDOW Premium device. ***)
  1220. buf[0] := ' ';
  1221. IO.WrStr('The');
  1222. IO.WrStr(buf);
  1223. IO.WrStr(' system is supported in');
  1224. IO.WrLn();
  1225. IO.WrStr(' MetaWINDOW/Premium only.');
  1226. IO.WrLn()
  1227. ELSE
  1228. buf[0] := ' ';
  1229. IO.WrStr('Device');
  1230. IO.WrStr(buf);
  1231. IO.WrStr(' is not');
  1232. IO.WrLn();
  1233. Meta.MetaVersion(buf);
  1234. IO.WrStr(' supported in ');
  1235. IO.WrStr(buf);
  1236. IO.WrLn()
  1237. END
  1238. END
  1239. END;
  1240. Lib.SetReturnCode(1);
  1241. HALT
  1242. END GrInitErr;
  1243. PROCEDURE GrQuery(VAR GrafixCard, CommPort: INTEGER);
  1244. (*** Determine which devices are available. ***)
  1245. VAR
  1246. i: INTEGER;
  1247. pass: BOOLEAN;
  1248. c: CHAR;
  1249. BEGIN
  1250. (*** Initialise GrafixCard and CommPort from QueryGrafix() and ***)
  1251. (*** QueryComm(). These settings can be changed by grQParse(). ***)
  1252. GrInit(GrafixCard, CommPort);
  1253. (*** Parse out the command line or environment variable, if any. ***)
  1254. pass := grQParse(GrafixCard, CommPort);
  1255. (*** If the /; option was present, don't do anything more. ***)
  1256. IF (pass) THEN
  1257. RETURN
  1258. END;
  1259. (*%F GRQtrim *)
  1260. (*** Test to see if mono or color display installed and set vals into ***)
  1261. (*** global structure. ***)
  1262. IF txtMono() THEN
  1263. (* on a monochrome system *)
  1264. txtAttrVal.normal := MNORMAL;
  1265. txtAttrVal.inverse := MINVERSE;
  1266. txtAttrVal.hilite := MHILITE
  1267. ELSE (* color system *)
  1268. txtAttrVal.normal := CNORMAL;
  1269. txtAttrVal.inverse := CINVERSE;
  1270. txtAttrVal.hilite := CHILITE
  1271. END;
  1272. (*** Allow text screen menu selection. ***)
  1273. grQMenu(GrafixCard, CommPort);
  1274. (*%E GRQtrim *)
  1275. (*%T DOSDISP *)
  1276. Meta.MetaVersion(line);
  1277. IO.WrLn();
  1278. IO.WrStr('-[ ');
  1279. IO.WrStr(line);
  1280. IO.WrStr(' ]-');
  1281. IO.WrLn();
  1282. (* find display adapter info *)
  1283. i := 0;
  1284. WHILE (oDev[i].devnum # 0) AND (oDev[i].devnum # GrafixCard) DO
  1285. INC(i)
  1286. END;
  1287. IO.WrLn();
  1288. IO.WrStr('DISPLAY: -');
  1289. IO.WrStr(oDev[i].devslash);
  1290. IO.WrStr(' -> ');
  1291. IO.WrStr(oDev[i].devdesc);
  1292. IO.WrStr(', ');
  1293. IO.WrInt(oDev[i].devhres, 4);
  1294. IO.WrStr(' x ');
  1295. IO.WrInt(oDev[i].devvres, 4);
  1296. IO.WrLn();
  1297. (* find input device info *)
  1298. i := 0;
  1299. WHILE (iDev[i].devnum # 0) AND (iDev[i].devnum # CommPort) DO
  1300. INC(i)
  1301. END;
  1302. IO.WrStr(' MOUSE: -');
  1303. IO.WrStr(iDev[i].devslash);
  1304. IO.WrStr(' -> ');
  1305. IO.WrStr(iDev[i].devdesc);
  1306. IO.WrLn();
  1307. c := IO.RdKey();
  1308. (*%E DOSDISP *)
  1309. (*** GrafixCard and CommPort are now set with valid InitGrafix and ***)
  1310. (*** InitMouse values (or are equal to zero if no devices were found ***)
  1311. (*** or specified). ***)
  1312. END GrQuery;
  1313. BEGIN
  1314. END GrQry.