R5900: Fix LWL not sign extending in interpreter

This was zero extending because of the implicit promotion from
signed->unsigned, causing incorrect high bits in the GPR.

Funnily enough, this was noted in the source, but implemented
incorrectly.
This commit is contained in:
Connor McLaughlin 2021-09-09 17:36:36 +10:00 committed by refractionpcsx2
parent 9722bcd3c3
commit a8a50641f6
1 changed files with 4 additions and 4 deletions

View File

@ -595,13 +595,13 @@ void LWL()
s32 addr = cpuRegs.GPR.r[_Rs_].UL[0] + _Imm_; s32 addr = cpuRegs.GPR.r[_Rs_].UL[0] + _Imm_;
u32 shift = addr & 3; u32 shift = addr & 3;
// ensure the compiler does correct sign extension into 64 bits by using s32 u32 mem = memRead32(addr & ~3);
s32 mem = memRead32(addr & ~3);
if (!_Rt_) return; if (!_Rt_) return;
cpuRegs.GPR.r[_Rt_].SD[0] = (cpuRegs.GPR.r[_Rt_].SL[0] & LWL_MASK[shift]) | // ensure the compiler does correct sign extension into 64 bits by using s32
(mem << LWL_SHIFT[shift]); cpuRegs.GPR.r[_Rt_].SD[0] = (s32)((cpuRegs.GPR.r[_Rt_].UL[0] & LWL_MASK[shift]) |
(mem << LWL_SHIFT[shift]));
/* /*
Mem = 1234. Reg = abcd Mem = 1234. Reg = abcd