Mercurial > repos > blastem
comparison blastem.c @ 450:3758bcdae5de
Fix bug that caused a DMA fill to start after another DMA operation completed if the FIFO is not empty
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 01 Sep 2013 12:11:28 -0700 |
parents | e730fc040169 |
children | 608815ab4ff2 |
comparison
equal
deleted
inserted
replaced
448:e85a107e6ec0 | 450:3758bcdae5de |
---|---|
217 gen->ym->current_cycle -= mclks_per_frame; | 217 gen->ym->current_cycle -= mclks_per_frame; |
218 gen->psg->cycles -= mclks_per_frame; | 218 gen->psg->cycles -= mclks_per_frame; |
219 if (gen->ym->write_cycle != CYCLE_NEVER) { | 219 if (gen->ym->write_cycle != CYCLE_NEVER) { |
220 gen->ym->write_cycle = gen->ym->write_cycle >= mclks_per_frame/MCLKS_PER_68K ? gen->ym->write_cycle - mclks_per_frame/MCLKS_PER_68K : 0; | 220 gen->ym->write_cycle = gen->ym->write_cycle >= mclks_per_frame/MCLKS_PER_68K ? gen->ym->write_cycle - mclks_per_frame/MCLKS_PER_68K : 0; |
221 } | 221 } |
222 //printf("reached frame end | 68K Cycles: %d, MCLK Cycles: %d\n", context->current_cycle, mclks); | 222 printf("reached frame end | 68K Cycles: %d, MCLK Cycles: %d\n", context->current_cycle, mclks); |
223 vdp_run_context(v_context, mclks_per_frame); | 223 vdp_run_context(v_context, mclks_per_frame); |
224 | 224 |
225 if (!headless) { | 225 if (!headless) { |
226 break_on_sync |= wait_render_frame(v_context, frame_limit); | 226 break_on_sync |= wait_render_frame(v_context, frame_limit); |
227 } | 227 } |
282 while (vdp_data_port_write(v_context, value) < 0) { | 282 while (vdp_data_port_write(v_context, value) < 0) { |
283 while(v_context->flags & FLAG_DMA_RUN) { | 283 while(v_context->flags & FLAG_DMA_RUN) { |
284 vdp_run_dma_done(v_context, mclks_per_frame); | 284 vdp_run_dma_done(v_context, mclks_per_frame); |
285 if (v_context->cycles >= mclks_per_frame) { | 285 if (v_context->cycles >= mclks_per_frame) { |
286 if (!headless) { | 286 if (!headless) { |
287 printf("reached frame end | 68K Cycles: %d, MCLK Cycles: %d\n", context->current_cycle, v_context->cycles); | |
287 wait_render_frame(v_context, frame_limit); | 288 wait_render_frame(v_context, frame_limit); |
288 } | 289 } |
289 vdp_adjust_cycles(v_context, mclks_per_frame); | 290 vdp_adjust_cycles(v_context, mclks_per_frame); |
290 genesis_context * gen = context->system; | 291 genesis_context * gen = context->system; |
291 io_adjust_cycles(gen->ports, v_context->cycles/MCLKS_PER_68K, mclks_per_frame/MCLKS_PER_68K); | 292 io_adjust_cycles(gen->ports, v_context->cycles/MCLKS_PER_68K, mclks_per_frame/MCLKS_PER_68K); |
299 busack = new_busack; | 300 busack = new_busack; |
300 } | 301 } |
301 } | 302 } |
302 } | 303 } |
303 } | 304 } |
304 context->current_cycle = v_context->cycles / MCLKS_PER_68K; | 305 //context->current_cycle = v_context->cycles / MCLKS_PER_68K; |
305 } | 306 } |
306 } else if(vdp_port < 8) { | 307 } else if(vdp_port < 8) { |
307 blocked = vdp_control_port_write(v_context, value); | 308 blocked = vdp_control_port_write(v_context, value); |
308 if (blocked) { | 309 if (blocked) { |
309 while (blocked) { | 310 while (blocked) { |
341 } else { | 342 } else { |
342 printf("Illegal write to HV Counter port %X\n", vdp_port); | 343 printf("Illegal write to HV Counter port %X\n", vdp_port); |
343 exit(1); | 344 exit(1); |
344 } | 345 } |
345 if (v_context->cycles != before_cycle) { | 346 if (v_context->cycles != before_cycle) { |
347 printf("68K paused for %d cycles at cycle %d\n", v_context->cycles / MCLKS_PER_68K - context->current_cycle, context->current_cycle); | |
346 context->current_cycle = v_context->cycles / MCLKS_PER_68K; | 348 context->current_cycle = v_context->cycles / MCLKS_PER_68K; |
347 } | 349 } |
348 } else if (vdp_port < 0x18) { | 350 } else if (vdp_port < 0x18) { |
349 genesis_context * gen = context->system; | 351 genesis_context * gen = context->system; |
350 sync_sound(gen, context->current_cycle * MCLKS_PER_68K); | 352 sync_sound(gen, context->current_cycle * MCLKS_PER_68K); |