mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Added FadeBackgroundMusic option
This commit is contained in:
@@ -131,6 +131,9 @@ WorldMapTerrainInfo=0
|
||||
;Set to 0 to leave the default unchanged (i.e. 4). The maximum is 32
|
||||
NumSoundBuffers=0
|
||||
|
||||
;Set to 1 to enable fade effects for background music when stopping and starting the playback
|
||||
FadeBackgroundMusic=1
|
||||
|
||||
;Set to 1 to allow attaching sound files to combat float messages
|
||||
AllowSoundForFloats=0
|
||||
|
||||
|
||||
+12
-1
@@ -950,7 +950,9 @@ constexpr int SampleRate = 44100; // 44.1kHz
|
||||
void Sound::init() {
|
||||
// Set the 44.1kHz sample rate for the primary sound buffer
|
||||
SafeWrite32(0x44FDBC, SampleRate);
|
||||
LoadGameHook::OnAfterGameInit() += []() { fo::var::sampleRate = SampleRate / 2; }; // Revert to 22kHz for secondary sound buffers
|
||||
LoadGameHook::OnAfterGameInit() += []() {
|
||||
fo::var::sampleRate = SampleRate / 2; // Revert to 22kHz for secondary sound buffers
|
||||
};
|
||||
|
||||
LoadGameHook::OnGameReset() += WipeSounds;
|
||||
LoadGameHook::OnBeforeGameClose() += WipeSounds;
|
||||
@@ -1024,6 +1026,15 @@ void Sound::init() {
|
||||
if (IniReader::GetConfigInt("Sound", "AutoSearchSFX", 1)) {
|
||||
HookCalls(sfxl_init_hook, {0x4A9999, 0x4A9B34});
|
||||
}
|
||||
|
||||
if (IniReader::GetConfigInt("Sound", "FadeBackgroundMusic", 1)) {
|
||||
SafeMemSet(0x45020C, CodeType::Nop, 6); // gsound_reset_
|
||||
SafeWrite32(0x45212C, 250); // delay start
|
||||
SafeWrite32(0x450ADE, 500); // delay stop
|
||||
LoadGameHook::OnAfterGameInit() += []() {
|
||||
*(DWORD*)FO_VAR_gsound_background_fade = 1;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
void Sound::exit() {
|
||||
|
||||
Reference in New Issue
Block a user