dma: do some madr updates
authornotaz <notasas@gmail.com>
Thu, 5 Feb 2015 00:29:23 +0000 (02:29 +0200)
committernotaz <notasas@gmail.com>
Thu, 5 Feb 2015 00:36:19 +0000 (02:36 +0200)
untested, but makes ff7 behave better with linked lists
(dither problem)

libpcsxcore/cdrom.c
libpcsxcore/new_dynarec/emu_if.c
libpcsxcore/psxdma.c

index 3a2eb1f..2e6277b 100644 (file)
@@ -1413,9 +1413,8 @@ void psxDma3(u32 madr, u32 bcr, u32 chcr) {
                        psxCpu->Clear(madr, cdsize / 4);
                        pTransfer += cdsize;
 
-
-                       // burst vs normal
                        if( chcr == 0x11400100 ) {
+                               HW_DMA3_MADR = SWAPu32(madr + cdsize);
                                CDRDMA_INT( (cdsize/4) / 4 );
                        }
                        else if( chcr == 0x11000000 ) {
index 092c8ae..22db5d1 100644 (file)
@@ -378,7 +378,7 @@ static void ari64_clear(u32 addr, u32 size)
 {
        u32 start, end, main_ram;
 
-       size *= 4; /* PCSX uses DMA units */
+       size *= 4; /* PCSX uses DMA units (words) */
 
        evprintf("ari64_clear %08x %04x\n", addr, size);
 
index ff7d6a3..b0f3fba 100644 (file)
@@ -37,7 +37,7 @@ void spuInterrupt() {
 
 void psxDma4(u32 madr, u32 bcr, u32 chcr) { // SPU
        u16 *ptr;
-       u32 size;
+       u32 words;
 
        switch (chcr) {
                case 0x01000201: //cpu to spu transfer
@@ -51,8 +51,10 @@ void psxDma4(u32 madr, u32 bcr, u32 chcr) { // SPU
 #endif
                                break;
                        }
-                       SPU_writeDMAMem(ptr, (bcr >> 16) * (bcr & 0xffff) * 2, psxRegs.cycle);
-                       SPUDMA_INT((bcr >> 16) * (bcr & 0xffff) / 2);
+                       words = (bcr >> 16) * (bcr & 0xffff);
+                       SPU_writeDMAMem(ptr, words * 2, psxRegs.cycle);
+                       HW_DMA4_MADR = SWAPu32(madr + words * 4);
+                       SPUDMA_INT(words / 2);
                        return;
 
                case 0x01000200: //spu to cpu transfer
@@ -66,10 +68,13 @@ void psxDma4(u32 madr, u32 bcr, u32 chcr) { // SPU
 #endif
                                break;
                        }
-                       size = (bcr >> 16) * (bcr & 0xffff) * 2;
-                       SPU_readDMAMem(ptr, size, psxRegs.cycle);
-                       psxCpu->Clear(madr, size);
-                       break;
+                       words = (bcr >> 16) * (bcr & 0xffff);
+                       SPU_readDMAMem(ptr, words * 2, psxRegs.cycle);
+                       psxCpu->Clear(madr, words);
+
+                       HW_DMA4_MADR = SWAPu32(madr + words * 4);
+                       SPUDMA_INT(words / 2);
+                       return;
 
 #ifdef PSXDMA_LOG
                default:
@@ -124,6 +129,7 @@ static u32 gpuDmaChainSize(u32 addr) {
 
 void psxDma2(u32 madr, u32 bcr, u32 chcr) { // GPU
        u32 *ptr;
+       u32 words;
        u32 size;
 
        switch (chcr) {
@@ -139,12 +145,14 @@ void psxDma2(u32 madr, u32 bcr, u32 chcr) { // GPU
                                break;
                        }
                        // BA blocks * BS words (word = 32-bits)
-                       size = (bcr >> 16) * (bcr & 0xffff);
-                       GPU_readDataMem(ptr, size);
-                       psxCpu->Clear(madr, size);
+                       words = (bcr >> 16) * (bcr & 0xffff);
+                       GPU_readDataMem(ptr, words);
+                       psxCpu->Clear(madr, words);
+
+                       HW_DMA2_MADR = SWAPu32(madr + words * 4);
 
                        // already 32-bit word size ((size * 4) / 4)
-                       GPUDMA_INT(size / 4);
+                       GPUDMA_INT(words / 4);
                        return;
 
                case 0x01000201: // mem2vram
@@ -159,11 +167,13 @@ void psxDma2(u32 madr, u32 bcr, u32 chcr) { // GPU
                                break;
                        }
                        // BA blocks * BS words (word = 32-bits)
-                       size = (bcr >> 16) * (bcr & 0xffff);
-                       GPU_writeDataMem(ptr, size);
+                       words = (bcr >> 16) * (bcr & 0xffff);
+                       GPU_writeDataMem(ptr, words);
+
+                       HW_DMA2_MADR = SWAPu32(madr + words * 4);
 
                        // already 32-bit word size ((size * 4) / 4)
-                       GPUDMA_INT(size / 4);
+                       GPUDMA_INT(words / 4);
                        return;
 
                case 0x01000401: // dma chain
@@ -175,7 +185,11 @@ void psxDma2(u32 madr, u32 bcr, u32 chcr) { // GPU
                        if ((int)size <= 0)
                                size = gpuDmaChainSize(madr);
                        HW_GPU_STATUS &= ~PSXGPU_nBUSY;
-                       
+
+                       // we don't emulate progress, just busy flag and end irq,
+                       // so pretend we're already at the last block
+                       HW_DMA2_MADR = SWAPu32(0xffffff);
+
                        // Tekken 3 = use 1.0 only (not 1.5x)
 
                        // Einhander = parse linked list in pieces (todo)