summaryrefslogtreecommitdiff
path: root/menu.c
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2016-04-17 23:50:41 -0700
committerMichael Pavone <pavone@retrodev.com>2016-04-17 23:50:41 -0700
commit4e282f87d2f2ee80e7d136ab6d335227a438caa1 (patch)
tree14af38b66151b5089e79cd6b284595f7f7239a9f /menu.c
parent87e279c0c1accec9b86d70d48241a123e4a0e492 (diff)
Save State menu option is now fully functional. Load state sort of works, but is mostly broken.
Diffstat (limited to 'menu.c')
-rw-r--r--menu.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/menu.c b/menu.c
index b978b90..da72b49 100644
--- a/menu.c
+++ b/menu.c
@@ -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 @@ void * menu_write_w(uint32_t address, void * context, uint16_t value)
}
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);