[Project64] Add plugin to get notification of settings change
This commit is contained in:
parent
f19fb532a4
commit
3889ebf37d
|
@ -247,7 +247,7 @@ bool AppInit(CNotification * Notify, const char * BaseDirectory, int argc, char
|
|||
|
||||
//Create the plugin container
|
||||
WriteTrace(TraceAppInit, TraceInfo, "Create Plugins");
|
||||
g_Plugins = new CPlugins(Directory_Plugin);
|
||||
g_Plugins = new CPlugins(Directory_Plugin, false);
|
||||
|
||||
g_Lang = new CLanguage();
|
||||
g_Lang->LoadCurrentStrings();
|
||||
|
|
|
@ -87,7 +87,7 @@ CN64System::CN64System(CPlugins * Plugins, bool SavesReadOnly, bool SyncSystem)
|
|||
}
|
||||
g_Notify->DisplayMessage(5, "Copy Plugins");
|
||||
g_Plugins->CopyPlugins(g_Settings->LoadStringVal(Directory_PluginSync));
|
||||
m_SyncPlugins = new CPlugins(Directory_PluginSync);
|
||||
m_SyncPlugins = new CPlugins(Directory_PluginSync, true);
|
||||
m_SyncPlugins->SetRenderWindows(g_Plugins->SyncWindow(), NULL);
|
||||
m_SyncCPU = new CN64System(m_SyncPlugins, true, true);
|
||||
}
|
||||
|
|
|
@ -129,17 +129,20 @@ bool CAudioPlugin::Initiate(CN64System * System, RenderWindow * Window)
|
|||
// Send initialization information to the DLL
|
||||
else
|
||||
{
|
||||
CMipsMemoryVM & MMU = System->m_MMU_VM;
|
||||
CRegisters & Reg = System->m_Reg;
|
||||
|
||||
Info.HEADER = g_Rom->GetRomAddress();
|
||||
Info.RDRAM = g_MMU->Rdram();
|
||||
Info.DMEM = g_MMU->Dmem();
|
||||
Info.IMEM = g_MMU->Imem();
|
||||
Info.MI__INTR_REG = &g_Reg->m_AudioIntrReg;
|
||||
Info.AI__DRAM_ADDR_REG = &g_Reg->AI_DRAM_ADDR_REG;
|
||||
Info.AI__LEN_REG = &g_Reg->AI_LEN_REG;
|
||||
Info.AI__CONTROL_REG = &g_Reg->AI_CONTROL_REG;
|
||||
Info.AI__STATUS_REG = &g_Reg->AI_STATUS_REG;
|
||||
Info.AI__DACRATE_REG = &g_Reg->AI_DACRATE_REG;
|
||||
Info.AI__BITRATE_REG = &g_Reg->AI_BITRATE_REG;
|
||||
Info.RDRAM = MMU.Rdram();
|
||||
Info.DMEM = MMU.Dmem();
|
||||
Info.IMEM = MMU.Imem();
|
||||
Info.MI__INTR_REG = &Reg.m_AudioIntrReg;
|
||||
Info.AI__DRAM_ADDR_REG = &Reg.AI_DRAM_ADDR_REG;
|
||||
Info.AI__LEN_REG = &Reg.AI_LEN_REG;
|
||||
Info.AI__CONTROL_REG = &Reg.AI_CONTROL_REG;
|
||||
Info.AI__STATUS_REG = &Reg.AI_STATUS_REG;
|
||||
Info.AI__DACRATE_REG = &Reg.AI_DACRATE_REG;
|
||||
Info.AI__BITRATE_REG = &Reg.AI_BITRATE_REG;
|
||||
}
|
||||
|
||||
m_Initialized = InitiateAudio(Info) != 0;
|
||||
|
@ -161,7 +164,7 @@ bool CAudioPlugin::Initiate(CN64System * System, RenderWindow * Window)
|
|||
m_hAudioThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)AudioThread, (LPVOID)this, 0, &ThreadID);
|
||||
}
|
||||
|
||||
if (g_Reg->AI_DACRATE_REG != 0)
|
||||
if (System->m_Reg.AI_DACRATE_REG != 0)
|
||||
{
|
||||
DacrateChanged(System->SystemType());
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <Project64-core/N64System/N64RomClass.h>
|
||||
#include <Project64-core/N64System/Mips/MemoryVirtualMem.h>
|
||||
#include <Project64-core/N64System/Mips/RegisterClass.h>
|
||||
#include <Project64-core/N64System/N64Class.h>
|
||||
#include "GFXPlugin.h"
|
||||
|
||||
CGfxPlugin::CGfxPlugin() :
|
||||
|
@ -181,7 +182,7 @@ bool CGfxPlugin::Initiate(CN64System * System, RenderWindow * Window)
|
|||
#ifdef _WIN32
|
||||
if (Window != NULL)
|
||||
{
|
||||
Info.hWnd = Window->GetWindowHandle();
|
||||
Info.hWnd = Window->GetWindowHandle();
|
||||
Info.hStatusBar = Window->GetStatusBar();
|
||||
}
|
||||
#endif
|
||||
|
@ -189,7 +190,7 @@ bool CGfxPlugin::Initiate(CN64System * System, RenderWindow * Window)
|
|||
|
||||
// We are initializing the plugin before any rom is loaded so we do not have any correct
|
||||
// parameters here.. it's just needed so we can config the DLL.
|
||||
WriteTrace(TraceGFXPlugin, TraceDebug, "System = %X",System);
|
||||
WriteTrace(TraceGFXPlugin, TraceDebug, "System = %X", System);
|
||||
if (System == NULL)
|
||||
{
|
||||
static uint8_t Buffer[100];
|
||||
|
@ -218,33 +219,36 @@ bool CGfxPlugin::Initiate(CN64System * System, RenderWindow * Window)
|
|||
// Send initialization information to the DLL
|
||||
else
|
||||
{
|
||||
CMipsMemoryVM & MMU = System->m_MMU_VM;
|
||||
CRegisters & Reg = System->m_Reg;
|
||||
|
||||
Info.HEADER = g_Rom->GetRomAddress();
|
||||
Info.RDRAM = g_MMU->Rdram();
|
||||
Info.DMEM = g_MMU->Dmem();
|
||||
Info.IMEM = g_MMU->Imem();
|
||||
Info.MI__INTR_REG = &g_Reg->m_GfxIntrReg;
|
||||
Info.DPC__START_REG = &g_Reg->DPC_START_REG;
|
||||
Info.DPC__END_REG = &g_Reg->DPC_END_REG;
|
||||
Info.DPC__CURRENT_REG = &g_Reg->DPC_CURRENT_REG;
|
||||
Info.DPC__STATUS_REG = &g_Reg->DPC_STATUS_REG;
|
||||
Info.DPC__CLOCK_REG = &g_Reg->DPC_CLOCK_REG;
|
||||
Info.DPC__BUFBUSY_REG = &g_Reg->DPC_BUFBUSY_REG;
|
||||
Info.DPC__PIPEBUSY_REG = &g_Reg->DPC_PIPEBUSY_REG;
|
||||
Info.DPC__TMEM_REG = &g_Reg->DPC_TMEM_REG;
|
||||
Info.VI__STATUS_REG = &g_Reg->VI_STATUS_REG;
|
||||
Info.VI__ORIGIN_REG = &g_Reg->VI_ORIGIN_REG;
|
||||
Info.VI__WIDTH_REG = &g_Reg->VI_WIDTH_REG;
|
||||
Info.VI__INTR_REG = &g_Reg->VI_INTR_REG;
|
||||
Info.VI__V_CURRENT_LINE_REG = &g_Reg->VI_CURRENT_REG;
|
||||
Info.VI__TIMING_REG = &g_Reg->VI_TIMING_REG;
|
||||
Info.VI__V_SYNC_REG = &g_Reg->VI_V_SYNC_REG;
|
||||
Info.VI__H_SYNC_REG = &g_Reg->VI_H_SYNC_REG;
|
||||
Info.VI__LEAP_REG = &g_Reg->VI_LEAP_REG;
|
||||
Info.VI__H_START_REG = &g_Reg->VI_H_START_REG;
|
||||
Info.VI__V_START_REG = &g_Reg->VI_V_START_REG;
|
||||
Info.VI__V_BURST_REG = &g_Reg->VI_V_BURST_REG;
|
||||
Info.VI__X_SCALE_REG = &g_Reg->VI_X_SCALE_REG;
|
||||
Info.VI__Y_SCALE_REG = &g_Reg->VI_Y_SCALE_REG;
|
||||
Info.RDRAM = MMU.Rdram();
|
||||
Info.DMEM = MMU.Dmem();
|
||||
Info.IMEM = MMU.Imem();
|
||||
Info.MI__INTR_REG = &Reg.m_GfxIntrReg;
|
||||
Info.DPC__START_REG = &Reg.DPC_START_REG;
|
||||
Info.DPC__END_REG = &Reg.DPC_END_REG;
|
||||
Info.DPC__CURRENT_REG = &Reg.DPC_CURRENT_REG;
|
||||
Info.DPC__STATUS_REG = &Reg.DPC_STATUS_REG;
|
||||
Info.DPC__CLOCK_REG = &Reg.DPC_CLOCK_REG;
|
||||
Info.DPC__BUFBUSY_REG = &Reg.DPC_BUFBUSY_REG;
|
||||
Info.DPC__PIPEBUSY_REG = &Reg.DPC_PIPEBUSY_REG;
|
||||
Info.DPC__TMEM_REG = &Reg.DPC_TMEM_REG;
|
||||
Info.VI__STATUS_REG = &Reg.VI_STATUS_REG;
|
||||
Info.VI__ORIGIN_REG = &Reg.VI_ORIGIN_REG;
|
||||
Info.VI__WIDTH_REG = &Reg.VI_WIDTH_REG;
|
||||
Info.VI__INTR_REG = &Reg.VI_INTR_REG;
|
||||
Info.VI__V_CURRENT_LINE_REG = &Reg.VI_CURRENT_REG;
|
||||
Info.VI__TIMING_REG = &Reg.VI_TIMING_REG;
|
||||
Info.VI__V_SYNC_REG = &Reg.VI_V_SYNC_REG;
|
||||
Info.VI__H_SYNC_REG = &Reg.VI_H_SYNC_REG;
|
||||
Info.VI__LEAP_REG = &Reg.VI_LEAP_REG;
|
||||
Info.VI__H_START_REG = &Reg.VI_H_START_REG;
|
||||
Info.VI__V_START_REG = &Reg.VI_V_START_REG;
|
||||
Info.VI__V_BURST_REG = &Reg.VI_V_BURST_REG;
|
||||
Info.VI__X_SCALE_REG = &Reg.VI_X_SCALE_REG;
|
||||
Info.VI__Y_SCALE_REG = &Reg.VI_Y_SCALE_REG;
|
||||
}
|
||||
|
||||
WriteTrace(TraceGFXPlugin, TraceDebug, "Calling InitiateGFX");
|
||||
|
|
|
@ -38,7 +38,7 @@ CPlugin::~CPlugin()
|
|||
|
||||
bool CPlugin::Load(const char * FileName)
|
||||
{
|
||||
WriteTrace(PluginTraceType(), TraceDebug, "Loading: %s",FileName);
|
||||
WriteTrace(PluginTraceType(), TraceDebug, "Loading: %s", FileName);
|
||||
|
||||
// Already loaded, so unload first.
|
||||
if (m_LibHandle != NULL)
|
||||
|
@ -49,6 +49,8 @@ bool CPlugin::Load(const char * FileName)
|
|||
// Try to load the plugin DLL
|
||||
//Try to load the DLL library
|
||||
m_LibHandle = pjutil::DynLibOpen(FileName, bHaveDebugger());
|
||||
WriteTrace(PluginTraceType(), TraceDebug, "Loaded: %s LibHandle: %X", FileName, m_LibHandle);
|
||||
|
||||
if (m_LibHandle == NULL)
|
||||
{
|
||||
return false;
|
||||
|
@ -70,6 +72,16 @@ bool CPlugin::Load(const char * FileName)
|
|||
LoadFunction(DllConfig);
|
||||
LoadFunction(DllAbout);
|
||||
|
||||
LoadFunction(SetSettingNotificationInfo);
|
||||
if (SetSettingNotificationInfo)
|
||||
{
|
||||
WriteTrace(PluginTraceType(), TraceDebug, "Found SetSettingNotificationInfo");
|
||||
PLUGIN_SETTINGS_NOTIFICATION info;
|
||||
info.RegisterChangeCB = (void(*)(void *, int ID, void * Data, PLUGIN_SETTINGS_NOTIFICATION::SettingChangedFunc Func))CSettings::sRegisterChangeCB;
|
||||
info.UnregisterChangeCB = (void(*)(void *, int ID, void * Data, PLUGIN_SETTINGS_NOTIFICATION::SettingChangedFunc Func))CSettings::sUnregisterChangeCB;
|
||||
SetSettingNotificationInfo(&info);
|
||||
}
|
||||
|
||||
LoadFunction(SetSettingInfo3);
|
||||
if (SetSettingInfo3)
|
||||
{
|
||||
|
@ -260,7 +272,7 @@ TraceModuleProject64 CPlugin::PluginTraceType() const
|
|||
case PLUGIN_TYPE_AUDIO: return TraceAudioPlugin;
|
||||
case PLUGIN_TYPE_CONTROLLER: return TraceControllerPlugin;
|
||||
}
|
||||
return TraceUnknown;
|
||||
return TracePlugins;
|
||||
}
|
||||
|
||||
bool CPlugin::ValidPluginVersion(PLUGIN_INFO & PluginInfo)
|
||||
|
|
|
@ -57,9 +57,10 @@ protected:
|
|||
void(CALL *RomOpen) (void);
|
||||
void(CALL *RomClosed) (void);
|
||||
void(CALL *PluginOpened)(void);
|
||||
void(CALL *SetSettingInfo) (PLUGIN_SETTINGS *);
|
||||
void(CALL *SetSettingInfo2) (PLUGIN_SETTINGS2 *);
|
||||
void(CALL *SetSettingInfo3) (PLUGIN_SETTINGS3 *);
|
||||
void(CALL *SetSettingInfo)(PLUGIN_SETTINGS *);
|
||||
void(CALL *SetSettingInfo2)(PLUGIN_SETTINGS2 *);
|
||||
void(CALL *SetSettingInfo3)(PLUGIN_SETTINGS3 *);
|
||||
void(CALL *SetSettingNotificationInfo)(PLUGIN_SETTINGS_NOTIFICATION *);
|
||||
|
||||
pjutil::DynLibHandle m_LibHandle;
|
||||
bool m_Initialized, m_RomOpen;
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include <Project64-core/Plugins/PluginClass.h>
|
||||
#include <Common/path.h>
|
||||
|
||||
CPlugins::CPlugins(SettingID PluginDirSetting) :
|
||||
CPlugins::CPlugins(SettingID PluginDirSetting, bool SyncPlugins) :
|
||||
m_MainWindow(NULL),
|
||||
m_SyncWindow(NULL),
|
||||
m_PluginDirSetting(PluginDirSetting),
|
||||
|
@ -23,7 +23,8 @@ m_Gfx(NULL),
|
|||
m_Audio(NULL),
|
||||
m_RSP(NULL),
|
||||
m_Control(NULL),
|
||||
m_initilized(false)
|
||||
m_initilized(false),
|
||||
m_SyncPlugins(SyncPlugins)
|
||||
{
|
||||
CreatePlugins();
|
||||
g_Settings->RegisterChangeCB(Plugin_RSP_Current, this, (CSettings::SettingChangedFunc)PluginChanged);
|
||||
|
@ -73,11 +74,11 @@ void CPlugins::PluginChanged(CPlugins * _this)
|
|||
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;
|
||||
bool bDirChange = _stricmp(_this->m_PluginDir.c_str(), g_Settings->LoadStringVal(_this->m_PluginDirSetting).c_str()) != 0;
|
||||
WriteTrace(TracePlugins, TraceVerbose, "m_GfxFile: \"%s\" Game_Plugin_Gfx: \"%s\" changed: %s",_this->m_GfxFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_Gfx).c_str(), bGfxChange ? "true" : "false");
|
||||
WriteTrace(TracePlugins, TraceVerbose, "m_AudioFile: \"%s\" Game_Plugin_Audio: \"%s\" changed: %s",_this->m_GfxFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_Gfx).c_str(), bAudioChange ? "true" : "false");
|
||||
WriteTrace(TracePlugins, TraceVerbose, "m_RSPFile: \"%s\" Game_Plugin_RSP: \"%s\" changed: %s",_this->m_GfxFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_Gfx).c_str(), bRspChange ? "true" : "false");
|
||||
WriteTrace(TracePlugins, TraceVerbose, "m_ControlFile: \"%s\" Game_Plugin_Controller: \"%s\" changed: %s",_this->m_GfxFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_Gfx).c_str(), bContChange ? "true" : "false");
|
||||
WriteTrace(TracePlugins, TraceVerbose, "m_PluginDir: \"%s\" m_PluginDirSetting: \"%s\" changed: %s",_this->m_PluginDir.c_str(), g_Settings->LoadStringVal(_this->m_PluginDirSetting).c_str(), bDirChange ? "true" : "false");
|
||||
WriteTrace(TracePlugins, TraceVerbose, "m_GfxFile: \"%s\" Game_Plugin_Gfx: \"%s\" changed: %s", _this->m_GfxFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_Gfx).c_str(), bGfxChange ? "true" : "false");
|
||||
WriteTrace(TracePlugins, TraceVerbose, "m_AudioFile: \"%s\" Game_Plugin_Audio: \"%s\" changed: %s", _this->m_GfxFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_Gfx).c_str(), bAudioChange ? "true" : "false");
|
||||
WriteTrace(TracePlugins, TraceVerbose, "m_RSPFile: \"%s\" Game_Plugin_RSP: \"%s\" changed: %s", _this->m_GfxFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_Gfx).c_str(), bRspChange ? "true" : "false");
|
||||
WriteTrace(TracePlugins, TraceVerbose, "m_ControlFile: \"%s\" Game_Plugin_Controller: \"%s\" changed: %s", _this->m_GfxFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_Gfx).c_str(), bContChange ? "true" : "false");
|
||||
WriteTrace(TracePlugins, TraceVerbose, "m_PluginDir: \"%s\" m_PluginDirSetting: \"%s\" changed: %s", _this->m_PluginDir.c_str(), g_Settings->LoadStringVal(_this->m_PluginDirSetting).c_str(), bDirChange ? "true" : "false");
|
||||
if (bDirChange)
|
||||
{
|
||||
WriteTrace(TracePlugins, TraceDebug, "plugin directory changed");
|
||||
|
@ -111,7 +112,7 @@ void CPlugins::PluginChanged(CPlugins * _this)
|
|||
}
|
||||
|
||||
template <typename plugin_type>
|
||||
static void LoadPlugin(SettingID PluginSettingID, SettingID PluginVerSettingID, plugin_type * & plugin, const char * PluginDir, stdstr & FileName, TraceModuleProject64 TraceLevel, const char * type)
|
||||
static void LoadPlugin(SettingID PluginSettingID, SettingID PluginVerSettingID, plugin_type * & plugin, const char * PluginDir, stdstr & FileName, TraceModuleProject64 TraceLevel, const char * type, bool IsCopy)
|
||||
{
|
||||
if (plugin != NULL)
|
||||
{
|
||||
|
@ -119,6 +120,10 @@ static void LoadPlugin(SettingID PluginSettingID, SettingID PluginVerSettingID,
|
|||
}
|
||||
FileName = g_Settings->LoadStringVal(PluginSettingID);
|
||||
CPath PluginFileName(PluginDir, FileName.c_str());
|
||||
if (IsCopy)
|
||||
{
|
||||
PluginFileName.SetName(stdstr_f("%s-copy", PluginFileName.GetName().c_str()).c_str());
|
||||
}
|
||||
plugin = new plugin_type();
|
||||
if (plugin)
|
||||
{
|
||||
|
@ -145,11 +150,11 @@ static void LoadPlugin(SettingID PluginSettingID, SettingID PluginVerSettingID,
|
|||
void CPlugins::CreatePlugins(void)
|
||||
{
|
||||
WriteTrace(TracePlugins, TraceInfo, "Start");
|
||||
|
||||
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");
|
||||
|
||||
LoadPlugin(Game_Plugin_Gfx, Plugin_GFX_CurVer, m_Gfx, m_PluginDir.c_str(), m_GfxFile, TraceGFXPlugin, "GFX", m_SyncPlugins);
|
||||
LoadPlugin(Game_Plugin_Audio, Plugin_AUDIO_CurVer, m_Audio, m_PluginDir.c_str(), m_AudioFile, TraceAudioPlugin, "Audio", m_SyncPlugins);
|
||||
LoadPlugin(Game_Plugin_RSP, Plugin_RSP_CurVer, m_RSP, m_PluginDir.c_str(), m_RSPFile, TraceRSPPlugin, "RSP", m_SyncPlugins);
|
||||
LoadPlugin(Game_Plugin_Controller, Plugin_CONT_CurVer, m_Control, m_PluginDir.c_str(), m_ControlFile, TraceControllerPlugin, "Control", m_SyncPlugins);
|
||||
|
||||
//Enable debugger
|
||||
if (m_RSP != NULL && m_RSP->EnableDebugging)
|
||||
|
@ -246,14 +251,14 @@ void CPlugins::DestroyControlPlugin(void)
|
|||
|
||||
void CPlugins::SetRenderWindows(RenderWindow * MainWindow, RenderWindow * SyncWindow)
|
||||
{
|
||||
WriteTrace(TracePlugins, TraceDebug, "MainWindow = %p SyncWindow = %p",MainWindow,SyncWindow);
|
||||
WriteTrace(TracePlugins, TraceDebug, "MainWindow = %p SyncWindow = %p", MainWindow, SyncWindow);
|
||||
m_MainWindow = MainWindow;
|
||||
m_SyncWindow = SyncWindow;
|
||||
}
|
||||
|
||||
void CPlugins::RomOpened(void)
|
||||
{
|
||||
WriteTrace(TracePlugins, TraceDebug, "Start");
|
||||
WriteTrace(TracePlugins, TraceDebug, "Start");
|
||||
|
||||
m_Gfx->RomOpened(m_MainWindow);
|
||||
m_RSP->RomOpened(m_MainWindow);
|
||||
|
@ -265,7 +270,7 @@ void CPlugins::RomOpened(void)
|
|||
|
||||
void CPlugins::RomClosed(void)
|
||||
{
|
||||
WriteTrace(TracePlugins, TraceDebug, "Start");
|
||||
WriteTrace(TracePlugins, TraceDebug, "Start");
|
||||
|
||||
m_Gfx->RomClose(m_MainWindow);
|
||||
m_RSP->RomClose(m_MainWindow);
|
||||
|
@ -427,6 +432,7 @@ bool CPlugins::CopyPlugins(const stdstr & DstDir) const
|
|||
//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());
|
||||
dstGfxPlugin.SetName(stdstr_f("%s-copy", dstGfxPlugin.GetName().c_str()).c_str());
|
||||
|
||||
if (!dstGfxPlugin.DirectoryExists())
|
||||
{
|
||||
|
@ -434,12 +440,14 @@ bool CPlugins::CopyPlugins(const stdstr & DstDir) const
|
|||
}
|
||||
if (!srcGfxPlugin.CopyTo(dstGfxPlugin))
|
||||
{
|
||||
WriteTrace(TracePlugins, TraceError, "failed to copy %s to %s", (const char *)srcGfxPlugin, (const char *)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());
|
||||
dstAudioPlugin.SetName(stdstr_f("%s-copy", dstAudioPlugin.GetName().c_str()).c_str());
|
||||
if (!dstAudioPlugin.DirectoryExists())
|
||||
{
|
||||
dstAudioPlugin.DirectoryCreate();
|
||||
|
@ -448,10 +456,10 @@ bool CPlugins::CopyPlugins(const stdstr & DstDir) const
|
|||
{
|
||||
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());
|
||||
dstRSPPlugin.SetName(stdstr_f("%s-copy", dstRSPPlugin.GetName().c_str()).c_str());
|
||||
if (!dstRSPPlugin.DirectoryExists())
|
||||
{
|
||||
dstRSPPlugin.DirectoryCreate();
|
||||
|
@ -464,6 +472,7 @@ bool CPlugins::CopyPlugins(const stdstr & DstDir) const
|
|||
//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());
|
||||
dstContPlugin.SetName(stdstr_f("%s-copy", dstContPlugin.GetName().c_str()).c_str());
|
||||
if (!dstContPlugin.DirectoryExists())
|
||||
{
|
||||
dstContPlugin.DirectoryCreate();
|
||||
|
|
|
@ -72,6 +72,14 @@ typedef struct
|
|||
void(*FlushSettings) (void * handle);
|
||||
} PLUGIN_SETTINGS3;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef void(*SettingChangedFunc)(void *);
|
||||
|
||||
void(*RegisterChangeCB)(void * handle, int ID, void * Data, SettingChangedFunc Func);
|
||||
void(*UnregisterChangeCB)(void * handle, int ID, void * Data, SettingChangedFunc Func);
|
||||
} PLUGIN_SETTINGS_NOTIFICATION;
|
||||
|
||||
enum PLUGIN_TYPE
|
||||
{
|
||||
PLUGIN_TYPE_NONE = 0,
|
||||
|
@ -111,7 +119,7 @@ class CPlugins :
|
|||
{
|
||||
public:
|
||||
//Functions
|
||||
CPlugins(SettingID PluginDirSetting);
|
||||
CPlugins(SettingID PluginDirSetting, bool SyncPlugins);
|
||||
~CPlugins();
|
||||
|
||||
bool Initiate(CN64System * System);
|
||||
|
@ -133,7 +141,7 @@ public:
|
|||
inline RenderWindow * MainWindow(void) const { return m_MainWindow; }
|
||||
inline RenderWindow * SyncWindow(void) const { return m_SyncWindow; }
|
||||
|
||||
inline bool initilized ( void ) const { return m_initilized; }
|
||||
inline bool initilized(void) const { return m_initilized; }
|
||||
|
||||
private:
|
||||
CPlugins(void); // Disable default constructor
|
||||
|
@ -164,6 +172,7 @@ private:
|
|||
stdstr m_RSPFile;
|
||||
stdstr m_ControlFile;
|
||||
bool m_initilized;
|
||||
bool m_SyncPlugins;
|
||||
};
|
||||
|
||||
//Dummy Functions
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <Project64-core/N64System/SystemGlobals.h>
|
||||
#include <Project64-core/N64System/Mips/MemoryVirtualMem.h>
|
||||
#include <Project64-core/N64System/Mips/RegisterClass.h>
|
||||
#include <Project64-core/N64System/N64Class.h>
|
||||
#include "RSPPlugin.h"
|
||||
#include "GFXPlugin.h"
|
||||
#include <Project64-core/Plugins/AudioPlugin.h>
|
||||
|
@ -69,8 +70,8 @@ bool CRSP_Plugin::Initiate(CPlugins * Plugins, CN64System * System)
|
|||
WriteTrace(TraceRSPPlugin, TraceDebug, "Starting");
|
||||
if (m_PluginInfo.Version == 1 || m_PluginInfo.Version == 0x100)
|
||||
{
|
||||
WriteTrace(TraceRSPPlugin, TraceDebug, "Invalid Version: %X",m_PluginInfo.Version);
|
||||
WriteTrace(TraceRSPPlugin, TraceDebug, "Done (res: false)");
|
||||
WriteTrace(TraceRSPPlugin, TraceDebug, "Invalid Version: %X", m_PluginInfo.Version);
|
||||
WriteTrace(TraceRSPPlugin, TraceDebug, "Done (res: false)");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -120,16 +121,16 @@ bool CRSP_Plugin::Initiate(CPlugins * Plugins, CN64System * System)
|
|||
#endif
|
||||
Info.CheckInterrupts = DummyCheckInterrupts;
|
||||
Info.MemoryBswaped = (System == NULL); // only true when the system's not yet loaded
|
||||
|
||||
|
||||
//Get Function from DLL
|
||||
void(CALL *InitiateRSP) (RSP_INFO_1_1 Audio_Info, uint32_t * Cycles);
|
||||
LoadFunction(InitiateRSP);
|
||||
if (InitiateRSP == NULL)
|
||||
{
|
||||
WriteTrace(TraceRSPPlugin, TraceDebug, "Failed to find InitiateRSP");
|
||||
WriteTrace(TraceRSPPlugin, TraceDebug, "Done (res: false)");
|
||||
return false;
|
||||
}
|
||||
{
|
||||
WriteTrace(TraceRSPPlugin, TraceDebug, "Failed to find InitiateRSP");
|
||||
WriteTrace(TraceRSPPlugin, TraceDebug, "Done (res: false)");
|
||||
return false;
|
||||
}
|
||||
|
||||
// We are initializing the plugin before any rom is loaded so we do not have any correct
|
||||
// parameters here.. just needed to we can config the DLL.
|
||||
|
@ -176,40 +177,43 @@ bool CRSP_Plugin::Initiate(CPlugins * Plugins, CN64System * System)
|
|||
Info.ShowCFB = Plugins->Gfx()->ShowCFB;
|
||||
Info.ProcessAlist = Plugins->Audio()->ProcessAList;
|
||||
|
||||
Info.RDRAM = g_MMU->Rdram();
|
||||
Info.DMEM = g_MMU->Dmem();
|
||||
Info.IMEM = g_MMU->Imem();
|
||||
CMipsMemoryVM & MMU = System->m_MMU_VM;
|
||||
CRegisters & Reg = System->m_Reg;
|
||||
|
||||
Info.MI__INTR_REG = &g_Reg->m_RspIntrReg;
|
||||
Info.RDRAM = MMU.Rdram();
|
||||
Info.DMEM = MMU.Dmem();
|
||||
Info.IMEM = MMU.Imem();
|
||||
|
||||
Info.SP__MEM_ADDR_REG = &g_Reg->SP_MEM_ADDR_REG;
|
||||
Info.SP__DRAM_ADDR_REG = &g_Reg->SP_DRAM_ADDR_REG;
|
||||
Info.SP__RD_LEN_REG = &g_Reg->SP_RD_LEN_REG;
|
||||
Info.SP__WR_LEN_REG = &g_Reg->SP_WR_LEN_REG;
|
||||
Info.SP__STATUS_REG = &g_Reg->SP_STATUS_REG;
|
||||
Info.SP__DMA_FULL_REG = &g_Reg->SP_DMA_FULL_REG;
|
||||
Info.SP__DMA_BUSY_REG = &g_Reg->SP_DMA_BUSY_REG;
|
||||
Info.SP__PC_REG = &g_Reg->SP_PC_REG;
|
||||
Info.SP__SEMAPHORE_REG = &g_Reg->SP_SEMAPHORE_REG;
|
||||
Info.MI__INTR_REG = &Reg.m_RspIntrReg;
|
||||
|
||||
Info.DPC__START_REG = &g_Reg->DPC_START_REG;
|
||||
Info.DPC__END_REG = &g_Reg->DPC_END_REG;
|
||||
Info.DPC__CURRENT_REG = &g_Reg->DPC_CURRENT_REG;
|
||||
Info.DPC__STATUS_REG = &g_Reg->DPC_STATUS_REG;
|
||||
Info.DPC__CLOCK_REG = &g_Reg->DPC_CLOCK_REG;
|
||||
Info.DPC__BUFBUSY_REG = &g_Reg->DPC_BUFBUSY_REG;
|
||||
Info.DPC__PIPEBUSY_REG = &g_Reg->DPC_PIPEBUSY_REG;
|
||||
Info.DPC__TMEM_REG = &g_Reg->DPC_TMEM_REG;
|
||||
Info.SP__MEM_ADDR_REG = &Reg.SP_MEM_ADDR_REG;
|
||||
Info.SP__DRAM_ADDR_REG = &Reg.SP_DRAM_ADDR_REG;
|
||||
Info.SP__RD_LEN_REG = &Reg.SP_RD_LEN_REG;
|
||||
Info.SP__WR_LEN_REG = &Reg.SP_WR_LEN_REG;
|
||||
Info.SP__STATUS_REG = &Reg.SP_STATUS_REG;
|
||||
Info.SP__DMA_FULL_REG = &Reg.SP_DMA_FULL_REG;
|
||||
Info.SP__DMA_BUSY_REG = &Reg.SP_DMA_BUSY_REG;
|
||||
Info.SP__PC_REG = &Reg.SP_PC_REG;
|
||||
Info.SP__SEMAPHORE_REG = &Reg.SP_SEMAPHORE_REG;
|
||||
|
||||
Info.DPC__START_REG = &Reg.DPC_START_REG;
|
||||
Info.DPC__END_REG = &Reg.DPC_END_REG;
|
||||
Info.DPC__CURRENT_REG = &Reg.DPC_CURRENT_REG;
|
||||
Info.DPC__STATUS_REG = &Reg.DPC_STATUS_REG;
|
||||
Info.DPC__CLOCK_REG = &Reg.DPC_CLOCK_REG;
|
||||
Info.DPC__BUFBUSY_REG = &Reg.DPC_BUFBUSY_REG;
|
||||
Info.DPC__PIPEBUSY_REG = &Reg.DPC_PIPEBUSY_REG;
|
||||
Info.DPC__TMEM_REG = &Reg.DPC_TMEM_REG;
|
||||
}
|
||||
|
||||
InitiateRSP(Info, &m_CycleCount);
|
||||
m_Initialized = true;
|
||||
|
||||
#ifdef _WIN32
|
||||
//jabo had a bug so I call CreateThread so his dllmain gets called again
|
||||
//jabo had a bug so I call CreateThread so his dllmain gets called again
|
||||
pjutil::DynLibCallDllMain();
|
||||
#endif
|
||||
WriteTrace(TraceRSPPlugin, TraceDebug, "Done (res: %s)",m_Initialized ? "true" : "false");
|
||||
WriteTrace(TraceRSPPlugin, TraceDebug, "Done (res: %s)", m_Initialized ? "true" : "false");
|
||||
return m_Initialized;
|
||||
}
|
||||
|
||||
|
|
|
@ -433,6 +433,16 @@ void CSettings::FlushSettings(CSettings * /*_this*/)
|
|||
CSettingTypeApplication::Flush();
|
||||
}
|
||||
|
||||
void CSettings::sRegisterChangeCB(CSettings * _this, SettingID Type, void * Data, SettingChangedFunc Func)
|
||||
{
|
||||
_this->RegisterChangeCB(Type, Data, Func);
|
||||
}
|
||||
|
||||
void CSettings::sUnregisterChangeCB(CSettings * _this, SettingID Type, void * Data, SettingChangedFunc Func)
|
||||
{
|
||||
_this->UnregisterChangeCB(Type, Data, Func);
|
||||
}
|
||||
|
||||
uint32_t CSettings::GetSetting(CSettings * _this, SettingID Type)
|
||||
{
|
||||
return _this->LoadDword(Type);
|
||||
|
@ -459,9 +469,12 @@ void CSettings::SetSettingSz(CSettings * _this, SettingID ID, const char * Value
|
|||
}
|
||||
|
||||
void CSettings::RegisterSetting(CSettings * _this, SettingID ID, SettingID DefaultID, SettingDataType DataType,
|
||||
SettingType Type, const char * Category, const char * DefaultStr,
|
||||
uint32_t Value)
|
||||
SettingType Type, const char * Category, const char * DefaultStr,
|
||||
uint32_t Value)
|
||||
{
|
||||
SettingID RdbSetting;
|
||||
stdstr Name;
|
||||
|
||||
switch (Type)
|
||||
{
|
||||
case SettingType_ConstValue:
|
||||
|
@ -509,47 +522,41 @@ void CSettings::RegisterSetting(CSettings * _this, SettingID ID, SettingID Defau
|
|||
}
|
||||
break;
|
||||
case SettingType_GameSetting:
|
||||
{
|
||||
stdstr_f Name("%s-%s", Category, DefaultStr);
|
||||
Name.Format("%s-%s", Category, DefaultStr);
|
||||
switch (DataType)
|
||||
{
|
||||
case Data_DWORD:
|
||||
RdbSetting = (SettingID)_this->m_NextAutoSettingId;
|
||||
_this->m_NextAutoSettingId += 1;
|
||||
if (DefaultID == Default_None)
|
||||
{
|
||||
SettingID RdbSetting = (SettingID)_this->m_NextAutoSettingId;
|
||||
_this->m_NextAutoSettingId += 1;
|
||||
if (DefaultID == Default_None)
|
||||
{
|
||||
_this->AddHandler(RdbSetting, new CSettingTypeRomDatabase(Name.c_str(), (int)Value));
|
||||
_this->AddHandler(ID, new CSettingTypeGame(Name.c_str(), RdbSetting));
|
||||
}
|
||||
else
|
||||
{
|
||||
_this->AddHandler(RdbSetting, new CSettingTypeRomDatabase(Name.c_str(), DefaultID));
|
||||
_this->AddHandler(ID, new CSettingTypeGame(Name.c_str(), RdbSetting));
|
||||
}
|
||||
_this->AddHandler(RdbSetting, new CSettingTypeRomDatabase(Name.c_str(), (int)Value));
|
||||
_this->AddHandler(ID, new CSettingTypeGame(Name.c_str(), RdbSetting));
|
||||
}
|
||||
else
|
||||
{
|
||||
_this->AddHandler(RdbSetting, new CSettingTypeRomDatabase(Name.c_str(), DefaultID));
|
||||
_this->AddHandler(ID, new CSettingTypeGame(Name.c_str(), RdbSetting));
|
||||
}
|
||||
break;
|
||||
case Data_String:
|
||||
RdbSetting = (SettingID)_this->m_NextAutoSettingId;
|
||||
_this->m_NextAutoSettingId += 1;
|
||||
if (DefaultID == Default_None)
|
||||
{
|
||||
SettingID RdbSetting = (SettingID)_this->m_NextAutoSettingId;
|
||||
_this->m_NextAutoSettingId += 1;
|
||||
if (DefaultID == Default_None)
|
||||
{
|
||||
_this->AddHandler(RdbSetting, new CSettingTypeRomDatabase(Name.c_str(), ""));
|
||||
_this->AddHandler(ID, new CSettingTypeGame(Name.c_str(), RdbSetting));
|
||||
}
|
||||
else
|
||||
{
|
||||
_this->AddHandler(RdbSetting, new CSettingTypeRomDatabase(Name.c_str(), DefaultID));
|
||||
_this->AddHandler(ID, new CSettingTypeGame(Name.c_str(), RdbSetting));
|
||||
}
|
||||
_this->AddHandler(RdbSetting, new CSettingTypeRomDatabase(Name.c_str(), ""));
|
||||
_this->AddHandler(ID, new CSettingTypeGame(Name.c_str(), RdbSetting));
|
||||
}
|
||||
else
|
||||
{
|
||||
_this->AddHandler(RdbSetting, new CSettingTypeRomDatabase(Name.c_str(), DefaultID));
|
||||
_this->AddHandler(ID, new CSettingTypeGame(Name.c_str(), RdbSetting));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case SettingType_RomDatabase:
|
||||
switch (DataType)
|
||||
{
|
||||
|
|
|
@ -94,13 +94,15 @@ public:
|
|||
// static functions for plugins
|
||||
static uint32_t GetSetting(CSettings * _this, SettingID Type);
|
||||
static const char * GetSettingSz(CSettings * _this, SettingID Type, char * Buffer, int32_t BufferSize);
|
||||
static void SetSetting(CSettings * _this, SettingID ID, uint32_t Value);
|
||||
static void SetSettingSz(CSettings * _this, SettingID ID, const char * Value);
|
||||
static void RegisterSetting(CSettings * _this, SettingID ID, SettingID DefaultID, SettingDataType DataType,
|
||||
static void SetSetting(CSettings * _this, SettingID ID, uint32_t Value);
|
||||
static void SetSettingSz(CSettings * _this, SettingID ID, const char * Value);
|
||||
static void RegisterSetting(CSettings * _this, SettingID ID, SettingID DefaultID, SettingDataType DataType,
|
||||
SettingType Type, const char * Category, const char * DefaultStr,
|
||||
uint32_t Value);
|
||||
static uint32_t FindSetting(CSettings * _this, const char * Name);
|
||||
static void FlushSettings(CSettings * _this);
|
||||
static uint32_t FindSetting(CSettings * _this, const char * Name);
|
||||
static void FlushSettings(CSettings * _this);
|
||||
static void sRegisterChangeCB(CSettings * _this, SettingID Type, void * Data, SettingChangedFunc Func);
|
||||
static void sUnregisterChangeCB(CSettings * _this, SettingID Type, void * Data, SettingChangedFunc Func);
|
||||
|
||||
//Notification
|
||||
void NotifyCallBacks(SettingID Type);
|
||||
|
|
|
@ -64,11 +64,20 @@ typedef struct
|
|||
void(*FlushSettings) (void * handle);
|
||||
} PLUGIN_SETTINGS3;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef void(*SettingChangedFunc)(void *);
|
||||
|
||||
void(*RegisterChangeCB)(void * handle, int ID, void * Data, SettingChangedFunc Func);
|
||||
void(*UnregisterChangeCB)(void * handle, int ID, void * Data, SettingChangedFunc Func);
|
||||
} PLUGIN_SETTINGS_NOTIFICATION;
|
||||
|
||||
static PLUGIN_SETTINGS g_PluginSettings;
|
||||
static PLUGIN_SETTINGS2 g_PluginSettings2;
|
||||
static PLUGIN_SETTINGS3 g_PluginSettings3;
|
||||
static bool g_PluginInitilized = false;
|
||||
static char g_PluginSettingName[300];
|
||||
static PLUGIN_SETTINGS_NOTIFICATION g_PluginSettingsNotification;
|
||||
static bool g_PluginInitilized = false;
|
||||
static char g_PluginSettingName[300];
|
||||
|
||||
EXPORT void SetSettingInfo(PLUGIN_SETTINGS * info);
|
||||
EXPORT void SetSettingInfo2(PLUGIN_SETTINGS2 * info);
|
||||
|
@ -91,6 +100,11 @@ EXPORT void SetSettingInfo3(PLUGIN_SETTINGS3 * info)
|
|||
g_PluginSettings3 = *info;
|
||||
}
|
||||
|
||||
EXPORT void SetSettingNotificationInfo(PLUGIN_SETTINGS_NOTIFICATION * info)
|
||||
{
|
||||
g_PluginSettingsNotification = *info;
|
||||
}
|
||||
|
||||
int32_t SettingsInitilized(void)
|
||||
{
|
||||
return g_PluginInitilized;
|
||||
|
@ -275,4 +289,20 @@ void SetSetting(short SettingID, unsigned int Value)
|
|||
void SetSettingSz(short SettingID, const char * Value)
|
||||
{
|
||||
g_PluginSettings.SetSettingSz(g_PluginSettings.handle, SettingID + g_PluginSettings.SettingStartRange, Value);
|
||||
}
|
||||
}
|
||||
|
||||
void SettingsRegisterChange(bool SystemSetting, int SettingID, void * Data, SettingChangedFunc Func)
|
||||
{
|
||||
if (g_PluginSettingsNotification.RegisterChangeCB && g_PluginSettings.handle)
|
||||
{
|
||||
g_PluginSettingsNotification.RegisterChangeCB(g_PluginSettings.handle, SettingID + (SystemSetting ? 0 : g_PluginSettings.SettingStartRange), Data, Func);
|
||||
}
|
||||
}
|
||||
|
||||
void SettingsUnregisterChange(bool SystemSetting, int SettingID, void * Data, SettingChangedFunc Func)
|
||||
{
|
||||
if (g_PluginSettingsNotification.UnregisterChangeCB && g_PluginSettings.handle)
|
||||
{
|
||||
g_PluginSettingsNotification.UnregisterChangeCB(g_PluginSettings.handle, SettingID + (SystemSetting ? 0 : g_PluginSettings.SettingStartRange), Data, Func);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,6 +41,10 @@ extern "C" {
|
|||
// this must be implemented to be notified when a setting is used but has not been set up
|
||||
void UseUnregisteredSetting(int SettingID);
|
||||
|
||||
typedef void(*SettingChangedFunc)(void *);
|
||||
void SettingsRegisterChange(bool SystemSetting, int Type, void * Data, SettingChangedFunc Func);
|
||||
void SettingsUnregisterChange(bool SystemSetting, int Type, void * Data, SettingChangedFunc Func);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue