From 9223be5a30ba9e1820c468cc9a3ac8a4a92954df Mon Sep 17 00:00:00 2001 From: cottonvibes Date: Thu, 29 Jan 2009 14:25:09 +0000 Subject: [PATCH] enabled the FPU extra-flags code after reviewing it. ZEROx told me it fixes some freezes in MGS3 as well. git-svn-id: http://pcsx2-playground.googlecode.com/svn/trunk@653 a6443dda-0b58-4228-96e9-037be469359c --- pcsx2/Misc.h | 4 ++-- pcsx2/x86/iFPU.cpp | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/pcsx2/Misc.h b/pcsx2/Misc.h index 9f6cb3f1ad..e04cdaadf4 100644 --- a/pcsx2/Misc.h +++ b/pcsx2/Misc.h @@ -117,10 +117,10 @@ extern SessionOverrideFlags g_Session; #define CHECK_VU_EXTRA_OVERFLOW (Config.vuOptions & 0x2) // If enabled, Operands are clamped before being used in the VU recs #define CHECK_VU_SIGN_OVERFLOW (Config.vuOptions & 0x4) #define CHECK_VU_UNDERFLOW (Config.vuOptions & 0x8) -#define CHECK_VU_EXTRA_FLAGS 0 // Always disabled now, doesn't seem to affect games positively. // Sets correct flags in the VU recs +#define CHECK_VU_EXTRA_FLAGS 0 // Always disabled now // Sets correct flags in the VU recs #define CHECK_FPU_OVERFLOW (Config.eeOptions & 0x1) #define CHECK_FPU_EXTRA_OVERFLOW (Config.eeOptions & 0x2) // If enabled, Operands are checked for infinities before being used in the FPU recs -#define CHECK_FPU_EXTRA_FLAGS 0 // Always disabled now, doesn't seem to affect games positively. // Sets correct flags in the FPU recs +#define CHECK_FPU_EXTRA_FLAGS 1 // Always enabled now // Sets D/I flags on FPU instructions #define DEFAULT_eeOptions 0x01 #define DEFAULT_vuOptions 0x01 //------------ DEFAULT sseMXCSR VALUES!!! --------------- diff --git a/pcsx2/x86/iFPU.cpp b/pcsx2/x86/iFPU.cpp index 9d63b72710..5e70b9aaea 100644 --- a/pcsx2/x86/iFPU.cpp +++ b/pcsx2/x86/iFPU.cpp @@ -1071,6 +1071,7 @@ void recDIV_S_xmm(int info) int t0reg = _allocTempXMMreg(XMMT_FPS, -1); //if (t0reg == -1) {Console::Error("FPU: DIV Allocation Error!");} //SysPrintf("DIV\n"); + if ((g_sseMXCSR & 0x00006000) != 0x00000000) { // Set roundmode to nearest if it isn't already //SysPrintf("div to nearest\n"); roundmode_temp[0] = (g_sseMXCSR & 0xFFFF9FFF); // Set new roundmode @@ -1625,8 +1626,6 @@ void recSQRT_S_xmm(int info) u8* pjmp; static u32 PCSX2_ALIGNED16(roundmode_temp[4]) = { 0x00000000, 0x00000000, 0x00000000, 0x00000000 }; int roundmodeFlag = 0; - int tempReg = _allocX86reg(-1, X86TYPE_TEMP, 0, 0); - if (tempReg == -1) {Console::Error("FPU: SQRT Allocation Error!"); tempReg = EAX;} //SysPrintf("FPU: SQRT\n"); if ((g_sseMXCSR & 0x00006000) != 0x00000000) { // Set roundmode to nearest if it isn't already @@ -1641,6 +1640,9 @@ void recSQRT_S_xmm(int info) else SSE_MOVSS_M32_to_XMM(EEREC_D, (uptr)&fpuRegs.fpr[_Ft_]); if (CHECK_FPU_EXTRA_FLAGS) { + int tempReg = _allocX86reg(-1, X86TYPE_TEMP, 0, 0); + if (tempReg == -1) {Console::Error("FPU: SQRT Allocation Error!"); tempReg = EAX;} + AND32ItoM((uptr)&fpuRegs.fprc[31], ~(FPUflagI|FPUflagD)); // Clear I and D flags /*--- Check for negative SQRT ---*/ @@ -1650,6 +1652,8 @@ void recSQRT_S_xmm(int info) OR32ItoM((uptr)&fpuRegs.fprc[31], FPUflagI|FPUflagSI); // Set I and SI flags SSE_ANDPS_M128_to_XMM(EEREC_D, (uptr)&s_pos[0]); // Make EEREC_D Positive x86SetJ8(pjmp); + + _freeX86reg(tempReg); } else SSE_ANDPS_M128_to_XMM(EEREC_D, (uptr)&s_pos[0]); // Make EEREC_D Positive @@ -1660,8 +1664,6 @@ void recSQRT_S_xmm(int info) if (roundmodeFlag == 1) { // Set roundmode back if it was changed SSE_LDMXCSR ((uptr)&roundmode_temp[1]); } - - _freeX86reg(tempReg); } FPURECOMPILE_CONSTCODE(SQRT_S, XMMINFO_WRITED|XMMINFO_READT);