GB: Fix sram if GBLoadSave is not called

This commit is contained in:
Jeffrey Pfau 2016-02-23 23:01:51 -08:00
parent 05ef05317c
commit 7b610da735
2 changed files with 3 additions and 2 deletions

View File

@ -102,8 +102,6 @@ bool GBLoadSave(struct GB* gb, struct VFile* vf) {
vf->truncate(vf, 0x20000);
}
gb->memory.sram = vf->map(vf, 0x20000, MAP_WRITE);
} else {
gb->memory.sram = anonymousMemoryMap(0x20000);
}
return gb->memory.sram;
}

View File

@ -108,6 +108,9 @@ void GBMemoryReset(struct GB* gb) {
GBMemorySwitchWramBank(&gb->memory, 1);
gb->memory.romBank = &gb->memory.rom[GB_SIZE_CART_BANK0];
gb->memory.currentBank = 1;
if (!gb->memory.sram) {
gb->memory.sram = anonymousMemoryMap(0x20000);
}
gb->memory.sramCurrentBank = 0;
gb->memory.sramBank = gb->memory.sram;