CnC_Remastered_Collection

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

WWSTD.H (5060B)


      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 : wwstd.h                                  *
     21  *                                                                         *
     22  *                    File Name : WWLIB.H                                  *
     23  *                                                                         *
     24  *                   Programmer : Jeff Wilson                              *
     25  *                                                                         *
     26  *                   Start Date : March 1, 1994                            *
     27  *                                                                         *
     28  *                  Last Update : March 1, 1994   []                       *
     29  *                                                                         *
     30  *-------------------------------------------------------------------------*
     31  * Functions:                                                              *
     32  * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
     33 
     34 #ifndef WWSTD_H
     35 #define	WWSTD_H
     36 
     37 
     38 
     39 #include <windows.h>
     40 #include <windowsx.h>
     41 
     42 #ifndef IBM
     43 #define IBM				TRUE
     44 #endif
     45 
     46 #define WW_ERROR		-1
     47 
     48 #define PRIVATE		static
     49 #define PUBLIC			/* Routines & data don't have a specifier */
     50 
     51 #ifdef __cplusplus
     52 #define	__CPPARGS	...
     53 #else
     54 #define	__CPPARGS
     55 #endif
     56 
     57 
     58 
     59 #ifdef GET_SIZE
     60 #undef GET_SIZE
     61 #endif
     62 #define GET_SIZE(a)					((sizeof(a) / sizeof(*a)))
     63 
     64 //PG_TO_FIX
     65 //#pragma option -Jg
     66 // Returns the absolute value of the number.
     67 #ifdef ABS
     68 #undef ABS
     69 #endif
     70 template<class T> T ABS(T a)
     71 {
     72 	return (a < 0) ? -a : a;
     73 }
     74 //int ABS(int);
     75 //long ABS(long);
     76 
     77 // Returns the minimum of the two numbers.
     78 #ifdef MIN
     79 #undef MIN
     80 #endif
     81 template<class T> T MIN(T a, T b)
     82 {
     83 	return (b < a) ? b : a;
     84 };
     85 //short MIN(short, short);
     86 //int MIN(int, int);
     87 //long MIN(long, long);
     88 
     89 // Returns the maximum of the two numbers.
     90 #ifdef MAX
     91 #undef MAX
     92 #endif
     93 template<class T> T MAX(T a, T b)
     94 {
     95 	return (b > a) ? b : a;
     96 };
     97 
     98 // Returns the low word of a long
     99 #define	LOW_WORD(a)		((unsigned short)((long)(a) & 0x0000FFFFL))
    100 
    101 // Returns the high word of a long
    102 #define	HIGH_WORD(a)	((unsigned long)(a) >> 16)
    103 
    104 // Merges to shorts to become a long
    105 #define	MAKE_LONG(a,b) (((long)(a) << 16) | (long)((b)&0x0000FFFFL))
    106 
    107 /*
    108 ** Macro allows our routines to act like
    109 ** sprintf etc..
    110 */
    111 #ifdef AssembleTo
    112 #undef AssembleTo
    113 #endif
    114 
    115 #define AssembleTo(dest,fmt)\
    116 {\
    117 	va_list argptr;\
    118 	if (fmt != (dest))\
    119 		{\
    120 		va_start (argptr, fmt);\
    121 		vsprintf ((dest), fmt, argptr);\
    122 		va_end (argptr);\
    123 		}\
    124 }
    125 
    126 
    127 /*
    128 **	The type of processor running on this system as
    129 **	returned by Processor().
    130 */
    131 #define	PROC_80386		0
    132 #define	PROC_80486		1
    133 #define	PROC_PENTIUM	2
    134 
    135 
    136 // Inline Routines
    137 //様様様様様様様様
    138 //
    139 // These Template functions are generally used
    140 // by classes when they havce over loaded > and <.
    141 //
    142 #ifdef __cplusplus
    143 template<class T> T Min(T a, T b)
    144 {
    145 	return (a<b ? a : b);
    146 }
    147 
    148 template<class T> inline  T Max(T a, T b)
    149 {
    150 	return (a>b ? a : b);
    151 }
    152 
    153 template<class T> T Abs(T a)
    154 {
    155 	return ((a<0) ? -(a) : a);
    156 }
    157 
    158 template<class T> VOID minimize(T &a, T b)
    159 {
    160 	if( b<a )
    161 		a=b;
    162 }
    163 
    164 template<class T> VOID maximize(T &a, T b)
    165 {
    166 	if( b>a )
    167 		a=b;
    168 }
    169 #endif
    170 
    171 /*
    172 **	Macros that control bit settings in a variable.
    173 */
    174 #define Bit_Flags_On(a,b)			a |= (b)
    175 #define Bit_Flags_Off(a,b)			a &= (~(b))
    176 #define Bit_Flags_Value(a,b)		(a & (b))
    177 #define Bit_Flags_Flip(a,b)		a ^= (b)
    178 
    179 // Template replacements for the user defines above
    180 #ifdef __cplusplus
    181 template<class T> VOID BitFlagsOn(T &a, T b)
    182 {
    183 	a |= (b);
    184 }
    185 
    186 template<class T> VOID BitFlagsOff(T &a, T b)
    187 {
    188 	a &= (~(b));
    189 }
    190 
    191 template<class T> T BitFlagsValue(T a, T b)
    192 {
    193 	return (a & (b));
    194 }
    195 
    196 template<class T> VOID BitFlagsFlip(T &a, T b)
    197 {
    198 	a ^= (b);
    199 }
    200 #endif
    201 
    202 typedef enum {
    203 	TBLACK,
    204 	PURPLE,
    205 	CYAN,
    206 	GREEN,
    207 	LTGREEN,
    208 	YELLOW,
    209 	PINK,
    210 	BROWN,
    211 	RED,
    212 	LTCYAN,
    213 	LTBLUE,
    214 	BLUE,
    215 	BLACK,
    216 	GREY,
    217 	LTGREY,
    218 	WHITE,
    219 	COLOR_PADDING=0x1000
    220 } ColorType;
    221 
    222 
    223 
    224 #endif	//WWSTD_H