Move more options to g_owned_opts

* Moves most remaining options toggled by menu items to g_owned_opts and
  modifies associated usage.
* Adds more obervers to handle option changes.
This commit is contained in:
Fabrice de Gans 2023-04-07 14:56:30 -07:00 committed by Fabrice de Gans
parent 928a61704f
commit 86bef62faf
14 changed files with 178 additions and 257 deletions

View File

@ -52,6 +52,7 @@ struct EmulatedSystem {
extern struct CoreOptions { extern struct CoreOptions {
bool cpuIsMultiBoot = false; bool cpuIsMultiBoot = false;
bool mirroringEnable = true; bool mirroringEnable = true;
bool skipBios = false;
bool parseDebug = true; bool parseDebug = true;
bool speedHack = false; bool speedHack = false;
bool speedup = false; bool speedup = false;
@ -63,7 +64,6 @@ extern struct CoreOptions {
int layerEnable = 0xff00; int layerEnable = 0xff00;
int rtcEnabled = 0; int rtcEnabled = 0;
int saveType = 0; int saveType = 0;
int skipBios = 0;
int skipSaveGameBattery = 1; int skipSaveGameBattery = 1;
int skipSaveGameCheats = 0; int skipSaveGameCheats = 0;
int useBios = 0; int useBios = 0;

View File

@ -42,7 +42,7 @@ int const SOUND_CLOCK_TICKS_ = 280896; // ~1074 samples per frame
static uint16_t soundFinalWave[1600]; static uint16_t soundFinalWave[1600];
long soundSampleRate = 44100; long soundSampleRate = 44100;
bool soundInterpolation = true; bool g_gbaSoundInterpolation = true;
bool soundPaused = true; bool soundPaused = true;
float soundFiltering = 0.5f; float soundFiltering = 0.5f;
int SOUND_CLOCK_TICKS = SOUND_CLOCK_TICKS_; int SOUND_CLOCK_TICKS = SOUND_CLOCK_TICKS_;
@ -156,7 +156,7 @@ void Gba_Pcm::update(int dac)
last_amp = dac; last_amp = dac;
int filter = 0; int filter = 0;
if (soundInterpolation) { if (g_gbaSoundInterpolation) {
// base filtering on how long since last sample was output // base filtering on how long since last sample was output
int period = time - last_time; int period = time - last_time;

View File

@ -42,7 +42,7 @@ long soundGetSampleRate();
void soundSetSampleRate(long sampleRate); void soundSetSampleRate(long sampleRate);
// Sound settings // Sound settings
extern bool soundInterpolation; // 1 if PCM should have low-pass filtering extern bool g_gbaSoundInterpolation; // 1 if PCM should have low-pass filtering
extern float soundFiltering; // 0.0 = none, 1.0 = max extern float soundFiltering; // 0.0 = none, 1.0 = max
//// GBA sound emulation //// GBA sound emulation

View File

@ -1036,8 +1036,8 @@ static void update_variables(bool startup)
} }
if (sound_changed) { if (sound_changed) {
soundInterpolation = option_sndInterpolation; g_gbaSoundInterpolation = option_sndInterpolation;
soundFiltering = option_sndFiltering; soundFiltering = option_sndFiltering;
} }
var.key = "vbam_usebios"; var.key = "vbam_usebios";

View File

@ -83,6 +83,7 @@ enum named_opts
OPT_SCREEN_SHOT_DIR, OPT_SCREEN_SHOT_DIR,
OPT_SHOW_SPEED, OPT_SHOW_SPEED,
OPT_SHOW_SPEED_TRANSPARENT, OPT_SHOW_SPEED_TRANSPARENT,
OPT_SKIP_BIOS,
OPT_SOUND_FILTERING, OPT_SOUND_FILTERING,
OPT_SPEEDUP_THROTTLE, OPT_SPEEDUP_THROTTLE,
OPT_SPEEDUP_FRAME_SKIP, OPT_SPEEDUP_FRAME_SKIP,
@ -212,7 +213,7 @@ struct option argOptions[] = {
{ "show-speed-detailed", no_argument, &showSpeed, 2 }, { "show-speed-detailed", no_argument, &showSpeed, 2 },
{ "show-speed-normal", no_argument, &showSpeed, 1 }, { "show-speed-normal", no_argument, &showSpeed, 1 },
{ "show-speed-transparent", required_argument, 0, OPT_SHOW_SPEED_TRANSPARENT }, { "show-speed-transparent", required_argument, 0, OPT_SHOW_SPEED_TRANSPARENT },
{ "skip-bios", no_argument, &coreOptions.skipBios, 1 }, { "skip-bios", no_argument, 0, OPT_SKIP_BIOS},
{ "skip-save-game-battery", no_argument, &coreOptions.skipSaveGameBattery, 1 }, { "skip-save-game-battery", no_argument, &coreOptions.skipSaveGameBattery, 1 },
{ "skip-save-game-cheats", no_argument, &coreOptions.skipSaveGameCheats, 1 }, { "skip-save-game-cheats", no_argument, &coreOptions.skipSaveGameCheats, 1 },
{ "sound-filtering", required_argument, 0, OPT_SOUND_FILTERING }, { "sound-filtering", required_argument, 0, OPT_SOUND_FILTERING },
@ -330,7 +331,7 @@ void LoadConfig()
coreOptions.skipSaveGameBattery = ReadPref("skipSaveGameBattery", 1); coreOptions.skipSaveGameBattery = ReadPref("skipSaveGameBattery", 1);
coreOptions.skipSaveGameCheats = ReadPref("skipSaveGameCheats", 0); coreOptions.skipSaveGameCheats = ReadPref("skipSaveGameCheats", 0);
soundFiltering = (float)ReadPref("gbaSoundFiltering", 50) / 100.0f; soundFiltering = (float)ReadPref("gbaSoundFiltering", 50) / 100.0f;
soundInterpolation = ReadPref("gbaSoundInterpolation", 1); g_gbaSoundInterpolation = ReadPref("gbaSoundInterpolation", 1);
coreOptions.throttle = ReadPref("throttle", 100); coreOptions.throttle = ReadPref("throttle", 100);
coreOptions.speedup_throttle = ReadPref("speedupThrottle", 100); coreOptions.speedup_throttle = ReadPref("speedupThrottle", 100);
coreOptions.speedup_frame_skip = ReadPref("speedupFrameSkip", 9); coreOptions.speedup_frame_skip = ReadPref("speedupFrameSkip", 9);
@ -819,6 +820,11 @@ int ReadOpts(int argc, char ** argv)
} }
break; break;
case OPT_SKIP_BIOS:
// --skip-bios
coreOptions.skipBios = true;
break;
case OPT_AUTO_FRAME_SKIP: case OPT_AUTO_FRAME_SKIP:
// --auto-frame-skip // --auto-frame-skip
if (optarg) { if (optarg) {

View File

@ -25,8 +25,6 @@
wxStaticCast(wxGetApp().frame->FindWindowByName(n), wxDialog) wxStaticCast(wxGetApp().frame->FindWindowByName(n), wxDialog)
#endif #endif
void GDBBreak(MainFrame* mf);
bool cmditem_lt(const struct cmditem& cmd1, const struct cmditem& cmd2) bool cmditem_lt(const struct cmditem& cmd1, const struct cmditem& cmd2)
{ {
return wxStrcmp(cmd1.cmd, cmd2.cmd) < 0; return wxStrcmp(cmd1.cmd, cmd2.cmd) < 0;
@ -227,11 +225,7 @@ EVT_HANDLER(RecentReset, "Reset recent ROM list")
EVT_HANDLER(RecentFreeze, "Freeze recent ROM list (toggle)") EVT_HANDLER(RecentFreeze, "Freeze recent ROM list (toggle)")
{ {
bool menuPress = false; GetMenuOptionConfig("RecentFreeze", config::OptionID::kGenFreezeRecent);
GetMenuOptionBool("RecentFreeze", &menuPress);
toggleBooleanVar(&menuPress, &gopts.recent_freeze);
SetMenuOption("RecentFreeze", gopts.recent_freeze ? 1 : 0);
update_opts();
} }
// following 10 should really be a single ranged handler // following 10 should really be a single ranged handler
@ -239,101 +233,51 @@ EVT_HANDLER(RecentFreeze, "Freeze recent ROM list (toggle)")
EVT_HANDLER(wxID_FILE1, "Load recent ROM 1") EVT_HANDLER(wxID_FILE1, "Load recent ROM 1")
{ {
panel->LoadGame(gopts.recent->GetHistoryFile(0)); panel->LoadGame(gopts.recent->GetHistoryFile(0));
#ifndef NO_DEBUGGER
if (gopts.gdb_break_on_load)
GDBBreak();
#endif
} }
EVT_HANDLER(wxID_FILE2, "Load recent ROM 2") EVT_HANDLER(wxID_FILE2, "Load recent ROM 2")
{ {
panel->LoadGame(gopts.recent->GetHistoryFile(1)); panel->LoadGame(gopts.recent->GetHistoryFile(1));
#ifndef NO_DEBUGGER
if (gopts.gdb_break_on_load)
GDBBreak();
#endif
} }
EVT_HANDLER(wxID_FILE3, "Load recent ROM 3") EVT_HANDLER(wxID_FILE3, "Load recent ROM 3")
{ {
panel->LoadGame(gopts.recent->GetHistoryFile(2)); panel->LoadGame(gopts.recent->GetHistoryFile(2));
#ifndef NO_DEBUGGER
if (gopts.gdb_break_on_load)
GDBBreak();
#endif
} }
EVT_HANDLER(wxID_FILE4, "Load recent ROM 4") EVT_HANDLER(wxID_FILE4, "Load recent ROM 4")
{ {
panel->LoadGame(gopts.recent->GetHistoryFile(3)); panel->LoadGame(gopts.recent->GetHistoryFile(3));
#ifndef NO_DEBUGGER
if (gopts.gdb_break_on_load)
GDBBreak();
#endif
} }
EVT_HANDLER(wxID_FILE5, "Load recent ROM 5") EVT_HANDLER(wxID_FILE5, "Load recent ROM 5")
{ {
panel->LoadGame(gopts.recent->GetHistoryFile(4)); panel->LoadGame(gopts.recent->GetHistoryFile(4));
#ifndef NO_DEBUGGER
if (gopts.gdb_break_on_load)
GDBBreak();
#endif
} }
EVT_HANDLER(wxID_FILE6, "Load recent ROM 6") EVT_HANDLER(wxID_FILE6, "Load recent ROM 6")
{ {
panel->LoadGame(gopts.recent->GetHistoryFile(5)); panel->LoadGame(gopts.recent->GetHistoryFile(5));
#ifndef NO_DEBUGGER
if (gopts.gdb_break_on_load)
GDBBreak();
#endif
} }
EVT_HANDLER(wxID_FILE7, "Load recent ROM 7") EVT_HANDLER(wxID_FILE7, "Load recent ROM 7")
{ {
panel->LoadGame(gopts.recent->GetHistoryFile(6)); panel->LoadGame(gopts.recent->GetHistoryFile(6));
#ifndef NO_DEBUGGER
if (gopts.gdb_break_on_load)
GDBBreak();
#endif
} }
EVT_HANDLER(wxID_FILE8, "Load recent ROM 8") EVT_HANDLER(wxID_FILE8, "Load recent ROM 8")
{ {
panel->LoadGame(gopts.recent->GetHistoryFile(7)); panel->LoadGame(gopts.recent->GetHistoryFile(7));
#ifndef NO_DEBUGGER
if (gopts.gdb_break_on_load)
GDBBreak();
#endif
} }
EVT_HANDLER(wxID_FILE9, "Load recent ROM 9") EVT_HANDLER(wxID_FILE9, "Load recent ROM 9")
{ {
panel->LoadGame(gopts.recent->GetHistoryFile(8)); panel->LoadGame(gopts.recent->GetHistoryFile(8));
#ifndef NO_DEBUGGER
if (gopts.gdb_break_on_load)
GDBBreak();
#endif
} }
EVT_HANDLER(wxID_FILE10, "Load recent ROM 10") EVT_HANDLER(wxID_FILE10, "Load recent ROM 10")
{ {
panel->LoadGame(gopts.recent->GetHistoryFile(9)); panel->LoadGame(gopts.recent->GetHistoryFile(9));
#ifndef NO_DEBUGGER
if (gopts.gdb_break_on_load)
GDBBreak();
#endif
} }
static const struct rom_maker { static const struct rom_maker {
@ -1722,11 +1666,7 @@ EVT_HANDLER_MASK(LoadGameRecent, "Load most recent save", CMDEN_SAVST)
EVT_HANDLER(LoadGameAutoLoad, "Auto load most recent save (toggle)") EVT_HANDLER(LoadGameAutoLoad, "Auto load most recent save (toggle)")
{ {
bool menuPress = false; GetMenuOptionConfig("LoadGameAutoLoad", config::OptionID::kGenAutoLoadLastState);
GetMenuOptionBool("LoadGameAutoLoad", &menuPress);
toggleBooleanVar(&menuPress, &gopts.autoload_state);
SetMenuOption("LoadGameAutoLoad", gopts.autoload_state ? 1 : 0);
update_opts();
} }
EVT_HANDLER_MASK(LoadGame01, "Load saved state 1", CMDEN_SAVST) EVT_HANDLER_MASK(LoadGame01, "Load saved state 1", CMDEN_SAVST)
@ -1976,11 +1916,7 @@ EVT_HANDLER_MASK(CheatsSearch, "Create cheat...", CMDEN_GB | CMDEN_GBA)
// new // new
EVT_HANDLER(CheatsAutoSaveLoad, "Auto save/load cheats (toggle)") EVT_HANDLER(CheatsAutoSaveLoad, "Auto save/load cheats (toggle)")
{ {
bool menuPress = false; GetMenuOptionConfig("CheatsAutoSaveLoad", config::OptionID::kPrefAutoSaveLoadCheatList);
GetMenuOptionBool("CheatsAutoSaveLoad", &menuPress);
toggleBooleanVar(&menuPress, &gopts.autoload_cheats);
SetMenuOption("CheatsAutoSaveLoad", gopts.autoload_cheats ? 1 : 0);
update_opts();
} }
// was CheatsDisable // was CheatsDisable
@ -1998,7 +1934,7 @@ EVT_HANDLER(CheatsEnable, "Enable cheats (toggle)")
EVT_HANDLER(ColorizerHack, "Enable Colorizer Hack (toggle)") EVT_HANDLER(ColorizerHack, "Enable Colorizer Hack (toggle)")
{ {
GetMenuOptionConfig("ColorizerHack", config::OptionID::kGBColorizerHack); GetMenuOptionConfig("ColorizerHack", config::OptionID::kGBColorizerHack);
if (OPTION(kGBColorizerHack) && gopts.use_bios_file_gb) { if (OPTION(kGBColorizerHack) && OPTION(kPrefUseBiosGB)) {
wxLogError( wxLogError(
_("Cannot use Colorizer Hack when Game Boy BIOS File is enabled.")); _("Cannot use Colorizer Hack when Game Boy BIOS File is enabled."));
SetMenuOption("ColorizerHack", 0); SetMenuOption("ColorizerHack", 0);
@ -2335,8 +2271,7 @@ EVT_HANDLER(DebugGDBPort, "Configure port...")
EVT_HANDLER(DebugGDBBreakOnLoad, "Break on load") EVT_HANDLER(DebugGDBBreakOnLoad, "Break on load")
{ {
#ifndef NO_DEBUGGER #ifndef NO_DEBUGGER
GetMenuOptionBool("DebugGDBBreakOnLoad", &gopts.gdb_break_on_load); GetMenuOptionConfig("DebugGDBBreakOnLoad", config::OptionID::kPrefGDBBreakOnLoad);
update_opts();
#endif #endif
} }
@ -2925,42 +2860,32 @@ EVT_HANDLER(Printer, "Enable printer emulation")
EVT_HANDLER(PrintGather, "Automatically gather a full page before printing") EVT_HANDLER(PrintGather, "Automatically gather a full page before printing")
{ {
GetMenuOptionBool("PrintGather", &gopts.print_auto_page); GetMenuOptionConfig("PrintGather", config::OptionID::kGBPrintAutoPage);
update_opts();
} }
EVT_HANDLER(PrintSnap, "Automatically save printouts as screen captures with -print suffix") EVT_HANDLER(PrintSnap, "Automatically save printouts as screen captures with -print suffix")
{ {
GetMenuOptionBool("PrintSnap", &gopts.print_screen_cap); GetMenuOptionConfig("PrintSnap", config::OptionID::kGBPrintScreenCap);
update_opts();
} }
EVT_HANDLER(GBASoundInterpolation, "GBA sound interpolation") EVT_HANDLER(GBASoundInterpolation, "GBA sound interpolation")
{ {
GetMenuOptionBool("GBASoundInterpolation", &soundInterpolation); GetMenuOptionConfig("GBASoundInterpolation", config::OptionID::kSoundGBAInterpolation);
update_opts();
} }
EVT_HANDLER(GBDeclicking, "GB sound declicking") EVT_HANDLER(GBDeclicking, "GB sound declicking")
{ {
GetMenuOptionBool("GBDeclicking", &gopts.gb_declick); GetMenuOptionConfig("GBDeclicking", config::OptionID::kSoundGBDeclicking);
// note that setting declick may reset gb sound engine
gbSoundSetDeclicking(gopts.gb_declick);
update_opts();
} }
EVT_HANDLER(GBEnhanceSound, "Enable GB sound effects") EVT_HANDLER(GBEnhanceSound, "Enable GB sound effects")
{ {
GetMenuOptionBool("GBEnhanceSound", &gopts.gb_effects_config_enabled); GetMenuOptionConfig("GBEnhanceSound", config::OptionID::kSoundGBEnableEffects);
gb_effects_config.enabled = gopts.gb_effects_config_enabled;
update_opts();
} }
EVT_HANDLER(GBSurround, "GB surround sound effect (%)") EVT_HANDLER(GBSurround, "GB surround sound effect (%)")
{ {
GetMenuOptionBool("GBSurround",&gopts.gb_effects_config_surround); GetMenuOptionConfig("GBSurround",config::OptionID::kSoundGBSurround);
gb_effects_config.surround = gopts.gb_effects_config_surround;
update_opts();
} }
EVT_HANDLER(AGBPrinter, "Enable AGB printer") EVT_HANDLER(AGBPrinter, "Enable AGB printer")
@ -2970,22 +2895,12 @@ EVT_HANDLER(AGBPrinter, "Enable AGB printer")
EVT_HANDLER_MASK(GBALcdFilter, "Enable LCD filter", CMDEN_GBA) EVT_HANDLER_MASK(GBALcdFilter, "Enable LCD filter", CMDEN_GBA)
{ {
bool menuPress = false; GetMenuOptionConfig("GBALcdFilter", config::OptionID::kGBALCDFilter);
GetMenuOptionBool("GBALcdFilter", &menuPress);
toggleBooleanVar(&menuPress, &gopts.gba_lcd_filter);
SetMenuOption("GBALcdFilter", gopts.gba_lcd_filter ? 1 : 0);
utilUpdateSystemColorMaps(gopts.gba_lcd_filter);
update_opts();
} }
EVT_HANDLER_MASK(GBLcdFilter, "Enable LCD filter", CMDEN_GB) EVT_HANDLER_MASK(GBLcdFilter, "Enable LCD filter", CMDEN_GB)
{ {
bool menuPress = false; GetMenuOptionConfig("GBLcdFilter", config::OptionID::kGBLCDFilter);
GetMenuOptionBool("GBLcdFilter", &menuPress);
toggleBooleanVar(&menuPress, &gopts.gb_lcd_filter);
SetMenuOption("GBLcdFilter", gopts.gb_lcd_filter ? 1 : 0);
utilUpdateSystemColorMaps(gopts.gb_lcd_filter);
update_opts();
} }
EVT_HANDLER(GBColorOption, "Enable GB color option") EVT_HANDLER(GBColorOption, "Enable GB color option")
@ -3005,18 +2920,7 @@ EVT_HANDLER(KeepOnTop, "Keep window on top")
EVT_HANDLER(StatusBar, "Enable status bar") EVT_HANDLER(StatusBar, "Enable status bar")
{ {
GetMenuOptionBool("StatusBar", &gopts.statusbar); GetMenuOptionConfig("StatusBar", config::OptionID::kGenStatusBar);
update_opts();
MainFrame* mf = wxGetApp().frame;
if (gopts.statusbar)
mf->GetStatusBar()->Show();
else
mf->GetStatusBar()->Hide();
mf->SendSizeEvent();
panel->AdjustSize(false);
mf->SendSizeEvent();
} }
EVT_HANDLER(NoStatusMsg, "Disable on-screen status messages") EVT_HANDLER(NoStatusMsg, "Disable on-screen status messages")
@ -3052,43 +2956,32 @@ EVT_HANDLER(Transparent, "Draw on-screen messages transparently")
EVT_HANDLER(SkipIntro, "Skip BIOS initialization") EVT_HANDLER(SkipIntro, "Skip BIOS initialization")
{ {
GetMenuOptionInt("SkipIntro", &coreOptions.skipBios, 1); GetMenuOptionConfig("SkipIntro", config::OptionID::kPrefSkipBios);
update_opts();
} }
EVT_HANDLER(BootRomEn, "Use the specified BIOS file for GBA") EVT_HANDLER(BootRomEn, "Use the specified BIOS file for GBA")
{ {
GetMenuOptionBool("BootRomEn", &gopts.use_bios_file_gba); GetMenuOptionConfig("BootRomEn", config::OptionID::kPrefUseBiosGBA);
update_opts();
} }
EVT_HANDLER(BootRomGB, "Use the specified BIOS file for GB") EVT_HANDLER(BootRomGB, "Use the specified BIOS file for GB")
{ {
int val = 0; GetMenuOptionConfig("BootRomGB", config::OptionID::kPrefUseBiosGB);
GetMenuOptionInt("BootRomGB", &val, 1); if (OPTION(kPrefUseBiosGB) && OPTION(kGBColorizerHack)) {
if (val == 1 && OPTION(kGBColorizerHack)) {
wxLogError(_("Cannot use Game Boy BIOS when Colorizer Hack is enabled.")); wxLogError(_("Cannot use Game Boy BIOS when Colorizer Hack is enabled."));
val = 0;
SetMenuOption("BootRomGB", 0); SetMenuOption("BootRomGB", 0);
OPTION(kPrefUseBiosGB) = false;
} }
gopts.use_bios_file_gb = val;
update_opts();
} }
EVT_HANDLER(BootRomGBC, "Use the specified BIOS file for GBC") EVT_HANDLER(BootRomGBC, "Use the specified BIOS file for GBC")
{ {
GetMenuOptionBool("BootRomGBC", &gopts.use_bios_file_gbc); GetMenuOptionConfig("BootRomGBC", config::OptionID::kPrefUseBiosGBC);
update_opts();
} }
EVT_HANDLER(VSync, "Wait for vertical sync") EVT_HANDLER(VSync, "Wait for vertical sync")
{ {
GetMenuOptionBool("VSync", &gopts.vsync); GetMenuOptionConfig("VSync", config::OptionID::kPrefVsync);
update_opts();
panel->ResetPanel();
} }
void MainFrame::EnableNetworkMenu() void MainFrame::EnableNetworkMenu()
@ -3098,7 +2991,7 @@ void MainFrame::EnableNetworkMenu()
if (gopts.gba_link_type != 0) if (gopts.gba_link_type != 0)
cmd_enable |= CMDEN_LINK_ANY; cmd_enable |= CMDEN_LINK_ANY;
if (gopts.link_proto) if (OPTION(kGBALinkProto))
cmd_enable &= ~CMDEN_LINK_ANY; cmd_enable &= ~CMDEN_LINK_ANY;
enable_menus(); enable_menus();
@ -3133,7 +3026,7 @@ EVT_HANDLER_MASK(LanLink, "Start Network link", CMDEN_LINK_ANY)
return; return;
} }
if (gopts.link_proto) { if (OPTION(kGBALinkProto)) {
// see above comment // see above comment
wxLogError(_("Network is not supported in local mode.")); wxLogError(_("Network is not supported in local mode."));
return; return;
@ -3172,22 +3065,17 @@ EVT_HANDLER(LinkType4Gameboy, "Link Gameboy")
EVT_HANDLER(LinkAuto, "Enable link at boot") EVT_HANDLER(LinkAuto, "Enable link at boot")
{ {
GetMenuOptionBool("LinkAuto", &gopts.link_auto); GetMenuOptionConfig("LinkAuto", config::OptionID::kGBALinkAuto);
update_opts();
} }
EVT_HANDLER(SpeedOn, "Enable faster network protocol by default") EVT_HANDLER(SpeedOn, "Enable faster network protocol by default")
{ {
GetMenuOptionBool("SpeedOn", &gopts.link_hacks); GetMenuOptionConfig("SpeedOn", config::OptionID::kGBALinkFast);
update_opts();
} }
EVT_HANDLER(LinkProto, "Local host IPC") EVT_HANDLER(LinkProto, "Local host IPC")
{ {
GetMenuOptionBool("LinkProto", &gopts.link_proto); GetMenuOptionConfig("LinkProto", config::OptionID::kGBALinkHost);
update_opts();
enable_menus();
EnableNetworkMenu();
} }
EVT_HANDLER(LinkConfigure, "Link options...") EVT_HANDLER(LinkConfigure, "Link options...")

View File

@ -10,6 +10,7 @@
#include <wx/log.h> #include <wx/log.h>
#include "../System.h" #include "../System.h"
#include "../gba/Sound.h"
#include "../gb/gbGlobals.h" #include "../gb/gbGlobals.h"
#include "opts.h" #include "opts.h"
@ -165,30 +166,46 @@ std::array<Option, kNbOptions>& Option::All() {
/// GB /// GB
wxString gb_bios = wxEmptyString; wxString gb_bios = wxEmptyString;
bool colorizer_hack = false; bool colorizer_hack = false;
bool gb_lcd_filter = false;
wxString gbc_bios = wxEmptyString; wxString gbc_bios = wxEmptyString;
bool print_auto_page = true;
bool print_screen_cap = false;
wxString gb_rom_dir = wxEmptyString; wxString gb_rom_dir = wxEmptyString;
wxString gbc_rom_dir = wxEmptyString; wxString gbc_rom_dir = wxEmptyString;
/// GBA /// GBA
bool gba_lcd_filter = false;
bool link_auto = false;
bool link_hacks = true;
bool link_proto = false;
wxString gba_rom_dir; wxString gba_rom_dir;
/// Core /// Core
bool agb_print = false; bool agb_print = false;
bool auto_frame_skip = false; bool auto_frame_skip = false;
bool auto_patch = true; bool auto_patch = true;
bool autoload_cheats = false;
uint32_t capture_format = 0; uint32_t capture_format = 0;
bool disable_status_messages = false; bool disable_status_messages = false;
uint32_t flash_size = 0; uint32_t flash_size = 0;
int32_t frame_skip = 0; int32_t frame_skip = 0;
bool gdb_break_on_load = false;
bool pause_when_inactive = false; bool pause_when_inactive = false;
uint32_t show_speed = 0; uint32_t show_speed = 0;
bool show_speed_transparent = false; bool show_speed_transparent = false;
bool use_bios_file_gb = false;
bool use_bios_file_gba = false;
bool use_bios_file_gbc = false;
bool vsync = false;
/// General /// General
bool autoload_state = false;
wxString battery_dir = wxEmptyString; wxString battery_dir = wxEmptyString;
bool recent_freeze = false;
wxString recording_dir = wxEmptyString; wxString recording_dir = wxEmptyString;
wxString screenshot_dir = wxEmptyString; wxString screenshot_dir = wxEmptyString;
wxString state_dir = wxEmptyString; wxString state_dir = wxEmptyString;
bool statusbar = false;
uint32_t ini_version = kIniLatestVersion; uint32_t ini_version = kIniLatestVersion;
/// Geometry /// Geometry
@ -202,6 +219,11 @@ std::array<Option, kNbOptions>& Option::All() {
/// UI /// UI
bool allow_keyboard_background_input = false; bool allow_keyboard_background_input = false;
bool allow_joystick_background_input = true; bool allow_joystick_background_input = true;
/// Sound
bool gb_declicking = true;
bool gb_effects_config_enabled = false;
bool gb_effects_config_surround = false;
}; };
static OwnedOptions g_owned_opts; static OwnedOptions g_owned_opts;
@ -227,40 +249,40 @@ std::array<Option, kNbOptions>& Option::All() {
Option(OptionID::kGBBiosFile, &g_owned_opts.gb_bios), Option(OptionID::kGBBiosFile, &g_owned_opts.gb_bios),
Option(OptionID::kGBColorOption, &gbColorOption), Option(OptionID::kGBColorOption, &gbColorOption),
Option(OptionID::kGBColorizerHack, &g_owned_opts.colorizer_hack), Option(OptionID::kGBColorizerHack, &g_owned_opts.colorizer_hack),
Option(OptionID::kGBLCDFilter, &gopts.gb_lcd_filter), Option(OptionID::kGBLCDFilter, &g_owned_opts.gb_lcd_filter),
Option(OptionID::kGBGBCBiosFile, &g_owned_opts.gbc_bios), Option(OptionID::kGBGBCBiosFile, &g_owned_opts.gbc_bios),
Option(OptionID::kGBPalette0, systemGbPalette), Option(OptionID::kGBPalette0, systemGbPalette),
Option(OptionID::kGBPalette1, systemGbPalette + 8), Option(OptionID::kGBPalette1, systemGbPalette + 8),
Option(OptionID::kGBPalette2, systemGbPalette + 16), Option(OptionID::kGBPalette2, systemGbPalette + 16),
Option(OptionID::kGBPrintAutoPage, &gopts.print_auto_page), Option(OptionID::kGBPrintAutoPage, &g_owned_opts.print_auto_page),
Option(OptionID::kGBPrintScreenCap, &gopts.print_screen_cap), Option(OptionID::kGBPrintScreenCap, &g_owned_opts.print_screen_cap),
Option(OptionID::kGBROMDir, &g_owned_opts.gb_rom_dir), Option(OptionID::kGBROMDir, &g_owned_opts.gb_rom_dir),
Option(OptionID::kGBGBCROMDir, &g_owned_opts.gbc_rom_dir), Option(OptionID::kGBGBCROMDir, &g_owned_opts.gbc_rom_dir),
/// GBA /// GBA
Option(OptionID::kGBABiosFile, &gopts.gba_bios), Option(OptionID::kGBABiosFile, &gopts.gba_bios),
Option(OptionID::kGBALCDFilter, &gopts.gba_lcd_filter), Option(OptionID::kGBALCDFilter, &g_owned_opts.gba_lcd_filter),
#ifndef NO_LINK #ifndef NO_LINK
Option(OptionID::kGBALinkAuto, &gopts.link_auto), Option(OptionID::kGBALinkAuto, &g_owned_opts.link_auto),
Option(OptionID::kGBALinkFast, &gopts.link_hacks), Option(OptionID::kGBALinkFast, &g_owned_opts.link_hacks),
Option(OptionID::kGBALinkHost, &gopts.link_host), Option(OptionID::kGBALinkHost, &gopts.link_host),
Option(OptionID::kGBAServerIP, &gopts.server_ip), Option(OptionID::kGBAServerIP, &gopts.server_ip),
Option(OptionID::kGBALinkPort, &gopts.link_port, 0, 65535), Option(OptionID::kGBALinkPort, &gopts.link_port, 0, 65535),
Option(OptionID::kGBALinkProto, &gopts.link_proto), Option(OptionID::kGBALinkProto, &g_owned_opts.link_proto),
Option(OptionID::kGBALinkTimeout, &gopts.link_timeout, 0, 9999999), Option(OptionID::kGBALinkTimeout, &gopts.link_timeout, 0, 9999999),
Option(OptionID::kGBALinkType, &gopts.gba_link_type, 0, 5), Option(OptionID::kGBALinkType, &gopts.gba_link_type, 0, 5),
#endif #endif
Option(OptionID::kGBAROMDir, &g_owned_opts.gba_rom_dir), Option(OptionID::kGBAROMDir, &g_owned_opts.gba_rom_dir),
/// General /// General
Option(OptionID::kGenAutoLoadLastState, &gopts.autoload_state), Option(OptionID::kGenAutoLoadLastState, &g_owned_opts.autoload_state),
Option(OptionID::kGenBatteryDir, &g_owned_opts.battery_dir), Option(OptionID::kGenBatteryDir, &g_owned_opts.battery_dir),
Option(OptionID::kGenFreezeRecent, &gopts.recent_freeze), Option(OptionID::kGenFreezeRecent, &g_owned_opts.recent_freeze),
Option(OptionID::kGenRecordingDir, &g_owned_opts.recording_dir), Option(OptionID::kGenRecordingDir, &g_owned_opts.recording_dir),
Option(OptionID::kGenRewindInterval, &gopts.rewind_interval, 0, 600), Option(OptionID::kGenRewindInterval, &gopts.rewind_interval, 0, 600),
Option(OptionID::kGenScreenshotDir, &g_owned_opts.screenshot_dir), Option(OptionID::kGenScreenshotDir, &g_owned_opts.screenshot_dir),
Option(OptionID::kGenStateDir, &g_owned_opts.state_dir), Option(OptionID::kGenStateDir, &g_owned_opts.state_dir),
Option(OptionID::kGenStatusBar, &gopts.statusbar), Option(OptionID::kGenStatusBar, &g_owned_opts.statusbar),
Option(OptionID::kGenIniVersion, &g_owned_opts.ini_version, 0, std::numeric_limits<uint32_t>::max()), Option(OptionID::kGenIniVersion, &g_owned_opts.ini_version, 0, std::numeric_limits<uint32_t>::max()),
/// Joypad /// Joypad
@ -275,7 +297,7 @@ std::array<Option, kNbOptions>& Option::All() {
Option(OptionID::kPrefAgbPrint, &g_owned_opts.agb_print), Option(OptionID::kPrefAgbPrint, &g_owned_opts.agb_print),
Option(OptionID::kPrefAutoFrameSkip, &g_owned_opts.auto_frame_skip), Option(OptionID::kPrefAutoFrameSkip, &g_owned_opts.auto_frame_skip),
Option(OptionID::kPrefAutoPatch, &g_owned_opts.auto_patch), Option(OptionID::kPrefAutoPatch, &g_owned_opts.auto_patch),
Option(OptionID::kPrefAutoSaveLoadCheatList, &gopts.autoload_cheats), Option(OptionID::kPrefAutoSaveLoadCheatList, &g_owned_opts.autoload_cheats),
Option(OptionID::kPrefBorderAutomatic, &gbBorderAutomatic), Option(OptionID::kPrefBorderAutomatic, &gbBorderAutomatic),
Option(OptionID::kPrefBorderOn, &gbBorderOn), Option(OptionID::kPrefBorderOn, &gbBorderOn),
Option(OptionID::kPrefCaptureFormat, &g_owned_opts.capture_format, 0, 1), Option(OptionID::kPrefCaptureFormat, &g_owned_opts.capture_format, 0, 1),
@ -286,7 +308,7 @@ std::array<Option, kNbOptions>& Option::All() {
Option(OptionID::kPrefFrameSkip, &g_owned_opts.frame_skip, -1, 9), Option(OptionID::kPrefFrameSkip, &g_owned_opts.frame_skip, -1, 9),
Option(OptionID::kPrefGBPaletteOption, &gbPaletteOption, 0, 2), Option(OptionID::kPrefGBPaletteOption, &gbPaletteOption, 0, 2),
Option(OptionID::kPrefGBPrinter, &coreOptions.winGbPrinterEnabled, 0, 1), Option(OptionID::kPrefGBPrinter, &coreOptions.winGbPrinterEnabled, 0, 1),
Option(OptionID::kPrefGDBBreakOnLoad, &gopts.gdb_break_on_load), Option(OptionID::kPrefGDBBreakOnLoad, &g_owned_opts.gdb_break_on_load),
Option(OptionID::kPrefGDBPort, &gopts.gdb_port, 0, 65535), Option(OptionID::kPrefGDBPort, &gopts.gdb_port, 0, 65535),
#ifndef NO_LINK #ifndef NO_LINK
Option(OptionID::kPrefLinkNumPlayers, &gopts.link_num_players, 2, 4), Option(OptionID::kPrefLinkNumPlayers, &gopts.link_num_players, 2, 4),
@ -297,17 +319,17 @@ std::array<Option, kNbOptions>& Option::All() {
Option(OptionID::kPrefSaveType, &coreOptions.cpuSaveType, 0, 5), Option(OptionID::kPrefSaveType, &coreOptions.cpuSaveType, 0, 5),
Option(OptionID::kPrefShowSpeed, &g_owned_opts.show_speed, 0, 2), Option(OptionID::kPrefShowSpeed, &g_owned_opts.show_speed, 0, 2),
Option(OptionID::kPrefShowSpeedTransparent, &g_owned_opts.show_speed_transparent), Option(OptionID::kPrefShowSpeedTransparent, &g_owned_opts.show_speed_transparent),
Option(OptionID::kPrefSkipBios, &coreOptions.skipBios, 0, 1), Option(OptionID::kPrefSkipBios, &coreOptions.skipBios),
Option(OptionID::kPrefSkipSaveGameCheats, &coreOptions.skipSaveGameCheats, 0, 1), Option(OptionID::kPrefSkipSaveGameCheats, &coreOptions.skipSaveGameCheats, 0, 1),
Option(OptionID::kPrefSkipSaveGameBattery, &coreOptions.skipSaveGameBattery, 0, 1), Option(OptionID::kPrefSkipSaveGameBattery, &coreOptions.skipSaveGameBattery, 0, 1),
Option(OptionID::kPrefThrottle, &coreOptions.throttle, 0, 450), Option(OptionID::kPrefThrottle, &coreOptions.throttle, 0, 450),
Option(OptionID::kPrefSpeedupThrottle, &coreOptions.speedup_throttle, 0, 3000), Option(OptionID::kPrefSpeedupThrottle, &coreOptions.speedup_throttle, 0, 3000),
Option(OptionID::kPrefSpeedupFrameSkip, &coreOptions.speedup_frame_skip, 0, 300), Option(OptionID::kPrefSpeedupFrameSkip, &coreOptions.speedup_frame_skip, 0, 300),
Option(OptionID::kPrefSpeedupThrottleFrameSkip, &coreOptions.speedup_throttle_frame_skip), Option(OptionID::kPrefSpeedupThrottleFrameSkip, &coreOptions.speedup_throttle_frame_skip),
Option(OptionID::kPrefUseBiosGB, &gopts.use_bios_file_gb), Option(OptionID::kPrefUseBiosGB, &g_owned_opts.use_bios_file_gb),
Option(OptionID::kPrefUseBiosGBA, &gopts.use_bios_file_gba), Option(OptionID::kPrefUseBiosGBA, &g_owned_opts.use_bios_file_gba),
Option(OptionID::kPrefUseBiosGBC, &gopts.use_bios_file_gbc), Option(OptionID::kPrefUseBiosGBC, &g_owned_opts.use_bios_file_gbc),
Option(OptionID::kPrefVsync, &gopts.vsync), Option(OptionID::kPrefVsync, &g_owned_opts.vsync),
/// Geometry /// Geometry
Option(OptionID::kGeomFullScreen, &g_owned_opts.fullscreen), Option(OptionID::kGeomFullScreen, &g_owned_opts.fullscreen),
@ -329,12 +351,12 @@ std::array<Option, kNbOptions>& Option::All() {
Option(OptionID::kSoundBuffers, &gopts.audio_buffers, 2, 10), Option(OptionID::kSoundBuffers, &gopts.audio_buffers, 2, 10),
Option(OptionID::kSoundEnable, &gopts.sound_en, 0, 0x30f), Option(OptionID::kSoundEnable, &gopts.sound_en, 0, 0x30f),
Option(OptionID::kSoundGBAFiltering, &gopts.gba_sound_filter, 0, 100), Option(OptionID::kSoundGBAFiltering, &gopts.gba_sound_filter, 0, 100),
Option(OptionID::kSoundGBAInterpolation, &gopts.soundInterpolation), Option(OptionID::kSoundGBAInterpolation, &g_gbaSoundInterpolation),
Option(OptionID::kSoundGBDeclicking, &gopts.gb_declick), Option(OptionID::kSoundGBDeclicking, &g_owned_opts.gb_declicking),
Option(OptionID::kSoundGBEcho, &gopts.gb_echo, 0, 100), Option(OptionID::kSoundGBEcho, &gopts.gb_echo, 0, 100),
Option(OptionID::kSoundGBEnableEffects, &gopts.gb_effects_config_enabled), Option(OptionID::kSoundGBEnableEffects, &g_owned_opts.gb_effects_config_enabled),
Option(OptionID::kSoundGBStereo, &gopts.gb_stereo, 0, 100), Option(OptionID::kSoundGBStereo, &gopts.gb_stereo, 0, 100),
Option(OptionID::kSoundGBSurround, &gopts.gb_effects_config_surround), Option(OptionID::kSoundGBSurround, &g_owned_opts.gb_effects_config_surround),
Option(OptionID::kSoundQuality, &gopts.sound_qual), Option(OptionID::kSoundQuality, &gopts.sound_qual),
Option(OptionID::kSoundVolume, &gopts.sound_vol, 0, 200), Option(OptionID::kSoundVolume, &gopts.sound_vol, 0, 200),
}; };

View File

@ -95,7 +95,7 @@ static constexpr std::array<Option::Type, kNbOptions> kOptionsTypes = {
/*kPrefSaveType*/ Option::Type::kInt, /*kPrefSaveType*/ Option::Type::kInt,
/*kPrefShowSpeed*/ Option::Type::kUnsigned, /*kPrefShowSpeed*/ Option::Type::kUnsigned,
/*kPrefShowSpeedTransparent*/ Option::Type::kBool, /*kPrefShowSpeedTransparent*/ Option::Type::kBool,
/*kPrefSkipBios*/ Option::Type::kInt, /*kPrefSkipBios*/ Option::Type::kBool,
/*kPrefSkipSaveGameCheats*/ Option::Type::kInt, /*kPrefSkipSaveGameCheats*/ Option::Type::kInt,
/*kPrefSkipSaveGameBattery*/ Option::Type::kInt, /*kPrefSkipSaveGameBattery*/ Option::Type::kInt,
/*kPrefThrottle*/ Option::Type::kUnsigned, /*kPrefThrottle*/ Option::Type::kUnsigned,

View File

@ -135,7 +135,7 @@ public:
wxString connmsg; wxString connmsg;
wxString title; wxString title;
SetLinkTimeout(gopts.link_timeout); SetLinkTimeout(gopts.link_timeout);
EnableSpeedHacks(gopts.link_hacks); EnableSpeedHacks(OPTION(kGBALinkFast));
EnableLinkServer(server, gopts.link_num_players - 1); EnableLinkServer(server, gopts.link_num_players - 1);
if (server) { if (server) {
@ -2703,7 +2703,7 @@ bool MainFrame::BindControls()
// set pointers for checkable menu items // set pointers for checkable menu items
// and set initial checked status // and set initial checked status
if (checkable_mi.size()) { if (checkable_mi.size()) {
MenuOptionBool("RecentFreeze", gopts.recent_freeze); MenuOptionBool("RecentFreeze", OPTION(kGenFreezeRecent));
MenuOptionBool("Pause", paused); MenuOptionBool("Pause", paused);
MenuOptionIntMask("SoundChannel1", gopts.sound_en, (1 << 0)); MenuOptionIntMask("SoundChannel1", gopts.sound_en, (1 << 0));
MenuOptionIntMask("SoundChannel2", gopts.sound_en, (1 << 1)); MenuOptionIntMask("SoundChannel2", gopts.sound_en, (1 << 1));
@ -2719,12 +2719,12 @@ bool MainFrame::BindControls()
MenuOptionIntMask("VideoLayersWIN0", coreOptions.layerSettings, (1 << 13)); MenuOptionIntMask("VideoLayersWIN0", coreOptions.layerSettings, (1 << 13));
MenuOptionIntMask("VideoLayersWIN1", coreOptions.layerSettings, (1 << 14)); MenuOptionIntMask("VideoLayersWIN1", coreOptions.layerSettings, (1 << 14));
MenuOptionIntMask("VideoLayersOBJWIN", coreOptions.layerSettings, (1 << 15)); MenuOptionIntMask("VideoLayersOBJWIN", coreOptions.layerSettings, (1 << 15));
MenuOptionBool("CheatsAutoSaveLoad", gopts.autoload_cheats); MenuOptionBool("CheatsAutoSaveLoad", OPTION(kPrefAutoSaveLoadCheatList));
MenuOptionIntMask("CheatsEnable", coreOptions.cheatsEnabled, 1); MenuOptionIntMask("CheatsEnable", coreOptions.cheatsEnabled, 1);
SetMenuOption("ColorizerHack", OPTION(kGBColorizerHack)); SetMenuOption("ColorizerHack", OPTION(kGBColorizerHack));
MenuOptionIntMask("KeepSaves", coreOptions.skipSaveGameBattery, 1); MenuOptionIntMask("KeepSaves", coreOptions.skipSaveGameBattery, 1);
MenuOptionIntMask("KeepCheats", coreOptions.skipSaveGameCheats, 1); MenuOptionIntMask("KeepCheats", coreOptions.skipSaveGameCheats, 1);
MenuOptionBool("LoadGameAutoLoad", gopts.autoload_state); MenuOptionBool("LoadGameAutoLoad", OPTION(kGenAutoLoadLastState));
MenuOptionIntMask("JoypadAutofireA", autofire, KEYM_A); MenuOptionIntMask("JoypadAutofireA", autofire, KEYM_A);
MenuOptionIntMask("JoypadAutofireB", autofire, KEYM_B); MenuOptionIntMask("JoypadAutofireB", autofire, KEYM_B);
MenuOptionIntMask("JoypadAutofireL", autofire, KEYM_L); MenuOptionIntMask("JoypadAutofireL", autofire, KEYM_L);
@ -3499,20 +3499,9 @@ bool MainFrame::BindControls()
#endif #endif
// delayed fullscreen // delayed fullscreen
if (wxGetApp().pending_fullscreen) if (wxGetApp().pending_fullscreen) {
panel->ShowFullScreen(true); panel->ShowFullScreen(true);
}
MainFrame* mf = wxGetApp().frame;
if (gopts.statusbar)
mf->GetStatusBar()->Show();
else
mf->GetStatusBar()->Hide();
if (OPTION(kDispKeepOnTop))
mf->SetWindowStyle(mf->GetWindowStyle() | wxSTAY_ON_TOP);
else
mf->SetWindowStyle(mf->GetWindowStyle() & ~wxSTAY_ON_TOP);
#ifndef NO_LINK #ifndef NO_LINK
LinkMode link_mode = GetConfiguredLinkMode(); LinkMode link_mode = GetConfiguredLinkMode();
@ -3540,7 +3529,7 @@ bool MainFrame::BindControls()
if (GetLinkMode() != LINK_DISCONNECTED) { if (GetLinkMode() != LINK_DISCONNECTED) {
cmd_enable |= CMDEN_LINK_ANY; cmd_enable |= CMDEN_LINK_ANY;
SetLinkTimeout(gopts.link_timeout); SetLinkTimeout(gopts.link_timeout);
EnableSpeedHacks(gopts.link_hacks); EnableSpeedHacks(OPTION(kGBALinkFast));
} }
EnableNetworkMenu(); EnableNetworkMenu();

View File

@ -25,30 +25,17 @@ extern struct opts_t {
/// Display /// Display
wxVideoMode fs_mode; wxVideoMode fs_mode;
/// GB
bool gb_lcd_filter = false;
bool print_auto_page = true;
bool print_screen_cap = false;
/// GBA /// GBA
wxString gba_bios; wxString gba_bios;
bool gba_lcd_filter = false;
bool link_auto = false;
bool link_hacks = true;
// quick fix for issues #48 and #445 // quick fix for issues #48 and #445
wxString link_host = "127.0.0.1"; wxString link_host = "127.0.0.1";
wxString server_ip = "*"; wxString server_ip = "*";
uint32_t link_port = 5738; uint32_t link_port = 5738;
bool link_proto = false;
int link_timeout = 500; int link_timeout = 500;
int gba_link_type; int gba_link_type;
/// General /// General
bool autoload_state = false;
bool autoload_cheats = false;
bool recent_freeze = false;
int rewind_interval = 0; int rewind_interval = 0;
bool statusbar = false;
/// Joypad /// Joypad
std::map<config::GameControl, std::set<config::UserInput>> std::map<config::GameControl, std::set<config::UserInput>>
@ -60,14 +47,9 @@ extern struct opts_t {
wxAcceleratorEntry_v accels; wxAcceleratorEntry_v accels;
/// Core /// Core
bool gdb_break_on_load = false;
int gdb_port = 55555; int gdb_port = 55555;
int link_num_players = 2; int link_num_players = 2;
int max_scale = 0; int max_scale = 0;
bool use_bios_file_gb = false;
bool use_bios_file_gba = false;
bool use_bios_file_gbc = false;
bool vsync = false;
/// Sound /// Sound
int audio_api = 0; int audio_api = 0;
@ -77,13 +59,9 @@ extern struct opts_t {
wxString audio_dev; wxString audio_dev;
int sound_en = 0x30f; // soundSetEnable() int sound_en = 0x30f; // soundSetEnable()
int gba_sound_filter = 50; int gba_sound_filter = 50;
bool soundInterpolation;
bool gb_declick = true;
int gb_echo = 20; int gb_echo = 20;
bool gb_effects_config_enabled;
bool dsound_hw_accel; bool dsound_hw_accel;
int gb_stereo = 15; int gb_stereo = 15;
bool gb_effects_config_surround;
int sound_qual = 1; // soundSetSampleRate() / gbSoundSetSampleRate() int sound_qual = 1; // soundSetSampleRate() / gbSoundSetSampleRate()
int sound_vol = 100; // soundSetVolume() int sound_vol = 100; // soundSetVolume()
bool upmix = false; // xa2 only bool upmix = false; // xa2 only

View File

@ -112,7 +112,7 @@ GameArea::GameArea()
render_observer_( render_observer_(
{config::OptionID::kDispBilinear, config::OptionID::kDispFilter, {config::OptionID::kDispBilinear, config::OptionID::kDispFilter,
config::OptionID::kDispRenderMethod, config::OptionID::kDispIFB, config::OptionID::kDispRenderMethod, config::OptionID::kDispIFB,
config::OptionID::kDispStretch}, config::OptionID::kDispStretch, config::OptionID::kPrefVsync},
std::bind(&GameArea::ResetPanel, this)), std::bind(&GameArea::ResetPanel, this)),
scale_observer_(config::OptionID::kDispScale, scale_observer_(config::OptionID::kDispScale,
std::bind(&GameArea::AdjustSize, this, true)), std::bind(&GameArea::AdjustSize, this, true)),
@ -123,7 +123,14 @@ GameArea::GameArea()
{config::OptionID::kGBPalette0, config::OptionID::kGBPalette1, {config::OptionID::kGBPalette0, config::OptionID::kGBPalette1,
config::OptionID::kGBPalette2, config::OptionID::kGBPalette2,
config::OptionID::kPrefGBPaletteOption}, config::OptionID::kPrefGBPaletteOption},
std::bind(&gbResetPalette)) { std::bind(&gbResetPalette)),
gb_declick_observer_(config::OptionID::kSoundGBDeclicking,
[&](config::Option* option) {
gbSoundSetDeclicking(option->GetBool());
}),
lcd_filters_observer_(
{config::OptionID::kGBLCDFilter, config::OptionID::kGBALCDFilter},
std::bind(&GameArea::UpdateLcdFilter, this)) {
SetSizer(new wxBoxSizer(wxVERTICAL)); SetSizer(new wxBoxSizer(wxVERTICAL));
// all renderers prefer 32-bit // all renderers prefer 32-bit
// well, "simple" prefers 24-bit, but that's not available for filters // well, "simple" prefers 24-bit, but that's not available for filters
@ -183,7 +190,7 @@ void GameArea::LoadGame(const wxString& name)
{ {
wxConfigBase* cfg = wxConfigBase::Get(); wxConfigBase* cfg = wxConfigBase::Get();
if (!gopts.recent_freeze) { if (!OPTION(kGenFreezeRecent)) {
gopts.recent->AddFileToHistory(name); gopts.recent->AddFileToHistory(name);
wxGetApp().frame->SetRecentAccels(); wxGetApp().frame->SetRecentAccels();
cfg->SetPath("/Recent"); cfg->SetPath("/Recent");
@ -246,11 +253,10 @@ void GameArea::LoadGame(const wxString& name)
} }
// start sound; this must happen before CPU stuff // start sound; this must happen before CPU stuff
gb_effects_config.enabled = gopts.gb_effects_config_enabled; gb_effects_config.enabled = OPTION(kSoundGBEnableEffects);
gb_effects_config.surround = gopts.gb_effects_config_surround; gb_effects_config.surround = OPTION(kSoundGBSurround);
gb_effects_config.echo = (float)gopts.gb_echo / 100.0; gb_effects_config.echo = (float)gopts.gb_echo / 100.0;
gb_effects_config.stereo = (float)gopts.gb_stereo / 100.0; gb_effects_config.stereo = (float)gopts.gb_stereo / 100.0;
gbSoundSetDeclicking(gopts.gb_declick);
if (!soundInit()) { if (!soundInit()) {
wxLogError(_("Could not initialize the sound driver!")); wxLogError(_("Could not initialize the sound driver!"));
} }
@ -263,17 +269,16 @@ void GameArea::LoadGame(const wxString& name)
// Disable bios loading when using colorizer hack. // Disable bios loading when using colorizer hack.
if (gopts.use_bios_file_gb && OPTION(kGBColorizerHack)) { if (OPTION(kPrefUseBiosGB) && OPTION(kGBColorizerHack)) {
wxLogError(_("Cannot use Game Boy BIOS file when Colorizer Hack is enabled, disabling Game Boy BIOS file.")); wxLogError(_("Cannot use Game Boy BIOS file when Colorizer Hack is enabled, disabling Game Boy BIOS file."));
gopts.use_bios_file_gb = false; OPTION(kPrefUseBiosGB) = false;
update_opts();
} }
// Set up the core for the colorizer hack. // Set up the core for the colorizer hack.
setColorizerHack(OPTION(kGBColorizerHack)); setColorizerHack(OPTION(kGBColorizerHack));
const bool use_bios = const bool use_bios = gbCgbMode ? OPTION(kPrefUseBiosGBC).Get()
gbCgbMode ? gopts.use_bios_file_gbc : gopts.use_bios_file_gb; : OPTION(kPrefUseBiosGB).Get();
const wxString bios_file = gbCgbMode ? OPTION(kGBGBCBiosFile).Get() : OPTION(kGBBiosFile).Get(); const wxString bios_file = gbCgbMode ? OPTION(kGBGBCBiosFile).Get() : OPTION(kGBBiosFile).Get();
gbCPUInit(bios_file.To8BitData().data(), use_bios); gbCPUInit(bios_file.To8BitData().data(), use_bios);
@ -376,9 +381,9 @@ void GameArea::LoadGame(const wxString& name)
rtcEnableRumble(true); rtcEnableRumble(true);
CPUInit(UTF8(gopts.gba_bios), gopts.use_bios_file_gba); CPUInit(UTF8(gopts.gba_bios), OPTION(kPrefUseBiosGBA));
if (gopts.use_bios_file_gba && !coreOptions.useBios) { if (OPTION(kPrefUseBiosGBA) && !coreOptions.useBios) {
wxLogError(_("Could not load BIOS %s"), gopts.gba_bios.mb_str()); wxLogError(_("Could not load BIOS %s"), gopts.gba_bios.mb_str());
// could clear use flag & file name now, but better to force // could clear use flag & file name now, but better to force
// user to do it // user to do it
@ -434,7 +439,7 @@ void GameArea::LoadGame(const wxString& name)
// load battery and/or saved state // load battery and/or saved state
recompute_dirs(); recompute_dirs();
mf->update_state_ts(true); mf->update_state_ts(true);
bool did_autoload = gopts.autoload_state ? LoadState() : false; bool did_autoload = OPTION(kGenAutoLoadLastState) ? LoadState() : false;
if (!did_autoload || coreOptions.skipSaveGameBattery) { if (!did_autoload || coreOptions.skipSaveGameBattery) {
wxString bname = loaded_game.GetFullName(); wxString bname = loaded_game.GetFullName();
@ -496,7 +501,7 @@ void GameArea::LoadGame(const wxString& name)
// FIXME: backup battery file (useful if game name conflict) // FIXME: backup battery file (useful if game name conflict)
cheats_dirty = (did_autoload && !coreOptions.skipSaveGameCheats) || (loaded == IMAGE_GB ? gbCheatNumber > 0 : cheatsNumber > 0); cheats_dirty = (did_autoload && !coreOptions.skipSaveGameCheats) || (loaded == IMAGE_GB ? gbCheatNumber > 0 : cheatsNumber > 0);
if (gopts.autoload_cheats && (!did_autoload || coreOptions.skipSaveGameCheats)) { if (OPTION(kPrefAutoSaveLoadCheatList) && (!did_autoload || coreOptions.skipSaveGameCheats)) {
wxFileName cfn = loaded_game; wxFileName cfn = loaded_game;
// SetExt may strip something off by accident, so append to text instead // SetExt may strip something off by accident, so append to text instead
cfn.SetFullName(cfn.GetFullName() + wxT(".clt")); cfn.SetFullName(cfn.GetFullName() + wxT(".clt"));
@ -517,12 +522,17 @@ void GameArea::LoadGame(const wxString& name)
} }
#ifndef NO_LINK #ifndef NO_LINK
if (OPTION(kGBALinkAuto)) {
if (gopts.link_auto) {
BootLink(mf->GetConfiguredLinkMode(), UTF8(gopts.link_host), BootLink(mf->GetConfiguredLinkMode(), UTF8(gopts.link_host),
gopts.link_timeout, gopts.link_hacks, gopts.link_num_players); gopts.link_timeout, OPTION(kGBALinkFast),
gopts.link_num_players);
} }
#endif
#ifndef NO_DEBUGGER
if (OPTION(kPrefGDBBreakOnLoad)) {
mf->GDBBreak();
}
#endif #endif
} }
@ -583,7 +593,7 @@ void GameArea::UnloadGame(bool destruct)
return; return;
// last opportunity to autosave cheats // last opportunity to autosave cheats
if (gopts.autoload_cheats && cheats_dirty) { if (OPTION(kPrefAutoSaveLoadCheatList) && cheats_dirty) {
wxFileName cfn = loaded_game; wxFileName cfn = loaded_game;
// SetExt may strip something off by accident, so append to text instead // SetExt may strip something off by accident, so append to text instead
cfn.SetFullName(cfn.GetFullName() + wxT(".clt")); cfn.SetFullName(cfn.GetFullName() + wxT(".clt"));
@ -1077,8 +1087,9 @@ void GameArea::OnIdle(wxIdleEvent& event)
LoadGame(pl); LoadGame(pl);
#ifndef NO_DEBUGGER #ifndef NO_DEBUGGER
if (gopts.gdb_break_on_load) if (OPTION(kPrefGDBBreakOnLoad)) {
mf->GDBBreak(); mf->GDBBreak();
}
if (debugger && loaded != IMAGE_GBA) { if (debugger && loaded != IMAGE_GBA) {
wxLogError(_("Not a valid Game Boy Advance cartridge")); wxLogError(_("Not a valid Game Boy Advance cartridge"));
@ -1196,12 +1207,7 @@ void GameArea::OnIdle(wxIdleEvent& event)
w->SetFocus(); w->SetFocus();
// generate system color maps (after output module init) // generate system color maps (after output module init)
if (loaded == IMAGE_GBA) UpdateLcdFilter();
utilUpdateSystemColorMaps(gopts.gba_lcd_filter);
else if (loaded == IMAGE_GB)
utilUpdateSystemColorMaps(gopts.gb_lcd_filter);
else
utilUpdateSystemColorMaps(false);
} }
mf->PollJoysticks(); mf->PollJoysticks();
@ -1895,7 +1901,7 @@ void DrawingPanelBase::DrawArea(uint8_t** data)
// draw OSD text old-style (directly into output buffer), if needed // draw OSD text old-style (directly into output buffer), if needed
// new style flickers too much, so we'll stick to this for now // new style flickers too much, so we'll stick to this for now
if (wxGetApp().frame->IsFullScreen() || !gopts.statusbar) { if (wxGetApp().frame->IsFullScreen() || !OPTION(kGenStatusBar)) {
GameArea* panel = wxGetApp().frame->GetPanel(); GameArea* panel = wxGetApp().frame->GetPanel();
if (panel->osdstat.size()) if (panel->osdstat.size())
@ -2276,16 +2282,16 @@ void GLDrawingPanel::DrawingPanelInit()
#if defined(__WXGTK__) #if defined(__WXGTK__)
if (IsWayland()) { if (IsWayland()) {
#ifdef HAVE_EGL #ifdef HAVE_EGL
if (gopts.vsync) if (OPTION(kPrefVsync))
wxLogDebug(_("Enabling EGL VSync.")); wxLogDebug(_("Enabling EGL VSync."));
else else
wxLogDebug(_("Disabling EGL VSync.")); wxLogDebug(_("Disabling EGL VSync."));
eglSwapInterval(0, gopts.vsync); eglSwapInterval(0, OPTION(kPrefVsync));
#endif #endif
} }
else { else {
if (gopts.vsync) if (OPTION(kPrefVsync))
wxLogDebug(_("Enabling GLX VSync.")); wxLogDebug(_("Enabling GLX VSync."));
else else
wxLogDebug(_("Disabling GLX VSync.")); wxLogDebug(_("Disabling GLX VSync."));
@ -2304,7 +2310,7 @@ void GLDrawingPanel::DrawingPanelInit()
glXSwapIntervalEXT = reinterpret_cast<PFNGLXSWAPINTERVALEXTPROC>(glXGetProcAddress((const GLubyte*)"glXSwapIntervalEXT")); glXSwapIntervalEXT = reinterpret_cast<PFNGLXSWAPINTERVALEXTPROC>(glXGetProcAddress((const GLubyte*)"glXSwapIntervalEXT"));
if (glXSwapIntervalEXT) if (glXSwapIntervalEXT)
glXSwapIntervalEXT(glXGetCurrentDisplay(), glXSwapIntervalEXT(glXGetCurrentDisplay(),
glXGetCurrentDrawable(), gopts.vsync); glXGetCurrentDrawable(), OPTION(kPrefVsync));
else else
systemScreenMessage(_("Failed to set glXSwapIntervalEXT")); systemScreenMessage(_("Failed to set glXSwapIntervalEXT"));
} }
@ -2313,7 +2319,7 @@ void GLDrawingPanel::DrawingPanelInit()
glXSwapIntervalSGI = reinterpret_cast<PFNGLXSWAPINTERVALSGIPROC>(glXGetProcAddress((const GLubyte*)("glXSwapIntervalSGI"))); glXSwapIntervalSGI = reinterpret_cast<PFNGLXSWAPINTERVALSGIPROC>(glXGetProcAddress((const GLubyte*)("glXSwapIntervalSGI")));
if (glXSwapIntervalSGI) if (glXSwapIntervalSGI)
glXSwapIntervalSGI(gopts.vsync); glXSwapIntervalSGI(OPTION(kPrefVsync));
else else
systemScreenMessage(_("Failed to set glXSwapIntervalSGI")); systemScreenMessage(_("Failed to set glXSwapIntervalSGI"));
} }
@ -2322,7 +2328,7 @@ void GLDrawingPanel::DrawingPanelInit()
glXSwapIntervalMESA = reinterpret_cast<PFNGLXSWAPINTERVALMESAPROC>(glXGetProcAddress((const GLubyte*)("glXSwapIntervalMESA"))); glXSwapIntervalMESA = reinterpret_cast<PFNGLXSWAPINTERVALMESAPROC>(glXGetProcAddress((const GLubyte*)("glXSwapIntervalMESA")));
if (glXSwapIntervalMESA) if (glXSwapIntervalMESA)
glXSwapIntervalMESA(gopts.vsync); glXSwapIntervalMESA(OPTION(kPrefVsync));
else else
systemScreenMessage(_("Failed to set glXSwapIntervalMESA")); systemScreenMessage(_("Failed to set glXSwapIntervalMESA"));
} }
@ -2341,11 +2347,11 @@ void GLDrawingPanel::DrawingPanelInit()
static PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT = NULL; static PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT = NULL;
wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT"); wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT");
if (wglSwapIntervalEXT) if (wglSwapIntervalEXT)
wglSwapIntervalEXT(gopts.vsync); wglSwapIntervalEXT(OPTION(kPrefVsync));
else else
systemScreenMessage(_("Failed to set wglSwapIntervalEXT")); systemScreenMessage(_("Failed to set wglSwapIntervalEXT"));
#elif defined(__WXMAC__) #elif defined(__WXMAC__)
int swap_interval = gopts.vsync ? 1 : 0; int swap_interval = OPTION(kPrefVsync) ? 1 : 0;
CGLContextObj cgl_context = CGLGetCurrentContext(); CGLContextObj cgl_context = CGLGetCurrentContext();
CGLSetParameter(cgl_context, kCGLCPSwapInterval, &swap_interval); CGLSetParameter(cgl_context, kCGLCPSwapInterval, &swap_interval);
#else #else
@ -2648,6 +2654,15 @@ void GameArea::OnGBBorderChanged(config::Option* option) {
} }
} }
void GameArea::UpdateLcdFilter() {
if (loaded == IMAGE_GBA)
utilUpdateSystemColorMaps(OPTION(kGBALCDFilter));
else if (loaded == IMAGE_GB)
utilUpdateSystemColorMaps(OPTION(kGBLCDFilter));
else
utilUpdateSystemColorMaps(false);
}
void GameArea::SuspendScreenSaver() { void GameArea::SuspendScreenSaver() {
#ifdef HAVE_XSS #ifdef HAVE_XSS
if (xscreensaver_suspended || !gopts.suspend_screensaver) if (xscreensaver_suspended || !gopts.suspend_screensaver)

View File

@ -1077,7 +1077,7 @@ void systemGbPrint(uint8_t* data, int len, int pages, int feed, int pal, int con
// or at the very least dump when the game state changes // or at the very least dump when the game state changes
uint16_t* to_print = prdata; uint16_t* to_print = prdata;
if ((gopts.print_auto_page && !(feed & 15)) || accum_prdata_len) { if ((OPTION(kGBPrintAutoPage) && !(feed & 15)) || accum_prdata_len) {
if (!accum_prdata_len) if (!accum_prdata_len)
accum_prdata_len = 162; // top border accum_prdata_len = 162; // top border
@ -1095,7 +1095,7 @@ void systemGbPrint(uint8_t* data, int len, int pages, int feed, int pal, int con
memcpy(accum_prdata + accum_prdata_len - lines * 162, prdata + 162, memcpy(accum_prdata + accum_prdata_len - lines * 162, prdata + 162,
lines * 162 * 2); lines * 162 * 2);
if (gopts.print_auto_page && !(feed & 15)) if (OPTION(kGBPrintAutoPage) && !(feed & 15))
return; return;
to_print = accum_prdata; to_print = accum_prdata;
@ -1103,7 +1103,7 @@ void systemGbPrint(uint8_t* data, int len, int pages, int feed, int pal, int con
accum_prdata_len = 0; accum_prdata_len = 0;
} }
if (gopts.print_screen_cap) { if (OPTION(kGBPrintScreenCap)) {
wxFileName fn = wxFileName(wxGetApp().frame->GetGamePath(OPTION(kGenScreenshotDir)), wxEmptyString); wxFileName fn = wxFileName(wxGetApp().frame->GetGamePath(OPTION(kGenScreenshotDir)), wxEmptyString);
int num = 1; int num = 1;
const int capture_format = OPTION(kPrefCaptureFormat); const int capture_format = OPTION(kPrefCaptureFormat);

View File

@ -786,18 +786,34 @@ MainFrame::MainFrame()
menus_opened(0), menus_opened(0),
dialog_opened(0), dialog_opened(0),
focused(false), focused(false),
keep_on_top_styler_(this) { keep_on_top_styler_(this),
status_bar_observer_(config::OptionID::kGenStatusBar,
std::bind(&MainFrame::OnStatusBarChanged,
this,
std::placeholders::_1)),
gba_link_observer_(config::OptionID::kGBALinkHost,
std::bind(&MainFrame::EnableNetworkMenu, this)) {
jpoll = new JoystickPoller(); jpoll = new JoystickPoller();
this->Connect(wxID_ANY, wxEVT_SHOW, wxShowEventHandler(JoystickPoller::ShowDialog), jpoll, jpoll); this->Connect(wxID_ANY, wxEVT_SHOW, wxShowEventHandler(JoystickPoller::ShowDialog), jpoll, jpoll);
} }
MainFrame::~MainFrame() MainFrame::~MainFrame() {
{
#ifndef NO_LINK #ifndef NO_LINK
CloseLink(); CloseLink();
#endif #endif
} }
void MainFrame::OnStatusBarChanged(config::Option* option) {
if (option->GetBool())
GetStatusBar()->Show();
else
GetStatusBar()->Hide();
SendSizeEvent();
panel->AdjustSize(false);
SendSizeEvent();
}
BEGIN_EVENT_TABLE(MainFrame, wxFrame) BEGIN_EVENT_TABLE(MainFrame, wxFrame)
#include "cmd-evtable.h" #include "cmd-evtable.h"
EVT_CONTEXT_MENU(MainFrame::OnMenu) EVT_CONTEXT_MENU(MainFrame::OnMenu)
@ -1204,15 +1220,15 @@ LinkMode MainFrame::GetConfiguredLinkMode()
break; break;
case 1: case 1:
if (gopts.link_proto) if (OPTION(kGBALinkProto))
return LINK_CABLE_IPC; return LINK_CABLE_IPC;
else else
return LINK_CABLE_SOCKET; return LINK_CABLE_SOCKET;
break; break;
case 2: case 2:
if (gopts.link_proto) if (OPTION(kGBALinkProto))
return LINK_RFU_IPC; return LINK_RFU_IPC;
else else
return LINK_RFU_SOCKET; return LINK_RFU_SOCKET;
@ -1224,7 +1240,7 @@ LinkMode MainFrame::GetConfiguredLinkMode()
break; break;
case 4: case 4:
if (gopts.link_proto) if (OPTION(kGBALinkProto))
return LINK_GAMEBOY_IPC; return LINK_GAMEBOY_IPC;
else else
return LINK_GAMEBOY_SOCKET; return LINK_GAMEBOY_SOCKET;

View File

@ -366,10 +366,14 @@ private:
// quicker & more accurate than FindFocus() != NULL // quicker & more accurate than FindFocus() != NULL
bool focused; bool focused;
const widgets::KeepOnTopStyler keep_on_top_styler_; const widgets::KeepOnTopStyler keep_on_top_styler_;
const config::OptionsObserver status_bar_observer_;
const config::OptionsObserver gba_link_observer_;
// helper function for adding menu to accel editor // helper function for adding menu to accel editor
void add_menu_accels(wxTreeCtrl* tc, wxTreeItemId& parent, wxMenu* menu); void add_menu_accels(wxTreeCtrl* tc, wxTreeItemId& parent, wxMenu* menu);
// For enabling / disabling the status bar.
void OnStatusBarChanged(config::Option* option);
// for detecting window focus // for detecting window focus
void OnActivate(wxActivateEvent&); void OnActivate(wxActivateEvent&);
// may work, may not... if so, load dropped file // may work, may not... if so, load dropped file
@ -606,6 +610,7 @@ public:
void HideMenuBar(); void HideMenuBar();
void ShowMenuBar(); void ShowMenuBar();
void OnGBBorderChanged(config::Option* option); void OnGBBorderChanged(config::Option* option);
void UpdateLcdFilter();
void SuspendScreenSaver(); void SuspendScreenSaver();
void UnsuspendScreenSaver(); void UnsuspendScreenSaver();
@ -622,10 +627,12 @@ protected:
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
private: private:
config::OptionsObserver render_observer_; const config::OptionsObserver render_observer_;
config::OptionsObserver scale_observer_; const config::OptionsObserver scale_observer_;
config::OptionsObserver gb_border_observer_; const config::OptionsObserver gb_border_observer_;
config::OptionsObserver gb_palette_observer_; const config::OptionsObserver gb_palette_observer_;
const config::OptionsObserver gb_declick_observer_;
const config::OptionsObserver lcd_filters_observer_;
}; };
// wxString version of OSD message // wxString version of OSD message