From e4b1c30f472e7a4fdbce657aba7b9b5fb0dd2d59 Mon Sep 17 00:00:00 2001 From: elijah-thomas774 Date: Sun, 15 Jun 2025 14:40:59 -0400 Subject: [PATCH] Pad stuff --- config/SOUE01/splits.txt | 13 +- config/SOUE01/symbols.txt | 501 +++++++++--------- configure.py | 3 +- include/d/a/obj/d_a_obj_boomerang.h | 46 +- include/d/d_gfx.h | 93 +++- include/d/d_pad.h | 247 ++++++++- include/d/snd/d_snd_player_mgr.h | 3 + include/egg/audio/eggAudioRmtSpeakerMgr.h | 12 +- include/egg/core/eggController.h | 499 +++++++++++------ include/egg/core/eggSingleton.h | 55 ++ include/egg/prim/eggAssert.h | 17 +- include/egg/prim/eggBuffer.h | 136 +++-- include/m/m_pad.h | 34 +- include/rvl/KPAD/KPAD.h | 116 +++- include/rvl/MTX/mtx.h | 30 +- include/rvl/WPAD/WPAD.h | 33 +- include/toBeSorted/lyt_related_floats.h | 66 --- src/d/a/obj/d_a_obj_boomerang.cpp | 67 ++- src/d/d_cursor_hit_check.cpp | 28 +- src/d/d_dvd_drive_error.cpp | 32 +- src/d/d_pad.cpp | 390 ++++++++++++++ src/d/d_pad_ex.cpp | 270 ++++++++++ src/d/d_sc_title.cpp | 4 +- src/d/d_textwindow_unk.cpp | 4 +- src/d/lyt/d_lyt_area_caption.cpp | 20 +- src/d/lyt/d_lyt_battery.cpp | 6 +- src/d/lyt/d_textbox.cpp | 4 +- src/d/lyt/meter/d_lyt_meter_item_select.cpp | 2 +- src/d/lyt/meter/d_lyt_meter_z_btn.cpp | 9 +- src/d/lyt/msg_window/d_lyt_msg_window.cpp | 22 +- .../d_lyt_msg_window_select_btn.cpp | 5 +- .../lyt/msg_window/d_lyt_msg_window_sword.cpp | 5 +- src/d/snd/d_snd_player_mgr.cpp | 15 +- src/egg/audio/eggAudioRmtSpeakerMgr.cpp | 33 +- src/egg/core/eggController.cpp | 208 ++++---- src/egg/util/eggException.cpp | 15 +- src/m/m_pad.cpp | 15 +- src/toBeSorted/attention.cpp | 4 +- src/toBeSorted/d_emitter.cpp | 61 ++- src/toBeSorted/fi_context.cpp | 9 +- 40 files changed, 2258 insertions(+), 874 deletions(-) create mode 100644 include/egg/core/eggSingleton.h delete mode 100644 include/toBeSorted/lyt_related_floats.h create mode 100644 src/d/d_pad.cpp create mode 100644 src/d/d_pad_ex.cpp diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index b8538c4c..5139c7b6 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -233,11 +233,18 @@ d/d_main.cpp: .sbss start:0x805751D0 end:0x805751E0 d/d_pad.cpp: - .text start:0x80055170 end:0x80059CE0 align:16 + .text start:0x80055170 end:0x8005961C align:16 .ctors start:0x804DB684 end:0x804DB688 + .sdata start:0x80571C60 end:0x80571C68 + .sbss start:0x805751E0 end:0x805751E8 + .sdata2 start:0x80576F60 end:0x80577008 + .bss start:0x80597A80 end:0x805A06B0 -d/d_pad_player.cpp: - .text start:0x80059CE0 end:0x8005B6E0 align:16 +d/d_pad_ex.cpp: + .text start:0x80059620 end:0x80059CE0 align:16 + +d/d_pause_manager.cpp: + .text start:0x80059CE0 end:0x8005B6D4 align:16 d/d_player_act.cpp: .text start:0x8005B6E0 end:0x8005CE8C align:16 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 46c3499b..f867165a 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -2243,21 +2243,21 @@ dMain__Create = .text:0x80055000; // type:function size:0x28 dMain__Execute = .text:0x80055030; // type:function size:0x14 dMain__main01 = .text:0x80055050; // type:function size:0x28 main = .text:0x80055080; // type:function size:0xE4 scope:global -fn_80055170 = .text:0x80055170; // type:function size:0x38 -fn_800551B0 = .text:0x800551B0; // type:function size:0x24 -fn_800551E0 = .text:0x800551E0; // type:function size:0x8C -dPad__create = .text:0x80055270; // type:function size:0xBC -fn_80055330 = .text:0x80055330; // type:function size:0x98 -fn_800553D0 = .text:0x800553D0; // type:function size:0x50 -fn_80055420 = .text:0x80055420; // type:function size:0x73C +control_mpls_callback__4dPadFll = .text:0x80055170; // type:function size:0x38 +checkDeviceType__4dPadFUl = .text:0x800551B0; // type:function size:0x24 +initMpls__4dPadFl = .text:0x800551E0; // type:function size:0x8C +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 -errRangeOver__Q23EGG29TBufferFv = .text:0x80055B70; // type:function size:0x4 -mPad__endPad = .text:0x80055B80; // type:function size:0x4 -fn_80055B90 = .text:0x80055B90; // type:function size:0x94 -fn_80055C30 = .text:0x80055C30; // type:function size:0x10 -fn_80055C40 = .text:0x80055C40; // type:function size:0x4 -fn_80055C50 = .text:0x80055C50; // type:function size:0x4 -fn_80055C60 = .text:0x80055C60; // type:function size:0x284 +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 +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 @@ -2266,16 +2266,16 @@ 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_80056AF0 = .text:0x80056AF0; // type:function size:0x90 +fn_80056AF0__Q24dPad4ex_cFl = .text:0x80056AF0; // type:function size:0x90 fn_80056B80 = .text:0x80056B80; // type:function size:0x10 -fn_80056B90 = .text:0x80056B90; // type:function size:0x14C -fn_80056CE0 = .text:0x80056CE0; // type:function size:0xBC +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_80056EF0 = .text:0x80056EF0; // type:function size:0xC +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 @@ -2288,7 +2288,7 @@ 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 -fn_80057370 = .text:0x80057370; // type:function size:0x30C +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 @@ -2310,15 +2310,15 @@ 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 -isLowBattery2 = .text:0x80058CB0; // type:function size:0x2C -isLowBattery1 = .text:0x80058CE0; // type:function size:0x28 -fn_80058D10 = .text:0x80058D10; // type:function size:0x3C -fn_80058D50 = .text:0x80058D50; // type:function size:0x44 -fn_80058DA0 = .text:0x80058DA0; // type:function size:0x84 -fn_80058E30 = .text:0x80058E30; // type:function size:0x64 -getBatteryStatus = .text:0x80058EA0; // type:function size:0x8 -fn_80058EB0 = .text:0x80058EB0; // type:function size:0x30 -fn_80058EE0 = .text:0x80058EE0; // type:function size:0x68 +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 +clearInfo__Q24dPad4ex_cFl = .text:0x80058D50; // type:function size:0x44 +async_info_callback = .text:0x80058DA0; // type:function size:0x84 +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 @@ -2335,78 +2335,78 @@ 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_80059250 = .text:0x80059250; // type:function size:0x1C -fn_80059270 = .text:0x80059270; // type:function size:0x1C -fn_80059290 = .text:0x80059290; // type:function size:0x1C -fn_800592B0 = .text:0x800592B0; // type:function size:0x1C -fn_800592D0 = .text:0x800592D0; // type:function size:0x28 -fn_80059300 = .text:0x80059300; // type:function size:0x2C +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_800593B0 = .text:0x800593B0; // type:function size:0x14 -fn_800593D0 = .text:0x800593D0; // type:function size:0x6C -fn_80059440 = .text:0x80059440; // type:function size:0x8 -fn_80059450 = .text:0x80059450; // type:function size:0x2C -dPad__sinit = .text:0x80059480; // type:function size:0x58 -fn_800594E0 = .text:0x800594E0; // type:function size:0x118 -fn_80059600 = .text:0x80059600; // type:function size:0x1C -fn_80059620 = .text:0x80059620; // type:function size:0x4 -fn_80059630 = .text:0x80059630; // type:function size:0x4 -fn_80059640 = .text:0x80059640; // type:function size:0x4 -fn_80059650 = .text:0x80059650; // type:function size:0x4 -checkInputManagerPressedMask = .text:0x80059660; // type:function size:0x18 -checkButtonAPressed__4dPadFv = .text:0x80059680; // type:function size:0x18 -checkButtonBPressed__4dPadFv = .text:0x800596A0; // type:function size:0x18 -checkButtonCPressed__4dPadFv = .text:0x800596C0; // type:function size:0x18 -checkButtonZPressed__4dPadFv = .text:0x800596E0; // type:function size:0x18 -checkButtonDpadUpPressed__4dPadFv = .text:0x80059700; // type:function size:0x18 -checkButtonDpadDownPressed__4dPadFv = .text:0x80059720; // type:function size:0x18 -checkButtonDpadLeftPressed__4dPadFv = .text:0x80059740; // type:function size:0x18 -checkButtonDpadRightPressed__4dPadFv = .text:0x80059760; // type:function size:0x18 -checkButton1Pressed__4dPadFv = .text:0x80059780; // type:function size:0x18 -checkButton2Pressed__4dPadFv = .text:0x800597A0; // type:function size:0x18 -checkButtonMinusPressed__4dPadFv = .text:0x800597C0; // type:function size:0x18 -checkButtonPlusPressed__4dPadFv = .text:0x800597E0; // type:function size:0x18 -checkInputManagerHeldMask = .text:0x80059800; // 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 +__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 +fn_80059620__4dPadFv = .text:0x80059620; // type:function size:0x4 +fn_80059630__4dPadFv = .text:0x80059630; // type:function size:0x4 +fn_80059640__4dPadFv = .text:0x80059640; // type:function size:0x4 +fn_80059650__4dPadFv = .text:0x80059650; // type:function size:0x4 +getDownTrig__4dPadFUl = .text:0x80059660; // type:function size:0x18 +getDownTrigA__4dPadFv = .text:0x80059680; // type:function size:0x18 +getDownTrigB__4dPadFv = .text:0x800596A0; // type:function size:0x18 +getDownTrigC__4dPadFv = .text:0x800596C0; // type:function size:0x18 +getDownTrigZ__4dPadFv = .text:0x800596E0; // type:function size:0x18 +getDownTrigUp__4dPadFv = .text:0x80059700; // type:function size:0x18 +getDownTrigDown__4dPadFv = .text:0x80059720; // type:function size:0x18 +getDownTrigLeft__4dPadFv = .text:0x80059740; // type:function size:0x18 +getDownTrigRight__4dPadFv = .text:0x80059760; // type:function size:0x18 +getDownTrig1__4dPadFv = .text:0x80059780; // type:function size:0x18 +getDownTrig2__4dPadFv = .text:0x800597A0; // type:function size:0x18 +getDownTrigMinus__4dPadFv = .text:0x800597C0; // type:function size:0x18 +getDownTrigPlus__4dPadFv = .text:0x800597E0; // type:function size:0x18 +getDown__4dPadFUl = .text:0x80059800; // type:function size:0x18 down__Q23EGG14CoreControllerCFUl = .text:0x80059820; // type:function size:0x18 downAll__Q23EGG14CoreControllerCFUl = .text:0x80059840; // type:function size:0x18 -checkButtonAHeld__4dPadFv = .text:0x80059860; // type:function size:0x18 -checkButtonBHeld = .text:0x80059880; // type:function size:0x18 -checkButtonCHeld = .text:0x800598A0; // type:function size:0x18 -checkButtonZHeld__4dPadFv = .text:0x800598C0; // type:function size:0x18 -checkButtonDpadUpHeld = .text:0x800598E0; // type:function size:0x18 -checkButtonDpadDownHeld = .text:0x80059900; // type:function size:0x18 -checkButtonDpadLeftHeld = .text:0x80059920; // type:function size:0x18 -checkButtonDpadRightHeld = .text:0x80059940; // type:function size:0x18 -checkButton1Held = .text:0x80059960; // type:function size:0x18 -checkButton2Held = .text:0x80059980; // type:function size:0x18 -checkButtonMinusHeld = .text:0x800599A0; // type:function size:0x18 -checkButtonPlusHeld = .text:0x800599C0; // type:function size:0x18 +getDownA__4dPadFv = .text:0x80059860; // type:function size:0x18 +getDownB__4dPadFv = .text:0x80059880; // type:function size:0x18 +getDownC__4dPadFv = .text:0x800598A0; // type:function size:0x18 +getDownZ__4dPadFv = .text:0x800598C0; // type:function size:0x18 +getDownUp__4dPadFv = .text:0x800598E0; // type:function size:0x18 +getDownDown__4dPadFv = .text:0x80059900; // type:function size:0x18 +getDownLeft__4dPadFv = .text:0x80059920; // type:function size:0x18 +getDownRight__4dPadFv = .text:0x80059940; // type:function size:0x18 +getDown1__4dPadFv = .text:0x80059960; // type:function size:0x18 +getDown2__4dPadFv = .text:0x80059980; // type:function size:0x18 +getDownMinus__4dPadFv = .text:0x800599A0; // type:function size:0x18 +getDownPlus__4dPadFv = .text:0x800599C0; // type:function size:0x18 upTrigger__Q23EGG14CoreControllerCFUl = .text:0x800599E0; // type:function size:0x18 -checkButtonAReleased = .text:0x80059A00; // type:function size:0x18 -buttonBReleased = .text:0x80059A20; // type:function size:0x18 -checkButtonZReleased = .text:0x80059A40; // type:function size:0x18 +getUpTrigA__4dPadFv = .text:0x80059A00; // type:function size:0x18 +getUpTrigB__4dPadFv = .text:0x80059A20; // type:function size:0x18 +getUpTrigZ__4dPadFv = .text:0x80059A40; // type:function size:0x18 up__Q23EGG14CoreControllerCFUl = .text:0x80059A60; // type:function size:0x1C upAll__Q23EGG14CoreControllerCFUl = .text:0x80059A80; // type:function size:0x14 -checkButtonAHeldReleased = .text:0x80059AA0; // type:function size:0x18 -fn_80059AC0 = .text:0x80059AC0; // type:function size:0x8 -fn_80059AD0 = .text:0x80059AD0; // type:function size:0xC -fn_80059AE0 = .text:0x80059AE0; // type:function size:0xC -fn_80059AF0 = .text:0x80059AF0; // type:function size:0xC -fn_80059B00 = .text:0x80059B00; // type:function size:0xC -fn_80059B10 = .text:0x80059B10; // type:function size:0xC -fn_80059B20 = .text:0x80059B20; // type:function size:0x10 -fn_80059B30 = .text:0x80059B30; // type:function size:0x20 -fn_80059B50 = .text:0x80059B50; // type:function size:0x10 -fn_80059B60 = .text:0x80059B60; // type:function size:0x10 -fn_80059B70 = .text:0x80059B70; // type:function size:0x10 -fn_80059B80 = .text:0x80059B80; // type:function size:0x10 -fn_80059B90 = .text:0x80059B90; // type:function size:0x10 -fn_80059BA0 = .text:0x80059BA0; // type:function size:0x120 -fn_80059CC0 = .text:0x80059CC0; // type:function size:0x10 -fn_80059CD0 = .text:0x80059CD0; // type:function size:0x10 +getUpA__4dPadFv = .text:0x80059AA0; // type:function size:0x18 +getDpdPos__4dPadFv = .text:0x80059AC0; // type:function size:0x8 +getDpdStableMaybe__4dPadFv = .text:0x80059AD0; // type:function size:0xC +getFSStick__4dPadFv = .text:0x80059AE0; // type:function size:0xC +getFSStickX__4dPadFv = .text:0x80059AF0; // type:function size:0xC +getFSStickY__4dPadFv = .text:0x80059B00; // type:function size:0xC +getFSStickDistance__4dPadFv = .text:0x80059B10; // type:function size:0xC +getFSStickAngle__4dPadFv = .text:0x80059B20; // type:function size:0x10 +getAcc__4dPadFv = .text:0x80059B30; // type:function size:0x20 +fn_80059B750__4dPadFv = .text:0x80059B50; // type:function size:0x10 +fn_80059B760__4dPadFv = .text:0x80059B60; // type:function size:0x10 +fn_80059B70__4dPadFv = .text:0x80059B70; // type:function size:0x10 +fn_80059B80__4dPadFv = .text:0x80059B80; // type:function size:0x10 +fn_80059B90__4dPadFv = .text:0x80059B90; // type:function size:0x10 +getFSAcc__4dPadFv = .text:0x80059BA0; // type:function size:0x120 +fn_80059CC0__4dPadFv = .text:0x80059CC0; // type:function size:0x10 +fn_80059CD0__4dPadFv = .text:0x80059CD0; // type:function size:0x10 fn_80059CE0 = .text:0x80059CE0; // type:function size:0x2C fn_80059D10 = .text:0x80059D10; // type:function size:0x44 fn_80059D60 = .text:0x80059D60; // type:function size:0x40 @@ -19961,8 +19961,8 @@ fn_8035E790 = .text:0x8035E790; // type:function size:0x84 fn_8035E820 = .text:0x8035E820; // type:function size:0x38 fn_8035E860 = .text:0x8035E860; // type:function size:0x14 fn_8035E880 = .text:0x8035E880; // type:function size:0x14 -fn_8035E8A0 = .text:0x8035E8A0; // type:function size:0xC -fn_8035E8B0 = .text:0x8035E8B0; // type:function size:0xC +setup__15dSndPlayerMgr_cFl = .text:0x8035E8A0; // type:function size:0xC +shutdown__15dSndPlayerMgr_cFl = .text:0x8035E8B0; // type:function size:0xC startSound__15dSndPlayerMgr_cFPQ34nw4r3snd11SoundHandleUlPCQ44nw4r3snd14SoundStartable9StartInfo = .text:0x8035E8C0; // type:function size:0x90 startSound__15dSndPlayerMgr_cFPQ34nw4r3snd11SoundHandlePCcPCQ44nw4r3snd14SoundStartable9StartInfo = .text:0x8035E950; // type:function size:0x6C fn_8035E9C0 = .text:0x8035E9C0; // type:function size:0x80 @@ -22996,8 +22996,8 @@ KPADSetHoriParam = .text:0x803EE3E0; // type:function size:0x1C KPADSetDistParam = .text:0x803EE400; // type:function size:0x1C KPADSetAccParam = .text:0x803EE420; // type:function size:0x1C reset_kpad = .text:0x803EE440; // type:function size:0x1B4 -fn_803EE600 = .text:0x803EE600; // type:function size:0x18 -fn_803EE620 = .text:0x803EE620; // type:function size:0x18 +KPADIsEnableAimingMode = .text:0x803EE600; // type:function size:0x18 +KPADGetSensorHeight = .text:0x803EE620; // type:function size:0x18 calc_button_repeat = .text:0x803EE640; // type:function size:0x1A8 read_kpad_button = .text:0x803EE7F0; // type:function size:0xB4 calc_acc = .text:0x803EE8B0; // type:function size:0xB4 @@ -23013,7 +23013,7 @@ read_kpad_dpd = .text:0x803EFF10; // type:function size:0x4BC clamp_stick_circle = .text:0x803F03D0; // type:function size:0x128 clamp_stick_cross = .text:0x803F0500; // type:function size:0x224 read_kpad_ext = .text:0x803F0730; // type:function size:0x103C -fn_803F1770 = .text:0x803F1770; // type:function size:0xA0 +KPADiMplsSamplingCallback = .text:0x803F1770; // type:function size:0xA0 KPADRead = .text:0x803F1810; // type:function size:0xC KPADReadEx = .text:0x803F1820; // type:function size:0x8 KPADiRead = .text:0x803F1830; // type:function size:0x808 @@ -23023,129 +23023,129 @@ KPADSetConnectCallback = .text:0x803F26B0; // type:function size:0x58 KPADiControlWbcCallback = .text:0x803F2710; // type:function size:0x1C KPADiUpdateTempWbcCallback = .text:0x803F2730; // type:function size:0x2C KPADiControlDpdCallback = .text:0x803F2760; // type:function size:0x94 -fn_803F2800 = .text:0x803F2800; // type:function size:0x2C -fn_803F2830 = .text:0x803F2830; // type:function size:0x28 -fn_803F2860 = .text:0x803F2860; // type:function size:0x4 -fn_803F2870 = .text:0x803F2870; // type:function size:0x50 -fn_803F28C0 = .text:0x803F28C0; // type:function size:0xDC -fn_803F29A0 = .text:0x803F29A0; // type:function size:0x4 -fn_803F29B0 = .text:0x803F29B0; // type:function size:0x10 -fn_803F29C0 = .text:0x803F29C0; // type:function size:0x4 -fn_803F29D0 = .text:0x803F29D0; // type:function size:0x4 -fn_803F29E0 = .text:0x803F29E0; // type:function size:0x4 -fn_803F29F0 = .text:0x803F29F0; // type:function size:0x4 -fn_803F2A00 = .text:0x803F2A00; // type:function size:0x4 -fn_803F2A10 = .text:0x803F2A10; // type:function size:0x4 -fn_803F2A20 = .text:0x803F2A20; // type:function size:0x4 -fn_803F2A30 = .text:0x803F2A30; // type:function size:0x4 -fn_803F2A40 = .text:0x803F2A40; // type:function size:0x4 -fn_803F2A50 = .text:0x803F2A50; // type:function size:0x4 -fn_803F2A60 = .text:0x803F2A60; // type:function size:0x4 -fn_803F2A70 = .text:0x803F2A70; // type:function size:0x4 -fn_803F2A80 = .text:0x803F2A80; // type:function size:0x4 -fn_803F2A90 = .text:0x803F2A90; // type:function size:0x4 -fn_803F2AA0 = .text:0x803F2AA0; // type:function size:0x4 -fn_803F2AB0 = .text:0x803F2AB0; // type:function size:0x4 -fn_803F2AC0 = .text:0x803F2AC0; // type:function size:0x1C -fn_803F2AE0 = .text:0x803F2AE0; // type:function size:0x6C +KPADDisableMpls = .text:0x803F2800; // type:function size:0x2C +KPADEnableMpls = .text:0x803F2830; // type:function size:0x28 +KPADGetMplsStatus = .text:0x803F2860; // type:function size:0x4 +KPADSetControlMplsCallback = .text:0x803F2870; // type:function size:0x50 +KPADiControlMplsCallback = .text:0x803F28C0; // type:function size:0xDC +KPADGetMplsWorkSize = .text:0x803F29A0; // type:function size:0x4 +KPADSetMplsWorkarea = .text:0x803F29B0; // type:function size:0x10 +KPADStartMplsCalibration = .text:0x803F29C0; // type:function size:0x4 +KPADWorkMplsCalibration = .text:0x803F29D0; // type:function size:0x4 +KPADStopMplsCalibration = .text:0x803F29E0; // type:function size:0x4 +KPADEnableMplsDirRevise = .text:0x803F29F0; // type:function size:0x4 +KPADEnableMplsAccRevise = .text:0x803F2A00; // type:function size:0x4 +KPADEnableMplsDpdRevise = .text:0x803F2A10; // type:function size:0x4 +KPADDisableMplsZeroPlay = .text:0x803F2A20; // type:function size:0x4 +KPADDisableMplsDirRevise = .text:0x803F2A30; // type:function size:0x4 +KPADDisableMplsAccRevise = .text:0x803F2A40; // type:function size:0x4 +KPADDisableMplsDpdRevise = .text:0x803F2A50; // type:function size:0x4 +KPADIsEnableMplsDpdRevise = .text:0x803F2A60; // type:function size:0x4 +KPADSetMplsZeroPlayParam = .text:0x803F2A70; // type:function size:0x4 +KPADSetMplsDirReviseParam = .text:0x803F2A80; // type:function size:0x4 +KPADSetMplsAccReviseParam = .text:0x803F2A90; // type:function size:0x4 +KPADSetMplsDpdReviseParam = .text:0x803F2AA0; // type:function size:0x4 +KPADSetMplsDirReviseBase = .text:0x803F2AB0; // type:function size:0x4 +KPADSetMplsZeroDriftMode = .text:0x803F2AC0; // type:function size:0x1C +KPADResetMpls = .text:0x803F2AE0; // type:function size:0x6C KPADiSamplingCallback = .text:0x803F2B50; // type:function size:0x9D0 -fn_803F3520 = .text:0x803F3520; // type:function size:0xE4 -fn_803F3610 = .text:0x803F3610; // type:function size:0x18 -fn_803F3630 = .text:0x803F3630; // type:function size:0x34 -fn_803F3670 = .text:0x803F3670; // type:function size:0x134 -fn_803F37B0 = .text:0x803F37B0; // type:function size:0x214 -fn_803F39D0 = .text:0x803F39D0; // type:function size:0x8 -fn_803F39E0 = .text:0x803F39E0; // type:function size:0x14 -fn_803F3A00 = .text:0x803F3A00; // type:function size:0xC -fn_803F3A10 = .text:0x803F3A10; // type:function size:0x2C0 -fn_803F3CD0 = .text:0x803F3CD0; // type:function size:0x20 -fn_803F3CF0 = .text:0x803F3CF0; // type:function size:0x1C -fn_803F3D10 = .text:0x803F3D10; // type:function size:0x40 -fn_803F3D50 = .text:0x803F3D50; // type:function size:0x40 -fn_803F3D90 = .text:0x803F3D90; // type:function size:0x40 -fn_803F3DD0 = .text:0x803F3DD0; // type:function size:0x20 -fn_803F3DF0 = .text:0x803F3DF0; // type:function size:0x20 -fn_803F3E10 = .text:0x803F3E10; // type:function size:0x1C -fn_803F3E30 = .text:0x803F3E30; // type:function size:0x60 -fn_803F3E90 = .text:0x803F3E90; // type:function size:0x20 -fn_803F3EB0 = .text:0x803F3EB0; // type:function size:0x20 -fn_803F3ED0 = .text:0x803F3ED0; // type:function size:0x28 -fn_803F3F00 = .text:0x803F3F00; // type:function size:0x20 -fn_803F3F20 = .text:0x803F3F20; // type:function size:0x20 -fn_803F3F40 = .text:0x803F3F40; // type:function size:0x38 -fn_803F3F80 = .text:0x803F3F80; // type:function size:0x1C -fn_803F3FA0 = .text:0x803F3FA0; // type:function size:0x11C -fn_803F40C0 = .text:0x803F40C0; // type:function size:0x1B0 -fn_803F4270 = .text:0x803F4270; // type:function size:0x2AC -fn_803F4520 = .text:0x803F4520; // type:function size:0x38C -fn_803F48B0 = .text:0x803F48B0; // type:function size:0x2C0 -fn_803F4B70 = .text:0x803F4B70; // type:function size:0xE8 -fn_803F4C60 = .text:0x803F4C60; // type:function size:0xE8 -fn_803F4D50 = .text:0x803F4D50; // type:function size:0xE8 -fn_803F4E40 = .text:0x803F4E40; // type:function size:0xAC0 -fn_803F5900 = .text:0x803F5900; // type:function size:0x1A0 -fn_803F5AA0 = .text:0x803F5AA0; // type:function size:0x24 -fn_803F5AD0 = .text:0x803F5AD0; // type:function size:0x42C -fn_803F5F00 = .text:0x803F5F00; // type:function size:0x14 -fn_803F5F20 = .text:0x803F5F20; // type:function size:0x64 -fn_803F5F90 = .text:0x803F5F90; // type:function size:0x6C -fn_803F6000 = .text:0x803F6000; // type:function size:0x20 -fn_803F6020 = .text:0x803F6020; // type:function size:0x44 -fn_803F6070 = .text:0x803F6070; // type:function size:0x88 -fn_803F6100 = .text:0x803F6100; // type:function size:0x36C -fn_803F6470 = .text:0x803F6470; // type:function size:0x308 -fn_803F6780 = .text:0x803F6780; // type:function size:0x1B4 -fn_803F6940 = .text:0x803F6940; // type:function size:0xE4 -usb__USB_LOG = .text:0x803F6A30; // type:function size:0xA8 -usb__USB_ERR = .text:0x803F6AE0; // type:function size:0xAC -usb__IUSB_OpenLib = .text:0x803F6B90; // type:function size:0xF8 +KPADGetUnifiedWpadStatus = .text:0x803F3520; // type:function size:0xE4 +KPADSetReviseMode = .text:0x803F3610; // type:function size:0x18 +wpad_callback_func = .text:0x803F3630; // type:function size:0x34 +work_calibration = .text:0x803F3670; // type:function size:0x134 +KMPLSInit = .text:0x803F37B0; // type:function size:0x214 +KMPLSGetLibWorkSize = .text:0x803F39D0; // type:function size:0x8 +KMPLSIsInit = .text:0x803F39E0; // type:function size:0x14 +KMPLSShutdown = .text:0x803F3A00; // type:function size:0xC +KMPLSReset = .text:0x803F3A10; // type:function size:0x2C0 +KMPLSDisableZeroPlay = .text:0x803F3CD0; // type:function size:0x20 +KMPLSSetZeroPlayParam = .text:0x803F3CF0; // type:function size:0x1C +KMPLSSetZeroDriftStandard = .text:0x803F3D10; // type:function size:0x40 +KMPLSSetZeroDriftTight = .text:0x803F3D50; // type:function size:0x40 +KMPLSSetZeroDriftLoose = .text:0x803F3D90; // type:function size:0x40 +KMPLSEnableDirRevise = .text:0x803F3DD0; // type:function size:0x20 +KMPLSDisableDirRevise = .text:0x803F3DF0; // type:function size:0x20 +KMPLSSetDirReviseParam = .text:0x803F3E10; // type:function size:0x1C +KMPLSSetDirReviseBase = .text:0x803F3E30; // type:function size:0x60 +KMPLSEnableAccRevise = .text:0x803F3E90; // type:function size:0x20 +KMPLSDisableAccRevise = .text:0x803F3EB0; // type:function size:0x20 +KMPLSSetAccReviseParam = .text:0x803F3ED0; // type:function size:0x28 +KMPLSEnableDpdRevise = .text:0x803F3F00; // type:function size:0x20 +KMPLSDisableDpdRevise = .text:0x803F3F20; // type:function size:0x20 +KMPLSIsEnableDpdRevise = .text:0x803F3F40; // type:function size:0x38 +KMPLSSetDpdReviseParam = .text:0x803F3F80; // type:function size:0x1C +dpd_revise_scale = .text:0x803F3FA0; // type:function size:0x11C +move_mpls_orient = .text:0x803F40C0; // type:function size:0x1B0 +revise_dir_acc = .text:0x803F4270; // type:function size:0x2AC +revise_dir_dpd = .text:0x803F4520; // type:function size:0x38C +calc_mpls_dir = .text:0x803F48B0; // type:function size:0x2C0 +get_mpls_data_x = .text:0x803F4B70; // type:function size:0xE8 +get_mpls_data_y = .text:0x803F4C60; // type:function size:0xE8 +get_mpls_data_z = .text:0x803F4D50; // type:function size:0xE8 +read_mpls = .text:0x803F4E40; // type:function size:0xAC0 +set_calibration_data = .text:0x803F5900; // type:function size:0x1A0 +KMPLSSetKpadRingBuffer = .text:0x803F5AA0; // type:function size:0x24 +KMPLSRead = .text:0x803F5AD0; // type:function size:0x42C +KMPLSSetSamplingCallback = .text:0x803F5F00; // type:function size:0x14 +KMPLSStartCalibration = .text:0x803F5F20; // type:function size:0x64 +KMPLSWorkCalibration = .text:0x803F5F90; // type:function size:0x6C +KMPLSStopCalibration = .text:0x803F6000; // type:function size:0x20 +__KMPLS_f2i = .text:0x803F6020; // type:function size:0x44 +__KMPLS_normalize_Fxyz = .text:0x803F6070; // type:function size:0x88 +__KMPLS_normalize_directionXYZ = .text:0x803F6100; // type:function size:0x36C +__KMPLS_make_vec_dir = .text:0x803F6470; // type:function size:0x308 +__KMPLS_mult_dir = .text:0x803F6780; // type:function size:0x1B4 +__KMPLS_linear_Direction = .text:0x803F6940; // type:function size:0xE4 +USB_LOG = .text:0x803F6A30; // type:function size:0xA8 +USB_ERR = .text:0x803F6AE0; // type:function size:0xAC +IUSB_OpenLib = .text:0x803F6B90; // type:function size:0xF8 fn_803F6C90 = .text:0x803F6C90; // type:function size:0x8 -fn_803F6CA0 = .text:0x803F6CA0; // type:function size:0x19C -fn_803F6E40 = .text:0x803F6E40; // type:function size:0x144 -fn_803F6F90 = .text:0x803F6F90; // type:function size:0x124 -fn_803F70C0 = .text:0x803F70C0; // type:function size:0x354 -fn_803F7420 = .text:0x803F7420; // type:function size:0x358 -fn_803F7780 = .text:0x803F7780; // type:function size:0x74 -fn_803F7800 = .text:0x803F7800; // type:function size:0xA0 -fn_803F78A0 = .text:0x803F78A0; // type:function size:0xA0 -usb____CtrlMsgInt = .text:0x803F7940; // type:function size:0x5A4 -usb__IUSB_WriteCtrlMsgAsync = .text:0x803F7EF0; // type:function size:0x8C +_intrBlkCtrlIsoCb = .text:0x803F6CA0; // type:function size:0x19C +IUSB_OpenDeviceIds = .text:0x803F6E40; // type:function size:0x144 +IUSB_CloseDeviceAsync = .text:0x803F6F90; // type:function size:0x124 +__LongBlkMsgInt = .text:0x803F70C0; // type:function size:0x354 +__IntrBlkMsgInt = .text:0x803F7420; // type:function size:0x358 +IUSB_ReadIntrMsgAsync = .text:0x803F7780; // type:function size:0x74 +IUSB_ReadBlkMsgAsync = .text:0x803F7800; // type:function size:0xA0 +IUSB_WriteBlkMsgAsync = .text:0x803F78A0; // type:function size:0xA0 +__CtrlMsgInt = .text:0x803F7940; // type:function size:0x5A4 +IUSB_WriteCtrlMsgAsync = .text:0x803F7EF0; // type:function size:0x8C gki_init_free_queue = .text:0x803F7F80; // type:function size:0x220 gki_buffer_init = .text:0x803F81A0; // type:function size:0x2AC -bte__GKI_init_q = .text:0x803F8450; // type:function size:0x14 -bte__GKI_getbuf = .text:0x803F8470; // type:function size:0x1A0 -bte__GKI_getpoolbuf = .text:0x803F8610; // type:function size:0xE8 -bte__GKI_freebuf = .text:0x803F8700; // type:function size:0x170 -bte__GKI_get_buf_size = .text:0x803F8870; // type:function size:0x44 +GKI_init_q = .text:0x803F8450; // type:function size:0x14 +GKI_getbuf = .text:0x803F8470; // type:function size:0x1A0 +GKI_getpoolbuf = .text:0x803F8610; // type:function size:0xE8 +GKI_freebuf = .text:0x803F8700; // type:function size:0x170 +GKI_get_buf_size = .text:0x803F8870; // type:function size:0x44 GKI_send_msg = .text:0x803F88C0; // type:function size:0x1BC GKI_read_mbox = .text:0x803F8A80; // type:function size:0xB0 -bte__GKI_enqueue = .text:0x803F8B30; // type:function size:0x13C -bte__GKI_enqueue_head = .text:0x803F8C70; // type:function size:0x140 -bte__GKI_dequeue = .text:0x803F8DB0; // type:function size:0xA0 -bte__GKI_remove_from_queue = .text:0x803F8E50; // type:function size:0xC4 -fn_803F8F20 = .text:0x803F8F20; // type:function size:0x8 -bte__GKI_getnext = .text:0x803F8F30; // type:function size:0x1C -bte__GKI_queue_is_empty = .text:0x803F8F50; // type:function size:0x10 -bte__GKI_create_pool = .text:0x803F8F60; // type:function size:0x348 +GKI_enqueue = .text:0x803F8B30; // type:function size:0x13C +GKI_enqueue_head = .text:0x803F8C70; // type:function size:0x140 +GKI_dequeue = .text:0x803F8DB0; // type:function size:0xA0 +GKI_remove_from_queue = .text:0x803F8E50; // type:function size:0xC4 +GKI_getfirst = .text:0x803F8F20; // type:function size:0x8 +GKI_getnext = .text:0x803F8F30; // type:function size:0x1C +GKI_queue_is_empty = .text:0x803F8F50; // type:function size:0x10 +GKI_create_pool = .text:0x803F8F60; // type:function size:0x348 GKI_delete_pool = .text:0x803F92B0; // type:function size:0x168 -bte__gki_timers_init = .text:0x803F9420; // type:function size:0xBC -bte__GKI_get_tick_count = .text:0x803F94E0; // type:function size:0x14 +gki_timers_init = .text:0x803F9420; // type:function size:0xBC +GKI_get_tick_count = .text:0x803F94E0; // type:function size:0x14 GKI_start_timer = .text:0x803F9500; // type:function size:0x14C GKI_stop_timer = .text:0x803F9650; // type:function size:0x84 -bte__GKI_init_timer_list = .text:0x803F96E0; // type:function size:0x14 -bte__GKI_update_timer_list = .text:0x803F9700; // type:function size:0x90 -bte__GKI_add_to_timer_list = .text:0x803F9790; // type:function size:0xEC +GKI_init_timer_list = .text:0x803F96E0; // type:function size:0x14 +GKI_update_timer_list = .text:0x803F9700; // type:function size:0x90 +GKI_add_to_timer_list = .text:0x803F9790; // type:function size:0xEC GKI_remove_from_timer_list = .text:0x803F9880; // type:function size:0x124 -bte__GKI_init = .text:0x803F99B0; // type:function size:0x90 -fn_803F9A40 = .text:0x803F9A40; // type:function size:0xA8 +GKI_init = .text:0x803F99B0; // type:function size:0x90 +GKI_shutdown = .text:0x803F9A40; // type:function size:0xA8 GKI_run = .text:0x803F9AF0; // type:function size:0x4 bte__GKI_sched_lock = .text:0x803F9B00; // type:function size:0x4 bte__GKI_sched_unlock = .text:0x803F9B10; // type:function size:0x4 GKI_delay = .text:0x803F9B20; // type:function size:0x4 GKI_send_event = .text:0x803F9B30; // type:function size:0xA4 bte__GKI_get_taskid = .text:0x803F9BE0; // type:function size:0x8 -bte__GKI_enable = .text:0x803F9BF0; // type:function size:0x24 -bte__GKI_disable = .text:0x803F9C20; // type:function size:0x44 +GKI_enable = .text:0x803F9BF0; // type:function size:0x24 +GKI_disable = .text:0x803F9C20; // type:function size:0x44 bte__GKI_exception = .text:0x803F9C70; // type:function size:0x4 GKI_os_malloc = .text:0x803F9C80; // type:function size:0x2C GKI_os_free = .text:0x803F9CB0; // type:function size:0x4 @@ -26311,7 +26311,7 @@ create__Q23EGG12GraphicsFifoFUlPQ23EGG4Heap = .text:0x80498E20; // type:function __dt__Q23EGG12GraphicsFifoFv = .text:0x80498E90; // type:function size:0x98 __ct__Q23EGG12GraphicsFifoFUlPQ23EGG4Heap = .text:0x80498F30; // type:function size:0x60 init__Q23EGG10CoreStatusFv = .text:0x80498F90; // type:function size:0xC -getFSStickButton__Q23EGG10CoreStatusCFv = .text:0x80498FA0; // type:function size:0xAC +getFSStickButton__Q23EGG10CoreStatusFv = .text:0x80498FA0; // type:function size:0xAC __ct__Q23EGG14CoreControllerFv = .text:0x80499050; // type:function size:0x60 sceneReset__Q23EGG14CoreControllerFv = .text:0x804990B0; // type:function size:0xB4 getDpdRawPos__Q23EGG14CoreControllerFv = .text:0x80499170; // type:function size:0x14 @@ -26331,7 +26331,7 @@ __dt__Q33EGG17CoreControllerMgr11T__DisposerFv = .text:0x80499B00; // type:funct createInstance__Q23EGG17CoreControllerMgrFv = .text:0x80499B80; // type:function size:0x48 deleteInstance__Q23EGG17CoreControllerMgrFv = .text:0x80499BD0; // type:function size:0x10 getNthController__Q23EGG17CoreControllerMgrFi = .text:0x80499BE0; // type:function size:0x74 -errRangeOver__Q23EGG32TBufferFv = .text:0x80499C60; // type:function size:0x4 scope:weak +errRangeOver__Q23EGG32TBufferCFv = .text:0x80499C60; // type:function size:0x4 scope:weak alloc__Q23EGG27@unnamed@eggController_cpp@FUl = .text:0x80499C70; // type:function size:0x18 scope:local free__Q23EGG27@unnamed@eggController_cpp@FPv = .text:0x80499C90; // type:function size:0x38 scope:local connectCallback__Q23EGG17CoreControllerMgrFll = .text:0x80499CD0; // type:function size:0x3C @@ -26838,14 +26838,14 @@ detail_SetupSound__Q23EGG21SoundArchivePlayerEGGFPQ34nw4r3snd11SoundHandleUlbPCQ @248@__dt__Q23EGG14SimpleAudioMgrFv = .text:0x804B69C0; // type:function size:0x8 scope:weak setupCallback__Q23EGG18AudioRmtSpeakerMgrFll = .text:0x804B69D0; // type:function size:0x90 shutdownCallback__Q23EGG18AudioRmtSpeakerMgrFll = .text:0x804B6A60; // type:function size:0x8C -fn_804B6AF0__Q23EGG18AudioRmtSpeakerMgrFlPFll_vb = .text:0x804B6AF0; // type:function size:0x84 -fn_804B6B80__Q23EGG18AudioRmtSpeakerMgrFlPFll_v = .text:0x804B6B80; // type:function size:0x7C -fn_804B6C00__Q23EGG18AudioRmtSpeakerMgrFlPFll_v = .text:0x804B6C00; // type:function size:0x48 +add_task__Q23EGG18AudioRmtSpeakerMgrFlPFll_vb = .text:0x804B6AF0; // type:function size:0x84 +doSetup__Q23EGG18AudioRmtSpeakerMgrFlPFll_v = .text:0x804B6B80; // type:function size:0x7C +doShutdown__Q23EGG18AudioRmtSpeakerMgrFlPFll_v = .text:0x804B6C00; // type:function size:0x48 calc__Q23EGG18AudioRmtSpeakerMgrFv = .text:0x804B6C50; // type:function size:0xC4 setupCallbackDirect__Q23EGG18AudioRmtSpeakerMgrFll = .text:0x804B6D20; // type:function size:0x3C shutdownCallbackDirect__Q23EGG18AudioRmtSpeakerMgrFll = .text:0x804B6D60; // type:function size:0x20 -fn_804B6D80__Q23EGG18AudioRmtSpeakerMgrFlPFll_v = .text:0x804B6D80; // type:function size:0x60 -fn_804B6DE0__Q23EGG18AudioRmtSpeakerMgrFlPFll_v = .text:0x804B6DE0; // type:function size:0x78 +setup__Q23EGG18AudioRmtSpeakerMgrFlPFll_v = .text:0x804B6D80; // type:function size:0x60 +shutdown__Q23EGG18AudioRmtSpeakerMgrFlPFll_v = .text:0x804B6DE0; // type:function size:0x78 connectAllByForce__Q23EGG18AudioRmtSpeakerMgrFv = .text:0x804B6E60; // type:function size:0x68 disconnectAllByForce__Q23EGG18AudioRmtSpeakerMgrFv = .text:0x804B6ED0; // type:function size:0x78 getWpadVolume__Q23EGG18AudioRmtSpeakerMgrFv = .text:0x804B6F50; // type:function size:0x8 @@ -39144,7 +39144,7 @@ status_2__4dDyl = .sdata:0x80571C44; // type:object size:0x4 data:4byte lbl_80571C48 = .sdata:0x80571C48; // type:object size:0x8 lbl_80571C50 = .sdata:0x80571C50; // type:object size:0x4 align:4 data:float lbl_80571C58 = .sdata:0x80571C58; // type:object size:0x8 data:byte -lbl_80571C60 = .sdata:0x80571C60; // type:object size:0x8 data:4byte +m_current_ex__Q24dPad4ex_c = .sdata:0x80571C60; // type:object size:0x4 data:4byte lbl_80571C68 = .sdata:0x80571C68; // type:object size:0x8 OBTAINED_ITEM_ID = .sdata:0x80571C70; // type:object size:0x4 data:4byte sCurrentSword__17daPlayerActBase_c = .sdata:0x80571C74; // type:object size:0x1 data:byte @@ -41263,42 +41263,42 @@ DVD__4dDyl = .sbss:0x805750F8; // type:object size:0x4 data:4byte mFaderColor = .sbss:0x80575100; // type:object size:0x4 scope:local data:byte @GUARD@getFontPath__10dFontMng_cFUc@TEMP_FONT_NAME = .sbss:0x80575108; // type:object size:0x1 scope:local data:byte sInstance__6dGfx_c = .sbss:0x80575110; // type:object size:0x8 data:4byte -lbl_80575118 = .sbss:0x80575118; // type:object size:0x4 data:4byte -lbl_8057511C = .sbss:0x8057511C; // type:object size:0x4 data:4byte -lbl_80575120 = .sbss:0x80575120; // type:object size:0x4 data:4byte -lbl_80575124 = .sbss:0x80575124; // type:object size:0x4 data:4byte -lbl_80575128 = .sbss:0x80575128; // type:object size:0x4 data:4byte -lbl_8057512C = .sbss:0x8057512C; // type:object size:0x4 data:4byte -lbl_80575130 = .sbss:0x80575130; // type:object size:0x4 data:4byte -lbl_80575134 = .sbss:0x80575134; // type:object size:0x4 data:4byte -lbl_80575138 = .sbss:0x80575138; // type:object size:0x4 data:4byte -lbl_8057513C = .sbss:0x8057513C; // type:object size:0x4 data:4byte -lbl_80575140 = .sbss:0x80575140; // type:object size:0x4 data:4byte -lbl_80575144 = .sbss:0x80575144; // type:object size:0x4 align:4 data:float -lbl_80575148 = .sbss:0x80575148; // type:object size:0x4 align:4 data:float -lbl_8057514C = .sbss:0x8057514C; // type:object size:0x4 align:4 data:float -lbl_80575150 = .sbss:0x80575150; // type:object size:0x4 align:4 data:float -lbl_80575154 = .sbss:0x80575154; // type:object size:0x4 align:4 data:float -lbl_80575158 = .sbss:0x80575158; // type:object size:0x4 align:4 data:float -lbl_8057515C = .sbss:0x8057515C; // type:object size:0x4 align:4 data:float -lbl_80575160 = .sbss:0x80575160; // type:object size:0x4 align:4 data:float -lbl_80575164 = .sbss:0x80575164; // type:object size:0x4 align:4 data:float -lbl_80575168 = .sbss:0x80575168; // type:object size:0x4 align:4 data:float -lbl_8057516C = .sbss:0x8057516C; // type:object size:0x4 align:4 data:float -lbl_80575170 = .sbss:0x80575170; // type:object size:0x4 align:4 data:float -lbl_80575174 = .sbss:0x80575174; // type:object size:0x4 align:4 data:float -lbl_80575178 = .sbss:0x80575178; // type:object size:0x4 align:4 data:float -lbl_8057517C = .sbss:0x8057517C; // type:object size:0x4 data:4byte -lbl_80575180 = .sbss:0x80575180; // type:object size:0x4 data:4byte -lbl_80575184 = .sbss:0x80575184; // type:object size:0x4 data:4byte -lbl_80575188 = .sbss:0x80575188; // type:object size:0x4 data:4byte -lbl_8057518C = .sbss:0x8057518C; // type:object size:0x4 data:4byte -lbl_80575190 = .sbss:0x80575190; // type:object size:0x4 align:4 data:float -lbl_80575194 = .sbss:0x80575194; // type:object size:0x4 align:4 data:float -lbl_80575198 = .sbss:0x80575198; // type:object size:0x4 align:4 data:float -lbl_8057519C = .sbss:0x8057519C; // type:object size:0x4 align:4 data:float -lbl_805751A0 = .sbss:0x805751A0; // type:object size:0x4 align:4 data:float -lbl_805751A4 = .sbss:0x805751A4; // type:object size:0x4 align:4 data:float +g_CurrentScreenWidth_s32__6dGfx_c = .sbss:0x80575118; // type:object size:0x4 data:4byte +g_CurrentScreenHeight_s32__6dGfx_c = .sbss:0x8057511C; // type:object size:0x4 data:4byte +g_CurrentScreenWidthLimit_s32__6dGfx_c = .sbss:0x80575120; // type:object size:0x4 data:4byte +g_CurrentScreenHeightLimit_s32__6dGfx_c = .sbss:0x80575124; // type:object size:0x4 data:4byte +g_CurrentScreenLeft_s32__6dGfx_c = .sbss:0x80575128; // type:object size:0x4 data:4byte +g_CurrentScreenRight_s32__6dGfx_c = .sbss:0x8057512C; // type:object size:0x4 data:4byte +g_CurrentScreenTop_s32__6dGfx_c = .sbss:0x80575130; // type:object size:0x4 data:4byte +g_CurrentScreenBottom_s32__6dGfx_c = .sbss:0x80575134; // type:object size:0x4 data:4byte +g_CurrentEFBHeight_s32__6dGfx_c = .sbss:0x80575138; // type:object size:0x4 data:4byte +g_CurrentEFBHeightLimit_s32__6dGfx_c = .sbss:0x8057513C; // type:object size:0x4 data:4byte +g_CurrentLetterBoxAmount_s32__6dGfx_c = .sbss:0x80575140; // type:object size:0x4 data:4byte +g_CurrentScreenWidth_f32__6dGfx_c = .sbss:0x80575144; // type:object size:0x4 align:4 data:float +g_CurrentScreenHeight_f32__6dGfx_c = .sbss:0x80575148; // type:object size:0x4 align:4 data:float +g_CurrentScreenWidthLimit_f32__6dGfx_c = .sbss:0x8057514C; // type:object size:0x4 align:4 data:float +g_CurrentScreenHeightLimit_f32__6dGfx_c = .sbss:0x80575150; // type:object size:0x4 align:4 data:float +g_CurrentScreenLeft_f32__6dGfx_c = .sbss:0x80575154; // type:object size:0x4 align:4 data:float +g_CurrentScreenRight_f32__6dGfx_c = .sbss:0x80575158; // type:object size:0x4 align:4 data:float +g_CurrentScreenTop_f32__6dGfx_c = .sbss:0x8057515C; // type:object size:0x4 align:4 data:float +g_CurrentScreenBottom_f32__6dGfx_c = .sbss:0x80575160; // type:object size:0x4 align:4 data:float +g_CurrentScreenAspect__6dGfx_c = .sbss:0x80575164; // type:object size:0x4 align:4 data:float +g_CurrentEFBHeight_f32__6dGfx_c = .sbss:0x80575168; // type:object size:0x4 align:4 data:float +g_CurrentEFBHeightLimit_f32__6dGfx_c = .sbss:0x8057516C; // type:object size:0x4 align:4 data:float +g_CurrentEFBHeightDifference_f32__6dGfx_c = .sbss:0x80575170; // type:object size:0x4 align:4 data:float +g_CurrentHeightScaled_f32__6dGfx_c = .sbss:0x80575174; // type:object size:0x4 align:4 data:float +g_CurrentEFBHeightDifference2_f32__6dGfx_c = .sbss:0x80575178; // type:object size:0x4 align:4 data:float +g_Width4x3_s32__6dGfx_c = .sbss:0x8057517C; // type:object size:0x4 data:4byte +g_Width4x3Limit_s32__6dGfx_c = .sbss:0x80575180; // type:object size:0x4 data:4byte +g_Width16x9_s32__6dGfx_c = .sbss:0x80575184; // type:object size:0x4 data:4byte +g_Width4x3Left_s32__6dGfx_c = .sbss:0x80575188; // type:object size:0x4 data:4byte +g_Width4x3Right_s32__6dGfx_c = .sbss:0x8057518C; // type:object size:0x4 data:4byte +g_Width4x3_f32__6dGfx_c = .sbss:0x80575190; // type:object size:0x4 align:4 data:float +g_Width4x3Limit_f32__6dGfx_c = .sbss:0x80575194; // type:object size:0x4 align:4 data:float +g_Width16x9_f32__6dGfx_c = .sbss:0x80575198; // type:object size:0x4 align:4 data:float +g_Width4x3Left_f32__6dGfx_c = .sbss:0x8057519C; // type:object size:0x4 align:4 data:float +g_Width4x3Right_f32__6dGfx_c = .sbss:0x805751A0; // type:object size:0x4 align:4 data:float +g_16x9to4x3WidthScale__6dGfx_c = .sbss:0x805751A4; // type:object size:0x4 align:4 data:float work1Heap__5dHeap = .sbss:0x805751A8; // type:object size:0x4 data:4byte work2Heap__5dHeap = .sbss:0x805751AC; // type:object size:0x4 data:4byte workExHeap__5dHeap = .sbss:0x805751B0; // type:object size:0x4 data:4byte @@ -41311,7 +41311,7 @@ HBMHeap__5dHeap = .sbss:0x805751C8; // type:object size:0x4 data:4byte lbl_805751D0 = .sbss:0x805751D0; // type:object size:0x8 data:4byte dMain__g_InitialTime = .sbss:0x805751D8; // type:object size:0x4 data:4byte g_InitialTime+4 = .sbss:0x805751DC; // type:object size:0x4 data:4byte -dPad__connectedStatus = .sbss:0x805751E0; // type:object size:0x8 +m_connected__Q24dPad4ex_c = .sbss:0x805751E0; // type:object size:0x4 lbl_805751E8 = .sbss:0x805751E8; // type:object size:0x8 data:4byte LINK_ROT = .sbss:0x805751F0; // type:object size:0x2 data:2byte LINK_ROT_2 = .sbss:0x805751F4; // type:object size:0x2 data:2byte @@ -50372,9 +50372,8 @@ l_dFontMng_obj = .bss:0x80597618; // type:object size:0xA8 scope:local sAllocator__14dHeapAllocator = .bss:0x80597740; // type:object size:0x18 data:4byte MAIN_THREAD = .bss:0x80597758; // type:object size:0x318 lbl_80597A70 = .bss:0x80597A70; // type:object size:0x10 -sControllers = .bss:0x80597A80; // type:object size:0x8B70 align:4 data:float -lbl_805A05F0 = .bss:0x805A05F0; // type:object size:0x60 -PadExtendedStuff_ARRAY_805a0604_3_.field4_0x4 = .bss:0x805A0650; // type:object size:0x60 +m_ex__Q24dPad4ex_c = .bss:0x80597A80; // type:object size:0x8B70 align:4 data:float +m_info__Q24dPad4ex_c = .bss:0x805A05F0; // type:object size:0xC0 LINK_POS = .bss:0x805A06B0; // type:object size:0xC align:4 data:float LINK_POS_2 = .bss:0x805A06BC; // type:object size:0xC align:4 data:float sHandMats = .bss:0x805A06C8; // type:object size:0xE scope:local data:byte diff --git a/configure.py b/configure.py index d6166140..0e789eac 100644 --- a/configure.py +++ b/configure.py @@ -411,7 +411,8 @@ config.libs = [ Object(Matching, "d/d_heap.cpp"), Object(NonMatching, "d/d_main.cpp"), Object(NonMatching, "d/d_pad.cpp"), - Object(NonMatching, "d/d_pad_player.cpp"), + Object(NonMatching, "d/d_pad_ex.cpp"), + Object(NonMatching, "d/d_pause_manager.cpp"), Object(NonMatching, "d/d_player_act.cpp"), Object(Matching, "d/d_player_mdl.cpp"), Object(Matching, "d/d_player_guide_colors.cpp"), 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: - static bool checkButtonAPressed(); - static bool checkButtonBPressed(); - static bool checkButtonZPressed(); - static bool checkButtonCPressed(); - static bool checkButtonMinusPressed(); - static bool checkButtonPlusPressed(); - static bool checkButton1Pressed(); - static bool checkButton2Pressed(); + 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); - static bool checkButtonDpadUpPressed(); - static bool checkButtonDpadDownPressed(); - static bool checkButtonDpadLeftPressed(); - static bool checkButtonDpadRightPressed(); + void fn_800572A0(); - static bool checkButtonAHeld(); - static bool checkButtonZHeld(); + 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: + /* 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, }; -typedef void (*ConnectCallback)(int args[]); -typedef class CoreController *(*ControllerFactory)(); +enum eCoreButton { + cCORE_BUTTON_UP = 1 << 3, + cCORE_BUTTON_DOWN = 1 << 2, + cCORE_BUTTON_LEFT = 1 << 0, + cCORE_BUTTON_RIGHT = 1 << 1, -class CoreStatus { + 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: - /* 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]; + virtual void onConnect(const CoreControllerExtensionArg &rArg); // at 0x8 +}; + +/****************************************************************************** + * + * CoreStatus + * + ******************************************************************************/ +class CoreStatus : public KPADStatus { + friend class CoreController; + +public: + CoreStatus() {} public: void init(); - u32 getFSStickButton() const; - f32 getFSStickX() const { - return mFSStickX; - } - f32 getFSStickY() const { - return mFSStickY; - } - bool down(u32 mask) const { - return (mask & mHold); - } - bool up(u32 mask) const { - return (mask & mHold) != mask; - } - bool downTrigger(u32 mask) const { - return (mask & mTrig); - } - bool upTrigger(u32 mask) const { - return (mask & mRelease); - } - bool downAll(u32 mask) const { - return (mask & mHold) == mask; - } - bool upAll(u32 mask) const { - return (mask & mHold) == 0; - } - - s32 getDevType() const { - return mDevType; - } - bool isCore() const { - return getDevType() == WPAD_DEV_CORE; - } - bool isFreestyle() const { - return getDevType() == WPAD_DEV_FS; - } u32 getHold() const { - return mHold; + return hold; + } + u32 getRelease() const { + return release; + } + u32 getTrigger() const { + return trig; } - s8 getDpdValidFlag() const { - return mDpdValid; - }; + bool down(u32 buttons) const { + return buttons & hold; + } + bool up(u32 buttons) const { + return (buttons & hold) != buttons; + } - Vector2f getUnk() { - return Vector2f(float_0x54, float_0x58); + bool downAll(u32 buttons) const { + return (buttons & hold) == buttons; + } + bool upAll(u32 buttons) const { + return (buttons & hold) == 0; + } + + bool downTrigger(u32 buttons) const { + return buttons & trig; + } + bool upTrigger(u32 buttons) const { + return buttons & release; } const Vector3f &getAccel() const { - return mAccel; + return *reinterpret_cast(&acc); } -}; + Vector2f getAccelVertical() { + return Vector2f(acc_vertical.x, acc_vertical.y); + } + + eCoreDevType getDevType() const { + return static_cast(dev_type); + } + + bool isCore() const { + return getDevType() == cDEV_CORE || isFreestyle(); + } + bool isFreestyle() const { + return getDevType() == cDEV_FREESTYLE; + } + + s8 getDPDValidFlag() const { + return dpd_valid_fg; + } + + f32 getFSStickX() const { + return ex_status.fs.stick.x; + } + 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 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 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 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: + CoreController *getNthController(int index); + + 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); + +private: /* 0x0014 */ TBuffer mControllers; /* 0x0020 */ u8 field_0x20[0x10a0 - 0x0020]; /* 0x10A0 */ UnkField0x10A0 *field_0x10A0; /* 0x10A4 */ TBuffer mDevTypes; /* 0x10b0 */ u8 field_0x10B0[0x10e0 - 0x10b0]; -public: - static CoreControllerMgr *createInstance(); - static void deleteInstance(); - CoreController *getNthController(int); - - 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; + 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 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 mFlags; + /* 0x1C */ nw4r::ut::Node mNode; + /* 0x24 */ u32 field_0x24; }; +/****************************************************************************** + * + * ControllerRumbleMgr + * + ******************************************************************************/ class ControllerRumbleMgr { -public: - // 0x00 vtable - /* vt 0x08 */ virtual ~ControllerRumbleMgr() {} - -public: - /* 0x04 */ nw4r::ut::List mActiveUnitList; - /* 0x10 */ nw4r::ut::List mInactiveUnitList; - /* 0x1C */ CoreController *mController; - public: ControllerRumbleMgr(); - void createUnit(u8 numUnits, CoreController *controller); + virtual ~ControllerRumbleMgr() {} // at 0x8 + + void createUnit(u8 overlap_num, CoreController *pController); + 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 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; - } + + 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: - /* 0x08 */ s32 mSize; - /* 0x0C */ T *mBuffer; + TBuffer() : mSize(0), mBuffer(NULL) {} -public: - inline TBuffer() : mSize(0), mBuffer(nullptr) {} + virtual ~TBuffer() { + if (mBuffer == NULL) { + return; + } - inline bool isRangeValid(int i) { - return (i >= 0 && i < mSize); + 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 void checkRange(int i) { + const T &operator()(int i) const { + checkRange(i); + return mBuffer[i]; + } + + 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(); } } - inline T &operator()(int i) { - checkRange(i); - return mBuffer[i]; - } - inline s32 getSize() { - return mSize; + + bool isRangeValid(int i) const { + return i >= 0 && i < mSize; } + +private: + int mSize; // at 0x4 + T *mBuffer; // at 0x8 }; template -void TBuffer::allocate(int n, int) { - mSize = n; - mBuffer = new T[n]; +void TBuffer::allocate(int size, int) { + mSize = size; + mBuffer = new T[size]; onAllocate(nullptr); } - template -void TBuffer::allocate(int n, Heap *heap, int) { - mSize = n; - if (heap == nullptr) { - heap = Heap::sCurrentHeap; +void TBuffer::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 void (*KPADConnectCallback)(s32, s32); -// TODO: Create Proper Headers -void KPADInitEx(void * /* UNKTYPE */, u32); +typedef struct KPADUnifiedWpadStatus { + union { + WPADStatus core; + WPADFSStatus fs; + WPADCLStatus cl; + WPADTRStatus tr; + WPADBLStatus bl; + } u; // at 0x0 + u8 fmt; // 0x36; + u8 padding; // 0x37; -s32 KPADRead(s32 chan, UNKTYPE *status, s32); -s32 KPADReadEx(s32 chan, UNKTYPE *status, s32, s32 *); +} KPADUnifiedWpadStatus; + +typedef void (*KPADConnectCallback)(s32, s32); void KPADSetConnectCallback(u32, KPADConnectCallback); -void KPADSetPosParam(u32, f32, f32); -void KPADSetHoriParam(u32, f32, f32); -void KPADSetDistParam(u32, f32, f32); -void KPADSetAccParam(u32, f32, f32); +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 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); + +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 diff --git a/src/d/a/obj/d_a_obj_boomerang.cpp b/src/d/a/obj/d_a_obj_boomerang.cpp index 48264a84..55c7f0ab 100644 --- a/src/d/a/obj/d_a_obj_boomerang.cpp +++ b/src/d/a/obj/d_a_obj_boomerang.cpp @@ -7,6 +7,7 @@ #include "d/col/bg/d_bg_s.h" #include "d/col/bg/d_bg_s_lin_chk.h" #include "d/col/c/c_cc_d.h" +#include "d/d_pad.h" #include "d/d_rumble.h" #include "d/snd/d_snd_wzsound.h" #include "f/f_base.h" @@ -91,7 +92,7 @@ void dAcBoomerang_c::atHitCallback(cCcD_Obj *i_objInfA, dAcObjBase_c *i_actorB, field_0x8D8.normalize(); - setField_0x8CC(FLAG_BOOMERANG_CANCEL); + setField_0x8CC(FLAG_CANCEL); mStateMgr.changeState(StateID_MoveCancelWait); } else { // Play the animation to move the pincers @@ -290,16 +291,16 @@ const dAcBoomerang_c::ChrAnimation_t dAcBoomerang_c::sChrAnims[dAcBoomerang_c::R bool dAcBoomerang_c::tryGrabObject(dAcObjBase_c *pObj) { dAcPy_c *player = dAcPy_c::GetLink2(); - if (checkField_0x8CC(0x1000) && GetLinkage().checkFlag(0x80)) {} + if (checkField_0x8CC(FLAG_CONTROLLABLE) && GetLinkage().checkFlag(0x80)) {} } // ... void dAcBoomerang_c::bonk() { - if (checkField_0x8CC(FLAG_BOOMERANG_RUMBLE_ACTIVE)) { + if (checkField_0x8CC(FLAG_RUMBLE_ACTIVE)) { return; } - setField_0x8CC(FLAG_BOOMERANG_RUMBLE_ACTIVE); + setField_0x8CC(FLAG_RUMBLE_ACTIVE); dRumble_c::start(dRumble_c::sRumblePreset1, 1); } @@ -360,10 +361,7 @@ void dAcBoomerang_c::initializeState_Wait() { mSph0.ClrAtHit(); mSph1.ClrTgHit(); mSph1.ClrAtHit(); - unsetField_0x8CC( - FLAG_BOOMERANG_0x10000 | FLAG_BOOMERANG_WING_EFFECT_ACTIVE | FLAG_BOOMERANG_0x2000 | - FLAG_BOOMERANG_STOP_TIMER_ACTIVE | FLAG_BOOMERANG_0x10 | FLAG_BOOMERANG_RELEASE_ITEM | FLAG_BOOMERANG_CANCEL - ); + unsetField_0x8CC(FLAG_COMMON_INIT); placeOnArm(); field_0x8D0 = 0.f; @@ -373,7 +371,7 @@ void dAcBoomerang_c::initializeState_Wait() { void dAcBoomerang_c::executeState_Wait() { forwardSpeed = 0.f; placeOnArm(); - if (checkField_0x8CC(FLAG_BOOMERANG_REQUEST_MOVE)) { + if (checkField_0x8CC(FLAG_REQUEST_MOVE)) { mStateMgr.changeState(StateID_Move); } } @@ -385,10 +383,7 @@ void dAcBoomerang_c::initializeState_ReturnWait() { mSph0.ClrAtHit(); mSph1.ClrTgHit(); mSph1.ClrAtHit(); - unsetField_0x8CC( - FLAG_BOOMERANG_0x10000 | FLAG_BOOMERANG_WING_EFFECT_ACTIVE | FLAG_BOOMERANG_0x2000 | - FLAG_BOOMERANG_STOP_TIMER_ACTIVE | FLAG_BOOMERANG_0x10 | FLAG_BOOMERANG_RELEASE_ITEM | FLAG_BOOMERANG_CANCEL - ); + unsetField_0x8CC(FLAG_COMMON_INIT); placeOnArm(); } void dAcBoomerang_c::executeState_ReturnWait() { @@ -411,7 +406,28 @@ void dAcBoomerang_c::initializeState_Move() { setFlyChrAnimation(RB_FLY); field_0x8B1 = 45; // 1.5 seconds if that means anything field_0x8C8 = 0; - forwardSpeed = dAcPy_c::GetLink2()->getBeetleSmallRadius(); + + dAcPy_c *player = dAcPy_c::GetLink2(); + forwardSpeed = player->getBeetleNormalSpeed(); + + mSph0.ClrAtHit(); + mSph1.ClrTgHit(); + mSph1.ClrAtHit(); + + mRemainingFlightTime = player->getBeetleFlightTime(); + mFlashTimer = player->getBeetleWarningTimeLeft(); + unsetField_0x8CC(FLAG_REQUEST_MOVE | FLAG_WING_EFFECT_ACTIVE | FLAG_0x10000); + setField_0x8CC(FLAG_CONTROLLABLE | FLAG_0x80000); + + angle.x = 2000 - player->vt_0x198(); + + rotation.x.set(-angle.x); + rotation.y.set(angle.y); + rotation.z.set(0); + field_0x8B2 = 0; + + mOldPosition = position; + mOldPosition.y += 60.f; } void dAcBoomerang_c::executeState_Move() {} void dAcBoomerang_c::finalizeState_Move() {} @@ -426,10 +442,7 @@ void dAcBoomerang_c::initializeState_EventReturnWait() { mSph1.ClrTgHit(); mSph1.ClrAtHit(); - unsetField_0x8CC( - FLAG_BOOMERANG_0x10000 | FLAG_BOOMERANG_WING_EFFECT_ACTIVE | FLAG_BOOMERANG_0x2000 | - FLAG_BOOMERANG_STOP_TIMER_ACTIVE | FLAG_BOOMERANG_0x10 | FLAG_BOOMERANG_RELEASE_ITEM | FLAG_BOOMERANG_CANCEL - ); + unsetField_0x8CC(FLAG_COMMON_INIT); } void dAcBoomerang_c::executeState_EventReturnWait() {} void dAcBoomerang_c::finalizeState_EventReturnWait() {} @@ -439,7 +452,7 @@ void dAcBoomerang_c::executeTimeWarning() { mColor flashClr(0, 0, 0, 0xFF); if (mRemainingFlightTime <= timeLimit) { - setField_0x8CC(FLAG_BOOMERANG_STOP_TIMER_ACTIVE); + setField_0x8CC(FLAG_STOP_TIMER_ACTIVE); if (mFlashTimer != 0) { mFlashTimer--; @@ -471,22 +484,22 @@ void dAcBoomerang_c::registerInEvent() { int dAcBoomerang_c::actorExecute() { dAcPy_c *player = dAcPy_c::GetLink2(); - if (checkField_0x8CC(FLAG_BOOMERANG_REQUEST_0x400)) { - unsetField_0x8CC(FLAG_BOOMERANG_REQUEST_0x400); + if (checkField_0x8CC(FLAG_REQUEST_0x400)) { + unsetField_0x8CC(FLAG_REQUEST_0x400); } if (dAcPy_c::GetLink2()->checkModelUpdateFlag(0x10000 | 0x80)) { deleteRequest(); - unsetField_0x8CC(FLAG_BOOMERANG_REQUEST_0x400); + unsetField_0x8CC(FLAG_REQUEST_0x400); return SUCCEEDED; } if (EventManager::isInEvent() && mEventRelated.getSomeEventRelatedNumber() != -1) { - setField_0x8CC(FLAG_BOOMERANG_0x40); + setField_0x8CC(FLAG_0x40); mEventRelated.advanceNext(); } - unsetField_0x8CC(FLAG_BOOMERANG_0x40000 | FLAG_BOOMERANG_RUMBLE_ACTIVE); + unsetField_0x8CC(FLAG_0x40000 | FLAG_RUMBLE_ACTIVE); for (int i = 0; i < 2; ++i) { mAnmChr[i].play(); @@ -503,7 +516,7 @@ int dAcBoomerang_c::actorExecute() { mMdl.getNodeWorldMtxMultVecZero(0, poscopy2); poscopy3 = poscopy2; - if (checkField_0x8CC(FLAG_BOOMERANG_WING_EFFECT_ACTIVE)) { + if (checkField_0x8CC(FLAG_WING_EFFECT_ACTIVE)) { mEff0.createContinuousEffect(PARTICLE_RESOURCE_ID_MAPPING_6_, mWorldMtx, nullptr, nullptr); mEff1.setTransform(mWorldMtx); @@ -523,14 +536,14 @@ int dAcBoomerang_c::actorExecute() { mEff2.remove(true); } - if (checkField_0x8CC(FLAG_BOOMERANG_0x20) && !checkField_0x8CC(FLAG_BOOMERANG_CANCEL)) { + if (checkField_0x8CC(FLAG_0x20) && !checkField_0x8CC(FLAG_CANCEL)) { if (mStateMgr.isState(StateID_Move) || mStateMgr.isState(StateID_MoveCancelWait)) { mEff3.createContinuousEffect(PARTICLE_RESOURCE_ID_MAPPING_7_, mWorldMtx, nullptr, nullptr); playSoundEffect1(SE_BE_HIT_LEAVES_LV); } } - unsetField_0x8CC(FLAG_BOOMERANG_0x20 | FLAG_BOOMERANG_0x40 | FLAG_BOOMERANG_0x80 | FLAG_BOOMERANG_DROP_ITEM); + unsetField_0x8CC(FLAG_0x20 | FLAG_0x40 | FLAG_0x80 | FLAG_DROP_ITEM); retrieve(); return SUCCEEDED; } diff --git a/src/d/d_cursor_hit_check.cpp b/src/d/d_cursor_hit_check.cpp index 160c6c28..c50b1c60 100644 --- a/src/d/d_cursor_hit_check.cpp +++ b/src/d/d_cursor_hit_check.cpp @@ -4,6 +4,8 @@ #include "d/col/bg/d_bg_s.h" #include "d/col/bg/d_bg_s_lin_chk.h" #include "d/col/cc/d_cc_s.h" +#include "d/d_gfx.h" +#include "d/d_pad.h" #include "d/d_stage_mgr.h" #include "m/m_mtx.h" #include "m/m_vec.h" @@ -11,9 +13,7 @@ #include "nw4r/lyt/lyt_bounding.h" #include "nw4r/lyt/lyt_pane.h" #include "nw4r/ut/ut_RuntimeTypeInfo.h" -#include "rvl/MTX/mtx.h" #include "toBeSorted/d_d3d.h" -#include "toBeSorted/lyt_related_floats.h" dCsMgr_c::dCsMgr_c() { // NONMATCHING - TList ctor issues @@ -117,19 +117,24 @@ bool dCursorHitCheck_c::checkOverrideCallback(bool b) { bool dCursorHitCheckCC_c::checkHit(s32 x, s32 y) { // NONMATCHING - TODO - mVec3_c pos(x, y, 10000.0f); - pos.x = (pos.x - get_8057515C()) / get_80575148() * -2.0f - 1.0f; - pos.y = (pos.y - get_8057519C()) / get_80575190() * 2.0f - 1.0f; + + mVec3_c pos( + (x - dGfx_c::getWidth4x3LeftF()) / dGfx_c::getWidth4x3F() * 2.f - 1.f, + (y - dGfx_c::getCurrentScreenTopF()) / dGfx_c::getCurrentScreenHeightF() * -2.f - 1.f, 10000.f + ); + mVec3_c v; d3d::fn_80016B60(v, pos); + nw4r::g3d::Camera cam = dStageMgr_c::GetInstance()->getCamera(0); + mMtx_c mtx; - cam.GetCameraMtx(mtx); - PSMTXInverse(mtx, mtx); mVec3_c a; - a.x = mtx.m[0][3]; - a.y = mtx.m[1][3]; - a.z = mtx.m[2][3]; + + cam.GetCameraMtx(mtx); + mtx.inverse(); + mtx.getTranslation(a); + dBgS_LinChk ck; ck.Set(&a, &v, nullptr); dBgS::GetInstance()->LineCross(&ck); @@ -254,6 +259,5 @@ void dCursorHitCheckLyt_c::gatherBoundings(dCsCheckLyt_BoundingData **pEnd, nw4r } mVec2_c &dCursorInterface_c::getCursorPos() { - // NONMATCHING - Controller stuff - return *(mVec2_c *)nullptr; + return dPad::ex_c::getInstance()->field_0x8; } diff --git a/src/d/d_dvd_drive_error.cpp b/src/d/d_dvd_drive_error.cpp index 2f7329b5..8f1bdc91 100644 --- a/src/d/d_dvd_drive_error.cpp +++ b/src/d/d_dvd_drive_error.cpp @@ -1,15 +1,14 @@ #include "d/d_dvd_drive_error.h" #include "d/d_dvd_unk.h" +#include "d/d_gfx.h" #include "d/d_textunk.h" #include "egg/gfx/eggDrawGX.h" #include "egg/gfx/eggScreen.h" #include "m/m_mtx.h" #include "m/m_vec.h" -#include "toBeSorted/lyt_related_floats.h" #include "toBeSorted/reload_color_fader.h" - /** 805750d0 */ dDvdDriveError_c *dDvdDriveError_c::sInstance; @@ -28,7 +27,8 @@ bool dDvdDriveError_c::isError() const { static const wchar_t sErrEnGeneral[] = L"Please insert The Legend of Zelda:\nSkyward Sword Game Disc."; static const wchar_t sErrEnDiskId[] = L"Please insert The Legend of Zelda:\nSkyward Sword Game Disc."; -static const wchar_t sErrEnDiskError[] = L"The disc could not be read.\nRefer to the Wii Operations\nManual for details."; +static const wchar_t sErrEnDiskError[] = + L"The disc could not be read.\nRefer to the Wii Operations\nManual for details."; static const wchar_t *sErrorsEn[] = { sErrEnGeneral, @@ -38,7 +38,8 @@ static const wchar_t *sErrorsEn[] = { static const wchar_t sErrEsGeneral[] = L"Por favor, inserta el disco\nde The Legend of Zelda:\nSkyward Sword."; static const wchar_t sErrEsDiskId[] = L"Por favor, inserta el disco\nde The Legend of Zelda:\nSkyward Sword."; -static const wchar_t sErrEsDiskError[] = L"No se puede leer el disco.\nConsulta el manual de operaciones\nde la consola Wii para obtener m\xe1" +static const wchar_t sErrEsDiskError[] = + L"No se puede leer el disco.\nConsulta el manual de operaciones\nde la consola Wii para obtener m\xe1" "s\ninformaci\xf3" "n."; @@ -48,11 +49,14 @@ static const wchar_t *sErrorsEs[] = { sErrEsDiskError, }; -static const wchar_t sErrFrGeneral[] = L"Veuillez ins\xe9" +static const wchar_t sErrFrGeneral[] = + L"Veuillez ins\xe9" "rer le disque\nThe Legend of Zelda:\nSkyward Sword."; -static const wchar_t sErrFrDiskId[] = L"Veuillez ins\xe9" +static const wchar_t sErrFrDiskId[] = + L"Veuillez ins\xe9" "rer le disque\nThe Legend of Zelda:\nSkyward Sword."; -static const wchar_t sErrFrDiskError[] = L"Impossible de lire le disque.\nVeuillez vous r\xe9" +static const wchar_t sErrFrDiskError[] = + L"Impossible de lire le disque.\nVeuillez vous r\xe9" "f\xe9" "rer au mode\nd'emploi de la Wii pour plus\nde d\xe9" "tails."; @@ -71,11 +75,11 @@ void dDvdDriveError_c::draw() { screen.SetCanvasMode(EGG::Screen::CANVASMODE_0); screen.SetProjectionType(EGG::Frustum::PROJ_ORTHO); screen.SetNearFar(0.0f, 500.0f); - screen.SetScale(mVec3_c(get_80575190() / get_80575144(), 1.0f, 1.0f)); + screen.SetScale(mVec3_c(dGfx_c::getWidth4x3F() / dGfx_c::getCurrentScreenWidthF(), 1.0f, 1.0f)); screen.SetProjectionGX(); - f32 x = get_80575144() * 0.5f; + f32 x = dGfx_c::getCurrentScreenWidthF() * 0.5f; f32 mx = -x; - f32 y = get_80575148() * 0.5f; + f32 y = dGfx_c::getCurrentScreenHeightF() * 0.5f; f32 my = -y; EGG::DrawGX::BeginDrawScreen(screen.GetCanvasMode() == EGG::Screen::CANVASMODE_1, false, false); @@ -89,8 +93,8 @@ void dDvdDriveError_c::draw() { EGG::DrawGX::DrawDL(EGG::DrawGX::DL_17, mtx, EGG::DrawGX::BLACK); nw4r::math::MTX44 mtx2; - f32 a = get_8057511C(); - f32 b = get_80575118(); + f32 a = dGfx_c::getCurrentScreenHeight(); + f32 b = dGfx_c::getCurrentScreenWidth(); C_MTXOrtho(mtx2, 0.0f, a, 0.0f, b, 0.0f, 1.0f); GXSetProjection(mtx2, GX_ORTHOGRAPHIC); GXSetScissor(0, 0, b, a); @@ -126,8 +130,8 @@ void dDvdDriveError_c::draw() { textWriter.SetupGX(); textWriter.SetDrawFlag(0x110); - textWriter.SetCursorX(get_8057514C()); - textWriter.SetCursorY(get_80575150()); + textWriter.SetCursorX(dGfx_c::getCurrentScreenWidthLimitF()); + textWriter.SetCursorY(dGfx_c::getCurrentScreenHeightLimitF()); textWriter.Print(str, wcslen(str)); } diff --git a/src/d/d_pad.cpp b/src/d/d_pad.cpp new file mode 100644 index 00000000..e7ab853b --- /dev/null +++ b/src/d/d_pad.cpp @@ -0,0 +1,390 @@ +#include "d/d_pad.h" + +#include "common.h" +#include "d/d_gfx.h" +#include "d/snd/d_snd_player_mgr.h" +#include "egg/core/eggController.h" +#include "egg/core/eggHeap.h" +#include "m/m_pad.h" +#include "m/m_vec.h" +#include "rvl/KPAD/KPAD.h" +#include "rvl/WPAD/WPAD.h" + +#include "rvl/WPAD.h" + +namespace dPad { + +ex_c ex_c::m_ex[4]; +ex_c *ex_c::m_current_ex = ex_c::m_ex; + +WPADInfo ex_c::m_info[2][4]; + +bool ex_c::m_connected[4]; + +void control_mpls_callback(s32 idx, s32 code) { + switch (code) { + case WPAD_ERR_OK: { + ex_c::on_0x54(idx); + break; + } + case WPAD_ERR_NO_CONTROLLER: { + ex_c::on_0x55(idx); + break; + } + case WPAD_ERR_BUSY: { + ex_c::on_0x56(idx); + break; + } + case 1: { + ex_c::on_0x57(idx); + break; + } + } +} + +bool checkDeviceType(u32 type) { + switch (type) { + case WPAD_DEV_MOTION_PLUS: + case WPAD_DEV_MPLS_PT_FS: + case WPAD_DEV_MPLS_PT_CLASSIC: + case WPAD_DEV_MPLS_PT_UNKNOWN: return true; + default: return false; + } +} + +void initMpls(s32 chan) { + KPADResetMpls(chan); + KPADDisableMplsZeroPlay(chan); + KPADSetMplsZeroPlayParam(chan, 0.005f); + KPADSetMplsZeroDriftMode(chan, 2); + disableMplsDirRevise(chan); + KPADSetMplsDirReviseParam(chan, 0.35f); + KPADEnableMplsAccRevise(chan); + KPADSetMplsAccReviseParam(chan, 0.03f, 0.4f); + KPADEnableMplsDpdRevise(chan); + KPADSetMplsDpdReviseParam(chan, 0.5f); +} + +extern "C" void fn_80194080(); +void create() { + mPad::create(); + + KPADSetBtnRepeat(mPad::getCore(0)->getChannelID(), 0.5f, 0.1f); + ex_c::resetInfo(); + + KPADSetMplsWorkarea(new (0x20) u8[KPADGetMplsWorkSize()]); + + for (int i = 0; i < 4; ++i) { + ex_c::m_ex[i].mMotion.init(); + KPADSetReviseMode(i, 1); + KPADSetControlMplsCallback(i, control_mpls_callback); + ex_c::m_ex[i].resetState(i); + } + fn_80194080(); +} + +void setMpls(bool enable, s32 chan) { + if (enable) { + if (ex_c::m_ex[chan].mMplsEnabled == false) { + ex_c::m_ex[chan].mMplsEnabled = true; + KPADEnableMpls(chan, 5); + initMpls(chan); + } + } else { + if (ex_c::m_ex[chan].mMplsEnabled) { + ex_c::m_ex[chan].mMplsEnabled = false; + KPADDisableMpls(chan); + } + } +} + +void centerPos(mVec2_c &in, mVec2_c &out) { + out.x = dGfx_c::getWidth4x3F() * 0.5f * (1.f + in.x) + dGfx_c::getWidth4x3LeftF(); + out.y = dGfx_c::getCurrentScreenHeightF() * -0.5f * (1.f + in.y) + dGfx_c::getCurrentScreenTopF(); +} + +void beginPad_BR() { + mPad::beginPad(); + + if (mPad::getCore(0)->isConnected()) { + WPADSetAcceptConnection(0); + } else { + WPADSetAcceptConnection(1); + } + + for (int i = 0; i < 4; ++i) { + if (mPad::getCore(i)->isConnected()) { + WPADDisconnect(i); + } + } + + ex_c::m_ex[0].fn_800572A0(); + if (mPad::getCore(0)->isConnected()) { + ex_c::m_ex[0].getUnifiedWpadStatus(0); + ex_c::m_ex[0].fn_80059300(0); + ex_c::m_ex[0].fn_80056AF0(0); + ex_c::m_ex[0].fn_80056B90(0); + ex_c::m_ex[0].fn_80056CE0(0); + ex_c::m_ex[0].fn_80056DF0(0); + } + + ex_c::m_current_ex = &ex_c::m_ex[mPad::getCurrentCoreID()]; +} + +void endPad_BR() { + mPad::endPad(); +} + +void connectCallback(const EGG::CoreControllerConnectArg &rArg) { + switch (rArg.result) { + case WPAD_ERR_OK: { + dSndPlayerMgr_c::GetInstance()->setup(rArg.chan); + ex_c::m_ex[rArg.chan].mSpeakerSetup = true; + break; + } + case WPAD_ERR_NO_CONTROLLER: { + dSndPlayerMgr_c::GetInstance()->shutdown(rArg.chan); + ex_c::m_ex[rArg.chan].mSpeakerShutdown = true; + break; + } + } +} + +void setConnectCallback() { + EGG::CoreControllerMgr::setConnectCallback(connectCallback); +} + +void enableMplsDirRevise(s32 chan) { + KPADEnableMplsDirRevise(chan); +} + +void disableMplsDirRevise(s32 chan) { + KPADDisableMplsDirRevise(chan); +} + +void ex_c::fn_80056AF0(s32 chan) { + if (mSpeakerSetup) { + mSpeakerSetup = false; + field_0x38 = 90; + field_0x44 = true; + + m_ex[chan].field_0x46 = true; + m_ex[chan].field_0x3C = 120; + } else { + field_0x44 = false; + } + if (mSpeakerShutdown) { + mSpeakerShutdown = false; + field_0x45 = true; + m_ex[chan].mWPADDeviceTypeStable = WPAD_DEV_UNKNOWN; + } else { + field_0x45 = false; + } +} + +void ex_c::fn_80056B90(s32 chan) { + u32 prevType = mWPADDeviceType; + WPADResult prevResult = mWPADProbeResult; + + mWPADProbeResult = WPADProbe(chan, &mWPADDeviceType); + + if (prevResult == mWPADProbeResult) { + mWPADProbeStableTimer++; + if (mWPADProbeStableTimer >= 5) { + mWPADProbeStableTimer = 5; + } + } else { + mWPADProbeStableTimer = 0; + } + if (mWPADProbeStableTimer >= 5) { + mWPADProbeResultStable = mWPADProbeResult; + } + if (field_0x38 > 0) { + field_0x38--; + if (field_0x38 < 0) { + field_0x38 = 0; + } + } + + if (prevType != mWPADDeviceType) { + mWPADDeviceTypeStableTimer = 0; + } else { + mWPADDeviceTypeStableTimer++; + if (mWPADDeviceTypeStableTimer > 20) { + mWPADDeviceTypeStableTimer = 20; + } + } + + if (mWPADDeviceType != mWPADDeviceTypeStable && mWPADDeviceTypeStableTimer >= 20) { + mWPADDeviceTypeStable = mWPADDeviceType; + } + + if (!checkDeviceType(mWPADDeviceTypeStable)) { + mIncorrectDeviceType = true; + field_0x6C = 0; + } + if (checkDeviceType(mWPADDeviceTypeStable) && field_0x6C < 8) { + field_0x6C++; + } +} + +void ex_c::fn_80056CE0(s32 chan) { + if (field_0x46 == false) { + return; + } + + if (field_0x3C == 1) { + if (WPADCanSendStreamData(chan) && WPADGetRadioSensitivity(chan) > 50) { + WPADResult res = getInfo(chan); + if (res == WPAD_ERR_OK || res == WPAD_ERR_NO_CONTROLLER) { + field_0x46 = false; + } else { + field_0x3C = 120; + } + } else { + field_0x3C = 120; + } + } + field_0x3C--; + if (field_0x3C < 0) { + field_0x3C = 0; + } +} + +// . . . + +bool ex_c::isLowBattery() { + return getBatteryLevel() == 1; +} +bool ex_c::isOutOfBattery() { + return getBatteryLevel() == 0; +} + +void ex_c::resetInfo() { + for (int i = 0; i < 4; ++i) { + clearInfo(i); + } +} +void ex_c::clearInfo(s32 chan) { + m_connected[chan] = false; + m_info[0][chan].dpd = FALSE; + m_info[0][chan].speaker = FALSE; + m_info[0][chan].attach = FALSE; + m_info[0][chan].lowBat = FALSE; + m_info[0][chan].nearempty = FALSE; + m_info[0][chan].battery = 0; + m_info[0][chan].led = 0; + m_info[0][chan].protocol = 0; + m_info[0][chan].firmware = 0; +} +extern "C" void async_info_callback(WPADChannel chan, WPADResult result) { + switch (result) { + case WPAD_ERR_OK: { + ex_c::setInfo(chan, &ex_c::m_info[0][chan]); + break; + } + case WPAD_ERR_NO_CONTROLLER: { + ex_c::clearInfo(chan); + break; + } + case WPAD_ERR_BUSY: { + ex_c::m_ex[chan].field_0x46 = true; + ex_c::m_ex[chan].field_0x3C = 120; + break; + } + case WPAD_ERR_TRANSFER: { + ex_c::m_ex[chan].field_0x46 = true; + ex_c::m_ex[chan].field_0x3C = 120; + break; + } + } +} +s32 ex_c::getInfo(s32 chan) { + WPADResult res = WPADGetInfoAsync(chan, &ex_c::m_info[0][chan], async_info_callback); + if (res == WPAD_ERR_NO_CONTROLLER) { + clearInfo(chan); + } + return res; +} + +s32 ex_c::getBatteryLevel() { + return getBatteryLevel(mPad::g_currentCoreId); +} +s32 ex_c::getBatteryLevel(s32 chan) { + if (m_connected[chan]) { + return m_info[0][chan].battery; + } + return -1; +} + +void ex_c::setInfo(s32 chan, const WPADInfo *pInfo) { + m_info[0][chan].dpd = pInfo->dpd; + m_info[0][chan].speaker = pInfo->speaker; + m_info[0][chan].attach = pInfo->attach; + m_info[0][chan].lowBat = pInfo->lowBat; + m_info[0][chan].nearempty = pInfo->nearempty; + m_info[0][chan].battery = pInfo->battery; + m_info[0][chan].led = pInfo->led; + m_info[0][chan].protocol = pInfo->protocol; + m_info[0][chan].firmware = pInfo->firmware; + m_connected[chan] = true; +} +// . . . + +void ex_c::on_0x54(s32 idx) { + m_ex[idx].field_0x54[0] = true; +} +void ex_c::on_0x55(s32 idx) { + m_ex[idx].field_0x54[1] = true; +} +void ex_c::on_0x56(s32 idx) { + m_ex[idx].field_0x54[2] = true; +} +void ex_c::on_0x57(s32 idx) { + m_ex[idx].field_0x54[3] = 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; +} + +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]; + fn_800592D0(chan); +} + +void ex_c::getUnifiedWpadStatus(s32 chan) { + KPADGetUnifiedWpadStatus(chan, &mStatus, 1); +} + +void ex_c::fn_800593D0() { + field_0x22D1 = 0; + if (mFSStickDistance < 0.8f) { + field_0x22D4 = 0; + return; + } + u32 prev22D4 = field_0x22D4; + s32 ang = mFSStickAngle; + ang = ((ang + 0x11000) / 0x2000) % 8; + field_0x22D4 = 1 << ang; + if (field_0x22D4 != 0 && field_0x22D4 != prev22D4) { + field_0x22D1 = 1; + } +} + +void setNoSleep() { + WPADSetAutoSleepTime(0); +} + +void setAutoSleepTime() { + WPADSetAutoSleepTime(5); + WPADSetControllerLastDataUpdateTime(0); +} + +} // namespace dPad diff --git a/src/d/d_pad_ex.cpp b/src/d/d_pad_ex.cpp new file mode 100644 index 00000000..d4e66ddc --- /dev/null +++ b/src/d/d_pad_ex.cpp @@ -0,0 +1,270 @@ +#include "common.h" +#include "d/d_pad.h" +#include "egg/core/eggController.h" +#include "m/m_angle.h" +#include "m/m_pad.h" +#include "m/m_vec.h" + +namespace dPad { + +void fn_80059620() { + return; +} + +void fn_80059630() { + return; +} + +void fn_80059640() { + return; +} + +void fn_80059650() { + return; +} + +// GET DOWN TRIG + +bool getDownTrig(u32 btns) { + return mPad::g_currentCore->downTrigger(btns); +} + +bool getDownTrigA() { + return mPad::g_currentCore->downTrigger(mPad::BUTTON_A); +} + +bool getDownTrigB() { + return mPad::g_currentCore->downTrigger(mPad::BUTTON_B); +} + +bool getDownTrigC() { + return mPad::g_currentCore->downTrigger(mPad::BUTTON_C); +} + +bool getDownTrigZ() { + return mPad::g_currentCore->downTrigger(mPad::BUTTON_Z); +} + +bool getDownTrigUp() { + return mPad::g_currentCore->downTrigger(mPad::BUTTON_UP); +} + +bool getDownTrigDown() { + return mPad::g_currentCore->downTrigger(mPad::BUTTON_DOWN); +} + +bool getDownTrigLeft() { + return mPad::g_currentCore->downTrigger(mPad::BUTTON_LEFT); +} + +bool getDownTrigRight() { + return mPad::g_currentCore->downTrigger(mPad::BUTTON_RIGHT); +} + +bool getDownTrig1() { + return mPad::g_currentCore->downTrigger(mPad::BUTTON_1); +} + +bool getDownTrig2() { + return mPad::g_currentCore->downTrigger(mPad::BUTTON_2); +} + +bool getDownTrigMinus() { + return mPad::g_currentCore->downTrigger(mPad::BUTTON_MINUS); +} + +bool getDownTrigPlus() { + return mPad::g_currentCore->downTrigger(mPad::BUTTON_PLUS); +} + +// GET DOWN + +bool getDown(u32 btns) { + return mPad::g_currentCore->down(btns); +} +bool getDownAll(u32 btns) { + return mPad::g_currentCore->downAll(btns); +} +bool getDownA() { + return mPad::g_currentCore->down(mPad::BUTTON_A); +} +bool getDownB() { + return mPad::g_currentCore->down(mPad::BUTTON_B); +} +bool getDownC() { + return mPad::g_currentCore->down(mPad::BUTTON_C); +} +bool getDownZ() { + return mPad::g_currentCore->down(mPad::BUTTON_Z); +} +bool getDownUp() { + return mPad::g_currentCore->down(mPad::BUTTON_UP); +} +bool getDownDown() { + return mPad::g_currentCore->down(mPad::BUTTON_DOWN); +} +bool getDownLeft() { + return mPad::g_currentCore->down(mPad::BUTTON_LEFT); +} +bool getDownRight() { + return mPad::g_currentCore->down(mPad::BUTTON_RIGHT); +} +bool getDown1() { + return mPad::g_currentCore->down(mPad::BUTTON_1); +} +bool getDown2() { + return mPad::g_currentCore->down(mPad::BUTTON_2); +} +bool getDownMinus() { + return mPad::g_currentCore->down(mPad::BUTTON_MINUS); +} +bool getDownPlus() { + return mPad::g_currentCore->down(mPad::BUTTON_PLUS); +} + +// GET UP TRIG + +bool getUpTrig(u32 btns) { + return mPad::g_currentCore->upTrigger(btns); +} +bool getUpTrigA() { + return mPad::g_currentCore->upTrigger(mPad::BUTTON_A); +} +bool getUpTrigB() { + return mPad::g_currentCore->upTrigger(mPad::BUTTON_B); +} +bool getUpTrigC() { + return mPad::g_currentCore->upTrigger(mPad::BUTTON_C); +} +bool getUpTrigZ() { + return mPad::g_currentCore->upTrigger(mPad::BUTTON_Z); +} +bool getUpTrigUp() { + return mPad::g_currentCore->upTrigger(mPad::BUTTON_UP); +} +bool getUpTrigDown() { + return mPad::g_currentCore->upTrigger(mPad::BUTTON_DOWN); +} +bool getUpTrigLeft() { + return mPad::g_currentCore->upTrigger(mPad::BUTTON_LEFT); +} +bool getUpTrigRight() { + return mPad::g_currentCore->upTrigger(mPad::BUTTON_RIGHT); +} +bool getUpTrig1() { + return mPad::g_currentCore->upTrigger(mPad::BUTTON_1); +} +bool getUpTrig2() { + return mPad::g_currentCore->upTrigger(mPad::BUTTON_2); +} +bool getUpTrigMinus() { + return mPad::g_currentCore->upTrigger(mPad::BUTTON_MINUS); +} +bool getUpTrigPlus() { + return mPad::g_currentCore->upTrigger(mPad::BUTTON_PLUS); +} + +// GET UP + +bool getUp(u32 btns) { + return mPad::g_currentCore->up(btns); +} +bool getUpAll(u32 btns) { + return mPad::g_currentCore->upAll(btns); +} +bool getUpA() { + return mPad::g_currentCore->up(mPad::BUTTON_A); +} +bool getUpB() { + return mPad::g_currentCore->up(mPad::BUTTON_B); +} +bool getUpC() { + return mPad::g_currentCore->up(mPad::BUTTON_C); +} +bool getUpZ() { + return mPad::g_currentCore->up(mPad::BUTTON_Z); +} +bool getUpUp() { + return mPad::g_currentCore->up(mPad::BUTTON_UP); +} +bool getUpDown() { + return mPad::g_currentCore->up(mPad::BUTTON_DOWN); +} +bool getUpLeft() { + return mPad::g_currentCore->up(mPad::BUTTON_LEFT); +} +bool getUpRight() { + return mPad::g_currentCore->up(mPad::BUTTON_RIGHT); +} +bool getUp1() { + return mPad::g_currentCore->up(mPad::BUTTON_1); +} +bool getUp2() { + return mPad::g_currentCore->up(mPad::BUTTON_2); +} +bool getUpMinus() { + return mPad::g_currentCore->up(mPad::BUTTON_MINUS); +} +bool getUpPlus() { + return mPad::g_currentCore->up(mPad::BUTTON_PLUS); +} + +mVec2_c &getDpdPos() { + return ex_c::m_current_ex->mDpdPos; +} +mVec2_c &getDpdStableMaybe() { + return ex_c::m_current_ex->field_0x8; +} +mVec2_c &getFSStick() { + return ex_c::m_current_ex->mFSStick; +} +f32 getFSStickX() { + return ex_c::m_current_ex->mFSStick.x; +} +f32 getFSStickY() { + return ex_c::m_current_ex->mFSStick.y; +} +f32 getFSStickDistance() { + return ex_c::m_current_ex->mFSStickDistance; +} +mAng getFSStickAngle() { + return ex_c::m_current_ex->mFSStickAngle; +} +mVec3_c getAcc() { + const EGG::CoreStatus *status = mPad::g_currentCore->getCoreStatus(); + return mVec3_c(status->acc.x, status->acc.y, status->acc.z); +} + +u32 fn_80059B750() { + return ex_c::getInstance()->mMotion.field_0x10C8 >> 0 & 1; +} +u32 fn_80059B760() { + return ex_c::getInstance()->mMotion.field_0x10C8 >> 1 & 1; +} +u32 fn_80059B70() { + return ex_c::getInstance()->mMotion.field_0x10C8 >> 2 & 1; +} +u32 fn_80059B80() { + return ex_c::getInstance()->mMotion.field_0x10C8 >> 3 & 1; +} +u32 fn_80059B90() { + return ex_c::getInstance()->mMotion.field_0x10C8 >> 5 & 1; +} + +mVec3_c getFSAcc() { + if (mPad::g_padMg->getDevType(mPad::g_currentCoreId) == EGG::cDEV_FREESTYLE || + mPad::g_padMg->getDevType(mPad::g_currentCoreId) == EGG::cDEV_MPLS_PT_FS) { + const EGG::CoreStatus *status = mPad::g_currentCore->getCoreStatus(); + return mVec3_c(status->ex_status.fs.acc.x, status->ex_status.fs.acc.y, status->ex_status.fs.acc.z); + } else { + return mVec3_c(mVec3_c::Zero.x, mVec3_c::Zero.y, mVec3_c::Zero.z); + } +} +u32 fn_80059CC0() { + return ex_c::getInstance()->mFSMotion.field_0x10C8 >> 4 & 1; +} +u32 fn_80059CD0() { + return ex_c::getInstance()->mFSMotion.field_0x10C8 >> 5 & 1; +} + +} // namespace dPad diff --git a/src/d/d_sc_title.cpp b/src/d/d_sc_title.cpp index 7402456a..11fcbb41 100644 --- a/src/d/d_sc_title.cpp +++ b/src/d/d_sc_title.cpp @@ -4,6 +4,7 @@ #include "d/d_dvd_unk.h" #include "d/d_heap.h" #include "d/d_message.h" +#include "d/d_pad.h" #include "d/d_sc_game.h" #include "d/d_sys.h" #include "f/f_base.h" @@ -66,7 +67,6 @@ dScTitle_c::~dScTitle_c() { } extern "C" u32 TITLE_SCREEN_CHANGE; -extern "C" void fn_80059450(); extern "C" void fn_80058C90(s32); static const char *const sFileSelect = "FileSelect"; @@ -90,7 +90,7 @@ int dScTitle_c::create() { if (ret == SUCCEEDED) { dSys::setFrameRate(2); dSys::setClearColor(mColor(0x00000000)); - fn_80059450(); + dPad::setAutoSleepTime(); fn_80058C90(0); SaveRelated::create(); field_0x2AD = 0; diff --git a/src/d/d_textwindow_unk.cpp b/src/d/d_textwindow_unk.cpp index 07919f80..e26dc737 100644 --- a/src/d/d_textwindow_unk.cpp +++ b/src/d/d_textwindow_unk.cpp @@ -3,13 +3,13 @@ #include "d/d_textwindow_unk.h" #include "common.h" +#include "d/d_gfx.h" #include "d/d_message.h" #include "d/d_tag_processor.h" #include "d/d_textunk.h" #include "d/lyt/d_textbox.h" #include "d/lyt/msg_window/d_lyt_msg_window.h" #include "m/m_vec.h" -#include "toBeSorted/lyt_related_floats.h" #include "toBeSorted/other_sound_stuff.h" TextWindowUnk::TextWindowUnk(dTagProcessor_c *c) { @@ -89,7 +89,7 @@ void MsgWindowBlurRelated::drawTextBlur(dLytTextLight *thing, mVec2_c size, u8 a } else { mData[i].displayTimerMaybe = t; } - mVec3_c v((size.x + mData[i].posX) / get_805751A4(), size.y + mData[i].posY, 0.0f); + mVec3_c v((size.x + mData[i].posX) / dGfx_c::get16x9to4x3WidthScaleF(), size.y + mData[i].posY, 0.0f); thing->draw(mData[i].displayTimerMaybe, v, alpha, mData[i].field_0x08); } } diff --git a/src/d/lyt/d_lyt_area_caption.cpp b/src/d/lyt/d_lyt_area_caption.cpp index d15b9e1d..db56ea34 100644 --- a/src/d/lyt/d_lyt_area_caption.cpp +++ b/src/d/lyt/d_lyt_area_caption.cpp @@ -232,43 +232,43 @@ bool dLytAreaCaptionParts_c::shouldImmediatelyDismiss() const { return true; } - if (dPad::checkButtonBPressed()) { + if (dPad::getDownTrigB()) { return true; } - if (dLytMeter_c::GetInstance()->checkAllFlags(METER_BTN_C) && dPad::checkButtonCPressed()) { + if (dLytMeter_c::GetInstance()->checkAllFlags(METER_BTN_C) && dPad::getDownTrigC()) { return true; } - if (dLytMeter_c::GetInstance()->checkAllFlags(METER_BTN_PLUS) && dPad::checkButtonPlusPressed()) { + if (dLytMeter_c::GetInstance()->checkAllFlags(METER_BTN_PLUS) && dPad::getDownTrigPlus()) { return true; } - if (dPad::checkButtonMinusPressed()) { + if (dPad::getDownTrigMinus()) { return true; } - if (dLytMeter_c::GetInstance()->checkAllFlags(METER_BTN_1) && dPad::checkButton1Pressed()) { + if (dLytMeter_c::GetInstance()->checkAllFlags(METER_BTN_1) && dPad::getDownTrig1()) { return true; } - if (dLytMeter_c::GetInstance()->checkAllFlags(METER_BTN_2) && dPad::checkButton2Pressed()) { + if (dLytMeter_c::GetInstance()->checkAllFlags(METER_BTN_2) && dPad::getDownTrig2()) { return true; } - if (dPad::checkButtonDpadUpPressed()) { + if (dPad::getDownTrigUp()) { return true; } - if (dLytMeter_c::GetInstance()->checkAllFlags(METER_BTN_CROSS_DOWN) && dPad::checkButtonDpadDownPressed()) { + if (dLytMeter_c::GetInstance()->checkAllFlags(METER_BTN_CROSS_DOWN) && dPad::getDownTrigDown()) { return true; } - if (dLytMeter_c::GetInstance()->checkAllFlags(METER_BTN_CROSS_LEFT) && dPad::checkButtonDpadLeftPressed()) { + if (dLytMeter_c::GetInstance()->checkAllFlags(METER_BTN_CROSS_LEFT) && dPad::getDownTrigLeft()) { return true; } - if (dLytMeter_c::GetInstance()->checkAllFlags(METER_BTN_CROSS_RIGHT) && dPad::checkButtonDpadRightPressed()) { + if (dLytMeter_c::GetInstance()->checkAllFlags(METER_BTN_CROSS_RIGHT) && dPad::getDownTrigRight()) { return true; } diff --git a/src/d/lyt/d_lyt_battery.cpp b/src/d/lyt/d_lyt_battery.cpp index 5a522545..5884928d 100644 --- a/src/d/lyt/d_lyt_battery.cpp +++ b/src/d/lyt/d_lyt_battery.cpp @@ -1,6 +1,7 @@ #include "d/lyt/d_lyt_battery.h" #include "d/d_d2d.h" +#include "d/d_pad.h" #include "egg/core/eggController.h" #include "m/m_pad.h" #include "toBeSorted/arc_managers/layout_arc_manager.h" @@ -85,11 +86,8 @@ bool dLytBattery_c::dismissManually() { return true; } -extern "C" bool isLowBattery1(); -extern "C" bool isLowBattery2(); - bool dLytBattery_c::hasEnoughBatteryCharge() { - if (!mPad::g_currentCore->mFlag.offBit(0) && (isLowBattery2() || isLowBattery1())) { + if (mPad::getCore()->isConnected() && (dPad::ex_c::isLowBattery() || dPad::ex_c::isOutOfBattery())) { return false; } return true; diff --git a/src/d/lyt/d_textbox.cpp b/src/d/lyt/d_textbox.cpp index 950d2a63..ae6666ba 100644 --- a/src/d/lyt/d_textbox.cpp +++ b/src/d/lyt/d_textbox.cpp @@ -2,6 +2,7 @@ #include "common.h" #include "d/d_font_manager.h" +#include "d/d_gfx.h" #include "d/d_message.h" #include "d/d_tag_processor.h" #include "d/d_textunk.h" @@ -20,7 +21,6 @@ #include "rvl/GX/GXPixel.h" #include "rvl/GX/GXTev.h" #include "rvl/GX/GXTypes.h" -#include "toBeSorted/lyt_related_floats.h" #include @@ -442,7 +442,7 @@ f32 dTextBox_c::GetLinesHeight() const { } f32 dTextBox_c::GetUnkWidthRatio() const { - return GetLineWidth(nullptr) / get_805751A4(); + return GetLineWidth(nullptr) / dGfx_c::get16x9to4x3WidthScaleF(); } f32 dTextBox_c::resizeTextToFit(f32 maxWidth) { diff --git a/src/d/lyt/meter/d_lyt_meter_item_select.cpp b/src/d/lyt/meter/d_lyt_meter_item_select.cpp index a8f6452b..30e858cb 100644 --- a/src/d/lyt/meter/d_lyt_meter_item_select.cpp +++ b/src/d/lyt/meter/d_lyt_meter_item_select.cpp @@ -791,7 +791,7 @@ void dLytMeterItemSelect_c::finalizeState_SelectIn() { void dLytMeterItemSelect_c::initializeState_Select() {} void dLytMeterItemSelect_c::executeState_Select() { - if (dLytMeter_c::getCrossIconDown() == 0 && dPad::checkButtonDpadDownPressed()) { + if (dLytMeter_c::getCrossIconDown() == 0 && dPad::getDownTrigDown()) { if (field_0x5794 != I_INVALID) { field_0x5780 = 0.0f; mStateMgr.changeState(StateID_SetIn); diff --git a/src/d/lyt/meter/d_lyt_meter_z_btn.cpp b/src/d/lyt/meter/d_lyt_meter_z_btn.cpp index 935f78fe..81437458 100644 --- a/src/d/lyt/meter/d_lyt_meter_z_btn.cpp +++ b/src/d/lyt/meter/d_lyt_meter_z_btn.cpp @@ -186,14 +186,15 @@ bool dLytMeterZBtn_c::execute() { return true; } field_0x1C4 = true; - if ((!fn_80081FE0(dScGame_c::getCamera(0)->getField_0xD98(), "mogu") || AttentionManager::GetInstance()->checkLink2()) && + if ((!fn_80081FE0(dScGame_c::getCamera(0)->getField_0xD98(), "mogu") || + AttentionManager::GetInstance()->checkLink2()) && LytDoButtonRelated::get(LytDoButtonRelated::DO_BUTTON_Z) == 0x67) { field_0x1C4 = false; LytDoButtonRelated::set(LytDoButtonRelated::DO_BUTTON_Z, LytDoButtonRelated::ACT_IE_NONE); } field_0x1B4 = LytDoButtonRelated::get(LytDoButtonRelated::DO_BUTTON_Z); - field_0x1B8 = LytDoButtonRelated::getHas(LytDoButtonRelated::DO_BUTTON_Z) && - dLytMeter_c::GetInstance()->checkAllFlags(0x800); + field_0x1B8 = + LytDoButtonRelated::getHas(LytDoButtonRelated::DO_BUTTON_Z) && dLytMeter_c::GetInstance()->checkAllFlags(0x800); mStateMgr.executeState(); for (int i = 0; i < Z_BTN_NUM_ANIMS; i++) { @@ -204,7 +205,7 @@ bool dLytMeterZBtn_c::execute() { if (dLytControlGame_c::getInstance()->isStateNormal()) { if (StoryflagManager::sInstance->getCounterOrFlag(565)) { - if (dPad::checkButtonZPressed()) { + if (dPad::getDownTrigZ()) { field_0x1C5 = 0; StoryflagManager::sInstance->unsetFlag(565); } else { diff --git a/src/d/lyt/msg_window/d_lyt_msg_window.cpp b/src/d/lyt/msg_window/d_lyt_msg_window.cpp index 0d3d6739..a6a2940d 100644 --- a/src/d/lyt/msg_window/d_lyt_msg_window.cpp +++ b/src/d/lyt/msg_window/d_lyt_msg_window.cpp @@ -27,6 +27,7 @@ #include "d/lyt/d_lyt_auto_caption.h" // clang-format on +#include "d/d_gfx.h" #include "d/snd/d_snd_small_effect_mgr.h" #include "f/f_base.h" #include "m/m_fader_base.h" @@ -36,7 +37,6 @@ #include "toBeSorted/d_d3d.h" #include "toBeSorted/event_manager.h" #include "toBeSorted/fi_context.h" -#include "toBeSorted/lyt_related_floats.h" #include "toBeSorted/music_mgrs.h" #include "toBeSorted/other_sound_stuff.h" @@ -265,9 +265,14 @@ void dLytMsgWindow_c::initializeState_In() { param = 1; } else if (obj != nullptr && d3d::fn_80016A90(obj->poscopy2)) { d3d::fn_80016960(field_0x768, obj->poscopy2); - // TODO - stack and FPR problems - field_0x768 = mVec3_c(field_0x768.x, field_0x768.y, 0.0f); - if (field_0x768.y < get_8057511C() / 3.0f + get_80575134()) { + mVec3_c v = field_0x768; + v.z = 0.f; + field_0x768 = v; + f32 h, b; + h = dGfx_c::getCurrentScreenHeight(); + b = +dGfx_c::getCurrentScreenBottom(); + + if (v.y < b + (h / 3.f)) { param = 2; } } @@ -297,7 +302,7 @@ void dLytMsgWindow_c::executeState_OutputText() { if (field_0x815 == 0 && field_0x816 == 0) { mpMsgWindowUnk->textAdvancingRelated(false, true); - if (field_0x811 == 0 && dPad::checkButtonAHeld() && field_0x815 == 0 && field_0x816 == 0) { + if (field_0x811 == 0 && dPad::getDownA() && field_0x815 == 0 && field_0x816 == 0) { mpMsgWindowUnk->textAdvancingRelated(false, true); } } @@ -354,7 +359,7 @@ void dLytMsgWindow_c::executeState_WaitKeyChangePage0() { field_0x813 = 0; allowChange = true; } - } else if (dPad::checkButtonAPressed() || fn_8011A5D0()) { + } else if (dPad::getDownTrigA() || fn_8011A5D0()) { fn_8035E880(BGM_MGR); allowChange = true; } @@ -414,7 +419,7 @@ void dLytMsgWindow_c::executeState_WaitKeyMsgEnd0() { field_0x813 = 0; allowChange = true; } - } else if (dPad::checkButtonAPressed() || fn_8011A5D0()) { + } else if (dPad::getDownTrigA() || fn_8011A5D0()) { fn_8035E880(BGM_MGR); allowChange = true; } @@ -553,8 +558,7 @@ void dLytMsgWindow_c::finalizeState_MapOpen() {} void dLytMsgWindow_c::initializeState_WaitKeyMapClose() {} void dLytMsgWindow_c::executeState_WaitKeyMapClose() { - if ((dPad::checkButtonBPressed() || dPad::checkButtonPlusPressed()) && - !dLytControlGame_c::getInstance()->isNotInStateMap()) { + if ((dPad::getDownTrigB() || dPad::getDownTrigPlus()) && !dLytControlGame_c::getInstance()->isNotInStateMap()) { dLytControlGame_c::getInstance()->fn_802CCD40(true); mStateMgr.changeState(StateID_MapClose); } diff --git a/src/d/lyt/msg_window/d_lyt_msg_window_select_btn.cpp b/src/d/lyt/msg_window/d_lyt_msg_window_select_btn.cpp index 6ea90360..5adc3ef8 100644 --- a/src/d/lyt/msg_window/d_lyt_msg_window_select_btn.cpp +++ b/src/d/lyt/msg_window/d_lyt_msg_window_select_btn.cpp @@ -6,7 +6,6 @@ #include "d/snd/d_snd_small_effect_mgr.h" #include "toBeSorted/music_mgrs.h" - STATE_DEFINE(dLytMsgWindowSelectBtnParts_c, Wait); STATE_DEFINE(dLytMsgWindowSelectBtnParts_c, On); STATE_DEFINE(dLytMsgWindowSelectBtnParts_c, Select); @@ -328,7 +327,7 @@ void dLytMsgWindowSelectBtn_c::executeState_WaitSelect() { return; } - if (mBtnHelper.field_0x50 >= 0 && dPad::checkButtonAPressed()) { + if (mBtnHelper.field_0x50 >= 0 && dPad::getDownTrigA()) { field_0x9D0 = 0; field_0x9B0 = mBtnHelper.field_0x50; mStateMgr.changeState(StateID_WaitDecide); @@ -339,7 +338,7 @@ void dLytMsgWindowSelectBtn_c::executeState_WaitSelect() { dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_TALK_CURSOR_OK); } fn_8035E880(BGM_MGR); - } else if (dPad::checkButtonBPressed()) { + } else if (dPad::getDownTrigB()) { f32 f = mBtnHelper.fn_8011D690(field_0x9BC); // TODO field_0x9CC = field_0x9BC; diff --git a/src/d/lyt/msg_window/d_lyt_msg_window_sword.cpp b/src/d/lyt/msg_window/d_lyt_msg_window_sword.cpp index 7a7e755c..53c1d5a9 100644 --- a/src/d/lyt/msg_window/d_lyt_msg_window_sword.cpp +++ b/src/d/lyt/msg_window/d_lyt_msg_window_sword.cpp @@ -1,6 +1,7 @@ #include "d/lyt/msg_window/d_lyt_msg_window_sword.h" #include "common.h" +#include "d/d_gfx.h" #include "d/d_tag_processor.h" #include "d/d_textunk.h" #include "d/lyt/d2d.h" @@ -11,7 +12,6 @@ #include "nw4r/lyt/lyt_types.h" #include "nw4r/math/math_types.h" #include "s/s_State.hpp" -#include "toBeSorted/lyt_related_floats.h" STATE_DEFINE(dLytMsgWindowSword_c, Invisible); STATE_DEFINE(dLytMsgWindowSword_c, In); @@ -271,7 +271,8 @@ void dLytMsgWindowSword_c::draw() { mCharacterData[i].displayTimerMaybe += 1; } mVec3_c v( - (mOffset.x + mCharacterData[i].posX) / get_805751A4(), mOffset.y + mCharacterData[i].posY, 0.0f + (mOffset.x + mCharacterData[i].posX) / dGfx_c::get16x9to4x3WidthScaleF(), + mOffset.y + mCharacterData[i].posY, 0.0f ); wchar_t str[2]; diff --git a/src/d/snd/d_snd_player_mgr.cpp b/src/d/snd/d_snd_player_mgr.cpp index 4851d179..981f2150 100644 --- a/src/d/snd/d_snd_player_mgr.cpp +++ b/src/d/snd/d_snd_player_mgr.cpp @@ -7,6 +7,7 @@ #include "d/snd/d_snd_small_effect_mgr.h" #include "d/snd/d_snd_source_enums.h" #include "d/snd/d_snd_wzsound.h" +#include "egg/audio/eggAudioRmtSpeakerMgr.h" #include "egg/core/eggDvdRipper.h" #include "nw4r/snd/snd_SoundHandle.h" #include "nw4r/snd/snd_SoundStartable.h" @@ -72,6 +73,14 @@ void dSndPlayerMgr_c::leaveHelp() { dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_HELP_OUT); } +void dSndPlayerMgr_c::setup(s32 channel) { + EGG::AudioRmtSpeakerMgr::setup(channel, nullptr); +} + +void dSndPlayerMgr_c::shutdown(s32 channel) { + EGG::AudioRmtSpeakerMgr::shutdown(channel, nullptr); +} + nw4r::snd::SoundStartable::StartResult dSndPlayerMgr_c::startSound( nw4r::snd::SoundHandle *pHandle, u32 soundId, const nw4r::snd::SoundStartable::StartInfo *pStartInfo ) { @@ -118,10 +127,8 @@ bool dSndPlayerMgr_c::canUseThisPlayer(u8 sourceType) const { switch (sourceType) { case SND_SOURCE_PLAYER: case SND_SOURCE_PLAYER_HEAD: - case SND_SOURCE_58: - return true; - default: - return false; + case SND_SOURCE_58: return true; + default: return false; } } diff --git a/src/egg/audio/eggAudioRmtSpeakerMgr.cpp b/src/egg/audio/eggAudioRmtSpeakerMgr.cpp index af752d30..a60645e7 100644 --- a/src/egg/audio/eggAudioRmtSpeakerMgr.cpp +++ b/src/egg/audio/eggAudioRmtSpeakerMgr.cpp @@ -1,6 +1,7 @@ #include "egg/audio/eggAudioRmtSpeakerMgr.h" #include "nw4r/snd/snd_SoundSystem.h" + #include "rvl/OS.h" // IWYU pragma: export namespace EGG { @@ -21,7 +22,7 @@ void AudioRmtSpeakerMgr::setupCallback(s32 arg1, s32 arg2) { } sAudioRmtSpeakerWpadVolume = WPADGetSpeakerVolume(); } else { - fn_804B6D80(arg1, sTasks[mTaskFinishCount].mpCallback); + setup(arg1, sTasks[mTaskFinishCount].mpCallback); } sTasks[mTaskFinishCount].field_0x01 = true; } @@ -32,12 +33,12 @@ void AudioRmtSpeakerMgr::shutdownCallback(s32 arg1, s32 arg2) { (sTasks[mTaskFinishCount].mpCallback)(arg1, arg2); } } else { - fn_804B6DE0(arg1, sTasks[mTaskFinishCount].mpCallback); + shutdown(arg1, sTasks[mTaskFinishCount].mpCallback); } sTasks[mTaskFinishCount].field_0x01 = true; } -void AudioRmtSpeakerMgr::fn_804B6AF0(s32 i, WPADCallback *pCallback, bool enable) { +void AudioRmtSpeakerMgr::add_task(s32 i, WPADCallback *pCallback, bool enable) { BOOL intr = OSDisableInterrupts(); u32 index = mTaskRequestCount; @@ -52,14 +53,14 @@ void AudioRmtSpeakerMgr::fn_804B6AF0(s32 i, WPADCallback *pCallback, bool enable OSRestoreInterrupts(intr); } -void AudioRmtSpeakerMgr::fn_804B6B80(s32 i, WPADCallback *pCallback) { +void AudioRmtSpeakerMgr::doSetup(s32 i, WPADCallback *pCallback) { if (!nw4r::snd::SoundSystem::GetRemoteSpeaker(i).Setup(pCallback)) { - fn_804B6AF0(i, pCallback, true); + add_task(i, pCallback, true); sTasks[mTaskRequestCount].field_0x01 = true; } } -void AudioRmtSpeakerMgr::fn_804B6C00(s32 i, WPADCallback *pCallback) { +void AudioRmtSpeakerMgr::doShutdown(s32 i, WPADCallback *pCallback) { nw4r::snd::SoundSystem::GetRemoteSpeaker(i).Shutdown(pCallback); } @@ -67,9 +68,9 @@ void AudioRmtSpeakerMgr::calc() { if (!sTask) { if (mTaskRequestCount != mTaskFinishCount) { if (sTasks[mTaskFinishCount].field_0x00) { - fn_804B6B80(sTasks[mTaskFinishCount].mChannel, setupCallback); + doSetup(sTasks[mTaskFinishCount].mChannel, setupCallback); } else { - fn_804B6C00(sTasks[mTaskFinishCount].mChannel, shutdownCallback); + doShutdown(sTasks[mTaskFinishCount].mChannel, shutdownCallback); } sTask = true; } @@ -86,7 +87,7 @@ void AudioRmtSpeakerMgr::setupCallbackDirect(s32 arg1, s32 arg2) { if (arg2 == 0) { sAudioRmtSpeakerWpadVolume = WPADGetSpeakerVolume(); } else { - fn_804B6B80(arg1, setupCallbackDirect); + doSetup(arg1, setupCallbackDirect); } } @@ -97,17 +98,17 @@ void AudioRmtSpeakerMgr::shutdownCallbackDirect(s32 arg1, s32 arg2) { if (arg2 == 0) { return; } - fn_804B6C00(arg1, shutdownCallbackDirect); + doShutdown(arg1, shutdownCallbackDirect); } -void AudioRmtSpeakerMgr::fn_804B6D80(s32 i, WPADCallback *pCallback) { +void AudioRmtSpeakerMgr::setup(s32 i, WPADCallback *pCallback) { WPADDeviceType ty; if (!sAudioRmtSpeakerConnectCanncelSw && WPADProbe(i, &ty) != WPAD_ERR_NO_CONTROLLER) { - fn_804B6AF0(i, pCallback, true); + add_task(i, pCallback, true); } } -void AudioRmtSpeakerMgr::fn_804B6DE0(s32 i, WPADCallback *pCallback) { +void AudioRmtSpeakerMgr::shutdown(s32 i, WPADCallback *pCallback) { WPADDeviceType ty; if (!sAudioRmtSpeakerConnectCanncelSw) { if (WPADProbe(i, &ty) == WPAD_ERR_NO_CONTROLLER) { @@ -115,7 +116,7 @@ void AudioRmtSpeakerMgr::fn_804B6DE0(s32 i, WPADCallback *pCallback) { return; } } - fn_804B6AF0(i, pCallback, false); + add_task(i, pCallback, false); } } @@ -124,7 +125,7 @@ void AudioRmtSpeakerMgr::connectAllByForce() { sAudioRmtSpeakerConnectCanncelSw = false; for (int i = 0; i < 4; i++) { if (WPADProbe(i, &ty) != WPAD_ERR_NO_CONTROLLER) { - fn_804B6B80(i, setupCallbackDirect); + doSetup(i, setupCallbackDirect); } } } @@ -134,7 +135,7 @@ void AudioRmtSpeakerMgr::disconnectAllByForce() { for (int i = 0; i < 4; i++) { WPADProbe(i, &ty); // ignoring result here if (nw4r::snd::SoundSystem::GetRemoteSpeaker(i).IsAvailable()) { - fn_804B6C00(i, shutdownCallbackDirect); + doShutdown(i, shutdownCallbackDirect); } } sAudioRmtSpeakerConnectCanncelSw = true; diff --git a/src/egg/core/eggController.cpp b/src/egg/core/eggController.cpp index bcc0c551..0fb022ac 100644 --- a/src/egg/core/eggController.cpp +++ b/src/egg/core/eggController.cpp @@ -5,16 +5,20 @@ #include "egg/core/eggExpHeap.h" #include "egg/core/eggSystem.h" #include "egg/math/eggMath.h" -#include "rvl/VI.h" // IWYU pragma: export +#include "egg/math/eggVector.h" +#include "rvl/WPAD/WPAD.h" #include "string.h" -EGG::NullController null_controller; +#include "rvl/VI.h" // IWYU pragma: export + namespace EGG { +NullController null_controller; + CoreControllerMgr *CoreControllerMgr::sInstance; CoreControllerMgr::T__Disposer *CoreControllerMgr::T__Disposer::sStaticDisposer; -ControllerFactory CoreControllerMgr::sCoreControllerFactory; -ConnectCallback CoreControllerMgr::sConnectCallback; +CoreControllerFactory CoreControllerMgr::sCoreControllerFactory; +CoreControllerConnectCallback CoreControllerMgr::sConnectCallback; // This controls whether EggController registers an allocator within the WPAD driver bool CoreControllerMgr::sUseBuiltinWpadAllocator; s32 CoreControllerMgr::sWPADWorkSize = 0x32000; @@ -23,7 +27,7 @@ void CoreStatus::init() { memset(this, 0, sizeof(CoreStatus)); } -u32 CoreStatus::getFSStickButton() const { +u32 CoreStatus::getFSStickButton() { f32 stick = getFSStickX(); u32 result = 0; @@ -51,47 +55,47 @@ u32 CoreStatus::getFSStickButton() const { return result; } -CoreController::CoreController() : mDpdPos(), mAccel(), mAccelFlags(), mFlag(0) { +CoreController::CoreController() : mDpdPosPrev(), mStableAccel(), mFlag(0) { mRumbleMgr = nullptr; - mButtonHeld = 0; - mButtonTriggered = 0; - mButtonReleased = 0; + mFSStickHold = 0; + mFSStickTrig = 0; + mFSStickRelease = 0; sceneReset(); mFlag.makeAllZero(); } void CoreController::sceneReset() { - mAccel.set(0.0, 0.0, 0.0); - mDpdPos.x = 0.0f; - mDpdPos.y = 0.0f; + mAccelPrev.set(0.0, 0.0, 0.0); + mDpdPosPrev.x = 0.0f; + mDpdPosPrev.y = 0.0f; mIdleTime = 0; mPostureMatrixPrev.makeIdentity(); mPostureMatrix.makeIdentity(); - mMaxAccelFrameTime = 10; - mMaxAccelDiff = 0.13; - mPrevAccel.set(0.0, 0.0, 0.0); - mAccelFlags.makeAllZero(); - mAccelFrameTime[2] = 0; - mAccelFrameTime[1] = 0; - mAccelFrameTime[0] = 0; - mMotorPattern = 0; - mMotorFrameDuration = 0; - mEnableMotor = false; - mMotorPatternLength = 0x20; - mMotorPatternPos = 0x1f; + mStableFrame = 10; + mStableMag = 0.13; + mStableAccel.set(0.0, 0.0, 0.0); + mStableFlags = 0; + mStableTimer[2] = 0; + mStableTimer[1] = 0; + mStableTimer[0] = 0; + mSimpleRumblePattern = 0; + mSimpleRumbleFrame = 0; + mEnableSimpleRumble = false; + mSimpleRumbleSize = 0x20; + mSimpleRumbleIndex = 0x1f; stopRumbleMgr(); } Vector2f CoreController::getDpdRawPos() { - return Vector2f(mCoreStatus[0].mDpdRawX, mCoreStatus[0].mDpdRawY); + return Vector2f(mCoreStatus[0].pos.x, mCoreStatus[0].pos.y); } f32 CoreController::getDpdDistance() { - return mCoreStatus[0].mDpdDistance; + return mCoreStatus[0].dist; } s32 CoreController::getDpdValidFlag() { - return mCoreStatus[0].getDpdValidFlag(); + return mCoreStatus[0].getDPDValidFlag(); } void CoreController::startMotor() { @@ -169,15 +173,15 @@ void CoreController::calc_posture_matrix(Matrix34f &posture, bool checkStable) { void CoreController::beginFrame(PADStatus *padStatus) { s32 kpad_result; - mReadStatusIdx = KPADReadEx(mChannelID, mCoreStatus, 0x10, &kpad_result); - if (mReadStatusIdx == 0 && kpad_result == -1 /* Rvl usually uses negative nums for results */) { - mReadStatusIdx = 1; + mKPADReadLength = KPADReadEx(mChannelID, mCoreStatus, 0x10, &kpad_result); + if (mKPADReadLength == 0 && kpad_result == WPAD_ERR_NO_CONTROLLER) { + mKPADReadLength = 1; } WPADDeviceType dev_type; switch (WPADProbe(mChannelID, &dev_type)) { case WPAD_ERR_OK: { - if ((u32)dev_type == WPAD_DEV_NONE) { + if ((u32)dev_type == WPAD_DEV_NOT_FOUND) { mFlag.resetBit(0); } else { mFlag.setBit(0); @@ -188,59 +192,59 @@ void CoreController::beginFrame(PADStatus *padStatus) { } break; } - if (mReadStatusIdx > 0) { + if (mKPADReadLength > 0) { CoreStatus *pStatus = mCoreStatus; - u32 prev_held = mButtonHeld; + u32 prev_held = mFSStickHold; if (pStatus->isFreestyle()) { - mButtonHeld = pStatus->getFSStickButton(); + mFSStickHold = pStatus->getFSStickButton(); } else { - mButtonHeld = 0; + mFSStickHold = 0; } - mButtonTriggered = mButtonHeld & ~prev_held; - mButtonReleased = prev_held & ~mButtonHeld; - pStatus->mHold &= ~0xF0000; - pStatus->mTrig &= ~0xF0000; - pStatus->mRelease &= ~0xF0000; - pStatus->mHold |= (mButtonHeld & 0xF0000); - pStatus->mTrig |= (mButtonTriggered & 0xF0000); - pStatus->mRelease |= (mButtonReleased & 0xF0000); + mFSStickTrig = mFSStickHold & ~prev_held; + mFSStickRelease = prev_held & ~mFSStickHold; + pStatus->hold &= ~0xF0000; + pStatus->trig &= ~0xF0000; + pStatus->release &= ~0xF0000; + pStatus->hold |= (mFSStickHold & 0xF0000); + pStatus->trig |= (mFSStickTrig & 0xF0000); + pStatus->release |= (mFSStickRelease & 0xF0000); } mPostureMatrixPrev.copyFrom(mPostureMatrix); - mAccelFlags.makeAllZero(); + mStableFlags = 0; Vector3f acc = mCoreStatus->getAccel(); for (int i = 0; i < 3; i++) { - if (acc(i) - mAccel(i) < mMaxAccelDiff) { - if (mMaxAccelFrameTime <= ++mAccelFrameTime[i]) { - mAccelFrameTime[i] = mMaxAccelFrameTime; - mAccelFlags.set(1 << i); - mPrevAccel(i) = acc(i); + if (acc(i) - mAccelPrev(i) < mStableMag) { + if (mStableFrame <= ++mStableTimer[i]) { + mStableTimer[i] = mStableFrame; + mStableFlags |= (1 << i); + mStableAccel(i) = acc(i); } } else { - mAccelFlags.value &= ~(1 << i); // ? - mAccelFrameTime[i] = 0; + mStableFlags &= ~(1 << i); + mStableTimer[i] = 0; } } calc_posture_matrix(mPostureMatrix, true); - if (mEnableMotor) { - if (mMotorPattern & (1 << mMotorPatternPos)) { + if (mEnableSimpleRumble) { + if (mSimpleRumblePattern & (1 << mSimpleRumbleIndex)) { startMotor(); } else { stopMotor(); } - if (mMotorPatternPos == 0) { - mMotorPatternPos = mMotorPatternLength - 1; + if (mSimpleRumbleIndex == 0) { + mSimpleRumbleIndex = mSimpleRumbleSize - 1; } else { - mMotorPatternPos = mMotorPatternPos - 1; + mSimpleRumbleIndex = mSimpleRumbleIndex - 1; } - if (--mMotorFrameDuration == 0) { + if (--mSimpleRumbleFrame == 0) { stopMotor(); - mEnableMotor = false; + mEnableSimpleRumble = false; } } @@ -254,13 +258,13 @@ void CoreController::beginFrame(PADStatus *padStatus) { } if (increment) { - Vector3f diff = (mAccel - mCoreStatus->getAccel()); + Vector3f diff = (mAccelPrev - mCoreStatus->getAccel()); if (diff.squaredLength() > 0.01f) { increment = false; } } if (increment) { - Vector2f diff = (mDpdPos - getDpdRawPos()); + Vector2f diff = (mDpdPosPrev - getDpdRawPos()); if (diff.squaredLength() > 0.05f) { increment = false; } @@ -278,8 +282,8 @@ void CoreController::beginFrame(PADStatus *padStatus) { } void CoreController::endFrame() { - mAccel = getAccel(); - mDpdPos = getDpdRawPos(); + mAccelPrev = *reinterpret_cast(&mCoreStatus[0].acc); + mDpdPosPrev = getDpdRawPos(); } /* 0x80499AC0 */ @@ -343,7 +347,7 @@ int free(void *ptr) { /* 0x80499CD0 */ void CoreControllerMgr::connectCallback(s32 a1, s32 a2) { - int args[] = {a1, a2}; + CoreControllerConnectArg args = {a1, a2}; if (sConnectCallback != nullptr) { (sConnectCallback)(args); } @@ -393,7 +397,7 @@ void CoreControllerMgr::beginFrame() { /* 0x8049A1E0 */ void CoreControllerMgr::endFrame() { - for (int i = 0; i < mControllers.mSize; i++) { + for (int i = 0; i < mControllers.getSize(); i++) { mControllers(i)->endFrame(); WPADDeviceType dev_type; @@ -403,7 +407,7 @@ void CoreControllerMgr::endFrame() { if (result == WPAD_ERR_OK) { res_dev_type = dev_type; } else if (result == WPAD_ERR_NO_CONTROLLER) { - res_dev_type = WPAD_DEV_NONE; + res_dev_type = WPAD_DEV_NOT_FOUND; } else { continue; } @@ -425,77 +429,77 @@ void CoreControllerMgr::endFrame() { /* 0x8049A3B0 */ void ControllerRumbleUnit::init() { - mPattern = nullptr; - mPatternPos = nullptr; - mTimer = 0; - mIntensity = 0.0f; - mRampUp = 0.0f; - mFlag.makeAllZero(); + mRumblePattern = nullptr; + mRumblePatternPtr = nullptr; + mRumbleFrame = 0; + mRumbleValue = 0.0f; + mRumblePower = 0.0f; + mFlags.makeAllZero(); } /* 0x8049A3E0 */ void ControllerRumbleUnit::startPattern(const char *pattern, int duration) { - mPattern = pattern; - mPatternPos = pattern; + mRumblePattern = pattern; + mRumblePatternPtr = pattern; - mFlag.value &= 0xef; - mFlag.value &= 0xdf; + mFlags.value &= 0xef; + mFlags.value &= 0xdf; if (duration < 0) { - mFlag.set(0x10); + mFlags.set(0x10); } else if (duration > 0) { - mFlag.set(0x30); + mFlags.set(0x30); } - mTimer = duration; + mRumbleFrame = duration; - mFlag.setBit(0); - mFlag.resetBit(1); - mFlag.setBit(3); + mFlags.setBit(0); + mFlags.resetBit(1); + mFlags.setBit(3); } /* 0x8049A440 */ f32 ControllerRumbleUnit::calc() { f32 result = 0.0f; - if (mFlag.onBit(3)) { - if (mFlag.onBit(0)) { - char x = *++mPatternPos; + if (mFlags.onBit(3)) { + if (mFlags.onBit(0)) { + char x = *++mRumblePatternPtr; if (x == '\0') { - if (mFlag.onBit(4)) { - mPatternPos = mPattern; + if (mFlags.onBit(4)) { + mRumblePatternPtr = mRumblePattern; } else { - mFlag.resetBit(3); + mFlags.resetBit(3); } } else if (x == '*') { result = 1.0f; } - if (mFlag.offBit(5)) { + if (mFlags.offBit(5)) { return result; } - if (--mTimer > 0) { + if (--mRumbleFrame > 0) { return result; } - mFlag.resetBit(3); + mFlags.resetBit(3); return result; } else { - f32 intensity = mIntensity + mRampUp; - mIntensity = intensity; + f32 intensity = mRumbleValue + mRumblePower; + mRumbleValue = intensity; if (intensity >= 1.0f) { result = 1.0f; - mIntensity = 0.0f; + mRumbleValue = 0.0f; } - if (mFlag.onBit(2)) { + if (mFlags.onBit(2)) { return result; } - if (--mTimer > 0) { + if (--mRumbleFrame > 0) { return result; } } - mFlag.resetBit(3); + mFlags.resetBit(3); return result; } else { return -1.0f; @@ -506,14 +510,14 @@ f32 ControllerRumbleUnit::calc() { ControllerRumbleMgr::ControllerRumbleMgr() { mController = nullptr; List_Init(&mActiveUnitList, offsetof(ControllerRumbleUnit, mNode)); - List_Init(&mInactiveUnitList, offsetof(ControllerRumbleUnit, mNode)); + List_Init(&mStoppedUnitList, offsetof(ControllerRumbleUnit, mNode)); } /* 0x8049A590 */ void ControllerRumbleMgr::createUnit(u8 numUnits, CoreController *ctrl) { for (u8 created = 0; created < numUnits; created++) { ControllerRumbleUnit *unit = new ControllerRumbleUnit(); - List_Append(&mInactiveUnitList, unit); + List_Append(&mStoppedUnitList, unit); } mController = ctrl; } @@ -524,7 +528,7 @@ void ControllerRumbleMgr::stop() { while (List_GetSize(&mActiveUnitList) != 0) { ControllerRumbleUnit *unit = static_cast(List_GetNext(&mActiveUnitList, nullptr)); List_Remove(&mActiveUnitList, unit); - List_Append(&mInactiveUnitList, unit); + List_Append(&mStoppedUnitList, unit); } } @@ -540,7 +544,7 @@ void ControllerRumbleMgr::calc() { void *nextObject = List_GetNext(&mActiveUnitList, object); if (x < 0.0f) { List_Remove(&mActiveUnitList, object); - List_Append(&mInactiveUnitList, object); + List_Append(&mStoppedUnitList, object); } else { acc += x; } @@ -565,9 +569,9 @@ void ControllerRumbleMgr::startPattern(const char *pattern, int duration, bool b /* 0x8049A7F0 */ ControllerRumbleUnit *ControllerRumbleMgr::getUnitFromList(bool bGrabActive) { - void *first = List_GetFirst(&this->mInactiveUnitList); + void *first = List_GetFirst(&this->mStoppedUnitList); if (first) { - List_Remove(&mInactiveUnitList, first); + List_Remove(&mStoppedUnitList, first); List_Append(&mActiveUnitList, first); } else if (bGrabActive && (first = List_GetFirst(&mActiveUnitList), first != nullptr)) { List_Remove(&mActiveUnitList, first); diff --git a/src/egg/util/eggException.cpp b/src/egg/util/eggException.cpp index b02caae4..5d4c97c7 100644 --- a/src/egg/util/eggException.cpp +++ b/src/egg/util/eggException.cpp @@ -7,6 +7,7 @@ #include "nw4r/db/db_directPrint.h" #include "nw4r/db/db_exception.h" #include "nw4r/db/db_mapFile.h" + #include "rvl/KPAD.h" // IWYU pragma: export #include "rvl/OS.h" // IWYU pragma: export @@ -52,9 +53,9 @@ bool Exception::ExceptionCallback_(nw4r::db::ConsoleHandle console, void *data) while (((u16 *)data)[u4] != 0) { KPADRead(0, &status, 1); ExceptionWaitTime(50); - if (status.mTrig) { + if (status.trig) { // Reset the sequence on wrong button press, advance on right button press - u4 = status.mTrig & (((u16 *)data)[u4]) ? u4 + 1 : 0; + u4 = status.trig & (((u16 *)data)[u4]) ? u4 + 1 : 0; } } } @@ -79,7 +80,7 @@ bool Exception::ExceptionCallback_(nw4r::db::ConsoleHandle console, void *data) while (true) { KPADRead(0, &status, 1); ExceptionWaitTime(100); - if (status.mTrig & (/* HOME */ 0x8000)) { + if (status.trig & cCORE_BUTTON_HOME) { sUserCallbackMode = !sUserCallbackMode; } if (sUserCallbackMode && sUserCallbackFunc != nullptr) { @@ -91,22 +92,22 @@ bool Exception::ExceptionCallback_(nw4r::db::ConsoleHandle console, void *data) ; prevY = newY; - if (status.mHold & (/* DPAD_DOWN */ 0x4)) { + if (status.hold & cCORE_BUTTON_DOWN) { newY += 1; if (newY > end) { newY = end; } - } else if (status.mHold & (/* DPAD_UP */ 0x8)) { + } else if (status.hold & cCORE_BUTTON_UP) { newY -= 1; if (newY < start) { newY = start; } - } else if (status.mHold & (/* DPAD_RIGHT */ 0x2)) { + } else if (status.hold & cCORE_BUTTON_RIGHT) { newX -= 5; if (newX < -150) { newX = -150; } - } else if (status.mHold & (/* DPAD_LEFT */ 0x1)) { + } else if (status.hold & cCORE_BUTTON_LEFT) { newX += 5; if (newX > 10) { newX = 10; diff --git a/src/m/m_pad.cpp b/src/m/m_pad.cpp index b277c448..5c1afd84 100644 --- a/src/m/m_pad.cpp +++ b/src/m/m_pad.cpp @@ -1,10 +1,11 @@ #include "m/m_pad.h" #include "common.h" +#include "d/d_pad.h" #include "egg/core/eggController.h" #include "egg/math/eggVector.h" -#include "rvl/WPAD.h" // IWYU pragma: export +#include "rvl/WPAD.h" // IWYU pragma: export namespace mPad { @@ -38,7 +39,7 @@ static void clearWPADInfo(int); static int getWPADInfoCB(int controller); void create() { - g_padMg = EGG::CoreControllerMgr::sInstance; + g_padMg = EGG::CoreControllerMgr::instance(); initWPADInfo(); beginPad(); endPad(); @@ -62,10 +63,10 @@ void beginPad() { for (; i < 4; i++) { ctl = g_padMg->getNthController(i); *p_ctl = ctl; - if (ctl->mFlag.onBit(0)) { + if (ctl->isConnected()) { // These sort of look like value, first order derivative, and second order derivative // So perhaps value, velocity, acceleration? - EGG::Vector2f pos = ctl->mCoreStatus[0].getUnk(); + EGG::Vector2f pos = ctl->getCoreStatus()->getAccelVertical(); EGG::Vector2f v = pos - dat->v1; dat->v1 = pos; dat->v3 = v - dat->v2; @@ -81,7 +82,7 @@ void beginPad() { getWPADInfoCB(i); } } else if (*connected) { - ctl->mCoreStatus->init(); + ctl->getCoreStatus()->init(); ctl->sceneReset(); dat->v1.x = 0.0f; dat->v1.y = 0.0f; @@ -134,10 +135,8 @@ static void initWPADInfo() { } } -extern "C" void fn_80058DA0(s32, s32); - static int getWPADInfoCB(int controller) { - int result = WPADGetInfoAsync(controller, &s_WPADInfoTmp[controller], fn_80058DA0); + int result = WPADGetInfoAsync(controller, &s_WPADInfoTmp[controller], async_info_callback); if (result == -1) { clearWPADInfo(controller); } diff --git a/src/toBeSorted/attention.cpp b/src/toBeSorted/attention.cpp index d7b17d1f..b26c9ee4 100644 --- a/src/toBeSorted/attention.cpp +++ b/src/toBeSorted/attention.cpp @@ -140,11 +140,11 @@ bool AttentionManager::isInNormalGameState() const { } bool AttentionManager::isZButtonPressed() const { - return dPad::checkButtonZPressed(); + return dPad::getDownTrigZ(); } bool AttentionManager::isZButtonHeld() const { - return dPad::checkButtonZHeld(); + return dPad::getDownZ(); } bool AttentionManager::checkUnknown() const { diff --git a/src/toBeSorted/d_emitter.cpp b/src/toBeSorted/d_emitter.cpp index a8b0379f..28ce1387 100644 --- a/src/toBeSorted/d_emitter.cpp +++ b/src/toBeSorted/d_emitter.cpp @@ -2,6 +2,7 @@ // vtable order #include "JSystem/JParticle/JPAEmitter.h" #include "JSystem/JParticle/JPAParticle.h" +#include "d/d_gfx.h" #include "rvl/GX/GXTypes.h" #include "toBeSorted/d_d3d.h" // clang-format on @@ -40,12 +41,10 @@ #include "toBeSorted/d_d3d.h" #include "toBeSorted/d_particle.h" #include "toBeSorted/event_manager.h" -#include "toBeSorted/lyt_related_floats.h" #include "rvl/GX.h" #include "rvl/MTX.h" - void float_ordering_1(s32 a) { (f32) a; } @@ -465,15 +464,18 @@ void dEffect2D_c::draw() { f32 proj[GX_PROJECTION_SZ]; GXGetProjectionv(proj); f32 base = proj[1]; - proj[1] = base / get_805751A4(); + proj[1] = base / dGfx_c::get16x9to4x3WidthScaleF(); GXSetProjectionv(proj); - f32 f = get_80575184() / 2; + f32 f = dGfx_c::getWidth16x9() / 2.f; mMtx_c mtx1, mtx2; JPADrawInfo info; - C_MTXLightOrtho(mtx1, -get_80575150(), get_80575150(), -f, f, 0.5f, 0.5f, 0.5f, 0.5f); + C_MTXLightOrtho( + mtx1, -dGfx_c::getCurrentScreenHeightLimitF(), dGfx_c::getCurrentScreenHeightLimitF(), -f, f, 0.5f, 0.5f, 0.5f, + 0.5f + ); - MTXScale(mtx2, fn_80054AD0() ? get_805751A4() : 1.0f, 1.0f, 1.0f); + MTXScale(mtx2, fn_80054AD0() ? dGfx_c::get16x9to4x3WidthScaleF() : 1.0f, 1.0f, 1.0f); MTXCopy(mtx2, info.mCamMtx); MTXCopy(mtx1, info.mPrjMtx); dJEffManager_c::draw(&info, mGroupId); @@ -1030,7 +1032,6 @@ bool dJEffManager_c::createMassObjEffect( void dEmitterBase_c::loadColors( JPABaseEmitter *emitter, const GXColor *color1, const GXColor *color2, s32 plltIdx1, s32 plltIdx2 ) { - dLightEnv_c &mgr = dLightEnv_c::GetInstance(); u8 r1 = 0xFF; u8 g1 = 0xFF; u8 b1 = 0xFF; @@ -1039,6 +1040,7 @@ void dEmitterBase_c::loadColors( u8 b2 = 0xFF; u8 r, g, b; + dLightEnv_c &mgr = dLightEnv_c::GetInstance(); const mColor c1 = mgr.GetCurrentSpf().mParticleTransparentClr; const mColor c2 = mgr.GetCurrentSpf().mParticleSolidClr; @@ -1073,22 +1075,22 @@ void dEmitterBase_c::loadColors( if (plltIdx1 > 0) { if ((flags & 0x1000) != 0) { - const PaletteEAF_smol_entry &entry = mgr.getSmallEAF(plltIdx1 - 1, plltIdx2); - r1 = entry.field_0x00.r; - g1 = entry.field_0x00.g; - b1 = entry.field_0x00.b; + const mColor &entry = mgr.getSmallEAF(plltIdx1 - 1, plltIdx2).field_0x00; + r1 = entry.r; + g1 = entry.g; + b1 = entry.b; } else if ((flags & 0x2000) != 0) { - const PaletteEAF_smol_entry &entry = mgr.getSmallEAF(plltIdx1 - 1, plltIdx2); - r1 = entry.field_0x08.r; - g1 = entry.field_0x08.g; - b1 = entry.field_0x08.b; + const mColor &entry = mgr.getSmallEAF(plltIdx1 - 1, plltIdx2).field_0x08; + r1 = entry.r; + g1 = entry.g; + b1 = entry.b; } } if (factor != 0) { - r = mgr.getfield_0x2F14() * r1 * scaleR; - g = mgr.getfield_0x2F18() * g1 * scaleG; - b = mgr.getfield_0x2F1C() * b1 * scaleB; + r = r1 * scaleR * mgr.getfield_0x2F14(); + g = g1 * scaleG * mgr.getfield_0x2F18(); + b = b1 * scaleB * mgr.getfield_0x2F1C(); } else { r = r1 * scaleR; g = g1 * scaleG; @@ -1105,15 +1107,15 @@ void dEmitterBase_c::loadColors( if (plltIdx1 > 0) { if ((flags & 0x1000) != 0) { - const PaletteEAF_smol_entry &entry = mgr.getSmallEAF(plltIdx1 - 1, plltIdx2); - r2 = entry.field_0x04.r; - g2 = entry.field_0x04.g; - b2 = entry.field_0x04.b; + const mColor &entry = mgr.getSmallEAF(plltIdx1 - 1, plltIdx2).field_0x04; + r2 = entry.r; + g2 = entry.g; + b2 = entry.b; } else if ((flags & 0x2000) != 0) { - const PaletteEAF_smol_entry &entry = mgr.getSmallEAF(plltIdx1 - 1, plltIdx2); - r2 = entry.field_0x0C.r; - g2 = entry.field_0x0C.g; - b2 = entry.field_0x0C.b; + const mColor &entry = mgr.getSmallEAF(plltIdx1 - 1, plltIdx2).field_0x0C; + r2 = entry.r; + g2 = entry.g; + b2 = entry.b; } } @@ -1232,14 +1234,11 @@ dEmitterBase_c *dJEffManager_c::spawnGroundEffect( mtx.makeRotationFromVecs(mVec3_c::Ey, v1, 1.0f); mAng rot(cM::rndF(65536.0f)); mtx.YrotM(rot); - mtx.m[0][3] = pos.x; - mtx.m[1][3] = pos.y; - mtx.m[2][3] = pos.z; + mtx.setTranslation(pos); mMtx_c scaleMtx; MTXScale(scaleMtx, scale, scale, scale); MTXConcat(mtx, scaleMtx, mtx); - u16 eff = sEffArray[idx][unk]; - return spawnEffect(eff, mtx, nullptr, nullptr, polyAttr0, polyAttr1); + return spawnEffect(sEffArray[idx][unk], mtx, nullptr, nullptr, polyAttr0, polyAttr1); } void dWaterEffect_c::init(dAcObjBase_c *base, f32 height, f32 scale, f32 f3) { diff --git a/src/toBeSorted/fi_context.cpp b/src/toBeSorted/fi_context.cpp index cf4584d8..8f0c7b06 100644 --- a/src/toBeSorted/fi_context.cpp +++ b/src/toBeSorted/fi_context.cpp @@ -3,6 +3,7 @@ #include "common.h" #include "d/a/d_a_item.h" #include "d/d_message.h" +#include "d/d_pad.h" #include "d/d_pouch.h" #include "d/d_sc_game.h" #include "d/d_stage_mgr.h" @@ -13,6 +14,7 @@ #include "toBeSorted/file_manager.h" #include "toBeSorted/unk_save_time.h" + // https://github.com/lepelog/skywardsword-tools/wiki/Navi-Table-(Fi-Advice) // Portability hazard, only works for 32 bit architectures @@ -290,9 +292,6 @@ u8 FiContext::rateBattlePerformance(u8 id) { return ret; } -extern "C" bool isLowBattery1(); -extern "C" bool isLowBattery2(); - u16 FiContext::prepareFiHelpIndex() { u16 ret = 0xFFFF; setHelpIndex(-1); @@ -317,10 +316,10 @@ u16 FiContext::prepareFiHelpIndex() { setHelpIndex(0); } - if (isLowBattery2() || isLowBattery1()) { + if (dPad::ex_c::getInstance()->isLowBattery() || dPad::ex_c::getInstance()->isOutOfBattery()) { if (!getField_0x48()) { ret = 6400; - if (isLowBattery1()) { + if (dPad::ex_c::getInstance()->isOutOfBattery()) { // "Master, the batteries in your Wii Remote will be depleted any moment." setHelpIndex(3); } else {