Added missing launcher
[mupen64plus-pandora.git] / source / mupen64plus-video-arachnoid / src / UCodeDefs.h
CommitLineData
22726e4d 1/******************************************************************************
2 * Arachnoid Graphics Plugin for Mupen64Plus
3 * http://bitbucket.org/wahrhaft/mupen64plus-video-arachnoid/
4 *
5 * Copyright (C) 2007 Kristofer Karlsson, Rickard Niklasson
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 *****************************************************************************/
21
22#ifndef _UCODE_DEFS_H_
23#define _UCODE_DEFS_H_
24
25//*****************************************************************************
26// Matrices
27//*****************************************************************************
28
29//! Add matrix struct used for example ucode F3D
30struct RSPUCodeAddMatrix0
31{
32 unsigned int length:16; //!< Length
33 unsigned int projection:1; //!< Is this a projection or view matrix?
34 unsigned int load:1; //!< Replace current matrix or multiply with it?
35 unsigned int push:1; //!< Save current matrix in stack?
36 unsigned int :5; //!< Padding
37 unsigned int cmd:8; //!< Command
38 unsigned int segmentAddress; //!< Address to register where there is an RDRAM address used to retrieve matrix
39};
40
41//! Add matrix struct used for example ucode F3DEX2
42#pragma pack(push, 1)
43struct RSPUCodeAddMatrixF3DEX2
44{
45 union
46 {
47 struct
48 {
49 unsigned int param:8; //!< Push?, Load?, Projection?
50 unsigned int len:16; //!< Length
51 };
52 struct
53 {
54 unsigned int nopush:1; //!< Save current matrix in stack?
55 unsigned int load:1; //!< Replace current matrix or multiply with it?
56 unsigned int projection:1; //!< Is this a projection or view matrix?
57 unsigned int :5; //!< Padding
58 unsigned int lenght:16; //!< Length
59 };
60 };
61 unsigned int cmd:8; //!< Command
62 unsigned int segmentAddress:32; //!< Address to register where there is an RDRAM address used to retrieve matrix
63};
64#pragma pack(pop)
65//*****************************************************************************
66// Vertices
67//*****************************************************************************
68
69//! Add vertices struct used for ucode F3D
70struct RSPUCodeAddVertices0
71{
72 unsigned int length:16; //!< Length
73 unsigned int firstVertex:4; //!< Index of first vertex
74 unsigned int numVertices:4; //!< Number of vertices minus one
75 unsigned int cmd:8; //!< Command
76 unsigned int segmentAddress; //!< Address to register where there is an RDRAM address used to retrieve vertices
77};
78//! Add vertices struct used for ucode F3DEX
79struct RSPUCodeAddVertices1
80{
81 unsigned int length:10; //!< Length
82 unsigned int numVertices:6; //!< Number of vertices
83 unsigned int :1; //!< Padding
84 unsigned int firstVertex:7; //!< Index of first vertex
85 unsigned int cmd:8; //!< Command
86 unsigned int segmentAddress; //!< Address to register where there is an RDRAM address used to retrieve vertices
87};
88
89//! Add vertices struct used for ucode F3DEX2
90struct RSPUCodeAddVerticesF3DEX2
91{
92 unsigned int pad0:1; //!< Padding
93 unsigned int vertexEnd:7; //!< Index of last vertex
94 unsigned int pad1:4; //!< Padding
95 unsigned int numVertices:8; //!< Number of vertices
96 unsigned int pad2:4; //!< Padding
97 unsigned int cmd:8; //!< Command
98 unsigned int segmentAddress:32; //!< Address to register where there is an RDRAM address used to retrieve vertices
99};
100
101//! Add vertices struct used for ucode 9 (Perfect Dark)
102struct RSPUCode9AddColorIndexVertices
103{
104 unsigned int pad0:16; //!< Padding
105 unsigned int firstVertexIndex:4; //!< Index of first vertex (where to place vertices in vertexbuffer)
106 unsigned int numVertices:4; //!< Add one
107 unsigned int cmd:8; //!< Command
108 unsigned int segmentAddress:32; //!< Address to register where there is an RDRAM address used to retrieve vertices
109};
110
111//! Add vertices struct used for ucode 4 (Wave Rave 64)
112struct RSPUCodeAddVerticesWaveRace64
113{
114 unsigned int pad0:8; //!< Padding
115 unsigned int pad1:1; //!< Padding
116 unsigned int numVertices:7; //!< Number of vertices
117 unsigned int firstVertexIndex:8; //!< Index of first vertex (where to place vertices in vertexbuffer)(divide by 5)
118 unsigned int cmd:8; //!< Command
119 unsigned int segmentAddress:32; //!< Address to register where there is an RDRAM address used to retrieve vertices
120};
121
122//*****************************************************************************
123// One triangle
124//*****************************************************************************
125
126//! Add triangle struct used for ucode F3D (and F3DEX)
127struct RSPUCodeAddOneTriangleF3D
128{
129 unsigned int padding:24; //!< padding
130 unsigned int cmd:8; //!< Command
131 unsigned int index2:8; //!< Third vertex index (divide by 10 in ucode F3D and 2 in F3DEX, 5 for wave race)
132 unsigned int index1:8; //!< Second vertex index (divide by 10 in ucode F3D and 2 in F3DEX, 5 for wave race)
133 unsigned int index0:8; //!< First vertex index (divide by 10 in ucode F3D and 2 in F3DEX, 5 for wave race)
134 unsigned int flag:8; //!< ???
135};
136
137//! Add triangle struct used for example ucode F3DEX
138struct RSPUCodeAddOneTriangleF3DEX
139{
140 unsigned int padding:24; //!< padding
141 unsigned int cmd:8; //!< Command
142 unsigned int pad0:1; //!< Padding
143 unsigned int index2:7; //!< Third vertex index
144 unsigned int pad1:1; //!< Padding
145 unsigned int index1:7; //!< Second vertex index
146 unsigned int pad2:1; //!< Padding
147 unsigned int index0:7; //!< First vertex index
148 unsigned int pad3:8; //!< Padding
149};
150
151//! Add triangle struct used for ucode F3DEX2
152struct RSPUCodeAddOneTriangleF3DEX2
153{
154 unsigned int index2:8; //!< Third vertex index
155 unsigned int index1:8; //!< Second vertex index
156 unsigned int index0:8; //!< First vertex index
157 unsigned int cmd:8; //!< Command
158 unsigned int pad:32; //!< padding
159};
160
161//*****************************************************************************
162// Two triangles
163//*****************************************************************************
164
165//! Add triangle struct used for adding two triangles
166struct RSPUCodeAddTwoTrianglesWaveRace64
167{
168 unsigned int v2:8; //!< Third vertex index for first triangle (divide by 5 for wave race)
169 unsigned int v1:8; //!< Second vertex index for first triangle (divide by 5 for wave race)
170 unsigned int v0:8; //!< First vertex index for first triangle (divide by 5 for wave race)
171 unsigned int cmd:8; //!< Command
172 unsigned int v5:8; //!< Third vertex index for second triangle (divide by 5 for wave race)
173 unsigned int v4:8; //!< Second vertex index for second triangle (divide by 5 for wave race)
174 unsigned int v3:8; //!< First vertex index for second triangle (divide by 5 for wave race)
175 unsigned int flag:8; //!< ???
176};
177
178//! Add triangle struct used for adding two triangles
179struct RSPUCodeAddTwoTrianglesF3DEX
180{
181 unsigned int pad0:1; //!< Padding
182 unsigned int v2:7; //!< Third vertex index for first triangle
183 unsigned int pad1:1; //!< Padding
184 unsigned int v1:7; //!< Second vertex index for first triangle
185 unsigned int pad2:1; //!< Padding
186 unsigned int v0:7; //!< First vertex index for first triangle
187 unsigned int cmd:8; //!< Command
188 unsigned int pad3:1; //!< Padding
189 unsigned int v5:7; //!< Third vertex index for second triangle
190 unsigned int pad4:1; //!< Padding
191 unsigned int v4:7; //!< Second vertex index for second triangle
192 unsigned int pad8:1; //!< Padding
193 unsigned int v3:7; //!< First vertex index for second triangle
194 unsigned int flag:8; //!< ???
195};
196
197//*****************************************************************************
198// Four triangles
199//*****************************************************************************
200
201//! Add triangle struct used for adding four triangles, used by ucode F3D
202struct RSPUCodeAddFourTrianglesF3D
203{
204 unsigned int v0:4;
205 unsigned int v3:4;
206 unsigned int v6:4;
207 unsigned int v9:4;
208 unsigned int pad:8;
209 unsigned int cmd:8;
210 unsigned int v1:4;
211 unsigned int v2:4;
212 unsigned int v4:4;
213 unsigned int v5:4;
214 unsigned int v7:4;
215 unsigned int v8:4;
216 unsigned int v10:4;
217 unsigned int v11:4;
218};
219
220//*****************************************************************************
221// One Quad
222//*****************************************************************************
223
224//! Add quad struct used for adding a rectangel, used by ucode F3D
225struct RSPUCodeAddOneQuadF3D
226{
227 unsigned int pad0:24; //!< Padding
228 unsigned int cmd:8; //!< Command
229 unsigned int index3:8; //!< (divide by 10, 5 for Wave Race)
230 unsigned int index2:8; //!< (divide by 10, 5 for Wave Race)
231 unsigned int index1:8; //!< (divide by 10, 5 for Wave Race)
232 unsigned int index0:8; //!< (divide by 10, 5 for Wave Race)
233};
234
235//! Add quad struct used for adding a rectangel, used by ucode F3DEX
236struct RSPUCodeAddOneQuadF3DEX
237{
238 unsigned int pad0:24; //!< Padding
239 unsigned int cmd:8; //!< Command
240 unsigned int pad1:1; //!< Padding
241 unsigned int index3:7; //!< Index of fourth vertex
242 unsigned int pad2:1; //!< Padding
243 unsigned int index2:7; //!< Index of third vertex
244 unsigned int pad3:1; //!< Padding
245 unsigned int index1:7; //!< Index of second vertex
246 unsigned int pad4:1; //!< Padding
247 unsigned int index0:7; //!< Index of first vertex
248};
249
250//! Add quad struct used for adding a rectangel, used by ucode F3DEX2
251struct RSPUCodeAddOneQuadF3DEX2 //aka TwoTriangles
252{
253 unsigned int v2:8;
254 unsigned int v1:8;
255 unsigned int v0:8;
256 unsigned int cmd:8;
257 unsigned int v5:8;
258 unsigned int v4:8;
259 unsigned int v3:8;
260 unsigned int pad0:8;
261};
262
263//*****************************************************************************
264// Misc
265//*****************************************************************************
266
267//! Struct used to set DMA Offsets (Mainly used by Diddy Kong Racing UCode6)
268struct RSPUCodeSetDMAOffsets
269{
270 unsigned int addressOffsetMatrix:24;
271 unsigned int cmd:8;
272 unsigned int addressOffsetVertex:24;
273 unsigned int padding:8;
274};
275
276//! Struct used to set Vertex Color Base
277struct RSPUCodeSetVertexColorBase
278{
279 unsigned int padding:24; //!< Padding
280 unsigned int cmd:8; //!< Command
281 unsigned int rdramAddress:32; //!< Address to RDRAM where vertex colors are located.
282};
283
284//! Struct used to change display list
285struct RSPUCodeDisplayList
286{
287 unsigned int padding:16; //!< Padding
288 unsigned int param:8; //!< Push display list or not?
289 unsigned int cmd:8; //!< Command
290 unsigned int segmentAddress:32; //!<
291};
292
293//! Struct used when modifying vertex data
294struct RSPUCodeModifyVertex
295{
296 unsigned int pad0:1; //!< Padding
297 unsigned int vertexIndex:15; //!< Vertex Index (witch vertex to modify
298 unsigned int modifyType:8; //!< How to modify vertex (set color or texcoords?)
299 unsigned int cmd:8; //!< Command
300 union
301 {
302 unsigned int value:16; //!< Input values for vertex
303 struct
304 {
305 unsigned int a:8; //!< Alpha component of color
306 unsigned int b:8; //!< Blue component of color
307 unsigned int g:8; //!< Green component of color
308 unsigned int r:8; //!< Red component of color
309 };
310 struct
311 {
312 unsigned int t:16; //!< Second value of texturecoord
313 unsigned int s:16; //!< First value of texturecoord
314 };
315 };
316};
317
318//*****************************************************************************
319// Move Word
320//*****************************************************************************
321
322//! Struct used to extract information in MoveWord instruction for ucode F3D
323struct RSPUCodeMoveWordF3D
324{
325 unsigned int type:8; //!< Type of MoveWord
326 unsigned int offset:16; //!< Offset
327 unsigned int cmd:8; //!< Command
328
329 union
330 {
331 unsigned int value:32; //!< Value
332 struct
333 {
334 unsigned int fo:16; //!< Fog
335 unsigned int fm:16; //!< Fog
336 };
337 };
338};
339
340//! Struct used to extract information in MoveWord instruction for ucode F3DEX2
341struct RSPUCodeMoveWordF3DEX2
342{
343 unsigned int offset:16; //!< Offset
344 unsigned int type:8; //!< Type of MoveWord
345 unsigned int cmd:8; //!< Command
346 union
347 {
348 unsigned int value:32; //!< Value
349 struct
350 {
351 unsigned int fo:16; //!< Fog
352 unsigned int fm:16; //!< Fog
353 };
354 };
355};
356
357//*****************************************************************************
358//* Texture
359//! Struct used when retriving texture information on RSP
360//*****************************************************************************
361struct RSPUCodeTexture
362{
363 unsigned int enable_gbi0:1;
364 unsigned int enable_gbi2:1;
365 unsigned int :6;
366 unsigned int tile:3;
367 unsigned int level:3;
368 unsigned int :10;
369 unsigned int cmd:8;
370 unsigned int scaleT:16;
371 unsigned int scaleS:16;
372};
373
374//*****************************************************************************
375//* RSPUCodeLoadUCode
376//! Struct used when changing ucode on RSP
377//*****************************************************************************
378struct RSPUCodeLoadUCode
379{
380 unsigned int ucodeSize:16; //!< UCode size, note: Add one
381 unsigned int padding:8; //!< Padding?
382 unsigned int cmd:8; //!< Command
383 unsigned int ucodeStart:32; //!< UCode Start
384};
385
386
387//*****************************************************************************
388// Display List
389//*****************************************************************************
390
391//! Struct used to cull displaylist
392struct RSPUCodeCullDisplayList
393{
394 unsigned int pad0:1; //!< Padding
395 unsigned int vertexIndex:15; //!< First vertex index to vertices to cull
396 unsigned int pad2:8; //!< Padding
397 unsigned int cmd:8; //!< Command
398 unsigned int pad3:1; //!< Padding
399 unsigned int numVerticies:15; //!< Number of vertices to cull
400 unsigned int pad4:8; //!< Padding
401};
402
403//! Used by instruction branch display list by ucode F3DEX
404struct RSPUCodeBranchZF3DEX
405{
406 unsigned int pad0:1; //!< Padding
407 unsigned int vertex:11; //!< Vertex to retrive z value from
408 unsigned int pad1:12; //!< Padding
409 unsigned int cmd:8; //!< Command
410 unsigned int zvalue:32; //!< z value used to compare with
411};
412
413//*****************************************************************************
414// Others
415//*****************************************************************************
416
417//typedef struct {
418// union {
419// unsigned int w0;
420// struct {
421// unsigned int arg0:24;
422// unsigned int cmd:8;
423// };
424// };
425// unsigned int w1;
426//} Gwords;
427
428//! Stuct used to give GBI instructions input data as function argument.
429typedef union {
430 struct {
431 union {
432 unsigned int w0;
433 struct {
434 unsigned int arg0:24;
435 unsigned int cmd:8;
436 };
437 };
438 unsigned int w1;
439 };
440 long long int force_structure_alignment;
441} MicrocodeArgument;
442
443#endif