vesamode.pp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1999-2000 by Florian Klaempfl
  5. member of the Free Pascal development team
  6. Video unit extension for VESA Modes for go32v2
  7. See the file COPYING.FPC, included in this distribution,
  8. for details about the copyright.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. **********************************************************************}
  13. unit vesamode;
  14. interface
  15. implementation
  16. uses
  17. dos,go32,dpmiexcp,video,mouse;
  18. type
  19. twordarray = array[0..0] of word;
  20. pwordarray = ^twordarray;
  21. TVESAInfoBlock = record
  22. VESASignature : ARRAY[0..3] OF CHAR;
  23. VESAVersion : WORD;
  24. OEMStringPtr : PChar;
  25. Capabilities : LONGINT;
  26. VideoModePtr : pwordarray;
  27. TotalMemory : WORD;
  28. Reserved : ARRAY[1..242] OF BYTE;
  29. end;
  30. function ReturnSuperVGAInfo(var ib : TVESAInfoBLock) : Word;
  31. var
  32. regs : registers;
  33. begin
  34. regs.ah:=$4f;
  35. regs.al:=0;
  36. regs.es:=tb_segment;
  37. regs.di:=tb_offset;
  38. intr($10,regs);
  39. dosmemget(tb_segment,tb_offset,ib,sizeof(ib));
  40. ReturnSuperVGAInfo:=regs.ax;
  41. end;
  42. function SetSuperVGAMode(m : word) : word;
  43. var
  44. regs : registers;
  45. begin
  46. regs.ah:=$4f;
  47. regs.al:=2;
  48. regs.bx:=m;
  49. intr($10,regs);
  50. SetSuperVGAMode:=regs.ax;
  51. end;
  52. function SetVESAMode(const VideoMode: TVideoMode; Params: Longint): Boolean;
  53. var
  54. w : word;
  55. begin
  56. w:=SetSuperVGAMode(Params);
  57. if w<>$4f then
  58. SetVESAMode:=false
  59. else
  60. begin
  61. SetVESAMode:=true;
  62. ScreenWidth:=VideoMode.Col;
  63. ScreenHeight:=VideoMode.Row;
  64. ScreenColor:=true;
  65. // cheat to get a correct mouse
  66. {
  67. mem[$40:$84]:=ScreenHeight-1;
  68. mem[$40:$4a]:=ScreenWidth;
  69. memw[$40:$4c]:=ScreenHeight*((ScreenWidth shl 1)-1);
  70. }
  71. DoCustomMouse(true);
  72. end;
  73. end;
  74. var
  75. infoblock : TVESAInfoBLock;
  76. i : longint;
  77. m : word;
  78. begin
  79. ReturnSuperVGAInfo(infoblock);
  80. if not((infoblock.VESASignature[0]<>'V') or
  81. (infoblock.VESASignature[1]<>'E') or
  82. (infoblock.VESASignature[2]<>'S') or
  83. (infoblock.VESASignature[3]<>'A')) then
  84. begin
  85. {$R-}
  86. i:=0;
  87. while true do
  88. begin
  89. dosmemget(hi(dword(infoblock.VideoModePtr)),lo(dword(infoblock.VideoModePtr))+i*2,m,2);
  90. case m of
  91. 264:
  92. RegisterVideoMode(80,60,true,@SetVESAMode,264);
  93. 265:
  94. RegisterVideoMode(132,25,true,@SetVESAMode,265);
  95. 266:
  96. RegisterVideoMode(132,43,true,@SetVESAMode,266);
  97. 267:
  98. RegisterVideoMode(132,50,true,@SetVESAMode,267);
  99. 268:
  100. RegisterVideoMode(132,60,true,@SetVESAMode,268);
  101. $ffff:
  102. break;
  103. end;
  104. inc(i);
  105. end;
  106. end;
  107. end.