From 067d06bb56f2acb3436c24150e16487437dbf7c1 Mon Sep 17 00:00:00 2001 From: cadmic Date: Sat, 27 Jul 2024 21:09:05 -0700 Subject: [PATCH] Match NTSC loose ends (#2004) * Match NTSC loose ends * Add comment about giObjectSegment size --- src/code/z_actor.c | 10 +++++++++- src/code/z_common_data.c | 3 +++ src/code/z_play.c | 4 ++++ src/overlays/actors/ovl_Fishing/z_fishing.c | 12 +++++++++++- src/overlays/actors/ovl_player_actor/z_player.c | 6 +++++- 5 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 6afae4f1fd..890a05a681 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -689,7 +689,7 @@ void TitleCard_InitPlaceName(PlayState* play, TitleCardContext* titleCtx, void* SceneTableEntry* loadedScene = play->loadedScene; u32 size = loadedScene->titleFile.vromEnd - loadedScene->titleFile.vromStart; - if ((size != 0) && (size <= 0x3000)) { + if ((size != 0) && (size <= 0x1000 * LANGUAGE_MAX)) { DMA_REQUEST_SYNC(texture, loadedScene->titleFile.vromStart, size, "../z_actor.c", 2765); } @@ -733,7 +733,15 @@ void TitleCard_Draw(PlayState* play, TitleCardContext* titleCtx) { OPEN_DISPS(play->state.gfxCtx, "../z_actor.c", 2824); +#if OOT_NTSC + if (gSaveContext.language == LANGUAGE_JPN) { + textureLanguageOffset = 0; + } else { + textureLanguageOffset = width * height; + } +#else textureLanguageOffset = width * height * gSaveContext.language; +#endif height = (width * height > 0x1000) ? 0x1000 / width : height; titleSecondY = titleY + (height * 4); diff --git a/src/code/z_common_data.c b/src/code/z_common_data.c index 47aecd9e6a..a0588d9295 100644 --- a/src/code/z_common_data.c +++ b/src/code/z_common_data.c @@ -24,4 +24,7 @@ void SaveContext_Init(void) { gSaveContext.dogIsLost = true; gSaveContext.nextTransitionType = TRANS_NEXT_TYPE_DEFAULT; gSaveContext.prevHudVisibilityMode = HUD_VISIBILITY_ALL; +#if OOT_NTSC + gSaveContext.language = LANGUAGE_ENG; +#endif } diff --git a/src/code/z_play.c b/src/code/z_play.c index 7abd6705c5..4f536524fe 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -168,7 +168,11 @@ void Play_SetupTransition(PlayState* this, s32 transitionType) { break; default: +#if OOT_NTSC + HUNGUP_AND_CRASH("../z_play.c", 2287); +#else HUNGUP_AND_CRASH("../z_play.c", 2290); +#endif break; } } diff --git a/src/overlays/actors/ovl_Fishing/z_fishing.c b/src/overlays/actors/ovl_Fishing/z_fishing.c index 49ff3b5f1e..34876f792d 100644 --- a/src/overlays/actors/ovl_Fishing/z_fishing.c +++ b/src/overlays/actors/ovl_Fishing/z_fishing.c @@ -5759,8 +5759,18 @@ void Fishing_UpdateOwner(Actor* thisx, PlayState* play2) { SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &sStreamSfxPos, &sStreamSfxProjectedPos, &sProjectedW); Sfx_PlaySfxAtPos(&sStreamSfxProjectedPos, NA_SE_EV_WATER_WALL - SFX_FLAG); - // convert length to weight. Theoretical max of 59 lbs (127^2*.0036+.5) + +#if OOT_NTSC + if (gSaveContext.language == LANGUAGE_JPN) { + gSaveContext.minigameScore = sFishLengthToWeigh; + } else { + // Convert length to weight. Theoretical max of 59 lbs (127^2*.0036+.5) + gSaveContext.minigameScore = (SQ((f32)sFishLengthToWeigh) * 0.0036f) + 0.5f; + } +#else + // Same as above, but for PAL gSaveContext.minigameScore = (SQ((f32)sFishLengthToWeigh) * 0.0036f) + 0.5f; +#endif #if OOT_DEBUG if (BREG(26) != 0) { diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index 0073b5d76e..aac7839a9f 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -10113,7 +10113,11 @@ void Player_Init(Actor* thisx, PlayState* play2) { Player_SetEquipmentData(play, this); this->prevBoots = this->currentBoots; Player_InitCommon(this, play, gPlayerSkelHeaders[((void)0, gSaveContext.save.linkAge)]); - this->giObjectSegment = (void*)(((uintptr_t)ZELDA_ARENA_MALLOC(0x3008, "../z_player.c", 17175) + 8) & ~0xF); + // `giObjectSegment` is used for both "get item" objects and title cards. The maximum size for + // get item objects is 0x2000 (see the assert in func_8083AE40), and the maximum size for + // title cards is 0x1000 * LANGUAGE_MAX since each title card image includes all languages. + this->giObjectSegment = + (void*)(((uintptr_t)ZELDA_ARENA_MALLOC(0x1000 * LANGUAGE_MAX + 8, "../z_player.c", 17175) + 8) & ~0xF); respawnFlag = gSaveContext.respawnFlag;