From cf3b1495949b5e22fbcaac0510cfe002b2cccb16 Mon Sep 17 00:00:00 2001 From: Andre Weissflog Date: Mon, 9 Dec 2024 12:21:55 +0100 Subject: [PATCH] z80: prevent infinite loop when op-stepping with wait active (fixes #22) --- src/sim.c | 2 +- src/trace.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sim.c b/src/sim.c index c5a59e5..390cbda 100644 --- a/src/sim.c +++ b/src/sim.c @@ -122,7 +122,7 @@ void sim_step_op(void) { prev_m1 = cpu_readM1(sim.cpu_state); sim_step(1); cur_m1 = cpu_readM1(sim.cpu_state); - } while (!(prev_m1 && !cur_m1)); // M1 pin is active-low! + } while (!(prev_m1 && !cur_m1) && cpu_readWAIT(sim.cpu_state)); // M1 pin is active-low! #endif } diff --git a/src/trace.c b/src/trace.c index 42c4bea..a39a59b 100644 --- a/src/trace.c +++ b/src/trace.c @@ -429,7 +429,7 @@ uint8_t trace_z80_get_mcycle(uint32_t index) { case (1<<2): return 3; case (1<<3): return 4; case (1<<4): return 5; - default: return 0xFF; + default: return 0; } } @@ -441,7 +441,7 @@ uint8_t trace_z80_get_tstate(uint32_t index) { case (1<<3): return 4; case (1<<4): return 5; case (1<<5): return 6; - default: return 0xFF; + default: return 0; } }