From 2bbf7ff47ec861475faf867b077baf07dae0ded8 Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Wed, 4 Nov 2015 19:14:39 -0800 Subject: Improve timing of Z80 busack. Fixes a crash in Barkley: Shut Up and Jam. Also vastly improves the audio output of Stuck Somewhere in Time --- z80_to_x86.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'z80_to_x86.c') diff --git a/z80_to_x86.c b/z80_to_x86.c index 54f4c6e..c373d1b 100644 --- a/z80_to_x86.c +++ b/z80_to_x86.c @@ -14,6 +14,7 @@ #include #define MODE_UNUSED (MODE_IMMED-1) +#define MAX_MCYCLE_LENGTH 6 //#define DO_DEBUG_PRINT @@ -2623,6 +2624,11 @@ void z80_assert_busreq(z80_context * context, uint32_t cycle) { z80_run(context, cycle); context->busreq = 1; + //this is an imperfect aproximation since most M-cycles take less tstates than the max + //and a short 3-tstate m-cycle can take an unbounded number due to wait states + if (context->current_cycle - cycle > MAX_MCYCLE_LENGTH * context->options->gen.clock_divider) { + context->busack = 1; + } } void z80_clear_busreq(z80_context * context, uint32_t cycle) -- cgit v1.2.3