X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=blobdiff_plain;f=plugins%2Fdfsound%2Fdma.c;h=43019f1d9fccc059bd0be630f50d224d527a9ab4;hp=13f9c269f6525e4b4cb58a1aff46d4737f192b7b;hb=HEAD;hpb=c2eee46bfb8a3fde297735a8b115330498d442b4 diff --git a/plugins/dfsound/dma.c b/plugins/dfsound/dma.c index 13f9c269..fde1f835 100644 --- a/plugins/dfsound/dma.c +++ b/plugins/dfsound/dma.c @@ -51,8 +51,8 @@ void CALLBACK SPUreadDMAMem(unsigned short *pusPSXMem, int iSize, addr &= 0x7fffe; } if ((spu.spuCtrl & CTRL_IRQ) && irq_after < iSize * 2) { - log_unhandled("rdma spu irq: %x/%x+%x\n", irq_addr, spu.spuAddr, iSize * 2); - spu.irqCallback(irq_after); + log_unhandled("rdma spu irq: %x/%x-%x\n", irq_addr, spu.spuAddr, addr); + do_irq_io(irq_after); } spu.spuAddr = addr; set_dma_end(iSize, cycles); @@ -68,7 +68,7 @@ void CALLBACK SPUwriteDMAMem(unsigned short *pusPSXMem, int iSize, unsigned int addr = spu.spuAddr, irq_addr = regAreaGet(H_SPUirqAddr) << 3; int i, irq_after; - do_samples_if_needed(cycles, 1, 2); + do_samples_if_needed(cycles + iSize*2 * 4, 1, 2); irq_after = (irq_addr - addr) & 0x7ffff; spu.bMemDirty = 1; @@ -87,11 +87,28 @@ void CALLBACK SPUwriteDMAMem(unsigned short *pusPSXMem, int iSize, } } if ((spu.spuCtrl & CTRL_IRQ) && irq_after < iSize * 2) { - log_unhandled("wdma spu irq: %x/%x+%x (%u)\n", - irq_addr, spu.spuAddr, iSize * 2, irq_after); + log_unhandled("%u wdma spu irq: %x/%x-%x (%u)\n", + cycles, irq_addr, spu.spuAddr, addr, irq_after); // this should be consistent with psxdma.c timing // might also need more delay like in set_dma_end() - spu.irqCallback(irq_after); + do_irq_io(irq_after * 4); + } + for (i = 0; i < 24; i++) { + size_t ediff, p = spu.s_chan[i].pCurr - spu.spuMemC; + if (spu.s_chan[i].ADSRX.State == ADSR_RELEASE && !spu.s_chan[i].ADSRX.EnvelopeVol) + continue; + ediff = addr - p; + if (spu.spuAddr < p && p < spu.spuAddr + iSize * 2) { + log_unhandled("%u spu ch%02d play %zx dma %x-%x (%zd)\n", + cycles, i, p, spu.spuAddr, addr, ediff); + //exit(1); + } + // a hack for the super annoying timing issues in The Emperor's New Groove + // (which is a game bug, but tends to trigger more here) + if (ediff <= 0x20u) { + spu.s_chan[i].pCurr += ediff; + break; + } } spu.spuAddr = addr; set_dma_end(iSize, cycles);