/[pcsx2_0.9.7]/trunk/pcsx2/Sif.h
ViewVC logotype

Annotation of /trunk/pcsx2/Sif.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 62 - (hide annotations) (download)
Tue Sep 7 11:08:22 2010 UTC (9 years, 10 months ago) by william
File MIME type: text/plain
File size: 3118 byte(s)
Auto Commited Import of: pcsx2-0.9.7-r3738-debug in ./trunk
1 william 31 /* PCSX2 - PS2 Emulator for PCs
2     * Copyright (C) 2002-2010 PCSX2 Dev Team
3     *
4     * PCSX2 is free software: you can redistribute it and/or modify it under the terms
5     * of the GNU Lesser General Public License as published by the Free Software Found-
6     * ation, either version 3 of the License, or (at your option) any later version.
7     *
8     * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9     * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
10     * PURPOSE. See the GNU General Public License for more details.
11     *
12     * You should have received a copy of the GNU General Public License along with PCSX2.
13     * If not, see <http://www.gnu.org/licenses/>.
14     */
15    
16     #ifndef __SIF_H__
17     #define __SIF_H__
18    
19 william 62 static const int FIFO_SIF_W = 128;
20 william 31
21 william 62 static DMACh& sif0dma = (DMACh&)eeHw[0xc000];
22     static DMACh& sif1dma = (DMACh&)eeHw[0xc400];
23     static DMACh& sif2dma = (DMACh&)eeHw[0xc800];
24    
25    
26 william 31 struct sifData
27     {
28     s32 data;
29     s32 words;
30     s32 count; // I think this is unused.
31     s32 addr; // This too.
32     };
33    
34     struct sifFifo
35     {
36     u32 data[FIFO_SIF_W];
37     s32 readPos;
38     s32 writePos;
39     s32 size;
40    
41     s32 free()
42     {
43     return FIFO_SIF_W - size;
44     }
45    
46     void write(u32 *from, int words)
47     {
48     if (words > 0)
49     {
50     const int wP0 = min((FIFO_SIF_W - writePos), words);
51     const int wP1 = words - wP0;
52    
53     memcpy_fast(&data[writePos], from, wP0 << 2);
54     memcpy_fast(&data[0], &from[wP0], wP1 << 2);
55    
56     writePos = (writePos + words) & (FIFO_SIF_W - 1);
57     size += words;
58     }
59     SIF_LOG(" SIF + %d = %d (pos=%d)", words, size, writePos);
60     }
61    
62     void read(u32 *to, int words)
63     {
64     if (words > 0)
65     {
66     const int wP0 = min((FIFO_SIF_W - readPos), words);
67     const int wP1 = words - wP0;
68    
69     memcpy_fast(to, &data[readPos], wP0 << 2);
70     memcpy_fast(&to[wP0], &data[0], wP1 << 2);
71    
72     readPos = (readPos + words) & (FIFO_SIF_W - 1);
73     size -= words;
74     }
75     SIF_LOG(" SIF - %d = %d (pos=%d)", words, size, readPos);
76     }
77     void clear()
78     {
79     memzero(data);
80     readPos = 0;
81     writePos = 0;
82     size = 0;
83     }
84     };
85    
86     struct old_sif_structure
87     {
88     sifFifo fifo; // Used in both.
89     s32 chain; // Not used.
90     s32 end; // Only used for EE.
91     s32 tagMode; // No longer used.
92     s32 counter; // Used to keep track of how much is left in IOP.
93     struct sifData data; // Only used in IOP.
94     };
95    
96     struct sif_ee
97     {
98     bool end; // Only used for EE.
99     bool busy;
100    
101     s32 cycles;
102     };
103     struct sif_iop
104     {
105     bool end;
106     bool busy;
107    
108     s32 cycles;
109    
110     s32 counter; // Used to keep track of how much is left in IOP.
111     struct sifData data; // Only used in IOP.
112     };
113     struct _sif
114     {
115     sifFifo fifo; // Used in both.
116     sif_ee ee;
117     sif_iop iop;
118     };
119    
120     extern _sif sif0, sif1;
121    
122     extern void sifInit();
123    
124     extern void SIF0Dma();
125     extern void SIF1Dma();
126    
127     extern void dmaSIF0();
128     extern void dmaSIF1();
129     extern void dmaSIF2();
130    
131     extern void EEsif0Interrupt();
132     extern void EEsif1Interrupt();
133    
134     extern void sif0Interrupt();
135     extern void sif1Interrupt();
136    
137     #define sif0data sif0.iop.data.data
138     #define sif1data sif1.iop.data.data
139    
140     #define sif0words sif0.iop.data.words
141     #define sif1words sif1.iop.data.words
142    
143     #define sif0tag DMA_TAG(sif0data)
144     #define sif1tag DMA_TAG(sif1data)
145    
146     #endif /* __SIF_H__ */

  ViewVC Help
Powered by ViewVC 1.1.22