/*============================================================*/
/*============================================================*/
/*==														==*/
/*==					Global Declarations					==*/
/*==														==*/
/*============================================================*/
/*============================================================*/

#pragma once
#include "Palettes.h"


/*========================================================  Constants  */

#define	kDisplay9Inch			1		/* Display Constants */
#define	kDisplay12Inch			2		/* we display on a 12" monitor */
#define	kDisplay13Inch			3		/* we display on a 13" or larger monitor */
#define	kSmallArena				1		/* we're using the small dish */
#define	kLargeArena				2		/* we have available the large dish */

#define	kIdleMode				0		/* Game modes - game is not in progress */
#define	kPlayMode				1		/* a game is in progress */

#define kLeftScoreSelector		0		/* score board & timer constants */
#define kRightScoreSelector		1		/* refers to the score on the right */
#define	kOnesPlace				2		/* the one's digit of the score/time */
#define	kTensPlace				1		/* the tens's digit of the score/time */
#define	kHundredsPlace			0		/* the hundreds's digit of the score */
#define	kMinutesPlace			0		/* the minutes's digit of the time */
#define	kBlankCharacter			10		/* constant meaning, 'No number' - blank */

#define kPlayerSelector			0		/* means this is the player structure */
#define kOpponentSelector		1		/* means this is the opponent structure */

#define kLeftGoal				0		/* goal selector constants */
#define kRightGoal				1		/* referes to the right hand goal */
#define	kSmInitLeftXPos			-3072	/* left goal constants */
#define	kSmInitLeftZPos			0		/* initial place for player to appear */
#define	kLgInitLeftXPos			-4096	/* and initial X position */
#define	kLgInitLeftZPos			0		/* and Z for the large arena */
#define	kSmInitRightXPos		3072	/* right goal constants */
#define	kSmInitRightZPos		0		/* for small arena - right position */
#define	kLgInitRightXPos		4096	/* and X position for player to begin */
#define	kLgInitRightZPos		0		/* and the Z position */

#define kBallFiring				0		/* Ball modes */
#define	kBallRolling			1		/* the ball is subject to the dish dynamics */
#define	kBallHeld				2		/* the ball is being carried */
#define kBallInStasis			3		/* the ball is waiting to be fired into arena */

#define kPlayerHolding			0		/* Ball modifiers */
#define kOpponentHolding		1		/* the opponent has the ball */
#define kNoOneLastHeld			2		/* no one has yet touched the ball */
#define kPlayerLastHeld			3		/* player was the last one touching ball */
#define kOpponentLastHeld		4		/* opponent was the last one touching ball */

#define kBallIsNotHere			0		/* Status of ball - for opponent decisions */
#define kBallRollsFreely		1		/* no one has caught the ball */
#define kPlayerHasBall			2		/* the player has grabbed the ball */
#define kOpponentHasBall		3		/* the opponent has grabbed the ball */

#define	kInArena				0		/* Person modes */
#define	kBeamingIn				1		/* in the process of fading in */
#define	kBeamingOut				2		/* in the process of fading out */
#define	kInStasis				3		/* waiting to be beamed in */

#define kStanding				0		/* Person display mode modifiers */
#define kCarrying				1		/* display graphic of player with ball */
#define kCrouching				2		/* display graphic of player crouching */

#define kNoOpponent				-1		/* Opponent/Player types (personas) */
#define kHumanPlayer			0		/* player is the user */
#define kSimpleGeorge			1		/* player is computer George */
#define kMadMara				2		/* player is computer Mara */
#define kHeavyOtto				3		/* player is computer Otto */
#define kCleverClaire			4		/* player is computer Claire */
#define kMisterEaze				5		/* player is computer Eaze */
#define kMissTeak				6		/* player is computer Teak */
#define kNetHuman				7		/* player is a human on the network */

#define kRunDiagonal			0		/* goal-scoring selectors */
#define kRunCircle				1		/* run around the edge of dish to score */

