vesamode.pas 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. {
  2. $Id$
  3. VESA-Textmode support for the DOS version of the FPC API
  4. Copyright (c) 1999 by Florian Klaempfl
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Library General Public
  7. License as published by the Free Software Foundation; either
  8. version 2 of the License, or (at your option) any later version.
  9. This library 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. See the GNU
  12. Library General Public License for more details.
  13. You should have received a copy of the GNU Library General Public
  14. License along with this library; if not, write to the Free
  15. Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. }
  17. unit vesamode;
  18. interface
  19. implementation
  20. uses
  21. dos,go32,dpmiexcp,video,mouse;
  22. type
  23. twordarray = array[0..0] of word;
  24. pwordarray = ^twordarray;
  25. TVESAInfoBlock = record
  26. VESASignature : ARRAY[0..3] OF CHAR;
  27. VESAVersion : WORD;
  28. OEMStringPtr : PChar;
  29. Capabilities : LONGINT;
  30. VideoModePtr : pwordarray;
  31. TotalMemory : WORD;
  32. Reserved : ARRAY[1..242] OF BYTE;
  33. end;
  34. function ReturnSuperVGAInfo(var ib : TVESAInfoBLock) : Word;
  35. var
  36. regs : registers;
  37. begin
  38. regs.ah:=$4f;
  39. regs.al:=0;
  40. regs.es:=tb_segment;
  41. regs.di:=tb_offset;
  42. intr($10,regs);
  43. dosmemget(tb_segment,tb_offset,ib,sizeof(ib));
  44. ReturnSuperVGAInfo:=regs.ax;
  45. end;
  46. function SetSuperVGAMode(m : word) : word;
  47. var
  48. regs : registers;
  49. begin
  50. regs.ah:=$4f;
  51. regs.al:=2;
  52. regs.bx:=m;
  53. intr($10,regs);
  54. SetSuperVGAMode:=regs.ax;
  55. end;
  56. function SetVESAMode(const VideoMode: TVideoMode; Params: Longint): Boolean;
  57. var
  58. w : word;
  59. begin
  60. w:=SetSuperVGAMode(Params);
  61. if w<>$4f then
  62. SetVESAMode:=false
  63. else
  64. begin
  65. SetVESAMode:=true;
  66. ScreenWidth:=VideoMode.Col;
  67. ScreenHeight:=VideoMode.Row;
  68. ScreenColor:=true;
  69. // cheat to get a correct mouse
  70. {
  71. mem[$40:$84]:=ScreenHeight-1;
  72. mem[$40:$4a]:=ScreenWidth;
  73. memw[$40:$4c]:=ScreenHeight*((ScreenWidth shl 1)-1);
  74. }
  75. DoCustomMouse(true);
  76. end;
  77. end;
  78. var
  79. infoblock : TVESAInfoBLock;
  80. i : longint;
  81. m : word;
  82. begin
  83. ReturnSuperVGAInfo(infoblock);
  84. if not((infoblock.VESASignature[0]<>'V') or
  85. (infoblock.VESASignature[1]<>'E') or
  86. (infoblock.VESASignature[2]<>'S') or
  87. (infoblock.VESASignature[3]<>'A')) then
  88. begin
  89. {$R-}
  90. i:=0;
  91. while true do
  92. begin
  93. dosmemget(hi(dword(infoblock.VideoModePtr)),lo(dword(infoblock.VideoModePtr))+i*2,m,2);
  94. case m of
  95. 264:
  96. RegisterVideoMode(80,60,true,@SetVESAMode,264);
  97. 265:
  98. RegisterVideoMode(132,25,true,@SetVESAMode,265);
  99. 266:
  100. RegisterVideoMode(132,43,true,@SetVESAMode,266);
  101. 267:
  102. RegisterVideoMode(132,50,true,@SetVESAMode,267);
  103. 268:
  104. RegisterVideoMode(132,60,true,@SetVESAMode,268);
  105. $ffff:
  106. break;
  107. end;
  108. inc(i);
  109. end;
  110. end;
  111. end.
  112. {
  113. $Log$
  114. Revision 1.3 2000-02-07 22:54:44 florian
  115. * custommouse define removed, i.e. code is always active
  116. * the xor value for the mouse cursor must be $7f instead of $ff
  117. Revision 1.2 2000/02/06 14:29:45 florian
  118. * mouse support for vesa resolutions under go32v2, needs currently the define
  119. custommouse
  120. Revision 1.1 2000/01/06 01:20:30 peter
  121. * moved out of packages/ back to topdir
  122. Revision 1.2 1999/12/23 22:37:38 pierre
  123. * Use @SetVesaMode for normal FPC syntax
  124. * variable I was not initialized in unit initialization!!
  125. Revision 1.1 1999/11/24 23:36:38 peter
  126. * moved to packages dir
  127. Revision 1.2 1999/03/14 17:43:02 florian
  128. + 80x50 mode support added
  129. * some bugs in VESA mode support removed
  130. Revision 1.1 1999/03/13 17:29:39 florian
  131. + first implementation for VESA 1.x, only standard modes are supported
  132. }