diff --git a/configure.py b/configure.py index 61d65144..0d57cd82 100755 --- a/configure.py +++ b/configure.py @@ -1101,7 +1101,7 @@ def MatchingFor(*versions): Object(NonMatching, "Kameda/Race2D.cpp"), Object(Matching, "Kameda/ReadPrintMessage.cpp"), Object(Matching, "Kameda/PrintProgressive.cpp"), - Object(NonMatching, "Kameda/PrintMemoryCard.cpp"), + Object(Matching, "Kameda/PrintMemoryCard.cpp"), Object(NonMatching, "Kameda/PreRace2D.cpp"), Object(Matching, "Kameda/Go2D.cpp"), Object(Matching, "Kameda/Mario.cpp"), diff --git a/include/Kameda/PrintMemoryCard.h b/include/Kameda/PrintMemoryCard.h index c3fd3d59..a9faf908 100644 --- a/include/Kameda/PrintMemoryCard.h +++ b/include/Kameda/PrintMemoryCard.h @@ -1,13 +1,13 @@ #ifndef PRINTMEMORYCARD_H #define PRINTMEMORYCARD_H -#include +#include "JSystem/JKernel/JKRHeap.h" +#include "Kameda/PrintWindow.h" +#include "Osako/ResMgr.h" class PrintMemoryCard { public: - PrintMemoryCard(JKRHeap *heap); // 0x8016be58 - // TODO: are these actually correct? enum MessageID { @@ -48,62 +48,68 @@ class PrintMemoryCard mcGstBrokenNoLoad, mcBrokenNoLoad, // these are lan related for whatever reason - mcTooManyFilesContinue, // begin lan setup - mcNoSpaceContinue, // disconnect lan link - mcMsg38, // disconnecting LAN Link - mcMsg39, // Quit are you sure? - mcMsg40 // black screen, no text here, also panic if bmg gets requested + mcTooManyFilesContinue, // begin lan setup + mcNoSpaceContinue, // disconnect lan link + mcMsg38, // disconnecting LAN Link + mcMsg39, // Quit are you sure? + mcMsg40 // black screen, no text here, also panic if bmg gets requested }; - + + PrintMemoryCard(JKRHeap *heap); // 0x8016be58 + ~PrintMemoryCard(); + // TODO - void setStuff(u8 a, u8 b, u8 c) { - _c = a ; + void setStuff(u8 a, u8 b, u8 c) + { + _c = a; _d = b; _e = c; } - void reset(); // 0x8016bf24 - void init(MessageID); // 0x8016bf90 - void changeMessage(); // 0x8016bfac - void draw(); // 0x8016c3e0 - void calc(); // 0x8016c410 - void closeWindow(); // 0x8016c92c - void closeWindowNoSe(); // 0x8016c9f8 - void setBmgPtr(); // 0x8016ca9c - void isMessage(); // 0x8016cb0c - void getChoiceType(); // 0x8016cb98 - void getWindowSize(); // 0x8016cc34 - void getWindowColor(); // 0x8016cd00 - // Inline/Unused - // void initWindow(); - // ~PrintMemoryCard(); + void reset(); // 0x8016bf24 + void init(MessageID); // 0x8016bf90 + void initWindow(); + void changeMessage(); // 0x8016bfac + void draw(); // 0x8016c3e0 + void calc(); // 0x8016c410 + void closeWindow(); // 0x8016c92c + void closeWindowNoSe(); // 0x8016c9f8 + void setBmgPtr(); // 0x8016ca9c + bool isMessage(); // 0x8016cb0c + s32 getChoiceType(); // 0x8016cb98 + int getWindowSize(); // 0x8016cc34 + int getWindowColor(); // 0x8016cd00 - int get_1cThing() { - if (_20 == 0 || _20 == 25) + int get_1cThing() + { + if (mFrame == 0 || mFrame == 25) return 3; return _1c; - } + } - int get_14Thing() { - if (_1c == 2 && (_20 == 0 || _20 == 25)) - return _14; - return 2; - } + int get_14Thing() + { + if (_1c == 2 && (mFrame == 0 || mFrame == 25)) + return _14; + return 2; + } private: - // TODO - u8 _0[0x4]; - void *mpBmg; // 0x4 - u8 _8[0xc - 0x8]; - u8 _c; - u8 _d; - u8 _e; - u8 _f[0x14 - 0xf]; - int _14; - u8 _18[4]; - int _1c; - int _20; - u8 _24[0x30 - 0x24]; -}; // Size: 0x30 + void *mResColor; // 0x0 + void *mResCard; // 0x4 + PrintWindow *mPrintWindow; // 0x8 + u8 _c; // 0xc + u8 _d; // 0xd + u8 _e; // 0xe + u8 _f; // 0xf + PrintMemoryCard::MessageID mMessageID; // 0x10 + s32 _14; // 0x14 + s32 _18; // 0x18 + s32 _1c; // 0x1c + s32 mFrame; // 0x20 + s32 _24; // 0x24 + s32 _28; // 0x28 + JUTColor mColor; // 0x2c +}; // Size: 0x30 -#endif // PRINTMEMORYCARD_H +#endif // PRINTMEMORYCARD_H diff --git a/src/Kameda/PrintMemoryCard.cpp b/src/Kameda/PrintMemoryCard.cpp index cc4524db..77306221 100644 --- a/src/Kameda/PrintMemoryCard.cpp +++ b/src/Kameda/PrintMemoryCard.cpp @@ -1,29 +1,605 @@ #include "Kameda/PrintMemoryCard.h" -PrintMemoryCard::PrintMemoryCard(JKRHeap *) {} +#include "Inagaki/GameAudioMain.h" +#include "JSystem/JAudio/JASFakeMatch2.h" // For static initializer +#include "JSystem/JUtility/JUTAssert.h" +#include "JSystem/JUtility/JUTGamePad.h" +#include "Kameda/ReadPrintMessage.h" +#include "Osako/NetGameMgr.h" +#include "Osako/ResMgr.h" +#include "Osako/kartPad.h" -void PrintMemoryCard::reset() {} +PrintMemoryCard::PrintMemoryCard(JKRHeap *heap) +{ + mPrintWindow = new (heap, 0) PrintWindow(heap); + mPrintWindow->mInfo.type = 1; + mPrintWindow->mInfo._2f0 = 0; -void PrintMemoryCard::init(PrintMemoryCard::MessageID) {} + mResColor = ResMgr::getPtr(ResMgr::mcColor); + mResCard = ResMgr::getPtr(ResMgr::mcCard); -void PrintMemoryCard::changeMessage() {} + mColor = ReadPrintMessage::getColor(mResColor, ReadPrintMessage::getDefaultColor(mResCard)); -void PrintMemoryCard::draw() {} + reset(); +} -void PrintMemoryCard::calc() {} +void PrintMemoryCard::reset() +{ + _c = 0; + _d = 0; + _e = 0; + _f = 0; + mFrame = 0; + _24 = 0; + _28 = 0; -void PrintMemoryCard::closeWindow() {} + mPrintWindow->mInfo.frame = mFrame; + mPrintWindow->calc(); +} -void PrintMemoryCard::closeWindowNoSe() {} +void PrintMemoryCard::init(PrintMemoryCard::MessageID messageID) +{ + _f = 1; + mMessageID = messageID; + _14 = 2; + _1c = 2; +} -void PrintMemoryCard::setBmgPtr() {} +void PrintMemoryCard::changeMessage() +{ + _14 = 2; + _1c = 0; -void PrintMemoryCard::isMessage() {} + switch (_24) + { + case 0: + mFrame = -1; + break; + case 1: + mFrame = 24; + break; + default: + break; + } -void PrintMemoryCard::getChoiceType() {} + if (mMessageID == mcMsg40) + return; -void PrintMemoryCard::getWindowSize() {} + mPrintWindow->mInfo.type = getWindowSize(); + mPrintWindow->mInfo._2f0 = getWindowColor(); -void PrintMemoryCard::getWindowColor() {} + switch (getChoiceType()) + { + case 0: + _18 = 2; + mPrintWindow->mInfo._2ec = 1; + mPrintWindow->mInfo._2f8 = 2; + break; + case 1: + _18 = 0; + mPrintWindow->mInfo._2ec = 0; + mPrintWindow->mInfo._2f8 = 0; + break; + case 2: + _18 = 1; + mPrintWindow->mInfo._2ec = 0; + mPrintWindow->mInfo._2f8 = 1; + break; + default: +#line 151 + JUT_ASSERT(0); + } -#include "JSystem/JAudio/JASFakeMatch2.h" + if (isMessage()) + { + mPrintWindow->getTextBox()->show(); + } + else + { + mPrintWindow->getTextBox()->hide(); + } + + if (getChoiceType() == 0) + { + mPrintWindow->mInfo._2ec = 1; + } + else + { + mPrintWindow->mInfo._2ec = 0; + } + + if (isMessage()) + { + setBmgPtr(); + + int bmgMessageID = ReadPrintMessage::getBmgMessageID(mMessageID); + char *message = ReadPrintMessage::getMessage(mResCard, bmgMessageID); + + mColor = ReadPrintMessage::getColor(mResColor, ReadPrintMessage::getDefaultColor(mResCard)); + mPrintWindow->getTextBox()->setFontColor(mColor, mColor); + + { + J2DTextBox::TFontSize fontSize = mPrintWindow->getBaseFontSize(); + mPrintWindow->getTextBox()->setFontSize( + fontSize.x * ReadPrintMessage::getRate(mResCard, bmgMessageID) / 100.0f, + fontSize.y * ReadPrintMessage::getRate(mResCard, bmgMessageID) / 100.0f); + } + + mPrintWindow->getTextBox()->setCharSpace( + ReadPrintMessage::getCharSpace(mResCard, bmgMessageID)); + + { + J2DTextBox::TFontSize fontSize; + mPrintWindow->getTextBox()->getFontSize(fontSize); + char buf[512]; + ReadPrintMessage::tagCnv(message, mResColor, fontSize, sizeof(buf), buf); + strncpy(mPrintWindow->getTextBox()->getStringPtr(), buf, sizeof(buf)); + } + } + + if (_c == 0) + { + GameAudio::Main::getAudio()->startSystemSe(0x2000b); + _c = 1; + } + else if (_e == 0) + { + GameAudio::Main::getAudio()->startSystemSe(0x20047); + } + _e = 0; +} + +void PrintMemoryCard::draw() +{ + if (mMessageID != PrintMemoryCard::mcMsg40) + { + mPrintWindow->draw(); + } +} + +void PrintMemoryCard::calc() +{ + if (mMessageID == mcMsg40) + return; + + bool left, right; + bool pressed; + if (NetGameMgr::ptr()->getState() != 0) + { + left = gpaKartPad[0]->testRepeat(JUTGamePad::MAINSTICK_LEFT); + pressed = gpaKartPad[0]->testTrigger(JUTGamePad::A); + right = gpaKartPad[0]->testRepeat(JUTGamePad::MAINSTICK_RIGHT); + } + else + { + left = gpaGamePad[0]->testRepeat(JUTGamePad::MAINSTICK_LEFT); + pressed = gpaGamePad[0]->testTrigger(JUTGamePad::A); + right = gpaGamePad[0]->testRepeat(JUTGamePad::MAINSTICK_RIGHT); + } + + if (getChoiceType() != 0) + { + if (pressed) + { + if (_14 == 2 && _1c == 1) + { + switch (_18) + { + case 0: + GameAudio::Main::getAudio()->startSystemSe(0x20003); + _d = 1; + _e = 1; + _14 = 0; + break; + case 1: + GameAudio::Main::getAudio()->startSystemSe(0x20005); + _d = 1; + _e = 1; + _14 = 1; + break; + default: +#line 272 + JUT_ASSERT(0); + } + closeWindowNoSe(); + } + } + else if (left && _18 == 1) + { + if (_14 == 2 && _1c == 1) + { + GameAudio::Main::getAudio()->startSystemSe(0x20000); + _18 = 0; + } + } + else if (right && _18 == 0) + { + if (_14 == 2 && _1c == 1) + { + GameAudio::Main::getAudio()->startSystemSe(0x20000); + _18 = 1; + } + } + } + else + { + switch (mMessageID) + { + case mcMissSaved: + case mcInCardPushButton: + case mcChangeCardPushButton: + case mcMissFormat: + case mcMissMakeFile: + case mcGstNoLoad: + case mcGstBrokenNoLoad: + case mcBrokenNoLoad: + for (int i = 0; i < 1; ++i) // To match reference assembly; iterator not even used. + { + if (pressed && _14 == 2 && _1c == 1) + { + GameAudio::Main::getAudio()->startSystemSe(0x20003); + _d = 1; + _e = 1; + _14 = 0; + closeWindowNoSe(); + } + } + break; + default: + break; + } + } + + switch (_1c) + { + case 0: + switch (_24) + { + case 0: + if (mFrame++ + 1 >= 10) + { + mFrame = 9; + _1c = 1; + } + break; + case 1: + if (mFrame++ + 1 >= 30) + { + mFrame = 30; + _1c = 1; + } + break; + default: +#line 340 + JUT_ASSERT(0); + } + break; + case 1: + break; + case 2: + case 3: + switch (_28) + { + case 0: + if (--mFrame < 0) + { + mFrame = 0; + } + break; + case 1: + if (mFrame++ + 1 >= 25) + { + mFrame = 25; + } + break; + default: +#line 360 + JUT_ASSERT(0); + } + if ((mFrame == 0 || mFrame == 25) && _f) + { + _f = 0; + changeMessage(); + } + break; + default: +#line 373 + JUT_ASSERT(0); + } + + if (getChoiceType()) + { + switch (_18) + { + case 0: + mPrintWindow->mInfo._2f8 = 0; + break; + case 1: + mPrintWindow->mInfo._2f8 = 1; + break; + case 2: + mPrintWindow->mInfo._2f8 = 2; + break; + default: +#line 390 + JUT_ASSERT(0); + } + } + + mPrintWindow->mInfo.frame = mFrame; + mPrintWindow->calc(); +} + +void PrintMemoryCard::closeWindow() +{ + if (_1c == 3) + return; + + if (_1c == 2) + return; + + GameAudio::Main::getAudio()->startSystemSe(0x20046); + + _d = 1; + _e = 1; + + _1c = 2; + + switch (_28) + { + case 0: + mFrame = 9; + break; + case 1: + mFrame = 20; + break; + default: +#line 424 + JUT_ASSERT(0); + } +} + +void PrintMemoryCard::closeWindowNoSe() +{ + if (_1c == 3) + return; + + if (_1c == 2) + return; + + _1c = 2; + + switch (_28) + { + case 0: + mFrame = 9; + break; + case 1: + mFrame = 20; + break; + default: +#line 451 + JUT_ASSERT(0); + } +} + +void PrintMemoryCard::setBmgPtr() +{ + switch (mMessageID) + { + case mcTooManyFilesContinue: + case mcNoSpaceContinue: + case mcMsg38: + mResCard = ResMgr::getPtr(ResMgr::mcLan); + break; + case mcMsg39: + mResCard = ResMgr::getPtr(ResMgr::mcRace); + break; + default: + mResCard = ResMgr::getPtr(ResMgr::mcCard); + break; + } +} + +bool PrintMemoryCard::isMessage() +{ + bool result; + + if (0 <= mMessageID && mMessageID < 41) + { + if (mMessageID == mcMsg40) + { + result = false; + } + else + { + result = true; + } + } + else + { +#line 497 + JUT_ASSERT(0); + } + + return result; +} + +s32 PrintMemoryCard::getChoiceType() +{ + s32 result; + + switch (mMessageID) + { + case mcGameSavingNoTouch: + case mcGetSavingNoTouch: + case mcMissSaved: + case mcInCardPushButton: + case mcChangeCardPushButton: + case mcMissFormat: + case mcFormatNoTouch: + case mcMakeFileNoTouch: + case mcMadeFile: + case mcMissMakeFile: + case mcNoUse: + case mcWithoutMK: + case mcBrokenNoUse: + case mcBrokenNeedFormat: + case mcLoaded: + case mcNoSpaceNoSave: + case mcTooManyFiles: + case mcSaved: + case mcNoGst: + case mcGstNoLoad: + case mcGstBrokenNoLoad: + case mcBrokenNoLoad: + case mcMsg38: + case mcMsg40: + result = 0; + break; + case mcMakeFile: + case mcNoSpaceGoIPL: + case mcTooManyFilesGoIPL: + result = 1; + break; + case mcNoCardContinue: + case mcNoUseContinue: + case mcWithouMKContinue: + case mcBrokenNoSaveContinue: + case mcBrokenGoFormat: + case mcNoFileNoSave: + case mcFormatLost: + case mcNoSaveContinue: + case mcGstLoad: + case mcGstSave: + case mcGstOverwrite: + case mcTooManyFilesContinue: + case mcNoSpaceContinue: + case mcMsg39: + result = 2; + break; + default: +#line 561 + JUT_ASSERT(0); + } + + return result; +} + +int PrintMemoryCard::getWindowSize() +{ + int result; + + switch (mMessageID) + { + case mcMadeFile: + case mcGstLoad: + case mcLoaded: + case mcGstSave: + case mcSaved: + case mcGstOverwrite: + case mcMsg39: + result = 0; + break; + case mcNoCardContinue: + case mcNoUseContinue: + case mcWithouMKContinue: + case mcBrokenNoSaveContinue: + case mcBrokenGoFormat: + case mcNoFileNoSave: + case mcGameSavingNoTouch: + case mcGetSavingNoTouch: + case mcMissSaved: + case mcInCardPushButton: + case mcChangeCardPushButton: + case mcMissFormat: + case mcFormatLost: + case mcFormatNoTouch: + case mcNoSaveContinue: + case mcMakeFile: + case mcMakeFileNoTouch: + case mcMissMakeFile: + case mcNoSpaceGoIPL: + case mcTooManyFilesGoIPL: + case mcNoUse: + case mcWithoutMK: + case mcBrokenNoUse: + case mcBrokenNeedFormat: + case mcNoSpaceNoSave: + case mcTooManyFiles: + case mcNoGst: + case mcGstNoLoad: + case mcGstBrokenNoLoad: + case mcBrokenNoLoad: + case mcTooManyFilesContinue: + case mcNoSpaceContinue: + case mcMsg38: + case mcMsg40: + result = 1; + break; + default: +#line 624 + JUT_ASSERT(0); + } + + return result; +} + +int PrintMemoryCard::getWindowColor() +{ + int result; + + switch (mMessageID) + { + case mcNoCardContinue: + case mcNoUseContinue: + case mcWithouMKContinue: + case mcBrokenNoSaveContinue: + case mcBrokenGoFormat: + case mcNoFileNoSave: + case mcGameSavingNoTouch: + case mcGetSavingNoTouch: + case mcInCardPushButton: + case mcChangeCardPushButton: + case mcFormatLost: + case mcFormatNoTouch: + case mcNoSaveContinue: + case mcMakeFile: + case mcMakeFileNoTouch: + case mcMadeFile: + case mcNoSpaceGoIPL: + case mcTooManyFilesGoIPL: + case mcNoUse: + case mcWithoutMK: + case mcBrokenNoUse: + case mcBrokenNeedFormat: + case mcGstLoad: + case mcLoaded: + case mcNoSpaceNoSave: + case mcTooManyFiles: + case mcGstSave: + case mcSaved: + case mcGstOverwrite: + case mcNoGst: + case mcTooManyFilesContinue: + case mcNoSpaceContinue: + case mcMsg38: + case mcMsg39: + case mcMsg40: + result = 0; + break; + case mcMissSaved: + case mcMissFormat: + case mcMissMakeFile: + case mcGstNoLoad: + case mcGstBrokenNoLoad: + case mcBrokenNoLoad: + result = 1; + break; + default: +#line 687 + JUT_ASSERT(0); + } + + return result; +}