/******************************************************************************************
	CRTEST PS   (c) 1999-2001 ISL

	pause.c:			Very minimalist pause mode
******************************************************************************************/
#include "global.h"
#include "main.h"
#include "menu.h"
#include "gametext.h"
#include "map_draw.h"
#include "overlays.h"
#include "maths.h"
#include "card.h"
#include "inventory.h"
#include "scenics.h"
#include "sptstream.h"
#include "demo.h"
#include "enemies.h"
#include "charactr.h"
#include "map_play.h"
#include "puzzles.h"
#include "fma.h"
#include "charactr.h"

// Bad bad person who ever did this.....keep PSX stuff in global please....
#ifndef _WINDOWS
#include <libgpu.h>
#endif

#include "pause.h"
#include "map_play.h"
#include "overlays.h"
#include "options.h"
#include "sound.h"
#include "dualshock.h"
#include "fireworks.h"
#include "egglaying.h"
#include "seesaw.h"
#include "catapult.h"
#include "pause.h"
#include "startup.h"
#include "crate.h"
#include "dogchase.h"
#include "wings.h"
#include "construct.h"
#include "engine.h"

extern void dogchaseFree(void);
extern void mapplayEnd(void);

extern KMSURFACEDESC		PrimarySurfaceDesc;		/* Primary frame buffer			*/
extern KMSURFACEDESC		BackSurfaceDesc;		/* Back-buffer frame buffer		*/


#define PAUSE_NUM_OPTIONS (5)
#define PAUSE_MENU_Y_POSITION -76
int options_colour = 0;
int options_colouradd = 8;
int pause_levelplaying;

int pause_option;
extern VOID_SUBROUTINE old_draw_routine;
extern VOID_SUBROUTINE old_cycle_routine;
char quit_confirmation;
TextureType *pause_wood;

int pauselist[PAUSE_NUM_OPTIONS+1] =		// Text used in the pause menu + title
{	
	TEXTSTR_MENU_PAUSED,
	TEXTSTR_OPTIONS_HEADING_RETURN,
	TEXTSTR_OPTIONS_PAUSE_QUIT,
	TEXTSTR_OPTIONS_MENU_SFXVOLUME,
	TEXTSTR_OPTIONS_MENU_MUSICVOLUME,		
	TEXTSTR_OPTIONS_CONTROLLER_VIBRATION
};

void pauseCycle(void)
{
//	debugPrintf("Hi\n");
	if(!quit_confirmation)
	{
		if(pReadPad->debounce[0] & PAD_DOWN)
		{
			pause_option++;
			if(pause_option>PAUSE_NUM_OPTIONS-1)
				pause_option = 0;
		}

		if(pReadPad->debounce[0] & PAD_UP)
		{
			pause_option--;
			if(pause_option<0)
				pause_option = PAUSE_NUM_OPTIONS-1;
		}

		if(pReadPad->debounce[0] & (PAD_START | PAD_CROSS))
		{
			switch(pause_option)
			{
				case 0:
					pauseEndReturnToGame();
					break;
				case 1:
					pReadPad->debounce[0] = 0;
					quit_confirmation = 1;
					pause_option = 1;
					break;
				case 2:
					break;
				case 3:
					break;
				case 4:
					if(pReadPad->shockEnable) pReadPad->shockEnable=0;
					else 
					{
						pReadPad->shockEnable = 1;
						pReadPad->currShock[0]=117;		// Test vibration
						pReadPad->shock[0]=1280;
						pReadPad->shockDiv[0]=128;
						pReadPad->buzzTime[0]=19;
					}
					optionData.control.vibration=pReadPad->shockEnable;
					optionsHitOptions(OPTIONS_HIT_SHOCKENABLE);
					break;
				default:
					break;
			}
		}
	}

	else
	{	
		if(pReadPad->debounce[0] & PAD_DOWN)
		{
			pause_option++;
			if(pause_option>1)
				pause_option = 0;
		}

		if(pReadPad->debounce[0] & PAD_UP)
		{
			pause_option--;
			if(pause_option<0)
				pause_option = 1;
		}
		if(pReadPad->debounce[0] & (PAD_START | PAD_CROSS))
		{
			switch(pause_option)
			{
				case 0:
					pauseEndQuitGame();
					break;

				case 1:
					quit_confirmation = 0;//pauseEndReturnToGame();
					break;

				default:
					break;
			}
		}
	}

	options_colour+=options_colouradd;

	if((options_colour<0) ||(options_colour>64))
		options_colouradd=-options_colouradd;

	pauseOptionsCycle();
}

