#include "generic.h"
#include "teamdata.h"
#include "file.h"
#include "memory.h"

#define NULL 0


#define TEAM_BULLS 4
#define TEAM_SONICS 25


#define aiffID(ch0, ch1, ch2, ch3) \
                ((UD)(UB)(ch3)        | \
                ((UD)(UB)(ch2) <<  8) | \
                ((UD)(UB)(ch1) << 16) | \
                ((UD)(UB)(ch0) << 24 ))


/*

Options_T
	{
	0,	//SB                  sb___OptionSrc;				// 0
	0,	//SB                  sb___OptionTyp;				// 1
	0,	//SB                  sb___SeasonLength;			// 2
	0,	//SB                  sb___TradeDeadline;			// 3
	0,	//SB                  sb___PlayoffSource;			// 4
	0,	//SB                  sb___PlayoffLength;			// 5
	0,	//SB                  sb___CustomRoster;			// 6
	0,	//SB                  sb___QuarterLen;			// 7
	0,	//SB                  sb___Difficulty;			// 8
	0,	//SB                  sb___DefFouls;				// 9
	0,	//SB                  sb___OffFouls;				// 10
	0,	//SB                  sb___FoulOuts;				// 11
	0,	//SB                  sb___OutOfBounds;			// 12
	0,	//SB                  sb___BackCourt;				// 13
	0,	//SB                  sb___Traveling;				// 14
	0,	//SB                  sb___GoalTending;			// 15
	0,	//SB                  sb___IllegalDef;			// 16
	0,	//SB                  sb___3InTheKey;				// 17
	0,	//SB                  sb___5SecInbounds;			// 18
	0,	//SB                  sb___10SecHalfcourt;		// 19
	0,	//SB                  sb___ShotClock;				// 20
	0,	//SB                  sb___Fatigue;				// 21
	0,	//SB                  sb___Injuries;				// 22
	0,	//SB                  sb___Padding0;				// 23

	0,	//SW                  sw___PlayoffIndx;			// 24
	0,	//SW                  sw___SeasonMatch;			// 26
	0,	//UD                  ud___SeasonTeams;			// 28
	0,	//UD                  ud___PlayoffTeams;			// 32
	};									// 36
*/

global	Preferences_T       cl___gPreferences =
	{
	0,						// 0  ud___PrefChecksum;
	0,						// 4  sb___PrefVersion;
	0,						// 5  sb___PrefRandom;
	24,						// 6  sb___VolMusic;
	24,						// 7  sb___VolSound;
	24,						// 8  sb___VolCrowd;
	24,						// 9  sb___VolSpeech;

	#ifdef JAPAN
	0,						// 10 sb___Mono;
	1,						// 11 sb___SpecialCameras; IN-GAME
	#else
	1,						// 10 sb___Mono;
	0,						// 11 sb___SpecialCameras;
	#endif

	1,						// 12 sb___IndicatePlayer;
	1,						// 13 sb___IndicatePassing;
	1,						// 14 sb___IndicateRebound;
	1,						// 15 sb___IndicateTurbo;

	#ifdef JAPAN
	1,						// 16 sb___ShowClock;
	#else
	0,						// 16 sb___ShowClock;
	#endif

	1,						// 17 sb___ShowStatistics;
	0,						// 18 sb___AutoPlyrSwitch;
	64,						// 19 ub___ZoomSetting;
	0,						// 20 sb___Padding0;
	0,						// 21 sb___Padding1;
	0,						// 22 sb___Padding2;
	0						// 23 sb___Padding3;
	};						// 24

//
// Current Match.
//

#define	HOME_TEAM           0
#define	AWAY_TEAM           1
#define	NULL_TEAM           2
#define	BOTH_TEAM           3					// Only used in the shell.
#define	EVERYBODY           4					// Only used in the shell.




PlyrRamData_T pl[10];

PlyrRamData_T *homePlyrs[5]={
	&pl[0],
	&pl[1],
	&pl[2],
	&pl[3],
	&pl[4],
};

PlyrRamData_T *awayPlyrs[5]={
	&pl[5],
	&pl[6],
	&pl[7],
	&pl[8],
	&pl[9],
};



//
// ROM Team Data Structure Definition
//

