vesamode.pas 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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;
  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. end;
  76. end;
  77. var
  78. infoblock : TVESAInfoBLock;
  79. i : longint;
  80. m : word;
  81. begin
  82. ReturnSuperVGAInfo(infoblock);
  83. if not((infoblock.VESASignature[0]<>'V') or
  84. (infoblock.VESASignature[1]<>'E') or
  85. (infoblock.VESASignature[2]<>'S') or
  86. (infoblock.VESASignature[3]<>'A')) then
  87. begin
  88. {$R-}
  89. i:=0;
  90. while true do
  91. begin
  92. dosmemget(hi(dword(infoblock.VideoModePtr)),lo(dword(infoblock.VideoModePtr))+i*2,m,2);
  93. case m of
  94. 264:
  95. RegisterVideoMode(80,60,true,@SetVESAMode,264);
  96. 265:
  97. RegisterVideoMode(132,25,true,@SetVESAMode,265);
  98. 266:
  99. RegisterVideoMode(132,43,true,@SetVESAMode,266);
  100. 267:
  101. RegisterVideoMode(132,50,true,@SetVESAMode,267);
  102. 268:
  103. RegisterVideoMode(132,60,true,@SetVESAMode,268);
  104. $ffff:
  105. break;
  106. end;
  107. inc(i);
  108. end;
  109. end;
  110. end.
  111. {
  112. $Log$
  113. Revision 1.1 2000-01-06 01:20:30 peter
  114. * moved out of packages/ back to topdir
  115. Revision 1.2 1999/12/23 22:37:38 pierre
  116. * Use @SetVesaMode for normal FPC syntax
  117. * variable I was not initialized in unit initialization!!
  118. Revision 1.1 1999/11/24 23:36:38 peter
  119. * moved to packages dir
  120. Revision 1.2 1999/03/14 17:43:02 florian
  121. + 80x50 mode support added
  122. * some bugs in VESA mode support removed
  123. Revision 1.1 1999/03/13 17:29:39 florian
  124. + first implementation for VESA 1.x, only standard modes are supported
  125. }