Mercurial > repos > blastem
comparison 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 |
comparison
equal
deleted
inserted
replaced
1008:51885857c019 | 1009:883fe974f72b |
---|---|
866 genesis_context *genesis; | 866 genesis_context *genesis; |
867 genesis_context *menu_context; | 867 genesis_context *menu_context; |
868 genesis_context *game_context; | 868 genesis_context *game_context; |
869 void persist_save() | 869 void persist_save() |
870 { | 870 { |
871 if (!game_context) { | |
872 return; | |
873 } | |
871 FILE * f = fopen(save_filename, "wb"); | 874 FILE * f = fopen(save_filename, "wb"); |
872 if (!f) { | 875 if (!f) { |
873 fprintf(stderr, "Failed to open %s file %s for writing\n", genesis->save_type == SAVE_I2C ? "EEPROM" : "SRAM", save_filename); | 876 fprintf(stderr, "Failed to open %s file %s for writing\n", game_context->save_type == SAVE_I2C ? "EEPROM" : "SRAM", save_filename); |
874 return; | 877 return; |
875 } | 878 } |
876 fwrite(genesis->save_storage, 1, genesis->save_size, f); | 879 fwrite(game_context->save_storage, 1, game_context->save_size, f); |
877 fclose(f); | 880 fclose(f); |
878 printf("Saved %s to %s\n", genesis->save_type == SAVE_I2C ? "EEPROM" : "SRAM", save_filename); | 881 printf("Saved %s to %s\n", game_context->save_type == SAVE_I2C ? "EEPROM" : "SRAM", save_filename); |
879 } | 882 } |
880 | 883 |
881 #ifndef NO_Z80 | 884 #ifndef NO_Z80 |
882 const memmap_chunk z80_map[] = { | 885 const memmap_chunk z80_map[] = { |
883 { 0x0000, 0x4000, 0x1FFF, 0, MMAP_READ | MMAP_WRITE | MMAP_CODE, z80_ram, NULL, NULL, NULL, NULL }, | 886 { 0x0000, 0x4000, 0x1FFF, 0, MMAP_READ | MMAP_WRITE | MMAP_CODE, z80_ram, NULL, NULL, NULL, NULL }, |