From b2b13c5d77a418633c43ed2f70dfffd0946bbea1 Mon Sep 17 00:00:00 2001 From: LT-Schmiddy Date: Sat, 30 Nov 2024 16:29:59 -0500 Subject: [PATCH] Add variable to track if we're in the title sequence. --- patches/options.c | 5 +++++ patches/play_patches.c | 7 ++++++- patches/title_patches.c | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 patches/title_patches.c diff --git a/patches/options.c b/patches/options.c index 07c0a23..1a67af5 100644 --- a/patches/options.c +++ b/patches/options.c @@ -69,11 +69,16 @@ RECOMP_PATCH void FileSelect_RotateToOptions(GameState* thisx) { recomp_exit(); } +extern int recomp_in_title_sequence; + RECOMP_PATCH void FileSelect_Init(GameState* thisx) { s32 pad; FileSelectState* this = (FileSelectState*)thisx; size_t size; + recomp_in_title_sequence = false; + recomp_printf("FileSelect_Init\n"); + GameState_SetFramerateDivisor(&this->state, 1); Matrix_Init(&this->state); ShrinkWindow_Init(); diff --git a/patches/play_patches.c b/patches/play_patches.c index 27cbfee..0269dba 100644 --- a/patches/play_patches.c +++ b/patches/play_patches.c @@ -164,11 +164,13 @@ extern u8 D_80784600[]; // Non-relocatable references to the original addresses of these game state functions. void DayTelop_Init_NORELOCATE(GameState*); void TitleSetup_Init_NORELOCATE(GameState*); +void TitleSetup_Init(GameState*); RECOMP_DECLARE_EVENT(recomp_on_play_init(PlayState* this)); RECOMP_DECLARE_EVENT(recomp_after_play_init(PlayState* this)); bool allow_no_ocarina_tf = false; +bool recomp_in_title_sequence = false; // @recomp_export void recomp_set_allow_no_ocarina_tf(bool new_val): Set whether to force Termina Field to load normally even if Link has no ocarina. RECOMP_EXPORT void recomp_set_allow_no_ocarina_tf(bool new_val) { @@ -189,7 +191,10 @@ RECOMP_PATCH void Play_Init(GameState* thisx) { // @recomp_event recomp_on_play_init(PlayState* this): A new PlayState is being initialized. recomp_on_play_init(this); - recomp_set_reset_button_visibility(1); + if (!recomp_in_title_sequence) { + recomp_set_reset_button_visibility(1); + } + if ((gSaveContext.respawnFlag == -4) || (gSaveContext.respawnFlag == -0x63)) { diff --git a/patches/title_patches.c b/patches/title_patches.c new file mode 100644 index 0000000..a45aab2 --- /dev/null +++ b/patches/title_patches.c @@ -0,0 +1,41 @@ +#include "patches.h" +#include "patch_helpers.h" + +#include "global.h" +#include "z64save.h" +#include "z64shrink_window.h" +#include "z64view.h" +#include "regs.h" + +DECLARE_FUNC(void, recomp_set_reset_button_visibility, u8 visibility); + +typedef struct { + /* 0x000 */ GameState state; + /* 0x0A8 */ View view; +} TitleSetupState; // size = 0x210 + +extern int recomp_in_title_sequence; + +void TitleSetup_Init(GameState* thisx); +void TitleSetup_Main(GameState* thisx); +void TitleSetup_Destroy(GameState* thisx); + +RECOMP_PATCH void TitleSetup_Init(GameState* thisx) { + TitleSetupState* this = (TitleSetupState*)thisx; + + GameState_SetFramerateDivisor(&this->state, 1); + Matrix_Init(&this->state); + ShrinkWindow_Init(); + View_Init(&this->view, this->state.gfxCtx); + this->state.main = TitleSetup_Main; + this->state.destroy = TitleSetup_Destroy; + + gSaveContext.respawnFlag = 0; + gSaveContext.respawn[RESPAWN_MODE_GORON].entrance = 0xFF; + gSaveContext.respawn[RESPAWN_MODE_ZORA].entrance = 0xFF; + gSaveContext.respawn[RESPAWN_MODE_DEKU].entrance = 0xFF; + gSaveContext.respawn[RESPAWN_MODE_HUMAN].entrance = 0xFF; + + recomp_in_title_sequence = true; + recomp_printf("TitleSetup_Init\n"); +}