diff --git a/Source/Core/DSPCore/Src/DSPIntExtOps.cpp b/Source/Core/DSPCore/Src/DSPIntExtOps.cpp index 9e623fffdf..e707c4750d 100644 --- a/Source/Core/DSPCore/Src/DSPIntExtOps.cpp +++ b/Source/Core/DSPCore/Src/DSPIntExtOps.cpp @@ -121,7 +121,6 @@ void l(const UDSPInstruction& opc) u8 sreg = opc.hex & 0x3; u8 dreg = ((opc.hex >> 3) & 0x7) + DSP_REG_AXL0; - // 40bit sign extension if target is acm.D (important for zelda type ucodes) if ((dreg >= DSP_REG_ACM0) && (g_dsp.r[DSP_REG_SR] & SR_40_MODE_BIT)) { u16 val = dsp_dmem_read(g_dsp.r[sreg]); @@ -146,8 +145,19 @@ void ln(const UDSPInstruction& opc) u8 sreg = opc.hex & 0x3; u8 dreg = ((opc.hex >> 3) & 0x7) + DSP_REG_AXL0; - writeToBackLog(0, dreg, dsp_dmem_read(g_dsp.r[sreg])); - writeToBackLog(1, sreg, dsp_increase_addr_reg(sreg, (s16)g_dsp.r[DSP_REG_IX0 + sreg])); + if ((dreg >= DSP_REG_ACM0) && (g_dsp.r[DSP_REG_SR] & SR_40_MODE_BIT)) + { + u16 val = dsp_dmem_read(g_dsp.r[sreg]); + writeToBackLog(0, dreg - DSP_REG_ACM0 + DSP_REG_ACH0, (val & 0x8000) ? 0xFFFF : 0x0000); + writeToBackLog(1, dreg, val); + writeToBackLog(2, dreg - DSP_REG_ACM0 + DSP_REG_ACL0, 0); + writeToBackLog(3, sreg, dsp_increase_addr_reg(sreg, (s16)g_dsp.r[DSP_REG_IX0 + sreg])); + } + else + { + writeToBackLog(0, dreg, dsp_dmem_read(g_dsp.r[sreg])); + writeToBackLog(1, sreg, dsp_increase_addr_reg(sreg, (s16)g_dsp.r[DSP_REG_IX0 + sreg])); + } } // LS $axD.l, $acS.m diff --git a/Source/Core/DSPCore/Src/DspIntArithmetic.cpp b/Source/Core/DSPCore/Src/DspIntArithmetic.cpp index aa7b95b5d6..0e51e45a2e 100644 --- a/Source/Core/DSPCore/Src/DspIntArithmetic.cpp +++ b/Source/Core/DSPCore/Src/DspIntArithmetic.cpp @@ -58,15 +58,15 @@ void addaxl(const UDSPInstruction& opc) u8 sreg = (opc.hex >> 9) & 0x1; u8 dreg = (opc.hex >> 8) & 0x1; - s64 acc = dsp_get_long_acc(dreg); - s64 acx = dsp_get_ax_l(sreg); + u64 acc = (u64)dsp_get_long_acc(dreg); + u16 acx = (u16)dsp_get_ax_l(sreg); acc += acx; zeroWriteBackLog(); - dsp_set_long_acc(dreg, acc); - Update_SR_Register64(acc); + dsp_set_long_acc(dreg, (s64)acc); + Update_SR_Register64((s64)acc); } // TSTAXH $axR.h diff --git a/Source/Core/DSPCore/Src/DspIntMultiplier.cpp b/Source/Core/DSPCore/Src/DspIntMultiplier.cpp index 1a33280865..a671b6e710 100644 --- a/Source/Core/DSPCore/Src/DspIntMultiplier.cpp +++ b/Source/Core/DSPCore/Src/DspIntMultiplier.cpp @@ -184,8 +184,8 @@ void tstprod(const UDSPInstruction& opc) // secondary accumulator $axS (treat them both as signed). void mulc(const UDSPInstruction& opc) { - u8 sreg = (opc.hex >> 11) & 0x1; - u8 treg = (opc.hex >> 12) & 0x1; + u8 sreg = (opc.hex >> 12) & 0x1; + u8 treg = (opc.hex >> 11) & 0x1; u16 accm = dsp_get_acc_m(sreg); u16 axh = dsp_get_ax_h(treg); s64 prod = dsp_multiply(accm, axh);