video.inc 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. {
  2. System independent low-level video interface for go32v2
  3. $Id$
  4. }
  5. {$ASMMODE ATT}
  6. uses
  7. go32;
  8. var
  9. VideoSeg : word;
  10. OldVideoBuf : PVideoBuf;
  11. { used to know if LastCursorType is valid }
  12. const
  13. InitVideoCalled : boolean = false;
  14. LastCursorType : word = crUnderline;
  15. { allways set blink state again }
  16. procedure SetHighBitBlink;
  17. var
  18. regs : trealregs;
  19. begin
  20. regs.ax:=$1003;
  21. regs.bx:=$0001;
  22. realintr($10,regs);
  23. end;
  24. procedure InitVideo;
  25. var
  26. regs : trealregs;
  27. begin
  28. VideoSeg:=$b800;
  29. if (ScreenWidth=$ffff) or (ScreenHeight=$ffff) or
  30. (ScreenWidth=0) or (ScreenHeight=0) then
  31. begin
  32. ScreenColor:=true;
  33. regs.ah:=$0f;
  34. realintr($10,regs);
  35. if (regs.al and 1)=0 then
  36. ScreenColor:=false;
  37. if regs.al=7 then
  38. begin
  39. ScreenColor:=false;
  40. VideoSeg:=$b000;
  41. end
  42. else
  43. VideoSeg:=$b800;
  44. ScreenWidth:=regs.ah;
  45. regs.ax:=$1130;
  46. regs.bx:=0;
  47. realintr($10,regs);
  48. ScreenHeight:=regs.dl+1;
  49. end;
  50. regs.ah:=$03;
  51. regs.bh:=0;
  52. realintr($10,regs);
  53. CursorLines:=regs.cl;
  54. CursorX:=regs.dl;
  55. CursorY:=regs.dh;
  56. If InitVideoCalled then
  57. Begin
  58. FreeMem(VideoBuf,VideoBufSize);
  59. FreeMem(OldVideoBuf,VideoBufSize);
  60. End;
  61. { allocate pmode memory buffer }
  62. VideoBufSize:=ScreenWidth*ScreenHeight*2;
  63. GetMem(VideoBuf,VideoBufSize);
  64. GetMem(OldVideoBuf,VideoBufSize);
  65. InitVideoCalled:=true;
  66. SetHighBitBlink;
  67. SetCursorType(LastCursorType);
  68. { ClearScreen; removed here
  69. to be able to catch the content of the monitor }
  70. end;
  71. procedure DoneVideo;
  72. begin
  73. If InitVideoCalled then
  74. Begin
  75. LastCursorType:=GetCursorType;
  76. ClearScreen;
  77. SetCursorType(crUnderLine);
  78. SetCursorPos(0,0);
  79. FreeMem(VideoBuf,VideoBufSize);
  80. VideoBuf:=nil;
  81. FreeMem(OldVideoBuf,VideoBufSize);
  82. OldVideoBuf:=nil;
  83. InitVideoCalled:=false;
  84. VideoBufSize:=0;
  85. End;
  86. end;
  87. function GetCapabilities: Word;
  88. begin
  89. GetCapabilities := $3F;
  90. end;
  91. procedure SetCursorPos(NewCursorX, NewCursorY: Word);
  92. var
  93. regs : trealregs;
  94. begin
  95. regs.ah:=$02;
  96. regs.bh:=0;
  97. regs.dh:=NewCursorY;
  98. regs.dl:=NewCursorX;
  99. realintr($10,regs);
  100. CursorY:=regs.dh;
  101. CursorX:=regs.dl;
  102. end;
  103. { I don't know the maximum value for the scan line
  104. probably 7 or 15 depending on resolution !!
  105. }
  106. function GetCursorType: Word;
  107. var
  108. regs : trealregs;
  109. begin
  110. regs.ah:=$03;
  111. regs.bh:=0;
  112. realintr($10,regs);
  113. GetCursorType:=crHidden;
  114. if (regs.ch and $60)=0 then
  115. begin
  116. GetCursorType:=crBlock;
  117. if (regs.ch and $1f)<>0 then
  118. begin
  119. GetCursorType:=crHalfBlock;
  120. if regs.cl+1=(regs.ch and $1F) then
  121. GetCursorType:=crUnderline;
  122. end;
  123. end;
  124. end;
  125. procedure SetCursorType(NewType: Word);
  126. var
  127. regs : trealregs;
  128. const
  129. MaxCursorLines = 7;
  130. begin
  131. regs.ah:=$01;
  132. regs.bx:=NewType;
  133. case NewType of
  134. crHidden : regs.cx:=$2000;
  135. crHalfBlock : begin
  136. regs.ch:=MaxCursorLines shr 1;
  137. regs.cl:=MaxCursorLines;
  138. end;
  139. crBlock : begin
  140. regs.ch:=0;
  141. regs.cl:=MaxCursorLines;
  142. end;
  143. else begin
  144. regs.ch:=MaxCursorLines-1;
  145. regs.cl:=MaxCursorLines;
  146. end;
  147. end;
  148. realintr($10,regs);
  149. end;
  150. function DefaultVideoModeSelector(const VideoMode: TVideoMode; Params: Longint): Boolean;
  151. type
  152. wordrec=packed record
  153. lo,hi : word;
  154. end;
  155. var
  156. regs : trealregs;
  157. begin
  158. regs.ax:=wordrec(Params).lo;
  159. regs.bx:=wordrec(Params).hi;
  160. realintr($10,regs);
  161. defaultvideomodeselector:=true;
  162. end;
  163. function VideoModeSelector8x8(const VideoMode: TVideoMode; Params: Longint): Boolean;
  164. type
  165. wordrec=packed record
  166. lo,hi : word;
  167. end;
  168. var
  169. regs : trealregs;
  170. begin
  171. regs.ax:=3;
  172. regs.bx:=0;
  173. realintr($10,regs);
  174. regs.ax:=$1112;
  175. regs.bx:=$0;
  176. realintr($10,regs);
  177. videomodeselector8x8:=true;
  178. ScreenColor:=true;
  179. ScreenWidth:=80;
  180. ScreenHeight:=50;
  181. end;
  182. procedure ClearScreen;
  183. begin
  184. FillWord(VideoBuf^,VideoBufSize shr 1,$0720);
  185. UpdateScreen(true);
  186. end;
  187. procedure UpdateScreen(Force: Boolean);
  188. begin
  189. if LockUpdateScreen<>0 then
  190. exit;
  191. if not force then
  192. begin
  193. asm
  194. movl VideoBuf,%esi
  195. movl OldVideoBuf,%edi
  196. movl VideoBufSize,%ecx
  197. shrl $2,%ecx
  198. repe
  199. cmpsl
  200. orl %ecx,%ecx
  201. jz .Lno_update
  202. movb $1,force
  203. .Lno_update:
  204. end;
  205. end;
  206. if Force then
  207. begin
  208. { dosmemput(videoseg,0,videobuf^,VideoBufSize);}
  209. asm
  210. pushw %es
  211. pushl %edi
  212. pushl %esi
  213. xor %edi, %edi
  214. movw videoseg, %di
  215. shll $0x4, %edi
  216. movl videobuf, %esi
  217. movl videobufsize, %ecx
  218. movw %fs, %ax
  219. movw %ax, %es
  220. rep movsb
  221. popl %esi
  222. popl %edi
  223. popw %es
  224. end ['EAX','ECX'];
  225. move(videobuf^,oldvideobuf^,VideoBufSize);
  226. end;
  227. end;
  228. procedure RegisterVideoModes;
  229. begin
  230. RegisterVideoMode(40, 25, False,@DefaultVideoModeSelector, $00000000);
  231. RegisterVideoMode(40, 25, True, @DefaultVideoModeSelector, $00000001);
  232. RegisterVideoMode(80, 25, False,@DefaultVideoModeSelector, $00000002);
  233. RegisterVideoMode(80, 25, True, @DefaultVideoModeSelector, $00000003);
  234. RegisterVideoMode(80, 50, True, @VideoModeSelector8x8, 0);
  235. end;
  236. {
  237. $Log$
  238. Revision 1.1 2000-01-06 01:20:30 peter
  239. * moved out of packages/ back to topdir
  240. Revision 1.1 1999/11/24 23:36:38 peter
  241. * moved to packages dir
  242. Revision 1.14 1999/10/03 19:53:26 peter
  243. * changed screenheight detection
  244. Revision 1.13 1999/08/16 18:26:20 peter
  245. * asm updatescreen for speed reasons
  246. Revision 1.12 1999/06/02 11:22:10 pierre
  247. * @ needed for proc address
  248. Revision 1.11 1999/04/01 12:51:51 pierre
  249. * removed clearscreen in initvideo for capture
  250. Revision 1.10 1999/03/21 22:49:40 florian
  251. * correct screeneight in 80x50 mode
  252. Revision 1.9 1999/03/14 22:15:49 florian
  253. * my last changes doesn't work correctly, fixed more
  254. the screen height calculation works incorrect in 80x50 mode
  255. Revision 1.8 1999/03/14 17:43:03 florian
  256. + 80x50 mode support added
  257. * some bugs in VESA mode support removed
  258. Revision 1.7 1999/02/19 16:42:48 peter
  259. * fixed typo
  260. Revision 1.6 1999/02/19 12:29:52 pierre
  261. * several bugs related to Cursor fixed !
  262. I still don't know the maximum value for
  263. the scan line (depends on resolution used !)
  264. Revision 1.5 1999/02/08 17:53:17 pierre
  265. + added restoring of BlinkState in InitVideo, old mode not stored
  266. Revision 1.4 1998/12/15 17:17:17 peter
  267. + cursor at 1,1 at the end
  268. Revision 1.3 1998/12/12 19:13:01 peter
  269. * keyboard updates
  270. * make test target, make all only makes units
  271. Revision 1.2 1998/12/10 11:41:50 florian
  272. * cursor is properly restored in DoneVideo
  273. Revision 1.1 1998/12/04 12:48:27 peter
  274. * moved some dirs
  275. Revision 1.4 1998/11/01 20:29:11 peter
  276. + lockupdatescreen counter to not let updatescreen() update
  277. Revision 1.3 1998/10/28 21:18:26 peter
  278. * more fixes
  279. Revision 1.2 1998/10/28 00:02:08 peter
  280. + mouse
  281. + video.clearscreen, video.videobufsize
  282. Revision 1.1 1998/10/26 11:31:47 peter
  283. + inital include files
  284. }