diff options
author | Michael Pavone <pavone@retrodev.com> | 2016-05-01 22:07:37 -0700 |
---|---|---|
committer | Michael Pavone <pavone@retrodev.com> | 2016-05-01 22:07:37 -0700 |
commit | 096ea6fc83699e30a1a53e4314487d1ba3e46e2c (patch) | |
tree | 4ab1fd10cafb866589b3d9f6d3c943633cc11722 | |
parent | 5278b492751f31df81c297c60630b3106776b29e (diff) |
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
-rw-r--r-- | blastem.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -868,14 +868,17 @@ genesis_context *menu_context; 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 |