diff options
author | Michael Pavone <pavone@retrodev.com> | 2019-08-19 19:15:52 -0700 |
---|---|---|
committer | Michael Pavone <pavone@retrodev.com> | 2019-08-19 19:15:52 -0700 |
commit | 2a6dee8faa7d37f81f404cc7794a857d3bb425bb (patch) | |
tree | c77b3670d305d03d7fa603e321ec3219ca320f60 /genesis.c | |
parent | 6ca5e29f7272be7dfd245416b7f55c0457209210 (diff) |
Only do full sync on VDP data port reads instead of all VDP port reads, provides a perf bump for games that busy wait on the status or HV registers
Diffstat (limited to 'genesis.c')
-rw-r--r-- | genesis.c | 24 |
1 files changed, 13 insertions, 11 deletions
@@ -632,16 +632,27 @@ 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); } @@ -650,15 +661,6 @@ 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; //refresh may have happened while we were waiting on the VDP, |