diff --git a/config/SOUE01/config.yml b/config/SOUE01/config.yml index 3615db70..8ad52f93 100644 --- a/config/SOUE01/config.yml +++ b/config/SOUE01/config.yml @@ -10,8 +10,15 @@ force_active: [ "ProcessTab__Q34nw4r2ut19TagProcessorBaseFPQ34nw4r2ut15PrintContext", "ProcessLinefeed__Q34nw4r2ut19TagProcessorBaseFPQ34nw4r2ut15PrintContext", "ProcessTab__Q34nw4r2ut19TagProcessorBaseFPQ34nw4r2ut15PrintContext", - # "RemoveResourceBuffer__Q44nw4r2ut6detail11ResFontBaseFv", "RemoveResource__Q34nw4r2ut7ResFontFv", + "Set__Q34nw4r3lyt15ArcResourceLinkFPvPCc", + "__ct__Q34nw4r3lyt24MultiArcResourceAccessorFv", + "__dt__Q34nw4r3lyt24MultiArcResourceAccessorFv", + "Attach__Q34nw4r3lyt24MultiArcResourceAccessorFPQ34nw4r3lyt15ArcResourceLink", + "GetResource__Q34nw4r3lyt24MultiArcResourceAccessorFUlPCcPUl", + "RegistFont__Q34nw4r3lyt24MultiArcResourceAccessorFPQ34nw4r3lyt11FontRefLink", + "GetFont__Q34nw4r3lyt24MultiArcResourceAccessorFPCc", + ] # modules: # - object: orig/SOUE01/rels/d_a_asura_bulletNP.rel diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index cbff745b..ec781942 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -316,6 +316,11 @@ nw4r/db/db_directPrint.cpp: .sbss start:0x805765E8 end:0x805765EC .bss start:0x80636B80 end:0x80636BA4 +nw4r/lyt/lyt_arcResourceAccessor.cpp: + .text start:0x80492060 end:0x80492780 + .data start:0x8056E7F8 end:0x8056E820 + .sdata start:0x80574EC0 end:0x80574EC8 + nw4r/lyt/lyt_common.cpp: .text start:0x80492780 end:0x804932E0 .sbss start:0x80576720 end:0x80576728 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 33de0e69..cbfd0edc 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -3866,7 +3866,7 @@ fn_800B1630 = .text:0x800B1630; // type:function size:0x3C fn_800B1670 = .text:0x800B1670; // type:function size:0x134 fn_800B17B0 = .text:0x800B17B0; // type:function size:0x8 fn_800B17C0 = .text:0x800B17C0; // type:function size:0x58 -fn_800B1820 = .text:0x800B1820; // type:function size:0x6C +__dt__Q34nw4r3lyt19ArcResourceAccessorFv = .text:0x800B1820; // type:function size:0x6C scope:weak fn_800B1890 = .text:0x800B1890; // type:function size:0x40 fn_800B18D0 = .text:0x800B18D0; // type:function size:0x4D4 fn_800B1DB0 = .text:0x800B1DB0; // type:function size:0x15C @@ -17361,7 +17361,7 @@ searchBaseByGroupType__10fManager_cFUcPC7fBase_c = .text:0x802E2980; // type:fun mainLoop__10fManager_cFv = .text:0x802E29E0; // type:function size:0xC0 __sinit_\f_manager_cpp = .text:0x802E2AA0; // type:function size:0x138 scope:local __ct__9fLiMgBa_cFv = .text:0x802E2BE0; // type:function size:0x10 -__arraydtor$4110 = .text:0x802E2BF0; // type:function size:0x1C scope:local +fn_802E2BF0 = .text:0x802E2BF0; // type:function size:0x1C scope:local walkPack__11fTrMgPTMF_cFv = .text:0x802E2C10; // type:function size:0x84 searchNodeByProfName__9fTrMgBa_cCFUsPC9fTrNdBa_c = .text:0x802E2CA0; // type:function size:0x68 searchNodeByGroupType__9fTrMgBa_cCFUcPC9fTrNdBa_c = .text:0x802E2D10; // type:function size:0x68 @@ -21678,21 +21678,21 @@ fn_8039B0E0 = .text:0x8039B0E0; // type:function size:0x14 fn_8039B100 = .text:0x8039B100; // type:function size:0x180 fn_8039B280 = .text:0x8039B280; // type:function size:0xA8 fn_8039B330 = .text:0x8039B330; // type:function size:0x64 -fn_8039B3A0 = .text:0x8039B3A0; // type:function size:0x1CC -fn_8039B570 = .text:0x8039B570; // type:function size:0xA0 -fn_8039B610 = .text:0x8039B610; // type:function size:0x2AC -fn_8039B8C0 = .text:0x8039B8C0; // type:function size:0x50 -fn_8039B910 = .text:0x8039B910; // type:function size:0x27C -fn_8039BB90 = .text:0x8039BB90; // type:function size:0x1D0 -fn_8039BD60 = .text:0x8039BD60; // type:function size:0x14 -fn_8039BD80 = .text:0x8039BD80; // type:function size:0x8 -fn_8039BD90 = .text:0x8039BD90; // type:function size:0x8 -fn_8039BDA0 = .text:0x8039BDA0; // type:function size:0x8 -fn_8039BDB0 = .text:0x8039BDB0; // type:function size:0x58 -fn_8039BE10 = .text:0x8039BE10; // type:function size:0x7C -fn_8039BE90 = .text:0x8039BE90; // type:function size:0xBC -fn_8039BF50 = .text:0x8039BF50; // type:function size:0x8 -fn_8039BF60 = .text:0x8039BF60; // type:function size:0x54 +__AI_SRC_INIT = .text:0x8039B3A0; // type:function size:0x1CC +ARCInitHandle = .text:0x8039B570; // type:function size:0xA0 +ARCOpen = .text:0x8039B610; // type:function size:0x2AC +ARCFastOpen = .text:0x8039B8C0; // type:function size:0x50 +ARCConvertPathToEntrynum = .text:0x8039B910; // type:function size:0x27C +entryToPath = .text:0x8039BB90; // type:function size:0x1D0 scope:local +ARCGetStartAddrInMem = .text:0x8039BD60; // type:function size:0x14 +ARCGetStartOffset = .text:0x8039BD80; // type:function size:0x8 +ARCGetLength = .text:0x8039BD90; // type:function size:0x8 +ARCClose = .text:0x8039BDA0; // type:function size:0x8 +ARCChangeDir = .text:0x8039BDB0; // type:function size:0x58 +ARCOpenDir = .text:0x8039BE10; // type:function size:0x7C +ARCReadDir = .text:0x8039BE90; // type:function size:0xBC +ARCCloseDir = .text:0x8039BF50; // type:function size:0x8 +AXInit = .text:0x8039BF60; // type:function size:0x54 fn_8039BFC0 = .text:0x8039BFC0; // type:function size:0x8 fn_8039BFD0 = .text:0x8039BFD0; // type:function size:0x14 fn_8039BFF0 = .text:0x8039BFF0; // type:function size:0xAC @@ -22438,7 +22438,7 @@ DVDConvertPathToEntrynum = .text:0x803C3090; // type:function size:0x308 DVDFastOpen = .text:0x803C33A0; // type:function size:0x68 DVDOpen = .text:0x803C3410; // type:function size:0x120 DVDClose = .text:0x803C3530; // type:function size:0x24 -entryToPath = .text:0x803C3560; // type:function size:0x114 +entryToPath = .text:0x803C3560; // type:function size:0x114 scope:local DVDReadAsyncPrio = .text:0x803C3680; // type:function size:0xD0 cbForReadAsync = .text:0x803C3750; // type:function size:0x18 DVDReadPrio = .text:0x803C3770; // type:function size:0x128 @@ -26088,22 +26088,22 @@ __ct__Q34nw4r3lyt16ResourceAccessorFv = .text:0x80492040; // type:function size: GetFont__Q34nw4r3lyt16ResourceAccessorFPCc = .text:0x80492050; // type:function size:0x8 FindNameResource__37@unnamed@lyt_arcResourceAccessor_cpp@FP9ARCHandlePCc = .text:0x80492060; // type:function size:0xCC GetResourceSub__37@unnamed@lyt_arcResourceAccessor_cpp@FP9ARCHandlePCcUlPCcPUl = .text:0x80492130; // type:function size:0x140 -FUN_80492270 = .text:0x80492270; // type:function size:0x14 -FUN_80492290 = .text:0x80492290; // type:function size:0x40 +__ct__Q34nw4r3lyt11FontRefLinkFv = .text:0x80492270; // type:function size:0x14 +Set__Q34nw4r3lyt11FontRefLinkFPCcPQ34nw4r2ut4Font = .text:0x80492290; // type:function size:0x40 __ct__Q34nw4r3lyt19ArcResourceAccessorFv = .text:0x804922D0; // type:function size:0x54 Attach__Q34nw4r3lyt19ArcResourceAccessorFPvPCc = .text:0x80492330; // type:function size:0x7C Detach__Q34nw4r3lyt19ArcResourceAccessorFv = .text:0x804923B0; // type:function size:0x14 GetResource__Q34nw4r3lyt19ArcResourceAccessorFUlPCcPUl = .text:0x804923D0; // type:function size:0x20 -FUN_804923f0 = .text:0x804923F0; // type:function size:0x6C -FUN_80492460 = .text:0x80492460; // type:function size:0x34 -FUN_804924a0 = .text:0x804924A0; // type:function size:0x8 +Set__Q34nw4r3lyt15ArcResourceLinkFPvPCc = .text:0x804923F0; // type:function size:0x6C +RegistFont__Q34nw4r3lyt19ArcResourceAccessorFPQ34nw4r3lyt11FontRefLink = .text:0x80492460; // type:function size:0x34 +UnregistFont__Q34nw4r3lyt19ArcResourceAccessorFPQ34nw4r3lyt11FontRefLink = .text:0x804924A0; // type:function size:0x8 GetFont__Q34nw4r3lyt19ArcResourceAccessorFPCc = .text:0x804924B0; // type:function size:0x70 -__ct__Q34nw4r3lyt19MultiArcResourceAccessorFv = .text:0x80492520; // type:function size:0x60 -__dt__Q34nw4r3lyt19MultiArcResourceAccessorFv = .text:0x80492580; // type:function size:0x90 -Attach__Q34nw4r3lyt19MultiArcResourceAccessorFPQ34nw4r3lyt16ArcResourceLink_PCc = .text:0x80492610; // type:function size:0x34 -GetResource__Q34nw4r3lyt19MultiArcResourceAccessorFUlPCcPUl = .text:0x80492650; // type:function size:0x78 -RegistFont__Q34nw4r3lyt19MultiArcResourceAccessorFPQ34nw4r3lyt12FontRefLink_ = .text:0x804926D0; // type:function size:0x34 -GetFont__Q34nw4r3lyt19MultiArcResourceAccessorFPCc = .text:0x80492710; // type:function size:0x70 +__ct__Q34nw4r3lyt24MultiArcResourceAccessorFv = .text:0x80492520; // type:function size:0x60 +__dt__Q34nw4r3lyt24MultiArcResourceAccessorFv = .text:0x80492580; // type:function size:0x90 +Attach__Q34nw4r3lyt24MultiArcResourceAccessorFPQ34nw4r3lyt15ArcResourceLink = .text:0x80492610; // type:function size:0x34 +GetResource__Q34nw4r3lyt24MultiArcResourceAccessorFUlPCcPUl = .text:0x80492650; // type:function size:0x78 +RegistFont__Q34nw4r3lyt24MultiArcResourceAccessorFPQ34nw4r3lyt11FontRefLink = .text:0x804926D0; // type:function size:0x34 +GetFont__Q34nw4r3lyt24MultiArcResourceAccessorFPCc = .text:0x80492710; // type:function size:0x70 EqualsResName__Q34nw4r3lyt6detailFPCcPCc = .text:0x80492780; // type:function size:0x2C EqualsMaterialName__Q34nw4r3lyt6detailFPCcPCc = .text:0x804927B0; // type:function size:0x2C TestFileHeader__Q34nw4r3lyt6detailFRCQ44nw4r3lyt3res16BinaryFileHeaderUl = .text:0x804927E0; // type:function size:0x28 @@ -37088,8 +37088,8 @@ lbl_8056E778 = .data:0x8056E778; // type:object size:0x30 lbl_8056E7A8 = .data:0x8056E7A8; // type:object size:0x10 lbl_8056E7B8 = .data:0x8056E7B8; // type:object size:0x28 lbl_8056E7E0 = .data:0x8056E7E0; // type:object size:0x18 -lbl_8056E7F8 = .data:0x8056E7F8; // type:object size:0x14 -lbl_8056E80C = .data:0x8056E80C; // type:object size:0x14 +__vt__Q34nw4r3lyt24MultiArcResourceAccessor = .data:0x8056E7F8; // type:object size:0x14 +__vt__Q34nw4r3lyt19ArcResourceAccessor = .data:0x8056E80C; // type:object size:0x14 lbl_8056E820 = .data:0x8056E820; // type:object size:0x10 lbl_8056E830 = .data:0x8056E830; // type:object size:0x28 lbl_8056E858 = .data:0x8056E858; // type:object size:0x18 @@ -39588,8 +39588,8 @@ lbl_80574EA0 = .sdata:0x80574EA0; // type:object size:0x8 data:4byte lbl_80574EA8 = .sdata:0x80574EA8; // type:object size:0x8 data:4byte lbl_80574EB0 = .sdata:0x80574EB0; // type:object size:0x8 data:4byte lbl_80574EB8 = .sdata:0x80574EB8; // type:object size:0x8 -lbl_80574EC0 = .sdata:0x80574EC0; // type:object size:0x4 -lbl_80574EC4 = .sdata:0x80574EC4; // type:object size:0x4 +lbl_80574EC0 = .sdata:0x80574EC0; // type:object size:0x2 data:string +lbl_80574EC4 = .sdata:0x80574EC4; // type:object size:0x3 data:string lbl_80574EC8 = .sdata:0x80574EC8; // type:object size:0x8 lbl_80574ED0 = .sdata:0x80574ED0; // type:object size:0x8 data:byte lbl_80574ED8 = .sdata:0x80574ED8; // type:object size:0x8 diff --git a/configure.py b/configure.py index 21bb27b7..3247adcc 100644 --- a/configure.py +++ b/configure.py @@ -203,6 +203,7 @@ cflags_nw4r = [ *cflags_base, "-ipa file", "-fp_contract off", + ] # REL flags @@ -248,11 +249,11 @@ def EGGLib(lib_name, objects): } -def nw4rLib(lib_name, objects): +def nw4rLib(lib_name, objects, extra_cflags=[]): return { "lib": lib_name, "mw_version": "Wii/1.1", # most seem to be around 1.2, snd is 1.6 - "cflags": cflags_nw4r, + "cflags": cflags_nw4r + extra_cflags, "host": False, "objects": objects, } @@ -351,8 +352,9 @@ config.libs = [ nw4rLib( "lyt", [ + Object(Matching, "nw4r/lyt/lyt_arcResourceAccessor.cpp"), Object(Matching, "nw4r/lyt/lyt_common.cpp"), - ], + ], [""] ), # EGG EGGLib( diff --git a/include/nw4r/lyt/lyt_arcResourceAccessor.h b/include/nw4r/lyt/lyt_arcResourceAccessor.h index 505639b2..7755e260 100644 --- a/include/nw4r/lyt/lyt_arcResourceAccessor.h +++ b/include/nw4r/lyt/lyt_arcResourceAccessor.h @@ -1,13 +1,15 @@ #ifndef NW4R_LYT_ARC_RESOURCE_ACCESSOR_H #define NW4R_LYT_ARC_RESOURCE_ACCESSOR_H + #include "common.h" -#include "lyt_resourceAccessor.h" +#include "nw4r/lyt/lyt_resourceAccessor.h" #include "nw4r/ut/ut_Font.h" #include "nw4r/ut/ut_LinkList.h" -#include +#include #include -#define FONTNAMEBUF_MAX 127 +#define FONTNAMEBUF_MAX 128 +#define ROOTPATH_MAX 128 namespace nw4r { namespace lyt { @@ -16,7 +18,7 @@ public: FontRefLink(); ~FontRefLink() {} - void Set(const char *, ut::Font *); + void Set(const char *name, ut::Font *pFont); ut::Font *GetFont() const { return mFont; @@ -32,37 +34,61 @@ private: ut::Font *mFont; // at 0x88 }; -class ArcResourceAccessor : public ResourceAccessor { +class ArcResourceLink { public: - ArcResourceAccessor(); - virtual ~ArcResourceAccessor() {} // at 0x8 - virtual UNKTYPE *GetResource(u32, const char *, u32 *); // at 0xC - virtual ut::Font *GetFont(const char *); // at 0x10 + bool Set(void *pFile, const char *name); - bool Attach(void *, const char *); - void *Detach() { - void *old = mArchive; - mArchive = NULL; - - return old; + const char *GetResRootDir() const { + return mResRootDir; } - bool IsAttached() const { - return (mArchive != NULL); - } - - void RegistFont(FontRefLink *pLink) { - mRefList.PushBack(pLink); - } - void UnregistFont(FontRefLink *pLink) { - mRefList.Erase(pLink); + ARCHandle *GetArcHandle() { + return &mArcHandle; } private: - ARCHandle mHandle; // at 0x4 - void *mArchive; // at 0x8 - ut::LinkList mRefList; // at 0x24 - char mRootDir[FONTNAMEBUF_MAX]; // at 0x30 + ut::LinkListNode mLink; // at 0x00 + ARCHandle mArcHandle; // at 0x08 + char mResRootDir[ROOTPATH_MAX]; // at 0x24 +}; + +class ArcResourceAccessor : public ResourceAccessor { +public: + ArcResourceAccessor(); + virtual ~ArcResourceAccessor() {} // at 0x8 + virtual void *GetResource(u32, const char *, u32 *); // at 0xC + virtual ut::Font *GetFont(const char *); // at 0x10 + + bool Attach(void *pFile, const char *name); + void *Detach(); + + bool IsAttached() const { + return (mArcBuf != NULL); + } + + void RegistFont(FontRefLink *pLink); + + void UnregistFont(FontRefLink *pLink); + +private: + ARCHandle mArcHandle; // at 0x4 + void *mArcBuf; // at 0x8 + ut::LinkList mFontList; // at 0x24 + char mResRootDir[ROOTPATH_MAX]; // at 0x30 +}; + +class MultiArcResourceAccessor : ResourceAccessor { +public: + MultiArcResourceAccessor(); + virtual ~MultiArcResourceAccessor(); // at 0x8 + virtual void *GetResource(u32 resType, const char *name, u32 *pSize); // at 0xC + virtual ut::Font *GetFont(const char *); // at 0x10 + + void Attach(ArcResourceLink *pArcResource); + void RegistFont(FontRefLink *pLink); + + ut::LinkList mArcList; // at 0x4 + ut::LinkList mFontList; // at 0x10 }; namespace detail { @@ -76,6 +102,7 @@ static ut::Font *FindFont(ut::LinkList *pList, const char *name) return NULL; } + } // namespace detail } // namespace lyt } // namespace nw4r diff --git a/include/rvl/ARC/arc.h b/include/rvl/ARC/arc.h index 3e012138..11c2eb16 100644 --- a/include/rvl/ARC/arc.h +++ b/include/rvl/ARC/arc.h @@ -81,9 +81,9 @@ typedef struct ARCEntry { typedef struct ARCDirEntry { ARCHandle *handle; // at 0x0 - u32 path_begin; // at 0x4 - u32 path_it; // at 0x8 - u32 path_end; // at 0xC + u32 entryNum; // at 0x4 + BOOL isDir; // at 0x8 + const char *name; // at 0xC } ARCDirEntry; BOOL ARCGetCurrentDir(ARCHandle *handle, char *string, u32 maxlen); @@ -96,9 +96,9 @@ s32 ARCGetStartOffset(ARCFileInfo *info); u32 ARCGetLength(ARCFileInfo *info); BOOL ARCClose(ARCFileInfo *info); BOOL ARCChangeDir(ARCHandle *info, const char *path); -BOOL ARCOpenDir(ARCHandle *info, const char *path, ARCDirEntry *dir); -BOOL ARCReadDir(ARCDirEntry *dir, ARCEntry *entry); -BOOL ARCCloseDir(ARCDirEntry *dir); +BOOL ARCOpenDir(ARCHandle *info, const char *path, ARCDir *dir); +BOOL ARCReadDir(ARCDir *dir, ARCDirEntry *entry); +BOOL ARCCloseDir(ARCDir *dir); #ifdef __cplusplus } diff --git a/src/nw4r/lyt/lyt_arcResourceAccessor.cpp b/src/nw4r/lyt/lyt_arcResourceAccessor.cpp index 5aab3607..89cd84e5 100644 --- a/src/nw4r/lyt/lyt_arcResourceAccessor.cpp +++ b/src/nw4r/lyt/lyt_arcResourceAccessor.cpp @@ -1,197 +1,171 @@ + #include "nw4r/lyt/lyt_arcResourceAccessor.h" #include "nw4r/ut/ut_Font.h" namespace { // FindNameResource__37@unnamed@lyt_arcResourceAccessor_cpp@FP9ARCHandlePCc -s32 FindResourcename(ARCHandle *pArcHandle, const char *resName) { - return 1; +DECOMP_DONT_INLINE s32 FindNameResource(ARCHandle *pArcHandle, const char *resName) { + s32 entryNum = -1; + ARCDir dir; + ARCDirEntry dirEntry; + BOOL bSuccess = ARCOpenDir(pArcHandle, ".", &dir); + + while (ARCReadDir(&dir, &dirEntry)) { + if (dirEntry.isDir) { + ARCChangeDir(pArcHandle, dirEntry.name); + entryNum = FindNameResource(pArcHandle, resName); + ARCChangeDir(pArcHandle, ".."); + + if (entryNum != -1) { + break; + } + } else { + if (stricmp(resName, dirEntry.name) == 0) { + entryNum = dirEntry.entryNum; + break; + } + } + } + bSuccess = ARCCloseDir(&dir); + return entryNum; } // GetResourceSub__37@unnamed@lyt_arcResourceAccessor_cpp@FP9ARCHandlePCcUlPCcPUl -void *GetResourceSub(ARCHandle *pArcHandle, const char *resRootDir, u32 resType, const char *name, u32 *pSize) {} +void *GetResourceSub(ARCHandle *pArcHandle, const char *resRootDir, u32 resType, const char *name, u32 *pSize) { + s32 entryNum = -1; + if (ARCConvertPathToEntrynum(pArcHandle, resRootDir) != -1 && ARCChangeDir(pArcHandle, resRootDir)) { + if (resType == 0) { + entryNum = FindNameResource(pArcHandle, name); + } else { + char resTypeStr[5]; + resTypeStr[0] = resType >> 24; + resTypeStr[1] = resType >> 16; + resTypeStr[2] = resType >> 8; + resTypeStr[3] = resType; + resTypeStr[4] = '\0'; + + if (ARCConvertPathToEntrynum(pArcHandle, resTypeStr) != -1) { + if (ARCChangeDir(pArcHandle, resTypeStr)) { + entryNum = ARCConvertPathToEntrynum(pArcHandle, name); + ARCChangeDir(pArcHandle, ".."); + } + } + } + ARCChangeDir(pArcHandle, ".."); + } + if (entryNum != -1) { + ARCFileInfo arcFileInfo; + ARCFastOpen(pArcHandle, entryNum, &arcFileInfo); + void *resPointer = ARCGetStartAddrInMem(&arcFileInfo); + if (pSize != nullptr) { + *pSize = ARCGetLength(&arcFileInfo); + } + ARCClose(&arcFileInfo); + return resPointer; + } + return nullptr; +} } // namespace namespace nw4r { namespace lyt { // __ct__Q34nw4r3lyt11FontRefLinkFv -FontRefLink::FontRefLink() {} +FontRefLink::FontRefLink() : mFont(nullptr) {} // Set__Q34nw4r3lyt11FontRefLinkFPCcPQ34nw4r2ut4Font -void FontRefLink::Set(const char *name, ut::Font *pFont) {} +void FontRefLink::Set(const char *name, ut::Font *pFont) { + strcpy(this->mFontName, name); + this->mFont = pFont; +} // __ct__Q34nw4r3lyt19ArcResourceAccessorFv -ArcResourceAccessor::ArcResourceAccessor() {} +ArcResourceAccessor::ArcResourceAccessor() : mArcBuf(nullptr) {} // Attach__Q34nw4r3lyt19ArcResourceAccessorFPvPCc bool ArcResourceAccessor::Attach(void *archiveStart, const char *resourceRootDirectory) { - return false; + if (!ARCInitHandle(archiveStart, &this->mArcHandle)) { + return false; + } + this->mArcBuf = archiveStart; + strncpy(this->mResRootDir, resourceRootDirectory, ROOTPATH_MAX - 1); + this->mResRootDir[ROOTPATH_MAX - 1] = '\0'; + return true; } // Detach__Q34nw4r3lyt19ArcResourceAccessorFv +void *ArcResourceAccessor::Detach() { + void *ret = this->mArcBuf; + this->mArcBuf = nullptr; + return ret; +} // GetResource__Q34nw4r3lyt19ArcResourceAccessorFUlPCcPUl +void *ArcResourceAccessor::GetResource(u32 resType, const char *name, u32 *pSize) { + return GetResourceSub(&this->mArcHandle, this->mResRootDir, resType, name, pSize); +} + +// Set__Q34nw4r3lyt15ArcResourceLinkFPvPCc +bool ArcResourceLink::Set(void *pFile, const char *name) { + if (!ARCInitHandle(pFile, &this->mArcHandle)) { + return false; + } + strncpy(this->mResRootDir, name, ROOTPATH_MAX - 1); + this->mResRootDir[ROOTPATH_MAX - 1] = '\0'; + return true; +} // RegistFont__Q34nw4r3lyt19ArcResourceAccessorFPQ34nw4r3lyt11FontRefLink +void ArcResourceAccessor::RegistFont(FontRefLink *pLink) { + mFontList.PushBack(pLink); +} // UnregistFont__Q34nw4r3lyt19ArcResourceAccessorFPQ34nw4r3lyt11FontRefLink +void ArcResourceAccessor::UnregistFont(FontRefLink *pLink) { + mFontList.Erase(pLink); +} // GetFont__Q34nw4r3lyt19ArcResourceAccessorFPCc +ut::Font *ArcResourceAccessor::GetFont(const char *name) { + return detail::FindFont(&this->mFontList, name); +} + +// __ct__Q34nw4r3lyt24MultiArcResourceAccessorFv +MultiArcResourceAccessor::MultiArcResourceAccessor() {} // __dt__Q34nw4r3lyt24MultiArcResourceAccessorFv +MultiArcResourceAccessor::~MultiArcResourceAccessor() { + this->mArcList.Clear(); +} + +// Attach__Q34nw4r3lyt24MultiArcResourceAccessorFPQ34nw4r3lyt15ArcResourceLink +void MultiArcResourceAccessor::Attach(ArcResourceLink *pArcResource) { + this->mArcList.PushBack(pArcResource); +} + +// GetResource__Q34nw4r3lyt24MultiArcResourceAccessorFUlPCcPUl +void *MultiArcResourceAccessor::GetResource(u32 resType, const char *name, u32 *pSize) { + void *pResource; + ut::LinkList::Iterator it = this->mArcList.GetBeginIter(); + for (; it != mArcList.GetEndIter(); it++) { + pResource = GetResourceSub(it->GetArcHandle(), it->GetResRootDir(), resType, name, pSize); + if (pResource != nullptr) { + return pResource; + } + } + + return NULL; +} + +void MultiArcResourceAccessor::RegistFont(FontRefLink *pLink) { + this->mFontList.PushBack(pLink); +} + +// GetFont__Q34nw4r3lyt24MultiArcResourceAccessorFPCc +ut::Font *MultiArcResourceAccessor::GetFont(const char *name) { + return detail::FindFont(&this->mFontList, name); +} } // namespace lyt } // namespace nw4r - -// 29c03b: <88> TAG_global_subroutine -// AT_sibling(0x29c0dc) -// AT_name("Detach") -// AT_lo_user("Detach__Q34nw4r3lyt19ArcResourceAccessorFv") -// AT_member(0x16271) -// AT_fund_type(FT_pointer) -// AT_low_pc(0x802d50c8) -// AT_high_pc(0x802d5158) - -// 29c093: <38> TAG_formal_parameter -// AT_sibling(0x29c0b9) -// AT_name("this") -// AT_mod_u_d_type(<6>MOD_const MOD_pointer_to 0x16271) -// AT_location(<5>OP_REG(0x1f) ) - -// 29c0dc: <105> TAG_global_subroutine -// AT_sibling(0x29c1ec) -// AT_name("GetResource") -// AT_lo_user("GetResource__Q34nw4r3lyt19ArcResourceAccessorFUlPCcPUl") -// AT_member(0x16271) -// AT_fund_type(FT_pointer) -// AT_low_pc(0x802d5158) -// AT_high_pc(0x802d51a4) - -// 29c145: <38> TAG_formal_parameter -// AT_sibling(0x29c16b) -// AT_name("this") -// AT_mod_u_d_type(<6>MOD_const MOD_pointer_to 0x16271) -// AT_location(<5>OP_REG(0x1f) ) - -// 29c16b: <41> TAG_formal_parameter -// AT_sibling(0x29c194) -// AT_name("resType") -// AT_fund_type(FT_unsigned_long) -// AT_location(<11>OP_BASEREG(0x1) OP_CONST(0x8) OP_ADD ) - -// 29c194: <42> TAG_formal_parameter -// AT_sibling(0x29c1be) -// AT_name("name") -// AT_mod_fund_type(<4>MOD_pointer_to MOD_const FT_char) -// AT_location(<11>OP_BASEREG(0x1) OP_CONST(0xc) OP_ADD ) - -// 29c1be: <42> TAG_formal_parameter -// AT_sibling(0x29c1e8) -// AT_name("pSize") -// AT_mod_fund_type(<3>MOD_pointer_to FT_unsigned_long) -// AT_location(<11>OP_BASEREG(0x1) OP_CONST(0x10) OP_ADD ) -// 29c1e8: <4> - -// 29c1ec: <116> TAG_global_subroutine -// AT_sibling(0x29c2b6) -// AT_name("RegistFont") -// AT_lo_user("RegistFont__Q34nw4r3lyt19ArcResourceAccessorFPQ34nw4r3lyt11FontRefLink") -// AT_member(0x16271) -// AT_low_pc(0x802d51a4) -// AT_high_pc(0x802d5228) - -// 29c260: <44> TAG_formal_parameter -// AT_sibling(0x29c28c) -// AT_name("this") -// AT_mod_u_d_type(<6>MOD_const MOD_pointer_to 0x16271) -// AT_location(<11>OP_BASEREG(0x1) OP_CONST(0x8) OP_ADD ) - -// 29c28c: <38> TAG_formal_parameter -// AT_sibling(0x29c2b2) -// AT_name("pLink") -// AT_mod_u_d_type(<5>MOD_pointer_to 0x1613f) -// AT_location(<5>OP_REG(0x1d) ) -// 29c2b2: <4> - -// 29c2b6: <120> TAG_global_subroutine -// AT_sibling(0x29c384) -// AT_name("UnregistFont") -// AT_lo_user("UnregistFont__Q34nw4r3lyt19ArcResourceAccessorFPQ34nw4r3lyt11FontRefLink") -// AT_member(0x16271) -// AT_low_pc(0x802d5228) -// AT_high_pc(0x802d52ac) - -// 29c32e: <44> TAG_formal_parameter -// AT_sibling(0x29c35a) -// AT_name("this") -// AT_mod_u_d_type(<6>MOD_const MOD_pointer_to 0x16271) -// AT_location(<11>OP_BASEREG(0x1) OP_CONST(0x8) OP_ADD ) - -// 29c35a: <38> TAG_formal_parameter -// AT_sibling(0x29c380) -// AT_name("pLink") -// AT_mod_u_d_type(<5>MOD_pointer_to 0x1613f) -// AT_location(<5>OP_REG(0x1d) ) -// 29c380: <4> - -// 29c384: <97> TAG_global_subroutine -// AT_sibling(0x29c43f) -// AT_name("GetFont") -// AT_lo_user("GetFont__Q34nw4r3lyt19ArcResourceAccessorFPCc") -// AT_member(0x16271) -// AT_mod_u_d_type(<5>MOD_pointer_to 0x15c72) -// AT_low_pc(0x802d52ac) -// AT_high_pc(0x802d52e0) - -// 29c3e5: <44> TAG_formal_parameter -// AT_sibling(0x29c411) -// AT_name("this") -// AT_mod_u_d_type(<6>MOD_const MOD_pointer_to 0x16271) -// AT_location(<11>OP_BASEREG(0x1) OP_CONST(0x8) OP_ADD ) - -// 29c411: <42> TAG_formal_parameter -// AT_sibling(0x29c43b) -// AT_name("name") -// AT_mod_fund_type(<4>MOD_pointer_to MOD_const FT_char) -// AT_location(<11>OP_BASEREG(0x1) OP_CONST(0xc) OP_ADD ) -// 29c43b: <4> - -// 29c43f: <95> TAG_global_subroutine -// AT_sibling(0x29c4c8) -// AT_name("__dt") -// AT_lo_user("__dt__Q34nw4r3lyt24MultiArcResourceAccessorFv") -// AT_member(0x63219) -// AT_fund_type(FT_pointer) -// AT_low_pc(0x802d533c) -// AT_high_pc(0x802d53cc) -// (0x29c83e) - -// 29c49e: <38> TAG_formal_parameter -// AT_sibling(0x29c4c4) -// AT_name("this") -// AT_mod_u_d_type(<6>MOD_const MOD_pointer_to 0x63219) -// AT_location(<5>OP_REG(0x1f) ) -// 29c4c4: <4> - -// AT_name("DetachAll") -// AT_lo_user("DetachAll__Q34nw4r3lyt24MultiArcResourceAccessorFv") - -// AT_name("GetResource") -// AT_lo_user("GetResource__Q34nw4r3lyt24MultiArcResourceAccessorFUlPCcPUl") -// AT_fund_type(FT_pointer) -// AT_name("this") -// AT_mod_u_d_type(<6>MOD_const MOD_pointer_to 0x63219) -// AT_name("resType") -// AT_fund_type(FT_unsigned_long) -// AT_name("name") -// AT_mod_fund_type(<4>MOD_pointer_to MOD_const FT_char) -// AT_name("pSize") -// AT_mod_fund_type(<3>MOD_pointer_to FT_unsigned_long) - -// AT_lo_user("GetFont__Q34nw4r3lyt24MultiArcResourceAccessorFPCc") -// AT_name("name") -// AT_mod_fund_type(<4>MOD_pointer_to MOD_const FT_char) - -// "__vt__Q34nw4r3lyt24MultiArcResourceAccessor" -// "__vt__Q34nw4r3lyt19ArcResourceAccessor"