Loading a save state creating during the effect of the previous MBC RAM bug will now attempt to fix the (broken) save state.

This commit is contained in:
Lior Halphon 2017-06-08 23:26:04 +03:00
parent c650337928
commit 144d0348dd
1 changed files with 3 additions and 2 deletions

View File

@ -302,7 +302,7 @@ int GB_load_state(GB_gameboy_t *gb, const char *path)
goto error;
}
if (gb->mbc_ram_size != save.mbc_ram_size) {
if (gb->mbc_ram_size < save.mbc_ram_size) {
GB_log(gb, "Save state has non-matching MBC RAM size.\n");
errno = -1;
goto error;
@ -320,7 +320,8 @@ int GB_load_state(GB_gameboy_t *gb, const char *path)
goto error;
}
if (fread(gb->mbc_ram, 1, gb->mbc_ram_size, f) != gb->mbc_ram_size) {
memset(gb->mbc_ram + save.mbc_ram_size, 0xFF, gb->mbc_ram_size - save.mbc_ram_size);
if (fread(gb->mbc_ram, 1, save.mbc_ram_size, f) != save.mbc_ram_size) {
fclose(f);
return EIO;
}