WWSTD.H 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  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 : wwstd.h *
  23. * *
  24. * File Name : WWLIB.H *
  25. * *
  26. * Programmer : Jeff Wilson *
  27. * *
  28. * Start Date : March 1, 1994 *
  29. * *
  30. * Last Update : March 1, 1994 [] *
  31. * *
  32. *-------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #ifndef WWSTD_H
  36. #define WWSTD_H
  37. //
  38. // Win 95 includes
  39. //
  40. #ifndef WIN32
  41. #ifndef _WIN32 // Denzil 6/2/98 Watcom 11.0 complains without this check
  42. #define _WIN32
  43. #endif // _WIN32
  44. #define WIN32 1
  45. #define WIN32_LEAN_AND_MEAN
  46. #include <windows.h>
  47. #include <windowsx.h>
  48. #endif
  49. // Note: SKB 4/11/94
  50. // Before this library is done, this needs to be able to be set to TRUE.
  51. // Once it is, the FALSE parts should be removed from the source code.
  52. #define LIB_EXTERNS_RESOLVED FALSE
  53. #include <stdio.h>
  54. #include <stdlib.h>
  55. #include <dos.h>
  56. #include <bios.h>
  57. //================================
  58. // TRUE and FALSE are defined in pltypes.h
  59. #ifndef IBM
  60. #define IBM TRUE
  61. #endif
  62. #ifndef AMIGA
  63. #define AMIGA FALSE
  64. #endif
  65. #ifndef SEGA
  66. #define SEGA FALSE
  67. #endif
  68. /*
  69. ** Common constants used in normal code.
  70. */
  71. #define WW_ERROR -1
  72. #ifdef NULL
  73. #undef NULL
  74. #endif
  75. #ifndef NULL
  76. #define NULL 0L
  77. #endif
  78. #ifdef VOID
  79. #undef VOID
  80. #endif
  81. #define PRIVATE static
  82. #define PUBLIC /* Routines & data don't have a specifier */
  83. #ifdef __cplusplus
  84. #define __CPPARGS ...
  85. #else
  86. #define __CPPARGS
  87. #endif
  88. // This macro will get the size (in elements) of the specified array.
  89. #ifdef GET_SIZE
  90. #undef GET_SIZE
  91. #endif
  92. #define GET_SIZE(a) ((sizeof(a) / sizeof(*a)))
  93. #pragma option -Jg
  94. // Returns the absolute value of the number.
  95. #ifdef ABS
  96. #undef ABS
  97. #endif
  98. template<class T> T ABS(T a)
  99. {
  100. return (a < 0) ? -a : a;
  101. }
  102. int ABS(int);
  103. long ABS(long);
  104. // Returns the minimum of the two numbers.
  105. #ifdef MIN
  106. #undef MIN
  107. #endif
  108. template<class T> T MIN(T a, T b)
  109. {
  110. return (b < a) ? b : a;
  111. };
  112. short MIN(short, short);
  113. int MIN(int, int);
  114. long MIN(long, long);
  115. // Returns the maximum of the two numbers.
  116. #ifdef MAX
  117. #undef MAX
  118. #endif
  119. template<class T> T MAX(T a, T b)
  120. {
  121. return (b > a) ? b : a;
  122. };
  123. short MAX(short, short);
  124. int MAX(int, int);
  125. long MAX(long, long);
  126. #pragma option -Jgd
  127. // Returns the low word of a long
  128. #define LOW_WORD(a) ((unsigned short)((long)(a) & 0x0000FFFFL))
  129. // Returns the high word of a long
  130. #define HIGH_WORD(a) ((unsigned long)(a) >> 16)
  131. // Merges to shorts to become a long
  132. #define MAKE_LONG(a,b) (((long)(a) << 16) | (long)((b)&0x0000FFFFL))
  133. /*
  134. ** Macro allows our routines to act like
  135. ** sprintf etc..
  136. */
  137. #ifdef AssembleTo
  138. #undef AssembleTo
  139. #endif
  140. #define AssembleTo(dest,fmt)\
  141. {\
  142. va_list argptr;\
  143. if (fmt != (dest))\
  144. {\
  145. va_start (argptr, fmt);\
  146. vsprintf ((dest), fmt, argptr);\
  147. va_end (argptr);\
  148. }\
  149. }
  150. // type definitions
  151. //=======================================
  152. typedef void VOID;
  153. //==================================================
  154. // Pharlape defines these for use so we use their
  155. // typedefs!
  156. // typedef unsigned char BOOL;
  157. // typedef signed long LONG;
  158. // typedef unsigned long ULONG;
  159. //==================================================
  160. #ifndef PRIVATE
  161. #define PRIVATE static
  162. #endif
  163. // The purpose of the INT and UINT is for efficiency. It says that while a short int (16 bit)
  164. // has enough precision, it is more efficient to pass in an int (32 bits). For efficiency, most
  165. // WORD and UWORD should be an INT or UINT, especially on the stack and structures that will
  166. // not be in large arrays. When size efficiency is more important then speed, use WORD UWORD.
  167. #define VOID void
  168. #pragma warn -eas
  169. #define TRUE 1
  170. #define FALSE 0
  171. /*
  172. ** The "bool" integral type was defined by the C++ comittee in
  173. ** November of '94. Until the compiler supports this, use the following
  174. ** definition.
  175. */
  176. #ifndef __BORLANDC__
  177. #ifndef TRUE_FALSE_DEFINED
  178. #define TRUE_FALSE_DEFINED
  179. enum {false=0,true=1};
  180. typedef int bool;
  181. #endif
  182. #endif
  183. //#define true 1
  184. //#define false 0
  185. #define BOOL int // 32 bits for speed. use CHAR for size optimizations.
  186. #if(0)
  187. #ifndef HMI_DRIVER
  188. #define INT int
  189. #define UINT unsigned int
  190. #define BYTE char
  191. #define UBYTE unsigned char
  192. #define UCHAR unsigned char
  193. #define WORD signed short
  194. #define UWORD unsigned short
  195. #define USHORT unsigned short
  196. #define LONG signed long
  197. #define ULONG unsigned long
  198. #define REALPTR unsigned long
  199. #define FARPTR char far *
  200. #endif
  201. #endif
  202. /*
  203. ** The type of processor running on this system as
  204. ** returned by Processor().
  205. */
  206. #define PROC_80386 0
  207. #define PROC_80486 1
  208. #define PROC_PENTIUM 2
  209. // Inline Routines
  210. //ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
  211. //
  212. // These Template functions are generally used
  213. // by classes when they havce over loaded > and <.
  214. //
  215. #ifdef __cplusplus
  216. template<class T> T Min(T a, T b)
  217. {
  218. return (a<b ? a : b);
  219. }
  220. template<class T> inline T Max(T a, T b)
  221. {
  222. return (a>b ? a : b);
  223. }
  224. template<class T> T Abs(T a)
  225. {
  226. return ((a<0) ? -(a) : a);
  227. }
  228. template<class T> VOID minimize(T &a, T b)
  229. {
  230. if( b<a )
  231. a=b;
  232. }
  233. template<class T> VOID maximize(T &a, T b)
  234. {
  235. if( b>a )
  236. a=b;
  237. }
  238. #endif
  239. /*
  240. ** Macros that control bit settings in a variable.
  241. */
  242. #define Bit_Flags_On(a,b) a |= (b)
  243. #define Bit_Flags_Off(a,b) a &= (~(b))
  244. #define Bit_Flags_Value(a,b) (a & (b))
  245. #define Bit_Flags_Flip(a,b) a ^= (b)
  246. // Template replacements for the user defines above
  247. #ifdef __cplusplus
  248. template<class T> VOID BitFlagsOn(T &a, T b)
  249. {
  250. a |= (b);
  251. }
  252. template<class T> VOID BitFlagsOff(T &a, T b)
  253. {
  254. a &= (~(b));
  255. }
  256. template<class T> T BitFlagsValue(T a, T b)
  257. {
  258. return (a & (b));
  259. }
  260. template<class T> VOID BitFlagsFlip(T &a, T b)
  261. {
  262. a ^= (b);
  263. }
  264. #endif
  265. typedef enum {
  266. TBLACK,
  267. PURPLE,
  268. CYAN,
  269. GREEN,
  270. LTGREEN,
  271. YELLOW,
  272. PINK,
  273. BROWN,
  274. RED,
  275. LTCYAN,
  276. LTBLUE,
  277. BLUE,
  278. BLACK,
  279. GREY,
  280. LTGREY,
  281. WHITE,
  282. COLOR_PADDING=0x1000
  283. } ColorType;
  284. #endif