Fix a few stability issues with on-the-fly plugin re-configuration and the F9 RenderSwitch. (all plugin settings should be changeable without having to reset emulation or anything now)

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2133 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
Jake.Stine 2009-11-05 13:13:02 +00:00
parent 8102692d36
commit 0ed2093e5d
9 changed files with 97 additions and 26 deletions

View File

@ -35,10 +35,17 @@ int g_ZeroGSOptions=0, patchnumber;
wxString strgametitle;
struct PatchTextTable
{
const char *text;
int code;
PATCHTABLEFUNC func;
};
//
// Variables
//
PatchTextTable commands[] =
static const PatchTextTable commands[] =
{
{ "comment", 1, patchFunc_comment },
{ "gametitle", 2, patchFunc_gametitle },
@ -56,7 +63,7 @@ PatchTextTable commands[] =
{ "", 0, NULL }
};
PatchTextTable dataType[] =
static const PatchTextTable dataType[] =
{
{ "byte", 1, NULL },
{ "short", 2, NULL },
@ -66,7 +73,7 @@ PatchTextTable dataType[] =
{ "", 0, NULL }
};
PatchTextTable cpuCore[] =
static const PatchTextTable cpuCore[] =
{
{ "EE", 1, NULL },
{ "IOP", 2, NULL },
@ -77,7 +84,7 @@ PatchTextTable cpuCore[] =
// Function Implementations
//
int PatchTableExecute( char * text1, char * text2, PatchTextTable * Table )
static int PatchTableExecute( char * text1, char * text2, const PatchTextTable * Table )
{
int i = 0;

View File

@ -54,13 +54,6 @@ enum patch_data_type {
//
typedef void (*PATCHTABLEFUNC)( char * text1, char * text2 );
struct PatchTextTable
{
const char *text;
int code;
PATCHTABLEFUNC func;
};
struct IniPatch
{
int enabled;
@ -90,9 +83,6 @@ void inifile_trim( char * buffer );
//
// Variables
//
extern PatchTextTable commands[];
extern PatchTextTable dataType[];
extern PatchTextTable cpuCore[];
extern IniPatch patch[ MAX_PATCH ];
extern int patchnumber;

View File

@ -368,10 +368,9 @@ memSavingState::memSavingState( SafeArray<u8>& save_to ) :
// Saving of state data
void memSavingState::FreezeMem( void* data, int size )
{
u8* const dest = m_memory.GetPtr(m_idx);
m_memory.MakeRoomFor( m_idx+size );
memcpy_fast( m_memory.GetPtr(m_idx), data, size );
m_idx += size;
m_memory.MakeRoomFor( m_idx );
memcpy_fast( dest, data, size );
}
void memSavingState::FreezeAll()

View File

@ -247,11 +247,11 @@ void SysCoreThread::OnSuspendInThread()
void SysCoreThread::OnResumeInThread( bool isSuspended )
{
if( isSuspended && g_plugins != NULL )
{
if( g_plugins != NULL )
g_plugins->Open();
if( isSuspended )
CpuInitializeMess();
}
}

View File

@ -552,12 +552,34 @@ DECLARE_APP(Pcsx2App)
#define sMenuBar \
if( wxMenuBar* __menubar_ = GetMenuBar() ) (*__menubar_)
// --------------------------------------------------------------------------------------
// SaveSinglePluginHelper
// --------------------------------------------------------------------------------------
// A scoped convenience class for closing a single plugin and saving its state to memory.
// Emulation is suspended as needed, and is restored when the object leaves scope. Within
// the scope of the object, code is free to call plugin re-configurations or even unload
// a plugin entirely and re-load a different DLL in its place.
//
class SaveSinglePluginHelper
{
protected:
SafeArray<u8> m_plugstore;
const SafeArray<u8>* m_whereitsat;
bool m_resume;
bool m_validstate;
PluginsEnum_t m_pid;
public:
SaveSinglePluginHelper( PluginsEnum_t pid );
virtual ~SaveSinglePluginHelper() throw();
};
// --------------------------------------------------------------------------------------
// External App-related Globals and Shortcuts
// --------------------------------------------------------------------------------------
extern int EnumeratePluginsInFolder( const wxDirName& searchPath, wxArrayString* dest );
extern int EnumeratePluginsInFolder( const wxDirName& searchPath, wxArrayString* dest );
extern void LoadPluginsPassive( FnType_OnThreadComplete* onComplete );
extern void LoadPluginsImmediate();
extern void UnloadPlugins();

View File

@ -90,9 +90,10 @@ namespace Implementations
void Sys_RenderToggle()
{
bool resume = CoreThread.Suspend();
if( g_plugins == NULL ) return;
SaveSinglePluginHelper helper( PluginId_GS );
renderswitch = !renderswitch;
if( resume ) CoreThread.Resume();
}
void Sys_LoggingToggle()

View File

@ -21,6 +21,9 @@
#include "App.h"
// --------------------------------------------------------------------------------------
// GSFrame
// --------------------------------------------------------------------------------------
class GSFrame : public wxFrame
{
protected:

View File

@ -16,6 +16,7 @@
#include "PrecompiledHeader.h"
#include "HostGui.h"
#include "CDVD/CDVD.h"
#include "GS.h"
#include "MainFrame.h"
#include "Dialogs/ModalPopups.h"
@ -72,7 +73,6 @@ bool MainEmuFrame::_DoSelectIsoBrowser( wxString& result )
{
result = ctrl.GetPath();
g_Conf->Folders.RunIso = wxFileName( result ).GetPath();
//sApp.GetRecentIsoList().Add( result );
return true;
}
@ -256,10 +256,9 @@ void MainEmuFrame::Menu_ConfigPlugin_Click(wxCommandEvent &event)
LoadPluginsImmediate();
if( g_plugins == NULL ) return;
bool resume = CoreThread.Suspend();
wxWindowDisabler disabler;
SaveSinglePluginHelper helper( pid );
g_plugins->Configure( pid );
if( resume ) CoreThread.Resume();
}
void MainEmuFrame::Menu_Debug_Open_Click(wxCommandEvent &event)

View File

@ -29,6 +29,15 @@ using namespace Threading;
static FnType_OnThreadComplete* Callback_PluginsLoadComplete = NULL;
// --------------------------------------------------------------------------------------
// AppPluginManager
// --------------------------------------------------------------------------------------
// This extension of PluginManager provides event listener sources for plugins -- loading,
// unloading, open, close, shutdown, etc.
//
// FIXME : Should this be made part of the PCSX2 core emulation? (integrated into PluginManager)
// I'm undecided on if it makes sense more in that context or in this one (interface).
//
class AppPluginManager : public PluginManager
{
typedef PluginManager _parent;
@ -134,6 +143,47 @@ void LoadPluginsTask::OnCleanupInThread()
_parent::OnCleanupInThread();
}
// --------------------------------------------------------------------------------------
// SaveSinglePluginHelper (Implementations)
// --------------------------------------------------------------------------------------
SaveSinglePluginHelper::SaveSinglePluginHelper( PluginsEnum_t pid ) :
m_plugstore( L"PluginConf Savestate" )
, m_whereitsat( NULL )
, m_resume( false )
{
m_pid = pid;
m_validstate = SysHasValidState();
if( !m_validstate ) return;
Console.WriteLn( Color_Green, L"Suspending single plugin: " + tbl_PluginInfo[m_pid].GetShortname() );
m_resume = CoreThread.Pause();
m_whereitsat = StateCopy_GetBuffer();
if( m_whereitsat == NULL )
{
m_whereitsat = &m_plugstore;
memSavingState save( m_plugstore );
g_plugins->Freeze( m_pid, save );
}
g_plugins->Close( pid );
}
SaveSinglePluginHelper::~SaveSinglePluginHelper() throw()
{
if( m_validstate )
{
Console.WriteLn( Color_Green, L"Recovering single plugin: " + tbl_PluginInfo[m_pid].GetShortname() );
memLoadingState load( *m_whereitsat );
if( m_plugstore.IsDisposed() ) load.SeekToSection( m_pid );
g_plugins->Freeze( m_pid, load );
}
if( m_resume ) CoreThread.Resume();
}
/////////////////////////////////////////////////////////////////////////////////////////