1 /******************************************************************************
2 * Arachnoid Graphics Plugin for Mupen64Plus
3 * http://bitbucket.org/wahrhaft/mupen64plus-video-arachnoid/
5 * Copyright (C) 2007 Kristofer Karlsson, Rickard Niklasson
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.
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.
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 *****************************************************************************/
22 #ifndef _UCODE_DEFS_H_
23 #define _UCODE_DEFS_H_
25 //*****************************************************************************
27 //*****************************************************************************
29 //! Add matrix struct used for example ucode F3D
30 struct RSPUCodeAddMatrix0
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
41 //! Add matrix struct used for example ucode F3DEX2
43 struct RSPUCodeAddMatrixF3DEX2
49 unsigned int param:8; //!< Push?, Load?, Projection?
50 unsigned int len:16; //!< Length
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
61 unsigned int cmd:8; //!< Command
62 unsigned int segmentAddress:32; //!< Address to register where there is an RDRAM address used to retrieve matrix
65 //*****************************************************************************
67 //*****************************************************************************
69 //! Add vertices struct used for ucode F3D
70 struct RSPUCodeAddVertices0
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
78 //! Add vertices struct used for ucode F3DEX
79 struct RSPUCodeAddVertices1
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
89 //! Add vertices struct used for ucode F3DEX2
90 struct RSPUCodeAddVerticesF3DEX2
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
101 //! Add vertices struct used for ucode 9 (Perfect Dark)
102 struct RSPUCode9AddColorIndexVertices
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
111 //! Add vertices struct used for ucode 4 (Wave Rave 64)
112 struct RSPUCodeAddVerticesWaveRace64
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
122 //*****************************************************************************
124 //*****************************************************************************
126 //! Add triangle struct used for ucode F3D (and F3DEX)
127 struct RSPUCodeAddOneTriangleF3D
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; //!< ???
137 //! Add triangle struct used for example ucode F3DEX
138 struct RSPUCodeAddOneTriangleF3DEX
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
151 //! Add triangle struct used for ucode F3DEX2
152 struct RSPUCodeAddOneTriangleF3DEX2
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
161 //*****************************************************************************
163 //*****************************************************************************
165 //! Add triangle struct used for adding two triangles
166 struct RSPUCodeAddTwoTrianglesWaveRace64
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; //!< ???
178 //! Add triangle struct used for adding two triangles
179 struct RSPUCodeAddTwoTrianglesF3DEX
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; //!< ???
197 //*****************************************************************************
199 //*****************************************************************************
201 //! Add triangle struct used for adding four triangles, used by ucode F3D
202 struct RSPUCodeAddFourTrianglesF3D
220 //*****************************************************************************
222 //*****************************************************************************
224 //! Add quad struct used for adding a rectangel, used by ucode F3D
225 struct RSPUCodeAddOneQuadF3D
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)
235 //! Add quad struct used for adding a rectangel, used by ucode F3DEX
236 struct RSPUCodeAddOneQuadF3DEX
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
250 //! Add quad struct used for adding a rectangel, used by ucode F3DEX2
251 struct RSPUCodeAddOneQuadF3DEX2 //aka TwoTriangles
263 //*****************************************************************************
265 //*****************************************************************************
267 //! Struct used to set DMA Offsets (Mainly used by Diddy Kong Racing UCode6)
268 struct RSPUCodeSetDMAOffsets
270 unsigned int addressOffsetMatrix:24;
272 unsigned int addressOffsetVertex:24;
273 unsigned int padding:8;
276 //! Struct used to set Vertex Color Base
277 struct RSPUCodeSetVertexColorBase
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.
284 //! Struct used to change display list
285 struct RSPUCodeDisplayList
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; //!<
293 //! Struct used when modifying vertex data
294 struct RSPUCodeModifyVertex
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
302 unsigned int value:16; //!< Input values for vertex
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
312 unsigned int t:16; //!< Second value of texturecoord
313 unsigned int s:16; //!< First value of texturecoord
318 //*****************************************************************************
320 //*****************************************************************************
322 //! Struct used to extract information in MoveWord instruction for ucode F3D
323 struct RSPUCodeMoveWordF3D
325 unsigned int type:8; //!< Type of MoveWord
326 unsigned int offset:16; //!< Offset
327 unsigned int cmd:8; //!< Command
331 unsigned int value:32; //!< Value
334 unsigned int fo:16; //!< Fog
335 unsigned int fm:16; //!< Fog
340 //! Struct used to extract information in MoveWord instruction for ucode F3DEX2
341 struct RSPUCodeMoveWordF3DEX2
343 unsigned int offset:16; //!< Offset
344 unsigned int type:8; //!< Type of MoveWord
345 unsigned int cmd:8; //!< Command
348 unsigned int value:32; //!< Value
351 unsigned int fo:16; //!< Fog
352 unsigned int fm:16; //!< Fog
357 //*****************************************************************************
359 //! Struct used when retriving texture information on RSP
360 //*****************************************************************************
361 struct RSPUCodeTexture
363 unsigned int enable_gbi0:1;
364 unsigned int enable_gbi2:1;
367 unsigned int level:3;
370 unsigned int scaleT:16;
371 unsigned int scaleS:16;
374 //*****************************************************************************
375 //* RSPUCodeLoadUCode
376 //! Struct used when changing ucode on RSP
377 //*****************************************************************************
378 struct RSPUCodeLoadUCode
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
387 //*****************************************************************************
389 //*****************************************************************************
391 //! Struct used to cull displaylist
392 struct RSPUCodeCullDisplayList
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
403 //! Used by instruction branch display list by ucode F3DEX
404 struct RSPUCodeBranchZF3DEX
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
413 //*****************************************************************************
415 //*****************************************************************************
421 // unsigned int arg0:24;
422 // unsigned int cmd:8;
428 //! Stuct used to give GBI instructions input data as function argument.
434 unsigned int arg0:24;
440 long long int force_structure_alignment;