/*

	This file is part of Frogger2, (c) 1999 Interactive Studios Ltd.


	File		: layout.c
	Programmer	: Andrew Eder
	Date		: 01/03/99

----------------------------------------------------------------------------------------------- */

#define F3DEX_GBI_2

#ifndef PSX_VERSION

#include <windows.h>
#include <ddraw.h>
#include <d3d.h>

#endif

#include <islmem.h>
#include <islutil.h>

#include "ultra64.h"
#include "layout.h"
#include "types.h"
#include "sprite.h"
#include "platform.h"
#include "collect.h"
#include "map.h"
#include "textover.h"
#include "enemies.h"
#include "babyfrog.h"
#include "event.h"
#include "tongue.h"
#include "game.h"
#include "cam.h"
#include "hud.h"
#include "frontend.h"
#include "script.h"
#include "Main.h"
#include "maths.h"
#include "newpsx.h"
#include "menus.h"
#include "specfx.h"
#include "e3_demo.h"
#include "levplay.h"
#include "frogmove.h"
#include "fadeout.h"
#include "backdrop.h"
#include "story.h"
#include "particle.h"
#include "multi.h"
#include "training.h"
#include "ptexture.h"
#include "options.h"
//ma#include "flatpack.h"

#ifdef PSX_VERSION
//ma#include <libspu.h>
#include "Bff_Load.h"
#include "Objects.h"
#include "Map_Draw.h"
#include "Water.h"
#include "temp_psx.h"
#include "audio.h"
#include "backdrop.h"
#include "loadingbar.h"
#include "eff_draw.h"
//#include <islxa.h>
#else
#include <banks.h>
#include <mdx.h>
#include <pcsprite.h>
extern MDX_LANDSCAPE *world;
#include <pcaudio.h>
#include <pcmisc.h>
#endif

#include "lang.h"

//stuff taken out of PSX main,
//for commonality
fixed gameSpeed = 4096;
char quitMainLoop;
unsigned long actFrameCount = 0;
unsigned long lastActFrameCount = 0;
ULONG	frame;
VECTOR bbsrc, bbtar;
char useAudio = 1;
char screenshotEnable = 0;
int gameTextLang = 0;

extern unsigned long USE_MENUS;

unsigned long worldNum;
unsigned long levelNum;

unsigned char darkenedLevel		= 0;
short lightIntensity	= 255;

void LSCAPE_DrawSortedPrimitives(int);
void customDrawPrimitives2(int, long*);

//BB
//This really sucks.
//Gotta do a get-around 'cos psiDestroy doesn't work
//if psiAllocWorkspace hasn't been called.
int AllowPsiDestroy = 0;


