From 3d891b549db48864b5b88310d2308f64e5287237 Mon Sep 17 00:00:00 2001 From: SwareJonge <41187958+SwareJonge@users.noreply.github.com> Date: Mon, 25 May 2026 17:41:58 +0200 Subject: [PATCH] Match and link J2DManager --- configure.py | 2 +- include/Kameda/Demo2D.h | 2 + include/Kameda/Go2D.h | 7 + include/Kameda/Go3212D.h | 10 +- include/Kameda/Goal2D.h | 7 + include/Kameda/J2DManager.h | 9 +- include/Kameda/LANNum2D.h | 4 + include/Kameda/LANResult2D.h | 4 + include/Kameda/PauseManager.h | 2 + include/Kameda/PreRace2D.h | 10 ++ include/Kameda/Race2D.h | 18 +- src/Kameda/J2DManager.cpp | 326 +++++++++++++++++++++++++++++++--- src/Kameda/Race2D.cpp | 2 +- 13 files changed, 366 insertions(+), 37 deletions(-) diff --git a/configure.py b/configure.py index 63b553a..7227dd8 100755 --- a/configure.py +++ b/configure.py @@ -1080,7 +1080,7 @@ def MatchingFor(*versions): [ Object(NonMatching, "Kameda/Motor.cpp"), Object(NonMatching, "Kameda/MotorManager.cpp"), - Object(NonMatching, "Kameda/J2DManager.cpp"), + Object(Matching, "Kameda/J2DManager.cpp"), Object(Matching, "Kameda/Task.cpp"), Object(NonMatching, "Kameda/Goal2D.cpp"), Object(NonMatching, "Kameda/PauseManager.cpp"), diff --git a/include/Kameda/Demo2D.h b/include/Kameda/Demo2D.h index f15bf1f..1b7ac48 100644 --- a/include/Kameda/Demo2D.h +++ b/include/Kameda/Demo2D.h @@ -29,6 +29,8 @@ class Demo2D { void draw(); // 0x801832d0 void calc(); // 0x80183344 + void reset() { init(); } + // Inline/Unused ~Demo2D(); diff --git a/include/Kameda/Go2D.h b/include/Kameda/Go2D.h index 319822a..ccdf3e2 100644 --- a/include/Kameda/Go2D.h +++ b/include/Kameda/Go2D.h @@ -29,5 +29,12 @@ class Go2D { // Autogenerated void calc(); // 0x8016ed58 // Inline/Unused ~Go2D(); + + void reset() { init(); } + void setDrawFlag(bool enable) { mDrawFlag = enable; } +private: + PLACEHOLDER_BYTES(0, 0x30); + bool mDrawFlag; // 30 + PLACEHOLDER_BYTES(0x31, 0x34); }; // class Go2D #endif // GO2D_H diff --git a/include/Kameda/Go3212D.h b/include/Kameda/Go3212D.h index ee88a8e..147b19f 100644 --- a/include/Kameda/Go3212D.h +++ b/include/Kameda/Go3212D.h @@ -22,12 +22,20 @@ class Go3212DHioNode : public HioNode { }; class Go3212D { // Autogenerated - // Global +public: Go3212D(JKRHeap *); // 0x80183460 void init(); // 0x801835f8 void draw(); // 0x80183680 void calc(); // 0x8018372c // Inline/Unused ~Go3212D(); + + void reset() { init(); } + bool isStart() { return mIsStart; } + void start() { mIsStart = true; } +private: + PLACEHOLDER_BYTES(0, 0x24); + bool mIsStart; + PLACEHOLDER_BYTES(0x25, 0x28); }; // class Go3212D #endif // GO3212D_H diff --git a/include/Kameda/Goal2D.h b/include/Kameda/Goal2D.h index 4a63265..1156678 100644 --- a/include/Kameda/Goal2D.h +++ b/include/Kameda/Goal2D.h @@ -37,5 +37,12 @@ class Goal2D { // Autogenerated static bool mDrawEndFlag; // 0x80416290 // Inline/Unused ~Goal2D(); + + void reset() { init(); } + int getAnmFrame(int status) const { return mAnmFrame[status*4]; } +private: + PLACEHOLDER_BYTES(0, 0xb0); + int mAnmFrame[4]; // b0 TODO: check size/is this part of a sub struct + PLACEHOLDER_BYTES(0xc0, 0xec); }; // class Goal2D #endif // GOAL2D_H diff --git a/include/Kameda/J2DManager.h b/include/Kameda/J2DManager.h index 29ca1c0..5a51eb5 100644 --- a/include/Kameda/J2DManager.h +++ b/include/Kameda/J2DManager.h @@ -34,11 +34,11 @@ class J2DManager int getPreRaceWipeType(); // 0x80132064 void setRace2DDrawFlag(bool); // 0x80132070 void hideRace2D(); // 0x80132084 - void getHideFrameRace2D(); // 0x80132094 + int getHideFrameRace2D(); // 0x80132094 bool isHideRace2D(); // 0x801320a0 bool isRaceEnd(); // 0x801320c0 bool isGoalAnmEnd(int); // 0x80132120 - void getGoalAnmFrame(int); // 0x801321b0 + int getGoalAnmFrame(int); // 0x801321b0 bool isAlarm(int); // 0x801321c4 void startLANNumAnm(); // 0x801321e8 void startLANNumResultAnm(); // 0x8013220c @@ -62,7 +62,7 @@ class J2DManager static char *mKartNumberName[8]; // 0x80394378 static int mKart2Status[8]; // 0x803fb9a0 - static int mStatus2Kart[8]; // 0x803fba10 + static int mStatus2Kart[4]; // 0x803fba10 static J2DManager *mThis; // 0x80416288 static bool mNetFlag; // 0x8041628c @@ -70,11 +70,12 @@ class J2DManager J2DOrthoGraph *mOrtho; bool mDrawFlag; bool mInit; + bool _a; int mAnmFrame; bool mWinnerAnmFlag[8]; bool mLoserAnmFlag[8]; int mDuration; - Demo2D *mDemo2D; + Demo2D *mDemo; PreRace2D *mPreRace; Go3212D *mGo321; Go2D *mGo; diff --git a/include/Kameda/LANNum2D.h b/include/Kameda/LANNum2D.h index 0102d5b..208263b 100644 --- a/include/Kameda/LANNum2D.h +++ b/include/Kameda/LANNum2D.h @@ -34,5 +34,9 @@ class LANNum2D { // Autogenerated void start2(); // 0x80197c88 // Inline/Unused ~LANNum2D(); + + void reset() { init(); } +private: + PLACEHOLDER_BYTES(0, 0x10c); }; // class LANNum2D #endif // LANNUM2D_H diff --git a/include/Kameda/LANResult2D.h b/include/Kameda/LANResult2D.h index 866e647..faf80c8 100644 --- a/include/Kameda/LANResult2D.h +++ b/include/Kameda/LANResult2D.h @@ -30,5 +30,9 @@ class LANResult2D { // Autogenerated void start(int); // 0x80195664 // Inline/Unused ~LANResult2D(); + + void reset() { init(); } +private: + PLACEHOLDER_BYTES(0, 0x1c); }; // class LANResult2D #endif // LANRESULT2D_H diff --git a/include/Kameda/PauseManager.h b/include/Kameda/PauseManager.h index 9f478fb..56ffb50 100644 --- a/include/Kameda/PauseManager.h +++ b/include/Kameda/PauseManager.h @@ -27,6 +27,8 @@ class PauseManager { return mThis; } + bool isResultStart() const { return mResultStart; } + private: static PauseManager *mThis; // 0x80416298 static bool mIsPause; // 0x8041629c diff --git a/include/Kameda/PreRace2D.h b/include/Kameda/PreRace2D.h index dd76e55..2c0f2d0 100644 --- a/include/Kameda/PreRace2D.h +++ b/include/Kameda/PreRace2D.h @@ -5,6 +5,7 @@ #include "JSystem/JKernel/JKRHeap.h" #include "JSystem/JORReflexible.h" #include "Kaneshige/HioMgr.h" +#include "macros.h" class PreRace2DParam : public JORReflexible { public: @@ -40,5 +41,14 @@ class PreRace2D { // Autogenerated static const u64 mPreRaceBckTag[2]; // 0x80371070 // Inline/Unused ~PreRace2D(); + + int getStatus() const { return mStatus; } + int getWipeType() const { return mWipeType; } +private: + PLACEHOLDER_BYTES(0, 0x24); + int mStatus; // 24 + PLACEHOLDER_BYTES(0x28, 0x2c); + int mWipeType; // 2c + PLACEHOLDER_BYTES(0x30, 0xe0); }; // class PreRace2D #endif // PRERACE2D_H diff --git a/include/Kameda/Race2D.h b/include/Kameda/Race2D.h index 381f697..6dfab08 100644 --- a/include/Kameda/Race2D.h +++ b/include/Kameda/Race2D.h @@ -60,7 +60,7 @@ class Race2D void setEscapeColor(int); // 0x80161894 void getTimeColor(JUTColor, JUTColor); // 0x80162844 void startBombDemo(); // 0x801629bc - void isAlarm(int); // 0x801629e0 + bool isAlarm(int); // 0x801629e0 void getMapPos(int, JGeometry::TVec3f &, JGeometry::TVec2f &); // 0x80162a40 void getCharacterInfo(int, int, f32 &, f32 &, f32 &); // 0x80162dac void getCharacterClr(int, int, int, JUTColor &, JUTColor &, u8 &); // 0x80162ec8 @@ -124,9 +124,23 @@ class Race2D static Task *mTask; // 0x80416304 // Inline/Unused ~Race2D(); - void getItemPos(int, int, JGeometry::TVec2 &); + void getItemPos(int, int, JGeometry::TVec2f &); void itemUseInit(); void itemUseMain(); + + void reset() { init(); } + void hide() { mHideFrame = 1; } + + int getHideFrame() const { return mHideFrame; } + void setDrawFlag(bool enable) { mDrawFlag = enable; } + + void endBombDemo() { mIsEndBombDemo = true; } +private: + PLACEHOLDER_BYTES(0, 0x4ebc); + int mHideFrame; // 4ebc + bool mDrawFlag; // 4ec0 + bool mIsEndBombDemo; // 4ec1 + PLACEHOLDER_BYTES(0x4ec2, 0x4ec4); }; #endif // RACE2D_H diff --git a/src/Kameda/J2DManager.cpp b/src/Kameda/J2DManager.cpp index 6841f87..c18b169 100644 --- a/src/Kameda/J2DManager.cpp +++ b/src/Kameda/J2DManager.cpp @@ -1,6 +1,26 @@ #include "Kameda/J2DManager.h" +#include "JSystem/JKernel/JKRArchive.h" +#include "JSystem/JKernel/JKRHeap.h" +#include "JSystem/JUtility/JUTAssert.h" +#include "JSystem/JUtility/TColor.h" +#include "Kameda/Demo2D.h" +#include "Kameda/Go2D.h" +#include "Kameda/Go3212D.h" +#include "Kameda/Goal2D.h" +#include "Kameda/LANNum2D.h" +#include "Kameda/LANResult2D.h" +#include "Kameda/PauseManager.h" +#include "Kameda/PreRace2D.h" +#include "Kameda/Race2D.h" +#include "Kameda/WipeManager.h" +#include "Kaneshige/RaceMgr.h" +#include "Osako/NetGameMgr.h" +#include "Osako/ResMgr.h" +#include "Osako/kartPad.h" +#include "Osako/system.h" #include "kartEnums.h" #include "mathHelper.h" +#include "types.h" char *J2DManager::mKartNumberName[8] = { "MarioFont_128.1.bti", @@ -13,64 +33,314 @@ char *J2DManager::mKartNumberName[8] = { "MarioFont_128.8.bti", }; -int J2DManager::mStatus2Kart[8]; int J2DManager::mKart2Status[8]; +int J2DManager::mStatus2Kart[4]; J2DManager *J2DManager::mThis; bool J2DManager::mNetFlag; -J2DManager::J2DManager(JKRHeap *) {} +J2DManager::J2DManager(JKRHeap *heap) { + if (heap == nullptr) { + heap = JKRGetCurrentHeap(); + } + mThis = this; -void J2DManager::reset() {} + mArchive = JKRMountArchive(ResMgr::getPtr(ResMgr::mcArcMRAM, "Race2D.arc"), heap, JKRArchive::MOUNT_DIRECTION_HEAD); + mOrtho = System::getJ2DOrtho(); + mDrawFlag = true; + mInit = true; + _a = true; + + mKart2Status[0] = -1; + mKart2Status[1] = -1; + mKart2Status[2] = -1; + mKart2Status[3] = -1; + mKart2Status[4] = -1; + mKart2Status[5] = -1; + mKart2Status[6] = -1; + mKart2Status[7] = -1; + mStatus2Kart[0] = -1; + mStatus2Kart[1] = -1; + mStatus2Kart[2] = -1; + mStatus2Kart[3] = -1; + mNetFlag = NetGameMgr::ptr()->getState() != 0; -void J2DManager::draw() {} + for (int i = 0; i < 8; i++) { + mWinnerAnmFlag[i] = false; + mLoserAnmFlag[i] = false; + } -void J2DManager::calc() {} + mDuration = 10000; + mWipeMgr = new (heap, 0) WipeManager(heap); + mDemo = new (heap, 0) Demo2D(heap); + mPreRace = new (heap, 0) PreRace2D(heap); + mGo321 = new (heap, 0) Go3212D(heap); + mGo = new (heap, 0) Go2D(heap); + mRace = new (heap, 0) Race2D(heap); + mGoal = new (heap, 0) Goal2D(heap); + mLANNumAnm = new (heap, 0) LANNum2D(heap); + mLANResultAnm = new (heap, 0) LANResult2D(heap); +} -void J2DManager::calcParticle() {} +void J2DManager::reset() { + mDemo->reset(); + mGo321->reset(); + mGo->reset(); + mGoal->reset(); + mRace->reset(); + mLANNumAnm->reset(); + mLANResultAnm->reset(); + mWipeMgr->reset(); + mDuration = 10000; -int J2DManager::getKart2Status(int) {} + if (_a) { + if (RCMGetManager()->isAwardDemoMode()) { + + WipeManager::getManager()->setWipe(getStatus2Kart(0), 1, 0, 40, 0, JUTColor(0xc0, 0xc0, 0xc0, 0xff)); + mDuration = 40; + } + else if (RCMGetManager()->getStatusNumber() < 2) { + WipeManager::getManager()->setWipe(getStatus2Kart(0), 7, 0, 45, 0, JUTColor(0, 0, 0, 0xff)); + mDuration = 45; + } + else { + for (int i = 0; i < RCMGetManager()->getStatusNumber(); i++) { + WipeManager::getManager()->setWipe(getStatus2Kart(i), 1, 0, 40, 0, JUTColor(0, 0, 0, 0xff)); + mDuration = 40; + } + } + _a = false; + } -int J2DManager::getStatus2Kart(int) {} + mAnmFrame = 0; + for (int i = 0; i < 8; i++) { + mWinnerAnmFlag[i] = false; + mLoserAnmFlag[i] = false; + } +} -void J2DManager::setStatus2Kart(int, int) {} +void J2DManager::draw() { + mDemo->draw(); + if (!mDrawFlag) { + mWipeMgr->draw(); + return; + } -void J2DManager::setUsisi(int, ECharID) {} + if (!RCMGetManager()->isAbleStart()) { + mPreRace->draw(); + } -void J2DManager::startPreRace() {} + if (!isLANDemo()) { + mRace->drawPlayerMark(); + mRace->drawMask(); + mRace->draw(); + mWipeMgr->draw(); + mRace->drawCourse(); + mGo321->draw(); + + if (RCMGetManager()->isAbleStart()) { + mGo->draw(); + } + mGoal->drawGoal(); + mGoal->drawRetire(); + mLANNumAnm->draw(); + mLANResultAnm->draw(); + } +} -int J2DManager::getPreRaceStatus() {} +void J2DManager::calc() { + mDemo->calc(); -int J2DManager::getPreRaceWipeType() {} + if (!mInit) return; -void J2DManager::setRace2DDrawFlag(bool) {} + if (!PauseManager::getManager()->isResultStart() && PauseManager::tstPause()) return; + + if (RCMGetManager()->isRaceEnd()) { + mAnmFrame++; + if (RCMGetManager()->isRaceModeGp()) { + if ((mAnmFrame > 333 && mAnmFrame < 333) && gpaGamePad[0]->testTrigger(KartGamePad::A)) { + mAnmFrame = 333; + } + } + if (RCMGetManager()->isRaceModeTA()) { + if (mAnmFrame > 333 && mAnmFrame < 333) { + mAnmFrame = 333; + } + } + } -void J2DManager::hideRace2D() {} + if (!RCMGetManager()->isAbleStart()) { + mPreRace->calc(); + } -void J2DManager::getHideFrameRace2D() {} + mGoal->calc(); + mRace->calc(); -bool J2DManager::isHideRace2D() {} + if (RCMGetManager()->isJugemCountStart()) { + mGo321->start(); + } + mGo321->calc(); -bool J2DManager::isRaceEnd() {} + if (RCMGetManager()->isAbleStart()) { + mGo->calc(); + } -bool J2DManager::isGoalAnmEnd(int) {} + mLANNumAnm->calc(); + mLANResultAnm->calc(); + mWipeMgr->calc(); -void J2DManager::getGoalAnmFrame(int) {} + if (--mDuration < 0) { + mDuration = 0; + } +} -bool J2DManager::isAlarm(int) {} +void J2DManager::calcParticle() { + if (!mInit) { + return; + } -void J2DManager::startLANNumAnm() {} + if (PauseManager::getManager()->isResultStart() || !PauseManager::tstPause()) { + mRace->calcParticle(); + } +} -void J2DManager::startLANNumResultAnm() {} +int J2DManager::getKart2Status(int kart) { +#line 303 + JUT_MINMAX_ASSERT(0, kart, 8); + return mKart2Status[kart]; +} -void J2DManager::startLANResultAnm(int) {} +int J2DManager::getStatus2Kart(int status) { +#line 316 + JUT_MINMAX_ASSERT(0, status, 4); + return mStatus2Kart[status]; +} -void J2DManager::startBombDemo() {} +void J2DManager::setStatus2Kart(int status, int kart) { +#line 330 + JUT_MINMAX_ASSERT(0, kart, 8); + JUT_MINMAX_ASSERT(0, status, 4); + mStatus2Kart[status] = kart; -void J2DManager::endBombDemo() {} + for (int i = 0; i < 8; i++) { + mKart2Status[i] = -1; + } -bool J2DManager::isLANDemo() {} + for (int i = 3; i >= 0; i--) { + if (mStatus2Kart[i] == -1) + continue; + JUT_MINMAX_ASSERT(0, mStatus2Kart[i], 8); + mKart2Status[mStatus2Kart[i]] = i; + } -bool J2DManager::isStartGo321() {} +} + +void J2DManager::setUsisi(int kart, ECharID character) { +#line 357 + JUT_MINMAX_ASSERT(0, kart, 8); + JUT_MINMAX_ASSERT(1, character, cCharIDMax); + mRace->setUsisi(kart, (ECharID)(character - 1)); +} + +void J2DManager::startPreRace() { + mPreRace->start(); +} + +int J2DManager::getPreRaceStatus() { + return mPreRace->getStatus(); +} + +int J2DManager::getPreRaceWipeType() { + return mPreRace->getWipeType(); +} + +void J2DManager::setRace2DDrawFlag(bool enable) { + mGo->setDrawFlag(enable); + mRace->setDrawFlag(enable); +} + +void J2DManager::hideRace2D() { + mRace->hide(); +} + +int J2DManager::getHideFrameRace2D() { + return mRace->getHideFrame(); +} + +bool J2DManager::isHideRace2D() { + return getHideFrameRace2D() >= 20; +} + +bool J2DManager::isRaceEnd() { + switch (RCMGetManager()->getRaceMode()) { + case TIME_ATTACK: + case GRAND_PRIX: + case VERSUS_RACE: { + return mAnmFrame > 353; + default: + return mAnmFrame > 128; + } + } +} + +bool J2DManager::isGoalAnmEnd(int status) { + int goalAnmFrame = mGoal->getAnmFrame(status); + bool ret = (goalAnmFrame >= 128); + if (ret) { + switch (RCMGetManager()->getRaceMode()) { + case TIME_ATTACK: + case GRAND_PRIX: + case VERSUS_RACE: { + ret = mAnmFrame > 353; + break; + default: + ret = mAnmFrame > 128; + break; + } + } + } + + return ret; +} + +bool J2DManager::isMiniGameAnmEnd(int status) { + // UNUSED +} + +int J2DManager::getGoalAnmFrame(int status) { + return mGoal->getAnmFrame(status); +} + +bool J2DManager::isAlarm(int kart) { + return mRace->isAlarm(kart); +} + +void J2DManager::startLANNumAnm() { + mLANNumAnm->start(); +} + +void J2DManager::startLANNumResultAnm() { + mLANNumAnm->start2(); +} + +void J2DManager::startLANResultAnm(int kart) { + mLANResultAnm->start(kart); +} + +void J2DManager::startBombDemo() { + mRace->startBombDemo(); +} + +void J2DManager::endBombDemo() { + mRace->endBombDemo(); +} + +bool J2DManager::isLANDemo() { + return mNetFlag && RCMGetManager()->isDemoCamera(0); +} + +bool J2DManager::isStartGo321() { + return mGo321->isStart(); +} #include "JSystem/JAudio/JASFakeMatch2.h" diff --git a/src/Kameda/Race2D.cpp b/src/Kameda/Race2D.cpp index aaf85b2..dbc3f98 100644 --- a/src/Kameda/Race2D.cpp +++ b/src/Kameda/Race2D.cpp @@ -391,7 +391,7 @@ void Race2D::getTimeColor(JUTColor, JUTColor) {} void Race2D::startBombDemo() {} -void Race2D::isAlarm(int) {} +bool Race2D::isAlarm(int) {} void Race2D::getMapPos(int, JGeometry::TVec3f &, JGeometry::TVec2f &) {}