mirror of https://github.com/mgba-emu/mgba.git
GB, GBA: Clean up some corner cases with ROM fd closing
This commit is contained in:
parent
7e474db93a
commit
eaf45b9ab8
|
@ -483,12 +483,10 @@ void GBApplyPatch(struct GB* gb, struct Patch* patch) {
|
|||
mappedMemoryFree(newRom, GB_SIZE_CART_MAX);
|
||||
return;
|
||||
}
|
||||
if (gb->romVf) {
|
||||
if (gb->romVf && gb->isPristine) {
|
||||
#ifndef FIXED_ROM_BUFFER
|
||||
gb->romVf->unmap(gb->romVf, gb->memory.rom, gb->pristineRomSize);
|
||||
#endif
|
||||
gb->romVf->close(gb->romVf);
|
||||
gb->romVf = NULL;
|
||||
}
|
||||
gb->isPristine = false;
|
||||
if (gb->memory.romBase == gb->memory.rom) {
|
||||
|
|
|
@ -1017,8 +1017,6 @@ void _pristineCow(struct GB* gb) {
|
|||
}
|
||||
if (gb->romVf) {
|
||||
gb->romVf->unmap(gb->romVf, gb->memory.rom, gb->memory.romSize);
|
||||
gb->romVf->close(gb->romVf);
|
||||
gb->romVf = NULL;
|
||||
}
|
||||
gb->memory.rom = newRom;
|
||||
GBMBCSwitchBank(gb, gb->memory.currentBank);
|
||||
|
|
|
@ -668,6 +668,9 @@ static size_t _GBACoreROMSize(const struct mCore* core) {
|
|||
if (gba->romVf) {
|
||||
return gba->romVf->size(gba->romVf);
|
||||
}
|
||||
if (gba->mbVf) {
|
||||
return gba->mbVf->size(gba->mbVf);
|
||||
}
|
||||
return gba->pristineRomSize;
|
||||
}
|
||||
|
||||
|
|
|
@ -557,16 +557,14 @@ void GBAApplyPatch(struct GBA* gba, struct Patch* patch) {
|
|||
mappedMemoryFree(newRom, GBA_SIZE_ROM0);
|
||||
return;
|
||||
}
|
||||
if (gba->romVf) {
|
||||
if (gba->memory.rom) {
|
||||
#ifndef FIXED_ROM_BUFFER
|
||||
if (!gba->isPristine) {
|
||||
mappedMemoryFree(gba->memory.rom, GBA_SIZE_ROM0);
|
||||
mappedMemoryFree(gba->memory.rom, gba->memory.romSize);
|
||||
} else {
|
||||
gba->romVf->unmap(gba->romVf, gba->memory.rom, gba->pristineRomSize);
|
||||
}
|
||||
#endif
|
||||
gba->romVf->close(gba->romVf);
|
||||
gba->romVf = NULL;
|
||||
}
|
||||
gba->isPristine = false;
|
||||
gba->memory.rom = newRom;
|
||||
|
|
|
@ -1894,8 +1894,6 @@ void _pristineCow(struct GBA* gba) {
|
|||
}
|
||||
if (gba->romVf) {
|
||||
gba->romVf->unmap(gba->romVf, gba->memory.rom, gba->memory.romSize);
|
||||
gba->romVf->close(gba->romVf);
|
||||
gba->romVf = NULL;
|
||||
}
|
||||
gba->memory.rom = newRom;
|
||||
gba->memory.hw.gpioBase = &((uint16_t*) gba->memory.rom)[GPIO_REG_DATA >> 1];
|
||||
|
|
Loading…
Reference in New Issue