From 3b6081165adc64fe53802ed35e2ae0665de6b54e Mon Sep 17 00:00:00 2001 From: elijah-thomas774 Date: Wed, 16 Jul 2025 10:34:06 -0400 Subject: [PATCH] some updates -> non working yet --- config/SOUE01/symbols.txt | 144 +++++------ include/d/d_pad.h | 118 +++++++-- include/egg/core/eggController.h | 9 + include/rvl/KPAD/KPAD.h | 5 + src/d/d_pad.cpp | 416 +++++++++++++++++++++++++++++-- src/d/d_sc_title.cpp | 2 +- 6 files changed, 579 insertions(+), 115 deletions(-) diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index bd4873b1..4b7399a8 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -2250,7 +2250,7 @@ create__4dPadFv = .text:0x80055270; // type:function size:0xBC setMpls__4dPadFbl = .text:0x80055330; // type:function size:0x98 centerPos__4dPadFR7mVec2_cR7mVec2_c = .text:0x800553D0; // type:function size:0x50 beginPad_BR__4dPadFv = .text:0x80055420; // type:function size:0x73C -fn_80055B60 = .text:0x80055B60; // type:function size:0x10 +getStateID__86sStateMgr_c<17dLytControlGame_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x80055B60; // type:function size:0x10 errRangeOver__Q23EGG29TBufferCFv = .text:0x80055B70; // type:function size:0x4 endPad_BR__4dPadFv = .text:0x80055B80; // type:function size:0x4 connectCallback__4dPadFRCQ23EGG24CoreControllerConnectArg = .text:0x80055B90; // type:function size:0x94 @@ -2258,58 +2258,58 @@ setConnectCallback__4dPadFv = .text:0x80055C30; // type:function size:0x10 enableMplsDirRevise__4dPadFl = .text:0x80055C40; // type:function size:0x4 disableMplsDirRevise__4dPadFl = .text:0x80055C50; // type:function size:0x4 __ct__Q24dPad4ex_cFv = .text:0x80055C60; // type:function size:0x284 -fn_80055EF0 = .text:0x80055EF0; // type:function size:0x3B4 -fn_800562B0 = .text:0x800562B0; // type:function size:0x74 -fn_80056330 = .text:0x80056330; // type:function size:0x24C -fn_80056580 = .text:0x80056580; // type:function size:0xEC -centerCursor = .text:0x80056670; // type:function size:0x114 -fn_80056790 = .text:0x80056790; // type:function size:0x334 -fn_80056AD0 = .text:0x80056AD0; // type:function size:0xC -fn_80056AE0 = .text:0x80056AE0; // type:function size:0xC +fn_80055EF0__Q24dPad4ex_cFl = .text:0x80055EF0; // type:function size:0x3B4 +fn_800562B0__Q24dPad4ex_cFlR7mVec3_c = .text:0x800562B0; // type:function size:0x74 +fn_80056330__Q24dPad4ex_cFl = .text:0x80056330; // type:function size:0x24C +fn_80056580__Q24dPad4ex_cFlR7mVec2_c = .text:0x80056580; // type:function size:0xEC +centerCursor__Q24dPad4ex_cFlb = .text:0x80056670; // type:function size:0x114 +fn_80056790__Q24dPad4ex_cFl = .text:0x80056790; // type:function size:0x334 +setField_0x70__Q24dPad4ex_cF4mAng = .text:0x80056AD0; // type:function size:0xC +setField_0x70__Q24dPad4ex_cFv = .text:0x80056AE0; // type:function size:0xC fn_80056AF0__Q24dPad4ex_cFl = .text:0x80056AF0; // type:function size:0x90 -fn_80056B80 = .text:0x80056B80; // type:function size:0x10 +checkWPADProbeStable__Q24dPad4ex_cFv = .text:0x80056B80; // type:function size:0x10 fn_80056B90__Q24dPad4ex_cFl = .text:0x80056B90; // type:function size:0x14C fn_80056CE0__Q24dPad4ex_cFl = .text:0x80056CE0; // type:function size:0xBC -fn_80056DA0 = .text:0x80056DA0; // type:function size:0x48 -fn_80056DF0 = .text:0x80056DF0; // type:function size:0x60 -fn_80056E50 = .text:0x80056E50; // type:function size:0x8 -fn_80056E60 = .text:0x80056E60; // type:function size:0x4C -fn_80056EB0 = .text:0x80056EB0; // type:function size:0x38 +fn_80056DA0__Q24dPad4ex_cFl = .text:0x80056DA0; // type:function size:0x48 +fn_80056DF0__Q24dPad4ex_cFl = .text:0x80056DF0; // type:function size:0x60 +fn_80056E50__Q24dPad4ex_cFv = .text:0x80056E50; // type:function size:0x8 +fn_80056E60__Q24dPad4ex_cFl = .text:0x80056E60; // type:function size:0x4C +centerCursor__Q24dPad4ex_cFl = .text:0x80056EB0; // type:function size:0x38 resetState__Q24dPad4ex_cFl = .text:0x80056EF0; // type:function size:0xC -fn_80056F00 = .text:0x80056F00; // type:function size:0x24 -fn_80056F30 = .text:0x80056F30; // type:function size:0xC -fn_80056F40 = .text:0x80056F40; // type:function size:0xC8 -fn_80057010 = .text:0x80057010; // type:function size:0x10 -fn_80057020 = .text:0x80057020; // type:function size:0x80 -fn_800570A0 = .text:0x800570A0; // type:function size:0x10 -fn_800570B0 = .text:0x800570B0; // type:function size:0x4 -fn_800570C0 = .text:0x800570C0; // type:function size:0x40 -fn_80057100 = .text:0x80057100; // type:function size:0xA8 -fn_800571B0 = .text:0x800571B0; // type:function size:0xC -fn_800571C0 = .text:0x800571C0; // type:function size:0xD4 -fn_800572A0 = .text:0x800572A0; // type:function size:0xC8 -init__Q34dPad4ex_c8motion_cFv = .text:0x80057370; // type:function size:0x30C -fn_80057680 = .text:0x80057680; // type:function size:0x4C -fn_800576D0 = .text:0x800576D0; // type:function size:0x210 -fn_800578E0 = .text:0x800578E0; // type:function size:0x1E0 -fn_80057AC0 = .text:0x80057AC0; // type:function size:0x440 -fn_80057F00 = .text:0x80057F00; // type:function size:0x24 -fn_80057F30 = .text:0x80057F30; // type:function size:0x24 -fn_80057F60 = .text:0x80057F60; // type:function size:0x24 -fn_80057F90 = .text:0x80057F90; // type:function size:0x12C -fn_800580C0 = .text:0x800580C0; // type:function size:0x12C -fn_800581F0 = .text:0x800581F0; // type:function size:0x12C -fn_80058320 = .text:0x80058320; // type:function size:0x12C -fn_80058450 = .text:0x80058450; // type:function size:0xEC -fn_80058540 = .text:0x80058540; // type:function size:0x450 -fn_80058990 = .text:0x80058990; // type:function size:0x60 -fn_800589F0 = .text:0x800589F0; // type:function size:0x8 -fn_80058A00 = .text:0x80058A00; // type:function size:0xD8 -fn_80058AE0 = .text:0x80058AE0; // type:function size:0x70 -fn_80058B50 = .text:0x80058B50; // type:function size:0x6C -fn_80058BC0 = .text:0x80058BC0; // type:function size:0x58 -fn_80058C20 = .text:0x80058C20; // type:function size:0x68 -fn_80058C90 = .text:0x80058C90; // type:function size:0x20 +fn_80056F00__Q24dPad4ex_cFl = .text:0x80056F00; // type:function size:0x24 +fn_80056F30__Q24dPad4ex_cFl = .text:0x80056F30; // type:function size:0xC +fn_80056F40__Q24dPad4ex_cFl = .text:0x80056F40; // type:function size:0xC8 +fn_80057010__Q24dPad4ex_cFl = .text:0x80057010; // type:function size:0x10 +fn_80057020__Q24dPad4ex_cFl = .text:0x80057020; // type:function size:0x80 +fn_800570A0__Q24dPad4ex_cFl = .text:0x800570A0; // type:function size:0x10 +fn_800570B0__Q24dPad4ex_cFl = .text:0x800570B0; // type:function size:0x4 +fn_800570C0__Q24dPad4ex_cFl = .text:0x800570C0; // type:function size:0x40 +fn_80057100__Q24dPad4ex_cFl = .text:0x80057100; // type:function size:0xA8 +fn_800571B0__Q24dPad4ex_cFl = .text:0x800571B0; // type:function size:0xC +fn_800571C0__Q24dPad4ex_cFl = .text:0x800571C0; // type:function size:0xD4 +fn_800572A0__Q24dPad4ex_cFl = .text:0x800572A0; // type:function size:0xC8 +init__Q34dPad4ex_c5acc_cFv = .text:0x80057370; // type:function size:0x30C +getEntryField_0xB40__Q34dPad4ex_c5acc_cFl = .text:0x80057680; // type:function size:0x4C +fn_800576D0__Q34dPad4ex_c5acc_cFl = .text:0x800576D0; // type:function size:0x210 +fn_800578E0__Q34dPad4ex_c5acc_cFl = .text:0x800578E0; // type:function size:0x1E0 +fn_80057AC0__Q34dPad4ex_c5acc_cFlb = .text:0x80057AC0; // type:function size:0x440 +fn_80057F00__Q34dPad4ex_c5acc_cFl = .text:0x80057F00; // type:function size:0x24 +fn_80057F30__Q34dPad4ex_c5acc_cFl = .text:0x80057F30; // type:function size:0x24 +fn_80057F60__Q34dPad4ex_c5acc_cFl = .text:0x80057F60; // type:function size:0x24 +fn_80057F90__Q34dPad4ex_c5acc_cFlb = .text:0x80057F90; // type:function size:0x12C +fn_800580C0__Q34dPad4ex_c5acc_cFlb = .text:0x800580C0; // type:function size:0x12C +fn_800581F0__Q34dPad4ex_c5acc_cFlb = .text:0x800581F0; // type:function size:0x12C +fn_80058320__Q34dPad4ex_c5acc_cFlb = .text:0x80058320; // type:function size:0x12C +fn_80058450__Q34dPad4ex_c5acc_cFlb = .text:0x80058450; // type:function size:0xEC +fn_80058540__Q34dPad4ex_c5acc_cFlb = .text:0x80058540; // type:function size:0x450 +fn_80058990__Q34dPad4ex_c5acc_cFUlb = .text:0x80058990; // type:function size:0x60 +fn_800589F0__Q34dPad4ex_c5acc_cFv = .text:0x800589F0; // type:function size:0x8 +fn_80058A00__Q34dPad4ex_c5acc_cFv = .text:0x80058A00; // type:function size:0xD8 +fn_80058AE0__Q34dPad4ex_c5acc_cFlb = .text:0x80058AE0; // type:function size:0x70 +getMtx__Q34dPad4ex_c6mpls_cCFv = .text:0x80058B50; // type:function size:0x6C +fn_80058BC0__Q24dPad4ex_cFv = .text:0x80058BC0; // type:function size:0x58 +fn_80058C20__Q24dPad4ex_cFv = .text:0x80058C20; // type:function size:0x68 +fn_80058C90__Q24dPad4ex_cFv = .text:0x80058C90; // type:function size:0x20 isLowBattery__Q24dPad4ex_cFv = .text:0x80058CB0; // type:function size:0x2C isOutOfBattery__Q24dPad4ex_cFv = .text:0x80058CE0; // type:function size:0x28 resetInfo__Q24dPad4ex_cFv = .text:0x80058D10; // type:function size:0x3C @@ -2319,36 +2319,36 @@ getInfo__Q24dPad4ex_cFl = .text:0x80058E30; // type:function size:0x64 getBatteryLevel__Q24dPad4ex_cFv = .text:0x80058EA0; // type:function size:0x8 getBatteryLevel__Q24dPad4ex_cFl = .text:0x80058EB0; // type:function size:0x30 setInfo__Q24dPad4ex_cFlPC8WPADInfo = .text:0x80058EE0; // type:function size:0x68 -fn_80058F50 = .text:0x80058F50; // type:function size:0xC -fn_80058F60 = .text:0x80058F60; // type:function size:0x78 -fn_80058FE0 = .text:0x80058FE0; // type:function size:0x8 -fn_80058FF0 = .text:0x80058FF0; // type:function size:0xC -fn_80059000 = .text:0x80059000; // type:function size:0xC -fn_80059010 = .text:0x80059010; // type:function size:0x90 -fn_800590A0 = .text:0x800590A0; // type:function size:0x10 -fn_800590B0 = .text:0x800590B0; // type:function size:0x30 -fn_800590E0 = .text:0x800590E0; // type:function size:0xC -fn_800590F0 = .text:0x800590F0; // type:function size:0x10 -fn_80059100 = .text:0x80059100; // type:function size:0x8 -fn_80059110 = .text:0x80059110; // type:function size:0x100 -fn_80059210 = .text:0x80059210; // type:function size:0x10 -fn_80059220 = .text:0x80059220; // type:function size:0x10 -fn_80059230 = .text:0x80059230; // type:function size:0x10 -fn_80059240 = .text:0x80059240; // type:function size:0x10 +fn_80058F50__Q24dPad4ex_cFv = .text:0x80058F50; // type:function size:0xC +fn_80058F60__Q24dPad4ex_cFv = .text:0x80058F60; // type:function size:0x78 +fn_80058FE0__Q24dPad4ex_cFv = .text:0x80058FE0; // type:function size:0x8 +fn_80058FF0__Q24dPad4ex_cFv = .text:0x80058FF0; // type:function size:0xC +fn_80059000__Q24dPad4ex_cFv = .text:0x80059000; // type:function size:0xC +fn_80059010__Q24dPad4ex_cFv = .text:0x80059010; // type:function size:0x90 +fn_800590A0__Q24dPad4ex_cFv = .text:0x800590A0; // type:function size:0x10 +fn_800590B0__Q24dPad4ex_cFv = .text:0x800590B0; // type:function size:0x30 +fn_800590E0__Q24dPad4ex_cFv = .text:0x800590E0; // type:function size:0xC +fn_800590F0__Q24dPad4ex_cFv = .text:0x800590F0; // type:function size:0x10 +fn_80059100__Q24dPad4ex_cFv = .text:0x80059100; // type:function size:0x8 +fn_80059110__Q24dPad4ex_cFl = .text:0x80059110; // type:function size:0x100 +fn_80059210__Q24dPad4ex_cFv = .text:0x80059210; // type:function size:0x10 +fn_80059220__Q24dPad4ex_cFv = .text:0x80059220; // type:function size:0x10 +fn_80059230__Q24dPad4ex_cFv = .text:0x80059230; // type:function size:0x10 +fn_80059240__Q24dPad4ex_cFv = .text:0x80059240; // type:function size:0x10 on_0x54__Q24dPad4ex_cFl = .text:0x80059250; // type:function size:0x1C on_0x55__Q24dPad4ex_cFl = .text:0x80059270; // type:function size:0x1C on_0x56__Q24dPad4ex_cFl = .text:0x80059290; // type:function size:0x1C on_0x57__Q24dPad4ex_cFl = .text:0x800592B0; // type:function size:0x1C fn_800592D0__Q24dPad4ex_cFl = .text:0x800592D0; // type:function size:0x28 fn_80059300__Q24dPad4ex_cFl = .text:0x80059300; // type:function size:0x2C -fn_80059330 = .text:0x80059330; // type:function size:0x18 -fn_80059350 = .text:0x80059350; // type:function size:0x18 -fn_80059370 = .text:0x80059370; // type:function size:0x18 -fn_80059390 = .text:0x80059390; // type:function size:0x18 +fn_80059330__Q24dPad4ex_cFl = .text:0x80059330; // type:function size:0x18 +fn_80059350__Q24dPad4ex_cFl = .text:0x80059350; // type:function size:0x18 +fn_80059370__Q24dPad4ex_cFl = .text:0x80059370; // type:function size:0x18 +fn_80059390__Q24dPad4ex_cFl = .text:0x80059390; // type:function size:0x18 getUnifiedWpadStatus__Q24dPad4ex_cFl = .text:0x800593B0; // type:function size:0x14 fn_800593D0__Q24dPad4ex_cFv = .text:0x800593D0; // type:function size:0x6C -setNoSleep__4dPadFv = .text:0x80059440; // type:function size:0x8 -setAutoSleepTime__4dPadFv = .text:0x80059450; // type:function size:0x2C +setNoSleep__Q24dPad4ex_cFv = .text:0x80059440; // type:function size:0x8 +setAutoSleepTime__Q24dPad4ex_cFv = .text:0x80059450; // type:function size:0x2C __sinit_\d_pad_cpp = .text:0x80059480; // type:function size:0x58 scope:local __dt__Q24dPad4ex_cFv = .text:0x800594E0; // type:function size:0x118 __arraydtor$5368 = .text:0x80059600; // type:function size:0x1C @@ -11308,7 +11308,7 @@ doDelete__9dCsGame_cFv = .text:0x801BF210; // type:function size:0x84 CsGame__baseUpdate = .text:0x801BF2A0; // type:function size:0x25C fn_801BF500 = .text:0x801BF500; // type:function size:0x14 CsGame__draw = .text:0x801BF520; // type:function size:0xBC -fn_801BF5E0 = .text:0x801BF5E0; // type:function size:0x44 +fn_801BF5E0__9dCsGame_cCFv = .text:0x801BF5E0; // type:function size:0x44 fn_801BF630 = .text:0x801BF630; // type:function size:0x288 setNextCursorType__9dCsGame_cFQ39dCsGame_c15lytItemCursor_c12CursorType_e = .text:0x801BF8C0; // type:function size:0x10 fn_801BF8D0 = .text:0x801BF8D0; // type:function size:0x8 diff --git a/include/d/d_pad.h b/include/d/d_pad.h index f53a81c9..ec992c05 100644 --- a/include/d/d_pad.h +++ b/include/d/d_pad.h @@ -2,7 +2,7 @@ #define D_PAD_H #include "common.h" -#include "egg/core/eggController.h" +#include "m/m_angle.h" #include "m/m_mtx.h" #include "m/m_vec.h" #include "rvl/KPAD/KPAD.h" @@ -11,8 +11,32 @@ namespace dPad { class ex_c { // Complete Made up name - struct motion_c { + struct acc_c { void init(); + f32 getEntryField_0xB40(s32 chan); + void fn_800576D0(s32 chan); + void fn_800578E0(s32 chan); + void fn_80057AC0(s32 chan, bool); + + f32 fn_80057F00(s32 chan); + f32 fn_80057F30(s32 chan); + f32 fn_80057F60(s32 chan); + + bool fn_80057F90(s32 chan, bool); + bool fn_800580C0(s32 chan, bool); + + bool fn_800581F0(s32 chan, bool); + bool fn_80058320(s32 chan, bool); + + bool fn_80058450(s32 chan, bool); + + void fn_80058540(s32 chan, bool); + + void fn_80058990(u32 mask, bool); + + bool fn_800589F0(); + f32 fn_80058A00(); + void fn_80058AE0(s32 chan, bool); /* 0x0000 */ mVec3_c field_0x000[120]; /* 0x05A0 */ mVec3_c field_0x5A0[120]; @@ -29,18 +53,54 @@ class ex_c { /* 0x10D8 */ u32 field_0x10D8; }; + struct mpls_c { + mpls_c() : mX(mVec3_c::Ex), mY(mVec3_c::Ey), mZ(mVec3_c::Ez) {} + mMtx_c getMtx() const; + /* 0x00 */ mVec3_c mX; + /* 0x0C */ mVec3_c mY; + /* 0x18 */ mVec3_c mZ; + }; + public: + ex_c(); + void fn_80055EF0(s32 chan); + void fn_800562B0(s32 chan, mVec3_c &mpls); + void fn_80056330(s32 chan); + void fn_80056580(s32 chan, const mVec2_c &); + void centerCursor(s32 chan, bool); void fn_80056790(s32 chan); + void setField_0x70(mAng ang); + void setField_0x70(); void fn_80056AF0(s32 chan); + + bool checkWPADProbeStable(); void fn_80056B90(s32 chan); void fn_80056CE0(s32 chan); + void fn_80056DA0(s32 chan); // Deals with Mpls Calibration Start void fn_80056DF0(s32 chan); // Deals with Mpls Calibration Work f32 fn_80056E50(); void fn_80056E60(s32 chan); // Deals with Mpls Calibration Stop - void resetState(s32 chan); - void fn_800572A0(s32 chan); + void centerCursor(s32 chan); + + void resetState(s32 chan); + void fn_80056F00(s32 chan); + void fn_80056F30(s32 chan); // Sets State to 1 + void fn_80056F40(s32 chan); + void fn_80057010(s32 chan); // Sets State to 2 (EnableMPLS) + void fn_80057020(s32 chan); + void fn_800570A0(s32 chan); // Sets State to 3 (Disconnect) + void fn_800570B0(s32 chan); // Sets State to 1 + void fn_800570C0(s32 chan); // Sets State to 4 + void fn_80057100(s32 chan); + void fn_800571B0(s32 chan); // Sets State to 5 + void fn_800571C0(s32 chan); + void fn_800572A0(s32 chan); // State Handling + + static bool fn_80058BC0(); + static bool fn_80058C20(); + static void fn_80058C90(); static bool isLowBattery(); static bool isOutOfBattery(); @@ -52,6 +112,23 @@ public: static s32 getBatteryLevel(s32 chan); static void setInfo(s32 chan, const WPADInfo *pInfo); + static f32 fn_80058F50(); + static bool fn_80058F60(); + static f32 fn_80058FE0(); + static void fn_80058FF0(); + static void fn_80059000(); + static void fn_80059010(); + static void fn_800590A0(); + static bool fn_800590B0(); + static bool fn_800590E0(); + static void fn_800590F0(); + static bool fn_80059100(); + static bool fn_80059110(s32 chan); + static void fn_80059210(); + static void fn_80059220(); + static void fn_80059230(); + static void fn_80059240(); + static void on_0x54(s32 chan); static void on_0x55(s32 chan); static void on_0x56(s32 chan); @@ -60,9 +137,16 @@ public: static void fn_800592D0(s32 chan); void fn_80059300(s32 chan); + static bool fn_80059330(s32 chan); + static bool fn_80059350(s32 chan); + static bool fn_80059370(s32 chan); + static bool fn_80059390(s32 chan); void getUnifiedWpadStatus(s32 chan); void fn_800593D0(); + static void setNoSleep(); + static void setAutoSleepTime(); + void updateStatus(s32 chan); static ex_c *getInstance() { @@ -94,11 +178,17 @@ public: /* 0x004E */ bool mIncorrectDeviceType; /* 0x004F */ bool field_0x4F; /* 0x0050 */ bool field_0x50; - /* 0x0051 */ bool field_0x51; + /* 0x0051 */ u8 field_0x51; /* 0x0052 */ bool mMplsEnabled; /* 0x0053 */ bool field_0x53; - /* 0x0054 */ bool field_0x54[4]; - /* 0x0058 */ bool field_0x58[4]; + /* 0x0054 */ bool field_0x54; + /* 0x0055 */ bool field_0x55; + /* 0x0056 */ bool field_0x56; + /* 0x0057 */ bool field_0x57; + /* 0x0058 */ bool field_0x58; + /* 0x0059 */ bool field_0x59; + /* 0x005A */ bool field_0x5A; + /* 0x005B */ bool field_0x5B; /* 0x005C */ mVec2_c field_0x5C; /* 0x0064 */ mVec2_c field_0x64; /* 0x006C */ s32 field_0x6C; @@ -106,17 +196,14 @@ public: /* 0x0074 */ mVec3_c field_0x74; /* 0x0080 */ mVec3_c field_0x80; /* 0x008C */ mVec3_c field_0x8C; - /* 0x0098 */ motion_c mMotion; - /* 0x1174 */ motion_c mFSMotion; - /* 0x2250 */ mVec3_c mMPLSSpeed; - /* 0x225C */ mVec3_c mMPLSBasisX; - /* 0x2268 */ mVec3_c mMPLSBasisY; - /* 0x2274 */ mVec3_c mMPLSBasisZ; + /* 0x0098 */ acc_c mMotion; + /* 0x1174 */ acc_c mFSMotion; + /* 0x2250 */ mVec3_c mMPLSVelocity; + /* 0x225C */ mpls_c mMPLS; /* 0x2280 */ s32 mState; /* 0x2284 */ s32 field_0x2284; /* 0x2288 */ s32 field_0x2288; /* 0x228C */ KPADUnifiedWpadStatus mStatus; - /* 0x22C4 */ u8 _0x22C4[0x22CE - 0x22C4]; /* 0x22CE */ bool field_0x22CE; /* 0x22CF */ bool field_0x22CF; /* 0x22D0 */ u8 field_0x22D0; @@ -140,9 +227,6 @@ void setConnectCallback(); void enableMplsDirRevise(s32 chan); void disableMplsDirRevise(s32 chan); -void setNoSleep(); -void setAutoSleepTime(); - // the next 4 funcs do nothing void fn_80059620(); void fn_80059630(); diff --git a/include/egg/core/eggController.h b/include/egg/core/eggController.h index 16d7e8bd..e8414b13 100644 --- a/include/egg/core/eggController.h +++ b/include/egg/core/eggController.h @@ -127,6 +127,9 @@ public: return *reinterpret_cast(&acc); } + Vector3f getAccelBad() const { + return Vector3f(acc.x, acc.y, acc.z); + } Vector2f getAccelVertical() { return Vector2f(acc_vertical.x, acc_vertical.y); } @@ -212,6 +215,9 @@ public: const Vector3f &getAccel() const { return mCoreStatus[0].getAccel(); } + Vector3f getAccelBad() const { + return mCoreStatus[0].getAccelBad(); + } eCoreDevType getDevType() const { return mCoreStatus[0].getDevType(); @@ -223,6 +229,9 @@ public: bool isFreestyle() const { return mCoreStatus[0].isFreestyle(); } + u32 getHold() const { + return mCoreStatus[0].hold; + } s32 getReadLength() const { return mKPADReadLength; diff --git a/include/rvl/KPAD/KPAD.h b/include/rvl/KPAD/KPAD.h index 6b069111..4cd1ed91 100644 --- a/include/rvl/KPAD/KPAD.h +++ b/include/rvl/KPAD/KPAD.h @@ -76,6 +76,9 @@ typedef struct KPADUnifiedWpadStatus { WPADCLStatus cl; WPADTRStatus tr; WPADBLStatus bl; + struct { + u8 _[0x40]; + } unk; } u; // at 0x0 u8 fmt; // 0x36; u8 padding; // 0x37; @@ -125,6 +128,8 @@ f32 KPADIsEnableMplsDpdRevise(s32 chan); void KPADDisableMplsDpdRevise(s32 chan); void KPADSetMplsDpdReviseParam(s32 chan, f32); +s32 KPADGetMplsStatus(s32 chan); + typedef Vec KPADVec[3]; void KPADSetMplsDirReviseBase(s32 chan, Vec *); diff --git a/src/d/d_pad.cpp b/src/d/d_pad.cpp index 7b822be2..ba658d7c 100644 --- a/src/d/d_pad.cpp +++ b/src/d/d_pad.cpp @@ -9,13 +9,20 @@ #include "d/lyt/d_lyt_control_game.h" #include "d/lyt/meter/d_lyt_meter.h" #include "d/snd/d_snd_player_mgr.h" +#include "d/snd/d_snd_small_effect_mgr.h" +#include "d/snd/d_snd_wzsound.h" #include "egg/core/eggController.h" #include "egg/core/eggHeap.h" +#include "egg/math/eggMath.h" +#include "egg/math/eggVector.h" #include "m/m_angle.h" #include "m/m_mtx.h" #include "m/m_pad.h" #include "m/m_vec.h" +#include "nw4r/math/math_types.h" #include "rvl/KPAD/KPAD.h" +#include "rvl/MTX/mtx.h" +#include "rvl/MTX/mtxvec.h" #include "rvl/MTX/vec.h" #include "rvl/WPAD/WPAD.h" @@ -163,7 +170,7 @@ void beginPad_BR() { kpadvec[2].y = baseZ.y; kpadvec[2].z = baseZ.z; - VECCrossProduct(ex_c::m_ex[0].mMPLSBasisY, baseZ, baseX); + VECCrossProduct(ex_c::m_ex[0].mMPLS.mY, baseZ, baseX); if (VECMag(baseX) > 0.05f) { baseX.normalize(); kpadvec[0].z = baseX.z; @@ -229,15 +236,15 @@ void beginPad_BR() { bool isMpls = mPad::isMpls(0) || mPad::isMplsPtFS(0); if (isMpls) { - ex.mMPLSSpeed.copyFrom(&mPad::getCore(0)->getCoreStatus()->mpls_rot); - ex.mMPLSBasisX.copyFrom(&mPad::getCore(0)->getCoreStatus()->mpls_basis_x); - ex.mMPLSBasisY.copyFrom(&mPad::getCore(0)->getCoreStatus()->mpls_basis_y); - ex.mMPLSBasisZ.copyFrom(&mPad::getCore(0)->getCoreStatus()->mpls_basis_z); + ex.mMPLSVelocity.copyFrom(&mPad::getCore(0)->getCoreStatus()->mpls_rot); + ex.mMPLS.mX.copyFrom(&mPad::getCore(0)->getCoreStatus()->mpls_basis_x); + ex.mMPLS.mY.copyFrom(&mPad::getCore(0)->getCoreStatus()->mpls_basis_y); + ex.mMPLS.mZ.copyFrom(&mPad::getCore(0)->getCoreStatus()->mpls_basis_z); } else { - ex.mMPLSSpeed.set(0.f, 0.f, 0.f); - ex.mMPLSBasisX = mVec3_c::Ex; - ex.mMPLSBasisY = mVec3_c::Ey; - ex.mMPLSBasisZ = mVec3_c::Ez; + ex.mMPLSVelocity.set(0.f, 0.f, 0.f); + ex.mMPLS.mX = mVec3_c::Ex; + ex.mMPLS.mY = mVec3_c::Ey; + ex.mMPLS.mZ = mVec3_c::Ez; } ex.fn_80056790(0); @@ -300,6 +307,173 @@ void disableMplsDirRevise(s32 chan) { KPADDisableMplsDirRevise(chan); } +ex_c::ex_c() + : mDpdPos(0.f, 0.f), + field_0x8(0.f, 0.f), + mFSStick(0.f, 0.f), + mFSStickDistance(0.f), + mFSStickAngle(0), + mWPADProbeResult(0), + mWPADProbeResultStable(0), + mWPADProbeStableTimer(0), + mWPADDeviceType(0), + mWPADDeviceTypeStable(0xFF), + mWPADDeviceTypeStableTimer(0), + field_0x38(0), + field_0x3C(0), + field_0x40(0.f), + field_0x44(false), + field_0x45(false), + field_0x46(false), + field_0x47(false), + field_0x48(0), + mSpeakerSetup(false), + mSpeakerShutdown(false), + mIncorrectDeviceType(true), + field_0x4F(false), + field_0x50(true), + field_0x51(0), + mMplsEnabled(false), + field_0x53(false), + field_0x54(false), + field_0x55(false), + field_0x56(false), + field_0x57(false), + field_0x58(false), + field_0x59(false), + field_0x5A(false), + field_0x5B(false), + field_0x5C(0.f, 0.f), + field_0x64(0.f, 0.f), + field_0x6C(0), + field_0x70(0x1200), + field_0x74(1.f, 0.f, 0.f), + field_0x80(0.f, 1.f, 0.f), + field_0x8C(0.f, 0.f, 1.f), + mState(0), + field_0x2284(0), + field_0x2288(0), + field_0x22CE(0), + field_0x22CF(0), + field_0x22D0(0), + field_0x22D1(0), + field_0x22D4(0), + field_0x22D8(0) { + memset(&mStatus, 0, sizeof(mStatus)); +} + +void ex_c::fn_80055EF0(s32 chan) { + const s32 readLen = mPad::getCore(chan)->getReadLength(); + + // I dont understand this loop - Nonmatching garbage + for (int i = 0; i < readLen; i++) { + mMotion.field_0x000[i] = mMotion.field_0x5A0[i]; + mFSMotion.field_0x000[i] = mFSMotion.field_0x5A0[i]; + } + + for (int i = 0; i < readLen; ++i) { + EGG::CoreStatus status = *mPad::getCore(chan)->getCoreStatus(i); + mMotion.field_0x000[i].copyFrom(&status.acc); + mMotion.field_0xB40[i] = status.acc_value; + } + + mMotion.fn_80058AE0(chan, true); + + for (int i = 0; i < readLen; ++i) { + if (mPad::getCore(chan)->getDevType() == EGG::cDEV_FREESTYLE || + (mPad::isMplsPtFS(chan) && (u8)KPADGetMplsStatus(chan) == 5)) { + EGG::CoreStatus status = *mPad::getCore(chan)->getCoreStatus(i); + mFSMotion.field_0x000[i].copyFrom(&status.acc); + mFSMotion.field_0xB40[i] = status.acc_value; + } else { + mFSMotion.field_0x000[i].set(0.f, 0.f, 0.f); + mFSMotion.field_0xB40[i] = 0.f; + } + } + if (mPad::getCore(chan)->getDevType() == EGG::cDEV_FREESTYLE || + (mPad::isMplsPtFS(chan) && (u8)KPADGetMplsStatus(chan) == 5)) { + mFSMotion.fn_80058AE0(chan, false); + } +} + +void ex_c::fn_800562B0(s32 chan, mVec3_c &mpls) { + if (field_0x53) { + mpls = m_ex[chan].mMPLS.mY; + mpls *= -1.f; + } else { + mpls = m_ex[chan].mMPLS.mZ; + } +} + +void ex_c::fn_80056330(s32 chan) { + f32 mult = nw4r::ut::Clamp(1.f - field_0x8C.y * field_0x8C.y, 0.f, 1.f); + + mVec3_c basis; + if (field_0x53) { + basis = m_ex[chan].mMPLS.mZ; + } else { + basis = m_ex[chan].mMPLS.mY; + } + // ?? + field_0x74 = (mult * (mVec3_c::Ey - basis) + basis).cross(field_0x8C); + + f32 mag = field_0x74.mag(); + bool b = std::abs(mag) <= EGG::Math::epsilon(); + if (b) { + field_0x74 = mVec3_c::Ex; + } else { + field_0x74 *= 1.f / mag; + } + + field_0x80 = field_0x8C.cross(field_0x74); + field_0x80.normalize(); +} + +void ex_c::fn_80056580(s32 chan, const mVec2_c &vec) { + field_0x5C = vec; + field_0x53 = false; + + mMtx_c m; + m.ZXYrotS(-field_0x5C.y * field_0x70, field_0x5C.x * field_0x70, 0); + MTXMultVecSR(m, m_ex[chan].mMPLS.mZ, field_0x8C); + + fn_80056330(chan); +} + +void ex_c::centerCursor(s32 chan, bool b) { + if (field_0x51 != 0 && b) { + return; + } + field_0x64 = field_0x5C; + + // NON-MATCHING + bool tmp = false; + const EGG::Vector3f acc = mPad::getCore()->getAccelBad(); + if (dAcPy_c::GetLink() && dAcPy_c::GetLink()->checkActionFlagsCont(0x2) && acc.z < -0.9f) { + tmp = true; + } + field_0x53 = tmp; + + fn_800562B0(chan, field_0x8C); + fn_80056330(chan); + + if (b) { + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_POINTER_RESET); + field_0x51 = 3; + } else { + field_0x51 = 0; + field_0x5C.set(0.f, 0.f); + mDpdPos.set(0.f, 0.f); + centerPos(mDpdPos, field_0x8); + } +} + +void ex_c::fn_80056790(s32 chan) {} + +void ex_c::setField_0x70(mAng ang) {} + +void ex_c::setField_0x70() {} + void ex_c::fn_80056AF0(s32 chan) { if (mSpeakerSetup) { mSpeakerSetup = false; @@ -320,6 +494,10 @@ void ex_c::fn_80056AF0(s32 chan) { } } +bool ex_c::checkWPADProbeStable() { + return mWPADProbeResultStable == WPAD_ERR_OK; +} + void ex_c::fn_80056B90(s32 chan) { u32 prevType = mWPADDeviceType; WPADResult prevResult = mWPADProbeResult; @@ -389,7 +567,132 @@ void ex_c::fn_80056CE0(s32 chan) { } } -// . . . +void ex_c::fn_80056DA0(s32 chan) {} + +void ex_c::fn_80056DF0(s32 chan) {} + +f32 ex_c::fn_80056E50() {} + +void ex_c::fn_80056E60(s32 chan) {} + +void ex_c::centerCursor(s32 chan) {} + +void ex_c::resetState(s32 chan) {} + +void ex_c::fn_80056F00(s32 chan) {} + +void ex_c::fn_80056F30(s32 chan) { + mState = 1; +} + +void ex_c::fn_80056F40(s32 chan) {} + +void ex_c::fn_80057010(s32 chan) { + mState = 2; + setMpls(true, chan); +} + +void ex_c::fn_80057020(s32 chan) {} + +void ex_c::fn_800570A0(s32 chan) { + mState = 3; + WPADDisconnect(chan); +} + +void ex_c::fn_800570B0(s32 chan) { + fn_80056F30(chan); +} + +void ex_c::fn_800570C0(s32 chan) { + mState = 4; +} + +void ex_c::fn_80057100(s32 chan) {} + +void ex_c::fn_800571B0(s32 chan) { + mState = 5; +} + +void ex_c::fn_800571C0(s32 chan) {} + +void ex_c::fn_800572A0(s32 chan) {} + +void ex_c::acc_c::init() { + for (int i = 0; i < 120; ++i) { + field_0x000[i].set(0.f, 0.f, 0.f); + field_0x5A0[i].set(0.f, 0.f, 0.f); + field_0xB40[i] = 0.f; + } + for (int i = 0; i < 39; ++i) { + field_0xD20[i].set(0.f, 0.f, 0.f); + } + for (int i = 0; i < 33; ++i) { + field_0xEF4[i].set(0.f, 0.f, 0.f); + } + field_0x1080.set(0.f, 0.f, 0.f); + field_0x108C.set(0.f, 0.f, 0.f); + + MTXIdentity(field_0x1098); + field_0x10C8 = 0; + field_0x10CC = 0; + field_0x10D0 = 0; + field_0x10D4 = 0; + field_0x10D8 = 31; +} + +f32 ex_c::acc_c::getEntryField_0xB40(s32 chan) {} + +void ex_c::acc_c::fn_800576D0(s32 chan) {} + +void ex_c::acc_c::fn_800578E0(s32 chan) {} + +void ex_c::acc_c::fn_80057AC0(s32 chan, bool) {} + +f32 ex_c::acc_c::fn_80057F00(s32 chan) { + s32 offs = chan + 3; + return field_0xD20[offs].x - field_0xEF4[chan].x; +} + +f32 ex_c::acc_c::fn_80057F30(s32 chan) { + s32 offs = chan + 3; + return field_0xD20[offs].y - field_0xEF4[chan].y; +} + +f32 ex_c::acc_c::fn_80057F60(s32 chan) { + s32 offs = chan + 3; + return field_0xD20[offs].z - field_0xEF4[chan].z; +} + +bool ex_c::acc_c::fn_80057F90(s32 chan, bool) {} +bool ex_c::acc_c::fn_800580C0(s32 chan, bool) {} + +bool ex_c::acc_c::fn_800581F0(s32 chan, bool) {} +bool ex_c::acc_c::fn_80058320(s32 chan, bool) {} + +bool ex_c::acc_c::fn_80058450(s32 chan, bool) {} + +void ex_c::acc_c::fn_80058540(s32 chan, bool) {} + +void ex_c::acc_c::fn_80058990(u32 mask, bool) {} + +bool ex_c::acc_c::fn_800589F0() {} + +f32 ex_c::acc_c::fn_80058A00() {} + +void ex_c::acc_c::fn_80058AE0(s32 chan, bool) {} + +mMtx_c ex_c::mpls_c::getMtx() const { + mMtx_c m; + m.setBase(0, mX); + m.setBase(1, mY); + m.setBase(2, mZ); + m.setBase(3, mVec3_c::Zero); + return m; +} + +bool ex_c::fn_80058BC0() {} +bool ex_c::fn_80058C20() {} +void ex_c::fn_80058C90() {} bool ex_c::isLowBattery() { return getBatteryLevel() == 1; @@ -467,36 +770,99 @@ void ex_c::setInfo(s32 chan, const WPADInfo *pInfo) { m_info[0][chan].firmware = pInfo->firmware; m_connected[chan] = true; } -// . . . + +f32 ex_c::fn_80058F50() { + return m_current_ex->mMotion.fn_80058A00(); +} + +bool ex_c::fn_80058F60() {} + +f32 ex_c::fn_80058FE0() {} + +void ex_c::fn_80058FF0() {} + +void ex_c::fn_80059000() {} + +void ex_c::fn_80059010() {} + +void ex_c::fn_800590A0() {} + +bool ex_c::fn_800590B0() {} + +bool ex_c::fn_800590E0() {} + +void ex_c::fn_800590F0() {} + +bool ex_c::fn_80059100() { + fn_80059110(mPad::g_currentCoreId); +} + +bool ex_c::fn_80059110(s32 chan) { + return nw4r::math::VEC3LenSq(m_ex[chan].mMPLSVelocity) >= 0.01f || m_ex[chan].mFSStickDistance >= 0.0001f || + mPad::g_core[chan]->getCoreStatus()->getHold() || mPad::g_core[chan]->getCoreStatus()->getTrigger() || + m_ex[chan].mMotion.field_0x10C8 != 0; +} + +void ex_c::fn_80059210() { + m_current_ex->field_0x22CE = 1; +} + +void ex_c::fn_80059220() { + m_current_ex->field_0x22CF = 1; +} + +void ex_c::fn_80059230() { + m_current_ex->field_0x22D0 = 1; +} + +void ex_c::fn_80059240() { + m_current_ex->field_0x22D0 = 0; +} void ex_c::on_0x54(s32 idx) { - m_ex[idx].field_0x54[0] = true; + m_ex[idx].field_0x54 = true; } void ex_c::on_0x55(s32 idx) { - m_ex[idx].field_0x54[1] = true; + m_ex[idx].field_0x55 = true; } void ex_c::on_0x56(s32 idx) { - m_ex[idx].field_0x54[2] = true; + m_ex[idx].field_0x56 = true; } void ex_c::on_0x57(s32 idx) { - m_ex[idx].field_0x54[3] = true; + m_ex[idx].field_0x57 = true; } void ex_c::fn_800592D0(s32 chan) { - m_ex[chan].field_0x54[0] = 0; - m_ex[chan].field_0x54[1] = 0; - m_ex[chan].field_0x54[2] = 0; - m_ex[chan].field_0x54[3] = 0; + m_ex[chan].field_0x54 = false; + m_ex[chan].field_0x55 = false; + m_ex[chan].field_0x56 = false; + m_ex[chan].field_0x57 = false; } void ex_c::fn_80059300(s32 chan) { - field_0x58[0] = field_0x54[0]; - field_0x58[1] = field_0x54[1]; - field_0x58[2] = field_0x54[2]; - field_0x58[3] = field_0x54[3]; + field_0x58 = field_0x54; + field_0x59 = field_0x55; + field_0x5A = field_0x56; + field_0x5B = field_0x57; fn_800592D0(chan); } +bool ex_c::fn_80059330(s32 chan) { + return m_ex[chan].field_0x58; +} + +bool ex_c::fn_80059350(s32 chan) { + return m_ex[chan].field_0x59; +} + +bool ex_c::fn_80059370(s32 chan) { + return m_ex[chan].field_0x5A; +} + +bool ex_c::fn_80059390(s32 chan) { + return m_ex[chan].field_0x5B; +} + void ex_c::getUnifiedWpadStatus(s32 chan) { KPADGetUnifiedWpadStatus(chan, &mStatus, 1); } @@ -516,11 +882,11 @@ void ex_c::fn_800593D0() { } } -void setNoSleep() { +void ex_c::setNoSleep() { WPADSetAutoSleepTime(0); } -void setAutoSleepTime() { +void ex_c::setAutoSleepTime() { WPADSetAutoSleepTime(5); WPADSetControllerLastDataUpdateTime(0); } diff --git a/src/d/d_sc_title.cpp b/src/d/d_sc_title.cpp index 548125aa..a17cd63a 100644 --- a/src/d/d_sc_title.cpp +++ b/src/d/d_sc_title.cpp @@ -90,7 +90,7 @@ int dScTitle_c::create() { if (ret == SUCCEEDED) { dSys::setFrameRate(2); dSys::setClearColor(mColor(0x00000000)); - dPad::setAutoSleepTime(); + dPad::ex_c::setAutoSleepTime(); fn_80058C90(0); SaveRelated::create(); field_0x2AD = 0;