Merge git://github.com/notaz/pcsx_rearmed
[pcsx_rearmed.git] / plugins / dfsound / dma.c
... / ...
CommitLineData
1/***************************************************************************\r
2 dma.c - description\r
3 -------------------\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
9 * *\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
15 * *\r
16 ***************************************************************************/\r
17\r
18#include "stdafx.h"\r
19\r
20#define _IN_DMA\r
21\r
22#include "externals.h"\r
23\r
24////////////////////////////////////////////////////////////////////////\r
25// READ DMA (one value)\r
26////////////////////////////////////////////////////////////////////////\r
27\r
28unsigned short CALLBACK SPUreadDMA(void)\r
29{\r
30 unsigned short s=spuMem[spuAddr>>1];\r
31 spuAddr+=2;\r
32 if(spuAddr>0x7ffff) spuAddr=0;\r
33\r
34 return s;\r
35}\r
36\r
37////////////////////////////////////////////////////////////////////////\r
38// READ DMA (many values)\r
39////////////////////////////////////////////////////////////////////////\r
40\r
41void CALLBACK SPUreadDMAMem(unsigned short * pusPSXMem,int iSize)\r
42{\r
43 int i;\r
44\r
45 for(i=0;i<iSize;i++)\r
46 {\r
47 *pusPSXMem++=spuMem[spuAddr>>1]; // spu addr got by writeregister\r
48 spuAddr+=2; // inc spu addr\r
49 if(spuAddr>0x7ffff) spuAddr=0; // wrap\r
50 }\r
51}\r
52\r
53////////////////////////////////////////////////////////////////////////\r
54////////////////////////////////////////////////////////////////////////\r
55////////////////////////////////////////////////////////////////////////\r
56\r
57// to investigate: do sound data updates by writedma affect spu\r
58// irqs? Will an irq be triggered, if new data is written to\r
59// the memory irq address?\r
60\r
61////////////////////////////////////////////////////////////////////////\r
62// WRITE DMA (one value)\r
63////////////////////////////////////////////////////////////////////////\r
64 \r
65void CALLBACK SPUwriteDMA(unsigned short val)\r
66{\r
67 spuMem[spuAddr>>1] = val; // spu addr got by writeregister\r
68\r
69 spuAddr+=2; // inc spu addr\r
70 if(spuAddr>0x7ffff) spuAddr=0; // wrap\r
71}\r
72\r
73////////////////////////////////////////////////////////////////////////\r
74// WRITE DMA (many values)\r
75////////////////////////////////////////////////////////////////////////\r
76\r
77void CALLBACK SPUwriteDMAMem(unsigned short * pusPSXMem,int iSize)\r
78{\r
79 int i;\r
80 \r
81 had_dma = 1;\r
82\r
83 if(spuAddr + iSize*2 < 0x80000)\r
84 {\r
85 memcpy(&spuMem[spuAddr>>1], pusPSXMem, iSize*2);\r
86 spuAddr += iSize*2;\r
87 return;\r
88 }\r
89\r
90 for(i=0;i<iSize;i++)\r
91 {\r
92 spuMem[spuAddr>>1] = *pusPSXMem++; // spu addr got by writeregister\r
93 spuAddr+=2; // inc spu addr\r
94 spuAddr&=0x7ffff; // wrap\r
95 }\r
96}\r
97\r
98////////////////////////////////////////////////////////////////////////\r