WORLD_VISUAL_DATA origWorldVisualData[MAX_WORLDS] = 
{
//------------------------------------------------ GARDEN
	{
	STR_WORLD_GARDEN,				// description
	WORLDID_GARDEN,			// world ID
	GARDENMASTER_OBJ_BANK,		// master object bank
	GARDEN_TEX_BANK,		// master texture bank
	WORLD_OPEN,
	1,						// number of levels
	1,						// number of single player levels
		{ 
		STR_LEVEL_GARDEN1,	"LEV_GAR1",0,		LEVELID_GARDEN1,LEVELID_ANCIENT1,WORLDID_ANCIENT,GARDENLEV1_OBJ_BANK,0,GARDENLEV1_COL,LEVEL_OPEN,0,WORLDID_ANCIENT,0,  0,0,0,650,780,60,"LAUREN",7000,GARDEN1_STAK,
//		STR_LEVEL_GARDENMULTI,"GARDEN1",0,	LEVELID_GARDEN6,LEVELID_ANCIENT1,WORLDID_ANCIENT,GARDENMULTI_OBJ_BANK,0,GARDENMULTI_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,1100,1100,60,"SIMON",7000,
		},
	},

//------------------------------------------------ ANCIENT

	{
	STR_WORLD_ANCIENT,			// description
	WORLDID_ANCIENT,		// world ID
	ANCIENTMASTER_OBJ_BANK,	// master object bank
	ANCIENT_TEX_BANK,	// master texture bank
	WORLD_CLOSED,
	4,						// number of levels
	3,						// number of single player levels
		{ 
//		STR_LEVEL_ANCIENT1,"ANCIENT1",0,		LEVELID_ANCIENT1,LEVELID_SUBTERRANEAN1,WORLDID_SUBTERRANEAN,ANCIENTLEV1_OBJ_BANK,0,ANCIENTLEV1_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,800,1000,80,"SANDRO",7000,
		STR_LEVEL_ANCIENT1,"LEV_ANC1",0,		LEVELID_ANCIENT1,LEVELID_SUBTERRANEAN1,WORLDID_SUBTERRANEAN,ANCIENTLEV1_OBJ_BANK,0,ANCIENTLEV1_COL,LEVEL_CLOSED,0,-1,0, 0,0, 0,800,1000,400,"SANDRO",7000,ANCIENTS1_STAK,
		STR_LEVEL_ANCIENT2,"LEV_ANC2",0,		LEVELID_ANCIENT3,LEVELID_SUBTERRANEAN2,WORLDID_SUBTERRANEAN,ANCIENTLEV3_OBJ_BANK,0,ANCIENTLEV3_COL,LEVEL_CLOSED,0,-1,0, 0,0, 0,800,1100,120,"MATT",7000,ANCIENTS2_STAK,
		STR_LEVEL_ANCIENT3,"LEV_ANC3",0,		LEVELID_ANCIENT4,LEVELID_ANCIENT3,WORLDID_ANCIENT,ANCIENTBOSS_OBJ_BANK,0,ANCIENTMASTER_COL,LEVEL_CLOSED,0,-1,0, 0,0, 0,1100,1100,120,"JIM",7000,ANCIENTS3_STAK,
		STR_LEVEL_ANCIENTMULTI,"GARDEN1",0,	LEVELID_ANCIENT6,LEVELID_ANCIENT1,WORLDID_ANCIENT,ANCIENTMULTI_OBJ_BANK,0,ANCIENTMULTI_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,1100,1100,60,"DAVE",9000,0,
		},
	},


//------------------------------------------------ SPACE

	{
	STR_WORLD_SPACE,			// description
	WORLDID_SPACE,		// world ID
	SPACEMASTER_OBJ_BANK,		// master object bank
	SPACE_TEX_BANK,		// master texture bank
	WORLD_CLOSED,
	3,						// number of levels
	3,						// number of single player levels
		{ 
		STR_LEVEL_SPACE1,"LEV_SPA1",0,		LEVELID_SPACE1,LEVELID_LABORATORY3,WORLDID_LABORATORY,SPACELEV1_OBJ_BANK,0,SPACELEV1_COL,LEVEL_CLOSED,0,-1,0, 0,0, 0,500,1100,120,"BYRON",7000,SPACE1_STAK,
		STR_LEVEL_SPACE2,"LEV_SPA2",0,		LEVELID_SPACE3,LEVELID_SPACE1,WORLDID_SPACE,SPACELEV3_OBJ_BANK,0,SPACELEV3_COL,LEVEL_CLOSED,0,-1,0, 0,0, 0,1100,1800,130,"RANDOM",14000,SPACE2_STAK,
		STR_LEVEL_SPACE3,"LEV_SPA3",0,		LEVELID_SPACE4,LEVELID_HALLOWEEN1,WORLDID_HALLOWEEN,SPACEBOSS_OBJ_BANK,0,SPACEMASTER_COL,LEVEL_CLOSED,0,-1,0, 0,0, 0,1100,1100,180,"JOFF",7000,SPACE3_STAK,
//		STR_LEVEL_SPACEMULTI,"SPACE1",0,	LEVELID_SPACE6,LEVELID_LABORATORY1,WORLDID_LABORATORY,SPACEMULTI_OBJ_BANK,0,SPACEMULTI_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,1100,1100,60,"RICHARD",7000,
		},
	},

//------------------------------------------------ CITY

	{
	STR_WORLD_CITY,				// description
	WORLDID_CITY,		// world ID
	CITYMASTER_OBJ_BANK,		// master object bank
	CITY_TEX_BANK,		// master texture bank
	WORLD_OPEN,
	1,						// number of levels
	0,						// number of single player levels
		{ 
//		STR_LEVEL_CITY1,"CITY1",80,			LEVELID_CITY1,LEVELID_CITY2,WORLDID_CITY,CITYLEV1_OBJ_BANK,0,CITYLEV1_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,1100,1100,150,"BRUCE",7000,
//		STR_LEVEL_CITY2,"CITY2",80,			LEVELID_CITY2,LEVELID_CITY3,WORLDID_CITY,CITYLEV2_OBJ_BANK,0,CITYLEV2_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,1100,1100,160,"MIKE",7000,
//		STR_LEVEL_CITY3,"CITY3",90,			LEVELID_CITY3,LEVELID_SUBTERRANEAN1,WORLDID_SUBTERRANEAN,CITYLEV3_OBJ_BANK,0,CITYLEV3_COL,LEVEL_OPEN,0,-1,0, 100,100, 000,350,1100,150,"ANDY",7000,
		STR_LEVEL_CITYMULTI,"GARDEN1",0,	LEVELID_CITY6,LEVELID_CITY6,WORLDID_CITY,CITYMULTI_OBJ_BANK,0,CITYMULTI_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,1100,1100,60,"ALEX",7000,0,
		},
	},

//------------------------------------------------ SUBTERRANEAN

	{
	STR_WORLD_SUB,				// description
	WORLDID_SUBTERRANEAN,		// world ID
	SUBTERRANEANMASTER_OBJ_BANK,		// master object bank
	SUBTERRANEAN_TEX_BANK,		// master texture bank
	WORLD_CLOSED,
	3,						// number of levels
	3,						// number of single player levels
		{ 
		STR_LEVEL_SUB1,"LEV_SUB1",0,				LEVELID_SUBTERRANEAN1,LEVELID_ANCIENT3,WORLDID_ANCIENT,SUBTERRANEANLEV1_OBJ_BANK,0,SUBTERRANEANLEV1_COL,LEVEL_CLOSED,0,-1,0, 0,0, 0,1100,1100,120,"KEVIN",7000,SUB1_STAK,
		STR_LEVEL_SUB2,"LEV_SUB2",0,				LEVELID_SUBTERRANEAN2,LEVELID_SUBTERRANEAN3,WORLDID_SUBTERRANEAN,SUBTERRANEANLEV2_OBJ_BANK,0,SUBTERRANEANLEV2_COL,LEVEL_CLOSED,0,-1,0, 0,0, 0,1100,1100,130,"PHILLIP",7000,SUB2_STAK,
		STR_LEVEL_SUB3,"LEV_SUB3",0,				LEVELID_SUBTERRANEAN4,LEVELID_LABORATORY1,WORLDID_LABORATORY,SUBTERRANEANBOSS_OBJ_BANK,0,SUBTERRANEANMASTER_COL,LEVEL_CLOSED,0,-1,0, 0,0, 0,1100,1100,180,"ANDREW",7000,SUB3_STAK,
//		STR_LEVEL_SUBMULTI,"GARDEN1",0,		LEVELID_SUBTERRANEAN6,LEVELID_SUBTERRANEAN1,WORLDID_SUBTERRANEAN,SUBTERRANEANMULTI_OBJ_BANK,0,SUBTERRANEANMULTI_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,1100,1100,60,"SUSIE",7000,
		},
	},

//------------------------------------------------ LABORATORY

	{
	STR_WORLD_LAB,				// description
	WORLDID_LABORATORY,		// world ID
	LABORATORYMASTER_OBJ_BANK,		// master object bank
	LABORATORY_TEX_BANK,		// master texture bank
	WORLD_CLOSED,
	6,						// number of levels
	3,						// number of single player levels
		{ 
		STR_LEVEL_LAB1,"LEV_LAB1",0,		LEVELID_LABORATORY1,LEVELID_LABORATORY2,WORLDID_LABORATORY,LABORATORYLEV1_OBJ_BANK,0,LABORATORYLEV1_COL,LEVEL_CLOSED,0,-1,0, 0,0, 0,1100,1100,120,"CAROLINE",7000,LAB1_STAK,
		STR_LEVEL_LAB2,"LEV_LAB2",0,		LEVELID_LABORATORY3,LEVELID_SPACE2,WORLDID_SPACE,LABORATORYLEV3_OBJ_BANK,0,LABORATORYLEV3_COL,LEVEL_CLOSED,0,-1,0, 0,0, 0,1100,1100,300,"ALISON",12000,LAB2_STAK,
		STR_LEVEL_LAB3,"LEV_LAB3",0,		LEVELID_LABORATORY4,LEVELID_SPACE3,WORLDID_SPACE,LABORATORYBOSSA_OBJ_BANK,0,LABORATORYMASTERA_COL,LEVEL_CLOSED,0,-1,0, 0,0, 0,1100,1100,210,"ROLAND",10000,LAB3_STAK,
		STR_LEVEL_LABMULTI1,"GARDEN1",0,LEVELID_LABORATORY5,LEVELID_LABORATORY2,WORLDID_LABORATORY,LABORATORYMULTI1_OBJ_BANK,0,LABORATORYMULTI1_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,1100,1100,60,"NIGEL",15000,0,
		STR_LEVEL_LABMULTI2,"GARDEN1",0,LEVELID_LABORATORY6,LEVELID_LABORATORY2,WORLDID_LABORATORY,LABORATORYMULTI2_OBJ_BANK,0,LABORATORYMULTI2_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,1100,1100,60,"NIGEL",15000,0,
		STR_LEVEL_LABMULTI3,"GARDEN1",0,LEVELID_LABORATORY7,LEVELID_LABORATORY2,WORLDID_LABORATORY,LABORATORYMULTI3_OBJ_BANK,0,LABORATORYMULTI3_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,1100,1100,60,"NIGEL",15000,0,
		},
	},

//------------------------------------------------ HALLOWEEN

	{
	STR_WORLD_HALL,					// description
	WORLDID_HALLOWEEN,			// world ID
	HALLOWEENMASTER_OBJ_BANK,			// master object bank
	HALLOWEEN_TEX_BANK,			// master texture bank
	WORLD_CLOSED,
	3,						// number of levels 
	3,						// number of single player levels
		{ 
		STR_LEVEL_HALL1,"LEV_HAL1",0,		LEVELID_HALLOWEEN1,LEVELID_HALLOWEEN2,WORLDID_HALLOWEEN,HALLOWEENLEV1_OBJ_BANK,0,HALLOWEENLEV1_COL,LEVEL_CLOSED,0,-1,0, 0,0, 0,1100,1100,150,"LAUREN",7000,HALLOWEEN1_STAK,
		STR_LEVEL_HALL2,"LEV_HAL2",0,		LEVELID_HALLOWEEN2,LEVELID_HALLOWEEN3,WORLDID_HALLOWEEN,HALLOWEENLEV2_OBJ_BANK,0,HALLOWEENLEV2_COL,LEVEL_CLOSED,0,-1,0, 0,0, 0,1000,1150,190,"SIMON",7000,HALLOWEEN2_STAK,
		STR_LEVEL_SWAMPY3,"LEV_HAL3",0,	LEVELID_HALLOWEEN5,LEVELID_FRONTEND1,WORLDID_FRONTEND,HALLOWEENBOSSB_OBJ_BANK,0,HALLOWEENMASTERB_COL,LEVEL_CLOSED,0,-1,0, 0,0, 0,1100,1100,120,"JIM",7000,HALLOWEEN3_STAK,
//		STR_LEVEL_HALLMULTI,"GARDEN1",0,LEVELID_HALLOWEEN7,LEVELID_HALLOWEEN2,WORLDID_LABORATORY,HALLOWEENMULTI_OBJ_BANK,0,HALLOWEENMULTI_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,1100,1100,60,"BYRON",7000,
		},
	},

	
//------------------------------------------------ SWAMPYWORLD

//	{
//	STR_WORLD_SWAMPY,					// description
//	WORLDID_SWAMPYWORLD,			// world ID
//	SWAMPYWORLDMASTER_OBJ_BANK,			// master object bank
//	SWAMPYWORLD_TEX_BANK,			// master texture bank
//	WORLD_OPEN,
//	4,						// number of levels 
//	4,						// number of single player levels
//		{ 
//		STR_LEVEL_SWAMPY1,"",90,				LEVELID_SWAMPYWORLD3,LEVELID_SWAMPYWORLD4,WORLDID_SWAMPYWORLD,SWAMPYWORLDLEV3_OBJ_BANK,0,SWAMPYWORLDLEV3_COL,LEVEL_OPEN,-1,0, 0,0, 0,1100,1100,190,"SANDRO",7000,
//		STR_LEVEL_SWAMPY2,"HALL3",0,			LEVELID_SWAMPYWORLD4,LEVELID_SWAMPYWORLD5,WORLDID_SWAMPYWORLD,SWAMPYWORLDBOSS_OBJ_BANK,0,SWAMPYWORLDMASTER_COL,LEVEL_OPEN,-1,0, 0,0, 0,1100,1100,120,"MATT",7000,
//		STR_LEVEL_SWAMPY3,"",0,					LEVELID_SWAMPYWORLD5,LEVELID_SWAMPYWORLD6,WORLDID_SWAMPYWORLD,SWAMPYWORLDBOSSB_OBJ_BANK,0,SWAMPYWORLDMASTERB_COL,LEVEL_OPEN,-1,0, 0,0, 0,1100,1100,120,"JIM",7000,
//		STR_WORLD_SWAMPY,"GARDEN1",0,		LEVELID_SWAMPYWORLD6,LEVELID_SUPERRETRO1,WORLDID_SUPERRETRO,SWAMPYWORLDMULTI_OBJ_BANK,0,SWAMPYWORLDMULTI_COL,LEVEL_OPEN,-1,0, 0,0, 0,1100,1100,60,"DAVE",7000,
//		},
//	},


//------------------------------------------------ SUPERRETRO

	{
	STR_WORLD_RETRO,			// description
	WORLDID_SUPERRETRO,		// world ID
	RETROMASTER_OBJ_BANK,	// master object bank
	SUPERRETRO_TEX_BANK,	// master texture bank
	WORLD_OPEN,
	14,						// number of levels
	10,						// number of single player levels
		{ 
		STR_LEVEL_RETRO1,"LEV_RET1",0,		LEVELID_SUPERRETRO1,LEVELID_SUPERRETRO2,WORLDID_SUPERRETRO,RETROLEV1_OBJ_BANK,0,RETROLEV1_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,1100,1100,60,"BRUCE",7000,0,
		STR_LEVEL_RETRO2,"LEV_RET1",0,		LEVELID_SUPERRETRO2,LEVELID_SUPERRETRO3,WORLDID_SUPERRETRO,RETROLEV2_OBJ_BANK,0,RETROLEV2_COL,LEVEL_CLOSED,0,-1,0, 0,0, 0,1100,1100,60,"BRUCE",7000,0,
		STR_LEVEL_RETRO3,"LEV_RET1",0,		LEVELID_SUPERRETRO3,LEVELID_SUPERRETRO4,WORLDID_SUPERRETRO,RETROLEV3_OBJ_BANK,0,RETROLEV3_COL,LEVEL_CLOSED,0,-1,0, 0,0, 0,1100,1100,60,"BRUCE",7000,0,
		STR_LEVEL_RETRO4,"LEV_RET1",0,		LEVELID_SUPERRETRO4,LEVELID_SUPERRETRO5,WORLDID_SUPERRETRO,RETROLEV4_OBJ_BANK,0,RETROLEV4_COL,LEVEL_CLOSED,0,-1,0, 0,0, 0,1100,1100,60,"BRUCE",7000,0,
		STR_LEVEL_RETRO5,"LEV_RET1",0,		LEVELID_SUPERRETRO5,LEVELID_SUPERRETRO6,WORLDID_SUPERRETRO,RETROLEV5_OBJ_BANK,0,RETROLEV5_COL,LEVEL_CLOSED,0,-1,0, 0,0, 0,1100,1100,60,"BRUCE",7000,0,
		STR_LEVEL_RETRO6,"LEV_RET1",0,		LEVELID_SUPERRETRO6,LEVELID_SUPERRETRO7,WORLDID_SUPERRETRO,RETROLEV6_OBJ_BANK,0,RETROLEV6_COL,LEVEL_CLOSED,0,-1,0, 0,0, 0,1100,1100,60,"BRUCE",7000,0,
		STR_LEVEL_RETRO7,"LEV_RET1",0,		LEVELID_SUPERRETRO7,LEVELID_SUPERRETRO8,WORLDID_SUPERRETRO,RETROLEV7_OBJ_BANK,0,RETROLEV7_COL,LEVEL_CLOSED,0,-1,0, 0,0, 0,1100,1100,60,"BRUCE",7000,0,
		STR_LEVEL_RETRO8,"LEV_RET1",0,		LEVELID_SUPERRETRO8,LEVELID_SUPERRETRO9,WORLDID_SUPERRETRO,RETROLEV8_OBJ_BANK,0,RETROLEV8_COL,LEVEL_CLOSED,0,-1,0, 0,0, 0,1100,1100,60,"BRUCE",7000,0,
		STR_LEVEL_RETRO9,"LEV_RET1",0,		LEVELID_SUPERRETRO9,LEVELID_SUPERRETRO10,WORLDID_SUPERRETRO,RETROLEV9_OBJ_BANK,0,RETROLEV9_COL,LEVEL_CLOSED,0,-1,0, 0,0, 0,1100,1100,60,"BRUCE",7000,0,
		STR_LEVEL_RETRO10,"LEV_RET1",0,		LEVELID_SUPERRETRO10,LEVELID_FRONTEND1,WORLDID_FRONTEND,RETROLEV10_OBJ_BANK,0,RETROLEV10_COL,LEVEL_CLOSED,0,-1,0, 0,0, 0,1100,1100,60,"BRUCE",7000,0,
		STR_LEVEL_RETROMULTI1,"SUPER1",0,	LEVELID_SUPERRETRO11,LEVELID_SUPERRETRO2,WORLDID_SUPERRETRO,RETROMULTI1_OBJ_BANK,0,RETROMULTI1_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,1100,1100,60,"BRUCE",12000,0,
		STR_LEVEL_RETROMULTI2,"SUPER1",0,	LEVELID_SUPERRETRO12,LEVELID_SUPERRETRO2,WORLDID_SUPERRETRO,RETROMULTI2_OBJ_BANK,0,RETROMULTI2_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,1100,1100,60,"BRUCE",12000,0,
//		STR_LEVEL_RETROMULTI3,"SUPER1",0,	LEVELID_SUPERRETRO13,LEVELID_SUPERRETRO2,WORLDID_SUPERRETRO,RETROMULTI3_OBJ_BANK,0,RETROMULTI3_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,1100,1100,60,"BRUCE",12000,
//		STR_LEVEL_RETROMULTI4,"SUPER1",0,	LEVELID_SUPERRETRO14,LEVELID_SUPERRETRO2,WORLDID_SUPERRETRO,RETROMULTI4_OBJ_BANK,0,RETROMULTI4_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,1100,1100,60,"BRUCE",12000,
//		STR_LEVEL_RETROMULTI5,"SUPER1",0,	LEVELID_SUPERRETRO15,LEVELID_SUPERRETRO2,WORLDID_SUPERRETRO,RETROMULTI5_OBJ_BANK,0,RETROMULTI5_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,1100,1100,60,"BRUCE",12000,
		STR_LEVEL_RETROMULTI3,"SUPER1",0,	LEVELID_SUPERRETRO16,LEVELID_SUPERRETRO2,WORLDID_SUPERRETRO,RETROMULTI6_OBJ_BANK,0,RETROMULTI6_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,1100,1100,60,"BRUCE",12000,0,
//		STR_LEVEL_RETROMULTI7,"SUPER1",0,	LEVELID_SUPERRETRO17,LEVELID_SUPERRETRO2,WORLDID_SUPERRETRO,RETROMULTI7_OBJ_BANK,0,RETROMULTI7_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,1100,1100,60,"BRUCE",12000,
//		STR_LEVEL_RETROMULTI8,"SUPER1",0,	LEVELID_SUPERRETRO18,LEVELID_SUPERRETRO2,WORLDID_SUPERRETRO,RETROMULTI8_OBJ_BANK,0,RETROMULTI8_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,1100,1100,60,"BRUCE",12000,
		STR_LEVEL_RETROMULTI4,"SUPER1",0,	LEVELID_SUPERRETRO19,LEVELID_SUPERRETRO2,WORLDID_SUPERRETRO,RETROMULTI9_OBJ_BANK,0,RETROMULTI9_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,1100,1100,60,"BRUCE",12000,0,
//		STR_LEVEL_RETROMULTI10,"SUPER1",0,	LEVELID_SUPERRETRO20,LEVELID_SUPERRETRO2,WORLDID_SUPERRETRO,RETROMULTI10_OBJ_BANK,0,RETROMULTI10_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,1100,1100,60,"BRUCE",12000,
		},
	},

//------------------------------------------------

	{
	-1,			// description
	WORLDID_FRONTEND,		// world ID
	FRONTEND_OBJ_BANK,	// master object bank
	FRONTEND_TEX_BANK,	// master texture bank
	WORLD_OPEN,
	5,						// number of levels
	5,						// number of single player levels
		{
		STR_LEVEL_UNNAMED,"GARDEN1",0,		LEVELID_FRONTEND1,LEVELID_FRONTEND1,WORLDID_FRONTEND,FRONTEND1_OBJ_BANK,0,FRONTEND1_COL,LEVEL_OPEN,0,-1,0, 120,120,160,350,6500,60,"MATT",7000,FRONTEND1_STAK,
		STR_LEVEL_UNNAMED,"GARDEN1",0,		LEVELID_FRONTEND2,LEVELID_FRONTEND1,WORLDID_FRONTEND,FRONTEND2_OBJ_BANK,0,FRONTEND2_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,1100,1100,60,"MATT",7000,0,
		STR_LEVEL_UNNAMED,"GARDEN1",0,		LEVELID_FRONTEND3,LEVELID_FRONTEND1,WORLDID_FRONTEND,FRONTEND3_OBJ_BANK,0,FRONTEND3_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,1100,1100,60,"MATT",7000,0,
		STR_LEVEL_TRAINING,"LEV_TRAN",0,	LEVELID_FRONTEND4,LEVELID_GARDEN1,WORLDID_GARDEN,FRONTEND4_OBJ_BANK,0,FRONTEND4_COL,LEVEL_OPEN,0,-1,0, 120,120,160,350,900,60,"MATT",7000,0,
		STR_LEVEL_UNNAMED,"GARDEN1",0,		LEVELID_FRONTEND5,LEVELID_FRONTEND1,WORLDID_FRONTEND,FRONTEND5_OBJ_BANK,0,FRONTEND5_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,1100,1100,60,"MATT",7000,0,
		},
	}
};


