Look if it matches it matches

This commit is contained in:
robojumper
2024-05-28 20:45:14 +02:00
parent d05a543bc1
commit 35a4b294a1
6 changed files with 80 additions and 59 deletions
+1 -1
View File
@@ -248,7 +248,7 @@ m/m_mtx.cpp:
.ctors start:0x804DB8D4 end:0x804DB8D8
m/m_pad.cpp:
.text start:0x802F1F20 end:0x802F2330
.text start:0x802F1F20 end:0x802F232C
.ctors start:0x804DB8D8 end:0x804DB8DC
.sbss start:0x80575C50 end:0x80575C70
.sdata2 start:0x8057CDF8 end:0x8057CE00
+4 -4
View File
@@ -17860,7 +17860,7 @@ getWPADInfoCB__4mPadFi = .text:0x802F21F0; // type:function size:0x64
__sinit_\m_pad_cpp = .text:0x802F2260; // type:function size:0x58 scope:local
__ct__Q24mPad19PadAdditionalData_tFv = .text:0x802F22C0; // type:function size:0x4
__dt__Q24mPad19PadAdditionalData_tFv = .text:0x802F22D0; // type:function size:0x40
__arraydtor$4391 = .text:0x802F2310; // type:function size:0x1C
__arraydtor$4414 = .text:0x802F2310; // type:function size:0x1C
fn_802F2330 = .text:0x802F2330; // type:function size:0x120
fn_802F2450 = .text:0x802F2450; // type:function size:0x18C
fn_802F25E0 = .text:0x802F25E0; // type:function size:0x19C
@@ -22811,7 +22811,7 @@ fn_803DADF0 = .text:0x803DADF0; // type:function size:0x5C
fn_803DAE50 = .text:0x803DAE50; // type:function size:0x44
fn_803DAEA0 = .text:0x803DAEA0; // type:function size:0xC0
fn_803DAF60 = .text:0x803DAF60; // type:function size:0x54
fn_803DAFC0 = .text:0x803DAFC0; // type:function size:0x220
WPADGetInfoAsync = .text:0x803DAFC0; // type:function size:0x220
fn_803DB1E0 = .text:0x803DB1E0; // type:function size:0xCC
fn_803DB2B0 = .text:0x803DB2B0; // type:function size:0x34
fn_803DB2F0 = .text:0x803DB2F0; // type:function size:0x34
@@ -40279,7 +40279,7 @@ g_assertHeap__5mHeap = .sbss:0x80575C48; // type:object size:0x4 data:4byte
g_padMg__4mPad = .sbss:0x80575C50; // type:object size:0x4 data:4byte
g_currentCoreId__4mPad = .sbss:0x80575C54; // type:object size:0x4 data:4byte
g_currentCore__4mPad = .sbss:0x80575C58; // type:object size:0x4 data:4byte
g_IsConnected__4mPad = .sbss:0x80575C5C; // type:object size:0x1 data:byte
g_IsConnected__4mPad = .sbss:0x80575C5C; // type:object size:0x4 data:byte
g_PadFrame__4mPad = .sbss:0x80575C60; // type:object size:0x4 data:4byte
s_WPADInfoAvailable__4mPad = .sbss:0x80575C64; // type:object size:0x4
s_GetWPADInfoInterval__4mPad = .sbss:0x80575C68; // type:object size:0x4 data:4byte
@@ -49082,7 +49082,7 @@ lbl_805CAF98 = .bss:0x805CAF98; // type:object size:0xC
g_gameHeaps__5mHeap = .bss:0x805CB078; // type:object size:0x10 data:4byte
lbl_805CB088 = .bss:0x805CB088; // type:object size:0x30 data:4byte
g_core__4mPad = .bss:0x805CB0B8; // type:object size:0x10 data:4byte
lbl_805CB0C8 = .bss:0x805CB0C8; // type:object size:0x10
lbl_805CB0C8 = .bss:0x805CB0C8; // type:object size:0xC
g_PadAdditionalData__4mPad = .bss:0x805CB0D8; // type:object size:0x60 data:float
s_WPADInfo__4mPad = .bss:0x805CB138; // type:object size:0x60
s_WPADInfoTmp__4mPad = .bss:0x805CB198; // type:object size:0x60
+1 -1
View File
@@ -307,7 +307,7 @@ config.libs = [
Object(Matching, "m/m_dvd.cpp"),
Object(Matching, "m/m_heap.cpp"),
Object(NonMatching, "m/m_mtx.cpp"),
Object(NonMatching, "m/m_pad.cpp"),
Object(Matching, "m/m_pad.cpp"),
Object(Matching, "DynamicLink.cpp"),
# framework (f_name)
# d stuff (d_name)
+5
View File
@@ -3,6 +3,11 @@
namespace mPad {
extern EGG::CoreControllerMgr *g_padMg;
extern int g_currentCoreId;
extern EGG::CoreController *g_currentCore;
extern EGG::CoreController *g_core[4];
void create();
void beginPad();
void endPad();
+14
View File
@@ -17,12 +17,26 @@ typedef enum {
WPAD_RESULT_SUCCESS = 0,
} WPADResult;
typedef struct {
u32 field_0x00;
u32 field_0x04;
u32 field_0x08;
u32 field_0x0C;
u32 field_0x10;
bool field_0x14;
bool field_0x15;
bool field_0x16;
bool field_0x17;
} WPADInfo;
UNKTYPE WPADControlSpeaker(s32, UNKWORD, WPADCallback);
BOOL WPADCanSendStreamData(s32);
UNKWORD WPADSendStreamData(s32, UNKTYPE *, UNKWORD);
s32 WPADProbe(s32 chan, u32 *type);
s32 WPADReadFaceData(s32 chan, void *dst, u32 size, u32 src, WPADCallback cb);
s32 WPADGetInfoAsync(s32 chan, WPADInfo *dst, WPADCallback cb);
#ifdef __cplusplus
}
+55 -53
View File
@@ -2,44 +2,22 @@
#include <egg/core/eggController.h>
#include <egg/math/eggVector.h>
#include <m/m_pad.h>
#include <rvl/WPAD.h>
namespace mPad {
static EGG::CoreControllerMgr *g_padMg;
static int g_currentCoreId;
static EGG::CoreController *g_currentCore;
EGG::CoreControllerMgr *g_padMg;
int g_currentCoreId;
EGG::CoreController *g_currentCore;
EGG::CoreController *g_core[4];
static bool g_IsConnected[4];
static u32 g_PadFrame;
static u32 s_GetWPADInfoInterval = 0;
static bool s_WPADInfoAvailable[4];
static u32 s_GetWPADInfoInterval = 0;
static u32 s_GetWPADInfoCount = 0;
static EGG::CoreController *g_core[4];
struct WPADInfo_t {
u32 field_0x00;
u32 field_0x04;
u32 field_0x08;
u32 field_0x0C;
u32 field_0x10;
bool field_0x14;
bool field_0x15;
bool field_0x16;
bool field_0x17;
inline void clear() {
field_0x00 = 0;
field_0x04 = 0;
field_0x08 = 0;
field_0x0C = 0;
field_0x10 = 0;
field_0x14 = false;
field_0x15 = false;
field_0x16 = false;
field_0x17 = false;
}
};
struct PadAdditionalData_t {
PadAdditionalData_t() {}
@@ -51,8 +29,8 @@ struct PadAdditionalData_t {
};
static PadAdditionalData_t g_PadAdditionalData[4];
static WPADInfo_t s_WPADInfo[4];
static WPADInfo_t s_WPADInfoTmp[4];
static WPADInfo s_WPADInfo[4];
static WPADInfo s_WPADInfoTmp[4];
static void initWPADInfo();
static void clearWPADInfo(int);
@@ -65,27 +43,36 @@ void create() {
endPad();
}
// Has a regshuffle
// This code looks really bad.
// It mostly matches when writing it the obvious way
// (just indexing the arrays normally)
// but has an annoying regshuffle
void beginPad() {
EGG::CoreController *ctl;
g_PadFrame++;
g_padMg->beginFrame();
for (int i = 0; i < 4; i++) {
EGG::CoreController *ctl;
EGG::CoreController **p_ctl = g_core;
PadAdditionalData_t *dat = g_PadAdditionalData;
bool *connected;
int i = 0;
connected = g_IsConnected;
for (; i < 4; i++) {
ctl = g_padMg->getNthController(i);
g_core[i] = ctl;
*p_ctl = ctl;
if (ctl->mFlag.onBit(0)) {
// These sort of look like value, first order derivative, and second order derivative
// So perhaps value, velocity, acceleration?
EGG::Vector2f pos = ctl->coreStatus[0].getUnk();
EGG::Vector2f v = pos - g_PadAdditionalData[i].v1;
g_PadAdditionalData[i].v1 = pos;
g_PadAdditionalData[i].v3 = v - g_PadAdditionalData[i].v2;
g_PadAdditionalData[i].v2 = v;
EGG::Vector2f v = pos - dat->v1;
dat->v1 = pos;
dat->v3 = v - dat->v2;
dat->v2 = v;
if (!g_IsConnected[i]) {
g_IsConnected[i] = true;
if (!*connected) {
*connected = true;
}
// Not sure why this checks the controller index against the tick count
@@ -94,18 +81,22 @@ void beginPad() {
(s_GetWPADInfoInterval <= 3 && (s_GetWPADInfoCount & 1) == (i & 1)))) {
getWPADInfoCB(i);
}
} else if (g_IsConnected[i]) {
} else if (*connected) {
ctl->coreStatus->init();
ctl->sceneReset();
g_PadAdditionalData[i].v1.x = 0.0f;
g_PadAdditionalData[i].v1.y = 0.0f;
g_PadAdditionalData[i].v3.x = 0.0f;
g_PadAdditionalData[i].v3.y = 0.0f;
g_PadAdditionalData[i].v2.x = 0.0f;
g_PadAdditionalData[i].v2.y = 0.0f;
dat->v1.x = 0.0f;
dat->v1.y = 0.0f;
dat->v3.x = 0.0f;
dat->v3.y = 0.0f;
dat->v2.x = 0.0f;
dat->v2.y = 0.0f;
clearWPADInfo(i);
g_IsConnected[i] = false;
*connected = false;
}
p_ctl++;
dat++;
connected++;
}
if (s_GetWPADInfoInterval != 0) {
@@ -121,9 +112,21 @@ void endPad() {
g_padMg->endFrame();
}
static inline void clear(WPADInfo *info) {
info->field_0x00 = 0;
info->field_0x04 = 0;
info->field_0x08 = 0;
info->field_0x0C = 0;
info->field_0x10 = 0;
info->field_0x14 = false;
info->field_0x15 = false;
info->field_0x16 = false;
info->field_0x17 = false;
}
static void clearWPADInfo(int controller) {
s_WPADInfoAvailable[controller] = false;
s_WPADInfo[controller].clear();
clear(&s_WPADInfo[controller]);
}
static void initWPADInfo() {
@@ -132,11 +135,10 @@ static void initWPADInfo() {
}
}
extern "C" int fn_803DAFC0(int controller, void *data, void (*callback)(int, int));
extern "C" void fn_80058DA0(int, int);
extern "C" void fn_80058DA0(s32, s32);
static int getWPADInfoCB(int controller) {
int result = fn_803DAFC0(controller, &s_WPADInfoTmp[controller], fn_80058DA0);
int result = WPADGetInfoAsync(controller, &s_WPADInfoTmp[controller], fn_80058DA0);
if (result == -1) {
clearWPADInfo(controller);
}