From 52a1c2f9694a45f42397121ab52d62662b82a045 Mon Sep 17 00:00:00 2001 From: cadmic Date: Mon, 23 Sep 2024 17:13:09 -0700 Subject: [PATCH] [PAL N64] Miscellaneous changes (#2211) * [PAL N64] Miscellaneous changes * Reword comment Co-authored-by: fig02 * glitch -> Glitch --------- Co-authored-by: fig02 --- src/audio/lib/load.c | 14 +++++++++-- src/code/z_play.c | 4 +++- src/code/z_scene.c | 23 +++++++++++++------ .../misc/ovl_kaleido_scope/z_kaleido_map.c | 7 ++++++ .../misc/ovl_kaleido_scope/z_kaleido_scope.c | 3 ++- 5 files changed, 40 insertions(+), 11 deletions(-) diff --git a/src/audio/lib/load.c b/src/audio/lib/load.c index be87f5c457..99217c61fc 100644 --- a/src/audio/lib/load.c +++ b/src/audio/lib/load.c @@ -1,5 +1,6 @@ #include "ultra64.h" #include "global.h" +#include "versions.h" #define MK_ASYNC_MSG(retData, tableType, id, loadStatus) \ (((retData) << 24) | ((tableType) << 16) | ((id) << 8) | (loadStatus)) @@ -1149,6 +1150,7 @@ void AudioLoad_Init(void* heap, u32 heapSize) { } // 1000 is a conversion from seconds to milliseconds +#if !OOT_PAL_N64 switch (osTvType) { case OS_TV_PAL: gAudioCtx.maxTempoTvTypeFactors = 1000 * REFRESH_RATE_DEVIATION_PAL / REFRESH_RATE_PAL; @@ -1166,6 +1168,15 @@ void AudioLoad_Init(void* heap, u32 heapSize) { gAudioCtx.refreshRate = REFRESH_RATE_NTSC; break; } +#else + switch (osTvType) { + case OS_TV_PAL: + default: + gAudioCtx.maxTempoTvTypeFactors = 1000 * REFRESH_RATE_DEVIATION_PAL / REFRESH_RATE_PAL; + gAudioCtx.refreshRate = REFRESH_RATE_PAL; + break; + } +#endif AudioThread_InitMesgQueues(); @@ -1195,8 +1206,7 @@ void AudioLoad_Init(void* heap, u32 heapSize) { gAudioCtx.audioHeap = gAudioHeap; gAudioCtx.audioHeapSize = gAudioHeapInitSizes.heapSize; } else { - void** hp = &heap; - gAudioCtx.audioHeap = *hp; + gAudioCtx.audioHeap = heap; gAudioCtx.audioHeapSize = heapSize; } diff --git a/src/code/z_play.c b/src/code/z_play.c index 99bb024681..dc61dd25f9 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -176,8 +176,10 @@ void Play_SetupTransition(PlayState* this, s32 transitionType) { break; default: -#if PLATFORM_N64 +#if OOT_VERSION < PAL_1_1 HUNGUP_AND_CRASH("../z_play.c", 2269); +#elif OOT_VERSION < GC_JP + HUNGUP_AND_CRASH("../z_play.c", 2272); #elif OOT_VERSION < GC_EU_MQ_DBG HUNGUP_AND_CRASH("../z_play.c", 2287); #elif OOT_VERSION < GC_JP_CE diff --git a/src/code/z_scene.c b/src/code/z_scene.c index f72c06cada..44ad2f9bba 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -45,6 +45,15 @@ s32 Object_SpawnPersistent(ObjectContext* objectCtx, s16 objectId) { return objectCtx->numEntries - 1; } +// PAL N64 versions reduce the size of object space by 4 KiB in order to give some space back to +// the Zelda arena, which can help prevent an issue where actors fail to spawn in specific areas +// (sometimes referred to as the "Hyrule Field Glitch" although it can happen in more places than Hyrule Field). +#if !OOT_PAL_N64 +#define OBJECT_SPACE_ADJUSTMENT 0 +#else +#define OBJECT_SPACE_ADJUSTMENT (4 * 1024) +#endif + void Object_InitContext(PlayState* play, ObjectContext* objectCtx) { PlayState* play2 = play; s32 pad; @@ -52,21 +61,21 @@ void Object_InitContext(PlayState* play, ObjectContext* objectCtx) { s32 i; if (play2->sceneId == SCENE_HYRULE_FIELD) { - spaceSize = 1000 * 1024; + spaceSize = 1000 * 1024 - OBJECT_SPACE_ADJUSTMENT; } else if (play2->sceneId == SCENE_GANON_BOSS) { if (gSaveContext.sceneLayer != 4) { - spaceSize = 1150 * 1024; + spaceSize = 1150 * 1024 - OBJECT_SPACE_ADJUSTMENT; } else { - spaceSize = 1000 * 1024; + spaceSize = 1000 * 1024 - OBJECT_SPACE_ADJUSTMENT; } } else if (play2->sceneId == SCENE_SPIRIT_TEMPLE_BOSS) { - spaceSize = 1050 * 1024; + spaceSize = 1050 * 1024 - OBJECT_SPACE_ADJUSTMENT; } else if (play2->sceneId == SCENE_CHAMBER_OF_THE_SAGES) { - spaceSize = 1050 * 1024; + spaceSize = 1050 * 1024 - OBJECT_SPACE_ADJUSTMENT; } else if (play2->sceneId == SCENE_GANONDORF_BOSS) { - spaceSize = 1050 * 1024; + spaceSize = 1050 * 1024 - OBJECT_SPACE_ADJUSTMENT; } else { - spaceSize = 1000 * 1024; + spaceSize = 1000 * 1024 - OBJECT_SPACE_ADJUSTMENT; } objectCtx->numEntries = objectCtx->numPersistentEntries = 0; diff --git a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_map.c b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_map.c index d355fc0e56..1d4d25bc56 100644 --- a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_map.c +++ b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_map.c @@ -1,4 +1,5 @@ #include "z_kaleido_scope.h" +#include "versions.h" #include "assets/textures/icon_item_24_static/icon_item_24_static.h" #if OOT_NTSC #include "assets/textures/icon_item_jpn_static/icon_item_jpn_static.h" @@ -725,6 +726,12 @@ void KaleidoScope_DrawWorldMap(PlayState* play, GraphicsContext* gfxCtx) { gSP1Quadrangle(POLY_OPA_DISP++, j, j + 2, j + 3, j + 1, 0); #endif +#if PLATFORM_N64 && OOT_VERSION != NTSC_1_2 + if (0) { + s32 pad[3]; + } +#endif + if (ZREG(38) == 0) { gDPPipeSync(POLY_OPA_DISP++); gDPSetTextureFilter(POLY_OPA_DISP++, G_TF_BILERP); diff --git a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope.c b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope.c index b270a56fa7..247b744486 100644 --- a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope.c +++ b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope.c @@ -14,6 +14,7 @@ #endif #include "assets/textures/icon_item_gameover_static/icon_item_gameover_static.h" #include "terminal.h" +#include "versions.h" #pragma increment_block_number "ntsc-1.2:128" @@ -1057,7 +1058,7 @@ void KaleidoScope_SetupPageSwitch(PauseContext* pauseCtx, u8 pt) { pauseCtx->cursorSpecialPos = PAUSE_CURSOR_PAGE_LEFT; } -#if OOT_NTSC +#if PLATFORM_N64 || OOT_NTSC gSaveContext.buttonStatus[0] = gPageSwitchNextButtonStatus[pauseCtx->pageIndex + pt][0]; #endif gSaveContext.buttonStatus[1] = gPageSwitchNextButtonStatus[pauseCtx->pageIndex + pt][1];