static TeamRomData_T
	team1romdata =
	{
		NULL,   //           pcz__tCity;				//  0
		NULL,   //           pcz__tName;				//  4
		NULL,   //           pcz__tAbbr;				//  8
		NULL,   //           pcz__tCityName;			// 12

		0,      //            ub___tConference;		// 16
		0,      //            ub___tDivision;			// 17
		TEAM_SONICS,      //            ub___tTeam;				// 18
		0,			//		ub___tRatScoring;		// 19
		0,			//		ub___tRatRebound;		// 20
		0,			//		ub___tRatControl;		// 21
		0,			//		ub___tRatDefense;		// 22
		0,			//		ub___tRatOverall;		// 23

		0,			//		ub___tDefaultSet0;		// 24
		0,			//		ub___tDefaultSet1;		// 25
		0,			//		ub___tPadding0;			// 26
		0,			//		ub___tPadding1;			// 27

		//	cl___tStatNBA;			// 28
		{
			0,      //            wb___tGP;				//  0
			0,      //            wb___tGW;				//  2
			0,      //            uw___tFGM;				//  4 (just FGM, not FGM+3PM)
			0,      //            uw___tFGA;				//  6(just FGA, not FGA+3PA)
			0,      //            uw___t3PM;				//  8
			0,      //            uw___t3PA;				// 10
			0,      //            uw___tFTM;				// 12
			0,      //            uw___tFTA;				// 14
			0,      //            uw___tAST;				// 16
			0,      //            uw___tSTL;				// 18
			0,      //            uw___tBLK;				// 20
			0,      //            uw___tDEF;				// 22
			0,      //            uw___tOFF;				// 24
			0,      //            uw___tPF;				// 26
			0, 	    //             uw___tTO;				// 28
			0 	    //             uw___tTF;				// 30
		}							// 32

	},
	team2romdata =
	{
		NULL,   //           pcz__tCity;				//  0
		NULL,   //           pcz__tName;				//  4
		NULL,   //           pcz__tAbbr;				//  8
		NULL,   //           pcz__tCityName;			// 12

		0,      //            ub___tConference;		// 16
		0,      //            ub___tDivision;			// 17
		TEAM_BULLS,      //            ub___tTeam;				// 18
		0,			//		ub___tRatScoring;		// 19
		0,			//		ub___tRatRebound;		// 20
		0,			//		ub___tRatControl;		// 21
		0,			//		ub___tRatDefense;		// 22
		0,			//		ub___tRatOverall;		// 23

		0,			//		ub___tDefaultSet0;		// 24
		0,			//		ub___tDefaultSet1;		// 25
		0,			//		ub___tPadding0;			// 26
		0,			//		ub___tPadding1;			// 27

		//	cl___tStatNBA;			// 28
		{
			0,      //            wb___tGP;				//  0
			0,      //            wb___tGW;				//  2
			0,      //            uw___tFGM;				//  4 (just FGM, not FGM+3PM)
			0,      //            uw___tFGA;				//  6(just FGA, not FGA+3PA)
			0,      //            uw___t3PM;				//  8
			0,      //            uw___t3PA;				// 10
			0,      //            uw___tFTM;				// 12
			0,      //            uw___tFTA;				// 14
			0,      //            uw___tAST;				// 16
			0,      //            uw___tSTL;				// 18
			0,      //            uw___tBLK;				// 20
			0,      //            uw___tDEF;				// 22
			0,      //            uw___tOFF;				// 24
			0,      //            uw___tPF;				// 26
			0, 	    //             uw___tTO;				// 28
			0 	    //             uw___tTF;				// 30
		}							// 32

	};							// 56


global TeamRamData_T cl___gHomeTeam={

	&team1romdata,		//TeamRomData_T *     pcl__tTeamRom;	  pcl__tTeamRom;
	NULL,		//PlyrRamData_T *     pcl__tPlyrRam;	  pcl__tPlyrRam;	//
	NULL,		//										  pcl__tPlyrSim;	//
	homePlyrs,	//PlyrRamData_T **    ppcl_tPlyrLst;	  ppcl_tPlyrLst;	//

	0,			//SB    sb___tPlayers;					  sb___tPlayers;
	0,0,0,0,0,	//SB    asb__tPlaying [5];				  asb__tPlaying [5];
	0,0,0,0,0,	//SB    sb__tStarter [5];				  asb__tStarter [5];

	0,			//UB    ub___tTimeouts;					  ub___tInAMatch;
	0,			//UB    ub___tTimeouts;					  ub___tTimeOuts;
	0,			//UB    ub___tWon;						  ub___tWon;
	0,			//UW    uw___tPoints;					  uw___tPoints;

	//TeamRamStat_T     cl___tStatGame;					  cl___tStatGame;
	0,			//UB    ub___tGP;				//  0	  cl___tStatSeason;
	0,			//UB    ub___tDQ;				//  1
	0,			//UW    uw___tPF;				//  2	  si___tLastScored;
	0,			//UW    uw___tFGM;				//  4	  si___tLastDrought;
	0,			//UW    uw___tFGA;				//  6
	0,			//UW    uw___t3PM;				//  8
	0,			//UW    uw___t3PA;				// 10
	0,			//UW    uw___tFTM;				// 12
	0,			//UW    uw___tFTA;				// 14
	0,			//UW    uw___tAST;				// 16
	0,			//UW    uw___tSTL;				// 18
	0,			//UW    uw___tBLK;				// 20
	0,			//UW    uw___tOFF;				// 22
	0,			//UW    uw___tDEF;				// 24
	0,			//UW    uw___tTO;				// 26

	//TeamRamStat_T     cl___tStatSeason;
	0,			//UB    ub___tGP;				//  0
	0,			//UB    ub___tDQ;				//  1
	0,			//UW    uw___tPF;				//  2
	0,			//UW    uw___tFGM;				//  4
	0,			//UW    uw___tFGA;				//  6
	0,			//UW    uw___t3PM;				//  8
	0,			//UW    uw___t3PA;				// 10
	0,			//UW    uw___tFTM;				// 12
	0,			//UW    uw___tFTA;				// 14
	0,			//UW    uw___tAST;				// 16
	0,			//UW    uw___tSTL;				// 18
	0,			//UW    uw___tBLK;				// 20
	0,			//UW    uw___tOFF;				// 22
	0,			//UW    uw___tDEF;				// 24
	0,			//UW    uw___tTO;				// 26

};


