GBA Memory: Only copy-on-write if ROM buffer is not fixed

This commit is contained in:
Vicki Pfau 2018-01-25 19:48:05 -08:00
parent d133cabd33
commit adcb2de814
1 changed files with 2 additions and 2 deletions

View File

@ -1629,6 +1629,7 @@ void _pristineCow(struct GBA* gba) {
if (!gba->isPristine) {
return;
}
#ifndef FIXED_ROM_BUFFER
void* newRom = anonymousMemoryMap(SIZE_CART0);
memcpy(newRom, gba->memory.rom, gba->memory.romSize);
memset(((uint8_t*) newRom) + gba->memory.romSize, 0xFF, SIZE_CART0 - gba->memory.romSize);
@ -1636,14 +1637,13 @@ void _pristineCow(struct GBA* gba) {
gba->cpu->memory.activeRegion = newRom;
}
if (gba->romVf) {
#ifndef FIXED_ROM_BUFFER
gba->romVf->unmap(gba->romVf, gba->memory.rom, gba->memory.romSize);
#endif
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];
#endif
gba->isPristine = false;
}