[Project64] Clean up plugin classes

This commit is contained in:
zilmar 2015-11-08 17:08:15 +11:00
parent 9f87dbf30d
commit 3b8e03b570
12 changed files with 1313 additions and 1256 deletions

View File

@ -11,177 +11,179 @@
#include "stdafx.h"
CAudioPlugin::CAudioPlugin() :
AiLenChanged(NULL),
AiReadLength(NULL),
ProcessAList(NULL),
m_hAudioThread(NULL),
AiUpdate(NULL),
AiDacrateChanged(NULL)
AiLenChanged(NULL),
AiReadLength(NULL),
ProcessAList(NULL),
m_hAudioThread(NULL),
AiUpdate(NULL),
AiDacrateChanged(NULL)
{
}
CAudioPlugin::~CAudioPlugin()
{
Close();
UnloadPlugin();
Close();
UnloadPlugin();
}
bool CAudioPlugin::LoadFunctions ( void )
bool CAudioPlugin::LoadFunctions(void)
{
// Find entries for functions in DLL
void (__cdecl *InitiateAudio) ( void );
LoadFunction(InitiateAudio);
LoadFunction(AiDacrateChanged);
LoadFunction(AiLenChanged);
LoadFunction(AiReadLength);
LoadFunction(AiUpdate);
LoadFunction(ProcessAList);
// Find entries for functions in DLL
void(__cdecl *InitiateAudio) (void);
LoadFunction(InitiateAudio);
LoadFunction(AiDacrateChanged);
LoadFunction(AiLenChanged);
LoadFunction(AiReadLength);
LoadFunction(AiUpdate);
LoadFunction(ProcessAList);
// Make sure dll has all needed functions
if (AiDacrateChanged == NULL) { UnloadPlugin(); return false; }
if (AiLenChanged == NULL) { UnloadPlugin(); return false; }
if (AiReadLength == NULL) { UnloadPlugin(); return false; }
if (InitiateAudio == NULL) { UnloadPlugin(); return false; }
if (ProcessAList == NULL) { UnloadPlugin(); return false; }
// Make sure dll has all needed functions
if (AiDacrateChanged == NULL) { UnloadPlugin(); return false; }
if (AiLenChanged == NULL) { UnloadPlugin(); return false; }
if (AiReadLength == NULL) { UnloadPlugin(); return false; }
if (InitiateAudio == NULL) { UnloadPlugin(); return false; }
if (ProcessAList == NULL) { UnloadPlugin(); return false; }
if (m_PluginInfo.Version >= 0x0102)
{
if (PluginOpened == NULL) { UnloadPlugin(); return false; }
}
return true;
if (m_PluginInfo.Version >= 0x0102)
{
if (PluginOpened == NULL) { UnloadPlugin(); return false; }
}
return true;
}
bool CAudioPlugin::Initiate(CN64System * System, CMainGui * RenderWindow)
{
struct AUDIO_INFO {
HWND hwnd;
HINSTANCE hinst;
struct AUDIO_INFO
{
HWND hwnd;
HINSTANCE hinst;
BOOL MemoryBswaped; // If this is set to TRUE, then the memory has been pre
// bswap on a dword (32 bits) boundry
// eg. the first 8 bytes are stored like this:
// 4 3 2 1 8 7 6 5
BYTE * HEADER; // This is the rom header (first 40h bytes of the rom
// This will be in the same memory format as the rest of the memory.
BYTE * RDRAM;
BYTE * DMEM;
BYTE * IMEM;
int32_t MemoryBswaped; // If this is set to TRUE, then the memory has been pre
DWORD * MI__INTR_REG;
// bswap on a dword (32 bits) boundry
// eg. the first 8 bytes are stored like this:
// 4 3 2 1 8 7 6 5
uint8_t * HEADER; // This is the rom header (first 40h bytes of the rom
// This will be in the same memory format as the rest of the memory.
uint8_t * RDRAM;
uint8_t * DMEM;
uint8_t * IMEM;
DWORD * AI__DRAM_ADDR_REG;
DWORD * AI__LEN_REG;
DWORD * AI__CONTROL_REG;
DWORD * AI__STATUS_REG;
DWORD * AI__DACRATE_REG;
DWORD * AI__BITRATE_REG;
uint32_t * MI__INTR_REG;
void (__cdecl *CheckInterrupts)( void );
};
uint32_t * AI__DRAM_ADDR_REG;
uint32_t * AI__LEN_REG;
uint32_t * AI__CONTROL_REG;
uint32_t * AI__STATUS_REG;
uint32_t * AI__DACRATE_REG;
uint32_t * AI__BITRATE_REG;
//Get Function from DLL
BOOL (__cdecl *InitiateAudio)( AUDIO_INFO Audio_Info );
LoadFunction(InitiateAudio);
if (InitiateAudio == NULL) { return false; }
void(__cdecl *CheckInterrupts)(void);
};
AUDIO_INFO Info = { 0 };
//Get Function from DLL
int32_t(__cdecl *InitiateAudio)(AUDIO_INFO Audio_Info);
LoadFunction(InitiateAudio);
if (InitiateAudio == NULL) { return false; }
AUDIO_INFO Info = { 0 };
Info.hwnd = (HWND)RenderWindow->m_hMainWindow;;
Info.hinst = GetModuleHandle(NULL);
Info.MemoryBswaped = TRUE;
Info.CheckInterrupts = DummyCheckInterrupts;
Info.hinst = GetModuleHandle(NULL);
Info.MemoryBswaped = TRUE;
Info.CheckInterrupts = DummyCheckInterrupts;
// 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.
if (System == NULL)
{
BYTE Buffer[100];
DWORD Value = 0;
// 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.
if (System == NULL)
{
uint8_t Buffer[100];
uint32_t Value = 0;
Info.HEADER = Buffer;
Info.RDRAM = Buffer;
Info.DMEM = Buffer;
Info.IMEM = Buffer;
Info.MI__INTR_REG = &Value;
Info.AI__DRAM_ADDR_REG = &Value;
Info.AI__LEN_REG = &Value;
Info.AI__CONTROL_REG = &Value;
Info.AI__STATUS_REG = &Value;
Info.AI__DACRATE_REG = &Value;
Info.AI__BITRATE_REG = &Value;
}
// Send initialization information to the DLL
else
{
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.HEADER = Buffer;
Info.RDRAM = Buffer;
Info.DMEM = Buffer;
Info.IMEM = Buffer;
Info.MI__INTR_REG = &Value;
Info.AI__DRAM_ADDR_REG = &Value;
Info.AI__LEN_REG = &Value;
Info.AI__CONTROL_REG = &Value;
Info.AI__STATUS_REG = &Value;
Info.AI__DACRATE_REG = &Value;
Info.AI__BITRATE_REG = &Value;
}
// Send initialization information to the DLL
else
{
Info.HEADER = g_Rom->GetRomAddress();
Info.RDRAM = g_MMU->Rdram();
Info.DMEM = g_MMU->Dmem();
Info.IMEM = g_MMU->Imem();
Info.MI__INTR_REG = (uint32_t *)&g_Reg->m_AudioIntrReg;
Info.AI__DRAM_ADDR_REG = (uint32_t *)&g_Reg->AI_DRAM_ADDR_REG;
Info.AI__LEN_REG = (uint32_t *)&g_Reg->AI_LEN_REG;
Info.AI__CONTROL_REG = (uint32_t *)&g_Reg->AI_CONTROL_REG;
Info.AI__STATUS_REG = (uint32_t *)&g_Reg->AI_STATUS_REG;
Info.AI__DACRATE_REG = (uint32_t *)&g_Reg->AI_DACRATE_REG;
Info.AI__BITRATE_REG = (uint32_t *)&g_Reg->AI_BITRATE_REG;
}
m_Initialized = InitiateAudio(Info) != 0;
m_Initialized = InitiateAudio(Info) != 0;
//jabo had a bug so I call CreateThread so his dllmain gets called again
DWORD ThreadID;
HANDLE hthread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)DummyFunction, NULL, 0, &ThreadID);
CloseHandle(hthread);
//jabo had a bug so I call CreateThread so his dllmain gets called again
DWORD ThreadID;
HANDLE hthread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)DummyFunction, NULL, 0, &ThreadID);
CloseHandle(hthread);
if (System != NULL)
{
if (AiUpdate)
{
if (m_hAudioThread)
{
WriteTraceF(TraceAudio, __FUNCTION__ ": Terminate Audio Thread");
TerminateThread(m_hAudioThread, 0);
}
m_hAudioThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)AudioThread, (LPVOID)this, 0, &ThreadID);
}
if (g_Reg->AI_DACRATE_REG != 0)
{
DacrateChanged(System->SystemType());
}
}
return m_Initialized;
if (System != NULL)
{
if (AiUpdate)
{
if (m_hAudioThread)
{
WriteTraceF(TraceAudio, __FUNCTION__ ": Terminate Audio Thread");
TerminateThread(m_hAudioThread, 0);
}
m_hAudioThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)AudioThread, (LPVOID)this, 0, &ThreadID);
}
if (g_Reg->AI_DACRATE_REG != 0)
{
DacrateChanged(System->SystemType());
}
}
return m_Initialized;
}
void CAudioPlugin::UnloadPluginDetails(void)
{
if (m_hAudioThread)
{
WriteTraceF(TraceAudio, __FUNCTION__ ": Terminate Audio Thread");
TerminateThread(m_hAudioThread, 0);
m_hAudioThread = NULL;
}
AiDacrateChanged = NULL;
AiLenChanged = NULL;
AiReadLength = NULL;
AiUpdate = NULL;
ProcessAList = NULL;
if (m_hAudioThread)
{
WriteTraceF(TraceAudio, __FUNCTION__ ": Terminate Audio Thread");
TerminateThread(m_hAudioThread, 0);
m_hAudioThread = NULL;
}
AiDacrateChanged = NULL;
AiLenChanged = NULL;
AiReadLength = NULL;
AiUpdate = NULL;
ProcessAList = NULL;
}
void CAudioPlugin::DacrateChanged(SYSTEM_TYPE Type)
{
if (!Initialized()) { return; }
WriteTraceF(TraceAudio, __FUNCTION__ ": SystemType: %s", Type == SYSTEM_NTSC ? "SYSTEM_NTSC" : "SYSTEM_PAL");
if (!Initialized()) { return; }
WriteTraceF(TraceAudio, __FUNCTION__ ": SystemType: %s", Type == SYSTEM_NTSC ? "SYSTEM_NTSC" : "SYSTEM_PAL");
//DWORD Frequency = g_Reg->AI_DACRATE_REG * 30;
//DWORD CountsPerSecond = (g_Reg->VI_V_SYNC_REG != 0 ? (g_Reg->VI_V_SYNC_REG + 1) * g_Settings->LoadDword(Game_ViRefreshRate) : 500000) * 60;
AiDacrateChanged(Type);
//uint32_t Frequency = g_Reg->AI_DACRATE_REG * 30;
//uint32_t CountsPerSecond = (g_Reg->VI_V_SYNC_REG != 0 ? (g_Reg->VI_V_SYNC_REG + 1) * g_Settings->LoadDword(Game_ViRefreshRate) : 500000) * 60;
AiDacrateChanged(Type);
}
void CAudioPlugin::AudioThread(CAudioPlugin * _this) {
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
for (;;)
{
_this->AiUpdate(true);
}
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
for (;;)
{
_this->AiUpdate(true);
}
}

View File

@ -13,32 +13,32 @@
class CAudioPlugin : public CPlugin
{
public:
CAudioPlugin(void);
~CAudioPlugin();
CAudioPlugin(void);
~CAudioPlugin();
void DacrateChanged(SYSTEM_TYPE Type);
void DacrateChanged(SYSTEM_TYPE Type);
bool Initiate(CN64System * System, CMainGui * RenderWindow);
void(__cdecl *AiLenChanged)(void);
DWORD(__cdecl *AiReadLength)(void);
void(__cdecl *ProcessAList)(void);
void(__cdecl *AiLenChanged)(void);
uint32_t(__cdecl *AiReadLength)(void);
void(__cdecl *ProcessAList)(void);
private:
CAudioPlugin(const CAudioPlugin&); // Disable copy constructor
CAudioPlugin& operator=(const CAudioPlugin&); // Disable assignment
CAudioPlugin(const CAudioPlugin&); // Disable copy constructor
CAudioPlugin& operator=(const CAudioPlugin&); // Disable assignment
virtual int GetDefaultSettingStartRange() const { return FirstAudioDefaultSet; }
virtual int GetSettingStartRange() const { return FirstAudioSettings; }
PLUGIN_TYPE type() { return PLUGIN_TYPE_AUDIO; }
virtual int32_t GetDefaultSettingStartRange() const { return FirstAudioDefaultSet; }
virtual int32_t GetSettingStartRange() const { return FirstAudioSettings; }
PLUGIN_TYPE type() { return PLUGIN_TYPE_AUDIO; }
void * m_hAudioThread;
bool LoadFunctions ( void );
void UnloadPluginDetails ( void );
void * m_hAudioThread;
void(__cdecl *AiUpdate) (BOOL Wait);
void(__cdecl *AiDacrateChanged)(SYSTEM_TYPE Type);
bool LoadFunctions(void);
void UnloadPluginDetails(void);
// Function used in a thread for using audio
static void AudioThread(CAudioPlugin * _this);
void(__cdecl *AiUpdate) (int32_t Wait);
void(__cdecl *AiDacrateChanged)(SYSTEM_TYPE Type);
// Function used in a thread for using audio
static void AudioThread(CAudioPlugin * _this);
};

View File

