MISC.H 10 KB

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