#include "global.h"
#include "main.h"
#include "menu.h"
#include "map_draw.h"
#include "bff_load.h"
#include "collide.h"
#include "debris.h"
#include "lights.h"
#include "timer.h"
#include "maths.h"
#include "overlays.h"
#include "map_view.h"
//#include "global.h"

#include "enemies.h"
#include "fma.h"

//#include "text_ids.h"
#include "loadsnd.h"
#include "map_draw.h"
#include "inventory.h"
#include "scenics.h"
#include "charactr.h"
#include "card.h"
#include "puzzles.h"
//extern CHARACTERVARSTR characterVars;
//#include "map_play.h"
//#include "puzzles.h"

#include "dogchase.h"
#include "deth.h"
#include "inventory.h"

#include <psitypes.h>
#include <stdio.h>
#include <string.h>
//#include <conio.h>
#include <stdlib.h>
#include "gametext.h"
#include "map_play.h"
#include "sound.h"
#include "inventory.h"	// and if its not prototyped don't blame me
#include "camera.h"
/*
#include "global.h"
#include "main.h"
#include "card.h"
#include "gametext.h"
#include "menu.h"
#include "overlays.h"
#include "maths.h"
#include "options.h"
#include "startup.h"
#include "inventory.h"
*/

#ifdef DREAMCAST
	#define HALFSCREENWIDTH 320
	#define HALFSCREENHEIGHT 240
	extern int scrOffsetX, scrOffsetY;
	#define HEIGHTDIV 1
	#define FRAMEBLANKLIMIT 13
	#undef NULL
	#define NULL 0
#else
	// JS: I've added these defines here to make the overlay and text drawing code more
	// flexible for which ever build of the game that we're doing.  
	//#ifndef _WINDOWS
	#define HALFSCREENWIDTH 256
	#define HALFSCREENHEIGHT 128
	/*#else
	extern int scrOffsetX, scrOffsetY;
	#define HALFSCREENWIDTH scrOffsetX
	#define HALFSCREENHEIGHT scrOffsetY
	#endif */

	#define HEIGHTDIV 1
	//#define FRAMEBLANKLIMIT 26
	#define FRAMEBLANKLIMIT 13

#endif



void	setupPositions(void);
void	FMAtestDraw(void);
void	FMAtestCycle(void);

extern int currentCharacter;

//extern CHARACTERVARSTR characterVars;

FMAINFO*	fmaInfo;


VOID_SUBROUTINE old_draw_routine_FMA = NULL;
VOID_SUBROUTINE old_cycle_routine_FMA = NULL;

PSIMODEL	*testchar_model;
ACTOR		*testchar_actor1;
ACTOR		*testchar_actor2;

VECTOR		actorPos1;
VECTOR		actorVel1;

VECTOR		actorPos2;
VECTOR		actorVel2;

FMASTATUS	fmaStatus;

TEXTCTRL	textCtrl;


FMACTRL		*fmaCtrl;

FMAOBJECT	*camObject;
FMAOBJECT	*generalObject;
FMAOBJECT	*mainObject;

//	additions for target changes
VECTOR		camTargetStart;
VECTOR		camTargetEnd;
int			targetChangeStart;
int			targetChangeLen;
//int			targetChangeEnd;

int		objCmdNum[2];	// keep an eye on these

int		frameTimeCount=0;

ENEMYINFO setupInfo[]={
//	{"DOG01",	enemyUpdateDog,		STATE_SLEEPING,	0, (2*4096)<<3, 18<<3, NULL},
	{"DOG01",	enemyUpdateDog,		STATE_NULL,	0, (2*4096)<<3, 18<<3, NULL},
	{"ROCKY",	enemyUpdateChicken,	STATE_NULL,0, (2*4096)<<3, 18<<3, NULL},
	{"MAC",	enemyUpdateChicken,	STATE_NULL,0, (2*4096)<<3, 18<<3, NULL}
};

//#define	STANDALONE
char	act1FmaStatus[MAX_ACT1_FMAS];

// RFW - Moved to gamePlayData->
//FMAPLAYEDSTATUS	gamePlayData->A1fmaStatus[MAX_ACT1_FMAS];
//FMAPLAYEDSTATUS	gamePlayData->A2fmaStatus[MAX_ACT2_FMAS];
//FMAPLAYEDSTATUS	gamePlayData->A4fmaStatus[MAX_ACT4_FMAS];

int options_returnlevel;

int	fmaExitFlag=FALSE;

VECTOR	ropePos[2];

VECTOR	objectStartPositions[10];

////////////////////////////////////////////////////////////////////////////////////
int	startfov;
unsigned long	inCrc;

int	playedSceneNumber;
int	playedActNumber;

int	SpecialCaseFma=0;

#define	ACT2FMA1	1
#define	ACT2FMA2	2

#define	ACT4FMA1	4
#define	ACT4FMA2	8

//int	leadInCount;

TextureType	*FMAcross;

void	startFMA(char *name)
{
	int	loop;
	int	match=0;
	fmaExitFlag=FALSE;
	//enemyAdd(&setupInfo[0]);	// This is a bit naughty but as the level does'nt activate then it needed
	//enemyAdd(&setupInfo[1]);
	//enemyAdd(&setupInfo[2]);
	// quick and nasty check to stop fma running the puzzel engine which then calls the fma

	if (cycle_routine == FMAtestCycle) return;
//	leadInCount=13;

	DB("stoping xa\n");
	sound_XA_Stop();	// stop xa if playing
	DB("xa stoped\n");
	characterVars.pMainChar->movement.speed=0;

	old_draw_routine_FMA=draw_routine;
	old_cycle_routine_FMA=cycle_routine;

	DB("look for script %s\n",name);
	inCrc=utilStr2CRC(name);
	DB("crc =%d\n",inCrc);

	draw_routine = FMAtestDraw;
	cycle_routine = FMAtestCycle;

	fmaStatus.fade=FALSE;	// no fade going
	fmaStatus.breakFlag=FALSE;
	fmaStatus.holdFrameFlag=FALSE;
	frameTimeCount=0;
	fmaStatus.planOn=FALSE;
	fmaStatus.fadeStatus=NOFADE;
	fmaStatus.XAplaying=FALSE;

	fmaStatus.menuChoice=0;
	fmaStatus.menuOn=0;
	fmaStatus.menuOnTime=0;
	fmaStatus.breakOverideCount=0;

	//if (levinfo->level_number==LEVNUMBER_A2_HUT17) SpecialCaseFma=ACT2FMA;
	//else if (levinfo->level_number==LEVNUMBER_A4_HUT17) SpecialCaseFma=ACT4FMA;
	//else SpecialCaseFma=FALSE;

	//SpecialCaseFma=FALSE;

	//fmaStatus.planFadeCount=0;
	//fmaStatus.planFadeOn=FALSE;
	//fmaStatus.planFadeOff=FALSE;
	//fmaStatus.planFadeOffTime=0;
/*	for (loop=0;loop<3;loop++)
	{
		for (loop1=0;loop1<6;loop1++)
		{
			textCtrl.line[loop][loop1]=NULL;
			textCtrl.endLineTime[loop][loop1]=0;
		}
		textCtrl.block[loop]=NULL;
		textCtrl.endBlockTime[loop]=0;
		textCtrl.colour[loop]=0;
	}
*/
	match=99;
	fmaStatus.playing=FALSE;
	for (loop=0;loop<fmaInfo->numScripts;loop++)
	{
		if (inCrc==fmaInfo->scriptCrc[loop])
		{
			match=loop;
			break;
		}
	}
	if (match!=99)
	{
		fmaCtrl=fmaInfo->fmaStart[match];
		fmaStatus.playing=TRUE;
		FMAcross= textureFindInAllBanks("CROSS");

		setupModels();
		setupPositions();
		gte_ReadGeomScreen(&startfov);
		GsSetProjection(950);
	}
	else
	{
		char temp[80];
		sprintf(temp,"(FMA script %s)",name);
		overlayDebugMessage(temp, 25 * 3);

		DB("FMA script %s not found!\n",name);
		//CRASH;
		draw_routine=old_draw_routine;
		cycle_routine=old_cycle_routine;
	}


	//fmaCtrl=fmaInfo->fmaStart[0];

	//setupModels();
	//setupPositions();
}
////////////////////////////////////////////////////////////////////////////////////

void	fmaLinkBFF( FMAINFO *work)
{
	int i,j;

	fmaInfo=work;
//	caminfo = work;
//	if (info->numCases)
//		info->rec = ADD2POINTER(info->rec, (int)info);
//	if (info->numRailCases)
//		info->data = ADD2POINTER(info->rec, (int)info);
//	DB("test\n");
	SpecialCaseFma=FALSE;
	fmaStatus.playing=FALSE;
	for (i=0;i<work->numScripts;i++)
	{
		work->fmaStart[i]=ADD2POINTER(work->fmaStart[i], (int)work);
		//work->fmaStart[i]->object=ADD2POINTER( work->fmaStart[i]->object, (int)work);
		work->fmaStart[i]->object=ADD2POINTER( work->fmaStart[i]->object, (int)work->fmaStart[i]);

		for (j=0;j<work->fmaStart[i]->numObjects;j++)
		{
			//work->fmaStart[i]->object[j].data=ADD2POINTER( work->fmaStart[i]->object[j].data,(int)work);
			work->fmaStart[i]->object[j].data=ADD2POINTER( work->fmaStart[i]->object[j].data,(int)work->fmaStart[i]);
		}
	}
}

////////////////////////////////////////////////////////////////////////////////////
/*
void	loadFMA(void)
{
	long*	offset;
	int		len,loop;

// tbd need to put this in the bff file
	fmaCtrl=(FMACTRL *)fileLoad("fmatest\\test.dat",&len);	// returns lenght of loaded file (I think)
	offset=(long*)fmaCtrl;

	fmaCtrl->object=(long*) ((long)(offset)+(long)fmaCtrl->object);

	for (loop=0;loop<fmaCtrl->numObjects;loop++)
	{
		fmaCtrl->object[loop].data=(long*) ((long)(offset)+(long)fmaCtrl->object[loop].data);
		fmaCtrl->object[loop].flags=0;
	}

	//DB("test\n");
	//loadsndLoadBank(-1);

//	pM=(ULONG *)(((ULONG)offMesh)+((ULONG)tempFile)+((ULONG)collBox[loop].rampheader));
}
*/
///////////////////////////////////////////////////////////////////////////////////////////
void	freeFMA(void)
{
	int	loop;
	// not sure what to do about actors used in fma's called in mid level

	if ( (levinfo->level_number!=LEVNUMBER_A4_KITCHEN) /*&& (levinfo->level_number!=LEVNUMBER_A2_HOUSEXT_D)*/ )
	{
		for (loop=0;loop<fmaCtrl->numObjects;loop++)
		{
			fmaCtrl->object[loop].pos.vx=objectStartPositions[loop].vx;
			fmaCtrl->object[loop].pos.vy=objectStartPositions[loop].vy;
			fmaCtrl->object[loop].pos.vz=objectStartPositions[loop].vz;

			if (fmaCtrl->object[loop].crc>1)	// a crc of 0 is the camera
			{
				//actorFree(fmaCtrl->object[loop].actor);
				if (mainObject==&fmaCtrl->object[loop])
				{
					characterVars.pMainChar->movement.desiredAngle=fmaCtrl->object[loop].actor->psiData.object->rotate.vy;
					characterVars.pMainChar->pEnemy->desiredDir=characterVars.pMainChar->pEnemy->dir=fmaCtrl->object[loop].actor->psiData.object->rotate.vy;
				}
				else if ( fmaCtrl->object[loop].crc!=utilStr2CRC("ROPE01") && fmaCtrl->object[loop].crc!=utilStr2CRC("ROPE02") )
				{
					fmaCtrl->object[loop].enemy->dir=fmaCtrl->object[loop].actor->psiData.object->rotate.vy;
				}
				else
				{
					if ( fmaCtrl->object[loop].crc==utilStr2CRC("ROPE01") )
					{
						fmaCtrl->object[loop].actor->position.vx=ropePos[0].vx;
						fmaCtrl->object[loop].actor->position.vy=ropePos[0].vy;
						fmaCtrl->object[loop].actor->position.vz=ropePos[0].vz;
					}
					else if ( fmaCtrl->object[loop].crc==utilStr2CRC("ROPE02") )
					{
						fmaCtrl->object[loop].actor->position.vx=ropePos[1].vx;
						fmaCtrl->object[loop].actor->position.vy=ropePos[1].vy;
						fmaCtrl->object[loop].actor->position.vz=ropePos[1].vz;
					}
				}
			}
		}
	}

#ifdef STANDALONE
	for (loop=0;loop<fmaCtrl->numObjects;loop++)
	{
		if (fmaCtrl->object[loop].crc>1)	// a crc of 0 is the camera
		{
			actorFree(fmaCtrl->object[loop].actor);
		}
	}
 	FREE(fmaCtrl);
	fmaCtrl = NULL;
#else
// RFW - fmaCtrl is now in the BFF
// 	FREE(fmaCtrl);
	fmaCtrl = NULL;
#endif

	draw_routine=old_draw_routine_FMA;
	cycle_routine=old_cycle_routine_FMA;

}

////////////////////////////////////////////////////////////////////////////////////
void	setupModels(void)
{
	int	loop;
	int	firstTime=0;
	int	flag=0;
	ENEMY *enemy;
#ifdef STANDALONE
	for (loop=0;loop<fmaCtrl->numObjects;loop++)
	{
		if (fmaCtrl->object[loop].crc>1)	// a crc of 0 is the camera
		{
			//testchar_model = BFF_IsCRCModelLoaded(fmaCtrl->object[loop].crc);
			testchar_model = BFF_IsCRCModelLoaded(fmaCtrl->object[loop].crc);	// as theres something wrong with the dog use first model
			ASSERT(testchar_model);
			fmaCtrl->object[loop].actor = actorCreate(testchar_model);
			ASSERT(fmaCtrl->object[loop].actor);
			if (!flag)
			{
				mainObject=&fmaCtrl->object[loop];	// the object the puzzels will run off
				flag=1;
			}

			if (!firstTime)
			{
				firstTime=1;
			}

		}
		else if (fmaCtrl->object[loop].crc==0) // 0=camera
		{
			camObject=&fmaCtrl->object[loop];
		}
		else if (fmaCtrl->object[loop].crc==1) // 1= general data
		{
			generalObject=&fmaCtrl->object[loop];
		}
	}
#else
// tbd at the mo fma loads models directly needs to go throught list and get them from there
// bodged the link list with the required models for testing purpases done

	for (loop=0;loop<fmaCtrl->numObjects;loop++)
	{
		if (fmaCtrl->object[loop].crc>1)	// a crc of 0 is the camera
		{
			{
//				if (fmaCtrl->object[loop].crc==utilStr2CRC(characterVars.pMainChar->pEnemy->readData.pInfo->sName))
// Check main char 
				if (fmaCtrl->object[loop].crc==characterVars.pMainChar->pEnemy->readData.nameCRC)
				{
//					DB("found the main model %s\n",characterVars.pMainChar->pEnemy->readData.pInfo->sName);
					int i;
					DB("found the main model\n");

					for (i=0;i<20;i++)
						enemyLookAtPos3D(characterVars.pMainChar->pEnemy, NULL); // point heads forwards


					//if(characterVars.pMainChar->pEnemy->readData.pHead)	// point heads forwards
					//{
					//	characterVars.pMainChar->pEnemy->readData.pHead->rotate.vy = 0;
					//}
					fmaCtrl->object[loop].actor=characterVars.pMainChar->pEnemy->readData.pActor;
					fmaCtrl->object[loop].enemy=characterVars.pMainChar->pEnemy;
				}
				else	// if not main char scan enemy list
				{
					ENEMY *ptr;
					for(ptr=enemyList.head.next; ptr != &enemyList.head; ptr = ptr->next)
					{
						if (fmaCtrl->object[loop].crc==ptr->readData.nameCRC)
						{
							int i;
							DB("found main model in enemy list\n");
							fmaCtrl->object[loop].actor=ptr->readData.pActor;
							fmaCtrl->object[loop].enemy=ptr;
							for (i=0;i<20;i++)
								enemyLookAtPos3D(ptr, NULL); // point heads forwards

							//if(ptr->readData.pHead)
							//{
							//	ptr->readData.pHead->rotate.vy = 0;
							//}
						}
					}
				}
				// special case for the rope
				{
					if ( fmaCtrl->object[loop].crc==utilStr2CRC("ROPE01") )
					{
						// now want to check scenics for the rope (tag 100)
						SCENIC *tempS;
						tempS=scenicFind(100);
						ASSERT(tempS);
						fmaCtrl->object[loop].actor=tempS->pActor;
						ropePos[0].vx=tempS->pActor->position.vx;
						ropePos[0].vy=tempS->pActor->position.vy;
						ropePos[0].vz=tempS->pActor->position.vz;
					}
					if ( fmaCtrl->object[loop].crc==utilStr2CRC("ROPE02") )
					{
						// now want to check scenics for the rope (tag 101)
						SCENIC *tempS;
						tempS=scenicFind(101);
						ASSERT(tempS);
						fmaCtrl->object[loop].actor=tempS->pActor;
						ropePos[1].vx=tempS->pActor->position.vx;
						ropePos[1].vy=tempS->pActor->position.vy;
						ropePos[1].vz=tempS->pActor->position.vz;
					}

				}
			}

/*			{

				temps=scenicFind(100);
				DB("test for debuging\n");
				DB("temp=%d\n",(LONG*)temps);
			}
*/
			if (!flag)
			{
				mainObject=&fmaCtrl->object[loop];	// the object the puzzels will run off
				flag=1;
			}

			if (!firstTime)
			{
				//dummy.pModel=testchar_model;
				//dummy.pActor=fmaCtrl->object[loop].actor
				firstTime=1;
			}

		}
		else if (fmaCtrl->object[loop].crc==0) // 0=camera
		{
			camObject=&fmaCtrl->object[loop];
		}
		else if (fmaCtrl->object[loop].crc==1) // 1= general data
		{
			generalObject=&fmaCtrl->object[loop];
		}


		//if (fmaCtrl->object[loop].crc==utilStr2CRC("GINGER") )
		//	debugActor=fmaCtrl->object[loop].actor;


	}
	//inventoryLoadPlan();
	for (loop=0;loop<fmaCtrl->numObjects;loop++)
	{
		if (fmaCtrl->object[loop].crc>1)
		{
			ASSERT(fmaCtrl->object[loop].actor);	// check models setup ok 
		}		
	}

	// Make sure that at start all char have open eyes
	for(enemy=enemyList.head.next; enemy != &enemyList.head; enemy = enemy->next)
	{
		ASSERT(enemy);
		if( (enemy->runFlags & RUNFLAGS_VISIBLE))
		{
			//enemyBlinkHandler(enemy);	// Needs to be part of the draw routine, not the cycle one
			enemy->blinkCtr==0;
			//enemy->blinkOverride=0;
			textureSetAnimation(enemy->readData.animeyes.pAnim, 0);
		}
	}

#endif
//characterVars.pMainChar->pEnemy->pos;

}

////////////////////////////////////////////////////////////////////////////////////
void	setupPositions(void)
{
	int	loop;
	for (loop=0;loop<fmaCtrl->numObjects;loop++)
	{
		
		objectStartPositions[loop].vx=fmaCtrl->object[loop].pos.vx;
		objectStartPositions[loop].vy=fmaCtrl->object[loop].pos.vy;
		objectStartPositions[loop].vz=fmaCtrl->object[loop].pos.vz;

		if (fmaCtrl->object[loop].crc > 1)	// a crc of 0 is the camera 1=general
		{
			fmaCtrl->object[loop].actor->position.vx=fmaCtrl->object[loop].pos.vx;
			fmaCtrl->object[loop].actor->position.vy=fmaCtrl->object[loop].pos.vy;
			fmaCtrl->object[loop].actor->position.vz=fmaCtrl->object[loop].pos.vz;
			fmaCtrl->object[loop].oldPos.vx=fmaCtrl->object[loop].pos.vx;
			fmaCtrl->object[loop].oldPos.vy=fmaCtrl->object[loop].pos.vy;
			fmaCtrl->object[loop].oldPos.vz=fmaCtrl->object[loop].pos.vz;

			DB("setting model position to X %d Y %d Z %d\n",fmaCtrl->object[loop].pos.vx,fmaCtrl->object[loop].pos.vy,fmaCtrl->object[loop].pos.vz);

#ifndef STANDALONE

			if (&fmaCtrl->object[loop]==mainObject)
			{
				characterVars.pMainChar->pEnemy->pos.vx=fmaCtrl->object[loop].actor->position.vx;
				characterVars.pMainChar->pEnemy->pos.vy=fmaCtrl->object[loop].actor->position.vy;
				characterVars.pMainChar->pEnemy->pos.vz=fmaCtrl->object[loop].actor->position.vz;
			}
			else if (fmaCtrl->object[loop].crc>1)
			{
				if (fmaCtrl->object[loop].crc!=utilStr2CRC("ROPE01") && fmaCtrl->object[loop].crc!=utilStr2CRC("ROPE02") )
				{
					fmaCtrl->object[loop].enemy->pos.vx=fmaCtrl->object[loop].pos.vx;
					fmaCtrl->object[loop].enemy->pos.vy=fmaCtrl->object[loop].pos.vy;
					fmaCtrl->object[loop].enemy->pos.vz=fmaCtrl->object[loop].pos.vz;
				}
			}
#endif
		}
		else if (fmaCtrl->object[loop].crc==0)
		{
			mycamera.vpx = fmaCtrl->object[loop].pos.vx;
			mycamera.vpy = fmaCtrl->object[loop].pos.vy;
			mycamera.vpz = fmaCtrl->object[loop].pos.vz;

			fmaCtrl->object[loop].oldPos.vx=fmaCtrl->object[loop].pos.vx;
			fmaCtrl->object[loop].oldPos.vy=fmaCtrl->object[loop].pos.vy;
			fmaCtrl->object[loop].oldPos.vz=fmaCtrl->object[loop].pos.vz;

			DB("setting camera position to X %d Y %d Z %d\n",fmaCtrl->object[loop].pos.vx,fmaCtrl->object[loop].pos.vy,fmaCtrl->object[loop].pos.vz);
			//if (fmaCtrl->object[loop].pos.pad!=999)	// holds target number
		}
	}
}

//	added to make text display in draw instead of cycle
int	numTextStrings;
int	textNumbers[10];	// if we have more than 10 then somthing has gone wrong in a big way
int	textColours[10];	// record the colour for later use
////////////////////////////////////////////////////////////////////////////////////

/*
int testPosX=0;
int	testPosY=60;
*/

void	FMAtestDraw(void)
{
	int	loop,target;
	ENEMY *enemy;
	char	*string;	

	if (camObject->tracking==TARGET)
	{
		target=camObject->trackNum;
		mycamera.vrx=fmaCtrl->object[target].actor->position.vx;
		mycamera.vry=fmaCtrl->object[target].actor->position.vy;
		mycamera.vrz=fmaCtrl->object[target].actor->position.vz;
	}

	mapCamSetRefView2L(&mycamera);

	overlayPreviewOverlay();
	debrisDraw();
	texanimDraw();
	platformDraw();
	scenicDrawAll();
//	enemyDrawAll();	// let see if we can get the eyes working, well its gets the eyes to blink but spacks up every thing else


#ifdef STANDALONE
	if (!fmaStatus.planOn)
		MapDraw_DrawFMA_World(mapview_fma_world);
#else
	if (!fmaStatus.planOn)
		MapDraw_DrawFMA_World(mapplay_fma_world);
#endif


	EXLIGHT_DebugDrawLights();

	//textDisplay();
	//mapviewBasicMapCycle();


	if (fmaStatus.holdFrameFlag==2 && !fmaStatus.menuOn)
	{
#if PALMODE == 1
		//fontPrintCentred(font,0,60,TEXTSTR(TEXTSTR_ALLACTS_FMAMENU), 128,128,128);

		//if (padData.digital[0] & PAD_UP) testPosY--;
		//if (padData.digital[0] & PAD_DOWN) testPosY++;


		if (loop_ticker2&2)
			overlaySprite(FMAcross, 210,108, 0,0xff808080);
		else
			overlaySprite(FMAcross, 210,108, 0,0xffeeeeee);

/*		if (padData.debounce[0] & PAD_UP) testPosY--;
		if (padData.debounce[0] & PAD_DOWN) testPosY++;

		if (padData.debounce[0] & PAD_LEFT) testPosX--;
		if (padData.debounce[0] & PAD_RIGHT) testPosX++;
*/

		//fontPrintCentred(font,0,60,"@X", 128,128,128);
#else
		//fontPrintCentred(font,0,60-25,TEXTSTR(TEXTSTR_ALLACTS_FMAMENU), 128,128,128);
		//fontPrintCentred(font,0,60-25,"@X", 128,128,128);

		if (loop_ticker2&2)
			overlaySprite(FMAcross, 210,108-25, 0,0xff808080);
		else
			overlaySprite(FMAcross, 210,108-25, 0,0xffeeeeee);


#endif
	}


	if ( (fmaStatus.fadeStatus!=NOFADE) && !fmaStatus.holdFrameFlag)
	{
		deathScreenAdd(fmaStatus.fadeAmount, fmaStatus.fadeAmount, fmaStatus.fadeAmount, SEMITRANS_SUB, 1);
	}

	if (fmaStatus.planOn)
		fmaDrawPlan();


	for(enemy=enemyList.head.next; enemy != &enemyList.head; enemy = enemy->next)
	{
		ASSERT(enemy);

		if( (enemy->runFlags & RUNFLAGS_VISIBLE))
		{
			//enemy->blinkOverride=1;
			enemyBlinkHandler(enemy);	// Needs to be part of the draw routine, not the cycle one
		}
	}

	//fmaStatus.menuOn=TRUE;
	if (fmaStatus.menuOn && (SpecialCaseFma==ACT2FMA1 || SpecialCaseFma==ACT2FMA2) )
	{
		fmaStatus.menuOnTime++;
#if PALMODE == 1
		//fontPrintCentred(font,0,0,TEXTSTR(TEXTSTR_ACT2_FMAMENU_EXIT), 128,128,128);
		fontPrintCentred(font,0,0,TEXTSTR(TEXTSTR_ACT2_FMAMENU_SEESAW), 128,128,128);
		fontPrintCentred(font,0,20,TEXTSTR(TEXTSTR_ACT2_FMAMENU_FIREWORKS), 128,128,128);
		fontPrintCentred(font,0,40,TEXTSTR(TEXTSTR_ACT2_FMAMENU_CATAPULT), 128,128,128);
		fontPrintCentred(font,0,60,TEXTSTR(TEXTSTR_ACT2_FMAMENU_EXIT), 128,128,128);

		fontCentredMultiLine(font,0,78,(512-40),TEXTSTR(TEXTSTR_ALLACTS_FMACHOOSE), 128,128,128);
#else
		//fontPrintCentred(font,0,0-25,TEXTSTR(TEXTSTR_ACT2_FMAMENU_EXIT), 128,128,128);
		fontPrintCentred(font,0,0-25,TEXTSTR(TEXTSTR_ACT2_FMAMENU_SEESAW), 128,128,128);
		fontPrintCentred(font,0,20-25,TEXTSTR(TEXTSTR_ACT2_FMAMENU_FIREWORKS), 128,128,128);
		fontPrintCentred(font,0,40-25,TEXTSTR(TEXTSTR_ACT2_FMAMENU_CATAPULT), 128,128,128);
		fontPrintCentred(font,0,60-25,TEXTSTR(TEXTSTR_ACT2_FMAMENU_EXIT), 128,128,128);

		fontCentredMultiLine(font,0,78-25,(512-40),TEXTSTR(TEXTSTR_ALLACTS_FMACHOOSE), 128,128,128);
#endif
/*
#if PALMODE == 1
		fontCentredMultiLine(font,0,78,(512-40),TEXTSTR(TEXTSTR_ALLACTS_FMACHOOSE), 128,128,128);
#else
		fontCentredMultiLine(font,0,78-10,(512-40),TEXTSTR(TEXTSTR_ALLACTS_FMACHOOSE), 128,128,128);
#endif
*/
	}
	if (fmaStatus.menuOn && ((SpecialCaseFma==ACT4FMA1) || (SpecialCaseFma==ACT4FMA2)) )
	{
		fmaStatus.menuOnTime++;
#if PALMODE == 1
		//fontPrintCentred(font,0,0,TEXTSTR(TEXTSTR_ACT4_FMAMENU_EXIT), 128,128,128);
		fontPrintCentred(font,0,0,TEXTSTR(TEXTSTR_ACT4_FMAMENU_ENGINE), 128,128,128);
		fontPrintCentred(font,0,20,TEXTSTR(TEXTSTR_ACT4_FMAMENU_CONSTRUCTION), 128,128,128);
		fontPrintCentred(font,0,40,TEXTSTR(TEXTSTR_ACT4_FMAMENU_WINGS), 128,128,128);
		fontPrintCentred(font,0,60,TEXTSTR(TEXTSTR_ACT4_FMAMENU_EXIT), 128,128,128);

		fontCentredMultiLine(font,0,78,(512-40),TEXTSTR(TEXTSTR_ALLACTS_FMACHOOSE), 128,128,128);
#else
		//fontPrintCentred(font,0,0-25,TEXTSTR(TEXTSTR_ACT4_FMAMENU_EXIT), 128,128,128);
		fontPrintCentred(font,0,0-25,TEXTSTR(TEXTSTR_ACT4_FMAMENU_ENGINE), 128,128,128);
		fontPrintCentred(font,0,20-25,TEXTSTR(TEXTSTR_ACT4_FMAMENU_CONSTRUCTION), 128,128,128);
		fontPrintCentred(font,0,40-25,TEXTSTR(TEXTSTR_ACT4_FMAMENU_WINGS), 128,128,128);
		fontPrintCentred(font,0,60-25,TEXTSTR(TEXTSTR_ACT4_FMAMENU_EXIT), 128,128,128);

		fontCentredMultiLine(font,0,78-25,(512-40),TEXTSTR(TEXTSTR_ALLACTS_FMACHOOSE), 128,128,128);
#endif
	}
	//fmaStatus.menuOn=FALSE;
/*	if (!fmaStatus.menuOn && fmaStatus.holdFrameFlag==2)
	{
		fontPrintCentred(font,0,60,"Press @X to continue", 128,128,128);
	}
*/

	if (!fmaStatus.planOn)
	{
		for (loop=0;loop<fmaCtrl->numObjects;loop++)
		{
			if (fmaCtrl->object[loop].crc>1)	// a crc of 0 is the camera 1 is for general commands
			{
				ASSERT(fmaCtrl->object[loop].actor);
				actorUpdateAnimations(fmaCtrl->object[loop].actor);
				EXLIGHT_SetupActorLights(fmaCtrl->object[loop].actor);
				//enemyBlinkHandler(pE);
#ifndef _WINDOWS
				if (actorIsVisible(fmaCtrl->object[loop].actor) )
					actorDraw(fmaCtrl->object[loop].actor);
#else
				if (actorIsVisible(fmaCtrl->object[loop].actor) )
					d2mActorDraw(fmaCtrl->object[loop].actor);
#endif
			}
		}
	}
	proccessObjectAngles();

	drawOverlayPloys();

	// moved from cycle
	// JS: and moved to the end of the draw code by me from the PC 3D hardware version of the game

	for (loop=0;loop<numTextStrings;loop++) 
	{
		int	r,g,b,test;

		string=TEXTSTR(textNumbers[loop]);

		//test=0;
		r=128;g=128;b=128;
		if (string[0]=='c')
		{
			switch (string[1])
			{
/*				case	'0':
					r=128;g=128;b=128;
					string+=2;
					break;
*/				case	'1':
					r=128;g=64;b=0;	//Orange
					string+=2;
					break;
				case	'2':
					r=128;g=128;b=128;	// white
					string+=2;
					break;
				case	'3':
					r=128;g=128;b=0;	// yellow
					string+=2;
					break;
				case	'4':
					r=0;g=64;b=128;		// cyan
					string+=2;
					break;
				case	'5':
					r=0;g=100;b=0;		// green
					string+=2;
					break;
				case	'6':
					//r=157/2;g=110/2;b=57/2; 	// Light brown
					r=78;g=55;b=28; 	// Light brown
					string+=2;
					break;
				case	'7':
					r=78;g=71;b=28;	// light brown II
					string+=2;
					break;
				case	'8':
					r=128;g=70;b=0;	// l brwn
					string+=2;
					break;
				case	'9':
					r=128;g=0;b=0;	// red
					string+=2;
					break;
			}
			//string+=2;
		}
		//if (string[0]=='c' && string[1]=='1') test=5;
		//if (string[0]=='c' && string[1]=='2') test=0;
		//if (test) string+=2;
		//string+=2;
		//switch (textColours[loop])	// tdb change this for chicken portrate
/*		switch (test)	// tdb change this for chicken portrate
		{
		 	case WHITE:
				r=128;g=128;b=128;
				break;
			case LBLUE:
				r=26;g=100;b=128;
				break;
			case BLUE:
				r=0;g=0;b=128;
				break;
			case YELLOW:
				r=128;g=128;b=0;
				break;
			case GREEN:
				r=0;g=128;b=0;
				break;
			case ORANGE:
				r=128;g=70;b=0;
				break;
			default:
				DB("unknown colour setting to white\n");
				r=128;g=128;b=128;
				break;
		}
*/		//fontCentredMultiLine(font,0,78,(512-40), TEXTSTR(textNumbers[loop]), r,g,b);


//		r=128;g=128;b=128;	// untill we sort the colours out set to white

#if PALMODE == 1
		fontCentredMultiLine(font,0,78,(512-40), string, r,g,b);
#else
		//fontCentredMultiLine(font,0,78-10,(512-40), string, r,g,b);
		fontCentredMultiLine(font,0,78-25,(512-40), string, r,g,b);
#endif
		//fontCentredMultiLine(font,0,78,(512-40), string, r,g,b);
	}
	if (fmaStatus.fade) holdFade();
}

