From 4f95ab3f46b1e6d5d6ce34e5b400de16683e2c87 Mon Sep 17 00:00:00 2001 From: nclok1405 <155463060+nclok1405@users.noreply.github.com> Date: Fri, 20 Jun 2025 05:39:03 +0900 Subject: [PATCH] Add/Restore the option to automatically boot into Debug Warp Screen (#5485) * Added/Restored the option to automatically boot into Debug Warp Screen * clang-formated * Added a new hook and moved Boot To Debug Warp Screen to it * clang * Added DebugEnabled to initFunc's CVar list. This should prevent Debug Warp from being triggered when Boot to Debug Warp option is enabled but Debug Mode option is disabled. * No longer hijacks CustomLogoTitle * Disable "Boot Sequence" dropdown when Boot to Debug Warp Screen is enabled --- .../Enhancements/BootToDebugWarpScreen.cpp | 47 +++++++++++++++++++ .../GameInteractor_HookTable.h | 1 + .../game-interactor/GameInteractor_Hooks.cpp | 4 ++ .../game-interactor/GameInteractor_Hooks.h | 1 + soh/soh/SohGui/MenuTypes.h | 1 + soh/soh/SohGui/SohMenu.cpp | 6 +++ soh/soh/SohGui/SohMenuDevTools.cpp | 6 +++ soh/soh/SohGui/SohMenuSettings.cpp | 4 ++ .../ovl_file_choose/z_file_choose.c | 3 ++ 9 files changed, 73 insertions(+) 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..a2b8c6b60 --- /dev/null +++ b/soh/soh/Enhancements/BootToDebugWarpScreen.cpp @@ -0,0 +1,47 @@ +#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 OnZTitleUpdateBootToDebugWarpScreen(void* gameState) { + TitleContext* titleContext = (TitleContext*)gameState; + + gSaveContext.seqId = (u8)NA_BGM_DISABLED; + gSaveContext.natureAmbienceId = 0xFF; + gSaveContext.gameMode = GAMEMODE_FILE_SELECT; + titleContext->state.running = false; + + SET_NEXT_GAMESTATE(&titleContext->state, FileChoose_Init, FileChooseContext); +} + +void RegisterBootToDebugWarpScreen() { + COND_HOOK(OnFileChooseMain, CVAR_DEBUG_ENABLED_VALUE && CVAR_BOOT_TO_DEBUG_WARP_SCREEN_VALUE, + OnFileChooseMainBootToDebugWarpScreen); + COND_HOOK(OnZTitleUpdate, CVAR_DEBUG_ENABLED_VALUE && CVAR_BOOT_TO_DEBUG_WARP_SCREEN_VALUE, + OnZTitleUpdateBootToDebugWarpScreen); +} + +static RegisterShipInitFunc initFunc_BootToDebugWarpScreen(RegisterBootToDebugWarpScreen, + { CVAR_DEBUG_ENABLED_NAME, + 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/soh/SohGui/MenuTypes.h b/soh/soh/SohGui/MenuTypes.h index de78e8961..e96d015ef 100644 --- a/soh/soh/SohGui/MenuTypes.h +++ b/soh/soh/SohGui/MenuTypes.h @@ -19,6 +19,7 @@ typedef enum { DISABLE_FOR_FRAME_ADVANCE_OFF, DISABLE_FOR_ADVANCED_RESOLUTION_OFF, DISABLE_FOR_VERTICAL_RESOLUTION_OFF, + DISABLE_FOR_BOOT_TO_DEBUG_WARP_SCREEN_ON, } DisableOption; struct WidgetInfo; diff --git a/soh/soh/SohGui/SohMenu.cpp b/soh/soh/SohGui/SohMenu.cpp index 61967087b..a71fd1cad 100644 --- a/soh/soh/SohGui/SohMenu.cpp +++ b/soh/soh/SohGui/SohMenu.cpp @@ -155,6 +155,12 @@ void SohMenu::InitElement() { return !CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".VerticalResolutionToggle", 0); }, "Vertical Resolution Toggle is Off" } }, + { DISABLE_FOR_BOOT_TO_DEBUG_WARP_SCREEN_ON, + { [](disabledInfo& info) -> bool { + return CVarGetInteger(CVAR_DEVELOPER_TOOLS("DebugEnabled"), 0) && + CVarGetInteger(CVAR_DEVELOPER_TOOLS("BootToDebugWarpScreen"), 0); + }, + "\"Boot To Debug Warp Screen\" Enabled (see Dev Tools -> General)" } }, }; } diff --git a/soh/soh/SohGui/SohMenuDevTools.cpp b/soh/soh/SohGui/SohMenuDevTools.cpp index 6a5c292eb..3e87af890 100644 --- a/soh/soh/SohGui/SohMenuDevTools.cpp +++ b/soh/soh/SohGui/SohMenuDevTools.cpp @@ -21,6 +21,12 @@ void SohMenu::AddMenuDevTools() { .Options( CheckboxOptions().Tooltip("Enables Debug Mode, allowing you to select maps with L + R + Z, noclip " "with L + D-pad Right, and open the debug menu with L on the pause screen.")); + AddWidget(path, "Boot To Debug Warp Screen", WIDGET_CVAR_CHECKBOX) + .CVar(CVAR_DEVELOPER_TOOLS("BootToDebugWarpScreen")) + .PreFunc([](WidgetInfo& info) { info.isHidden = !CVarGetInteger(CVAR_DEVELOPER_TOOLS("DebugEnabled"), 0); }) + .Options( + CheckboxOptions().Tooltip("Automatically shows Debug Warp Screen when starting or resetting the game.\n" + "This option takes precedence over \"Boot Sequence\" option.")); AddWidget(path, "OoT Registry Editor", WIDGET_CVAR_CHECKBOX) .CVar(CVAR_DEVELOPER_TOOLS("RegEditEnabled")) .PreFunc([](WidgetInfo& info) { info.isHidden = !CVarGetInteger(CVAR_DEVELOPER_TOOLS("DebugEnabled"), 0); }) diff --git a/soh/soh/SohGui/SohMenuSettings.cpp b/soh/soh/SohGui/SohMenuSettings.cpp index 23bee56dc..c3c5bdfa1 100644 --- a/soh/soh/SohGui/SohMenuSettings.cpp +++ b/soh/soh/SohGui/SohMenuSettings.cpp @@ -159,6 +159,10 @@ void SohMenu::AddMenuSettings() { AddWidget(path, "Boot Sequence", WIDGET_CVAR_COMBOBOX) .CVar(CVAR_SETTING("BootSequence")) .RaceDisable(false) + .PreFunc([](WidgetInfo& info) { + if (mSohMenu->disabledMap.at(DISABLE_FOR_BOOT_TO_DEBUG_WARP_SCREEN_ON).active) + info.activeDisables.push_back(DISABLE_FOR_BOOT_TO_DEBUG_WARP_SCREEN_ON); + }) .Options(ComboboxOptions() .DefaultIndex(BOOTSEQUENCE_DEFAULT) .LabelPosition(LabelPositions::Far) 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 b715b488e..736616fc9 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 @@ -3565,6 +3565,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 });