Mercurial > repos > blastem
comparison 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 |
comparison
equal
deleted
inserted
replaced
960:0abfecaaf5c8 | 961:750995b587a0 |
---|---|
5 #include <errno.h> | 5 #include <errno.h> |
6 #include "blastem.h" | 6 #include "blastem.h" |
7 #include "menu.h" | 7 #include "menu.h" |
8 #include "backend.h" | 8 #include "backend.h" |
9 #include "util.h" | 9 #include "util.h" |
10 #include "gst.h" | |
11 #include "m68k_internal.h" //needed for get_native_address_trans, should be eliminated once handling of PC is cleaned up | |
10 | 12 |
11 | 13 |
12 uint16_t menu_read_w(uint32_t address, void * context) | 14 uint16_t menu_read_w(uint32_t address, void * context) |
13 { | 15 { |
14 //This should return the status of the last request with 0 | 16 //This should return the status of the last request with 0 |
271 *(cur++) = 0; | 273 *(cur++) = 0; |
272 *(cur++) = 0; | 274 *(cur++) = 0; |
273 } | 275 } |
274 copy_to_guest(m68k, dst, buffer, cur-buffer); | 276 copy_to_guest(m68k, dst, buffer, cur-buffer); |
275 break; | 277 break; |
278 case 5: | |
279 //save state | |
280 if (gen->next_context) { | |
281 gen->next_context->save_state = dst + 1; | |
282 } | |
283 m68k->should_return = 1; | |
284 break; | |
285 case 6: | |
286 //load state | |
287 if (gen->next_context && gen->next_context->save_dir) { | |
288 char numslotname[] = "slot_0.gst"; | |
289 char *slotname; | |
290 if (dst == QUICK_SAVE_SLOT) { | |
291 slotname = "quicksave.gst"; | |
292 } else { | |
293 numslotname[5] = '0' + dst; | |
294 slotname = numslotname; | |
295 } | |
296 char const *parts[] = {gen->next_context->save_dir, "/", slotname}; | |
297 char *gstpath = alloc_concat_m(3, parts); | |
298 uint32_t pc = load_gst(gen->next_context, gstpath); | |
299 free(gstpath); | |
300 gen->next_context->m68k->resume_pc = get_native_address_trans(gen->next_context->m68k, pc); | |
301 } | |
302 m68k->should_return = 1; | |
303 break; | |
276 } | 304 } |
277 default: | 305 default: |
278 fprintf(stderr, "WARNING: write to undefined menu port %X\n", address); | 306 fprintf(stderr, "WARNING: write to undefined menu port %X\n", address); |
279 } | 307 } |
280 menu->state = 0; | 308 menu->state = 0; |