global TeamRamData_T cl___gAwayTeam={
	&team2romdata,		//TeamRomData_T *     pcl__tTeamRom;
	NULL,		//PlyrRamData_T *     pcl__tPlyrRam;
	NULL,
	awayPlyrs,	//PlyrRamData_T **    ppcl_tPlyrLst;

	0,			//SB    sb___tPlayers;
	0,0,0,0,0,	//SB    asb__tPlaying [5];
	0,0,0,0,0,	//SB    sb__tStarter [5];

	0,			//UB    ub___tTimeouts;
	0,			//UB    ub___tTimeouts;
	0,			//UB    ub___tWon;
	0,			//UW    uw___tPoints;

	//TeamRamStat_T     cl___tStatGame;
	0,			//UB    ub___tGP;				//  0
	0,			//UB    ub___tDQ;				//  1
	0,			//UW    uw___tPF;				//  2
	0,			//UW    uw___tFGM;				//  4
	0,			//UW    uw___tFGA;				//  6
	0,			//UW    uw___t3PM;				//  8
	0,			//UW    uw___t3PA;				// 10
	0,			//UW    uw___tFTM;				// 12
	0,			//UW    uw___tFTA;				// 14
	0,			//UW    uw___tAST;				// 16
	0,			//UW    uw___tSTL;				// 18
	0,			//UW    uw___tBLK;				// 20
	0,			//UW    uw___tOFF;				// 22
	0,			//UW    uw___tDEF;				// 24
	0,			//UW    uw___tTO;				// 26

	//TeamRamStat_T     cl___tStatSeason;
	0,			//UB    ub___tGP;				//  0
	0,			//UB    ub___tDQ;				//  1
	0,			//UW    uw___tPF;				//  2
	0,			//UW    uw___tFGM;				//  4
	0,			//UW    uw___tFGA;				//  6
	0,			//UW    uw___t3PM;				//  8
	0,			//UW    uw___t3PA;				// 10
	0,			//UW    uw___tFTM;				// 12
	0,			//UW    uw___tFTA;				// 14
	0,			//UW    uw___tAST;				// 16
	0,			//UW    uw___tSTL;				// 18
	0,			//UW    uw___tBLK;				// 20
	0,			//UW    uw___tOFF;				// 22
	0,			//UW    uw___tDEF;				// 24
	0,			//UW    uw___tTO;				// 26

	0,			//SI	si___gLastDrought
	0,			//SI	si___g



};


ThisMatch_T this_match={

2,2,2,2,				 //asb__mPads[4];
0,						 //ud___mNewPads;
25,4,					 //asb__mTeam[2];
0,						 //sb___mMaxTeamFouls;
0,						 //sb___mMaxPlyrFouls;
0,						 //sb___mQuarter;
0,						 //sb___mEditing;
0,						 //sb___mPadding1;
0,						 //sb___mPadding2;
0,						 //si___m30HzClk;
0,					 //pcl__mOptions;
0,0,				 //apcl_mTeamRom[2];
//&cl___gHomeTeam,
//&cl___gAwayTeam,
&cl___gHomeTeam,		 //apcl_mTeamRam[2];
&cl___gAwayTeam,

};

ThisMatch_T *pcl__gMatch = &this_match;

#define	P01	1
#define	P02	2
#define	P03	3
#define	P04	4
#define	P05	5
#define	P06	6
#define	P07	7
#define	P08	8
#define	P09	9
#define	P10	10
#define	P11	11
#define	P12	12
#define	P13	13

#define	Pxx	1

