Clean up gfx plugin
This commit is contained in:
parent
0632516c41
commit
28113945e8
|
@ -2,27 +2,55 @@
|
||||||
|
|
||||||
void FixUPXIssue ( BYTE * ProgramLocation );
|
void FixUPXIssue ( BYTE * ProgramLocation );
|
||||||
|
|
||||||
CGfxPlugin::CGfxPlugin ( const char * FileName) {
|
CGfxPlugin::CGfxPlugin ( const char * FileName) :
|
||||||
//Make sure all parts of the class are initialized
|
CaptureScreen(NULL),
|
||||||
m_Initilized = false;
|
ChangeWindow(NULL),
|
||||||
m_RomOpen = false;
|
Config(NULL),
|
||||||
hDll = NULL;
|
DrawScreen(NULL),
|
||||||
UnloadPlugin();
|
DrawStatus(NULL),
|
||||||
|
MoveScreen(NULL),
|
||||||
|
ProcessDList(NULL),
|
||||||
|
ProcessRDPList(NULL),
|
||||||
|
ShowCFB(NULL),
|
||||||
|
UpdateScreen(NULL),
|
||||||
|
ViStatusChanged(NULL),
|
||||||
|
ViWidthChanged(NULL),
|
||||||
|
SoftReset(NULL),
|
||||||
|
GetRomBrowserMenu(NULL),
|
||||||
|
OnRomBrowserMenuItem(NULL),
|
||||||
|
CloseDLL(NULL),
|
||||||
|
RomOpen(NULL),
|
||||||
|
RomClosed(NULL),
|
||||||
|
GetDebugInfo(NULL),
|
||||||
|
InitiateDebugger(NULL),
|
||||||
|
PluginOpened(NULL),
|
||||||
|
SetSettingInfo(NULL),
|
||||||
|
SetSettingInfo2(NULL),
|
||||||
|
m_hDll(NULL),
|
||||||
|
m_Initilized(false),
|
||||||
|
m_RomOpen(false)
|
||||||
|
{
|
||||||
|
memset(&m_GFXDebug,0,sizeof(m_GFXDebug));
|
||||||
|
memset(&m_PluginInfo,0,sizeof(m_PluginInfo));
|
||||||
|
Init(FileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGfxPlugin::Init ( const char * FileName )
|
||||||
|
{
|
||||||
//Try to load the DLL library
|
//Try to load the DLL library
|
||||||
UINT LastErrorMode = SetErrorMode( SEM_FAILCRITICALERRORS );
|
UINT LastErrorMode = SetErrorMode( SEM_FAILCRITICALERRORS );
|
||||||
hDll = LoadLibrary(FileName);
|
m_hDll = LoadLibrary(FileName);
|
||||||
SetErrorMode(LastErrorMode);
|
SetErrorMode(LastErrorMode);
|
||||||
|
|
||||||
if (hDll == NULL) {
|
if (m_hDll == NULL) {
|
||||||
UnloadPlugin();
|
UnloadPlugin();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
FixUPXIssue((BYTE *)hDll);
|
FixUPXIssue((BYTE *)m_hDll);
|
||||||
|
|
||||||
//Get DLL information
|
//Get DLL information
|
||||||
void (__cdecl *GetDllInfo) ( PLUGIN_INFO * PluginInfo );
|
void (__cdecl *GetDllInfo) ( PLUGIN_INFO * PluginInfo );
|
||||||
GetDllInfo = (void (__cdecl *)(PLUGIN_INFO *))GetProcAddress( (HMODULE)hDll, "GetDllInfo" );
|
GetDllInfo = (void (__cdecl *)(PLUGIN_INFO *))GetProcAddress( (HMODULE)m_hDll, "GetDllInfo" );
|
||||||
if (GetDllInfo == NULL) { UnloadPlugin(); return; }
|
if (GetDllInfo == NULL) { UnloadPlugin(); return; }
|
||||||
|
|
||||||
GetDllInfo(&m_PluginInfo);
|
GetDllInfo(&m_PluginInfo);
|
||||||
|
@ -30,27 +58,27 @@ CGfxPlugin::CGfxPlugin ( const char * FileName) {
|
||||||
|
|
||||||
//Find entries for functions in DLL
|
//Find entries for functions in DLL
|
||||||
BOOL (__cdecl *InitFunc) ( void * Gfx_Info );
|
BOOL (__cdecl *InitFunc) ( void * Gfx_Info );
|
||||||
CloseDLL = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)hDll, "CloseDLL" );
|
CloseDLL = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)m_hDll, "CloseDLL" );
|
||||||
ChangeWindow = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)hDll, "ChangeWindow" );
|
ChangeWindow = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)m_hDll, "ChangeWindow" );
|
||||||
Config = (void (__cdecl *)(DWORD)) GetProcAddress( (HMODULE)hDll, "DllConfig" );
|
Config = (void (__cdecl *)(DWORD)) GetProcAddress( (HMODULE)m_hDll, "DllConfig" );
|
||||||
DrawScreen = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)hDll, "DrawScreen" );
|
DrawScreen = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)m_hDll, "DrawScreen" );
|
||||||
InitFunc = (BOOL (__cdecl *)(void *)) GetProcAddress( (HMODULE)hDll, "InitiateGFX" );
|
InitFunc = (BOOL (__cdecl *)(void *)) GetProcAddress( (HMODULE)m_hDll, "InitiateGFX" );
|
||||||
MoveScreen = (void (__cdecl *)(int, int))GetProcAddress( (HMODULE)hDll, "MoveScreen" );
|
MoveScreen = (void (__cdecl *)(int, int))GetProcAddress( (HMODULE)m_hDll, "MoveScreen" );
|
||||||
ProcessDList = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)hDll, "ProcessDList" );
|
ProcessDList = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)m_hDll, "ProcessDList" );
|
||||||
RomClosed = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)hDll, "RomClosed" );
|
RomClosed = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)m_hDll, "RomClosed" );
|
||||||
RomOpen = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)hDll, "RomOpen" );
|
RomOpen = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)m_hDll, "RomOpen" );
|
||||||
UpdateScreen = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)hDll, "UpdateScreen" );
|
UpdateScreen = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)m_hDll, "UpdateScreen" );
|
||||||
ViStatusChanged = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)hDll, "ViStatusChanged" );
|
ViStatusChanged = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)m_hDll, "ViStatusChanged" );
|
||||||
ViWidthChanged = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)hDll, "ViWidthChanged" );
|
ViWidthChanged = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)m_hDll, "ViWidthChanged" );
|
||||||
SoftReset = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)hDll, "SoftReset" );
|
SoftReset = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)m_hDll, "SoftReset" );
|
||||||
|
|
||||||
//version 104 functions
|
//version 104 functions
|
||||||
PluginOpened = (void (__cdecl *)(void))GetProcAddress( (HMODULE)hDll, "PluginLoaded" );
|
PluginOpened = (void (__cdecl *)(void))GetProcAddress( (HMODULE)m_hDll, "PluginLoaded" );
|
||||||
DrawStatus = (void (__cdecl *)(const char *, BOOL ))GetProcAddress((HMODULE)hDll, "DrawFullScreenStatus");
|
DrawStatus = (void (__cdecl *)(const char *, BOOL ))GetProcAddress((HMODULE)m_hDll, "DrawFullScreenStatus");
|
||||||
|
|
||||||
// Rom Browser
|
// Rom Browser
|
||||||
GetRomBrowserMenu = (MENU_HANDLE (__cdecl *)( void ))GetProcAddress( (HMODULE)hDll, "GetRomBrowserMenu" );
|
GetRomBrowserMenu = (MENU_HANDLE (__cdecl *)( void ))GetProcAddress( (HMODULE)m_hDll, "GetRomBrowserMenu" );
|
||||||
OnRomBrowserMenuItem = (void (__cdecl *) ( int, WND_HANDLE, BYTE * ))GetProcAddress( (HMODULE)hDll, "OnRomBrowserMenuItem" );
|
OnRomBrowserMenuItem = (void (__cdecl *) ( int, WND_HANDLE, BYTE * ))GetProcAddress( (HMODULE)m_hDll, "OnRomBrowserMenuItem" );
|
||||||
|
|
||||||
//Make sure dll had all needed functions
|
//Make sure dll had all needed functions
|
||||||
if (ChangeWindow == NULL) { UnloadPlugin(); return; }
|
if (ChangeWindow == NULL) { UnloadPlugin(); return; }
|
||||||
|
@ -67,11 +95,11 @@ CGfxPlugin::CGfxPlugin ( const char * FileName) {
|
||||||
if (SoftReset == NULL) { SoftReset = DummySoftReset; }
|
if (SoftReset == NULL) { SoftReset = DummySoftReset; }
|
||||||
|
|
||||||
if (m_PluginInfo.Version >= 0x0103 ){
|
if (m_PluginInfo.Version >= 0x0103 ){
|
||||||
ProcessRDPList = (void (__cdecl *)(void))GetProcAddress( (HMODULE)hDll, "ProcessRDPList" );
|
ProcessRDPList = (void (__cdecl *)(void))GetProcAddress( (HMODULE)m_hDll, "ProcessRDPList" );
|
||||||
CaptureScreen = (void (__cdecl *)(const char *))GetProcAddress( (HMODULE)hDll, "CaptureScreen" );
|
CaptureScreen = (void (__cdecl *)(const char *))GetProcAddress( (HMODULE)m_hDll, "CaptureScreen" );
|
||||||
ShowCFB = (void (__cdecl *)(void))GetProcAddress( (HMODULE)hDll, "ShowCFB" );
|
ShowCFB = (void (__cdecl *)(void))GetProcAddress( (HMODULE)m_hDll, "ShowCFB" );
|
||||||
GetDebugInfo = (void (__cdecl *)(GFXDEBUG_INFO *))GetProcAddress( (HMODULE)hDll, "GetGfxDebugInfo" );
|
GetDebugInfo = (void (__cdecl *)(GFXDEBUG_INFO *))GetProcAddress( (HMODULE)m_hDll, "GetGfxDebugInfo" );
|
||||||
InitiateDebugger = (void (__cdecl *)(DEBUG_INFO))GetProcAddress( (HMODULE)hDll, "InitiateGFXDebugger" );
|
InitiateDebugger = (void (__cdecl *)(DEBUG_INFO))GetProcAddress( (HMODULE)m_hDll, "InitiateGFXDebugger" );
|
||||||
|
|
||||||
if (ProcessRDPList == NULL) { UnloadPlugin(); return; }
|
if (ProcessRDPList == NULL) { UnloadPlugin(); return; }
|
||||||
if (CaptureScreen == NULL) { UnloadPlugin(); return; }
|
if (CaptureScreen == NULL) { UnloadPlugin(); return; }
|
||||||
|
@ -81,7 +109,7 @@ CGfxPlugin::CGfxPlugin ( const char * FileName) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SetSettingInfo2 = (void (__cdecl *)(PLUGIN_SETTINGS2 *))GetProcAddress( (HMODULE)hDll, "SetSettingInfo2" );
|
SetSettingInfo2 = (void (__cdecl *)(PLUGIN_SETTINGS2 *))GetProcAddress( (HMODULE)m_hDll, "SetSettingInfo2" );
|
||||||
if (SetSettingInfo2)
|
if (SetSettingInfo2)
|
||||||
{
|
{
|
||||||
PLUGIN_SETTINGS2 info;
|
PLUGIN_SETTINGS2 info;
|
||||||
|
@ -89,7 +117,7 @@ CGfxPlugin::CGfxPlugin ( const char * FileName) {
|
||||||
SetSettingInfo2(&info);
|
SetSettingInfo2(&info);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetSettingInfo = (void (__cdecl *)(PLUGIN_SETTINGS *))GetProcAddress( (HMODULE)hDll, "SetSettingInfo" );
|
SetSettingInfo = (void (__cdecl *)(PLUGIN_SETTINGS *))GetProcAddress( (HMODULE)m_hDll, "SetSettingInfo" );
|
||||||
if (SetSettingInfo)
|
if (SetSettingInfo)
|
||||||
{
|
{
|
||||||
PLUGIN_SETTINGS info;
|
PLUGIN_SETTINGS info;
|
||||||
|
@ -117,8 +145,8 @@ CGfxPlugin::CGfxPlugin ( const char * FileName) {
|
||||||
|
|
||||||
PluginOpened();
|
PluginOpened();
|
||||||
}
|
}
|
||||||
// FrameBufferRead = (void (__cdecl *)(DWORD))GetProcAddress( (HMODULE)hDll, "FBRead" );
|
// FrameBufferRead = (void (__cdecl *)(DWORD))GetProcAddress( (HMODULE)m_hDll, "FBRead" );
|
||||||
// FrameBufferWrite = (void (__cdecl *)(DWORD, DWORD))GetProcAddress( (HMODULE)hDll, "FBWrite" );
|
// FrameBufferWrite = (void (__cdecl *)(DWORD, DWORD))GetProcAddress( (HMODULE)m_hDll, "FBWrite" );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,7 +202,7 @@ bool CGfxPlugin::Initiate ( CN64System * System, CMainGui * RenderWindow ) {
|
||||||
|
|
||||||
//Get Function from DLL
|
//Get Function from DLL
|
||||||
BOOL (__cdecl *InitiateGFX)( GFX_INFO Gfx_Info );
|
BOOL (__cdecl *InitiateGFX)( GFX_INFO Gfx_Info );
|
||||||
InitiateGFX = (BOOL (__cdecl *)(GFX_INFO))GetProcAddress( (HMODULE)hDll, "InitiateGFX" );
|
InitiateGFX = (BOOL (__cdecl *)(GFX_INFO))GetProcAddress( (HMODULE)m_hDll, "InitiateGFX" );
|
||||||
if (InitiateGFX == NULL) { return false; }
|
if (InitiateGFX == NULL) { return false; }
|
||||||
|
|
||||||
GFX_INFO Info;
|
GFX_INFO Info;
|
||||||
|
@ -306,9 +334,9 @@ bool CGfxPlugin::ValidPluginVersion(PLUGIN_INFO * PluginInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGfxPlugin::UnloadPlugin(void) {
|
void CGfxPlugin::UnloadPlugin(void) {
|
||||||
if (hDll != NULL ) {
|
if (m_hDll != NULL ) {
|
||||||
FreeLibrary((HMODULE)hDll);
|
FreeLibrary((HMODULE)m_hDll);
|
||||||
hDll = NULL;
|
m_hDll = NULL;
|
||||||
}
|
}
|
||||||
memset(&m_GFXDebug,0,sizeof(m_GFXDebug));
|
memset(&m_GFXDebug,0,sizeof(m_GFXDebug));
|
||||||
memset(&m_PluginInfo,0,sizeof(m_PluginInfo));
|
memset(&m_PluginInfo,0,sizeof(m_PluginInfo));
|
||||||
|
@ -335,4 +363,12 @@ void CGfxPlugin::UnloadPlugin(void) {
|
||||||
ViWidthChanged = NULL;
|
ViWidthChanged = NULL;
|
||||||
GetRomBrowserMenu = NULL;
|
GetRomBrowserMenu = NULL;
|
||||||
OnRomBrowserMenuItem = NULL;
|
OnRomBrowserMenuItem = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CGfxPlugin::ProcessMenuItem (int id )
|
||||||
|
{
|
||||||
|
if (m_GFXDebug.ProcessMenuItem)
|
||||||
|
{
|
||||||
|
m_GFXDebug.ProcessMenuItem(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
class CGfxPlugin {
|
class CGfxPlugin
|
||||||
|
{
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/* Menu */
|
/* Menu */
|
||||||
/* Items should have an ID between 5101 and 5200 */
|
/* Items should have an ID between 5101 and 5200 */
|
||||||
|
@ -32,32 +33,6 @@ class CGfxPlugin {
|
||||||
void (__cdecl *Enter_Memory_Window)( void );
|
void (__cdecl *Enter_Memory_Window)( void );
|
||||||
} DEBUG_INFO;
|
} DEBUG_INFO;
|
||||||
|
|
||||||
GFXDEBUG_INFO m_GFXDebug;
|
|
||||||
void * hDll;
|
|
||||||
bool m_Initilized, m_RomOpen;
|
|
||||||
PLUGIN_INFO m_PluginInfo;
|
|
||||||
|
|
||||||
void UnloadPlugin ( void );
|
|
||||||
bool ValidPluginVersion ( PLUGIN_INFO * PluginInfo );
|
|
||||||
|
|
||||||
|
|
||||||
void (__cdecl *CloseDLL) ( void );
|
|
||||||
void (__cdecl *RomOpen) ( void );
|
|
||||||
void (__cdecl *RomClosed) ( void );
|
|
||||||
void (__cdecl *GetDebugInfo) ( GFXDEBUG_INFO * GFXDebugInfo );
|
|
||||||
void (__cdecl *InitiateDebugger) ( DEBUG_INFO DebugInfo);
|
|
||||||
void (__cdecl *PluginOpened) ( void );
|
|
||||||
void (__cdecl *SetSettingInfo) ( PLUGIN_SETTINGS * info );
|
|
||||||
void (__cdecl *SetSettingInfo2) ( PLUGIN_SETTINGS2 * info );
|
|
||||||
|
|
||||||
static void LoadLib (LPCSTR FileName);
|
|
||||||
|
|
||||||
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 ) {}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CGfxPlugin ( const char * FileName);
|
CGfxPlugin ( const char * FileName);
|
||||||
~CGfxPlugin ( void );
|
~CGfxPlugin ( void );
|
||||||
|
@ -71,12 +46,9 @@ public:
|
||||||
|
|
||||||
void (__cdecl *CaptureScreen) ( const char * );
|
void (__cdecl *CaptureScreen) ( const char * );
|
||||||
void (__cdecl *ChangeWindow) ( void );
|
void (__cdecl *ChangeWindow) ( void );
|
||||||
// void (__cdecl *DllAbout) ( DWORD hParent );
|
|
||||||
void (__cdecl *Config) ( DWORD hParent );
|
void (__cdecl *Config) ( DWORD hParent );
|
||||||
void (__cdecl *DrawScreen) ( void );
|
void (__cdecl *DrawScreen) ( void );
|
||||||
void (__cdecl *DrawStatus) ( const char * lpString, BOOL RightAlign );
|
void (__cdecl *DrawStatus) ( const char * lpString, BOOL RightAlign );
|
||||||
// void (__cdecl *FrameBufferRead) ( DWORD addr );
|
|
||||||
// void (__cdecl *FrameBufferWrite) ( DWORD addr, DWORD Bytes );
|
|
||||||
void (__cdecl *MoveScreen) ( int xpos, int ypos );
|
void (__cdecl *MoveScreen) ( int xpos, int ypos );
|
||||||
void (__cdecl *ProcessDList) ( void );
|
void (__cdecl *ProcessDList) ( void );
|
||||||
void (__cdecl *ProcessRDPList) ( void );
|
void (__cdecl *ProcessRDPList) ( void );
|
||||||
|
@ -89,14 +61,36 @@ public:
|
||||||
//Rom Browser
|
//Rom Browser
|
||||||
MENU_HANDLE (__cdecl * GetRomBrowserMenu) ( void ); /* Items should have an ID between 4101 and 4200 */
|
MENU_HANDLE (__cdecl * GetRomBrowserMenu) ( void ); /* Items should have an ID between 4101 and 4200 */
|
||||||
void (__cdecl * OnRomBrowserMenuItem) ( int MenuID, WND_HANDLE hParent, BYTE * HEADER );
|
void (__cdecl * OnRomBrowserMenuItem) ( int MenuID, WND_HANDLE hParent, BYTE * HEADER );
|
||||||
|
|
||||||
|
|
||||||
MENU_HANDLE GetDebugMenu (void ) { return m_GFXDebug.hGFXMenu; }
|
MENU_HANDLE GetDebugMenu (void ) { return m_GFXDebug.hGFXMenu; }
|
||||||
void ProcessMenuItem (int id )
|
void ProcessMenuItem (int id );
|
||||||
{
|
|
||||||
if (m_GFXDebug.ProcessMenuItem)
|
private:
|
||||||
{
|
CGfxPlugin(void); // Disable default constructor
|
||||||
m_GFXDebug.ProcessMenuItem(id);
|
CGfxPlugin(const CGfxPlugin&); // Disable copy constructor
|
||||||
}
|
CGfxPlugin& operator=(const CGfxPlugin&); // Disable assignment
|
||||||
}
|
|
||||||
|
void Init ( const char * FileName );
|
||||||
|
void UnloadPlugin ( void );
|
||||||
|
bool ValidPluginVersion ( PLUGIN_INFO * PluginInfo );
|
||||||
|
|
||||||
|
GFXDEBUG_INFO m_GFXDebug;
|
||||||
|
void * m_hDll;
|
||||||
|
bool m_Initilized, m_RomOpen;
|
||||||
|
PLUGIN_INFO m_PluginInfo;
|
||||||
|
|
||||||
|
void (__cdecl *CloseDLL) ( void );
|
||||||
|
void (__cdecl *RomOpen) ( void );
|
||||||
|
void (__cdecl *RomClosed) ( void );
|
||||||
|
void (__cdecl *GetDebugInfo) ( GFXDEBUG_INFO * GFXDebugInfo );
|
||||||
|
void (__cdecl *InitiateDebugger) ( DEBUG_INFO DebugInfo);
|
||||||
|
void (__cdecl *PluginOpened) ( void );
|
||||||
|
void (__cdecl *SetSettingInfo) ( PLUGIN_SETTINGS * info );
|
||||||
|
void (__cdecl *SetSettingInfo2) ( PLUGIN_SETTINGS2 * info );
|
||||||
|
|
||||||
|
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 ) {}
|
||||||
};
|
};
|
Loading…
Reference in New Issue