From 1a129abe0da5bd1ff51e2acf4aa14e5a5fe99b25 Mon Sep 17 00:00:00 2001 From: Pierre Bourdon Date: Tue, 27 Nov 2012 21:48:59 +0100 Subject: [PATCH] AUX return data should be mixed to main buffers, not AUX buffers. Fixes a regression introduced by r954c55e35afb, now EA games sound works again. --- .../Core/Src/HW/DSPHLE/UCodes/UCode_AX.cpp | 9 ++++--- .../Core/Src/HW/DSPHLE/UCodes/UCode_AXWii.cpp | 26 +++++++++++-------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_AX.cpp b/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_AX.cpp index e62e40735b..089e0c7933 100644 --- a/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_AX.cpp +++ b/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_AX.cpp @@ -405,9 +405,12 @@ void CUCode_AX::MixAUXSamples(int aux_id, u32 write_addr, u32 read_addr) // Then, we read the new temp from the CPU and add to our current // temp. int* ptr = (int*)HLEMemory_Get_Pointer(read_addr); - for (u32 i = 0; i < 3; ++i) - for (u32 j = 0; j < 5 * 32; ++j) - buffers[i][j] += (int)Common::swap32(*ptr++); + for (u32 i = 0; i < 5 * 32; ++i) + m_samples_left[i] += (int)Common::swap32(*ptr++); + for (u32 i = 0; i < 5 * 32; ++i) + m_samples_right[i] += (int)Common::swap32(*ptr++); + for (u32 i = 0; i < 5 * 32; ++i) + m_samples_surround[i] += (int)Common::swap32(*ptr++); } void CUCode_AX::UploadLRS(u32 dst_addr) diff --git a/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_AXWii.cpp b/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_AXWii.cpp index 3eadc5a840..42b2d510da 100644 --- a/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_AXWii.cpp +++ b/Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_AXWii.cpp @@ -252,8 +252,12 @@ void CUCode_AXWii::ProcessPBList(u32 pb_addr) void CUCode_AXWii::MixAUXSamples(int aux_id, u32 write_addr, u32 read_addr, u16 volume) { - int temp[3][3 * 32]; int* buffers[3] = { 0 }; + int* main_buffers[3] = { + m_samples_left, + m_samples_right, + m_samples_surround + }; switch (aux_id) { @@ -279,19 +283,19 @@ void CUCode_AXWii::MixAUXSamples(int aux_id, u32 write_addr, u32 read_addr, u16 // Send the content of AUX buffers to the CPU if (write_addr) { - for (u32 i = 0; i < 3 * 32; ++i) - for (u32 j = 0; j < 3; ++j) - temp[j][i] = Common::swap32(buffers[j][i]); - memcpy(HLEMemory_Get_Pointer(write_addr), temp, sizeof (temp)); + int* ptr = (int*)HLEMemory_Get_Pointer(write_addr); + for (u32 i = 0; i < 3; ++i) + for (u32 j = 0; j < 3 * 32; ++j) + *ptr++ = Common::swap32(buffers[i][j]); } - // Then read the buffers from the CPU and add to our current buffers. - memcpy(temp, HLEMemory_Get_Pointer(read_addr), sizeof (temp)); - for (u32 i = 0; i < 3 * 32; ++i) - for (u32 j = 0; j < 3; ++j) + // Then read the buffers from the CPU and add to our main buffers. + int* ptr = (int*)HLEMemory_Get_Pointer(read_addr); + for (u32 i = 0; i < 3; ++i) + for (u32 j = 0; j < 3 * 32; ++j) { - s64 new_val = buffers[j][i] + Common::swap32(temp[j][i]); - buffers[j][i] = (new_val * volume) >> 15; + s64 new_val = main_buffers[i][j] + Common::swap32(*ptr++); + main_buffers[i][j] = (new_val * volume) >> 15; } }