CPU/Recompiler: Fix a few incorrect calls to PGXP

Fixes PGXP not being effective in Grandia.
This commit is contained in:
Connor McLaughlin 2021-06-24 16:52:38 +10:00
parent 98f0e5908b
commit 2343696995
2 changed files with 15 additions and 9 deletions

View file

@ -1874,7 +1874,10 @@ bool CodeGenerator::Compile_Multiply(const CodeBlockInstruction& cbi)
Value rs = m_register_cache.ReadGuestRegister(cbi.instruction.r.rs); Value rs = m_register_cache.ReadGuestRegister(cbi.instruction.r.rs);
Value rt = m_register_cache.ReadGuestRegister(cbi.instruction.r.rt); Value rt = m_register_cache.ReadGuestRegister(cbi.instruction.r.rt);
if (g_settings.UsingPGXPCPUMode()) if (g_settings.UsingPGXPCPUMode())
EmitFunctionCall(nullptr, signed_multiply ? &PGXP::CPU_MULT : &PGXP::CPU_MULTU, rs, rt); {
EmitFunctionCall(nullptr, signed_multiply ? &PGXP::CPU_MULT : &PGXP::CPU_MULTU,
Value::FromConstantU32(cbi.instruction.bits), rs, rt);
}
std::pair<Value, Value> result = MulValues(rs, rt, signed_multiply); std::pair<Value, Value> result = MulValues(rs, rt, signed_multiply);
rs.ReleaseAndClear(); rs.ReleaseAndClear();
@ -1937,7 +1940,7 @@ bool CodeGenerator::Compile_Divide(const CodeBlockInstruction& cbi)
Value denom = m_register_cache.ReadGuestRegister(cbi.instruction.r.rt); Value denom = m_register_cache.ReadGuestRegister(cbi.instruction.r.rt);
if (g_settings.UsingPGXPCPUMode()) if (g_settings.UsingPGXPCPUMode())
EmitFunctionCall(nullptr, &PGXP::CPU_DIV, num, denom); EmitFunctionCall(nullptr, &PGXP::CPU_DIV, Value::FromConstantU32(cbi.instruction.bits), num, denom);
if (num.IsConstant() && denom.IsConstant()) if (num.IsConstant() && denom.IsConstant())
{ {
@ -1998,7 +2001,7 @@ bool CodeGenerator::Compile_SignedDivide(const CodeBlockInstruction& cbi)
Value denom = m_register_cache.ReadGuestRegister(cbi.instruction.r.rt); Value denom = m_register_cache.ReadGuestRegister(cbi.instruction.r.rt);
if (g_settings.UsingPGXPCPUMode()) if (g_settings.UsingPGXPCPUMode())
EmitFunctionCall(nullptr, &PGXP::CPU_DIVU, num, denom); EmitFunctionCall(nullptr, &PGXP::CPU_DIV, Value::FromConstantU32(cbi.instruction.bits), num, denom);
if (num.IsConstant() && denom.IsConstant()) if (num.IsConstant() && denom.IsConstant())
{ {

View file

@ -185,7 +185,7 @@ ALWAYS_INLINE_RELEASE void ValidateAndCopyMem(PGXP_value* dest, u32 addr, u32 va
*dest = PGXP_value_invalid; *dest = PGXP_value_invalid;
} }
static void ValidateAndCopyMem16(PGXP_value* dest, u32 addr, u32 value, int sign) ALWAYS_INLINE_RELEASE static void ValidateAndCopyMem16(PGXP_value* dest, u32 addr, u32 value, int sign)
{ {
u32 validMask = 0; u32 validMask = 0;
psx_value val, mask; psx_value val, mask;
@ -236,7 +236,7 @@ ALWAYS_INLINE_RELEASE void WriteMem(const PGXP_value* value, u32 addr)
*pMem = *value; *pMem = *value;
} }
static void WriteMem16(PGXP_value* src, u32 addr) ALWAYS_INLINE_RELEASE static void WriteMem16(const PGXP_value* src, u32 addr)
{ {
PGXP_value* dest = GetPtr(addr); PGXP_value* dest = GetPtr(addr);
psx_value* pVal = NULL; psx_value* pVal = NULL;
@ -599,16 +599,19 @@ void CPU_SB(u32 instr, u8 rtVal, u32 addr)
void CPU_SH(u32 instr, u16 rtVal, u32 addr) void CPU_SH(u32 instr, u16 rtVal, u32 addr)
{ {
PGXP_value* val = &CPU_reg[rt(instr)];
// validate and copy half value // validate and copy half value
MaskValidate(&CPU_reg[rt(instr)], rtVal, 0xFFFF, VALID_0); MaskValidate(val, rtVal, 0xFFFF, VALID_0);
WriteMem16(&CPU_reg[rt(instr)], addr); WriteMem16(val, addr);
} }
void CPU_SW(u32 instr, u32 rtVal, u32 addr) void CPU_SW(u32 instr, u32 rtVal, u32 addr)
{ {
// Mem[Rs + Im] = Rt // Mem[Rs + Im] = Rt
Validate(&CPU_reg[rt(instr)], rtVal); PGXP_value* val = &CPU_reg[rt(instr)];
WriteMem(&CPU_reg[rt(instr)], addr); Validate(val, rtVal);
WriteMem(val, addr);
} }
void CPU_MOVE(u32 rd_and_rs, u32 rsVal) void CPU_MOVE(u32 rd_and_rs, u32 rsVal)