1 /***************************************************************************
\r
4 begin : Wed May 15 2002
\r
5 copyright : (C) 2002 by Pete Bernert
\r
6 email : BlackDove@addcom.de
\r
7 ***************************************************************************/
\r
8 /***************************************************************************
\r
10 * This program is free software; you can redistribute it and/or modify *
\r
11 * it under the terms of the GNU General Public License as published by *
\r
12 * the Free Software Foundation; either version 2 of the License, or *
\r
13 * (at your option) any later version. See also the license.txt file for *
\r
14 * additional informations. *
\r
16 ***************************************************************************/
\r
22 #include "externals.h"
\r
23 #include "registers.h"
\r
25 ////////////////////////////////////////////////////////////////////////
\r
26 // READ DMA (one value)
\r
27 ////////////////////////////////////////////////////////////////////////
\r
29 unsigned short CALLBACK SPUreadDMA(void)
\r
31 unsigned short s = *(unsigned short *)(spu.spuMemC + spu.spuAddr);
\r
32 check_irq_io(spu.spuAddr);
\r
34 spu.spuAddr &= 0x7fffe;
\r
39 ////////////////////////////////////////////////////////////////////////
\r
40 // READ DMA (many values)
\r
41 ////////////////////////////////////////////////////////////////////////
\r
43 void CALLBACK SPUreadDMAMem(unsigned short *pusPSXMem, int iSize,
\r
44 unsigned int cycles)
\r
46 unsigned int addr = spu.spuAddr, irq_addr = regAreaGet(H_SPUirqAddr) << 3;
\r
49 do_samples_if_needed(cycles, 1);
\r
50 irq = addr <= irq_addr && irq_addr < addr + iSize*2;
\r
52 for(i = 0; i < iSize; i++)
\r
54 *pusPSXMem++ = *(unsigned short *)(spu.spuMemC + addr);
\r
58 if (irq && (spu.spuCtrl & CTRL_IRQ))
\r
59 log_unhandled("rdma spu irq: %x/%x+%x\n", irq_addr, spu.spuAddr, iSize * 2);
\r
63 ////////////////////////////////////////////////////////////////////////
\r
64 ////////////////////////////////////////////////////////////////////////
\r
65 ////////////////////////////////////////////////////////////////////////
\r
67 ////////////////////////////////////////////////////////////////////////
\r
68 // WRITE DMA (one value)
\r
69 ////////////////////////////////////////////////////////////////////////
\r
71 void CALLBACK SPUwriteDMA(unsigned short val)
\r
73 *(unsigned short *)(spu.spuMemC + spu.spuAddr) = val;
\r
75 check_irq_io(spu.spuAddr);
\r
77 spu.spuAddr &= 0x7fffe;
\r
81 ////////////////////////////////////////////////////////////////////////
\r
82 // WRITE DMA (many values)
\r
83 ////////////////////////////////////////////////////////////////////////
\r
85 void CALLBACK SPUwriteDMAMem(unsigned short *pusPSXMem, int iSize,
\r
86 unsigned int cycles)
\r
88 unsigned int addr = spu.spuAddr, irq_addr = regAreaGet(H_SPUirqAddr) << 3;
\r
91 do_samples_if_needed(cycles, 1);
\r
93 irq = addr <= irq_addr && irq_addr < addr + iSize*2;
\r
95 if (addr + iSize*2 < 0x80000)
\r
97 memcpy(spu.spuMemC + addr, pusPSXMem, iSize*2);
\r
102 irq |= irq_addr < ((addr + iSize*2) & 0x7ffff);
\r
103 for (i = 0; i < iSize; i++)
\r
105 *(unsigned short *)(spu.spuMemC + addr) = *pusPSXMem++;
\r
110 if (irq && (spu.spuCtrl & CTRL_IRQ)) // unhandled because need to implement delay
\r
111 log_unhandled("wdma spu irq: %x/%x+%x\n", irq_addr, spu.spuAddr, iSize * 2);
\r
112 spu.spuAddr = addr;
\r
115 ////////////////////////////////////////////////////////////////////////
\r