From 596d0798aea02e7044d6e928dede438b4b353f7d Mon Sep 17 00:00:00 2001 From: Pistonight Date: Thu, 8 Aug 2024 23:40:59 -0700 Subject: [PATCH] finish most of LayoutResourceMgr --- data/data_symbols.csv | 31 ++++++++++--------- data/uking_functions.csv | 16 +++++----- src/KingSystem/System/UI/ArcResourceMgr.h | 2 +- .../System/UI/LayoutResourceMgr.cpp | 28 ++++++++--------- src/KingSystem/System/UI/LayoutResourceMgr.h | 14 +++++++-- tools/format_data_symbols.py | 22 +++++++++++++ 6 files changed, 72 insertions(+), 41 deletions(-) create mode 100644 tools/format_data_symbols.py diff --git a/data/data_symbols.csv b/data/data_symbols.csv index 8d8bb29d..81b773f9 100644 --- a/data/data_symbols.csv +++ b/data/data_symbols.csv @@ -1,6 +1,6 @@ -0x0000007101e9fe68,_ZN4sead8Matrix34IfE5identE -0x0000007101e9ff18,_ZN4sead7Vector3IfE4zeroE -0x0000007101e9ff48,_ZN4sead7Vector3IfE4onesE +0x0000007101E9FE68,_ZN4sead8Matrix34IfE5identE +0x0000007101E9FF18,_ZN4sead7Vector3IfE4zeroE +0x0000007101E9FF48,_ZN4sead7Vector3IfE4onesE 0x00000071023556B0,_ZTVN4sead14SafeStringBaseIcEE 0x0000007102356AF0,_ZTVN4sead22BufferedSafeStringBaseIcEE 0x000000710246F9E0,_ZN4ksys3gdt6detail13sCommonFlags0E @@ -20,6 +20,9 @@ 0x00000071024C1600,_ZTVN3agl3utl9ParameterIN4sead15FixedSafeStringILi64EEEEE 0x00000071024C16A0,_ZTVN3agl3utl9ParameterIN4sead15FixedSafeStringILi256EEEEE 0x00000071024C1740,_ZTVN3agl3utl9ParameterIN4sead14SafeStringBaseIcEEEE +0x00000071024C6600,_ZN6xlink216ContainerCreator17sContainerSizeMaxE +0x00000071024C68A8,_ZN6xlink215sMinAddressHighE +0x00000071024C68B0,_ZN6xlink214sMinAddressLowE 0x00000071024D8D58,_ZTVN4ksys3act2ai10ActionBaseE 0x00000071025129E0,_ZTVN4ksys3act2ai6ActionE 0x0000007102513268,_ZTVN4ksys3act2ai2AiE @@ -500,17 +503,15 @@ 0x00000071025F8480,pfnc_nvnEventSignal 0x00000071025F8488,pfnc_nvnCommandBufferWaitEvent 0x00000071025F8490,pfnc_nvnCommandBufferSignalEvent -0x0000007102606910,_ZN4ksys12SystemTimers9sInstanceE -0x0000007102650608,_ZN4ksys3act11BaseProcMgr9sInstanceE 0x00000071025F9CB0,_ZN3agl6driver17GraphicsDriverMgr18SingletonDisposer_15sStaticDisposerE 0x00000071025F9CB8,_ZN3agl6driver17GraphicsDriverMgr9sInstanceE -0x00000071024c6600,_ZN6xlink216ContainerCreator17sContainerSizeMaxE -0x00000071024c68a8,_ZN6xlink215sMinAddressHighE -0x00000071024c68b0,_ZN6xlink214sMinAddressLowE -0x00000071025fb508,_ZN3aal6System9sInstanceE -0x00000071025fc7f0,_ZN6xlink211SystemSLink9sInstanceE -0x00000071025fc7f8,_ZN6xlink211SystemSLink10sLockProxyE -0x00000071025fc878,_ZZNK6xlink214ResourceBuffer18getEmptyUserHeaderEvE6sDummy -0x00000071025fc8b0,_ZZNK6xlink214ResourceBuffer24getEmptyRomResourceParamEvE6sDummy -0x00000071025fc948,_ZZNK6xlink214ResourceBuffer24getEmptyRomResourceParamEvE6sDummy -0x00000071025fc950,_ZN6xlink27Locator16sDataLoadedCountE \ No newline at end of file +0x00000071025FB508,_ZN3aal6System9sInstanceE +0x00000071025FC7F0,_ZN6xlink211SystemSLink9sInstanceE +0x00000071025FC7F8,_ZN6xlink211SystemSLink10sLockProxyE +0x00000071025FC878,_ZZNK6xlink214ResourceBuffer18getEmptyUserHeaderEvE6sDummy +0x00000071025FC8B0,_ZZNK6xlink214ResourceBuffer24getEmptyRomResourceParamEvE6sDummy +0x00000071025FC948,_ZZNK6xlink214ResourceBuffer24getEmptyRomResourceParamEvE6sDummy +0x00000071025FC950,_ZN6xlink27Locator16sDataLoadedCountE +0x0000007102606910,_ZN4ksys12SystemTimers9sInstanceE +0x0000007102650608,_ZN4ksys3act11BaseProcMgr9sInstanceE +0x000000710261EB90,_ZN4ksys2ui17LayoutResourceMgr9sInstanceE diff --git a/data/uking_functions.csv b/data/uking_functions.csv index f120bd59..66d7a8b2 100644 --- a/data/uking_functions.csv +++ b/data/uking_functions.csv @@ -88328,22 +88328,22 @@ Address,Quality,Size,Name 0x00000071010a2294,U,000008, 0x00000071010a229c,U,000040, 0x00000071010a22c4,U,000372, -0x00000071010a2438,W,000112,_ZN4ksys2ui17LayoutResourceMgr18SingletonDisposer_D0Ev -0x00000071010a24a8,W,000120,_ZN4ksys2ui17LayoutResourceMgr18SingletonDisposer_D1Ev +0x00000071010a2438,O,000112,_ZN4ksys2ui17LayoutResourceMgr18SingletonDisposer_D1Ev +0x00000071010a24a8,O,000120,_ZN4ksys2ui17LayoutResourceMgr18SingletonDisposer_D0Ev 0x00000071010a2520,O,000284,_ZN4ksys2ui17LayoutResourceMgr14createInstanceEPN4sead4HeapE 0x00000071010a263c,O,000268,_ZN4ksys2ui17LayoutResourceMgr4initEPN4sead4HeapE 0x00000071010a2748,O,000424,_ZN4ksys2ui17LayoutResourceMgr11loadMsgPackEPj -0x00000071010a28f0,U,000384,LayoutResourceMgr::__auto2 -0x00000071010a2a70,W,000260,_ZN4ksys2ui17LayoutResourceMgr12loadLangFontEPN4sead4HeapE -0x00000071010a2b74,U,000388,LayoutResourceMgr::__auto0 +0x00000071010a28f0,U,000384,LayoutResourceMgr::loadGrammarArticleMaxLen +0x00000071010a2a70,O,000260,_ZN4ksys2ui17LayoutResourceMgr12loadLangFontEPN4sead4HeapE +0x00000071010a2b74,U,000388,LayoutResourceMgr::initializeFontMgr 0x00000071010a2cf8,W,000680,_ZN4ksys2ui17LayoutResourceMgr18loadExtraLangFontsEPN4sead4HeapE 0x00000071010a2fa0,O,000188,_ZN4ksys2ui17LayoutResourceMgr18checkLangFontReadyEv 0x00000071010a305c,O,000136,_ZNK4ksys2ui17LayoutResourceMgr24checkExtraLangFontsReadyEv 0x00000071010a30e4,O,000136,_ZN4ksys2ui17LayoutResourceMgr11loadVersionEv -0x00000071010a316c,W,000372,_ZN4ksys2ui17LayoutResourceMgr17checkVersionReadyEv -0x00000071010a32e0,U,001584,LayoutResourceMgr::loadALotOfResources +0x00000071010a316c,O,000372,_ZN4ksys2ui17LayoutResourceMgr17checkVersionReadyEv +0x00000071010a32e0,U,001584,LayoutResourceMgr::doSomethingWithFontTextureCache 0x00000071010a3910,W,000064,_ZN4sead12PerfJobQueue13measureEndRunEv -0x00000071010a3950,W,000072,_ZN4ksys2ui17LayoutResourceMgr23loadCommonLayoutArchiveEPN4sead7ExpHeapE +0x00000071010a3950,O,000072,_ZN4ksys2ui17LayoutResourceMgr23loadCommonLayoutArchiveEPN4sead7ExpHeapE 0x00000071010a3998,O,000288,_ZN4ksys2ui17LayoutResourceMgr15loadArcResourceERNS1_7ArchiveEPKc 0x00000071010a3ab8,O,000104,_ZN4ksys2ui17LayoutResourceMgr8unloadA8Ev 0x00000071010a3b20,O,000208,_ZN4ksys2ui17LayoutResourceMgr15loadTitleLayoutEPN4sead4HeapE diff --git a/src/KingSystem/System/UI/ArcResourceMgr.h b/src/KingSystem/System/UI/ArcResourceMgr.h index cee7d935..501dd515 100644 --- a/src/KingSystem/System/UI/ArcResourceMgr.h +++ b/src/KingSystem/System/UI/ArcResourceMgr.h @@ -16,8 +16,8 @@ public: ArcResourceMgr() = default; virtual ~ArcResourceMgr(); + virtual void sub_10(); virtual void loadArchive(sead::ExpHeap* heap, const sead::SafeString& path); - virtual void sub_18(); virtual void sub_20(); virtual void sub_28(); virtual void addArchive(ArcResource* archive); diff --git a/src/KingSystem/System/UI/LayoutResourceMgr.cpp b/src/KingSystem/System/UI/LayoutResourceMgr.cpp index aa2786fc..21af64a9 100644 --- a/src/KingSystem/System/UI/LayoutResourceMgr.cpp +++ b/src/KingSystem/System/UI/LayoutResourceMgr.cpp @@ -9,7 +9,6 @@ namespace ksys::ui { SEAD_SINGLETON_DISPOSER_IMPL(LayoutResourceMgr) -LayoutResourceMgr::~LayoutResourceMgr() = default; void LayoutResourceMgr::init(sead::Heap* heap) { mMsgPackHandle = new (heap) res::Handle; @@ -61,7 +60,7 @@ u8* LayoutResourceMgr::loadMsgPack(u32* size) { void LayoutResourceMgr::loadLangFont(sead::Heap* heap) { mLangFontHandle->resetUnitFlag20000IfSuccess(); mLangFontHandle->unload(); - mLangFontHandle = nullptr; + mLangFontResource = nullptr; res::LoadRequest req; req.mRequester = "LayoutResourceMgr"; @@ -70,10 +69,9 @@ void LayoutResourceMgr::loadLangFont(sead::Heap* heap) { req._26 = false; sead::FixedSafeString<0x20> path; - // TODO: needs sead::EnvUtil::getRegion() and sead::RegionID - /* path.format("Font/Font_%s.bfarc", sead::EnvUtil::getRegion()); */ + path.format("Font/Font_%s.bfarc", sead::EnvUtil2::getRegion().text()); - mLangFontHandle->load(path, &req, nullptr); + mLangFontHandle->requestLoad(path, &req, nullptr); } constexpr const char* cExtraFontFiles[3][4] = { @@ -153,17 +151,17 @@ void LayoutResourceMgr::loadVersion() { // non-matching bool LayoutResourceMgr::checkVersionReady() { if (!mVersionHandle) { - if (!mVersionHandle->isReady()) { - return false; - } - auto* resource = sead::DynamicCast(mVersionHandle->getResource()); - instance()->mVersionString = reinterpret_cast(resource->getRawData()); - if (mVersionHandle) { - delete mVersionHandle; - mVersionHandle = nullptr; - } + return true; } - return true; + if (mVersionHandle->isReady()) { + auto* resource = sead::DynamicCast(mVersionHandle->getResource()); + instance()->mVersionString + .copy(reinterpret_cast(resource->getRawData()), static_cast(resource->getRawSize())); + delete mVersionHandle; + mVersionHandle = nullptr; + return true; + } + return false; } void LayoutResourceMgr::loadCommonLayoutArchive(sead::ExpHeap* heap) { diff --git a/src/KingSystem/System/UI/LayoutResourceMgr.h b/src/KingSystem/System/UI/LayoutResourceMgr.h index 168cac17..d592adf0 100644 --- a/src/KingSystem/System/UI/LayoutResourceMgr.h +++ b/src/KingSystem/System/UI/LayoutResourceMgr.h @@ -14,13 +14,21 @@ enum SharedFontType : int { Unknown = 0 }; u64 RequestSharedFontLoad(nn::pl::SharedFontType type); u32 GetSharedFontLoadState(nn::pl::SharedFontType type); } // namespace nn::pl +#include "prim/seadEnum.h" +namespace sead { +SEAD_ENUM(RegionID, JP, US, EU, KR, CN) + class EnvUtil2 { + public: + static RegionID getRegion(); +}; +} namespace ksys::ui { class LayoutResourceMgr { SEAD_SINGLETON_DISPOSER(LayoutResourceMgr) LayoutResourceMgr() = default; - virtual ~LayoutResourceMgr(); + ~LayoutResourceMgr() = default; private: class Archive { friend class LayoutResourceMgr; @@ -54,6 +62,8 @@ private: public: + virtual void this_class_has_vtable(); + void init(sead::Heap* heap); u8* loadMsgPack(u32* size); void loadLangFont(sead::Heap* heap); @@ -71,11 +81,11 @@ public: bool hasHorseLayoutLoadFailure() const; bool unloadHorseLayout(); void unloadA8(); + void doSomethingWithFontTextureCache(void* texture_cache); bool loadArcResource(Archive& archive, const char* name); private: - res::Handle* mMsgPackHandle = nullptr; res::Handle* mLangFontHandle = nullptr; res::Handle* mVersionHandle = nullptr; diff --git a/tools/format_data_symbols.py b/tools/format_data_symbols.py new file mode 100644 index 00000000..8758c93c --- /dev/null +++ b/tools/format_data_symbols.py @@ -0,0 +1,22 @@ +import os + +DATA_SYMBOLS = os.path.join(os.path.dirname(__file__), '../data/data_symbols.csv') + +if __name__ == "__main__": + lines = {} + + with open(DATA_SYMBOLS, "r", encoding="utf-8") as f: + for line in f: + line = line.strip() + if not line: + continue + hex = "0x" + (line[2:18].upper()) + name = line[19:].strip() + new_line = f"{hex},{name}" + lines[hex] = new_line + + with open(DATA_SYMBOLS, "w", encoding="utf-8") as f: + for hex in sorted(lines): + f.write(f"{lines[hex]}\n") + print("data_symbols.csv updated") +