Bind the cdvd's newDiskCB properly when changing CDVD sources; and more jASSUME->pxAssert change-overs.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1953 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
Jake.Stine 2009-10-04 15:34:40 +00:00
parent db01c15977
commit e1c89dacdb
13 changed files with 60 additions and 78 deletions

View File

@ -107,13 +107,13 @@ public:
// Generates a debug assertion if the object is NULL!
T& operator*() const
{
wxASSERT(m_ptr != NULL);
pxAssert(m_ptr != NULL);
return *m_ptr;
}
T* operator->() const
{
wxASSERT(m_ptr != NULL);
pxAssert(m_ptr != NULL);
return m_ptr;
}
};
@ -180,27 +180,27 @@ public:
T& operator*() const
{
wxASSERT(m_ptr != NULL);
pxAssert(m_ptr != NULL);
return *m_ptr;
}
T* operator->() const
{
wxASSERT(m_ptr != NULL);
pxAssert(m_ptr != NULL);
return m_ptr;
}
T* get() const
{
wxASSERT(m_ptr != NULL);
pxAssert(m_ptr != NULL);
return m_ptr;
}
void swap(pxObjPtr& other)
{
// Neither pointer in either container should ever be NULL...
wxASSERT(m_ptr != NULL);
wxASSERT(other.m_ptr != NULL);
pxAssert(m_ptr != NULL);
pxAssert(other.m_ptr != NULL);
T * const tmp = other.m_ptr;
other.m_ptr = m_ptr;

View File

@ -150,5 +150,5 @@ void _DoI_helpermess( const xImpl& helpme, const xDirectOrIndirect<T>& to, const
// One of the fields needs to be direct, or else we cannot complete the operation.
// (intel doesn't support indirects in both fields)
jASSUME( false );
pxFailDev( "Invalid asm instruction: Both operands are indirect memory addresses." );
}

View File

@ -137,7 +137,7 @@ public:
MovImplAll() {} // Satisfy GCC's whims.
};
#define ccSane() jASSUME( ccType >= 0 && ccType <= 0x0f )
#define ccSane() pxAssertDev( ccType >= 0 && ccType <= 0x0f, "Invalid comparison type specifier." )
//////////////////////////////////////////////////////////////////////////////////////////
// CMOV !! [in all of it's disappointing lack-of glory] .. and ..

View File

