GB Core: Fix extracting SRAM when none is present

This commit is contained in:
Vicki Pfau 2020-06-18 01:25:48 -07:00
parent 0234cb07b8
commit 853cdf2880
2 changed files with 9 additions and 3 deletions

View File

@ -3,6 +3,8 @@ Emulation fixes:
- GB Memory: Fix OAM DMA from top 8 kB
- GB MBC: Fix MBC1 RAM enable bit selection
- GB MBC: Fix MBC2 bit selection
Other fixes:
- GB Core: Fix extracting SRAM when none is present
0.8.2: (2020-06-14)
Emulation fixes:

View File

@ -822,9 +822,13 @@ static size_t _GBCoreSavedataClone(struct mCore* core, void** sram) {
vf->seek(vf, 0, SEEK_SET);
return vf->read(vf, *sram, vf->size(vf));
}
*sram = malloc(gb->sramSize);
memcpy(*sram, gb->memory.sram, gb->sramSize);
return gb->sramSize;
if (gb->sramSize) {
*sram = malloc(gb->sramSize);
memcpy(*sram, gb->memory.sram, gb->sramSize);
return gb->sramSize;
}
*sram = NULL;
return 0;
}
static bool _GBCoreSavedataRestore(struct mCore* core, const void* sram, size_t size, bool writeback) {