comparison genesis.c @ 2184:408fb8a7e990

Implement argumentless variant of z80 debugger command
author Michael Pavone <pavone@retrodev.com>
date Sat, 13 Aug 2022 23:15:00 -0700
parents 9a8dd4ba2753
children 01ff005b08f6
comparison
equal deleted inserted replaced
2183:eb2e0e61b1b4 2184:408fb8a7e990
375 z_context->int_pulse_end = z_context->int_pulse_start + Z80_INT_PULSE_MCLKS; 375 z_context->int_pulse_end = z_context->int_pulse_start + Z80_INT_PULSE_MCLKS;
376 z_context->im2_vector = 0xFF; 376 z_context->im2_vector = 0xFF;
377 #endif 377 #endif
378 } 378 }
379 379
380 static void sync_z80(z80_context * z_context, uint32_t mclks) 380 static void sync_z80(genesis_context *gen, uint32_t mclks)
381 { 381 {
382 z80_context *z_context = gen->z80;
382 #ifndef NO_Z80 383 #ifndef NO_Z80
383 if (z80_enabled) { 384 if (z80_enabled) {
384 #ifdef NEW_CORE 385 #ifdef NEW_CORE
385 if (z_context->int_cycle == 0xFFFFFFFFU) { 386 if (z_context->int_cycle == 0xFFFFFFFFU) {
386 z80_next_int_pulse(z_context); 387 z80_next_int_pulse(z_context);
387 } 388 }
388 #endif 389 #endif
390 if (gen->enter_z80_debugger && !z_context->reset && !z_context->busack) {
391 while (!z_context->pc) {
392 z80_run(z_context, z_context->current_cycle + 4);
393 }
394 gen->enter_z80_debugger = 0;
395 zdebugger(z_context, z_context->pc);
396 }
389 z80_run(z_context, mclks); 397 z80_run(z_context, mclks);
390 } else 398 } else
391 #endif 399 #endif
392 { 400 {
393 z_context->Z80_CYCLE = mclks; 401 z_context->Z80_CYCLE = mclks;
442 } 450 }
443 refresh_counter = refresh_counter % (MCLKS_PER_68K * REFRESH_INTERVAL); 451 refresh_counter = refresh_counter % (MCLKS_PER_68K * REFRESH_INTERVAL);
444 #endif 452 #endif
445 453
446 uint32_t mclks = context->current_cycle; 454 uint32_t mclks = context->current_cycle;
447 sync_z80(z_context, mclks); 455 sync_z80(gen, mclks);
448 sync_sound(gen, mclks); 456 sync_sound(gen, mclks);
449 vdp_run_context(v_context, mclks); 457 vdp_run_context(v_context, mclks);
450 io_run(gen->io.ports, mclks); 458 io_run(gen->io.ports, mclks);
451 io_run(gen->io.ports + 1, mclks); 459 io_run(gen->io.ports + 1, mclks);
452 io_run(gen->io.ports + 2, mclks); 460 io_run(gen->io.ports + 2, mclks);
543 #ifndef NEW_CORE 551 #ifndef NEW_CORE
544 if (z_context->native_pc && !z_context->reset) { 552 if (z_context->native_pc && !z_context->reset) {
545 //advance Z80 core to the start of an instruction 553 //advance Z80 core to the start of an instruction
546 while (!z_context->pc) 554 while (!z_context->pc)
547 { 555 {
548 sync_z80(z_context, z_context->current_cycle + MCLKS_PER_Z80); 556 sync_z80(gen, z_context->current_cycle + MCLKS_PER_Z80);
549 } 557 }
550 } 558 }
551 #endif 559 #endif
552 char *save_path = slot >= SERIALIZE_SLOT ? NULL : get_slot_name(&gen->header, slot, use_native_states ? "state" : "gst"); 560 char *save_path = slot >= SERIALIZE_SLOT ? NULL : get_slot_name(&gen->header, slot, use_native_states ? "state" : "gst");
553 if (use_native_states || slot >= SERIALIZE_SLOT) { 561 if (use_native_states || slot >= SERIALIZE_SLOT) {
666 m68k_cycle_diff += MCLKS_PER_68K; 674 m68k_cycle_diff += MCLKS_PER_68K;
667 } 675 }
668 context->current_cycle += m68k_cycle_diff; 676 context->current_cycle += m68k_cycle_diff;
669 //Lock the Z80 out of the bus until the VDP access is complete 677 //Lock the Z80 out of the bus until the VDP access is complete
670 gen->bus_busy = 1; 678 gen->bus_busy = 1;
671 sync_z80(gen->z80, v_context->cycles); 679 sync_z80(gen, v_context->cycles);
672 gen->bus_busy = 0; 680 gen->bus_busy = 0;
673 } 681 }
674 } else if (vdp_port < 0x18) { 682 } else if (vdp_port < 0x18) {
675 psg_write(gen->psg, value); 683 psg_write(gen->psg, value);
676 } else { 684 } else {
763 //printf("68K paused for %d (%d) cycles at cycle %d (%d) for read\n", v_context->cycles - context->current_cycle, v_context->cycles - before_cycle, context->current_cycle, before_cycle); 771 //printf("68K paused for %d (%d) cycles at cycle %d (%d) for read\n", v_context->cycles - context->current_cycle, v_context->cycles - before_cycle, context->current_cycle, before_cycle);
764 context->current_cycle = v_context->cycles; 772 context->current_cycle = v_context->cycles;
765 //Lock the Z80 out of the bus until the VDP access is complete 773 //Lock the Z80 out of the bus until the VDP access is complete
766 genesis_context *gen = context->system; 774 genesis_context *gen = context->system;
767 gen->bus_busy = 1; 775 gen->bus_busy = 1;
768 sync_z80(gen->z80, v_context->cycles); 776 sync_z80(gen, v_context->cycles);
769 gen->bus_busy = 0; 777 gen->bus_busy = 0;
770 } 778 }
771 #ifdef REFRESH_EMULATION 779 #ifdef REFRESH_EMULATION
772 last_sync_cycle -= 4 * MCLKS_PER_68K; 780 last_sync_cycle -= 4 * MCLKS_PER_68K;
773 //refresh may have happened while we were waiting on the VDP, 781 //refresh may have happened while we were waiting on the VDP,
940 } else { 948 } else {
941 gen->z80->busack = 0; 949 gen->z80->busack = 0;
942 } 950 }
943 } 951 }
944 } else if (masked == 0x11200) { 952 } else if (masked == 0x11200) {
945 sync_z80(gen->z80, context->current_cycle); 953 sync_z80(gen, context->current_cycle);
946 if (value & 1) { 954 if (value & 1) {
947 if (z80_enabled) { 955 if (z80_enabled) {
948 z80_clear_reset(gen->z80, context->current_cycle); 956 z80_clear_reset(gen->z80, context->current_cycle);
949 } else { 957 } else {
950 gen->z80->reset = 0; 958 gen->z80->reset = 0;