GB: Make sure save files are large enough

This commit is contained in:
Jeffrey Pfau 2016-01-25 22:20:18 -08:00
parent 61e7cc9556
commit 5d7a43639b
1 changed files with 3 additions and 0 deletions

View File

@ -77,6 +77,9 @@ bool GBLoadROM(struct GB* gb, struct VFile* vf, struct VFile* sav, const char* f
gb->romCrc32 = doCrc32(gb->memory.rom, gb->memory.romSize);
gb->sramVf = sav;
if (sav) {
if (sav->size(sav) < 0x8000) {
sav->truncate(sav, 0x8000);
}
gb->memory.sram = sav->map(sav, 0x8000, MAP_WRITE);
} else {
gb->memory.sram = anonymousMemoryMap(0x8000);