void copyFrontToBack()
{
	return;

	vertices_GT4[0].fX = 0;
	vertices_GT4[0].fY = 0;
	vertices_GT4[0].u.fInvW = 1.0 / ((float)(1));//d1));
	vertices_GT4[0].fU = 0;//(float)poly->u0 / width;
	vertices_GT4[0].fV = 0;//(float)poly->v0 / height;
	vertices_GT4[0].uBaseRGB.dwPacked = RGBA(128,128,128,255);

	vertices_GT4[1].fX = 0;
	vertices_GT4[1].fY = 480;
	vertices_GT4[1].u.fInvW = 1.0 / ((float)(1));//d3));
	vertices_GT4[1].fU = 1;//640;//(float)poly->u1 / width;
	vertices_GT4[1].fV = 0;//(float)poly->v1 / height;
	vertices_GT4[1].uBaseRGB.dwPacked = RGBA(128,128,128,255);

	vertices_GT4[2].fX = 640;
	vertices_GT4[2].fY = 0;
	vertices_GT4[2].u.fInvW = 1.0 / ((float)(1));//d2));
	vertices_GT4[2].fU = 0;//(float)poly->u2 / width;
	vertices_GT4[2].fV = 1;//480;//(float)poly->v2 / height;
	vertices_GT4[2].uBaseRGB.dwPacked = RGBA(128,128,128,255);

	vertices_GT4[3].fX = 640;
	vertices_GT4[3].fY = 480;
	vertices_GT4[3].u.fInvW = 1.0 / ((float)(1));//d4));
	vertices_GT4[3].fU = 1;//640;//(float)poly->u3 / width;
	vertices_GT4[3].fV = 1;//480;//(float)poly->v3 / height;
	vertices_GT4[3].uBaseRGB.dwPacked = RGBA(128,128,128,255);

																	//BackSurfaceDesc	PrimarySurfaceDesc
	kmChangeStripTextureSurface(&StripHead_GT4,KM_IMAGE_PARAM1,&PrimarySurfaceDesc);//currSurface);
//	stripGT4textureID = poly->tpage;
	kmStartStrip(&vertexBufferDesc, &StripHead_GT4);	

	kmSetVertex(&vertexBufferDesc, &vertices_GT4[0], KM_VERTEXTYPE_03, sizeof(KMVERTEX_03));
	kmSetVertex(&vertexBufferDesc, &vertices_GT4[1], KM_VERTEXTYPE_03, sizeof(KMVERTEX_03));
	kmSetVertex(&vertexBufferDesc, &vertices_GT4[2], KM_VERTEXTYPE_03, sizeof(KMVERTEX_03));	
	kmSetVertex(&vertexBufferDesc, &vertices_GT4[3], KM_VERTEXTYPE_03, sizeof(KMVERTEX_03));	
	kmEndStrip(&vertexBufferDesc);


			  /*
	kmCreateTextureSurface(&smallSurface, 32, 32, KM_TEXTURE_RGB565|KM_TEXTURE_RECTANGLE);

	sizeOfTexture = 640*480*24;
	blockSize=32*32*24;

	i = 0;
//Load the first BUFFSIZE*32 byte block into pTexture;
	for(j=0;j<)


	while(KMSTATUS_SUCCESS == kmLoadTextureBlock(
		&smallSurface,
		pTexture,
		i++,
		BUFFSIZE
		)) {
Load the next BUFFSIZE*32 byte block into pTexture;
}
				*/

}


