summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2011-03-15 04:52:35 +0100
committerTreeki <treeki@gmail.com>2011-03-15 04:52:35 +0100
commit4b440c0ac3040267be036e536c3e1ad69a5ef49d (patch)
treea4e2ee0c449ba3119fe7760ade10f38e0c67be4b
parentc73a4a4f79ae7974509b134cd3225307099a7900 (diff)
downloadkamek-4b440c0ac3040267be036e536c3e1ad69a5ef49d.tar.gz
kamek-4b440c0ac3040267be036e536c3e1ad69a5ef49d.zip
refactored WorldMap to use the same init method as Nintendo (function chains)
Diffstat (limited to '')
-rwxr-xr-xinclude/game.h2
-rw-r--r--kamek_ntsc.x3
-rw-r--r--kamek_ntsc2.x3
-rw-r--r--kamek_pal.x3
-rw-r--r--kamek_pal2.x3
-rw-r--r--src/worldmap.cpp239
6 files changed, 136 insertions, 117 deletions
diff --git a/include/game.h b/include/game.h
index 13e5be2..152c864 100755
--- a/include/game.h
+++ b/include/game.h
@@ -853,6 +853,8 @@ public:
fBase_c *GetParent();
fBase_c *GetChild();
fBase_c *GetNext();
+
+ bool hasUninitialisedProcesses(); // 80162B60
};
class dBase_c : public fBase_c {
diff --git a/kamek_ntsc.x b/kamek_ntsc.x
index 272affd..258b588 100644
--- a/kamek_ntsc.x
+++ b/kamek_ntsc.x
@@ -90,11 +90,14 @@ SECTIONS {
__destroy_new_array = 0x802DCB10;
+ setup__13FunctionChainFPPFPv_bUs = 0x8015F600;
+
willBeDeleted__7fBase_cFv = 0x801622D0;
moreHeapShit__7fBase_cFUiPv = 0x801625F0;
createHeap__7fBase_cFUiPv = 0x801627F0;
heapCreated__7fBase_cFv = 0x801628B0;
Delete__7fBase_cFv = 0x80162510;
+ hasUninitialisedProcesses__7fBase_cFv = 0x80162A20;
GetExplanationString__7dBase_cFv = 0x8006C660;
diff --git a/kamek_ntsc2.x b/kamek_ntsc2.x
index e89820e..2186096 100644
--- a/kamek_ntsc2.x
+++ b/kamek_ntsc2.x
@@ -90,11 +90,14 @@ SECTIONS {
__destroy_new_array = 0x802DCB10;
+ setup__13FunctionChainFPPFPv_bUs = 0x8015F600;
+
willBeDeleted__7fBase_cFv = 0x801622D0;
moreHeapShit__7fBase_cFUiPv = 0x801625F0;
createHeap__7fBase_cFUiPv = 0x801627F0;
heapCreated__7fBase_cFv = 0x801628B0;
Delete__7fBase_cFv = 0x80162510;
+ hasUninitialisedProcesses__7fBase_cFv = 0x80162A20;
GetExplanationString__7dBase_cFv = 0x8006C660;
diff --git a/kamek_pal.x b/kamek_pal.x
index 92fd6ab..244af05 100644
--- a/kamek_pal.x
+++ b/kamek_pal.x
@@ -90,11 +90,14 @@ SECTIONS {
__destroy_new_array = 0x802DCE00;
+ setup__13FunctionChainFPPFPv_bUs = 0x8015F740;
+
willBeDeleted__7fBase_cFv = 0x80162410;
moreHeapShit__7fBase_cFUiPv = 0x80162730;
createHeap__7fBase_cFUiPv = 0x80162930;
heapCreated__7fBase_cFv = 0x801629F0;
Delete__7fBase_cFv = 0x80162650;
+ hasUninitialisedProcesses__7fBase_cFv = 0x80162B60;
GetExplanationString__7dBase_cFv = 0x8006C660;
diff --git a/kamek_pal2.x b/kamek_pal2.x
index 28f0135..9d386bd 100644
--- a/kamek_pal2.x
+++ b/kamek_pal2.x
@@ -90,11 +90,14 @@ SECTIONS {
__destroy_new_array = 0xDEADBEEF;
+ setup__13FunctionChainFPPFPv_bUs = 0xDEADBEEF;
+
willBeDeleted__7fBase_cFv = 0xDEADBEEF;
moreHeapShit__7fBase_cFUiPv = 0xDEADBEEF;
createHeap__7fBase_cFUiPv = 0xDEADBEEF;
heapCreated__7fBase_cFv = 0xDEADBEEF;
Delete__7fBase_cFv = 0xDEADBEEF;
+ hasUninitialisedProcesses__7fBase_cFv = 0xDEADBEEF;
GetExplanationString__7dBase_cFv = 0xDEADBEEF;
diff --git a/src/worldmap.cpp b/src/worldmap.cpp
index d537ff6..cd43a47 100644
--- a/src/worldmap.cpp
+++ b/src/worldmap.cpp
@@ -18,22 +18,30 @@ dScNewerWorldMap_c *dScNewerWorldMap_c::build() {
return c;
}
-
-/*ChainedFunc *initFunctions[] = {
+bool WMInit_StartLoading(void*);
+bool WMInit_LoadSIAnims(void*);
+bool WMInit_EndLoading(void*);
+bool WMInit_LoadResources(void*);
+bool WMInit_SetupWait(void*);
+bool WMInit_SetupExtra(void*);
+bool WMInit_SetupWipe(void*);
+
+ChainedFunc initFunctions[] = {
WMInit_StartLoading,
- WMInit_LoadResources,
+ WMInit_LoadSIAnims,
WMInit_EndLoading,
- WMInit_CreateManagers,
+ WMInit_LoadResources,
WMInit_SetupWait,
+ WMInit_SetupExtra,
WMInit_SetupWipe
};
-
dScNewerWorldMap_c::dScNewerWorldMap_c() {
- initChain.setup(
+ initChain.setup(initFunctions, 6);
setInitChain(initChain);
-}*/
+}
+
#define SELC_SETUP_DONE(sc) (*((bool*)(((u32)(sc))+0xD38)))
@@ -88,12 +96,106 @@ dScNewerWorldMap_c::dScNewerWorldMap_c() {
#define CONT_DONE(cont) (*((bool*)(((u32)(cont))+0x2D7)))
#define CONT_UNK3(cont) (*((bool*)(((u32)(cont))+0x2E0)))
+bool WMInit_StartLoading(void *ptr) {
+ DVD_Start();
+ return true;
+}
+
+bool WMInit_LoadSIAnims(void *ptr) {
+ DVD_LoadFile(GetDVDClass(), "WorldMap", "SI_kinoko", 0);
+ DVD_LoadFile(GetDVDClass(), "WorldMap", "SI_fireflower", 0);
+ DVD_LoadFile(GetDVDClass(), "WorldMap", "SI_iceflower", 0);
+ DVD_LoadFile(GetDVDClass(), "WorldMap", "SI_penguin", 0);
+ DVD_LoadFile(GetDVDClass(), "WorldMap", "SI_propeller", 0);
+ DVD_LoadFile(GetDVDClass(), "WorldMap", "SI_star", 0);
+ return true;
+}
+
+bool WMInit_EndLoading(void *ptr) {
+ if (DVD_StillLoading(GetDVDClass2()))
+ return false;
+
+ DVD_End();
+ return true;
+}
+
+bool WMInit_LoadResources(void *ptr) {
+ dScNewerWorldMap_c *wm = (dScNewerWorldMap_c*)ptr;
+ return wm->resMng.loadSet("SMGoldwood");
+}
+
+bool WMInit_SetupWait(void *ptr) {
+ dScNewerWorldMap_c *wm = (dScNewerWorldMap_c*)ptr;
+
+ bool success = true;
+
+ success &= CSMENU_SETUP_DONE(wm->csMenu);
+ success &= SELC_SETUP_DONE(wm->selectCursor);
+ success &= NPCHG_SETUP_DONE(wm->numPeopleChange);
+ success &= YESNO_SETUP_DONE(wm->yesNoWindow);
+ success &= CONT_SETUP_DONE(wm->continueObj);
+ success &= STKI_SETUP_DONE(wm->stockItem);
+ success &= SIS_SETUP_DONE(wm->stockItemShadow);
+ success &= EASYP_SETUP_DONE(wm->easyPairing);
+
+ return success;
+}
+
+bool WMInit_SetupExtra(void *ptr) {
+ // ok, now we can set up other required shit
+ dScNewerWorldMap_c *wm = (dScNewerWorldMap_c*)ptr;
+
+ // first up: player models for Stocked Items
+ for (int i = 0; i < 4; i++) {
+ void *obj = CreateChildObject(WM_2D_PLAYER, wm, i, 0, 0);
+ STKI_2DPLAYER(wm->stockItem,i) = obj;
+ NPCHG_2DPLAYER(wm->numPeopleChange,i) = obj;
+ }
+
+ // next: items for the Powerup screen
+ for (int i = 0; i < 7; i++) {
+ void *obj = CreateChildObject(WM_ITEM, wm, i, 0, 0);
+ STKI_ITEM(wm->stockItem,i) = obj;
+ }
+
+ // since we've got all the resources, set up the path data too
+ wm->pathData.load(wm->resMng['PATH']);
+
+ SaveBlock *save = GetSaveFile()->GetBlock(-1);
+ if (save->current_path_node >= wm->pathData.pointCount()) {
+ wm->currentPoint = wm->pathData.getPath(0)->startPoint;
+ } else {
+ wm->currentPoint = wm->pathData.getPoint(save->current_path_node);
+ }
+
+ // and now Player setup
+ wm->player = (daWMPlayer_c*)CreateParentedObject(WM_PLAYER, wm, 0, 2);
+ wm->player->modelHandler->mdlClass->setPowerup(2);
+ wm->player->modelHandler->mdlClass->startAnimation(0, 1.2f, 10.0f, 0.0f);
+ wm->player->pos = wm->currentPoint->position;
+
+ return true;
+}
+
+bool WMInit_SetupWipe(void *ptr) {
+ dScNewerWorldMap_c *wm = (dScNewerWorldMap_c*)ptr;
+
+ if (wm->hasUninitialisedProcesses())
+ return false;
+
+ return true;
+}
+
+
+
+
+
// Todo: remove level menu related states from here
-#define STATE_START_DVD 0
+/*#define STATE_START_DVD 0
#define STATE_LOAD_RES 1
#define STATE_END_DVD 2
-#define STATE_SETUP_WAIT 3
+#define STATE_SETUP_WAIT 3*/
#define STATE_LIMBO 4
#define STATE_CONTINUE_WAIT 5
#define STATE_NORMAL 6
@@ -173,6 +275,16 @@ int dScNewerWorldMap_c::onCreate() {
this->continueObj = CreateParentedObject(CONTINUE, this, 0, 0);
+ // check if we need to handle Continue
+ if (CheckIfContinueShouldBeActivated()) {
+ this->state = STATE_CONTINUE_WAIT;
+ CONT_UNK1(this->continueObj) = true;
+ CONT_UNK2(this->continueObj) = true;
+ CONT_UNK3(this->continueObj) = false;
+ } else {
+ this->state = STATE_NORMAL;
+ }
+
this->stockItem = CreateParentedObject(STOCK_ITEM, this, 0, 0);
this->stockItemShadow = CreateParentedObject(STOCK_ITEM_SHADOW, this, 0, 0);
STKI_SHADOW(this->stockItem) = this->stockItemShadow;
@@ -181,8 +293,6 @@ int dScNewerWorldMap_c::onCreate() {
CreateParentedObject(WORLD_CAMERA, this, 0, 0);
- this->state = STATE_START_DVD;
-
*CurrentDrawFunc = NewerMapDrawFunc;
// level info
@@ -212,6 +322,7 @@ int dScNewerWorldMap_c::onExecute() {
if (QueryGlobal5758(0xFFFFFFFF)) return true;
if (CheckIfWeCantDoStuff()) return true;
+ if (this->state == STATE_LIMBO) return true;
/**************************************************************************/
// Read Wiimote Buttons
@@ -224,112 +335,6 @@ int dScNewerWorldMap_c::onExecute() {
switch (this->state) {
/**********************************************************************/
- // STATE_START_DVD : Set up DVD
- case STATE_START_DVD:
-
- DVD_Start();
- this->state = STATE_LOAD_RES;
-
- break;
-
- /**********************************************************************/
- // STATE_LOAD_RES : Load extra stuff we need
- case STATE_LOAD_RES:
-
- DVD_LoadFile(GetDVDClass(), "WorldMap", "SI_kinoko", 0);
- DVD_LoadFile(GetDVDClass(), "WorldMap", "SI_fireflower", 0);
- DVD_LoadFile(GetDVDClass(), "WorldMap", "SI_iceflower", 0);
- DVD_LoadFile(GetDVDClass(), "WorldMap", "SI_penguin", 0);
- DVD_LoadFile(GetDVDClass(), "WorldMap", "SI_propeller", 0);
- DVD_LoadFile(GetDVDClass(), "WorldMap", "SI_star", 0);
- //DVD_LoadFile(GetDVDClass(), "Object", "fruits_kusa_gake", 0);
-
- this->state = STATE_END_DVD;
-
- break;
-
- /**********************************************************************/
- // STATE_END_DVD : Wait for files to load, end DVD
- // Also, load the WM Set files
- case STATE_END_DVD: {
-
- bool didEndDVD = false, didWMSetLoad = false;
-
- if (!DVD_StillLoading(GetDVDClass2())) {
- if (DVD_End()) {
- didEndDVD = true;
- }
- }
-
- didWMSetLoad = resMng.loadSet("SMGoldwood");
-
- if (didEndDVD && didWMSetLoad)
- this->state = STATE_SETUP_WAIT;
-
- } break;
-
- /**********************************************************************/
- // STATE_SETUP_WAIT : Waiting for the world map managers to be set up
- case STATE_SETUP_WAIT: {
-
- bool success = true;
-
- success &= CSMENU_SETUP_DONE(this->csMenu);
- success &= SELC_SETUP_DONE(this->selectCursor);
- success &= NPCHG_SETUP_DONE(this->numPeopleChange);
- success &= YESNO_SETUP_DONE(this->yesNoWindow);
- success &= CONT_SETUP_DONE(this->continueObj);
- success &= STKI_SETUP_DONE(this->stockItem);
- success &= SIS_SETUP_DONE(this->stockItemShadow);
- success &= EASYP_SETUP_DONE(this->easyPairing);
-
- if (success) {
- // ok, now we can set up other required shit
-
- // first up: player models for Stocked Items
- for (int i = 0; i < 4; i++) {
- void *obj = CreateChildObject(WM_2D_PLAYER, this, i, 0, 0);
- STKI_2DPLAYER(this->stockItem,i) = obj;
- NPCHG_2DPLAYER(this->numPeopleChange,i) = obj;
- }
-
- // next: items for the Powerup screen
- for (int i = 0; i < 7; i++) {
- void *obj = CreateChildObject(WM_ITEM, this, i, 0, 0);
- STKI_ITEM(this->stockItem,i) = obj;
- }
-
- // now, check if we need to handle Continue
- if (CheckIfContinueShouldBeActivated()) {
- this->state = STATE_CONTINUE_WAIT;
- CONT_UNK1(this->continueObj) = true;
- CONT_UNK2(this->continueObj) = true;
- CONT_UNK3(this->continueObj) = false;
- } else {
- this->state = STATE_NORMAL;
- }
-
- // since we've got all the resources, set up the path data too
- pathData.load(resMng['PATH']);
-
- SaveBlock *save = GetSaveFile()->GetBlock(-1);
-
- if (save->current_path_node >= pathData.pointCount()) {
- this->currentPoint = pathData.getPath(0)->startPoint;
- } else {
- this->currentPoint = pathData.getPoint(save->current_path_node);
- }
-
- // and now Player setup
- this->player = (daWMPlayer_c*)CreateParentedObject(WM_PLAYER, this, 0, 2);
- this->player->modelHandler->mdlClass->setPowerup(2);
- this->player->modelHandler->mdlClass->startAnimation(0, 1.2f, 10.0f, 0.0f);
- this->player->pos = this->currentPoint->position;
-s }
-
- } break;
-
- /**********************************************************************/
// STATE_CONTINUE_WAIT : Waiting for the Continue anim to finish
case STATE_CONTINUE_WAIT: