wxSavestates branch: still nothing to see here (yet)...

git-svn-id: http://pcsx2.googlecode.com/svn/branches/wxSavestates@4034 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
Jake.Stine 2010-11-18 13:01:38 +00:00
parent 5efe38b270
commit 1dfc69670d
7 changed files with 34 additions and 63 deletions

View File

@ -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<u8>& 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<u8>& load_from )

View File

@ -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; }
};

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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;

View File

@ -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.
}
};

View File

@ -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 ;-)
}