Mercurial > audlegacy-plugins
comparison src/psf2/peops2/dma.c @ 2737:62cc6d667119
Import a bunch of stuff for new psf2 plugin.
author | William Pitcock <nenolod@atheme.org> |
---|---|
date | Mon, 30 Jun 2008 20:20:53 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
2731:324f950774cb | 2737:62cc6d667119 |
---|---|
1 /*************************************************************************** | |
2 dma.c - description | |
3 ------------------- | |
4 begin : Wed May 15 2002 | |
5 copyright : (C) 2002 by Pete Bernert | |
6 email : BlackDove@addcom.de | |
7 ***************************************************************************/ | |
8 | |
9 /*************************************************************************** | |
10 * * | |
11 * This program is free software; you can redistribute it and/or modify * | |
12 * it under the terms of the GNU General Public License as published by * | |
13 * the Free Software Foundation; either version 2 of the License, or * | |
14 * (at your option) any later version. See also the license.txt file for * | |
15 * additional informations. * | |
16 * * | |
17 ***************************************************************************/ | |
18 | |
19 //*************************************************************************// | |
20 // History of changes: | |
21 // | |
22 // 2004/04/04 - Pete | |
23 // - changed plugin to emulate PS2 spu | |
24 // | |
25 // 2002/05/15 - Pete | |
26 // - generic cleanup for the Peops release | |
27 // | |
28 //*************************************************************************// | |
29 | |
30 #include "../peops2/stdafx.h" | |
31 | |
32 #define _IN_DMA | |
33 | |
34 #include "../peops2/externals.h" | |
35 #include "../peops2/registers.h" | |
36 //#include "debug.h" | |
37 | |
38 extern uint32 psx_ram[(2*1024*1024)/4]; | |
39 | |
40 //////////////////////////////////////////////////////////////////////// | |
41 // READ DMA (many values) | |
42 //////////////////////////////////////////////////////////////////////// | |
43 | |
44 EXPORT_GCC void CALLBACK SPU2readDMA4Mem(u32 usPSXMem,int iSize) | |
45 { | |
46 int i; | |
47 u16 *ram16 = (u16 *)&psx_ram[0]; | |
48 | |
49 for(i=0;i<iSize;i++) | |
50 { | |
51 ram16[usPSXMem>>1]=spuMem[spuAddr2[0]]; // spu addr 0 got by writeregister | |
52 usPSXMem+=2; | |
53 spuAddr2[0]++; // inc spu addr | |
54 if(spuAddr2[0]>0xfffff) spuAddr2[0]=0; // wrap | |
55 } | |
56 | |
57 spuAddr2[0]+=0x20; //????? | |
58 | |
59 | |
60 iSpuAsyncWait=0; | |
61 | |
62 // got from J.F. and Kanodin... is it needed? | |
63 regArea[(PS2_C0_ADMAS)>>1]=0; // Auto DMA complete | |
64 spuStat2[0]=0x80; // DMA complete | |
65 } | |
66 | |
67 EXPORT_GCC void CALLBACK SPU2readDMA7Mem(u32 usPSXMem,int iSize) | |
68 { | |
69 int i; | |
70 u16 *ram16 = (u16 *)&psx_ram[0]; | |
71 | |
72 for(i=0;i<iSize;i++) | |
73 { | |
74 ram16[usPSXMem>>1]=spuMem[spuAddr2[1]]; // spu addr 1 got by writeregister | |
75 usPSXMem+=2; | |
76 spuAddr2[1]++; // inc spu addr | |
77 if(spuAddr2[1]>0xfffff) spuAddr2[1]=0; // wrap | |
78 } | |
79 | |
80 spuAddr2[1]+=0x20; //????? | |
81 | |
82 iSpuAsyncWait=0; | |
83 | |
84 // got from J.F. and Kanodin... is it needed? | |
85 regArea[(PS2_C1_ADMAS)>>1]=0; // Auto DMA complete | |
86 spuStat2[1]=0x80; // DMA complete | |
87 } | |
88 | |
89 //////////////////////////////////////////////////////////////////////// | |
90 //////////////////////////////////////////////////////////////////////// | |
91 //////////////////////////////////////////////////////////////////////// | |
92 | |
93 // to investigate: do sound data updates by writedma affect spu | |
94 // irqs? Will an irq be triggered, if new data is written to | |
95 // the memory irq address? | |
96 | |
97 //////////////////////////////////////////////////////////////////////// | |
98 // WRITE DMA (many values) | |
99 //////////////////////////////////////////////////////////////////////// | |
100 | |
101 EXPORT_GCC void CALLBACK SPU2writeDMA4Mem(u32 usPSXMem,int iSize) | |
102 { | |
103 int i; | |
104 u16 *ram16 = (u16 *)&psx_ram[0]; | |
105 | |
106 for(i=0;i<iSize;i++) | |
107 { | |
108 spuMem[spuAddr2[0]] = ram16[usPSXMem>>1]; // spu addr 0 got by writeregister | |
109 usPSXMem+=2; | |
110 spuAddr2[0]++; // inc spu addr | |
111 if(spuAddr2[0]>0xfffff) spuAddr2[0]=0; // wrap | |
112 } | |
113 | |
114 iSpuAsyncWait=0; | |
115 | |
116 // got from J.F. and Kanodin... is it needed? | |
117 spuStat2[0]=0x80; // DMA complete | |
118 } | |
119 | |
120 EXPORT_GCC void CALLBACK SPU2writeDMA7Mem(u32 usPSXMem,int iSize) | |
121 { | |
122 int i; | |
123 u16 *ram16 = (u16 *)&psx_ram[0]; | |
124 | |
125 for(i=0;i<iSize;i++) | |
126 { | |
127 spuMem[spuAddr2[1]] = ram16[usPSXMem>>1]; // spu addr 1 got by writeregister | |
128 spuAddr2[1]++; // inc spu addr | |
129 if(spuAddr2[1]>0xfffff) spuAddr2[1]=0; // wrap | |
130 } | |
131 | |
132 iSpuAsyncWait=0; | |
133 | |
134 // got from J.F. and Kanodin... is it needed? | |
135 spuStat2[1]=0x80; // DMA complete | |
136 } | |
137 | |
138 //////////////////////////////////////////////////////////////////////// | |
139 // INTERRUPTS | |
140 //////////////////////////////////////////////////////////////////////// | |
141 | |
142 void InterruptDMA4(void) | |
143 { | |
144 // taken from linuzappz NULL spu2 | |
145 // spu2Rs16(CORE0_ATTR)&= ~0x30; | |
146 // spu2Rs16(REG__1B0) = 0; | |
147 // spu2Rs16(SPU2_STATX_WRDY_M)|= 0x80; | |
148 | |
149 spuCtrl2[0]&=~0x30; | |
150 regArea[(PS2_C0_ADMAS)>>1]=0; | |
151 spuStat2[0]|=0x80; | |
152 } | |
153 | |
154 EXPORT_GCC void CALLBACK SPU2interruptDMA4(void) | |
155 { | |
156 InterruptDMA4(); | |
157 } | |
158 | |
159 void InterruptDMA7(void) | |
160 { | |
161 // taken from linuzappz NULL spu2 | |
162 // spu2Rs16(CORE1_ATTR)&= ~0x30; | |
163 // spu2Rs16(REG__5B0) = 0; | |
164 // spu2Rs16(SPU2_STATX_DREQ)|= 0x80; | |
165 | |
166 spuCtrl2[1]&=~0x30; | |
167 regArea[(PS2_C1_ADMAS)>>1]=0; | |
168 spuStat2[1]|=0x80; | |
169 } | |
170 | |
171 EXPORT_GCC void CALLBACK SPU2interruptDMA7(void) | |
172 { | |
173 InterruptDMA7(); | |
174 } | |
175 |