diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/AXWii.cpp b/Source/Core/Core/HW/DSPHLE/UCodes/AXWii.cpp index e0af6bbadd..6b01712bb3 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/AXWii.cpp +++ b/Source/Core/Core/HW/DSPHLE/UCodes/AXWii.cpp @@ -67,17 +67,22 @@ void AXWiiUCode::HandleCommandList() SetupProcessing(HILO_TO_32(addr)); break; - case CMD_ADD_TO_LR_OLD: - case CMD_SUB_TO_LR_OLD: + case CMD_ADD_ADD_1_TO_LR_OLD: addr_hi = m_cmdlist[curr_idx++]; addr_lo = m_cmdlist[curr_idx++]; - AddToLR(HILO_TO_32(addr), cmd == CMD_SUB_TO_LR_OLD); + AddAdd1ToLR(HILO_TO_32(addr)); break; - case CMD_ADD_SUB_TO_LR_OLD: + case CMD_SUB_ADD_1_TO_LR_OLD: addr_hi = m_cmdlist[curr_idx++]; addr_lo = m_cmdlist[curr_idx++]; - AddSubToLR(HILO_TO_32(addr)); + SubAdd1ToLR(HILO_TO_32(addr)); + break; + + case CMD_ADD_SUB_2_TO_LR_OLD: + addr_hi = m_cmdlist[curr_idx++]; + addr_lo = m_cmdlist[curr_idx++]; + AddSub2ToLR(HILO_TO_32(addr)); break; case CMD_PB_ADDR_OLD: @@ -168,17 +173,22 @@ void AXWiiUCode::HandleCommandList() SetupProcessing(HILO_TO_32(addr)); break; - case CMD_ADD_TO_LR: - case CMD_SUB_TO_LR: + case CMD_ADD_ADD_1_TO_LR: addr_hi = m_cmdlist[curr_idx++]; addr_lo = m_cmdlist[curr_idx++]; - AddToLR(HILO_TO_32(addr), cmd == CMD_SUB_TO_LR); + AddAdd1ToLR(HILO_TO_32(addr)); break; - case CMD_ADD_SUB_TO_LR: + case CMD_SUB_ADD_1_TO_LR: addr_hi = m_cmdlist[curr_idx++]; addr_lo = m_cmdlist[curr_idx++]; - AddSubToLR(HILO_TO_32(addr)); + SubAdd1ToLR(HILO_TO_32(addr)); + break; + + case CMD_ADD_SUB_2_TO_LR: + addr_hi = m_cmdlist[curr_idx++]; + addr_lo = m_cmdlist[curr_idx++]; + AddSub2ToLR(HILO_TO_32(addr)); break; case CMD_PROCESS: @@ -271,7 +281,7 @@ void AXWiiUCode::SetupProcessing(u32 init_addr) InitMixingBuffers<3 /*ms*/>(init_addr, buffers); } -void AXWiiUCode::AddToLR(u32 val_addr, bool neg) +void AXWiiUCode::AddAdd1ToLR(u32 val_addr) { auto& memory = m_dsphle->GetSystem().GetMemory(); int* ptr = reinterpret_cast(memory.GetPointerForRange(val_addr, 32 * 3 * sizeof(int))); @@ -279,14 +289,25 @@ void AXWiiUCode::AddToLR(u32 val_addr, bool neg) { int val = (int)Common::swap32(*ptr++); - m_samples_main_right[i] += val; - if (neg) - val = -val; m_samples_main_left[i] += val; + m_samples_main_right[i] += val; } } -void AXWiiUCode::AddSubToLR(u32 val_addr) +void AXWiiUCode::SubAdd1ToLR(u32 val_addr) +{ + auto& memory = m_dsphle->GetSystem().GetMemory(); + int* ptr = reinterpret_cast(memory.GetPointerForRange(val_addr, 32 * 3 * sizeof(int))); + for (int i = 0; i < 32 * 3; ++i) + { + int val = (int)Common::swap32(*ptr++); + + m_samples_main_left[i] -= val; + m_samples_main_right[i] += val; + } +} + +void AXWiiUCode::AddSub2ToLR(u32 val_addr) { auto& memory = m_dsphle->GetSystem().GetMemory(); int* ptr = reinterpret_cast(memory.GetPointerForRange(val_addr, 2 * 32 * 3 * sizeof(int))); diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/AXWii.h b/Source/Core/Core/HW/DSPHLE/UCodes/AXWii.h index b3c43b8012..6c63f2ff9b 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/AXWii.h +++ b/Source/Core/Core/HW/DSPHLE/UCodes/AXWii.h @@ -59,8 +59,9 @@ protected: void HandleCommandList() override; void SetupProcessing(u32 init_addr); - void AddToLR(u32 val_addr, bool neg); - void AddSubToLR(u32 val_addr); + void AddAdd1ToLR(u32 val_addr); + void SubAdd1ToLR(u32 val_addr); + void AddSub2ToLR(u32 val_addr); void ProcessPBList(u32 pb_addr); void MixAUXSamples(int aux_id, u32 write_addr, u32 read_addr, u16 volume); void UploadAUXMixLRSC(int aux_id, u32* addresses, u16 volume); @@ -74,9 +75,9 @@ private: enum CmdType { CMD_SETUP = 0x00, - CMD_ADD_TO_LR = 0x01, - CMD_SUB_TO_LR = 0x02, - CMD_ADD_SUB_TO_LR = 0x03, + CMD_ADD_ADD_1_TO_LR = 0x01, + CMD_SUB_ADD_1_TO_LR = 0x02, + CMD_ADD_SUB_2_TO_LR = 0x03, CMD_PROCESS = 0x04, CMD_MIX_AUXA = 0x05, CMD_MIX_AUXB = 0x06, @@ -96,9 +97,9 @@ private: enum CmdTypeOld { CMD_SETUP_OLD = 0x00, - CMD_ADD_TO_LR_OLD = 0x01, - CMD_SUB_TO_LR_OLD = 0x02, - CMD_ADD_SUB_TO_LR_OLD = 0x03, + CMD_ADD_ADD_1_TO_LR_OLD = 0x01, + CMD_SUB_ADD_1_TO_LR_OLD = 0x02, + CMD_ADD_SUB_2_TO_LR_OLD = 0x03, CMD_PB_ADDR_OLD = 0x04, CMD_PROCESS_OLD = 0x05, CMD_MIX_AUXA_OLD = 0x06,