From 257953908fa4bd6115471f4a22747e7f7119598a Mon Sep 17 00:00:00 2001 From: ramapcsx2 Date: Thu, 5 Feb 2009 00:55:02 +0000 Subject: [PATCH] Refraction fixed the delay slot handling and the VU clip problem. This lets us remove 2 game specific hacks from the gamefixes dialog ;) git-svn-id: http://pcsx2-playground.googlecode.com/svn/trunk@697 a6443dda-0b58-4228-96e9-037be469359c --- pcsx2/Misc.h | 2 -- pcsx2/windows/WinMain.cpp | 2 -- pcsx2/windows/pcsx2.rc | 50 ++++++++++++++++--------------------- pcsx2/windows/resource.h | 1 - pcsx2/x86/iVUmicroUpper.cpp | 13 +++++++--- pcsx2/x86/iVUzerorec.cpp | 14 +++++++---- 6 files changed, 40 insertions(+), 42 deletions(-) diff --git a/pcsx2/Misc.h b/pcsx2/Misc.h index 20f9b38d39..1ba9018ffa 100644 --- a/pcsx2/Misc.h +++ b/pcsx2/Misc.h @@ -88,9 +88,7 @@ extern SessionOverrideFlags g_Session; //------------ SPECIAL GAME FIXES!!! --------------- #define CHECK_VUADDSUBHACK (Config.GameFixes & 0x1) // Special Fix for Tri-ace games, they use an encryption algorithm that requires VU addi opcode to be bit-accurate. #define CHECK_FPUCLAMPHACK (Config.GameFixes & 0x4) // Special Fix for Tekken 5, different clamping for FPU (sets NaN to zero; doesn't clamp infinities) -#define CHECK_VUCLIPHACK (Config.GameFixes & 0x2) // Special Fix for GoW, updates the clipflag differently in recVUMI_CLIP() (note: turning this hack on, breaks Rockstar games) #define CHECK_VUBRANCHHACK (Config.GameFixes & 0x8) // Special Fix for Magna Carta (note: Breaks Crash Bandicoot) -#define CHECK_DELAYSLOTHACK (Config.GameFixes & 0x10)// Avoids supervu messing up the delayslot handling //------------ Advanced Options!!! --------------- #define CHECK_VU_OVERFLOW (Config.vuOptions & 0x1) #define CHECK_VU_EXTRA_OVERFLOW (Config.vuOptions & 0x2) // If enabled, Operands are clamped before being used in the VU recs diff --git a/pcsx2/windows/WinMain.cpp b/pcsx2/windows/WinMain.cpp index cfe468c9bc..07f16f3e4e 100644 --- a/pcsx2/windows/WinMain.cpp +++ b/pcsx2/windows/WinMain.cpp @@ -524,7 +524,6 @@ BOOL APIENTRY GameFixes(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) if(Config.GameFixes & 0x2) CheckDlgButton(hDlg, IDC_GAMEFIX2, TRUE); if(Config.GameFixes & 0x4) CheckDlgButton(hDlg, IDC_GAMEFIX3, TRUE); if(Config.GameFixes & 0x8) CheckDlgButton(hDlg, IDC_GAMEFIX4, TRUE); - if(Config.GameFixes & 0x10) CheckDlgButton(hDlg, IDC_GAMEFIX6, TRUE); return TRUE; case WM_COMMAND: @@ -535,7 +534,6 @@ BOOL APIENTRY GameFixes(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) newfixes |= IsDlgButtonChecked(hDlg, IDC_GAMEFIX2) ? 0x2 : 0; newfixes |= IsDlgButtonChecked(hDlg, IDC_GAMEFIX3) ? 0x4 : 0; newfixes |= IsDlgButtonChecked(hDlg, IDC_GAMEFIX4) ? 0x8 : 0; - newfixes |= IsDlgButtonChecked(hDlg, IDC_GAMEFIX6) ? 0x10 : 0; EndDialog(hDlg, TRUE); diff --git a/pcsx2/windows/pcsx2.rc b/pcsx2/windows/pcsx2.rc index 50ebfc9618..a543c1f99d 100644 --- a/pcsx2/windows/pcsx2.rc +++ b/pcsx2/windows/pcsx2.rc @@ -7,12 +7,11 @@ // // Generated from the TEXTINCLUDE 2 resource. // -#include "afxresmw.h" -///////////////////////////////////////////////////////////////////////////// +#include "afxresmw.h" ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// -// Rumänisch resources +// Romanian resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ROM) #ifdef _WIN32 @@ -56,12 +55,12 @@ BEGIN END #endif // APSTUDIO_INVOKED -#endif // Rumänisch resources +#endif // Romanian resources ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// -// Deutsch (Deutschland) resources +// German (Germany) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU) #ifdef _WIN32 @@ -74,25 +73,21 @@ LANGUAGE LANG_GERMAN, SUBLANG_GERMAN // Dialog // -IDD_GAMEFIXES DIALOGEX 0, 0, 278, 154 +IDD_GAMEFIXES DIALOGEX 0, 0, 278, 129 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Game Special Fixes" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN - DEFPUSHBUTTON "OK",IDOK,85,133,50,14 - PUSHBUTTON "Cancel",IDCANCEL,139,133,50,14 + DEFPUSHBUTTON "OK",IDOK,85,108,50,14 + PUSHBUTTON "Cancel",IDCANCEL,139,108,50,14 CTEXT "Some games need special settings.\nConfigure them here.",IDC_STATIC,7,7,264,17 - CONTROL "VU Clip Hack - Special fix for God of War; Breaks Rockstar games!",IDC_GAMEFIX2, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,74,252,10 GROUPBOX "PCSX2 Gamefixes",IDC_STATIC,7,30,264,92 - CONTROL "FPU Clamp Hack - Special fix for Tekken 5 and Rogue Galaxy.",IDC_GAMEFIX3, + CONTROL "FPU Clamp Hack - Special fix for Tekken 5.",IDC_GAMEFIX3, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,46,249,10 CONTROL "VU Branch Hack - Special fix for Magna Carta; Breaks Crash Bandicoot!",IDC_GAMEFIX4, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,88,252,10 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,74,252,10 CONTROL "VU Add / Sub Hack - Special fix for Tri-Ace games!",IDC_GAMEFIX1, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,60,252,10 - CONTROL "Avoid 2 cycle branch delay handling - Fixes KH2 and Tri-Ace games",IDC_GAMEFIX6, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,103,252,10 END @@ -110,17 +105,17 @@ BEGIN RIGHTMARGIN, 271 VERTGUIDE, 12 TOPMARGIN, 7 - BOTTOMMARGIN, 147 + BOTTOMMARGIN, 122 END END #endif // APSTUDIO_INVOKED -#endif // Deutsch (Deutschland) resources +#endif // German (Germany) resources ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// -// Englisch (USA) resources +// English (U.S.) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) #ifdef _WIN32 @@ -1025,12 +1020,12 @@ END // IDB_PS2SILVER BITMAP "ps2_silver.bmp" -#endif // Englisch (USA) resources +#endif // English (U.S.) resources ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// -// Englisch (GB) resources +// English (U.K.) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG) #ifdef _WIN32 @@ -1117,12 +1112,12 @@ END // SPLASH_LOGO BITMAP "..\\pcsxAbout.bmp" -#endif // Englisch (GB) resources +#endif // English (U.K.) resources ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// -// Spanisch resources +// Spanish resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ESN) #ifdef _WIN32 @@ -1363,12 +1358,12 @@ END #endif // APSTUDIO_INVOKED -#endif // Spanisch resources +#endif // Spanish resources ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// -// Spanisch (Argentinien) resources +// Spanish (Argentina) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ESS) #ifdef _WIN32 @@ -1521,12 +1516,12 @@ END // Icon with lowest ID value placed first to ensure application icon // remains consistent on all systems. IDI_ICON ICON "Cdrom02.ico" -#endif // Spanisch (Argentinien) resources +#endif // Spanish (Argentina) resources ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// -// Griechisch resources +// Greek resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ELL) #ifdef _WIN32 @@ -1708,7 +1703,7 @@ END #endif // APSTUDIO_INVOKED -#endif // Griechisch resources +#endif // Greek resources ///////////////////////////////////////////////////////////////////////////// @@ -1718,7 +1713,6 @@ END // // Generated from the TEXTINCLUDE 3 resource. // - -///////////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////////// #endif // not APSTUDIO_INVOKED diff --git a/pcsx2/windows/resource.h b/pcsx2/windows/resource.h index 2f1b9174cb..764d13cc99 100644 --- a/pcsx2/windows/resource.h +++ b/pcsx2/windows/resource.h @@ -573,7 +573,6 @@ #define IDC_GAMEFIX5 1304 #define IDC_GAMEFIX1 1304 #define IDC_EE_ROUNDMODE0 1305 -#define IDC_GAMEFIX6 1305 #define IDC_EE_ROUNDMODE1 1306 #define IDC_EE_ROUNDMODE2 1307 #define IDC_EE_ROUNDMODE3 1308 diff --git a/pcsx2/x86/iVUmicroUpper.cpp b/pcsx2/x86/iVUmicroUpper.cpp index 7d806ff245..ab02fcfa5e 100644 --- a/pcsx2/x86/iVUmicroUpper.cpp +++ b/pcsx2/x86/iVUmicroUpper.cpp @@ -3014,12 +3014,18 @@ void recVUMI_CLIP(VURegs *VU, int info) u32 clipaddr = VU_VI_ADDR(REG_CLIP_FLAG, 0); u32 prevclipaddr = VU_VI_ADDR(REG_CLIP_FLAG, 2); - //SysPrintf ("recVUMI_CLIP \n"); - if( clipaddr == 0 ) { // battle star has a clip right before fcset SysPrintf("skipping vu clip\n"); return; } + + //Flush the clip flag before processing, incase of double clip commands (GoW) + + if( prevclipaddr != (uptr)&VU->VI[REG_CLIP_FLAG] ) { + MOV32MtoR(EAX, prevclipaddr); + MOV32RtoM((uptr)&VU->VI[REG_CLIP_FLAG], EAX); + } + assert( clipaddr != 0 ); assert( t1reg != t2reg && t1reg != EEREC_TEMP && t2reg != EEREC_TEMP ); @@ -3064,8 +3070,7 @@ void recVUMI_CLIP(VURegs *VU, int info) MOV32RtoM(clipaddr, EAX); - // God of War needs this additional move, but it breaks Rockstar games; ideally this hack shouldn't be needed, i think its a clipflag allocation bug in iVUzerorec.cpp - if ( ( CHECK_VUCLIPHACK ) || ( !(info & (PROCESS_VU_SUPER|PROCESS_VU_COP2)) ) ) + if (( !(info & (PROCESS_VU_SUPER|PROCESS_VU_COP2)) ) ) //Instantly update the flag if its called from elsewhere (unlikely, but ok) MOV32RtoM((uptr)&VU->VI[REG_CLIP_FLAG], EAX); _freeX86reg(x86temp1); diff --git a/pcsx2/x86/iVUzerorec.cpp b/pcsx2/x86/iVUzerorec.cpp index e92a2dcf60..e991579452 100644 --- a/pcsx2/x86/iVUzerorec.cpp +++ b/pcsx2/x86/iVUzerorec.cpp @@ -932,7 +932,6 @@ static VuBaseBlock* SuperVUBuildBlocks(VuBaseBlock* parent, u32 startpc, const V { // check if block already exists //SysPrintf("startpc %x\n", startpc); - bool TwoCycle = false; startpc &= (s_vu ? 0x3fff : 0xfff); VuBlockHeader* pbh = &recVUBlocks[s_vu][startpc/8]; @@ -1135,8 +1134,6 @@ static VuBaseBlock* SuperVUBuildBlocks(VuBaseBlock* parent, u32 startpc, const V #ifdef SUPERVU_VIBRANCHDELAY if( pinst->regs[0].pipe == VUPIPE_BRANCH && pblock->insts.size() > 1 ) { - TwoCycle = true; - if( pprevinst != NULL && pprevinst->info.cycle+1==pinst->info.cycle && (pprevinst->regs[0].pipe == VUPIPE_IALU||pprevinst->regs[0].pipe == VUPIPE_FMAC) && ((pprevinst->regs[0].VIwrite & pinst->regs[0].VIread) & 0xffff) && !(pprevinst->regs[0].VIread&((1<type |= BLOCKTYPE_EOP; // jump out of procedure, since not returning, set EOP pblock->insts.push_back(SuperVUFlushInst()); + firstbranch = 0xff; //Non-Conditional Jump break; case 0x25: // jalr @@ -1380,6 +1377,7 @@ static VuBaseBlock* SuperVUBuildBlocks(VuBaseBlock* parent, u32 startpc, const V assert( pblock != NULL ); pblock->blocks.push_back(pjumpblock); + firstbranch = 0xff; //Non-Conditional Jump break; } case 0x20: // B @@ -1391,6 +1389,7 @@ static VuBaseBlock* SuperVUBuildBlocks(VuBaseBlock* parent, u32 startpc, const V assert( pblock != NULL ); pblock->blocks.push_back(pbranchblock); + firstbranch = 0xff; //Non-Conditional Jump break; } case 0x21: // BAL @@ -1401,6 +1400,7 @@ static VuBaseBlock* SuperVUBuildBlocks(VuBaseBlock* parent, u32 startpc, const V pblock = recVUBlocks[s_vu][lastpc/8-2].pblock; assert( pblock != NULL ); pblock->blocks.push_back(pbranchblock); + firstbranch = 0xff; //Non-Conditional Jump break; } case 0x28: // IBEQ @@ -1436,7 +1436,11 @@ static VuBaseBlock* SuperVUBuildBlocks(VuBaseBlock* parent, u32 startpc, const V pblock = recVUBlocks[s_vu][lastpc/8-2].pblock; #ifdef SUPERVU_VIBRANCHDELAY - if( hasSecondBranch && ( CHECK_DELAYSLOTHACK ? (!TwoCycle ? 1 : 0) : 1 ) ) { +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +///// NOTE! This could still be a hack for KH2/GoW, but until we know how it properly works, this will do for now./// +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + if( hasSecondBranch && firstbranch != 0xff ) { //check the previous jump was conditional and there is a second branch #else if( hasSecondBranch) { #endif