From b5cc785c83d76a481c7cef2211f30fea8be39246 Mon Sep 17 00:00:00 2001 From: lepelog <25211966+lepelog@users.noreply.github.com> Date: Fri, 6 Oct 2023 21:32:53 +0200 Subject: [PATCH] start misc flag managers and update wibo --- .vscode/settings.json | 3 +- config/SOUE01/splits.txt | 3 + config/SOUE01/symbols.txt | 20 +++---- configure.py | 3 +- include/toBeSorted/file_manager.h | 2 + src/toBeSorted/misc_flag_managers.cpp | 85 +++++++++++++++++++++++++++ tools/project.py | 2 +- 7 files changed, 105 insertions(+), 13 deletions(-) create mode 100644 src/toBeSorted/misc_flag_managers.cpp diff --git a/.vscode/settings.json b/.vscode/settings.json index 9049f7e5..9a75dccb 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,6 @@ { "clangd.fallbackFlags": [ - "-I${workspaceFolder}/include" + "-I${workspaceFolder}/include", + "-I${workspaceFolder}/include/lib", ] } \ No newline at end of file diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index a216a464..1317c56a 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -44,6 +44,9 @@ toBeSorted/sceneflag_manager.cpp: .sbss start:0x805753E0 end:0x805753F0 .bss start:0x805A78D0 end:0x805A7AD8 +toBeSorted/misc_flag_managers.cpp: + .text start:0x800BE7B0 end:0x800BEE00 + toBeSorted/flag_space.cpp: .text start:0x800BEE00 end:0x800BEF90 .data start:0x80510D04 end:0x80510D10 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 8df834f6..c693e72f 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -284,7 +284,7 @@ fn_8000A730 = .text:0x8000A730; // type:function size:0x58 fn_8000A790 = .text:0x8000A790; // type:function size:0x58 fn_8000A7F0 = .text:0x8000A7F0; // type:function size:0x58 setSceneflags__11FileManagerFPUsUiUs = .text:0x8000A850; // type:function size:0x58 -fn_8000A8B0 = .text:0x8000A8B0; // type:function size:0x58 +setTBoxFlags__11FileManagerFPUsUiUs = .text:0x8000A8B0; // type:function size:0x58 setTempflags__11FileManagerFPUsUsUs = .text:0x8000A910; // type:function size:0x58 setZoneflags__11FileManagerFPUsUsUs = .text:0x8000A970; // type:function size:0x58 fn_8000A9D0 = .text:0x8000A9D0; // type:function size:0x58 @@ -4101,15 +4101,15 @@ unsetFlag__16SceneflagManagerFUsUs = .text:0x800BE490; // type:function size:0x7 unsetSceneflagGlobal__16SceneflagManagerFUsUs = .text:0x800BE500; // type:function size:0xE0 unsetTempOrSceneflag__16SceneflagManagerFUs = .text:0x800BE5E0; // type:function size:0x100 doCommit__16SceneflagManagerFv = .text:0x800BE6E0; // type:function size:0xC8 -fn_800BE7B0 = .text:0x800BE7B0; // type:function size:0x58 -fn_800BE810 = .text:0x800BE810; // type:function size:0x58 -fn_800BE870 = .text:0x800BE870; // type:function size:0x68 -fn_800BE8E0 = .text:0x800BE8E0; // type:function size:0x40 -fn_800BE920 = .text:0x800BE920; // type:function size:0x4 -fn_800BE930 = .text:0x800BE930; // type:function size:0x5C -fn_800BE990 = .text:0x800BE990; // type:function size:0x94 -fn_800BEA30 = .text:0x800BEA30; // type:function size:0x8 -fn_800BEA40 = .text:0x800BEA40; // type:function size:0x80 +commitIfNecessary__22CommittableFlagManagerFv = .text:0x800BE7B0; // type:function size:0x58 +doCommit__15TBoxFlagManagerFv = .text:0x800BE810; // type:function size:0x58 +checkUncommittedFlag__15TBoxFlagManagerFUs = .text:0x800BE870; // type:function size:0x68 +__ct__15TBoxFlagManagerFv = .text:0x800BE8E0; // type:function size:0x40 +init__15TBoxFlagManagerFv = .text:0x800BE920; // type:function size:0x4 +copyFromSave__15TBoxFlagManagerFUs = .text:0x800BE930; // type:function size:0x5C +checkFlag__15TBoxFlagManagerFUsUs = .text:0x800BE990; // type:function size:0x94 +getFlagCount__15TBoxFlagManagerCFv = .text:0x800BEA30; // type:function size:0x8 +setFlag__15TBoxFlagManagerFUs = .text:0x800BEA40; // type:function size:0x80 fn_800BEAC0 = .text:0x800BEAC0; // type:function size:0x40 fn_800BEB00 = .text:0x800BEB00; // type:function size:0x7C fn_800BEB80 = .text:0x800BEB80; // type:function size:0x38 diff --git a/configure.py b/configure.py index 53b59361..6ab1e4c2 100644 --- a/configure.py +++ b/configure.py @@ -122,7 +122,7 @@ if not is_windows(): config.compilers_tag = "1" config.dtk_tag = "v0.5.5" config.sjiswrap_tag = "v1.1.1" -config.wibo_tag = "0.5.1" +config.wibo_tag = "0.6.3" # Project config.config_path = Path("config") / config.version / "config.yml" @@ -248,6 +248,7 @@ config.libs = [ Object(Matching, "toBeSorted/bitwise_flag_helper.cpp"), Object(Matching, "toBeSorted/sceneflag_manager.cpp"), Object(NonMatching, "toBeSorted/flag_space.cpp"), + Object(NonMatching, "toBeSorted/misc_flag_managers.cpp"), Object(Matching, "d/d_base.cpp"), Object(NonMatching, "d/a/d_a_base.cpp"), Object(NonMatching,"d/a/obj/d_a_obj_base.cpp"), diff --git a/include/toBeSorted/file_manager.h b/include/toBeSorted/file_manager.h index b2e3cbf3..7de39396 100644 --- a/include/toBeSorted/file_manager.h +++ b/include/toBeSorted/file_manager.h @@ -11,9 +11,11 @@ struct FileManager { u16* getSceneflags2(); u16* getTempflags2(); u16* getZoneflags2(); + u16* getTBoxFlags2(); void setTempflags(u16*, u16, u16); void setZoneflags(u16*, u16, u16); void setSceneflags(u16*, u32, u16); + void setTBoxFlags(u16*, u32, u16); static FileManager* getInstance() { return sInstance; } diff --git a/src/toBeSorted/misc_flag_managers.cpp b/src/toBeSorted/misc_flag_managers.cpp new file mode 100644 index 00000000..685210b4 --- /dev/null +++ b/src/toBeSorted/misc_flag_managers.cpp @@ -0,0 +1,85 @@ +#include +#include +#include +#include + +class CommittableFlagManager { + public: + bool mNeedsCommit; + + virtual void doCommit() = 0; + bool commitIfNecessary(); + void setNeedsCommit(bool commit) { + mNeedsCommit = commit; + } + // CommittableFlagManager(bool commit) { + // mNeedsCommit = commit; + // } +}; + +bool CommittableFlagManager::commitIfNecessary() { + if (mNeedsCommit) { + doCommit(); + mNeedsCommit = false; + return true; + } else { + return false; + } +} + +class TBoxFlagManager: public CommittableFlagManager { +// class TBoxFlagManager { + // bool mNeedsCommit; + // u32 pad; + FlagSpace mFlagSpace; + u16 mSceneIndex; + BitwiseFlagHelper mFlagHelper; + + static u16* sFlags; + public: + virtual void doCommit(); + bool checkUncommittedFlag(u16 flag); + TBoxFlagManager(); + virtual ~TBoxFlagManager() {} + void init(); + void copyFromSave(u16 sceneIndex); + bool checkFlag(u16 sceneIndex, u16 flag); + virtual s32 getFlagCount() const; + void setFlag(u16 flag); + bool checkUncommittedFlag(u16 sceneIndex, u16 flag); +}; + +void TBoxFlagManager::doCommit() { + if (mSceneIndex != 0xFFFF) { + FileManager::getInstance()->setTBoxFlags(mFlagSpace.getFlagPtrUnchecked(), mSceneIndex * 2, 2); + } +} + +bool TBoxFlagManager::checkUncommittedFlag(u16 flag) { + return mFlagHelper.checkFlag(flag / 16, flag % 16, mFlagSpace.getFlagPtrUnchecked(), mFlagSpace.mCount); +} + +TBoxFlagManager::TBoxFlagManager(): mFlagSpace(sFlags, 2) { + mSceneIndex = 0xFFFF; +} + +void TBoxFlagManager::init() {} + +void TBoxFlagManager::copyFromSave(u16 sceneIndex) { + mSceneIndex = sceneIndex; + u16* flags = FileManager::getInstance()->getTBoxFlags2(); + mFlagSpace.copyFromSaveFile2(flags + sceneIndex * 2, 0, 2); +} + +bool TBoxFlagManager::checkFlag(u16 sceneIndex, u16 flag) { + s32 actualFlag = sceneIndex * 0x20 + flag; + return mFlagHelper.checkFlag(actualFlag % 16, actualFlag / 16, FileManager::getInstance()->getTBoxFlags2(), getFlagCount()); +} + +s32 TBoxFlagManager::getFlagCount() const { + return 0x200; +} + +void TBoxFlagManager::setFlag(u16 flag) { + +} diff --git a/tools/project.py b/tools/project.py index 84ac07c9..cdadec68 100644 --- a/tools/project.py +++ b/tools/project.py @@ -99,7 +99,7 @@ class Object: "add_to_all": True, "cflags": None, "mw_version": None, - "shiftjis": False, # NOTE: This was defaulted to True -> caused it to not build in wsl? + "shiftjis": True, "source": name, } self.options.update(options)