From 415873f7b34faa42ead43e620c591842dadee68e Mon Sep 17 00:00:00 2001 From: robojumper Date: Wed, 30 Jul 2025 21:44:01 +0200 Subject: [PATCH 1/4] d_pad_manager WIP --- config/SOUE01/splits.txt | 6 +- config/SOUE01/symbols.txt | 106 ++-- configure.py | 2 +- include/d/d_cs_base.h | 10 +- include/d/d_dvd_unk.h | 1 + include/d/d_gfx.h | 5 + include/d/d_pad.h | 10 +- include/d/d_pad_manager.h | 108 ++++ include/d/d_pause.h | 23 - include/d/lyt/d_lyt_battery.h | 4 + include/d/lyt/d_lyt_system_window.h | 57 ++ include/toBeSorted/save_manager.h | 1 + src/REL/d/d_s_boot.cpp | 5 +- src/d/d_pad.cpp | 10 +- src/d/d_pad_manager.cpp | 798 ++++++++++++++++++++++++++++ 15 files changed, 1056 insertions(+), 90 deletions(-) create mode 100644 include/d/d_pad_manager.h delete mode 100644 include/d/d_pause.h create mode 100644 src/d/d_pad_manager.cpp diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index f86ffcfa..1794e3e7 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -250,8 +250,12 @@ d/d_pad.cpp: d/d_pad_ex.cpp: .text start:0x80059620 end:0x80059CE0 align:16 -d/d_pause_manager.cpp: +d/d_pad_manager.cpp: .text start:0x80059CE0 end:0x8005B6D4 align:16 + .rodata start:0x804DE188 end:0x804DE1E8 + .data start:0x8050D458 end:0x8050D620 + .sdata start:0x80571C68 end:0x80571C70 + .sdata2 start:0x80577008 end:0x80577010 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 8bf8ce41..77a7fe84 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -2164,7 +2164,7 @@ fn_80052C60__Q27dDvdUnk7FontUnkFv = .text:0x80052C60; // type:function size:0x24 fn_80052C90__Q27dDvdUnk7FontUnkFv = .text:0x80052C90; // type:function size:0x28 fn_80052CC0 = .text:0x80052CC0; // type:function size:0x38 fn_80052D00__Q27dDvdUnk7FontUnkFb = .text:0x80052D00; // type:function size:0x14 -fn_80052D20 = .text:0x80052D20; // type:function size:0x30 +fn_80052D20__Q27dDvdUnk7FontUnkFv = .text:0x80052D20; // type:function size:0x30 fn_80052D50__Q27dDvdUnk7FontUnkFv = .text:0x80052D50; // type:function size:0x78 fn_80052DD0 = .text:0x80052DD0; // type:function size:0x2C initDylinkHeap__4dDylFiPC10RelNamePtriPQ23EGG4Heap = .text:0x80052E00; // type:function size:0x1A0 @@ -2320,10 +2320,10 @@ 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__Q24dPad4ex_cFv = .text:0x80058F50; // type:function size:0xC -fn_80058F60__Q24dPad4ex_cFv = .text:0x80058F60; // type:function size:0x78 +startCurrentMplsCalibration__Q24dPad4ex_cFv = .text:0x80058F60; // type:function size:0x78 getCurrentCalibrationWork__Q24dPad4ex_cFv = .text:0x80058FE0; // type:function size:0x8 -fn_80058FF0__Q24dPad4ex_cFv = .text:0x80058FF0; // type:function size:0xC -fn_80059000__Q24dPad4ex_cFv = .text:0x80059000; // type:function size:0xC +stopCurrentMplsCalibration__Q24dPad4ex_cFv = .text:0x80058FF0; // type:function size:0xC +centerCurrentCursor__Q24dPad4ex_cFv = .text:0x80059000; // type:function size:0xC needMplsCalibration__Q24dPad4ex_cFv = .text:0x80059010; // type:function size:0x90 setCalibrateMpls__Q24dPad4ex_cFv = .text:0x800590A0; // type:function size:0x10 fn_800590B0__Q24dPad4ex_cFv = .text:0x800590B0; // type:function size:0x30 @@ -2407,38 +2407,38 @@ 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 -fn_80059DA0 = .text:0x80059DA0; // type:function size:0x24 -fn_80059DD0 = .text:0x80059DD0; // type:function size:0x54 -fn_80059E30 = .text:0x80059E30; // type:function size:0x60 -fn_80059E90 = .text:0x80059E90; // type:function size:0x44 -fn_80059EE0 = .text:0x80059EE0; // type:function size:0x2C -fn_80059F10 = .text:0x80059F10; // type:function size:0x2C -fn_80059F40 = .text:0x80059F40; // type:function size:0xC -fn_80059F50 = .text:0x80059F50; // type:function size:0x84 -fn_80059FE0 = .text:0x80059FE0; // type:function size:0x68 -fn_8005A050 = .text:0x8005A050; // type:function size:0x104 -fn_8005A160 = .text:0x8005A160; // type:function size:0x40 -fn_8005A1A0 = .text:0x8005A1A0; // type:function size:0x144 -fn_8005A2F0 = .text:0x8005A2F0; // type:function size:0x40 -fn_8005A330 = .text:0x8005A330; // type:function size:0x174 -fn_8005A4B0 = .text:0x8005A4B0; // type:function size:0x8 -fn_8005A4C0 = .text:0x8005A4C0; // type:function size:0x188 -fn_8005A650 = .text:0x8005A650; // type:function size:0x48 -performInitialCalibrationMaybeMaybe = .text:0x8005A6A0; // type:function size:0x2C4 -fn_8005A970 = .text:0x8005A970; // type:function size:0x3C -fn_8005A9B0 = .text:0x8005A9B0; // type:function size:0x1D8 -fn_8005AB90 = .text:0x8005AB90; // type:function size:0x5C -fn_8005ABF0 = .text:0x8005ABF0; // type:function size:0x374 -fn_8005AF70 = .text:0x8005AF70; // type:function size:0x8 -fn_8005AF80 = .text:0x8005AF80; // type:function size:0x50C -fn_8005B490 = .text:0x8005B490; // type:function size:0x18 -fn_8005B4B0 = .text:0x8005B4B0; // type:function size:0xDC -fn_8005B590 = .text:0x8005B590; // type:function size:0xB0 -fn_8005B640 = .text:0x8005B640; // type:function size:0x2C -fn_8005B670 = .text:0x8005B670; // type:function size:0x64 +__ct__13dPadManager_cFv = .text:0x80059CE0; // type:function size:0x2C +create__13dPadManager_cFPQ23EGG4Heap = .text:0x80059D10; // type:function size:0x44 +__dt__13dPadManager_cFv = .text:0x80059D60; // type:function size:0x40 +execute__13dPadManager_cFv = .text:0x80059DA0; // type:function size:0x24 +draw__13dPadManager_cFv = .text:0x80059DD0; // type:function size:0x54 +init__13dPadManager_cFv = .text:0x80059E30; // type:function size:0x60 +buildWindow__13dPadManager_cFv = .text:0x80059E90; // type:function size:0x44 +get30SecondsInTicks__13dPadManager_cFv = .text:0x80059EE0; // type:function size:0x2C +get3Point3SecondsInTicks__13dPadManager_cFv = .text:0x80059F10; // type:function size:0x2C +requestMplsCalibration__13dPadManager_cFv = .text:0x80059F40; // type:function size:0xC +executeProc__13dPadManager_cFv = .text:0x80059F50; // type:function size:0x84 +ModeRequestNormal__13dPadManager_cFv = .text:0x80059FE0; // type:function size:0x68 +ModeProc_Normal__13dPadManager_cFv = .text:0x8005A050; // type:function size:0x104 +ModeRequestReconnectPad__13dPadManager_cFv = .text:0x8005A160; // type:function size:0x40 +ModeProc_ReconnectPad__13dPadManager_cFv = .text:0x8005A1A0; // type:function size:0x144 +ModeRequestAttachMplsAndNunchuk__13dPadManager_cFv = .text:0x8005A2F0; // type:function size:0x40 +ModeProc_AttachMplsAndNunchuk__13dPadManager_cFv = .text:0x8005A330; // type:function size:0x174 +ModeRequestAttachNunchuk__13dPadManager_cFv = .text:0x8005A4B0; // type:function size:0x8 +ModeProc_AttachNunchuk__13dPadManager_cFv = .text:0x8005A4C0; // type:function size:0x188 +ModeRequestCalibrating__13dPadManager_cFv = .text:0x8005A650; // type:function size:0x48 +ModeProc_Calibrating__13dPadManager_cFv = .text:0x8005A6A0; // type:function size:0x2C4 +ModeRequestLowBattery__13dPadManager_cFv = .text:0x8005A970; // type:function size:0x3C +ModeProc_LowBattery__13dPadManager_cFv = .text:0x8005A9B0; // type:function size:0x1D8 +ModeRequestPointCenter__13dPadManager_cFv = .text:0x8005AB90; // type:function size:0x5C +ModeProc_PointCenter__13dPadManager_cFv = .text:0x8005ABF0; // type:function size:0x374 +ModeRequestCalibrationFail__13dPadManager_cFv = .text:0x8005AF70; // type:function size:0x8 +ModeProc_CalibrationFail__13dPadManager_cFv = .text:0x8005AF80; // type:function size:0x50C +ModeRequest__13dPadManager_cFQ213dPadManager_c6Mode_e = .text:0x8005B490; // type:function size:0x18 +getPadStatus__13dPadManager_cFv = .text:0x8005B4B0; // type:function size:0xDC +ModeRequestNext__13dPadManager_cFQ213dPadManager_c11PadStatus_e = .text:0x8005B590; // type:function size:0xB0 +get1Point5SecondsInTicks__13dPadManager_cFv = .text:0x8005B640; // type:function size:0x2C +isOutOfBattery__13dPadManager_cFv = .text:0x8005B670; // type:function size:0x64 preExecute__17daPlayerActBase_cFv = .text:0x8005B6E0; // type:function size:0x4C postExecute__17daPlayerActBase_cFQ27fBase_c12MAIN_STATE_e = .text:0x8005B730; // type:function size:0x18 isInEvent__17daPlayerActBase_cFv = .text:0x8005B750; // type:function size:0x24 @@ -8465,27 +8465,27 @@ fn_80150430 = .text:0x80150430; // type:function size:0x34 fn_80150470 = .text:0x80150470; // type:function size:0x1CC fn_80150640 = .text:0x80150640; // type:function size:0x28 fn_80150670 = .text:0x80150670; // type:function size:0x28 -fn_801506A0 = .text:0x801506A0; // type:function size:0x138 +__ct__22dLytSystemWindowMain_cFv = .text:0x801506A0; // type:function size:0x138 fn_801507E0 = .text:0x801507E0; // type:function size:0x40 fn_80150820 = .text:0x80150820; // type:function size:0x10C -fn_80150930 = .text:0x80150930; // type:function size:0x78 -fn_801509B0 = .text:0x801509B0; // type:function size:0xA0 -fn_80150A50 = .text:0x80150A50; // type:function size:0x60 +build__22dLytSystemWindowMain_cFv = .text:0x80150930; // type:function size:0x78 +calc__22dLytSystemWindowMain_cFv = .text:0x801509B0; // type:function size:0xA0 +draw__22dLytSystemWindowMain_cFv = .text:0x80150A50; // type:function size:0x60 fn_80150AB0 = .text:0x80150AB0; // type:function size:0x1A8 -fn_80150C60 = .text:0x80150C60; // type:function size:0xC +init__22dLytSystemWindowMain_cFv = .text:0x80150C60; // type:function size:0xC fn_80150C70 = .text:0x80150C70; // type:function size:0xC -fn_80150C80 = .text:0x80150C80; // type:function size:0x230 -fn_80150EB0 = .text:0x80150EB0; // type:function size:0x24 -fn_80150EE0 = .text:0x80150EE0; // type:function size:0x24 +setProperties__22dLytSystemWindowMain_cFPCcbPCw = .text:0x80150C80; // type:function size:0x230 +fn_80150EB0__22dLytSystemWindowMain_cFv = .text:0x80150EB0; // type:function size:0x24 +fn_80150EE0__22dLytSystemWindowMain_cFv = .text:0x80150EE0; // type:function size:0x24 fn_80150F10 = .text:0x80150F10; // type:function size:0x14 -fn_80150F30 = .text:0x80150F30; // type:function size:0x1C -fn_80150F50 = .text:0x80150F50; // type:function size:0x5C -fn_80150FB0 = .text:0x80150FB0; // type:function size:0x24 -fn_80150FE0 = .text:0x80150FE0; // type:function size:0xC -fn_80150FF0 = .text:0x80150FF0; // type:function size:0xC -fn_80151000 = .text:0x80151000; // type:function size:0xC +fn_80150F30__22dLytSystemWindowMain_cFl = .text:0x80150F30; // type:function size:0x1C +requestABtnOut__22dLytSystemWindowMain_cFv = .text:0x80150F50; // type:function size:0x5C +fn_80150FB0__22dLytSystemWindowMain_cFv = .text:0x80150FB0; // type:function size:0x24 +fn_80150FE0__22dLytSystemWindowMain_cFv = .text:0x80150FE0; // type:function size:0xC +fn_80150FF0__22dLytSystemWindowMain_cFv = .text:0x80150FF0; // type:function size:0xC +fn_80151000__22dLytSystemWindowMain_cFv = .text:0x80151000; // type:function size:0xC fn_80151010 = .text:0x80151010; // type:function size:0x1C -fn_80151030 = .text:0x80151030; // type:function size:0x10 +isPointerWithinWindow__22dLytSystemWindowMain_cFv = .text:0x80151030; // type:function size:0x10 fn_80151040 = .text:0x80151040; // type:function size:0x90 fn_801510D0 = .text:0x801510D0; // type:function size:0xA0 fn_80151170 = .text:0x80151170; // type:function size:0x1EC @@ -30797,7 +30797,7 @@ lbl_8050D528 = .data:0x8050D528; // type:object size:0x30 jumptable_8050D558 = .data:0x8050D558; // type:object size:0x54 scope:local lbl_8050D5AC = .data:0x8050D5AC; // type:object size:0x24 jumptable_8050D5D0 = .data:0x8050D5D0; // type:object size:0x44 scope:local -lbl_8050D614 = .data:0x8050D614; // type:object size:0xC +__vt__13dPadManager_c = .data:0x8050D614; // type:object size:0xC lbl_8050D620 = .data:0x8050D620; // type:object size:0xC data:string lbl_8050D62C = .data:0x8050D62C; // type:object size:0xC data:string lbl_8050D638 = .data:0x8050D638; // type:object size:0xC data:string @@ -41402,7 +41402,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:0x8 data:4byte m_connected__Q24dPad4ex_c = .sbss:0x805751E0; // type:object size:0x4 -sInstance__15dPauseManager_c = .sbss:0x805751E8; // type:object size:0x8 data:4byte +sInstance__13dPadManager_c = .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 lbl_805751F6 = .sbss:0x805751F6; // type:object size:0x1 data:byte diff --git a/configure.py b/configure.py index 3ba694db..5e719ca7 100644 --- a/configure.py +++ b/configure.py @@ -413,7 +413,7 @@ config.libs = [ Object(NonMatching, "d/d_main.cpp"), Object(NonMatching, "d/d_pad.cpp"), Object(Matching, "d/d_pad_ex.cpp"), - Object(NonMatching, "d/d_pause_manager.cpp"), + Object(NonMatching, "d/d_pad_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/d_cs_base.h b/include/d/d_cs_base.h index 361175cf..50786801 100644 --- a/include/d/d_cs_base.h +++ b/include/d/d_cs_base.h @@ -25,10 +25,12 @@ public: void setField703(bool val) { field_0x703 = val; } - void setField704(bool val) { field_0x704 = val; } + bool getField704() const { + return field_0x704; + } void setField705(bool val) { field_0x705 = val; } @@ -41,6 +43,10 @@ public: return sInstance; } + void setCursorStickVisible(bool visible) { + mCursorStick.setShouldBeOn(visible); + } + private: static dCsBase_c *sInstance; void setCurrentLyt(int lyt); @@ -55,7 +61,7 @@ private: /* 0x700 */ mAng field_0x700; /* 0x702 */ u8 mAlpha; /* 0x703 */ u8 field_0x703; - /* 0x704 */ u8 field_0x704; + /* 0x704 */ bool field_0x704; /* 0x705 */ u8 field_0x705; }; diff --git a/include/d/d_dvd_unk.h b/include/d/d_dvd_unk.h index 2b93fd22..90cd7175 100644 --- a/include/d/d_dvd_unk.h +++ b/include/d/d_dvd_unk.h @@ -28,6 +28,7 @@ public: void fn_80052D50(); void fn_80052C90(); void fn_80052C60(); + bool fn_80052D20(); s32 getField_0x24() const { return field_0x24; diff --git a/include/d/d_gfx.h b/include/d/d_gfx.h index 337d3d57..826e8d33 100644 --- a/include/d/d_gfx.h +++ b/include/d/d_gfx.h @@ -36,6 +36,11 @@ public: return sInstance; } + static void doDrawCapTexture() { + nw4r::ut::Color c(0xFFFFFFFF); + sInstance->drawCapTexture(sInstance->mpTextureBuffer, &c); + } + public: // clang-format off static s32 getCurrentScreenWidth() { return g_CurrentScreenWidth_s32; } diff --git a/include/d/d_pad.h b/include/d/d_pad.h index fa95a003..9c20a6c9 100644 --- a/include/d/d_pad.h +++ b/include/d/d_pad.h @@ -137,10 +137,10 @@ public: static void setInfo(s32 chan, const WPADInfo *pInfo); static f32 fn_80058F50(); - static bool fn_80058F60(); + static bool startCurrentMplsCalibration(); static f32 getCurrentCalibrationWork(); - static void fn_80058FF0(); - static void fn_80059000(); + static void stopCurrentMplsCalibration(); + static void centerCurrentCursor(); static bool needMplsCalibration(); static void setCalibrateMpls(); static bool fn_800590B0(); @@ -168,6 +168,10 @@ public: void getUnifiedWpadStatus(s32 chan); void calcFSStickDirMask(); + void setNoCalibrationNeeded() { + mNeedMplsCalibration = false; + } + static void setNoSleep(); static void setAutoSleepTime(); diff --git a/include/d/d_pad_manager.h b/include/d/d_pad_manager.h new file mode 100644 index 00000000..a27fb945 --- /dev/null +++ b/include/d/d_pad_manager.h @@ -0,0 +1,108 @@ +#ifndef D_PAD_MANAGER_H +#define D_PAD_MANAGER_H + +#include "common.h" +#include "d/lyt/d_lyt_system_window.h" +#include "egg/core/eggHeap.h" + +class dPadManager_c { +public: + dPadManager_c(); + virtual ~dPadManager_c(); + + static bool create(EGG::Heap *pHeap); + void init(); + bool execute(); + bool draw(); + + static void buildWindow(); + + static dPadManager_c *GetInstance() { + return sInstance; + } + bool getField_0x25() const { + return field_0x25; + } + + void requestMplsCalibration(); + +private: + typedef void (dPadManager_c::*ModeFunc)(); + + void executeProc(); + static s32 get30SecondsInTicks(); + static s32 get3Point3SecondsInTicks(); + /* static */ s32 get1Point5SecondsInTicks(); + + enum Mode_e { + Normal = 0, + ReconnectPad = 1, + AttachMplsAndNunchuk = 2, + AttachNunchuk = 3, + Calibrating = 4, + LowBattery = 5, + PointCenter = 6, + CalibrationFail = 7, + }; + + enum PadStatus_e { + PAD_DISCONNECTED = 0, + PAD_NO_MPLS = 1, + PAD_NO_NUNCHUK = 2, + PAD_NEED_CALIBRATION = 3, + PAD_CONFIGURING_MPLS = 4, + PAD_NEED_POINT_CENTER = 5, + PAD_NORMAL = 6, + }; + + void ModeRequestNormal(); + void ModeProc_Normal(); + + void ModeRequestReconnectPad(); + void ModeProc_ReconnectPad(); + + void ModeRequestAttachMplsAndNunchuk(); + void ModeProc_AttachMplsAndNunchuk(); + + void ModeRequestAttachNunchuk(); + void ModeProc_AttachNunchuk(); + + void ModeRequestCalibrating(); + void ModeProc_Calibrating(); + + void ModeRequestLowBattery(); + void ModeProc_LowBattery(); + + void ModeRequestPointCenter(); + void ModeProc_PointCenter(); + + void ModeRequestCalibrationFail(); + void ModeProc_CalibrationFail(); + + void ModeRequest(Mode_e mode); + void ModeRequestNext(PadStatus_e status); + + PadStatus_e getPadStatus(); + bool isOutOfBattery(); + + /* 0x04 */ dLytSystemWindowMain_c *mpWindow; + /* 0x08 */ PadStatus_e mPadStatus; + /* 0x0C */ Mode_e mMode; + /* 0x10 */ s32 mStep; + /* 0x14 */ s32 mCalibrationTimer; + /* 0x18 */ s32 mStepTimer; + /* 0x1C */ bool field_0x1C; + /* 0x1D */ bool field_0x1D; + /* 0x1E */ bool field_0x1E; + /* 0x1F */ bool field_0x1F; + /* 0x20 */ bool field_0x20; + /* 0x21 */ bool mCalibrationFinished; + /* 0x22 */ bool field_0x22; + /* 0x23 */ bool field_0x23; + /* 0x24 */ bool field_0x24; + /* 0x25 */ bool field_0x25; + + static dPadManager_c *sInstance; +}; + +#endif diff --git a/include/d/d_pause.h b/include/d/d_pause.h deleted file mode 100644 index a42c5a87..00000000 --- a/include/d/d_pause.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef D_PAUSE_H -#define D_PAUSE_H - -#include "common.h" - -// reference to NSMBW PauseManage_c (im adding back the d) -class dPauseManager_c { -public: - static dPauseManager_c *GetInstance() { - return sInstance; - } - bool getField_0x25() const { - return field_0x25; - } - -private: - /* 0x00 */ u8 _00[0x25 - 0x00]; - /* 0x25 */ bool field_0x25; - - static dPauseManager_c *sInstance; -}; - -#endif diff --git a/include/d/lyt/d_lyt_battery.h b/include/d/lyt/d_lyt_battery.h index 1d7c52aa..06abee5f 100644 --- a/include/d/lyt/d_lyt_battery.h +++ b/include/d/lyt/d_lyt_battery.h @@ -11,6 +11,10 @@ public: static bool draw(); bool dismissManually(); + static dLytBattery_c *GetInstance() { + return sInstance; + } + private: dLytBattery_c() : mStateMgr(*this, sStateID::null) { sInstance = this; diff --git a/include/d/lyt/d_lyt_system_window.h b/include/d/lyt/d_lyt_system_window.h index ff1959a0..6e1b1ab1 100644 --- a/include/d/lyt/d_lyt_system_window.h +++ b/include/d/lyt/d_lyt_system_window.h @@ -3,6 +3,63 @@ #include "common.h" +// TODO - the Main vs not-main split may not make sense here, +// but I don't know what the second class here does + +class dLytSystemWindowMain_c { +public: + dLytSystemWindowMain_c(); + virtual ~dLytSystemWindowMain_c(); + + bool draw(); + bool build(); + bool calc(); + + void init(); + + bool setProperties(const char *label, bool, const wchar_t *); + void fn_80150F30(s32 arg); + bool requestABtnOut(); + + bool fn_80150EB0(); + bool fn_80150EE0(); + bool fn_80150FB0(); + void fn_80150FE0(); + void fn_80150FF0(); + void fn_80151000(); + bool isPointerWithinWindow(); + + s32 getField_0xDDC() const { + return field_0xDDC; + } + + bool getField_0xDF7() const { + return field_0xDF7; + } + + bool getField_0xDF8() const { + return field_0xDF8; + } + + void setField_0xE03(bool val) { + field_0xE03 = val; + } + + void setField_0xE04(bool val) { + field_0xE04 = val; + } + +private: + /* 0x004 */ u8 _0x004[0xDDC - 0x004]; + /* 0xDDC */ s32 field_0xDDC; + /* 0xDF0 */ u8 _0xDF0[0xDF7 - 0xDE0]; + /* 0xDF7 */ bool field_0xDF7; + /* 0xDF8 */ bool field_0xDF8; + /* 0xDF9 */ u8 _0xDF9[0xE03 - 0xDF9]; + /* 0xE03 */ bool field_0xE03; + /* 0xE04 */ bool field_0xE04; +}; + class dLytSystemWindow_c { public: virtual ~dLytSystemWindow_c(); diff --git a/include/toBeSorted/save_manager.h b/include/toBeSorted/save_manager.h index d1e74677..fc58e410 100644 --- a/include/toBeSorted/save_manager.h +++ b/include/toBeSorted/save_manager.h @@ -153,6 +153,7 @@ public: bool clearSelectedFile(); private: + // TODO - Align with NSMBW ModeInit_ / ModeProc_ naming convention? void initializeCheckForSave(); void initializeCheckForFreeSpace(); void initializeCreateFiles(); diff --git a/src/REL/d/d_s_boot.cpp b/src/REL/d/d_s_boot.cpp index ea55d6c0..19984abf 100644 --- a/src/REL/d/d_s_boot.cpp +++ b/src/REL/d/d_s_boot.cpp @@ -10,6 +10,7 @@ #include "d/d_hbm.h" #include "d/d_heap.h" #include "d/d_message.h" +#include "d/d_pad_manager.h" #include "d/d_reset.h" #include "d/d_scene.h" #include "d/d_sys.h" @@ -293,13 +294,13 @@ sFPhaseBase::sFPhaseState dScBoot_c::cb7() { sFPhaseBase::sFPhaseState dScBoot_c::cb8() { return sFPhaseBase::PHASE_NEXT; } -extern "C" void fn_80059E90(); + sFPhaseBase::sFPhaseState dScBoot_c::cb9() { dBase_c::createRoot(fProfile::MESSAGE, 0, dBase_c::OTHER); dBase_c::createRoot(fProfile::C_BASE, 0, dBase_c::OTHER); dLytSystemWindow_c::create(); SaveMgr::GetInstance()->createSaveMsgWindow(); - fn_80059E90(); + dPadManager_c::buildWindow(); dLytBattery_c::create(); return sFPhaseBase::PHASE_NEXT; } diff --git a/src/d/d_pad.cpp b/src/d/d_pad.cpp index 1630083f..0508dbaf 100644 --- a/src/d/d_pad.cpp +++ b/src/d/d_pad.cpp @@ -8,7 +8,7 @@ #include "d/d_gfx.h" #include "d/d_hbm.h" #include "d/d_pad_nav.h" -#include "d/d_pause.h" +#include "d/d_pad_manager.h" #include "d/d_reset.h" #include "d/d_sc_game.h" #include "d/lyt/d_lyt_control_game.h" @@ -228,7 +228,7 @@ void beginPad_BR() { !dAcPy_c::GetLink()->vt_0x1C0() && !dLytMeter_c::GetMain()->getField_0x1377F()) || ex.field_0x22CF) { if (dLytControlGame_c::getInstance() && dLytControlGame_c::getInstance()->isStateNormal()) { - if (!(dPauseManager_c::GetInstance() && dPauseManager_c::GetInstance()->getField_0x25())) { + if (!(dPadManager_c::GetInstance() && dPadManager_c::GetInstance()->getField_0x25())) { KPADDisableMplsDpdRevise(0); KPADDisableMplsAccRevise(0); } @@ -1271,7 +1271,7 @@ f32 ex_c::fn_80058F50() { return m_current_ex->mMotion.fn_80058A00(); } -bool ex_c::fn_80058F60() { +bool ex_c::startCurrentMplsCalibration() { if (m_current_ex->mIsWPADDeviceTypeMplsStableTimer < 8) { return true; } @@ -1292,11 +1292,11 @@ f32 ex_c::getCurrentCalibrationWork() { return m_current_ex->getCalibrationWork(); } -void ex_c::fn_80058FF0() { +void ex_c::stopCurrentMplsCalibration() { m_current_ex->stopMplsCalibration(mPad::getCurrentCoreID()); } -void ex_c::fn_80059000() { +void ex_c::centerCurrentCursor() { m_current_ex->centerCursor(mPad::getCurrentCoreID()); } diff --git a/src/d/d_pad_manager.cpp b/src/d/d_pad_manager.cpp new file mode 100644 index 00000000..255fa7a1 --- /dev/null +++ b/src/d/d_pad_manager.cpp @@ -0,0 +1,798 @@ +#include "d/d_pad_manager.h" + +#include "common.h" +#include "d/d_cs_base.h" +#include "d/d_dvd_unk.h" +#include "d/d_gfx.h" +#include "d/d_pad.h" +#include "d/d_pad_nav.h" +#include "d/d_sys.h" +#include "d/lyt/d_lyt_battery.h" +#include "d/snd/d_snd_small_effect_mgr.h" +#include "d/snd/d_snd_wzsound.h" +#include "m/m_pad.h" + +dPadManager_c::dPadManager_c() { + sInstance = this; + field_0x20 = true; + mpWindow = nullptr; + mCalibrationFinished = false; + field_0x25 = false; +} + +bool dPadManager_c::create(EGG::Heap *pHeap) { + new (pHeap) dPadManager_c(); + sInstance->init(); + return true; +} + +dPadManager_c::~dPadManager_c() {} + +bool dPadManager_c::execute() { + executeProc(); + return true; +} + +bool dPadManager_c::draw() { + dGfx_c::doDrawCapTexture(); + if (mpWindow != nullptr) { + mpWindow->draw(); + } + return true; +} + +void dPadManager_c::init() { + field_0x22 = false; + field_0x23 = false; + ModeRequestNormal(); + field_0x1E = false; + field_0x1F = false; + if (mpWindow != nullptr) { + mpWindow->init(); + } + field_0x24 = false; +} + +void dPadManager_c::buildWindow() { + sInstance->mpWindow = new dLytSystemWindowMain_c(); + sInstance->mpWindow->build(); +} + +s32 dPadManager_c::get30SecondsInTicks() { + return 1800 / dSys_c::getFrameRate(); +} + +s32 dPadManager_c::get3Point3SecondsInTicks() { + return 200 / dSys_c::getFrameRate(); +} + +void dPadManager_c::requestMplsCalibration() { + mCalibrationFinished = false; + dPad::ex_c::setCalibrateMpls(); +} + +void dPadManager_c::executeProc() { + static const ModeFunc procs[] = { + &dPadManager_c::ModeProc_Normal, + &dPadManager_c::ModeProc_ReconnectPad, + &dPadManager_c::ModeProc_AttachMplsAndNunchuk, + &dPadManager_c::ModeProc_AttachNunchuk, + &dPadManager_c::ModeProc_Calibrating, + &dPadManager_c::ModeProc_LowBattery, + &dPadManager_c::ModeProc_PointCenter, + &dPadManager_c::ModeProc_CalibrationFail, + }; + ModeFunc f = procs[mMode]; + if (f != nullptr) { + (this->*f)(); + } + + if (mpWindow != nullptr) { + mpWindow->calc(); + } +} + +void dPadManager_c::ModeRequestNormal() { + ModeRequest(Normal); + field_0x1C = false; + field_0x1D = false; + if (dCsBase_c::GetInstance() != nullptr) { + dCsBase_c::GetInstance()->setField704(field_0x22); + if (field_0x23) { + dPadNav::setCursorStickVisible(); + } else { + dPadNav::setCursorStickInvisible(); + } + } +} + +void dPadManager_c::ModeProc_Normal() { + PadStatus_e status = getPadStatus(); + if (status == PAD_NORMAL || status == PAD_CONFIGURING_MPLS) { + if (isOutOfBattery() == true) { + field_0x1C = true; + dDvdUnk::FontUnk::GetInstance()->fn_80052C60(); + ModeRequestLowBattery(); + } + return; + } + + // Some sort of error occured + + field_0x1C = true; + mPadStatus = status; + dCsBase_c *cs = dCsBase_c::GetInstance(); + field_0x22 = cs->getField704(); + cs->setField704(false); + cs->setCursorStickVisible(false); + field_0x23 = dPadNav::isCursorStickVisible(); + dPadNav::setCursorStickInvisible(); + dDvdUnk::FontUnk::GetInstance()->fn_80052C60(); + + if (status == PAD_DISCONNECTED) { + ModeRequestReconnectPad(); + } else if (status == PAD_NO_MPLS) { + ModeRequestAttachMplsAndNunchuk(); + } else if (status == PAD_NO_NUNCHUK) { + ModeRequestAttachNunchuk(); + } else if (status == PAD_NEED_POINT_CENTER) { + ModeRequestPointCenter(); + } else { + ModeRequestCalibrating(); + } +} + +void dPadManager_c::ModeRequestReconnectPad() { + ModeRequest(ReconnectPad); + field_0x1D = true; + mCalibrationFinished = false; +} +void dPadManager_c::ModeProc_ReconnectPad() { + PadStatus_e status = getPadStatus(); + if (status == PAD_NEED_CALIBRATION || status == PAD_CONFIGURING_MPLS) { + status = PAD_NORMAL; + } + + switch (mStep) { + case 0: + // "Communications with the Wii Remote have been interrupted. Reconnect the Wii Remote. + // Press (A) without touching the Control Stick." + if (mpWindow->setProperties("SYS_CONT_10", true, nullptr) == true) { + mStep = 1; + } + break; + case 1: + if (mPad::getCore()->isConnected() && mpWindow->requestABtnOut() == true) { + mPad::getCore()->startPatternRumble("***--***--***", 0, false); + mStepTimer = 0; + mStep = 2; + } + break; + case 2: + if (mStepTimer < get3Point3SecondsInTicks()) { + mStepTimer++; + } else if (mpWindow->fn_80150EE0() == true) { + mStep = 3; + } + break; + case 3: + if (mpWindow->getField_0xDF7() == true) { + mStep = 4; + } + break; + case 4: ModeRequestNext(status); break; + } +} + +void dPadManager_c::ModeRequestAttachMplsAndNunchuk() { + ModeRequest(AttachMplsAndNunchuk); + field_0x1D = true; + mCalibrationFinished = false; +} +void dPadManager_c::ModeProc_AttachMplsAndNunchuk() { + PadStatus_e status = getPadStatus(); + if (status == PAD_NEED_CALIBRATION || status == PAD_CONFIGURING_MPLS) { + status = PAD_NORMAL; + } + + switch (mStep) { + case 0: + // "Connect the Wii Remote and Nunchuk to the Wii MotionPlus accessory. Next, wait a few moments without + // touching the Control Stick." + if (mpWindow->setProperties("SYS_CONT_01_02", false, nullptr) == true) { + mpWindow->fn_80150F30(2); + mStep = 1; + } + break; + case 1: + if (mpWindow->getField_0xDF7() == true) { + mStep++; + } + // fall-through + case 2: + if (status == PAD_DISCONNECTED) { + if (mpWindow->fn_80150EE0() == true) { + mStep = 4; + } + } else { + if (dPad::ex_c::isMissingMpls() != true) { + mStep = 3; + mStepTimer = 0; + } + } + break; + case 3: + if (mStepTimer < get3Point3SecondsInTicks()) { + mStepTimer++; + } else if (mpWindow->fn_80150EE0() == true) { + mStep = 4; + mStepTimer = 0; + dPad::ex_c::fn_800590F0(); + } + break; + case 4: + if (mpWindow->getField_0xDF7() == true) { + mStep = 5; + } + break; + case 5: ModeRequestNext(status); break; + } +} + +void dPadManager_c::ModeRequestAttachNunchuk() { + ModeRequest(AttachNunchuk); +} +void dPadManager_c::ModeProc_AttachNunchuk() { + PadStatus_e status = getPadStatus(); + if (status == PAD_NEED_CALIBRATION || status == PAD_CONFIGURING_MPLS) { + status = PAD_NORMAL; + } + + switch (mStep) { + case 0: + // "Connect the Nunchuk to the Wii Remote. Once you have connected the Nunchuk, wait a few moments without + // touching the Control Stick." + if (mpWindow->setProperties("SYS_CONT_01_01", false, nullptr) == true) { + mpWindow->fn_80150F30(1); + mStep = 1; + mStepTimer = 0; + } + break; + case 1: + if (mpWindow->getField_0xDF7() == true) { + mStep++; + } + break; + case 2: + if (status == PAD_DISCONNECTED) { + if (mpWindow->fn_80150EE0() == true) { + mStep = 3; + } + } else if (status == PAD_NO_MPLS) { + if (mpWindow->fn_80150EE0() == true) { + mStep = 3; + } + } else if (mStepTimer < get1Point5SecondsInTicks()) { + mStepTimer++; + } else if (dPad::ex_c::isMissingNunchuk() != true && mpWindow->fn_80150EB0() == true) { + mStep = 3; + mStepTimer = 0; + } + break; + case 3: + if (mpWindow->getField_0xDF7() == true) { + mStep = 4; + } + break; + case 4: ModeRequestNext(status); break; + } +} + +void dPadManager_c::ModeRequestCalibrating() { + ModeRequest(Calibrating); + mCalibrationTimer = 0; + field_0x1D = true; + mCalibrationFinished = false; + field_0x24 = false; +} +void dPadManager_c::ModeProc_Calibrating() { + PadStatus_e status = getPadStatus(); + bool empty = false; + if (status == PAD_NEED_CALIBRATION) { + empty = true; + status = PAD_NORMAL; + } + + static const char *s_messages[] = { + "SYS_MPLS_01", // "Now calibrating the Wii MotionPlus. Place the Wii Remote on a flat surface." + "SYS_MPLS_05", // "" + }; + + switch (mStep) { + case 0: { + s32 idx = 0; + if (empty) { + idx = 1; + } + if (mpWindow->setProperties(s_messages[idx], false, nullptr) == true) { + mpWindow->fn_80150F30(3); + mpWindow->fn_80150FE0(); + mpWindow->fn_80151000(); + mStep = 1; + mStepTimer = 0; + } + break; + } + case 1: + if (mpWindow->getField_0xDF7() == true) { + mStep++; + } + break; + case 2: + if (status != PAD_NORMAL && status != PAD_CONFIGURING_MPLS) { + mStep = 20; + } else if (mStepTimer < get1Point5SecondsInTicks()) { + mStepTimer++; + } else if (dPad::ex_c::startCurrentMplsCalibration() == false) { + mStep = 3; + mStepTimer = 0; + } else if (mCalibrationTimer >= get30SecondsInTicks() && mpWindow->fn_80150EE0() == true) { + mpWindow->fn_80150FF0(); + mStep = 10; + mCalibrationTimer = 0; + } else { + mCalibrationTimer++; + } + break; + case 3: + if (status != PAD_NORMAL) { + dPad::ex_c::stopCurrentMplsCalibration(); + mStep = 20; + } else if (!dPad::ex_c::getCurrentCalibrationWork()) { + // okay cool everywhere else we do "== true" and so on + // but here the float is simply converted to bool + // done calibrating + if (mpWindow->fn_80150EE0() == true) { + mStep = 4; + } + } else if (mCalibrationTimer >= get30SecondsInTicks() && mpWindow->fn_80150EE0() == true) { + mpWindow->fn_80150FF0(); + mStep = 10; + mCalibrationTimer = 0; + } else { + mCalibrationTimer++; + } + break; + case 4: + if (mpWindow->getField_0xDF7() == true) { + field_0x1D = false; + mCalibrationFinished = true; + ModeRequestPointCenter(); + } + break; + case 10: + if (mpWindow->getField_0xDF7() == true) { + ModeRequestCalibrationFail(); + } + break; + case 20: + mpWindow->fn_80150FF0(); + if (mpWindow->fn_80150EE0() == true) { + mStep = 21; + } + break; + case 21: + if (mpWindow->getField_0xDF7() == true) { + if (status == PAD_CONFIGURING_MPLS) { + mStep = 30; + } else { + ModeRequestNext(status); + } + } + break; + case 30: ModeRequestCalibrationFail(); break; + } +} + +void dPadManager_c::ModeRequestLowBattery() { + ModeRequest(LowBattery); + mCalibrationTimer = 0; + field_0x20 = false; +} +void dPadManager_c::ModeProc_LowBattery() { + PadStatus_e status = getPadStatus(); + switch (mStep) { + case 0: + // "The Wii Remote battery charge is running low. Please check the HOME Menu." + if (mpWindow->setProperties("SYS_CONT_09", false, nullptr) == true) { + mStep = 1; + mStepTimer = 0; + } + break; + case 1: + if (mpWindow->getField_0xDF7() == true) { + mStep++; + } + break; + case 2: + if (status != PAD_NORMAL) { + mStep = 10; + } else if (mStepTimer < get1Point5SecondsInTicks()) { + mStepTimer++; + } else if (mpWindow->fn_80150FB0() == true) { + mStep = 3; + mStepTimer = 0; + } + break; + case 3: + if (status != PAD_NORMAL) { + mStep = 10; + } else if (mPad::getCore()->downTrigger(mPad::BUTTON_A) && mpWindow->fn_80150EB0() == true) { + mStep = 4; + } + break; + case 4: + if (mpWindow->getField_0xDF7() == true) { + dLytBattery_c::GetInstance()->dismissManually(); + ModeRequestNext(status); + } + break; + case 10: + if (mpWindow->fn_80150EE0() == true) { + mStep = 11; + } + break; + case 11: + if (mpWindow->getField_0xDF7() == true) { + dLytBattery_c::GetInstance()->dismissManually(); + ModeRequestNext(status); + } + break; + } +} + +void dPadManager_c::ModeRequestPointCenter() { + ModeRequest(PointCenter); + field_0x25 = true; + if (field_0x20 == false && dPad::ex_c::getBatteryLevel() >= 2) { + field_0x20 = true; + } +} +void dPadManager_c::ModeProc_PointCenter() { + PadStatus_e status = getPadStatus(); + if (status == PAD_NEED_CALIBRATION || status == PAD_CONFIGURING_MPLS) { + status = PAD_NORMAL; + } + + switch (mStep) { + case 0: + // "Point the Wii Remote at the screen, and move to the center." + if (mpWindow->setProperties("SYS_MPLS_02", false, nullptr) == true) { + dCsBase_c::GetInstance()->setField703(true); + dCsBase_c::GetInstance()->setField704(true); + dCsBase_c::GetInstance()->setField705(true); + mStep = 1; + } + break; + case 1: + if (mpWindow->getField_0xDF7() == true) { + mStep++; + } + break; + case 2: + if (status != PAD_NORMAL) { + mStep = 10; + } else if (mpWindow->isPointerWithinWindow() != false && + // "Press (A)." + mpWindow->setProperties("SYS_MPLS_07", false, nullptr) == true) { + mpWindow->fn_80150FB0(); + mPad::getCore()->startPatternRumble("**-*----", 0, false); + mStepTimer = 0; + mStep++; + } + break; + case 3: + if (mpWindow->getField_0xDF7() == true) { + mStep = 5; + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_POINTER_IN); + } + break; + case 4: + if (status != PAD_NORMAL) { + mStep = 10; + } else if (mpWindow->isPointerWithinWindow() == false && + // "Point the Wii Remote at the screen, and move to the center." + mpWindow->setProperties("SYS_MPLS_02", false, nullptr) == true) { + mStep = 1; + } else if (mStepTimer < 8) { + mStepTimer++; + } else if (mpWindow->fn_80150FB0() == true) { + mStepTimer = 0; + mStep++; + } + break; + case 5: + if (mpWindow->getField_0xDF8() == true) { + if (status != PAD_NORMAL) { + mStep = 20; + } else if (mpWindow->isPointerWithinWindow() == false && + // "Point the Wii Remote at the screen, and move to the center." + mpWindow->setProperties("SYS_MPLS_02", false, nullptr) == true) { + mpWindow->setField_0xE03(true); + mStep = 1; + } else if (mPad::getCore()->downTrigger(mPad::BUTTON_A) != false && mpWindow->fn_80150EB0() == true) { + mStepTimer = 0; + mStep++; + dPad::ex_c::centerCurrentCursor(); + dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_POINTER_OK); + } + } + break; + case 6: + if (mpWindow->getField_0xDF7() == true) { + field_0x1E = true; + field_0x25 = false; + dCsBase_c::GetInstance()->setField703(false); + dCsBase_c::GetInstance()->setField704(false); + dCsBase_c::GetInstance()->setField705(false); + ModeRequestNormal(); + return; + } + break; + case 10: + if (mpWindow->fn_80150EE0() == true) { + mStep = 11; + } + break; + case 11: + if (mpWindow->getField_0xDF7() == true) { + ModeRequestNext(status); + dCsBase_c::GetInstance()->setField703(false); + dCsBase_c::GetInstance()->setField704(false); + dCsBase_c::GetInstance()->setField705(false); + return; + } + break; + case 20: + if (mpWindow->fn_80150EE0() == true) { + mpWindow->setField_0xE03(true); + mStep = 11; + } + break; + } + dCsBase_c::GetInstance()->update(); +} + +void dPadManager_c::ModeRequestCalibrationFail() { + ModeRequest(CalibrationFail); +} +void dPadManager_c::ModeProc_CalibrationFail() { + PadStatus_e status = getPadStatus(); + + switch (mStep) { + case 0: + // "Could not successfully complete the calibration check. Run the check again? [1]Check [2]Don't check" + if (mpWindow->setProperties("SYS_MPLS_03", false, nullptr) == true) { + mpWindow->fn_80150F30(4); + mStep = 1; + mStepTimer = 0; + } + break; + case 1: + if (status != PAD_NORMAL && status != PAD_CONFIGURING_MPLS && status != PAD_NEED_CALIBRATION) { + mStep = 14; + } else if (mStepTimer < get1Point5SecondsInTicks()) { + mStepTimer++; + } else if (mPad::getCore()->downTrigger(mPad::BUTTON_A) != false && mpWindow->getField_0xDDC() != 2 && + mpWindow->fn_80150EE0() == true) { + mStep = 2; + mStepTimer = 0; + } + break; + case 2: + if (mpWindow->getField_0xDF7() == true) { + mStep = 3; + } + break; + case 3: + if (mpWindow->getField_0xDDC() == 0) { + if ( + // "If you proceed without finishing calibration, game controls may not work properly. Continue without finishing calibration? [1]Continue [2]Retry check" + mpWindow->setProperties("SYS_MPLS_04", false, nullptr) == true + ) { + mStep = 4; + mpWindow->fn_80150F30(4); + } + } else { + mStep = 6; + } + break; + case 4: + if (status != PAD_NORMAL && status != PAD_CONFIGURING_MPLS && status != PAD_NEED_CALIBRATION) { + mStep = 14; + } else if (mPad::getCore()->downTrigger(mPad::BUTTON_A) != false && mpWindow->getField_0xDDC() != 2) { + if (mpWindow->getField_0xDDC() == 0) { + if (mpWindow->fn_80150EE0() == true) { + mStep = 5; + } + } else { + if (mpWindow->fn_80150EB0() == true) { + field_0x1D = false; + dPad::ex_c::getInstance()->setNoCalibrationNeeded(); + field_0x24 = true; + field_0x25 = false; + mStep = 16; + } + } + } + break; + case 5: + if (mpWindow->getField_0xDF7() == true) { + mStep = 6; + } + break; + case 6: + // "Now calibrating the Wii MotionPlus. Place the Wii Remote on a flat surface." + if (mpWindow->setProperties("SYS_MPLS_01", false, nullptr) == true) { + mpWindow->fn_80150F30(3); + mpWindow->fn_80150FE0(); + mpWindow->fn_80151000(); + mCalibrationTimer = 0; + mStep = 7; + } + break; + case 7: + if (mpWindow->getField_0xDF7() == true) { + mStep = 8; + mStepTimer = 0; + } + break; + case 8: + if (status != PAD_NORMAL && status != PAD_NEED_CALIBRATION) { + mStep = 12; + } else if (mStepTimer < get1Point5SecondsInTicks()) { + mStepTimer++; + } else if (dPad::ex_c::startCurrentMplsCalibration() == false) { + mStep = 9; + mStepTimer = 0; + mCalibrationTimer = 0; + } else if (mCalibrationTimer >= get30SecondsInTicks() && mpWindow->fn_80150EE0() == true) { + mpWindow->fn_80150FF0(); + mStep = 11; + mCalibrationTimer = 0; + } else { + mCalibrationTimer++; + } + break; + case 9: + if (status != PAD_NORMAL && status != PAD_NEED_CALIBRATION) { + dPad::ex_c::stopCurrentMplsCalibration(); + mStep = 12; + } else if (!dPad::ex_c::getCurrentCalibrationWork() && mpWindow->fn_80150EE0() == true) { + // okay cool everywhere else we do "== true" and so on + // but here the float is simply converted to bool + // done calibrating + mStep = 10; + } else if (mCalibrationTimer >= get30SecondsInTicks() && mpWindow->fn_80150EE0() == true) { + mpWindow->fn_80150FF0(); + mStep = 11; + mCalibrationTimer = 0; + } else { + mCalibrationTimer++; + } + break; + case 10: + if (mpWindow->getField_0xDF7() == true) { + field_0x1D = false; + mCalibrationFinished = true; + ModeRequestPointCenter(); + } + break; + case 11: + if (mpWindow->getField_0xDF7() == true) { + ModeRequestCalibrationFail(); + } + break; + case 12: + mpWindow->fn_80150FF0(); + if (mpWindow->fn_80150EE0() == true) { + mStep = 13; + } + break; + case 13: + if (mpWindow->getField_0xDF7() == true) { + if (status == PAD_CONFIGURING_MPLS) { + ModeRequestCalibrationFail(); + } else { + ModeRequestNext(status); + } + } + break; + case 14: + if (mpWindow->fn_80150EB0() == true) { + mpWindow->setField_0xE04(true); + mStep = 15; + } + break; + case 15: + if (mpWindow->getField_0xDF7() == true) { + ModeRequestNext(status); + } + break; + case 16: + if (mpWindow->getField_0xDF7() == true) { + ModeRequestNext(status); + } + break; + } +} + +void dPadManager_c::ModeRequest(Mode_e mode) { + mMode = mode; + mStep = 0; + mStepTimer = 0; + mCalibrationTimer = 0; +} + +dPadManager_c::PadStatus_e dPadManager_c::getPadStatus() { + PadStatus_e ret = PAD_NORMAL; + if (dDvdUnk::FontUnk::GetInstance()->fn_80052D20() != true) { + return PAD_NORMAL; + } + + if (!mPad::getCore()->isConnected()) { + ret = PAD_DISCONNECTED; + } else if (dPad::ex_c::isMissingMpls() == true || dPad::ex_c::fn_800590E0()) { + ret = PAD_NO_MPLS; + } else if (dPad::ex_c::isMissingNunchuk() == true) { + ret = PAD_NO_NUNCHUK; + } else { + if (mMode == Normal) { + if (dPad::ex_c::needMplsCalibration()) { + ret = PAD_NEED_CALIBRATION; + } else if (field_0x25) { + ret = PAD_NEED_POINT_CENTER; + } + } + if (dPad::ex_c::fn_800590B0()) { + ret = PAD_CONFIGURING_MPLS; + } + } + + return ret; +} + +void dPadManager_c::ModeRequestNext(PadStatus_e status) { + if (status == PAD_DISCONNECTED) { + ModeRequestReconnectPad(); + } else if (status == PAD_NO_MPLS) { + ModeRequestAttachMplsAndNunchuk(); + } else if (status == PAD_NO_NUNCHUK) { + ModeRequestAttachNunchuk(); + } else if (status == PAD_NEED_CALIBRATION) { + ModeRequestCalibrating(); + } else if (field_0x1D == true) { + ModeRequestCalibrating(); + } else if (field_0x25 == true) { + ModeRequestPointCenter(); + } else if (isOutOfBattery() == true) { + ModeRequestLowBattery(); + } else { + ModeRequestNormal(); + } +} + +s32 dPadManager_c::get1Point5SecondsInTicks() { + return 90 / dSys_c::getFrameRate(); +} + +bool dPadManager_c::isOutOfBattery() { + if (dDvdUnk::FontUnk::GetInstance()->fn_80052D20() != true) { + return false; + } + + if (dPad::ex_c::isOutOfBattery() && field_0x20 == true) { + return true; + } + return false; +} From d153cbc0ede10dd24a32e89faf81c8fb839ee23a Mon Sep 17 00:00:00 2001 From: robojumper Date: Fri, 1 Aug 2025 11:26:25 +0200 Subject: [PATCH 2/4] Other cleanup --- config/SOUE01/symbols.txt | 45 ++--- configure.py | 6 +- include/d/d_cs_base.h | 22 +-- include/d/d_dvd_drive_error.h | 4 + include/d/d_dvd_unk.h | 73 ++++++-- include/d/d_pad_manager.h | 19 +- include/d/d_video.h | 10 + include/d/snd/d_snd_player_mgr.h | 1 + include/toBeSorted/nand_result_tracker.h | 42 ++++- src/d/d_cs_base.cpp | 21 ++- src/d/d_cs_game.cpp | 2 +- src/d/d_dvd_drive_error.cpp | 2 +- src/d/d_dvd_unk.cpp | 224 ++++++++++++++++++++++- src/d/d_pad_manager.cpp | 40 ++-- src/d/d_reset.cpp | 21 ++- src/d/d_sc_title.cpp | 3 - src/toBeSorted/nand_result_tracker.cpp | 118 ++++++++++++ src/toBeSorted/save_manager.cpp | 46 ++--- 18 files changed, 569 insertions(+), 130 deletions(-) create mode 100644 include/d/d_video.h create mode 100644 src/toBeSorted/nand_result_tracker.cpp diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 77a7fe84..a2ed088c 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -2151,22 +2151,22 @@ draw__16dDvdDriveError_cFv = .text:0x80052350; // type:function size:0x35C execute__16dDvdDriveError_cFv = .text:0x800526B0; // type:function size:0x98 init__16dDvdDriveError_cFv = .text:0x80052750; // type:function size:0x10 create__Q27dDvdUnk7FontUnkFPQ23EGG4Heap = .text:0x80052760; // type:function size:0x88 -fn_800527F0 = .text:0x800527F0; // type:function size:0x11C -fn_80052910 = .text:0x80052910; // type:function size:0x48 -fn_80052960 = .text:0x80052960; // type:function size:0x18 +execute__Q27dDvdUnk7FontUnkFv = .text:0x800527F0; // type:function size:0x11C +drawNonDriveError__Q27dDvdUnk7FontUnkFv = .text:0x80052910; // type:function size:0x48 +drawDriveError__Q27dDvdUnk7FontUnkFv = .text:0x80052960; // type:function size:0x18 init__Q27dDvdUnk7FontUnkFv = .text:0x80052980; // type:function size:0x30 fn_800529B0__Q27dDvdUnk7FontUnkFv = .text:0x800529B0; // type:function size:0x30 -fn_800529E0__Q27dDvdUnk7FontUnkFv = .text:0x800529E0; // type:function size:0x38 +clearNandError__Q27dDvdUnk7FontUnkFv = .text:0x800529E0; // type:function size:0x38 fn_80052A20__Q27dDvdUnk7FontUnkFv = .text:0x80052A20; // type:function size:0xB8 -fn_80052AE0 = .text:0x80052AE0; // type:function size:0x148 -fn_80052C30 = .text:0x80052C30; // type:function size:0x24 -fn_80052C60__Q27dDvdUnk7FontUnkFv = .text:0x80052C60; // type:function size:0x24 -fn_80052C90__Q27dDvdUnk7FontUnkFv = .text:0x80052C90; // type:function size:0x28 -fn_80052CC0 = .text:0x80052CC0; // type:function size:0x38 -fn_80052D00__Q27dDvdUnk7FontUnkFb = .text:0x80052D00; // type:function size:0x14 -fn_80052D20__Q27dDvdUnk7FontUnkFv = .text:0x80052D20; // type:function size:0x30 +preExecute__Q27dDvdUnk7FontUnkFv = .text:0x80052AE0; // type:function size:0x148 +isAnyError__Q27dDvdUnk7FontUnkCFv = .text:0x80052C30; // type:function size:0x24 +onError__Q27dDvdUnk7FontUnkFv = .text:0x80052C60; // type:function size:0x24 +clearNandTrackerError__Q27dDvdUnk7FontUnkFv = .text:0x80052C90; // type:function size:0x28 +fn_80052CC0__Q27dDvdUnk7FontUnkFv = .text:0x80052CC0; // type:function size:0x38 +setNeedsPad__Q27dDvdUnk7FontUnkFb = .text:0x80052D00; // type:function size:0x14 +padErrorsAllowed__Q27dDvdUnk7FontUnkFv = .text:0x80052D20; // type:function size:0x30 fn_80052D50__Q27dDvdUnk7FontUnkFv = .text:0x80052D50; // type:function size:0x78 -fn_80052DD0 = .text:0x80052DD0; // type:function size:0x2C +fn_80052DD0__Q27dDvdUnk7FontUnkFv = .text:0x80052DD0; // type:function size:0x2C initDylinkHeap__4dDylFiPC10RelNamePtriPQ23EGG4Heap = .text:0x80052E00; // type:function size:0x1A0 isLinked__4dDylFUs = .text:0x80052FA0; // type:function size:0x30 Unlink__4dDylFUs = .text:0x80052FD0; // type:function size:0x20 @@ -2860,7 +2860,7 @@ CreateArcEntry__22ArcCallbackHandlerBaseFPvPCc = .text:0x800651C0; // type:funct DestroyArcEntry__22ArcCallbackHandlerBaseFPCc = .text:0x800653D0; // type:function size:0x194 __sinit_\arc_callback_handler_cpp = .text:0x80065570; // type:function size:0x20 scope:local create__6mVideoFv = .text:0x80065590; // type:function size:0x54 -fn_800655F0 = .text:0x800655F0; // type:function size:0x4 +enableDimming__6dVideoFi = .text:0x800655F0; // type:function size:0x4 __ct__8dCsMgr_cFv = .text:0x80065600; // type:function size:0x3C execute__8dCsMgr_cFv = .text:0x80065640; // type:function size:0x164 registCursor__8dCsMgr_cFP18dCursorInterface_c = .text:0x800657B0; // type:function size:0x58 @@ -4062,13 +4062,14 @@ onEnter__Q23EGG6ThreadFv = .text:0x800BD600; // type:function size:0x4 create__17NandResultTrackerFPQ23EGG4Heap = .text:0x800BD610; // type:function size:0x34 GetInstance__17NandResultTrackerFv = .text:0x800BD650; // type:function size:0x8 isFailure__17NandResultTrackerF10NANDResult = .text:0x800BD660; // type:function size:0x5C -fn_800BD6C0 = .text:0x800BD6C0; // type:function size:0x34 -fn_800BD700 = .text:0x800BD700; // type:function size:0x74 -fn_800BD780 = .text:0x800BD780; // type:function size:0x18 -fn_800BD7A0 = .text:0x800BD7A0; // type:function size:0x74 -fn_800BD820 = .text:0x800BD820; // type:function size:0x8 -fn_800BD830 = .text:0x800BD830; // type:function size:0x78 -fn_800BD8B0 = .text:0x800BD8B0; // type:function size:0x10 +draw__17NandResultTrackerFv = .text:0x800BD6C0; // type:function size:0x34 +execute__17NandResultTrackerFv = .text:0x800BD700; // type:function size:0x74 +init__17NandResultTrackerFv = .text:0x800BD780; // type:function size:0x10 +ModeRequestNormal__17NandResultTrackerFv = .text:0x800BD790; // type:function size:0x8 +ModeProc_Normal__17NandResultTrackerFv = .text:0x800BD7A0; // type:function size:0x74 +ModeRequestError__17NandResultTrackerFv = .text:0x800BD820; // type:function size:0x8 +ModeProc_Error__17NandResultTrackerFv = .text:0x800BD830; // type:function size:0x78 +ModeRequest__17NandResultTrackerFQ217NandResultTracker6Mode_e = .text:0x800BD8B0; // type:function size:0x10 init__16SceneflagManagerFv = .text:0x800BD8C0; // type:function size:0x4 setShouldCommit__16SceneflagManagerFUs = .text:0x800BD8D0; // type:function size:0xC __ct__16SceneflagManagerFv = .text:0x800BD8E0; // type:function size:0x64 @@ -19953,7 +19954,7 @@ enterHelp__15dSndPlayerMgr_cFv = .text:0x8035E540; // type:function size:0x18 fn_8035E560 = .text:0x8035E560; // type:function size:0x18 fn_8035E580 = .text:0x8035E580; // type:function size:0x50 fn_8035E5D0 = .text:0x8035E5D0; // type:function size:0x44 -fn_8035E620 = .text:0x8035E620; // type:function size:0xB4 +fn_8035E620__15dSndPlayerMgr_cFv = .text:0x8035E620; // type:function size:0xB4 fn_8035E6E0__15dSndPlayerMgr_cFv = .text:0x8035E6E0; // type:function size:0xA4 fn_8035E790 = .text:0x8035E790; // type:function size:0x84 fn_8035E820 = .text:0x8035E820; // type:function size:0x38 @@ -41506,7 +41507,7 @@ sInstance__14dTimeAreaMgr_c = .sbss:0x805753C0; // type:object size:0x4 data:4by TIMESHIFT_TRANSITION_BORDER_COLOR = .sbss:0x805753C4; // type:object size:0x1 data:byte CURR_TIMESHIFT_STONE_ACTIVE = .sbss:0x805753C8; // type:object size:0x8 data:4byte sInstance__17NandRequestThread = .sbss:0x805753D0; // type:object size:0x8 data:4byte -lbl_805753D8 = .sbss:0x805753D8; // type:object size:0x8 data:4byte +sInstance__17NandResultTracker = .sbss:0x805753D8; // type:object size:0x8 data:4byte sInstance__16SceneflagManager = .sbss:0x805753E0; // type:object size:0x4 data:4byte sTempFlags__16SceneflagManager = .sbss:0x805753E8; // type:object size:0x8 sInstance__15TBoxflagManager = .sbss:0x805753F0; // type:object size:0x4 data:4byte diff --git a/configure.py b/configure.py index 5e719ca7..506acb7b 100644 --- a/configure.py +++ b/configure.py @@ -403,7 +403,7 @@ config.libs = [ Object(Matching, "d/d_cc.cpp"), Object(Matching, "d/d_dvd.cpp"), Object(Matching, "d/d_dvd_drive_error.cpp"), - Object(NonMatching, "d/d_dvd_unk.cpp"), + Object(Matching, "d/d_dvd_unk.cpp"), Object(NonMatching, "d/d_dylink.cpp"), Object(Matching, "d/d_fader.cpp"), Object(Matching, "d/d_font_manager.cpp"), @@ -413,7 +413,7 @@ config.libs = [ Object(NonMatching, "d/d_main.cpp"), Object(NonMatching, "d/d_pad.cpp"), Object(Matching, "d/d_pad_ex.cpp"), - Object(NonMatching, "d/d_pad_manager.cpp"), + Object(Matching, "d/d_pad_manager.cpp"), Object(NonMatching, "d/d_player_act.cpp"), Object(Matching, "d/d_player_mdl.cpp"), Object(Matching, "d/d_player_guide_colors.cpp"), @@ -462,7 +462,7 @@ config.libs = [ Object(Matching, "d/d_tag_processor.cpp"), Object(NonMatching, "toBeSorted/time_area_mgr.cpp"), Object(NonMatching, "toBeSorted/nand_request_thread.cpp"), - Object(NonMatching, "toBeSorted/nand_result_tracker.cpp"), + Object(Matching, "toBeSorted/nand_result_tracker.cpp"), Object(Matching, "d/flag/flag_managers.cpp"), Object(NonMatching, "toBeSorted/bigboss_model_math_stuff.cpp"), Object(NonMatching, "toBeSorted/actor_event_flow_manager_related.cpp"), diff --git a/include/d/d_cs_base.h b/include/d/d_cs_base.h index 50786801..54eedd01 100644 --- a/include/d/d_cs_base.h +++ b/include/d/d_cs_base.h @@ -22,17 +22,17 @@ public: int update(); bool drawDirectly(); - void setField703(bool val) { - field_0x703 = val; + void setVisible(bool val) { + mVisible = val; } - void setField704(bool val) { - field_0x704 = val; + void setDrawDirectly(bool val) { + mDrawDirectly = val; } - bool getField704() const { - return field_0x704; + bool getDrawDirectly() const { + return mDrawDirectly; } - void setField705(bool val) { - field_0x705 = val; + void setCalibrationPointCenterEnabled(bool val) { + mCalibrationPointCenterEnabled = val; } dCursorHitCheck_c *getHitCheck() { @@ -60,9 +60,9 @@ private: /* 0x6F8 */ mVec2_c mCsVelocity; /* 0x700 */ mAng field_0x700; /* 0x702 */ u8 mAlpha; - /* 0x703 */ u8 field_0x703; - /* 0x704 */ bool field_0x704; - /* 0x705 */ u8 field_0x705; + /* 0x703 */ bool mVisible; + /* 0x704 */ bool mDrawDirectly; + /* 0x705 */ bool mCalibrationPointCenterEnabled; }; #endif diff --git a/include/d/d_dvd_drive_error.h b/include/d/d_dvd_drive_error.h index 9c950315..0cbd5870 100644 --- a/include/d/d_dvd_drive_error.h +++ b/include/d/d_dvd_drive_error.h @@ -16,6 +16,10 @@ public: return sInstance; } + s32 getStatus() const { + return mDvdDriveStatus; + } + private: static dDvdDriveError_c *sInstance; diff --git a/include/d/d_dvd_unk.h b/include/d/d_dvd_unk.h index 90cd7175..10aa6cb2 100644 --- a/include/d/d_dvd_unk.h +++ b/include/d/d_dvd_unk.h @@ -11,8 +11,22 @@ namespace dDvdUnk { class FontUnk { +private: + enum Error_e { + ERROR_NONE, + ERROR_DISK, + ERROR_PAD, + ERROR_NAND, + }; + + enum Flag_e { + FLAG_ERROR_REQUEST = 0x1, + FLAG_0x2 = 0x2, + FLAG_ERROR_STATE = 0x4, + }; + public: - FontUnk() : field_0x2D(0) {} + FontUnk() : mFlags(0) {} static FontUnk *GetInstance() { return sInstance; @@ -20,26 +34,35 @@ public: static void create(EGG::Heap *heap); void init(); + void execute(); + void drawNonDriveError(); + void drawDriveError(); + + void preExecute(); + + bool isAnyError() const; + void onError(); + void clearNandTrackerError(); void fn_800529B0(); - void fn_800529E0(); + void clearNandError(); void fn_80052A20(); - void fn_80052D00(bool); + void fn_80052CC0(); + void setNeedsPad(bool); + bool padErrorsAllowed(); void fn_80052D50(); - void fn_80052C90(); - void fn_80052C60(); - bool fn_80052D20(); + void fn_80052DD0(); - s32 getField_0x24() const { - return field_0x24; + s32 getNandError() const { + return mNandErrorCode; } - bool getField_0x28() const { - return field_0x28; + bool isDiskError() const { + return mIsDiskError; } - u8 getField_0x29() const { - return field_0x29; + bool isNandError() const { + return mIsNandError; } void setField_0x2C(u8 val) { @@ -53,16 +76,28 @@ public: private: static FontUnk *sInstance; + void onFlag(u8 mask) { + mFlags |= mask; + } + + void offFlag(u8 mask) { + mFlags &= ~mask; + } + + bool checkFlag(u8 mask) const { + return (mFlags & mask) != 0; + } + /* 0x00 */ nw4r::ut::ResFont mFont; - /* 0x1C */ s32 field_0x1C; - /* 0x20 */ s32 field_0x20; - /* 0x24 */ s32 field_0x24; - /* 0x28 */ bool field_0x28; - /* 0x29 */ u8 field_0x29; - /* 0x2A */ u8 field_0x2A; + /* 0x1C */ s32 mErrorType; + /* 0x20 */ s32 mDiskErrorCode; + /* 0x24 */ s32 mNandErrorCode; + /* 0x28 */ bool mIsDiskError; + /* 0x29 */ bool mIsNandError; + /* 0x2A */ bool mIsPadError; /* 0x2B */ u8 field_0x2B; /* 0x2C */ u8 field_0x2C; - /* 0x2D */ u8 field_0x2D; + /* 0x2D */ u8 mFlags; }; } // namespace dDvdUnk diff --git a/include/d/d_pad_manager.h b/include/d/d_pad_manager.h index a27fb945..7db0cfbc 100644 --- a/include/d/d_pad_manager.h +++ b/include/d/d_pad_manager.h @@ -20,9 +20,24 @@ public: static dPadManager_c *GetInstance() { return sInstance; } + + bool isCalibrationFinished() const { + return mCalibrationFinished; + } bool getField_0x25() const { return field_0x25; } + bool isError() const { + return mIsError; + } + + void setField_0x1F(bool b) { + field_0x1F = b; + } + bool getField_0x1F() const { + return field_0x1F; + } + void requestMplsCalibration(); @@ -91,13 +106,13 @@ private: /* 0x10 */ s32 mStep; /* 0x14 */ s32 mCalibrationTimer; /* 0x18 */ s32 mStepTimer; - /* 0x1C */ bool field_0x1C; + /* 0x1C */ bool mIsError; /* 0x1D */ bool field_0x1D; /* 0x1E */ bool field_0x1E; /* 0x1F */ bool field_0x1F; /* 0x20 */ bool field_0x20; /* 0x21 */ bool mCalibrationFinished; - /* 0x22 */ bool field_0x22; + /* 0x22 */ bool mSavedCsDrawDirectly; /* 0x23 */ bool field_0x23; /* 0x24 */ bool field_0x24; /* 0x25 */ bool field_0x25; diff --git a/include/d/d_video.h b/include/d/d_video.h new file mode 100644 index 00000000..a25e3ac2 --- /dev/null +++ b/include/d/d_video.h @@ -0,0 +1,10 @@ +#ifndef D_VIDEO_H +#define D_VIDEO_H + +namespace dVideo { + +void enableDimming(int); + +} // namespace dVideo + +#endif diff --git a/include/d/snd/d_snd_player_mgr.h b/include/d/snd/d_snd_player_mgr.h index 6bbf7fb0..5b83ee5d 100644 --- a/include/d/snd/d_snd_player_mgr.h +++ b/include/d/snd/d_snd_player_mgr.h @@ -44,6 +44,7 @@ public: void fn_8035E250(u16); bool fn_8035E2E0(); void fn_8035E310(); + void fn_8035E620(); void fn_8035E6E0(); u32 getFreeSize(); diff --git a/include/toBeSorted/nand_result_tracker.h b/include/toBeSorted/nand_result_tracker.h index 6177d858..c8112fb1 100644 --- a/include/toBeSorted/nand_result_tracker.h +++ b/include/toBeSorted/nand_result_tracker.h @@ -2,16 +2,56 @@ #define NAND_RESULT_TRACKER_H #include "egg/core/eggHeap.h" + #include "rvl/NAND.h" class NandResultTracker { + enum Mode_e { + Normal = 0, + Error = 1, + }; + public: + enum ErrorCategory_e { + // Everything is ok + ERR_CAT_NONE = 0, + // Error handled by us + ERR_CAT_FATAL = 3, + // Error handled by save manager + ERR_CAT_SAVE_MGR = 4, + }; static void create(EGG::Heap *heap); static NandResultTracker *GetInstance(); bool isFailure(NANDResult status); + void init(); + void draw(); + void execute(); + + s32 getErrorCategory() const { + return mErrorCategory; + } + + bool isError() const { + return mIsError; + } + private: - NandResultTracker *sInstance; + typedef void (NandResultTracker::*ModeFunc)(); + + void ModeRequestNormal(); + void ModeProc_Normal(); + void ModeRequestError(); + void ModeProc_Error(); + + void ModeRequest(Mode_e mode); + + static NandResultTracker *sInstance; + + /* 0x00 */ s32 mErrorCategory; + /* 0x04 */ Mode_e mMode; + /* 0x08 */ s32 mStep; + /* 0x0C */ bool mIsError; }; #endif diff --git a/src/d/d_cs_base.cpp b/src/d/d_cs_base.cpp index 30fc60f1..b16fddf4 100644 --- a/src/d/d_cs_base.cpp +++ b/src/d/d_cs_base.cpp @@ -24,9 +24,9 @@ dCsBase_c::dCsBase_c() mCsVelocity(0.0f, 0.0f), field_0x700(0), mAlpha(0), - field_0x703(0), - field_0x704(0), - field_0x705(0) { + mVisible(false), + mDrawDirectly(false), + mCalibrationPointCenterEnabled(false) { sInstance = this; } @@ -58,7 +58,7 @@ int dCsBase_c::create() { field_0x700 = 0; mAlpha = 0; - field_0x703 = 0; + mVisible = false; return SUCCEEDED; } @@ -74,7 +74,10 @@ int dCsBase_c::execute() { mVec2_c dpdPosScreen = dPad::ex_c::getInstance()->getDpdPosScreen(); u8 oldAlpha = mAlpha; bool bIsInBounds = false; - if (field_0x705 == 1) { + if (mCalibrationPointCenterEnabled == true) { + // If we're in the initial "cursor center" process at startup or when manually calibrating, + // we need to make sure to only take the raw pointer inputs into account (transforming them + // to screen coordinates of course) mVec2_c dpdPos = mPad::getDpdRawPos(); dpdPosScreen.x = dGfx_c::getWidth4x3F() * 0.5f * (1.f + dpdPos.x) + dGfx_c::getWidth4x3LeftF(); dpdPosScreen.y = dGfx_c::getCurrentScreenHeightF() * -0.5f * (1.f + dpdPos.y) + dGfx_c::getCurrentScreenTopF(); @@ -112,11 +115,11 @@ int dCsBase_c::execute() { } int dCsBase_c::draw() { - if (field_0x704 == 1) { + if (mDrawDirectly == true) { return SUCCEEDED; } - if (field_0x703 && dPadNav::isPointerVisible() && mAlpha) { + if (mVisible && dPadNav::isPointerVisible() && mAlpha != 0) { nw4r::lyt::Pane *p = mpCurrLyt->getLayout()->GetRootPane(); nw4r::math::VEC3 pos; pos.x = mCsPosition.x; @@ -140,11 +143,11 @@ int dCsBase_c::update() { } bool dCsBase_c::drawDirectly() { - if (field_0x704 != 1) { + if (mDrawDirectly != true) { return true; } - if (field_0x703 && dPadNav::isPointerVisible() && mAlpha) { + if (mVisible && dPadNav::isPointerVisible() && mAlpha != 0) { nw4r::lyt::Pane *p = mpCurrLyt->getLayout()->GetRootPane(); nw4r::math::VEC3 pos; pos.x = mCsPosition.x; diff --git a/src/d/d_cs_game.cpp b/src/d/d_cs_game.cpp index 8d2b2a91..7163184a 100644 --- a/src/d/d_cs_game.cpp +++ b/src/d/d_cs_game.cpp @@ -149,7 +149,7 @@ int dCsGame_c::create() { mCursor.setField0x9A0(0); mCursorIf.setCursorMask(2); dCsMgr_c::GetInstance()->registCursor(&mCursorIf); - dCsBase_c::GetInstance()->setField703(false); + dCsBase_c::GetInstance()->setVisible(false); return SUCCEEDED; } diff --git a/src/d/d_dvd_drive_error.cpp b/src/d/d_dvd_drive_error.cpp index 3cf15bb2..68dace4a 100644 --- a/src/d/d_dvd_drive_error.cpp +++ b/src/d/d_dvd_drive_error.cpp @@ -142,7 +142,7 @@ void dDvdDriveError_c::execute() { if (!mIsError) { if (mDvdDriveStatus != DVD_STATE_IDLE && mDvdDriveStatus != DVD_STATE_BUSY) { mIsError = true; - dDvdUnk::FontUnk::GetInstance()->fn_80052C60(); + dDvdUnk::FontUnk::GetInstance()->onError(); } } else if (mDvdDriveStatus == DVD_STATE_IDLE) { if (!dReset::Manage_c::GetInstance()->isSoftResetOrSafetyWait()) { diff --git a/src/d/d_dvd_unk.cpp b/src/d/d_dvd_unk.cpp index 5732bdc8..e0225142 100644 --- a/src/d/d_dvd_unk.cpp +++ b/src/d/d_dvd_unk.cpp @@ -1,23 +1,237 @@ #include "d/d_dvd_unk.h" +#include "common.h" +#include "d/d_cs_base.h" +#include "d/d_cursor_hit_check.h" #include "d/d_dvd_drive_error.h" +#include "d/d_gfx.h" +#include "d/d_hbm.h" +#include "d/d_pad.h" +#include "d/d_pad_manager.h" +#include "d/d_s_boot.h" +#include "d/d_video.h" +#include "d/lyt/d_lyt_system_window.h" +#include "d/snd/d_snd_player_mgr.h" #include "egg/core/eggHeap.h" +#include "egg/gfx/eggTextureBuffer.h" +#include "rvl/NAND/nand.h" #include "toBeSorted/nand_result_tracker.h" - -#include "d/dol_backup_error_font.inc" - namespace dDvdUnk { +#include "d/dol_backup_error_font.inc" + FontUnk *FontUnk::sInstance; -extern "C" void fn_80059D10(EGG::Heap *heap); + void FontUnk::create(EGG::Heap *heap) { sInstance = new (heap, 0x04) FontUnk(); sInstance->init(); dDvdDriveError_c::create(heap); NandResultTracker::create(heap); - fn_80059D10(heap); + dPadManager_c::create(heap); sInstance->field_0x2C = 0; } +void FontUnk::execute() { + if (dHbm::Manage_c::GetInstance()->getState() == dHbm::Manage_c::HBM_MANAGE_ACTIVE) { + return; + } + + dDvdDriveError_c *driveError = dDvdDriveError_c::GetInstance(); + dPadManager_c *padManager = dPadManager_c::GetInstance(); + NandResultTracker *nandTracker = NandResultTracker::GetInstance(); + + // Errors in decreasing importance + switch (mErrorType) { + case ERROR_DISK: driveError->execute(); break; + case ERROR_PAD: + driveError->execute(); + padManager->execute(); + break; + case ERROR_NAND: + driveError->execute(); + padManager->execute(); + nandTracker->execute(); + break; + default: + driveError->execute(); + nandTracker->execute(); + padManager->execute(); + break; + } + if (checkFlag(FLAG_ERROR_REQUEST)) { + offFlag(FLAG_ERROR_REQUEST); + EGG::TextureBuffer *buf = dGfx_c::GetInstance()->getTextureBuffer(); + if (buf != nullptr) { + buf->capture(0, 0, false, -1); + } + onFlag(FLAG_ERROR_STATE); + } +} + +void FontUnk::drawNonDriveError() { + switch (mErrorType) { + case ERROR_PAD: dPadManager_c::GetInstance()->draw(); break; + case ERROR_NAND: NandResultTracker::GetInstance()->draw(); break; + default: break; + } +} + +void FontUnk::drawDriveError() { + if (mIsDiskError == true) { + dDvdDriveError_c::GetInstance()->draw(); + } +} + +void FontUnk::init() { + mIsDiskError = false; + mIsNandError = false; + mIsPadError = false; + mFlags = 0; + mDiskErrorCode = 0; + mNandErrorCode = 0; + field_0x2B = false; + mErrorType = ERROR_NONE; + mFont.SetResource(DOL_BACKUP_FONT); +} + +void dDvdUnk::FontUnk::fn_800529B0() { + mIsPadError = false; + field_0x2B = false; + if (dCsBase_c::GetInstance() == nullptr) { + return; + } + dCsBase_c::GetInstance()->setVisible(false); + dCsBase_c::GetInstance()->setDrawDirectly(false); + dCsBase_c::GetInstance()->setCalibrationPointCenterEnabled(false); +} + +void dDvdUnk::FontUnk::clearNandError() { + clearNandTrackerError(); + mIsNandError = false; + mNandErrorCode = 0; +} + +void dDvdUnk::FontUnk::fn_80052A20() { + if (dScBoot_c::GetInstance() == nullptr && !dPadManager_c::GetInstance()->isCalibrationFinished()) { + dPad::ex_c::setCalibrateMpls(); + } + + if (checkFlag(FLAG_ERROR_STATE)) { + dGfx_c::GetInstance()->releaseTextureBuffer(); + dSndPlayerMgr_c::GetInstance()->fn_8035E6E0(); + } + + if (dLytSystemWindow_c::GetInstance() != nullptr && dLytSystemWindow_c::GetInstance()->fn_80152F80()) { + dLytSystemWindow_c::GetInstance()->fn_80152F10(); + } + + mIsDiskError = false; + mIsNandError = false; + mIsPadError = false; + mFlags = false; + mDiskErrorCode = 0; + mNandErrorCode = 0; + field_0x2B = false; + mErrorType = ERROR_NONE; + + dPadManager_c::GetInstance()->init(); + NandResultTracker::GetInstance()->init(); +} + +void FontUnk::preExecute() { + if (dHbm::Manage_c::GetInstance()->getState() != dHbm::Manage_c::HBM_MANAGE_ACTIVE) { + dDvdDriveError_c *drive = dDvdDriveError_c::GetInstance(); + NandResultTracker *nand = NandResultTracker::GetInstance(); + dPadManager_c *pad = dPadManager_c::GetInstance(); + bool prevError = isAnyError(); + mIsDiskError = drive->isError(); + mDiskErrorCode = drive->getStatus(); + mIsNandError = nand->isError(); + mNandErrorCode = nand->getErrorCategory(); + + if (padErrorsAllowed() == true) { + mIsPadError = pad->isError(); + } + + // Errors in decreasing importance + if (mIsDiskError == true) { + mErrorType = ERROR_DISK; + } else if (mIsPadError == true) { + mErrorType = ERROR_PAD; + } else if (mIsNandError == true) { + mErrorType = ERROR_NAND; + } else { + mErrorType = ERROR_NONE; + } + + if (prevError && !isAnyError()) { + dGfx_c::GetInstance()->releaseTextureBuffer(); + offFlag(FLAG_ERROR_STATE); + dSndPlayerMgr_c::GetInstance()->fn_8035E6E0(); + } + + if (field_0x2C == true && !prevError && isAnyError()) { + dSndPlayerMgr_c::GetInstance()->fn_8035E620(); + } + } +} + +bool FontUnk::isAnyError() const { + return mIsDiskError | mIsNandError | mIsPadError; +} + +void FontUnk::onError() { + if (checkFlag(FLAG_ERROR_STATE)) { + return; + } + onFlag(FLAG_ERROR_REQUEST); + dVideo::enableDimming(1); +} + +void FontUnk::clearNandTrackerError() { + NandResultTracker::GetInstance()->isFailure(NAND_RESULT_OK); +} + +void FontUnk::fn_80052CC0() { + setNeedsPad(true); + field_0x2B = true; +} + +void FontUnk::setNeedsPad(bool b) { + if (dPadManager_c::GetInstance() != nullptr) { + dPadManager_c::GetInstance()->setField_0x1F(b); + } +} + +bool FontUnk::padErrorsAllowed() { + if (field_0x2B != true) { + return false; + } + + if (dPadManager_c::GetInstance() != nullptr) { + return dPadManager_c::GetInstance()->getField_0x1F(); + } + + return false; +} + +void FontUnk::fn_80052D50() { + if (dPadManager_c::GetInstance()->isError() == true) { + if (checkFlag(FLAG_ERROR_STATE)) { + dGfx_c::GetInstance()->releaseTextureBuffer(); + mFlags = 0; + dSndPlayerMgr_c::GetInstance()->fn_8035E6E0(); + } + dPadManager_c::GetInstance()->init(); + } + setNeedsPad(false); + dVideo::enableDimming(0); +} + +void FontUnk::fn_80052DD0() { + setNeedsPad(true); + dVideo::enableDimming(1); +} + } // namespace dDvdUnk diff --git a/src/d/d_pad_manager.cpp b/src/d/d_pad_manager.cpp index 255fa7a1..7c63d0ba 100644 --- a/src/d/d_pad_manager.cpp +++ b/src/d/d_pad_manager.cpp @@ -42,7 +42,7 @@ bool dPadManager_c::draw() { } void dPadManager_c::init() { - field_0x22 = false; + mSavedCsDrawDirectly = false; field_0x23 = false; ModeRequestNormal(); field_0x1E = false; @@ -94,10 +94,10 @@ void dPadManager_c::executeProc() { void dPadManager_c::ModeRequestNormal() { ModeRequest(Normal); - field_0x1C = false; + mIsError = false; field_0x1D = false; if (dCsBase_c::GetInstance() != nullptr) { - dCsBase_c::GetInstance()->setField704(field_0x22); + dCsBase_c::GetInstance()->setDrawDirectly(mSavedCsDrawDirectly); if (field_0x23) { dPadNav::setCursorStickVisible(); } else { @@ -110,8 +110,8 @@ void dPadManager_c::ModeProc_Normal() { PadStatus_e status = getPadStatus(); if (status == PAD_NORMAL || status == PAD_CONFIGURING_MPLS) { if (isOutOfBattery() == true) { - field_0x1C = true; - dDvdUnk::FontUnk::GetInstance()->fn_80052C60(); + mIsError = true; + dDvdUnk::FontUnk::GetInstance()->onError(); ModeRequestLowBattery(); } return; @@ -119,15 +119,15 @@ void dPadManager_c::ModeProc_Normal() { // Some sort of error occured - field_0x1C = true; + mIsError = true; mPadStatus = status; dCsBase_c *cs = dCsBase_c::GetInstance(); - field_0x22 = cs->getField704(); - cs->setField704(false); + mSavedCsDrawDirectly = cs->getDrawDirectly(); + cs->setDrawDirectly(false); cs->setCursorStickVisible(false); field_0x23 = dPadNav::isCursorStickVisible(); dPadNav::setCursorStickInvisible(); - dDvdUnk::FontUnk::GetInstance()->fn_80052C60(); + dDvdUnk::FontUnk::GetInstance()->onError(); if (status == PAD_DISCONNECTED) { ModeRequestReconnectPad(); @@ -468,9 +468,9 @@ void dPadManager_c::ModeProc_PointCenter() { case 0: // "Point the Wii Remote at the screen, and move to the center." if (mpWindow->setProperties("SYS_MPLS_02", false, nullptr) == true) { - dCsBase_c::GetInstance()->setField703(true); - dCsBase_c::GetInstance()->setField704(true); - dCsBase_c::GetInstance()->setField705(true); + dCsBase_c::GetInstance()->setVisible(true); + dCsBase_c::GetInstance()->setDrawDirectly(true); + dCsBase_c::GetInstance()->setCalibrationPointCenterEnabled(true); mStep = 1; } break; @@ -532,9 +532,9 @@ void dPadManager_c::ModeProc_PointCenter() { if (mpWindow->getField_0xDF7() == true) { field_0x1E = true; field_0x25 = false; - dCsBase_c::GetInstance()->setField703(false); - dCsBase_c::GetInstance()->setField704(false); - dCsBase_c::GetInstance()->setField705(false); + dCsBase_c::GetInstance()->setVisible(false); + dCsBase_c::GetInstance()->setDrawDirectly(false); + dCsBase_c::GetInstance()->setCalibrationPointCenterEnabled(false); ModeRequestNormal(); return; } @@ -547,9 +547,9 @@ void dPadManager_c::ModeProc_PointCenter() { case 11: if (mpWindow->getField_0xDF7() == true) { ModeRequestNext(status); - dCsBase_c::GetInstance()->setField703(false); - dCsBase_c::GetInstance()->setField704(false); - dCsBase_c::GetInstance()->setField705(false); + dCsBase_c::GetInstance()->setVisible(false); + dCsBase_c::GetInstance()->setDrawDirectly(false); + dCsBase_c::GetInstance()->setCalibrationPointCenterEnabled(false); return; } break; @@ -736,7 +736,7 @@ void dPadManager_c::ModeRequest(Mode_e mode) { dPadManager_c::PadStatus_e dPadManager_c::getPadStatus() { PadStatus_e ret = PAD_NORMAL; - if (dDvdUnk::FontUnk::GetInstance()->fn_80052D20() != true) { + if (dDvdUnk::FontUnk::GetInstance()->padErrorsAllowed() != true) { return PAD_NORMAL; } @@ -787,7 +787,7 @@ s32 dPadManager_c::get1Point5SecondsInTicks() { } bool dPadManager_c::isOutOfBattery() { - if (dDvdUnk::FontUnk::GetInstance()->fn_80052D20() != true) { + if (dDvdUnk::FontUnk::GetInstance()->padErrorsAllowed() != true) { return false; } diff --git a/src/d/d_reset.cpp b/src/d/d_reset.cpp index 4f2910f2..15331958 100644 --- a/src/d/d_reset.cpp +++ b/src/d/d_reset.cpp @@ -26,6 +26,7 @@ #include "rvl/OS/OSThread.h" #include "rvl/VI/vi.h" #include "toBeSorted/file_manager.h" +#include "toBeSorted/nand_result_tracker.h" #include "toBeSorted/save_manager.h" #include "rvl/OS.h" @@ -339,12 +340,12 @@ void Manage_c::ModeProc_SoftReset() { dDvdUnk::FontUnk::GetInstance()->fn_800529B0(); dSndPlayerMgr_c::GetInstance()->fn_8035E6E0(); - if (dDvdUnk::FontUnk::GetInstance()->getField_0x29() || - dDvdUnk::FontUnk::GetInstance()->getField_0x24() || + if (dDvdUnk::FontUnk::GetInstance()->isNandError() || + dDvdUnk::FontUnk::GetInstance()->getNandError() != NandResultTracker::ERR_CAT_NONE || SaveMgr::GetInstance()->getCheckForFreeSpaceResult()) { dScBoot_c::GetInstance()->setField_0x5E3(0); dScBoot_c::GetInstance()->setField_0x5E2(1); - dDvdUnk::FontUnk::GetInstance()->fn_800529E0(); + dDvdUnk::FontUnk::GetInstance()->clearNandError(); } dDvdUnk::FontUnk::GetInstance()->fn_80052A20(); } @@ -356,9 +357,9 @@ void Manage_c::ModeProc_SoftReset() { dDvdUnk::FontUnk::GetInstance()->fn_800529B0(); dDvdUnk::FontUnk::GetInstance()->fn_80052A20(); - dCsBase_c::GetInstance()->setField703(false); - dCsBase_c::GetInstance()->setField704(false); - dCsBase_c::GetInstance()->setField705(false); + dCsBase_c::GetInstance()->setVisible(false); + dCsBase_c::GetInstance()->setDrawDirectly(false); + dCsBase_c::GetInstance()->setCalibrationPointCenterEnabled(false); field_0x66 = false; } @@ -564,7 +565,7 @@ bool Manage_c::IsFatalError() { } bool Manage_c::IsDiskError() { - return dDvdUnk::FontUnk::GetInstance()->getField_0x28(); + return dDvdUnk::FontUnk::GetInstance()->isDiskError(); } bool Manage_c::FadeOutCalc() { @@ -581,9 +582,9 @@ void Manage_c::FadeOutRequest(bool fade) { dDvdUnk::FontUnk::GetInstance()->fn_800529B0(); dDvdUnk::FontUnk::GetInstance()->fn_80052A20(); - dCsBase_c::GetInstance()->setField703(false); - dCsBase_c::GetInstance()->setField704(false); - dCsBase_c::GetInstance()->setField705(false); + dCsBase_c::GetInstance()->setVisible(false); + dCsBase_c::GetInstance()->setDrawDirectly(false); + dCsBase_c::GetInstance()->setCalibrationPointCenterEnabled(false); field_0x66 = 0; diff --git a/src/d/d_sc_title.cpp b/src/d/d_sc_title.cpp index 73e578d7..31f2b0fc 100644 --- a/src/d/d_sc_title.cpp +++ b/src/d/d_sc_title.cpp @@ -42,9 +42,6 @@ static const char *sLayoutArcsToLoad[] = { STATE_VIRTUAL_DEFINE(dScTitle_c, Stanby); STATE_VIRTUAL_DEFINE(dScTitle_c, Action); -extern "C" void *lbl_805750D8; -extern "C" void fn_80052D50(void *); - dScTitle_c::dScTitle_c() { sInstance = this; mRelCtrl.set(sModulesToLoad, ARRAY_LENGTH(sModulesToLoad)); diff --git a/src/toBeSorted/nand_result_tracker.cpp b/src/toBeSorted/nand_result_tracker.cpp new file mode 100644 index 00000000..bd877255 --- /dev/null +++ b/src/toBeSorted/nand_result_tracker.cpp @@ -0,0 +1,118 @@ +#include "toBeSorted/nand_result_tracker.h" + +#include "common.h" +#include "d/d_dvd_unk.h" +#include "d/d_gfx.h" +#include "d/lyt/d_lyt_system_window.h" +#include "egg/core/eggHeap.h" + +NandResultTracker *NandResultTracker::sInstance; + +void NandResultTracker::create(EGG::Heap *heap) { + sInstance = new (heap) NandResultTracker(); + sInstance->init(); +} + +NandResultTracker *NandResultTracker::GetInstance() { + return sInstance; +} + +bool NandResultTracker::isFailure(NANDResult status) { + bool ret = true; + + switch (status) { + case NAND_RESULT_OK: + case NAND_RESULT_EXISTS: + case NAND_RESULT_NOEXISTS: { + mErrorCategory = ERR_CAT_NONE; + ret = false; + break; + } + case NAND_RESULT_ECC_CRIT: + case NAND_RESULT_AUTHENTICATION: { + mErrorCategory = ERR_CAT_SAVE_MGR; + break; + } + default: { + mErrorCategory = ERR_CAT_FATAL; + break; + } + } + + return ret; +} + +void NandResultTracker::draw() { + dGfx_c::doDrawCapTexture(); +} + +void NandResultTracker::execute() { + static const ModeFunc procs[] = { + &NandResultTracker::ModeProc_Normal, + &NandResultTracker::ModeProc_Error, + }; + ModeFunc f = procs[mMode]; + if (f != nullptr) { + (this->*f)(); + } +} + +void NandResultTracker::init() { + mErrorCategory = ERR_CAT_NONE; + mIsError = false; + ModeRequestNormal(); +} + +void NandResultTracker::ModeRequestNormal() { + ModeRequest(Normal); +} + +void NandResultTracker::ModeProc_Normal() { + if (mErrorCategory != ERR_CAT_NONE && mErrorCategory != ERR_CAT_SAVE_MGR) { + mIsError = true; + dDvdUnk::FontUnk::GetInstance()->onError(); + } else { + mIsError = false; + } + + if (mErrorCategory != ERR_CAT_NONE && mErrorCategory != ERR_CAT_SAVE_MGR) { + ModeRequestError(); + } +} + +void NandResultTracker::ModeRequestError() { + ModeRequest(Error); +} + +void NandResultTracker::ModeProc_Error() { + // Note: Only index 3 (SYS_NAND_12) is reachable apparently +#pragma push +#pragma readonly_strings on + static const char *sMessages[] = { + // "The Wii system memory has been damaged. Refer to the Wii Operations Manual for details." + "SYS_NAND_08", + "SYS_NAND_08", + // "Could not access Wii system memory. Refer to the Wii Operations Manual for details." + "SYS_NAND_11", + // "An error occurred while accessing Wii system memory. Refer to the Wii Operations Manual for details." + "SYS_NAND_12", + "SYS_NAND_12", + }; +#pragma pop + dLytSystemWindow_c *window = dLytSystemWindow_c::GetInstance(); + s32 error = GetInstance()->getErrorCategory(); + + switch (mStep) { + case 0: + if (window->setProperties(sMessages[error], false, nullptr) == true) { + mStep = 1; + } + break; + default: break; + } +} + +void NandResultTracker::ModeRequest(Mode_e mode) { + mMode = mode; + mStep = 0; +} diff --git a/src/toBeSorted/save_manager.cpp b/src/toBeSorted/save_manager.cpp index cb023b03..221d129a 100644 --- a/src/toBeSorted/save_manager.cpp +++ b/src/toBeSorted/save_manager.cpp @@ -81,7 +81,7 @@ void SaveMgr::init() { mDelayTimer = 0; FileManager::GetInstance()->setField0xA840(1); if (dCsBase_c::GetInstance() != nullptr) { - dCsBase_c::GetInstance()->setField704(false); + dCsBase_c::GetInstance()->setDrawDirectly(false); } if (mpWindow != nullptr) { mpWindow->reset(); @@ -175,7 +175,7 @@ bool SaveMgr::saveAfterCredits() { return false; } field_0x836 = 0; - dDvdUnk::FontUnk::GetInstance()->fn_80052D00(true); + dDvdUnk::FontUnk::GetInstance()->setNeedsPad(true); FileManager::GetInstance()->setFileTimes(); FileManager::GetInstance()->saveAfterCredits(); initializeSave(); @@ -218,7 +218,7 @@ void SaveMgr::initializeCheckForSave() { beginState(STATE_CHECK_FOR_SAVE); mCheckIsFileRequest.checkIsFile(sSaveFileName); field_0x839 = 0; - dDvdUnk::FontUnk::GetInstance()->fn_80052D00(false); + dDvdUnk::FontUnk::GetInstance()->setNeedsPad(false); } void SaveMgr::executeCheckForSave() { @@ -290,7 +290,7 @@ void SaveMgr::executeCheckForSave() { void SaveMgr::initializeCheckForFreeSpace() { beginState(STATE_CHECK_FOR_FREE_SPACE); - dDvdUnk::FontUnk::GetInstance()->fn_80052D00(false); + dDvdUnk::FontUnk::GetInstance()->setNeedsPad(false); mCheckRequest.check(7, 3); mCheckForFreeSpaceResult = 0; } @@ -327,7 +327,7 @@ void SaveMgr::initializeCreateFiles() { beginState(STATE_CREATE_FILES); field_0x838 = 1; FileManager::GetInstance()->setField0xA84D(1); - dDvdUnk::FontUnk::GetInstance()->fn_80052D00(false); + dDvdUnk::FontUnk::GetInstance()->setNeedsPad(false); } void SaveMgr::executeCreateFiles() { @@ -510,7 +510,7 @@ void SaveMgr::executeSaveBanner() { } if (b == 1) { - if (!dDvdUnk::FontUnk::GetInstance()->getField_0x28()) { + if (!dDvdUnk::FontUnk::GetInstance()->isDiskError()) { dSndSmallEffectMgr_c::GetInstance()->playSound(SE_S_SAVE_FINISH); } mDelayTimer = 0; @@ -532,8 +532,8 @@ void SaveMgr::executeSaveBanner() { } case 5: { if (mpWindow->getWillFinishOut() == 1) { - if (fontUnk->getField_0x29() == 1) { - fontUnk->fn_80052C90(); + if (fontUnk->isNandError() == 1) { + fontUnk->clearNandTrackerError(); } field_0x838 = 0; field_0x83A = 0; @@ -721,7 +721,7 @@ void SaveMgr::executeLoadSave() { void SaveMgr::initializeWriteSave() { beginState(STATE_WRITE); mDelayTimer = 0; - dDvdUnk::FontUnk::GetInstance()->fn_80052D00(false); + dDvdUnk::FontUnk::GetInstance()->setNeedsPad(false); FileManager::GetInstance()->setField0xA84D(1); field_0x83D = 1; } @@ -1110,7 +1110,7 @@ void SaveMgr::executeClearSelectedFile() { void SaveMgr::initializeSave() { beginState(STATE_SAVE); FileManager::GetInstance()->setField0xA840(0); - dDvdUnk::FontUnk::GetInstance()->fn_80052D00(false); + dDvdUnk::FontUnk::GetInstance()->setNeedsPad(false); FileManager::GetInstance()->setField_0xA843(1); } @@ -1218,7 +1218,7 @@ void SaveMgr::initializeError() { FileManager::GetInstance()->setField0xA84D(0); field_0x83D = 0; beginState(STATE_ERROR); - dDvdUnk::FontUnk::GetInstance()->fn_80052D00(true); + dDvdUnk::FontUnk::GetInstance()->setNeedsPad(true); field_0x83F = 0; } @@ -1227,7 +1227,7 @@ void SaveMgr::executeError() { FileManager *fileManager = FileManager::GetInstance(); switch (mStep) { case 0: { - if (dDvdUnk::FontUnk::GetInstance()->getField_0x24() == 4) { + if (dDvdUnk::FontUnk::GetInstance()->getNandError() == NandResultTracker::ERR_CAT_SAVE_MGR) { if (field_0x837 == true) { // "The save data is corrupted. Save data will be restored." if (systemWindow->setProperties("SYS_INIT_05", false, nullptr) == true) { @@ -1239,7 +1239,7 @@ void SaveMgr::executeError() { if (systemWindow->setProperties("SYS_INIT_04", false, nullptr) == true) { systemWindow->showMaybe(4); mStep = 1; - dCsBase_c::GetInstance()->setField704(true); + dCsBase_c::GetInstance()->setDrawDirectly(true); } } else { // "The file cannot be used because nthe data is corrupted. All data saved up to this point will be @@ -1247,7 +1247,7 @@ void SaveMgr::executeError() { if (systemWindow->setProperties("SYS_NAND_07", false, nullptr) == true) { systemWindow->showMaybe(4); mStep = 1; - dCsBase_c::GetInstance()->setField704(true); + dCsBase_c::GetInstance()->setDrawDirectly(true); } } } @@ -1274,7 +1274,7 @@ void SaveMgr::executeError() { mStep = 3; } else { initializeDeleteAllData(); - dCsBase_c::GetInstance()->setField704(false); + dCsBase_c::GetInstance()->setDrawDirectly(false); } } break; @@ -1336,11 +1336,11 @@ void SaveMgr::executeError() { } case 10: { if (systemWindow->fn_80152F70() == true) { - dDvdUnk::FontUnk::GetInstance()->fn_80052C90(); + dDvdUnk::FontUnk::GetInstance()->clearNandTrackerError(); if (field_0x837 != true) { fileManager->setField0xA84C(1); } - dCsBase_c::GetInstance()->setField704(false); + dCsBase_c::GetInstance()->setDrawDirectly(false); endState(); } break; @@ -1372,7 +1372,7 @@ void SaveMgr::executeError() { void SaveMgr::initializeNandError() { FileManager::GetInstance()->setField0xA84D(0); field_0x83D = 0; - dDvdUnk::FontUnk::GetInstance()->fn_80052D00(true); + dDvdUnk::FontUnk::GetInstance()->setNeedsPad(true); beginState(STATE_NAND_ERROR); } @@ -1424,7 +1424,7 @@ void SaveMgr::executeNandError() { // "Do you want to go to the Wii console's Data Management screen to edit data? [1]Yes[2]No" if (systemWindow->setProperties("SYS_NAND_04", false, nullptr) == true) { systemWindow->showMaybe(4); - dCsBase_c::GetInstance()->setField704(true); + dCsBase_c::GetInstance()->setDrawDirectly(true); mStep = 5; } break; @@ -1455,7 +1455,7 @@ void SaveMgr::executeNandError() { if (systemWindow->getField_0xDE0() == 0) { mStep = 9; } else { - dCsBase_c::GetInstance()->setField704(false); + dCsBase_c::GetInstance()->setDrawDirectly(false); dReset::Manage_c::GetInstance()->SetInteriorReturnDataManager(); endState(); field_0x836 = 0; @@ -1501,8 +1501,8 @@ void SaveMgr::executeNandError() { } case 13: { if (systemWindow->fn_80152F70() == 1) { - dCsBase_c::GetInstance()->setField704(false); - dDvdUnk::FontUnk::GetInstance()->fn_80052C90(); + dCsBase_c::GetInstance()->setDrawDirectly(false); + dDvdUnk::FontUnk::GetInstance()->clearNandTrackerError(); fileManager->setField0xA84C(1); endState(); } @@ -1522,7 +1522,7 @@ void SaveMgr::endState() { field_0x836 = 1; FileManager::GetInstance()->setField0xA840(1); field_0x83D = 0; - dDvdUnk::FontUnk::GetInstance()->fn_80052D00(true); + dDvdUnk::FontUnk::GetInstance()->setNeedsPad(true); field_0x83B = 0; field_0x83C = 0; mCurrentState = STATE_MAX; From 0be5f872286ad600dd0485da377cf8bdb7542526 Mon Sep 17 00:00:00 2001 From: robojumper Date: Sat, 2 Aug 2025 09:20:00 +0200 Subject: [PATCH 3/4] d_s_boot progress --- config/SOUE01/rels/d_s_bootNP/symbols.txt | 2 +- config/SOUE01/symbols.txt | 4 +- include/d/d_gfx.h | 8 +- include/d/d_pad_manager.h | 5 +- include/d/d_s_boot.h | 33 ++-- include/toBeSorted/save_related.h | 12 ++ src/REL/d/d_s_boot.cpp | 229 +++++++++++++++++++--- src/d/d_gfx.cpp | 10 +- src/d/d_pad_manager.cpp | 6 +- src/d/d_reset.cpp | 11 +- 10 files changed, 252 insertions(+), 68 deletions(-) diff --git a/config/SOUE01/rels/d_s_bootNP/symbols.txt b/config/SOUE01/rels/d_s_bootNP/symbols.txt index 84a375b5..31754f44 100644 --- a/config/SOUE01/rels/d_s_bootNP/symbols.txt +++ b/config/SOUE01/rels/d_s_bootNP/symbols.txt @@ -52,7 +52,7 @@ finalizeState_Connect__9dScBoot_cFv = .text:0x00001DB0; // type:function size:0x initializeState_Save__9dScBoot_cFv = .text:0x00001DC0; // type:function size:0x18 executeState_Save__9dScBoot_cFv = .text:0x00001DE0; // type:function size:0x29C finalizeState_Save__9dScBoot_cFv = .text:0x00002080; // type:function size:0x4 -fn_3_2090 = .text:0x00002090; // type:function size:0x78 +tryLoadTitleScreen__9dScBoot_cFv = .text:0x00002090; // type:function size:0x78 checkDone__9dScBoot_cFv = .text:0x00002110; // type:function size:0x2C build__24sFStateFct_c<9dScBoot_c>FRC12sStateIDIf_c = .text:0x00002140; // type:function size:0x60 dispose__24sFStateFct_c<9dScBoot_c>FRP10sStateIf_c = .text:0x000021A0; // type:function size:0xC diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index a2ed088c..6adab5b6 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -527,8 +527,8 @@ fn_80015DE0 = .text:0x80015DE0; // type:function size:0x8 fn_80015DF0 = .text:0x80015DF0; // type:function size:0x48 create__11SaveRelatedFv = .text:0x80015E40; // type:function size:0x38 remove__11SaveRelatedFv = .text:0x80015E80; // type:function size:0x18 -fn_80015EA0 = .text:0x80015EA0; // type:function size:0x14 -fn_80015EC0 = .text:0x80015EC0; // type:function size:0x74 +fn_80015EA0__11SaveRelatedFv = .text:0x80015EA0; // type:function size:0x14 +fn_80015EC0__11SaveRelatedFv = .text:0x80015EC0; // type:function size:0x74 fn_80015F40__11SaveRelatedFv = .text:0x80015F40; // type:function size:0xC fn_80015F50 = .text:0x80015F50; // type:function size:0x8 fn_80015F60 = .text:0x80015F60; // type:function size:0x14 diff --git a/include/d/d_gfx.h b/include/d/d_gfx.h index 826e8d33..f1ec0e32 100644 --- a/include/d/d_gfx.h +++ b/include/d/d_gfx.h @@ -28,8 +28,8 @@ public: mDrawCallback = cb; } - void setField0x09(u8 val) { - field_0x09 = val; + void setLetterboxEnabled(bool val) { + mLetterboxEnabled = val; } static dGfx_c *GetInstance() { @@ -142,8 +142,8 @@ private: /* 0x00 */ EGG::TextureBuffer *mpTextureBuffer; /* 0x04 */ DrawCallback mDrawCallback; - /* 0x08 */ u8 field_0x08; - /* 0x09 */ u8 field_0x09; + /* 0x08 */ u8 mBufRefcount; + /* 0x09 */ bool mLetterboxEnabled; }; #endif diff --git a/include/d/d_pad_manager.h b/include/d/d_pad_manager.h index 7db0cfbc..8cd5725d 100644 --- a/include/d/d_pad_manager.h +++ b/include/d/d_pad_manager.h @@ -24,6 +24,9 @@ public: bool isCalibrationFinished() const { return mCalibrationFinished; } + bool isCalibrationSkipped() const { + return mCalibrationSkipped; + } bool getField_0x25() const { return field_0x25; } @@ -114,7 +117,7 @@ private: /* 0x21 */ bool mCalibrationFinished; /* 0x22 */ bool mSavedCsDrawDirectly; /* 0x23 */ bool field_0x23; - /* 0x24 */ bool field_0x24; + /* 0x24 */ bool mCalibrationSkipped; /* 0x25 */ bool field_0x25; static dPadManager_c *sInstance; diff --git a/include/d/d_s_boot.h b/include/d/d_s_boot.h index e87c371c..428f04e5 100644 --- a/include/d/d_s_boot.h +++ b/include/d/d_s_boot.h @@ -24,22 +24,22 @@ public: return sInstance; } - u8 getField_0x5E2() const { + bool getField_0x5E2() const { return field_0x5E2; } - void setField_0x5E2(u8 val) { + void setField_0x5E2(bool val) { field_0x5E2 = val; } - u8 getField_0x5E3() const { + bool getField_0x5E3() const { return field_0x5E3; } - void setField_0x5E3(u8 val) { + void setField_0x5E3(bool val) { field_0x5E3 = val; } - u8 getField_0x5E4() const { + bool getField_0x5E4() const { return field_0x5E4; } - void setField_0x5E4(u8 val) { + void setField_0x5E4(bool val) { field_0x5E4 = val; } @@ -76,6 +76,7 @@ private: virtual void deleteReady() override; bool checkDone(); + bool tryLoadTitleScreen(); static void drawCallback(); @@ -99,16 +100,16 @@ private: /* 0x574 */ STATE_MGR_DECLARE(dScBoot_c); /* 0x5B4 */ dFader_c mFader; /* 0x5D4 */ s32 mProgressStage; - /* 0x5D8 */ u32 field_0x5D8; - /* 0x5DC */ u8 field_0x5DC; - /* 0x5DD */ u8 field_0x5DD; - /* 0x5DE */ u8 field_0x5DE; - /* 0x5DF */ u8 field_0x5DF; - /* 0x5E0 */ u8 field_0x5E0; - /* 0x5E1 */ u8 field_0x5E1; - /* 0x5E2 */ u8 field_0x5E2; - /* 0x5E3 */ u8 field_0x5E3; - /* 0x5E4 */ u8 field_0x5E4; + /* 0x5D8 */ s32 field_0x5D8; + /* 0x5DC */ bool mStrapScreenSeen; + /* 0x5DD */ bool mCalibrationDone; + /* 0x5DE */ bool mAllDataLoaded; + /* 0x5DF */ bool mObjectDataLoaded; + /* 0x5E0 */ bool field_0x5E0; + /* 0x5E1 */ bool mStrapScreenVisible; + /* 0x5E2 */ bool field_0x5E2; + /* 0x5E3 */ bool field_0x5E3; + /* 0x5E4 */ bool field_0x5E4; }; #endif diff --git a/include/toBeSorted/save_related.h b/include/toBeSorted/save_related.h index f6c85a1c..0072dc1c 100644 --- a/include/toBeSorted/save_related.h +++ b/include/toBeSorted/save_related.h @@ -1,6 +1,8 @@ #ifndef SAVE_RELATED_H #define SAVE_RELATED_H +#include "common.h" + class SaveRelated { public: static void create(); @@ -10,10 +12,20 @@ public: return sInstance; } + void fn_80015EA0(); + void fn_80015EC0(); void fn_80015F40(); + bool getField_0x09() const { + return field_0x09; + } + private: static SaveRelated *sInstance; + + /* 0x00 */ u8 _0x00[0x08 - 0x00]; + /* 0x08 */ u8 field_0x08; + /* 0x09 */ bool field_0x09; }; #endif diff --git a/src/REL/d/d_s_boot.cpp b/src/REL/d/d_s_boot.cpp index 19984abf..746d8713 100644 --- a/src/REL/d/d_s_boot.cpp +++ b/src/REL/d/d_s_boot.cpp @@ -2,6 +2,7 @@ #include "common.h" #include "d/d_base.h" +#include "d/d_cs_base.h" #include "d/d_d2d.h" #include "d/d_dvd_unk.h" #include "d/d_dylink.h" @@ -10,8 +11,11 @@ #include "d/d_hbm.h" #include "d/d_heap.h" #include "d/d_message.h" +#include "d/d_pad.h" #include "d/d_pad_manager.h" +#include "d/d_pad_nav.h" #include "d/d_reset.h" +#include "d/d_sc_title.h" #include "d/d_scene.h" #include "d/d_sys.h" #include "d/lyt/d_lyt_battery.h" @@ -33,6 +37,7 @@ #include "toBeSorted/d_emitter.h" #include "toBeSorted/d_particle.h" #include "toBeSorted/fi_context.h" +#include "toBeSorted/file_manager.h" #include "toBeSorted/save_manager.h" #include "toBeSorted/save_related.h" #include "toBeSorted/special_item_drop_mgr.h" @@ -244,7 +249,7 @@ sFPhaseBase::sFPhaseState dScBoot_c::cb6() { } dDvdUnk::FontUnk::GetInstance()->setField_0x2C(1); - field_0x5DF = 1; + mObjectDataLoaded = true; return sFPhaseBase::PHASE_NEXT; } @@ -401,12 +406,12 @@ void dScBoot_c::strap_c::init() { } dScBoot_c::dScBoot_c() : mStateMgr(*this, sStateID::null), mPhases(this, sCallbacks), mpDvdCallback(nullptr) { - field_0x5DF = 0; + mObjectDataLoaded = false; sInstance = this; - field_0x5E1 = 0; - field_0x5E2 = 0; - field_0x5E3 = 0; - field_0x5E4 = 0; + mStrapScreenVisible = false; + field_0x5E2 = false; + field_0x5E3 = false; + field_0x5E4 = false; } dScBoot_c::~dScBoot_c() { @@ -438,7 +443,7 @@ int dScBoot_c::doDelete() { dBase_c::createRoot(fProfile::LAST, 0, 0); d3d::createLightTextures(); SpecialItemDropMgr::create(); - dHbm::Manage_c::GetInstance()->offFlags(8); + dHbm::Manage_c::GetInstance()->offFlags(0x8); dGfx_c::GetInstance()->setDrawCallback(nullptr); dReset::Manage_c::GetInstance()->BootComplete(true); return SUCCEEDED; @@ -448,15 +453,15 @@ int dScBoot_c::execute() { mFader.calc(); mStateMgr.executeState(); sFPhaseBase::sFPhaseState state = executeLoadPhase(); - if (field_0x5DE == 0 && state == sFPhaseBase::PHASE_ALL_DONE) { - field_0x5DE = 1; + if (mAllDataLoaded == false && state == sFPhaseBase::PHASE_ALL_DONE) { + mAllDataLoaded = true; } return SUCCEEDED; } int dScBoot_c::draw() { - if (field_0x5E1 == 1) { + if (mStrapScreenVisible == true) { mStrapScreen.draw(); } @@ -464,16 +469,16 @@ int dScBoot_c::draw() { } void dScBoot_c::deleteReady() { - // TODO + // no-op } void dScBoot_c::initializeState_Init() { mProgressStage = 0; field_0x5D8 = 0; - field_0x5DC = 0; - field_0x5DD = 0; - field_0x5DE = 0; - field_0x5E0 = 0; + mStrapScreenSeen = false; + mCalibrationDone = false; + mAllDataLoaded = false; + field_0x5E0 = false; } void dScBoot_c::executeState_Init() { @@ -484,7 +489,7 @@ void dScBoot_c::finalizeState_Init() {} void dScBoot_c::initializeState_Strap() { mProgressStage = 0; - field_0x5E1 = 1; + mStrapScreenVisible = true; mFader.fadeIn(); mFader.resetFrames(); } @@ -505,7 +510,7 @@ void dScBoot_c::executeState_Strap() { } if (ok) { - field_0x5DC = 1; + mStrapScreenSeen = true; if (mFader.fadeOut() == true) { mProgressStage = 2; } @@ -516,7 +521,7 @@ void dScBoot_c::executeState_Strap() { if (!checkDone() && mFader.isNotStatus(mFaderBase_c::FADING_OUT)) { if (mFader.fadeIn() == true) { mProgressStage = 3; - field_0x5E1 = 0; + mStrapScreenVisible = false; } } break; @@ -528,9 +533,9 @@ void dScBoot_c::executeState_Strap() { case 4: mFader.setStatus(mFaderBase_c::FADED_OUT); if (mFader.fadeIn() == true) { - field_0x5E4 = 1; - if (field_0x5DC != 0) { - field_0x5E1 = 0; + field_0x5E4 = true; + if (mStrapScreenSeen != false) { + mStrapScreenVisible = false; mStateMgr.changeState(StateID_Connect); } else { mProgressStage = 0; @@ -544,8 +549,7 @@ void dScBoot_c::executeState_Strap() { } void dScBoot_c::finalizeState_Strap() { - // TODO - dGfx_c::GetInstance()->setField0x09(1); + dGfx_c::GetInstance()->setLetterboxEnabled(1); } void dScBoot_c::initializeState_Connect() { @@ -554,7 +558,91 @@ void dScBoot_c::initializeState_Connect() { } void dScBoot_c::executeState_Connect() { - // TODO + switch (mProgressStage) { + case 0: + if (field_0x5E3 == true) { + field_0x5E3 = false; + mProgressStage = 4; + } else if (mObjectDataLoaded == true) { + mProgressStage = 1; + } + break; + case 1: + if (field_0x5E3 == true) { + field_0x5E3 = false; + mProgressStage = 4; + } else { + dHbm::Manage_c::GetInstance()->offFlags(0x8); + dDvdUnk::FontUnk::GetInstance()->fn_80052CC0(); + mProgressStage = 2; + } + break; + case 2: + if (field_0x5E3 == true) { + field_0x5E3 = false; + mProgressStage = 5; + } else { + mProgressStage = 3; + } + break; + case 3: + if (field_0x5E3 == true) { + field_0x5E3 = false; + mProgressStage = 5; + } else if (dPadManager_c::GetInstance()->isCalibrationFinished() || + dPadManager_c::GetInstance()->isCalibrationSkipped()) { + mCalibrationDone = true; + mStateMgr.changeState(StateID_Save); + } + break; + case 4: + mFader.setStatus(mFaderBase_c::FADED_OUT); + if (mFader.fadeIn() == true) { + field_0x5E4 = true; + if (mObjectDataLoaded == true) { + mProgressStage = 1; + } else { + mProgressStage = 0; + } + dHbm::Manage_c::GetInstance()->fn_80197560(0); + } + break; + case 5: + mFader.setStatus(mFaderBase_c::FADED_OUT); + if (mFader.fadeIn() == true) { + field_0x5E4 = true; + mProgressStage = 6; + } + break; + case 6: + if (mFader.isNotStatus(mFaderBase_c::FADING_IN)) { + if (dReset::Manage_c::GetInstance()->isSoftReset()) { + if (dPadManager_c::GetInstance()->isCalibrationFinished() == true && + dPadManager_c::GetInstance()->getField_0x25() == false) { + mCalibrationDone = true; + mStateMgr.changeState(StateID_Save); + } else { + mProgressStage = 2; + } + } else { + dHbm::Manage_c::GetInstance()->fn_80197560(0); + if (dPadManager_c::GetInstance()->isCalibrationFinished() == true) { + if (dPadManager_c::GetInstance()->getField_0x25() == false) { + mCalibrationDone = true; + mStateMgr.changeState(StateID_Save); + } else { + dDvdUnk::FontUnk::GetInstance()->fn_80052CC0(); + mProgressStage = 2; + } + } else { + dPad::ex_c::setCalibrateMpls(); + dDvdUnk::FontUnk::GetInstance()->fn_80052CC0(); + mProgressStage = 2; + } + } + } + break; + } } void dScBoot_c::finalizeState_Connect() {} @@ -566,16 +654,95 @@ void dScBoot_c::initializeState_Save() { } void dScBoot_c::executeState_Save() { - // TODO + switch (mProgressStage) { + case 0: + if (field_0x5E3 == true) { + field_0x5E3 = false; + field_0x5D8 = mProgressStage; + dDvdUnk::FontUnk::GetInstance()->fn_800529B0(); + mProgressStage = 3; + } else if (field_0x5E2 == true) { + field_0x5E2 = false; + mProgressStage = 2; + } else { + SaveRelated *saveRelated = SaveRelated::GetInstance(); + saveRelated->fn_80015EC0(); + if (saveRelated->getField_0x09() == true) { + mProgressStage = 1; + field_0x5E0 = true; + } + } + break; + case 1: + if (field_0x5E3 == true) { + field_0x5E3 = false; + field_0x5D8 = mProgressStage; + mProgressStage = 3; + } else if (tryLoadTitleScreen()) { + mProgressStage = 100; + } + break; + case 2: + if (FileManager::GetInstance()->getField_0xA84D() != true) { + mFader.setStatus(mFaderBase_c::FADED_OUT); + if (mFader.fadeIn() == mFaderBase_c::FADED_IN) { + dCsBase_c::GetInstance()->setCursorStickVisible(false); + dDvdUnk::FontUnk::GetInstance()->fn_800529B0(); + dDvdUnk::FontUnk::GetInstance()->fn_80052A20(); + dLytSystemWindow_c::GetInstance()->fn_80152F10(); + SaveMgr::GetInstance()->init(); + dPadNav::setNavEnabled(false, false); + field_0x5E4 = true; + dHbm::Manage_c::GetInstance()->fn_80197560(0); + SaveRelated::GetInstance()->fn_80015EA0(); + SaveRelated::GetInstance()->fn_80015F40(); + dDvdUnk::FontUnk::GetInstance()->fn_80052CC0(); + mProgressStage = 0; + } + } + break; + case 3: + mFader.setStatus(mFaderBase_c::FADED_OUT); + if (mFader.fadeIn() == mFaderBase_c::FADED_IN) { + field_0x5E4 = true; + mProgressStage = field_0x5D8; + dDvdUnk::FontUnk::GetInstance()->fn_80052CC0(); + dHbm::Manage_c::GetInstance()->fn_80197560(0); + } + break; + case 999999: + if (tryLoadTitleScreen()) { + mProgressStage = 100; + } + break; + } } void dScBoot_c::finalizeState_Save() {} -bool dScBoot_c::checkDone() { - if (field_0x5E3 == 1) { - field_0x5E3 = 0; - mProgressStage = 4; - return 1; +bool dScBoot_c::tryLoadTitleScreen() { + if (mStrapScreenSeen != true) { + return false; } - return 0; + if (mCalibrationDone != true) { + return false; + } + if (mAllDataLoaded != true) { + return false; + } + if (field_0x5E0 != true) { + return false; + } + + dScTitle_c::loadTitleScreen(0); + return true; +} + +bool dScBoot_c::checkDone() { + if (field_0x5E3 == true) { + field_0x5E3 = false; + mProgressStage = 4; + return true; + } + return false; } diff --git a/src/d/d_gfx.cpp b/src/d/d_gfx.cpp index 3ef697c3..fde95962 100644 --- a/src/d/d_gfx.cpp +++ b/src/d/d_gfx.cpp @@ -23,7 +23,7 @@ dGfx_c *dGfx_c::sInstance; -dGfx_c::dGfx_c() : mpTextureBuffer(nullptr), field_0x08(0), field_0x09(0) { +dGfx_c::dGfx_c() : mpTextureBuffer(nullptr), mBufRefcount(0), mLetterboxEnabled(false) { mDrawCallback = nullptr; d3d::create(mHeap::g_gameHeaps[0]); @@ -52,13 +52,13 @@ EGG::TextureBuffer *dGfx_c::getTextureBuffer() { mpTextureBuffer->onCapFlag(0x20); // TODO ret = mpTextureBuffer; } - field_0x08++; + mBufRefcount++; return ret; } void dGfx_c::releaseTextureBuffer() { - field_0x08--; - if (field_0x08 == 0 && mpTextureBuffer != nullptr) { + mBufRefcount--; + if (mBufRefcount == 0 && mpTextureBuffer != nullptr) { mpTextureBuffer->free(); mpTextureBuffer = nullptr; } @@ -74,7 +74,7 @@ void dGfx_c::drawBefore() { } void dGfx_c::drawLetterbox() { - if (field_0x09 != 0 && isTvMode4To3()) { + if (mLetterboxEnabled && isTvMode4To3()) { EGG::Screen screen(*EGG::Screen::GetRoot()); screen.SetNearFar(-1.0f, 1.0f); screen.SetProjectionGX(); diff --git a/src/d/d_pad_manager.cpp b/src/d/d_pad_manager.cpp index 7c63d0ba..af73e352 100644 --- a/src/d/d_pad_manager.cpp +++ b/src/d/d_pad_manager.cpp @@ -50,7 +50,7 @@ void dPadManager_c::init() { if (mpWindow != nullptr) { mpWindow->init(); } - field_0x24 = false; + mCalibrationSkipped = false; } void dPadManager_c::buildWindow() { @@ -293,7 +293,7 @@ void dPadManager_c::ModeRequestCalibrating() { mCalibrationTimer = 0; field_0x1D = true; mCalibrationFinished = false; - field_0x24 = false; + mCalibrationSkipped = false; } void dPadManager_c::ModeProc_Calibrating() { PadStatus_e status = getPadStatus(); @@ -619,7 +619,7 @@ void dPadManager_c::ModeProc_CalibrationFail() { if (mpWindow->fn_80150EB0() == true) { field_0x1D = false; dPad::ex_c::getInstance()->setNoCalibrationNeeded(); - field_0x24 = true; + mCalibrationSkipped = true; field_0x25 = false; mStep = 16; } diff --git a/src/d/d_reset.cpp b/src/d/d_reset.cpp index 15331958..840df09c 100644 --- a/src/d/d_reset.cpp +++ b/src/d/d_reset.cpp @@ -329,13 +329,13 @@ void Manage_c::ModeProc_SoftReset() { if (dScBoot_c::GetInstance()) { if (mpFader->getStatus() == EGG::ColorFader::STATUS_PREPARE_IN) { if (dScBoot_c::GetInstance()->getField_0x5E4()) { - dScBoot_c::GetInstance()->setField_0x5E4(0); + dScBoot_c::GetInstance()->setField_0x5E4(false); mpFader->setStatus(EGG::ColorFader::STATUS_PREPARE_OUT); ModeRequest(Normal); dSndPlayerMgr_c::GetInstance()->fn_8035E310(); } else { if (field_0x66) { - dScBoot_c::GetInstance()->setField_0x5E3(1); + dScBoot_c::GetInstance()->setField_0x5E3(true); dDvdUnk::FontUnk::GetInstance()->fn_800529B0(); dSndPlayerMgr_c::GetInstance()->fn_8035E6E0(); @@ -343,8 +343,8 @@ void Manage_c::ModeProc_SoftReset() { if (dDvdUnk::FontUnk::GetInstance()->isNandError() || dDvdUnk::FontUnk::GetInstance()->getNandError() != NandResultTracker::ERR_CAT_NONE || SaveMgr::GetInstance()->getCheckForFreeSpaceResult()) { - dScBoot_c::GetInstance()->setField_0x5E3(0); - dScBoot_c::GetInstance()->setField_0x5E2(1); + dScBoot_c::GetInstance()->setField_0x5E3(false); + dScBoot_c::GetInstance()->setField_0x5E2(true); dDvdUnk::FontUnk::GetInstance()->clearNandError(); } dDvdUnk::FontUnk::GetInstance()->fn_80052A20(); @@ -553,7 +553,8 @@ void Manage_c::CleanUpLC() { void Manage_c::MotorCancelOn() { for (int i = 0; i < 4; i++) { - mPad::g_core[--++i]->stopRumbleMgr(); + // TODO: Fakematch + mPad::getCore(--++i)->stopRumbleMgr(); } dRumble_c::stop(-1); } From e5e09f0f1e66c7c904e80c4da75fa805cd5e6c2b Mon Sep 17 00:00:00 2001 From: robojumper Date: Sat, 2 Aug 2025 09:25:15 +0200 Subject: [PATCH 4/4] ninja apply --- config/SOUE01/symbols.txt | 48 ++++++++++++++++++++++----------------- include/d/d_dvd_unk.h | 6 ++--- src/d/d_dvd_unk.cpp | 5 ++-- 3 files changed, 33 insertions(+), 26 deletions(-) diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 6adab5b6..653052ca 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -27846,7 +27846,7 @@ fontMgrIndex = .rodata:0x804DDFF0; // type:object size:0x14 scope:local @LOCAL@createLayoutResHeap__5dHeapFUlPQ23EGG4Heap@name = .rodata:0x804DE114; // type:object size:0x31 scope:local @LOCAL@createFontHeap__5dHeapFUlPQ23EGG4Heap@name = .rodata:0x804DE148; // type:object size:0x22 scope:local @LOCAL@createHBMHeap__5dHeapFUlPQ23EGG4Heap@name = .rodata:0x804DE16C; // type:object size:0x1C scope:local -lbl_804DE188 = .rodata:0x804DE188; // type:object size:0x60 +@LOCAL@executeProc__13dPadManager_cFv@procs = .rodata:0x804DE188; // type:object size:0x60 scope:local @26290 = .rodata:0x804DE1E8; // type:object size:0xA scope:local data:string ...rodata.0 = .rodata:0x804DE1E8; // type:label scope:local @26295 = .rodata:0x804DE1F4; // type:object size:0xC scope:local data:string @@ -28240,10 +28240,10 @@ sReplacementSequences = .rodata:0x804E39E0; // type:object size:0x10 scope:local sUpperCaseChars = .rodata:0x804E39F0; // type:object size:0x240 scope:local data:2byte sMsgWindowFlags = .rodata:0x804E3C30; // type:object size:0x1004 scope:local @LOCAL@symbolToFontIdx__15dTagProcessor_cFl@index = .rodata:0x804E4C34; // type:object size:0x1C scope:local data:string -lbl_804E4C50 = .rodata:0x804E4C50; // type:object size:0x18 -lbl_804E4C68 = .rodata:0x804E4C68; // type:object size:0xC data:string -lbl_804E4C74 = .rodata:0x804E4C74; // type:object size:0xC data:string -lbl_804E4C80 = .rodata:0x804E4C80; // type:object size:0xC data:string +@LOCAL@execute__17NandResultTrackerFv@procs = .rodata:0x804E4C50; // type:object size:0x18 scope:local +@4322 = .rodata:0x804E4C68; // type:object size:0xC scope:local data:string +@4323 = .rodata:0x804E4C74; // type:object size:0xC scope:local data:string +@4324 = .rodata:0x804E4C80; // type:object size:0xC scope:local data:string lbl_804E4C90 = .rodata:0x804E4C90; // type:object size:0x18 lbl_804E4CA8 = .rodata:0x804E4CA8; // type:object size:0x10 align:4 data:float lbl_804E4CB8 = .rodata:0x804E4CB8; // type:object size:0x10 align:4 data:float @@ -30787,17 +30787,23 @@ special_00__10dFontMng_c = .data:0x8050D40C; // type:object size:0x11 scope:glob @4045 = .data:0x8050D420; // type:object size:0x9 scope:local data:string @4046 = .data:0x8050D42C; // type:object size:0xF scope:local data:string __vt__14dHeapAllocator = .data:0x8050D440; // type:object size:0x14 -lbl_8050D458 = .data:0x8050D458; // type:object size:0xC data:string -lbl_8050D464 = .data:0x8050D464; // type:object size:0x10 -lbl_8050D474 = .data:0x8050D474; // type:object size:0x10 -lbl_8050D484 = .data:0x8050D484; // type:object size:0x10 -lbl_8050D494 = .data:0x8050D494; // type:object size:0xC data:string -lbl_8050D4A0 = .data:0x8050D4A0; // type:object size:0xC data:string -jumptable_8050D4AC = .data:0x8050D4AC; // type:object size:0x7C scope:local -lbl_8050D528 = .data:0x8050D528; // type:object size:0x30 -jumptable_8050D558 = .data:0x8050D558; // type:object size:0x54 scope:local -lbl_8050D5AC = .data:0x8050D5AC; // type:object size:0x24 -jumptable_8050D5D0 = .data:0x8050D5D0; // type:object size:0x44 scope:local +@11471 = .data:0x8050D458; // type:object size:0xC scope:local data:string +...data.0 = .data:0x8050D458; // type:label scope:local +@11472 = .data:0x8050D464; // type:object size:0xE scope:local data:string +@11499 = .data:0x8050D474; // type:object size:0xF scope:local data:string +@11525 = .data:0x8050D484; // type:object size:0xF scope:local data:string +@10312 = .data:0x8050D494; // type:object size:0xC scope:local data:string +@10313 = .data:0x8050D4A0; // type:object size:0xC scope:local data:string +@11568 = .data:0x8050D4AC; // type:object size:0x7C scope:local +@11603 = .data:0x8050D528; // type:object size:0xC scope:local data:string +@11682 = .data:0x8050D534; // type:object size:0xC scope:local data:string +@11683 = .data:0x8050D540; // type:object size:0xC scope:local data:string +@11684 = .data:0x8050D54C; // type:object size:0x9 scope:local data:string +@11686 = .data:0x8050D558; // type:object size:0x54 scope:local +@11785 = .data:0x8050D5AC; // type:object size:0xC scope:local data:string +@11786 = .data:0x8050D5B8; // type:object size:0xC scope:local data:string +@11787 = .data:0x8050D5C4; // type:object size:0xC scope:local data:string +@11789 = .data:0x8050D5D0; // type:object size:0x44 scope:local __vt__13dPadManager_c = .data:0x8050D614; // type:object size:0xC lbl_8050D620 = .data:0x8050D620; // type:object size:0xC data:string lbl_8050D62C = .data:0x8050D62C; // type:object size:0xC data:string @@ -31106,7 +31112,7 @@ __vt__17NandRequestThread = .data:0x80510B30; // type:object size:0x18 __vt__16NandRequestWrite = .data:0x80510B48; // type:object size:0xC __vt__17NandRequestCreate = .data:0x80510B54; // type:object size:0xC __vt__16NandRequestCheck = .data:0x80510B60; // type:object size:0xC -lbl_80510B70 = .data:0x80510B70; // type:object size:0x18 +@LOCAL@ModeProc_Error__17NandResultTrackerFv@sMessages = .data:0x80510B70; // type:object size:0x14 scope:local __vt__32MyFlagManager<15ItemflagManager> = .data:0x80510B88; // type:object size:0x3C scope:weak __vt__33MyFlagManager<16StoryflagManager> = .data:0x80510BC4; // type:object size:0x3C scope:weak __vt__33MyFlagManager<16EnemyflagManager> = .data:0x80510C00; // type:object size:0x14 scope:weak @@ -39237,7 +39243,7 @@ lbl_80571C48 = .sdata:0x80571C48; // type:object size:0x8 g_CurrentScreenTo4x3WidthScale__6dGfx_c = .sdata:0x80571C50; // type:object size:0x4 align:4 data:float lbl_80571C58 = .sdata:0x80571C58; // type:object size:0x8 data:byte m_current_ex__Q24dPad4ex_c = .sdata:0x80571C60; // type:object size:0x4 data:4byte -lbl_80571C68 = .sdata:0x80571C68; // type:object size:0x8 +@LOCAL@ModeProc_Calibrating__13dPadManager_cFv@s_messages = .sdata:0x80571C68; // type:object size:0x8 scope:local OBTAINED_ITEM_ID = .sdata:0x80571C70; // type:object size:0x4 data:4byte sCurrentSword__17daPlayerActBase_c = .sdata:0x80571C74; // type:object size:0x1 data:byte lbl_80571C78 = .sdata:0x80571C78; // type:object size:0x8 data:4byte @@ -41344,7 +41350,7 @@ s_ExecuteControlFlags__7dBase_c = .sbss:0x805750C0; // type:object size:0x4 data s_DrawControlFlags__7dBase_c = .sbss:0x805750C4; // type:object size:0x4 data:4byte s_NextExecuteControlFlags__7dBase_c = .sbss:0x805750C8; // type:object size:0x4 data:4byte sInstance__16dDvdDriveError_c = .sbss:0x805750D0; // type:object size:0x4 data:4byte -sInstance__Q27dDvdUnk7FontUnk = .sbss:0x805750D8; // type:object size:0x8 data:4byte +sInstance__Q27dDvdUnk7FontUnk = .sbss:0x805750D8; // type:object size:0x4 data:4byte pDynamicNameTable = .sbss:0x805750E0; // type:object size:0x4 data:4byte nDynamicNameTable = .sbss:0x805750E4; // type:object size:0x4 data:4byte pDMC__4dDyl = .sbss:0x805750E8; // type:object size:0x4 data:4byte @@ -41507,7 +41513,7 @@ sInstance__14dTimeAreaMgr_c = .sbss:0x805753C0; // type:object size:0x4 data:4by TIMESHIFT_TRANSITION_BORDER_COLOR = .sbss:0x805753C4; // type:object size:0x1 data:byte CURR_TIMESHIFT_STONE_ACTIVE = .sbss:0x805753C8; // type:object size:0x8 data:4byte sInstance__17NandRequestThread = .sbss:0x805753D0; // type:object size:0x8 data:4byte -sInstance__17NandResultTracker = .sbss:0x805753D8; // type:object size:0x8 data:4byte +sInstance__17NandResultTracker = .sbss:0x805753D8; // type:object size:0x4 data:4byte sInstance__16SceneflagManager = .sbss:0x805753E0; // type:object size:0x4 data:4byte sTempFlags__16SceneflagManager = .sbss:0x805753E8; // type:object size:0x8 sInstance__15TBoxflagManager = .sbss:0x805753F0; // type:object size:0x4 data:4byte @@ -43008,7 +43014,7 @@ lbl_80576FF8 = .sdata2:0x80576FF8; // type:object size:0x4 align:4 data:float lbl_80576FFC = .sdata2:0x80576FFC; // type:object size:0x4 align:4 data:float lbl_80577000 = .sdata2:0x80577000; // type:object size:0x4 align:4 data:float lbl_80577004 = .sdata2:0x80577004; // type:object size:0x4 align:4 data:float -lbl_80577008 = .sdata2:0x80577008; // type:object size:0x4 align:4 data:float +@11566 = .sdata2:0x80577008; // type:object size:0x4 scope:local align:4 data:float lbl_80577010 = .sdata2:0x80577010; // type:object size:0x4 align:4 data:float lbl_80577014 = .sdata2:0x80577014; // type:object size:0x4 align:4 data:float lbl_80577018 = .sdata2:0x80577018; // type:object size:0x4 align:4 data:float diff --git a/include/d/d_dvd_unk.h b/include/d/d_dvd_unk.h index 10aa6cb2..04a06789 100644 --- a/include/d/d_dvd_unk.h +++ b/include/d/d_dvd_unk.h @@ -4,9 +4,9 @@ #include "common.h" #include "egg/core/eggHeap.h" -// This file is related to errors that are -// displayed on the screen, using a backup font -// included in the DOL. +// TODO - rename when NSMBW figures out their type; +// they too apparently have a type with a ResFont at 0x00, +// which will be revealed when NSMBW function 80107090 is cracked namespace dDvdUnk { diff --git a/src/d/d_dvd_unk.cpp b/src/d/d_dvd_unk.cpp index e0225142..60a344f3 100644 --- a/src/d/d_dvd_unk.cpp +++ b/src/d/d_dvd_unk.cpp @@ -17,10 +17,11 @@ #include "rvl/NAND/nand.h" #include "toBeSorted/nand_result_tracker.h" -namespace dDvdUnk { - +// included asset #include "d/dol_backup_error_font.inc" +namespace dDvdUnk { + FontUnk *FontUnk::sInstance; void FontUnk::create(EGG::Heap *heap) {