From a35d5ec02342b3f6ef900f28e9b31774a49e8df4 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Wed, 4 Oct 2023 21:01:02 +0200 Subject: [PATCH] port Sound_SetMasterVolume --- docs/progress.svg | 14 +++++++------- docs/progress.txt | 2 +- meson.build | 1 + src/game/sound.c | 8 ++++++++ src/game/sound.h | 5 +++++ src/global/funcs.h | 1 - src/inject_exec.c | 10 +++++++++- 7 files changed, 31 insertions(+), 10 deletions(-) create mode 100644 src/game/sound.c create mode 100644 src/game/sound.h diff --git a/docs/progress.svg b/docs/progress.svg index 97f1586..7b3ad6c 100644 --- a/docs/progress.svg +++ b/docs/progress.svg @@ -69,10 +69,10 @@ Tomb2.exe progress according to the physical function order: -2.33% (28) · 95.25% (1143) · 0.67% (8) · 1.75% (21) +2.42% (29) · 95.17% (1142) · 0.67% (8) · 1.75% (21) - - + + @@ -1193,7 +1193,7 @@ int32_t __cdecl S_Audio_Sample_OutPlayLooped(int32_t track_id, uint16_t volume, int32_t pitch, int32_t pan); void __cdecl S_Audio_Sample_OutSetPanAndVolume(int32_t track_id, int32_t pan, uint16_t volume); void __cdecl S_Audio_Sample_OutSetPitch(int32_t track_id, int32_t pitch); -void __cdecl Sound_SetMasterVolume(int32_t volume); +void __cdecl Sound_SetMasterVolume(int32_t volume); void __cdecl S_Audio_Sample_OutCloseTrack(int32_t track_id); void __cdecl S_Audio_Sample_OutCloseAllTracks(void); BOOL __cdecl S_Audio_Sample_OutIsTrackPlaying(int32_t track_id); @@ -1283,8 +1283,8 @@ Tomb2.exe progress according to the function sizes: 2.91% · 96.76% · 0.02% · 0.31% - - + + @@ -2461,7 +2461,7 @@ void __cdecl SeedRandomDraw(int32_t seed); void __cdecl SE_SoundAdapterSet(HWND hwndDlg, SOUND_ADAPTER_NODE *adapter); void __cdecl SE_ControlsJoystickSet(HWND hwndDlg, JOYSTICK_NODE *joystick); -void __cdecl Sound_SetMasterVolume(int32_t volume); +void __cdecl Sound_SetMasterVolume(int32_t volume); void __cdecl invisibility_on(struct ITEM_INFO *item); void __cdecl dynamic_light_on(struct ITEM_INFO *item); void __cdecl WinVidClearMinWindowSize(void); diff --git a/docs/progress.txt b/docs/progress.txt index 4bf42bb..ef79f71 100644 --- a/docs/progress.txt +++ b/docs/progress.txt @@ -2077,7 +2077,7 @@ typedef struct CINE_FRAME { 004552D0 00000046 - int32_t __cdecl S_Audio_Sample_OutPlayLooped(int32_t track_id, uint16_t volume, int32_t pitch, int32_t pan); 00455320 00000039 - void __cdecl S_Audio_Sample_OutSetPanAndVolume(int32_t track_id, int32_t pan, uint16_t volume); 00455360 0000001C - void __cdecl S_Audio_Sample_OutSetPitch(int32_t track_id, int32_t pitch); -00455380 0000000A - void __cdecl Sound_SetMasterVolume(int32_t volume); +00455380 0000000A + void __cdecl Sound_SetMasterVolume(int32_t volume); 00455390 00000017 - void __cdecl S_Audio_Sample_OutCloseTrack(int32_t track_id); 004553B0 0000003C - void __cdecl S_Audio_Sample_OutCloseAllTracks(void); 004553C0 0000001F - BOOL __cdecl S_Audio_Sample_OutIsTrackPlaying(int32_t track_id); diff --git a/meson.build b/meson.build index 4db536c..db0f546 100644 --- a/meson.build +++ b/meson.build @@ -78,6 +78,7 @@ dll_sources = [ 'src/game/math.c', 'src/game/matrix.c', 'src/game/shell.c', + 'src/game/sound.c', 'src/inject_exec.c', 'src/inject_util.c', 'src/log.c', diff --git a/src/game/sound.c b/src/game/sound.c new file mode 100644 index 0000000..69b325d --- /dev/null +++ b/src/game/sound.c @@ -0,0 +1,8 @@ +#include "game/sound.h" + +#include "global/vars.h" + +void __cdecl Sound_SetMasterVolume(int32_t volume) +{ + g_MasterVolume = volume; +} diff --git a/src/game/sound.h b/src/game/sound.h new file mode 100644 index 0000000..9615c80 --- /dev/null +++ b/src/game/sound.h @@ -0,0 +1,5 @@ +#pragma once + +#include "global/types.h" + +void __cdecl Sound_SetMasterVolume(int32_t volume); diff --git a/src/global/funcs.h b/src/global/funcs.h index 33e02a5..d4da38e 100644 --- a/src/global/funcs.h +++ b/src/global/funcs.h @@ -1069,7 +1069,6 @@ #define S_Audio_Sample_OutPlayLooped ((int32_t __cdecl (*)(int32_t track_id, uint16_t volume, int32_t pitch, int32_t pan))0x004552D0) #define S_Audio_Sample_OutSetPanAndVolume ((void __cdecl (*)(int32_t track_id, int32_t pan, uint16_t volume))0x00455320) #define S_Audio_Sample_OutSetPitch ((void __cdecl (*)(int32_t track_id, int32_t pitch))0x00455360) -#define Sound_SetMasterVolume ((void __cdecl (*)(int32_t volume))0x00455380) #define S_Audio_Sample_OutCloseTrack ((void __cdecl (*)(int32_t track_id))0x00455390) #define S_Audio_Sample_OutCloseAllTracks ((void __cdecl (*)(void))0x004553B0) #define S_Audio_Sample_OutIsTrackPlaying ((BOOL __cdecl (*)(int32_t track_id))0x004553C0) diff --git a/src/inject_exec.c b/src/inject_exec.c index f58596f..41ea3ac 100644 --- a/src/inject_exec.c +++ b/src/inject_exec.c @@ -4,12 +4,14 @@ #include "game/math.h" #include "game/matrix.h" #include "game/shell.h" +#include "game/sound.h" #include "inject_util.h" static void Inject_Camera(void); static void Inject_Math(void); static void Inject_Matrix(void); static void Inject_Shell(void); +static void Inject_Sound(void); static void Inject_Camera(void) { @@ -54,10 +56,16 @@ static void Inject_Shell(void) INJECT(1, 0x0044E890, Shell_ExitSystem); } +static void Inject_Sound(void) +{ + INJECT(1, 0x00455380, Sound_SetMasterVolume); +} + void Inject_Exec(void) { Inject_Camera(); - Inject_Matrix(); Inject_Math(); + Inject_Matrix(); Inject_Shell(); + Inject_Sound(); }