From bd787b53c6822e1ec98847f16cc47328dd73879c Mon Sep 17 00:00:00 2001 From: guymakinggames <66076221+guymakinggames@users.noreply.github.com> Date: Sun, 22 Mar 2026 20:42:11 +0000 Subject: [PATCH] System: Implement `SaveDataAccessFunction` (#960) --- data/file_list.yml | 26 +++++------ src/System/GameDataHolder.h | 2 + src/System/SaveDataAccessFunction.cpp | 64 +++++++++++++++++++++++++++ src/System/SaveDataAccessFunction.h | 26 +++++------ src/System/SaveDataAccessSequence.h | 56 +++++++++++++++++++++++ 5 files changed, 148 insertions(+), 26 deletions(-) create mode 100644 src/System/SaveDataAccessFunction.cpp create mode 100644 src/System/SaveDataAccessSequence.h diff --git a/data/file_list.yml b/data/file_list.yml index a106d1fe..57275543 100644 --- a/data/file_list.yml +++ b/data/file_list.yml @@ -151057,55 +151057,55 @@ System/SaveDataAccessFunction.o: - offset: 0x539674 size: 8 label: _ZN22SaveDataAccessFunction17startSaveDataInitEP14GameDataHolder - status: NotDecompiled + status: Matching - offset: 0x53967c size: 8 label: _ZN22SaveDataAccessFunction21startSaveDataInitSyncEP14GameDataHolder - status: NotDecompiled + status: Matching - offset: 0x539684 size: 40 label: _ZN22SaveDataAccessFunction21startSaveDataLoadFileEP14GameDataHolder - status: NotDecompiled + status: Matching - offset: 0x5396ac size: 8 label: _ZN22SaveDataAccessFunction21startSaveDataReadSyncEP14GameDataHolder - status: NotDecompiled + status: Matching - offset: 0x5396b4 size: 8 label: _ZN22SaveDataAccessFunction20startSaveDataReadAllEP14GameDataHolder - status: NotDecompiled + status: Matching - offset: 0x5396bc size: 8 label: _ZN22SaveDataAccessFunction18startSaveDataWriteEP14GameDataHolder - status: NotDecompiled + status: Matching - offset: 0x5396c4 size: 40 label: _ZN22SaveDataAccessFunction28startSaveDataWriteWithWindowEP14GameDataHolder - status: NotDecompiled + status: Matching - offset: 0x5396ec size: 64 label: _ZN22SaveDataAccessFunction27startSaveDataCopyWithWindowEP14GameDataHolderii - status: NotDecompiled + status: Matching - offset: 0x53972c size: 48 label: _ZN22SaveDataAccessFunction29startSaveDataDeleteWithWindowEP14GameDataHolderi - status: NotDecompiled + status: Matching - offset: 0x53975c size: 8 label: _ZN22SaveDataAccessFunction22startSaveDataWriteSyncEP14GameDataHolder - status: NotDecompiled + status: Matching - offset: 0x539764 size: 8 label: _ZN22SaveDataAccessFunction20updateSaveDataAccessEP14GameDataHolderb - status: NotDecompiled + status: Matching - offset: 0x53976c size: 8 label: _ZN22SaveDataAccessFunction12isEnableSaveEPK14GameDataHolder - status: NotDecompiled + status: Matching - offset: 0x539774 size: 8 label: _ZN22SaveDataAccessFunction10isDoneSaveEP14GameDataHolder - status: NotDecompiled + status: Matching System/SaveDataAccessSequence.o: '.text': - offset: 0x53977c diff --git a/src/System/GameDataHolder.h b/src/System/GameDataHolder.h index 940768dd..1150aeec 100644 --- a/src/System/GameDataHolder.h +++ b/src/System/GameDataHolder.h @@ -281,6 +281,8 @@ public: GameConfigData* getGameConfigData() const { return mGameConfigData; } + SaveDataAccessSequence* getSaveDataAccessSequence() const { return mSaveDataAccessSequence; } + private: al::MessageSystem* mMessageSystem; GameDataFile** mFiles; diff --git a/src/System/SaveDataAccessFunction.cpp b/src/System/SaveDataAccessFunction.cpp new file mode 100644 index 00000000..24cf3552 --- /dev/null +++ b/src/System/SaveDataAccessFunction.cpp @@ -0,0 +1,64 @@ +#include "System/SaveDataAccessFunction.h" + +#include "System/GameDataHolder.h" +#include "System/SaveDataAccessSequence.h" + +namespace SaveDataAccessFunction { + +void startSaveDataInit(GameDataHolder* holder) { + holder->getSaveDataAccessSequence()->startInit(); +} + +void startSaveDataInitSync(GameDataHolder* holder) { + holder->getSaveDataAccessSequence()->startInitSync(); +} + +void startSaveDataLoadFile(GameDataHolder* holder) { + holder->getSaveDataAccessSequence()->setWindowSwitch(); + holder->getSaveDataAccessSequence()->startWrite(); +} + +void startSaveDataReadSync(GameDataHolder* holder) { + holder->getSaveDataAccessSequence()->startReadSync(); +} + +void startSaveDataReadAll(GameDataHolder* holder) { + holder->getSaveDataAccessSequence()->startReadAll(); +} + +void startSaveDataWrite(GameDataHolder* holder) { + holder->getSaveDataAccessSequence()->startWrite(); +} + +void startSaveDataWriteWithWindow(GameDataHolder* holder) { + holder->getSaveDataAccessSequence()->setWindowSave(); + holder->getSaveDataAccessSequence()->startWriteWithWindow(); +} + +void startSaveDataCopyWithWindow(GameDataHolder* holder, s32 srcFileIndex, s32 destFileIndex) { + holder->getSaveDataAccessSequence()->setWindowSave(); + holder->getSaveDataAccessSequence()->startCopyWithWindow(srcFileIndex, destFileIndex); +} + +void startSaveDataDeleteWithWindow(GameDataHolder* holder, s32 fileIndex) { + holder->getSaveDataAccessSequence()->setWindowDelete(); + holder->getSaveDataAccessSequence()->startDeleteWithWindow(fileIndex); +} + +void startSaveDataWriteSync(GameDataHolder* holder) { + holder->getSaveDataAccessSequence()->startWriteSync(); +} + +bool updateSaveDataAccess(GameDataHolder* holder, bool _unused) { + return holder->getSaveDataAccessSequence()->update(); +} + +bool isEnableSave(const GameDataHolder* holder) { + return holder->getSaveDataAccessSequence()->isEnableSave(); +} + +bool isDoneSave(GameDataHolder* holder) { + return holder->getSaveDataAccessSequence()->isDoneSave(); +} + +} // namespace SaveDataAccessFunction diff --git a/src/System/SaveDataAccessFunction.h b/src/System/SaveDataAccessFunction.h index 2abaaf00..9741a4bd 100644 --- a/src/System/SaveDataAccessFunction.h +++ b/src/System/SaveDataAccessFunction.h @@ -5,17 +5,17 @@ class GameDataHolder; namespace SaveDataAccessFunction { -void startSaveDataInit(GameDataHolder*); -void startSaveDataInitSync(GameDataHolder*); -void startSaveDataLoadFile(GameDataHolder*); -void startSaveDataReadSync(GameDataHolder*); -void startSaveDataReadAll(GameDataHolder*); -void startSaveDataWrite(GameDataHolder*); -void startSaveDataWriteWithWindow(GameDataHolder*); -void startSaveDataCopyWithWindow(GameDataHolder*, s32, s32); -void startSaveDataDeleteWithWindow(GameDataHolder*, s32); -void startSaveDataWriteSync(GameDataHolder*); -bool updateSaveDataAccess(GameDataHolder*, bool); -bool isEnableSave(const GameDataHolder*); -bool isDoneSave(GameDataHolder*); +void startSaveDataInit(GameDataHolder* holder); +void startSaveDataInitSync(GameDataHolder* holder); +void startSaveDataLoadFile(GameDataHolder* holder); +void startSaveDataReadSync(GameDataHolder* holder); +void startSaveDataReadAll(GameDataHolder* holder); +void startSaveDataWrite(GameDataHolder* holder); +void startSaveDataWriteWithWindow(GameDataHolder* holder); +void startSaveDataCopyWithWindow(GameDataHolder* holder, s32 srcFileIndex, s32 destFileIndex); +void startSaveDataDeleteWithWindow(GameDataHolder* holder, s32 fileIndex); +void startSaveDataWriteSync(GameDataHolder* holder); +bool updateSaveDataAccess(GameDataHolder* holder, bool _unused); +bool isEnableSave(const GameDataHolder* holder); +bool isDoneSave(GameDataHolder* holder); } // namespace SaveDataAccessFunction diff --git a/src/System/SaveDataAccessSequence.h b/src/System/SaveDataAccessSequence.h new file mode 100644 index 00000000..63dd1553 --- /dev/null +++ b/src/System/SaveDataAccessSequence.h @@ -0,0 +1,56 @@ +#pragma once + +#include +#include + +#include "Library/Nerve/NerveExecutor.h" + +class GameDataHolder; +class SaveDataAccessor; + +namespace al { +class LayoutInitInfo; +} + +class SaveDataAccessSequence : public al::NerveExecutor { +public: + SaveDataAccessSequence(GameDataHolder*, const al::LayoutInitInfo&); + bool update(); + bool isDone() const; + void startInit(); + void startInitSync(); + void startReadSync(); + void startReadAll(); + void addRequest(sead::FixedSafeString<32>*, sead::FixedSafeString<32>*, s32); + sead::FixedSafeString<32>* getFileNamePtrByIndex(s32) const; + void startWrite(); + sead::FixedSafeString<32>* getPlayingFileNamePtr() const; + sead::FixedSafeString<32>* getFileNameCommon() const; + void startWriteSync(); + void startWriteWithWindow(); + void startCopyWithWindow(s32, s32); + void startDeleteWithWindow(s32); + void exeIdle(); + void exeInit(); + void exeWaitLayout(); + void exeWrite(); + void clearAllRequest(); + bool isNextFileCommon() const; + const char* getNextFileNameSrc() const; + const char* getNextFileNameDest() const; + void clearCurrentRequest(); + bool tryChangeNextNerve(); + void exeFlush(); + void exeRead(); + bool isEnableSave() const; + bool isDoneSave() const; + void setWindowSave(); + void setWindowSwitch(); + void setWindowDelete(); + bool isExistRequest() const; + +private: + char filler_8[0x50]; +}; + +static_assert(sizeof(SaveDataAccessSequence) == 0x60);