From 445abbd5ad40b8bafc7b2f36157ad7038a283e31 Mon Sep 17 00:00:00 2001 From: Kenix3 Date: Thu, 28 Jul 2022 23:47:38 -0400 Subject: [PATCH 1/3] Adds beta quest Gameshark cheat. --- libultraship/libultraship/ImGuiImpl.cpp | 71 +++++++++++++++++++++++++ soh/soh/Enhancements/debugconsole.cpp | 4 ++ soh/src/code/z_common_data.c | 2 +- 3 files changed, 76 insertions(+), 1 deletion(-) diff --git a/libultraship/libultraship/ImGuiImpl.cpp b/libultraship/libultraship/ImGuiImpl.cpp index f7288ae3af7..21870159f7f 100644 --- a/libultraship/libultraship/ImGuiImpl.cpp +++ b/libultraship/libultraship/ImGuiImpl.cpp @@ -68,6 +68,8 @@ OSContPad* pads; std::map DefaultAssets; std::vector emptyArgs; +extern bool IsInGamePlay(); + namespace SohImGui { WindowImpl impl; @@ -1407,6 +1409,75 @@ namespace SohImGui { EnhancementCheckbox("Shield with Two-Handed Weapons", "gShieldTwoHanded"); Tooltip("This allows you to put up your shield with any two-handed weapon in hand\nexcept for Deku Sticks"); + { + static int32_t betaQuestEnabled = CVar_GetS32("gEnableBetaQuest", 0); + static int32_t lastBetaQuestEnabled = betaQuestEnabled; + static int32_t betaQuestWorld = CVar_GetS32("gBetaQuestWorld", 0xFFEF); + static int32_t lastBetaQuestWorld = betaQuestWorld; + + bool isDisabled = !IsInGamePlay(); + + if (isDisabled) { + ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true); + ImGui::PushStyleVar(ImGuiStyleVar_Alpha, ImGui::GetStyle().Alpha * 0.5f); + } + + EnhancementCheckbox("Enable Beta Quest", "gEnableBetaQuest"); + Tooltip("Turns on OoT Beta Quest. *WARNING* This will reset your game."); + betaQuestEnabled = CVar_GetS32("gEnableBetaQuest", 0); + if (betaQuestEnabled) { + if (betaQuestEnabled != lastBetaQuestEnabled) { + betaQuestWorld = 0; + } + + ImGui::Text("Beta Quest World: %d", betaQuestWorld); + + if (ImGui::Button(" - ##BetaQuest")) { + betaQuestWorld--; + } + ImGui::SameLine(); + ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 7.0f); + + ImGui::SliderInt("##BetaQuest", &betaQuestWorld, 0, 16, "", ImGuiSliderFlags_AlwaysClamp); + Tooltip("Set the Beta Quest world to explore. *WARNING* Changing this will reset your game.\nCtrl+Click to type in a value."); + + ImGui::SameLine(); + ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 7.0f); + if (ImGui::Button(" + ##BetaQuest")) { + betaQuestWorld++; + } + + if (betaQuestWorld > 16) { + betaQuestWorld = 16; + } + else if (betaQuestWorld < 0) { + betaQuestWorld = 0; + } + } + else { + lastBetaQuestWorld = betaQuestWorld = 0xFFEF; + CVar_SetS32("gBetaQuestWorld", betaQuestWorld); + needs_save = true; + } + if (betaQuestEnabled != lastBetaQuestEnabled || betaQuestWorld != lastBetaQuestWorld) + { + // Reset the game if the beta quest state or world changed because beta quest happens on redirecting the title screen cutscene. + lastBetaQuestEnabled = betaQuestEnabled; + lastBetaQuestWorld = betaQuestWorld; + CVar_SetS32("gEnableBetaQuest", betaQuestEnabled); + CVar_SetS32("gBetaQuestWorld", betaQuestWorld); + + console->Commands["reset"].handler(emptyArgs); + + needs_save = true; + } + + if (isDisabled) { + ImGui::PopItemFlag(); + ImGui::PopStyleVar(); + } + } + ImGui::EndMenu(); } diff --git a/soh/soh/Enhancements/debugconsole.cpp b/soh/soh/Enhancements/debugconsole.cpp index eb2b02b115e..0a9409fb67f 100644 --- a/soh/soh/Enhancements/debugconsole.cpp +++ b/soh/soh/Enhancements/debugconsole.cpp @@ -33,6 +33,10 @@ extern GlobalContext* gGlobalCtx; #define CMD_REGISTER SohImGui::BindCmd +bool IsInGamePlay() { + return gGlobalCtx != nullptr; +} + static bool ActorSpawnHandler(const std::vector& args) { if ((args.size() != 9) && (args.size() != 3) && (args.size() != 6)) { ERROR("Not enough arguments passed to actorspawn"); diff --git a/soh/src/code/z_common_data.c b/soh/src/code/z_common_data.c index c92a36b71c2..53334fb842f 100644 --- a/soh/src/code/z_common_data.c +++ b/soh/src/code/z_common_data.c @@ -8,7 +8,7 @@ void SaveContext_Init(void) { gSaveContext.seqId = (u8)NA_BGM_DISABLED; gSaveContext.natureAmbienceId = NATURE_ID_DISABLED; gSaveContext.forcedSeqId = NA_BGM_GENERAL_SFX; - gSaveContext.nextCutsceneIndex = 0xFFEF; + gSaveContext.nextCutsceneIndex = CVar_GetS32("gBetaQuestWorld", 0xFFEF); gSaveContext.cutsceneTrigger = 0; gSaveContext.chamberCutsceneNum = 0; gSaveContext.nextDayTime = 0xFFFF; From 7978c55f7698dbd6b4eedd1347236ebb16b7bd55 Mon Sep 17 00:00:00 2001 From: Kenix3 Date: Sat, 30 Jul 2022 13:40:20 -0400 Subject: [PATCH 2/3] Fixes issue where lus was including a function from soh. --- libultraship/libultraship/ImGuiImpl.cpp | 13 ++++++++----- libultraship/libultraship/ImGuiImpl.h | 12 ++++++++++++ soh/soh/Enhancements/debugconsole.cpp | 4 ---- soh/src/code/z_play.c | 4 +++- 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/libultraship/libultraship/ImGuiImpl.cpp b/libultraship/libultraship/ImGuiImpl.cpp index 21870159f7f..3a87fcc29e3 100644 --- a/libultraship/libultraship/ImGuiImpl.cpp +++ b/libultraship/libultraship/ImGuiImpl.cpp @@ -68,7 +68,12 @@ OSContPad* pads; std::map DefaultAssets; std::vector emptyArgs; -extern bool IsInGamePlay(); +bool isBetaQuestEnabled = false; + +extern "C" { + void enableBetaQuest() { isBetaQuestEnabled = true; } + void disableBetaQuest() { isBetaQuestEnabled = false; } +} namespace SohImGui { @@ -1415,9 +1420,7 @@ namespace SohImGui { static int32_t betaQuestWorld = CVar_GetS32("gBetaQuestWorld", 0xFFEF); static int32_t lastBetaQuestWorld = betaQuestWorld; - bool isDisabled = !IsInGamePlay(); - - if (isDisabled) { + if (!isBetaQuestEnabled) { ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true); ImGui::PushStyleVar(ImGuiStyleVar_Alpha, ImGui::GetStyle().Alpha * 0.5f); } @@ -1472,7 +1475,7 @@ namespace SohImGui { needs_save = true; } - if (isDisabled) { + if (!isBetaQuestEnabled) { ImGui::PopItemFlag(); ImGui::PopStyleVar(); } diff --git a/libultraship/libultraship/ImGuiImpl.h b/libultraship/libultraship/ImGuiImpl.h index 580d5cdb619..7e8db07f794 100644 --- a/libultraship/libultraship/ImGuiImpl.h +++ b/libultraship/libultraship/ImGuiImpl.h @@ -1,5 +1,15 @@ #pragma once +#ifdef __cplusplus +extern "C" { +#endif + void enableBetaQuest(); + void disableBetaQuest(); +#ifdef __cplusplus +} +#endif + +#ifdef __cplusplus #include "GameOverlay.h" #include "Lib/ImGui/imgui.h" #include "Console.h" @@ -95,3 +105,5 @@ namespace SohImGui { void BeginGroupPanel(const char* name, const ImVec2 & size = ImVec2(0.0f, 0.0f)); void EndGroupPanel(float minHeight = 0.0f); } + +#endif \ No newline at end of file diff --git a/soh/soh/Enhancements/debugconsole.cpp b/soh/soh/Enhancements/debugconsole.cpp index 0a9409fb67f..eb2b02b115e 100644 --- a/soh/soh/Enhancements/debugconsole.cpp +++ b/soh/soh/Enhancements/debugconsole.cpp @@ -33,10 +33,6 @@ extern GlobalContext* gGlobalCtx; #define CMD_REGISTER SohImGui::BindCmd -bool IsInGamePlay() { - return gGlobalCtx != nullptr; -} - static bool ActorSpawnHandler(const std::vector& args) { if ((args.size() != 9) && (args.size() != 3) && (args.size() != 6)) { ERROR("Not enough arguments passed to actorspawn"); diff --git a/soh/src/code/z_play.c b/soh/src/code/z_play.c index 5656f4c07ef..763ed1ee85a 100644 --- a/soh/src/code/z_play.c +++ b/soh/src/code/z_play.c @@ -4,7 +4,7 @@ #include #include "soh/Enhancements/gameconsole.h" - +#include "../libultraship/ImGuiImpl.h" #include "soh/frame_interpolation.h" void* D_8012D1F0 = NULL; @@ -190,6 +190,7 @@ void Gameplay_Destroy(GameState* thisx) { KaleidoManager_Destroy(); ZeldaArena_Cleanup(); Fault_RemoveClient(&D_801614B8); + disableBetaQuest(); gGlobalCtx = NULL; } @@ -260,6 +261,7 @@ void GivePlayerRandoRewardSariaGift(GlobalContext* globalCtx, RandomizerCheck ch void Gameplay_Init(GameState* thisx) { GlobalContext* globalCtx = (GlobalContext*)thisx; GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + enableBetaQuest(); gGlobalCtx = globalCtx; //globalCtx->state.gfxCtx = NULL; uintptr_t zAlloc; From 6ce7393aaa16e2a9e52d578df0047b1825ca2bda Mon Sep 17 00:00:00 2001 From: Kenix3 Date: Sat, 30 Jul 2022 13:58:53 -0400 Subject: [PATCH 3/3] Limits beta quest to 0-8 --- libultraship/libultraship/ImGuiImpl.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libultraship/libultraship/ImGuiImpl.cpp b/libultraship/libultraship/ImGuiImpl.cpp index 3a87fcc29e3..4ec26ddd5ab 100644 --- a/libultraship/libultraship/ImGuiImpl.cpp +++ b/libultraship/libultraship/ImGuiImpl.cpp @@ -1441,21 +1441,26 @@ namespace SohImGui { ImGui::SameLine(); ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 7.0f); - ImGui::SliderInt("##BetaQuest", &betaQuestWorld, 0, 16, "", ImGuiSliderFlags_AlwaysClamp); + ImGui::SliderInt("##BetaQuest", &betaQuestWorld, 0, 8, "", ImGuiSliderFlags_AlwaysClamp); Tooltip("Set the Beta Quest world to explore. *WARNING* Changing this will reset your game.\nCtrl+Click to type in a value."); + ImGui::Text("After Slider Beta Quest World: %d", betaQuestWorld); + + ImGui::SameLine(); ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 7.0f); if (ImGui::Button(" + ##BetaQuest")) { betaQuestWorld++; } - if (betaQuestWorld > 16) { - betaQuestWorld = 16; + if (betaQuestWorld > 8) { + betaQuestWorld = 8; } else if (betaQuestWorld < 0) { betaQuestWorld = 0; } + + ImGui::Text("After Clamp Beta Quest World: %d", betaQuestWorld); } else { lastBetaQuestWorld = betaQuestWorld = 0xFFEF;