diff --git a/bin/GameIndex.dbf b/bin/GameIndex.dbf index c16273304b..4d785a5e2b 100644 --- a/bin/GameIndex.dbf +++ b/bin/GameIndex.dbf @@ -17,6 +17,8 @@ -- You can use c++ style 1-line comments (//) or (--) -- All comments must be written in this header or they will not be -- saved properly by pcsx2's database writer. +-- For gamefixes/roundmodes/clampmodes, pcsx2 will use the current user +-- settings if the game database does not explicitly change the values. --------------------------------------------- -- Compatibility Status (Compat = n) @@ -39,6 +41,17 @@ -- 2 = Positive Infinity -- 3 = Chop (Zero) +--------------------------------------------- +-- Clamp Modes (eeClampMode = n and vuClampMode = n) +--------------------------------------------- +-- The clamp modes are numerically based. +-- eeClampMode refers to the EE's FPU co-processor +-- vuClampMode refers to the VU's and COP2 +-- 0 = Disables clamping completely +-- 1 = Clamp Normally (only clamp results) +-- 2 = Clamp Extra (clamp results as well as operands) +-- 3 = Full Clamping for FPU / Extra+Preserve Sign Clamping for VU + --------------------------------------------- -- Game Fixes (gameFixName = 1) --------------------------------------------- diff --git a/pcsx2/Config.h b/pcsx2/Config.h index bf53cfa531..1cad6e583c 100644 --- a/pcsx2/Config.h +++ b/pcsx2/Config.h @@ -541,6 +541,7 @@ struct Pcsx2Config extern const Pcsx2Config EmuConfig; Pcsx2Config::GSOptions& SetGSConfig(); +Pcsx2Config::RecompilerOptions& SetRecompilerConfig(); Pcsx2Config::GamefixOptions& SetGameFixConfig(); ConsoleLogFilters& SetConsoleConfig(); TraceLogFilters& SetTraceConfig(); diff --git a/pcsx2/DataBase_Loader.h b/pcsx2/DataBase_Loader.h index d3244b4797..618b771f5c 100644 --- a/pcsx2/DataBase_Loader.h +++ b/pcsx2/DataBase_Loader.h @@ -393,9 +393,23 @@ static void loadGameSettings(DataBase_Loader* gameDB) { if (gameDB->keyExists("eeRoundMode")) { eeRM = gameDB->getInt("eeRoundMode"); rm=1; } if (gameDB->keyExists("vuRoundMode")) { vuRM = gameDB->getInt("vuRoundMode"); rm=1; } if (rm && eeRM<4 && vuRM<4) { - Console.WriteLn("Game DataBase: Changing roundmodes!"); + Console.WriteLn("Game DataBase: Changing roundmodes! [ee=%d] [vu=%d]", eeRM, vuRM); SetCPUState(eeMX.SetRoundMode((SSE_RoundMode)eeRM), vuMX.SetRoundMode((SSE_RoundMode)vuRM)); } + if (gameDB->keyExists("eeClampMode")) { + int clampMode = gameDB->getInt("eeClampMode"); + Console.WriteLn("Game DataBase: Changing EE/FPU clamp mode [mode=%d]", clampMode); + SetRecompilerConfig().fpuOverflow = clampMode >= 1; + SetRecompilerConfig().fpuExtraOverflow = clampMode >= 2; + SetRecompilerConfig().fpuFullMode = clampMode >= 3; + } + if (gameDB->keyExists("vuClampMode")) { + int clampMode = gameDB->getInt("vuClampMode"); + Console.WriteLn("Game DataBase: Changing VU0/VU1 clamp mode [mode=%d]", clampMode); + SetRecompilerConfig().vuOverflow = clampMode >= 1; + SetRecompilerConfig().vuExtraOverflow = clampMode >= 2; + SetRecompilerConfig().vuSignOverflow = clampMode >= 3; + } checkGamefix(VuAddSubHack); checkGamefix(VuClipFlagHack); checkGamefix(FpuCompareHack); diff --git a/pcsx2/System.cpp b/pcsx2/System.cpp index a52ad7c771..0b40073c1a 100644 --- a/pcsx2/System.cpp +++ b/pcsx2/System.cpp @@ -68,6 +68,15 @@ Pcsx2Config::GSOptions& SetGSConfig() return const_cast(EmuConfig.GS); } +// Provides an accessor for quick modification of Recompiler options. +// Used by loadGameSettings() to set clamp modes via database at game startup. +Pcsx2Config::RecompilerOptions& SetRecompilerConfig() +{ + //DbgCon.WriteLn( "Direct modification of EmuConfig.Gamefixes detected" ); + AffinityAssert_AllowFrom_MainUI(); + return const_cast(EmuConfig.Cpu.Recompiler); +} + // Provides an accessor for quick modification of Gamefix options. // Used by loadGameSettings() to set gamefixes via database at game startup. Pcsx2Config::GamefixOptions& SetGameFixConfig() diff --git a/pcsx2/x86/microVU_Upper.inl b/pcsx2/x86/microVU_Upper.inl index 68dc872ead..bb73f24551 100644 --- a/pcsx2/x86/microVU_Upper.inl +++ b/pcsx2/x86/microVU_Upper.inl @@ -26,7 +26,6 @@ // Note: If modXYZW is true, then it adjusts XYZW for Single Scalar operations static void mVUupdateFlags(mV, int reg, int regT1 = -1, int regT2 = -1, bool modXYZW = 1) { int sReg, mReg = gprT1, regT1b = 0, regT2b = 0; - //int xyzw = _X_Y_Z_W; // unused local, still needed? -- air static const u16 flipMask[16] = {0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15}; //SysPrintf("Status = %d; Mac = %d\n", sFLAG.doFlag, mFLAG.doFlag);