Skip to content

Commit

Permalink
AUX return data should be mixed to main buffers, not AUX buffers. Fix…
Browse files Browse the repository at this point in the history
…es a regression introduced by r954c55e35afb, now EA games sound works again.
  • Loading branch information
delroth committed Nov 27, 2012
1 parent 9270b62 commit 1a129ab
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
9 changes: 6 additions & 3 deletions Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_AX.cpp
Expand Up @@ -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)
Expand Down
26 changes: 15 additions & 11 deletions Source/Core/Core/Src/HW/DSPHLE/UCodes/UCode_AXWii.cpp
Expand Up @@ -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)
{
Expand All @@ -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;
}
}

Expand Down

0 comments on commit 1a129ab

Please sign in to comment.