2012-12-19 09:30:18 +00:00
|
|
|
/****************************************************************************
|
|
|
|
* *
|
|
|
|
* Project 64 - A Nintendo 64 emulator. *
|
|
|
|
* http://www.pj64-emu.com/ *
|
|
|
|
* Copyright (C) 2012 Project64. All rights reserved. *
|
|
|
|
* *
|
|
|
|
* License: *
|
|
|
|
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
|
|
|
|
* *
|
|
|
|
****************************************************************************/
|
2010-06-07 02:23:58 +00:00
|
|
|
#include "stdafx.h"
|
2008-09-18 03:15:49 +00:00
|
|
|
|
|
|
|
CPlugins::CPlugins (const stdstr & PluginDir):
|
2015-09-23 09:00:51 +00:00
|
|
|
m_RenderWindow(NULL), m_DummyWindow(NULL),
|
|
|
|
m_PluginDir(PluginDir), m_Gfx(NULL), m_Audio(NULL),
|
|
|
|
m_RSP(NULL), m_Control(NULL)
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
|
|
|
CreatePlugins();
|
2012-11-17 01:02:04 +00:00
|
|
|
g_Settings->RegisterChangeCB(Plugin_RSP_Current,this,(CSettings::SettingChangedFunc)PluginChanged);
|
|
|
|
g_Settings->RegisterChangeCB(Plugin_GFX_Current,this,(CSettings::SettingChangedFunc)PluginChanged);
|
|
|
|
g_Settings->RegisterChangeCB(Plugin_AUDIO_Current,this,(CSettings::SettingChangedFunc)PluginChanged);
|
|
|
|
g_Settings->RegisterChangeCB(Plugin_CONT_Current,this,(CSettings::SettingChangedFunc)PluginChanged);
|
2015-02-24 21:44:06 +00:00
|
|
|
g_Settings->RegisterChangeCB(Plugin_UseHleGfx,this,(CSettings::SettingChangedFunc)PluginChanged);
|
2012-11-17 01:02:04 +00:00
|
|
|
g_Settings->RegisterChangeCB(Plugin_UseHleAudio,this,(CSettings::SettingChangedFunc)PluginChanged);
|
|
|
|
g_Settings->RegisterChangeCB(Game_EditPlugin_Gfx,this,(CSettings::SettingChangedFunc)PluginChanged);
|
|
|
|
g_Settings->RegisterChangeCB(Game_EditPlugin_Audio,this,(CSettings::SettingChangedFunc)PluginChanged);
|
|
|
|
g_Settings->RegisterChangeCB(Game_EditPlugin_Contr,this,(CSettings::SettingChangedFunc)PluginChanged);
|
|
|
|
g_Settings->RegisterChangeCB(Game_EditPlugin_RSP,this,(CSettings::SettingChangedFunc)PluginChanged);
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
2013-01-03 08:51:00 +00:00
|
|
|
CPlugins::~CPlugins (void)
|
|
|
|
{
|
2012-11-17 01:02:04 +00:00
|
|
|
g_Settings->UnregisterChangeCB(Plugin_RSP_Current,this,(CSettings::SettingChangedFunc)PluginChanged);
|
|
|
|
g_Settings->UnregisterChangeCB(Plugin_GFX_Current,this,(CSettings::SettingChangedFunc)PluginChanged);
|
|
|
|
g_Settings->UnregisterChangeCB(Plugin_AUDIO_Current,this,(CSettings::SettingChangedFunc)PluginChanged);
|
|
|
|
g_Settings->UnregisterChangeCB(Plugin_CONT_Current,this,(CSettings::SettingChangedFunc)PluginChanged);
|
2015-02-24 21:44:06 +00:00
|
|
|
g_Settings->UnregisterChangeCB(Plugin_UseHleGfx,this,(CSettings::SettingChangedFunc)PluginChanged);
|
2012-11-17 01:02:04 +00:00
|
|
|
g_Settings->UnregisterChangeCB(Plugin_UseHleAudio,this,(CSettings::SettingChangedFunc)PluginChanged);
|
|
|
|
g_Settings->UnregisterChangeCB(Game_EditPlugin_Gfx,this,(CSettings::SettingChangedFunc)PluginChanged);
|
|
|
|
g_Settings->UnregisterChangeCB(Game_EditPlugin_Audio,this,(CSettings::SettingChangedFunc)PluginChanged);
|
|
|
|
g_Settings->UnregisterChangeCB(Game_EditPlugin_Contr,this,(CSettings::SettingChangedFunc)PluginChanged);
|
|
|
|
g_Settings->UnregisterChangeCB(Game_EditPlugin_RSP,this,(CSettings::SettingChangedFunc)PluginChanged);
|
2015-02-24 21:44:06 +00:00
|
|
|
|
2013-01-03 08:51:00 +00:00
|
|
|
DestroyGfxPlugin();
|
|
|
|
DestroyAudioPlugin();
|
|
|
|
DestroyRspPlugin();
|
|
|
|
DestroyControlPlugin();
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
2010-06-07 02:23:58 +00:00
|
|
|
void CPlugins::PluginChanged ( CPlugins * _this )
|
|
|
|
{
|
2015-02-24 21:44:06 +00:00
|
|
|
if (g_Settings->LoadBool(Game_TempLoaded) == true)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2012-11-17 01:02:04 +00:00
|
|
|
bool bGfxChange = _stricmp(_this->m_GfxFile.c_str(),g_Settings->LoadString(Game_Plugin_Gfx).c_str()) != 0;
|
|
|
|
bool bAudioChange = _stricmp(_this->m_AudioFile.c_str(),g_Settings->LoadString(Game_Plugin_Audio).c_str()) != 0;
|
|
|
|
bool bRspChange = _stricmp(_this->m_RSPFile.c_str(),g_Settings->LoadString(Game_Plugin_RSP).c_str()) != 0;
|
|
|
|
bool bContChange = _stricmp(_this->m_ControlFile.c_str(),g_Settings->LoadString(Game_Plugin_Controller).c_str()) != 0;
|
2010-06-07 02:23:58 +00:00
|
|
|
|
|
|
|
if ( bGfxChange || bAudioChange || bRspChange || bContChange )
|
|
|
|
{
|
2015-02-12 10:58:28 +00:00
|
|
|
if (g_Settings->LoadBool(GameRunning_CPU_Running))
|
|
|
|
{
|
|
|
|
//Ensure that base system actually exists before we go triggering the event
|
|
|
|
if (g_BaseSystem)
|
|
|
|
{
|
|
|
|
g_BaseSystem->ExternalEvent(SysEvent_ChangePlugins);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_this->Reset(NULL);
|
|
|
|
g_Notify->RefreshMenu();
|
|
|
|
}
|
2013-01-03 08:51:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-30 21:01:21 +00:00
|
|
|
template <typename plugin_type>
|
|
|
|
static void LoadPlugin (SettingID PluginSettingID, SettingID PluginVerSettingID, plugin_type * & plugin, const char * PluginDir, stdstr & FileName, TraceType TraceLevel, const char * type)
|
|
|
|
{
|
|
|
|
if (plugin != NULL)
|
2013-01-03 08:51:00 +00:00
|
|
|
{
|
2015-01-30 21:01:21 +00:00
|
|
|
return;
|
2013-01-03 08:51:00 +00:00
|
|
|
}
|
2015-01-30 21:01:21 +00:00
|
|
|
FileName = g_Settings->LoadString(PluginSettingID);
|
|
|
|
CPath PluginFileName(PluginDir,FileName.c_str());
|
|
|
|
plugin = new plugin_type();
|
|
|
|
if (plugin)
|
2013-01-03 08:51:00 +00:00
|
|
|
{
|
2015-01-30 21:01:21 +00:00
|
|
|
WriteTraceF(TraceLevel,__FUNCTION__ ": %s Loading (%s): Starting",type,(LPCTSTR)PluginFileName);
|
|
|
|
if (plugin->Load(PluginFileName))
|
|
|
|
{
|
2015-02-26 10:57:51 +00:00
|
|
|
WriteTraceF(TraceLevel,__FUNCTION__ ": %s Current Ver: %s",type,plugin->PluginName());
|
|
|
|
g_Settings->SaveString(PluginVerSettingID,plugin->PluginName());
|
2015-01-30 21:01:21 +00:00
|
|
|
}
|
|
|
|
else
|
2010-06-07 02:23:58 +00:00
|
|
|
{
|
2015-01-30 21:01:21 +00:00
|
|
|
WriteTraceF(TraceError,__FUNCTION__ ": Failed to load %s",(LPCTSTR)PluginFileName);
|
|
|
|
delete plugin;
|
|
|
|
plugin = NULL;
|
2010-06-07 02:23:58 +00:00
|
|
|
}
|
2015-01-30 21:01:21 +00:00
|
|
|
WriteTraceF(TraceLevel,__FUNCTION__ ": %s Loading Done",type);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WriteTraceF(TraceError,__FUNCTION__ ": Failed to allocate %s plugin",type);
|
2010-06-07 02:23:58 +00:00
|
|
|
}
|
2015-01-30 21:01:21 +00:00
|
|
|
}
|
2010-06-07 02:23:58 +00:00
|
|
|
|
2015-01-30 21:01:21 +00:00
|
|
|
void CPlugins::CreatePlugins( void )
|
|
|
|
{
|
|
|
|
LoadPlugin(Game_Plugin_Gfx, Plugin_GFX_CurVer, m_Gfx, m_PluginDir.c_str(), m_GfxFile, TraceGfxPlugin, "GFX");
|
|
|
|
LoadPlugin(Game_Plugin_Audio, Plugin_AUDIO_CurVer, m_Audio, m_PluginDir.c_str(), m_AudioFile, TraceDebug, "Audio");
|
|
|
|
LoadPlugin(Game_Plugin_RSP, Plugin_RSP_CurVer, m_RSP, m_PluginDir.c_str(), m_RSPFile, TraceRSP, "RSP");
|
|
|
|
LoadPlugin(Game_Plugin_Controller, Plugin_CONT_CurVer, m_Control, m_PluginDir.c_str(), m_ControlFile, TraceDebug, "Control");
|
|
|
|
|
|
|
|
//Enable debugger
|
|
|
|
if (m_RSP != NULL && m_RSP->EnableDebugging)
|
2013-01-03 08:51:00 +00:00
|
|
|
{
|
2015-01-30 21:01:21 +00:00
|
|
|
WriteTrace(TraceRSP,__FUNCTION__ ": EnableDebugging starting");
|
|
|
|
m_RSP->EnableDebugging(bHaveDebugger());
|
|
|
|
WriteTrace(TraceRSP,__FUNCTION__ ": EnableDebugging done");
|
2013-01-03 08:51:00 +00:00
|
|
|
}
|
|
|
|
|
2012-09-28 20:07:45 +00:00
|
|
|
if (bHaveDebugger())
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
2012-11-17 00:58:31 +00:00
|
|
|
g_Notify->RefreshMenu();
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPlugins::GameReset ( void )
|
|
|
|
{
|
2015-01-30 21:01:21 +00:00
|
|
|
if (m_Gfx)
|
|
|
|
{
|
2008-09-18 03:15:49 +00:00
|
|
|
m_Gfx->GameReset();
|
|
|
|
}
|
2015-01-30 21:01:21 +00:00
|
|
|
if (m_Audio)
|
|
|
|
{
|
2008-09-18 03:15:49 +00:00
|
|
|
m_Audio->GameReset();
|
|
|
|
}
|
2015-01-30 21:01:21 +00:00
|
|
|
if (m_RSP)
|
|
|
|
{
|
2008-09-18 03:15:49 +00:00
|
|
|
m_RSP->GameReset();
|
|
|
|
}
|
2015-01-30 21:01:21 +00:00
|
|
|
if (m_Control)
|
|
|
|
{
|
2008-09-18 03:15:49 +00:00
|
|
|
m_Control->GameReset();
|
|
|
|
}
|
|
|
|
}
|
2013-01-03 08:51:00 +00:00
|
|
|
|
|
|
|
void CPlugins::DestroyGfxPlugin( void )
|
|
|
|
{
|
|
|
|
if (m_Gfx == NULL)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
WriteTrace(TraceGfxPlugin,__FUNCTION__ ": before delete m_Gfx");
|
|
|
|
delete m_Gfx;
|
|
|
|
WriteTrace(TraceGfxPlugin,__FUNCTION__ ": after delete m_Gfx");
|
|
|
|
m_Gfx = NULL;
|
2012-11-17 01:02:04 +00:00
|
|
|
// g_Settings->UnknownSetting_GFX = NULL;
|
2013-01-03 08:51:00 +00:00
|
|
|
DestroyRspPlugin();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPlugins::DestroyAudioPlugin( void )
|
|
|
|
{
|
|
|
|
if (m_Audio == NULL)
|
|
|
|
{
|
|
|
|
return;
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
2013-01-03 08:51:00 +00:00
|
|
|
WriteTrace(TraceDebug,__FUNCTION__ ": 5");
|
|
|
|
m_Audio->Close();
|
|
|
|
WriteTrace(TraceDebug,__FUNCTION__ ": 6");
|
|
|
|
delete m_Audio;
|
|
|
|
WriteTrace(TraceDebug,__FUNCTION__ ": 7");
|
|
|
|
m_Audio = NULL;
|
|
|
|
WriteTrace(TraceDebug,__FUNCTION__ ": 8");
|
2012-11-17 01:02:04 +00:00
|
|
|
// g_Settings->UnknownSetting_AUDIO = NULL;
|
2013-01-03 08:51:00 +00:00
|
|
|
DestroyRspPlugin();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPlugins::DestroyRspPlugin( void )
|
|
|
|
{
|
|
|
|
if (m_RSP == NULL)
|
|
|
|
{
|
|
|
|
return;
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
2013-01-03 08:51:00 +00:00
|
|
|
WriteTrace(TraceDebug,__FUNCTION__ ": 9");
|
|
|
|
m_RSP->Close();
|
|
|
|
WriteTrace(TraceDebug,__FUNCTION__ ": 10");
|
|
|
|
delete m_RSP;
|
|
|
|
WriteTrace(TraceDebug,__FUNCTION__ ": 11");
|
|
|
|
m_RSP = NULL;
|
|
|
|
WriteTrace(TraceDebug,__FUNCTION__ ": 12");
|
2012-11-17 01:02:04 +00:00
|
|
|
// g_Settings->UnknownSetting_RSP = NULL;
|
2013-01-03 08:51:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CPlugins::DestroyControlPlugin( void )
|
|
|
|
{
|
|
|
|
if (m_Control == NULL)
|
|
|
|
{
|
|
|
|
return;
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
2013-01-03 08:51:00 +00:00
|
|
|
WriteTrace(TraceDebug,__FUNCTION__ ": 13");
|
|
|
|
m_Control->Close();
|
|
|
|
WriteTrace(TraceDebug,__FUNCTION__ ": 14");
|
|
|
|
delete m_Control;
|
|
|
|
WriteTrace(TraceDebug,__FUNCTION__ ": 15");
|
|
|
|
m_Control = NULL;
|
|
|
|
WriteTrace(TraceDebug,__FUNCTION__ ": 16");
|
2012-11-17 01:02:04 +00:00
|
|
|
// g_Settings->UnknownSetting_CTRL = NULL;
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
2012-11-02 23:28:09 +00:00
|
|
|
void CPlugins::SetRenderWindows( CMainGui * RenderWindow, CMainGui * DummyWindow )
|
|
|
|
{
|
|
|
|
m_RenderWindow = RenderWindow;
|
|
|
|
m_DummyWindow = DummyWindow;
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
2013-01-03 08:51:00 +00:00
|
|
|
void CPlugins::RomOpened ( void )
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
2013-01-03 08:51:00 +00:00
|
|
|
m_Gfx->RomOpened();
|
2013-02-11 08:27:00 +00:00
|
|
|
m_RSP->RomOpened();
|
2013-01-03 08:51:00 +00:00
|
|
|
m_Audio->RomOpened();
|
|
|
|
m_Control->RomOpened();
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
2013-01-03 08:51:00 +00:00
|
|
|
void CPlugins::RomClosed ( void )
|
|
|
|
{
|
|
|
|
m_Gfx->RomClose();
|
2013-02-11 08:27:00 +00:00
|
|
|
m_RSP->RomClose();
|
2013-01-03 08:51:00 +00:00
|
|
|
m_Audio->RomClose();
|
|
|
|
m_Control->RomClose();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CPlugins::Initiate ( CN64System * System )
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
2012-12-17 00:21:29 +00:00
|
|
|
WriteTrace(TraceDebug,__FUNCTION__ ": Start");
|
2013-01-03 08:51:00 +00:00
|
|
|
//Check to make sure we have the plugin available to be used
|
2008-09-18 03:15:49 +00:00
|
|
|
if (m_Gfx == NULL) { return false; }
|
|
|
|
if (m_Audio == NULL) { return false; }
|
|
|
|
if (m_RSP == NULL) { return false; }
|
|
|
|
if (m_Control == NULL) { return false; }
|
|
|
|
|
2012-12-17 00:21:29 +00:00
|
|
|
WriteTrace(TraceGfxPlugin,__FUNCTION__ ": Gfx Initiate Starting");
|
2013-01-03 08:51:00 +00:00
|
|
|
if (!m_Gfx->Initiate(System,m_RenderWindow)) { return false; }
|
2012-12-17 00:21:29 +00:00
|
|
|
WriteTrace(TraceGfxPlugin,__FUNCTION__ ": Gfx Initiate Done");
|
2013-01-03 08:51:00 +00:00
|
|
|
WriteTrace(TraceDebug,__FUNCTION__ ": Audio Initiate Starting");
|
|
|
|
if (!m_Audio->Initiate(System,m_RenderWindow)) { return false; }
|
|
|
|
WriteTrace(TraceDebug,__FUNCTION__ ": Audio Initiate Done");
|
2015-01-30 21:01:21 +00:00
|
|
|
WriteTrace(TraceDebug, __FUNCTION__ ": Control Initiate Starting");
|
2013-01-03 08:51:00 +00:00
|
|
|
if (!m_Control->Initiate(System,m_RenderWindow)) { return false; }
|
2015-01-30 21:01:21 +00:00
|
|
|
WriteTrace(TraceDebug, __FUNCTION__ ": Control Initiate Done");
|
2013-01-03 08:51:00 +00:00
|
|
|
WriteTrace(TraceRSP,__FUNCTION__ ": RSP Initiate Starting");
|
|
|
|
if (!m_RSP->Initiate(this,System)) { return false; }
|
|
|
|
WriteTrace(TraceRSP,__FUNCTION__ ": RSP Initiate Done");
|
2012-12-17 00:21:29 +00:00
|
|
|
WriteTrace(TraceDebug,__FUNCTION__ ": Done");
|
2008-09-18 03:15:49 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-02-12 10:58:28 +00:00
|
|
|
bool CPlugins::ResetInUiThread ( CN64System * System )
|
|
|
|
{
|
2015-09-14 19:55:11 +00:00
|
|
|
#if defined(WINDOWS_UI)
|
2015-02-12 10:58:28 +00:00
|
|
|
return m_RenderWindow->ResetPlugins(this, System);
|
2015-09-14 19:55:11 +00:00
|
|
|
#else
|
|
|
|
g_Notify -> BreakPoint(__FILEW__, __LINE__);
|
|
|
|
return false;
|
|
|
|
#endif
|
2015-02-12 10:58:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CPlugins::Reset ( CN64System * System )
|
2013-01-03 08:51:00 +00:00
|
|
|
{
|
2015-02-12 10:58:28 +00:00
|
|
|
WriteTrace(TraceDebug,__FUNCTION__ ": Start");
|
|
|
|
|
2013-01-03 08:51:00 +00:00
|
|
|
bool bGfxChange = _stricmp(m_GfxFile.c_str(),g_Settings->LoadString(Game_Plugin_Gfx).c_str()) != 0;
|
|
|
|
bool bAudioChange = _stricmp(m_AudioFile.c_str(),g_Settings->LoadString(Game_Plugin_Audio).c_str()) != 0;
|
|
|
|
bool bRspChange = _stricmp(m_RSPFile.c_str(),g_Settings->LoadString(Game_Plugin_RSP).c_str()) != 0;
|
|
|
|
bool bContChange = _stricmp(m_ControlFile.c_str(),g_Settings->LoadString(Game_Plugin_Controller).c_str()) != 0;
|
|
|
|
|
2015-02-12 10:58:28 +00:00
|
|
|
//if GFX and Audio has changed we also need to force reset of RSP
|
|
|
|
if (bGfxChange || bAudioChange)
|
|
|
|
bRspChange = true;
|
|
|
|
|
2013-01-03 08:51:00 +00:00
|
|
|
if (bGfxChange) { DestroyGfxPlugin(); }
|
|
|
|
if (bAudioChange) { DestroyAudioPlugin(); }
|
|
|
|
if (bRspChange) { DestroyRspPlugin(); }
|
|
|
|
if (bContChange) { DestroyControlPlugin(); }
|
|
|
|
|
2008-09-18 03:15:49 +00:00
|
|
|
CreatePlugins();
|
2015-02-12 10:58:28 +00:00
|
|
|
|
2015-03-18 09:49:15 +00:00
|
|
|
if (m_Gfx && bGfxChange)
|
2015-02-12 10:58:28 +00:00
|
|
|
{
|
|
|
|
WriteTrace(TraceGfxPlugin,__FUNCTION__ ": Gfx Initiate Starting");
|
|
|
|
if (!m_Gfx->Initiate(System,m_RenderWindow)) { return false; }
|
|
|
|
WriteTrace(TraceGfxPlugin,__FUNCTION__ ": Gfx Initiate Done");
|
|
|
|
}
|
2015-03-18 09:49:15 +00:00
|
|
|
if (m_Audio && bAudioChange)
|
2015-02-12 10:58:28 +00:00
|
|
|
{
|
|
|
|
WriteTrace(TraceDebug,__FUNCTION__ ": Audio Initiate Starting");
|
|
|
|
if (!m_Audio->Initiate(System,m_RenderWindow)) { return false; }
|
|
|
|
WriteTrace(TraceDebug,__FUNCTION__ ": Audio Initiate Done");
|
|
|
|
}
|
2015-03-18 09:49:15 +00:00
|
|
|
if (m_Control && bContChange)
|
2015-02-12 10:58:28 +00:00
|
|
|
{
|
|
|
|
WriteTrace(TraceDebug, __FUNCTION__ ": Control Initiate Starting");
|
|
|
|
if (!m_Control->Initiate(System,m_RenderWindow)) { return false; }
|
|
|
|
WriteTrace(TraceDebug, __FUNCTION__ ": Control Initiate Done");
|
|
|
|
}
|
2015-03-18 09:49:15 +00:00
|
|
|
if (m_RSP && bRspChange)
|
2015-02-12 10:58:28 +00:00
|
|
|
{
|
|
|
|
WriteTrace(TraceRSP,__FUNCTION__ ": RSP Initiate Starting");
|
|
|
|
if (!m_RSP->Initiate(this,System)) { return false; }
|
|
|
|
WriteTrace(TraceRSP,__FUNCTION__ ": RSP Initiate Done");
|
|
|
|
}
|
|
|
|
WriteTrace(TraceDebug,__FUNCTION__ ": Done");
|
|
|
|
return true;
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CPlugins::ConfigPlugin ( DWORD hParent, PLUGIN_TYPE Type ) {
|
|
|
|
switch (Type) {
|
|
|
|
case PLUGIN_TYPE_RSP:
|
2015-02-02 18:26:13 +00:00
|
|
|
if (m_RSP == NULL || m_RSP->DllConfig == NULL) { break; }
|
2015-04-20 20:01:18 +00:00
|
|
|
if (!m_RSP->Initialized()) {
|
2008-09-18 03:15:49 +00:00
|
|
|
if (!m_RSP->Initiate(NULL,NULL)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2015-02-02 18:26:13 +00:00
|
|
|
m_RSP->DllConfig(hParent);
|
2008-09-18 03:15:49 +00:00
|
|
|
break;
|
|
|
|
case PLUGIN_TYPE_GFX:
|
2015-01-30 21:01:21 +00:00
|
|
|
if (m_Gfx == NULL || m_Gfx->DllConfig == NULL) { break; }
|
2015-04-20 20:01:18 +00:00
|
|
|
if (!m_Gfx->Initialized()) {
|
2012-11-02 23:28:09 +00:00
|
|
|
if (!m_Gfx->Initiate(NULL,m_DummyWindow)) {
|
2008-09-18 03:15:49 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2015-01-30 21:01:21 +00:00
|
|
|
m_Gfx->DllConfig(hParent);
|
2008-09-18 03:15:49 +00:00
|
|
|
break;
|
|
|
|
case PLUGIN_TYPE_AUDIO:
|
2015-01-30 21:01:21 +00:00
|
|
|
if (m_Audio == NULL || m_Audio->DllConfig == NULL) { break; }
|
2015-04-20 20:01:18 +00:00
|
|
|
if (!m_Audio->Initialized()) {
|
2012-11-02 23:28:09 +00:00
|
|
|
if (!m_Audio->Initiate(NULL,m_DummyWindow)) {
|
2008-09-18 03:15:49 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2015-01-30 21:01:21 +00:00
|
|
|
m_Audio->DllConfig(hParent);
|
2008-09-18 03:15:49 +00:00
|
|
|
break;
|
|
|
|
case PLUGIN_TYPE_CONTROLLER:
|
2015-01-30 21:01:21 +00:00
|
|
|
if (m_Control == NULL || m_Control->DllConfig == NULL) { break; }
|
2015-04-20 20:01:18 +00:00
|
|
|
if (!m_Control->Initialized()) {
|
2012-11-02 23:28:09 +00:00
|
|
|
if (!m_Control->Initiate(NULL,m_DummyWindow)) {
|
2008-09-18 03:15:49 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2015-01-30 21:01:21 +00:00
|
|
|
m_Control->DllConfig(hParent);
|
2008-09-18 03:15:49 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DummyCheckInterrupts ( void ) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void DummyFunction (void) {
|
|
|
|
}
|
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
|
|
|
|
void CPlugins::CreatePluginDir ( const stdstr & DstDir ) const {
|
|
|
|
char path_buffer[_MAX_PATH], drive[_MAX_DRIVE], dir[_MAX_DIR],
|
|
|
|
fname[_MAX_FNAME], ext[_MAX_EXT];
|
|
|
|
_splitpath(DstDir.c_str(), drive, dir, fname, ext );
|
|
|
|
_makepath(path_buffer, drive, dir, "", "" );
|
|
|
|
if (CreateDirectory(path_buffer,NULL) == 0 && GetLastError() == ERROR_PATH_NOT_FOUND)
|
|
|
|
{
|
|
|
|
path_buffer[strlen(path_buffer) - 1] = 0;
|
|
|
|
CreatePluginDir(stdstr(path_buffer));
|
|
|
|
CreateDirectory(path_buffer,NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-04 01:47:02 +00:00
|
|
|
bool CPlugins::CopyPlugins ( const stdstr & DstDir ) const
|
|
|
|
{
|
2008-09-18 03:15:49 +00:00
|
|
|
//Copy GFX Plugin
|
2015-02-24 21:44:06 +00:00
|
|
|
CPath srcGfxPlugin(m_PluginDir.c_str(),g_Settings->LoadString(Game_Plugin_Gfx).c_str());
|
|
|
|
CPath dstGfxPlugin(DstDir.c_str(),g_Settings->LoadString(Game_Plugin_Gfx).c_str());
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2012-10-04 01:47:02 +00:00
|
|
|
if (CopyFile(srcGfxPlugin,dstGfxPlugin,false) == 0)
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
2012-10-05 09:23:41 +00:00
|
|
|
if (GetLastError() == ERROR_PATH_NOT_FOUND) { dstGfxPlugin.CreateDirectory(); }
|
2012-10-04 01:47:02 +00:00
|
|
|
if (!CopyFile(srcGfxPlugin,dstGfxPlugin,false))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//Copy m_Audio Plugin
|
2015-02-24 21:44:06 +00:00
|
|
|
CPath srcAudioPlugin(m_PluginDir.c_str(),g_Settings->LoadString(Game_Plugin_Audio).c_str());
|
|
|
|
CPath dstAudioPlugin(DstDir.c_str(), g_Settings->LoadString(Game_Plugin_Audio).c_str());
|
2012-10-04 01:47:02 +00:00
|
|
|
if (CopyFile(srcAudioPlugin,dstAudioPlugin,false) == 0) {
|
2012-10-05 09:23:41 +00:00
|
|
|
if (GetLastError() == ERROR_PATH_NOT_FOUND) { dstAudioPlugin.CreateDirectory(); }
|
2012-10-04 01:47:02 +00:00
|
|
|
if (!CopyFile(srcAudioPlugin,dstAudioPlugin,false))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
2015-02-24 21:44:06 +00:00
|
|
|
//Copy RSP Plugin
|
|
|
|
CPath srcRSPPlugin(m_PluginDir.c_str(), g_Settings->LoadString(Game_Plugin_RSP).c_str());
|
|
|
|
CPath dstRSPPlugin(DstDir.c_str(),g_Settings->LoadString(Game_Plugin_RSP).c_str());
|
2012-10-04 01:47:02 +00:00
|
|
|
if (CopyFile(srcRSPPlugin,dstRSPPlugin,false) == 0) {
|
2012-10-05 09:23:41 +00:00
|
|
|
if (GetLastError() == ERROR_PATH_NOT_FOUND) { dstRSPPlugin.CreateDirectory(); }
|
2012-10-04 01:47:02 +00:00
|
|
|
if (!CopyFile(srcRSPPlugin,dstRSPPlugin,false))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
2012-10-04 01:47:02 +00:00
|
|
|
//Copy Controller Plugin
|
2015-02-24 21:44:06 +00:00
|
|
|
CPath srcContPlugin(m_PluginDir.c_str(), g_Settings->LoadString(Game_Plugin_Controller).c_str());
|
|
|
|
CPath dstContPlugin(DstDir.c_str(),g_Settings->LoadString(Game_Plugin_Controller).c_str());
|
2012-10-05 09:23:41 +00:00
|
|
|
if (!srcContPlugin.CopyTo(dstContPlugin))
|
|
|
|
{
|
|
|
|
if (GetLastError() == ERROR_PATH_NOT_FOUND) { dstContPlugin.CreateDirectory(); }
|
2012-10-04 01:47:02 +00:00
|
|
|
if (!CopyFile(srcContPlugin,dstContPlugin,false))
|
|
|
|
{
|
2012-10-05 09:23:41 +00:00
|
|
|
DWORD dwError = GetLastError();
|
|
|
|
dwError = dwError;
|
2012-10-04 01:47:02 +00:00
|
|
|
return false;
|
|
|
|
}
|
2010-05-31 00:21:08 +00:00
|
|
|
}
|
2012-10-04 01:47:02 +00:00
|
|
|
return true;
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|