////////////////////////////////////////////////////////////////////////////////////
//FMADATA	*FMADATA;
void	FMAtestCycle(void)
{
	int	loop,loop1;
	FMADATA		*fmaData;
	FMAOBJECT	*fmaObject;
	char		message[255];

	char		*debug;

	//if (frameTimeCount==0) setupPositions();


	fmaStatus.fadeStatus=NOFADE;	// reset this and work it out again (stops the skip frame fuck up)

	//DB("SpecialCaseFma %d\n",SpecialCaseFma);

	if ( (SpecialCaseFma==ACT2FMA1) || (SpecialCaseFma==ACT2FMA2) ) specialMenuAct2();
	else if ( (SpecialCaseFma==ACT4FMA1) || (SpecialCaseFma==ACT4FMA2) ) specialMenuAct4();

	for (loop=0;loop<fmaCtrl->numObjects;loop++)
	{
		fmaObject=&fmaCtrl->object[loop];
		fmaObject->flags=0;
	}
	fmaStatus.planOn=FALSE;

	numTextStrings=0;
	for (loop=0;loop<10;loop++)
		textNumbers[loop]=0;

	fmaStatus.breakFlag=FALSE;

	for (loop=0;loop<fmaCtrl->numObjects;loop++)
	{
		fmaObject=&fmaCtrl->object[loop];
		fmaData=&fmaCtrl->object[loop].data[0];
		for (loop1=0;loop1<fmaObject->numCommands;loop1++)
		{
			if ( (fmaData->startTime<=frameTimeCount) && (fmaData->endTime>=frameTimeCount) )
			{
				if (fmaObject->crc!=1) processCmd(fmaObject,fmaData);
				else processGeneralCmd(fmaObject,fmaData);
				if (fmaExitFlag) return;
			}
			fmaData++;
		}
	}

	if (fmaStatus.breakOverideCount)	// if just made menu choice stop skip for a bit 
	{
		fmaStatus.breakOverideCount--;
		fmaStatus.breakFlag=FALSE;
	}

	if (fmaStatus.breakFlag && (padData.debounce[0] & (PAD_CROSS|PAD_SQUARE|PAD_TRIANGLE|PAD_CIRCLE) ) && !fmaStatus.menuOn )
		jumpToFrame();

	
//	textDisplay();
//	mapviewBasicMapCycle();

 	/*
 	enemyProcessAll();
	deat
	debrisCycle();
	EXLIGHT_Update();
	platformCycle();
	texanimCycle();
	scenicCycle();
	*/

//	mapviewBasicMapDraw();

//	puzzleCheckPuzzles();

	//mapviewBasicMapCycle();

	mapviewBasicFmaMapCycle();



#if GOLDCD==0
	sprintf(message,"frameTimeCount %d",frameTimeCount);
	fontPrint(font, -200,-110, message, 128,128,0);
#endif

	if (fmaStatus.holdFrameFlag==1)
	{
		fmaStatus.holdFrameFlag=2;
	}
	else if (fmaStatus.holdFrameFlag==2)
	{
		//if ( (padData.digital[0] & (PAD_CROSS|PAD_SQUARE|PAD_TRIANGLE|PAD_CIRCLE) )  && !fmaStatus.menuOn)
		if ( (padData.digital[0] & (PAD_CROSS) )  && !fmaStatus.menuOn)
		{
			fmaStatus.holdFrameFlag=0;
			frameTimeCount++;
		}
	}
	else /*if (!( loop_ticker2%8))*/ frameTimeCount++;


	if ( (fmaStatus.XAplaying==TEXTWITHXAWAITING) && !XAcheckPlay() && fmaStatus.holdFrameFlag==0)
	{
		frameTimeCount--; // if we have XA with the text stop the counter untill xa has started
	}

	if ( (fmaStatus.XAplaying==TEXTWITHXAWAITING) && XAcheckPlay())
		fmaStatus.XAplaying=TEXTWITHXAPLAYING;

}

////////////////////////////////////////////////////////////////////////////////////
typedef struct
{
	int	startTime;
	int	endTime;
}MENUDATAFMA;

/*
MENUDATAFMA briefTimesAct2[] =
{
	{0,		480 },	// 1st brief
	{501,	1000},	// 2nd brief
	{1001,	1500},	// end string
	{2001,	3000},	// seesaw
	{3001,	4000},	// fireworks
	{4001,	5000},	// catapult
	{5001,	6000}	// exit brief
};
*/

MENUDATAFMA briefTimesAct2a[] =
{
	{0,		700 },	// 1st brief
	{0,		700},	// 2nd brief
	{600,	700},	// end string
	{1001,	1500},	// seesaw
	{2001,	2700},	// fireworks
	{3001,	3800},	// catapult
	{4001,	4100}	// exit brief
};

MENUDATAFMA briefTimesAct2b[] =
{
	{0,		200 },	// 1st brief
	{0,		200},	// 2nd brief
	{100,	200},	// end string
	{1001,	1500},	// seesaw
	{2001,	2700},	// fireworks
	{3001,	3800},	// catapult
	{4001,	4301}	// exit brief
};

enum
{
	A2BRIEF1,
	A2BRIEF2,
	A2ENDSTRING,
	A2SEESAWBRIEF,
	A2FIREWORKSBRIEF,
	A2CATAPULTBRIEF,
	A2EXITBRIEF,
	MAXA2BRIEF
};


void	specialMenuAct2(void)
{
	int	testFlag=FALSE;
	int	loop,temp;
	int	brief=0;

	for (loop=0;loop<MAXA2BRIEF;loop++)
	{
		if (SpecialCaseFma==ACT2FMA1)
		{
			if (briefTimesAct2a[loop].endTime==frameTimeCount) // has anything finished
			{
				testFlag=TRUE;
				brief=loop;
				break;
			}
		}
		else
		{
			if (briefTimesAct2b[loop].endTime==frameTimeCount) // has anything finished
			{
				testFlag=TRUE;
				brief=loop;
				break;
			}
		}
	}
	if (!testFlag) return;

	// ok weve reached the end of a segment
	if ( (brief==A2BRIEF1) || (brief==A2BRIEF2) || (brief==A2ENDSTRING) )
	{
		fmaStatus.holdFrameFlag=2;	// stop the timer
		fmaStatus.menuOn=TRUE;		// display the menu

		if (fmaStatus.menuOnTime>20)		
			fmaStatus.menuChoice=( padData.debounce[0]&(PAD_TRIANGLE|PAD_SQUARE|PAD_CIRCLE|PAD_CROSS) );
		else
			fmaStatus.menuChoice=NULL;	// stops accidental menu activation after pressing button to skip

		switch(fmaStatus.menuChoice)
		{
#ifdef DREAMCAST		
			case	PAD_CIRCLE:
#else
			case	PAD_TRIANGLE:
#endif

				if (SpecialCaseFma==ACT2FMA1)
					frameTimeCount=briefTimesAct2a[A2EXITBRIEF].startTime;
				else
					frameTimeCount=briefTimesAct2b[A2EXITBRIEF].startTime;

				DB("frametime set to %d\n",frameTimeCount);
				fmaStatus.holdFrameFlag=0;
				fmaStatus.menuOn=FALSE;
				fmaStatus.breakOverideCount=10;
				fmaStatus.menuOnTime=0;
				break;

			case	PAD_SQUARE:
				frameTimeCount=briefTimesAct2a[A2SEESAWBRIEF].startTime;	// as a and b have the same time for most thing no need to check
				DB("frametime set to %d\n",frameTimeCount);
				fmaStatus.holdFrameFlag=0;
				fmaStatus.menuOn=FALSE;
				fmaStatus.breakOverideCount=10;
				fmaStatus.menuOnTime=0;
				break;

			case	PAD_CROSS:
				frameTimeCount=briefTimesAct2a[A2FIREWORKSBRIEF].startTime;
				DB("frametime set to %d\n",frameTimeCount);
				fmaStatus.holdFrameFlag=0;
				fmaStatus.menuOn=FALSE;
				fmaStatus.breakOverideCount=10;
				fmaStatus.menuOnTime=0;
				break;

#ifdef DREAMCAST
			case	PAD_TRIANGLE:
#else
			case	PAD_CIRCLE:
#endif
				frameTimeCount=briefTimesAct2a[A2CATAPULTBRIEF].startTime;
				DB("frametime set to %d\n",frameTimeCount);
				fmaStatus.holdFrameFlag=0;
				fmaStatus.menuOn=FALSE;
				fmaStatus.breakOverideCount=10;
				fmaStatus.menuOnTime=0;
				break;

			default:
				fmaStatus.holdFrameFlag=2;	// stop the timer
				break;
		}
	}
	if ( (brief==A2SEESAWBRIEF) || (brief==A2FIREWORKSBRIEF) || (brief==A2CATAPULTBRIEF) )	// reach end
	{
		if (SpecialCaseFma==ACT2FMA1)
			frameTimeCount=briefTimesAct2a[A2ENDSTRING].startTime;
		else
			frameTimeCount=briefTimesAct2b[A2ENDSTRING].startTime;
	}

	// best if the fma exits on it own
	//if ( brief==A2EXITBRIEF ) 


}

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

//INTRO		0001-1200
//ENGINE		2001-2700
//CONSTRUCTION	3001-3800
//WINGS		4001-4300
//OUTRO		5001-5501


MENUDATAFMA briefTimesAct4a[] =
{
	{0,		1120 },	// 1st brief
	{0,		1120},	// 2nd brief
	{1100,	1120},	// end string
	{2001,	2700},	// engine
	{3001,	3800},	// construction
	{4001,	4300},	// wings
	{5001,	5501}	// exit brief
};


MENUDATAFMA briefTimesAct4b[] =
{
	{0,		300 },	// 1st brief
	{0,		300},	// 2nd brief
	{200,	300},	// end string

	{2001,	2700},	// engine
	{3001,	3800},	// construction
	{4001,	4300},	// wings
	{5001,	5301}	// exit brief
};


//INTRO		0001-300
//ENGINE		2001-2700
//CONSTRUCTION	3001-3800
//WINGS		4001-4300
//OUTRO		5001-5301	


enum
{
	A4BRIEF1,
	A4BRIEF2,
	A4ENDSTRING,
	A4ENGINEBRIEF,
	A4CONSTRUCTIONBRIEF,
	A4WINGBRIEF,
	A4EXITBRIEF,
	MAXA4BRIEF
};


void	specialMenuAct4(void)
{
	int	testFlag=FALSE;
	int	loop,temp;
	int	brief=0;
	
	for (loop=0;loop<MAXA4BRIEF;loop++)
	{
		if (SpecialCaseFma==ACT4FMA1)
		{
			if (briefTimesAct4a[loop].endTime==frameTimeCount) // has anything finished
			{
				testFlag=TRUE;
				brief=loop;
				break;
			}
		}
		else
		{
			if (briefTimesAct4b[loop].endTime==frameTimeCount) // has anything finished
			{
				testFlag=TRUE;
				brief=loop;
				break;
			}
		}
	}
	if (!testFlag) return;


	if ( (brief==A4BRIEF1) || (brief==A4BRIEF2) || (brief==A4ENDSTRING) )
	{
		fmaStatus.holdFrameFlag=2;	// stop the timer
		fmaStatus.menuOn=TRUE;		// display the menu
		
		if (fmaStatus.menuOnTime>20)		
			fmaStatus.menuChoice=( padData.debounce[0]&(PAD_TRIANGLE|PAD_SQUARE|PAD_CIRCLE|PAD_CROSS) );
		else
			fmaStatus.menuChoice=NULL;	// stops accidental menu activation after pressing button to skip

		switch(fmaStatus.menuChoice)
		{
#ifdef DREAMCAST
			case	PAD_CIRCLE:
#else
			case	PAD_TRIANGLE:
#endif
				if (SpecialCaseFma==ACT4FMA1)
					frameTimeCount=briefTimesAct4a[A4EXITBRIEF].startTime;
				else
					frameTimeCount=briefTimesAct4b[A4EXITBRIEF].startTime;
				DB("frametime set to %d\n",frameTimeCount);
				fmaStatus.holdFrameFlag=0;
				fmaStatus.menuOn=FALSE;
				fmaStatus.breakOverideCount=10;
				fmaStatus.menuOnTime=0;
				break;

			case	PAD_SQUARE:
				frameTimeCount=briefTimesAct4a[A4ENGINEBRIEF].startTime;
				DB("frametime set to %d\n",frameTimeCount);
				fmaStatus.holdFrameFlag=0;
				fmaStatus.menuOn=FALSE;
				fmaStatus.breakOverideCount=10;
				fmaStatus.menuOnTime=0;
				break;

			case	PAD_CROSS:
				frameTimeCount=briefTimesAct4a[A4CONSTRUCTIONBRIEF].startTime;
				DB("frametime set to %d\n",frameTimeCount);
				fmaStatus.holdFrameFlag=0;
				fmaStatus.menuOn=FALSE;
				fmaStatus.breakOverideCount=10;
				fmaStatus.menuOnTime=0;
				break;

#ifdef DREAMCAST
			case	PAD_TRIANGLE:
#else
			case	PAD_CIRCLE:
#endif
				frameTimeCount=briefTimesAct4a[A4WINGBRIEF].startTime;
				DB("frametime set to %d\n",frameTimeCount);
				fmaStatus.holdFrameFlag=0;
				fmaStatus.menuOn=FALSE;
				fmaStatus.breakOverideCount=10;
				fmaStatus.menuOnTime=0;
				break;

			default:
				fmaStatus.holdFrameFlag=2;	// stop the timer
				break;
		}
	}
	if ( (brief==A4ENGINEBRIEF) || (brief==A4CONSTRUCTIONBRIEF) || (brief==A4WINGBRIEF) )	// reach end
	{
		if (SpecialCaseFma==ACT4FMA1)
			frameTimeCount=briefTimesAct4a[A4ENDSTRING].startTime;
		else
			frameTimeCount=briefTimesAct4b[A4ENDSTRING].startTime;
	}


}
////////////////////////////////////////////////////////////////////////////////////
void	processCmd(FMAOBJECT* object,FMADATA* data)
{
	
	ASSERT(object);

	ASSERT(data);
	//if (!data) return;

	switch(data->action)
	{
		case CMD_MOVE_TO:
			processMove(object,data);
			break;

		case CMD_JUMP_TO:
			processJump(object,data);
			break;

		case CMD_ANIM:
			//DB("anim change found\n");
			processAnim(object,data);
			break;

		case CMD_TARGET_OBJECT:
			processTargetObj(object,data);
			break;

		case CMD_TARGET_POS:
			processCamTarget(object,data);

		case CMD_CAM_CIRCLE:
			processCamCircle(object,data);
			break;

		case CMD_CAM_CUTTO:
			processCamCutTo(object,data);
			break;

		case CMD_FACE_ANGLE:
			processFaceAngle(object,data);
			break;

		case CMD_FACE_TO:
			processFaceObject(object,data);
			break;
	}
}
////////////////////////////////////////////////////////////////////////////////////
void	processGeneralCmd(FMAOBJECT* object,FMADATA* data)
{

	ASSERT(object);
	ASSERT(data);

	switch(data->action)
	{
		case CMD_FADE_UP:
			processFadeUp(object,data);
			break;

		case CMD_FADE_DOWN:
			processFadeDown(object,data);
			break;

		case CMD_BREAK_ON:
			// pause and skips need to be addressed
			fmaStatus.breakFlag=TRUE;
			fmaStatus.timeToJumpTo=data->spare1;
			break;

		case CMD_BREAK_OFF:
			fmaStatus.breakFlag=FALSE;
			break;

		case CMD_CONVERSATION:
			processConversation(object,data);
			break;

		case CMD_SOUND:
			processSound(object,data);
			break;

		case CMD_MUSIC:
			processMusic(object,data);
			break;

		case CMD_HOLD:
			//DB("test for hold\n");
			if (!fmaStatus.holdFrameFlag && fmaStatus.planOn) fmaStatus.holdFrameFlag=1;
			//if (!fmaStatus.holdFrameFlag ) fmaStatus.holdFrameFlag=1;
			//DB("hold processed\n");
			break;

		case CMD_PLAN:
			processPlan(object,data);
			break;

		case CMD_EXIT:
			processExit(object,data);
			break;
	}			  
}
////////////////////////////////////////////////////////////////////////////////////

// this is only going to be able to cope with 1 char jumping at an one time
VECTOR	jumpStart;
//VECTOR	jumpEnd;

void	processJump(FMAOBJECT* object,FMADATA* data)
{

	int	currentTime,timeLen;
	VECTOR	oldPos,pos,tempVec;
	int	angle,angle1,temp;
	int	jumpHeight,sin;

	if (frameTimeCount==data->startTime)	// check for just started
	{
		// This is causing the fma when restarted to be in wrong position
		jumpStart.vx=object->pos.vx=object->actor->position.vx;	// store position so  interpolation can procede
		jumpStart.vy=object->pos.vy=object->actor->position.vy;
		jumpStart.vz=object->pos.vz=object->actor->position.vz;
		object->timeLen=data->endTime-data->startTime;
	}
	currentTime=frameTimeCount-data->startTime;

	oldPos.vx=object->actor->position.vx;
	oldPos.vy=object->actor->position.vy;
	oldPos.vz=object->actor->position.vz;

	object->actor->position.vx=( (jumpStart.vx*(object->timeLen-currentTime))+(data->targetPos.vx*currentTime) )/object->timeLen;
	object->actor->position.vy=( (jumpStart.vy*(object->timeLen-currentTime))+(data->targetPos.vy*currentTime) )/object->timeLen;
	object->actor->position.vz=( (jumpStart.vz*(object->timeLen-currentTime))+(data->targetPos.vz*currentTime) )/object->timeLen;

	tempVec.vx=jumpStart.vx-data->targetPos.vx;
	tempVec.vy=jumpStart.vy-data->targetPos.vy;
	tempVec.vz=jumpStart.vz-data->targetPos.vz;

	jumpHeight=Magnitude(&tempVec)/2;
	sin=rsin( (currentTime*2048)/object->timeLen );
	jumpHeight=(jumpHeight*sin)/4096;
	object->actor->position.vy-=jumpHeight;
/*
#ifndef STANDALONE
		if (object==mainObject)
		{
			characterVars.pMainChar->pEnemy->pos.vx=object->actor->position.vx;
			characterVars.pMainChar->pEnemy->pos.vy=object->actor->position.vy;
			characterVars.pMainChar->pEnemy->pos.vz=object->actor->position.vz;
		}
#endif
*/

}

////////////////////////////////////////////////////////////////////////////////////
void	processMove(FMAOBJECT* object,FMADATA* data)
{
	int	currentTime,timeLen;
	VECTOR	oldPos,pos;
	int	angle,angle1,temp;

	//DB("for debug\n");

	if (camObject!=object)
	{
		if (frameTimeCount==data->startTime)	// check for just started
		{
			// This is causing the fma when restarted to be in wrong position
			object->pos.vx=object->actor->position.vx;	// store position so  interpolation can procede
			object->pos.vy=object->actor->position.vy;
			object->pos.vz=object->actor->position.vz;
			object->timeLen=data->endTime-data->startTime;
		}
		currentTime=frameTimeCount-data->startTime;

		oldPos.vx=object->actor->position.vx;
		oldPos.vy=object->actor->position.vy;
		oldPos.vz=object->actor->position.vz;

		object->actor->position.vx=( (object->pos.vx*(object->timeLen-currentTime))+(data->targetPos.vx*currentTime) )/object->timeLen;
		object->actor->position.vy=( (object->pos.vy*(object->timeLen-currentTime))+(data->targetPos.vy*currentTime) )/object->timeLen;
		object->actor->position.vz=( (object->pos.vz*(object->timeLen-currentTime))+(data->targetPos.vz*currentTime) )/object->timeLen;

#ifndef STANDALONE
		if (object==mainObject)
		{
			characterVars.pMainChar->pEnemy->pos.vx=object->actor->position.vx;
			characterVars.pMainChar->pEnemy->pos.vy=object->actor->position.vy;
			characterVars.pMainChar->pEnemy->pos.vz=object->actor->position.vz;
		}
#endif

/*		if (!(object->flags&STOPMOVEFACE))
		{
			angle=(calc_angle((oldPos.vx-object->actor->position.vx),(oldPos.vz-object->actor->position.vz)))&4095;
			angle1=object->actor->psiData.object->rotate.vy&4095;
			temp=findShortestAngle(angle,angle1);
			if (temp>DEFAULTTURNRATE) temp=DEFAULTTURNRATE;
			if (temp<-DEFAULTTURNRATE) temp=-DEFAULTTURNRATE;
			object->actor->psiData.object->rotate.vy+=temp;
		}
*/	}
	else
	{
		if (frameTimeCount==data->startTime)	// check for just started
		{
			//object->oldPos.vx=object->pos.vx;
			//object->oldPos.vy=object->pos.vy;
			//object->oldPos.vz=object->pos.vz;

			object->pos.vx=mycamera.vpx;
			object->pos.vy=mycamera.vpy;
			object->pos.vz=mycamera.vpz;

			//object->pos.vx=data->targetPos.vx;
			//object->pos.vy=data->targetPos.vy;
			//object->pos.vz=data->targetPos.vz;

			//object->timeLen=data->endTime-data->startTime;
		}
	
		pos.vx=data->targetPos.vx;
		pos.vy=data->targetPos.vy;
		pos.vz=data->targetPos.vz;

		currentTime=frameTimeCount-data->startTime;
		timeLen=data->endTime-data->startTime;

		mycamera.vpx=( (object->pos.vx*(timeLen-currentTime))+(pos.vx*currentTime) )/timeLen;
		mycamera.vpy=( (object->pos.vy*(timeLen-currentTime))+(pos.vy*currentTime) )/timeLen;
		mycamera.vpz=( (object->pos.vz*(timeLen-currentTime))+(pos.vz*currentTime) )/timeLen;
		camObject->flags==0;

		//DB("moving camera to X %d Y %d Z %d\n",mycamera.vpx/8,-(mycamera.vpy/8),mycamera.vpz/8);
	}
}


////////////////////////////////////////////////////////////////////////////////////
void	processAnim(FMAOBJECT* object,FMADATA* data)
{
	actorAnimate(object->actor, data->animSegment, data->targetPos.vz, data->targetPos.vy, data->targetPos.vx, 0, data->spare1);	// anim #, loop, queue, speed, skiplast

	DB("seg = %d speed = %d queue = %d loop = %d blend = %d\n",data->animSegment,data->targetPos.vx,data->targetPos.vy,data->targetPos.vz,data->spare1);
}

////////////////////////////////////////////////////////////////////////////////////
void	processTargetObj(FMAOBJECT* object,FMADATA* data)
{
	int		currentTime;
	VECTOR	pos,pos1;
	FMAOBJECT	*fmaObject;

	if (object->actor) // 
	{
		DB("only works with camera at the mo\n");
		CRASH;
	}

	if (camObject->tracking)
	{
		fmaObject=&fmaCtrl->object[camObject->trackNum];	// get pos from tracked object
		pos.vx=fmaObject->actor->position.vx;
		pos.vy=fmaObject->actor->position.vy;
		pos.vz=fmaObject->actor->position.vz;
		camObject->tracking=NOUPDATE;
	}
	else if (frameTimeCount==data->startTime)
	{
		pos.vx=camObject->pos.vx=mycamera.vrx;
		pos.vy=camObject->pos.vy=mycamera.vry;
		pos.vz=camObject->pos.vz=mycamera.vrz;
	}
	else
	{
		pos.vx=camObject->pos.vx;
		pos.vy=camObject->pos.vy;
		pos.vz=camObject->pos.vz;
	}
	currentTime=frameTimeCount-data->startTime;	
	object->timeLen=data->endTime-data->startTime;

	if (frameTimeCount==data->endTime)
	{
		camObject->tracking=TARGET;
		camObject->trackNum=data->targetNum;
	}

	fmaObject=&fmaCtrl->object[data->targetNum];	// get pos from tracked object

	pos1.vx=fmaObject->actor->position.vx;
	pos1.vy=fmaObject->actor->position.vy;
	pos1.vz=fmaObject->actor->position.vz;

	mycamera.vrx=( (pos.vx*(object->timeLen-currentTime) )+(pos1.vx*currentTime) )/object->timeLen;
	mycamera.vry=( (pos.vy*(object->timeLen-currentTime) )+(pos1.vy*currentTime) )/object->timeLen;
	mycamera.vrz=( (pos.vz*(object->timeLen-currentTime) )+(pos1.vz*currentTime) )/object->timeLen;

}

////////////////////////////////////////////////////////////////////////////////////
void	processCamCircle(FMAOBJECT* object,FMADATA* data)
{
	int		dist,angle,time;
	VECTOR	rot,pos;
	FMAOBJECT	*fmaObject;
	
	DB("cam circle\n");

	if (object!=camObject)
	{
		DB("error in fma cam circle\n");
		CRASH;
	}
	
	if (data->startTime==frameTimeCount)	// store starting pos on first frame
	{
		object->pos.vx=mycamera.vpx;
		object->pos.vy=mycamera.vpy;
		object->pos.vz=mycamera.vpz;
		object->spare2=0;	// use this for interpolation
	}

	if (data->targetType)
	{
		fmaObject=&fmaCtrl->object[data->targetNum];	// get pos from tracked object
		pos.vx=fmaObject->actor->position.vx;
		pos.vy=fmaObject->actor->position.vy;
		pos.vz=fmaObject->actor->position.vz;
		camObject->tracking=1;
		camObject->trackNum=data->targetNum;	// force cam target to be the same as circle target
	}
	else
	{
		pos.vx=data->targetPos.vx;
		pos.vy=data->targetPos.vy;
		pos.vz=data->targetPos.vz;
		camObject->tracking=0;
		camObject->trackNum=0;	// if circling a point stop tracking
	}

	dist=data->spare1;
	angle=object->spare1;
	time=object->spare2;

	rot.vx=dist;
	//rot.vy=-4500;	// need to get this info from script
	rot.vy=data->spare2;
	rot.vz=0;
	RotateVector2D(&rot,&rot,angle);

	mycamera.vrx=pos.vx;
	mycamera.vry=pos.vy;
	mycamera.vrz=pos.vz;

	pos.vx+=rot.vx;
	pos.vy+=rot.vy;
	pos.vz+=rot.vz;

	if (time<=10)
	{
		mycamera.vpx=( (object->pos.vx*(10-time))+(pos.vx*time) )/10;
		mycamera.vpy=( (object->pos.vy*(10-time))+(pos.vy*time) )/10;
		mycamera.vpz=( (object->pos.vz*(10-time))+(pos.vz*time) )/10;
	}
	else
	{
		mycamera.vpx=pos.vx;
		mycamera.vpy=pos.vy;
		mycamera.vpz=pos.vz;
	}

	object->spare1+=32;
	if (object->spare2<11) object->spare2++;
}

////////////////////////////////////////////////////////////////////////////////
void	processCamTarget(FMAOBJECT* object,FMADATA* data)
{	// not used
/*
	FMAOBJECT	*fmaObject;
	int		angle,angle1,len;
	VECTOR	rot,pos;
	int	currentTime,timeLen;

//VECTOR		camTarget;
//int			targetChangeStart;
//int			targetChangeLen;


	if (data->startTime==frameTimeCount)
	{
		camTargetStart.vx=mycamera.vrx;
		camTargetStart.vy=mycamera.vry;
		camTargetStart.vz=mycamera.vrz;
		targetChangeLen=data->endTime-data->startTime;
		//camObject->oldPos.vx=mycamera.vrx;
		//camObject->oldPos.vy=mycamera.vry;
		//camObject->oldPos.vz=mycamera.vrz;
		//camObject->timeLen=data->endTime-data->startTime;
		//camObject->tracking=NULL;
	}
*/

}


////////////////////////////////////////////////////////////////////////////////
#define	TARGETOBJECT	1
#define	TARGETVECTOR	2

#define	CAMCLOSE		16
#define	CAMFACING		32



void	processCamCutTo(FMAOBJECT* object,FMADATA* data)
{
	FMAOBJECT	*fmaObject;
	int		angle,angle1,len;
	VECTOR	rot,pos;
	int	currentTime,timeLen;

	//DB("cam cut to\n");
	if ( (data->targetType&15)==TARGETVECTOR)
	{
		if (data->startTime==frameTimeCount)
		{
			camObject->oldPos.vx=mycamera.vrx;
			camObject->oldPos.vy=mycamera.vry;
			camObject->oldPos.vz=mycamera.vrz;
			camObject->timeLen=data->endTime-data->startTime;
			camObject->tracking=NULL;
		}
		currentTime=frameTimeCount-data->startTime;
		mycamera.vrx=( (camObject->oldPos.vx*(camObject->timeLen-currentTime))+(data->targetPos.vx*currentTime) )/camObject->timeLen;
		mycamera.vry=( (camObject->oldPos.vy*(camObject->timeLen-currentTime))+(data->targetPos.vy*currentTime) )/camObject->timeLen;
		mycamera.vrz=( (camObject->oldPos.vz*(camObject->timeLen-currentTime))+(data->targetPos.vz*currentTime) )/camObject->timeLen;
	}
	else if ( (data->targetType&15)==TARGETOBJECT)
	{
		if (data->startTime==frameTimeCount)
		{
			camObject->oldPos.vx=mycamera.vrx;
			camObject->oldPos.vy=mycamera.vry;
			camObject->oldPos.vz=mycamera.vrz;
			camObject->timeLen=data->endTime-data->startTime;
			camObject->tracking=NULL;
		}

		pos.vx=fmaCtrl->object[data->targetNum].actor->position.vx;
		pos.vy=fmaCtrl->object[data->targetNum].actor->position.vy;
		pos.vz=fmaCtrl->object[data->targetNum].actor->position.vz;
		currentTime=frameTimeCount-data->startTime;

		mycamera.vrx=( (camObject->oldPos.vx*(camObject->timeLen-currentTime))+(pos.vx*currentTime) )/camObject->timeLen;
		mycamera.vry=( (camObject->oldPos.vy*(camObject->timeLen-currentTime))+(pos.vy*currentTime) )/camObject->timeLen;
		mycamera.vrz=( (camObject->oldPos.vz*(camObject->timeLen-currentTime))+(pos.vz*currentTime) )/camObject->timeLen;

		if (data->endTime==frameTimeCount)
		{
			camObject->tracking==TARGET;
			camObject->trackNum=data->targetNum;
		}
	}
	if ( (data->targetType&240)==CAMFACING)
	{
		fmaObject=&fmaCtrl->object[data->targetNum];	// get pos from tracked object
		angle=fmaObject->actor->psiData.object->rotate.vy&4095;	// angle of tracked object

		if (data->startTime==frameTimeCount)	// store starting pos on first frame
		{
			object->pos.vx=mycamera.vpx;
			object->pos.vy=mycamera.vpy;
			object->pos.vz=mycamera.vpz;
			object->spare2=0;	// use this for interpolation
		}

		rot.vx=0;
		rot.vy=-2000;
		rot.vz=3000;
		angle=(angle+2048)&4095;

		angle1=calc_angle( (mycamera.vpx-mycamera.vrx),(mycamera.vpz-mycamera.vrz) )&4095;
		//DB("angle %d angle1 %d\n",angle,angle1);

		RotateVector2D(&rot,&rot,angle);

		//if (ABS(angle-angle1)<DEFAULTTURNRATE) RotateVector2D(&rot,&rot,angle1);
		//else RotateVector2D(&rot,&rot,angle);
		//DB("angle=%d\n",angle);

		mycamera.vrx=fmaObject->actor->position.vx;
		mycamera.vry=fmaObject->actor->position.vy;
		mycamera.vrz=fmaObject->actor->position.vz;

		//DB("target pos x %d y %d z %d \n",fmaObject->actor->position.vx,fmaObject->actor->position.vy,fmaObject->actor->position.vz);
		len=frameTimeCount-data->startTime;
			
		rot.vx+=fmaObject->actor->position.vx;
		rot.vy+=fmaObject->actor->position.vy;
		rot.vz+=fmaObject->actor->position.vz;

		if (len<10)
		{
			mycamera.vpx=( (object->pos.vx*(10-len))+(rot.vx*len) )/10;
			mycamera.vpy=( (object->pos.vy*(10-len))+(rot.vy*len) )/10;
			mycamera.vpz=( (object->pos.vz*(10-len))+(rot.vz*len) )/10;
		}
		else
		{
			mycamera.vpx=rot.vx;
			mycamera.vpy=rot.vy;
			mycamera.vpz=rot.vz;
		}
	}
	//DB("camera cutto X %d Y %d Z %d \n",mycamera.vrx/8,-(mycamera.vry/8),mycamera.vrz/8 );
	
}

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

void	processFaceAngle(FMAOBJECT* object,FMADATA* data)
{
	FMAOBJECT	*fmaObject;
	int			angle,angle1,temp;

	//DB("process face angle\n");

	object->flags|=STOPMOVEFACE;
	angle=data->spare1;

	if (frameTimeCount<10)
	{
		object->actor->psiData.object->rotate.vy=angle;
	}
	else
	{
		angle1=object->actor->psiData.object->rotate.vy&4095;
		temp=findShortestAngle(angle,angle1);
		if (temp>DEFAULTTURNRATE) temp=DEFAULTTURNRATE;
		if (temp<-DEFAULTTURNRATE) temp=-DEFAULTTURNRATE;
		object->actor->psiData.object->rotate.vy+=temp;
		//DB("angle %d angle1 %d temp %d\n",angle,angle1,temp);
	}

	if (inCrc==A1_GARDEN_SPECIAL_CASE)
	{
		//int	angle;
		//angle=calc_angle( (object->pos.vz-5600),(object->pos.vx-25680) );
		angle=calc_angle( (object->pos.vz-3432),(object->pos.vx-4160) )+2048;
		object->actor->psiData.object->rotate.vy=(angle&4095);
		//DB("setting ginger to face pole\n");
	}
}

////////////////////////////////////////////////////////////////////////////////
void	processFaceObject(FMAOBJECT* object,FMADATA* data)
{
	FMAOBJECT	*fmaObject;
	int			angle,angle1,temp;
	VECTOR		*pos1,*pos2;

	object->flags|=STOPMOVEFACE;
	fmaObject=&fmaCtrl->object[data->targetNum];

	pos1=&fmaObject->actor->position;
	pos2=&object->actor->position;

	//angle=(calc_angle( (pos->vx-oldPos->vx),(pos->vz-oldPos->vz) )&4095);
	if (frameTimeCount<10)
	{
		angle=(calc_angle( (pos2->vx-pos1->vx),(pos2->vz-pos1->vz) )&4095);
		object->actor->psiData.object->rotate.vy=angle;
	}
	else
	{
		angle=(calc_angle( (pos2->vx-pos1->vx),(pos2->vz-pos1->vz) )&4095);
	 	angle1=object->actor->psiData.object->rotate.vy&4095;
		temp=findShortestAngle(angle,angle1);
		if (temp>DEFAULTTURNRATE) temp=DEFAULTTURNRATE;
		if (temp<-DEFAULTTURNRATE) temp=-DEFAULTTURNRATE;
		object->actor->psiData.object->rotate.vy+=temp;
	}
}