WORLD_VISUAL_DATA worldVisualData[MAX_WORLDS] = 
{
//------------------------------------------------ GARDEN
	{
	STR_WORLD_GARDEN,				// description
	WORLDID_GARDEN,			// world ID
	GARDENMASTER_OBJ_BANK,		// master object bank
	GARDEN_TEX_BANK,		// master texture bank
	WORLD_OPEN,
	1,						// number of levels
	1,						// number of single player levels
		{ 
		STR_LEVEL_GARDEN1,	"GARDEN1",0,		LEVELID_GARDEN1,LEVELID_ANCIENT1,WORLDID_ANCIENT,GARDENLEV1_OBJ_BANK,0,GARDENLEV1_COL,LEVEL_OPEN,0,WORLDID_ANCIENT,0,  0,0,0,650,780,60,"LAUREN",7000,GARDEN1_STAK,
//		STR_LEVEL_GARDENMULTI,"GARDEN1",0,	LEVELID_GARDEN6,LEVELID_ANCIENT1,WORLDID_ANCIENT,GARDENMULTI_OBJ_BANK,0,GARDENMULTI_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,1100,1100,60,"SIMON",7000,
		},
	},

//------------------------------------------------ ANCIENT

	{
	STR_WORLD_ANCIENT,			// description
	WORLDID_ANCIENT,		// world ID
	ANCIENTMASTER_OBJ_BANK,	// master object bank
	ANCIENT_TEX_BANK,	// master texture bank
	WORLD_CLOSED,
	4,						// number of levels
	3,						// number of single player levels
		{ 
//		STR_LEVEL_ANCIENT1,"ANCIENT1",0,		LEVELID_ANCIENT1,LEVELID_SUBTERRANEAN1,WORLDID_SUBTERRANEAN,ANCIENTLEV1_OBJ_BANK,0,ANCIENTLEV1_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,800,1000,80,"SANDRO",7000,
		STR_LEVEL_ANCIENT1,"ANCIENT1",0,		LEVELID_ANCIENT1,LEVELID_SUBTERRANEAN1,WORLDID_SUBTERRANEAN,ANCIENTLEV1_OBJ_BANK,0,ANCIENTLEV1_COL,LEVEL_CLOSED,0,-1,0, 0,0, 0,800,1000,400,"SANDRO",7000,ANCIENTS1_STAK,
		STR_LEVEL_ANCIENT2,"ANCIENT2",0,		LEVELID_ANCIENT3,LEVELID_SUBTERRANEAN2,WORLDID_SUBTERRANEAN,ANCIENTLEV3_OBJ_BANK,0,ANCIENTLEV3_COL,LEVEL_CLOSED,0,-1,0, 0,0, 0,800,1100,120,"MATT",7000,ANCIENTS2_STAK,
		STR_LEVEL_ANCIENT3,"ANCIENT3",0,		LEVELID_ANCIENT4,LEVELID_ANCIENT3,WORLDID_ANCIENT,ANCIENTBOSS_OBJ_BANK,0,ANCIENTMASTER_COL,LEVEL_CLOSED,0,-1,0, 0,0, 0,1100,1100,120,"JIM",7000,ANCIENTS3_STAK,
		STR_LEVEL_ANCIENTMULTI,"GARDEN1",0,	LEVELID_ANCIENT6,LEVELID_ANCIENT1,WORLDID_ANCIENT,ANCIENTMULTI_OBJ_BANK,0,ANCIENTMULTI_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,1100,1100,60,"DAVE",9000,0,
		},
	},


//------------------------------------------------ SPACE

	{
	STR_WORLD_SPACE,			// description
	WORLDID_SPACE,		// world ID
	SPACEMASTER_OBJ_BANK,		// master object bank
	SPACE_TEX_BANK,		// master texture bank
	WORLD_CLOSED,
	3,						// number of levels
	3,						// number of single player levels
		{ 
		STR_LEVEL_SPACE1,"SPACE1",0,		LEVELID_SPACE1,LEVELID_LABORATORY3,WORLDID_LABORATORY,SPACELEV1_OBJ_BANK,0,SPACELEV1_COL,LEVEL_CLOSED,0,-1,0, 0,0, 0,500,1100,120,"BYRON",7000,SPACE1_STAK,
		STR_LEVEL_SPACE2,"SPACE2",0,		LEVELID_SPACE3,LEVELID_SPACE1,WORLDID_SPACE,SPACELEV3_OBJ_BANK,0,SPACELEV3_COL,LEVEL_CLOSED,0,-1,0, 0,0, 0,1100,1800,130,"RANDOM",14000,SPACE2_STAK,
		STR_LEVEL_SPACE3,"SPACE3",0,		LEVELID_SPACE4,LEVELID_HALLOWEEN1,WORLDID_HALLOWEEN,SPACEBOSS_OBJ_BANK,0,SPACEMASTER_COL,LEVEL_CLOSED,0,-1,0, 0,0, 0,1100,1100,180,"JOFF",7000,SPACE3_STAK,
//		STR_LEVEL_SPACEMULTI,"SPACE1",0,	LEVELID_SPACE6,LEVELID_LABORATORY1,WORLDID_LABORATORY,SPACEMULTI_OBJ_BANK,0,SPACEMULTI_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,1100,1100,60,"RICHARD",7000,
		},
	},

//------------------------------------------------ CITY

	{
	STR_WORLD_CITY,				// description
	WORLDID_CITY,		// world ID
	CITYMASTER_OBJ_BANK,		// master object bank
	CITY_TEX_BANK,		// master texture bank
	WORLD_OPEN,
	1,						// number of levels
	0,						// number of single player levels
		{ 
//		STR_LEVEL_CITY1,"CITY1",80,			LEVELID_CITY1,LEVELID_CITY2,WORLDID_CITY,CITYLEV1_OBJ_BANK,0,CITYLEV1_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,1100,1100,150,"BRUCE",7000,
//		STR_LEVEL_CITY2,"CITY2",80,			LEVELID_CITY2,LEVELID_CITY3,WORLDID_CITY,CITYLEV2_OBJ_BANK,0,CITYLEV2_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,1100,1100,160,"MIKE",7000,
//		STR_LEVEL_CITY3,"CITY3",90,			LEVELID_CITY3,LEVELID_SUBTERRANEAN1,WORLDID_SUBTERRANEAN,CITYLEV3_OBJ_BANK,0,CITYLEV3_COL,LEVEL_OPEN,0,-1,0, 100,100, 000,350,1100,150,"ANDY",7000,
		STR_LEVEL_CITYMULTI,"GARDEN1",0,	LEVELID_CITY6,LEVELID_CITY6,WORLDID_CITY,CITYMULTI_OBJ_BANK,0,CITYMULTI_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,1100,1100,60,"ALEX",7000,0,
		},
	},

//------------------------------------------------ SUBTERRANEAN

	{
	STR_WORLD_SUB,				// description
	WORLDID_SUBTERRANEAN,		// world ID
	SUBTERRANEANMASTER_OBJ_BANK,		// master object bank
	SUBTERRANEAN_TEX_BANK,		// master texture bank
	WORLD_CLOSED,
	3,						// number of levels
	3,						// number of single player levels
		{ 
		STR_LEVEL_SUB1,"SUB1",0,				LEVELID_SUBTERRANEAN1,LEVELID_ANCIENT3,WORLDID_ANCIENT,SUBTERRANEANLEV1_OBJ_BANK,0,SUBTERRANEANLEV1_COL,LEVEL_CLOSED,0,-1,0, 0,0, 0,1100,1100,120,"KEVIN",7000,SUB1_STAK,
		STR_LEVEL_SUB2,"SUB2",0,				LEVELID_SUBTERRANEAN2,LEVELID_SUBTERRANEAN3,WORLDID_SUBTERRANEAN,SUBTERRANEANLEV2_OBJ_BANK,0,SUBTERRANEANLEV2_COL,LEVEL_CLOSED,0,-1,0, 0,0, 0,1100,1100,130,"PHILLIP",7000,SUB2_STAK,
		STR_LEVEL_SUB3,"SUB3",0,				LEVELID_SUBTERRANEAN4,LEVELID_LABORATORY1,WORLDID_LABORATORY,SUBTERRANEANBOSS_OBJ_BANK,0,SUBTERRANEANMASTER_COL,LEVEL_CLOSED,0,-1,0, 0,0, 0,1100,1100,180,"ANDREW",7000,SUB3_STAK,
//		STR_LEVEL_SUBMULTI,"GARDEN1",0,		LEVELID_SUBTERRANEAN6,LEVELID_SUBTERRANEAN1,WORLDID_SUBTERRANEAN,SUBTERRANEANMULTI_OBJ_BANK,0,SUBTERRANEANMULTI_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,1100,1100,60,"SUSIE",7000,
		},
	},

//------------------------------------------------ LABORATORY

	{
	STR_WORLD_LAB,				// description
	WORLDID_LABORATORY,		// world ID
	LABORATORYMASTER_OBJ_BANK,		// master object bank
	LABORATORY_TEX_BANK,		// master texture bank
	WORLD_CLOSED,
	6,						// number of levels
	3,						// number of single player levels
		{ 
		STR_LEVEL_LAB1,"LAB1",0,		LEVELID_LABORATORY1,LEVELID_LABORATORY2,WORLDID_LABORATORY,LABORATORYLEV1_OBJ_BANK,0,LABORATORYLEV1_COL,LEVEL_CLOSED,0,-1,0, 0,0, 0,1100,1100,120,"CAROLINE",7000,LAB1_STAK,
		STR_LEVEL_LAB2,"LAB2",0,		LEVELID_LABORATORY3,LEVELID_SPACE2,WORLDID_SPACE,LABORATORYLEV3_OBJ_BANK,0,LABORATORYLEV3_COL,LEVEL_CLOSED,0,-1,0, 0,0, 0,1100,1100,300,"ALISON",7000,LAB2_STAK,
		STR_LEVEL_LAB3,"LAB3",0,		LEVELID_LABORATORY4,LEVELID_SPACE3,WORLDID_SPACE,LABORATORYBOSSA_OBJ_BANK,0,LABORATORYMASTERA_COL,LEVEL_CLOSED,0,-1,0, 0,0, 0,1100,1100,210,"ROLAND",7000,LAB3_STAK,
		STR_LEVEL_LABMULTI1,"GARDEN1",0,LEVELID_LABORATORY5,LEVELID_LABORATORY2,WORLDID_LABORATORY,LABORATORYMULTI1_OBJ_BANK,0,LABORATORYMULTI1_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,1100,1100,60,"NIGEL",15000,0,
		STR_LEVEL_LABMULTI2,"GARDEN1",0,LEVELID_LABORATORY6,LEVELID_LABORATORY2,WORLDID_LABORATORY,LABORATORYMULTI2_OBJ_BANK,0,LABORATORYMULTI2_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,1100,1100,60,"NIGEL",15000,0,
		STR_LEVEL_LABMULTI3,"GARDEN1",0,LEVELID_LABORATORY7,LEVELID_LABORATORY2,WORLDID_LABORATORY,LABORATORYMULTI3_OBJ_BANK,0,LABORATORYMULTI3_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,1100,1100,60,"NIGEL",15000,0,
		},
	},

//------------------------------------------------ HALLOWEEN

	{
	STR_WORLD_HALL,					// description
	WORLDID_HALLOWEEN,			// world ID
	HALLOWEENMASTER_OBJ_BANK,			// master object bank
	HALLOWEEN_TEX_BANK,			// master texture bank
	WORLD_CLOSED,
	3,						// number of levels 
	3,						// number of single player levels
		{ 
		STR_LEVEL_HALL1,"HALL1",0,		LEVELID_HALLOWEEN1,LEVELID_HALLOWEEN2,WORLDID_HALLOWEEN,HALLOWEENLEV1_OBJ_BANK,0,HALLOWEENLEV1_COL,LEVEL_CLOSED,0,-1,0, 0,0, 0,1100,1100,150,"LAUREN",7000,HALLOWEEN1_STAK,
		STR_LEVEL_HALL2,"HALL2",0,		LEVELID_HALLOWEEN2,LEVELID_HALLOWEEN3,WORLDID_HALLOWEEN,HALLOWEENLEV2_OBJ_BANK,0,HALLOWEENLEV2_COL,LEVEL_CLOSED,0,-1,0, 0,0, 0,1000,1150,190,"SIMON",7000,HALLOWEEN2_STAK,
		STR_LEVEL_SWAMPY3,"HALL5",0,	LEVELID_HALLOWEEN5,LEVELID_GARDEN1,WORLDID_GARDEN,HALLOWEENBOSSB_OBJ_BANK,0,HALLOWEENMASTERB_COL,LEVEL_CLOSED,0,-1,0, 0,0, 0,1100,1100,120,"JIM",7000,HALLOWEEN3_STAK,
//		STR_LEVEL_HALLMULTI,"GARDEN1",0,LEVELID_HALLOWEEN7,LEVELID_HALLOWEEN2,WORLDID_LABORATORY,HALLOWEENMULTI_OBJ_BANK,0,HALLOWEENMULTI_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,1100,1100,60,"BYRON",7000,
		},
	},

	
//------------------------------------------------ SWAMPYWORLD

//	{
//	STR_WORLD_SWAMPY,					// description
//	WORLDID_SWAMPYWORLD,			// world ID
//	SWAMPYWORLDMASTER_OBJ_BANK,			// master object bank
//	SWAMPYWORLD_TEX_BANK,			// master texture bank
//	WORLD_OPEN,
//	4,						// number of levels 
//	4,						// number of single player levels
//		{ 
//		STR_LEVEL_SWAMPY1,"",90,				LEVELID_SWAMPYWORLD3,LEVELID_SWAMPYWORLD4,WORLDID_SWAMPYWORLD,SWAMPYWORLDLEV3_OBJ_BANK,0,SWAMPYWORLDLEV3_COL,LEVEL_OPEN,-1,0, 0,0, 0,1100,1100,190,"SANDRO",7000,
//		STR_LEVEL_SWAMPY2,"HALL3",0,			LEVELID_SWAMPYWORLD4,LEVELID_SWAMPYWORLD5,WORLDID_SWAMPYWORLD,SWAMPYWORLDBOSS_OBJ_BANK,0,SWAMPYWORLDMASTER_COL,LEVEL_OPEN,-1,0, 0,0, 0,1100,1100,120,"MATT",7000,
//		STR_LEVEL_SWAMPY3,"",0,					LEVELID_SWAMPYWORLD5,LEVELID_SWAMPYWORLD6,WORLDID_SWAMPYWORLD,SWAMPYWORLDBOSSB_OBJ_BANK,0,SWAMPYWORLDMASTERB_COL,LEVEL_OPEN,-1,0, 0,0, 0,1100,1100,120,"JIM",7000,
//		STR_WORLD_SWAMPY,"GARDEN1",0,		LEVELID_SWAMPYWORLD6,LEVELID_SUPERRETRO1,WORLDID_SUPERRETRO,SWAMPYWORLDMULTI_OBJ_BANK,0,SWAMPYWORLDMULTI_COL,LEVEL_OPEN,-1,0, 0,0, 0,1100,1100,60,"DAVE",7000,
//		},
//	},


//------------------------------------------------ SUPERRETRO

	{
	STR_WORLD_RETRO,			// description
	WORLDID_SUPERRETRO,		// world ID
	RETROMASTER_OBJ_BANK,	// master object bank
	SUPERRETRO_TEX_BANK,	// master texture bank
	WORLD_OPEN,
	14,						// number of levels
	10,						// number of single player levels
		{ 
		STR_LEVEL_RETRO1,"SUPER1",0,		LEVELID_SUPERRETRO1,LEVELID_SUPERRETRO2,WORLDID_SUPERRETRO,RETROLEV1_OBJ_BANK,0,RETROLEV1_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,1100,1100,60,"BRUCE",7000,0,
		STR_LEVEL_RETRO2,"SUPER1",0,		LEVELID_SUPERRETRO2,LEVELID_SUPERRETRO3,WORLDID_SUPERRETRO,RETROLEV2_OBJ_BANK,0,RETROLEV2_COL,LEVEL_CLOSED,0,-1,0, 0,0, 0,1100,1100,60,"BRUCE",7000,0,
		STR_LEVEL_RETRO3,"SUPER1",0,		LEVELID_SUPERRETRO3,LEVELID_SUPERRETRO4,WORLDID_SUPERRETRO,RETROLEV3_OBJ_BANK,0,RETROLEV3_COL,LEVEL_CLOSED,0,-1,0, 0,0, 0,1100,1100,60,"BRUCE",7000,0,
		STR_LEVEL_RETRO4,"SUPER1",0,		LEVELID_SUPERRETRO4,LEVELID_SUPERRETRO5,WORLDID_SUPERRETRO,RETROLEV4_OBJ_BANK,0,RETROLEV4_COL,LEVEL_CLOSED,0,-1,0, 0,0, 0,1100,1100,60,"BRUCE",7000,0,
		STR_LEVEL_RETRO5,"SUPER1",0,		LEVELID_SUPERRETRO5,LEVELID_SUPERRETRO6,WORLDID_SUPERRETRO,RETROLEV5_OBJ_BANK,0,RETROLEV5_COL,LEVEL_CLOSED,0,-1,0, 0,0, 0,1100,1100,60,"BRUCE",7000,0,
		STR_LEVEL_RETRO6,"SUPER1",0,		LEVELID_SUPERRETRO6,LEVELID_SUPERRETRO7,WORLDID_SUPERRETRO,RETROLEV6_OBJ_BANK,0,RETROLEV6_COL,LEVEL_CLOSED,0,-1,0, 0,0, 0,1100,1100,60,"BRUCE",7000,0,
		STR_LEVEL_RETRO7,"SUPER1",0,		LEVELID_SUPERRETRO7,LEVELID_SUPERRETRO8,WORLDID_SUPERRETRO,RETROLEV7_OBJ_BANK,0,RETROLEV7_COL,LEVEL_CLOSED,0,-1,0, 0,0, 0,1100,1100,60,"BRUCE",7000,0,
		STR_LEVEL_RETRO8,"SUPER1",0,		LEVELID_SUPERRETRO8,LEVELID_SUPERRETRO9,WORLDID_SUPERRETRO,RETROLEV8_OBJ_BANK,0,RETROLEV8_COL,LEVEL_CLOSED,0,-1,0, 0,0, 0,1100,1100,60,"BRUCE",7000,0,
		STR_LEVEL_RETRO9,"SUPER1",0,		LEVELID_SUPERRETRO9,LEVELID_SUPERRETRO10,WORLDID_SUPERRETRO,RETROLEV9_OBJ_BANK,0,RETROLEV9_COL,LEVEL_CLOSED,0,-1,0, 0,0, 0,1100,1100,60,"BRUCE",7000,0,
		STR_LEVEL_RETRO10,"SUPER1",0,		LEVELID_SUPERRETRO10,LEVELID_FRONTEND1,WORLDID_FRONTEND,RETROLEV10_OBJ_BANK,0,RETROLEV10_COL,LEVEL_CLOSED,0,-1,0, 0,0, 0,1100,1100,60,"BRUCE",7000,0,
		STR_LEVEL_RETROMULTI1,"SUPER1",0,	LEVELID_SUPERRETRO11,LEVELID_SUPERRETRO2,WORLDID_SUPERRETRO,RETROMULTI1_OBJ_BANK,0,RETROMULTI1_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,1100,1100,60,"BRUCE",12000,0,
		STR_LEVEL_RETROMULTI2,"SUPER1",0,	LEVELID_SUPERRETRO12,LEVELID_SUPERRETRO2,WORLDID_SUPERRETRO,RETROMULTI2_OBJ_BANK,0,RETROMULTI2_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,1100,1100,60,"BRUCE",12000,0,
//		STR_LEVEL_RETROMULTI3,"SUPER1",0,	LEVELID_SUPERRETRO13,LEVELID_SUPERRETRO2,WORLDID_SUPERRETRO,RETROMULTI3_OBJ_BANK,0,RETROMULTI3_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,1100,1100,60,"BRUCE",12000,
//		STR_LEVEL_RETROMULTI4,"SUPER1",0,	LEVELID_SUPERRETRO14,LEVELID_SUPERRETRO2,WORLDID_SUPERRETRO,RETROMULTI4_OBJ_BANK,0,RETROMULTI4_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,1100,1100,60,"BRUCE",12000,
//		STR_LEVEL_RETROMULTI5,"SUPER1",0,	LEVELID_SUPERRETRO15,LEVELID_SUPERRETRO2,WORLDID_SUPERRETRO,RETROMULTI5_OBJ_BANK,0,RETROMULTI5_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,1100,1100,60,"BRUCE",12000,
		STR_LEVEL_RETROMULTI3,"SUPER1",0,	LEVELID_SUPERRETRO16,LEVELID_SUPERRETRO2,WORLDID_SUPERRETRO,RETROMULTI6_OBJ_BANK,0,RETROMULTI6_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,1100,1100,60,"BRUCE",12000,0,
//		STR_LEVEL_RETROMULTI7,"SUPER1",0,	LEVELID_SUPERRETRO17,LEVELID_SUPERRETRO2,WORLDID_SUPERRETRO,RETROMULTI7_OBJ_BANK,0,RETROMULTI7_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,1100,1100,60,"BRUCE",12000,
//		STR_LEVEL_RETROMULTI8,"SUPER1",0,	LEVELID_SUPERRETRO18,LEVELID_SUPERRETRO2,WORLDID_SUPERRETRO,RETROMULTI8_OBJ_BANK,0,RETROMULTI8_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,1100,1100,60,"BRUCE",12000,
		STR_LEVEL_RETROMULTI4,"SUPER1",0,	LEVELID_SUPERRETRO19,LEVELID_SUPERRETRO2,WORLDID_SUPERRETRO,RETROMULTI9_OBJ_BANK,0,RETROMULTI9_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,1100,1100,60,"BRUCE",12000,0,
//		STR_LEVEL_RETROMULTI10,"SUPER1",0,	LEVELID_SUPERRETRO20,LEVELID_SUPERRETRO2,WORLDID_SUPERRETRO,RETROMULTI10_OBJ_BANK,0,RETROMULTI10_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,1100,1100,60,"BRUCE",12000,
		},
	},

//------------------------------------------------

	{
	-1,			// description
	WORLDID_FRONTEND,		// world ID
	FRONTEND_OBJ_BANK,	// master object bank
	FRONTEND_TEX_BANK,	// master texture bank
	WORLD_OPEN,
	5,						// number of levels
	5,						// number of single player levels
		{
		STR_LEVEL_UNNAMED,"GARDEN1",0,		LEVELID_FRONTEND1,LEVELID_FRONTEND1,WORLDID_FRONTEND,FRONTEND1_OBJ_BANK,0,FRONTEND1_COL,LEVEL_OPEN,0,-1,0, 120,120,160,350,6500,60,"MATT",7000,FRONTEND1_STAK,
		STR_LEVEL_UNNAMED,"GARDEN1",0,		LEVELID_FRONTEND2,LEVELID_FRONTEND1,WORLDID_FRONTEND,FRONTEND2_OBJ_BANK,0,FRONTEND2_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,1100,1100,60,"MATT",7000,0,
		STR_LEVEL_UNNAMED,"GARDEN1",0,		LEVELID_FRONTEND3,LEVELID_FRONTEND1,WORLDID_FRONTEND,FRONTEND3_OBJ_BANK,0,FRONTEND3_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,1100,1100,60,"MATT",7000,0,
		STR_LEVEL_TRAINING,"GARDEN1",0,		LEVELID_FRONTEND4,LEVELID_GARDEN1,WORLDID_GARDEN,FRONTEND4_OBJ_BANK,0,FRONTEND4_COL,LEVEL_OPEN,0,-1,0, 120,120,160,350,900,60,"MATT",7000,0,
		STR_LEVEL_UNNAMED,"GARDEN1",0,		LEVELID_FRONTEND5,LEVELID_FRONTEND1,WORLDID_FRONTEND,FRONTEND5_OBJ_BANK,0,FRONTEND5_COL,LEVEL_OPEN,0,-1,0, 0,0, 0,1100,1100,60,"MATT",7000,0,
		},
	}
};


