From a3a32a19d07c8de34fa91b149c66c8469da13126 Mon Sep 17 00:00:00 2001 From: nclok1405 <155463060+nclok1405@users.noreply.github.com> Date: Fri, 13 Jun 2025 13:07:37 +0900 Subject: [PATCH] Added a new hook and moved Boot To Debug Warp Screen to it --- .../Enhancements/BootToDebugWarpScreen.cpp | 30 +++++++++++++++++++ .../GameInteractor_HookTable.h | 1 + .../game-interactor/GameInteractor_Hooks.cpp | 4 +++ .../game-interactor/GameInteractor_Hooks.h | 1 + .../ovl_file_choose/z_file_choose.c | 11 ++----- 5 files changed, 39 insertions(+), 8 deletions(-) create mode 100644 soh/soh/Enhancements/BootToDebugWarpScreen.cpp diff --git a/soh/soh/Enhancements/BootToDebugWarpScreen.cpp b/soh/soh/Enhancements/BootToDebugWarpScreen.cpp new file mode 100644 index 000000000..77163d141 --- /dev/null +++ b/soh/soh/Enhancements/BootToDebugWarpScreen.cpp @@ -0,0 +1,30 @@ +#include +#include "soh/Enhancements/game-interactor/GameInteractor.h" +#include "soh/ShipInit.hpp" +#include "functions.h" + +extern "C" { +#include "z64.h" +#include "overlays/gamestates/ovl_file_choose/file_choose.h" +} + +static constexpr int32_t CVAR_DEBUG_ENABLED_DEFAULT = 0; +#define CVAR_DEBUG_ENABLED_NAME CVAR_DEVELOPER_TOOLS("DebugEnabled") +#define CVAR_DEBUG_ENABLED_VALUE CVarGetInteger(CVAR_DEBUG_ENABLED_NAME, CVAR_DEBUG_ENABLED_DEFAULT) + +static constexpr int32_t CVAR_BOOT_TO_DEBUG_WARP_SCREEN_DEFAULT = 0; +#define CVAR_BOOT_TO_DEBUG_WARP_SCREEN_NAME CVAR_DEVELOPER_TOOLS("BootToDebugWarpScreen") +#define CVAR_BOOT_TO_DEBUG_WARP_SCREEN_VALUE CVarGetInteger(CVAR_BOOT_TO_DEBUG_WARP_SCREEN_NAME, CVAR_BOOT_TO_DEBUG_WARP_SCREEN_DEFAULT) + +void OnFileChooseMainBootToDebugWarpScreen(void* gameState) { + FileChooseContext* fileChooseContext = (FileChooseContext*)gameState; + fileChooseContext->buttonIndex = 0xFF; + fileChooseContext->menuMode = FS_MENU_MODE_SELECT; + fileChooseContext->selectMode = SM_LOAD_GAME; +} + +void RegisterBootToDebugWarpScreen() { + COND_HOOK(OnFileChooseMain, CVAR_DEBUG_ENABLED_VALUE && CVAR_BOOT_TO_DEBUG_WARP_SCREEN_VALUE, OnFileChooseMainBootToDebugWarpScreen); +} + +static RegisterShipInitFunc initFunc_BootToDebugWarpScreen(RegisterBootToDebugWarpScreen, { CVAR_BOOT_TO_DEBUG_WARP_SCREEN_NAME }); diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor_HookTable.h b/soh/soh/Enhancements/game-interactor/GameInteractor_HookTable.h index 8d5a8f4e5..2c94d27a4 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor_HookTable.h +++ b/soh/soh/Enhancements/game-interactor/GameInteractor_HookTable.h @@ -66,6 +66,7 @@ DEFINE_HOOK(OnUpdateFileLanguageSelection, (uint8_t optionIndex)); DEFINE_HOOK(OnUpdateFileQuestSelection, (uint8_t questIndex)); DEFINE_HOOK(OnUpdateFileBossRushOptionSelection, (uint8_t optionIndex, uint8_t optionValue)); DEFINE_HOOK(OnUpdateFileNameSelection, (int16_t charCode)); +DEFINE_HOOK(OnFileChooseMain, (void* gameState)); DEFINE_HOOK(OnSetGameLanguage, ()); DEFINE_HOOK(OnFileDropped, (std::string filePath)); diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.cpp b/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.cpp index 120ca4e99..21f1a9c09 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.cpp +++ b/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.cpp @@ -298,6 +298,10 @@ void GameInteractor_ExecuteOnUpdateFileNameSelection(int16_t charCode) { GameInteractor::Instance->ExecuteHooks(charCode); } +void GameInteractor_ExecuteOnFileChooseMain(void* gameState) { + GameInteractor::Instance->ExecuteHooks(gameState); +} + // MARK: - Game void GameInteractor_ExecuteOnSetGameLanguage() { diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h b/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h index 9bb47868f..b32dada61 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h +++ b/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h @@ -73,6 +73,7 @@ void GameInteractor_ExecuteOnUpdateFileLanguageSelection(uint8_t optionIndex); void GameInteractor_ExecuteOnUpdateFileQuestSelection(uint8_t questIndex); void GameInteractor_ExecuteOnUpdateFileBossRushOptionSelection(uint8_t optionIndex, uint8_t optionValue); void GameInteractor_ExecuteOnUpdateFileNameSelection(int16_t charCode); +void GameInteractor_ExecuteOnFileChooseMain(void* gameState); // MARK: - Game void GameInteractor_ExecuteOnSetGameLanguage(); diff --git a/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c b/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c index be582949a..9150656f4 100644 --- a/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c +++ b/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c @@ -3557,6 +3557,9 @@ void FileChoose_Main(GameState* thisx) { Input* input = &this->state.input[0]; Color_RGB8 helpTextColor = { 100, 255, 255 }; + + GameInteractor_ExecuteOnFileChooseMain(thisx); + if (CVarGetInteger(CVAR_COSMETIC("Title.FileChoose.Changed"), 0)) { Color_RGB8 backgroundColor = CVarGetColor24(CVAR_COSMETIC("Title.FileChoose.Value"), (Color_RGB8){ 100, 150, 255 }); @@ -3588,14 +3591,6 @@ void FileChoose_Main(GameState* thisx) { gSaveContext.skyboxTime += 0x10; } - // Boot to Debug Warp Screen - if ((CVarGetInteger(CVAR_DEVELOPER_TOOLS("DebugEnabled"), 0) != 0) && - (CVarGetInteger(CVAR_DEVELOPER_TOOLS("BootToDebugWarpScreen"), 0) != 0)) { - this->buttonIndex = 0xFF; - this->menuMode = FS_MENU_MODE_SELECT; - this->selectMode = SM_LOAD_GAME; - } - OPEN_DISPS(this->state.gfxCtx); this->n64ddFlag = 0;