WWSTD.H 6.8 KB

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