/*	--------------------------------------------------------------------------------
	Function		: LoadVisualBanksForWorld
	Purpose			: loads the relevant object and texture banks for a world
	Parameters		: unsigned long,unsigned long
	Returns			: void
	Info			: 
*/
void LoadVisualBanksForWorld(unsigned long worldID,unsigned long levelID)
{
#ifndef  PSX_VERSION
	MDX_ACTOR *tActor;
#endif
	unsigned long i;
	long objBankToUse;
	long texBankToUse;

	objBankToUse = worldVisualData[worldID].masterObjectBank;
	texBankToUse = worldVisualData[worldID].masterTextureBank;

#ifdef PSX_VERSION
//ma	LoadStakFile ( GENERIC_STAK );
#endif

	// Contains frogger and froglet - probably quite important
	LoadObjectBank ( INGAMEGENERIC_OBJ_BANK );

	// Load multiple frogs for multiplayer modes - note the lovely comparison(0/1) multiplied by the number of frogs
	// to get an offset for multiplayer :)
#ifdef PSX_VERSION
//ma	for( i=0; i<NUM_FROGS; i++ )
//ma		LoadStakFile ( FROGGER_STAK + player[i].character + ((gameState.multi != SINGLEPLAYER)*FROG_NUMFROGS) );
#endif

	for( i=0; i<NUM_FROGS; i++ )
		LoadObjectBank( FROGGER_OBJ_BANK + player[i].character + ((gameState.multi != SINGLEPLAYER)*FROG_NUMFROGS) );

	LoadTextureBank(texBankToUse);
	LoadObjectBank(objBankToUse);

	if(worldVisualData[worldID].levelVisualData[levelID].collBank > -1)
	{
		if(worldVisualData[worldID].levelVisualData[levelID].objectBankToUse > 0)
			LoadObjectBank(worldVisualData[worldID].levelVisualData[levelID].objectBankToUse);
	}

#ifndef PSX_VERSION
	if( (tActor = CreateActor("world.obe",INIT_ANIMATION)) )
	{
		world = ConvertActorToLandscape(tActor);
		FreeActor(&tActor);
	}
#endif
}

