#include "global.h"
#include "sound.h"
#include "charactr.h"

#include "loadsnd.h"

SfxBankType *pSfxGenericBank = NULL;
//SfxBankType *pSfxLevelBank = NULL;
//int sfxBankNumber = -1;

SfxSampleType	*pSamples[LOADSND_MAXSAMPLES];

int loadsndLoadBank(char *sLevelName)
{
	if(!pSfxGenericBank)
	{
		pSfxGenericBank = (SfxBankType *)soundLoadJustBody("GENERIC");

		loadsndSetUpGeneric();
	}

	if(sLevelName)
	{
// The "sfxBankType" (SBH) is part of the BFF, and will be linked in during BFF_Load
// (Consequently, it's important that SBB files and SBH's in the BFF match up)
// (see BFF_Load, and soundLinkBFF)


		soundLoadJustBody(sLevelName);
/*
		if(pSfxLevelBank)
		{
			sfxUnloadSampleBank(pSfxLevelBank);
			sfxRemoveSampleBank(pSfxLevelBank, 1);
		}
		pSfxLevelBank = (SfxBankType *)soundLoadBodyAndHeader(sLevelName);
*/
	}

	return 0;
}

int loadsndKillBanks(void)
{
	if(pSfxGenericBank)
	{
		sfxUnloadSampleBank(pSfxGenericBank);
		sfxDestroySampleBank(pSfxGenericBank);
		pSfxGenericBank = NULL;
	}

// The level bank gets freed during BFF_ReleaseFile
// (see BFF_ReleaseFile, and soundUnlinkBFF)
/*
	if(pSfxLevelBank)
	{
		sfxUnloadSampleBank(pSfxLevelBank);
		sfxDestroySampleBank(pSfxLevelBank);
		pSfxLevelBank = NULL;
	}
*/


	return 0;
}

SfxSampleType *loadsndGetSample(SfxSampleType **ppS, int offset, char *sName)
{
	SfxSampleType *pS;

	ASSERT(offset < LOADSND_MAXSAMPLES);

	pS = sfxFindSampleInAllBanks(sName);
	if(!pS)
	{
		DB(" *** I can't find the sample that goes by the name of '%s'\n", sName);
	}

// CPW: 	ASSERT(pS);

	ppS[offset] = pS;

	return pS;
}

int loadsndSetUpGeneric(void)
{
/*
	loadsndGetSample(pSamples, SFX_GINGER_JUMP,			"gljump1b");
	loadsndGetSample(pSamples, SFX_GINGER_LAND,			"glland");
	loadsndGetSample(pSamples, SFX_GINGER_FOOTSTEP,		"glfootl");
	loadsndGetSample(pSamples, SFX_GINGER_DOUBLEJUMP,	"glrjump2");

	loadsndGetSample(pSamples, SFX_DOG_BARK1,			"dog_bark1");
	loadsndGetSample(pSamples, SFX_DOG_BARK2,			"dog_bark2");
	loadsndGetSample(pSamples, SFX_DOG_BARK3,			"dog_bark3");
	loadsndGetSample(pSamples, SFX_DOG_GROWL1,			"dog_growl1");
	loadsndGetSample(pSamples, SFX_DOG_GROWL2,			"dog_growl2");
	loadsndGetSample(pSamples, SFX_DOG_WHIMPER1,		"dog_whimper1");
	loadsndGetSample(pSamples, SFX_DOG_WHIMPER2,		"dog_whimper2");
*/

	loadsndGetSample(pSamples, SFX_SUCKER,				"sucker");
	loadsndGetSample(pSamples, SFX_TESTLOOP,			"n512");// CPW: middle C sine wave

	return 0;
}

