vesa.pas 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724
  1. {
  2. $Id$
  3. This file is part of the PinGUI - Platform Independent GUI Project
  4. Copyright (c) 1999 by Berczi Gabor
  5. VESA support routines
  6. See the file COPYING.GUI, 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 VESA;
  13. {$ifdef DEBUG}
  14. {$define TESTGRAPHIC}
  15. {$endif DEBUG}
  16. interface
  17. uses
  18. Dos,
  19. Objects,Strings,WUtils;
  20. const
  21. { Video Mode Attributes mask constants }
  22. vesa_vma_CanBeSetInCurrentConfig = $0001;
  23. vesa_vma_OptionalBlockPresent = $0002;
  24. vesa_vma_BIOSSupport = $0004;
  25. vesa_vma_ColorMode = $0008; { else mono }
  26. vesa_vma_GraphicsMode = $0010; { else text }
  27. { -- VBE 2.0 --- }
  28. vesa_vma_VGACompatibleMode = $0020;
  29. vesa_vma_VGACompWindowedAvail = $0040;
  30. vesa_vma_LinearFrameBufferAvail = $0080;
  31. { Windows Attributes mask constants }
  32. vesa_wa_Present = $0001;
  33. vesa_wa_Readable = $0002;
  34. vesa_wa_Writeable = $0004;
  35. { Memory Model value constants }
  36. vesa_mm_Text = $0000;
  37. vesa_mm_CGAGraphics = $0001;
  38. vesa_mm_HerculesGraphics = $0002;
  39. vesa_mm_4planePlanar = $0003;
  40. vesa_mm_PackedPixel = $0004;
  41. vesa_mm_NonChain4_256color = $0005;
  42. vesa_mm_DirectColor = $0006;
  43. vesa_mm_YUV = $0007;
  44. { Memory Window value constants }
  45. vesa_mw_WindowA = $0000;
  46. vesa_mw_WindowB = $0001;
  47. type
  48. {$ifdef FPC}tregisters=registers;{$endif}
  49. {$ifdef TP}tregisters=registers;{$endif}
  50. PtrRec16 = record
  51. Ofs,Seg: word;
  52. end;
  53. TVESAInfoBlock = record
  54. Signature : longint; { 'VESA' }
  55. Version : word;
  56. OEMString : PString;
  57. Capabilities : longint;
  58. VideoModeList: PWordArray;
  59. TotalMemory : word; { in 64KB blocks }
  60. Fill : array[1..236] of byte;
  61. VBE2Fill : array[1..256] of byte;
  62. end;
  63. TVESAModeInfoBlock = record
  64. Attributes : word;
  65. WinAAttrs : byte;
  66. WinBAttrs : byte;
  67. Granularity : word;
  68. Size : word;
  69. ASegment : word;
  70. BSegment : word;
  71. FuncPtr : pointer;
  72. BytesPerLine : word;
  73. { optional }
  74. XResolution : word;
  75. YResolution : word;
  76. XCharSize : byte;
  77. YCharSize : byte;
  78. NumberOfPlanes : byte;
  79. BitsPerPixel : byte;
  80. NumberOfBanks : byte;
  81. MemoryModel : byte;
  82. BankSize : byte;
  83. NumberOfImagePages: byte;
  84. Reserved : byte;
  85. { direct color fields }
  86. RedMaskSize : byte;
  87. RedFieldPosition: byte;
  88. GreenMaskSize : byte;
  89. GreenFieldPosition: byte;
  90. BlueMaskSize : byte;
  91. BlueFieldPosition: byte;
  92. ReservedMaskSize: byte;
  93. ReservedPosition: byte;
  94. DirectColorModeInfo: byte;
  95. { --- VBE 2.0 optional --- }
  96. LinearFrameAddr : longint;
  97. OffScreenAddr : longint;
  98. OffScreenSize : word;
  99. Reserved2 : array[1..216-(4+4+2)] of byte;
  100. end;
  101. TVESAModeList = record
  102. Count : word;
  103. Modes : array[1..256] of word;
  104. end;
  105. function VESAInit: boolean;
  106. function VESAGetInfo(var B: TVESAInfoBlock): boolean;
  107. function VESAGetModeInfo(Mode: word; var B: TVESAModeInfoBlock): boolean;
  108. function VESAGetModeList(var B: TVESAModeList): boolean;
  109. function VESASearchMode(XRes,YRes,BPX: word; LFB: boolean; var Mode: word; var ModeInfo: TVESAModeInfoBlock): boolean;
  110. function VESAGetOemString: string;
  111. function VESASetMode(Mode: word): boolean;
  112. function VESAGetMode(var Mode: word): boolean;
  113. function VESASelectMemoryWindow(Window: byte; Position: word): boolean;
  114. function VESAReturnMemoryWindow(Window: byte; var Position: word): boolean;
  115. function RegisterVesaVideoMode(Mode : word) : boolean;
  116. Procedure FreeVesaModes;
  117. implementation
  118. uses
  119. {$ifdef FPC}
  120. video, mouse,
  121. {$endif FPC}
  122. {$ifdef TESTGRAPHIC}
  123. graph,
  124. {$endif TESTGRAPHIC}
  125. pmode;
  126. type
  127. PVesaVideoMode = ^TVesaVideoMode;
  128. TVesaVideoMode = record
  129. {Col,Row : word;
  130. Color : boolean;}
  131. V : TVideoMode;
  132. Mode : word;
  133. IsGraphic : boolean;
  134. { zero based vesa specific driver count }
  135. VideoIndex : word;
  136. Next : PVesaVideoMode;
  137. end;
  138. CursorBitMap = Record
  139. width,height,size : longint;
  140. colors : array[0..8*8-1] of word;
  141. end;
  142. const
  143. VesaVideoModeHead : PVesaVideoMode = nil;
  144. VesaRegisteredModes : word = 0;
  145. {$ifdef TESTGRAPHIC}
  146. IsGraphicMode : boolean = false;
  147. GraphDriver : integer = 0;
  148. GraphMode : Integer = 0;
  149. FirstCallAfterSetVesaMode : boolean = false;
  150. LastCursorX : word = $ffff;
  151. LastCursorY : word = $ffff;
  152. LastCursorType : word = crHidden;
  153. var
  154. UnderLineImage : CursorBitMap;
  155. BlockImage : CursorBitMap;
  156. HalfBlockImage : CursorBitMap;
  157. {$endif TESTGRAPHIC}
  158. Var
  159. SysGetVideoModeCount : function : word;
  160. SysSetVideoMode : function (Const VideoMode : TVideoMode) : boolean;
  161. SysGetVideoModeData : function (Index : Word; Var Data : TVideoMode) : boolean;
  162. SysUpdateScreen : procedure(Force : Boolean);
  163. SysDoneVideo : procedure;
  164. SysInitVideo : procedure;
  165. SysSetCursorPos : procedure(NewCursorX, NewCursorY: Word);
  166. SysSetCursorType : procedure(NewCurosrType : word);
  167. function VESAGetInfo(var B: TVESAInfoBlock): boolean;
  168. var r: registers;
  169. OK: boolean;
  170. M: MemPtr;
  171. begin
  172. StrToMem('VBE2',B.Signature);
  173. GetDosMem(M,SizeOf(B));
  174. M.MoveDataTo(B,sizeof(B));
  175. r.ah:=$4f; r.al:=0;
  176. r.es:=M.DosSeg; r.di:=M.DosOfs;
  177. realintr($10,r);
  178. M.MoveDataFrom(sizeof(B),B);
  179. FreeDosMem(M);
  180. OK:=(r.ax=$004f){ and (MemToStr(B.Signature,4)='VESA')};
  181. VESAGetInfo:=OK;
  182. end;
  183. function VESAGetModeList(var B: TVESAModeList): boolean;
  184. var OK: boolean;
  185. VI: TVESAInfoBlock;
  186. begin
  187. FillChar(B,SizeOf(B),0);
  188. OK:=VESAGetInfo(VI);
  189. if OK then
  190. begin
  191. OK:=MoveDosToPM(VI.VideoModeList,@B.Modes,sizeof(B.Modes));
  192. if OK then
  193. while (B.Modes[B.Count+1]<>$ffff) and (B.Count<High(B.Modes)) do
  194. Inc(B.Count);
  195. end;
  196. VESAGetModeList:=OK;
  197. end;
  198. function VESASearchMode(XRes,YRes,BPX: word; LFB: boolean; var Mode: word; var ModeInfo: TVESAModeInfoBlock): boolean;
  199. var B: TVESAModeList;
  200. OK: boolean;
  201. I: integer;
  202. MI: TVESAModeInfoBlock;
  203. begin
  204. OK:=VESAGetModeList(B);
  205. I:=1; Mode:=0;
  206. repeat
  207. OK:=VESAGetModeInfo(B.Modes[I],MI);
  208. if OK and (MI.XResolution=XRes) and (MI.YResolution=YRes) and
  209. (MI.BitsPerPixel=BPX) and
  210. ((LFB=false) or ((MI.Attributes and vesa_vma_LinearFrameBufferAvail)<>0)) then
  211. begin Mode:=B.Modes[I]; ModeInfo:=MI; end;
  212. Inc(I);
  213. until (OK=false) or (I>=B.Count) or (Mode<>0);
  214. OK:=Mode<>0;
  215. VESASearchMode:=OK;
  216. end;
  217. function VESAGetOemString: string;
  218. var OK: boolean;
  219. VI: TVESAInfoBlock;
  220. S: array[0..256] of char;
  221. begin
  222. FillChar(S,SizeOf(S),0);
  223. OK:=VESAGetInfo(VI);
  224. if OK then
  225. OK:=MoveDosToPM(VI.OemString,@S,sizeof(S));
  226. VESAGetOemString:=StrPas(@S);
  227. end;
  228. function VESAGetModeInfo(Mode: word; var B: TVESAModeInfoBlock): boolean;
  229. var r : registers;
  230. M : MemPtr;
  231. OK: boolean;
  232. begin
  233. r.ah:=$4f; r.al:=$01; r.cx:=Mode;
  234. GetDosMem(M,sizeof(B));
  235. r.es:=M.DosSeg; r.di:=M.DosOfs; {r.ds:=r.es;}
  236. realintr($10,r);
  237. M.MoveDataFrom(sizeof(B),B);
  238. FreeDosMem(M);
  239. OK:=(r.ax=$004f);
  240. VESAGetModeInfo:=OK;
  241. end;
  242. function RegisterVesaVideoMode(Mode : word) : boolean;
  243. var B: TVESAModeInfoBlock;
  244. VH : PVesaVideoMode;
  245. DoAdd : boolean;
  246. begin
  247. if not VESAGetModeInfo(Mode,B) then
  248. RegisterVesaVideoMode:=false
  249. else
  250. begin
  251. VH:=VesaVideoModeHead;
  252. DoAdd:=true;
  253. RegisterVesaVideoMode:=false;
  254. while assigned(VH) do
  255. begin
  256. if VH^.mode=mode then
  257. DoAdd:=false;
  258. VH:=VH^.next;
  259. end;
  260. if DoAdd then
  261. begin
  262. New(VH);
  263. VH^.next:=VesaVideoModeHead;
  264. VH^.mode:=mode;
  265. VH^.IsGraphic:=(B.Attributes and vesa_vma_GraphicsMode)<>0;
  266. VH^.v.color:=(B.Attributes and vesa_vma_ColorMode)<>0;
  267. if VH^.IsGraphic then
  268. begin
  269. VH^.v.col:=B.XResolution div 8;
  270. VH^.v.row:=B.YResolution div 8;
  271. end
  272. else
  273. begin
  274. VH^.v.col:=B.XResolution;
  275. VH^.v.row:=B.YResolution;
  276. end;
  277. VH^.VideoIndex:=VesaRegisteredModes;
  278. Inc(VesaRegisteredModes);
  279. RegisterVesaVideoMode:=true;
  280. VesaVideoModeHead:=VH;
  281. end;
  282. end;
  283. end;
  284. function VESASetMode(Mode: word): boolean;
  285. var r: registers;
  286. OK: boolean;
  287. begin
  288. r.ah:=$4f; r.al:=$02; r.bx:=Mode;
  289. dos.intr($10,r);
  290. OK:=(r.ax=$004f);
  291. VESASetMode:=OK;
  292. end;
  293. function VESAGetMode(var Mode: word): boolean;
  294. var r : registers;
  295. OK: boolean;
  296. begin
  297. r.ah:=$4f; r.al:=$03;
  298. dos.intr($10,r);
  299. OK:=(r.ax=$004f);
  300. if OK then Mode:=r.bx;
  301. VESAGetMode:=OK;
  302. end;
  303. function VESASelectMemoryWindow(Window: byte; Position: word): boolean;
  304. var r : registers;
  305. OK : boolean;
  306. begin
  307. r.ah:=$4f; r.al:=$05; r.bh:=0; r.bl:=Window; r.dx:=Position;
  308. dos.intr($10,r);
  309. OK:=(r.ax=$004f);
  310. VESASelectMemoryWindow:=OK;
  311. end;
  312. function VESAReturnMemoryWindow(Window: byte; var Position: word): boolean;
  313. var r : registers;
  314. OK : boolean;
  315. begin
  316. r.ah:=$4f; r.al:=$05; r.bh:=1; r.bl:=Window;
  317. dos.intr($10,r);
  318. OK:=(r.ax=$004f);
  319. if OK then Position:=r.dx;
  320. VESAReturnMemoryWindow:=OK;
  321. end;
  322. function VESAInit: boolean;
  323. var OK: boolean;
  324. VI: TVESAInfoBlock;
  325. begin
  326. OK:=VESAGetInfo(VI);
  327. if OK then
  328. VESAInit:=OK;
  329. end;
  330. {$ifdef FPC}
  331. Function VesaGetVideoModeData (Index : Word; Var Data : TVideoMode) : boolean;
  332. Var
  333. PrevCount : word;
  334. VH : PVesaVideoMode;
  335. begin
  336. PrevCount:=SysGetVideoModeCount();
  337. VesaGetVideoModeData:=(Index<PrevCount);
  338. If VesaGetVideoModeData then
  339. begin
  340. VesaGetVideoModeData:=SysGetVideoModeData(Index,Data);
  341. exit;
  342. end;
  343. VesaGetVideoModeData:=(Index-PrevCount)<VesaRegisteredModes;
  344. If VesaGetVideoModeData then
  345. begin
  346. VH:=VesaVideoModeHead;
  347. while assigned(VH) and (VH^.VideoIndex<>Index-PrevCount) do
  348. VH:=VH^.next;
  349. if assigned(VH) then
  350. Data:=VH^.v
  351. else
  352. VesaGetVideoModeData:=false;
  353. end;
  354. end;
  355. function SetVESAMode(const VideoMode: TVideoMode): Boolean;
  356. var
  357. res : boolean;
  358. VH : PVesaVideoMode;
  359. begin
  360. res:=false;
  361. VH:=VesaVideoModeHead;
  362. while assigned(VH) do
  363. begin
  364. if (VideoMode.col=VH^.v.col) and
  365. (VideoMode.row=VH^.v.row) and
  366. (VideoMode.color=VH^.v.color) then
  367. begin
  368. {$ifdef TESTGRAPHIC}
  369. if VH^.IsGraphic then
  370. begin
  371. if IsGraphicMode then
  372. CloseGraph;
  373. GraphDriver:=Graph.Vesa;
  374. if (VideoMode.col = 100) and (VideoMode.row = 75) then
  375. GraphMode:=m800x600x256
  376. else if (VideoMode.col = 80) and (VideoMode.row = 60) then
  377. GraphMode:=m640x480x256
  378. else if (VideoMode.col = 128) and (VideoMode.row = 96) then
  379. GraphMode:=m1024x768x256
  380. else
  381. GraphMode:=Graph.Detect;
  382. InitGraph(GraphDriver,GraphMode,'');
  383. res:=(GraphResult=grOK);
  384. if not res then
  385. begin
  386. SetVesaMode:=false;
  387. exit;
  388. end;
  389. end
  390. else
  391. {$endif TESTGRAPHIC}
  392. res:=VESASetMode(VH^.mode);
  393. if res then
  394. begin
  395. ScreenWidth:=VideoMode.Col;
  396. ScreenHeight:=VideoMode.Row;
  397. ScreenColor:=VideoMode.Color;
  398. {$ifdef TESTGRAPHIC}
  399. IsGraphicMode:=VH^.IsGraphic;
  400. FirstCallAfterSetVesaMode:=true;
  401. LastCursorX:=$ffff;
  402. LastCursorY:=$ffff;
  403. LastCursorType:=crHidden;
  404. if IsGraphicMode then
  405. DoCustomMouse(false)
  406. else
  407. {$endif TESTGRAPHIC}
  408. DoCustomMouse(true);
  409. end;
  410. end;
  411. if res then
  412. begin
  413. SetVesaMode:=true;
  414. exit;
  415. end;
  416. VH:=VH^.next;
  417. end;
  418. SetVESAMode:=SysSetVideoMode(VideoMode);
  419. end;
  420. procedure VesaSetCursorPos(NewCursorX, NewCursorY: Word);
  421. begin
  422. {$ifdef TESTGRAPHIC}
  423. if not IsGraphicMode then
  424. {$endif TESTGRAPHIC}
  425. begin
  426. SysSetCursorPos(NewCursorX,NewCursorY);
  427. exit;
  428. end;
  429. {$ifdef TESTGRAPHIC}
  430. if (NewCursorX<>LastCursorX) or (NewCursorY<>LastCursorY) then
  431. begin
  432. Case GetCursorType of
  433. crHidden : ;
  434. crUnderLine :
  435. Begin
  436. PutImage(LastCursorX*8,LastCursorY*8+7,UnderLineImage,XORPut);
  437. PutImage(NewCursorX*8,NewCursorY*8+7,UnderLineImage,XORPut);
  438. End;
  439. crBlock :
  440. Begin
  441. PutImage(LastCursorX*8,LastCursorY*8,BlockImage,XORPut);
  442. PutImage(NewCursorX*8,NewCursorY*8,BlockImage,XORPut);
  443. End;
  444. crHalfBlock :
  445. Begin
  446. PutImage(LastCursorX*8,LastCursorY*8+4,HalfBlockImage,XORPut);
  447. PutImage(NewCursorX*8,NewCursorY*8+4,HalfBlockImage,XORPut);
  448. End;
  449. end;
  450. LastCursorX:=NewCursorX;
  451. LastCursorY:=NewCursorY;
  452. end;
  453. {$endif TESTGRAPHIC}
  454. end;
  455. procedure VesaSetCursorType(NewType : Word);
  456. begin
  457. {$ifdef TESTGRAPHIC}
  458. if not IsGraphicMode then
  459. {$endif TESTGRAPHIC}
  460. begin
  461. SysSetCursorType(NewType);
  462. exit;
  463. end;
  464. {$ifdef TESTGRAPHIC}
  465. if (NewType<>LastCursorType) then
  466. begin
  467. Case LastCursorType of
  468. crHidden : ;
  469. crUnderLine :
  470. Begin
  471. PutImage(LastCursorX*8,LastCursorY*8+7,UnderLineImage,XORPut);
  472. End;
  473. crBlock :
  474. Begin
  475. PutImage(LastCursorX*8,LastCursorY*8,BlockImage,XORPut);
  476. End;
  477. crHalfBlock :
  478. Begin
  479. PutImage(LastCursorX*8,LastCursorY*8+4,HalfBlockImage,XORPut);
  480. End;
  481. end;
  482. SysSetCursorType(NewType);
  483. Case NewType of
  484. crHidden : ;
  485. crUnderLine :
  486. Begin
  487. PutImage(LastCursorX*8,LastCursorY*8+7,UnderLineImage,XORPut);
  488. End;
  489. crBlock :
  490. Begin
  491. PutImage(LastCursorX*8,LastCursorY*8,BlockImage,XORPut);
  492. End;
  493. crHalfBlock :
  494. Begin
  495. PutImage(LastCursorX*8,LastCursorY*8+4,HalfBlockImage,XORPut);
  496. End;
  497. end;
  498. LastCursorType:=NewType;
  499. end;
  500. {$endif TESTGRAPHIC}
  501. end;
  502. procedure VesaUpdateScreen(Force: Boolean);
  503. {$ifdef TESTGRAPHIC}
  504. var
  505. StoreDrawTextBackground,
  506. MustUpdate : boolean;
  507. x,y : longint;
  508. w, prevcolor,
  509. prevbkcolor, StoreCursorType : word;
  510. Color,BkCol,Col : byte;
  511. Ch : char;
  512. {$endif TESTGRAPHIC}
  513. begin
  514. {$ifdef TESTGRAPHIC}
  515. if not IsGraphicMode then
  516. {$endif TESTGRAPHIC}
  517. begin
  518. SysUpdateScreen(Force);
  519. exit;
  520. end;
  521. {$ifdef TESTGRAPHIC}
  522. if FirstCallAfterSetVesaMode then
  523. begin
  524. { Make sure to redraw all }
  525. Fillchar(OldVideoBuf^,VideoBufSize,#0);
  526. FirstCallAfterSetVesaMode:=false;
  527. end;
  528. if not force then
  529. begin
  530. MustUpdate:=false;
  531. asm
  532. movl VideoBuf,%esi
  533. movl OldVideoBuf,%edi
  534. movl VideoBufSize,%ecx
  535. shrl $2,%ecx
  536. repe
  537. cmpsl
  538. setne MustUpdate
  539. end;
  540. end;
  541. StoreDrawTextBackground:=DrawTextBackground;
  542. DrawTextBackground:=true;
  543. if Force or MustUpdate then
  544. begin
  545. PrevColor:=GetColor;
  546. PrevBkColor:=GetBkColor;
  547. for y:=0 to ScreenHeight-1 do
  548. for x:=0 to Screenwidth-1 do
  549. begin
  550. w:=VideoBuf^[x+y*ScreenWidth];
  551. if Force or
  552. (w<>OldVideoBuf^[x+y*ScreenWidth]) then
  553. Begin
  554. Color:=w shr 8;
  555. Ch:=chr(w and $ff);
  556. Col:=Color and $f;
  557. if (Col = 0) and (GetMaxColor=255) then
  558. Col:=255;
  559. SetColor(Col);
  560. BkCol:=(Color shr 4) and 7;
  561. if (BkCol = 0) and (GetMaxColor=255) then
  562. BkCol:=255;
  563. SetBkColor(BkCol);
  564. if (x=LastCursorX) and (Y=LastCursorY) then
  565. begin
  566. StoreCursorType:=LastCursorType;
  567. VesaSetCursorType(crHidden);
  568. end;
  569. OutTextXY(x*8,y*8,Ch);
  570. if (x=LastCursorX) and (Y=LastCursorY) then
  571. VesaSetCursorType(StoreCursorType);
  572. if not force then
  573. OldVideoBuf^[x+y*ScreenWidth]:=w;
  574. End;
  575. end;
  576. if Force then
  577. move(videobuf^,oldvideobuf^,
  578. VideoBufSize);
  579. SetColor(PrevColor);
  580. SetBkColor(GetBkColor);
  581. end;
  582. DrawTextBackground:=StoreDrawTextBackground;
  583. {$endif TESTGRAPHIC}
  584. end;
  585. procedure VesaDoneVideo;
  586. begin
  587. {$ifdef TESTGRAPHIC}
  588. if IsGraphicMode then
  589. begin
  590. CloseGraph;
  591. IsGraphicMode:=false;
  592. end;
  593. {$endif TESTGRAPHIC}
  594. SysDoneVideo();
  595. end;
  596. procedure VesaInitVideo;
  597. begin
  598. {$ifdef TESTGRAPHIC}
  599. if IsGraphicMode then
  600. begin
  601. SysInitVideo();
  602. InitGraph(GraphDriver,GraphMode,'');
  603. end
  604. else
  605. {$endif TESTGRAPHIC}
  606. SysInitVideo();
  607. end;
  608. Function VesaGetVideoModeCount : Word;
  609. begin
  610. VesaGetVideoModeCount:=SysGetVideoModeCount()+VesaRegisteredModes;
  611. end;
  612. Procedure FreeVesaModes;
  613. var
  614. VH : PVesaVideoMode;
  615. begin
  616. VH:=VesaVideoModeHead;
  617. While assigned(VH) do
  618. begin
  619. VesaVideoModeHead:=VH^.Next;
  620. FreeMem(VH,Sizeof(TVesaVideoMode));
  621. VH:=VesaVideoModeHead;
  622. end;
  623. end;
  624. Var
  625. Driver : TVideoDriver;
  626. {$ifdef TESTGRAPHIC}
  627. i : longint;
  628. {$endif TESTGRAPHIC}
  629. BEGIN
  630. { Get the videodriver to be used }
  631. GetVideoDriver (Driver);
  632. { Change needed functions }
  633. SysGetVideoModeCount:=Driver.GetVideoModeCount;
  634. Driver.GetVideoModeCount:=@VesaGetVideoModeCount;
  635. SysGetVideoModeData:=Driver.GetVideoModeData;
  636. Driver.GetVideoModeData:=@VesaGetVideoModeData;
  637. SysSetVideoMode:=Driver.SetVideoMode;
  638. Driver.SetVideoMode:=@SetVESAMode;
  639. SysSetCursorPos:=Driver.SetCursorPos;
  640. Driver.SetCursorPos:=@VESASetCursorPos;
  641. SysSetCursorType:=Driver.SetCursorType;
  642. Driver.SetCursorType:=@VESASetCursorType;
  643. SysUpdateScreen:=Driver.UpdateScreen;
  644. Driver.UpdateScreen:=@VesaUpdateScreen;
  645. SysDoneVideo:=Driver.DoneDriver;
  646. Driver.DoneDriver:=@VesaDoneVideo;
  647. SysInitVideo:=Driver.InitDriver;
  648. Driver.InitDriver:=@VesaInitVideo;
  649. {$ifdef TESTGRAPHIC}
  650. BlockImage.width:=7;
  651. BlockImage.height:=7;
  652. For i:=0 to 8*8-1 do
  653. BlockImage.colors[i]:=White;
  654. HalfBlockImage:=BlockImage;
  655. HalfBlockImage.height:=3;
  656. UnderLineImage:=BlockImage;
  657. UnderLineImage.height:=0;
  658. {$endif TESTGRAPHIC}
  659. SetVideoDriver (Driver);
  660. {$endif FPC}
  661. END.
  662. {
  663. $Log$
  664. Revision 1.8 2002-09-07 15:40:47 peter
  665. * old logs removed and tabs fixed
  666. Revision 1.7 2002/05/29 22:39:51 pierre
  667. + FreeVesaModes
  668. }