@ -93,51 +93,51 @@ namespace x86Emitter
//
__forceinline xAddressInfo xAddressReg::operator+( const xAddressReg& right ) const
{
jASSUME( Id != -1 );
pxAssertMsg( Id != -1, "Uninitialized x86 register." );
return xAddressInfo( *this, right );
}
__forceinline xAddressInfo xAddressReg::operator+( const xAddressInfo& right ) const
{
jASSUME( Id != -1 );
pxAssertMsg( Id != -1, "Uninitialized x86 register." );
return right + *this;
}
__forceinline xAddressInfo xAddressReg::operator+( s32 right ) const
{
jASSUME( Id != -1 );
pxAssertMsg( Id != -1, "Uninitialized x86 register." );
return xAddressInfo( *this, right );
}
__forceinline xAddressInfo xAddressReg::operator+( const void* right ) const
{
jASSUME( Id != -1 );
pxAssertMsg( Id != -1, "Uninitialized x86 register." );
return xAddressInfo( *this, (s32)right );
}
// ------------------------------------------------------------------------
__forceinline xAddressInfo xAddressReg::operator-( s32 right ) const
{
jASSUME( Id != -1 );
pxAssertMsg( Id != -1, "Uninitialized x86 register." );
return xAddressInfo( *this, -right );
}
__forceinline xAddressInfo xAddressReg::operator-( const void* right ) const
{
jASSUME( Id != -1 );
pxAssertMsg( Id != -1, "Uninitialized x86 register." );
return xAddressInfo( *this, -(s32)right );
}
// ------------------------------------------------------------------------
__forceinline xAddressInfo xAddressReg::operator*( u32 right ) const
{
jASSUME( Id != -1 );
pxAssertMsg( Id != -1, "Uninitialized x86 register." );
return xAddressInfo( Empty, *this, right );
}
__forceinline xAddressInfo xAddressReg::operator<<( u32 shift ) const
{
jASSUME( Id != -1 );
pxAssertMsg( Id != -1, "Uninitialized x86 register." );
return xAddressInfo( Empty, *this, 1<<shift );
}
@ -213,7 +213,7 @@ namespace x86Emitter
else if( Index.IsEmpty() )
Index = src;
else
wxASSERT_MSG( false, L"x86Emitter: address modifiers cannot have more than two index registers." ); // oops, only 2 regs allowed per ModRm!
pxFailDev( L"x86Emitter: address modifiers cannot have more than two index registers." ); // oops, only 2 regs allowed per ModRm!
return *this;
}
@ -237,7 +237,7 @@ namespace x86Emitter
else if( Index == src.Index )
Factor++;
else
wxASSERT_MSG( false, L"x86Emitter: address modifiers cannot have more than two index registers." ); // oops, only 2 regs allowed per ModRm!
pxFailDev( L"x86Emitter: address modifiers cannot have more than two index registers." ); // oops, only 2 regs allowed per ModRm!
return *this;
}
@ -253,8 +253,8 @@ namespace x86Emitter
((cctype==Jcc_Unconditional) ? 5 : 6 )) // j32's are either 5 or 6 bytes
)
{
jASSUME( cctype != Jcc_Unknown );
jASSUME( OperandSize == 1 || OperandSize == 4 );
pxAssert( cctype != Jcc_Unknown );
pxAssert( OperandSize == 1 || OperandSize == 4 );
if( OperandSize == 1 )
xWrite8( (cctype == Jcc_Unconditional) ? 0xeb : (0x70 | cctype) );
@ -276,14 +276,14 @@ namespace x86Emitter
template< typename OperandType >
void xForwardJump<OperandType>::SetTarget() const
{
jASSUME( BasePtr != NULL );
pxAssert( BasePtr != NULL );
sptr displacement = (sptr)xGetPtr() - (sptr)BasePtr;
if( OperandSize == 1 )
{
if( !is_s8( displacement ) )
{
wxASSERT( false );
pxAssert( false );
// Don't ask. --arcum42
#if !defined(__LINUX__) || !defined(DEBUG)
@ -304,7 +304,7 @@ namespace x86Emitter
//
static __forceinline JccComparisonType xInvertCond( JccComparisonType src )
{
jASSUME( src != Jcc_Unknown );
pxAssert( src != Jcc_Unknown );
if( Jcc_Unconditional == src ) return Jcc_Unconditional;
// x86 conditionals are clever! To invert conditional types, just invert the lower bit:

View File

@ -127,7 +127,7 @@ __forceinline void xWrite( T val )
int Id;
xRegisterBase(): Id( -1 ) {}
explicit xRegisterBase( int regId ) : Id( regId ) { jASSUME( Id >= -2 && Id < 8 ); } // allow -2 for user-custom identifiers.
explicit xRegisterBase( int regId ) : Id( regId ) { pxAssert( Id >= -2 && Id < 8 ); } // allow -2 for user-custom identifiers.
bool IsEmpty() const { return Id < 0; }
@ -644,7 +644,7 @@ __forceinline void xWrite( T val )
public:
int GetMaxInstructionSize() const
{
jASSUME( m_cc != Jcc_Unknown );
pxAssert( m_cc != Jcc_Unknown );
return ( m_cc == Jcc_Unconditional ) ? 5 : 6;
}
@ -656,7 +656,7 @@ __forceinline void xWrite( T val )
//
xSmartJump( JccComparisonType ccType )
{
jASSUME( ccType != Jcc_Unknown );
pxAssert( ccType != Jcc_Unknown );
m_baseptr = xGetPtr();
m_cc = ccType;
xAdvancePtr( GetMaxInstructionSize() );

View File

@ -18,25 +18,13 @@
#include <wx/file.h>
#ifdef __LINUX__
#ifndef _S_IFDIR
#define _S_IFDIR S_IFDIR
#endif
#ifndef _S_IFREG
#define _S_IFREG S_IFREG
#endif
#else
#include <direct.h>
#endif
// ---------------------------------------------------------------------------------
// wxDirName Implementations
// ---------------------------------------------------------------------------------
wxFileName wxDirName::Combine( const wxFileName& right ) const
{
wxASSERT_MSG( IsDir(), L"Warning: Malformed directory name detected during wxDirName concatenation." );
pxAssertMsg( IsDir(), L"Warning: Malformed directory name detected during wxDirName concatenation." );
if( right.IsAbsolute() )
return right;
@ -51,7 +39,7 @@ wxFileName wxDirName::Combine( const wxFileName& right ) const
wxDirName wxDirName::Combine( const wxDirName& right ) const
{
wxASSERT_MSG( IsDir() && right.IsDir(), L"Warning: Malformed directory name detected during wDirName concatenation." );
pxAssertMsg( IsDir() && right.IsDir(), L"Warning: Malformed directory name detected during wDirName concatenation." );
wxDirName result( right );
result.Normalize( wxPATH_NORM_ENV_VARS | wxPATH_NORM_DOTS | wxPATH_NORM_ABSOLUTE, GetPath() );
@ -60,7 +48,7 @@ wxDirName wxDirName::Combine( const wxDirName& right ) const
wxDirName& wxDirName::Normalize( int flags, const wxString& cwd )
{
wxASSERT_MSG( IsDir(), L"Warning: Malformed directory name detected during wDirName normalization." );
pxAssertMsg( IsDir(), L"Warning: Malformed directory name detected during wDirName normalization." );
if( !wxFileName::Normalize( flags, cwd ) )
throw Exception::RuntimeError( "wxDirName::Normalize operation failed." );
return *this;
@ -68,7 +56,7 @@ wxDirName& wxDirName::Normalize( int flags, const wxString& cwd )
wxDirName& wxDirName::MakeRelativeTo( const wxString& pathBase )
{
wxASSERT_MSG( IsDir(), L"Warning: Malformed directory name detected during wDirName normalization." );
pxAssertMsg( IsDir(), L"Warning: Malformed directory name detected during wDirName normalization." );
if( !wxFileName::MakeRelativeTo( pathBase ) )
throw Exception::RuntimeError( "wxDirName::MakeRelativeTo operation failed." );
return *this;
@ -76,7 +64,7 @@ wxDirName& wxDirName::MakeRelativeTo( const wxString& pathBase )
wxDirName& wxDirName::MakeAbsolute( const wxString& cwd )
{
wxASSERT_MSG( IsDir(), L"Warning: Malformed directory name detected during wDirName normalization." );
pxAssertMsg( IsDir(), L"Warning: Malformed directory name detected during wDirName normalization." );
if( !wxFileName::MakeAbsolute( cwd ) )
throw Exception::RuntimeError( "wxDirName::MakeAbsolute operation failed." );
return *this;

View File

@ -108,7 +108,7 @@ namespace Threading
// This function should not be called from the owner thread.
bool PersistentThread::Detach()
{
wxASSERT( !IsSelf() ); // not allowed from our own thread.
pxAssertMsg( !IsSelf(), "Thread affinity error." ); // not allowed from our own thread.
if( _InterlockedExchange( &m_detached, true ) ) return false;
pthread_detach( m_thread );
@ -128,7 +128,7 @@ namespace Threading
//
void PersistentThread::Cancel( bool isBlocking )
{
wxASSERT( !IsSelf() );
pxAssertMsg( !IsSelf(), "Thread affinity error." );
if( !m_running ) return;
@ -193,7 +193,7 @@ namespace Threading
// OnThreadCleanup() to extend clenup functionality.
void PersistentThread::_ThreadCleanup()
{
wxASSERT( IsSelf() ); // only allowed from our own thread, thanks.
pxAssertMsg( IsSelf(), "Thread affinity error." ); // only allowed from our own thread, thanks.
// Typically thread cleanup needs to lock against thread startup, since both
// will perform some measure of variable inits or resets, depending on how the
@ -272,9 +272,11 @@ namespace Threading
void PersistentThread::DoSetThreadName( __unused const char* name )
{
wxASSERT( IsSelf() ); // only allowed from our own thread, thanks.
pxAssertMsg( IsSelf(), "Thread affinity error." ); // only allowed from our own thread, thanks.
#ifdef _WINDOWS_
// This feature needs Windows headers and MSVC's SEH support:
#if defined(_WINDOWS_) && defined (_MSC_VER)
// This code sample was borrowed form some obscure MSDN article.
// In a rare bout of sanity, it's an actual Micrsoft-published hack
@ -325,7 +327,7 @@ namespace Threading
// initialized internal variables / preparations for task execution.
void BaseTaskThread::PostTask()
{
wxASSERT( !m_detached );
pxAssert( !m_detached );
ScopedLock locker( m_lock_TaskComplete );
m_TaskPending = true;

View File

@ -112,12 +112,9 @@ __emitinline void Internal::xJccKnownTarget( JccComparisonType comparison, const
const int slideVal = slideForward ? ((comparison == Jcc_Unconditional) ? 3 : 4) : 0;
displacement8 -= slideVal;
// if the following assert fails it means we accidentally used slideForard on a backward
// jump (which is an invalid operation since there's nothing to slide forward).
if( slideForward )
{
// jASSUME has an else statement in it that would be abiguous without the brackets.
jASSUME( displacement8 >= 0 );
pxAssertDev( displacement8 >= 0, "Used slideForward on a backward jump; nothing to slide!" );
}
if( is_s8( displacement8 ) )

View File

@ -32,12 +32,12 @@
//
emitterT void ModRM( uint mod, uint reg, uint rm )
{
// Note: Following ASSUMEs are for legacy support only.
// Note: Following assertions are for legacy support only.
// The new emitter performs these sanity checks during operand construction, so these
// assertions can probably be removed once all legacy emitter code has been removed.
jASSUME( mod < 4 );
jASSUME( reg < 8 );
jASSUME( rm < 8 );
pxAssert( mod < 4 );
pxAssert( reg < 8 );
pxAssert( rm < 8 );
xWrite8( (mod << 6) | (reg << 3) | rm );
}
@ -46,9 +46,9 @@ emitterT void SibSB( uint ss, uint index, uint base )
// Note: Following ASSUMEs are for legacy support only.
// The new emitter performs these sanity checks during operand construction, so these
// assertions can probably be removed once all legacy emitter code has been removed.
jASSUME( ss < 4 );
jASSUME( index < 8 );
jASSUME( base < 8 );
pxAssert( ss < 4 );
pxAssert( index < 8 );
pxAssert( base < 8 );
xWrite8( (ss << 6) | (index << 3) | base );
}

View File

@ -33,7 +33,7 @@ __emitinline void Internal::SimdPrefix( u8 prefix, u16 opcode )
// If the lower byte is not a valid prefix and the upper byte is non-zero it
// means we made a mistake!
if( !is16BitOpcode ) jASSUME( (opcode >> 8) == 0 );
if( !is16BitOpcode ) pxAssert( (opcode >> 8) == 0 );
if( prefix != 0 )
{

View File

@ -272,7 +272,7 @@ namespace Internal
//
__noinline void EmitSibMagic( uint regfield, const ModSibBase& info )
{
jASSUME( regfield < 8 );
pxAssert( regfield < 8, "Invalid x86 register identifier." );
int displacement_size = (info.Displacement == 0) ? 0 :
( ( info.IsByteSizeDisp() ) ? 1 : 2 );
@ -497,8 +497,8 @@ void ModSibBase::Reduce()
// note: intentionally leave index assigned to esp also (generates correct
// encoding later, since ESP cannot be encoded 'alone')
jASSUME( Scale == 0 ); // esp can't have an index modifier!
jASSUME( Base.IsEmpty() ); // base must be empty or else!
pxAssert( Scale == 0 ); // esp can't have an index modifier!
pxAssert( Base.IsEmpty() ); // base must be empty or else!
Base = Index;
return;
@ -523,7 +523,7 @@ void ModSibBase::Reduce()
case 2: Scale = 1; break;
case 3: // becomes [reg*2+reg]
jASSUME( Base.IsEmpty() );
pxAssertDev( Base.IsEmpty(), "Cannot scale an Index register by 3 when Base is not empty!" );
Base = Index;
Scale = 1;
break;
@ -531,22 +531,22 @@ void ModSibBase::Reduce()
case 4: Scale = 2; break;
case 5: // becomes [reg*4+reg]
jASSUME( Base.IsEmpty() );
pxAssertDev( Base.IsEmpty(), "Cannot scale an Index register by 5 when Base is not empty!" );
Base = Index;
Scale = 2;
break;
case 6: // invalid!
assert( false );
pxFail( "x86 asm cannot scale a register by 6." );
break;
case 7: // so invalid!
assert( false );
pxFail( "x86 asm cannot scale a register by 7." );
break;
case 8: Scale = 3; break;
case 9: // becomes [reg*8+reg]
jASSUME( Base.IsEmpty() );
pxAssertDev( Base.IsEmpty(), "Cannot scale an Index register by 9 when Base is not empty!" );
Base = Index;
Scale = 3;
break;

View File

@ -275,7 +275,7 @@ void CDVDsys_SetFile( CDVD_SourceType srctype, const wxString& newfile )
void CDVDsys_ChangeSource( CDVD_SourceType type )
{
GetPluginManager().Close( PluginId_CDVD );
switch( m_CurrentSourceType = type )
{
case CDVDsrc_Iso:
@ -292,6 +292,8 @@ void CDVDsys_ChangeSource( CDVD_SourceType type )
jNO_DEFAULT;
}
CDVD->newDiskCB( cdvdNewDiskCB );
}
bool DoCDVDopen()

View File

@ -826,13 +826,6 @@ extern void spu2DMA4Irq();
extern void spu2DMA7Irq();
extern void spu2Irq();
static bool OpenPlugin_CDVD()
{
if( CDVDapi_Plugin.open(NULL) ) return false;
CDVDapi_Plugin.newDiskCB( cdvdNewDiskCB );
return true;
}
static bool OpenPlugin_GS()
{
mtgsThread.Resume();