From 99b66e13268495f309d2e247945f2ddce5f8685d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ed=C3=AAnis=20Freindorfer=20Azevedo?= Date: Mon, 17 Feb 2020 01:58:32 -0300 Subject: [PATCH] Expose LCD filter for GBA and GB color saturation. We offer a way to control the color saturation for GBA games such as Fire Emblem Tactics Advance. It will be enabled by default for GBA games and disabled for GB. The user will be able to toggle both of them and these options will be persistent by saving to `vbam.ini`. - Fix #131. --- src/common/ConfigManager.cpp | 2 ++ src/common/ConfigManager.h | 2 ++ src/wx/cmdevents.cpp | 20 ++++++++++++++++++++ src/wx/opts.cpp | 3 +++ src/wx/panel.cpp | 6 ++++-- src/wx/xrc/MainMenu.xrc | 12 ++++++++++++ 6 files changed, 43 insertions(+), 2 deletions(-) diff --git a/src/common/ConfigManager.cpp b/src/common/ConfigManager.cpp index 322ba952..251f0fb2 100644 --- a/src/common/ConfigManager.cpp +++ b/src/common/ConfigManager.cpp @@ -133,6 +133,8 @@ bool mirroringEnable = true; bool parseDebug = true; bool speedHack = false; bool speedup = false; +bool gbaLcdFilter = true; +bool gbLcdFilter = false; const char* aviRecordDir; const char* batteryDir; const char* biosFileNameGB; diff --git a/src/common/ConfigManager.h b/src/common/ConfigManager.h index d7fbe81d..0b7e5974 100644 --- a/src/common/ConfigManager.h +++ b/src/common/ConfigManager.h @@ -25,6 +25,8 @@ extern bool mirroringEnable; extern bool parseDebug; extern bool speedHack; extern bool speedup; +extern bool gbaLcdFilter; +extern bool gbLcdFilter; extern char *rewindMemory; extern const char *aviRecordDir; extern const char *biosFileNameGB; diff --git a/src/wx/cmdevents.cpp b/src/wx/cmdevents.cpp index b99a7c5c..d3efceb5 100644 --- a/src/wx/cmdevents.cpp +++ b/src/wx/cmdevents.cpp @@ -2883,6 +2883,26 @@ EVT_HANDLER(AGBPrinter, "Enable AGB printer") update_opts(); } +EVT_HANDLER(GBALcdFilter, "Enable LCD filter") +{ + GetMenuOptionBool("GBALcdFilter", gbaLcdFilter); + utilUpdateSystemColorMaps(gbaLcdFilter); + update_opts(); +} + +EVT_HANDLER(GBLcdFilter, "Enable LCD filter") +{ + GetMenuOptionBool("GBLcdFilter", gbLcdFilter); + utilUpdateSystemColorMaps(gbLcdFilter); + update_opts(); +} + +EVT_HANDLER(GBColorOption, "Enable GB color option") +{ + GetMenuOptionInt("GBColorOption", gbColorOption, 1); + update_opts(); +} + EVT_HANDLER(ApplyPatches, "Apply IPS/UPS/IPF patches if found") { GetMenuOptionInt("ApplyPatches", autoPatch, 1); diff --git a/src/wx/opts.cpp b/src/wx/opts.cpp index 9e770c9b..f9155814 100644 --- a/src/wx/opts.cpp +++ b/src/wx/opts.cpp @@ -208,6 +208,8 @@ opt_desc opts[] = { /// GB STROPT("GB/BiosFile", "", wxTRANSLATE("BIOS file to use for GB, if enabled"), gopts.gb_bios), + INTOPT("GB/ColorOption", "GBColorOption", wxTRANSLATE("GB color enhancement, if enabled"), gbColorOption, 0, 1), + BOOLOPT("GB/LCDFilter", "GBLcdFilter", wxTRANSLATE("Apply LCD filter, if enabled"), gbLcdFilter), STROPT("GB/GBCBiosFile", "", wxTRANSLATE("BIOS file to use for GBC, if enabled"), gopts.gbc_bios), NOOPT(wxT("GB/Palette0"), "", wxTRANSLATE("The default palette, as 8 comma-separated 4-digit hex integers (rgb555).")), NOOPT(wxT("GB/Palette1"), "", wxTRANSLATE("The first user palette, as 8 comma-separated 4-digit hex integers (rgb555).")), @@ -219,6 +221,7 @@ opt_desc opts[] = { /// GBA STROPT("GBA/BiosFile", "", wxTRANSLATE("BIOS file to use, if enabled"), gopts.gba_bios), + BOOLOPT("GBA/LCDFilter", "GBALcdFilter", wxTRANSLATE("Apply LCD filter, if enabled"), gbaLcdFilter), #ifndef NO_LINK BOOLOPT("GBA/LinkAuto", "LinkAuto", wxTRANSLATE("Enable link at boot"), gopts.link_auto), INTOPT("GBA/LinkFast", "SpeedOn", wxTRANSLATE("Enable faster network protocol by default"), linkHacks, 0, 1), diff --git a/src/wx/panel.cpp b/src/wx/panel.cpp index 037f610a..92fd377e 100644 --- a/src/wx/panel.cpp +++ b/src/wx/panel.cpp @@ -1082,6 +1082,9 @@ void GameArea::OnIdle(wxIdleEvent& event) mf->PollJoysticks(); + if (loaded == IMAGE_GBA) utilUpdateSystemColorMaps(gbaLcdFilter); + else if (loaded == IMAGE_GB) utilUpdateSystemColorMaps(gbLcdFilter); + if (!paused) { HidePointer(); event.RequestMore(); @@ -1469,8 +1472,7 @@ DrawingPanelBase::DrawingPanelBase(int _width, int _height) RGB_LOW_BITS_MASK = 0x0421; } - // FIXME: should be "true" for GBA carts if lcd mode selected - // which means this needs to be re-run at pref change time + // needs to be run once before the first draw utilUpdateSystemColorMaps(false); } diff --git a/src/wx/xrc/MainMenu.xrc b/src/wx/xrc/MainMenu.xrc index 9aeadd6c..92e20416 100644 --- a/src/wx/xrc/MainMenu.xrc +++ b/src/wx/xrc/MainMenu.xrc @@ -508,6 +508,10 @@ 1 + + + 1 + @@ -515,6 +519,14 @@ + + + 1 + + + + 1 + 1