Boot sequence adjustments (#6119)

This commit is contained in:
Garrett Cox
2026-01-08 11:21:52 -06:00
committed by GitHub
parent 4839e575b1
commit 71a47559f7
7 changed files with 51 additions and 74 deletions

View File

@@ -9,18 +9,14 @@
extern "C" {
#include "z64.h"
#include "overlays/gamestates/ovl_file_choose/file_choose.h"
#include "soh/Enhancements/enhancementTypes.h"
void Sram_InitDebugSave(void);
void Select_LoadGame(SelectContext* selectContext, s32 entranceIndex);
}
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)
#define CVAR_BOOTSEQUENCE_NAME CVAR_SETTING("BootSequence")
#define CVAR_BOOTSEQUENCE_DEFAULT BOOTSEQUENCE_DEFAULT
#define CVAR_BOOTSEQUENCE_VALUE CVarGetInteger(CVAR_BOOTSEQUENCE_NAME, CVAR_BOOTSEQUENCE_DEFAULT)
typedef struct WarpPoint {
s32 entranceId;
@@ -49,15 +45,21 @@ void SaveConfig() {
}
void Warp(WarpPoint& warpPoint) {
SPDLOG_INFO("PLAYSTATE IS NULL: {}", gPlayState == NULL);
if (gPlayState == NULL) {
// If gPlayState is NULL, it means the the user opted into BootToWarpPoint and the game is starting up.
gSaveContext.gameMode = GAMEMODE_NORMAL;
gSaveContext.fileNum = 0xFE; // temporary file so that this will respect debug save file option
Sram_InitDebugSave();
gSaveContext.magicFillTarget = gSaveContext.magic;
gSaveContext.magic = 0;
gSaveContext.magicCapacity = 0;
gSaveContext.magicLevel = gSaveContext.magic;
gSaveContext.fileNum = 0xFF;
gSaveContext.sceneSetupIndex = 0;
gSaveContext.cutsceneIndex = 0;
gSaveContext.linkAge = 0;
gSaveContext.nightFlag = 0;
gSaveContext.skyboxTime = gSaveContext.dayTime = 0x8000;
// Copied from Select_LoadGame
for (int buttonIndex = 0; buttonIndex < ARRAY_COUNT(gSaveContext.buttonStatus); buttonIndex++) {
@@ -182,26 +184,33 @@ void RegisterWarping() {
loadedConfig = true;
}
COND_HOOK(OnZTitleUpdate, CVAR_DEBUG_ENABLED_VALUE && CVAR_BOOT_TO_DEBUG_WARP_SCREEN_VALUE == 1,
[](void* gameState) {
TitleContext* titleContext = (TitleContext*)gameState;
COND_HOOK(OnZTitleUpdate, CVAR_BOOTSEQUENCE_VALUE == BOOTSEQUENCE_DEBUGWARPSCREEN, [](void* gameState) {
TitleContext* titleContext = (TitleContext*)gameState;
gSaveContext.seqId = (u8)NA_BGM_DISABLED;
gSaveContext.natureAmbienceId = 0xFF;
gSaveContext.gameMode = GAMEMODE_NORMAL;
titleContext->state.running = false;
SET_NEXT_GAMESTATE(&titleContext->state, Select_Init, SelectContext);
});
gSaveContext.seqId = (u8)NA_BGM_DISABLED;
gSaveContext.natureAmbienceId = 0xFF;
gSaveContext.gameMode = GAMEMODE_NORMAL;
titleContext->state.running = false;
SET_NEXT_GAMESTATE(&titleContext->state, Select_Init, SelectContext);
});
COND_HOOK(OnZTitleUpdate, CVAR_DEBUG_ENABLED_VALUE && CVAR_BOOT_TO_DEBUG_WARP_SCREEN_VALUE == 2,
[](void* gameState) {
for (auto& wp : warpPoints) {
if (wp.second.bootToPoint) {
Warp(wp.second);
break;
}
}
});
COND_HOOK(OnZTitleUpdate, CVAR_BOOTSEQUENCE_VALUE == BOOTSEQUENCE_WARPPOINT, [](void* gameState) {
for (auto& wp : warpPoints) {
if (wp.second.bootToPoint) {
Warp(wp.second);
return;
}
}
// Fallback to Debug Warp Screen if no warp point is set to boot to
TitleContext* titleContext = (TitleContext*)gameState;
gSaveContext.seqId = (u8)NA_BGM_DISABLED;
gSaveContext.natureAmbienceId = 0xFF;
gSaveContext.gameMode = GAMEMODE_NORMAL;
titleContext->state.running = false;
SET_NEXT_GAMESTATE(&titleContext->state, Select_Init, SelectContext);
});
}
static RegisterShipInitFunc initFunc(RegisterWarping, { CVAR_DEBUG_ENABLED_NAME, CVAR_BOOT_TO_DEBUG_WARP_SCREEN_NAME });
static RegisterShipInitFunc initFunc(RegisterWarping, { CVAR_BOOTSEQUENCE_NAME });

View File

@@ -213,15 +213,10 @@ void OnZTitleUpdateSkipToFileSelect(void* gameState) {
}
void RegisterCustomLogoTitleBootsequence() {
COND_HOOK(OnZTitleUpdate,
CVAR_BOOTSEQUENCE_VALUE == BOOTSEQUENCE_FILESELECT &&
CVarGetInteger(CVAR_DEVELOPER_TOOLS("BootToDebugWarpScreen"), 0) == 0,
OnZTitleUpdateSkipToFileSelect);
COND_HOOK(OnZTitleUpdate, CVAR_BOOTSEQUENCE_VALUE == BOOTSEQUENCE_FILESELECT, OnZTitleUpdateSkipToFileSelect);
}
static RegisterShipInitFunc registerTitleBootSequence(RegisterCustomLogoTitleBootsequence,
{ CVAR_BOOTSEQUENCE_NAME,
CVAR_DEVELOPER_TOOLS("BootToDebugWarpScreen") });
static RegisterShipInitFunc registerTitleBootSequence(RegisterCustomLogoTitleBootsequence, { CVAR_BOOTSEQUENCE_NAME });
// // // // // //
// Let it Snow

View File

@@ -49,6 +49,8 @@ typedef enum {
BOOTSEQUENCE_DEFAULT,
BOOTSEQUENCE_AUTHENTIC,
BOOTSEQUENCE_FILESELECT,
BOOTSEQUENCE_DEBUGWARPSCREEN,
BOOTSEQUENCE_WARPPOINT,
} BootSequenceType;
typedef enum {

View File

@@ -19,7 +19,6 @@ 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;

View File

@@ -154,12 +154,6 @@ 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)" } },
};
}

View File

@@ -17,11 +17,6 @@ static const std::map<int32_t, const char*> logLevels = {
{ DEBUG_LOG_WARN, "Warn" }, { DEBUG_LOG_ERROR, "Error" }, { DEBUG_LOG_CRITICAL, "Critical" },
{ DEBUG_LOG_OFF, "Off" },
};
static std::map<int32_t, const char*> bootToOptions = {
{ 0, "Disabled" },
{ 1, "Debug Warp Screen" },
{ 2, "Warp Point" },
};
#ifdef _DEBUG
DebugLogOption defaultLogLevel = DEBUG_LOG_TRACE;
@@ -64,7 +59,8 @@ void SohMenu::AddMenuDevTools() {
"- Off: The debug save file will be a normal savefile.\n"
"- Vanilla: The debug save file will be the debug save file from the original game.\n"
"- Maxed: The debug save file will be a save file with all of the items & upgrades.")
.ComboMap(debugSaveFileModes));
.ComboMap(debugSaveFileModes)
.DefaultIndex(1));
AddWidget(path, "OoT Skulltula Debug", WIDGET_CVAR_CHECKBOX)
.CVar(CVAR_DEVELOPER_TOOLS("SkulltulaDebugEnabled"))
.PreFunc([](WidgetInfo& info) { info.isHidden = !CVarGetInteger(CVAR_DEVELOPER_TOOLS("DebugEnabled"), 0); })
@@ -122,33 +118,17 @@ void SohMenu::AddMenuDevTools() {
.PreFunc([](WidgetInfo& info) { info.isHidden = mSohMenu->disabledMap.at(DISABLE_FOR_DEBUG_MODE_OFF).active; });
path.column = SECTION_COLUMN_2;
AddWidget(path, "Warping", WIDGET_SEPARATOR_TEXT).PreFunc([](WidgetInfo& info) {
info.isHidden = !CVarGetInteger(CVAR_DEVELOPER_TOOLS("DebugEnabled"), 0);
});
AddWidget(path, "Warping", WIDGET_SEPARATOR_TEXT);
AddWidget(path, "Better Debug Warp Screen", WIDGET_CVAR_CHECKBOX)
.CVar(CVAR_DEVELOPER_TOOLS("BetterDebugWarpScreen"))
.PreFunc([](WidgetInfo& info) { info.isHidden = !CVarGetInteger(CVAR_DEVELOPER_TOOLS("DebugEnabled"), 0); })
.Options(CheckboxOptions()
.Tooltip("Optimized Debug Warp Screen, with the added ability to chose entrances and time of day.")
.DefaultValue(true));
AddWidget(path, "Debug Warp Screen Translation", WIDGET_CVAR_CHECKBOX)
.CVar(CVAR_DEVELOPER_TOOLS("DebugWarpScreenTranslation"))
.PreFunc([](WidgetInfo& info) { info.isHidden = !CVarGetInteger(CVAR_DEVELOPER_TOOLS("DebugEnabled"), 0); })
.Options(CheckboxOptions()
.Tooltip("Translate the Debug Warp Screen based on the game language.")
.DefaultValue(true));
AddWidget(path, "Boot To:", WIDGET_CVAR_COMBOBOX)
.CVar(CVAR_DEVELOPER_TOOLS("BootToDebugWarpScreen"))
.PreFunc([](WidgetInfo& info) { info.isHidden = !CVarGetInteger(CVAR_DEVELOPER_TOOLS("DebugEnabled"), 0); })
.Options(ComboboxOptions()
.DefaultIndex(0)
.ComponentAlignment(ComponentAlignments::Right)
.LabelPosition(LabelPositions::Far)
.Color(THEME_COLOR)
.ComboMap(bootToOptions)
.Tooltip("Automatically boots to Debug Warp Screen or custom Warp Point when starting or "
"resetting the game.\n"
"This option takes precedence over \"Boot Sequence\" option."));
AddWidget(path, "Warp Points", WIDGET_CUSTOM).CustomFunction(WarpPointsWidget).HideInSearch(true);
// Stats

View File

@@ -54,9 +54,9 @@ static const std::map<int32_t, const char*> notificationPosition = {
};
static const std::map<int32_t, const char*> bootSequenceLabels = {
{ BOOTSEQUENCE_DEFAULT, "Default" },
{ BOOTSEQUENCE_AUTHENTIC, "Authentic" },
{ BOOTSEQUENCE_FILESELECT, "File Select" },
{ BOOTSEQUENCE_DEFAULT, "Default" }, { BOOTSEQUENCE_AUTHENTIC, "Authentic" },
{ BOOTSEQUENCE_FILESELECT, "File Select" }, { BOOTSEQUENCE_DEBUGWARPSCREEN, "Debug Warp Screen" },
{ BOOTSEQUENCE_WARPPOINT, "Warp Point" },
};
const char* GetGameVersionString(uint32_t index) {
@@ -125,7 +125,7 @@ void SohMenu::UpdateLanguageMap(std::map<int32_t, const char*>& languageMap) {
void SohMenu::AddMenuSettings() {
// Add Settings Menu
AddMenuEntry("Settings", CVAR_SETTING("Menu.SettingsSidebarSection"));
AddSidebarEntry("Settings", "General", 3);
AddSidebarEntry("Settings", "General", 2);
WidgetPath path = { "Settings", "General", SECTION_COLUMN_1 };
// General - Settings
@@ -190,10 +190,6 @@ 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)
@@ -202,7 +198,9 @@ void SohMenu::AddMenuSettings() {
.Tooltip("Configure what happens when starting or resetting the game.\n\n"
"Default: LUS logo -> N64 logo\n"
"Authentic: N64 logo only\n"
"File Select: Skip to file select menu"));
"File Select: Skip to file select menu\n"
"Debug Warp Screen: Skip to the debug warp screen\n"
"Warp Point: Skip to active warp point (if set), see Dev Tools -> General"));
AddWidget(path, "Languages", WIDGET_SEPARATOR_TEXT);
AddWidget(path, "Translate Title Screen", WIDGET_CVAR_CHECKBOX)