#define kFacingSouth			0		/* Directional constants */
#define kFacingSouthEast		1		/* facing bottom-right corner of screen */
#define kFacingEast				2		/* facing right edge of screen */
#define kFacingNorthEast		3		/* facing top-right corner of screen */
#define kFacingNorth			4		/* facing away from user */
#define kFacingNorthWest		5		/* facing top-left corner of screen */
#define kFacingWest				6		/* facing left edge of screen */
#define kFacingSouthWest		7		/* facing bottom-left corner of screen */
#define kFacingRested			8		/* player is centered (facing user) */
#define kLastDirection			7		/* last (maximum) direction */
#define kFirstDirection			0		/* first (minimum) direction */

#define kNoOneWon				0		/* constant describing who won a game */
#define kPlayerWon				1		/* player has won the game */
#define kOpponentWon			2		/* the opponent has won the game */

#define kDoorIsClosed			0		/* Ball-firing door constants */
#define kDoorIsOpen				1		/* selector constants */
#define kLeftDoor				0		/* which door selectors */
#define kRightDoor				1		/* which door selectors */
#define kDoorPhases				16		/* game loops door remains open */

#define kMaxReplayFrames		300		/* frames preserved for instant replay */
#define kLoopLimitOnHeldBall	1200	/* # of frames allowed to hold ball (20 s) */
#define kTimingScale			46		/* kLoopLimitOnHeldBall / 26 pixels */
#define kLoopLimitOnIdleBall	1800	/* # of frames allowed for dead ball (30 s) */
#define kAddForceFract			4		/* fraction of force added when crouching */
#define kCriticalFoul			3		/* this # fouls -> give other player point */
#define kRoundSeconds			240		/* 240 seconds = 4 minutes */
#define kLengthOfPenalty		60		/* animation "loops" left out of arena */

#define kHooplaTime				600		/* ticks winner has to show off */
#define kCrowdClosingHoopla		500		/* ticks crowd/mob carry on after game */

#define	kTickDelay				1L		/* minimum (& ideal) time for 1 game loop */
#define kEndOfFadeSequence		68		/* 'frames' - duration of fade in/out */
#define kVelocitySensitive		8		/* was 8 ... smaller = more sensitive */
#define kFrictionFraction		128		/* was 128 ... smaller = more friction */
#define	kPlayerInputSensitive	3		/* smaller is MORE sensitive */
#define kMaxBoardForceLg		64		/* max force applied when skating was 64 */
#define kMaxBoardForceSm		57		/* max force applied when skating was 57 */
#define kPersonImpulse			18		/* force with which ball is thrown (was 16) */
#define kNumberOfStars			256		/* number of stars in resource (blinking) */
#define kNumberOfStarColors		3		/* for color, number of colors to animate */
#define kFramesToSkip			6		/* number of frames to skip for PowerBooks */

#define kXComponent				0		/* constant for arrays involving x & z */
#define kZComponent				1		/* this one refers to the z component */

#define	kOutOBounds				-12345	/* Force Table constants */
#define	kBackBoard				-2345	/* in force array, refers to the backboard */
#define	kGoalPath				-345	/* signifies hole (goal path) used to score */

#define kIsNormal				0		/* Flag constants */
#define kIsOutOfBounds			1		/* means the player/ball has left the dish */
#define kIsRebounding			2		/* the player/ball has hit the backboard */
#define kIsInGoal				3		/* the ball is in the goal (ding! ding!) */

#define kPlayerSrc				0		/* refers to the player source indicee */
#define kOpponentSrc			1		/* refers to the opponent source indicee */
#define kMask					0		/* refers to a standard mask indicee */
#define kFadeMask				1		/* refers to the fad mask indicee */

#define kSmallDishDataID		1000	/* resource ID's for small arena data */
#define kLargeDishDataID		1001	/* resource ID's for large arena data */