global PlyrRomData_T PlyrRomArray[] =

	{
	"Payton",		   //pcz__pSName;
	"Gary",            //pcz__pCName;
					   //
	289,				   //uw___pIndx;

	TEAM_SONICS,       //ub___pTeam;
	20,                //ub___pNum;
	POS_G,			   //ub___pPos;
	HGT(6,4),          //ub___pHgt;
	WGT(190),          //ub___pWgt;
	AGE(25,5,68+1),    //ub___pAge;
	8,	               //ub___pExp;
	3,				   //ub___pSkin;
	0,				   //ub___pAcc0;
	0,				   //ub___pAcc1;
	1,				   //ub___pDunks;
	4,				   //ub___pPostUps;
					   //
    (UB)(4),     	   //ub___pAttrRange;
    (UB)(96),     	   //ub___pAttrFG;
    (UB)(76),     	   //ub___pAttr3P;
    (UB)(74),     	   //ub___pAttrFT;
    (UB)(62),     	   //ub___pAttrRebOff;
    (UB)(62),     	   //ub___pAttrRebDef;
    (UB)(100),     	   //ub___pAttrSteal;
    (UB)(96),     	   //ub___pAttrPass;
    (UB)(29),     	   //ub___pAttrBlock;
    (UB)(1),     	   //ub___pAttrFoul;
    (UB)(95),     	   //ub___pAttrDribble;
    (UB)(100),     	   //ub___pAttrSpeed;
    (UB)(80),     	   //ub___pAttrJump;
    (UB)(55),     	   //ub___pAttrDunk;
    (UB)(64),     	   //ub___pAttrGoto;
    (UB)(100),     	   //ub___pAttrStrength;
    (UB)(100),     	   //ub___pAttrStamina;
	(UB)(82),		   //ub___pAttrInjury;

	 0,				   //  0
	 0,				   //  1
	 0,				   //  2
	 0,				   //  4 (just FGM, not FGM+3PM)
	 0,				   //  6 (just FGA, not FGA+3PA)
	 0,				   //  8
	 0,				   // 10
	 0,				   // 12
	 0,				   // 14
	 0,				   // 16
	 0,				   // 18
	 0,				   // 20
	 0,				   // 22
	 0,				   // 24
	 0,				   // 26
	 0,				   // 28 (1/4 minute resolution)
	 0,				   // 30


	"Hawkins",             /* SName                003*/
	"Hersey",           /* CName*/

	290,					//uw___pIndx;

	TEAM_SONICS,     	//ub___pTeam;
	33,              	//ub___pNum;
	POS_G,				//ub___pPos;
	HGT(6,3),        	//ub___pHgt;
	WGT(190),        	//ub___pWgt;
	AGE(25,5,68+1),  	//ub___pAge;
	4,	             	//ub___pExp;
	3,					//ub___pSkin;
	0,				   //ub___pAcc0;
	0,				   //ub___pAcc1;
	0,				   //ub___pDunks;
	2,				   //ub___pPostUps;

    (UB)(4),     	//ub___pAttrRange;		// 26
    (UB)(87),     	//ub___pAttrFG;			// 27
    (UB)(90),     	//ub___pAttr3P;			// 28
    (UB)(87),     	//ub___pAttrFT;			// 29
    (UB)(65),     	//ub___pAttrRebOff;		// 30
    (UB)(65),     	//ub___pAttrRebDef;		// 31
    (UB)(97),     	//ub___pAttrSteal;		// 32
    (UB)(73),     	//ub___pAttrPass;			// 33
    (UB)(14),     	//ub___pAttrBlock;		// 34
    (UB)(1),     	//ub___pAttrFoul;			// 35
    (UB)(78),     	//ub___pAttrDribble;		// 36
    (UB)(91),     	//ub___pAttrSpeed;		// 37
    (UB)(78),     	//ub___pAttrJump;			// 38
    (UB)(48),     	//ub___pAttrDunk;			// 39
    (UB)(2),     	//ub___pAttrGoto;			// 40
    (UB)(59),     	//ub___pAttrStrength;		// 41
    (UB)(80),     	//ub___pAttrStamina;		// 42
	(UB)(100),		//ub___pAttrInjury;		// 43
	 0,				//  0
	 0,				//  1
	 0,				//  2
	 0,				//  4 (just FGM, not FGM+3PM)
	 0,				//  6 (just FGA, not FGA+3PA)
	 0,				//  8
	 0,				// 10
	 0,				// 12
	 0,				// 14
	 0,				// 16
	 0,				// 18
	 0,				// 20
	 0,				// 22
	 0,				// 24
	 0,				// 26
	 0,				// 28 (1/4 minute resolution)
	 0,				// 30


	"Schrempf",             /* SName                003*/
	"Detlef",          /* CName*/

	291,					//uw___pIndx;

	TEAM_SONICS,     	//ub___pTeam;
	11,              	//ub___pNum;
	POS_G,				//ub___pPos;
	HGT(6,10),        	//ub___pHgt;
	WGT(235),        	//ub___pWgt;
	AGE(25,5,68+1),  	//ub___pAge;
	12,	             	//ub___pExp;
	8,					//ub___pSkin;				// 22
	0,				   //ub___pAcc0;
	0,				   //ub___pAcc1;
	1,				   //ub___pDunks;
	3,				   //ub___pPostUps;

    (UB)(4),     	//ub___pAttrRange;		// 26
    (UB)(89),     	//ub___pAttrFG;			// 27
    (UB)(87),     	//ub___pAttr3P;			// 28
    (UB)(82),     	//ub___pAttrFT;			// 29
    (UB)(82),     	//ub___pAttrRebOff;		// 30
    (UB)(77),     	//ub___pAttrRebDef;		// 31
    (UB)(63),     	//ub___pAttrSteal;		// 32
    (UB)(76),     	//ub___pAttrPass;			// 33
    (UB)(31),     	//ub___pAttrBlock;		// 34
    (UB)(1),     	//ub___pAttrFoul;			// 35
    (UB)(78),     	//ub___pAttrDribble;		// 36
    (UB)(76),     	//ub___pAttrSpeed;		// 37
    (UB)(73),     	//ub___pAttrJump;			// 38
    (UB)(72),     	//ub___pAttrDunk;			// 39
    (UB)(3),     	//ub___pAttrGoto;			// 40
    (UB)(84),     	//ub___pAttrStrength;		// 41
    (UB)(91),     	//ub___pAttrStamina;		// 42
	(UB)(83),		//ub___pAttrInjury;		// 43
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,




	"Baker",             /* SName                003*/
	"Vin",          /* CName*/
	292,					//uw___pIndx;

	TEAM_SONICS,     	//ub___pTeam;
	42,              	//ub___pNum;
	POS_G,				//ub___pPos;
	HGT(6,10),        	//ub___pHgt;
	WGT(244),        	//ub___pWgt;
	AGE(25,5,68+1),  	//ub___pAge;
	4,	             	//ub___pExp;
	2,					//ub___pSkin;				// 22
	0,				   //ub___pAcc0;
	0,				   //ub___pAcc1;
	2,				   //ub___pDunks;
	2,				   //ub___pPostUps;

    (UB)(2),     	//ub___pAttrRange;		// 26
    (UB)(100),     	//ub___pAttrFG;			// 27
    (UB)(41),     	//ub___pAttr3P;			// 28
    (UB)(67),     	//ub___pAttrFT;			// 29
    (UB)(91),     	//ub___pAttrRebOff;		// 30
    (UB)(91),     	//ub___pAttrRebDef;		// 31
    (UB)(72),     	//ub___pAttrSteal;		// 32
    (UB)(74),     	//ub___pAttrPass;			// 33
    (UB)(75),     	//ub___pAttrBlock;		// 34
    (UB)(2),     	//ub___pAttrFoul;			// 35
    (UB)(74),     	//ub___pAttrDribble;		// 36
    (UB)(83),     	//ub___pAttrSpeed;		// 37
    (UB)(85),     	//ub___pAttrJump;			// 38
    (UB)(72),     	//ub___pAttrDunk;			// 39
    (UB)(5),     	//ub___pAttrGoto;			// 40
    (UB)(92),     	//ub___pAttrStrength;		// 41
    (UB)(99),     	//ub___pAttrStamina;		// 42
		(UB)(97),				//ub___pAttrInjury;		// 43
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,




	"McIlvaine",             /* SName                003*/
	"Jim",          /* CName*/
	293,					//uw___pIndx;

	TEAM_SONICS,     	//ub___pTeam;
	22,              	//ub___pNum;
	POS_G,				//ub___pPos;
	HGT(7,1),        	//ub___pHgt;
	WGT(260),        	//ub___pWgt;
	AGE(25,5,68+1),  	//ub___pAge;
	3,	             	//ub___pExp;
	8,					//ub___pSkin;				// 22
	0,				   //ub___pAcc0;
	0,				   //ub___pAcc1;
	1,				   //ub___pDunks;
	3,				   //ub___pPostUps;

    (UB)(1),     	//ub___pAttrRange;		// 26
    (UB)(60),     	//ub___pAttrFG;			// 27
    (UB)(20),     	//ub___pAttr3P;			// 28
    (UB)(52),     	//ub___pAttrFT;			// 29
    (UB)(71),     	//ub___pAttrRebOff;		// 30
    (UB)(71),     	//ub___pAttrRebDef;		// 31
    (UB)(46),     	//ub___pAttrSteal;		// 32
    (UB)(33),     	//ub___pAttrPass;			// 33
    (UB)(100),     	//ub___pAttrBlock;		// 34
    (UB)(3),     	//ub___pAttrFoul;			// 35
    (UB)(36),     	//ub___pAttrDribble;		// 36
    (UB)(66),     	//ub___pAttrSpeed;		// 37
    (UB)(73),     	//ub___pAttrJump;			// 38
    (UB)(48),     	//ub___pAttrDunk;			// 39
    (UB)(1),     	//ub___pAttrGoto;			// 40
    (UB)(90),     	//ub___pAttrStrength;		// 41
    (UB)(69),     	//ub___pAttrStamina;		// 42
		(UB)(98),				//ub___pAttrInjury;		// 43
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,







	"Harper",             /* SName                003*/
	"Ron",          /* CName*/

	37,					//uw___pIndx;

	TEAM_BULLS,     	//ub___pTeam;
	9,              	//ub___pNum;
	POS_G,				//ub___pPos;
	HGT(6,6),        	//ub___pHgt;
	WGT(216),        	//ub___pWgt;
	AGE(25,5,68+1),  	//ub___pAge;
	11,	             	//ub___pExp;
	3,					//ub___pSkin;				// 22
	0,				   //ub___pAcc0;
	0,				   //ub___pAcc1;
	2,				   //ub___pDunks;
	4,				   //ub___pPostUps;

    (UB)(3),     	//ub___pAttrRange;		// 26
    (UB)(74),     	//ub___pAttrFG;			// 27
    (UB)(62),     	//ub___pAttr3P;			// 28
    (UB)(72),     	//ub___pAttrFT;			// 29
    (UB)(63),     	//ub___pAttrRebOff;		// 30
    (UB)(63),     	//ub___pAttrRebDef;		// 31
    (UB)(89),     	//ub___pAttrSteal;		// 32
    (UB)(70),     	//ub___pAttrPass;			// 33
    (UB)(73),     	//ub___pAttrBlock;		// 34
    (UB)(2),     	//ub___pAttrFoul;			// 35
    (UB)(82),     	//ub___pAttrDribble;		// 36
    (UB)(89),     	//ub___pAttrSpeed;		// 37
    (UB)(82),     	//ub___pAttrJump;			// 38
    (UB)(66),     	//ub___pAttrDunk;			// 39
    (UB)(2),     	//ub___pAttrGoto;			// 40
    (UB)(60),     	//ub___pAttrStrength;		// 41
    (UB)(50),     	//ub___pAttrStamina;		// 42
		(UB)(95),				//ub___pAttrInjury;		// 43
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,



	"Player",             /* SName                003*/
	"Roster",          /* CName*/

	38,					//uw___pIndx;

	TEAM_BULLS,     	//ub___pTeam;
	98,              	//ub___pNum;
	POS_G,				//ub___pPos;
	HGT(6,6),        	//ub___pHgt;
	WGT(216),        	//ub___pWgt;
	AGE(25,5,68+1),  	//ub___pAge;
	4,	             	//ub___pExp;
	3,					//ub___pSkin;				// 22
	0,				   //ub___pAcc0;
	0,				   //ub___pAcc1;
	2,				   //ub___pDunks;
	1,				   //ub___pPostUps;

    (UB)(4),     	//ub___pAttrRange;		// 26
    (UB)(85),     	//ub___pAttrFG;			// 27
    (UB)(64),     	//ub___pAttr3P;			// 28
    (UB)(71),     	//ub___pAttrFT;			// 29
    (UB)(60),     	//ub___pAttrRebOff;		// 30
    (UB)(60),     	//ub___pAttrRebDef;		// 31
    (UB)(72),     	//ub___pAttrSteal;		// 32
    (UB)(59),     	//ub___pAttrPass;			// 33
    (UB)(39),     	//ub___pAttrBlock;		// 34
    (UB)(1),     	//ub___pAttrFoul;			// 35
    (UB)(78),     	//ub___pAttrDribble;		// 36
    (UB)(85),     	//ub___pAttrSpeed;		// 37
    (UB)(90),     	//ub___pAttrJump;			// 38
    (UB)(90),     	//ub___pAttrDunk;			// 39
    (UB)(4),     	//ub___pAttrGoto;			// 40
    (UB)(61),     	//ub___pAttrStrength;		// 41
    (UB)(87),     	//ub___pAttrStamina;		// 42
		(UB)(100),				//ub___pAttrInjury;		// 43
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,




	"Pippen",             /* SName                003*/
	"Scottie",          /* CName*/

	39,					//uw___pIndx;

	TEAM_BULLS,     	//ub___pTeam;
	33,              	//ub___pNum;
	POS_G,				//ub___pPos;
	HGT(6,7),        	//ub___pHgt;
	WGT(228),        	//ub___pWgt;
	AGE(25,5,68+1),  	//ub___pAge;
	10,	             	//ub___pExp;
	3,					//ub___pSkin;				// 22
	0,				   //ub___pAcc0;
	0,				   //ub___pAcc1;
	3,				   //ub___pDunks;
	4,				   //ub___pPostUps;

    (UB)(4),     	//ub___pAttrRange;		// 26
    (UB)(96),     	//ub___pAttrFG;			// 27
    (UB)(89),     	//ub___pAttr3P;			// 28
    (UB)(80),     	//ub___pAttrFT;			// 29
    (UB)(75),     	//ub___pAttrRebOff;		// 30
    (UB)(75),     	//ub___pAttrRebDef;		// 31
    (UB)(96),     	//ub___pAttrSteal;		// 32
    (UB)(88),     	//ub___pAttrPass;			// 33
    (UB)(46),     	//ub___pAttrBlock;		// 34
    (UB)(1),     	//ub___pAttrFoul;			// 35
    (UB)(89),     	//ub___pAttrDribble;		// 36
    (UB)(92),     	//ub___pAttrSpeed;		// 37
    (UB)(95),     	//ub___pAttrJump;			// 38
    (UB)(88),     	//ub___pAttrDunk;			// 39
    (UB)(5),     	//ub___pAttrGoto;			// 40
    (UB)(73),     	//ub___pAttrStrength;		// 41
    (UB)(97),     	//ub___pAttrStamina;		// 42
		(UB)(71),				//ub___pAttrInjury;		// 43
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,



	"Rodman",             /* SName                003*/
	"Dennis",          /* CName*/

	40,					//uw___pIndx;

	TEAM_BULLS,     	//ub___pTeam;
	91,              	//ub___pNum;
	POS_G,				//ub___pPos;
	HGT(6,8),        	//ub___pHgt;
	WGT(220),        	//ub___pWgt;
	AGE(25,5,68+1),  	//ub___pAge;
	11,	             	//ub___pExp;
	2,					//ub___pSkin;				// 22
	0,				   //ub___pAcc0;
	0,				   //ub___pAcc1;
	1,				   //ub___pDunks;
	3,				   //ub___pPostUps;

    (UB)(1),     	//ub___pAttrRange;		// 26
    (UB)(58),     	//ub___pAttrFG;			// 27
    (UB)(32),     	//ub___pAttr3P;			// 28
    (UB)(51),     	//ub___pAttrFT;			// 29
    (UB)(100),     	//ub___pAttrRebOff;		// 30
    (UB)(100),     	//ub___pAttrRebDef;		// 31
    (UB)(53),     	//ub___pAttrSteal;		// 32
    (UB)(70),     	//ub___pAttrPass;			// 33
    (UB)(82),     	//ub___pAttrBlock;		// 34
    (UB)(2),     	//ub___pAttrFoul;			// 35
    (UB)(34),     	//ub___pAttrDribble;		// 36
    (UB)(81),     	//ub___pAttrSpeed;		// 37
    (UB)(94),     	//ub___pAttrJump;			// 38
    (UB)(49),     	//ub___pAttrDunk;			// 39
    (UB)(1),     	//ub___pAttrGoto;			// 40
    (UB)(91),     	//ub___pAttrStrength;		// 41
    (UB)(87),     	//ub___pAttrStamina;		// 42
		(UB)(78),				//ub___pAttrInjury;		// 43
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,




	"Longley",        /* SName                003*/
	"Luc",			  /* CName*/

	41,					//uw___pIndx;

	TEAM_BULLS,     	//ub___pTeam;
	13,              	//ub___pNum;
	POS_G,				//ub___pPos;
	HGT(7,2),        	//ub___pHgt;
	WGT(292),        	//ub___pWgt;
	AGE(25,5,68+1),  	//ub___pAge;
	6,	             	//ub___pExp;
	7,					//ub___pSkin;				// 22
	0,				   //ub___pAcc0;
	0,				   //ub___pAcc1;
	1,				   //ub___pDunks;
	3,				   //ub___pPostUps;

    (UB)(1),     	//ub___pAttrRange;		// 26
    (UB)(86),     	//ub___pAttrFG;			// 27
    (UB)(28),     	//ub___pAttr3P;			// 28
    (UB)(76),     	//ub___pAttrFT;			// 29
    (UB)(86),     	//ub___pAttrRebOff;		// 30
    (UB)(86),     	//ub___pAttrRebDef;		// 31
    (UB)(34),     	//ub___pAttrSteal;		// 32
    (UB)(71),     	//ub___pAttrPass;			// 33
    (UB)(87),     	//ub___pAttrBlock;		// 34
    (UB)(3),     	//ub___pAttrFoul;			// 35
    (UB)(42),     	//ub___pAttrDribble;		// 36
    (UB)(62),     	//ub___pAttrSpeed;		// 37
    (UB)(63),     	//ub___pAttrJump;			// 38
    (UB)(52),     	//ub___pAttrDunk;			// 39
    (UB)(3),     	//ub___pAttrGoto;			// 40
    (UB)(99),     	//ub___pAttrStrength;		// 41
    (UB)(65),     	//ub___pAttrStamina;		// 42
		(UB)(80),				//ub___pAttrInjury;		// 43
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,
	 0,


};

