Skip to content

Commit

Permalink
BlueCoinCounter bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Evanbowl committed Nov 13, 2024
1 parent b0dfc4b commit 862d87a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
34 changes: 17 additions & 17 deletions PTD/BlueCoinSystem/source/BlueCoinLayouts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void BlueCoinCounter::init(const JMapInfoIter& rIter) {
void BlueCoinCounter::appear() {
mAppearer->reset();
mPaneRumbler->reset();
_28 = 0;
_3C = 0;
MR::hideLayout(this);
setNerve(&NrvBlueCoinCounter::NrvHide::sInstance);
LayoutActor::appear();
Expand All @@ -63,7 +63,6 @@ void BlueCoinCounter::forceAppear() {
appear();
setNerve(&NrvBlueCoinCounter::NrvAppear::sInstance);
}

}

void BlueCoinCounter::disappear() {
Expand Down Expand Up @@ -109,6 +108,7 @@ void BlueCoinCounter::updateCounter() {
}
}

OSReport("var: %d, _3C: %d\n", var, _3C);
MR::setTextBoxNumberRecursive(this, "Counter", mBlueCoinDisplayNum);
}

Expand Down Expand Up @@ -138,7 +138,7 @@ void BlueCoinCounter::exeAppear() {
}

void BlueCoinCounter::exeWait() {
if (mAppearer->isDisappeared() && mBlueCoinDisplayNum == mBlueCoinCount) {
if (mAppearer->isAppeared() && mBlueCoinDisplayNum == mBlueCoinCount) {
if (CounterLayoutController::isWaitToDisappearCounter(this)) {
setNerve(&NrvBlueCoinCounter::NrvDisappear::sInstance);
}
Expand Down Expand Up @@ -187,8 +187,8 @@ CounterLayoutControllerExt* createCounterLayoutControllerExt() {
return new CounterLayoutControllerExt();
}

kmCall(0x80471784, createCounterLayoutControllerExt);
kmWrite32(0x80471788, 0x4800000C);
kmCall(0x80471784, createCounterLayoutControllerExt); // bl createCounterLayoutControllerExt
kmWrite32(0x80471788, 0x4800000C); // b 0xC

namespace NrvBlueCoinCounter {
void NrvHide::execute(Spine* pSpine) const {
Expand Down Expand Up @@ -249,7 +249,7 @@ bool isBlueCoinCounterWait(CounterLayoutControllerExt* pController) {
}

kmWrite32(0x80465C20, 0x7F23CB78); // mr r3, r25
kmCall(0x80465C24, isBlueCoinCounterWait);
kmCall(0x80465C24, isBlueCoinCounterWait); // bl isBlueCoinCounterWait


void appearBlueCoinLayout(CounterLayoutControllerExt* pController) {
Expand All @@ -272,7 +272,7 @@ void appearBlueCoinLayoutWithoutStar(CounterLayoutControllerExt* pController) {
}
}

kmCall(0x80465EC4, appearBlueCoinLayoutWithoutStar);
kmCall(0x80465EC4, appearBlueCoinLayoutWithoutStar); // bl appearBlueCoinLayoutWithoutStar
kmWrite32(0x80465EC8, 0x48000010); // b 0x10

void disappearBlueCoinLayout(CounterLayoutControllerExt* pController) {
Expand All @@ -293,7 +293,7 @@ void killBlueCoinCounter(CounterLayoutControllerExt* pController) {
pController->killAllCoounter();
}

kmCall(0x8046590C, killBlueCoinCounter);
kmCall(0x8046590C, killBlueCoinCounter); // bl killBlueCoinCounter

// PAUSE MENU

Expand All @@ -304,7 +304,7 @@ void initPauseMenuBlueCoin(PauseMenuExt* pPauseMenu) {
MR::setTextBoxFormatRecursive(pPauseMenu, "ShaBlueCoinStage", counterPictureFonts);
}

kmCall(0x80486D60+REGIONOFF, initPauseMenuBlueCoin);
kmCall(0x80486D60+REGIONOFF, initPauseMenuBlueCoin); // bl initPauseMenuBlueCoin


void setPauseMenuBlueCoinStageCount(PauseMenu* pPauseMenu) {
Expand Down Expand Up @@ -407,7 +407,7 @@ s32 setUpBlueCoinInfo(PauseMenu* pPauseMenu) {
return MR::getCoinNum();
}

kmCall(0x80487090+REGIONOFF, setUpBlueCoinInfo);
kmCall(0x80487090+REGIONOFF, setUpBlueCoinInfo); // bl setUpBlueCoinInfo

void PauseMenuIDListControls(PauseMenuExt* pPauseMenu) {
bool stagecheck = MR::isStageNoPauseMenuStars() || MR::isStageStoryBook() || MR::isStageMarioFaceShipOrWorldMap();
Expand Down Expand Up @@ -441,7 +441,7 @@ PauseMenuExt* createPauseMenuExt() {
return new PauseMenuExt();
}

kmCall(0x804712C0, createPauseMenuExt);
kmCall(0x804712C0, createPauseMenuExt); // bl createPauseMenuExt
kmWrite32(0x804712C4, 0x48000010); // b 0x10

PauseMenuExt::PauseMenuExt() : PauseMenu() {
Expand All @@ -466,7 +466,7 @@ void PauseMenuMoveButtonForBlueCoin(PauseMenuExt* pPauseMenu, const char* pStr1,
MR::startPaneAnimAndSetFrameAndStop(pPauseMenu, pStr1, pStr2, frame, u);
}

kmCall(0x804874D4+REGIONOFF, PauseMenuMoveButtonForBlueCoin);
kmCall(0x804874D4+REGIONOFF, PauseMenuMoveButtonForBlueCoin); // bl PauseMenuMoveButtonForBlueCoin
#endif

void initBlueCoinCounterFileInfo(LayoutActor* pLayout) {
Expand All @@ -475,24 +475,24 @@ void initBlueCoinCounterFileInfo(LayoutActor* pLayout) {
MR::setTextBoxFormatRecursive(pLayout, "ShaBlueCoinFileInfo", counterPictureFonts);
}

kmCall(0x8046D908, initBlueCoinCounterFileInfo);
kmCall(0x8046D908, initBlueCoinCounterFileInfo); // bl initBlueCoinCounterFileInfo

void setBlueCoinCounterFileInfo(LayoutActor* pLayout, const char* pStr, s32 fileID) {
MR::setTextBoxArgNumberRecursive(pLayout, "ShaBlueCoinFileInfo", BlueCoinUtil::getTotalBlueCoinNum(fileID - 1, false), 0);
MR::setTextBoxNumberRecursive(pLayout, pStr, fileID);
}

kmCall(0x8046DCF8, setBlueCoinCounterFileInfo);
kmCall(0x8046DCF8, setBlueCoinCounterFileInfo); // bl setBlueCoinCounterFileInfo

#ifdef DISABLED
void initGalaxyInfoBlueCoinCount(LayoutActor* actor) {
MR::setTextBoxFormatRecursive(actor, "ShaBlueCoinGalax", counterPictureFonts2);
}

#if defined TWN || defined KOR
kmCall(0x804A952C, initGalaxyInfoBlueCoinCount);
kmCall(0x804A952C, initGalaxyInfoBlueCoinCount); // bl initGalaxyInfoBlueCoinCount
#else
kmCall(0x804A952C, initGalaxyInfoBlueCoinCount);
kmCall(0x804A952C, initGalaxyInfoBlueCoinCount); // bl initGalaxyInfoBlueCoinCount
#endif

void setGalaxyInfoBlueCoinCount(LayoutActor* actor, const char* pGalaxyName, const wchar_t* pWStr) {
Expand All @@ -509,5 +509,5 @@ void setGalaxyInfoBlueCoinCount(LayoutActor* actor, const char* pGalaxyName, con
}

kmWrite32(0x804A95E4, 0x809B003C); // lwz r4, 0x3C(r27)
kmCall(0x804A95E8, setGalaxyInfoBlueCoinCount);
kmCall(0x804A95E8, setGalaxyInfoBlueCoinCount); // bl setGalaxyInfoBlueCoinCount
#endif
8 changes: 4 additions & 4 deletions PTD/BlueCoinSystem/source/BlueCoinUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ void resetAllBlueCoinOnDeleteFile(SaveDataHandleSequence* pSeq, UserFile* pFile,
BlueCoinUtil::resetAllBlueCoin(fileID);
}

kmCall(0x804D9BF8, resetAllBlueCoinOnDeleteFile);
kmCall(0x804D9BF8, resetAllBlueCoinOnDeleteFile); // bl resetAllBlueCoinOnDeleteFile

// Save gBlueCoinData->collectionData to file.

Expand All @@ -376,9 +376,9 @@ void saveBlueCoinDataOnGameSave(const char* pName) {
}

#if defined TWN || defined KOR
kmCall(0x804DB060, saveBlueCoinDataOnGameSave);
kmCall(0x804DB060, saveBlueCoinDataOnGameSave); // bl saveBlueCoinDataOnGameSave
#else
kmCall(0x804DAFD0, saveBlueCoinDataOnGameSave);
kmCall(0x804DAFD0, saveBlueCoinDataOnGameSave); // bl saveBlueCoinDataOnGameSave
#endif

// Read blue coin binary on title screen load.
Expand All @@ -389,4 +389,4 @@ void onTitleScreenLoad(FileSelector* pFileSelector) {
BlueCoinUtil::loadBlueCoinData();
}

kmCall(0x8024F358, onTitleScreenLoad);
kmCall(0x8024F358, onTitleScreenLoad); // bl saveBlueCoinDataOnGameSave

0 comments on commit 862d87a

Please sign in to comment.