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:
@@ -104,6 +104,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
|
||||
|
||||
|
||||
@@ -959,8 +959,11 @@ static void __declspec(naked) sfxl_init_hook() {
|
||||
|
||||
static const int SampleRate = 44100; // 44.1kHz
|
||||
|
||||
static bool fadeBgMusic = false;
|
||||
|
||||
void Sound_OnAfterGameInit() {
|
||||
*ptr_sampleRate = SampleRate / 2; // Revert to 22kHz for secondary sound buffers
|
||||
if (fadeBgMusic) *(DWORD*)FO_VAR_gsound_background_fade = 1;
|
||||
}
|
||||
|
||||
void Sound_Init() {
|
||||
@@ -1040,6 +1043,13 @@ void Sound_Init() {
|
||||
const DWORD sfxlInitAddr[] = {0x4A9999, 0x4A9B34};
|
||||
HookCalls(sfxl_init_hook, sfxlInitAddr);
|
||||
}
|
||||
|
||||
if (GetConfigInt("Sound", "FadeBackgroundMusic", 1)) {
|
||||
SafeMemSet(0x45020C, CODETYPE_Nop, 6); // gsound_reset_
|
||||
SafeWrite32(0x45212C, 250); // delay start
|
||||
SafeWrite32(0x450ADE, 500); // delay stop
|
||||
fadeBgMusic = true;
|
||||
}
|
||||
}
|
||||
|
||||
void Sound_Exit() {
|
||||
|
||||
Reference in New Issue
Block a user