GBA: Regrettably add VBA bug compat mode
Vicki Pfau vi@endrift.com
Sun, 29 Nov 2020 13:41:53 -0800
8 files changed,
31 insertions(+),
37 deletions(-)
M
CHANGES
→
CHANGES
@@ -7,6 +7,7 @@ - Game Boy Player features can be enabled by default for all compatible games
- Frame viewer support for Game Boy - Mute option in homebrew ports - Status indicators for fast-forward and mute in homebrew ports + - VBA bug compatibility mode for ROM hacks that don't work on real hardware - Read-only support for MBC6 flash memory - New unlicensed GB mappers: Pokémon Jade/Diamond, BBD, and Hitek - Stack tracing tools in ARM debugger (by ahigerd)
M
include/mgba/internal/gba/gba.h
→
include/mgba/internal/gba/gba.h
@@ -116,6 +116,7 @@ int idleDetectionFailures;
int32_t cachedRegisters[16]; bool taintedRegisters[16]; + bool vbaBugCompat; bool hardCrash; bool allowOpposingDirections;
M
include/mgba/internal/gba/overrides.h
→
include/mgba/internal/gba/overrides.h
@@ -20,6 +20,7 @@ enum SavedataType savetype;
int hardware; uint32_t idleLoop; bool mirroring; + bool vbaBugCompat; }; struct Configuration;
M
src/gba/gba.c
→
src/gba/gba.c
@@ -108,6 +108,7 @@
gba->idleOptimization = IDLE_LOOP_REMOVE; gba->idleLoop = IDLE_LOOP_NONE; + gba->vbaBugCompat = false; gba->hardCrash = true; gba->allowOpposingDirections = true;
M
src/gba/hardware.c
→
src/gba/hardware.c
@@ -99,8 +99,12 @@ return;
} switch (address) { case GPIO_REG_DATA: - hw->pinState &= ~hw->direction; - hw->pinState |= value & hw->direction; + if (!hw->p->vbaBugCompat) { + hw->pinState &= ~hw->direction; + hw->pinState |= value & hw->direction; + } else { + hw->pinState = value; + } _readPins(hw); break; case GPIO_REG_DIRECTION:
M
src/gba/overrides.c
→
src/gba/overrides.c
@@ -207,6 +207,7 @@ override->savetype = SAVEDATA_AUTODETECT;
override->hardware = HW_NONE; override->idleLoop = IDLE_LOOP_NONE; override->mirroring = false; + override->vbaBugCompat = false; bool found = false; int i;@@ -320,6 +321,8 @@ if (override->savetype != SAVEDATA_AUTODETECT) {
GBASavedataForceType(&gba->memory.savedata, override->savetype); } + gba->vbaBugCompat = override->vbaBugCompat; + if (override->hardware != HW_NO_OVERRIDE) { GBAHardwareClear(&gba->memory.hw);@@ -376,6 +379,7 @@ if (!strncmp("pokemon red version", &((const char*) gba->memory.rom)[0x108], 20) && gba->romCrc32 != 0xDD88761C) {
// Enable FLASH1M and RTC on Pokémon FireRed ROM hacks override.savetype = SAVEDATA_FLASH1M; override.hardware = HW_RTC; + override.vbaBugCompat = true; GBAOverrideApply(gba, &override); } else if (GBAOverrideFind(overrides, &override)) { GBAOverrideApply(gba, &override);
M
src/platform/qt/OverrideView.cpp
→
src/platform/qt/OverrideView.cpp
@@ -142,6 +142,7 @@ gba->override.savetype = static_cast<SavedataType>(m_ui.savetype->currentIndex() - 1);
gba->override.hardware = HW_NO_OVERRIDE; gba->override.idleLoop = IDLE_LOOP_NONE; gba->override.mirroring = false; + gba->override.vbaBugCompat = false; if (!m_ui.hwAutodetect->isChecked()) { gba->override.hardware = HW_NONE;@@ -163,6 +164,9 @@ }
} if (m_ui.hwGBPlayer->isChecked()) { gba->override.hardware |= HW_GB_PLAYER_DETECTION; + } + if (m_ui.vbaBugCompat->isChecked()) { + gba->override.vbaBugCompat = true; } bool ok;@@ -219,6 +223,7 @@ m_ui.hwLight->setChecked(gba->memory.hw.devices & HW_LIGHT_SENSOR);
m_ui.hwTilt->setChecked(gba->memory.hw.devices & HW_TILT); m_ui.hwRumble->setChecked(gba->memory.hw.devices & HW_RUMBLE); m_ui.hwGBPlayer->setChecked(gba->memory.hw.devices & HW_GB_PLAYER_DETECTION); + m_ui.vbaBugCompat->setChecked(gba->vbaBugCompat); if (gba->idleLoop != IDLE_LOOP_NONE) { m_ui.idleLoop->setText(QString::number(gba->idleLoop, 16));
M
src/platform/qt/OverrideView.ui
→
src/platform/qt/OverrideView.ui
@@ -175,41 +175,18 @@ </property>
</widget> </item> <item> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <item> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>0</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QCheckBox" name="hwGBPlayer"> - <property name="text"> - <string>Game Boy Player features</string> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer_3"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>0</height> - </size> - </property> - </spacer> - </item> - </layout> + <widget class="QCheckBox" name="hwGBPlayer"> + <property name="text"> + <string>Game Boy Player features</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="vbaBugCompat"> + <property name="text"> + <string>VBA bug compatibility mode</string> + </property> + </widget> </item> </layout> </widget>