void pauseDraw(void)
{
	if(!quit_confirmation)
	{
		fontPrintCentred(font,0,PAUSE_MENU_Y_POSITION+6,fontUpper(TEXTSTR(TEXTSTR_MENU_PAUSED)),96,96,128);

		if(pause_option==0)
		{
			fontPrintCentred(font,0,PAUSE_MENU_Y_POSITION+28,fontUpper(TEXTSTR(pauselist[1])),64+options_colour,64+options_colour,64+options_colour);
			fontPrintCentred(font,0,PAUSE_MENU_Y_POSITION+46,TEXTSTR(pauselist[2]),48,48,48);
			fontPrint(font,-99,PAUSE_MENU_Y_POSITION+64,fontUpper(TEXTSTR(pauselist[3])),48,48,48);
			fontPrint(font,-123,PAUSE_MENU_Y_POSITION+82,fontUpper(TEXTSTR(pauselist[4])),48,48,48);
			fontPrint(font,-89,PAUSE_MENU_Y_POSITION+100,fontUpper(TEXTSTR(pauselist[5])),48,48,48);
		}
		else if(pause_option==1)
		{
			fontPrintCentred(font,0,PAUSE_MENU_Y_POSITION+28,fontUpper(TEXTSTR(pauselist[1])),48,48,48);
			fontPrintCentred(font,0,PAUSE_MENU_Y_POSITION+46,TEXTSTR(pauselist[2]),64+options_colour,64+options_colour,64+options_colour);
			fontPrint(font,-99,PAUSE_MENU_Y_POSITION+64,fontUpper(TEXTSTR(pauselist[3])),48,48,48);
			fontPrint(font,-123,PAUSE_MENU_Y_POSITION+82,fontUpper(TEXTSTR(pauselist[4])),48,48,48);
			fontPrint(font,-89,PAUSE_MENU_Y_POSITION+100,fontUpper(TEXTSTR(pauselist[5])),48,48,48);
		}
		else if(pause_option==2)
		{
			fontPrintCentred(font,0,PAUSE_MENU_Y_POSITION+28,fontUpper(TEXTSTR(pauselist[1])),48,48,48);
			fontPrintCentred(font,0,PAUSE_MENU_Y_POSITION+46,TEXTSTR(pauselist[2]),48,48,48);
			fontPrint(font,-99,PAUSE_MENU_Y_POSITION+64,fontUpper(TEXTSTR(pauselist[3])),64+options_colour,64+options_colour,64+options_colour);
			fontPrint(font,-123,PAUSE_MENU_Y_POSITION+82,fontUpper(TEXTSTR(pauselist[4])),48,48,48);
			fontPrint(font,-89,PAUSE_MENU_Y_POSITION+100,fontUpper(TEXTSTR(pauselist[5])),48,48,48);
		}
		else if(pause_option==3)
		{
			fontPrintCentred(font,0,PAUSE_MENU_Y_POSITION+28,fontUpper(TEXTSTR(pauselist[1])),48,48,48);
			fontPrintCentred(font,0,PAUSE_MENU_Y_POSITION+46,TEXTSTR(pauselist[2]),48,48,48);
			fontPrint(font,-99,PAUSE_MENU_Y_POSITION+64,fontUpper(TEXTSTR(pauselist[3])),48,48,48);
			fontPrint(font,-123,PAUSE_MENU_Y_POSITION+82,fontUpper(TEXTSTR(pauselist[4])),64+options_colour,64+options_colour,64+options_colour);
			fontPrint(font,-89,PAUSE_MENU_Y_POSITION+100,fontUpper(TEXTSTR(pauselist[5])),48,48,48);
		}
		else if(pause_option==4)
		{
			fontPrintCentred(font,0,PAUSE_MENU_Y_POSITION+28,fontUpper(TEXTSTR(pauselist[1])),48,48,48);
			fontPrintCentred(font,0,PAUSE_MENU_Y_POSITION+46,TEXTSTR(pauselist[2]),48,48,48);
			fontPrint(font,-99,PAUSE_MENU_Y_POSITION+64,fontUpper(TEXTSTR(pauselist[3])),48,48,48);
			fontPrint(font,-123,PAUSE_MENU_Y_POSITION+82,fontUpper(TEXTSTR(pauselist[4])),48,48,48);
			fontPrint(font,-89,PAUSE_MENU_Y_POSITION+100,fontUpper(TEXTSTR(pauselist[5])),64+options_colour,64+options_colour,64+options_colour);
		}

		pauseDrawOptions();
	}

	else
	{
		fontPrintCentred(font,0,-48,TEXTSTR(TEXTSTR_OPTIONS_PAUSE_QUIT),96,96,128);
		switch(pause_option)
		{
			case 0:
				fontPrintCentred(font,0,-6,fontUpper(TEXTSTR(TEXTSTR_YES)),64+options_colour,64+options_colour,64+options_colour);
				fontPrintCentred(font,0,10,fontUpper(TEXTSTR(TEXTSTR_NO)),48,48,48);
				break;
			case 1:
				fontPrintCentred(font,0,-6,fontUpper(TEXTSTR(TEXTSTR_YES)),48,48,48);
				fontPrintCentred(font,0,10,fontUpper(TEXTSTR(TEXTSTR_NO)),64+options_colour,64+options_colour,64+options_colour);
				break;
			default:
				break;
		}
	}

	// Need something to cover the background where the text is, as it aint being redrawn, and the planks were handy as they 
	// are used for the inventory and are now in the generic sprite bank...

	overlaySprite(pause_wood,-128,PAUSE_MENU_Y_POSITION, 4, 0x202020);
	overlaySprite(pause_wood,0,PAUSE_MENU_Y_POSITION, 4, 0x202020);
	overlaySprite(pause_wood,-128,PAUSE_MENU_Y_POSITION+64, 4, 0x202020);
	overlaySprite(pause_wood,0,PAUSE_MENU_Y_POSITION+64, 4, 0x202020);

	optionsDrawBoxOutline(-129, PAUSE_MENU_Y_POSITION-1,257,129,0x606060);
}



