# HG changeset patch # User Michael Pavone # Date 1462165657 25200 # Node ID 883fe974f72bc790e55123956d9294449e908c6d # Parent 51885857c019247eba48cd7427fabaeaeabf0063 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 diff -r 51885857c019 -r 883fe974f72b blastem.c --- 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