comparison genesis.c @ 1374:8f404b1fa572

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)
author Michael Pavone <pavone@retrodev.com>
date Tue, 23 May 2017 23:47:40 -0700
parents 7cfc9d532e34
children e587f16e7d3d
comparison
equal deleted inserted replaced
1373:7cfc9d532e34 1374:8f404b1fa572
281 last_sync_cycle = context->current_cycle; 281 last_sync_cycle = context->current_cycle;
282 #endif 282 #endif
283 sync_components(context, 0); 283 sync_components(context, 0);
284 genesis_context * gen = context->system; 284 genesis_context * gen = context->system;
285 vdp_context *v_context = gen->vdp; 285 vdp_context *v_context = gen->vdp;
286 uint32_t before_cycle = v_context->cycles;
286 if (vdp_port < 0x10) { 287 if (vdp_port < 0x10) {
287 int blocked; 288 int blocked;
288 uint32_t before_cycle = v_context->cycles;
289 if (vdp_port < 4) { 289 if (vdp_port < 4) {
290 while (vdp_data_port_write(v_context, value) < 0) { 290 while (vdp_data_port_write(v_context, value) < 0) {
291 while(v_context->flags & FLAG_DMA_RUN) { 291 while(v_context->flags & FLAG_DMA_RUN) {
292 vdp_run_dma_done(v_context, gen->frame_end); 292 vdp_run_dma_done(v_context, gen->frame_end);
293 if (v_context->cycles >= gen->frame_end) { 293 if (v_context->cycles >= gen->frame_end) {
359 } 359 }
360 #ifdef REFRESH_EMULATION 360 #ifdef REFRESH_EMULATION
361 last_sync_cycle -= 4; 361 last_sync_cycle -= 4;
362 //refresh may have happened while we were waiting on the VDP, 362 //refresh may have happened while we were waiting on the VDP,
363 //so advance refresh_counter but don't add any delays 363 //so advance refresh_counter but don't add any delays
364 refresh_counter += (context->current_cycle - last_sync_cycle); 364 if (vdp_port >= 4 && vdp_port < 8 && v_context->cycles != before_cycle) {
365 refresh_counter = refresh_counter % (MCLKS_PER_68K * REFRESH_INTERVAL); 365 refresh_counter = 0;
366 } else {
367 refresh_counter += (context->current_cycle - last_sync_cycle);
368 refresh_counter = refresh_counter % (MCLKS_PER_68K * REFRESH_INTERVAL);
369 }
366 last_sync_cycle = context->current_cycle; 370 last_sync_cycle = context->current_cycle;
367 #endif 371 #endif
368 return context; 372 return context;
369 } 373 }
370 374