void UpdateCompletedLevel(unsigned long worldID,unsigned long levelID)
{
	if (levelID<3)
		worldVisualData[worldID].levelVisualData[levelID+1].levelOpen = LEVEL_OPEN;
}


#ifdef PSX_VERSION
void InitLoadingScreen( const char *filename )
{
	SetProgressBar(0);

	// JH: Lets load up the backdrop before we do any thing
	InitBackdrop ( "LOADING" );

	SetCurrentDisplayPage ( 1, 0 );

	// JH: And now let's draw it so that it goes straight to the screen, hence the 1.....
	DrawBackDrop(0, 1);
	DrawLoadingBar(0);

	SendOTDisp();

//ma	displayPage[0].drawenv.isbg = displayPage[1].drawenv.isbg = 0;
}

void UpdateLoadingScreen( short addprog )
{
	StepProgressBar(addprog);

	SetCurrentDisplayPage ( 1, 0 );

	// JH: And now let's draw it so that it goes straight to the screen, hence the 1.....
	DrawLoadingBar(0);

	SendOTDisp();
}

void FreeLoadingScreen( )
{
	ResetDrawingEnvironment();

	FreeBackdrop();
}
#endif

/* --------------------------------------------------------------------------------
	Programmer	: Matthew Cloy
	Function	: InitLevel
	Purpose		:
	Parameters	: unsigned long , unsigned long
	Returns		: void 
*/
extern unsigned long actTickCountModifier;
extern unsigned long actTickCount;

