diff options
author | Michael Pavone <pavone@retrodev.com> | 2015-11-04 19:14:39 -0800 |
---|---|---|
committer | Michael Pavone <pavone@retrodev.com> | 2015-11-04 19:14:39 -0800 |
commit | 2bbf7ff47ec861475faf867b077baf07dae0ded8 (patch) | |
tree | 02e4f9e8d25d4443e480acd93ca0af9f6e4108da | |
parent | d0896e7e7e918a8e73ae63636bb34b9dd8042570 (diff) |
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
-rw-r--r-- | z80_to_x86.c | 6 |
1 files changed, 6 insertions, 0 deletions
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 <string.h> #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) |