#define	rArenaPictSm1BitID		1000	/* PICT Resource ID Constants */
#define	rArenaPictSm4BitID		1001	/* 16 color small arena PICT */
#define	rArenaPictLg4BitID		1002	/* 16 color large arena PICT */
#define	rArenaPictLg8BitID		1003	/* 256 color large arena PICT <unimp.> */
#define	rArenaPictLg1BitID		1004	/* b&w large arena PICT */
#define	rPartsPict1BitID		1010	/* bits (hah) and pieces b&w PICT */
#define	rPartsPict4BitID		1011	/* the same for 16 colors */
#define	rPartsPict8BitID		1012	/* and for 256 colors <unimplemented> */
#define	rMaskPict1ID			1020	/* mask PICT with 1 pixel outline */
#define	rMaskPict48ID			1021	/* mask PICT for color (no outline) */
#define	kAnnouncerPict1ID		1100	/* the basic announcer PICT for b&w */
#define	kAnnouncerPict4ID		1101	/* the 16 color announcer PICT */
#define	kBalloon1PictID			2000	/* and the Pow! balloon PICT for b&w */
#define	kBalloon4PictID			2001	/* the 16 color Pow! balloon */
#define rAbortGameAlertID		1009	/* alert warning player */
#define rCantRepeatAlertID		1011	/* alert informing user of repeated tourny */
#define rHelpDialogID			3000	/* ID for help dialog */
#define rHelpBasePictID			3100	/* ID for first PICT in help dialog */

#define rNamesStringID			1000	/* the opponents names */
#define rMiscStrings			1001	/* other miscellaneous strings */

#define kMaxNumberOfSounds		26		/* number of 'primary' game sounds */
#define kMaxIncidentalSounds	3		/* number of 'incidental' sounds */
#define	kLastIncidentalSounds	28		/* ID of last incidental sound */
#define kClashSound				1		/* sound ('SMSD') resource ID numbers */
#define kRicochetSound			2		/* these are the primary game sounds */
#define kScoreSound				3		/* sound of a goal being scored */
#define kBallFiringSound		4		/* sound of ball firing onto arena */
#define kBeamInSound			5		/* sound of player beaming in*/
#define kBeamOutSound			6		/* and sound of player beaming out */
#define kFoulSound				7		/* sound made by the foul bell */
#define kBallPickUpSound		8		/* sound of player grabbing up the ball */
#define kCrowdSound				9		/* the soft crowd drone in background */
#define kCrowdSwellSound		10		/* the crowd sound rises in volume */
#define kApplauseSound			11		/* full-out loud crowd appluase */
#define kCrowdFadeSound			12		/* and the crowd fades back down */
#define kBellSound				13		/* the bell (end of period/game) sound */
#define kMobSwellSound			14		/* the booing-crowd sound gets louder */
#define kMobSound				15		/* loudest booing crowd */
#define kMobFadeSound			16		/* and the crowd fades back down */
#define kHoldingSound			17		/* the warning sound "Holding" */
#define kGameSound				18		/* part one of "Game Point" sound */
#define kPointSound				19		/* referee saying second half - "Époint" */
#define kBallDropSound			20		/* ball being released by player */
#define kBrakeSound				21		/* when brakes are applied */
#define kAllSound				22		/* part one of "All Tied" sound */
#define kTiedSound				23		/* referee saying second half - "Étied" */
#define kIdleSound				24		/* when ball is idle (about beamed out) */
#define kOverSound				25		/* "Game over" sound (goes with kGameSound) */
#define kBeerManSound			26		/* incidental "Beer man!" shout */
#define kHotDogSound			27		/* incidental "Hot dog!" shout */
#define kProgramSound			28		/* incidental "Program!" shout */
#define kLadiesSound			100		/* one-time sounds, load-when-needed */
#define kAndSound				101		/* of "Ladies - and - gentlemen" */
#define kGentlemenSound			102		/* the announcer saying "Égentlemen" */
#define kParSound				103		/* announcer saying "Pair - uh - reenuh!" */
#define kASound					104		/* the "-a-" from "Éa-rena" */
#define kRenaSound				105		/* the "É-rena" sound */

#define kApplauseSwellTicks		16		/* really 15.959 */
#define kApplauseFadeTicks		20		/* really 20.013 */
#define kMobSwellTicks			21		/* really 21.566 */
#define kMobFadeTicks			21		/* really 21.566 */

