From 9eddbb584592e3d79e87fe78ccc68767d7db4edd Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Tue, 14 Dec 2010 15:09:22 +0000 Subject: [PATCH] wxSavestates: savestates now include game serial code, and a ps2z extension (which can be linked to any zip-supporting tool, like winzip or 7zip). This branch is ready for extensive testing. :) git-svn-id: http://pcsx2.googlecode.com/svn/branches/wxSavestates@4092 96395faa-99c1-11dd-bbfe-3dabce05a288 --- common/include/Utilities/ScopedAlloc.h | 12 +++++- pcsx2/SaveState.cpp | 8 +++- pcsx2/gui/SysState.cpp | 56 ++++++++++++++++---------- 3 files changed, 51 insertions(+), 25 deletions(-) diff --git a/common/include/Utilities/ScopedAlloc.h b/common/include/Utilities/ScopedAlloc.h index 749f1c3ad1..6dcdfa3e9d 100644 --- a/common/include/Utilities/ScopedAlloc.h +++ b/common/include/Utilities/ScopedAlloc.h @@ -176,8 +176,10 @@ public: template< typename T > class ScopedAlloc : public BaseScopedAlloc { + typedef BaseScopedAlloc _parent; + public: - ScopedAlloc( size_t size=0 ) : BaseScopedAlloc() + ScopedAlloc( size_t size=0 ) : _parent() { Alloc(size); } @@ -206,6 +208,8 @@ public: if (!this->m_buffer) throw Exception::OutOfMemory(L"ScopedAlloc::Resize"); } + + using _parent::operator[]; }; // -------------------------------------------------------------------------------------- @@ -220,8 +224,10 @@ public: template< typename T, uint align > class ScopedAlignedAlloc : public BaseScopedAlloc { + typedef BaseScopedAlloc _parent; + public: - ScopedAlignedAlloc( size_t size=0 ) : BaseScopedAlloc() + ScopedAlignedAlloc( size_t size=0 ) : _parent() { Alloc(size); } @@ -250,4 +256,6 @@ public: if (!this->m_buffer) throw Exception::OutOfMemory(L"ScopedAlignedAlloc::Resize"); } + + using _parent::operator[]; }; diff --git a/pcsx2/SaveState.cpp b/pcsx2/SaveState.cpp index b6d67b0e50..00322001e9 100644 --- a/pcsx2/SaveState.cpp +++ b/pcsx2/SaveState.cpp @@ -51,8 +51,14 @@ static void PostLoadPrep() // -------------------------------------------------------------------------------------- wxString SaveStateBase::GetFilename( int slot ) { + wxString serialName( DiscSerial ); + if (serialName.IsEmpty()) serialName = L"BIOS"; + return (g_Conf->Folders.Savestates + - pxsFmt( L"%08X.%03d", ElfCRC, slot )).GetFullPath(); + pxsFmt( L"%s (%08X).%02d.ps2z", serialName.c_str(), ElfCRC, slot )).GetFullPath(); + + //return (g_Conf->Folders.Savestates + + // pxsFmt( L"%08X.%03d", ElfCRC, slot )).GetFullPath(); } SaveStateBase::SaveStateBase( SafeArray& memblock ) diff --git a/pcsx2/gui/SysState.cpp b/pcsx2/gui/SysState.cpp index 4350d82f65..033d805e15 100644 --- a/pcsx2/gui/SysState.cpp +++ b/pcsx2/gui/SysState.cpp @@ -215,29 +215,41 @@ public: // would not be useful). // -static const BaseSavestateEntry* const SavestateEntries[] = -{ - new SavestateEntry_EmotionMemory, - new SavestateEntry_IopMemory, - new SavestateEntry_HwRegs, - new SavestateEntry_IopHwRegs, - new SavestateEntry_Scratchpad, - new SavestateEntry_VU0mem, - new SavestateEntry_VU1mem, - new SavestateEntry_VU0prog, - new SavestateEntry_VU1prog, - - new PluginSavestateEntry( PluginId_GS ), - new PluginSavestateEntry( PluginId_PAD ), - new PluginSavestateEntry( PluginId_SPU2 ), - new PluginSavestateEntry( PluginId_CDVD ), - new PluginSavestateEntry( PluginId_USB ), - new PluginSavestateEntry( PluginId_FW ), - new PluginSavestateEntry( PluginId_DEV9 ), +static const uint NumSavestateEntries = 9 + PluginId_Count; +class SavestateEntryPack : public ScopedAlloc +{ + typedef ScopedAlloc _parent; + +public: + SavestateEntryPack() + : _parent( NumSavestateEntries ) + { + uint i = 0; // more convenient in case we re-arrange anything... + + this->operator[](i++) = new SavestateEntry_EmotionMemory; + this->operator[](i++) = new SavestateEntry_IopMemory; + this->operator[](i++) = new SavestateEntry_HwRegs; + this->operator[](i++) = new SavestateEntry_IopHwRegs; + this->operator[](i++) = new SavestateEntry_Scratchpad; + this->operator[](i++) = new SavestateEntry_VU0mem; + this->operator[](i++) = new SavestateEntry_VU1mem; + this->operator[](i++) = new SavestateEntry_VU0prog; + this->operator[](i++) = new SavestateEntry_VU1prog; + + this->operator[](i++) = new PluginSavestateEntry( PluginId_GS ); + this->operator[](i++) = new PluginSavestateEntry( PluginId_PAD ); + this->operator[](i++) = new PluginSavestateEntry( PluginId_SPU2 ); + this->operator[](i++) = new PluginSavestateEntry( PluginId_CDVD ); + this->operator[](i++) = new PluginSavestateEntry( PluginId_USB ); + this->operator[](i++) = new PluginSavestateEntry( PluginId_FW ); + this->operator[](i++) = new PluginSavestateEntry( PluginId_DEV9 ); + } + + using _parent::operator[]; }; -static const uint NumSavestateEntries = ArraySize(SavestateEntries); +static const SavestateEntryPack SavestateEntries; // It's bad mojo to have savestates trying to read and write from the same file at the // same time. To prevent that we use this mutex lock, which is used by both the @@ -312,7 +324,7 @@ protected: internals.SetDataSize( saveme.GetCurrentPos() - internals.GetDataIndex() ); m_dest_list->Add( internals ); - for (uint i=0; iFreezeOut( saveme ); @@ -496,7 +508,7 @@ protected: bool foundVersion = false; //bool foundScreenshot = false; - //bool foundEntry[NumSavestateEntries] = false; + //bool foundEntry[numSavestateEntries] = false; ScopedPtr foundInternal; ScopedPtr foundEntry[NumSavestateEntries];