SfxSampleType **loadsndSetUpEnemy(int ch)
{
	// CPW: don't forget to free this at the end of the level
	SfxSampleType **pCharS = (SfxSampleType **)MALLOC(sizeof(SfxSampleType *) * MAX_CHAR_SFX);
	int i;

	ASSERT(pCharS);

	DB("Setting up enemy %d sounds...\n", ch);

	for(i=0; i<MAX_CHAR_SFX; i++)
		pCharS[i] = NULL;

	switch(ch)
	{
	case ENEMY_MRST_PATROL:
	case ENEMY_MRST_CLIP_PATROL:
		pCharS[ENEMY_SFX_MRSTMINISCULE] =	loadsndGetSample(pSamples, SFX_MRSTMINISCULE,	"minisculeprofits");
		pCharS[ENEMY_SFX_MRSTCHICKENS] =	loadsndGetSample(pSamples, SFX_MRSTCHICKENS,	"mrstchickens");
		pCharS[ENEMY_SFX_MRSTCHICKENS2] =	loadsndGetSample(pSamples, SFX_MRSTCHICKENS2,	"mrstchickens2");	
		pCharS[ENEMY_SFX_MRSTFOOTSTPS1] =	loadsndGetSample(pSamples, SFX_MRSTFOOTSTPS1,	"mrstfootstps1");	
		pCharS[ENEMY_SFX_MRSTFOOTSTPS2] =	loadsndGetSample(pSamples, SFX_MRSTFOOTSTPS2,	"mrstfootstps2");	
		pCharS[ENEMY_SFX_MRSTFOOTSTPS3] =	loadsndGetSample(pSamples, SFX_MRSTFOOTSTPS3,	"mrstfootstps3");

		break;

	case ENEMY_SLEEPYDOG:
	case ENEMY_DOG:
		pCharS[ENEMY_SFX_DOGBARK1] =		loadsndGetSample(pSamples, SFX_DOGBARK1,		"dogbark1");
		pCharS[ENEMY_SFX_DOGBARK2] =		loadsndGetSample(pSamples, SFX_DOGBARK2,		"dogbark2");
		pCharS[ENEMY_SFX_DOGBARK3] =		loadsndGetSample(pSamples, SFX_DOGBARK3,		"dogbark3");	
		pCharS[ENEMY_SFX_DOGGROWLBIG] =		loadsndGetSample(pSamples, SFX_DOGGROWLBIG,		"doggrowlbig");	
		pCharS[ENEMY_SFX_DOGGROWLS1] =		loadsndGetSample(pSamples, SFX_DOGGROWLS1,		"doggrowls1");	
		pCharS[ENEMY_SFX_DOGGROWLS2] =		loadsndGetSample(pSamples, SFX_DOGGROWLS2,		"doggrowls2");	
		pCharS[ENEMY_SFX_DOGSCRATCH1] =		loadsndGetSample(pSamples, SFX_DOGSCRATCH1,		"dogscratch1");	
		pCharS[ENEMY_SFX_DOGSCRATCH2] =		loadsndGetSample(pSamples, SFX_DOGSCRATCH2,		"dogscratch2");	
		pCharS[ENEMY_SFX_DOGSKIDS] =		loadsndGetSample(pSamples, SFX_DOGSKIDS,		"dogskids");	
		pCharS[ENEMY_SFX_DOGSNIFFS1] =		loadsndGetSample(pSamples, SFX_DOGSNIFFS1,		"dogsniffs1");	
		pCharS[ENEMY_SFX_DOGSNIFFS2] =		loadsndGetSample(pSamples, SFX_DOGSNIFFS2,		"dogsniffs2");	
		pCharS[ENEMY_SFX_DOGSNORES1] =		loadsndGetSample(pSamples, SFX_DOGSNORES1,		"dogsnores1");	
		pCharS[ENEMY_SFX_DOGWALKS1] =		loadsndGetSample(pSamples, SFX_DOGWALKS1,		"dogwalks1");	
		pCharS[ENEMY_SFX_DOGWALKS2] =		loadsndGetSample(pSamples, SFX_DOGWALKS2,		"dogwalks2");	
		pCharS[ENEMY_SFX_DOGWHIMPER1] =		loadsndGetSample(pSamples, SFX_DOGWHIMPER1,		"dogwhimper1");	
		pCharS[ENEMY_SFX_DOGWHIMPER2] =		loadsndGetSample(pSamples, SFX_DOGWHIMPER2,		"dogwhimper2");	
		pCharS[ENEMY_SFX_DOGYAWNS1] =		loadsndGetSample(pSamples, SFX_DOGYAWNS1,		"dogyawns1");	
		pCharS[ENEMY_SFX_DOGYELPS1] =		loadsndGetSample(pSamples, SFX_DOGYELPS1,		"dogyelps1");	

		break;

	case ENEMY_MRT_TORCH:
	case ENEMY_MRT_PATROL:
		pCharS[ENEMY_SFX_MRTINMEHEAD] =			loadsndGetSample(pSamples, SFX_MRTINMEHEAD,		"inmehead");
		pCharS[ENEMY_SFX_MRTHUH1] =				loadsndGetSample(pSamples, SFX_MRTHUH1,			"mrt_huh1");
		pCharS[ENEMY_SFX_MRTSTEP] =				loadsndGetSample(pSamples, SFX_MRTSTEP,			"mrt_step");	
		pCharS[ENEMY_SFX_MRTNOCHICKESCAPES] =	loadsndGetSample(pSamples, SFX_MRTNOCHICKESCAPES,"nochikescapes");	
		pCharS[ENEMY_SFX_MRTTHIEVEBUGGRS] =		loadsndGetSample(pSamples, SFX_MRTTHIEVEBUGGRS,	"thievebuggrs");

	}

	DB("Seems to have completed OK\n");

	return(pCharS);
}

