From 600080ba0c3286dc7d3cf5e3dce65afe344674d9 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Wed, 7 Jan 2015 21:43:21 -0800 Subject: [PATCH] GBA BIOS: Implement Diff8bitUnFilterVram --- CHANGES | 2 +- src/gba/gba-bios.c | 28 +++++++++++++++++----------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/CHANGES b/CHANGES index e39dc2171..57080449d 100644 --- a/CHANGES +++ b/CHANGES @@ -14,7 +14,7 @@ Features: - Support for games using the tilt sensor - Remappable shortcuts for keyboard and gamepad - Rewinding of emulation - - Implemented BIOS routines Diff8bitUnFilterWram, and Diff16bitUnFilter + - Implemented BIOS routines Diff8bitUnFilterWram, Diff8bitUnFilterVram, and Diff16bitUnFilter Bugfixes: - Qt: Fix issue with set frame sizes being the wrong height - Qt: Fix emulator crashing when full screen if a game is not running diff --git a/src/gba/gba-bios.c b/src/gba/gba-bios.c index 765fb8105..5f3ad806d 100644 --- a/src/gba/gba-bios.c +++ b/src/gba/gba-bios.c @@ -477,26 +477,32 @@ static void _unFilter(struct GBA* gba, int inwidth, int outwidth) { uint16_t old = 0; source += 4; while (remaining > 0) { + uint16_t new; if (inwidth == 1) { - halfword = cpu->memory.loadU8(cpu, source, 0); + new = cpu->memory.loadU8(cpu, source, 0); } else { - halfword = cpu->memory.loadU16(cpu, source, 0); + new = cpu->memory.loadU16(cpu, source, 0); } - halfword += old; + new += old; if (outwidth > inwidth) { - GBALog(gba, GBA_LOG_STUB, "Unimplemented Diff8bitUnFilterVram"); - } else { - if (outwidth == 1) { - halfword &= 0xFF; - cpu->memory.store8(cpu, dest, halfword, 0); - } else { + halfword >>= 8; + halfword |= (new << 8); + if (source & 1) { cpu->memory.store16(cpu, dest, halfword, 0); + dest += outwidth; + remaining -= outwidth; } - old = halfword; + } else if (outwidth == 1) { + cpu->memory.store8(cpu, dest, new, 0); dest += outwidth; + remaining -= outwidth; + } else { + cpu->memory.store16(cpu, dest, new, 0); + dest += outwidth; + remaining -= outwidth; } + old = new; source += inwidth; - remaining -= outwidth; } cpu->gprs[0] = source; cpu->gprs[1] = dest;