all repos — mgba @ 836051ee32a58a7190331bf4da0767459d00cc75

mGBA Game Boy Advance Emulator

GB, GBA: Clean up ROM unloading
Jeffrey Pfau jeffrey@endrift.com
Mon, 19 Sep 2016 07:17:49 -0700
commit

836051ee32a58a7190331bf4da0767459d00cc75

parent

d97d2b9565d6939bd340cb4c76b01d7a1dc04766

2 files changed, 6 insertions(+), 5 deletions(-)

jump to
M src/gb/gb.csrc/gb/gb.c

@@ -232,14 +232,15 @@ }

void GBUnloadROM(struct GB* gb) { // TODO: Share with GBAUnloadROM - if (gb->memory.rom && gb->memory.romBase != gb->memory.rom) { - free(gb->memory.romBase); - } if (gb->memory.rom && gb->pristineRom != gb->memory.rom) { if (gb->yankedRomSize) { gb->yankedRomSize = 0; } mappedMemoryFree(gb->memory.rom, GB_SIZE_CART_MAX); + gb->memory.rom = gb->pristineRom; + } + if (gb->memory.rom && gb->memory.romBase != gb->memory.rom) { + free(gb->memory.romBase); } gb->memory.rom = 0;

@@ -248,9 +249,9 @@ #ifndef _3DS

gb->romVf->unmap(gb->romVf, gb->pristineRom, gb->pristineRomSize); #endif gb->romVf->close(gb->romVf); - gb->pristineRom = 0; gb->romVf = 0; } + gb->pristineRom = 0; struct VFile* vf = gb->sramVf; GBSramDeinit(gb);
M src/gba/gba.csrc/gba/gba.c

@@ -127,9 +127,9 @@ #ifndef _3DS

gba->romVf->unmap(gba->romVf, gba->pristineRom, gba->pristineRomSize); #endif gba->romVf->close(gba->romVf); - gba->pristineRom = 0; gba->romVf = 0; } + gba->pristineRom = 0; GBASavedataDeinit(&gba->memory.savedata); if (gba->memory.savedata.realVf) {