////////////////////////////////////////////////////////////////////////////////
void	proccessObjectAngles()
{
	int		loop,angle,angle1,temp;
	FMAOBJECT	*fmaObject=NULL;
	VECTOR		*pos,*oldPos;
	
	for (loop=0;loop<fmaCtrl->numObjects;loop++)
	{
		if (fmaCtrl->object[loop].crc>1)	// a crc of 0 is the camera 1=general ctrl
		{
			fmaObject=&fmaCtrl->object[loop];
			ASSERT(fmaObject);
			pos=&fmaObject->pos;
			//oldPos=&fmaObject->oldPos;
			oldPos=&fmaObject->actor->position;
			if (!(fmaObject->flags&STOPMOVEFACE) && ( (pos->vx-oldPos->vx) || (pos->vy-oldPos->vy) || (pos->vz-oldPos->vz) ))
			{
				//angle=(calc_angle((oldPos.vx-object->actor->position.vx),(oldPos.vz-object->actor->position.vz)))&4095;
				angle=(calc_angle( (pos->vx-oldPos->vx),(pos->vz-oldPos->vz) )&4095);
				angle1=fmaObject->actor->psiData.object->rotate.vy&4095;
				temp=findShortestAngle(angle,angle1);
				if (temp>DEFAULTTURNRATE) temp=DEFAULTTURNRATE;
				if (temp<-DEFAULTTURNRATE) temp=-DEFAULTTURNRATE;
				fmaObject->actor->psiData.object->rotate.vy+=temp;
			}
		}
	}
}
////////////////////////////////////////////////////////////////////////////////
void	processFadeDown(FMAOBJECT* object,FMADATA* data)
{
	int	amount,len;
	POLY_F4		*siF4;

	DB("fade down\n");

	len=frameTimeCount-data->startTime;
	amount=-(data->startTime-data->endTime);

#ifdef DREAMCAST
	amount=640-((640*len)/amount);

	if (data->endTime==frameTimeCount) fmaStatus.fade=TRUE;

	BEGINPRIM(siF4, POLY_F4);
	siF4->x0=0;//-256;
	siF4->y1=0;//-128;
	siF4->x1=0;//-256;
	siF4->y0=480;//128;
	siF4->x2=-amount;
	siF4->y3=0;//-128;
	siF4->x3=-amount;
	siF4->y2=480;//128;
	siF4->r0=0;	siF4->g0=0;	siF4->b0=0;	
	setPolyF4(siF4);
	ENDPRIM(siF4, 1, POLY_F4);

	BEGINPRIM(siF4, POLY_F4);
	siF4->x0=640;//256;
	siF4->y1=0;//-128;
	siF4->x1=640;//256;
	siF4->y0=480;//128;
	siF4->x2=amount;
	siF4->y3=0;//-128;
	siF4->x3=amount;
	siF4->y2=480;//128;
	siF4->r0=0;	siF4->g0=0;	siF4->b0=0;	
	setPolyF4(siF4);
	ENDPRIM(siF4, 1, POLY_F4);
#else
	amount=256-((256*len)/amount);

	if (data->endTime==frameTimeCount) fmaStatus.fade=TRUE;

	BEGINPRIM(siF4, POLY_F4);
	siF4->x0=-256;
	siF4->y0=-128;
	siF4->x1=-256;
	siF4->y1=128;
	siF4->x2=-amount;
	siF4->y2=-128;
	siF4->x3=-amount;
	siF4->y3=128;
	siF4->r0=0;	siF4->g0=0;	siF4->b0=0;	
	setPolyF4(siF4);
	ENDPRIM(siF4, 1, POLY_F4);

	BEGINPRIM(siF4, POLY_F4);
	siF4->x0=256;
	siF4->y0=-128;
	siF4->x1=256;
	siF4->y1=128;
	siF4->x2=amount;
	siF4->y2=-128;
	siF4->x3=amount;
	siF4->y3=128;
	siF4->r0=0;	siF4->g0=0;	siF4->b0=0;	
	setPolyF4(siF4);
	ENDPRIM(siF4, 1, POLY_F4);
#endif
/*
return;
	BEGINPRIM(siF4, POLY_F4);
	siF4->x0=-256;
	siF4->y0=0;
	siF4->x2=256;
	siF4->y2=0;
	siF4->x3=256;
	siF4->y3=10;
	siF4->x1=-256;
	siF4->y1=10;
	siF4->r0=0;	
	siF4->g0=0;	
	siF4->b0=0;	
	setPolyF4(siF4);
	//siF4->code |= 2;
	//ENDPRIM(siF4, depth, POLY_F4);
	ENDPRIM(siF4, 0, POLY_F4);
*/
}

////////////////////////////////////////////////////////////////////////////////
void	processFadeUp(FMAOBJECT* object,FMADATA* data)
{
	int	amount,len;
	POLY_F4			*siF4;

	len=frameTimeCount-data->endTime;
	amount=(data->startTime-data->endTime);

	DB("fade up\n");

#ifdef DREAMCAST
	amount=640-((640*len)/amount);

	fmaStatus.fade=FALSE;

	BEGINPRIM(siF4, POLY_F4);
	siF4->x0=0;//-256;
	siF4->y1=0;//-128;
	siF4->x1=0;//-256;
	siF4->y0=480;//128;
	siF4->x2=-amount;
	siF4->y3=0;//-128;
	siF4->x3=-amount;
	siF4->y2=480;//128;
	siF4->r0=0;	siF4->g0=0;	siF4->b0=0;	
	setPolyF4(siF4);
	ENDPRIM(siF4, 1, POLY_F4);

	BEGINPRIM(siF4, POLY_F4);
	siF4->x0=640;//256;
	siF4->y1=0;//-128;
	siF4->x1=640;//256;
	siF4->y0=480;//128;
	siF4->x2=amount;
	siF4->y3=0;//-128;
	siF4->x3=amount;
	siF4->y2=480;//128;
	siF4->r0=0;	siF4->g0=0;	siF4->b0=0;	
	setPolyF4(siF4);
	ENDPRIM(siF4, 1, POLY_F4);
#else
	amount=256-((256*len)/amount);

	fmaStatus.fade=FALSE;

	BEGINPRIM(siF4, POLY_F4);
	siF4->x0=-256;
	siF4->y0=-128;
	siF4->x1=-256;
	siF4->y1=128;
	siF4->x2=-amount;
	siF4->y2=-128;
	siF4->x3=-amount;
	siF4->y3=128;
	siF4->r0=0;	siF4->g0=0;	siF4->b0=0;	
	setPolyF4(siF4);
	ENDPRIM(siF4, 1, POLY_F4);

	BEGINPRIM(siF4, POLY_F4);
	siF4->x0=256;
	siF4->y0=-128;
	siF4->x1=256;
	siF4->y1=128;
	siF4->x2=amount;
	siF4->y2=-128;
	siF4->x3=amount;
	siF4->y3=128;
	siF4->r0=0;	siF4->g0=0;	siF4->b0=0;	
	setPolyF4(siF4);
	ENDPRIM(siF4, 1, POLY_F4);
#endif	

}




////////////////////////////////////////////////////////////////////////////////
void	drawOverlayPloys(void)
{
	int topY,bottomY;
	POLY_F4			*siF4;
	int	flag=TRUE;

#ifdef DREAMCAST
#define DC_X 320
#define DC_Y 240
	if (frameTimeCount<FRAMEBLANKLIMIT)
	{
		topY=(frameTimeCount*7.7)-HALFSCREENHEIGHT;
		bottomY=HALFSCREENHEIGHT-(frameTimeCount*7.7);
	}
	else
	{
		topY=-140;
		bottomY=140;
	}
#else

#if PALMODE==1
	if (frameTimeCount<FRAMEBLANKLIMIT)
	//if (leadInCount)
	{
		//topY=(frameTimeCount*2)-HALFSCREENHEIGHT;
		//bottomY=HALFSCREENHEIGHT-(frameTimeCount*2);
		topY=(frameTimeCount*4)-HALFSCREENHEIGHT;
		bottomY=HALFSCREENHEIGHT-(frameTimeCount*4);
	}
	else
	{
		topY=-76;
		bottomY=76;
	}
#else
	if (frameTimeCount<FRAMEBLANKLIMIT)
//	if (leadInCount)
	{
		//topY=(frameTimeCount * 3/2) - HALFSCREENHEIGHT;
		//bottomY=HALFSCREENHEIGHT-(frameTimeCount*5/2);
		topY=(frameTimeCount * 3) - HALFSCREENHEIGHT;
		bottomY=HALFSCREENHEIGHT-(frameTimeCount*6);
	}
	else
	{
		topY=(26 * 3/2)-HALFSCREENHEIGHT;
		//bottomY=HALFSCREENHEIGHT - (26 * 5/2);
		bottomY=HALFSCREENHEIGHT - (32 * 5/2);
	}
#endif

#endif

#ifdef DREAMCAST
	if (flag)
	{
		BEGINPRIM(siF4, POLY_F4);
		siF4->x0=DC_X-HALFSCREENWIDTH;
		siF4->y1=DC_Y-HALFSCREENHEIGHT;
		siF4->x2=DC_X+HALFSCREENWIDTH;
		siF4->y3=DC_Y+-HALFSCREENHEIGHT;
		siF4->x3=DC_X+HALFSCREENWIDTH;
		siF4->y2=DC_Y+topY-15;
		siF4->x1=DC_X-HALFSCREENWIDTH;
		siF4->y0=DC_Y+topY-15;
		siF4->r0=0;	siF4->g0=0;	siF4->b0=0;	
		setPolyF4(siF4);
		ENDPRIM(siF4, 1, POLY_F4);
	}

	BEGINPRIM(siF4, POLY_F4);
	siF4->x0=DC_X-HALFSCREENWIDTH;
	siF4->y0=DC_Y+HALFSCREENHEIGHT;
	siF4->x2=DC_X+HALFSCREENWIDTH;
	siF4->y2=DC_Y+HALFSCREENHEIGHT;
	siF4->x3=DC_X+HALFSCREENWIDTH;
	siF4->y3=DC_Y+bottomY;
	siF4->x1=DC_X-HALFSCREENWIDTH;
	siF4->y1=DC_Y+bottomY;
	siF4->r0=0;	siF4->g0=0;	siF4->b0=0;	
	setPolyF4(siF4);
	ENDPRIM(siF4, 1, POLY_F4);
#else
	if (flag)
	{
		BEGINPRIM(siF4, POLY_F4);
		siF4->x0=-HALFSCREENWIDTH;
		siF4->y0=-HALFSCREENHEIGHT;
		siF4->x2=HALFSCREENWIDTH;
		siF4->y2=-HALFSCREENHEIGHT;
		siF4->x3=HALFSCREENWIDTH;
		siF4->y3=topY-15;
		siF4->x1=-HALFSCREENWIDTH;
		siF4->y1=topY-15;
		siF4->r0=0;	siF4->g0=0;	siF4->b0=0;	
		setPolyF4(siF4);
		ENDPRIM(siF4, 1, POLY_F4);
	}

	BEGINPRIM(siF4, POLY_F4);
	siF4->x0=-HALFSCREENWIDTH;
	siF4->y0=HALFSCREENHEIGHT;
	siF4->x2=HALFSCREENWIDTH;
	siF4->y2=HALFSCREENHEIGHT;
	siF4->x3=HALFSCREENWIDTH;
	siF4->y3=bottomY;
	siF4->x1=-HALFSCREENWIDTH;
	siF4->y1=bottomY;
	siF4->r0=0;	siF4->g0=0;	siF4->b0=0;	
	setPolyF4(siF4);
	ENDPRIM(siF4, 1, POLY_F4);
#endif
}
////////////////////////////////////////////////////////////////////////////////

void	holdFade(void)
{
	POLY_F4			*siF4;

	BEGINPRIM(siF4, POLY_F4);
	siF4->x0=-HALFSCREENWIDTH;
	siF4->y0=-HALFSCREENHEIGHT;
	siF4->x2=HALFSCREENWIDTH;
	siF4->y2=-HALFSCREENHEIGHT;
	siF4->x3=HALFSCREENWIDTH;
	siF4->y3=HALFSCREENHEIGHT;
	siF4->x1=-HALFSCREENWIDTH;
	siF4->y1=HALFSCREENHEIGHT;
	siF4->r0=0;	siF4->g0=0;	siF4->b0=0;	
	setPolyF4(siF4);
	ENDPRIM(siF4, 0, POLY_F4);


}

////////////////////////////////////////////////////////////////////////////////
void	jumpToFrame(void)
{
	int		loop,requiredFrame,loop1;
	FMAOBJECT	*fmaObject;
	FMADATA		*fmaData;
	VECTOR		*pos,*oldPos;
	int			count;
	FMADATA		*lastData[20] [10];
	int			commands[20];
	

	// first need to find the final possitions of all the models

	if (fmaStatus.XAplaying!=TEXTWITHOUTXA)
	{
		sound_XA_Stop();	// if useing xa's stop them
		fmaStatus.XAplaying=NULL;
	}

	for (loop=0;loop<20;loop++)
	{
		for (loop1=0;loop1<10;loop1++)
		{
			lastData[loop] [loop1]=NULL;
		}
		commands[loop]=0;
	}
	requiredFrame=fmaStatus.timeToJumpTo;

	for (loop=0;loop<fmaCtrl->numObjects;loop++)
	{
		fmaObject=&fmaCtrl->object[loop];
		fmaData=&fmaCtrl->object[loop].data[0];
		count=0;
		for (loop1=0;loop1<fmaObject->numCommands;loop1++)
		{
			if ( (fmaData->endTime>=frameTimeCount) && (fmaData->endTime<=requiredFrame) )
			{
				//if (fmaData->endTime>lastFrame[loop])
				//lastFrame[loop] [count]=fmaData->endTime;
				count=commands[loop];
				lastData[loop] [count]=fmaData;
				count++;
				commands[loop]=count;
			}
			fmaData++;
		}
	}


	for (loop=0;loop<fmaCtrl->numObjects;loop++)
	{
		fmaObject=&fmaCtrl->object[loop];
		//if (fmaObject->crc>1 && lastData[loop])
		if (fmaObject->crc>1 && commands[loop])
		{
			for (loop1=0;loop1<commands[loop];loop1++)
			{
				if ( (lastData[loop] [loop1]->endTime>=frameTimeCount) && (lastData[loop] [loop1]->endTime<=requiredFrame) )
				{
					switch(lastData[loop] [loop1]->action)
					{
						case CMD_MOVE_TO:
							fmaObject->actor->position.vx=fmaObject->oldPos.vx=fmaObject->pos.vx=lastData[loop] [loop1]->targetPos.vx;
							fmaObject->actor->position.vy=fmaObject->oldPos.vy=fmaObject->pos.vy=lastData[loop] [loop1]->targetPos.vy;
							fmaObject->actor->position.vz=fmaObject->oldPos.vz=fmaObject->pos.vz=lastData[loop] [loop1]->targetPos.vz;
							break;
					}
				}
			}
		}
		//else if (fmaObject->crc==0  && lastData[loop]) // camera
		else if (fmaObject->crc==0  && commands[loop]) // camera
		{
			for (loop1=0;loop1<commands[loop];loop1++)
			{
				if ( (lastData[loop] [loop1]->endTime>=frameTimeCount) && (lastData[loop] [loop1]->endTime<=requiredFrame) )
				{
					switch(lastData[loop] [loop1]->action)
					{
						case CMD_MOVE_TO:
							mycamera.vpx=lastData[loop] [loop1]->targetPos.vx;
							mycamera.vpy=lastData[loop] [loop1]->targetPos.vy;
							mycamera.vpz=lastData[loop] [loop1]->targetPos.vz;
							break;
						// tbd add cam cutto and others if required
					}
				}
			}
		}
	}
	frameTimeCount=fmaStatus.timeToJumpTo;
	fmaStatus.breakFlag=FALSE;
	// Note fade status is not changed at the moment

}

//////////////////////////////////////////////////////////////////////////////////////////
void	processConversation(FMAOBJECT* object,FMADATA* data)
{
	int	sceneNum,stringNum,numLines,blockToUse,loop,trackNum;
	int	stringLen,count,endTime;
	char*	string;
	char*	buff[255];

	//DB("scene num %d\n",data->spare1);

	// TDB change this so its only does this once per scene !!
	// trust me if I knew it would be thisa massive at start i'd hae done somthing else!
	switch (data->spare1)
	{
		case 1001:
			sceneNum=TEXTSTR_FMA_SCENE1001;
			break;
		case 1002:
			sceneNum=TEXTSTR_FMA_SCENE1002;
			break;
		case 1003:
			sceneNum=TEXTSTR_FMA_SCENE1003;
			break;
		case 1004:
			sceneNum=TEXTSTR_FMA_SCENE1004;
			break;
		case 1005:
			sceneNum=TEXTSTR_FMA_SCENE1005;
			break;
		case 1006:
			sceneNum=TEXTSTR_FMA_SCENE1006;
			break;
		case 1007:
			sceneNum=TEXTSTR_FMA_SCENE1007;
			break;

//		case 1008:
//			sceneNum=TEXTSTR_FMA_SCENE1008;
//			break;


		case 1010:
			sceneNum=TEXTSTR_FMA_SCENE1010;
			break;
		case 1011:
			sceneNum=TEXTSTR_FMA_SCENE1011;
			break;
		case 1012:
			sceneNum=TEXTSTR_FMA_SCENE1012;
			break;
		case 1013:
			sceneNum=TEXTSTR_FMA_SCENE1013;
			break;
		case 1014:
			sceneNum=TEXTSTR_FMA_SCENE1014;
			break;
		case 1015:
			sceneNum=TEXTSTR_FMA_SCENE1015;
			break;


		case 2001:
			sceneNum=TEXTSTR_FMA_SCENE2001;
			break;
//		case 2002:
//			sceneNum=TEXTSTR_FMA_SCENE2002;
//			break;
		case 2003:
			sceneNum=TEXTSTR_FMA_SCENE2003;
			break;
		case 2004:
			sceneNum=TEXTSTR_FMA_SCENE2004;
			break;
		case 2005:
			sceneNum=TEXTSTR_FMA_SCENE2005;
			break;
		case 2009:
			sceneNum=TEXTSTR_FMA_SCENE2009;
			break;

//		case 2007:
//			sceneNum=TEXTSTR_FMA_SCENE2007;
//			break;
//		case 2008:
//			sceneNum=TEXTSTR_FMA_SCENE2008;
//			break;
//		case 2009:
//			sceneNum=TEXTSTR_FMA_SCENE2009;
//			break;

		case 2019:
			sceneNum=TEXTSTR_FMA_SCENE2019;
			break;
		case 2020:
			sceneNum=TEXTSTR_FMA_SCENE2020;
			break;
		case 2021:
			sceneNum=TEXTSTR_FMA_SCENE2021;
			break;
		case 2022:
			sceneNum=TEXTSTR_FMA_SCENE2022;
			break;
		case 2023:
			sceneNum=TEXTSTR_FMA_SCENE2023;
			break;
		case 2024:
			sceneNum=TEXTSTR_FMA_SCENE2024;
			break;
/*		case 2030:
			sceneNum=TEXTSTR_FMA_SCENE2030;
			break;
		case 2031:
			sceneNum=TEXTSTR_FMA_SCENE2031;
			break;
		case 2032:
			sceneNum=TEXTSTR_FMA_SCENE2032;
			break;
		case 2033:
			sceneNum=TEXTSTR_FMA_SCENE2033;
			break;
		case 2034:
			sceneNum=TEXTSTR_FMA_SCENE2034;
			break;
		case 2035:
			sceneNum=TEXTSTR_FMA_SCENE2035;
			break;
*/

		case 2040:
			sceneNum=TEXTSTR_FMA_SCENE2040;
			break;
		case 2041:
			sceneNum=TEXTSTR_FMA_SCENE2041;
			break;
		case 2042:
			sceneNum=TEXTSTR_FMA_SCENE2042;
			break;
		case 2043:
			sceneNum=TEXTSTR_FMA_SCENE2043;
			break;
		case 2044:
			sceneNum=TEXTSTR_FMA_SCENE2044;
			break;
		case 2045:
			sceneNum=TEXTSTR_FMA_SCENE2045;
			break;
/*		case 2046:
			sceneNum=TEXTSTR_FMA_SCENE2046;
			break;
		case 2047:
			sceneNum=TEXTSTR_FMA_SCENE2047;
			break;
		case 2048:
			sceneNum=TEXTSTR_FMA_SCENE2048;
			break;
		case 2049:
			sceneNum=TEXTSTR_FMA_SCENE2049;
			break;
		case 2050:
			sceneNum=TEXTSTR_FMA_SCENE2050;
			break;
		case 2051:
			sceneNum=TEXTSTR_FMA_SCENE2051;
			break;
*/
		case 2070:
			sceneNum=TEXTSTR_FMA_SCENE2070;
			break;
		case 2071:
			sceneNum=TEXTSTR_FMA_SCENE2071;
			break;
		case 2074:
			sceneNum=TEXTSTR_FMA_SCENE2074;
			break;
		case 2075:
			sceneNum=TEXTSTR_FMA_SCENE2075;
			break;
/*		case 2076:
			sceneNum=TEXTSTR_FMA_SCENE2076;
			break;
		case 2077:
			sceneNum=TEXTSTR_FMA_SCENE2077;
			break;
		case 2078:
			sceneNum=TEXTSTR_FMA_SCENE2078;
			break;
		case 2079:
			sceneNum=TEXTSTR_FMA_SCENE2079;
			break;
*/
		case 4001:
			sceneNum=TEXTSTR_FMA_SCENE4001;
			break;
//		case 4002:
//			sceneNum=TEXTSTR_FMA_SCENE4002;
//			break;
		case 4003:
			sceneNum=TEXTSTR_FMA_SCENE4003;
			break;
		case 4004:
			sceneNum=TEXTSTR_FMA_SCENE4004;
			break;
		case 4005:
			sceneNum=TEXTSTR_FMA_SCENE4005;
			break;
//		case 4006:
//			sceneNum=TEXTSTR_FMA_SCENE4006;
//			break;
//		case 4007:
//			sceneNum=TEXTSTR_FMA_SCENE4007;
//			break;
//		case 4008:
//			sceneNum=TEXTSTR_FMA_SCENE4008;
//			break;
		case 4009:
			sceneNum=TEXTSTR_FMA_SCENE4009;
			break;

		case 4019:
			sceneNum=TEXTSTR_FMA_SCENE4019;
			break;
		case 4020:
			sceneNum=TEXTSTR_FMA_SCENE4020;
			break;
//		case 4021:
//			sceneNum=TEXTSTR_FMA_SCENE4021;
//			break;
//		case 4022:
//			sceneNum=TEXTSTR_FMA_SCENE4022;
//			break;
		case 4040:
			sceneNum=TEXTSTR_FMA_SCENE4040;
			break;
		case 4041:
			sceneNum=TEXTSTR_FMA_SCENE4041;
			break;

		case 4042:
			sceneNum=TEXTSTR_FMA_SCENE4042;
			break;
		case 4043:
			sceneNum=TEXTSTR_FMA_SCENE4043;
			break;
		case 4044:
			sceneNum=TEXTSTR_FMA_SCENE4044;
			break;
		case 4045:
			sceneNum=TEXTSTR_FMA_SCENE4045;
			break;
		case 4046:
			sceneNum=TEXTSTR_FMA_SCENE4046;
			break;
/*		case 4047:
			sceneNum=TEXTSTR_FMA_SCENE4047;
			break;
		case 4048:
			sceneNum=TEXTSTR_FMA_SCENE4048;
			break;
		case 4049:
			sceneNum=TEXTSTR_FMA_SCENE4049;
			break;
		case 4050:
			sceneNum=TEXTSTR_FMA_SCENE4050;
			break;
		case 4051:
			sceneNum=TEXTSTR_FMA_SCENE4051;
			break;
		case 4052:
			sceneNum=TEXTSTR_FMA_SCENE4052;
			break;
		case 4053:
			sceneNum=TEXTSTR_FMA_SCENE4053;
			break;
*/
		case 4060:
			sceneNum=TEXTSTR_FMA_SCENE4060;
			break;
		case 4061:
			sceneNum=TEXTSTR_FMA_SCENE4061;
			break;
		case 4062:
			sceneNum=TEXTSTR_FMA_SCENE4062;
			break;
		case 4063:
			sceneNum=TEXTSTR_FMA_SCENE4063;
			break;
		case 4064:
			sceneNum=TEXTSTR_FMA_SCENE4064;
			break;
		case 4065:
			sceneNum=TEXTSTR_FMA_SCENE4065;
			break;
/*		case 4066:
			sceneNum=TEXTSTR_FMA_SCENE4066;
			break;
		case 4067:
			sceneNum=TEXTSTR_FMA_SCENE4067;
			break;
		case 4068:
			sceneNum=TEXTSTR_FMA_SCENE4068;
			break;
		case 4069:
			sceneNum=TEXTSTR_FMA_SCENE4069;
			break;
		case 4070:
			sceneNum=TEXTSTR_FMA_SCENE4070;
			break;
		case 4071:
			sceneNum=TEXTSTR_FMA_SCENE4071;
			break;
*/
		case 4080:
			sceneNum=TEXTSTR_FMA_SCENE4080;
			break;
		case 4081:
			sceneNum=TEXTSTR_FMA_SCENE4081;
			break;
		case 4082:
			sceneNum=TEXTSTR_FMA_SCENE4082;
			break;
		case 4083:
			sceneNum=TEXTSTR_FMA_SCENE4083;
			break;
		case 4084:
			sceneNum=TEXTSTR_FMA_SCENE4084;
			break;
		case 4085:
			sceneNum=TEXTSTR_FMA_SCENE4085;
			break;
		case 4086:
			sceneNum=TEXTSTR_FMA_SCENE4086;
			break;
/*		case 4087:
			sceneNum=TEXTSTR_FMA_SCENE4087;
			break;
		case 4088:
			sceneNum=TEXTSTR_FMA_SCENE4088;
			break;
		case 4089:
			sceneNum=TEXTSTR_FMA_SCENE4089;
			break;
		case 4090:
			sceneNum=TEXTSTR_FMA_SCENE4090;
			break;
		case 4091:
			sceneNum=TEXTSTR_FMA_SCENE4091;
			break;
		case 4092:
			sceneNum=TEXTSTR_FMA_SCENE4092;
			break;
*/
		case 4200:
			sceneNum=TEXTSTR_FMA_SCENE4200;
			break;
		case 4201:
			sceneNum=TEXTSTR_FMA_SCENE4201;
			break;
		case 4202:
			sceneNum=TEXTSTR_FMA_SCENE4202;
			break;
		case 4203:
			sceneNum=TEXTSTR_FMA_SCENE4203;
			break;
		case 4210:
			sceneNum=TEXTSTR_FMA_SCENE4210;
			break;
		case 4211:
			sceneNum=TEXTSTR_FMA_SCENE4211;
			break;
		case 4212:
			sceneNum=TEXTSTR_FMA_SCENE4212;
			break;
		case 4213:
			sceneNum=TEXTSTR_FMA_SCENE4213;
			break;
		case 4214:
			sceneNum=TEXTSTR_FMA_SCENE4214;
			break;
		case 4215:
			sceneNum=TEXTSTR_FMA_SCENE4215;
			break;
		case 4216:
			sceneNum=TEXTSTR_FMA_SCENE4216;
			break;
		case 4217:
			sceneNum=TEXTSTR_FMA_SCENE4217;
			break;
		case 4218:
			sceneNum=TEXTSTR_FMA_SCENE4218;
			break;
		case 4219:
			sceneNum=TEXTSTR_FMA_SCENE4219;
			break;
		case 4220:
			sceneNum=TEXTSTR_FMA_SCENE4220;
			break;

/*		case 4250:
			sceneNum=TEXTSTR_FMA_SCENE4250;
			break;
		case 4251:
			sceneNum=TEXTSTR_FMA_SCENE4251;
			break;
		case 4252:
			sceneNum=TEXTSTR_FMA_SCENE4252;
			break;
		case 4253:
			sceneNum=TEXTSTR_FMA_SCENE4253;
			break;

		case 4260:
			sceneNum=TEXTSTR_FMA_SCENE4260;
			break;
		case 4261:
			sceneNum=TEXTSTR_FMA_SCENE4261;
			break;
		case 4262:
			sceneNum=TEXTSTR_FMA_SCENE4262;
			break;
		case 4263:
			sceneNum=TEXTSTR_FMA_SCENE4263;
			break;
		case 4264:
			sceneNum=TEXTSTR_FMA_SCENE4264;
			break;
		case 4265:
			sceneNum=TEXTSTR_FMA_SCENE4265;
			break;
		case 4266:
			sceneNum=TEXTSTR_FMA_SCENE4266;
			break;
		case 4267:
			sceneNum=TEXTSTR_FMA_SCENE4267;
			break;
		case 4268:
			sceneNum=TEXTSTR_FMA_SCENE4268;
			break;
		case 4269:
			sceneNum=TEXTSTR_FMA_SCENE4269;
			break;
		case 4270:
			sceneNum=TEXTSTR_FMA_SCENE4270;
			break;
*/
		case 4400:
			sceneNum=TEXTSTR_FMA_SCENE4400;
			break;
		case 4401:
			sceneNum=TEXTSTR_FMA_SCENE4401;
			break;
		case 4402:
			sceneNum=TEXTSTR_FMA_SCENE4402;
			break;
		case 4403:
			sceneNum=TEXTSTR_FMA_SCENE4403;
			break;
		case 4410:
			sceneNum=TEXTSTR_FMA_SCENE4410;
			break;
		case 4411:
			sceneNum=TEXTSTR_FMA_SCENE4411;
			break;
		case 4412:
			sceneNum=TEXTSTR_FMA_SCENE4412;
			break;
		case 4413:
			sceneNum=TEXTSTR_FMA_SCENE4413;
			break;
		case 4414:
			sceneNum=TEXTSTR_FMA_SCENE4414;
			break;
		case 4415:
			sceneNum=TEXTSTR_FMA_SCENE4415;
			break;
		case 4416:
			sceneNum=TEXTSTR_FMA_SCENE4416;
			break;
		case 4417:
			sceneNum=TEXTSTR_FMA_SCENE4417;
			break;
		case 4418:
			sceneNum=TEXTSTR_FMA_SCENE4418;
			break;
		case 4419:
			sceneNum=TEXTSTR_FMA_SCENE4419;
			break;
		case 4420:
			sceneNum=TEXTSTR_FMA_SCENE4420;
			break;

/*		case 4450:
			sceneNum=TEXTSTR_FMA_SCENE4450;
			break;
		case 4451:
			sceneNum=TEXTSTR_FMA_SCENE4451;
			break;
		case 4452:
			sceneNum=TEXTSTR_FMA_SCENE4452;
			break;
		case 4453:
			sceneNum=TEXTSTR_FMA_SCENE4453;
			break;


		case 4460:
			sceneNum=TEXTSTR_FMA_SCENE4460;
			break;
		case 4461:
			sceneNum=TEXTSTR_FMA_SCENE4461;
			break;
		case 4462:
			sceneNum=TEXTSTR_FMA_SCENE4462;
			break;
		case 4463:
			sceneNum=TEXTSTR_FMA_SCENE4463;
			break;
		case 4464:
			sceneNum=TEXTSTR_FMA_SCENE4464;
			break;
		case 4465:
			sceneNum=TEXTSTR_FMA_SCENE4465;
			break;
		case 4466:
			sceneNum=TEXTSTR_FMA_SCENE4466;
			break;
		case 4467:
			sceneNum=TEXTSTR_FMA_SCENE4467;
			break;
		case 4468:
			sceneNum=TEXTSTR_FMA_SCENE4468;
			break;
		case 4469:
			sceneNum=TEXTSTR_FMA_SCENE4469;
			break;
		case 4470:
			sceneNum=TEXTSTR_FMA_SCENE4470;
			break;
*/

		case 4300:
			sceneNum=TEXTSTR_FMA_SCENE4300;
			break;
		case 4301:
			sceneNum=TEXTSTR_FMA_SCENE4301;
			break;
		case 4302:
			sceneNum=TEXTSTR_FMA_SCENE4302;
			break;
		case 4303:
			sceneNum=TEXTSTR_FMA_SCENE4303;
			break;

		case 4310:
			sceneNum=TEXTSTR_FMA_SCENE4310;
			break;
		case 4311:
			sceneNum=TEXTSTR_FMA_SCENE4311;
			break;
		case 4312:
			sceneNum=TEXTSTR_FMA_SCENE4312;
			break;
		case 4313:
			sceneNum=TEXTSTR_FMA_SCENE4313;
			break;
		case 4314:
			sceneNum=TEXTSTR_FMA_SCENE4314;
			break;
		case 4315:
			sceneNum=TEXTSTR_FMA_SCENE4315;
			break;
		case 4316:
			sceneNum=TEXTSTR_FMA_SCENE4316;
			break;
		case 4317:
			sceneNum=TEXTSTR_FMA_SCENE4317;
			break;
		case 4318:
			sceneNum=TEXTSTR_FMA_SCENE4318;
			break;
		case 4319:
			sceneNum=TEXTSTR_FMA_SCENE4319;
			break;
		case 4320:
			sceneNum=TEXTSTR_FMA_SCENE4320;
			break;

		case 8001:
			sceneNum=TEXTSTR_FMA_SCENE8001;
			break;
		case 8002:
			sceneNum=TEXTSTR_FMA_SCENE8002;
			break;
		case 8003:
			sceneNum=TEXTSTR_FMA_SCENE8003;
			break;
		case 8004:
			sceneNum=TEXTSTR_FMA_SCENE8004;
			break;
		case 8005:
			sceneNum=TEXTSTR_FMA_SCENE8005;
			break;

		case 8011:
			sceneNum=TEXTSTR_FMA_SCENE8011;
			break;
		case 8012:
			sceneNum=TEXTSTR_FMA_SCENE8012;
			break;
		case 8013:
			sceneNum=TEXTSTR_FMA_SCENE8013;
			break;
		case 8014:
			sceneNum=TEXTSTR_FMA_SCENE8014;
			break;
		case 8015:
			sceneNum=TEXTSTR_FMA_SCENE8015;
			break;

		default:
			sceneNum=TEXTSTR_FMA_CONVERSATIONS;
			break;
	}
	stringNum=data->spare2;

//	sceneNum=TEXTSTR_FMA_SCENE1001;

//	textColours[numTextStrings]=data->targetNum;	// tbd change this for chicken portrate

	//DB("text colour %d\n",object->pos.pad);
//	sceneNum=TEXTSTR_FMA_SCENE1001;

	textColours[numTextStrings]=object->pos.pad;
	textNumbers[numTextStrings++]=(sceneNum+stringNum);

	//DB("scene num %d string num %d frame time %d\n",data->spare1,data->spare2,frameTimeCount);

	if (fmaStatus.XAplaying==TEXTWITHXAPLAYING)
	{
		if (XAcheckPlay() )
		{
			if (data->endTime<=frameTimeCount)
				//data->endTime++; // if xa playing then keep text on screen
				frameTimeCount--;
		}
		else
		{
			fmaStatus.XAplaying=TEXTWITHOUTXA;
			//data->endTime=frameTimeCount;	// if xa finished stop convsation
			frameTimeCount=data->endTime;	// this is risky
		}
	}

	if ( (frameTimeCount==data->startTime) && (fmaStatus.XAplaying!=TEXTWITHXAWAITING) )
//	if ( (frameTimeCount==data->startTime))	// fmaStatus.XAplaying check removed
	{
		//if(!XAcheckPlay() || !XAgetStatus())
		if( !XAgetStatus() )
		{
			DB ("no CD found\n");
			DB ("Track = %d channel = %d\n",(data->animChange-1),(data->animSegment-1));
			fmaStatus.XAplaying=TEXTWITHOUTXA;	// no cd cannot play 
			return;
		}
		if (data->animChange!=-1 && (frameTimeCount==data->startTime)) // I'm using animchange and animsegment to hold track and channel
		{
			DB("XA track = %d XA channel = %d\n",data->animChange-1,data->animSegment-1);

			trackNum=( (data->animChange-1) *32)+(data->animSegment-1);
			fmaStatus.XAplaying=TEXTWITHXAWAITING;
			//sound_XA_StartFma(trackNum|SOUND_XA_NOLOOP);
			sound_XA_StartFma(trackNum);
		}
		else
		{
			fmaStatus.XAplaying=TEXTWITHOUTXA;		
			DB("no XA given for this convesation\n");
		}
	}
}

//////////////////////////////////////////////////////////////////////////////////////////
typedef struct
{
	char*		string;
	int			startTime;
	int			endTime;
	int			yPos;
	int			timeTillMove;
	int			timeTillMove1;
}DISPLAYABLETEXT;

DISPLAYABLETEXT	screenText[5];

