mirror of https://github.com/PCSX2/pcsx2.git
FWnull reformat
This commit is contained in:
parent
b246d13bae
commit
67e7d63f0f
|
@ -25,24 +25,23 @@ PluginConf Ini;
|
||||||
|
|
||||||
void setLoggingState()
|
void setLoggingState()
|
||||||
{
|
{
|
||||||
if (conf.Log)
|
if (conf.Log) {
|
||||||
{
|
|
||||||
FWLog.WriteToConsole = true;
|
FWLog.WriteToConsole = true;
|
||||||
FWLog.WriteToFile = true;
|
FWLog.WriteToFile = true;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
FWLog.WriteToConsole = false;
|
FWLog.WriteToConsole = false;
|
||||||
FWLog.WriteToFile = false;
|
FWLog.WriteToFile = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(void) FWabout()
|
EXPORT_C_(void)
|
||||||
|
FWabout()
|
||||||
{
|
{
|
||||||
SysMessage("FWnull: A simple null plugin.");
|
SysMessage("FWnull: A simple null plugin.");
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(void) FWconfigure()
|
EXPORT_C_(void)
|
||||||
|
FWconfigure()
|
||||||
{
|
{
|
||||||
LoadConfig();
|
LoadConfig();
|
||||||
PluginNullConfigure("Since this is a null plugin, all that is really configurable is logging.", conf.Log);
|
PluginNullConfigure("Since this is a null plugin, all that is really configurable is logging.", conf.Log);
|
||||||
|
@ -52,8 +51,7 @@ EXPORT_C_(void) FWconfigure()
|
||||||
void LoadConfig()
|
void LoadConfig()
|
||||||
{
|
{
|
||||||
string IniPath = s_strIniPath + "/FWnull.ini";
|
string IniPath = s_strIniPath + "/FWnull.ini";
|
||||||
if (!Ini.Open(IniPath, READ_FILE))
|
if (!Ini.Open(IniPath, READ_FILE)) {
|
||||||
{
|
|
||||||
FWLog.WriteLn("Failed to open %s", IniPath.c_str());
|
FWLog.WriteLn("Failed to open %s", IniPath.c_str());
|
||||||
SaveConfig();
|
SaveConfig();
|
||||||
return;
|
return;
|
||||||
|
@ -67,8 +65,7 @@ void LoadConfig()
|
||||||
void SaveConfig()
|
void SaveConfig()
|
||||||
{
|
{
|
||||||
string IniPath = s_strIniPath + "/FWnull.ini";
|
string IniPath = s_strIniPath + "/FWnull.ini";
|
||||||
if (!Ini.Open(IniPath, WRITE_FILE))
|
if (!Ini.Open(IniPath, WRITE_FILE)) {
|
||||||
{
|
|
||||||
FWLog.WriteLn("Failed to open %s\n", IniPath.c_str());
|
FWLog.WriteLn("Failed to open %s\n", IniPath.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -76,4 +73,3 @@ void SaveConfig()
|
||||||
Ini.WriteInt("logging", conf.Log);
|
Ini.WriteInt("logging", conf.Log);
|
||||||
Ini.Close();
|
Ini.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,8 @@ void LogInit()
|
||||||
FWLog.Open(LogFile);
|
FWLog.Open(LogFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(void) FWsetLogDir(const char* dir)
|
EXPORT_C_(void)
|
||||||
|
FWsetLogDir(const char* dir)
|
||||||
{
|
{
|
||||||
// Get the path to the log directory.
|
// Get the path to the log directory.
|
||||||
s_strLogPath = (dir == NULL) ? "logs" : dir;
|
s_strLogPath = (dir == NULL) ? "logs" : dir;
|
||||||
|
@ -59,23 +60,27 @@ EXPORT_C_(void) FWsetLogDir(const char* dir)
|
||||||
LogInit();
|
LogInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(u32) PS2EgetLibType()
|
EXPORT_C_(u32)
|
||||||
|
PS2EgetLibType()
|
||||||
{
|
{
|
||||||
return PS2E_LT_FW;
|
return PS2E_LT_FW;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(char*) PS2EgetLibName()
|
EXPORT_C_(char*)
|
||||||
|
PS2EgetLibName()
|
||||||
{
|
{
|
||||||
snprintf(libraryName, 255, "FWnull Driver %lld%s", SVN_REV, SVN_MODS ? "m" : "");
|
snprintf(libraryName, 255, "FWnull Driver %lld%s", SVN_REV, SVN_MODS ? "m" : "");
|
||||||
return libraryName;
|
return libraryName;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(u32) PS2EgetLibVersion2(u32 type)
|
EXPORT_C_(u32)
|
||||||
|
PS2EgetLibVersion2(u32 type)
|
||||||
{
|
{
|
||||||
return (version << 16) | (revision << 8) | build;
|
return (version << 16) | (revision << 8) | build;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(s32) FWinit()
|
EXPORT_C_(s32)
|
||||||
|
FWinit()
|
||||||
{
|
{
|
||||||
LoadConfig();
|
LoadConfig();
|
||||||
LogInit();
|
LogInit();
|
||||||
|
@ -85,15 +90,15 @@ EXPORT_C_(s32) FWinit()
|
||||||
memset(phyregs, 0, sizeof(phyregs));
|
memset(phyregs, 0, sizeof(phyregs));
|
||||||
// Initializing our registers.
|
// Initializing our registers.
|
||||||
fwregs = (s8*)calloc(0x10000, 1);
|
fwregs = (s8*)calloc(0x10000, 1);
|
||||||
if (fwregs == NULL)
|
if (fwregs == NULL) {
|
||||||
{
|
|
||||||
FWLog.Message("Error allocating Memory");
|
FWLog.Message("Error allocating Memory");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(void) FWshutdown()
|
EXPORT_C_(void)
|
||||||
|
FWshutdown()
|
||||||
{
|
{
|
||||||
// Freeing the registers.
|
// Freeing the registers.
|
||||||
free(fwregs);
|
free(fwregs);
|
||||||
|
@ -102,14 +107,16 @@ EXPORT_C_(void) FWshutdown()
|
||||||
FWLog.Close();
|
FWLog.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(s32) FWopen(void *pDsp)
|
EXPORT_C_(s32)
|
||||||
|
FWopen(void* pDsp)
|
||||||
{
|
{
|
||||||
FWLog.WriteLn("Opening FWnull.");
|
FWLog.WriteLn("Opening FWnull.");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(void) FWclose()
|
EXPORT_C_(void)
|
||||||
|
FWclose()
|
||||||
{
|
{
|
||||||
// Close the plugin.
|
// Close the plugin.
|
||||||
FWLog.WriteLn("Closing FWnull.");
|
FWLog.WriteLn("Closing FWnull.");
|
||||||
|
@ -139,12 +146,12 @@ void PHYRead()
|
||||||
FWirq();
|
FWirq();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EXPORT_C_(u32) FWread32(u32 addr)
|
EXPORT_C_(u32)
|
||||||
|
FWread32(u32 addr)
|
||||||
{
|
{
|
||||||
u32 ret = 0;
|
u32 ret = 0;
|
||||||
|
|
||||||
switch (addr)
|
switch (addr) {
|
||||||
{
|
|
||||||
//Node ID Register the top part is default, bottom part i got from my ps2
|
//Node ID Register the top part is default, bottom part i got from my ps2
|
||||||
case 0x1f808400:
|
case 0x1f808400:
|
||||||
ret = /*(0x3ff << 22) | 1;*/ 0xffc00001;
|
ret = /*(0x3ff << 22) | 1;*/ 0xffc00001;
|
||||||
|
@ -176,10 +183,10 @@ EXPORT_C_(u32) FWread32(u32 addr)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(void) FWwrite32(u32 addr, u32 value)
|
EXPORT_C_(void)
|
||||||
{
|
FWwrite32(u32 addr, u32 value)
|
||||||
switch (addr)
|
|
||||||
{
|
{
|
||||||
|
switch (addr) {
|
||||||
// Include other memory locations we want to catch here.
|
// Include other memory locations we want to catch here.
|
||||||
// For example:
|
// For example:
|
||||||
//
|
//
|
||||||
|
@ -198,8 +205,7 @@ EXPORT_C_(void) FWwrite32(u32 addr, u32 value)
|
||||||
if (value & 0x40000000) //Writing to PHY
|
if (value & 0x40000000) //Writing to PHY
|
||||||
{
|
{
|
||||||
PHYWrite();
|
PHYWrite();
|
||||||
}
|
} else if (value & 0x80000000) //Reading from PHY
|
||||||
else if(value & 0x80000000) //Reading from PHY
|
|
||||||
{
|
{
|
||||||
PHYRead();
|
PHYRead();
|
||||||
}
|
}
|
||||||
|
@ -264,24 +270,26 @@ EXPORT_C_(void) FWwrite32(u32 addr, u32 value)
|
||||||
FWLog.WriteLn("FW write mem 0x%x: 0x%x", addr, value);
|
FWLog.WriteLn("FW write mem 0x%x: 0x%x", addr, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(void) FWirqCallback(void (*callback)())
|
EXPORT_C_(void)
|
||||||
|
FWirqCallback(void (*callback)())
|
||||||
{
|
{
|
||||||
// Register FWirq, so we can trigger an interrupt with it later.
|
// Register FWirq, so we can trigger an interrupt with it later.
|
||||||
FWirq = callback;
|
FWirq = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(void) FWsetSettingsDir(const char* dir)
|
EXPORT_C_(void)
|
||||||
|
FWsetSettingsDir(const char* dir)
|
||||||
{
|
{
|
||||||
// Find out from pcsx2 where we are supposed to put our ini file.
|
// Find out from pcsx2 where we are supposed to put our ini file.
|
||||||
s_strIniPath = (dir == NULL) ? "inis" : dir;
|
s_strIniPath = (dir == NULL) ? "inis" : dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(s32) FWfreeze(int mode, freezeData *data)
|
EXPORT_C_(s32)
|
||||||
|
FWfreeze(int mode, freezeData* data)
|
||||||
{
|
{
|
||||||
// This should store or retrieve any information, for if emulation
|
// This should store or retrieve any information, for if emulation
|
||||||
// gets suspended, or for savestates.
|
// gets suspended, or for savestates.
|
||||||
switch(mode)
|
switch (mode) {
|
||||||
{
|
|
||||||
case FREEZE_LOAD:
|
case FREEZE_LOAD:
|
||||||
// Load previously saved data.
|
// Load previously saved data.
|
||||||
break;
|
break;
|
||||||
|
@ -295,7 +303,8 @@ EXPORT_C_(s32) FWfreeze(int mode, freezeData *data)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(s32) FWtest()
|
EXPORT_C_(s32)
|
||||||
|
FWtest()
|
||||||
{
|
{
|
||||||
// 0 if the plugin works, non-0 if it doesn't.
|
// 0 if the plugin works, non-0 if it doesn't.
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -28,14 +28,15 @@ void SaveConfig()
|
||||||
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
|
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
|
||||||
szTemp = strrchr(szIniFile, '\\');
|
szTemp = strrchr(szIniFile, '\\');
|
||||||
|
|
||||||
if(!szTemp) return;
|
if (!szTemp)
|
||||||
|
return;
|
||||||
strcpy(szTemp, "\\inis\\fwnull.ini");
|
strcpy(szTemp, "\\inis\\fwnull.ini");
|
||||||
sprintf(szValue, "%u", Conf1->Log);
|
sprintf(szValue, "%u", Conf1->Log);
|
||||||
WritePrivateProfileString("Interface", "Logging", szValue, szIniFile);
|
WritePrivateProfileString("Interface", "Logging", szValue, szIniFile);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadConfig() {
|
void LoadConfig()
|
||||||
|
{
|
||||||
FILE* fp;
|
FILE* fp;
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,11 +47,11 @@ void LoadConfig() {
|
||||||
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
|
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
|
||||||
szTemp = strrchr(szIniFile, '\\');
|
szTemp = strrchr(szIniFile, '\\');
|
||||||
|
|
||||||
if(!szTemp) return ;
|
if (!szTemp)
|
||||||
|
return;
|
||||||
strcpy(szTemp, "\\inis\\fwnull.ini");
|
strcpy(szTemp, "\\inis\\fwnull.ini");
|
||||||
fp = fopen("inis\\fwnull.ini", "rt"); //check if firewirenull.ini really exists
|
fp = fopen("inis\\fwnull.ini", "rt"); //check if firewirenull.ini really exists
|
||||||
if (!fp)
|
if (!fp) {
|
||||||
{
|
|
||||||
CreateDirectory("inis", NULL);
|
CreateDirectory("inis", NULL);
|
||||||
memset(&conf, 0, sizeof(conf));
|
memset(&conf, 0, sizeof(conf));
|
||||||
conf.Log = 0; //default value
|
conf.Log = 0; //default value
|
||||||
|
@ -61,6 +62,4 @@ void LoadConfig() {
|
||||||
GetPrivateProfileString("Interface", "Logging", NULL, szValue, 20, szIniFile);
|
GetPrivateProfileString("Interface", "Logging", NULL, szValue, 20, szIniFile);
|
||||||
Conf1->Log = strtoul(szValue, NULL, 10);
|
Conf1->Log = strtoul(szValue, NULL, 10);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,8 @@
|
||||||
|
|
||||||
HINSTANCE hInst;
|
HINSTANCE hInst;
|
||||||
|
|
||||||
void SysMessage(char *fmt, ...) {
|
void SysMessage(char* fmt, ...)
|
||||||
|
{
|
||||||
va_list list;
|
va_list list;
|
||||||
char tmp[512];
|
char tmp[512];
|
||||||
|
|
||||||
|
@ -33,12 +34,14 @@ void SysMessage(char *fmt, ...) {
|
||||||
MessageBox(GetActiveWindow(), tmp, "FW Plugin Msg", MB_SETFOREGROUND | MB_OK);
|
MessageBox(GetActiveWindow(), tmp, "FW Plugin Msg", MB_SETFOREGROUND | MB_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
|
||||||
switch (uMsg) {
|
switch (uMsg) {
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
LoadConfig();
|
LoadConfig();
|
||||||
if (conf.Log) CheckDlgButton(hW, IDC_LOGGING, TRUE);
|
if (conf.Log)
|
||||||
|
CheckDlgButton(hW, IDC_LOGGING, TRUE);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
|
@ -49,7 +52,8 @@ BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
case IDOK:
|
case IDOK:
|
||||||
if (IsDlgButtonChecked(hW, IDC_LOGGING))
|
if (IsDlgButtonChecked(hW, IDC_LOGGING))
|
||||||
conf.Log = 1;
|
conf.Log = 1;
|
||||||
else conf.Log = 0;
|
else
|
||||||
|
conf.Log = 0;
|
||||||
SaveConfig();
|
SaveConfig();
|
||||||
EndDialog(hW, FALSE);
|
EndDialog(hW, FALSE);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -58,7 +62,8 @@ BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
switch (uMsg) {
|
switch (uMsg) {
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -73,14 +78,16 @@ BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CALLBACK FWconfigure() {
|
void CALLBACK FWconfigure()
|
||||||
|
{
|
||||||
DialogBox(hInst,
|
DialogBox(hInst,
|
||||||
MAKEINTRESOURCE(IDD_CONFIG),
|
MAKEINTRESOURCE(IDD_CONFIG),
|
||||||
GetActiveWindow(),
|
GetActiveWindow(),
|
||||||
(DLGPROC)ConfigureDlgProc);
|
(DLGPROC)ConfigureDlgProc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CALLBACK FWabout() {
|
void CALLBACK FWabout()
|
||||||
|
{
|
||||||
DialogBox(hInst,
|
DialogBox(hInst,
|
||||||
MAKEINTRESOURCE(IDD_ABOUT),
|
MAKEINTRESOURCE(IDD_ABOUT),
|
||||||
GetActiveWindow(),
|
GetActiveWindow(),
|
||||||
|
@ -89,8 +96,8 @@ void CALLBACK FWabout() {
|
||||||
|
|
||||||
BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT
|
BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT
|
||||||
DWORD dwReason,
|
DWORD dwReason,
|
||||||
LPVOID lpReserved) {
|
LPVOID lpReserved)
|
||||||
|
{
|
||||||
hInst = (HINSTANCE)hModule;
|
hInst = (HINSTANCE)hModule;
|
||||||
return TRUE; // very quick :)
|
return TRUE; // very quick :)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue