From 9093b42d477ade250bd73978ddb28d349b96abb5 Mon Sep 17 00:00:00 2001 From: zilmar Date: Mon, 6 Mar 2023 20:58:47 +1030 Subject: [PATCH] Core: improve the accuracy of COP1_S_SUB --- .../N64System/Interpreter/InterpreterOps.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Source/Project64-core/N64System/Interpreter/InterpreterOps.cpp b/Source/Project64-core/N64System/Interpreter/InterpreterOps.cpp index aee0073f6..427f6114d 100644 --- a/Source/Project64-core/N64System/Interpreter/InterpreterOps.cpp +++ b/Source/Project64-core/N64System/Interpreter/InterpreterOps.cpp @@ -2127,8 +2127,22 @@ void R4300iOp::COP1_S_SUB() { return; } + _FPCR[31] &= ~0x0003F000; + fesetround(*_RoundingModel); + feclearexcept(FE_ALL_EXCEPT); + + if (!CheckFPUInput32(*(float *)_FPR_S[m_Opcode.fs]) || !CheckFPUInput32(*(float *)_FPR_S[m_Opcode.ft])) + { + return; + } + float Result = (*(float *)_FPR_S[m_Opcode.fs] - *(float *)_FPR_S[m_Opcode.ft]); + if (CheckFPUException() || CheckFPUResult32(Result)) + { + return; + } + *(uint32_t *)_FPR_S[m_Opcode.fd] = *(uint32_t *)&Result; + fesetround(*_RoundingModel); - *(float *)_FPR_S[m_Opcode.fd] = (*(float *)_FPR_S[m_Opcode.fs] - *(float *)_FPR_S[m_Opcode.ft]); } void R4300iOp::COP1_S_MUL()