ce879073 |
1 | /***************************************************************************\r |
2 | prim.c - description\r |
3 | -------------------\r |
4 | begin : Sun Mar 08 2009\r |
5 | copyright : (C) 1999-2009 by Pete Bernert\r |
6 | web : www.pbernert.com \r |
7 | ***************************************************************************/\r |
8 | \r |
9 | /***************************************************************************\r |
10 | * *\r |
11 | * This program is free software; you can redistribute it and/or modify *\r |
12 | * it under the terms of the GNU General Public License as published by *\r |
13 | * the Free Software Foundation; either version 2 of the License, or *\r |
14 | * (at your option) any later version. See also the license.txt file for *\r |
15 | * additional informations. *\r |
16 | * *\r |
17 | ***************************************************************************/\r |
18 | \r |
19 | //*************************************************************************// \r |
20 | // History of changes:\r |
21 | //\r |
22 | // 2009/03/08 - Pete \r |
23 | // - generic cleanup for the Peops release\r |
24 | //\r |
25 | //*************************************************************************// \r |
26 | \r |
27 | #define _IN_PRIMDRAW\r |
28 | \r |
29 | #ifdef _WINDOWS\r |
30 | #include "stdafx.h"\r |
31 | #include "externals.h"\r |
32 | #include "gpu.h"\r |
33 | #include "draw.h"\r |
34 | #include "texture.h"\r |
35 | #else\r |
36 | #include "gpuStdafx.h"\r |
37 | #include "gpuExternals.h"\r |
38 | #include "gpuPlugin.h"\r |
39 | #include "gpuDraw.h"\r |
40 | #include "gpuTexture.h"\r |
41 | #include "gpuPrim.h"\r |
42 | \r |
43 | #endif\r |
44 | \r |
45 | //////////////////////////////////////////////////////////////////////// \r |
46 | // defines\r |
47 | ////////////////////////////////////////////////////////////////////////\r |
48 | \r |
49 | #define DEFOPAQUEON glAlphaFunc(GL_EQUAL,0.0f);bBlendEnable=FALSE;glDisable(GL_BLEND); \r |
50 | #define DEFOPAQUEOFF glAlphaFunc(GL_GREATER,0.49f);\r |
51 | #define fpoint(x) x\r |
52 | //////////////////////////////////////////////////////////////////////// \r |
53 | // globals\r |
54 | ////////////////////////////////////////////////////////////////////////\r |
55 | \r |
7eadbf88 |
56 | //#ifndef _WINDOWS\r |
57 | //EGLSurface surface;\r |
58 | //EGLDisplay display;\r |
59 | //#endif\r |
ce879073 |
60 | \r |
61 | BOOL bDrawTextured; // current active drawing states\r |
62 | BOOL bDrawSmoothShaded;\r |
63 | BOOL bOldSmoothShaded;\r |
64 | BOOL bDrawNonShaded;\r |
65 | BOOL bDrawMultiPass;\r |
66 | int iOffscreenDrawing;\r |
67 | int iDrawnSomething=0;\r |
68 | \r |
69 | BOOL bRenderFrontBuffer=FALSE; // flag for front buffer rendering\r |
70 | \r |
71 | GLubyte ubGloAlpha; // texture alpha\r |
72 | GLubyte ubGloColAlpha; // color alpha\r |
73 | int iFilterType; // type of filter\r |
74 | BOOL bFullVRam=FALSE; // sign for tex win\r |
75 | BOOL bDrawDither; // sign for dither\r |
76 | BOOL bUseMultiPass; // sign for multi pass\r |
77 | GLuint gTexName; // binded texture\r |
78 | BOOL bTexEnabled; // texture enable flag\r |
79 | BOOL bBlendEnable; // blend enable flag\r |
80 | PSXRect_t xrUploadArea; // rect to upload\r |
81 | PSXRect_t xrUploadAreaIL; // rect to upload\r |
82 | PSXRect_t xrUploadAreaRGB24; // rect to upload rgb24\r |
83 | int iSpriteTex=0; // flag for "hey, it's a sprite"\r |
84 | unsigned short usMirror; // mirror, mirror on the wall\r |
85 | \r |
86 | BOOL bNeedUploadAfter=FALSE; // sign for uploading in next frame\r |
87 | BOOL bNeedUploadTest=FALSE; // sign for upload test\r |
88 | BOOL bUsingTWin=FALSE; // tex win active flag\r |
89 | BOOL bUsingMovie=FALSE; // movie active flag\r |
90 | PSXRect_t xrMovieArea; // rect for movie upload\r |
91 | short sSprite_ux2; // needed for sprire adjust\r |
92 | short sSprite_vy2; // \r |
93 | unsigned long ulOLDCOL=0; // active color\r |
94 | unsigned long ulClutID; // clut\r |
95 | \r |
96 | unsigned long dwCfgFixes; // game fixes\r |
97 | unsigned long dwActFixes=0;\r |
98 | unsigned long dwEmuFixes=0;\r |
99 | BOOL bUseFixes;\r |
100 | \r |
101 | long drawX,drawY,drawW,drawH; // offscreen drawing checkers\r |
102 | short sxmin,sxmax,symin,symax;\r |
103 | \r |
104 | //////////////////////////////////////////////////////////////////////// \r |
105 | // Update global TP infos\r |
106 | ////////////////////////////////////////////////////////////////////////\r |
107 | \r |
108 | void UpdateGlobalTP(unsigned short gdata)\r |
109 | {\r |
110 | GlobalTextAddrX = (gdata << 6) & 0x3c0;\r |
111 | \r |
112 | if(iGPUHeight==1024) // ZN mode\r |
113 | {\r |
114 | if(dwGPUVersion==2) // very special zn gpu\r |
115 | {\r |
116 | GlobalTextAddrY =((gdata & 0x60 ) << 3);\r |
117 | GlobalTextIL =(gdata & 0x2000) >> 13;\r |
118 | GlobalTextABR = (unsigned short)((gdata >> 7) & 0x3);\r |
119 | GlobalTextTP = (gdata >> 9) & 0x3;\r |
120 | if(GlobalTextTP==3) GlobalTextTP=2; \r |
121 | GlobalTexturePage = (GlobalTextAddrX>>6)+(GlobalTextAddrY>>4);\r |
122 | usMirror =0;\r |
123 | STATUSREG = (STATUSREG & 0xffffe000 ) | (gdata & 0x1fff );\r |
124 | return;\r |
125 | }\r |
126 | else // "enhanced" psx gpu\r |
127 | {\r |
128 | GlobalTextAddrY = (unsigned short)(((gdata << 4) & 0x100) | ((gdata >> 2) & 0x200));\r |
129 | }\r |
130 | }\r |
131 | else GlobalTextAddrY = (gdata << 4) & 0x100; // "normal" psx gpu\r |
132 | \r |
133 | usMirror=gdata&0x3000;\r |
134 | \r |
135 | GlobalTextTP = (gdata >> 7) & 0x3; // tex mode (4,8,15)\r |
136 | if(GlobalTextTP==3) GlobalTextTP=2; // seen in Wild9 :(\r |
137 | GlobalTextABR = (gdata >> 5) & 0x3; // blend mode\r |
138 | \r |
139 | GlobalTexturePage = (GlobalTextAddrX>>6)+(GlobalTextAddrY>>4);\r |
140 | \r |
141 | STATUSREG&=~0x07ff; // Clear the necessary bits\r |
142 | STATUSREG|=(gdata & 0x07ff); // set the necessary bits\r |
143 | }\r |
144 | \r |
145 | //////////////////////////////////////////////////////////////////////// \r |
146 | // Some ASM color convertion... Lewpy's special...\r |
147 | ////////////////////////////////////////////////////////////////////////\r |
148 | \r |
149 | #ifdef _WINDOWS\r |
150 | #pragma warning (disable : 4035)\r |
151 | \r |
152 | unsigned long DoubleBGR2RGB (unsigned long BGR)\r |
153 | {\r |
154 | \r |
155 | __asm\r |
156 | {\r |
157 | mov eax, BGR /* this can hold the G value */\r |
158 | mov ebx, eax /* this can hold the R value */\r |
159 | mov edx, eax /* this can hold the B value */\r |
160 | and ebx, 000000ffh /* mask the R value */\r |
161 | shl ebx, 1\r |
162 | test ebx, 00000100h\r |
163 | jz RSKIP\r |
164 | mov ebx, 000000ffh\r |
165 | \r |
166 | RSKIP: \r |
167 | and eax, 0000ff00h /* mask the G value */\r |
168 | shl eax, 1\r |
169 | test eax, 00010000h\r |
170 | jz GSKIP\r |
171 | mov eax, 0000ff00h\r |
172 | \r |
173 | GSKIP: \r |
174 | and edx, 00ff0000h /* mask the B value */\r |
175 | shl edx, 1\r |
176 | test edx, 01000000h\r |
177 | jz BSKIP\r |
178 | mov edx, 00ff0000h\r |
179 | \r |
180 | BSKIP: \r |
181 | or eax, ebx /* add R to G value */\r |
182 | or eax, edx /* add B to RG value */\r |
183 | }\r |
184 | /* Result returned in EAX */\r |
185 | }\r |
186 | \r |
187 | unsigned short BGR24to16 (unsigned long BGR)\r |
188 | {\r |
189 | __asm\r |
190 | {\r |
191 | mov eax, BGR /* this can hold the G value */\r |
192 | mov ebx, eax /* this can hold the R value */\r |
193 | mov edx, eax /* this can hold the B value */\r |
194 | shr ebx, 3 /* move the R value */\r |
195 | and edx, 00f80000h /* mask the B value */\r |
196 | shr edx, 9 /* move the B value */\r |
197 | and eax, 00f800h /* mask the G value */\r |
198 | shr eax, 6 /* move the G value */\r |
199 | and ebx, 0000001fh /* mask the R value */\r |
200 | or eax, ebx /* add R to G value */\r |
201 | or eax, edx /* add B to RG value */\r |
202 | }\r |
203 | /* Result returned in AX */\r |
204 | }\r |
205 | \r |
206 | #pragma warning (default : 4035)\r |
207 | \r |
208 | #else\r |
209 | \r |
210 | unsigned long DoubleBGR2RGB (unsigned long BGR)\r |
211 | {\r |
212 | unsigned long ebx,eax,edx;\r |
213 | \r |
214 | ebx=(BGR&0x000000ff)<<1;\r |
215 | if(ebx&0x00000100) ebx=0x000000ff;\r |
216 | \r |
217 | eax=(BGR&0x0000ff00)<<1;\r |
218 | if(eax&0x00010000) eax=0x0000ff00;\r |
219 | \r |
220 | edx=(BGR&0x00ff0000)<<1;\r |
221 | if(edx&0x01000000) edx=0x00ff0000;\r |
222 | \r |
223 | return (ebx|eax|edx);\r |
224 | }\r |
225 | \r |
226 | unsigned short BGR24to16 (unsigned long BGR)\r |
227 | {\r |
228 | return ((BGR>>3)&0x1f)|((BGR&0xf80000)>>9)|((BGR&0xf800)>>6);\r |
229 | }\r |
230 | \r |
231 | #endif\r |
232 | \r |
233 | ////////////////////////////////////////////////////////////////////////\r |
234 | // OpenGL primitive drawing commands\r |
235 | ////////////////////////////////////////////////////////////////////////\r |
236 | \r |
237 | __inline void PRIMdrawTexturedQuad(OGLVertex* vertex1, OGLVertex* vertex2, \r |
238 | OGLVertex* vertex3, OGLVertex* vertex4) \r |
239 | {\r |
240 | \r |
241 | \r |
242 | Vertex v[4];\r |
243 | \r |
244 | v[0].xyz.x = fpoint(vertex1->x);\r |
245 | v[0].xyz.y = fpoint(vertex1->y);\r |
246 | v[0].xyz.z = fpoint(vertex1->z);\r |
247 | v[0].st.x = fpoint(vertex1->sow);\r |
248 | v[0].st.y = fpoint(vertex1->tow);\r |
249 | \r |
250 | v[1].xyz.x = fpoint(vertex2->x);\r |
251 | v[1].xyz.y = fpoint(vertex2->y);\r |
252 | v[1].xyz.z = fpoint(vertex2->z);\r |
253 | v[1].st.x = fpoint(vertex2->sow);\r |
254 | v[1].st.y = fpoint(vertex2->tow);\r |
255 | \r |
256 | v[2].xyz.x = fpoint(vertex4->x);\r |
257 | v[2].xyz.y = fpoint(vertex4->y);\r |
258 | v[2].xyz.z = fpoint(vertex4->z);\r |
259 | v[2].st.x = fpoint(vertex4->sow);\r |
260 | v[2].st.y = fpoint(vertex4->tow);\r |
261 | \r |
262 | v[3].xyz.x = fpoint(vertex3->x);\r |
263 | v[3].xyz.y = fpoint(vertex3->y);\r |
264 | v[3].xyz.z = fpoint(vertex3->z);\r |
265 | v[3].st.x = fpoint(vertex3->sow);\r |
266 | v[3].st.y = fpoint(vertex3->tow);\r |
267 | \r |
268 | glEnableClientState(GL_TEXTURE_COORD_ARRAY);\r |
269 | glEnableClientState(GL_VERTEX_ARRAY);\r |
270 | glTexCoordPointer(2, GL_FLOAT, sizeof(v[0]), &v[0].st);\r |
271 | glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0].xyz);\r |
272 | glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);\r |
273 | glDisableClientState(GL_TEXTURE_COORD_ARRAY);\r |
274 | glDisableClientState(GL_VERTEX_ARRAY); \r |
275 | }\r |
276 | \r |
277 | ///////////////////////////////////////////////////////// \r |
278 | \r |
279 | __inline void PRIMdrawTexturedTri(OGLVertex* vertex1, OGLVertex* vertex2, \r |
280 | OGLVertex* vertex3) \r |
281 | {\r |
282 | Vertex v[3];\r |
283 | \r |
284 | v[0].xyz.x = fpoint(vertex1->x);\r |
285 | v[0].xyz.y = fpoint(vertex1->y);\r |
286 | v[0].xyz.z = fpoint(vertex1->z);\r |
287 | v[0].st.x = fpoint(vertex1->sow);\r |
288 | v[0].st.y = fpoint(vertex1->tow);\r |
289 | \r |
290 | v[1].xyz.x = fpoint(vertex2->x);\r |
291 | v[1].xyz.y = fpoint(vertex2->y);\r |
292 | v[1].xyz.z = fpoint(vertex2->z);\r |
293 | v[1].st.x = fpoint(vertex2->sow);\r |
294 | v[1].st.y = fpoint(vertex2->tow);\r |
295 | \r |
296 | v[2].xyz.x = fpoint(vertex3->x);\r |
297 | v[2].xyz.y = fpoint(vertex3->y);\r |
298 | v[2].xyz.z = fpoint(vertex3->z);\r |
299 | v[2].st.x = fpoint(vertex3->sow);\r |
300 | v[2].st.y = fpoint(vertex3->tow);\r |
301 | \r |
302 | glEnableClientState(GL_TEXTURE_COORD_ARRAY);\r |
303 | glEnableClientState(GL_VERTEX_ARRAY);\r |
304 | glTexCoordPointer(2, GL_FLOAT, sizeof(v[0]), &v[0].st);\r |
305 | glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0].xyz);\r |
306 | glDrawArrays(GL_TRIANGLES, 0, 3);\r |
307 | glDisableClientState(GL_TEXTURE_COORD_ARRAY);\r |
308 | glDisableClientState(GL_VERTEX_ARRAY);\r |
309 | \r |
310 | }\r |
311 | \r |
312 | ///////////////////////////////////////////////////////// \r |
313 | \r |
314 | __inline void PRIMdrawTexGouraudTriColor(OGLVertex* vertex1, OGLVertex* vertex2, \r |
315 | OGLVertex* vertex3) \r |
316 | {\r |
317 | \r |
318 | Vertex2 v[3];\r |
319 | \r |
320 | v[0].xyz.x = fpoint(vertex1->x);\r |
321 | v[0].xyz.y = fpoint(vertex1->y);\r |
322 | v[0].xyz.z = fpoint(vertex1->z);\r |
323 | v[0].st.x = fpoint(vertex1->sow);\r |
324 | v[0].st.y = fpoint(vertex1->tow);\r |
325 | v[0].rgba.r = vertex1->c.col[0];\r |
326 | v[0].rgba.g = vertex1->c.col[1];\r |
327 | v[0].rgba.b = vertex1->c.col[2];\r |
328 | v[0].rgba.a = vertex1->c.col[3];\r |
329 | \r |
330 | v[1].xyz.x = fpoint(vertex2->x);\r |
331 | v[1].xyz.y = fpoint(vertex2->y);\r |
332 | v[1].xyz.z = fpoint(vertex2->z);\r |
333 | v[1].st.x = fpoint(vertex2->sow);\r |
334 | v[1].st.y = fpoint(vertex2->tow);\r |
335 | v[1].rgba.r = vertex2->c.col[0];\r |
336 | v[1].rgba.g = vertex2->c.col[1];\r |
337 | v[1].rgba.b = vertex2->c.col[2];\r |
338 | v[1].rgba.a = vertex2->c.col[3];\r |
339 | \r |
340 | v[2].xyz.x = fpoint(vertex3->x);\r |
341 | v[2].xyz.y = fpoint(vertex3->y);\r |
342 | v[2].xyz.z = fpoint(vertex3->z);\r |
343 | v[2].st.x = fpoint(vertex3->sow);\r |
344 | v[2].st.y = fpoint(vertex3->tow);\r |
345 | v[2].rgba.r = vertex3->c.col[0];\r |
346 | v[2].rgba.g = vertex3->c.col[1];\r |
347 | v[2].rgba.b = vertex3->c.col[2];\r |
348 | v[2].rgba.a = vertex3->c.col[3];\r |
349 | \r |
350 | glEnableClientState(GL_TEXTURE_COORD_ARRAY);\r |
351 | glEnableClientState(GL_VERTEX_ARRAY);\r |
352 | glEnableClientState(GL_COLOR_ARRAY);\r |
353 | \r |
354 | glTexCoordPointer(2, GL_FLOAT, sizeof(v[0]), &v[0].st);\r |
355 | glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0].xyz);\r |
356 | glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(v[0]), &v[0].rgba);\r |
357 | \r |
358 | glDrawArrays(GL_TRIANGLES, 0, 3);\r |
359 | glDisableClientState(GL_TEXTURE_COORD_ARRAY);\r |
360 | glDisableClientState(GL_VERTEX_ARRAY);\r |
361 | glDisableClientState(GL_COLOR_ARRAY);\r |
362 | }\r |
363 | \r |
364 | ///////////////////////////////////////////////////////// \r |
365 | \r |
366 | __inline void PRIMdrawTexGouraudTriColorQuad(OGLVertex* vertex1, OGLVertex* vertex2, \r |
367 | OGLVertex* vertex3, OGLVertex* vertex4) \r |
368 | {\r |
369 | Vertex2 v[4];\r |
370 | \r |
371 | v[0].xyz.x = fpoint(vertex1->x);\r |
372 | v[0].xyz.y = fpoint(vertex1->y);\r |
373 | v[0].xyz.z = fpoint(vertex1->z);\r |
374 | v[0].st.x = fpoint(vertex1->sow);\r |
375 | v[0].st.y = fpoint(vertex1->tow);\r |
376 | v[0].rgba.r = vertex1->c.col[0];\r |
377 | v[0].rgba.g = vertex1->c.col[1];\r |
378 | v[0].rgba.b = vertex1->c.col[2];\r |
379 | v[0].rgba.a = vertex1->c.col[3];\r |
380 | \r |
381 | v[1].xyz.x = fpoint(vertex2->x);\r |
382 | v[1].xyz.y = fpoint(vertex2->y);\r |
383 | v[1].xyz.z = fpoint(vertex2->z);\r |
384 | v[1].st.x = fpoint(vertex2->sow);\r |
385 | v[1].st.y = fpoint(vertex2->tow);\r |
386 | v[1].rgba.r = vertex2->c.col[0];\r |
387 | v[1].rgba.g = vertex2->c.col[1];\r |
388 | v[1].rgba.b = vertex2->c.col[2];\r |
389 | v[1].rgba.a = vertex2->c.col[3];\r |
390 | \r |
391 | v[2].xyz.x = fpoint(vertex4->x);\r |
392 | v[2].xyz.y = fpoint(vertex4->y);\r |
393 | v[2].xyz.z = fpoint(vertex4->z);\r |
394 | v[2].st.x = fpoint(vertex4->sow);\r |
395 | v[2].st.y = fpoint(vertex4->tow);\r |
396 | v[2].rgba.r = vertex4->c.col[0];\r |
397 | v[2].rgba.g = vertex4->c.col[1];\r |
398 | v[2].rgba.b = vertex4->c.col[2];\r |
399 | v[2].rgba.a = vertex4->c.col[3];\r |
400 | \r |
401 | v[3].xyz.x = fpoint(vertex3->x);\r |
402 | v[3].xyz.y = fpoint(vertex3->y);\r |
403 | v[3].xyz.z = fpoint(vertex3->z);\r |
404 | v[3].st.x = fpoint(vertex3->sow);\r |
405 | v[3].st.y = fpoint(vertex3->tow);\r |
406 | v[3].rgba.r = vertex3->c.col[0];\r |
407 | v[3].rgba.g = vertex3->c.col[1];\r |
408 | v[3].rgba.b = vertex3->c.col[2];\r |
409 | v[3].rgba.a = vertex3->c.col[3];\r |
410 | \r |
411 | glEnableClientState(GL_TEXTURE_COORD_ARRAY);\r |
412 | glEnableClientState(GL_VERTEX_ARRAY);\r |
413 | glEnableClientState(GL_COLOR_ARRAY);\r |
414 | \r |
415 | glTexCoordPointer(2, GL_FLOAT, sizeof(v[0]), &v[0].st);\r |
416 | glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0].xyz);\r |
417 | glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(v[0]), &v[0].rgba);\r |
418 | \r |
419 | glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);\r |
420 | glDisableClientState(GL_TEXTURE_COORD_ARRAY);\r |
421 | glDisableClientState(GL_VERTEX_ARRAY);\r |
422 | glDisableClientState(GL_COLOR_ARRAY);\r |
423 | }\r |
424 | \r |
425 | ///////////////////////////////////////////////////////// \r |
426 | \r |
427 | __inline void PRIMdrawTri(OGLVertex* vertex1, OGLVertex* vertex2, OGLVertex* vertex3) \r |
428 | {\r |
429 | Vec3f v[3];\r |
430 | \r |
431 | v[0].x = fpoint(vertex1->x);\r |
432 | v[0].y = fpoint(vertex1->y);\r |
433 | v[0].z = fpoint(vertex1->z);\r |
434 | \r |
435 | v[1].x = fpoint(vertex2->x);\r |
436 | v[1].y = fpoint(vertex2->y);\r |
437 | v[1].z = fpoint(vertex2->z);\r |
438 | \r |
439 | v[2].x = fpoint(vertex3->x);\r |
440 | v[2].y = fpoint(vertex3->y);\r |
441 | v[2].z = fpoint(vertex3->z);\r |
442 | \r |
443 | glEnableClientState(GL_VERTEX_ARRAY);\r |
444 | glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0]);\r |
445 | glDrawArrays(GL_TRIANGLES, 0, 3);\r |
446 | glDisableClientState(GL_VERTEX_ARRAY);\r |
447 | }\r |
448 | \r |
449 | ///////////////////////////////////////////////////////// \r |
450 | \r |
451 | __inline void PRIMdrawTri2(OGLVertex* vertex1, OGLVertex* vertex2, \r |
452 | OGLVertex* vertex3, OGLVertex* vertex4) \r |
453 | {\r |
454 | Vec3f v[4];\r |
455 | \r |
456 | v[0].x = fpoint(vertex1->x);\r |
457 | v[0].y = fpoint(vertex1->y);\r |
458 | v[0].z = fpoint(vertex1->z);\r |
459 | \r |
460 | v[1].x = fpoint(vertex3->x);\r |
461 | v[1].y = fpoint(vertex3->y);\r |
462 | v[1].z = fpoint(vertex3->z);\r |
463 | \r |
464 | v[2].x = fpoint(vertex2->x);\r |
465 | v[2].y = fpoint(vertex2->y);\r |
466 | v[2].z = fpoint(vertex2->z);\r |
467 | \r |
468 | v[3].x = fpoint(vertex4->x);\r |
469 | v[3].y = fpoint(vertex4->y);\r |
470 | v[3].z = fpoint(vertex4->z);\r |
471 | \r |
472 | glEnableClientState(GL_VERTEX_ARRAY);\r |
473 | glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0]);\r |
474 | glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);\r |
475 | glDisableClientState(GL_VERTEX_ARRAY);\r |
476 | }\r |
477 | \r |
478 | ///////////////////////////////////////////////////////// \r |
479 | \r |
480 | __inline void PRIMdrawGouraudTriColor(OGLVertex* vertex1, OGLVertex* vertex2, \r |
481 | OGLVertex* vertex3) \r |
482 | {\r |
483 | Vertex2 v[3];\r |
484 | \r |
485 | v[0].xyz.x = fpoint(vertex1->x);\r |
486 | v[0].xyz.y = fpoint(vertex1->y);\r |
487 | v[0].xyz.z = fpoint(vertex1->z);\r |
488 | v[0].rgba.r = vertex1->c.col[0];\r |
489 | v[0].rgba.g = vertex1->c.col[1];\r |
490 | v[0].rgba.b = vertex1->c.col[2];\r |
491 | v[0].rgba.a = vertex1->c.col[3];\r |
492 | \r |
493 | v[1].xyz.x = fpoint(vertex2->x);\r |
494 | v[1].xyz.y = fpoint(vertex2->y);\r |
495 | v[1].xyz.z = fpoint(vertex2->z);\r |
496 | v[1].rgba.r = vertex2->c.col[0];\r |
497 | v[1].rgba.g = vertex2->c.col[1];\r |
498 | v[1].rgba.b = vertex2->c.col[2];\r |
499 | v[1].rgba.a = vertex2->c.col[3];\r |
500 | \r |
501 | v[2].xyz.x = fpoint(vertex3->x);\r |
502 | v[2].xyz.y = fpoint(vertex3->y);\r |
503 | v[2].xyz.z = fpoint(vertex3->z);\r |
504 | v[2].rgba.r = vertex3->c.col[0];\r |
505 | v[2].rgba.g = vertex3->c.col[1];\r |
506 | v[2].rgba.b = vertex3->c.col[2];\r |
507 | v[2].rgba.a = vertex3->c.col[3];\r |
508 | \r |
509 | glEnableClientState(GL_VERTEX_ARRAY);\r |
510 | glEnableClientState(GL_COLOR_ARRAY);\r |
511 | \r |
512 | glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0].xyz);\r |
513 | glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(v[0]), &v[0].rgba);\r |
514 | \r |
515 | glDrawArrays(GL_TRIANGLES, 0, 3);\r |
516 | glDisableClientState(GL_VERTEX_ARRAY);\r |
517 | glDisableClientState(GL_COLOR_ARRAY);\r |
518 | }\r |
519 | \r |
520 | ///////////////////////////////////////////////////////// \r |
521 | \r |
522 | __inline void PRIMdrawGouraudTri2Color(OGLVertex* vertex1, OGLVertex* vertex2, \r |
523 | OGLVertex* vertex3, OGLVertex* vertex4) \r |
524 | {\r |
525 | Vertex2 v[4];\r |
526 | \r |
527 | v[0].xyz.x = fpoint(vertex1->x);\r |
528 | v[0].xyz.y = fpoint(vertex1->y);\r |
529 | v[0].xyz.z = fpoint(vertex1->z);\r |
530 | v[0].rgba.r = vertex1->c.col[0];\r |
531 | v[0].rgba.g = vertex1->c.col[1];\r |
532 | v[0].rgba.b = vertex1->c.col[2];\r |
533 | v[0].rgba.a = vertex1->c.col[3];\r |
534 | \r |
535 | v[1].xyz.x = fpoint(vertex2->x);\r |
536 | v[1].xyz.y = fpoint(vertex2->y);\r |
537 | v[1].xyz.z = fpoint(vertex2->z);\r |
538 | v[1].rgba.r = vertex2->c.col[0];\r |
539 | v[1].rgba.g = vertex2->c.col[1];\r |
540 | v[1].rgba.b = vertex2->c.col[2];\r |
541 | v[1].rgba.a = vertex2->c.col[3];\r |
542 | \r |
543 | v[2].xyz.x = fpoint(vertex3->x);\r |
544 | v[2].xyz.y = fpoint(vertex3->y);\r |
545 | v[2].xyz.z = fpoint(vertex3->z);\r |
546 | v[2].rgba.r = vertex3->c.col[0];\r |
547 | v[2].rgba.g = vertex3->c.col[1];\r |
548 | v[2].rgba.b = vertex3->c.col[2];\r |
549 | v[2].rgba.a = vertex3->c.col[3];\r |
550 | \r |
551 | v[3].xyz.x = fpoint(vertex4->x);\r |
552 | v[3].xyz.y = fpoint(vertex4->y);\r |
553 | v[3].xyz.z = fpoint(vertex4->z);\r |
554 | v[3].rgba.r = vertex4->c.col[0];\r |
555 | v[3].rgba.g = vertex4->c.col[1];\r |
556 | v[3].rgba.b = vertex4->c.col[2];\r |
557 | v[3].rgba.a = vertex4->c.col[3];\r |
558 | \r |
559 | glEnableClientState(GL_VERTEX_ARRAY);\r |
560 | glEnableClientState(GL_COLOR_ARRAY);\r |
561 | \r |
562 | glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0].xyz);\r |
563 | glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(v[0]), &v[0].rgba);\r |
564 | \r |
565 | glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);\r |
566 | glDisableClientState(GL_VERTEX_ARRAY);\r |
567 | glDisableClientState(GL_COLOR_ARRAY);\r |
568 | }\r |
569 | \r |
570 | ///////////////////////////////////////////////////////// \r |
571 | \r |
572 | __inline void PRIMdrawFlatLine(OGLVertex* vertex1, OGLVertex* vertex2,OGLVertex* vertex3, OGLVertex* vertex4)\r |
573 | {\r |
574 | Vertex2 v[4];\r |
575 | \r |
576 | v[0].xyz.x = fpoint(vertex1->x);\r |
577 | v[0].xyz.y = fpoint(vertex1->y);\r |
578 | v[0].xyz.z = fpoint(vertex1->z);\r |
579 | v[0].rgba.r = vertex1->c.col[0];\r |
580 | v[0].rgba.g = vertex1->c.col[1];\r |
581 | v[0].rgba.b = vertex1->c.col[2];\r |
582 | v[0].rgba.a = vertex1->c.col[3];\r |
583 | \r |
584 | v[1].xyz.x = fpoint(vertex2->x);\r |
585 | v[1].xyz.y = fpoint(vertex2->y);\r |
586 | v[1].xyz.z = fpoint(vertex2->z);\r |
587 | v[1].rgba.r = vertex1->c.col[0];\r |
588 | v[1].rgba.g = vertex1->c.col[1];\r |
589 | v[1].rgba.b = vertex1->c.col[2];\r |
590 | v[1].rgba.a = vertex1->c.col[3];\r |
591 | \r |
592 | v[2].xyz.x = fpoint(vertex4->x);\r |
593 | v[2].xyz.y = fpoint(vertex4->y);\r |
594 | v[2].xyz.z = fpoint(vertex4->z);\r |
595 | v[2].rgba.r = vertex1->c.col[0];\r |
596 | v[2].rgba.g = vertex1->c.col[1];\r |
597 | v[2].rgba.b = vertex1->c.col[2];\r |
598 | v[2].rgba.a = vertex1->c.col[3];\r |
599 | \r |
600 | v[3].xyz.x = fpoint(vertex3->x);\r |
601 | v[3].xyz.y = fpoint(vertex3->y);\r |
602 | v[3].xyz.z = fpoint(vertex3->z);\r |
603 | v[3].rgba.r = vertex1->c.col[0];\r |
604 | v[3].rgba.g = vertex1->c.col[1];\r |
605 | v[3].rgba.b = vertex1->c.col[2];\r |
606 | v[3].rgba.a = vertex1->c.col[3];\r |
607 | \r |
608 | glEnableClientState(GL_VERTEX_ARRAY);\r |
609 | glEnableClientState(GL_COLOR_ARRAY);\r |
610 | \r |
611 | glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0].xyz);\r |
612 | glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(v[0]), &v[0].rgba);\r |
613 | \r |
614 | glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);\r |
615 | glDisableClientState(GL_VERTEX_ARRAY);\r |
616 | glDisableClientState(GL_COLOR_ARRAY);\r |
617 | \r |
618 | \r |
619 | }\r |
620 | \r |
621 | ///////////////////////////////////////////////////////// \r |
622 | \r |
623 | __inline void PRIMdrawGouraudLine(OGLVertex* vertex1, OGLVertex* vertex2,OGLVertex* vertex3, OGLVertex* vertex4)\r |
624 | {\r |
625 | Vertex2 v[4];\r |
626 | \r |
627 | v[0].xyz.x = fpoint(vertex1->x);\r |
628 | v[0].xyz.y = fpoint(vertex1->y);\r |
629 | v[0].xyz.z = fpoint(vertex1->z);\r |
630 | v[0].rgba.r = vertex1->c.col[0];\r |
631 | v[0].rgba.g = vertex1->c.col[1];\r |
632 | v[0].rgba.b = vertex1->c.col[2];\r |
633 | v[0].rgba.a = vertex1->c.col[3];\r |
634 | \r |
635 | v[1].xyz.x = fpoint(vertex2->x);\r |
636 | v[1].xyz.y = fpoint(vertex2->y);\r |
637 | v[1].xyz.z = fpoint(vertex2->z);\r |
638 | v[1].rgba.r = vertex2->c.col[0];\r |
639 | v[1].rgba.g = vertex2->c.col[1];\r |
640 | v[1].rgba.b = vertex2->c.col[2];\r |
641 | v[1].rgba.a = vertex2->c.col[3];\r |
642 | \r |
643 | v[3].xyz.x = fpoint(vertex3->x);\r |
644 | v[3].xyz.y = fpoint(vertex3->y);\r |
645 | v[3].xyz.z = fpoint(vertex3->z);\r |
646 | v[3].rgba.r = vertex3->c.col[0];\r |
647 | v[3].rgba.g = vertex3->c.col[1];\r |
648 | v[3].rgba.b = vertex3->c.col[2];\r |
649 | v[3].rgba.a = vertex3->c.col[3];\r |
650 | \r |
651 | v[2].xyz.x = fpoint(vertex4->x);\r |
652 | v[2].xyz.y = fpoint(vertex4->y);\r |
653 | v[2].xyz.z = fpoint(vertex4->z);\r |
654 | v[2].rgba.r = vertex4->c.col[0];\r |
655 | v[2].rgba.g = vertex4->c.col[1];\r |
656 | v[2].rgba.b = vertex4->c.col[2];\r |
657 | v[2].rgba.a = vertex4->c.col[3];\r |
658 | \r |
659 | glEnableClientState(GL_VERTEX_ARRAY);\r |
660 | glEnableClientState(GL_COLOR_ARRAY);\r |
661 | \r |
662 | glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0].xyz);\r |
663 | glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(v[0]), &v[0].rgba);\r |
664 | \r |
665 | glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);\r |
666 | glDisableClientState(GL_VERTEX_ARRAY);\r |
667 | glDisableClientState(GL_COLOR_ARRAY);\r |
668 | }\r |
669 | \r |
670 | ///////////////////////////////////////////////////////// \r |
671 | \r |
672 | __inline void PRIMdrawQuad(OGLVertex* vertex1, OGLVertex* vertex2, \r |
673 | OGLVertex* vertex3, OGLVertex* vertex4) \r |
674 | {\r |
675 | Vec3f v[4];\r |
676 | \r |
677 | v[0].x = fpoint(vertex1->x);\r |
678 | v[0].y = fpoint(vertex1->y);\r |
679 | v[0].z = fpoint(vertex1->z);\r |
680 | \r |
681 | v[1].x = fpoint(vertex2->x);\r |
682 | v[1].y = fpoint(vertex2->y);\r |
683 | v[1].z = fpoint(vertex2->z);\r |
684 | \r |
685 | v[2].x = fpoint(vertex4->x);\r |
686 | v[2].y = fpoint(vertex4->y);\r |
687 | v[2].z = fpoint(vertex4->z);\r |
688 | \r |
689 | v[3].x = fpoint(vertex3->x);\r |
690 | v[3].y = fpoint(vertex3->y);\r |
691 | v[3].z = fpoint(vertex3->z);\r |
692 | \r |
693 | glEnableClientState(GL_VERTEX_ARRAY);\r |
694 | glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0]);\r |
695 | glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);\r |
696 | glDisableClientState(GL_VERTEX_ARRAY);\r |
697 | }\r |
698 | \r |
699 | //////////////////////////////////////////////////////////////////////// \r |
700 | // Transparent blending settings\r |
701 | ////////////////////////////////////////////////////////////////////////\r |
702 | \r |
703 | static GLenum obm1=GL_ZERO;\r |
704 | static GLenum obm2=GL_ZERO;\r |
705 | \r |
706 | typedef struct SEMITRANSTAG\r |
707 | {\r |
708 | GLenum srcFac;\r |
709 | GLenum dstFac;\r |
710 | GLubyte alpha;\r |
711 | } SemiTransParams;\r |
712 | \r |
713 | SemiTransParams TransSets[4]=\r |
714 | {\r |
715 | {GL_SRC_ALPHA,GL_SRC_ALPHA, 127},\r |
716 | {GL_ONE, GL_ONE, 255},\r |
717 | {GL_ZERO, GL_ONE_MINUS_SRC_COLOR,255},\r |
718 | {GL_ONE_MINUS_SRC_ALPHA,GL_ONE, 192}\r |
719 | }; \r |
720 | \r |
721 | ////////////////////////////////////////////////////////////////////////\r |
722 | \r |
723 | void SetSemiTrans(void)\r |
724 | {\r |
725 | /*\r |
726 | * 0.5 x B + 0.5 x F\r |
727 | * 1.0 x B + 1.0 x F\r |
728 | * 1.0 x B - 1.0 x F\r |
729 | * 1.0 x B +0.25 x F\r |
730 | */\r |
731 | \r |
732 | if(!DrawSemiTrans) // no semi trans at all?\r |
733 | {\r |
734 | if(bBlendEnable)\r |
735 | {glDisable(GL_BLEND);bBlendEnable=FALSE;} // -> don't wanna blend\r |
736 | ubGloAlpha=ubGloColAlpha=255; // -> full alpha\r |
737 | return; // -> and bye\r |
738 | }\r |
739 | \r |
740 | ubGloAlpha=ubGloColAlpha=TransSets[GlobalTextABR].alpha;\r |
741 | \r |
742 | if(!bBlendEnable)\r |
743 | {glEnable(GL_BLEND);bBlendEnable=TRUE;} // wanna blend\r |
744 | \r |
745 | if(TransSets[GlobalTextABR].srcFac!=obm1 || \r |
746 | TransSets[GlobalTextABR].dstFac!=obm2)\r |
747 | {\r |
748 | //if(glBlendEquationEXTEx==NULL)\r |
749 | {\r |
750 | obm1=TransSets[GlobalTextABR].srcFac;\r |
751 | obm2=TransSets[GlobalTextABR].dstFac;\r |
752 | glBlendFunc(obm1,obm2); // set blend func\r |
753 | }\r |
754 | /*else\r |
755 | if(TransSets[GlobalTextABR].dstFac !=GL_ONE_MINUS_SRC_COLOR)\r |
756 | {\r |
757 | if(obm2==GL_ONE_MINUS_SRC_COLOR)\r |
758 | glBlendEquationEXTEx(FUNC_ADD_EXT);\r |
759 | obm1=TransSets[GlobalTextABR].srcFac;\r |
760 | obm2=TransSets[GlobalTextABR].dstFac;\r |
761 | glBlendFunc(obm1,obm2); // set blend func\r |
762 | }\r |
763 | else\r |
764 | {\r |
765 | glBlendEquationEXTEx(FUNC_REVERSESUBTRACT_EXT);\r |
766 | obm1=TransSets[GlobalTextABR].srcFac;\r |
767 | obm2=TransSets[GlobalTextABR].dstFac;\r |
768 | glBlendFunc(GL_ONE,GL_ONE); // set blend func\r |
769 | }*/\r |
770 | }\r |
771 | }\r |
772 | \r |
773 | void SetScanTrans(void) // blending for scan lines\r |
774 | {\r |
775 | /* if(glBlendEquationEXTEx!=NULL)\r |
776 | {\r |
777 | if(obm2==GL_ONE_MINUS_SRC_COLOR)\r |
778 | glBlendEquationEXTEx(FUNC_ADD_EXT);\r |
779 | }\r |
780 | */\r |
781 | obm1=TransSets[0].srcFac;\r |
782 | obm2=TransSets[0].dstFac;\r |
783 | glBlendFunc(obm1,obm2); // set blend func\r |
784 | }\r |
785 | \r |
786 | void SetScanTexTrans(void) // blending for scan mask texture\r |
787 | {\r |
788 | /* if(glBlendEquationEXTEx!=NULL)\r |
789 | {\r |
790 | if(obm2==GL_ONE_MINUS_SRC_COLOR)\r |
791 | glBlendEquationEXTEx(FUNC_ADD_EXT);\r |
792 | }\r |
793 | */\r |
794 | obm1=TransSets[2].srcFac;\r |
795 | obm2=TransSets[2].dstFac;\r |
796 | glBlendFunc(obm1,obm2); // set blend func\r |
797 | }\r |
798 | \r |
799 | //////////////////////////////////////////////////////////////////////// \r |
800 | // multi pass in old 'Advanced blending' mode... got it from Lewpy :)\r |
801 | //////////////////////////////////////////////////////////////////////// \r |
802 | \r |
803 | SemiTransParams MultiTexTransSets[4][2]=\r |
804 | {\r |
805 | {\r |
806 | {GL_ONE ,GL_SRC_ALPHA, 127},\r |
807 | {GL_SRC_ALPHA,GL_ONE, 127}\r |
808 | },\r |
809 | {\r |
810 | {GL_ONE, GL_SRC_ALPHA, 255},\r |
811 | {GL_SRC_ALPHA,GL_ONE, 255}\r |
812 | },\r |
813 | {\r |
814 | {GL_ZERO, GL_ONE_MINUS_SRC_COLOR,255},\r |
815 | {GL_ZERO, GL_ONE_MINUS_SRC_COLOR,255}\r |
816 | },\r |
817 | {\r |
818 | {GL_SRC_ALPHA,GL_ONE, 127},\r |
819 | {GL_ONE_MINUS_SRC_ALPHA,GL_ONE, 255}\r |
820 | }\r |
821 | }; \r |
822 | \r |
823 | //////////////////////////////////////////////////////////////////////// \r |
824 | \r |
825 | SemiTransParams MultiColTransSets[4]=\r |
826 | {\r |
827 | {GL_ONE_MINUS_SRC_ALPHA,GL_SRC_ALPHA,127},\r |
828 | {GL_ONE, GL_ONE, 255},\r |
829 | {GL_ZERO, GL_ONE_MINUS_SRC_COLOR,255},\r |
830 | {GL_SRC_ALPHA,GL_ONE, 127}\r |
831 | }; \r |
832 | \r |
833 | //////////////////////////////////////////////////////////////////////// \r |
834 | \r |
835 | void SetSemiTransMulti(int Pass)\r |
836 | {\r |
837 | static GLenum bm1=GL_ZERO;\r |
838 | static GLenum bm2=GL_ONE;\r |
839 | \r |
840 | ubGloAlpha=255;\r |
841 | ubGloColAlpha=255;\r |
842 | \r |
843 | // are we enabling SemiTransparent mode?\r |
844 | if(DrawSemiTrans)\r |
845 | {\r |
846 | if(bDrawTextured)\r |
847 | {\r |
848 | bm1=MultiTexTransSets[GlobalTextABR][Pass].srcFac;\r |
849 | bm2=MultiTexTransSets[GlobalTextABR][Pass].dstFac;\r |
850 | ubGloAlpha=MultiTexTransSets[GlobalTextABR][Pass].alpha;\r |
851 | }\r |
852 | // no texture\r |
853 | else\r |
854 | {\r |
855 | bm1=MultiColTransSets[GlobalTextABR].srcFac;\r |
856 | bm2=MultiColTransSets[GlobalTextABR].dstFac;\r |
857 | ubGloColAlpha=MultiColTransSets[GlobalTextABR].alpha;\r |
858 | }\r |
859 | }\r |
860 | // no shading\r |
861 | else\r |
862 | {\r |
863 | if(Pass==0)\r |
864 | {\r |
865 | // disable blending\r |
866 | bm1=GL_ONE;bm2=GL_ZERO;\r |
867 | }\r |
868 | else\r |
869 | {\r |
870 | // disable blending, but add src col a second time\r |
871 | bm1=GL_ONE;bm2=GL_ONE;\r |
872 | }\r |
873 | }\r |
874 | \r |
875 | if(!bBlendEnable)\r |
876 | {glEnable(GL_BLEND);bBlendEnable=TRUE;} // wanna blend\r |
877 | \r |
878 | if(bm1!=obm1 || bm2!=obm2)\r |
879 | {\r |
880 | glBlendFunc(bm1,bm2); // set blend func\r |
881 | obm1=bm1;obm2=bm2;\r |
882 | }\r |
883 | }\r |
884 | \r |
885 | //////////////////////////////////////////////////////////////////////// \r |
886 | // Set several rendering stuff including blending \r |
887 | ////////////////////////////////////////////////////////////////////////\r |
888 | \r |
889 | __inline void SetZMask3O(void)\r |
890 | {\r |
891 | if(iUseMask && DrawSemiTrans && !iSetMask)\r |
892 | {\r |
893 | vertex[0].z=vertex[1].z=vertex[2].z=gl_z;\r |
894 | gl_z+=0.00004f;\r |
895 | }\r |
896 | }\r |
897 | \r |
898 | __inline void SetZMask3(void)\r |
899 | {\r |
900 | if(iUseMask)\r |
901 | {\r |
902 | if(iSetMask || DrawSemiTrans)\r |
903 | {vertex[0].z=vertex[1].z=vertex[2].z=0.95f;}\r |
904 | else\r |
905 | {\r |
906 | vertex[0].z=vertex[1].z=vertex[2].z=gl_z;\r |
907 | gl_z+=0.00004f;\r |
908 | }\r |
909 | }\r |
910 | }\r |
911 | \r |
912 | __inline void SetZMask3NT(void)\r |
913 | {\r |
914 | if(iUseMask)\r |
915 | {\r |
916 | if(iSetMask)\r |
917 | {vertex[0].z=vertex[1].z=vertex[2].z=0.95f;}\r |
918 | else\r |
919 | {\r |
920 | vertex[0].z=vertex[1].z=vertex[2].z=gl_z;\r |
921 | gl_z+=0.00004f;\r |
922 | }\r |
923 | }\r |
924 | }\r |
925 | \r |
926 | ////////////////////////////////////////////////////////////////////////\r |
927 | \r |
928 | __inline void SetZMask4O(void)\r |
929 | {\r |
930 | if(iUseMask && DrawSemiTrans && !iSetMask)\r |
931 | {\r |
932 | vertex[0].z=vertex[1].z=vertex[2].z=vertex[3].z=gl_z;\r |
933 | gl_z+=0.00004f;\r |
934 | }\r |
935 | }\r |
936 | \r |
937 | __inline void SetZMask4(void)\r |
938 | {\r |
939 | if(iUseMask)\r |
940 | {\r |
941 | if(iSetMask || DrawSemiTrans)\r |
942 | {vertex[0].z=vertex[1].z=vertex[2].z=vertex[3].z=0.95f;}\r |
943 | else\r |
944 | {\r |
945 | vertex[0].z=vertex[1].z=vertex[2].z=vertex[3].z=gl_z;\r |
946 | gl_z+=0.00004f;\r |
947 | }\r |
948 | }\r |
949 | }\r |
950 | \r |
951 | __inline void SetZMask4NT(void)\r |
952 | {\r |
953 | if(iUseMask)\r |
954 | {\r |
955 | if(iSetMask==1)\r |
956 | {vertex[0].z=vertex[1].z=vertex[2].z=vertex[3].z=0.95f;}\r |
957 | else\r |
958 | {\r |
959 | vertex[0].z=vertex[1].z=vertex[2].z=vertex[3].z=gl_z;\r |
960 | gl_z+=0.00004f;\r |
961 | }\r |
962 | }\r |
963 | }\r |
964 | \r |
965 | __inline void SetZMask4SP(void)\r |
966 | {\r |
967 | if(iUseMask)\r |
968 | {\r |
969 | if(iSetMask==1)\r |
970 | {vertex[0].z=vertex[1].z=vertex[2].z=vertex[3].z=0.95f;}\r |
971 | else\r |
972 | {\r |
973 | if(bCheckMask)\r |
974 | {\r |
975 | vertex[0].z=vertex[1].z=vertex[2].z=vertex[3].z=gl_z;\r |
976 | gl_z+=0.00004f;\r |
977 | }\r |
978 | else\r |
979 | {vertex[0].z=vertex[1].z=vertex[2].z=vertex[3].z=0.95f;}\r |
980 | }\r |
981 | }\r |
982 | }\r |
983 | \r |
984 | ////////////////////////////////////////////////////////////////////////\r |
985 | \r |
986 | __inline void SetRenderState(unsigned long DrawAttributes)\r |
987 | {\r |
988 | bDrawNonShaded = (SHADETEXBIT(DrawAttributes)) ? TRUE : FALSE;\r |
989 | DrawSemiTrans = (SEMITRANSBIT(DrawAttributes)) ? TRUE : FALSE;\r |
990 | } \r |
991 | \r |
992 | //////////////////////////////////////////////////////////////////////// \r |
993 | \r |
994 | __inline void SetRenderColor(unsigned long DrawAttributes)\r |
995 | {\r |
996 | if(bDrawNonShaded) {g_m1=g_m2=g_m3=128;}\r |
997 | else\r |
998 | {\r |
999 | g_m1=DrawAttributes&0xff;\r |
1000 | g_m2=(DrawAttributes>>8)&0xff;\r |
1001 | g_m3=(DrawAttributes>>16)&0xff;\r |
1002 | }\r |
1003 | }\r |
1004 | \r |
1005 | //////////////////////////////////////////////////////////////////////// \r |
1006 | \r |
1007 | void SetRenderMode(unsigned long DrawAttributes,BOOL bSCol)\r |
1008 | {\r |
1009 | if((bUseMultiPass) && (bDrawTextured) && !(bDrawNonShaded))\r |
1010 | {bDrawMultiPass = TRUE; SetSemiTransMulti(0);}\r |
1011 | else {bDrawMultiPass = FALSE;SetSemiTrans();}\r |
1012 | \r |
1013 | if(bDrawTextured) // texture ? build it/get it from cache\r |
1014 | {\r |
1015 | GLuint currTex;\r |
1016 | if(bUsingTWin) currTex=LoadTextureWnd(GlobalTexturePage,GlobalTextTP, ulClutID);\r |
1017 | else if(bUsingMovie) currTex=LoadTextureMovie();\r |
1018 | else currTex=SelectSubTextureS(GlobalTextTP,ulClutID);\r |
1019 | \r |
1020 | if(gTexName!=currTex)\r |
1021 | {gTexName=currTex;glBindTexture(GL_TEXTURE_2D,currTex);}\r |
1022 | \r |
1023 | if(!bTexEnabled) // -> turn texturing on\r |
1024 | {bTexEnabled=TRUE;glEnable(GL_TEXTURE_2D);}\r |
1025 | }\r |
1026 | else // no texture ?\r |
1027 | if(bTexEnabled) \r |
1028 | {bTexEnabled=FALSE;glDisable(GL_TEXTURE_2D);} // -> turn texturing off\r |
1029 | \r |
1030 | if(bSCol) // also set color ?\r |
1031 | {\r |
1032 | if((dwActFixes&4) && ((DrawAttributes&0x00ffffff)==0))\r |
1033 | DrawAttributes|=0x007f7f7f;\r |
1034 | \r |
1035 | if(bDrawNonShaded) // -> non shaded?\r |
1036 | {\r |
1037 | /* if(bGLBlend) vertex[0].c.lcol=0x7f7f7f; // --> solid color...\r |
1038 | else */vertex[0].c.lcol=0xffffff;\r |
1039 | }\r |
1040 | else // -> shaded?\r |
1041 | {\r |
1042 | // if(!bUseMultiPass && !bGLBlend) // --> given color...\r |
1043 | vertex[0].c.lcol=DoubleBGR2RGB(DrawAttributes);\r |
1044 | // else vertex[0].c.lcol=DrawAttributes;\r |
1045 | }\r |
1046 | vertex[0].c.col[3]=ubGloAlpha; // -> set color with\r |
1047 | SETCOL(vertex[0]); // texture alpha\r |
1048 | }\r |
1049 | \r |
1050 | if(bDrawSmoothShaded!=bOldSmoothShaded) // shading changed?\r |
1051 | {\r |
1052 | if(bDrawSmoothShaded) glShadeModel(GL_SMOOTH); // -> set actual shading\r |
1053 | else glShadeModel(GL_FLAT);\r |
1054 | bOldSmoothShaded=bDrawSmoothShaded;\r |
1055 | }\r |
1056 | }\r |
1057 | \r |
1058 | //////////////////////////////////////////////////////////////////////// \r |
1059 | // Set Opaque multipass color\r |
1060 | ////////////////////////////////////////////////////////////////////////\r |
1061 | \r |
1062 | void SetOpaqueColor(unsigned long DrawAttributes)\r |
1063 | {\r |
1064 | if(bDrawNonShaded) return; // no shading? bye\r |
1065 | \r |
1066 | DrawAttributes=DoubleBGR2RGB(DrawAttributes); // multipass is just half color, so double it on opaque pass\r |
1067 | vertex[0].c.lcol=DrawAttributes|0xff000000;\r |
1068 | SETCOL(vertex[0]); // set color\r |
1069 | }\r |
1070 | \r |
1071 | //////////////////////////////////////////////////////////////////////// \r |
1072 | // Fucking stupid screen coord checking\r |
1073 | ////////////////////////////////////////////////////////////////////////\r |
1074 | \r |
1075 | BOOL ClipVertexListScreen(void)\r |
1076 | {\r |
1077 | if (lx0 >= PSXDisplay.DisplayEnd.x) goto NEXTSCRTEST;\r |
1078 | if (ly0 >= PSXDisplay.DisplayEnd.y) goto NEXTSCRTEST;\r |
1079 | if (lx2 < PSXDisplay.DisplayPosition.x) goto NEXTSCRTEST;\r |
1080 | if (ly2 < PSXDisplay.DisplayPosition.y) goto NEXTSCRTEST;\r |
1081 | \r |
1082 | return TRUE;\r |
1083 | \r |
1084 | NEXTSCRTEST:\r |
1085 | if(PSXDisplay.InterlacedTest) return FALSE;\r |
1086 | \r |
1087 | if (lx0 >= PreviousPSXDisplay.DisplayEnd.x) return FALSE;\r |
1088 | if (ly0 >= PreviousPSXDisplay.DisplayEnd.y) return FALSE;\r |
1089 | if (lx2 < PreviousPSXDisplay.DisplayPosition.x) return FALSE;\r |
1090 | if (ly2 < PreviousPSXDisplay.DisplayPosition.y) return FALSE;\r |
1091 | \r |
1092 | return TRUE;\r |
1093 | }\r |
1094 | \r |
1095 | ////////////////////////////////////////////////////////////////////////\r |
1096 | \r |
1097 | BOOL bDrawOffscreenFront(void)\r |
1098 | {\r |
1099 | if(sxmin < PSXDisplay.DisplayPosition.x) return FALSE; // must be complete in front\r |
1100 | if(symin < PSXDisplay.DisplayPosition.y) return FALSE;\r |
1101 | if(sxmax > PSXDisplay.DisplayEnd.x) return FALSE;\r |
1102 | if(symax > PSXDisplay.DisplayEnd.y) return FALSE;\r |
1103 | return TRUE;\r |
1104 | }\r |
1105 | \r |
1106 | BOOL bOnePointInFront(void)\r |
1107 | {\r |
1108 | if(sxmax< PSXDisplay.DisplayPosition.x)\r |
1109 | return FALSE;\r |
1110 | \r |
1111 | if(symax< PSXDisplay.DisplayPosition.y)\r |
1112 | return FALSE;\r |
1113 | \r |
1114 | if(sxmin>=PSXDisplay.DisplayEnd.x)\r |
1115 | return FALSE;\r |
1116 | \r |
1117 | if(symin>=PSXDisplay.DisplayEnd.y)\r |
1118 | return FALSE;\r |
1119 | \r |
1120 | return TRUE;\r |
1121 | }\r |
1122 | \r |
1123 | \r |
1124 | BOOL bOnePointInBack(void)\r |
1125 | {\r |
1126 | if(sxmax< PreviousPSXDisplay.DisplayPosition.x)\r |
1127 | return FALSE;\r |
1128 | \r |
1129 | if(symax< PreviousPSXDisplay.DisplayPosition.y)\r |
1130 | return FALSE;\r |
1131 | \r |
1132 | if(sxmin>=PreviousPSXDisplay.DisplayEnd.x)\r |
1133 | return FALSE;\r |
1134 | \r |
1135 | if(symin>=PreviousPSXDisplay.DisplayEnd.y)\r |
1136 | return FALSE;\r |
1137 | \r |
1138 | return TRUE;\r |
1139 | }\r |
1140 | \r |
1141 | BOOL bDrawOffscreen4(void)\r |
1142 | {\r |
1143 | BOOL bFront;short sW,sH;\r |
1144 | \r |
1145 | sxmax=max(lx0,max(lx1,max(lx2,lx3)));\r |
1146 | if(sxmax<drawX) return FALSE;\r |
1147 | sxmin=min(lx0,min(lx1,min(lx2,lx3)));\r |
1148 | if(sxmin>drawW) return FALSE;\r |
1149 | symax=max(ly0,max(ly1,max(ly2,ly3)));\r |
1150 | if(symax<drawY) return FALSE;\r |
1151 | symin=min(ly0,min(ly1,min(ly2,ly3)));\r |
1152 | if(symin>drawH) return FALSE;\r |
1153 | \r |
1154 | if(PSXDisplay.Disabled) return TRUE; // disabled? ever\r |
1155 | \r |
1156 | if(iOffscreenDrawing==1) return bFullVRam;\r |
1157 | \r |
1158 | if(dwActFixes&1 && iOffscreenDrawing==4)\r |
1159 | {\r |
1160 | if(PreviousPSXDisplay.DisplayPosition.x==PSXDisplay.DisplayPosition.x &&\r |
1161 | PreviousPSXDisplay.DisplayPosition.y==PSXDisplay.DisplayPosition.y &&\r |
1162 | PreviousPSXDisplay.DisplayEnd.x==PSXDisplay.DisplayEnd.x &&\r |
1163 | PreviousPSXDisplay.DisplayEnd.y==PSXDisplay.DisplayEnd.y)\r |
1164 | {\r |
1165 | bRenderFrontBuffer=TRUE;\r |
1166 | return FALSE;\r |
1167 | }\r |
1168 | }\r |
1169 | \r |
1170 | sW=drawW-1;sH=drawH-1;\r |
1171 | \r |
1172 | sxmin=min(sW,max(sxmin,drawX));\r |
1173 | sxmax=max(drawX,min(sxmax,sW));\r |
1174 | symin=min(sH,max(symin,drawY));\r |
1175 | symax=max(drawY,min(symax,sH));\r |
1176 | \r |
1177 | if(bOnePointInBack()) return bFullVRam;\r |
1178 | \r |
1179 | if(iOffscreenDrawing==2) \r |
1180 | bFront=bDrawOffscreenFront();\r |
1181 | else bFront=bOnePointInFront();\r |
1182 | \r |
1183 | if(bFront)\r |
1184 | {\r |
1185 | if(PSXDisplay.InterlacedTest) return bFullVRam; // -> ok, no need for adjust\r |
1186 | \r |
1187 | vertex[0].x=lx0 - PSXDisplay.DisplayPosition.x+PreviousPSXDisplay.Range.x0;\r |
1188 | vertex[1].x=lx1 - PSXDisplay.DisplayPosition.x+PreviousPSXDisplay.Range.x0;\r |
1189 | vertex[2].x=lx2 - PSXDisplay.DisplayPosition.x+PreviousPSXDisplay.Range.x0;\r |
1190 | vertex[3].x=lx3 - PSXDisplay.DisplayPosition.x+PreviousPSXDisplay.Range.x0;\r |
1191 | vertex[0].y=ly0 - PSXDisplay.DisplayPosition.y+PreviousPSXDisplay.Range.y0;\r |
1192 | vertex[1].y=ly1 - PSXDisplay.DisplayPosition.y+PreviousPSXDisplay.Range.y0;\r |
1193 | vertex[2].y=ly2 - PSXDisplay.DisplayPosition.y+PreviousPSXDisplay.Range.y0;\r |
1194 | vertex[3].y=ly3 - PSXDisplay.DisplayPosition.y+PreviousPSXDisplay.Range.y0;\r |
1195 | \r |
1196 | if(iOffscreenDrawing==4 && !(dwActFixes&1)) // -> frontbuffer wanted\r |
1197 | {\r |
1198 | bRenderFrontBuffer=TRUE;\r |
1199 | //return TRUE;\r |
1200 | }\r |
1201 | return bFullVRam; // -> but no od\r |
1202 | }\r |
1203 | \r |
1204 | return TRUE;\r |
1205 | }\r |
1206 | \r |
1207 | ////////////////////////////////////////////////////////////////////////\r |
1208 | \r |
1209 | BOOL bDrawOffscreen3(void)\r |
1210 | {\r |
1211 | BOOL bFront;short sW,sH;\r |
1212 | \r |
1213 | sxmax=max(lx0,max(lx1,lx2));\r |
1214 | if(sxmax<drawX) return FALSE;\r |
1215 | sxmin=min(lx0,min(lx1,lx2));\r |
1216 | if(sxmin>drawW) return FALSE;\r |
1217 | symax=max(ly0,max(ly1,ly2));\r |
1218 | if(symax<drawY) return FALSE;\r |
1219 | symin=min(ly0,min(ly1,ly2));\r |
1220 | if(symin>drawH) return FALSE;\r |
1221 | \r |
1222 | if(PSXDisplay.Disabled) return TRUE; // disabled? ever\r |
1223 | \r |
1224 | if(iOffscreenDrawing==1) return bFullVRam;\r |
1225 | \r |
1226 | sW=drawW-1;sH=drawH-1;\r |
1227 | sxmin=min(sW,max(sxmin,drawX));\r |
1228 | sxmax=max(drawX,min(sxmax,sW));\r |
1229 | symin=min(sH,max(symin,drawY));\r |
1230 | symax=max(drawY,min(symax,sH));\r |
1231 | \r |
1232 | if(bOnePointInBack()) return bFullVRam;\r |
1233 | \r |
1234 | if(iOffscreenDrawing==2) \r |
1235 | bFront=bDrawOffscreenFront();\r |
1236 | else bFront=bOnePointInFront();\r |
1237 | \r |
1238 | if(bFront)\r |
1239 | {\r |
1240 | if(PSXDisplay.InterlacedTest) return bFullVRam; // -> ok, no need for adjust\r |
1241 | \r |
1242 | vertex[0].x=lx0 - PSXDisplay.DisplayPosition.x+PreviousPSXDisplay.Range.x0;\r |
1243 | vertex[1].x=lx1 - PSXDisplay.DisplayPosition.x+PreviousPSXDisplay.Range.x0;\r |
1244 | vertex[2].x=lx2 - PSXDisplay.DisplayPosition.x+PreviousPSXDisplay.Range.x0;\r |
1245 | vertex[0].y=ly0 - PSXDisplay.DisplayPosition.y+PreviousPSXDisplay.Range.y0;\r |
1246 | vertex[1].y=ly1 - PSXDisplay.DisplayPosition.y+PreviousPSXDisplay.Range.y0;\r |
1247 | vertex[2].y=ly2 - PSXDisplay.DisplayPosition.y+PreviousPSXDisplay.Range.y0;\r |
1248 | \r |
1249 | if(iOffscreenDrawing==4) // -> frontbuffer wanted\r |
1250 | {\r |
1251 | bRenderFrontBuffer=TRUE;\r |
1252 | // return TRUE;\r |
1253 | }\r |
1254 | \r |
1255 | return bFullVRam; // -> but no od\r |
1256 | }\r |
1257 | \r |
1258 | return TRUE;\r |
1259 | }\r |
1260 | \r |
1261 | ////////////////////////////////////////////////////////////////////////\r |
1262 | \r |
1263 | BOOL FastCheckAgainstScreen(short imageX0,short imageY0,short imageX1,short imageY1)\r |
1264 | {\r |
1265 | PSXRect_t xUploadArea;\r |
1266 | \r |
1267 | imageX1 += imageX0;\r |
1268 | imageY1 += imageY0;\r |
1269 | \r |
1270 | if (imageX0 < PreviousPSXDisplay.DisplayPosition.x)\r |
1271 | xUploadArea.x0 = PreviousPSXDisplay.DisplayPosition.x;\r |
1272 | else\r |
1273 | if (imageX0 > PreviousPSXDisplay.DisplayEnd.x)\r |
1274 | xUploadArea.x0 = PreviousPSXDisplay.DisplayEnd.x;\r |
1275 | else\r |
1276 | xUploadArea.x0 = imageX0;\r |
1277 | \r |
1278 | if(imageX1 < PreviousPSXDisplay.DisplayPosition.x)\r |
1279 | xUploadArea.x1 = PreviousPSXDisplay.DisplayPosition.x;\r |
1280 | else\r |
1281 | if (imageX1 > PreviousPSXDisplay.DisplayEnd.x)\r |
1282 | xUploadArea.x1 = PreviousPSXDisplay.DisplayEnd.x;\r |
1283 | else\r |
1284 | xUploadArea.x1 = imageX1;\r |
1285 | \r |
1286 | if (imageY0 < PreviousPSXDisplay.DisplayPosition.y)\r |
1287 | xUploadArea.y0 = PreviousPSXDisplay.DisplayPosition.y;\r |
1288 | else\r |
1289 | if (imageY0 > PreviousPSXDisplay.DisplayEnd.y)\r |
1290 | xUploadArea.y0 = PreviousPSXDisplay.DisplayEnd.y;\r |
1291 | else\r |
1292 | xUploadArea.y0 = imageY0;\r |
1293 | \r |
1294 | if (imageY1 < PreviousPSXDisplay.DisplayPosition.y)\r |
1295 | xUploadArea.y1 = PreviousPSXDisplay.DisplayPosition.y;\r |
1296 | else\r |
1297 | if (imageY1 > PreviousPSXDisplay.DisplayEnd.y)\r |
1298 | xUploadArea.y1 = PreviousPSXDisplay.DisplayEnd.y;\r |
1299 | else\r |
1300 | xUploadArea.y1 = imageY1;\r |
1301 | \r |
1302 | if ((xUploadArea.x0 != xUploadArea.x1) && (xUploadArea.y0 != xUploadArea.y1))\r |
1303 | return TRUE;\r |
1304 | else return FALSE;\r |
1305 | }\r |
1306 | \r |
1307 | BOOL CheckAgainstScreen(short imageX0,short imageY0,short imageX1,short imageY1)\r |
1308 | {\r |
1309 | imageX1 += imageX0;\r |
1310 | imageY1 += imageY0;\r |
1311 | \r |
1312 | if (imageX0 < PreviousPSXDisplay.DisplayPosition.x)\r |
1313 | xrUploadArea.x0 = PreviousPSXDisplay.DisplayPosition.x;\r |
1314 | else\r |
1315 | if (imageX0 > PreviousPSXDisplay.DisplayEnd.x)\r |
1316 | xrUploadArea.x0 = PreviousPSXDisplay.DisplayEnd.x;\r |
1317 | else\r |
1318 | xrUploadArea.x0 = imageX0;\r |
1319 | \r |
1320 | if(imageX1 < PreviousPSXDisplay.DisplayPosition.x)\r |
1321 | xrUploadArea.x1 = PreviousPSXDisplay.DisplayPosition.x;\r |
1322 | else\r |
1323 | if (imageX1 > PreviousPSXDisplay.DisplayEnd.x)\r |
1324 | xrUploadArea.x1 = PreviousPSXDisplay.DisplayEnd.x;\r |
1325 | else\r |
1326 | xrUploadArea.x1 = imageX1;\r |
1327 | \r |
1328 | if (imageY0 < PreviousPSXDisplay.DisplayPosition.y)\r |
1329 | xrUploadArea.y0 = PreviousPSXDisplay.DisplayPosition.y;\r |
1330 | else\r |
1331 | if (imageY0 > PreviousPSXDisplay.DisplayEnd.y)\r |
1332 | xrUploadArea.y0 = PreviousPSXDisplay.DisplayEnd.y;\r |
1333 | else\r |
1334 | xrUploadArea.y0 = imageY0;\r |
1335 | \r |
1336 | if (imageY1 < PreviousPSXDisplay.DisplayPosition.y)\r |
1337 | xrUploadArea.y1 = PreviousPSXDisplay.DisplayPosition.y;\r |
1338 | else\r |
1339 | if (imageY1 > PreviousPSXDisplay.DisplayEnd.y)\r |
1340 | xrUploadArea.y1 = PreviousPSXDisplay.DisplayEnd.y;\r |
1341 | else\r |
1342 | xrUploadArea.y1 = imageY1;\r |
1343 | \r |
1344 | if ((xrUploadArea.x0 != xrUploadArea.x1) && (xrUploadArea.y0 != xrUploadArea.y1))\r |
1345 | return TRUE;\r |
1346 | else return FALSE;\r |
1347 | }\r |
1348 | \r |
1349 | BOOL FastCheckAgainstFrontScreen(short imageX0,short imageY0,short imageX1,short imageY1)\r |
1350 | {\r |
1351 | PSXRect_t xUploadArea;\r |
1352 | \r |
1353 | imageX1 += imageX0;\r |
1354 | imageY1 += imageY0;\r |
1355 | \r |
1356 | if (imageX0 < PSXDisplay.DisplayPosition.x)\r |
1357 | xUploadArea.x0 = PSXDisplay.DisplayPosition.x;\r |
1358 | else\r |
1359 | if (imageX0 > PSXDisplay.DisplayEnd.x)\r |
1360 | xUploadArea.x0 = PSXDisplay.DisplayEnd.x;\r |
1361 | else\r |
1362 | xUploadArea.x0 = imageX0;\r |
1363 | \r |
1364 | if(imageX1 < PSXDisplay.DisplayPosition.x)\r |
1365 | xUploadArea.x1 = PSXDisplay.DisplayPosition.x;\r |
1366 | else\r |
1367 | if (imageX1 > PSXDisplay.DisplayEnd.x)\r |
1368 | xUploadArea.x1 = PSXDisplay.DisplayEnd.x;\r |
1369 | else\r |
1370 | xUploadArea.x1 = imageX1;\r |
1371 | \r |
1372 | if (imageY0 < PSXDisplay.DisplayPosition.y)\r |
1373 | xUploadArea.y0 = PSXDisplay.DisplayPosition.y;\r |
1374 | else\r |
1375 | if (imageY0 > PSXDisplay.DisplayEnd.y)\r |
1376 | xUploadArea.y0 = PSXDisplay.DisplayEnd.y;\r |
1377 | else\r |
1378 | xUploadArea.y0 = imageY0;\r |
1379 | \r |
1380 | if (imageY1 < PSXDisplay.DisplayPosition.y)\r |
1381 | xUploadArea.y1 = PSXDisplay.DisplayPosition.y;\r |
1382 | else\r |
1383 | if (imageY1 > PSXDisplay.DisplayEnd.y)\r |
1384 | xUploadArea.y1 = PSXDisplay.DisplayEnd.y;\r |
1385 | else\r |
1386 | xUploadArea.y1 = imageY1;\r |
1387 | \r |
1388 | if ((xUploadArea.x0 != xUploadArea.x1) && (xUploadArea.y0 != xUploadArea.y1))\r |
1389 | return TRUE; \r |
1390 | else return FALSE;\r |
1391 | }\r |
1392 | \r |
1393 | BOOL CheckAgainstFrontScreen(short imageX0,short imageY0,short imageX1,short imageY1)\r |
1394 | {\r |
1395 | imageX1 += imageX0;\r |
1396 | imageY1 += imageY0;\r |
1397 | \r |
1398 | if (imageX0 < PSXDisplay.DisplayPosition.x)\r |
1399 | xrUploadArea.x0 = PSXDisplay.DisplayPosition.x;\r |
1400 | else\r |
1401 | if (imageX0 > PSXDisplay.DisplayEnd.x)\r |
1402 | xrUploadArea.x0 = PSXDisplay.DisplayEnd.x;\r |
1403 | else\r |
1404 | xrUploadArea.x0 = imageX0;\r |
1405 | \r |
1406 | if(imageX1 < PSXDisplay.DisplayPosition.x)\r |
1407 | xrUploadArea.x1 = PSXDisplay.DisplayPosition.x;\r |
1408 | else\r |
1409 | if (imageX1 > PSXDisplay.DisplayEnd.x)\r |
1410 | xrUploadArea.x1 = PSXDisplay.DisplayEnd.x;\r |
1411 | else\r |
1412 | xrUploadArea.x1 = imageX1;\r |
1413 | \r |
1414 | if (imageY0 < PSXDisplay.DisplayPosition.y)\r |
1415 | xrUploadArea.y0 = PSXDisplay.DisplayPosition.y;\r |
1416 | else\r |
1417 | if (imageY0 > PSXDisplay.DisplayEnd.y)\r |
1418 | xrUploadArea.y0 = PSXDisplay.DisplayEnd.y;\r |
1419 | else\r |
1420 | xrUploadArea.y0 = imageY0;\r |
1421 | \r |
1422 | if (imageY1 < PSXDisplay.DisplayPosition.y)\r |
1423 | xrUploadArea.y1 = PSXDisplay.DisplayPosition.y;\r |
1424 | else\r |
1425 | if (imageY1 > PSXDisplay.DisplayEnd.y)\r |
1426 | xrUploadArea.y1 = PSXDisplay.DisplayEnd.y;\r |
1427 | else\r |
1428 | xrUploadArea.y1 = imageY1;\r |
1429 | \r |
1430 | if ((xrUploadArea.x0 != xrUploadArea.x1) && (xrUploadArea.y0 != xrUploadArea.y1))\r |
1431 | return TRUE; \r |
1432 | else return FALSE;\r |
1433 | }\r |
1434 | \r |
1435 | ////////////////////////////////////////////////////////////////////////\r |
1436 | \r |
1437 | void PrepareFullScreenUpload (long Position)\r |
1438 | {\r |
1439 | if (Position==-1) // rgb24\r |
1440 | {\r |
1441 | if(PSXDisplay.Interlaced)\r |
1442 | {\r |
1443 | xrUploadArea.x0 = PSXDisplay.DisplayPosition.x;\r |
1444 | xrUploadArea.x1 = PSXDisplay.DisplayEnd.x;\r |
1445 | xrUploadArea.y0 = PSXDisplay.DisplayPosition.y;\r |
1446 | xrUploadArea.y1 = PSXDisplay.DisplayEnd.y;\r |
1447 | }\r |
1448 | else\r |
1449 | {\r |
1450 | xrUploadArea.x0 = PreviousPSXDisplay.DisplayPosition.x;\r |
1451 | xrUploadArea.x1 = PreviousPSXDisplay.DisplayEnd.x;\r |
1452 | xrUploadArea.y0 = PreviousPSXDisplay.DisplayPosition.y;\r |
1453 | xrUploadArea.y1 = PreviousPSXDisplay.DisplayEnd.y;\r |
1454 | }\r |
1455 | \r |
1456 | if(bNeedRGB24Update)\r |
1457 | {\r |
1458 | if(lClearOnSwap) \r |
1459 | {\r |
1460 | // lClearOnSwap=0;\r |
1461 | }\r |
1462 | else \r |
1463 | if(PSXDisplay.Interlaced && PreviousPSXDisplay.RGB24<2) // in interlaced mode we upload at least two full frames (GT1 menu)\r |
1464 | {\r |
1465 | PreviousPSXDisplay.RGB24++;\r |
1466 | }\r |
1467 | else\r |
1468 | {\r |
1469 | xrUploadArea.y1 = min(xrUploadArea.y0+xrUploadAreaRGB24.y1,xrUploadArea.y1);\r |
1470 | xrUploadArea.y0+=xrUploadAreaRGB24.y0;\r |
1471 | }\r |
1472 | }\r |
1473 | }\r |
1474 | else\r |
1475 | if (Position)\r |
1476 | {\r |
1477 | xrUploadArea.x0 = PSXDisplay.DisplayPosition.x;\r |
1478 | xrUploadArea.x1 = PSXDisplay.DisplayEnd.x;\r |
1479 | xrUploadArea.y0 = PSXDisplay.DisplayPosition.y;\r |
1480 | xrUploadArea.y1 = PSXDisplay.DisplayEnd.y;\r |
1481 | }\r |
1482 | else\r |
1483 | {\r |
1484 | xrUploadArea.x0 = PreviousPSXDisplay.DisplayPosition.x;\r |
1485 | xrUploadArea.x1 = PreviousPSXDisplay.DisplayEnd.x;\r |
1486 | xrUploadArea.y0 = PreviousPSXDisplay.DisplayPosition.y;\r |
1487 | xrUploadArea.y1 = PreviousPSXDisplay.DisplayEnd.y;\r |
1488 | }\r |
1489 | \r |
1490 | if (xrUploadArea.x0 < 0) xrUploadArea.x0 = 0;\r |
1491 | else\r |
1492 | if (xrUploadArea.x0 > 1023) xrUploadArea.x0 = 1023;\r |
1493 | \r |
1494 | if (xrUploadArea.x1 < 0) xrUploadArea.x1 = 0;\r |
1495 | else\r |
1496 | if (xrUploadArea.x1 > 1024) xrUploadArea.x1 = 1024;\r |
1497 | \r |
1498 | if (xrUploadArea.y0 < 0) xrUploadArea.y0 = 0;\r |
1499 | else\r |
1500 | if (xrUploadArea.y0 > iGPUHeightMask) xrUploadArea.y0 = iGPUHeightMask;\r |
1501 | \r |
1502 | if (xrUploadArea.y1 < 0) xrUploadArea.y1 = 0;\r |
1503 | else\r |
1504 | if (xrUploadArea.y1 > iGPUHeight) xrUploadArea.y1 = iGPUHeight;\r |
1505 | \r |
1506 | if (PSXDisplay.RGB24)\r |
1507 | {\r |
1508 | InvalidateTextureArea(xrUploadArea.x0,xrUploadArea.y0,xrUploadArea.x1-xrUploadArea.x0,xrUploadArea.y1-xrUploadArea.y0);\r |
1509 | }\r |
1510 | }\r |
1511 | \r |
1512 | ////////////////////////////////////////////////////////////////////////\r |
1513 | // Upload screen (MDEC and such)\r |
1514 | ////////////////////////////////////////////////////////////////////////\r |
1515 | ////////////////////////////////////////////////////////////////////////\r |
1516 | \r |
1517 | u8 * LoadDirectMovieFast(void);\r |
1518 | \r |
1519 | void UploadScreenEx(long Position)\r |
1520 | {\r |
1521 | short ya,yb,xa,xb,x, y, YStep, XStep, U, UStep,ux[4],vy[4];\r |
1522 | \r |
1523 | if(!PSXDisplay.DisplayMode.x) return;\r |
1524 | if(!PSXDisplay.DisplayMode.y) return;\r |
1525 | \r |
1526 | glDisable(GL_SCISSOR_TEST);\r |
1527 | glShadeModel(GL_FLAT);\r |
1528 | bOldSmoothShaded=FALSE;\r |
1529 | glDisable(GL_BLEND);\r |
1530 | bBlendEnable=FALSE;\r |
1531 | glDisable(GL_TEXTURE_2D);\r |
1532 | bTexEnabled=FALSE;\r |
1533 | glDisable(GL_ALPHA_TEST);\r |
1534 | \r |
1535 | //glPixelZoom(((float)rRatioRect.right)/((float)PSXDisplay.DisplayMode.x),\r |
1536 | // -1.0f*(((float)rRatioRect.bottom)/((float)PSXDisplay.DisplayMode.y)));\r |
1537 | \r |
1538 | //----------------------------------------------------//\r |
1539 | \r |
1540 | YStep = 256; // max texture size\r |
1541 | XStep = 256;\r |
1542 | UStep = (PSXDisplay.RGB24 ? 128 : 0);\r |
1543 | ya = xrUploadArea.y0;\r |
1544 | yb = xrUploadArea.y1;\r |
1545 | xa = xrUploadArea.x0;\r |
1546 | xb = xrUploadArea.x1;\r |
1547 | \r |
1548 | for(y=ya;y<=yb;y+=YStep) // loop y\r |
1549 | {\r |
1550 | U = 0;\r |
1551 | for(x=xa;x<=xb;x+=XStep) // loop x\r |
1552 | {\r |
1553 | ly0 = ly1 = y; // -> get y coords\r |
1554 | ly2 = y + YStep;\r |
1555 | if (ly2 > yb) ly2 = yb;\r |
1556 | ly3 = ly2;\r |
1557 | \r |
1558 | lx0 = lx3 = x; // -> get x coords\r |
1559 | lx1 = x + XStep;\r |
1560 | if (lx1 > xb) lx1 = xb;\r |
1561 | \r |
1562 | lx2 = lx1;\r |
1563 | \r |
1564 | ux[0]=ux[3]=(xa - x); // -> set tex x coords\r |
1565 | if (ux[0] < 0) ux[0]=ux[3]=0;\r |
1566 | ux[2]=ux[1]=(xb - x);\r |
1567 | if (ux[2] > 256) ux[2]=ux[1]=256;\r |
1568 | \r |
1569 | vy[0]=vy[1]=(ya - y); // -> set tex y coords\r |
1570 | if (vy[0] < 0) vy[0]=vy[1]=0;\r |
1571 | vy[2]=vy[3]=(yb - y);\r |
1572 | if (vy[2] > 256) vy[2]=vy[3]=256;\r |
1573 | \r |
1574 | if ((ux[0] >= ux[2]) || // -> cheaters never win...\r |
1575 | (vy[0] >= vy[2])) continue; // (but winners always cheat...)\r |
1576 | \r |
1577 | xrMovieArea.x0=lx0+U; xrMovieArea.y0=ly0;\r |
1578 | xrMovieArea.x1=lx2+U; xrMovieArea.y1=ly2;\r |
1579 | \r |
1580 | offsetScreenUpload(Position);\r |
1581 | \r |
1582 | //glRasterPos2f(vertex[0].x,vertex[0].y);\r |
1583 | \r |
1584 | //glDrawPixels(xrMovieArea.x1-xrMovieArea.x0,\r |
1585 | // xrMovieArea.y1-xrMovieArea.y0,\r |
1586 | // GL_RGBA,GL_UNSIGNED_BYTE,\r |
1587 | LoadDirectMovieFast();//);\r |
1588 | \r |
1589 | U+=UStep;\r |
1590 | }\r |
1591 | }\r |
1592 | \r |
1593 | //----------------------------------------------------//\r |
1594 | \r |
1595 | // glPixelZoom(1.0F,1.0F);\r |
1596 | \r |
1597 | glEnable(GL_ALPHA_TEST);\r |
1598 | glEnable(GL_SCISSOR_TEST);\r |
1599 | }\r |
1600 | \r |
1601 | ////////////////////////////////////////////////////////////////////////\r |
1602 | \r |
1603 | void UploadScreen(long Position)\r |
1604 | {\r |
1605 | short x, y, YStep, XStep, U, s, UStep,ux[4],vy[4];\r |
1606 | short xa,xb,ya,yb;\r |
1607 | \r |
1608 | if(xrUploadArea.x0>1023) xrUploadArea.x0=1023;\r |
1609 | if(xrUploadArea.x1>1024) xrUploadArea.x1=1024;\r |
1610 | if(xrUploadArea.y0>iGPUHeightMask) xrUploadArea.y0=iGPUHeightMask;\r |
1611 | if(xrUploadArea.y1>iGPUHeight) xrUploadArea.y1=iGPUHeight;\r |
1612 | \r |
1613 | if(xrUploadArea.x0==xrUploadArea.x1) return;\r |
1614 | if(xrUploadArea.y0==xrUploadArea.y1) return;\r |
1615 | \r |
1616 | if(PSXDisplay.Disabled && iOffscreenDrawing<4) return;\r |
1617 | \r |
1618 | iDrawnSomething = 2;\r |
1619 | iLastRGB24=PSXDisplay.RGB24+1;\r |
1620 | \r |
1621 | if(bSkipNextFrame) return;\r |
1622 | \r |
1623 | if(dwActFixes & 2) {UploadScreenEx(Position);return;}\r |
1624 | \r |
1625 | bUsingMovie = TRUE;\r |
1626 | bDrawTextured = TRUE; // just doing textures\r |
1627 | bDrawSmoothShaded = FALSE;\r |
1628 | \r |
1629 | /* if(bGLBlend) vertex[0].c.lcol=0xff7f7f7f; // set solid col\r |
1630 | else */vertex[0].c.lcol=0xffffffff;\r |
1631 | SETCOL(vertex[0]); \r |
1632 | \r |
1633 | SetOGLDisplaySettings(0);\r |
1634 | \r |
1635 | YStep = 256; // max texture size\r |
1636 | XStep = 256;\r |
1637 | \r |
1638 | UStep = (PSXDisplay.RGB24 ? 128 : 0);\r |
1639 | \r |
1640 | ya=xrUploadArea.y0;\r |
1641 | yb=xrUploadArea.y1;\r |
1642 | xa=xrUploadArea.x0;\r |
1643 | xb=xrUploadArea.x1;\r |
1644 | \r |
1645 | for(y=ya;y<=yb;y+=YStep) // loop y\r |
1646 | {\r |
1647 | U = 0;\r |
1648 | for(x=xa;x<=xb;x+=XStep) // loop x\r |
1649 | {\r |
1650 | ly0 = ly1 = y; // -> get y coords\r |
1651 | ly2 = y + YStep;\r |
1652 | if (ly2 > yb) ly2 = yb;\r |
1653 | ly3 = ly2;\r |
1654 | \r |
1655 | lx0 = lx3 = x; // -> get x coords\r |
1656 | lx1 = x + XStep;\r |
1657 | if (lx1 > xb) lx1 = xb;\r |
1658 | \r |
1659 | lx2 = lx1;\r |
1660 | \r |
1661 | ux[0]=ux[3]=(xa - x); // -> set tex x coords\r |
1662 | if (ux[0] < 0) ux[0]=ux[3]=0;\r |
1663 | ux[2]=ux[1]=(xb - x);\r |
1664 | if (ux[2] > 256) ux[2]=ux[1]=256;\r |
1665 | \r |
1666 | vy[0]=vy[1]=(ya - y); // -> set tex y coords\r |
1667 | if (vy[0] < 0) vy[0]=vy[1]=0;\r |
1668 | vy[2]=vy[3]=(yb - y);\r |
1669 | if (vy[2] > 256) vy[2]=vy[3]=256;\r |
1670 | \r |
1671 | if ((ux[0] >= ux[2]) || // -> cheaters never win...\r |
1672 | (vy[0] >= vy[2])) continue; // (but winners always cheat...)\r |
1673 | \r |
1674 | xrMovieArea.x0=lx0+U; xrMovieArea.y0=ly0;\r |
1675 | xrMovieArea.x1=lx2+U; xrMovieArea.y1=ly2;\r |
1676 | \r |
1677 | s=ux[2] - ux[0]; if(s>255) s=255;\r |
1678 | \r |
1679 | gl_ux[2] = gl_ux[1] = s;\r |
1680 | s=vy[2] - vy[0]; if(s>255) s=255;\r |
1681 | gl_vy[2] = gl_vy[3] = s;\r |
1682 | gl_ux[0] = gl_ux[3] = gl_vy[0] = gl_vy[1] = 0;\r |
1683 | \r |
1684 | SetRenderState((unsigned long)0x01000000);\r |
1685 | SetRenderMode((unsigned long)0x01000000, FALSE); // upload texture data\r |
1686 | offsetScreenUpload(Position);\r |
1687 | assignTextureVRAMWrite();\r |
1688 | \r |
1689 | PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r |
1690 | \r |
1691 | U+=UStep;\r |
1692 | }\r |
1693 | }\r |
1694 | \r |
1695 | bUsingMovie=FALSE; // done...\r |
1696 | bDisplayNotSet = TRUE;\r |
1697 | }\r |
1698 | \r |
1699 | ////////////////////////////////////////////////////////////////////////\r |
1700 | // Detect next screen\r |
1701 | ////////////////////////////////////////////////////////////////////////\r |
1702 | \r |
1703 | BOOL IsCompleteInsideNextScreen(short x, short y, short xoff, short yoff)\r |
1704 | { \r |
1705 | if (x > PSXDisplay.DisplayPosition.x+1) return FALSE;\r |
1706 | if ((x + xoff) < PSXDisplay.DisplayEnd.x-1) return FALSE;\r |
1707 | yoff+=y;\r |
1708 | if (y >= PSXDisplay.DisplayPosition.y &&\r |
1709 | y <= PSXDisplay.DisplayEnd.y )\r |
1710 | {\r |
1711 | if ((yoff) >= PSXDisplay.DisplayPosition.y &&\r |
1712 | (yoff) <= PSXDisplay.DisplayEnd.y ) return TRUE;\r |
1713 | } \r |
1714 | if (y > PSXDisplay.DisplayPosition.y+1) return FALSE;\r |
1715 | if (yoff < PSXDisplay.DisplayEnd.y-1) return FALSE;\r |
1716 | return TRUE;\r |
1717 | }\r |
1718 | \r |
1719 | BOOL IsPrimCompleteInsideNextScreen(short x, short y, short xoff, short yoff)\r |
1720 | {\r |
1721 | x+=PSXDisplay.DrawOffset.x;\r |
1722 | if (x > PSXDisplay.DisplayPosition.x+1) return FALSE;\r |
1723 | y+=PSXDisplay.DrawOffset.y;\r |
1724 | if (y > PSXDisplay.DisplayPosition.y+1) return FALSE;\r |
1725 | xoff+=PSXDisplay.DrawOffset.x;\r |
1726 | if (xoff < PSXDisplay.DisplayEnd.x-1) return FALSE;\r |
1727 | yoff+=PSXDisplay.DrawOffset.y;\r |
1728 | if (yoff < PSXDisplay.DisplayEnd.y-1) return FALSE;\r |
1729 | return TRUE;\r |
1730 | }\r |
1731 | \r |
1732 | BOOL IsInsideNextScreen(short x, short y, short xoff, short yoff)\r |
1733 | { \r |
1734 | if (x > PSXDisplay.DisplayEnd.x) return FALSE;\r |
1735 | if (y > PSXDisplay.DisplayEnd.y) return FALSE;\r |
1736 | if ((x + xoff) < PSXDisplay.DisplayPosition.x) return FALSE;\r |
1737 | if ((y + yoff) < PSXDisplay.DisplayPosition.y) return FALSE;\r |
1738 | return TRUE;\r |
1739 | }\r |
1740 | \r |
1741 | ////////////////////////////////////////////////////////////////////////\r |
1742 | // mask stuff...\r |
1743 | ////////////////////////////////////////////////////////////////////////\r |
1744 | \r |
1745 | //Mask1 Set mask bit while drawing. 1 = on\r |
1746 | //Mask2 Do not draw to mask areas. 1= on\r |
1747 | \r |
1748 | void cmdSTP(u8 * baseAddr)\r |
1749 | {\r |
1750 | unsigned long gdata = ((unsigned long*)baseAddr)[0];\r |
1751 | \r |
1752 | STATUSREG&=~0x1800; // clear the necessary bits\r |
1753 | STATUSREG|=((gdata & 0x03) << 11); // set the current bits\r |
1754 | \r |
1755 | if(!iUseMask) return;\r |
1756 | \r |
1757 | if(gdata&1) {sSetMask=0x8000;lSetMask=0x80008000;iSetMask=1;}\r |
1758 | else {sSetMask=0; lSetMask=0; iSetMask=0;}\r |
1759 | \r |
1760 | if(gdata&2) \r |
1761 | {\r |
1762 | if(!(gdata&1)) iSetMask=2;\r |
1763 | bCheckMask=TRUE;\r |
1764 | if(iDepthFunc==0) return;\r |
1765 | iDepthFunc=0;\r |
1766 | glDepthFunc(GL_LESS);\r |
1767 | }\r |
1768 | else\r |
1769 | {\r |
1770 | bCheckMask=FALSE;\r |
1771 | if(iDepthFunc==1) return;\r |
1772 | glDepthFunc(GL_ALWAYS);\r |
1773 | iDepthFunc=1;\r |
1774 | }\r |
1775 | }\r |
1776 | \r |
1777 | ////////////////////////////////////////////////////////////////////////\r |
1778 | // cmd: Set texture page infos\r |
1779 | ////////////////////////////////////////////////////////////////////////\r |
1780 | \r |
1781 | void cmdTexturePage(u8 * baseAddr)\r |
1782 | {\r |
1783 | unsigned long gdata = ((unsigned long*)baseAddr)[0];\r |
1784 | UpdateGlobalTP((unsigned short)gdata);\r |
1785 | GlobalTextREST = (gdata&0x00ffffff)>>9;\r |
1786 | }\r |
1787 | \r |
1788 | ////////////////////////////////////////////////////////////////////////\r |
1789 | // cmd: turn on/off texture window\r |
1790 | ////////////////////////////////////////////////////////////////////////\r |
1791 | \r |
1792 | void cmdTextureWindow(u8 *baseAddr)\r |
1793 | {\r |
1794 | unsigned long gdata = ((unsigned long*)baseAddr)[0];\r |
1795 | \r |
1796 | unsigned long YAlign,XAlign;\r |
1797 | \r |
1798 | ulGPUInfoVals[INFO_TW]=gdata&0xFFFFF;\r |
1799 | \r |
1800 | if(gdata & 0x020)\r |
1801 | TWin.Position.y1 = 8; // xxxx1\r |
1802 | else if (gdata & 0x040)\r |
1803 | TWin.Position.y1 = 16; // xxx10\r |
1804 | else if (gdata & 0x080)\r |
1805 | TWin.Position.y1 = 32; // xx100\r |
1806 | else if (gdata & 0x100)\r |
1807 | TWin.Position.y1 = 64; // x1000\r |
1808 | else if (gdata & 0x200)\r |
1809 | TWin.Position.y1 = 128; // 10000\r |
1810 | else\r |
1811 | TWin.Position.y1 = 256; // 00000\r |
1812 | \r |
1813 | // Texture window size is determined by the least bit set of the relevant 5 bits\r |
1814 | \r |
1815 | if (gdata & 0x001)\r |
1816 | TWin.Position.x1 = 8; // xxxx1\r |
1817 | else if (gdata & 0x002)\r |
1818 | TWin.Position.x1 = 16; // xxx10\r |
1819 | else if (gdata & 0x004)\r |
1820 | TWin.Position.x1 = 32; // xx100\r |
1821 | else if (gdata & 0x008)\r |
1822 | TWin.Position.x1 = 64; // x1000\r |
1823 | else if (gdata & 0x010)\r |
1824 | TWin.Position.x1 = 128; // 10000\r |
1825 | else\r |
1826 | TWin.Position.x1 = 256; // 00000\r |
1827 | \r |
1828 | // Re-calculate the bit field, because we can't trust what is passed in the data\r |
1829 | \r |
1830 | YAlign = (unsigned long)(32 - (TWin.Position.y1 >> 3));\r |
1831 | XAlign = (unsigned long)(32 - (TWin.Position.x1 >> 3));\r |
1832 | \r |
1833 | // Absolute position of the start of the texture window\r |
1834 | \r |
1835 | TWin.Position.y0 = (short)(((gdata >> 15) & YAlign) << 3);\r |
1836 | TWin.Position.x0 = (short)(((gdata >> 10) & XAlign) << 3);\r |
1837 | \r |
1838 | if((TWin.Position.x0 == 0 && // tw turned off\r |
1839 | TWin.Position.y0 == 0 &&\r |
1840 | TWin.Position.x1 == 0 &&\r |
1841 | TWin.Position.y1 == 0) ||\r |
1842 | (TWin.Position.x1 == 256 &&\r |
1843 | TWin.Position.y1 == 256))\r |
1844 | {\r |
1845 | bUsingTWin = FALSE; // -> just do it\r |
1846 | \r |
1847 | #ifdef OWNSCALE\r |
1848 | TWin.UScaleFactor = 1.0f;\r |
1849 | TWin.VScaleFactor = 1.0f;\r |
1850 | #else\r |
1851 | TWin.UScaleFactor = \r |
1852 | TWin.VScaleFactor = 1.0f/256.0f;\r |
1853 | #endif\r |
1854 | }\r |
1855 | else // tw turned on\r |
1856 | {\r |
1857 | bUsingTWin = TRUE;\r |
1858 | \r |
1859 | TWin.OPosition.y1 = TWin.Position.y1; // -> get psx sizes\r |
1860 | TWin.OPosition.x1 = TWin.Position.x1; \r |
1861 | \r |
1862 | if(TWin.Position.x1<=2) TWin.Position.x1=2; // -> set OGL sizes\r |
1863 | else\r |
1864 | if(TWin.Position.x1<=4) TWin.Position.x1=4;\r |
1865 | else\r |
1866 | if(TWin.Position.x1<=8) TWin.Position.x1=8;\r |
1867 | else\r |
1868 | if(TWin.Position.x1<=16) TWin.Position.x1=16;\r |
1869 | else\r |
1870 | if(TWin.Position.x1<=32) TWin.Position.x1=32;\r |
1871 | else\r |
1872 | if(TWin.Position.x1<=64) TWin.Position.x1=64;\r |
1873 | else\r |
1874 | if(TWin.Position.x1<=128) TWin.Position.x1=128;\r |
1875 | else\r |
1876 | if(TWin.Position.x1<=256) TWin.Position.x1=256;\r |
1877 | \r |
1878 | if(TWin.Position.y1<=2) TWin.Position.y1=2;\r |
1879 | else\r |
1880 | if(TWin.Position.y1<=4) TWin.Position.y1=4;\r |
1881 | else\r |
1882 | if(TWin.Position.y1<=8) TWin.Position.y1=8;\r |
1883 | else\r |
1884 | if(TWin.Position.y1<=16) TWin.Position.y1=16;\r |
1885 | else\r |
1886 | if(TWin.Position.y1<=32) TWin.Position.y1=32;\r |
1887 | else\r |
1888 | if(TWin.Position.y1<=64) TWin.Position.y1=64;\r |
1889 | else\r |
1890 | if(TWin.Position.y1<=128) TWin.Position.y1=128;\r |
1891 | else\r |
1892 | if(TWin.Position.y1<=256) TWin.Position.y1=256;\r |
1893 | \r |
1894 | #ifdef OWNSCALE\r |
1895 | TWin.UScaleFactor = (float)TWin.Position.x1;\r |
1896 | TWin.VScaleFactor = (float)TWin.Position.y1;\r |
1897 | #else\r |
1898 | TWin.UScaleFactor = ((float)TWin.Position.x1)/256.0f; // -> set scale factor\r |
1899 | TWin.VScaleFactor = ((float)TWin.Position.y1)/256.0f;\r |
1900 | #endif\r |
1901 | }\r |
1902 | }\r |
1903 | \r |
1904 | ////////////////////////////////////////////////////////////////////////\r |
1905 | // mmm, Lewpy uses that in TileS ... I don't ;)\r |
1906 | ////////////////////////////////////////////////////////////////////////\r |
1907 | \r |
1908 | /*\r |
1909 | void ClampToPSXDrawAreaOffset(short *x0, short *y0, short *x1, short *y1)\r |
1910 | {\r |
1911 | if (*x0 < PSXDisplay.DrawArea.x0)\r |
1912 | {\r |
1913 | *x1 -= (PSXDisplay.DrawArea.x0 - *x0);\r |
1914 | *x0 = PSXDisplay.DrawArea.x0;\r |
1915 | }\r |
1916 | else\r |
1917 | if (*x0 > PSXDisplay.DrawArea.x1)\r |
1918 | {\r |
1919 | *x0 = PSXDisplay.DrawArea.x1;\r |
1920 | *x1 = 0;\r |
1921 | }\r |
1922 | \r |
1923 | if (*y0 < PSXDisplay.DrawArea.y0)\r |
1924 | {\r |
1925 | *y1 -= (PSXDisplay.DrawArea.y0 - *y0);\r |
1926 | *y0 = PSXDisplay.DrawArea.y0;\r |
1927 | }\r |
1928 | else\r |
1929 | if (*y0 > PSXDisplay.DrawArea.y1)\r |
1930 | {\r |
1931 | *y0 = PSXDisplay.DrawArea.y1;\r |
1932 | *y1 = 0;\r |
1933 | }\r |
1934 | \r |
1935 | if (*x1 < 0) *x1 = 0;\r |
1936 | \r |
1937 | if ((*x1 + *x0) > PSXDisplay.DrawArea.x1)\r |
1938 | *x1 = (PSXDisplay.DrawArea.x1 - *x0 + 1);\r |
1939 | \r |
1940 | if (*y1 < 0) *y1 = 0;\r |
1941 | \r |
1942 | if ((*y1 + *y0) > PSXDisplay.DrawArea.y1)\r |
1943 | *y1 = (PSXDisplay.DrawArea.y1 - *y0 + 1);\r |
1944 | }\r |
1945 | */\r |
1946 | \r |
1947 | ////////////////////////////////////////////////////////////////////////\r |
1948 | // Check draw area dimensions\r |
1949 | ////////////////////////////////////////////////////////////////////////\r |
1950 | \r |
1951 | void ClampToPSXScreen(short *x0, short *y0, short *x1, short *y1)\r |
1952 | {\r |
1953 | if (*x0 < 0) *x0 = 0;\r |
1954 | else\r |
1955 | if (*x0 > 1023) *x0 = 1023;\r |
1956 | \r |
1957 | if (*x1 < 0) *x1 = 0;\r |
1958 | else\r |
1959 | if (*x1 > 1023) *x1 = 1023;\r |
1960 | \r |
1961 | if (*y0 < 0) *y0 = 0;\r |
1962 | else\r |
1963 | if (*y0 > iGPUHeightMask) *y0 = iGPUHeightMask;\r |
1964 | \r |
1965 | if (*y1 < 0) *y1 = 0;\r |
1966 | else\r |
1967 | if (*y1 > iGPUHeightMask) *y1 = iGPUHeightMask;\r |
1968 | }\r |
1969 | \r |
1970 | ////////////////////////////////////////////////////////////////////////\r |
1971 | // Used in Load Image and Blk Fill\r |
1972 | ////////////////////////////////////////////////////////////////////////\r |
1973 | \r |
1974 | void ClampToPSXScreenOffset(short *x0, short *y0, short *x1, short *y1)\r |
1975 | {\r |
1976 | if (*x0 < 0)\r |
1977 | { *x1 += *x0; *x0 = 0; }\r |
1978 | else\r |
1979 | if (*x0 > 1023)\r |
1980 | { *x0 = 1023; *x1 = 0; }\r |
1981 | \r |
1982 | if (*y0 < 0)\r |
1983 | { *y1 += *y0; *y0 = 0; }\r |
1984 | else\r |
1985 | if (*y0 > iGPUHeightMask)\r |
1986 | { *y0 = iGPUHeightMask; *y1 = 0; }\r |
1987 | \r |
1988 | if (*x1 < 0) *x1 = 0;\r |
1989 | \r |
1990 | if ((*x1 + *x0) > 1024) *x1 = (1024 - *x0);\r |
1991 | \r |
1992 | if (*y1 < 0) *y1 = 0;\r |
1993 | \r |
1994 | if ((*y1 + *y0) > iGPUHeight) *y1 = (iGPUHeight - *y0);\r |
1995 | }\r |
1996 | \r |
1997 | ////////////////////////////////////////////////////////////////////////\r |
1998 | // cmd: start of drawing area... primitives will be clipped inside\r |
1999 | ////////////////////////////////////////////////////////////////////////\r |
2000 | \r |
2001 | void cmdDrawAreaStart(u8 * baseAddr)\r |
2002 | {\r |
2003 | unsigned long gdata = ((unsigned long*)baseAddr)[0];\r |
2004 | \r |
2005 | drawX = gdata & 0x3ff; // for soft drawing\r |
2006 | if(drawX>=1024) drawX=1023;\r |
2007 | \r |
2008 | if(dwGPUVersion==2)\r |
2009 | {\r |
2010 | ulGPUInfoVals[INFO_DRAWSTART]=gdata&0x3FFFFF;\r |
2011 | drawY = (gdata>>12)&0x3ff;\r |
2012 | }\r |
2013 | else\r |
2014 | {\r |
2015 | ulGPUInfoVals[INFO_DRAWSTART]=gdata&0xFFFFF;\r |
2016 | drawY = (gdata>>10)&0x3ff;\r |
2017 | }\r |
2018 | \r |
2019 | if(drawY>=iGPUHeight) drawY=iGPUHeightMask;\r |
2020 | \r |
2021 | PreviousPSXDisplay.DrawArea.y0=PSXDisplay.DrawArea.y0;\r |
2022 | PreviousPSXDisplay.DrawArea.x0=PSXDisplay.DrawArea.x0;\r |
2023 | \r |
2024 | PSXDisplay.DrawArea.y0 = (short)drawY; // for OGL drawing\r |
2025 | PSXDisplay.DrawArea.x0 = (short)drawX;\r |
2026 | }\r |
2027 | \r |
2028 | ////////////////////////////////////////////////////////////////////////\r |
2029 | // cmd: end of drawing area... primitives will be clipped inside\r |
2030 | ////////////////////////////////////////////////////////////////////////\r |
2031 | \r |
2032 | void cmdDrawAreaEnd(u8 * baseAddr)\r |
2033 | {\r |
2034 | unsigned long gdata = ((unsigned long*)baseAddr)[0];\r |
2035 | \r |
2036 | drawW = gdata & 0x3ff; // for soft drawing\r |
2037 | if(drawW>=1024) drawW=1023;\r |
2038 | \r |
2039 | if(dwGPUVersion==2)\r |
2040 | {\r |
2041 | ulGPUInfoVals[INFO_DRAWEND]=gdata&0x3FFFFF;\r |
2042 | drawH = (gdata>>12)&0x3ff;\r |
2043 | }\r |
2044 | else\r |
2045 | {\r |
2046 | ulGPUInfoVals[INFO_DRAWEND]=gdata&0xFFFFF;\r |
2047 | drawH = (gdata>>10)&0x3ff;\r |
2048 | }\r |
2049 | \r |
2050 | if(drawH>=iGPUHeight) drawH=iGPUHeightMask;\r |
2051 | \r |
2052 | PSXDisplay.DrawArea.y1 = (short)drawH; // for OGL drawing\r |
2053 | PSXDisplay.DrawArea.x1 = (short)drawW;\r |
2054 | \r |
2055 | ClampToPSXScreen(&PSXDisplay.DrawArea.x0, // clamp\r |
2056 | &PSXDisplay.DrawArea.y0,\r |
2057 | &PSXDisplay.DrawArea.x1,\r |
2058 | &PSXDisplay.DrawArea.y1);\r |
2059 | \r |
2060 | bDisplayNotSet = TRUE;\r |
2061 | }\r |
2062 | \r |
2063 | ////////////////////////////////////////////////////////////////////////\r |
2064 | // cmd: draw offset... will be added to prim coords\r |
2065 | ////////////////////////////////////////////////////////////////////////\r |
2066 | \r |
2067 | void cmdDrawOffset(u8 * baseAddr)\r |
2068 | {\r |
2069 | unsigned long gdata = ((unsigned long*)baseAddr)[0];\r |
2070 | \r |
2071 | PreviousPSXDisplay.DrawOffset.x = \r |
2072 | PSXDisplay.DrawOffset.x = (short)(gdata & 0x7ff);\r |
2073 | \r |
2074 | if(dwGPUVersion==2)\r |
2075 | {\r |
2076 | ulGPUInfoVals[INFO_DRAWOFF]=gdata&0x7FFFFF;\r |
2077 | PSXDisplay.DrawOffset.y = (short)((gdata>>12) & 0x7ff);\r |
2078 | }\r |
2079 | else\r |
2080 | {\r |
2081 | ulGPUInfoVals[INFO_DRAWOFF]=gdata&0x3FFFFF;\r |
2082 | PSXDisplay.DrawOffset.y = (short)((gdata>>11) & 0x7ff);\r |
2083 | }\r |
2084 | \r |
2085 | PSXDisplay.DrawOffset.x=(short)(((int)PSXDisplay.DrawOffset.x<<21)>>21);\r |
2086 | PSXDisplay.DrawOffset.y=(short)(((int)PSXDisplay.DrawOffset.y<<21)>>21);\r |
2087 | \r |
2088 | PSXDisplay.CumulOffset.x = // new OGL prim offsets\r |
2089 | PSXDisplay.DrawOffset.x - PSXDisplay.GDrawOffset.x + PreviousPSXDisplay.Range.x0;\r |
2090 | PSXDisplay.CumulOffset.y = \r |
2091 | PSXDisplay.DrawOffset.y - PSXDisplay.GDrawOffset.y + PreviousPSXDisplay.Range.y0;\r |
2092 | }\r |
2093 | \r |
2094 | ////////////////////////////////////////////////////////////////////////\r |
2095 | // cmd: load image to vram\r |
2096 | ////////////////////////////////////////////////////////////////////////\r |
2097 | \r |
2098 | void primLoadImage(u8 * baseAddr)\r |
2099 | {\r |
2100 | unsigned short *sgpuData = ((unsigned short *) baseAddr);\r |
2101 | \r |
2102 | VRAMWrite.x = sgpuData[2]&0x03ff;\r |
2103 | VRAMWrite.y = sgpuData[3]&iGPUHeightMask;\r |
2104 | VRAMWrite.Width = sgpuData[4];\r |
2105 | VRAMWrite.Height = sgpuData[5];\r |
2106 | \r |
2107 | iDataWriteMode = DR_VRAMTRANSFER;\r |
2108 | VRAMWrite.ImagePtr = psxVuw + (VRAMWrite.y<<10) + VRAMWrite.x;\r |
2109 | VRAMWrite.RowsRemaining = VRAMWrite.Width;\r |
2110 | VRAMWrite.ColsRemaining = VRAMWrite.Height;\r |
2111 | \r |
2112 | bNeedWriteUpload=TRUE;\r |
2113 | }\r |
2114 | \r |
2115 | ////////////////////////////////////////////////////////////////////////\r |
2116 | \r |
2117 | void PrepareRGB24Upload(void)\r |
2118 | {\r |
2119 | VRAMWrite.x=(VRAMWrite.x*2)/3;\r |
2120 | VRAMWrite.Width=(VRAMWrite.Width*2)/3;\r |
2121 | \r |
2122 | if(!PSXDisplay.InterlacedTest && // NEW\r |
2123 | CheckAgainstScreen(VRAMWrite.x, VRAMWrite.y, VRAMWrite.Width, VRAMWrite.Height))\r |
2124 | {\r |
2125 | xrUploadArea.x0-=PreviousPSXDisplay.DisplayPosition.x;\r |
2126 | xrUploadArea.x1-=PreviousPSXDisplay.DisplayPosition.x;\r |
2127 | xrUploadArea.y0-=PreviousPSXDisplay.DisplayPosition.y;\r |
2128 | xrUploadArea.y1-=PreviousPSXDisplay.DisplayPosition.y;\r |
2129 | } \r |
2130 | else\r |
2131 | if(CheckAgainstFrontScreen(VRAMWrite.x, VRAMWrite.y, VRAMWrite.Width, VRAMWrite.Height))\r |
2132 | {\r |
2133 | xrUploadArea.x0-=PSXDisplay.DisplayPosition.x;\r |
2134 | xrUploadArea.x1-=PSXDisplay.DisplayPosition.x;\r |
2135 | xrUploadArea.y0-=PSXDisplay.DisplayPosition.y;\r |
2136 | xrUploadArea.y1-=PSXDisplay.DisplayPosition.y;\r |
2137 | } \r |
2138 | else return;\r |
2139 | \r |
2140 | if(bRenderFrontBuffer) \r |
2141 | {\r |
2142 | updateFrontDisplay();\r |
2143 | }\r |
2144 | \r |
2145 | if(bNeedRGB24Update==FALSE)\r |
2146 | {\r |
2147 | xrUploadAreaRGB24=xrUploadArea;\r |
2148 | bNeedRGB24Update=TRUE;\r |
2149 | }\r |
2150 | else\r |
2151 | {\r |
2152 | xrUploadAreaRGB24.x0=min(xrUploadAreaRGB24.x0,xrUploadArea.x0);\r |
2153 | xrUploadAreaRGB24.x1=max(xrUploadAreaRGB24.x1,xrUploadArea.x1);\r |
2154 | xrUploadAreaRGB24.y0=min(xrUploadAreaRGB24.y0,xrUploadArea.y0);\r |
2155 | xrUploadAreaRGB24.y1=max(xrUploadAreaRGB24.y1,xrUploadArea.y1);\r |
2156 | }\r |
2157 | }\r |
2158 | \r |
2159 | ////////////////////////////////////////////////////////////////////////\r |
2160 | \r |
2161 | void CheckWriteUpdate()\r |
2162 | {\r |
2163 | int iX=0,iY=0;\r |
2164 | \r |
2165 | if(VRAMWrite.Width) iX=1;\r |
2166 | if(VRAMWrite.Height) iY=1;\r |
2167 | \r |
2168 | InvalidateTextureArea(VRAMWrite.x, VRAMWrite.y, VRAMWrite.Width-iX, VRAMWrite.Height-iY);\r |
2169 | \r |
2170 | if(PSXDisplay.Interlaced && !iOffscreenDrawing) return;\r |
2171 | \r |
2172 | if(PSXDisplay.RGB24) {PrepareRGB24Upload();return;}\r |
2173 | \r |
2174 | if(!PSXDisplay.InterlacedTest &&\r |
2175 | CheckAgainstScreen(VRAMWrite.x, VRAMWrite.y, VRAMWrite.Width, VRAMWrite.Height)) \r |
2176 | {\r |
2177 | if(dwActFixes&0x800) return;\r |
2178 | \r |
2179 | if(bRenderFrontBuffer) \r |
2180 | {\r |
2181 | updateFrontDisplay();\r |
2182 | }\r |
2183 | \r |
2184 | UploadScreen(FALSE);\r |
2185 | \r |
2186 | bNeedUploadTest=TRUE;\r |
2187 | }\r |
2188 | else \r |
2189 | if(iOffscreenDrawing)\r |
2190 | {\r |
2191 | if (CheckAgainstFrontScreen(VRAMWrite.x, VRAMWrite.y, VRAMWrite.Width, VRAMWrite.Height)) \r |
2192 | {\r |
2193 | if(PSXDisplay.InterlacedTest)\r |
2194 | {\r |
2195 | if(PreviousPSXDisplay.InterlacedNew) \r |
2196 | {\r |
2197 | PreviousPSXDisplay.InterlacedNew=FALSE;\r |
2198 | bNeedInterlaceUpdate=TRUE;\r |
2199 | xrUploadAreaIL.x0=PSXDisplay.DisplayPosition.x;\r |
2200 | xrUploadAreaIL.y0=PSXDisplay.DisplayPosition.y;\r |
2201 | xrUploadAreaIL.x1=PSXDisplay.DisplayPosition.x+PSXDisplay.DisplayModeNew.x;\r |
2202 | xrUploadAreaIL.y1=PSXDisplay.DisplayPosition.y+PSXDisplay.DisplayModeNew.y;\r |
2203 | if(xrUploadAreaIL.x1>1023) xrUploadAreaIL.x1=1023;\r |
2204 | if(xrUploadAreaIL.y1>511) xrUploadAreaIL.y1=511;\r |
2205 | }\r |
2206 | \r |
2207 | if(bNeedInterlaceUpdate==FALSE)\r |
2208 | {\r |
2209 | xrUploadAreaIL=xrUploadArea;\r |
2210 | bNeedInterlaceUpdate=TRUE;\r |
2211 | }\r |
2212 | else\r |
2213 | {\r |
2214 | xrUploadAreaIL.x0=min(xrUploadAreaIL.x0,xrUploadArea.x0);\r |
2215 | xrUploadAreaIL.x1=max(xrUploadAreaIL.x1,xrUploadArea.x1);\r |
2216 | xrUploadAreaIL.y0=min(xrUploadAreaIL.y0,xrUploadArea.y0);\r |
2217 | xrUploadAreaIL.y1=max(xrUploadAreaIL.y1,xrUploadArea.y1);\r |
2218 | }\r |
2219 | return;\r |
2220 | }\r |
2221 | \r |
2222 | if(!bNeedUploadAfter)\r |
2223 | {\r |
2224 | bNeedUploadAfter = TRUE;\r |
2225 | xrUploadArea.x0=VRAMWrite.x;\r |
2226 | xrUploadArea.x1=VRAMWrite.x+VRAMWrite.Width;\r |
2227 | xrUploadArea.y0=VRAMWrite.y;\r |
2228 | xrUploadArea.y1=VRAMWrite.y+VRAMWrite.Height;\r |
2229 | }\r |
2230 | else\r |
2231 | {\r |
2232 | xrUploadArea.x0=min(xrUploadArea.x0,VRAMWrite.x);\r |
2233 | xrUploadArea.x1=max(xrUploadArea.x1,VRAMWrite.x+VRAMWrite.Width);\r |
2234 | xrUploadArea.y0=min(xrUploadArea.y0,VRAMWrite.y);\r |
2235 | xrUploadArea.y1=max(xrUploadArea.y1,VRAMWrite.y+VRAMWrite.Height);\r |
2236 | }\r |
2237 | \r |
2238 | if(dwActFixes&0x8000)\r |
2239 | {\r |
2240 | if((xrUploadArea.x1-xrUploadArea.x0)>=(PSXDisplay.DisplayMode.x-32) &&\r |
2241 | (xrUploadArea.y1-xrUploadArea.y0)>=(PSXDisplay.DisplayMode.y-32))\r |
2242 | {\r |
2243 | UploadScreen(-1);\r |
2244 | updateFrontDisplay();\r |
2245 | }\r |
2246 | }\r |
2247 | }\r |
2248 | }\r |
2249 | }\r |
2250 | \r |
2251 | ////////////////////////////////////////////////////////////////////////\r |
2252 | // cmd: vram -> psx mem\r |
2253 | ////////////////////////////////////////////////////////////////////////\r |
2254 | \r |
2255 | void primStoreImage(u8 * baseAddr)\r |
2256 | {\r |
2257 | unsigned short *sgpuData = ((unsigned short *) baseAddr);\r |
2258 | \r |
2259 | VRAMRead.x = sgpuData[2]&0x03ff;\r |
2260 | VRAMRead.y = sgpuData[3]&iGPUHeightMask;\r |
2261 | VRAMRead.Width = sgpuData[4];\r |
2262 | VRAMRead.Height = sgpuData[5];\r |
2263 | \r |
2264 | VRAMRead.ImagePtr = psxVuw + (VRAMRead.y<<10) + VRAMRead.x;\r |
2265 | VRAMRead.RowsRemaining = VRAMRead.Width;\r |
2266 | VRAMRead.ColsRemaining = VRAMRead.Height;\r |
2267 | \r |
2268 | iDataReadMode = DR_VRAMTRANSFER;\r |
2269 | \r |
2270 | STATUSREG |= GPUSTATUS_READYFORVRAM;\r |
2271 | }\r |
2272 | \r |
2273 | ////////////////////////////////////////////////////////////////////////\r |
2274 | // cmd: blkfill - NO primitive! Doesn't care about draw areas...\r |
2275 | ////////////////////////////////////////////////////////////////////////\r |
2276 | \r |
2277 | void primBlkFill(u8 * baseAddr)\r |
2278 | {\r |
2279 | unsigned long *gpuData = ((unsigned long *) baseAddr);\r |
2280 | short *sgpuData = ((short *) baseAddr);\r |
2281 | \r |
2282 | iDrawnSomething=1;\r |
2283 | \r |
2284 | sprtX = sgpuData[2];\r |
2285 | sprtY = sgpuData[3];\r |
2286 | sprtW = sgpuData[4] & 0x3ff;\r |
2287 | sprtH = sgpuData[5] & iGPUHeightMask;\r |
2288 | \r |
2289 | sprtW = (sprtW+15) & ~15;\r |
2290 | \r |
2291 | // Increase H & W if they are one short of full values, because they never can be full values\r |
2292 | if (sprtH == iGPUHeightMask) sprtH=iGPUHeight;\r |
2293 | if (sprtW == 1023) sprtW=1024; \r |
2294 | \r |
2295 | // x and y of start\r |
2296 | ly0 = ly1 = sprtY;\r |
2297 | ly2 = ly3 = (sprtY+sprtH);\r |
2298 | lx0 = lx3 = sprtX;\r |
2299 | lx1 = lx2 = (sprtX+sprtW);\r |
2300 | \r |
2301 | offsetBlk();\r |
2302 | \r |
2303 | if(ClipVertexListScreen()) \r |
2304 | {\r |
2305 | PSXDisplay_t * pd;\r |
2306 | if(PSXDisplay.InterlacedTest) pd=&PSXDisplay;\r |
2307 | else pd=&PreviousPSXDisplay;\r |
2308 | \r |
2309 | if ((lx0 <= pd->DisplayPosition.x+16) &&\r |
2310 | (ly0 <= pd->DisplayPosition.y+16) &&\r |
2311 | (lx2 >= pd->DisplayEnd.x-16) &&\r |
2312 | (ly2 >= pd->DisplayEnd.y-16))\r |
2313 | {\r |
2314 | GLclampf g,b,r;\r |
2315 | g=((GLclampf)GREEN(gpuData[0]))/255.0f;\r |
2316 | b=((GLclampf)BLUE(gpuData[0]))/255.0f;\r |
2317 | r=((GLclampf)RED(gpuData[0]))/255.0f;\r |
2318 | \r |
2319 | glDisable(GL_SCISSOR_TEST); \r |
2320 | glClearColor(r,g,b,1.0f);\r |
2321 | glClear(uiBufferBits); \r |
2322 | gl_z=0.0f;\r |
2323 | \r |
2324 | if(gpuData[0]!=0x02000000 &&\r |
2325 | (ly0>pd->DisplayPosition.y ||\r |
2326 | ly2<pd->DisplayEnd.y))\r |
2327 | {\r |
2328 | bDrawTextured = FALSE;\r |
2329 | bDrawSmoothShaded = FALSE;\r |
2330 | SetRenderState((unsigned long)0x01000000);\r |
2331 | SetRenderMode((unsigned long)0x01000000, FALSE);\r |
2332 | vertex[0].c.lcol=0xff000000;\r |
2333 | SETCOL(vertex[0]); \r |
2334 | if(ly0>pd->DisplayPosition.y)\r |
2335 | {\r |
2336 | vertex[0].x=0;vertex[0].y=0;\r |
2337 | vertex[1].x=pd->DisplayEnd.x-pd->DisplayPosition.x;vertex[1].y=0;\r |
2338 | vertex[2].x=vertex[1].x;vertex[2].y=ly0-pd->DisplayPosition.y;\r |
2339 | vertex[3].x=0;vertex[3].y=vertex[2].y;\r |
2340 | PRIMdrawQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r |
2341 | }\r |
2342 | if(ly2<pd->DisplayEnd.y)\r |
2343 | {\r |
2344 | vertex[0].x=0;vertex[0].y=(pd->DisplayEnd.y-pd->DisplayPosition.y)-(pd->DisplayEnd.y-ly2);\r |
2345 | vertex[1].x=pd->DisplayEnd.x-pd->DisplayPosition.x;vertex[1].y=vertex[0].y;\r |
2346 | vertex[2].x=vertex[1].x;vertex[2].y=pd->DisplayEnd.y;\r |
2347 | vertex[3].x=0;vertex[3].y=vertex[2].y;\r |
2348 | PRIMdrawQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r |
2349 | }\r |
2350 | }\r |
2351 | \r |
2352 | glEnable(GL_SCISSOR_TEST); \r |
2353 | }\r |
2354 | else\r |
2355 | {\r |
2356 | bDrawTextured = FALSE;\r |
2357 | bDrawSmoothShaded = FALSE;\r |
2358 | SetRenderState((unsigned long)0x01000000);\r |
2359 | SetRenderMode((unsigned long)0x01000000, FALSE);\r |
2360 | vertex[0].c.lcol=gpuData[0]|0xff000000;\r |
2361 | SETCOL(vertex[0]); \r |
2362 | glDisable(GL_SCISSOR_TEST); \r |
2363 | PRIMdrawQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r |
2364 | glEnable(GL_SCISSOR_TEST); \r |
2365 | }\r |
2366 | }\r |
2367 | \r |
2368 | //mmm... will clean all stuff, also if not all _should_ be cleaned...\r |
2369 | //if (IsInsideNextScreen(sprtX, sprtY, sprtW, sprtH))\r |
2370 | // try this:\r |
2371 | if (IsCompleteInsideNextScreen(sprtX, sprtY, sprtW, sprtH))\r |
2372 | {\r |
2373 | lClearOnSwapColor = COLOR(gpuData[0]);\r |
2374 | lClearOnSwap = 1;\r |
2375 | }\r |
2376 | \r |
2377 | /* if(iOffscreenDrawing)\r |
2378 | {\r |
2379 | ClampToPSXScreenOffset( &sprtX, &sprtY, &sprtW, &sprtH);\r |
2380 | if ((sprtW == 0) || (sprtH == 0)) return;\r |
2381 | InvalidateTextureArea(sprtX, sprtY, sprtW-1, sprtH-1); \r |
2382 | \r |
2383 | sprtW+=sprtX;\r |
2384 | sprtH+=sprtY;\r |
2385 | \r |
2386 | FillSoftwareArea(sprtX, sprtY, sprtW, sprtH, BGR24to16(gpuData[0]));\r |
2387 | }*/\r |
2388 | }\r |
2389 | \r |
2390 | ////////////////////////////////////////////////////////////////////////\r |
2391 | // cmd: move image vram -> vram\r |
2392 | ////////////////////////////////////////////////////////////////////////\r |
2393 | \r |
2394 | void MoveImageWrapped(short imageX0,short imageY0,\r |
2395 | short imageX1,short imageY1,\r |
2396 | short imageSX,short imageSY)\r |
2397 | {\r |
2398 | int i,j,imageXE,imageYE;\r |
2399 | \r |
2400 | if(iFrameReadType&2)\r |
2401 | {\r |
2402 | imageXE=imageX0+imageSX;\r |
2403 | imageYE=imageY0+imageSY;\r |
2404 | \r |
2405 | if(imageYE>iGPUHeight && imageXE>1024) \r |
2406 | {\r |
2407 | CheckVRamRead(0,0,\r |
2408 | (imageXE&0x3ff),\r |
2409 | (imageY0&iGPUHeightMask),\r |
2410 | FALSE);\r |
2411 | }\r |
2412 | \r |
2413 | if(imageXE>1024) \r |
2414 | {\r |
2415 | CheckVRamRead(0,imageY0, \r |
2416 | (imageXE&0x3ff),\r |
2417 | (imageYE>iGPUHeight)?iGPUHeight:imageYE,\r |
2418 | FALSE);\r |
2419 | }\r |
2420 | \r |
2421 | if(imageYE>iGPUHeight) \r |
2422 | {\r |
2423 | CheckVRamRead(imageX0,0, \r |
2424 | (imageXE>1024)?1024:imageXE,\r |
2425 | imageYE&iGPUHeightMask,\r |
2426 | FALSE);\r |
2427 | }\r |
2428 | \r |
2429 | CheckVRamRead(imageX0,imageY0, \r |
2430 | (imageXE>1024)?1024:imageXE,\r |
2431 | (imageYE>iGPUHeight)?iGPUHeight:imageYE,\r |
2432 | FALSE);\r |
2433 | }\r |
2434 | \r |
2435 | for(j=0;j<imageSY;j++)\r |
2436 | for(i=0;i<imageSX;i++)\r |
2437 | psxVuw [(1024*((imageY1+j)&iGPUHeightMask))+((imageX1+i)&0x3ff)]=\r |
2438 | psxVuw[(1024*((imageY0+j)&iGPUHeightMask))+((imageX0+i)&0x3ff)];\r |
2439 | \r |
2440 | if(!PSXDisplay.RGB24)\r |
2441 | {\r |
2442 | imageXE=imageX1+imageSX;\r |
2443 | imageYE=imageY1+imageSY;\r |
2444 | \r |
2445 | if(imageYE>iGPUHeight && imageXE>1024) \r |
2446 | {\r |
2447 | InvalidateTextureArea(0,0,\r |
2448 | (imageXE&0x3ff)-1,\r |
2449 | (imageYE&iGPUHeightMask)-1);\r |
2450 | }\r |
2451 | \r |
2452 | if(imageXE>1024) \r |
2453 | {\r |
2454 | InvalidateTextureArea(0,imageY1,\r |
2455 | (imageXE&0x3ff)-1,\r |
2456 | ((imageYE>iGPUHeight)?iGPUHeight:imageYE)-imageY1-1);\r |
2457 | }\r |
2458 | \r |
2459 | if(imageYE>iGPUHeight) \r |
2460 | {\r |
2461 | InvalidateTextureArea(imageX1,0,\r |
2462 | ((imageXE>1024)?1024:imageXE)-imageX1-1,\r |
2463 | (imageYE&iGPUHeightMask)-1);\r |
2464 | }\r |
2465 | \r |
2466 | InvalidateTextureArea(imageX1,imageY1,\r |
2467 | ((imageXE>1024)?1024:imageXE)-imageX1-1,\r |
2468 | ((imageYE>iGPUHeight)?iGPUHeight:imageYE)-imageY1-1);\r |
2469 | }\r |
2470 | }\r |
2471 | \r |
2472 | ////////////////////////////////////////////////////////////////////////\r |
2473 | \r |
2474 | void primMoveImage(u8 * baseAddr)\r |
2475 | {\r |
2476 | short *sgpuData = ((short *) baseAddr);\r |
2477 | short imageY0,imageX0,imageY1,imageX1,imageSX,imageSY,i,j;\r |
2478 | \r |
2479 | imageX0 = sgpuData[2]&0x03ff;\r |
2480 | imageY0 = sgpuData[3]&iGPUHeightMask;\r |
2481 | imageX1 = sgpuData[4]&0x03ff;\r |
2482 | imageY1 = sgpuData[5]&iGPUHeightMask;\r |
2483 | imageSX = sgpuData[6];\r |
2484 | imageSY = sgpuData[7];\r |
2485 | \r |
2486 | if((imageX0 == imageX1) && (imageY0 == imageY1)) return; \r |
2487 | if(imageSX<=0) return;\r |
2488 | if(imageSY<=0) return;\r |
2489 | \r |
2490 | if(iGPUHeight==1024 && sgpuData[7]>1024) return;\r |
2491 | \r |
2492 | if((imageY0+imageSY)>iGPUHeight ||\r |
2493 | (imageX0+imageSX)>1024 ||\r |
2494 | (imageY1+imageSY)>iGPUHeight ||\r |
2495 | (imageX1+imageSX)>1024)\r |
2496 | {\r |
2497 | MoveImageWrapped(imageX0,imageY0,imageX1,imageY1,imageSX,imageSY);\r |
2498 | if((imageY0+imageSY)>iGPUHeight) imageSY=iGPUHeight-imageY0;\r |
2499 | if((imageX0+imageSX)>1024) imageSX=1024-imageX0;\r |
2500 | if((imageY1+imageSY)>iGPUHeight) imageSY=iGPUHeight-imageY1;\r |
2501 | if((imageX1+imageSX)>1024) imageSX=1024-imageX1;\r |
2502 | }\r |
2503 | \r |
2504 | if(iFrameReadType&2)\r |
2505 | CheckVRamRead(imageX0,imageY0, \r |
2506 | imageX0+imageSX,\r |
2507 | imageY0+imageSY,\r |
2508 | FALSE);\r |
2509 | \r |
2510 | if(imageSX&1)\r |
2511 | {\r |
2512 | unsigned short *SRCPtr, *DSTPtr;\r |
2513 | unsigned short LineOffset;\r |
2514 | \r |
2515 | SRCPtr = psxVuw + (1024*imageY0) + imageX0;\r |
2516 | DSTPtr = psxVuw + (1024*imageY1) + imageX1;\r |
2517 | \r |
2518 | LineOffset = 1024 - imageSX;\r |
2519 | \r |
2520 | for(j=0;j<imageSY;j++)\r |
2521 | {\r |
2522 | for(i=0;i<imageSX;i++) *DSTPtr++ = *SRCPtr++;\r |
2523 | SRCPtr += LineOffset;\r |
2524 | DSTPtr += LineOffset;\r |
2525 | }\r |
2526 | }\r |
2527 | else\r |
2528 | {\r |
2529 | unsigned long *SRCPtr, *DSTPtr;\r |
2530 | unsigned short LineOffset;\r |
2531 | int dx=imageSX>>1;\r |
2532 | \r |
2533 | SRCPtr = (unsigned long *)(psxVuw + (1024*imageY0) + imageX0);\r |
2534 | DSTPtr = (unsigned long *)(psxVuw + (1024*imageY1) + imageX1);\r |
2535 | \r |
2536 | LineOffset = 512 - dx;\r |
2537 | \r |
2538 | for(j=0;j<imageSY;j++)\r |
2539 | {\r |
2540 | for(i=0;i<dx;i++) *DSTPtr++ = *SRCPtr++;\r |
2541 | SRCPtr += LineOffset;\r |
2542 | DSTPtr += LineOffset;\r |
2543 | }\r |
2544 | }\r |
2545 | \r |
2546 | if (!PSXDisplay.RGB24)\r |
2547 | {\r |
2548 | InvalidateTextureArea(imageX1,imageY1,imageSX-1,imageSY-1);\r |
2549 | \r |
2550 | if (CheckAgainstScreen(imageX1,imageY1,imageSX,imageSY)) \r |
2551 | {\r |
2552 | if(imageX1>=PreviousPSXDisplay.DisplayPosition.x &&\r |
2553 | imageX1<PreviousPSXDisplay.DisplayEnd.x &&\r |
2554 | imageY1>=PreviousPSXDisplay.DisplayPosition.y &&\r |
2555 | imageY1<PreviousPSXDisplay.DisplayEnd.y)\r |
2556 | {\r |
2557 | imageX1 += imageSX;\r |
2558 | imageY1 += imageSY;\r |
2559 | \r |
2560 | if(imageX1>=PreviousPSXDisplay.DisplayPosition.x &&\r |
2561 | imageX1<=PreviousPSXDisplay.DisplayEnd.x &&\r |
2562 | imageY1>=PreviousPSXDisplay.DisplayPosition.y &&\r |
2563 | imageY1<=PreviousPSXDisplay.DisplayEnd.y)\r |
2564 | {\r |
2565 | if(!(\r |
2566 | imageX0>=PSXDisplay.DisplayPosition.x &&\r |
2567 | imageX0<PSXDisplay.DisplayEnd.x &&\r |
2568 | imageY0>=PSXDisplay.DisplayPosition.y &&\r |
2569 | imageY0<PSXDisplay.DisplayEnd.y \r |
2570 | ))\r |
2571 | {\r |
2572 | if(bRenderFrontBuffer) \r |
2573 | {\r |
2574 | updateFrontDisplay();\r |
2575 | }\r |
2576 | \r |
2577 | UploadScreen(FALSE);\r |
2578 | }\r |
2579 | else bFakeFrontBuffer=TRUE;\r |
2580 | }\r |
2581 | }\r |
2582 | \r |
2583 | bNeedUploadTest=TRUE;\r |
2584 | }\r |
2585 | else\r |
2586 | if(iOffscreenDrawing)\r |
2587 | {\r |
2588 | if (CheckAgainstFrontScreen(imageX1,imageY1,imageSX,imageSY)) \r |
2589 | {\r |
2590 | if(!PSXDisplay.InterlacedTest &&\r |
2591 | // !bFullVRam &&\r |
2592 | ((\r |
2593 | imageX0>=PreviousPSXDisplay.DisplayPosition.x &&\r |
2594 | imageX0<PreviousPSXDisplay.DisplayEnd.x &&\r |
2595 | imageY0>=PreviousPSXDisplay.DisplayPosition.y &&\r |
2596 | imageY0<PreviousPSXDisplay.DisplayEnd.y\r |
2597 | ) ||\r |
2598 | (\r |
2599 | imageX0>=PSXDisplay.DisplayPosition.x &&\r |
2600 | imageX0<PSXDisplay.DisplayEnd.x &&\r |
2601 | imageY0>=PSXDisplay.DisplayPosition.y &&\r |
2602 | imageY0<PSXDisplay.DisplayEnd.y\r |
2603 | )))\r |
2604 | return;\r |
2605 | \r |
2606 | bNeedUploadTest=TRUE;\r |
2607 | \r |
2608 | if(!bNeedUploadAfter)\r |
2609 | {\r |
2610 | bNeedUploadAfter = TRUE;\r |
2611 | xrUploadArea.x0=imageX0;\r |
2612 | xrUploadArea.x1=imageX0+imageSX;\r |
2613 | xrUploadArea.y0=imageY0;\r |
2614 | xrUploadArea.y1=imageY0+imageSY;\r |
2615 | }\r |
2616 | else\r |
2617 | {\r |
2618 | xrUploadArea.x0=min(xrUploadArea.x0,imageX0);\r |
2619 | xrUploadArea.x1=max(xrUploadArea.x1,imageX0+imageSX);\r |
2620 | xrUploadArea.y0=min(xrUploadArea.y0,imageY0);\r |
2621 | xrUploadArea.y1=max(xrUploadArea.y1,imageY0+imageSY);\r |
2622 | }\r |
2623 | }\r |
2624 | }\r |
2625 | }\r |
2626 | }\r |
2627 | \r |
2628 | \r |
2629 | ////////////////////////////////////////////////////////////////////////\r |
2630 | // cmd: draw free-size Tile \r |
2631 | ////////////////////////////////////////////////////////////////////////\r |
2632 | \r |
2633 | void primTileS(u8 * baseAddr)\r |
2634 | {\r |
2635 | unsigned long *gpuData = ((unsigned long*)baseAddr);\r |
2636 | short *sgpuData = ((short *) baseAddr);\r |
2637 | \r |
2638 | sprtX = sgpuData[2];\r |
2639 | sprtY = sgpuData[3];\r |
2640 | sprtW = sgpuData[4] & 0x3ff;\r |
2641 | sprtH = sgpuData[5] & iGPUHeightMask;\r |
2642 | \r |
2643 | // x and y of start\r |
2644 | \r |
2645 | lx0 = sprtX;\r |
2646 | ly0 = sprtY;\r |
2647 | \r |
2648 | offsetST();\r |
2649 | \r |
2650 | if((dwActFixes&1) && // FF7 special game gix (battle cursor)\r |
2651 | sprtX==0 && sprtY==0 && sprtW==24 && sprtH==16) \r |
2652 | return;\r |
2653 | \r |
2654 | bDrawTextured = FALSE;\r |
2655 | bDrawSmoothShaded = FALSE;\r |
2656 | \r |
2657 | SetRenderState(gpuData[0]);\r |
2658 | \r |
2659 | /* if(iOffscreenDrawing)\r |
2660 | {\r |
2661 | if(IsPrimCompleteInsideNextScreen(lx0,ly0,lx2,ly2) ||\r |
2662 | (ly0==-6 && ly2==10)) // OH MY GOD... I DIDN'T WANT TO DO IT... BUT I'VE FOUND NO OTHER WAY... HACK FOR GRADIUS SHOOTER :(\r |
2663 | {\r |
2664 | lClearOnSwapColor = COLOR(gpuData[0]);\r |
2665 | lClearOnSwap = 1;\r |
2666 | }\r |
2667 | \r |
2668 | offsetPSX4();\r |
2669 | if(bDrawOffscreen4())\r |
2670 | {\r |
2671 | if(!(iTileCheat && sprtH==32 && gpuData[0]==0x60ffffff)) // special cheat for certain ZiNc games\r |
2672 | {\r |
2673 | InvalidateTextureAreaEx(); \r |
2674 | FillSoftwareAreaTrans(lx0,ly0,lx2,ly2,\r |
2675 | BGR24to16(gpuData[0])); \r |
2676 | }\r |
2677 | }\r |
2678 | }*/\r |
2679 | \r |
2680 | SetRenderMode(gpuData[0], FALSE);\r |
2681 | SetZMask4NT();\r |
2682 | \r |
2683 | if(bIgnoreNextTile) {bIgnoreNextTile=FALSE;return;}\r |
2684 | \r |
2685 | vertex[0].c.lcol=gpuData[0];\r |
2686 | vertex[0].c.col[3]=ubGloColAlpha;\r |
2687 | SETCOL(vertex[0]); \r |
2688 | \r |
2689 | PRIMdrawQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r |
2690 | \r |
2691 | iDrawnSomething=1;\r |
2692 | }\r |
2693 | \r |
2694 | ////////////////////////////////////////////////////////////////////////\r |
2695 | // cmd: draw 1 dot Tile (point)\r |
2696 | ////////////////////////////////////////////////////////////////////////\r |
2697 | \r |
2698 | void primTile1(u8 * baseAddr)\r |
2699 | {\r |
2700 | unsigned long *gpuData = ((unsigned long*)baseAddr);\r |
2701 | short *sgpuData = ((short *) baseAddr);\r |
2702 | \r |
2703 | sprtX = sgpuData[2];\r |
2704 | sprtY = sgpuData[3];\r |
2705 | sprtW = 1;\r |
2706 | sprtH = 1;\r |
2707 | \r |
2708 | lx0 = sprtX;\r |
2709 | ly0 = sprtY;\r |
2710 | \r |
2711 | offsetST();\r |
2712 | \r |
2713 | bDrawTextured = FALSE;\r |
2714 | bDrawSmoothShaded = FALSE;\r |
2715 | \r |
2716 | SetRenderState(gpuData[0]);\r |
2717 | \r |
2718 | /* if(iOffscreenDrawing)\r |
2719 | {\r |
2720 | offsetPSX4();\r |
2721 | \r |
2722 | if(bDrawOffscreen4())\r |
2723 | {\r |
2724 | InvalidateTextureAreaEx(); \r |
2725 | FillSoftwareAreaTrans(lx0,ly0,lx2,ly2,\r |
2726 | BGR24to16(gpuData[0])); \r |
2727 | }\r |
2728 | }\r |
2729 | */\r |
2730 | SetRenderMode(gpuData[0], FALSE);\r |
2731 | SetZMask4NT();\r |
2732 | \r |
2733 | vertex[0].c.lcol=gpuData[0];vertex[0].c.col[3]=ubGloColAlpha;\r |
2734 | SETCOL(vertex[0]); \r |
2735 | \r |
2736 | PRIMdrawQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r |
2737 | \r |
2738 | iDrawnSomething=1;\r |
2739 | }\r |
2740 | \r |
2741 | ////////////////////////////////////////////////////////////////////////\r |
2742 | // cmd: draw 8 dot Tile (small rect)\r |
2743 | ////////////////////////////////////////////////////////////////////////\r |
2744 | \r |
2745 | void primTile8(u8 * baseAddr)\r |
2746 | {\r |
2747 | unsigned long *gpuData = ((unsigned long*)baseAddr);\r |
2748 | short *sgpuData = ((short *) baseAddr);\r |
2749 | \r |
2750 | sprtX = sgpuData[2];\r |
2751 | sprtY = sgpuData[3];\r |
2752 | sprtW = 8;\r |
2753 | sprtH = 8;\r |
2754 | \r |
2755 | lx0 = sprtX;\r |
2756 | ly0 = sprtY;\r |
2757 | \r |
2758 | offsetST();\r |
2759 | \r |
2760 | bDrawTextured = FALSE;\r |
2761 | bDrawSmoothShaded = FALSE;\r |
2762 | SetRenderState(gpuData[0]);\r |
2763 | \r |
2764 | /* if(iOffscreenDrawing)\r |
2765 | {\r |
2766 | offsetPSX4();\r |
2767 | \r |
2768 | if(bDrawOffscreen4())\r |
2769 | {\r |
2770 | InvalidateTextureAreaEx(); \r |
2771 | FillSoftwareAreaTrans(lx0,ly0,lx2,ly2,\r |
2772 | BGR24to16(gpuData[0])); \r |
2773 | }\r |
2774 | }\r |
2775 | */\r |
2776 | SetRenderMode(gpuData[0], FALSE);\r |
2777 | SetZMask4NT();\r |
2778 | \r |
2779 | vertex[0].c.lcol=gpuData[0];\r |
2780 | vertex[0].c.col[3]=ubGloColAlpha;\r |
2781 | SETCOL(vertex[0]); \r |
2782 | \r |
2783 | PRIMdrawQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r |
2784 | \r |
2785 | iDrawnSomething=1;\r |
2786 | }\r |
2787 | \r |
2788 | ////////////////////////////////////////////////////////////////////////\r |
2789 | // cmd: draw 16 dot Tile (medium rect)\r |
2790 | ////////////////////////////////////////////////////////////////////////\r |
2791 | \r |
2792 | void primTile16(u8 * baseAddr)\r |
2793 | {\r |
2794 | unsigned long *gpuData = ((unsigned long*)baseAddr);\r |
2795 | short *sgpuData = ((short *) baseAddr);\r |
2796 | \r |
2797 | sprtX = sgpuData[2];\r |
2798 | sprtY = sgpuData[3];\r |
2799 | sprtW = 16;\r |
2800 | sprtH = 16;\r |
2801 | // x and y of start\r |
2802 | lx0 = sprtX;\r |
2803 | ly0 = sprtY;\r |
2804 | \r |
2805 | offsetST();\r |
2806 | \r |
2807 | bDrawTextured = FALSE;\r |
2808 | bDrawSmoothShaded = FALSE;\r |
2809 | SetRenderState(gpuData[0]);\r |
2810 | \r |
2811 | /* if(iOffscreenDrawing)\r |
2812 | {\r |
2813 | offsetPSX4();\r |
2814 | \r |
2815 | if(bDrawOffscreen4())\r |
2816 | {\r |
2817 | InvalidateTextureAreaEx(); \r |
2818 | FillSoftwareAreaTrans(lx0,ly0,lx2,ly2,\r |
2819 | BGR24to16(gpuData[0])); \r |
2820 | }\r |
2821 | }\r |
2822 | */\r |
2823 | SetRenderMode(gpuData[0], FALSE);\r |
2824 | SetZMask4NT();\r |
2825 | \r |
2826 | vertex[0].c.lcol=gpuData[0];\r |
2827 | vertex[0].c.col[3]=ubGloColAlpha;\r |
2828 | SETCOL(vertex[0]); \r |
2829 | \r |
2830 | PRIMdrawQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r |
2831 | \r |
2832 | iDrawnSomething=1;\r |
2833 | }\r |
2834 | \r |
2835 | ////////////////////////////////////////////////////////////////////////\r |
2836 | // helper: filter effect by multipass rendering\r |
2837 | ////////////////////////////////////////////////////////////////////////\r |
2838 | \r |
2839 | /*void DrawMultiBlur(void)\r |
2840 | {\r |
2841 | long lABR,lDST;float fx,fy;\r |
2842 | \r |
2843 | lABR=GlobalTextABR;\r |
2844 | lDST=DrawSemiTrans;\r |
2845 | \r |
2846 | fx=(float)PSXDisplay.DisplayMode.x/(float)(iResX); \r |
2847 | fy=(float)PSXDisplay.DisplayMode.y/(float)(iResY);\r |
2848 | \r |
2849 | vertex[0].x+=fx;vertex[1].x+=fx;\r |
2850 | vertex[2].x+=fx;vertex[3].x+=fx;\r |
2851 | \r |
2852 | GlobalTextABR=0;\r |
2853 | DrawSemiTrans=1;\r |
2854 | SetSemiTrans();\r |
2855 | \r |
2856 | PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r |
2857 | \r |
2858 | vertex[0].y+=fy;vertex[1].y+=fy;\r |
2859 | vertex[2].y+=fy;vertex[3].y+=fy;\r |
2860 | PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r |
2861 | \r |
2862 | if(bDrawMultiPass) {obm1=obm2=GL_SRC_ALPHA;}\r |
2863 | \r |
2864 | GlobalTextABR=lABR;\r |
2865 | DrawSemiTrans=lDST;\r |
2866 | }\r |
2867 | */\r |
2868 | ////////////////////////////////////////////////////////////////////////\r |
2869 | \r |
2870 | #define POFF 0.375f\r |
2871 | \r |
2872 | void DrawMultiFilterSprite(void)\r |
2873 | {\r |
2874 | long lABR,lDST;\r |
2875 | \r |
2876 | if(bUseMultiPass || DrawSemiTrans || ubOpaqueDraw) \r |
2877 | {\r |
2878 | PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r |
2879 | return;\r |
2880 | }\r |
2881 | \r |
2882 | lABR=GlobalTextABR;\r |
2883 | lDST=DrawSemiTrans;\r |
2884 | vertex[0].c.col[3]=ubGloAlpha/2; // -> set color with\r |
2885 | SETCOL(vertex[0]); // texture alpha\r |
2886 | PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r |
2887 | vertex[0].x+=POFF;vertex[1].x+=POFF;\r |
2888 | vertex[2].x+=POFF;vertex[3].x+=POFF;\r |
2889 | vertex[0].y+=POFF;vertex[1].y+=POFF;\r |
2890 | vertex[2].y+=POFF;vertex[3].y+=POFF;\r |
2891 | GlobalTextABR=0;\r |
2892 | DrawSemiTrans=1;\r |
2893 | SetSemiTrans();\r |
2894 | PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r |
2895 | GlobalTextABR=lABR;\r |
2896 | DrawSemiTrans=lDST;\r |
2897 | }\r |
2898 | \r |
2899 | ////////////////////////////////////////////////////////////////////////\r |
2900 | // cmd: small sprite (textured rect)\r |
2901 | ////////////////////////////////////////////////////////////////////////\r |
2902 | \r |
2903 | void primSprt8(u8 * baseAddr)\r |
2904 | {\r |
2905 | unsigned long *gpuData = ((unsigned long *) baseAddr);\r |
2906 | short *sgpuData = ((short *) baseAddr);\r |
2907 | short s;\r |
2908 | \r |
2909 | iSpriteTex=1;\r |
2910 | \r |
2911 | sprtX = sgpuData[2];\r |
2912 | sprtY = sgpuData[3];\r |
2913 | sprtW = 8;\r |
2914 | sprtH = 8;\r |
2915 | \r |
2916 | lx0 = sprtX;\r |
2917 | ly0 = sprtY;\r |
2918 | \r |
2919 | offsetST();\r |
2920 | \r |
2921 | // do texture stuff\r |
2922 | gl_ux[0]=gl_ux[3]=baseAddr[8];//gpuData[2]&0xff;\r |
2923 | \r |
2924 | if(usMirror & 0x1000) \r |
2925 | {\r |
2926 | s=gl_ux[0];\r |
2927 | s-=sprtW-1;\r |
2928 | if(s<0) {s=0;}\r |
2929 | gl_ux[0]=gl_ux[3]=s;\r |
2930 | }\r |
2931 | \r |
2932 | sSprite_ux2=s=gl_ux[0]+sprtW; \r |
2933 | if(s) s--;\r |
2934 | if(s>255) s=255;\r |
2935 | gl_ux[1]=gl_ux[2]=s;\r |
2936 | // Y coords\r |
2937 | gl_vy[0]=gl_vy[1]=baseAddr[9];//(gpuData[2]>>8)&0xff;\r |
2938 | \r |
2939 | if(usMirror & 0x2000) \r |
2940 | {\r |
2941 | s=gl_vy[0];\r |
2942 | s-=sprtH-1;\r |
2943 | if(s<0) {s=0;}\r |
2944 | gl_vy[0]=gl_vy[1]=s;\r |
2945 | }\r |
2946 | \r |
2947 | sSprite_vy2=s=gl_vy[0]+sprtH; \r |
2948 | if(s) s--;\r |
2949 | if(s>255) s=255;\r |
2950 | gl_vy[2]=gl_vy[3]=s;\r |
2951 | \r |
2952 | ulClutID=(gpuData[2]>>16);\r |
2953 | \r |
2954 | bDrawTextured = TRUE;\r |
2955 | bDrawSmoothShaded = FALSE;\r |
2956 | SetRenderState(gpuData[0]);\r |
2957 | \r |
2958 | /* if(iOffscreenDrawing) \r |
2959 | {\r |
2960 | offsetPSX4();\r |
2961 | \r |
2962 | if(bDrawOffscreen4())\r |
2963 | {\r |
2964 | InvalidateTextureAreaEx(); \r |
2965 | SetRenderColor(gpuData[0]);\r |
2966 | lx0-=PSXDisplay.DrawOffset.x;\r |
2967 | ly0-=PSXDisplay.DrawOffset.y;\r |
2968 | \r |
2969 | if(bUsingTWin) DrawSoftwareSpriteTWin(baseAddr,8,8);\r |
2970 | else\r |
2971 | if(usMirror) DrawSoftwareSpriteMirror(baseAddr,8,8);\r |
2972 | else\r |
2973 | DrawSoftwareSprite(baseAddr,8,8,baseAddr[8],baseAddr[9]);\r |
2974 | }\r |
2975 | }\r |
2976 | */\r |
2977 | SetRenderMode(gpuData[0], TRUE);\r |
2978 | SetZMask4SP();\r |
2979 | \r |
2980 | sSprite_ux2=gl_ux[0]+sprtW;\r |
2981 | sSprite_vy2=gl_vy[0]+sprtH;\r |
2982 | \r |
2983 | assignTextureSprite();\r |
2984 | \r |
2985 | if(iFilterType>4) \r |
2986 | DrawMultiFilterSprite();\r |
2987 | else\r |
2988 | PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r |
2989 | \r |
2990 | if(bDrawMultiPass)\r |
2991 | {\r |
2992 | SetSemiTransMulti(1);\r |
2993 | PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r |
2994 | }\r |
2995 | \r |
2996 | if(ubOpaqueDraw)\r |
2997 | {\r |
2998 | SetZMask4O();\r |
2999 | if(bUseMultiPass) SetOpaqueColor(gpuData[0]);\r |
3000 | DEFOPAQUEON\r |
3001 | \r |
3002 | /* if(bSmallAlpha && iFilterType<=2)\r |
3003 | {\r |
3004 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);\r |
3005 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\r |
3006 | PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r |
3007 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);\r |
3008 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\r |
3009 | SetZMask4O();\r |
3010 | }\r |
3011 | */\r |
3012 | PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r |
3013 | DEFOPAQUEOFF\r |
3014 | }\r |
3015 | \r |
3016 | iSpriteTex=0;\r |
3017 | iDrawnSomething=1;\r |
3018 | }\r |
3019 | \r |
3020 | ////////////////////////////////////////////////////////////////////////\r |
3021 | // cmd: medium sprite (textured rect)\r |
3022 | ////////////////////////////////////////////////////////////////////////\r |
3023 | \r |
3024 | void primSprt16(u8 * baseAddr)\r |
3025 | {\r |
3026 | unsigned long *gpuData = ((unsigned long *) baseAddr);\r |
3027 | short *sgpuData = ((short *) baseAddr);\r |
3028 | short s;\r |
3029 | \r |
3030 | iSpriteTex=1;\r |
3031 | \r |
3032 | sprtX = sgpuData[2];\r |
3033 | sprtY = sgpuData[3];\r |
3034 | sprtW = 16;\r |
3035 | sprtH = 16;\r |
3036 | \r |
3037 | lx0 = sprtX;\r |
3038 | ly0 = sprtY;\r |
3039 | \r |
3040 | offsetST();\r |
3041 | \r |
3042 | // do texture stuff\r |
3043 | gl_ux[0]=gl_ux[3]=baseAddr[8];//gpuData[2]&0xff;\r |
3044 | \r |
3045 | if(usMirror & 0x1000) \r |
3046 | {\r |
3047 | s=gl_ux[0];\r |
3048 | s-=sprtW-1;\r |
3049 | if(s<0) {s=0;}\r |
3050 | gl_ux[0]=gl_ux[3]=s;\r |
3051 | }\r |
3052 | \r |
3053 | sSprite_ux2=s=gl_ux[0]+sprtW; \r |
3054 | if(s) s--;\r |
3055 | if(s>255) s=255;\r |
3056 | gl_ux[1]=gl_ux[2]=s; \r |
3057 | // Y coords\r |
3058 | gl_vy[0]=gl_vy[1]=baseAddr[9];//(gpuData[2]>>8)&0xff;\r |
3059 | \r |
3060 | if(usMirror & 0x2000) \r |
3061 | {\r |
3062 | s=gl_vy[0];\r |
3063 | s-=sprtH-1;\r |
3064 | if(s<0) {s=0;}\r |
3065 | gl_vy[0]=gl_vy[1]=s;\r |
3066 | }\r |
3067 | \r |
3068 | sSprite_vy2=s=gl_vy[0]+sprtH; \r |
3069 | if(s) s--;\r |
3070 | if(s>255) s=255;\r |
3071 | gl_vy[2]=gl_vy[3]=s;\r |
3072 | \r |
3073 | ulClutID=(gpuData[2]>>16);\r |
3074 | \r |
3075 | bDrawTextured = TRUE;\r |
3076 | bDrawSmoothShaded = FALSE;\r |
3077 | SetRenderState(gpuData[0]);\r |
3078 | \r |
3079 | /* if(iOffscreenDrawing) \r |
3080 | {\r |
3081 | offsetPSX4();\r |
3082 | \r |
3083 | if(bDrawOffscreen4())\r |
3084 | {\r |
3085 | InvalidateTextureAreaEx(); \r |
3086 | SetRenderColor(gpuData[0]);\r |
3087 | lx0-=PSXDisplay.DrawOffset.x;\r |
3088 | ly0-=PSXDisplay.DrawOffset.y;\r |
3089 | if(bUsingTWin) DrawSoftwareSpriteTWin(baseAddr,16,16);\r |
3090 | else\r |
3091 | if(usMirror) DrawSoftwareSpriteMirror(baseAddr,16,16);\r |
3092 | else\r |
3093 | DrawSoftwareSprite(baseAddr,16,16,baseAddr[8],baseAddr[9]);\r |
3094 | }\r |
3095 | }\r |
3096 | */\r |
3097 | SetRenderMode(gpuData[0], TRUE);\r |
3098 | SetZMask4SP();\r |
3099 | \r |
3100 | sSprite_ux2=gl_ux[0]+sprtW;\r |
3101 | sSprite_vy2=gl_vy[0]+sprtH;\r |
3102 | \r |
3103 | assignTextureSprite();\r |
3104 | \r |
3105 | if(iFilterType>4) \r |
3106 | DrawMultiFilterSprite();\r |
3107 | else\r |
3108 | PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r |
3109 | \r |
3110 | if(bDrawMultiPass)\r |
3111 | {\r |
3112 | SetSemiTransMulti(1);\r |
3113 | PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r |
3114 | }\r |
3115 | \r |
3116 | if(ubOpaqueDraw)\r |
3117 | {\r |
3118 | SetZMask4O();\r |
3119 | if(bUseMultiPass) SetOpaqueColor(gpuData[0]);\r |
3120 | DEFOPAQUEON\r |
3121 | \r |
3122 | /* if(bSmallAlpha && iFilterType<=2)\r |
3123 | {\r |
3124 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);\r |
3125 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\r |
3126 | PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r |
3127 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);\r |
3128 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\r |
3129 | SetZMask4O();\r |
3130 | }\r |
3131 | */\r |
3132 | PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r |
3133 | DEFOPAQUEOFF\r |
3134 | }\r |
3135 | \r |
3136 | iSpriteTex=0;\r |
3137 | iDrawnSomething=1;\r |
3138 | }\r |
3139 | \r |
3140 | ////////////////////////////////////////////////////////////////////////\r |
3141 | // cmd: free-size sprite (textured rect)\r |
3142 | ////////////////////////////////////////////////////////////////////////\r |
3143 | \r |
3144 | void primSprtSRest(u8 * baseAddr,unsigned short type)\r |
3145 | {\r |
3146 | unsigned long *gpuData = ((unsigned long *) baseAddr);\r |
3147 | short *sgpuData = ((short *) baseAddr);\r |
3148 | short s;unsigned short sTypeRest=0;\r |
3149 | \r |
3150 | sprtX = sgpuData[2];\r |
3151 | sprtY = sgpuData[3];\r |
3152 | sprtW = sgpuData[6] & 0x3ff;\r |
3153 | sprtH = sgpuData[7] & 0x1ff;\r |
3154 | \r |
3155 | \r |
3156 | // do texture stuff\r |
3157 | switch(type)\r |
3158 | {\r |
3159 | case 1:\r |
3160 | gl_vy[0]=gl_vy[1]=baseAddr[9];\r |
3161 | s=256-baseAddr[8];\r |
3162 | sprtW-=s;\r |
3163 | sprtX+=s;\r |
3164 | gl_ux[0]=gl_ux[3]=0;\r |
3165 | break;\r |
3166 | case 2:\r |
3167 | gl_ux[0]=gl_ux[3]=baseAddr[8];\r |
3168 | s=256-baseAddr[9];\r |
3169 | sprtH-=s;\r |
3170 | sprtY+=s;\r |
3171 | gl_vy[0]=gl_vy[1]=0;\r |
3172 | break;\r |
3173 | case 3:\r |
3174 | s=256-baseAddr[8];\r |
3175 | sprtW-=s;\r |
3176 | sprtX+=s;\r |
3177 | gl_ux[0]=gl_ux[3]=0;\r |
3178 | s=256-baseAddr[9];\r |
3179 | sprtH-=s;\r |
3180 | sprtY+=s;\r |
3181 | gl_vy[0]=gl_vy[1]=0;\r |
3182 | break;\r |
3183 | \r |
3184 | case 4:\r |
3185 | gl_vy[0]=gl_vy[1]=baseAddr[9];\r |
3186 | s=512-baseAddr[8];\r |
3187 | sprtW-=s;\r |
3188 | sprtX+=s;\r |
3189 | gl_ux[0]=gl_ux[3]=0;\r |
3190 | break;\r |
3191 | case 5:\r |
3192 | gl_ux[0]=gl_ux[3]=baseAddr[8];\r |
3193 | s=512-baseAddr[9];\r |
3194 | sprtH-=s;\r |
3195 | sprtY+=s;\r |
3196 | gl_vy[0]=gl_vy[1]=0;\r |
3197 | break;\r |
3198 | case 6:\r |
3199 | s=512-baseAddr[8];\r |
3200 | sprtW-=s;\r |
3201 | sprtX+=s;\r |
3202 | gl_ux[0]=gl_ux[3]=0;\r |
3203 | s=512-baseAddr[9];\r |
3204 | sprtH-=s;\r |
3205 | sprtY+=s;\r |
3206 | gl_vy[0]=gl_vy[1]=0;\r |
3207 | break;\r |
3208 | \r |
3209 | }\r |
3210 | \r |
3211 | if(usMirror & 0x1000) \r |
3212 | {\r |
3213 | s=gl_ux[0];\r |
3214 | s-=sprtW-1;if(s<0) s=0;\r |
3215 | gl_ux[0]=gl_ux[3]=s;\r |
3216 | }\r |
3217 | if(usMirror & 0x2000) \r |
3218 | {\r |
3219 | s=gl_vy[0];\r |
3220 | s-=sprtH-1;if(s<0) {s=0;}\r |
3221 | gl_vy[0]=gl_vy[1]=s;\r |
3222 | }\r |
3223 | \r |
3224 | sSprite_ux2=s=gl_ux[0]+sprtW; \r |
3225 | if(s>255) s=255;\r |
3226 | gl_ux[1]=gl_ux[2]=s;\r |
3227 | sSprite_vy2=s=gl_vy[0]+sprtH; \r |
3228 | if(s>255) s=255;\r |
3229 | gl_vy[2]=gl_vy[3]=s;\r |
3230 | \r |
3231 | if(!bUsingTWin)\r |
3232 | {\r |
3233 | if(sSprite_ux2>256) \r |
3234 | {sprtW=256-gl_ux[0];sSprite_ux2=256;sTypeRest+=1;}\r |
3235 | if(sSprite_vy2>256) \r |
3236 | {sprtH=256-gl_vy[0];sSprite_vy2=256;sTypeRest+=2;}\r |
3237 | }\r |
3238 | \r |
3239 | lx0 = sprtX;\r |
3240 | ly0 = sprtY;\r |
3241 | \r |
3242 | offsetST();\r |
3243 | \r |
3244 | ulClutID=(gpuData[2]>>16);\r |
3245 | \r |
3246 | bDrawTextured = TRUE;\r |
3247 | bDrawSmoothShaded = FALSE;\r |
3248 | SetRenderState(gpuData[0]);\r |
3249 | \r |
3250 | /* if(iOffscreenDrawing)\r |
3251 | {\r |
3252 | offsetPSX4();\r |
3253 | \r |
3254 | if(bDrawOffscreen4())\r |
3255 | {\r |
3256 | InvalidateTextureAreaEx(); \r |
3257 | SetRenderColor(gpuData[0]);\r |
3258 | lx0-=PSXDisplay.DrawOffset.x;\r |
3259 | ly0-=PSXDisplay.DrawOffset.y;\r |
3260 | if(bUsingTWin) DrawSoftwareSpriteTWin(baseAddr,sprtW,sprtH);\r |
3261 | else\r |
3262 | if(usMirror) DrawSoftwareSpriteMirror(baseAddr,sprtW,sprtH);\r |
3263 | else\r |
3264 | DrawSoftwareSprite(baseAddr,sprtW,sprtH,baseAddr[8],baseAddr[9]);\r |
3265 | }\r |
3266 | }\r |
3267 | */\r |
3268 | SetRenderMode(gpuData[0], TRUE);\r |
3269 | SetZMask4SP();\r |
3270 | \r |
3271 | sSprite_ux2=gl_ux[0]+sprtW;\r |
3272 | sSprite_vy2=gl_vy[0]+sprtH;\r |
3273 | \r |
3274 | assignTextureSprite();\r |
3275 | \r |
3276 | if(iFilterType>4) \r |
3277 | DrawMultiFilterSprite();\r |
3278 | else\r |
3279 | PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r |
3280 | \r |
3281 | if(bDrawMultiPass)\r |
3282 | {\r |
3283 | SetSemiTransMulti(1);\r |
3284 | PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r |
3285 | }\r |
3286 | \r |
3287 | if(ubOpaqueDraw)\r |
3288 | {\r |
3289 | SetZMask4O();\r |
3290 | if(bUseMultiPass) SetOpaqueColor(gpuData[0]);\r |
3291 | DEFOPAQUEON\r |
3292 | \r |
3293 | /* if(bSmallAlpha && iFilterType<=2)\r |
3294 | {\r |
3295 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);\r |
3296 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\r |
3297 | PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r |
3298 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);\r |
3299 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\r |
3300 | SetZMask4O();\r |
3301 | }\r |
3302 | */\r |
3303 | PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r |
3304 | DEFOPAQUEOFF\r |
3305 | }\r |
3306 | \r |
3307 | if(sTypeRest && type<4) \r |
3308 | {\r |
3309 | if(sTypeRest&1 && type==1) primSprtSRest(baseAddr,4);\r |
3310 | if(sTypeRest&2 && type==2) primSprtSRest(baseAddr,5);\r |
3311 | if(sTypeRest==3 && type==3) primSprtSRest(baseAddr,6);\r |
3312 | }\r |
3313 | }\r |
3314 | \r |
3315 | void primSprtS(u8 * baseAddr)\r |
3316 | {\r |
3317 | unsigned long *gpuData = ((unsigned long *) baseAddr);\r |
3318 | short *sgpuData = ((short *) baseAddr);\r |
3319 | \r |
3320 | short s;unsigned short sTypeRest=0;\r |
3321 | \r |
3322 | sprtX = sgpuData[2];\r |
3323 | sprtY = sgpuData[3];\r |
3324 | sprtW = sgpuData[6] & 0x3ff;\r |
3325 | sprtH = sgpuData[7] & 0x1ff;\r |
3326 | \r |
3327 | if(!sprtH) return;\r |
3328 | if(!sprtW) return;\r |
3329 | \r |
3330 | iSpriteTex=1;\r |
3331 | \r |
3332 | // do texture stuff\r |
3333 | gl_ux[0]=gl_ux[3]=baseAddr[8];//gpuData[2]&0xff;\r |
3334 | gl_vy[0]=gl_vy[1]=baseAddr[9];//(gpuData[2]>>8)&0xff;\r |
3335 | \r |
3336 | if(usMirror & 0x1000) \r |
3337 | {\r |
3338 | s=gl_ux[0];\r |
3339 | s-=sprtW-1;\r |
3340 | if(s<0) {s=0;}\r |
3341 | gl_ux[0]=gl_ux[3]=s;\r |
3342 | }\r |
3343 | if(usMirror & 0x2000) \r |
3344 | {\r |
3345 | s=gl_vy[0];\r |
3346 | s-=sprtH-1;\r |
3347 | if(s<0) {s=0;}\r |
3348 | gl_vy[0]=gl_vy[1]=s;\r |
3349 | }\r |
3350 | \r |
3351 | sSprite_ux2=s=gl_ux[0]+sprtW; \r |
3352 | if(s) s--;\r |
3353 | if(s>255) s=255;\r |
3354 | gl_ux[1]=gl_ux[2]=s;\r |
3355 | sSprite_vy2=s=gl_vy[0]+sprtH; \r |
3356 | if(s) s--;\r |
3357 | if(s>255) s=255;\r |
3358 | gl_vy[2]=gl_vy[3]=s;\r |
3359 | \r |
3360 | if(!bUsingTWin)\r |
3361 | {\r |
3362 | if(sSprite_ux2>256) \r |
3363 | {sprtW=256-gl_ux[0];sSprite_ux2=256;sTypeRest+=1;}\r |
3364 | if(sSprite_vy2>256) \r |
3365 | {sprtH=256-gl_vy[0];sSprite_vy2=256;sTypeRest+=2;}\r |
3366 | }\r |
3367 | \r |
3368 | lx0 = sprtX;\r |
3369 | ly0 = sprtY;\r |
3370 | \r |
3371 | offsetST();\r |
3372 | \r |
3373 | ulClutID=(gpuData[2]>>16);\r |
3374 | \r |
3375 | bDrawTextured = TRUE;\r |
3376 | bDrawSmoothShaded = FALSE;\r |
3377 | SetRenderState(gpuData[0]);\r |
3378 | \r |
3379 | /* if(iOffscreenDrawing)\r |
3380 | {\r |
3381 | offsetPSX4();\r |
3382 | \r |
3383 | if(bDrawOffscreen4())\r |
3384 | {\r |
3385 | InvalidateTextureAreaEx(); \r |
3386 | SetRenderColor(gpuData[0]);\r |
3387 | lx0-=PSXDisplay.DrawOffset.x;\r |
3388 | ly0-=PSXDisplay.DrawOffset.y;\r |
3389 | if(bUsingTWin) DrawSoftwareSpriteTWin(baseAddr,sprtW,sprtH);\r |
3390 | else\r |
3391 | if(usMirror) DrawSoftwareSpriteMirror(baseAddr,sprtW,sprtH);\r |
3392 | else\r |
3393 | DrawSoftwareSprite(baseAddr,sprtW,sprtH,baseAddr[8],baseAddr[9]);\r |
3394 | }\r |
3395 | }\r |
3396 | */\r |
3397 | SetRenderMode(gpuData[0], TRUE);\r |
3398 | SetZMask4SP();\r |
3399 | \r |
3400 | if((dwActFixes&1) && gTexFrameName && gTexName==gTexFrameName) \r |
3401 | {iSpriteTex=0;return;}\r |
3402 | \r |
3403 | sSprite_ux2=gl_ux[0]+sprtW;\r |
3404 | sSprite_vy2=gl_vy[0]+sprtH;\r |
3405 | \r |
3406 | assignTextureSprite();\r |
3407 | \r |
3408 | if(iFilterType>4) \r |
3409 | DrawMultiFilterSprite();\r |
3410 | else\r |
3411 | PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r |
3412 | \r |
3413 | if(bDrawMultiPass)\r |
3414 | {\r |
3415 | SetSemiTransMulti(1);\r |
3416 | PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r |
3417 | }\r |
3418 | \r |
3419 | if(ubOpaqueDraw)\r |
3420 | {\r |
3421 | SetZMask4O();\r |
3422 | if(bUseMultiPass) SetOpaqueColor(gpuData[0]);\r |
3423 | DEFOPAQUEON\r |
3424 | \r |
3425 | /* if(bSmallAlpha && iFilterType<=2)\r |
3426 | {\r |
3427 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);\r |
3428 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\r |
3429 | PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r |
3430 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);\r |
3431 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\r |
3432 | SetZMask4O();\r |
3433 | }\r |
3434 | */\r |
3435 | PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r |
3436 | DEFOPAQUEOFF\r |
3437 | }\r |
3438 | \r |
3439 | if(sTypeRest) \r |
3440 | {\r |
3441 | if(sTypeRest&1) primSprtSRest(baseAddr,1);\r |
3442 | if(sTypeRest&2) primSprtSRest(baseAddr,2);\r |
3443 | if(sTypeRest==3) primSprtSRest(baseAddr,3);\r |
3444 | }\r |
3445 | \r |
3446 | iSpriteTex=0;\r |
3447 | iDrawnSomething=1;\r |
3448 | }\r |
3449 | \r |
3450 | ////////////////////////////////////////////////////////////////////////\r |
3451 | // cmd: flat shaded Poly4\r |
3452 | ////////////////////////////////////////////////////////////////////////\r |
3453 | \r |
3454 | void primPolyF4(u8 *baseAddr)\r |
3455 | {\r |
3456 | unsigned long *gpuData = ((unsigned long *) baseAddr);\r |
3457 | short *sgpuData = ((short *) baseAddr);\r |
3458 | \r |
3459 | lx0 = sgpuData[2];\r |
3460 | ly0 = sgpuData[3];\r |
3461 | lx1 = sgpuData[4];\r |
3462 | ly1 = sgpuData[5];\r |
3463 | lx2 = sgpuData[6];\r |
3464 | ly2 = sgpuData[7];\r |
3465 | lx3 = sgpuData[8];\r |
3466 | ly3 = sgpuData[9];\r |
3467 | \r |
3468 | if(offset4()) return;\r |
3469 | \r |
3470 | bDrawTextured = FALSE;\r |
3471 | bDrawSmoothShaded = FALSE;\r |
3472 | SetRenderState(gpuData[0]);\r |
3473 | \r |
3474 | /* if(iOffscreenDrawing)\r |
3475 | {\r |
3476 | offsetPSX4();\r |
3477 | if(bDrawOffscreen4())\r |
3478 | {\r |
3479 | InvalidateTextureAreaEx(); \r |
3480 | drawPoly4F(gpuData[0]);\r |
3481 | }\r |
3482 | }\r |
3483 | */\r |
3484 | SetRenderMode(gpuData[0], FALSE);\r |
3485 | SetZMask4NT();\r |
3486 | \r |
3487 | vertex[0].c.lcol=gpuData[0];vertex[0].c.col[3]=ubGloColAlpha;\r |
3488 | SETCOL(vertex[0]); \r |
3489 | \r |
3490 | PRIMdrawTri2(&vertex[0], &vertex[1], &vertex[2],&vertex[3]);\r |
3491 | \r |
3492 | iDrawnSomething=1;\r |
3493 | }\r |
3494 | \r |
3495 | ////////////////////////////////////////////////////////////////////////\r |
3496 | // cmd: smooth shaded Poly4\r |
3497 | ////////////////////////////////////////////////////////////////////////\r |
3498 | \r |
3499 | void primPolyG4(u8 * baseAddr);\r |
3500 | \r |
3501 | BOOL bDrawOffscreenFrontFF9G4(void)\r |
3502 | {\r |
3503 | if(lx0< PSXDisplay.DisplayPosition.x) return FALSE; // must be complete in front\r |
3504 | if(lx0> PSXDisplay.DisplayEnd.x) return FALSE;\r |
3505 | if(ly0< PSXDisplay.DisplayPosition.y) return FALSE;\r |
3506 | if(ly0> PSXDisplay.DisplayEnd.y) return FALSE;\r |
3507 | if(lx1< PSXDisplay.DisplayPosition.x) return FALSE;\r |
3508 | if(lx1> PSXDisplay.DisplayEnd.x) return FALSE;\r |
3509 | if(ly1< PSXDisplay.DisplayPosition.y) return FALSE;\r |
3510 | if(ly1> PSXDisplay.DisplayEnd.y) return FALSE;\r |
3511 | if(lx2< PSXDisplay.DisplayPosition.x) return FALSE;\r |
3512 | if(lx2> PSXDisplay.DisplayEnd.x) return FALSE;\r |
3513 | if(ly2< PSXDisplay.DisplayPosition.y) return FALSE;\r |
3514 | if(ly2> PSXDisplay.DisplayEnd.y) return FALSE;\r |
3515 | if(lx3< PSXDisplay.DisplayPosition.x) return FALSE;\r |
3516 | if(lx3> PSXDisplay.DisplayEnd.x) return FALSE;\r |
3517 | if(ly3< PSXDisplay.DisplayPosition.y) return FALSE;\r |
3518 | if(ly3> PSXDisplay.DisplayEnd.y) return FALSE;\r |
3519 | return TRUE;\r |
3520 | }\r |
3521 | \r |
3522 | BOOL bCheckFF9G4(u8 * baseAddr)\r |
3523 | {\r |
3524 | static u8 pFF9G4Cache[32];\r |
3525 | static int iFF9Fix=0;\r |
3526 | \r |
3527 | if(baseAddr)\r |
3528 | {\r |
3529 | if(iFF9Fix==0)\r |
3530 | {\r |
3531 | if(bDrawOffscreenFrontFF9G4())\r |
3532 | {\r |
3533 | short *sgpuData = ((short *) pFF9G4Cache);\r |
3534 | iFF9Fix=2;\r |
3535 | memcpy(pFF9G4Cache,baseAddr,32);\r |
3536 | \r |
3537 | if(sgpuData[2]==142)\r |
3538 | {\r |
3539 | sgpuData[2] +=65;\r |
3540 | sgpuData[10]+=65;\r |
3541 | }\r |
3542 | return TRUE;\r |
3543 | }\r |
3544 | else iFF9Fix=1;\r |
3545 | }\r |
3546 | return FALSE;\r |
3547 | }\r |
3548 | \r |
3549 | if(iFF9Fix==2)\r |
3550 | {\r |
3551 | long labr=GlobalTextABR;\r |
3552 | GlobalTextABR=1;\r |
3553 | primPolyG4(pFF9G4Cache);\r |
3554 | GlobalTextABR=labr;\r |
3555 | }\r |
3556 | iFF9Fix=0;\r |
3557 | \r |
3558 | return FALSE;\r |
3559 | }\r |
3560 | \r |
3561 | ////////////////////////////////////////////////////////////////////////\r |
3562 | \r |
3563 | void primPolyG4(u8 * baseAddr)\r |
3564 | {\r |
3565 | unsigned long *gpuData = (unsigned long *)baseAddr;\r |
3566 | short *sgpuData = ((short *) baseAddr);\r |
3567 | \r |
3568 | lx0 = sgpuData[2];\r |
3569 | ly0 = sgpuData[3];\r |
3570 | lx1 = sgpuData[6];\r |
3571 | ly1 = sgpuData[7];\r |
3572 | lx2 = sgpuData[10];\r |
3573 | ly2 = sgpuData[11];\r |
3574 | lx3 = sgpuData[14];\r |
3575 | ly3 = sgpuData[15];\r |
3576 | \r |
3577 | if(offset4()) return;\r |
3578 | \r |
3579 | bDrawTextured = FALSE;\r |
3580 | bDrawSmoothShaded = TRUE;\r |
3581 | SetRenderState(gpuData[0]);\r |
3582 | \r |
3583 | /* if(iOffscreenDrawing)\r |
3584 | {\r |
3585 | offsetPSX4();\r |
3586 | \r |
3587 | if((dwActFixes&512) && bCheckFF9G4(baseAddr)) return;\r |
3588 | \r |
3589 | if(bDrawOffscreen4())\r |
3590 | {\r |
3591 | InvalidateTextureAreaEx(); \r |
3592 | drawPoly4G(gpuData[0], gpuData[2], gpuData[4], gpuData[6]);\r |
3593 | } \r |
3594 | }\r |
3595 | */\r |
3596 | SetRenderMode(gpuData[0], FALSE);\r |
3597 | SetZMask4NT();\r |
3598 | \r |
3599 | vertex[0].c.lcol=gpuData[0];\r |
3600 | vertex[1].c.lcol=gpuData[2];\r |
3601 | vertex[2].c.lcol=gpuData[4];\r |
3602 | vertex[3].c.lcol=gpuData[6];\r |
3603 | \r |
3604 | vertex[0].c.col[3]=vertex[1].c.col[3]=vertex[2].c.col[3]=vertex[3].c.col[3]=ubGloAlpha;\r |
3605 | \r |
3606 | \r |
3607 | PRIMdrawGouraudTri2Color(&vertex[0],&vertex[1], &vertex[2], &vertex[3]);\r |
3608 | \r |
3609 | iDrawnSomething=1;\r |
3610 | }\r |
3611 | \r |
3612 | ////////////////////////////////////////////////////////////////////////\r |
3613 | // cmd: flat shaded Texture3\r |
3614 | ////////////////////////////////////////////////////////////////////////\r |
3615 | \r |
3616 | BOOL DoLineCheck(unsigned long * gpuData)\r |
3617 | {\r |
3618 | BOOL bQuad=FALSE;short dx,dy;\r |
3619 | \r |
3620 | if(lx0==lx1)\r |
3621 | {\r |
3622 | dx=lx0-lx2;if(dx<0) dx=-dx;\r |
3623 | \r |
3624 | if(ly1==ly2) \r |
3625 | {\r |
3626 | dy=ly1-ly0;if(dy<0) dy=-dy;\r |
3627 | if(dx<=1)\r |
3628 | {\r |
3629 | vertex[3]=vertex[2];\r |
3630 | vertex[2]=vertex[0];\r |
3631 | vertex[2].x=vertex[3].x;\r |
3632 | }\r |
3633 | else\r |
3634 | if(dy<=1)\r |
3635 | {\r |
3636 | vertex[3]=vertex[2];\r |
3637 | vertex[2].y=vertex[0].y;\r |
3638 | }\r |
3639 | else return FALSE;\r |
3640 | \r |
3641 | bQuad=TRUE;\r |
3642 | }\r |
3643 | else\r |
3644 | if(ly0==ly2) \r |
3645 | {\r |
3646 | dy=ly0-ly1;if(dy<0) dy=-dy;\r |
3647 | if(dx<=1)\r |
3648 | {\r |
3649 | vertex[3]=vertex[1];\r |
3650 | vertex[3].x=vertex[2].x;\r |
3651 | }\r |
3652 | else\r |
3653 | if(dy<=1)\r |
3654 | {\r |
3655 | vertex[3]=vertex[2];\r |
3656 | vertex[3].y=vertex[1].y;\r |
3657 | }\r |
3658 | else return FALSE;\r |
3659 | \r |
3660 | bQuad=TRUE;\r |
3661 | }\r |
3662 | }\r |
3663 | \r |
3664 | if(lx0==lx2)\r |
3665 | {\r |
3666 | dx=lx0-lx1;if(dx<0) dx=-dx;\r |
3667 | \r |
3668 | if(ly2==ly1) \r |
3669 | {\r |
3670 | dy=ly2-ly0;if(dy<0) dy=-dy;\r |
3671 | if(dx<=1)\r |
3672 | {\r |
3673 | vertex[3]=vertex[1];\r |
3674 | vertex[1]=vertex[0];\r |
3675 | vertex[1].x=vertex[3].x;\r |
3676 | }\r |
3677 | else\r |
3678 | if(dy<=1)\r |
3679 | {\r |
3680 | vertex[3]=vertex[1];\r |
3681 | vertex[1].y=vertex[0].y;\r |
3682 | }\r |
3683 | else return FALSE;\r |
3684 | \r |
3685 | bQuad=TRUE;\r |
3686 | }\r |
3687 | else\r |
3688 | if(ly0==ly1)\r |
3689 | {\r |
3690 | dy=ly2-ly0;if(dy<0) dy=-dy;\r |
3691 | if(dx<=1)\r |
3692 | {\r |
3693 | vertex[3]=vertex[2];\r |
3694 | vertex[3].x=vertex[1].x;\r |
3695 | }\r |
3696 | else\r |
3697 | if(dy<=1)\r |
3698 | {\r |
3699 | vertex[3]=vertex[1];\r |
3700 | vertex[3].y=vertex[2].y;\r |
3701 | }\r |
3702 | else return FALSE;\r |
3703 | \r |
3704 | bQuad=TRUE;\r |
3705 | }\r |
3706 | }\r |
3707 | \r |
3708 | if(lx1==lx2)\r |
3709 | {\r |
3710 | dx=lx1-lx0;if(dx<0) dx=-dx;\r |
3711 | \r |
3712 | if(ly1==ly0)\r |
3713 | {\r |
3714 | dy=ly1-ly2;if(dy<0) dy=-dy;\r |
3715 | \r |
3716 | if(dx<=1)\r |
3717 | {\r |
3718 | vertex[3]=vertex[2];\r |
3719 | vertex[2].x=vertex[0].x;\r |
3720 | }\r |
3721 | else\r |
3722 | if(dy<=1)\r |
3723 | {\r |
3724 | vertex[3]=vertex[2];\r |
3725 | vertex[2]=vertex[0];\r |
3726 | vertex[2].y=vertex[3].y;\r |
3727 | }\r |
3728 | else return FALSE;\r |
3729 | \r |
3730 | bQuad=TRUE;\r |
3731 | }\r |
3732 | else\r |
3733 | if(ly2==ly0)\r |
3734 | {\r |
3735 | dy=ly2-ly1;if(dy<0) dy=-dy;\r |
3736 | \r |
3737 | if(dx<=1)\r |
3738 | {\r |
3739 | vertex[3]=vertex[1];\r |
3740 | vertex[1].x=vertex[0].x;\r |
3741 | }\r |
3742 | else\r |
3743 | if(dy<=1)\r |
3744 | {\r |
3745 | vertex[3]=vertex[1];\r |
3746 | vertex[1]=vertex[0];\r |
3747 | vertex[1].y=vertex[3].y;\r |
3748 | }\r |
3749 | else return FALSE;\r |
3750 | \r |
3751 | bQuad=TRUE;\r |
3752 | }\r |
3753 | }\r |
3754 | \r |
3755 | if(!bQuad) return FALSE;\r |
3756 | \r |
3757 | PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[3], &vertex[2]);\r |
3758 | \r |
3759 | if(bDrawMultiPass)\r |
3760 | {\r |
3761 | SetSemiTransMulti(1);\r |
3762 | PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[3], &vertex[2]);\r |
3763 | }\r |
3764 | \r |
3765 | if(ubOpaqueDraw)\r |
3766 | {\r |
3767 | SetZMask4O();\r |
3768 | if(bUseMultiPass) SetOpaqueColor(gpuData[0]);\r |
3769 | DEFOPAQUEON\r |
3770 | PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[3], &vertex[2]);\r |
3771 | DEFOPAQUEOFF\r |
3772 | }\r |
3773 | \r |
3774 | iDrawnSomething=1;\r |
3775 | \r |
3776 | return TRUE;\r |
3777 | }\r |
3778 | \r |
3779 | ////////////////////////////////////////////////////////////////////////\r |
3780 | \r |
3781 | void primPolyFT3(u8 * baseAddr)\r |
3782 | {\r |
3783 | unsigned long *gpuData = ((unsigned long *) baseAddr);\r |
3784 | short *sgpuData = ((short *) baseAddr);\r |
3785 | \r |
3786 | lx0 = sgpuData[2];\r |
3787 | ly0 = sgpuData[3];\r |
3788 | lx1 = sgpuData[6];\r |
3789 | ly1 = sgpuData[7];\r |
3790 | lx2 = sgpuData[10];\r |
3791 | ly2 = sgpuData[11];\r |
3792 | \r |
3793 | if(offset3()) return;\r |
3794 | \r |
3795 | // do texture UV coordinates stuff\r |
3796 | gl_ux[0]=gl_ux[3]=baseAddr[8];//gpuData[2]&0xff;\r |
3797 | gl_vy[0]=gl_vy[3]=baseAddr[9];//(gpuData[2]>>8)&0xff;\r |
3798 | gl_ux[1]=baseAddr[16];//gpuData[4]&0xff;\r |
3799 | gl_vy[1]=baseAddr[17];//(gpuData[4]>>8)&0xff;\r |
3800 | gl_ux[2]=baseAddr[24];//gpuData[6]&0xff;\r |
3801 | gl_vy[2]=baseAddr[25];//(gpuData[6]>>8)&0xff;\r |
3802 | \r |
3803 | UpdateGlobalTP((unsigned short)(gpuData[4]>>16));\r |
3804 | ulClutID=gpuData[2]>>16;\r |
3805 | \r |
3806 | bDrawTextured = TRUE;\r |
3807 | bDrawSmoothShaded = FALSE;\r |
3808 | SetRenderState(gpuData[0]);\r |
3809 | \r |
3810 | /* if(iOffscreenDrawing)\r |
3811 | {\r |
3812 | offsetPSX3();\r |
3813 | if(bDrawOffscreen3())\r |
3814 | {\r |
3815 | InvalidateTextureAreaEx(); \r |
3816 | SetRenderColor(gpuData[0]);\r |
3817 | drawPoly3FT(baseAddr);\r |
3818 | }\r |
3819 | }\r |
3820 | */\r |
3821 | SetRenderMode(gpuData[0], TRUE);\r |
3822 | SetZMask3();\r |
3823 | \r |
3824 | assignTexture3();\r |
3825 | \r |
3826 | if(!(dwActFixes&0x10))\r |
3827 | {\r |
3828 | if(DoLineCheck(gpuData)) return;\r |
3829 | }\r |
3830 | \r |
3831 | PRIMdrawTexturedTri(&vertex[0], &vertex[1], &vertex[2]);\r |
3832 | \r |
3833 | if(bDrawMultiPass)\r |
3834 | {\r |
3835 | SetSemiTransMulti(1);\r |
3836 | PRIMdrawTexturedTri(&vertex[0], &vertex[1], &vertex[2]);\r |
3837 | }\r |
3838 | \r |
3839 | if(ubOpaqueDraw)\r |
3840 | {\r |
3841 | SetZMask3O();\r |
3842 | if(bUseMultiPass) SetOpaqueColor(gpuData[0]);\r |
3843 | DEFOPAQUEON\r |
3844 | PRIMdrawTexturedTri(&vertex[0], &vertex[1], &vertex[2]);\r |
3845 | DEFOPAQUEOFF\r |
3846 | }\r |
3847 | \r |
3848 | iDrawnSomething=1;\r |
3849 | }\r |
3850 | \r |
3851 | ////////////////////////////////////////////////////////////////////////\r |
3852 | // cmd: flat shaded Texture4\r |
3853 | ////////////////////////////////////////////////////////////////////////\r |
3854 | \r |
3855 | #define ST_FAC 255.99f\r |
3856 | \r |
3857 | void RectTexAlign(void)\r |
3858 | {\r |
3859 | int UFlipped = FALSE;\r |
3860 | int VFlipped = FALSE;\r |
3861 | \r |
3862 | if(gTexName==gTexFrameName) return;\r |
3863 | \r |
3864 | if(ly0==ly1)\r |
3865 | {\r |
3866 | if(!((lx1==lx3 && ly3==ly2 && lx2==lx0) ||\r |
3867 | (lx1==lx2 && ly2==ly3 && lx3==lx0)))\r |
3868 | return;\r |
3869 | \r |
3870 | if(ly0<ly2) \r |
3871 | {\r |
3872 | if (vertex[0].tow > vertex[2].tow)\r |
3873 | VFlipped = 1;\r |
3874 | }\r |
3875 | else\r |
3876 | {\r |
3877 | if (vertex[0].tow < vertex[2].tow)\r |
3878 | VFlipped = 2;\r |
3879 | }\r |
3880 | }\r |
3881 | else\r |
3882 | if(ly0==ly2)\r |
3883 | {\r |
3884 | if(!((lx2==lx3 && ly3==ly1 && lx1==lx0) ||\r |
3885 | (lx2==lx1 && ly1==ly3 && lx3==lx0)))\r |
3886 | return;\r |
3887 | \r |
3888 | if(ly0<ly1) \r |
3889 | {\r |
3890 | if (vertex[0].tow > vertex[1].tow)\r |
3891 | VFlipped = 3;\r |
3892 | }\r |
3893 | else\r |
3894 | {\r |
3895 | if (vertex[0].tow < vertex[1].tow)\r |
3896 | VFlipped = 4;\r |
3897 | }\r |
3898 | }\r |
3899 | else\r |
3900 | if(ly0==ly3)\r |
3901 | {\r |
3902 | if(!((lx3==lx2 && ly2==ly1 && lx1==lx0) ||\r |
3903 | (lx3==lx1 && ly1==ly2 && lx2==lx0)))\r |
3904 | return;\r |
3905 | \r |
3906 | if(ly0<ly1) \r |
3907 | {\r |
3908 | if (vertex[0].tow > vertex[1].tow)\r |
3909 | VFlipped = 5;\r |
3910 | }\r |
3911 | else\r |
3912 | {\r |
3913 | if (vertex[0].tow < vertex[1].tow)\r |
3914 | VFlipped = 6;\r |
3915 | }\r |
3916 | }\r |
3917 | else return;\r |
3918 | \r |
3919 | if(lx0==lx1)\r |
3920 | {\r |
3921 | if(lx0<lx2) \r |
3922 | {\r |
3923 | if (vertex[0].sow > vertex[2].sow)\r |
3924 | UFlipped = 1;\r |
3925 | }\r |
3926 | else\r |
3927 | {\r |
3928 | if (vertex[0].sow < vertex[2].sow)\r |
3929 | UFlipped = 2;\r |
3930 | }\r |
3931 | }\r |
3932 | else\r |
3933 | if(lx0==lx2)\r |
3934 | {\r |
3935 | if(lx0<lx1) \r |
3936 | {\r |
3937 | if (vertex[0].sow > vertex[1].sow)\r |
3938 | UFlipped = 3;\r |
3939 | }\r |
3940 | else\r |
3941 | {\r |
3942 | if (vertex[0].sow < vertex[1].sow)\r |
3943 | UFlipped = 4;\r |
3944 | }\r |
3945 | }\r |
3946 | else\r |
3947 | if(lx0==lx3)\r |
3948 | {\r |
3949 | if(lx0<lx1) \r |
3950 | {\r |
3951 | if (vertex[0].sow > vertex[1].sow)\r |
3952 | UFlipped = 5;\r |
3953 | }\r |
3954 | else\r |
3955 | {\r |
3956 | if (vertex[0].sow < vertex[1].sow)\r |
3957 | UFlipped = 6;\r |
3958 | }\r |
3959 | }\r |
3960 | \r |
3961 | if (UFlipped)\r |
3962 | {\r |
3963 | #ifdef OWNSCALE\r |
3964 | if(bUsingTWin)\r |
3965 | {\r |
3966 | switch(UFlipped)\r |
3967 | {\r |
3968 | case 1:\r |
3969 | vertex[2].sow+=0.95f/TWin.UScaleFactor; \r |
3970 | vertex[3].sow+=0.95f/TWin.UScaleFactor;\r |
3971 | break;\r |
3972 | case 2:\r |
3973 | vertex[0].sow+=0.95f/TWin.UScaleFactor; \r |
3974 | vertex[1].sow+=0.95f/TWin.UScaleFactor;\r |
3975 | break;\r |
3976 | case 3:\r |
3977 | vertex[1].sow+=0.95f/TWin.UScaleFactor; \r |
3978 | vertex[3].sow+=0.95f/TWin.UScaleFactor;\r |
3979 | break;\r |
3980 | case 4:\r |
3981 | vertex[0].sow+=0.95f/TWin.UScaleFactor; \r |
3982 | vertex[2].sow+=0.95f/TWin.UScaleFactor;\r |
3983 | break;\r |
3984 | case 5:\r |
3985 | vertex[1].sow+=0.95f/TWin.UScaleFactor; \r |
3986 | vertex[2].sow+=0.95f/TWin.UScaleFactor;\r |
3987 | break;\r |
3988 | case 6:\r |
3989 | vertex[0].sow+=0.95f/TWin.UScaleFactor; \r |
3990 | vertex[3].sow+=0.95f/TWin.UScaleFactor;\r |
3991 | break;\r |
3992 | }\r |
3993 | }\r |
3994 | else\r |
3995 | {\r |
3996 | switch(UFlipped)\r |
3997 | {\r |
3998 | case 1:\r |
3999 | vertex[2].sow+=1.0f/ST_FAC; \r |
4000 | vertex[3].sow+=1.0f/ST_FAC;\r |
4001 | break;\r |
4002 | case 2:\r |
4003 | vertex[0].sow+=1.0f/ST_FAC; \r |
4004 | vertex[1].sow+=1.0f/ST_FAC;\r |
4005 | break;\r |
4006 | case 3:\r |
4007 | vertex[1].sow+=1.0f/ST_FAC; \r |
4008 | vertex[3].sow+=1.0f/ST_FAC;\r |
4009 | break;\r |
4010 | case 4:\r |
4011 | vertex[0].sow+=1.0f/ST_FAC; \r |
4012 | vertex[2].sow+=1.0f/ST_FAC;\r |
4013 | break;\r |
4014 | case 5:\r |
4015 | vertex[1].sow+=1.0f/ST_FAC; \r |
4016 | vertex[2].sow+=1.0f/ST_FAC;\r |
4017 | break;\r |
4018 | case 6:\r |
4019 | vertex[0].sow+=1.0f/ST_FAC; \r |
4020 | vertex[3].sow+=1.0f/ST_FAC;\r |
4021 | break;\r |
4022 | }\r |
4023 | }\r |
4024 | #else\r |
4025 | if(bUsingTWin)\r |
4026 | {\r |
4027 | switch(UFlipped)\r |
4028 | {\r |
4029 | case 1:\r |
4030 | vertex[2].sow+=1.0f/TWin.UScaleFactor; \r |
4031 | vertex[3].sow+=1.0f/TWin.UScaleFactor;\r |
4032 | break;\r |
4033 | case 2:\r |
4034 | vertex[0].sow+=1.0f/TWin.UScaleFactor; \r |
4035 | vertex[1].sow+=1.0f/TWin.UScaleFactor;\r |
4036 | break;\r |
4037 | case 3:\r |
4038 | vertex[1].sow+=1.0f/TWin.UScaleFactor; \r |
4039 | vertex[3].sow+=1.0f/TWin.UScaleFactor;\r |
4040 | break;\r |
4041 | case 4:\r |
4042 | vertex[0].sow+=1.0f/TWin.UScaleFactor; \r |
4043 | vertex[2].sow+=1.0f/TWin.UScaleFactor;\r |
4044 | break;\r |
4045 | case 5:\r |
4046 | vertex[1].sow+=1.0f/TWin.UScaleFactor; \r |
4047 | vertex[2].sow+=1.0f/TWin.UScaleFactor;\r |
4048 | break;\r |
4049 | case 6:\r |
4050 | vertex[0].sow+=1.0f/TWin.UScaleFactor; \r |
4051 | vertex[3].sow+=1.0f/TWin.UScaleFactor;\r |
4052 | break;\r |
4053 | }\r |
4054 | }\r |
4055 | else\r |
4056 | {\r |
4057 | switch(UFlipped)\r |
4058 | {\r |
4059 | case 1:\r |
4060 | vertex[2].sow+=1.0f; \r |
4061 | vertex[3].sow+=1.0f;\r |
4062 | break;\r |
4063 | case 2:\r |
4064 | vertex[0].sow+=1.0f; \r |
4065 | vertex[1].sow+=1.0f;\r |
4066 | break;\r |
4067 | case 3:\r |
4068 | vertex[1].sow+=1.0f; \r |
4069 | vertex[3].sow+=1.0f;\r |
4070 | break;\r |
4071 | case 4:\r |
4072 | vertex[0].sow+=1.0f; \r |
4073 | vertex[2].sow+=1.0f;\r |
4074 | break;\r |
4075 | case 5:\r |
4076 | vertex[1].sow+=1.0f; \r |
4077 | vertex[2].sow+=1.0f;\r |
4078 | break;\r |
4079 | case 6:\r |
4080 | vertex[0].sow+=1.0f; \r |
4081 | vertex[3].sow+=1.0f;\r |
4082 | break;\r |
4083 | }\r |
4084 | }\r |
4085 | #endif\r |
4086 | }\r |
4087 | \r |
4088 | if (VFlipped)\r |
4089 | {\r |
4090 | #ifdef OWNSCALE\r |
4091 | if(bUsingTWin)\r |
4092 | {\r |
4093 | switch(VFlipped)\r |
4094 | {\r |
4095 | case 1:\r |
4096 | vertex[2].tow+=0.95f/TWin.VScaleFactor; \r |
4097 | vertex[3].tow+=0.95f/TWin.VScaleFactor;\r |
4098 | break;\r |
4099 | case 2:\r |
4100 | vertex[0].tow+=0.95f/TWin.VScaleFactor; \r |
4101 | vertex[1].tow+=0.95f/TWin.VScaleFactor;\r |
4102 | break;\r |
4103 | case 3:\r |
4104 | vertex[1].tow+=0.95f/TWin.VScaleFactor; \r |
4105 | vertex[3].tow+=0.95f/TWin.VScaleFactor;\r |
4106 | break;\r |
4107 | case 4:\r |
4108 | vertex[0].tow+=0.95f/TWin.VScaleFactor; \r |
4109 | vertex[2].tow+=0.95f/TWin.VScaleFactor;\r |
4110 | break;\r |
4111 | case 5:\r |
4112 | vertex[1].tow+=0.95f/TWin.VScaleFactor; \r |
4113 | vertex[2].tow+=0.95f/TWin.VScaleFactor;\r |
4114 | break;\r |
4115 | case 6:\r |
4116 | vertex[0].tow+=0.95f/TWin.VScaleFactor; \r |
4117 | vertex[3].tow+=0.95f/TWin.VScaleFactor;\r |
4118 | break;\r |
4119 | }\r |
4120 | }\r |
4121 | else\r |
4122 | {\r |
4123 | switch(VFlipped)\r |
4124 | {\r |
4125 | case 1:\r |
4126 | vertex[2].tow+=1.0f/ST_FAC; \r |
4127 | vertex[3].tow+=1.0f/ST_FAC;\r |
4128 | break;\r |
4129 | case 2:\r |
4130 | vertex[0].tow+=1.0f/ST_FAC; \r |
4131 | vertex[1].tow+=1.0f/ST_FAC;\r |
4132 | break;\r |
4133 | case 3:\r |
4134 | vertex[1].tow+=1.0f/ST_FAC;\r |
4135 | vertex[3].tow+=1.0f/ST_FAC;\r |
4136 | break;\r |
4137 | case 4:\r |
4138 | vertex[0].tow+=1.0f/ST_FAC; \r |
4139 | vertex[2].tow+=1.0f/ST_FAC;\r |
4140 | break;\r |
4141 | case 5:\r |
4142 | vertex[1].tow+=1.0f/ST_FAC;\r |
4143 | vertex[2].tow+=1.0f/ST_FAC;\r |
4144 | break;\r |
4145 | case 6:\r |
4146 | vertex[0].tow+=1.0f/ST_FAC;\r |
4147 | vertex[3].tow+=1.0f/ST_FAC;\r |
4148 | break;\r |
4149 | }\r |
4150 | }\r |
4151 | #else\r |
4152 | if(bUsingTWin)\r |
4153 | {\r |
4154 | switch(VFlipped)\r |
4155 | {\r |
4156 | case 1:\r |
4157 | vertex[2].tow+=1.0f/TWin.VScaleFactor; \r |
4158 | vertex[3].tow+=1.0f/TWin.VScaleFactor;\r |
4159 | break;\r |
4160 | case 2:\r |
4161 | vertex[0].tow+=1.0f/TWin.VScaleFactor; \r |
4162 | vertex[1].tow+=1.0f/TWin.VScaleFactor;\r |
4163 | break;\r |
4164 | case 3:\r |
4165 | vertex[1].tow+=1.0f/TWin.VScaleFactor; \r |
4166 | vertex[3].tow+=1.0f/TWin.VScaleFactor;\r |
4167 | break;\r |
4168 | case 4:\r |
4169 | vertex[0].tow+=1.0f/TWin.VScaleFactor; \r |
4170 | vertex[2].tow+=1.0f/TWin.VScaleFactor;\r |
4171 | break;\r |
4172 | case 5:\r |
4173 | vertex[1].tow+=1.0f/TWin.VScaleFactor; \r |
4174 | vertex[2].tow+=1.0f/TWin.VScaleFactor;\r |
4175 | break;\r |
4176 | case 6:\r |
4177 | vertex[0].tow+=1.0f/TWin.VScaleFactor; \r |
4178 | vertex[3].tow+=1.0f/TWin.VScaleFactor;\r |
4179 | break;\r |
4180 | }\r |
4181 | }\r |
4182 | else\r |
4183 | {\r |
4184 | switch(VFlipped)\r |
4185 | {\r |
4186 | case 1:\r |
4187 | vertex[2].tow+=1.0f; \r |
4188 | vertex[3].tow+=1.0f;\r |
4189 | break;\r |
4190 | case 2:\r |
4191 | vertex[0].tow+=1.0f; \r |
4192 | vertex[1].tow+=1.0f;\r |
4193 | break;\r |
4194 | case 3:\r |
4195 | vertex[1].tow+=1.0f; \r |
4196 | vertex[3].tow+=1.0f;\r |
4197 | break;\r |
4198 | case 4:\r |
4199 | vertex[0].tow+=1.0f; \r |
4200 | vertex[2].tow+=1.0f;\r |
4201 | break;\r |
4202 | case 5:\r |
4203 | vertex[1].tow+=1.0f; \r |
4204 | vertex[2].tow+=1.0f;\r |
4205 | break;\r |
4206 | case 6:\r |
4207 | vertex[0].tow+=1.0f; \r |
4208 | vertex[3].tow+=1.0f;\r |
4209 | break;\r |
4210 | }\r |
4211 | }\r |
4212 | #endif\r |
4213 | }\r |
4214 | \r |
4215 | }\r |
4216 | \r |
4217 | void primPolyFT4(u8 * baseAddr)\r |
4218 | {\r |
4219 | unsigned long *gpuData = ((unsigned long *) baseAddr);\r |
4220 | short *sgpuData = ((short *) baseAddr);\r |
4221 | \r |
4222 | lx0 = sgpuData[2];\r |
4223 | ly0 = sgpuData[3];\r |
4224 | lx1 = sgpuData[6];\r |
4225 | ly1 = sgpuData[7];\r |
4226 | lx2 = sgpuData[10];\r |
4227 | ly2 = sgpuData[11];\r |
4228 | lx3 = sgpuData[14];\r |
4229 | ly3 = sgpuData[15];\r |
4230 | \r |
4231 | if(offset4()) return;\r |
4232 | \r |
4233 | gl_vy[0]=baseAddr[9];//((gpuData[2]>>8)&0xff);\r |
4234 | gl_vy[1]=baseAddr[17];//((gpuData[4]>>8)&0xff);\r |
4235 | gl_vy[2]=baseAddr[25];//((gpuData[6]>>8)&0xff);\r |
4236 | gl_vy[3]=baseAddr[33];//((gpuData[8]>>8)&0xff);\r |
4237 | \r |
4238 | gl_ux[0]=baseAddr[8];//(gpuData[2]&0xff);\r |
4239 | gl_ux[1]=baseAddr[16];//(gpuData[4]&0xff);\r |
4240 | gl_ux[2]=baseAddr[24];//(gpuData[6]&0xff);\r |
4241 | gl_ux[3]=baseAddr[32];//(gpuData[8]&0xff);\r |
4242 | \r |
4243 | UpdateGlobalTP((unsigned short)(gpuData[4]>>16));\r |
4244 | ulClutID=(gpuData[2]>>16);\r |
4245 | \r |
4246 | bDrawTextured = TRUE;\r |
4247 | bDrawSmoothShaded = FALSE;\r |
4248 | SetRenderState(gpuData[0]);\r |
4249 | \r |
4250 | /* if(iOffscreenDrawing)\r |
4251 | {\r |
4252 | offsetPSX4();\r |
4253 | if(bDrawOffscreen4())\r |
4254 | {\r |
4255 | InvalidateTextureAreaEx(); \r |
4256 | SetRenderColor(gpuData[0]);\r |
4257 | drawPoly4FT(baseAddr);\r |
4258 | }\r |
4259 | }\r |
4260 | */\r |
4261 | SetRenderMode(gpuData[0], TRUE);\r |
4262 | \r |
4263 | SetZMask4();\r |
4264 | \r |
4265 | assignTexture4();\r |
4266 | \r |
4267 | RectTexAlign();\r |
4268 | \r |
4269 | PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[3], &vertex[2]);\r |
4270 | \r |
4271 | if(bDrawMultiPass)\r |
4272 | {\r |
4273 | SetSemiTransMulti(1);\r |
4274 | PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[3], &vertex[2]);\r |
4275 | }\r |
4276 | \r |
4277 | if(ubOpaqueDraw)\r |
4278 | {\r |
4279 | SetZMask4O();\r |
4280 | if(bUseMultiPass) SetOpaqueColor(gpuData[0]);\r |
4281 | DEFOPAQUEON\r |
4282 | \r |
4283 | /* if(bSmallAlpha && iFilterType<=2)\r |
4284 | {\r |
4285 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);\r |
4286 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\r |
4287 | PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[3], &vertex[2]);\r |
4288 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);\r |
4289 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\r |
4290 | SetZMask4O();\r |
4291 | }\r |
4292 | */\r |
4293 | \r |
4294 | PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[3], &vertex[2]);\r |
4295 | DEFOPAQUEOFF\r |
4296 | }\r |
4297 | \r |
4298 | iDrawnSomething=1;\r |
4299 | }\r |
4300 | \r |
4301 | ////////////////////////////////////////////////////////////////////////\r |
4302 | // cmd: smooth shaded Texture3\r |
4303 | ////////////////////////////////////////////////////////////////////////\r |
4304 | \r |
4305 | void primPolyGT3(u8 *baseAddr)\r |
4306 | { \r |
4307 | unsigned long *gpuData = ((unsigned long *) baseAddr);\r |
4308 | short *sgpuData = ((short *) baseAddr);\r |
4309 | \r |
4310 | lx0 = sgpuData[2];\r |
4311 | ly0 = sgpuData[3];\r |
4312 | lx1 = sgpuData[8];\r |
4313 | ly1 = sgpuData[9];\r |
4314 | lx2 = sgpuData[14];\r |
4315 | ly2 = sgpuData[15];\r |
4316 | \r |
4317 | if(offset3()) return;\r |
4318 | \r |
4319 | // do texture stuff\r |
4320 | gl_ux[0]=gl_ux[3]=baseAddr[8];//gpuData[2]&0xff;\r |
4321 | gl_vy[0]=gl_vy[3]=baseAddr[9];//(gpuData[2]>>8)&0xff;\r |
4322 | gl_ux[1]=baseAddr[20];//gpuData[5]&0xff;\r |
4323 | gl_vy[1]=baseAddr[21];//(gpuData[5]>>8)&0xff;\r |
4324 | gl_ux[2]=baseAddr[32];//gpuData[8]&0xff;\r |
4325 | gl_vy[2]=baseAddr[33];//(gpuData[8]>>8)&0xff;\r |
4326 | \r |
4327 | UpdateGlobalTP((unsigned short)(gpuData[5]>>16));\r |
4328 | ulClutID=(gpuData[2]>>16);\r |
4329 | \r |
4330 | bDrawTextured = TRUE;\r |
4331 | bDrawSmoothShaded = TRUE;\r |
4332 | SetRenderState(gpuData[0]);\r |
4333 | \r |
4334 | /* if(iOffscreenDrawing)\r |
4335 | {\r |
4336 | offsetPSX3();\r |
4337 | if(bDrawOffscreen3())\r |
4338 | {\r |
4339 | InvalidateTextureAreaEx(); \r |
4340 | drawPoly3GT(baseAddr);\r |
4341 | }\r |
4342 | }\r |
4343 | */\r |
4344 | SetRenderMode(gpuData[0], FALSE);\r |
4345 | SetZMask3();\r |
4346 | \r |
4347 | assignTexture3();\r |
4348 | \r |
4349 | if(bDrawNonShaded)\r |
4350 | {\r |
4351 | //if(!bUseMultiPass) vertex[0].lcol=DoubleBGR2RGB(gpuData[0]); else vertex[0].lcol=gpuData[0];\r |
4352 | // eat this...\r |
4353 | /* if(bGLBlend) vertex[0].c.lcol=0x7f7f7f;\r |
4354 | else */vertex[0].c.lcol=0xffffff;\r |
4355 | vertex[0].c.col[3]=ubGloAlpha;\r |
4356 | SETCOL(vertex[0]); \r |
4357 | \r |
4358 | PRIMdrawTexturedTri(&vertex[0], &vertex[1], &vertex[2]);\r |
4359 | \r |
4360 | if(ubOpaqueDraw)\r |
4361 | {\r |
4362 | SetZMask3O();\r |
4363 | DEFOPAQUEON\r |
4364 | PRIMdrawTexturedTri(&vertex[0], &vertex[1], &vertex[2]);\r |
4365 | DEFOPAQUEOFF\r |
4366 | }\r |
4367 | return; \r |
4368 | }\r |
4369 | \r |
4370 | /* if(!bUseMultiPass && !bGLBlend)\r |
4371 | {\r |
4372 | */ vertex[0].c.lcol=DoubleBGR2RGB(gpuData[0]); \r |
4373 | vertex[1].c.lcol=DoubleBGR2RGB(gpuData[3]); \r |
4374 | vertex[2].c.lcol=DoubleBGR2RGB(gpuData[6]);\r |
4375 | /*}\r |
4376 | else\r |
4377 | {\r |
4378 | vertex[0].c.lcol=gpuData[0];\r |
4379 | vertex[1].c.lcol=gpuData[3];\r |
4380 | vertex[2].c.lcol=gpuData[6];\r |
4381 | }*/\r |
4382 | vertex[0].c.col[3]=vertex[1].c.col[3]=vertex[2].c.col[3]=ubGloAlpha;\r |
4383 | \r |
4384 | PRIMdrawTexGouraudTriColor(&vertex[0], &vertex[1], &vertex[2]);\r |
4385 | \r |
4386 | if(bDrawMultiPass)\r |
4387 | {\r |
4388 | SetSemiTransMulti(1);\r |
4389 | PRIMdrawTexGouraudTriColor(&vertex[0], &vertex[1], &vertex[2]);\r |
4390 | }\r |
4391 | \r |
4392 | if(ubOpaqueDraw)\r |
4393 | {\r |
4394 | SetZMask3O();\r |
4395 | if(bUseMultiPass) \r |
4396 | {\r |
4397 | vertex[0].c.lcol=DoubleBGR2RGB(gpuData[0]);\r |
4398 | vertex[1].c.lcol=DoubleBGR2RGB(gpuData[3]);\r |
4399 | vertex[2].c.lcol=DoubleBGR2RGB(gpuData[6]);\r |
4400 | vertex[0].c.col[3]=vertex[1].c.col[3]=vertex[2].c.col[3]=ubGloAlpha;\r |
4401 | }\r |
4402 | DEFOPAQUEON\r |
4403 | PRIMdrawTexGouraudTriColor(&vertex[0], &vertex[1], &vertex[2]);\r |
4404 | DEFOPAQUEOFF\r |
4405 | }\r |
4406 | \r |
4407 | iDrawnSomething=1;\r |
4408 | }\r |
4409 | \r |
4410 | ////////////////////////////////////////////////////////////////////////\r |
4411 | // cmd: smooth shaded Poly3\r |
4412 | ////////////////////////////////////////////////////////////////////////\r |
4413 | \r |
4414 | void primPolyG3(u8 *baseAddr)\r |
4415 | { \r |
4416 | unsigned long *gpuData = ((unsigned long *) baseAddr);\r |
4417 | short *sgpuData = ((short *) baseAddr);\r |
4418 | \r |
4419 | lx0 = sgpuData[2];\r |
4420 | ly0 = sgpuData[3];\r |
4421 | lx1 = sgpuData[6];\r |
4422 | ly1 = sgpuData[7];\r |
4423 | lx2 = sgpuData[10];\r |
4424 | ly2 = sgpuData[11];\r |
4425 | \r |
4426 | if(offset3()) return;\r |
4427 | \r |
4428 | bDrawTextured = FALSE;\r |
4429 | bDrawSmoothShaded = TRUE;\r |
4430 | SetRenderState(gpuData[0]);\r |
4431 | \r |
4432 | /* if(iOffscreenDrawing) \r |
4433 | {\r |
4434 | offsetPSX3();\r |
4435 | if(bDrawOffscreen3())\r |
4436 | {\r |
4437 | InvalidateTextureAreaEx(); \r |
4438 | drawPoly3G(gpuData[0], gpuData[2], gpuData[4]);\r |
4439 | }\r |
4440 | }\r |
4441 | */\r |
4442 | SetRenderMode(gpuData[0], FALSE);\r |
4443 | SetZMask3NT();\r |
4444 | \r |
4445 | vertex[0].c.lcol=gpuData[0];\r |
4446 | vertex[1].c.lcol=gpuData[2];\r |
4447 | vertex[2].c.lcol=gpuData[4];\r |
4448 | vertex[0].c.col[3]=vertex[1].c.col[3]=vertex[2].c.col[3]=ubGloColAlpha; \r |
4449 | \r |
4450 | PRIMdrawGouraudTriColor(&vertex[0], &vertex[1], &vertex[2]);\r |
4451 | \r |
4452 | iDrawnSomething=1;\r |
4453 | }\r |
4454 | \r |
4455 | ////////////////////////////////////////////////////////////////////////\r |
4456 | // cmd: smooth shaded Texture4\r |
4457 | ////////////////////////////////////////////////////////////////////////\r |
4458 | \r |
4459 | void primPolyGT4(u8 *baseAddr)\r |
4460 | { \r |
4461 | unsigned long *gpuData = ((unsigned long *) baseAddr);\r |
4462 | short *sgpuData = ((short *) baseAddr);\r |
4463 | \r |
4464 | lx0 = sgpuData[2];\r |
4465 | ly0 = sgpuData[3];\r |
4466 | lx1 = sgpuData[8];\r |
4467 | ly1 = sgpuData[9];\r |
4468 | lx2 = sgpuData[14];\r |
4469 | ly2 = sgpuData[15];\r |
4470 | lx3 = sgpuData[20];\r |
4471 | ly3 = sgpuData[21];\r |
4472 | \r |
4473 | if(offset4()) return;\r |
4474 | \r |
4475 | // do texture stuff\r |
4476 | gl_ux[0]=baseAddr[8];//gpuData[2]&0xff;\r |
4477 | gl_vy[0]=baseAddr[9];//(gpuData[2]>>8)&0xff;\r |
4478 | gl_ux[1]=baseAddr[20];//gpuData[5]&0xff;\r |
4479 | gl_vy[1]=baseAddr[21];//(gpuData[5]>>8)&0xff;\r |
4480 | gl_ux[2]=baseAddr[32];//gpuData[8]&0xff;\r |
4481 | gl_vy[2]=baseAddr[33];//(gpuData[8]>>8)&0xff;\r |
4482 | gl_ux[3]=baseAddr[44];//gpuData[11]&0xff;\r |
4483 | gl_vy[3]=baseAddr[45];//(gpuData[11]>>8)&0xff;\r |
4484 | \r |
4485 | UpdateGlobalTP((unsigned short)(gpuData[5]>>16));\r |
4486 | ulClutID=(gpuData[2]>>16);\r |
4487 | \r |
4488 | bDrawTextured = TRUE;\r |
4489 | bDrawSmoothShaded = TRUE;\r |
4490 | SetRenderState(gpuData[0]);\r |
4491 | \r |
4492 | /* if(iOffscreenDrawing)\r |
4493 | {\r |
4494 | offsetPSX4();\r |
4495 | if(bDrawOffscreen4())\r |
4496 | {\r |
4497 | InvalidateTextureAreaEx(); \r |
4498 | drawPoly4GT(baseAddr);\r |
4499 | } \r |
4500 | }\r |
4501 | */\r |
4502 | SetRenderMode(gpuData[0], FALSE);\r |
4503 | SetZMask4();\r |
4504 | \r |
4505 | assignTexture4();\r |
4506 | \r |
4507 | RectTexAlign();\r |
4508 | \r |
4509 | if(bDrawNonShaded)\r |
4510 | {\r |
4511 | //if(!bUseMultiPass) vertex[0].lcol=DoubleBGR2RGB(gpuData[0]); else vertex[0].lcol=gpuData[0];\r |
4512 | /* if(bGLBlend) vertex[0].c.lcol=0x7f7f7f;\r |
4513 | else */vertex[0].c.lcol=0xffffff;\r |
4514 | vertex[0].c.col[3]=ubGloAlpha;\r |
4515 | SETCOL(vertex[0]); \r |
4516 | \r |
4517 | PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[3], &vertex[2]);\r |
4518 | \r |
4519 | if(ubOpaqueDraw)\r |
4520 | {\r |
4521 | SetZMask4O();\r |
4522 | ubGloAlpha=ubGloColAlpha=0xff; \r |
4523 | DEFOPAQUEON\r |
4524 | PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[3], &vertex[2]);\r |
4525 | DEFOPAQUEOFF\r |
4526 | }\r |
4527 | return;\r |
4528 | }\r |
4529 | \r |
4530 | // if(!bUseMultiPass && !bGLBlend) \r |
4531 | {\r |
4532 | vertex[0].c.lcol=DoubleBGR2RGB(gpuData[0]);\r |
4533 | vertex[1].c.lcol=DoubleBGR2RGB(gpuData[3]);\r |
4534 | vertex[2].c.lcol=DoubleBGR2RGB(gpuData[6]);\r |
4535 | vertex[3].c.lcol=DoubleBGR2RGB(gpuData[9]);\r |
4536 | }\r |
4537 | /*else\r |
4538 | {\r |
4539 | vertex[0].c.lcol=gpuData[0];\r |
4540 | vertex[1].c.lcol=gpuData[3];\r |
4541 | vertex[2].c.lcol=gpuData[6];\r |
4542 | vertex[3].c.lcol=gpuData[9];\r |
4543 | }*/\r |
4544 | \r |
4545 | vertex[0].c.col[3]=vertex[1].c.col[3]=vertex[2].c.col[3]=vertex[3].c.col[3]=ubGloAlpha; \r |
4546 | \r |
4547 | PRIMdrawTexGouraudTriColorQuad(&vertex[0], &vertex[1], &vertex[3],&vertex[2]);\r |
4548 | \r |
4549 | if(bDrawMultiPass)\r |
4550 | {\r |
4551 | SetSemiTransMulti(1);\r |
4552 | PRIMdrawTexGouraudTriColorQuad(&vertex[0], &vertex[1], &vertex[3],&vertex[2]);\r |
4553 | }\r |
4554 | \r |
4555 | if(ubOpaqueDraw)\r |
4556 | {\r |
4557 | SetZMask4O();\r |
4558 | if(bUseMultiPass) \r |
4559 | {\r |
4560 | vertex[0].c.lcol=DoubleBGR2RGB(gpuData[0]);\r |
4561 | vertex[1].c.lcol=DoubleBGR2RGB(gpuData[3]);\r |
4562 | vertex[2].c.lcol=DoubleBGR2RGB(gpuData[6]);\r |
4563 | vertex[3].c.lcol=DoubleBGR2RGB(gpuData[9]);\r |
4564 | vertex[0].c.col[3]=vertex[1].c.col[3]=vertex[2].c.col[3]=vertex[3].c.col[3]=ubGloAlpha; \r |
4565 | }\r |
4566 | ubGloAlpha=ubGloColAlpha=0xff; \r |
4567 | DEFOPAQUEON\r |
4568 | PRIMdrawTexGouraudTriColorQuad(&vertex[0], &vertex[1], &vertex[3],&vertex[2]);\r |
4569 | DEFOPAQUEOFF\r |
4570 | }\r |
4571 | \r |
4572 | iDrawnSomething=1;\r |
4573 | }\r |
4574 | \r |
4575 | ////////////////////////////////////////////////////////////////////////\r |
4576 | // cmd: smooth shaded Poly3\r |
4577 | ////////////////////////////////////////////////////////////////////////\r |
4578 | \r |
4579 | void primPolyF3(u8 *baseAddr)\r |
4580 | { \r |
4581 | unsigned long *gpuData = ((unsigned long *) baseAddr);\r |
4582 | short *sgpuData = ((short *) baseAddr);\r |
4583 | \r |
4584 | lx0 = sgpuData[2];\r |
4585 | ly0 = sgpuData[3];\r |
4586 | lx1 = sgpuData[4];\r |
4587 | ly1 = sgpuData[5];\r |
4588 | lx2 = sgpuData[6];\r |
4589 | ly2 = sgpuData[7];\r |
4590 | \r |
4591 | if(offset3()) return;\r |
4592 | \r |
4593 | bDrawTextured = FALSE;\r |
4594 | bDrawSmoothShaded = FALSE;\r |
4595 | SetRenderState(gpuData[0]);\r |
4596 | \r |
4597 | /* if(iOffscreenDrawing)\r |
4598 | {\r |
4599 | offsetPSX3();\r |
4600 | if(bDrawOffscreen3())\r |
4601 | {\r |
4602 | InvalidateTextureAreaEx(); \r |
4603 | drawPoly3F(gpuData[0]);\r |
4604 | }\r |
4605 | }\r |
4606 | */\r |
4607 | SetRenderMode(gpuData[0], FALSE);\r |
4608 | SetZMask3NT();\r |
4609 | \r |
4610 | vertex[0].c.lcol=gpuData[0];\r |
4611 | vertex[0].c.col[3]=ubGloColAlpha;\r |
4612 | SETCOL(vertex[0]); \r |
4613 | \r |
4614 | PRIMdrawTri(&vertex[0], &vertex[1], &vertex[2]);\r |
4615 | \r |
4616 | iDrawnSomething=1;\r |
4617 | }\r |
4618 | \r |
4619 | ////////////////////////////////////////////////////////////////////////\r |
4620 | // cmd: skipping shaded polylines\r |
4621 | ////////////////////////////////////////////////////////////////////////\r |
4622 | \r |
4623 | void primLineGSkip(u8 *baseAddr)\r |
4624 | { \r |
4625 | unsigned long *gpuData = ((unsigned long *) baseAddr);\r |
4626 | short *sgpuData = ((short *) baseAddr);\r |
4627 | int iMax=255;\r |
4628 | int i=2;\r |
4629 | \r |
4630 | lx1 = sgpuData[2];\r |
4631 | ly1 = sgpuData[3];\r |
4632 | \r |
4633 | while(!(((gpuData[i] & 0xF000F000) == 0x50005000) && i>=4))\r |
4634 | {\r |
4635 | i++;\r |
4636 | \r |
4637 | ly1 = (short)((gpuData[i]>>16) & 0xffff);\r |
4638 | lx1 = (short)(gpuData[i] & 0xffff);\r |
4639 | \r |
4640 | i++;if(i>iMax) break;\r |
4641 | }\r |
4642 | }\r |
4643 | \r |
4644 | ////////////////////////////////////////////////////////////////////////\r |
4645 | // cmd: shaded polylines\r |
4646 | ////////////////////////////////////////////////////////////////////////\r |
4647 | \r |
4648 | void primLineGEx(u8 *baseAddr)\r |
4649 | { \r |
4650 | unsigned long *gpuData = ((unsigned long *) baseAddr);\r |
4651 | int iMax=255;\r |
4652 | short cx0,cx1,cy0,cy1;int i;BOOL bDraw=TRUE;\r |
4653 | \r |
4654 | bDrawTextured = FALSE;\r |
4655 | bDrawSmoothShaded = TRUE;\r |
4656 | SetRenderState(gpuData[0]);\r |
4657 | SetRenderMode(gpuData[0], FALSE);\r |
4658 | SetZMask4NT();\r |
4659 | \r |
4660 | vertex[0].c.lcol=vertex[3].c.lcol=gpuData[0];\r |
4661 | vertex[0].c.col[3]=vertex[3].c.col[3]=ubGloColAlpha; \r |
4662 | ly1 = (short)((gpuData[1]>>16) & 0xffff);\r |
4663 | lx1 = (short)(gpuData[1] & 0xffff);\r |
4664 | \r |
4665 | i=2;\r |
4666 | \r |
4667 | //while((gpuData[i]>>24)!=0x55)\r |
4668 | //while((gpuData[i]&0x50000000)!=0x50000000) \r |
4669 | // currently best way to check for poly line end:\r |
4670 | while(!(((gpuData[i] & 0xF000F000) == 0x50005000) && i>=4))\r |
4671 | {\r |
4672 | ly0 = ly1;lx0=lx1;\r |
4673 | vertex[1].c.lcol=vertex[2].c.lcol=vertex[0].c.lcol;\r |
4674 | vertex[0].c.lcol=vertex[3].c.lcol=gpuData[i];\r |
4675 | vertex[0].c.col[3]=vertex[3].c.col[3]=ubGloColAlpha; \r |
4676 | \r |
4677 | i++;\r |
4678 | \r |
4679 | ly1 = (short)((gpuData[i]>>16) & 0xffff);\r |
4680 | lx1 = (short)(gpuData[i] & 0xffff);\r |
4681 | \r |
4682 | if(offsetline()) bDraw=FALSE; else bDraw=TRUE;\r |
4683 | \r |
4684 | if (bDraw && ((lx0 != lx1) || (ly0 != ly1)))\r |
4685 | {\r |
4686 | /* if(iOffscreenDrawing)\r |
4687 | {\r |
4688 | cx0=lx0;cx1=lx1;cy0=ly0;cy1=ly1;\r |
4689 | offsetPSXLine();\r |
4690 | if(bDrawOffscreen4())\r |
4691 | {\r |
4692 | InvalidateTextureAreaEx(); \r |
4693 | drawPoly4G(gpuData[i-3],gpuData[i-1],gpuData[i-3],gpuData[i-1]);\r |
4694 | }\r |
4695 | lx0=cx0;lx1=cx1;ly0=cy0;ly1=cy1;\r |
4696 | }*/\r |
4697 | \r |
4698 | PRIMdrawGouraudLine(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r |
4699 | }\r |
4700 | i++; \r |
4701 | \r |
4702 | if(i>iMax) break;\r |
4703 | }\r |
4704 | \r |
4705 | iDrawnSomething=1;\r |
4706 | }\r |
4707 | \r |
4708 | ////////////////////////////////////////////////////////////////////////\r |
4709 | // cmd: shaded polyline2\r |
4710 | ////////////////////////////////////////////////////////////////////////\r |
4711 | \r |
4712 | void primLineG2(u8 *baseAddr)\r |
4713 | { \r |
4714 | unsigned long *gpuData = ((unsigned long *) baseAddr);\r |
4715 | short *sgpuData = ((short *) baseAddr);\r |
4716 | \r |
4717 | lx0 = sgpuData[2];\r |
4718 | ly0 = sgpuData[3];\r |
4719 | lx1 = sgpuData[6];\r |
4720 | ly1 = sgpuData[7];\r |
4721 | \r |
4722 | vertex[0].c.lcol=vertex[3].c.lcol=gpuData[0];\r |
4723 | vertex[1].c.lcol=vertex[2].c.lcol=gpuData[2];\r |
4724 | vertex[0].c.col[3]=vertex[1].c.col[3]=vertex[2].c.col[3]=vertex[3].c.col[3]=ubGloColAlpha; \r |
4725 | \r |
4726 | bDrawTextured = FALSE;\r |
4727 | bDrawSmoothShaded = TRUE;\r |
4728 | \r |
4729 | if((lx0 == lx1) && (ly0 == ly1)) return;\r |
4730 | \r |
4731 | if(offsetline()) return;\r |
4732 | \r |
4733 | SetRenderState(gpuData[0]);\r |
4734 | SetRenderMode(gpuData[0], FALSE);\r |
4735 | SetZMask4NT();\r |
4736 | \r |
4737 | /* if(iOffscreenDrawing)\r |
4738 | {\r |
4739 | offsetPSXLine();\r |
4740 | if(bDrawOffscreen4())\r |
4741 | {\r |
4742 | InvalidateTextureAreaEx(); \r |
4743 | drawPoly4G(gpuData[0],gpuData[2],gpuData[0],gpuData[2]);\r |
4744 | }\r |
4745 | }\r |
4746 | */\r |
4747 | //if(ClipVertexList4())\r |
4748 | PRIMdrawGouraudLine(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r |
4749 | \r |
4750 | iDrawnSomething=1;\r |
4751 | }\r |
4752 | \r |
4753 | ////////////////////////////////////////////////////////////////////////\r |
4754 | // cmd: skipping flat polylines\r |
4755 | ////////////////////////////////////////////////////////////////////////\r |
4756 | \r |
4757 | void primLineFSkip(u8 *baseAddr)\r |
4758 | {\r |
4759 | unsigned long *gpuData = ((unsigned long *) baseAddr);\r |
4760 | int i=2,iMax=255;\r |
4761 | \r |
4762 | ly1 = (short)((gpuData[1]>>16) & 0xffff);\r |
4763 | lx1 = (short)(gpuData[1] & 0xffff);\r |
4764 | \r |
4765 | while(!(((gpuData[i] & 0xF000F000) == 0x50005000) && i>=3))\r |
4766 | {\r |
4767 | ly1 = (short)((gpuData[i]>>16) & 0xffff);\r |
4768 | lx1 = (short)(gpuData[i] & 0xffff);\r |
4769 | i++;if(i>iMax) break;\r |
4770 | } \r |
4771 | }\r |
4772 | \r |
4773 | ////////////////////////////////////////////////////////////////////////\r |
4774 | // cmd: drawing flat polylines\r |
4775 | ////////////////////////////////////////////////////////////////////////\r |
4776 | \r |
4777 | void primLineFEx(u8 *baseAddr)\r |
4778 | {\r |
4779 | unsigned long *gpuData = ((unsigned long *) baseAddr);\r |
4780 | int iMax;\r |
4781 | short cx0,cx1,cy0,cy1;int i;\r |
4782 | \r |
4783 | iMax=255;\r |
4784 | \r |
4785 | bDrawTextured = FALSE;\r |
4786 | bDrawSmoothShaded = FALSE;\r |
4787 | SetRenderState(gpuData[0]);\r |
4788 | SetRenderMode(gpuData[0], FALSE);\r |
4789 | SetZMask4NT();\r |
4790 | \r |
4791 | vertex[0].c.lcol=gpuData[0];\r |
4792 | vertex[0].c.col[3]=ubGloColAlpha; \r |
4793 | \r |
4794 | ly1 = (short)((gpuData[1]>>16) & 0xffff);\r |
4795 | lx1 = (short)(gpuData[1] & 0xffff);\r |
4796 | \r |
4797 | i=2;\r |
4798 | \r |
4799 | // while(!(gpuData[i]&0x40000000)) \r |
4800 | // while((gpuData[i]>>24)!=0x55)\r |
4801 | // while((gpuData[i]&0x50000000)!=0x50000000) \r |
4802 | // currently best way to check for poly line end:\r |
4803 | while(!(((gpuData[i] & 0xF000F000) == 0x50005000) && i>=3))\r |
4804 | {\r |
4805 | ly0 = ly1;lx0=lx1;\r |
4806 | ly1 = (short)((gpuData[i]>>16) & 0xffff);\r |
4807 | lx1 = (short)(gpuData[i] & 0xffff);\r |
4808 | \r |
4809 | if(!offsetline())\r |
4810 | {\r |
4811 | /* if(iOffscreenDrawing)\r |
4812 | {\r |
4813 | cx0=lx0;cx1=lx1;cy0=ly0;cy1=ly1;\r |
4814 | offsetPSXLine();\r |
4815 | if(bDrawOffscreen4())\r |
4816 | {\r |
4817 | InvalidateTextureAreaEx(); \r |
4818 | drawPoly4F(gpuData[0]);\r |
4819 | }\r |
4820 | lx0=cx0;lx1=cx1;ly0=cy0;ly1=cy1;\r |
4821 | }*/\r |
4822 | PRIMdrawFlatLine(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r |
4823 | }\r |
4824 | \r |
4825 | i++;if(i>iMax) break;\r |
4826 | }\r |
4827 | \r |
4828 | iDrawnSomething=1;\r |
4829 | }\r |
4830 | \r |
4831 | ////////////////////////////////////////////////////////////////////////\r |
4832 | // cmd: drawing flat polyline2\r |
4833 | ////////////////////////////////////////////////////////////////////////\r |
4834 | \r |
4835 | void primLineF2(u8 *baseAddr)\r |
4836 | {\r |
4837 | unsigned long *gpuData = ((unsigned long *) baseAddr);\r |
4838 | short *sgpuData = ((short *) baseAddr);\r |
4839 | \r |
4840 | lx0 = sgpuData[2];\r |
4841 | ly0 = sgpuData[3];\r |
4842 | lx1 = sgpuData[4];\r |
4843 | ly1 = sgpuData[5];\r |
4844 | \r |
4845 | if(offsetline()) return;\r |
4846 | \r |
4847 | bDrawTextured = FALSE;\r |
4848 | bDrawSmoothShaded = FALSE;\r |
4849 | SetRenderState(gpuData[0]);\r |
4850 | SetRenderMode(gpuData[0], FALSE);\r |
4851 | SetZMask4NT();\r |
4852 | \r |
4853 | vertex[0].c.lcol=gpuData[0];\r |
4854 | vertex[0].c.col[3]=ubGloColAlpha; \r |
4855 | \r |
4856 | /* if(iOffscreenDrawing)\r |
4857 | {\r |
4858 | offsetPSXLine();\r |
4859 | if(bDrawOffscreen4())\r |
4860 | {\r |
4861 | InvalidateTextureAreaEx(); \r |
4862 | drawPoly4F(gpuData[0]);\r |
4863 | }\r |
4864 | }\r |
4865 | */\r |
4866 | //if(ClipVertexList4()) \r |
4867 | PRIMdrawFlatLine(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);\r |
4868 | \r |
4869 | iDrawnSomething=1;\r |
4870 | }\r |
4871 | \r |
4872 | ////////////////////////////////////////////////////////////////////////\r |
4873 | // cmd: well, easiest command... not implemented\r |
4874 | ////////////////////////////////////////////////////////////////////////\r |
4875 | \r |
4876 | void primNI(u8 *bA)\r |
4877 | {\r |
4878 | }\r |
4879 | \r |
4880 | ////////////////////////////////////////////////////////////////////////\r |
4881 | // cmd func ptr table\r |
4882 | ////////////////////////////////////////////////////////////////////////\r |
4883 | \r |
4884 | void (*primTableJ[256])(u8 *) = \r |
4885 | {\r |
4886 | // 00\r |
4887 | primNI,primNI,primBlkFill,primNI,primNI,primNI,primNI,primNI,\r |
4888 | // 08\r |
4889 | primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r |
4890 | // 10\r |
4891 | primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r |
4892 | // 18\r |
4893 | primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r |
4894 | // 20\r |
4895 | primPolyF3,primPolyF3,primPolyF3,primPolyF3,primPolyFT3,primPolyFT3,primPolyFT3,primPolyFT3,\r |
4896 | // 28\r |
4897 | primPolyF4,primPolyF4,primPolyF4,primPolyF4,primPolyFT4,primPolyFT4,primPolyFT4,primPolyFT4,\r |
4898 | // 30\r |
4899 | primPolyG3,primPolyG3,primPolyG3,primPolyG3,primPolyGT3,primPolyGT3,primPolyGT3,primPolyGT3,\r |
4900 | // 38\r |
4901 | primPolyG4,primPolyG4,primPolyG4,primPolyG4,primPolyGT4,primPolyGT4,primPolyGT4,primPolyGT4,\r |
4902 | // 40\r |
4903 | primLineF2,primLineF2,primLineF2,primLineF2,primNI,primNI,primNI,primNI,\r |
4904 | // 48\r |
4905 | primLineFEx,primLineFEx,primLineFEx,primLineFEx,primLineFEx,primLineFEx,primLineFEx,primLineFEx,\r |
4906 | // 50\r |
4907 | primLineG2,primLineG2,primLineG2,primLineG2,primNI,primNI,primNI,primNI,\r |
4908 | // 58\r |
4909 | primLineGEx,primLineGEx,primLineGEx,primLineGEx,primLineGEx,primLineGEx,primLineGEx,primLineGEx,\r |
4910 | // 60\r |
4911 | primTileS,primTileS,primTileS,primTileS,primSprtS,primSprtS,primSprtS,primSprtS,\r |
4912 | // 68\r |
4913 | primTile1,primTile1,primTile1,primTile1,primNI,primNI,primNI,primNI,\r |
4914 | // 70\r |
4915 | primTile8,primTile8,primTile8,primTile8,primSprt8,primSprt8,primSprt8,primSprt8,\r |
4916 | // 78\r |
4917 | primTile16,primTile16,primTile16,primTile16,primSprt16,primSprt16,primSprt16,primSprt16,\r |
4918 | // 80\r |
4919 | primMoveImage,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r |
4920 | // 88\r |
4921 | primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r |
4922 | // 90\r |
4923 | primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r |
4924 | // 98\r |
4925 | primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r |
4926 | // a0\r |
4927 | primLoadImage,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r |
4928 | // a8\r |
4929 | primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r |
4930 | // b0\r |
4931 | primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r |
4932 | // b8\r |
4933 | primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r |
4934 | // c0\r |
4935 | primStoreImage,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r |
4936 | // c8\r |
4937 | primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r |
4938 | // d0\r |
4939 | primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r |
4940 | // d8\r |
4941 | primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r |
4942 | // e0\r |
4943 | primNI,cmdTexturePage,cmdTextureWindow,cmdDrawAreaStart,cmdDrawAreaEnd,cmdDrawOffset,cmdSTP,primNI,\r |
4944 | // e8\r |
4945 | primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r |
4946 | // f0\r |
4947 | primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r |
4948 | // f8\r |
4949 | primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI\r |
4950 | };\r |
4951 | \r |
4952 | ////////////////////////////////////////////////////////////////////////\r |
4953 | // cmd func ptr table for skipping\r |
4954 | ////////////////////////////////////////////////////////////////////////\r |
4955 | \r |
4956 | void (*primTableSkip[256])(u8 *) = \r |
4957 | {\r |
4958 | // 00\r |
4959 | primNI,primNI,primBlkFill,primNI,primNI,primNI,primNI,primNI,\r |
4960 | // 08\r |
4961 | primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r |
4962 | // 10\r |
4963 | primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r |
4964 | // 18\r |
4965 | primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r |
4966 | // 20\r |
4967 | primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r |
4968 | // 28\r |
4969 | primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r |
4970 | // 30\r |
4971 | primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r |
4972 | // 38\r |
4973 | primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r |
4974 | // 40\r |
4975 | primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r |
4976 | // 48\r |
4977 | primLineFSkip,primLineFSkip,primLineFSkip,primLineFSkip,primLineFSkip,primLineFSkip,primLineFSkip,primLineFSkip,\r |
4978 | // 50\r |
4979 | primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r |
4980 | // 58\r |
4981 | primLineGSkip,primLineGSkip,primLineGSkip,primLineGSkip,primLineGSkip,primLineGSkip,primLineGSkip,primLineGSkip,\r |
4982 | // 60\r |
4983 | primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r |
4984 | // 68\r |
4985 | primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r |
4986 | // 70\r |
4987 | primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r |
4988 | // 78\r |
4989 | primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r |
4990 | // 80\r |
4991 | primMoveImage,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r |
4992 | // 88\r |
4993 | primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r |
4994 | // 90\r |
4995 | primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r |
4996 | // 98\r |
4997 | primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r |
4998 | // a0\r |
4999 | primLoadImage,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r |
5000 | // a8\r |
5001 | primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r |
5002 | // b0\r |
5003 | primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r |
5004 | // b8\r |
5005 | primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r |
5006 | // c0\r |
5007 | primStoreImage,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r |
5008 | // c8\r |
5009 | primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r |
5010 | // d0\r |
5011 | primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r |
5012 | // d8\r |
5013 | primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r |
5014 | // e0\r |
5015 | primNI,cmdTexturePage,cmdTextureWindow,cmdDrawAreaStart,cmdDrawAreaEnd,cmdDrawOffset,cmdSTP,primNI,\r |
5016 | // e8\r |
5017 | primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r |
5018 | // f0\r |
5019 | primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,\r |
5020 | // f8\r |
5021 | primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI\r |
5022 | };\r |