long numLevelsPlayed = 0;
void InitLevel(unsigned long worldID,unsigned long levelID)
{
	int i;
	FVECTOR tempPos;
	GAMETILE *tempTile;


#ifdef PC_VERSION
	pFrameModifier = 0;
#endif
	numLevelsPlayed++;

	player[0].worldNum = worldID;
	player[0].levelNum = levelID;

#ifdef PC_VERSION
	dp("                                                                                 %lu Levels Played\n",numLevelsPlayed);
#endif

	// ------ Free existing data and setup for loading ------------
	FreeAllLists();

//	memoryShow();

	InitLoadingScreen( "LOADING01" );

#ifdef PSX_VERSION
	//jiggledVerts = MALLOC0 ( sizeof ( SVECTOR ) * 700 );

//ma	SpuSetKey(SPU_OFF,0xffffff);
//ma	FreeBackdrop();
//	DrawBackDrop(0, 1);

	oldActor.psiData.object = NULL;
#endif

	UpdateLoadingScreen( 10 );

	lastActFrameCount = 0;
	actFrameCount = 0;
	frameCount = 1;

#ifdef PC_VERSION
	InitTiming(60);
#else PSX_VERSION	
	psiInitialise(100);

//	psiInitLights();
//	psiSetAmbient(128,128,128);
//ma	psiRegisterDrawFunction(LSCAPE_DrawSortedPrimitives);
//ma	psiRegisterDrawFunction2(customDrawPrimitives2);
	InitTextureAnimLinkedList();
#endif


	UpdateLoadingScreen( 10 );

#ifndef E3_DEMO
	// Only Frogger works on the playStation right now! bahh.

	if ((gameState.mode != FRONTEND_MODE) && (gameState.multi == SINGLEPLAYER) && (gameState.single == STORY_MODE)) // - hello yes, I am testing
		StoryStartLevel();
#endif

	// ------ Initialise lists ------------

	InitSpriteList();
#ifdef PC_VERSION
	InitSpriteSortArray();
#endif
	InitSampleList();
	InitAmbientSoundList();
	
	
	// ------ Load data from disk ------------

	if (useAudio)
		LoadSfx(worldID);

	UpdateLoadingScreen( 20 );

#ifdef PSX_VERSION
	// JH: Here we load the super new large file, which contains all level info.
//ma	LoadStakFile ( worldVisualData[worldID].levelVisualData[levelID].stakFileToUse );
#endif

	LoadMapBank(worldVisualData[worldID].levelVisualData[levelID].collBank);

	LoadTextureBank ( INGAMEGENERIC_TEX_BANK );
#ifdef PSX_VERSION
	fontInitButtonSprites();
	LoadTextureAnimBank ( INGAMEGENERIC_TEX_BANK );
#endif

	LoadVisualBanksForWorld ( worldID, levelID );

	UpdateLoadingScreen( 20 );


	// ------ Initialise more lists ------------

	InitSpecFXList();
	InitParticleList( );
	
	InitSpriteOverlayLinkedList();

	if (gameState.mode == FRONTEND_MODE)
	{
		InitTextOverlayLinkedList(200);
	}
	else
	{
		InitTextOverlayLinkedList(30);
	}


	// ------ Populate game lists ------------

#ifdef PSX_VERSION
	LoadTextureAnimBank ( worldVisualData [ worldID ].masterTextureBank );
	InitWaterLinkedList();
	InitScenicObjLinkedList();
#endif

#ifdef PC_VERSION
	PTTextureLoad();
#endif

	InitBabyList( TRUE );
	InitEnemyLinkedList();
	InitPlatformLinkedList();
	InitGaribList();
	InitTriggerList();

	CreateFrogger(1,1);
	CreateLevelObjects ( worldID, levelID );

	InitTongues( );

	UpdateLoadingScreen( 15 );

	utilPrintf("Loading............\n");

	fog.r = worldVisualData[worldID].levelVisualData[levelID].fogR;
	fog.g = worldVisualData[worldID].levelVisualData[levelID].fogG;
	fog.b = worldVisualData[worldID].levelVisualData[levelID].fogB;
	fog.min = worldVisualData[worldID].levelVisualData[levelID].fogNearDist;
	fog.max = worldVisualData[worldID].levelVisualData[levelID].farClip;
//	fog.max = worldVisualData[worldID].levelVisualData[levelID].fogFarDist;
	
#ifdef PC_VERSION
	dp("Fog to c(%lu,%lu,%lu) from %lu\n",fog.r,fog.g,fog.b,fog.min);
#endif

	LoadLevelEntities( worldVisualData[worldID].worldID, worldVisualData[worldID].levelVisualData[levelID].levelID );

#ifdef PSX_VERSION
	if ( (worldID == 1 && levelID == 5) )//||
/*		   (worldID == 1 && levelID == 5) ||
			 (worldID == 3 && levelID == 5) ||
			 (worldID == 5 && levelID == 4) || 
			 (worldID == 5 && levelID == 5) || 
			 (worldID == 5 && levelID == 6) || 
			 (worldID == 7 && levelID == 10)|| 
			 (worldID == 7 && levelID == 11)|| 
			 (worldID == 7 && levelID == 15)|| 
			 (worldID == 7 && levelID == 18)|| */
//			 (worldID == 1 && levelID == 5)) 
	{
		utilPrintf("World   %d : %d\n", worldID, levelID );
	}
	else
	{
		LoadLevelScript( worldVisualData[worldID].worldID, worldVisualData[worldID].levelVisualData[levelID].levelID );
	}
	// ENDIF

#else
	LoadLevelScript( worldVisualData[worldID].worldID, worldVisualData[worldID].levelVisualData[levelID].levelID );
#endif


	UpdateLoadingScreen( 20 );

	if (useAudio)
		LoadSfxMapping(worldID,levelID);

	InitInGameTextOverlays(worldID,levelID);



	if((reverseMode) && (numBabies))
	{
		SetVectorFF(&tempPos,&frog[0]->actor->position);
		SetVectorFF(&frog[0]->actor->position,&babyList[numBabies - 1].baby->actor->position);
		SetVectorFF(&babyList[numBabies - 1].baby->actor->position,&tempPos);

		tempTile = currTile[0];
		currTile[0] = babyList[numBabies - 1].enemy->inTile;
		babyList[numBabies - 1].enemy->inTile = tempTile;
	}


	ResetCamera( );
	InitCamera();

	if( gameState.multi != SINGLEPLAYER )
	{
		ReinitialiseMultiplayer( );
		ResetMultiplayer( );
	}

	// ------ Reset miscellaneous pieces of data ------------

	// Stuff that used to be in RunGameLoop
	if( gameState.single != STORY_MODE )
		player[0].lives = 10;

	player[0].score				= 0;
	player[0].spawnTimer		= 0;
	player[0].spawnScoreLevel	= 1;
	GTInit( &scoreTimer, 90 );

	if( worldID == WORLDID_FRONTEND || gameState.multi != SINGLEPLAYER )
	{
		garibCount->draw = 0;
		creditCount->draw = 0;
		countdownTimer = 0;

		i = numBabies;
		while(i--)
			babyIcons[i]->draw = 0;

		if((worldID == WORLDID_FRONTEND) && (levelID == LEVELID_FRONTEND1))
		{
			NUM_FROGS = 1;
			gameState.multi = SINGLEPLAYER;

//			flogo[0] = CreateAndAddSpriteOverlay(1254,2176,"FROGGER2",1638,2048,255,0) ;
//			flogo[0]->speed = 81920;
//			fadingLogos = 0;
		}
	}

	// ---- Set up any other miscellaneous level variables

#ifdef PSX_VERSION
	psiAllocWorkspace();
	AllowPsiDestroy = 1;

//	InitWater();

#else
	InitTiming(60);
#endif

	actFrameCount = 0;
	drawLandscape = 1;

	UpdateLoadingScreen( 100 );
	FreeLoadingScreen( );

	ScreenFade(0,0,1);
	keepFade = 1;

	// Here's a little experiment.. if we update things once here, it might stop things from
	// jumping on frame 1 (perhaps.) - Dave

	UpdateEnemies();
	UpdatePlatforms();

	if((worldID == WORLDID_FRONTEND) && (levelID == LEVELID_FRONTEND4))
		InitTrainingMode();

	UpdateEvents();

// JH : #ifdefed because we need a cd for this to work, so uncomment when we have one.....................
#ifdef PC_VERSION
	if(useAudio)
		PrepareSong((short)worldID);
#else
	bb_InitXA();
	if(useAudio && XAgetStatus())
		PrepareSong((short)worldID);
	displayPage[0].drawenv.isbg = displayPage[1].drawenv.isbg = 1;
#endif

	//memoryShow();
	//memoryShowStats();
	SetMusicVolume();
}