SfxSampleType **loadsndSetUpCharacter(int ch)
{
	// CPW: don't forget to free this at the end of the level
	SfxSampleType **pCharS = (SfxSampleType **)MALLOC(sizeof(SfxSampleType *) * MAX_CHAR_SFX);
	int i;

	ASSERT(pCharS);

	DB("Setting up character %d sounds...\n", ch);

	for(i=0; i<MAX_CHAR_SFX; i++)
		pCharS[i] = NULL;

	switch(ch)
	{
	case CHAR_NAME_GINGER:
		pCharS[CHAR_SFX_DOUBLEJUMP] =	loadsndGetSample(pSamples, SFX_GINGERDBLEJUMP1,		"gingerexert1");
		pCharS[CHAR_SFX_EXERT1] =		loadsndGetSample(pSamples, SFX_GINGEREXERT1,		"gingerexert1");
		pCharS[CHAR_SFX_JUMP1] =		loadsndGetSample(pSamples, SFX_GINGERJUMP1,			"gingerexert1");
		pCharS[CHAR_SFX_LAND] =			loadsndGetSample(pSamples, SFX_GINGERLAND,			"gingerland");
		pCharS[CHAR_SFX_PUSH] =			loadsndGetSample(pSamples, SFX_GINGERPUSH1,			"gingerpush1");
		pCharS[CHAR_SFX_STEP1] =		loadsndGetSample(pSamples, SFX_GINGERSTEP,			"gingerstep");
		pCharS[CHAR_SFX_THROW] =		loadsndGetSample(pSamples, SFX_GINGERTHROW,			"gingerjump1");
		break;
	
	case CHAR_NAME_ROCKY:
		pCharS[CHAR_SFX_EXERT1] =		loadsndGetSample(pSamples, SFX_ROCKYEXERT1,			"rockyexert1");
		pCharS[CHAR_SFX_JUMP1] =		loadsndGetSample(pSamples, SFX_ROCKYJUMP1,			"rockyjump1");
		pCharS[CHAR_SFX_LAND] =			loadsndGetSample(pSamples, SFX_ROCKYLAND,			"rockyland");
		pCharS[CHAR_SFX_STEP1] =		loadsndGetSample(pSamples, SFX_ROCKYSTEP,			"rockystep");
		pCharS[CHAR_SFX_DOUBLEJUMP] =	pCharS[CHAR_SFX_JUMP1];
		pCharS[CHAR_SFX_THROW] =		loadsndGetSample(pSamples, SFX_ROCKYTHROW,			"rockyjump1");
		break;

	case CHAR_NAME_NICK:
		pCharS[CHAR_SFX_JUMP1] =		loadsndGetSample(pSamples, SFX_NICKJUMP,			"nickhup");
		pCharS[CHAR_SFX_LAND] =			loadsndGetSample(pSamples, SFX_NICKLAND,			"nickland");
		pCharS[CHAR_SFX_PUSH] =			loadsndGetSample(pSamples, SFX_NICKPUSH1,			"nickpush1");
		pCharS[CHAR_SFX_STEP1] =		loadsndGetSample(pSamples, SFX_NICKSTEP,			"nickstep");
		break;

	case CHAR_NAME_FETCHER:
		pCharS[CHAR_SFX_DOUBLEJUMP] =	loadsndGetSample(pSamples, SFX_NICKJUMP,			"fletchdblejump");
		pCharS[CHAR_SFX_LAND] =			loadsndGetSample(pSamples, SFX_NICKLAND,			"fletchexert");
		pCharS[CHAR_SFX_JUMP1] =		loadsndGetSample(pSamples, SFX_NICKPUSH1,			"fetcherhup");
		pCharS[CHAR_SFX_LAND] =			loadsndGetSample(pSamples, SFX_NICKSTEP,			"fletchland");
		pCharS[CHAR_SFX_PUSH] =			loadsndGetSample(pSamples, SFX_NICKSTEP,			"fletchpush1");
		pCharS[CHAR_SFX_STEP1] =		loadsndGetSample(pSamples, SFX_NICKSTEP,			"fletchstep");
	}

	DB("Seems to have completed OK\n");

	return(pCharS);
}


/*
	SFX_FOWLER_BRONZE,
	SFX_FOWLER_SILVER,
	SFX_FOWLER_GOLD,
	SFX_FOWLER_FAIL,
	NUM_SFX_FOWLER_SAMPLES,
*/

SfxSampleType *fowlerSubGameSample[NUM_SFX_FOWLER_SAMPLES];


