X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=plugins%2Fdfsound%2Fdma.c;h=fde1f835b54bbf60e0a4e7329ff9e3e68614e3c6;hb=HEAD;hp=ada007f01d9ded25d2fc9f12732a40523ec0fe61;hpb=3c7a8977ddbdbfb4a8840a487fadade29bd939d6;p=pcsx_rearmed.git diff --git a/plugins/dfsound/dma.c b/plugins/dfsound/dma.c index ada007f0..fde1f835 100644 --- a/plugins/dfsound/dma.c +++ b/plugins/dfsound/dma.c @@ -39,10 +39,10 @@ void CALLBACK SPUreadDMAMem(unsigned short *pusPSXMem, int iSize, unsigned int cycles) { unsigned int addr = spu.spuAddr, irq_addr = regAreaGet(H_SPUirqAddr) << 3; - int i, irq; + int i, irq_after; - do_samples_if_needed(cycles, 1); - irq = addr <= irq_addr && irq_addr < addr + iSize*2; + do_samples_if_needed(cycles, 1, 2); + irq_after = (irq_addr - addr) & 0x7ffff; for(i = 0; i < iSize; i++) { @@ -50,8 +50,10 @@ void CALLBACK SPUreadDMAMem(unsigned short *pusPSXMem, int iSize, addr += 2; addr &= 0x7fffe; } - if (irq && (spu.spuCtrl & CTRL_IRQ)) - log_unhandled("rdma spu irq: %x/%x+%x\n", irq_addr, spu.spuAddr, iSize * 2); + if ((spu.spuCtrl & CTRL_IRQ) && irq_after < iSize * 2) { + 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); } @@ -64,11 +66,11 @@ void CALLBACK SPUwriteDMAMem(unsigned short *pusPSXMem, int iSize, unsigned int cycles) { unsigned int addr = spu.spuAddr, irq_addr = regAreaGet(H_SPUirqAddr) << 3; - int i, irq; + int i, irq_after; - do_samples_if_needed(cycles, 1); + do_samples_if_needed(cycles + iSize*2 * 4, 1, 2); + irq_after = (irq_addr - addr) & 0x7ffff; spu.bMemDirty = 1; - irq = addr <= irq_addr && irq_addr < addr + iSize*2; if (addr + iSize*2 < 0x80000) { @@ -77,7 +79,6 @@ void CALLBACK SPUwriteDMAMem(unsigned short *pusPSXMem, int iSize, } else { - irq |= irq_addr < ((addr + iSize*2) & 0x7ffff); for (i = 0; i < iSize; i++) { *(unsigned short *)(spu.spuMemC + addr) = *pusPSXMem++; @@ -85,10 +86,33 @@ void CALLBACK SPUwriteDMAMem(unsigned short *pusPSXMem, int iSize, addr &= 0x7fffe; } } - if (irq && (spu.spuCtrl & CTRL_IRQ)) // unhandled because need to implement delay - log_unhandled("wdma spu irq: %x/%x+%x\n", irq_addr, spu.spuAddr, iSize * 2); + if ((spu.spuCtrl & CTRL_IRQ) && irq_after < iSize * 2) { + 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() + 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); } //////////////////////////////////////////////////////////////////////// +// vim:shiftwidth=1:expandtab