From b7dca5d5a8709b1560495cb50f7e58ac5750beb7 Mon Sep 17 00:00:00 2001 From: Adam Bird Date: Mon, 3 Jul 2023 10:29:06 -0400 Subject: [PATCH] Fix: Various PAL1.1 asset offsets and Main Menu options screen (#3045) * fix pal11 ganondorf falling platform offsets * fix pal11 dins fire offsets * add game region and platform methods * fix pal11 file menu options * move --- .../overlays/ovl_Bg_Ganon_Otyuka.xml | 6 +-- .../N64_PAL_11/overlays/ovl_File_Choose.xml | 17 ++++--- .../N64_PAL_11/overlays/ovl_Magic_Fire.xml | 10 ++-- soh/soh/OTRGlobals.cpp | 46 +++++++++++++++++++ soh/soh/OTRGlobals.h | 8 ++++ .../ovl_file_choose/z_file_nameset_PAL.c | 37 +++++++++++++-- 6 files changed, 104 insertions(+), 20 deletions(-) diff --git a/soh/assets/xml/N64_PAL_11/overlays/ovl_Bg_Ganon_Otyuka.xml b/soh/assets/xml/N64_PAL_11/overlays/ovl_Bg_Ganon_Otyuka.xml index 5bba7f35b..99d32f6e6 100644 --- a/soh/assets/xml/N64_PAL_11/overlays/ovl_Bg_Ganon_Otyuka.xml +++ b/soh/assets/xml/N64_PAL_11/overlays/ovl_Bg_Ganon_Otyuka.xml @@ -1,8 +1,8 @@ - - + + - + diff --git a/soh/assets/xml/N64_PAL_11/overlays/ovl_File_Choose.xml b/soh/assets/xml/N64_PAL_11/overlays/ovl_File_Choose.xml index 55c8779e4..de41882eb 100644 --- a/soh/assets/xml/N64_PAL_11/overlays/ovl_File_Choose.xml +++ b/soh/assets/xml/N64_PAL_11/overlays/ovl_File_Choose.xml @@ -3,18 +3,20 @@ - + + - + + + - + @@ -24,5 +26,6 @@ + diff --git a/soh/assets/xml/N64_PAL_11/overlays/ovl_Magic_Fire.xml b/soh/assets/xml/N64_PAL_11/overlays/ovl_Magic_Fire.xml index b5b7ba82d..0164ab203 100644 --- a/soh/assets/xml/N64_PAL_11/overlays/ovl_Magic_Fire.xml +++ b/soh/assets/xml/N64_PAL_11/overlays/ovl_Magic_Fire.xml @@ -1,10 +1,10 @@ - - - + + + - - + + diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index b044c0533..9c48d7c77 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -1030,6 +1030,52 @@ extern "C" uint32_t ResourceMgr_GetGameVersion(int index) { return LUS::Context::GetInstance()->GetResourceManager()->GetArchive()->GetGameVersions()[index]; } +extern "C" uint32_t ResourceMgr_GetGamePlatform(int index) { + uint32_t version = LUS::Context::GetInstance()->GetResourceManager()->GetArchive()->GetGameVersions()[index]; + + switch (version) { + case OOT_NTSC_US_10: + case OOT_NTSC_US_11: + case OOT_NTSC_US_12: + case OOT_PAL_10: + case OOT_PAL_11: + return GAME_PLATFORM_N64; + case OOT_NTSC_JP_GC: + case OOT_NTSC_US_GC: + case OOT_PAL_GC: + case OOT_NTSC_JP_MQ: + case OOT_NTSC_US_MQ: + case OOT_PAL_MQ: + case OOT_PAL_GC_DBG1: + case OOT_PAL_GC_DBG2: + case OOT_PAL_GC_MQ_DBG: + return GAME_PLATFORM_GC; + } +} + +extern "C" uint32_t ResourceMgr_GetGameRegion(int index) { + uint32_t version = LUS::Context::GetInstance()->GetResourceManager()->GetArchive()->GetGameVersions()[index]; + + switch (version) { + case OOT_NTSC_US_10: + case OOT_NTSC_US_11: + case OOT_NTSC_US_12: + case OOT_NTSC_JP_GC: + case OOT_NTSC_US_GC: + case OOT_NTSC_JP_MQ: + case OOT_NTSC_US_MQ: + return GAME_REGION_NTSC; + case OOT_PAL_10: + case OOT_PAL_11: + case OOT_PAL_GC: + case OOT_PAL_MQ: + case OOT_PAL_GC_DBG1: + case OOT_PAL_GC_DBG2: + case OOT_PAL_GC_MQ_DBG: + return GAME_REGION_PAL; + } +} + uint32_t IsSceneMasterQuest(s16 sceneNum) { uint32_t value = 0; uint8_t mqMode = CVarGetInteger("gBetterDebugWarpScreenMQMode", WARP_MODE_OVERRIDE_OFF); diff --git a/soh/soh/OTRGlobals.h b/soh/soh/OTRGlobals.h index 05ea04e12..329f4f0bf 100644 --- a/soh/soh/OTRGlobals.h +++ b/soh/soh/OTRGlobals.h @@ -6,6 +6,12 @@ #include "SaveManager.h" #include +#define GAME_REGION_NTSC 0 +#define GAME_REGION_PAL 1 + +#define GAME_PLATFORM_N64 0 +#define GAME_PLATFORM_GC 1 + #ifdef __cplusplus #include #include "Enhancements/savestates.h" @@ -59,6 +65,8 @@ uint32_t ResourceMgr_GameHasMasterQuest(); uint32_t ResourceMgr_GameHasOriginal(); uint32_t ResourceMgr_GetNumGameVersions(); uint32_t ResourceMgr_GetGameVersion(int index); +uint32_t ResourceMgr_GetGamePlatform(int index); +uint32_t ResourceMgr_GetGameRegion(int index); void ResourceMgr_LoadDirectory(const char* resName); char** ResourceMgr_ListFiles(const char* searchMask, int* resultSize); uint8_t ResourceMgr_FileExists(const char* resName); diff --git a/soh/src/overlays/gamestates/ovl_file_choose/z_file_nameset_PAL.c b/soh/src/overlays/gamestates/ovl_file_choose/z_file_nameset_PAL.c index 17d63fb0d..3aca1ee8c 100644 --- a/soh/src/overlays/gamestates/ovl_file_choose/z_file_nameset_PAL.c +++ b/soh/src/overlays/gamestates/ovl_file_choose/z_file_nameset_PAL.c @@ -909,7 +909,13 @@ void FileChoose_DrawOptionsImpl(GameState* thisx) { } } - if (gSaveContext.language == LANGUAGE_GER) { + uint8_t versionIndex = ResourceMgr_GameHasMasterQuest() && ResourceMgr_GameHasOriginal(); + uint8_t isPalN64 = ResourceMgr_GetGameRegion(versionIndex) == GAME_REGION_PAL && + ResourceMgr_GetGamePlatform(versionIndex) == GAME_PLATFORM_N64; + uint8_t isPalGC = ResourceMgr_GetGameRegion(versionIndex) == GAME_REGION_PAL && + ResourceMgr_GetGamePlatform(versionIndex) == GAME_PLATFORM_GC; + + if (gSaveContext.language == LANGUAGE_GER && isPalGC) { gSPVertex(POLY_OPA_DISP++, D_80811E30, 32, 0); } else { gSPVertex(POLY_OPA_DISP++, D_80811D30, 32, 0); @@ -926,13 +932,24 @@ void FileChoose_DrawOptionsImpl(GameState* thisx) { G_IM_SIZ_8b, gOptionsMenuHeaders[i].width[gSaveContext.language], gOptionsMenuHeaders[i].height, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); - gSP1Quadrangle(POLY_OPA_DISP++, vtx, vtx + 2, vtx + 3, vtx + 1, 0); + + if (i == 2 && gSaveContext.language == LANGUAGE_GER && isPalN64) { + // Pal N64 German vertex for Z target header are offset by 12 vertices + gSP1Quadrangle(POLY_OPA_DISP++, vtx + 12, vtx + 2 + 12, vtx + 3 + 12, vtx + 1 + 12, 0); + } else { + gSP1Quadrangle(POLY_OPA_DISP++, vtx, vtx + 2, vtx + 3, vtx + 1, 0); + } } - if (gSaveContext.language == LANGUAGE_GER) { + if (gSaveContext.language == LANGUAGE_GER && isPalGC) { gSPVertex(POLY_OPA_DISP++, D_80812130, 32, 0); } else { - gSPVertex(POLY_OPA_DISP++, D_80811F30, 32, 0); + // PAL N64 has extra german vertices combined in the regular array instead of a dedicated array + if (isPalN64) { + gSPVertex(POLY_OPA_DISP++, D_80811F30, 40, 0); + } else { + gSPVertex(POLY_OPA_DISP++, D_80811F30, 32, 0); + } } for (i = 0, vtx = 0; i < 4; i++, vtx += 4) { @@ -979,7 +996,17 @@ void FileChoose_DrawOptionsImpl(GameState* thisx) { G_IM_SIZ_8b, gOptionsMenuSettings[i].width[gSaveContext.language], gOptionsMenuSettings[i].height, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); - gSP1Quadrangle(POLY_OPA_DISP++, vtx, vtx + 2, vtx + 3, vtx + 1, 0); + // Pal N64 German vertices for z target options are offset an by 8 + if (gSaveContext.language == LANGUAGE_GER && isPalN64) { + gSP1Quadrangle(POLY_OPA_DISP++, vtx + 8, vtx + 2 + 8, vtx + 3 + 8, vtx + 1 + 8, 0); + } else { + gSP1Quadrangle(POLY_OPA_DISP++, vtx, vtx + 2, vtx + 3, vtx + 1, 0); + } + } + + // Pal N64 needs to skip over the extra german vertices to get to brightness vertices + if (isPalN64) { + vtx += 8; } gDPPipeSync(POLY_OPA_DISP++);