# HG changeset patch # User Michael Pavone # Date 1660457700 25200 # Node ID 408fb8a7e990ff78f1976f0cb92af109873187bd # Parent eb2e0e61b1b4920e3720dc58ea0a9b825483c039 Implement argumentless variant of z80 debugger command diff -r eb2e0e61b1b4 -r 408fb8a7e990 debug.c --- a/debug.c Sat Aug 13 22:57:57 2022 -0700 +++ b/debug.c Sat Aug 13 23:15:00 2022 -0700 @@ -1631,7 +1631,7 @@ free_parsed_command(&cmd); return ret; } else { - fputs("not implemented yet", stderr); + gen->enter_z80_debugger = 1; return 0; } } diff -r eb2e0e61b1b4 -r 408fb8a7e990 genesis.c --- a/genesis.c Sat Aug 13 22:57:57 2022 -0700 +++ b/genesis.c Sat Aug 13 23:15:00 2022 -0700 @@ -377,8 +377,9 @@ #endif } -static void sync_z80(z80_context * z_context, uint32_t mclks) +static void sync_z80(genesis_context *gen, uint32_t mclks) { + z80_context *z_context = gen->z80; #ifndef NO_Z80 if (z80_enabled) { #ifdef NEW_CORE @@ -386,6 +387,13 @@ z80_next_int_pulse(z_context); } #endif + if (gen->enter_z80_debugger && !z_context->reset && !z_context->busack) { + while (!z_context->pc) { + z80_run(z_context, z_context->current_cycle + 4); + } + gen->enter_z80_debugger = 0; + zdebugger(z_context, z_context->pc); + } z80_run(z_context, mclks); } else #endif @@ -444,7 +452,7 @@ #endif uint32_t mclks = context->current_cycle; - sync_z80(z_context, mclks); + sync_z80(gen, mclks); sync_sound(gen, mclks); vdp_run_context(v_context, mclks); io_run(gen->io.ports, mclks); @@ -545,7 +553,7 @@ //advance Z80 core to the start of an instruction while (!z_context->pc) { - sync_z80(z_context, z_context->current_cycle + MCLKS_PER_Z80); + sync_z80(gen, z_context->current_cycle + MCLKS_PER_Z80); } } #endif @@ -668,7 +676,7 @@ context->current_cycle += m68k_cycle_diff; //Lock the Z80 out of the bus until the VDP access is complete gen->bus_busy = 1; - sync_z80(gen->z80, v_context->cycles); + sync_z80(gen, v_context->cycles); gen->bus_busy = 0; } } else if (vdp_port < 0x18) { @@ -765,7 +773,7 @@ //Lock the Z80 out of the bus until the VDP access is complete genesis_context *gen = context->system; gen->bus_busy = 1; - sync_z80(gen->z80, v_context->cycles); + sync_z80(gen, v_context->cycles); gen->bus_busy = 0; } #ifdef REFRESH_EMULATION @@ -942,7 +950,7 @@ } } } else if (masked == 0x11200) { - sync_z80(gen->z80, context->current_cycle); + sync_z80(gen, context->current_cycle); if (value & 1) { if (z80_enabled) { z80_clear_reset(gen->z80, context->current_cycle); diff -r eb2e0e61b1b4 -r 408fb8a7e990 genesis.h --- a/genesis.h Sat Aug 13 22:57:57 2022 -0700 +++ b/genesis.h Sat Aug 13 23:15:00 2022 -0700 @@ -74,6 +74,7 @@ uint8_t reset_requested; uint8_t tmss; uint8_t vdp_unlocked; + uint8_t enter_z80_debugger; eeprom_state eeprom; nor_state nor; };