VIDEO.CPP 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651
  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 : June 29, 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. * Set_Original_Video_Mode -- sets mode to restore system to on exit *
  38. * Get_Original_Video_Mode -- Gets the original video mode value *
  39. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  40. #include <dos.h>
  41. #include "iostream.h"
  42. #include "video.h"
  43. #include "descmgmt.h"
  44. #include "mcgaprim.h"
  45. #include "gbuffer.h"
  46. #include "vbuffer.h"
  47. #include "wwmem.h"
  48. #include "playcd.h"
  49. extern "C" int MInstalled ;
  50. extern "C" void Hide_Mouse(void);
  51. extern "C" void Show_Mouse(void);
  52. extern "C" void Reset_Mouse (void) ;
  53. extern "C" int Vesa_Hook ( REALPTR function ) ;
  54. extern "C" void Remove_Vesa (void) ;
  55. extern "C" SEGSEL RMVesaVectorSel ;
  56. extern "C" REALPTR VesaFunc;
  57. /*=========================================================================*/
  58. /* Define the global variables that we require. */
  59. /*=========================================================================*/
  60. long BankTable[MAX_BANK_ENTRIES];
  61. int GraphicMode = UNINITIALIZED_MODE;
  62. long XRes = 0;
  63. long YRes = 0;
  64. REALPTR VesaFunc;
  65. unsigned long RMVesaVector ;
  66. unsigned long RMVesaRegs ;
  67. /*=========================================================================*
  68. * Private Varirables *
  69. * *
  70. * VInfo - Protected mode copy of VInfo structure. *
  71. * ModeInfo - Protected mode copy of ModeInfo structure. *
  72. * rpModeInfo - Real ptr to ModeInfo structure in conventional memory. *
  73. * rpVInfo - Real ptr to VInfo structure in conventional memory. *
  74. * _regs - Registers used for calling software interrupts. *
  75. *=========================================================================*/
  76. PRIVATE void * rpModeInfo = NULL;
  77. PRIVATE SEGSEL rpModeInfoSel ;
  78. PRIVATE void * rpVInfo = NULL;
  79. PRIVATE SEGSEL rpVInfoSel ;
  80. PRIVATE long _OriginalVideoMode = UNINITIALIZED_MODE;
  81. PRIVATE VesaInfoType VInfo;
  82. PRIVATE VesaModeInfoType ModeInfo;
  83. /*=========================================================================*/
  84. /* The following PRIVATE functions are in this file: */
  85. /*=========================================================================*/
  86. PRIVATE long Install_Vesa(void);
  87. PRIVATE long Vesa_Get_Mode_Info(long mode);
  88. PRIVATE long Vesa_Set_Mode(long mode);
  89. PRIVATE void Init_Bank_Table(void);
  90. PRIVATE VOID Set_LoRes_Function_Pointers(VOID);
  91. PRIVATE VOID Set_HiRes_Function_Pointers(VOID);
  92. extern "C" long Vesa_XRes(void);
  93. extern "C" long Vesa_YRes(void);
  94. extern "C" char CurrentPalette [ 256 * 3 ] ;
  95. extern "C" char PaletteTable [ 1024 ] ;
  96. /*= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
  97. /***************************************************************************
  98. * GET_VIDEO_MODE -- Returns the current video mode. *
  99. * *
  100. * INPUT: none *
  101. * *
  102. * OUTPUT: returns the graphic mode as a WWLIB library define *
  103. * *
  104. * WARNINGS: none *
  105. * *
  106. * HISTORY: *
  107. * 01/25/1994 : Created. *
  108. *=========================================================================*/
  109. int Get_Video_Mode(void)
  110. {
  111. union REGS regs;
  112. if( GraphicMode == UNINITIALIZED_MODE )
  113. {
  114. regs . x . eax = 0xf00 ; // get graphic mode
  115. int386 ( 0x10 , & regs , & regs ) ;
  116. return ( regs . w . ax & 0xff ) ;
  117. }
  118. return(GraphicMode); // return the graphic mode
  119. }
  120. /***************************************************************************
  121. * Install_Vesa -- Initializes the vesa driver if it exists *
  122. * *
  123. * INPUT: none *
  124. * *
  125. * OUTPUT: return -1 if error/VESA not supported. *
  126. * *
  127. * WARNINGS: This function will not work unless a vesa compatable driver *
  128. * is installed in either hardware or software. *
  129. * *
  130. * HISTORY: *
  131. * 11/21/1994 PWG : Created. *
  132. *=========================================================================*/
  133. PRIVATE long Install_Vesa(void)
  134. {
  135. UINT paras;
  136. USHORT longest ;
  137. union REGS regs;
  138. struct SREGS sregs;
  139. /* Calculate size of VesaInfo structure in paragraphs */
  140. paras = ( sizeof(VesaInfoType) + 15 ) >> 4 ;
  141. /* Allocate real-mode memory for VESA structure. */
  142. if ( DPMI_real_alloc ( paras , & rpVInfoSel , & longest ) ) return - 1 ;
  143. rpVInfo = ( void * ) ( rpVInfoSel . seg << 4 ) ;
  144. /* Calculate size of VesaModeInfo structure in paragraphs */
  145. paras = ( sizeof(VesaModeInfoType) + 15 ) >> 4 ;
  146. /* Allocate real-mode memory for VESA structure. */
  147. if ( DPMI_real_alloc ( paras , & rpModeInfoSel , & longest ) )
  148. {
  149. Remove_Vesa();
  150. return (-1);
  151. }
  152. rpModeInfo = ( void * ) ( rpModeInfoSel . seg << 4 ) ;
  153. /* Clear the input buffer */
  154. memset ( rpVInfo , 0 , sizeof ( VesaInfoType) ) ;
  155. /* Read Vesa information */
  156. regs . x . eax = 0x4f00 ;
  157. regs . x . edi = 0 ;
  158. sregs . es = rpVInfoSel . seg ;
  159. DPMI_real_intr ( 0x10 , & regs , & sregs );
  160. regs . x . eax &= 0xffff ;
  161. if ( regs . x . eax != 0x004F) return (-1);
  162. Mem_Copy ( rpVInfo , & VInfo , sizeof(VesaInfoType)) ;
  163. return 0;
  164. }
  165. /***************************************************************************
  166. * VESA_GET_MODE_INFO -- Gets info about specified video mode *
  167. * *
  168. * INPUT: long - the mode we are requesting info about *
  169. * *
  170. * OUTPUT: long - 0 if sucessful, -1 if failure *
  171. * *
  172. * HISTORY: *
  173. * 11/21/1994 PWG : Created. *
  174. *=========================================================================*/
  175. PRIVATE long Vesa_Get_Mode_Info(long mode)
  176. {
  177. union REGS regs;
  178. struct SREGS sregs;
  179. if (rpModeInfo )
  180. {
  181. /* Clear the input buffer */
  182. memset ( rpModeInfo, 0, sizeof(VesaModeInfoType));
  183. /* Set up function call */
  184. regs . x . eax = 0x4F01;
  185. regs . x . ecx = mode;
  186. regs . x . edi = 0 ;
  187. sregs . es = rpModeInfoSel . seg ;
  188. DPMI_real_intr ( 0x10 , & regs , & sregs );
  189. regs . x . eax &= 0xffff ;
  190. if ( regs . x . eax == 0x004F)
  191. {
  192. Mem_Copy ( rpModeInfo , &ModeInfo , sizeof(VesaModeInfoType));
  193. // this part is only temporary until Phil get the documentation
  194. // for DPMI funtion 0x301 simulate real call
  195. // in the mean time we will be making call to the vesa driver
  196. // thru a real interrupt
  197. if ( Vesa_Hook ( ModeInfo . WinFunc ) ) return ( -1 ) ;
  198. return (0);
  199. }
  200. }
  201. return (-1);
  202. }
  203. /***************************************************************************
  204. * VESA_SET_MODE -- Sets the specified Vesa mode *
  205. * *
  206. * INPUT: long - the mode we wish to set *
  207. * *
  208. * OUTPUT: long - 0 if all is ok, -1 if we cannot set this mode *
  209. * *
  210. * WARNINGS: You must call Install_Vesa before calling Vesa_Set_Mode *
  211. * *
  212. * HISTORY: *
  213. * 11/21/1994 PWG : Created. *
  214. *=========================================================================*/
  215. PRIVATE long Vesa_Set_Mode(long mode)
  216. {
  217. union REGS regs;
  218. struct SREGS sregs;
  219. /* Get mode info */
  220. if ( Vesa_Get_Mode_Info(mode) ) return (-1) ;
  221. if ((ModeInfo.Attributes & 0x01) == 0) return (-1);
  222. /* Set vesa VIDEO MODE */
  223. regs . x . eax = 0x4F02; //
  224. regs . x . ebx = mode;
  225. int386 ( 0x10 , & regs , & regs ) ;
  226. // delay ( 1000 ) ;
  227. if ( VInfo . Capabilities & 1 )
  228. {
  229. /* Set DAC to 6 bit per color register */
  230. regs . x . eax = 0x4F08;
  231. regs . h . bl = 0;
  232. regs . h . bh = 6 ;
  233. int386 ( 0x10 , & regs , & regs ) ;
  234. // delay ( 1000 ) ;
  235. }
  236. regs . x . eax &= 0xffff ;
  237. if ( regs . x . eax != 0x004F) return (-1);
  238. Init_Bank_Table();
  239. return (0);
  240. }
  241. /***************************************************************************
  242. * VESA_XRES -- Returns horizontal resolution of vesa mode *
  243. * *
  244. * INPUT: none *
  245. * *
  246. * OUTPUT: long - the horizontal resolution of vesa mode *
  247. * *
  248. * WARNINGS: You must call Install_Vesa and Vesa_Set_Mode before calling *
  249. * Vesa_XRes(). *
  250. * *
  251. * HISTORY: *
  252. * 11/21/1994 PWG : Created. *
  253. *=========================================================================*/
  254. long Vesa_XRes(void)
  255. {
  256. return ((long)ModeInfo.XRes);
  257. }
  258. /***************************************************************************
  259. * VESA_YRES -- Returns vertical resolution of a vesa mode *
  260. * *
  261. * INPUT: none *
  262. * *
  263. * OUTPUT: long - the horizontal resolution of vesa mode *
  264. * *
  265. * WARNINGS: You must call Install_Vesa and Vesa_Set_Mode before calling *
  266. * Vesa_XRes(). *
  267. * *
  268. * HISTORY: *
  269. * 11/21/1994 PWG : Created. *
  270. *=========================================================================*/
  271. long Vesa_YRes(void)
  272. {
  273. return ((long)ModeInfo.YRes);
  274. }
  275. /***************************************************************************
  276. * INIT_BANK_TABLE -- Initializes the values in the bank table *
  277. * *
  278. * INPUT: none *
  279. * *
  280. * OUTPUT: none *
  281. * *
  282. * HISTORY: *
  283. * 12/02/1994 PWG : Created. *
  284. *=========================================================================*/
  285. PRIVATE void Init_Bank_Table(void)
  286. {
  287. long size,bankval;
  288. int num_banks,lp;
  289. union REGS regs;
  290. struct SREGS sregs;
  291. size = Vesa_XRes() * Vesa_YRes(); // get video mode size
  292. num_banks = size / 65536; // get number of banks
  293. if (size % 65536) // adjust number of banks if
  294. num_banks++; // they dont break evenly
  295. bankval = 64 / ModeInfo.WinGranularity;
  296. VesaFunc = ModeInfo.WinFunc;
  297. for (lp = 0; lp < num_banks; lp++)
  298. BankTable[lp] = lp * bankval;
  299. regs . x . eax = 0x4F05; // Reset Vesa to Point to Bank 0
  300. regs . x . ebx = 0x0000;
  301. regs . x . edx = 0x0000;
  302. int386 ( 0x10 , & regs , & regs ) ;
  303. }
  304. /***************************************************************************
  305. * SET_MODE -- Used to set a graphic mode *
  306. * *
  307. * INPUT: int - the mode that we are setting *
  308. * *
  309. * OUTPUT: int - FALSE if failure, TRUE otherwise *
  310. * *
  311. * HISTORY: *
  312. * 11/21/1994 PWG : Created. *
  313. *=========================================================================*/
  314. int Set_Video_Mode(int mode)
  315. {
  316. union REGS inregs,outregs;
  317. static first_time = 0 ;
  318. int oldmode ;
  319. /*======================================================================*/
  320. /* If this is the first time we have set the mode we need to store */
  321. /* of the original mode. */
  322. /*======================================================================*/
  323. if ( ! first_time ) {
  324. first_time = 1 ;
  325. Set_Original_Video_Mode(Get_Video_Mode());
  326. }
  327. /*======================================================================*/
  328. /* If the mode we are trying to set is mode zero than we are actually */
  329. /* trying to restore the system to its original video mode. */
  330. /*======================================================================*/
  331. if (mode == RESET_MODE)
  332. mode = Get_Original_Video_Mode(); // set mode properly
  333. if (mode == GraphicMode) // if mode already correct
  334. return(TRUE); // get out of here
  335. oldmode = GraphicMode ;
  336. GraphicMode = mode ;
  337. /**********************************************************************/
  338. /* make sure the mouse is term off before any change */
  339. /*********************************************************************/
  340. if ( MInstalled == TRUE ) Hide_Mouse () ;
  341. /* clear color palette */
  342. memset ( CurrentPalette , 255 , sizeof ( CurrentPalette ) ) ;
  343. memset ( PaletteTable , 0 , sizeof ( PaletteTable ) ) ;
  344. /*======================================================================*/
  345. /* If we are currently in a vesa mode, free it up so that we can do it */
  346. /* again. */
  347. /*======================================================================*/
  348. if ((oldmode >= VESA_MIN) && (oldmode <= VESA_MAX))
  349. Remove_Vesa();
  350. /*======================================================================*/
  351. /* If we are requesting a vesa mode, than use the vesa calls to handle */
  352. /* it. */
  353. /*======================================================================*/
  354. if ( GraphicMode >= VESA_MIN && GraphicMode <= VESA_MAX)
  355. {
  356. inregs . x . eax = MCGA_MODE;
  357. int386 ( 0x10 , &inregs , &outregs);
  358. // delay ( 1000 ) ;
  359. if ( Install_Vesa () != 0 ) {
  360. Set_Video_Mode(oldmode);
  361. return(FALSE);
  362. }
  363. if (Vesa_Set_Mode(GraphicMode) != 0)
  364. {
  365. Set_Video_Mode(oldmode);
  366. return(FALSE);
  367. }
  368. XRes = Vesa_XRes();
  369. YRes = Vesa_YRes();
  370. Set_HiRes_Function_Pointers();
  371. }
  372. else
  373. {
  374. /*===================================================================*/
  375. /* If not a vesa mode, then handle that as well. */
  376. /*===================================================================*/
  377. inregs . x . eax = GraphicMode ;
  378. int386( 0x10, &inregs, &outregs);
  379. // delay ( 1000 ) ;
  380. if ( GraphicMode == MCGA_MODE ) {
  381. XRes = 320;
  382. YRes = 200;
  383. Set_LoRes_Function_Pointers();
  384. }
  385. }
  386. if ( MInstalled == TRUE ) {
  387. Reset_Mouse () ;
  388. Show_Mouse () ;
  389. }
  390. return(TRUE);
  391. }
  392. /***************************************************************************
  393. * VESA_INFO -- Debug routine which displays vesa info to stdout *
  394. * *
  395. * INPUT: none *
  396. * *
  397. * OUTPUT: none *
  398. * *
  399. * WARNINGS: Must call Install_Vesa before attempting to get the vesa *
  400. * info. *
  401. * *
  402. * HISTORY: *
  403. * 11/22/1994 PWG : Created. *
  404. *=========================================================================*/
  405. void Vesa_Info(void)
  406. {
  407. cout << "Attributes: " << (long)ModeInfo.Attributes << "\n"
  408. << "Win A Attributes: " << (long)ModeInfo.WinA_Attributes << "\n"
  409. << "Win B Attributes: " << (long)ModeInfo.WinB_Attributes << "\n"
  410. << "Win Granularity " << (long)ModeInfo.WinGranularity << "\n"
  411. << "Win Size: " << (long)ModeInfo.WinSize << "\n"
  412. << "Win A Segment: " << hex << (unsigned short)ModeInfo.WinA_Segment << "\n"
  413. << "Win B Segment: " << (unsigned short)ModeInfo.WinB_Segment << "\n"
  414. << "Bytes per scan line: " << dec << (unsigned short)ModeInfo.BytesPerScanline << "\n"
  415. << "X resolution: " << (long)ModeInfo.XRes << "\n"
  416. << "Y resolution: " << (long)ModeInfo.YRes << "\n"
  417. << "X Char Size: " << (long)ModeInfo.XCharSize << "\n"
  418. << "Y Char Size: " << (long)ModeInfo.YCharSize << "\n"
  419. << "Number of planes: " << (long)ModeInfo.NumPlanes << "\n"
  420. << "Bits per pixels: " << (long)ModeInfo.BitsPerPixel << "\n"
  421. << "Number of Banks: " << (long)ModeInfo.NumBanks << "\n"
  422. << "Memory Model: " << (long)ModeInfo.MemoryModel << "\n"
  423. << "Bank Size: " << (long)ModeInfo.BankSize << "\n";
  424. }
  425. /***************************************************************************
  426. * VESA_SET_WINDOW -- Sets given vesa window to given grain *
  427. * *
  428. * INPUT: int window - 0 for window A, 1 for window B *
  429. * int grain - the granularity point for window *
  430. * *
  431. * OUTPUT: none *
  432. * *
  433. * HISTORY: *
  434. * 12/05/1994 PWG : Created. *
  435. *=========================================================================*/
  436. void Vesa_Set_Window(long grain_num)
  437. {
  438. union REGS regs;
  439. struct SREGS sregs;
  440. regs . x . eax = 0x4f05 ;
  441. regs . x . ebx = 0 ;
  442. regs . x . edx = grain_num;
  443. // DPMI_real_call ( ModeInfo.WinFunc , & regs , & sregs ) ;
  444. DPMI_real_intr ( VesaFunc , & regs , & sregs ) ;
  445. }
  446. /***************************************************************************
  447. * SET_LORES_FUNCTION_POINTERS -- Sets up the lowres function pointers *
  448. * *
  449. * INPUT: *
  450. * *
  451. * OUTPUT: *
  452. * *
  453. * WARNINGS: *
  454. * *
  455. * HISTORY: *
  456. * 01/12/1995 PWG : Created. *
  457. *=========================================================================*/
  458. PRIVATE VOID Set_LoRes_Function_Pointers(VOID)
  459. {
  460. VVPC_Clear_Func = MCGA_Clear;
  461. VVPC_To_Buffer_Func = MCGA_To_Buffer;
  462. VVPC_Put_Pixel_Func = MCGA_Put_Pixel;
  463. VVPC_Get_Pixel_Func = MCGA_Get_Pixel;
  464. GVPC_Blit_to_VVPC_Func = Linear_Blit_To_Linear;
  465. VVPC_Blit_to_GVPC_Func = Linear_Blit_To_Linear;
  466. VVPC_Blit_to_VVPC_Func = Linear_Blit_To_Linear;
  467. VVPC_Buffer_To_Page = MCGA_Buffer_To_Page;
  468. GVPC_Scale_To_VVPC = Linear_Scale_To_Linear;
  469. VVPC_Scale_To_GVPC = Linear_Scale_To_Linear;
  470. VVPC_Scale_To_VVPC = Linear_Scale_To_Linear;
  471. VVPC_Print_Func = MCGA_Print;
  472. }
  473. /***************************************************************************
  474. * SET_HIRES_FUNCTION_POINTERS -- Sets the HiRes function pointers *
  475. * *
  476. * INPUT: *
  477. * *
  478. * OUTPUT: *
  479. * *
  480. * WARNINGS: *
  481. * *
  482. * HISTORY: *
  483. * 01/12/1995 PWG : Created. *
  484. *=========================================================================*/
  485. PRIVATE VOID Set_HiRes_Function_Pointers(VOID)
  486. {
  487. VVPC_Clear_Func = Vesa_Clear;
  488. VVPC_To_Buffer_Func = Vesa_To_Buffer;
  489. VVPC_Put_Pixel_Func = Vesa_Put_Pixel;
  490. VVPC_Get_Pixel_Func = Vesa_Get_Pixel;
  491. GVPC_Blit_to_VVPC_Func = Linear_Blit_To_Vesa;
  492. VVPC_Blit_to_GVPC_Func = Vesa_Blit_To_Linear;
  493. VVPC_Blit_to_VVPC_Func = Vesa_Blit_To_Vesa;
  494. VVPC_Buffer_To_Page = Vesa_Buffer_To_Page;
  495. GVPC_Scale_To_VVPC = Linear_Scale_To_Vesa;
  496. VVPC_Scale_To_GVPC = Vesa_Scale_To_Linear;
  497. VVPC_Scale_To_VVPC = Vesa_Scale_To_Vesa;
  498. VVPC_Print_Func = Vesa_Print;
  499. }
  500. /***************************************************************************
  501. * Update_Video_Mode -- used to reprogram the current graphic mode afte *
  502. * a task swicthing from windows *
  503. * *
  504. * INPUT: *
  505. * *
  506. * OUTPUT: *
  507. * *
  508. * HISTORY: *
  509. * 03/18/94 JRJ : Created. *
  510. *=========================================================================*/
  511. void Update_Video_Mode (void)
  512. {
  513. union REGS inregs,outregs;
  514. /* clear color palette */
  515. memset ( CurrentPalette , 255 , sizeof ( CurrentPalette ) ) ;
  516. memset ( PaletteTable , 0 , sizeof ( PaletteTable ) ) ;
  517. /**********************************************************************/
  518. /* make sure the mouse is term off before any change */
  519. /*********************************************************************/
  520. if ( MInstalled == TRUE )
  521. Hide_Mouse () ;
  522. /*======================================================================*/
  523. /* If we are requesting a vesa mode, than use the vesa calls to handle */
  524. /* it. */
  525. /*======================================================================*/
  526. if ( GraphicMode >= VESA_MIN && GraphicMode <= VESA_MAX) {
  527. inregs . x . eax = MCGA_MODE;
  528. int386 ( 0x10 , &inregs , &outregs);
  529. Vesa_Set_Mode(GraphicMode);
  530. }
  531. else {
  532. /*===================================================================*/
  533. /* If not a vesa mode, then handle that as well. */
  534. /*===================================================================*/
  535. inregs . x . eax = GraphicMode ;
  536. int386( 0x10, &inregs, &outregs);
  537. }
  538. if ( MInstalled == TRUE ) {
  539. Reset_Mouse () ;
  540. Show_Mouse () ;
  541. }
  542. }
  543. /***************************************************************************
  544. * SET_ORIGINAL_VIDEO_MODE -- sets mode to restore system to on exit *
  545. * *
  546. * INPUT: int video mode number *
  547. * *
  548. * OUTPUT: none *
  549. * *
  550. * HISTORY: *
  551. * 06/29/1995 PWG : Created. *
  552. *=========================================================================*/
  553. void Set_Original_Video_Mode(int mode)
  554. {
  555. _OriginalVideoMode = mode;
  556. }
  557. /***************************************************************************
  558. * GET_ORIGINAL_VIDEO_MODE -- Gets the original video mode value *
  559. * *
  560. * INPUT: none *
  561. * *
  562. * OUTPUT: int the video mode set when we entered *
  563. * *
  564. * HISTORY: *
  565. * 06/29/1995 PWG : Created. *
  566. *=========================================================================*/
  567. int Get_Original_Video_Mode(void)
  568. {
  569. return(_OriginalVideoMode);
  570. }