all repos — mgba @ 459d1338554b0bc3d411c72979cc363248cf0b99

mGBA Game Boy Advance Emulator

GBA Memory: Don't reallocate RAM every reset
Vicki Pfau vi@endrift.com
Thu, 28 Dec 2017 14:17:53 -0500
commit

459d1338554b0bc3d411c72979cc363248cf0b99

parent

821c8988a385025f2f5c741d279ea0e745f47c0c

2 files changed, 7 insertions(+), 8 deletions(-)

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

@@ -300,7 +300,6 @@ bool GBALoadNull(struct GBA* gba) {

GBAUnloadROM(gba); gba->romVf = NULL; gba->pristineRomSize = 0; - gba->memory.wram = anonymousMemoryMap(SIZE_WORKING_RAM); #ifndef FIXED_ROM_BUFFER gba->memory.rom = anonymousMemoryMap(SIZE_CART0); #else

@@ -328,7 +327,6 @@ if (gba->pristineRomSize > SIZE_WORKING_RAM) {

gba->pristineRomSize = SIZE_WORKING_RAM; } gba->isPristine = true; - gba->memory.wram = anonymousMemoryMap(SIZE_WORKING_RAM); memset(gba->memory.wram, 0, SIZE_WORKING_RAM); vf->read(vf, gba->memory.wram, gba->pristineRomSize); if (!gba->memory.wram) {
M src/gba/memory.csrc/gba/memory.c

@@ -81,6 +81,7 @@ gba->memory.biosPrefetch = 0;

gba->memory.mirroring = false; gba->memory.iwram = anonymousMemoryMap(SIZE_WORKING_IRAM); + gba->memory.wram = anonymousMemoryMap(SIZE_WORKING_RAM); GBADMAInit(gba); GBAVFameInit(&gba->memory.vfame);

@@ -98,15 +99,15 @@ GBASavedataDeinit(&gba->memory.savedata);

if (gba->memory.savedata.realVf) { gba->memory.savedata.realVf->close(gba->memory.savedata.realVf); } + + if (gba->memory.agbPrintBuffer) { + mappedMemoryFree(gba->memory.agbPrintBuffer, SIZE_AGB_PRINT); + } } void GBAMemoryReset(struct GBA* gba) { - if (gba->memory.rom || gba->memory.fullBios || !gba->memory.wram) { - // Not multiboot - if (gba->memory.wram) { - mappedMemoryFree(gba->memory.wram, SIZE_WORKING_RAM); - } - gba->memory.wram = anonymousMemoryMap(SIZE_WORKING_RAM); + if (gba->memory.wram && gba->memory.rom) { + memset(gba->memory.wram, 0, SIZE_WORKING_RAM); } if (gba->memory.iwram) {