mirror of
https://github.com/zeldaret/ss
synced 2026-09-02 17:53:15 -04:00
save_manager OK
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user