crt.pas 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972
  1. {****************************************************************************
  2. $Id$
  3. Standard CRT unit.
  4. Free Pascal runtime library for EMX.
  5. Copyright (c) 1997 Daniel Mantione.
  6. This file may be reproduced and modified under the same conditions
  7. as all other Free Pascal source code.
  8. ****************************************************************************}
  9. unit crt;
  10. {$ASMMODE ATT}
  11. interface
  12. {$i crth.inc}
  13. {cemodeset means that the procedure textmode has failed to set up a mode.}
  14. type
  15. cexxxx=(cenoerror,cemodeset);
  16. var
  17. crt_error:cexxxx; {Crt-status. RW}
  18. {***************************************************************************}
  19. implementation
  20. {$i textrec.inc}
  21. const extkeycode:char=#0;
  22. var maxrows,maxcols:word;
  23. calibration:longint;
  24. type Tkbdkeyinfo=record
  25. charcode,scancode:char;
  26. fbstatus,bnlsshift:byte;
  27. fsstate:word;
  28. time:longint;
  29. end;
  30. {if you have information on the folowing datastructure, please
  31. send them to me at [email protected]}
  32. {This datastructure is needed when we ask in what video mode we are,
  33. or we want to set up a new mode.}
  34. viomodeinfo=record
  35. cb:word; { length of the entire data
  36. structure }
  37. fbtype, { bit mask of mode being set}
  38. color: byte; { number of colors (power of 2) }
  39. col, { number of text columns }
  40. row, { number of text rows }
  41. hres, { horizontal resolution }
  42. vres: word; { vertical resolution }
  43. fmt_ID, { attribute format
  44. ! more info wanted !}
  45. attrib: byte; { number of attributes }
  46. buf_addr, { physical address of
  47. videobuffer, e.g. $0b800}
  48. buf_length, { length of a videopage (bytes)}
  49. full_length, { total video-memory on video-
  50. card (bytes)}
  51. partial_length:longint; { ????? info wanted !}
  52. ext_data_addr:pointer; { ????? info wanted !}
  53. end;
  54. Pviomodeinfo=^viomodeinfo;
  55. TVioCursorInfo=record
  56. case boolean of
  57. false:(
  58. yStart:word; {Cursor start (top) scan line (0-based)}
  59. cEnd:word; {Cursor end (bottom) scan line}
  60. cx:word; {Cursor width (0=default width)}
  61. Attr:word); {Cursor colour attribute (-1=hidden)}
  62. true:(
  63. yStartInt: integer; {integer variants can be used to specify negative}
  64. cEndInt:integer; {negative values (interpreted as percentage by OS/2)}
  65. cxInt:integer;
  66. AttrInt:integer);
  67. end;
  68. PVioCursorInfo=^TVioCursorInfo;
  69. {EMXWRAP.DLL has strange calling conventions: All parameters must have
  70. a 4 byte size.}
  71. function kbdcharin(var Akeyrec:Tkbdkeyinfo;wait,kbdhandle:longint):word; cdecl;
  72. external 'EMXWRAP' index 204;
  73. function kbdpeek(var Akeyrec:TkbdkeyInfo;kbdhandle:word):word; cdecl;
  74. external 'EMXWRAP' index 222;
  75. function dossleep(time:cardinal):cardinal; cdecl;
  76. external 'DOSCALLS' index 229;
  77. function vioscrollup(top,left,bottom,right,lines:longint;
  78. var screl:word;viohandle:longint):word; cdecl;
  79. external 'EMXWRAP' index 107;
  80. function vioscrolldn(top,left,bottom,right,lines:longint;
  81. var screl:word;viohandle:longint):word; cdecl;
  82. external 'EMXWRAP' index 147;
  83. function viogetcurpos(var row,column:word;viohandle:longint):word; cdecl;
  84. external 'EMXWRAP' index 109;
  85. function viosetcurpos(row,column,viohandle:longint):word; cdecl;
  86. external 'EMXWRAP' index 115;
  87. function viowrtTTY(s:Pchar;len,viohandle:longint):word; cdecl;
  88. external 'EMXWRAP' index 119;
  89. function viowrtcharstratt(s:Pchar;len,row,col:longint;var attr:byte;
  90. viohandle:longint):word; cdecl;
  91. external 'EMXWRAP' index 148;
  92. function viogetmode(var Amodeinfo:viomodeinfo;viohandle:longint):word; cdecl;
  93. external 'EMXWRAP' index 121;
  94. function viosetmode(var Amodeinfo:viomodeinfo;viohandle:longint):word; cdecl;
  95. external 'EMXWRAP' index 122;
  96. function VioSetCurType(var CurData:TVioCursorInfo;VioHandle:word):word; cdecl;
  97. external 'EMXWRAP' index 132;
  98. {external 'VIOCALLS' index 32;}
  99. function VioGetCurType(var CurData:TVioCursorInfo;VioHandle:word):word; cdecl;
  100. external 'EMXWRAP' index 127;
  101. {external 'VIOCALLS' index 27;}
  102. procedure syscall;external name '___SYSCALL';
  103. procedure setscreenmode(mode:word);
  104. { This procedure sets a new videomode. Note that the constants passes to
  105. this procedure are different than in the dos mode.}
  106. const modecols:array[0..2] of word=(40,80,132);
  107. moderows:array[0..3] of word=(25,28,43,50);
  108. var newmode:viomodeinfo;
  109. begin
  110. if os_mode=osOS2 then
  111. begin
  112. newmode.cb:=8;
  113. newmode.fbtype:=1; {Non graphics colour mode.}
  114. newmode.color:=4; {We want 16 colours, 2^4=16.}
  115. newmode.col:=modecols[mode and 15];
  116. newmode.row:=moderows[mode shr 4];
  117. if viosetmode(newmode,0)=0 then
  118. crt_error:=cenoerror
  119. else
  120. crt_error:=cemodeset;
  121. maxcols:=newmode.col;
  122. maxrows:=newmode.row;
  123. end
  124. else
  125. begin
  126. maxcols:=modecols[mode and 15];
  127. maxrows:=moderows[mode shr 4];
  128. crt_error:=cenoerror;
  129. {Set correct vertical resolution.}
  130. asm
  131. movw $0x1202,%ax
  132. movw 8(%ebp),%bx
  133. shrw $4,%bx
  134. cmpb $2,%bl
  135. jne .L_crtsetmode_a1
  136. decw %ax
  137. .L_crtsetmode_a1:
  138. mov $0x30,%bl
  139. int $0x10
  140. end;
  141. {132 column mode in DOS is videocard dependend.}
  142. if mode and 15=2 then
  143. begin
  144. crt_error:=cemodeset;
  145. exit;
  146. end;
  147. {Switch to correct mode.}
  148. asm
  149. mov 8(%ebp),%bx
  150. and $15,%bl
  151. mov $1,%ax
  152. cmp $1,%bl
  153. jne .L_crtsetmode_b1
  154. mov $3,%al
  155. .L_crtsetmode_b1:
  156. int $0x10
  157. {Use alternate print-screen function.}
  158. mov $0x12,%ah
  159. mov $0x20,%bl
  160. int $0x10
  161. end;
  162. {Set correct font.}
  163. case mode shr 4 of
  164. 1:
  165. {Set 8x14 font.}
  166. asm
  167. mov $0x1111,%ax
  168. mov $0,%bl
  169. int $0x10
  170. end;
  171. 2,3:
  172. {Set 8x8 font.}
  173. asm
  174. mov $0x1112,%ax
  175. mov $0,%bl
  176. int $0x10
  177. end;
  178. end;
  179. end;
  180. end;
  181. procedure getcursor(var y,x:word);
  182. {Get the cursor position.}
  183. begin
  184. if os_mode=osOS2 then
  185. viogetcurpos(y,x,0)
  186. else
  187. asm
  188. movb $3,%ah
  189. movb $0,%bh
  190. int $0x10
  191. movl y,%eax
  192. movl x,%ebx
  193. movzbl %dh,%edi
  194. andw $255,%dx
  195. movw %di,(%eax)
  196. movw %dx,(%ebx)
  197. end;
  198. end;
  199. {$ASMMODE INTEL}
  200. procedure setcursor(y,x:word);
  201. {Set the cursor position.}
  202. begin
  203. if os_mode=osOS2 then
  204. viosetcurpos(y,x,0)
  205. else
  206. asm
  207. mov ah, 2
  208. mov bh, 0
  209. mov dh, byte ptr y
  210. mov dl, byte ptr x
  211. int 10h
  212. end;
  213. end;
  214. procedure scroll_up(top,left,bottom,right,lines:word;var screl:word);
  215. begin
  216. if os_mode=osOS2 then
  217. vioscrollup(top,left,bottom,right,lines,screl,0)
  218. else
  219. asm
  220. mov ah, 6
  221. mov al, byte ptr lines
  222. mov edi, screl
  223. mov bh, [edi + 1]
  224. mov ch, byte ptr top
  225. mov cl, byte ptr left
  226. mov dh, byte ptr bottom
  227. mov dl, byte ptr right
  228. int 10h
  229. end;
  230. end;
  231. procedure scroll_dn(top,left,bottom,right,lines:word;var screl:word);
  232. begin
  233. if os_mode=osOS2 then
  234. vioscrolldn(top,left,bottom,right,lines,screl,0)
  235. else
  236. asm
  237. mov ah, 7
  238. mov al, byte ptr lines
  239. mov edi, screl
  240. mov bh, [edi + 1]
  241. mov ch, byte ptr top
  242. mov cl, byte ptr left
  243. mov dh, byte ptr bottom
  244. mov dl, byte ptr right
  245. int 10h
  246. end;
  247. end;
  248. {$ASMMODE ATT}
  249. function keypressed:boolean;
  250. {Checks if a key is pressed.}
  251. var Akeyrec:Tkbdkeyinfo;
  252. begin
  253. if os_mode=osOS2 then
  254. begin
  255. kbdpeek(Akeyrec,0);
  256. keypressed:=(extkeycode<>#0) or ((Akeyrec.fbstatus and $40)<>0);
  257. end
  258. else
  259. begin
  260. if extkeycode<>#0 then
  261. begin
  262. keypressed:=true;
  263. exit
  264. end
  265. else
  266. asm
  267. movb $1,%ah
  268. int $0x16
  269. setnz %al
  270. movb %al,__RESULT
  271. end;
  272. end;
  273. end;
  274. function readkey:char;
  275. {Reads the next character from the keyboard.}
  276. var Akeyrec:Tkbdkeyinfo;
  277. c,s:char;
  278. begin
  279. if extkeycode<>#0 then
  280. begin
  281. readkey:=extkeycode;
  282. extkeycode:=#0
  283. end
  284. else
  285. begin
  286. if os_mode=osOS2 then
  287. begin
  288. kbdcharin(Akeyrec,0,0);
  289. c:=Akeyrec.charcode;
  290. s:=Akeyrec.scancode;
  291. if (c=#224) and (s<>#0) then
  292. c:=#0;
  293. end
  294. else
  295. begin
  296. asm
  297. movb $0,%ah
  298. int $0x16
  299. movb %al,c
  300. movb %ah,s
  301. end;
  302. end;
  303. if c=#0 then
  304. extkeycode:=s;
  305. readkey:=c;
  306. end;
  307. end;
  308. procedure clrscr;
  309. {Clears the current window.}
  310. var screl:word;
  311. begin
  312. screl:=$20+textattr shl 8;
  313. scroll_up(hi(windmin),lo(windmin),
  314. hi(windmax),lo(windmax),
  315. hi(windmax)-hi(windmin)+1,
  316. screl);
  317. gotoXY(1,1);
  318. end;
  319. procedure gotoXY(x,y:byte);
  320. {Positions the cursor on (x,y) relative to the window origin.}
  321. begin
  322. if x<1 then
  323. x:=1;
  324. if y<1 then
  325. y:=1;
  326. if y+hi(windmin)-2>=hi(windmax) then
  327. y:=hi(windmax)-hi(windmin)+1;
  328. if x+lo(windmin)-2>=lo(windmax) then
  329. x:=lo(windmax)-lo(windmin)+1;
  330. setcursor(y+hi(windmin)-1,x+lo(windmin)-1);
  331. end;
  332. function whereX:byte;
  333. {Returns the x position of the cursor.}
  334. var x,y:word;
  335. begin
  336. getcursor(y,x);
  337. whereX:=x-lo(windmin)+1;
  338. end;
  339. function whereY:byte;
  340. {Returns the y position of the cursor.}
  341. var x,y:word;
  342. begin
  343. getcursor(y,x);
  344. whereY:=y-hi(windmin)+1;
  345. end;
  346. procedure clreol;
  347. {Clear from current position to end of line.
  348. Contributed by Michail A. Baikov}
  349. var i:byte;
  350. begin
  351. {not fastest, but compatible}
  352. for i:=wherex to lo(windmax) do write(' ');
  353. gotoxy(1,wherey); {may be not}
  354. end;
  355. procedure delline;
  356. {Deletes the line at the cursor.}
  357. var row,left,right,bot:longint;
  358. fil:word;
  359. begin
  360. row:=whereY;
  361. left:=lo(windmin);
  362. right:=lo(windmax);
  363. bot:=hi(windmax)+1;
  364. fil:=$20 or (textattr shl 8);
  365. scroll_up(row+1,left,bot,right,1,fil);
  366. end;
  367. procedure insline;
  368. {Inserts a line at the cursor position.}
  369. var row,left,right,bot:longint;
  370. fil:word;
  371. begin
  372. row:=whereY;
  373. left:=lo(windmin);
  374. right:=lo(windmax);
  375. bot:=hi(windmax);
  376. fil:=$20 or (textattr shl 8);
  377. scroll_dn(row,left,bot,right,1,fil);
  378. end;
  379. procedure TextMode (Mode: word);
  380. { Use this procedure to set-up a specific text-mode.}
  381. begin
  382. textattr:=$07;
  383. lastmode:=mode;
  384. mode:=mode and $ff;
  385. setscreenmode(mode);
  386. windmin:=0;
  387. windmax:=(maxcols-1) or ((maxrows-1) shl 8);
  388. clrscr;
  389. end;
  390. procedure textcolor(color:byte);
  391. {All text written after calling this will have color as foreground colour.}
  392. begin
  393. textattr:=(textattr and $70) or (color and $f)+color and 128;
  394. end;
  395. procedure textbackground(color:byte);
  396. {All text written after calling this will have colour as background colour.}
  397. begin
  398. textattr:=(textattr and $8f) or ((color and $7) shl 4);
  399. end;
  400. procedure normvideo;
  401. {Changes the text-background to black and the foreground to white.}
  402. begin
  403. textattr:=$7;
  404. end;
  405. procedure lowvideo;
  406. {All text written after this will have low intensity.}
  407. begin
  408. textattr:=textattr and $f7;
  409. end;
  410. procedure highvideo;
  411. {All text written after this will have high intensity.}
  412. begin
  413. textattr:=textattr or $8;
  414. end;
  415. procedure delay(ms:word);
  416. var i,j:longint;
  417. {Waits ms microseconds. The DOS code is copied from the DOS rtl.}
  418. begin
  419. {Under OS/2 we could also calibrate like under DOS. But this is
  420. unreliable, because OS/2 can hold our programs while calibrating,
  421. if it needs the processor for other things.}
  422. if os_mode=osOS2 then
  423. dossleep(ms)
  424. else
  425. begin
  426. for i:=1 to ms do
  427. for j:=1 to calibration do
  428. begin
  429. end;
  430. end;
  431. end;
  432. procedure window(X1,Y1,X2,Y2:byte);
  433. {Change the write window to the given coordinates.}
  434. begin
  435. if (X1<1) or
  436. (Y1<1) or
  437. (X2>maxcols) or
  438. (Y2>maxrows) or
  439. (X1>X2) or
  440. (Y1>Y2) then
  441. exit;
  442. windmin:=(X1-1) or ((Y1-1) shl 8);
  443. windmax:=(X2-1) or ((Y2-1) shl 8);
  444. gotoXY(1,1);
  445. end;
  446. {$ASMMODE INTEL}
  447. procedure writePchar(s:Pchar;len:word);
  448. {Write a series of characters to the screen.
  449. Not very fast, but is just text-mode isn't it?}
  450. var x,y:word;
  451. c:char;
  452. i,n:integer;
  453. screl:word;
  454. ca:Pchar;
  455. begin
  456. i:=0;
  457. getcursor(y,x);
  458. while i<=len-1 do
  459. begin
  460. case s[i] of
  461. #7: asm
  462. mov dl, 7
  463. mov ah, 2
  464. call syscall
  465. end;
  466. #8: if X > Succ (Lo (WindMin)) then Dec (X);
  467. { #9: x:=(x-lo(windmin)) and $fff8+8+lo(windmin);}
  468. #10: inc(y);
  469. #13: x:=lo(windmin);
  470. else
  471. begin
  472. ca:=@s[i];
  473. n:=1;
  474. while not(s[i+1] in [#7,#8,#10,#13]) and
  475. { (x+n<=lo(windmax)+1) and (i<len-1) do}
  476. (x+n<=lo(windmax)) and (i<len-1) do
  477. begin
  478. inc(n);
  479. inc(i);
  480. end;
  481. if os_mode=osOS2 then
  482. viowrtcharstratt(ca,n,y,x,textattr,0)
  483. else
  484. asm
  485. mov ax, 1300h
  486. mov bh, 0
  487. mov bl, TEXTATTR
  488. mov dh, byte ptr y
  489. mov dl, byte ptr x
  490. mov cx, n
  491. push ebp
  492. mov ebp, ca
  493. int 10h
  494. pop ebp
  495. end;
  496. x:=x+n;
  497. end;
  498. end;
  499. if x>lo(windmax) then
  500. begin
  501. x:=lo(windmin);
  502. inc(y);
  503. end;
  504. if y>hi(windmax) then
  505. begin
  506. screl:=$20+textattr shl 8;
  507. scroll_up(hi(windmin),lo(windmin),
  508. hi(windmax),lo(windmax),
  509. 1,screl);
  510. y:=hi(windmax);
  511. end;
  512. { writeln(stderr,x,' ',y);}
  513. inc(i);
  514. end;
  515. setcursor(y,x);
  516. end;
  517. {$ASMMODE ATT}
  518. function crtread(var f:textrec):word;
  519. {Read a series of characters from the console.}
  520. var max,curpos:integer;
  521. c:char;
  522. clist:array[0..2] of char;
  523. begin
  524. max:=f.bufsize-2;
  525. curpos:=0;
  526. repeat
  527. c:=readkey;
  528. case c of
  529. #0:
  530. readkey;
  531. #8:
  532. if curpos>0 then
  533. begin
  534. clist:=#8' '#8;
  535. writePchar(@clist,3);
  536. dec(curpos);
  537. end;
  538. #13:
  539. begin
  540. f.bufptr^[curpos]:=#13;
  541. inc(curpos);
  542. f.bufptr^[curpos]:=#10;
  543. inc(curpos);
  544. f.bufpos:=0;
  545. f.bufend:=curpos;
  546. clist[0]:=#13;
  547. writePchar(@clist,1);
  548. break;
  549. end;
  550. #32..#255:
  551. if curpos<max then
  552. begin
  553. f.bufptr^[curpos]:=c;
  554. inc(curpos);
  555. writePchar(@c,1);
  556. end;
  557. end;
  558. until false;
  559. crtread:=0;
  560. end;
  561. function crtwrite(var f:textrec):word;
  562. {Write a series of characters to the console.}
  563. begin
  564. writePchar(Pchar(f.bufptr),f.bufpos);
  565. f.bufpos:=0;
  566. crtwrite:=0;
  567. end;
  568. function crtopen(var f:textrec):integer;
  569. begin
  570. if f.mode=fmoutput then
  571. crtopen:=0
  572. else
  573. crtopen:=5;
  574. end;
  575. function crtinout(var f:textrec):integer;
  576. begin
  577. case f.mode of
  578. fminput:
  579. crtinout:=crtread(f);
  580. fmoutput:
  581. crtinout:=crtwrite(f);
  582. end;
  583. end;
  584. function crtclose(var f:textrec):integer;
  585. begin
  586. f.mode:=fmclosed;
  587. crtclose:=0;
  588. end;
  589. procedure assigncrt(var f:text);
  590. {Assigns a file to the crt console.}
  591. begin
  592. textrec(f).mode:=fmclosed;
  593. textrec(f).bufsize:=128;
  594. textrec(f).bufptr:=@textrec(f).buffer;
  595. textrec(f).bufpos:=0;
  596. textrec(f).openfunc:=@crtopen;
  597. textrec(f).inoutfunc:=@crtinout;
  598. textrec(f).flushfunc:=@crtinout;
  599. textrec(f).closefunc:=@crtclose;
  600. textrec(f).name[0]:='.';
  601. textrec(f).name[0]:=#0;
  602. end;
  603. procedure sound(hz:word);
  604. {sound and nosound are not implemented because the OS/2 API supports a freq/
  605. duration procedure instead of start/stop procedures.}
  606. begin
  607. end;
  608. procedure nosound;
  609. begin
  610. end;
  611. function get_ticks:word;
  612. type Pword=^word;
  613. begin
  614. get_ticks:=Pword(longint(first_meg)+$46c)^;
  615. end;
  616. procedure initdelay;
  617. {Calibrate the delay procedure. Copied from DOS rtl.}
  618. var first:word;
  619. begin
  620. calibration:=0;
  621. { wait for new tick }
  622. first:=get_ticks;
  623. while get_ticks=first do
  624. begin
  625. end;
  626. first:=get_ticks;
  627. { this estimates calibration }
  628. while get_ticks=first do
  629. inc(calibration);
  630. { calculate this to ms }
  631. calibration:=calibration div 70;
  632. while true do
  633. begin
  634. first:=get_ticks;
  635. while get_ticks=first do
  636. begin
  637. end;
  638. first:=get_ticks;
  639. delay(55);
  640. if first=get_ticks then
  641. exit
  642. else
  643. begin
  644. { decrement calibration two percent }
  645. calibration:=calibration-calibration div 50;
  646. dec(calibration);
  647. end;
  648. end;
  649. end;
  650. {****************************************************************************
  651. Extra Crt Functions
  652. ****************************************************************************}
  653. {$ASMMODE INTEL}
  654. procedure CursorOn;
  655. var
  656. I: TVioCursorInfo;
  657. begin
  658. if Os_Mode = osOS2 then
  659. begin
  660. VioGetCurType (I, 0);
  661. with I do
  662. begin
  663. yStartInt := -90;
  664. cEndInt := -100;
  665. Attr := 15;
  666. end;
  667. VioSetCurType (I, 0);
  668. end
  669. else
  670. asm
  671. push es
  672. push bp
  673. mov ax, 1130h
  674. mov bh, 0
  675. mov ecx, 0
  676. int 10h
  677. pop bp
  678. pop es
  679. or ecx, ecx
  680. jnz @COnOld
  681. mov cx, 0707h
  682. jmp @COnAll
  683. @COnOld:
  684. dec cx
  685. mov ch, cl
  686. dec ch
  687. @COnAll:
  688. mov ah, 1
  689. int 10h
  690. end;
  691. end;
  692. procedure CursorOff;
  693. var
  694. I: TVioCursorInfo;
  695. begin
  696. if Os_Mode = osOS2 then
  697. begin
  698. VioGetCurType (I, 0);
  699. I.AttrInt := -1;
  700. VioSetCurType (I, 0);
  701. end
  702. else
  703. asm
  704. mov ah, 1
  705. mov cx, 0FFFFh
  706. int 10h
  707. end;
  708. end;
  709. procedure CursorBig;
  710. var
  711. I: TVioCursorInfo;
  712. begin
  713. if Os_Mode = osOS2 then
  714. begin
  715. VioGetCurType (I, 0);
  716. with I do
  717. begin
  718. yStart := 0;
  719. cEndInt := -100;
  720. Attr := 15;
  721. end;
  722. VioSetCurType (I, 0);
  723. end
  724. else
  725. asm
  726. mov ah, 1
  727. mov cx, 1Fh
  728. int 10h
  729. end;
  730. end;
  731. {$ASMMODE DEFAULT}
  732. {Initialization.}
  733. type Pbyte=^byte;
  734. var curmode:viomodeinfo;
  735. mode:byte;
  736. begin
  737. textattr:=lightgray;
  738. if os_mode=osOS2 then
  739. begin
  740. curmode.cb:=sizeof(curmode);
  741. viogetmode(curmode,0);
  742. maxcols:=curmode.col;
  743. maxrows:=curmode.row;
  744. lastmode:=0;
  745. case maxcols of
  746. 40:
  747. lastmode:=0;
  748. 80:
  749. lastmode:=1;
  750. 132:
  751. lastmode:=2;
  752. end;
  753. case maxrows of
  754. 25:;
  755. 28:
  756. lastmode:=lastmode+16;
  757. 43:
  758. lastmode:=lastmode+32;
  759. 50:
  760. lastmode:=lastmode+48;
  761. end
  762. end
  763. else
  764. begin
  765. {Request video mode to determine columns.}
  766. asm
  767. mov $0x0f,%ah
  768. int $0x10
  769. { mov %al,_MODE }
  770. mov %al,MODE
  771. end;
  772. case mode of
  773. 0,1:
  774. begin
  775. lastmode:=0;
  776. maxcols:=40;
  777. end;
  778. else
  779. begin
  780. lastmode:=1;
  781. maxcols:=80;
  782. end;
  783. end;
  784. {Get number of rows from realmode $0040:$0084.}
  785. maxrows:=Pbyte(longint(first_meg)+$484)^;
  786. case maxrows of
  787. 25:;
  788. 28:
  789. lastmode:=lastmode+16;
  790. 43:
  791. lastmode:=lastmode+32;
  792. 50:
  793. lastmode:=lastmode+48;
  794. end
  795. end;
  796. windmin:=0;
  797. windmax:=((maxrows-1) shl 8) or (maxcols-1);
  798. if os_mode <> osOS2 then
  799. initdelay;
  800. crt_error:=cenoerror;
  801. assigncrt(input);
  802. textrec(input).mode:=fminput;
  803. assigncrt(output);
  804. textrec(output).mode:=fmoutput;
  805. end.
  806. {
  807. $Log$
  808. Revision 1.7 2005-05-14 15:01:49 hajny
  809. * TextMode parameter type changed to word for TP/BP compatibility
  810. Revision 1.6 2005/03/30 23:11:35 hajny
  811. * OS/2 fixes merged to EMX
  812. Revision 1.5 2005/02/14 17:13:22 peter
  813. * truncate log
  814. }