save_manager OK

This commit is contained in:
robojumper
2025-05-01 15:11:11 +02:00
parent 594bc67d67
commit b148d141a0
33 changed files with 2961 additions and 303 deletions
+4
View File
@@ -24,6 +24,10 @@ public:
field_0x703 = val;
}
void setField704(bool val) {
field_0x704 = val;
}
dCursorHitCheck_c *getHitCheck() {
return mCursorIf.getHit();
}
+10
View File
@@ -0,0 +1,10 @@
#ifndef D_D2D_H
#define D_D2D_H
namespace d2d {
void defaultSet();
} // namespace d2d
#endif
+47
View File
@@ -4,6 +4,10 @@
#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.
namespace dDvdUnk {
class unkstruct_c {
@@ -21,6 +25,49 @@ private:
char field_0x4;
};
class FontUnk {
public:
FontUnk() {}
static FontUnk *GetInstance() {
return sInstance;
}
void fn_80052D00(bool);
void fn_80052D50();
void fn_80052C90();
s32 getField_0x24() const {
return field_0x24;
}
u8 getField_0x28() const {
return field_0x28;
}
u8 getField_0x29() const {
return field_0x29;
}
void setField_0x2C(u8 val) {
field_0x2C = val;
}
private:
static FontUnk *sInstance;
/* 0x00 */ nw4r::ut::ResFont mFont;
/* 0x1C */ s32 field_0x1C;
/* 0x20 */ s32 field_0x20;
/* 0x24 */ s32 field_0x24;
/* 0x28 */ u8 field_0x28;
/* 0x29 */ u8 field_0x29;
/* 0x2A */ u8 field_0x2A;
/* 0x2B */ u8 field_0x2B;
/* 0x2C */ u8 field_0x2C;
/* 0x2D */ u8 field_0x2D;
};
} // namespace dDvdUnk
#endif
+32
View File
@@ -0,0 +1,32 @@
#ifndef D_GFX_H
#define D_GFX_H
#include "common.h"
// Made up name
class dGfx_c {
public:
typedef void (*PreDrawCallback)(void);
void setDrawCallback(PreDrawCallback cb) {
mPreDrawCb = cb;
}
void setField0x09(u8 val) {
field_0x09 = val;
}
static dGfx_c *GetInstance() {
return sInstance;
}
private:
static dGfx_c *sInstance;
/* 0x00 */ u8 _0x00[0x04 - 0x00];
/* 0x04 */ PreDrawCallback mPreDrawCb;
/* 0x08 */ u8 field_0x08;
/* 0x09 */ u8 field_0x09;
};
#endif
+4 -1
View File
@@ -20,9 +20,12 @@ public:
STATE_FUNC_DECLARE(dScBoot_c, Connect);
STATE_FUNC_DECLARE(dScBoot_c, Save);
static dScBoot_c *sInstance;
static dScBoot_c *GetInstance() {
return sInstance;
}
private:
static dScBoot_c *sInstance;
class strap_c {
public:
strap_c();
+70
View File
@@ -0,0 +1,70 @@
#ifndef D_LYT_SAVE_MSG_WINDOW_H
#define D_LYT_SAVE_MSG_WINDOW_H
#include "d/lyt/d2d.h"
#include "d/lyt/msg_window/d_lyt_msg_window_select_btn.h"
#include "s/s_State.hpp"
#include "sized_string.h"
class dLytSaveMsgWindow_c {
public:
dLytSaveMsgWindow_c();
virtual ~dLytSaveMsgWindow_c() {}
bool build(bool);
bool remove();
bool execute();
bool draw();
bool drawNow();
void reset();
bool setProperties(const char *message, s32, s32, u8);
bool checkIsWait();
void setNumLines(s32 numLines) {
mNumLines = numLines;
}
u8 getWillFinishOut() const {
return mWillFinishOut;
}
private:
void resetProperties();
void setupSaveTextMaybe();
void updateSaveTextMaybe();
void updateSaveText();
void setAnmFrame(s32 group, f32 frame);
void unbindAnm(s32 group);
STATE_FUNC_DECLARE(dLytSaveMsgWindow_c, Init);
STATE_FUNC_DECLARE(dLytSaveMsgWindow_c, In);
STATE_FUNC_DECLARE(dLytSaveMsgWindow_c, Wait);
STATE_FUNC_DECLARE(dLytSaveMsgWindow_c, Out);
/* 0x0004 */ UI_STATE_MGR_DECLARE(dLytSaveMsgWindow_c);
/* 0x0040 */ d2d::ResAccIf_c mResAcc;
/* 0x03B0 */ d2d::LytBase_c mLyt;
/* 0x0440 */ d2d::AnmGroup_c mAnm[9];
/* 0x0680 */ d2d::SubPaneList mSubpaneList;
/* 0x068C */ d2d::SubPaneListNode mSubpanes[1];
/* 0x069C */ dLytMsgWindowSelectBtn_c mBtn;
/* 0x1070 */ SizedString<64> mLabel;
/* 0x10B0 */ s32 field_0x10B0;
/* 0x10B4 */ s32 field_0x10B4;
/* 0x10B8 */ s32 field_0x10B8;
/* 0x10BC */ s32 field_0x10BC;
/* 0x10C0 */ s32 field_0x10C0;
/* 0x10C4 */ s32 field_0x10C4;
/* 0x10C8 */ s32 field_0x10C8;
/* 0x10CC */ s32 mNumLines;
/* 0x10D0 */ s32 mSaveobjId;
/* 0x10D4 */ f32 mLineSpace;
/* 0x10D8 */ u8 field_0x10D8;
/* 0x10D9 */ u8 mWillFinishOut;
/* 0x10DA */ u8 field_0x10DA;
/* 0x10DB */ u8 field_0x10DB;
/* 0x10DC */ u8 field_0x10DC;
/* 0x10DD */ u8 field_0x10DD;
};
#endif
+35
View File
@@ -0,0 +1,35 @@
#ifndef D_LYT_SYSTEM_WINDOW_H
#define D_LYT_SYSTEM_WINDOW_H
#include "common.h"
class dLytSystemWindow_c {
public:
virtual ~dLytSystemWindow_c();
// TODO fill out
static dLytSystemWindow_c *GetInstance() {
return sInstance;
}
bool setProperties(const char *label, bool, const wchar_t *);
void showMaybe();
void showMaybe(s32 arg);
s32 getField_0xE10() const {
return field_0xE10;
}
s32 getField_0xDE0() const;
bool getField_0xDFC() const;
bool fn_80152F50() const;
bool fn_80152F60() const;
bool fn_80152F70() const;
private:
static dLytSystemWindow_c *sInstance;
/* 0x004 */ u8 _0x004[0xE10 - 0x004];
/* 0xE10 */ u8 field_0xE10;
};
#endif
@@ -36,6 +36,7 @@ class dLytMsgWindowSelectBtnParts_c {
public:
dLytMsgWindowSelectBtnParts_c() : mStateMgr(*this) {}
~dLytMsgWindowSelectBtnParts_c() {}
void init();
void execute();
@@ -73,6 +74,14 @@ public:
bool draw();
u8 getField_0x9A4() const {
return field_0x9A4;
}
s32 getField_0x9B0() const {
return field_0x9B0;
}
s32 getField_0x9B4() const {
return field_0x9B4;
}
@@ -85,14 +94,26 @@ public:
field_0x9BC = value;
}
void setField_0x9C4(s32 value) {
field_0x9C4 = value;
}
void setField_0x990(s32 value) {
mBtnHelper.field_0x4C = value;
}
void setField_0x998(dTagProcessor_c *value) {
void setField_0x9A0(s32 value) {
field_0x9A0 = value;
}
void setTagProcessor(dTagProcessor_c *value) {
mpTagProcessor = value;
}
void setField_0x99C(s32 value) {
field_0x99C = value;
}
void fn_8011E5D0(u32, bool);
dTextBox_c *getSelectTextBox(s32 option, s32 idx) const {
@@ -136,7 +157,7 @@ private:
/* 0x9B8 */ s32 field_0x9B8;
/* 0x9BC */ s32 field_0x9BC;
/* 0x9C0 */ s32 field_0x9C0;
/* 0x9C4 */ void *field_0x9C4;
/* 0x9C4 */ s32 field_0x9C4;
/* 0x9C8 */ s32 field_0x9C8;
/* 0x9CC */ s8 field_0x9CC;
/* 0x9CD */ u8 field_0x9CD;
+2
View File
@@ -4,10 +4,12 @@
extern "C" {
#endif
// IWYU pragma: begin_exports
#include "rvl/NAND/NANDCheck.h"
#include "rvl/NAND/NANDCore.h"
#include "rvl/NAND/NANDOpenClose.h"
#include "rvl/NAND/nand.h"
// IWYU pragma: end_exports
#ifdef __cplusplus
}
+7
View File
@@ -24,6 +24,13 @@ NANDResult NANDPrivateSafeOpenAsync(
);
NANDResult NANDSafeCloseAsync(NANDFileInfo *info, NANDAsyncCallback callback, NANDCommandBlock *block);
NANDResult NANDChangeDir(const char *path);
NANDResult NANDCreateDir(const char *path, u8 perm, u8 attr);
NANDResult NANDSimpleSafeOpen(const char *path, NANDFileInfo *outInfo, int, void *buf, size_t bufLen);
NANDResult NANDSimpleSafeCancel(NANDFileInfo *info);
NANDResult NANDSimpleSafeClose(NANDFileInfo *info);
#ifdef __cplusplus
}
#endif
+15 -8
View File
@@ -1,6 +1,7 @@
#ifndef RVL_SDK_NAND_H
#define RVL_SDK_NAND_H
#include "common.h"
#include "rvl/FS.h"
#ifdef __cplusplus
@@ -9,6 +10,8 @@ extern "C" {
#define NAND_BANNER_TITLE_MAX 32
#define NAND_BANNER_ICON_MAX_FRAME 8
#define NAND_BANNER_TEXTURE_SIZE 0x6000
#define NAND_BANNER_ICON_TEXTURE_SIZE 0x1200
// Forward declarations
typedef struct NANDCommandBlock;
@@ -127,15 +130,19 @@ typedef struct NANDCommandBlock {
int simpleFlag; //
} NANDCommandBlock;
// via spm
#define NAND_SET_ICON_SPEED(banner, icon, speed) \
(banner)->iconSpeed = (u16)(((banner)->iconSpeed & ~(3 << 2 * (icon))) | ((speed) << 2 * (icon)))
typedef struct NANDBanner {
u32 magic; // at 0x0
u32 flags; // at 0x4
u16 iconSpeed; // at 0x8
u8 reserved[0x20 - 0xA]; // at 0xA
wchar_t title[NAND_BANNER_TITLE_MAX]; // at 0x20
wchar_t subtitle[NAND_BANNER_TITLE_MAX]; // at 0x60
u8 bannerTexture[0x6000]; // at 0xA0
u8 iconTexture[0x1200][NAND_BANNER_ICON_MAX_FRAME]; // at 0x60A0
u32 magic; // at 0x0
u32 flags; // at 0x4
u16 iconSpeed; // at 0x8
u8 reserved[0x20 - 0xA]; // at 0xA
wchar_t title[NAND_BANNER_TITLE_MAX]; // at 0x20
wchar_t subtitle[NAND_BANNER_TITLE_MAX]; // at 0x60
u8 bannerTexture[NAND_BANNER_TEXTURE_SIZE]; // at 0xA0
u8 iconTexture[NAND_BANNER_ICON_MAX_FRAME][NAND_BANNER_ICON_TEXTURE_SIZE]; // at 0x60A0
} NANDBanner;
NANDResult NANDCreate(const char *path, u8 perm, u8 attr);
+1 -1
View File
@@ -4,7 +4,7 @@
extern "C" {
#endif
#include "rvl/TPL/TPL.h"
#include "rvl/TPL/TPL.h" // IWYU pragma: export
#ifdef __cplusplus
}
+51 -4
View File
@@ -6,7 +6,9 @@
#include "egg/core/eggHeap.h"
#include "m/m_angle.h"
#include "m/m_vec.h"
#include "toBeSorted/nand_request_thread.h"
#include "toBeSorted/save_file.h"
#include "toBeSorted/save_manager.h"
enum SAVE_ITEM_ID {
};
@@ -65,8 +67,8 @@ public:
/* 80009EE0 */ // mVec3();
/* 80009EF0 */ static FileManager *create(EGG::Heap *);
/* 80009F30 */ bool loadSaveData(void *out, char *name, bool isSkipData);
/* 80009F70 */ void saveSaveData(void *unk, bool isSkipData);
/* 80009F30 */ bool loadSaveData(NandRequestWriteHolder *out, const char *name, bool isSkipData);
/* 80009F70 */ void saveSaveData(NandRequestLoadSaveFileHolder *request, bool isSkipData);
/* 8000A000 */ void refreshSaveFileData();
/* 8000A260 */ wchar_t *getFileHeroname(int fileNum);
/* 8000A280 */ s64 getFileSaveTime(int fileNum);
@@ -256,7 +258,7 @@ public:
/* 80010160 */ void initSkipData();
/* 800101F0 */ void unsetFileANewFile();
/* 80010220 */ void saveT1SaveInfo(u8 entranceT1LoadFlag);
/* 80010220 */ void saveT1SaveInfo(bool entranceT1LoadFlag);
/* 80010350 */ void copyFileSkipData(int fileNum);
/* 80010440 */ void clearTempFileData();
/* 800104A0 */ void saveAfterCredits();
@@ -272,7 +274,7 @@ public:
/* 800112D0 */ void updateEmptyFileFlags();
/* 80011370 */ bool isFileEmpty(u8 fileNum);
/* 80011390 */ bool isFileDirty(int fileNum);
/* 800113B0 */ u8 get_0xA84C();
/* 800113B0 */ u32 get_0xA84C();
/* 800113C0 */ bool checkRegionCode();
/* 80011440 */ bool checkFileCRC(u8 fileNum);
/* 80011490 */ bool isFileInactive() const;
@@ -309,6 +311,51 @@ public:
return getStaminaPotionTimer() != 0;
}
u8 isFileInvalid() const {
return mIsFileInvalid[2];
}
void setField0xA840(u8 val) {
mIsFileUnk1[0] = val;
}
void setField0xA841(u8 val) {
mIsFileUnk1[1] = val;
}
void setField0xA842(u8 val) {
mIsFileUnk1[2] = val;
}
void setField_0xA843(u8 val) {
mIsFileInvalid[1] = val;
}
u8 getField_0xA841() const {
return mIsFileUnk1[1];
}
u8 getField_0xA842() const {
return mIsFileUnk1[2];
}
u8 getField_0xA843() const {
return mIsFileInvalid[1];
}
void setField0xA84C(u8 val) {
m_0xA84C = val;
}
void setField0xA84D(u8 val) {
m_0xA84D = val;
}
void setSelectedFileNum(u8 val) {
mSelectedFile = val;
}
private:
static FileManager *sInstance;
};
+2 -2
View File
@@ -62,8 +62,8 @@ struct NandRequestHolderBase {
NandRequest *mpRequest;
bool isCompleted() const;
NANDResult getStatus() const;
bool runToCompletion();
NANDResult getResult() const;
bool finish();
};
struct NandRequestCheckHolder : public NandRequestHolderBase {
+15
View File
@@ -0,0 +1,15 @@
#ifndef NAND_RESULT_TRACKER_H
#define NAND_RESULT_TRACKER_H
#include "rvl/NAND.h"
class NandResultTracker {
public:
static NandResultTracker *GetInstance();
bool isFailure(NANDResult status);
private:
NandResultTracker *sInstance;
};
#endif
+3
View File
@@ -9,6 +9,9 @@ public:
void fn_80067EF0(s32);
void fn_80067F00();
void fn_80067F50();
void fn_80067FE0();
bool fn_80068E80();
bool fn_80067F60();
u8 field_0x00[0x0C - 0x00];
s32 field_0x0C;
+229
View File
@@ -0,0 +1,229 @@
#ifndef D_SAVE_MANAGER_H
#define D_SAVE_MANAGER_H
#include "d/lyt/d_lyt_save_msg_window.h"
#include "egg/egg_types.h"
#include "toBeSorted/nand_request_thread.h"
#include "rvl/TPL.h"
class NandRequestCheckIsFile : public NandRequest {
friend class NandRequestCheckIsFileHolder;
public:
virtual bool execute() override;
private:
NandRequestCheckIsFile(const char *path);
/* 0x11 */ SizedString<0x40> mPath;
/* 0x51 */ bool mIsFile;
};
class NandRequestCheckIsFileHolder : public NandRequestHolderBase {
public:
NandRequestCheckIsFileHolder(NandRequestCheck *req) : NandRequestHolderBase(req) {}
bool checkIsFile(const char *path);
bool getCheckResult() const;
};
class NandRequestSaveBanner : public NandRequestCreate {
friend class NandRequestSaveBannerHolder;
NandRequestSaveBanner(
const char *filePath, TPLPalette *palette, const wchar_t *title, const wchar_t *subtitle, u8 perm, u8 attr
);
public:
virtual bool execute() override;
private:
TPLPalette *getPalette() const {
return mpPalette;
}
const wchar_t *getTitle() const {
return mpTitle;
}
const wchar_t *getSubTitle() const {
return mpSubTitle;
}
u32 writeBannerTpl(NANDFileInfo *info);
/* 0x54 */ TPLPalette *mpPalette;
/* 0x58 */ const wchar_t *mpTitle;
/* 0x5C */ const wchar_t *mpSubTitle;
/* 0x60 */ bool mFailed;
};
class NandRequestSaveBannerHolder : public NandRequestHolderBase {
public:
NandRequestSaveBannerHolder(NandRequestSaveBanner *req) : NandRequestHolderBase(req) {}
bool saveBanner(
const char *filePath, TPLPalette *palette, const wchar_t *title, const wchar_t *subtitle, u8 perm, u8 attr
);
bool hasFailed() const;
};
class NandRequestLoadSaveFile : public NandRequest {
friend class NandRequestLoadSaveFileHolder;
public:
virtual bool execute() override;
private:
NandRequestLoadSaveFile(const char *path, s32 readSize, s32 mountDirection, EGG::Heap *heap);
void remove();
/* 0x11 */ SizedString<0x40> mPath;
/* 0x54 */ EGG::Heap *mpHeap;
/* 0x58 */ void *mpBuf;
/* 0x5C */ u32 mBufLen;
/* 0x60 */ s32 mMountDirection;
/* 0x64 */ u32 mReadSize;
/* 0x68 */ bool mUnused;
};
class NandRequestLoadSaveFileHolder : public NandRequestHolderBase {
public:
NandRequestLoadSaveFileHolder(NandRequestLoadSaveFile *req) : NandRequestHolderBase(req) {}
bool loadSave(const char *path, s32 readSize, s32 mountDirection, EGG::Heap *heap);
void *getBuf() const;
u32 getLen() const;
void remove();
};
class NandRequestDelete : public NandRequest {
friend class NandRequestDeleteHolder;
public:
virtual bool execute() override;
private:
NandRequestDelete(const char *path);
/* 0x11 */ SizedString<0x40> mPath;
};
class NandRequestDeleteHolder : public NandRequestHolderBase {
public:
NandRequestDeleteHolder(NandRequestCheck *req) : NandRequestHolderBase(req) {}
bool doDelete(const char *path);
};
class SaveMgr {
static void create(EGG::Heap *heap);
static SaveMgr *GetInstance() {
return sInstance;
}
void createSaveMsgWindow();
void execute();
void draw();
bool checkForSave();
bool checkForFreeSpace();
bool createFiles();
bool loadSave();
bool save(bool entranceT1LoadFlag, bool full);
bool saveAfterCredits();
bool writeSkipDat();
bool copySave(u8 to, u8 from);
bool clearSelectedFile();
private:
void initializeCheckForSave();
void initializeCheckForFreeSpace();
void initializeCreateFiles();
void initializeSaveBanner();
void initializeLoadSave();
void initializeWriteSave();
void initializeWriteSkipDat();
void initializeCopySave();
void initializeClearSelectedFile();
void initializeSave();
void initializeDeleteAllData();
void initializeError();
void initializeNandError();
void executeCheckForSave();
void executeCheckForFreeSpace();
void executeCreateFiles();
void executeSaveBanner();
void executeLoadSave();
void executeWriteSave();
void executeWriteSkipDat();
void executeCopySave();
void executeClearSelectedFile();
void executeSave();
void executeDeleteAllData();
void executeError();
void executeNandError();
static s32 getFrameRate();
enum SaveMgrState_e {
STATE_CHECK_FOR_SAVE = 0,
STATE_CHECK_FOR_FREE_SPACE = 1,
STATE_CREATE_FILES = 2,
STATE_SAVE_BANNER = 3,
STATE_LOAD_SAVE = 4,
STATE_WRITE = 5,
STATE_WRITE_SKIP_DAT = 6,
STATE_COPY_SAVE = 7,
STATE_CLEAR_SELECTED_FILE = 8,
STATE_SAVE = 9,
STATE_DELETE_ALL_DATA = 10,
STATE_ERROR = 11,
STATE_NAND_ERROR = 12,
STATE_MAX = 13,
};
typedef void (SaveMgr::*StateFunc)();
static const StateFunc sStateFuncs[STATE_MAX];
SaveMgr();
~SaveMgr();
void init();
void beginState(SaveMgrState_e state);
void endState();
/* 0x000 */ NandRequestCheckIsFileHolder mCheckIsFileRequest;
/* 0x004 */ NandRequestCheckHolder mCheckRequest;
/* 0x008 */ NandRequestCreateHolder mCreateRequest;
/* 0x00C */ NandRequestWriteHolder mWriteRequest;
/* 0x010 */ NandRequestSaveBannerHolder mSaveBannerRequest;
/* 0x014 */ NandRequestLoadSaveFileHolder mLoadSaveRequest;
/* 0x018 */ NandRequestDeleteHolder mDeleteRequest;
/* 0x01C */ dLytSaveMsgWindow_c *mpWindow;
/* 0x020 */ wchar_t mTextBuf[0x400];
/* 0x820 */ SaveMgrState_e mCurrentState;
/* 0x824 */ s32 field_0x824;
/* 0x828 */ s32 mCheckForFreeSpaceResult;
/* 0x82C */ s32 mStep;
/* 0x830 */ s32 mDelayTimer;
/* 0x834 */ u8 mCopyToFile;
/* 0x835 */ u8 mCopyFromFile;
/* 0x836 */ u8 field_0x836;
/* 0x837 */ u8 field_0x837;
/* 0x838 */ u8 field_0x838;
/* 0x839 */ u8 field_0x839;
/* 0x83A */ u8 field_0x83A;
/* 0x83B */ u8 field_0x83B;
/* 0x83C */ u8 field_0x83C;
/* 0x83D */ u8 field_0x83D;
/* 0x83E */ u8 field_0x83E;
/* 0x83F */ u8 field_0x83F;
static SaveMgr *sInstance;
};
#endif
-28
View File
@@ -1,28 +0,0 @@
#ifndef SOME_GFX_THING_H
#define SOME_GFX_THING_H
#include "common.h"
class SomeGfxThing;
extern SomeGfxThing *SOME_GFX_THING;
class SomeGfxThing {
public:
typedef void (*drawCallback)(void);
static void setDrawCallback(drawCallback cb) {
SOME_GFX_THING->mDrawCb = cb;
}
static void setField0x09(u8 val) {
SOME_GFX_THING->field_0x09 = val;
}
private:
u8 _0x00[0x04 - 0x00];
drawCallback mDrawCb;
u8 field_0x08;
u8 field_0x09;
};
#endif