match and link PadMgr.cpp

This commit is contained in:
SwareJonge 2024-01-01 03:01:52 +01:00
parent d52af950f5
commit 8bf90ec7f3
14 changed files with 265 additions and 42 deletions

View File

@ -1254,6 +1254,14 @@ src/Osako/SaveFile.cpp:
.sbss: [0x80416a48, 0x80416a50] .sbss: [0x80416a48, 0x80416a50]
.sdata2: [0x8041b840, 0x8041b858] .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: src/Osako/AwardApp.cpp:
.text: [0x8020e15c, 0x8020e3ac] .text: [0x8020e15c, 0x8020e3ac]
.ctors: [0x803163b0, 0x803163b4] .ctors: [0x803163b0, 0x803163b4]

View File

@ -1182,6 +1182,12 @@ src/Osako/SaveFile.cpp:
#.bss: [0x803c65f4, 0x803c6a00] #.bss: [0x803c65f4, 0x803c6a00]
.sbss: [0x803d5c90, 0x803d5c98] .sbss: [0x803d5c90, 0x803d5c98]
src/Osako/PadMgr.cpp:
.text: [0x801dc0b4, 0x801dc588]
.ctors: [0x802d87ac, 0x802d87b0]
.bss: [0x803a3eb0, 0x803a3ee0]
.sbss: [0x803d5c98, 0x803d5ca0]
src/Osako/AwardApp.cpp: src/Osako/AwardApp.cpp:
.text: [0x801ddb68, 0x801dddb8] .text: [0x801ddb68, 0x801dddb8]
.ctors: [0x802d87b4, 0x802d87b8] .ctors: [0x802d87b4, 0x802d87b8]

View File

@ -3427,7 +3427,10 @@ global:
0x801d6a28: end__10NetGameMgrFb 0x801d6a28: end__10NetGameMgrFb
0x801d7c98: framework__10NetGameMgrFv 0x801d7c98: framework__10NetGameMgrFv
0x801d84b4: retraceCallback__10NetGameMgrFUl 0x801d84b4: retraceCallback__10NetGameMgrFUl
0x801d8944: getKartPad__10NetGameMgrFUcP11KartPadData
0x801d8a18: adjustFrame__10NetGameMgrFv 0x801d8a18: adjustFrame__10NetGameMgrFv
0x801d8c10: progressReadData__10NetGameMgrFv
0x801d8d70: fetchPadData__10NetGameMgrFv
0x803d5c58: mspNetGameMgr__10NetGameMgr 0x803d5c58: mspNetGameMgr__10NetGameMgr
# SequenceApp.cpp # SequenceApp.cpp
@ -3499,6 +3502,11 @@ global:
0x801dc290: getPadData__6PadMgrFUcQ26PadMgr12KartPadInputP11KartPadData 0x801dc290: getPadData__6PadMgrFUcQ26PadMgr12KartPadInputP11KartPadData
0x801dc354: setKartPadInput__6PadMgrFQ26PadMgr12KartPadInput 0x801dc354: setKartPadInput__6PadMgrFQ26PadMgr12KartPadInput
0x801dc384: resetPort__6PadMgrFv 0x801dc384: resetPort__6PadMgrFv
0x803d5c98: msKartPadInput__6PadMgr
0x803d5c9c: mspRecorder__6PadMgr
# PadRecoder.cpp
0x801dc900: line__11PadRecorderFUcP11KartPadData
0x801dcacc: framework__11PadRecorderFv
# BBAMgr.cpp # BBAMgr.cpp
0x801dd058: create__6BBAMgrFP7JKRHeap 0x801dd058: create__6BBAMgrFP7JKRHeap
# AwardApp.cpp # AwardApp.cpp

View File

@ -152,12 +152,34 @@ public:
return JUTGamePad::sClampMode; 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) static s8 getPortStatus(EPadPort port)
{ {
JUT_ASSERT(0 <= port && port < 4); JUT_ASSERT(0 <= port && port < 4);
return mPadStatus[port].err; 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 isPushing3ButtonReset() const
{ {
bool pushing = false; bool pushing = false;
@ -170,6 +192,15 @@ public:
return pushing; return pushing;
} }
void checkReset() // fabricated
{
if (C3ButtonReset::sResetOccurred)
{
if (!isPushing3ButtonReset())
clearResetOccurred();
}
}
int getErrorStatus() const int getErrorStatus() const
{ {
return this->mErrorStatus; return this->mErrorStatus;
@ -410,12 +441,9 @@ public:
ret = true; ret = true;
break; break;
} }
return ret; return ret;
} }
static LGWheels* getLGWheels() { return mspLGWheels; }
static PADStatus *getPadStatus(int idx) { return &mPadStatus[idx]; }
static LGWheels *mspLGWheels; static LGWheels *mspLGWheels;
static JSUList<JUTGamePad> mPadList; static JSUList<JUTGamePad> mPadList;
static CButton mPadButton[PAD_CONTROLLER_NUM]; static CButton mPadButton[PAD_CONTROLLER_NUM];