#define kClashPriority			0x2700	/* sound priority for above sound */
#define kRicochetPriority		0x2704	/* sound priority for above sound */
#define kScorePriority			0x6704	/* sound priority for above sound */
#define kBallFiringPriority		0x4700	/* sound priority for above sound */
#define kBeamInPriority			0x4704	/* sound priority for above sound */
#define kBeamOutPriority		0x4708	/* sound priority for above sound */
#define kFoulPriority			0x6700	/* sound priority for above sound */
#define kBallPickUpPriority		0x2708	/* sound priority for above sound */
#define kCrowdPriority			0x7FF0	/* sound priority for above sound */
#define kCrowdSwellPriority		0x7FF0	/* sound priority for above sound */
#define kApplausePriority		0x7FF0	/* sound priority for above sound */
#define kCrowdFadePriority		0x7FF0	/* sound priority for above sound */
#define kBellPriority			0x6708	/* sound priority for above sound */
#define kMobSwellPriority		0x7FF0	/* sound priority for above sound */
#define kMobPriority			0x7FF0	/* sound priority for above sound */
#define kMobFadePriority		0x7FF0	/* sound priority for above sound */
#define kHoldingPriority		0x670C	/* sound priority for above sound */
#define kGamePriority			0x470C	/* sound priority for above sound */
#define kPointPriority			0x4710	/* sound priority for above sound */
#define kBallDropPriority		0x270C	/* sound priority for above sound */
#define kBrakePriority			0x2710	/* sound priority for above sound */
#define kAllPriority			0x4600	/* sound priority for above sound */
#define kTiedPriority			0x4604	/* sound priority for above sound */
#define kIdlePriority			0x4712	/* sound priority for above sound */
#define kOverPriority			0x4714	/* sound priority for above sound */

#define	kPracticeBoardin		1		/* various game scenarios (sets of rules) */
#define	kPracticeScoring		2		/* play around with the ball - no opponent */
#define	kStandardGame			3		/* modified volleyball rule variation */
#define	kTournament				4		/* player first to 13 wins */

#define kLittleLeague			0		/* league constants defined */
#define kJuniorVarsity			1		/* league constants defined */
#define kVarsity				2		/* league constants defined */
#define kMinorLeague			3		/* league constants defined */
#define kProfessional			4		/* league constants defined */

#define kGameIsOverMessage		-1		/* net-game ... game is resolved */
#define kPausedMessage			-2		/* net-game ... other player has paused */
#define kInstantReplayMessage	-3		/* net-game ... other player in instant replay */
#define kAbortGameMessage		-4		/* net-game ... other player stopped game */
#define kEndGameMessage			-5		/* net-game ... game has ended */
#define kConfirmMessage			-9		/* net-game ... confirms messg. recvd. */

#define kUnplayedState			0		/* states for player stats flags */
#define kLostState				1		/* indicates played and lost */
#define kWonState				2		/* indicates played and won */
#define kSkunkedState			3		/* indicates played and won 5 to 0 */


/*========================================================  Structs Defined  */

typedef short forceData[41][41][2];				/* from 'forc' resource */

typedef short vertData[41][81];					/* from 'vert' resource */

typedef Point starData[kNumberOfStars];			/* from 'sPts' resource */

typedef char string31[32];