/*	--------------------------------------------------------------------------------
	Function		: FreeAllLists
	Purpose			: 
	Parameters		: 
	Returns			: 
	Info			: 
*/
void FreeAllLists()
{
	utilPrintf("----------------------------------\n");
	utilPrintf("----- FREEING ALL LISTS ----------\n");
	utilPrintf("----------------------------------\n");

	//memoryShow();
	//memoryShowStats();

#ifdef PC_VERSION
	StopSong( );
#endif
//ma	FreeStakFiles();

	FreeMap();
	FreeEntityBank();
	FreeScenic();

	FreeAmbientSoundList();
	FreeSampleList();

	FreeTriggerList();
	//KillAllTriggers();

	ResetBabies( );

	FreeEnemyLinkedList();
	FreePlatformLinkedList();
	FreePathList();
	FreeTransCameraList();
	FreeLevelScript();
	FreeTongues();
	FreeWaterObjectList();

	FreeSpecFXList( );
	
	if( gameState.multi != SINGLEPLAYER )
		FreeMultiplayer( );

	FreeParticleList();
	FreeGaribList();
	FreeActorList();
#ifdef PSX_VERSION
	actorInitialise();
#endif

	FreeAllObjectBanks();
	FreeAllTextureBanks();
	
	FreeTextOverlayLinkedList();
	FreeSpriteOverlayLinkedList();
	FreeSpriteList();


#ifdef PC_VERSION
	FreeProcTextures();

	InitSpriteSortArray();
#else PSX_VERSION
	FreeScenicObjectList();
	FreeTextureAnimList();
#endif

#ifdef PC_VERSION		
	FreeLandscape(&world);
#endif

#ifdef PSX_VERSION
	if(AllowPsiDestroy)
	{
		utilPrintf("psi destroy\n");
		psiDestroy();
		AllowPsiDestroy = 0;
	}
	//FreeBackdrop();
#endif

#ifdef PC_VERSION
	FreeUniqueActorList();
#endif
	
#ifdef PSX_VERSION
	if ( font )
		fontUnload ( font );
	// ENDIF
	font = NULL;

	if ( fontSmall )
		fontUnload ( fontSmall );
	// ENDIF
	fontSmall = NULL;

#endif

//	FREE(playKeyList);

	//memoryShow();
	//memoryShowStats();

#ifdef PSX_VERSION

	memoryReset();
	memoryDestroy();

//	psxCroakVtx=NULL;
	ringVtx = NULL;

	//memoryShow();
	//memoryShowStats();

	MainReset();

	//memoryShow();
	//memoryShowStats();


	//videoInit ( 1024, 3000, 0 );


	//textureInitialise ( 500, 8);
	font = fontLoad("font.pvr");
	fontSmall = fontLoad("smallfont.pvr");
	
	gameTextInit("LANGUAGE.TXT", LANG_NUM_STRINGS, LANG_NUM_LANGUAGES, gameTextLang);

	//FREE ( jiggledVerts );
#endif



//mm	pOIDistance = ToFixed(500000);
//mm	pointOfInterest = NULL;

	fog.mode = 0;
	pauseMode		= 0;
	darkenedLevel	= 0;
	backGnd = NULL;
	tileNum = NULL;
	dkPressed = 0;

#ifdef PC_VERSION
	headMatrix = NULL;
	if( breastMatrix )
		FREE( breastMatrix );
	breastMatrix = NULL;

	if( headPostMatrix )
		FREE( headPostMatrix );
	headPostMatrix = NULL;
#else
	{
		int i;

		//free the 4 head matrix pointers
		pHeadMatrix = NULL;
		for(i=0; i<4; i++)
		{
			pBreastMatrix[i] = NULL;
		}
	}

#endif

	utilPrintf("----------------------------------\n");
	utilPrintf("----- DONE FREEING ALL LISTS -----\n");
	utilPrintf("----------------------------------\n");
}

