From e7ffd801beef0f4b5e49db7d384fb3dd77c5a68c Mon Sep 17 00:00:00 2001 From: Treeki Date: Wed, 31 Oct 2012 00:50:54 +0100 Subject: bugfixes and some cleanup --- koopatlas.yaml | 6 +++++ src/koopatlas/core.cpp | 59 ++++--------------------------------------- src/koopatlas/fixes.S | 10 ++++++++ src/koopatlas/pathmanager.cpp | 10 ++++++++ src/koopatlas/pathmanager.h | 3 +++ 5 files changed, 34 insertions(+), 54 deletions(-) create mode 100644 src/koopatlas/fixes.S diff --git a/koopatlas.yaml b/koopatlas.yaml index 3556996..c21403e 100644 --- a/koopatlas.yaml +++ b/koopatlas.yaml @@ -1,5 +1,6 @@ --- source_files: + - ../src/koopatlas/fixes.S - ../src/boss.cpp # wtf is this doing in the Level Select/WorldMap stuff?? - ../src/fileload.cpp - ../src/scene.S @@ -80,3 +81,8 @@ hooks: # branch_type: b # target_func: 'UniversalFunctionLog' + - name: ClearLastPowerupStoreTypeAfterGameOver + type: branch_insn + src_addr_pal: 0x809216EC + branch_type: b + target_func: ClearLastPowerupStoreTypeAfterGameOver diff --git a/src/koopatlas/core.cpp b/src/koopatlas/core.cpp index 249861f..0a463f5 100644 --- a/src/koopatlas/core.cpp +++ b/src/koopatlas/core.cpp @@ -532,44 +532,18 @@ void dScKoopatlas_c::endState_ContinueWait() { void dScKoopatlas_c::executeState_Normal() { + if (pathManager.doingThings()) + return; + int nowPressed = Remocon_GetPressed(GetActiveRemocon()); // Nothing related to the menu is going on - if (nowPressed & WPAD_ONE && !pathManager.isEnteringLevel) { + if (nowPressed & WPAD_ONE) { STKI_SHOW(this->stockItem) = true; state.setState(&StateID_PowerupsWait); - } else if (nowPressed & WPAD_PLUS && !pathManager.isEnteringLevel) { + } else if (nowPressed & WPAD_PLUS) { CSMENU_ACTIVE(this->csMenu) = true; state.setState(&StateID_CSMenu); - // } else if (nowPressed & WPAD_A) { - - // if (pathManager.currentNode->type == dKPNode_s::LEVEL) { - // int w = pathManager.currentNode->levelNumber[0]; - // if (w == 9) { - // int l = pathManager.currentNode->levelNumber[1]; - - // if ((l < 6) || (l == 33) || (l == 34)) - // coins->LoadCoinsForWorld(9); - // else if ((l < 11) || (l == 35) || (l == 36)) - // coins->LoadCoinsForWorld(10); - // else if ((l < 16) || (l == 37) || (l == 38) || (l == 31) ) - // coins->LoadCoinsForWorld(11); - // else if ((l < 19) || (l == 39) || (l == 40)) - // coins->LoadCoinsForWorld(12); - // else - // coins->LoadCoinsForWorld(13); - - // state.setState(&StateID_CoinsWait); - // } - // else { - // coins->LoadCoinsForWorld(w-1); - // state.setState(&StateID_CoinsWait); - // } - // } - // else { - // MapSoundPlayer(SoundRelatedClass, SE_SYS_INVALID, 1); - // } - } else if (nowPressed & WPAD_MINUS) { pathManager.unlockAllPaths(2); } else if (nowPressed & WPAD_A) { @@ -590,29 +564,6 @@ void dScKoopatlas_c::executeState_CSMenu() { switch (CSMENU_CURRENT(this->csMenu)) { case 0: // Star Coins -// if (pathManager.currentNode->type == dKPNode_s::LEVEL) { -// int w = pathManager.currentNode->levelNumber[0]; -// if (w == 9) { -// int l = pathManager.currentNode->levelNumber[1]; -// -// if ((l < 6) || (l == 33) || (l == 34)) -// coins->LoadCoinsForWorld(9); -// else if ((l < 11) || (l == 35) || (l == 36)) -// coins->LoadCoinsForWorld(10); -// else if ((l < 16) || (l == 37) || (l == 38) || (l == 31) ) -// coins->LoadCoinsForWorld(11); -// else if ((l < 19) || (l == 39) || (l == 40)) -// coins->LoadCoinsForWorld(12); -// else -// coins->LoadCoinsForWorld(13); -// -// state.setState(&StateID_CoinsWait); -// } -// else { -// coins->LoadCoinsForWorld(w-1); -// } -// } -// else { MapSoundPlayer(SoundRelatedClass, SE_SYS_INVALID, 1); } coins->show(); state.setState(&StateID_CoinsWait); break; diff --git a/src/koopatlas/fixes.S b/src/koopatlas/fixes.S new file mode 100644 index 0000000..50c2bed --- /dev/null +++ b/src/koopatlas/fixes.S @@ -0,0 +1,10 @@ +.text +.global ClearLastPowerupStoreTypeAfterGameOver +.extern LastPowerupStoreType +ClearLastPowerupStoreTypeAfterGameOver: + lis r4, LastPowerupStoreType@h + ori r4, r4, LastPowerupStoreType@l + li r5, 0 + stw r5, 0(r4) + blr + diff --git a/src/koopatlas/pathmanager.cpp b/src/koopatlas/pathmanager.cpp index bb610e3..237c595 100644 --- a/src/koopatlas/pathmanager.cpp +++ b/src/koopatlas/pathmanager.cpp @@ -39,6 +39,7 @@ void dWMPathManager_c::setup() { if (LastPowerupStoreType == LOSE_LEVEL) { mustPlayAfterDeathAnim = true; daWMPlayer_c::instance->visible = false; + LastPowerupStoreType = BEAT_LEVEL; } SpammyReport("done\n"); @@ -329,6 +330,15 @@ bool dWMPathManager_c::evaluateUnlockCondition(u8 *&in, SaveBlock *save, int sta } +bool dWMPathManager_c::doingThings() { + if (isEnteringLevel || waitAfterUnlock || + waitAtStart || waitForAfterDeathAnim || + (countdownToFadeIn > 0)) + return true; + + return false; +} + void dWMPathManager_c::execute() { if (isEnteringLevel) { if (levelStartWait > 0) { diff --git a/src/koopatlas/pathmanager.h b/src/koopatlas/pathmanager.h index cd1d7ba..2a7ce46 100644 --- a/src/koopatlas/pathmanager.h +++ b/src/koopatlas/pathmanager.h @@ -71,6 +71,9 @@ class dWMPathManager_c { int waitAtStart; bool mustPlayAfterDeathAnim; int waitForAfterDeathAnim; + + bool doingThings(); + dLevelInfo_c::entry_s *enteredLevel; }; -- cgit v1.2.3