Mercurial > repos > blastem
diff blastem.c @ 1009:883fe974f72b
Fix bug in which save RAM/EEPROM was not persisted correctly if the emulator is exited via the menu rather than the X button in the title bar
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 01 May 2016 22:07:37 -0700 |
parents | 51885857c019 |
children | 5fb64487b6e1 |
line wrap: on
line diff
--- a/blastem.c Sun May 01 21:39:43 2016 -0700 +++ b/blastem.c Sun May 01 22:07:37 2016 -0700 @@ -868,14 +868,17 @@ genesis_context *game_context; void persist_save() { + if (!game_context) { + return; + } FILE * f = fopen(save_filename, "wb"); if (!f) { - fprintf(stderr, "Failed to open %s file %s for writing\n", genesis->save_type == SAVE_I2C ? "EEPROM" : "SRAM", save_filename); + fprintf(stderr, "Failed to open %s file %s for writing\n", game_context->save_type == SAVE_I2C ? "EEPROM" : "SRAM", save_filename); return; } - fwrite(genesis->save_storage, 1, genesis->save_size, f); + fwrite(game_context->save_storage, 1, game_context->save_size, f); fclose(f); - printf("Saved %s to %s\n", genesis->save_type == SAVE_I2C ? "EEPROM" : "SRAM", save_filename); + printf("Saved %s to %s\n", game_context->save_type == SAVE_I2C ? "EEPROM" : "SRAM", save_filename); } #ifndef NO_Z80