mirror of https://github.com/mgba-emu/mgba.git
GBA Memory: Don't reallocate RAM every reset
This commit is contained in:
parent
821c8988a3
commit
459d133855
|
@ -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 @@ bool GBALoadMB(struct GBA* gba, struct VFile* vf) {
|
|||
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) {
|
||||
|
|
|
@ -81,6 +81,7 @@ void GBAMemoryInit(struct GBA* gba) {
|
|||
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 @@ void GBAMemoryDeinit(struct GBA* gba) {
|
|||
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) {
|
||||
|
|
Loading…
Reference in New Issue