From 096ea6fc83699e30a1a53e4314487d1ba3e46e2c Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Sun, 1 May 2016 22:07:37 -0700 Subject: 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 --- blastem.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'blastem.c') diff --git a/blastem.c b/blastem.c index d71130a..0ffa8ec 100644 --- a/blastem.c +++ b/blastem.c @@ -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 -- cgit v1.2.3