From 3a58763af93611f22c971191220c44cf10e2c0f1 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Sat, 4 May 2024 23:12:34 +0200 Subject: [PATCH] port Sound_Shutdown --- docs/progress.svg | 16 ++++++++-------- docs/progress.txt | 2 +- src/game/sound.c | 13 +++++++++++++ src/game/sound.h | 1 + src/global/funcs.h | 1 - src/inject_exec.c | 1 + 6 files changed, 24 insertions(+), 10 deletions(-) diff --git a/docs/progress.svg b/docs/progress.svg index 731e886..9535115 100644 --- a/docs/progress.svg +++ b/docs/progress.svg @@ -69,10 +69,10 @@ Tomb2.exe progress according to the physical function order: -37.36% (455) · 60.18% (733) · 0.41% (5) · 2.05% (25) +37.44% (456) · 60.10% (732) · 0.41% (5) · 2.05% (25) - - + + @@ -804,7 +804,7 @@ void __cdecl Sound_Effect(int32_t sample_id, const XYZ_32 *pos, uint32_t flags); void __cdecl Sound_StopEffect(int32_t sample_id); void __cdecl Sound_EndScene(void); -void __cdecl Sound_Shutdown(void); +void __cdecl Sound_Shutdown(void); void __cdecl Sound_Init(void); int32_t __cdecl TestCollision(ITEM_INFO *item, ITEM_INFO *lara_item); int32_t __cdecl GetSpheres(ITEM_INFO *item, SPHERE *ptr, int32_t world_space); @@ -1299,10 +1299,10 @@ Tomb2.exe progress according to the function sizes: -35.31% · 64.36% · 0% · 0.32% +35.32% · 64.35% · 0% · 0.32% - - + + @@ -2353,7 +2353,7 @@ void __cdecl Control_TriggerMusicTrack(int16_t value, int16_t flags, int16_t type); void __cdecl AssaultStart(ITEM_INFO *item); void __cdecl RemoveInventoryText(void); -void __cdecl Sound_Shutdown(void); +void __cdecl Sound_Shutdown(void); int16_t __cdecl Text_GetTextLength(const char *text); bool __cdecl DInputEnumDevices(JOYSTICK_LIST *joystickList); void __cdecl HWR_TexSource(HWR_TEX_HANDLE tex_source); diff --git a/docs/progress.txt b/docs/progress.txt index 93d9f77..fbba4c7 100644 --- a/docs/progress.txt +++ b/docs/progress.txt @@ -2838,7 +2838,7 @@ typedef enum { 0x0043F3C0 0x0484 + void __cdecl Sound_Effect(int32_t sample_id, const XYZ_32 *pos, uint32_t flags); 0x0043F860 0x005E + void __cdecl Sound_StopEffect(int32_t sample_id); 0x0043F8C0 0x0086 + void __cdecl Sound_EndScene(void); -0x0043F950 0x0024 - void __cdecl Sound_Shutdown(void); +0x0043F950 0x0024 + void __cdecl Sound_Shutdown(void); 0x0043F980 0x002A * void __cdecl Sound_Init(void); # game/sphere.c diff --git a/src/game/sound.c b/src/game/sound.c index 12ed232..d199fea 100644 --- a/src/game/sound.c +++ b/src/game/sound.c @@ -263,3 +263,16 @@ void __cdecl Sound_EndScene(void) } } } + +void __cdecl Sound_Shutdown(void) +{ + if (!g_SoundIsActive) { + return; + } + + S_Audio_Sample_OutCloseAllTracks(); + for (int32_t i = 0; i < SOUND_MAX_SLOTS; i++) { + SOUND_SLOT *const slot = &g_SoundSlots[i]; + slot->sample_num = -1; + } +} diff --git a/src/game/sound.h b/src/game/sound.h index 214a190..55b70ca 100644 --- a/src/game/sound.h +++ b/src/game/sound.h @@ -7,3 +7,4 @@ void __cdecl Sound_UpdateEffects(void); void __cdecl Sound_Effect(int32_t sample_id, const XYZ_32 *pos, uint32_t flags); void __cdecl Sound_StopEffect(int32_t sample_id); void __cdecl Sound_EndScene(void); +void __cdecl Sound_Shutdown(void); diff --git a/src/global/funcs.h b/src/global/funcs.h index 241aa3c..fdfaa65 100644 --- a/src/global/funcs.h +++ b/src/global/funcs.h @@ -400,7 +400,6 @@ #define SkidmanPush ((void __cdecl (*)(ITEM_INFO *item, ITEM_INFO *lara_item, int32_t radius))0x0043F1D0) #define SkidmanCollision ((void __cdecl (*)(int16_t item_num, ITEM_INFO *lara_item, COLL_INFO *coll))0x0043F2F0) #define Music_GetRealTrack ((int32_t __cdecl (*)(int32_t track))0x0043F380) -#define Sound_Shutdown ((void __cdecl (*)(void))0x0043F950) #define Sound_Init ((void __cdecl (*)(void))0x0043F980) #define TestCollision ((int32_t __cdecl (*)(ITEM_INFO *item, ITEM_INFO *lara_item))0x0043F9B0) #define GetSpheres ((int32_t __cdecl (*)(ITEM_INFO *item, SPHERE *ptr, int32_t world_space))0x0043FAE0) diff --git a/src/inject_exec.c b/src/inject_exec.c index 567e744..fe2fa81 100644 --- a/src/inject_exec.c +++ b/src/inject_exec.c @@ -304,6 +304,7 @@ static void Inject_Sound(const bool enable) INJECT(enable, 0x0043F3C0, Sound_Effect); INJECT(enable, 0x0043F860, Sound_StopEffect); INJECT(enable, 0x0043F8C0, Sound_EndScene); + INJECT(enable, 0x0043F950, Sound_Shutdown); } static void Inject_Overlay(const bool enable)