# HG changeset patch # User Michael Pavone # Date 1446693279 28800 # Node ID adeb6465ad53b6abbe80be5306062e2f59f518f8 # Parent 2d474efb4629c1846357c25b4065b923c7608559 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 diff -r 2d474efb4629 -r adeb6465ad53 z80_to_x86.c --- a/z80_to_x86.c Tue Nov 03 07:41:10 2015 -0800 +++ b/z80_to_x86.c Wed Nov 04 19:14:39 2015 -0800 @@ -14,6 +14,7 @@ #include #define MODE_UNUSED (MODE_IMMED-1) +#define MAX_MCYCLE_LENGTH 6 //#define DO_DEBUG_PRINT @@ -2623,6 +2624,11 @@ { 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)