From 1dfc69670d320b23576b749ba819a8170df4ca45 Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Thu, 18 Nov 2010 13:01:38 +0000 Subject: [PATCH] wxSavestates branch: still nothing to see here (yet)... git-svn-id: http://pcsx2.googlecode.com/svn/branches/wxSavestates@4034 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/SaveState.cpp | 52 ++++++++---------------- pcsx2/SaveState.h | 10 ++--- pcsx2/System/SysCoreThread.cpp | 4 +- pcsx2/VUmicroMem.cpp | 19 +-------- pcsx2/gui/Panels/PluginSelectorPanel.cpp | 5 ++- pcsx2/gui/SysState.cpp | 5 ++- pcsx2/ps2/BiosTools.cpp | 2 +- 7 files changed, 34 insertions(+), 63 deletions(-) diff --git a/pcsx2/SaveState.cpp b/pcsx2/SaveState.cpp index 05dd445e27..c6333e951a 100644 --- a/pcsx2/SaveState.cpp +++ b/pcsx2/SaveState.cpp @@ -45,6 +45,9 @@ static void PostLoadPrep() UpdateVSyncRate(); } +// -------------------------------------------------------------------------------------- +// SaveStateBase (implementations) +// -------------------------------------------------------------------------------------- wxString SaveStateBase::GetFilename( int slot ) { return (g_Conf->Folders.Savestates + @@ -147,7 +150,10 @@ static const uint MainMemorySizeInBytes = void SaveStateBase::FreezeMainMemory() { - if (IsLoading()) PreLoadPrep(); + if (IsLoading()) + PreLoadPrep(); + else + m_memory->MakeRoomFor( m_idx + MainMemorySizeInBytes ); // First Block - Memory Dumps // --------------------------- @@ -237,7 +243,7 @@ void SaveStateBase::WritebackSectionLength( int seekpos, int sectlen, const wxCh } } -bool SaveStateBase::FreezeSection( bool freezeMem, int seek_section ) +bool SaveStateBase::FreezeSection( int seek_section ) { const bool isSeeking = (seek_section != FreezeId_NotSeeking ); if( IsSaving() ) pxAssertDev( !isSeeking, "Cannot seek on a saving-mode savestate stream." ); @@ -271,34 +277,6 @@ bool SaveStateBase::FreezeSection( bool freezeMem, int seek_section ) } break; - case FreezeId_Memory: - { - if (freezeMem) - { - FreezeTag( "MainMemory" ); - - int seekpos = m_idx+4; - int sectlen = MainMemorySizeInBytes; - Freeze( sectlen ); - if( sectlen != MainMemorySizeInBytes ) - { - throw Exception::SaveStateLoadError() - .SetDiagMsg(L"Invalid size encountered on MainMemory section.") - .SetUserMsg(_("The savestate data is invalid or corrupted.")); - } - - if( isSeeking ) - m_idx += sectlen; - else - FreezeMainMemory(); - - int realsectsize = m_idx - seekpos; - pxAssert( sectlen == realsectsize ); - } - m_sectid++; - } - break; - case FreezeId_Registers: { FreezeTag( "HardwareRegisters" ); @@ -363,7 +341,7 @@ bool SaveStateBase::FreezeSection( bool freezeMem, int seek_section ) return true; } -void SaveStateBase::FreezeAll( bool freezeMem ) +void SaveStateBase::FreezeAll() { if( IsSaving() ) { @@ -374,10 +352,12 @@ void SaveStateBase::FreezeAll( bool freezeMem ) m_pid = PluginId_GS; } - while( FreezeSection( freezeMem ) ); + while( FreezeSection() ); } -////////////////////////////////////////////////////////////////////////////////// +// -------------------------------------------------------------------------------------- +// memSavingState (implementations) +// -------------------------------------------------------------------------------------- // uncompressed to/from memory state saves implementation memSavingState::memSavingState( SafeArray& save_to ) @@ -398,14 +378,14 @@ void memSavingState::FreezeMem( void* data, int size ) m_idx += size; } -void memSavingState::FreezeAll( bool freezeMem ) +void memSavingState::FreezeAll() { pxAssumeDev( m_memory, "Savestate memory/buffer pointer is null!" ); m_memory->ChunkSize = ReallocThreshold; - m_memory->MakeRoomFor( MemoryBaseAllocSize + (freezeMem ? MainMemorySizeInBytes : 0) ); + m_memory->MakeRoomFor( m_idx + MemoryBaseAllocSize ); - _parent::FreezeAll( freezeMem ); + _parent::FreezeAll(); } memLoadingState::memLoadingState( const SafeArray& load_from ) diff --git a/pcsx2/SaveState.h b/pcsx2/SaveState.h index bfef4eb893..4022a646b3 100644 --- a/pcsx2/SaveState.h +++ b/pcsx2/SaveState.h @@ -39,7 +39,6 @@ enum FreezeSectionId // A BIOS tag should always be saved in conjunction with Memory or Registers tags, // but can be skipped if the savestate has only plugins. FreezeId_Bios, - FreezeId_Memory, FreezeId_Registers, FreezeId_Plugin, @@ -142,7 +141,9 @@ public: // Loads or saves the entire emulation state. // Note: The Cpu state must be reset, and plugins *open*, prior to Defrosting // (loading) a state! - virtual void FreezeAll( bool freezeMemory=true ); + virtual void FreezeAll(); + + void FreezeMainMemory(); // Loads or saves an arbitrary data type. Usable on atomic types, structs, and arrays. // For dynamically allocated pointers use FreezeMem instead. @@ -173,7 +174,7 @@ public: } void WritebackSectionLength( int seekpos, int sectlen, const wxChar* sectname ); - bool FreezeSection( bool freezeMem, int seek_section = FreezeId_NotSeeking ); + bool FreezeSection( int seek_section = FreezeId_NotSeeking ); // Freezes an identifier value into the savestate for troubleshooting purposes. // Identifiers can be used to determine where in a savestate that data has become @@ -200,7 +201,6 @@ protected: // Load/Save functions for the various components of our glorious emulator! void FreezeBios(); - void FreezeMainMemory(); void FreezeRegisters(); void rcntFreeze(); @@ -246,7 +246,7 @@ public: // Saving of state data to a memory buffer void FreezeMem( void* data, int size ); - void FreezeAll( bool freezeMemory ); + void FreezeAll(); bool IsSaving() const { return true; } }; diff --git a/pcsx2/System/SysCoreThread.cpp b/pcsx2/System/SysCoreThread.cpp index 0d351f6bac..19de3f2a32 100644 --- a/pcsx2/System/SysCoreThread.cpp +++ b/pcsx2/System/SysCoreThread.cpp @@ -150,7 +150,9 @@ void SysCoreThread::UploadStateCopy( const VmStateBuffer& copy ) { if( !pxAssertDev( IsPaused(), "CoreThread is not paused; new VM state cannot be uploaded." ) ) return; - memLoadingState( copy ).FreezeAll(); + memLoadingState loadme( copy ); + loadme.FreezeMainMemory(); + loadme.FreezeAll(); m_resetVirtualMachine = false; } diff --git a/pcsx2/VUmicroMem.cpp b/pcsx2/VUmicroMem.cpp index 70c2f9643a..3547466bef 100644 --- a/pcsx2/VUmicroMem.cpp +++ b/pcsx2/VUmicroMem.cpp @@ -79,22 +79,10 @@ void vuMemoryReserve::Reset() void SaveStateBase::vuMicroFreeze() { - FreezeTag( "vuMicro" ); - - pxAssume( VU0.Mem != NULL ); - pxAssume( VU1.Mem != NULL ); + FreezeTag( "vuMicroRegs" ); Freeze(VU0.ACC); - - // Seemingly silly and pointless use of temp var: GCC is unable to bind packed fields - // (appears to be a bug, tracked here: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36566 ). - // Dereferencing outside the context of the function (via a temp var) seems to circumvent it. --air - - u32& temp_vu0_code = VU0.code; - Freeze(temp_vu0_code); - - FreezeMem(VU0.Mem, 4*1024); - FreezeMem(VU0.Micro, 4*1024); + Freeze(VU0.code); Freeze(VU0.VF); Freeze(VU0.VI); @@ -104,9 +92,6 @@ void SaveStateBase::vuMicroFreeze() u32& temp_vu1_code = VU1.code; Freeze(temp_vu1_code); - FreezeMem(VU1.Mem, 16*1024); - FreezeMem(VU1.Micro, 16*1024); - Freeze(VU1.VF); Freeze(VU1.VI); } diff --git a/pcsx2/gui/Panels/PluginSelectorPanel.cpp b/pcsx2/gui/Panels/PluginSelectorPanel.cpp index a4006a874e..3d8679c9ab 100644 --- a/pcsx2/gui/Panels/PluginSelectorPanel.cpp +++ b/pcsx2/gui/Panels/PluginSelectorPanel.cpp @@ -273,7 +273,10 @@ void SysExecEvent_ApplyPlugins::InvokeEvent() // FIXME : We only actually have to save plugins here, except the recovery code // in SysCoreThread isn't quite set up yet to handle that (I think...) --air - memSavingState( *(buffer.Reassign(new VmStateBuffer(L"StateBuffer_ApplyNewPlugins"))) ).FreezeAll(); + memSavingState saveme( *(buffer.Reassign(new VmStateBuffer(L"StateBuffer_ApplyNewPlugins"))) ); + + saveme.FreezeMainMemory(); + saveme.FreezeAll(); } ScopedCoreThreadClose closed_core; diff --git a/pcsx2/gui/SysState.cpp b/pcsx2/gui/SysState.cpp index d2d697b776..527ff9e67a 100644 --- a/pcsx2/gui/SysState.cpp +++ b/pcsx2/gui/SysState.cpp @@ -160,7 +160,8 @@ protected: .SetDiagMsg(L"SysExecEvent_DownloadState: Cannot freeze/download an invalid VM state!") .SetUserMsg(L"There is no active virtual machine state to download or save." ); - memSavingState( m_dest_buffer ).FreezeAll( false ); + memSavingState saveme( m_dest_buffer ); + saveme.FreezeAll(); UI_EnableStateActions(); paused_core.AllowResume(); @@ -437,7 +438,7 @@ protected: reader->Read( buffer.GetPtr(), foundInternal->GetSize() ); //GetCoreThread().UploadStateCopy( buffer ); - memLoadingState( buffer ).FreezeAll( false ); + memLoadingState( buffer ).FreezeAll(); GetCoreThread().Resume(); // force resume regardless of emulation state earlier. } }; diff --git a/pcsx2/ps2/BiosTools.cpp b/pcsx2/ps2/BiosTools.cpp index c9a1d17f26..9638807a89 100644 --- a/pcsx2/ps2/BiosTools.cpp +++ b/pcsx2/ps2/BiosTools.cpp @@ -257,7 +257,7 @@ bool IsBIOS(const wxString& filename, wxString& description) { if ( biosFileSize < (int)fileOffset) { - description += wxsFormat( L" %d%%", ((biosFileSize*100) / (int)fileOffset) ); + description += pxsFmt( L" %d%%", ((biosFileSize*100) / (int)fileOffset) ); // we force users to have correct bioses, // not that lame scph10000 of 513KB ;-) }