//#define LEVEL_TIMEOUT (3000*30)
#define LEVEL_TIMEOUT (1500*30)

#define	HURTVEL		-4096*20
#define	DIEVEL		-4096*40

#define	ICESLIDESPEED	4*4096
//#define	HANDOFFLEVEL	2000*4096
//#define BALLOFFLEVEL	2000*4096	/* must change*/

//#define	NORMAL_SCALE	0.078125
#define	NORMAL_SCALE	.5
extern	NEWMODEL	*pBallPSA;
extern	NEWMODEL	*pCballPSA;
extern	NEWMODEL	*pPlasterPSA,*pPhongPSA;
extern	NEWMODEL	*pGlovePSA;
extern	NEWMODEL	*pRotorPSA;
extern	NEWMODEL	*pOldBall;

extern	NEWMODEL	*pBoulderPSA,*pGloveBoulderPSA;
extern	NEWMODEL *plionfishPSA;
extern	NEWMODEL *pmalletPSA;
extern	NEWMODEL *psharkyPSA;

extern	objectSegDataType	*pGloveAnim;
extern	AnimType			GloveAnim;
//	Models for cabonus
extern	NEWMODEL	*pCannonPSA;
extern	NEWMODEL	*pRing01PSA,*pRing02PSA,*pRing03PSA;
extern	NEWMODEL	*pPod01PSA;
extern	NEWMODEL	*pCard01PSA,*pCard02PSA,*pCard03PSA;
extern	NEWMODEL	*chuckBullet,*dennisBullet,*bugleBullet;

	   
extern VECTOR 	gloveVel, glovePos,oldGlovePos,oldBallPos;
extern VECTOR	GloveVel,JoinGlovePos,JoinBallPos;
extern VECTOR 	ballVel, ballPos, ballRot;
extern VECTOR 	cameraVel, cameraPos, cameraRot;
extern COLLDATA	ballColl,gloveColl,cameraColl,cameraProbeColl[2];

#define ANIM_QUEUE_LENGTH 10

typedef struct
{
	SHORT		fadeIn;
	SHORT		fadeOut;
	SHORT		gameActive;
	SHORT		state;
	SHORT		handFrameRate;
	SHORT		select;
	SHORT		dropOutFlag;
	SHORT		nextLevel;

	SHORT		wayroom_world;
	SHORT		hub_to_use;	// 1..8
	SHORT		previousLevel;	// used for deciding where to enter the hub from
	SHORT		port_with_ball;

	SHORT		reStartTimer;

	SHORT		MrTipActive;	// If one of these is set, then gamectrl.active (which the game-updating parts of the code check) is also set
	SHORT		PauseActive;
}GAME_CTRL;

extern	GAME_CTRL			gameCtrl;

// This should be move to menu when possable
typedef	struct
{
	SHORT	timeAllowed;
	SHORT	bestTime;
	char	name[3];
	UBYTE	levelOpen;
}TIMETRIALDATA;


// Okeydokey, here's the big "adventure mode" status structure for bunging into memory cards
// 60 garibs, 1 extra life, 3 crates, 1 chickencoop, 3 switches

// (I've left stuff like lives & score out of this structure (for now?) & just put the "architecture" stuff in it

// 12 mr tips
// 20 spare for now

#define HUB_STATUS_BITS (61 + 3 + 1 + 3 + 12 + 20)

#define LEVOPEN_L1_OPEN				 1
#define LEVOPEN_L2_OPEN				 2
#define LEVOPEN_L3_OPEN				 4
#define LEVOPEN_BOSS_OPEN			 8
#define LEVOPEN_BONUS_OPEN			16
#define LEVOPEN_BOSS_BEATEN			32
#define LEVOPEN_CRYSTAL_DELIVERED	64

#define GAMESTATE_VERSION 1
typedef struct GAMESTATESTR
{
	char version;	// DO NOT LOAD FROM A MEMORY CARD IF THIS DOESNT MATCH "GAMESTATE_VERSION"

// bit table of lives on levels that have been collected
//	short lifes_got[(SPACEBONUS+1) - ATLANTIS1];
	short	lives_got[5 * 6];
// bit table of hub garibs/xtralife/platform state
	int		hub_status[(HUB_STATUS_BITS + 15) >> 4];
// 5 bits = lev1,2,3,boss,bonus: level open for normal use (top 3 bits currently free)
// 32 = boss beaten
// 64 = crystal delivered
// (used for wayroom selection, hub secection)
	char	levels_open[6];

	short	lives;
	char	health;
	char	bhealth;
	char	maxhealth;	// for pickup hearts
	int		score;

	SVECTOR	hub_ball_pos;	// a bit more hubstate preservation...
	char	hub_ball_type;

}GAMESTATE;

extern GAMESTATE GameState;



////////////////////////////////////////////

typedef struct
{
	SHORT		numAnimations;
	SHORT		currentAnimation;
	BOOL		reachedEndOfAnimation;
	BOOL		loopAnimation;
	SHORT		animationSpeed;
	SHORT		queueAnimation[ANIM_QUEUE_LENGTH];
	BOOL		queueLoopAnimation[ANIM_QUEUE_LENGTH];
	SHORT		queueAnimationSpeed[ANIM_QUEUE_LENGTH];
	SHORT 		numberQueued;
	AnimType	*animInfo;
	SHORT		animTime;
}ACTOR_ANIMATION;

#define GAME_INLEVEL	0
#define GAME_EXITED		1
#define GAME_COMPLETED	2
#define GAME_TIMEDOUT	3
#define GAME_ERROR		4
#define GAME_FAILEDBONUS 5
#define GAME_BACKTOCASTLE 6

void	gameMainGame(int);
void	Control_Ball_And_Glove();

void	UpdateBallAndGlove();
void	pauseDisplay(void);
void	UpdateOverlays(void);


void	levelRestart(void);
void	UpdateGlovePos(void);
extern	VECTOR	BallStartPos;
extern	VECTOR	GloveStartPos;
extern	int		gameScore;
extern char	maxHealth;


extern UBYTE showGameOver;
void	loadCarnivalBonusModels(void);

//move this to menu when possable
void	timeTrialSelection(void);

void	loadPiratesModels(void);

typedef struct tagLEVELINFO
{
	unsigned char musictrack;
	unsigned char nextlevel;
	unsigned char world;
}LEVELINFO;

extern LEVELINFO LevelInfo[];


// value the powerwhack is until it hits something, at which point it counts down to zero

#define POWERWHACK_START 8

