[options] Remove duplicate string constants

* Changed the string to enum conversions to be built at runtime from
  the existing constant array rather than redefining the strings.
* Fixed an issue in the initialization of the `checkable_mi` array.
  A test had been mistakenly removed during the refactor.
* Fixed an issue where changing a bool or int option would cause an
  assertion error at runtime. Changed helper methods definitions to
  use a pointer to a variable rather than take a parameter by
  reference, clarifying the intent from the caller perspective.
* Fixed the `renderer` enum definition to properly exclude Direct3D or
  Quartz2D depending on the platform.
* Various comment fixes.
This commit is contained in:
Fabrice de Gans 2022-09-07 22:58:29 -07:00 committed by Rafael Kitover
parent c4d46a713f
commit 4a056c7720
7 changed files with 239 additions and 354 deletions

View File

@ -31,24 +31,26 @@ 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;
} }
void MainFrame::GetMenuOptionBool(const wxString& menuName, bool field) void MainFrame::GetMenuOptionBool(const wxString& menuName, bool* field)
{ {
field = !field; assert(field);
*field = !*field;
int id = wxXmlResource::GetXRCID(menuName); int id = wxXmlResource::GetXRCID(menuName);
for (size_t i = 0; i < checkable_mi.size(); i++) { for (size_t i = 0; i < checkable_mi.size(); i++) {
if (checkable_mi[i].cmd != id) if (checkable_mi[i].cmd != id)
continue; continue;
field = checkable_mi[i].mi->IsChecked(); *field = checkable_mi[i].mi->IsChecked();
break; break;
} }
} }
void MainFrame::GetMenuOptionInt(const wxString& menuName, int field, int mask) void MainFrame::GetMenuOptionInt(const wxString& menuName, int* field, int mask)
{ {
assert(field);
int value = mask; int value = mask;
bool is_checked = ((field) & (mask)) != (value); bool is_checked = ((*field) & (mask)) != (value);
int id = wxXmlResource::GetXRCID(menuName); int id = wxXmlResource::GetXRCID(menuName);
for (size_t i = 0; i < checkable_mi.size(); i++) { for (size_t i = 0; i < checkable_mi.size(); i++) {
@ -59,7 +61,7 @@ void MainFrame::GetMenuOptionInt(const wxString& menuName, int field, int mask)
break; break;
} }
field = ((field) & ~(mask)) | (is_checked ? (value) : 0); *field = ((*field) & ~(mask)) | (is_checked ? (value) : 0);
} }
void MainFrame::SetMenuOption(const wxString& menuName, int value) void MainFrame::SetMenuOption(const wxString& menuName, int value)
@ -192,8 +194,8 @@ 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; bool menuPress = false;
GetMenuOptionBool("RecentFreeze", menuPress); GetMenuOptionBool("RecentFreeze", &menuPress);
toggleBooleanVar(&menuPress, &gopts.recent_freeze); toggleBooleanVar(&menuPress, &gopts.recent_freeze);
SetMenuOption("RecentFreeze", gopts.recent_freeze ? 1 : 0); SetMenuOption("RecentFreeze", gopts.recent_freeze ? 1 : 0);
update_opts(); update_opts();
@ -1471,8 +1473,8 @@ EVT_HANDLER(wxID_EXIT, "Exit")
// Emulation menu // Emulation menu
EVT_HANDLER(Pause, "Pause (toggle)") EVT_HANDLER(Pause, "Pause (toggle)")
{ {
bool menuPress; bool menuPress = false;
GetMenuOptionBool("Pause", menuPress); GetMenuOptionBool("Pause", &menuPress);
toggleBooleanVar(&menuPress, &paused); toggleBooleanVar(&menuPress, &paused);
SetMenuOption("Pause", paused ? 1 : 0); SetMenuOption("Pause", paused ? 1 : 0);
@ -1491,8 +1493,8 @@ EVT_HANDLER(Pause, "Pause (toggle)")
// new // new
EVT_HANDLER_MASK(EmulatorSpeedupToggle, "Turbo mode (toggle)", CMDEN_GB | CMDEN_GBA) EVT_HANDLER_MASK(EmulatorSpeedupToggle, "Turbo mode (toggle)", CMDEN_GB | CMDEN_GBA)
{ {
bool menuPress; bool menuPress = false;
GetMenuOptionBool("EmulatorSpeedupToggle", menuPress); GetMenuOptionBool("EmulatorSpeedupToggle", &menuPress);
toggleBooleanVar(&menuPress, &turbo); toggleBooleanVar(&menuPress, &turbo);
SetMenuOption("EmulatorSpeedupToggle", turbo ? 1 : 0); SetMenuOption("EmulatorSpeedupToggle", turbo ? 1 : 0);
} }
@ -1510,156 +1512,156 @@ EVT_HANDLER(ToggleFullscreen, "Full screen (toggle)")
EVT_HANDLER(JoypadAutofireA, "Autofire A (toggle)") EVT_HANDLER(JoypadAutofireA, "Autofire A (toggle)")
{ {
bool menuPress; bool menuPress = false;
GetMenuOptionBool("JoypadAutofireA", menuPress); GetMenuOptionBool("JoypadAutofireA", &menuPress);
toggleBitVar(&menuPress, &autofire, KEYM_A); toggleBitVar(&menuPress, &autofire, KEYM_A);
SetMenuOption("JoypadAutofireA", menuPress ? 1 : 0); SetMenuOption("JoypadAutofireA", menuPress ? 1 : 0);
GetMenuOptionInt("JoypadAutofireA", autofire, KEYM_A); GetMenuOptionInt("JoypadAutofireA", &autofire, KEYM_A);
} }
EVT_HANDLER(JoypadAutofireB, "Autofire B (toggle)") EVT_HANDLER(JoypadAutofireB, "Autofire B (toggle)")
{ {
bool menuPress; bool menuPress = false;
GetMenuOptionBool("JoypadAutofireB", menuPress); GetMenuOptionBool("JoypadAutofireB", &menuPress);
toggleBitVar(&menuPress, &autofire, KEYM_B); toggleBitVar(&menuPress, &autofire, KEYM_B);
SetMenuOption("JoypadAutofireB", menuPress ? 1 : 0); SetMenuOption("JoypadAutofireB", menuPress ? 1 : 0);
GetMenuOptionInt("JoypadAutofireB", autofire, KEYM_B); GetMenuOptionInt("JoypadAutofireB", &autofire, KEYM_B);
} }
EVT_HANDLER(JoypadAutofireL, "Autofire L (toggle)") EVT_HANDLER(JoypadAutofireL, "Autofire L (toggle)")
{ {
bool menuPress; bool menuPress = false;
GetMenuOptionBool("JoypadAutofireL", menuPress); GetMenuOptionBool("JoypadAutofireL", &menuPress);
toggleBitVar(&menuPress, &autofire, KEYM_L); toggleBitVar(&menuPress, &autofire, KEYM_L);
SetMenuOption("JoypadAutofireL", menuPress ? 1 : 0); SetMenuOption("JoypadAutofireL", menuPress ? 1 : 0);
GetMenuOptionInt("JoypadAutofireL", autofire, KEYM_L); GetMenuOptionInt("JoypadAutofireL", &autofire, KEYM_L);
} }
EVT_HANDLER(JoypadAutofireR, "Autofire R (toggle)") EVT_HANDLER(JoypadAutofireR, "Autofire R (toggle)")
{ {
bool menuPress; bool menuPress = false;
GetMenuOptionBool("JoypadAutofireR", menuPress); GetMenuOptionBool("JoypadAutofireR", &menuPress);
toggleBitVar(&menuPress, &autofire, KEYM_R); toggleBitVar(&menuPress, &autofire, KEYM_R);
SetMenuOption("JoypadAutofireR", menuPress ? 1 : 0); SetMenuOption("JoypadAutofireR", menuPress ? 1 : 0);
GetMenuOptionInt("JoypadAutofireR", autofire, KEYM_R); GetMenuOptionInt("JoypadAutofireR", &autofire, KEYM_R);
} }
EVT_HANDLER(JoypadAutoholdUp, "Autohold Up (toggle)") EVT_HANDLER(JoypadAutoholdUp, "Autohold Up (toggle)")
{ {
bool menuPress; bool menuPress = false;
char keyName[] = "JoypadAutoholdUp"; char keyName[] = "JoypadAutoholdUp";
int keym = KEYM_UP; int keym = KEYM_UP;
GetMenuOptionBool(keyName, menuPress); GetMenuOptionBool(keyName, &menuPress);
toggleBitVar(&menuPress, &autohold, keym); toggleBitVar(&menuPress, &autohold, keym);
SetMenuOption(keyName, menuPress ? 1 : 0); SetMenuOption(keyName, menuPress ? 1 : 0);
GetMenuOptionInt(keyName, autohold, keym); GetMenuOptionInt(keyName, &autohold, keym);
} }
EVT_HANDLER(JoypadAutoholdDown, "Autohold Down (toggle)") EVT_HANDLER(JoypadAutoholdDown, "Autohold Down (toggle)")
{ {
bool menuPress; bool menuPress = false;
char keyName[] = "JoypadAutoholdDown"; char keyName[] = "JoypadAutoholdDown";
int keym = KEYM_DOWN; int keym = KEYM_DOWN;
GetMenuOptionBool(keyName, menuPress); GetMenuOptionBool(keyName, &menuPress);
toggleBitVar(&menuPress, &autohold, keym); toggleBitVar(&menuPress, &autohold, keym);
SetMenuOption(keyName, menuPress ? 1 : 0); SetMenuOption(keyName, menuPress ? 1 : 0);
GetMenuOptionInt(keyName, autohold, keym); GetMenuOptionInt(keyName, &autohold, keym);
} }
EVT_HANDLER(JoypadAutoholdLeft, "Autohold Left (toggle)") EVT_HANDLER(JoypadAutoholdLeft, "Autohold Left (toggle)")
{ {
bool menuPress; bool menuPress = false;
char keyName[] = "JoypadAutoholdLeft"; char keyName[] = "JoypadAutoholdLeft";
int keym = KEYM_LEFT; int keym = KEYM_LEFT;
GetMenuOptionBool(keyName, menuPress); GetMenuOptionBool(keyName, &menuPress);
toggleBitVar(&menuPress, &autohold, keym); toggleBitVar(&menuPress, &autohold, keym);
SetMenuOption(keyName, menuPress ? 1 : 0); SetMenuOption(keyName, menuPress ? 1 : 0);
GetMenuOptionInt(keyName, autohold, keym); GetMenuOptionInt(keyName, &autohold, keym);
} }
EVT_HANDLER(JoypadAutoholdRight, "Autohold Right (toggle)") EVT_HANDLER(JoypadAutoholdRight, "Autohold Right (toggle)")
{ {
bool menuPress; bool menuPress = false;
char keyName[] = "JoypadAutoholdRight"; char keyName[] = "JoypadAutoholdRight";
int keym = KEYM_RIGHT; int keym = KEYM_RIGHT;
GetMenuOptionBool(keyName, menuPress); GetMenuOptionBool(keyName, &menuPress);
toggleBitVar(&menuPress, &autohold, keym); toggleBitVar(&menuPress, &autohold, keym);
SetMenuOption(keyName, menuPress ? 1 : 0); SetMenuOption(keyName, menuPress ? 1 : 0);
GetMenuOptionInt(keyName, autohold, keym); GetMenuOptionInt(keyName, &autohold, keym);
} }
EVT_HANDLER(JoypadAutoholdA, "Autohold A (toggle)") EVT_HANDLER(JoypadAutoholdA, "Autohold A (toggle)")
{ {
bool menuPress; bool menuPress = false;
char keyName[] = "JoypadAutoholdA"; char keyName[] = "JoypadAutoholdA";
int keym = KEYM_A; int keym = KEYM_A;
GetMenuOptionBool(keyName, menuPress); GetMenuOptionBool(keyName, &menuPress);
toggleBitVar(&menuPress, &autohold, keym); toggleBitVar(&menuPress, &autohold, keym);
SetMenuOption(keyName, menuPress ? 1 : 0); SetMenuOption(keyName, menuPress ? 1 : 0);
GetMenuOptionInt(keyName, autohold, keym); GetMenuOptionInt(keyName, &autohold, keym);
} }
EVT_HANDLER(JoypadAutoholdB, "Autohold B (toggle)") EVT_HANDLER(JoypadAutoholdB, "Autohold B (toggle)")
{ {
bool menuPress; bool menuPress = false;
char keyName[] = "JoypadAutoholdB"; char keyName[] = "JoypadAutoholdB";
int keym = KEYM_B; int keym = KEYM_B;
GetMenuOptionBool(keyName, menuPress); GetMenuOptionBool(keyName, &menuPress);
toggleBitVar(&menuPress, &autohold, keym); toggleBitVar(&menuPress, &autohold, keym);
SetMenuOption(keyName, menuPress ? 1 : 0); SetMenuOption(keyName, menuPress ? 1 : 0);
GetMenuOptionInt(keyName, autohold, keym); GetMenuOptionInt(keyName, &autohold, keym);
} }
EVT_HANDLER(JoypadAutoholdL, "Autohold L (toggle)") EVT_HANDLER(JoypadAutoholdL, "Autohold L (toggle)")
{ {
bool menuPress; bool menuPress = false;
char keyName[] = "JoypadAutoholdL"; char keyName[] = "JoypadAutoholdL";
int keym = KEYM_L; int keym = KEYM_L;
GetMenuOptionBool(keyName, menuPress); GetMenuOptionBool(keyName, &menuPress);
toggleBitVar(&menuPress, &autohold, keym); toggleBitVar(&menuPress, &autohold, keym);
SetMenuOption(keyName, menuPress ? 1 : 0); SetMenuOption(keyName, menuPress ? 1 : 0);
GetMenuOptionInt(keyName, autohold, keym); GetMenuOptionInt(keyName, &autohold, keym);
} }
EVT_HANDLER(JoypadAutoholdR, "Autohold R (toggle)") EVT_HANDLER(JoypadAutoholdR, "Autohold R (toggle)")
{ {
bool menuPress; bool menuPress = false;
char keyName[] = "JoypadAutoholdR"; char keyName[] = "JoypadAutoholdR";
int keym = KEYM_R; int keym = KEYM_R;
GetMenuOptionBool(keyName, menuPress); GetMenuOptionBool(keyName, &menuPress);
toggleBitVar(&menuPress, &autohold, keym); toggleBitVar(&menuPress, &autohold, keym);
SetMenuOption(keyName, menuPress ? 1 : 0); SetMenuOption(keyName, menuPress ? 1 : 0);
GetMenuOptionInt(keyName, autohold, keym); GetMenuOptionInt(keyName, &autohold, keym);
} }
EVT_HANDLER(JoypadAutoholdSelect, "Autohold Select (toggle)") EVT_HANDLER(JoypadAutoholdSelect, "Autohold Select (toggle)")
{ {
bool menuPress; bool menuPress = false;
char keyName[] = "JoypadAutoholdSelect"; char keyName[] = "JoypadAutoholdSelect";
int keym = KEYM_SELECT; int keym = KEYM_SELECT;
GetMenuOptionBool(keyName, menuPress); GetMenuOptionBool(keyName, &menuPress);
toggleBitVar(&menuPress, &autohold, keym); toggleBitVar(&menuPress, &autohold, keym);
SetMenuOption(keyName, menuPress ? 1 : 0); SetMenuOption(keyName, menuPress ? 1 : 0);
GetMenuOptionInt(keyName, autohold, keym); GetMenuOptionInt(keyName, &autohold, keym);
} }
EVT_HANDLER(JoypadAutoholdStart, "Autohold Start (toggle)") EVT_HANDLER(JoypadAutoholdStart, "Autohold Start (toggle)")
{ {
bool menuPress; bool menuPress = false;
char keyName[] = "JoypadAutoholdStart"; char keyName[] = "JoypadAutoholdStart";
int keym = KEYM_START; int keym = KEYM_START;
GetMenuOptionBool(keyName, menuPress); GetMenuOptionBool(keyName, &menuPress);
toggleBitVar(&menuPress, &autohold, keym); toggleBitVar(&menuPress, &autohold, keym);
SetMenuOption(keyName, menuPress ? 1 : 0); SetMenuOption(keyName, menuPress ? 1 : 0);
GetMenuOptionInt(keyName, autohold, keym); GetMenuOptionInt(keyName, &autohold, keym);
} }
#include "background-input.h" #include "background-input.h"
EVT_HANDLER(AllowKeyboardBackgroundInput, "Allow keyboard background input (toggle)") EVT_HANDLER(AllowKeyboardBackgroundInput, "Allow keyboard background input (toggle)")
{ {
bool menuPress; bool menuPress = false;
GetMenuOptionBool("AllowKeyboardBackgroundInput", menuPress); GetMenuOptionBool("AllowKeyboardBackgroundInput", &menuPress);
toggleBooleanVar(&menuPress, &allowKeyboardBackgroundInput); toggleBooleanVar(&menuPress, &allowKeyboardBackgroundInput);
SetMenuOption("AllowKeyboardBackgroundInput", allowKeyboardBackgroundInput ? 1 : 0); SetMenuOption("AllowKeyboardBackgroundInput", allowKeyboardBackgroundInput ? 1 : 0);
@ -1676,8 +1678,8 @@ EVT_HANDLER(AllowKeyboardBackgroundInput, "Allow keyboard background input (togg
EVT_HANDLER(AllowJoystickBackgroundInput, "Allow joystick background input (toggle)") EVT_HANDLER(AllowJoystickBackgroundInput, "Allow joystick background input (toggle)")
{ {
bool menuPress; bool menuPress = false;
GetMenuOptionBool("AllowJoystickBackgroundInput", menuPress); GetMenuOptionBool("AllowJoystickBackgroundInput", &menuPress);
toggleBooleanVar(&menuPress, &allowJoystickBackgroundInput); toggleBooleanVar(&menuPress, &allowJoystickBackgroundInput);
SetMenuOption("AllowJoystickBackgroundInput", allowJoystickBackgroundInput ? 1 : 0); SetMenuOption("AllowJoystickBackgroundInput", allowJoystickBackgroundInput ? 1 : 0);
@ -1691,8 +1693,8 @@ 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; bool menuPress = false;
GetMenuOptionBool("LoadGameAutoLoad", menuPress); GetMenuOptionBool("LoadGameAutoLoad", &menuPress);
toggleBooleanVar(&menuPress, &gopts.autoload_state); toggleBooleanVar(&menuPress, &gopts.autoload_state);
SetMenuOption("LoadGameAutoLoad", gopts.autoload_state ? 1 : 0); SetMenuOption("LoadGameAutoLoad", gopts.autoload_state ? 1 : 0);
update_opts(); update_opts();
@ -1769,22 +1771,22 @@ EVT_HANDLER_MASK(Load, "Load state...", CMDEN_GB | CMDEN_GBA)
// new // new
EVT_HANDLER(KeepSaves, "Do not load battery saves (toggle)") EVT_HANDLER(KeepSaves, "Do not load battery saves (toggle)")
{ {
bool menuPress; bool menuPress = false;
GetMenuOptionBool("KeepSaves", menuPress); GetMenuOptionBool("KeepSaves", &menuPress);
toggleBitVar(&menuPress, &skipSaveGameBattery, 1); toggleBitVar(&menuPress, &skipSaveGameBattery, 1);
SetMenuOption("KeepSaves", menuPress ? 1 : 0); SetMenuOption("KeepSaves", menuPress ? 1 : 0);
GetMenuOptionInt("KeepSaves", skipSaveGameBattery, 1); GetMenuOptionInt("KeepSaves", &skipSaveGameBattery, 1);
update_opts(); update_opts();
} }
// new // new
EVT_HANDLER(KeepCheats, "Do not change cheat list (toggle)") EVT_HANDLER(KeepCheats, "Do not change cheat list (toggle)")
{ {
bool menuPress; bool menuPress = false;
GetMenuOptionBool("KeepCheats", menuPress); GetMenuOptionBool("KeepCheats", &menuPress);
toggleBitVar(&menuPress, &skipSaveGameCheats, 1); toggleBitVar(&menuPress, &skipSaveGameCheats, 1);
SetMenuOption("KeepCheats", menuPress ? 1 : 0); SetMenuOption("KeepCheats", menuPress ? 1 : 0);
GetMenuOptionInt("KeepCheats", skipSaveGameCheats, 1); GetMenuOptionInt("KeepCheats", &skipSaveGameCheats, 1);
update_opts(); update_opts();
} }
@ -1945,8 +1947,8 @@ 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; bool menuPress = false;
GetMenuOptionBool("CheatsAutoSaveLoad", menuPress); GetMenuOptionBool("CheatsAutoSaveLoad", &menuPress);
toggleBooleanVar(&menuPress, &gopts.autoload_cheats); toggleBooleanVar(&menuPress, &gopts.autoload_cheats);
SetMenuOption("CheatsAutoSaveLoad", gopts.autoload_cheats ? 1 : 0); SetMenuOption("CheatsAutoSaveLoad", gopts.autoload_cheats ? 1 : 0);
update_opts(); update_opts();
@ -1956,18 +1958,18 @@ EVT_HANDLER(CheatsAutoSaveLoad, "Auto save/load cheats (toggle)")
// changed for convenience to match internal variable functionality // changed for convenience to match internal variable functionality
EVT_HANDLER(CheatsEnable, "Enable cheats (toggle)") EVT_HANDLER(CheatsEnable, "Enable cheats (toggle)")
{ {
bool menuPress; bool menuPress = false;
GetMenuOptionBool("CheatsEnable", menuPress); GetMenuOptionBool("CheatsEnable", &menuPress);
toggleBitVar(&menuPress, &cheatsEnabled, 1); toggleBitVar(&menuPress, &cheatsEnabled, 1);
SetMenuOption("CheatsEnable", menuPress ? 1 : 0); SetMenuOption("CheatsEnable", menuPress ? 1 : 0);
GetMenuOptionInt("CheatsEnable", cheatsEnabled, 1); GetMenuOptionInt("CheatsEnable", &cheatsEnabled, 1);
update_opts(); update_opts();
} }
EVT_HANDLER(ColorizerHack, "Enable Colorizer Hack (toggle)") EVT_HANDLER(ColorizerHack, "Enable Colorizer Hack (toggle)")
{ {
int val = 0; int val = 0;
GetMenuOptionInt("ColorizerHack", val, 1); GetMenuOptionInt("ColorizerHack", &val, 1);
if (val == 1 && useBiosFileGB == 1) { if (val == 1 && useBiosFileGB == 1) {
wxLogError(_("Cannot use Colorizer Hack when GB BIOS File is enabled.")); wxLogError(_("Cannot use Colorizer Hack when GB BIOS File is enabled."));
@ -1983,96 +1985,96 @@ EVT_HANDLER(ColorizerHack, "Enable Colorizer Hack (toggle)")
// Debug menu // Debug menu
EVT_HANDLER_MASK(VideoLayersBG0, "Video layer BG0 (toggle)", CMDEN_GB | CMDEN_GBA) EVT_HANDLER_MASK(VideoLayersBG0, "Video layer BG0 (toggle)", CMDEN_GB | CMDEN_GBA)
{ {
bool menuPress; bool menuPress = false;
char keyName[] = "VideoLayersBG0"; char keyName[] = "VideoLayersBG0";
GetMenuOptionBool(keyName, menuPress); GetMenuOptionBool(keyName, &menuPress);
toggleBitVar(&menuPress, &layerSettings, (1 << 8)); toggleBitVar(&menuPress, &layerSettings, (1 << 8));
SetMenuOption(keyName, menuPress ? 1 : 0); SetMenuOption(keyName, menuPress ? 1 : 0);
GetMenuOptionInt(keyName, layerSettings, (1 << 8)); GetMenuOptionInt(keyName, &layerSettings, (1 << 8));
layerEnable = DISPCNT & layerSettings; layerEnable = DISPCNT & layerSettings;
CPUUpdateRenderBuffers(false); CPUUpdateRenderBuffers(false);
} }
EVT_HANDLER_MASK(VideoLayersBG1, "Video layer BG1 (toggle)", CMDEN_GB | CMDEN_GBA) EVT_HANDLER_MASK(VideoLayersBG1, "Video layer BG1 (toggle)", CMDEN_GB | CMDEN_GBA)
{ {
bool menuPress; bool menuPress = false;
char keyName[] = "VideoLayersBG1"; char keyName[] = "VideoLayersBG1";
GetMenuOptionBool(keyName, menuPress); GetMenuOptionBool(keyName, &menuPress);
toggleBitVar(&menuPress, &layerSettings, (1 << 9)); toggleBitVar(&menuPress, &layerSettings, (1 << 9));
SetMenuOption(keyName, menuPress ? 1 : 0); SetMenuOption(keyName, menuPress ? 1 : 0);
GetMenuOptionInt(keyName, layerSettings, (1 << 9)); GetMenuOptionInt(keyName, &layerSettings, (1 << 9));
layerEnable = DISPCNT & layerSettings; layerEnable = DISPCNT & layerSettings;
CPUUpdateRenderBuffers(false); CPUUpdateRenderBuffers(false);
} }
EVT_HANDLER_MASK(VideoLayersBG2, "Video layer BG2 (toggle)", CMDEN_GB | CMDEN_GBA) EVT_HANDLER_MASK(VideoLayersBG2, "Video layer BG2 (toggle)", CMDEN_GB | CMDEN_GBA)
{ {
bool menuPress; bool menuPress = false;
char keyName[] = "VideoLayersBG2"; char keyName[] = "VideoLayersBG2";
GetMenuOptionBool(keyName, menuPress); GetMenuOptionBool(keyName, &menuPress);
toggleBitVar(&menuPress, &layerSettings, (1 << 10)); toggleBitVar(&menuPress, &layerSettings, (1 << 10));
SetMenuOption(keyName, menuPress ? 1 : 0); SetMenuOption(keyName, menuPress ? 1 : 0);
GetMenuOptionInt(keyName, layerSettings, (1 << 10)); GetMenuOptionInt(keyName, &layerSettings, (1 << 10));
layerEnable = DISPCNT & layerSettings; layerEnable = DISPCNT & layerSettings;
CPUUpdateRenderBuffers(false); CPUUpdateRenderBuffers(false);
} }
EVT_HANDLER_MASK(VideoLayersBG3, "Video layer BG3 (toggle)", CMDEN_GB | CMDEN_GBA) EVT_HANDLER_MASK(VideoLayersBG3, "Video layer BG3 (toggle)", CMDEN_GB | CMDEN_GBA)
{ {
bool menuPress; bool menuPress = false;
char keyName[] = "VideoLayersBG3"; char keyName[] = "VideoLayersBG3";
GetMenuOptionBool(keyName, menuPress); GetMenuOptionBool(keyName, &menuPress);
toggleBitVar(&menuPress, &layerSettings, (1 << 11)); toggleBitVar(&menuPress, &layerSettings, (1 << 11));
SetMenuOption(keyName, menuPress ? 1 : 0); SetMenuOption(keyName, menuPress ? 1 : 0);
GetMenuOptionInt(keyName, layerSettings, (1 << 11)); GetMenuOptionInt(keyName, &layerSettings, (1 << 11));
layerEnable = DISPCNT & layerSettings; layerEnable = DISPCNT & layerSettings;
CPUUpdateRenderBuffers(false); CPUUpdateRenderBuffers(false);
} }
EVT_HANDLER_MASK(VideoLayersOBJ, "Video layer OBJ (toggle)", CMDEN_GB | CMDEN_GBA) EVT_HANDLER_MASK(VideoLayersOBJ, "Video layer OBJ (toggle)", CMDEN_GB | CMDEN_GBA)
{ {
bool menuPress; bool menuPress = false;
char keyName[] = "VideoLayersOBJ"; char keyName[] = "VideoLayersOBJ";
GetMenuOptionBool(keyName, menuPress); GetMenuOptionBool(keyName, &menuPress);
toggleBitVar(&menuPress, &layerSettings, (1 << 12)); toggleBitVar(&menuPress, &layerSettings, (1 << 12));
SetMenuOption(keyName, menuPress ? 1 : 0); SetMenuOption(keyName, menuPress ? 1 : 0);
GetMenuOptionInt(keyName, layerSettings, (1 << 12)); GetMenuOptionInt(keyName, &layerSettings, (1 << 12));
layerEnable = DISPCNT & layerSettings; layerEnable = DISPCNT & layerSettings;
CPUUpdateRenderBuffers(false); CPUUpdateRenderBuffers(false);
} }
EVT_HANDLER_MASK(VideoLayersWIN0, "Video layer WIN0 (toggle)", CMDEN_GB | CMDEN_GBA) EVT_HANDLER_MASK(VideoLayersWIN0, "Video layer WIN0 (toggle)", CMDEN_GB | CMDEN_GBA)
{ {
bool menuPress; bool menuPress = false;
char keyName[] = "VideoLayersWIN0"; char keyName[] = "VideoLayersWIN0";
GetMenuOptionBool(keyName, menuPress); GetMenuOptionBool(keyName, &menuPress);
toggleBitVar(&menuPress, &layerSettings, (1 << 13)); toggleBitVar(&menuPress, &layerSettings, (1 << 13));
SetMenuOption(keyName, menuPress ? 1 : 0); SetMenuOption(keyName, menuPress ? 1 : 0);
GetMenuOptionInt(keyName, layerSettings, (1 << 13)); GetMenuOptionInt(keyName, &layerSettings, (1 << 13));
layerEnable = DISPCNT & layerSettings; layerEnable = DISPCNT & layerSettings;
CPUUpdateRenderBuffers(false); CPUUpdateRenderBuffers(false);
} }
EVT_HANDLER_MASK(VideoLayersWIN1, "Video layer WIN1 (toggle)", CMDEN_GB | CMDEN_GBA) EVT_HANDLER_MASK(VideoLayersWIN1, "Video layer WIN1 (toggle)", CMDEN_GB | CMDEN_GBA)
{ {
bool menuPress; bool menuPress = false;
char keyName[] = "VideoLayersWIN1"; char keyName[] = "VideoLayersWIN1";
GetMenuOptionBool(keyName, menuPress); GetMenuOptionBool(keyName, &menuPress);
toggleBitVar(&menuPress, &layerSettings, (1 << 14)); toggleBitVar(&menuPress, &layerSettings, (1 << 14));
SetMenuOption(keyName, menuPress ? 1 : 0); SetMenuOption(keyName, menuPress ? 1 : 0);
GetMenuOptionInt(keyName, layerSettings, (1 << 14)); GetMenuOptionInt(keyName, &layerSettings, (1 << 14));
layerEnable = DISPCNT & layerSettings; layerEnable = DISPCNT & layerSettings;
CPUUpdateRenderBuffers(false); CPUUpdateRenderBuffers(false);
} }
EVT_HANDLER_MASK(VideoLayersOBJWIN, "Video layer OBJWIN (toggle)", CMDEN_GB | CMDEN_GBA) EVT_HANDLER_MASK(VideoLayersOBJWIN, "Video layer OBJWIN (toggle)", CMDEN_GB | CMDEN_GBA)
{ {
bool menuPress; bool menuPress = false;
char keyName[] = "VideoLayersOBJWIN"; char keyName[] = "VideoLayersOBJWIN";
GetMenuOptionBool(keyName, menuPress); GetMenuOptionBool(keyName, &menuPress);
toggleBitVar(&menuPress, &layerSettings, (1 << 15)); toggleBitVar(&menuPress, &layerSettings, (1 << 15));
SetMenuOption(keyName, menuPress ? 1 : 0); SetMenuOption(keyName, menuPress ? 1 : 0);
GetMenuOptionInt(keyName, layerSettings, (1 << 15)); GetMenuOptionInt(keyName, &layerSettings, (1 << 15));
layerEnable = DISPCNT & layerSettings; layerEnable = DISPCNT & layerSettings;
CPUUpdateRenderBuffers(false); CPUUpdateRenderBuffers(false);
} }
@ -2103,72 +2105,72 @@ EVT_HANDLER_MASK(VideoLayersReset, "Show all video layers", CMDEN_GB | CMDEN_GBA
EVT_HANDLER_MASK(SoundChannel1, "Sound Channel 1 (toggle)", CMDEN_GB | CMDEN_GBA) EVT_HANDLER_MASK(SoundChannel1, "Sound Channel 1 (toggle)", CMDEN_GB | CMDEN_GBA)
{ {
bool menuPress; bool menuPress = false;
char keyName[] = "SoundChannel1"; char keyName[] = "SoundChannel1";
GetMenuOptionBool(keyName, menuPress); GetMenuOptionBool(keyName, &menuPress);
toggleBitVar(&menuPress, &gopts.sound_en, (1 << 0)); toggleBitVar(&menuPress, &gopts.sound_en, (1 << 0));
SetMenuOption(keyName, menuPress ? 1 : 0); SetMenuOption(keyName, menuPress ? 1 : 0);
GetMenuOptionInt(keyName, gopts.sound_en, (1 << 0)); GetMenuOptionInt(keyName, &gopts.sound_en, (1 << 0));
soundSetEnable(gopts.sound_en); soundSetEnable(gopts.sound_en);
update_opts(); update_opts();
} }
EVT_HANDLER_MASK(SoundChannel2, "Sound Channel 2 (toggle)", CMDEN_GB | CMDEN_GBA) EVT_HANDLER_MASK(SoundChannel2, "Sound Channel 2 (toggle)", CMDEN_GB | CMDEN_GBA)
{ {
bool menuPress; bool menuPress = false;
char keyName[] = "SoundChannel2"; char keyName[] = "SoundChannel2";
GetMenuOptionBool(keyName, menuPress); GetMenuOptionBool(keyName, &menuPress);
toggleBitVar(&menuPress, &gopts.sound_en, (1 << 1)); toggleBitVar(&menuPress, &gopts.sound_en, (1 << 1));
SetMenuOption(keyName, menuPress ? 1 : 0); SetMenuOption(keyName, menuPress ? 1 : 0);
GetMenuOptionInt(keyName, gopts.sound_en, (1 << 1)); GetMenuOptionInt(keyName, &gopts.sound_en, (1 << 1));
soundSetEnable(gopts.sound_en); soundSetEnable(gopts.sound_en);
update_opts(); update_opts();
} }
EVT_HANDLER_MASK(SoundChannel3, "Sound Channel 3 (toggle)", CMDEN_GB | CMDEN_GBA) EVT_HANDLER_MASK(SoundChannel3, "Sound Channel 3 (toggle)", CMDEN_GB | CMDEN_GBA)
{ {
bool menuPress; bool menuPress = false;
char keyName[] = "SoundChannel3"; char keyName[] = "SoundChannel3";
GetMenuOptionBool(keyName, menuPress); GetMenuOptionBool(keyName, &menuPress);
toggleBitVar(&menuPress, &gopts.sound_en, (1 << 2)); toggleBitVar(&menuPress, &gopts.sound_en, (1 << 2));
SetMenuOption(keyName, menuPress ? 1 : 0); SetMenuOption(keyName, menuPress ? 1 : 0);
GetMenuOptionInt(keyName, gopts.sound_en, (1 << 2)); GetMenuOptionInt(keyName, &gopts.sound_en, (1 << 2));
soundSetEnable(gopts.sound_en); soundSetEnable(gopts.sound_en);
update_opts(); update_opts();
} }
EVT_HANDLER_MASK(SoundChannel4, "Sound Channel 4 (toggle)", CMDEN_GB | CMDEN_GBA) EVT_HANDLER_MASK(SoundChannel4, "Sound Channel 4 (toggle)", CMDEN_GB | CMDEN_GBA)
{ {
bool menuPress; bool menuPress = false;
char keyName[] = "SoundChannel4"; char keyName[] = "SoundChannel4";
GetMenuOptionBool(keyName, menuPress); GetMenuOptionBool(keyName, &menuPress);
toggleBitVar(&menuPress, &gopts.sound_en, (1 << 3)); toggleBitVar(&menuPress, &gopts.sound_en, (1 << 3));
SetMenuOption(keyName, menuPress ? 1 : 0); SetMenuOption(keyName, menuPress ? 1 : 0);
GetMenuOptionInt(keyName, gopts.sound_en, (1 << 3)); GetMenuOptionInt(keyName, &gopts.sound_en, (1 << 3));
soundSetEnable(gopts.sound_en); soundSetEnable(gopts.sound_en);
update_opts(); update_opts();
} }
EVT_HANDLER_MASK(DirectSoundA, "Direct Sound A (toggle)", CMDEN_GBA) EVT_HANDLER_MASK(DirectSoundA, "Direct Sound A (toggle)", CMDEN_GBA)
{ {
bool menuPress; bool menuPress = false;
char keyName[] = "DirectSoundA"; char keyName[] = "DirectSoundA";
GetMenuOptionBool(keyName, menuPress); GetMenuOptionBool(keyName, &menuPress);
toggleBitVar(&menuPress, &gopts.sound_en, (1 << 8)); toggleBitVar(&menuPress, &gopts.sound_en, (1 << 8));
SetMenuOption(keyName, menuPress ? 1 : 0); SetMenuOption(keyName, menuPress ? 1 : 0);
GetMenuOptionInt(keyName, gopts.sound_en, (1 << 8)); GetMenuOptionInt(keyName, &gopts.sound_en, (1 << 8));
soundSetEnable(gopts.sound_en); soundSetEnable(gopts.sound_en);
update_opts(); update_opts();
} }
EVT_HANDLER_MASK(DirectSoundB, "Direct Sound B (toggle)", CMDEN_GBA) EVT_HANDLER_MASK(DirectSoundB, "Direct Sound B (toggle)", CMDEN_GBA)
{ {
bool menuPress; bool menuPress = false;
char keyName[] = "DirectSoundB"; char keyName[] = "DirectSoundB";
GetMenuOptionBool(keyName, menuPress); GetMenuOptionBool(keyName, &menuPress);
toggleBitVar(&menuPress, &gopts.sound_en, (1 << 9)); toggleBitVar(&menuPress, &gopts.sound_en, (1 << 9));
SetMenuOption(keyName, menuPress ? 1 : 0); SetMenuOption(keyName, menuPress ? 1 : 0);
GetMenuOptionInt(keyName, gopts.sound_en, (1 << 9)); GetMenuOptionInt(keyName, &gopts.sound_en, (1 << 9));
soundSetEnable(gopts.sound_en); soundSetEnable(gopts.sound_en);
update_opts(); update_opts();
} }
@ -2315,7 +2317,7 @@ EVT_HANDLER(DebugGDBPort, "Configure port...")
EVT_HANDLER(DebugGDBBreakOnLoad, "Break on load") EVT_HANDLER(DebugGDBBreakOnLoad, "Break on load")
{ {
#ifndef NO_DEBUGGER #ifndef NO_DEBUGGER
GetMenuOptionInt("DebugGDBBreakOnLoad", gdbBreakOnLoad, 1); GetMenuOptionInt("DebugGDBBreakOnLoad", &gdbBreakOnLoad, 1);
update_opts(); update_opts();
#endif #endif
} }
@ -2976,7 +2978,7 @@ EVT_HANDLER(wxID_ABOUT, "About...")
EVT_HANDLER(Bilinear, "Use bilinear filter with 3d renderer") EVT_HANDLER(Bilinear, "Use bilinear filter with 3d renderer")
{ {
GetMenuOptionBool("Bilinear", gopts.bilinear); GetMenuOptionBool("Bilinear", &gopts.bilinear);
// Force new panel with new bilinear option // Force new panel with new bilinear option
if (panel->panel) { if (panel->panel) {
panel->panel->Destroy(); panel->panel->Destroy();
@ -2987,7 +2989,7 @@ EVT_HANDLER(Bilinear, "Use bilinear filter with 3d renderer")
EVT_HANDLER(RetainAspect, "Retain aspect ratio when resizing") EVT_HANDLER(RetainAspect, "Retain aspect ratio when resizing")
{ {
GetMenuOptionBool("RetainAspect", gopts.retain_aspect); GetMenuOptionBool("RetainAspect", &gopts.retain_aspect);
// Force new panel with new aspect ratio options. // Force new panel with new aspect ratio options.
if (panel->panel) { if (panel->panel) {
@ -3000,7 +3002,7 @@ EVT_HANDLER(RetainAspect, "Retain aspect ratio when resizing")
EVT_HANDLER(Printer, "Enable printer emulation") EVT_HANDLER(Printer, "Enable printer emulation")
{ {
GetMenuOptionInt("Printer", winGbPrinterEnabled, 1); GetMenuOptionInt("Printer", &winGbPrinterEnabled, 1);
#if (defined __WIN32__ || defined _WIN32) #if (defined __WIN32__ || defined _WIN32)
#ifndef NO_LINK #ifndef NO_LINK
gbSerialFunction = gbStartLink; gbSerialFunction = gbStartLink;
@ -3016,25 +3018,25 @@ 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); GetMenuOptionBool("PrintGather", &gopts.print_auto_page);
update_opts(); 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); GetMenuOptionBool("PrintSnap", &gopts.print_screen_cap);
update_opts(); update_opts();
} }
EVT_HANDLER(GBASoundInterpolation, "GBA sound interpolation") EVT_HANDLER(GBASoundInterpolation, "GBA sound interpolation")
{ {
GetMenuOptionBool("GBASoundInterpolation", soundInterpolation); GetMenuOptionBool("GBASoundInterpolation", &soundInterpolation);
update_opts(); update_opts();
} }
EVT_HANDLER(GBDeclicking, "GB sound declicking") EVT_HANDLER(GBDeclicking, "GB sound declicking")
{ {
GetMenuOptionBool("GBDeclicking", gopts.gb_declick); GetMenuOptionBool("GBDeclicking", &gopts.gb_declick);
// note that setting declick may reset gb sound engine // note that setting declick may reset gb sound engine
gbSoundSetDeclicking(gopts.gb_declick); gbSoundSetDeclicking(gopts.gb_declick);
update_opts(); update_opts();
@ -3042,28 +3044,28 @@ EVT_HANDLER(GBDeclicking, "GB sound declicking")
EVT_HANDLER(GBEnhanceSound, "Enable GB sound effects") EVT_HANDLER(GBEnhanceSound, "Enable GB sound effects")
{ {
GetMenuOptionBool("GBEnhanceSound", gopts.gb_effects_config_enabled); GetMenuOptionBool("GBEnhanceSound", &gopts.gb_effects_config_enabled);
gb_effects_config.enabled = gopts.gb_effects_config_enabled; gb_effects_config.enabled = gopts.gb_effects_config_enabled;
update_opts(); update_opts();
} }
EVT_HANDLER(GBSurround, "GB surround sound effect (%)") EVT_HANDLER(GBSurround, "GB surround sound effect (%)")
{ {
GetMenuOptionBool("GBSurround", gopts.gb_effects_config_surround); GetMenuOptionBool("GBSurround",&gopts.gb_effects_config_surround);
gb_effects_config.surround = gopts.gb_effects_config_surround; gb_effects_config.surround = gopts.gb_effects_config_surround;
update_opts(); update_opts();
} }
EVT_HANDLER(AGBPrinter, "Enable AGB printer") EVT_HANDLER(AGBPrinter, "Enable AGB printer")
{ {
GetMenuOptionInt("AGBPrinter", agbPrint, 1); GetMenuOptionInt("AGBPrinter", &agbPrint, 1);
update_opts(); update_opts();
} }
EVT_HANDLER_MASK(GBALcdFilter, "Enable LCD filter", CMDEN_GBA) EVT_HANDLER_MASK(GBALcdFilter, "Enable LCD filter", CMDEN_GBA)
{ {
bool menuPress; bool menuPress = false;
GetMenuOptionBool("GBALcdFilter", menuPress); GetMenuOptionBool("GBALcdFilter", &menuPress);
toggleBooleanVar(&menuPress, &gbaLcdFilter); toggleBooleanVar(&menuPress, &gbaLcdFilter);
SetMenuOption("GBALcdFilter", gbaLcdFilter ? 1 : 0); SetMenuOption("GBALcdFilter", gbaLcdFilter ? 1 : 0);
utilUpdateSystemColorMaps(gbaLcdFilter); utilUpdateSystemColorMaps(gbaLcdFilter);
@ -3072,8 +3074,8 @@ EVT_HANDLER_MASK(GBALcdFilter, "Enable LCD filter", CMDEN_GBA)
EVT_HANDLER_MASK(GBLcdFilter, "Enable LCD filter", CMDEN_GB) EVT_HANDLER_MASK(GBLcdFilter, "Enable LCD filter", CMDEN_GB)
{ {
bool menuPress; bool menuPress = false;
GetMenuOptionBool("GBLcdFilter", menuPress); GetMenuOptionBool("GBLcdFilter", &menuPress);
toggleBooleanVar(&menuPress, &gbLcdFilter); toggleBooleanVar(&menuPress, &gbLcdFilter);
SetMenuOption("GBLcdFilter", gbLcdFilter ? 1 : 0); SetMenuOption("GBLcdFilter", gbLcdFilter ? 1 : 0);
utilUpdateSystemColorMaps(gbLcdFilter); utilUpdateSystemColorMaps(gbLcdFilter);
@ -3082,9 +3084,9 @@ EVT_HANDLER_MASK(GBLcdFilter, "Enable LCD filter", CMDEN_GB)
EVT_HANDLER(GBColorOption, "Enable GB color option") EVT_HANDLER(GBColorOption, "Enable GB color option")
{ {
bool menuPress; bool menuPress = false;
bool intVar = gbColorOption ? true : false; bool intVar = gbColorOption ? true : false;
GetMenuOptionBool("GBColorOption", menuPress); GetMenuOptionBool("GBColorOption", &menuPress);
toggleBooleanVar(&menuPress, &intVar); toggleBooleanVar(&menuPress, &intVar);
SetMenuOption("GBColorOption", intVar ? 1 : 0); SetMenuOption("GBColorOption", intVar ? 1 : 0);
gbColorOption = intVar ? 1 : 0; gbColorOption = intVar ? 1 : 0;
@ -3093,21 +3095,21 @@ EVT_HANDLER(GBColorOption, "Enable GB color option")
EVT_HANDLER(ApplyPatches, "Apply IPS/UPS/IPF patches if found") EVT_HANDLER(ApplyPatches, "Apply IPS/UPS/IPF patches if found")
{ {
GetMenuOptionInt("ApplyPatches", autoPatch, 1); GetMenuOptionInt("ApplyPatches", &autoPatch, 1);
update_opts(); update_opts();
} }
EVT_HANDLER(MMX, "Enable MMX") EVT_HANDLER(MMX, "Enable MMX")
{ {
#ifdef MMX #ifdef MMX
GetMenuOptionInt("MMX", enableMMX, 1); GetMenuOptionInt("MMX", &enableMMX, 1);
update_opts(); update_opts();
#endif #endif
} }
EVT_HANDLER(KeepOnTop, "Keep window on top") EVT_HANDLER(KeepOnTop, "Keep window on top")
{ {
GetMenuOptionBool("KeepOnTop", gopts.keep_on_top); GetMenuOptionBool("KeepOnTop", &gopts.keep_on_top);
MainFrame* mf = wxGetApp().frame; MainFrame* mf = wxGetApp().frame;
if (gopts.keep_on_top) if (gopts.keep_on_top)
@ -3120,7 +3122,7 @@ EVT_HANDLER(KeepOnTop, "Keep window on top")
EVT_HANDLER(StatusBar, "Enable status bar") EVT_HANDLER(StatusBar, "Enable status bar")
{ {
GetMenuOptionInt("StatusBar", gopts.statusbar, 1); GetMenuOptionInt("StatusBar", &gopts.statusbar, 1);
update_opts(); update_opts();
MainFrame* mf = wxGetApp().frame; MainFrame* mf = wxGetApp().frame;
@ -3136,56 +3138,56 @@ EVT_HANDLER(StatusBar, "Enable status bar")
EVT_HANDLER(NoStatusMsg, "Disable on-screen status messages") EVT_HANDLER(NoStatusMsg, "Disable on-screen status messages")
{ {
GetMenuOptionInt("NoStatusMsg", disableStatusMessages, 1); GetMenuOptionInt("NoStatusMsg", &disableStatusMessages, 1);
update_opts(); update_opts();
} }
EVT_HANDLER(FrameSkipAuto, "Auto Skip frames.") EVT_HANDLER(FrameSkipAuto, "Auto Skip frames.")
{ {
GetMenuOptionInt("FrameSkipAuto", autoFrameSkip, 1); GetMenuOptionInt("FrameSkipAuto", &autoFrameSkip, 1);
update_opts(); update_opts();
} }
EVT_HANDLER(Fullscreen, "Enter fullscreen mode at startup") EVT_HANDLER(Fullscreen, "Enter fullscreen mode at startup")
{ {
GetMenuOptionInt("Fullscreen", fullScreen, 1); GetMenuOptionInt("Fullscreen", &fullScreen, 1);
update_opts(); update_opts();
} }
EVT_HANDLER(PauseWhenInactive, "Pause game when main window loses focus") EVT_HANDLER(PauseWhenInactive, "Pause game when main window loses focus")
{ {
GetMenuOptionInt("PauseWhenInactive", pauseWhenInactive, 1); GetMenuOptionInt("PauseWhenInactive", &pauseWhenInactive, 1);
update_opts(); update_opts();
} }
EVT_HANDLER(RTC, "Enable RTC (vba-over.ini override is rtcEnabled") EVT_HANDLER(RTC, "Enable RTC (vba-over.ini override is rtcEnabled")
{ {
GetMenuOptionInt("RTC", rtcEnabled, 1); GetMenuOptionInt("RTC", &rtcEnabled, 1);
update_opts(); update_opts();
} }
EVT_HANDLER(Transparent, "Draw on-screen messages transparently") EVT_HANDLER(Transparent, "Draw on-screen messages transparently")
{ {
GetMenuOptionInt("Transparent", showSpeedTransparent, 1); GetMenuOptionInt("Transparent", &showSpeedTransparent, 1);
update_opts(); update_opts();
} }
EVT_HANDLER(SkipIntro, "Skip BIOS initialization") EVT_HANDLER(SkipIntro, "Skip BIOS initialization")
{ {
GetMenuOptionInt("SkipIntro", skipBios, 1); GetMenuOptionInt("SkipIntro", &skipBios, 1);
update_opts(); update_opts();
} }
EVT_HANDLER(BootRomEn, "Use the specified BIOS file for GBA") EVT_HANDLER(BootRomEn, "Use the specified BIOS file for GBA")
{ {
GetMenuOptionInt("BootRomEn", useBiosFileGBA, 1); GetMenuOptionInt("BootRomEn", &useBiosFileGBA, 1);
update_opts(); 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; int val = 0;
GetMenuOptionInt("BootRomGB", val, 1); GetMenuOptionInt("BootRomGB", &val, 1);
if (val == 1 && colorizerHack == 1) { if (val == 1 && colorizerHack == 1) {
wxLogError(_("Cannot use GB BIOS when Colorizer Hack is enabled.")); wxLogError(_("Cannot use GB BIOS when Colorizer Hack is enabled."));
@ -3200,13 +3202,13 @@ EVT_HANDLER(BootRomGB, "Use the specified BIOS file for GB")
EVT_HANDLER(BootRomGBC, "Use the specified BIOS file for GBC") EVT_HANDLER(BootRomGBC, "Use the specified BIOS file for GBC")
{ {
GetMenuOptionInt("BootRomGBC", useBiosFileGBC, 1); GetMenuOptionInt("BootRomGBC", &useBiosFileGBC, 1);
update_opts(); update_opts();
} }
EVT_HANDLER(VSync, "Wait for vertical sync") EVT_HANDLER(VSync, "Wait for vertical sync")
{ {
GetMenuOptionInt("VSync", vsync, 1); GetMenuOptionInt("VSync", &vsync, 1);
update_opts(); update_opts();
} }
@ -3291,19 +3293,19 @@ EVT_HANDLER(LinkType4Gameboy, "Link Gameboy")
EVT_HANDLER(LinkAuto, "Enable link at boot") EVT_HANDLER(LinkAuto, "Enable link at boot")
{ {
GetMenuOptionBool("LinkAuto", gopts.link_auto); GetMenuOptionBool("LinkAuto", &gopts.link_auto);
update_opts(); update_opts();
} }
EVT_HANDLER(SpeedOn, "Enable faster network protocol by default") EVT_HANDLER(SpeedOn, "Enable faster network protocol by default")
{ {
GetMenuOptionInt("SpeedOn", linkHacks, 1); GetMenuOptionInt("SpeedOn", &linkHacks, 1);
update_opts(); update_opts();
} }
EVT_HANDLER(LinkProto, "Local host IPC") EVT_HANDLER(LinkProto, "Local host IPC")
{ {
GetMenuOptionInt("LinkProto", gopts.link_proto, 1); GetMenuOptionInt("LinkProto", &gopts.link_proto, 1);
update_opts(); update_opts();
enable_menus(); enable_menus();
EnableNetworkMenu(); EnableNetworkMenu();

View File

@ -2978,10 +2978,14 @@ bool MainFrame::BindControls()
checkable_mi.push_back(cmi); checkable_mi.push_back(cmi);
for (const VbamOption& option : VbamOption::AllOptions()) { for (const VbamOption& option : VbamOption::AllOptions()) {
if (cmdtab[i].cmd == option.command()) {
if (option.is_int()) { if (option.is_int()) {
MenuOptionIntMask(option.command(), option.GetInt(), (1 << 0)); MenuOptionIntMask(
option.command(), option.GetInt(), (1 << 0));
} else if (option.is_bool()) { } else if (option.is_bool()) {
MenuOptionBool(option.command(), option.GetBool()); MenuOptionBool(
option.command(), option.GetBool());
}
} }
} }
} }
@ -3692,8 +3696,11 @@ bool MainFrame::BindControls()
getsc("MaxScale", maxScale); getsc("MaxScale", maxScale);
/// Basic /// Basic
getrbi("OutputSimple", gopts.render_method, RND_SIMPLE); getrbi("OutputSimple", gopts.render_method, RND_SIMPLE);
#if defined(__WXMAC__)
getrbi("OutputQuartz2D", gopts.render_method, RND_QUARTZ2D); getrbi("OutputQuartz2D", gopts.render_method, RND_QUARTZ2D);
#if !defined(__WXMAC__) #else
rb = SafeXRCCTRL<wxRadioButton>(d, "OutputQuartz2D");
rb->Hide(); rb->Hide();
#endif #endif
getrbi("OutputOpenGL", gopts.render_method, RND_OPENGL); getrbi("OutputOpenGL", gopts.render_method, RND_OPENGL);
@ -3706,10 +3713,11 @@ bool MainFrame::BindControls()
rb->Hide(); rb->Hide();
} }
#endif #endif
getrbi("OutputDirect3D", gopts.render_method, RND_DIRECT3D);
#if !defined(__WXMSW__) || defined(NO_D3D) || 1 // not implemented // Direct3D is not implemented so hide the option on every platform.
rb = SafeXRCCTRL<wxRadioButton>(d, "OutputDirect3D");
rb->Hide(); rb->Hide();
#endif
ch = GetValidatedChild<wxChoice, wxGenericValidator>(d, "Filter", wxGenericValidator(&gopts.filter)); ch = GetValidatedChild<wxChoice, wxGenericValidator>(d, "Filter", wxGenericValidator(&gopts.filter));
// Save the Filters choice control to extract the names from the XRC. // Save the Filters choice control to extract the names from the XRC.

View File

@ -18,7 +18,7 @@ struct VbamOptionData {
const VbamOption::Type type; const VbamOption::Type type;
}; };
// Static data to initialize global values.; // Static data to initialize global values.
extern const std::array<VbamOptionData, kNbOptions + 1> kAllOptionsData; extern const std::array<VbamOptionData, kNbOptions + 1> kAllOptionsData;
// Conversion utilities. // Conversion utilities.

View File

@ -1,7 +1,8 @@
#include "vbam-options.h" #include "vbam-options.h"
// Helper implementation file to define and compile all of these huge constants // Helper implementation file to define and compile all of these huge constants
// separately. These should not be updated very often, so this improves // separately. These should not be updated very often, so having these in a
// separate file improves incremental build time.
#include <algorithm> #include <algorithm>
#include <wx/log.h> #include <wx/log.h>
@ -9,7 +10,6 @@
#include "../common/ConfigManager.h" #include "../common/ConfigManager.h"
#include "../gb/gbGlobals.h" #include "../gb/gbGlobals.h"
#include "opts.h" #include "opts.h"
#include "wx/stringimpl.h"
#define VBAM_OPTIONS_INTERNAL_INCLUDE #define VBAM_OPTIONS_INTERNAL_INCLUDE
#include "vbam-options-internal.h" #include "vbam-options-internal.h"
@ -18,6 +18,7 @@
namespace { namespace {
// This enum must be kept in sync with the one in wxvbam.h // This enum must be kept in sync with the one in wxvbam.h
// TODO: These 2 enums should be unified and a validator created for this enum.
enum class FilterFunction { enum class FilterFunction {
kNone, kNone,
k2xsai, k2xsai,
@ -78,6 +79,7 @@ static const std::array<wxString, kNbFilterFunctions> kFilterStrings = {
}; };
// This enum must be kept in sync with the one in wxvbam.h // This enum must be kept in sync with the one in wxvbam.h
// TODO: These 2 enums should be unified and a validator created for this enum.
enum class Interframe { enum class Interframe {
kNone = 0, kNone = 0,
kSmart, kSmart,
@ -98,6 +100,7 @@ static const std::array<wxString, kNbInterframes> kInterframeStrings = {
}; };
// This enum must be kept in sync with the one in wxvbam.h // This enum must be kept in sync with the one in wxvbam.h
// TODO: These 2 enums should be unified and a validator created for this enum.
enum class RenderMethod { enum class RenderMethod {
kSimple = 0, kSimple = 0,
kOpenGL, kOpenGL,
@ -126,6 +129,8 @@ static const std::array<wxString, kNbRenderMethods> kRenderMethodStrings = {
}; };
// This enum must be kept in sync with the one in wxvbam.h // This enum must be kept in sync with the one in wxvbam.h
// TODO: These 2 enums should be unified and a validator created for this enum.
// TODO: DirectSound and XAudio2 should only be used on Windows.
enum class AudioApi { enum class AudioApi {
kSdl = 0, kSdl = 0,
kOpenAL, kOpenAL,
@ -469,140 +474,23 @@ const std::array<VbamOptionData, kNbOptions + 1> kAllOptionsData = {
VbamOptionData { "Sound/Quality", "", _("Sound sample rate (kHz)"), VbamOption::Type::kSoundQuality }, VbamOptionData { "Sound/Quality", "", _("Sound sample rate (kHz)"), VbamOption::Type::kSoundQuality },
VbamOptionData { "Sound/Volume", "", _("Sound volume (%)"), VbamOption::Type::kInt }, VbamOptionData { "Sound/Volume", "", _("Sound volume (%)"), VbamOption::Type::kInt },
// Last // Last. This should never be used, it actually maps to VbamOptionID::kLast.
// This is to prevent a memory access violation error in case something
// attempts to instantiate a VbamOptionID::kLast. It will trigger a check
// in the VbamOption constructor, but that is after the constructor has
// accessed this entry.
VbamOptionData { "", "", "", VbamOption::Type::kNone }, VbamOptionData { "", "", "", VbamOption::Type::kNone },
}; };
nonstd::optional<VbamOptionID> StringToOptionId(const wxString& input) { nonstd::optional<VbamOptionID> StringToOptionId(const wxString& input) {
// Note: This map does not include "Joystick" and "Keyboard". This is on static std::map<wxString, VbamOptionID> kStringToOptionId;
// purpose, as these are handled separately. if (kStringToOptionId.empty()) {
static const std::map<wxString, VbamOptionID> kStringToOptionId = { for (size_t i = 0; i < kNbOptions; i++) {
{ "Display/Bilinear", VbamOptionID::kDisplayBilinear }, kStringToOptionId.emplace(
{ "Display/Filter", VbamOptionID::kDisplayFilter }, kAllOptionsData[i].config_name, static_cast<VbamOptionID>(i));
{ "Display/FilterPlugin", VbamOptionID::kDisplayFilterPlugin }, }
{ "Display/IFB", VbamOptionID::kDisplayIFB }, assert(kStringToOptionId.size() == kNbOptions);
{ "Display/KeepOnTop", VbamOptionID::kDisplayKeepOnTop }, }
{ "Display/MaxThreads", VbamOptionID::kDisplayMaxThreads },
{ "Display/RenderMethod", VbamOptionID::kDisplayRenderMethod },
{ "Display/Scale", VbamOptionID::kDisplayScale },
{ "Display/Stretch", VbamOptionID::kDisplayStretch },
/// GB
{ "GB/BiosFile", VbamOptionID::kGBBiosFile },
{ "GB/ColorOption", VbamOptionID::kGBColorOption },
{ "GB/ColorizerHack", VbamOptionID::kGBColorizerHack },
{ "GB/LCDFilter", VbamOptionID::kGBLCDFilter },
{ "GB/GBCBiosFile", VbamOptionID::kGBGBCBiosFile },
{ "GB/Palette0", VbamOptionID::kGBPalette0 },
{ "GB/Palette1", VbamOptionID::kGBPalette1 },
{ "GB/Palette2", VbamOptionID::kGBPalette2 },
{ "GB/PrintAutoPage", VbamOptionID::kGBPrintAutoPage },
{ "GB/PrintScreenCap", VbamOptionID::kGBPrintScreenCap },
{ "GB/ROMDir", VbamOptionID::kGBROMDir },
{ "GB/GBCROMDir", VbamOptionID::kGBGBCROMDir },
/// GBA
{ "GBA/BiosFile", VbamOptionID::kGBABiosFile },
{ "GBA/LCDFilter", VbamOptionID::kGBALCDFilter },
#ifndef NO_LINK
{ "GBA/LinkAuto", VbamOptionID::kGBALinkAuto },
{ "GBA/LinkFast", VbamOptionID::kGBALinkFast },
{ "GBA/LinkHost", VbamOptionID::kGBALinkHost },
{ "GBA/ServerIP", VbamOptionID::kGBAServerIP },
{ "GBA/LinkPort", VbamOptionID::kGBALinkPort },
{ "GBA/LinkProto", VbamOptionID::kGBALinkProto },
{ "GBA/LinkTimeout", VbamOptionID::kGBALinkTimeout },
{ "GBA/LinkType", VbamOptionID::kGBALinkType },
#endif
{ "GBA/ROMDir", VbamOptionID::kGBAROMDir },
/// General
{ "General/AutoLoadLastState", VbamOptionID::kGeneralAutoLoadLastState },
{ "General/BatteryDir", VbamOptionID::kGeneralBatteryDir },
{ "General/FreezeRecent", VbamOptionID::kGeneralFreezeRecent },
{ "General/RecordingDir", VbamOptionID::kGeneralRecordingDir },
{ "General/RewindInterval", VbamOptionID::kGeneralRewindInterval },
{ "General/ScreenshotDir", VbamOptionID::kGeneralScreenshotDir },
{ "General/StateDir", VbamOptionID::kGeneralStateDir },
{ "General/StatusBar", VbamOptionID::kGeneralStatusBar },
/// Joypad
{ "Joypad/AutofireThrottle", VbamOptionID::kJoypadAutofireThrottle },
{ "Joypad/Default", VbamOptionID::kJoypadDefault },
// Core
{ "preferences/agbPrint", VbamOptionID::kpreferencesagbPrint },
{ "preferences/autoFrameSkip", VbamOptionID::kpreferencesautoFrameSkip },
{ "preferences/autoPatch", VbamOptionID::kpreferencesautoPatch },
{ "preferences/autoSaveLoadCheatList", VbamOptionID::kpreferencesautoSaveLoadCheatList },
{ "preferences/borderAutomatic", VbamOptionID::kpreferencesborderAutomatic },
{ "preferences/borderOn", VbamOptionID::kpreferencesborderOn },
{ "preferences/captureFormat", VbamOptionID::kpreferencescaptureFormat },
{ "preferences/cheatsEnabled", VbamOptionID::kpreferencescheatsEnabled },
#ifdef MMX
{ "preferences/enableMMX", VbamOptionID::kpreferencesenableMMX },
#endif
{ "preferences/disableStatus", VbamOptionID::kpreferencesdisableStatus },
{ "preferences/emulatorType", VbamOptionID::kpreferencesemulatorType },
{ "preferences/flashSize", VbamOptionID::kpreferencesflashSize },
{ "preferences/frameSkip", VbamOptionID::kpreferencesframeSkip },
{ "preferences/fsColorDepth", VbamOptionID::kpreferencesfsColorDepth },
{ "preferences/fsFrequency", VbamOptionID::kpreferencesfsFrequency },
{ "preferences/fsHeight", VbamOptionID::kpreferencesfsHeight },
{ "preferences/fsWidth", VbamOptionID::kpreferencesfsWidth },
{ "preferences/gbPaletteOption", VbamOptionID::kpreferencesgbPaletteOption },
{ "preferences/gbPrinter", VbamOptionID::kpreferencesgbPrinter },
{ "preferences/gdbBreakOnLoad", VbamOptionID::kpreferencesgdbBreakOnLoad },
{ "preferences/gdbPort", VbamOptionID::kpreferencesgdbPort },
#ifndef NO_LINK
{ "preferences/LinkNumPlayers", VbamOptionID::kpreferencesLinkNumPlayers },
#endif
{ "preferences/maxScale", VbamOptionID::kpreferencesmaxScale },
{ "preferences/pauseWhenInactive", VbamOptionID::kpreferencespauseWhenInactive },
{ "preferences/rtcEnabled", VbamOptionID::kpreferencesrtcEnabled },
{ "preferences/saveType", VbamOptionID::kpreferencessaveType },
{ "preferences/showSpeed", VbamOptionID::kpreferencesshowSpeed },
{ "preferences/showSpeedTransparent", VbamOptionID::kpreferencesshowSpeedTransparent },
{ "preferences/skipBios", VbamOptionID::kpreferencesskipBios },
{ "preferences/skipSaveGameCheats", VbamOptionID::kpreferencesskipSaveGameCheats },
{ "preferences/skipSaveGameBattery", VbamOptionID::kpreferencesskipSaveGameBattery },
{ "preferences/throttle", VbamOptionID::kpreferencesthrottle },
{ "preferences/speedupThrottle", VbamOptionID::kpreferencesspeedupThrottle },
{ "preferences/speedupFrameSkip", VbamOptionID::kpreferencesspeedupFrameSkip },
{ "preferences/speedupThrottleFrameSkip", VbamOptionID::kpreferencesspeedupThrottleFrameSkip },
{ "preferences/useBiosGB", VbamOptionID::kpreferencesuseBiosGB },
{ "preferences/useBiosGBA", VbamOptionID::kpreferencesuseBiosGBA },
{ "preferences/useBiosGBC", VbamOptionID::kpreferencesuseBiosGBC },
{ "preferences/vsync", VbamOptionID::kpreferencesvsync },
/// Geometry
{ "geometry/fullScreen", VbamOptionID::kgeometryfullScreen },
{ "geometry/isMaximized", VbamOptionID::kgeometryisMaximized },
{ "geometry/windowHeight", VbamOptionID::kgeometrywindowHeight },
{ "geometry/windowWidth", VbamOptionID::kgeometrywindowWidth },
{ "geometry/windowX", VbamOptionID::kgeometrywindowX },
{ "geometry/windowY", VbamOptionID::kgeometrywindowY },
/// UI
{ "ui/allowKeyboardBackgroundInput", VbamOptionID::kuiallowKeyboardBackgroundInput },
{ "ui/allowJoystickBackgroundInput", VbamOptionID::kuiallowJoystickBackgroundInput },
{ "ui/hideMenuBar", VbamOptionID::kuihideMenuBar },
/// Sound
{ "Sound/AudioAPI", VbamOptionID::kSoundAudioAPI },
{ "Sound/AudioDevice", VbamOptionID::kSoundAudioDevice },
{ "Sound/Buffers", VbamOptionID::kSoundBuffers },
{ "Sound/Enable", VbamOptionID::kSoundEnable },
{ "Sound/GBAFiltering", VbamOptionID::kSoundGBAFiltering },
{ "Sound/GBAInterpolation", VbamOptionID::kSoundGBAInterpolation },
{ "Sound/GBDeclicking", VbamOptionID::kSoundGBDeclicking },
{ "Sound/GBEcho", VbamOptionID::kSoundGBEcho },
{ "Sound/GBEnableEffects", VbamOptionID::kSoundGBEnableEffects },
{ "Sound/GBStereo", VbamOptionID::kSoundGBStereo },
{ "Sound/GBSurround", VbamOptionID::kSoundGBSurround },
{ "Sound/Quality", VbamOptionID::kSoundQuality },
{ "Sound/Volume", VbamOptionID::kSoundVolume },
};
const auto iter = kStringToOptionId.find(input); const auto iter = kStringToOptionId.find(input);
if (iter == kStringToOptionId.end()) { if (iter == kStringToOptionId.end()) {
@ -637,32 +525,14 @@ wxString SoundQualityToString(int value) {
} }
int StringToFilter(const wxString& config_name, const wxString& input) { int StringToFilter(const wxString& config_name, const wxString& input) {
static const std::map<wxString, FilterFunction> kStringToFilter = { static std::map<wxString, FilterFunction> kStringToFilter;
{ kFilterStrings[0], FilterFunction::kNone }, if (kStringToFilter.empty()) {
{ kFilterStrings[1], FilterFunction::k2xsai }, for (size_t i = 0; i < kNbFilterFunctions; i++) {
{ kFilterStrings[2], FilterFunction::kSuper2xsai }, kStringToFilter.emplace(
{ kFilterStrings[3], FilterFunction::kSupereagle }, kFilterStrings[i], static_cast<FilterFunction>(i));
{ kFilterStrings[4], FilterFunction::kPixelate }, }
{ kFilterStrings[5], FilterFunction::kAdvmame }, assert(kStringToFilter.size() == kNbFilterFunctions);
{ kFilterStrings[6], FilterFunction::kBilinear }, }
{ kFilterStrings[7], FilterFunction::kBilinearplus },
{ kFilterStrings[8], FilterFunction::kScanlines },
{ kFilterStrings[9], FilterFunction::kTvmode },
{ kFilterStrings[10], FilterFunction::kHQ2x },
{ kFilterStrings[11], FilterFunction::kLQ2x },
{ kFilterStrings[12], FilterFunction::kSimple2x },
{ kFilterStrings[13], FilterFunction::kSimple3x },
{ kFilterStrings[14], FilterFunction::kHQ3x },
{ kFilterStrings[15], FilterFunction::kSimple4x },
{ kFilterStrings[16], FilterFunction::kHQ4x },
{ kFilterStrings[17], FilterFunction::kXbrz2x },
{ kFilterStrings[18], FilterFunction::kXbrz3x },
{ kFilterStrings[19], FilterFunction::kXbrz4x },
{ kFilterStrings[20], FilterFunction::kXbrz5x },
{ kFilterStrings[21], FilterFunction::kXbrz6x },
{ kFilterStrings[22], FilterFunction::kPlugin },
};
assert(kFilterStrings.size() == kNbFilterFunctions);
const auto iter = kStringToFilter.find(input); const auto iter = kStringToFilter.find(input);
if (iter == kStringToFilter.end()) { if (iter == kStringToFilter.end()) {
@ -676,12 +546,14 @@ int StringToFilter(const wxString& config_name, const wxString& input) {
} }
int StringToInterframe(const wxString& config_name, const wxString& input) { int StringToInterframe(const wxString& config_name, const wxString& input) {
static const std::map<wxString, Interframe> kStringToInterframe = { static std::map<wxString, Interframe> kStringToInterframe;
{ kInterframeStrings[0], Interframe::kNone }, if (kStringToInterframe.empty()) {
{ kInterframeStrings[1], Interframe::kSmart }, for (size_t i = 0; i < kNbInterframes; i++) {
{ kInterframeStrings[2], Interframe::kMotionBlur }, kStringToInterframe.emplace(
}; kInterframeStrings[i], static_cast<Interframe>(i));
}
assert(kStringToInterframe.size() == kNbInterframes); assert(kStringToInterframe.size() == kNbInterframes);
}
const auto iter = kStringToInterframe.find(input); const auto iter = kStringToInterframe.find(input);
if (iter == kStringToInterframe.end()) { if (iter == kStringToInterframe.end()) {
@ -695,16 +567,13 @@ int StringToInterframe(const wxString& config_name, const wxString& input) {
} }
int StringToRenderMethod(const wxString& config_name, const wxString& input) { int StringToRenderMethod(const wxString& config_name, const wxString& input) {
static const std::map<wxString, RenderMethod> kStringToRenderMethod = { static std::map<wxString, RenderMethod> kStringToRenderMethod;
{ kRenderMethodStrings[0], RenderMethod::kSimple }, if (kStringToRenderMethod.empty()) {
{ kRenderMethodStrings[1], RenderMethod::kOpenGL }, for (size_t i = 0; i < kNbRenderMethods; i++) {
#ifdef __WXMSW__ kStringToRenderMethod.emplace(kRenderMethodStrings[i], static_cast<RenderMethod>(i));
{ kRenderMethodStrings[2], RenderMethod::kDirect3d }, }
#elif defined(__WXMAC__)
{ kRenderMethodStrings[2], RenderMethod::kQuartz2d },
#endif
};
assert(kStringToRenderMethod.size() == kNbRenderMethods); assert(kStringToRenderMethod.size() == kNbRenderMethods);
}
const auto iter = kStringToRenderMethod.find(input); const auto iter = kStringToRenderMethod.find(input);
if (iter == kStringToRenderMethod.end()) { if (iter == kStringToRenderMethod.end()) {
@ -718,14 +587,13 @@ int StringToRenderMethod(const wxString& config_name, const wxString& input) {
} }
int StringToAudioApi(const wxString& config_name, const wxString& input) { int StringToAudioApi(const wxString& config_name, const wxString& input) {
static const std::map<wxString, AudioApi> kStringToAudioApi = { static std::map<wxString, AudioApi> kStringToAudioApi;
{ kAudioApiStrings[0], AudioApi::kSdl }, if (kStringToAudioApi.empty()) {
{ kAudioApiStrings[1], AudioApi::kOpenAL }, for (size_t i = 0; i < kNbAudioApis; i++) {
{ kAudioApiStrings[2], AudioApi::kDirectSound }, kStringToAudioApi.emplace(kAudioApiStrings[i], static_cast<AudioApi>(i));
{ kAudioApiStrings[3], AudioApi::kXAudio2 }, }
{ kAudioApiStrings[4], AudioApi::kFaudio },
};
assert(kStringToAudioApi.size() == kNbAudioApis); assert(kStringToAudioApi.size() == kNbAudioApis);
}
const auto iter = kStringToAudioApi.find(input); const auto iter = kStringToAudioApi.find(input);
if (iter == kStringToAudioApi.end()) { if (iter == kStringToAudioApi.end()) {
@ -739,13 +607,13 @@ int StringToAudioApi(const wxString& config_name, const wxString& input) {
} }
int StringToSoundQuality(const wxString& config_name, const wxString& input) { int StringToSoundQuality(const wxString& config_name, const wxString& input) {
static const std::map<wxString, SoundQuality> kStringToSoundQuality = { static std::map<wxString, SoundQuality> kStringToSoundQuality;
{ kSoundQualityStrings[0], SoundQuality::k48kHz }, if (kStringToSoundQuality.empty()) {
{ kSoundQualityStrings[1], SoundQuality::k44kHz }, for (size_t i = 0; i < kNbSoundQualities; i++) {
{ kSoundQualityStrings[2], SoundQuality::k22kHz }, kStringToSoundQuality.emplace(kSoundQualityStrings[i], static_cast<SoundQuality>(i));
{ kSoundQualityStrings[3], SoundQuality::k11kHz }, }
};
assert(kStringToSoundQuality.size() == kNbSoundQualities); assert(kStringToSoundQuality.size() == kNbSoundQualities);
}
const auto iter = kStringToSoundQuality.find(input); const auto iter = kStringToSoundQuality.find(input);
if (iter == kStringToSoundQuality.end()) { if (iter == kStringToSoundQuality.end()) {

View File

@ -318,7 +318,7 @@ void VbamOption::SetGbPalette(const wxString& value) const {
uint16_t* dest = std::get<uint16_t*>(value_); uint16_t* dest = std::get<uint16_t*>(value_);
for (size_t i = 0; i < 8; i++) { for (size_t i = 0; i < 8; i++) {
wxString number = value.substr(i * 4, 4); wxString number = value.substr(i * 5, 4);
long temp = 0; long temp = 0;
if (number.ToLong(&temp, 16)) { if (number.ToLong(&temp, 16)) {
dest[i] = temp; dest[i] = temp;

View File

@ -60,8 +60,6 @@ enum class VbamOptionID {
/// Joypad /// Joypad
kJoypad, kJoypad,
kJoypadAutofireThrottle, kJoypadAutofireThrottle,
/// Keyboard
kJoypadDefault, kJoypadDefault,
/// Keyboard /// Keyboard

View File

@ -221,8 +221,8 @@ public:
void MenuOptionIntMask(const wxString& menuName, int field, int mask); void MenuOptionIntMask(const wxString& menuName, int field, int mask);
void MenuOptionIntRadioValue(const wxString& menuName, int field, int mask); void MenuOptionIntRadioValue(const wxString& menuName, int field, int mask);
void MenuOptionBool(const wxString& menuName, bool field); void MenuOptionBool(const wxString& menuName, bool field);
void GetMenuOptionInt(const wxString& menuName, int field, int mask); void GetMenuOptionInt(const wxString& menuName, int* field, int mask);
void GetMenuOptionBool(const wxString& menuName, bool field); void GetMenuOptionBool(const wxString& menuName, bool* field);
void SetMenuOption(const wxString& menuName, int value); void SetMenuOption(const wxString& menuName, int value);
void SetJoystick(); void SetJoystick();
@ -435,6 +435,7 @@ enum showspeed {
}; };
// This enum must be kept in sync with the one in vbam-options-static.cpp. // This enum must be kept in sync with the one in vbam-options-static.cpp.
// TODO: These 2 enums should be unified and a validator created for this enum.
enum filtfunc { enum filtfunc {
// this order must match order of option enum and selector widget // this order must match order of option enum and selector widget
FF_NONE, FF_NONE,
@ -471,6 +472,7 @@ enum filtfunc {
: x == FF_PLUGIN ? 0 : x == FF_NONE ? 1 : 2) : x == FF_PLUGIN ? 0 : x == FF_NONE ? 1 : 2)
// This enum must be kept in sync with the one in vbam-options-static.cpp. // This enum must be kept in sync with the one in vbam-options-static.cpp.
// TODO: These 2 enums should be unified and a validator created for this enum.
enum ifbfunc { enum ifbfunc {
IFB_NONE, IFB_NONE,
IFB_SMART, IFB_SMART,
@ -478,19 +480,26 @@ enum ifbfunc {
}; };
// This enum must be kept in sync with the one in vbam-options-static.cpp. // This enum must be kept in sync with the one in vbam-options-static.cpp.
// TODO: These 2 enums should be unified and a validator created for this enum.
enum renderer { enum renderer {
RND_SIMPLE, RND_SIMPLE,
RND_OPENGL, RND_OPENGL,
#if defined(__WXMSW__)
RND_DIRECT3D, RND_DIRECT3D,
#elif defined(__WXMAC__)
RND_QUARTZ2D, RND_QUARTZ2D,
#endif
}; };
// This enum must be kept in sync with the one in vbam-options-static.cpp. // This enum must be kept in sync with the one in vbam-options-static.cpp.
enum audioapi { AUD_SDL, // TODO: These 2 enums should be unified and a validator created for this enum.
enum audioapi {
AUD_SDL,
AUD_OPENAL, AUD_OPENAL,
AUD_DIRECTSOUND, AUD_DIRECTSOUND,
AUD_XAUDIO2, AUD_XAUDIO2,
AUD_FAUDIO }; AUD_FAUDIO
};
// an unfortunate legacy default; should have a non-digit preceding %d // an unfortunate legacy default; should have a non-digit preceding %d
// the only reason to keep it is that user can set slotdir to old dir // the only reason to keep it is that user can set slotdir to old dir