From 2dc47e63dd204d6607de36d23d3db55f268e2692 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Thu, 15 Apr 2021 23:19:06 -0700 Subject: [PATCH] Qt: Improve handling of disabling VBA bug compat mode (fixes #2129) --- CHANGES | 1 + src/gba/core.c | 8 +++++++ src/platform/qt/GBAOverride.cpp | 7 ++++++- src/platform/qt/GBAOverride.h | 1 + src/platform/qt/OverrideView.cpp | 8 ++++--- src/platform/qt/OverrideView.ui | 6 ++++++ src/platform/qt/SettingsView.cpp | 2 ++ src/platform/qt/SettingsView.ui | 36 ++++++++++++++++++++------------ 8 files changed, 52 insertions(+), 17 deletions(-) diff --git a/CHANGES b/CHANGES index acd401c9e..593265406 100644 --- a/CHANGES +++ b/CHANGES @@ -26,6 +26,7 @@ Misc: - GBA Memory: Log GPIO writes on non-GPIO carts as Pak Hardware instead of Memory - Qt: Add ROM filename and size to bug reporter - Qt: Rearrange menus some + - Qt: Improve handling of disabling VBA bug compat mode (fixes mgba.io/i/2129) 0.9.0: (2021-03-28) Features: diff --git a/src/gba/core.c b/src/gba/core.c index 5c85aee5a..88171fbeb 100644 --- a/src/gba/core.c +++ b/src/gba/core.c @@ -300,6 +300,7 @@ static void _GBACoreLoadConfig(struct mCore* core, const struct mCoreConfig* con mCoreConfigCopyValue(&core->config, config, "gba.bios"); mCoreConfigCopyValue(&core->config, config, "gba.forceGbp"); mCoreConfigCopyValue(&core->config, config, "gba.audioHle"); + mCoreConfigCopyValue(&core->config, config, "vbaBugCompat"); #ifndef DISABLE_THREADING mCoreConfigCopyValue(&core->config, config, "threadedVideo"); @@ -610,6 +611,10 @@ static void _GBACoreReset(struct mCore* core) { if (mCoreConfigGetIntValue(&core->config, "gba.forceGbp", &fakeBool)) { forceGbp = fakeBool; } + bool vbaBugCompat = true; + if (mCoreConfigGetIntValue(&core->config, "vbaBugCompat", &fakeBool)) { + vbaBugCompat = fakeBool; + } if (!forceGbp) { gba->memory.hw.devices &= ~HW_GB_PLAYER_DETECTION; } @@ -617,6 +622,9 @@ static void _GBACoreReset(struct mCore* core) { if (forceGbp) { gba->memory.hw.devices |= HW_GB_PLAYER_DETECTION; } + if (!vbaBugCompat) { + gba->vbaBugCompat = false; + } #if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2 if (!gba->biosVf && core->opts.useBios) { diff --git a/src/platform/qt/GBAOverride.cpp b/src/platform/qt/GBAOverride.cpp index ca819e6bc..885a5d3ac 100644 --- a/src/platform/qt/GBAOverride.cpp +++ b/src/platform/qt/GBAOverride.cpp @@ -6,6 +6,7 @@ #include "GBAOverride.h" #include +#include using namespace QGBA; @@ -13,7 +14,11 @@ void GBAOverride::apply(struct mCore* core) { if (core->platform(core) != mPLATFORM_GBA) { return; } - GBAOverrideApply(static_cast(core->board), &override); + GBA* gba = static_cast(core->board); + if (!vbaBugCompatSet) { + override.vbaBugCompat = gba->vbaBugCompat; + } + GBAOverrideApply(gba, &override); } void GBAOverride::identify(const struct mCore* core) { diff --git a/src/platform/qt/GBAOverride.h b/src/platform/qt/GBAOverride.h index 2cbc6944b..8b07659fd 100644 --- a/src/platform/qt/GBAOverride.h +++ b/src/platform/qt/GBAOverride.h @@ -18,6 +18,7 @@ public: void save(struct Configuration*) const override; struct GBACartridgeOverride override; + bool vbaBugCompatSet; }; } diff --git a/src/platform/qt/OverrideView.cpp b/src/platform/qt/OverrideView.cpp index 375e2b360..ccf8a6fae 100644 --- a/src/platform/qt/OverrideView.cpp +++ b/src/platform/qt/OverrideView.cpp @@ -144,6 +144,7 @@ void OverrideView::updateOverrides() { gba->override.idleLoop = IDLE_LOOP_NONE; gba->override.mirroring = false; gba->override.vbaBugCompat = false; + gba->vbaBugCompatSet = false; if (!m_ui.hwAutodetect->isChecked()) { hasOverride = true; @@ -168,9 +169,10 @@ void OverrideView::updateOverrides() { hasOverride = true; gba->override.hardware |= HW_GB_PLAYER_DETECTION; } - if (m_ui.vbaBugCompat->isChecked()) { + if (m_ui.vbaBugCompat->checkState() != Qt::PartiallyChecked) { hasOverride = true; - gba->override.vbaBugCompat = true; + gba->vbaBugCompatSet = true; + gba->override.vbaBugCompat = m_ui.vbaBugCompat->isChecked(); } bool ok; @@ -270,7 +272,7 @@ void OverrideView::gameStopped() { m_ui.tabWidget->setEnabled(true); m_ui.savetype->setCurrentIndex(0); m_ui.idleLoop->clear(); - m_ui.vbaBugCompat->setChecked(false); + m_ui.vbaBugCompat->setCheckState(Qt::PartiallyChecked); m_ui.mbc->setCurrentIndex(0); m_ui.gbModel->setCurrentIndex(0); diff --git a/src/platform/qt/OverrideView.ui b/src/platform/qt/OverrideView.ui index d34d0aa22..a1eb8a1d0 100644 --- a/src/platform/qt/OverrideView.ui +++ b/src/platform/qt/OverrideView.ui @@ -186,6 +186,12 @@ VBA bug compatibility mode + + true + + + Qt::PartiallyChecked + diff --git a/src/platform/qt/SettingsView.cpp b/src/platform/qt/SettingsView.cpp index be100fc07..579f11a30 100644 --- a/src/platform/qt/SettingsView.cpp +++ b/src/platform/qt/SettingsView.cpp @@ -429,6 +429,7 @@ void SettingsView::updateConfig() { saveSetting("dynamicTitle", m_ui.dynamicTitle); saveSetting("videoScale", m_ui.videoScale); saveSetting("gba.forceGbp", m_ui.forceGbp); + saveSetting("vbaBugCompat", m_ui.vbaBugCompat); if (m_ui.audioBufferSize->currentText().toInt() > 8192) { m_ui.audioBufferSize->setCurrentText("8192"); @@ -622,6 +623,7 @@ void SettingsView::reloadConfig() { loadSetting("gba.audioHle", m_ui.audioHle); loadSetting("dynamicTitle", m_ui.dynamicTitle, true); loadSetting("gba.forceGbp", m_ui.forceGbp); + loadSetting("vbaBugCompat", m_ui.vbaBugCompat, true); m_ui.libraryStyle->setCurrentIndex(loadSetting("libraryStyle").toInt()); diff --git a/src/platform/qt/SettingsView.ui b/src/platform/qt/SettingsView.ui index 750eec352..5e8be4fbc 100644 --- a/src/platform/qt/SettingsView.ui +++ b/src/platform/qt/SettingsView.ui @@ -873,21 +873,28 @@ - + + + + Enable Game Boy Player features by default + + + + Qt::Horizontal - + Save state extra data: - + Screenshot @@ -897,7 +904,7 @@ - + Save game @@ -907,7 +914,7 @@ - + Cheat codes @@ -917,21 +924,21 @@ - + Qt::Horizontal - + Load state extra data: - + Screenshot @@ -941,24 +948,27 @@ - + Save game - + Cheat codes - - + + - Enable Game Boy Player features by default + Enable VBA bug compatibility in ROM hacks + + + true