@ -11,164 +11,170 @@
#include "stdafx.h"
CControl_Plugin::CControl_Plugin(void) :
WM_KeyDown(NULL),
WM_KeyUp(NULL),
RumbleCommand(NULL),
GetKeys(NULL),
ReadController(NULL),
ControllerCommand(NULL),
m_AllocatedControllers(false)
WM_KeyDown(NULL),
WM_KeyUp(NULL),
RumbleCommand(NULL),
GetKeys(NULL),
ReadController(NULL),
ControllerCommand(NULL),
m_AllocatedControllers(false)
{
memset(&m_PluginControllers, 0, sizeof(m_PluginControllers));
memset(&m_Controllers, 0, sizeof(m_Controllers));
memset(&m_PluginControllers, 0, sizeof(m_PluginControllers));
memset(&m_Controllers, 0, sizeof(m_Controllers));
}
CControl_Plugin::~CControl_Plugin()
{
Close();
UnloadPlugin();
Close();
UnloadPlugin();
}
bool CControl_Plugin::LoadFunctions ( void )
bool CControl_Plugin::LoadFunctions(void)
{
// Find entries for functions in DLL
void (__cdecl *InitiateControllers)( void );
LoadFunction(InitiateControllers);
LoadFunction(ControllerCommand);
LoadFunction(GetKeys);
LoadFunction(ReadController);
LoadFunction(WM_KeyDown);
LoadFunction(WM_KeyUp);
LoadFunction(RumbleCommand);
// Find entries for functions in DLL
void(__cdecl *InitiateControllers)(void);
LoadFunction(InitiateControllers);
LoadFunction(ControllerCommand);
LoadFunction(GetKeys);
LoadFunction(ReadController);
LoadFunction(WM_KeyDown);
LoadFunction(WM_KeyUp);
LoadFunction(RumbleCommand);
//Make sure dll had all needed functions
if (InitiateControllers == NULL) { UnloadPlugin(); return false; }
//Make sure dll had all needed functions
if (InitiateControllers == NULL) { UnloadPlugin(); return false; }
if (m_PluginInfo.Version >= 0x0102)
{
if (PluginOpened == NULL) { UnloadPlugin(); return false; }
}
if (m_PluginInfo.Version >= 0x0102)
{
if (PluginOpened == NULL) { UnloadPlugin(); return false; }
}
// Allocate our own controller
m_AllocatedControllers = true;
for (int i = 0; i < 4; i++)
{
m_Controllers[i] = new CCONTROL(m_PluginControllers[i].Present, m_PluginControllers[i].RawData, m_PluginControllers[i].Plugin);
}
return true;
// Allocate our own controller
m_AllocatedControllers = true;
for (int32_t i = 0; i < 4; i++)
{
m_Controllers[i] = new CCONTROL(m_PluginControllers[i].Present, m_PluginControllers[i].RawData, m_PluginControllers[i].Plugin);
}
return true;
}
bool CControl_Plugin::Initiate(CN64System * System, CMainGui * RenderWindow)
{
for (int i = 0; i < 4; i++)
{
m_PluginControllers[i].Present = FALSE;
m_PluginControllers[i].RawData = FALSE;
m_PluginControllers[i].Plugin = PLUGIN_NONE;
}
for (int32_t i = 0; i < 4; i++)
{
m_PluginControllers[i].Present = FALSE;
m_PluginControllers[i].RawData = FALSE;
m_PluginControllers[i].Plugin = PLUGIN_NONE;
}
// Test Plugin version
if (m_PluginInfo.Version == 0x0100)
{
//Get Function from DLL
void (__cdecl *InitiateControllers_1_0)( HWND hMainWindow, CONTROL Controls[4] );
InitiateControllers_1_0 = (void (__cdecl *)(HWND, CONTROL *))GetProcAddress( (HMODULE)m_hDll, "InitiateControllers" );
if (InitiateControllers_1_0 == NULL) { return false; }
// Test Plugin version
if (m_PluginInfo.Version == 0x0100)
{
//Get Function from DLL
void(__cdecl *InitiateControllers_1_0)(HWND hMainWindow, CONTROL Controls[4]);
InitiateControllers_1_0 = (void(__cdecl *)(HWND, CONTROL *))GetProcAddress((HMODULE)m_hDll, "InitiateControllers");
if (InitiateControllers_1_0 == NULL) { return false; }
InitiateControllers_1_0((HWND)RenderWindow->m_hMainWindow,m_PluginControllers);
m_Initialized = true;
}
else if (m_PluginInfo.Version >= 0x0101)
{
typedef struct {
HWND hMainWindow;
HINSTANCE hinst;
m_Initialized = true;
}
else if (m_PluginInfo.Version >= 0x0101)
{
typedef struct
{
HWND hMainWindow;
HINSTANCE hinst;
BOOL MemoryBswaped; // If this is set to TRUE, then the memory has been pre
// bswap on a dword (32 bits) boundry, only effects header.
// eg. the first 8 bytes are stored like this:
// 4 3 2 1 8 7 6 5
BYTE * HEADER; // This is the rom header (first 40h bytes of the rom)
CONTROL *Controls; // A pointer to an array of 4 controllers .. eg:
// CONTROL Controls[4];
} CONTROL_INFO;
int32_t MemoryBswaped; // If this is set to TRUE, then the memory has been pre
// bswap on a dword (32 bits) boundry, only effects header.
// eg. the first 8 bytes are stored like this:
// 4 3 2 1 8 7 6 5
uint8_t * HEADER; // This is the rom header (first 40h bytes of the rom)
CONTROL *Controls; // A pointer to an array of 4 controllers .. eg:
// CONTROL Controls[4];
} CONTROL_INFO;
//Get Function from DLL
void (__cdecl *InitiateControllers_1_1)( CONTROL_INFO * ControlInfo );
InitiateControllers_1_1 = (void (__cdecl *)(CONTROL_INFO *))GetProcAddress( (HMODULE)m_hDll, "InitiateControllers" );
if (InitiateControllers_1_1 == NULL) { return false; }
CONTROL_INFO ControlInfo;
BYTE Buffer[100];
//Get Function from DLL
void(__cdecl *InitiateControllers_1_1)(CONTROL_INFO * ControlInfo);
InitiateControllers_1_1 = (void(__cdecl *)(CONTROL_INFO *))GetProcAddress((HMODULE)m_hDll, "InitiateControllers");
if (InitiateControllers_1_1 == NULL) { return false; }
ControlInfo.Controls = m_PluginControllers;
ControlInfo.HEADER = (System == NULL ? Buffer : g_Rom->GetRomAddress());
ControlInfo.hinst = GetModuleHandle(NULL);
CONTROL_INFO ControlInfo;
uint8_t Buffer[100];
ControlInfo.Controls = m_PluginControllers;
ControlInfo.HEADER = (System == NULL ? Buffer : g_Rom->GetRomAddress());
ControlInfo.hinst = GetModuleHandle(NULL);
ControlInfo.hMainWindow = (HWND)RenderWindow->m_hMainWindow;
ControlInfo.MemoryBswaped = TRUE;
ControlInfo.MemoryBswaped = TRUE;
InitiateControllers_1_1(&ControlInfo);
m_Initialized = true;
}
InitiateControllers_1_1(&ControlInfo);
m_Initialized = true;
}
//jabo had a bug so I call CreateThread so his dllmain gets called again
DWORD ThreadID;
HANDLE hthread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)DummyFunction, NULL, 0, &ThreadID);
CloseHandle(hthread);
//jabo had a bug so I call CreateThread so his dllmain gets called again
DWORD ThreadID;
HANDLE hthread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)DummyFunction, NULL, 0, &ThreadID);
CloseHandle(hthread);
return m_Initialized;
return m_Initialized;
}
void CControl_Plugin::UnloadPluginDetails(void)
{
if (m_AllocatedControllers)
{
for (int32_t count = 0; count < sizeof(m_Controllers) / sizeof(m_Controllers[0]); count++)
{
delete m_Controllers[count];
m_Controllers[count] = NULL;
}
}
if (m_AllocatedControllers)
{
for (int count = 0; count < sizeof(m_Controllers) / sizeof(m_Controllers[0]); count++)
{
delete m_Controllers[count];
m_Controllers[count] = NULL;
}
}
m_AllocatedControllers = false;
ControllerCommand = NULL;
GetKeys = NULL;
ReadController = NULL;
WM_KeyDown = NULL;
WM_KeyUp = NULL;
m_AllocatedControllers = false;
ControllerCommand = NULL;
GetKeys = NULL;
ReadController = NULL;
WM_KeyDown = NULL;
WM_KeyUp = NULL;
}
void CControl_Plugin::UpdateKeys (void)
void CControl_Plugin::UpdateKeys(void)
{
if (!m_AllocatedControllers) { return; }
for (int cont = 0; cont < sizeof(m_Controllers) / sizeof(m_Controllers[0]); cont++)
{
if (!m_Controllers[cont]->m_Present) { continue; }
if (!m_Controllers[cont]->m_RawData) {
GetKeys(cont,&m_Controllers[cont]->m_Buttons);
} else {
g_Notify->BreakPoint(__FILEW__,__LINE__);
}
}
if (ReadController) { ReadController(-1, NULL); }
if (!m_AllocatedControllers) { return; }
for (int32_t cont = 0; cont < sizeof(m_Controllers) / sizeof(m_Controllers[0]); cont++)
{
if (!m_Controllers[cont]->m_Present) { continue; }
if (!m_Controllers[cont]->m_RawData)
{
GetKeys(cont, &m_Controllers[cont]->m_Buttons);
}
else
{
g_Notify->BreakPoint(__FILEW__, __LINE__);
}
}
if (ReadController) { ReadController(-1, NULL); }
}
void CControl_Plugin::SetControl(CControl_Plugin const * const Plugin)
{
if (m_AllocatedControllers) {
for (int count = 0; count < sizeof(m_Controllers) / sizeof(m_Controllers[0]); count++) {
delete m_Controllers[count];
m_Controllers[count] = NULL;
}
}
m_AllocatedControllers = false;
for (int count = 0; count < sizeof(m_Controllers) / sizeof(m_Controllers[0]); count++) {
m_Controllers[count] = Plugin->m_Controllers[count];
}
if (m_AllocatedControllers)
{
for (int32_t count = 0; count < sizeof(m_Controllers) / sizeof(m_Controllers[0]); count++)
{
delete m_Controllers[count];
m_Controllers[count] = NULL;
}
}
m_AllocatedControllers = false;
for (int32_t count = 0; count < sizeof(m_Controllers) / sizeof(m_Controllers[0]); count++)
{
m_Controllers[count] = Plugin->m_Controllers[count];
}
}
CCONTROL::CCONTROL(DWORD &Present, DWORD &RawData, int &PlugType) :
m_Present(Present), m_RawData(RawData), m_PlugType(PlugType)
CCONTROL::CCONTROL(uint32_t &Present, uint32_t &RawData, int32_t &PlugType) :
m_Present(Present), m_RawData(RawData), m_PlugType(PlugType)
{
m_Buttons.Value = 0;
m_Buttons.Value = 0;
}

View File

