AUX return data should be mixed to main buffers, not AUX buffers. Fixes a regression introduced by r954c55e35afb, now EA games sound works again.

This commit is contained in:
Pierre Bourdon 2012-11-27 21:48:59 +01:00
commit 1a129abe0d
2 changed files with 21 additions and 14 deletions

View file

@ -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 // Then, we read the new temp from the CPU and add to our current
// temp. // temp.
int* ptr = (int*)HLEMemory_Get_Pointer(read_addr); int* ptr = (int*)HLEMemory_Get_Pointer(read_addr);
for (u32 i = 0; i < 3; ++i) for (u32 i = 0; i < 5 * 32; ++i)
for (u32 j = 0; j < 5 * 32; ++j) m_samples_left[i] += (int)Common::swap32(*ptr++);
buffers[i][j] += (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) void CUCode_AX::UploadLRS(u32 dst_addr)

View file

@ -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) 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* buffers[3] = { 0 };
int* main_buffers[3] = {
m_samples_left,
m_samples_right,
m_samples_surround
};
switch (aux_id) 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 // Send the content of AUX buffers to the CPU
if (write_addr) if (write_addr)
{ {
for (u32 i = 0; i < 3 * 32; ++i) int* ptr = (int*)HLEMemory_Get_Pointer(write_addr);
for (u32 j = 0; j < 3; ++j) for (u32 i = 0; i < 3; ++i)
temp[j][i] = Common::swap32(buffers[j][i]); for (u32 j = 0; j < 3 * 32; ++j)
memcpy(HLEMemory_Get_Pointer(write_addr), temp, sizeof (temp)); *ptr++ = Common::swap32(buffers[i][j]);
} }
// Then read the buffers from the CPU and add to our current buffers. // Then read the buffers from the CPU and add to our main buffers.
memcpy(temp, HLEMemory_Get_Pointer(read_addr), sizeof (temp)); int* ptr = (int*)HLEMemory_Get_Pointer(read_addr);
for (u32 i = 0; i < 3 * 32; ++i) for (u32 i = 0; i < 3; ++i)
for (u32 j = 0; j < 3; ++j) for (u32 j = 0; j < 3 * 32; ++j)
{ {
s64 new_val = buffers[j][i] + Common::swap32(temp[j][i]); s64 new_val = main_buffers[i][j] + Common::swap32(*ptr++);
buffers[j][i] = (new_val * volume) >> 15; main_buffers[i][j] = (new_val * volume) >> 15;
} }
} }