diff options
author | Michael Pavone <pavone@retrodev.com> | 2017-05-23 23:47:40 -0700 |
---|---|---|
committer | Michael Pavone <pavone@retrodev.com> | 2017-05-23 23:47:40 -0700 |
commit | 96ccd78f03449abf5ae4a993ed47628d240ab496 (patch) | |
tree | 08db8883ee6115a01b878b80e200c96a04153725 | |
parent | ece95165b14b053b5fcdb342063a52c9a0b9e5e4 (diff) |
Go back to resetting the refresh counter after a DMA. Probably not quite correct as it is probably reset on VDP triggered refresh, but this is close enough for now given the general limitations with my refresh code. VDP FIFO Testing seems to be passing 100% reliably again (was occassionally failing still with the last commit)
-rw-r--r-- | genesis.c | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -283,9 +283,9 @@ static m68k_context * vdp_port_write(uint32_t vdp_port, m68k_context * context, 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) { int blocked; - uint32_t before_cycle = v_context->cycles; if (vdp_port < 4) { while (vdp_data_port_write(v_context, value) < 0) { while(v_context->flags & FLAG_DMA_RUN) { @@ -361,8 +361,12 @@ static m68k_context * vdp_port_write(uint32_t vdp_port, m68k_context * context, last_sync_cycle -= 4; //refresh may have happened while we were waiting on the VDP, //so advance refresh_counter but don't add any delays - refresh_counter += (context->current_cycle - last_sync_cycle); - refresh_counter = refresh_counter % (MCLKS_PER_68K * REFRESH_INTERVAL); + if (vdp_port >= 4 && vdp_port < 8 && v_context->cycles != before_cycle) { + refresh_counter = 0; + } else { + refresh_counter += (context->current_cycle - last_sync_cycle); + refresh_counter = refresh_counter % (MCLKS_PER_68K * REFRESH_INTERVAL); + } last_sync_cycle = context->current_cycle; #endif return context; |