/******************************************************************************************
	CRTest PS   (c) 1999-2001 ISL

	global.h:		Global defintions / system includes
******************************************************************************************/

// ==== JS : I've had to comment this out because of the PC conversion.  Sorry Chris, but 
// ====      sometimes we have a sane reason for compiling under win32. :o)
/*#ifdef _WIN32
	#error This is a PSX program, you dolt!
#endif*/

#include "dcinc.h"

#ifndef _GLOBAL_H_
#define _GLOBAL_H_

#ifdef _WINDNOWS
	#define TERRIT 2
	#define LOTS_OF_LANGUAGES 0	// UK, PAL
	#define PALMODE 1
	#define PRODUCTPREFIX		"BE"
	#define PRODUCTCODE	"SLES-03188"
#endif


#ifdef DREAMCAST

	#define TERRIT 1
	#define LOTS_OF_LANGUAGES 0	// UK, PAL
	#ifndef PALMODE
	#define PALMODE 1
	#endif
	#define PRODUCTPREFIX		"BE"
	#define PRODUCTCODE	"SLES-03188"

#else	

#ifndef _WINDOWS

	#ifndef TERRIT
		stop_dead_with_an_error("territ" is defined in the latest MAKEFILE. 0=NTSC,1=PAL euro, 2=PAL uk)
	#endif

#endif

	#if TERRIT==0
		#define LOTS_OF_LANGUAGES 0	// US, NTSC
		#define PALMODE 0
		#define PRODUCTPREFIX		"BA"
		#define PRODUCTCODE	"SLUS-01304"
	#endif
	#if TERRIT==1
		#define LOTS_OF_LANGUAGES 1	// Euro, PAL
		#define PALMODE 1
		#define PRODUCTPREFIX		"BE"
		#define PRODUCTCODE	"SLES-03285"
	#endif
	#if TERRIT==2
		#define LOTS_OF_LANGUAGES 0	// UK, PAL
		#define PALMODE 1
		#define PRODUCTPREFIX		"BE"
		#define PRODUCTCODE	"SLES-03188"
	#endif

#endif


#ifndef DREAMCAST
#define MEMORYCARDNAME	PRODUCTPREFIX PRODUCTCODE "CHRUN"
#endif

//#endif

// Take the attrib off, and define this for ECTS, etc
// #define GAME_SHOW_DEMO

// #define USE_CUSTOM_SPLASH

//#define POLY_COUNTERS

#define VERSIONSTR		__DATE__




#define LEAVE_THE_GIBSON 0
#define GAG_THE_GIBSON 1
#define REMOVE_THE_GIBSON 2

#if (TERRIT == 1)
// Euro is fine
  #define SENSIBLE_CONTRACT_NEGOTIATION___NOT_US LEAVE_THE_GIBSON
#else
// UK/US is the swine
  #define SENSIBLE_CONTRACT_NEGOTIATION___NOT_US LEAVE_THE_GIBSON
//  #define SENSIBLE_CONTRACT_NEGOTIATION___NOT_US REMOVE_THE_GIBSON
#endif







/*
#if PALMODE==0
	#define PRODUCTCODE			NTSCPRODUCTCODE
	#define OTHERPRODUCTCODE	PALPRODUCTCODE
	#define PRODUCTPREFIX		"BA"
	#define OTHERPRODUCTPREFIX	"BE"
#else
	#define PRODUCTCODE			PALPRODUCTCODE
	#define OTHERPRODUCTCODE	NTSCPRODUCTCODE
	#define PRODUCTPREFIX		"BE"
	#define OTHERPRODUCTPREFIX	"BA"
#endif
*/

//#define OTHERMEMORYCARDNAME	OTHERPRODUCTPREFIX OTHERPRODUCTCODE "CHRUN"

#ifdef DREAMCAST
	#define MEMORYCARDNAME	"CHICKENRUNDC"
#endif

#define PREVIEW_VERSION				0
#define EIDOS_DEBUG_STUFF			0	//1	// Even in burns
#define FRAME_RATE_COMPENTSATION	1

#ifndef _WINDOWS

#define BYTE	char
#define UBYTE	unsigned char
#define uchar	unsigned char
#define SHORT	short
#define USHORT	unsigned short
#define LONG	long
#define ULONG	unsigned long
#define VOID	void

#endif

#define ANG2FIX(a)		(((a)*4096)/360)
#define SAMESIGN(a,b)	(((long)((unsigned long)a^(unsigned long)b))>=0)
#define PER2FIX(a)		(((a)*4096)/100)
#define INT_SMALLEST	(-2147483647)
#define INT_LARGEST		(2147483647)



