From a309f2e45fc90616f44e210eb6fdc15dd60875cb Mon Sep 17 00:00:00 2001 From: Steven Casper Date: Thu, 4 Jul 2024 19:57:41 -0400 Subject: [PATCH 1/3] Compile nonmatching funcs and fix some incorrect symbol visibility --- src/SB/Core/x/xstransvc.cpp | 65 ++++++++++++++++++++++--------------- src/SB/Core/x/xstransvc.h | 15 +-------- 2 files changed, 39 insertions(+), 41 deletions(-) diff --git a/src/SB/Core/x/xstransvc.cpp b/src/SB/Core/x/xstransvc.cpp index f4e1de187..24a71149e 100644 --- a/src/SB/Core/x/xstransvc.cpp +++ b/src/SB/Core/x/xstransvc.cpp @@ -8,11 +8,24 @@ #include "iTRC.h" #include "iFile.h" -// extern st_PKR_ASSET_TOCINFO lbl_80253EC8; -st_STRAN_DATA g_xstdata = {}; -int32 g_straninit; -st_PACKER_READ_FUNCS* g_pkrf; -st_PACKER_ASSETTYPE* g_typeHandlers; +static st_STRAN_DATA g_xstdata = {}; +static int32 g_straninit; +static st_PACKER_READ_FUNCS* g_pkrf; +static st_PACKER_ASSETTYPE* g_typeHandlers; + +static st_STRAN_SCENE* XST_lock_next(); +static void XST_unlock_all(); +static int32 XST_cnt_locked(); +static int32 XST_PreLoadScene(st_STRAN_SCENE* sdata, const int8* path); +static int8* XST_translate_sid(uint32 sid, int8* extension); +static int8* XST_translate_sid_path(uint32 sid, int8* extension); +static st_STRAN_SCENE* XST_find_bySID(uint32 sid, int32 findTheHOP); +static void XST_reset_raw(); +static void XST_unlock(st_STRAN_SCENE* sdata); +static void XST_unlock_all(); +static st_STRAN_SCENE* XST_get_rawinst(int32 index); +static int32 XST_cnt_locked(); +static st_STRAN_SCENE* XST_nth_locked(int32 index); int32 xSTStartup(st_PACKER_ASSETTYPE* handlers) { @@ -422,9 +435,8 @@ int8* xST_xAssetID_HIPFullPath(uint32 aid, uint32* sceneID) return id; } -#ifdef NON_MATCHING // register crap -int32 XST_PreLoadScene(st_STRAN_SCENE* sdata, const int8* name) +static int32 XST_PreLoadScene(st_STRAN_SCENE* sdata, const int8* name) { int32 buf = 0; st_PACKER_READ_DATA* spkg = g_pkrf->Init(sdata->userdata, name, 0x2e, &buf, g_typeHandlers); @@ -435,32 +447,31 @@ int32 XST_PreLoadScene(st_STRAN_SCENE* sdata, const int8* name) } return NULL; } -#endif -int8* XST_translate_sid(uint32 sid, int8* extension) +static int8* XST_translate_sid(uint32 sid, int8* extension) { - static int8 buffer[0x40] = {}; - sprintf(buffer, "%s%s", xUtil_idtag2string(sid, 0), extension); - return buffer; + static int8 fname[0x40] = {}; + sprintf(fname, "%s%s", xUtil_idtag2string(sid, 0), extension); + return fname; } -int8* XST_translate_sid_path(uint32 sid, int8* extension) +static int8* XST_translate_sid_path(uint32 sid, int8* extension) { // NOTE: This buffer extends for 0x44 bytes in the rom // However, I think that's most likely padding for the jumptable that occurs afterwards - static int8 buffer[0x40] = {}; + static int8 fname[0x40] = {}; int8 pathSeparator[2] = "/"; - sprintf(buffer, "%c%c%s%s%s", *xUtil_idtag2string(sid, 0), *(xUtil_idtag2string(sid, 0) + 1), + sprintf(fname, "%c%c%s%s%s", *xUtil_idtag2string(sid, 0), *(xUtil_idtag2string(sid, 0) + 1), pathSeparator, xUtil_idtag2string(sid, 0), extension); - return buffer; + return fname; } -void XST_reset_raw() +static void XST_reset_raw() { memset(&g_xstdata, 0, sizeof(st_STRAN_DATA)); } -st_STRAN_SCENE* XST_lock_next() +static st_STRAN_SCENE* XST_lock_next() { st_STRAN_SCENE* sdata = NULL; int32 uselock = -1; @@ -484,8 +495,7 @@ st_STRAN_SCENE* XST_lock_next() return sdata; } -#ifdef NON_MATCHING -void XST_unlock(st_STRAN_SCENE* sdata) +static void XST_unlock(st_STRAN_SCENE* sdata) { if (sdata != NULL) { @@ -493,14 +503,15 @@ void XST_unlock(st_STRAN_SCENE* sdata) { // Can't figure out how to get the andc instruction instead of two instructions // Seems to only generate andc if I remove the memset call. + // NOTE (Square): pulling 1 << sdata->lockid into a temp variable works but + // causes regswaps. g_xstdata.loadlock &= ~(1 << sdata->lockid); memset(sdata, 0, sizeof(st_STRAN_SCENE)); } } } -#endif -void XST_unlock_all() +static void XST_unlock_all() { if (g_xstdata.loadlock) { @@ -514,12 +525,12 @@ void XST_unlock_all() } } -st_STRAN_SCENE* XST_get_rawinst(int32 index) +static st_STRAN_SCENE* XST_get_rawinst(int32 index) { return &g_xstdata.hipscn[index]; } -int32 XST_cnt_locked() +static int32 XST_cnt_locked() { int32 sum = 0; for (int i = 0; i < 16; i++) @@ -532,7 +543,7 @@ int32 XST_cnt_locked() return sum; } -st_STRAN_SCENE* XST_nth_locked(int32 index) +static st_STRAN_SCENE* XST_nth_locked(int32 index) { st_STRAN_SCENE* sdata = NULL; int32 cnt = 0; @@ -552,7 +563,7 @@ st_STRAN_SCENE* XST_nth_locked(int32 index) return sdata; } -st_STRAN_SCENE* XST_find_bySID(uint32 sid, int32 findTheHOP) +static st_STRAN_SCENE* XST_find_bySID(uint32 sid, int32 findTheHOP) { st_STRAN_SCENE* da_sdata = NULL; @@ -571,6 +582,6 @@ st_STRAN_SCENE* XST_find_bySID(uint32 sid, int32 findTheHOP) return da_sdata; } -void iFileAsyncService() +WEAK void iFileAsyncService() { } diff --git a/src/SB/Core/x/xstransvc.h b/src/SB/Core/x/xstransvc.h index c39d8b8e2..4db41260d 100644 --- a/src/SB/Core/x/xstransvc.h +++ b/src/SB/Core/x/xstransvc.h @@ -13,7 +13,6 @@ struct st_STRAN_SCENE int8 fnam[256]; }; -st_STRAN_SCENE* XST_find_bySID(uint32 sid, int32 findTheHOP); struct st_STRAN_DATA { @@ -22,7 +21,6 @@ struct st_STRAN_DATA }; int32 xSTPreLoadScene(uint32 sid, void* userdata, int32 flg_hiphop); -st_STRAN_SCENE* XST_lock_next(); int32 xSTQueueSceneAssets(uint32 sid, int32 flg_hiphop); void xSTUnLoadScene(uint32 sid, int32 flg_hiphop); float32 xSTLoadStep(uint32); @@ -36,19 +34,8 @@ char* xSTAssetName(void* raw_HIP_asset); int32 xSTGetAssetInfo(uint32 aid, st_PKR_ASSET_TOCINFO* tocainfo); int32 xSTGetAssetInfoByType(uint32 type, int32 idx, st_PKR_ASSET_TOCINFO* ainfo); char* xST_xAssetID_HIPFullPath(uint32 aid); -void XST_unlock_all(); int32 PKRShutdown(); int8* xST_xAssetID_HIPFullPath(uint32 aid, uint32* sceneID); -int32 XST_cnt_locked(); int32 xSTShutdown(); -int32 XST_PreLoadScene(st_STRAN_SCENE* sdata, const int8* path); -int8* XST_translate_sid(uint32 sid, int8* extension); -int8* XST_translate_sid_path(uint32 sid, int8* extension); -void XST_reset_raw(); -void XST_unlock(st_STRAN_SCENE* sdata); -void XST_unlock_all(); -st_STRAN_SCENE* XST_get_rawinst(int32 index); -int32 XST_cnt_locked(); -st_STRAN_SCENE* XST_nth_locked(int32 index); -#endif \ No newline at end of file +#endif From 291fe09b786ea216baf188e80e5f28f074fa8050 Mon Sep 17 00:00:00 2001 From: Steven Casper Date: Thu, 4 Jul 2024 22:05:26 -0400 Subject: [PATCH 2/3] xSTGetAssetInfoByType equivalent --- src/SB/Core/x/xstransvc.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/SB/Core/x/xstransvc.cpp b/src/SB/Core/x/xstransvc.cpp index 24a71149e..6b3867423 100644 --- a/src/SB/Core/x/xstransvc.cpp +++ b/src/SB/Core/x/xstransvc.cpp @@ -355,15 +355,14 @@ int32 xSTGetAssetInfo(uint32 aid, st_PKR_ASSET_TOCINFO* tocainfo) return rc; } -#if 0 -// WIP +// Equivalent: scheduling is off with the copy of tocinfo to ainfo int32 xSTGetAssetInfoByType(uint32 type, int32 idx, st_PKR_ASSET_TOCINFO* ainfo) { int32 rc = 0; + int32 sum = 0; const st_PKR_ASSET_TOCINFO tocinfo = { 0, NULL, 0, 0, 0, NULL }; memset(ainfo, 0, sizeof(st_PKR_ASSET_TOCINFO)); - int32 sum = 0; int32 found = XST_cnt_locked(); for (int32 i = 0; i < found; i++) { @@ -372,7 +371,7 @@ int32 xSTGetAssetInfoByType(uint32 type, int32 idx, st_PKR_ASSET_TOCINFO* ainfo) if (idx >= sum && idx < sum + cnt) { g_pkrf->GetBaseSector(sdata->spkg); - if (g_pkrf->GetAssetInfoByType(sdata->spkg, type, idx - cnt, &tocinfo) != 0) + if (g_pkrf->GetAssetInfoByType(sdata->spkg, type, idx - sum, &tocinfo) != 0) { ainfo->aid = tocinfo.aid; ainfo->sector = tocinfo.sector; @@ -383,11 +382,11 @@ int32 xSTGetAssetInfoByType(uint32 type, int32 idx, st_PKR_ASSET_TOCINFO* ainfo) break; } } + sum += cnt; } return rc; } -#endif int32 xSTGetAssetInfoInHxP(uint32 aid, st_PKR_ASSET_TOCINFO* ainfo, uint32 j) { From 14dde200b032daca343c9721fa5bb81f3ea829f7 Mon Sep 17 00:00:00 2001 From: Steven Casper Date: Thu, 4 Jul 2024 22:50:28 -0400 Subject: [PATCH 3/3] Mark xstransvc equivalent --- configure.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.py b/configure.py index f3dabd757..858377121 100644 --- a/configure.py +++ b/configure.py @@ -329,7 +329,7 @@ def Rel(lib_name: str, objects: List[Object]) -> Dict[str, Any]: Object(NonMatching, "SB/Core/x/xShadow.cpp"), Object(NonMatching, "SB/Core/x/xSnd.cpp"), Object(NonMatching, "SB/Core/x/xSpline.cpp"), - Object(NonMatching, "SB/Core/x/xstransvc.cpp"), + Object(Equivalent, "SB/Core/x/xstransvc.cpp"), Object(NonMatching, "SB/Core/x/xString.cpp"), Object(Matching, "SB/Core/x/xSurface.cpp"), Object(NonMatching, "SB/Core/x/xTimer.cpp"),