Beispiel #1
0
xAddressVoid::xAddressVoid( const xAddressReg& base, const xAddressReg& index, int factor, s32 displacement )
{
	Base         = base;
	Index        = index;
	Factor       = factor;
	Displacement = displacement;

	pxAssertMsg( base.Id != xRegId_Invalid, "Uninitialized x86 register." );
	pxAssertMsg( index.Id != xRegId_Invalid, "Uninitialized x86 register." );
}
uint MultipartFileReader::GetFirstPart(uint lsn)
{
	pxAssertMsg(lsn < GetBlockCount(),	"Invalid lsn passed into MultipartFileReader::GetFirstPart.");
	pxAssertMsg(m_numparts, "Invalid object state; multi-part iso file needs at least one part!");

	for (uint i = 0; i < m_numparts; ++i)
	{
		if (lsn < m_parts[i].end)
			return i;
	}

	// should never get here
	return 0xBAAAAAAD;
}
Beispiel #3
0
wxDirName &wxDirName::MakeAbsolute(const wxString &cwd)
{
    pxAssertMsg(IsDir(), L"Warning: Malformed directory name detected during wDirName normalization.");
    if (!wxFileName::MakeAbsolute(cwd))
        throw Exception::ParseError().SetDiagMsg(L"wxDirName::MakeAbsolute operation failed.");
    return *this;
}
Beispiel #4
0
s32 __fastcall Savestate::FreezeIt( DataBlock& spud )
{
	spud.spu2id		= SAVE_ID;
	spud.version	= SAVE_VERSION;

	pxAssertMsg( spu2regs && _spu2mem, "Looks like PCSX2 is trying to savestate while pluigns are shut down.  That's a no-no! It shouldn't crash, but the savestate will probably be corrupted." );

	if( spu2regs != NULL )	memcpy(spud.unkregs,	spu2regs,	sizeof(spud.unkregs));
	if( _spu2mem != NULL )	memcpy(spud.mem,		_spu2mem,	sizeof(spud.mem));

	memcpy(spud.Cores,		Cores,		sizeof(Cores));
	memcpy(&spud.Spdif,		&Spdif,		sizeof(Spdif));

	spud.OutPos		= OutPos;
	spud.InputPos	= InputPos;
	spud.Cycles		= Cycles;
	spud.lClocks    = lClocks;
	spud.PlayMode	= PlayMode;

	// note: Don't save the cache.  PCSX2 doesn't offer a safe method of predicting
	// the required size of the savestate prior to saving, plus this is just too
	// "implementation specific" for the intended spec of a savestate.  Let's just
	// force the user to rebuild their cache instead.

	return 0;
}
Beispiel #5
0
wxDirName wxDirName::Combine(const wxDirName &right) const
{
    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());
    return result;
}
Beispiel #6
0
xAddressVoid::xAddressVoid( const xAddressReg& index, int displacement )
{
	Base         = xEmptyReg;
	Index        = index;
	Factor       = 0;
	Displacement = displacement;

	pxAssertMsg( index.Id != xRegId_Invalid, "Uninitialized x86 register." );
}
void isoFile::_ReadBlock(u8* dst, uint lsn)
{
	pxAssertMsg(lsn <= m_blocks,	"Invalid lsn passed into isoFile::_ReadBlock.");
	pxAssertMsg(m_numparts,			"Invalid isoFile object state; an iso file needs at least one part!");

	uint i;
	for (i = 0; i < m_numparts-1; ++i)
	{
		// lsn indexes should always go in order; use an assertion just to be sure:
		pxAssert(lsn >= m_parts[i].slsn);
		if (lsn <= m_parts[i].elsn) break;
	}

	wxFileOffset ofs = (wxFileOffset)(lsn - m_parts[i].slsn) * m_blocksize + m_offset;

//	Console.WriteLn("_isoReadBlock %u, blocksize=%u, blockofs=%u\n", lsn, iso->blocksize, iso->blockofs);

	memset(dst, 0, m_blockofs);
	m_parts[i].Seek(ofs);
	m_parts[i].Read(dst + m_blockofs, m_blocksize);
}
Beispiel #8
0
wxFileName wxDirName::Combine(const wxFileName &right) const
{
    pxAssertMsg(IsDir(), L"Warning: Malformed directory name detected during wxDirName concatenation.");
    if (right.IsAbsolute())
        return right;

    // Append any directory parts from right, and then set the filename.
    // Except we can't do that because our m_members are private (argh!) and there is no API
    // for getting each component of the path.  So instead let's use Normalize:

    wxFileName result(right);
    result.Normalize(wxPATH_NORM_ENV_VARS | wxPATH_NORM_DOTS | wxPATH_NORM_ABSOLUTE, GetPath());
    return result;
}
Beispiel #9
0
static __ri void PageSizeAssertionTest( size_t size )
{
	pxAssertMsg( (__pagesize == getpagesize()), pxsFmt(
		"Internal system error: Operating system pagesize does not match compiled pagesize.\n\t"
		L"\tOS Page Size: 0x%x (%d), Compiled Page Size: 0x%x (%u)",
		getpagesize(), getpagesize(), __pagesize, __pagesize )
	);

	pxAssertDev( (size & (__pagesize-1)) == 0, pxsFmt(
		L"Memory block size must be a multiple of the target platform's page size.\n"
		L"\tPage Size: 0x%x (%u), Block Size: 0x%x (%u)",
		__pagesize, __pagesize, size, size )
	);
}
Beispiel #10
0
void xImpl_IncDec::operator()(const xRegisterInt &to) const
{
    if (to.Is8BitOp()) {
        u8 regfield = isDec ? 1 : 0;
        xOpWrite(to.GetPrefix16(), 0xfe, regfield, to);
    } else {
#ifdef __x86_64__
        pxAssertMsg(0, "Single Byte INC/DEC aren't valid in 64 bits."
                       "You need to use the ModR/M form (FF/0 FF/1 opcodes)");
#endif
        to.prefix16();
        xWrite8((isDec ? 0x48 : 0x40) | to.Id);
    }
}
Beispiel #11
0
// Tests the specified filename to see if it is a supported ISO type.  This function typically
// executes faster than isoFile::Open since it does not do the following:
//  * check for multi-part ISOs.  I tests for header info in the main/root ISO only.
//  * load blockdump indexes.
//
// Note that this is a member method, and that it will clobber any existing ISO state.
// (assertions are generated in debug mode if the object state is not already closed).
bool isoFile::Test( const wxString& srcfile )
{
	pxAssertMsg( !m_parts[0].handle, "Warning!  isoFile::Test is about to clobber whatever existing iso bound to this isoFile object!" );

	Close();
	m_filename = srcfile;

	m_parts[0].handle = new wxFileInputStream( m_filename );
	pxStream_OpenCheck( *m_parts[0].handle, m_filename, L"reading" );

	m_numparts		= 1;
	m_parts[0].slsn = 0;

	// elsn is unknown at this time, but is also unused when m_numparts == 1.
	// (and if numparts is incremented, elsn will get assigned accordingly)

	return Detect( false );
}
Beispiel #12
0
void MainEmuFrame::DispatchEvent( const PluginEventType& plugin_evt )
{
	if( !pxAssertMsg( GetMenuBar()!=NULL, "Mainframe menu bar is NULL!" ) ) return;

	//ApplyCoreStatus();

	if( plugin_evt == CorePlugins_Unloaded )
	{
		for( int i=0; i<PluginId_Count; ++i )
			m_PluginMenuPacks[i].OnUnloaded();
	}
	else if( plugin_evt == CorePlugins_Loaded )
	{
		for( int i=0; i<PluginId_Count; ++i )
			m_PluginMenuPacks[i].OnLoaded();

		// bleh this makes the menu too cluttered. --air
		//m_menuCDVD.SetLabel( MenuId_Src_Plugin, wxsFormat( L"%s (%s)", _("Plugin"),
		//	GetCorePlugins().GetName( PluginId_CDVD ).c_str() ) );
	}
}
Beispiel #13
0
xAddressVoid xAddressReg::operator+( s32 right ) const
{
	pxAssertMsg( Id != -1, "Uninitialized x86 register." );
	return xAddressVoid( *this, right );
}
Beispiel #14
0
void MainEmuFrame::DispatchEvent( const CoreThreadStatus& status )
{
	if( !pxAssertMsg( GetMenuBar()!=NULL, "Mainframe menu bar is NULL!" ) ) return;
	ApplyCoreStatus();
}
Beispiel #15
0
// This is a direct blocking action -- very fast, very efficient, and generally very dangerous
// if used from the main GUI thread, since it typically results in an unresponsive program.
// Call this method directly only if you know the code in question will be run from threads
// other than the main thread.
void Threading::Mutex::AcquireWithoutYield()
{
	pxAssertMsg( !wxThread::IsMain(), "Unyielding mutex acquire issued from the main/gui thread.  Please use Acquire() instead." );
	pthread_mutex_lock( &m_mutex );
}
Beispiel #16
0
void Threading::Semaphore::WaitWithoutYield()
{
    pxAssertMsg(!wxThread::IsMain(), "Unyielding semaphore wait issued from the main/gui thread.  Please use Wait() instead.");
    sem_wait(&m_sema);
}
Beispiel #17
0
// Implementation note:  Calls SetColor and Write( text ).  Override those virtuals
// and this one will magically follow suite. :)
bool ConsoleLogFrame::Write( ConsoleColors color, const wxString& text )
{
	pthread_testcancel();

	ScopedLock lock( m_mtx_Queue );

	if( m_QueueColorSection.GetLength() == 0 )
	{
		pxAssertMsg( m_CurQueuePos == 0, "Queue's character position didn't get reset in sync with it's ColorSection table." );
	}

	if( (m_QueueColorSection.GetLength() == 0) || ((color != Color_Current) && (m_QueueColorSection.GetLast().color != color)) )
	{
		++m_CurQueuePos;		// Don't overwrite the NULL;
		m_QueueColorSection.Add( ColorSection(color, m_CurQueuePos) );
	}

	int endpos = m_CurQueuePos + text.Length();
	m_QueueBuffer.MakeRoomFor( endpos + 1 );		// and the null!!
	memcpy( &m_QueueBuffer[m_CurQueuePos], text.wc_str(), sizeof(wxChar) * text.Length() );
	m_CurQueuePos = endpos;

	// this NULL may be overwritten if the next message sent doesn't perform a color change.
	m_QueueBuffer[m_CurQueuePos] = 0;

	// Idle events don't always pass (wx blocks them when moving windows or using menus, for
	// example).  So let's hackfix it so that an alternate message is posted if the queue is
	// "piling up."

	if( !m_pendingFlushMsg )
	{
		m_pendingFlushMsg = true;

		// wxWidgets may have aggressive locks on event processing, so best to release
		// our own mutex lest wx get hung for an extended period of time and cause all
		// of our own stuff to get sluggish.
		lock.Release();

		wxCommandEvent evt( pxEvt_FlushQueue );
		evt.SetInt( 0 );
		if( wxThread::IsMain() )
		{
			OnFlushEvent( evt );
			return false;
		}
		else
			GetEventHandler()->AddPendingEvent( evt );

		lock.Acquire();
	}

	if( !wxThread::IsMain() )
	{
		// Too many color changes causes huge slowdowns when decorating the rich textview, so
		// include a secondary check to avoid having a colorful log spam killing gui responsiveness.

		if( m_CurQueuePos > 0x100000 || m_QueueColorSection.GetLength() > 256 )
		{
			++m_WaitingThreadsForFlush;
			lock.Release();

			// Note: if the queue flushes, we need to return TRUE, so that our thread sleeps
			// until the main thread has had a chance to repaint the console window contents.
			// [TODO] : It'd be a lot better if the console window repaint released the lock
			//  once its task were complete, but thats been problematic, so for now this hack is
			//  what we get.
			if( m_sem_QueueFlushed.Wait( wxTimeSpan( 0,0,0,250 ) ) ) return true;

			// If we're here it means QueueFlush wait timed out, so remove us from the waiting
			// threads count. This way no thread permanently deadlocks against the console
			// logger.  They just run quite slow, but should remain responsive to user input.
			lock.Acquire();
			if( m_WaitingThreadsForFlush != 0 ) --m_WaitingThreadsForFlush;
		}
	}

	return false;
}
Beispiel #18
0
s32 __fastcall Savestate::ThawIt( DataBlock& spud )
{
	if( spud.spu2id != SAVE_ID || spud.version < SAVE_VERSION )
	{
		fprintf(stderr, "\n*** SPU2-X Warning:\n");
		if( spud.spu2id == SAVE_ID )
			fprintf(stderr, "\tSavestate version is from an older version of this plugin.\n");
		else
			fprintf(stderr, "\tThe savestate you are trying to load was not made with this plugin.\n");

		fprintf(stderr,
			"\tAudio may not recover correctly.  Save your game to memorycard, reset,\n\n"
			"\tand then continue from there.\n\n"
		);

		// Do *not* reset the cores.
		// We'll need some "hints" as to how the cores should be initialized, and the
		// only way to get that is to use the game's existing core settings and hope
		// they kinda match the settings for the savestate (IRQ enables and such).

		// adpcm cache : Clear all the cache flags and buffers.

		wipe_the_cache();
	}
	else
	{
		SndBuffer::ClearContents();

		pxAssertMsg( spu2regs && _spu2mem, "Looks like PCSX2 is trying to loadstate while pluigns are shut down.  That's a no-no!  It shouldn't crash, but the savestate will probably be corrupted." );

		// base stuff
		if( spu2regs )	memcpy(spu2regs, spud.unkregs,	sizeof(spud.unkregs));
		if( _spu2mem )	memcpy(_spu2mem, spud.mem,		sizeof(spud.mem));

		memcpy(Cores,	spud.Cores,		sizeof(Cores));
		memcpy(&Spdif,	&spud.Spdif,	sizeof(Spdif));

		OutPos		= spud.OutPos;
		InputPos	= spud.InputPos;
		Cycles		= spud.Cycles;
		lClocks     = spud.lClocks;
		PlayMode	= spud.PlayMode;

		wipe_the_cache();

		// Go through the V_Voice structs and recalculate SBuffer pointer from
		// the NextA setting.

		for( int c=0; c<2; c++ )
		{
			for( int v=0; v<24; v++ )
			{
				const int cacheIdx = Cores[c].Voices[v].NextA / pcm_WordsPerBlock;
				Cores[c].Voices[v].SBuffer = pcm_cache_data[cacheIdx].Sampledata;
			}
		}

		// HACKFIX!! DMAPtr can be invalid after a savestate load, so force it to NULL and
		// ignore it on any pending ADMA writes.  (the DMAPtr concept used to work in old VM
		// editions of PCSX2 with fixed addressing, but new PCSX2s have dynamic memory
		// addressing).

		Cores[0].DMAPtr = Cores[1].DMAPtr = NULL;
	}
	return 0;
}
Beispiel #19
0
xAddressVoid xAddressReg::operator<<( u32 shift ) const
{
	pxAssertMsg( Id != -1, "Uninitialized x86 register." );
	return xAddressVoid( xEmptyReg, *this, 1<<shift );
}
Beispiel #20
0
xAddressVoid xAddressReg::operator*( u32 factor ) const
{
	pxAssertMsg( Id != -1, "Uninitialized x86 register." );
	return xAddressVoid( xEmptyReg, *this, factor );
}
Beispiel #21
0
xAddressVoid xAddressReg::operator-( const void* right ) const
{
	pxAssertMsg( Id != -1, "Uninitialized x86 register." );
	return xAddressVoid( *this, -(sptr)right );
}
Beispiel #22
0
void Threading::Semaphore::WaitWithoutYield()
{
	pxAssertMsg(!wxThread::IsMain(), "Unyielding semaphore wait issued from the main/gui thread.  Please use Wait() instead.");
	MACH_CHECK(semaphore_wait(m_sema));
	__atomic_sub_fetch(&m_counter, 1, __ATOMIC_SEQ_CST);
}