# HG changeset patch # User Michael Pavone # Date 1701327396 28800 # Node ID 664c3e7494289fc6327e4f7e12a48404f789997f # Parent 9264c847ceb7b2c94da942a50e514942ccaf6fba Restore reset of refresh counter after DMA since its removal caused some regressions diff -r 9264c847ceb7 -r 664c3e749428 genesis.c --- a/genesis.c Sat Nov 25 11:54:56 2023 -0800 +++ b/genesis.c Wed Nov 29 22:56:36 2023 -0800 @@ -705,11 +705,13 @@ sync_components(context, 0); vdp_context *v_context = gen->vdp; uint32_t before_cycle = v_context->cycles; + uint8_t did_dma = 0; if (vdp_port < 0x10) { int blocked; if (vdp_port < 4) { while (vdp_data_port_write(v_context, value) < 0) { while(v_context->flags & FLAG_DMA_RUN) { + did_dma = 1; vdp_run_dma_done(v_context, gen->frame_end); if (v_context->cycles >= gen->frame_end) { uint32_t cycle_diff = v_context->cycles - context->current_cycle; @@ -732,6 +734,7 @@ if (blocked) { while (blocked) { while(v_context->flags & FLAG_DMA_RUN) { + did_dma = 1; vdp_run_dma_done(v_context, gen->frame_end); if (v_context->cycles >= gen->frame_end) { uint32_t cycle_diff = v_context->cycles - context->current_cycle; @@ -779,9 +782,14 @@ vdp_test_port_write(gen->vdp, value); } - //refresh may have happened while we were waiting on the VDP, - //so advance refresh_counter but don't add any delays - gen_update_refresh_no_wait(context); + if (did_dma) { + gen->refresh_counter = 0; + gen->last_sync_cycle = context->current_cycle; + } else { + //refresh may have happened while we were waiting on the VDP, + //so advance refresh_counter but don't add any delays + gen_update_refresh_no_wait(context); + } return context; }