From 4d2adcae9f4634f0c212a97846edea1554a5e03e Mon Sep 17 00:00:00 2001 From: sudonim1 Date: Wed, 15 Apr 2009 20:31:58 +0000 Subject: [PATCH] New speed hack mainly targeting 3D geometry. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@984 96395faa-99c1-11dd-bbfe-3dabce05a288 --- common/include/Pcsx2Config.h | 1 + pcsx2/Linux/Pref.cpp | 4 ++++ pcsx2/windows/HacksDlg.cpp | 41 +++++++++++++++++++++++++++++++++++- pcsx2/windows/ini.cpp | 3 +++ pcsx2/windows/pcsx2.rc | 5 +++++ pcsx2/windows/resource.h | 5 ++++- pcsx2/x86/iVUzerorec.cpp | 1 + 7 files changed, 58 insertions(+), 2 deletions(-) diff --git a/common/include/Pcsx2Config.h b/common/include/Pcsx2Config.h index 2da21f9f11..cfff17a591 100644 --- a/common/include/Pcsx2Config.h +++ b/common/include/Pcsx2Config.h @@ -137,6 +137,7 @@ public: int Patch; int CustomFps; int Hacks; + int VUCycleHack; int GameFixes; int CustomFrameSkip; int CustomConsecutiveFrames; diff --git a/pcsx2/Linux/Pref.cpp b/pcsx2/Linux/Pref.cpp index f2097abce9..90f513353b 100644 --- a/pcsx2/Linux/Pref.cpp +++ b/pcsx2/Linux/Pref.cpp @@ -101,6 +101,9 @@ int LoadConfig() #endif GetValuel("Options", Config.Options); GetValuel("Hacks", Config.Hacks); + GetValuel("VUCycleHack", Config.VUCycleHack); + if (Config.VUCycleHack < 0 || Config.VUCycleHack > 4) + Config.VUCycleHack = 0; GetValuel("Fixes", Config.GameFixes); GetValuel("CustomFps", Config.CustomFps); @@ -163,6 +166,7 @@ void SaveConfig() SetValuel("Options", Config.Options); SetValuel("Hacks", Config.Hacks); + SetValuel("VUCycleHack", Config.VUCycleHack); SetValuel("Fixes", Config.GameFixes); SetValuel("Patch", Config.Patch); diff --git a/pcsx2/windows/HacksDlg.cpp b/pcsx2/windows/HacksDlg.cpp index 045705f6bd..3bead95237 100644 --- a/pcsx2/windows/HacksDlg.cpp +++ b/pcsx2/windows/HacksDlg.cpp @@ -19,6 +19,23 @@ #include "win32.h" +static _TCHAR *VUCycleHackLevels[] = { + _T("Speedup for 3D games.\nCurrently off"), + _T("Slight speedup for 3D geometry, should work with most games."), + _T("Moderate speedup for 3D geometry, should work with most games with minor problems."), + _T("Large speedup for 3D geometry, may break many games and make others skip frames."), + _T("Very large speedup for 3D geometry, will break games in interesting ways."), +}; + +static void CheckVUCycleHack(HWND hDlg, int &vucyclehack) +{ + if (vucyclehack < 0 || vucyclehack > 4) { + vucyclehack = 0; + SendDlgItemMessage(hDlg, IDC_VUCYCLE, TBM_SETPOS, TRUE, vucyclehack); + } + SetDlgItemText(hDlg, IDC_VUCYCLEDESC, VUCycleHackLevels[vucyclehack]); +} + BOOL APIENTRY HacksProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { @@ -31,8 +48,26 @@ BOOL APIENTRY HacksProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) if(CHECK_INTC_STAT_HACK) CheckDlgButton(hDlg, IDC_INTCSTATHACK, TRUE); if(CHECK_ESCAPE_HACK) CheckDlgButton(hDlg, IDC_ESCHACK, TRUE); + SendDlgItemMessage(hDlg, IDC_VUCYCLE, TBM_SETRANGE, TRUE, MAKELONG(0, 4)); + CheckVUCycleHack(hDlg, Config.VUCycleHack); + SendDlgItemMessage(hDlg, IDC_VUCYCLE, TBM_SETPOS, TRUE, Config.VUCycleHack); + return TRUE; + case WM_HSCROLL: { + HWND slider = (HWND)lParam; + int curpos = HIWORD(wParam); + switch (LOWORD(wParam)) { + case TB_THUMBTRACK: + case TB_THUMBPOSITION: + break; + default: + curpos = SendMessage(slider, TBM_GETPOS, 0, 0); + } + CheckVUCycleHack(hDlg, curpos); + return FALSE; + } + case WM_COMMAND: switch (LOWORD(wParam)) { @@ -53,12 +88,16 @@ BOOL APIENTRY HacksProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) newhacks |= IsDlgButtonChecked(hDlg, IDC_INTCSTATHACK) << 5; newhacks |= IsDlgButtonChecked(hDlg, IDC_ESCHACK) << 10; + int newvucyclehack = SendDlgItemMessage(hDlg, IDC_VUCYCLE, TBM_GETPOS, 0, 0); + CheckVUCycleHack(hDlg, newvucyclehack); + EndDialog(hDlg, TRUE); - if( newhacks != Config.Hacks ) + if( newhacks != Config.Hacks || newvucyclehack != Config.VUCycleHack) { SysRestorableReset(); Config.Hacks = newhacks; + Config.VUCycleHack = newvucyclehack; SaveConfig(); } } diff --git a/pcsx2/windows/ini.cpp b/pcsx2/windows/ini.cpp index 7fe4942aea..6a1016afef 100644 --- a/pcsx2/windows/ini.cpp +++ b/pcsx2/windows/ini.cpp @@ -223,6 +223,9 @@ void IniFile::DoConfig( PcsxConfig& Conf ) Entry( "eeOptions", Conf.eeOptions, DEFAULT_eeOptions ); Entry( "vuOptions", Conf.vuOptions, DEFAULT_vuOptions ); Entry( "SpeedHacks", Conf.Hacks ); + Entry( "VUCycleHack", Conf.VUCycleHack, 0 ); + if (Conf.VUCycleHack < 0 || Conf.VUCycleHack > 4) + Conf.VUCycleHack = 0; } ////////////////////////////////////////////////////////////////////////////////////////// diff --git a/pcsx2/windows/pcsx2.rc b/pcsx2/windows/pcsx2.rc index 63316593a2..65623bd61d 100644 --- a/pcsx2/windows/pcsx2.rc +++ b/pcsx2/windows/pcsx2.rc @@ -371,6 +371,9 @@ BEGIN LTEXT "Moderate speedup and works well with most games.",IDC_STATIC,25,90,129,19 CONTROL "INTC Sync Hack (experimental)",IDC_INTCSTATHACK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,174,43,127,10 LTEXT "Huge speedup in many games, and a pretty high compatibility rate (some games still work better with EE sync hacks).",IDC_STATIC,186,55,140,28 + CONTROL "",IDC_VUCYCLE,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,174,176,36,15 + LTEXT "This space intentionally left blank",IDC_VUCYCLEDESC,186,194,142,30 + LTEXT "VU Cycle Stealing (experimental)",IDC_STATIC,210,180,105,8 END @@ -393,6 +396,8 @@ BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 328 VERTGUIDE, 13 + VERTGUIDE, 174 + VERTGUIDE, 186 TOPMARGIN, 7 BOTTOMMARGIN, 256 END diff --git a/pcsx2/windows/resource.h b/pcsx2/windows/resource.h index 6e9f1ab34c..24e02c3816 100644 --- a/pcsx2/windows/resource.h +++ b/pcsx2/windows/resource.h @@ -272,6 +272,9 @@ #define IDC_MCD_LABEL2 1325 #define IDC_INTCSTATHACK 1326 #define IDC_EE_CHECK3 1327 +#define IDC_SLIDER1 1327 +#define IDC_VUCYCLE 1327 +#define IDC_VUCYCLEDESC 1328 #define IDC_CPULOG 1500 #define IDC_MEMLOG 1501 #define IDC_HWLOG 1502 @@ -405,7 +408,7 @@ #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 141 #define _APS_NEXT_COMMAND_VALUE 40018 -#define _APS_NEXT_CONTROL_VALUE 1326 +#define _APS_NEXT_CONTROL_VALUE 1329 #define _APS_NEXT_SYMED_VALUE 104 #endif #endif diff --git a/pcsx2/x86/iVUzerorec.cpp b/pcsx2/x86/iVUzerorec.cpp index ce9549be0c..d2fbdf1e17 100644 --- a/pcsx2/x86/iVUzerorec.cpp +++ b/pcsx2/x86/iVUzerorec.cpp @@ -2294,6 +2294,7 @@ void SuperVUCleanupProgram(u32 startpc, int vuindex) VU = vuindex ? &VU1 : &VU0; VU->cycle += s_TotalVUCycles; + cpuRegs.cycle += s_TotalVUCycles * Config.VUCycleHack; if( (int)s_writeQ > 0 ) VU->VI[REG_Q] = VU->q; if( (int)s_writeP > 0 ) { assert(VU == &VU1);