Mercurial > repos > blastem
comparison genesis.c @ 1478:da1dce39e846 nuklear_ui
Refactored save slot related logic to reduce duplication and allow reuse in new UI. Get state loading/saving mostly working in new UI
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 24 Nov 2017 12:04:02 -0800 |
parents | 2e6320d261ff |
children | a568dca999b2 |
comparison
equal
deleted
inserted
replaced
1477:1cdd7f492af8 | 1478:da1dce39e846 |
---|---|
13 #include "render.h" | 13 #include "render.h" |
14 #include "gst.h" | 14 #include "gst.h" |
15 #include "util.h" | 15 #include "util.h" |
16 #include "debug.h" | 16 #include "debug.h" |
17 #include "gdb_remote.h" | 17 #include "gdb_remote.h" |
18 #include "saves.h" | |
18 #define MCLKS_NTSC 53693175 | 19 #define MCLKS_NTSC 53693175 |
19 #define MCLKS_PAL 53203395 | 20 #define MCLKS_PAL 53203395 |
20 | 21 |
21 uint32_t MCLKS_PER_68K; | 22 uint32_t MCLKS_PER_68K; |
22 #define MCLKS_PER_YM 7 | 23 #define MCLKS_PER_YM 7 |
357 while (!z_context->pc) | 358 while (!z_context->pc) |
358 { | 359 { |
359 sync_z80(z_context, z_context->current_cycle + MCLKS_PER_Z80); | 360 sync_z80(z_context, z_context->current_cycle + MCLKS_PER_Z80); |
360 } | 361 } |
361 } | 362 } |
362 char *save_path; | 363 char *save_path = get_slot_name(&gen->header, slot, use_native_states ? "state" : "gst"); |
363 if (slot == QUICK_SAVE_SLOT) { | |
364 save_path = save_state_path; | |
365 } else { | |
366 char slotname[] = "slot_0.state"; | |
367 slotname[5] = '0' + slot; | |
368 if (!use_native_states) { | |
369 strcpy(slotname + 7, "gst"); | |
370 } | |
371 char const *parts[] = {gen->header.save_dir, PATH_SEP, slotname}; | |
372 save_path = alloc_concat_m(3, parts); | |
373 } | |
374 if (use_native_states) { | 364 if (use_native_states) { |
375 serialize_buffer state; | 365 serialize_buffer state; |
376 init_serialize(&state); | 366 init_serialize(&state); |
377 genesis_serialize(gen, &state, address); | 367 genesis_serialize(gen, &state, address); |
378 save_to_file(&state, save_path); | 368 save_to_file(&state, save_path); |
379 free(state.data); | 369 free(state.data); |
380 } else { | 370 } else { |
381 save_gst(gen, save_path, address); | 371 save_gst(gen, save_path, address); |
382 } | 372 } |
383 printf("Saved state to %s\n", save_path); | 373 printf("Saved state to %s\n", save_path); |
384 if (slot != QUICK_SAVE_SLOT) { | 374 free(save_path); |
385 free(save_path); | |
386 } | |
387 } else if(gen->header.save_state) { | 375 } else if(gen->header.save_state) { |
388 context->sync_cycle = context->current_cycle + 1; | 376 context->sync_cycle = context->current_cycle + 1; |
389 } | 377 } |
390 } | 378 } |
391 #ifdef REFRESH_EMULATION | 379 #ifdef REFRESH_EMULATION |