void pauseStart(void)
{	

	sfxStopChannel(-1);

	debugPrintf("Pausing!! Please wait while I crash spectacularly");
	sound_XA_PauseForLoading();
	debugPrintf(".");
	old_draw_routine = draw_routine;
	debugPrintf(".");

	old_cycle_routine = cycle_routine;
	debugPrintf(".");

	pause_option = 0;
	draw_routine = pauseDraw;
	cycle_routine = pauseCycle;
	displayPage[0].drawenv.isbg = 0;
	displayPage[1].drawenv.isbg = 0;
	debugPrintf(".");

	dsEvent_Init();
	debugPrintf(".");

	pause_wood = textureFindInAllBanks("WOODSTRIP");
	ASSERT(pause_wood);
	debugPrintf(".");


	options_colour=0;
	options_colouradd = 8;

	// Copy page 0 over page 1 to stop that annoying flickeriness
	{
		static RECT rect = {0,256,512,256};
		MoveImage(&rect,0,0);	
		DrawSync(0);
	}
	debugPrintf(".");

	quit_confirmation = 0;
}

void pauseEndReturnToGame(void)
{
	draw_routine = old_draw_routine;
	cycle_routine = old_cycle_routine;
	displayPage[0].drawenv.isbg = 1;
	displayPage[1].drawenv.isbg = 1;
	sound_XA_Resume(-1);
}

void pauseEndQuitGame(void)
{
	displayPage[0].drawenv.isbg = 1;
	displayPage[1].drawenv.isbg = 1;
	cardInitialGameState();			// Reset the game - need to load a saved game to continue

	if(pause_levelplaying==LEVNUMBER_A2_FIREWORKS)
	{
		fireworksFree();
		startupStart();
	}
	else if(pause_levelplaying==LEVNUMBER_A2_CATAPULT)
	{
		catapultFree();
		startupStart();
	}
	else if(pause_levelplaying==LEVNUMBER_A2_SEESAW)
	{
		seesawFree();
		startupStart();
	}

	else if(pause_levelplaying==LEVNUMBER_A4_EGGHUT)
	{
		egglayingFree();
		startupStart();
	}
	else if(pause_levelplaying==LEVNUMBER_A4_FLYMACHINE)
	{
		crateFree();
		startupStart();
	}
	else if(pause_levelplaying==LEVNUMBER_A1_DOGCHASE)
	{
		dogchaseFree();
		startupStart();
	}
	else if(pause_levelplaying==LEVNUMBER_A4_ENGINEHUT)
	{
		engineFree();
		startupStart();
	}
	else if(pause_levelplaying==LEVNUMBER_A4_WINGSHUT)
	{
		wingFree();
		startupStart();
	}
	else if(pause_levelplaying==LEVNUMBER_A4_CONSTRUCT)
	{
		constructFree();
		startupStart();
	}
	else
	{
		mapplayEnd();
		startupStart();		// Take the player back to the Title screen
	}
}




