all repos — mgba @ 97291824a55ee6b701179d24daf39f0d41950710

mGBA Game Boy Advance Emulator

GBA BIOS: Fix LZ77UnCompVram to use 16-bit loads from decompressed memory
Jeffrey Pfau jeffrey@endrift.com
Sat, 10 Jan 2015 20:30:32 -0800
commit

97291824a55ee6b701179d24daf39f0d41950710

parent

293831e3bf85da749dea26ab0382cd8c866d5a41

2 files changed, 10 insertions(+), 7 deletions(-)

jump to
M CHANGESCHANGES

@@ -47,6 +47,7 @@ - Qt: Fix a race condition when a game crashes immediately

- Qt: Fix some cases where key mapping can break if focus is adjusted - GBA Memory: Filter out top nybble of DMA addresses - Debugger: Fix binary print putting spaces between digits + - GBA BIOS: Fix LZ77UnCompVram to use 16-bit loads from decompressed memory Misc: - Qt: Disable sync to video by default - GBA: Exit cleanly on FATAL if the port supports it
M src/gba/gba-bios.csrc/gba/gba-bios.c

@@ -312,7 +312,6 @@ // We assume the signature byte (0x10) is correct

int blockheader = 0; // Some compilers warn if this isn't set, even though it's trivially provably always set source += 4; int blocksRemaining = 0; - int block; uint32_t disp; int bytes; int byte;

@@ -321,24 +320,27 @@ while (remaining > 0) {

if (blocksRemaining) { if (blockheader & 0x80) { // Compressed - block = cpu->memory.load8(cpu, source, 0) | (cpu->memory.load8(cpu, source + 1, 0) << 8); + int block = cpu->memory.load8(cpu, source + 1, 0) | (cpu->memory.load8(cpu, source, 0) << 8); source += 2; - disp = dest - (((block & 0x000F) << 8) | ((block & 0xFF00) >> 8)) - 1; - bytes = ((block & 0x00F0) >> 4) + 3; + disp = dest - (block & 0x0FFF) - 1; + bytes = (block >> 12) + 3; while (bytes-- && remaining) { --remaining; - byte = cpu->memory.load8(cpu, disp, 0); - ++disp; if (width == 2) { + byte = cpu->memory.load16(cpu, disp & ~1, 0); if (dest & 1) { + byte >>= (disp & 1) * 8; halfword |= byte << 8; cpu->memory.store16(cpu, dest ^ 1, halfword, 0); } else { - halfword = byte; + byte >>= (disp & 1) * 8; + halfword = byte & 0xFF; } } else { + byte = cpu->memory.load8(cpu, disp, 0); cpu->memory.store8(cpu, dest, byte, 0); } + ++disp; ++dest; } } else {