@ -10,95 +10,110 @@
****************************************************************************/
#pragma once
typedef union {
DWORD Value;
struct {
unsigned R_DPAD : 1;
unsigned L_DPAD : 1;
unsigned D_DPAD : 1;
unsigned U_DPAD : 1;
unsigned START_BUTTON : 1;
unsigned Z_TRIG : 1;
unsigned B_BUTTON : 1;
unsigned A_BUTTON : 1;
#pragma warning(push)
#pragma warning(disable : 4201) // warning C4201: nonstandard extension used : nameless struct/union
unsigned R_CBUTTON : 1;
unsigned L_CBUTTON : 1;
unsigned D_CBUTTON : 1;
unsigned U_CBUTTON : 1;
unsigned R_TRIG : 1;
unsigned L_TRIG : 1;
unsigned Reserved1 : 1;
unsigned Reserved2 : 1;
typedef union
{
uint32_t Value;
struct
{
unsigned R_DPAD : 1;
unsigned L_DPAD : 1;
unsigned D_DPAD : 1;
unsigned U_DPAD : 1;
unsigned START_BUTTON : 1;
unsigned Z_TRIG : 1;
unsigned B_BUTTON : 1;
unsigned A_BUTTON : 1;
signed Y_AXIS : 8;
unsigned R_CBUTTON : 1;
unsigned L_CBUTTON : 1;
unsigned D_CBUTTON : 1;
unsigned U_CBUTTON : 1;
unsigned R_TRIG : 1;
unsigned L_TRIG : 1;
unsigned Reserved1 : 1;
unsigned Reserved2 : 1;
signed X_AXIS : 8;
};
signed Y_AXIS : 8;
signed X_AXIS : 8;
};
} BUTTONS;
#pragma warning(pop)
typedef struct {
DWORD Present;
DWORD RawData;
int Plugin;
typedef struct
{
uint32_t Present;
uint32_t RawData;
int32_t Plugin;
} CONTROL;
enum PluginType {
PLUGIN_NONE = 1,
PLUGIN_MEMPAK = 2,
PLUGIN_RUMBLE_PAK = 3,
PLUGIN_TANSFER_PAK = 4, // not implemeted for non raw data
PLUGIN_RAW = 5, // the controller plugin is passed in raw data
enum PluginType
{
PLUGIN_NONE = 1,
PLUGIN_MEMPAK = 2,
PLUGIN_RUMBLE_PAK = 3,
PLUGIN_TANSFER_PAK = 4, // not implemeted for non raw data
PLUGIN_RAW = 5, // the controller plugin is passed in raw data
};
class CCONTROL {
friend CControl_Plugin; //controller plugin class has full access
DWORD & m_Present;
DWORD & m_RawData;
int & m_PlugType;
BUTTONS m_Buttons;
class CControl_Plugin;
class CCONTROL
{
public:
CCONTROL(DWORD &Present, DWORD &RawData, int &PlugType);
inline bool Present(void) const { return m_Present != 0; }
inline DWORD Buttons(void) const { return m_Buttons.Value; }
inline PluginType Plugin(void) const { return static_cast<PluginType>(m_PlugType); }
CCONTROL(uint32_t &Present, uint32_t &RawData, int32_t &PlugType);
inline bool Present(void) const { return m_Present != 0; }
inline uint32_t Buttons(void) const { return m_Buttons.Value; }
inline PluginType Plugin(void) const { return static_cast<PluginType>(m_PlugType); }
private:
friend CControl_Plugin; //controller plugin class has full access
uint32_t & m_Present;
uint32_t & m_RawData;
int32_t & m_PlugType;
BUTTONS m_Buttons;
CCONTROL(void); // Disable default constructor
CCONTROL(const CCONTROL&); // Disable copy constructor
CCONTROL& operator=(const CCONTROL&); // Disable assignment
};
class CControl_Plugin : public CPlugin
{
public:
CControl_Plugin(void);
~CControl_Plugin();
CControl_Plugin(void);
~CControl_Plugin();
bool Initiate(CN64System * System, CMainGui * RenderWindow);
void SetControl(CControl_Plugin const * const Plugin);
void UpdateKeys(void);
void SetControl(CControl_Plugin const * const Plugin);
void UpdateKeys(void);
void(__cdecl *WM_KeyDown) (DWORD wParam, DWORD lParam);
void(__cdecl *WM_KeyUp) (DWORD wParam, DWORD lParam);
void(__cdecl *RumbleCommand) (int Control, BOOL bRumble);
void(__cdecl *GetKeys) (int Control, BUTTONS * Keys);
void(__cdecl *ReadController) (int Control, BYTE * Command);
void(__cdecl *ControllerCommand)(int Control, BYTE * Command);
void(__cdecl *WM_KeyDown) (uint32_t wParam, uint32_t lParam);
void(__cdecl *WM_KeyUp) (uint32_t wParam, uint32_t lParam);
void(__cdecl *RumbleCommand) (int32_t Control, int32_t bRumble);
void(__cdecl *GetKeys) (int32_t Control, BUTTONS * Keys);
void(__cdecl *ReadController) (int32_t Control, uint8_t * Command);
void(__cdecl *ControllerCommand)(int32_t Control, uint8_t * Command);
inline CCONTROL const * Controller(int control) { return m_Controllers[control]; }
inline CONTROL * PluginControllers(void) { return m_PluginControllers; }
inline CCONTROL const * Controller(int32_t control) { return m_Controllers[control]; }
inline CONTROL * PluginControllers(void) { return m_PluginControllers; }
private:
CControl_Plugin(const CControl_Plugin&); // Disable copy constructor
CControl_Plugin& operator=(const CControl_Plugin&); // Disable assignment
CControl_Plugin(const CControl_Plugin&); // Disable copy constructor
CControl_Plugin& operator=(const CControl_Plugin&); // Disable assignment
virtual int GetDefaultSettingStartRange() const { return FirstCtrlDefaultSet; }
virtual int GetSettingStartRange() const { return FirstCtrlSettings; }
PLUGIN_TYPE type() { return PLUGIN_TYPE_CONTROLLER; }
bool LoadFunctions ( void );
void UnloadPluginDetails ( void );
virtual int32_t GetDefaultSettingStartRange() const { return FirstCtrlDefaultSet; }
virtual int32_t GetSettingStartRange() const { return FirstCtrlSettings; }
PLUGIN_TYPE type() { return PLUGIN_TYPE_CONTROLLER; }
bool LoadFunctions(void);
void UnloadPluginDetails(void);
bool m_AllocatedControllers;
bool m_AllocatedControllers;
// What the different controls are set up as
CONTROL m_PluginControllers[4];
CCONTROL * m_Controllers[4];
// What the different controls are set up as
CONTROL m_PluginControllers[4];
CCONTROL * m_Controllers[4];
};

View File

@ -10,250 +10,254 @@
****************************************************************************/
#include "stdafx.h"
CGfxPlugin::CGfxPlugin() :
CaptureScreen(NULL),
ChangeWindow(NULL),
DrawScreen(NULL),
DrawStatus(NULL),
MoveScreen(NULL),
ProcessDList(NULL),
ProcessRDPList(NULL),
ShowCFB(NULL),
UpdateScreen(NULL),
ViStatusChanged(NULL),
ViWidthChanged(NULL),
SoftReset(NULL),
GetRomBrowserMenu(NULL),
OnRomBrowserMenuItem(NULL),
GetDebugInfo(NULL),
InitiateDebugger(NULL)
CGfxPlugin::CGfxPlugin() :
CaptureScreen(NULL),
ChangeWindow(NULL),
DrawScreen(NULL),
DrawStatus(NULL),
MoveScreen(NULL),
ProcessDList(NULL),
ProcessRDPList(NULL),
ShowCFB(NULL),
UpdateScreen(NULL),
ViStatusChanged(NULL),
ViWidthChanged(NULL),
SoftReset(NULL),
GetRomBrowserMenu(NULL),
OnRomBrowserMenuItem(NULL),
GetDebugInfo(NULL),
InitiateDebugger(NULL)
{
memset(&m_GFXDebug, 0, sizeof(m_GFXDebug));
memset(&m_GFXDebug, 0, sizeof(m_GFXDebug));
}
CGfxPlugin::~CGfxPlugin()
{
Close();
UnloadPlugin();
Close();
UnloadPlugin();
}
bool CGfxPlugin::LoadFunctions ( void )
bool CGfxPlugin::LoadFunctions(void)
{
// Find entries for functions in DLL
BOOL (__cdecl *InitiateGFX) ( void * Gfx_Info );
LoadFunction(InitiateGFX);
LoadFunction(ChangeWindow);
LoadFunction(DrawScreen);
LoadFunction(MoveScreen);
LoadFunction(ProcessDList);
LoadFunction(UpdateScreen);
LoadFunction(ViStatusChanged);
LoadFunction(ViWidthChanged);
LoadFunction(SoftReset);
// Find entries for functions in DLL
int32_t(__cdecl *InitiateGFX) (void * Gfx_Info);
LoadFunction(InitiateGFX);
LoadFunction(ChangeWindow);
LoadFunction(DrawScreen);
LoadFunction(MoveScreen);
LoadFunction(ProcessDList);
LoadFunction(UpdateScreen);
LoadFunction(ViStatusChanged);
LoadFunction(ViWidthChanged);
LoadFunction(SoftReset);
// version 0x104 functions
_LoadFunction("DrawFullScreenStatus", DrawStatus);
// version 0x104 functions
_LoadFunction("DrawFullScreenStatus", DrawStatus);
// Rom Browser
LoadFunction(GetRomBrowserMenu);
LoadFunction(OnRomBrowserMenuItem);
// Rom Browser
LoadFunction(GetRomBrowserMenu);
LoadFunction(OnRomBrowserMenuItem);
//Make sure dll had all needed functions
if (ChangeWindow == NULL) { UnloadPlugin(); return false; }
if (DrawScreen == NULL) { DrawScreen = DummyDrawScreen; }
if (InitiateGFX == NULL) { UnloadPlugin(); return false; }
if (MoveScreen == NULL) { MoveScreen = DummyMoveScreen; }
if (ProcessDList == NULL) { UnloadPlugin(); return false; }
if (UpdateScreen == NULL) { UnloadPlugin(); return false; }
if (ViStatusChanged == NULL) { ViStatusChanged = DummyViStatusChanged; }
if (ViWidthChanged == NULL) { ViWidthChanged = DummyViWidthChanged; }
if (SoftReset == NULL) { SoftReset = DummySoftReset; }
//Make sure dll had all needed functions
if (ChangeWindow == NULL) { UnloadPlugin(); return false; }
if (DrawScreen == NULL) { DrawScreen = DummyDrawScreen; }
if (InitiateGFX == NULL) { UnloadPlugin(); return false; }
if (MoveScreen == NULL) { MoveScreen = DummyMoveScreen; }
if (ProcessDList == NULL) { UnloadPlugin(); return false; }
if (UpdateScreen == NULL) { UnloadPlugin(); return false; }
if (ViStatusChanged == NULL) { ViStatusChanged = DummyViStatusChanged; }
if (ViWidthChanged == NULL) { ViWidthChanged = DummyViWidthChanged; }
if (SoftReset == NULL) { SoftReset = DummySoftReset; }
if (m_PluginInfo.Version >= 0x0103)
{
LoadFunction(ProcessRDPList);
LoadFunction(CaptureScreen);
LoadFunction(ShowCFB);
LoadFunction(GetDebugInfo);
_LoadFunction("InitiateGFXDebugger", InitiateDebugger);
if (m_PluginInfo.Version >= 0x0103)
{
LoadFunction(ProcessRDPList);
LoadFunction(CaptureScreen);
LoadFunction(ShowCFB);
LoadFunction(GetDebugInfo);
_LoadFunction("InitiateGFXDebugger", InitiateDebugger);
if (ProcessRDPList == NULL) { UnloadPlugin(); return false; }
if (CaptureScreen == NULL) { UnloadPlugin(); return false; }
if (ShowCFB == NULL) { UnloadPlugin(); return false; }
}
if (ProcessRDPList == NULL) { UnloadPlugin(); return false; }
if (CaptureScreen == NULL) { UnloadPlugin(); return false; }
if (ShowCFB == NULL) { UnloadPlugin(); return false; }
}
if (m_PluginInfo.Version >= 0x0104)
{
if (PluginOpened == NULL) { UnloadPlugin(); return false; }
}
if (m_PluginInfo.Version >= 0x0104)
{
if (PluginOpened == NULL) { UnloadPlugin(); return false; }
}
if (GetDebugInfo != NULL)
GetDebugInfo(&m_GFXDebug);
if (GetDebugInfo != NULL)
GetDebugInfo(&m_GFXDebug);
return true;
return true;
}
bool CGfxPlugin::Initiate(CN64System * System, CMainGui * RenderWindow)
{
if (m_Initialized)
Close();
if (m_Initialized)
{
Close();
}
typedef struct {
HWND hWnd; /* Render window */
HWND hStatusBar; /* if render window does not have a status bar then this is NULL */
typedef struct
{
HWND hWnd; /* Render window */
HWND hStatusBar; /* if render window does not have a status bar then this is NULL */
BOOL MemoryBswaped; // If this is set to TRUE, then the memory has been pre
// bswap on a dword (32 bits) boundry
// eg. the first 8 bytes are stored like this:
// 4 3 2 1 8 7 6 5
int32_t MemoryBswaped; // If this is set to TRUE, then the memory has been pre
// bswap on a dword (32 bits) boundry
// eg. the first 8 bytes are stored like this:
// 4 3 2 1 8 7 6 5
BYTE * HEADER; // This is the rom header (first 40h bytes of the rom
// This will be in the same memory format as the rest of the memory.
BYTE * RDRAM;
BYTE * DMEM;
BYTE * IMEM;
uint8_t * HEADER; // This is the rom header (first 40h bytes of the rom
// This will be in the same memory format as the rest of the memory.
uint8_t * RDRAM;
uint8_t * DMEM;
uint8_t * IMEM;
DWORD * MI__INTR_REG;
uint32_t * MI__INTR_REG;
DWORD * DPC__START_REG;
DWORD * DPC__END_REG;
DWORD * DPC__CURRENT_REG;
DWORD * DPC__STATUS_REG;
DWORD * DPC__CLOCK_REG;
DWORD * DPC__BUFBUSY_REG;
DWORD * DPC__PIPEBUSY_REG;
DWORD * DPC__TMEM_REG;
uint32_t * DPC__START_REG;
uint32_t * DPC__END_REG;
uint32_t * DPC__CURRENT_REG;
uint32_t * DPC__STATUS_REG;
uint32_t * DPC__CLOCK_REG;
uint32_t * DPC__BUFBUSY_REG;
uint32_t * DPC__PIPEBUSY_REG;
uint32_t * DPC__TMEM_REG;
DWORD * VI__STATUS_REG;
DWORD * VI__ORIGIN_REG;
DWORD * VI__WIDTH_REG;
DWORD * VI__INTR_REG;
DWORD * VI__V_CURRENT_LINE_REG;
DWORD * VI__TIMING_REG;
DWORD * VI__V_SYNC_REG;
DWORD * VI__H_SYNC_REG;
DWORD * VI__LEAP_REG;
DWORD * VI__H_START_REG;
DWORD * VI__V_START_REG;
DWORD * VI__V_BURST_REG;
DWORD * VI__X_SCALE_REG;
DWORD * VI__Y_SCALE_REG;
uint32_t * VI__STATUS_REG;
uint32_t * VI__ORIGIN_REG;
uint32_t * VI__WIDTH_REG;
uint32_t * VI__INTR_REG;
uint32_t * VI__V_CURRENT_LINE_REG;
uint32_t * VI__TIMING_REG;
uint32_t * VI__V_SYNC_REG;
uint32_t * VI__H_SYNC_REG;
uint32_t * VI__LEAP_REG;
uint32_t * VI__H_START_REG;
uint32_t * VI__V_START_REG;
uint32_t * VI__V_BURST_REG;
uint32_t * VI__X_SCALE_REG;
uint32_t * VI__Y_SCALE_REG;
void (__cdecl *CheckInterrupts)( void );
} GFX_INFO;
void(__cdecl *CheckInterrupts)(void);
} GFX_INFO;
//Get Function from DLL
BOOL (__cdecl *InitiateGFX)( GFX_INFO Gfx_Info );
InitiateGFX = (BOOL (__cdecl *)(GFX_INFO))GetProcAddress( (HMODULE)m_hDll, "InitiateGFX" );
if (InitiateGFX == NULL) { return false; }
//Get Function from DLL
int32_t(__cdecl *InitiateGFX)(GFX_INFO Gfx_Info);
InitiateGFX = (int32_t(__cdecl *)(GFX_INFO))GetProcAddress((HMODULE)m_hDll, "InitiateGFX");
if (InitiateGFX == NULL) { return false; }
GFX_INFO Info = { 0 };
GFX_INFO Info = { 0 };
Info.MemoryBswaped = TRUE;
Info.MemoryBswaped = TRUE;
Info.hWnd = (HWND)RenderWindow->m_hMainWindow;
Info.hStatusBar = (HWND)RenderWindow->m_hStatusWnd;
Info.CheckInterrupts = DummyCheckInterrupts;
Info.CheckInterrupts = DummyCheckInterrupts;
// 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.
if (System == NULL)
{
BYTE Buffer[100];
DWORD Value = 0;
// 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.
if (System == NULL)
{
uint8_t Buffer[100];
uint32_t Value = 0;
Info.HEADER = Buffer;
Info.RDRAM = Buffer;
Info.DMEM = Buffer;
Info.IMEM = Buffer;
Info.MI__INTR_REG = &Value;
Info.VI__STATUS_REG = &Value;
Info.VI__ORIGIN_REG = &Value;
Info.VI__WIDTH_REG = &Value;
Info.VI__INTR_REG = &Value;
Info.VI__V_CURRENT_LINE_REG = &Value;
Info.VI__TIMING_REG = &Value;
Info.VI__V_SYNC_REG = &Value;
Info.VI__H_SYNC_REG = &Value;
Info.VI__LEAP_REG = &Value;
Info.VI__H_START_REG = &Value;
Info.VI__V_START_REG = &Value;
Info.VI__V_BURST_REG = &Value;
Info.VI__X_SCALE_REG = &Value;
Info.VI__Y_SCALE_REG = &Value;
}
// Send initialization information to the DLL
else
{
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.HEADER = Buffer;
Info.RDRAM = Buffer;
Info.DMEM = Buffer;
Info.IMEM = Buffer;
Info.MI__INTR_REG = &Value;
Info.VI__STATUS_REG = &Value;
Info.VI__ORIGIN_REG = &Value;
Info.VI__WIDTH_REG = &Value;
Info.VI__INTR_REG = &Value;
Info.VI__V_CURRENT_LINE_REG = &Value;
Info.VI__TIMING_REG = &Value;
Info.VI__V_SYNC_REG = &Value;
Info.VI__H_SYNC_REG = &Value;
Info.VI__LEAP_REG = &Value;
Info.VI__H_START_REG = &Value;
Info.VI__V_START_REG = &Value;
Info.VI__V_BURST_REG = &Value;
Info.VI__X_SCALE_REG = &Value;
Info.VI__Y_SCALE_REG = &Value;
}
// Send initialization information to the DLL
else
{
Info.HEADER = g_Rom->GetRomAddress();
Info.RDRAM = g_MMU->Rdram();
Info.DMEM = g_MMU->Dmem();
Info.IMEM = g_MMU->Imem();
Info.MI__INTR_REG = (uint32_t *)&g_Reg->m_GfxIntrReg;
Info.DPC__START_REG = (uint32_t *)&g_Reg->DPC_START_REG;
Info.DPC__END_REG = (uint32_t *)&g_Reg->DPC_END_REG;
Info.DPC__CURRENT_REG = (uint32_t *)&g_Reg->DPC_CURRENT_REG;
Info.DPC__STATUS_REG = (uint32_t *)&g_Reg->DPC_STATUS_REG;
Info.DPC__CLOCK_REG = (uint32_t *)&g_Reg->DPC_CLOCK_REG;
Info.DPC__BUFBUSY_REG = (uint32_t *)&g_Reg->DPC_BUFBUSY_REG;
Info.DPC__PIPEBUSY_REG = (uint32_t *)&g_Reg->DPC_PIPEBUSY_REG;
Info.DPC__TMEM_REG = (uint32_t *)&g_Reg->DPC_TMEM_REG;
Info.VI__STATUS_REG = (uint32_t *)&g_Reg->VI_STATUS_REG;
Info.VI__ORIGIN_REG = (uint32_t *)&g_Reg->VI_ORIGIN_REG;
Info.VI__WIDTH_REG = (uint32_t *)&g_Reg->VI_WIDTH_REG;
Info.VI__INTR_REG = (uint32_t *)&g_Reg->VI_INTR_REG;
Info.VI__V_CURRENT_LINE_REG = (uint32_t *)&g_Reg->VI_CURRENT_REG;
Info.VI__TIMING_REG = (uint32_t *)&g_Reg->VI_TIMING_REG;
Info.VI__V_SYNC_REG = (uint32_t *)&g_Reg->VI_V_SYNC_REG;
Info.VI__H_SYNC_REG = (uint32_t *)&g_Reg->VI_H_SYNC_REG;
Info.VI__LEAP_REG = (uint32_t *)&g_Reg->VI_LEAP_REG;
Info.VI__H_START_REG = (uint32_t *)&g_Reg->VI_H_START_REG;
Info.VI__V_START_REG = (uint32_t *)&g_Reg->VI_V_START_REG;
Info.VI__V_BURST_REG = (uint32_t *)&g_Reg->VI_V_BURST_REG;
Info.VI__X_SCALE_REG = (uint32_t *)&g_Reg->VI_X_SCALE_REG;
Info.VI__Y_SCALE_REG = (uint32_t *)&g_Reg->VI_Y_SCALE_REG;
}
m_Initialized = InitiateGFX(Info) != 0;
m_Initialized = InitiateGFX(Info) != 0;
//jabo had a bug so I call CreateThread so his dllmain gets called again
DWORD ThreadID;
HANDLE hthread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)DummyFunction, NULL, 0, &ThreadID);
CloseHandle(hthread);
//jabo had a bug so I call CreateThread so his dllmain gets called again
DWORD ThreadID;
HANDLE hthread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)DummyFunction, NULL, 0, &ThreadID);
CloseHandle(hthread);
return m_Initialized;
return m_Initialized;
}
void CGfxPlugin::UnloadPluginDetails(void)
{
if (m_hDll != NULL ) {
FreeLibrary((HMODULE)m_hDll);
m_hDll = NULL;
}
memset(&m_GFXDebug, 0, sizeof(m_GFXDebug));
if (m_hDll != NULL)
{
FreeLibrary((HMODULE)m_hDll);
m_hDll = NULL;
}
memset(&m_GFXDebug, 0, sizeof(m_GFXDebug));
// CaptureScreen = NULL;
ChangeWindow = NULL;
GetDebugInfo = NULL;
DrawScreen = NULL;
DrawStatus = NULL;
// FrameBufferRead = NULL;
// FrameBufferWrite = NULL;
InitiateDebugger = NULL;
MoveScreen = NULL;
ProcessDList = NULL;
ProcessRDPList = NULL;
ShowCFB = NULL;
UpdateScreen = NULL;
ViStatusChanged = NULL;
ViWidthChanged = NULL;
GetRomBrowserMenu = NULL;
OnRomBrowserMenuItem = NULL;
// CaptureScreen = NULL;
ChangeWindow = NULL;
GetDebugInfo = NULL;
DrawScreen = NULL;
DrawStatus = NULL;
// FrameBufferRead = NULL;
// FrameBufferWrite = NULL;
InitiateDebugger = NULL;
MoveScreen = NULL;
ProcessDList = NULL;
ProcessRDPList = NULL;
ShowCFB = NULL;
UpdateScreen = NULL;
ViStatusChanged = NULL;
ViWidthChanged = NULL;
GetRomBrowserMenu = NULL;
OnRomBrowserMenuItem = NULL;
}
void CGfxPlugin::ProcessMenuItem(int id)
void CGfxPlugin::ProcessMenuItem(int32_t id)
{
if (m_GFXDebug.ProcessMenuItem)
{
m_GFXDebug.ProcessMenuItem(id);
}
if (m_GFXDebug.ProcessMenuItem)
{
m_GFXDebug.ProcessMenuItem(id);
}
}

View File

@ -12,84 +12,86 @@
class CGfxPlugin : public CPlugin
{
typedef struct {
/* Menu */
/* Items should have an ID between 5101 and 5200 */
HMENU hGFXMenu;
void(__cdecl *ProcessMenuItem) (int ID);
typedef struct
{
/* Menu */
/* Items should have an ID between 5101 and 5200 */
void * hGFXMenu;
void(__cdecl *ProcessMenuItem) (int32_t ID);
/* Break Points */
BOOL UseBPoints;
char BPPanelName[20];
void(__cdecl *Add_BPoint) (void);
void(__cdecl *CreateBPPanel) (HWND hDlg, RECT_STRUCT rcBox);
void(__cdecl *HideBPPanel) (void);
void(__cdecl *PaintBPPanel) (WINDOWS_PAINTSTRUCT ps);
void(__cdecl *ShowBPPanel) (void);
void(__cdecl *RefreshBpoints) (HWND hList);
void(__cdecl *RemoveBpoint) (HWND hList, int index);
void(__cdecl *RemoveAllBpoint) (void);
/* Break Points */
int32_t UseBPoints;
char BPPanelName[20];
void(__cdecl *Add_BPoint) (void);
void(__cdecl *CreateBPPanel) (void * hDlg, void * rcBox);
void(__cdecl *HideBPPanel) (void);
void(__cdecl *PaintBPPanel) (void * ps);
void(__cdecl *ShowBPPanel) (void);
void(__cdecl *RefreshBpoints) (void * hList);
void(__cdecl *RemoveBpoint) (void * hList, int32_t index);
void(__cdecl *RemoveAllBpoint) (void);
/* GFX command Window */
void(__cdecl *Enter_GFX_Commands_Window) (void);
} GFXDEBUG_INFO;
/* GFX command Window */
void(__cdecl *Enter_GFX_Commands_Window) (void);
} GFXDEBUG_INFO;
typedef struct {
void(__cdecl *UpdateBreakPoints)(void);
void(__cdecl *UpdateMemory)(void);
void(__cdecl *UpdateR4300iRegisters)(void);
void(__cdecl *Enter_BPoint_Window)(void);
void(__cdecl *Enter_R4300i_Commands_Window)(void);
void(__cdecl *Enter_R4300i_Register_Window)(void);
void(__cdecl *Enter_RSP_Commands_Window) (void);
void(__cdecl *Enter_Memory_Window)(void);
} DEBUG_INFO;
typedef struct
{
void(__cdecl *UpdateBreakPoints)(void);
void(__cdecl *UpdateMemory)(void);
void(__cdecl *UpdateR4300iRegisters)(void);
void(__cdecl *Enter_BPoint_Window)(void);
void(__cdecl *Enter_R4300i_Commands_Window)(void);
void(__cdecl *Enter_R4300i_Register_Window)(void);
void(__cdecl *Enter_RSP_Commands_Window) (void);
void(__cdecl *Enter_Memory_Window)(void);
} DEBUG_INFO;
public:
CGfxPlugin(void);
~CGfxPlugin();
CGfxPlugin(void);
~CGfxPlugin();
bool LoadFunctions ( void );
bool LoadFunctions(void);
bool Initiate(CN64System * System, CMainGui * RenderWindow);
void(__cdecl *CaptureScreen) (const char *);
void(__cdecl *ChangeWindow) (void);
void(__cdecl *DrawScreen) (void);
void(__cdecl *DrawStatus) (const char * lpString, BOOL RightAlign);
void(__cdecl *MoveScreen) (int xpos, int ypos);
void(__cdecl *ProcessDList) (void);
void(__cdecl *ProcessRDPList) (void);
void(__cdecl *ShowCFB) (void);
void(__cdecl *UpdateScreen) (void);
void(__cdecl *ViStatusChanged) (void);
void(__cdecl *ViWidthChanged) (void);
void(__cdecl *SoftReset) (void);
void(__cdecl *CaptureScreen) (const char *);
void(__cdecl *ChangeWindow) (void);
void(__cdecl *DrawScreen) (void);
void(__cdecl *DrawStatus) (const char * lpString, int32_t RightAlign);
void(__cdecl *MoveScreen) (int32_t xpos, int32_t ypos);
void(__cdecl *ProcessDList) (void);
void(__cdecl *ProcessRDPList) (void);
void(__cdecl *ShowCFB) (void);
void(__cdecl *UpdateScreen) (void);
void(__cdecl *ViStatusChanged) (void);
void(__cdecl *ViWidthChanged) (void);
void(__cdecl *SoftReset) (void);
//Rom Browser
HMENU(__cdecl * GetRomBrowserMenu) (void); /* Items should have an ID between 4101 and 4200 */
void(__cdecl * OnRomBrowserMenuItem) (int MenuID, HWND hParent, BYTE * HEADER);
//Rom Browser
void *(__cdecl * GetRomBrowserMenu) (void); /* Items should have an ID between 4101 and 4200 */
void(__cdecl * OnRomBrowserMenuItem) (int32_t MenuID, void * hParent, uint8_t * HEADER);
HMENU GetDebugMenu(void) { return m_GFXDebug.hGFXMenu; }
void ProcessMenuItem(int id);
void * GetDebugMenu(void) { return m_GFXDebug.hGFXMenu; }
void ProcessMenuItem(int32_t id);
private:
CGfxPlugin(const CGfxPlugin&); // Disable copy constructor
CGfxPlugin& operator=(const CGfxPlugin&); // Disable assignment
CGfxPlugin(const CGfxPlugin&); // Disable copy constructor
CGfxPlugin& operator=(const CGfxPlugin&); // Disable assignment
virtual int GetDefaultSettingStartRange() const { return FirstGfxDefaultSet; }
virtual int GetSettingStartRange() const { return FirstGfxSettings; }
PLUGIN_TYPE type() { return PLUGIN_TYPE_GFX; }
virtual int32_t GetDefaultSettingStartRange() const { return FirstGfxDefaultSet; }
virtual int32_t GetSettingStartRange() const { return FirstGfxSettings; }
PLUGIN_TYPE type() { return PLUGIN_TYPE_GFX; }
void UnloadPluginDetails ( void );
void UnloadPluginDetails(void);
GFXDEBUG_INFO m_GFXDebug;
GFXDEBUG_INFO m_GFXDebug;
void(__cdecl *GetDebugInfo) (GFXDEBUG_INFO * GFXDebugInfo);
void(__cdecl *InitiateDebugger)(DEBUG_INFO DebugInfo);
void(__cdecl *GetDebugInfo) (GFXDEBUG_INFO * GFXDebugInfo);
void(__cdecl *InitiateDebugger)(DEBUG_INFO DebugInfo);
static void __cdecl DummyDrawScreen(void) {}
static void __cdecl DummyMoveScreen(int /*xpos*/, int /*ypos*/) {}
static void __cdecl DummyViStatusChanged(void) {}
static void __cdecl DummyViWidthChanged(void) {}
static void __cdecl DummySoftReset(void) {}
static void __cdecl DummyDrawScreen(void) {}
static void __cdecl DummyMoveScreen(int32_t /*xpos*/, int32_t /*ypos*/) {}
static void __cdecl DummyViStatusChanged(void) {}
static void __cdecl DummyViWidthChanged(void) {}
static void __cdecl DummySoftReset(void) {}
};

View File

@ -11,214 +11,245 @@
#include "stdafx.h"
CPlugin::CPlugin() :
DllAbout(NULL),
DllConfig(NULL),
CloseDLL(NULL),
RomOpen(NULL),
RomClosed(NULL),
PluginOpened(NULL),
SetSettingInfo(NULL),
SetSettingInfo2(NULL),
SetSettingInfo3(NULL),
m_hDll(NULL),
m_Initialized(false),
m_RomOpen(false)
DllAbout(NULL),
DllConfig(NULL),
CloseDLL(NULL),
RomOpen(NULL),
RomClosed(NULL),
PluginOpened(NULL),
SetSettingInfo(NULL),
SetSettingInfo2(NULL),
SetSettingInfo3(NULL),
m_hDll(NULL),
m_Initialized(false),
m_RomOpen(false)
{
memset(&m_PluginInfo, 0, sizeof(m_PluginInfo));
memset(&m_PluginInfo, 0, sizeof(m_PluginInfo));
}
CPlugin::~CPlugin()
{
UnloadPlugin();
UnloadPlugin();
}
bool CPlugin::Load (const char * FileName)
{
// Already loaded, so unload first.
if (m_hDll != NULL)
{
UnloadPlugin();
}
// Already loaded, so unload first.
if (m_hDll != NULL)
{
UnloadPlugin();
}
// Try to load the plugin DLL
//Try to load the DLL library
if (bHaveDebugger())
{
m_hDll = LoadLibrary(FileName);
}
else
{
UINT LastErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS);
m_hDll = LoadLibrary(FileName);
SetErrorMode(LastErrorMode);
}
// Try to load the plugin DLL
//Try to load the DLL library
if (bHaveDebugger())
{
m_hDll = LoadLibrary(FileName);
}
else
{
UINT LastErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS);
m_hDll = LoadLibrary(FileName);
SetErrorMode(LastErrorMode);
}
if (m_hDll == NULL)
{
return false;
}
if (m_hDll == NULL)
{
return false;
}
// Get DLL information
void(__cdecl *GetDllInfo) (PLUGIN_INFO * PluginInfo);
LoadFunction(GetDllInfo);
if (GetDllInfo == NULL) { return false; }
// Get DLL information
void(__cdecl *GetDllInfo) (PLUGIN_INFO * PluginInfo);
LoadFunction(GetDllInfo);
if (GetDllInfo == NULL) { return false; }
GetDllInfo(&m_PluginInfo);
if (!CPluginList::ValidPluginVersion(m_PluginInfo)) { return false; }
if (m_PluginInfo.Type != type()) { return false; }
GetDllInfo(&m_PluginInfo);
if (!ValidPluginVersion(m_PluginInfo)) { return false; }
if (m_PluginInfo.Type != type()) { return false; }
CloseDLL = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)m_hDll, "CloseDLL" );
RomOpen = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)m_hDll, "RomOpen" );
RomClosed = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)m_hDll, "RomClosed" );
PluginOpened = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)m_hDll, "PluginLoaded" );
DllConfig = (void (__cdecl *)(DWORD)) GetProcAddress( (HMODULE)m_hDll, "DllConfig" );
DllAbout = (void (__cdecl *)(HWND)) GetProcAddress( (HMODULE)m_hDll, "DllAbout" );
CloseDLL = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)m_hDll, "CloseDLL" );
RomOpen = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)m_hDll, "RomOpen" );
RomClosed = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)m_hDll, "RomClosed" );
PluginOpened = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)m_hDll, "PluginLoaded" );
DllConfig = (void (__cdecl *)(uint32_t)) GetProcAddress( (HMODULE)m_hDll, "DllConfig" );
DllAbout = (void (__cdecl *)(void *)) GetProcAddress( (HMODULE)m_hDll, "DllAbout" );
SetSettingInfo3 = (void (__cdecl *)(PLUGIN_SETTINGS3 *))GetProcAddress( (HMODULE)m_hDll, "SetSettingInfo3" );
if (SetSettingInfo3)
{
PLUGIN_SETTINGS3 info;
info.FlushSettings = (void (*)( void * handle))CSettings::FlushSettings;
SetSettingInfo3(&info);
}
SetSettingInfo3 = (void (__cdecl *)(PLUGIN_SETTINGS3 *))GetProcAddress( (HMODULE)m_hDll, "SetSettingInfo3" );
if (SetSettingInfo3)
{
PLUGIN_SETTINGS3 info;
info.FlushSettings = (void (*)( void * handle))CSettings::FlushSettings;
SetSettingInfo3(&info);
}
SetSettingInfo2 = (void (__cdecl *)(PLUGIN_SETTINGS2 *))GetProcAddress( (HMODULE)m_hDll, "SetSettingInfo2" );
if (SetSettingInfo2)
{
PLUGIN_SETTINGS2 info;
info.FindSystemSettingId = (unsigned int (*)( void * handle, const char * ))CSettings::FindSetting;
SetSettingInfo2(&info);
}
SetSettingInfo2 = (void (__cdecl *)(PLUGIN_SETTINGS2 *))GetProcAddress( (HMODULE)m_hDll, "SetSettingInfo2" );
if (SetSettingInfo2)
{
PLUGIN_SETTINGS2 info;
info.FindSystemSettingId = (uint32_t (*)( void * handle, const char * ))CSettings::FindSetting;
SetSettingInfo2(&info);
}
SetSettingInfo = (void (__cdecl *)(PLUGIN_SETTINGS *))GetProcAddress( (HMODULE)m_hDll, "SetSettingInfo" );
if (SetSettingInfo)
{
PLUGIN_SETTINGS info;
info.dwSize = sizeof(PLUGIN_SETTINGS);
info.DefaultStartRange = GetDefaultSettingStartRange();
info.SettingStartRange = GetSettingStartRange();
info.MaximumSettings = MaxPluginSetting;
info.NoDefault = Default_None;
info.DefaultLocation = g_Settings->LoadDword(Setting_UseFromRegistry) ? SettingType_Registry : SettingType_CfgFile;
info.handle = g_Settings;
info.RegisterSetting = (void(*)(void *, int, int, SettingDataType, SettingType, const char *, const char *, DWORD))&CSettings::RegisterSetting;
info.GetSetting = (unsigned int(*)(void *, int))&CSettings::GetSetting;
info.GetSettingSz = (const char * (*)(void *, int, char *, int))&CSettings::GetSettingSz;
info.SetSetting = (void(*)(void *, int, unsigned int))&CSettings::SetSetting;
info.SetSettingSz = (void(*)(void *, int, const char *))&CSettings::SetSettingSz;
info.UseUnregisteredSetting = NULL;
SetSettingInfo = (void (__cdecl *)(PLUGIN_SETTINGS *))GetProcAddress( (HMODULE)m_hDll, "SetSettingInfo" );
if (SetSettingInfo)
{
PLUGIN_SETTINGS info;
info.dwSize = sizeof(PLUGIN_SETTINGS);
info.DefaultStartRange = GetDefaultSettingStartRange();
info.SettingStartRange = GetSettingStartRange();
info.MaximumSettings = MaxPluginSetting;
info.NoDefault = Default_None;
info.DefaultLocation = g_Settings->LoadDword(Setting_UseFromRegistry) ? SettingType_Registry : SettingType_CfgFile;
info.handle = g_Settings;
info.RegisterSetting = (void(*)(void *, int, int, SettingDataType, SettingType, const char *, const char *, uint32_t))&CSettings::RegisterSetting;
info.GetSetting = (uint32_t(*)(void *, int))&CSettings::GetSetting;
info.GetSettingSz = (const char * (*)(void *, int, char *, int))&CSettings::GetSettingSz;
info.SetSetting = (void(*)(void *, int, uint32_t))&CSettings::SetSetting;
info.SetSettingSz = (void(*)(void *, int, const char *))&CSettings::SetSettingSz;
info.UseUnregisteredSetting = NULL;
SetSettingInfo(&info);
}
SetSettingInfo(&info);
}
if (RomClosed == NULL)
return false;
if (RomClosed == NULL)
return false;
if (!LoadFunctions())
{
return false;
}
WriteTraceF(PluginTraceType(),__FUNCTION__ "(%s): Functions loaded",PluginType());
if (!LoadFunctions())
{
return false;
}
WriteTraceF(PluginTraceType(),__FUNCTION__ "(%s): Functions loaded",PluginType());
if (PluginOpened)
{
WriteTraceF(PluginTraceType(),__FUNCTION__ "(%s): Before Plugin Opened",PluginType());
PluginOpened();
WriteTraceF(PluginTraceType(),__FUNCTION__ "(%s): After Plugin Opened",PluginType());
}
return true;
if (PluginOpened)
{
WriteTraceF(PluginTraceType(),__FUNCTION__ "(%s): Before Plugin Opened",PluginType());
PluginOpened();
WriteTraceF(PluginTraceType(),__FUNCTION__ "(%s): After Plugin Opened",PluginType());
}
return true;
}
void CPlugin::RomOpened()
{
if (m_RomOpen)
return;
if (m_RomOpen)
return;
if(RomOpen != NULL){
WriteTraceF(PluginTraceType(),__FUNCTION__ "(%s): Before Rom Open",PluginType());
RomOpen();
WriteTraceF(PluginTraceType(),__FUNCTION__ "(%s): After Rom Open",PluginType());
}
m_RomOpen = true;
if(RomOpen != NULL){
WriteTraceF(PluginTraceType(),__FUNCTION__ "(%s): Before Rom Open",PluginType());
RomOpen();
WriteTraceF(PluginTraceType(),__FUNCTION__ "(%s): After Rom Open",PluginType());
}
m_RomOpen = true;
}
void CPlugin::RomClose()
{
if (!m_RomOpen)
return;
if (!m_RomOpen)
return;
WriteTraceF(PluginTraceType(),__FUNCTION__ "(%s): Before Rom Close",PluginType());
RomClosed();
m_RomOpen = false;
WriteTraceF(PluginTraceType(),__FUNCTION__ "(%s): After Rom Close",PluginType());
WriteTraceF(PluginTraceType(),__FUNCTION__ "(%s): Before Rom Close",PluginType());
RomClosed();
m_RomOpen = false;
WriteTraceF(PluginTraceType(),__FUNCTION__ "(%s): After Rom Close",PluginType());
}
void CPlugin::GameReset()
{
if (m_RomOpen)
{
RomClose();
if (RomOpen)
{
RomOpen();
}
}
if (m_RomOpen)
{
RomClose();
if (RomOpen)
{
RomOpen();
}
}
}
void CPlugin::Close()
{
WriteTraceF(PluginTraceType(),__FUNCTION__ "(%s): Start",PluginType());
RomClose();
if (m_Initialized)
{
CloseDLL();
m_Initialized = false;
}
WriteTraceF(PluginTraceType(),__FUNCTION__ "(%s): Done",PluginType());
WriteTraceF(PluginTraceType(),__FUNCTION__ "(%s): Start",PluginType());
RomClose();
if (m_Initialized)
{
CloseDLL();
m_Initialized = false;
}
WriteTraceF(PluginTraceType(),__FUNCTION__ "(%s): Done",PluginType());
}
void CPlugin::UnloadPlugin()
{
WriteTraceF(PluginTraceType(),__FUNCTION__ "(%s): unloading",PluginType());
memset(&m_PluginInfo, 0, sizeof(m_PluginInfo));
if (m_hDll != NULL)
{
UnloadPluginDetails();
FreeLibrary((HMODULE)m_hDll);
m_hDll = NULL;
}
WriteTraceF(PluginTraceType(),__FUNCTION__ "(%s): unloading",PluginType());
memset(&m_PluginInfo, 0, sizeof(m_PluginInfo));
if (m_hDll != NULL)
{
UnloadPluginDetails();
FreeLibrary((HMODULE)m_hDll);
m_hDll = NULL;
}
DllAbout = NULL;
CloseDLL = NULL;
RomOpen = NULL;
RomClosed = NULL;
PluginOpened = NULL;
DllConfig = NULL;
SetSettingInfo = NULL;
SetSettingInfo2 = NULL;
SetSettingInfo3 = NULL;
DllAbout = NULL;
CloseDLL = NULL;
RomOpen = NULL;
RomClosed = NULL;
PluginOpened = NULL;
DllConfig = NULL;
SetSettingInfo = NULL;
SetSettingInfo2 = NULL;
SetSettingInfo3 = NULL;
}
const char * CPlugin::PluginType () const
{
switch (m_PluginInfo.Type)
{
case PLUGIN_TYPE_RSP: return "RSP";
case PLUGIN_TYPE_GFX: return "GFX";
case PLUGIN_TYPE_AUDIO: return "Audio";
case PLUGIN_TYPE_CONTROLLER: return "Control";
}
return "Unknown";
switch (m_PluginInfo.Type)
{
case PLUGIN_TYPE_RSP: return "RSP";
case PLUGIN_TYPE_GFX: return "GFX";
case PLUGIN_TYPE_AUDIO: return "Audio";
case PLUGIN_TYPE_CONTROLLER: return "Control";
}
return "Unknown";
}
TraceType CPlugin::PluginTraceType () const
{
switch (m_PluginInfo.Type)
{
case PLUGIN_TYPE_RSP: return TraceRSP;
case PLUGIN_TYPE_GFX: return TraceGfxPlugin;
case PLUGIN_TYPE_AUDIO: return TraceDebug;
case PLUGIN_TYPE_CONTROLLER: return TraceDebug;
}
return TraceDebug;
switch (m_PluginInfo.Type)
{
case PLUGIN_TYPE_RSP: return TraceRSP;
case PLUGIN_TYPE_GFX: return TraceGfxPlugin;
case PLUGIN_TYPE_AUDIO: return TraceDebug;
case PLUGIN_TYPE_CONTROLLER: return TraceDebug;
}
return TraceDebug;
}
bool CPlugin::ValidPluginVersion ( PLUGIN_INFO & PluginInfo )
{
switch (PluginInfo.Type)
{
case PLUGIN_TYPE_RSP:
if (!PluginInfo.MemoryBswaped) { return false; }
if (PluginInfo.Version == 0x0001) { return true; }
if (PluginInfo.Version == 0x0100) { return true; }
if (PluginInfo.Version == 0x0101) { return true; }
if (PluginInfo.Version == 0x0102) { return true; }
break;
case PLUGIN_TYPE_GFX:
if (!PluginInfo.MemoryBswaped) { return false; }
if (PluginInfo.Version == 0x0102) { return true; }
if (PluginInfo.Version == 0x0103) { return true; }
if (PluginInfo.Version == 0x0104) { return true; }
break;
case PLUGIN_TYPE_AUDIO:
if (!PluginInfo.MemoryBswaped) { return false; }
if (PluginInfo.Version == 0x0101) { return true; }
if (PluginInfo.Version == 0x0102) { return true; }
break;
case PLUGIN_TYPE_CONTROLLER:
if (PluginInfo.Version == 0x0100) { return true; }
if (PluginInfo.Version == 0x0101) { return true; }
if (PluginInfo.Version == 0x0102) { return true; }
break;
}
return FALSE;
}

