Skip to content

Commit 9ab861e

Browse files
authored
Fix power up jingle fading in BGM prematurely at HFR (#120)
1 parent 2361db8 commit 9ab861e

3 files changed

Lines changed: 48 additions & 0 deletions

File tree

MarathonRecomp/patches/audio_patches.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <os/version.h>
55
#include <patches/audio_patches.h>
66
#include <user/config.h>
7+
#include <app.h>
78

89
int AudioPatches::m_isAttenuationSupported = -1;
910

@@ -33,6 +34,7 @@ void AudioPatches::Update(float deltaTime)
3334
return;
3435

3536
const float musicVolume = Config::MusicVolume * Config::MasterVolume;
37+
3638
if (Config::MusicAttenuation && CanAttenuate())
3739
{
3840
auto time = 1.0f - expf(2.5f * -deltaTime);
@@ -51,3 +53,38 @@ void AudioPatches::Update(float deltaTime)
5153
pAudioEngine->m_MusicVolume = musicVolume;
5254
}
5355
}
56+
57+
// Update function for CRI cues.
58+
// This hook fixes jingles fading the BGM back in prematurely.
59+
PPC_FUNC_IMPL(__imp__sub_8260F168);
60+
PPC_FUNC(sub_8260F168)
61+
{
62+
struct CueParams
63+
{
64+
be<float> Duration;
65+
be<float> FrameTime;
66+
be<float> Field08;
67+
be<float> Field0C;
68+
be<float> MusicVolume;
69+
bool Field14;
70+
};
71+
72+
auto pParams = (CueParams*)(base + ctx.r3.u32);
73+
74+
pParams->FrameTime = App::s_deltaTime;
75+
76+
__imp__sub_8260F168(ctx, base);
77+
}
78+
79+
void CriCueUpdateDeltaTimeFix(PPCRegister& deltaTime)
80+
{
81+
deltaTime.f64 = App::s_deltaTime;
82+
}
83+
84+
void PowerUpJingleDurationFix(PPCRegister& duration)
85+
{
86+
if (!Config::FixPowerUpJingleDuration)
87+
return;
88+
89+
duration.f64 = 20.0;
90+
}

MarathonRecomp/user/config_def.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ CONFIG_DEFINE_HIDDEN("Codes", bool, DisableDWMRoundedCorners, false);
7777
CONFIG_DEFINE_HIDDEN("Codes", bool, DisableTitleInputDelay, false);
7878
CONFIG_DEFINE_HIDDEN("Codes", bool, HUDToggleKey, false);
7979
CONFIG_DEFINE_HIDDEN("Codes", bool, SkipIntroLogos, false);
80+
CONFIG_DEFINE_HIDDEN("Codes", bool, FixPowerUpJingleDuration, false);
8081
CONFIG_DEFINE_HIDDEN("Codes", bool, UseOfficialTitleOnTitleBar, false);
8182
CONFIG_DEFINE_HIDDEN("Codes", bool, DisableLowResolutionFontOnCustomUI, false);
8283
CONFIG_DEFINE_HIDDEN("Codes", bool, RestoreContextualHUDColours, false);

MarathonRecompLib/config/Marathon.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,3 +209,13 @@ jump_address_on_true = 0x82653840
209209
name = "PostureControlRotationSpeedFix"
210210
address = 0x82201C6C
211211
registers = ["f1", "r1"]
212+
213+
[[midasm_hook]]
214+
name = "CriCueUpdateDeltaTimeFix"
215+
address = 0x8260F238
216+
registers = ["f13"]
217+
218+
[[midasm_hook]]
219+
name = "PowerUpJingleDurationFix"
220+
address = 0x8216CC28
221+
registers = ["f31"]

0 commit comments

Comments
 (0)