From 58ebb94c13df061762a7aca78e52f066339d9610 Mon Sep 17 00:00:00 2001 From: notaz Date: Thu, 5 Feb 2015 02:29:23 +0200 Subject: [PATCH] dma: do some madr updates untested, but makes ff7 behave better with linked lists (dither problem) --- libpcsxcore/cdrom.c | 3 +-- libpcsxcore/new_dynarec/emu_if.c | 2 +- libpcsxcore/psxdma.c | 44 +++++++++++++++++++++----------- 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/libpcsxcore/cdrom.c b/libpcsxcore/cdrom.c index 3a2eb1f6..2e6277b8 100644 --- a/libpcsxcore/cdrom.c +++ b/libpcsxcore/cdrom.c @@ -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 ) { diff --git a/libpcsxcore/new_dynarec/emu_if.c b/libpcsxcore/new_dynarec/emu_if.c index 092c8ae9..22db5d11 100644 --- a/libpcsxcore/new_dynarec/emu_if.c +++ b/libpcsxcore/new_dynarec/emu_if.c @@ -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); diff --git a/libpcsxcore/psxdma.c b/libpcsxcore/psxdma.c index ff7d6a3b..b0f3fba4 100644 --- a/libpcsxcore/psxdma.c +++ b/libpcsxcore/psxdma.c @@ -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) -- 2.39.2