View File

@ -11,55 +11,56 @@
#pragma once
class CPlugin :
private CDebugSettings
private CDebugSettings
{
public:
CPlugin();
virtual ~CPlugin();
inline const char * PluginName() const { return m_PluginInfo.Name; }
inline bool Initialized() { return m_Initialized; }
CPlugin();
virtual ~CPlugin();
inline const char * PluginName() const { return m_PluginInfo.Name; }
inline bool Initialized() { return m_Initialized; }
virtual int GetDefaultSettingStartRange() const = 0;
virtual int GetSettingStartRange() const = 0;
virtual int32_t GetDefaultSettingStartRange() const = 0;
virtual int32_t GetSettingStartRange() const = 0;
bool Load ( const char * FileName );
bool Load(const char * FileName);
void RomOpened();
void RomClose();
void GameReset();
void Close();
void RomOpened();
void RomClose();
void GameReset();
void Close();
void(__cdecl *DllAbout) (HWND hWnd);
void(__cdecl *DllConfig) (DWORD hParent);
void(__cdecl *DllAbout) (void * hWnd);
void(__cdecl *DllConfig) (uint32_t hParent);
static bool ValidPluginVersion ( PLUGIN_INFO & PluginInfo );
protected:
void UnloadPlugin();
const char * PluginType() const;
TraceType PluginTraceType() const;
virtual void UnloadPluginDetails() = 0;
virtual PLUGIN_TYPE type() = 0;
virtual bool LoadFunctions(void) = 0;
void UnloadPlugin();
const char * PluginType () const;
TraceType PluginTraceType () const;
virtual void UnloadPluginDetails() = 0;
virtual PLUGIN_TYPE type() = 0;
virtual bool LoadFunctions ( void ) = 0;
void(__cdecl *CloseDLL) (void);
void(__cdecl *RomOpen) (void);
void(__cdecl *RomClosed) (void);
void(__cdecl *PluginOpened)(void);
void(__cdecl *SetSettingInfo) (PLUGIN_SETTINGS *);
void(__cdecl *SetSettingInfo2) (PLUGIN_SETTINGS2 *);
void(__cdecl *SetSettingInfo3) (PLUGIN_SETTINGS3 *);
void(__cdecl *CloseDLL) (void);
void(__cdecl *RomOpen) (void);
void(__cdecl *RomClosed) (void);
void(__cdecl *PluginOpened)(void);
void(__cdecl *SetSettingInfo) (PLUGIN_SETTINGS *);
void(__cdecl *SetSettingInfo2) (PLUGIN_SETTINGS2 *);
void(__cdecl *SetSettingInfo3) (PLUGIN_SETTINGS3 *);
void * m_hDll;
bool m_Initialized, m_RomOpen;
PLUGIN_INFO m_PluginInfo;
void * m_hDll;
bool m_Initialized, m_RomOpen;
PLUGIN_INFO m_PluginInfo;
// Loads a function pointer from the currently loaded DLL
template <typename T>
void _LoadFunction(const char * szFunctionName, T & functionPointer) {
functionPointer = (T)GetProcAddress((HMODULE)m_hDll, szFunctionName);
}
// Loads a function pointer from the currently loaded DLL
template <typename T>
void _LoadFunction(const char * szFunctionName, T & functionPointer) {
functionPointer = (T)GetProcAddress((HMODULE)m_hDll, szFunctionName);
}
// Simple wrapper around _LoadFunction() to avoid having to specify the same two arguments
// i.e. _LoadFunction("CloseDLL", CloseDLL);
// Simple wrapper around _LoadFunction() to avoid having to specify the same two arguments
// i.e. _LoadFunction("CloseDLL", CloseDLL);
#define LoadFunction(functionName) _LoadFunction(#functionName, functionName)
};