void	textDisplay(void)
{
	int	loop,loop1,slot,slot1,time,ypos;
	char	buff[255];

	slot=0;
	slot1=0;

	for (loop=0;loop<3;loop++)
	{
		if (textCtrl.block[loop])
		{
			//DB("here\n");
			textCtrl.block[loop]=NULL;
			slot=99;
			for (loop1=0;loop1<5;loop1++)
			{
				if (!screenText[loop1].startTime)	// as no conversation will start on frame 0 use for test
				{
					slot1=slot=loop1;
					break;
				}
			}
			if (slot!=99)
			{
				loop1=0;
				ypos=128;
				time=frameTimeCount;
				while (textCtrl.line[loop][loop1])
				{
					screenText[slot].string=textCtrl.line[loop][loop1];
					screenText[slot].yPos=ypos;
					screenText[slot].startTime=time;
					//screenText[slot].endTime=time+textCtrl.endLineTime[loop][loop1];
					screenText[slot].endTime=textCtrl.endLineTime[loop][loop1];
					screenText[slot].timeTillMove=screenText[slot].timeTillMove1=textCtrl.lineLen[loop][loop1];
					//screenText[slot].timeTillMove=1;
					loop1++;
					slot++;
					ypos+=12;
				}
				screenText[slot1].timeTillMove=1;
			}
		}
	}
	ypos=999;
	for (loop=0;loop<5;loop++)
	{
		if ( screenText[loop].yPos )
		{
			//fontPrint(font, -200,screenText[loop].yPos, screenText[loop].string, 128,128,128);
			fontFitToWidth(font, 512, screenText[loop].string, buff);
			fontPrintCentred(font,0,screenText[loop].yPos, buff, 128,128,128);

			//fontPrintCentred(font,0,screenText[loop].yPos, screenText[loop].string, 128,128,128);
			if (screenText[loop].yPos<ypos)
			{
				ypos=screenText[loop].yPos;
				slot=loop;
			}
			//if (screenText[slot].endTime<=frameTimeCount && screenText[slot].endTime>0)
			screenText[slot].timeTillMove--;
			if (screenText[slot].timeTillMove==0)
			{
				if (screenText[slot].yPos<92)
				{
					screenText[slot].yPos=0;
					screenText[slot].string=NULL;
					screenText[slot].startTime=0;
				}
				else
					screenText[slot].timeTillMove=screenText[slot].timeTillMove1;

				for (loop=0;loop<5;loop++)
				{
					if (screenText[loop].yPos)
					{
						screenText[loop].yPos-=12;
					}
				}
			}
		}
	}
}




//////////////////////////////////////////////////////////////////////////////////////////
void	processSound(FMAOBJECT* object,FMADATA* data)
{
	int	sampleNum;
	FMAOBJECT	*fmaObject;
	SfxSampleType *sample;


	if (frameTimeCount!=data->startTime) return;
	sampleNum=data->spare1;	// changed to hold crc value

	DB("sample crc %d\n",sampleNum);

	sample = sfxFindSampleInAllBanksCRC(sampleNum);

	if(sample)
	{
		if (levinfo->level_number==LEVNUMBER_A1_HUT17 || levinfo->level_number==LEVNUMBER_A2_HUT17 || levinfo->level_number==LEVNUMBER_A4_HUT17)
			soundPlaySample(sample, 0x6464, 0);	// lower the volume of gingers footsteps in hut17 all acts
		else
			soundPlaySample(sample, 0xaaaa, 0);
	}
	else DB("sample not found\n");
}

//////////////////////////////////////////////////////////////////////////////////////////
void	processMusic(FMAOBJECT* object,FMADATA* data)
{
	int	trackNum;
	FMAOBJECT	*fmaObject;

	trackNum=data->spare1;

	DB("starting music track %d\n",trackNum);

	data->endTime=data->startTime-1; // make sure this is only called the once
#if GOLDCD==0
	DB("music started but as this is not on cd no music will play\n");
#else
	sound_XA_Start(trackNum);
	//sound_XA_PauseForLoading();
#endif


}


//////////////////////////////////////////////////////////////////////////////////////////
#define	FADETIME	20
void	processPlan(FMAOBJECT* object,FMADATA* data)
{
	int	startTime;
	int	endTime,temp;

	if (frameTimeCount==data->startTime)
	{
		DB("load plan number %d\n",data->spare1);
		inventoryLoadPlan(data->spare1); // load the correct
	}
	startTime=data->startTime;
	endTime=data->endTime;
	
	if ( (frameTimeCount-startTime)<=FADETIME )
	{
		fmaStatus.fadeStatus=FADEUP;
		fmaStatus.fadeAmount=255-((frameTimeCount-startTime)*13);
		if (fmaStatus.fadeAmount<0) fmaStatus.fadeAmount=0;
	}
	else if ( (endTime-frameTimeCount)<=FADETIME )
	{
		fmaStatus.fadeStatus=FADEDOWN;
		fmaStatus.fadeAmount=255-((endTime-frameTimeCount)*13);
		if (fmaStatus.fadeAmount<0) fmaStatus.fadeAmount=0;
	}
	fmaStatus.planOn=TRUE;

	//fmaDrawPlan();

}

//////////////////////////////////////////////////////////////////////////////////////////
void	processExit(FMAOBJECT* object,FMADATA* data)
{
	int	i,temp,loop;

// put chars where the fma leaves them

	characterGetMainCharacter()->pEnemy->runFlags &=(~RUNFLAGS_BEENONGROUND);

	for (loop=0;loop<fmaCtrl->numObjects;loop++)
	{
		if (fmaCtrl->object[loop].crc>1)	// a crc of 0 is the camera
		{
			if ( (fmaCtrl->object[loop].crc!=utilStr2CRC("ROPE01")) && (fmaCtrl->object[loop].crc!=utilStr2CRC("ROPE02")) && (fmaCtrl->object[loop].crc!=utilStr2CRC("GINGERTOOLS")))
			{
				//fmaCtrl->object[loop].enemy->pos.vx=fmaCtrl->object[loop].actor->position.vx;
				//fmaCtrl->object[loop].enemy->pos.vy=fmaCtrl->object[loop].actor->position.vy;
				//fmaCtrl->object[loop].enemy->pos.vz=fmaCtrl->object[loop].actor->position.vz;
				if (levinfo->level_number!=LEVNUMBER_A4_KITCHEN && levinfo->level_number!=LEVNUMBER_A2_HOUSEXT_D && levinfo->level_number!=LEVNUMBER_A2_TOOLEXT_D)
				{
					enemyPlaceAt(fmaCtrl->object[loop].enemy,fmaCtrl->object[loop].actor->position.vx,
								fmaCtrl->object[loop].actor->position.vy,
								fmaCtrl->object[loop].actor->position.vz);
					fmaCtrl->object[loop].enemy->dir=fmaCtrl->object[loop].actor->psiData.object->rotate.vy;
					fmaCtrl->object[loop].enemy->desiredDir=fmaCtrl->object[loop].actor->psiData.object->rotate.vy;
				}
				else if (levinfo->level_number==LEVNUMBER_A2_HOUSEXT_D &&  inCrc!=A2_HOUSEXT_SPECIAL_CASE)
				{
					POSMARK *mark;
					mark=NULL;
					if ( fmaCtrl->object[loop].crc==utilStr2CRC("GINGER") )
					{
						//DB("looking for mark\n");
						mark = levinfoFindMarker(3);
					}
					if(mark)
					{
						enemyPlaceAt(fmaCtrl->object[loop].enemy,mark->x,mark->y-320,mark->z);
						//DB("mark found\n");
						fmaCtrl->object[loop].enemy->dir = mark->ya;
						fmaCtrl->object[loop].enemy->desiredDir = mark->ya;
						//pC->movement.desiredAngle=mark->ya;
					}
				}
				else if (inCrc==A2_TOOLEXT_SPECIAL_CASE2)
				{
					POSMARK *mark;
					mark=NULL;
					if ( fmaCtrl->object[loop].crc==utilStr2CRC("GINGER") )
					{
						DB("looking for mark\n");
						mark = levinfoFindMarker(3212);
					}
					if(mark)
					{
						enemyPlaceAt(fmaCtrl->object[loop].enemy,mark->x,mark->y-320,mark->z);
						DB("mark found\n");
						fmaCtrl->object[loop].enemy->dir = mark->ya;
						fmaCtrl->object[loop].enemy->desiredDir = mark->ya;
						//pC->movement.desiredAngle=mark->ya;
					}
				}

				else
				{
					POSMARK *mark;
					mark=NULL;
					if ( fmaCtrl->object[loop].crc==utilStr2CRC("NICK") )
					{
						mark = levinfoFindMarker(3213);
					}
					else if ( fmaCtrl->object[loop].crc==utilStr2CRC("FETCHER") )
					{
						mark = levinfoFindMarker(3214);
					}
					if(mark)
					{
						enemyPlaceAt(fmaCtrl->object[loop].enemy,mark->x,mark->y-320,mark->z);
						DB("mark found\n");
						fmaCtrl->object[loop].enemy->dir = mark->ya;
						fmaCtrl->object[loop].enemy->desiredDir = mark->ya;
						//pC->movement.desiredAngle=mark->ya;
					}
				}
			}
		}
	}


	freeFMA();
	inventoryLoadInventory();

	SpecialCaseFma=FALSE;

//	initCamera();

	camVars.timerTar=0;
	camVars.tarChange=0;
	camVars.tarChangeOn=0;

	fmaStatus.playing=FALSE;
//	temp=camVars.camTransitionSpeed;
//	camVars.camTransitionSpeed=7;

	initCamera();
	for (i=0;i<camVars.camTransitionSpeed;i++)
	{
		puzzleCheckPuzzles();	// This is here so that cam cases are setup for cam restart 
		upDateCamera(); // Yes I know but sorts out transistion from fma cam to game cam
	}

//	camVars.camTransitionSpeed=temp;

	fmaExitFlag=TRUE;

	GsSetProjection(startfov);
	if (inCrc==utilStr2CRC("SCENE1014") )
	{
		strcpy(&mapplay_next_level[0],"A1_DOGCHASE");
		mapplay_next_marker = 0;
		mapplay_leave_level_flag = 1;
	}
	if ( inCrc==utilStr2CRC("SCENE2023") || inCrc==utilStr2CRC("SCENE2024") || inCrc==utilStr2CRC("SCENE2034") || inCrc==utilStr2CRC("SCENE2035"))
	{
		strcpy(&mapplay_next_level[0],"A2_FIREWORKS");
		mapplay_next_marker = 0;
		mapplay_leave_level_flag = 1;
		gamePlayData->tasks_done[TASK_FIREWORKS_AVAIL] = 1;
	}
	if ( inCrc==utilStr2CRC("SCENE2044") || inCrc==utilStr2CRC("SCENE2045") || inCrc==utilStr2CRC("SCENE2050") || inCrc==utilStr2CRC("SCENE2051"))
	{
		strcpy(&mapplay_next_level[0],"A2_CATAPULT");
		mapplay_next_marker = 0;
		mapplay_leave_level_flag = 1;
		gamePlayData->tasks_done[TASK_CATAPULT_AVAIL] = 1;
	}
	if ( inCrc==utilStr2CRC("SCENE2074") || inCrc==utilStr2CRC("SCENE2075") || inCrc==utilStr2CRC("SCENE2078") || inCrc==utilStr2CRC("SCENE2079"))
	{
		strcpy(&mapplay_next_level[0],"A2_SEESAW");
		mapplay_next_marker = 0;
		mapplay_leave_level_flag = 1;
		gamePlayData->tasks_done[TASK_SEESAW_AVAIL] = 1;
	}

	if ( inCrc==utilStr2CRC("SCENE4045") || inCrc==utilStr2CRC("SCENE4046") || inCrc==utilStr2CRC("SCENE4052") || inCrc==utilStr2CRC("SCENE4053"))
	{
		strcpy(&mapplay_next_level[0],"A4_ENGINEHUT");
		mapplay_next_marker = 0;
		mapplay_leave_level_flag = 1;
		gamePlayData->tasks_done[TASK_ENGINE_AVAIL] = 1;
	}

	if ( inCrc==utilStr2CRC("SCENE4064") || inCrc==utilStr2CRC("SCENE4065") || inCrc==utilStr2CRC("SCENE4070") || inCrc==utilStr2CRC("SCENE4071"))
	{
		//strcpy(&mapplay_next_level[0],"A4_WINGHUT");
		strcpy(&mapplay_next_level[0],"A4_WINGSHUT"); // can I spell (no I can't)
		mapplay_next_marker = 0;
		mapplay_leave_level_flag = 1;
		gamePlayData->tasks_done[TASK_WINGMAKE_AVAIL] = 1;
		//overlayDebugMessage("Err where's the wing making sub game?", 25 * 3);
	}

	if ( inCrc==utilStr2CRC("SCENE4085") || inCrc==utilStr2CRC("SCENE4086") || inCrc==utilStr2CRC("SCENE4092") || inCrc==utilStr2CRC("SCENE4093"))
	{
		strcpy(&mapplay_next_level[0],"A4_CONSTRUCT");
		mapplay_next_marker = 0;
		mapplay_leave_level_flag = 1;
		gamePlayData->tasks_done[TASK_CONSTRUCT_AVAIL] = 1;
	}

	if ( inCrc==utilStr2CRC("SCENE4402") || inCrc==utilStr2CRC("SCENE4403") || inCrc==utilStr2CRC("SCENE4452") || inCrc==utilStr2CRC("SCENE4453") )
	{
		strcpy(&mapplay_next_level[0],"A4_TOOLSHED_N");
		mapplay_next_marker = 1;
		mapplay_leave_level_flag = 1;
		currentRat=currentCharacter=CHAR_NAME_NICK;	// dought this will work
		// it did!!
	}
	if ( inCrc==A4_EGGROOM_SPECIAL_CASE)
	{
		strcpy(&mapplay_next_level[0],"A4_EGGROOM");
		mapplay_next_marker = 0;
		mapplay_leave_level_flag = 1;
		currentChicken=currentCharacter=CHAR_NAME_GINGER;	// dought this will work
		characterMakeMainCRC(CRC_GINGER);
	}
	if ( inCrc==A4_GARDEN_SPECIAL_CASE_G)
	{
		//overlayDebugMessage("To the Garden!", 25 * 3);
		strcpy(&mapplay_next_level[0],"A4_GARDEN_N");
		mapplay_next_marker = 2;
		mapplay_leave_level_flag = 1;
		currentChicken=currentCharacter=CHAR_NAME_GINGER;	// dought this will work
		characterMakeMainCRC(CRC_GINGER);
	}
	if ( inCrc==A4_GARDEN_SPECIAL_CASE_R)
	{
		//overlayDebugMessage("To the Garden!", 25 * 3);
		strcpy(&mapplay_next_level[0],"A4_GARDEN_N");
		mapplay_next_marker = 2;
		mapplay_leave_level_flag = 1;
		currentChicken=currentCharacter=CHAR_NAME_ROCKY;	// dought this will work
		characterMakeMainCRC(CRC_ROCKY);
	}
	if ( inCrc==A2_HOUSEXT_SPECIAL_CASE)
	{
		strcpy(&mapplay_next_level[0],"A2_COOP1_D");
		mapplay_next_marker = 4;
		mapplay_leave_level_flag = 1;
		currentChicken=currentCharacter=CHAR_NAME_GINGER;
		characterMakeMainCRC(CRC_GINGER);
	}
	if ( inCrc==A2_TOOLEXT_SPECIAL_CASE)
	{
		strcpy(&mapplay_next_level[0],"A2_COOP2_D");
		mapplay_next_marker = 20;
		mapplay_leave_level_flag = 1;
		currentChicken=currentCharacter=CHAR_NAME_GINGER;
		characterMakeMainCRC(CRC_GINGER);
	}
	if ( inCrc==A4_KITCHEN_SPECIAL_CASE)
	{
		strcpy(&mapplay_next_level[0],"A4_GARDEN_N");
		mapplay_next_marker = 2;	// tbd correct pos marker
		mapplay_leave_level_flag = 1;
		currentChicken=currentCharacter=CHAR_NAME_GINGER;
		characterMakeMainCRC(CRC_GINGER);
	}
	if (inCrc==A4_PIEBARN_SPECIAL_CASE)
	{
		strcpy(&mapplay_next_level[0],"A4_EGGROOM");
		mapplay_next_marker = 0;	// tbd correct pos marker
		mapplay_leave_level_flag = 1;
		currentChicken=currentCharacter=CHAR_NAME_GINGER;
		characterMakeMainCRC(CRC_GINGER);
	}

	if ( inCrc==A1_COOP1_SPECIAL_CASE )
		gamePlayData->tasks_done[TASK_CUT_COOP1_FENCE] = 1;

	if ( inCrc==A1_GARDEN_SPECIAL_CASE )
		gamePlayData->tasks_done[TASK_CUT_CLOTHES_LINE] = 1;


	if (playedActNumber==FMA_ACT1)
		gamePlayData->A1fmaStatus[playedSceneNumber].playedTime=loop_ticker2;	// this might not be quite what i want
	else if (playedActNumber==FMA_ACT2)
		gamePlayData->A2fmaStatus[playedSceneNumber].playedTime=loop_ticker2;
	else if (playedActNumber==FMA_ACT4)
		gamePlayData->A4fmaStatus[playedSceneNumber].playedTime=loop_ticker2;
}

//////////////////////////////////////////////////////////////////////////////////////////
// This is called at the start of a new level


typedef struct
{
	char *name;
	int value;
}NAMEVALUE;

// TBD At some point, this can be switched to use levinfo->level_num
NAMEVALUE LevelConverter[] =
{
	{"A1_HUT17",	A1_HUT17_FMA},
	{"A1_WORKHUT1",	A1_WORKHUT1_FMA},
	{"A2_HUT17",	A2_HUT17_FMA},
	{"A2_WORKHUT1",	A2_WORKHUT1_FMA},
	{"A2_WORKHUT2",	A2_WORKHUT2_FMA},
	{"A2_WORKHUT3",	A2_WORKHUT3_FMA},
	{"A4_HUT17",	A4_HUT17_FMA},
	{"A4_WORKHUT1",	A4_WORKHUT1_FMA},
	{"A4_WORKHUT2",	A4_WORKHUT2_FMA},
	{"A4_WORKHUT3",	A4_WORKHUT3_FMA},
	{"A4_WORKHUT4",	A4_WORKHUT4_FMA},
	{"A4_EGGHUT",	A4_EGGHUT_FMA},
	{"A4_KITCHEN",	A4_KITCHEN_FMA},
	{"A4_PIEBARN",	A4_PIEBARN_FMA},
	{"A4_TUNNEL",	A4_TUNNEL_FMA},

	{"A4_CONSTRUCT",A4_CONSTRUCT_FMA}, 
	{"A4_FLYMACHINE",A4_FLYMACHINE_FMA},
	{"TL_HUT17FMA",	TL_HUT17FMA_FMA},	// This is for testing 
	{"TL_KITCHEN",	TL_KITCHEN_FMA},	// This is for testing 
	{"TL_PIEBARN",	TL_PIEBARN_FMA},
	{"TL_TUNNEL",	TL_TUNNEL_FMA},
	{"TL_GARDEN_N",	TL_GARDEN_FMA},
	{"TL_WORKHUT1",	TL_WORKHUT1_FMA},
	{"TL_WORKHUT2",	TL_WORKHUT2_FMA},
	{"TL_WORKHUT3",	TL_WORKHUT3_FMA},
	{"TL_WORKHUT4",	TL_WORKHUT4_FMA},
	{"TL_COOP1_D",	TL_COOP1_FMA},
	{"TL_COOP2_D",	TL_COOP2_FMA},
	{"TL_HOUSEXT_D",TL_HOUSEXT_FMA},
	{"TL_TOOLEXT_D",TL_TOOLEXT_FMA},
	{"TL_LOUNGE",	TL_LOUNGE_FMA}
};

#define	NOT_FOUND	9999


//	this is now going to handle all cases for the fma with xState set if button pressed
// TBD	move level stuff to seperate subroutine before it gets too unweldly
void	FMAplayCheck(int xState)
{
	int	test;
	int	count;
//	int	subgame1;
//	int	subgame2;
//	int	subgame3;

	DB("fma play check called\n");
	//SpecialCaseFma=FALSE;
	//startFMA("NICKTEST");
	//return;
	if (fmaStatus.playing) return;	// stop the fma calling itself


	switch(levinfo->level_number)
	{
		case LEVNUMBER_A1_HUT17:
			a1Hut17FmaChecks(xState);
			break;

		case LEVNUMBER_A1_COOP1_N:
			if(currentInv->selected_item==WIRE_CUTTERS && xState)
			{
				if(!gamePlayData->tasks_done[TASK_CUT_COOP1_FENCE])
				{
					//overlayDebugMessage("TBD - You cut through the fence", 25 * 3);
					// Cut through the fence. The meshswap is dealt with in the puzzle engine
					startFMA("WCUT_G");

					inCrc=A1_COOP1_SPECIAL_CASE;
					//gamePlayData->tasks_done[TASK_CUT_COOP1_FENCE] = 1;
					//return 1;
					return;
				}
				else
				{
					// Trying to use the cutters at an already-cut wire
					//return 0;
					return;
				}
			}
			break;

		case LEVNUMBER_A1_WORKHUT1:
			a1Workhut1FmaChecks(xState);
			break;

		case LEVNUMBER_A1_GARDEN_N:

			if (currentInv->selected_item==WIRE_CUTTERS && xState)
			{
				if(!gamePlayData->tasks_done[TASK_CUT_CLOTHES_LINE])
				{
					//overlayDebugMessage("Snip the clothesline", 25 * 3);
					//inventoryRemoveItem(item);			// You shouldnt lose the wire-cutters
					startFMA("WASH_G");
					inCrc=A1_GARDEN_SPECIAL_CASE;
					// CPW: gamePlayData->tasks_done[TASK_CUT_CLOTHES_LINE] = 1;
				}

				return;
			}
			break;

	// and that ladies and gents is the end of act1	
	// here comes act2
		case LEVNUMBER_A2_HUT17:
			a2Hut17FmaChecks(xState);
			break;
		// ok hut 17 looks ok but not tested with rocky yet
		case	LEVNUMBER_A2_WORKHUT1:
			a2Workhut1FmaChecks(xState);
			break;
		case	LEVNUMBER_A2_WORKHUT2:
			a2Workhut2FmaChecks(xState);
			break;
		case	LEVNUMBER_A2_WORKHUT3:
			a2Workhut3FmaChecks(xState);
			break;

		case LEVNUMBER_A2_COOP2_D:
			if (currentInv->selected_item==SPOON && xState)
			{
				if(!gamePlayData->tasks_done[TASK_DUG_COOP2_FENCE])
				{
					//overlayDebugMessage("TBD - You dig under the fence", 25 * 3);
					// Dig under the fence. The meshswap is dealt with in the puzzle engine
					//startFMA("insert correct fma here");
					startFMA("DIG_G");

					gamePlayData->tasks_done[TASK_DUG_COOP2_FENCE] = 1;

					inventoryRemoveItem(SPOON);
					return;
				}
				else
				{
// Actually, this should never happen
					overlayDebugMessage("Program flow error!", 25 * 3);
					ASSERT(0);
					return;
				}
			}
			break;


		case 	LEVNUMBER_A2_HOUSEXT_D:
			a2HousextFmaChecks(xState);	// an extension of the above
			break;

		case	LEVNUMBER_A2_TOOLEXT_D:
			a2ToolextFmaChecks(xState);
			break;

		case LEVNUMBER_A4_HUT17:
			a4Hut17FmaChecks(xState);
			break;

		case LEVNUMBER_A4_WORKHUT1:
			a4Workhut1FmaChecks(xState);
			break;

		case LEVNUMBER_A4_WORKHUT2:
			a4Workhut2FmaChecks(xState);
			break;

		case LEVNUMBER_A4_WORKHUT3:
			a4Workhut3FmaChecks(xState);
			break;

		case LEVNUMBER_A4_WORKHUT4:
			a4Workhut4FmaChecks(xState);
			break;

		case LEVNUMBER_A4_KITCHEN:
			a4KitchenFmaChecks(xState);
			break;

		case LEVNUMBER_A4_PIEBARN:
			a4PiebarnFmaChecks(xState);
			break;

		case LEVNUMBER_A4_TUNNEL:
			a4TunnelFmaChecks(xState);
			break;
	}
}

/////////////////////////////////////////////////////////////////////////////
void	a2ToolextFmaChecks(int	xState)
{
	int	itemsCarried,itemsCollected;

	itemsCarried=0;
	itemsCollected=0;;

 	playedActNumber=FMA_ACT2;

	if (gamePlayData->inventory_item_status[COOKING_WEIGHTS]==INV_STATUS_IN_INVENTORY) itemsCarried++;
	else if (gamePlayData->inventory_item_status[COOKING_WEIGHTS]==INV_STATUS_REMOVED) itemsCollected++;

	if (gamePlayData->inventory_item_status[MATCHES]==INV_STATUS_IN_INVENTORY) itemsCarried++;
	else if (gamePlayData->inventory_item_status[MATCHES]==INV_STATUS_REMOVED) itemsCollected++;

	if (gamePlayData->inventory_item_status[FIREWORKS]==INV_STATUS_IN_INVENTORY) itemsCarried++;
	else if (gamePlayData->inventory_item_status[FIREWORKS]==INV_STATUS_REMOVED) itemsCollected++;

	if (gamePlayData->inventory_item_status[TENNIS_RACKET]==INV_STATUS_IN_INVENTORY) itemsCarried++;
	else if (gamePlayData->inventory_item_status[TENNIS_RACKET]==INV_STATUS_REMOVED) itemsCollected++;

	if (gamePlayData->inventory_item_status[PRAM_CHASSIS]==INV_STATUS_IN_INVENTORY) itemsCarried++;
	else if (gamePlayData->inventory_item_status[PRAM_CHASSIS]==INV_STATUS_REMOVED) itemsCollected++;

	if (gamePlayData->inventory_item_status[STRONG_CORD]==INV_STATUS_IN_INVENTORY) itemsCarried++;
	else if (gamePlayData->inventory_item_status[STRONG_CORD]==INV_STATUS_REMOVED) itemsCollected++;

	if (gamePlayData->inventory_item_status[BROKEN_LADDER]==INV_STATUS_IN_INVENTORY) itemsCarried++;
	else if (gamePlayData->inventory_item_status[BROKEN_LADDER]==INV_STATUS_REMOVED) itemsCollected++;


	if (currentCharacter==CHAR_NAME_GINGER) // you've come from the coop leave as rocky
	{
		//characterSetHideStatus(TRUE);	// turn ginger off
		currentChicken=currentCharacter=CHAR_NAME_ROCKY;
		characterMakeMainCRC(CRC_ROCKY);

		if ( (itemsCarried+itemsCollected)<7 ) // hav'nt got all objects
		{
			gamePlayData->A2fmaStatus[SCENE8011].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE8011;
			startFMA("SCENE8011");	// normal gin to roc
			inCrc=A2_TOOLEXT_SPECIAL_CASE2;
			return;
		}
		else // all objects done
		{
			gamePlayData->A2fmaStatus[SCENE8014].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE8014;
			startFMA("SCENE8014");	// all done gin to roc
			inCrc=A2_TOOLEXT_SPECIAL_CASE2;
			return;
		}
	}
	else	// going to coop leave as ginger
	{
		//characterSetHideStatus(TRUE);	// turn rocky off
		currentChicken=currentCharacter=CHAR_NAME_GINGER;
		characterMakeMainCRC(CRC_GINGER);

		if ( (itemsCarried==0) && (itemsCollected==7) )
		{
			gamePlayData->A2fmaStatus[SCENE8015].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE8015;
			startFMA("SCENE8015");	// normal rocky to ginger with full sucess
			inCrc=A2_TOOLEXT_SPECIAL_CASE;
			return;
		}
		if ( (itemsCarried)==0 ) // no objects
		{
			gamePlayData->A2fmaStatus[SCENE8013].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE8013;
			startFMA("SCENE8013");	// normal rocky to ginger
			inCrc=A2_TOOLEXT_SPECIAL_CASE;
			return;
		}
		else if ( (itemsCarried+itemsCollected)<7 ) // some but not all objects
		{
			gamePlayData->A2fmaStatus[SCENE8012].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE8012;
			startFMA("SCENE8012");	// normal rocky to ginger with part sucess
			inCrc=A2_TOOLEXT_SPECIAL_CASE;
			return;
		}
		else
		{
			gamePlayData->A2fmaStatus[SCENE8015].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE8015;
			startFMA("SCENE8015");	// normal rocky to ginger with full sucess
			inCrc=A2_TOOLEXT_SPECIAL_CASE;
			return;
		}
	}
}

/////////////////////////////////////////////////////////////////////////////
void	a2HousextFmaChecks(int	xState)
{
	int	itemsCarried,itemsCollected;
// Ok the all new rocky to ginger change over code, would have been nice to be told whats going on instead of having to figure it out all the time
// Its an automatic one to handle charater changes

// Ok first thing have we come from the coop ?
// We can get this info from what the current char is

// next what if any items do we have
	itemsCarried=0;
	itemsCollected=0;;

/*	COOKING_WEIGHTS,
	MATCHES,
	FIREWORKS,
	TENNIS_RACKET,
	PRAM_CHASSIS,
	STRONG_CORD,
	BROKEN_LADDER,
*/

 	playedActNumber=FMA_ACT2;

	if (gamePlayData->inventory_item_status[COOKING_WEIGHTS]==INV_STATUS_IN_INVENTORY) itemsCarried++;
	else if (gamePlayData->inventory_item_status[COOKING_WEIGHTS]==INV_STATUS_REMOVED) itemsCollected++;

	if (gamePlayData->inventory_item_status[MATCHES]==INV_STATUS_IN_INVENTORY) itemsCarried++;
	else if (gamePlayData->inventory_item_status[MATCHES]==INV_STATUS_REMOVED) itemsCollected++;

	if (gamePlayData->inventory_item_status[FIREWORKS]==INV_STATUS_IN_INVENTORY) itemsCarried++;
	else if (gamePlayData->inventory_item_status[FIREWORKS]==INV_STATUS_REMOVED) itemsCollected++;

	if (gamePlayData->inventory_item_status[TENNIS_RACKET]==INV_STATUS_IN_INVENTORY) itemsCarried++;
	else if (gamePlayData->inventory_item_status[TENNIS_RACKET]==INV_STATUS_REMOVED) itemsCollected++;

	if (gamePlayData->inventory_item_status[PRAM_CHASSIS]==INV_STATUS_IN_INVENTORY) itemsCarried++;
	else if (gamePlayData->inventory_item_status[PRAM_CHASSIS]==INV_STATUS_REMOVED) itemsCollected++;

	if (gamePlayData->inventory_item_status[STRONG_CORD]==INV_STATUS_IN_INVENTORY) itemsCarried++;
	else if (gamePlayData->inventory_item_status[STRONG_CORD]==INV_STATUS_REMOVED) itemsCollected++;

	if (gamePlayData->inventory_item_status[BROKEN_LADDER]==INV_STATUS_IN_INVENTORY) itemsCarried++;
	else if (gamePlayData->inventory_item_status[BROKEN_LADDER]==INV_STATUS_REMOVED) itemsCollected++;

	if (currentCharacter==CHAR_NAME_GINGER) // you've come from the coop leave as rocky
	{
		//characterSetHideStatus(TRUE);	// turn ginger off
		currentChicken=currentCharacter=CHAR_NAME_ROCKY;	// set to rocky
		characterMakeMainCRC(CRC_ROCKY);
		//mapplay_next_marker=99;
		

		if ( (itemsCarried+itemsCollected)<7 ) // hav'nt got all objects
		{
			gamePlayData->A2fmaStatus[SCENE8001].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE8001;
			startFMA("SCENE8001");	// normal gin to roc
			return;
		}
		else // all objects done
		{
			gamePlayData->A2fmaStatus[SCENE8004].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE8004;
			startFMA("SCENE8004");	// all done gin to roc
			return;
		}
	}
	else	// going to coop leave as ginger
	{
		//characterSetHideStatus(TRUE);	// turn rocky off
		currentChicken=currentCharacter=CHAR_NAME_GINGER;
		characterMakeMainCRC(CRC_GINGER);

		if ( (itemsCarried==0) && (itemsCollected==7) )
		{
			gamePlayData->A2fmaStatus[SCENE8015].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE8015;
			startFMA("SCENE8015");	// normal rocky to ginger with full sucess
			inCrc=A2_TOOLEXT_SPECIAL_CASE;
			return;
		}

		if ( (itemsCarried)==0 ) // no objects
		{
			gamePlayData->A2fmaStatus[SCENE8003].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE8003;
			startFMA("SCENE8003");	// normal rocky to ginger
			inCrc=A2_HOUSEXT_SPECIAL_CASE;
			return;
		}
		else if ( (itemsCarried+itemsCollected)<7 ) // some but not all objects
		{
			gamePlayData->A2fmaStatus[SCENE8002].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE8002;
			startFMA("SCENE8002");	// normal rocky to ginger with part sucess
			inCrc=A2_HOUSEXT_SPECIAL_CASE;
			return;
		}
		else
		{
			gamePlayData->A2fmaStatus[SCENE8005].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE8005;
			startFMA("SCENE8005");	// normal rocky to ginger with full sucess
			inCrc=A2_HOUSEXT_SPECIAL_CASE;
			return;
		}
	}
}