void pauseEndRestartAct(void)
{
	displayPage[0].drawenv.isbg = 1;	
	displayPage[1].drawenv.isbg = 1;
	draw_routine = old_draw_routine;
	cycle_routine = old_cycle_routine;

	//mapplayEnd();

	// Erm, we also need to (probably) reset a whole load of variables here... all the objects you've collected in this act etc etc
	// Reset all the FMA flags for this act, re-spot items, re-set puzzles, replace sprouts / map pieces / film reels / pictures 

/*	if(levinfo->level_number<=LEVNUMBER_A1_DOGCHASE)
	{
		int i;
		

		// Remove any and all act 1 items from inventory

		for(i=0;i<NIGHTDRESS;i++)
		{
			if(gameSaveData.inventory_item_status[i]!=INV_STATUS_NOTCOLLECTED)
			{
				scenicInventoryNotification(i,SCENIC_INVENTORY_RESPOT);
				gameSaveData.inventory_item_status[i] = INV_STATUS_NOTCOLLECTED;
			}
		}

		for(i=0;i<6;i++)
			currentInv->slot_contents[i] = EMPTY;

		currentInv->selected_item = EMPTY;


		// Clear the task completed flags

		gameSaveData.tasks_done[TASK_CUT_COOP1_FENCE] = 0;
		gameSaveData.tasks_done[TASK_CUT_CLOTHES_LINE] = 0;


		// Clear the FMA flags

		for(i=0;i<MAX_ACT1_FMAS;i++)
		{
			A1fmaStatus[i].playedFlag = 0;
			A1fmaStatus[i].playedTime = 0;
		}
		
		gameSaveData.tasks_done[TASK_A1_BRIEF_FMA] = 0;


		// Rid ourselves of sprouts

		gameSaveData.sprouts_carried = 0;
		for(i=0;i<LEVNUMBER_A1_DOGCHASE;i++)
			gameSaveData.pickups_collected[i] = 0;

		// Respot any map pieces, film reels, pictures etc you might have picked up in Act 1
		// How??? All we know is that you've picked them up, we dont know which act you picked them up in... 
		// Since this is Act 1, we can just re-spot everything, but for a restart act2 or act3, we're
		// gonna have to store more information :(

		// Replace all the map pieces
		for(i=0;i<14;i++)
		{
			if(gameSaveData.map_pieces_got[i])
			{
				scenicInventoryNotification(MAP1+i,SCENIC_INVENTORY_RESPOT);
				gameSaveData.map_pieces_got[i]=0;
			}
		}

		gameSaveData.map_pieces_got[8] = 1;		// Always got piece 8


		// Replace all the stills
		for(i=0;i<30;i++)
		{
			if(gameSaveData.stills_available[i])
			{
				gameSaveData.stills_available[i] = 0;
				scenicInventoryNotification(PIC1+i,SCENIC_INVENTORY_RESPOT);
			}
		}

		
				
		// And send the player back to Act 1 Hut 17 

		inventoryEnsureStreamBank(STREAMBANK_INVENTORYACT1);
		mapplayStart("A1_HUT17", 0);
	}
	



	else if(levinfo->level_number<=LEVNUMBER_A2_COGCHASE)
	{
		int i;
	

		// Remove any and all act 1 items from inventory

		for(i=SPOON;i<BONE+1;i++)
		{
			if(gameSaveData.inventory_item_status[i]!=INV_STATUS_NOTCOLLECTED)
			{
				scenicInventoryNotification(i,SCENIC_INVENTORY_RESPOT);
				gameSaveData.inventory_item_status[i] = INV_STATUS_NOTCOLLECTED;
			}
		}

		for(i=0;i<6;i++)
			currentInv->slot_contents[i] = EMPTY;

		currentInv->selected_item = EMPTY;


		// Clear the task completed flags

		gameSaveData.tasks_done[TASK_DUG_COOP2_FENCE] = 0;
		

		// Clear the FMA flags

		for(i=0;i<MAX_ACT2_FMAS;i++)
		{
			A2fmaStatus[i].playedFlag = 0;
			A2fmaStatus[i].playedTime = 0;
		}
		
		gameSaveData.tasks_done[TASK_A2_BRIEF_FMA] = 0;


		// Rid ourselves of sprouts

		gameSaveData.sprouts_carried = 0;
		for(i=0;i<LEVNUMBER_A2_COGCHASE;i++)
			gameSaveData.pickups_collected[i] = 0;

		// Respot any map pieces, film reels, pictures etc you might have picked up in Act 1
		// How??? All we know is that you've picked them up, we dont know which act you picked them up in... 
		// Since this is Act 1, we can just re-spot everything, but for a restart act2 or act3, we're
		// gonna have to store more information :(

		// Replace all the map pieces
		for(i=0;i<14;i++)
		{
			if(gameSaveData.map_pieces_got[i])
			{
				scenicInventoryNotification(MAP1+i,SCENIC_INVENTORY_RESPOT);
				gameSaveData.map_pieces_got[i]=0;
			}
		}

		gameSaveData.map_pieces_got[8] = 1;		// Always got piece 8


		// Replace all the stills
		for(i=0;i<30;i++)
		{
			if(gameSaveData.stills_available[i])
			{
				gameSaveData.stills_available[i] = 0;
				scenicInventoryNotification(PIC1+i,SCENIC_INVENTORY_RESPOT);
			}
		}


		inventoryEnsureStreamBank(STREAMBANK_INVENTORYACT2);
		mapplayStart("A2_HUT17",0);
	}



	else if(levinfo->level_number<=LEVNUMBER_A4_FLYMACHINE)
	{
		int i;
	

		// Remove any and all act 1 items from inventory

		for(i=EGG;i<GNOME+1;i++)
		{
			if(gameSaveData.inventory_item_status[i]!=INV_STATUS_NOTCOLLECTED)
			{
				scenicInventoryNotification(i,SCENIC_INVENTORY_RESPOT);
				gameSaveData.inventory_item_status[i] = INV_STATUS_NOTCOLLECTED;
			}
		}

		for(i=0;i<6;i++)
			currentInv->slot_contents[i] = EMPTY;

		currentInv->selected_item = EMPTY;


		// Clear the task completed flags

		gameSaveData.tasks_done[TASK_REVEALED_SEWER] = 0;
		gameSaveData.tasks_done[TASK_FINISHED_A4_TRACTOR] = 0;
		

		// Clear the FMA flags

		for(i=0;i<MAX_ACT4_FMAS;i++)
		{
			A4fmaStatus[i].playedFlag = 0;
			A4fmaStatus[i].playedTime = 0;
		}
		
		gameSaveData.tasks_done[TASK_A4_BRIEF_FMA] = 0;


		// Rid ourselves of sprouts

		gameSaveData.sprouts_carried = 0;
		for(i=0;i<LEVNUMBER_A4_FLYMACHINE;i++)
			gameSaveData.pickups_collected[i] = 0;

		// Respot any map pieces, film reels, pictures etc you might have picked up in Act 1
		// How??? All we know is that you've picked them up, we dont know which act you picked them up in... 
		// Since this is Act 1, we can just re-spot everything, but for a restart act2 or act3, we're
		// gonna have to store more information :(

		// Replace all the map pieces
		for(i=0;i<14;i++)
		{
			if(gameSaveData.map_pieces_got[i])
			{
				scenicInventoryNotification(MAP1+i,SCENIC_INVENTORY_RESPOT);
				gameSaveData.map_pieces_got[i]=0;
			}
		}

		gameSaveData.map_pieces_got[8] = 1;		// Always got piece 8


		// Replace all the stills
		for(i=0;i<30;i++)
		{
			if(gameSaveData.stills_available[i])
			{
				gameSaveData.stills_available[i] = 0;
				scenicInventoryNotification(PIC1+i,SCENIC_INVENTORY_RESPOT);
			}
		}

		inventoryEnsureStreamBank(STREAMBANK_INVENTORYACT4);	
		mapplayStart("A4_HUT17",0);
	}		*/


}

