From f3924c2f8338a06f7f9df375330d0fba57c4aea3 Mon Sep 17 00:00:00 2001 From: aMannus Date: Wed, 8 May 2024 07:28:46 +0200 Subject: [PATCH] [Enhancement] Enable Suns Song (#262) * Enable Suns Song * Move Sun's Song to no longer check for save data at all * Update description * Address review comments --------- Co-authored-by: Archez --- mm/2s2h/BenGui/BenMenuBar.cpp | 10 ++++++++++ mm/2s2h/Enhancements/Enhancements.cpp | 3 +++ mm/2s2h/Enhancements/Enhancements.h | 1 + .../Enhancements/GameInteractor/GameInteractor.h | 1 + mm/2s2h/Enhancements/Songs/EnableSunsSong.cpp | 16 ++++++++++++++++ mm/2s2h/Enhancements/Songs/EnableSunsSong.h | 6 ++++++ mm/src/audio/code_8019AF00.c | 5 ++++- mm/src/code/z_message.c | 12 +++++++----- 8 files changed, 48 insertions(+), 6 deletions(-) create mode 100644 mm/2s2h/Enhancements/Songs/EnableSunsSong.cpp create mode 100644 mm/2s2h/Enhancements/Songs/EnableSunsSong.h diff --git a/mm/2s2h/BenGui/BenMenuBar.cpp b/mm/2s2h/BenGui/BenMenuBar.cpp index 527bb85d5..8d37b4233 100644 --- a/mm/2s2h/BenGui/BenMenuBar.cpp +++ b/mm/2s2h/BenGui/BenMenuBar.cpp @@ -382,6 +382,16 @@ void DrawEnhancementsMenu() { ImGui::EndMenu(); } + if (UIWidgets::BeginMenu("Songs")) { + UIWidgets::CVarCheckbox("Enable Sun's Song", "gEnhancements.Songs.EnableSunsSong", { + .tooltip = "Enables the partially implemented Sun's Song. RIGHT-DOWN-UP-RIGHT-DOWN-UP to play it. " + "This song will make time move very fast until either Link moves to a different scene, " + "or when the time switches to a new time period." + }); + + ImGui::EndMenu(); + } + if (mHudEditorWindow) { UIWidgets::WindowButton("Hud Editor", "gWindows.HudEditor", mHudEditorWindow, { .tooltip = "Enables the Hud Editor window, allowing you to edit your hud" diff --git a/mm/2s2h/Enhancements/Enhancements.cpp b/mm/2s2h/Enhancements/Enhancements.cpp index 65bddb64b..f00768e8c 100644 --- a/mm/2s2h/Enhancements/Enhancements.cpp +++ b/mm/2s2h/Enhancements/Enhancements.cpp @@ -16,6 +16,9 @@ void InitEnhancements() { // Minigames RegisterAlwaysWinDoggyRace(); + // Songs + RegisterEnableSunsSong(); + // Restorations RegisterSideRoll(); diff --git a/mm/2s2h/Enhancements/Enhancements.h b/mm/2s2h/Enhancements/Enhancements.h index c6035601b..56ed3c0c6 100644 --- a/mm/2s2h/Enhancements/Enhancements.h +++ b/mm/2s2h/Enhancements/Enhancements.h @@ -13,6 +13,7 @@ #include "Cutscenes/HideTitleCards.h" #include "Restorations/SideRoll.h" #include "Graphics/PlayAsKafei.h" +#include "Songs/EnableSunsSong.h" enum AlwaysWinDoggyRaceOptions { ALWAYS_WIN_DOGGY_RACE_OFF, diff --git a/mm/2s2h/Enhancements/GameInteractor/GameInteractor.h b/mm/2s2h/Enhancements/GameInteractor/GameInteractor.h index 07825a8d3..e72059282 100644 --- a/mm/2s2h/Enhancements/GameInteractor/GameInteractor.h +++ b/mm/2s2h/Enhancements/GameInteractor/GameInteractor.h @@ -37,6 +37,7 @@ typedef enum { GI_VB_SET_BLAST_MASK_COOLDOWN_TIMER, GI_VB_PATCH_SIDEROLL, GI_VB_PREVENT_MASK_TRANSFORMATION_CS, + GI_VB_SONG_AVAILABLE_TO_PLAY, } GIVanillaBehavior; #ifdef __cplusplus diff --git a/mm/2s2h/Enhancements/Songs/EnableSunsSong.cpp b/mm/2s2h/Enhancements/Songs/EnableSunsSong.cpp new file mode 100644 index 000000000..a75271b21 --- /dev/null +++ b/mm/2s2h/Enhancements/Songs/EnableSunsSong.cpp @@ -0,0 +1,16 @@ +#include +#include "Enhancements/GameInteractor/GameInteractor.h" + +extern "C" { + #include +} + +void RegisterEnableSunsSong() { + REGISTER_VB_SHOULD(GI_VB_SONG_AVAILABLE_TO_PLAY, { + uint8_t* songIndex = static_cast(opt); + // If the enhancement is on, and the currently played song is Sun's Song, set it to be available to be played. + if (CVarGetInteger("gEnhancements.Songs.EnableSunsSong", 0) && *songIndex == OCARINA_SONG_SUNS) { + *should = true; + } + }); +} diff --git a/mm/2s2h/Enhancements/Songs/EnableSunsSong.h b/mm/2s2h/Enhancements/Songs/EnableSunsSong.h new file mode 100644 index 000000000..6ce2b5342 --- /dev/null +++ b/mm/2s2h/Enhancements/Songs/EnableSunsSong.h @@ -0,0 +1,6 @@ +#ifndef SONGS_ENABLE_SUNS_SONG_H +#define SONGS_ENABLE_SUNS_SONG_H + +void RegisterEnableSunsSong(); + +#endif // SONGS_ENABLE_SUNS_SONG_H diff --git a/mm/src/audio/code_8019AF00.c b/mm/src/audio/code_8019AF00.c index 4b4d50899..f5a8aaf25 100644 --- a/mm/src/audio/code_8019AF00.c +++ b/mm/src/audio/code_8019AF00.c @@ -1,5 +1,7 @@ #include "global.h" +#include "Enhancements/GameInteractor/GameInteractor.h" + typedef struct { /* 0x0 */ s8 x; /* 0x1 */ s8 y; @@ -2551,7 +2553,8 @@ void AudioOcarina_CheckSongsWithoutMusicStaff(void) { // Loop through each of the songs for (songIndex = sFirstOcarinaSongIndex; songIndex < sLastOcarinaSongIndex; songIndex++) { // Checks to see if the song is available to be played - if ((u32)sOcarinaAvailableSongFlags & (1 << songIndex)) { + bool vanillaCondition = (u32)sOcarinaAvailableSongFlags & (1 << songIndex); + if (GameInteractor_Should(GI_VB_SONG_AVAILABLE_TO_PLAY, vanillaCondition, &songIndex)) { // Loops through all possible starting indices? // Loops through the notes of the song? for (j = 0, k = 0; (j < gOcarinaSongButtons[songIndex].numButtons) && (k == 0) && diff --git a/mm/src/code/z_message.c b/mm/src/code/z_message.c index b3a0c0010..aff05b005 100644 --- a/mm/src/code/z_message.c +++ b/mm/src/code/z_message.c @@ -4574,6 +4574,12 @@ void Message_DrawMain(PlayState* play, Gfx** gfxP) { msgCtx->songPlayed = msgCtx->ocarinaStaff->state; + bool vanillaOwnedSongCheck = (msgCtx->ocarinaStaff->state == OCARINA_SONG_SCARECROW_SPAWN) || + (msgCtx->ocarinaStaff->state == OCARINA_SONG_INVERTED_TIME) || + (msgCtx->ocarinaStaff->state == OCARINA_SONG_DOUBLE_TIME) || + (msgCtx->ocarinaStaff->state == OCARINA_SONG_GORON_LULLABY_INTRO) || + CHECK_QUEST_ITEM(QUEST_SONG_SONATA + msgCtx->ocarinaStaff->state); + if (msgCtx->ocarinaStaff->state <= OCARINA_SONG_SCARECROW_SPAWN) { if (msgCtx->ocarinaStaff->state == OCARINA_SONG_EVAN_PART1) { AudioOcarina_ResetAndReadInput(); @@ -4583,11 +4589,7 @@ void Message_DrawMain(PlayState* play, Gfx** gfxP) { AudioOcarina_SetOcarinaDisableTimer(0, 20); Message_CloseTextbox(play); play->msgCtx.ocarinaMode = OCARINA_MODE_PLAYED_FULL_EVAN_SONG; - } else if ((msgCtx->ocarinaStaff->state == OCARINA_SONG_SCARECROW_SPAWN) || - (msgCtx->ocarinaStaff->state == OCARINA_SONG_INVERTED_TIME) || - (msgCtx->ocarinaStaff->state == OCARINA_SONG_DOUBLE_TIME) || - (msgCtx->ocarinaStaff->state == OCARINA_SONG_GORON_LULLABY_INTRO) || - CHECK_QUEST_ITEM(QUEST_SONG_SONATA + msgCtx->ocarinaStaff->state)) { + } else if (GameInteractor_Should(GI_VB_SONG_AVAILABLE_TO_PLAY, vanillaOwnedSongCheck, &msgCtx->ocarinaStaff->state)) { sLastPlayedSong = msgCtx->ocarinaStaff->state; msgCtx->lastPlayedSong = msgCtx->ocarinaStaff->state; msgCtx->songPlayed = msgCtx->ocarinaStaff->state;