Mercurial > repos > blastem
comparison blastem.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 | 1618d3676a35 |
children | e28f365605da |
comparison
equal
deleted
inserted
replaced
960:0abfecaaf5c8 | 961:750995b587a0 |
---|---|
189 context->current_cycle, context->target_cycle, context->int_cycle, context->int_num, (context->status & 0x7), | 189 context->current_cycle, context->target_cycle, context->int_cycle, context->int_num, (context->status & 0x7), |
190 v_context->regs[REG_MODE_2] & 0x20, v_context->regs[REG_MODE_1] & 0x10, v_context->hint_counter, v_context->regs[REG_HINT], v_context->cycles / MCLKS_LINE);*/ | 190 v_context->regs[REG_MODE_2] & 0x20, v_context->regs[REG_MODE_1] & 0x10, v_context->hint_counter, v_context->regs[REG_HINT], v_context->cycles / MCLKS_LINE);*/ |
191 } | 191 } |
192 | 192 |
193 int break_on_sync = 0; | 193 int break_on_sync = 0; |
194 int save_state = 0; | |
195 char *save_state_path; | 194 char *save_state_path; |
196 | 195 |
197 //#define DO_DEBUG_PRINT | 196 //#define DO_DEBUG_PRINT |
198 #ifdef DO_DEBUG_PRINT | 197 #ifdef DO_DEBUG_PRINT |
199 #define dprintf printf | 198 #define dprintf printf |
292 if (context->int_ack) { | 291 if (context->int_ack) { |
293 //printf("acknowledging %d @ %d:%d, vcounter: %d, hslot: %d\n", context->int_ack, context->current_cycle, v_context->cycles, v_context->vcounter, v_context->hslot); | 292 //printf("acknowledging %d @ %d:%d, vcounter: %d, hslot: %d\n", context->int_ack, context->current_cycle, v_context->cycles, v_context->vcounter, v_context->hslot); |
294 vdp_int_ack(v_context); | 293 vdp_int_ack(v_context); |
295 context->int_ack = 0; | 294 context->int_ack = 0; |
296 } | 295 } |
297 if (!address && (break_on_sync || save_state)) { | 296 if (!address && (break_on_sync || gen->save_state)) { |
298 context->sync_cycle = context->current_cycle + 1; | 297 context->sync_cycle = context->current_cycle + 1; |
299 } | 298 } |
300 adjust_int_cycle(context, v_context); | 299 adjust_int_cycle(context, v_context); |
301 if (address) { | 300 if (address) { |
302 if (break_on_sync) { | 301 if (break_on_sync) { |
303 break_on_sync = 0; | 302 break_on_sync = 0; |
304 debugger(context, address); | 303 debugger(context, address); |
305 } | 304 } |
306 if (save_state && (z_context->pc || (!z_context->reset && !z_context->busreq))) { | 305 if (gen->save_state && (z_context->pc || (!z_context->reset && !z_context->busreq))) { |
307 save_state = 0; | 306 uint8_t slot = gen->save_state - 1; |
307 gen->save_state = 0; | |
308 //advance Z80 core to the start of an instruction | 308 //advance Z80 core to the start of an instruction |
309 while (!z_context->pc) | 309 while (!z_context->pc) |
310 { | 310 { |
311 sync_z80(z_context, z_context->current_cycle + MCLKS_PER_Z80); | 311 sync_z80(z_context, z_context->current_cycle + MCLKS_PER_Z80); |
312 } | 312 } |
313 save_gst(gen, save_state_path, address); | 313 char *save_path; |
314 printf("Saved state to %s\n", save_state_path); | 314 if (slot == QUICK_SAVE_SLOT) { |
315 } else if(save_state) { | 315 save_path = save_state_path; |
316 } else { | |
317 char slotname[] = "slot_0.gst"; | |
318 slotname[5] = '0' + slot; | |
319 char const *parts[] = {gen->save_dir, "/", slotname}; | |
320 save_path = alloc_concat_m(3, parts); | |
321 } | |
322 save_gst(gen, save_path, address); | |
323 printf("Saved state to %s\n", save_path); | |
324 if (slot != QUICK_SAVE_SLOT) { | |
325 free(save_path); | |
326 } | |
327 } else if(gen->save_state) { | |
316 context->sync_cycle = context->current_cycle + 1; | 328 context->sync_cycle = context->current_cycle + 1; |
317 } | 329 } |
318 } | 330 } |
319 last_sync_cycle = context->current_cycle; | 331 last_sync_cycle = context->current_cycle; |
320 return context; | 332 return context; |