//Should do this with all of them really - much easier.
char *wingSounds[NUM_WINGS_SAMPLES] =
{
	"makecloth06",		//SFX_WINGS_MAKECLOTH,    
	"tiepoles02",		//SFX_WINGS_MAKEPOLES,    
	"sewing01",			//SFX_WINGS_MAKESTITCHES, 
	"dropcloth",		//SFX_WINGS_DROPCLOTH,   
	"droppole",			//SFX_WINGS_DROPPOLES,   
	"dropsewing",		//SFX_WINGS_DROPSTITCHES,
	"chickgetup07",		//SFX_WINGS_GETUP1,       
	"chickgetup02",		//SFX_WINGS_GETUP2,       
	"chickgetup04",		//SFX_WINGS_GETUP3,       
	"chickgetup01",		//SFX_WINGS_GETUP4,       
	"ing_13a",			//SFX_WINGS_TIRED,      
	"ing_12a",			//SFX_WINGS_BORED,      
	"ing_07c",			//SFX_WINGS_CANTSEE,    
	"ing_19a",			//SFX_WINGS_THEREYOUGO, 
	"ing_11a",			//SFX_WINGS_TOILET,     
	"ing_14b",			//SFX_WINGS_CANWESTOP,  
	"ing_20b",			//SFX_WINGS_FRIGHTENED, 
	"ing_15a",			//SFX_WINGS_THIRSTY,    
	"ing_18a",			//SFX_WINGS_ISFARMER,   
	"g_encourage02",	//SFX_WINGS_ENCOURAGE1, 
	"g_encourage03",	//SFX_WINGS_ENCOURAGE2, 
	"g_encourage04",	//SFX_WINGS_ENCOURAGE3, 
	"chickfinish01",	//SFX_WINGS_FINISH,

};





char *seesawSounds[NUM_SEESAW_SAMPLES] =
{
	"hitfence2",   		//SFX_SEESAW_LAUNCH	 
	"boiing1",  		//SFX_SEESAW_BOUNCE			 
	"chickenthud1",		//SFX_SEESAW_CRASH			 
	"dropweights1",		//SFX_SEESAW_LAND			 
	"ing_argh_06",		//SFX_SEESAW_HIT1
	"ing_ooph_01",		//SFX_SEESAW_HIT2	
	"ing_ooph_03",		//SFX_SEESAW_HIT3	
	"ing_ouch_03",		//SFX_SEESAW_HIT4	
	"ing_ouch_07",		//SFX_SEESAW_HIT5
	"ing_wee_02a",		//SFX_SEESAW_WEE1	
	"ing_wee_06c",		//SFX_SEESAW_WEE2	
	"ing_wee_06i",		//SFX_SEESAW_WEE3	
	"ing_wee_10a",		//SFX_SEESAW_WEE4	
	"ing_wee_12c",		//SFX_SEESAW_WEE5	
	"ing_wee_16a",		//SFX_SEESAW_WEE6	
	"ing_wee_17a",		//SFX_SEESAW_WEE7
};


char *fireworksSounds[NUM_FIREWORKS_SAMPLES] =
{
	"fireworkfizz1", 		//SFX_FIREWORKS_LAUNCH	      	
	"fireworkpop2",  		//SFX_FIREWORKS_HIT				
	"firewrktravels",		//SFX_FIREWORKS_RUNBACK			
	"wind1",         		//SFX_FIREWORKS_WIND			
	"dropweights1",  		//SFX_FIREWORKS_THUD			
															
	"ing_argh_06",			//SFX_FIREWORKS_HIT1			
	"ing_ooph_01",			//SFX_FIREWORKS_HIT2			
	"ing_ooph_03",			//SFX_FIREWORKS_HIT3			
	"ing_ouch_03",			//SFX_FIREWORKS_HIT4			
	"ing_ouch_07",			//SFX_FIREWORKS_HIT5			
	"ing_wee_02a",			//SFX_FIREWORKS_WEE1			
	"ing_wee_06c",			//SFX_FIREWORKS_WEE2			
	"ing_wee_06i",			//SFX_FIREWORKS_WEE3			
	"ing_wee_10a",			//SFX_FIREWORKS_WEE4			
	"ing_wee_12c",			//SFX_FIREWORKS_WEE5			
	"ing_wee_16a",			//SFX_FIREWORKS_WEE6			
	"ing_wee_17a",			//SFX_FIREWORKS_WEE7			
															
	"whoosh01",				//SFX_FIREWORKS_WHOOSH1,		
	"whoosh02",				//SFX_FIREWORKS_WHOOSH2,		
	"whoosh03",				//SFX_FIREWORKS_WHOOSH3,		
	"whoosh04",				//SFX_FIREWORKS_WHOOSH4,		
	"whoosh05",				//SFX_FIREWORKS_WHOOSH5,		
	"yipee04",				//SFX_FIREWORKS_YIPEE,  		
															
	"crash03",				//SFX_FIREWORKS_CRASH1			
	"crash04",				//SFX_FIREWORKS_CRASH2			
//	"crash03",				//SFX_FIREWORKS_CRASH3			
//	"crash04",				//SFX_FIREWORKS_CRASH4			
//	"crash05",				//SFX_FIREWORKS_CRASH5			                      

};




