1 // Copyright (C) 2003 Dolphin Project.
3 // This program is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, version 2.0.
7 // This program is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 // GNU General Public License 2.0 for more details.
12 // A copy of the GPL 2.0 should have been included with the program.
13 // If not, see http://www.gnu.org/licenses/
15 // Official SVN repository and contact information can be found at
16 // http://code.google.com/p/dolphin-emu/
18 // --------------------------------------------------------------------------------------------
19 // This is the common Plugin class that links to the functions that are
20 // common to all plugins. This class is inherited by all plugin classes. But it's only created
21 // directly in PluginManager.cpp when we check if a plugin is valid or not.
22 // --------------------------------------------------------------------------------------------
34 CPlugin::CPlugin(const char* _szName
) : valid(false)
39 m_SetDllGlobals
= NULL
;
43 m_EmuStateChange
= NULL
;
45 if (m_hInstLib
.Load(_szName
))
47 m_GetDllInfo
= reinterpret_cast<TGetDllInfo
>
48 (m_hInstLib
.Get("GetDllInfo"));
49 m_DllConfig
= reinterpret_cast<TDllConfig
>
50 (m_hInstLib
.Get("DllConfig"));
51 m_DllDebugger
= reinterpret_cast<TDllDebugger
>
52 (m_hInstLib
.Get("DllDebugger"));
53 m_SetDllGlobals
= reinterpret_cast<TSetDllGlobals
>
54 (m_hInstLib
.Get("SetDllGlobals"));
55 m_Initialize
= reinterpret_cast<TInitialize
>
56 (m_hInstLib
.Get("Initialize"));
57 m_Shutdown
= reinterpret_cast<TShutdown
>
58 (m_hInstLib
.Get("Shutdown"));
59 m_DoState
= reinterpret_cast<TDoState
>
60 (m_hInstLib
.Get("DoState"));
61 m_EmuStateChange
= reinterpret_cast<TEmuStateChange
>
62 (m_hInstLib
.Get("EmuStateChange"));
64 // Check if the plugin has all the functions it should have
65 if (m_GetDllInfo
!= 0 &&
68 m_SetDllGlobals
!= 0 &&
72 m_EmuStateChange
!= 0)
76 // Save the filename for this plugin
80 void *CPlugin::LoadSymbol(const char *sym
)
82 return m_hInstLib
.Get(sym
);
85 // GetInfo: Get DLL info
86 bool CPlugin::GetInfo(PLUGIN_INFO
& _pluginInfo
)
88 if (m_GetDllInfo
!= NULL
) {
89 m_GetDllInfo(&_pluginInfo
);
95 // Config: Open the Config window
96 void CPlugin::Config(void *_hwnd
)
98 if (m_DllConfig
!= NULL
)
102 // Debug: Open the Debugging window
103 void *CPlugin::Debug(void *Parent
, bool Show
)
105 return m_DllDebugger(Parent
, Show
);
108 void CPlugin::SetGlobals(PLUGIN_GLOBALS
* _pluginGlobals
) {
109 if (m_SetDllGlobals
!= NULL
)
110 m_SetDllGlobals(_pluginGlobals
);
113 void CPlugin::DoState(unsigned char **ptr
, int mode
) {
114 if (m_DoState
!= NULL
)
115 m_DoState(ptr
, mode
);
118 void CPlugin::EmuStateChange(PLUGIN_EMUSTATE newState
) {
119 if (m_EmuStateChange
!= NULL
)
120 m_EmuStateChange(newState
);
123 void CPlugin::Initialize(void *init
)
125 if (m_Initialize
!= NULL
)
129 void CPlugin::Shutdown()
131 if (m_Shutdown
!= NULL
)