#ifndef DCK_MAIN_H_INCLUDED
#define DCK_MAIN_H_INCLUDED

#include "include.h"
#include "global.h"

#define	DREAMCAST_VERSION
//#define ECTS_DEMO
#define	MALLOC0			Align32Malloc
#define	MALLOC			Align32Malloc
#define	FREE(freeptr)	{Align32Free(freeptr);(freeptr) = NULL;}

#ifndef NULL
	#define NULL 0
#endif

//#define calc_angle(a,b) utilCalcAngle((a),(b))	

#define PostQuitMessage(x)
#define RunDesignWorkViewer()
#define StartControllerView()
#define RunControllerView()
#define StopSample(x)
#define SetCurrentDisplayPage(x,y);		kmBeginScene(&kmSystemConfig);kmBeginPass(&vertexBufferDesc);	
#define SendOTDisp();					kmEndPass(&vertexBufferDesc);kmRender(KM_RENDER_FLIP);kmEndScene(&kmSystemConfig);			

#define SetSp(x)		0
#define ResetDrawingEnvironment();

#define bb_InitXA();
#define XAgetStatus()	1
#define	memoryReset();
#define	memoryDestroy();
#define MainReset();

//#define LoadGame();
//#define SaveGame();

//#define PALMODE 0

extern int	digistick;
extern int digistick_debounced;


typedef struct _displayPageType {
	DISPENV	dispenv;
	DRAWENV	drawenv;
	ULONG	*ot;
	char	*primBuffer, *primPtr;
} displayPageType;

extern int	originalTexCount;
extern int 	afterRoomTexCount;
extern int	texNumAfterFont;


extern char *packetSpace;
extern const PDS_PERIPHERAL 	*per[4];
extern Sint32 soundMode;

#define BEGINPRIM(p,t) (p) = (t *)packetSpace;
				
#define ENDPRIM(p,d,t)		{addDCPrim((p),(d),(d),(d),(d));}
#define ENDPRIMA(p,d1,d2,d3,d4,t)		{addDCPrim((p),(d1),(d2),(d3),(d4));}

extern fixed gameSpeed;
extern fixed globalFrogScale;
extern TextureBankType *bg_textures;
extern char playing_ticker_enabled;

extern displayPageType 	displayPage[2];
extern displayPageType 	*currentDisplayPage;
extern psFont			*font;

extern PadDataType *pReadPad;

#define GOLDCD 1

#define SETSEMIPRIM(p,m)	(p)->tpage |= (((m)-1)<<5);
enum {
	SEMITRANS_NONE,
	SEMITRANS_SEMI,
	SEMITRANS_ADD,
	SEMITRANS_SUB,
	SEMITRANS_SUB2,

};

enum
{
	VIDEO_PLAYING_OVERLAY,
	ACT1_SUBGAME_OVERLAY,
	ACT2_SUBGAME_OVERLAY,
	ACT4_SUBGAME_OVERLAY,
	DEBUG_OVERLAY,
};

typedef void (*VOID_SUBROUTINE)(void);

extern VOID_SUBROUTINE draw_routine;
extern VOID_SUBROUTINE cycle_routine;


extern VOID_SUBROUTINE menuStart2pointer;	// It's actually in main.c
extern VOID_SUBROUTINE fireworksStartPointer;
extern VOID_SUBROUTINE catapultStartPointer;
extern VOID_SUBROUTINE seesawStartPointer;
extern VOID_SUBROUTINE engineStartPointer;
extern VOID_SUBROUTINE constructStartPointer;
extern VOID_SUBROUTINE wingsStartPointer;
extern VOID_SUBROUTINE crateStartPointer;
extern VOID_SUBROUTINE dogStartPointer;
extern VOID_SUBROUTINE elStartPointer;





void resetToBootROM();
extern int inDraw;

#define PREVIEW_VERSION 0
#define MASTER 0
#ifndef CRASH
	#define CRASH while(0==0);
#endif

extern ULONG			frame;
extern ULONG			loop_ticker;
extern ULONG			loop_ticker2;
extern int				gameTextLang;
extern GsRVIEW2			mycamera;
extern int globalAbortFlag;
extern int softResetAllowed;
extern int softresetlimit;

#ifndef PALMODE
#define PALMODE 1
#endif

#define debugPrintf debug_printf

#define WAIT_FOR_BUTTON

//define this when making a gd rom
#define debug_printf emptyPrintf 

	  /*
extern KMPACKEDARGB 	borderColour;
extern KMDWORD 			FBarea[];
extern PDS_PERIPHERAL 	*per;

extern KMSTRIPCONTEXT 	stripContext00;
extern KMSTRIPHEAD 		stripHead00;
extern KMSTRIPCONTEXT 	StripContext;
extern KMSTRIPHEAD 		StripHead;

extern DCKVERTEX 		*globalVerts;

extern KMSURFACEDESC	TexList[];

extern int				matrixSize;
extern DCKMATRIX		matrixStack[];
extern DCKMATRIX		viewMatrix;

extern DCKVECTOR		camPos;
extern DCKVECTOR		camTarg;
extern float			viewAngle;
extern float			viewDist;

extern GsRVIEW2			camera;

extern KMPACKEDARGB		colourClampMin;
extern KMPACKEDARGB		colourClampMax;

extern psFont 			*font;
extern psFont 			*fontSmall;

extern int 				drawLandscape;
extern long 			textEntry;	
extern char 			textString[255];

extern long 			drawGame;
*/
//extern unsigned long 	*sqrtable;
//extern short			*acostable;
  /*
extern long 			turbo;

extern struct gameStateStruct gameState;
*/
void mainDebugMenuVideo(int n);
extern UBYTE		skipable;
extern int preTitle;
extern int firstPad;
extern int hzQuit;
#ifdef WAIT_FOR_BUTTON
void waitForButton(int i);
#else
#define waitForButton
#endif
#endif