From 892527e53b7f428a0472d007dab1ada8d51a9551 Mon Sep 17 00:00:00 2001 From: Fabrice de Gans Date: Sat, 11 Feb 2023 18:55:30 -0800 Subject: [PATCH] Move ConfigManager to SDL This removes ConfigManager from common source and header files and moves it to be only used by the SDL frontend. --- CMakeLists.txt | 4 ++-- src/System.h | 27 +++++++++++++++++++++ src/gb/GB.cpp | 1 - src/gb/gbCheats.cpp | 1 - src/gb/gbCheats.h | 1 - src/gb/gbGfx.cpp | 1 - src/gba/Cheats.h | 4 +++- src/gba/GBA-arm.cpp | 1 - src/gba/GBA-thumb.cpp | 1 - src/gba/GBA.cpp | 5 +++- src/libretro/UtilRetro.cpp | 1 - src/libretro/libretro.cpp | 2 +- src/{common => sdl}/ConfigManager.cpp | 2 -- src/{common => sdl}/ConfigManager.h | 28 ---------------------- src/sdl/SDL.cpp | 3 ++- src/sdl/inputSDL.cpp | 2 +- src/wx/config/internal/option-internal.cpp | 2 +- src/wx/faudio.cpp | 2 +- src/wx/guiinit.cpp | 4 ++-- src/wx/wxvbam.cpp | 19 +++++++++------ 20 files changed, 56 insertions(+), 55 deletions(-) rename src/{common => sdl}/ConfigManager.cpp (99%) rename src/{common => sdl}/ConfigManager.h (69%) diff --git a/CMakeLists.txt b/CMakeLists.txt index c26d659a..ee7896af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -862,7 +862,6 @@ endif() set( SRC_MAIN src/Util.cpp - src/common/ConfigManager.cpp src/common/dictionary.c src/common/iniparser.c src/common/Patch.cpp @@ -879,7 +878,6 @@ set( src/System.h src/Util.h src/common/array.h - src/common/ConfigManager.h src/common/dictionary.h src/common/iniparser.h src/common/memgzio.h @@ -1015,6 +1013,7 @@ set( set( SRC_SDL + src/sdl/ConfigManager.cpp src/sdl/SDL.cpp src/sdl/filters.cpp src/sdl/text.cpp @@ -1027,6 +1026,7 @@ set( set( HDR_SDL + src/sdl/ConfigManager.h src/sdl/filters.h src/sdl/text.h src/sdl/inputSDL.h diff --git a/src/System.h b/src/System.h index 46eab9a2..08db09d0 100644 --- a/src/System.h +++ b/src/System.h @@ -49,6 +49,32 @@ struct EmulatedSystem { int emuCount; }; +extern struct CoreOptions { + bool cpuIsMultiBoot = false; + bool mirroringEnable = true; + bool parseDebug = true; + bool speedHack = false; + bool speedup = false; + bool speedup_throttle_frame_skip = false; + int cheatsEnabled = 1; + int cpuDisableSfx = 0; + int cpuSaveType = 0; + int layerSettings = 0xff00; + int layerEnable = 0xff00; + int rtcEnabled = 0; + int saveType = 0; + int skipBios = 0; + int skipSaveGameBattery = 1; + int skipSaveGameCheats = 0; + int useBios = 0; + int winGbPrinterEnabled = 1; + uint32_t speedup_throttle = 100; + uint32_t speedup_frame_skip = 9; + uint32_t throttle = 100; + const char *loadDotCodeFile = nullptr; + const char *saveDotCodeFile = nullptr; +} coreOptions; + extern void log(const char *, ...); extern bool systemPauseOnFrame(); extern void systemGbPrint(uint8_t *, int, int, int, int, int); @@ -96,6 +122,7 @@ extern int systemVerbose; extern int systemFrameSkip; extern int systemSaveUpdateCounter; extern int systemSpeed; +#define MAX_CHEATS 16384 #define SYSTEM_SAVE_UPDATED 30 #define SYSTEM_SAVE_NOT_UPDATED 0 #endif // SYSTEM_H diff --git a/src/gb/GB.cpp b/src/gb/GB.cpp index 74b6db45..755ffd52 100644 --- a/src/gb/GB.cpp +++ b/src/gb/GB.cpp @@ -9,7 +9,6 @@ #include "../NLS.h" #include "../System.h" #include "../Util.h" -#include "../common/ConfigManager.h" #include "../gba/GBALink.h" #include "../gba/Sound.h" #include "gb.h" diff --git a/src/gb/gbCheats.cpp b/src/gb/gbCheats.cpp index bf8207f7..43e75623 100644 --- a/src/gb/gbCheats.cpp +++ b/src/gb/gbCheats.cpp @@ -7,7 +7,6 @@ #include "../System.h" #include "../Util.h" -#include "../common/ConfigManager.h" #include "gb.h" #include "gbCheats.h" #include "gbGlobals.h" diff --git a/src/gb/gbCheats.h b/src/gb/gbCheats.h index 03287424..b32e44f7 100644 --- a/src/gb/gbCheats.h +++ b/src/gb/gbCheats.h @@ -2,7 +2,6 @@ #define GBCHEATS_H #include "../System.h" -#include "../common/ConfigManager.h" struct gbXxCheat { char cheatDesc[100]; diff --git a/src/gb/gbGfx.cpp b/src/gb/gbGfx.cpp index c019cbf7..8be051a6 100644 --- a/src/gb/gbGfx.cpp +++ b/src/gb/gbGfx.cpp @@ -1,7 +1,6 @@ #include #include "../Util.h" -#include "../common/ConfigManager.h" #include "gbGlobals.h" #include "gbSGB.h" diff --git a/src/gba/Cheats.h b/src/gba/Cheats.h index 2b235d65..2a62f84e 100644 --- a/src/gba/Cheats.h +++ b/src/gba/Cheats.h @@ -1,7 +1,9 @@ #ifndef CHEATS_H #define CHEATS_H -#include "../common/ConfigManager.h" +#include + +#include "../System.h" struct CheatsData { int code; diff --git a/src/gba/GBA-arm.cpp b/src/gba/GBA-arm.cpp index 318b700b..656d5df0 100644 --- a/src/gba/GBA-arm.cpp +++ b/src/gba/GBA-arm.cpp @@ -7,7 +7,6 @@ #include "../NLS.h" #include "../System.h" #include "../Util.h" -#include "../common/ConfigManager.h" #include "Cheats.h" #include "EEprom.h" #include "Flash.h" diff --git a/src/gba/GBA-thumb.cpp b/src/gba/GBA-thumb.cpp index 96dd0a60..e7a5865c 100644 --- a/src/gba/GBA-thumb.cpp +++ b/src/gba/GBA-thumb.cpp @@ -10,7 +10,6 @@ #include "../NLS.h" #include "../System.h" #include "../Util.h" -#include "../common/ConfigManager.h" #include "Cheats.h" #include "EEprom.h" #include "Flash.h" diff --git a/src/gba/GBA.cpp b/src/gba/GBA.cpp index 7aeec5fe..a6ac1cc7 100644 --- a/src/gba/GBA.cpp +++ b/src/gba/GBA.cpp @@ -11,7 +11,6 @@ #include "../NLS.h" #include "../System.h" #include "../Util.h" -#include "../common/ConfigManager.h" #include "../common/Port.h" #include "Cheats.h" #include "EEprom.h" @@ -37,6 +36,10 @@ #define _stricmp strcasecmp #endif +#ifdef _MSC_VER +#define strdup _strdup +#endif + extern int emulating; bool debugger; diff --git a/src/libretro/UtilRetro.cpp b/src/libretro/UtilRetro.cpp index 96234989..3261e628 100644 --- a/src/libretro/UtilRetro.cpp +++ b/src/libretro/UtilRetro.cpp @@ -8,7 +8,6 @@ #include "System.h" #include "Util.h" #include "common/Port.h" -#include "common/ConfigManager.h" #include "gba/Flash.h" #include "gba/GBA.h" #include "gba/Globals.h" diff --git a/src/libretro/libretro.cpp b/src/libretro/libretro.cpp index 565f82dc..bec98d65 100644 --- a/src/libretro/libretro.cpp +++ b/src/libretro/libretro.cpp @@ -16,7 +16,6 @@ #include "../apu/Gb_Apu.h" #include "../apu/Gb_Oscs.h" #include "../common/Port.h" -#include "../common/ConfigManager.h" #include "../gba/Cheats.h" #include "../gba/EEprom.h" #include "../gba/Flash.h" @@ -65,6 +64,7 @@ static unsigned option_gbPalette = 0; static bool option_lcdfilter = false; // filters +typedef void (*IFBFilterFunc)(uint8_t*, uint32_t, int, int); static IFBFilterFunc ifb_filter_func = NULL; static unsigned retropad_device[4] = {0}; diff --git a/src/common/ConfigManager.cpp b/src/sdl/ConfigManager.cpp similarity index 99% rename from src/common/ConfigManager.cpp rename to src/sdl/ConfigManager.cpp index 87248978..57c00634 100644 --- a/src/common/ConfigManager.cpp +++ b/src/sdl/ConfigManager.cpp @@ -16,10 +16,8 @@ extern "C" { #include #include #include -#include #include "../common/Patch.h" -#include "../common/ConfigManager.h" #include "../gba/GBA.h" #include "../gba/agbprint.h" #include "../gba/Flash.h" diff --git a/src/common/ConfigManager.h b/src/sdl/ConfigManager.h similarity index 69% rename from src/common/ConfigManager.h rename to src/sdl/ConfigManager.h index c00b8a0e..cbbafa45 100644 --- a/src/common/ConfigManager.h +++ b/src/sdl/ConfigManager.h @@ -18,34 +18,6 @@ #endif #endif // ! __GNUC__ -#define MAX_CHEATS 16384 - -extern struct CoreOptions { - bool cpuIsMultiBoot = false; - bool mirroringEnable = true; - bool parseDebug = true; - bool speedHack = false; - bool speedup = false; - bool speedup_throttle_frame_skip = false; - int cheatsEnabled = 1; - int cpuDisableSfx = 0; - int cpuSaveType = 0; - int layerSettings = 0xff00; - int layerEnable = 0xff00; - int rtcEnabled = 0; - int saveType = 0; - int skipBios = 0; - int skipSaveGameBattery = 1; - int skipSaveGameCheats = 0; - int useBios = 0; - int winGbPrinterEnabled = 1; - uint32_t speedup_throttle = 100; - uint32_t speedup_frame_skip = 9; - uint32_t throttle = 100; - const char *loadDotCodeFile = nullptr; - const char *saveDotCodeFile = nullptr; -} coreOptions; - extern const char *biosFileNameGB; extern const char *biosFileNameGBA; extern const char *biosFileNameGBC; diff --git a/src/sdl/SDL.cpp b/src/sdl/SDL.cpp index e720d3e8..77531ab8 100644 --- a/src/sdl/SDL.cpp +++ b/src/sdl/SDL.cpp @@ -46,7 +46,6 @@ #include "SDL.h" #include "../Util.h" -#include "../common/ConfigManager.h" #include "../common/Patch.h" #include "../gb/gb.h" #include "../gb/gbCheats.h" @@ -60,6 +59,8 @@ #include "../gba/agbprint.h" #include "../common/SoundSDL.h" + +#include "ConfigManager.h" #include "filters.h" #include "inputSDL.h" #include "text.h" diff --git a/src/sdl/inputSDL.cpp b/src/sdl/inputSDL.cpp index 680db862..1187019c 100644 --- a/src/sdl/inputSDL.cpp +++ b/src/sdl/inputSDL.cpp @@ -16,7 +16,7 @@ // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "inputSDL.h" -#include "../common/ConfigManager.h" +#include "ConfigManager.h" #define SDLBUTTONS_NUM 14 diff --git a/src/wx/config/internal/option-internal.cpp b/src/wx/config/internal/option-internal.cpp index f465392e..e15e455c 100644 --- a/src/wx/config/internal/option-internal.cpp +++ b/src/wx/config/internal/option-internal.cpp @@ -8,7 +8,7 @@ #include #include -#include "../common/ConfigManager.h" +#include "../System.h" #include "../gb/gbGlobals.h" #include "opts.h" diff --git a/src/wx/faudio.cpp b/src/wx/faudio.cpp index 57dd95b6..a49bec67 100644 --- a/src/wx/faudio.cpp +++ b/src/wx/faudio.cpp @@ -544,7 +544,7 @@ void FAudio_Output::write(uint16_t* finalWave, int length) break; } else { // the maximum number of buffers is currently queued - if (!coreOptions.speedup && throttle && !gba_joybus_active) { + if (!coreOptions.speedup && coreOptions.throttle && !gba_joybus_active) { // wait for one buffer to finish playing if (WaitForSingleObject(notify.hBufferEndEvent, 10000) == WAIT_TIMEOUT) { device_changed = true; diff --git a/src/wx/guiinit.cpp b/src/wx/guiinit.cpp index f1cbf6da..1f859856 100644 --- a/src/wx/guiinit.cpp +++ b/src/wx/guiinit.cpp @@ -25,8 +25,8 @@ #include "../gba/CheatSearch.h" #include "config/game-control.h" -#include "config/option.h" #include "config/option-proxy.h" +#include "config/option.h" #include "config/user-input.h" #include "dialogs/display-config.h" #include "opts.h" @@ -2881,7 +2881,7 @@ bool MainFrame::BindControls() MenuOptionIntMask("VideoLayersOBJWIN", coreOptions.layerSettings, (1 << 15)); MenuOptionBool("CheatsAutoSaveLoad", gopts.autoload_cheats); MenuOptionIntMask("CheatsEnable", coreOptions.cheatsEnabled, 1); - SetMenuOption("ColorizerHack", OPTION(kGBColorizerHack) ? 1 : 0); + SetMenuOption("ColorizerHack", OPTION(kGBColorizerHack)); MenuOptionIntMask("KeepSaves", coreOptions.skipSaveGameBattery, 1); MenuOptionIntMask("KeepCheats", coreOptions.skipSaveGameCheats, 1); MenuOptionBool("LoadGameAutoLoad", gopts.autoload_state); diff --git a/src/wx/wxvbam.cpp b/src/wx/wxvbam.cpp index 52e26217..f7280682 100644 --- a/src/wx/wxvbam.cpp +++ b/src/wx/wxvbam.cpp @@ -26,6 +26,8 @@ #include #include +#include "../gba/remote.h" + // The built-in xrc file #include "builtin-xrc.h" @@ -41,8 +43,15 @@ namespace { static const wxString kOldConfigFileName("vbam.conf"); static const wxString knewConfigFileName("vbam.ini"); +static const char kDotDir[] = "visualboyadvance-m"; } // namespace +#ifndef NO_DEBUGGER +void(*dbgMain)() = remoteStubMain; +void(*dbgSignal)(int, int) = remoteStubSignal; +void(*dbgOutput)(const char *, uint32_t) = debuggerOutput; +#endif + #ifdef __WXMSW__ int __stdcall WinMain(HINSTANCE hInstance, @@ -743,21 +752,17 @@ bool wxvbamApp::OnCmdLineParsed(wxCmdLineParser& cl) } } - home = strdup(wxString(wxApp::argv[0]).char_str()); - SetHome(home); - LoadConfig(); // Parse command line arguments (overrides ini) - ReadOpts(argc, (char**)argv); return true; } wxString wxvbamApp::GetConfigDir() { - return GetAbsolutePath(wxString((get_xdg_user_config_home() + DOT_DIR).c_str(), wxConvLibc)); + return GetAbsolutePath(wxString((get_xdg_user_config_home() + kDotDir).c_str(), wxConvLibc)); } wxString wxvbamApp::GetDataDir() { - return GetAbsolutePath(wxString((get_xdg_user_data_home() + DOT_DIR).c_str(), wxConvLibc)); + return GetAbsolutePath(wxString((get_xdg_user_data_home() + kDotDir).c_str(), wxConvLibc)); } wxvbamApp::~wxvbamApp() { @@ -929,7 +934,7 @@ wxString MainFrame::GetGamePath(wxString path) if (!wxIsWritable(game_path)) { - game_path = wxGetApp().GetAbsolutePath(wxString((get_xdg_user_data_home() + DOT_DIR).c_str(), wxConvLibc)); + game_path = wxGetApp().GetAbsolutePath(wxString((get_xdg_user_data_home() + kDotDir).c_str(), wxConvLibc)); wxFileName::Mkdir(game_path, 0777, wxPATH_MKDIR_FULL); }