GBA BIOS: Fix LZ77UnCompVram to use 16-bit loads from decompressed memory

This commit is contained in:
Jeffrey Pfau 2015-01-10 20:30:32 -08:00
parent 293831e3bf
commit 97291824a5
2 changed files with 10 additions and 7 deletions

View File

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

View File

@ -312,7 +312,6 @@ static void _unLz77(struct GBA* gba, int width) {
int blockheader = 0; // Some compilers warn if this isn't set, even though it's trivially provably always set int blockheader = 0; // Some compilers warn if this isn't set, even though it's trivially provably always set
source += 4; source += 4;
int blocksRemaining = 0; int blocksRemaining = 0;
int block;
uint32_t disp; uint32_t disp;
int bytes; int bytes;
int byte; int byte;
@ -321,24 +320,27 @@ static void _unLz77(struct GBA* gba, int width) {
if (blocksRemaining) { if (blocksRemaining) {
if (blockheader & 0x80) { if (blockheader & 0x80) {
// Compressed // 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; source += 2;
disp = dest - (((block & 0x000F) << 8) | ((block & 0xFF00) >> 8)) - 1; disp = dest - (block & 0x0FFF) - 1;
bytes = ((block & 0x00F0) >> 4) + 3; bytes = (block >> 12) + 3;
while (bytes-- && remaining) { while (bytes-- && remaining) {
--remaining; --remaining;
byte = cpu->memory.load8(cpu, disp, 0);
++disp;
if (width == 2) { if (width == 2) {
byte = cpu->memory.load16(cpu, disp & ~1, 0);
if (dest & 1) { if (dest & 1) {
byte >>= (disp & 1) * 8;
halfword |= byte << 8; halfword |= byte << 8;
cpu->memory.store16(cpu, dest ^ 1, halfword, 0); cpu->memory.store16(cpu, dest ^ 1, halfword, 0);
} else { } else {
halfword = byte; byte >>= (disp & 1) * 8;
halfword = byte & 0xFF;
} }
} else { } else {
byte = cpu->memory.load8(cpu, disp, 0);
cpu->memory.store8(cpu, dest, byte, 0); cpu->memory.store8(cpu, dest, byte, 0);
} }
++disp;
++dest; ++dest;
} }
} else { } else {