Mercurial > repos > blastem
diff menu.c @ 961:750995b587a0
Save State menu option is now fully functional. Load state sort of works, but is mostly broken.
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 17 Apr 2016 23:50:41 -0700 |
parents | 83532f944e3b |
children | 4899d3ae37b3 |
line wrap: on
line diff
--- a/menu.c Sun Apr 17 20:31:22 2016 -0700 +++ b/menu.c Sun Apr 17 23:50:41 2016 -0700 @@ -7,6 +7,8 @@ #include "menu.h" #include "backend.h" #include "util.h" +#include "gst.h" +#include "m68k_internal.h" //needed for get_native_address_trans, should be eliminated once handling of PC is cleaned up uint16_t menu_read_w(uint32_t address, void * context) @@ -273,6 +275,32 @@ } copy_to_guest(m68k, dst, buffer, cur-buffer); break; + case 5: + //save state + if (gen->next_context) { + gen->next_context->save_state = dst + 1; + } + m68k->should_return = 1; + break; + case 6: + //load state + if (gen->next_context && gen->next_context->save_dir) { + char numslotname[] = "slot_0.gst"; + char *slotname; + if (dst == QUICK_SAVE_SLOT) { + slotname = "quicksave.gst"; + } else { + numslotname[5] = '0' + dst; + slotname = numslotname; + } + char const *parts[] = {gen->next_context->save_dir, "/", slotname}; + char *gstpath = alloc_concat_m(3, parts); + uint32_t pc = load_gst(gen->next_context, gstpath); + free(gstpath); + gen->next_context->m68k->resume_pc = get_native_address_trans(gen->next_context->m68k, pc); + } + m68k->should_return = 1; + break; } default: fprintf(stderr, "WARNING: write to undefined menu port %X\n", address);