Merge pull request #227 from robojumper/d_pad_manager

More game bootup / error related things
This commit is contained in:
robojumper
2025-09-13 10:07:19 +02:00
committed by GitHub
31 changed files with 1873 additions and 277 deletions
+16 -10
View File
@@ -22,15 +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;
}
void setField705(bool val) {
field_0x705 = val;
bool getDrawDirectly() const {
return mDrawDirectly;
}
void setCalibrationPointCenterEnabled(bool val) {
mCalibrationPointCenterEnabled = val;
}
dCursorHitCheck_c *getHitCheck() {
@@ -41,6 +43,10 @@ public:
return sInstance;
}
void setCursorStickVisible(bool visible) {
mCursorStick.setShouldBeOn(visible);
}
private:
static dCsBase_c *sInstance;
void setCurrentLyt(int lyt);
@@ -54,9 +60,9 @@ private:
/* 0x6F8 */ mVec2_c mCsVelocity;
/* 0x700 */ mAng field_0x700;
/* 0x702 */ u8 mAlpha;
/* 0x703 */ u8 field_0x703;
/* 0x704 */ u8 field_0x704;
/* 0x705 */ u8 field_0x705;
/* 0x703 */ bool mVisible;
/* 0x704 */ bool mDrawDirectly;
/* 0x705 */ bool mCalibrationPointCenterEnabled;
};
#endif
+4
View File
@@ -16,6 +16,10 @@ public:
return sInstance;
}
s32 getStatus() const {
return mDvdDriveStatus;
}
private:
static dDvdDriveError_c *sInstance;
+57 -21
View File
@@ -4,15 +4,29 @@
#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 {
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,25 +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();
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) {
@@ -52,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
+9 -4
View File
@@ -28,14 +28,19 @@ public:
mDrawCallback = cb;
}
void setField0x09(u8 val) {
field_0x09 = val;
void setLetterboxEnabled(bool val) {
mLetterboxEnabled = val;
}
static dGfx_c *GetInstance() {
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; }
@@ -137,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
+7 -3
View File
@@ -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();
+126
View File
@@ -0,0 +1,126 @@
#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 isCalibrationFinished() const {
return mCalibrationFinished;
}
bool isCalibrationSkipped() const {
return mCalibrationSkipped;
}
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();
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 mIsError;
/* 0x1D */ bool field_0x1D;
/* 0x1E */ bool field_0x1E;
/* 0x1F */ bool field_0x1F;
/* 0x20 */ bool field_0x20;
/* 0x21 */ bool mCalibrationFinished;
/* 0x22 */ bool mSavedCsDrawDirectly;
/* 0x23 */ bool field_0x23;
/* 0x24 */ bool mCalibrationSkipped;
/* 0x25 */ bool field_0x25;
static dPadManager_c *sInstance;
};
#endif
-23
View File
@@ -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
+17 -16
View File
@@ -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
+10
View File
@@ -0,0 +1,10 @@
#ifndef D_VIDEO_H
#define D_VIDEO_H
namespace dVideo {
void enableDimming(int);
} // namespace dVideo
#endif
+4
View File
@@ -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;
+57
View File
@@ -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();
+1
View File
@@ -44,6 +44,7 @@ public:
void fn_8035E250(u16);
bool fn_8035E2E0();
void fn_8035E310();
void fn_8035E620();
void fn_8035E6E0();
u32 getFreeSize();
+41 -1
View File
@@ -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
+1
View File
@@ -153,6 +153,7 @@ public:
bool clearSelectedFile();
private:
// TODO - Align with NSMBW ModeInit_ / ModeProc_ naming convention?
void initializeCheckForSave();
void initializeCheckForFreeSpace();
void initializeCreateFiles();
+12
View File
@@ -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