From e31b0755d0a9c42b5b727855f3b8ee26dcedb820 Mon Sep 17 00:00:00 2001 From: ramapcsx2 Date: Wed, 30 May 2012 11:54:59 +0000 Subject: [PATCH] 1.0 branch: Merged in miscellaneous changes from trunk. Lots of changes in GSdx need Linux side verification before they can get in! git-svn-id: http://pcsx2.googlecode.com/svn/branches/1.0.0@5242 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/gui/AppConfig.cpp | 11 ++-- pcsx2/gui/FrameForGS.cpp | 6 ++ pcsx2/gui/Panels/SpeedhacksPanel.cpp | 21 ++++--- plugins/GSnull/Registers.h | 17 ------ tools/dynacrchack/Auto_Compile.bat | 40 +++++++++----- tools/dynacrchack/DynaCrcHack.c | 83 ++++++++++++++++++++++++---- 6 files changed, 120 insertions(+), 58 deletions(-) diff --git a/pcsx2/gui/AppConfig.cpp b/pcsx2/gui/AppConfig.cpp index ddf65394c0..cd494c28dd 100644 --- a/pcsx2/gui/AppConfig.cpp +++ b/pcsx2/gui/AppConfig.cpp @@ -869,8 +869,9 @@ bool AppConfig::IsOkApplyPreset(int n) //Console.WriteLn("Applying Preset %d ...", n); //Have some original and default values at hand to be used later. - Pcsx2Config::GSOptions original_GS = EmuOptions.GS; - AppConfig::FramerateOptions original_Framerate = Framerate; + Pcsx2Config::GSOptions original_GS = EmuOptions.GS; + AppConfig::FramerateOptions original_Framerate = Framerate; + Pcsx2Config::SpeedhackOptions original_SpeedHacks = EmuOptions.Speedhacks; AppConfig default_AppConfig; Pcsx2Config default_Pcsx2Config; @@ -880,7 +881,7 @@ bool AppConfig::IsOkApplyPreset(int n) // 2. The panels should not apply values which the presets don't control if the value is initiated by a preset. // Currently controlled by the presets: // - AppConfig: Framerate (except turbo/slowmo factors), EnableSpeedHacks, EnableGameFixes. - // - EmuOptions: Cpu, Gamefixes, SpeedHacks, EnablePatches, GS (except for FrameLimitEnable, VsyncEnable and ManagedVsync). + // - EmuOptions: Cpu, Gamefixes, SpeedHacks (except mtvu), EnablePatches, GS (except for FrameLimitEnable, VsyncEnable and ManagedVsync). // // This essentially currently covers all the options on all the panels except for framelimiter which isn't // controlled by the presets, and the entire GSWindow panel which also isn't controlled by presets @@ -908,7 +909,8 @@ bool AppConfig::IsOkApplyPreset(int n) EmuOptions.Gamefixes = default_Pcsx2Config.Gamefixes; EmuOptions.Speedhacks = default_Pcsx2Config.Speedhacks; EmuOptions.Speedhacks.bitset = 0; //Turn off individual hacks to make it visually clear they're not used. - + EmuOptions.Speedhacks.vuThread = original_SpeedHacks.vuThread; // MTVU is not modified by presets + EnableSpeedHacks = true; //Actual application of current preset over the base settings which all presets use (mostly pcsx2's default values). //The presets themselves might need some voodoo tuning to be even more useful. Currently they mostly modify Speedhacks. @@ -936,7 +938,6 @@ bool AppConfig::IsOkApplyPreset(int n) //EmuOptions.Gamefixes.EETimingHack = true; case 1 : //Recommended speed hacks. - EnableSpeedHacks = true; EmuOptions.Speedhacks.IntcStat = true; EmuOptions.Speedhacks.WaitLoop = true; EmuOptions.Speedhacks.vuFlagHack = true; diff --git a/pcsx2/gui/FrameForGS.cpp b/pcsx2/gui/FrameForGS.cpp index eb2da6ffc1..70ab14abe4 100644 --- a/pcsx2/gui/FrameForGS.cpp +++ b/pcsx2/gui/FrameForGS.cpp @@ -516,6 +516,12 @@ GSPanel* GSFrame::GetViewport() void GSFrame::OnUpdateTitle( wxTimerEvent& evt ) { +#ifdef __LINUX__ + // Important Linux note: When the title is set in fullscreen the window is redrawn. Unfortunately + // an intermediate white screen appears too which leads to a very annoying flickering. + if (IsFullScreen()) return; +#endif + double fps = wxGetApp().FpsManager.GetFramerate(); char gsDest[128]; diff --git a/pcsx2/gui/Panels/SpeedhacksPanel.cpp b/pcsx2/gui/Panels/SpeedhacksPanel.cpp index 0052b1a0de..6a4e1ccd5c 100644 --- a/pcsx2/gui/Panels/SpeedhacksPanel.cpp +++ b/pcsx2/gui/Panels/SpeedhacksPanel.cpp @@ -269,9 +269,7 @@ Panels::SpeedHacksPanel::SpeedHacksPanel( wxWindow* parent ) void Panels::SpeedHacksPanel::EnableStuff( AppConfig* configToUse ) { - //Console.WriteLn("SpeedHacksPanel::EnableStuff: Using %s", configToUse?"Object":"NULL"); if( !configToUse ) configToUse = g_Conf; - //Console.WriteLn("SpeedHacksPanel::EnableStuff: EnabledPresets: %s", configToUse->EnablePresets?"true":"false"); wxSizerItemList& items( s_table->GetChildren() ); wxSizerItemList::iterator it = items.begin(); @@ -279,7 +277,7 @@ void Panels::SpeedHacksPanel::EnableStuff( AppConfig* configToUse ) while( it != end ) { - (*it)->GetWindow()->Enable( m_check_Enable->GetValue() && !configToUse->EnablePresets); + (*it)->GetWindow()->Enable( m_check_Enable->GetValue()); ++it; } } @@ -295,19 +293,22 @@ void Panels::SpeedHacksPanel::ApplyConfigToGui( AppConfig& configToApply, int fl const bool enabled = configToApply.EnableSpeedHacks; Pcsx2Config::SpeedhackOptions& opts=configToApply.EmuOptions.Speedhacks; - m_check_Enable ->SetValue( !!enabled ); + m_check_Enable ->SetValue( !!enabled ).Enable(!configToApply.EnablePresets); m_slider_eecycle ->SetValue( opts.EECycleRate + 1 ); m_slider_vustealer ->SetValue( opts.VUCycleSteal ); + m_slider_eecycle->Enable(!configToApply.EnablePresets); + m_slider_vustealer->Enable(!configToApply.EnablePresets); SetEEcycleSliderMsg(); SetVUcycleSliderMsg(); - m_check_vuFlagHack ->SetValue(opts.vuFlagHack); - m_check_vuThread ->SetValue(opts.vuThread); - m_check_intc ->SetValue(opts.IntcStat); - m_check_waitloop ->SetValue(opts.WaitLoop); - m_check_fastCDVD ->SetValue(opts.fastCDVD); + m_check_vuFlagHack ->SetValue(opts.vuFlagHack).Enable(!configToApply.EnablePresets); + if( !(flags & AppConfig::APPLY_FLAG_FROM_PRESET) ) + m_check_vuThread ->SetValue(opts.vuThread); + m_check_intc ->SetValue(opts.IntcStat).Enable(!configToApply.EnablePresets); + m_check_waitloop ->SetValue(opts.WaitLoop).Enable(!configToApply.EnablePresets); + m_check_fastCDVD ->SetValue(opts.fastCDVD).Enable(!configToApply.EnablePresets); EnableStuff( &configToApply ); @@ -315,8 +316,6 @@ void Panels::SpeedHacksPanel::ApplyConfigToGui( AppConfig& configToApply, int fl Layout(); //Console.WriteLn("SpeedHacksPanel::ApplyConfigToGui: EnabledPresets: %s", configToApply.EnablePresets?"true":"false"); - - this->Enable(!configToApply.EnablePresets); } diff --git a/plugins/GSnull/Registers.h b/plugins/GSnull/Registers.h index ed81b2fe3e..75c8aaffd0 100644 --- a/plugins/GSnull/Registers.h +++ b/plugins/GSnull/Registers.h @@ -16,14 +16,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -// These enums & structures are copied from GSdx, which got them from sp2dev 0.4.0. - -// sp2dev is Copyright (C) 2002 Terratron Technologies Inc. All Rights Reserved. -// http://window.terratron.com/~sosman/ps2linux/ -// -// Gsdx is Copyright (C) 2007-2009 Gabest All Rights Reserved. -// http://www.gabest.org -// #ifndef __REGISTERS_H__ #define __REGISTERS_H__ @@ -578,15 +570,6 @@ REG64_SET(GSReg) GSRegSMODE2 SMODE2; REG_SET_END -// -// sps2tags.h -// - -#define SET_GIF_REG(gifTag, iRegNo, uiValue) \ - {((GIFTag*)&gifTag)->u64[1] |= (((uiValue) & 0xf) << ((iRegNo) << 2));} - -#define GET_GIF_REG(tag, reg) \ - (((tag).u32[2 + ((reg) >> 3)] >> (((reg) & 7) << 2)) & 0xf) // // GIFTag diff --git a/tools/dynacrchack/Auto_Compile.bat b/tools/dynacrchack/Auto_Compile.bat index ebf445062f..af9f43c7e4 100644 --- a/tools/dynacrchack/Auto_Compile.bat +++ b/tools/dynacrchack/Auto_Compile.bat @@ -1,26 +1,37 @@ @echo off set source=DynaCrcHack.c +set tcc=tcc\tcc -@cd /D "%~d1%~p1" > nul +pushd "%~dp0" -if not exist tcc\tcc.exe ( - echo. - echo Missing ^\tcc\tcc.exe - echo. - echo Please download TCC 0.9.25 for windows from http://bellard.org/tcc/ - echo and extract the package to ^\tcc - echo. - pause - goto end +if exist %tcc%.exe goto pre + +rem local tcc not found, try to invoke a global tcc +set tcc=tcc +%tcc% utils\ding.c -luser32 -o utils\ding.exe >nul 2>nul +if %errorlevel% == 0 ( + echo. + echo Using globally installed tcc ... + echo. +) else ( + echo. + echo Missing ^\tcc\tcc.exe + echo. + echo Please download TCC 0.9.25 for windows from http://bellard.org/tcc/ + echo and extract the package to ^\tcc + echo. + pause + goto end ) -if not exist utils\waitForChange.exe tcc\tcc utils\waitForChange.c -o utils\waitForChange.exe -if not exist utils\ding.exe tcc\tcc utils\ding.c -luser32 -o utils\ding.exe +:pre +if not exist utils\waitForChange.exe %tcc% utils\waitForChange.c -o utils\waitForChange.exe +if not exist utils\ding.exe %tcc% utils\ding.c -luser32 -o utils\ding.exe :start echo Compiling ... echo. -tcc\tcc -shared -Wall %source% +%tcc% -shared -Wall %source% if %errorlevel% == 0 ( echo -^> OK utils\ding 2 @@ -38,4 +49,5 @@ echo. goto start -:end \ No newline at end of file +:end +popd \ No newline at end of file diff --git a/tools/dynacrchack/DynaCrcHack.c b/tools/dynacrchack/DynaCrcHack.c index 6cc6e22ae8..fd6a2fb32d 100644 --- a/tools/dynacrchack/DynaCrcHack.c +++ b/tools/dynacrchack/DynaCrcHack.c @@ -28,11 +28,13 @@ version 1.1 - initial release Version 1.2 - better GSdx integration, Bugfix. Version 1.4 - Configuration, few utils, Cleanups (dll API is unchanged) + version 1.5 - Supports CRC passed from GSdx and util IsCRC(crc1 [, crc2, ...]) \*----------------------------------------------------------*/ #include #include +#include #include //some common tokens not available in C @@ -53,7 +55,7 @@ enum GS_PSM{PSM_PSMCT32=0,PSM_PSMCT24=1,PSM_PSMCT16=2,PSM_PSMCT16S=10,PSM_PSMT8= #define skip (*pSkip) #define GSUtil_HasSharedBits(a,b,c,d) sharedBits #define GSC_AnyGame(a,b) _GSC_AnyGame() -GSFrameInfo fi; int* pSkip; uint32 g_crc_region; uint32 sharedBits; +GSFrameInfo fi; int* pSkip; uint32 g_crc_region; uint32 sharedBits; uint32 g_crc; //utils const int MODE_3_DELAY = 750; // ms @@ -61,7 +63,11 @@ void dprintf(const char* format, ...); void dings(const int n); bool isCornerTriggered(); bool IsIn(const DWORD val, ...); -#define END 0x72951413 +// END is a magic number, if we have such CRC - meh +#define END (0x72951413) +#define IsCRC(...) (g_crc!=END && IsIn(g_crc, __VA_ARGS__, END)) +// C99 syntax for variadic macro: #define FOO(fmt, ...) printf(fmt, __VA_ARGS__) // empty list not supported +// empty list is possible by suppressing prior comma by using ##__VA_ARGS__ // ---------- Configuration --------------------------------- @@ -85,7 +91,7 @@ bool GSC_AnyGame( const GSFrameInfo& fi, int& skip ) { //Example: MGS3 CRC hack copied directly from GSState.cpp (see the Notes section exceptions): - +if( IsCRC(0x086273D2, 0x26A6E286, 0x9F185CE1) ){ // 3 first MGS3 CRCs from GSCrc.c if(skip == 0) { if(fi.TME && fi.FBP == 0x02000 && fi.FPSM == PSM_PSMCT32 && (fi.TBP0 == 0x00000 || fi.TBP0 == 0x01000) && fi.TPSM == PSM_PSMCT24) @@ -120,17 +126,22 @@ bool GSC_AnyGame( const GSFrameInfo& fi, int& skip ) return true; } + + +return true; +} + /*********** Dynamic CRC hack code ends here *****************/ // Prints to the Debugger's output window or to DebugView ( http://technet.microsoft.com/en-us/sysinternals/bb896647 ) void dprintf( const char* format, ...) { - #define BUFSIZ 2048 - char buffer[BUFSIZ]; + #define _BUFSIZ 2048 + char buffer[_BUFSIZ]; va_list args; va_start( args, format ); - if( 0 > vsnprintf( buffer, BUFSIZ, format, args ) ) + if( 0 > vsnprintf( buffer, _BUFSIZ, format, args ) ) sprintf( buffer, "%s","\n" ); OutputDebugString( buffer ); va_end( args ); @@ -200,24 +211,70 @@ bool preProcess_isAbort() } +DWORD WINAPI thread_PrintStats( LPVOID lpParam ); +typedef struct _stats { uint32 overall, changed, skipped, nextPrint;} Stats; + #define DLL_EXPORT __declspec(dllexport) -#define CRC_HACK DynamicCrcHack +#define CRC_HACK DynamicCrcHack2 +#define CRC_HACK_OLD DynamicCrcHack #if INITIAL_MODE == 0 - #define CRC_HACK Voldemort + #define CRC_HACK Voldemort2 + #define CRC_HACK_OLD Voldemort #endif DLL_EXPORT bool CRC_HACK (uint32 FBP, uint32 FPSM, uint32 FBMSK, uint32 TBP0, uint32 TPSM, uint32 TZTST, - uint32 TME, int* _pSkip, uint32 _g_crc_region, uint32 _sharedBits) + uint32 TME, int* _pSkip, uint32 _g_crc_region, uint32 _sharedBits, uint32 _crc) { + + static Stats stat={overall:0, changed:0, skipped:0, nextPrint:0}; + + DWORD now=GetTickCount(); + if(stat.nextPrint <= now){ + dprintf("DH: Overall: %5d, skipped: %5d, actions:%5d\n", stat.overall, stat.skipped, stat.changed); + stat.overall=stat.changed=stat.skipped=0; + stat.nextPrint=now+1000; + } + + stat.overall++; + if(preProcess_isAbort()) // Process dings if required return true; // Abort hack depending on mode fi.FBP=FBP; fi.FPSM=FPSM; fi.FBMSK=FBMSK; fi.TBP0=TBP0; fi.TPSM=TPSM; fi.TZTST=TZTST; fi.TME=TME; - pSkip=_pSkip; g_crc_region=_g_crc_region; sharedBits=_sharedBits; + pSkip=_pSkip; g_crc_region=_g_crc_region; sharedBits=_sharedBits; g_crc = _crc; - return _GSC_AnyGame(); + int pre=skip; + bool res=_GSC_AnyGame(); + int post=skip; + + if(skip) stat.skipped++; + + if(post!=pre) stat.changed++; + + return res; + } +DLL_EXPORT bool CRC_HACK_OLD (uint32 FBP, uint32 FPSM, uint32 FBMSK, uint32 TBP0, uint32 TPSM, uint32 TZTST, + uint32 TME, int* _pSkip, uint32 _g_crc_region, uint32 _sharedBits) +{ + return CRC_HACK(FBP, FPSM, FBMSK, TBP0, TPSM, TZTST, TME,_pSkip, _g_crc_region,_sharedBits, END); +} + +char* v[]={ + "DLL_PROCESS_DETACH", + "DLL_PROCESS_ATTACH", + "DLL_THREAD_ATTACH", + "DLL_THREAD_DETACH" +}; +BOOL WINAPI DllMain (HANDLE hDll, DWORD dwReason, LPVOID lpReserved) +{ + if (dwReason<4) + dprintf("DllMain: %s\n", v[dwReason]); + else + dprintf("DllMain: %d\n", dwReason); + return TRUE; +} /*-------------------- Notes- -------------------------------*\ 1. If required, Use CRC_ instead of CRC:: (e.g. CRC_US instead of CRC::US) @@ -230,6 +287,10 @@ DLL_EXPORT bool CRC_HACK (uint32 FBP, uint32 FPSM, uint32 FBMSK, uint32 TBP0, ui 3. When copying the code back to GSState.cpp, remember to restore CRC::.. and GSUtil::... + 4. GSdx v5215 onwards also sends the CRC of the game (even if it's not defined at GSdx). + You can test the CRC using IsCRC(0x12345678) or, for few CRCs: IsCRC(0x12345678, 0x87654321, ...) + NOTE: with GSdx v5214 and before: IsCRC(...) always returns false. + \*----------------------------------------------------------*/ /* --------------- Usage instructions --------------------------------------------*\