From 8bf90ec7f35de9fdd8629a0b50fbbca74a423816 Mon Sep 17 00:00:00 2001 From: SwareJonge Date: Mon, 1 Jan 2024 03:01:52 +0100 Subject: [PATCH] match and link PadMgr.cpp --- config/MarioClub_us/dol_slices.yml | 8 ++ config/Release_eu/dol_slices.yml | 6 ++ config/Release_eu/symbols.yml | 8 ++ include/JSystem/JUtility/JUTGamePad.h | 36 ++++++- include/JSystem/Logitech/Wheels.h | 2 +- include/Kaneshige/Course/CrsData.h | 2 +- include/Kaneshige/THP/THPPlayer.h | 4 +- include/Osako/NetGameMgr.h | 36 +++++-- include/Osako/PadMgr.h | 9 +- include/Osako/kartPad.h | 30 ++++-- src/Osako/PadMgr.cpp | 147 ++++++++++++++++++++++++++ src/Osako/not matched/PadMgr.cpp | 0 src/Osako/system.cpp | 11 +- src/Osako/testApp.cpp | 8 +- 14 files changed, 265 insertions(+), 42 deletions(-) create mode 100644 src/Osako/PadMgr.cpp delete mode 100644 src/Osako/not matched/PadMgr.cpp diff --git a/config/MarioClub_us/dol_slices.yml b/config/MarioClub_us/dol_slices.yml index 79294e4..5778e61 100644 --- a/config/MarioClub_us/dol_slices.yml +++ b/config/MarioClub_us/dol_slices.yml @@ -1254,6 +1254,14 @@ src/Osako/SaveFile.cpp: .sbss: [0x80416a48, 0x80416a50] .sdata2: [0x8041b840, 0x8041b858] +src/Osako/PadMgr.cpp: + .text: [0x8020c3ac, 0x8020c980] + .ctors: [0x803163a8, 0x803163ac] + .rodata: [0x8037e090, 0x8037e0c8] + .bss: [0x803e4b50, 0x803e4b80] + .sbss: [0x80416a50, 0x80416a58] + .sdata2: [0x8041b858, 0x8041b868] + src/Osako/AwardApp.cpp: .text: [0x8020e15c, 0x8020e3ac] .ctors: [0x803163b0, 0x803163b4] diff --git a/config/Release_eu/dol_slices.yml b/config/Release_eu/dol_slices.yml index faed7b0..fd9f7d2 100644 --- a/config/Release_eu/dol_slices.yml +++ b/config/Release_eu/dol_slices.yml @@ -1182,6 +1182,12 @@ src/Osako/SaveFile.cpp: #.bss: [0x803c65f4, 0x803c6a00] .sbss: [0x803d5c90, 0x803d5c98] +src/Osako/PadMgr.cpp: + .text: [0x801dc0b4, 0x801dc588] + .ctors: [0x802d87ac, 0x802d87b0] + .bss: [0x803a3eb0, 0x803a3ee0] + .sbss: [0x803d5c98, 0x803d5ca0] + src/Osako/AwardApp.cpp: .text: [0x801ddb68, 0x801dddb8] .ctors: [0x802d87b4, 0x802d87b8] diff --git a/config/Release_eu/symbols.yml b/config/Release_eu/symbols.yml index 3e7a26f..6f323dd 100644 --- a/config/Release_eu/symbols.yml +++ b/config/Release_eu/symbols.yml @@ -3427,7 +3427,10 @@ global: 0x801d6a28: end__10NetGameMgrFb 0x801d7c98: framework__10NetGameMgrFv 0x801d84b4: retraceCallback__10NetGameMgrFUl + 0x801d8944: getKartPad__10NetGameMgrFUcP11KartPadData 0x801d8a18: adjustFrame__10NetGameMgrFv + 0x801d8c10: progressReadData__10NetGameMgrFv + 0x801d8d70: fetchPadData__10NetGameMgrFv 0x803d5c58: mspNetGameMgr__10NetGameMgr # SequenceApp.cpp @@ -3499,6 +3502,11 @@ global: 0x801dc290: getPadData__6PadMgrFUcQ26PadMgr12KartPadInputP11KartPadData 0x801dc354: setKartPadInput__6PadMgrFQ26PadMgr12KartPadInput 0x801dc384: resetPort__6PadMgrFv + 0x803d5c98: msKartPadInput__6PadMgr + 0x803d5c9c: mspRecorder__6PadMgr + # PadRecoder.cpp + 0x801dc900: line__11PadRecorderFUcP11KartPadData + 0x801dcacc: framework__11PadRecorderFv # BBAMgr.cpp 0x801dd058: create__6BBAMgrFP7JKRHeap # AwardApp.cpp diff --git a/include/JSystem/JUtility/JUTGamePad.h b/include/JSystem/JUtility/JUTGamePad.h index 7a2cd48..631e7e2 100644 --- a/include/JSystem/JUtility/JUTGamePad.h +++ b/include/JSystem/JUtility/JUTGamePad.h @@ -152,12 +152,34 @@ public: return JUTGamePad::sClampMode; } + static LGWheels *getLGWheels() { return mspLGWheels; } + static const PADStatus &getPadStatus(u8 port) + { +#line 363 + JUT_ASSERT(port < 4); + return mPadStatus[port]; + } + static s8 getPortStatus(EPadPort port) { JUT_ASSERT(0 <= port && port < 4); return mPadStatus[port].err; } + static s32 getSIType(u8 port) { +#line 528 + JUT_ASSERT(port < 4); + return msaSIType[port]; + } + + static const LGPosition &getLGPosition(u8 port) + { +#line 535 + JUT_ASSERT(port < 4); + JUT_ASSERT(mspLGWheels); + return mspLGWheels->getPosition(port); + } + bool isPushing3ButtonReset() const { bool pushing = false; @@ -170,6 +192,15 @@ public: return pushing; } + void checkReset() // fabricated + { + if (C3ButtonReset::sResetOccurred) + { + if (!isPushing3ButtonReset()) + clearResetOccurred(); + } + } + int getErrorStatus() const { return this->mErrorStatus; @@ -410,12 +441,9 @@ public: ret = true; break; } - return ret; + return ret; } - static LGWheels* getLGWheels() { return mspLGWheels; } - static PADStatus *getPadStatus(int idx) { return &mPadStatus[idx]; } - static LGWheels *mspLGWheels; static JSUList mPadList; static CButton mPadButton[PAD_CONTROLLER_NUM]; diff --git a/include/JSystem/Logitech/Wheels.h b/include/JSystem/Logitech/Wheels.h index 28786c0..b430be9 100644 --- a/include/JSystem/Logitech/Wheels.h +++ b/include/JSystem/Logitech/Wheels.h @@ -54,7 +54,7 @@ public: // void StopDirtRoadEffect(s32); // void StopSurfaceEffect(s32); - LGPosition &getPosition(int idx) {return mPosition[idx]; } + LGPosition &getPosition(u8 idx) {return mPosition[idx]; } LGPosition mPosition[4]; u8 _28[0x1440]; // TODO diff --git a/include/Kaneshige/Course/CrsData.h b/include/Kaneshige/Course/CrsData.h index ba64da2..027c846 100644 --- a/include/Kaneshige/Course/CrsData.h +++ b/include/Kaneshige/Course/CrsData.h @@ -11,7 +11,7 @@ class Course; // Forward Declaration -// TODO: refactor some of these structs to not use camelcase naming +// TODO: refactor all of these structs to use mVarName naming class CrsData { diff --git a/include/Kaneshige/THP/THPPlayer.h b/include/Kaneshige/THP/THPPlayer.h index b775c82..6d765f8 100644 --- a/include/Kaneshige/THP/THPPlayer.h +++ b/include/Kaneshige/THP/THPPlayer.h @@ -71,12 +71,12 @@ BOOL THPPlayerSetBuffer(u8 *data); u32 THPPlayerCalcNeedMemory(); -BOOL THPPlayerGetVideoInfo(void *dst); +BOOL THPPlayerGetVideoInfo(THPVideoInfo *videoInfo); // BOOL THPPlayerGetAudioInfo(void *dst); // f32 THPPlayerGetFrameRate(); BOOL THPPlayerSetVolume(s32 vol, s32 duration); -s32 THPPlayerDrawCurrentFrame(GXRenderModeObj *rmode, s32, s32, s32, s32); // TODO, parameter names from dwarf info if it exists +s32 THPPlayerDrawCurrentFrame(GXRenderModeObj *rmode, u32 x, u32 y, u32 polygonW, u32 polygonH); // TODO, parameter names from dwarf info if it exists u32 THPPlayerGetTotalFrame(); s32 THPPlayerGetState(); diff --git a/include/Osako/NetGameMgr.h b/include/Osako/NetGameMgr.h index 62314ee..acca230 100644 --- a/include/Osako/NetGameMgr.h +++ b/include/Osako/NetGameMgr.h @@ -14,12 +14,13 @@ struct SSDPSearchInfo; class NetGameMgr { // Autogenerated public: - enum NetActionType { + enum NetActionType + { }; - struct NetPkt { - + struct NetPkt + { }; // Global static void create(JKRHeap *); // 0x80205db4 @@ -41,7 +42,7 @@ public: void sendTask(void *); // 0x802072e4 void framework(); // 0x802073a4 void syncwork(); // 0x802079c4 - static void retraceCallback(u32); // 0x80207c58 + static void retraceCallback(u32); // 0x80207c58 void callbackNotify(const char *, const SOInAddr *); // 0x80207c84 void callbackSearch(const char *, const SOInAddr *, const SSDPSearchInfo *); // 0x80207e2c void appendGCInfo(const SOInAddr *); // 0x80207fc0 @@ -94,10 +95,29 @@ public: static NetGameMgr *ptr() { return mspNetGameMgr; } int getState() { return mState; } + int getNetworkNum() { return mNetworkNum; } + + // Fabricated + u8 getPadConvNum(u8 idx) + { + int temp = mPadConvData[idx]; + return (temp / 4); + } + + u8 getPadConvPort(u8 idx) + { + int temp = mPadConvData[idx]; + return (temp % 4); + } private: - u8 _0[0x96c]; - int mState; - u8 _970[0x1308 - 0x970]; -}; // size: 0x1308 + u8 _0[0x96c]; // + int mState; // 6C + u8 _970[0xC58 - 0x970]; // + u8 mNetworkNum; // C58 + u8 _C59[0x12f4 - 0xC59]; // + u8 mPadConvData[16]; // this might be a double sided array and a union? + u8 _1304[0x1308 - 0x1304]; // + +}; // size: 0x1308 #endif // NETGAMEMGR_H \ No newline at end of file diff --git a/include/Osako/PadMgr.h b/include/Osako/PadMgr.h index b0caf0f..9f972ea 100644 --- a/include/Osako/PadMgr.h +++ b/include/Osako/PadMgr.h @@ -2,13 +2,14 @@ #define PADMGR_H #include "Osako/kartPad.h" - +#include "Osako/PadRecorder.h" namespace PadMgr { // Autogenerated enum KartPadInput - { // this is either 0 or 1? - + { + Input_Local, + Input_Net }; // Global void init(); // 0x8020c3ac @@ -18,6 +19,6 @@ namespace PadMgr void setKartPadInput(KartPadInput); // 0x8020c74c void resetPort(); // 0x8020c77c extern KartPadInput msKartPadInput; // 0x80416a50 - extern void *mspRecorder; // 0x80416a54 + extern PadRecorder *mspRecorder; // 0x80416a54 }; // namespace PadMgr #endif // PADMGR_H \ No newline at end of file diff --git a/include/Osako/kartPad.h b/include/Osako/kartPad.h index ac33419..8be1c29 100644 --- a/include/Osako/kartPad.h +++ b/include/Osako/kartPad.h @@ -10,26 +10,30 @@ class KartGamePad : public JUTGamePad { public: // placeholder Enums - enum PadPort { + enum PadPort + { PORT_NET = -2, - PORT_INV = -1, // uninitialized maybe? + PORT_INV = -1, // uninitialized/local pad? PORT_1 = 0, PORT_2 = 1, PORT_3 = 2, PORT_4 = 3, }; - enum PadType { + enum PadType + { NORMAL, NETWORK, RECORD }; - enum PadState { + enum PadState + { STATE_0, // available? STATE_1 // unavailable? }; - KartGamePad(EPadPort ePadPort, PadPort padPort, PadType padType, PadState padState) : JUTGamePad(ePadPort) { + KartGamePad(EPadPort ePadPort, PadPort padPort, PadType padType, PadState padState) : JUTGamePad(ePadPort) + { mPadType = padType; mPadPort = padPort; mPadState = padState; @@ -42,12 +46,16 @@ public: PadType getPadType() { return mPadType; } PadPort getPadPort() { return mPadPort; } - PadState getPadState() { return mPadState;} + PadState getPadState() { return mPadState; } + + void setPadType(PadType padType) { mPadType = padType; } + void setPadPort(PadPort padPort) { mPadPort = padPort; } + void setPadState(PadState padState) { mPadState = padState; } private: - PadType mPadType; - PadPort mPadPort; - PadState mPadState; + PadType mPadType; // A8 + PadPort mPadPort; // AC + PadState mPadState; // B0 }; extern KartGamePad gGamePad1P; // has -common on and bss bug @@ -72,7 +80,7 @@ extern KartGamePad gKartPad14P; extern KartGamePad gKartPad15P; extern KartGamePad gKartPad16P; -extern KartGamePad * gpaGamePad[]; -extern KartGamePad * gpaKartPad[]; +extern KartGamePad *gpaGamePad[]; +extern KartGamePad *gpaKartPad[]; #endif KARTPAD_H \ No newline at end of file diff --git a/src/Osako/PadMgr.cpp b/src/Osako/PadMgr.cpp new file mode 100644 index 0000000..67d96db --- /dev/null +++ b/src/Osako/PadMgr.cpp @@ -0,0 +1,147 @@ +#include + +#include "Osako/PadMgr.h" +#include "Osako/NetGameMgr.h" + +#include +#include + +#ifdef DEBUG +static const float float_slack_PadMgr[4] = {0.0f, 0.0f, 0.0f, 1.0f}; +#pragma push +#pragma force_active on +DUMMY_POINTER(float_slack_PadMgr) +#pragma pop +#endif + +namespace PadMgr +{ + KartPadInput msKartPadInput; + PadRecorder *mspRecorder; + + void init() + { + for (int i = 0; i < 4; i++) + gpaGamePad[i]->setButtonRepeat(0xf000000, 0x14, 8); + + for (int i = 0; i < 16; i++) + gpaKartPad[i]->setButtonRepeat(0xf000000, 0x14, 8); + } + + void framework() + { + JUTGamePad::read(); + gGamePad1P.checkReset(); + + processKartPad(); + if (msKartPadInput == Input_Net) + { + NetGameMgr::ptr()->progressReadData(); + NetGameMgr::ptr()->fetchPadData(); + } + } + + void processKartPad() + { + KartPadData padData; + if (mspRecorder) + { + + for (u8 i = 0; i < 16; i++) + { + getPadData(i, msKartPadInput, &padData); + mspRecorder->line(i, &padData); + gpaKartPad[i]->expand(padData); + } + mspRecorder->framework(); + } + else + { + for (u8 i = 0; i < 16; i++) + { + getPadData(i, msKartPadInput, &padData); + gpaKartPad[i]->expand(padData); + } + } + } + + void getPadData(u8 port, KartPadInput padInput, KartPadData *padData) + { + if (padInput == Input_Local) + { + if (port < 4) + { + s32 siType = JUTGamePad::getSIType(port); + switch (siType) + { + case SI_TYPE_GC: + { + KartGamePad::compress(JUTGamePad::getLGPosition(port), padData); + return; + } + case SI_GC_CONTROLLER: + case SI_GC_WAVEBIRD: + KartGamePad::compress(JUTGamePad::getPadStatus(port), padData); + return; + } + } + memset(padData, 0, sizeof(KartPadData)); + } + else + { + NetGameMgr::ptr()->getKartPad(port, padData); + } + } + + void setKartPadInput(KartPadInput padInput) + { + if (msKartPadInput == padInput) + return; + + msKartPadInput = padInput; + resetPort(); + } + + void resetPort() + { + switch (msKartPadInput) + { + case Input_Local: + { + for (int i = 0; i < 16; i++) + { + gpaKartPad[i]->setPadType(KartGamePad::NORMAL); + if (i < 4) + { + gpaKartPad[i]->setPadPort((KartGamePad::PadPort)i); + } + else + { + gpaKartPad[i]->setPadPort(KartGamePad::PORT_INV); + } + } + break; + } + case Input_Net: + { + for (int i = 0; i < 16; i++) + { + gpaKartPad[i]->setPadType(KartGamePad::NETWORK); + + u8 port = NetGameMgr::ptr()->getPadConvPort(i); + u8 num = NetGameMgr::ptr()->getPadConvNum(i); + + if (num == NetGameMgr::ptr()->getNetworkNum()) + { + gpaKartPad[i]->setPadPort((KartGamePad::PadPort)port); + } + else + { + gpaKartPad[i]->setPadPort(KartGamePad::PORT_NET); + } + } + break; + } + } + } +} \ No newline at end of file diff --git a/src/Osako/not matched/PadMgr.cpp b/src/Osako/not matched/PadMgr.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/src/Osako/system.cpp b/src/Osako/system.cpp index bc3bd62..889713e 100644 --- a/src/Osako/system.cpp +++ b/src/Osako/system.cpp @@ -32,10 +32,10 @@ // .rodata #ifdef DEBUG -static const float lbl_8037d5e8[4] = {0.0f, 0.0f, 0.0f, 1.0f}; +static const float float_slack_system[4] = {0.0f, 0.0f, 0.0f, 1.0f}; #pragma push #pragma force_active on -DUMMY_POINTER(lbl_8037d5e8) +DUMMY_POINTER(float_slack_system) #pragma pop #endif @@ -58,9 +58,10 @@ namespace System { J2DOrthoGraph *mspJ2DOrtho; JKRSolidHeap *mspAudioHeap; - void startAudioTask(void*) { - void *audioFile = JKRDvdRipper::loadToMainRAM("AudioRes/GCKart.baa", nullptr, EXPAND_SWITCH_DECOMPRESS, - 0, SequenceApp::mspSequenceApp->getHeap(), JKRDvdRipper::ALLOC_DIR_BOTTOM, 0, nullptr, nullptr); + void startAudioTask(void* arg) { + // this either doesn't use the inline or it got recasted to u8* for whatever reason + u8 *audioFile = (u8 *)JKRDvdToMainRam("AudioRes/GCKart.baa", nullptr, EXPAND_SWITCH_DECOMPRESS, + 0, SequenceApp::ptr()->getHeap(), JKRDvdRipper::ALLOC_DIR_BOTTOM, 0, nullptr, nullptr); GetGameAudioMain()->init(mspAudioHeap, SystemData::scAudioAramSize, audioFile, 0, 0); delete audioFile; gSystemRecord.applyAudioSetting(); diff --git a/src/Osako/testApp.cpp b/src/Osako/testApp.cpp index 9a7905d..7a1f2a6 100644 --- a/src/Osako/testApp.cpp +++ b/src/Osako/testApp.cpp @@ -15,13 +15,9 @@ TestApp * TestApp::create(void) return mspTestApp; } -TestApp::TestApp() : GameApp(null, "test", nullptr) { +TestApp::TestApp() : GameApp(0, "test", nullptr) { } -} - -TestApp::~TestApp() { - mspTestApp = 0; -} +TestApp::~TestApp() { mspTestApp = nullptr; } void TestApp::draw() { #if DEBUG