#define OLDSTYLE_HEADER	1

#define VERSIONSTR	__DATE__

#define DEMO

//#define USE_DIVTABLE

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

#define LBYTE            long
#define LUBYTE  unsigned long
#define LSHORT           long
#define LUSHORT unsigned long
#define LLONG            long
#define LULONG  unsigned long
#define BOOLEAN unsigned char
#define uchar	unsigned char
#define Boolean unsigned char
#define BOOL	unsigned char


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


#include <libetc.h>
#include <libgte.h>
#include <libgpu.h>
#include <libgs.h>
#include <libsn.h>
#include <libcd.h>
#include <libspu.h>
#include <libsnd.h>
#include <asm.h>
#include <kernel.h>
#include <libmath.h>
#include <stdarg.h>
#include <stdio.h>
#include <inline_c.h>
#include <gtemac.h>
#include <libmcrd.h>
#include <libpress.h>
#include <libpad.h>
#include <libmcrd.h>
#include <memory.h>
#include <libapi.h>	
#include <string.h>	
//#include <kernel.h>
/***************************** GENERAL STUFF ******************************************/

#define MOD %
#define NOT !
#define lAND &&    /*logical AND */
#define bAND &  /*bitwise AND */
#define lOR ||     /*logical OR */
#define bOR |           /*bitwise OR */
#define XOR ^
#define EOR ^
#define INT short
#define YES (1)
#define NO  (0)
//#define TRUE (1)
//#define FALSE (0)
#define OFF (0)
#define ON  (1)


// "make_goldcd" is a "-d" in the makefile, and should never be defined in the source
/*
#ifdef MAKE_GOLDCD
	#define GOLDCD MAKE_GOLDCD
#else
	#define GOLDCD NO
#endif
*/


#define RELEASE NO
#define GOLDCD NO

#define PALMODE YES

#define	RECORDKEYS	NO


#if PALMODE==YES
#define MULTI_LANGUAGE
#else
//#define MULTI_LANGUAGE
#endif

// The main trouble with the exception handler is that it prevents "testcd" from working on the devkit.
// The other problem is that I've never seen it work when it should have, either.
#if GOLDCD==YES
#define EXCEPTION_HANDLER NO
#else
#define EXCEPTION_HANDLER NO
#endif

// Sony req: knock a few frames off the video length

#define HASBRO_VIDEO_LEN (249-3)
#define ATARI_VIDEO_LEN (416-3)
#define INT_VIDEO_LEN (1818-3)
#define OUTRO_VIDEO_LEN (942-3)

// just define, not yes/no
//#define TWOLEVEL_DEMO

#include "debug.h"


#define SHOWCOLL

#define SCREENOFF  SetDispMask(0);   
#define SCREENON        SetDispMask(1);     
#define HALT            VSync(0);
#define CRASH while(0==0)POLLHOST();
#define DEMOINTERACTIVE 0
#define DEMOATTRACT 1
#define DEMONOT 255

#define PAD_LEFT		(1<<7)
#define PAD_RIGHT		(1<<5)
#define PAD_UP			(1<<4)
#define PAD_DOWN		(1<<6)
#define PAD_CROSS		(1<<14)
#define PAD_CIRCLE		(1<<13)
#define PAD_TRIANGLE	(1<<12)
#define PAD_SQUARE		(1<<15)
#define PAD_L1			(1<<10)
#define PAD_L2			(1<<8)
#define PAD_R1			(1<<11)
#define PAD_R2			(1<<9)
#define PAD_SELECT		(1<<0)
#define PAD_START		(1<<3)

#define	SEMITRANS_NONE	0
#define	SEMITRANS_SEMI	1
#define	SEMITRANS_ADD	2
#define	SEMITRANS_SUB	3

#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 FRACTIONAL_BITS	12
#define FRACTIONAL_DIV	4096

#define MAXDEPTH		(0x0fff)
#define PROJECTION 1024
#define SCREENYLIMIT (120+PALMODE*8)


#define STACKBASE  0x001ff000 /*4k stack*/
#define STACKTOP   0x001ffffc
#define DCACHE  0x1f800000
#define DCACHETOP 0x1f800400 /*1k stack!*/
#define BASEMEM   0x00000000
#define TOPMEM    0x00200000
#define EI	ExitCriticalSection()
#define DI	EnterCriticalSection()

#define BLACK	0,0,0
#define RED		255,0,0
#define GREEN	0,255,0
#define YELLOW	255,255,0
#define BLUE	0,0,255
#define MAGENTA	255,0,255
#define CYAN	0,255,255
#define WHITE	255,255,255

extern	UBYTE	palmode;
extern	UBYTE	goldcd;
extern	UBYTE	music;
extern	UBYTE	dovideo;
extern	UBYTE	level;

//bodges!
//extern UBYTE briefingactive;
//extern UBYTE noofplayers;
//extern UBYTE fastprintmodels;
//extern UBYTE *origstack;

#define	PRINTMESS	FALSE

typedef struct
{
	SHORT	x;	//note, they need to be this way round!
	SHORT	y;
}XYSHORT;

#include "card.h"
#include "overlay.h"
#include "font.h"
#include "quatern.h"
#include "utils.h"
#include "main.h"
#include "poly.h"
#include "texture.h"	
#include "object.h"
#include "interupt.h"
#include "memory.h"
#include "maths.h"
#include "ctrller.h"
#include "camera.h"
#include "fileio.h"
#include "font.h"
#include "collide.h"

#include "gameflow.h"
#include "anim.h"
#include "enemies.h"
#include "effects.h"
#include "ball.h"
#include "hand.h"
#include "camera.h"
#include "menu.h"
#include "sfx.h"
#include "loadlnd.h"
#include "xa.h"
#include "platform.h"
#include "lscape.h"
#include "video.h"
//#include "lightnin.h"
#include "weather.h"

#include "puzzles.h"
#include "cameo.h"
#include "bff_load.h"
#include "water.h"
#include "bosses.h"
#include "cacase.h"
#include "cheats.h"
#include "exc.h"

