#define _IN_DMA\r
\r
#include "externals.h"\r
+#include "registers.h"\r
\r
////////////////////////////////////////////////////////////////////////\r
// READ DMA (one value)\r
unsigned short CALLBACK SPUreadDMA(void)\r
{\r
unsigned short s = *(unsigned short *)(spu.spuMemC + spu.spuAddr);\r
+ check_irq_io(spu.spuAddr);\r
spu.spuAddr += 2;\r
spu.spuAddr &= 0x7fffe;\r
\r
void CALLBACK SPUreadDMAMem(unsigned short *pusPSXMem, int iSize,\r
unsigned int cycles)\r
{\r
- int i;\r
+ unsigned int addr = spu.spuAddr, irq_addr = regAreaGet(H_SPUirqAddr) << 3;\r
+ int i, irq;\r
\r
do_samples_if_needed(cycles, 1);\r
-\r
- for(i=0;i<iSize;i++)\r
- {\r
- *pusPSXMem++ = *(unsigned short *)(spu.spuMemC + spu.spuAddr);\r
- spu.spuAddr += 2;\r
- spu.spuAddr &= 0x7fffe;\r
- }\r
+ irq = addr <= irq_addr && irq_addr < addr + iSize*2;\r
+\r
+ for(i = 0; i < iSize; i++)\r
+ {\r
+ *pusPSXMem++ = *(unsigned short *)(spu.spuMemC + addr);\r
+ addr += 2;\r
+ addr &= 0x7fffe;\r
+ }\r
+ if (irq && (spu.spuCtrl & CTRL_IRQ))\r
+ log_unhandled("rdma spu irq: %x/%x+%x\n", irq_addr, spu.spuAddr, iSize * 2);\r
+ spu.spuAddr = addr;\r
}\r
\r
////////////////////////////////////////////////////////////////////////\r
////////////////////////////////////////////////////////////////////////\r
////////////////////////////////////////////////////////////////////////\r
\r
-// to investigate: do sound data updates by writedma affect spu\r
-// irqs? Will an irq be triggered, if new data is written to\r
-// the memory irq address?\r
-\r
////////////////////////////////////////////////////////////////////////\r
// WRITE DMA (one value)\r
////////////////////////////////////////////////////////////////////////\r
{\r
*(unsigned short *)(spu.spuMemC + spu.spuAddr) = val;\r
\r
+ check_irq_io(spu.spuAddr);\r
spu.spuAddr += 2;\r
spu.spuAddr &= 0x7fffe;\r
spu.bMemDirty = 1;\r
void CALLBACK SPUwriteDMAMem(unsigned short *pusPSXMem, int iSize,\r
unsigned int cycles)\r
{\r
- int i;\r
+ unsigned int addr = spu.spuAddr, irq_addr = regAreaGet(H_SPUirqAddr) << 3;\r
+ int i, irq;\r
\r
do_samples_if_needed(cycles, 1);\r
spu.bMemDirty = 1;\r
-\r
- if(spu.spuAddr + iSize*2 < 0x80000)\r
- {\r
- memcpy(spu.spuMemC + spu.spuAddr, pusPSXMem, iSize*2);\r
- spu.spuAddr += iSize*2;\r
- return;\r
- }\r
-\r
- for(i=0;i<iSize;i++)\r
+ irq = addr <= irq_addr && irq_addr < addr + iSize*2;\r
+\r
+ if (addr + iSize*2 < 0x80000)\r
+ {\r
+ memcpy(spu.spuMemC + addr, pusPSXMem, iSize*2);\r
+ addr += iSize*2;\r
+ }\r
+ else\r
+ {\r
+ irq |= irq_addr < ((addr + iSize*2) & 0x7ffff);\r
+ for (i = 0; i < iSize; i++)\r
{\r
- *(unsigned short *)(spu.spuMemC + spu.spuAddr) = *pusPSXMem++;\r
- spu.spuAddr += 2;\r
- spu.spuAddr &= 0x7fffe;\r
+ *(unsigned short *)(spu.spuMemC + addr) = *pusPSXMem++;\r
+ addr += 2;\r
+ addr &= 0x7fffe;\r
}\r
+ }\r
+ if (irq && (spu.spuCtrl & CTRL_IRQ)) // unhandled because need to implement delay\r
+ log_unhandled("wdma spu irq: %x/%x+%x\n", irq_addr, spu.spuAddr, iSize * 2);\r
+ spu.spuAddr = addr;\r
}\r
\r
////////////////////////////////////////////////////////////////////////\r
static int check_irq(int ch, unsigned char *pos)
{
- if((spu.spuCtrl & CTRL_IRQ) && pos == spu.pSpuIrq)
+ if((spu.spuCtrl & (CTRL_ON|CTRL_IRQ)) == (CTRL_ON|CTRL_IRQ) && pos == spu.pSpuIrq)
{
//printf("ch%d irq %04x\n", ch, pos - spu.spuMemC);
do_irq();
return 0;
}
+void check_irq_io(unsigned int addr)
+{
+ unsigned int irq_addr = regAreaGet(H_SPUirqAddr) << 3;
+ //addr &= ~7; // ?
+ if((spu.spuCtrl & (CTRL_ON|CTRL_IRQ)) == (CTRL_ON|CTRL_IRQ) && addr == irq_addr)
+ {
+ //printf("io irq %04x\n", irq_addr);
+ do_irq();
+ }
+}
+
////////////////////////////////////////////////////////////////////////
// START SOUND... called by main thread to setup a new sound on a channel
////////////////////////////////////////////////////////////////////////
do_irq();
}
}
+ check_irq_io(spu.spuAddr);
if (unlikely(spu.rvb->dirty))
REVERBPrep();