From c41edc94c2898e72213b2ded8ddb74a8042feced Mon Sep 17 00:00:00 2001 From: ramapcsx2 Date: Fri, 12 Dec 2008 19:03:16 +0000 Subject: [PATCH] Huge precision improvements for FPU. Add and Sub now calculate the same values as on the ps2. Mul is now closer to the ps2. This commit fixes Tales of the Abyss, Rogue Galaxy and possibly many others :) git-svn-id: http://pcsx2-playground.googlecode.com/svn/trunk@420 a6443dda-0b58-4228-96e9-037be469359c --- pcsx2/windows/VCprojects/pcsx2_2005.vcproj | 4 ++++ pcsx2/x86/iFPU.c | 14 +++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/pcsx2/windows/VCprojects/pcsx2_2005.vcproj b/pcsx2/windows/VCprojects/pcsx2_2005.vcproj index 9489b01512..f9d34e9f61 100644 --- a/pcsx2/windows/VCprojects/pcsx2_2005.vcproj +++ b/pcsx2/windows/VCprojects/pcsx2_2005.vcproj @@ -694,6 +694,10 @@ RelativePath="..\..\Patch.h" > + + diff --git a/pcsx2/x86/iFPU.c b/pcsx2/x86/iFPU.c index 36766921cd..e6c7735523 100644 --- a/pcsx2/x86/iFPU.c +++ b/pcsx2/x86/iFPU.c @@ -84,6 +84,10 @@ static u32 PCSX2_ALIGNED16(s_pos[4]) = { 0x7fffffff, 0xffffffff, 0xffffffff, 0xf static u32 fpucw = 0x007f; static u32 fpucws = 0; +static u32 chop = 0x0000FFC0; +static u32 nearest = 0x00009FC0; //might use the global one later + + void recCOP1_BC1() { recCP1BC1[_Rt_](); @@ -641,7 +645,9 @@ int recCommutativeOp(int info, int regd, int op) void recADD_S_xmm(int info) { //AND32ItoM((uptr)&fpuRegs.fprc[31], ~(FPUflagO|FPUflagU)); // Clear O and U flags + SSE_LDMXCSR ((uptr)&chop); ClampValues2(recCommutativeOp(info, EEREC_D, 0)); + SSE_LDMXCSR ((uptr)&nearest); //REC_FPUOP(ADD_S); } @@ -1513,7 +1519,9 @@ FPURECOMPILE_CONSTCODE(MSUBA_S, XMMINFO_WRITEACC|XMMINFO_READACC|XMMINFO_READS|X void recMUL_S_xmm(int info) { //AND32ItoM((uptr)&fpuRegs.fprc[31], ~(FPUflagO|FPUflagU)); // Clear O and U flags - ClampValues(recCommutativeOp(info, EEREC_D, 1)); + SSE_LDMXCSR ((uptr)&chop); + ClampValues(recCommutativeOp(info, EEREC_D, 1)); + SSE_LDMXCSR ((uptr)&nearest); } FPURECOMPILE_CONSTCODE(MUL_S, XMMINFO_WRITED|XMMINFO_READS|XMMINFO_READT); @@ -1521,7 +1529,9 @@ FPURECOMPILE_CONSTCODE(MUL_S, XMMINFO_WRITED|XMMINFO_READS|XMMINFO_READT); void recMULA_S_xmm(int info) { //AND32ItoM((uptr)&fpuRegs.fprc[31], ~(FPUflagO|FPUflagU)); // Clear O and U flags + SSE_LDMXCSR ((uptr)&chop); ClampValues(recCommutativeOp(info, EEREC_ACC, 1)); + SSE_LDMXCSR ((uptr)&nearest); } FPURECOMPILE_CONSTCODE(MULA_S, XMMINFO_WRITEACC|XMMINFO_READS|XMMINFO_READT); @@ -1607,7 +1617,9 @@ void recSUBop(int info, int regd) void recSUB_S_xmm(int info) { + SSE_LDMXCSR ((uptr)&chop); recSUBop(info, EEREC_D); + SSE_LDMXCSR ((uptr)&nearest); } FPURECOMPILE_CONSTCODE(SUB_S, XMMINFO_WRITED|XMMINFO_READS|XMMINFO_READT);