From fb7c2c1837946fc313de3da8b8dd02b24fd6eec4 Mon Sep 17 00:00:00 2001 From: Jonathan Li Date: Wed, 23 May 2018 19:59:17 +0100 Subject: [PATCH] dev9null|fwnull|usbnull: Switch to new null config code --- plugins/FWnull/CMakeLists.txt | 2 - plugins/FWnull/Config.cpp | 69 ------------------ plugins/FWnull/Config.h | 21 ------ plugins/FWnull/FW.cpp | 35 +++++---- plugins/FWnull/FW.h | 11 --- plugins/FWnull/Windows/FWnull.vcxproj | 7 +- plugins/FWnull/Windows/FWnull.vcxproj.filters | 11 ++- plugins/USBnull/CMakeLists.txt | 2 - plugins/USBnull/Config.cpp | 69 ------------------ plugins/USBnull/Config.h | 17 ----- plugins/USBnull/USB.cpp | 61 ++++++++-------- plugins/USBnull/USB.h | 10 --- plugins/USBnull/Windows/USBnull.vcxproj | 5 +- .../USBnull/Windows/USBnull.vcxproj.filters | 11 ++- plugins/dev9null/CMakeLists.txt | 2 - plugins/dev9null/Config.cpp | 71 ------------------- plugins/dev9null/Config.h | 24 ------- plugins/dev9null/DEV9.cpp | 54 +++++++------- plugins/dev9null/DEV9.h | 12 ---- plugins/dev9null/Windows/DEV9null.vcxproj | 5 +- .../dev9null/Windows/DEV9null.vcxproj.filters | 7 +- 21 files changed, 105 insertions(+), 401 deletions(-) delete mode 100644 plugins/FWnull/Config.cpp delete mode 100644 plugins/FWnull/Config.h delete mode 100644 plugins/USBnull/Config.cpp delete mode 100644 plugins/USBnull/Config.h delete mode 100644 plugins/dev9null/Config.cpp delete mode 100644 plugins/dev9null/Config.h diff --git a/plugins/FWnull/CMakeLists.txt b/plugins/FWnull/CMakeLists.txt index f5074cdb8d..681578756f 100644 --- a/plugins/FWnull/CMakeLists.txt +++ b/plugins/FWnull/CMakeLists.txt @@ -12,12 +12,10 @@ set(FWnullFinalFlags "") # FWnull sources set(FWnullSources - Config.cpp FW.cpp) # FWnull headers set(FWnullHeaders - Config.h FW.h) # FWnull Linux sources diff --git a/plugins/FWnull/Config.cpp b/plugins/FWnull/Config.cpp deleted file mode 100644 index 34acf258ed..0000000000 --- a/plugins/FWnull/Config.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* FWnull - * Copyright (C) 2004-2009 PCSX2 Dev Team - * - * PCSX2 is free software: you can redistribute it and/or modify it under the terms - * of the GNU Lesser General Public License as published by the Free Software Found- - * ation, either version 3 of the License, or (at your option) any later version. - * - * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with PCSX2. - * If not, see . - */ - -#include -using namespace std; - -#include "FW.h" -#include "Config.h" - -extern string s_strIniPath; -extern PluginLog FWLog; -PluginConf Ini; - -void setLoggingState() -{ - if (conf.Log) { - FWLog.WriteToConsole = true; - FWLog.WriteToFile = true; - } else { - FWLog.WriteToConsole = false; - FWLog.WriteToFile = false; - } -} - -EXPORT_C_(void) -FWconfigure() -{ - LoadConfig(); - PluginNullConfigure("Since this is a null plugin, all that is really configurable is logging.", conf.Log); - SaveConfig(); -} - -void LoadConfig() -{ - string IniPath = s_strIniPath + "/FWnull.ini"; - if (!Ini.Open(IniPath, READ_FILE)) { - FWLog.WriteLn("Failed to open %s", IniPath.c_str()); - SaveConfig(); - return; - } - - conf.Log = Ini.ReadInt("logging", 0); - setLoggingState(); - Ini.Close(); -} - -void SaveConfig() -{ - string IniPath = s_strIniPath + "/FWnull.ini"; - if (!Ini.Open(IniPath, WRITE_FILE)) { - FWLog.WriteLn("Failed to open %s\n", IniPath.c_str()); - return; - } - - Ini.WriteInt("logging", conf.Log); - Ini.Close(); -} diff --git a/plugins/FWnull/Config.h b/plugins/FWnull/Config.h deleted file mode 100644 index 6d1c81fd1f..0000000000 --- a/plugins/FWnull/Config.h +++ /dev/null @@ -1,21 +0,0 @@ -/* FWnull - * Copyright (C) 2004-2010 PCSX2 Dev Team - * - * PCSX2 is free software: you can redistribute it and/or modify it under the terms - * of the GNU Lesser General Public License as published by the Free Software Found- - * ation, either version 3 of the License, or (at your option) any later version. - * - * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with PCSX2. - * If not, see . - */ - -void SaveConf(); -void LoadConf(); -void SysMessage(const char *fmt, ...); - -#define is_checked(main_widget, widget_name) (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(main_widget, widget_name)))) -#define set_checked(main_widget, widget_name, state) gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(main_widget, widget_name)), state) diff --git a/plugins/FWnull/FW.cpp b/plugins/FWnull/FW.cpp index f57fd37dc3..e2f7761a95 100644 --- a/plugins/FWnull/FW.cpp +++ b/plugins/FWnull/FW.cpp @@ -22,6 +22,7 @@ using namespace std; #include "FW.h" #include "svnrev.h" +#include "null/config.inl" const u8 version = PS2E_FW_VERSION; const u8 revision = 0; @@ -34,16 +35,22 @@ string s_strLogPath = "logs"; u8 phyregs[16]; s8 *fwregs; -Config conf; -PluginLog FWLog; void (*FWirq)(); +EXPORT_C_(void) +FWconfigure() +{ + const std::string ini_path = s_strIniPath + "/FWnull.ini"; + LoadConfig(ini_path); + ConfigureLogging(); + SaveConfig(ini_path); +} + void LogInit() { const std::string LogFile(s_strLogPath + "/FWnull.log"); - setLoggingState(); - FWLog.Open(LogFile); + g_plugin_log.Open(LogFile); } EXPORT_C_(void) @@ -53,7 +60,7 @@ FWsetLogDir(const char *dir) s_strLogPath = (dir == NULL) ? "logs" : dir; // Reload the log file after updated the path - FWLog.Close(); + g_plugin_log.Close(); LogInit(); } @@ -79,16 +86,16 @@ PS2EgetLibVersion2(u32 type) EXPORT_C_(s32) FWinit() { - LoadConfig(); + LoadConfig(s_strIniPath + "/FWnull.ini"); LogInit(); - FWLog.WriteLn("FWnull plugin version %d,%d", revision, build); - FWLog.WriteLn("Initializing FWnull"); + g_plugin_log.WriteLn("FWnull plugin version %d,%d", revision, build); + g_plugin_log.WriteLn("Initializing FWnull"); memset(phyregs, 0, sizeof(phyregs)); // Initializing our registers. fwregs = (s8 *)calloc(0x10000, 1); if (fwregs == NULL) { - FWLog.Message("Error allocating Memory"); + g_plugin_log.Message("Error allocating Memory"); return -1; } return 0; @@ -101,13 +108,13 @@ FWshutdown() free(fwregs); fwregs = NULL; - FWLog.Close(); + g_plugin_log.Close(); } EXPORT_C_(s32) FWopen(void *pDsp) { - FWLog.WriteLn("Opening FWnull."); + g_plugin_log.WriteLn("Opening FWnull."); return 0; } @@ -116,7 +123,7 @@ EXPORT_C_(void) FWclose() { // Close the plugin. - FWLog.WriteLn("Closing FWnull."); + g_plugin_log.WriteLn("Closing FWnull."); } void PHYWrite() @@ -175,7 +182,7 @@ FWread32(u32 addr) break; } - FWLog.WriteLn("FW read mem 0x%x: 0x%x", addr, ret); + g_plugin_log.WriteLn("FW read mem 0x%x: 0x%x", addr, ret); return ret; } @@ -264,7 +271,7 @@ FWwrite32(u32 addr, u32 value) fwRu32(addr) = value; break; } - FWLog.WriteLn("FW write mem 0x%x: 0x%x", addr, value); + g_plugin_log.WriteLn("FW write mem 0x%x: 0x%x", addr, value); } EXPORT_C_(void) diff --git a/plugins/FWnull/FW.h b/plugins/FWnull/FW.h index 6f80050eba..b5da41d5f4 100644 --- a/plugins/FWnull/FW.h +++ b/plugins/FWnull/FW.h @@ -30,17 +30,6 @@ extern s8 *fwregs; //PHY Access Address for ease of use :P #define PHYACC fwRu32(0x8414) -typedef struct -{ - s32 Log; -} Config; - -extern Config conf; - extern void (*FWirq)(); -extern void SaveConfig(); -extern void LoadConfig(); -extern void setLoggingState(); - #endif diff --git a/plugins/FWnull/Windows/FWnull.vcxproj b/plugins/FWnull/Windows/FWnull.vcxproj index 1b0944671f..e4d503820e 100644 --- a/plugins/FWnull/Windows/FWnull.vcxproj +++ b/plugins/FWnull/Windows/FWnull.vcxproj @@ -13,7 +13,7 @@ Release Win32 - + Release x64 @@ -52,16 +52,17 @@ - - + + + diff --git a/plugins/FWnull/Windows/FWnull.vcxproj.filters b/plugins/FWnull/Windows/FWnull.vcxproj.filters index b3b952a936..2586a12ea4 100644 --- a/plugins/FWnull/Windows/FWnull.vcxproj.filters +++ b/plugins/FWnull/Windows/FWnull.vcxproj.filters @@ -15,9 +15,6 @@ - - Source Files - Source Files @@ -26,13 +23,15 @@ Header Files - - Header Files - Resource Files + + + Resource Files + + \ No newline at end of file diff --git a/plugins/USBnull/CMakeLists.txt b/plugins/USBnull/CMakeLists.txt index 4cb8fdb1b1..6e9c8dd578 100644 --- a/plugins/USBnull/CMakeLists.txt +++ b/plugins/USBnull/CMakeLists.txt @@ -12,12 +12,10 @@ set(USBnullFinalFlags "") # USBnull sources set(USBnullSources - Config.cpp USB.cpp) # USBnull headers set(USBnullHeaders - Config.h USB.h) # USBnull Linux sources diff --git a/plugins/USBnull/Config.cpp b/plugins/USBnull/Config.cpp deleted file mode 100644 index a3f12f850e..0000000000 --- a/plugins/USBnull/Config.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* USBnull - * Copyright (C) 2002-2010 PCSX2 Dev Team - * - * PCSX2 is free software: you can redistribute it and/or modify it under the terms - * of the GNU Lesser General Public License as published by the Free Software Found- - * ation, either version 3 of the License, or (at your option) any later version. - * - * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with PCSX2. - * If not, see . - */ - -#include -using namespace std; - -#include "USB.h" -#include "Config.h" - -extern string s_strIniPath; -extern PluginLog USBLog; -PluginConf Ini; - -void setLoggingState() -{ - if (conf.Log) { - USBLog.WriteToConsole = true; - USBLog.WriteToFile = true; - } else { - USBLog.WriteToConsole = false; - USBLog.WriteToFile = false; - } -} - -EXPORT_C_(void) -USBconfigure() -{ - LoadConfig(); - PluginNullConfigure("Since this is a null plugin, all that is really configurable is logging.", conf.Log); - SaveConfig(); -} - -void LoadConfig() -{ - string IniPath = s_strIniPath + "/USBnull.ini"; - if (!Ini.Open(IniPath, READ_FILE)) { - USBLog.WriteLn("Failed to open %s", IniPath.c_str()); - SaveConfig(); - return; - } - - conf.Log = Ini.ReadInt("logging", 0); - setLoggingState(); - Ini.Close(); -} - -void SaveConfig() -{ - string IniPath = s_strIniPath + "/USBnull.ini"; - if (!Ini.Open(IniPath, WRITE_FILE)) { - USBLog.WriteLn("Failed to open %s", IniPath.c_str()); - return; - } - - Ini.WriteInt("logging", conf.Log); - Ini.Close(); -} diff --git a/plugins/USBnull/Config.h b/plugins/USBnull/Config.h deleted file mode 100644 index cd3861f9fd..0000000000 --- a/plugins/USBnull/Config.h +++ /dev/null @@ -1,17 +0,0 @@ -/* USBnull - * Copyright (C) 2002-2010 PCSX2 Dev Team - * - * PCSX2 is free software: you can redistribute it and/or modify it under the terms - * of the GNU Lesser General Public License as published by the Free Software Found- - * ation, either version 3 of the License, or (at your option) any later version. - * - * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with PCSX2. - * If not, see . - */ - -extern void SaveConfig(); -extern void LoadConfig(); diff --git a/plugins/USBnull/USB.cpp b/plugins/USBnull/USB.cpp index cad7c20196..a86dbb7180 100644 --- a/plugins/USBnull/USB.cpp +++ b/plugins/USBnull/USB.cpp @@ -18,6 +18,8 @@ using namespace std; #include "svnrev.h" #include "USB.h" +#include "null/config.inl" + string s_strIniPath = "inis"; string s_strLogPath = "logs"; @@ -28,16 +30,22 @@ const unsigned char build = 7; // increase that with each version static char libraryName[256]; USBcallback USBirq; -Config conf; -PluginLog USBLog; s8 *usbregs, *ram; +EXPORT_C_(void) +USBconfigure() +{ + const std::string ini_path = s_strIniPath + "/USBnull.ini"; + LoadConfig(ini_path); + ConfigureLogging(); + SaveConfig(ini_path); +} + void LogInit() { const std::string LogFile(s_strLogPath + "/USBnull.log"); - setLoggingState(); - USBLog.Open(LogFile); + g_plugin_log.Open(LogFile); } EXPORT_C_(void) @@ -47,7 +55,7 @@ USBsetLogDir(const char *dir) s_strLogPath = (dir == NULL) ? "logs" : dir; // Reload the log file after updated the path - USBLog.Close(); + g_plugin_log.Close(); LogInit(); } @@ -73,16 +81,16 @@ PS2EgetLibVersion2(u32 type) EXPORT_C_(s32) USBinit() { - LoadConfig(); + LoadConfig(s_strIniPath + "/USBnull.ini"); LogInit(); - USBLog.WriteLn("USBnull plugin version %d,%d", revision, build); - USBLog.WriteLn("Initializing USBnull"); + g_plugin_log.WriteLn("USBnull plugin version %d,%d", revision, build); + g_plugin_log.WriteLn("Initializing USBnull"); // Initialize memory structures here. usbregs = (s8 *)calloc(0x10000, 1); if (usbregs == NULL) { - USBLog.Message("Error allocating memory"); + g_plugin_log.Message("Error allocating memory"); return -1; } @@ -94,7 +102,7 @@ USBshutdown() { // Yes, we close things in the Shutdown routine, and // don't do anything in the close routine. - USBLog.Close(); + g_plugin_log.Close(); free(usbregs); usbregs = NULL; @@ -103,7 +111,7 @@ USBshutdown() EXPORT_C_(s32) USBopen(void *pDsp) { - USBLog.WriteLn("Opening USBnull."); + g_plugin_log.WriteLn("Opening USBnull."); // Take care of anything else we need on opening, other then initialization. return 0; @@ -112,7 +120,7 @@ USBopen(void *pDsp) EXPORT_C_(void) USBclose() { - USBLog.WriteLn("Closing USBnull."); + g_plugin_log.WriteLn("Closing USBnull."); } // Note: actually uncommenting the read/write functions I provided here @@ -125,12 +133,12 @@ USBread8(u32 addr) switch (addr) { // Handle any appropriate addresses here. case 0x1f801600: - USBLog.WriteLn("(USBnull) 8 bit read at address %lx", addr); + g_plugin_log.WriteLn("(USBnull) 8 bit read at address %lx", addr); break; default: //value = usbRu8(addr); - USBLog.WriteLn("*(USBnull) 8 bit read at address %lx", addr); + g_plugin_log.WriteLn("*(USBnull) 8 bit read at address %lx", addr); break; } return value; @@ -144,12 +152,12 @@ USBread16(u32 addr) switch (addr) { // Handle any appropriate addresses here. case 0x1f801600: - USBLog.WriteLn("(USBnull) 16 bit read at address %lx", addr); + g_plugin_log.WriteLn("(USBnull) 16 bit read at address %lx", addr); break; default: //value = usbRu16(addr); - USBLog.WriteLn("(USBnull) 16 bit read at address %lx", addr); + g_plugin_log.WriteLn("(USBnull) 16 bit read at address %lx", addr); } return value; } @@ -162,12 +170,12 @@ USBread32(u32 addr) switch (addr) { // Handle any appropriate addresses here. case 0x1f801600: - USBLog.WriteLn("(USBnull) 32 bit read at address %lx", addr); + g_plugin_log.WriteLn("(USBnull) 32 bit read at address %lx", addr); break; default: //value = usbRu32(addr); - USBLog.WriteLn("(USBnull) 32 bit read at address %lx", addr); + g_plugin_log.WriteLn("(USBnull) 32 bit read at address %lx", addr); } return value; } @@ -178,12 +186,12 @@ USBwrite8(u32 addr, u8 value) switch (addr) { // Handle any appropriate addresses here. case 0x1f801600: - USBLog.WriteLn("(USBnull) 8 bit write at address %lx value %x", addr, value); + g_plugin_log.WriteLn("(USBnull) 8 bit write at address %lx value %x", addr, value); break; default: //usbRu8(addr) = value; - USBLog.WriteLn("(USBnull) 8 bit write at address %lx value %x", addr, value); + g_plugin_log.WriteLn("(USBnull) 8 bit write at address %lx value %x", addr, value); } } @@ -193,12 +201,12 @@ USBwrite16(u32 addr, u16 value) switch (addr) { // Handle any appropriate addresses here. case 0x1f801600: - USBLog.WriteLn("(USBnull) 16 bit write at address %lx value %x", addr, value); + g_plugin_log.WriteLn("(USBnull) 16 bit write at address %lx value %x", addr, value); break; default: //usbRu16(addr) = value; - USBLog.WriteLn("(USBnull) 16 bit write at address %lx value %x", addr, value); + g_plugin_log.WriteLn("(USBnull) 16 bit write at address %lx value %x", addr, value); } } @@ -208,12 +216,12 @@ USBwrite32(u32 addr, u32 value) switch (addr) { // Handle any appropriate addresses here. case 0x1f801600: - USBLog.WriteLn("(USBnull) 16 bit write at address %lx value %x", addr, value); + g_plugin_log.WriteLn("(USBnull) 16 bit write at address %lx value %x", addr, value); break; default: //usbRu32(addr) = value; - USBLog.WriteLn("(USBnull) 32 bit write at address %lx value %x", addr, value); + g_plugin_log.WriteLn("(USBnull) 32 bit write at address %lx value %x", addr, value); } } @@ -245,7 +253,7 @@ EXPORT_C_(void) USBsetRAM(void *mem) { ram = (s8 *)mem; - USBLog.WriteLn("*Setting ram."); + g_plugin_log.WriteLn("*Setting ram."); } EXPORT_C_(void) @@ -287,6 +295,3 @@ USBtest() // 0 if the plugin works, non-0 if it doesn't. return 0; } - -/* For operating systems that need an entry point for a dll/library, here it is. Defined in PS2Eext.h. */ -ENTRY_POINT; diff --git a/plugins/USBnull/USB.h b/plugins/USBnull/USB.h index 441f12cf62..a7be9fadcb 100644 --- a/plugins/USBnull/USB.h +++ b/plugins/USBnull/USB.h @@ -22,13 +22,7 @@ #include "PS2Edefs.h" #include "PS2Eext.h" -typedef struct -{ - int Log; -} Config; - extern USBcallback USBirq; -extern Config conf; // Previous USB plugins have needed this in ohci. static const s64 PSXCLK = 36864000; /* 36.864 Mhz */ @@ -42,8 +36,4 @@ extern s8 *usbregs, *ram; #define usbRu16(mem) (*(u16 *)&usbregs[(mem)&0xffff]) #define usbRu32(mem) (*(u32 *)&usbregs[(mem)&0xffff]) -extern void SaveConfig(); -extern void LoadConfig(); -extern void setLoggingState(); - #endif diff --git a/plugins/USBnull/Windows/USBnull.vcxproj b/plugins/USBnull/Windows/USBnull.vcxproj index 7044ad01d1..6e15fc3073 100644 --- a/plugins/USBnull/Windows/USBnull.vcxproj +++ b/plugins/USBnull/Windows/USBnull.vcxproj @@ -52,16 +52,17 @@ - - + + + diff --git a/plugins/USBnull/Windows/USBnull.vcxproj.filters b/plugins/USBnull/Windows/USBnull.vcxproj.filters index 8208bc47f3..90257927f9 100644 --- a/plugins/USBnull/Windows/USBnull.vcxproj.filters +++ b/plugins/USBnull/Windows/USBnull.vcxproj.filters @@ -15,17 +15,11 @@ - - Source Files - Source Files - - Header Files - Header Files @@ -35,4 +29,9 @@ Resource Files + + + Resource Files + + \ No newline at end of file diff --git a/plugins/dev9null/CMakeLists.txt b/plugins/dev9null/CMakeLists.txt index 1fb0a3e7b5..8ac97c3bb6 100644 --- a/plugins/dev9null/CMakeLists.txt +++ b/plugins/dev9null/CMakeLists.txt @@ -12,12 +12,10 @@ set(dev9nullFinalFlags "") # dev9null sources set(dev9nullSources - Config.cpp DEV9.cpp) # dev9null headers set(dev9nullHeaders - Config.h DEV9.h) # dev9null Linux sources diff --git a/plugins/dev9null/Config.cpp b/plugins/dev9null/Config.cpp deleted file mode 100644 index e102fd8dff..0000000000 --- a/plugins/dev9null/Config.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* DEV9null - * Copyright (C) 2002-2010 Pcsx2 Team - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include -using namespace std; - -#include "Config.h" -#include "DEV9.h" - -extern string s_strIniPath; -extern PluginLog Dev9Log; -PluginConf Ini; - -void setLoggingState() -{ - if (conf.Log) { - Dev9Log.WriteToConsole = true; - Dev9Log.WriteToFile = true; - } else { - Dev9Log.WriteToConsole = false; - Dev9Log.WriteToFile = false; - } -} - -EXPORT_C_(void) -DEV9configure() -{ - LoadConfig(); - PluginNullConfigure("Since this is a null plugin, all that is really configurable is logging.", conf.Log); - SaveConfig(); -} - -void LoadConfig() -{ - string IniPath = s_strIniPath + "/Dev9null.ini"; - if (!Ini.Open(IniPath, READ_FILE)) { - Dev9Log.WriteLn("Failed to open %s", IniPath.c_str()); - SaveConfig(); - return; - } - - conf.Log = Ini.ReadInt("logging", 0); - Ini.Close(); -} - -void SaveConfig() -{ - string IniPath = s_strIniPath + "/Dev9null.ini"; - if (!Ini.Open(IniPath, WRITE_FILE)) { - Dev9Log.WriteLn("Failed to open %s", IniPath.c_str()); - return; - } - - Ini.WriteInt("logging", conf.Log); - Ini.Close(); -} diff --git a/plugins/dev9null/Config.h b/plugins/dev9null/Config.h deleted file mode 100644 index 1013380a2c..0000000000 --- a/plugins/dev9null/Config.h +++ /dev/null @@ -1,24 +0,0 @@ -/* dev9null - * Copyright (C) 2002-2010 PCSX2 Team - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -void SaveConfig(); -void LoadConfig(); -void SysMessage(char *fmt, ...); - -//#define is_checked(main_widget, widget_name) (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(main_widget, widget_name)))) -//#define set_checked(main_widget,widget_name, state) gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(main_widget, widget_name)), state) diff --git a/plugins/dev9null/DEV9.cpp b/plugins/dev9null/DEV9.cpp index 6eb1400d91..1901306c34 100644 --- a/plugins/dev9null/DEV9.cpp +++ b/plugins/dev9null/DEV9.cpp @@ -32,6 +32,7 @@ using namespace std; #include "DEV9.h" #include "svnrev.h" +#include "null/config.inl" const unsigned char version = PS2E_DEV9_VERSION; const unsigned char revision = 0; @@ -47,14 +48,19 @@ __aligned16 s8 dev9regs[0x10000]; string s_strIniPath = "inis"; string s_strLogPath = "logs"; -PluginLog Dev9Log; -Config conf; +EXPORT_C_(void) +DEV9configure() +{ + const std::string ini_path = s_strIniPath + "/Dev9null.ini"; + LoadConfig(ini_path); + ConfigureLogging(); + SaveConfig(ini_path); +} void LogInit() { const std::string LogFile(s_strLogPath + "/dev9null.log"); - setLoggingState(); - Dev9Log.Open(LogFile); + g_plugin_log.Open(LogFile); } EXPORT_C_(void) @@ -64,7 +70,7 @@ DEV9setLogDir(const char *dir) s_strLogPath = (dir == NULL) ? "logs" : dir; // Reload the log file after updated the path - Dev9Log.Close(); + g_plugin_log.Close(); LogInit(); } @@ -90,11 +96,10 @@ PS2EgetLibVersion2(u32 type) EXPORT_C_(s32) DEV9init() { - LoadConfig(); - setLoggingState(); + LoadConfig(s_strIniPath + "/Dev9null.ini"); LogInit(); - Dev9Log.WriteLn("dev9null plugin version %d,%d", revision, build); - Dev9Log.WriteLn("Initializing dev9null"); + g_plugin_log.WriteLn("dev9null plugin version %d,%d", revision, build); + g_plugin_log.WriteLn("Initializing dev9null"); // Initialize anything that needs to be initialized. memset(dev9regs, 0, sizeof(dev9regs)); return 0; @@ -103,14 +108,14 @@ DEV9init() EXPORT_C_(void) DEV9shutdown() { - Dev9Log.WriteLn("Shutting down Dev9null."); - Dev9Log.Close(); + g_plugin_log.WriteLn("Shutting down Dev9null."); + g_plugin_log.Close(); } EXPORT_C_(s32) DEV9open(void *pDsp) { - Dev9Log.WriteLn("Opening Dev9null."); + g_plugin_log.WriteLn("Opening Dev9null."); // Get anything ready we need to. Opening and creating hard // drive files, for example. return 0; @@ -119,7 +124,7 @@ DEV9open(void *pDsp) EXPORT_C_(void) DEV9close() { - Dev9Log.WriteLn("Closing Dev9null."); + g_plugin_log.WriteLn("Closing Dev9null."); // Close files opened. } @@ -134,7 +139,7 @@ DEV9read8(u32 addr) break; // We need to have at least one case to avoid warnings. default: //value = dev9Ru8(addr); - Dev9Log.WriteLn("*Unknown 8 bit read at address %lx", addr); + g_plugin_log.WriteLn("*Unknown 8 bit read at address %lx", addr); break; } return value; @@ -167,7 +172,7 @@ DEV9read16(u32 addr) break; default: //value = dev9Ru16(addr); - Dev9Log.WriteLn("*Unknown 16 bit read at address %lx", addr); + g_plugin_log.WriteLn("*Unknown 16 bit read at address %lx", addr); break; } @@ -184,7 +189,7 @@ DEV9read32(u32 addr) break; default: //value = dev9Ru32(addr); - Dev9Log.WriteLn("*Unknown 32 bit read at address %lx", addr); + g_plugin_log.WriteLn("*Unknown 32 bit read at address %lx", addr); break; } @@ -198,7 +203,7 @@ DEV9write8(u32 addr, u8 value) case 0x10000038: /*dev9Ru8(addr) = value;*/ break; default: - Dev9Log.WriteLn("*Unknown 8 bit write; address %lx = %x", addr, value); + g_plugin_log.WriteLn("*Unknown 8 bit write; address %lx = %x", addr, value); //dev9Ru8(addr) = value; break; } @@ -213,7 +218,7 @@ DEV9write16(u32 addr, u16 value) case 0x10000038: /*dev9Ru16(addr) = value;*/ break; default: - Dev9Log.WriteLn("*Unknown 16 bit write; address %lx = %x", addr, value); + g_plugin_log.WriteLn("*Unknown 16 bit write; address %lx = %x", addr, value); //dev9Ru16(addr) = value; break; } @@ -226,7 +231,7 @@ DEV9write32(u32 addr, u32 value) case 0x10000038: /*dev9Ru32(addr) = value;*/ break; default: - Dev9Log.WriteLn("*Unknown 32 bit write; address %lx = %x", addr, value); + g_plugin_log.WriteLn("*Unknown 32 bit write; address %lx = %x", addr, value); //dev9Ru32(addr) = value; break; } @@ -238,7 +243,7 @@ DEV9dmaRead(s32 channel, u32 *data, u32 bytesLeft, u32 *bytesProcessed) { // You'll want to put your own DMA8 reading code here. // Time to interact with your fake (or real) hardware. - Dev9Log.WriteLn("Reading DMA8 Mem."); + g_plugin_log.WriteLn("Reading DMA8 Mem."); *bytesProcessed = bytesLeft; return 0; } @@ -247,7 +252,7 @@ EXPORT_C_(s32) DEV9dmaWrite(s32 channel, u32 *data, u32 bytesLeft, u32 *bytesProcessed) { // See above. - Dev9Log.WriteLn("Writing DMA8 Mem."); + g_plugin_log.WriteLn("Writing DMA8 Mem."); *bytesProcessed = bytesLeft; return 0; } @@ -263,14 +268,14 @@ DEV9readDMA8Mem(u32 *pMem, int size) { // You'll want to put your own DMA8 reading code here. // Time to interact with your fake (or real) hardware. - Dev9Log.WriteLn("Reading DMA8 Mem."); + g_plugin_log.WriteLn("Reading DMA8 Mem."); } EXPORT_C_(void) DEV9writeDMA8Mem(u32 *pMem, int size) { // See above. - Dev9Log.WriteLn("Writing DMA8 Mem."); + g_plugin_log.WriteLn("Writing DMA8 Mem."); } //#endif @@ -328,6 +333,3 @@ DEV9freeze(int mode, freezeData *data) } return 0; } - -/* For operating systems that need an entry point for a dll/library, here it is. Defined in PS2Eext.h. */ -ENTRY_POINT; diff --git a/plugins/dev9null/DEV9.h b/plugins/dev9null/DEV9.h index baa46d6c97..6d2141b898 100644 --- a/plugins/dev9null/DEV9.h +++ b/plugins/dev9null/DEV9.h @@ -25,21 +25,11 @@ #include "PS2Edefs.h" #include "PS2Eext.h" -typedef struct -{ - s32 Log; -} Config; - -extern Config conf; - extern const unsigned char version; extern const unsigned char revision; extern const unsigned char build; extern const unsigned int minor; -void SaveConfig(); -void LoadConfig(); - extern void (*DEV9irq)(int); extern __aligned16 s8 dev9regs[0x10000]; @@ -50,6 +40,4 @@ extern __aligned16 s8 dev9regs[0x10000]; #define dev9Ru16(mem) (*(u16 *)&dev9regs[(mem)&0xffff]) #define dev9Ru32(mem) (*(u32 *)&dev9regs[(mem)&0xffff]) -extern void setLoggingState(); - #endif diff --git a/plugins/dev9null/Windows/DEV9null.vcxproj b/plugins/dev9null/Windows/DEV9null.vcxproj index bb75071811..fd12b626b1 100644 --- a/plugins/dev9null/Windows/DEV9null.vcxproj +++ b/plugins/dev9null/Windows/DEV9null.vcxproj @@ -53,14 +53,15 @@ - - + + + diff --git a/plugins/dev9null/Windows/DEV9null.vcxproj.filters b/plugins/dev9null/Windows/DEV9null.vcxproj.filters index 91d1762b73..40525a7bab 100644 --- a/plugins/dev9null/Windows/DEV9null.vcxproj.filters +++ b/plugins/dev9null/Windows/DEV9null.vcxproj.filters @@ -10,9 +10,6 @@ Source Files - - Source Files - @@ -21,6 +18,8 @@ - + + + \ No newline at end of file