#ifndef DREAMCAST
	#ifndef _WINDOWS

	#include <r3000.h>

	#include <sys/errno.h>
	#include <sys/types.h>

	#include <libapi.h>
	#include <libetc.h>
	#include <libgte.h>
	#include <libgpu.h>
	#include <libgs.h>
	#include <libsn.h>
	#include <libcd.h>
	#include <libspu.h>
	#include <libmcrd.h>
	#include <libpad.h>
	#include <asm.h>
	#include <kernel.h>
	#include <libmath.h>
	#include <stdarg.h>
	#include <stdio.h>
	#include <inline_c.h>
	#include <gtemac.h>
	#include <strings.h>
	#include <convert.h>

	#include <islmem.h>
	#include <islfile.h>
	#include <isltex.h>
	#include <islfont.h>
	#include <islcard.h>
	#include <isllocal.h>
	#include <islxa.h>
	#include <islvideo.h>
	//#include <islsound.h>
	#include <islsfx2.h>
	#include <islpad.h>
	#include <islutil.h>
	#include <islpsi.h>
	#include <psitypes.h>

	#else

	#include "PsxShell.h"
	#include "pcCustom.h"
	#include "d3d.h"
	#include "ddraw.h"
	#include "isllocal.h"
	#include "pcTim.h"
	//#include "gte.h"
	//#include "pcGameStuff.h"
	//#include "pcHardware3D.h"

	extern int runningHard;

	#endif
#endif

#include "actor.h"
#include "ranges.h"	// I don't know if this should be in here or not
#include "overlay.h"
//#include "gametext.h"

#ifndef _WINDOWS
#include "shell.h"
#endif

#ifdef _WINDOWS
	extern char pcDCacheData[1024*4];
	#define DCACHE  pcDCacheData
	#define DCACHETOP (pcDCacheData+4096)
#else
	#ifdef DREAMCAST
		extern char pcDCacheData[1024*4];
		#define DCACHE  pcDCacheData
		#define DCACHETOP (pcDCacheData+4096)
	#else
		#define DCACHE  0x1f800000
		#define DCACHETOP  0x1f8003fc
	#endif
#endif

extern int debugPrintf(char* fmt, ...);
extern int DB(char* fmt, ...);

#ifndef ADD2POINTER
	#define ADD2POINTER(a,b) ( (void *) ( (int)(a) + (b))  )
#endif
#ifndef SUBPOINTERS
	#define SUBPOINTERS(a,b) (((int)((int)(a) - (int)(b))))
#endif
#ifndef CRASH
//	#define CRASH while(0==0)POLLHOST();
  #ifndef _WINDOWS
	#define CRASH while(0==0);
  #else
	#define CRASH
  #endif
#endif

#ifdef DEBUG
  // RFW, indents, trying to untangle something of a nightmare!

  #ifdef SCREENDEBUG
	#ifndef DREAMCAST
		// RFW, 4 Oct. PSX version wants its DB, badly, because folks are putting non-debug-only utilPrintf's in if it ain't there. Tsk.
		#define debugPrintf screenPrintf
		#define DB debugPrintf
	#else
		#define DB
	#endif
  #else
	#ifndef DREAMCAST
		// RFW, 4 Oct. PSX version wants its DB, badly, because folks are putting non-debug-only utilPrintf's in if it ain't there. Tsk.
		#define debugPrintf utilPrintf
		#define DB debugPrintf
	#else
		#define DB
	#endif

  #endif

  #define ASSERT(V) if(!(V)) {DB("\nASSERT FAILED! in "__FILE__", %d, "#V"\n", __LINE__); CRASH}
  #ifndef DREAMCAST
		#ifdef _WINDOWS
			#define VERIFY(V)
		#else
			#define VERIFY(V) verifyPointer(V, sizeof(*V), __FILE__, __LINE__)
		#endif

	#else
		#define VERIFY(V) 
	#endif
#else
	#ifndef DREAMCAST
		#define debugPrintf
	#endif
	#define DB
	#define ASSERT
	#define VERIFY
#endif



#define ENEMIES_FORCEFRONT_SORTDEPTH	1
#ifdef DREAMCAST
extern int DEATH_FADEPOLY_SORTDEPTH;
#else
#define DEATH_FADEPOLY_SORTDEPTH		2
#endif
#define PANEL_OVERLAYS_SORTDEPTH		3

#ifdef POLY_COUNTERS
	enum
	{
		SKY_POLYS,
		MAP_POLYS,
		MODEL_POLYS,
		SPRITE_POLYS,
		N_POLY_COUNTERS
	};
	extern int polycounts[N_POLY_COUNTERS];

	#define INCPOLYCOUNT(a) {polycounts[a]++;}
#else
	#define INCPOLYCOUNT(a)
#endif

#endif
