34cf4058 |
1 | #ifndef GSP_H |
2 | #define GSP_H |
3 | |
4 | #include "Types.h" |
5 | #include "GBI.h" |
6 | #include "gDP.h" |
7 | |
8 | #define CHANGED_VIEWPORT 0x01 |
9 | #define CHANGED_MATRIX 0x02 |
10 | #define CHANGED_COLORBUFFER 0x04 |
11 | #define CHANGED_GEOMETRYMODE 0x08 |
12 | #define CHANGED_TEXTURE 0x10 |
13 | #define CHANGED_FOGPOSITION 0x20 |
14 | #define CHANGED_TEXTURESCALE 0x40 |
15 | |
16 | //#ifdef __TRIBUFFER_OPT |
17 | // #define gSPFlushTriangles() \ |
18 | // if \ |
19 | // ( \ |
20 | // (OGL.triangles.num > 1000) || \ |
21 | // ( \ |
22 | // (RSP.nextCmd != G_NOOP) && \ |
23 | // (RSP.nextCmd != G_RDPNOOP) && \ |
24 | // (RSP.nextCmd != G_MOVEMEM) && \ |
25 | // (RSP.nextCmd != G_ENDDL) && \ |
26 | // (RSP.nextCmd != G_DL) && \ |
27 | // (RSP.nextCmd != G_VTXCOLORBASE) && \ |
28 | // (RSP.nextCmd != G_TRI1) && \ |
29 | // (RSP.nextCmd != G_TRI2) && \ |
30 | // (RSP.nextCmd != G_TRI4) && \ |
31 | // (RSP.nextCmd != G_QUAD) && \ |
32 | // (RSP.nextCmd != G_VTX) && \ |
33 | // (RSP.nextCmd != G_MTX) \ |
34 | // ) \ |
35 | // ) \ |
36 | // { \ |
37 | // OGL_DrawTriangles(); \ |
38 | // } |
39 | //#else |
40 | // #define gSPFlushTriangles() \ |
41 | // if \ |
42 | // ( \ |
43 | // (RSP.nextCmd != G_TRI1) && \ |
44 | // (RSP.nextCmd != G_TRI2) && \ |
45 | // (RSP.nextCmd != G_TRI4) && \ |
46 | // (RSP.nextCmd != G_QUAD) \ |
47 | // ) \ |
48 | // { \ |
49 | // OGL_DrawTriangles(); \ |
50 | // } |
51 | //#endif |
52 | #define gSPFlushTriangles() \ |
53 | if \ |
54 | ( \ |
55 | ( \ |
56 | (config.tribufferOpt) && \ |
57 | (OGL.triangles.num > 1000) || \ |
58 | ( \ |
59 | (RSP.nextCmd != G_NOOP) && \ |
60 | (RSP.nextCmd != G_RDPNOOP) && \ |
61 | (RSP.nextCmd != G_MOVEMEM) && \ |
62 | (RSP.nextCmd != G_ENDDL) && \ |
63 | (RSP.nextCmd != G_DL) && \ |
64 | (RSP.nextCmd != G_VTXCOLORBASE) && \ |
65 | (RSP.nextCmd != G_TRI1) && \ |
66 | (RSP.nextCmd != G_TRI2) && \ |
67 | (RSP.nextCmd != G_TRI4) && \ |
68 | (RSP.nextCmd != G_QUAD) && \ |
69 | (RSP.nextCmd != G_VTX) && \ |
70 | (RSP.nextCmd != G_MTX) \ |
71 | ) \ |
72 | ) || \ |
73 | ( \ |
74 | (RSP.nextCmd != G_TRI1) && \ |
75 | (RSP.nextCmd != G_TRI2) && \ |
76 | (RSP.nextCmd != G_TRI4) && \ |
77 | (RSP.nextCmd != G_QUAD) \ |
78 | ) \ |
79 | ) \ |
80 | { \ |
81 | OGL_DrawTriangles(); \ |
82 | } |
83 | |
84 | |
85 | #define CLIP_X 0x03 |
86 | #define CLIP_NEGX 0x01 |
87 | #define CLIP_POSX 0x02 |
88 | |
89 | #define CLIP_Y 0x0C |
90 | #define CLIP_NEGY 0x04 |
91 | #define CLIP_POSY 0x08 |
92 | |
93 | #define CLIP_Z 0x30 |
94 | #define CLIP_NEGZ 0x10 |
95 | #define CLIP_POSZ 0x20 |
96 | |
97 | struct SPVertex |
98 | { |
99 | f32 x, y, z, w; |
100 | f32 nx, ny, nz, __pad0; |
101 | f32 r, g, b, a; |
102 | f32 s, t; |
103 | |
104 | u32 clip; |
105 | s16 flag; |
106 | s16 __pad1; |
107 | }; |
108 | |
109 | typedef SPVertex SPTriangle[3]; |
110 | |
111 | struct SPLight |
112 | { |
113 | f32 r, g, b; |
114 | f32 x, y, z; |
115 | }; |
116 | |
117 | struct gSPInfo |
118 | { |
119 | u32 segment[16]; |
120 | |
121 | struct |
122 | { |
123 | u32 modelViewi, stackSize, billboard; |
124 | f32 modelView[32][4][4]; |
125 | f32 projection[4][4]; |
126 | f32 combined[4][4]; |
127 | } matrix; |
128 | |
129 | struct |
130 | { |
131 | f32 A, B, C, D; |
132 | f32 X, Y; |
133 | f32 baseScaleX, baseScaleY; |
134 | } objMatrix; |
135 | |
136 | u32 vertexColorBase; |
137 | u32 vertexi; |
138 | |
139 | SPLight lights[8]; |
140 | |
141 | struct |
142 | { |
143 | f32 scales, scalet; |
144 | s32 level, on, tile; |
145 | } texture; |
146 | |
147 | gDPTile *textureTile[2]; |
148 | |
149 | struct |
150 | { |
151 | f32 vscale[4]; |
152 | f32 vtrans[4]; |
153 | f32 x, y, width, height; |
154 | f32 nearz, farz; |
155 | } viewport; |
156 | |
157 | struct |
158 | { |
159 | s16 multiplier, offset; |
160 | } fog; |
161 | |
162 | struct |
163 | { |
164 | u32 address, width, height, format, size, palette; |
165 | } bgImage; |
166 | |
167 | u32 geometryMode; |
168 | s32 numLights; |
169 | |
170 | u32 changed; |
171 | |
172 | u32 status[4]; |
173 | |
174 | struct |
175 | { |
176 | u32 vtx, mtx; |
177 | } DMAOffsets; |
178 | }; |
179 | |
180 | extern gSPInfo gSP; |
181 | |
182 | void gSPLoadUcodeEx( u32 uc_start, u32 uc_dstart, u16 uc_dsize ); |
183 | void gSPNoOp(); |
184 | void gSPMatrix( u32 matrix, u8 param ); |
185 | void gSPDMAMatrix( u32 matrix, u8 index, u8 multiply ); |
186 | void gSPViewport( u32 v ); |
187 | void gSPForceMatrix( u32 mptr ); |
188 | void gSPLight( u32 l, s32 n ); |
189 | void gSPLookAt( u32 l ); |
190 | void gSPVertex( u32 v, u32 n, u32 v0 ); |
191 | void gSPCIVertex( u32 v, u32 n, u32 v0 ); |
192 | void gSPDMAVertex( u32 v, u32 n, u32 v0 ); |
193 | void gSPDisplayList( u32 dl ); |
194 | void gSPDMADisplayList( u32 dl, u32 n ); |
195 | void gSPBranchList( u32 dl ); |
196 | void gSPBranchLessZ( u32 branchdl, u32 vtx, f32 zval ); |
197 | void gSPSprite2DBase( u32 base ); |
198 | void gSPDMATriangles( u32 tris, u32 n ); |
199 | void gSP1Quadrangle( s32 v0, s32 v1, s32 v2, s32 v3 ); |
200 | void gSPCullDisplayList( u32 v0, u32 vn ); |
201 | void gSPPopMatrix( u32 param ); |
202 | void gSPPopMatrixN( u32 param, u32 num ); |
203 | void gSPSegment( s32 seg, s32 base ); |
204 | void gSPClipRatio( u32 r ); |
205 | void gSPInsertMatrix( u32 where, u32 num ); |
206 | void gSPModifyVertex( u32 vtx, u32 where, u32 val ); |
207 | void gSPNumLights( s32 n ); |
208 | void gSPLightColor( u32 lightNum, u32 packedColor ); |
209 | void gSPFogFactor( s16 fm, s16 fo ); |
210 | void gSPPerspNormalize( u16 scale ); |
211 | void gSPTexture( f32 sc, f32 tc, s32 level, s32 tile, s32 on ); |
212 | void gSPEndDisplayList(); |
213 | void gSPGeometryMode( u32 clear, u32 set ); |
214 | void gSPSetGeometryMode( u32 mode ); |
215 | void gSPClearGeometryMode( u32 mode ); |
216 | void gSPLine3D( s32 v0, s32 v1, s32 flag ); |
217 | void gSPLineW3D( s32 v0, s32 v1, s32 wd, s32 flag ); |
218 | void gSPObjRectangle( u32 sp ); |
219 | void gSPObjSprite( u32 sp ); |
220 | void gSPObjLoadTxtr( u32 tx ); |
221 | void gSPObjLoadTxSprite( u32 txsp ); |
222 | void gSPObjLoadTxRectR( u32 txsp ); |
223 | void gSPBgRect1Cyc( u32 bg ); |
224 | void gSPBgRectCopy( u32 bg ); |
225 | void gSPObjMatrix( u32 mtx ); |
226 | void gSPObjSubMatrix( u32 mtx ); |
227 | void gSPSetDMAOffsets( u32 mtxoffset, u32 vtxoffset ); |
228 | void gSPSetVertexColorBase( u32 base ); |
229 | void gSPProcessVertex(u32 v); |
230 | |
231 | void gSPTriangleUnknown(); |
232 | |
233 | void gSP1Triangle(s32 v0, s32 v1, s32 v2); |
234 | void gSP2Triangles(const s32 v00, const s32 v01, const s32 v02, const s32 flag0, |
235 | const s32 v10, const s32 v11, const s32 v12, const s32 flag1 ); |
236 | void gSP4Triangles(const s32 v00, const s32 v01, const s32 v02, |
237 | const s32 v10, const s32 v11, const s32 v12, |
238 | const s32 v20, const s32 v21, const s32 v22, |
239 | const s32 v30, const s32 v31, const s32 v32 ); |
240 | |
241 | |
242 | //#ifdef __TRIBUFFER_OPT |
243 | void __indexmap_init(); |
244 | void __indexmap_clear(); |
245 | u32 __indexmap_findunused(u32 num); |
246 | u32 __indexmap_getnew(u32 index, u32 num); |
247 | //#endif |
248 | |
249 | #ifdef __VEC4_OPT |
250 | extern void (*gSPTransformVertex4)(u32 v, float mtx[4][4]); |
251 | extern void (*gSPTransformNormal4)(u32 v, float mtx[4][4]); |
252 | extern void (*gSPLightVertex4)(u32 v); |
253 | extern void (*gSPBillboardVertex4)(u32 v); |
254 | #endif |
255 | extern void (*gSPTransformVertex)(float vtx[4], float mtx[4][4]); |
256 | extern void (*gSPLightVertex)(u32 v); |
257 | extern void (*gSPBillboardVertex)(u32 v, u32 i); |
258 | |
259 | #ifdef __NEON_OPT |
260 | void gSPInitNeon(); |
261 | #endif |
262 | |
263 | #endif |
264 | |