SMARTSCR.LST 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816
  1. Listing:
  2. 1 IMPLEMENTATION MODULE SmartScreen;
  3. 2 (*
  4. 3 * REPERTOIRE
  5. 4 * Release 1.6
  6. 5 * By Charles Bradford and Cole Brecheen
  7. 6 * (c) Copyright 1985-1992 PMI
  8. 7 * Green Bay, Wisconsin
  9. 8 * All rights reserved
  10. 9 * (414) 468-6040
  11. 10 *
  12. 11 * $Header: D:/logfiles/mods/smartscr.mov 1.5 17 Mar 1991 17:53:50 coleb $
  13. 12 *
  14. 13 *)
  15. 14
  16. 15
  17. 16 (*EntryDiag:
  18. 17 IMPORT Diagnostics;
  19. 18 :EntryDiag*)
  20. 19
  21. 20 (* IMPORT EnvironUtils; *)
  22. 21 IMPORT ErrorManager;
  23. 22 IMPORT LowLevel;
  24. 23 IMPORT M2Strings;
  25. 24 IMPORT Numbers;
  26. 25 IMPORT StrConv;
  27. 26 IMPORT StrEdit;
  28. 27 IMPORT StringIO;
  29. 28 IMPORT SYSTEM;
  30. 29 IMPORT VStorage;
  31. 30 IMPORT FAPI;
  32. 31
  33. 32
  34. 33 VAR
  35. 34 Initialized : BOOLEAN;
  36. 35
  37. 36
  38. 37 CONST
  39. 38 blink = 16;
  40. 39 byte1 = 0;
  41. 40 VAR
  42. 41 ReturnCode: CARDINAL;
  43. 42 TextAttrByte: CHAR;
  44. 43 NoSnow, UsingColor: BOOLEAN;
  45. 44 NilValue : VStorage.MemHandle;
  46. ***** ^ not supported yet
  47. 45 setting : ARRAY [0..80] OF CHAR;
  48. ***** ^ not supported yet
  49. ***** ^ not supported yet
  50. 46
  51. 47
  52. 48 PROCEDURE SetBits( VAR TheWord: SYSTEM.BYTE; bit1, bit2, bit3: CARDINAL );
  53. ***** ^ not supported yet
  54. 49 BEGIN
  55. 50 END SetBits;
  56. ***** ^ not supported yet
  57. 51
  58. 52
  59. 53 PROCEDURE EndCol(): CARDINAL;
  60. 54 VAR
  61. 55 ModeData: FAPI.VIOMODEINFO;
  62. ***** ^ not supported yet
  63. 56 ErrorNum: CARDINAL;
  64. 57 BEGIN
  65. 58
  66. 59 ModeData.cb := SYSTEM.TSIZE(FAPI.VIOMODEINFO);
  67. ***** ^ not supported yet
  68. ***** ^ not supported yet
  69. ***** ^ not supported yet
  70. ***** ^ not supported yet
  71. ***** ^ not supported yet
  72. ***** ^ not supported yet
  73. 60 ErrorNum := FAPI.VIOGETMODE(SYSTEM.ADR(ModeData), 0);
  74. ***** ^ not supported yet
  75. ***** ^ not supported yet
  76. ***** ^ not supported yet
  77. ***** ^ not supported yet
  78. ***** ^ not supported yet
  79. ***** ^ not supported yet
  80. 61 IF ErrorNum # 0 THEN
  81. 62 ErrorManager.WarnNumber("VioGetMode error", ErrorNum);
  82. ***** ^ not supported yet
  83. ***** ^ not supported yet
  84. ***** ^ not supported yet
  85. ***** ^ not supported yet
  86. 63 END;
  87. 64 MaxCol := ModeData.col;
  88. ***** ^ undeclared identifier
  89. ***** ^ not supported yet
  90. ***** ^ not supported yet
  91. 65 (*
  92. 66 MaxCol := 80;
  93. 67 *)
  94. 68 RETURN MaxCol;
  95. ***** ^ undeclared identifier
  96. 69 END EndCol;
  97. ***** ^ not supported yet
  98. 70
  99. 71
  100. 72 PROCEDURE EndRow(): CARDINAL;
  101. 73 VAR
  102. 74 ModeData: FAPI.VIOMODEINFO;
  103. ***** ^ not supported yet
  104. 75 ErrorNum: CARDINAL;
  105. 76 BEGIN
  106. 77
  107. 78 ModeData.cb := SYSTEM.TSIZE(FAPI.VIOMODEINFO);
  108. ***** ^ not supported yet
  109. ***** ^ not supported yet
  110. ***** ^ not supported yet
  111. ***** ^ not supported yet
  112. ***** ^ not supported yet
  113. ***** ^ not supported yet
  114. 79 ErrorNum := FAPI.VIOGETMODE(SYSTEM.ADR(ModeData), 0);
  115. ***** ^ not supported yet
  116. ***** ^ not supported yet
  117. ***** ^ not supported yet
  118. ***** ^ not supported yet
  119. ***** ^ not supported yet
  120. ***** ^ not supported yet
  121. 80 IF ErrorNum # 0 THEN
  122. 81 ErrorManager.WarnNumber("VioGetMode error", ErrorNum);
  123. ***** ^ not supported yet
  124. ***** ^ not supported yet
  125. ***** ^ not supported yet
  126. ***** ^ not supported yet
  127. 82 END;
  128. 83 MaxRow := ModeData.row;
  129. ***** ^ undeclared identifier
  130. ***** ^ not supported yet
  131. ***** ^ not supported yet
  132. 84 (*
  133. 85 MaxRow := 25;
  134. 86 *)
  135. 87 RETURN MaxRow;
  136. ***** ^ undeclared identifier
  137. 88 END EndRow;
  138. ***** ^ not supported yet
  139. 89
  140. 90
  141. 91 PROCEDURE GotoXY(column, row : CARDINAL);
  142. 92 (*puts cursor at column X, row Y *)
  143. 93 VAR
  144. 94 dumstr, dumstr2 : ARRAY [0..20] OF CHAR;
  145. ***** ^ not supported yet
  146. ***** ^ not supported yet
  147. 95 BEGIN
  148. 96 IF row>MaxRow THEN
  149. ***** ^ undeclared identifier
  150. 97 row := MaxRow - 1;
  151. ***** ^ undeclared identifier
  152. 98 ELSIF row>0 THEN
  153. 99 DEC(row);
  154. ***** ^ undeclared identifier
  155. ***** ^ not supported yet
  156. 100 END;
  157. 101 IF column>MaxCol THEN
  158. ***** ^ undeclared identifier
  159. 102 column := MaxCol - 1;
  160. ***** ^ undeclared identifier
  161. 103 ELSIF column>0 THEN
  162. 104 DEC(column);
  163. ***** ^ undeclared identifier
  164. ***** ^ not supported yet
  165. 105 END;
  166. 106 IF FAPI.VIOSETCURPOS(row, column, 0) # 0 THEN
  167. ***** ^ not supported yet
  168. ***** ^ not supported yet
  169. ***** ^ not supported yet
  170. 107 ErrorManager.WARN("VioSetCurPos error ");
  171. ***** ^ not supported yet
  172. ***** ^ not supported yet
  173. ***** ^ not supported yet
  174. 108 END;
  175. 109 END GotoXY;
  176. ***** ^ not supported yet
  177. 110
  178. 111
  179. 112 PROCEDURE MonoAttrsToColor(AttrSet : AttributeSet; VAR fg, bg :
  180. ***** ^ undeclared identifier
  181. 113 Colors);
  182. ***** ^ undeclared identifier
  183. 114 BEGIN
  184. 115 fg := ForeGround;
  185. ***** ^ not supported yet
  186. ***** ^ undeclared identifier
  187. 116 bg := BackGround;
  188. ***** ^ not supported yet
  189. ***** ^ undeclared identifier
  190. 117 IF invisible IN AttrSet THEN
  191. ***** ^ undeclared identifier
  192. ***** ^ not supported yet
  193. 118 fg := black;
  194. ***** ^ not supported yet
  195. ***** ^ undeclared identifier
  196. 119 bg := black;
  197. ***** ^ not supported yet
  198. ***** ^ undeclared identifier
  199. 120 RETURN;
  200. 121 END;
  201. 122 IF plain IN AttrSet THEN
  202. ***** ^ undeclared identifier
  203. ***** ^ not supported yet
  204. 123 fg := lightgrey;
  205. ***** ^ not supported yet
  206. ***** ^ undeclared identifier
  207. 124 bg := black;
  208. ***** ^ not supported yet
  209. ***** ^ undeclared identifier
  210. 125 RETURN;
  211. 126 END;
  212. 127 IF underscored IN AttrSet THEN
  213. ***** ^ undeclared identifier
  214. ***** ^ not supported yet
  215. 128 fg := blue;
  216. ***** ^ not supported yet
  217. ***** ^ undeclared identifier
  218. 129 bg := black;
  219. ***** ^ not supported yet
  220. ***** ^ undeclared identifier
  221. 130 END;
  222. 131 IF ReverseVideo IN AttrSet THEN
  223. ***** ^ undeclared identifier
  224. ***** ^ not supported yet
  225. 132 fg := black;
  226. ***** ^ not supported yet
  227. ***** ^ undeclared identifier
  228. 133 bg := lightgrey;
  229. ***** ^ not supported yet
  230. ***** ^ undeclared identifier
  231. 134 END;
  232. 135 IF (bold IN AttrSet) AND (ForeGround<darkgrey) THEN
  233. ***** ^ undeclared identifier
  234. ***** ^ not supported yet
  235. ***** ^ undeclared identifier
  236. ***** ^ undeclared identifier
  237. 136 fg := VAL(Colors, ORD(ForeGround)+ORD(darkgrey));
  238. ***** ^ not supported yet
  239. ***** ^ undeclared identifier
  240. ***** ^ undeclared identifier
  241. ***** ^ undeclared identifier
  242. ***** ^ undeclared identifier
  243. ***** ^ undeclared identifier
  244. ***** ^ undeclared identifier
  245. 137 END;
  246. 138 IF (blinking IN AttrSet) AND (ORD(BackGround)<(blink DIV 2)) THEN
  247. ***** ^ undeclared identifier
  248. ***** ^ not supported yet
  249. ***** ^ undeclared identifier
  250. ***** ^ undeclared identifier
  251. 139 bg := VAL(Colors, ORD(BackGround)+(blink DIV 2));
  252. ***** ^ not supported yet
  253. ***** ^ undeclared identifier
  254. ***** ^ undeclared identifier
  255. ***** ^ undeclared identifier
  256. ***** ^ undeclared identifier
  257. ***** ^ not supported yet
  258. 140 END;
  259. 141 END MonoAttrsToColor;
  260. ***** ^ not supported yet
  261. 142
  262. 143 PROCEDURE ColorToMonoAttrs(fg, bg : Colors; VAR AttrSet :
  263. ***** ^ undeclared identifier
  264. 144 AttributeSet);
  265. ***** ^ undeclared identifier
  266. 145 BEGIN
  267. 146 AttrSet := AttributeSet{plain};
  268. ***** ^ not supported yet
  269. ***** ^ undeclared identifier
  270. 147 IF (ORD(bg)>=(blink DIV 2)) THEN
  271. 148 AttrSet := AttributeSet{blinking};
  272. 149 bg := VAL(Colors, ORD(bg)-(blink DIV 2));
  273. 150 END;
  274. 151 IF fg>=darkgrey THEN
  275. 152 INCL(AttrSet, bold);
  276. 153 fg := VAL(Colors, ORD(fg)-ORD(darkgrey));
  277. 154 END;
  278. 155 CASE bg OF
  279. 156 black :
  280. 157 IF fg=blue THEN
  281. 158 INCL(AttrSet, underscored);
  282. 159 ELSIF fg=black THEN
  283. 160 AttrSet := AttributeSet{invisible};
  284. 161 END;
  285. 162 | lightgrey :
  286. 163 IF fg=black THEN
  287. 164 INCL(AttrSet, ReverseVideo);
  288. 165 END;
  289. 166 ELSE
  290. 167 END;
  291. 168 IF AttrSet#AttributeSet{plain} THEN
  292. 169 EXCL(AttrSet, plain);
  293. 170 END;
  294. 171 END ColorToMonoAttrs;
  295. 172
  296. 173 PROCEDURE MakeAttrByte();
  297. 174 VAR
  298. 175 cnt: CARDINAL;
  299. 176 BEGIN
  300. 177 cnt := ORD(BackGround);
  301. 178 LowLevel.ShiftLeft(cnt, 4);
  302. 179 TextAttrByte := CHR(ORD(ForeGround)+cnt);
  303. 180 END MakeAttrByte;
  304. 181
  305. 182
  306. 183
  307. 184 PROCEDURE TextColor(fg, bg : Colors);
  308. 185 VAR
  309. 186 dumstr : ARRAY [0..8] OF CHAR;
  310. 187 BEGIN
  311. 188 ForeGround := fg;
  312. 189 BackGround := bg;
  313. 190 ColorToMonoAttrs(fg, bg, TextModeNow);
  314. 191 MakeAttrByte();
  315. 192 END TextColor;
  316. 193
  317. 194 PROCEDURE ReverseColors();
  318. 195 (* Switches fore and back ground colors, like reverse video *)
  319. 196 VAR
  320. 197 SwitchColor : Colors;
  321. 198 BEGIN
  322. 199 SwitchColor := ForeGround;
  323. 200 ForeGround := BackGround;
  324. 201 BackGround := SwitchColor;
  325. 202 MakeAttrByte();
  326. 203 END ReverseColors;
  327. 204
  328. 205 PROCEDURE SetAttribOrColor(forec, backc: Colors; atrib: TextAttribute);
  329. 206 (* depending on current screen mode, sets color or mono attribute *)
  330. 207 BEGIN
  331. 208 IF UsingColor THEN
  332. 209 IF (forec<>ForeGround) OR (backc<>BackGround) THEN
  333. 210 TextColor( forec, backc);
  334. 211 END;
  335. 212 ELSE
  336. 213 IF NOT (atrib IN TextModeNow) THEN
  337. 214 TextModeNow := AttributeSet{};
  338. 215 ForeGround := lightgrey;
  339. 216 BackGround := black;
  340. 217 IF VideoMethod=ANSI THEN
  341. 218 TextMode( plain); (* resets to plain first *)
  342. 219 TextMode( atrib);
  343. 220 ELSE
  344. 221 INCL(TextModeNow, atrib);
  345. 222 MonoAttrsToColor(TextModeNow, ForeGround, BackGround);
  346. 223 MakeAttrByte();
  347. 224 END;
  348. 225 END;
  349. 226 END;
  350. 227 END SetAttribOrColor;
  351. 228
  352. 229
  353. 230 PROCEDURE TextMode(attribute : TextAttribute);
  354. 231
  355. 232 PROCEDURE UpdateNeeded(attribute : TextAttribute) : BOOLEAN;
  356. 233 VAR
  357. 234 answer : BOOLEAN;
  358. 235 BEGIN
  359. 236 answer := FALSE;
  360. 237 IF attribute=plain THEN
  361. 238 IF TextModeNow#AttributeSet{plain} THEN
  362. 239 answer := TRUE;
  363. 240 END;
  364. 241 TextModeNow := AttributeSet{plain};
  365. 242 ELSIF NOT (attribute IN TextModeNow) THEN
  366. 243 INCL(TextModeNow, attribute);
  367. 244 EXCL(TextModeNow, plain);
  368. 245 RETURN (TRUE);
  369. 246 END;
  370. 247 RETURN (answer);
  371. 248 END UpdateNeeded;
  372. 249
  373. 250 VAR
  374. 251 fground, bground : CARDINAL;
  375. 252 BEGIN
  376. 253 IF UpdateNeeded(attribute) THEN
  377. 254 MonoAttrsToColor(TextModeNow, ForeGround, BackGround);
  378. 255 MakeAttrByte();
  379. 256 END;
  380. 257 END TextMode;
  381. 258
  382. 259
  383. 260 PROCEDURE ScreenMode(TheMode : ScreenModeType);
  384. 261 VAR
  385. 262
  386. 263 dumstr : ARRAY [0..8] OF CHAR;
  387. 264 temp, ModeData: FAPI.VIOMODEINFO;
  388. 265 BEGIN
  389. 266
  390. 267 IF TheMode # ScreenModeNow THEN
  391. 268 CASE TheMode OF
  392. 269
  393. 270 BW40x25:
  394. 271 (* BIOS MODE 0 *)
  395. 272 ModeData.cb := 12;
  396. 273 ModeData.fbType := FAPI.UCHAR(FAPI.VGMT_DISABLEBURST);
  397. 274 (* mono *)
  398. 275 ModeData.hres := 320;
  399. 276 ModeData.vres := 200;
  400. 277 ModeData.row := 25;
  401. 278 ModeData.col := 40;
  402. 279 SetBits (ModeData.color, 0, 7, 1);
  403. 280 (* 2 colors = B/w ???*)
  404. 281
  405. 282 | color40x25:
  406. 283 (* BIOS MODE 1 *)
  407. 284 ModeData.cb := 12;
  408. 285 ModeData.row :=25 ;
  409. 286 ModeData.col := 40;
  410. 287 ModeData.fbType := FAPI.VGMT_OTHER;
  411. 288 (* color ??? *)
  412. 289 ModeData.hres := 320;
  413. 290 ModeData.vres := 200;
  414. 291 SetBits (ModeData.color, 0, 7, 4);
  415. 292 (* 16 colors *)
  416. 293
  417. 294 | BW80x25:
  418. 295 (* BIOS MODE 2 *)
  419. 296 ModeData.cb := 12;
  420. 297 ModeData.row := 25;
  421. 298 ModeData.col := 80;
  422. 299 ModeData.fbType := FAPI.VGMT_DISABLEBURST;
  423. 300 ModeData.hres := 640;
  424. 301 ModeData.vres := 200;
  425. 302 SetBits (ModeData.color, 0, 7, 1);
  426. 303 (* 2 colors = B/w ???*)
  427. 304
  428. 305 | color80x25:
  429. 306 (* BIOS MODE 3 *)
  430. 307 ModeData.cb := 12;
  431. 308 ModeData.row :=25 ;
  432. 309 ModeData.col :=80 ;
  433. 310 ModeData.fbType := FAPI.VGMT_OTHER;
  434. 311 (* ModeData.color *)
  435. 312 ModeData.hres := 640;
  436. 313 ModeData.vres := 200;
  437. 314 SetBits (ModeData.color, 0, 7, 4);
  438. 315 (* 16 colors *)
  439. 316
  440. 317 | color320:
  441. 318 (* BIOS MODE 4 *)
  442. 319 ModeData.cb := 12;
  443. 320 ModeData.row := 0 ;
  444. 321 ModeData.col := 0 ;
  445. 322 ModeData.fbType := FAPI.VGMT_GRAPHICS;
  446. 323 (* color graphics *)
  447. 324 ModeData.hres := 320;
  448. 325 ModeData.vres := 200;
  449. 326 SetBits (ModeData.color, 0, 7, 2);
  450. 327 (* 4 colors *)
  451. 328
  452. 329 | BW320:
  453. 330 (* BIOS MODE 5 *)
  454. 331 ModeData.cb := 12;
  455. 332 ModeData.row := 0;
  456. 333 ModeData.col :=0 ;
  457. 334 ModeData.fbType := FAPI.VGMT_DISABLEBURST + FAPI.VGMT_GRAPHICS;
  458. 335 ModeData.hres := 320;
  459. 336 ModeData.vres := 200;
  460. 337 SetBits (ModeData.color, 0, 7, 1);
  461. 338 (* 2 colors = B/w ???*)
  462. 339
  463. 340 | BW640:
  464. 341 (* BIOS MODE 6 *)
  465. 342 ModeData.cb := 12;
  466. 343 ModeData.row := 0;
  467. 344 ModeData.col :=0 ;
  468. 345 ModeData.fbType := FAPI.VGMT_DISABLEBURST + FAPI.VGMT_GRAPHICS;
  469. 346 ModeData.hres := 640;
  470. 347 ModeData.vres := 200;
  471. 348 SetBits (ModeData.color, 0, 7, 1);
  472. 349 (* 2 colors = B/w ???*)
  473. 350
  474. 351 | Mono:
  475. 352 (* BIOS MODE 7 *)
  476. 353 ModeData.row := 25;
  477. 354 ModeData.cb := 12;
  478. 355 ModeData.col :=80 ;
  479. 356 ModeData.fbType := FAPI.VGMT_DISABLEBURST;
  480. 357 (* mono *)
  481. 358 ModeData.hres := 720;
  482. 359 ModeData.vres := 350;
  483. 360 SetBits (ModeData.color, 0, 7, 1);
  484. 361 (* 2 colors = B/w ???*)
  485. 362
  486. 363 | PCjr160:
  487. 364 (* BIOS MODE 8 not supported *)
  488. 365 ErrorManager.WARN("VioSetMode - not supported ");
  489. 366
  490. 367 | PCjr320:
  491. 368 (* BIOS MODE 9 - NOT SUPPORTED *)
  492. 369 ErrorManager.WARN("VioSetMode - not supported ");
  493. 370
  494. 371 | PCjr640:
  495. 372 (* BIOS MODE Ah - NOT SUPPORTS *)
  496. 373 ErrorManager.WARN("VioSetMode - not supported ");
  497. 374
  498. 375 | EGA11:
  499. 376 (* BIOS MODE B hex - not supported *)
  500. 377 ErrorManager.WARN("VioSetMode - not supported ");
  501. 378
  502. 379 | EGA12:
  503. 380 (* BIOS MODE c hex *);
  504. 381
  505. 382 | EGA320:
  506. 383 (* BIOS MODE d hex *)
  507. 384 ModeData.cb := 12;
  508. 385 ModeData.row := 0;
  509. 386 ModeData.col := 0;
  510. 387 ModeData.fbType := FAPI.VGMT_GRAPHICS + FAPI.VGMT_OTHER;
  511. 388 (*??*)
  512. 389 ModeData.hres := 320;
  513. 390 ModeData.vres := 200;
  514. 391 SetBits (ModeData.color, 0, 7, 4);
  515. 392 (* 16 colors *)
  516. 393
  517. 394 | EGA640:
  518. 395 (* BIOS MODE E hex *)
  519. 396 ModeData.cb := 12;
  520. 397 ModeData.row := 0;
  521. 398 ModeData.col :=0 ;
  522. 399 ModeData.fbType := FAPI.VGMT_GRAPHICS + FAPI.VGMT_OTHER;
  523. 400 ModeData.hres := 640;
  524. 401 ModeData.vres := 200;
  525. 402 SetBits (ModeData.color, 0, 7, 2);
  526. 403 (* 4 colors = *)
  527. 404
  528. 405 | EGAMono:
  529. 406 (* BIOS MODE F hex *)
  530. 407 ModeData.cb := 12;
  531. 408 ModeData.row := 0;
  532. 409 ModeData.col :=0 ;
  533. 410 ModeData.fbType := FAPI.VGMT_GRAPHICS;
  534. 411 ModeData.hres := 640;
  535. 412 ModeData.vres := 350;
  536. 413 SetBits (ModeData.color, 0, 7, 1);
  537. 414 (* 2 colors = B/w ???*)
  538. 415
  539. 416 | EGA64color:
  540. 417 (* BIOS MODE 10 hex *)
  541. 418 ModeData.cb := 12;
  542. 419 ModeData.row := 0;
  543. 420 ModeData.col :=0 ;
  544. 421 ModeData.fbType := FAPI.VGMT_GRAPHICS + FAPI.VGMT_OTHER;
  545. 422 ModeData.hres := 640;
  546. 423 ModeData.vres := 350;
  547. 424 SetBits (ModeData.color, 0, 7, 4);
  548. 425 (* 16 colors *)
  549. 426
  550. 427 ELSE
  551. 428 ErrorManager.WARN ("Screen mode not supported");
  552. 429 END; (* CASE *)
  553. 430
  554. 431 ModeData.cb := SYSTEM.TSIZE(FAPI.VIOMODEINFO);
  555. 432 IF FAPI.VIOSETMODE(SYSTEM.ADR(ModeData), 0) #0 THEN
  556. 433 ErrorManager.WARN("VioSetMode error");
  557. 434 END;
  558. 435
  559. 436 MaxCol := ModeData.col;
  560. 437 MaxRow := ModeData.row;
  561. 438 ScreenModeNow := TheMode;
  562. 439 UsingColor := NOT ( (TheMode = BW40x25) OR (TheMode = BW80x25)
  563. 440 OR (TheMode = BW320) OR (TheMode = BW640) OR
  564. 441 (TheMode = Mono) OR (TheMode = EGAMono));
  565. 442 END;
  566. 443
  567. 444 END ScreenMode;
  568. 445
  569. 446
  570. 447 PROCEDURE coord(ColNum, RowNum : CARDINAL) : CARDINAL;
  571. 448 (*Makes it easier to work with the routines below, which
  572. 449 treat the screen as a linear sequence OF 4000 bytes.*)
  573. 450 BEGIN
  574. 451 RETURN (Numbers.Between(0, RowNum-1, MaxRow-1) * MaxCol +
  575. 452 Numbers.Between(1, ColNum, MaxCol));
  576. 453 END coord;
  577. 454
  578. 455
  579. 456 PROCEDURE RealVideoMode() : ScreenModeType;
  580. 457 (* This is incomplete, I know, but its only purpose is
  581. 458 compatibility with old code. New code ought
  582. 459 to get this information in some more rational way. *)
  583. 460 VAR
  584. 461 ModeData: FAPI.VIOMODEINFO;
  585. 462 ErrorNum: CARDINAL;
  586. 463 BEGIN
  587. 464 ModeData.cb := SYSTEM.TSIZE(FAPI.VIOMODEINFO);
  588. 465
  589. 466 ErrorNum := FAPI.VIOGETMODE(SYSTEM.ADR(ModeData), 0);
  590. 467
  591. 468 IF ErrorNum # 0 THEN
  592. 469 ErrorManager.WarnNumber("VioGetMode Error", ErrorNum);
  593. 470 END;
  594. 471 MaxCol := ModeData.col;
  595. 472 MaxRow := ModeData.row +1;
  596. 473 (* Adjust to Repertoire's system of
  597. 474 numbering from 1 instead of 0 *)
  598. 475 IF (CARDINAL(LowLevel.BitwiseAnd(FAPI.VGMT_OTHER,
  599. 476 ORD(ModeData.fbType))) # 0) THEN
  600. 477 IF (CARDINAL(LowLevel.BitwiseAnd(FAPI.VGMT_GRAPHICS,
  601. 478 ORD(ModeData.fbType))) # 0) THEN
  602. 479 (* We're in a graphics mode. *)
  603. 480 IF CARDINAL(LowLevel.BitwiseAnd(FAPI.VGMT_DISABLEBURST,
  604. 481 ORD(ModeData.fbType))) # 0 THEN
  605. 482 (* We're in a monochrome graphics mode. *)
  606. 483 IF ModeData.hres = 320 THEN
  607. 484 RETURN BW320;
  608. 485 ELSE
  609. 486 RETURN BW640;
  610. 487 END;
  611. 488 ELSE
  612. 489 (* We're in a color graphics mode. *)
  613. 490 IF ModeData.hres = 320 THEN
  614. 491 RETURN EGA320;
  615. 492 ELSE
  616. 493 RETURN EGA640;
  617. 494 END;
  618. 495 END;
  619. 496 ELSE
  620. 497 (* We're in a text mode. *)
  621. 498 IF CARDINAL(LowLevel.BitwiseAnd(FAPI.VGMT_DISABLEBURST,
  622. 499 ORD(ModeData.fbType))) # 0 THEN
  623. 500 (* We're in a monochrome text mode. *)
  624. 501 IF (ModeData.row =25) AND (ModeData.col = 40) THEN
  625. 502 RETURN BW40x25;
  626. 503 ELSE
  627. 504 RETURN BW80x25;
  628. 505 END;
  629. 506 ELSE
  630. 507 (* We're in a color text mode. *)
  631. 508 IF (ModeData.row =25) AND (ModeData.col = 40) THEN
  632. 509 RETURN color40x25;
  633. 510 ELSE
  634. 511 RETURN color80x25;
  635. 512 END;
  636. 513 END;
  637. 514 END;
  638. 515 ELSE
  639. 516 RETURN Mono;
  640. 517 END;
  641. 518
  642. 519 RETURN color80x25;
  643. 520 END RealVideoMode;
  644. 521
  645. 522
  646. 523 PROCEDURE WriteAt(ColNum, RowNum : CARDINAL; TheStr : ARRAY OF CHAR);
  647. 524 BEGIN
  648. 525 AdrWriteAt( ColNum, RowNum, SYSTEM.ADR(TheStr),
  649. 526 M2Strings.Length(TheStr));
  650. 527 END WriteAt;
  651. 528
  652. 529
  653. 530 PROCEDURE AdrWriteAt(ColNum, RowNum : CARDINAL; TheAdr:
  654. 531 SYSTEM.ADDRESS; TheSize: CARDINAL );
  655. 532 BEGIN
  656. 533 IF TheSize = 0 THEN
  657. 534 RETURN;
  658. 535 END;
  659. 536 ColNum := Numbers.Between( 1, ColNum, MaxCol );
  660. 537 RowNum := Numbers.Between( 1, RowNum, MaxRow );
  661. 538 TheSize := Numbers.Min( TheSize, (MaxCol - ColNum) + 1 );
  662. 539 NominalCol := ColNum + TheSize;
  663. 540 NominalRow := RowNum;
  664. 541 IF FAPI.VIOWRTCHARSTRATT( TheAdr, TheSize,
  665. 542 RowNum-1, ColNum-1, SYSTEM.ADR(TextAttrByte), 0 ) # 0 THEN
  666. 543 ErrorManager.WARN("VioWrtCharStrAtt error");
  667. 544 END;
  668. 545 END AdrWriteAt;
  669. 546
  670. 547
  671. 548 PROCEDURE SetCursorHeight(lines : CARDINAL);
  672. 549 VAR
  673. 550 CursorData: FAPI.VIOCURSORINFO;
  674. 551 BEGIN
  675. 552 ReturnCode := FAPI.VIOGETCURTYPE(SYSTEM.ADR(CursorData), 0);
  676. 553 IF ReturnCode # 0 THEN
  677. 554 ErrorManager.WarnNumber("VioGetCurType error", ReturnCode);
  678. 555 END;
  679. 556 (* We set CursorWidth to 0, which means default width, because
  680. 557 the API.LIB version of VIOGETCURTYPE doesn't seem to be
  681. 558 returning values that can be passed on to VIOSETCURTYPE. *)
  682. 559 CursorData.cx := 0;
  683. 560 (*
  684. 561 CursorData.CursorEndLine := -100;
  685. 562 OS/2 lets us specify percentages of the character cell by
  686. 563 using negative numbers. This means that the end line is
  687. 564 always 100% of the way down from the top of the character
  688. 565 cell.
  689. 566
  690. 567 Unfortunately, API.LIB doesn't support this, so we start by getting
  691. 568 CursorData, and we try not to change it much.
  692. 569 *)
  693. 570 IF lines <= 0 THEN
  694. 571 CursorData.attr := 65535;
  695. 572 ELSE
  696. 573 CursorData.attr := 1;
  697. 574 IF lines >= 10 THEN
  698. 575 CursorData.yStart := 0;
  699. 576 ELSE
  700. 577 CursorData.yStart := CursorData.cEnd - lines;
  701. 578 END;
  702. 579 END;
  703. 580 ReturnCode := FAPI.VIOSETCURTYPE(SYSTEM.ADR(CursorData), 0);
  704. 581 IF ReturnCode # 0 THEN
  705. 582 ErrorManager.WarnNumber("VioSetCurType error", ReturnCode);
  706. 583 END;
  707. 584 END SetCursorHeight;
  708. 585
  709. 586
  710. 587 PROCEDURE ClearPart(col1, row1, col2, row2 : CARDINAL);
  711. 588 VAR
  712. 589 BackGroundCell: VideoMemChar;
  713. 590 BEGIN
  714. 591 row2 := Numbers.Min( row2, MaxRow );
  715. 592 col2 := Numbers.Min( col2, MaxCol );
  716. 593 col1 := Numbers.Between( 1, col1, col2 );
  717. 594 row1 := Numbers.Between( 1, row1, row2 );
  718. 595 BackGroundCell.attr :=TextAttrByte;
  719. 596 BackGroundCell.ch := ' ';
  720. 597 IF FAPI.VIOSCROLLUP( row1-1, col1-1, row2-1, col2-1, 65535,
  721. 598 SYSTEM.ADR(BackGroundCell), 0) # 0 THEN
  722. 599 ErrorManager.WARN("VioScrollUp error");
  723. 600 END;
  724. 601 END ClearPart;
  725. 602
  726. 603
  727. 604 PROCEDURE ClearScreen();
  728. 605 (*Clears the screen and sends the cursor to the top left corner.*)
  729. 606 BEGIN
  730. 607 ClearPart(1, 1, MaxCol, MaxRow);
  731. 608 END ClearScreen;
  732. 609
  733. 610
  734. 611 PROCEDURE SetVideoVars();
  735. 612 BEGIN
  736. 613 ScreenModeNow := RealVideoMode();
  737. 614 IF ScreenModeNow >= color320 THEN
  738. 615 VideoMethod := ROM;
  739. 616 END;
  740. 617 IF M2Strings.CompareStr( setting, 'DMAWAIT') = 0 THEN
  741. 618 NoSnow := TRUE;
  742. 619 ELSIF M2Strings.CompareStr( setting, 'DMA') = 0 THEN
  743. 620 NoSnow := FALSE;
  744. 621 ELSE
  745. 622 NoSnow := ScreenModeNow < Mono;
  746. 623 END;
  747. 624 UsingColor := NOT ( (ScreenModeNow = BW40x25) OR
  748. 625 (ScreenModeNow = BW80x25) OR
  749. 626 (ScreenModeNow = BW320) OR
  750. 627 (ScreenModeNow = BW640) OR
  751. 628 (ScreenModeNow = Mono) OR
  752. 629 (ScreenModeNow = EGAMono));
  753. 630 END SetVideoVars;
  754. 631
  755. 632
  756. 633
  757. 634 PROCEDURE SetVideoMethod( NewMethod: VidMethodType);
  758. 635 BEGIN
  759. 636 IF (VideoMethod = ANSI) AND (NewMethod # ANSI) THEN
  760. 637 SetVideoVars();
  761. 638 END;
  762. 639 VideoMethod := NewMethod;
  763. 640 END SetVideoMethod;
  764. 641
  765. 642
  766. 643 PROCEDURE Init();
  767. 644 BEGIN
  768. 645 IF Initialized THEN
  769. 646 RETURN;
  770. 647 ELSE
  771. 648 Initialized := TRUE;
  772. 649 END;
  773. 650 (*EntryDiag:
  774. 651 Diagnostics.Init();
  775. 652 :EntryDiag*)
  776. 653
  777. 654 ErrorManager.Init();
  778. 655 LowLevel.Init();
  779. 656 M2Strings.Init();
  780. 657 Numbers.Init();
  781. 658 StrConv.Init();
  782. 659 StrEdit.Init();
  783. 660 StringIO.Init();
  784. 661 VStorage.Init();
  785. 662 (*EntryDiag:
  786. 663 Diagnostics.diagS( 'Entering SmartScreen', '' );
  787. 664 :EntryDiag*)
  788. 665
  789. 666 VStorage.NilHandle( NilValue );
  790. 667 VideoMethod := DMA;
  791. 668 ForeGround := lightgrey;
  792. 669 BackGround := black;
  793. 670 TextModeNow := AttributeSet{ plain};
  794. 671 MakeAttrByte();
  795. 672 MaxCol := 80;
  796. 673 MaxRow := 25;
  797. 674
  798. 675 (*
  799. 676 ScreenModeNow :=RealVideoMode();
  800. 677 *)
  801. 678 SetVideoVars();
  802. 679
  803. 680 (*EntryDiag:
  804. 681 Diagnostics.diagS( 'Exiting SmartScreen', '' );
  805. 682 :EntryDiag*)
  806. 683 END Init;
  807. 684
  808. 685 BEGIN
  809. 686 Initialized := FALSE;
  810. 687 Init();
  811. 688 END SmartScreen.
  812. 122 errors