/////////////////////////////////////////////////////////////////////////////
void	a4TunnelFmaChecks(int	xState)
{
	int	loop,count;
	// Ok have we entered as a chicken or rat?
 	playedActNumber=FMA_ACT4;
	if (currentCharacter==CHAR_NAME_ROCKY || currentCharacter==CHAR_NAME_GINGER)
	{	// if you come in as a chicken and you have eggs then you leave as a rat
		//count=0;
		//for (loop=0;loop<6;loop++)
		//{
		//	if (currentInv->slot_contents[loop]==EGG) count++;	// how are we going to pick up eggs?
		//}
		//count=6;	// I'm not going to code for the no eggs case till the whole issue is sorted out

		count=gamePlayData->eggs_carried;
		if (count==6)	// do we have the required number of eggs?
		{
			gamePlayData->eggs_carried=0;
			if (currentCharacter==CHAR_NAME_GINGER)
			{
				if (gamePlayData->A4fmaStatus[SCENE4402].playedFlag==FMA_NOTPLAYED)
				{
					gamePlayData->A4fmaStatus[SCENE4402].playedFlag=FMA_PLAYED;
					gamePlayData->A4fmaStatus[SCENE4400].playedFlag=FMA_PLAYED;
					playedSceneNumber=SCENE4402;
					startFMA("SCENE4402");
					return;
				}
				else 
				{
					gamePlayData->A4fmaStatus[SCENE4403].playedFlag=FMA_PLAYED;
					playedSceneNumber=SCENE4403;
					startFMA("SCENE4403");
					return;
				}
			}
/*			else
			{
				if (gamePlayData->A4fmaStatus[SCENE4452].playedFlag==FMA_NOTPLAYED)
				{
					gamePlayData->A4fmaStatus[SCENE4452].playedFlag=FMA_PLAYED;
					playedSceneNumber=SCENE4452;
					startFMA("SCENE4452");
					return;
				}
				else 
				{
					gamePlayData->A4fmaStatus[SCENE4453].playedFlag=FMA_PLAYED;
					playedSceneNumber=SCENE4453;
					startFMA("SCENE4453");
					return;
				}
			}
*/		}
		else
		{
			if (gamePlayData->A4fmaStatus[SCENE4400].playedFlag==FMA_NOTPLAYED)
			{
				gamePlayData->A4fmaStatus[SCENE4400].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4400;
				startFMA("SCENE4400");
				return;
			}
			else
			{
				gamePlayData->A4fmaStatus[SCENE4401].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4401;
				startFMA("SCENE4401");
				return;
			}
		}
	}
	else // ok you've entered as a rat NOTE I'm hoping currentchicken stays set to who you were
	{
		int	engineC=0;int chainC=0;int polesC=0;	// currently held objects
		int	engineL=0;int chainL=0;int polesL=0;	// not held but done
		int	eTest,cTest,pTest;	// used for tests

		//if (gamePlayData->inventory_item_status[ENGINE]==INV_STATUS_IN_INVENTORY) engineC=TRUE;
		//if (gamePlayData->inventory_item_status[ENGINE]==INV_STATUS_IN_INVENTORY) engineC=TRUE;

		if ( gamePlayData->tasks_done[TASK_FINISHED_A4_TRACTOR] )
		{
			engineC=TRUE;
			gamePlayData->inventory_item_status[ENGINE]=INV_STATUS_REMOVED;
		}

		if (gamePlayData->inventory_item_status[CHAIN]==INV_STATUS_IN_INVENTORY) chainC=TRUE;
		if (gamePlayData->inventory_item_status[A4POLES]==INV_STATUS_IN_INVENTORY) polesC=TRUE;

		//if (gamePlayData->inventory_item_status[ENGINE]==INV_STATUS_REMOVED) engineL=TRUE;
		if (gamePlayData->inventory_item_status[CHAIN]==INV_STATUS_REMOVED) chainL=TRUE;
		if (gamePlayData->inventory_item_status[A4POLES]==INV_STATUS_REMOVED) polesL=TRUE;

		// ok were you ginger or rocky?
		if (currentChicken==CHAR_NAME_GINGER)
		{
			currentChicken=currentCharacter=CHAR_NAME_GINGER;	// dought this will work
			characterMakeMainCRC(CRC_GINGER);
			// and guess what, it did'nt
			if ( engineC && chainC && polesC ) // all objects
			{
				gamePlayData->A4fmaStatus[SCENE4417].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4417;
				startFMA("SCENE4417");
				return;
			}
			else if ( engineC && chainL && polesL ) // all objects but some done last time round
			{
				gamePlayData->A4fmaStatus[SCENE4418].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4418;
				startFMA("SCENE4418");	// done it but ginger has a moan
				return;
			}
			else if ( engineL && chainC && polesL ) // all objects but some done last time round
			{
				gamePlayData->A4fmaStatus[SCENE4419].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4419;
				startFMA("SCENE4419");	// done it but ginger has a moan
				return;
			}
			else if ( engineL && chainL && polesC ) // all objects but some done last time round
			{
				gamePlayData->A4fmaStatus[SCENE4420].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4420;
				startFMA("SCENE4420");	// done it but ginger has a moan
				return;
			}
			eTest=engineL|engineC;
			cTest=chainL|chainC;
			pTest=polesL|polesC;
			if ( eTest && pTest && cTest ) // just to stop anything falling throught the net
			{
				gamePlayData->A4fmaStatus[SCENE4417].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4417;
				startFMA("SCENE4417");
				return;
			}
			if ( !engineC && !chainC && !polesC )
			{
				gamePlayData->A4fmaStatus[SCENE4410].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4410;
				startFMA("SCENE4410");	// nothing
				return;
			}
			else if (!engineC && !chainC && polesC)
			{
				gamePlayData->A4fmaStatus[SCENE4413].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4413;
				startFMA("SCENE4413");
				return;
			}
			else if (!engineC && chainC && !polesC)
			{
				gamePlayData->A4fmaStatus[SCENE4412].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4412;
				startFMA("SCENE4412");
				return;
			}
			else if (!engineC && chainC && polesC)
			{
				gamePlayData->A4fmaStatus[SCENE4416].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4416;
				startFMA("SCENE4416");
				return;
			}
			else if (engineC && !chainC && !polesC)
			{
				gamePlayData->A4fmaStatus[SCENE4411].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4411;
				startFMA("SCENE4411");
				return;
			}
			else if (engineC && !chainC && polesC)
			{
				gamePlayData->A4fmaStatus[SCENE4415].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4415;
				startFMA("SCENE4415");
				return;
			}
			else if (engineC && chainC && !polesC)
			{
				gamePlayData->A4fmaStatus[SCENE4414].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4414;
				startFMA("SCENE4414");
				return;
			}
			// and that should cope with all eventuallitys
		}
		else // rocky
		{
			currentChicken=currentCharacter=CHAR_NAME_ROCKY;	// dought this will work
			characterMakeMainCRC(CRC_ROCKY);
			// and guess what, it did'nt (t'll it was fixed)
			if ( engineC && chainC && polesC ) // all objects
			{
				gamePlayData->A4fmaStatus[SCENE4467].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4467;
				startFMA("SCENE4467");
				return;
			}
			else if ( engineC && chainL && polesL ) // all objects but some done last time round
			{
				gamePlayData->A4fmaStatus[SCENE4468].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4468;
				startFMA("SCENE4468");	// done it but ginger has a moan
				return;
			}
			else if ( engineL && chainC && polesL ) // all objects but some done last time round
			{
				gamePlayData->A4fmaStatus[SCENE4469].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4469;
				startFMA("SCENE4469");	// done it but ginger has a moan
				return;
			}
			else if ( engineL && chainL && polesC ) // all objects but some done last time round
			{
				gamePlayData->A4fmaStatus[SCENE4470].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4470;
				startFMA("SCENE4470");	// done it but ginger sorry rocky has a moan
				return;
			}
			eTest=engineL|engineC;
			cTest=chainL|chainC;
			pTest=polesL|polesC;
			if ( eTest && pTest && cTest ) // just to stop anything falling throught the net
			{
				gamePlayData->A4fmaStatus[SCENE4467].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4467;
				startFMA("SCENE4467");
				return;
			}
			if ( !engineC && !chainC && !polesC )
			{
				gamePlayData->A4fmaStatus[SCENE4460].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4460;
				startFMA("SCENE4460");	// nothing
				return;
			}
			else if (!engineC && !chainC && polesC)
			{
				gamePlayData->A4fmaStatus[SCENE4463].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4463;
				startFMA("SCENE4463");
				return;
			}
			else if (!engineC && chainC && !polesC)
			{
				gamePlayData->A4fmaStatus[SCENE4462].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4462;
				startFMA("SCENE4462");
				return;
			}
			else if (!engineC && chainC && polesC)
			{
				gamePlayData->A4fmaStatus[SCENE4466].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4466;
				startFMA("SCENE4466");
				return;
			}
			else if (engineC && !chainC && !polesC)
			{
				gamePlayData->A4fmaStatus[SCENE4461].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4461;
				startFMA("SCENE4461");
				return;
			}
			else if (engineC && !chainC && polesC)
			{
				gamePlayData->A4fmaStatus[SCENE4465].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4465;
				startFMA("SCENE4465");
				return;
			}
			else if (engineC && chainC && !polesC)
			{
				gamePlayData->A4fmaStatus[SCENE4464].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4464;
				startFMA("SCENE4464");
				return;
			}
			// and that should cope with all eventuallitys
		}
	}
}

/////////////////////////////////////////////////////////////////////////////
void	a4PiebarnFmaChecks(int	xState)
{
	//DB("Fma needs to be coded\n");
	int	loop,count;
	// Ok have we entered as a chicken or rat?
 	playedActNumber=FMA_ACT4;
	if (currentCharacter==CHAR_NAME_GINGER)
	{	// if you come in as a chicken and you have eggs then you leave as a rat
		//count=0;
		//for (loop=0;loop<6;loop++)
		//{
		//	if (currentInv->slot_contents[loop]==EGG) count++;	// how are we going to pick up eggs?
		//}
//		count=6;	// I'm not going to code for the no eggs case till the whole issue is sorted out

		count=gamePlayData->eggs_carried;

		if (count==6)	// do we have the required number of eggs?
		{
			// Turn ginger into a rat 
			gamePlayData->eggs_carried=0;
			currentRat=currentCharacter=CHAR_NAME_NICK;	// dought this will work
			characterMakeMainCRC(CRC_NICK);
			if (gamePlayData->A4fmaStatus[SCENE4302].playedFlag==FMA_NOTPLAYED)
			{
				gamePlayData->A4fmaStatus[SCENE4302].playedFlag=FMA_PLAYED;
				gamePlayData->A4fmaStatus[SCENE4300].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4302;
				startFMA("SCENE4302");
				return;
			}
			else 
			{
				gamePlayData->A4fmaStatus[SCENE4303].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4303;
				startFMA("SCENE4303");
				return;
			}
		}
		else
		{
			if (gamePlayData->A4fmaStatus[SCENE4300].playedFlag==FMA_NOTPLAYED)
			{
				gamePlayData->A4fmaStatus[SCENE4300].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4300;
				startFMA("SCENE4300");
				inCrc=A4_PIEBARN_SPECIAL_CASE;
				return;
			}
			else 
			{
				gamePlayData->A4fmaStatus[SCENE4301].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4301;
				startFMA("SCENE4301");
				inCrc=A4_PIEBARN_SPECIAL_CASE;
				return;
			}
		}
	}
	else if (currentCharacter==CHAR_NAME_ROCKY)	// you should'nt be here go away
	{
		strcpy(&mapplay_next_level[0],"A4_EGGROOM");
		mapplay_next_marker = 0;
		mapplay_leave_level_flag = 1;
		//gamePlayData->tasks_done[TASK_FIREWORKS_AVAIL] = 1;
	}
	else if (xState) // if your near ginger and you press x 
	{
		int	oilC=0;int cogsC=0;int toolsC=0;	// currently held objects
		int	oilL=0;int cogsL=0;int toolsL=0;	// not held but done
		int	oTest,cTest,tTest;	// used for tests

		if (gamePlayData->inventory_item_status[OIL_CAN]==INV_STATUS_IN_INVENTORY) oilC=TRUE;
		if (gamePlayData->inventory_item_status[COGS]==INV_STATUS_IN_INVENTORY) cogsC=TRUE;
		if (gamePlayData->inventory_item_status[TOOLS]==INV_STATUS_IN_INVENTORY) toolsC=TRUE;

		if (gamePlayData->inventory_item_status[OIL_CAN]==INV_STATUS_REMOVED) oilL=TRUE;
		if (gamePlayData->inventory_item_status[COGS]==INV_STATUS_REMOVED) cogsL=TRUE;
		if (gamePlayData->inventory_item_status[TOOLS]==INV_STATUS_REMOVED) toolsL=TRUE;

		if (oilC && cogsC && toolsC)
		{
			gamePlayData->A4fmaStatus[SCENE4317].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE4317;
			startFMA("SCENE4317");
			inCrc=A4_EGGROOM_SPECIAL_CASE;
			return;
		}
		else if (oilC && cogsL && toolsL)
		{
			gamePlayData->A4fmaStatus[SCENE4318].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE4318;
			startFMA("SCENE4318");
			inCrc=A4_EGGROOM_SPECIAL_CASE;
			return;
		}
		else if (oilL && cogsL && toolsC)
		{
			gamePlayData->A4fmaStatus[SCENE4319].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE4319;
			startFMA("SCENE4319");
			inCrc=A4_EGGROOM_SPECIAL_CASE;
			return;
		}
		else if (oilL && cogsC && toolsL)
		{
			gamePlayData->A4fmaStatus[SCENE4320].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE4320;
			startFMA("SCENE4320");
			inCrc=A4_EGGROOM_SPECIAL_CASE;
			return;
		}
		oTest=oilL|oilC;
		cTest=cogsL|cogsC;
		tTest=toolsL|toolsC;
		if ( oTest && cTest && tTest ) // just in case
		{
			gamePlayData->A4fmaStatus[SCENE4317].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE4317;
			startFMA("SCENE4317");
			inCrc=A4_EGGROOM_SPECIAL_CASE;
			return;
		}
		if ( !oTest && !cTest && !tTest )
		{
			gamePlayData->A4fmaStatus[SCENE4310].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE4310;
			startFMA("SCENE4310");
			inCrc=A4_EGGROOM_SPECIAL_CASE;
			return;
		}

		if ( !oilC && !cogsC && toolsC )
		{
			gamePlayData->A4fmaStatus[SCENE4312].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE4312;
			startFMA("SCENE4312");
			inCrc=A4_EGGROOM_SPECIAL_CASE;
			return;
		}
		else if ( !oilC && cogsC && !toolsC )
		{
			gamePlayData->A4fmaStatus[SCENE4313].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE4313;
			startFMA("SCENE4313");
			inCrc=A4_EGGROOM_SPECIAL_CASE;
			return;
		}
		else if ( !oilC && cogsC && toolsC )
		{
			gamePlayData->A4fmaStatus[SCENE4316].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE4316;
			startFMA("SCENE4316");
			inCrc=A4_EGGROOM_SPECIAL_CASE;
			return;
		}
		else if ( oilC && !cogsC && !toolsC )
		{
			gamePlayData->A4fmaStatus[SCENE4311].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE4311;
			startFMA("SCENE4311");
			inCrc=A4_EGGROOM_SPECIAL_CASE;
			return;
		}
		else if ( oilC && !cogsC && toolsC )
		{
			gamePlayData->A4fmaStatus[SCENE4314].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE4314;
			startFMA("SCENE4314");
			inCrc=A4_EGGROOM_SPECIAL_CASE;
			return;
		}
		else if ( oilC && cogsC && !toolsC )
		{
			gamePlayData->A4fmaStatus[SCENE4315].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE4315;
			startFMA("SCENE4315");
			inCrc=A4_EGGROOM_SPECIAL_CASE;
			return;
		}
	}
}

/////////////////////////////////////////////////////////////////////////////
void	a4KitchenFmaChecks(int	xState)
{
	int	loop,count;
	// Ok have we entered as a chicken or rat?
 	playedActNumber=FMA_ACT4;
	if (currentCharacter==CHAR_NAME_ROCKY || currentCharacter==CHAR_NAME_GINGER)
	{	// if you come in as a chicken and you have eggs then you leave as a rat

		//count=0;
		//for (loop=0;loop<6;loop++)
		//{
		//	if (currentInv->slot_contents[loop]==EGG) count++;	// how are we going to pick up eggs?
		//}
		//count=6;	// I'm not going to code for the no eggs case till the whole issue is sorted out

		count=gamePlayData->eggs_carried;

		if (count==6)	// do we have the required number of eggs?
		{
			gamePlayData->eggs_carried=0;
			if (currentCharacter==CHAR_NAME_GINGER)
			{
				currentRat=currentCharacter=CHAR_NAME_NICK;	// dought this will work
				characterMakeMainCRC(CRC_NICK);
				//inCrc=A4_GARDEN_SPECIAL_CASE;
				if (gamePlayData->A4fmaStatus[SCENE4202].playedFlag==FMA_NOTPLAYED)
				{
					gamePlayData->A4fmaStatus[SCENE4202].playedFlag=FMA_PLAYED;
					gamePlayData->A4fmaStatus[SCENE4200].playedFlag=FMA_PLAYED;
					playedSceneNumber=SCENE4202;
					startFMA("SCENE4202");
					return;
				}
				else 
				{
					gamePlayData->A4fmaStatus[SCENE4203].playedFlag=FMA_PLAYED;
					playedSceneNumber=SCENE4203;
					startFMA("SCENE4203");
					return;
				}
			}
/*			else
			{
				currentRat=currentCharacter=CHAR_NAME_NICK;	// dought this will work
				characterMakeMainCRC(CRC_NICK);
				if (gamePlayData->A4fmaStatus[SCENE4252].playedFlag==FMA_NOTPLAYED)
				{
					gamePlayData->A4fmaStatus[SCENE4252].playedFlag=FMA_PLAYED;
					playedSceneNumber=SCENE4252;
					startFMA("SCENE4252");
					return;
				}
				else 
				{
					gamePlayData->A4fmaStatus[SCENE4253].playedFlag=FMA_PLAYED;
					playedSceneNumber=SCENE4253;
					startFMA("SCENE4253");
					return;
				}
			}
*/		}
		else
		{
			if (gamePlayData->A4fmaStatus[SCENE4200].playedFlag==FMA_NOTPLAYED)
			{
				gamePlayData->A4fmaStatus[SCENE4200].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4200;
				startFMA("SCENE4200");
				inCrc=A4_KITCHEN_SPECIAL_CASE;
				return;
			}
			else
			{
				gamePlayData->A4fmaStatus[SCENE4201].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4201;
				startFMA("SCENE4201");
				inCrc=A4_KITCHEN_SPECIAL_CASE;
				return;
			}
		}
	}
	else // ok you've entered as a rat NOTE I'm hoping currentchicken stays set to who you were
	{
		int	laundryC=0;int twineC=0;int binocularsC=0;	// currently held objects
		int	laundryL=0;int twineL=0;int binocularsL=0;	// not held but done
		int	lTest,tTest,bTest;	// used for tests

		//inCrc=A4_GARDEN_SPECIAL_CASE;
		inventoryRemoveItem(GNOME);	// lets reset the gnome
		scenicInventoryNotification(GNOME,SCENIC_INVENTORY_RESPOT);


		if (gamePlayData->inventory_item_status[LAUNDRY]==INV_STATUS_IN_INVENTORY) laundryC=TRUE;
		if (gamePlayData->inventory_item_status[YARN]==INV_STATUS_IN_INVENTORY) twineC=TRUE;
		if (gamePlayData->inventory_item_status[BINOCULARS]==INV_STATUS_IN_INVENTORY) binocularsC=TRUE;

		if (gamePlayData->inventory_item_status[LAUNDRY]==INV_STATUS_REMOVED) laundryL=TRUE;
		if (gamePlayData->inventory_item_status[YARN]==INV_STATUS_REMOVED) twineL=TRUE;
		if (gamePlayData->inventory_item_status[BINOCULARS]==INV_STATUS_REMOVED) binocularsL=TRUE;

		//if (gamePlayData->inventory_item_status[YARN]==INV_STATUS_REMOVED) laundryL=TRUE;
		//if (gamePlayData->inventory_item_status[BINOCULARS]==INV_STATUS_REMOVED) twineL=TRUE;
		//if (gamePlayData->inventory_item_status[LAUNDRY]==INV_STATUS_REMOVED) binocularsL=TRUE;
		// exellent I got every one of them wrong
		// ok were you ginger or rocky?
		if (currentChicken==CHAR_NAME_GINGER)
		{
			currentChicken=currentCharacter=CHAR_NAME_GINGER;	// dought this will work
			characterMakeMainCRC(CRC_GINGER);
			// and guess what, it did'nt
			if ( laundryC && twineC && binocularsC ) // all objects
			{
				gamePlayData->A4fmaStatus[SCENE4217].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4217;
				startFMA("SCENE4217");
				inCrc=A4_GARDEN_SPECIAL_CASE_G;
				return;
			}
			else if ( laundryC && twineL && binocularsL ) // all objects but some done last time round
			{
				gamePlayData->A4fmaStatus[SCENE4218].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4218;
				startFMA("SCENE4218");	// done it but ginger has a moan
				inCrc=A4_GARDEN_SPECIAL_CASE_G;
				return;
			}
			else if ( laundryL && twineC && binocularsL ) // all objects but some done last time round
			{
				gamePlayData->A4fmaStatus[SCENE4219].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4219;
				startFMA("SCENE4219");	// done it but ginger has a moan
				inCrc=A4_GARDEN_SPECIAL_CASE_G;
				return;
			}
			else if ( laundryL && twineL && binocularsC ) // all objects but some done last time round
			{
				gamePlayData->A4fmaStatus[SCENE4220].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4220;
				startFMA("SCENE4220");	// done it but ginger has a moan
				inCrc=A4_GARDEN_SPECIAL_CASE_G;
				return;
			}
			lTest=laundryL|laundryC;
			tTest=twineL|twineC;
			bTest=binocularsL|binocularsC;
			if ( lTest && tTest && bTest ) // just to stop anything falling throught the net
			{
				gamePlayData->A4fmaStatus[SCENE4217].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4217;
				startFMA("SCENE4217");
				inCrc=A4_GARDEN_SPECIAL_CASE_G;
				return;
			}
			if ( !laundryC && !twineC && !binocularsC )
			{
				gamePlayData->A4fmaStatus[SCENE4210].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4210;
				startFMA("SCENE4210");	// nothing
				inCrc=A4_GARDEN_SPECIAL_CASE_G;
				return;
			}
			else if (!laundryC && !twineC && binocularsC)
			{
				gamePlayData->A4fmaStatus[SCENE4213].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4213;
				startFMA("SCENE4213");
				inCrc=A4_GARDEN_SPECIAL_CASE_G;
				return;
			}
			else if (!laundryC && twineC && !binocularsC)
			{
				gamePlayData->A4fmaStatus[SCENE4212].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4212;
				startFMA("SCENE4212");
				inCrc=A4_GARDEN_SPECIAL_CASE_G;
				return;
			}
			else if (!laundryC && twineC && binocularsC)
			{
				gamePlayData->A4fmaStatus[SCENE4216].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4216;
				startFMA("SCENE4216");
				inCrc=A4_GARDEN_SPECIAL_CASE_G;
				return;
			}
			else if (laundryC && !twineC && !binocularsC)
			{
				gamePlayData->A4fmaStatus[SCENE4211].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4211;
				startFMA("SCENE4211");
				inCrc=A4_GARDEN_SPECIAL_CASE_G;
				return;
			}
			else if (laundryC && !twineC && binocularsC)
			{
				gamePlayData->A4fmaStatus[SCENE4215].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4215;
				startFMA("SCENE4215");
				inCrc=A4_GARDEN_SPECIAL_CASE_G;
				return;
			}
			else if (laundryC && twineC && !binocularsC)
			{
				gamePlayData->A4fmaStatus[SCENE4214].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4214;
				startFMA("SCENE4214");
				inCrc=A4_GARDEN_SPECIAL_CASE_G;
				return;
			}
			// and that should cope with all eventuallitys
		}
		else // rocky
		{
			currentChicken=currentCharacter=CHAR_NAME_ROCKY;	// dought this will work
			characterMakeMainCRC(CRC_ROCKY);
			// and guess what, it did'nt (t'll it was fixed)
			if ( laundryC && twineC && binocularsC ) // all objects
			{
				gamePlayData->A4fmaStatus[SCENE4267].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4267;
				startFMA("SCENE4267");
				inCrc=A4_GARDEN_SPECIAL_CASE_R;
				return;
			}
			else if ( laundryC && twineL && binocularsL ) // all objects but some done last time round
			{
				gamePlayData->A4fmaStatus[SCENE4268].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4268;
				startFMA("SCENE4268");	// done it but ginger has a moan
				inCrc=A4_GARDEN_SPECIAL_CASE_R;
				return;
			}
			else if ( laundryL && twineC && binocularsL ) // all objects but some done last time round
			{
				gamePlayData->A4fmaStatus[SCENE4269].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4269;
				startFMA("SCENE4269");	// done it but ginger has a moan
				inCrc=A4_GARDEN_SPECIAL_CASE_R;
				return;
			}
			else if ( laundryL && twineL && binocularsC ) // all objects but some done last time round
			{
				gamePlayData->A4fmaStatus[SCENE4270].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4270;
				startFMA("SCENE4270");	// done it but ginger sorry rocky has a moan
				inCrc=A4_GARDEN_SPECIAL_CASE_R;
				return;
			}
			lTest=laundryL|laundryC;
			tTest=twineL|twineC;
			bTest=binocularsL|binocularsC;
			if ( lTest && tTest && bTest ) // just to stop anything falling throught the net
			{
				gamePlayData->A4fmaStatus[SCENE4267].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4267;
				startFMA("SCENE4267");
				inCrc=A4_GARDEN_SPECIAL_CASE_R;
				return;
			}
			if ( !laundryC && !twineC && !binocularsC )
			{
				gamePlayData->A4fmaStatus[SCENE4260].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4260;
				startFMA("SCENE4260");	// nothing
				inCrc=A4_GARDEN_SPECIAL_CASE_R;
				return;
			}
			else if (!laundryC && !twineC && binocularsC)
			{
				gamePlayData->A4fmaStatus[SCENE4263].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4263;
				startFMA("SCENE4263");
				inCrc=A4_GARDEN_SPECIAL_CASE_R;
				return;
			}
			else if (!laundryC && twineC && !binocularsC)
			{
				gamePlayData->A4fmaStatus[SCENE4262].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4262;
				startFMA("SCENE4262");
				inCrc=A4_GARDEN_SPECIAL_CASE_R;
				return;
			}
			else if (!laundryC && twineC && binocularsC)
			{
				gamePlayData->A4fmaStatus[SCENE4266].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4266;
				startFMA("SCENE4266");
				inCrc=A4_GARDEN_SPECIAL_CASE_R;
				return;
			}
			else if (laundryC && !twineC && !binocularsC)
			{
				gamePlayData->A4fmaStatus[SCENE4261].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4261;
				startFMA("SCENE4261");
				inCrc=A4_GARDEN_SPECIAL_CASE_R;
				return;
			}
			else if (laundryC && !twineC && binocularsC)
			{
				gamePlayData->A4fmaStatus[SCENE4265].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4265;
				startFMA("SCENE4265");
				inCrc=A4_GARDEN_SPECIAL_CASE_R;
				return;
			}
			else if (laundryC && twineC && !binocularsC)
			{
				gamePlayData->A4fmaStatus[SCENE4264].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4264;
				startFMA("SCENE4264");
				inCrc=A4_GARDEN_SPECIAL_CASE_R;
				return;
			}
			// and that should cope with all eventuallitys
		}
	}
}

/////////////////////////////////////////////////////////////////////////////
void	a4Workhut4FmaChecks(int	xState)
{
	int	test;
	int	count;
	int	whut2Items=0;
	int	whut3Items=0;
	int	whut4Items=0;
	int	selectedItem;

 	playedActNumber=FMA_ACT4;

	// ok lets do our item check
	// engine whut2
	if (gamePlayData->inventory_item_status[ENGINE]==INV_STATUS_IN_INVENTORY) whut2Items++;
	if (gamePlayData->inventory_item_status[CHAIN]==INV_STATUS_IN_INVENTORY) whut2Items++;
	if (gamePlayData->inventory_item_status[OIL_CAN]==INV_STATUS_IN_INVENTORY) whut2Items++;
	// whut3
	if (gamePlayData->inventory_item_status[A4POLES]==INV_STATUS_IN_INVENTORY) whut3Items++;
	if (gamePlayData->inventory_item_status[YARN]==INV_STATUS_IN_INVENTORY) whut3Items++;
	if (gamePlayData->inventory_item_status[LAUNDRY]==INV_STATUS_IN_INVENTORY) whut3Items++;
	// wings whut4
	if (gamePlayData->inventory_item_status[COGS]==INV_STATUS_IN_INVENTORY) whut4Items++;
	if (gamePlayData->inventory_item_status[TOOLS]==INV_STATUS_IN_INVENTORY) whut4Items++;
	if (gamePlayData->inventory_item_status[WOOD]==INV_STATUS_IN_INVENTORY) whut4Items++;
	if (gamePlayData->inventory_item_status[BINOCULARS]==INV_STATUS_IN_INVENTORY) whut4Items++;


	if (currentChicken == CHAR_NAME_GINGER)
	{
		if (gamePlayData->A4fmaStatus[SCENE4085].playedFlag==FMA_PLAYED)
		{
			gamePlayData->A4fmaStatus[SCENE4086].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE4086;
			//overlayDebugMessage("TBD - to the sub game", 25 * 3);
			startFMA("SCENE4086");
			return;
		}
		if (whut4Items)
		{
			count=0;
			if (gamePlayData->inventory_item_status[COGS]!=INV_STATUS_NOTCOLLECTED)
			{
				count++;
				if (gamePlayData->inventory_item_status[COGS]==INV_STATUS_IN_INVENTORY)
					inventoryRemoveItem(COGS);
			}
			if (gamePlayData->inventory_item_status[TOOLS]!=INV_STATUS_NOTCOLLECTED)
			{
				count++;
				if (gamePlayData->inventory_item_status[TOOLS]==INV_STATUS_IN_INVENTORY)
					inventoryRemoveItem(TOOLS);
			}
			if (gamePlayData->inventory_item_status[WOOD]!=INV_STATUS_NOTCOLLECTED)
			{
				count++;
				if (gamePlayData->inventory_item_status[WOOD]==INV_STATUS_IN_INVENTORY)
					inventoryRemoveItem(WOOD);
			}
			if (gamePlayData->inventory_item_status[BINOCULARS]!=INV_STATUS_NOTCOLLECTED)
			{
				count++;
				if (gamePlayData->inventory_item_status[BINOCULARS]==INV_STATUS_IN_INVENTORY)
					inventoryRemoveItem(BINOCULARS);
			}
			if (count==1)
			{
				gamePlayData->A4fmaStatus[SCENE4082].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4082;
				startFMA("SCENE4082");
				return;
			}
			if (count==2)
			{
				gamePlayData->A4fmaStatus[SCENE4083].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4083;
				startFMA("SCENE4083");
				return;
			}
			if (count==3)
			{
				gamePlayData->A4fmaStatus[SCENE4084].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4084;
				startFMA("SCENE4084");
				return;
			}
			if (count==4)
			{
				gamePlayData->A4fmaStatus[SCENE4085].playedFlag=FMA_PLAYED;
				gamePlayData->A4fmaStatus[SCENE4092].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4085;
				//overlayDebugMessage("TBD - to the sub game", 25 * 3);
				startFMA("SCENE4085");
				return;
			}
		}
		else if ( (whut2Items||whut3Items) && xState )
		{
			gamePlayData->A4fmaStatus[SCENE4080].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE4080;
			startFMA("SCENE4080");
			return;
		}
		else if (xState)
		{
			gamePlayData->A4fmaStatus[SCENE4081].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE4081;
			startFMA("SCENE4081");
			return;
		}
	}
/*	else if (currentChicken == CHAR_NAME_ROCKY)
	{
		if (gamePlayData->A4fmaStatus[SCENE4092].playedFlag==FMA_PLAYED)
		{
			gamePlayData->A4fmaStatus[SCENE4093].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE4093;
			//overlayDebugMessage("TBD - to the sub game", 25 * 3);
			startFMA("SCENE4093");
			return;
		}
		if (whut4Items)
		{
			count=0;
			if (gamePlayData->inventory_item_status[COGS]!=INV_STATUS_NOTCOLLECTED)
			{
				count++;
				if (gamePlayData->inventory_item_status[COGS]==INV_STATUS_IN_INVENTORY)
					inventoryRemoveItem(COGS);
			}
			if (gamePlayData->inventory_item_status[TOOLS]!=INV_STATUS_NOTCOLLECTED)
			{
				count++;
				if (gamePlayData->inventory_item_status[TOOLS]==INV_STATUS_IN_INVENTORY)
					inventoryRemoveItem(TOOLS);
			}
			if (gamePlayData->inventory_item_status[WOOD]!=INV_STATUS_NOTCOLLECTED)
			{
				count++;
				if (gamePlayData->inventory_item_status[WOOD]==INV_STATUS_IN_INVENTORY)
					inventoryRemoveItem(WOOD);
			}
			if (gamePlayData->inventory_item_status[BINOCULARS]!=INV_STATUS_NOTCOLLECTED)
			{
				count++;
				if (gamePlayData->inventory_item_status[BINOCULARS]==INV_STATUS_IN_INVENTORY)
					inventoryRemoveItem(BINOCULARS);
			}
			if (count==1)
			{
				gamePlayData->A4fmaStatus[SCENE4089].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4089;
				startFMA("SCENE4089");
				return;
			}
			if (count==2)
			{
				gamePlayData->A4fmaStatus[SCENE4090].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4090;
				startFMA("SCENE4090");
				return;
			}
			if (count==3)
			{
				gamePlayData->A4fmaStatus[SCENE4091].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4091;
				startFMA("SCENE4091");
				return;
			}
			if (count==4)
			{
				gamePlayData->A4fmaStatus[SCENE4085].playedFlag=FMA_PLAYED;
				gamePlayData->A4fmaStatus[SCENE4092].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4092;
				//overlayDebugMessage("TBD - to the sub game", 25 * 3);
				startFMA("SCENE4092");
				return;
			}
		}
		else if (whut2Items||whut3Items)
		{
			gamePlayData->A4fmaStatus[SCENE4087].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE4087;
			startFMA("SCENE4087");
			return;
		}
		else
		{
			gamePlayData->A4fmaStatus[SCENE4088].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE4088;
			startFMA("SCENE4088");
			return;
		}
	}
	*/
}

/////////////////////////////////////////////////////////////////////////////
void	a4Workhut3FmaChecks(int	xState)
{
	int	test;
	int	count;
	int	whut2Items=0;
	int	whut3Items=0;
	int	whut4Items=0;
	int	selectedItem;

 	playedActNumber=FMA_ACT4;

	// ok lets do our item check
	// engine whut2
	if (gamePlayData->inventory_item_status[ENGINE]==INV_STATUS_IN_INVENTORY) whut2Items++;
	if (gamePlayData->inventory_item_status[CHAIN]==INV_STATUS_IN_INVENTORY) whut2Items++;
	if (gamePlayData->inventory_item_status[OIL_CAN]==INV_STATUS_IN_INVENTORY) whut2Items++;
	// whut3
	// in a word BUGGER
	if (gamePlayData->inventory_item_status[A4POLES]==INV_STATUS_IN_INVENTORY) whut3Items++;
	if (gamePlayData->inventory_item_status[YARN]==INV_STATUS_IN_INVENTORY) whut3Items++;
	if (gamePlayData->inventory_item_status[LAUNDRY]==INV_STATUS_IN_INVENTORY) whut3Items++;

	// wings whut4
	if (gamePlayData->inventory_item_status[COGS]==INV_STATUS_IN_INVENTORY) whut4Items++;
	if (gamePlayData->inventory_item_status[TOOLS]==INV_STATUS_IN_INVENTORY) whut4Items++;
	if (gamePlayData->inventory_item_status[WOOD]==INV_STATUS_IN_INVENTORY) whut4Items++;
	if (gamePlayData->inventory_item_status[BINOCULARS]==INV_STATUS_IN_INVENTORY) whut4Items++;

	if (currentChicken == CHAR_NAME_GINGER)
	{
		if (gamePlayData->A4fmaStatus[SCENE4064].playedFlag==FMA_PLAYED)
		{
			if (gamePlayData->A4fmaStatus[SCENE4065].playedFlag==FMA_NOTPLAYED || xState)
			{
				gamePlayData->A4fmaStatus[SCENE4065].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4065;
				//overlayDebugMessage("TBD - to the sub game", 25 * 3);
				startFMA("SCENE4065");
			}
			return;
		}
		if (whut3Items)
		{
			count=0;
			if (gamePlayData->inventory_item_status[A4POLES]!=INV_STATUS_NOTCOLLECTED)
			{
				count++;
				if (gamePlayData->inventory_item_status[A4POLES]==INV_STATUS_IN_INVENTORY)
					inventoryRemoveItem(A4POLES);
			}
			if (gamePlayData->inventory_item_status[YARN]!=INV_STATUS_NOTCOLLECTED)
			{
				count++;
				if (gamePlayData->inventory_item_status[YARN]==INV_STATUS_IN_INVENTORY)
					inventoryRemoveItem(YARN);
			}
			if (gamePlayData->inventory_item_status[LAUNDRY]!=INV_STATUS_NOTCOLLECTED)
			{
				count++;
				if (gamePlayData->inventory_item_status[LAUNDRY]==INV_STATUS_IN_INVENTORY)
					inventoryRemoveItem(LAUNDRY);
			}
/*			if (gamePlayData->inventory_item_status[BINOCULARS]!=INV_STATUS_NOTCOLLECTED)
			{
				count++;
				if (gamePlayData->inventory_item_status[BINOCULARS]==INV_STATUS_IN_INVENTORY)
					inventoryRemoveItem(BINOCULARS);
			}
*/			if (count==1)
			{
				gamePlayData->A4fmaStatus[SCENE4062].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4062;
				startFMA("SCENE4062");
				return;
			}
			else if (count==2)
			{
				gamePlayData->A4fmaStatus[SCENE4063].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4063;
				startFMA("SCENE4063");
				return;
			}
			else if (count==3)
			{
				gamePlayData->A4fmaStatus[SCENE4064].playedFlag=FMA_PLAYED;
				gamePlayData->A4fmaStatus[SCENE4070].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4064;
				startFMA("SCENE4064");
				return;
			}
		}
		else if ( (whut2Items || whut4Items) && xState)
		{
			gamePlayData->A4fmaStatus[SCENE4060].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE4060;
			startFMA("SCENE4060");
			return;
		}
		else if (xState)
		{
			gamePlayData->A4fmaStatus[SCENE4061].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE4061;
			startFMA("SCENE4061");
			return;
		}
	}
/*	if (currentChicken == CHAR_NAME_ROCKY)
	{
		if (gamePlayData->A4fmaStatus[SCENE4070].playedFlag==FMA_PLAYED)
		{
			gamePlayData->A4fmaStatus[SCENE4071].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE4071;
			//overlayDebugMessage("TBD - to the sub game", 25 * 3);
			startFMA("SCENE4071");
			return;
		}
		if (whut3Items)
		{
			count=0;
			count=0;
			if (gamePlayData->inventory_item_status[A4POLES]!=INV_STATUS_NOTCOLLECTED)
			{
				count++;
				if (gamePlayData->inventory_item_status[A4POLES]==INV_STATUS_IN_INVENTORY)
					inventoryRemoveItem(A4POLES);
			}
			if (gamePlayData->inventory_item_status[YARN]!=INV_STATUS_NOTCOLLECTED)
			{
				count++;
				if (gamePlayData->inventory_item_status[YARN]==INV_STATUS_IN_INVENTORY)
					inventoryRemoveItem(YARN);
			}
			if (gamePlayData->inventory_item_status[LAUNDRY]!=INV_STATUS_NOTCOLLECTED)
			{
				count++;
				if (gamePlayData->inventory_item_status[LAUNDRY]==INV_STATUS_IN_INVENTORY)
					inventoryRemoveItem(LAUNDRY);
			}
			if (count==1)
			{
				gamePlayData->A4fmaStatus[SCENE4068].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4068;
				startFMA("SCENE4068");
				return;
			}
			else if (count==2)
			{
				gamePlayData->A4fmaStatus[SCENE4069].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4069;
				startFMA("SCENE4069");
				return;
			}
			else if (count==3)
			{
				gamePlayData->A4fmaStatus[SCENE4064].playedFlag=FMA_PLAYED;
				gamePlayData->A4fmaStatus[SCENE4070].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4070;
				startFMA("SCENE4070");
				return;
			}
		}
		else if (whut2Items || whut4Items)
		{
			gamePlayData->A4fmaStatus[SCENE4066].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE4066;
			startFMA("SCENE4066");
			return;
		}
		else
		{
			gamePlayData->A4fmaStatus[SCENE4067].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE4067;
			startFMA("SCENE4067");
			return;
		}
	}
	*/
}
 