typedef struct									/* defines player object */
{
	Rect		isRect;							/* current bounds rect */
	Rect		wasRect;						/* old bounds rect */
	Rect		srcRect;						/* source rect for graphic */
	Rect		maskRect;						/* mask rect for graphic */
	long		srcAddr, maskAddr;				/* for asm graphics */
	short		xPos, zPos;						/* real x & z position of player */
	short		xVel, zVel;						/* real x & z velocity of player */
	short		hMouse, vMouse;					/* screen centered mouse position */
	short		direction, posture;				/* direction player facing & posture */
	short		flag, persona, selector;		/* situations, who's acting?, who? */
	short		strategy, turnCount, turnNow;	/* used for running-the-circle shots */
	short		teaksThresh, whichGoal;			/* for Miss Teak only!, left/right */
	short		initXPos, initZPos;				/* initial x & z position of player */
	short		justHitWall;					/* flags a recent collision */
	short		justHitBall;					/* flags a recent collision */
	short		justHitOpponent;				/* flags a recent collision */
	short		loopsBallHeld;					/* keeps track of # of loops ball held */
	char		mode;							/* mode player is in */
	char		dirFlagSrc;						/* for selecting src entities */
	char		postFlagSrc;					/* ditto */
	char		arrayFlagMask, dirFlagMask;		/* for selecting src & mask entities */
	char		postFlagMask;					/* ditto */
	char		brakeApplied;					/* flags whether brake is applied */
	char		bashApplied;					/* flags whether bashing key applied */
	Boolean		buttonIs;						/* the state of the mouse button */
	Boolean		mouseWasLetUp;					/* did human release mouse button */
} playerType;

typedef struct									/* defines ball object */
{
	Rect		isRect;							/* current bounds rect */
	Rect		wasRect;						/* old bounds rect */
	Rect		srcRect;						/* source pixMap bounds rect */
	Rect		eraser;							/* kludge to hold rect for erasing */
	short		xPos, zPos;						/* real x & z position of ball */
	short		xVel, zVel;						/* real x & z velocity of ball */
	short		modifier;						/* ball modifier */
	short		flag;							/* flags various situations detected */
	short		initXPos, initZPos;				/* initial x & z position of ball */
	short		initXVel, initZVel;				/* initial x & z velocity of ball */
	short		justHitWall;					/* flags a recent collision */
	short		loopsBallIdle;					/* counts frames ball idle */
	char		mode;							/* mode ball is in */
	Boolean		eraseTheBall;					/* a kludge to flag a clean erase */
	Boolean		dontDraw;						/* kludge for the ball out of bounds */
} ballType;

typedef struct
{
	Rect		srcRects[2][2];					/* rects containing door src graphics */
	Rect		destRects[2];					/* dest rects for left & right doors */
	long		srcAddrs[2][2];					/* screen address for asm graphics */
	long		screenDestAddr[2];				/* screen address for asm graphics */
	long		workDestAddr[2];				/* off-work address for asm graphics */
	long		backDestAddr[2];				/* background address for asm graphics */
	short		phase;							/* phase of the door, by 0 it closes */
	char		doorState;						/* 0 if closed, 1 if open */
	char		doorOpen;						/* 0 if left open, 1 if right */
	Boolean		stateChanged;					/* boolean flagging an open or a close */
} doorType;

typedef struct									/* defines a digit of timer/score */
{
	Rect		srcRects[11];					/* source of digits 0-9 and <blank> */
	Rect		destRects[3];					/* dest rects for up to 3 digits */
	Rect		lightDest[4];					/* dest rects for the little lights */
	long		srcAddrs[11];					/* source address for asm graphics */
	long		destAddrs[3];					/* screen dest address for asm */
} digiDispType;

typedef struct									/* defines board cursor structure */
{
	Rect		isRect;							/* current bounds rect */
	Rect		wasRect;						/* old bounds rect */
	Rect		srcRect;						/* source pixMap bounds rect */
	long		srcAddr, maskAddr;				/* for the ol' asm. */
	short		xPos, zPos;						/* real x & z position of cursor */
	Boolean		isVisible;						/* kludge for the ball out of bounds */
} cursorType;

typedef struct									/* net data struct sent to slave game */
{
	short		messageType;					/* 2 bytes */
	long		ballIsPoint;					/* 4 bytes */
	long		eraserPoint;					/* 4 bytes */
	long		playerIsPoint;					/* 4 bytes */
	long		opponentIsPoint;				/* 4 bytes */
	short		opponentXPos;					/* 2 bytes */
	short		opponentZPos;					/* 2 bytes */
	char		playerArrayDirSrc;				/* 1 byte */
	char		playerPostArray;				/* 1 byte */
	char		playerDirPostMask;				/* 1 byte */
	char		opponentArrayDirSrc;			/* 1 byte */
	char		opponentPostArray;				/* 1 byte */
	char		opponentDirPostMask;			/* 1 byte */
	char		ballWhosMode;					/* 1 byte */
	char		playerOpponentMode;				/* 1 byte */
	char		bitFlags;						/* 1 byte */
	char		packedFoulsRead;				/* 1 byte */
	char		playerScoreReads;				/* 1 byte */
	char		opponentScoreReads;				/* 1 byte */
	char		soundPlayed;					/* 1 byte */
	char		padding;						/* 1 byte, total = 36 */
} masterSendType;

