Mercurial > repos > blastem
comparison 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 |
comparison
equal
deleted
inserted
replaced
853:2d474efb4629 | 854:adeb6465ad53 |
---|---|
12 #include <stdlib.h> | 12 #include <stdlib.h> |
13 #include <stddef.h> | 13 #include <stddef.h> |
14 #include <string.h> | 14 #include <string.h> |
15 | 15 |
16 #define MODE_UNUSED (MODE_IMMED-1) | 16 #define MODE_UNUSED (MODE_IMMED-1) |
17 #define MAX_MCYCLE_LENGTH 6 | |
17 | 18 |
18 //#define DO_DEBUG_PRINT | 19 //#define DO_DEBUG_PRINT |
19 | 20 |
20 #ifdef DO_DEBUG_PRINT | 21 #ifdef DO_DEBUG_PRINT |
21 #define dprintf printf | 22 #define dprintf printf |
2621 | 2622 |
2622 void z80_assert_busreq(z80_context * context, uint32_t cycle) | 2623 void z80_assert_busreq(z80_context * context, uint32_t cycle) |
2623 { | 2624 { |
2624 z80_run(context, cycle); | 2625 z80_run(context, cycle); |
2625 context->busreq = 1; | 2626 context->busreq = 1; |
2627 //this is an imperfect aproximation since most M-cycles take less tstates than the max | |
2628 //and a short 3-tstate m-cycle can take an unbounded number due to wait states | |
2629 if (context->current_cycle - cycle > MAX_MCYCLE_LENGTH * context->options->gen.clock_divider) { | |
2630 context->busack = 1; | |
2631 } | |
2626 } | 2632 } |
2627 | 2633 |
2628 void z80_clear_busreq(z80_context * context, uint32_t cycle) | 2634 void z80_clear_busreq(z80_context * context, uint32_t cycle) |
2629 { | 2635 { |
2630 z80_run(context, cycle); | 2636 z80_run(context, cycle); |