global	UL                  ul___gInfoFileRom;

global	SL                  sl___gInfoVersPos;
global	SL                  sl___gInfoVersLen;
global	SL                  sl___gInfoCstrPos;
global	SL                  sl___gInfoCstrLen;
global	SL                  sl___gInfoTeamPos;
global	SL                  sl___gInfoTeamLen;
global	SL                  sl___gInfoRostPos;
global	SL                  sl___gInfoRostLen;
global	SL                  sl___gInfoPlyrPos;
global	SL                  sl___gInfoPlyrLen;
global	SL                  sl___gInfoDatePos;
global	SL                  sl___gInfoDateLen;

global	UL                  ul___gDataFileRom;

global	SL                  sl___gDataVersPos;
global	SL                  sl___gDataVersLen;
global	SL                  sl___gDataPtexPos;
global	SL                  sl___gDataPtexLen;
global	SL                  sl___gDataPimgPos;
global	SL                  sl___gDataPimgLen;
global	SL                  sl___gDataSpalPos;
global	SL                  sl___gDataSpalLen;


global	UL                  ul___gCommFileRom;
global	SL                  sl___gCommVersPos;
global	SL                  sl___gCommVersLen;
global	SL                  sl___gCommPnamPos;
global	SL                  sl___gCommPnamLen;
global	SL                  sl___gCommTalkPos;
global	SL                  sl___gCommTalkLen;
global	UD *                pud__gIndxPnam;
global	UD *                pud__gIndxTalk;


