Mercurial > repos > blastem
diff blastem.c @ 508:b976c6d6e5fb
Initial attempt at emulating extended bank area access delays when 68K bus is busy with VDP stuff. Also emulate the extra delay on the second access of a word-wide read to the bank area. Needs work as it seems to break stuff.
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 03 Feb 2014 09:18:10 -0800 |
parents | b7b7a1cab44a |
children | a277de8c1a18 |
line wrap: on
line diff
--- a/blastem.c Tue Jan 28 08:36:06 2014 -0800 +++ b/blastem.c Mon Feb 03 09:18:10 2014 -0800 @@ -312,10 +312,12 @@ //printf("vdp_port write: %X, value: %X, cycle: %d\n", vdp_port, value, context->current_cycle); sync_components(context, 0); vdp_context * v_context = context->video_context; + genesis_context * gen = context->system; if (vdp_port < 0x10) { int blocked; uint32_t before_cycle = v_context->cycles; if (vdp_port < 4) { + gen->bus_busy = 1; while (vdp_data_port_write(v_context, value) < 0) { while(v_context->flags & FLAG_DMA_RUN) { vdp_run_dma_done(v_context, mclks_per_frame); @@ -347,6 +349,7 @@ //context->current_cycle = v_context->cycles / MCLKS_PER_68K; } } else if(vdp_port < 8) { + gen->bus_busy = 1; blocked = vdp_control_port_write(v_context, value); if (blocked) { while (blocked) { @@ -394,12 +397,17 @@ context->current_cycle = v_context->cycles / MCLKS_PER_68K; } } else if (vdp_port < 0x18) { - genesis_context * gen = context->system; sync_sound(gen, context->current_cycle * MCLKS_PER_68K); psg_write(gen->psg, value); } else { //TODO: Implement undocumented test register(s) } + if (gen->bus_busy) + { + //Lock the Z80 out of the bus until the VDP access is complete + sync_z80(gen->z80, v_context->cycles); + gen->bus_busy = 0; + } return context; }