From f6b88660d248f643319ae430b4ecda7c3e3dcbbe Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Sun, 4 Nov 2018 15:54:00 -0800 Subject: [PATCH] GBA: Reset now reloads multiboot ROMs --- CHANGES | 1 + src/gba/gba.c | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/CHANGES b/CHANGES index f9e151f54..5b6203f48 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,7 @@ 0.8.0: (Future) Bugfixes: - GBA: All IRQs have 7 cycle delay (fixes mgba.io/i/539, mgba.io/i/1208) + - GBA: Reset now reloads multiboot ROMs Misc: - GBA Savedata: EEPROM performance fixes - GBA Savedata: Automatically map 1Mbit Flash files as 1Mbit Flash diff --git a/src/gba/gba.c b/src/gba/gba.c index d68a03c2e..7cb3faafe 100644 --- a/src/gba/gba.c +++ b/src/gba/gba.c @@ -216,6 +216,20 @@ void GBAReset(struct ARMCore* cpu) { GBASIOReset(&gba->sio); + bool isELF = false; +#ifdef USE_ELF + struct ELF* elf = ELFOpen(gba->romVf); + if (elf) { + isELF = true; + ELFClose(elf); + } +#endif + + if (GBAIsMB(gba->romVf) && !isELF) { + gba->romVf->seek(gba->romVf, 0, SEEK_SET); + gba->romVf->read(gba->romVf, gba->memory.wram, gba->pristineRomSize); + } + gba->lastJump = 0; gba->haltPending = false; gba->idleDetectionStep = 0; @@ -343,11 +357,6 @@ bool GBALoadMB(struct GBA* gba, struct VFile* vf) { } gba->isPristine = true; memset(gba->memory.wram, 0, SIZE_WORKING_RAM); - vf->read(vf, gba->memory.wram, gba->pristineRomSize); - if (!gba->memory.wram) { - mLOG(GBA, WARN, "Couldn't map ROM"); - return false; - } gba->yankedRomSize = 0; gba->memory.romSize = 0; gba->memory.romMask = 0;