char						aub__gError[256];

// **************************************************************************
// * ScanAiffFile ()                                                        *
// **************************************************************************
// * Scan one of our AIFF format data files for chunks                      *
// **************************************************************************
// * Inputs  char *   File name                                             *
// *                                                                        *
// * Output  int      zero if OK, or -ve if an error                        *
// **************************************************************************

global	int                 ScanAiffFile            (
								char *              pcz__Name)

	{
	// Local Variables.

	FH                  pcl__fil;

	SL                  sl___pos;
	SL                  sl___end;

	SD                  asd__chk [3];

	// Open the file.

	if ((pcl__fil = FileOpen(pcz__Name, "rb")) == NULL)
		{
		DIAGNOSE(("Can't open aiff file !"));
		exit(-1);
		}

	// Read the header.

	if (FileRead(asd__chk, 1, 12, pcl__fil) != 12)
		{
		DIAGNOSE(("Can't read aiff file head !"));
		exit(-1);
		}

	if (asd__chk[0] != aiffID('A', 'I', 'F', 'F'))
		{
		DIAGNOSE(("Not an aiff file !"));
		exit(-1);
		}

	// Now scan through the file.

	asd__chk[1] = (asd__chk[1] + 3) & ~ 3;

	sl___pos = 12;
	sl___end = asd__chk[1] + 8;

	while (sl___pos < sl___end)
		{
		// Read chunk header.

		if (FileRead(asd__chk, 1, 8, pcl__fil) != 8)
			{
			DIAGNOSE(("Can't read aiff chunk head !"));
			exit(-1);
			}

		asd__chk[1] = (asd__chk[1] + 3) & ~ 3;

		sl___pos = sl___pos + 8;

		// Process chunk.

		switch (asd__chk[0])
			{
			// INFO file chunks.

			case aiffID('I', 'V', 'E', 'R'):
				{
				sl___gInfoVersPos = sl___pos;
				sl___gInfoVersLen = asd__chk[1];
				break;
				}
			case aiffID('C', 'S', 'T', 'R'):
				{
				sl___gInfoCstrPos = sl___pos;
				sl___gInfoCstrLen = asd__chk[1];
				break;
				}
			case aiffID('T', 'E', 'A', 'M'):
				{
				sl___gInfoTeamPos = sl___pos;
				sl___gInfoTeamLen = asd__chk[1];
				break;
				}
			case aiffID('R', 'O', 'S', 'T'):
				{
				sl___gInfoRostPos = sl___pos;
				sl___gInfoRostLen = asd__chk[1];
				break;
				}
			case aiffID('P', 'L', 'Y', 'R'):
				{
				sl___gInfoPlyrPos = sl___pos;
				sl___gInfoPlyrLen = asd__chk[1];
				break;
				}
			case aiffID('D', 'A', 'T', 'E'):
				{
				sl___gInfoDatePos = sl___pos;
				sl___gInfoDateLen = asd__chk[1];
				break;
				}

			// DATA file chunks.

			case aiffID('D', 'V', 'E', 'R'):
				{
				sl___gDataVersPos = sl___pos;
				sl___gDataVersLen = asd__chk[1];
				break;
				}
			case aiffID('P', 'T', 'E', 'X'):
				{
				sl___gDataPtexPos = sl___pos;
				sl___gDataPtexLen = asd__chk[1];
				break;
				}
			case aiffID('P', 'I', 'M', 'G'):
				{
				sl___gDataPimgPos = sl___pos;
				sl___gDataPimgLen = asd__chk[1];
				break;
				}
			case aiffID('S', 'P', 'A', 'L'):
				{
				sl___gDataSpalPos = sl___pos;
				sl___gDataSpalLen = asd__chk[1];
				break;
				}

			// COMM file chunks.

			case aiffID('C', 'V', 'E', 'R'):
				{
				sl___gCommVersPos = sl___pos;
				sl___gCommVersLen = asd__chk[1];
				break;
				}
			case aiffID('P', 'N', 'A', 'M'):
				{
				sl___gCommPnamPos = sl___pos;
				sl___gCommPnamLen = asd__chk[1];
				break;
				}
			case aiffID('T', 'A', 'L', 'K'):
				{
				sl___gCommTalkPos = sl___pos;
				sl___gCommTalkLen = asd__chk[1];
				break;
				}
			}

		// Move onto the next chunk.

		FileSeek(pcl__fil, asd__chk[1], SEEK_CUR);

		sl___pos = sl___pos + asd__chk[1];
		}

	// Close the file.

	FileClose(pcl__fil);

	// All done, return -ve if error.

	return (0);
	}




