CnC_Remastered_Collection

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

MISC.H (10689B)


      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   S T U D I O S       **
     18  ***************************************************************************
     19  *                                                                         *
     20  *                 Project Name : 32 bit library                           *
     21  *                                                                         *
     22  *                    File Name : MISC.H                                   *
     23  *                                                                         *
     24  *                   Programmer : Scott K. Bowen                           *
     25  *                                                                         *
     26  *                   Start Date : August 3, 1994                           *
     27  *                                                                         *
     28  *                  Last Update : August 3, 1994   [SKB]                   *
     29  *                                                                         *
     30  *-------------------------------------------------------------------------*
     31  * Functions:                                                              *
     32  * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
     33 
     34 #ifndef MISC_H
     35 #define MISC_H
     36 
     37 #define WIN32_LEAN_AND_MEAN	// eliminates unecessary definitions in windows.h
     38 #ifndef _WIN32 // Denzil 6/2/98 Watcom 11.0 complains without this check
     39 #define _WIN32
     40 #endif // _WIN32
     41 #include <windows.h>
     42 #include <windowsx.h>
     43 #include <ddraw.h>
     44 
     45 extern	LPDIRECTDRAWSURFACE	PaletteSurface;
     46 
     47 /*========================= C++ Routines ==================================*/
     48 
     49 
     50 /*=========================================================================*/
     51 /* The following prototypes are for the file: DDRAW.CPP							*/
     52 /*=========================================================================*/
     53 void 		Process_DD_Result(HRESULT result, int display_ok_msg);
     54 BOOL 		Set_Video_Mode(HWND hwnd, int w, int h, int bits_per_pixel);
     55 void 		Reset_Video_Mode(void);
     56 unsigned 	Get_Free_Video_Memory(void);
     57 void 		Wait_Blit(void);
     58 unsigned 	Get_Video_Hardware_Capabilities(void);
     59 
     60 extern "C" void Wait_Vert_Blank(void);
     61 extern "C" void Set_DD_Palette (void *palette);
     62 
     63 /*
     64 ** Pointer to function to call if we detect a focus loss
     65 */
     66 extern	void (*Misc_Focus_Loss_Function)(void);
     67 /*
     68 ** Pointer to function to call if we detect a surface restore
     69 */
     70 extern	void (*Misc_Focus_Restore_Function)(void);
     71 
     72 
     73 /*
     74  *  Flags returned by Get_Video_Hardware_Capabilities
     75  */
     76 /* Hardware blits supported? */
     77 #define	VIDEO_BLITTER					1
     78 
     79 /* Hardware blits asyncronous? */
     80 #define	VIDEO_BLITTER_ASYNC  		2
     81 
     82 /* Can palette changes be synced to vertical refresh? */
     83 #define	VIDEO_SYNC_PALETTE			4
     84 
     85 /* Is the video cards memory bank switched? */
     86 #define	VIDEO_BANK_SWITCHED			8
     87 
     88 /* Can the blitter do filled rectangles? */
     89 #define	VIDEO_COLOR_FILL				16
     90 
     91 /* Is there no hardware assistance avaailable at all? */
     92 #define	VIDEO_NO_HARDWARE_ASSIST	32
     93 
     94 
     95 
     96 /*
     97  * Definition of surface monitor class
     98  *
     99  * This class keeps track of all the graphic buffers we generate in video memory so they
    100  *  can be restored after a focus switch.
    101 */
    102 
    103 #define	MAX_SURFACES	20
    104 
    105 class SurfaceMonitorClass {
    106 
    107 	public:
    108 
    109 		SurfaceMonitorClass();
    110 
    111 		void	Add_DD_Surface (LPDIRECTDRAWSURFACE);
    112 		void	Remove_DD_Surface (LPDIRECTDRAWSURFACE);
    113 		BOOL	Got_Surface_Already (LPDIRECTDRAWSURFACE);
    114 		void	Restore_Surfaces (void);
    115 		void	Set_Surface_Focus ( BOOL in_focus );
    116 		void	Release(void);
    117 
    118 		BOOL	SurfacesRestored;
    119 
    120 	private:
    121 
    122 		LPDIRECTDRAWSURFACE	Surface[MAX_SURFACES];
    123 		BOOL						InFocus;
    124 
    125 };
    126 
    127 extern	SurfaceMonitorClass	AllSurfaces;				//List of all direct draw surfaces
    128 
    129 
    130 /*=========================================================================*/
    131 /* The following variables are declared in: DDRAW.CPP								*/
    132 /*=========================================================================*/
    133 extern	LPDIRECTDRAW	DirectDrawObject;
    134 extern	LPDIRECTDRAW2	DirectDraw2Interface;
    135 extern	HWND				MainWindow;
    136 extern BOOL 				SystemToVideoBlits;
    137 extern BOOL				VideoToSystemBlits;
    138 extern BOOL				SystemToSystemBlits;
    139 extern BOOL				OverlappedVideoBlits;	// Can video driver blit overlapped regions?
    140 
    141 /*=========================================================================*/
    142 /* The following prototypes are for the file: EXIT.CPP							*/
    143 /* Prog_End Must be supplied by the user program in startup.cpp				*/
    144 /*=========================================================================*/
    145 void __cdecl Prog_End(const char *why, bool fatal);  // Added why and fatal. ST - 8/7/2019 10:54AM	
    146 VOID __cdecl Exit(INT errorval, const BYTE *message, ...);
    147 
    148 /*=========================================================================*/
    149 /* The following prototypes are for the file: DELAY.CPP							*/
    150 /*=========================================================================*/
    151 void Delay(int duration);
    152 void Vsync(void);
    153 
    154 
    155 /*=========================================================================*/
    156 /* The following prototypes are for the file: FINDARGV.CPP						*/
    157 /*=========================================================================*/
    158 
    159 BYTE  __cdecl Find_Argv(BYTE const *str);
    160 
    161 /*=========================================================================*/
    162 /* The following prototypes are for the file: LIB.CPP								*/
    163 /*=========================================================================*/
    164 char *Find_Argv(char const *str);
    165 void Mono_Mem_Dump(void const *databuf, int bytes, int y);
    166 void Convert_RGB_To_HSV(unsigned int r, unsigned int g, unsigned int b, unsigned int *h, unsigned int *s, unsigned int *v);
    167 void Convert_HSV_To_RGB(unsigned int h, unsigned int s, unsigned int v, unsigned int *r, unsigned int *g, unsigned int *b);
    168 
    169 
    170 /*=========================================================================*/
    171 /* The following prototypes are for the file: VERSION.CPP						*/
    172 /*=========================================================================*/
    173 
    174 BYTE  __cdecl Version(VOID);
    175 
    176 
    177 /*=========================================================================*/
    178 /* The following prototypes are for the file: IRANDOM.CPP						*/
    179 /*=========================================================================*/
    180 int IRandom(int minval, int maxval);
    181 
    182 
    183 /*========================= Assembly Routines ==============================*/
    184 
    185 #ifdef __cplusplus
    186 extern "C" {
    187 #endif
    188 
    189 /*=========================================================================*/
    190 /* The following prototypes are for the file: RANDOM.ASM							*/
    191 /*=========================================================================*/
    192 
    193 unsigned char __cdecl Random(void);
    194 int __cdecl Get_Random_Mask(int maxval);
    195 
    196 /*=========================================================================*/
    197 /* The following prototype is for the file: SHAKESCR.ASM							*/
    198 /*=========================================================================*/
    199 
    200 void __cdecl Shake_Screen(int shakes);
    201 
    202 /*=========================================================================*/
    203 /* The following prototypes are for the file: REVERSE.ASM						*/
    204 /*=========================================================================*/
    205 
    206 long __cdecl Reverse_Long(long number);
    207 short __cdecl Reverse_Short(short number);
    208 long __cdecl Swap_Long(long number);
    209 #if (0)
    210 /*=========================================================================*/
    211 /* The following prototype is for the file: FACING8.ASM							*/
    212 /*=========================================================================*/
    213 
    214 int __cdecl Desired_Facing8(int x1, int y1, int x2, int y2);
    215 
    216 /*=========================================================================*/
    217 /* The following prototype is for the file: FACING16.ASM							*/
    218 /*=========================================================================*/
    219 
    220 int __cdecl Desired_Facing16(int x1, int y1, int x2, int y2);
    221 
    222 /*=========================================================================*/
    223 /* The following prototype is for the file: FACINGFF.ASM							*/
    224 /*=========================================================================*/
    225 
    226 int __cdecl Desired_Facing256(int x1, int y1, int x2, int y2);
    227 
    228 /*=========================================================================*/
    229 /* The following prototype is for the file: FADING.ASM							*/
    230 /*=========================================================================*/
    231 #endif
    232 
    233 void * __cdecl Build_Fading_Table(void const *palette, void const *dest, long int color, long int frac);
    234 /*=========================================================================*/
    235 /* The following prototype is for the file: CRC.ASM							*/
    236 /*=========================================================================*/
    237 
    238 long __cdecl Calculate_CRC(void *buffer, long length);
    239 
    240 /*=========================================================================*/
    241 /* The following prototypes are for the file: DETPROC.ASM						*/
    242 /*=========================================================================*/
    243 
    244 extern WORD __cdecl  Processor(void);
    245 extern WORD __cdecl Operating_System(void);
    246 extern unsigned long random ( unsigned long mod )  ;
    247 //extern void  randomize ( void ) ;
    248 
    249 extern int __cdecl Clip_Rect ( int * x , int * y , int * dw , int * dh ,
    250 	       	   			 int width , int height ) ;
    251 extern int __cdecl Confine_Rect ( int * x , int * y , int dw , int dh ,
    252 	      	      			 int width , int height ) ;
    253 
    254 
    255 
    256 /*=========================================================================*/
    257 /* The following prototypes are for the file: OPSYS.ASM							*/
    258 /*=========================================================================*/
    259 
    260 extern WORD OperationgSystem;
    261 
    262 #ifdef __cplusplus
    263 }
    264 #endif
    265 
    266 /*=========================================================================*/
    267 
    268 #endif // MISC_H