comparison sms.c @ 1931:374a5ae694e8 mame_interp

Merge from default
author Michael Pavone <pavone@retrodev.com>
date Sat, 18 Apr 2020 11:42:53 -0700
parents 49f65d240299 2d462aa78349
children 2c1c88cd1a3f
comparison
equal deleted inserted replaced
1843:13abdc98379e 1931:374a5ae694e8
7 #include "util.h" 7 #include "util.h"
8 #include "debug.h" 8 #include "debug.h"
9 #include "saves.h" 9 #include "saves.h"
10 #include "bindings.h" 10 #include "bindings.h"
11 11
12 #ifndef USE_NATIVE 12 #ifdef NEW_CORE
13 #define Z80_CYCLE cycles 13 #define Z80_CYCLE cycles
14 #define Z80_OPTS opts 14 #define Z80_OPTS opts
15 #define z80_handle_code_write(...) 15 #define z80_handle_code_write(...)
16 #else 16 #else
17 #define Z80_CYCLE current_cycle 17 #define Z80_CYCLE current_cycle
68 68
69 static void update_interrupts(sms_context *sms) 69 static void update_interrupts(sms_context *sms)
70 { 70 {
71 uint32_t vint = vdp_next_vint(sms->vdp); 71 uint32_t vint = vdp_next_vint(sms->vdp);
72 uint32_t hint = vdp_next_hint(sms->vdp); 72 uint32_t hint = vdp_next_hint(sms->vdp);
73 #ifndef USE_NATIVE 73 #ifdef NEW_CORE
74 sms->z80->int_cycle = vint < hint ? vint : hint; 74 sms->z80->int_cycle = vint < hint ? vint : hint;
75 z80_sync_cycle(sms->z80, sms->z80->sync_cycle); 75 z80_sync_cycle(sms->z80, sms->z80->sync_cycle);
76 #else 76 #else
77 sms->z80->int_pulse_start = vint < hint ? vint : hint; 77 sms->z80->int_pulse_start = vint < hint ? vint : hint;
78 #endif 78 #endif
355 static uint8_t load_state(system_header *system, uint8_t slot) 355 static uint8_t load_state(system_header *system, uint8_t slot)
356 { 356 {
357 sms_context *sms = (sms_context *)system; 357 sms_context *sms = (sms_context *)system;
358 char *statepath = get_slot_name(system, slot, "state"); 358 char *statepath = get_slot_name(system, slot, "state");
359 uint8_t ret; 359 uint8_t ret;
360 #ifdef USE_NATIVE 360 #ifndef NEW_CORE
361 if (!sms->z80->native_pc) { 361 if (!sms->z80->native_pc) {
362 ret = get_modification_time(statepath) != 0; 362 ret = get_modification_time(statepath) != 0;
363 if (ret) { 363 if (ret) {
364 system->delayed_load_slot = slot + 1; 364 system->delayed_load_slot = slot + 1;
365 } 365 }
379 uint32_t target_cycle = sms->z80->Z80_CYCLE + 3420*16; 379 uint32_t target_cycle = sms->z80->Z80_CYCLE + 3420*16;
380 //TODO: PAL support 380 //TODO: PAL support
381 render_set_video_standard(VID_NTSC); 381 render_set_video_standard(VID_NTSC);
382 while (!sms->should_return) 382 while (!sms->should_return)
383 { 383 {
384 #ifdef USE_NATIVE 384 #ifndef NEW_CORE
385 if (system->delayed_load_slot) { 385 if (system->delayed_load_slot) {
386 load_state(system, system->delayed_load_slot - 1); 386 load_state(system, system->delayed_load_slot - 1);
387 system->delayed_load_slot = 0; 387 system->delayed_load_slot = 0;
388 388
389 } 389 }
406 } 406 }
407 target_cycle = sms->z80->Z80_CYCLE; 407 target_cycle = sms->z80->Z80_CYCLE;
408 vdp_run_context(sms->vdp, target_cycle); 408 vdp_run_context(sms->vdp, target_cycle);
409 psg_run(sms->psg, target_cycle); 409 psg_run(sms->psg, target_cycle);
410 410
411 #ifdef USE_NATIVE 411 #ifndef NEW_CORE
412 if (system->save_state) { 412 if (system->save_state) {
413 while (!sms->z80->pc) { 413 while (!sms->z80->pc) {
414 //advance Z80 to an instruction boundary 414 //advance Z80 to an instruction boundary
415 z80_run(sms->z80, sms->z80->Z80_CYCLE + 1); 415 z80_run(sms->z80, sms->z80->Z80_CYCLE + 1);
416 } 416 }
458 458
459 if (statefile) { 459 if (statefile) {
460 load_state_path(sms, statefile); 460 load_state_path(sms, statefile);
461 } 461 }
462 462
463 #ifdef USE_NATIVE 463 #ifndef NEW_CORE
464 if (system->enter_debugger) { 464 if (system->enter_debugger) {
465 system->enter_debugger = 0; 465 system->enter_debugger = 0;
466 zinsert_breakpoint(sms->z80, sms->z80->pc, (uint8_t *)zdebugger); 466 zinsert_breakpoint(sms->z80, sms->z80->pc, (uint8_t *)zdebugger);
467 } 467 }
468 #endif 468 #endif
472 472
473 static void soft_reset(system_header *system) 473 static void soft_reset(system_header *system)
474 { 474 {
475 sms_context *sms = (sms_context *)system; 475 sms_context *sms = (sms_context *)system;
476 z80_assert_reset(sms->z80, sms->z80->Z80_CYCLE); 476 z80_assert_reset(sms->z80, sms->z80->Z80_CYCLE);
477 #ifdef USE_NATIVE 477 #ifndef NEW_CORE
478 sms->z80->target_cycle = sms->z80->sync_cycle = sms->z80->current_cycle; 478 sms->z80->target_cycle = sms->z80->sync_cycle = sms->z80->current_cycle;
479 #endif 479 #endif
480 } 480 }
481 481
482 static void free_sms(system_header *system) 482 static void free_sms(system_header *system)
496 496
497 static void request_exit(system_header *system) 497 static void request_exit(system_header *system)
498 { 498 {
499 sms_context *sms = (sms_context *)system; 499 sms_context *sms = (sms_context *)system;
500 sms->should_return = 1; 500 sms->should_return = 1;
501 #ifdef USE_NATIVE 501 #ifndef NEW_CORE
502 sms->z80->target_cycle = sms->z80->sync_cycle = sms->z80->Z80_CYCLE; 502 sms->z80->target_cycle = sms->z80->sync_cycle = sms->z80->Z80_CYCLE;
503 #endif 503 #endif
504 } 504 }
505 505
506 static void inc_debug_mode(system_header *system) 506 static void inc_debug_mode(system_header *system)
631 sms->psg = malloc(sizeof(psg_context)); 631 sms->psg = malloc(sizeof(psg_context));
632 psg_init(sms->psg, sms->master_clock, 15*16); 632 psg_init(sms->psg, sms->master_clock, 15*16);
633 633
634 set_gain_config(sms); 634 set_gain_config(sms);
635 635
636 sms->vdp = init_vdp_context(0); 636 sms->vdp = init_vdp_context(0, 0);
637 sms->vdp->system = &sms->header; 637 sms->vdp->system = &sms->header;
638 638
639 sms->header.info.save_type = SAVE_NONE; 639 sms->header.info.save_type = SAVE_NONE;
640 sms->header.info.name = strdup(media->name); 640 sms->header.info.name = strdup(media->name);
641 641