// **************************************************************************
// * ShellLoadPermData ()                                                   *
// **************************************************************************
// * Load permanent data (done only when machine is reset)                  *
// **************************************************************************
// * Inputs  -                                                              *
// *                                                                        *
// * Output  -                                                              *
// **************************************************************************

global	void                ShellLoadPermData       (void)

	{
	// Local Variables.

	int                 i;

	DIR_INFO_T *        pcl__DirInfo;
	FH                  pcl__File;

	UD *                pud__Indx;
	UD                  aud__Indx [1];

	char *              pub__Temp;


	// Find out where all my data is located.
	ul___gCommFileRom = 0;

	if ((pcl__DirInfo = FileRomInfo("TEAMTALK.IFF")) != NULL)
		{
		ul___gCommFileRom = pcl__DirInfo->romOffset;
		ScanAiffFile("TEAMTALK.IFF");
		}

	// Open the TEAMTALK.IFF file and load the Pnam and Talk index tables.

	if (ul___gCommFileRom != 0)
		{
		pcl__File = FileOpen("TEAMTALK.IFF", "rb");

		if (sl___gCommPnamPos != 0)
			{
			FileSeek(pcl__File, sl___gCommPnamPos, SEEK_SET);

			FileRead(aud__Indx, 1, 4, pcl__File);

			i = (aud__Indx[0] + 1) << 2;

			pud__Indx = (UD *) MemMalloc(i+4, MEM_ANY);

			pud__Indx[0] = aud__Indx[0];

			FileRead(&pud__Indx[1], 1, i, pcl__File);

			pud__gIndxPnam = pud__Indx;
			}

		if (sl___gCommTalkPos != 0)
			{
			FileSeek(pcl__File, sl___gCommTalkPos, SEEK_SET);

			FileRead(aud__Indx, 1, 4, pcl__File);

			i = (aud__Indx[0] + 1) << 2;

			pud__Indx = (UD *) MemMalloc(i+4, MEM_ANY);

			pud__Indx[0] = aud__Indx[0];

			FileRead(&pud__Indx[1], 1, i, pcl__File);

			pud__gIndxTalk = pud__Indx;
			}

		FileClose(pcl__File);
		}

	// All Done.

	return;
	}




