Mercurial > repos > blastem
comparison sms.c @ 1480:8464a3f09b94 nuklear_ui
Get SMS savestates working in Nuklear UI
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sat, 25 Nov 2017 11:31:08 -0800 |
parents | da1dce39e846 |
children | ce1f93be0104 |
comparison
equal
deleted
inserted
replaced
1479:a568dca999b2 | 1480:8464a3f09b94 |
---|---|
316 } | 316 } |
317 | 317 |
318 static uint8_t load_state(system_header *system, uint8_t slot) | 318 static uint8_t load_state(system_header *system, uint8_t slot) |
319 { | 319 { |
320 sms_context *sms = (sms_context *)system; | 320 sms_context *sms = (sms_context *)system; |
321 char numslotname[] = "slot_0.state"; | 321 char *statepath = get_slot_name(system, slot, "state"); |
322 char *slotname; | 322 uint8_t ret; |
323 if (slot == QUICK_SAVE_SLOT) { | 323 if (!sms->z80->native_pc) { |
324 slotname = "quicksave.state"; | 324 ret = get_modification_time(statepath) != 0; |
325 } else { | 325 if (ret) { |
326 numslotname[5] = '0' + slot; | 326 system->delayed_load_slot = slot + 1; |
327 slotname = numslotname; | 327 } |
328 } | 328 goto done; |
329 char const *parts[] = {sms->header.save_dir, PATH_SEP, slotname}; | 329 |
330 char *statepath = alloc_concat_m(3, parts); | 330 } |
331 uint8_t ret = load_state_path(sms, statepath); | 331 ret = load_state_path(sms, statepath); |
332 done: | |
332 free(statepath); | 333 free(statepath); |
333 return ret; | 334 return ret; |
334 } | 335 } |
335 | 336 |
336 static void run_sms(system_header *system) | 337 static void run_sms(system_header *system) |
340 uint32_t target_cycle = sms->z80->current_cycle + 3420*16; | 341 uint32_t target_cycle = sms->z80->current_cycle + 3420*16; |
341 //TODO: PAL support | 342 //TODO: PAL support |
342 render_set_video_standard(VID_NTSC); | 343 render_set_video_standard(VID_NTSC); |
343 while (!sms->should_return) | 344 while (!sms->should_return) |
344 { | 345 { |
346 if (system->delayed_load_slot) { | |
347 load_state(system, system->delayed_load_slot - 1); | |
348 system->delayed_load_slot = 0; | |
349 | |
350 } | |
345 if (system->enter_debugger && sms->z80->pc) { | 351 if (system->enter_debugger && sms->z80->pc) { |
346 system->enter_debugger = 0; | 352 system->enter_debugger = 0; |
347 zdebugger(sms->z80, sms->z80->pc); | 353 zdebugger(sms->z80, sms->z80->pc); |
348 } | 354 } |
349 if (sms->z80->nmi_start == CYCLE_NEVER) { | 355 if (sms->z80->nmi_start == CYCLE_NEVER) { |