/*
void		**gameTextStr;
static void *gameTextBuffer;

void gameTxtInit(char *fName, int numStrings, int numLang, int currLang)
{
	char	*bufPtr, *compactBuf;
	int		loop, lang, len = 0;


	gameTextStr = (void **)MALLOC(sizeof(void *) * numStrings);

	gameTextBuffer = fileLoad(fName,0);
	bufPtr = (char *)gameTextBuffer;
	for(loop=0; loop<numStrings; loop++)
	{
		for(lang=-2; lang<numLang; lang++)
		{
			if (*bufPtr=='\"')
				bufPtr++;
			if (lang==currLang)
				gameTextStr[loop] = bufPtr;
			while((*bufPtr!=13) && (*bufPtr!=10) && (*bufPtr!='\t') && (*bufPtr!='\0'))
				bufPtr++;
			if (*(bufPtr-1)=='\"')
				*(bufPtr-1) = '\0';
			*bufPtr++ = '\0';
			if ((*bufPtr==13)||(*bufPtr==10))
				bufPtr++;
			if (lang==currLang)
				len += strlen(gameTextStr[loop]);
		}
	}

	bufPtr = compactBuf = MALLOC(len+numStrings);
	printf("small game text = %d\n", len+numStrings);
	for(loop=0; loop<numStrings; loop++)
	{
		strcpy(bufPtr, gameTextStr[loop]);
		gameTextStr[loop] = bufPtr;
		bufPtr += strlen(gameTextStr[loop])+1;
//		printf("[%d][%s]\n", loop, gameTextStr[loop]);
	}
	FREE(gameTextBuffer);
	gameTextBuffer = compactBuf;
	compactBuf = MALLOC(len+numStrings);
	memcpy(compactBuf, gameTextBuffer, len+numStrings);
	for(loop=0; loop<numStrings; loop++)
	{
		gameTextStr[loop] -= (unsigned long)gameTextBuffer;
		gameTextStr[loop] += (unsigned long)compactBuf;
	}
	FREE(gameTextBuffer);
	gameTextBuffer = compactBuf;
}
*/

void CommonInit(void)
{
	frameCount=1;
	lastActFrameCount = actFrameCount = 1;

	gameTextInit("LANGUAGE.TXT", LANG_NUM_STRINGS, LANG_NUM_LANGUAGES, gameTextLang);

#ifdef PC_VERSION
	memcpy(worldVisualData,origWorldVisualData,sizeof(worldVisualData));
#endif

	frame = 0;
	quitMainLoop = 0;
	InitMatrixStack();

	player[0].worldNum = WORLDID_ANCIENT;
	player[0].levelNum = LEVELID_FRONTEND1;
	gameState.multi = MULTILOCAL;//SINGLEPLAYER;

	GTInit( &modeTimer, 1 );
	frameCount = 0;
			
	// JH: This is done at the start of Initlevel, doses this really need to be done here...........
	//	FreeAllLists();
	frameCount = 0;
	player[0].numSpawn	= 0;

#ifdef E3_DEMO
	StartE3LevelSelect();
#else
	gameState.mode = FRONTEND_MODE;
	InitLevel(player[0].worldNum,player[0].levelNum);
#ifdef PC_VERSION
	LoadGame();
#endif
#endif
}

