summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorelijah-thomas774 <elijahthomas774@gmail.com>2025-06-15 14:40:59 -0400
committerelijah-thomas774 <elijahthomas774@gmail.com>2025-06-15 14:40:59 -0400
commite4b1c30f472e7a4fdbce657aba7b9b5fb0dd2d59 (patch)
treecd267c29d69e4996ff1d120ebb3613744ca69f1b /include
parent2707f74d70f2783f8e70889f48e95b3ec8c00635 (diff)
Pad stuff
Diffstat (limited to 'include')
-rw-r--r--include/d/a/obj/d_a_obj_boomerang.h46
-rw-r--r--include/d/d_gfx.h93
-rw-r--r--include/d/d_pad.h251
-rw-r--r--include/d/snd/d_snd_player_mgr.h3
-rw-r--r--include/egg/audio/eggAudioRmtSpeakerMgr.h12
-rw-r--r--include/egg/core/eggController.h477
-rw-r--r--include/egg/core/eggSingleton.h55
-rw-r--r--include/egg/prim/eggAssert.h17
-rw-r--r--include/egg/prim/eggBuffer.h134
-rw-r--r--include/m/m_pad.h34
-rw-r--r--include/rvl/KPAD/KPAD.h114
-rw-r--r--include/rvl/MTX/mtx.h30
-rw-r--r--include/rvl/WPAD/WPAD.h33
-rw-r--r--include/toBeSorted/lyt_related_floats.h66
14 files changed, 1024 insertions, 341 deletions
diff --git a/include/d/a/obj/d_a_obj_boomerang.h b/include/d/a/obj/d_a_obj_boomerang.h
index 20dd7c9b..00fa98d0 100644
--- a/include/d/a/obj/d_a_obj_boomerang.h
+++ b/include/d/a/obj/d_a_obj_boomerang.h
@@ -106,24 +106,34 @@ public: // TYPES
RB_FLY_MAX = 2,
};
static const char *sFlyChrAnims[RB_FLY_MAX];
-// Macros until enum is solidified (0x8CC)
-#define FLAG_BOOMERANG_CANCEL (0x3)
-#define FLAG_BOOMERANG_RELEASE_ITEM (0x4)
-#define FLAG_BOOMERANG_0x8 (0x8)
-#define FLAG_BOOMERANG_0x10 (0x10)
-#define FLAG_BOOMERANG_0x20 (0x20)
-#define FLAG_BOOMERANG_0x40 (0x40)
-#define FLAG_BOOMERANG_0x80 (0x80)
-#define FLAG_BOOMERANG_STOP_TIMER_ACTIVE (0x100)
-#define FLAG_BOOMERANG_DROP_ITEM (0x200) // related to 0x400
-#define FLAG_BOOMERANG_REQUEST_0x400 (0x400) // related to 0x200
-#define FLAG_BOOMERANG_REQUEST_MOVE (0x800)
-#define FLAG_BOOMERANG_CONTROLLABLE (0x1000)
-#define FLAG_BOOMERANG_0x2000 (0x2000)
-#define FLAG_BOOMERANG_RUMBLE_ACTIVE (0x4000)
-#define FLAG_BOOMERANG_WING_EFFECT_ACTIVE (0x8000)
-#define FLAG_BOOMERANG_0x10000 (0x10000)
-#define FLAG_BOOMERANG_0x40000 (0x40000)
+
+ enum Flags_e {
+ /* 0x00000001 */ FLAG_CANCEL_1 = 1 << 0,
+ /* 0x00000002 */ FLAG_CANCEL_2 = 1 << 1,
+ /* 0x00000003 */ FLAG_CANCEL = FLAG_CANCEL_1 | FLAG_CANCEL_2,
+
+ /* 0x00000004 */ FLAG_RELEASE_ITEM = 1 << 2,
+ /* 0x00000008 */ FLAG_0x8 = (0x8),
+ /* 0x00000010 */ FLAG_0x10 = (0x10),
+ /* 0x00000020 */ FLAG_0x20 = (0x20),
+ /* 0x00000040 */ FLAG_0x40 = (0x40),
+ /* 0x00000080 */ FLAG_0x80 = (0x80),
+ /* 0x00000100 */ FLAG_STOP_TIMER_ACTIVE = (0x100),
+ /* 0x00000200 */ FLAG_DROP_ITEM = (0x200), // related to 0x400
+ /* 0x00000400 */ FLAG_REQUEST_0x400 = (0x400), // related to 0x200
+ /* 0x00000800 */ FLAG_REQUEST_MOVE = (0x800),
+ /* 0x00001000 */ FLAG_CONTROLLABLE = (0x1000),
+ /* 0x00002000 */ FLAG_0x2000 = (0x2000),
+ /* 0x00004000 */ FLAG_RUMBLE_ACTIVE = (0x4000),
+ /* 0x00008000 */ FLAG_WING_EFFECT_ACTIVE = (0x8000),
+ /* 0x00010000 */ FLAG_0x10000 = (0x10000),
+ /* 0x00020000 */ FLAG_0x20000 = (0x40000),
+ /* 0x00040000 */ FLAG_0x40000 = (0x40000),
+ /* 0x00080000 */ FLAG_0x80000 = (0x80000),
+
+ /* 0x0001A117 */ FLAG_COMMON_INIT = FLAG_0x10000 | FLAG_WING_EFFECT_ACTIVE | FLAG_0x2000 |
+ FLAG_STOP_TIMER_ACTIVE | FLAG_0x10 | FLAG_RELEASE_ITEM | FLAG_CANCEL,
+ };
public: // INLINES
bool checkField_0x8CC(u32 mask) const {
diff --git a/include/d/d_gfx.h b/include/d/d_gfx.h
index 18e63957..4a80203c 100644
--- a/include/d/d_gfx.h
+++ b/include/d/d_gfx.h
@@ -20,9 +20,100 @@ public:
return sInstance;
}
-private:
+public:
+ // clang-format off
+ static s32 getCurrentScreenWidth() { return g_CurrentScreenWidth_s32; }
+ static s32 getCurrentScreenHeight() { return g_CurrentScreenHeight_s32; }
+ static s32 getCurrentScreenWidthLimit() { return g_CurrentScreenWidthLimit_s32; }
+ static s32 getCurrentScreenHeightLimit() { return g_CurrentScreenHeightLimit_s32; }
+ static s32 getCurrentScreenLeft() { return g_CurrentScreenLeft_s32; }
+ static s32 getCurrentScreenRight() { return g_CurrentScreenRight_s32; }
+ static s32 getCurrentScreenTop() { return g_CurrentScreenTop_s32; }
+ static s32 getCurrentScreenBottom() { return g_CurrentScreenBottom_s32; }
+
+ static s32 getEFBHeight() { return g_CurrentEFBHeight_s32; }
+ static s32 getEFBHeightLimit() { return g_CurrentEFBHeightLimit_s32; }
+ static s32 getLetterboxAmount() { return g_CurrentLetterBoxAmount_s32; }
+
+ static f32 getCurrentScreenWidthF() { return g_CurrentScreenWidth_f32; }
+ static f32 getCurrentScreenHeightF() { return g_CurrentScreenHeight_f32; }
+ static f32 getCurrentScreenWidthLimitF() { return g_CurrentScreenWidthLimit_f32; }
+ static f32 getCurrentScreenHeightLimitF() { return g_CurrentScreenHeightLimit_f32; }
+ static f32 getCurrentScreenLeftF() { return g_CurrentScreenLeft_f32; }
+ static f32 getCurrentScreenRightF() { return g_CurrentScreenRight_f32; }
+ static f32 getCurrentScreenTopF() { return g_CurrentScreenTop_f32; }
+ static f32 getCurrentScreenBottomF() { return g_CurrentScreenBottom_f32; }
+
+ static f32 getScreenAspectF() { return g_CurrentScreenAspect; }
+
+ static f32 getEFBHeightF() { return g_CurrentEFBHeight_f32; }
+ static f32 getEFBHeightLimitF() { return g_CurrentEFBHeightLimit_f32; }
+ static f32 getLetterboxAmountF() { return g_CurrentEFBHeightDifference_f32; }
+ static f32 getHeightScaledF() { return g_CurrentHeightScaled_f32; }
+ static f32 getEFBHeightDifferenceF() { return g_CurrentEFBHeightDifference2_f32; }
+
+ static s32 getWidth4x3() { return g_Width4x3_s32; }
+ static s32 getWidth4x3Limit() { return g_Width4x3Limit_s32; }
+ static s32 getWidth16x9() { return g_Width16x9_s32; }
+ static s32 getWidth4x3Left() { return g_Width4x3Left_s32; }
+ static s32 getWidth4x3Right() { return g_Width4x3Right_s32; }
+
+ static f32 getWidth4x3F() { return g_Width4x3_f32; }
+ static f32 getWidth4x3LimitF() { return g_Width4x3Limit_f32; }
+ static f32 getWidth16x9F() { return g_Width16x9_f32; }
+ static f32 getWidth4x3LeftF() { return g_Width4x3Left_f32; }
+ static f32 getWidth4x3RightF() { return g_Width4x3Right_f32; }
+
+ static f32 get16x9to4x3WidthScaleF() { return g_16x9to4x3WidthScale; }
+ // clang-format on
+
+public:
static dGfx_c *sInstance;
+ static s32 g_CurrentScreenWidth_s32;
+ static s32 g_CurrentScreenHeight_s32;
+ static s32 g_CurrentScreenWidthLimit_s32;
+ static s32 g_CurrentScreenHeightLimit_s32;
+ static s32 g_CurrentScreenLeft_s32;
+ static s32 g_CurrentScreenRight_s32;
+ static s32 g_CurrentScreenTop_s32;
+ static s32 g_CurrentScreenBottom_s32;
+
+ static s32 g_CurrentEFBHeight_s32;
+ static s32 g_CurrentEFBHeightLimit_s32;
+ static s32 g_CurrentLetterBoxAmount_s32;
+
+ static f32 g_CurrentScreenWidth_f32;
+ static f32 g_CurrentScreenHeight_f32;
+ static f32 g_CurrentScreenWidthLimit_f32;
+ static f32 g_CurrentScreenHeightLimit_f32;
+ static f32 g_CurrentScreenLeft_f32;
+ static f32 g_CurrentScreenRight_f32;
+ static f32 g_CurrentScreenTop_f32;
+ static f32 g_CurrentScreenBottom_f32;
+
+ static f32 g_CurrentScreenAspect;
+
+ static f32 g_CurrentEFBHeight_f32;
+ static f32 g_CurrentEFBHeightLimit_f32;
+ static f32 g_CurrentEFBHeightDifference_f32;
+ static f32 g_CurrentHeightScaled_f32;
+ static f32 g_CurrentEFBHeightDifference2_f32;
+
+ static s32 g_Width4x3_s32;
+ static s32 g_Width4x3Limit_s32;
+ static s32 g_Width16x9_s32;
+ static s32 g_Width4x3Left_s32;
+ static s32 g_Width4x3Right_s32;
+
+ static f32 g_Width4x3_f32;
+ static f32 g_Width4x3Limit_f32;
+ static f32 g_Width16x9_f32;
+ static f32 g_Width4x3Left_f32;
+ static f32 g_Width4x3Right_f32;
+
+ static f32 g_16x9to4x3WidthScale;
+
/* 0x00 */ u8 _0x00[0x04 - 0x00];
/* 0x04 */ DrawCallback mDrawCallback;
/* 0x08 */ u8 field_0x08;
diff --git a/include/d/d_pad.h b/include/d/d_pad.h
index 53a9955a..7b5f4f0c 100644
--- a/include/d/d_pad.h
+++ b/include/d/d_pad.h
@@ -1,24 +1,241 @@
#ifndef D_PAD_H
#define D_PAD_H
-class dPad {
+#include "common.h"
+#include "egg/core/eggController.h"
+#include "m/m_mtx.h"
+#include "m/m_vec.h"
+#include "rvl/KPAD/KPAD.h"
+#include "rvl/WPAD/WPAD.h"
+
+namespace dPad {
+class ex_c {
+ // Complete Made up name
+ struct motion_c {
+ void init();
+
+ /* 0x0000 */ mVec3_c field_0x000[120];
+ /* 0x05A0 */ mVec3_c field_0x5A0[120];
+ /* 0x0B40 */ f32 field_0xB40[120];
+ /* 0x0D20 */ mVec3_c field_0xD20[39];
+ /* 0x0EF4 */ mVec3_c field_0xEF4[33];
+ /* 0x1080 */ mVec3_c field_0x1080;
+ /* 0x108C */ mVec3_c field_0x108C;
+ /* 0x1098 */ mMtx_c field_0x1098;
+ /* 0x10C8 */ u32 field_0x10C8;
+ /* 0x10CC */ u32 field_0x10CC;
+ /* 0x10D0 */ u32 field_0x10D0;
+ /* 0x10D4 */ f32 field_0x10D4;
+ /* 0x10D8 */ u32 field_0x10D8;
+ };
+
+public:
+ void fn_80056AF0(s32 chan);
+ 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();
+
+ static bool isLowBattery();
+ static bool isOutOfBattery();
+
+ static void resetInfo();
+ static void clearInfo(s32 chan);
+ static s32 getInfo(s32 chan);
+ static s32 getBatteryLevel();
+ static s32 getBatteryLevel(s32 chan);
+ static void setInfo(s32 chan, const WPADInfo *pInfo);
+
+ static void on_0x54(s32 chan);
+ static void on_0x55(s32 chan);
+ static void on_0x56(s32 chan);
+ static void on_0x57(s32 chan);
+
+ static void fn_800592D0(s32 chan);
+
+ void fn_80059300(s32 chan);
+ void getUnifiedWpadStatus(s32 chan);
+ void fn_800593D0();
+
+ static ex_c *getInstance() {
+ return m_current_ex;
+ }
+
public:
- static bool checkButtonAPressed();
- static bool checkButtonBPressed();
- static bool checkButtonZPressed();
- static bool checkButtonCPressed();
- static bool checkButtonMinusPressed();
- static bool checkButtonPlusPressed();
- static bool checkButton1Pressed();
- static bool checkButton2Pressed();
-
- static bool checkButtonDpadUpPressed();
- static bool checkButtonDpadDownPressed();
- static bool checkButtonDpadLeftPressed();
- static bool checkButtonDpadRightPressed();
-
- static bool checkButtonAHeld();
- static bool checkButtonZHeld();
+ /* 0x0000 */ mVec2_c mDpdPos;
+ /* 0x0008 */ mVec2_c field_0x8;
+ /* 0x0010 */ mVec2_c mFSStick;
+ /* 0x0018 */ f32 mFSStickDistance;
+ /* 0x001C */ mAng mFSStickAngle;
+ /* 0x0020 */ WPADResult mWPADProbeResult;
+ /* 0x0024 */ WPADResult mWPADProbeResultStable;
+ /* 0x0028 */ s32 mWPADProbeStableTimer;
+ /* 0x002C */ WPADDeviceType mWPADDeviceType;
+ /* 0x0030 */ u32 mWPADDeviceTypeStable;
+ /* 0x0034 */ s32 mWPADDeviceTypeStableTimer;
+ /* 0x0038 */ s32 field_0x38;
+ /* 0x003C */ s32 field_0x3C;
+ /* 0x0040 */ f32 field_0x40;
+ /* 0x0044 */ bool field_0x44;
+ /* 0x0045 */ bool field_0x45;
+ /* 0x0046 */ bool field_0x46;
+ /* 0x0047 */ bool field_0x47;
+ /* 0x0048 */ bool field_0x48;
+ /* 0x0049 */ bool field_0x49;
+ /* 0x004A */ bool field_0x4A;
+ /* 0x004B */ bool field_0x4B;
+ /* 0x004C */ bool mSpeakerSetup;
+ /* 0x004D */ bool mSpeakerShutdown;
+ /* 0x004E */ bool mIncorrectDeviceType;
+ /* 0x004F */ bool field_0x4F;
+ /* 0x0050 */ bool field_0x50;
+ /* 0x0051 */ bool field_0x51;
+ /* 0x0052 */ bool mMplsEnabled;
+ /* 0x0053 */ bool field_0x53;
+ /* 0x0054 */ bool field_0x54[4];
+ /* 0x0058 */ bool field_0x58[4];
+ /* 0x005C */ mVec2_c field_0x5C;
+ /* 0x0064 */ mVec2_c field_0x64;
+ /* 0x006C */ s32 field_0x6C;
+ /* 0x0070 */ mAng field_0x70;
+ /* 0x0074 */ mVec3_c field_0x74;
+ /* 0x0080 */ mVec3_c field_0x80;
+ /* 0x008C */ mVec3_c field_0x8C;
+ /* 0x0098 */ motion_c mMotion;
+ /* 0x1174 */ motion_c mFSMotion;
+ /* 0x2250 */ u8 _0x2250[0x2268 - 0x2250];
+ /* 0x2268 */ mVec3_c field_0x2268;
+ /* 0x2274 */ mVec3_c field_0x2274;
+ /* 0x2280 */ s32 mState;
+ /* 0x2284 */ s32 field_0x2284;
+ /* 0x2288 */ s32 field_0x2288;
+ /* 0x228C */ KPADUnifiedWpadStatus mStatus;
+ /* 0x22C0 */ u8 _0x22C0[0x22D0 - 0x22C4];
+ /* 0x22D0 */ u8 field_0x22D0;
+ /* 0x22D1 */ u8 field_0x22D1;
+ /* 0x22D4 */ s32 field_0x22D4;
+ /* 0x22D8 */ u8 field_0x22D8;
+
+ static WPADInfo m_info[2][4];
+ static bool m_connected[4];
+ static ex_c m_ex[4];
+ static ex_c *m_current_ex;
};
+void initMpls(s32 chan);
+void create();
+void setMpls(bool enable, s32 chan);
+void beginPad_BR();
+void endPad_BR();
+
+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();
+void fn_80059640();
+void fn_80059650();
+
+bool getDownTrig(u32 btns);
+bool getDownTrigA();
+bool getDownTrigB();
+bool getDownTrigC();
+bool getDownTrigZ();
+bool getDownTrigUp();
+bool getDownTrigDown();
+bool getDownTrigLeft();
+bool getDownTrigRight();
+bool getDownTrig1();
+bool getDownTrig2();
+bool getDownTrigMinus();
+bool getDownTrigPlus();
+
+bool getDown(u32 btns);
+bool getDownAll(u32 btns);
+bool getDownA();
+bool getDownB();
+bool getDownC();
+bool getDownZ();
+bool getDownUp();
+bool getDownDown();
+bool getDownLeft();
+bool getDownRight();
+bool getDown1();
+bool getDown2();
+bool getDownMinus();
+bool getDownPlus();
+
+bool getUpTrig(u32 btns);
+bool getUpTrigA();
+bool getUpTrigB();
+bool getUpTrigC();
+bool getUpTrigZ();
+bool getUpTrigUp();
+bool getUpTrigDown();
+bool getUpTrigLeft();
+bool getUpTrigRight();
+bool getUpTrig1();
+bool getUpTrig2();
+bool getUpTrigMinus();
+bool getUpTrigPlus();
+
+bool getUp(u32 btns);
+bool getUpAll(u32 btns);
+bool getUpA();
+bool getUpB();
+bool getUpC();
+bool getUpZ();
+bool getUpUp();
+bool getUpDown();
+bool getUpLeft();
+bool getUpRight();
+bool getUp1();
+bool getUp2();
+bool getUpMinus();
+bool getUpPlus();
+
+mVec2_c &getDpdPos();
+mVec2_c &getDpdStableMaybe();
+mVec2_c &getFSStick();
+f32 getFSStickX();
+f32 getFSStickY();
+f32 getFSStickDistance();
+mAng getFSStickAngle();
+mVec3_c getAcc();
+
+/** returns m_current_ex->field_0x1160 >> 0 & 1 */
+u32 fn_80059B750();
+
+/** returns m_current_ex->field_0x1160 >> 1 & 1 */
+u32 fn_80059B760();
+
+/** returns m_current_ex->field_0x1160 >> 2 & 1 */
+u32 fn_80059B70();
+
+/** returns m_current_ex->field_0x1160 >> 3 & 1 */
+u32 fn_80059B80();
+
+/** returns m_current_ex->field_0x1160 >> 5 & 1 */
+u32 fn_80059B90();
+
+mVec3_c getFSAcc();
+
+/** returns m_current_ex->field_0x223C >> 4 & 1 */
+u32 fn_80059CC0();
+
+/** returns m_current_ex->field_0x223C >> 5 & 1 */
+u32 fn_80059CD0();
+
+}; // namespace dPad
+
#endif
diff --git a/include/d/snd/d_snd_player_mgr.h b/include/d/snd/d_snd_player_mgr.h
index 7808092d..95886ba8 100644
--- a/include/d/snd/d_snd_player_mgr.h
+++ b/include/d/snd/d_snd_player_mgr.h
@@ -23,6 +23,9 @@ public:
public:
dSndPlayerMgr_c();
+ void setup(s32 channel);
+ void shutdown(s32 channel);
+
void shutdown();
void calc();
diff --git a/include/egg/audio/eggAudioRmtSpeakerMgr.h b/include/egg/audio/eggAudioRmtSpeakerMgr.h
index 80c8df82..9ed9eec3 100644
--- a/include/egg/audio/eggAudioRmtSpeakerMgr.h
+++ b/include/egg/audio/eggAudioRmtSpeakerMgr.h
@@ -2,8 +2,8 @@
#define EGG_AUDIO_REMOTE_SPEAKER_MANAGER_H
#include "common.h"
-#include "rvl/WPAD.h" // IWYU pragma: export
+#include "rvl/WPAD.h" // IWYU pragma: export
namespace EGG {
@@ -19,8 +19,8 @@ class AudioRmtSpeakerMgr {
public:
static void calc();
- static void fn_804B6D80(s32 i, WPADCallback *pCallback);
- static void fn_804B6DE0(s32 i, WPADCallback *pCallback);
+ static void setup(s32 i, WPADCallback *pCallback);
+ static void shutdown(s32 i, WPADCallback *pCallback);
static void connectAllByForce();
static void disconnectAllByForce();
@@ -30,9 +30,9 @@ public:
private:
static void setupCallback(s32, s32);
static void shutdownCallback(s32, s32);
- static void fn_804B6AF0(s32 i, WPADCallback *pCallback, bool);
- static void fn_804B6B80(s32 i, WPADCallback *pCallback);
- static void fn_804B6C00(s32 i, WPADCallback *pCallback);
+ static void add_task(s32 i, WPADCallback *pCallback, bool);
+ static void doSetup(s32 i, WPADCallback *pCallback);
+ static void doShutdown(s32 i, WPADCallback *pCallback);
static void setupCallbackDirect(s32, s32);
static void shutdownCallbackDirect(s32, s32);
static bool sAudioRmtSpeakerConnectCanncelSw;
diff --git a/include/egg/core/eggController.h b/include/egg/core/eggController.h
index e7d21300..c0dd6715 100644
--- a/include/egg/core/eggController.h
+++ b/include/egg/core/eggController.h
@@ -2,107 +2,168 @@
#define EGG_CONTROLLER_H
#include "common.h"
+#include "egg/core/eggSingleton.h"
#include "egg/math/eggMatrix.h"
#include "egg/math/eggVector.h"
#include "egg/prim/eggBitFlag.h"
#include "egg/prim/eggBuffer.h"
+#include "rvl/KPAD/KPAD.h"
+
#include "rvl/KPAD.h" // IWYU pragma: exports
#include "rvl/PAD.h" // IWYU pragma: exports
#include "rvl/WPAD.h" // IWYU pragma: exports
-
namespace EGG {
class ControllerRumbleMgr;
class CoreController;
-// To Be Filled out
enum eCoreDevType {
+ cDEV_CORE = WPAD_DEV_CORE,
+ cDEV_FREESTYLE = WPAD_DEV_FREESTYLE,
+ cDEV_CLASSIC = WPAD_DEV_CLASSIC,
+
+ cDEV_MPLS_PT_FS = WPAD_DEV_MPLS_PT_FS,
+
+ cDEV_FUTURE = WPAD_DEV_FUTURE,
+ cDEV_NOT_SUPPORTED = WPAD_DEV_NOT_SUPPORTED,
+ cDEV_NOT_FOUND = WPAD_DEV_NOT_FOUND,
+ cDEV_NULL = WPAD_DEV_NULL,
+ cDEV_UNKNOWN = WPAD_DEV_UNKNOWN,
+};
+
+enum eCoreButton {
+ cCORE_BUTTON_UP = 1 << 3,
+ cCORE_BUTTON_DOWN = 1 << 2,
+ cCORE_BUTTON_LEFT = 1 << 0,
+ cCORE_BUTTON_RIGHT = 1 << 1,
+
+ cCORE_BUTTON_PLUS = 1 << 4,
+ cCORE_BUTTON_MINUS = 1 << 12,
+
+ cCORE_BUTTON_1 = 1 << 9,
+ cCORE_BUTTON_2 = 1 << 8,
+
+ cCORE_BUTTON_A = 1 << 11,
+ cCORE_BUTTON_B = 1 << 10,
+
+ cCORE_BUTTON_HOME = 1 << 15,
+
+ cCORE_FSSTICK_UP = 1 << 16,
+ cCORE_FSSTICK_DOWN = 1 << 17,
+ cCORE_FSSTICK_LEFT = 1 << 18,
+ cCORE_FSSTICK_RIGHT = 1 << 19,
+
+ cCORE_FSSTICK_BUTTONS = cCORE_FSSTICK_UP | cCORE_FSSTICK_DOWN | cCORE_FSSTICK_LEFT | cCORE_FSSTICK_RIGHT
+};
+
+typedef CoreController *(*CoreControllerFactory)();
+
+struct CoreControllerConnectArg {
+ s32 chan; // at 0x0
+ s32 result; // at 0x4
+};
+
+typedef void (*CoreControllerConnectCallback)(const CoreControllerConnectArg &rArg);
+
+struct CoreControllerExtensionArg {
+ eCoreDevType newDevType; // at 0x0
+ eCoreDevType oldDevType; // at 0x4
+ s32 chan; // at 0x8
+};
+
+class CoreControllerExtensionCallback {
+public:
+ virtual void onConnect(const CoreControllerExtensionArg &rArg); // at 0x8
};
-typedef void (*ConnectCallback)(int args[]);
-typedef class CoreController *(*ControllerFactory)();
+/******************************************************************************
+ *
+ * CoreStatus
+ *
+ ******************************************************************************/
+class CoreStatus : public KPADStatus {
+ friend class CoreController;
-class CoreStatus {
public:
- /* 0x00 */ u32 mHold;
- /* 0x04 */ u32 mTrig;
- /* 0x08 */ u32 mRelease;
- /* 0x0C */ Vector3f mAccel;
- /* 0x18 */ u8 field_0x01[0x20 - 0x18];
- /* 0x20 */ f32 mDpdRawX;
- /* 0x24 */ f32 mDpdRawY;
- /* 0x28 */ u8 field_0x02[0x48 - 0x28];
- /* 0x48 */ f32 mDpdDistance;
- /* 0x4C */ f32 float_0x4C;
- /* 0x50 */ f32 float_0x50;
- /* 0x54 */ f32 float_0x54;
- /* 0x58 */ f32 float_0x58;
- /* 0x5C */ u8 mDevType;
- /* 0x5D */ u8 field_0x5D;
- /* 0x5E */ s8 mDpdValid;
- /* 0x5F */ s8 unknown;
- /* 0x60 */ f32 mFSStickX;
- /* 0x64 */ f32 mFSStickY;
- /* 0x68 */ u8 field_0x03[0x88];
+ CoreStatus() {}
public:
void init();
- u32 getFSStickButton() const;
- f32 getFSStickX() const {
- return mFSStickX;
+
+ u32 getHold() const {
+ return hold;
}
- f32 getFSStickY() const {
- return mFSStickY;
+ u32 getRelease() const {
+ return release;
+ }
+ u32 getTrigger() const {
+ return trig;
}
- bool down(u32 mask) const {
- return (mask & mHold);
+
+ bool down(u32 buttons) const {
+ return buttons & hold;
+ }
+ bool up(u32 buttons) const {
+ return (buttons & hold) != buttons;
}
- bool up(u32 mask) const {
- return (mask & mHold) != mask;
+
+ bool downAll(u32 buttons) const {
+ return (buttons & hold) == buttons;
}
- bool downTrigger(u32 mask) const {
- return (mask & mTrig);
+ bool upAll(u32 buttons) const {
+ return (buttons & hold) == 0;
+ }
+
+ bool downTrigger(u32 buttons) const {
+ return buttons & trig;
}
- bool upTrigger(u32 mask) const {
- return (mask & mRelease);
+ bool upTrigger(u32 buttons) const {
+ return buttons & release;
}
- bool downAll(u32 mask) const {
- return (mask & mHold) == mask;
+
+ const Vector3f &getAccel() const {
+ return *reinterpret_cast<const Vector3f *>(&acc);
}
- bool upAll(u32 mask) const {
- return (mask & mHold) == 0;
+
+ Vector2f getAccelVertical() {
+ return Vector2f(acc_vertical.x, acc_vertical.y);
}
- s32 getDevType() const {
- return mDevType;
+ eCoreDevType getDevType() const {
+ return static_cast<eCoreDevType>(dev_type);
}
+
bool isCore() const {
- return getDevType() == WPAD_DEV_CORE;
+ return getDevType() == cDEV_CORE || isFreestyle();
}
bool isFreestyle() const {
- return getDevType() == WPAD_DEV_FS;
+ return getDevType() == cDEV_FREESTYLE;
}
- u32 getHold() const {
- return mHold;
+ s8 getDPDValidFlag() const {
+ return dpd_valid_fg;
}
- s8 getDpdValidFlag() const {
- return mDpdValid;
- };
-
- Vector2f getUnk() {
- return Vector2f(float_0x54, float_0x58);
+ f32 getFSStickX() const {
+ return ex_status.fs.stick.x;
}
-
- const Vector3f &getAccel() const {
- return mAccel;
+ f32 getFSStickY() const {
+ return ex_status.fs.stick.y;
}
-};
+ u32 getFSStickButton();
+};
+/******************************************************************************
+ *
+ * CoreController
+ *
+ ******************************************************************************/
class CoreController {
+ friend class CoreControllerMgr;
+
public:
+ CoreController();
// vtable 0x0000
/* vt 0x08 */ virtual void setPosParam(f32 f1, f32 f2) {
KPADSetPosParam(mChannelID, f1, f2);
@@ -116,86 +177,145 @@ public:
/* vt 0x14 */ virtual void setAccParam(f32 f1, f32 f2) {
KPADSetAccParam(mChannelID, f1, f2);
}
- /* vt 0x18 */ virtual bool down(u32 mask) const {
- return mCoreStatus[0].down(mask);
+ /* vt 0x18 */ virtual bool down(u32 buttons) const {
+ return mCoreStatus[0].down(buttons);
}
- /* vt 0x1C */ virtual bool up(u32 mask) const {
- return mCoreStatus[0].up(mask);
+ /* vt 0x1C */ virtual bool up(u32 buttons) const {
+ return mCoreStatus[0].up(buttons);
}
- /* vt 0x20 */ virtual bool downTrigger(u32 mask) const {
- return mCoreStatus[0].downTrigger(mask);
+ /* vt 0x20 */ virtual bool downTrigger(u32 buttons) const {
+ return mCoreStatus[0].downTrigger(buttons);
}
- /* vt 0x24 */ virtual bool upTrigger(u32 mask) const {
- return mCoreStatus[0].upTrigger(mask);
+ /* vt 0x24 */ virtual bool upTrigger(u32 buttons) const {
+ return mCoreStatus[0].upTrigger(buttons);
}
- /* vt 0x28 */ virtual bool downAll(u32 mask) const {
- return mCoreStatus[0].downAll(mask);
+ /* vt 0x28 */ virtual bool downAll(u32 buttons) const {
+ return mCoreStatus[0].downAll(buttons);
}
- /* vt 0x2C */ virtual bool upAll(u32 mask) const {
- return mCoreStatus[0].upAll(mask);
+ /* vt 0x2C */ virtual bool upAll(u32 buttons) const {
+ return mCoreStatus[0].upAll(buttons);
}
/* vt 0x30 */ virtual void beginFrame(PADStatus *padStatus);
/* vt 0x34 */ virtual void endFrame();
-public:
- /* 0x004 */ s32 mChannelID;
- /* 0x008 */ u32 mButtonHeld;
- /* 0x00C */ u32 mButtonTriggered;
- /* 0x010 */ u32 mButtonReleased;
- /* 0x014 */ u32 field_0x14;
- /* 0x018 */ CoreStatus mCoreStatus[16];
- /* 0xf18 */ int mReadStatusIdx;
- /* 0xf1c */ TBitFlag<u8> mFlag;
- /* 0xf20 */ Vector3f mAccel;
- /* 0xf2c */ Vector2f mDpdPos;
- /* 0xf34 */ u32 mIdleTime;
- /* 0xf38 */ u32 mMotorPattern;
- /* 0xf3c */ bool mEnableMotor;
- /* 0xf40 */ s32 mMotorFrameDuration;
- /* 0xf44 */ u8 mMotorPatternLength;
- /* 0xf45 */ u8 mMotorPatternPos;
- /* 0xf48 */ ControllerRumbleMgr *mRumbleMgr;
- /* 0xf4c */ Matrix34f mPostureMatrix;
- /* 0xf7c */ Matrix34f mPostureMatrixPrev;
- /* 0xfac */ TBitFlag<u8> mAccelFlags; // May not be TBitFlag?
- /* 0xfb0 */ s32 mMaxAccelFrameTime;
- /* 0xfb4 */ s32 mAccelFrameTime[3];
- /* 0xfc0 */ f32 mMaxAccelDiff;
- /* 0xfc4 */ Vector3f mPrevAccel;
-
-public:
- CoreController();
- void sceneReset();
Vector2f getDpdRawPos();
f32 getDpdDistance();
- s32 getDpdValidFlag(); // Name Assumed. BBA hints at variable
- void startMotor();
- void stopMotor();
- void createRumbleMgr(u8);
- void startPatternRumble(const char *, int, bool);
- void stopRumbleMgr();
- CoreStatus *getCoreStatus(int idx);
- void calc_posture_matrix(Matrix34f &mat, bool);
+ s32 getDpdValidFlag();
f32 getFreeStickX() const;
f32 getFreeStickY() const;
+ s32 getChannelID() const {
+ return mChannelID;
+ }
+
const Vector3f &getAccel() const {
return mCoreStatus[0].getAccel();
}
- // Guess ?
- bool isStable(u8 p1) const {
- return (mAccelFlags.getDirect() & p1) == p1;
+ eCoreDevType getDevType() const {
+ return mCoreStatus[0].getDevType();
+ }
+
+ bool isCore() const {
+ return mCoreStatus[0].isCore();
+ }
+ bool isFreestyle() const {
+ return mCoreStatus[0].isFreestyle();
+ }
+
+ s32 getReadLength() const {
+ return mKPADReadLength;
}
+
+ bool isStable(u8 bits) const {
+ return (mStableFlags & bits) == bits;
+ }
+
+ void setStableFrame(int frame) {
+ mStableFrame = frame;
+ }
+ void setStableMag(f32 mag) {
+ mStableMag = mag;
+ }
+ void sceneReset();
+
+ void startMotor();
+ void stopMotor();
+
+ void createRumbleMgr(u8 overlap_num);
+ void startPatternRumble(const char *pPattern, int frame, bool force);
+ void startPowerFrameRumble(f32 power, int frame, bool force);
+ void stopRumbleMgr();
+
+ bool isConnected() const {
+ return mFlag.onBit(0);
+ }
+
+ CoreStatus *getCoreStatus(int idx);
+ CoreStatus *getCoreStatus() {
+ return mCoreStatus;
+ }
+
+private:
+ enum StableAxis {
+ STABLE_AXIS_X,
+ STABLE_AXIS_Y,
+ STABLE_AXIS_Z,
+
+ STABLE_AXIS_MAX
+ };
+
+ enum StableFlag {
+ STABLE_FLAG_X = 1 << STABLE_AXIS_X,
+ STABLE_FLAG_Y = 1 << STABLE_AXIS_Y,
+ STABLE_FLAG_Z = 1 << STABLE_AXIS_Z,
+
+ STABLE_FLAG_XYZ = STABLE_FLAG_X | STABLE_FLAG_Y | STABLE_FLAG_Z
+ };
+
+private:
+ void calc_posture_matrix(Matrix34f &rPostureMtx, bool checkStable);
+
+private:
+ /* 0x004 */ s32 mChannelID;
+
+ /* 0x008 */ u32 mFSStickHold;
+ /* 0x00C */ u32 mFSStickTrig;
+ /* 0x010 */ u32 mFSStickRelease;
+ /* 0x014 */ u32 field_0x14;
+
+ /* 0x018 */ CoreStatus mCoreStatus[16];
+ /* 0xf18 */ int mKPADReadLength;
+
+ /* 0xf1c */ TBitFlag<u8> mFlag;
+ /* 0xf20 */ Vector3f mAccelPrev;
+ /* 0xf2c */ Vector2f mDpdPosPrev;
+ /* 0xf34 */ u32 mIdleTime;
+
+ /* 0xf38 */ u32 mSimpleRumblePattern;
+ /* 0xf3c */ bool mEnableSimpleRumble;
+ /* 0xf40 */ s32 mSimpleRumbleFrame;
+ /* 0xf44 */ u8 mSimpleRumbleSize;
+ /* 0xf45 */ u8 mSimpleRumbleIndex;
+ /* 0xf48 */ ControllerRumbleMgr *mRumbleMgr;
+
+ /* 0xf4c */ Matrix34f mPostureMatrix;
+ /* 0xf7c */ Matrix34f mPostureMatrixPrev;
+
+ /* 0xfac */ u8 mStableFlags; // May not be TBitFlag?
+ /* 0xfb0 */ s32 mStableFrame;
+ /* 0xfb4 */ s32 mStableTimer[3];
+ /* 0xfc0 */ f32 mStableMag;
+ /* 0xfc4 */ Vector3f mStableAccel;
};
+/******************************************************************************
+ *
+ * CoreControllerMgr
+ *
+ ******************************************************************************/
class CoreControllerMgr {
-public:
- struct T__Disposer : Disposer {
- /* vt 0x08 */ virtual ~T__Disposer();
- static T__Disposer *sStaticDisposer;
- };
- /* 0x0000 */ T__Disposer mDisposer;
+ EGG_SINGLETON_DECL(CoreControllerMgr);
struct UnkField0x10A0 {
virtual void v_08(UNKTYPE *);
@@ -206,81 +326,130 @@ public:
/* vt 0x08 */ virtual void beginFrame();
/* vt 0x0C */ virtual void endFrame();
-public:
- /* 0x0014 */ TBuffer<CoreController *> mControllers;
- /* 0x0020 */ u8 field_0x20[0x10a0 - 0x0020];
- /* 0x10A0 */ UnkField0x10A0 *field_0x10A0;
- /* 0x10A4 */ TBuffer<eCoreDevType> mDevTypes;
- /* 0x10b0 */ u8 field_0x10B0[0x10e0 - 0x10b0];
+ CoreController *getNthController(int index);
-public:
- static CoreControllerMgr *createInstance();
- static void deleteInstance();
- CoreController *getNthController(int);
+ eCoreDevType getDevType(const int i) const {
+ return mDevTypes(i);
+ }
+
+ static void setConnectCallback(CoreControllerConnectCallback cb) {
+ sConnectCallback = cb;
+ }
+
+private:
+ CoreControllerMgr();
static void *allocThunk(size_t size);
static int deleteThunk(void *ptr);
-
static void connectCallback(s32, s32);
- CoreControllerMgr();
-public:
- static CoreControllerMgr *sInstance;
- static CoreController *(*sCoreControllerFactory)();
- static ConnectCallback sConnectCallback;
+private:
+ /* 0x0014 */ TBuffer<CoreController *> mControllers;
+ /* 0x0020 */ u8 field_0x20[0x10a0 - 0x0020];
+ /* 0x10A0 */ UnkField0x10A0 *field_0x10A0;
+ /* 0x10A4 */ TBuffer<eCoreDevType> mDevTypes;
+ /* 0x10b0 */ u8 field_0x10B0[0x10e0 - 0x10b0];
+
+ static CoreControllerFactory sCoreControllerFactory;
+ static CoreControllerConnectCallback sConnectCallback;
static bool sUseBuiltinWpadAllocator;
static s32 sWPADWorkSize;
};
+/******************************************************************************
+ *
+ * NullController
+ *
+ ******************************************************************************/
class NullController : public CoreController {
public:
NullController() {
unk[92] = 0xfe;
}
+
+private:
// idk this has NO effect on anything
u8 unk[0x80674c00 - 0x80674b10];
};
+/******************************************************************************
+ *
+ * ControllerRumbleUnit
+ *
+ ******************************************************************************/
class ControllerRumbleUnit {
+ friend class ControllerRumbleMgr;
+
public:
// 0x00 vtable
- inline ControllerRumbleUnit() : mFlag(0) {
+ ControllerRumbleUnit() : mFlags(0) {
init();
}
/* vt 0x08 */ virtual ~ControllerRumbleUnit() {}
-public:
- /* 0x04 */ const char *mPattern;
- /* 0x08 */ const char *mPatternPos;
- /* 0x0C */ s32 mTimer; // guess
- /* 0x10 */ f32 mRampUp; // guess
- /* 0x14 */ f32 mIntensity; // guess
- /* 0x18 */ TBitFlag<u8> mFlag;
- /* 0x1C */ nw4r::ut::Node mNode;
- /* 0x24 */ u32 field_0x24; // could just be part of the node (List)
-public:
- void init();
- void startPattern(const char *patter, int);
+ void startPattern(const char *pPattern, int frame);
+
f32 calc();
+
+private:
+ enum {
+ BIT_USE_PATTERN,
+ BIT_USE_POWER,
+
+ BIT_POWER_LOOP,
+ BIT_ENABLED,
+ BIT_PATTERN_LOOP,
+ BIT_PATTERN_TIMER,
+ };
+
+private:
+ void init();
+
+ void setFlags(u8 bit) {
+ mFlags.setBit(bit);
+ }
+ void clrFlags(u8 bit) {
+ mFlags.resetBit(bit);
+ }
+ bool tstFlags(u8 bit) {
+ return mFlags.onBit(bit);
+ }
+
+private:
+ /* 0x04 */ const char *mRumblePattern;
+ /* 0x08 */ const char *mRumblePatternPtr;
+ /* 0x0C */ s32 mRumbleFrame;
+ /* 0x10 */ f32 mRumblePower;
+ /* 0x14 */ f32 mRumbleValue;
+ /* 0x18 */ TBitFlag<u8> mFlags;
+ /* 0x1C */ nw4r::ut::Node mNode;
+ /* 0x24 */ u32 field_0x24;
};
+/******************************************************************************
+ *
+ * ControllerRumbleMgr
+ *
+ ******************************************************************************/
class ControllerRumbleMgr {
public:
- // 0x00 vtable
- /* vt 0x08 */ virtual ~ControllerRumbleMgr() {}
+ ControllerRumbleMgr();
+ virtual ~ControllerRumbleMgr() {} // at 0x8
-public:
- /* 0x04 */ nw4r::ut::List mActiveUnitList;
- /* 0x10 */ nw4r::ut::List mInactiveUnitList;
- /* 0x1C */ CoreController *mController;
+ void createUnit(u8 overlap_num, CoreController *pController);
-public:
- ControllerRumbleMgr();
- void createUnit(u8 numUnits, CoreController *controller);
void stop();
void calc();
+
void startPattern(const char *pattern, int, bool);
+
+private:
ControllerRumbleUnit *getUnitFromList(bool bGrabActive);
+
+private:
+ /* 0x04 */ nw4r::ut::List mActiveUnitList;
+ /* 0x10 */ nw4r::ut::List mStoppedUnitList;
+ /* 0x1C */ CoreController *mController;
};
} // namespace EGG
diff --git a/include/egg/core/eggSingleton.h b/include/egg/core/eggSingleton.h
new file mode 100644
index 00000000..a9b4817f
--- /dev/null
+++ b/include/egg/core/eggSingleton.h
@@ -0,0 +1,55 @@
+#ifndef EGG_CORE_SINGLETON_H
+#define EGG_CORE_SINGLETON_H
+
+#include "egg/core/eggDisposer.h"
+#include "egg/prim/eggAssert.h"
+
+/**
+ * @brief Declares functions and data for a disposable singleton class
+ */
+#define EGG_SINGLETON_DECL(T) \
+protected: \
+ class T__Disposer : public EGG::Disposer { \
+ public: \
+ virtual ~T__Disposer(); /* at 0x8 */ \
+ static T__Disposer *sStaticDisposer; \
+ }; \
+ \
+ T__Disposer mDisposer; \
+ \
+public: \
+ static T *createInstance(); \
+ static void deleteInstance(); \
+ \
+ static T *instance() { \
+ return sInstance; \
+ } \
+ \
+protected: \
+ static T *sInstance;
+
+/**
+ * @brief Defines functions and data for a disposable singleton class
+ */
+#define EGG_SINGLETON_IMPL(T) \
+ T::T__Disposer::~T__Disposer() { \
+ T::deleteInstance(); \
+ } \
+ \
+ T *T::createInstance() { \
+ if (sInstance == NULL) { \
+ sInstance = new T(); \
+ } else { \
+ EGG_ASSERT_MSG(false, "Create Singleton Twice (%s) : addr %x\n", #T, sInstance); \
+ } \
+ \
+ return sInstance; \
+ } \
+ \
+ void T::deleteInstance() { \
+ sInstance = NULL; \
+ } \
+ \
+ T *T::sInstance = NULL;
+
+#endif
diff --git a/include/egg/prim/eggAssert.h b/include/egg/prim/eggAssert.h
index 590919df..61afd754 100644
--- a/include/egg/prim/eggAssert.h
+++ b/include/egg/prim/eggAssert.h
@@ -9,8 +9,23 @@ namespace EGG {
// TODO: Fixup funtions
namespace Assert {
-typedef void (*AssertCallback)();
+#if 1
+#define EGG_ASSERT(EXP)
+#define EGG_ASSERT_MSG(EXP, ...)
+#define EGG_PRINT(...)
+#else
+#define EGG_ASSERT(EXP) \
+ if (!(EXP)) \
+ system_halt(__FILE__, __LINE__, #EXP)
+
+#define EGG_ASSERT_MSG(EXP, ...) \
+ if (!(EXP)) \
+ system_halt(__FILE__, __LINE__, __VA_ARGS__)
+#define EGG_PRINT(...) system_print(true, __FILE__, __VA_ARGS__)
+#endif
+
+typedef void (*AssertCallback)();
void wait(u32 time);
void system_vreport(const char *str, va_list list);
void system_report(const char *str, ...);
diff --git a/include/egg/prim/eggBuffer.h b/include/egg/prim/eggBuffer.h
index b9bfa01b..9158bf28 100644
--- a/include/egg/prim/eggBuffer.h
+++ b/include/egg/prim/eggBuffer.h
@@ -4,67 +4,127 @@
#include "common.h"
#include "egg/core/eggHeap.h"
-
namespace EGG {
template <typename T>
class TBuffer {
public:
- // vtable 0x00
- /* vt 0x08 */ virtual ~TBuffer() {
- if (mBuffer != nullptr) {
- delete[] mBuffer;
- mBuffer = nullptr;
+ class iterator {
+ public:
+ iterator(TBuffer *pBuffer, int index) : mBuffer(pBuffer), mIndex(index) {}
+
+ int get_index() const {
+ return mIndex;
}
- }
- /* vt 0x0C */ virtual void allocate(int n, int);
- /* vt 0x10 */ virtual void allocate(int n, Heap *heap, int);
- /* vt 0x14 */ virtual void onAllocate(Heap *) {
- return;
- }
- /* vt 0x18 */ virtual void errRangeOver() {
- return;
- }
-public:
- /* 0x08 */ s32 mSize;
- /* 0x0C */ T *mBuffer;
+ iterator &operator++() {
+ mIndex++;
+ return *this;
+ }
+
+ T &operator*() {
+ return (*mBuffer)(mIndex);
+ }
+
+ friend bool operator==(const iterator &rLhs, const iterator &rRhs) {
+ return rLhs.mBuffer == rRhs.mBuffer && rLhs.mIndex == rRhs.mIndex;
+ }
+ friend bool operator!=(const iterator &rLhs, const iterator &rRhs) {
+ return !(rLhs == rRhs);
+ }
+
+ private:
+ TBuffer *mBuffer; // at 0x0
+ int mIndex; // at 0x4
+ };
public:
- inline TBuffer() : mSize(0), mBuffer(nullptr) {}
+ TBuffer() : mSize(0), mBuffer(NULL) {}
- inline bool isRangeValid(int i) {
- return (i >= 0 && i < mSize);
- }
- inline void checkRange(int i) {
- if (!isRangeValid(i)) {
- errRangeOver();
+ virtual ~TBuffer() {
+ if (mBuffer == NULL) {
+ return;
}
+
+ delete[] mBuffer;
+ mBuffer = NULL;
+ } // at 0x8
+
+ virtual void allocate(int size, int align = 0); // at 0xC
+
+ virtual void allocate(int size, Heap *pHeap, int align = 0); // at 0x10
+
+ virtual void onAllocate(Heap * /* pHeap */) {} // at 0x14
+ virtual void errRangeOver() const {} // at 0x18
+
+ T &operator()(int i) {
+ checkRange(i);
+ return mBuffer[i];
}
- inline T &operator()(int i) {
+ const T &operator()(int i) const {
checkRange(i);
return mBuffer[i];
}
- inline s32 getSize() {
+
+ T &get(int i) {
+ checkRange(i);
+ return mBuffer[i];
+ }
+ const T &get(int i) const {
+ checkRange(i);
+ return mBuffer[i];
+ }
+
+ int getSize() const {
return mSize;
}
+ int size() const {
+ return mSize;
+ }
+
+ iterator begin() {
+ return iterator(this, 0);
+ }
+ iterator end() {
+ return iterator(this, getSize());
+ }
+
+private:
+ void flush() {}
+
+ void checkRange(int i) const {
+ if (!isRangeValid(i)) {
+ errRangeOver();
+ }
+ }
+
+ bool isRangeValid(int i) const {
+ return i >= 0 && i < mSize;
+ }
+
+private:
+ int mSize; // at 0x4
+ T *mBuffer; // at 0x8
};
template <typename T>
-void TBuffer<T>::allocate(int n, int) {
- mSize = n;
- mBuffer = new T[n];
+void TBuffer<T>::allocate(int size, int) {
+ mSize = size;
+ mBuffer = new T[size];
onAllocate(nullptr);
}
-
template <typename T>
-void TBuffer<T>::allocate(int n, Heap *heap, int) {
- mSize = n;
- if (heap == nullptr) {
- heap = Heap::sCurrentHeap;
+void TBuffer<T>::allocate(int size, Heap *pHeap, int) {
+ mSize = size;
+
+ if (pHeap == NULL) {
+ pHeap = Heap::getCurrentHeap();
}
- mBuffer = new (heap, 4) T[mSize];
- onAllocate(heap);
+
+ mBuffer = new (pHeap) T[mSize];
+
+ flush();
+ onAllocate(pHeap);
}
} // namespace EGG
diff --git a/include/m/m_pad.h b/include/m/m_pad.h
index a6dae38e..47fd5d1c 100644
--- a/include/m/m_pad.h
+++ b/include/m/m_pad.h
@@ -10,10 +10,40 @@ extern int g_currentCoreId;
extern EGG::CoreController *g_currentCore;
extern EGG::CoreController *g_core[4];
+enum Button {
+ BUTTON_LEFT = 0x1,
+ BUTTON_RIGHT = 0x2,
+ BUTTON_DOWN = 0x4,
+ BUTTON_UP = 0x8,
+ BUTTON_PLUS = 0x10,
+ BUTTON_2 = 0x100,
+ BUTTON_1 = 0x200,
+ BUTTON_B = 0x400,
+ BUTTON_A = 0x800,
+ BUTTON_MINUS = 0x1000,
+ BUTTON_Z = 0x2000,
+ BUTTON_C = 0x4000,
+};
+
+inline EGG::CoreController *getCore(int i) {
+ return g_core[i];
+}
+inline EGG::CoreController *getCore() {
+ return g_currentCore;
+}
+inline EGG::CoreControllerMgr *getMgr() {
+ return g_padMg;
+}
+inline int getCurrentCoreID() {
+ return g_currentCoreId;
+}
+
+// Defined in dPad, referenced in both mPad and dPad
+extern "C" void async_info_callback(s32 chan, s32 result);
+
void create();
void beginPad();
void endPad();
-
-} // namespace mPad
+}; // namespace mPad
#endif
diff --git a/include/rvl/KPAD/KPAD.h b/include/rvl/KPAD/KPAD.h
index 1efeeb3e..849e7730 100644
--- a/include/rvl/KPAD/KPAD.h
+++ b/include/rvl/KPAD/KPAD.h
@@ -1,27 +1,119 @@
#ifndef REVOSDK_KPAD_H
#define REVOSDK_KPAD_H
-#ifdef __cplusplus
+
#include "common.h"
+#include "rvl/WPAD/WPAD.h"
+
+#include "rvl/MTX.h"
+
+#ifdef __cplusplus
extern "C" {
#endif
-typedef struct {
- // TODO
+#define KPAD_MAX_SAMPLES 16
+
+typedef union KPADEXStatus {
+ struct {
+ Vec2 stick; // at 0x0
+ Vec acc; // at 0x8
+ f32 acc_value; // at 0x14
+ f32 acc_speed; // at 0x18
+ } fs; // at 0x0
+
+ struct {
+ u32 hold; // at 0x0
+ u32 trig; // at 0x4
+ u32 release; // at 0x8
+ Vec2 lstick; // at 0xC
+ Vec2 rstick; // at 0x14
+ f32 ltrigger; // at 0x1C
+ f32 rtrigger; // at 0x20
+ } cl; // at 0x0
+
+ struct {
+ f64 tgc_weight; // at 0x0
+ f64 weight[4]; // at 0x8
+ f64 weight_ave[4]; // at 0x28
+ s32 weight_err; // at 0x48
+ s32 tgc_weight_err; // at 0x4C
+ } bl; // at 0x0
+} KPADEXStatus;
+
+typedef struct KPADStatus {
+ u32 hold; // at 0x0
+ u32 trig; // at 0x4
+ u32 release; // at 0x8
+ Vec acc; // at 0xC
+ f32 acc_value; // at 0x18
+ f32 acc_speed; // at 0x1C
+ Vec2 pos; // at 0x20
+ Vec2 vec; // at 0x28
+ f32 speed; // at 0x30
+ Vec2 horizon; // at 0x34
+ Vec2 hori_vec; // at 0x3C
+ f32 hori_speed; // at 0x44
+ f32 dist; // at 0x48
+ f32 dist_vec; // at 0x4C
+ f32 dist_speed; // at 0x50
+ Vec2 acc_vertical; // at 0x54
+ u8 dev_type; // at 0x5C
+ s8 wpad_err; // at 0x5D
+ s8 dpd_valid_fg; // at 0x5E
+ u8 data_format; // at 0x5F
+ KPADEXStatus ex_status; // at 0x60
+ u8 _0xB0[0xF0 - 0xB0]; // at 0xB0
} KPADStatus;
+typedef struct KPADUnifiedWpadStatus {
+ union {
+ WPADStatus core;
+ WPADFSStatus fs;
+ WPADCLStatus cl;
+ WPADTRStatus tr;
+ WPADBLStatus bl;
+ } u; // at 0x0
+ u8 fmt; // 0x36;
+ u8 padding; // 0x37;
+
+} KPADUnifiedWpadStatus;
+
typedef void (*KPADConnectCallback)(s32, s32);
-// TODO: Create Proper Headers
-void KPADInitEx(void * /* UNKTYPE */, u32);
-s32 KPADRead(s32 chan, UNKTYPE *status, s32);
+void KPADSetConnectCallback(u32, KPADConnectCallback);
+
+void KPADSetPosParam(s32 chan, f32 playRadius, f32 sensitivity);
+void KPADSetHoriParam(s32 chan, f32 playRadius, f32 sensitivity);
+void KPADSetDistParam(s32 chan, f32 playRadius, f32 sensitivity);
+void KPADSetAccParam(s32 chan, f32 playRadius, f32 sensitivity);
+
+s32 KPADRead(s32 chan, KPADStatus *pSamples, s32 numSamples);
s32 KPADReadEx(s32 chan, UNKTYPE *status, s32, s32 *);
-void KPADSetConnectCallback(u32, KPADConnectCallback);
+void KPADGetUnifiedWpadStatus(s32 chan, KPADUnifiedWpadStatus *pStatus, int);
+
+void KPADInit(void);
+void KPADInitEx(void * /* UNKTYPE */, u32);
+
+void KPADSetBtnRepeat(s32 chan, f32, f32);
+void KPADSetReviseMode(s32 chan, s32);
+
+void KPADEnableMpls(s32 chan, s32);
+void KPADDisableMpls(s32 chan);
-void KPADSetPosParam(u32, f32, f32);
-void KPADSetHoriParam(u32, f32, f32);
-void KPADSetDistParam(u32, f32, f32);
-void KPADSetAccParam(u32, f32, f32);
+s32 KPADGetMplsWorkSize();
+void KPADSetMplsWorkarea(void *);
+void KPADSetControlMplsCallback(s32 chan, KPADConnectCallback cb);
+void KPADResetMpls(s32 chan);
+void KPADDisableMplsZeroPlay(s32 chan);
+void KPADSetMplsZeroPlayParam(s32 chan, f32);
+void KPADSetMplsZeroDriftMode(s32 chan, s32);
+void KPADEnableMplsDirRevise(s32 chan);
+void KPADDisableMplsDirRevise(s32 chan);
+void KPADSetMplsDirReviseParam(s32 chan, f32);
+void KPADEnableMplsAccRevise(s32 chan);
+void KPADSetMplsAccReviseParam(s32 chan, f32, f32);
+void KPADEnableMplsDpdRevise(s32 chan);
+void KPADSetMplsDpdReviseParam(s32 chan, f32);
#ifdef __cplusplus
}
diff --git a/include/rvl/MTX/mtx.h b/include/rvl/MTX/mtx.h
index 2581d7a3..de5a32f4 100644
--- a/include/rvl/MTX/mtx.h
+++ b/include/rvl/MTX/mtx.h
@@ -20,26 +20,30 @@ typedef struct Vec {
f32 x, y, z;
} Vec;
+typedef struct Vec2 {
+ f32 x, y;
+} Vec2;
+
typedef struct Quaternion {
f32 x, y, z, w;
} Quaternion;
-#define MTXIdentity PSMTXIdentity
-#define MTXCopy PSMTXCopy
-#define MTXConcat PSMTXConcat
-#define MTXInverse PSMTXInverse
-#define MTXTranspose PSMTXTranspose
-#define MTXInverse PSMTXInverse
-#define MTXInvXpose PSMTXInvXpose
-#define MTXRotRad PSMTXRotRad
-#define MTXRotTrig PSMTXRotTrig
+#define MTXIdentity PSMTXIdentity
+#define MTXCopy PSMTXCopy
+#define MTXConcat PSMTXConcat
+#define MTXInverse PSMTXInverse
+#define MTXTranspose PSMTXTranspose
+#define MTXInverse PSMTXInverse
+#define MTXInvXpose PSMTXInvXpose
+#define MTXRotRad PSMTXRotRad
+#define MTXRotTrig PSMTXRotTrig
#define MTXRotAxisRad PSMTXRotAxisRad
-#define MTXTrans PSMTXTrans
+#define MTXTrans PSMTXTrans
#define MTXTransApply PSMTXTransApply
-#define MTXScale PSMTXScale
+#define MTXScale PSMTXScale
#define MTXScaleApply PSMTXScaleApply
-#define MTXQuat PSMTXQuat
-#define MTXReflect PSMTXReflect
+#define MTXQuat PSMTXQuat
+#define MTXReflect PSMTXReflect
void PSMTXIdentity(Mtx);
void PSMTXCopy(const Mtx, Mtx);
diff --git a/include/rvl/WPAD/WPAD.h b/include/rvl/WPAD/WPAD.h
index d62c7d45..c26e7700 100644
--- a/include/rvl/WPAD/WPAD.h
+++ b/include/rvl/WPAD/WPAD.h
@@ -8,7 +8,6 @@
#include "rvl/SC/scsystem.h"
#include "rvl/WPAD/WUD.h"
-
/*******************************************************************************
* macros
*/
@@ -31,13 +30,13 @@ typedef s32 WPADResult;
enum WPADResult_et {
WPAD_ERR_OK = 0,
- WPAD_ERR_NO_CONTROLLER = -1, /* name known from asserts */
- WPAD_ERR_BUSY = -2, // [RT3P54] has this as WPAD_ERR_BUSY
- WPAD_ERR_TRANSFER = -3, // [RT3P54] has this as WPAD_ERR_TRANSFER
- WPAD_ERR_INVALID = -4, /* name comes from [R89JEL] */
- // WPAD_ERR_5 = -5, /* unknown */
- // WPAD_ERR_6 = -6, /* unknown */
- WPAD_ERR_CORRUPTED = -7, /* name comes from [R89JEL] */
+ WPAD_ERR_NO_CONTROLLER = -1, /* name known from asserts */
+ WPAD_ERR_BUSY = -2, // [RT3P54] has this as WPAD_ERR_BUSY
+ WPAD_ERR_TRANSFER = -3, // [RT3P54] has this as WPAD_ERR_TRANSFER
+ WPAD_ERR_INVALID = -4, /* name comes from [R89JEL] */
+ // WPAD_ERR_5 = -5, /* unknown */
+ // WPAD_ERR_6 = -6, /* unknown */
+ WPAD_ERR_CORRUPTED = -7, /* name comes from [R89JEL] */
#define WPAD_ESUCCESS WPAD_ERR_OK
#define WPAD_ENODEV WPAD_ERR_NO_CONTROLLER
@@ -86,7 +85,7 @@ enum WPADChannel_et {
typedef s32 WPADDeviceType;
enum WPADDeviceType_et {
WPAD_DEV_CORE = 0,
- WPAD_DEV_FS = 1,
+ WPAD_DEV_FREESTYLE = 1,
WPAD_DEV_CLASSIC = 2, /* name known from asserts, but not value */
WPAD_DEV_BALANCE_CHECKER = 3,
WPAD_DEV_VSM = 4,
@@ -114,12 +113,11 @@ enum WPADDeviceType_et {
WPAD_DEV_MPLS_PT_UNKNOWN = 250,
- WPAD_DEV_251 = 251,
- WPAD_DEV_252 = 252, // invalid device mode?
- WPAD_DEV_NONE =
- 253, // sort of like WPAD_ENODEV (see __wpadAbortInitExtension in WPADHIDParser.c)
- // WPAD_DEV_254 = 254, /* unknown, doesn't seem to be used anywhere */
- WPAD_DEV_INITIALIZING = 255, // see __a1_20_status_report
+ WPAD_DEV_FUTURE = 251,
+ WPAD_DEV_NOT_SUPPORTED = 252,
+ WPAD_DEV_NOT_FOUND = 253, // sort of like WPAD_ENODEV (see __wpadAbortInitExtension in WPADHIDParser.c)
+ WPAD_DEV_NULL = 254, /* unknown, doesn't seem to be used anywhere */
+ WPAD_DEV_UNKNOWN = 255, // see __a1_20_status_report
};
typedef u32 WPADDataFormat;
@@ -621,6 +619,11 @@ void WPADRecalibrate(WPADChannel chan);
BOOL WPADIsUsedCallbackByKPAD(void);
void WPADSetCallbackByKPAD(BOOL isKPAD);
+void WPADSetAutoSleepTime(int min);
+void WPADSetControllerLastDataUpdateTime(int min);
+
+void WPADSetAcceptConnection(int);
+
#ifdef __cplusplus
}
#endif
diff --git a/include/toBeSorted/lyt_related_floats.h b/include/toBeSorted/lyt_related_floats.h
deleted file mode 100644
index 8496f90d..00000000
--- a/include/toBeSorted/lyt_related_floats.h
+++ /dev/null
@@ -1,66 +0,0 @@
-#ifndef LYT_RELATED_FLOATS_H
-#define LYT_RELATED_FLOATS_H
-
-#include "common.h"
-
-extern "C" f32 lbl_80575144;
-inline f32 get_80575144() {
- return lbl_80575144;
-}
-
-extern "C" f32 lbl_80575148;
-inline f32 get_80575148() {
- return lbl_80575148;
-}
-
-extern "C" f32 lbl_805751A4;
-inline f32 get_805751A4() {
- return lbl_805751A4;
-}
-
-extern "C" s32 lbl_80575134;
-inline s32 get_80575134() {
- return lbl_80575134;
-}
-
-extern "C" s32 lbl_80575118;
-inline s32 get_80575118() {
- return lbl_80575118;
-}
-
-extern "C" s32 lbl_8057511C;
-inline s32 get_8057511C() {
- return lbl_8057511C;
-}
-
-extern "C" f32 lbl_8057514C;
-inline f32 get_8057514C() {
- return lbl_8057514C;
-}
-
-extern "C" f32 lbl_80575150;
-inline f32 get_80575150() {
- return lbl_80575150;
-}
-
-extern "C" f32 lbl_8057515C;
-inline f32 get_8057515C() {
- return lbl_8057515C;
-}
-
-extern "C" f32 lbl_8057519C;
-inline f32 get_8057519C() {
- return lbl_8057519C;
-}
-
-extern "C" f32 lbl_80575190;
-inline f32 get_80575190() {
- return lbl_80575190;
-}
-
-extern "C" s32 lbl_80575184;
-inline s32 get_80575184() {
- return lbl_80575184;
-}
-
-#endif