
#ifndef _COMMON
#define _COMMON


#pragma warning(disable:4244)   // conversion from 'double' to 'float'
#pragma warning(disable:4018)   // Signed unsigned warnings
#pragma warning(disable:4800)   // Forcing value to bool


//------------------------------------------------------------------------------
//	Win95 Headers
//------------------------------------------------------------------------------
#define	WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <windowsx.h>
#undef	max
#undef	min

//------------------------------------------------------------------------------
//	ANSI headers
//------------------------------------------------------------------------------
#include <limits.h>
#include <float.h>
#include <math.h>
#include <stdarg.h>
#include <stdlib.h>

//------------------------------------------------------------------------------
//	defines
//------------------------------------------------------------------------------
#define	USE_FLOATS																															//	whether or not the real type is a float

//------------------------------------------------------------------------------
//	types
//------------------------------------------------------------------------------
typedef	unsigned short		word;																									//	abbreviation
typedef	unsigned short		ushort;																									//	abbreviation
typedef	unsigned long		ulong;																									//	abbreviatio
typedef	unsigned char		uchar;																									//	abbreviation
typedef	unsigned char		ubyte;																									//	abbreviation
typedef	unsigned int		uint;																									//	abbreviation
typedef	char					*cstr;																									//
typedef	uchar					*pstr;																									//	a pascal style string (preceded by a length byte)
#ifdef	USE_FLOATS																															//	if the real type is a float
typedef	float						real;																										//	common name for floating point type
#else																																						//	otherwise
typedef	double					real;																										//	common name for floating point type
#endif																																					//	end

//------------------------------------------------------------------------------
//	enumerations
//------------------------------------------------------------------------------
#ifndef	bool																																		//	if the compiler does nto recognize the keyword 'bool'
#define	bool	int																																//	use an int instead
#endif																																					//	end
#ifndef	TRUE																																		//	if TRUE and FALSE are not defined
#define	TRUE	1																																	//	define TRUE
#define	FALSE	0																																	//	define FALSE
#endif																																					//	end

//------------------------------------------------------------------------------
//	macros
//------------------------------------------------------------------------------
#ifdef	USE_FLOATS																															//	if the real type is a float
#define	R(num)	(num ## F)																											//	want constants to have an F after them to specify float types
#else																																						//	otherwise
#define	R(num)	(num)																														//	want constants to have an L after them to specify long double types
#endif																																					//	end

#define	TopLeft(r)	(((Point *) &(r))[0])																				//	an easy way to get a point from a rectangle
#define	BotRight(r)	(((Point *) &(r))[1])																				//	an easy way to get a point from a rectangle
#define	hiword(val)	((ulong (val) & 0xFFFF0000) >> 16)													//	make a short from the hiword of a long word
#define	loword(val)	(val & 0x0000FFFF)																					//	want only the low word of a long word


#ifndef MIN
#define MIN(a,b) ((a)<(b)?(a):(b))
#endif

#ifndef MAX
#define MAX(a,b) ((a)>(b)?(a):(b))
#endif

#ifndef ABS
#define ABS(x) ((x)<0?-(x):(x))
#endif

#if !defined(SIGN)
#define SIGN(x) ((x)<0?-1:((x)>0?1:0))
#endif



	//fast int to float conversion.
#define QRound(x) ((int)((x)+.5))
#define QInt(x)   ((int)(x))
#define QInt16(x) ((int)((x)*65536.))


//------------------------------------------------------------------------------
//	constants
//------------------------------------------------------------------------------
const		real	INFINITY = R(100000.0);																						//	floating point infinity value
const		real	EPSILON = R(1.0) / R(100000.0);																		//	floating point epsilon value
const 	real  SMALL_EPSILON R(0.000001);			/* Very small value */
#ifndef	PI
const		real	PI = R(3.14159265358979323846);																		//	pi
#endif
#ifndef	M_PI
const		real	M_PI = R(3.14159265358979323846);																		//	pi
#endif
const		real	TWO_PI = PI * R(2.0);																							//	two times pi

//------------------------------------------------------------------------------

#endif //