// **************************************************************************
// * FindPlyrNam ()                                                         *
// **************************************************************************
// * Locate a GSM compressed player's name                                  *
// **************************************************************************
// * Inputs  -                                                              *
// *                                                                        *
// * Output  -                                                              *
// **************************************************************************

global	void                FindPlyrNam             (
								UL *                pul__Addr,
								UL *                pul__Size,
								PlyrRomData_T *     pcl__PlyrRom,
								UI                  ui___NameTyp)

	{
	// Local Variables.

	int                 i;

	UD                  ud___pos;
	UD                  ud___len;

	// Initialize for a failure.

	*pul__Addr =
	*pul__Size = 0;

	// Is the index table loaded ?

	if (pud__gIndxPnam != NULL)
		{
		// Is this a custom plyr ?

//		if (pcl__PlyrRom->uw___pIndx <= si___gPlyrRomCnt)
		if(1)
			{
			// Locate the data for this plyr.

			i = (pcl__PlyrRom->uw___pIndx * 2) + ui___NameTyp;

			ud___pos = pud__gIndxPnam[i];
			ud___len = pud__gIndxPnam[i+1];

			ud___len = ud___len - ud___pos;

			// Is there any data ?

			if (ud___len != 0)
				{
				ud___pos = ud___pos + ul___gCommFileRom + sl___gCommPnamPos;

				// Save the results.

				*pul__Addr = (UL) ud___pos;
				*pul__Size = (UL) ud___len;

				return;
				}
			}
		}

	// All done, return failure.

	return;
	}



// **************************************************************************
// * FindCommentary ()                                                      *
// **************************************************************************
// * Locate a GSM compressed commentary phrase                              *
// **************************************************************************
// * Inputs  -                                                              *
// *                                                                        *
// * Output  -                                                              *
// **************************************************************************

global	void                FindCommentary          (
								UL *                pul__Addr,
								UL *                pul__Size,
								UI                  ui___Phrase)

	{
	// Local Variables.

	UD                  ud___pos;
	UD                  ud___len;

	// Is the index table loaded ?

	if (pud__gIndxTalk == NULL)
		{
		*pul__Addr = *pul__Size = 0; return;
		}

	// Locate the data for this plyr.

	ud___pos = pud__gIndxTalk[ui___Phrase];
	ud___len = pud__gIndxTalk[ui___Phrase+1];

	ud___len = ud___len - ud___pos;

	ud___pos = ud___pos + ul___gCommFileRom + sl___gCommTalkPos;

	// Save the results.

	*pul__Addr = (UL) ud___pos;
	*pul__Size = (UL) ud___len;

	// All done.

	return;
	}
