mirror of https://github.com/PCSX2/pcsx2.git
Misc bugfixes to plugin management and error handling.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2128 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
cccebfe454
commit
0591686c67
|
@ -79,6 +79,17 @@
|
||||||
|
|
||||||
#define pxAssert(cond) pxAssertMsg(cond, (wxChar*)NULL)
|
#define pxAssert(cond) pxAssertMsg(cond, (wxChar*)NULL)
|
||||||
|
|
||||||
|
// Performs an unsigned index bounds check, and generates a debug assertion if the check fails.
|
||||||
|
// For stricter checking in Devel builds as well as debug builds (but possibly slower), use
|
||||||
|
// IndexBoundsCheckDev.
|
||||||
|
|
||||||
|
#define IndexBoundsCheck( objname, idx, sze ) pxAssertMsg( (uint)(idx) < (uint)(sze), \
|
||||||
|
wxsFormat( L"Array index out of bounds accessing object '%s' (index=%d, size=%d)", objname, (idx), (sze) ) )
|
||||||
|
|
||||||
|
#define IndexBoundsCheckDev( objname, idx, sze ) pxAssertDev( (uint)(idx) < (uint)(sze), \
|
||||||
|
wxsFormat( L"Array index out of bounds accessing object '%s' (index=%d, size=%d)", objname, (idx), (sze) ) )
|
||||||
|
|
||||||
|
|
||||||
extern void pxOnAssert( const wxChar* file, int line, const char* func, const wxChar* cond, const wxChar* msg);
|
extern void pxOnAssert( const wxChar* file, int line, const char* func, const wxChar* cond, const wxChar* msg);
|
||||||
extern void pxOnAssert( const wxChar* file, int line, const char* func, const wxChar* cond, const char* msg);
|
extern void pxOnAssert( const wxChar* file, int line, const char* func, const wxChar* cond, const char* msg);
|
||||||
|
|
||||||
|
|
|
@ -218,7 +218,7 @@ namespace Exception
|
||||||
};
|
};
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------------
|
||||||
// OutOfMemory / InvalidOperation / InvalidArgument / IndexBoundsFault / ParseError
|
// OutOfMemory / InvalidOperation / InvalidArgument / ParseError
|
||||||
// ---------------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------------
|
||||||
|
|
||||||
class OutOfMemory : public virtual RuntimeError
|
class OutOfMemory : public virtual RuntimeError
|
||||||
|
@ -245,32 +245,6 @@ namespace Exception
|
||||||
DEFINE_LOGIC_EXCEPTION( InvalidArgument, "Invalid argument passed to a function." )
|
DEFINE_LOGIC_EXCEPTION( InvalidArgument, "Invalid argument passed to a function." )
|
||||||
};
|
};
|
||||||
|
|
||||||
// Keep those array indexers in bounds when using the SafeArray type, or you'll be
|
|
||||||
// seeing these.
|
|
||||||
//
|
|
||||||
class IndexBoundsFault : public virtual LogicError
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
wxString ArrayName;
|
|
||||||
int ArrayLength;
|
|
||||||
int BadIndex;
|
|
||||||
|
|
||||||
public:
|
|
||||||
DEFINE_EXCEPTION_COPYTORS( IndexBoundsFault )
|
|
||||||
|
|
||||||
IndexBoundsFault( const wxString& objname, int index, int arrsize )
|
|
||||||
{
|
|
||||||
BaseException::InitBaseEx( "Index is outside the bounds of an array." );
|
|
||||||
|
|
||||||
ArrayName = objname;
|
|
||||||
ArrayLength = arrsize;
|
|
||||||
BadIndex = index;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual wxString FormatDiagnosticMessage() const;
|
|
||||||
virtual wxString FormatDisplayMessage() const;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ParseError : public RuntimeError
|
class ParseError : public RuntimeError
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -180,12 +180,12 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets a pointer to the requested allocation index.
|
// Gets a pointer to the requested allocation index.
|
||||||
// DevBuilds : Throws Exception::IndexBoundsFault() if the index is invalid.
|
// DevBuilds : Generates assertion if the index is invalid.
|
||||||
T *GetPtr( uint idx=0 ) { return _getPtr( idx ); }
|
T *GetPtr( uint idx=0 ) { return _getPtr( idx ); }
|
||||||
const T *GetPtr( uint idx=0 ) const { return _getPtr( idx ); }
|
const T *GetPtr( uint idx=0 ) const { return _getPtr( idx ); }
|
||||||
|
|
||||||
// Gets an element of this memory allocation much as if it were an array.
|
// Gets an element of this memory allocation much as if it were an array.
|
||||||
// DevBuilds : Throws Exception::IndexBoundsFault() if the index is invalid.
|
// DevBuilds : Generates assertion if the index is invalid.
|
||||||
T& operator[]( int idx ) { return *_getPtr( (uint)idx ); }
|
T& operator[]( int idx ) { return *_getPtr( (uint)idx ); }
|
||||||
const T& operator[]( int idx ) const { return *_getPtr( (uint)idx ); }
|
const T& operator[]( int idx ) const { return *_getPtr( (uint)idx ); }
|
||||||
|
|
||||||
|
@ -205,10 +205,7 @@ protected:
|
||||||
// the pointer into a local variable and use std (unsafe) C indexes.
|
// the pointer into a local variable and use std (unsafe) C indexes.
|
||||||
T* _getPtr( uint i ) const
|
T* _getPtr( uint i ) const
|
||||||
{
|
{
|
||||||
#ifdef PCSX2_DEVBUILD
|
IndexBoundsCheckDev( Name.c_str(), i, m_size );
|
||||||
if( IsDevBuild && i >= (uint)m_size )
|
|
||||||
throw Exception::IndexBoundsFault( Name, i, m_size );
|
|
||||||
#endif
|
|
||||||
return &m_ptr[i];
|
return &m_ptr[i];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -246,12 +243,6 @@ protected:
|
||||||
return (T*)realloc( m_ptr, newsize * sizeof(T) );
|
return (T*)realloc( m_ptr, newsize * sizeof(T) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void _boundsCheck( uint i ) const
|
|
||||||
{
|
|
||||||
if( IsDevBuild && i >= (uint)m_length )
|
|
||||||
throw Exception::IndexBoundsFault( Name, i, m_length );
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~SafeList() throw()
|
virtual ~SafeList() throw()
|
||||||
{
|
{
|
||||||
|
@ -345,7 +336,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets an element of this memory allocation much as if it were an array.
|
// Gets an element of this memory allocation much as if it were an array.
|
||||||
// DevBuilds : Throws Exception::IndexBoundsFault() if the index is invalid.
|
// DevBuilds : Generates assertion if the index is invalid.
|
||||||
T& operator[]( int idx ) { return *_getPtr( (uint)idx ); }
|
T& operator[]( int idx ) { return *_getPtr( (uint)idx ); }
|
||||||
const T& operator[]( int idx ) const { return *_getPtr( (uint)idx ); }
|
const T& operator[]( int idx ) const { return *_getPtr( (uint)idx ); }
|
||||||
|
|
||||||
|
@ -371,11 +362,12 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
// Performs a standard array-copy removal of the given item. All items past the
|
// Performs a standard array-copy removal of the given item. All items past the
|
||||||
// given item are copied over. Throws Exception::IndexBoundsFault() if the index
|
// given item are copied over.
|
||||||
// is invalid (devbuilds only)
|
// DevBuilds : Generates assertion if the index is invalid.
|
||||||
void Remove( int index )
|
void Remove( int index )
|
||||||
{
|
{
|
||||||
_boundsCheck( index );
|
IndexBoundsCheckDev( Name.c_str(), index, m_length );
|
||||||
|
|
||||||
int copylen = m_length - index;
|
int copylen = m_length - index;
|
||||||
if( copylen > 0 )
|
if( copylen > 0 )
|
||||||
memcpy_fast( &m_ptr[index], &m_ptr[index+1], copylen );
|
memcpy_fast( &m_ptr[index], &m_ptr[index+1], copylen );
|
||||||
|
@ -403,7 +395,7 @@ protected:
|
||||||
// the pointer into a local variable and use std (unsafe) C indexes.
|
// the pointer into a local variable and use std (unsafe) C indexes.
|
||||||
T* _getPtr( uint i ) const
|
T* _getPtr( uint i ) const
|
||||||
{
|
{
|
||||||
_boundsCheck( i );
|
IndexBoundsCheckDev( Name.c_str(), i, m_length );
|
||||||
return &m_ptr[i];
|
return &m_ptr[i];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -197,14 +197,3 @@ wxString Exception::StateCrcMismatch::FormatDisplayMessage() const
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
wxString Exception::IndexBoundsFault::FormatDiagnosticMessage() const
|
|
||||||
{
|
|
||||||
return L"Index out of bounds on SafeArray: " + ArrayName +
|
|
||||||
wxsFormat( L"(index=%d, size=%d)", BadIndex, ArrayLength );
|
|
||||||
}
|
|
||||||
|
|
||||||
wxString Exception::IndexBoundsFault::FormatDisplayMessage() const
|
|
||||||
{
|
|
||||||
return m_message_user;
|
|
||||||
}
|
|
||||||
|
|
|
@ -830,15 +830,8 @@ void mtgsThreadObject::WaitForOpen()
|
||||||
|
|
||||||
void mtgsThreadObject::Freeze( int mode, MTGS_FreezeData& data )
|
void mtgsThreadObject::Freeze( int mode, MTGS_FreezeData& data )
|
||||||
{
|
{
|
||||||
if( mode == FREEZE_LOAD )
|
SendPointerPacket( GS_RINGTYPE_FREEZE, mode, &data );
|
||||||
{
|
SetEvent();
|
||||||
WaitGS();
|
Resume();
|
||||||
SendPointerPacket( GS_RINGTYPE_FREEZE, mode, &data );
|
WaitGS();
|
||||||
SetEvent();
|
|
||||||
Resume();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
SendPointerPacket( GS_RINGTYPE_FREEZE, mode, &data );
|
|
||||||
|
|
||||||
mtgsThread.WaitGS();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -995,9 +995,10 @@ void PluginManager::Init()
|
||||||
printlog = true;
|
printlog = true;
|
||||||
}
|
}
|
||||||
Console.WriteLn( "\tInit %s", tbl_PluginInfo[pid].shortname );
|
Console.WriteLn( "\tInit %s", tbl_PluginInfo[pid].shortname );
|
||||||
m_info[pid].IsInitialized = true;
|
|
||||||
if( 0 != m_info[pid].CommonBindings.Init() )
|
if( 0 != m_info[pid].CommonBindings.Init() )
|
||||||
throw Exception::PluginInitError( pid );
|
throw Exception::PluginInitError( pid );
|
||||||
|
|
||||||
|
m_info[pid].IsInitialized = true;
|
||||||
} while( ++pi, pi->shortname != NULL );
|
} while( ++pi, pi->shortname != NULL );
|
||||||
|
|
||||||
if( SysPlugins.Mcd == NULL )
|
if( SysPlugins.Mcd == NULL )
|
||||||
|
|
|
@ -405,14 +405,10 @@ bool StateCopy_IsValid()
|
||||||
return !state_buffer.IsDisposed();
|
return !state_buffer.IsDisposed();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StateCopy_HasFullState()
|
const SafeArray<u8>* StateCopy_GetBuffer()
|
||||||
{
|
{
|
||||||
return false;
|
if( state_buffer_lock.IsLocked() || state_buffer.IsDisposed() ) return NULL;
|
||||||
}
|
return &state_buffer;
|
||||||
|
|
||||||
bool StateCopy_HasPartialState()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void StateCopy_FreezeToMem()
|
void StateCopy_FreezeToMem()
|
||||||
|
|
|
@ -69,7 +69,7 @@ void SaveStateBase::PrepBlock( int size )
|
||||||
m_memory.MakeRoomFor( end );
|
m_memory.MakeRoomFor( end );
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( m_memory.GetSizeInBytes() <= end )
|
if( m_memory.GetSizeInBytes() < end )
|
||||||
throw Exception::BadSavedState();
|
throw Exception::BadSavedState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -199,9 +199,33 @@ void SaveStateBase::FreezeRegisters()
|
||||||
PostLoadPrep();
|
PostLoadPrep();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SaveStateBase::FreezeSection()
|
void SaveStateBase::WritebackSectionLength( int seekpos, int sectlen, const wxChar* sectname )
|
||||||
{
|
{
|
||||||
|
int realsectsize = m_idx - seekpos;
|
||||||
|
if( IsSaving() )
|
||||||
|
{
|
||||||
|
// write back the section length...
|
||||||
|
*((u32*)m_memory.GetPtr(seekpos-4)) = realsectsize;
|
||||||
|
}
|
||||||
|
else // IsLoading!!
|
||||||
|
{
|
||||||
|
if( sectlen != realsectsize ) // if they don't match then we have a problem, jim.
|
||||||
|
{
|
||||||
|
throw Exception::BadSavedState( wxEmptyString,
|
||||||
|
wxsFormat( L"Invalid size encountered on section '%s'.", sectname ),
|
||||||
|
_("The savestate data is invalid or corrupted.")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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." );
|
||||||
|
|
||||||
Freeze( m_sectid );
|
Freeze( m_sectid );
|
||||||
|
if( seek_section == m_sectid ) return false;
|
||||||
|
|
||||||
switch( m_sectid )
|
switch( m_sectid )
|
||||||
{
|
{
|
||||||
|
@ -222,7 +246,10 @@ bool SaveStateBase::FreezeSection()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
FreezeBios();
|
if( isSeeking )
|
||||||
|
m_idx += sectlen;
|
||||||
|
else
|
||||||
|
FreezeBios();
|
||||||
m_sectid++;
|
m_sectid++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -242,7 +269,11 @@ bool SaveStateBase::FreezeSection()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
FreezeMainMemory();
|
if( isSeeking )
|
||||||
|
m_idx += sectlen;
|
||||||
|
else
|
||||||
|
FreezeMainMemory();
|
||||||
|
|
||||||
int realsectsize = m_idx - seekpos;
|
int realsectsize = m_idx - seekpos;
|
||||||
pxAssert( sectlen == realsectsize );
|
pxAssert( sectlen == realsectsize );
|
||||||
m_sectid++;
|
m_sectid++;
|
||||||
|
@ -253,27 +284,12 @@ bool SaveStateBase::FreezeSection()
|
||||||
{
|
{
|
||||||
FreezeTag( "HardwareRegisters" );
|
FreezeTag( "HardwareRegisters" );
|
||||||
int seekpos = m_idx+4;
|
int seekpos = m_idx+4;
|
||||||
int sectsize;
|
int sectlen = 0xdead; // gets written back over with "real" data in IsSaving() mode
|
||||||
|
|
||||||
Freeze( sectsize );
|
Freeze( sectlen );
|
||||||
FreezeRegisters();
|
FreezeRegisters();
|
||||||
|
|
||||||
int realsectsize = m_idx - seekpos;
|
WritebackSectionLength( seekpos, sectlen, L"HardwareRegisters" );
|
||||||
if( IsSaving() )
|
|
||||||
{
|
|
||||||
// write back the section length...
|
|
||||||
*((u32*)m_memory.GetPtr(seekpos-4)) = realsectsize;
|
|
||||||
}
|
|
||||||
else // IsLoading!!
|
|
||||||
{
|
|
||||||
if( sectsize != realsectsize ) // if they don't match then we have a problem, jim.
|
|
||||||
{
|
|
||||||
throw Exception::BadSavedState( wxEmptyString,
|
|
||||||
L"Invalid size encountered on HardwareRegisters section.",
|
|
||||||
_("The savestate data is invalid or corrupted.")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m_sectid++;
|
m_sectid++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -282,31 +298,20 @@ bool SaveStateBase::FreezeSection()
|
||||||
{
|
{
|
||||||
FreezeTag( "Plugin" );
|
FreezeTag( "Plugin" );
|
||||||
int seekpos = m_idx+4;
|
int seekpos = m_idx+4;
|
||||||
int sectsize;
|
int sectlen = 0xdead; // gets written back over with "real" data in IsSaving() mode
|
||||||
|
|
||||||
Freeze( sectsize );
|
Freeze( sectlen );
|
||||||
Freeze( m_pid );
|
Freeze( m_pid );
|
||||||
g_plugins->Freeze( (PluginsEnum_t)m_pid, *this );
|
|
||||||
|
|
||||||
int realsectsize = m_idx - seekpos;
|
if( isSeeking )
|
||||||
if( IsSaving() )
|
m_idx += sectlen;
|
||||||
{
|
|
||||||
// write back the section length...
|
|
||||||
*((u32*)m_memory.GetPtr(seekpos-4)) = realsectsize;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
g_plugins->Freeze( (PluginsEnum_t)m_pid, *this );
|
||||||
if( sectsize != realsectsize ) // if they don't match then we have a problem, jim.
|
|
||||||
{
|
|
||||||
throw Exception::BadSavedState( wxEmptyString,
|
|
||||||
L"Invalid size encountered on Plugin section.",
|
|
||||||
_("The savestate data is invalid or corrupted.")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
WritebackSectionLength( seekpos, sectlen, L"HardwareRegisters" );
|
||||||
|
|
||||||
// following increments only affect Saving mode, are ignored by Loading mode.
|
// following increments only affect Saving mode, which needs to be sure to save all
|
||||||
|
// plugins (order doesn't matter but sequential is easy enough. (ignored by Loading mode)
|
||||||
m_pid++;
|
m_pid++;
|
||||||
if( m_pid >= PluginId_Count )
|
if( m_pid >= PluginId_Count )
|
||||||
m_sectid = FreezeId_End;
|
m_sectid = FreezeId_End;
|
||||||
|
@ -340,8 +345,14 @@ bool SaveStateBase::FreezeSection()
|
||||||
|
|
||||||
void SaveStateBase::FreezeAll()
|
void SaveStateBase::FreezeAll()
|
||||||
{
|
{
|
||||||
m_sectid = (int)FreezeId_End+1;
|
if( IsSaving() )
|
||||||
m_pid = PluginId_GS;
|
{
|
||||||
|
// Loading mode streams will assign these, but saving mode reads them so better
|
||||||
|
// do some setup first.
|
||||||
|
|
||||||
|
m_sectid = (int)FreezeId_End+1;
|
||||||
|
m_pid = PluginId_GS;
|
||||||
|
}
|
||||||
|
|
||||||
while( FreezeSection() );
|
while( FreezeSection() );
|
||||||
}
|
}
|
||||||
|
@ -386,3 +397,24 @@ void memLoadingState::FreezeMem( void* data, int size )
|
||||||
m_idx += size;
|
m_idx += size;
|
||||||
memcpy_fast( data, src, size );
|
memcpy_fast( data, src, size );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool memLoadingState::SeekToSection( PluginsEnum_t pid )
|
||||||
|
{
|
||||||
|
m_idx = 0; // start from the beginning
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
while( FreezeSection( FreezeId_Plugin ) );
|
||||||
|
if( m_sectid == FreezeId_End ) return false;
|
||||||
|
|
||||||
|
FreezeTag( "Plugin" );
|
||||||
|
int seekpos = m_idx + 4;
|
||||||
|
int sectlen = 0xdead;
|
||||||
|
|
||||||
|
Freeze( sectlen );
|
||||||
|
Freeze( m_pid );
|
||||||
|
|
||||||
|
} while( m_pid != pid );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ extern s32 CALLBACK gsSafeFreeze( int mode, freezeData *data );
|
||||||
|
|
||||||
enum FreezeSectionId
|
enum FreezeSectionId
|
||||||
{
|
{
|
||||||
|
FreezeId_NotSeeking = -2,
|
||||||
FreezeId_End,
|
FreezeId_End,
|
||||||
|
|
||||||
// A BIOS tag should always be saved in conjunction with Memory or Registers tags,
|
// A BIOS tag should always be saved in conjunction with Memory or Registers tags,
|
||||||
|
@ -115,7 +116,8 @@ public:
|
||||||
m_idx += size;
|
m_idx += size;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FreezeSection();
|
void WritebackSectionLength( int seekpos, int sectlen, const wxChar* sectname );
|
||||||
|
bool FreezeSection( int seek_section = FreezeId_NotSeeking );
|
||||||
|
|
||||||
// Freezes an identifier value into the savestate for troubleshooting purposes.
|
// Freezes an identifier value into the savestate for troubleshooting purposes.
|
||||||
// Identifiers can be used to determine where in a savestate that data has become
|
// Identifiers can be used to determine where in a savestate that data has become
|
||||||
|
@ -193,13 +195,13 @@ public:
|
||||||
|
|
||||||
// Loading of state data from a memory buffer...
|
// Loading of state data from a memory buffer...
|
||||||
void FreezeMem( void* data, int size );
|
void FreezeMem( void* data, int size );
|
||||||
|
bool SeekToSection( PluginsEnum_t pid );
|
||||||
|
|
||||||
bool IsSaving() const { return false; }
|
bool IsSaving() const { return false; }
|
||||||
bool IsFinished() const { return m_idx >= m_memory.GetSizeInBytes(); }
|
bool IsFinished() const { return m_idx >= m_memory.GetSizeInBytes(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
extern bool StateCopy_IsValid();
|
extern bool StateCopy_IsValid();
|
||||||
extern bool StateCopy_HasFullState();
|
|
||||||
extern bool StateCopy_HasPartialState();
|
|
||||||
|
|
||||||
extern void StateCopy_FreezeToMem();
|
extern void StateCopy_FreezeToMem();
|
||||||
extern void StateCopy_ThawFromMem();
|
extern void StateCopy_ThawFromMem();
|
||||||
|
@ -209,3 +211,5 @@ extern void StateCopy_SaveToSlot( uint num );
|
||||||
extern void StateCopy_LoadFromSlot( uint slot );
|
extern void StateCopy_LoadFromSlot( uint slot );
|
||||||
extern void StateCopy_Clear();
|
extern void StateCopy_Clear();
|
||||||
extern bool StateCopy_IsBusy();
|
extern bool StateCopy_IsBusy();
|
||||||
|
|
||||||
|
extern const SafeArray<u8>* StateCopy_GetBuffer();
|
||||||
|
|
|
@ -448,7 +448,8 @@ protected:
|
||||||
void CleanupMess();
|
void CleanupMess();
|
||||||
void OpenWizardConsole();
|
void OpenWizardConsole();
|
||||||
|
|
||||||
void HandleEvent(wxEvtHandler *handler, wxEventFunction func, wxEvent& event) const;
|
void HandleEvent(wxEvtHandler* handler, wxEventFunction func, wxEvent& event) const;
|
||||||
|
void HandleEvent(wxEvtHandler* handler, wxEventFunction func, wxEvent& event);
|
||||||
|
|
||||||
void OnSysExecute( wxCommandEvent& evt );
|
void OnSysExecute( wxCommandEvent& evt );
|
||||||
void OnReloadPlugins( wxCommandEvent& evt );
|
void OnReloadPlugins( wxCommandEvent& evt );
|
||||||
|
|
|
@ -277,11 +277,8 @@ namespace FilenameDefs
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if( IsDevBuild && (port >= 2) )
|
IndexBoundsCheckDev( L"FilenameDefs::Memcard", port, 2 );
|
||||||
throw Exception::IndexBoundsFault( L"FilenameDefs::Memcard", port, 2 );
|
IndexBoundsCheckDev( L"FilenameDefs::Memcard", slot, 4 );
|
||||||
|
|
||||||
if( IsDevBuild && (slot >= 4) )
|
|
||||||
throw Exception::IndexBoundsFault( L"FilenameDefs::Memcard", slot, 4 );
|
|
||||||
|
|
||||||
return retval[port][slot];
|
return retval[port][slot];
|
||||||
}
|
}
|
||||||
|
@ -508,9 +505,7 @@ void AppConfig::FolderOptions::LoadSave( IniInterface& ini )
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
const wxFileName& AppConfig::FilenameOptions::operator[]( PluginsEnum_t pluginidx ) const
|
const wxFileName& AppConfig::FilenameOptions::operator[]( PluginsEnum_t pluginidx ) const
|
||||||
{
|
{
|
||||||
if( (uint)pluginidx >= PluginId_Count )
|
IndexBoundsCheckDev( L"Filename[Plugin]", pluginidx, PluginId_Count );
|
||||||
throw Exception::IndexBoundsFault( L"Filename[Plugin]", pluginidx, PluginId_Count );
|
|
||||||
|
|
||||||
return Plugins[pluginidx];
|
return Plugins[pluginidx];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -234,7 +234,12 @@ wxString BIOS_GetMsg_Required()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Pcsx2App::HandleEvent(wxEvtHandler *handler, wxEventFunction func, wxEvent& event) const
|
void Pcsx2App::HandleEvent(wxEvtHandler* handler, wxEventFunction func, wxEvent& event) const
|
||||||
|
{
|
||||||
|
const_cast<Pcsx2App*>(this)->HandleEvent( handler, func, event );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Pcsx2App::HandleEvent(wxEvtHandler* handler, wxEventFunction func, wxEvent& event)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
(handler->*func)(event);
|
(handler->*func)(event);
|
||||||
|
@ -250,14 +255,37 @@ void Pcsx2App::HandleEvent(wxEvtHandler *handler, wxEventFunction func, wxEvent&
|
||||||
if( !result )
|
if( !result )
|
||||||
Console.Warning( "User denied option to re-configure BIOS." );
|
Console.Warning( "User denied option to re-configure BIOS." );
|
||||||
|
|
||||||
if( (wxTheApp != NULL) && (Dialogs::BiosSelectorDialog().ShowModal() != wxID_CANCEL) )
|
if( Dialogs::BiosSelectorDialog().ShowModal() != wxID_CANCEL )
|
||||||
{
|
{
|
||||||
sApp.SysExecute();
|
SysExecute();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Console.Warning( "User canceled BIOS configuration." );
|
Console.Warning( "User canceled BIOS configuration." );
|
||||||
}
|
}
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
catch( Exception::PluginInitError& ex )
|
||||||
|
{
|
||||||
|
if( m_CorePlugins ) m_CorePlugins->Shutdown();
|
||||||
|
|
||||||
|
Console.Error( ex.FormatDiagnosticMessage() );
|
||||||
|
if( !HandlePluginError( ex ) )
|
||||||
|
{
|
||||||
|
Console.Error( L"User-canceled plugin configuration after plugin initialization failure. Plugins unloaded." );
|
||||||
|
Msgbox::Alert( _("Warning! System plugins have not been loaded. PCSX2 may be inoperable.") );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch( Exception::PluginError& ex )
|
||||||
|
{
|
||||||
|
if( m_CorePlugins ) m_CorePlugins->Close();
|
||||||
|
|
||||||
|
Console.Error( ex.FormatDiagnosticMessage() );
|
||||||
|
if( !HandlePluginError( ex ) )
|
||||||
|
{
|
||||||
|
Console.Error( L"User-canceled plugin configuration; Plugins not loaded!" );
|
||||||
|
Msgbox::Alert( _("Warning! System plugins have not been loaded. PCSX2 may be inoperable.") );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
catch( Exception::CancelEvent& ex )
|
catch( Exception::CancelEvent& ex )
|
||||||
{
|
{
|
||||||
Console.Warning( ex.FormatDiagnosticMessage() );
|
Console.Warning( ex.FormatDiagnosticMessage() );
|
||||||
|
@ -270,16 +298,6 @@ void Pcsx2App::HandleEvent(wxEvtHandler *handler, wxEventFunction func, wxEvent&
|
||||||
CoreThread.Resume();
|
CoreThread.Resume();
|
||||||
}
|
}
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
catch( Exception::PluginError& ex )
|
|
||||||
{
|
|
||||||
Console.Error( ex.FormatDiagnosticMessage() );
|
|
||||||
if( !HandlePluginError( ex ) )
|
|
||||||
{
|
|
||||||
Console.Error( L"User-canceled plugin configuration after load failure. Plugins not loaded!" );
|
|
||||||
Msgbox::Alert( _("Warning! Plugins have not been loaded. PCSX2 will be inoperable.") );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
catch( Exception::RuntimeError& ex )
|
catch( Exception::RuntimeError& ex )
|
||||||
{
|
{
|
||||||
// Runtime errors which have been unhandled should still be safe to recover from,
|
// Runtime errors which have been unhandled should still be safe to recover from,
|
||||||
|
@ -347,7 +365,7 @@ int Pcsx2App::OnExit()
|
||||||
if( g_Conf )
|
if( g_Conf )
|
||||||
AppSaveSettings();
|
AppSaveSettings();
|
||||||
|
|
||||||
sMainFrame.PopEventHandler( m_RecentIsoList );
|
sMainFrame.RemoveEventHandler( m_RecentIsoList );
|
||||||
|
|
||||||
m_RecentIsoList = NULL;
|
m_RecentIsoList = NULL;
|
||||||
m_RecentIsoMenu = NULL;
|
m_RecentIsoMenu = NULL;
|
||||||
|
@ -582,7 +600,7 @@ void Pcsx2App::SysReset()
|
||||||
// state (such as saving it), you *must* suspend the Corethread first!
|
// state (such as saving it), you *must* suspend the Corethread first!
|
||||||
__forceinline bool SysHasValidState()
|
__forceinline bool SysHasValidState()
|
||||||
{
|
{
|
||||||
return CoreThread.HasValidState() || StateCopy_HasFullState();
|
return CoreThread.HasValidState() || StateCopy_IsValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Writes text to console and updates the window status bar and/or HUD or whateverness.
|
// Writes text to console and updates the window status bar and/or HUD or whateverness.
|
||||||
|
|
|
@ -156,13 +156,16 @@ void IniLoader::Entry( const wxString& var, wxRect& value, const wxRect& defvalu
|
||||||
TryParse( value, m_Config.Read( var, ToString( defvalue ) ), defvalue );
|
TryParse( value, m_Config.Read( var, ToString( defvalue ) ), defvalue );
|
||||||
}
|
}
|
||||||
|
|
||||||
void IniLoader::_EnumEntry( const wxString& var, int& value, const wxChar* const* enumArray, const int defvalue )
|
void IniLoader::_EnumEntry( const wxString& var, int& value, const wxChar* const* enumArray, int defvalue )
|
||||||
{
|
{
|
||||||
// Confirm default value sanity...
|
// Confirm default value sanity...
|
||||||
|
|
||||||
const int cnt = _calcEnumLength( enumArray );
|
const int cnt = _calcEnumLength( enumArray );
|
||||||
if( defvalue >= cnt )
|
if( !IndexBoundsCheck( L"IniLoader EnumDefaultValue", defvalue, cnt ) )
|
||||||
throw Exception::IndexBoundsFault( L"IniLoader Enumeration DefaultValue", defvalue, cnt );
|
{
|
||||||
|
Console.Error( "(LoadSettings) Default enumeration index is out of bounds. Truncating." );
|
||||||
|
defvalue = cnt-1;
|
||||||
|
}
|
||||||
|
|
||||||
// Sanity confirmed, proceed with craziness!
|
// Sanity confirmed, proceed with craziness!
|
||||||
|
|
||||||
|
@ -174,7 +177,7 @@ void IniLoader::_EnumEntry( const wxString& var, int& value, const wxChar* const
|
||||||
|
|
||||||
if( enumArray[i] == NULL )
|
if( enumArray[i] == NULL )
|
||||||
{
|
{
|
||||||
Console.Warning( L"Loadini Warning: Unrecognized value '%s' on key '%s'\n\tUsing the default setting of '%s'.",
|
Console.Warning( L"(LoadSettings) Warning: Unrecognized value '%s' on key '%s'\n\tUsing the default setting of '%s'.",
|
||||||
retval.c_str(), var.c_str(), enumArray[defvalue]
|
retval.c_str(), var.c_str(), enumArray[defvalue]
|
||||||
);
|
);
|
||||||
value = defvalue;
|
value = defvalue;
|
||||||
|
@ -253,13 +256,22 @@ void IniSaver::Entry( const wxString& var, wxRect& value, const wxRect& defvalue
|
||||||
m_Config.Write( var, ToString( value ) );
|
m_Config.Write( var, ToString( value ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void IniSaver::_EnumEntry( const wxString& var, int& value, const wxChar* const* enumArray, const int defvalue )
|
void IniSaver::_EnumEntry( const wxString& var, int& value, const wxChar* const* enumArray, int defvalue )
|
||||||
{
|
{
|
||||||
const int cnt = _calcEnumLength( enumArray );
|
const int cnt = _calcEnumLength( enumArray );
|
||||||
|
|
||||||
|
// Confirm default value sanity...
|
||||||
|
|
||||||
|
if( !IndexBoundsCheck( L"IniSaver EnumDefaultValue", defvalue, cnt ) )
|
||||||
|
{
|
||||||
|
Console.Error( "(SaveSettings) Default enumeration index is out of bounds. Truncating." );
|
||||||
|
defvalue = cnt-1;
|
||||||
|
}
|
||||||
|
|
||||||
if( value >= cnt )
|
if( value >= cnt )
|
||||||
{
|
{
|
||||||
Console.Warning(
|
Console.Warning(
|
||||||
L"Settings Warning: An illegal enumerated index was detected when saving '%s'\n"
|
L"(SaveSettings) An illegal enumerated index was detected when saving '%s'\n"
|
||||||
L"\tIllegal Value: %d\n"
|
L"\tIllegal Value: %d\n"
|
||||||
L"\tUsing Default: %d (%s)\n",
|
L"\tUsing Default: %d (%s)\n",
|
||||||
var.c_str(), value, defvalue, enumArray[defvalue]
|
var.c_str(), value, defvalue, enumArray[defvalue]
|
||||||
|
|
|
@ -71,7 +71,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void _EnumEntry( const wxString& var, int& value, const wxChar* const* enumArray, const int defvalue )=0;
|
virtual void _EnumEntry( const wxString& var, int& value, const wxChar* const* enumArray, int defvalue )=0;
|
||||||
};
|
};
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -118,7 +118,7 @@ public:
|
||||||
void Entry( const wxString& var, wxRect& value, const wxRect& defvalue=wxDefaultRect );
|
void Entry( const wxString& var, wxRect& value, const wxRect& defvalue=wxDefaultRect );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void _EnumEntry( const wxString& var, int& value, const wxChar* const* enumArray, const int defvalue );
|
void _EnumEntry( const wxString& var, int& value, const wxChar* const* enumArray, int defvalue );
|
||||||
};
|
};
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -153,7 +153,7 @@ public:
|
||||||
void Entry( const wxString& var, wxRect& value, const wxRect& defvalue=wxDefaultRect );
|
void Entry( const wxString& var, wxRect& value, const wxRect& defvalue=wxDefaultRect );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void _EnumEntry( const wxString& var, int& value, const wxChar* const* enumArray, const int defvalue );
|
void _EnumEntry( const wxString& var, int& value, const wxChar* const* enumArray, int defvalue );
|
||||||
};
|
};
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue