CnC_Remastered_Collection

Command and Conquer: Red Alert
Log | Files | Refs | README | LICENSE

DDRAW.CPP (51508B)


      1 //
      2 // Copyright 2020 Electronic Arts Inc.
      3 //
      4 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free 
      5 // software: you can redistribute it and/or modify it under the terms of 
      6 // the GNU General Public License as published by the Free Software Foundation, 
      7 // either version 3 of the License, or (at your option) any later version.
      8 
      9 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed 
     10 // in the hope that it will be useful, but with permitted additional restrictions 
     11 // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT 
     12 // distributed with this program. You should have received a copy of the 
     13 // GNU General Public License along with permitted additional restrictions 
     14 // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
     15 
     16 /***************************************************************************
     17  **   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   **
     18  ***************************************************************************
     19  *                                                                         *
     20  *                 Project Name : Westwood Win32 Library                   *
     21  *                                                                         *
     22  *                    File Name : DDRAW.CPP                                *
     23  *                                                                         *
     24  *                   Programmer : Philip W. Gorrow                         *
     25  *                                                                         *
     26  *                   Start Date : October 10, 1995                         *
     27  *                                                                         *
     28  *                  Last Update : October 10, 1995   []                    *
     29  *                                                                         *
     30  *-------------------------------------------------------------------------*
     31  * Functions:                                                              *
     32  * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
     33 
     34 /*=========================================================================*/
     35 /* The following PRIVATE functions are in this file:                       */
     36 /*=========================================================================*/
     37 
     38 
     39 /*= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
     40 
     41 
     42 #include "misc.h"
     43 #include <gbuffer.h>
     44 #include <palette.h>
     45 #include "stdio.h"
     46 
     47 LPDIRECTDRAW		DirectDrawObject=NULL;	// Pointer to the direct draw object
     48 LPDIRECTDRAW2	DirectDraw2Interface = NULL;  	// Pointer to direct draw 2 interface
     49 
     50 HWND			MainWindow;					// Handle to programs main window
     51 												// this is passed to SetCooperativeLevel
     52 												// so DirectDraw knows which window is ours
     53 
     54 
     55 PALETTEENTRY				PaletteEntries[256];		// 256 windows palette entries
     56 LPDIRECTDRAWPALETTE	PalettePtr;					// Pointer to direct draw palette object
     57 BOOL						FirstPaletteSet=FALSE;	// Is this the first time 'Set_Palette' has been called?
     58 LPDIRECTDRAWSURFACE	PaletteSurface=NULL;
     59 SurfaceMonitorClass	AllSurfaces;				//List of all direct draw surfaces
     60 BOOL						CanVblankSync = TRUE;
     61 
     62 BOOL						SystemToVideoBlits =FALSE;	// Does hardware support system mem to video mem blits?
     63 BOOL						VideoToSystemBlits =FALSE;	// Does hardware support video mem to system mem blits?
     64 BOOL						SystemToSystemBlits = FALSE; 	// Does hardware support system mem to system mem blits?
     65 BOOL						OverlappedVideoBlits = TRUE;	// Can video driver blit overlapped regions?
     66 
     67 /*
     68 ** Function to call if we detect focus loss
     69 */
     70 extern	void (*Misc_Focus_Loss_Function)(void) = NULL;
     71 extern	void (*Misc_Focus_Restore_Function)(void) = NULL;
     72 
     73 
     74 /***********************************************************************************************
     75  * Process_DD_Result -- Does a message box based on the result of a DD command                 *
     76  *                                                                                             *
     77  * INPUT:		HRESULT result				- the result returned from the direct draw command		  *
     78  *             int     display_ok_msg	- should a message be displayed if command ok			  *                                                                                      *
     79  *                                                                                             *
     80  * OUTPUT:		none																									  *
     81  *                                                                                             *
     82  * HISTORY:                                                                                    *
     83  *   09/27/1995 PWG : Created.                                                                 *
     84  *=============================================================================================*/
     85 void Process_DD_Result(HRESULT result, int display_ok_msg)
     86 {
     87 	switch (result) {
     88 		case DD_OK:
     89 			if (display_ok_msg) {
     90 				MessageBox(MainWindow, "Direct Draw request went ok.", "Note", MB_ICONEXCLAMATION|MB_OK);
     91          }
     92 			break;
     93 		case DDERR_ALREADYINITIALIZED:
     94 			MessageBox(MainWindow, "This object is already initialized ","Note", MB_ICONEXCLAMATION|MB_OK);
     95 			break;
     96 		case DDERR_BLTFASTCANTCLIP:
     97 			MessageBox(MainWindow, "Return if a clipper object is attached to the source surface passed into a BltFast call.","Note", MB_ICONEXCLAMATION|MB_OK);
     98 			break;
     99 		case DDERR_CANNOTATTACHSURFACE:
    100 			MessageBox(MainWindow, "This surface can not be attached to the requested surface.	","Note", MB_ICONEXCLAMATION|MB_OK);
    101 			break;
    102 		case DDERR_CANNOTDETACHSURFACE:
    103 			MessageBox(MainWindow, "This surface can not be detached from the requested surface.	","Note", MB_ICONEXCLAMATION|MB_OK);
    104 			break;
    105 		case DDERR_CANTCREATEDC:
    106 			MessageBox(MainWindow, "Windows can not create any more DCs","Note", MB_ICONEXCLAMATION|MB_OK);
    107 			break;
    108 		case DDERR_CANTDUPLICATE:
    109 			MessageBox(MainWindow, "Can't duplicate primary & 3D surfaces, or surfaces that are implicitly created.","Note", MB_ICONEXCLAMATION|MB_OK);
    110 			break;
    111 		case DDERR_CANTLOCKSURFACE:
    112 			MessageBox(MainWindow, "Unable to lock surface because no driver exists which can supply a pointer to the surface.","Note", MB_ICONEXCLAMATION|MB_OK);
    113 			break;
    114 		case DDERR_CLIPPERISUSINGHWND:
    115 			MessageBox(MainWindow, "An attempt was made to set a cliplist for a clipper object that is already monitoring an hwnd.","Note", MB_ICONEXCLAMATION|MB_OK);
    116 			break;
    117 		case DDERR_COLORKEYNOTSET:
    118 			MessageBox(MainWindow, "No src color key specified for this operation.","Note", MB_ICONEXCLAMATION|MB_OK);
    119 			break;
    120 		case DDERR_CURRENTLYNOTAVAIL:
    121 			MessageBox(MainWindow, "Support is currently not available.	","Note", MB_ICONEXCLAMATION|MB_OK);
    122 			break;
    123 		case DDERR_DIRECTDRAWALREADYCREATED:
    124 			MessageBox(MainWindow, "A DirectDraw object representing this driver has already been created for this process.	","Note", MB_ICONEXCLAMATION|MB_OK);
    125 			break;
    126 		case DDERR_EXCEPTION:
    127 			MessageBox(MainWindow, "An exception was encountered while performing the requested operation.	","Note", MB_ICONEXCLAMATION|MB_OK);
    128 			break;
    129 		case DDERR_EXCLUSIVEMODEALREADYSET:
    130 			MessageBox(MainWindow, "An attempt was made to set the cooperative level when it was already set to exclusive.","Note", MB_ICONEXCLAMATION|MB_OK);
    131 			break;
    132 		case DDERR_GENERIC:
    133 			MessageBox(MainWindow, "Generic failure.","Note", MB_ICONEXCLAMATION|MB_OK);
    134 			break;
    135 		case DDERR_HEIGHTALIGN:
    136 			MessageBox(MainWindow, "Height of rectangle provided is not a multiple of reqd alignment.","Note", MB_ICONEXCLAMATION|MB_OK);
    137 			break;
    138 		case DDERR_HWNDALREADYSET:
    139 			MessageBox(MainWindow, "The CooperativeLevel HWND has already been set. It can not be reset while the process has surfaces or palettes created.","Note", MB_ICONEXCLAMATION|MB_OK);
    140 			break;
    141 		case DDERR_HWNDSUBCLASSED:
    142 			MessageBox(MainWindow, "HWND used by DirectDraw CooperativeLevel has been subclassed, this prevents DirectDraw from restoring state.","Note", MB_ICONEXCLAMATION|MB_OK);
    143 			break;
    144 		case DDERR_IMPLICITLYCREATED:
    145 			MessageBox(MainWindow, "This surface can not be restored because it is an implicitly created surface.","Note", MB_ICONEXCLAMATION|MB_OK);
    146 			break;
    147 		case DDERR_INCOMPATIBLEPRIMARY:
    148 			MessageBox(MainWindow, "Unable to match primary surface creation request with existing primary surface.","Note", MB_ICONEXCLAMATION|MB_OK);
    149 			break;
    150 		case DDERR_INVALIDCAPS:
    151 			MessageBox(MainWindow, "One or more of the caps bits passed to the callback are incorrect.","Note", MB_ICONEXCLAMATION|MB_OK);
    152 			break;
    153 		case DDERR_INVALIDCLIPLIST:
    154 			MessageBox(MainWindow, "DirectDraw does not support the provided cliplist.","Note", MB_ICONEXCLAMATION|MB_OK);
    155 			break;
    156 		case DDERR_INVALIDDIRECTDRAWGUID:
    157 			MessageBox(MainWindow, "The GUID passed to DirectDrawCreate is not a valid DirectDraw driver identifier.","Note", MB_ICONEXCLAMATION|MB_OK);
    158 			break;
    159 		case DDERR_INVALIDMODE:
    160 			MessageBox(MainWindow, "DirectDraw does not support the requested mode.","Note", MB_ICONEXCLAMATION|MB_OK);
    161 			break;
    162 		case DDERR_INVALIDOBJECT:
    163 			MessageBox(MainWindow, "DirectDraw received a pointer that was an invalid DIRECTDRAW object.","Note", MB_ICONEXCLAMATION|MB_OK);
    164 			break;
    165 		case DDERR_INVALIDPARAMS:
    166 			MessageBox(MainWindow, "One or more of the parameters passed to the function are incorrect.","Note", MB_ICONEXCLAMATION|MB_OK);
    167 			break;
    168 		case DDERR_INVALIDPIXELFORMAT:
    169 			MessageBox(MainWindow, "The pixel format was invalid as specified.","Note", MB_ICONEXCLAMATION|MB_OK);
    170 			break;
    171 		case DDERR_INVALIDPOSITION:
    172 			MessageBox(MainWindow, "Returned when the position of the overlay on the destination is no longer legal for that destination.","Note", MB_ICONEXCLAMATION|MB_OK);
    173 			break;
    174 		case DDERR_INVALIDRECT:
    175 			MessageBox(MainWindow, "Rectangle provided was invalid.","Note", MB_ICONEXCLAMATION|MB_OK);
    176 			break;
    177 
    178 		case DDERR_INVALIDSURFACETYPE:
    179 			MessageBox(MainWindow, "The requested action could not be performed because the surface was of the wrong type.","Note", MB_ICONEXCLAMATION|MB_OK);
    180 			break;
    181 		case DDERR_LOCKEDSURFACES:
    182 			MessageBox(MainWindow, "Operation could not be carried out because one or more surfaces are locked.","Note", MB_ICONEXCLAMATION|MB_OK);
    183 			break;
    184 		case DDERR_NO3D:
    185 			MessageBox(MainWindow, "There is no 3D present.","Note", MB_ICONEXCLAMATION|MB_OK);
    186 			break;
    187 		case DDERR_NOALPHAHW:
    188 			MessageBox(MainWindow, "Operation could not be carried out because there is no alpha accleration hardware present or available.","Note", MB_ICONEXCLAMATION|MB_OK);
    189 			break;
    190 #if(0)
    191 		case DDERR_NOANTITEARHW:
    192 			MessageBox(MainWindow, "Operation could not be carried out because there is no hardware support for synchronizing blts to avoid tearing.	","Note", MB_ICONEXCLAMATION|MB_OK);
    193 			break;
    194 #endif
    195 		case DDERR_NOBLTHW:
    196 			MessageBox(MainWindow, "No blter hardware present.","Note", MB_ICONEXCLAMATION|MB_OK);
    197 			break;
    198 #if(0)
    199 		case DDERR_NOBLTQUEUEHW:
    200 			MessageBox(MainWindow, "Operation could not be carried out because there is no hardware support for asynchronous blting.	","Note", MB_ICONEXCLAMATION|MB_OK);
    201 			break;
    202 #endif
    203 		case DDERR_NOCLIPLIST:
    204 			MessageBox(MainWindow, "No cliplist available.","Note", MB_ICONEXCLAMATION|MB_OK);
    205 			break;
    206 		case DDERR_NOCLIPPERATTACHED:
    207 			MessageBox(MainWindow, "No clipper object attached to surface object.","Note", MB_ICONEXCLAMATION|MB_OK);
    208 			break;
    209 		case DDERR_NOCOLORCONVHW:
    210 			MessageBox(MainWindow, "Operation could not be carried out because there is no color conversion hardware present or available.","Note", MB_ICONEXCLAMATION|MB_OK);
    211 			break;
    212 		case DDERR_NOCOLORKEY:
    213 			MessageBox(MainWindow, "Surface doesn't currently have a color key","Note", MB_ICONEXCLAMATION|MB_OK);
    214 			break;
    215 		case DDERR_NOCOLORKEYHW:
    216 			MessageBox(MainWindow, "Operation could not be carried out because there is no hardware support of the destination color key.","Note", MB_ICONEXCLAMATION|MB_OK);
    217 			break;
    218 		case DDERR_NOCOOPERATIVELEVELSET:
    219 			MessageBox(MainWindow, "Create function called without DirectDraw object method SetCooperativeLevel being called.","Note", MB_ICONEXCLAMATION|MB_OK);
    220 			break;
    221 		case DDERR_NODC:
    222 			MessageBox(MainWindow, "No DC was ever created for this surface.","Note", MB_ICONEXCLAMATION|MB_OK);
    223 			break;
    224 		case DDERR_NODDROPSHW:
    225 			MessageBox(MainWindow, "No DirectDraw ROP hardware.","Note", MB_ICONEXCLAMATION|MB_OK);
    226 			break;
    227 		case DDERR_NODIRECTDRAWHW:
    228 			MessageBox(MainWindow, "A hardware-only DirectDraw object creation was attempted but the driver did not support any hardware.","Note", MB_ICONEXCLAMATION|MB_OK);
    229 			break;
    230 		case DDERR_NODIRECTDRAWSUPPORT:
    231 			MessageBox(MainWindow, "No DirectDraw support possible with current display driver.","Note", MB_ICONEXCLAMATION|MB_OK);
    232 			break;
    233 		case DDERR_NOEMULATION:
    234 			MessageBox(MainWindow, "Software emulation not available.","Note", MB_ICONEXCLAMATION|MB_OK);
    235 			break;
    236 		case DDERR_NOEXCLUSIVEMODE:
    237 			MessageBox(MainWindow, "Operation requires the application to have exclusive mode but the application does not have exclusive mode.","Note", MB_ICONEXCLAMATION|MB_OK);
    238 			break;
    239 		case DDERR_NOFLIPHW:
    240 			MessageBox(MainWindow, "Flipping visible surfaces is not supported.","Note", MB_ICONEXCLAMATION|MB_OK);
    241 			break;
    242 		case DDERR_NOGDI:
    243 			MessageBox(MainWindow, "There is no GDI present.","Note", MB_ICONEXCLAMATION|MB_OK);
    244 			break;
    245 		case DDERR_NOHWND:
    246 			MessageBox(MainWindow, "Clipper notification requires an HWND or no HWND has previously been set as the CooperativeLevel HWND.","Note", MB_ICONEXCLAMATION|MB_OK);
    247 			break;
    248 		case DDERR_NOMIRRORHW:
    249 			MessageBox(MainWindow, "Operation could not be carried out because there is no hardware present or available.","Note", MB_ICONEXCLAMATION|MB_OK);
    250 			break;
    251 		case DDERR_NOOVERLAYDEST:
    252 			MessageBox(MainWindow, "Returned when GetOverlayPosition is called on an overlay that UpdateOverlay has never been called on to establish a destination.","Note", MB_ICONEXCLAMATION|MB_OK);
    253 			break;
    254 		case DDERR_NOOVERLAYHW:
    255 			MessageBox(MainWindow, "Operation could not be carried out because there is no overlay hardware present or available.","Note", MB_ICONEXCLAMATION|MB_OK);
    256 			break;
    257 		case DDERR_NOPALETTEATTACHED:
    258 			MessageBox(MainWindow, "No palette object attached to this surface.	","Note", MB_ICONEXCLAMATION|MB_OK);
    259 			break;
    260 		case DDERR_NOPALETTEHW:
    261 			MessageBox(MainWindow, "No hardware support for 16 or 256 color palettes.","Note", MB_ICONEXCLAMATION|MB_OK);
    262 			break;
    263 		case DDERR_NORASTEROPHW:
    264 			MessageBox(MainWindow, "Operation could not be carried out because there is no appropriate raster op hardware present or available.","Note", MB_ICONEXCLAMATION|MB_OK);
    265 			break;
    266 		case DDERR_NOROTATIONHW:
    267 			MessageBox(MainWindow, "Operation could not be carried out because there is no rotation hardware present or available.","Note", MB_ICONEXCLAMATION|MB_OK);
    268 			break;
    269 		case DDERR_NOSTRETCHHW:
    270 			MessageBox(MainWindow, "Operation could not be carried out because there is no hardware support for stretching.","Note", MB_ICONEXCLAMATION|MB_OK);
    271 			break;
    272 		case DDERR_NOT4BITCOLOR:
    273 			MessageBox(MainWindow, "DirectDrawSurface is not in 4 bit color palette and the requested operation requires 4 bit color palette.","Note", MB_ICONEXCLAMATION|MB_OK);
    274 			break;
    275 		case DDERR_NOT4BITCOLORINDEX:
    276 			MessageBox(MainWindow, "DirectDrawSurface is not in 4 bit color index palette and the requested operation requires 4 bit color index palette.","Note", MB_ICONEXCLAMATION|MB_OK);
    277 			break;
    278 		case DDERR_NOT8BITCOLOR:
    279 			MessageBox(MainWindow, "DirectDrawSurface is not in 8 bit color mode and the requested operation requires 8 bit color.","Note", MB_ICONEXCLAMATION|MB_OK);
    280 			break;
    281 		case DDERR_NOTAOVERLAYSURFACE:
    282 			MessageBox(MainWindow, "Returned when an overlay member is called for a non-overlay surface.","Note", MB_ICONEXCLAMATION|MB_OK);
    283 			break;
    284 		case DDERR_NOTEXTUREHW:
    285 			MessageBox(MainWindow, "Operation could not be carried out because there is no texture mapping hardware present or available.","Note", MB_ICONEXCLAMATION|MB_OK);
    286 			break;
    287 		case DDERR_NOTFLIPPABLE:
    288 			MessageBox(MainWindow, "An attempt has been made to flip a surface that is not flippable.","Note", MB_ICONEXCLAMATION|MB_OK);
    289 			break;
    290 		case DDERR_NOTFOUND:
    291 			MessageBox(MainWindow, "Requested item was not found.","Note", MB_ICONEXCLAMATION|MB_OK);
    292 			break;
    293 		case DDERR_NOTLOCKED:
    294 			MessageBox(MainWindow, "Surface was not locked.  An attempt to unlock a surface that was not locked at all, or by this process, has been attempted.","Note", MB_ICONEXCLAMATION|MB_OK);
    295 			break;
    296 		case DDERR_NOTPALETTIZED:
    297 			MessageBox(MainWindow, "The surface being used is not a palette-based surface.","Note", MB_ICONEXCLAMATION|MB_OK);
    298 			break;
    299 		case DDERR_NOVSYNCHW:
    300 			MessageBox(MainWindow, "Operation could not be carried out because there is no hardware support for vertical blank synchronized operations.","Note", MB_ICONEXCLAMATION|MB_OK);
    301 			break;
    302 		case DDERR_NOZBUFFERHW:
    303 			MessageBox(MainWindow, "Operation could not be carried out because there is no hardware support for zbuffer blting.","Note", MB_ICONEXCLAMATION|MB_OK);
    304 			break;
    305 		case DDERR_NOZOVERLAYHW:
    306 			MessageBox(MainWindow, "Overlay surfaces could not be z layered based on their BltOrder because the hardware does not support z layering of overlays.","Note", MB_ICONEXCLAMATION|MB_OK);
    307 			break;
    308 		case DDERR_OUTOFCAPS:
    309 			MessageBox(MainWindow, "The hardware needed for the requested operation has already been allocated.","Note", MB_ICONEXCLAMATION|MB_OK);
    310 			break;
    311 		case DDERR_OUTOFMEMORY:
    312 			MessageBox(MainWindow, "DirectDraw does not have enough memory to perform the operation.","Note", MB_ICONEXCLAMATION|MB_OK);
    313 			break;
    314 		case DDERR_OUTOFVIDEOMEMORY:
    315 			MessageBox(MainWindow, "DirectDraw does not have enough memory to perform the operation.","Note", MB_ICONEXCLAMATION|MB_OK);
    316 			break;
    317 		case DDERR_OVERLAYCANTCLIP:
    318 			MessageBox(MainWindow, "The hardware does not support clipped overlays.","Note", MB_ICONEXCLAMATION|MB_OK);
    319 			break;
    320 		case DDERR_OVERLAYCOLORKEYONLYONEACTIVE:
    321 			MessageBox(MainWindow, "Can only have ony color key active at one time for overlays.","Note", MB_ICONEXCLAMATION|MB_OK);
    322 			break;
    323 		case DDERR_OVERLAYNOTVISIBLE:
    324 			MessageBox(MainWindow, "Returned when GetOverlayPosition is called on a hidden overlay.","Note", MB_ICONEXCLAMATION|MB_OK);
    325 			break;
    326 		case DDERR_PALETTEBUSY:
    327 			MessageBox(MainWindow, "Access to this palette is being refused because the palette is already locked by another thread.","Note", MB_ICONEXCLAMATION|MB_OK);
    328 			break;
    329 		case DDERR_PRIMARYSURFACEALREADYEXISTS:
    330 			MessageBox(MainWindow, "This process already has created a primary surface.","Note", MB_ICONEXCLAMATION|MB_OK);
    331 			break;
    332 		case DDERR_REGIONTOOSMALL:
    333 			MessageBox(MainWindow, "Region passed to Clipper::GetClipList is too small.","Note", MB_ICONEXCLAMATION|MB_OK);
    334 			break;
    335 		case DDERR_SURFACEALREADYATTACHED:
    336 			MessageBox(MainWindow, "This surface is already attached to the surface it is being attached to.","Note", MB_ICONEXCLAMATION|MB_OK);
    337 			break;
    338 		case DDERR_SURFACEALREADYDEPENDENT:
    339 			MessageBox(MainWindow, "This surface is already a dependency of the surface it is being made a dependency of.","Note", MB_ICONEXCLAMATION|MB_OK);
    340 			break;
    341 		case DDERR_SURFACEBUSY:
    342 			MessageBox(MainWindow, "Access to this surface is being refused because the surface is already locked by another thread.","Note", MB_ICONEXCLAMATION|MB_OK);
    343 			break;
    344 		case DDERR_SURFACEISOBSCURED:
    345 			MessageBox(MainWindow, "Access to surface refused because the surface is obscured.","Note", MB_ICONEXCLAMATION|MB_OK);
    346 			break;
    347 		case DDERR_SURFACELOST:
    348 			MessageBox(MainWindow, "Access to this surface is being refused because the surface memory is gone. The DirectDrawSurface object representing this surface should have Restore called on it.","Note", MB_ICONEXCLAMATION|MB_OK);
    349 			break;
    350 		case DDERR_SURFACENOTATTACHED:
    351 			MessageBox(MainWindow, "The requested surface is not attached.","Note", MB_ICONEXCLAMATION|MB_OK);
    352 			break;
    353 		case DDERR_TOOBIGHEIGHT:
    354 			MessageBox(MainWindow, "Height requested by DirectDraw is too large.","Note", MB_ICONEXCLAMATION|MB_OK);
    355 			break;
    356 		case DDERR_TOOBIGSIZE:
    357 			MessageBox(MainWindow, "Size requested by DirectDraw is too large --	the individual height and width are OK.","Note", MB_ICONEXCLAMATION|MB_OK);
    358 			break;
    359 		case DDERR_TOOBIGWIDTH:
    360 			MessageBox(MainWindow, "Width requested by DirectDraw is too large.","Note", MB_ICONEXCLAMATION|MB_OK);
    361 			break;
    362 		case DDERR_UNSUPPORTED:
    363 			MessageBox(MainWindow, "Action not supported.","Note", MB_ICONEXCLAMATION|MB_OK);
    364 			break;
    365 		case DDERR_UNSUPPORTEDFORMAT:
    366 			MessageBox(MainWindow, "FOURCC format requested is unsupported by DirectDraw.","Note", MB_ICONEXCLAMATION|MB_OK);
    367 			break;
    368 		case DDERR_UNSUPPORTEDMASK:
    369 			MessageBox(MainWindow, "Bitmask in the pixel format requested is unsupported by DirectDraw.","Note", MB_ICONEXCLAMATION|MB_OK);
    370 			break;
    371 		case DDERR_VERTICALBLANKINPROGRESS:
    372 			MessageBox(MainWindow, "Vertical blank is in progress.","Note", MB_ICONEXCLAMATION|MB_OK);
    373 			break;
    374 		case DDERR_WASSTILLDRAWING:
    375 			MessageBox(MainWindow, "Informs DirectDraw that the previous Blt which is transfering information to or from this Surface is incomplete.","Note", MB_ICONEXCLAMATION|MB_OK);
    376 			break;
    377 		case DDERR_WRONGMODE:
    378 			MessageBox(MainWindow, "This surface can not be restored because it was created in a different mode.","Note", MB_ICONEXCLAMATION|MB_OK);
    379 			break;
    380 		case DDERR_XALIGN:
    381 			MessageBox(MainWindow, "Rectangle provided was not horizontally aligned on required boundary.","Note", MB_ICONEXCLAMATION|MB_OK);
    382 			break;
    383 		default:
    384 			char string[256];
    385 			sprintf (string, "Unrecognised Direct Draw result code: %d", result & 0xffff);
    386 			MessageBox(MainWindow, string,"Note", MB_ICONEXCLAMATION|MB_OK);
    387 			break;
    388 	}
    389 }
    390 
    391 
    392 
    393 /***********************************************************************************************
    394  * Check_Overlapped_Blit_Capability -- See if video driver supports blitting overlapped regions*
    395  *                                                                                             *
    396  *  We will check for this by drawing something to a video page and blitting it over itself.   *
    397  * If we end up with the top line repeating then overlapped region blits dont work.            *
    398  *                                                                                             *
    399  * INPUT:    Nothing                                                                           *
    400  *                                                                                             *
    401  * OUTPUT:   Nothing                                                                           *
    402  *                                                                                             *
    403  * WARNINGS: None                                                                              *
    404  *                                                                                             *
    405  * HISTORY:                                                                                    *
    406  *    6/7/96 5:06PM ST : Created                                                               *
    407  *=============================================================================================*/
    408 void Check_Overlapped_Blit_Capability(void)
    409 {
    410 
    411 	/*
    412 	** Assume we can until we find out otherwise
    413 	*/
    414 	OverlappedVideoBlits = TRUE;
    415 
    416 	GraphicBufferClass test_buffer;
    417 
    418 	test_buffer.Init (64, 64, NULL, 0, (GBC_Enum)GBC_VIDEOMEM);
    419 
    420 	test_buffer.Clear();
    421 
    422 	/*
    423 	** Plot a pixel in the top left corner of the buffer.
    424 	*/
    425 	test_buffer.Put_Pixel(0, 0, 255);
    426 
    427 	/*
    428 	** Blit the buffer down by one line. If we end up with a vertical strip of pixel 255's then
    429 	** overlapped blits dont work
    430 	*/
    431 
    432 	test_buffer.Blit(test_buffer, 0, 0, 0, 1, test_buffer.Get_Width(), test_buffer.Get_Height()-1);
    433 
    434 	if (test_buffer.Get_Pixel (0 ,5) == 255) OverlappedVideoBlits = FALSE;
    435 }
    436 
    437 
    438 
    439 /***********************************************************************************************
    440  * Set_Video_Mode -- Initializes Direct Draw and sets the required Video Mode                  *
    441  *                                                                                             *
    442  * INPUT:  		int width   			- the width of the video mode in pixels						  *
    443  *					int height           - the height of the video mode in pixels                   *
    444  *					int bits_per_pixel	- the number of bits per pixel the video mode supports     *
    445  *                                                                                             *
    446  * OUTPUT:     none                                                                            *
    447  *                                                                                             *
    448  * HISTORY:                                                                                    *
    449  *   09/26/1995 PWG : Created.                                                                 *
    450  *=============================================================================================*/
    451 BOOL Set_Video_Mode(HWND hwnd, int w, int h, int bits_per_pixel)
    452 {
    453 // ST - 1/3/2019 10:41AM
    454 	return TRUE;
    455 #if (0)
    456 	HRESULT result;
    457 	//
    458 	// If there is not currently a direct draw object then we need to define one.
    459 	//
    460 	if ( DirectDrawObject == NULL ){
    461 		//MessageBox(MainWindow, "In Set_Video_Mode. About to call DirectDrawCreate.","Note", MB_ICONEXCLAMATION|MB_OK);
    462 		result = DirectDrawCreate(NULL, &DirectDrawObject, NULL);
    463 		Process_DD_Result(result, FALSE);
    464 		if (result == DD_OK){
    465 			if (w==320){
    466 				result = DirectDrawObject->SetCooperativeLevel(hwnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_ALLOWMODEX);
    467 			} else {
    468 				//MessageBox(MainWindow, "In Set_Video_Mode. About to call SetCooperativeLevel.","Note", MB_ICONEXCLAMATION|MB_OK);
    469 				result = DirectDrawObject->SetCooperativeLevel(hwnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
    470 			}
    471 			Process_DD_Result(result, FALSE);
    472 		}else{
    473 			return (FALSE);
    474 		}
    475 	}
    476 
    477 	//
    478 	// Set the required display mode with 8 bits per pixel
    479 	//
    480 	//MessageBox(MainWindow, "In Set_Video_Mode. About to call call SetDisplayMode.","Note", MB_ICONEXCLAMATION|MB_OK);
    481 	result = DirectDrawObject->SetDisplayMode ( w , h , bits_per_pixel );
    482 	if (result != DD_OK){
    483 //		Process_DD_Result(result, FALSE);
    484 		DirectDrawObject->Release();
    485 		DirectDrawObject = NULL;
    486 		return(FALSE);
    487 	}
    488 
    489 	//
    490 	// Create a direct draw palette object
    491 	//
    492 	//MessageBox(MainWindow, "In Set_Video_Mode. About to call CreatePalette.","Note", MB_ICONEXCLAMATION|MB_OK);
    493 	result = DirectDrawObject->CreatePalette( DDPCAPS_8BIT | DDPCAPS_ALLOW256, &PaletteEntries[0] , &PalettePtr ,NULL);
    494 	Process_DD_Result(result, FALSE);
    495 	if (result != DD_OK){
    496 		return (FALSE);
    497 	}
    498 
    499 	Check_Overlapped_Blit_Capability();
    500 
    501 	//MessageBox(MainWindow, "In Set_Video_Mode. About to return success.","Note", MB_ICONEXCLAMATION|MB_OK);
    502 #if (0)
    503 	/*
    504 	** Find out if DirectX 2 extensions are available
    505 	*/
    506 	result = DirectDrawObject->QueryInterface (IID_IDirectDraw2, (LPVOID*)&DirectDraw2Interface);
    507 	SystemToVideoBlits = FALSE;
    508 	VideoToSystemBlits = FALSE;
    509 	SystemToSystemBlits= FALSE;
    510 	if (result != DD_OK){
    511 		DirectDraw2Interface = NULL;
    512 	}else{
    513 		DDCAPS capabilities;
    514 		DDCAPS emulated_capabilities;
    515 
    516 		memset ((char*)&capabilities, 0, sizeof(capabilities));
    517 		memset ((char*)&emulated_capabilities, 0, sizeof(emulated_capabilities));
    518 		capabilities.dwSize = sizeof (capabilities);
    519 		emulated_capabilities.dwSize = sizeof (emulated_capabilities);
    520 
    521 		DirectDrawObject->GetCaps (&capabilities, &emulated_capabilities);
    522 
    523 		if (capabilities.dwCaps & DDCAPS_CANBLTSYSMEM){
    524 			SystemToVideoBlits = (capabilities.dwSVBCaps & DDCAPS_BLT) ? TRUE : FALSE;
    525 			VideoToSystemBlits = (capabilities.dwVSBCaps & DDCAPS_BLT) ? TRUE : FALSE;
    526 			SystemToSystemBlits = (capabilities.dwSSBCaps & DDCAPS_BLT) ? TRUE : FALSE;
    527 		}
    528 	}
    529 #endif	//(0)
    530 
    531 	//MessageBox(MainWindow, "In Set_Video_Mode. About to return success.","Note", MB_ICONEXCLAMATION|MB_OK);
    532 
    533 	return (TRUE);
    534 #endif
    535 }
    536 
    537 /***********************************************************************************************
    538  * Reset_Video_Mode -- Resets video mode and deletes Direct Draw Object                        *
    539  *                                                                                             *
    540  * INPUT:		none                                                                            *
    541  *                                                                                             *
    542  * OUTPUT:     none                                                                            *
    543  *                                                                                             *
    544  * WARNINGS:                                                                                   *
    545  *                                                                                             *
    546  * HISTORY:                                                                                    *
    547  *   09/26/1995 PWG : Created.                                                                 *
    548  *=============================================================================================*/
    549 void Reset_Video_Mode(void)
    550 {
    551 	HRESULT result;
    552 
    553 	//
    554 	// If a direct draw object has been declared and a video mode has been set
    555 	// then reset the video mode and release the direct draw object.
    556 	//
    557 	if ( DirectDrawObject ) {
    558 		result = DirectDrawObject->RestoreDisplayMode();
    559 		Process_DD_Result(result, FALSE);
    560 		result = DirectDrawObject->Release();
    561 		Process_DD_Result(result, FALSE);
    562 
    563 		DirectDrawObject = NULL;
    564 	}
    565 }
    566 
    567 
    568 
    569 
    570 /***********************************************************************************************
    571  * Get_Free_Video_Memory -- returns amount of free video memory                                *
    572  *                                                                                             *
    573  *                                                                                             *
    574  *                                                                                             *
    575  * INPUT:    Nothing                                                                           *
    576  *                                                                                             *
    577  * OUTPUT:   bytes of available video RAM                                                      *
    578  *                                                                                             *
    579  * WARNINGS: None                                                                              *
    580  *                                                                                             *
    581  * HISTORY:                                                                                    *
    582  *    11/29/95 12:52PM ST : Created                                                            *
    583  *=============================================================================================*/
    584 unsigned int Get_Free_Video_Memory(void)
    585 {
    586 
    587 	DDCAPS	video_capabilities;
    588 
    589 	if (DirectDrawObject){
    590 
    591 		video_capabilities.dwSize = sizeof (video_capabilities);
    592 
    593 		//MessageBox(MainWindow, "In Get_Free_Video_Memory. About to call GetCaps","Note", MB_ICONEXCLAMATION|MB_OK);
    594 		if (DD_OK == DirectDrawObject->GetCaps (&video_capabilities , NULL)){
    595 			char string [256];
    596 			sprintf (string, "In Get_Free_Video_Memory. About to return %d bytes",video_capabilities.dwVidMemFree);
    597 			//MessageBox(MainWindow, string,"Note", MB_ICONEXCLAMATION|MB_OK);
    598 			return (video_capabilities.dwVidMemFree);
    599 		}
    600 	}
    601 
    602 	//MessageBox(MainWindow, "In Get_Free_Video_Memory. About to return failure","Note", MB_ICONEXCLAMATION|MB_OK);
    603 	return (0);
    604 }
    605 
    606 
    607 
    608 
    609 /***********************************************************************************************
    610  * Get_Video_Hardware_Caps -- returns bitmask of direct draw video hardware support            *
    611  *                                                                                             *
    612  *                                                                                             *
    613  *                                                                                             *
    614  * INPUT:    Nothing                                                                           *
    615  *                                                                                             *
    616  * OUTPUT:   hardware flags                                                                    *
    617  *                                                                                             *
    618  * WARNINGS: Must call Set_Video_Mode 1st to create the direct draw object                     *
    619  *                                                                                             *
    620  * HISTORY:                                                                                    *
    621  *    1/12/96 9:14AM ST : Created                                                              *
    622  *=============================================================================================*/
    623 unsigned Get_Video_Hardware_Capabilities(void)
    624 {
    625 	DDCAPS	video_capabilities;
    626 	unsigned	video;
    627 
    628 	/*
    629 	** Fail if the direct draw object has not been initialised
    630 	*/
    631 	if (!DirectDrawObject) return (0);
    632 
    633 	/*
    634 	** Get the capabilities of the direct draw object
    635 	*/
    636 	video_capabilities.dwSize = sizeof(video_capabilities);
    637 	//MessageBox(MainWindow, "In Get_Video_Hardware_Capabilities. About to call GetCaps","Note", MB_ICONEXCLAMATION|MB_OK);
    638 	HRESULT result = DirectDrawObject->GetCaps (&video_capabilities, NULL);
    639 	if (result != DD_OK){
    640 		Process_DD_Result(result, FALSE);
    641 		return (0);
    642 	}
    643 
    644 	/*
    645 	** Set flags to indicate the presence of the features we are interested in
    646 	*/
    647 	video = 0;
    648 
    649 	/* Hardware blits supported? */
    650 	if (video_capabilities.dwCaps & DDCAPS_BLT) 				video |= VIDEO_BLITTER;
    651 
    652 	/* Hardware blits asyncronous? */
    653 	if (video_capabilities.dwCaps & DDCAPS_BLTQUEUE) 		video |= VIDEO_BLITTER_ASYNC;
    654 
    655 	/* Can palette changes be synced to vertical refresh? */
    656 	if (video_capabilities.dwCaps & DDCAPS_PALETTEVSYNC) 	video |= VIDEO_SYNC_PALETTE;
    657 
    658 	/* Is the video cards memory bank switched? */
    659 	if (video_capabilities.dwCaps & DDCAPS_BANKSWITCHED) 	video |= VIDEO_BANK_SWITCHED;
    660 
    661 	/* Can the blitter do filled rectangles? */
    662 	if (video_capabilities.dwCaps & DDCAPS_BLTCOLORFILL)	video |= VIDEO_COLOR_FILL;
    663 
    664 	/* Is there no hardware assistance avaailable at all? */
    665 	if (video_capabilities.dwCaps & DDCAPS_NOHARDWARE) 	video |= VIDEO_NO_HARDWARE_ASSIST;
    666 
    667 	//MessageBox(MainWindow, "In Get_Video_Hardware_Capabilities. About to return success.","Note", MB_ICONEXCLAMATION|MB_OK);
    668 	return (video);
    669 }
    670 
    671 
    672 
    673 
    674 /***********************************************************************************************
    675  * Wait_Vert_Blank -- Waits for the start (leading edge) of a vertical blank                   *
    676  *                                                                                             *
    677  * INPUT:                                                                                      *
    678  *                                                                                             *
    679  * OUTPUT:                                                                                     *
    680  *                                                                                             *
    681  * WARNINGS:                                                                                   *
    682  *                                                                                             *
    683  * HISTORY:                                                                                    *
    684  *=============================================================================================*/
    685 extern int ScreenWidth;
    686 void Wait_Vert_Blank(void)
    687 {
    688 	if (DirectDrawObject == NULL) {
    689 		return;
    690 	}
    691 	if( ScreenWidth!=320 && CanVblankSync){
    692 		HRESULT result = DirectDrawObject->WaitForVerticalBlank(DDWAITVB_BLOCKBEGIN, 0);
    693 		if (result == E_NOTIMPL){
    694 			CanVblankSync = FALSE;
    695 			return;
    696 		}
    697 		Process_DD_Result(result, FALSE);
    698 	}
    699 }
    700 
    701 
    702 
    703 
    704 
    705 /***********************************************************************************************
    706  * Set_Palette -- set a direct draw palette                                                    *
    707  *                                                                                             *
    708  *                                                                                             *
    709  *                                                                                             *
    710  * INPUT:    ptr to 768 rgb palette bytes                                                      *
    711  *                                                                                             *
    712  * OUTPUT:   Nothing                                                                           *
    713  *                                                                                             *
    714  * WARNINGS: None                                                                              *
    715  *                                                                                             *
    716  * HISTORY:                                                                                    *
    717  *    10/11/95 3:33PM ST : Created                                                             *
    718  *=============================================================================================*/
    719 void Set_DD_Palette ( void *palette )
    720 {
    721 
    722 	/*
    723 	** Trap null ptr
    724 	*/
    725 	if (!palette) return;
    726 
    727 	int	j;
    728 	int	k;
    729 	char	*palette_get;
    730 
    731 	if ( DirectDrawObject && PaletteSurface ){
    732 
    733 		k=0;
    734 
    735 		palette_get = (char*)palette;
    736 
    737 		for( j=0 ; j<768 ; j+=3 )
    738 		{
    739 			PaletteEntries[k].peRed = (unsigned char)((*palette_get++)<<2);
    740 			PaletteEntries[k].peGreen = (unsigned char)((*palette_get++)<<2);
    741 			PaletteEntries[k].peBlue = (unsigned char)((*palette_get++)<<2);
    742 			k++;
    743 		}
    744 
    745 		if ( !FirstPaletteSet ){
    746 			//MessageBox(MainWindow, "In Set_DD_Palette. About to call SetPalette","Note", MB_ICONEXCLAMATION|MB_OK);
    747 			PaletteSurface->SetPalette( PalettePtr );
    748 			FirstPaletteSet=TRUE;
    749 		}
    750 
    751 		//MessageBox(MainWindow, "In Set_DD_Palette. About to call SetEntries","Note", MB_ICONEXCLAMATION|MB_OK);
    752 		PalettePtr->SetEntries( 0 , 0 , 256 , &PaletteEntries[0] );
    753 	}
    754 	//MessageBox(MainWindow, "Leaving Set_DD_Palette","Note", MB_ICONEXCLAMATION|MB_OK);
    755 
    756 }
    757 
    758 
    759 
    760 
    761 
    762 /***********************************************************************************************
    763  * Wait_Blit -- waits for the DirectDraw blitter to become idle                                *
    764  *                                                                                             *
    765  *                                                                                             *
    766  *                                                                                             *
    767  * INPUT:    Nothing                                                                           *
    768  *                                                                                             *
    769  * OUTPUT:   Nothing                                                                           *
    770  *                                                                                             *
    771  * WARNINGS: None                                                                              *
    772  *                                                                                             *
    773  * HISTORY:                                                                                    *
    774  *   07-25-95 03:53pm ST : Created                                                             *
    775  *=============================================================================================*/
    776 
    777 void Wait_Blit (void)
    778 {
    779 	HRESULT	return_code;
    780 
    781 	do {
    782 		return_code=PaletteSurface->GetBltStatus (DDGBS_ISBLTDONE);
    783 	} while (return_code != DD_OK && return_code != DDERR_SURFACELOST);
    784 
    785 }
    786 
    787 
    788 
    789 /***********************************************************************************************
    790  * SMC::SurfaceMonitorClass -- constructor for surface monitor class                           *
    791  *                                                                                             *
    792  *                                                                                             *
    793  *                                                                                             *
    794  * INPUT:    Nothing                                                                           *
    795  *                                                                                             *
    796  * OUTPUT:   Nothing                                                                           *
    797  *                                                                                             *
    798  * WARNINGS: None                                                                              *
    799  *                                                                                             *
    800  * HISTORY:                                                                                    *
    801  *    11/3/95 3:23PM ST : Created                                                              *
    802  *=============================================================================================*/
    803 
    804 SurfaceMonitorClass::SurfaceMonitorClass(void)
    805 {
    806 	for (int i=0 ; i<MAX_SURFACES ; i++)
    807 	{
    808 		Surface[i]=NULL;
    809 	}
    810 	InFocus=FALSE;
    811 	SurfacesRestored=FALSE;
    812 }
    813 
    814 
    815 /***********************************************************************************************
    816  * SMC::Add_DD_Surface -- add a new surface to the list                                        *
    817  *                                                                                             *
    818  *                                                                                             *
    819  *                                                                                             *
    820  * INPUT:    ptr to surface                                                                    *
    821  *                                                                                             *
    822  * OUTPUT:   Nothing                                                                           *
    823  *                                                                                             *
    824  * WARNINGS: None                                                                              *
    825  *                                                                                             *
    826  * HISTORY:                                                                                    *
    827  *                 11/3/95 3:24PM ST : Created                                                 *
    828  *=============================================================================================*/
    829 void SurfaceMonitorClass::Add_DD_Surface (LPDIRECTDRAWSURFACE new_surface)
    830 {
    831 	if ( !Got_Surface_Already (new_surface) ){
    832 		for (int i=0 ; i<MAX_SURFACES ; i++)
    833 		{
    834 			if ( Surface[i]==NULL ){
    835 				Surface[i]=new_surface;
    836 				return;
    837 			}
    838 		}
    839 	}
    840 }
    841 
    842 
    843 /***********************************************************************************************
    844  * SMC::Remove_DD_Surface -- remove a direct draw surface from the list                        *
    845  *                                                                                             *
    846  *                                                                                             *
    847  *                                                                                             *
    848  * INPUT:    ptr to Surface                                                                    *
    849  *                                                                                             *
    850  * OUTPUT:   Nothing                                                                           *
    851  *                                                                                             *
    852  * WARNINGS: None                                                                              *
    853  *                                                                                             *
    854  * HISTORY:                                                                                    *
    855  *    11/3/95 3:25PM ST : Created                                                              *
    856  *=============================================================================================*/
    857 
    858 void SurfaceMonitorClass::Remove_DD_Surface (LPDIRECTDRAWSURFACE old_surface)
    859 {
    860 	for (int i=0 ; i<MAX_SURFACES ; i++)
    861 	{
    862 		if ( Surface[i]==old_surface ){
    863 			Surface[i]=NULL;
    864 			return;
    865 		}
    866 	}
    867 }
    868 
    869 
    870 /***********************************************************************************************
    871  * SMC::Got_Surface_Already -- check if a surface is already in the list                       *
    872  *                                                                                             *
    873  *                                                                                             *
    874  *                                                                                             *
    875  * INPUT:    ptr to surface                                                                    *
    876  *                                                                                             *
    877  * OUTPUT:   True if surface is in list                                                        *
    878  *                                                                                             *
    879  * WARNINGS: None                                                                              *
    880  *                                                                                             *
    881  * HISTORY:                                                                                    *
    882  *    11/3/95 3:25PM ST : Created                                                              *
    883  *=============================================================================================*/
    884 
    885 BOOL SurfaceMonitorClass::Got_Surface_Already (LPDIRECTDRAWSURFACE test_surface)
    886 {
    887 	for (int i=0 ; i<MAX_SURFACES ; i++)
    888 	{
    889 		if ( Surface[i]==test_surface ){
    890 			return(TRUE);
    891 		}
    892 	}
    893 	return (FALSE);
    894 }
    895 
    896 /***********************************************************************************************
    897  * SMC::Restore_Surfaces -- restore the direct draw surfaces in the list                       *
    898  *                                                                                             *
    899  *                                                                                             *
    900  *                                                                                             *
    901  * INPUT:    Nothing                                                                           *
    902  *                                                                                             *
    903  * OUTPUT:   Nothing                                                                           *
    904  *                                                                                             *
    905  * WARNINGS: None                                                                              *
    906  *                                                                                             *
    907  * HISTORY:                                                                                    *
    908  *    11/3/95 3:26PM ST : Created                                                              *
    909  *=============================================================================================*/
    910 
    911 void SurfaceMonitorClass::Restore_Surfaces (void)
    912 {
    913 	if (InFocus){
    914 		/*
    915 		** Call restore for each Direct Draw surface
    916 		*/
    917 		for (int i=0 ; i<MAX_SURFACES ; i++)
    918 		{
    919 			if ( Surface[i] ){
    920 				if (Surface[i]->Restore() != DD_OK){
    921 					if (Misc_Focus_Loss_Function){
    922 						Misc_Focus_Loss_Function();
    923 					}
    924 					return;
    925 				}
    926 			}
    927 		}
    928 
    929 		/*
    930 		** PWG/ST: Now that we know all the surfaces are restored call
    931 		** the function pointer to notify the program that it has
    932 		** happened.  This function pointer is used to clear the pages,
    933 		** etc.
    934 		*/
    935 		if (Misc_Focus_Restore_Function){
    936 			Misc_Focus_Restore_Function();
    937 		}
    938 
    939 		SurfacesRestored = TRUE;
    940 
    941 		/*
    942 		** Restore the palette
    943 		*/
    944 		Set_DD_Palette (CurrentPalette);
    945 	}
    946 }
    947 
    948 
    949 /***********************************************************************************************
    950  * SMC::Set_Surface_Focus -- set the InFocus flag to the given state                           *
    951  *                                                                                             *
    952  *  The InFocus flag is used to keep track of whether our application is currently in focus.   *
    953  *  We dont want to be restoring video surfaces when we are supposed to be running in the      *
    954  *  background.                                                                                *
    955  *                                                                                             *
    956  * INPUT:    bool in focus                                                                     *
    957  *                                                                                             *
    958  * OUTPUT:   Nothing                                                                           *
    959  *                                                                                             *
    960  * WARNINGS: None                                                                              *
    961  *                                                                                             *
    962  * HISTORY:                                                                                    *
    963  *    11/6/95 12:21PM ST : Created                                                             *
    964  *=============================================================================================*/
    965 
    966 void SurfaceMonitorClass::Set_Surface_Focus ( BOOL in_focus )
    967 {
    968 	InFocus=in_focus;
    969 }
    970 
    971 
    972 
    973 
    974 /***********************************************************************************************
    975  * SMC::Release -- releases all direct draw surfaces                                           *
    976  *                                                                                             *
    977  *  Call this at the end of the game before called RestoreDisplayMode                          *
    978  *                                                                                             *
    979  * INPUT:    Nothing                                                                           *
    980  *                                                                                             *
    981  * OUTPUT:   Nothing                                                                           *
    982  *                                                                                             *
    983  * WARNINGS: None                                                                              *
    984  *                                                                                             *
    985  * HISTORY:                                                                                    *
    986  *    6/6/96 12:23PM ST : Created                                                              *
    987  *=============================================================================================*/
    988 
    989 void SurfaceMonitorClass::Release(void)
    990 {
    991 	/*
    992 	** Call release for each Direct Draw surface
    993 	*/
    994 	for (int i=0 ; i<MAX_SURFACES ; i++)
    995 	{
    996 		if ( Surface[i] ){
    997 			Surface[i]->Release();
    998 			Surface[i] = 0;
    999 		}
   1000 	}
   1001 
   1002 }