/////////////////////////////////////////////////////////////////////////////
void	a4Workhut2FmaChecks(int	xState)
{
	int	test;
	int	count;
	int	whut2Items=0;
	int	whut3Items=0;
	int	whut4Items=0;
	int	selectedItem;

 	playedActNumber=FMA_ACT4;
	// ok lets do our item check
	// engine whut2
	if (gamePlayData->inventory_item_status[ENGINE]==INV_STATUS_IN_INVENTORY) whut2Items++;
	if (gamePlayData->inventory_item_status[CHAIN]==INV_STATUS_IN_INVENTORY) whut2Items++;
	if (gamePlayData->inventory_item_status[OIL_CAN]==INV_STATUS_IN_INVENTORY) whut2Items++;
	// whut3
	if (gamePlayData->inventory_item_status[COGS]==INV_STATUS_IN_INVENTORY) whut3Items++;
	if (gamePlayData->inventory_item_status[TOOLS]==INV_STATUS_IN_INVENTORY) whut3Items++;
	if (gamePlayData->inventory_item_status[WOOD]==INV_STATUS_IN_INVENTORY) whut3Items++;
	if (gamePlayData->inventory_item_status[BINOCULARS]==INV_STATUS_IN_INVENTORY) whut3Items++;
	// wings whut4
	if (gamePlayData->inventory_item_status[A4POLES]==INV_STATUS_IN_INVENTORY) whut4Items++;
	if (gamePlayData->inventory_item_status[YARN]==INV_STATUS_IN_INVENTORY) whut4Items++;
	if (gamePlayData->inventory_item_status[LAUNDRY]==INV_STATUS_IN_INVENTORY) whut4Items++;


	//INV_STATUS_NOTCOLLECTED
	// tbd this will probably need the xstate checks and just played checks putting in

	if (currentChicken == CHAR_NAME_GINGER)
	{
		if (gamePlayData->A4fmaStatus[SCENE4045].playedFlag==FMA_PLAYED)
		{
			if (gamePlayData->A4fmaStatus[SCENE4046].playedFlag==FMA_NOTPLAYED || xState)
			{
				gamePlayData->A4fmaStatus[SCENE4046].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4046;
				//overlayDebugMessage("TBD - to the sub game", 25 * 3);
				startFMA("SCENE4046");
			}
			return;
		}
		if (whut2Items) // any items for this workhut ?
		{
			// this ones going to be a bit tricky
			int	chain=0,oil=0,engine=0;
			if (gamePlayData->inventory_item_status[ENGINE]!=INV_STATUS_NOTCOLLECTED)
			{
				engine=TRUE;
				if (gamePlayData->inventory_item_status[ENGINE]==INV_STATUS_IN_INVENTORY)
					inventoryRemoveItem(ENGINE);
			}
			if (gamePlayData->inventory_item_status[CHAIN]!=INV_STATUS_NOTCOLLECTED)
			{
				chain=TRUE;
				if (gamePlayData->inventory_item_status[CHAIN]==INV_STATUS_IN_INVENTORY)
					inventoryRemoveItem(CHAIN);
			}
			if (gamePlayData->inventory_item_status[OIL_CAN]!=INV_STATUS_NOTCOLLECTED)
			{
				oil=TRUE;
				if (gamePlayData->inventory_item_status[OIL_CAN]==INV_STATUS_IN_INVENTORY)
					inventoryRemoveItem(OIL_CAN);
			}
			if ( (oil || chain)  && !engine)
			{
				gamePlayData->A4fmaStatus[SCENE4042].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4042;
				startFMA("SCENE4042");
				return;
			}
			if (engine && chain && !oil)
			{
				gamePlayData->A4fmaStatus[SCENE4043].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4043;
				startFMA("SCENE4043");
				return;
			}
			if (engine && oil && !chain)
			{
				gamePlayData->A4fmaStatus[SCENE4044].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4044;
				startFMA("SCENE4044");
				return;
			}
			if (engine && !oil && !chain)
			{
				gamePlayData->A4fmaStatus[SCENE4041].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4041;
				startFMA("SCENE4041");
				return;
			}
			if ( engine && oil && chain )
			{
				gamePlayData->A4fmaStatus[SCENE4045].playedFlag=FMA_PLAYED;
				gamePlayData->A4fmaStatus[SCENE4052].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4045;
				//overlayDebugMessage("TBD - to the sub game", 25 * 3);
				startFMA("SCENE4045");
				return;
			}
		}
		else if ( (whut3Items || whut4Items) && xState )
		{
			gamePlayData->A4fmaStatus[SCENE4040].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE4040;
			startFMA("SCENE4040");
			return;
		}
		else if (!whut2Items && !whut3Items && !whut4Items)
		{
			if (gamePlayData->A4fmaStatus[SCENE4041].playedFlag!=FMA_PLAYED || xState)
			{
				gamePlayData->A4fmaStatus[SCENE4041].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4041;
				startFMA("SCENE4041");
			}
			return;
		}
	}
/*	else if (currentChicken == CHAR_NAME_ROCKY)
	{
		if (whut2Items) // any items for this workhut ?
		{
			int	chain=0,oil=0,engine=0;
			if (gamePlayData->inventory_item_status[ENGINE]!=INV_STATUS_NOTCOLLECTED)
			{
				engine=TRUE;
				if (gamePlayData->inventory_item_status[ENGINE]==INV_STATUS_IN_INVENTORY)
					inventoryRemoveItem(ENGINE);
			}
			if (gamePlayData->inventory_item_status[CHAIN]!=INV_STATUS_NOTCOLLECTED)
			{
				chain=TRUE;
				if (gamePlayData->inventory_item_status[CHAIN]==INV_STATUS_IN_INVENTORY)
					inventoryRemoveItem(CHAIN);
			}
			if (gamePlayData->inventory_item_status[CHAIN]!=INV_STATUS_NOTCOLLECTED)
			{
				oil=TRUE;
				if (gamePlayData->inventory_item_status[OIL_CAN]==INV_STATUS_IN_INVENTORY)
					inventoryRemoveItem(OIL_CAN);
			}
			if (oil && chain && !engine)
			{
				gamePlayData->A4fmaStatus[SCENE4049].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4049;
				startFMA("SCENE4049");
				return;
			}
			if (engine && chain && !oil)
			{
				gamePlayData->A4fmaStatus[SCENE4050].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4050;
				startFMA("SCENE4050");
				return;
			}
			if (engine && oil && !chain)
			{
				gamePlayData->A4fmaStatus[SCENE4051].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4051;
				startFMA("SCENE4051");
				return;
			}
			if (engine && !oil && !chain)
			{
				gamePlayData->A4fmaStatus[SCENE4048].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4048;
				startFMA("SCENE4048");
				return;
			}
			if (engine && oil && chain)
			{
				gamePlayData->A4fmaStatus[SCENE4045].playedFlag=FMA_PLAYED;
				gamePlayData->A4fmaStatus[SCENE4052].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4052;
				//overlayDebugMessage("TBD - to the sub game", 25 * 3);
				startFMA("SCENE4052");
				return;
			}
		}
		else if (whut3Items || whut4Items)
		{
			gamePlayData->A4fmaStatus[SCENE4047].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE4047;
			startFMA("SCENE4047");
			return;
		}
		else if (!whut2Items && !whut3Items && !whut4Items)
		{
			gamePlayData->A4fmaStatus[SCENE4041].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE4041;
			startFMA("SCENE4041");
			return;
		}
	}
	*/
}
	

/////////////////////////////////////////////////////////////////////////////
void	a4Workhut1FmaChecks(int	xState)
{
	int	test;
	int	count;
	int	whut2Items=0;
	int	whut3Items=0;
	int	whut4Items=0;
	int	selectedItem;

 	playedActNumber=FMA_ACT4;
	// ok lets do our item check
	// engine whut2
	if (gamePlayData->inventory_item_status[ENGINE]==INV_STATUS_IN_INVENTORY) whut2Items++;
	if (gamePlayData->inventory_item_status[CHAIN]==INV_STATUS_IN_INVENTORY) whut2Items++;
	if (gamePlayData->inventory_item_status[OIL_CAN]==INV_STATUS_IN_INVENTORY) whut2Items++;
	// whut3
	if (gamePlayData->inventory_item_status[COGS]==INV_STATUS_IN_INVENTORY) whut3Items++;
	if (gamePlayData->inventory_item_status[TOOLS]==INV_STATUS_IN_INVENTORY) whut3Items++;
	if (gamePlayData->inventory_item_status[WOOD]==INV_STATUS_IN_INVENTORY) whut3Items++;
	if (gamePlayData->inventory_item_status[BINOCULARS]==INV_STATUS_IN_INVENTORY) whut3Items++;
	// wings whut4
	if (gamePlayData->inventory_item_status[A4POLES]==INV_STATUS_IN_INVENTORY) whut4Items++;
	if (gamePlayData->inventory_item_status[YARN]==INV_STATUS_IN_INVENTORY) whut4Items++;
	if (gamePlayData->inventory_item_status[LAUNDRY]==INV_STATUS_IN_INVENTORY) whut4Items++;

	if (currentChicken == CHAR_NAME_GINGER)
	{
		if (whut2Items||whut3Items||whut4Items)
		{
			if (gamePlayData->A4fmaStatus[SCENE4019].playedFlag==FMA_NOTPLAYED || xState)
			{
				gamePlayData->A4fmaStatus[SCENE4019].playedFlag=FMA_PLAYED;	// This should have allready been done
				playedSceneNumber=SCENE4019;
				startFMA("SCENE4019");	// tell em what to do
				return;
			}
		}
		else
		{
			if (gamePlayData->A4fmaStatus[SCENE4020].playedFlag==FMA_NOTPLAYED || xState)
			{
				gamePlayData->A4fmaStatus[SCENE4020].playedFlag=FMA_PLAYED;	// This should have allready been done
				playedSceneNumber=SCENE4020;
				startFMA("SCENE4020");	// tell em what to do
				return;
			}
		}
	}
/*	else if (currentChicken == CHAR_NAME_ROCKY)
	{
		if (whut2Items||whut3Items||whut4Items)
		{
			if (gamePlayData->A4fmaStatus[SCENE4021].playedFlag==FMA_NOTPLAYED || xState)
			{
				gamePlayData->A4fmaStatus[SCENE4021].playedFlag=FMA_PLAYED;	// This should have allready been done
				playedSceneNumber=SCENE4021;
				startFMA("SCENE4021");	// tell em what to do
				return;
			}
		}
		else
		{
			if (gamePlayData->A4fmaStatus[SCENE4022].playedFlag==FMA_NOTPLAYED || xState)
			{
				gamePlayData->A4fmaStatus[SCENE4022].playedFlag=FMA_PLAYED;	// This should have allready been done
				playedSceneNumber=SCENE4022;
				startFMA("SCENE4022");	// tell em what to do
				return;
			}
		}
	}// that was easy
	*/
}


/////////////////////////////////////////////////////////////////////////////
void	a4Hut17FmaChecks(int	xState)
{
	int	test;
	int	count;
	int	whut2Items=0;
	int	whut3Items=0;
	int	whut4Items=0;
	int	selectedItem;

	playedActNumber=FMA_ACT4;
	// ok lets see what your carriing
	// engine whut2
	if (gamePlayData->inventory_item_status[ENGINE]==INV_STATUS_IN_INVENTORY) whut2Items++;
	if (gamePlayData->inventory_item_status[CHAIN]==INV_STATUS_IN_INVENTORY) whut2Items++;
	if (gamePlayData->inventory_item_status[OIL_CAN]==INV_STATUS_IN_INVENTORY) whut2Items++;
	// whut3
	if (gamePlayData->inventory_item_status[COGS]==INV_STATUS_IN_INVENTORY) whut3Items++;
	if (gamePlayData->inventory_item_status[TOOLS]==INV_STATUS_IN_INVENTORY) whut3Items++;
	if (gamePlayData->inventory_item_status[WOOD]==INV_STATUS_IN_INVENTORY) whut3Items++;
	if (gamePlayData->inventory_item_status[BINOCULARS]==INV_STATUS_IN_INVENTORY) whut3Items++;
	// wings whut4
	if (gamePlayData->inventory_item_status[A4POLES]==INV_STATUS_IN_INVENTORY) whut4Items++;
	if (gamePlayData->inventory_item_status[YARN]==INV_STATUS_IN_INVENTORY) whut4Items++;
	if (gamePlayData->inventory_item_status[LAUNDRY]==INV_STATUS_IN_INVENTORY) whut4Items++;

	if (currentChicken == CHAR_NAME_GINGER)
	{
		if (gamePlayData->A4fmaStatus[SCENE4001].playedFlag==FMA_NOTPLAYED)	// if first time play auto briefing
		{
			gamePlayData->A4fmaStatus[SCENE4001].playedFlag=FMA_PLAYED;	// This should have allready been done
			playedSceneNumber=SCENE4001;
			SpecialCaseFma=ACT4FMA1;
			startFMA("SCENE4001");	// tell em what to do
			return;
		}
		// ok now if chicken holding anything then lets deal that first
		if (currentInv->selected_item)
		{
			switch (currentInv->selected_item)
			{
				case ENGINE:	// bits for engine parts
				case CHAIN:
				case OIL_CAN:
					if (gamePlayData->A4fmaStatus[SCENE4003].playedFlag==FMA_NOTPLAYED || xState)
					{
						if (gamePlayData->A4fmaStatus[SCENE4003].playedTime<(loop_ticker2-90) ) // stop the anoying pressing x which restarts the fma
						{
							gamePlayData->A4fmaStatus[SCENE4003].playedFlag=FMA_PLAYED;
							playedSceneNumber=SCENE4003;
							startFMA("SCENE4003");	// tell em what to do
						}
					}
					break;

				case COGS:
				case TOOLS:
				case WOOD:
				case BINOCULARS:	// constructions bits
					if (gamePlayData->A4fmaStatus[SCENE4004].playedFlag==FMA_NOTPLAYED || xState)
					{
						if (gamePlayData->A4fmaStatus[SCENE4004].playedTime<(loop_ticker2-90) ) // stop the anoying pressing x which restarts the fma
						{
							gamePlayData->A4fmaStatus[SCENE4004].playedFlag=FMA_PLAYED;
							playedSceneNumber=SCENE4004;
							startFMA("SCENE4004");	// tell em what to do
						}
					}
					break;

				case A4POLES:	// wingmaking bits
				case YARN:
				case LAUNDRY:
					if (gamePlayData->A4fmaStatus[SCENE4005].playedFlag==FMA_NOTPLAYED || xState)
					{
						if (gamePlayData->A4fmaStatus[SCENE4005].playedTime<(loop_ticker2-90) ) // stop the anoying pressing x which restarts the fma
						{
							gamePlayData->A4fmaStatus[SCENE4005].playedFlag=FMA_PLAYED;
							playedSceneNumber=SCENE4005;
							startFMA("SCENE4005");	// tell em what to do
						}
					}
					break;
			}
			return;
		}
		else if (whut2Items||whut3Items||whut4Items) // ok nothing in hand anything in inventory?
		{
			if (whut2Items)
			{
				if (gamePlayData->A4fmaStatus[SCENE4003].playedFlag==FMA_NOTPLAYED || xState)
				{
					if (gamePlayData->A4fmaStatus[SCENE4003].playedTime<(loop_ticker2-90) ) // stop the anoying pressing x which restarts the fma
					{
						gamePlayData->A4fmaStatus[SCENE4003].playedFlag=FMA_PLAYED;
						playedSceneNumber=SCENE4003;
						startFMA("SCENE4003");	// tell em what to do
					}
				}
			}
			else if (whut3Items)
			{
				if (gamePlayData->A4fmaStatus[SCENE4004].playedFlag==FMA_NOTPLAYED || xState)
				{
					if (gamePlayData->A4fmaStatus[SCENE4004].playedTime<(loop_ticker2-90) ) // stop the anoying pressing x which restarts the fma
					{
						gamePlayData->A4fmaStatus[SCENE4004].playedFlag=FMA_PLAYED;
						playedSceneNumber=SCENE4004;
						startFMA("SCENE4004");	// tell em what to do
					}
				}
			}
			else if (whut4Items)
			{
				if (gamePlayData->A4fmaStatus[SCENE4005].playedFlag==FMA_NOTPLAYED || xState)
				{
					if (gamePlayData->A4fmaStatus[SCENE4005].playedTime<(loop_ticker2-90) ) // stop the anoying pressing x which restarts the fma
					{
						gamePlayData->A4fmaStatus[SCENE4005].playedFlag=FMA_PLAYED;
						playedSceneNumber=SCENE4005;
						startFMA("SCENE4005");	// tell em what to do
					}
				}
			}
		}
		else if (xState)
		{
			if (gamePlayData->A4fmaStatus[SCENE4009].playedTime<(loop_ticker2-90) ) // stop the anoying pressing x which restarts the fma
			{
				gamePlayData->A4fmaStatus[SCENE4009].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4009;
				SpecialCaseFma=ACT4FMA2;
				startFMA("SCENE4009");	// tell em what to do
			}
		}
	}
/*	else if (currentChicken == CHAR_NAME_ROCKY)	// ok thats ginger taken care off if its not rocky then whats going on
	{
		if (currentInv->selected_item)
		{
			switch (currentInv->selected_item)
			{
				case ENGINE:	// bits for engine parts
				case CHAIN:
				case OIL_CAN:
					if (gamePlayData->A4fmaStatus[SCENE4006].playedFlag==FMA_NOTPLAYED || xState)
					{
						if (gamePlayData->A4fmaStatus[SCENE4006].playedTime<(loop_ticker2-90) ) // stop the anoying pressing x which restarts the fma
						{
							gamePlayData->A4fmaStatus[SCENE4006].playedFlag=FMA_PLAYED;
							playedSceneNumber=SCENE4006;
							startFMA("SCENE4006");	// tell em what to do
						}
					}
					break;

				case COGS:
				case TOOLS:
				case WOOD:
				case BINOCULARS:	// constructions bits
					if (gamePlayData->A4fmaStatus[SCENE4007].playedFlag==FMA_NOTPLAYED || xState)
					{
						if (gamePlayData->A4fmaStatus[SCENE4007].playedTime<(loop_ticker2-90) ) // stop the anoying pressing x which restarts the fma
						{
							gamePlayData->A4fmaStatus[SCENE4007].playedFlag=FMA_PLAYED;
							playedSceneNumber=SCENE4007;
							startFMA("SCENE4007");	// tell em what to do
						}
					}
					break;

				case A4POLES:	// wingmaking bits
				case YARN:
				case LAUNDRY:
					if (gamePlayData->A4fmaStatus[SCENE4008].playedFlag==FMA_NOTPLAYED || xState)
					{
						if (gamePlayData->A4fmaStatus[SCENE4008].playedTime<(loop_ticker2-90) ) // stop the anoying pressing x which restarts the fma
						{
							gamePlayData->A4fmaStatus[SCENE4008].playedFlag=FMA_PLAYED;
							playedSceneNumber=SCENE4008;
							startFMA("SCENE4008");	// tell em what to do
						}
					}
					break;
			}
			return;
		}
		else if (whut2Items||whut3Items||whut4Items) // ok nothing in hand anything in inventory?
		{
			if (whut2Items)
			{
				if (gamePlayData->A4fmaStatus[SCENE4006].playedFlag==FMA_NOTPLAYED || xState)
				{
					if (gamePlayData->A4fmaStatus[SCENE4006].playedTime<(loop_ticker2-90) ) // stop the anoying pressing x which restarts the fma
					{
						gamePlayData->A4fmaStatus[SCENE4006].playedFlag=FMA_PLAYED;
						playedSceneNumber=SCENE4006;
						startFMA("SCENE4006");	// tell em what to do
					}
				}
			}
			else if (whut3Items)
			{
				if (gamePlayData->A4fmaStatus[SCENE4007].playedFlag==FMA_NOTPLAYED || xState)
				{
					if (gamePlayData->A4fmaStatus[SCENE4007].playedTime<(loop_ticker2-90) ) // stop the anoying pressing x which restarts the fma
					{
						gamePlayData->A4fmaStatus[SCENE4007].playedFlag=FMA_PLAYED;
						playedSceneNumber=SCENE4007;
						startFMA("SCENE4007");	// tell em what to do
					}
				}
			}
			else if (whut4Items)
			{
				if (gamePlayData->A4fmaStatus[SCENE4008].playedFlag==FMA_NOTPLAYED || xState)
				{
					if (gamePlayData->A4fmaStatus[SCENE4008].playedTime<(loop_ticker2-90) ) // stop the anoying pressing x which restarts the fma
					{
						gamePlayData->A4fmaStatus[SCENE4008].playedFlag=FMA_PLAYED;
						playedSceneNumber=SCENE4008;
						startFMA("SCENE4008");	// tell em what to do
					}
				}
			}
		}
		else if (xState)
		{
			if (gamePlayData->A4fmaStatus[SCENE4002].playedTime<(loop_ticker2-90) ) // stop the anoying pressing x which restarts the fma
			{
				gamePlayData->A4fmaStatus[SCENE4002].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE4002;
				startFMA("SCENE4002");	// tell em what to do
			}
		}
	}
	*/
}



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

void	a2Workhut3FmaChecks(int	xState)
{
	int	test=FALSE;
	int	count;
	int	items;
	int	subgame1,subgame2,subgame3;

	subgame1=0;
	subgame2=0;
	subgame3=0;

	playedActNumber=FMA_ACT2;
	// ok what are we holding?
	if (gamePlayData->inventory_item_status[MATCHES]==INV_STATUS_IN_INVENTORY) subgame1++;
	if (gamePlayData->inventory_item_status[FIREWORKS]==INV_STATUS_IN_INVENTORY) subgame1++;
	// seesaw
	if (gamePlayData->inventory_item_status[COOKING_WEIGHTS]==INV_STATUS_IN_INVENTORY) subgame3++;
	// catapult
	if (gamePlayData->inventory_item_status[STRONG_CORD]==INV_STATUS_IN_INVENTORY) subgame2++;
	if (gamePlayData->inventory_item_status[BROKEN_LADDER]==INV_STATUS_IN_INVENTORY) subgame2++;
	if (gamePlayData->inventory_item_status[PRAM_CHASSIS]==INV_STATUS_IN_INVENTORY) subgame2++;
	if (gamePlayData->inventory_item_status[TENNIS_RACKET]==INV_STATUS_IN_INVENTORY) subgame2++;

	if (currentChicken == CHAR_NAME_GINGER)
	{
		// first have we comleted yet
		if (gamePlayData->A2fmaStatus[SCENE2074].playedFlag==FMA_PLAYED)
		{
			if (xState)
			{
				gamePlayData->A2fmaStatus[SCENE2075].playedFlag=FMA_PLAYED;
				gamePlayData->A2fmaStatus[SCENE2079].playedFlag=FMA_PLAYED;	// set for rocky and ginger
				playedSceneNumber=SCENE2075;
				startFMA("SCENE2075");	// well done try again
				// tbd put the subgame here
				//overlayDebugMessage("TBD - To the Seesaw sub game ", 25 * 3);
				return;
			}
			else if ( subgame1 || subgame2 )
			{
				if ( (gamePlayData->A2fmaStatus[SCENE2071].playedFlag==FMA_NOTPLAYED) || xState)
				{
					gamePlayData->A2fmaStatus[SCENE2071].playedFlag=FMA_PLAYED;
					playedSceneNumber=SCENE2071;
					startFMA("SCENE2071");	// wrong hut
				}
				//return;
			}
			return;
		}
		else if (subgame3)
		{
			if (gamePlayData->inventory_item_status[COOKING_WEIGHTS]!=INV_STATUS_NOTCOLLECTED)
			{
				test=FALSE;
				if (gamePlayData->inventory_item_status[COOKING_WEIGHTS]==INV_STATUS_IN_INVENTORY)
				{
					inventoryRemoveItem(COOKING_WEIGHTS);
					test=TRUE;
				}
			}
			if (test)
			{
				gamePlayData->A2fmaStatus[SCENE2074].playedFlag=FMA_PLAYED;
				gamePlayData->A2fmaStatus[SCENE2078].playedFlag=FMA_PLAYED;	// set for rocky and ginger
				playedSceneNumber=SCENE2074;
				startFMA("SCENE2074");	// well done try again
				// tbd put the subgame here
				//overlayDebugMessage("TBD - To the Seesaw sub game ", 25 * 3);
			}
			return;
		}
		else if (subgame1 || subgame2)
		{
			if ( (gamePlayData->A2fmaStatus[SCENE2071].playedFlag==FMA_NOTPLAYED) || xState)
			{
				gamePlayData->A2fmaStatus[SCENE2071].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE2071;
				startFMA("SCENE2071");	// wrong hut
			}
			return;
		}
		else	// no objects 
		{
			if ( (gamePlayData->A2fmaStatus[SCENE2070].playedFlag==FMA_NOTPLAYED) || xState)
			{
				gamePlayData->A2fmaStatus[SCENE2070].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE2070;
				startFMA("SCENE2070");	// wrong hut
			}
			return;
		}
	}
/*	else if (currentChicken == CHAR_NAME_ROCKY)
	{
		if (gamePlayData->A2fmaStatus[SCENE2078].playedFlag==FMA_PLAYED)
		{
			if (xState)
			{
				gamePlayData->A2fmaStatus[SCENE2075].playedFlag=FMA_PLAYED;
				gamePlayData->A2fmaStatus[SCENE2079].playedFlag=FMA_PLAYED;	// set for rocky and ginger
				playedSceneNumber=SCENE2079;
				startFMA("SCENE2079");	// well done try again
				// tbd put the subgame here
				//overlayDebugMessage("TBD - To the Seesaw sub game ", 25 * 3);
				return;
			}
			else if ( subgame1 || subgame2 ) 
			{
				if ( (gamePlayData->A2fmaStatus[SCENE2077].playedFlag==FMA_NOTPLAYED) || xState)
				{
					gamePlayData->A2fmaStatus[SCENE2077].playedFlag=FMA_PLAYED;
					playedSceneNumber=SCENE2077;
					startFMA("SCENE2077");	// wrong hut
				}
				return;
			}
		}
		else if (subgame3)
		{
			if (gamePlayData->inventory_item_status[COOKING_WEIGHTS]!=INV_STATUS_NOTCOLLECTED)
			{
				test=FALSE;
				if (gamePlayData->inventory_item_status[COOKING_WEIGHTS]==INV_STATUS_IN_INVENTORY)
				{
					inventoryRemoveItem(COOKING_WEIGHTS);
					test=TRUE;
				}
			}
			if (test)
			{
				gamePlayData->A2fmaStatus[SCENE2074].playedFlag=FMA_PLAYED;
				gamePlayData->A2fmaStatus[SCENE2078].playedFlag=FMA_PLAYED;	// set for rocky and ginger
				playedSceneNumber=SCENE2078;
				startFMA("SCENE2078");	// well done try again
				// tbd put the subgame here
				//overlayDebugMessage("TBD - To the Seesaw sub game ", 25 * 3);
			}
			return;
		}
		else if (subgame1 || subgame2)
		{
			if ( (gamePlayData->A2fmaStatus[SCENE2077].playedFlag==FMA_NOTPLAYED) || xState)
			{
				gamePlayData->A2fmaStatus[SCENE2077].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE2077;
				startFMA("SCENE2077");	// wrong hut
			}
			return;
		}
		else	// no objects 
		{
			if ( (gamePlayData->A2fmaStatus[SCENE2076].playedFlag==FMA_NOTPLAYED) || xState)
			{
				gamePlayData->A2fmaStatus[SCENE2076].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE2076;
				startFMA("SCENE2076");	// wrong hut
			}
			return;
		}
	}
	*/
}