View File

@ -54,7 +54,7 @@ public:
// void StopDirtRoadEffect(s32); // void StopDirtRoadEffect(s32);
// void StopSurfaceEffect(s32); // void StopSurfaceEffect(s32);
LGPosition &getPosition(int idx) {return mPosition[idx]; } LGPosition &getPosition(u8 idx) {return mPosition[idx]; }
LGPosition mPosition[4]; LGPosition mPosition[4];
u8 _28[0x1440]; // TODO u8 _28[0x1440]; // TODO

View File

@ -11,7 +11,7 @@
class Course; // Forward Declaration 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 class CrsData
{ {

View File

@ -71,12 +71,12 @@ BOOL THPPlayerSetBuffer(u8 *data);
u32 THPPlayerCalcNeedMemory(); u32 THPPlayerCalcNeedMemory();
BOOL THPPlayerGetVideoInfo(void *dst); BOOL THPPlayerGetVideoInfo(THPVideoInfo *videoInfo);
// BOOL THPPlayerGetAudioInfo(void *dst); // BOOL THPPlayerGetAudioInfo(void *dst);
// f32 THPPlayerGetFrameRate(); // f32 THPPlayerGetFrameRate();
BOOL THPPlayerSetVolume(s32 vol, s32 duration); 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(); u32 THPPlayerGetTotalFrame();
s32 THPPlayerGetState(); s32 THPPlayerGetState();

View File

@ -14,12 +14,13 @@ struct SSDPSearchInfo;
class NetGameMgr class NetGameMgr
{ // Autogenerated { // Autogenerated
public: public:
enum NetActionType { enum NetActionType
{
}; };
struct NetPkt { struct NetPkt
{
}; };
// Global // Global
static void create(JKRHeap *); // 0x80205db4 static void create(JKRHeap *); // 0x80205db4
@ -41,7 +42,7 @@ public:
void sendTask(void *); // 0x802072e4 void sendTask(void *); // 0x802072e4
void framework(); // 0x802073a4 void framework(); // 0x802073a4
void syncwork(); // 0x802079c4 void syncwork(); // 0x802079c4
static void retraceCallback(u32); // 0x80207c58 static void retraceCallback(u32); // 0x80207c58
void callbackNotify(const char *, const SOInAddr *); // 0x80207c84 void callbackNotify(const char *, const SOInAddr *); // 0x80207c84
void callbackSearch(const char *, const SOInAddr *, const SSDPSearchInfo *); // 0x80207e2c void callbackSearch(const char *, const SOInAddr *, const SSDPSearchInfo *); // 0x80207e2c
void appendGCInfo(const SOInAddr *); // 0x80207fc0 void appendGCInfo(const SOInAddr *); // 0x80207fc0
@ -94,10 +95,29 @@ public:
static NetGameMgr *ptr() { return mspNetGameMgr; } static NetGameMgr *ptr() { return mspNetGameMgr; }
int getState() { return mState; } 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: private:
u8 _0[0x96c]; u8 _0[0x96c]; //
int mState; int mState; // 6C
u8 _970[0x1308 - 0x970]; u8 _970[0xC58 - 0x970]; //
}; // size: 0x1308 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 #endif // NETGAMEMGR_H

View File

@ -2,13 +2,14 @@
#define PADMGR_H #define PADMGR_H
#include "Osako/kartPad.h" #include "Osako/kartPad.h"
#include "Osako/PadRecorder.h"
namespace PadMgr namespace PadMgr
{ // Autogenerated { // Autogenerated
enum KartPadInput enum KartPadInput
{ // this is either 0 or 1? {
Input_Local,
Input_Net
}; };
// Global // Global
void init(); // 0x8020c3ac void init(); // 0x8020c3ac
@ -18,6 +19,6 @@ namespace PadMgr
void setKartPadInput(KartPadInput); // 0x8020c74c void setKartPadInput(KartPadInput); // 0x8020c74c
void resetPort(); // 0x8020c77c void resetPort(); // 0x8020c77c
extern KartPadInput msKartPadInput; // 0x80416a50 extern KartPadInput msKartPadInput; // 0x80416a50
extern void *mspRecorder; // 0x80416a54 extern PadRecorder *mspRecorder; // 0x80416a54
}; // namespace PadMgr }; // namespace PadMgr
#endif // PADMGR_H #endif // PADMGR_H

View File

@ -10,26 +10,30 @@ class KartGamePad : public JUTGamePad
{ {
public: public:
// placeholder Enums // placeholder Enums
enum PadPort { enum PadPort
{
PORT_NET = -2, PORT_NET = -2,
PORT_INV = -1, // uninitialized maybe? PORT_INV = -1, // uninitialized/local pad?
PORT_1 = 0, PORT_1 = 0,
PORT_2 = 1, PORT_2 = 1,
PORT_3 = 2, PORT_3 = 2,
PORT_4 = 3, PORT_4 = 3,
}; };
enum PadType { enum PadType
{
NORMAL, NORMAL,
NETWORK, NETWORK,
RECORD RECORD
}; };
enum PadState { enum PadState
{
STATE_0, // available? STATE_0, // available?
STATE_1 // unavailable? 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; mPadType = padType;
mPadPort = padPort; mPadPort = padPort;
mPadState = padState; mPadState = padState;
@ -42,12 +46,16 @@ public:
PadType getPadType() { return mPadType; } PadType getPadType() { return mPadType; }
PadPort getPadPort() { return mPadPort; } 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: private:
PadType mPadType; PadType mPadType; // A8
PadPort mPadPort; PadPort mPadPort; // AC
PadState mPadState; PadState mPadState; // B0
}; };
extern KartGamePad gGamePad1P; // has -common on and bss bug extern KartGamePad gGamePad1P; // has -common on and bss bug
@ -72,7 +80,7 @@ extern KartGamePad gKartPad14P;
extern KartGamePad gKartPad15P; extern KartGamePad gKartPad15P;
extern KartGamePad gKartPad16P; extern KartGamePad gKartPad16P;
extern KartGamePad * gpaGamePad[]; extern KartGamePad *gpaGamePad[];
extern KartGamePad * gpaKartPad[]; extern KartGamePad *gpaKartPad[];
#endif KARTPAD_H #endif KARTPAD_H

147
src/Osako/PadMgr.cpp Normal file
View File

@ -0,0 +1,147 @@
#include <string.h>
#include "Osako/PadMgr.h"
#include "Osako/NetGameMgr.h"
#include <ppcdis.h>
#include <JSystem/JAudio/JASFakeMatch2.h>
#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;
}
}
}
}

