GB, GBA: Clean up ROM unloading

This commit is contained in:
Jeffrey Pfau 2016-09-19 07:17:49 -07:00
parent d97d2b9565
commit 836051ee32
2 changed files with 6 additions and 5 deletions

View File

@ -232,14 +232,15 @@ void GBSavedataUnmask(struct GB* gb) {
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 @@ void GBUnloadROM(struct GB* gb) {
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);

View File

@ -127,9 +127,9 @@ void GBAUnloadROM(struct GBA* gba) {
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) {