crt.pp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1993,97 by Florian Klaempfl,
  5. member of the Free Pascal development team.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. unit crt;
  13. interface
  14. {$I os.inc}
  15. {$I386_ATT}
  16. const
  17. { CRT modes }
  18. BW40 = 0; { 40x25 B/W on Color Adapter }
  19. CO40 = 1; { 40x25 Color on Color Adapter }
  20. BW80 = 2; { 80x25 B/W on Color Adapter }
  21. CO80 = 3; { 80x25 Color on Color Adapter }
  22. Mono = 7; { 80x25 on Monochrome Adapter }
  23. Font8x8 = 256; { Add-in for ROM font }
  24. { Mode constants for 3.0 compatibility }
  25. C40 = CO40;
  26. C80 = CO80;
  27. { Foreground and background color constants }
  28. Black = 0;
  29. Blue = 1;
  30. Green = 2;
  31. Cyan = 3;
  32. Red = 4;
  33. Magenta = 5;
  34. Brown = 6;
  35. LightGray = 7;
  36. { Foreground color constants }
  37. DarkGray = 8;
  38. LightBlue = 9;
  39. LightGreen = 10;
  40. LightCyan = 11;
  41. LightRed = 12;
  42. LightMagenta = 13;
  43. Yellow = 14;
  44. White = 15;
  45. { Add-in for blinking }
  46. Blink = 128;
  47. var
  48. { Interface variables }
  49. CheckBreak: Boolean; { Enable Ctrl-Break }
  50. CheckEOF: Boolean; { Enable Ctrl-Z }
  51. DirectVideo: Boolean; { Enable direct video addressing }
  52. CheckSnow: Boolean; { Enable snow filtering }
  53. LastMode: Word; { Current text mode }
  54. TextAttr: Byte; { Current text attribute }
  55. WindMin: Word; { Window upper left coordinates }
  56. WindMax: Word; { Window lower right coordinates }
  57. { Interface procedures }
  58. procedure AssignCrt(var F: Text);
  59. function KeyPressed: Boolean;
  60. function ReadKey: Char;
  61. procedure TextMode(Mode: Integer);
  62. procedure Window(X1,Y1,X2,Y2: Byte);
  63. procedure GotoXY(X,Y: Byte);
  64. function WhereX: Byte;
  65. function WhereY: Byte;
  66. procedure ClrScr;
  67. procedure ClrEol;
  68. procedure InsLine;
  69. procedure DelLine;
  70. procedure TextColor(Color: Byte);
  71. procedure TextBackground(Color: Byte);
  72. procedure LowVideo;
  73. procedure HighVideo;
  74. procedure NormVideo;
  75. procedure Delay(MS: Word);
  76. procedure Sound(Hz: Word);
  77. procedure NoSound;
  78. {Extra Functions}
  79. procedure cursoron;
  80. procedure cursoroff;
  81. procedure cursorbig;
  82. implementation
  83. uses
  84. go32;
  85. var
  86. startattrib : byte;
  87. col,row,
  88. maxcols,maxrows : longint;
  89. {
  90. definition of textrec is in textrec.inc
  91. }
  92. {$i textrec.inc}
  93. {****************************************************************************
  94. Low level Routines
  95. ****************************************************************************}
  96. procedure setscreenmode(mode : byte);
  97. var regs : trealregs;
  98. begin
  99. {$ifdef GO32V2}
  100. regs.realeax:=mode;
  101. realintr($10,regs);
  102. {$else GO32V2}
  103. asm
  104. movb 8(%ebp),%al
  105. xorb %ah,%ah
  106. pushl %ebp
  107. int $0x10
  108. popl %ebp
  109. end;
  110. {$endif GO32V2}
  111. end;
  112. function screenrows : byte;
  113. begin
  114. {$ifdef GO32V2}
  115. screenrows:=mem[$40:$84]+1;
  116. {$else}
  117. dosmemget($40,$84,screenrows,1);
  118. inc(screenrows);
  119. {$endif}
  120. end;
  121. function screencols : byte;
  122. begin
  123. {$ifdef GO32V2}
  124. screencols:=mem[$40:$4a];
  125. {$else}
  126. dosmemget($40,$4a,screencols,1);
  127. {$endif}
  128. end;
  129. function get_addr(row,col : byte) : word;
  130. begin
  131. get_addr:=((row-1)*maxcols+(col-1))*2;
  132. end;
  133. procedure screensetcursor(row,col : longint);
  134. var
  135. {$ifdef GO32V2}
  136. regs : trealregs;
  137. {$endif GO32V2}
  138. begin
  139. {$ifndef GO32V2}
  140. asm
  141. movb $0x02,%ah
  142. movb $0,%bh
  143. movb row,%dh
  144. movb col,%dl
  145. subw $0x0101,%dx
  146. pushl %ebp
  147. int $0x10
  148. popl %ebp
  149. end;
  150. {$else GO32V2}
  151. regs.realeax:=$0200;
  152. regs.realebx:=0;
  153. regs.realedx:=(row-1)*$100+(col-1);
  154. realintr($10,regs);
  155. {$endif GO32V2}
  156. end;
  157. procedure screengetcursor(var row,col : longint);
  158. begin
  159. {$ifdef Go32V2}
  160. col:=mem[$40:$50]+1;
  161. row:=mem[$40:$51]+1;
  162. {$else}
  163. col:=0;
  164. row:=0;
  165. dosmemget($40,$50,col,1);
  166. dosmemget($40,$51,row,1);
  167. inc(col);
  168. inc(row);
  169. {$endif}
  170. end;
  171. { exported routines }
  172. procedure cursoron;
  173. {$ifdef GO32V2}
  174. var regs : trealregs;
  175. {$endif GO32V2}
  176. begin
  177. {$ifndef GO32V2}
  178. asm
  179. movb $1,%ah
  180. movb $10,%cl
  181. movb $9,%ch
  182. pushl %ebp
  183. int $0x10
  184. popl %ebp
  185. end;
  186. {$else GO32V2}
  187. regs.realeax:=$0100;
  188. regs.realecx:=$90A;
  189. realintr($10,regs);
  190. {$endif GO32V2}
  191. end;
  192. procedure cursoroff;
  193. {$ifdef GO32V2}
  194. var regs : trealregs;
  195. {$endif GO32V2}
  196. begin
  197. {$ifndef GO32V2}
  198. asm
  199. movb $1,%ah
  200. movb $-1,%cl
  201. movb $-1,%ch
  202. pushl %ebp
  203. int $0x10
  204. popl %ebp
  205. end;
  206. {$else GO32V2}
  207. regs.realeax:=$0100;
  208. regs.realecx:=$ffff;
  209. realintr($10,regs);
  210. {$endif GO32V2}
  211. end;
  212. procedure cursorbig;
  213. {$ifdef GO32V2}
  214. var
  215. regs : trealregs;
  216. {$endif GO32V2}
  217. begin
  218. {$ifdef GO32V2}
  219. regs.realeax:=$0100;
  220. regs.realecx:=$10A;
  221. realintr($10,regs);
  222. {$else GO32V2}
  223. asm
  224. movb $1,%ah
  225. movb $10,%cl
  226. movb $1,%ch
  227. pushl %ebp
  228. int $0x10
  229. popl %ebp
  230. end;
  231. {$endif GO32V2}
  232. end;
  233. var
  234. is_last : boolean;
  235. last : char;
  236. function readkey : char;
  237. var
  238. char2 : char;
  239. char1 : char;
  240. {$ifdef GO32V2}
  241. regs : trealregs;
  242. {$endif GO32V2}
  243. begin
  244. if is_last then
  245. begin
  246. is_last:=false;
  247. readkey:=last;
  248. end
  249. else
  250. begin
  251. {$ifdef GO32V2}
  252. regs.realeax:=$0000;
  253. realintr($16,regs);
  254. byte(char1):=regs.realeax and $ff;
  255. byte(char2):=(regs.realeax and $ff00) shr 8;
  256. {$else GO32V2}
  257. asm
  258. movb $0,%ah
  259. pushl %ebp
  260. int $0x16
  261. popl %ebp
  262. movb %al,char1
  263. movb %ah,char2
  264. end;
  265. {$endif GO32V2}
  266. if char1=#0 then
  267. begin
  268. is_last:=true;
  269. last:=char2;
  270. end;
  271. readkey:=char1;
  272. end;
  273. end;
  274. function keypressed : boolean;
  275. {$ifdef GO32V2}
  276. var regs : trealregs;
  277. {$endif GO32V2}
  278. begin
  279. if is_last then
  280. begin
  281. keypressed:=true;
  282. exit;
  283. end
  284. else
  285. {$ifdef GO32V2}
  286. begin
  287. regs.realeax:=$0100;
  288. realintr($16,regs);
  289. if (regs.realflags and zeroflag) = 0 then
  290. keypressed:=true
  291. else keypressed:=false;
  292. end;
  293. {$else GO32V2}
  294. asm
  295. movb $1,%ah
  296. pushl %ebp
  297. int $0x16
  298. popl %ebp
  299. setnz %al
  300. movb %al,__RESULT
  301. end;
  302. {$endif GO32V2}
  303. end;
  304. procedure gotoxy(x,y : byte);
  305. begin
  306. if (x<1) then
  307. x:=1;
  308. if (y<1) then
  309. y:=1;
  310. if y+hi(windmin)-2>=hi(windmax) then
  311. y:=hi(windmax)-hi(windmin)+1;
  312. if x+lo(windmin)-2>=lo(windmax) then
  313. x:=lo(windmax)-lo(windmin)+1;
  314. screensetcursor(y+hi(windmin),x+lo(windmin));
  315. end;
  316. function wherex : byte;
  317. var
  318. row,col : longint;
  319. begin
  320. screengetcursor(row,col);
  321. wherex:=col-lo(windmin);
  322. end;
  323. function wherey : byte;
  324. var
  325. row,col : longint;
  326. begin
  327. screengetcursor(row,col);
  328. wherey:=row-hi(windmin);
  329. end;
  330. procedure Window(X1,Y1,X2,Y2: Byte);
  331. begin
  332. if (x1<1) or (x2>screencols) or (y2>screenrows) or
  333. (x1>x2) or (y1>y2) then
  334. exit;
  335. windmin:=(x1-1) or ((x1-1) shl 8);
  336. windmax:=(x2-1) or ((y2-1) shl 8);
  337. gotoxy(1,1);
  338. end;
  339. procedure clrscr;
  340. var
  341. fil : word;
  342. row : longint;
  343. begin
  344. fil:=32 or (textattr shl 8);
  345. for row:=hi(windmin) to hi(windmax) do
  346. dosmemfillword($b800,get_addr(row+1,lo(windmin)+1),lo(windmax)-lo(windmin)+1,fil);
  347. gotoxy(1,1);
  348. end;
  349. procedure textcolor(color : Byte);
  350. begin
  351. textattr:=(textattr and $70) or color;
  352. end;
  353. procedure lowvideo;
  354. begin
  355. textattr:=textattr and $f7;
  356. end;
  357. procedure highvideo;
  358. begin
  359. textattr:=textattr or $08;
  360. end;
  361. procedure textbackground(color : Byte);
  362. begin
  363. textattr:=(textattr and $8f) or ((color and $7) shl 4);
  364. end;
  365. procedure normvideo;
  366. begin
  367. textattr:=startattrib;
  368. end;
  369. procedure removeline(line : byte);
  370. var
  371. row,left,right,bot : longint;
  372. fil : word;
  373. begin
  374. row:=line+hi(windmin);
  375. left:=lo(windmin)+1;
  376. right:=lo(windmax)+1;
  377. bot:=hi(windmax)+1;
  378. fil:=32 or (textattr shl 8);
  379. while (row<bot) do
  380. begin
  381. dosmemmove($b800,get_addr(row+1,left),$b800,get_addr(row,left),(right-left+1)*2);
  382. inc(row);
  383. end;
  384. dosmemfillword($b800,get_addr(bot,left),right-left+1,fil);
  385. end;
  386. procedure delline;
  387. begin
  388. removeline(wherey);
  389. end;
  390. procedure insline;
  391. var
  392. row,col,left,right,bot : longint;
  393. fil : word;
  394. begin
  395. screengetcursor(row,col);
  396. inc(row);
  397. left:=lo(windmin)+1;
  398. right:=lo(windmax)+1;
  399. bot:=hi(windmax);
  400. fil:=32 or (textattr shl 8);
  401. while (bot>row) do
  402. begin
  403. dosmemmove($b800,get_addr(bot-1,left),$b800,get_addr(bot,left),(right-left+1)*2);
  404. dec(bot);
  405. end;
  406. dosmemfillword($b800,get_addr(row,left),right-left+1,fil);
  407. end;
  408. procedure clreol;
  409. var
  410. row,col : longint;
  411. fil : word;
  412. begin
  413. screengetcursor(row,col);
  414. fil:=32 or (textattr shl 8);
  415. dosmemfillword($b800,get_addr(row,col),lo(windmax)-col+2,fil);
  416. end;
  417. procedure sound(hz : word);
  418. begin
  419. if hz=0 then
  420. begin
  421. nosound;
  422. exit;
  423. end;
  424. asm
  425. movzwl hz,%ecx
  426. movl $1193046,%eax
  427. cdq
  428. divl %ecx
  429. movl %eax,%ecx
  430. movb $0xb6,%al
  431. outb %al,$0x43
  432. movb %cl,%al
  433. outb %al,$0x42
  434. movb %ch,%al
  435. outb %al,$0x42
  436. inb $0x61,%al
  437. orb $0x3,%al
  438. outb %al,$0x61
  439. end ['EAX','ECX','EDX'];
  440. end;
  441. procedure nosound;
  442. begin
  443. asm
  444. inb $0x61,%al
  445. andb $0xfc,%al
  446. outb %al,$0x61
  447. end ['EAX'];
  448. end;
  449. var
  450. calibration : longint;
  451. {$ifdef GO32V2}
  452. get_ticks : longint absolute $40:$6c;
  453. {$endif}
  454. {$ifndef GO32V2}
  455. function get_ticks:longint;
  456. begin
  457. dosmemget($40,$6c,get_ticks,4);
  458. end;
  459. {$endif}
  460. procedure Delay(MS: Word);
  461. var
  462. i,j : longint;
  463. begin
  464. for i:=1 to ms do
  465. for j:=1 to calibration do;
  466. end;
  467. procedure initdelay;
  468. { From the mailling list,
  469. by Jonathan Anderson ([email protected]) }
  470. const
  471. threshold=7;
  472. { Raise this to increase speed but decrease accuracy }
  473. { currently the calibration will be no more than 7 off }
  474. { and shave a few ticks off the most accurate setting of 0 }
  475. { The best values to pick are powers of 2-1 (0,1,3,7,15...) }
  476. { but any non-negative value will work. }
  477. var
  478. too_small : boolean;
  479. first,
  480. incval : longint;
  481. begin
  482. calibration:=0;
  483. { wait for new tick }
  484. first:=get_ticks;
  485. while get_ticks=first do
  486. begin
  487. end;
  488. first:=get_ticks;
  489. { this estimates calibration }
  490. while get_ticks=first do
  491. inc(calibration);
  492. {$ifdef GO32V2}
  493. calibration:=calibration div 55;
  494. {$else}
  495. calibration:=calibration div 3;
  496. {$endif}
  497. { The ideal guess value is about half of the real value }
  498. { although a value lower than that take a large performance }
  499. { hit compared to a value higher than that because it has to }
  500. { go through the loop a few times. }
  501. if calibration<(threshold+1)*2 then
  502. calibration:=(threshold+1)*2;
  503. { If calibration is not at least this value, an }
  504. { infinite loop will result. }
  505. repeat
  506. incval:=calibration div 4;
  507. if calibration<0 then
  508. begin
  509. calibration:=$7FFFFFFF;
  510. exit;
  511. end;
  512. { If calibration becomes less than 0, then }
  513. { the maximum value was not long enough, so }
  514. { assign it the maximum value and exit. }
  515. { Without this code, an infinite loop would }
  516. { result on superfast computers about 315800 }
  517. { times faster (oh yeah!) than my Pentium 75. }
  518. { If you don't think that will happen, take }
  519. { out the if and save a few clock cycles. }
  520. too_small:=true; { Assumed true at beginning }
  521. while incval>threshold do
  522. begin
  523. incval:=incval div 2;
  524. first:=get_ticks;
  525. while get_ticks=first do
  526. begin
  527. end;
  528. first:=get_ticks;
  529. delay(55);
  530. if first=get_ticks then
  531. calibration:=calibration+incval
  532. else
  533. begin
  534. calibration:=calibration-incval;
  535. too_small:=false;
  536. { If you have to decrement calibration, }
  537. { the initial value was not too small to }
  538. { result in an accurate measurement. }
  539. end;
  540. end;
  541. until not too_small;
  542. end;
  543. procedure textmode(mode : integer);
  544. var
  545. set_font8x8 : boolean;
  546. begin
  547. lastmode:=mode;
  548. set_font8x8:=(mode and font8x8)<>0;
  549. mode:=mode and $ff;
  550. setscreenmode(mode);
  551. windmin:=0;
  552. windmax:=(screencols-1) or ((screenrows-1) shl 8);
  553. maxcols:=screencols;
  554. maxrows:=screenrows;
  555. end;
  556. {*****************************************************************************
  557. Read and Write routines
  558. *****************************************************************************}
  559. Procedure WriteChar(c:char);
  560. var
  561. {$ifdef GO32V2}
  562. regs : trealregs;
  563. {$else}
  564. chattr : word;
  565. {$endif}
  566. begin
  567. case c of
  568. #10 : inc(row);
  569. #13 : col:=lo(windmin)+1;
  570. #8 : begin
  571. if col>lo(windmin)+1 then
  572. dec(col);
  573. end;
  574. #7 : begin { beep }
  575. {$ifdef GO32V2}
  576. regs.dl:=7;
  577. regs.ah:=2;
  578. realintr($21,regs);
  579. {$endif}
  580. end;
  581. else
  582. begin
  583. {$ifdef GO32V2}
  584. memw[$b800:get_addr(row,col)]:=(textattr shl 8) or byte(c);
  585. {$else}
  586. chattr:=(textattr shl 8) or byte(c);
  587. dosmemput($b800,get_addr(row,col),chattr,2);
  588. {$endif}
  589. inc(col);
  590. end;
  591. end;
  592. if col>lo(windmax)+1 then
  593. begin
  594. col:=lo(windmin)+1;
  595. inc(row);
  596. end;
  597. while row>hi(windmax)+1 do
  598. begin
  599. removeline(1);
  600. dec(row);
  601. end;
  602. end;
  603. Function CrtWrite(var f : textrec):integer;
  604. var
  605. i : longint;
  606. begin
  607. screengetcursor(row,col);
  608. for i:=0 to f.bufpos-1 do
  609. WriteChar(f.buffer[i]);
  610. f.bufpos:=0;
  611. screensetcursor(row,col);
  612. CrtWrite:=0;
  613. end;
  614. Function CrtRead(Var F: TextRec): Integer;
  615. procedure BackSpace;
  616. begin
  617. if (f.bufpos>0) and (f.bufpos=f.bufend) then
  618. begin
  619. WriteChar(#8);
  620. WriteChar(' ');
  621. WriteChar(#8);
  622. dec(f.bufpos);
  623. dec(f.bufend);
  624. end;
  625. end;
  626. var
  627. ch : Char;
  628. Begin
  629. f.bufpos:=0;
  630. f.bufend:=0;
  631. repeat
  632. if f.bufpos>f.bufend then
  633. f.bufend:=f.bufpos;
  634. screensetcursor(row,col);
  635. ch:=readkey;
  636. case ch of
  637. #0 : case readkey of
  638. #71 : while f.bufpos>0 do
  639. begin
  640. dec(f.bufpos);
  641. WriteChar(#8);
  642. end;
  643. #75 : if f.bufpos>0 then
  644. begin
  645. dec(f.bufpos);
  646. WriteChar(#8);
  647. end;
  648. #77 : if f.bufpos<f.bufend then
  649. begin
  650. WriteChar(f.bufptr^[f.bufpos]);
  651. inc(f.bufpos);
  652. end;
  653. #79 : while f.bufpos<f.bufend do
  654. begin
  655. WriteChar(f.bufptr^[f.bufpos]);
  656. inc(f.bufpos);
  657. end;
  658. end;
  659. ^S,
  660. #8 : BackSpace;
  661. ^Y,
  662. #27 : begin
  663. f.bufpos:=f.bufend;
  664. while f.bufend>0 do
  665. BackSpace;
  666. end;
  667. #13 : begin
  668. WriteChar(#13);
  669. WriteChar(#10);
  670. f.bufptr^[f.bufend]:=#13;
  671. f.bufptr^[f.bufend+1]:=#10;
  672. inc(f.bufend,2);
  673. break;
  674. end;
  675. #26 : if CheckEOF then
  676. begin
  677. f.bufptr^[f.bufend]:=#26;
  678. inc(f.bufend);
  679. break;
  680. end;
  681. else
  682. begin
  683. if f.bufpos<f.bufsize-2 then
  684. begin
  685. f.buffer[f.bufpos]:=ch;
  686. inc(f.bufpos);
  687. WriteChar(ch);
  688. end;
  689. end;
  690. end;
  691. until false;
  692. f.bufpos:=0;
  693. screensetcursor(row,col);
  694. CrtRead:=0;
  695. End;
  696. Function CrtReturn:Integer;
  697. Begin
  698. CrtReturn:=0;
  699. end;
  700. Function CrtClose(Var F: TextRec): Integer;
  701. Begin
  702. F.Mode:=fmClosed;
  703. CrtClose:=0;
  704. End;
  705. Function CrtOpen(Var F: TextRec): Integer;
  706. Begin
  707. If F.Mode=fmOutput Then
  708. begin
  709. TextRec(F).InOutFunc:=@CrtWrite;
  710. TextRec(F).FlushFunc:=@CrtWrite;
  711. end
  712. Else
  713. begin
  714. F.Mode:=fmInput;
  715. TextRec(F).InOutFunc:=@CrtRead;
  716. TextRec(F).FlushFunc:=@CrtReturn;
  717. end;
  718. TextRec(F).CloseFunc:=@CrtClose;
  719. CrtOpen:=0;
  720. End;
  721. procedure AssignCrt(var F: Text);
  722. begin
  723. Assign(F,'');
  724. TextRec(F).OpenFunc:=@CrtOpen;
  725. end;
  726. begin
  727. is_last:=false;
  728. { load system variables to temporary variables to save time }
  729. maxcols:=screencols;
  730. maxrows:=screenrows;
  731. { set output window }
  732. windmax:=(maxcols-1) or ((maxrows-1) shl 8);
  733. { save the current settings to restore the old state after the exit }
  734. screengetcursor(row,col);
  735. {$ifdef GO32V2}
  736. startattrib:=mem[$b800:get_addr(row,col)+1];
  737. lastmode:=mem[$40:$49];
  738. {$else}
  739. dosmemget($b800,get_addr(row,col)+1,startattrib,1);
  740. dosmemget($40,$49,lastmode,1);
  741. {$endif}
  742. textattr:=startattrib;
  743. { redirect the standard output }
  744. assigncrt(Output);
  745. Rewrite(Output);
  746. TextRec(Output).Handle:=StdOutputHandle;
  747. assigncrt(Input);
  748. Reset(Input);
  749. TextRec(Input).Handle:=StdInputHandle;
  750. { calculates delay calibration }
  751. initdelay;
  752. end.
  753. {
  754. $Log$
  755. Revision 1.4 1998-05-28 10:21:38 pierre
  756. * Handles of input and output restored
  757. Revision 1.3 1998/05/27 00:19:16 peter
  758. * fixed crt input
  759. Revision 1.2 1998/05/21 19:30:46 peter
  760. * objects compiles for linux
  761. + assign(pchar), assign(char), rename(pchar), rename(char)
  762. * fixed read_text_as_array
  763. + read_text_as_pchar which was not yet in the rtl
  764. }