diff --git a/MarathonRecomp/patches/audio_patches.cpp b/MarathonRecomp/patches/audio_patches.cpp index 13afebeac..538eda159 100644 --- a/MarathonRecomp/patches/audio_patches.cpp +++ b/MarathonRecomp/patches/audio_patches.cpp @@ -4,6 +4,7 @@ #include #include #include +#include int AudioPatches::m_isAttenuationSupported = -1; @@ -33,6 +34,7 @@ void AudioPatches::Update(float deltaTime) return; const float musicVolume = Config::MusicVolume * Config::MasterVolume; + if (Config::MusicAttenuation && CanAttenuate()) { auto time = 1.0f - expf(2.5f * -deltaTime); @@ -51,3 +53,38 @@ void AudioPatches::Update(float deltaTime) pAudioEngine->m_MusicVolume = musicVolume; } } + +// Update function for CRI cues. +// This hook fixes jingles fading the BGM back in prematurely. +PPC_FUNC_IMPL(__imp__sub_8260F168); +PPC_FUNC(sub_8260F168) +{ + struct CueParams + { + be Duration; + be FrameTime; + be Field08; + be Field0C; + be MusicVolume; + bool Field14; + }; + + auto pParams = (CueParams*)(base + ctx.r3.u32); + + pParams->FrameTime = App::s_deltaTime; + + __imp__sub_8260F168(ctx, base); +} + +void CriCueUpdateDeltaTimeFix(PPCRegister& deltaTime) +{ + deltaTime.f64 = App::s_deltaTime; +} + +void PowerUpJingleDurationFix(PPCRegister& duration) +{ + if (!Config::FixPowerUpJingleDuration) + return; + + duration.f64 = 20.0; +} diff --git a/MarathonRecomp/user/config_def.h b/MarathonRecomp/user/config_def.h index 7cd66ba08..86618f09f 100644 --- a/MarathonRecomp/user/config_def.h +++ b/MarathonRecomp/user/config_def.h @@ -77,6 +77,7 @@ CONFIG_DEFINE_HIDDEN("Codes", bool, DisableDWMRoundedCorners, false); CONFIG_DEFINE_HIDDEN("Codes", bool, DisableTitleInputDelay, false); CONFIG_DEFINE_HIDDEN("Codes", bool, HUDToggleKey, false); CONFIG_DEFINE_HIDDEN("Codes", bool, SkipIntroLogos, false); +CONFIG_DEFINE_HIDDEN("Codes", bool, FixPowerUpJingleDuration, false); CONFIG_DEFINE_HIDDEN("Codes", bool, UseOfficialTitleOnTitleBar, false); CONFIG_DEFINE_HIDDEN("Codes", bool, DisableLowResolutionFontOnCustomUI, false); CONFIG_DEFINE_HIDDEN("Codes", bool, RestoreContextualHUDColours, false); diff --git a/MarathonRecompLib/config/Marathon.toml b/MarathonRecompLib/config/Marathon.toml index bef3b84b4..1093ad279 100644 --- a/MarathonRecompLib/config/Marathon.toml +++ b/MarathonRecompLib/config/Marathon.toml @@ -209,3 +209,13 @@ jump_address_on_true = 0x82653840 name = "PostureControlRotationSpeedFix" address = 0x82201C6C registers = ["f1", "r1"] + +[[midasm_hook]] +name = "CriCueUpdateDeltaTimeFix" +address = 0x8260F238 +registers = ["f13"] + +[[midasm_hook]] +name = "PowerUpJingleDurationFix" +address = 0x8216CC28 +registers = ["f31"]