/////////////////////////////////////////////////////////////////////////////
void	a2Workhut2FmaChecks(int	xState)
{
	int	test;
	int	count;
	int	items;
	int	subgame1,subgame2,subgame3;

	subgame1=0;
	subgame2=0;
	subgame3=0;

	playedActNumber=FMA_ACT2;
	// ok what are we holding?
	if (gamePlayData->inventory_item_status[MATCHES]==INV_STATUS_IN_INVENTORY) subgame1++;
	if (gamePlayData->inventory_item_status[FIREWORKS]==INV_STATUS_IN_INVENTORY) subgame1++;
	// seesaw
	if (gamePlayData->inventory_item_status[COOKING_WEIGHTS]==INV_STATUS_IN_INVENTORY) subgame3++;
	// catapult
	if (gamePlayData->inventory_item_status[STRONG_CORD]==INV_STATUS_IN_INVENTORY) subgame2++;
	if (gamePlayData->inventory_item_status[BROKEN_LADDER]==INV_STATUS_IN_INVENTORY) subgame2++;
	if (gamePlayData->inventory_item_status[PRAM_CHASSIS]==INV_STATUS_IN_INVENTORY) subgame2++;
	if (gamePlayData->inventory_item_status[TENNIS_RACKET]==INV_STATUS_IN_INVENTORY) subgame2++;

	if (currentChicken == CHAR_NAME_GINGER)
	{
		// first have we comleted with yet
		if (gamePlayData->A2fmaStatus[SCENE2044].playedFlag==FMA_PLAYED)
		{
			if (xState)
			{
				gamePlayData->A2fmaStatus[SCENE2045].playedFlag=FMA_PLAYED;
				gamePlayData->A2fmaStatus[SCENE2051].playedFlag=FMA_PLAYED;	// set for rocky and ginger
				playedSceneNumber=SCENE2045;
				startFMA("SCENE2045");	// well done try again
				//overlayDebugMessage("TBD - To the catapult sub game ", 25 * 3);
				// tbd put the subgame here
				return;
			}
			else if ( subgame1 || subgame3 ) 
			{
				if ( (gamePlayData->A2fmaStatus[SCENE2040].playedFlag==FMA_NOTPLAYED) || xState)
				{
					gamePlayData->A2fmaStatus[SCENE2040].playedFlag=FMA_PLAYED;
					playedSceneNumber=SCENE2040;
					startFMA("SCENE2040");	// wrong hut
				}
				return;
			}
		}
		if (subgame2) // do we have any required items
		{
			// ok lets go in to detail on this
			test=0;
			count=0;
			items=0;
			if (gamePlayData->inventory_item_status[TENNIS_RACKET]!=INV_STATUS_NOTCOLLECTED)
			{
				test=1;
				items++;
				if (gamePlayData->inventory_item_status[TENNIS_RACKET]==INV_STATUS_IN_INVENTORY)
				{
					inventoryRemoveItem(TENNIS_RACKET);
					count++;
				}
			}
			if (gamePlayData->inventory_item_status[PRAM_CHASSIS]!=INV_STATUS_NOTCOLLECTED)
			{
				test|=2;
				items++;
				if (gamePlayData->inventory_item_status[PRAM_CHASSIS]==INV_STATUS_IN_INVENTORY)
				{
					inventoryRemoveItem(PRAM_CHASSIS);
					count++;
				}
			}
			if (gamePlayData->inventory_item_status[STRONG_CORD]!=INV_STATUS_NOTCOLLECTED)
			{
				test|=4;
				items++;
				if (gamePlayData->inventory_item_status[STRONG_CORD]==INV_STATUS_IN_INVENTORY)
				{
					inventoryRemoveItem(STRONG_CORD);
					count++;
				}
			}
			if (gamePlayData->inventory_item_status[BROKEN_LADDER]!=INV_STATUS_NOTCOLLECTED)
			{
				test|=8;
				items++;
				if (gamePlayData->inventory_item_status[BROKEN_LADDER]==INV_STATUS_IN_INVENTORY)
				{
					inventoryRemoveItem(BROKEN_LADDER);
					count++;
				}
			}
			if (test==15) // all required object collected
			{
				gamePlayData->A2fmaStatus[SCENE2044].playedFlag=FMA_PLAYED;
				gamePlayData->A2fmaStatus[SCENE2050].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE2044;
				startFMA("SCENE2044");	// well done
				// tbd put the subgame here
				//overlayDebugMessage("TBD - To the catapult sub game ", 25 * 3);
				return;
			}
			else
			{
				if (items<3)
				{
					gamePlayData->A2fmaStatus[SCENE2042].playedFlag=FMA_PLAYED;
					playedSceneNumber=SCENE2042;
					startFMA("SCENE2042");	// got some
				}
				else
				{
					gamePlayData->A2fmaStatus[SCENE2043].playedFlag=FMA_PLAYED;
					playedSceneNumber=SCENE2043;
					startFMA("SCENE2043");	// got some 2
				}
				return;
			}
		}
		else if (subgame1 || subgame3)
		{
			if ( (gamePlayData->A2fmaStatus[SCENE2040].playedFlag==FMA_NOTPLAYED) || xState)
			{
				gamePlayData->A2fmaStatus[SCENE2040].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE2040;
				startFMA("SCENE2040");	// wrong hut
			}
			return;
		}
		else	// no objects 
		{
			// RFW - change to stop the chicken sending you off to find objects you've just delivered to her,
			// after you've played the game for the first time
			if ( (gamePlayData->A2fmaStatus[SCENE2044].playedFlag==FMA_PLAYED))
			{
				gamePlayData->A2fmaStatus[SCENE2045].playedFlag=FMA_PLAYED;
				gamePlayData->A2fmaStatus[SCENE2051].playedFlag=FMA_PLAYED;	// set for rocky and ginger
				playedSceneNumber=SCENE2045;
				startFMA("SCENE2045");	// well done try again
				return;
			}
			else if ( (gamePlayData->A2fmaStatus[SCENE2041].playedFlag==FMA_NOTPLAYED) || xState)
			{
				gamePlayData->A2fmaStatus[SCENE2041].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE2041;
				startFMA("SCENE2041");	// wrong hut
			}
			return;
		}
	}	// should be the ginger possabilitys delts with
/*	else if (currentChicken == CHAR_NAME_ROCKY)
	{
		if (gamePlayData->A2fmaStatus[SCENE2044].playedFlag==FMA_PLAYED)
		{
			if (xState)
			{
				gamePlayData->A2fmaStatus[SCENE2045].playedFlag=FMA_PLAYED;
				gamePlayData->A2fmaStatus[SCENE2051].playedFlag=FMA_PLAYED;	// set for rocky and ginger
				playedSceneNumber=SCENE2051;
				startFMA("SCENE2051");	// well done try again
				// tbd put the subgame here
				//overlayDebugMessage("TBD - To the catapult sub game ", 25 * 3);
				return;
			}
			else if ( subgame1 || subgame3 ) 
			{
				if ( (gamePlayData->A2fmaStatus[SCENE2046].playedFlag==FMA_NOTPLAYED) || xState)
				{
					gamePlayData->A2fmaStatus[SCENE2046].playedFlag=FMA_PLAYED;
					playedSceneNumber=SCENE2046;
					startFMA("SCENE2046");	// wrong hut
				}
				return;
			}
		}
		if (subgame2) // do we have any required items
		{
			// ok lets go in to detail on this
			test=0;
			count=0;
			items=0;
			if (gamePlayData->inventory_item_status[TENNIS_RACKET]!=INV_STATUS_NOTCOLLECTED)
			{
				test=1;
				items++;
				if (gamePlayData->inventory_item_status[TENNIS_RACKET]==INV_STATUS_IN_INVENTORY)
				{
					inventoryRemoveItem(TENNIS_RACKET);
					count++;
				}
			}
			if (gamePlayData->inventory_item_status[PRAM_CHASSIS]!=INV_STATUS_NOTCOLLECTED)
			{
				test|=2;
				items++;
				if (gamePlayData->inventory_item_status[PRAM_CHASSIS]==INV_STATUS_IN_INVENTORY)
				{
					inventoryRemoveItem(PRAM_CHASSIS);
					count++;
				}
			}
			if (gamePlayData->inventory_item_status[STRONG_CORD]!=INV_STATUS_NOTCOLLECTED)
			{
				test|=4;
				items++;
				if (gamePlayData->inventory_item_status[STRONG_CORD]==INV_STATUS_IN_INVENTORY)
				{
					inventoryRemoveItem(STRONG_CORD);
					count++;
				}
			}
			if (gamePlayData->inventory_item_status[BROKEN_LADDER]!=INV_STATUS_NOTCOLLECTED)
			{
				test|=8;
				items++;
				if (gamePlayData->inventory_item_status[BROKEN_LADDER]==INV_STATUS_IN_INVENTORY)
				{
					inventoryRemoveItem(BROKEN_LADDER);
					count++;
				}
			}
			if (test==15) // all required object collected
			{
				gamePlayData->A2fmaStatus[SCENE2044].playedFlag=FMA_PLAYED;
				gamePlayData->A2fmaStatus[SCENE2050].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE2050;
				startFMA("SCENE2050");	// well done
				// tbd put the subgame here
				//overlayDebugMessage("TBD - To the catapult sub game ", 25 * 3);
				return;
			}
			else
			{
				if (items<3)
				{
					gamePlayData->A2fmaStatus[SCENE2048].playedFlag=FMA_PLAYED;
					playedSceneNumber=SCENE2048;
					startFMA("SCENE2048");	// got some
				}
				else
				{
					gamePlayData->A2fmaStatus[SCENE2049].playedFlag=FMA_PLAYED;
					playedSceneNumber=SCENE2049;
					startFMA("SCENE2049");	// got some 2
				}
				return;
			}
		}
		else if (subgame1 || subgame3)
		{
			if ( (gamePlayData->A2fmaStatus[SCENE2046].playedFlag==FMA_NOTPLAYED) || xState)
			{
				gamePlayData->A2fmaStatus[SCENE2046].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE2046;
				startFMA("SCENE2046");	// wrong hut
			}
			return;
		}
		else	// no objects 
		{
			if ( (gamePlayData->A2fmaStatus[SCENE2047].playedFlag==FMA_NOTPLAYED) || xState)
			{
				gamePlayData->A2fmaStatus[SCENE2047].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE2047;
				startFMA("SCENE2047");	// wrong hut
			}
			return;
		}
	}
	*/
}
/////////////////////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////////////////////////////
void	a2Workhut1FmaChecks(int	xState)
{
	int	test;
	int	count;
	int	subgame1,subgame2,subgame3;


	playedActNumber=FMA_ACT2;
	subgame1=0;
	subgame2=0;
	subgame3=0;

	// ok what are we holding?
	if (gamePlayData->inventory_item_status[MATCHES]==INV_STATUS_IN_INVENTORY) subgame1++;
	if (gamePlayData->inventory_item_status[FIREWORKS]==INV_STATUS_IN_INVENTORY) subgame1++;
	// seesaw
	if (gamePlayData->inventory_item_status[COOKING_WEIGHTS]==INV_STATUS_IN_INVENTORY) subgame3++;
	// catapult
	if (gamePlayData->inventory_item_status[STRONG_CORD]==INV_STATUS_IN_INVENTORY) subgame2++;
	if (gamePlayData->inventory_item_status[BROKEN_LADDER]==INV_STATUS_IN_INVENTORY) subgame2++;
	if (gamePlayData->inventory_item_status[PRAM_CHASSIS]==INV_STATUS_IN_INVENTORY) subgame2++;
	if (gamePlayData->inventory_item_status[TENNIS_RACKET]==INV_STATUS_IN_INVENTORY) subgame2++;



	if (currentChicken == CHAR_NAME_GINGER)
	{
		if (gamePlayData->A2fmaStatus[SCENE2023].playedFlag==FMA_PLAYED)
		{
			if (gamePlayData->A2fmaStatus[SCENE2024].playedFlag==FMA_NOTPLAYED) // 1st time so auto start
			{
				gamePlayData->A2fmaStatus[SCENE2024].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE2024;
				startFMA("SCENE2024");	// tell em what to do
				// tbd put the subgame here
				//overlayDebugMessage("TBD - To the fireworks sub game ", 25 * 3);
			}
			else if (gamePlayData->A2fmaStatus[SCENE2024].playedTime<(loop_ticker2-90) && xState) // 2nd time button pressed?
			{
				gamePlayData->A2fmaStatus[SCENE2024].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE2024;
				startFMA("SCENE2024");	// tell em what to do
				// tbd put the subgame here
				//overlayDebugMessage("TBD - To the fireworks sub game ", 25 * 3);
			}
			return;
		}
		// ok so its not finished yet 
		// do we have any parts for this sub game?
		if (subgame1)
		{
			// ok what have done/holding for this
			test=0;
			count=0;
			if (gamePlayData->inventory_item_status[MATCHES]!=INV_STATUS_NOTCOLLECTED)
			{
				test=1;
				if (gamePlayData->inventory_item_status[MATCHES]==INV_STATUS_IN_INVENTORY)
				{
					inventoryRemoveItem(MATCHES);
					count++;
				}
			}
			if (gamePlayData->inventory_item_status[FIREWORKS]!=INV_STATUS_NOTCOLLECTED)
			{
				test|=2;
				if (gamePlayData->inventory_item_status[FIREWORKS]==INV_STATUS_IN_INVENTORY)
				{
					inventoryRemoveItem(FIREWORKS);
					count++;
				}
			}
			if (count) // a required item has been removed
			{
				if (test==1) // matches collected
				{
					gamePlayData->A2fmaStatus[SCENE2022].playedFlag=FMA_PLAYED;
					playedSceneNumber=SCENE2022;
					startFMA("SCENE2022");	// well done
				}
				if (test==2) // fireworks collected
				{
					gamePlayData->A2fmaStatus[SCENE2021].playedFlag=FMA_PLAYED;
					playedSceneNumber=SCENE2021;
					startFMA("SCENE2021");	// well done
				}
				if (test==3) // all parts collected
				{
					gamePlayData->A2fmaStatus[SCENE2023].playedFlag=FMA_PLAYED;
					gamePlayData->A2fmaStatus[SCENE2034].playedFlag=FMA_PLAYED; // set complete for rocky as well
					playedSceneNumber=SCENE2023;
					startFMA("SCENE2023");	// you did it
					// put subgame play/open here
					//overlayDebugMessage("TBD - To the fireworks sub game ", 25 * 3);
				}
				return;
			}
		}
		else if (subgame2)
		{
			//test=0;
			//count=0;
			// ok check for objects for this subgame (theres only one)
			//if (gamePlayData->inventory_item_status[COOKING_WEIGHTS]==INV_STATUS_IN_INVENTORY)
			//{
				if (gamePlayData->A2fmaStatus[SCENE2020].playedFlag==FMA_NOTPLAYED)
				{
					gamePlayData->A2fmaStatus[SCENE2020].playedFlag=FMA_PLAYED;
					playedSceneNumber=SCENE2020;
					startFMA("SCENE2020");	// go away
					return;
				}
				else if (gamePlayData->A2fmaStatus[SCENE2020].playedTime<(loop_ticker2-90) && xState)
				{
					gamePlayData->A2fmaStatus[SCENE2020].playedFlag=FMA_PLAYED;
					playedSceneNumber=SCENE2020;
					startFMA("SCENE2020");	// go away
					return;
				}
			//} dur I must be half asslep
		}
		else if (subgame3)
		{
			if (gamePlayData->A2fmaStatus[SCENE2020].playedFlag==FMA_NOTPLAYED)
			{
				gamePlayData->A2fmaStatus[SCENE2020].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE2020;
				startFMA("SCENE2020");	// go away
				return;
			}
			else if (gamePlayData->A2fmaStatus[SCENE2020].playedTime<(loop_ticker2-90) && xState)
			{
				gamePlayData->A2fmaStatus[SCENE2020].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE2020;
				startFMA("SCENE2020");	// go away
				return;
			}
		}
		else	// no objects 
		{
			if ( (gamePlayData->A2fmaStatus[SCENE2019].playedFlag==FMA_NOTPLAYED) || xState)
			{
				gamePlayData->A2fmaStatus[SCENE2019].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE2019;
				startFMA("SCENE2019");	// wrong hut
			}
			return;
		}
	}	// ok thats ginger delt with 
/*	else if (currentChicken == CHAR_NAME_ROCKY)
	{
		if (gamePlayData->A2fmaStatus[SCENE2034].playedFlag==FMA_PLAYED)	// this gets set if you complete with ginger
		{
			if (gamePlayData->A2fmaStatus[SCENE2035].playedFlag==FMA_NOTPLAYED) // 1st time so auto start
			{
				gamePlayData->A2fmaStatus[SCENE2035].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE2035;
				startFMA("SCENE2035");	// tell em what to do
				// tbd put the subgame here
				//overlayDebugMessage("TBD - To the fireworks sub game ", 25 * 3);
			}
			else if (gamePlayData->A2fmaStatus[SCENE2035].playedTime<(loop_ticker2-90) && xState) // 2nd time button pressed?
			{
				gamePlayData->A2fmaStatus[SCENE2035].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE2035;
				startFMA("SCENE2035");	// tell em what to do
				// tbd put the subgame here
				//overlayDebugMessage("TBD - To the fireworks sub game ", 25 * 3);
			}
			return;
		}
		// ok so if here then you hav'nt completed this subgame
		if (subgame1)
		{
			// ok what have done/holding for this
			test=0;
			count=0;
			if (gamePlayData->inventory_item_status[MATCHES]!=INV_STATUS_NOTCOLLECTED)
			{
				test=1;
				if (gamePlayData->inventory_item_status[MATCHES]==INV_STATUS_IN_INVENTORY)
				{
					inventoryRemoveItem(MATCHES);
					count++;
				}
			}
			if (gamePlayData->inventory_item_status[FIREWORKS]!=INV_STATUS_NOTCOLLECTED)
			{
				test|=2;
				if (gamePlayData->inventory_item_status[FIREWORKS]==INV_STATUS_IN_INVENTORY)
				{
					inventoryRemoveItem(FIREWORKS);
					count++;
				}
			}
			if (count) // a required item has been removed
			{
				if (test==1) // matches collected
				{
					gamePlayData->A2fmaStatus[SCENE2033].playedFlag=FMA_PLAYED;
					playedSceneNumber=SCENE2033;
					startFMA("SCENE2033");	// well done
				}
				if (test==2) // fireworks collected
				{
					gamePlayData->A2fmaStatus[SCENE2032].playedFlag=FMA_PLAYED;
					playedSceneNumber=SCENE2032;
					startFMA("SCENE2032");	// well done
				}
				if (test==3) // all parts collected
				{
					gamePlayData->A2fmaStatus[SCENE2023].playedFlag=FMA_PLAYED; // set complete for ginger as well
					gamePlayData->A2fmaStatus[SCENE2034].playedFlag=FMA_PLAYED;
					playedSceneNumber=SCENE2034;
					startFMA("SCENE2034");	// you did it
					// put subgame play/open here
					//overlayDebugMessage("TBD - To the fireworks sub game ", 25 * 3);
				}
				return;
			}
		}
		else if (subgame2)
		{
			if (gamePlayData->A2fmaStatus[SCENE2031].playedFlag==FMA_NOTPLAYED)
			{
				gamePlayData->A2fmaStatus[SCENE2031].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE2031;
				startFMA("SCENE2031");	// go away
				return;
			}
			else if (gamePlayData->A2fmaStatus[SCENE2031].playedTime<(loop_ticker2-90) && xState)
			{
				gamePlayData->A2fmaStatus[SCENE2031].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE2031;
				startFMA("SCENE2031");	// go away
				return;
			}
		}
		else if (subgame3)
		{
			if (gamePlayData->A2fmaStatus[SCENE2031].playedFlag==FMA_NOTPLAYED)
			{
				gamePlayData->A2fmaStatus[SCENE2031].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE2031;
				startFMA("SCENE2031");	// go away
				return;
			}
			else if (gamePlayData->A2fmaStatus[SCENE2031].playedTime<(loop_ticker2-90) && xState)
			{
				gamePlayData->A2fmaStatus[SCENE2031].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE2031;
				startFMA("SCENE2031");	// go away
				return;
			}
		}
		else	// no objects 
		{
			if ( (gamePlayData->A2fmaStatus[SCENE2030].playedFlag==FMA_NOTPLAYED) || xState)
			{
				gamePlayData->A2fmaStatus[SCENE2030].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE2030;
				startFMA("SCENE2030");	// wrong hut
			}
			return;
		}
	}
	*/
}

/////////////////////////////////////////////////////////////////////////////
void	a2Hut17FmaChecks(int	xState)
{
	int	test;
	int	count;
	int	subgame1;
	int	subgame2;
	int	subgame3;
	int	selectedItem=NULL;


	playedActNumber=FMA_ACT2;
	// find out current object status
	subgame1=0;	// fireworks
	subgame2=0;	// seesaw
	subgame3=0;	// catapult
	// lets check for firework subgame (workhut1)
	if (gamePlayData->inventory_item_status[MATCHES]==INV_STATUS_IN_INVENTORY) subgame1++;
	if (gamePlayData->inventory_item_status[FIREWORKS]==INV_STATUS_IN_INVENTORY) subgame1++;
	// seesaw
	if (gamePlayData->inventory_item_status[COOKING_WEIGHTS]==INV_STATUS_IN_INVENTORY) subgame2++;
	// catapult
	if (gamePlayData->inventory_item_status[STRONG_CORD]==INV_STATUS_IN_INVENTORY) subgame3++;
	if (gamePlayData->inventory_item_status[BROKEN_LADDER]==INV_STATUS_IN_INVENTORY) subgame3++;
	if (gamePlayData->inventory_item_status[PRAM_CHASSIS]==INV_STATUS_IN_INVENTORY) subgame3++;
	if (gamePlayData->inventory_item_status[TENNIS_RACKET]==INV_STATUS_IN_INVENTORY) subgame3++;

	if (currentChicken == CHAR_NAME_GINGER)
	{
		if (gamePlayData->A2fmaStatus[SCENE2001].playedFlag==FMA_NOTPLAYED)	// if first time play auto briefing
		{
			gamePlayData->A2fmaStatus[SCENE2001].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE2001;
			SpecialCaseFma=ACT2FMA1;
			startFMA("SCENE2001");	// tell em what to do
			return;
		}
		// ok so if were here then the auto brief has been done 
		// find out current object status
		subgame1=0;	// fireworks
		subgame2=0;	// seesaw
		subgame3=0;	// catapult
		// lets check for firework subgame (workhut1)
		if (gamePlayData->inventory_item_status[MATCHES]==INV_STATUS_IN_INVENTORY) subgame1++;
		if (gamePlayData->inventory_item_status[FIREWORKS]==INV_STATUS_IN_INVENTORY) subgame1++;
		// seesaw
		if (gamePlayData->inventory_item_status[COOKING_WEIGHTS]==INV_STATUS_IN_INVENTORY) subgame2++;
		// catapult
		if (gamePlayData->inventory_item_status[STRONG_CORD]==INV_STATUS_IN_INVENTORY) subgame3++;
		if (gamePlayData->inventory_item_status[BROKEN_LADDER]==INV_STATUS_IN_INVENTORY) subgame3++;
		if (gamePlayData->inventory_item_status[PRAM_CHASSIS]==INV_STATUS_IN_INVENTORY) subgame3++;
		if (gamePlayData->inventory_item_status[TENNIS_RACKET]==INV_STATUS_IN_INVENTORY) subgame3++;
		// ok if you have none of the required bits on you and xPresed play 2nd brief
		if (!subgame1 && !subgame2 && !subgame3)// && xState)
		{
			if (xState)
			{
				gamePlayData->A2fmaStatus[SCENE2009].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE2009;
				SpecialCaseFma=ACT2FMA2;
				startFMA("SCENE2009");	// tell em what to do
			}
			return;
		}
		// the empty case has been delt with so you must have something
		// Of course somebody is going to come in with items for 2 seperate subgames so what to do about that
		// do the is it the first time cases first
		// may need to check if any of them have been played resently

		// tdb if any object active (in hand) do that one first


		//selectedItem=0;

		switch (currentInv->selected_item)
		{
			case	STRONG_CORD:
			case	BROKEN_LADDER:
			case	PRAM_CHASSIS:
			case	TENNIS_RACKET:
				selectedItem=3;
				break;
			case	COOKING_WEIGHTS:
				selectedItem=2;
				break;
			case	FIREWORKS:
			case	MATCHES:
				selectedItem=1;
				break;
		}
		if (selectedItem)
		{
			if (selectedItem==1)
			{
				if ( gamePlayData->A2fmaStatus[SCENE2003].playedFlag==FMA_NOTPLAYED || xState)
				{
					gamePlayData->A2fmaStatus[SCENE2003].playedFlag=FMA_PLAYED;
					playedSceneNumber=SCENE2003;
					startFMA("SCENE2003");	// tell em what to do
				}
				return;
			}
			if (selectedItem==2)
			{
				if ( gamePlayData->A2fmaStatus[SCENE2004].playedFlag==FMA_NOTPLAYED || xState)
				{
					gamePlayData->A2fmaStatus[SCENE2004].playedFlag=FMA_PLAYED;
					playedSceneNumber=SCENE2004;
					startFMA("SCENE2004");	// tell em what to do
				}
				return;
			}
			if (selectedItem==3)
			{
				if ( gamePlayData->A2fmaStatus[SCENE2005].playedFlag==FMA_NOTPLAYED || xState)
				{
					gamePlayData->A2fmaStatus[SCENE2005].playedFlag=FMA_PLAYED;
					playedSceneNumber=SCENE2005;
					startFMA("SCENE2005");	// tell em what to do
				}
				return;
			}
		}

		if (subgame1 && gamePlayData->A2fmaStatus[SCENE2003].playedFlag==FMA_NOTPLAYED)
		{
			gamePlayData->A2fmaStatus[SCENE2003].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE2003;
			startFMA("SCENE2003");	// tell em what to do
			return;
		}
		if (subgame2 && gamePlayData->A2fmaStatus[SCENE2004].playedFlag==FMA_NOTPLAYED)
		{
			gamePlayData->A2fmaStatus[SCENE2004].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE2004;
			startFMA("SCENE2004");	// tell em what to do
			return;
		}
		if (subgame3 && gamePlayData->A2fmaStatus[SCENE2005].playedFlag==FMA_NOTPLAYED)
		{
			gamePlayData->A2fmaStatus[SCENE2005].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE2005;
			startFMA("SCENE2005");	// tell em what to do
			return;
		}
		// yes I think it is going to need to check last time played else if you come in with 1 from each you get 3 fmas
		// now check for item and button pressed
		if (subgame1 && gamePlayData->A2fmaStatus[SCENE2003].playedTime<(loop_ticker2-90) && xState)
		{
			gamePlayData->A2fmaStatus[SCENE2003].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE2003;
			startFMA("SCENE2003");	// tell em what to do
			return;
		}
		if (subgame2 && gamePlayData->A2fmaStatus[SCENE2004].playedTime<(loop_ticker2-90) && xState)
		{
			gamePlayData->A2fmaStatus[SCENE2004].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE2004;
			startFMA("SCENE2004");	// tell em what to do
			return;
		}
		if (subgame3 && gamePlayData->A2fmaStatus[SCENE2005].playedTime<(loop_ticker2-90) && xState)
		{
			gamePlayData->A2fmaStatus[SCENE2005].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE2005;
			startFMA("SCENE2005");	// tell em what to do
			return;
		}
	}
/*	else if (currentChicken == CHAR_NAME_ROCKY)
	{
		// do the briefing if applicable
		if (gamePlayData->A2fmaStatus[SCENE2002].playedFlag==FMA_NOTPLAYED)	// if first time play auto briefing
		{
			gamePlayData->A2fmaStatus[SCENE2002].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE2002;
			startFMA("SCENE2002");	// tell em what to do
			return;
		}
		if (subgame1 && gamePlayData->A2fmaStatus[SCENE2006].playedFlag==FMA_NOTPLAYED)
		{
			gamePlayData->A2fmaStatus[SCENE2006].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE2006;
			startFMA("SCENE2006");	// tell em what to do
			return;
		}
		if (subgame2 && gamePlayData->A2fmaStatus[SCENE2007].playedFlag==FMA_NOTPLAYED)
		{
			gamePlayData->A2fmaStatus[SCENE2007].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE2007;
			startFMA("SCENE2007");	// tell em what to do
			return;
		}
		if (subgame3 && gamePlayData->A2fmaStatus[SCENE2008].playedFlag==FMA_NOTPLAYED)
		{
			gamePlayData->A2fmaStatus[SCENE2008].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE2008;
			startFMA("SCENE2008");	// tell em what to do
			return;
		}
		// yes I think it is going to need to check last time played else if you come in with 1 from each you get 3 fmas
		// now check for item and button pressed
		if (subgame1 && gamePlayData->A2fmaStatus[SCENE2006].playedTime<(loop_ticker2-90) && xState)
		{
			gamePlayData->A2fmaStatus[SCENE2006].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE2006;
			startFMA("SCENE2006");	// tell em what to do
			return;
		}
		if (subgame2 && gamePlayData->A2fmaStatus[SCENE2007].playedTime<(loop_ticker2-90) && xState)
		{
			gamePlayData->A2fmaStatus[SCENE2007].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE2007;
			startFMA("SCENE2007");	// tell em what to do
			return;
		}
		if (subgame3 && gamePlayData->A2fmaStatus[SCENE2008].playedTime<(loop_ticker2-90) && xState)
		{
			gamePlayData->A2fmaStatus[SCENE2008].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE2008;
			startFMA("SCENE2008");	// tell em what to do
			return;
		}
	}
	else
	{
		// who the hell are we controlling
		DB("unknown char in fma play\n");
		ASSERT(0);
	}
	*/
}
/////////////////////////////////////////////////////////////////////////////
void	a1Workhut1FmaChecks(int	xState)
{
//int	test,count;

int		hut17Items,whut1Items,hut17ItemsDone,whut1ItemsDone,itemsRemovable;

//	If the wirecutter not completed then you dont know about the manakin
	itemsRemovable=TRUE;
	playedActNumber=FMA_ACT1;
	if (gamePlayData->A1fmaStatus[SCENE1004].playedFlag==FMA_NOTPLAYED)
	{
		itemsRemovable=FALSE;	// if not done wirecutters then dont remove any manakin objects
	}


	hut17Items=whut1Items=hut17ItemsDone=whut1ItemsDone=0;

	if (gamePlayData->inventory_item_status[RUSTY_SHEARS]!=INV_STATUS_NOTCOLLECTED)
		hut17ItemsDone++;
	if (gamePlayData->inventory_item_status[RUSTY_SHEARS]==INV_STATUS_IN_INVENTORY)
		hut17Items++;


	if (gamePlayData->inventory_item_status[BUTTER_KNIFE]!=INV_STATUS_NOTCOLLECTED)
		hut17ItemsDone++;
	if (gamePlayData->inventory_item_status[BUTTER_KNIFE]==INV_STATUS_IN_INVENTORY)
		hut17Items++;

	if (gamePlayData->inventory_item_status[BOOTS]!=INV_STATUS_NOTCOLLECTED)
		whut1ItemsDone++;
	if (gamePlayData->inventory_item_status[BOOTS]==INV_STATUS_IN_INVENTORY)
	{
		if (itemsRemovable) inventoryRemoveItem(BOOTS);
		whut1Items++;
	}

	if (gamePlayData->inventory_item_status[A1POLES]!=INV_STATUS_NOTCOLLECTED)
		whut1ItemsDone++;
	if (gamePlayData->inventory_item_status[A1POLES]==INV_STATUS_IN_INVENTORY)
	{
		if (itemsRemovable) inventoryRemoveItem(A1POLES);
		whut1Items++;
	}

	if (gamePlayData->inventory_item_status[GLOVES]!=INV_STATUS_NOTCOLLECTED)
		whut1ItemsDone++;
	if (gamePlayData->inventory_item_status[GLOVES]==INV_STATUS_IN_INVENTORY)
	{
		if (itemsRemovable) inventoryRemoveItem(GLOVES);
		whut1Items++;
	}

	if (gamePlayData->inventory_item_status[NIGHTDRESS]!=INV_STATUS_NOTCOLLECTED)
		whut1ItemsDone++;
	if (gamePlayData->inventory_item_status[NIGHTDRESS]==INV_STATUS_IN_INVENTORY)
	{
		if (itemsRemovable) inventoryRemoveItem(NIGHTDRESS);
		whut1Items++;
	}

	if (whut1Items && itemsRemovable)	// we have something for this hut
	{
		if ( (whut1ItemsDone)==4 ) // done all items
		{
			gamePlayData->A1fmaStatus[SCENE1014].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE1014;
			inventoryRemoveItem(WIRE_CUTTERS);		// remove wire cutters before dogchase ready for act2
			options_returnlevel=LEVNUMBER_A2_HUT17;	// so we know where we're going after the options/debriefing
			startFMA("SCENE1014");	// to the dog chase wahoo !!
			return;
		}
		else
		{
			if ( ((whut1ItemsDone)<3) && (gamePlayData->A1fmaStatus[SCENE1012].playedFlag==FMA_NOTPLAYED) )
			{
				gamePlayData->A1fmaStatus[SCENE1012].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE1012;
				startFMA("SCENE1012");	// ta 
				return;
			}
			else
			{
				gamePlayData->A1fmaStatus[SCENE1013].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE1013;
				startFMA("SCENE1013");	// ta  Mk.II
				return;
			}
		}
	}

	if (hut17Items /*&& xState*/) // if people want auto trigger thats what they'll get
	{
		gamePlayData->A1fmaStatus[SCENE1010].playedFlag=FMA_PLAYED;
		playedSceneNumber=SCENE1010;
		startFMA("SCENE1010");	// wrong hut
		return;
	}

	if ((hut17ItemsDone==0) /*&& xState*/)
	{
		gamePlayData->A1fmaStatus[SCENE1015].playedFlag=FMA_PLAYED;
		playedSceneNumber=SCENE1015;
		startFMA("SCENE1015");	// wrong hut hut17 objs help
		return;
	}

	if (xState && itemsRemovable)
	{
		gamePlayData->A1fmaStatus[SCENE1011].playedFlag=FMA_PLAYED;
		playedSceneNumber=SCENE1011;
		startFMA("SCENE1011");	// wrong hut no objects
		return;
	}
	else if (xState && !itemsRemovable)
	{
		gamePlayData->A1fmaStatus[SCENE1015].playedFlag=FMA_PLAYED;
		playedSceneNumber=SCENE1015;
		startFMA("SCENE1015");	// wrong hut no objects
		return;
	}

/*	if ( gamePlayData->A1fmaStatus[SCENE1004].playedFlag==FMA_NOTPLAYED ) // hav'nt compleated hut17 so go away
	{
		// do you have any items
		if ( (currentInv->empty_slots!=6) )
		{	// ok you are carring somthing and you don't know about workhut1 yet so 
			if (gamePlayData->A1fmaStatus[SCENE1010].playedFlag==FMA_NOTPLAYED)
			{
				gamePlayData->A1fmaStatus[SCENE1010].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE1010;
				startFMA("SCENE1010");	// your in the wrong hut sort it out
			}
			else if (xState && gamePlayData->A1fmaStatus[SCENE1010].playedTime<(loop_ticker2-90) ) // bet you only do that once
			{
				gamePlayData->A1fmaStatus[SCENE1010].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE1010;
				startFMA("SCENE1010");	// your in the wrong hut sort it out
			}
		}
	}
	else


	{
		// ok what have you got
		test=0;
		count=0;
		if (gamePlayData->inventory_item_status[BOOTS]!=INV_STATUS_NOTCOLLECTED)
		{
			if (gamePlayData->inventory_item_status[BOOTS]==INV_STATUS_IN_INVENTORY)
			{
				inventoryRemoveItem(BOOTS);
				test++;
			}
			count=1;
		}
		if (gamePlayData->inventory_item_status[A1POLES]!=INV_STATUS_NOTCOLLECTED)
		{
			if (gamePlayData->inventory_item_status[A1POLES]==INV_STATUS_IN_INVENTORY)
			{
				inventoryRemoveItem(A1POLES);
				test++;
			}
			count++;
		}
		if (gamePlayData->inventory_item_status[GLOVES]!=INV_STATUS_NOTCOLLECTED)
		{
			if (gamePlayData->inventory_item_status[GLOVES]==INV_STATUS_IN_INVENTORY)
			{
				inventoryRemoveItem(GLOVES);
				test++;
			}
			count++;
		}
		if (gamePlayData->inventory_item_status[NIGHTDRESS]!=INV_STATUS_NOTCOLLECTED)
		{
			if (gamePlayData->inventory_item_status[NIGHTDRESS]==INV_STATUS_IN_INVENTORY)
			{
				inventoryRemoveItem(NIGHTDRESS);
				test++;
			}
			count++;
		}
		if (!test)
		{
			//else if (xState && gamePlayData->A1fmaStatus[SCENE1010].playedTime<(loop_ticker2-90) // bet you only do that once
			if (gamePlayData->A1fmaStatus[SCENE1011].playedFlag==FMA_NOTPLAYED)
			{
				gamePlayData->A1fmaStatus[SCENE1011].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE1011;
				startFMA("SCENE1011");	// well bring me something then
				return;
			}
			else if (xState && gamePlayData->A1fmaStatus[SCENE1015].playedTime<(loop_ticker2-20) ) // bet you only do that once
			{
				gamePlayData->A1fmaStatus[SCENE1015].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE1015;
				startFMA("SCENE1015");	// well bring me something then
				return;
			}
		}
		else
		{
			if (count!=4)	// not yet completed
			{
				if ( (gamePlayData->A1fmaStatus[SCENE1012].playedFlag==FMA_NOTPLAYED) || count==1)
				{
					gamePlayData->A1fmaStatus[SCENE1012].playedFlag=FMA_PLAYED;
					playedSceneNumber=SCENE1012;
					startFMA("SCENE1012");	// ta 
					return;
				}
				else
				{
					gamePlayData->A1fmaStatus[SCENE1013].playedFlag=FMA_PLAYED;
					playedSceneNumber=SCENE1013;
					startFMA("SCENE1013");	// ta  Mk.II
					return;
				}
			}
			else
			{
				gamePlayData->A1fmaStatus[SCENE1014].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE1014;
				inventoryRemoveItem(WIRE_CUTTERS);		// remove wire cutters before dogchase ready for act2
				options_returnlevel=LEVNUMBER_A2_HUT17;	// so we know where we're going after the options/debriefing
				startFMA("SCENE1014");	// to the dog chase wahoo !!
				return;
			}
		}
	}
*/
}

