GLES2N64 (from mupen64plus-ae) plugin. Compile and run on the OpenPandora
[mupen64plus-pandora.git] / source / gles2n64 / src / gSP.h
CommitLineData
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() \
53if \
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
97struct 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
109typedef SPVertex SPTriangle[3];
110
111struct SPLight
112{
113 f32 r, g, b;
114 f32 x, y, z;
115};
116
117struct 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
180extern gSPInfo gSP;
181
182void gSPLoadUcodeEx( u32 uc_start, u32 uc_dstart, u16 uc_dsize );
183void gSPNoOp();
184void gSPMatrix( u32 matrix, u8 param );
185void gSPDMAMatrix( u32 matrix, u8 index, u8 multiply );
186void gSPViewport( u32 v );
187void gSPForceMatrix( u32 mptr );
188void gSPLight( u32 l, s32 n );
189void gSPLookAt( u32 l );
190void gSPVertex( u32 v, u32 n, u32 v0 );
191void gSPCIVertex( u32 v, u32 n, u32 v0 );
192void gSPDMAVertex( u32 v, u32 n, u32 v0 );
193void gSPDisplayList( u32 dl );
194void gSPDMADisplayList( u32 dl, u32 n );
195void gSPBranchList( u32 dl );
196void gSPBranchLessZ( u32 branchdl, u32 vtx, f32 zval );
197void gSPSprite2DBase( u32 base );
198void gSPDMATriangles( u32 tris, u32 n );
199void gSP1Quadrangle( s32 v0, s32 v1, s32 v2, s32 v3 );
200void gSPCullDisplayList( u32 v0, u32 vn );
201void gSPPopMatrix( u32 param );
202void gSPPopMatrixN( u32 param, u32 num );
203void gSPSegment( s32 seg, s32 base );
204void gSPClipRatio( u32 r );
205void gSPInsertMatrix( u32 where, u32 num );
206void gSPModifyVertex( u32 vtx, u32 where, u32 val );
207void gSPNumLights( s32 n );
208void gSPLightColor( u32 lightNum, u32 packedColor );
209void gSPFogFactor( s16 fm, s16 fo );
210void gSPPerspNormalize( u16 scale );
211void gSPTexture( f32 sc, f32 tc, s32 level, s32 tile, s32 on );
212void gSPEndDisplayList();
213void gSPGeometryMode( u32 clear, u32 set );
214void gSPSetGeometryMode( u32 mode );
215void gSPClearGeometryMode( u32 mode );
216void gSPLine3D( s32 v0, s32 v1, s32 flag );
217void gSPLineW3D( s32 v0, s32 v1, s32 wd, s32 flag );
218void gSPObjRectangle( u32 sp );
219void gSPObjSprite( u32 sp );
220void gSPObjLoadTxtr( u32 tx );
221void gSPObjLoadTxSprite( u32 txsp );
222void gSPObjLoadTxRectR( u32 txsp );
223void gSPBgRect1Cyc( u32 bg );
224void gSPBgRectCopy( u32 bg );
225void gSPObjMatrix( u32 mtx );
226void gSPObjSubMatrix( u32 mtx );
227void gSPSetDMAOffsets( u32 mtxoffset, u32 vtxoffset );
228void gSPSetVertexColorBase( u32 base );
229void gSPProcessVertex(u32 v);
230
231void gSPTriangleUnknown();
232
233void gSP1Triangle(s32 v0, s32 v1, s32 v2);
234void 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 );
236void 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
243void __indexmap_init();
244void __indexmap_clear();
245u32 __indexmap_findunused(u32 num);
246u32 __indexmap_getnew(u32 index, u32 num);
247//#endif
248
249#ifdef __VEC4_OPT
250extern void (*gSPTransformVertex4)(u32 v, float mtx[4][4]);
251extern void (*gSPTransformNormal4)(u32 v, float mtx[4][4]);
252extern void (*gSPLightVertex4)(u32 v);
253extern void (*gSPBillboardVertex4)(u32 v);
254#endif
255extern void (*gSPTransformVertex)(float vtx[4], float mtx[4][4]);
256extern void (*gSPLightVertex)(u32 v);
257extern void (*gSPBillboardVertex)(u32 v, u32 i);
258
259#ifdef __NEON_OPT
260void gSPInitNeon();
261#endif
262
263#endif
264