VESAINFO.CPP 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. /*
  2. ** Command & Conquer Red Alert(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***************************************************************************
  19. ** C O N F I D E N T I A L --- W E S T W O O D A S S O C I A T E S **
  20. ***************************************************************************
  21. * *
  22. * Project Name : LIBRARY *
  23. * *
  24. * File Name : VIDEO.C *
  25. * *
  26. * Programmer : David Dettmer *
  27. * *
  28. * Last Update : January 12, 1995 [PWG] *
  29. * *
  30. *-------------------------------------------------------------------------*
  31. * Functions: *
  32. * Find_Video_Mode -- Converts a dos video mode to a WWLIB video mode *
  33. * Get_Video_Mode -- Returns the current video mode. *
  34. * Set_Video_Mode -- Sets the requested video mode *
  35. * Set_Lores_Function_Pointers -- Sets up the lowres function pointers *
  36. * Set_HiRes_Function_Pointers -- Sets the HiRes function pointers *
  37. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  38. #include <dos.h>
  39. #include "iostream.h"
  40. #include "video.h"
  41. #include "descmgmt.h"
  42. #include "mcgaprim.h"
  43. #include "gbuffer.h"
  44. #include "vbuffer.h"
  45. #include "wwmem.h"
  46. #include "playcd.h"
  47. /***************************************************************************
  48. * VESA_INFO -- Debug routine which displays vesa info to stdout *
  49. * *
  50. * INPUT: none *
  51. * *
  52. * OUTPUT: none *
  53. * *
  54. * WARNINGS: *
  55. * *
  56. * *
  57. * HISTORY: *
  58. * 11/22/1994 PWG : Created. *
  59. *=========================================================================*/
  60. void Vesa_Info(int vesa_mode)
  61. {
  62. UINT paras;
  63. USHORT longest ;
  64. union REGS regs;
  65. struct SREGS sregs;
  66. SEGSEL VInfoSel ;
  67. VesaInfoType * VInfo ;
  68. SEGSEL ModeInfoSel ;
  69. VesaModeInfoType * ModeInfo ;
  70. unsigned temp ;
  71. short * ptr ;
  72. char buff [ 256 ] ;
  73. short mode_table [][4] = { { 0x100 , 640 , 400 , 256 },
  74. { 0x101 , 640 , 480 , 256 },
  75. { 0x103 , 800 , 600 , 256 },
  76. } ;
  77. cout << "\n\nWWESTWOOD STUDIOS. Vesa Driver attributes.\n" ;
  78. // verifie that this is a standard VESA MODE
  79. if ( (vesa_mode < VESA_640X400_256) || ( vesa_mode > VESA_TEXT_132X60 )) {
  80. cout << "this is not a standard VESA mode\n" ;
  81. return ;
  82. }
  83. // Compute size of VesaInfo structure in paragraphs
  84. paras = ( sizeof(VesaInfoType) + 15 ) >> 4 ;
  85. // Alloc real-mode memory for VESA structure.
  86. if ( DPMI_real_alloc ( paras , & VInfoSel , & longest ) ) return ;
  87. VInfo = ( VesaInfoType * ) ( VInfoSel . seg << 4 ) ;
  88. // Compute size of VesaModeInfo structure in paragraphs
  89. paras = ( sizeof(VesaModeInfoType) + 15 ) >> 4 ;
  90. //Alloc real-mode memory for VesaModeInfoType structure.
  91. if ( DPMI_real_alloc ( paras , & ModeInfoSel , & longest ) )
  92. {
  93. DPMI_real_free ( VInfoSel ) ;
  94. return ;
  95. }
  96. ModeInfo = ( VesaModeInfoType * ) ( ModeInfoSel . seg << 4 ) ;
  97. // Get Read Vesa Driver Vesa
  98. regs . x . eax = 0x4f00 ;
  99. regs . x . edi = 0 ;
  100. sregs . es = VInfoSel . seg ;
  101. DPMI_real_intr ( 0x10 , & regs , & sregs );
  102. regs . x . eax &= 0xffff ;
  103. if ( regs . x . eax != 0x004F) {
  104. cout << "\nNot Vesa Driver Present\n" ;
  105. DPMI_real_free ( ModeInfoSel ) ;
  106. DPMI_real_free ( VInfoSel ) ;
  107. return ;
  108. }
  109. temp = ( unsigned ) VInfo->AvailModes ;
  110. ptr = ( short * ) ( ( ( temp & 0xffff0000 ) >> 12 ) + ( temp & 0xffff ) ) ;
  111. cout << "Available Video Modes\n" ;
  112. for ( ; * ptr != -1 ; ptr ++ )
  113. for ( temp = 0 ; temp < 3 ; temp ++ )
  114. if ( * ptr == mode_table [ temp ] [ 0 ] ) {
  115. sprintf ( buff , "%d\t%d x %d x %d\n" ,
  116. mode_table [ temp ] [ 0 ],
  117. mode_table [ temp ] [ 1 ],
  118. mode_table [ temp ] [ 2 ],
  119. mode_table [ temp ] [ 3 ] ) ;
  120. cout << buff ;
  121. }
  122. // Get Info for this particular graphic mode
  123. regs . x . eax = 0x4F01;
  124. regs . x . ecx = vesa_mode;
  125. regs . x . edi = 0 ;
  126. sregs . es = ModeInfoSel . seg ;
  127. DPMI_real_intr ( 0x10 , & regs , & sregs );
  128. regs . x . eax &= 0xffff ;
  129. if ( regs . x . eax != 0x004F) {
  130. cout << "\nGraphic mode " << vesa_mode << " is not supported by this video card\n" ;
  131. DPMI_real_free ( ModeInfoSel ) ;
  132. DPMI_real_free ( VInfoSel ) ;
  133. return ;
  134. }
  135. cout << "\nMode attributes\n" ;
  136. temp = ( unsigned ) ModeInfo->Attributes ;
  137. if ( temp & 0x01 ) cout << "\tMode supported in hardware\n" ;
  138. else cout << "\tMode is not supported in hardware\n" ;
  139. if ( temp & 0x20 ) cout << "\tMode is not VGA Windowed memory compatible\n" ;
  140. else cout << "\tMode is VGA Windowed memory compatible\n" ;
  141. cout << "Window A attributes\n" ;
  142. temp = ( unsigned ) ModeInfo->WinA_Attributes; ;
  143. if ( temp & 0x02 ) cout << "\tWindow A is Readable\n" ;
  144. else cout << "\tWindow A is not Readable\n" ;
  145. if ( temp & 0x04 ) cout << "\tWindow A is Writeable\n" ;
  146. else cout << "\tWindow A is not Writeable\n" ;
  147. sprintf ( buff , "%P\n" , ModeInfo->WinA_Segment ) ;
  148. cout << "\tWindow A segment address 0x" << buff + 4 ;
  149. cout << "Window B attributes\n" ;
  150. temp = ( unsigned ) ModeInfo->WinB_Attributes; ;
  151. if ( temp & 0x02 ) cout << "\tWindow B is Readable\n" ;
  152. else cout << "\tWindow B is not Readable\n" ;
  153. if ( temp & 0x04 ) cout << "\tWindow B is Writeable\n" ;
  154. else cout << "\tWindow B is not Writeable\n" ;
  155. sprintf ( buff , "%P\n" , ModeInfo->WinB_Segment ) ;
  156. cout << "\tWindow B segment address 0x" << buff + 4 ;
  157. cout << "Window shared attributes\n" ;
  158. cout << "\tWindow Granularity (KB) :" << ModeInfo->WinGranularity << "\n" ;
  159. cout << "\tWindow Size (KB) : " << ModeInfo->WinSize << "\n";
  160. cout << "\tNumber of Banks : " << (long)ModeInfo->NumBanks << "\n";
  161. cout << "\tBytes per ScanLine : " << (long)ModeInfo->BytesPerScanline << "\n";
  162. cout << "\tXResolution : " << (long)ModeInfo->XRes << "\n";
  163. cout << "\tYResolution : " << (long)ModeInfo->YRes << "\n";
  164. cout << "\tX Char Size : " << (long)ModeInfo->XCharSize << "\n";
  165. cout << "\tY Char Size : " << (long)ModeInfo->YCharSize << "\n";
  166. cout << "\tMemory Model : " << (long)ModeInfo->MemoryModel << "\n";
  167. cout << "\tNumber of planes : " << (long)ModeInfo->NumPlanes << "\n" ;
  168. cout << "\tBits per pixels : " << (long)ModeInfo->BitsPerPixel << "\n" ;
  169. /*
  170. cout << "Bttributes: " << (long)ModeInfo.Bttributes << "\n"
  171. << "Win B Bttributes: " << (long)ModeInfo.WinB_Bttributes << "\n"
  172. << "Win B Bttributes: " << (long)ModeInfo.WinB_Bttributes << "\n"
  173. << "Win Granularity " << (long)ModeInfo.WinGranularity << "\n"
  174. << "Win Size: " << (long)ModeInfo.WinSize << "\n"
  175. << "Win B Segment: " << hex << (unsigned short)ModeInfo.WinB_Segment << "\n"
  176. << "Win B Segment: " << (unsigned short)ModeInfo.WinB_Segment << "\n"
  177. << "Bytes per scan line: " << dec << (unsigned short)ModeInfo.BytesPerScanline << "\n"
  178. << "X resolution: " << (long)ModeInfo.XRes << "\n"
  179. << "Y resolution: " << (long)ModeInfo.YRes << "\n"
  180. << "X Char Size: " << (long)ModeInfo.XCharSize << "\n"
  181. << "Y Char Size: " << (long)ModeInfo.YCharSize << "\n"
  182. << "Number of planes: " << (long)ModeInfo.NumPlanes << "\n"
  183. << "Bits per pixels: " << (long)ModeInfo.BitsPerPixel << "\n"
  184. << "Number of Banks: " << (long)ModeInfo.NumBanks << "\n"
  185. << "Memory Model: " << (long)ModeInfo.MemoryModel << "\n"
  186. << "Bank Size: " << (long)ModeInfo.BankSize << "\n";
  187. */
  188. DPMI_real_free ( ModeInfoSel ) ;
  189. DPMI_real_free ( VInfoSel ) ;
  190. }