/////////////////////////////////////////////////////////////////////////////
void	a1Hut17FmaChecks(int	xState)
{
int	test,count;

	playedActNumber=FMA_ACT1;
	if ( gamePlayData->A1fmaStatus[SCENE1004].playedFlag==FMA_NOTPLAYED )	// if this is done then wirecutters must be complete
	{
		// do we have any required objects?
		test=0;
		count=0;
		if (gamePlayData->inventory_item_status[RUSTY_SHEARS]!=INV_STATUS_NOTCOLLECTED)
		{
			if (gamePlayData->inventory_item_status[RUSTY_SHEARS]==INV_STATUS_IN_INVENTORY)
			{
				inventoryRemoveItem(RUSTY_SHEARS);
				count++;
			}
			test=1;
		}
		if (gamePlayData->inventory_item_status[BUTTER_KNIFE]!=INV_STATUS_NOTCOLLECTED)
		{
			if (gamePlayData->inventory_item_status[BUTTER_KNIFE]==INV_STATUS_IN_INVENTORY)
			{
				inventoryRemoveItem(BUTTER_KNIFE);
				count++;
			}
			test|=2;
		}
		if (!test)
		{	// we have no thing they want
			// could be the start of the game in which case scene 1001 will not have been played
			if ( gamePlayData->A1fmaStatus[SCENE1001].playedFlag==FMA_NOTPLAYED )
			{
				gamePlayData->A1fmaStatus[SCENE1001].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE1001;
				startFMA("SCENE1001");	// start fma
			}
			else if (xState && gamePlayData->A1fmaStatus[SCENE1007].playedTime<(loop_ticker2-20) ) // if button pressed and last played more then 3 seconds ago (stops crapy x repete)
			{
				gamePlayData->A1fmaStatus[SCENE1007].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE1007;
				startFMA("SCENE1007");	// start fma
			}
			return;
		}
		else if (count) // not sure what to do if you try to acivate with one done but none on you
		{
			if (test==1)
			{
				gamePlayData->A1fmaStatus[SCENE1002].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE1002;
				startFMA("SCENE1002");	// got shears fma
			}
			if (test==2)
			{
				gamePlayData->A1fmaStatus[SCENE1003].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE1003;
				startFMA("SCENE1003");	// got knife fma
			}
			if (test==3)
			{
				gamePlayData->A1fmaStatus[SCENE1004].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE1004;
				startFMA("SCENE1004");	// got all the bit get given cutters
				inventoryPickUpItem(WIRE_CUTTERS);	// and here they are
				currentInv->selected_item=WIRE_CUTTERS; // and make them held
			}
		}
		else if (xState)
		{
			if (test==3) // if test set to 3 then wirecutters done
			{
				gamePlayData->A1fmaStatus[SCENE1008].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE1008;
				startFMA("SCENE1008");
			}
			else
			{
				gamePlayData->A1fmaStatus[SCENE1007].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE1007;
				startFMA("SCENE1007");
			}
		}
/*		else if (xState && gamePlayData->A1fmaStatus[SCENE1008].playedTime<(loop_ticker2-20) ) // if button pressed and last played more then 3 seconds ago (stops crapy x repete)
		{
			gamePlayData->A1fmaStatus[SCENE1008].playedFlag=FMA_PLAYED;
			playedSceneNumber=SCENE1008;
			startFMA("SCENE1008");

			//gamePlayData->A1fmaStatus[SCENE1008].playedFlag=FMA_PLAYED;
			//playedSceneNumber=SCENE1008;
			//startFMA("SCENE1008");
		}
*/	}
	else
	{
		// If here then you allready have the wire cutters
		// check for any objects for workhut1
		int	itemsCarried=0;
		int	itemsCollected=0;

		test=0;

		if (gamePlayData->inventory_item_status[BOOTS]==INV_STATUS_IN_INVENTORY) itemsCarried++;
		else if (gamePlayData->inventory_item_status[BOOTS]==INV_STATUS_REMOVED) itemsCollected++;

		if (gamePlayData->inventory_item_status[A1POLES]==INV_STATUS_IN_INVENTORY) itemsCarried++;
		else if (gamePlayData->inventory_item_status[A1POLES]==INV_STATUS_REMOVED) itemsCollected++;

		if (gamePlayData->inventory_item_status[GLOVES]==INV_STATUS_IN_INVENTORY) itemsCarried++;
		else if (gamePlayData->inventory_item_status[GLOVES]==INV_STATUS_REMOVED) itemsCollected++;

		if (gamePlayData->inventory_item_status[NIGHTDRESS]==INV_STATUS_IN_INVENTORY) itemsCarried++;
		else if (gamePlayData->inventory_item_status[NIGHTDRESS]==INV_STATUS_REMOVED) itemsCollected++;

		if (itemsCarried)
		{
			if (xState && gamePlayData->A1fmaStatus[SCENE1005].playedTime<(loop_ticker2-20) )
			{
				gamePlayData->A1fmaStatus[SCENE1005].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE1005;
				startFMA("SCENE1005");	// your in the wrong hut sort it out
			}
		}
		else /*if (itemCollected==4)*/
		{
			if (xState && gamePlayData->A1fmaStatus[SCENE1008].playedTime<(loop_ticker2-20) )
			{
				gamePlayData->A1fmaStatus[SCENE1008].playedFlag=FMA_PLAYED;
				playedSceneNumber=SCENE1008;
				startFMA("SCENE1008");
			}
		}
	}
}

////////////////////////////////////////////////////////////////////////////////////////
void	resetFma(void)
{
	int	i;

	for (i=0;i<MAX_ACT1_FMAS;i++)
		gamePlayData->A1fmaStatus[i].playedTime=0;
	for (i=0;i<MAX_ACT2_FMAS;i++)
		gamePlayData->A2fmaStatus[i].playedTime=0;
	for (i=0;i<MAX_ACT4_FMAS;i++)
		gamePlayData->A4fmaStatus[i].playedTime=0;

}
////////////////////////////////////////////////////////////////////////////////////////

// this has got very messy with all the changes so a new routine is going to take over
void	FMAsequenceHandeler(char *leafname)
{
	int	levelNum,loop,flag,items,part;
	inventoryType *currentInv = &gamePlayData->inventories[INVNO_GINGER];

	DB("level name %s\n",leafname);

	if (!fmaInfo) return;

	SpecialCaseFma=FALSE;
	levelNum=NOT_FOUND;	// TBD At some point, this can be switched to use levinfo->level_num
	for (loop=0;loop<MAX_LEVELS_FMA;loop++)
	{
		if(strcmp(leafname,LevelConverter[loop].name) == 0)
		{
			levelNum=loop;
			break;
		}
	}
	if (levelNum==NOT_FOUND)
	{
		DB("level %s not recognized will not try to find fma scripts\n",leafname);
	}
	else
	{
		DB("level num %d\n",levelNum);
		switch (levelNum)
		{

// RFW - I've moved most of the hut17 fma's to inventory.c
// (All apart from the 1st briefing, which auto-triggers once)
			case A1_HUT17_FMA:
				// we know that we have just entered this level
				// now from the inventory we decide what if any fma to play
				if(!gamePlayData->tasks_done[TASK_A1_BRIEF_FMA])
				{
					startFMA("SCENE1001");
					gamePlayData->A1fmaStatus[SCENE1001].playedFlag=FMA_PLAYED;
					gamePlayData->tasks_done[TASK_A1_BRIEF_FMA] = 1;
				}
				break;

			case TL_HUT17FMA_FMA:
				startFMA("NICKTEST");
				break;

			case TL_KITCHEN_FMA:	// these can be remove for final version
			case TL_PIEBARN_FMA:
			case TL_TUNNEL_FMA:
			case TL_GARDEN_FMA:
			case TL_WORKHUT1_FMA:
			case TL_WORKHUT2_FMA:
			case TL_WORKHUT3_FMA:
			case TL_WORKHUT4_FMA:
			case TL_COOP1_FMA:
			case TL_COOP2_FMA:
			case TL_HOUSEXT_FMA:
			case TL_TOOLEXT_FMA:
			case TL_LOUNGE_FMA:

				startFMA("NICKTEST");
				break;

			case A1_WORKHUT1_FMA:
				break;

			case A2_HUT17_FMA:
				part=0;
				items=0;

				if(!gamePlayData->tasks_done[TASK_A2_BRIEF_FMA])
				{
					SpecialCaseFma=ACT2FMA1;
					gamePlayData->A2fmaStatus[SCENE2001].playedFlag=FMA_PLAYED;
					gamePlayData->tasks_done[TASK_A2_BRIEF_FMA] = 1;
					startFMA("SCENE2001");
				}

				break;


			case A4_HUT17_FMA:
				part=0;
				items=0;

				if(!gamePlayData->tasks_done[TASK_A4_BRIEF_FMA])
				{
					SpecialCaseFma=ACT4FMA1;
					gamePlayData->A4fmaStatus[SCENE4001].playedFlag=FMA_PLAYED;
					gamePlayData->tasks_done[TASK_A4_BRIEF_FMA] = 1;
					startFMA("SCENE4001");
				}
				break;
			case A4_PIEBARN_FMA:
				a4PiebarnFmaChecks(0);
				break;


			//case A4_TUNNEL_FMA:
			//	a4TunnelFmaChecks(0);
			//	break;
		}
	}
}

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

int	fmaMenuNum;
int	fmaMenuChoice;

void	FMAselectionTest(void)
{
//	DB("fma test selection\n");
//	CRASH;
	fmaMenuNum=0;
	fmaMenuChoice=0;

	old_draw_routine=draw_routine;
	old_cycle_routine=cycle_routine;

	draw_routine = FMAtestMenuDraw;
	cycle_routine = FMAtestMenuCycle;

	switch(levinfo->level_number)
	{
		case	LEVNUMBER_A1_HUT17:
			fmaMenuNum=8;
			break;
		case	LEVNUMBER_A1_COOP1_N:
			fmaMenuNum=1;
			break;
		case	LEVNUMBER_A1_WORKHUT1:
			fmaMenuNum=6;
			break;
		case	LEVNUMBER_A1_GARDEN_N:
			fmaMenuNum=1;
			break;
		case	LEVNUMBER_A2_HUT17:
			fmaMenuNum=5;
			break;
		case	LEVNUMBER_A2_WORKHUT1:
			fmaMenuNum=5;
			break;
		case	LEVNUMBER_A2_WORKHUT2:
			fmaMenuNum=6;
			break;
		case	LEVNUMBER_A2_WORKHUT3:
			fmaMenuNum=4;
			break;
		case	LEVNUMBER_A2_COOP1_D:
			fmaMenuNum=1;
			break;
		case	LEVNUMBER_A2_COOP2_D:
			fmaMenuNum=1;
			break;
		case 	LEVNUMBER_A2_HOUSEXT_D:
			fmaMenuNum=5;
			break;
		case	LEVNUMBER_A2_TOOLEXT_D:
			fmaMenuNum=5;
			break;
		case	LEVNUMBER_A4_HUT17:
			fmaMenuNum=4;
			break;
		case	LEVNUMBER_A4_WORKHUT1:
			fmaMenuNum=2;
			break;
		case	LEVNUMBER_A4_WORKHUT2:
			fmaMenuNum=7;
			break;
		case	LEVNUMBER_A4_WORKHUT3:
			fmaMenuNum=7;
			break;
		case	LEVNUMBER_A4_WORKHUT4:
			fmaMenuNum=7;
			break;
		case	LEVNUMBER_A4_KITCHEN:
			fmaMenuNum=15;
			break;
		case	LEVNUMBER_A4_PIEBARN:
			fmaMenuNum=15;
			break;
		case	LEVNUMBER_A4_TUNNEL:
			fmaMenuNum=15;
			break;
		case	LEVNUMBER_A4_LOUNGE:
			fmaMenuNum=4;
			break;

	}

}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
void	FMAtestMenuCycle(void)
{
//	int	ypos;

	if (fmaMenuNum)
	{
//		ypos=-60+(fmaMenuChoice*15);
//		if (levinfo->level_number!=LEVNUMBER_A4_KITCHEN && levinfo->level_number!=LEVNUMBER_A4_PIEBARN && levinfo->level_number!=LEVNUMBER_A4_TUNNEL )
//			fontCentredMultiLine(font,-70,ypos,(512-40),"*", 128,128,128);
//		else
//			fontCentredMultiLine(font,-70,ypos-30,(512-40),"*", 128,128,128);

		if (padData.debounce[0] & PAD_UP )
		{
			if (fmaMenuChoice) fmaMenuChoice--;
			else fmaMenuChoice=fmaMenuNum-1;
		}
		if (padData.debounce[0] & PAD_DOWN )
		{
			if (fmaMenuChoice<(fmaMenuNum-1)) fmaMenuChoice++;
			else fmaMenuChoice=0;
		}
	}


	if (padData.debounce[0] & PAD_CROSS)
	{
		draw_routine = old_draw_routine;
		cycle_routine = old_cycle_routine;

		switch(levinfo->level_number)
		{
			case	LEVNUMBER_A1_HUT17:
				switch(fmaMenuChoice)
				{
					case 0:
						startFMA("SCENE1001");
						break;
					case 1:
						startFMA("SCENE1002");
						break;
					case 2:
						startFMA("SCENE1003");
						break;
					case 3:
						startFMA("SCENE1004");
						break;
					case 4:
						startFMA("SCENE1005");
						break;
					case 5:
						startFMA("SCENE1006");
						break;
					case 6:
						startFMA("SCENE1007");
						break;
					case 7:
						startFMA("SCENE1008");
						break;
				}
			case	LEVNUMBER_A1_COOP1_N:
				startFMA("WCUT_G");
				break;
			case	LEVNUMBER_A1_WORKHUT1:
				switch(fmaMenuChoice)
				{
					case 0:
						startFMA("SCENE1010");
						break;
					case 1:
						startFMA("SCENE1011");
						break;
					case 2:
						startFMA("SCENE1012");
						break;
					case 3:
						startFMA("SCENE1013");
						break;
					case 4:
						startFMA("SCENE1014");
						break;
					case 5:
						startFMA("SCENE1015");
						break;
				}
				break;
			case	LEVNUMBER_A1_GARDEN_N:
				startFMA("WASH_G");
				break;
			case	LEVNUMBER_A2_HUT17:
				switch(fmaMenuChoice)
				{
					case 0:
						SpecialCaseFma=ACT2FMA1;
						startFMA("SCENE2001");
						break;
					case 1:
						startFMA("SCENE2003");
						break;
					case 2:
						startFMA("SCENE2004");
						break;
					case 3:
						startFMA("SCENE2005");
						break;
					case 4:
						SpecialCaseFma=ACT2FMA2;
						startFMA("SCENE2009");
						break;
				}
				break;
			case	LEVNUMBER_A2_WORKHUT1:
				switch(fmaMenuChoice)
				{
					case 0:
						startFMA("SCENE2019");
						break;
					case 1:
						startFMA("SCENE2020");
						break;
					case 2:
						startFMA("SCENE2021");
						break;
					case 3:
						startFMA("SCENE2022");
						break;
					case 4:
						startFMA("SCENE2023");
						break;
					case 5:
						startFMA("SCENE2024");
						break;
				}
				break;
			case	LEVNUMBER_A2_WORKHUT2:
				switch(fmaMenuChoice)
				{
					case 0:
						startFMA("SCENE2040");
						break;
					case 1:
						startFMA("SCENE2041");
						break;
					case 2:
						startFMA("SCENE2042");
						break;
					case 3:
						startFMA("SCENE2043");
						break;
					case 4:
						startFMA("SCENE2044");
						break;
					case 5:
						startFMA("SCENE2045");
						break;
				}
				break;
			case	LEVNUMBER_A2_WORKHUT3:
				switch(fmaMenuChoice)
				{
					case 0:
						startFMA("SCENE2070");
						break;
					case 1:
						startFMA("SCENE2071");
						break;
					case 2:
						startFMA("SCENE2074");
						break;
					case 3:
						startFMA("SCENE2075");
						break;
				}
				break;
			case	LEVNUMBER_A2_COOP1_D:
				startFMA("WCUT_G");
				break;
			case	LEVNUMBER_A2_COOP2_D:
				startFMA("DIG_G");
				break;
			case 	LEVNUMBER_A2_HOUSEXT_D:
				switch(fmaMenuChoice)
				{
					case 0:
						startFMA("SCENE8001");
						break;
					case 1:
						startFMA("SCENE8002");
						break;
					case 2:
						startFMA("SCENE8003");
						break;
					case 3:
						startFMA("SCENE8004");
						break;
					case 4:
						startFMA("SCENE8005");
						break;
				}
				break;
			case	LEVNUMBER_A2_TOOLEXT_D:
				switch(fmaMenuChoice)
				{
					case 0:
						startFMA("SCENE8011");
						break;
					case 1:
						startFMA("SCENE8012");
						break;
					case 2:
						startFMA("SCENE8013");
						break;
					case 3:
						startFMA("SCENE8014");
						break;
					case 4:
						startFMA("SCENE8015");
						break;
				}
				break;
			case	LEVNUMBER_A4_HUT17:
				switch(fmaMenuChoice)
				{
					case 0:
						SpecialCaseFma=ACT4FMA1;
						startFMA("SCENE4001");
						break;
					case 1:
						startFMA("SCENE4003");
						break;
					case 2:
						startFMA("SCENE4004");
						break;
					case 3:
						startFMA("SCENE4005");
						break;
				}
				break;
			case	LEVNUMBER_A4_WORKHUT1:
				switch(fmaMenuChoice)
				{
					case 0:
						startFMA("SCENE4019");
						break;
					case 1:
						startFMA("SCENE4020");
						break;
				}
				break;
			case	LEVNUMBER_A4_WORKHUT2:
				switch(fmaMenuChoice)
				{
					case 0:
						startFMA("SCENE4040");
						break;
					case 1:
						startFMA("SCENE4041");
						break;
					case 2:
						startFMA("SCENE4042");
						break;
					case 3:
						startFMA("SCENE4043");
						break;
					case 4:
						startFMA("SCENE4044");
						break;
					case 5:
						startFMA("SCENE4045");
						break;
					case 6:
						startFMA("SCENE4046");
						break;
				}
				break;
			case	LEVNUMBER_A4_WORKHUT3:
				switch(fmaMenuChoice)
				{
					case 0:
						startFMA("SCENE4060");
						break;
					case 1:
						startFMA("SCENE4061");
						break;
					case 2:
						startFMA("SCENE4062");
						break;
					case 3:
						startFMA("SCENE4063");
						break;
					case 4:
						startFMA("SCENE4064");
						break;
					case 5:
						startFMA("SCENE4065");
						break;
					case 6:
						startFMA("SCENE4066");
						break;
				}
				break;
			case	LEVNUMBER_A4_WORKHUT4:
				switch(fmaMenuChoice)
				{
					case 0:
						startFMA("SCENE4080");
						break;
					case 1:
						startFMA("SCENE4081");
						break;
					case 2:
						startFMA("SCENE4082");
						break;
					case 3:
						startFMA("SCENE4083");
						break;
					case 4:
						startFMA("SCENE4084");
						break;
					case 5:
						startFMA("SCENE4085");
						break;
					case 6:
						startFMA("SCENE4086");
						break;
				}
				break;
			case	LEVNUMBER_A4_KITCHEN:
				switch(fmaMenuChoice)
				{
					case 0:
						startFMA("SCENE4200");
						break;
					case 1:
						startFMA("SCENE4201");
						break;
					case 2:
						startFMA("SCENE4202");
						break;
					case 3:
						startFMA("SCENE4203");
						break;
					case 4:
						startFMA("SCENE4210");
						break;
					case 5:
						startFMA("SCENE4211");
						break;
					case 6:
						startFMA("SCENE4212");
						break;
					case 7:
						startFMA("SCENE4213");
						break;
					case 8:
						startFMA("SCENE4214");
						break;
					case 9:
						startFMA("SCENE4215");
						break;
					case 10:
						startFMA("SCENE4216");
						break;
					case 11:
						startFMA("SCENE4217");
						break;
					case 12:
						startFMA("SCENE4218");
						break;
					case 13:
						startFMA("SCENE4219");
						break;
					case 14:
						startFMA("SCENE4220");
						break;
				}
				break;
			case	LEVNUMBER_A4_PIEBARN:
				switch(fmaMenuChoice)
				{
					case 0:
						startFMA("SCENE4300");
						break;
					case 1:
						startFMA("SCENE4301");
						break;
					case 2:
						startFMA("SCENE4302");
						break;
					case 3:
						startFMA("SCENE4303");
						break;
					case 4:
						startFMA("SCENE4310");
						break;
					case 5:
						startFMA("SCENE4311");
						break;
					case 6:
						startFMA("SCENE4312");
						break;
					case 7:
						startFMA("SCENE4313");
						break;
					case 8:
						startFMA("SCENE4314");
						break;
					case 9:
						startFMA("SCENE4315");
						break;
					case 10:
						startFMA("SCENE4316");
						break;
					case 11:
						startFMA("SCENE4317");
						break;
					case 12:
						startFMA("SCENE4318");
						break;
					case 13:
						startFMA("SCENE4319");
						break;
					case 14:
						startFMA("SCENE4320");
						break;
				}
				break;
			case	LEVNUMBER_A4_TUNNEL:
				switch(fmaMenuChoice)
				{
					case 0:
						startFMA("SCENE4400");
						break;
					case 1:
						startFMA("SCENE4401");
						break;
					case 2:
						startFMA("SCENE4402");
						break;
					case 3:
						startFMA("SCENE4403");
						break;
					case 4:
						startFMA("SCENE4410");
						break;
					case 5:
						startFMA("SCENE4411");
						break;
					case 6:
						startFMA("SCENE4412");
						break;
					case 7:
						startFMA("SCENE4413");
						break;
					case 8:
						startFMA("SCENE4414");
						break;
					case 9:
						startFMA("SCENE4415");
						break;
					case 10:
						startFMA("SCENE4416");
						break;
					case 11:
						startFMA("SCENE4417");
						break;
					case 12:
						startFMA("SCENE4418");
						break;
					case 13:
						startFMA("SCENE4419");
						break;
					case 14:
						startFMA("SCENE4420");
						break;
				}
				break;
			case	LEVNUMBER_A4_LOUNGE:
				switch(fmaMenuChoice)
				{
					case 0:
						startFMA("FAIL01");
						break;
					case 1:
						startFMA("FAIL02");
						break;
					case 2:
						startFMA("FAIL03");
						break;
					case 3:
						startFMA("WORKS");
						break;
				}
				break;

			default:
				break;
		}
	}

#ifdef DREAMCAST
	if (padData.debounce[0] & PAD_CIRCLE)
#else
	if (padData.debounce[0] & PAD_TRIANGLE)
#endif
	{
		draw_routine = old_draw_routine;
		cycle_routine = old_cycle_routine;
	}


}

/////////////////////////////////////////////////////////////////////////////////////////////////////////
void	FMAtestMenuDraw(void)
{

	int	ypos;

	if (fmaMenuNum)
	{
		ypos=-60+(fmaMenuChoice*15);
		if (levinfo->level_number!=LEVNUMBER_A4_KITCHEN && levinfo->level_number!=LEVNUMBER_A4_PIEBARN && levinfo->level_number!=LEVNUMBER_A4_TUNNEL )
			fontCentredMultiLine(font,-80,ypos,(512-40),"*", 128,128,128);
		else
			fontCentredMultiLine(font,-80,ypos-30,(512-40),"*", 128,128,128);
	}


	if (levinfo->level_number!=LEVNUMBER_A4_KITCHEN && levinfo->level_number!=LEVNUMBER_A4_PIEBARN && levinfo->level_number!=LEVNUMBER_A4_TUNNEL )
		fontCentredMultiLine(font,0,-80,(512-40),"Fma's in level", 128,128,128);
	else
		fontCentredMultiLine(font,0,-110,(512-40),"Fma's in level", 128,128,128);



	switch(levinfo->level_number)
	{
		case	LEVNUMBER_A1_HUT17:
			fontCentredMultiLine(font,0,-60,(512-40),"scene 1001", 128,128,128);
			fontCentredMultiLine(font,0,-45,(512-40),"scene 1002", 128,128,128);
			fontCentredMultiLine(font,0,-30,(512-40),"scene 1003", 128,128,128);
			fontCentredMultiLine(font,0,-15,(512-40),"scene 1004", 128,128,128);
			fontCentredMultiLine(font,0,0,(512-40),"scene 1005", 128,128,128);
			fontCentredMultiLine(font,0,15,(512-40),"scene 1006", 128,128,128);
			fontCentredMultiLine(font,0,30,(512-40),"scene 1007", 128,128,128);
			fontCentredMultiLine(font,0,45,(512-40),"scene 1008", 128,128,128);
			break;
		case	LEVNUMBER_A1_COOP1_N:
			fontCentredMultiLine(font,0,-60,(512-40),"wcut_g", 128,128,128);
			break;
		case	LEVNUMBER_A1_WORKHUT1:
			fontCentredMultiLine(font,0,-60,(512-40),"scene 1010", 128,128,128);
			fontCentredMultiLine(font,0,-45,(512-40),"scene 1011", 128,128,128);
			fontCentredMultiLine(font,0,-30,(512-40),"scene 1012", 128,128,128);
			fontCentredMultiLine(font,0,-15,(512-40),"scene 1013", 128,128,128);
			fontCentredMultiLine(font,0,0,(512-40),"scene 1014", 128,128,128);
			fontCentredMultiLine(font,0,15,(512-40),"scene 1015", 128,128,128);
			break;
		case	LEVNUMBER_A1_GARDEN_N:
			fontCentredMultiLine(font,0,-60,(512-40),"wash_g", 128,128,128);
			break;
		case	LEVNUMBER_A2_HUT17:
			fontCentredMultiLine(font,0,-60,(512-40),"scene 2001", 128,128,128);
			fontCentredMultiLine(font,0,-45,(512-40),"scene 2003", 128,128,128);
			fontCentredMultiLine(font,0,-30,(512-40),"scene 2004", 128,128,128);
			fontCentredMultiLine(font,0,-15,(512-40),"scene 2005", 128,128,128);
			fontCentredMultiLine(font,0,0,(512-40),"scene 2009", 128,128,128);
			break;
		case	LEVNUMBER_A2_WORKHUT1:
			fontCentredMultiLine(font,0,-60,(512-40),"scene 2019", 128,128,128);
			fontCentredMultiLine(font,0,-45,(512-40),"scene 2020", 128,128,128);
			fontCentredMultiLine(font,0,-30,(512-40),"scene 2021", 128,128,128);
			fontCentredMultiLine(font,0,-15,(512-40),"scene 2022", 128,128,128);
			fontCentredMultiLine(font,0,0,(512-40),"scene 2023", 128,128,128);
			//fontCentredMultiLine(font,0,15,(512-40),"scene 2024", 128,128,128);
			break;
		case	LEVNUMBER_A2_WORKHUT2:
			fontCentredMultiLine(font,0,-60,(512-40),"scene 2040", 128,128,128);
			fontCentredMultiLine(font,0,-45,(512-40),"scene 2041", 128,128,128);
			fontCentredMultiLine(font,0,-30,(512-40),"scene 2042", 128,128,128);
			fontCentredMultiLine(font,0,-15,(512-40),"scene 2043", 128,128,128);
			fontCentredMultiLine(font,0,0,(512-40),"scene 2044", 128,128,128);
			fontCentredMultiLine(font,0,15,(512-40),"scene 2045", 128,128,128);
			break;

		case	LEVNUMBER_A2_WORKHUT3:
			fontCentredMultiLine(font,0,-60,(512-40),"scene 2070", 128,128,128);
			fontCentredMultiLine(font,0,-45,(512-40),"scene 2071", 128,128,128);
			fontCentredMultiLine(font,0,-30,(512-40),"scene 2074", 128,128,128);
			fontCentredMultiLine(font,0,-15,(512-40),"scene 2075", 128,128,128);
			break;
		case	LEVNUMBER_A2_COOP1_D:
			fontCentredMultiLine(font,0,-60,(512-40),"wcut_g", 128,128,128);
			break;
		case	LEVNUMBER_A2_COOP2_D:
			fontCentredMultiLine(font,0,-60,(512-40),"dig_g", 128,128,128);
			break;
		case 	LEVNUMBER_A2_HOUSEXT_D:
			fontCentredMultiLine(font,0,-60,(512-40),"scene 8001", 128,128,128);
			fontCentredMultiLine(font,0,-45,(512-40),"scene 8002", 128,128,128);
			fontCentredMultiLine(font,0,-30,(512-40),"scene 8003", 128,128,128);
			fontCentredMultiLine(font,0,-15,(512-40),"scene 8004", 128,128,128);
			fontCentredMultiLine(font,0,0,(512-40),"scene 8005", 128,128,128);
			break;
		case	LEVNUMBER_A2_TOOLEXT_D:
			fontCentredMultiLine(font,0,-60,(512-40),"scene 8011", 128,128,128);
			fontCentredMultiLine(font,0,-45,(512-40),"scene 8012", 128,128,128);
			fontCentredMultiLine(font,0,-30,(512-40),"scene 8013", 128,128,128);
			fontCentredMultiLine(font,0,-15,(512-40),"scene 8014", 128,128,128);
			fontCentredMultiLine(font,0,0,(512-40),"scene 8015", 128,128,128);
			break;
		case	LEVNUMBER_A4_HUT17:
			fontCentredMultiLine(font,0,-60,(512-40),"scene 4001", 128,128,128);
			fontCentredMultiLine(font,0,-45,(512-40),"scene 4003", 128,128,128);
			fontCentredMultiLine(font,0,-30,(512-40),"scene 4004", 128,128,128);
			fontCentredMultiLine(font,0,-15,(512-40),"scene 4005", 128,128,128);
			break;
		case	LEVNUMBER_A4_WORKHUT1:
			fontCentredMultiLine(font,0,-60,(512-40),"scene 4019", 128,128,128);
			fontCentredMultiLine(font,0,-45,(512-40),"scene 4020", 128,128,128);
			break;
		case	LEVNUMBER_A4_WORKHUT2:
			fontCentredMultiLine(font,0,-60,(512-40),"scene 4040", 128,128,128);
			fontCentredMultiLine(font,0,-45,(512-40),"scene 4041", 128,128,128);
			fontCentredMultiLine(font,0,-30,(512-40),"scene 4042", 128,128,128);
			fontCentredMultiLine(font,0,-15,(512-40),"scene 4043", 128,128,128);
			fontCentredMultiLine(font,0,0,(512-40),"scene 4044", 128,128,128);
			fontCentredMultiLine(font,0,15,(512-40),"scene 4045", 128,128,128);
			fontCentredMultiLine(font,0,30,(512-40),"scene 4046", 128,128,128);
			break;
		case	LEVNUMBER_A4_WORKHUT3:
			fontCentredMultiLine(font,0,-60,(512-40),"scene 4060", 128,128,128);
			fontCentredMultiLine(font,0,-45,(512-40),"scene 4061", 128,128,128);
			fontCentredMultiLine(font,0,-30,(512-40),"scene 4062", 128,128,128);
			fontCentredMultiLine(font,0,-15,(512-40),"scene 4063", 128,128,128);
			fontCentredMultiLine(font,0,0,(512-40),"scene 4064", 128,128,128);
			fontCentredMultiLine(font,0,15,(512-40),"scene 4065", 128,128,128);
			fontCentredMultiLine(font,0,30,(512-40),"scene 4066", 128,128,128);
			break;
		case	LEVNUMBER_A4_WORKHUT4:
			fontCentredMultiLine(font,0,-60,(512-40),"scene 4080", 128,128,128);
			fontCentredMultiLine(font,0,-45,(512-40),"scene 4081", 128,128,128);
			fontCentredMultiLine(font,0,-30,(512-40),"scene 4082", 128,128,128);
			fontCentredMultiLine(font,0,-15,(512-40),"scene 4083", 128,128,128);
			fontCentredMultiLine(font,0,0,(512-40),"scene 4084", 128,128,128);
			fontCentredMultiLine(font,0,15,(512-40),"scene 4085", 128,128,128);
			fontCentredMultiLine(font,0,30,(512-40),"scene 4086", 128,128,128);
			break;
		case	LEVNUMBER_A4_KITCHEN:
			fontCentredMultiLine(font,0,-90,(512-40),"scene 4200", 128,128,128);
			fontCentredMultiLine(font,0,-75,(512-40),"scene 4201", 128,128,128);
			fontCentredMultiLine(font,0,-60,(512-40),"scene 4202", 128,128,128);
			fontCentredMultiLine(font,0,-45,(512-40),"scene 4203", 128,128,128);
			fontCentredMultiLine(font,0,-30,(512-40),"scene 4210", 128,128,128);
			fontCentredMultiLine(font,0,-15,(512-40),"scene 4211", 128,128,128);
			fontCentredMultiLine(font,0,0,(512-40),"scene 4212", 128,128,128);
			fontCentredMultiLine(font,0,15,(512-40),"scene 4213", 128,128,128);
			fontCentredMultiLine(font,0,30,(512-40),"scene 4214", 128,128,128);
			fontCentredMultiLine(font,0,45,(512-40),"scene 4215", 128,128,128);
			fontCentredMultiLine(font,0,60,(512-40),"scene 4216", 128,128,128);
			fontCentredMultiLine(font,0,75,(512-40),"scene 4217", 128,128,128);
			fontCentredMultiLine(font,0,90,(512-40),"scene 4218", 128,128,128);
			fontCentredMultiLine(font,0,105,(512-40),"scene 4219", 128,128,128);
			fontCentredMultiLine(font,0,120,(512-40),"scene 4220", 128,128,128);
			break;
		case	LEVNUMBER_A4_PIEBARN:
			fontCentredMultiLine(font,0,-90,(512-40),"scene 4300", 128,128,128);
			fontCentredMultiLine(font,0,-75,(512-40),"scene 4301", 128,128,128);
			fontCentredMultiLine(font,0,-60,(512-40),"scene 4302", 128,128,128);
			fontCentredMultiLine(font,0,-45,(512-40),"scene 4303", 128,128,128);
			fontCentredMultiLine(font,0,-30,(512-40),"scene 4310", 128,128,128);
			fontCentredMultiLine(font,0,-15,(512-40),"scene 4311", 128,128,128);
			fontCentredMultiLine(font,0,0,(512-40),"scene 4312", 128,128,128);
			fontCentredMultiLine(font,0,15,(512-40),"scene 4313", 128,128,128);
			fontCentredMultiLine(font,0,30,(512-40),"scene 4314", 128,128,128);
			fontCentredMultiLine(font,0,45,(512-40),"scene 4315", 128,128,128);
			fontCentredMultiLine(font,0,60,(512-40),"scene 4316", 128,128,128);
			fontCentredMultiLine(font,0,75,(512-40),"scene 4317", 128,128,128);
			fontCentredMultiLine(font,0,90,(512-40),"scene 4318", 128,128,128);
			fontCentredMultiLine(font,0,105,(512-40),"scene 4319", 128,128,128);
			fontCentredMultiLine(font,0,120,(512-40),"scene 4320", 128,128,128);
			break;
		case	LEVNUMBER_A4_TUNNEL:
			fontCentredMultiLine(font,0,-90,(512-40),"scene 4400", 128,128,128);
			fontCentredMultiLine(font,0,-75,(512-40),"scene 4401", 128,128,128);
			fontCentredMultiLine(font,0,-60,(512-40),"scene 4402", 128,128,128);
			fontCentredMultiLine(font,0,-45,(512-40),"scene 4403", 128,128,128);
			fontCentredMultiLine(font,0,-30,(512-40),"scene 4410", 128,128,128);
			fontCentredMultiLine(font,0,-15,(512-40),"scene 4411", 128,128,128);
			fontCentredMultiLine(font,0,0,(512-40),"scene 4412", 128,128,128);
			fontCentredMultiLine(font,0,15,(512-40),"scene 4413", 128,128,128);
			fontCentredMultiLine(font,0,30,(512-40),"scene 4414", 128,128,128);
			fontCentredMultiLine(font,0,45,(512-40),"scene 4415", 128,128,128);
			fontCentredMultiLine(font,0,60,(512-40),"scene 4416", 128,128,128);
			fontCentredMultiLine(font,0,75,(512-40),"scene 4417", 128,128,128);
			fontCentredMultiLine(font,0,90,(512-40),"scene 4418", 128,128,128);
			fontCentredMultiLine(font,0,105,(512-40),"scene 4419", 128,128,128);
			fontCentredMultiLine(font,0,120,(512-40),"scene 4420", 128,128,128);
			break;
		case	LEVNUMBER_A4_LOUNGE:
			fontCentredMultiLine(font,0,-60,(512-40),"fail01", 128,128,128);
			fontCentredMultiLine(font,0,-45,(512-40),"fail02", 128,128,128);
			fontCentredMultiLine(font,0,-30,(512-40),"fail03", 128,128,128);
			fontCentredMultiLine(font,0,-15,(512-40),"works", 128,128,128);
			break;
		default:
			fontCentredMultiLine(font,0,-60,(512-40),"This level has no fma's", 128,128,128);
			break;
	}
}