// Reset all the variables n stuff in Act 1
void pauseResetAct1(void)
{
}


void pauseDrawOptions(void)
{
	int i;
	
	if(pause_option==2)
		optionsDrawBoxOutline(55, PAUSE_MENU_Y_POSITION+64,66,9,(((64+options_colour)<<16)+((64+options_colour)<<8)+((64+options_colour))));
	else if(pause_option==3)
		optionsDrawBoxOutline(55, PAUSE_MENU_Y_POSITION+82,66,9,(((64+options_colour)<<16)+((64+options_colour)<<8)+((64+options_colour))));

	optionsDrawBoxOutline(55, PAUSE_MENU_Y_POSITION+64,66,9,0x303030);
	optionsDrawBoxOutline(55, PAUSE_MENU_Y_POSITION+82,66,9,0x303030);

	if(optionData.sound.sfxvol>18)
	{
		for(i=0;i<optionData.sound.sfxvol/4;i+=5)
			overlayFilledRectangle( i+56, PAUSE_MENU_Y_POSITION+65, 3, 8, 0x880000+((i*2)<<1));	
	}

	if(optionData.sound.musicvol>18)
	{
		for(i=0;i<optionData.sound.musicvol/4;i+=5)
			overlayFilledRectangle( i+56, PAUSE_MENU_Y_POSITION+83, 3, 8, 0x880000+((i*2)<<1));	
	}
	if(pause_option!=4)
	{
		if(pReadPad->shockEnable)
			fontPrint(font, 52,PAUSE_MENU_Y_POSITION+100, fontUpper(TEXTSTR(TEXTSTR_OPTIONS_ON)),48,48,48);
		else
			fontPrint(font, 52,PAUSE_MENU_Y_POSITION+100, fontUpper(TEXTSTR(TEXTSTR_OPTIONS_OFF)),48,48,48);
	}
	else
	{
		if(pReadPad->shockEnable)
			fontPrint(font, 52,PAUSE_MENU_Y_POSITION+100, fontUpper(TEXTSTR(TEXTSTR_OPTIONS_ON)),64+options_colour,64+options_colour,64+options_colour);
		else
			fontPrint(font, 52,PAUSE_MENU_Y_POSITION+100, fontUpper(TEXTSTR(TEXTSTR_OPTIONS_OFF)),64+options_colour,64+options_colour,64+options_colour);
	}
}


void pauseOptionsCycle(void)
{
	if((pReadPad->digital[0] & PAD_LEFT) ||(pReadPad->analogXS[0]<-2048))
	{
		switch(pause_option)
		{
		case 2:
			if(optionData.sound.sfxvol>6)
				optionData.sound.sfxvol-=6;
			optionsHitOptions(OPTIONS_HIT_SFX_VOL);
			break;
		case 3:
			if(optionData.sound.musicvol>6)
				optionData.sound.musicvol-=6;
			break;
		default:
			break;
		}
	}

	if((pReadPad->digital[0] & PAD_RIGHT) ||(pReadPad->analogXS[0]>2048))
	{
		switch(pause_option)
		{
		case 2:
			if(optionData.sound.sfxvol<255)
				optionData.sound.sfxvol+=6;
			if(optionData.sound.sfxvol>255)
				optionData.sound.sfxvol = 255;
			optionsHitOptions(OPTIONS_HIT_SFX_VOL);
			break;
		case 3:
			if(optionData.sound.musicvol<255)
				optionData.sound.musicvol+=6;
			if(optionData.sound.musicvol>255)
				optionData.sound.musicvol = 255;
			break;
		default:
			break;
		}
	}
}