2012-12-19 09:30:18 +00:00
|
|
|
/****************************************************************************
|
|
|
|
* *
|
2015-11-10 05:21:49 +00:00
|
|
|
* Project64 - A Nintendo 64 emulator. *
|
2012-12-19 09:30:18 +00:00
|
|
|
* 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"
|
2015-12-06 09:59:58 +00:00
|
|
|
#include <Project64-core/N64System/SystemGlobals.h>
|
|
|
|
#include <Project64-core/N64System/N64Class.h>
|
2016-01-17 18:48:19 +00:00
|
|
|
#include <Project64-core/Plugins/PluginClass.h>
|
2015-12-04 06:49:31 +00:00
|
|
|
#include <Common/path.h>
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2015-11-08 06:08:15 +00:00
|
|
|
CPlugins::CPlugins(const stdstr & PluginDir) :
|
2016-01-17 18:48:19 +00:00
|
|
|
m_MainWindow(NULL),
|
|
|
|
m_SyncWindow(NULL),
|
|
|
|
m_PluginDir(PluginDir),
|
|
|
|
m_Gfx(NULL),
|
|
|
|
m_Audio(NULL),
|
|
|
|
m_RSP(NULL),
|
|
|
|
m_Control(NULL)
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
2015-11-15 20:10:01 +00:00
|
|
|
CreatePlugins();
|
|
|
|
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);
|
|
|
|
g_Settings->RegisterChangeCB(Plugin_UseHleGfx, this, (CSettings::SettingChangedFunc)PluginChanged);
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2015-11-08 06:08:15 +00:00
|
|
|
CPlugins::~CPlugins(void)
|
2013-01-03 08:51:00 +00:00
|
|
|
{
|
2015-11-15 20:10:01 +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);
|
|
|
|
g_Settings->UnregisterChangeCB(Plugin_UseHleGfx, this, (CSettings::SettingChangedFunc)PluginChanged);
|
|
|
|
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);
|
|
|
|
|
|
|
|
DestroyGfxPlugin();
|
|
|
|
DestroyAudioPlugin();
|
|
|
|
DestroyRspPlugin();
|
|
|
|
DestroyControlPlugin();
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
2015-11-08 06:08:15 +00:00
|
|
|
void CPlugins::PluginChanged(CPlugins * _this)
|
2010-06-07 02:23:58 +00:00
|
|
|
{
|
2015-11-15 20:10:01 +00:00
|
|
|
if (g_Settings->LoadBool(Game_TempLoaded) == true)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
bool bGfxChange = _stricmp(_this->m_GfxFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_Gfx).c_str()) != 0;
|
|
|
|
bool bAudioChange = _stricmp(_this->m_AudioFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_Audio).c_str()) != 0;
|
|
|
|
bool bRspChange = _stricmp(_this->m_RSPFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_RSP).c_str()) != 0;
|
|
|
|
bool bContChange = _stricmp(_this->m_ControlFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_Controller).c_str()) != 0;
|
|
|
|
|
|
|
|
if (bGfxChange || bAudioChange || bRspChange || bContChange)
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
2013-01-03 08:51:00 +00:00
|
|
|
}
|
|
|
|
|
2015-01-30 21:01:21 +00:00
|
|
|
template <typename plugin_type>
|
2015-12-14 10:51:33 +00:00
|
|
|
static void LoadPlugin(SettingID PluginSettingID, SettingID PluginVerSettingID, plugin_type * & plugin, const char * PluginDir, stdstr & FileName, TraceModuleProject64 TraceLevel, const char * type)
|
2015-11-08 06:08:15 +00:00
|
|
|
{
|
2015-11-15 20:10:01 +00:00
|
|
|
if (plugin != NULL)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
FileName = g_Settings->LoadStringVal(PluginSettingID);
|
|
|
|
CPath PluginFileName(PluginDir, FileName.c_str());
|
|
|
|
plugin = new plugin_type();
|
|
|
|
if (plugin)
|
|
|
|
{
|
2015-12-14 10:51:33 +00:00
|
|
|
WriteTrace(TraceLevel, TraceDebug, "%s Loading (%s): Starting", type, (const char *)PluginFileName);
|
2015-11-15 20:10:01 +00:00
|
|
|
if (plugin->Load(PluginFileName))
|
|
|
|
{
|
2015-12-14 10:51:33 +00:00
|
|
|
WriteTrace(TraceLevel, TraceDebug, "%s Current Ver: %s", type, plugin->PluginName());
|
2015-11-15 20:10:01 +00:00
|
|
|
g_Settings->SaveString(PluginVerSettingID, plugin->PluginName());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-12-14 10:51:33 +00:00
|
|
|
WriteTrace(TraceError, TraceDebug, "Failed to load %s", (const char *)PluginFileName);
|
2015-11-15 20:10:01 +00:00
|
|
|
delete plugin;
|
|
|
|
plugin = NULL;
|
|
|
|
}
|
2015-12-14 10:51:33 +00:00
|
|
|
WriteTrace(TraceLevel, TraceDebug, "%s Loading Done", type);
|
2015-11-15 20:10:01 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-12-14 10:51:33 +00:00
|
|
|
WriteTrace(TraceError, TraceDebug, "Failed to allocate %s plugin", type);
|
2015-11-15 20:10:01 +00:00
|
|
|
}
|
2015-01-30 21:01:21 +00:00
|
|
|
}
|
2010-06-07 02:23:58 +00:00
|
|
|
|
2015-11-08 06:08:15 +00:00
|
|
|
void CPlugins::CreatePlugins(void)
|
2015-01-30 21:01:21 +00:00
|
|
|
{
|
2015-12-14 10:51:33 +00:00
|
|
|
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, TraceAudioPlugin, "Audio");
|
|
|
|
LoadPlugin(Game_Plugin_RSP, Plugin_RSP_CurVer, m_RSP, m_PluginDir.c_str(), m_RSPFile, TraceRSPPlugin, "RSP");
|
|
|
|
LoadPlugin(Game_Plugin_Controller, Plugin_CONT_CurVer, m_Control, m_PluginDir.c_str(), m_ControlFile, TraceControllerPlugin, "Control");
|
2015-11-15 20:10:01 +00:00
|
|
|
|
|
|
|
//Enable debugger
|
|
|
|
if (m_RSP != NULL && m_RSP->EnableDebugging)
|
|
|
|
{
|
2015-12-14 10:51:33 +00:00
|
|
|
WriteTrace(TraceRSPPlugin, TraceInfo, "EnableDebugging starting");
|
2015-11-15 20:10:01 +00:00
|
|
|
m_RSP->EnableDebugging(bHaveDebugger());
|
2015-12-14 10:51:33 +00:00
|
|
|
WriteTrace(TraceRSPPlugin, TraceInfo, "EnableDebugging done");
|
2015-11-15 20:10:01 +00:00
|
|
|
}
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
2015-11-08 06:08:15 +00:00
|
|
|
void CPlugins::GameReset(void)
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
2015-11-15 20:10:01 +00:00
|
|
|
if (m_Gfx)
|
|
|
|
{
|
|
|
|
m_Gfx->GameReset();
|
|
|
|
}
|
|
|
|
if (m_Audio)
|
|
|
|
{
|
|
|
|
m_Audio->GameReset();
|
|
|
|
}
|
|
|
|
if (m_RSP)
|
|
|
|
{
|
|
|
|
m_RSP->GameReset();
|
|
|
|
}
|
|
|
|
if (m_Control)
|
|
|
|
{
|
|
|
|
m_Control->GameReset();
|
|
|
|
}
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
2013-01-03 08:51:00 +00:00
|
|
|
|
2015-11-08 06:08:15 +00:00
|
|
|
void CPlugins::DestroyGfxPlugin(void)
|
2013-01-03 08:51:00 +00:00
|
|
|
{
|
2015-11-15 20:10:01 +00:00
|
|
|
if (m_Gfx == NULL)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2015-12-14 10:51:33 +00:00
|
|
|
WriteTrace(TraceGFXPlugin, TraceInfo, "before delete m_Gfx");
|
2015-11-15 20:10:01 +00:00
|
|
|
delete m_Gfx;
|
2015-12-14 10:51:33 +00:00
|
|
|
WriteTrace(TraceGFXPlugin, TraceInfo, "after delete m_Gfx");
|
2015-11-15 20:10:01 +00:00
|
|
|
m_Gfx = NULL;
|
|
|
|
// g_Settings->UnknownSetting_GFX = NULL;
|
|
|
|
DestroyRspPlugin();
|
2013-01-03 08:51:00 +00:00
|
|
|
}
|
|
|
|
|
2015-11-08 06:08:15 +00:00
|
|
|
void CPlugins::DestroyAudioPlugin(void)
|
2013-01-03 08:51:00 +00:00
|
|
|
{
|
2015-11-15 20:10:01 +00:00
|
|
|
if (m_Audio == NULL)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2015-12-14 10:51:33 +00:00
|
|
|
WriteTrace(TraceAudioPlugin, TraceDebug, "before close");
|
2015-11-15 20:10:01 +00:00
|
|
|
m_Audio->Close();
|
2015-12-14 10:51:33 +00:00
|
|
|
WriteTrace(TraceAudioPlugin, TraceDebug, "before delete");
|
2015-11-15 20:10:01 +00:00
|
|
|
delete m_Audio;
|
2015-12-14 10:51:33 +00:00
|
|
|
WriteTrace(TraceAudioPlugin, TraceDebug, "after delete");
|
2015-11-15 20:10:01 +00:00
|
|
|
m_Audio = NULL;
|
2015-12-14 10:51:33 +00:00
|
|
|
WriteTrace(TraceAudioPlugin, TraceDebug, "before DestroyRspPlugin");
|
2015-11-15 20:10:01 +00:00
|
|
|
// g_Settings->UnknownSetting_AUDIO = NULL;
|
|
|
|
DestroyRspPlugin();
|
2015-12-14 10:51:33 +00:00
|
|
|
WriteTrace(TraceAudioPlugin, TraceDebug, "after DestroyRspPlugin");
|
2013-01-03 08:51:00 +00:00
|
|
|
}
|
|
|
|
|
2015-11-08 06:08:15 +00:00
|
|
|
void CPlugins::DestroyRspPlugin(void)
|
2013-01-03 08:51:00 +00:00
|
|
|
{
|
2015-11-15 20:10:01 +00:00
|
|
|
if (m_RSP == NULL)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2015-12-14 10:51:33 +00:00
|
|
|
WriteTrace(TraceRSPPlugin, TraceDebug, "before close");
|
2015-11-15 20:10:01 +00:00
|
|
|
m_RSP->Close();
|
2015-12-14 10:51:33 +00:00
|
|
|
WriteTrace(TraceRSPPlugin, TraceDebug, "before delete");
|
2015-11-15 20:10:01 +00:00
|
|
|
delete m_RSP;
|
|
|
|
m_RSP = NULL;
|
2015-12-14 10:51:33 +00:00
|
|
|
WriteTrace(TraceRSPPlugin, TraceDebug, "after delete");
|
2015-11-15 20:10:01 +00:00
|
|
|
// g_Settings->UnknownSetting_RSP = NULL;
|
2013-01-03 08:51:00 +00:00
|
|
|
}
|
|
|
|
|
2015-11-08 06:08:15 +00:00
|
|
|
void CPlugins::DestroyControlPlugin(void)
|
2013-01-03 08:51:00 +00:00
|
|
|
{
|
2015-11-15 20:10:01 +00:00
|
|
|
if (m_Control == NULL)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2015-12-14 10:51:33 +00:00
|
|
|
WriteTrace(TraceControllerPlugin, TraceDebug, "before close");
|
2015-11-15 20:10:01 +00:00
|
|
|
m_Control->Close();
|
2015-12-14 10:51:33 +00:00
|
|
|
WriteTrace(TraceControllerPlugin, TraceDebug, "before delete");
|
2015-11-15 20:10:01 +00:00
|
|
|
delete m_Control;
|
|
|
|
m_Control = NULL;
|
2015-12-14 10:51:33 +00:00
|
|
|
WriteTrace(TraceControllerPlugin, TraceDebug, "after delete");
|
2015-11-15 20:10:01 +00:00
|
|
|
// g_Settings->UnknownSetting_CTRL = NULL;
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
2015-11-12 10:08:47 +00:00
|
|
|
void CPlugins::SetRenderWindows(RenderWindow * MainWindow, RenderWindow * SyncWindow)
|
2012-11-02 23:28:09 +00:00
|
|
|
{
|
2015-11-15 20:10:01 +00:00
|
|
|
m_MainWindow = MainWindow;
|
|
|
|
m_SyncWindow = SyncWindow;
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
2015-11-08 06:08:15 +00:00
|
|
|
void CPlugins::RomOpened(void)
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
2015-11-15 20:10:01 +00:00
|
|
|
m_Gfx->RomOpened();
|
|
|
|
m_RSP->RomOpened();
|
|
|
|
m_Audio->RomOpened();
|
|
|
|
m_Control->RomOpened();
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
2015-11-08 06:08:15 +00:00
|
|
|
void CPlugins::RomClosed(void)
|
2013-01-03 08:51:00 +00:00
|
|
|
{
|
2015-11-15 20:10:01 +00:00
|
|
|
m_Gfx->RomClose();
|
|
|
|
m_RSP->RomClose();
|
|
|
|
m_Audio->RomClose();
|
|
|
|
m_Control->RomClose();
|
2013-01-03 08:51:00 +00:00
|
|
|
}
|
|
|
|
|
2015-11-08 06:08:15 +00:00
|
|
|
bool CPlugins::Initiate(CN64System * System)
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
2015-12-14 10:51:33 +00:00
|
|
|
WriteTrace(TracePlugins, TraceDebug, "Start");
|
2015-11-15 20:10:01 +00:00
|
|
|
//Check to make sure we have the plugin available to be used
|
|
|
|
if (m_Gfx == NULL) { return false; }
|
|
|
|
if (m_Audio == NULL) { return false; }
|
|
|
|
if (m_RSP == NULL) { return false; }
|
|
|
|
if (m_Control == NULL) { return false; }
|
|
|
|
|
2015-12-14 10:51:33 +00:00
|
|
|
WriteTrace(TraceGFXPlugin, TraceDebug, "Gfx Initiate Starting");
|
2015-11-15 20:10:01 +00:00
|
|
|
if (!m_Gfx->Initiate(System, m_MainWindow)) { return false; }
|
2015-12-14 10:51:33 +00:00
|
|
|
WriteTrace(TraceGFXPlugin, TraceDebug, "Gfx Initiate Done");
|
|
|
|
WriteTrace(TraceAudioPlugin, TraceDebug, "Audio Initiate Starting");
|
2015-11-15 20:10:01 +00:00
|
|
|
if (!m_Audio->Initiate(System, m_MainWindow)) { return false; }
|
2015-12-14 10:51:33 +00:00
|
|
|
WriteTrace(TraceAudioPlugin, TraceDebug, "Audio Initiate Done");
|
|
|
|
WriteTrace(TraceControllerPlugin, TraceDebug, "Control Initiate Starting");
|
2015-11-15 20:10:01 +00:00
|
|
|
if (!m_Control->Initiate(System, m_MainWindow)) { return false; }
|
2015-12-14 10:51:33 +00:00
|
|
|
WriteTrace(TraceControllerPlugin, TraceDebug, "Control Initiate Done");
|
|
|
|
WriteTrace(TraceRSPPlugin, TraceDebug, "RSP Initiate Starting");
|
2015-11-15 20:10:01 +00:00
|
|
|
if (!m_RSP->Initiate(this, System)) { return false; }
|
2015-12-14 10:51:33 +00:00
|
|
|
WriteTrace(TraceRSPPlugin, TraceDebug, "RSP Initiate Done");
|
|
|
|
WriteTrace(TracePlugins, TraceDebug, "Done");
|
2015-11-15 20:10:01 +00:00
|
|
|
return true;
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
2015-11-08 06:08:15 +00:00
|
|
|
bool CPlugins::ResetInUiThread(CN64System * System)
|
2015-02-12 10:58:28 +00:00
|
|
|
{
|
2015-11-15 20:10:01 +00:00
|
|
|
return m_MainWindow->ResetPluginsInUiThread(this, System);
|
2015-02-12 10:58:28 +00:00
|
|
|
}
|
|
|
|
|
2015-11-08 06:08:15 +00:00
|
|
|
bool CPlugins::Reset(CN64System * System)
|
2013-01-03 08:51:00 +00:00
|
|
|
{
|
2015-12-14 10:51:33 +00:00
|
|
|
WriteTrace(TracePlugins, TraceDebug, "Start");
|
2015-11-15 20:10:01 +00:00
|
|
|
|
|
|
|
bool bGfxChange = _stricmp(m_GfxFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_Gfx).c_str()) != 0;
|
|
|
|
bool bAudioChange = _stricmp(m_AudioFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_Audio).c_str()) != 0;
|
|
|
|
bool bRspChange = _stricmp(m_RSPFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_RSP).c_str()) != 0;
|
|
|
|
bool bContChange = _stricmp(m_ControlFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_Controller).c_str()) != 0;
|
|
|
|
|
|
|
|
//if GFX and Audio has changed we also need to force reset of RSP
|
|
|
|
if (bGfxChange || bAudioChange)
|
|
|
|
bRspChange = true;
|
|
|
|
|
|
|
|
if (bGfxChange) { DestroyGfxPlugin(); }
|
|
|
|
if (bAudioChange) { DestroyAudioPlugin(); }
|
|
|
|
if (bRspChange) { DestroyRspPlugin(); }
|
|
|
|
if (bContChange) { DestroyControlPlugin(); }
|
|
|
|
|
|
|
|
CreatePlugins();
|
|
|
|
|
|
|
|
if (m_Gfx && bGfxChange)
|
|
|
|
{
|
2015-12-14 10:51:33 +00:00
|
|
|
WriteTrace(TraceGFXPlugin, TraceDebug, "Gfx Initiate Starting");
|
2016-01-17 18:48:19 +00:00
|
|
|
if (!m_Gfx->Initiate(System, m_MainWindow)) { return false; }
|
2015-12-14 10:51:33 +00:00
|
|
|
WriteTrace(TraceGFXPlugin, TraceDebug, "Gfx Initiate Done");
|
2015-11-15 20:10:01 +00:00
|
|
|
}
|
|
|
|
if (m_Audio && bAudioChange)
|
|
|
|
{
|
2015-12-14 10:51:33 +00:00
|
|
|
WriteTrace(TraceAudioPlugin, TraceDebug, "Audio Initiate Starting");
|
2015-11-15 20:10:01 +00:00
|
|
|
if (!m_Audio->Initiate(System, m_MainWindow)) { return false; }
|
2015-12-14 10:51:33 +00:00
|
|
|
WriteTrace(TraceAudioPlugin, TraceDebug, "Audio Initiate Done");
|
2015-11-15 20:10:01 +00:00
|
|
|
}
|
|
|
|
if (m_Control && bContChange)
|
|
|
|
{
|
2015-12-14 10:51:33 +00:00
|
|
|
WriteTrace(TraceControllerPlugin, TraceDebug, "Control Initiate Starting");
|
2015-11-15 20:10:01 +00:00
|
|
|
if (!m_Control->Initiate(System, m_MainWindow)) { return false; }
|
2015-12-14 10:51:33 +00:00
|
|
|
WriteTrace(TraceControllerPlugin, TraceDebug, "Control Initiate Done");
|
2015-11-15 20:10:01 +00:00
|
|
|
}
|
|
|
|
if (m_RSP && bRspChange)
|
|
|
|
{
|
2015-12-14 10:51:33 +00:00
|
|
|
WriteTrace(TraceRSPPlugin, TraceDebug, "RSP Initiate Starting");
|
2016-01-17 18:48:19 +00:00
|
|
|
if (!m_RSP->Initiate(this, System)) { return false; }
|
2015-12-14 10:51:33 +00:00
|
|
|
WriteTrace(TraceRSPPlugin, TraceDebug, "RSP Initiate Done");
|
2015-11-15 20:10:01 +00:00
|
|
|
}
|
2015-12-14 10:51:33 +00:00
|
|
|
WriteTrace(TracePlugins, TraceDebug, "Done");
|
2015-11-15 20:10:01 +00:00
|
|
|
return true;
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
2015-11-13 02:52:34 +00:00
|
|
|
void CPlugins::ConfigPlugin(void* hParent, PLUGIN_TYPE Type)
|
2015-11-08 06:08:15 +00:00
|
|
|
{
|
2015-11-15 20:10:01 +00:00
|
|
|
switch (Type)
|
|
|
|
{
|
|
|
|
case PLUGIN_TYPE_RSP:
|
|
|
|
if (m_RSP == NULL || m_RSP->DllConfig == NULL) { break; }
|
|
|
|
if (!m_RSP->Initialized())
|
|
|
|
{
|
2015-11-15 20:13:09 +00:00
|
|
|
if (!m_RSP->Initiate(this, NULL))
|
2015-11-15 20:10:01 +00:00
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m_RSP->DllConfig(hParent);
|
|
|
|
break;
|
|
|
|
case PLUGIN_TYPE_GFX:
|
|
|
|
if (m_Gfx == NULL || m_Gfx->DllConfig == NULL) { break; }
|
|
|
|
if (!m_Gfx->Initialized())
|
|
|
|
{
|
2015-11-15 20:13:09 +00:00
|
|
|
if (!m_Gfx->Initiate(NULL, m_MainWindow))
|
2015-11-15 20:10:01 +00:00
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m_Gfx->DllConfig(hParent);
|
|
|
|
break;
|
|
|
|
case PLUGIN_TYPE_AUDIO:
|
|
|
|
if (m_Audio == NULL || m_Audio->DllConfig == NULL) { break; }
|
|
|
|
if (!m_Audio->Initialized())
|
|
|
|
{
|
2015-11-15 20:13:09 +00:00
|
|
|
if (!m_Audio->Initiate(NULL, m_MainWindow))
|
2015-11-15 20:10:01 +00:00
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m_Audio->DllConfig(hParent);
|
|
|
|
break;
|
|
|
|
case PLUGIN_TYPE_CONTROLLER:
|
|
|
|
if (m_Control == NULL || m_Control->DllConfig == NULL) { break; }
|
|
|
|
if (!m_Control->Initialized())
|
|
|
|
{
|
2015-11-15 20:13:09 +00:00
|
|
|
if (!m_Control->Initiate(NULL, m_MainWindow))
|
2015-11-15 20:10:01 +00:00
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m_Control->DllConfig(hParent);
|
|
|
|
break;
|
|
|
|
}
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
2015-11-08 06:08:15 +00:00
|
|
|
void DummyCheckInterrupts(void)
|
|
|
|
{
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
2015-11-08 06:08:15 +00:00
|
|
|
void DummyFunction(void)
|
|
|
|
{
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
|
2015-11-08 06:08:15 +00:00
|
|
|
bool CPlugins::CopyPlugins(const stdstr & DstDir) const
|
|
|
|
{
|
2015-11-15 20:10:01 +00:00
|
|
|
//Copy GFX Plugin
|
|
|
|
CPath srcGfxPlugin(m_PluginDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Gfx).c_str());
|
|
|
|
CPath dstGfxPlugin(DstDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Gfx).c_str());
|
|
|
|
|
|
|
|
if (!dstGfxPlugin.DirectoryExists())
|
|
|
|
{
|
|
|
|
dstGfxPlugin.DirectoryCreate();
|
|
|
|
}
|
|
|
|
if (!srcGfxPlugin.CopyTo(dstGfxPlugin))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Copy m_Audio Plugin
|
|
|
|
CPath srcAudioPlugin(m_PluginDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Audio).c_str());
|
|
|
|
CPath dstAudioPlugin(DstDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Audio).c_str());
|
|
|
|
if (!dstAudioPlugin.DirectoryExists())
|
|
|
|
{
|
|
|
|
dstAudioPlugin.DirectoryCreate();
|
|
|
|
}
|
|
|
|
if (!srcAudioPlugin.CopyTo(dstAudioPlugin))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Copy RSP Plugin
|
|
|
|
CPath srcRSPPlugin(m_PluginDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_RSP).c_str());
|
|
|
|
CPath dstRSPPlugin(DstDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_RSP).c_str());
|
|
|
|
if (!dstRSPPlugin.DirectoryExists())
|
|
|
|
{
|
|
|
|
dstRSPPlugin.DirectoryCreate();
|
|
|
|
}
|
|
|
|
if (!srcRSPPlugin.CopyTo(dstRSPPlugin))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Copy Controller Plugin
|
|
|
|
CPath srcContPlugin(m_PluginDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Controller).c_str());
|
|
|
|
CPath dstContPlugin(DstDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Controller).c_str());
|
|
|
|
if (!dstContPlugin.DirectoryExists())
|
|
|
|
{
|
|
|
|
dstContPlugin.DirectoryCreate();
|
|
|
|
}
|
|
|
|
if (!srcContPlugin.CopyTo(dstContPlugin))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|