From d026b267e351a78bcf3cb3c72fe71f594e64b92c Mon Sep 17 00:00:00 2001 From: starburst Date: Wed, 4 May 2022 21:08:45 -0500 Subject: [PATCH] Save Entrance --- .../libultraship/GameSettings.cpp.rej | 19 ++++++++++++++ libultraship/libultraship/GameSettings.h.rej | 9 +++++++ libultraship/libultraship/SohImGuiImpl.cpp | 1 + .../libultraship/SohImGuiImpl.cpp.rej | 13 ++++++++++ soh/src/code/z_sram.c | 12 +++++++-- soh/src/code/z_sram.c.rej | 26 +++++++++++++++++++ 6 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 libultraship/libultraship/GameSettings.cpp.rej create mode 100644 libultraship/libultraship/GameSettings.h.rej create mode 100644 libultraship/libultraship/SohImGuiImpl.cpp.rej create mode 100644 soh/src/code/z_sram.c.rej diff --git a/libultraship/libultraship/GameSettings.cpp.rej b/libultraship/libultraship/GameSettings.cpp.rej new file mode 100644 index 000000000..0c088af21 --- /dev/null +++ b/libultraship/libultraship/GameSettings.cpp.rej @@ -0,0 +1,19 @@ +diff a/libultraship/libultraship/GameSettings.cpp b/libultraship/libultraship/GameSettings.cpp (rejected hunks) +@@ -75,6 +75,9 @@ namespace Game { + + Settings.enhancements.newdrops = stob(Conf[EnhancementSection]["newdrops"]); + CVar_SetS32("gNewDrops", Settings.enhancements.newdrops); ++ ++ Settings.enhancements.save_entrance = stob(Conf[EnhancementSection]["save_entrance"]); ++ CVar_SetS32("gSaveEntrance", Settings.enhancements.save_entrance); + + // Audio + Settings.audio.master = Ship::stof(Conf[AudioSection]["master"]); +@@ -184,6 +187,7 @@ namespace Game { + Conf[EnhancementSection]["newdrops"] = std::to_string(Settings.enhancements.newdrops); + Conf[EnhancementSection]["visualagony"] = std::to_string(Settings.enhancements.visualagony); + Conf[EnhancementSection]["mm_bunny_hood"] = std::to_string(Settings.enhancements.mm_bunny_hood); ++ Conf[EnhancementSection]["save_entrance"] = std::to_string(Settings.enhancements.save_entrance); + + + // Controllers diff --git a/libultraship/libultraship/GameSettings.h.rej b/libultraship/libultraship/GameSettings.h.rej new file mode 100644 index 000000000..b2ef7aa8d --- /dev/null +++ b/libultraship/libultraship/GameSettings.h.rej @@ -0,0 +1,9 @@ +diff a/libultraship/libultraship/GameSettings.h b/libultraship/libultraship/GameSettings.h (rejected hunks) +@@ -29,6 +29,7 @@ struct SoHConfigType { + bool newdrops = false; + bool visualagony = false; + bool mm_bunny_hood = false; ++ bool save_entrance = true; + + } enhancements; + diff --git a/libultraship/libultraship/SohImGuiImpl.cpp b/libultraship/libultraship/SohImGuiImpl.cpp index af5066159..d0deeb142 100644 --- a/libultraship/libultraship/SohImGuiImpl.cpp +++ b/libultraship/libultraship/SohImGuiImpl.cpp @@ -576,6 +576,7 @@ namespace SohImGui { EnhancementCheckbox("Minimal UI", "gMinimalUI"); EnhancementCheckbox("MM Bunny Hood", "gMMBunnyHood"); EnhancementCheckbox("Visual Stone of Agony", "gVisualAgony"); + EnhancementCheckbox("Save Last Entrance", "gSaveEntrance"); ImGui::Text("Graphics"); ImGui::Separator(); diff --git a/libultraship/libultraship/SohImGuiImpl.cpp.rej b/libultraship/libultraship/SohImGuiImpl.cpp.rej new file mode 100644 index 000000000..58148a9dc --- /dev/null +++ b/libultraship/libultraship/SohImGuiImpl.cpp.rej @@ -0,0 +1,13 @@ +diff a/libultraship/libultraship/SohImGuiImpl.cpp b/libultraship/libultraship/SohImGuiImpl.cpp (rejected hunks) +@@ -421,6 +421,11 @@ namespace SohImGui { + needs_save = true; + } + ++ if (ImGui::Checkbox("Save Last Entrance", &Game::Settings.enhancements.save_entrance)) { ++ CVar_SetS32("gSaveEntrance", Game::Settings.enhancements.save_entrance); ++ needs_save = true; ++ } ++ + ImGui::Text("Graphics"); + ImGui::Separator(); + diff --git a/soh/src/code/z_sram.c b/soh/src/code/z_sram.c index a774636f7..f8beff730 100644 --- a/soh/src/code/z_sram.c +++ b/soh/src/code/z_sram.c @@ -362,14 +362,22 @@ void Sram_OpenSave(SramContext* sramCtx) { case SCENE_GANON_DEMO: gSaveContext.entranceIndex = 0x41B; break; - - default: + case SCENE_KAKUSIANA: if (gSaveContext.savedSceneNum != SCENE_LINK_HOME) { gSaveContext.entranceIndex = (LINK_AGE_IN_YEARS == YEARS_CHILD) ? 0xBB : 0x5F4; } else { gSaveContext.entranceIndex = 0xBB; } break; + default: + if (!CVar_GetS32("gSaveEntrance", 0)) { + if (gSaveContext.savedSceneNum != SCENE_LINK_HOME) { + gSaveContext.entranceIndex = (LINK_AGE_IN_YEARS == YEARS_CHILD) ? 0xBB : 0x5F4; + } else { + gSaveContext.entranceIndex = 0xBB; + } + break; + } } osSyncPrintf("scene_no = %d\n", gSaveContext.entranceIndex); diff --git a/soh/src/code/z_sram.c.rej b/soh/src/code/z_sram.c.rej new file mode 100644 index 000000000..ce7d0449a --- /dev/null +++ b/soh/src/code/z_sram.c.rej @@ -0,0 +1,26 @@ +diff a/soh/src/code/z_sram.c b/soh/src/code/z_sram.c (rejected hunks) +@@ -362,14 +362,22 @@ void Sram_OpenSave(SramContext* sramCtx) { + case SCENE_GANON_DEMO: + gSaveContext.entranceIndex = 0x41B; + break; +- +- default: ++ case SCENE_KAKUSIANA: + if (gSaveContext.savedSceneNum != SCENE_LINK_HOME) { + gSaveContext.entranceIndex = (LINK_AGE_IN_YEARS == YEARS_CHILD) ? 0xBB : 0x5F4; + } else { + gSaveContext.entranceIndex = 0xBB; + } + break; ++ default: ++ if (!CVar_GetS32("gSaveEntrance", 0)) { ++ if (gSaveContext.savedSceneNum != SCENE_LINK_HOME) { ++ gSaveContext.entranceIndex = (LINK_AGE_IN_YEARS == YEARS_CHILD) ? 0xBB : 0x5F4; ++ } else { ++ gSaveContext.entranceIndex = 0xBB; ++ } ++ break; ++ } + } + + osSyncPrintf("scene_no = %d\n", gSaveContext.entranceIndex);