char *egglayingSounds[NUM_EGGLAYING_SAMPLES] =
{
	"eggsplat1",		  //SFX_EGGLAYING_SPLAT,        
	"layegg",			  //SFX_EGGLAYING_LAY,			
	"oilblob",			  //SFX_EGGLAYING_LAY_SQUELCH,	
	"pumper1",			  //SFX_EGGLAYING_LAY_FART,		
	"eggsausted1",		  //SFX_EGGLAYING_TIRED,		
	"egglaypop01",		  //SFX_EGGLAYING_POP,			
	"brilliant",		  //SFX_EGGLAYING_BRILL,		
	"great",			  //SFX_EGGLAYING_GREAT,		
	"ing_gen_33a",		  //SFX_EGGLAYING_CAUGHT1,		
	"ing_gen_32a",		  //SFX_EGGLAYING_DROP1,		
	"ing_gen_31b",		  //SFX_EGGLAYING_DROP2,		
	"ing_gen_29c",		  //SFX_EGGLAYING_FEEDME1,		
	"munching02",		  //SFX_EGGLAYING_EATING1,		
	"munching03",		  //SFX_EGGLAYING_EATING2,		
	"cluck_idle",		  //SFX_EGGLAYING_CLUCK,		
};							  
	














char *catapultSounds[NUM_CATAPULT_SAMPLES] =
{
	"hitfence1",       	//	SFX_CATAPULT_BOIING		    
	"catpultwinding1", 	//	SFX_CATAPULT_WINDING	 
	"catpultlaunch3",  	//	SFX_CATAPULT_LAUNCH		 
	"splashes1",       	//	SFX_CATAPULT_SPLASH		 
	"bigsplash1",		//	SFX_CATAPULT_BIGSPLASH	 		   
	"weefire1",        	//	SFX_CATAPULT_BACKGROUNDS 

	"ing_wee_02a",		//	SFX_CATAPULT_WEE1,					
	"ing_wee_06c",		//	SFX_CATAPULT_WEE2,					
	"ing_wee_06i",		//	SFX_CATAPULT_WEE3,					
	"ing_wee_10a",		//	SFX_CATAPULT_WEE4,					
	"ing_wee_12c",		//	SFX_CATAPULT_WEE5,					
	"ing_wee_16a",		//	SFX_CATAPULT_WEE6,					
	"ing_wee_17a",		//	SFX_CATAPULT_WEE7,					

	"crate02",		 	//	SFX_CATAPULT_JUMPOFF
	"metdrum02",		//	SFX_CATAPULT_METDRUM

};





