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:
parent
c650337928
commit
144d0348dd
@ -302,7 +302,7 @@ int GB_load_state(GB_gameboy_t *gb, const char *path)
|
|||||||
goto error;
|
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");
|
GB_log(gb, "Save state has non-matching MBC RAM size.\n");
|
||||||
errno = -1;
|
errno = -1;
|
||||||
goto error;
|
goto error;
|
||||||
@ -320,7 +320,8 @@ int GB_load_state(GB_gameboy_t *gb, const char *path)
|
|||||||
goto error;
|
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);
|
fclose(f);
|
||||||
return EIO;
|
return EIO;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user