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

Contents of /trunk/pcsx2/Gif.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 31 - (show annotations) (download)
Tue Sep 7 03:24:11 2010 UTC (9 years, 10 months ago) by william
File MIME type: text/plain
File size: 6394 byte(s)
committing r3113 initial commit again...
1 /* 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 __GIF_H__
17 #define __GIF_H__
18
19 enum gifstate_t
20 {
21 GIF_STATE_READY = 0,
22 GIF_STATE_STALL = 1,
23 GIF_STATE_DONE = 2,
24 GIF_STATE_EMPTY = 0x10
25 };
26
27 enum GSTransferModes //0 = Image Mode (DirectHL), 1 = transferring, 2 = Stopped at End of Packet
28 {
29 IMAGE_MODE = 0,
30 TRANSFER_MODE = 1,
31 STOPPED_MODE = 2
32 };
33
34 union tGSTransferStatus {
35 struct {
36 u32 PTH1 : 2; // Resets Vif(0/1) when written.
37 u32 PTH2 : 2; // Causes a Forcebreak to Vif((0/1) when true. (Stall)
38 u32 PTH3 : 2; // Stops after the end of the Vifcode in progress when true. (Stall)
39 u32 reserved : 26;
40 };
41 u32 _u32;
42
43 tGSTransferStatus(u32 val) { _u32 = val; }
44 bool test (u32 flags) const { return !!(_u32 & flags); }
45 void set_flags (u32 flags) { _u32 |= flags; }
46 void clear_flags(u32 flags) { _u32 &= ~flags; }
47 void reset() { _u32 = 0; }
48 wxString desc() const { return wxsFormat(L"GSTransferStatus.PTH3: 0x%x", _u32); }
49 };
50 //GIF_STAT
51 enum gif_stat_flags
52 {
53 GIF_STAT_M3R = (1), // GIF_MODE Mask
54 GIF_STAT_M3P = (1<<1), // VIF PATH3 Mask
55 GIF_STAT_IMT = (1<<2), // Intermittent Transfer Mode
56 GIF_STAT_PSE = (1<<3), // Temporary Transfer Stop
57 GIF_STAT_IP3 = (1<<5), // Interrupted PATH3
58 GIF_STAT_P3Q = (1<<6), // PATH3 request Queued
59 GIF_STAT_P2Q = (1<<7), // PATH2 request Queued
60 GIF_STAT_P1Q = (1<<8), // PATH1 request Queued
61 GIF_STAT_OPH = (1<<9), // Output Path (Outputting Data)
62 GIF_STAT_APATH1 = (1<<10), // Data Transfer Path 1 (In progress)
63 GIF_STAT_APATH2 = (2<<10), // Data Transfer Path 2 (In progress)
64 GIF_STAT_APATH3 = (3<<10), // Data Transfer Path 3 (In progress) (Mask too)
65 GIF_STAT_DIR = (1<<12), // Transfer Direction
66 GIF_STAT_FQC = (31<<24) // QWC in GIF-FIFO
67 };
68
69 enum gif_mode_flags
70 {
71 GIF_MODE_M3R = (1),
72 GIF_MODE_IMT = (1<<2)
73 };
74
75 union tGIF_CTRL
76 {
77 struct
78 {
79 u32 RST : 1;
80 u32 reserved1 : 2;
81 u32 PSE : 1;
82 u32 reserved2 : 28;
83 };
84 u32 _u32;
85
86 tGIF_CTRL(u32 val) { _u32 = val; }
87
88 bool test(u32 flags) { return !!(_u32 & flags); }
89 void set_flags(u32 flags) { _u32 |= flags; }
90 void clear_flags(u32 flags) { _u32 &= ~flags; }
91 void reset() { _u32 = 0; }
92 wxString desc() { return wxsFormat(L"Ctrl: 0x%x", _u32); }
93 };
94
95 union tGIF_MODE
96 {
97 struct
98 {
99 u32 M3R : 1;
100 u32 reserved1 : 1;
101 u32 IMT : 1;
102 u32 reserved2 : 29;
103 };
104 u32 _u32;
105
106 tGIF_MODE(u32 val) { _u32 = val; }
107
108 void write(u32 val) { _u32 = val; }
109 bool test(u32 flags) { return !!(_u32 & flags); }
110 void set_flags(u32 flags) { _u32 |= flags; }
111 void clear_flags(u32 flags) { _u32 &= ~flags; }
112 void reset() { _u32 = 0; }
113 wxString desc() { return wxsFormat(L"Mode: 0x%x", _u32); }
114 };
115
116 enum gif_paths
117 {
118 GIF_APATH_IDLE = 0,
119 GIF_APATH1,
120 GIF_APATH2,
121 GIF_APATH3
122 };
123
124 union tGIF_STAT
125 {
126 struct
127 {
128 u32 M3R : 1;
129 u32 M3P : 1;
130 u32 IMT : 1;
131 u32 PSE : 1;
132 u32 reserved1 : 1;
133 u32 IP3 : 1;
134 u32 P3Q : 1;
135 u32 P2Q : 1;
136 u32 P1Q : 1;
137 u32 OPH : 1;
138 u32 APATH : 2;
139 u32 DIR : 1;
140 u32 reserved2 : 11;
141 u32 FQC : 5;
142 u32 reserved3 : 3;
143 };
144 u32 _u32;
145
146 tGIF_STAT(u32 val) { _u32 = val; }
147
148 bool test(u32 flags) { return !!(_u32 & flags); }
149 void set_flags(u32 flags) { _u32 |= flags; }
150 void clear_flags(u32 flags) { _u32 &= ~flags; }
151 void reset() { _u32 = 0; }
152 wxString desc() { return wxsFormat(L"Stat: 0x%x", _u32); }
153 };
154
155 union tGIF_TAG0
156 {
157 struct
158 {
159 u32 NLOOP : 15;
160 u32 EOP : 1;
161 u32 TAG : 16;
162 };
163 u32 _u32;
164
165 tGIF_TAG0(u32 val) { _u32 = val; }
166
167 bool test(u32 flags) { return !!(_u32 & flags); }
168 void set_flags(u32 flags) { _u32 |= flags; }
169 void clear_flags(u32 flags) { _u32 &= ~flags; }
170 void reset() { _u32 = 0; }
171 wxString desc() { return wxsFormat(L"Tag0: 0x%x", _u32); }
172 };
173
174 union tGIF_TAG1
175 {
176 struct
177 {
178 u32 TAG : 14;
179 u32 PRE : 1;
180 u32 PRIM : 11;
181 u32 FLG : 2;
182 u32 NREG : 4;
183 };
184 u32 _u32;
185
186 tGIF_TAG1(u32 val) { _u32 = val; }
187
188 bool test(u32 flags) { return !!(_u32 & flags); }
189 void set_flags(u32 flags) { _u32 |= flags; }
190 void clear_flags(u32 flags) { _u32 &= ~flags; }
191 void reset() { _u32 = 0; }
192 wxString desc() { return wxsFormat(L"Tag1: 0x%x", _u32); }
193 };
194
195 union tGIF_CNT
196 {
197 struct
198 {
199 u32 LOOPCNT : 15;
200 u32 reserved1 : 1;
201 u32 REGCNT : 4;
202 u32 VUADDR : 2;
203 u32 reserved2 : 10;
204
205 };
206 u32 _u32;
207
208 tGIF_CNT(u32 val) { _u32 = val; }
209
210 bool test(u32 flags) { return !!(_u32 & flags); }
211 void set_flags(u32 flags) { _u32 |= flags; }
212 void clear_flags(u32 flags) { _u32 &= ~flags; }
213 void reset() { _u32 = 0; }
214 wxString desc() { return wxsFormat(L"CNT: 0x%x", _u32); }
215 };
216
217 union tGIF_P3CNT
218 {
219 struct
220 {
221 u32 P3CNT : 15;
222 u32 reserved1 : 17;
223 };
224 u32 _u32;
225
226 tGIF_P3CNT(u32 val) { _u32 = val; }
227
228 void reset() { _u32 = 0; }
229 wxString desc() { return wxsFormat(L"P3CNT: 0x%x", _u32); }
230 };
231
232 union tGIF_P3TAG
233 {
234 struct
235 {
236 u32 LOOPCNT : 15;
237 u32 EOP : 1;
238 u32 reserved1 : 16;
239 };
240 u32 _u32;
241
242 tGIF_P3TAG(u32 val) { _u32 = val; }
243
244 bool test(u32 flags) { return !!(_u32 & flags); }
245 void set_flags(u32 flags) { _u32 |= flags; }
246 void clear_flags(u32 flags) { _u32 &= ~flags; }
247 void reset() { _u32 = 0; }
248 wxString desc() { return wxsFormat(L"P3Tag: 0x%x", _u32); }
249 };
250
251 struct GIFregisters
252 {
253 tGIF_CTRL ctrl;
254 u32 padding[3];
255 tGIF_MODE mode;
256 u32 padding1[3];
257 tGIF_STAT stat;
258 u32 padding2[7];
259
260 tGIF_TAG0 tag0;
261 u32 padding3[3];
262 tGIF_TAG1 tag1;
263 u32 padding4[3];
264 u32 tag2;
265 u32 padding5[3];
266 u32 tag3;
267 u32 padding6[3];
268
269 tGIF_CNT cnt;
270 u32 padding7[3];
271 tGIF_P3CNT p3cnt;
272 u32 padding8[3];
273 tGIF_P3TAG p3tag;
274 u32 padding9[3];
275 };
276
277 #define gifRegs ((GIFregisters*)(PS2MEM_HW+0x3000))
278
279 extern tGSTransferStatus GSTransferStatus;
280
281 extern void gsInterrupt();
282 extern int _GIFchain();
283 extern void GIFdma();
284 extern void dmaGIF();
285 extern void mfifoGIFtransfer(int qwc);
286 extern void gifMFIFOInterrupt();
287
288 #endif

  ViewVC Help
Powered by ViewVC 1.1.22