diff --git a/soh/soh/GbiWrap.cpp b/soh/soh/GbiWrap.cpp index cf33ed547..a63fa8fe7 100644 --- a/soh/soh/GbiWrap.cpp +++ b/soh/soh/GbiWrap.cpp @@ -83,9 +83,12 @@ extern "C" void gSPVertex(Gfx* pkt, uintptr_t v, int n, int v0) { extern "C" void gSPInvalidateTexCache(Gfx* pkt, uintptr_t texAddr) { char* imgData = (char*)texAddr; - - if (texAddr != 0 && ResourceMgr_OTRSigCheck(imgData)) - texAddr = (uintptr_t)ResourceMgr_LoadTexByName(imgData); + + if (texAddr != 0 && ResourceMgr_OTRSigCheck(imgData)) { + // Temporary solution to the mq/nonmq issue, this will be + // handled better with LUS 1.0 + texAddr = (uintptr_t)ResourceMgr_LoadTexOrDListByName(imgData); + } __gSPInvalidateTexCache(pkt, texAddr); } \ No newline at end of file diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 0e698f999..a0fe66a2e 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -724,29 +724,19 @@ extern "C" char** ResourceMgr_ListFiles(const char* searchMask, int* resultSize) return result; } -std::string GetName(const char* path) { - std::string Path = path; - if (IsGameMasterQuest()) { - size_t pos = 0; - if ((pos = Path.find("/nonmq/", 0)) != std::string::npos) { - Path.replace(pos, 7, "/mq/"); - } - } - return Path; -} - -extern "C" const char* ResourceMgr_GetName(const char* path) { - auto s = new std::string(GetName(path)); - const char* name = s->c_str(); - return name; -} - extern "C" void ResourceMgr_LoadFile(const char* resName) { OTRGlobals::Instance->context->GetResourceManager()->LoadResource(resName); } std::shared_ptr ResourceMgr_LoadResource(const char* path) { - return OTRGlobals::Instance->context->GetResourceManager()->LoadResource(ResourceMgr_GetName(path)); + std::string Path = path; + if (ResourceMgr_IsGameMasterQuest()) { + size_t pos = 0; + if ((pos = Path.find("/nonmq/", 0)) != std::string::npos) { + Path.replace(pos, 7, "/mq/"); + } + } + return OTRGlobals::Instance->context->GetResourceManager()->LoadResource(Path.c_str()); } extern "C" char* ResourceMgr_LoadFileRaw(const char* resName) { @@ -821,7 +811,14 @@ extern "C" char* ResourceMgr_LoadTexOrDListByName(const char* filePath) { else if (res->ResType == Ship::ResourceType::Array) return (char*)(std::static_pointer_cast(res))->vertices.data(); else { - return ResourceMgr_LoadTexByName(ResourceMgr_GetName(filePath)); + std::string Path = filePath; + if (ResourceMgr_IsGameMasterQuest()) { + size_t pos = 0; + if ((pos = Path.find("/nonmq/", 0)) != std::string::npos) { + Path.replace(pos, 7, "/mq/"); + } + } + return ResourceMgr_LoadTexByName(Path.c_str()); } } diff --git a/soh/soh/OTRGlobals.h b/soh/soh/OTRGlobals.h index 09435f5f6..51744dfb4 100644 --- a/soh/soh/OTRGlobals.h +++ b/soh/soh/OTRGlobals.h @@ -37,7 +37,6 @@ private: }; uint32_t IsGameMasterQuest(); -std::string GetName(const char* path); #endif #ifndef __cplusplus @@ -60,7 +59,6 @@ uint32_t ResourceMgr_GetNumGameVersions(); uint32_t ResourceMgr_GetGameVersion(int index); void ResourceMgr_CacheDirectory(const char* resName); char** ResourceMgr_ListFiles(const char* searchMask, int* resultSize); -const char* ResourceMgr_GetName(const char* path); void ResourceMgr_LoadFile(const char* resName); char* ResourceMgr_LoadFileFromDisk(const char* filePath); char* ResourceMgr_LoadJPEG(char* data, int dataSize); diff --git a/soh/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c b/soh/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c index 8f42c8d7a..e486e1218 100644 --- a/soh/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c +++ b/soh/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c @@ -1703,10 +1703,7 @@ void BossDodongo_DrawEffects(PlayState* play) { Gfx_SetupDL_25Xlu(play->state.gfxCtx); unkMtx = &play->billboardMtxF; - // OTRTODO: This call causes the whole texture cache to be cleaned up, which causes an important slowdown on switch so we need to find a way to avoid it. -#if !defined(__SWITCH__) && !defined(__WIIU__) - gSPInvalidateTexCache(POLY_XLU_DISP++, 0); -#endif + gSPInvalidateTexCache(POLY_XLU_DISP++, gDodongosCavernBossLavaFloorTex); for (i = 0; i < 80; i++, eff++) { FrameInterpolation_RecordOpenChild(eff, eff->epoch); diff --git a/soh/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c b/soh/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c index 7e08cbb0f..6fa26bab2 100644 --- a/soh/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c +++ b/soh/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c @@ -1197,8 +1197,10 @@ void BossGanon_SetupTowerCutscene(BossGanon* this, PlayState* play) { void BossGanon_ShatterWindows(u8 windowShatterState) { s16 i; - u8* tex1 = ResourceMgr_LoadTexByName(SEGMENTED_TO_VIRTUAL(ResourceMgr_GetName(ganon_boss_sceneTex_006C18))); - u8* tex2 = ResourceMgr_LoadTexByName(SEGMENTED_TO_VIRTUAL(ResourceMgr_GetName(ganon_boss_sceneTex_007418))); + // Temporary solution: using LoadTexOrDList to ensure we actually have the texture available + // based on mq/nonmq. This will be handled properly with LUS 1.0 + u8* tex1 = ResourceMgr_LoadTexOrDListByName(SEGMENTED_TO_VIRTUAL(ganon_boss_sceneTex_006C18)); + u8* tex2 = ResourceMgr_LoadTexOrDListByName(SEGMENTED_TO_VIRTUAL(ganon_boss_sceneTex_007418)); u8* templateTex = ResourceMgr_LoadTexByName(SEGMENTED_TO_VIRTUAL(gGanondorfWindowShatterTemplateTex)); for (i = 0; i < 2048; i++) { @@ -3820,8 +3822,8 @@ void BossGanon_Draw(Actor* thisx, PlayState* play) { // Invalidate textures if they have changed if (this->windowShatterState != GDF_WINDOW_SHATTER_OFF) { - gSPInvalidateTexCache(POLY_OPA_DISP++, ResourceMgr_GetName(ganon_boss_sceneTex_006C18)); - gSPInvalidateTexCache(POLY_OPA_DISP++, ResourceMgr_GetName(ganon_boss_sceneTex_007418)); + gSPInvalidateTexCache(POLY_OPA_DISP++, ganon_boss_sceneTex_006C18); + gSPInvalidateTexCache(POLY_OPA_DISP++, ganon_boss_sceneTex_007418); } Gfx_SetupDL_25Opa(play->state.gfxCtx);