View File

@ -32,10 +32,10 @@
// .rodata // .rodata
#ifdef DEBUG #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 push
#pragma force_active on #pragma force_active on
DUMMY_POINTER(lbl_8037d5e8) DUMMY_POINTER(float_slack_system)
#pragma pop #pragma pop
#endif #endif
@ -58,9 +58,10 @@ namespace System {
J2DOrthoGraph *mspJ2DOrtho; J2DOrthoGraph *mspJ2DOrtho;
JKRSolidHeap *mspAudioHeap; JKRSolidHeap *mspAudioHeap;
void startAudioTask(void*) { void startAudioTask(void* arg) {
void *audioFile = JKRDvdRipper::loadToMainRAM("AudioRes/GCKart.baa", nullptr, EXPAND_SWITCH_DECOMPRESS, // this either doesn't use the inline or it got recasted to u8* for whatever reason
0, SequenceApp::mspSequenceApp->getHeap(), JKRDvdRipper::ALLOC_DIR_BOTTOM, 0, nullptr, nullptr); 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); GetGameAudioMain()->init(mspAudioHeap, SystemData::scAudioAramSize, audioFile, 0, 0);
delete audioFile; delete audioFile;
gSystemRecord.applyAudioSetting(); gSystemRecord.applyAudioSetting();

View File

@ -15,13 +15,9 @@ TestApp * TestApp::create(void)
return mspTestApp; return mspTestApp;
} }
TestApp::TestApp() : GameApp(null, "test", nullptr) { TestApp::TestApp() : GameApp(0, "test", nullptr) { }
} TestApp::~TestApp() { mspTestApp = nullptr; }
TestApp::~TestApp() {
mspTestApp = 0;
}
void TestApp::draw() { void TestApp::draw() {
#if DEBUG #if DEBUG