From da1bf29722a76981394e91eb0cb47c13b0244d3a Mon Sep 17 00:00:00 2001 From: Tillmann Karras Date: Thu, 16 Nov 2023 21:40:01 +0000 Subject: [PATCH] AX: fix envelope volume for Wii ucodes Technically it is signed in the 0x7699af32 ucode but that's only used by the Wii Startup Disc which never uses negative values. --- Source/Core/Core/HW/DSPHLE/UCodes/AXVoice.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/AXVoice.h b/Source/Core/Core/HW/DSPHLE/UCodes/AXVoice.h index 1d8d957828..68ea99a9f6 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/AXVoice.h +++ b/Source/Core/Core/HW/DSPHLE/UCodes/AXVoice.h @@ -424,7 +424,14 @@ void ProcessVoice(PB_TYPE& pb, const AXBuffers& buffers, u16 count, AXMixControl // Apply a global volume ramp using the volume envelope parameters. for (u32 i = 0; i < count; ++i) { - const s32 sample = ((s32)samples[i] * pb.vol_env.cur_volume) >> 15; +#ifdef AX_GC + // signed on GameCube + const s32 volume = (s16)pb.vol_env.cur_volume; +#else + // unsigned on Wii + const s32 volume = (u16)pb.vol_env.cur_volume; +#endif + const s32 sample = ((s32)samples[i] * volume) >> 15; samples[i] = std::clamp(sample, -32767, 32767); // -32768 ? pb.vol_env.cur_volume += pb.vol_env.cur_volume_delta; }