diff --git a/CHANGES b/CHANGES index 63cea3797..be0ef5678 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,8 @@ Bugfixes: - Switch: Fix final cleanup (fixes mgba.io/i/1283) - Qt: Fix tile and sprite views not always displaying at first + - GBA Memory: Fix a few AGBPrint crashes + - GBA Memory: Fix OOB ROM reads showing up as AGBPrint memory Misc: - GBA Video: Improve sprite cycle counting (fixes mgba.io/i/1274) diff --git a/src/gba/memory.c b/src/gba/memory.c index 53fd57304..c779853b5 100644 --- a/src/gba/memory.c +++ b/src/gba/memory.c @@ -1647,6 +1647,10 @@ void _pristineCow(struct GBA* gba) { } void GBAPrintFlush(struct GBA* gba) { + if (!gba->memory.agbPrintBuffer) { + return; + } + char oolBuf[0x101]; size_t i; for (i = 0; gba->memory.agbPrintCtx.get != gba->memory.agbPrintCtx.put && i < 0x100; ++i) { @@ -1688,8 +1692,8 @@ static void _agbPrintStore(struct GBA* gba, uint32_t address, int16_t value) { static int16_t _agbPrintLoad(struct GBA* gba, uint32_t address) { struct GBAMemory* memory = &gba->memory; - int16_t value = 0xFFFF; - if (address < AGB_PRINT_TOP) { + int16_t value = address >> 1; + if (address < AGB_PRINT_TOP && memory->agbPrintBuffer) { LOAD_16(value, address & (SIZE_AGB_PRINT - 1), memory->agbPrintBuffer); } else if ((address & 0x00FFFFF8) == (AGB_PRINT_STRUCT & 0x00FFFFF8)) { value = (&memory->agbPrintCtx.request)[(address & 7) >> 1];