1 /***************************************************************************
\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
9 /***************************************************************************
\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
17 ***************************************************************************/
\r
19 //*************************************************************************//
\r
20 // History of changes:
\r
22 // 2009/03/08 - Pete
\r
23 // - generic cleanup for the Peops release
\r
25 //*************************************************************************//
\r
27 #define _IN_PRIMDRAW
\r
29 #include "gpuStdafx.h"
\r
30 #include "gpuExternals.h"
\r
31 #include "gpuPlugin.h"
\r
32 #include "gpuDraw.h"
\r
33 #include "gpuTexture.h"
\r
34 #include "gpuPrim.h"
\r
36 ////////////////////////////////////////////////////////////////////////
\r
38 ////////////////////////////////////////////////////////////////////////
\r
40 #define DEFOPAQUEON glAlphaFunc(GL_EQUAL,0.0f);bBlendEnable=FALSE;glDisable(GL_BLEND);
\r
41 #define DEFOPAQUEOFF glAlphaFunc(GL_GREATER,0.49f);
\r
43 ////////////////////////////////////////////////////////////////////////
\r
45 ////////////////////////////////////////////////////////////////////////
\r
51 BOOL bDrawTextured; // current active drawing states
\r
52 BOOL bDrawSmoothShaded;
\r
53 BOOL bOldSmoothShaded;
\r
54 BOOL bDrawNonShaded;
\r
55 BOOL bDrawMultiPass;
\r
56 int iOffscreenDrawing;
\r
57 int iDrawnSomething=0;
\r
59 BOOL bRenderFrontBuffer=FALSE; // flag for front buffer rendering
\r
61 GLubyte ubGloAlpha; // texture alpha
\r
62 GLubyte ubGloColAlpha; // color alpha
\r
63 int iFilterType; // type of filter
\r
64 BOOL bFullVRam=FALSE; // sign for tex win
\r
65 BOOL bDrawDither; // sign for dither
\r
66 BOOL bUseMultiPass; // sign for multi pass
\r
67 GLuint gTexName; // binded texture
\r
68 BOOL bTexEnabled; // texture enable flag
\r
69 BOOL bBlendEnable; // blend enable flag
\r
70 PSXRect_t xrUploadArea; // rect to upload
\r
71 PSXRect_t xrUploadAreaIL; // rect to upload
\r
72 PSXRect_t xrUploadAreaRGB24; // rect to upload rgb24
\r
73 int iSpriteTex=0; // flag for "hey, it's a sprite"
\r
74 unsigned short usMirror; // mirror, mirror on the wall
\r
76 BOOL bNeedUploadAfter=FALSE; // sign for uploading in next frame
\r
77 BOOL bNeedUploadTest=FALSE; // sign for upload test
\r
78 BOOL bUsingTWin=FALSE; // tex win active flag
\r
79 BOOL bUsingMovie=FALSE; // movie active flag
\r
80 PSXRect_t xrMovieArea; // rect for movie upload
\r
81 short sSprite_ux2; // needed for sprire adjust
\r
82 short sSprite_vy2; //
\r
83 unsigned long ulOLDCOL=0; // active color
\r
84 unsigned long ulClutID; // clut
\r
86 unsigned long dwCfgFixes; // game fixes
\r
87 unsigned long dwActFixes=0;
\r
88 unsigned long dwEmuFixes=0;
\r
91 long drawX,drawY,drawW,drawH; // offscreen drawing checkers
\r
92 short sxmin,sxmax,symin,symax;
\r
93 unsigned int CSVERTEX=0,CSCOLOR=0,CSTEXTURE=0;
\r
95 void offsetPSX4(void)
\r
97 lx0 += PSXDisplay.DrawOffset.x;
\r
98 ly0 += PSXDisplay.DrawOffset.y;
\r
99 lx1 += PSXDisplay.DrawOffset.x;
\r
100 ly1 += PSXDisplay.DrawOffset.y;
\r
101 lx2 += PSXDisplay.DrawOffset.x;
\r
102 ly2 += PSXDisplay.DrawOffset.y;
\r
103 lx3 += PSXDisplay.DrawOffset.x;
\r
104 ly3 += PSXDisplay.DrawOffset.y;
\r
107 ////////////////////////////////////////////////////////////////////////
\r
108 // Update global TP infos
\r
109 ////////////////////////////////////////////////////////////////////////
\r
111 void UpdateGlobalTP(unsigned short gdata)
\r
113 GlobalTextAddrX = (gdata << 6) & 0x3c0;
\r
115 if(iGPUHeight==1024) // ZN mode
\r
117 if(dwGPUVersion==2) // very special zn gpu
\r
119 GlobalTextAddrY =((gdata & 0x60 ) << 3);
\r
120 GlobalTextIL =(gdata & 0x2000) >> 13;
\r
121 GlobalTextABR = (unsigned short)((gdata >> 7) & 0x3);
\r
122 GlobalTextTP = (gdata >> 9) & 0x3;
\r
123 if(GlobalTextTP==3) GlobalTextTP=2;
\r
124 GlobalTexturePage = (GlobalTextAddrX>>6)+(GlobalTextAddrY>>4);
\r
126 STATUSREG = (STATUSREG & 0xffffe000 ) | (gdata & 0x1fff );
\r
129 else // "enhanced" psx gpu
\r
131 GlobalTextAddrY = (unsigned short)(((gdata << 4) & 0x100) | ((gdata >> 2) & 0x200));
\r
134 else GlobalTextAddrY = (gdata << 4) & 0x100; // "normal" psx gpu
\r
136 usMirror=gdata&0x3000;
\r
138 GlobalTextTP = (gdata >> 7) & 0x3; // tex mode (4,8,15)
\r
139 if(GlobalTextTP==3) GlobalTextTP=2; // seen in Wild9 :(
\r
140 GlobalTextABR = (gdata >> 5) & 0x3; // blend mode
\r
142 GlobalTexturePage = (GlobalTextAddrX>>6)+(GlobalTextAddrY>>4);
\r
144 STATUSREG&=~0x07ff; // Clear the necessary bits
\r
145 STATUSREG|=(gdata & 0x07ff); // set the necessary bits
\r
148 ////////////////////////////////////////////////////////////////////////
\r
149 // Some ASM color convertion... Lewpy's special...
\r
150 ////////////////////////////////////////////////////////////////////////
\r
153 unsigned long DoubleBGR2RGB (unsigned long BGR)
\r
155 unsigned long ebx,eax,edx;
\r
157 ebx=(BGR&0x000000ff)<<1;
\r
158 if(ebx&0x00000100) ebx=0x000000ff;
\r
160 eax=(BGR&0x0000ff00)<<1;
\r
161 if(eax&0x00010000) eax=0x0000ff00;
\r
163 edx=(BGR&0x00ff0000)<<1;
\r
164 if(edx&0x01000000) edx=0x00ff0000;
\r
166 return (ebx|eax|edx);
\r
169 unsigned short BGR24to16 (unsigned long BGR)
\r
171 return ((BGR>>3)&0x1f)|((BGR&0xf80000)>>9)|((BGR&0xf800)>>6);
\r
175 ////////////////////////////////////////////////////////////////////////
\r
176 // OpenGL primitive drawing commands
\r
177 ////////////////////////////////////////////////////////////////////////
\r
179 void PRIMdrawTexturedQuad(OGLVertex* vertex1, OGLVertex* vertex2,
\r
180 OGLVertex* vertex3, OGLVertex* vertex4)
\r
186 v[0].xyz.x = fpoint(vertex1->x);
\r
187 v[0].xyz.y = fpoint(vertex1->y);
\r
188 v[0].xyz.z = fpoint(vertex1->z);
\r
189 v[0].st.x = fpoint(vertex1->sow);
\r
190 v[0].st.y = fpoint(vertex1->tow);
\r
192 v[1].xyz.x = fpoint(vertex2->x);
\r
193 v[1].xyz.y = fpoint(vertex2->y);
\r
194 v[1].xyz.z = fpoint(vertex2->z);
\r
195 v[1].st.x = fpoint(vertex2->sow);
\r
196 v[1].st.y = fpoint(vertex2->tow);
\r
198 v[2].xyz.x = fpoint(vertex4->x);
\r
199 v[2].xyz.y = fpoint(vertex4->y);
\r
200 v[2].xyz.z = fpoint(vertex4->z);
\r
201 v[2].st.x = fpoint(vertex4->sow);
\r
202 v[2].st.y = fpoint(vertex4->tow);
\r
204 v[3].xyz.x = fpoint(vertex3->x);
\r
205 v[3].xyz.y = fpoint(vertex3->y);
\r
206 v[3].xyz.z = fpoint(vertex3->z);
\r
207 v[3].st.x = fpoint(vertex3->sow);
\r
208 v[3].st.y = fpoint(vertex3->tow);
\r
209 if (CSCOLOR==1) glDisableClientState(GL_COLOR_ARRAY);glError();
\r
210 if (CSTEXTURE==0) glEnableClientState(GL_TEXTURE_COORD_ARRAY);glError();
\r
211 if (CSVERTEX==0) glEnableClientState(GL_VERTEX_ARRAY);glError();
\r
212 glTexCoordPointer(2, GL_FLOAT, sizeof(v[0]), &v[0].st);glError();
\r
213 glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0].xyz);glError();
\r
214 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);glError();
\r
215 CSTEXTURE=CSVERTEX=1;
\r
219 /////////////////////////////////////////////////////////
\r
221 void PRIMdrawTexturedTri(OGLVertex* vertex1, OGLVertex* vertex2,
\r
222 OGLVertex* vertex3)
\r
225 if (vertex1->x==0&&vertex1->y==0&&vertex2->x==0&&vertex2->y==0&&vertex3->x==0&&vertex3->y==0) return;
\r
227 v[0].xyz.x = fpoint(vertex1->x);
\r
228 v[0].xyz.y = fpoint(vertex1->y);
\r
229 v[0].xyz.z = fpoint(vertex1->z);
\r
230 v[0].st.x = fpoint(vertex1->sow);
\r
231 v[0].st.y = fpoint(vertex1->tow);
\r
233 v[1].xyz.x = fpoint(vertex2->x);
\r
234 v[1].xyz.y = fpoint(vertex2->y);
\r
235 v[1].xyz.z = fpoint(vertex2->z);
\r
236 v[1].st.x = fpoint(vertex2->sow);
\r
237 v[1].st.y = fpoint(vertex2->tow);
\r
239 v[2].xyz.x = fpoint(vertex3->x);
\r
240 v[2].xyz.y = fpoint(vertex3->y);
\r
241 v[2].xyz.z = fpoint(vertex3->z);
\r
242 v[2].st.x = fpoint(vertex3->sow);
\r
243 v[2].st.y = fpoint(vertex3->tow);
\r
244 if (CSCOLOR==1) glDisableClientState(GL_COLOR_ARRAY);glError();
\r
245 if (CSTEXTURE==0) glEnableClientState(GL_TEXTURE_COORD_ARRAY);glError();
\r
246 if (CSVERTEX==0) glEnableClientState(GL_VERTEX_ARRAY);glError();
\r
247 glTexCoordPointer(2, GL_FLOAT, sizeof(v[0]), &v[0].st);glError();
\r
248 glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0].xyz);glError();
\r
249 glDrawArrays(GL_TRIANGLES, 0, 3);glError();
\r
250 CSTEXTURE=CSVERTEX=1;
\r
255 /////////////////////////////////////////////////////////
\r
257 void PRIMdrawTexGouraudTriColor(OGLVertex* vertex1, OGLVertex* vertex2,
\r
258 OGLVertex* vertex3)
\r
262 if (vertex1->x==0&&vertex1->y==0&&vertex2->x==0&&vertex2->y==0&&vertex3->x==0&&vertex3->y==0) return;
\r
264 v[0].xyz.x = fpoint(vertex1->x);
\r
265 v[0].xyz.y = fpoint(vertex1->y);
\r
266 v[0].xyz.z = fpoint(vertex1->z);
\r
267 v[0].st.x = fpoint(vertex1->sow);
\r
268 v[0].st.y = fpoint(vertex1->tow);
\r
269 v[0].rgba.r = vertex1->c.col[0];
\r
270 v[0].rgba.g = vertex1->c.col[1];
\r
271 v[0].rgba.b = vertex1->c.col[2];
\r
272 v[0].rgba.a = vertex1->c.col[3];
\r
274 v[1].xyz.x = fpoint(vertex2->x);
\r
275 v[1].xyz.y = fpoint(vertex2->y);
\r
276 v[1].xyz.z = fpoint(vertex2->z);
\r
277 v[1].st.x = fpoint(vertex2->sow);
\r
278 v[1].st.y = fpoint(vertex2->tow);
\r
279 v[1].rgba.r = vertex2->c.col[0];
\r
280 v[1].rgba.g = vertex2->c.col[1];
\r
281 v[1].rgba.b = vertex2->c.col[2];
\r
282 v[1].rgba.a = vertex2->c.col[3];
\r
284 v[2].xyz.x = fpoint(vertex3->x);
\r
285 v[2].xyz.y = fpoint(vertex3->y);
\r
286 v[2].xyz.z = fpoint(vertex3->z);
\r
287 v[2].st.x = fpoint(vertex3->sow);
\r
288 v[2].st.y = fpoint(vertex3->tow);
\r
289 v[2].rgba.r = vertex3->c.col[0];
\r
290 v[2].rgba.g = vertex3->c.col[1];
\r
291 v[2].rgba.b = vertex3->c.col[2];
\r
292 v[2].rgba.a = vertex3->c.col[3];
\r
294 if (CSTEXTURE==0) glEnableClientState(GL_TEXTURE_COORD_ARRAY);glError();
\r
295 if (CSVERTEX==0) glEnableClientState(GL_VERTEX_ARRAY);glError();
\r
296 if (CSCOLOR==0) glEnableClientState(GL_COLOR_ARRAY);glError();
\r
298 glTexCoordPointer(2, GL_FLOAT, sizeof(v[0]), &v[0].st);glError();
\r
299 glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0].xyz);glError();
\r
300 glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(v[0]), &v[0].rgba);glError();
\r
302 glDrawArrays(GL_TRIANGLES, 0, 3);glError();
\r
303 CSTEXTURE=CSVERTEX=CSCOLOR=1;
\r
306 /////////////////////////////////////////////////////////
\r
308 void PRIMdrawTexGouraudTriColorQuad(OGLVertex* vertex1, OGLVertex* vertex2,
\r
309 OGLVertex* vertex3, OGLVertex* vertex4)
\r
312 if (vertex1->x==0&&vertex1->y==0&&vertex2->x==0&&vertex2->y==0&&vertex3->x==0&&vertex3->y==0&&vertex4->x==0&&vertex4->y==0) return;
\r
314 v[0].xyz.x = fpoint(vertex1->x);
\r
315 v[0].xyz.y = fpoint(vertex1->y);
\r
316 v[0].xyz.z = fpoint(vertex1->z);
\r
317 v[0].st.x = fpoint(vertex1->sow);
\r
318 v[0].st.y = fpoint(vertex1->tow);
\r
319 v[0].rgba.r = vertex1->c.col[0];
\r
320 v[0].rgba.g = vertex1->c.col[1];
\r
321 v[0].rgba.b = vertex1->c.col[2];
\r
322 v[0].rgba.a = vertex1->c.col[3];
\r
324 v[1].xyz.x = fpoint(vertex2->x);
\r
325 v[1].xyz.y = fpoint(vertex2->y);
\r
326 v[1].xyz.z = fpoint(vertex2->z);
\r
327 v[1].st.x = fpoint(vertex2->sow);
\r
328 v[1].st.y = fpoint(vertex2->tow);
\r
329 v[1].rgba.r = vertex2->c.col[0];
\r
330 v[1].rgba.g = vertex2->c.col[1];
\r
331 v[1].rgba.b = vertex2->c.col[2];
\r
332 v[1].rgba.a = vertex2->c.col[3];
\r
334 v[2].xyz.x = fpoint(vertex4->x);
\r
335 v[2].xyz.y = fpoint(vertex4->y);
\r
336 v[2].xyz.z = fpoint(vertex4->z);
\r
337 v[2].st.x = fpoint(vertex4->sow);
\r
338 v[2].st.y = fpoint(vertex4->tow);
\r
339 v[2].rgba.r = vertex4->c.col[0];
\r
340 v[2].rgba.g = vertex4->c.col[1];
\r
341 v[2].rgba.b = vertex4->c.col[2];
\r
342 v[2].rgba.a = vertex4->c.col[3];
\r
344 v[3].xyz.x = fpoint(vertex3->x);
\r
345 v[3].xyz.y = fpoint(vertex3->y);
\r
346 v[3].xyz.z = fpoint(vertex3->z);
\r
347 v[3].st.x = fpoint(vertex3->sow);
\r
348 v[3].st.y = fpoint(vertex3->tow);
\r
349 v[3].rgba.r = vertex3->c.col[0];
\r
350 v[3].rgba.g = vertex3->c.col[1];
\r
351 v[3].rgba.b = vertex3->c.col[2];
\r
352 v[3].rgba.a = vertex3->c.col[3];
\r
354 if (CSTEXTURE==0) glEnableClientState(GL_TEXTURE_COORD_ARRAY);glError();
\r
355 if (CSVERTEX==0) glEnableClientState(GL_VERTEX_ARRAY);glError();
\r
356 if (CSCOLOR==0) glEnableClientState(GL_COLOR_ARRAY);glError();
\r
358 glTexCoordPointer(2, GL_FLOAT, sizeof(v[0]), &v[0].st);glError();
\r
359 glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0].xyz);glError();
\r
360 glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(v[0]), &v[0].rgba);glError();
\r
362 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);glError();
\r
363 CSTEXTURE=CSVERTEX=CSCOLOR=1;
\r
366 /////////////////////////////////////////////////////////
\r
368 void PRIMdrawTri(OGLVertex* vertex1, OGLVertex* vertex2, OGLVertex* vertex3)
\r
371 if (vertex1->x==0&&vertex1->y==0&&vertex2->x==0&&vertex2->y==0&&vertex3->x==0&&vertex3->y==0) return;
\r
373 v[0].x = fpoint(vertex1->x);
\r
374 v[0].y = fpoint(vertex1->y);
\r
375 v[0].z = fpoint(vertex1->z);
\r
377 v[1].x = fpoint(vertex2->x);
\r
378 v[1].y = fpoint(vertex2->y);
\r
379 v[1].z = fpoint(vertex2->z);
\r
381 v[2].x = fpoint(vertex3->x);
\r
382 v[2].y = fpoint(vertex3->y);
\r
383 v[2].z = fpoint(vertex3->z);
\r
385 if (CSVERTEX==0) glEnableClientState(GL_VERTEX_ARRAY);glError();
\r
386 if (CSTEXTURE==1) glDisableClientState(GL_TEXTURE_COORD_ARRAY);glError();
\r
387 if (CSCOLOR==1) glDisableClientState(GL_COLOR_ARRAY);glError();
\r
389 glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0]);glError();
\r
390 glDrawArrays(GL_TRIANGLES, 0, 3);glError();
\r
392 CSTEXTURE=CSCOLOR=0;
\r
396 /////////////////////////////////////////////////////////
\r
398 void PRIMdrawTri2(OGLVertex* vertex1, OGLVertex* vertex2,
\r
399 OGLVertex* vertex3, OGLVertex* vertex4)
\r
402 if (vertex1->x==0&&vertex1->y==0&&vertex2->x==0&&vertex2->y==0&&vertex3->x==0&&vertex3->y==0&&vertex4->x==0&&vertex4->y==0) return;
\r
404 v[0].x = fpoint(vertex1->x);
\r
405 v[0].y = fpoint(vertex1->y);
\r
406 v[0].z = fpoint(vertex1->z);
\r
408 v[1].x = fpoint(vertex3->x);
\r
409 v[1].y = fpoint(vertex3->y);
\r
410 v[1].z = fpoint(vertex3->z);
\r
412 v[2].x = fpoint(vertex2->x);
\r
413 v[2].y = fpoint(vertex2->y);
\r
414 v[2].z = fpoint(vertex2->z);
\r
416 v[3].x = fpoint(vertex4->x);
\r
417 v[3].y = fpoint(vertex4->y);
\r
418 v[3].z = fpoint(vertex4->z);
\r
420 if (CSVERTEX==0) glEnableClientState(GL_VERTEX_ARRAY);glError();
\r
421 if (CSTEXTURE==1) glDisableClientState(GL_TEXTURE_COORD_ARRAY);glError();
\r
422 if (CSCOLOR==1) glDisableClientState(GL_COLOR_ARRAY);glError();
\r
424 glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0]);glError();
\r
425 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);glError();
\r
427 CSTEXTURE=CSCOLOR=0;
\r
430 /////////////////////////////////////////////////////////
\r
432 void PRIMdrawGouraudTriColor(OGLVertex* vertex1, OGLVertex* vertex2,
\r
433 OGLVertex* vertex3)
\r
436 if (vertex1->x==0&&vertex1->y==0&&vertex2->x==0&&vertex2->y==0&&vertex3->x==0&&vertex3->y==0) return;
\r
438 v[0].xyz.x = fpoint(vertex1->x);
\r
439 v[0].xyz.y = fpoint(vertex1->y);
\r
440 v[0].xyz.z = fpoint(vertex1->z);
\r
441 v[0].rgba.r = vertex1->c.col[0];
\r
442 v[0].rgba.g = vertex1->c.col[1];
\r
443 v[0].rgba.b = vertex1->c.col[2];
\r
444 v[0].rgba.a = vertex1->c.col[3];
\r
446 v[1].xyz.x = fpoint(vertex2->x);
\r
447 v[1].xyz.y = fpoint(vertex2->y);
\r
448 v[1].xyz.z = fpoint(vertex2->z);
\r
449 v[1].rgba.r = vertex2->c.col[0];
\r
450 v[1].rgba.g = vertex2->c.col[1];
\r
451 v[1].rgba.b = vertex2->c.col[2];
\r
452 v[1].rgba.a = vertex2->c.col[3];
\r
454 v[2].xyz.x = fpoint(vertex3->x);
\r
455 v[2].xyz.y = fpoint(vertex3->y);
\r
456 v[2].xyz.z = fpoint(vertex3->z);
\r
457 v[2].rgba.r = vertex3->c.col[0];
\r
458 v[2].rgba.g = vertex3->c.col[1];
\r
459 v[2].rgba.b = vertex3->c.col[2];
\r
460 v[2].rgba.a = vertex3->c.col[3];
\r
462 if (CSVERTEX==0) glEnableClientState(GL_VERTEX_ARRAY);glError();
\r
463 if (CSCOLOR==0) glEnableClientState(GL_COLOR_ARRAY);glError();
\r
464 if (CSTEXTURE==1) glDisableClientState(GL_TEXTURE_COORD_ARRAY);glError();
\r
466 glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0].xyz);glError();
\r
467 glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(v[0]), &v[0].rgba);glError();
\r
469 glDrawArrays(GL_TRIANGLES, 0, 3);glError();
\r
470 CSVERTEX=CSCOLOR=1;
\r
474 /////////////////////////////////////////////////////////
\r
476 void PRIMdrawGouraudTri2Color(OGLVertex* vertex1, OGLVertex* vertex2,
\r
477 OGLVertex* vertex3, OGLVertex* vertex4)
\r
480 if (vertex1->x==0&&vertex1->y==0&&vertex2->x==0&&vertex2->y==0&&vertex3->x==0&&vertex3->y==0&&vertex4->x==0&&vertex4->y==0) return;
\r
482 v[0].xyz.x = fpoint(vertex1->x);
\r
483 v[0].xyz.y = fpoint(vertex1->y);
\r
484 v[0].xyz.z = fpoint(vertex1->z);
\r
485 v[0].rgba.r = vertex1->c.col[0];
\r
486 v[0].rgba.g = vertex1->c.col[1];
\r
487 v[0].rgba.b = vertex1->c.col[2];
\r
488 v[0].rgba.a = vertex1->c.col[3];
\r
490 v[1].xyz.x = fpoint(vertex2->x);
\r
491 v[1].xyz.y = fpoint(vertex2->y);
\r
492 v[1].xyz.z = fpoint(vertex2->z);
\r
493 v[1].rgba.r = vertex2->c.col[0];
\r
494 v[1].rgba.g = vertex2->c.col[1];
\r
495 v[1].rgba.b = vertex2->c.col[2];
\r
496 v[1].rgba.a = vertex2->c.col[3];
\r
498 v[2].xyz.x = fpoint(vertex3->x);
\r
499 v[2].xyz.y = fpoint(vertex3->y);
\r
500 v[2].xyz.z = fpoint(vertex3->z);
\r
501 v[2].rgba.r = vertex3->c.col[0];
\r
502 v[2].rgba.g = vertex3->c.col[1];
\r
503 v[2].rgba.b = vertex3->c.col[2];
\r
504 v[2].rgba.a = vertex3->c.col[3];
\r
506 v[3].xyz.x = fpoint(vertex4->x);
\r
507 v[3].xyz.y = fpoint(vertex4->y);
\r
508 v[3].xyz.z = fpoint(vertex4->z);
\r
509 v[3].rgba.r = vertex4->c.col[0];
\r
510 v[3].rgba.g = vertex4->c.col[1];
\r
511 v[3].rgba.b = vertex4->c.col[2];
\r
512 v[3].rgba.a = vertex4->c.col[3];
\r
514 if (CSTEXTURE==1) glDisableClientState(GL_TEXTURE_COORD_ARRAY);glError();
\r
515 if (CSVERTEX==0) glEnableClientState(GL_VERTEX_ARRAY);glError();
\r
516 if (CSCOLOR==0) glEnableClientState(GL_COLOR_ARRAY);glError();
\r
518 glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0].xyz);glError();
\r
519 glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(v[0]), &v[0].rgba);glError();
\r
521 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);glError();
\r
523 CSVERTEX=CSCOLOR=1;
\r
526 /////////////////////////////////////////////////////////
\r
528 void PRIMdrawFlatLine(OGLVertex* vertex1, OGLVertex* vertex2,OGLVertex* vertex3, OGLVertex* vertex4)
\r
531 if (vertex1->x==0&&vertex1->y==0&&vertex2->x==0&&vertex2->y==0&&vertex3->x==0&&vertex3->y==0&&vertex4->x==0&&vertex4->y==0) return;
\r
533 v[0].xyz.x = fpoint(vertex1->x);
\r
534 v[0].xyz.y = fpoint(vertex1->y);
\r
535 v[0].xyz.z = fpoint(vertex1->z);
\r
536 v[0].rgba.r = vertex1->c.col[0];
\r
537 v[0].rgba.g = vertex1->c.col[1];
\r
538 v[0].rgba.b = vertex1->c.col[2];
\r
539 v[0].rgba.a = vertex1->c.col[3];
\r
541 v[1].xyz.x = fpoint(vertex2->x);
\r
542 v[1].xyz.y = fpoint(vertex2->y);
\r
543 v[1].xyz.z = fpoint(vertex2->z);
\r
544 v[1].rgba.r = vertex1->c.col[0];
\r
545 v[1].rgba.g = vertex1->c.col[1];
\r
546 v[1].rgba.b = vertex1->c.col[2];
\r
547 v[1].rgba.a = vertex1->c.col[3];
\r
549 v[2].xyz.x = fpoint(vertex4->x);
\r
550 v[2].xyz.y = fpoint(vertex4->y);
\r
551 v[2].xyz.z = fpoint(vertex4->z);
\r
552 v[2].rgba.r = vertex1->c.col[0];
\r
553 v[2].rgba.g = vertex1->c.col[1];
\r
554 v[2].rgba.b = vertex1->c.col[2];
\r
555 v[2].rgba.a = vertex1->c.col[3];
\r
557 v[3].xyz.x = fpoint(vertex3->x);
\r
558 v[3].xyz.y = fpoint(vertex3->y);
\r
559 v[3].xyz.z = fpoint(vertex3->z);
\r
560 v[3].rgba.r = vertex1->c.col[0];
\r
561 v[3].rgba.g = vertex1->c.col[1];
\r
562 v[3].rgba.b = vertex1->c.col[2];
\r
563 v[3].rgba.a = vertex1->c.col[3];
\r
565 if (CSTEXTURE==1) glDisableClientState(GL_TEXTURE_COORD_ARRAY);glError();
\r
566 if (CSVERTEX==0) glEnableClientState(GL_VERTEX_ARRAY);glError();
\r
567 if (CSCOLOR==0) glEnableClientState(GL_COLOR_ARRAY);glError();
\r
569 glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0].xyz);glError();
\r
570 glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(v[0]), &v[0].rgba);glError();
\r
572 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);glError();
\r
575 CSVERTEX=CSCOLOR=1;
\r
580 /////////////////////////////////////////////////////////
\r
582 void PRIMdrawGouraudLine(OGLVertex* vertex1, OGLVertex* vertex2,OGLVertex* vertex3, OGLVertex* vertex4)
\r
585 if (vertex1->x==0&&vertex1->y==0&&vertex2->x==0&&vertex2->y==0&&vertex3->x==0&&vertex3->y==0&&vertex4->x==0&&vertex4->y==0) return;
\r
587 v[0].xyz.x = fpoint(vertex1->x);
\r
588 v[0].xyz.y = fpoint(vertex1->y);
\r
589 v[0].xyz.z = fpoint(vertex1->z);
\r
590 v[0].rgba.r = vertex1->c.col[0];
\r
591 v[0].rgba.g = vertex1->c.col[1];
\r
592 v[0].rgba.b = vertex1->c.col[2];
\r
593 v[0].rgba.a = vertex1->c.col[3];
\r
595 v[1].xyz.x = fpoint(vertex2->x);
\r
596 v[1].xyz.y = fpoint(vertex2->y);
\r
597 v[1].xyz.z = fpoint(vertex2->z);
\r
598 v[1].rgba.r = vertex2->c.col[0];
\r
599 v[1].rgba.g = vertex2->c.col[1];
\r
600 v[1].rgba.b = vertex2->c.col[2];
\r
601 v[1].rgba.a = vertex2->c.col[3];
\r
603 v[3].xyz.x = fpoint(vertex3->x);
\r
604 v[3].xyz.y = fpoint(vertex3->y);
\r
605 v[3].xyz.z = fpoint(vertex3->z);
\r
606 v[3].rgba.r = vertex3->c.col[0];
\r
607 v[3].rgba.g = vertex3->c.col[1];
\r
608 v[3].rgba.b = vertex3->c.col[2];
\r
609 v[3].rgba.a = vertex3->c.col[3];
\r
611 v[2].xyz.x = fpoint(vertex4->x);
\r
612 v[2].xyz.y = fpoint(vertex4->y);
\r
613 v[2].xyz.z = fpoint(vertex4->z);
\r
614 v[2].rgba.r = vertex4->c.col[0];
\r
615 v[2].rgba.g = vertex4->c.col[1];
\r
616 v[2].rgba.b = vertex4->c.col[2];
\r
617 v[2].rgba.a = vertex4->c.col[3];
\r
619 if (CSTEXTURE==1) glDisableClientState(GL_TEXTURE_COORD_ARRAY);glError();
\r
620 if (CSVERTEX==0) glEnableClientState(GL_VERTEX_ARRAY);glError();
\r
621 if (CSCOLOR==0) glEnableClientState(GL_COLOR_ARRAY);glError();
\r
623 glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0].xyz);glError();
\r
624 glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(v[0]), &v[0].rgba);glError();
\r
626 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);glError();
\r
628 CSVERTEX=CSCOLOR=1;
\r
631 /////////////////////////////////////////////////////////
\r
633 void PRIMdrawQuad(OGLVertex* vertex1, OGLVertex* vertex2,
\r
634 OGLVertex* vertex3, OGLVertex* vertex4)
\r
637 if (vertex1->x==0&&vertex1->y==0&&vertex2->x==0&&vertex2->y==0&&vertex3->x==0&&vertex3->y==0&&vertex4->x==0&&vertex4->y==0) return;
\r
639 v[0].x = fpoint(vertex1->x);
\r
640 v[0].y = fpoint(vertex1->y);
\r
641 v[0].z = fpoint(vertex1->z);
\r
643 v[1].x = fpoint(vertex2->x);
\r
644 v[1].y = fpoint(vertex2->y);
\r
645 v[1].z = fpoint(vertex2->z);
\r
647 v[2].x = fpoint(vertex4->x);
\r
648 v[2].y = fpoint(vertex4->y);
\r
649 v[2].z = fpoint(vertex4->z);
\r
651 v[3].x = fpoint(vertex3->x);
\r
652 v[3].y = fpoint(vertex3->y);
\r
653 v[3].z = fpoint(vertex3->z);
\r
655 if (CSTEXTURE==1) glDisableClientState(GL_TEXTURE_COORD_ARRAY);glError();
\r
656 if (CSVERTEX==0) glEnableClientState(GL_VERTEX_ARRAY);glError();
\r
657 if (CSCOLOR==1) glDisableClientState(GL_COLOR_ARRAY);glError();
\r
659 glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0]);glError();
\r
660 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);glError();
\r
666 ////////////////////////////////////////////////////////////////////////
\r
667 // Transparent blending settings
\r
668 ////////////////////////////////////////////////////////////////////////
\r
670 static GLenum obm1=GL_ZERO;
\r
671 static GLenum obm2=GL_ZERO;
\r
673 typedef struct SEMITRANSTAG
\r
680 SemiTransParams TransSets[4]=
\r
682 {GL_SRC_ALPHA,GL_SRC_ALPHA, 127},
\r
683 {GL_ONE, GL_ONE, 255},
\r
684 {GL_ZERO, GL_ONE_MINUS_SRC_COLOR,255},
\r
685 {GL_ONE_MINUS_SRC_ALPHA,GL_ONE, 192}
\r
688 ////////////////////////////////////////////////////////////////////////
\r
690 void SetSemiTrans(void)
\r
693 * 0.5 x B + 0.5 x F
\r
694 * 1.0 x B + 1.0 x F
\r
695 * 1.0 x B - 1.0 x F
\r
696 * 1.0 x B +0.25 x F
\r
699 if(!DrawSemiTrans) // no semi trans at all?
\r
702 {glDisable(GL_BLEND);glError();bBlendEnable=FALSE;}// -> don't wanna blend
\r
703 ubGloAlpha=ubGloColAlpha=255; // -> full alpha
\r
704 return; // -> and bye
\r
707 ubGloAlpha=ubGloColAlpha=TransSets[GlobalTextABR].alpha;
\r
710 {glEnable(GL_BLEND);glError();bBlendEnable=TRUE;} // wanna blend
\r
712 if(TransSets[GlobalTextABR].srcFac!=obm1 ||
\r
713 TransSets[GlobalTextABR].dstFac!=obm2)
\r
715 //if(glBlendEquationEXTEx==NULL)
\r
717 obm1=TransSets[GlobalTextABR].srcFac;
\r
718 obm2=TransSets[GlobalTextABR].dstFac;
\r
719 glBlendFunc(obm1,obm2); glError(); // set blend func
\r
722 if(TransSets[GlobalTextABR].dstFac !=GL_ONE_MINUS_SRC_COLOR)
\r
724 if(obm2==GL_ONE_MINUS_SRC_COLOR)
\r
725 glBlendEquationEXTEx(FUNC_ADD_EXT);
\r
726 obm1=TransSets[GlobalTextABR].srcFac;
\r
727 obm2=TransSets[GlobalTextABR].dstFac;
\r
728 glBlendFunc(obm1,obm2); // set blend func
\r
732 glBlendEquationEXTEx(FUNC_REVERSESUBTRACT_EXT);
\r
733 obm1=TransSets[GlobalTextABR].srcFac;
\r
734 obm2=TransSets[GlobalTextABR].dstFac;
\r
735 glBlendFunc(GL_ONE,GL_ONE); // set blend func
\r
740 void SetScanTrans(void) // blending for scan lines
\r
742 /* if(glBlendEquationEXTEx!=NULL)
\r
744 if(obm2==GL_ONE_MINUS_SRC_COLOR)
\r
745 glBlendEquationEXTEx(FUNC_ADD_EXT);
\r
748 obm1=TransSets[0].srcFac;
\r
749 obm2=TransSets[0].dstFac;
\r
750 glBlendFunc(obm1,obm2); glError(); // set blend func
\r
753 void SetScanTexTrans(void) // blending for scan mask texture
\r
755 /* if(glBlendEquationEXTEx!=NULL)
\r
757 if(obm2==GL_ONE_MINUS_SRC_COLOR)
\r
758 glBlendEquationEXTEx(FUNC_ADD_EXT);
\r
761 obm1=TransSets[2].srcFac;
\r
762 obm2=TransSets[2].dstFac;
\r
763 glBlendFunc(obm1,obm2); glError(); // set blend func
\r
766 ////////////////////////////////////////////////////////////////////////
\r
767 // multi pass in old 'Advanced blending' mode... got it from Lewpy :)
\r
768 ////////////////////////////////////////////////////////////////////////
\r
770 SemiTransParams MultiTexTransSets[4][2]=
\r
773 {GL_ONE ,GL_SRC_ALPHA, 127},
\r
774 {GL_SRC_ALPHA,GL_ONE, 127}
\r
777 {GL_ONE, GL_SRC_ALPHA, 255},
\r
778 {GL_SRC_ALPHA,GL_ONE, 255}
\r
781 {GL_ZERO, GL_ONE_MINUS_SRC_COLOR,255},
\r
782 {GL_ZERO, GL_ONE_MINUS_SRC_COLOR,255}
\r
785 {GL_SRC_ALPHA,GL_ONE, 127},
\r
786 {GL_ONE_MINUS_SRC_ALPHA,GL_ONE, 255}
\r
790 ////////////////////////////////////////////////////////////////////////
\r
792 SemiTransParams MultiColTransSets[4]=
\r
794 {GL_ONE_MINUS_SRC_ALPHA,GL_SRC_ALPHA,127},
\r
795 {GL_ONE, GL_ONE, 255},
\r
796 {GL_ZERO, GL_ONE_MINUS_SRC_COLOR,255},
\r
797 {GL_SRC_ALPHA,GL_ONE, 127}
\r
800 ////////////////////////////////////////////////////////////////////////
\r
802 void SetSemiTransMulti(int Pass)
\r
804 static GLenum bm1=GL_ZERO;
\r
805 static GLenum bm2=GL_ONE;
\r
810 // are we enabling SemiTransparent mode?
\r
815 bm1=MultiTexTransSets[GlobalTextABR][Pass].srcFac;
\r
816 bm2=MultiTexTransSets[GlobalTextABR][Pass].dstFac;
\r
817 ubGloAlpha=MultiTexTransSets[GlobalTextABR][Pass].alpha;
\r
822 bm1=MultiColTransSets[GlobalTextABR].srcFac;
\r
823 bm2=MultiColTransSets[GlobalTextABR].dstFac;
\r
824 ubGloColAlpha=MultiColTransSets[GlobalTextABR].alpha;
\r
832 // disable blending
\r
833 bm1=GL_ONE;bm2=GL_ZERO;
\r
837 // disable blending, but add src col a second time
\r
838 bm1=GL_ONE;bm2=GL_ONE;
\r
843 {glEnable(GL_BLEND);glError();bBlendEnable=TRUE;} // wanna blend
\r
845 if(bm1!=obm1 || bm2!=obm2)
\r
847 glBlendFunc(bm1,bm2); glError(); // set blend func
\r
852 ////////////////////////////////////////////////////////////////////////
\r
853 // Set several rendering stuff including blending
\r
854 ////////////////////////////////////////////////////////////////////////
\r
856 void SetZMask3O(void)
\r
858 if(iUseMask && DrawSemiTrans && !iSetMask)
\r
860 vertex[0].z=vertex[1].z=vertex[2].z=gl_z;
\r
865 void SetZMask3(void)
\r
869 if(iSetMask || DrawSemiTrans)
\r
870 {vertex[0].z=vertex[1].z=vertex[2].z=0.95f;}
\r
873 vertex[0].z=vertex[1].z=vertex[2].z=gl_z;
\r
879 void SetZMask3NT(void)
\r
884 {vertex[0].z=vertex[1].z=vertex[2].z=0.95f;}
\r
887 vertex[0].z=vertex[1].z=vertex[2].z=gl_z;
\r
893 ////////////////////////////////////////////////////////////////////////
\r
895 void SetZMask4O(void)
\r
897 if(iUseMask && DrawSemiTrans && !iSetMask)
\r
899 vertex[0].z=vertex[1].z=vertex[2].z=vertex[3].z=gl_z;
\r
904 void SetZMask4(void)
\r
908 if(iSetMask || DrawSemiTrans)
\r
909 {vertex[0].z=vertex[1].z=vertex[2].z=vertex[3].z=0.95f;}
\r
912 vertex[0].z=vertex[1].z=vertex[2].z=vertex[3].z=gl_z;
\r
918 void SetZMask4NT(void)
\r
923 {vertex[0].z=vertex[1].z=vertex[2].z=vertex[3].z=0.95f;}
\r
926 vertex[0].z=vertex[1].z=vertex[2].z=vertex[3].z=gl_z;
\r
932 void SetZMask4SP(void)
\r
937 {vertex[0].z=vertex[1].z=vertex[2].z=vertex[3].z=0.95f;}
\r
942 vertex[0].z=vertex[1].z=vertex[2].z=vertex[3].z=gl_z;
\r
946 {vertex[0].z=vertex[1].z=vertex[2].z=vertex[3].z=0.95f;}
\r
951 ////////////////////////////////////////////////////////////////////////
\r
953 void SetRenderState(unsigned long DrawAttributes)
\r
955 bDrawNonShaded = (SHADETEXBIT(DrawAttributes)) ? TRUE : FALSE;
\r
956 DrawSemiTrans = (SEMITRANSBIT(DrawAttributes)) ? TRUE : FALSE;
\r
959 ////////////////////////////////////////////////////////////////////////
\r
961 void SetRenderColor(unsigned long DrawAttributes)
\r
963 if(bDrawNonShaded) {g_m1=g_m2=g_m3=128;}
\r
966 g_m1=DrawAttributes&0xff;
\r
967 g_m2=(DrawAttributes>>8)&0xff;
\r
968 g_m3=(DrawAttributes>>16)&0xff;
\r
972 ////////////////////////////////////////////////////////////////////////
\r
974 void SetRenderMode(unsigned long DrawAttributes,BOOL bSCol)
\r
976 if((bUseMultiPass) && (bDrawTextured) && !(bDrawNonShaded))
\r
977 {bDrawMultiPass = TRUE; SetSemiTransMulti(0);}
\r
978 else {bDrawMultiPass = FALSE;SetSemiTrans();}
\r
980 if(bDrawTextured) // texture ? build it/get it from cache
\r
983 if(bUsingTWin) currTex=LoadTextureWnd(GlobalTexturePage,GlobalTextTP, ulClutID);
\r
984 else if(bUsingMovie) currTex=LoadTextureMovie();
\r
985 else currTex=SelectSubTextureS(GlobalTextTP,ulClutID);
\r
987 if(gTexName!=currTex)
\r
988 {gTexName=currTex;glBindTexture(GL_TEXTURE_2D,currTex); glError();}
\r
990 if(!bTexEnabled) // -> turn texturing on
\r
991 {bTexEnabled=TRUE;glEnable(GL_TEXTURE_2D); glError();}
\r
993 else // no texture ?
\r
995 {bTexEnabled=FALSE;glDisable(GL_TEXTURE_2D); glError();} // -> turn texturing off
\r
997 if(bSCol) // also set color ?
\r
999 if((dwActFixes&4) && ((DrawAttributes&0x00ffffff)==0))
\r
1000 DrawAttributes|=0x007f7f7f;
\r
1002 if(bDrawNonShaded) // -> non shaded?
\r
1004 /* if(bGLBlend) vertex[0].c.lcol=0x7f7f7f; // --> solid color...
\r
1005 else */vertex[0].c.lcol=0xffffff;
\r
1007 else // -> shaded?
\r
1009 // if(!bUseMultiPass && !bGLBlend) // --> given color...
\r
1010 vertex[0].c.lcol=DoubleBGR2RGB(DrawAttributes);
\r
1011 // else vertex[0].c.lcol=DrawAttributes;
\r
1013 vertex[0].c.col[3]=ubGloAlpha; // -> set color with
\r
1014 SETCOL(vertex[0]); // texture alpha
\r
1017 if(bDrawSmoothShaded!=bOldSmoothShaded) // shading changed?
\r
1019 if(bDrawSmoothShaded) glShadeModel(GL_SMOOTH); // -> set actual shading
\r
1020 else glShadeModel(GL_FLAT);
\r
1022 bOldSmoothShaded=bDrawSmoothShaded;
\r
1026 ////////////////////////////////////////////////////////////////////////
\r
1027 // Set Opaque multipass color
\r
1028 ////////////////////////////////////////////////////////////////////////
\r
1030 void SetOpaqueColor(unsigned long DrawAttributes)
\r
1032 if(bDrawNonShaded) return; // no shading? bye
\r
1034 DrawAttributes=DoubleBGR2RGB(DrawAttributes); // multipass is just half color, so double it on opaque pass
\r
1035 vertex[0].c.lcol=DrawAttributes|0xff000000;
\r
1036 SETCOL(vertex[0]); // set color
\r
1039 ////////////////////////////////////////////////////////////////////////
\r
1040 // Fucking stupid screen coord checking
\r
1041 ////////////////////////////////////////////////////////////////////////
\r
1043 BOOL ClipVertexListScreen(void)
\r
1045 if (lx0 >= PSXDisplay.DisplayEnd.x) goto NEXTSCRTEST;
\r
1046 if (ly0 >= PSXDisplay.DisplayEnd.y) goto NEXTSCRTEST;
\r
1047 if (lx2 < PSXDisplay.DisplayPosition.x) goto NEXTSCRTEST;
\r
1048 if (ly2 < PSXDisplay.DisplayPosition.y) goto NEXTSCRTEST;
\r
1053 if(PSXDisplay.InterlacedTest) return FALSE;
\r
1055 if (lx0 >= PreviousPSXDisplay.DisplayEnd.x) return FALSE;
\r
1056 if (ly0 >= PreviousPSXDisplay.DisplayEnd.y) return FALSE;
\r
1057 if (lx2 < PreviousPSXDisplay.DisplayPosition.x) return FALSE;
\r
1058 if (ly2 < PreviousPSXDisplay.DisplayPosition.y) return FALSE;
\r
1063 ////////////////////////////////////////////////////////////////////////
\r
1065 BOOL bDrawOffscreenFront(void)
\r
1067 if(sxmin < PSXDisplay.DisplayPosition.x) return FALSE; // must be complete in front
\r
1068 if(symin < PSXDisplay.DisplayPosition.y) return FALSE;
\r
1069 if(sxmax > PSXDisplay.DisplayEnd.x) return FALSE;
\r
1070 if(symax > PSXDisplay.DisplayEnd.y) return FALSE;
\r
1074 BOOL bOnePointInFront(void)
\r
1076 if(sxmax< PSXDisplay.DisplayPosition.x)
\r
1079 if(symax< PSXDisplay.DisplayPosition.y)
\r
1082 if(sxmin>=PSXDisplay.DisplayEnd.x)
\r
1085 if(symin>=PSXDisplay.DisplayEnd.y)
\r
1092 BOOL bOnePointInBack(void)
\r
1094 if(sxmax< PreviousPSXDisplay.DisplayPosition.x)
\r
1097 if(symax< PreviousPSXDisplay.DisplayPosition.y)
\r
1100 if(sxmin>=PreviousPSXDisplay.DisplayEnd.x)
\r
1103 if(symin>=PreviousPSXDisplay.DisplayEnd.y)
\r
1109 BOOL bDrawOffscreen4(void)
\r
1111 BOOL bFront;short sW,sH;
\r
1113 sxmax=max(lx0,max(lx1,max(lx2,lx3)));
\r
1114 if(sxmax<drawX) return FALSE;
\r
1115 sxmin=min(lx0,min(lx1,min(lx2,lx3)));
\r
1116 if(sxmin>drawW) return FALSE;
\r
1117 symax=max(ly0,max(ly1,max(ly2,ly3)));
\r
1118 if(symax<drawY) return FALSE;
\r
1119 symin=min(ly0,min(ly1,min(ly2,ly3)));
\r
1120 if(symin>drawH) return FALSE;
\r
1122 if(PSXDisplay.Disabled) return TRUE; // disabled? ever
\r
1124 if(iOffscreenDrawing==1) return bFullVRam;
\r
1126 if(dwActFixes&1 && iOffscreenDrawing==4)
\r
1128 if(PreviousPSXDisplay.DisplayPosition.x==PSXDisplay.DisplayPosition.x &&
\r
1129 PreviousPSXDisplay.DisplayPosition.y==PSXDisplay.DisplayPosition.y &&
\r
1130 PreviousPSXDisplay.DisplayEnd.x==PSXDisplay.DisplayEnd.x &&
\r
1131 PreviousPSXDisplay.DisplayEnd.y==PSXDisplay.DisplayEnd.y)
\r
1133 bRenderFrontBuffer=TRUE;
\r
1138 sW=drawW-1;sH=drawH-1;
\r
1140 sxmin=min(sW,max(sxmin,drawX));
\r
1141 sxmax=max(drawX,min(sxmax,sW));
\r
1142 symin=min(sH,max(symin,drawY));
\r
1143 symax=max(drawY,min(symax,sH));
\r
1145 if(bOnePointInBack()) return bFullVRam;
\r
1147 if(iOffscreenDrawing==2)
\r
1148 bFront=bDrawOffscreenFront();
\r
1149 else bFront=bOnePointInFront();
\r
1153 if(PSXDisplay.InterlacedTest) return bFullVRam; // -> ok, no need for adjust
\r
1155 vertex[0].x=lx0 - PSXDisplay.DisplayPosition.x+PreviousPSXDisplay.Range.x0;
\r
1156 vertex[1].x=lx1 - PSXDisplay.DisplayPosition.x+PreviousPSXDisplay.Range.x0;
\r
1157 vertex[2].x=lx2 - PSXDisplay.DisplayPosition.x+PreviousPSXDisplay.Range.x0;
\r
1158 vertex[3].x=lx3 - PSXDisplay.DisplayPosition.x+PreviousPSXDisplay.Range.x0;
\r
1159 vertex[0].y=ly0 - PSXDisplay.DisplayPosition.y+PreviousPSXDisplay.Range.y0;
\r
1160 vertex[1].y=ly1 - PSXDisplay.DisplayPosition.y+PreviousPSXDisplay.Range.y0;
\r
1161 vertex[2].y=ly2 - PSXDisplay.DisplayPosition.y+PreviousPSXDisplay.Range.y0;
\r
1162 vertex[3].y=ly3 - PSXDisplay.DisplayPosition.y+PreviousPSXDisplay.Range.y0;
\r
1164 if(iOffscreenDrawing==4 && !(dwActFixes&1)) // -> frontbuffer wanted
\r
1166 bRenderFrontBuffer=TRUE;
\r
1169 return bFullVRam; // -> but no od
\r
1175 ////////////////////////////////////////////////////////////////////////
\r
1177 BOOL bDrawOffscreen3(void)
\r
1179 BOOL bFront;short sW,sH;
\r
1181 sxmax=max(lx0,max(lx1,lx2));
\r
1182 if(sxmax<drawX) return FALSE;
\r
1183 sxmin=min(lx0,min(lx1,lx2));
\r
1184 if(sxmin>drawW) return FALSE;
\r
1185 symax=max(ly0,max(ly1,ly2));
\r
1186 if(symax<drawY) return FALSE;
\r
1187 symin=min(ly0,min(ly1,ly2));
\r
1188 if(symin>drawH) return FALSE;
\r
1190 if(PSXDisplay.Disabled) return TRUE; // disabled? ever
\r
1192 if(iOffscreenDrawing==1) return bFullVRam;
\r
1194 sW=drawW-1;sH=drawH-1;
\r
1195 sxmin=min(sW,max(sxmin,drawX));
\r
1196 sxmax=max(drawX,min(sxmax,sW));
\r
1197 symin=min(sH,max(symin,drawY));
\r
1198 symax=max(drawY,min(symax,sH));
\r
1200 if(bOnePointInBack()) return bFullVRam;
\r
1202 if(iOffscreenDrawing==2)
\r
1203 bFront=bDrawOffscreenFront();
\r
1204 else bFront=bOnePointInFront();
\r
1208 if(PSXDisplay.InterlacedTest) return bFullVRam; // -> ok, no need for adjust
\r
1210 vertex[0].x=lx0 - PSXDisplay.DisplayPosition.x+PreviousPSXDisplay.Range.x0;
\r
1211 vertex[1].x=lx1 - PSXDisplay.DisplayPosition.x+PreviousPSXDisplay.Range.x0;
\r
1212 vertex[2].x=lx2 - PSXDisplay.DisplayPosition.x+PreviousPSXDisplay.Range.x0;
\r
1213 vertex[0].y=ly0 - PSXDisplay.DisplayPosition.y+PreviousPSXDisplay.Range.y0;
\r
1214 vertex[1].y=ly1 - PSXDisplay.DisplayPosition.y+PreviousPSXDisplay.Range.y0;
\r
1215 vertex[2].y=ly2 - PSXDisplay.DisplayPosition.y+PreviousPSXDisplay.Range.y0;
\r
1217 if(iOffscreenDrawing==4) // -> frontbuffer wanted
\r
1219 bRenderFrontBuffer=TRUE;
\r
1223 return bFullVRam; // -> but no od
\r
1229 ////////////////////////////////////////////////////////////////////////
\r
1231 BOOL FastCheckAgainstScreen(short imageX0,short imageY0,short imageX1,short imageY1)
\r
1233 PSXRect_t xUploadArea;
\r
1235 imageX1 += imageX0;
\r
1236 imageY1 += imageY0;
\r
1238 if (imageX0 < PreviousPSXDisplay.DisplayPosition.x)
\r
1239 xUploadArea.x0 = PreviousPSXDisplay.DisplayPosition.x;
\r
1241 if (imageX0 > PreviousPSXDisplay.DisplayEnd.x)
\r
1242 xUploadArea.x0 = PreviousPSXDisplay.DisplayEnd.x;
\r
1244 xUploadArea.x0 = imageX0;
\r
1246 if(imageX1 < PreviousPSXDisplay.DisplayPosition.x)
\r
1247 xUploadArea.x1 = PreviousPSXDisplay.DisplayPosition.x;
\r
1249 if (imageX1 > PreviousPSXDisplay.DisplayEnd.x)
\r
1250 xUploadArea.x1 = PreviousPSXDisplay.DisplayEnd.x;
\r
1252 xUploadArea.x1 = imageX1;
\r
1254 if (imageY0 < PreviousPSXDisplay.DisplayPosition.y)
\r
1255 xUploadArea.y0 = PreviousPSXDisplay.DisplayPosition.y;
\r
1257 if (imageY0 > PreviousPSXDisplay.DisplayEnd.y)
\r
1258 xUploadArea.y0 = PreviousPSXDisplay.DisplayEnd.y;
\r
1260 xUploadArea.y0 = imageY0;
\r
1262 if (imageY1 < PreviousPSXDisplay.DisplayPosition.y)
\r
1263 xUploadArea.y1 = PreviousPSXDisplay.DisplayPosition.y;
\r
1265 if (imageY1 > PreviousPSXDisplay.DisplayEnd.y)
\r
1266 xUploadArea.y1 = PreviousPSXDisplay.DisplayEnd.y;
\r
1268 xUploadArea.y1 = imageY1;
\r
1270 if ((xUploadArea.x0 != xUploadArea.x1) && (xUploadArea.y0 != xUploadArea.y1))
\r
1272 else return FALSE;
\r
1275 BOOL CheckAgainstScreen(short imageX0,short imageY0,short imageX1,short imageY1)
\r
1277 imageX1 += imageX0;
\r
1278 imageY1 += imageY0;
\r
1280 if (imageX0 < PreviousPSXDisplay.DisplayPosition.x)
\r
1281 xrUploadArea.x0 = PreviousPSXDisplay.DisplayPosition.x;
\r
1283 if (imageX0 > PreviousPSXDisplay.DisplayEnd.x)
\r
1284 xrUploadArea.x0 = PreviousPSXDisplay.DisplayEnd.x;
\r
1286 xrUploadArea.x0 = imageX0;
\r
1288 if(imageX1 < PreviousPSXDisplay.DisplayPosition.x)
\r
1289 xrUploadArea.x1 = PreviousPSXDisplay.DisplayPosition.x;
\r
1291 if (imageX1 > PreviousPSXDisplay.DisplayEnd.x)
\r
1292 xrUploadArea.x1 = PreviousPSXDisplay.DisplayEnd.x;
\r
1294 xrUploadArea.x1 = imageX1;
\r
1296 if (imageY0 < PreviousPSXDisplay.DisplayPosition.y)
\r
1297 xrUploadArea.y0 = PreviousPSXDisplay.DisplayPosition.y;
\r
1299 if (imageY0 > PreviousPSXDisplay.DisplayEnd.y)
\r
1300 xrUploadArea.y0 = PreviousPSXDisplay.DisplayEnd.y;
\r
1302 xrUploadArea.y0 = imageY0;
\r
1304 if (imageY1 < PreviousPSXDisplay.DisplayPosition.y)
\r
1305 xrUploadArea.y1 = PreviousPSXDisplay.DisplayPosition.y;
\r
1307 if (imageY1 > PreviousPSXDisplay.DisplayEnd.y)
\r
1308 xrUploadArea.y1 = PreviousPSXDisplay.DisplayEnd.y;
\r
1310 xrUploadArea.y1 = imageY1;
\r
1312 if ((xrUploadArea.x0 != xrUploadArea.x1) && (xrUploadArea.y0 != xrUploadArea.y1))
\r
1314 else return FALSE;
\r
1317 BOOL FastCheckAgainstFrontScreen(short imageX0,short imageY0,short imageX1,short imageY1)
\r
1319 PSXRect_t xUploadArea;
\r
1321 imageX1 += imageX0;
\r
1322 imageY1 += imageY0;
\r
1324 if (imageX0 < PSXDisplay.DisplayPosition.x)
\r
1325 xUploadArea.x0 = PSXDisplay.DisplayPosition.x;
\r
1327 if (imageX0 > PSXDisplay.DisplayEnd.x)
\r
1328 xUploadArea.x0 = PSXDisplay.DisplayEnd.x;
\r
1330 xUploadArea.x0 = imageX0;
\r
1332 if(imageX1 < PSXDisplay.DisplayPosition.x)
\r
1333 xUploadArea.x1 = PSXDisplay.DisplayPosition.x;
\r
1335 if (imageX1 > PSXDisplay.DisplayEnd.x)
\r
1336 xUploadArea.x1 = PSXDisplay.DisplayEnd.x;
\r
1338 xUploadArea.x1 = imageX1;
\r
1340 if (imageY0 < PSXDisplay.DisplayPosition.y)
\r
1341 xUploadArea.y0 = PSXDisplay.DisplayPosition.y;
\r
1343 if (imageY0 > PSXDisplay.DisplayEnd.y)
\r
1344 xUploadArea.y0 = PSXDisplay.DisplayEnd.y;
\r
1346 xUploadArea.y0 = imageY0;
\r
1348 if (imageY1 < PSXDisplay.DisplayPosition.y)
\r
1349 xUploadArea.y1 = PSXDisplay.DisplayPosition.y;
\r
1351 if (imageY1 > PSXDisplay.DisplayEnd.y)
\r
1352 xUploadArea.y1 = PSXDisplay.DisplayEnd.y;
\r
1354 xUploadArea.y1 = imageY1;
\r
1356 if ((xUploadArea.x0 != xUploadArea.x1) && (xUploadArea.y0 != xUploadArea.y1))
\r
1358 else return FALSE;
\r
1361 BOOL CheckAgainstFrontScreen(short imageX0,short imageY0,short imageX1,short imageY1)
\r
1363 imageX1 += imageX0;
\r
1364 imageY1 += imageY0;
\r
1366 if (imageX0 < PSXDisplay.DisplayPosition.x)
\r
1367 xrUploadArea.x0 = PSXDisplay.DisplayPosition.x;
\r
1369 if (imageX0 > PSXDisplay.DisplayEnd.x)
\r
1370 xrUploadArea.x0 = PSXDisplay.DisplayEnd.x;
\r
1372 xrUploadArea.x0 = imageX0;
\r
1374 if(imageX1 < PSXDisplay.DisplayPosition.x)
\r
1375 xrUploadArea.x1 = PSXDisplay.DisplayPosition.x;
\r
1377 if (imageX1 > PSXDisplay.DisplayEnd.x)
\r
1378 xrUploadArea.x1 = PSXDisplay.DisplayEnd.x;
\r
1380 xrUploadArea.x1 = imageX1;
\r
1382 if (imageY0 < PSXDisplay.DisplayPosition.y)
\r
1383 xrUploadArea.y0 = PSXDisplay.DisplayPosition.y;
\r
1385 if (imageY0 > PSXDisplay.DisplayEnd.y)
\r
1386 xrUploadArea.y0 = PSXDisplay.DisplayEnd.y;
\r
1388 xrUploadArea.y0 = imageY0;
\r
1390 if (imageY1 < PSXDisplay.DisplayPosition.y)
\r
1391 xrUploadArea.y1 = PSXDisplay.DisplayPosition.y;
\r
1393 if (imageY1 > PSXDisplay.DisplayEnd.y)
\r
1394 xrUploadArea.y1 = PSXDisplay.DisplayEnd.y;
\r
1396 xrUploadArea.y1 = imageY1;
\r
1398 if ((xrUploadArea.x0 != xrUploadArea.x1) && (xrUploadArea.y0 != xrUploadArea.y1))
\r
1400 else return FALSE;
\r
1403 ////////////////////////////////////////////////////////////////////////
\r
1405 void PrepareFullScreenUpload (long Position)
\r
1407 if (Position==-1) // rgb24
\r
1409 if(PSXDisplay.Interlaced)
\r
1411 xrUploadArea.x0 = PSXDisplay.DisplayPosition.x;
\r
1412 xrUploadArea.x1 = PSXDisplay.DisplayEnd.x;
\r
1413 xrUploadArea.y0 = PSXDisplay.DisplayPosition.y;
\r
1414 xrUploadArea.y1 = PSXDisplay.DisplayEnd.y;
\r
1418 xrUploadArea.x0 = PreviousPSXDisplay.DisplayPosition.x;
\r
1419 xrUploadArea.x1 = PreviousPSXDisplay.DisplayEnd.x;
\r
1420 xrUploadArea.y0 = PreviousPSXDisplay.DisplayPosition.y;
\r
1421 xrUploadArea.y1 = PreviousPSXDisplay.DisplayEnd.y;
\r
1424 if(bNeedRGB24Update)
\r
1428 // lClearOnSwap=0;
\r
1431 if(PSXDisplay.Interlaced && PreviousPSXDisplay.RGB24<2) // in interlaced mode we upload at least two full frames (GT1 menu)
\r
1433 PreviousPSXDisplay.RGB24++;
\r
1437 xrUploadArea.y1 = min(xrUploadArea.y0+xrUploadAreaRGB24.y1,xrUploadArea.y1);
\r
1438 xrUploadArea.y0+=xrUploadAreaRGB24.y0;
\r
1445 xrUploadArea.x0 = PSXDisplay.DisplayPosition.x;
\r
1446 xrUploadArea.x1 = PSXDisplay.DisplayEnd.x;
\r
1447 xrUploadArea.y0 = PSXDisplay.DisplayPosition.y;
\r
1448 xrUploadArea.y1 = PSXDisplay.DisplayEnd.y;
\r
1452 xrUploadArea.x0 = PreviousPSXDisplay.DisplayPosition.x;
\r
1453 xrUploadArea.x1 = PreviousPSXDisplay.DisplayEnd.x;
\r
1454 xrUploadArea.y0 = PreviousPSXDisplay.DisplayPosition.y;
\r
1455 xrUploadArea.y1 = PreviousPSXDisplay.DisplayEnd.y;
\r
1458 if (xrUploadArea.x0 < 0) xrUploadArea.x0 = 0;
\r
1460 if (xrUploadArea.x0 > 1023) xrUploadArea.x0 = 1023;
\r
1462 if (xrUploadArea.x1 < 0) xrUploadArea.x1 = 0;
\r
1464 if (xrUploadArea.x1 > 1024) xrUploadArea.x1 = 1024;
\r
1466 if (xrUploadArea.y0 < 0) xrUploadArea.y0 = 0;
\r
1468 if (xrUploadArea.y0 > iGPUHeightMask) xrUploadArea.y0 = iGPUHeightMask;
\r
1470 if (xrUploadArea.y1 < 0) xrUploadArea.y1 = 0;
\r
1472 if (xrUploadArea.y1 > iGPUHeight) xrUploadArea.y1 = iGPUHeight;
\r
1474 if (PSXDisplay.RGB24)
\r
1476 InvalidateTextureArea(xrUploadArea.x0,xrUploadArea.y0,xrUploadArea.x1-xrUploadArea.x0,xrUploadArea.y1-xrUploadArea.y0);
\r
1480 ////////////////////////////////////////////////////////////////////////
\r
1481 // Upload screen (MDEC and such)
\r
1482 ////////////////////////////////////////////////////////////////////////
\r
1483 ////////////////////////////////////////////////////////////////////////
\r
1485 unsigned char * LoadDirectMovieFast(void);
\r
1487 void UploadScreenEx(long Position)
\r
1489 short ya,yb,xa,xb,x, y, YStep, XStep, U, UStep,ux[4],vy[4];
\r
1491 if(!PSXDisplay.DisplayMode.x) return;
\r
1492 if(!PSXDisplay.DisplayMode.y) return;
\r
1494 glDisable(GL_SCISSOR_TEST); glError();
\r
1495 glShadeModel(GL_FLAT); glError();
\r
1496 bOldSmoothShaded=FALSE;
\r
1497 glDisable(GL_BLEND); glError();
\r
1498 bBlendEnable=FALSE;
\r
1499 glDisable(GL_TEXTURE_2D); glError();
\r
1500 bTexEnabled=FALSE;
\r
1501 glDisable(GL_ALPHA_TEST); glError();
\r
1503 //glPixelZoom(((float)rRatioRect.right)/((float)PSXDisplay.DisplayMode.x),
\r
1504 // -1.0f*(((float)rRatioRect.bottom)/((float)PSXDisplay.DisplayMode.y)));
\r
1506 //----------------------------------------------------//
\r
1508 YStep = 256; // max texture size
\r
1510 UStep = (PSXDisplay.RGB24 ? 128 : 0);
\r
1511 ya = xrUploadArea.y0;
\r
1512 yb = xrUploadArea.y1;
\r
1513 xa = xrUploadArea.x0;
\r
1514 xb = xrUploadArea.x1;
\r
1516 for(y=ya;y<=yb;y+=YStep) // loop y
\r
1519 for(x=xa;x<=xb;x+=XStep) // loop x
\r
1521 ly0 = ly1 = y; // -> get y coords
\r
1523 if (ly2 > yb) ly2 = yb;
\r
1526 lx0 = lx3 = x; // -> get x coords
\r
1528 if (lx1 > xb) lx1 = xb;
\r
1532 ux[0]=ux[3]=(xa - x); // -> set tex x coords
\r
1533 if (ux[0] < 0) ux[0]=ux[3]=0;
\r
1534 ux[2]=ux[1]=(xb - x);
\r
1535 if (ux[2] > 256) ux[2]=ux[1]=256;
\r
1537 vy[0]=vy[1]=(ya - y); // -> set tex y coords
\r
1538 if (vy[0] < 0) vy[0]=vy[1]=0;
\r
1539 vy[2]=vy[3]=(yb - y);
\r
1540 if (vy[2] > 256) vy[2]=vy[3]=256;
\r
1542 if ((ux[0] >= ux[2]) || // -> cheaters never win...
\r
1543 (vy[0] >= vy[2])) continue; // (but winners always cheat...)
\r
1545 xrMovieArea.x0=lx0+U; xrMovieArea.y0=ly0;
\r
1546 xrMovieArea.x1=lx2+U; xrMovieArea.y1=ly2;
\r
1548 offsetScreenUpload(Position);
\r
1550 //glRasterPos2f(vertex[0].x,vertex[0].y);
\r
1552 //glDrawPixels(xrMovieArea.x1-xrMovieArea.x0,
\r
1553 // xrMovieArea.y1-xrMovieArea.y0,
\r
1554 // GL_RGBA,GL_UNSIGNED_BYTE,
\r
1555 LoadDirectMovieFast();//);
\r
1561 //----------------------------------------------------//
\r
1563 // glPixelZoom(1.0F,1.0F);
\r
1565 glEnable(GL_ALPHA_TEST); glError();
\r
1566 glEnable(GL_SCISSOR_TEST); glError();
\r
1569 ////////////////////////////////////////////////////////////////////////
\r
1571 void UploadScreen(long Position)
\r
1573 short x, y, YStep, XStep, U, s, UStep,ux[4],vy[4];
\r
1574 short xa,xb,ya,yb;
\r
1576 if(xrUploadArea.x0>1023) xrUploadArea.x0=1023;
\r
1577 if(xrUploadArea.x1>1024) xrUploadArea.x1=1024;
\r
1578 if(xrUploadArea.y0>iGPUHeightMask) xrUploadArea.y0=iGPUHeightMask;
\r
1579 if(xrUploadArea.y1>iGPUHeight) xrUploadArea.y1=iGPUHeight;
\r
1581 if(xrUploadArea.x0==xrUploadArea.x1) return;
\r
1582 if(xrUploadArea.y0==xrUploadArea.y1) return;
\r
1584 if(PSXDisplay.Disabled && iOffscreenDrawing<4) return;
\r
1586 iDrawnSomething = 2;
\r
1587 iLastRGB24=PSXDisplay.RGB24+1;
\r
1589 if(bSkipNextFrame) return;
\r
1591 if(dwActFixes & 2) {UploadScreenEx(Position);return;}
\r
1593 bUsingMovie = TRUE;
\r
1594 bDrawTextured = TRUE; // just doing textures
\r
1595 bDrawSmoothShaded = FALSE;
\r
1597 /* if(bGLBlend) vertex[0].c.lcol=0xff7f7f7f; // set solid col
\r
1598 else */vertex[0].c.lcol=0xffffffff;
\r
1599 SETCOL(vertex[0]);
\r
1601 SetOGLDisplaySettings(0);
\r
1603 YStep = 256; // max texture size
\r
1606 UStep = (PSXDisplay.RGB24 ? 128 : 0);
\r
1608 ya=xrUploadArea.y0;
\r
1609 yb=xrUploadArea.y1;
\r
1610 xa=xrUploadArea.x0;
\r
1611 xb=xrUploadArea.x1;
\r
1613 for(y=ya;y<=yb;y+=YStep) // loop y
\r
1616 for(x=xa;x<=xb;x+=XStep) // loop x
\r
1618 ly0 = ly1 = y; // -> get y coords
\r
1620 if (ly2 > yb) ly2 = yb;
\r
1623 lx0 = lx3 = x; // -> get x coords
\r
1625 if (lx1 > xb) lx1 = xb;
\r
1629 ux[0]=ux[3]=(xa - x); // -> set tex x coords
\r
1630 if (ux[0] < 0) ux[0]=ux[3]=0;
\r
1631 ux[2]=ux[1]=(xb - x);
\r
1632 if (ux[2] > 256) ux[2]=ux[1]=256;
\r
1634 vy[0]=vy[1]=(ya - y); // -> set tex y coords
\r
1635 if (vy[0] < 0) vy[0]=vy[1]=0;
\r
1636 vy[2]=vy[3]=(yb - y);
\r
1637 if (vy[2] > 256) vy[2]=vy[3]=256;
\r
1639 if ((ux[0] >= ux[2]) || // -> cheaters never win...
\r
1640 (vy[0] >= vy[2])) continue; // (but winners always cheat...)
\r
1642 xrMovieArea.x0=lx0+U; xrMovieArea.y0=ly0;
\r
1643 xrMovieArea.x1=lx2+U; xrMovieArea.y1=ly2;
\r
1645 s=ux[2] - ux[0]; if(s>255) s=255;
\r
1647 gl_ux[2] = gl_ux[1] = s;
\r
1648 s=vy[2] - vy[0]; if(s>255) s=255;
\r
1649 gl_vy[2] = gl_vy[3] = s;
\r
1650 gl_ux[0] = gl_ux[3] = gl_vy[0] = gl_vy[1] = 0;
\r
1652 SetRenderState((unsigned long)0x01000000);
\r
1653 SetRenderMode((unsigned long)0x01000000, FALSE); // upload texture data
\r
1654 offsetScreenUpload(Position);
\r
1655 assignTextureVRAMWrite();
\r
1657 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
1663 bUsingMovie=FALSE; // done...
\r
1664 bDisplayNotSet = TRUE;
\r
1667 ////////////////////////////////////////////////////////////////////////
\r
1668 // Detect next screen
\r
1669 ////////////////////////////////////////////////////////////////////////
\r
1671 BOOL IsCompleteInsideNextScreen(short x, short y, short xoff, short yoff)
\r
1673 if (x > PSXDisplay.DisplayPosition.x+1) return FALSE;
\r
1674 if ((x + xoff) < PSXDisplay.DisplayEnd.x-1) return FALSE;
\r
1676 if (y >= PSXDisplay.DisplayPosition.y &&
\r
1677 y <= PSXDisplay.DisplayEnd.y )
\r
1679 if ((yoff) >= PSXDisplay.DisplayPosition.y &&
\r
1680 (yoff) <= PSXDisplay.DisplayEnd.y ) return TRUE;
\r
1682 if (y > PSXDisplay.DisplayPosition.y+1) return FALSE;
\r
1683 if (yoff < PSXDisplay.DisplayEnd.y-1) return FALSE;
\r
1687 BOOL IsPrimCompleteInsideNextScreen(short x, short y, short xoff, short yoff)
\r
1689 x+=PSXDisplay.DrawOffset.x;
\r
1690 if (x > PSXDisplay.DisplayPosition.x+1) return FALSE;
\r
1691 y+=PSXDisplay.DrawOffset.y;
\r
1692 if (y > PSXDisplay.DisplayPosition.y+1) return FALSE;
\r
1693 xoff+=PSXDisplay.DrawOffset.x;
\r
1694 if (xoff < PSXDisplay.DisplayEnd.x-1) return FALSE;
\r
1695 yoff+=PSXDisplay.DrawOffset.y;
\r
1696 if (yoff < PSXDisplay.DisplayEnd.y-1) return FALSE;
\r
1700 BOOL IsInsideNextScreen(short x, short y, short xoff, short yoff)
\r
1702 if (x > PSXDisplay.DisplayEnd.x) return FALSE;
\r
1703 if (y > PSXDisplay.DisplayEnd.y) return FALSE;
\r
1704 if ((x + xoff) < PSXDisplay.DisplayPosition.x) return FALSE;
\r
1705 if ((y + yoff) < PSXDisplay.DisplayPosition.y) return FALSE;
\r
1709 ////////////////////////////////////////////////////////////////////////
\r
1711 ////////////////////////////////////////////////////////////////////////
\r
1713 //Mask1 Set mask bit while drawing. 1 = on
\r
1714 //Mask2 Do not draw to mask areas. 1= on
\r
1716 void cmdSTP(unsigned char * baseAddr)
\r
1718 unsigned long gdata = ((unsigned long*)baseAddr)[0];
\r
1720 STATUSREG&=~0x1800; // clear the necessary bits
\r
1721 STATUSREG|=((gdata & 0x03) << 11); // set the current bits
\r
1723 if(!iUseMask) return;
\r
1725 if(gdata&1) {sSetMask=0x8000;lSetMask=0x80008000;iSetMask=1;}
\r
1726 else {sSetMask=0; lSetMask=0; iSetMask=0;}
\r
1730 if(!(gdata&1)) iSetMask=2;
\r
1732 if(iDepthFunc==0) return;
\r
1734 glDepthFunc(GL_LESS); glError();
\r
1739 if(iDepthFunc==1) return;
\r
1740 glDepthFunc(GL_ALWAYS); glError();
\r
1745 ////////////////////////////////////////////////////////////////////////
\r
1746 // cmd: Set texture page infos
\r
1747 ////////////////////////////////////////////////////////////////////////
\r
1749 void cmdTexturePage(unsigned char * baseAddr)
\r
1751 unsigned long gdata = ((unsigned long*)baseAddr)[0];
\r
1752 UpdateGlobalTP((unsigned short)gdata);
\r
1753 GlobalTextREST = (gdata&0x00ffffff)>>9;
\r
1756 ////////////////////////////////////////////////////////////////////////
\r
1757 // cmd: turn on/off texture window
\r
1758 ////////////////////////////////////////////////////////////////////////
\r
1760 void cmdTextureWindow(unsigned char *baseAddr)
\r
1762 unsigned long gdata = ((unsigned long*)baseAddr)[0];
\r
1764 unsigned long YAlign,XAlign;
\r
1766 ulGPUInfoVals[INFO_TW]=gdata&0xFFFFF;
\r
1769 TWin.Position.y1 = 8; // xxxx1
\r
1770 else if (gdata & 0x040)
\r
1771 TWin.Position.y1 = 16; // xxx10
\r
1772 else if (gdata & 0x080)
\r
1773 TWin.Position.y1 = 32; // xx100
\r
1774 else if (gdata & 0x100)
\r
1775 TWin.Position.y1 = 64; // x1000
\r
1776 else if (gdata & 0x200)
\r
1777 TWin.Position.y1 = 128; // 10000
\r
1779 TWin.Position.y1 = 256; // 00000
\r
1781 // Texture window size is determined by the least bit set of the relevant 5 bits
\r
1783 if (gdata & 0x001)
\r
1784 TWin.Position.x1 = 8; // xxxx1
\r
1785 else if (gdata & 0x002)
\r
1786 TWin.Position.x1 = 16; // xxx10
\r
1787 else if (gdata & 0x004)
\r
1788 TWin.Position.x1 = 32; // xx100
\r
1789 else if (gdata & 0x008)
\r
1790 TWin.Position.x1 = 64; // x1000
\r
1791 else if (gdata & 0x010)
\r
1792 TWin.Position.x1 = 128; // 10000
\r
1794 TWin.Position.x1 = 256; // 00000
\r
1796 // Re-calculate the bit field, because we can't trust what is passed in the data
\r
1798 YAlign = (unsigned long)(32 - (TWin.Position.y1 >> 3));
\r
1799 XAlign = (unsigned long)(32 - (TWin.Position.x1 >> 3));
\r
1801 // Absolute position of the start of the texture window
\r
1803 TWin.Position.y0 = (short)(((gdata >> 15) & YAlign) << 3);
\r
1804 TWin.Position.x0 = (short)(((gdata >> 10) & XAlign) << 3);
\r
1806 if((TWin.Position.x0 == 0 && // tw turned off
\r
1807 TWin.Position.y0 == 0 &&
\r
1808 TWin.Position.x1 == 0 &&
\r
1809 TWin.Position.y1 == 0) ||
\r
1810 (TWin.Position.x1 == 256 &&
\r
1811 TWin.Position.y1 == 256))
\r
1813 bUsingTWin = FALSE; // -> just do it
\r
1816 TWin.UScaleFactor = 1.0f;
\r
1817 TWin.VScaleFactor = 1.0f;
\r
1819 TWin.UScaleFactor =
\r
1820 TWin.VScaleFactor = 1.0f/256.0f;
\r
1823 else // tw turned on
\r
1825 bUsingTWin = TRUE;
\r
1827 TWin.OPosition.y1 = TWin.Position.y1; // -> get psx sizes
\r
1828 TWin.OPosition.x1 = TWin.Position.x1;
\r
1830 if(TWin.Position.x1<=2) TWin.Position.x1=2; // -> set OGL sizes
\r
1832 if(TWin.Position.x1<=4) TWin.Position.x1=4;
\r
1834 if(TWin.Position.x1<=8) TWin.Position.x1=8;
\r
1836 if(TWin.Position.x1<=16) TWin.Position.x1=16;
\r
1838 if(TWin.Position.x1<=32) TWin.Position.x1=32;
\r
1840 if(TWin.Position.x1<=64) TWin.Position.x1=64;
\r
1842 if(TWin.Position.x1<=128) TWin.Position.x1=128;
\r
1844 if(TWin.Position.x1<=256) TWin.Position.x1=256;
\r
1846 if(TWin.Position.y1<=2) TWin.Position.y1=2;
\r
1848 if(TWin.Position.y1<=4) TWin.Position.y1=4;
\r
1850 if(TWin.Position.y1<=8) TWin.Position.y1=8;
\r
1852 if(TWin.Position.y1<=16) TWin.Position.y1=16;
\r
1854 if(TWin.Position.y1<=32) TWin.Position.y1=32;
\r
1856 if(TWin.Position.y1<=64) TWin.Position.y1=64;
\r
1858 if(TWin.Position.y1<=128) TWin.Position.y1=128;
\r
1860 if(TWin.Position.y1<=256) TWin.Position.y1=256;
\r
1863 TWin.UScaleFactor = (float)TWin.Position.x1;
\r
1864 TWin.VScaleFactor = (float)TWin.Position.y1;
\r
1866 TWin.UScaleFactor = ((float)TWin.Position.x1)/256.0f; // -> set scale factor
\r
1867 TWin.VScaleFactor = ((float)TWin.Position.y1)/256.0f;
\r
1872 ////////////////////////////////////////////////////////////////////////
\r
1873 // mmm, Lewpy uses that in TileS ... I don't ;)
\r
1874 ////////////////////////////////////////////////////////////////////////
\r
1877 void ClampToPSXDrawAreaOffset(short *x0, short *y0, short *x1, short *y1)
\r
1879 if (*x0 < PSXDisplay.DrawArea.x0)
\r
1881 *x1 -= (PSXDisplay.DrawArea.x0 - *x0);
\r
1882 *x0 = PSXDisplay.DrawArea.x0;
\r
1885 if (*x0 > PSXDisplay.DrawArea.x1)
\r
1887 *x0 = PSXDisplay.DrawArea.x1;
\r
1891 if (*y0 < PSXDisplay.DrawArea.y0)
\r
1893 *y1 -= (PSXDisplay.DrawArea.y0 - *y0);
\r
1894 *y0 = PSXDisplay.DrawArea.y0;
\r
1897 if (*y0 > PSXDisplay.DrawArea.y1)
\r
1899 *y0 = PSXDisplay.DrawArea.y1;
\r
1903 if (*x1 < 0) *x1 = 0;
\r
1905 if ((*x1 + *x0) > PSXDisplay.DrawArea.x1)
\r
1906 *x1 = (PSXDisplay.DrawArea.x1 - *x0 + 1);
\r
1908 if (*y1 < 0) *y1 = 0;
\r
1910 if ((*y1 + *y0) > PSXDisplay.DrawArea.y1)
\r
1911 *y1 = (PSXDisplay.DrawArea.y1 - *y0 + 1);
\r
1915 ////////////////////////////////////////////////////////////////////////
\r
1916 // Check draw area dimensions
\r
1917 ////////////////////////////////////////////////////////////////////////
\r
1919 void ClampToPSXScreen(short *x0, short *y0, short *x1, short *y1)
\r
1921 if (*x0 < 0) *x0 = 0;
\r
1923 if (*x0 > 1023) *x0 = 1023;
\r
1925 if (*x1 < 0) *x1 = 0;
\r
1927 if (*x1 > 1023) *x1 = 1023;
\r
1929 if (*y0 < 0) *y0 = 0;
\r
1931 if (*y0 > iGPUHeightMask) *y0 = iGPUHeightMask;
\r
1933 if (*y1 < 0) *y1 = 0;
\r
1935 if (*y1 > iGPUHeightMask) *y1 = iGPUHeightMask;
\r
1938 ////////////////////////////////////////////////////////////////////////
\r
1939 // Used in Load Image and Blk Fill
\r
1940 ////////////////////////////////////////////////////////////////////////
\r
1942 void ClampToPSXScreenOffset(short *x0, short *y0, short *x1, short *y1)
\r
1945 { *x1 += *x0; *x0 = 0; }
\r
1948 { *x0 = 1023; *x1 = 0; }
\r
1951 { *y1 += *y0; *y0 = 0; }
\r
1953 if (*y0 > iGPUHeightMask)
\r
1954 { *y0 = iGPUHeightMask; *y1 = 0; }
\r
1956 if (*x1 < 0) *x1 = 0;
\r
1958 if ((*x1 + *x0) > 1024) *x1 = (1024 - *x0);
\r
1960 if (*y1 < 0) *y1 = 0;
\r
1962 if ((*y1 + *y0) > iGPUHeight) *y1 = (iGPUHeight - *y0);
\r
1965 ////////////////////////////////////////////////////////////////////////
\r
1966 // cmd: start of drawing area... primitives will be clipped inside
\r
1967 ////////////////////////////////////////////////////////////////////////
\r
1969 void cmdDrawAreaStart(unsigned char * baseAddr)
\r
1971 unsigned long gdata = ((unsigned long*)baseAddr)[0];
\r
1973 drawX = gdata & 0x3ff; // for soft drawing
\r
1974 if(drawX>=1024) drawX=1023;
\r
1976 if(dwGPUVersion==2)
\r
1978 ulGPUInfoVals[INFO_DRAWSTART]=gdata&0x3FFFFF;
\r
1979 drawY = (gdata>>12)&0x3ff;
\r
1983 ulGPUInfoVals[INFO_DRAWSTART]=gdata&0xFFFFF;
\r
1984 drawY = (gdata>>10)&0x3ff;
\r
1987 if(drawY>=iGPUHeight) drawY=iGPUHeightMask;
\r
1989 PreviousPSXDisplay.DrawArea.y0=PSXDisplay.DrawArea.y0;
\r
1990 PreviousPSXDisplay.DrawArea.x0=PSXDisplay.DrawArea.x0;
\r
1992 PSXDisplay.DrawArea.y0 = (short)drawY; // for OGL drawing
\r
1993 PSXDisplay.DrawArea.x0 = (short)drawX;
\r
1996 ////////////////////////////////////////////////////////////////////////
\r
1997 // cmd: end of drawing area... primitives will be clipped inside
\r
1998 ////////////////////////////////////////////////////////////////////////
\r
2000 void cmdDrawAreaEnd(unsigned char * baseAddr)
\r
2002 unsigned long gdata = ((unsigned long*)baseAddr)[0];
\r
2004 drawW = gdata & 0x3ff; // for soft drawing
\r
2005 if(drawW>=1024) drawW=1023;
\r
2007 if(dwGPUVersion==2)
\r
2009 ulGPUInfoVals[INFO_DRAWEND]=gdata&0x3FFFFF;
\r
2010 drawH = (gdata>>12)&0x3ff;
\r
2014 ulGPUInfoVals[INFO_DRAWEND]=gdata&0xFFFFF;
\r
2015 drawH = (gdata>>10)&0x3ff;
\r
2018 if(drawH>=iGPUHeight) drawH=iGPUHeightMask;
\r
2020 PSXDisplay.DrawArea.y1 = (short)drawH; // for OGL drawing
\r
2021 PSXDisplay.DrawArea.x1 = (short)drawW;
\r
2023 ClampToPSXScreen(&PSXDisplay.DrawArea.x0, // clamp
\r
2024 &PSXDisplay.DrawArea.y0,
\r
2025 &PSXDisplay.DrawArea.x1,
\r
2026 &PSXDisplay.DrawArea.y1);
\r
2028 bDisplayNotSet = TRUE;
\r
2031 ////////////////////////////////////////////////////////////////////////
\r
2032 // cmd: draw offset... will be added to prim coords
\r
2033 ////////////////////////////////////////////////////////////////////////
\r
2035 void cmdDrawOffset(unsigned char * baseAddr)
\r
2037 unsigned long gdata = ((unsigned long*)baseAddr)[0];
\r
2039 PreviousPSXDisplay.DrawOffset.x =
\r
2040 PSXDisplay.DrawOffset.x = (short)(gdata & 0x7ff);
\r
2042 if(dwGPUVersion==2)
\r
2044 ulGPUInfoVals[INFO_DRAWOFF]=gdata&0x7FFFFF;
\r
2045 PSXDisplay.DrawOffset.y = (short)((gdata>>12) & 0x7ff);
\r
2049 ulGPUInfoVals[INFO_DRAWOFF]=gdata&0x3FFFFF;
\r
2050 PSXDisplay.DrawOffset.y = (short)((gdata>>11) & 0x7ff);
\r
2053 PSXDisplay.DrawOffset.x=(short)(((int)PSXDisplay.DrawOffset.x<<21)>>21);
\r
2054 PSXDisplay.DrawOffset.y=(short)(((int)PSXDisplay.DrawOffset.y<<21)>>21);
\r
2056 PSXDisplay.CumulOffset.x = // new OGL prim offsets
\r
2057 PSXDisplay.DrawOffset.x - PSXDisplay.GDrawOffset.x + PreviousPSXDisplay.Range.x0;
\r
2058 PSXDisplay.CumulOffset.y =
\r
2059 PSXDisplay.DrawOffset.y - PSXDisplay.GDrawOffset.y + PreviousPSXDisplay.Range.y0;
\r
2062 ////////////////////////////////////////////////////////////////////////
\r
2063 // cmd: load image to vram
\r
2064 ////////////////////////////////////////////////////////////////////////
\r
2066 void primLoadImage(unsigned char * baseAddr)
\r
2068 unsigned short *sgpuData = ((unsigned short *) baseAddr);
\r
2070 VRAMWrite.x = sgpuData[2]&0x03ff;
\r
2071 VRAMWrite.y = sgpuData[3]&iGPUHeightMask;
\r
2072 VRAMWrite.Width = sgpuData[4];
\r
2073 VRAMWrite.Height = sgpuData[5];
\r
2075 iDataWriteMode = DR_VRAMTRANSFER;
\r
2076 VRAMWrite.ImagePtr = psxVuw + (VRAMWrite.y<<10) + VRAMWrite.x;
\r
2077 VRAMWrite.RowsRemaining = VRAMWrite.Width;
\r
2078 VRAMWrite.ColsRemaining = VRAMWrite.Height;
\r
2080 bNeedWriteUpload=TRUE;
\r
2083 ////////////////////////////////////////////////////////////////////////
\r
2085 void PrepareRGB24Upload(void)
\r
2087 VRAMWrite.x=(VRAMWrite.x*2)/3;
\r
2088 VRAMWrite.Width=(VRAMWrite.Width*2)/3;
\r
2090 if(!PSXDisplay.InterlacedTest && // NEW
\r
2091 CheckAgainstScreen(VRAMWrite.x, VRAMWrite.y, VRAMWrite.Width, VRAMWrite.Height))
\r
2093 xrUploadArea.x0-=PreviousPSXDisplay.DisplayPosition.x;
\r
2094 xrUploadArea.x1-=PreviousPSXDisplay.DisplayPosition.x;
\r
2095 xrUploadArea.y0-=PreviousPSXDisplay.DisplayPosition.y;
\r
2096 xrUploadArea.y1-=PreviousPSXDisplay.DisplayPosition.y;
\r
2099 if(CheckAgainstFrontScreen(VRAMWrite.x, VRAMWrite.y, VRAMWrite.Width, VRAMWrite.Height))
\r
2101 xrUploadArea.x0-=PSXDisplay.DisplayPosition.x;
\r
2102 xrUploadArea.x1-=PSXDisplay.DisplayPosition.x;
\r
2103 xrUploadArea.y0-=PSXDisplay.DisplayPosition.y;
\r
2104 xrUploadArea.y1-=PSXDisplay.DisplayPosition.y;
\r
2108 if(bRenderFrontBuffer)
\r
2110 updateFrontDisplay();
\r
2113 if(bNeedRGB24Update==FALSE)
\r
2115 xrUploadAreaRGB24=xrUploadArea;
\r
2116 bNeedRGB24Update=TRUE;
\r
2120 xrUploadAreaRGB24.x0=min(xrUploadAreaRGB24.x0,xrUploadArea.x0);
\r
2121 xrUploadAreaRGB24.x1=max(xrUploadAreaRGB24.x1,xrUploadArea.x1);
\r
2122 xrUploadAreaRGB24.y0=min(xrUploadAreaRGB24.y0,xrUploadArea.y0);
\r
2123 xrUploadAreaRGB24.y1=max(xrUploadAreaRGB24.y1,xrUploadArea.y1);
\r
2127 ////////////////////////////////////////////////////////////////////////
\r
2129 void CheckWriteUpdate()
\r
2133 if(VRAMWrite.Width) iX=1;
\r
2134 if(VRAMWrite.Height) iY=1;
\r
2136 InvalidateTextureArea(VRAMWrite.x, VRAMWrite.y, VRAMWrite.Width-iX, VRAMWrite.Height-iY);
\r
2138 if(PSXDisplay.Interlaced && !iOffscreenDrawing) return;
\r
2140 if(PSXDisplay.RGB24) {PrepareRGB24Upload();return;}
\r
2142 if(!PSXDisplay.InterlacedTest &&
\r
2143 CheckAgainstScreen(VRAMWrite.x, VRAMWrite.y, VRAMWrite.Width, VRAMWrite.Height))
\r
2145 if(dwActFixes&0x800) return;
\r
2147 if(bRenderFrontBuffer)
\r
2149 updateFrontDisplay();
\r
2152 UploadScreen(FALSE);
\r
2154 bNeedUploadTest=TRUE;
\r
2157 if(iOffscreenDrawing)
\r
2159 if (CheckAgainstFrontScreen(VRAMWrite.x, VRAMWrite.y, VRAMWrite.Width, VRAMWrite.Height))
\r
2161 if(PSXDisplay.InterlacedTest)
\r
2163 if(PreviousPSXDisplay.InterlacedNew)
\r
2165 PreviousPSXDisplay.InterlacedNew=FALSE;
\r
2166 bNeedInterlaceUpdate=TRUE;
\r
2167 xrUploadAreaIL.x0=PSXDisplay.DisplayPosition.x;
\r
2168 xrUploadAreaIL.y0=PSXDisplay.DisplayPosition.y;
\r
2169 xrUploadAreaIL.x1=PSXDisplay.DisplayPosition.x+PSXDisplay.DisplayModeNew.x;
\r
2170 xrUploadAreaIL.y1=PSXDisplay.DisplayPosition.y+PSXDisplay.DisplayModeNew.y;
\r
2171 if(xrUploadAreaIL.x1>1023) xrUploadAreaIL.x1=1023;
\r
2172 if(xrUploadAreaIL.y1>511) xrUploadAreaIL.y1=511;
\r
2175 if(bNeedInterlaceUpdate==FALSE)
\r
2177 xrUploadAreaIL=xrUploadArea;
\r
2178 bNeedInterlaceUpdate=TRUE;
\r
2182 xrUploadAreaIL.x0=min(xrUploadAreaIL.x0,xrUploadArea.x0);
\r
2183 xrUploadAreaIL.x1=max(xrUploadAreaIL.x1,xrUploadArea.x1);
\r
2184 xrUploadAreaIL.y0=min(xrUploadAreaIL.y0,xrUploadArea.y0);
\r
2185 xrUploadAreaIL.y1=max(xrUploadAreaIL.y1,xrUploadArea.y1);
\r
2190 if(!bNeedUploadAfter)
\r
2192 bNeedUploadAfter = TRUE;
\r
2193 xrUploadArea.x0=VRAMWrite.x;
\r
2194 xrUploadArea.x1=VRAMWrite.x+VRAMWrite.Width;
\r
2195 xrUploadArea.y0=VRAMWrite.y;
\r
2196 xrUploadArea.y1=VRAMWrite.y+VRAMWrite.Height;
\r
2200 xrUploadArea.x0=min(xrUploadArea.x0,VRAMWrite.x);
\r
2201 xrUploadArea.x1=max(xrUploadArea.x1,VRAMWrite.x+VRAMWrite.Width);
\r
2202 xrUploadArea.y0=min(xrUploadArea.y0,VRAMWrite.y);
\r
2203 xrUploadArea.y1=max(xrUploadArea.y1,VRAMWrite.y+VRAMWrite.Height);
\r
2206 if(dwActFixes&0x8000)
\r
2208 if((xrUploadArea.x1-xrUploadArea.x0)>=(PSXDisplay.DisplayMode.x-32) &&
\r
2209 (xrUploadArea.y1-xrUploadArea.y0)>=(PSXDisplay.DisplayMode.y-32))
\r
2212 updateFrontDisplay();
\r
2219 ////////////////////////////////////////////////////////////////////////
\r
2220 // cmd: vram -> psx mem
\r
2221 ////////////////////////////////////////////////////////////////////////
\r
2223 void primStoreImage(unsigned char * baseAddr)
\r
2225 unsigned short *sgpuData = ((unsigned short *) baseAddr);
\r
2227 VRAMRead.x = sgpuData[2]&0x03ff;
\r
2228 VRAMRead.y = sgpuData[3]&iGPUHeightMask;
\r
2229 VRAMRead.Width = sgpuData[4];
\r
2230 VRAMRead.Height = sgpuData[5];
\r
2232 VRAMRead.ImagePtr = psxVuw + (VRAMRead.y<<10) + VRAMRead.x;
\r
2233 VRAMRead.RowsRemaining = VRAMRead.Width;
\r
2234 VRAMRead.ColsRemaining = VRAMRead.Height;
\r
2236 iDataReadMode = DR_VRAMTRANSFER;
\r
2238 STATUSREG |= GPUSTATUS_READYFORVRAM;
\r
2241 ////////////////////////////////////////////////////////////////////////
\r
2242 // cmd: blkfill - NO primitive! Doesn't care about draw areas...
\r
2243 ////////////////////////////////////////////////////////////////////////
\r
2245 void primBlkFill(unsigned char * baseAddr)
\r
2247 unsigned long *gpuData = ((unsigned long *) baseAddr);
\r
2248 short *sgpuData = ((short *) baseAddr);
\r
2250 iDrawnSomething=1;
\r
2252 sprtX = sgpuData[2];
\r
2253 sprtY = sgpuData[3];
\r
2254 sprtW = sgpuData[4] & 0x3ff;
\r
2255 sprtH = sgpuData[5] & iGPUHeightMask;
\r
2257 sprtW = (sprtW+15) & ~15;
\r
2259 // Increase H & W if they are one short of full values, because they never can be full values
\r
2260 if (sprtH == iGPUHeightMask) sprtH=iGPUHeight;
\r
2261 if (sprtW == 1023) sprtW=1024;
\r
2263 // x and y of start
\r
2264 ly0 = ly1 = sprtY;
\r
2265 ly2 = ly3 = (sprtY+sprtH);
\r
2266 lx0 = lx3 = sprtX;
\r
2267 lx1 = lx2 = (sprtX+sprtW);
\r
2271 if(ClipVertexListScreen())
\r
2273 PSXDisplay_t * pd;
\r
2274 if(PSXDisplay.InterlacedTest) pd=&PSXDisplay;
\r
2275 else pd=&PreviousPSXDisplay;
\r
2277 if ((lx0 <= pd->DisplayPosition.x+16) &&
\r
2278 (ly0 <= pd->DisplayPosition.y+16) &&
\r
2279 (lx2 >= pd->DisplayEnd.x-16) &&
\r
2280 (ly2 >= pd->DisplayEnd.y-16))
\r
2283 g=((GLclampf)GREEN(gpuData[0]))/255.0f;
\r
2284 b=((GLclampf)BLUE(gpuData[0]))/255.0f;
\r
2285 r=((GLclampf)RED(gpuData[0]))/255.0f;
\r
2287 //glDisable(GL_SCISSOR_TEST); glError();
\r
2288 glClearColor(r,g,b,1.0f); glError();
\r
2289 glClear(uiBufferBits); glError();
\r
2292 if(gpuData[0]!=0x02000000 &&
\r
2293 (ly0>pd->DisplayPosition.y ||
\r
2294 ly2<pd->DisplayEnd.y))
\r
2296 bDrawTextured = FALSE;
\r
2297 bDrawSmoothShaded = FALSE;
\r
2298 SetRenderState((unsigned long)0x01000000);
\r
2299 SetRenderMode((unsigned long)0x01000000, FALSE);
\r
2300 vertex[0].c.lcol=0xff000000;
\r
2301 SETCOL(vertex[0]);
\r
2302 if(ly0>pd->DisplayPosition.y)
\r
2304 vertex[0].x=0;vertex[0].y=0;
\r
2305 vertex[1].x=pd->DisplayEnd.x-pd->DisplayPosition.x;vertex[1].y=0;
\r
2306 vertex[2].x=vertex[1].x;vertex[2].y=ly0-pd->DisplayPosition.y;
\r
2307 vertex[3].x=0;vertex[3].y=vertex[2].y;
\r
2308 PRIMdrawQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
2310 if(ly2<pd->DisplayEnd.y)
\r
2312 vertex[0].x=0;vertex[0].y=(pd->DisplayEnd.y-pd->DisplayPosition.y)-(pd->DisplayEnd.y-ly2);
\r
2313 vertex[1].x=pd->DisplayEnd.x-pd->DisplayPosition.x;vertex[1].y=vertex[0].y;
\r
2314 vertex[2].x=vertex[1].x;vertex[2].y=pd->DisplayEnd.y;
\r
2315 vertex[3].x=0;vertex[3].y=vertex[2].y;
\r
2316 PRIMdrawQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
2320 //glEnable(GL_SCISSOR_TEST); glError();
\r
2324 bDrawTextured = FALSE;
\r
2325 bDrawSmoothShaded = FALSE;
\r
2326 SetRenderState((unsigned long)0x01000000);
\r
2327 SetRenderMode((unsigned long)0x01000000, FALSE);
\r
2328 vertex[0].c.lcol=gpuData[0]|0xff000000;
\r
2329 SETCOL(vertex[0]);
\r
2330 //glDisable(GL_SCISSOR_TEST); glError();
\r
2331 PRIMdrawQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
2332 //glEnable(GL_SCISSOR_TEST); glError();
\r
2336 //mmm... will clean all stuff, also if not all _should_ be cleaned...
\r
2337 //if (IsInsideNextScreen(sprtX, sprtY, sprtW, sprtH))
\r
2339 if (IsCompleteInsideNextScreen(sprtX, sprtY, sprtW, sprtH))
\r
2341 lClearOnSwapColor = COLOR(gpuData[0]);
\r
2345 /* if(iOffscreenDrawing)
\r
2347 ClampToPSXScreenOffset( &sprtX, &sprtY, &sprtW, &sprtH);
\r
2348 if ((sprtW == 0) || (sprtH == 0)) return;
\r
2349 InvalidateTextureArea(sprtX, sprtY, sprtW-1, sprtH-1);
\r
2354 FillSoftwareArea(sprtX, sprtY, sprtW, sprtH, BGR24to16(gpuData[0]));
\r
2358 ////////////////////////////////////////////////////////////////////////
\r
2359 // cmd: move image vram -> vram
\r
2360 ////////////////////////////////////////////////////////////////////////
\r
2362 void MoveImageWrapped(short imageX0,short imageY0,
\r
2363 short imageX1,short imageY1,
\r
2364 short imageSX,short imageSY)
\r
2366 int i,j,imageXE,imageYE;
\r
2368 if(iFrameReadType&2)
\r
2370 imageXE=imageX0+imageSX;
\r
2371 imageYE=imageY0+imageSY;
\r
2373 if(imageYE>iGPUHeight && imageXE>1024)
\r
2375 CheckVRamRead(0,0,
\r
2377 (imageY0&iGPUHeightMask),
\r
2383 CheckVRamRead(0,imageY0,
\r
2385 (imageYE>iGPUHeight)?iGPUHeight:imageYE,
\r
2389 if(imageYE>iGPUHeight)
\r
2391 CheckVRamRead(imageX0,0,
\r
2392 (imageXE>1024)?1024:imageXE,
\r
2393 imageYE&iGPUHeightMask,
\r
2397 CheckVRamRead(imageX0,imageY0,
\r
2398 (imageXE>1024)?1024:imageXE,
\r
2399 (imageYE>iGPUHeight)?iGPUHeight:imageYE,
\r
2403 for(j=0;j<imageSY;j++)
\r
2404 for(i=0;i<imageSX;i++)
\r
2405 psxVuw [(1024*((imageY1+j)&iGPUHeightMask))+((imageX1+i)&0x3ff)]=
\r
2406 psxVuw[(1024*((imageY0+j)&iGPUHeightMask))+((imageX0+i)&0x3ff)];
\r
2408 if(!PSXDisplay.RGB24)
\r
2410 imageXE=imageX1+imageSX;
\r
2411 imageYE=imageY1+imageSY;
\r
2413 if(imageYE>iGPUHeight && imageXE>1024)
\r
2415 InvalidateTextureArea(0,0,
\r
2416 (imageXE&0x3ff)-1,
\r
2417 (imageYE&iGPUHeightMask)-1);
\r
2422 InvalidateTextureArea(0,imageY1,
\r
2423 (imageXE&0x3ff)-1,
\r
2424 ((imageYE>iGPUHeight)?iGPUHeight:imageYE)-imageY1-1);
\r
2427 if(imageYE>iGPUHeight)
\r
2429 InvalidateTextureArea(imageX1,0,
\r
2430 ((imageXE>1024)?1024:imageXE)-imageX1-1,
\r
2431 (imageYE&iGPUHeightMask)-1);
\r
2434 InvalidateTextureArea(imageX1,imageY1,
\r
2435 ((imageXE>1024)?1024:imageXE)-imageX1-1,
\r
2436 ((imageYE>iGPUHeight)?iGPUHeight:imageYE)-imageY1-1);
\r
2440 ////////////////////////////////////////////////////////////////////////
\r
2442 void primMoveImage(unsigned char * baseAddr)
\r
2444 short *sgpuData = ((short *) baseAddr);
\r
2445 short imageY0,imageX0,imageY1,imageX1,imageSX,imageSY,i,j;
\r
2447 imageX0 = sgpuData[2]&0x03ff;
\r
2448 imageY0 = sgpuData[3]&iGPUHeightMask;
\r
2449 imageX1 = sgpuData[4]&0x03ff;
\r
2450 imageY1 = sgpuData[5]&iGPUHeightMask;
\r
2451 imageSX = sgpuData[6];
\r
2452 imageSY = sgpuData[7];
\r
2454 if((imageX0 == imageX1) && (imageY0 == imageY1)) return;
\r
2455 if(imageSX<=0) return;
\r
2456 if(imageSY<=0) return;
\r
2458 if(iGPUHeight==1024 && sgpuData[7]>1024) return;
\r
2460 if((imageY0+imageSY)>iGPUHeight ||
\r
2461 (imageX0+imageSX)>1024 ||
\r
2462 (imageY1+imageSY)>iGPUHeight ||
\r
2463 (imageX1+imageSX)>1024)
\r
2465 MoveImageWrapped(imageX0,imageY0,imageX1,imageY1,imageSX,imageSY);
\r
2466 if((imageY0+imageSY)>iGPUHeight) imageSY=iGPUHeight-imageY0;
\r
2467 if((imageX0+imageSX)>1024) imageSX=1024-imageX0;
\r
2468 if((imageY1+imageSY)>iGPUHeight) imageSY=iGPUHeight-imageY1;
\r
2469 if((imageX1+imageSX)>1024) imageSX=1024-imageX1;
\r
2472 if(iFrameReadType&2)
\r
2473 CheckVRamRead(imageX0,imageY0,
\r
2480 unsigned short *SRCPtr, *DSTPtr;
\r
2481 unsigned short LineOffset;
\r
2483 SRCPtr = psxVuw + (1024*imageY0) + imageX0;
\r
2484 DSTPtr = psxVuw + (1024*imageY1) + imageX1;
\r
2486 LineOffset = 1024 - imageSX;
\r
2488 for(j=0;j<imageSY;j++)
\r
2490 for(i=0;i<imageSX;i++) *DSTPtr++ = *SRCPtr++;
\r
2491 SRCPtr += LineOffset;
\r
2492 DSTPtr += LineOffset;
\r
2497 unsigned long *SRCPtr, *DSTPtr;
\r
2498 unsigned short LineOffset;
\r
2499 int dx=imageSX>>1;
\r
2501 SRCPtr = (unsigned long *)(psxVuw + (1024*imageY0) + imageX0);
\r
2502 DSTPtr = (unsigned long *)(psxVuw + (1024*imageY1) + imageX1);
\r
2504 LineOffset = 512 - dx;
\r
2506 for(j=0;j<imageSY;j++)
\r
2508 for(i=0;i<dx;i++) *DSTPtr++ = *SRCPtr++;
\r
2509 SRCPtr += LineOffset;
\r
2510 DSTPtr += LineOffset;
\r
2514 if (!PSXDisplay.RGB24)
\r
2516 InvalidateTextureArea(imageX1,imageY1,imageSX-1,imageSY-1);
\r
2518 if (CheckAgainstScreen(imageX1,imageY1,imageSX,imageSY))
\r
2520 if(imageX1>=PreviousPSXDisplay.DisplayPosition.x &&
\r
2521 imageX1<PreviousPSXDisplay.DisplayEnd.x &&
\r
2522 imageY1>=PreviousPSXDisplay.DisplayPosition.y &&
\r
2523 imageY1<PreviousPSXDisplay.DisplayEnd.y)
\r
2525 imageX1 += imageSX;
\r
2526 imageY1 += imageSY;
\r
2528 if(imageX1>=PreviousPSXDisplay.DisplayPosition.x &&
\r
2529 imageX1<=PreviousPSXDisplay.DisplayEnd.x &&
\r
2530 imageY1>=PreviousPSXDisplay.DisplayPosition.y &&
\r
2531 imageY1<=PreviousPSXDisplay.DisplayEnd.y)
\r
2534 imageX0>=PSXDisplay.DisplayPosition.x &&
\r
2535 imageX0<PSXDisplay.DisplayEnd.x &&
\r
2536 imageY0>=PSXDisplay.DisplayPosition.y &&
\r
2537 imageY0<PSXDisplay.DisplayEnd.y
\r
2540 if(bRenderFrontBuffer)
\r
2542 updateFrontDisplay();
\r
2545 UploadScreen(FALSE);
\r
2547 else bFakeFrontBuffer=TRUE;
\r
2551 bNeedUploadTest=TRUE;
\r
2554 if(iOffscreenDrawing)
\r
2556 if (CheckAgainstFrontScreen(imageX1,imageY1,imageSX,imageSY))
\r
2558 if(!PSXDisplay.InterlacedTest &&
\r
2561 imageX0>=PreviousPSXDisplay.DisplayPosition.x &&
\r
2562 imageX0<PreviousPSXDisplay.DisplayEnd.x &&
\r
2563 imageY0>=PreviousPSXDisplay.DisplayPosition.y &&
\r
2564 imageY0<PreviousPSXDisplay.DisplayEnd.y
\r
2567 imageX0>=PSXDisplay.DisplayPosition.x &&
\r
2568 imageX0<PSXDisplay.DisplayEnd.x &&
\r
2569 imageY0>=PSXDisplay.DisplayPosition.y &&
\r
2570 imageY0<PSXDisplay.DisplayEnd.y
\r
2574 bNeedUploadTest=TRUE;
\r
2576 if(!bNeedUploadAfter)
\r
2578 bNeedUploadAfter = TRUE;
\r
2579 xrUploadArea.x0=imageX0;
\r
2580 xrUploadArea.x1=imageX0+imageSX;
\r
2581 xrUploadArea.y0=imageY0;
\r
2582 xrUploadArea.y1=imageY0+imageSY;
\r
2586 xrUploadArea.x0=min(xrUploadArea.x0,imageX0);
\r
2587 xrUploadArea.x1=max(xrUploadArea.x1,imageX0+imageSX);
\r
2588 xrUploadArea.y0=min(xrUploadArea.y0,imageY0);
\r
2589 xrUploadArea.y1=max(xrUploadArea.y1,imageY0+imageSY);
\r
2597 ////////////////////////////////////////////////////////////////////////
\r
2598 // cmd: draw free-size Tile
\r
2599 ////////////////////////////////////////////////////////////////////////
\r
2601 void primTileS(unsigned char * baseAddr)
\r
2603 unsigned long *gpuData = ((unsigned long*)baseAddr);
\r
2604 short *sgpuData = ((short *) baseAddr);
\r
2606 sprtX = sgpuData[2];
\r
2607 sprtY = sgpuData[3];
\r
2608 sprtW = sgpuData[4] & 0x3ff;
\r
2609 sprtH = sgpuData[5] & iGPUHeightMask;
\r
2611 // x and y of start
\r
2618 if((dwActFixes&1) && // FF7 special game gix (battle cursor)
\r
2619 sprtX==0 && sprtY==0 && sprtW==24 && sprtH==16)
\r
2622 bDrawTextured = FALSE;
\r
2623 bDrawSmoothShaded = FALSE;
\r
2625 SetRenderState(gpuData[0]);
\r
2627 /* if(iOffscreenDrawing)
\r
2629 if(IsPrimCompleteInsideNextScreen(lx0,ly0,lx2,ly2) ||
\r
2630 (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
2632 lClearOnSwapColor = COLOR(gpuData[0]);
\r
2637 if(bDrawOffscreen4())
\r
2639 if(!(iTileCheat && sprtH==32 && gpuData[0]==0x60ffffff)) // special cheat for certain ZiNc games
\r
2641 InvalidateTextureAreaEx();
\r
2642 FillSoftwareAreaTrans(lx0,ly0,lx2,ly2,
\r
2643 BGR24to16(gpuData[0]));
\r
2648 SetRenderMode(gpuData[0], FALSE);
\r
2651 if(bIgnoreNextTile) {bIgnoreNextTile=FALSE;return;}
\r
2653 vertex[0].c.lcol=gpuData[0];
\r
2654 vertex[0].c.col[3]=ubGloColAlpha;
\r
2655 SETCOL(vertex[0]);
\r
2657 PRIMdrawQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
2659 iDrawnSomething=1;
\r
2662 ////////////////////////////////////////////////////////////////////////
\r
2663 // cmd: draw 1 dot Tile (point)
\r
2664 ////////////////////////////////////////////////////////////////////////
\r
2666 void primTile1(unsigned char * baseAddr)
\r
2668 unsigned long *gpuData = ((unsigned long*)baseAddr);
\r
2669 short *sgpuData = ((short *) baseAddr);
\r
2671 sprtX = sgpuData[2];
\r
2672 sprtY = sgpuData[3];
\r
2681 bDrawTextured = FALSE;
\r
2682 bDrawSmoothShaded = FALSE;
\r
2684 SetRenderState(gpuData[0]);
\r
2686 /* if(iOffscreenDrawing)
\r
2690 if(bDrawOffscreen4())
\r
2692 InvalidateTextureAreaEx();
\r
2693 FillSoftwareAreaTrans(lx0,ly0,lx2,ly2,
\r
2694 BGR24to16(gpuData[0]));
\r
2698 SetRenderMode(gpuData[0], FALSE);
\r
2701 vertex[0].c.lcol=gpuData[0];vertex[0].c.col[3]=ubGloColAlpha;
\r
2702 SETCOL(vertex[0]);
\r
2704 PRIMdrawQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
2706 iDrawnSomething=1;
\r
2709 ////////////////////////////////////////////////////////////////////////
\r
2710 // cmd: draw 8 dot Tile (small rect)
\r
2711 ////////////////////////////////////////////////////////////////////////
\r
2713 void primTile8(unsigned char * baseAddr)
\r
2715 unsigned long *gpuData = ((unsigned long*)baseAddr);
\r
2716 short *sgpuData = ((short *) baseAddr);
\r
2718 sprtX = sgpuData[2];
\r
2719 sprtY = sgpuData[3];
\r
2728 bDrawTextured = FALSE;
\r
2729 bDrawSmoothShaded = FALSE;
\r
2730 SetRenderState(gpuData[0]);
\r
2732 /* if(iOffscreenDrawing)
\r
2736 if(bDrawOffscreen4())
\r
2738 InvalidateTextureAreaEx();
\r
2739 FillSoftwareAreaTrans(lx0,ly0,lx2,ly2,
\r
2740 BGR24to16(gpuData[0]));
\r
2744 SetRenderMode(gpuData[0], FALSE);
\r
2747 vertex[0].c.lcol=gpuData[0];
\r
2748 vertex[0].c.col[3]=ubGloColAlpha;
\r
2749 SETCOL(vertex[0]);
\r
2751 PRIMdrawQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
2753 iDrawnSomething=1;
\r
2756 ////////////////////////////////////////////////////////////////////////
\r
2757 // cmd: draw 16 dot Tile (medium rect)
\r
2758 ////////////////////////////////////////////////////////////////////////
\r
2760 void primTile16(unsigned char * baseAddr)
\r
2762 unsigned long *gpuData = ((unsigned long*)baseAddr);
\r
2763 short *sgpuData = ((short *) baseAddr);
\r
2765 sprtX = sgpuData[2];
\r
2766 sprtY = sgpuData[3];
\r
2769 // x and y of start
\r
2775 bDrawTextured = FALSE;
\r
2776 bDrawSmoothShaded = FALSE;
\r
2777 SetRenderState(gpuData[0]);
\r
2779 /* if(iOffscreenDrawing)
\r
2783 if(bDrawOffscreen4())
\r
2785 InvalidateTextureAreaEx();
\r
2786 FillSoftwareAreaTrans(lx0,ly0,lx2,ly2,
\r
2787 BGR24to16(gpuData[0]));
\r
2791 SetRenderMode(gpuData[0], FALSE);
\r
2794 vertex[0].c.lcol=gpuData[0];
\r
2795 vertex[0].c.col[3]=ubGloColAlpha;
\r
2796 SETCOL(vertex[0]);
\r
2798 PRIMdrawQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
2800 iDrawnSomething=1;
\r
2803 ////////////////////////////////////////////////////////////////////////
\r
2804 // helper: filter effect by multipass rendering
\r
2805 ////////////////////////////////////////////////////////////////////////
\r
2807 /*void DrawMultiBlur(void)
\r
2809 long lABR,lDST;float fx,fy;
\r
2811 lABR=GlobalTextABR;
\r
2812 lDST=DrawSemiTrans;
\r
2814 fx=(float)PSXDisplay.DisplayMode.x/(float)(iResX);
\r
2815 fy=(float)PSXDisplay.DisplayMode.y/(float)(iResY);
\r
2817 vertex[0].x+=fx;vertex[1].x+=fx;
\r
2818 vertex[2].x+=fx;vertex[3].x+=fx;
\r
2824 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
2826 vertex[0].y+=fy;vertex[1].y+=fy;
\r
2827 vertex[2].y+=fy;vertex[3].y+=fy;
\r
2828 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
2830 if(bDrawMultiPass) {obm1=obm2=GL_SRC_ALPHA;}
\r
2832 GlobalTextABR=lABR;
\r
2833 DrawSemiTrans=lDST;
\r
2836 ////////////////////////////////////////////////////////////////////////
\r
2838 #define POFF 0.375f
\r
2840 void DrawMultiFilterSprite(void)
\r
2844 if(bUseMultiPass || DrawSemiTrans || ubOpaqueDraw)
\r
2846 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
2850 lABR=GlobalTextABR;
\r
2851 lDST=DrawSemiTrans;
\r
2852 vertex[0].c.col[3]=ubGloAlpha/2; // -> set color with
\r
2853 SETCOL(vertex[0]); // texture alpha
\r
2854 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
2855 vertex[0].x+=POFF;vertex[1].x+=POFF;
\r
2856 vertex[2].x+=POFF;vertex[3].x+=POFF;
\r
2857 vertex[0].y+=POFF;vertex[1].y+=POFF;
\r
2858 vertex[2].y+=POFF;vertex[3].y+=POFF;
\r
2862 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
2863 GlobalTextABR=lABR;
\r
2864 DrawSemiTrans=lDST;
\r
2867 ////////////////////////////////////////////////////////////////////////
\r
2868 // cmd: small sprite (textured rect)
\r
2869 ////////////////////////////////////////////////////////////////////////
\r
2871 void primSprt8(unsigned char * baseAddr)
\r
2873 unsigned long *gpuData = ((unsigned long *) baseAddr);
\r
2874 short *sgpuData = ((short *) baseAddr);
\r
2879 sprtX = sgpuData[2];
\r
2880 sprtY = sgpuData[3];
\r
2889 // do texture stuff
\r
2890 gl_ux[0]=gl_ux[3]=baseAddr[8];//gpuData[2]&0xff;
\r
2892 if(usMirror & 0x1000)
\r
2897 gl_ux[0]=gl_ux[3]=s;
\r
2900 sSprite_ux2=s=gl_ux[0]+sprtW;
\r
2903 gl_ux[1]=gl_ux[2]=s;
\r
2905 gl_vy[0]=gl_vy[1]=baseAddr[9];//(gpuData[2]>>8)&0xff;
\r
2907 if(usMirror & 0x2000)
\r
2912 gl_vy[0]=gl_vy[1]=s;
\r
2915 sSprite_vy2=s=gl_vy[0]+sprtH;
\r
2918 gl_vy[2]=gl_vy[3]=s;
\r
2920 ulClutID=(gpuData[2]>>16);
\r
2922 bDrawTextured = TRUE;
\r
2923 bDrawSmoothShaded = FALSE;
\r
2924 SetRenderState(gpuData[0]);
\r
2926 /* if(iOffscreenDrawing)
\r
2930 if(bDrawOffscreen4())
\r
2932 InvalidateTextureAreaEx();
\r
2933 SetRenderColor(gpuData[0]);
\r
2934 lx0-=PSXDisplay.DrawOffset.x;
\r
2935 ly0-=PSXDisplay.DrawOffset.y;
\r
2937 if(bUsingTWin) DrawSoftwareSpriteTWin(baseAddr,8,8);
\r
2939 if(usMirror) DrawSoftwareSpriteMirror(baseAddr,8,8);
\r
2941 DrawSoftwareSprite(baseAddr,8,8,baseAddr[8],baseAddr[9]);
\r
2945 SetRenderMode(gpuData[0], TRUE);
\r
2948 sSprite_ux2=gl_ux[0]+sprtW;
\r
2949 sSprite_vy2=gl_vy[0]+sprtH;
\r
2951 assignTextureSprite();
\r
2953 if(iFilterType>4)
\r
2954 DrawMultiFilterSprite();
\r
2956 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
2958 if(bDrawMultiPass)
\r
2960 SetSemiTransMulti(1);
\r
2961 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
2967 if(bUseMultiPass) SetOpaqueColor(gpuData[0]);
\r
2970 /* if(bSmallAlpha && iFilterType<=2)
\r
2972 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
\r
2973 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
\r
2974 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
2975 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
\r
2976 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
\r
2980 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
2985 iDrawnSomething=1;
\r
2988 ////////////////////////////////////////////////////////////////////////
\r
2989 // cmd: medium sprite (textured rect)
\r
2990 ////////////////////////////////////////////////////////////////////////
\r
2992 void primSprt16(unsigned char * baseAddr)
\r
2994 unsigned long *gpuData = ((unsigned long *) baseAddr);
\r
2995 short *sgpuData = ((short *) baseAddr);
\r
3000 sprtX = sgpuData[2];
\r
3001 sprtY = sgpuData[3];
\r
3010 // do texture stuff
\r
3011 gl_ux[0]=gl_ux[3]=baseAddr[8];//gpuData[2]&0xff;
\r
3013 if(usMirror & 0x1000)
\r
3018 gl_ux[0]=gl_ux[3]=s;
\r
3021 sSprite_ux2=s=gl_ux[0]+sprtW;
\r
3024 gl_ux[1]=gl_ux[2]=s;
\r
3026 gl_vy[0]=gl_vy[1]=baseAddr[9];//(gpuData[2]>>8)&0xff;
\r
3028 if(usMirror & 0x2000)
\r
3033 gl_vy[0]=gl_vy[1]=s;
\r
3036 sSprite_vy2=s=gl_vy[0]+sprtH;
\r
3039 gl_vy[2]=gl_vy[3]=s;
\r
3041 ulClutID=(gpuData[2]>>16);
\r
3043 bDrawTextured = TRUE;
\r
3044 bDrawSmoothShaded = FALSE;
\r
3045 SetRenderState(gpuData[0]);
\r
3047 /* if(iOffscreenDrawing)
\r
3051 if(bDrawOffscreen4())
\r
3053 InvalidateTextureAreaEx();
\r
3054 SetRenderColor(gpuData[0]);
\r
3055 lx0-=PSXDisplay.DrawOffset.x;
\r
3056 ly0-=PSXDisplay.DrawOffset.y;
\r
3057 if(bUsingTWin) DrawSoftwareSpriteTWin(baseAddr,16,16);
\r
3059 if(usMirror) DrawSoftwareSpriteMirror(baseAddr,16,16);
\r
3061 DrawSoftwareSprite(baseAddr,16,16,baseAddr[8],baseAddr[9]);
\r
3065 SetRenderMode(gpuData[0], TRUE);
\r
3068 sSprite_ux2=gl_ux[0]+sprtW;
\r
3069 sSprite_vy2=gl_vy[0]+sprtH;
\r
3071 assignTextureSprite();
\r
3073 if(iFilterType>4)
\r
3074 DrawMultiFilterSprite();
\r
3076 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
3078 if(bDrawMultiPass)
\r
3080 SetSemiTransMulti(1);
\r
3081 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
3087 if(bUseMultiPass) SetOpaqueColor(gpuData[0]);
\r
3090 /* if(bSmallAlpha && iFilterType<=2)
\r
3092 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
\r
3093 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
\r
3094 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
3095 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
\r
3096 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
\r
3100 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
3105 iDrawnSomething=1;
\r
3108 ////////////////////////////////////////////////////////////////////////
\r
3109 // cmd: free-size sprite (textured rect)
\r
3110 ////////////////////////////////////////////////////////////////////////
\r
3112 void primSprtSRest(unsigned char * baseAddr,unsigned short type)
\r
3114 unsigned long *gpuData = ((unsigned long *) baseAddr);
\r
3115 short *sgpuData = ((short *) baseAddr);
\r
3116 short s;unsigned short sTypeRest=0;
\r
3118 sprtX = sgpuData[2];
\r
3119 sprtY = sgpuData[3];
\r
3120 sprtW = sgpuData[6] & 0x3ff;
\r
3121 sprtH = sgpuData[7] & 0x1ff;
\r
3124 // do texture stuff
\r
3128 gl_vy[0]=gl_vy[1]=baseAddr[9];
\r
3129 s=256-baseAddr[8];
\r
3132 gl_ux[0]=gl_ux[3]=0;
\r
3135 gl_ux[0]=gl_ux[3]=baseAddr[8];
\r
3136 s=256-baseAddr[9];
\r
3139 gl_vy[0]=gl_vy[1]=0;
\r
3142 s=256-baseAddr[8];
\r
3145 gl_ux[0]=gl_ux[3]=0;
\r
3146 s=256-baseAddr[9];
\r
3149 gl_vy[0]=gl_vy[1]=0;
\r
3153 gl_vy[0]=gl_vy[1]=baseAddr[9];
\r
3154 s=512-baseAddr[8];
\r
3157 gl_ux[0]=gl_ux[3]=0;
\r
3160 gl_ux[0]=gl_ux[3]=baseAddr[8];
\r
3161 s=512-baseAddr[9];
\r
3164 gl_vy[0]=gl_vy[1]=0;
\r
3167 s=512-baseAddr[8];
\r
3170 gl_ux[0]=gl_ux[3]=0;
\r
3171 s=512-baseAddr[9];
\r
3174 gl_vy[0]=gl_vy[1]=0;
\r
3179 if(usMirror & 0x1000)
\r
3182 s-=sprtW-1;if(s<0) s=0;
\r
3183 gl_ux[0]=gl_ux[3]=s;
\r
3185 if(usMirror & 0x2000)
\r
3188 s-=sprtH-1;if(s<0) {s=0;}
\r
3189 gl_vy[0]=gl_vy[1]=s;
\r
3192 sSprite_ux2=s=gl_ux[0]+sprtW;
\r
3194 gl_ux[1]=gl_ux[2]=s;
\r
3195 sSprite_vy2=s=gl_vy[0]+sprtH;
\r
3197 gl_vy[2]=gl_vy[3]=s;
\r
3201 if(sSprite_ux2>256)
\r
3202 {sprtW=256-gl_ux[0];sSprite_ux2=256;sTypeRest+=1;}
\r
3203 if(sSprite_vy2>256)
\r
3204 {sprtH=256-gl_vy[0];sSprite_vy2=256;sTypeRest+=2;}
\r
3212 ulClutID=(gpuData[2]>>16);
\r
3214 bDrawTextured = TRUE;
\r
3215 bDrawSmoothShaded = FALSE;
\r
3216 SetRenderState(gpuData[0]);
\r
3218 /* if(iOffscreenDrawing)
\r
3222 if(bDrawOffscreen4())
\r
3224 InvalidateTextureAreaEx();
\r
3225 SetRenderColor(gpuData[0]);
\r
3226 lx0-=PSXDisplay.DrawOffset.x;
\r
3227 ly0-=PSXDisplay.DrawOffset.y;
\r
3228 if(bUsingTWin) DrawSoftwareSpriteTWin(baseAddr,sprtW,sprtH);
\r
3230 if(usMirror) DrawSoftwareSpriteMirror(baseAddr,sprtW,sprtH);
\r
3232 DrawSoftwareSprite(baseAddr,sprtW,sprtH,baseAddr[8],baseAddr[9]);
\r
3236 SetRenderMode(gpuData[0], TRUE);
\r
3239 sSprite_ux2=gl_ux[0]+sprtW;
\r
3240 sSprite_vy2=gl_vy[0]+sprtH;
\r
3242 assignTextureSprite();
\r
3244 if(iFilterType>4)
\r
3245 DrawMultiFilterSprite();
\r
3247 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
3249 if(bDrawMultiPass)
\r
3251 SetSemiTransMulti(1);
\r
3252 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
3258 if(bUseMultiPass) SetOpaqueColor(gpuData[0]);
\r
3261 /* if(bSmallAlpha && iFilterType<=2)
\r
3263 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
\r
3264 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
\r
3265 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
3266 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
\r
3267 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
\r
3271 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
3275 if(sTypeRest && type<4)
\r
3277 if(sTypeRest&1 && type==1) primSprtSRest(baseAddr,4);
\r
3278 if(sTypeRest&2 && type==2) primSprtSRest(baseAddr,5);
\r
3279 if(sTypeRest==3 && type==3) primSprtSRest(baseAddr,6);
\r
3283 void primSprtS(unsigned char * baseAddr)
\r
3285 unsigned long *gpuData = ((unsigned long *) baseAddr);
\r
3286 short *sgpuData = ((short *) baseAddr);
\r
3288 short s;unsigned short sTypeRest=0;
\r
3290 sprtX = sgpuData[2];
\r
3291 sprtY = sgpuData[3];
\r
3292 sprtW = sgpuData[6] & 0x3ff;
\r
3293 sprtH = sgpuData[7] & 0x1ff;
\r
3295 if(!sprtH) return;
\r
3296 if(!sprtW) return;
\r
3300 // do texture stuff
\r
3301 gl_ux[0]=gl_ux[3]=baseAddr[8];//gpuData[2]&0xff;
\r
3302 gl_vy[0]=gl_vy[1]=baseAddr[9];//(gpuData[2]>>8)&0xff;
\r
3304 if(usMirror & 0x1000)
\r
3309 gl_ux[0]=gl_ux[3]=s;
\r
3311 if(usMirror & 0x2000)
\r
3316 gl_vy[0]=gl_vy[1]=s;
\r
3319 sSprite_ux2=s=gl_ux[0]+sprtW;
\r
3322 gl_ux[1]=gl_ux[2]=s;
\r
3323 sSprite_vy2=s=gl_vy[0]+sprtH;
\r
3326 gl_vy[2]=gl_vy[3]=s;
\r
3330 if(sSprite_ux2>256)
\r
3331 {sprtW=256-gl_ux[0];sSprite_ux2=256;sTypeRest+=1;}
\r
3332 if(sSprite_vy2>256)
\r
3333 {sprtH=256-gl_vy[0];sSprite_vy2=256;sTypeRest+=2;}
\r
3341 ulClutID=(gpuData[2]>>16);
\r
3343 bDrawTextured = TRUE;
\r
3344 bDrawSmoothShaded = FALSE;
\r
3345 SetRenderState(gpuData[0]);
\r
3347 /* if(iOffscreenDrawing)
\r
3351 if(bDrawOffscreen4())
\r
3353 InvalidateTextureAreaEx();
\r
3354 SetRenderColor(gpuData[0]);
\r
3355 lx0-=PSXDisplay.DrawOffset.x;
\r
3356 ly0-=PSXDisplay.DrawOffset.y;
\r
3357 if(bUsingTWin) DrawSoftwareSpriteTWin(baseAddr,sprtW,sprtH);
\r
3359 if(usMirror) DrawSoftwareSpriteMirror(baseAddr,sprtW,sprtH);
\r
3361 DrawSoftwareSprite(baseAddr,sprtW,sprtH,baseAddr[8],baseAddr[9]);
\r
3365 SetRenderMode(gpuData[0], TRUE);
\r
3368 if((dwActFixes&1) && gTexFrameName && gTexName==gTexFrameName)
\r
3369 {iSpriteTex=0;return;}
\r
3371 sSprite_ux2=gl_ux[0]+sprtW;
\r
3372 sSprite_vy2=gl_vy[0]+sprtH;
\r
3374 assignTextureSprite();
\r
3376 if(iFilterType>4)
\r
3377 DrawMultiFilterSprite();
\r
3379 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
3381 if(bDrawMultiPass)
\r
3383 SetSemiTransMulti(1);
\r
3384 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
3390 if(bUseMultiPass) SetOpaqueColor(gpuData[0]);
\r
3393 /* if(bSmallAlpha && iFilterType<=2)
\r
3395 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
\r
3396 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
\r
3397 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
3398 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
\r
3399 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
\r
3403 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
3409 if(sTypeRest&1) primSprtSRest(baseAddr,1);
\r
3410 if(sTypeRest&2) primSprtSRest(baseAddr,2);
\r
3411 if(sTypeRest==3) primSprtSRest(baseAddr,3);
\r
3415 iDrawnSomething=1;
\r
3418 ////////////////////////////////////////////////////////////////////////
\r
3419 // cmd: flat shaded Poly4
\r
3420 ////////////////////////////////////////////////////////////////////////
\r
3422 void primPolyF4(unsigned char *baseAddr)
\r
3424 unsigned long *gpuData = ((unsigned long *) baseAddr);
\r
3425 short *sgpuData = ((short *) baseAddr);
\r
3427 lx0 = sgpuData[2];
\r
3428 ly0 = sgpuData[3];
\r
3429 lx1 = sgpuData[4];
\r
3430 ly1 = sgpuData[5];
\r
3431 lx2 = sgpuData[6];
\r
3432 ly2 = sgpuData[7];
\r
3433 lx3 = sgpuData[8];
\r
3434 ly3 = sgpuData[9];
\r
3436 if(offset4()) return;
\r
3438 bDrawTextured = FALSE;
\r
3439 bDrawSmoothShaded = FALSE;
\r
3440 SetRenderState(gpuData[0]);
\r
3442 /* if(iOffscreenDrawing)
\r
3445 if(bDrawOffscreen4())
\r
3447 InvalidateTextureAreaEx();
\r
3448 drawPoly4F(gpuData[0]);
\r
3452 SetRenderMode(gpuData[0], FALSE);
\r
3455 vertex[0].c.lcol=gpuData[0];vertex[0].c.col[3]=ubGloColAlpha;
\r
3456 SETCOL(vertex[0]);
\r
3458 PRIMdrawTri2(&vertex[0], &vertex[1], &vertex[2],&vertex[3]);
\r
3460 iDrawnSomething=1;
\r
3463 ////////////////////////////////////////////////////////////////////////
\r
3464 // cmd: smooth shaded Poly4
\r
3465 ////////////////////////////////////////////////////////////////////////
\r
3467 void primPolyG4(unsigned char * baseAddr);
\r
3469 BOOL bDrawOffscreenFrontFF9G4(void)
\r
3471 if(lx0< PSXDisplay.DisplayPosition.x) return FALSE; // must be complete in front
\r
3472 if(lx0> PSXDisplay.DisplayEnd.x) return FALSE;
\r
3473 if(ly0< PSXDisplay.DisplayPosition.y) return FALSE;
\r
3474 if(ly0> PSXDisplay.DisplayEnd.y) return FALSE;
\r
3475 if(lx1< PSXDisplay.DisplayPosition.x) return FALSE;
\r
3476 if(lx1> PSXDisplay.DisplayEnd.x) return FALSE;
\r
3477 if(ly1< PSXDisplay.DisplayPosition.y) return FALSE;
\r
3478 if(ly1> PSXDisplay.DisplayEnd.y) return FALSE;
\r
3479 if(lx2< PSXDisplay.DisplayPosition.x) return FALSE;
\r
3480 if(lx2> PSXDisplay.DisplayEnd.x) return FALSE;
\r
3481 if(ly2< PSXDisplay.DisplayPosition.y) return FALSE;
\r
3482 if(ly2> PSXDisplay.DisplayEnd.y) return FALSE;
\r
3483 if(lx3< PSXDisplay.DisplayPosition.x) return FALSE;
\r
3484 if(lx3> PSXDisplay.DisplayEnd.x) return FALSE;
\r
3485 if(ly3< PSXDisplay.DisplayPosition.y) return FALSE;
\r
3486 if(ly3> PSXDisplay.DisplayEnd.y) return FALSE;
\r
3490 BOOL bCheckFF9G4(unsigned char * baseAddr)
\r
3492 static unsigned char pFF9G4Cache[32];
\r
3493 static int iFF9Fix=0;
\r
3499 if(bDrawOffscreenFrontFF9G4())
\r
3501 short *sgpuData = ((short *) pFF9G4Cache);
\r
3503 memcpy(pFF9G4Cache,baseAddr,32);
\r
3505 if(sgpuData[2]==142)
\r
3519 long labr=GlobalTextABR;
\r
3521 primPolyG4(pFF9G4Cache);
\r
3522 GlobalTextABR=labr;
\r
3529 ////////////////////////////////////////////////////////////////////////
\r
3531 void primPolyG4(unsigned char * baseAddr)
\r
3533 unsigned long *gpuData = (unsigned long *)baseAddr;
\r
3534 short *sgpuData = ((short *) baseAddr);
\r
3536 lx0 = sgpuData[2];
\r
3537 ly0 = sgpuData[3];
\r
3538 lx1 = sgpuData[6];
\r
3539 ly1 = sgpuData[7];
\r
3540 lx2 = sgpuData[10];
\r
3541 ly2 = sgpuData[11];
\r
3542 lx3 = sgpuData[14];
\r
3543 ly3 = sgpuData[15];
\r
3545 if(offset4()) return;
\r
3547 bDrawTextured = FALSE;
\r
3548 bDrawSmoothShaded = TRUE;
\r
3549 SetRenderState(gpuData[0]);
\r
3551 /* if(iOffscreenDrawing)
\r
3555 if((dwActFixes&512) && bCheckFF9G4(baseAddr)) return;
\r
3557 if(bDrawOffscreen4())
\r
3559 InvalidateTextureAreaEx();
\r
3560 drawPoly4G(gpuData[0], gpuData[2], gpuData[4], gpuData[6]);
\r
3564 SetRenderMode(gpuData[0], FALSE);
\r
3567 vertex[0].c.lcol=gpuData[0];
\r
3568 vertex[1].c.lcol=gpuData[2];
\r
3569 vertex[2].c.lcol=gpuData[4];
\r
3570 vertex[3].c.lcol=gpuData[6];
\r
3572 vertex[0].c.col[3]=vertex[1].c.col[3]=vertex[2].c.col[3]=vertex[3].c.col[3]=ubGloAlpha;
\r
3575 PRIMdrawGouraudTri2Color(&vertex[0],&vertex[1], &vertex[2], &vertex[3]);
\r
3577 iDrawnSomething=1;
\r
3580 ////////////////////////////////////////////////////////////////////////
\r
3581 // cmd: flat shaded Texture3
\r
3582 ////////////////////////////////////////////////////////////////////////
\r
3584 BOOL DoLineCheck(unsigned long * gpuData)
\r
3586 BOOL bQuad=FALSE;short dx,dy;
\r
3590 dx=lx0-lx2;if(dx<0) dx=-dx;
\r
3594 dy=ly1-ly0;if(dy<0) dy=-dy;
\r
3597 vertex[3]=vertex[2];
\r
3598 vertex[2]=vertex[0];
\r
3599 vertex[2].x=vertex[3].x;
\r
3604 vertex[3]=vertex[2];
\r
3605 vertex[2].y=vertex[0].y;
\r
3607 else return FALSE;
\r
3614 dy=ly0-ly1;if(dy<0) dy=-dy;
\r
3617 vertex[3]=vertex[1];
\r
3618 vertex[3].x=vertex[2].x;
\r
3623 vertex[3]=vertex[2];
\r
3624 vertex[3].y=vertex[1].y;
\r
3626 else return FALSE;
\r
3634 dx=lx0-lx1;if(dx<0) dx=-dx;
\r
3638 dy=ly2-ly0;if(dy<0) dy=-dy;
\r
3641 vertex[3]=vertex[1];
\r
3642 vertex[1]=vertex[0];
\r
3643 vertex[1].x=vertex[3].x;
\r
3648 vertex[3]=vertex[1];
\r
3649 vertex[1].y=vertex[0].y;
\r
3651 else return FALSE;
\r
3658 dy=ly2-ly0;if(dy<0) dy=-dy;
\r
3661 vertex[3]=vertex[2];
\r
3662 vertex[3].x=vertex[1].x;
\r
3667 vertex[3]=vertex[1];
\r
3668 vertex[3].y=vertex[2].y;
\r
3670 else return FALSE;
\r
3678 dx=lx1-lx0;if(dx<0) dx=-dx;
\r
3682 dy=ly1-ly2;if(dy<0) dy=-dy;
\r
3686 vertex[3]=vertex[2];
\r
3687 vertex[2].x=vertex[0].x;
\r
3692 vertex[3]=vertex[2];
\r
3693 vertex[2]=vertex[0];
\r
3694 vertex[2].y=vertex[3].y;
\r
3696 else return FALSE;
\r
3703 dy=ly2-ly1;if(dy<0) dy=-dy;
\r
3707 vertex[3]=vertex[1];
\r
3708 vertex[1].x=vertex[0].x;
\r
3713 vertex[3]=vertex[1];
\r
3714 vertex[1]=vertex[0];
\r
3715 vertex[1].y=vertex[3].y;
\r
3717 else return FALSE;
\r
3723 if(!bQuad) return FALSE;
\r
3725 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[3], &vertex[2]);
\r
3727 if(bDrawMultiPass)
\r
3729 SetSemiTransMulti(1);
\r
3730 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[3], &vertex[2]);
\r
3736 if(bUseMultiPass) SetOpaqueColor(gpuData[0]);
\r
3738 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[3], &vertex[2]);
\r
3742 iDrawnSomething=1;
\r
3747 ////////////////////////////////////////////////////////////////////////
\r
3749 void primPolyFT3(unsigned char * baseAddr)
\r
3751 unsigned long *gpuData = ((unsigned long *) baseAddr);
\r
3752 short *sgpuData = ((short *) baseAddr);
\r
3754 lx0 = sgpuData[2];
\r
3755 ly0 = sgpuData[3];
\r
3756 lx1 = sgpuData[6];
\r
3757 ly1 = sgpuData[7];
\r
3758 lx2 = sgpuData[10];
\r
3759 ly2 = sgpuData[11];
\r
3761 if(offset3()) return;
\r
3763 // do texture UV coordinates stuff
\r
3764 gl_ux[0]=gl_ux[3]=baseAddr[8];//gpuData[2]&0xff;
\r
3765 gl_vy[0]=gl_vy[3]=baseAddr[9];//(gpuData[2]>>8)&0xff;
\r
3766 gl_ux[1]=baseAddr[16];//gpuData[4]&0xff;
\r
3767 gl_vy[1]=baseAddr[17];//(gpuData[4]>>8)&0xff;
\r
3768 gl_ux[2]=baseAddr[24];//gpuData[6]&0xff;
\r
3769 gl_vy[2]=baseAddr[25];//(gpuData[6]>>8)&0xff;
\r
3771 UpdateGlobalTP((unsigned short)(gpuData[4]>>16));
\r
3772 ulClutID=gpuData[2]>>16;
\r
3774 bDrawTextured = TRUE;
\r
3775 bDrawSmoothShaded = FALSE;
\r
3776 SetRenderState(gpuData[0]);
\r
3778 /* if(iOffscreenDrawing)
\r
3781 if(bDrawOffscreen3())
\r
3783 InvalidateTextureAreaEx();
\r
3784 SetRenderColor(gpuData[0]);
\r
3785 drawPoly3FT(baseAddr);
\r
3789 SetRenderMode(gpuData[0], TRUE);
\r
3794 if(!(dwActFixes&0x10))
\r
3796 if(DoLineCheck(gpuData)) return;
\r
3799 PRIMdrawTexturedTri(&vertex[0], &vertex[1], &vertex[2]);
\r
3801 if(bDrawMultiPass)
\r
3803 SetSemiTransMulti(1);
\r
3804 PRIMdrawTexturedTri(&vertex[0], &vertex[1], &vertex[2]);
\r
3810 if(bUseMultiPass) SetOpaqueColor(gpuData[0]);
\r
3812 PRIMdrawTexturedTri(&vertex[0], &vertex[1], &vertex[2]);
\r
3816 iDrawnSomething=1;
\r
3819 ////////////////////////////////////////////////////////////////////////
\r
3820 // cmd: flat shaded Texture4
\r
3821 ////////////////////////////////////////////////////////////////////////
\r
3823 #define ST_FAC 255.99f
\r
3825 void RectTexAlign(void)
\r
3827 int UFlipped = FALSE;
\r
3828 int VFlipped = FALSE;
\r
3830 if(gTexName==gTexFrameName) return;
\r
3834 if(!((lx1==lx3 && ly3==ly2 && lx2==lx0) ||
\r
3835 (lx1==lx2 && ly2==ly3 && lx3==lx0)))
\r
3840 if (vertex[0].tow > vertex[2].tow)
\r
3845 if (vertex[0].tow < vertex[2].tow)
\r
3852 if(!((lx2==lx3 && ly3==ly1 && lx1==lx0) ||
\r
3853 (lx2==lx1 && ly1==ly3 && lx3==lx0)))
\r
3858 if (vertex[0].tow > vertex[1].tow)
\r
3863 if (vertex[0].tow < vertex[1].tow)
\r
3870 if(!((lx3==lx2 && ly2==ly1 && lx1==lx0) ||
\r
3871 (lx3==lx1 && ly1==ly2 && lx2==lx0)))
\r
3876 if (vertex[0].tow > vertex[1].tow)
\r
3881 if (vertex[0].tow < vertex[1].tow)
\r
3891 if (vertex[0].sow > vertex[2].sow)
\r
3896 if (vertex[0].sow < vertex[2].sow)
\r
3905 if (vertex[0].sow > vertex[1].sow)
\r
3910 if (vertex[0].sow < vertex[1].sow)
\r
3919 if (vertex[0].sow > vertex[1].sow)
\r
3924 if (vertex[0].sow < vertex[1].sow)
\r
3937 vertex[2].sow+=0.95f/TWin.UScaleFactor;
\r
3938 vertex[3].sow+=0.95f/TWin.UScaleFactor;
\r
3941 vertex[0].sow+=0.95f/TWin.UScaleFactor;
\r
3942 vertex[1].sow+=0.95f/TWin.UScaleFactor;
\r
3945 vertex[1].sow+=0.95f/TWin.UScaleFactor;
\r
3946 vertex[3].sow+=0.95f/TWin.UScaleFactor;
\r
3949 vertex[0].sow+=0.95f/TWin.UScaleFactor;
\r
3950 vertex[2].sow+=0.95f/TWin.UScaleFactor;
\r
3953 vertex[1].sow+=0.95f/TWin.UScaleFactor;
\r
3954 vertex[2].sow+=0.95f/TWin.UScaleFactor;
\r
3957 vertex[0].sow+=0.95f/TWin.UScaleFactor;
\r
3958 vertex[3].sow+=0.95f/TWin.UScaleFactor;
\r
3967 vertex[2].sow+=1.0f/ST_FAC;
\r
3968 vertex[3].sow+=1.0f/ST_FAC;
\r
3971 vertex[0].sow+=1.0f/ST_FAC;
\r
3972 vertex[1].sow+=1.0f/ST_FAC;
\r
3975 vertex[1].sow+=1.0f/ST_FAC;
\r
3976 vertex[3].sow+=1.0f/ST_FAC;
\r
3979 vertex[0].sow+=1.0f/ST_FAC;
\r
3980 vertex[2].sow+=1.0f/ST_FAC;
\r
3983 vertex[1].sow+=1.0f/ST_FAC;
\r
3984 vertex[2].sow+=1.0f/ST_FAC;
\r
3987 vertex[0].sow+=1.0f/ST_FAC;
\r
3988 vertex[3].sow+=1.0f/ST_FAC;
\r
3998 vertex[2].sow+=1.0f/TWin.UScaleFactor;
\r
3999 vertex[3].sow+=1.0f/TWin.UScaleFactor;
\r
4002 vertex[0].sow+=1.0f/TWin.UScaleFactor;
\r
4003 vertex[1].sow+=1.0f/TWin.UScaleFactor;
\r
4006 vertex[1].sow+=1.0f/TWin.UScaleFactor;
\r
4007 vertex[3].sow+=1.0f/TWin.UScaleFactor;
\r
4010 vertex[0].sow+=1.0f/TWin.UScaleFactor;
\r
4011 vertex[2].sow+=1.0f/TWin.UScaleFactor;
\r
4014 vertex[1].sow+=1.0f/TWin.UScaleFactor;
\r
4015 vertex[2].sow+=1.0f/TWin.UScaleFactor;
\r
4018 vertex[0].sow+=1.0f/TWin.UScaleFactor;
\r
4019 vertex[3].sow+=1.0f/TWin.UScaleFactor;
\r
4028 vertex[2].sow+=1.0f;
\r
4029 vertex[3].sow+=1.0f;
\r
4032 vertex[0].sow+=1.0f;
\r
4033 vertex[1].sow+=1.0f;
\r
4036 vertex[1].sow+=1.0f;
\r
4037 vertex[3].sow+=1.0f;
\r
4040 vertex[0].sow+=1.0f;
\r
4041 vertex[2].sow+=1.0f;
\r
4044 vertex[1].sow+=1.0f;
\r
4045 vertex[2].sow+=1.0f;
\r
4048 vertex[0].sow+=1.0f;
\r
4049 vertex[3].sow+=1.0f;
\r
4064 vertex[2].tow+=0.95f/TWin.VScaleFactor;
\r
4065 vertex[3].tow+=0.95f/TWin.VScaleFactor;
\r
4068 vertex[0].tow+=0.95f/TWin.VScaleFactor;
\r
4069 vertex[1].tow+=0.95f/TWin.VScaleFactor;
\r
4072 vertex[1].tow+=0.95f/TWin.VScaleFactor;
\r
4073 vertex[3].tow+=0.95f/TWin.VScaleFactor;
\r
4076 vertex[0].tow+=0.95f/TWin.VScaleFactor;
\r
4077 vertex[2].tow+=0.95f/TWin.VScaleFactor;
\r
4080 vertex[1].tow+=0.95f/TWin.VScaleFactor;
\r
4081 vertex[2].tow+=0.95f/TWin.VScaleFactor;
\r
4084 vertex[0].tow+=0.95f/TWin.VScaleFactor;
\r
4085 vertex[3].tow+=0.95f/TWin.VScaleFactor;
\r
4094 vertex[2].tow+=1.0f/ST_FAC;
\r
4095 vertex[3].tow+=1.0f/ST_FAC;
\r
4098 vertex[0].tow+=1.0f/ST_FAC;
\r
4099 vertex[1].tow+=1.0f/ST_FAC;
\r
4102 vertex[1].tow+=1.0f/ST_FAC;
\r
4103 vertex[3].tow+=1.0f/ST_FAC;
\r
4106 vertex[0].tow+=1.0f/ST_FAC;
\r
4107 vertex[2].tow+=1.0f/ST_FAC;
\r
4110 vertex[1].tow+=1.0f/ST_FAC;
\r
4111 vertex[2].tow+=1.0f/ST_FAC;
\r
4114 vertex[0].tow+=1.0f/ST_FAC;
\r
4115 vertex[3].tow+=1.0f/ST_FAC;
\r
4125 vertex[2].tow+=1.0f/TWin.VScaleFactor;
\r
4126 vertex[3].tow+=1.0f/TWin.VScaleFactor;
\r
4129 vertex[0].tow+=1.0f/TWin.VScaleFactor;
\r
4130 vertex[1].tow+=1.0f/TWin.VScaleFactor;
\r
4133 vertex[1].tow+=1.0f/TWin.VScaleFactor;
\r
4134 vertex[3].tow+=1.0f/TWin.VScaleFactor;
\r
4137 vertex[0].tow+=1.0f/TWin.VScaleFactor;
\r
4138 vertex[2].tow+=1.0f/TWin.VScaleFactor;
\r
4141 vertex[1].tow+=1.0f/TWin.VScaleFactor;
\r
4142 vertex[2].tow+=1.0f/TWin.VScaleFactor;
\r
4145 vertex[0].tow+=1.0f/TWin.VScaleFactor;
\r
4146 vertex[3].tow+=1.0f/TWin.VScaleFactor;
\r
4155 vertex[2].tow+=1.0f;
\r
4156 vertex[3].tow+=1.0f;
\r
4159 vertex[0].tow+=1.0f;
\r
4160 vertex[1].tow+=1.0f;
\r
4163 vertex[1].tow+=1.0f;
\r
4164 vertex[3].tow+=1.0f;
\r
4167 vertex[0].tow+=1.0f;
\r
4168 vertex[2].tow+=1.0f;
\r
4171 vertex[1].tow+=1.0f;
\r
4172 vertex[2].tow+=1.0f;
\r
4175 vertex[0].tow+=1.0f;
\r
4176 vertex[3].tow+=1.0f;
\r
4185 void primPolyFT4(unsigned char * baseAddr)
\r
4187 unsigned long *gpuData = ((unsigned long *) baseAddr);
\r
4188 short *sgpuData = ((short *) baseAddr);
\r
4190 lx0 = sgpuData[2];
\r
4191 ly0 = sgpuData[3];
\r
4192 lx1 = sgpuData[6];
\r
4193 ly1 = sgpuData[7];
\r
4194 lx2 = sgpuData[10];
\r
4195 ly2 = sgpuData[11];
\r
4196 lx3 = sgpuData[14];
\r
4197 ly3 = sgpuData[15];
\r
4199 if(offset4()) return;
\r
4201 gl_vy[0]=baseAddr[9];//((gpuData[2]>>8)&0xff);
\r
4202 gl_vy[1]=baseAddr[17];//((gpuData[4]>>8)&0xff);
\r
4203 gl_vy[2]=baseAddr[25];//((gpuData[6]>>8)&0xff);
\r
4204 gl_vy[3]=baseAddr[33];//((gpuData[8]>>8)&0xff);
\r
4206 gl_ux[0]=baseAddr[8];//(gpuData[2]&0xff);
\r
4207 gl_ux[1]=baseAddr[16];//(gpuData[4]&0xff);
\r
4208 gl_ux[2]=baseAddr[24];//(gpuData[6]&0xff);
\r
4209 gl_ux[3]=baseAddr[32];//(gpuData[8]&0xff);
\r
4211 UpdateGlobalTP((unsigned short)(gpuData[4]>>16));
\r
4212 ulClutID=(gpuData[2]>>16);
\r
4214 bDrawTextured = TRUE;
\r
4215 bDrawSmoothShaded = FALSE;
\r
4216 SetRenderState(gpuData[0]);
\r
4218 /* if(iOffscreenDrawing)
\r
4221 if(bDrawOffscreen4())
\r
4223 InvalidateTextureAreaEx();
\r
4224 SetRenderColor(gpuData[0]);
\r
4225 drawPoly4FT(baseAddr);
\r
4229 SetRenderMode(gpuData[0], TRUE);
\r
4237 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[3], &vertex[2]);
\r
4239 if(bDrawMultiPass)
\r
4241 SetSemiTransMulti(1);
\r
4242 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[3], &vertex[2]);
\r
4248 if(bUseMultiPass) SetOpaqueColor(gpuData[0]);
\r
4251 /* if(bSmallAlpha && iFilterType<=2)
\r
4253 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
\r
4254 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
\r
4255 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[3], &vertex[2]);
\r
4256 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
\r
4257 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
\r
4262 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[3], &vertex[2]);
\r
4266 iDrawnSomething=1;
\r
4269 ////////////////////////////////////////////////////////////////////////
\r
4270 // cmd: smooth shaded Texture3
\r
4271 ////////////////////////////////////////////////////////////////////////
\r
4273 void primPolyGT3(unsigned char *baseAddr)
\r
4275 unsigned long *gpuData = ((unsigned long *) baseAddr);
\r
4276 short *sgpuData = ((short *) baseAddr);
\r
4278 lx0 = sgpuData[2];
\r
4279 ly0 = sgpuData[3];
\r
4280 lx1 = sgpuData[8];
\r
4281 ly1 = sgpuData[9];
\r
4282 lx2 = sgpuData[14];
\r
4283 ly2 = sgpuData[15];
\r
4285 if(offset3()) return;
\r
4287 // do texture stuff
\r
4288 gl_ux[0]=gl_ux[3]=baseAddr[8];//gpuData[2]&0xff;
\r
4289 gl_vy[0]=gl_vy[3]=baseAddr[9];//(gpuData[2]>>8)&0xff;
\r
4290 gl_ux[1]=baseAddr[20];//gpuData[5]&0xff;
\r
4291 gl_vy[1]=baseAddr[21];//(gpuData[5]>>8)&0xff;
\r
4292 gl_ux[2]=baseAddr[32];//gpuData[8]&0xff;
\r
4293 gl_vy[2]=baseAddr[33];//(gpuData[8]>>8)&0xff;
\r
4295 UpdateGlobalTP((unsigned short)(gpuData[5]>>16));
\r
4296 ulClutID=(gpuData[2]>>16);
\r
4298 bDrawTextured = TRUE;
\r
4299 bDrawSmoothShaded = TRUE;
\r
4300 SetRenderState(gpuData[0]);
\r
4302 /* if(iOffscreenDrawing)
\r
4305 if(bDrawOffscreen3())
\r
4307 InvalidateTextureAreaEx();
\r
4308 drawPoly3GT(baseAddr);
\r
4312 SetRenderMode(gpuData[0], FALSE);
\r
4317 if(bDrawNonShaded)
\r
4319 //if(!bUseMultiPass) vertex[0].lcol=DoubleBGR2RGB(gpuData[0]); else vertex[0].lcol=gpuData[0];
\r
4321 /* if(bGLBlend) vertex[0].c.lcol=0x7f7f7f;
\r
4322 else */vertex[0].c.lcol=0xffffff;
\r
4323 vertex[0].c.col[3]=ubGloAlpha;
\r
4324 SETCOL(vertex[0]);
\r
4326 PRIMdrawTexturedTri(&vertex[0], &vertex[1], &vertex[2]);
\r
4332 PRIMdrawTexturedTri(&vertex[0], &vertex[1], &vertex[2]);
\r
4338 /* if(!bUseMultiPass && !bGLBlend)
\r
4340 */ vertex[0].c.lcol=DoubleBGR2RGB(gpuData[0]);
\r
4341 vertex[1].c.lcol=DoubleBGR2RGB(gpuData[3]);
\r
4342 vertex[2].c.lcol=DoubleBGR2RGB(gpuData[6]);
\r
4346 vertex[0].c.lcol=gpuData[0];
\r
4347 vertex[1].c.lcol=gpuData[3];
\r
4348 vertex[2].c.lcol=gpuData[6];
\r
4350 vertex[0].c.col[3]=vertex[1].c.col[3]=vertex[2].c.col[3]=ubGloAlpha;
\r
4352 PRIMdrawTexGouraudTriColor(&vertex[0], &vertex[1], &vertex[2]);
\r
4354 if(bDrawMultiPass)
\r
4356 SetSemiTransMulti(1);
\r
4357 PRIMdrawTexGouraudTriColor(&vertex[0], &vertex[1], &vertex[2]);
\r
4363 if(bUseMultiPass)
\r
4365 vertex[0].c.lcol=DoubleBGR2RGB(gpuData[0]);
\r
4366 vertex[1].c.lcol=DoubleBGR2RGB(gpuData[3]);
\r
4367 vertex[2].c.lcol=DoubleBGR2RGB(gpuData[6]);
\r
4368 vertex[0].c.col[3]=vertex[1].c.col[3]=vertex[2].c.col[3]=ubGloAlpha;
\r
4371 PRIMdrawTexGouraudTriColor(&vertex[0], &vertex[1], &vertex[2]);
\r
4375 iDrawnSomething=1;
\r
4378 ////////////////////////////////////////////////////////////////////////
\r
4379 // cmd: smooth shaded Poly3
\r
4380 ////////////////////////////////////////////////////////////////////////
\r
4382 void primPolyG3(unsigned char *baseAddr)
\r
4384 unsigned long *gpuData = ((unsigned long *) baseAddr);
\r
4385 short *sgpuData = ((short *) baseAddr);
\r
4387 lx0 = sgpuData[2];
\r
4388 ly0 = sgpuData[3];
\r
4389 lx1 = sgpuData[6];
\r
4390 ly1 = sgpuData[7];
\r
4391 lx2 = sgpuData[10];
\r
4392 ly2 = sgpuData[11];
\r
4394 if(offset3()) return;
\r
4396 bDrawTextured = FALSE;
\r
4397 bDrawSmoothShaded = TRUE;
\r
4398 SetRenderState(gpuData[0]);
\r
4400 /* if(iOffscreenDrawing)
\r
4403 if(bDrawOffscreen3())
\r
4405 InvalidateTextureAreaEx();
\r
4406 drawPoly3G(gpuData[0], gpuData[2], gpuData[4]);
\r
4410 SetRenderMode(gpuData[0], FALSE);
\r
4413 vertex[0].c.lcol=gpuData[0];
\r
4414 vertex[1].c.lcol=gpuData[2];
\r
4415 vertex[2].c.lcol=gpuData[4];
\r
4416 vertex[0].c.col[3]=vertex[1].c.col[3]=vertex[2].c.col[3]=ubGloColAlpha;
\r
4418 PRIMdrawGouraudTriColor(&vertex[0], &vertex[1], &vertex[2]);
\r
4420 iDrawnSomething=1;
\r
4423 ////////////////////////////////////////////////////////////////////////
\r
4424 // cmd: smooth shaded Texture4
\r
4425 ////////////////////////////////////////////////////////////////////////
\r
4427 void primPolyGT4(unsigned char *baseAddr)
\r
4429 unsigned long *gpuData = ((unsigned long *) baseAddr);
\r
4430 short *sgpuData = ((short *) baseAddr);
\r
4432 lx0 = sgpuData[2];
\r
4433 ly0 = sgpuData[3];
\r
4434 lx1 = sgpuData[8];
\r
4435 ly1 = sgpuData[9];
\r
4436 lx2 = sgpuData[14];
\r
4437 ly2 = sgpuData[15];
\r
4438 lx3 = sgpuData[20];
\r
4439 ly3 = sgpuData[21];
\r
4441 if(offset4()) return;
\r
4443 // do texture stuff
\r
4444 gl_ux[0]=baseAddr[8];//gpuData[2]&0xff;
\r
4445 gl_vy[0]=baseAddr[9];//(gpuData[2]>>8)&0xff;
\r
4446 gl_ux[1]=baseAddr[20];//gpuData[5]&0xff;
\r
4447 gl_vy[1]=baseAddr[21];//(gpuData[5]>>8)&0xff;
\r
4448 gl_ux[2]=baseAddr[32];//gpuData[8]&0xff;
\r
4449 gl_vy[2]=baseAddr[33];//(gpuData[8]>>8)&0xff;
\r
4450 gl_ux[3]=baseAddr[44];//gpuData[11]&0xff;
\r
4451 gl_vy[3]=baseAddr[45];//(gpuData[11]>>8)&0xff;
\r
4453 UpdateGlobalTP((unsigned short)(gpuData[5]>>16));
\r
4454 ulClutID=(gpuData[2]>>16);
\r
4456 bDrawTextured = TRUE;
\r
4457 bDrawSmoothShaded = TRUE;
\r
4458 SetRenderState(gpuData[0]);
\r
4460 /* if(iOffscreenDrawing)
\r
4463 if(bDrawOffscreen4())
\r
4465 InvalidateTextureAreaEx();
\r
4466 drawPoly4GT(baseAddr);
\r
4470 SetRenderMode(gpuData[0], FALSE);
\r
4477 if(bDrawNonShaded)
\r
4479 //if(!bUseMultiPass) vertex[0].lcol=DoubleBGR2RGB(gpuData[0]); else vertex[0].lcol=gpuData[0];
\r
4480 /* if(bGLBlend) vertex[0].c.lcol=0x7f7f7f;
\r
4481 else */vertex[0].c.lcol=0xffffff;
\r
4482 vertex[0].c.col[3]=ubGloAlpha;
\r
4483 SETCOL(vertex[0]);
\r
4485 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[3], &vertex[2]);
\r
4490 ubGloAlpha=ubGloColAlpha=0xff;
\r
4492 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[3], &vertex[2]);
\r
4498 // if(!bUseMultiPass && !bGLBlend)
\r
4500 vertex[0].c.lcol=DoubleBGR2RGB(gpuData[0]);
\r
4501 vertex[1].c.lcol=DoubleBGR2RGB(gpuData[3]);
\r
4502 vertex[2].c.lcol=DoubleBGR2RGB(gpuData[6]);
\r
4503 vertex[3].c.lcol=DoubleBGR2RGB(gpuData[9]);
\r
4507 vertex[0].c.lcol=gpuData[0];
\r
4508 vertex[1].c.lcol=gpuData[3];
\r
4509 vertex[2].c.lcol=gpuData[6];
\r
4510 vertex[3].c.lcol=gpuData[9];
\r
4513 vertex[0].c.col[3]=vertex[1].c.col[3]=vertex[2].c.col[3]=vertex[3].c.col[3]=ubGloAlpha;
\r
4515 PRIMdrawTexGouraudTriColorQuad(&vertex[0], &vertex[1], &vertex[3],&vertex[2]);
\r
4517 if(bDrawMultiPass)
\r
4519 SetSemiTransMulti(1);
\r
4520 PRIMdrawTexGouraudTriColorQuad(&vertex[0], &vertex[1], &vertex[3],&vertex[2]);
\r
4526 if(bUseMultiPass)
\r
4528 vertex[0].c.lcol=DoubleBGR2RGB(gpuData[0]);
\r
4529 vertex[1].c.lcol=DoubleBGR2RGB(gpuData[3]);
\r
4530 vertex[2].c.lcol=DoubleBGR2RGB(gpuData[6]);
\r
4531 vertex[3].c.lcol=DoubleBGR2RGB(gpuData[9]);
\r
4532 vertex[0].c.col[3]=vertex[1].c.col[3]=vertex[2].c.col[3]=vertex[3].c.col[3]=ubGloAlpha;
\r
4534 ubGloAlpha=ubGloColAlpha=0xff;
\r
4536 PRIMdrawTexGouraudTriColorQuad(&vertex[0], &vertex[1], &vertex[3],&vertex[2]);
\r
4540 iDrawnSomething=1;
\r
4543 ////////////////////////////////////////////////////////////////////////
\r
4544 // cmd: smooth shaded Poly3
\r
4545 ////////////////////////////////////////////////////////////////////////
\r
4547 void primPolyF3(unsigned char *baseAddr)
\r
4549 unsigned long *gpuData = ((unsigned long *) baseAddr);
\r
4550 short *sgpuData = ((short *) baseAddr);
\r
4552 lx0 = sgpuData[2];
\r
4553 ly0 = sgpuData[3];
\r
4554 lx1 = sgpuData[4];
\r
4555 ly1 = sgpuData[5];
\r
4556 lx2 = sgpuData[6];
\r
4557 ly2 = sgpuData[7];
\r
4559 if(offset3()) return;
\r
4561 bDrawTextured = FALSE;
\r
4562 bDrawSmoothShaded = FALSE;
\r
4563 SetRenderState(gpuData[0]);
\r
4565 /* if(iOffscreenDrawing)
\r
4568 if(bDrawOffscreen3())
\r
4570 InvalidateTextureAreaEx();
\r
4571 drawPoly3F(gpuData[0]);
\r
4575 SetRenderMode(gpuData[0], FALSE);
\r
4578 vertex[0].c.lcol=gpuData[0];
\r
4579 vertex[0].c.col[3]=ubGloColAlpha;
\r
4580 SETCOL(vertex[0]);
\r
4582 PRIMdrawTri(&vertex[0], &vertex[1], &vertex[2]);
\r
4584 iDrawnSomething=1;
\r
4587 ////////////////////////////////////////////////////////////////////////
\r
4588 // cmd: skipping shaded polylines
\r
4589 ////////////////////////////////////////////////////////////////////////
\r
4591 void primLineGSkip(unsigned char *baseAddr)
\r
4593 unsigned long *gpuData = ((unsigned long *) baseAddr);
\r
4594 short *sgpuData = ((short *) baseAddr);
\r
4598 lx1 = sgpuData[2];
\r
4599 ly1 = sgpuData[3];
\r
4601 while(!(((gpuData[i] & 0xF000F000) == 0x50005000) && i>=4))
\r
4605 ly1 = (short)((gpuData[i]>>16) & 0xffff);
\r
4606 lx1 = (short)(gpuData[i] & 0xffff);
\r
4608 i++;if(i>iMax) break;
\r
4612 ////////////////////////////////////////////////////////////////////////
\r
4613 // cmd: shaded polylines
\r
4614 ////////////////////////////////////////////////////////////////////////
\r
4616 void primLineGEx(unsigned char *baseAddr)
\r
4618 unsigned long *gpuData = ((unsigned long *) baseAddr);
\r
4620 short cx0,cx1,cy0,cy1;int i;BOOL bDraw=TRUE;
\r
4622 bDrawTextured = FALSE;
\r
4623 bDrawSmoothShaded = TRUE;
\r
4624 SetRenderState(gpuData[0]);
\r
4625 SetRenderMode(gpuData[0], FALSE);
\r
4628 vertex[0].c.lcol=vertex[3].c.lcol=gpuData[0];
\r
4629 vertex[0].c.col[3]=vertex[3].c.col[3]=ubGloColAlpha;
\r
4630 ly1 = (short)((gpuData[1]>>16) & 0xffff);
\r
4631 lx1 = (short)(gpuData[1] & 0xffff);
\r
4635 //while((gpuData[i]>>24)!=0x55)
\r
4636 //while((gpuData[i]&0x50000000)!=0x50000000)
\r
4637 // currently best way to check for poly line end:
\r
4638 while(!(((gpuData[i] & 0xF000F000) == 0x50005000) && i>=4))
\r
4640 ly0 = ly1;lx0=lx1;
\r
4641 vertex[1].c.lcol=vertex[2].c.lcol=vertex[0].c.lcol;
\r
4642 vertex[0].c.lcol=vertex[3].c.lcol=gpuData[i];
\r
4643 vertex[0].c.col[3]=vertex[3].c.col[3]=ubGloColAlpha;
\r
4647 ly1 = (short)((gpuData[i]>>16) & 0xffff);
\r
4648 lx1 = (short)(gpuData[i] & 0xffff);
\r
4650 if(offsetline()) bDraw=FALSE; else bDraw=TRUE;
\r
4652 if (bDraw && ((lx0 != lx1) || (ly0 != ly1)))
\r
4654 /* if(iOffscreenDrawing)
\r
4656 cx0=lx0;cx1=lx1;cy0=ly0;cy1=ly1;
\r
4658 if(bDrawOffscreen4())
\r
4660 InvalidateTextureAreaEx();
\r
4661 drawPoly4G(gpuData[i-3],gpuData[i-1],gpuData[i-3],gpuData[i-1]);
\r
4663 lx0=cx0;lx1=cx1;ly0=cy0;ly1=cy1;
\r
4666 PRIMdrawGouraudLine(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
4673 iDrawnSomething=1;
\r
4676 ////////////////////////////////////////////////////////////////////////
\r
4677 // cmd: shaded polyline2
\r
4678 ////////////////////////////////////////////////////////////////////////
\r
4680 void primLineG2(unsigned char *baseAddr)
\r
4682 unsigned long *gpuData = ((unsigned long *) baseAddr);
\r
4683 short *sgpuData = ((short *) baseAddr);
\r
4685 lx0 = sgpuData[2];
\r
4686 ly0 = sgpuData[3];
\r
4687 lx1 = sgpuData[6];
\r
4688 ly1 = sgpuData[7];
\r
4690 vertex[0].c.lcol=vertex[3].c.lcol=gpuData[0];
\r
4691 vertex[1].c.lcol=vertex[2].c.lcol=gpuData[2];
\r
4692 vertex[0].c.col[3]=vertex[1].c.col[3]=vertex[2].c.col[3]=vertex[3].c.col[3]=ubGloColAlpha;
\r
4694 bDrawTextured = FALSE;
\r
4695 bDrawSmoothShaded = TRUE;
\r
4697 if((lx0 == lx1) && (ly0 == ly1)) return;
\r
4699 if(offsetline()) return;
\r
4701 SetRenderState(gpuData[0]);
\r
4702 SetRenderMode(gpuData[0], FALSE);
\r
4705 /* if(iOffscreenDrawing)
\r
4708 if(bDrawOffscreen4())
\r
4710 InvalidateTextureAreaEx();
\r
4711 drawPoly4G(gpuData[0],gpuData[2],gpuData[0],gpuData[2]);
\r
4715 //if(ClipVertexList4())
\r
4716 PRIMdrawGouraudLine(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
4718 iDrawnSomething=1;
\r
4721 ////////////////////////////////////////////////////////////////////////
\r
4722 // cmd: skipping flat polylines
\r
4723 ////////////////////////////////////////////////////////////////////////
\r
4725 void primLineFSkip(unsigned char *baseAddr)
\r
4727 unsigned long *gpuData = ((unsigned long *) baseAddr);
\r
4730 ly1 = (short)((gpuData[1]>>16) & 0xffff);
\r
4731 lx1 = (short)(gpuData[1] & 0xffff);
\r
4733 while(!(((gpuData[i] & 0xF000F000) == 0x50005000) && i>=3))
\r
4735 ly1 = (short)((gpuData[i]>>16) & 0xffff);
\r
4736 lx1 = (short)(gpuData[i] & 0xffff);
\r
4737 i++;if(i>iMax) break;
\r
4741 ////////////////////////////////////////////////////////////////////////
\r
4742 // cmd: drawing flat polylines
\r
4743 ////////////////////////////////////////////////////////////////////////
\r
4745 void primLineFEx(unsigned char *baseAddr)
\r
4747 unsigned long *gpuData = ((unsigned long *) baseAddr);
\r
4749 short cx0,cx1,cy0,cy1;int i;
\r
4753 bDrawTextured = FALSE;
\r
4754 bDrawSmoothShaded = FALSE;
\r
4755 SetRenderState(gpuData[0]);
\r
4756 SetRenderMode(gpuData[0], FALSE);
\r
4759 vertex[0].c.lcol=gpuData[0];
\r
4760 vertex[0].c.col[3]=ubGloColAlpha;
\r
4762 ly1 = (short)((gpuData[1]>>16) & 0xffff);
\r
4763 lx1 = (short)(gpuData[1] & 0xffff);
\r
4767 // while(!(gpuData[i]&0x40000000))
\r
4768 // while((gpuData[i]>>24)!=0x55)
\r
4769 // while((gpuData[i]&0x50000000)!=0x50000000)
\r
4770 // currently best way to check for poly line end:
\r
4771 while(!(((gpuData[i] & 0xF000F000) == 0x50005000) && i>=3))
\r
4773 ly0 = ly1;lx0=lx1;
\r
4774 ly1 = (short)((gpuData[i]>>16) & 0xffff);
\r
4775 lx1 = (short)(gpuData[i] & 0xffff);
\r
4779 /* if(iOffscreenDrawing)
\r
4781 cx0=lx0;cx1=lx1;cy0=ly0;cy1=ly1;
\r
4783 if(bDrawOffscreen4())
\r
4785 InvalidateTextureAreaEx();
\r
4786 drawPoly4F(gpuData[0]);
\r
4788 lx0=cx0;lx1=cx1;ly0=cy0;ly1=cy1;
\r
4790 PRIMdrawFlatLine(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
4793 i++;if(i>iMax) break;
\r
4796 iDrawnSomething=1;
\r
4799 ////////////////////////////////////////////////////////////////////////
\r
4800 // cmd: drawing flat polyline2
\r
4801 ////////////////////////////////////////////////////////////////////////
\r
4803 void primLineF2(unsigned char *baseAddr)
\r
4805 unsigned long *gpuData = ((unsigned long *) baseAddr);
\r
4806 short *sgpuData = ((short *) baseAddr);
\r
4808 lx0 = sgpuData[2];
\r
4809 ly0 = sgpuData[3];
\r
4810 lx1 = sgpuData[4];
\r
4811 ly1 = sgpuData[5];
\r
4813 if(offsetline()) return;
\r
4815 bDrawTextured = FALSE;
\r
4816 bDrawSmoothShaded = FALSE;
\r
4817 SetRenderState(gpuData[0]);
\r
4818 SetRenderMode(gpuData[0], FALSE);
\r
4821 vertex[0].c.lcol=gpuData[0];
\r
4822 vertex[0].c.col[3]=ubGloColAlpha;
\r
4824 /* if(iOffscreenDrawing)
\r
4827 if(bDrawOffscreen4())
\r
4829 InvalidateTextureAreaEx();
\r
4830 drawPoly4F(gpuData[0]);
\r
4834 //if(ClipVertexList4())
\r
4835 PRIMdrawFlatLine(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
4837 iDrawnSomething=1;
\r
4840 ////////////////////////////////////////////////////////////////////////
\r
4841 // cmd: well, easiest command... not implemented
\r
4842 ////////////////////////////////////////////////////////////////////////
\r
4844 void primNI(unsigned char *bA)
\r
4848 ////////////////////////////////////////////////////////////////////////
\r
4849 // cmd func ptr table
\r
4850 ////////////////////////////////////////////////////////////////////////
\r
4852 void (*primTableJ[256])(unsigned char *) =
\r
4855 primNI,primNI,primBlkFill,primNI,primNI,primNI,primNI,primNI,
\r
4857 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4859 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4861 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4863 primPolyF3,primPolyF3,primPolyF3,primPolyF3,primPolyFT3,primPolyFT3,primPolyFT3,primPolyFT3,
\r
4865 primPolyF4,primPolyF4,primPolyF4,primPolyF4,primPolyFT4,primPolyFT4,primPolyFT4,primPolyFT4,
\r
4867 primPolyG3,primPolyG3,primPolyG3,primPolyG3,primPolyGT3,primPolyGT3,primPolyGT3,primPolyGT3,
\r
4869 primPolyG4,primPolyG4,primPolyG4,primPolyG4,primPolyGT4,primPolyGT4,primPolyGT4,primPolyGT4,
\r
4871 primLineF2,primLineF2,primLineF2,primLineF2,primNI,primNI,primNI,primNI,
\r
4873 primLineFEx,primLineFEx,primLineFEx,primLineFEx,primLineFEx,primLineFEx,primLineFEx,primLineFEx,
\r
4875 primLineG2,primLineG2,primLineG2,primLineG2,primNI,primNI,primNI,primNI,
\r
4877 primLineGEx,primLineGEx,primLineGEx,primLineGEx,primLineGEx,primLineGEx,primLineGEx,primLineGEx,
\r
4879 primTileS,primTileS,primTileS,primTileS,primSprtS,primSprtS,primSprtS,primSprtS,
\r
4881 primTile1,primTile1,primTile1,primTile1,primNI,primNI,primNI,primNI,
\r
4883 primTile8,primTile8,primTile8,primTile8,primSprt8,primSprt8,primSprt8,primSprt8,
\r
4885 primTile16,primTile16,primTile16,primTile16,primSprt16,primSprt16,primSprt16,primSprt16,
\r
4887 primMoveImage,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4889 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4891 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4893 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4895 primLoadImage,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4897 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4899 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4901 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4903 primStoreImage,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4905 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4907 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4909 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4911 primNI,cmdTexturePage,cmdTextureWindow,cmdDrawAreaStart,cmdDrawAreaEnd,cmdDrawOffset,cmdSTP,primNI,
\r
4913 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4915 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4917 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI
\r
4920 ////////////////////////////////////////////////////////////////////////
\r
4921 // cmd func ptr table for skipping
\r
4922 ////////////////////////////////////////////////////////////////////////
\r
4924 void (*primTableSkip[256])(unsigned char *) =
\r
4927 primNI,primNI,primBlkFill,primNI,primNI,primNI,primNI,primNI,
\r
4929 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4931 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4933 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4935 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4937 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4939 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4941 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4943 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4945 primLineFSkip,primLineFSkip,primLineFSkip,primLineFSkip,primLineFSkip,primLineFSkip,primLineFSkip,primLineFSkip,
\r
4947 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4949 primLineGSkip,primLineGSkip,primLineGSkip,primLineGSkip,primLineGSkip,primLineGSkip,primLineGSkip,primLineGSkip,
\r
4951 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4953 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4955 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4957 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4959 primMoveImage,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4961 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4963 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4965 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4967 primLoadImage,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4969 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4971 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4973 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4975 primStoreImage,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4977 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4979 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4981 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4983 primNI,cmdTexturePage,cmdTextureWindow,cmdDrawAreaStart,cmdDrawAreaEnd,cmdDrawOffset,cmdSTP,primNI,
\r
4985 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4987 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4989 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI
\r