From 2bc46bfa6831ffc615867611f68f885dd17fbe30 Mon Sep 17 00:00:00 2001 From: briaguya <70942617+briaguya-ai@users.noreply.github.com> Date: Tue, 21 Jan 2025 14:47:28 -0500 Subject: [PATCH] skip z_title with button press --- .../TimeSavers/SkipCutscene/SkipLogoTitle.cpp | 19 +++++++++++++++++++ .../Enhancements/TimeSavers/TimeSavers.cpp | 1 + soh/soh/Enhancements/TimeSavers/TimeSavers.h | 1 + .../GameInteractor_HookTable.h | 1 + .../game-interactor/GameInteractor_Hooks.cpp | 4 ++++ .../game-interactor/GameInteractor_Hooks.h | 1 + .../overlays/gamestates/ovl_title/z_title.c | 3 +++ 7 files changed, 30 insertions(+) create mode 100644 soh/soh/Enhancements/TimeSavers/SkipCutscene/SkipLogoTitle.cpp diff --git a/soh/soh/Enhancements/TimeSavers/SkipCutscene/SkipLogoTitle.cpp b/soh/soh/Enhancements/TimeSavers/SkipCutscene/SkipLogoTitle.cpp new file mode 100644 index 000000000..4142286b5 --- /dev/null +++ b/soh/soh/Enhancements/TimeSavers/SkipCutscene/SkipLogoTitle.cpp @@ -0,0 +1,19 @@ +#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h" + +extern "C" { +#include "macros.h" +#include "z64.h" +} + +void SkipLogoTitle_Register() { + // Allows pressing A to skip the boot logo and go to the next state (opening or file select) + COND_HOOK(OnZTitleUpdate, true, [](void* gameState) { + TitleContext* titleContext = (TitleContext*)gameState; + + if (CHECK_BTN_ANY(titleContext->state.input->press.button, BTN_A | BTN_B | BTN_START)) { + // Force the title state to start fading to black and to last roughly 5 frames based on current fade in/out + titleContext->visibleDuration = 0; + titleContext->addAlpha = (255 - titleContext->coverAlpha) / 5; + } + }); +} diff --git a/soh/soh/Enhancements/TimeSavers/TimeSavers.cpp b/soh/soh/Enhancements/TimeSavers/TimeSavers.cpp index a198f8289..e9e21064d 100644 --- a/soh/soh/Enhancements/TimeSavers/TimeSavers.cpp +++ b/soh/soh/Enhancements/TimeSavers/TimeSavers.cpp @@ -9,6 +9,7 @@ void TimeSavers_Register() { SkipToGivingZeldasLetter_Register(); SkipZeldaFleeingCastle_Register(); SkipIntro_Register(); + SkipLogoTitle_Register(); // SkipMiscInteractions MoveJabuJabuElevator_Register(); MoveMidoInKokiriForest_Register(); diff --git a/soh/soh/Enhancements/TimeSavers/TimeSavers.h b/soh/soh/Enhancements/TimeSavers/TimeSavers.h index ad521c6c2..6ce14111b 100644 --- a/soh/soh/Enhancements/TimeSavers/TimeSavers.h +++ b/soh/soh/Enhancements/TimeSavers/TimeSavers.h @@ -11,6 +11,7 @@ void TimeSavers_Register(); void SkipToGivingZeldasLetter_Register(); void SkipZeldaFleeingCastle_Register(); void SkipIntro_Register(); + void SkipLogoTitle_Register(); // SkipMiscInteractions void MoveJabuJabuElevator_Register(); void MoveMidoInKokiriForest_Register(); diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor_HookTable.h b/soh/soh/Enhancements/game-interactor/GameInteractor_HookTable.h index a2d5c56ec..0ed761716 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor_HookTable.h +++ b/soh/soh/Enhancements/game-interactor/GameInteractor_HookTable.h @@ -5,6 +5,7 @@ * - Argument 1: Name of the hook * - Argument 2: Function type that the hook uses */ +DEFINE_HOOK(OnZTitleUpdate, (void* gameState)); DEFINE_HOOK(OnLoadGame, (int32_t fileNum)); DEFINE_HOOK(OnExitGame, (int32_t fileNum)); DEFINE_HOOK(OnGameFrameUpdate, ()); diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.cpp b/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.cpp index 39fc298a8..bd2baef98 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.cpp +++ b/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.cpp @@ -2,6 +2,10 @@ // MARK: - Gameplay +void GameInteractor_ExecuteOnZTitleUpdate(void* gameState) { + GameInteractor::Instance->ExecuteHooks(gameState); +} + void GameInteractor_ExecuteOnLoadGame(int32_t fileNum) { GameInteractor::Instance->ExecuteHooks(fileNum); } diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h b/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h index cb238539f..0808bd844 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h +++ b/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h @@ -7,6 +7,7 @@ extern "C" { #endif // MARK: - Gameplay +void GameInteractor_ExecuteOnZTitleUpdate(void* gameState); void GameInteractor_ExecuteOnLoadGame(int32_t fileNum); void GameInteractor_ExecuteOnExitGame(int32_t fileNum); void GameInteractor_ExecuteOnGameFrameUpdate(); diff --git a/soh/src/overlays/gamestates/ovl_title/z_title.c b/soh/src/overlays/gamestates/ovl_title/z_title.c index f8561166f..b0455bf7e 100644 --- a/soh/src/overlays/gamestates/ovl_title/z_title.c +++ b/soh/src/overlays/gamestates/ovl_title/z_title.c @@ -14,6 +14,7 @@ #include #include #include "soh/ResourceManagerHelpers.h" +#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h" #include #include "time.h" @@ -275,6 +276,8 @@ void Title_Main(GameState* thisx) { SET_NEXT_GAMESTATE(&this->state, Opening_Init, OpeningContext); } + GameInteractor_ExecuteOnZTitleUpdate(this); + CLOSE_DISPS(this->state.gfxCtx); }