Prevent creating .sav files for ROMs claiming they have a battery but have no cartridge RAM or RTC

This commit is contained in:
Lior Halphon 2016-04-16 14:09:56 +03:00
parent 7dc575d01e
commit 0fa2d6ea2f
1 changed files with 1 additions and 0 deletions

View File

@ -341,6 +341,7 @@ int gb_load_state(GB_gameboy_t *gb, const char *path)
int gb_save_battery(GB_gameboy_t *gb, const char *path)
{
if (!gb->cartridge_type->has_battery) return 0; // Nothing to save.
if (gb->mbc_ram_size == 0 && !gb->cartridge_type->has_rtc) return 0; /* Claims to have battery, but has no RAM or RTC */
FILE *f = fopen(path, "w");
if (!f) {
return errno;