From 7f91cfe58d70453de76c2eb25897d7f0a5a6fec1 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Fri, 1 Jul 2022 23:37:50 -0700 Subject: [PATCH] GBA: Fix some ROM buffer handling issues with oddly sized files --- src/gba/gba.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gba/gba.c b/src/gba/gba.c index cee833c5b..1c0de38e4 100644 --- a/src/gba/gba.c +++ b/src/gba/gba.c @@ -399,14 +399,15 @@ bool GBALoadROM(struct GBA* gba, struct VFile* vf) { } GBAUnloadROM(gba); gba->romVf = vf; + gba->isPristine = true; gba->pristineRomSize = vf->size(vf); vf->seek(vf, 0, SEEK_SET); if (gba->pristineRomSize > SIZE_CART0) { - gba->isPristine = false; char ident; vf->seek(vf, 0xAC, SEEK_SET); vf->read(vf, &ident, 1); if (ident == 'M') { + gba->isPristine = false; gba->memory.romSize = 0x01000000; #ifdef FIXED_ROM_BUFFER gba->memory.rom = romBuffer; @@ -417,8 +418,8 @@ bool GBALoadROM(struct GBA* gba, struct VFile* vf) { gba->memory.rom = vf->map(vf, SIZE_CART0, MAP_READ); gba->memory.romSize = SIZE_CART0; } + gba->pristineRomSize = SIZE_CART0; } else { - gba->isPristine = true; gba->memory.rom = vf->map(vf, gba->pristineRomSize, MAP_READ); gba->memory.romSize = gba->pristineRomSize; }