From 597a65adca3f56e3d0df4b60d51ca3ebacb68fe5 Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Tue, 24 Nov 2020 20:23:38 -0800 Subject: Backed out changeset 96971b673f51 This optimization caused a regression in Overdrive 2 due to the impact of Z80 access to the 68K bus --- genesis.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'genesis.c') diff --git a/genesis.c b/genesis.c index f36cdc5..5d50394 100644 --- a/genesis.c +++ b/genesis.c @@ -644,27 +644,16 @@ static uint16_t vdp_port_read(uint32_t vdp_port, m68k_context * context) refresh_counter = refresh_counter % (MCLKS_PER_68K * REFRESH_INTERVAL); last_sync_cycle = context->current_cycle; #endif + sync_components(context, 0); genesis_context *gen = context->system; vdp_context * v_context = gen->vdp; + uint32_t before_cycle = v_context->cycles; if (vdp_port < 0x10) { if (vdp_port < 4) { - sync_components(context, 0); - uint32_t before_cycle = v_context->cycles; value = vdp_data_port_read(v_context); - if (v_context->cycles != before_cycle) { - //printf("68K paused for %d (%d) cycles at cycle %d (%d) for read\n", v_context->cycles - context->current_cycle, v_context->cycles - before_cycle, context->current_cycle, before_cycle); - context->current_cycle = v_context->cycles; - //Lock the Z80 out of the bus until the VDP access is complete - genesis_context *gen = context->system; - gen->bus_busy = 1; - sync_z80(gen->z80, v_context->cycles); - gen->bus_busy = 0; - } } else if(vdp_port < 8) { - vdp_run_context(v_context, context->current_cycle); value = vdp_control_port_read(v_context); } else { - vdp_run_context(v_context, context->current_cycle); value = vdp_hv_counter_read(v_context); //printf("HV Counter: %X at cycle %d\n", value, v_context->cycles); } @@ -673,6 +662,15 @@ static uint16_t vdp_port_read(uint32_t vdp_port, m68k_context * context) } else { value = get_open_bus_value(&gen->header); } + if (v_context->cycles != before_cycle) { + //printf("68K paused for %d (%d) cycles at cycle %d (%d) for read\n", v_context->cycles - context->current_cycle, v_context->cycles - before_cycle, context->current_cycle, before_cycle); + context->current_cycle = v_context->cycles; + //Lock the Z80 out of the bus until the VDP access is complete + genesis_context *gen = context->system; + gen->bus_busy = 1; + sync_z80(gen->z80, v_context->cycles); + gen->bus_busy = 0; + } #ifdef REFRESH_EMULATION last_sync_cycle -= 4 * MCLKS_PER_68K; //refresh may have happened while we were waiting on the VDP, -- cgit v1.2.3