diff --git a/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp b/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp index 0b1e9c346..5715b75ff 100644 --- a/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp +++ b/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp @@ -7494,7 +7494,14 @@ void CX86RecompilerOps::COP1_CF() } m_RegWorkingSet.Map_GPR_32bit(m_Opcode.rt, true, -1); - m_Assembler.MoveVariableToX86reg(m_RegWorkingSet.GetMipsRegMapLo(m_Opcode.rt), &m_Reg.m_FPCR[m_Opcode.fs], CRegName::FPR_Ctrl[m_Opcode.fs]); + if (m_Opcode.fs == 31 && m_RegWorkingSet.IsFPStatusRegMapped()) + { + m_Assembler.mov(m_RegWorkingSet.GetMipsRegMapLo(m_Opcode.rt), m_RegWorkingSet.Map_FPStatusReg()); + } + else + { + m_Assembler.MoveVariableToX86reg(m_RegWorkingSet.GetMipsRegMapLo(m_Opcode.rt), &m_Reg.m_FPCR[m_Opcode.fs], CRegName::FPR_Ctrl[m_Opcode.fs]); + } } void CX86RecompilerOps::COP1_MT() diff --git a/Source/Project64-core/N64System/Recompiler/x86/x86RegInfo.cpp b/Source/Project64-core/N64System/Recompiler/x86/x86RegInfo.cpp index b72eb71bc..b7049ea1b 100644 --- a/Source/Project64-core/N64System/Recompiler/x86/x86RegInfo.cpp +++ b/Source/Project64-core/N64System/Recompiler/x86/x86RegInfo.cpp @@ -596,6 +596,18 @@ const asmjit::x86::St & CX86RegInfo::StackPosition(int32_t Reg) return Unknown; } +bool CX86RegInfo::IsFPStatusRegMapped() +{ + for (int32_t i = 0, n = x86RegIndex_Size; i < n; i++) + { + if (GetX86Mapped((x86RegIndex)i) == FPStatusReg_Mapped) + { + return true; + } + } + return false; +} + asmjit::x86::Gp CX86RegInfo::FreeX86Reg() { if (GetX86Mapped(x86RegIndex_EDI) == NotMapped && !GetX86Protected(x86RegIndex_EDI)) diff --git a/Source/Project64-core/N64System/Recompiler/x86/x86RegInfo.h b/Source/Project64-core/N64System/Recompiler/x86/x86RegInfo.h index 95bf3c403..d75873180 100644 --- a/Source/Project64-core/N64System/Recompiler/x86/x86RegInfo.h +++ b/Source/Project64-core/N64System/Recompiler/x86/x86RegInfo.h @@ -91,6 +91,7 @@ public: void UnMap_FPR(int32_t Reg, bool WriteBackValue); const asmjit::x86::St & StackPosition(int32_t Reg); + bool IsFPStatusRegMapped(); asmjit::x86::Gp FreeX86Reg(); asmjit::x86::Gp Free8BitX86Reg(); void Map_GPR_32bit(int32_t MipsReg, bool SignValue, int32_t MipsRegToLoad);