Mercurial > repos > blastem
diff z80_to_x86.c @ 854:adeb6465ad53
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
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 04 Nov 2015 19:14:39 -0800 |
parents | 74e161fe7d39 |
children | 252dfd29831d |
line wrap: on
line diff
--- 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 <string.h> #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)