From bbb1c8a94a9c9159a7976ff503d36b8ba22160f9 Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Wed, 15 Dec 2010 00:04:23 +0000 Subject: [PATCH] wxSavestates: Fixed Bios CRC calculations and improved robustness against saving multiple states at once (hackfix). Console title still doesn't display the BIOS label properly ... not sure yet the good way to remedy that one. git-svn-id: http://pcsx2.googlecode.com/svn/branches/wxSavestates@4097 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/System.cpp | 2 ++ pcsx2/ZipTools/thread_gzip.cpp | 1 - pcsx2/gui/App.h | 1 + pcsx2/gui/AppCoreThread.cpp | 42 ++++++++++++++++++++-------------- pcsx2/gui/AppMain.cpp | 6 +++++ pcsx2/gui/Saveslots.cpp | 9 +++++--- pcsx2/ps2/BiosTools.cpp | 6 ++--- 7 files changed, 43 insertions(+), 24 deletions(-) diff --git a/pcsx2/System.cpp b/pcsx2/System.cpp index f0d6256365..101f46dbee 100644 --- a/pcsx2/System.cpp +++ b/pcsx2/System.cpp @@ -605,6 +605,8 @@ wxString SysGetDiscID() // FIXME: system is currently running the BIOS, so it should return a serial based on // the BIOS being run (either a checksum of the BIOS roms, and/or a string based on BIOS // region and revision). + + return wxEmptyString; } return pxsFmt( L"%08x", ElfCRC ); diff --git a/pcsx2/ZipTools/thread_gzip.cpp b/pcsx2/ZipTools/thread_gzip.cpp index 6002ef6b61..eb9eb1577d 100644 --- a/pcsx2/ZipTools/thread_gzip.cpp +++ b/pcsx2/ZipTools/thread_gzip.cpp @@ -75,7 +75,6 @@ void BaseCompressThread::ExecuteTaskInThread() woot.CloseEntry(); } - m_gzfp->Close(); if( !wxRenameFile( m_gzfp->GetStreamName(), m_final_filename, true ) ) diff --git a/pcsx2/gui/App.h b/pcsx2/gui/App.h index d92e35e947..12b7e03374 100644 --- a/pcsx2/gui/App.h +++ b/pcsx2/gui/App.h @@ -539,6 +539,7 @@ public: void WipeUserModeSettings(); void ReadUserModeSettings(); + bool HasPendingSaves() const; void StartPendingSave(); void ClearPendingSave(); diff --git a/pcsx2/gui/AppCoreThread.cpp b/pcsx2/gui/AppCoreThread.cpp index 7e3a42298a..aa91171eb4 100644 --- a/pcsx2/gui/AppCoreThread.cpp +++ b/pcsx2/gui/AppCoreThread.cpp @@ -298,8 +298,7 @@ void AppCoreThread::ApplySettings( const Pcsx2Config& src ) wxString gameFixes; wxString gameCheats; - // [TODO] : Fix this so that it recognizes and reports BIOS-booting status! - wxString gameName (L"Unknown"); + wxString gameName; wxString gameCompat; if (ElfCRC) gameCRC.Printf( L"%8.8x", ElfCRC ); @@ -309,27 +308,36 @@ void AppCoreThread::ApplySettings( const Pcsx2Config& src ) const bool verbose( newGameKey != curGameKey ); curGameKey = newGameKey; - if (IGameDatabase* GameDB = AppHost_GetGameDatabase() ) + if (!curGameKey.IsEmpty()) { - Game_Data game; - if (GameDB->findGame(game, curGameKey)) { - int compat = game.getInt("Compat"); - gameName = game.getString("Name"); - gameName += L" (" + game.getString("Region") + L")"; - gameCompat = L" [Status = "+compatToStringWX(compat)+L"]"; - } + if (IGameDatabase* GameDB = AppHost_GetGameDatabase() ) + { + Game_Data game; + if (GameDB->findGame(game, curGameKey)) { + int compat = game.getInt("Compat"); + gameName = game.getString("Name"); + gameName += L" (" + game.getString("Region") + L")"; + gameCompat = L" [Status = "+compatToStringWX(compat)+L"]"; + } - if (EmuConfig.EnablePatches) { - if (int patches = InitPatches(gameCRC, game)) { - gamePatch.Printf(L" [%d Patches]", patches); - if (verbose) Console.WriteLn(Color_Green, "(GameDB) Patches Loaded: %d", patches); - } - if (int fixes = loadGameSettings(fixup, game, verbose)) { - gameFixes.Printf(L" [%d Fixes]", fixes); + if (EmuConfig.EnablePatches) { + if (int patches = InitPatches(gameCRC, game)) { + gamePatch.Printf(L" [%d Patches]", patches); + if (verbose) Console.WriteLn(Color_Green, "(GameDB) Patches Loaded: %d", patches); + } + if (int fixes = loadGameSettings(fixup, game, verbose)) { + gameFixes.Printf(L" [%d Fixes]", fixes); + } } } } + if (gameName.IsEmpty() && gameSerial.IsEmpty() && BiosChecksum) + { + gameName = L"BIOS"; + gameCRC.Printf( L"%8.8x", BiosChecksum ); + } + if (EmuConfig.EnableCheats) { if (int cheats = InitCheats(gameCRC)) { gameCheats.Printf(L" [%d Cheats]", cheats); diff --git a/pcsx2/gui/AppMain.cpp b/pcsx2/gui/AppMain.cpp index 21d9399b34..2f6890bfaf 100644 --- a/pcsx2/gui/AppMain.cpp +++ b/pcsx2/gui/AppMain.cpp @@ -605,6 +605,12 @@ void Pcsx2App::HandleEvent(wxEvtHandler* handler, wxEventFunction func, wxEvent& } } +bool Pcsx2App::HasPendingSaves() const +{ + AffinityAssert_AllowFrom_MainUI(); + return !!m_PendingSaves; +} + // A call to this method informs the app that there is a pending save operation that must be // finished prior to exiting the app, or else data loss will occur. Any call to this method // should be matched by a call to ClearPendingSave(). diff --git a/pcsx2/gui/Saveslots.cpp b/pcsx2/gui/Saveslots.cpp index 67c2c9eb0e..f116cea7af 100644 --- a/pcsx2/gui/Saveslots.cpp +++ b/pcsx2/gui/Saveslots.cpp @@ -37,6 +37,8 @@ bool States_isSlotUsed(int num) return wxFileExists( SaveStateBase::GetFilename( num ) ); } +// FIXME : Use of the IsSavingOrLoading flag is mostly a hack until we implement a +// complete thread to manage queuing savestate tasks, and zipping states to disk. --air static volatile u32 IsSavingOrLoading = false; class SysExecEvent_ClearSavingLoadingFlag : public SysExecEvent @@ -60,7 +62,10 @@ protected: void States_FreezeCurrentSlot() { - if( AtomicExchange(IsSavingOrLoading, true) ) + // FIXME : Use of the IsSavingOrLoading flag is mostly a hack until we implement a + // complete thread to manage queuing savestate tasks, and zipping states to disk. --air + + if( wxGetApp().HasPendingSaves() || AtomicExchange(IsSavingOrLoading, true) ) { Console.WriteLn( "Load or save action is already pending." ); return; @@ -84,8 +89,6 @@ void States_DefrostCurrentSlot() StateCopy_LoadFromSlot( StatesC ); GetSysExecutorThread().PostIdleEvent( SysExecEvent_ClearSavingLoadingFlag() ); - - //SysStatus( wxsFormat( _("Loaded State (slot %d)"), StatesC ) ); } static void OnSlotChanged() diff --git a/pcsx2/ps2/BiosTools.cpp b/pcsx2/ps2/BiosTools.cpp index afdfe6dcea..cbd9663c8c 100644 --- a/pcsx2/ps2/BiosTools.cpp +++ b/pcsx2/ps2/BiosTools.cpp @@ -158,12 +158,12 @@ static void LoadBiosVersion( pxInputStream& fp, u32& version, wxString& descript } } -template< typename T, size_t _size > -void ChecksumIt( u32& result, const T (&srcdata)[_size] ) +template< size_t _size > +void ChecksumIt( u32& result, const u8 (&srcdata)[_size] ) { pxAssume( (_size & 3) == 0 ); for( size_t i=0; i<_size/4; ++i ) - result ^= srcdata[i]; + result ^= ((u32*)srcdata)[i]; } // Attempts to load a BIOS rom sub-component, by trying multiple combinations of base