SBSPSS/source/map/map.cpp

790 lines
23 KiB
C++
Raw Normal View History

2001-04-24 18:15:04 +02:00
/*=========================================================================
map.cpp
Author: PKG
Created:
Project: Spongebob
Purpose:
Copyright (c) 2001 Climax Development Ltd
===========================================================================*/
/*----------------------------------------------------------------------
Includes
-------- */
2001-04-24 21:37:12 +02:00
#include "map\map.h"
2001-04-24 18:15:04 +02:00
#ifndef __GFX_FONT_H__
#include "gfx\font.h"
#endif
#ifndef __PAD_PADS_H__
#include "pad\pads.h"
#endif
#ifndef __PRIM_HEADER__
#include "gfx\prim.h"
#endif
2001-04-25 20:15:19 +02:00
#ifndef __GAME_GAME_H__
#include "game\game.h"
2001-04-24 18:15:04 +02:00
#endif
2001-07-02 17:46:34 +02:00
#ifndef __SAVE_SAVE_H__
#include "save\save.h"
#endif
2001-04-24 18:15:04 +02:00
#ifndef __GFX_FADER_H__
#include "gfx\fader.h"
#endif
2001-04-24 21:37:12 +02:00
#ifndef __VID_HEADER_
#include "system\vid.h"
#endif
#ifndef _FILEIO_HEADER_
#include "fileio\fileio.h"
#endif
2001-04-25 01:14:50 +02:00
#ifndef __MATHTABLE_HEADER__
#include "utils\mathtab.h"
#endif
2001-05-09 22:15:01 +02:00
#ifndef __GAME_GAMESLOT_H__
#include "game\gameslot.h"
#endif
2001-06-06 04:11:50 +02:00
#ifndef __SOUND_SOUND_H__
#include "sound\sound.h"
#endif
2001-06-19 00:58:36 +02:00
#ifndef __GUI_POINTER_H__
#include "gui\pointer.h"
#endif
2001-04-24 18:15:04 +02:00
2001-07-11 16:42:13 +02:00
#ifndef __FMA_FMA_H__
#include "fma\fma.h"
#endif
2001-07-25 18:20:01 +02:00
#include "utils\lznp.h"
2001-06-19 00:58:36 +02:00
2001-04-24 18:15:04 +02:00
/* Std Lib
------- */
/* Data
---- */
#ifndef __STRING_ENUMS__
#include <trans.h>
#endif
2001-04-25 01:14:50 +02:00
#ifndef __SPR_SPRITES_H__
#include <sprites.h>
#endif
2001-05-30 16:58:29 +02:00
// Level data include files:
#include <CHAPTER01_LEVEL01_INF.h>
#include <CHAPTER01_LEVEL02_INF.h>
#include <CHAPTER01_LEVEL03_INF.h>
#include <CHAPTER01_LEVEL04_INF.h>
#include <CHAPTER02_LEVEL01_INF.h>
#include <CHAPTER02_LEVEL02_INF.h>
#include <CHAPTER02_LEVEL03_INF.h>
#include <CHAPTER02_LEVEL04_INF.h>
#include <CHAPTER03_LEVEL01_INF.h>
#include <CHAPTER03_LEVEL02_INF.h>
#include <CHAPTER03_LEVEL03_INF.h>
#include <CHAPTER03_LEVEL04_INF.h>
#include <CHAPTER04_LEVEL01_INF.h>
#include <CHAPTER04_LEVEL02_INF.h>
#include <CHAPTER04_LEVEL03_INF.h>
#include <CHAPTER04_LEVEL04_INF.h>
#include <CHAPTER05_LEVEL01_INF.h>
#include <CHAPTER05_LEVEL02_INF.h>
#include <CHAPTER05_LEVEL03_INF.h>
#include <CHAPTER05_LEVEL04_INF.h>
#include <CHAPTER06_LEVEL01_INF.h>
#include <CHAPTER06_LEVEL02_INF.h>
#include <CHAPTER06_LEVEL03_INF.h>
#include <CHAPTER06_LEVEL04_INF.h>
#include <CHAPTER06_LEVEL05_INF.h>
2001-04-24 18:15:04 +02:00
/*----------------------------------------------------------------------
Tyepdefs && Defines
------------------- */
/*----------------------------------------------------------------------
Structure defintions
-------------------- */
/*----------------------------------------------------------------------
Function Prototypes
------------------- */
/*----------------------------------------------------------------------
Vars
---- */
CMapScene MapScene;
2001-07-25 18:20:01 +02:00
CMapScene::sMapLevelGfxTable CMapScene::s_GfxTable[MAP_GFX_MAX]=
{
{MAP_C1_L1_GFX,0},
{MAP_C1_L2_GFX,0},
{MAP_C1_L3_GFX,0},
{MAP_C1_L4_GFX,0},
{MAP_C1_FAIR_GFX,0},
{MAP_C2_L1_GFX,0},
{MAP_C2_L2_GFX,0},
{MAP_C2_L3_GFX,0},
{MAP_C2_L4_GFX,0},
{MAP_C2_FAIR_GFX,0},
{MAP_C3_L1_GFX,0},
{MAP_C3_L2_GFX,0},
{MAP_C3_L3_GFX,0},
{MAP_C3_L4_GFX,0},
{MAP_C3_FAIR_GFX,0},
{MAP_C4_L1_GFX,0},
{MAP_C4_L2_GFX,0},
{MAP_C4_L3_GFX,0},
{MAP_C4_L4_GFX,0},
{MAP_C4_FAIR_GFX,0},
{MAP_C5_L1_GFX,0},
{MAP_C5_L2_GFX,0},
{MAP_C5_L3_GFX,0},
{MAP_C5_L4_GFX,0},
{MAP_C5_FAIR_GFX,0},
};
2001-04-24 18:15:04 +02:00
2001-05-30 16:58:29 +02:00
CMapScene::sMapLevelData CMapScene::s_mapLevelData[MAP_NUM_CHAPTERS][MAP_NUM_LEVELS_PER_CHAPTER]=
2001-04-25 20:15:19 +02:00
{
2001-07-25 18:20:01 +02:00
// mapFile Gfx, globalLevelNumber spatulaOrTokenCounts questItemFrame kelpWorldLevel
2001-04-25 20:15:19 +02:00
{
2001-07-25 18:20:01 +02:00
{ MAP_GFX_C1_L1, 0, CHAPTER01_LEVEL01_INF_TOTAL_ITEM_GOLDEN_SPATULA, FRM__C1_L1_QUEST_ITEM, false },
{ MAP_GFX_C1_L2, 1, CHAPTER01_LEVEL02_INF_TOTAL_ITEM_GOLDEN_SPATULA, FRM__C1_L2_QUEST_ITEM, false },
{ MAP_GFX_C1_L3, 2, CHAPTER01_LEVEL03_INF_TOTAL_ITEM_GOLDEN_SPATULA, FRM__C1_L3_QUEST_ITEM, false },
{ MAP_GFX_C1_L4, 3, CHAPTER01_LEVEL04_INF_TOTAL_ITEM_GOLDEN_SPATULA, FRM__C1_L4_QUEST_ITEM, false },
{ MAP_GFX_C1_FAIR, 4, CHAPTER06_LEVEL01_INF_TOTAL_ITEM_KELP_TOKEN, -1, true },
2001-04-25 20:15:19 +02:00
},
{
2001-07-25 18:20:01 +02:00
{ MAP_GFX_C2_L1, 5, CHAPTER02_LEVEL01_INF_TOTAL_ITEM_GOLDEN_SPATULA, FRM__C2_L1_QUEST_ITEM, false },
{ MAP_GFX_C2_L2, 6, CHAPTER02_LEVEL02_INF_TOTAL_ITEM_GOLDEN_SPATULA, FRM__C2_L2_QUEST_ITEM, false },
{ MAP_GFX_C2_L3, 7, CHAPTER02_LEVEL03_INF_TOTAL_ITEM_GOLDEN_SPATULA, FRM__C2_L3_QUEST_ITEM, false },
{ MAP_GFX_C2_L4, 8, CHAPTER02_LEVEL04_INF_TOTAL_ITEM_GOLDEN_SPATULA, FRM__C2_L4_QUEST_ITEM, false },
{ MAP_GFX_C2_FAIR, 9, CHAPTER06_LEVEL02_INF_TOTAL_ITEM_KELP_TOKEN, -1, true },
2001-04-25 20:15:19 +02:00
},
{
2001-07-25 18:20:01 +02:00
{ MAP_GFX_C3_L1, 10, CHAPTER03_LEVEL01_INF_TOTAL_ITEM_GOLDEN_SPATULA, FRM__C3_L1_QUEST_ITEM, false },
{ MAP_GFX_C3_L2, 11, CHAPTER03_LEVEL02_INF_TOTAL_ITEM_GOLDEN_SPATULA, FRM__C3_L2_QUEST_ITEM, false },
{ MAP_GFX_C3_L3, 12, CHAPTER03_LEVEL03_INF_TOTAL_ITEM_GOLDEN_SPATULA, FRM__C3_L3_QUEST_ITEM, false },
{ MAP_GFX_C3_L4, 13, CHAPTER03_LEVEL04_INF_TOTAL_ITEM_GOLDEN_SPATULA, FRM__C3_L4_QUEST_ITEM, false },
{ MAP_GFX_C3_FAIR, 14, CHAPTER06_LEVEL03_INF_TOTAL_ITEM_KELP_TOKEN, -1, true },
2001-04-25 20:15:19 +02:00
},
{
2001-07-25 18:20:01 +02:00
{ MAP_GFX_C4_L1, 15, CHAPTER04_LEVEL01_INF_TOTAL_ITEM_GOLDEN_SPATULA, FRM__C4_QUEST_ITEM_1, false },
{ MAP_GFX_C4_L2, 16, CHAPTER04_LEVEL02_INF_TOTAL_ITEM_GOLDEN_SPATULA, FRM__C4_QUEST_ITEM_1, false },
{ MAP_GFX_C4_L3, 17, CHAPTER04_LEVEL03_INF_TOTAL_ITEM_GOLDEN_SPATULA, FRM__C4_QUEST_ITEM_1, false },
{ MAP_GFX_C4_L4, 18, CHAPTER04_LEVEL04_INF_TOTAL_ITEM_GOLDEN_SPATULA, FRM__C4_QUEST_ITEM_1, false },
{ MAP_GFX_C4_FAIR, 19, CHAPTER06_LEVEL04_INF_TOTAL_ITEM_KELP_TOKEN, -1, true },
2001-04-25 20:15:19 +02:00
},
{
2001-07-25 18:20:01 +02:00
{ MAP_GFX_C5_L1, 20, CHAPTER05_LEVEL01_INF_TOTAL_ITEM_GOLDEN_SPATULA, FRM__C5_L1_QUEST_ITEM, false },
{ MAP_GFX_C5_L2, 21, CHAPTER05_LEVEL02_INF_TOTAL_ITEM_GOLDEN_SPATULA, FRM__C5_L2_QUEST_ITEM, false },
{ MAP_GFX_C5_L3, 22, CHAPTER05_LEVEL03_INF_TOTAL_ITEM_GOLDEN_SPATULA, FRM__C5_L3_QUEST_ITEM, false },
{ MAP_GFX_C5_L4, 23, CHAPTER05_LEVEL04_INF_TOTAL_ITEM_GOLDEN_SPATULA, FRM__C5_L4_QUEST_ITEM, false },
{ MAP_GFX_C5_FAIR, 24, CHAPTER06_LEVEL05_INF_TOTAL_ITEM_KELP_TOKEN, -1, true },
2001-04-25 20:15:19 +02:00
},
};
2001-05-30 16:58:29 +02:00
2001-08-03 01:44:21 +02:00
// Positions of map gfx on the screen
DVECTOR CMapScene::s_mapLevelPositions[CMapScene::MAP_NUM_LEVELS_PER_CHAPTER]=
2001-05-30 16:58:29 +02:00
{
2001-08-03 01:44:21 +02:00
{ 42,49 }, // MAP_ICON_LEVEL_1
{ 186,49 }, // MAP_ICON_LEVEL_2
{ 330,49 }, // MAP_ICON_LEVEL_3
{ 42,113 }, // MAP_ICON_LEVEL_4
{ 330,113 }, // MAP_ICON_LEVEL_BONUS
2001-05-30 16:58:29 +02:00
};
2001-08-03 01:44:21 +02:00
// Cursor positions for all icons
2001-08-09 21:51:18 +02:00
DVECTOR CMapScene::s_mapPointerPositions[CMapScene::MAP_NUM_LEVELS_PER_CHAPTER+2]=
2001-08-03 01:44:21 +02:00
{
2001-08-09 21:51:18 +02:00
{ MAP_CHAPTER_ARROW_XOFF,MAP_CHAPTER_ARROW_Y+25 }, // MAP_ICON_PREVIOUS_CHAPTER
{ 42+(MAP_LEVEL_WIDTH/2),49+MAP_LEVEL_HEIGHT }, // MAP_ICON_LEVEL_1
{ 186+(MAP_LEVEL_WIDTH/2),49+MAP_LEVEL_HEIGHT }, // MAP_ICON_LEVEL_2
{ 330+(MAP_LEVEL_WIDTH/2),49+MAP_LEVEL_HEIGHT }, // MAP_ICON_LEVEL_3
{ 42+(MAP_LEVEL_WIDTH/2),113+MAP_LEVEL_HEIGHT }, // MAP_ICON_LEVEL_4
{ 330+(MAP_LEVEL_WIDTH/2),113+MAP_LEVEL_HEIGHT }, // MAP_ICON_LEVEL_BONUS
{ 512-MAP_CHAPTER_ARROW_XOFF,MAP_CHAPTER_ARROW_Y+25 }, // MAP_ICON_NEXT_CHAPTER
2001-08-03 01:44:21 +02:00
};
2001-06-13 16:35:14 +02:00
int CMapScene::s_chapterToStartOn=0;
int CMapScene::s_levelToStartOn=0;
2001-06-13 16:28:41 +02:00
2001-05-30 16:58:29 +02:00
2001-04-25 20:15:19 +02:00
extern int s_globalLevelSelectThing;
2001-04-24 18:15:04 +02:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CMapScene::init()
{
2001-07-28 18:45:46 +02:00
CLevel::DisplayLoadingScreen();
2001-04-24 21:37:12 +02:00
m_font=new ("map screen font") FontBank();
2001-04-24 18:15:04 +02:00
m_font->initialise(&standardFont);
2001-04-25 01:14:50 +02:00
m_font->setOt(10);
m_font->setJustification(FontBank::JUST_LEFT);
2001-06-13 16:28:41 +02:00
m_currentChapterSelection=s_chapterToStartOn;
2001-07-29 21:06:48 +02:00
2001-07-28 18:45:46 +02:00
m_screenImage=MemAlloc(512*256*2,"MapScreen");
2001-07-29 21:06:48 +02:00
ASSERT(m_screenImage);
m_packedBackgroundImage=(char*)CFileIO::loadFile(MAP_MAP_BACKGROUND_GFX);
ASSERT(m_packedBackgroundImage);
2001-07-25 18:20:01 +02:00
// Load level Gfx
for (int i=0; i<MAP_GFX_MAX; i++)
{
s_GfxTable[i].Gfx=(u8*)CFileIO::loadFile((FileEquate)s_GfxTable[i].Filename,"MapLevelGfx");
}
2001-04-25 20:15:19 +02:00
generateMapScreenImage();
2001-08-03 01:44:21 +02:00
m_currentIconSelection=s_levelToStartOn+1;
2001-06-19 00:58:36 +02:00
m_pointerIcon=new ("MapPointer") CPointerIcon();
m_pointerIcon->snapToTarget(getPointerTargetPosition());
2001-06-13 16:28:41 +02:00
2001-04-24 21:37:12 +02:00
SetScreenImage((u8*)m_screenImage);
2001-04-25 01:14:50 +02:00
m_readyToExit=false;
2001-06-21 00:57:27 +02:00
CFader::setFadingIn();
2001-07-02 18:29:53 +02:00
CSoundMediator::setSong(CSoundMediator::SONG_MAPSCREEN);
2001-07-02 22:04:02 +02:00
m_musicStarted=false;
2001-08-03 18:40:57 +02:00
StopLoad();
2001-04-24 18:15:04 +02:00
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CMapScene::shutdown()
{
2001-07-02 18:29:53 +02:00
CSoundMediator::dumpSong();
2001-04-24 21:37:12 +02:00
ClearScreenImage();
2001-07-25 18:20:01 +02:00
// Free level Gfx
for (int i=0; i<MAP_GFX_MAX; i++)
{
MemFree(s_GfxTable[i].Gfx);
}
2001-06-19 00:58:36 +02:00
delete m_pointerIcon;
2001-07-29 21:06:48 +02:00
MemFree(m_packedBackgroundImage);
2001-04-24 21:37:12 +02:00
MemFree(m_screenImage);
2001-04-24 18:15:04 +02:00
m_font->dump(); delete m_font;
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CMapScene::render()
{
2001-05-31 23:17:33 +02:00
SpriteBank *sb;
2001-05-30 16:58:29 +02:00
sMapLevelData *level;
int i;
char buf[100];
2001-04-25 01:14:50 +02:00
2001-08-09 21:51:18 +02:00
m_pointerIcon->render();
2001-06-19 00:58:36 +02:00
2001-05-31 23:17:33 +02:00
sb=CGameScene::getSpriteBank();
2001-05-30 16:58:29 +02:00
level=&s_mapLevelData[m_currentChapterSelection][0];
// Render spatula/kelp counts and quest items
for(i=0;i<MAP_NUM_LEVELS_PER_CHAPTER;i++)
2001-04-25 01:14:50 +02:00
{
2001-06-12 20:56:40 +02:00
if(isLevelOpen(m_currentChapterSelection,i))
{
DVECTOR pos;
2001-06-01 20:59:33 +02:00
2001-06-12 20:56:40 +02:00
pos=s_mapLevelPositions[i];
2001-05-30 16:58:29 +02:00
2001-06-12 20:56:40 +02:00
if(!level->m_kelpWorldLevel)
2001-04-25 01:14:50 +02:00
{
2001-06-12 20:56:40 +02:00
sFrameHdr *fh;
POLY_FT4 *ft4;
// Normal level
m_font->setColour(253,251,67);
sprintf(buf,"%d/%d",CGameSlotManager::getSlotData()->getSpatulaCollectedCount(m_currentChapterSelection,i),level->m_spatulaOrTokenCounts);
fh=sb->getFrameHeader(level->m_questItemFrame);
ft4=sb->printFT4(fh,pos.vx+MAP_LEVEL_WIDTH-fh->W,pos.vy+MAP_LEVEL_HEIGHT-fh->H,0,0,10);
if(!hasQuestItemBeenCollected(m_currentChapterSelection,i))
{
setRGB0(ft4,50,50,50);
}
}
else
{
// Bonuse level
m_font->setColour(67,251,67);
sprintf(buf,"%d/%d",CGameSlotManager::getSlotData()->getKelpTokenCollectedCount(m_currentChapterSelection,i),level->m_spatulaOrTokenCounts);
2001-04-25 01:14:50 +02:00
}
2001-05-30 16:58:29 +02:00
2001-06-12 20:56:40 +02:00
m_font->print(pos.vx,pos.vy,buf);
}
2001-05-30 16:58:29 +02:00
level++;
2001-04-25 01:14:50 +02:00
}
2001-05-31 23:17:33 +02:00
renderInstructions();
2001-08-03 01:44:21 +02:00
renderChapterArrows();
2001-05-31 23:17:33 +02:00
2001-04-25 20:15:19 +02:00
2001-08-03 01:44:21 +02:00
sprintf(buf,"Chapter %d",m_currentChapterSelection+1);
2001-04-25 20:15:19 +02:00
m_font->setColour(0,255,0);
m_font->print(24,24,buf);
m_font->setColour(0,0,0);
m_font->print(25,25,buf);
2001-04-24 18:15:04 +02:00
}
2001-05-31 23:17:33 +02:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CMapScene::renderInstructions()
{
// Instructions
SpriteBank *sb;
sFrameHdr *fh1,*fh2;
int width;
int x,y;
2001-08-03 01:44:21 +02:00
int xText=0;
2001-05-31 23:17:33 +02:00
2001-06-12 20:56:40 +02:00
2001-05-31 23:17:33 +02:00
sb=CGameScene::getSpriteBank();
m_font->setColour(MAP_INSTRUCTIONS_TEXT_R,MAP_INSTRUCTIONS_TEXT_G,MAP_INSTRUCTIONS_TEXT_B);
y=MAP_INSTRUCTIONS_YSTART;
2001-08-03 01:44:21 +02:00
switch(m_currentIconSelection)
2001-06-12 20:56:40 +02:00
{
2001-08-03 01:44:21 +02:00
case MAP_ICON_PREVIOUS_CHAPTER:
xText=STR__MAP_SCREEN__X_FOR_PREVIOUS_CHAPTER;
break;
case MAP_ICON_LEVEL_1:
case MAP_ICON_LEVEL_2:
case MAP_ICON_LEVEL_3:
case MAP_ICON_LEVEL_4:
case MAP_ICON_LEVEL_BONUS:
xText=STR__MAP_SCREEN__X_TO_START;
break;
case MAP_ICON_NEXT_CHAPTER:
xText=STR__MAP_SCREEN__X_FOR_NEXT_CHAPTER;
break;
2001-06-12 20:56:40 +02:00
}
2001-08-03 01:44:21 +02:00
2001-05-31 23:17:33 +02:00
y+=MAP_INSTRUCTIONS_Y_SPACE_BETWEEN_LINES;
fh1=sb->getFrameHeader(FRM__BUTX);
2001-08-03 01:44:21 +02:00
width=fh1->W+MAP_INSTRUCTIONS_GAP_BETWEEN_BUTTONS_AND_TEXT+m_font->getStringWidth(xText);
2001-05-31 23:17:33 +02:00
x=256-(width/2);
sb->printFT4(fh1,x,y+MAP_INSTRUCTIONS_BUTTON_Y_OFFSET,0,0,0);
x+=fh1->W+MAP_INSTRUCTIONS_GAP_BETWEEN_BUTTONS_AND_TEXT;
2001-08-03 01:44:21 +02:00
m_font->print(x,y,xText);
2001-07-02 17:46:34 +02:00
y+=MAP_INSTRUCTIONS_Y_SPACE_BETWEEN_LINES;
fh1=sb->getFrameHeader(FRM__BUTT);
width=fh1->W+MAP_INSTRUCTIONS_GAP_BETWEEN_BUTTONS_AND_TEXT+m_font->getStringWidth(STR__MAP_SCREEN__TRIANGLE_TO_SAVE);
x=256-(width/2);
sb->printFT4(fh1,x,y+MAP_INSTRUCTIONS_BUTTON_Y_OFFSET,0,0,0);
x+=fh1->W+MAP_INSTRUCTIONS_GAP_BETWEEN_BUTTONS_AND_TEXT;
m_font->print(x,y,STR__MAP_SCREEN__TRIANGLE_TO_SAVE);
2001-05-31 23:17:33 +02:00
}
2001-08-03 01:44:21 +02:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CMapScene::renderChapterArrows()
{
SpriteBank *sb;
sFrameHdr *fh;
int x,y;
POLY_FT4 *ft4;
sb=CGameScene::getSpriteBank();
fh=sb->getFrameHeader(FRM__MAP_ARROW);
if(m_currentChapterSelection>0&&isChapterOpen(m_currentChapterSelection-1))
{
2001-08-09 21:51:18 +02:00
int rgb;
rgb=m_currentIconSelection==MAP_ICON_PREVIOUS_CHAPTER?MAP_CHAPTER_ARROW_RGB_SELECTED:MAP_CHAPTER_ARROW_RGB_UNSELECTED;
x=MAP_CHAPTER_ARROW_XOFF-(fh->W/2);
y=MAP_CHAPTER_ARROW_Y;
ft4=sb->printFT4(fh,x,y,0,0,0);
setRGB0(ft4,rgb,rgb,rgb);
2001-08-03 01:44:21 +02:00
}
2001-08-06 17:16:50 +02:00
if(m_currentChapterSelection<5-1&&isChapterOpen(m_currentChapterSelection+1))
2001-08-03 01:44:21 +02:00
{
2001-08-09 21:51:18 +02:00
int rgb;
rgb=m_currentIconSelection==MAP_ICON_NEXT_CHAPTER?MAP_CHAPTER_ARROW_RGB_SELECTED:MAP_CHAPTER_ARROW_RGB_UNSELECTED;
x=512-MAP_CHAPTER_ARROW_XOFF-(fh->W/2)+fh->W;
y=MAP_CHAPTER_ARROW_Y;
ft4=sb->printFT4(fh,x,y,1,0,0);
setRGB0(ft4,rgb,rgb,rgb);
2001-08-03 01:44:21 +02:00
}
}
2001-04-24 18:15:04 +02:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
2001-08-09 21:51:18 +02:00
const int CMapScene::s_padToIconMappings[4][NUM_MAP_ICONS][NUM_MAP_ICONS]=
{
// UP
{
// MAP_ICON_PREVIOUS_CHAPTER
{ MAP_ICON_LEVEL_4,MAP_ICON_LEVEL_BONUS,MAP_ICON_LEVEL_1,MAP_ICON_LEVEL_2,MAP_ICON_LEVEL_3,MAP_ICON_PREVIOUS_CHAPTER },
// MAP_ICON_LEVEL_1
{ MAP_ICON_LEVEL_1 },
// MAP_ICON_LEVEL_2
{ MAP_ICON_LEVEL_2 },
// MAP_ICON_LEVEL_3
{ MAP_ICON_LEVEL_3 },
// MAP_ICON_LEVEL_4
{ MAP_ICON_LEVEL_1,MAP_ICON_LEVEL_4 },
// MAP_ICON_LEVEL_BONUS
{ MAP_ICON_LEVEL_3,MAP_ICON_LEVEL_2,MAP_ICON_LEVEL_1,MAP_ICON_LEVEL_BONUS },
// MAP_ICON_NEXT_CHAPTER
{ MAP_ICON_LEVEL_BONUS,MAP_ICON_LEVEL_4,MAP_ICON_LEVEL_3,MAP_ICON_LEVEL_2,MAP_ICON_LEVEL_1,MAP_ICON_NEXT_CHAPTER },
},
// DOWN
{
// MAP_ICON_PREVIOUS_CHAPTER
{ MAP_ICON_PREVIOUS_CHAPTER },
// MAP_ICON_LEVEL_1
{ MAP_ICON_LEVEL_4,MAP_ICON_LEVEL_BONUS,MAP_ICON_PREVIOUS_CHAPTER,MAP_ICON_NEXT_CHAPTER,MAP_ICON_LEVEL_1 },
// MAP_ICON_LEVEL_2
{ MAP_ICON_LEVEL_4,MAP_ICON_LEVEL_BONUS,MAP_ICON_PREVIOUS_CHAPTER,MAP_ICON_NEXT_CHAPTER,MAP_ICON_LEVEL_2 },
// MAP_ICON_LEVEL_3
{ MAP_ICON_LEVEL_BONUS,MAP_ICON_LEVEL_4,MAP_ICON_NEXT_CHAPTER,MAP_ICON_PREVIOUS_CHAPTER,MAP_ICON_LEVEL_3 },
// MAP_ICON_LEVEL_4
{ MAP_ICON_PREVIOUS_CHAPTER,MAP_ICON_NEXT_CHAPTER,MAP_ICON_LEVEL_4 },
// MAP_ICON_LEVEL_BONUS
{ MAP_ICON_NEXT_CHAPTER,MAP_ICON_PREVIOUS_CHAPTER,MAP_ICON_LEVEL_BONUS },
// MAP_ICON_NEXT_CHAPTER
{ MAP_ICON_NEXT_CHAPTER },
},
// LEFT
{
// MAP_ICON_PREVIOUS_CHAPTER
{ MAP_ICON_LEVEL_BONUS,MAP_ICON_LEVEL_4,MAP_ICON_LEVEL_3,MAP_ICON_LEVEL_2,MAP_ICON_LEVEL_1,MAP_ICON_NEXT_CHAPTER,MAP_ICON_PREVIOUS_CHAPTER },
// MAP_ICON_LEVEL_1
{ MAP_ICON_NEXT_CHAPTER,MAP_ICON_PREVIOUS_CHAPTER,MAP_ICON_LEVEL_BONUS,MAP_ICON_LEVEL_4,MAP_ICON_LEVEL_3,MAP_ICON_LEVEL_2,MAP_ICON_LEVEL_1 },
// MAP_ICON_LEVEL_2
{ MAP_ICON_LEVEL_1,MAP_ICON_NEXT_CHAPTER,MAP_ICON_PREVIOUS_CHAPTER,MAP_ICON_LEVEL_BONUS,MAP_ICON_LEVEL_4,MAP_ICON_LEVEL_3,MAP_ICON_LEVEL_2 },
// MAP_ICON_LEVEL_3
{ MAP_ICON_LEVEL_2,MAP_ICON_LEVEL_1,MAP_ICON_NEXT_CHAPTER,MAP_ICON_PREVIOUS_CHAPTER,MAP_ICON_LEVEL_BONUS,MAP_ICON_LEVEL_4,MAP_ICON_LEVEL_3 },
// MAP_ICON_LEVEL_4
{ MAP_ICON_LEVEL_3,MAP_ICON_LEVEL_2,MAP_ICON_LEVEL_1,MAP_ICON_NEXT_CHAPTER,MAP_ICON_PREVIOUS_CHAPTER,MAP_ICON_LEVEL_BONUS,MAP_ICON_LEVEL_4 },
// MAP_ICON_LEVEL_BONUS
{ MAP_ICON_LEVEL_4,MAP_ICON_LEVEL_3,MAP_ICON_LEVEL_2,MAP_ICON_LEVEL_1,MAP_ICON_NEXT_CHAPTER,MAP_ICON_PREVIOUS_CHAPTER,MAP_ICON_LEVEL_BONUS },
// MAP_ICON_NEXT_CHAPTER
{ MAP_ICON_PREVIOUS_CHAPTER,MAP_ICON_LEVEL_BONUS,MAP_ICON_LEVEL_4,MAP_ICON_LEVEL_3,MAP_ICON_LEVEL_2,MAP_ICON_LEVEL_1,MAP_ICON_NEXT_CHAPTER },
},
// RIGHT
{
// MAP_ICON_PREVIOUS_CHAPTER
{ MAP_ICON_NEXT_CHAPTER,MAP_ICON_LEVEL_1,MAP_ICON_LEVEL_2,MAP_ICON_LEVEL_3,MAP_ICON_LEVEL_4,MAP_ICON_LEVEL_BONUS,MAP_ICON_PREVIOUS_CHAPTER },
// MAP_ICON_LEVEL_1
{ MAP_ICON_LEVEL_2,MAP_ICON_LEVEL_3,MAP_ICON_LEVEL_4,MAP_ICON_LEVEL_BONUS,MAP_ICON_PREVIOUS_CHAPTER,MAP_ICON_NEXT_CHAPTER,MAP_ICON_LEVEL_1 },
// MAP_ICON_LEVEL_2
{ MAP_ICON_LEVEL_3,MAP_ICON_LEVEL_4,MAP_ICON_LEVEL_BONUS,MAP_ICON_PREVIOUS_CHAPTER,MAP_ICON_NEXT_CHAPTER,MAP_ICON_LEVEL_1,MAP_ICON_LEVEL_2 },
// MAP_ICON_LEVEL_3
{ MAP_ICON_LEVEL_4,MAP_ICON_LEVEL_BONUS,MAP_ICON_PREVIOUS_CHAPTER,MAP_ICON_NEXT_CHAPTER,MAP_ICON_LEVEL_1,MAP_ICON_LEVEL_2,MAP_ICON_LEVEL_3 },
// MAP_ICON_LEVEL_4
{ MAP_ICON_LEVEL_BONUS,MAP_ICON_PREVIOUS_CHAPTER,MAP_ICON_NEXT_CHAPTER,MAP_ICON_LEVEL_1,MAP_ICON_LEVEL_2,MAP_ICON_LEVEL_3,MAP_ICON_LEVEL_4 },
// MAP_ICON_LEVEL_BONUS
{ MAP_ICON_PREVIOUS_CHAPTER,MAP_ICON_NEXT_CHAPTER,MAP_ICON_LEVEL_1,MAP_ICON_LEVEL_2,MAP_ICON_LEVEL_3,MAP_ICON_LEVEL_4,MAP_ICON_LEVEL_BONUS },
// MAP_ICON_NEXT_CHAPTER
{ MAP_ICON_LEVEL_1,MAP_ICON_LEVEL_2,MAP_ICON_LEVEL_3,MAP_ICON_LEVEL_4,MAP_ICON_LEVEL_BONUS,MAP_ICON_PREVIOUS_CHAPTER,MAP_ICON_NEXT_CHAPTER },
},
};
2001-04-24 18:15:04 +02:00
void CMapScene::think(int _frames)
{
if(!CFader::isFading()&&!m_readyToExit)
{
2001-08-03 01:44:21 +02:00
CURSOR_MOVE_STATE cursor=CURSOR_DIDNT_MOVE;
2001-07-02 22:04:02 +02:00
if(m_musicStarted==false)
{
m_musicStarted=true;
CSoundMediator::playSong();
}
2001-06-12 20:56:40 +02:00
int pad=PadGetDown(0);
2001-08-03 01:44:21 +02:00
#ifdef __VERSION_DEBUG__
if(pad&PAD_L1)
{
CGameSlotManager::getSlotData()->debugCheatOpenAllLevels();
generateMapScreenImage();
}
#endif
2001-06-12 20:56:40 +02:00
2001-08-03 01:44:21 +02:00
// Move cursor in the gayest way possible..
// Hahahaha! It's like a spiders nest! (pkg and proud of it)
2001-08-09 21:51:18 +02:00
const int *mapBase=NULL;
2001-08-03 01:44:21 +02:00
2001-08-09 21:51:18 +02:00
if(pad&PAD_UP)mapBase=&s_padToIconMappings[0][m_currentIconSelection][0];
else if(pad&PAD_DOWN)mapBase=&s_padToIconMappings[1][m_currentIconSelection][0];
else if(pad&PAD_LEFT)mapBase=&s_padToIconMappings[2][m_currentIconSelection][0];
else if(pad&PAD_RIGHT)mapBase=&s_padToIconMappings[3][m_currentIconSelection][0];
if(mapBase)
2001-04-25 01:14:50 +02:00
{
2001-08-09 21:51:18 +02:00
int i,level,isOpen;
for(i=0;i<NUM_MAP_ICONS;i++)
2001-04-25 01:14:50 +02:00
{
2001-08-09 21:51:18 +02:00
level=*mapBase++;
if(level==m_currentIconSelection)
{
CSoundMediator::playSfx(CSoundMediator::SFX_FRONT_END__ERROR,false,true);
2001-08-03 01:44:21 +02:00
break;
2001-08-09 21:51:18 +02:00
}
isOpen=false;
switch(level)
{
case MAP_ICON_PREVIOUS_CHAPTER:
if(m_currentChapterSelection>0&&isChapterOpen(m_currentChapterSelection-1))isOpen=true;
break;
case MAP_ICON_LEVEL_1:
case MAP_ICON_LEVEL_2:
case MAP_ICON_LEVEL_3:
case MAP_ICON_LEVEL_4:
case MAP_ICON_LEVEL_BONUS:
if(isLevelOpen(m_currentChapterSelection,level-1))isOpen=true;
break;
case MAP_ICON_NEXT_CHAPTER:
if(m_currentChapterSelection<5-1&&isChapterOpen(m_currentChapterSelection+1))isOpen=true;
break;
}
2001-08-03 01:44:21 +02:00
2001-08-09 21:51:18 +02:00
if(isOpen)
2001-08-03 01:44:21 +02:00
{
2001-08-09 21:51:18 +02:00
m_currentIconSelection=level;
2001-08-03 01:44:21 +02:00
m_pointerIcon->setTarget(getPointerTargetPosition());
2001-08-09 21:51:18 +02:00
CSoundMediator::playSfx(CSoundMediator::SFX_FRONT_END__MOVE_CURSOR);
break;
2001-08-03 01:44:21 +02:00
}
2001-08-09 21:51:18 +02:00
}
2001-05-31 23:17:33 +02:00
}
2001-06-19 00:58:36 +02:00
m_pointerIcon->think(_frames);
2001-04-25 01:14:50 +02:00
2001-08-03 01:44:21 +02:00
// SELECT or SAVE pressed?
2001-06-19 00:58:36 +02:00
if(m_pointerIcon->canPointerSelect()&&
2001-06-12 20:56:40 +02:00
pad&PAD_CROSS)
2001-04-24 18:15:04 +02:00
{
2001-08-03 01:44:21 +02:00
CSoundMediator::playSfx(CSoundMediator::SFX_FRONT_END__SELECT);
switch(m_currentIconSelection)
2001-07-11 16:42:13 +02:00
{
2001-08-03 01:44:21 +02:00
case MAP_ICON_PREVIOUS_CHAPTER:
m_currentChapterSelection--;
generateMapScreenImage();
2001-08-03 22:10:37 +02:00
if(m_currentChapterSelection==0)
{
m_currentIconSelection=MAP_ICON_LEVEL_1;
m_pointerIcon->setTarget(getPointerTargetPosition());
}
2001-08-03 01:44:21 +02:00
break;
case MAP_ICON_LEVEL_1:
case MAP_ICON_LEVEL_2:
case MAP_ICON_LEVEL_3:
case MAP_ICON_LEVEL_4:
case MAP_ICON_LEVEL_BONUS:
s_globalLevelSelectThing=s_mapLevelData[m_currentChapterSelection][m_currentIconSelection-1].m_globalLevelNumber;
m_readyToExit=true;
CFader::setFadingOut();
if(m_currentChapterSelection==3-1&&m_currentIconSelection-1==1-1)
{
// Plankton FMA..
CFmaScene::selectFma(CFmaScene::FMA_SCRIPT__PLANKTON);
GameState::setNextScene(&FmaScene);
}
else
{
GameState::setNextScene(&GameScene);
}
break;
case MAP_ICON_NEXT_CHAPTER:
m_currentChapterSelection++;
generateMapScreenImage();
2001-08-06 17:16:50 +02:00
if(m_currentChapterSelection==5-1||!isChapterOpen(m_currentChapterSelection+1))
2001-08-03 22:10:37 +02:00
{
2001-08-06 17:16:50 +02:00
for(int i=MAP_ICON_LEVEL_BONUS;i>=MAP_ICON_LEVEL_1;i--)
2001-08-03 22:10:37 +02:00
{
if(isLevelOpen(m_currentChapterSelection,i-1))
{
m_currentIconSelection=i;
m_pointerIcon->setTarget(getPointerTargetPosition());
break;
}
}
}
2001-08-03 01:44:21 +02:00
break;
2001-07-11 16:42:13 +02:00
}
2001-04-24 18:15:04 +02:00
}
2001-07-02 17:46:34 +02:00
else if(pad&PAD_TRIANGLE)
{
CSoundMediator::playSfx(CSoundMediator::SFX_FRONT_END__OK);
m_readyToExit=true;
CFader::setFadingOut();
2001-07-10 16:43:20 +02:00
CSaveScene::setNextScene(CSaveScene::NEXTSCENE_MAP);
2001-07-02 17:46:34 +02:00
GameState::setNextScene(&SaveScene);
}
2001-04-24 18:15:04 +02:00
}
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
int CMapScene::readyToShutdown()
{
return m_readyToExit&&!CFader::isFading();
}
2001-04-25 20:15:19 +02:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CMapScene::generateMapScreenImage()
{
2001-05-30 16:58:29 +02:00
int i;
2001-04-25 20:15:19 +02:00
2001-07-29 21:06:48 +02:00
LZNP_Decode((u8*)m_packedBackgroundImage,(u8*)m_screenImage);
2001-05-30 16:58:29 +02:00
for(i=0;i<MAP_NUM_LEVELS_PER_CHAPTER;i++)
2001-04-25 20:15:19 +02:00
{
2001-05-30 16:58:29 +02:00
if(isLevelOpen(m_currentChapterSelection,i))
2001-04-25 20:15:19 +02:00
{
2001-07-25 18:20:01 +02:00
copyImageToScreen(s_mapLevelData[m_currentChapterSelection][i].m_Gfx,s_mapLevelPositions[i].vx,s_mapLevelPositions[i].vy,MAP_LEVEL_WIDTH,MAP_LEVEL_HEIGHT);
2001-04-25 20:15:19 +02:00
}
}
}
2001-04-24 21:37:12 +02:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CMapScene::copyImageToScreen(int _file,int _x,int _y,int _w,int _h)
{
u8 *image;
u16 *src,*dst;
2001-07-06 20:39:24 +02:00
int y;
2001-04-24 21:37:12 +02:00
2001-07-25 18:20:01 +02:00
image=(u8*)MemAlloc(MAP_LEVEL_WIDTH*MAP_LEVEL_HEIGHT*2,"MapLvlBuffer");
LZNP_Decode(s_GfxTable[_file].Gfx,image);
2001-04-24 21:37:12 +02:00
src=(u16*)image;
dst=(u16*)m_screenImage+(_x+(_y*512));
for(y=0;y<_h;y++)
{
2001-07-25 18:20:01 +02:00
u32 *S=(u32*)src;
u32 *D=(u32*)dst;
for (int x=0; x<MAP_LEVEL_WIDTH/2; x++)
{
*D++=*S++;
}
2001-07-06 20:19:03 +02:00
dst+=512;
src+=_w;
2001-04-24 21:37:12 +02:00
}
MemFree(image);
}
2001-04-25 20:15:19 +02:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
DVECTOR CMapScene::getPointerTargetPosition()
{
DVECTOR pos;
2001-08-09 21:51:18 +02:00
pos=s_mapPointerPositions[m_currentIconSelection];
2001-04-25 20:15:19 +02:00
return pos;
}
2001-04-25 01:14:50 +02:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
2001-05-30 16:58:29 +02:00
int CMapScene::isLevelOpen(unsigned int _chapter,unsigned int _level)
2001-04-25 01:14:50 +02:00
{
2001-06-12 20:56:40 +02:00
return CGameSlotManager::getSlotData()->isLevelOpen(_chapter,_level);
}
int CMapScene::isChapterOpen(unsigned int _chapter)
{
return CGameSlotManager::getSlotData()->isLevelOpen(_chapter,0);
2001-04-25 01:14:50 +02:00
}
2001-05-30 16:58:29 +02:00
int CMapScene::getSpatulaCollectedCount(unsigned int _chapter,unsigned int _level)
2001-04-25 01:14:50 +02:00
{
2001-05-09 22:15:01 +02:00
return CGameSlotManager::getSlotData()->getSpatulaCollectedCount(_chapter,_level);
2001-04-25 01:14:50 +02:00
}
2001-05-30 16:58:29 +02:00
int CMapScene::hasQuestItemBeenCollected(unsigned int _chapter,unsigned int _level)
{
2001-06-12 20:56:40 +02:00
return CGameSlotManager::getSlotData()->hasQustItemBeenCollected(_chapter,_level);
2001-04-25 01:14:50 +02:00
}
2001-04-24 18:15:04 +02:00
/*===========================================================================
end */