typedef struct									/* net data struct sent from slave */
{
	short		messageType;					/* 2 bytes */
	short		mouseH;							/* 2 bytes */
	short		mouseV;							/* 2 bytes */
	char		bits;							/* 1 byte */
	char		padding;						/* 1 byte, total = 8 */
} slaveSendType;

typedef struct
{
	Rect		playerIs;
	Rect		opponentIs;
	Rect		ballIs;
	char		playerArraySrc;
	char		playerDirSrc;
	char		playerPostSrc;
	char		playerArrayMask;
	char		playerDirMask;
	char		playerPostMask;
	char		playerMode;
	char		opponentArraySrc;
	char		opponentDirSrc;
	char		opponentPostSrc;
	char		opponentArrayMask;
	char		opponentDirMask;
	char		opponentPostMask;
	char		opponentMode;
	char		ballMode;
	char		wheresBall;
	Boolean		ballDontDraw;
} frameType;

typedef struct
{
	frameType	data[kMaxReplayFrames];
	short		frame, lastFrame;
	short		hVel, vVel;
}	replayType, *replayPtr;

typedef struct
{
	short		wasDepth, isDepth;				/* bit depth before/currently */
	Boolean		hasWNE, hasSystem7;				/* various attributes */
	Boolean		hasColor, hasGestalt;			/* various attributes */
	Boolean		canSwitch, canColor;			/* various attributes */
} macEnvironment;

typedef struct
{
	short			number;
	short			priority;
	short			when;
} soundQueue;

typedef struct
{
	long			tournamentTime;
	long			bestPlatinumTime;
	short			copperTitles;
	short			bronzeTitles;
	short			silverTitles;
	short			goldTitles;
	short			platinumTitles;
	short			played;
	short			won;
	short			goals;
	short			fouls;
	short			criticals;
	short			oppGoals;
	short			oppFouls;
	short			oppCriticals;
	short			georgeState;
	short			maraState;
	short			ottoState;
	short			claireState;
	short			eazeState;
	short			teakState;
} statType;

typedef struct									/* defines preference format */
{
	short			prefVersion;
	short			unusedShort;
	long			timeWas;
	long			encryption;
	statType		wasStats[10];
	string31		mostTitlesName;
	long			mostTitlesDate;
	short			mostTitles;
	string31		mostPointsName;
	long			mostPointsDate;
	short			mostPoints;
	string31		mostFoulsName;
	long			mostFoulsDate;
	short			mostFouls;
	string31		mostCritsName;
	long			mostCritsDate;
	short			mostCrits;
	string31		namesWere[10];
	short			opponentWas;
	short			playerWas;
	short			gameWas;
	short			wasVolume;
	short			wasLeague;
	short			wasTeaksThresh[10];
	Boolean			wasUseQD;
	Boolean			wasAutoTeams;
	Boolean			replayGoalsWas;
	Boolean			replayFoulsWas;
	Boolean			replayOnRWas;
	Boolean			wasShowCursor;
	Boolean			leftGoalWasPlayers;
	Boolean			wasSoundOn;
	Boolean			wasBeamSoundOn;
	Boolean			wasIncidentSoundOn;
	Boolean			wasCollisionSoundOn;
	Boolean			wasCrowdSoundOn;
	Boolean			wasSetDepth;
	Boolean			wasAnnouncer;
	Boolean			wasBackground;
	Boolean			wasZooms;
	Boolean			wasReplayZooms;
	Boolean			wasSkipFrames;
	Boolean			wasNetOnly;
} prefsInfo;

