# HG changeset patch # User Michael Pavone # Date 1489882154 25200 # Node ID 76e47254596bda5bf982890bc0232ee04444dced # Parent 82838d4c84d94a15dae83712fa1adb7487657c47 Remove hacky post-DMA delay add proper pre-DMA delay based on logic analyzer capture. 512 color screen is a bit messed up but mostly works. Needs investigation diff -r 82838d4c84d9 -r 76e47254596b genesis.c --- a/genesis.c Fri Mar 17 08:05:55 2017 -0700 +++ b/genesis.c Sat Mar 18 17:09:14 2017 -0700 @@ -296,12 +296,6 @@ sync_components(context, 0); gen->bus_busy = 0; } - if (!(v_context->flags & FLAG_DMA_RUN)) { - //two more slots of delay are needed to kill sufficient sprite capacity in Overdrive - //TODO: Measure exact value with logic analyzer - vdp_run_context(v_context, v_context->cycles + 1); - vdp_run_context(v_context, v_context->cycles + 1); - } } if (blocked < 0) { diff -r 82838d4c84d9 -r 76e47254596b vdp.c --- a/vdp.c Fri Mar 17 08:05:55 2017 -0700 +++ b/vdp.c Sat Mar 18 17:09:14 2017 -0700 @@ -2482,13 +2482,16 @@ // if((context->regs[REG_DMASRC_H] & 0xC0) != 0x80) { //DMA copy or 68K -> VDP, transfer starts immediately - context->flags |= FLAG_DMA_RUN; context->dma_cd = context->cd; //printf("DMA start (length: %X) at cycle %d, frame: %d, vcounter: %d, hslot: %d\n", (context->regs[REG_DMALEN_H] << 8) | context->regs[REG_DMALEN_L], context->cycles, context->frame, context->vcounter, context->hslot); if (!(context->regs[REG_DMASRC_H] & 0x80)) { //printf("DMA Address: %X, New CD: %X, Source: %X, Length: %X\n", context->address, context->cd, (context->regs[REG_DMASRC_H] << 17) | (context->regs[REG_DMASRC_M] << 9) | (context->regs[REG_DMASRC_L] << 1), context->regs[REG_DMALEN_H] << 8 | context->regs[REG_DMALEN_L]); + //68K -> VDP DMA takes 4 slots to actually start reading even though it acquires the bus immediately + vdp_run_context(context, context->cycles + 16 * ((context->regs[REG_MODE_2] & BIT_MODE_5) && (context->regs[REG_MODE_4] & BIT_H40) ? 4 : 5)); + context->flags |= FLAG_DMA_RUN; return 1; } else { + context->flags |= FLAG_DMA_RUN; //printf("DMA Copy Address: %X, New CD: %X, Source: %X\n", context->address, context->cd, (context->regs[REG_DMASRC_M] << 8) | context->regs[REG_DMASRC_L]); } } else {