From 997e462a4f4b9a8e43413eefa3c45ebd4930ac35 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Tue, 30 Mar 2021 23:47:50 -0700 Subject: [PATCH] GBA e-Reader: Fix bitmap short strip scanning --- CHANGES | 1 + src/gba/ereader.c | 9 +++++++-- src/platform/qt/CoreController.cpp | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index c01f0a255..31abe963d 100644 --- a/CHANGES +++ b/CHANGES @@ -6,6 +6,7 @@ Emulation fixes: Other fixes: - GBA: Fix non-USA 1.0 FireRed misdetecting as a ROM hack (fixes mgba.io/i/2100) - GBA: Fix crash when ROM loading fails + - GBA e-Reader: Fix bitmap short strip scanning - GBA Video: Fix mode 5 frame 1 caching (fixes mgba.io/i/2075) Misc: - GBA: Default-enable VBA bug compat for Ruby and Emerald ROM hacks diff --git a/src/gba/ereader.c b/src/gba/ereader.c index c6e581eba..c50ae5a97 100644 --- a/src/gba/ereader.c +++ b/src/gba/ereader.c @@ -370,6 +370,11 @@ void GBAHardwareEReaderScan(struct GBACartridgeHardware* hw, const void* data, s // Bitmap sizes case 5456: bitmap = true; + blocks = 124; + break; + case 3520: + bitmap = true; + blocks = 80; break; default: return; @@ -380,9 +385,9 @@ void GBAHardwareEReaderScan(struct GBACartridgeHardware* hw, const void* data, s if (bitmap) { size_t x; for (i = 0; i < 40; ++i) { - const uint8_t* line = &cdata[(i + 2) * 124]; + const uint8_t* line = &cdata[(i + 2) * blocks]; uint8_t* origin = &hw->eReaderDots[EREADER_DOTCODE_STRIDE * i + 200]; - for (x = 0; x < 124; ++x) { + for (x = 0; x < blocks; ++x) { uint8_t byte = line[x]; if (x == 123) { byte &= 0xE0; diff --git a/src/platform/qt/CoreController.cpp b/src/platform/qt/CoreController.cpp index 8db5609de..81b7b3ad5 100644 --- a/src/platform/qt/CoreController.cpp +++ b/src/platform/qt/CoreController.cpp @@ -799,7 +799,7 @@ void CoreController::scanCard(const QString& path) { QFile file(path); file.open(QIODevice::ReadOnly); m_eReaderData = file.read(2912); - } else if (image.size() == QSize(989, 44)) { + } else if (image.size() == QSize(989, 44) || image.size() == QSize(639, 44)) { const uchar* bits = image.constBits(); size_t size; #if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))