MISC.H 10 KB

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