View File

@ -10,36 +10,39 @@
****************************************************************************/
#include "stdafx.h"
CPlugins::CPlugins (const stdstr & PluginDir):
CPlugins::CPlugins(const stdstr & PluginDir) :
m_RenderWindow(NULL), m_DummyWindow(NULL),
m_PluginDir(PluginDir), m_Gfx(NULL), m_Audio(NULL),
m_RSP(NULL), m_Control(NULL)
m_PluginDir(PluginDir),
m_Gfx(NULL),
m_Audio(NULL),
m_RSP(NULL),
m_Control(NULL)
{
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);
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);
}
CPlugins::~CPlugins (void)
CPlugins::~CPlugins(void)
{
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);
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();
@ -47,18 +50,18 @@ CPlugins::~CPlugins (void)
DestroyControlPlugin();
}
void CPlugins::PluginChanged ( CPlugins * _this )
void CPlugins::PluginChanged(CPlugins * _this)
{
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 )
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))
{
@ -77,38 +80,38 @@ void CPlugins::PluginChanged ( CPlugins * _this )
}
template <typename plugin_type>
static void LoadPlugin (SettingID PluginSettingID, SettingID PluginVerSettingID, plugin_type * & plugin, const char * PluginDir, stdstr & FileName, TraceType TraceLevel, const char * type)
{
static void LoadPlugin(SettingID PluginSettingID, SettingID PluginVerSettingID, plugin_type * & plugin, const char * PluginDir, stdstr & FileName, TraceType TraceLevel, const char * type)
{
if (plugin != NULL)
{
return;
}
FileName = g_Settings->LoadStringVal(PluginSettingID);
CPath PluginFileName(PluginDir,FileName.c_str());
CPath PluginFileName(PluginDir, FileName.c_str());
plugin = new plugin_type();
if (plugin)
{
WriteTraceF(TraceLevel,__FUNCTION__ ": %s Loading (%s): Starting",type,(LPCTSTR)PluginFileName);
WriteTraceF(TraceLevel, __FUNCTION__ ": %s Loading (%s): Starting", type, (const char *)PluginFileName);
if (plugin->Load(PluginFileName))
{
WriteTraceF(TraceLevel,__FUNCTION__ ": %s Current Ver: %s",type,plugin->PluginName());
g_Settings->SaveString(PluginVerSettingID,plugin->PluginName());
WriteTraceF(TraceLevel, __FUNCTION__ ": %s Current Ver: %s", type, plugin->PluginName());
g_Settings->SaveString(PluginVerSettingID, plugin->PluginName());
}
else
{
WriteTraceF(TraceError,__FUNCTION__ ": Failed to load %s",(LPCTSTR)PluginFileName);
WriteTraceF(TraceError, __FUNCTION__ ": Failed to load %s", (const char *)PluginFileName);
delete plugin;
plugin = NULL;
}
WriteTraceF(TraceLevel,__FUNCTION__ ": %s Loading Done",type);
}
WriteTraceF(TraceLevel, __FUNCTION__ ": %s Loading Done", type);
}
else
{
WriteTraceF(TraceError,__FUNCTION__ ": Failed to allocate %s plugin",type);
WriteTraceF(TraceError, __FUNCTION__ ": Failed to allocate %s plugin", type);
}
}
void CPlugins::CreatePlugins( void )
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");
@ -118,9 +121,9 @@ void CPlugins::CreatePlugins( void )
//Enable debugger
if (m_RSP != NULL && m_RSP->EnableDebugging)
{
WriteTrace(TraceRSP,__FUNCTION__ ": EnableDebugging starting");
WriteTrace(TraceRSP, __FUNCTION__ ": EnableDebugging starting");
m_RSP->EnableDebugging(bHaveDebugger());
WriteTrace(TraceRSP,__FUNCTION__ ": EnableDebugging done");
WriteTrace(TraceRSP, __FUNCTION__ ": EnableDebugging done");
}
if (bHaveDebugger())
@ -129,7 +132,7 @@ void CPlugins::CreatePlugins( void )
}
}
void CPlugins::GameReset ( void )
void CPlugins::GameReset(void)
{
if (m_Gfx)
{
@ -149,67 +152,67 @@ void CPlugins::GameReset ( void )
}
}
void CPlugins::DestroyGfxPlugin( void )
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");
WriteTrace(TraceGfxPlugin, __FUNCTION__ ": before delete m_Gfx");
delete m_Gfx;
WriteTrace(TraceGfxPlugin, __FUNCTION__ ": after delete m_Gfx");
m_Gfx = NULL;
// g_Settings->UnknownSetting_GFX = NULL;
// g_Settings->UnknownSetting_GFX = NULL;
DestroyRspPlugin();
}
void CPlugins::DestroyAudioPlugin( void )
void CPlugins::DestroyAudioPlugin(void)
{
if (m_Audio == NULL)
{
return;
}
WriteTrace(TraceDebug,__FUNCTION__ ": 5");
WriteTrace(TraceDebug, __FUNCTION__ ": 5");
m_Audio->Close();
WriteTrace(TraceDebug,__FUNCTION__ ": 6");
delete m_Audio;
WriteTrace(TraceDebug,__FUNCTION__ ": 7");
WriteTrace(TraceDebug, __FUNCTION__ ": 6");
delete m_Audio;
WriteTrace(TraceDebug, __FUNCTION__ ": 7");
m_Audio = NULL;
WriteTrace(TraceDebug,__FUNCTION__ ": 8");
// g_Settings->UnknownSetting_AUDIO = NULL;
WriteTrace(TraceDebug, __FUNCTION__ ": 8");
// g_Settings->UnknownSetting_AUDIO = NULL;
DestroyRspPlugin();
}
void CPlugins::DestroyRspPlugin( void )
void CPlugins::DestroyRspPlugin(void)
{
if (m_RSP == NULL)
{
return;
}
WriteTrace(TraceDebug,__FUNCTION__ ": 9");
WriteTrace(TraceDebug, __FUNCTION__ ": 9");
m_RSP->Close();
WriteTrace(TraceDebug,__FUNCTION__ ": 10");
delete m_RSP;
WriteTrace(TraceDebug,__FUNCTION__ ": 11");
WriteTrace(TraceDebug, __FUNCTION__ ": 10");
delete m_RSP;
WriteTrace(TraceDebug, __FUNCTION__ ": 11");
m_RSP = NULL;
WriteTrace(TraceDebug,__FUNCTION__ ": 12");
// g_Settings->UnknownSetting_RSP = NULL;
WriteTrace(TraceDebug, __FUNCTION__ ": 12");
// g_Settings->UnknownSetting_RSP = NULL;
}
void CPlugins::DestroyControlPlugin( void )
void CPlugins::DestroyControlPlugin(void)
{
if (m_Control == NULL)
if (m_Control == NULL)
{
return;
}
WriteTrace(TraceDebug,__FUNCTION__ ": 13");
WriteTrace(TraceDebug, __FUNCTION__ ": 13");
m_Control->Close();
WriteTrace(TraceDebug,__FUNCTION__ ": 14");
WriteTrace(TraceDebug, __FUNCTION__ ": 14");
delete m_Control;
WriteTrace(TraceDebug,__FUNCTION__ ": 15");
WriteTrace(TraceDebug, __FUNCTION__ ": 15");
m_Control = NULL;
WriteTrace(TraceDebug,__FUNCTION__ ": 16");
// g_Settings->UnknownSetting_CTRL = NULL;
WriteTrace(TraceDebug, __FUNCTION__ ": 16");
// g_Settings->UnknownSetting_CTRL = NULL;
}
void CPlugins::SetRenderWindows( CMainGui * RenderWindow, CMainGui * DummyWindow )
@ -218,7 +221,7 @@ void CPlugins::SetRenderWindows( CMainGui * RenderWindow, CMainGui * DummyWindow
m_DummyWindow = DummyWindow;
}
void CPlugins::RomOpened ( void )
void CPlugins::RomOpened(void)
{
m_Gfx->RomOpened();
m_RSP->RomOpened();
@ -226,7 +229,7 @@ void CPlugins::RomOpened ( void )
m_Control->RomOpened();
}
void CPlugins::RomClosed ( void )
void CPlugins::RomClosed(void)
{
m_Gfx->RomClose();
m_RSP->RomClose();
@ -234,32 +237,32 @@ void CPlugins::RomClosed ( void )
m_Control->RomClose();
}
bool CPlugins::Initiate ( CN64System * System )
bool CPlugins::Initiate(CN64System * System)
{
WriteTrace(TraceDebug,__FUNCTION__ ": Start");
WriteTrace(TraceDebug, __FUNCTION__ ": Start");
//Check to make sure we have the plugin available to be used
if (m_Gfx == NULL) { return false; }
if (m_Gfx == NULL) { return false; }
if (m_Audio == NULL) { return false; }
if (m_RSP == NULL) { return false; }
if (m_RSP == NULL) { return false; }
if (m_Control == NULL) { return false; }
WriteTrace(TraceGfxPlugin,__FUNCTION__ ": Gfx Initiate Starting");
WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Gfx Initiate Starting");
if (!m_Gfx->Initiate(System,m_RenderWindow)) { return false; }
WriteTrace(TraceGfxPlugin,__FUNCTION__ ": Gfx Initiate Done");
WriteTrace(TraceDebug,__FUNCTION__ ": Audio Initiate Starting");
WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Gfx Initiate Done");
WriteTrace(TraceDebug, __FUNCTION__ ": Audio Initiate Starting");
if (!m_Audio->Initiate(System,m_RenderWindow)) { return false; }
WriteTrace(TraceDebug,__FUNCTION__ ": Audio Initiate Done");
WriteTrace(TraceDebug, __FUNCTION__ ": Audio Initiate Done");
WriteTrace(TraceDebug, __FUNCTION__ ": Control Initiate Starting");
if (!m_Control->Initiate(System,m_RenderWindow)) { return false; }
WriteTrace(TraceDebug, __FUNCTION__ ": Control Initiate Done");
WriteTrace(TraceRSP,__FUNCTION__ ": RSP Initiate Starting");
if (!m_RSP->Initiate(this,System)) { return false; }
WriteTrace(TraceRSP,__FUNCTION__ ": RSP Initiate Done");
WriteTrace(TraceDebug,__FUNCTION__ ": Done");
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;
}
bool CPlugins::ResetInUiThread ( CN64System * System )
bool CPlugins::ResetInUiThread(CN64System * System)
{
#if defined(WINDOWS_UI)
return m_RenderWindow->ResetPlugins(this, System);
@ -269,14 +272,14 @@ bool CPlugins::ResetInUiThread ( CN64System * System )
#endif
}
bool CPlugins::Reset ( CN64System * System )
bool CPlugins::Reset(CN64System * System)
{
WriteTrace(TraceDebug,__FUNCTION__ ": Start");
WriteTrace(TraceDebug, __FUNCTION__ ": Start");
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;
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)
@ -289,17 +292,17 @@ bool CPlugins::Reset ( CN64System * System )
CreatePlugins();
if (m_Gfx && bGfxChange)
if (m_Gfx && bGfxChange)
{
WriteTrace(TraceGfxPlugin,__FUNCTION__ ": Gfx Initiate Starting");
WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Gfx Initiate Starting");
if (!m_Gfx->Initiate(System,m_RenderWindow)) { return false; }
WriteTrace(TraceGfxPlugin,__FUNCTION__ ": Gfx Initiate Done");
WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Gfx Initiate Done");
}
if (m_Audio && bAudioChange)
if (m_Audio && bAudioChange)
{
WriteTrace(TraceDebug,__FUNCTION__ ": Audio Initiate Starting");
WriteTrace(TraceDebug, __FUNCTION__ ": Audio Initiate Starting");
if (!m_Audio->Initiate(System,m_RenderWindow)) { return false; }
WriteTrace(TraceDebug,__FUNCTION__ ": Audio Initiate Done");
WriteTrace(TraceDebug, __FUNCTION__ ": Audio Initiate Done");
}
if (m_Control && bContChange)
{
@ -307,22 +310,26 @@ bool CPlugins::Reset ( CN64System * System )
if (!m_Control->Initiate(System,m_RenderWindow)) { return false; }
WriteTrace(TraceDebug, __FUNCTION__ ": Control Initiate Done");
}
if (m_RSP && bRspChange)
if (m_RSP && bRspChange)
{
WriteTrace(TraceRSP,__FUNCTION__ ": RSP Initiate Starting");
if (!m_RSP->Initiate(this,System)) { return false; }
WriteTrace(TraceRSP,__FUNCTION__ ": RSP Initiate Done");
WriteTrace(TraceRSP, __FUNCTION__ ": RSP Initiate Starting");
if (!m_RSP->Initiate(this, System)) { return false; }
WriteTrace(TraceRSP, __FUNCTION__ ": RSP Initiate Done");
}
WriteTrace(TraceDebug,__FUNCTION__ ": Done");
WriteTrace(TraceDebug, __FUNCTION__ ": Done");
return true;
}
void CPlugins::ConfigPlugin ( DWORD hParent, PLUGIN_TYPE Type ) {
switch (Type) {
void CPlugins::ConfigPlugin(uint32_t hParent, PLUGIN_TYPE Type)
{
switch (Type)
{
case PLUGIN_TYPE_RSP:
if (m_RSP == NULL || m_RSP->DllConfig == NULL) { break; }
if (!m_RSP->Initialized()) {
if (!m_RSP->Initiate(NULL,NULL)) {
if (!m_RSP->Initialized())
{
if (!m_RSP->Initiate(NULL, NULL))
{
break;
}
}
@ -330,8 +337,10 @@ void CPlugins::ConfigPlugin ( DWORD hParent, PLUGIN_TYPE Type ) {
break;
case PLUGIN_TYPE_GFX:
if (m_Gfx == NULL || m_Gfx->DllConfig == NULL) { break; }
if (!m_Gfx->Initialized()) {
if (!m_Gfx->Initiate(NULL,m_DummyWindow)) {
if (!m_Gfx->Initialized())
{
if (!m_Gfx->Initiate(NULL, NULL))
{
break;
}
}
@ -339,8 +348,10 @@ void CPlugins::ConfigPlugin ( DWORD hParent, PLUGIN_TYPE Type ) {
break;
case PLUGIN_TYPE_AUDIO:
if (m_Audio == NULL || m_Audio->DllConfig == NULL) { break; }
if (!m_Audio->Initialized()) {
if (!m_Audio->Initiate(NULL,m_DummyWindow)) {
if (!m_Audio->Initialized())
{
if (!m_Audio->Initiate(NULL, NULL))
{
break;
}
}
@ -348,8 +359,10 @@ void CPlugins::ConfigPlugin ( DWORD hParent, PLUGIN_TYPE Type ) {
break;
case PLUGIN_TYPE_CONTROLLER:
if (m_Control == NULL || m_Control->DllConfig == NULL) { break; }
if (!m_Control->Initialized()) {
if (!m_Control->Initiate(NULL,m_DummyWindow)) {
if (!m_Control->Initialized())
{
if (!m_Control->Initiate(NULL, NULL))
{
break;
}
}
@ -358,76 +371,63 @@ void CPlugins::ConfigPlugin ( DWORD hParent, PLUGIN_TYPE Type ) {
}
}
void DummyCheckInterrupts ( void ) {
void DummyCheckInterrupts(void)
{
}
void DummyFunction (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);
}
}
bool CPlugins::CopyPlugins ( const stdstr & DstDir ) const
{
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());
if (CopyFile(srcGfxPlugin,dstGfxPlugin,false) == 0)
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())
{
if (GetLastError() == ERROR_PATH_NOT_FOUND) { dstGfxPlugin.DirectoryCreate(); }
if (!CopyFile(srcGfxPlugin,dstGfxPlugin,false))
{
return false;
}
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 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 (CopyFile(srcAudioPlugin,dstAudioPlugin,false) == 0) {
if (GetLastError() == ERROR_PATH_NOT_FOUND) { dstAudioPlugin.DirectoryCreate(); }
if (!CopyFile(srcAudioPlugin,dstAudioPlugin,false))
{
return false;
}
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 (CopyFile(srcRSPPlugin,dstRSPPlugin,false) == 0) {
if (GetLastError() == ERROR_PATH_NOT_FOUND) { dstRSPPlugin.DirectoryCreate(); }
if (!CopyFile(srcRSPPlugin,dstRSPPlugin,false))
{
return false;
}
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());
CPath dstContPlugin(DstDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Controller).c_str());
if (!dstContPlugin.DirectoryExists())
{
dstContPlugin.DirectoryCreate();
}
if (!srcContPlugin.CopyTo(dstContPlugin))
{
if (GetLastError() == ERROR_PATH_NOT_FOUND) { dstContPlugin.DirectoryCreate(); }
if (!CopyFile(srcContPlugin,dstContPlugin,false))
{
DWORD dwError = GetLastError();
dwError = dwError;
return false;
}
return false;
}
return true;
}

View File

@ -11,137 +11,133 @@
#pragma once
#include <list>
typedef int BOOL;
typedef unsigned char BYTE;
typedef unsigned short WORD;
typedef unsigned long DWORD;
typedef unsigned __int64 QWORD;
#ifndef PLUGIN_INFO_STRUCT
#define PLUGIN_INFO_STRUCT
typedef struct {
WORD Version; /* Should be set to 1 */
WORD Type; /* Set to PLUGIN_TYPE_GFX */
char Name[100]; /* Name of the DLL */
typedef struct
{
uint16_t Version; /* Should be set to 1 */
uint16_t Type; /* Set to PLUGIN_TYPE_GFX */
char Name[100]; /* Name of the DLL */
/* If DLL supports memory these memory options then set them to TRUE or FALSE
if it does not support it */
BOOL NormalMemory; /* a normal BYTE array */
BOOL MemoryBswaped; /* a normal BYTE array where the memory has been pre
bswap on a dword (32 bits) boundry */
/* If DLL supports memory these memory options then set them to TRUE or FALSE
if it does not support it */
int32_t NormalMemory; /* a normal BYTE array */
int32_t MemoryBswaped; /* a normal BYTE array where the memory has been pre
bswap on a dword (32 bits) boundry */
} PLUGIN_INFO;
#endif
// enum's
enum SETTING_DATA_TYPE {
Data_DWORD_General = 0, // A unsigned int setting used anywhere
Data_String_General = 1, // A string setting used anywhere
Data_DWORD_Game = 2, // A unsigned int associated with the current game
Data_String_Game = 3, // A string associated with the current game
Data_DWORD_RDB = 4, // A unsigned int associated with the current game in the rom database
Data_String_RDB = 5, // A string associated with the current game in the rom database
Data_DWORD_RDB_Setting = 6, // A unsigned int read from the rom database, with config file
Data_String_RDB_Setting = 7, // A string read from the rom database, with config file
enum SETTING_DATA_TYPE
{
Data_DWORD_General = 0, // A uint32_t setting used anywhere
Data_String_General = 1, // A string setting used anywhere
Data_DWORD_Game = 2, // A uint32_t associated with the current game
Data_String_Game = 3, // A string associated with the current game
Data_DWORD_RDB = 4, // A uint32_t associated with the current game in the rom database
Data_String_RDB = 5, // A string associated with the current game in the rom database
Data_DWORD_RDB_Setting = 6, // A uint32_t read from the rom database, with config file
Data_String_RDB_Setting = 7, // A string read from the rom database, with config file
};
typedef struct {
DWORD dwSize;
int DefaultStartRange;
int SettingStartRange;
int MaximumSettings;
int NoDefault;
int DefaultLocation;
void * handle;
unsigned int (*GetSetting) ( void * handle, int ID );
const char * (*GetSettingSz) ( void * handle, int ID, char * Buffer, int BufferLen );
void (*SetSetting) ( void * handle, int ID, unsigned int Value );
void (*SetSettingSz) ( void * handle, int ID, const char * Value );
void (*RegisterSetting) ( void * handle, int ID, int DefaultID, SettingDataType Type,
SettingType Location, const char * Category, const char * DefaultStr, DWORD Value );
void (*UseUnregisteredSetting) (int ID);
typedef struct
{
uint32_t dwSize;
int32_t DefaultStartRange;
int32_t SettingStartRange;
int32_t MaximumSettings;
int32_t NoDefault;
int32_t DefaultLocation;
void * handle;
uint32_t(*GetSetting) (void * handle, int32_t ID);
const char * (*GetSettingSz) (void * handle, int32_t ID, char * Buffer, int32_t BufferLen);
void(*SetSetting) (void * handle, int32_t ID, uint32_t Value);
void(*SetSettingSz) (void * handle, int32_t ID, const char * Value);
void(*RegisterSetting) (void * handle, int32_t ID, int32_t DefaultID, SettingDataType Type,
SettingType Location, const char * Category, const char * DefaultStr, uint32_t Value);
void(*UseUnregisteredSetting) (int32_t ID);
} PLUGIN_SETTINGS;
typedef struct {
unsigned int (*FindSystemSettingId) ( void * handle, const char * Name );
typedef struct
{
uint32_t(*FindSystemSettingId) (void * handle, const char * Name);
} PLUGIN_SETTINGS2;
typedef struct {
void (*FlushSettings) ( void * handle );
typedef struct
{
void(*FlushSettings) (void * handle);
} PLUGIN_SETTINGS3;
enum PLUGIN_TYPE {
PLUGIN_TYPE_NONE = 0,
PLUGIN_TYPE_RSP = 1,
PLUGIN_TYPE_GFX = 2,
PLUGIN_TYPE_AUDIO = 3,
PLUGIN_TYPE_CONTROLLER = 4,
enum PLUGIN_TYPE
{
PLUGIN_TYPE_NONE = 0,
PLUGIN_TYPE_RSP = 1,
PLUGIN_TYPE_GFX = 2,
PLUGIN_TYPE_AUDIO = 3,
PLUGIN_TYPE_CONTROLLER = 4,
};
class CSettings;
class CSettings;
class CMainGui;
class CGfxPlugin; class CAudioPlugin; class CRSP_Plugin; class CControl_Plugin;
class CPlugins :
private CDebugSettings
private CDebugSettings
{
public:
//Functions
CPlugins (const stdstr & PluginDir );
~CPlugins ();
//Functions
CPlugins(const stdstr & PluginDir);
~CPlugins();
bool Initiate ( CN64System * System );
void RomOpened ( void );
void RomClosed ( void );
bool Initiate(CN64System * System);
void RomOpened(void);
void RomClosed(void);
void SetRenderWindows ( CMainGui * RenderWindow, CMainGui * DummyWindow );
void ConfigPlugin ( DWORD hParent, PLUGIN_TYPE Type );
bool CopyPlugins ( const stdstr & DstDir ) const;
void CreatePlugins ( void );
bool Reset ( CN64System * System );
bool ResetInUiThread ( CN64System * System );
void GameReset ( void );
void ConfigPlugin(uint32_t hParent, PLUGIN_TYPE Type);
bool CopyPlugins(const stdstr & DstDir) const;
void CreatePlugins(void);
bool Reset(CN64System * System);
bool ResetInUiThread(CN64System * System);
void GameReset(void);
inline CGfxPlugin * Gfx(void) const { return m_Gfx; }
inline CAudioPlugin * Audio(void) const { return m_Audio; }
inline CRSP_Plugin * RSP(void) const { return m_RSP; }
inline CControl_Plugin * Control(void) const { return m_Control; }
inline CGfxPlugin * Gfx ( void) const { return m_Gfx; };
inline CAudioPlugin * Audio ( void) const { return m_Audio; };
inline CRSP_Plugin * RSP ( void) const { return m_RSP; };
inline CControl_Plugin * Control ( void) const { return m_Control; };
private:
CPlugins(void); // Disable default constructor
CPlugins(const CPlugins&); // Disable copy constructor
CPlugins& operator=(const CPlugins&); // Disable assignment
CPlugins(void); // Disable default constructor
CPlugins(const CPlugins&); // Disable copy constructor
CPlugins& operator=(const CPlugins&); // Disable assignment
// void Reset ( PLUGIN_TYPE Type );
void DestroyGfxPlugin(void);
void DestroyAudioPlugin(void);
void DestroyRspPlugin(void);
void DestroyControlPlugin(void);
void CreatePluginDir ( const stdstr & DstDir ) const;
static void PluginChanged(CPlugins * _this);
void DestroyGfxPlugin ( void );
void DestroyAudioPlugin ( void );
void DestroyRspPlugin ( void );
void DestroyControlPlugin ( void );
static void PluginChanged ( CPlugins * _this );
//Common Classes
CMainGui * m_RenderWindow;
CMainGui * m_DummyWindow;
stdstr const m_PluginDir;
stdstr const m_PluginDir;
//Plugins
CGfxPlugin * m_Gfx;
CAudioPlugin * m_Audio;
CRSP_Plugin * m_RSP;
CControl_Plugin * m_Control;
//Plugins
CGfxPlugin * m_Gfx;
CAudioPlugin * m_Audio;
CRSP_Plugin * m_RSP;
CControl_Plugin * m_Control;
stdstr m_GfxFile;
stdstr m_AudioFile;
stdstr m_RSPFile;
stdstr m_ControlFile;
stdstr m_GfxFile;
stdstr m_AudioFile;
stdstr m_RSPFile;
stdstr m_ControlFile;
};
//Dummy Functions
void DummyCheckInterrupts ( void );
void DummyFunction (void);
void DummyCheckInterrupts(void);
void DummyFunction(void);

View File

@ -10,202 +10,202 @@
****************************************************************************/
#include "stdafx.h"
void DummyFunc1(BOOL /*a*/) {}
void DummyFunc1(int a) { a += 1;}
CRSP_Plugin::CRSP_Plugin(void) :
DoRspCycles(NULL),
EnableDebugging(NULL),
m_CycleCount(0),
GetDebugInfo(NULL),
InitiateDebugger(NULL)
DoRspCycles(NULL),
EnableDebugging(NULL),
m_CycleCount(0),
GetDebugInfo(NULL),
InitiateDebugger(NULL)
{
memset(&m_RSPDebug, 0, sizeof(m_RSPDebug));
memset(&m_RSPDebug, 0, sizeof(m_RSPDebug));
}
CRSP_Plugin::~CRSP_Plugin()
{
Close();
UnloadPlugin();
Close();
UnloadPlugin();
}
bool CRSP_Plugin::LoadFunctions ( void )
bool CRSP_Plugin::LoadFunctions(void)
{
// Find entries for functions in DLL
void (__cdecl *InitiateRSP)( void );
LoadFunction(InitiateRSP);
LoadFunction(DoRspCycles);
_LoadFunction("GetRspDebugInfo", GetDebugInfo);
_LoadFunction("InitiateRSPDebugger", InitiateDebugger);
LoadFunction(EnableDebugging);
if (EnableDebugging == NULL) { EnableDebugging = DummyFunc1; }
// Find entries for functions in DLL
void(__cdecl *InitiateRSP)(void);
LoadFunction(InitiateRSP);
LoadFunction(DoRspCycles);
_LoadFunction("GetRspDebugInfo", GetDebugInfo);
_LoadFunction("InitiateRSPDebugger", InitiateDebugger);
LoadFunction(EnableDebugging);
if (EnableDebugging == NULL) { EnableDebugging = DummyFunc1; }
//Make sure dll had all needed functions
if (DoRspCycles == NULL) { UnloadPlugin(); return false; }
if (InitiateRSP == NULL) { UnloadPlugin(); return false; }
if (RomClosed == NULL) { UnloadPlugin(); return false; }
if (CloseDLL == NULL) { UnloadPlugin(); return false; }
//Make sure dll had all needed functions
if (DoRspCycles == NULL) { UnloadPlugin(); return false; }
if (InitiateRSP == NULL) { UnloadPlugin(); return false; }
if (RomClosed == NULL) { UnloadPlugin(); return false; }
if (CloseDLL == NULL) { UnloadPlugin(); return false; }
if (m_PluginInfo.Version >= 0x0102)
{
if (PluginOpened == NULL) { UnloadPlugin(); return false; }
}
if (m_PluginInfo.Version >= 0x0102)
{
if (PluginOpened == NULL) { UnloadPlugin(); return false; }
}
// Get debug info if able
if (GetDebugInfo != NULL)
GetDebugInfo(&m_RSPDebug);
// Get debug info if able
if (GetDebugInfo != NULL)
GetDebugInfo(&m_RSPDebug);
return true;
return true;
}
bool CRSP_Plugin::Initiate(CPlugins * Plugins, CN64System * System)
{
if (m_PluginInfo.Version == 1 || m_PluginInfo.Version == 0x100)
{
return false;
}
if (m_PluginInfo.Version == 1 || m_PluginInfo.Version == 0x100)
{
return false;
}
typedef struct
{
HINSTANCE hInst;
BOOL MemoryBswaped; /* If this is set to TRUE, then the memory has been pre
bswap on a dword (32 bits) boundry */
BYTE * RDRAM;
BYTE * DMEM;
BYTE * IMEM;
typedef struct
{
HINSTANCE hInst;
int MemoryBswaped; /* If this is set to TRUE, then the memory has been pre
bswap on a dword (32 bits) boundry */
uint8_t * RDRAM;
uint8_t * DMEM;
uint8_t * IMEM;
DWORD * MI__INTR_REG;
uint32_t * MI__INTR_REG;
DWORD * SP__MEM_ADDR_REG;
DWORD * SP__DRAM_ADDR_REG;
DWORD * SP__RD_LEN_REG;
DWORD * SP__WR_LEN_REG;
DWORD * SP__STATUS_REG;
DWORD * SP__DMA_FULL_REG;
DWORD * SP__DMA_BUSY_REG;
DWORD * SP__PC_REG;
DWORD * SP__SEMAPHORE_REG;
uint32_t * SP__MEM_ADDR_REG;
uint32_t * SP__DRAM_ADDR_REG;
uint32_t * SP__RD_LEN_REG;
uint32_t * SP__WR_LEN_REG;
uint32_t * SP__STATUS_REG;
uint32_t * SP__DMA_FULL_REG;
uint32_t * SP__DMA_BUSY_REG;
uint32_t * SP__PC_REG;
uint32_t * SP__SEMAPHORE_REG;
DWORD * DPC__START_REG;
DWORD * DPC__END_REG;
DWORD * DPC__CURRENT_REG;
DWORD * DPC__STATUS_REG;
DWORD * DPC__CLOCK_REG;
DWORD * DPC__BUFBUSY_REG;
DWORD * DPC__PIPEBUSY_REG;
DWORD * DPC__TMEM_REG;
uint32_t * DPC__START_REG;
uint32_t * DPC__END_REG;
uint32_t * DPC__CURRENT_REG;
uint32_t * DPC__STATUS_REG;
uint32_t * DPC__CLOCK_REG;
uint32_t * DPC__BUFBUSY_REG;
uint32_t * DPC__PIPEBUSY_REG;
uint32_t * DPC__TMEM_REG;
void ( __cdecl *CheckInterrupts)( void );
void (__cdecl *ProcessDlist)( void );
void (__cdecl *ProcessAlist)( void );
void (__cdecl *ProcessRdpList)( void );
void (__cdecl *ShowCFB)( void );
} RSP_INFO_1_1;
void(__cdecl *CheckInterrupts)(void);
void(__cdecl *ProcessDlist)(void);
void(__cdecl *ProcessAlist)(void);
void(__cdecl *ProcessRdpList)(void);
void(__cdecl *ShowCFB)(void);
} RSP_INFO_1_1;
RSP_INFO_1_1 Info = { 0 };
RSP_INFO_1_1 Info = { 0 };
Info.hInst = GetModuleHandle(NULL);
Info.CheckInterrupts = DummyCheckInterrupts;
Info.MemoryBswaped = (System == NULL); // only true when the system's not yet loaded
Info.hInst = GetModuleHandle(NULL);
Info.CheckInterrupts = DummyCheckInterrupts;
Info.MemoryBswaped = (System == NULL); // only true when the system's not yet loaded
//Get Function from DLL
void (__cdecl *InitiateRSP) ( RSP_INFO_1_1 Audio_Info,DWORD * Cycles );
LoadFunction(InitiateRSP);
if (InitiateRSP == NULL) { return false; }
//Get Function from DLL
void(__cdecl *InitiateRSP) (RSP_INFO_1_1 Audio_Info, uint32_t * Cycles);
LoadFunction(InitiateRSP);
if (InitiateRSP == NULL) { 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.
if (System == NULL)
{
BYTE Buffer[100];
DWORD Value = 0;
// 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.
if (System == NULL)
{
uint8_t Buffer[100];
uint32_t Value = 0;
Info.ProcessDlist = DummyCheckInterrupts;
Info.ProcessRdpList = DummyCheckInterrupts;
Info.ShowCFB = DummyCheckInterrupts;
Info.ProcessAlist = DummyCheckInterrupts;
Info.ProcessDlist = DummyCheckInterrupts;
Info.ProcessRdpList = DummyCheckInterrupts;
Info.ShowCFB = DummyCheckInterrupts;
Info.ProcessAlist = DummyCheckInterrupts;
Info.RDRAM = Buffer;
Info.DMEM = Buffer;
Info.IMEM = Buffer;
Info.RDRAM = Buffer;
Info.DMEM = Buffer;
Info.IMEM = Buffer;
Info.MI__INTR_REG = &Value;
Info.MI__INTR_REG = &Value;
Info.SP__MEM_ADDR_REG = &Value;
Info.SP__DRAM_ADDR_REG = &Value;
Info.SP__RD_LEN_REG = &Value;
Info.SP__WR_LEN_REG = &Value;
Info.SP__STATUS_REG = &Value;
Info.SP__DMA_FULL_REG = &Value;
Info.SP__DMA_BUSY_REG = &Value;
Info.SP__PC_REG = &Value;
Info.SP__SEMAPHORE_REG = &Value;
Info.SP__MEM_ADDR_REG = &Value;
Info.SP__DRAM_ADDR_REG = &Value;
Info.SP__RD_LEN_REG = &Value;
Info.SP__WR_LEN_REG = &Value;
Info.SP__STATUS_REG = &Value;
Info.SP__DMA_FULL_REG = &Value;
Info.SP__DMA_BUSY_REG = &Value;
Info.SP__PC_REG = &Value;
Info.SP__SEMAPHORE_REG = &Value;
Info.DPC__START_REG = &Value;
Info.DPC__END_REG = &Value;
Info.DPC__CURRENT_REG = &Value;
Info.DPC__STATUS_REG = &Value;
Info.DPC__CLOCK_REG = &Value;
Info.DPC__BUFBUSY_REG = &Value;
Info.DPC__PIPEBUSY_REG = &Value;
Info.DPC__TMEM_REG = &Value;
}
// Send initialization information to the DLL
else
{
Info.ProcessDlist = Plugins->Gfx()->ProcessDList;
Info.ProcessRdpList = Plugins->Gfx()->ProcessRDPList;
Info.ShowCFB = Plugins->Gfx()->ShowCFB;
Info.ProcessAlist = Plugins->Audio()->ProcessAList;
Info.DPC__START_REG = &Value;
Info.DPC__END_REG = &Value;
Info.DPC__CURRENT_REG = &Value;
Info.DPC__STATUS_REG = &Value;
Info.DPC__CLOCK_REG = &Value;
Info.DPC__BUFBUSY_REG = &Value;
Info.DPC__PIPEBUSY_REG = &Value;
Info.DPC__TMEM_REG = &Value;
}
// Send initialization information to the DLL
else
{
Info.ProcessDlist = Plugins->Gfx()->ProcessDList;
Info.ProcessRdpList = Plugins->Gfx()->ProcessRDPList;
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();
Info.RDRAM = g_MMU->Rdram();
Info.DMEM = g_MMU->Dmem();
Info.IMEM = g_MMU->Imem();
Info.MI__INTR_REG = &g_Reg->m_RspIntrReg;
Info.MI__INTR_REG = (uint32_t *)&g_Reg->m_RspIntrReg;
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.SP__MEM_ADDR_REG = (uint32_t *)&g_Reg->SP_MEM_ADDR_REG;
Info.SP__DRAM_ADDR_REG = (uint32_t *)&g_Reg->SP_DRAM_ADDR_REG;
Info.SP__RD_LEN_REG = (uint32_t *)&g_Reg->SP_RD_LEN_REG;
Info.SP__WR_LEN_REG = (uint32_t *)&g_Reg->SP_WR_LEN_REG;
Info.SP__STATUS_REG = (uint32_t *)&g_Reg->SP_STATUS_REG;
Info.SP__DMA_FULL_REG = (uint32_t *)&g_Reg->SP_DMA_FULL_REG;
Info.SP__DMA_BUSY_REG = (uint32_t *)&g_Reg->SP_DMA_BUSY_REG;
Info.SP__PC_REG = (uint32_t *)&g_Reg->SP_PC_REG;
Info.SP__SEMAPHORE_REG = (uint32_t *)&g_Reg->SP_SEMAPHORE_REG;
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.DPC__START_REG = (uint32_t *)&g_Reg->DPC_START_REG;
Info.DPC__END_REG = (uint32_t *)&g_Reg->DPC_END_REG;
Info.DPC__CURRENT_REG = (uint32_t *)&g_Reg->DPC_CURRENT_REG;
Info.DPC__STATUS_REG = (uint32_t *)&g_Reg->DPC_STATUS_REG;
Info.DPC__CLOCK_REG = (uint32_t *)&g_Reg->DPC_CLOCK_REG;
Info.DPC__BUFBUSY_REG = (uint32_t *)&g_Reg->DPC_BUFBUSY_REG;
Info.DPC__PIPEBUSY_REG = (uint32_t *)&g_Reg->DPC_PIPEBUSY_REG;
Info.DPC__TMEM_REG = (uint32_t *)&g_Reg->DPC_TMEM_REG;
}
InitiateRSP(Info, &m_CycleCount);
m_Initialized = true;
InitiateRSP(Info, &m_CycleCount);
m_Initialized = true;
//jabo had a bug so I call CreateThread so his dllmain gets called again
DWORD ThreadID;
HANDLE hthread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)DummyFunction, NULL, 0, &ThreadID);
CloseHandle(hthread);
return m_Initialized;
//jabo had a bug so I call CreateThread so his dllmain gets called again
DWORD ThreadID;
HANDLE hthread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)DummyFunction, NULL, 0, &ThreadID);
CloseHandle(hthread);
return m_Initialized;
}
void CRSP_Plugin::UnloadPluginDetails(void)
void CRSP_Plugin::UnloadPluginDetails(void)
{
memset(&m_RSPDebug, 0, sizeof(m_RSPDebug));
DoRspCycles = NULL;
EnableDebugging = NULL;
GetDebugInfo = NULL;
InitiateDebugger = NULL;
memset(&m_RSPDebug, 0, sizeof(m_RSPDebug));
DoRspCycles = NULL;
EnableDebugging = NULL;
GetDebugInfo = NULL;
InitiateDebugger = NULL;
}
void CRSP_Plugin::ProcessMenuItem(int id)
{
if (m_RSPDebug.ProcessMenuItem)
{
m_RSPDebug.ProcessMenuItem(id);
}
if (m_RSPDebug.ProcessMenuItem)
{
m_RSPDebug.ProcessMenuItem(id);
}
}

View File

@ -9,68 +9,68 @@
* *
****************************************************************************/
#pragma once
#include "Plugin Base.h"
class CRSP_Plugin : public CPlugin
{
typedef struct {
/* Menu */
/* Items should have an ID between 5001 and 5100 */
HMENU hRSPMenu;
void (__cdecl *ProcessMenuItem) ( int ID );
typedef struct {
/* Menu */
/* Items should have an ID between 5001 and 5100 */
void * hRSPMenu;
void(__cdecl *ProcessMenuItem) (int32_t ID);
/* Break Points */
BOOL UseBPoints;
char BPPanelName[20];
void (__cdecl *Add_BPoint) ( void );
void (__cdecl *CreateBPPanel) ( HMENU hDlg, RECT_STRUCT rcBox );
void (__cdecl *HideBPPanel) ( void );
void (__cdecl *PaintBPPanel) ( WINDOWS_PAINTSTRUCT ps );
void (__cdecl *ShowBPPanel) ( void );
void (__cdecl *RefreshBpoints) ( HMENU hList );
void (__cdecl *RemoveBpoint) ( HMENU hList, int index );
void (__cdecl *RemoveAllBpoint) ( void );
/* RSP command Window */
void (__cdecl *Enter_RSP_Commands_Window) ( void );
} RSPDEBUG_INFO;
/* Break Points */
int32_t UseBPoints;
char BPPanelName[20];
void(__cdecl *Add_BPoint) (void);
void(__cdecl *CreateBPPanel) (void);
void(__cdecl *HideBPPanel) (void);
void(__cdecl *PaintBPPanel) (void);
void(__cdecl *ShowBPPanel) (void);
void(__cdecl *RefreshBpoints) (void * hList);
void(__cdecl *RemoveBpoint) (void * hList, int32_t index);
void(__cdecl *RemoveAllBpoint) (void);
/* RSP command Window */
void(__cdecl *Enter_RSP_Commands_Window) (void);
} RSPDEBUG_INFO;
typedef struct {
void (__cdecl *UpdateBreakPoints)( void );
void (__cdecl *UpdateMemory)( void );
void (__cdecl *UpdateR4300iRegisters)( void );
void (__cdecl *Enter_BPoint_Window)( void );
void (__cdecl *Enter_R4300i_Commands_Window)( void );
void (__cdecl *Enter_R4300i_Register_Window)( void );
void (__cdecl *Enter_RSP_Commands_Window) ( void );
void (__cdecl *Enter_Memory_Window)( void );
} DEBUG_INFO;
typedef struct {
void(__cdecl *UpdateBreakPoints)(void);
void(__cdecl *UpdateMemory)(void);
void(__cdecl *UpdateR4300iRegisters)(void);
void(__cdecl *Enter_BPoint_Window)(void);
void(__cdecl *Enter_R4300i_Commands_Window)(void);
void(__cdecl *Enter_R4300i_Register_Window)(void);
void(__cdecl *Enter_RSP_Commands_Window) (void);
void(__cdecl *Enter_Memory_Window)(void);
} DEBUG_INFO;
public:
CRSP_Plugin(void);
~CRSP_Plugin();
CRSP_Plugin(void);
~CRSP_Plugin();
bool Initiate(CPlugins * Plugins, CN64System * System);
bool Initiate(CPlugins * Plugins, CN64System * System);
DWORD(__cdecl *DoRspCycles) (DWORD);
void(__cdecl *EnableDebugging)(BOOL Enable);
uint32_t(__cdecl *DoRspCycles) (uint32_t);
void(__cdecl *EnableDebugging)(int32_t Enable);
HMENU GetDebugMenu (void ) { return m_RSPDebug.hRSPMenu; }
void ProcessMenuItem(int id);
void * GetDebugMenu(void) { return m_RSPDebug.hRSPMenu; }
void ProcessMenuItem(int32_t id);
private:
CRSP_Plugin(const CRSP_Plugin&); // Disable copy constructor
CRSP_Plugin& operator=(const CRSP_Plugin&); // Disable assignment
CRSP_Plugin(const CRSP_Plugin&); // Disable copy constructor
CRSP_Plugin& operator=(const CRSP_Plugin&); // Disable assignment
PLUGIN_TYPE type() { return PLUGIN_TYPE_RSP; }
virtual int GetDefaultSettingStartRange() const { return FirstRSPDefaultSet; }
virtual int GetSettingStartRange() const { return FirstRSPSettings; }
PLUGIN_TYPE type() { return PLUGIN_TYPE_RSP; }
virtual int32_t GetDefaultSettingStartRange() const { return FirstRSPDefaultSet; }
virtual int32_t GetSettingStartRange() const { return FirstRSPSettings; }
bool LoadFunctions ( void );
void UnloadPluginDetails ( void );
bool LoadFunctions(void);
void UnloadPluginDetails(void);
RSPDEBUG_INFO m_RSPDebug;
DWORD m_CycleCount;
RSPDEBUG_INFO m_RSPDebug;
uint32_t m_CycleCount;
void(__cdecl *GetDebugInfo) (RSPDEBUG_INFO * GFXDebugInfo);
void(__cdecl *InitiateDebugger) (DEBUG_INFO DebugInfo);
void(__cdecl *GetDebugInfo) (RSPDEBUG_INFO * GFXDebugInfo);
void(__cdecl *InitiateDebugger) (DEBUG_INFO DebugInfo);
};