TSRCALC.LST 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591
  1. Listing:
  2. 1 (*========================================================
  3. 2 == JPI-TopSpeed Modula-2 V2 ==
  4. 3 == demo program: ==
  5. 4 == ==
  6. 5 == Terminate and Stay Resident Calculator ==
  7. 6 == ==
  8. 7 ========================================================*)
  9. 8
  10. 9 (*# data(stack_size=>2000H) *)
  11. 10 (*# check(stack=>off,index=>off,range=>off,overflow=>off,nil_ptr=>off) *)
  12. 11 (*# debug(vid=>off) *)
  13. 12
  14. 13 MODULE TSRcalc;
  15. 14 (* ==== *)
  16. 15
  17. 16 IMPORT IO,Window,Lib,SYSTEM,Storage;
  18. 17 IMPORT TSR ;
  19. 18
  20. 19 CONST Ix = 30;
  21. 20 Iy = 10;
  22. 21 Sx = 22;
  23. 22 Sy = 2;
  24. 23
  25. 24 TYPE LONGSET = SET OF [0..31];
  26. ***** ^ not supported yet
  27. 25
  28. 26 StateType = (DigState,NumState,OptState);
  29. 27
  30. 28 ModeType = (DecMode,HexMode,BinMode);
  31. 29
  32. 30 ModeInfRec = RECORD
  33. 31 Name:ARRAY[1..4] OF CHAR;
  34. ***** ^ not supported yet
  35. ***** ^ not supported yet
  36. 32 Base:CARDINAL;
  37. 33 END;
  38. ***** ^ not supported yet
  39. 34
  40. 35 ModeInfArr = ARRAY ModeType OF ModeInfRec;
  41. ***** ^ not supported yet
  42. ***** ^ not supported yet
  43. 36
  44. 37 CONST ModeInf = ModeInfArr(ModeInfRec("Dec",10),ModeInfRec("Hex",16),ModeInfRec
  45. ***** ^ not supported yet
  46. ***** ^ not supported yet
  47. ***** ^ not supported yet
  48. ***** ^ not supported yet
  49. 38 ("Bin",2));
  50. ***** ^ not supported yet
  51. ***** ^ not supported yet
  52. 39
  53. 40 VAR Value,Other,Memory :LONGINT;
  54. 41 Mode :ModeType;
  55. ***** ^ not supported yet
  56. 42 State :StateType;
  57. ***** ^ not supported yet
  58. 43 Q,C,Opt :CHAR;
  59. 44 W :Window.WinType;
  60. ***** ^ not supported yet
  61. 45 X,Y :CARDINAL;
  62. 46
  63. 47
  64. 48 CONST KeyL = CHR(128+75);
  65. ***** ^ undeclared identifier
  66. ***** ^ not supported yet
  67. 49 KeyR = CHR(128+77);
  68. ***** ^ undeclared identifier
  69. ***** ^ not supported yet
  70. 50 KeyU = CHR(128+72);
  71. ***** ^ undeclared identifier
  72. ***** ^ not supported yet
  73. 51 KeyD = CHR(128+80);
  74. ***** ^ undeclared identifier
  75. ***** ^ not supported yet
  76. 52 Key5 = CHR(128+63);
  77. ***** ^ undeclared identifier
  78. ***** ^ not supported yet
  79. 53 Key10 = CHR(128+68);
  80. ***** ^ undeclared identifier
  81. ***** ^ not supported yet
  82. 54
  83. 55 PROCEDURE BiosGetKey():CHAR;
  84. 56 (* ========== *)
  85. 57
  86. 58 VAR R:SYSTEM.Registers;
  87. ***** ^ not supported yet
  88. 59
  89. 60 BEGIN
  90. 61 R.AH := 0;
  91. ***** ^ not supported yet
  92. ***** ^ not supported yet
  93. 62 Lib.Intr(R,016H);
  94. ***** ^ not supported yet
  95. ***** ^ not supported yet
  96. ***** ^ not supported yet
  97. ***** ^ not supported yet
  98. 63 IF R.AL<>0 THEN
  99. ***** ^ not supported yet
  100. ***** ^ not supported yet
  101. 64 RETURN CHR(R.AL);
  102. ***** ^ undeclared identifier
  103. ***** ^ not supported yet
  104. ***** ^ not supported yet
  105. 65 ELSE
  106. 66 RETURN CHR(128+R.AH);
  107. ***** ^ undeclared identifier
  108. ***** ^ not supported yet
  109. ***** ^ not supported yet
  110. 67 END;
  111. 68 END BiosGetKey;
  112. ***** ^ not supported yet
  113. 69
  114. 70 PROCEDURE UpdateDisplay;
  115. 71 (* ============== *)
  116. 72
  117. 73 CONST Width = 16;
  118. 74
  119. 75 VAR I:CARDINAL;
  120. 76
  121. 77 BEGIN
  122. 78 Window.GotoXY(4,1);
  123. ***** ^ not supported yet
  124. ***** ^ not supported yet
  125. ***** ^ not supported yet
  126. 79 CASE Mode OF
  127. ***** ^ not supported yet
  128. 80
  129. 81 | DecMode:IO.WrLngInt(Value,Width);
  130. ***** ^ not supported yet
  131. ***** ^ not supported yet
  132. ***** ^ not supported yet
  133. ***** ^ not supported yet
  134. 82 | HexMode:IO.WrLngHex(Value,Width);
  135. ***** ^ not supported yet
  136. ***** ^ not supported yet
  137. ***** ^ not supported yet
  138. ***** ^ not supported yet
  139. 83 | BinMode:FOR I := Width-1 TO 0 BY -1 DO
  140. ***** ^ not supported yet
  141. 84 IO.WrChar(CHR(ORD('0')+ORD(I IN LONGSET(Value))));
  142. ***** ^ not supported yet
  143. ***** ^ not supported yet
  144. ***** ^ undeclared identifier
  145. ***** ^ undeclared identifier
  146. ***** ^ not supported yet
  147. ***** ^ undeclared identifier
  148. ***** ^ not supported yet
  149. 85 END;
  150. 86
  151. 87 END;
  152. 88 Window.GotoXY(4,2);
  153. ***** ^ not supported yet
  154. ***** ^ not supported yet
  155. ***** ^ not supported yet
  156. 89 IO.WrStr(ModeInf[Mode].Name);
  157. ***** ^ not supported yet
  158. ***** ^ not supported yet
  159. ***** ^ not supported yet
  160. ***** ^ not supported yet
  161. 90 IO.WrStr(" ");
  162. ***** ^ not supported yet
  163. ***** ^ not supported yet
  164. ***** ^ not supported yet
  165. 91 IF Memory<>0 THEN
  166. 92 IO.WrStr("M");
  167. ***** ^ not supported yet
  168. ***** ^ not supported yet
  169. ***** ^ not supported yet
  170. 93 ELSE
  171. 94 IO.WrStr(" ");
  172. ***** ^ not supported yet
  173. ***** ^ not supported yet
  174. ***** ^ not supported yet
  175. 95 END;
  176. 96 END UpdateDisplay;
  177. ***** ^ not supported yet
  178. 97
  179. 98 PROCEDURE Crash(L:CARDINAL);
  180. 99 (* ===== *)
  181. 100
  182. 101
  183. 102 VAR I:SHORTCARD;
  184. 103 J:CARDINAL;
  185. 104 P,Q:BITSET;
  186. ***** ^ undeclared identifier
  187. 105
  188. 106 BEGIN
  189. 107 Q := BITSET(SYSTEM.In(061H));
  190. ***** ^ not supported yet
  191. ***** ^ undeclared identifier
  192. ***** ^ not supported yet
  193. ***** ^ not supported yet
  194. ***** ^ not supported yet
  195. 108 P := Q*{2..7};
  196. ***** ^ not supported yet
  197. ***** ^ not supported yet
  198. ***** ^ not supported yet
  199. ***** ^ not supported yet
  200. 109 J := L;
  201. 110 WHILE J>0 DO
  202. 111 SYSTEM.Out(061H,SHORTCARD(P));
  203. ***** ^ not supported yet
  204. ***** ^ not supported yet
  205. ***** ^ not supported yet
  206. 112 FOR I := 0 TO SHORTCARD([400H:J]^) DO
  207. ***** ^ not supported yet
  208. ***** ^ not supported yet
  209. 113 P := P/{1};
  210. ***** ^ not supported yet
  211. ***** ^ not supported yet
  212. ***** ^ not supported yet
  213. 114 END;
  214. 115 DEC(J);
  215. ***** ^ undeclared identifier
  216. ***** ^ not supported yet
  217. 116 END;
  218. 117 SYSTEM.Out(061H,SHORTCARD(Q));
  219. ***** ^ not supported yet
  220. ***** ^ not supported yet
  221. ***** ^ not supported yet
  222. 118 L := L DIV 100;
  223. 119 IF (X>=L) AND (Y>=L) THEN
  224. 120 FOR J := 1 TO L DO
  225. 121 DEC(X);
  226. ***** ^ undeclared identifier
  227. ***** ^ not supported yet
  228. 122 DEC(Y);
  229. ***** ^ undeclared identifier
  230. ***** ^ not supported yet
  231. 123 Window.Change(W,X,Y,X+Sx+J+J,Y+Sy+J+J);
  232. ***** ^ not supported yet
  233. ***** ^ not supported yet
  234. ***** ^ not supported yet
  235. ***** ^ not supported yet
  236. 124 END;
  237. 125 FOR J := L TO 1 BY -1 DO
  238. 126 INC(X);
  239. ***** ^ undeclared identifier
  240. ***** ^ not supported yet
  241. 127 INC(Y);
  242. ***** ^ undeclared identifier
  243. ***** ^ not supported yet
  244. 128 Window.Change(W,X,Y,X+Sx+J+J-1,Y+Sy+J+J-1);
  245. ***** ^ not supported yet
  246. ***** ^ not supported yet
  247. ***** ^ not supported yet
  248. ***** ^ not supported yet
  249. 129 END;
  250. 130 END
  251. 131 END Crash;
  252. ***** ^ not supported yet
  253. 132
  254. 133
  255. 134 PROCEDURE RunCalc;
  256. 135 (* ======= *)
  257. 136
  258. 137 VAR I,F:CARDINAL;
  259. 138 R:SYSTEM.Registers;
  260. ***** ^ not supported yet
  261. 139
  262. 140 BEGIN
  263. 141 Window.PutOnTop(W);
  264. ***** ^ not supported yet
  265. ***** ^ not supported yet
  266. ***** ^ not supported yet
  267. 142 Window.Use(W);
  268. ***** ^ not supported yet
  269. ***** ^ not supported yet
  270. ***** ^ not supported yet
  271. 143 LOOP
  272. 144 CASE C OF
  273. 145 | 'c':Value := 0;
  274. 146 Other := 0;
  275. 147 Opt := '=';
  276. 148 | '0'..'9','A'..'F',
  277. 149 Key5..Key10:IF C<='9' THEN
  278. 150 DEC(C,ORD('0'));
  279. ***** ^ undeclared identifier
  280. ***** ^ undeclared identifier
  281. ***** ^ not supported yet
  282. 151 ELSIF (C>='A')AND(C<='F') THEN
  283. 152 DEC(C,ORD('A'));
  284. ***** ^ undeclared identifier
  285. ***** ^ undeclared identifier
  286. ***** ^ not supported yet
  287. 153 INC(C,10);
  288. ***** ^ undeclared identifier
  289. ***** ^ not supported yet
  290. 154 ELSE
  291. 155 DEC(C,ORD(Key5));
  292. ***** ^ undeclared identifier
  293. ***** ^ undeclared identifier
  294. ***** ^ not supported yet
  295. 156 INC(C,10);
  296. ***** ^ undeclared identifier
  297. ***** ^ not supported yet
  298. 157 END;
  299. 158 IF ORD(C)<ModeInf[Mode].Base THEN
  300. ***** ^ undeclared identifier
  301. ***** ^ not supported yet
  302. ***** ^ not supported yet
  303. ***** ^ not supported yet
  304. 159 IF State<>DigState THEN
  305. ***** ^ not supported yet
  306. ***** ^ not supported yet
  307. 160 Value := 0;
  308. 161 END;
  309. 162 State := DigState;
  310. ***** ^ not supported yet
  311. ***** ^ not supported yet
  312. 163 IF Value<=MAX(LONGINT) DIV LONGINT(ModeInf[Mode].Base)
  313. ***** ^ undeclared identifier
  314. ***** ^ not supported yet
  315. ***** ^ not supported yet
  316. ***** ^ not supported yet
  317. 164 THEN
  318. 165 Value := Value*LONGINT(ModeInf[Mode].Base)+LONGINT(ORD
  319. ***** ^ not supported yet
  320. ***** ^ not supported yet
  321. ***** ^ undeclared identifier
  322. 166 (C));
  323. ***** ^ not supported yet
  324. 167 ELSE
  325. 168 Crash(50);
  326. ***** ^ not supported yet
  327. ***** ^ not supported yet
  328. 169 END;
  329. 170 ELSE
  330. 171 Crash(100);
  331. ***** ^ not supported yet
  332. ***** ^ not supported yet
  333. 172 END;
  334. 173 | 10C:IF State = DigState THEN
  335. ***** ^ not supported yet
  336. ***** ^ not supported yet
  337. 174 Value := Value DIV LONGINT(ModeInf[Mode].Base);
  338. ***** ^ not supported yet
  339. ***** ^ not supported yet
  340. 175 END;
  341. 176 | 'e':Value := 0;
  342. 177 State := NumState;
  343. ***** ^ not supported yet
  344. ***** ^ not supported yet
  345. 178
  346. 179 | '+','-','*','/','a','o','x','=',CHR(13),'X','O':
  347. ***** ^ undeclared identifier
  348. ***** ^ not supported yet
  349. 180 IF State<>OptState THEN
  350. ***** ^ not supported yet
  351. ***** ^ not supported yet
  352. 181 CASE Opt OF
  353. 182
  354. 183 | '+':Other := Other+Value;
  355. 184 | '-':Other := Other-Value;
  356. 185 | '*':Other := Other*Value;
  357. 186 | '/':
  358. 187 IF Value = 0 THEN Other := MAX(LONGINT)
  359. ***** ^ undeclared identifier
  360. ***** ^ not supported yet
  361. 188 ELSE Other := Other DIV Value;
  362. 189 END;
  363. 190 | 'a':Other := LONGINT(LONGSET(Other)*LONGSET(Value));
  364. ***** ^ not supported yet
  365. ***** ^ not supported yet
  366. 191 | 'O',
  367. 192 'o':Other := LONGINT(LONGSET(Other)+LONGSET(Value));
  368. ***** ^ not supported yet
  369. ***** ^ not supported yet
  370. 193 | 'X',
  371. 194 'x':Other := LONGINT(LONGSET(Other)/LONGSET(Value));
  372. ***** ^ not supported yet
  373. ***** ^ not supported yet
  374. 195 | CHR(13),
  375. ***** ^ undeclared identifier
  376. ***** ^ not supported yet
  377. 196 '=':Other := Value;
  378. 197
  379. 198 END;
  380. 199 Value := Other;
  381. 200 State := OptState;
  382. ***** ^ not supported yet
  383. ***** ^ not supported yet
  384. 201 END;
  385. 202 Opt := C;
  386. 203 | 'd':Mode := DecMode;
  387. ***** ^ not supported yet
  388. ***** ^ not supported yet
  389. 204 State := NumState;
  390. ***** ^ not supported yet
  391. ***** ^ not supported yet
  392. 205 | 'H',
  393. 206 'h':Mode := HexMode;
  394. ***** ^ not supported yet
  395. ***** ^ not supported yet
  396. 207 State := NumState;
  397. ***** ^ not supported yet
  398. ***** ^ not supported yet
  399. 208 | 'b':Mode := BinMode;
  400. ***** ^ not supported yet
  401. ***** ^ not supported yet
  402. 209 State := NumState;
  403. ***** ^ not supported yet
  404. ***** ^ not supported yet
  405. 210 | 'M',
  406. 211 'm':C := BiosGetKey();
  407. ***** ^ not supported yet
  408. ***** ^ not supported yet
  409. 212 CASE CAP(C) OF
  410. ***** ^ undeclared identifier
  411. ***** ^ not supported yet
  412. 213
  413. 214 | '+':Memory := Memory+Value;
  414. 215 | '-':Memory := Memory-Value;
  415. 216 | '*':Memory := Memory*Value;
  416. 217 | '/':Memory := Memory DIV Value;
  417. 218 | 'R':Value := Memory;
  418. 219 State := NumState;
  419. ***** ^ not supported yet
  420. ***** ^ not supported yet
  421. 220 | 'C':Memory := 0;
  422. 221 | '=':Memory := Value;
  423. 222
  424. 223 END;
  425. 224 State := NumState;
  426. ***** ^ not supported yet
  427. ***** ^ not supported yet
  428. 225 | KeyL,KeyR,
  429. 226 KeyU,KeyD:
  430. 227
  431. 228 IF (C = KeyL) AND (X>0) THEN DEC(X);
  432. ***** ^ undeclared identifier
  433. ***** ^ not supported yet
  434. 229 ELSIF (C = KeyR) AND (X+Sx<78) THEN INC(X);
  435. ***** ^ undeclared identifier
  436. ***** ^ not supported yet
  437. 230 ELSIF (C = KeyU) AND (Y>0) THEN DEC(Y);
  438. ***** ^ undeclared identifier
  439. ***** ^ not supported yet
  440. 231 ELSIF (C = KeyD) AND (Y+Sy<23) THEN INC(Y);
  441. ***** ^ undeclared identifier
  442. ***** ^ not supported yet
  443. 232 ELSE
  444. 233 F := 2000;
  445. 234 WHILE (X<>Ix) OR (Y<>Iy) DO
  446. 235 FOR I := 1 TO 10 DO
  447. 236 Lib.Sound(F);
  448. ***** ^ not supported yet
  449. ***** ^ not supported yet
  450. ***** ^ not supported yet
  451. 237 Lib.Delay(5);
  452. ***** ^ not supported yet
  453. ***** ^ not supported yet
  454. ***** ^ not supported yet
  455. 238 DEC(F,F DIV 50);
  456. ***** ^ undeclared identifier
  457. ***** ^ not supported yet
  458. 239 END;
  459. 240 IF X>Ix THEN DEC(X); END;
  460. ***** ^ undeclared identifier
  461. ***** ^ not supported yet
  462. 241 IF X<Ix THEN INC(X); END;
  463. ***** ^ undeclared identifier
  464. ***** ^ not supported yet
  465. 242 IF Y>Iy THEN DEC(Y); END;
  466. ***** ^ undeclared identifier
  467. ***** ^ not supported yet
  468. 243 IF Y<Iy THEN INC(Y); END;
  469. ***** ^ undeclared identifier
  470. ***** ^ not supported yet
  471. 244 Window.Change(W,X,Y,X+Sx+1,Y+Sy+1);
  472. ***** ^ not supported yet
  473. ***** ^ not supported yet
  474. ***** ^ not supported yet
  475. ***** ^ not supported yet
  476. 245 END;
  477. 246 Lib.NoSound;
  478. ***** ^ not supported yet
  479. ***** ^ not supported yet
  480. 247 Crash(800);
  481. ***** ^ not supported yet
  482. ***** ^ not supported yet
  483. 248 C := ' ';
  484. 249 EXIT;
  485. 250 END;
  486. 251 Window.Change(W,X,Y,X+Sx+1,Y+Sy+1);
  487. ***** ^ not supported yet
  488. ***** ^ not supported yet
  489. ***** ^ not supported yet
  490. ***** ^ not supported yet
  491. 252 | ' ':;
  492. 253 | CHR(27):
  493. ***** ^ undeclared identifier
  494. ***** ^ not supported yet
  495. 254 C := ' ';
  496. 255 EXIT;
  497. 256 | CHR(45+128): (* ALT X *)
  498. ***** ^ undeclared identifier
  499. ***** ^ not supported yet
  500. 257 TSR.DeInstall ;
  501. ***** ^ not supported yet
  502. ***** ^ not supported yet
  503. 258 EXIT ;
  504. 259 |
  505. 260 ELSE
  506. 261 Crash(200);
  507. ***** ^ not supported yet
  508. ***** ^ not supported yet
  509. 262 END;
  510. 263 UpdateDisplay;
  511. ***** ^ not supported yet
  512. 264 C := BiosGetKey();
  513. ***** ^ not supported yet
  514. ***** ^ not supported yet
  515. 265 END;
  516. 266 Window.Hide(W);
  517. ***** ^ not supported yet
  518. ***** ^ not supported yet
  519. ***** ^ not supported yet
  520. 267 END RunCalc;
  521. ***** ^ not supported yet
  522. 268
  523. 269
  524. 270
  525. 271 BEGIN
  526. 272 IO.WrStr("Installing JPI-CALC,"); IO.WrLn;
  527. ***** ^ not supported yet
  528. ***** ^ not supported yet
  529. ***** ^ not supported yet
  530. ***** ^ not supported yet
  531. ***** ^ not supported yet
  532. 273 IO.WrStr("AltZ to activate."); IO.WrLn;
  533. ***** ^ not supported yet
  534. ***** ^ not supported yet
  535. ***** ^ not supported yet
  536. ***** ^ not supported yet
  537. ***** ^ not supported yet
  538. 274 X := Ix;
  539. 275 Y := Iy;
  540. 276 W := Window.Open(Window.WinDef(Ix,Iy,Ix+Sx+1,Iy+Sy+1,
  541. ***** ^ not supported yet
  542. ***** ^ not supported yet
  543. ***** ^ not supported yet
  544. ***** ^ not supported yet
  545. ***** ^ not supported yet
  546. 277 Window.White,Window.Black,
  547. ***** ^ not supported yet
  548. ***** ^ not supported yet
  549. ***** ^ not supported yet
  550. ***** ^ not supported yet
  551. 278 FALSE,FALSE,TRUE,TRUE,
  552. 279 Window.DoubleFrame,Window.Black,
  553. ***** ^ not supported yet
  554. ***** ^ not supported yet
  555. ***** ^ not supported yet
  556. ***** ^ not supported yet
  557. 280 Window.Green));
  558. ***** ^ not supported yet
  559. ***** ^ not supported yet
  560. 281 Window.SetTitle(W," JPI-CALC ",Window.CenterUpperTitle);
  561. ***** ^ not supported yet
  562. ***** ^ not supported yet
  563. ***** ^ not supported yet
  564. ***** ^ not supported yet
  565. ***** ^ not supported yet
  566. ***** ^ not supported yet
  567. 282 Memory := 0;
  568. 283 Mode := DecMode;
  569. ***** ^ not supported yet
  570. ***** ^ not supported yet
  571. 284 State := NumState;
  572. ***** ^ not supported yet
  573. ***** ^ not supported yet
  574. 285 C := 'c';
  575. 286 TSR.Install(RunCalc,TSR.KBFlagSet{TSR.Alt},44,400H) ; (* ALT Z *)
  576. ***** ^ not supported yet
  577. ***** ^ not supported yet
  578. ***** ^ not supported yet
  579. ***** ^ not supported yet
  580. ***** ^ not supported yet
  581. 287 Window.Clear ;
  582. 288 IO.WrStr("JPI-CALC Deinstalled.");
  583. 289 IO.WrLn;
  584. 290 END TSRcalc.
  585. 291 (*======================================================*)
  586. 292
  587. 293 errors