// Must pass in pointer to array of SfxSampleType of sufficient size	   
void loadsndSubGames(int levelNum, SfxSampleType **pSamples, int arraySize)
{
	// CPW: don't forget to free this at the end of the level
	// DJH: OK

	int i;

	ASSERT(pSamples);

	for(i=0; i<arraySize; i++)
		pSamples[i] = NULL;




	DB("Setting up Subgame sounds...\n");

	switch(levelNum)
	{
		case LEVNUMBER_A2_CATAPULT:

			ASSERT(arraySize >= NUM_CATAPULT_SAMPLES);


			for(i=0; i<NUM_CATAPULT_SAMPLES; i++)
			{
				pSamples[i]	= sfxFindSampleInAllBanks(catapultSounds[i]);

#ifdef DEBUG
				if(pSamples[i] == NULL)
					DB("catapult pSamples[%d] not found\n",i);
#endif
				ASSERT(pSamples[i]);
			}


//			pSamples[SFX_CATAPULT_BOIING]		= sfxFindSampleInAllBanks("hitfence1");
//			ASSERT(pSamples[SFX_CATAPULT_BOIING]);

//			pSamples[SFX_CATAPULT_WINDING]		= sfxFindSampleInAllBanks("catpultwinding1");			   
//			ASSERT(pSamples[SFX_CATAPULT_WINDING]);

//			pSamples[SFX_CATAPULT_LAUNCH]		= sfxFindSampleInAllBanks("catpultlaunch3");	   
//			ASSERT(pSamples[SFX_CATAPULT_LAUNCH]);

//			pSamples[SFX_CATAPULT_SPLASH]		= sfxFindSampleInAllBanks("splashes1");			   
//			ASSERT(pSamples[SFX_CATAPULT_SPLASH]);

//			pSamples[SFX_CATAPULT_BIGSPLASH]	= sfxFindSampleInAllBanks("bigsplash1");			   
//			ASSERT(pSamples[SFX_CATAPULT_BIGSPLASH]);

//			pSamples[SFX_CATAPULT_BACKGROUNDS]	= sfxFindSampleInAllBanks("weefire1");
//			ASSERT(pSamples[SFX_CATAPULT_BACKGROUNDS]);

			fowlerSubGameSample[SFX_FOWLER_BRONZE] = sfxFindSampleInAllBanks("catapult_01a");
			ASSERT(fowlerSubGameSample[SFX_FOWLER_BRONZE]);

			fowlerSubGameSample[SFX_FOWLER_SILVER] = sfxFindSampleInAllBanks("catapult_02a");
			ASSERT(fowlerSubGameSample[SFX_FOWLER_SILVER]);

			fowlerSubGameSample[SFX_FOWLER_GOLD] = sfxFindSampleInAllBanks("catapult_03a");
			ASSERT(fowlerSubGameSample[SFX_FOWLER_GOLD]);

			fowlerSubGameSample[SFX_FOWLER_FAIL] = sfxFindSampleInAllBanks("catapult_04a");
			ASSERT(fowlerSubGameSample[SFX_FOWLER_FAIL]);
			break;


		case LEVNUMBER_A2_SEESAW:

			ASSERT(arraySize >= NUM_SEESAW_SAMPLES);


			for(i=0; i<NUM_SEESAW_SAMPLES; i++)
			{
				pSamples[i]	= sfxFindSampleInAllBanks(seesawSounds[i]);

#ifdef DEBUG
				if(pSamples[i] == NULL)
					DB("seesaw pSamples[%d] not found\n",i);
#endif
				ASSERT(pSamples[i]);
			}

			fowlerSubGameSample[SFX_FOWLER_BRONZE] = sfxFindSampleInAllBanks("seesaw_01a");
			ASSERT(fowlerSubGameSample[SFX_FOWLER_BRONZE]);

			fowlerSubGameSample[SFX_FOWLER_SILVER] = sfxFindSampleInAllBanks("seesaw_02a");
			ASSERT(fowlerSubGameSample[SFX_FOWLER_SILVER]);

			fowlerSubGameSample[SFX_FOWLER_GOLD] = sfxFindSampleInAllBanks("seesaw_03a");
			ASSERT(fowlerSubGameSample[SFX_FOWLER_GOLD]);

			fowlerSubGameSample[SFX_FOWLER_FAIL] = sfxFindSampleInAllBanks("seesaw_04a");
			ASSERT(fowlerSubGameSample[SFX_FOWLER_FAIL]);
			break;


		
		case LEVNUMBER_A2_FIREWORKS:

			ASSERT(arraySize >= NUM_FIREWORKS_SAMPLES);

			for(i=0; i<NUM_FIREWORKS_SAMPLES; i++)
			{
				pSamples[i]	= sfxFindSampleInAllBanks(fireworksSounds[i]);

#ifdef DEBUG
				if(pSamples[i] == NULL)
					DB("fireworks pSamples[%d] not found\n",i);
#endif
				ASSERT(pSamples[i]);
			}


			fowlerSubGameSample[SFX_FOWLER_BRONZE] = sfxFindSampleInAllBanks("fireworks_01a");
			ASSERT(fowlerSubGameSample[SFX_FOWLER_BRONZE]);

			fowlerSubGameSample[SFX_FOWLER_SILVER] = sfxFindSampleInAllBanks("fireworks_02a");
			ASSERT(fowlerSubGameSample[SFX_FOWLER_SILVER]);

			fowlerSubGameSample[SFX_FOWLER_GOLD] = sfxFindSampleInAllBanks("fireworks_03a");
			ASSERT(fowlerSubGameSample[SFX_FOWLER_GOLD]);

			fowlerSubGameSample[SFX_FOWLER_FAIL] = sfxFindSampleInAllBanks("fireworks_04a");
			ASSERT(fowlerSubGameSample[SFX_FOWLER_FAIL]);


			break;


		case LEVNUMBER_A4_EGGHUT:

			ASSERT(arraySize >= NUM_EGGLAYING_SAMPLES);

			for(i=0; i<NUM_EGGLAYING_SAMPLES; i++)
			{
				pSamples[i]	= sfxFindSampleInAllBanks(egglayingSounds[i]);

#ifdef DEBUG
				if(pSamples[i] == NULL)
					DB("egglaying pSamples[%d] not found\n",i);
#endif
				ASSERT(pSamples[i]);
			}


//			pSamples[SFX_EGGLAYING_SPLAT]		= sfxFindSampleInAllBanks("eggsplat1");  
//			ASSERT(pSamples[SFX_EGGLAYING_SPLAT]);

//			pSamples[SFX_EGGLAYING_LAY]			= sfxFindSampleInAllBanks("layegg");     
//			ASSERT(pSamples[SFX_EGGLAYING_LAY]);

//			pSamples[SFX_EGGLAYING_LAY_SQUELCH]	= sfxFindSampleInAllBanks("oilblob");    
//			ASSERT(pSamples[SFX_EGGLAYING_LAY_SQUELCH]);

//			pSamples[SFX_EGGLAYING_LAY_FART]	= sfxFindSampleInAllBanks("pumper1");    
//			ASSERT(pSamples[SFX_EGGLAYING_LAY_FART]);

//			pSamples[SFX_EGGLAYING_TIRED]		= sfxFindSampleInAllBanks("eggsausted1");
//			ASSERT(pSamples[SFX_EGGLAYING_TIRED]);

			fowlerSubGameSample[SFX_FOWLER_BRONZE] = sfxFindSampleInAllBanks("egg_01a");
			ASSERT(fowlerSubGameSample[SFX_FOWLER_BRONZE]);

			fowlerSubGameSample[SFX_FOWLER_SILVER] = sfxFindSampleInAllBanks("egg_02a");
			ASSERT(fowlerSubGameSample[SFX_FOWLER_SILVER]);

			fowlerSubGameSample[SFX_FOWLER_GOLD] = sfxFindSampleInAllBanks("egg_03a");
			ASSERT(fowlerSubGameSample[SFX_FOWLER_GOLD]);

			fowlerSubGameSample[SFX_FOWLER_FAIL] = sfxFindSampleInAllBanks("egg_04a");
			ASSERT(fowlerSubGameSample[SFX_FOWLER_FAIL]);

			break;

	
		case LEVNUMBER_A4_CONSTRUCT:

			ASSERT(arraySize >= NUM_CONSTRUCT_SAMPLES);


			pSamples[SFX_CONSTRUCT_H]	=	sfxFindSampleInAllBanks("h");
			ASSERT(pSamples[SFX_CONSTRUCT_H]);

			pSamples[SFX_CONSTRUCT_K]	=	sfxFindSampleInAllBanks("k");
			ASSERT(pSamples[SFX_CONSTRUCT_K]);
			
			pSamples[SFX_CONSTRUCT_KH]	=	sfxFindSampleInAllBanks("kh");
			ASSERT(pSamples[SFX_CONSTRUCT_KH]);
			
			pSamples[SFX_CONSTRUCT_KS]	=	sfxFindSampleInAllBanks("ks");
			ASSERT(pSamples[SFX_CONSTRUCT_KS]);
			
			pSamples[SFX_CONSTRUCT_KSH]	=	sfxFindSampleInAllBanks("ksh");
			ASSERT(pSamples[SFX_CONSTRUCT_KSH]);
			
			pSamples[SFX_CONSTRUCT_S]   =	sfxFindSampleInAllBanks("s");
			ASSERT(pSamples[SFX_CONSTRUCT_S]);
			
			pSamples[SFX_CONSTRUCT_SH]	=	sfxFindSampleInAllBanks("sh");
			ASSERT(pSamples[SFX_CONSTRUCT_SH]);

			pSamples[SFX_CONSTRUCT_HAMMER1]	=	sfxFindSampleInAllBanks("chickhammer1");
			ASSERT(pSamples[SFX_CONSTRUCT_HAMMER1]);

			pSamples[SFX_CONSTRUCT_HAMMER2]	=	sfxFindSampleInAllBanks("chickhammer2");
			ASSERT(pSamples[SFX_CONSTRUCT_HAMMER2]);

			pSamples[SFX_CONSTRUCT_HAMMER3]	=	sfxFindSampleInAllBanks("chickhammer3");
			ASSERT(pSamples[SFX_CONSTRUCT_HAMMER3]);

			pSamples[SFX_CONSTRUCT_SPANNER1]	=	sfxFindSampleInAllBanks("chickspanner1");
			ASSERT(pSamples[SFX_CONSTRUCT_SPANNER1]);

			pSamples[SFX_CONSTRUCT_SPANNER2]	=	sfxFindSampleInAllBanks("chickspanner2");
			ASSERT(pSamples[SFX_CONSTRUCT_SPANNER2]);

			pSamples[SFX_CONSTRUCT_SPANNER3]	=	sfxFindSampleInAllBanks("chickspanner3");
			ASSERT(pSamples[SFX_CONSTRUCT_SPANNER3]);

			pSamples[SFX_CONSTRUCT_SAW1]	=	sfxFindSampleInAllBanks("saw1");
			ASSERT(pSamples[SFX_CONSTRUCT_SAW1]);

			pSamples[SFX_CONSTRUCT_SAW2]	=	sfxFindSampleInAllBanks("saw2");
			ASSERT(pSamples[SFX_CONSTRUCT_SAW2]);

			pSamples[SFX_CONSTRUCT_SAW3]	=	sfxFindSampleInAllBanks("saw3");
			ASSERT(pSamples[SFX_CONSTRUCT_SAW3]);



			fowlerSubGameSample[SFX_FOWLER_BRONZE] = sfxFindSampleInAllBanks("build_01a");
			ASSERT(fowlerSubGameSample[SFX_FOWLER_BRONZE]);

			fowlerSubGameSample[SFX_FOWLER_SILVER] = sfxFindSampleInAllBanks("build_02a");
			ASSERT(fowlerSubGameSample[SFX_FOWLER_SILVER]);

			fowlerSubGameSample[SFX_FOWLER_GOLD] = sfxFindSampleInAllBanks("build_03a");
			ASSERT(fowlerSubGameSample[SFX_FOWLER_GOLD]);

			fowlerSubGameSample[SFX_FOWLER_FAIL] = sfxFindSampleInAllBanks("build_04a");
			ASSERT(fowlerSubGameSample[SFX_FOWLER_FAIL]);
			break;
		
		case LEVNUMBER_A4_ENGINEHUT:
			ASSERT(arraySize >= NUM_ENGINE_SAMPLES);

			pSamples[SFX_ENGINE_SQUEAKS]	= sfxFindSampleInAllBanks("bikesqueaks");
			ASSERT(pSamples[SFX_ENGINE_SQUEAKS]);
			pSamples[SFX_ENGINE_FAILED]		= sfxFindSampleInAllBanks("levelfailed");
			ASSERT(pSamples[SFX_ENGINE_FAILED]);
			pSamples[SFX_ENGINE_OIL]		= sfxFindSampleInAllBanks("oilblob");
			ASSERT(pSamples[SFX_ENGINE_OIL]);
			pSamples[SFX_ENGINE_PUMPER]		= sfxFindSampleInAllBanks("pumper1");
			ASSERT(pSamples[SFX_ENGINE_PUMPER]);
			pSamples[SFX_ENGINE_AH]			= sfxFindSampleInAllBanks("rocky_aaah");
			ASSERT(pSamples[SFX_ENGINE_AH]);
			pSamples[SFX_ENGINE_RUNNING]	= sfxFindSampleInAllBanks("running1");
			ASSERT(pSamples[SFX_ENGINE_RUNNING]);

			fowlerSubGameSample[SFX_FOWLER_BRONZE] = sfxFindSampleInAllBanks("engine_01a");
			ASSERT(fowlerSubGameSample[SFX_FOWLER_BRONZE]);

			fowlerSubGameSample[SFX_FOWLER_SILVER] = sfxFindSampleInAllBanks("engine_02a");
			ASSERT(fowlerSubGameSample[SFX_FOWLER_SILVER]);

			fowlerSubGameSample[SFX_FOWLER_GOLD] = sfxFindSampleInAllBanks("engine_03a");
			ASSERT(fowlerSubGameSample[SFX_FOWLER_GOLD]);

			fowlerSubGameSample[SFX_FOWLER_FAIL] = sfxFindSampleInAllBanks("engine_04a");
			ASSERT(fowlerSubGameSample[SFX_FOWLER_FAIL]);
			break;

		case LEVNUMBER_A4_WINGSHUT:
			ASSERT(arraySize >= NUM_WINGS_SAMPLES);

			for(i=0; i<NUM_WINGS_SAMPLES; i++)
			{
				pSamples[i]	= sfxFindSampleInAllBanks(wingSounds[i]);

#ifdef DEBUG
				if(pSamples[i] == NULL)
					DB("wings pSamples[%d] not found\n",i);
#endif
				ASSERT(pSamples[i]);
			}


			fowlerSubGameSample[SFX_FOWLER_BRONZE] = sfxFindSampleInAllBanks("wing_01a");
			ASSERT(fowlerSubGameSample[SFX_FOWLER_BRONZE]);

			fowlerSubGameSample[SFX_FOWLER_SILVER] = sfxFindSampleInAllBanks("wing_02a");
			ASSERT(fowlerSubGameSample[SFX_FOWLER_SILVER]);

			fowlerSubGameSample[SFX_FOWLER_GOLD] = sfxFindSampleInAllBanks("wing_03a");
			ASSERT(fowlerSubGameSample[SFX_FOWLER_GOLD]);

			fowlerSubGameSample[SFX_FOWLER_FAIL] = sfxFindSampleInAllBanks("wing_04a");
			ASSERT(fowlerSubGameSample[SFX_FOWLER_FAIL]);
			break;


		default:
			DB("NOT A sublevel\n");
			ASSERT(0);
			break;

	}
}



