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
48 BOOL bDrawTextured; // current active drawing states
\r
49 BOOL bDrawSmoothShaded;
\r
50 BOOL bOldSmoothShaded;
\r
51 BOOL bDrawNonShaded;
\r
52 BOOL bDrawMultiPass;
\r
53 int iOffscreenDrawing;
\r
54 int iDrawnSomething=0;
\r
56 BOOL bRenderFrontBuffer=FALSE; // flag for front buffer rendering
\r
58 GLubyte ubGloAlpha; // texture alpha
\r
59 GLubyte ubGloColAlpha; // color alpha
\r
60 int iFilterType; // type of filter
\r
61 BOOL bFullVRam=FALSE; // sign for tex win
\r
62 BOOL bDrawDither; // sign for dither
\r
63 BOOL bUseMultiPass; // sign for multi pass
\r
64 GLuint gTexName; // binded texture
\r
65 BOOL bTexEnabled; // texture enable flag
\r
66 BOOL bBlendEnable; // blend enable flag
\r
67 PSXRect_t xrUploadArea; // rect to upload
\r
68 PSXRect_t xrUploadAreaIL; // rect to upload
\r
69 PSXRect_t xrUploadAreaRGB24; // rect to upload rgb24
\r
70 int iSpriteTex=0; // flag for "hey, it's a sprite"
\r
71 unsigned short usMirror; // mirror, mirror on the wall
\r
73 BOOL bNeedUploadAfter=FALSE; // sign for uploading in next frame
\r
74 BOOL bNeedUploadTest=FALSE; // sign for upload test
\r
75 BOOL bUsingTWin=FALSE; // tex win active flag
\r
76 BOOL bUsingMovie=FALSE; // movie active flag
\r
77 PSXRect_t xrMovieArea; // rect for movie upload
\r
78 short sSprite_ux2; // needed for sprire adjust
\r
79 short sSprite_vy2; //
\r
80 unsigned int ulOLDCOL=0; // active color
\r
81 unsigned int ulClutID; // clut
\r
83 unsigned int dwCfgFixes; // game fixes
\r
84 unsigned int dwActFixes=0;
\r
85 unsigned int dwEmuFixes=0;
\r
88 int drawX,drawY,drawW,drawH; // offscreen drawing checkers
\r
89 short sxmin,sxmax,symin,symax;
\r
90 unsigned int CSVERTEX=0,CSCOLOR=0,CSTEXTURE=0;
\r
92 void offsetPSX4(void)
\r
94 lx0 += PSXDisplay.DrawOffset.x;
\r
95 ly0 += PSXDisplay.DrawOffset.y;
\r
96 lx1 += PSXDisplay.DrawOffset.x;
\r
97 ly1 += PSXDisplay.DrawOffset.y;
\r
98 lx2 += PSXDisplay.DrawOffset.x;
\r
99 ly2 += PSXDisplay.DrawOffset.y;
\r
100 lx3 += PSXDisplay.DrawOffset.x;
\r
101 ly3 += PSXDisplay.DrawOffset.y;
\r
104 ////////////////////////////////////////////////////////////////////////
\r
105 // Update global TP infos
\r
106 ////////////////////////////////////////////////////////////////////////
\r
108 void UpdateGlobalTP(unsigned short gdata)
\r
110 GlobalTextAddrX = (gdata << 6) & 0x3c0;
\r
112 if(iGPUHeight==1024) // ZN mode
\r
114 if(dwGPUVersion==2) // very special zn gpu
\r
116 GlobalTextAddrY =((gdata & 0x60 ) << 3);
\r
117 GlobalTextIL =(gdata & 0x2000) >> 13;
\r
118 GlobalTextABR = (unsigned short)((gdata >> 7) & 0x3);
\r
119 GlobalTextTP = (gdata >> 9) & 0x3;
\r
120 if(GlobalTextTP==3) GlobalTextTP=2;
\r
121 GlobalTexturePage = (GlobalTextAddrX>>6)+(GlobalTextAddrY>>4);
\r
123 STATUSREG = (STATUSREG & 0xffffe000 ) | (gdata & 0x1fff );
\r
126 else // "enhanced" psx gpu
\r
128 GlobalTextAddrY = (unsigned short)(((gdata << 4) & 0x100) | ((gdata >> 2) & 0x200));
\r
131 else GlobalTextAddrY = (gdata << 4) & 0x100; // "normal" psx gpu
\r
133 usMirror=gdata&0x3000;
\r
135 GlobalTextTP = (gdata >> 7) & 0x3; // tex mode (4,8,15)
\r
136 if(GlobalTextTP==3) GlobalTextTP=2; // seen in Wild9 :(
\r
137 GlobalTextABR = (gdata >> 5) & 0x3; // blend mode
\r
139 GlobalTexturePage = (GlobalTextAddrX>>6)+(GlobalTextAddrY>>4);
\r
141 STATUSREG&=~0x07ff; // Clear the necessary bits
\r
142 STATUSREG|=(gdata & 0x07ff); // set the necessary bits
\r
145 ////////////////////////////////////////////////////////////////////////
\r
146 // Some ASM color convertion... Lewpy's special...
\r
147 ////////////////////////////////////////////////////////////////////////
\r
150 unsigned int DoubleBGR2RGB (unsigned int BGR)
\r
152 unsigned int ebx,eax,edx;
\r
154 ebx=(BGR&0x000000ff)<<1;
\r
155 if(ebx&0x00000100) ebx=0x000000ff;
\r
157 eax=(BGR&0x0000ff00)<<1;
\r
158 if(eax&0x00010000) eax=0x0000ff00;
\r
160 edx=(BGR&0x00ff0000)<<1;
\r
161 if(edx&0x01000000) edx=0x00ff0000;
\r
163 return (ebx|eax|edx);
\r
166 unsigned short BGR24to16 (unsigned int BGR)
\r
168 return ((BGR>>3)&0x1f)|((BGR&0xf80000)>>9)|((BGR&0xf800)>>6);
\r
172 ////////////////////////////////////////////////////////////////////////
\r
173 // OpenGL primitive drawing commands
\r
174 ////////////////////////////////////////////////////////////////////////
\r
176 void PRIMdrawTexturedQuad(OGLVertex* vertex1, OGLVertex* vertex2,
\r
177 OGLVertex* vertex3, OGLVertex* vertex4)
\r
183 v[0].xyz.x = fpoint(vertex1->x);
\r
184 v[0].xyz.y = fpoint(vertex1->y);
\r
185 v[0].xyz.z = fpoint(vertex1->z);
\r
186 v[0].st.x = fpoint(vertex1->sow);
\r
187 v[0].st.y = fpoint(vertex1->tow);
\r
189 v[1].xyz.x = fpoint(vertex2->x);
\r
190 v[1].xyz.y = fpoint(vertex2->y);
\r
191 v[1].xyz.z = fpoint(vertex2->z);
\r
192 v[1].st.x = fpoint(vertex2->sow);
\r
193 v[1].st.y = fpoint(vertex2->tow);
\r
195 v[2].xyz.x = fpoint(vertex4->x);
\r
196 v[2].xyz.y = fpoint(vertex4->y);
\r
197 v[2].xyz.z = fpoint(vertex4->z);
\r
198 v[2].st.x = fpoint(vertex4->sow);
\r
199 v[2].st.y = fpoint(vertex4->tow);
\r
201 v[3].xyz.x = fpoint(vertex3->x);
\r
202 v[3].xyz.y = fpoint(vertex3->y);
\r
203 v[3].xyz.z = fpoint(vertex3->z);
\r
204 v[3].st.x = fpoint(vertex3->sow);
\r
205 v[3].st.y = fpoint(vertex3->tow);
\r
206 if (CSCOLOR==1) glDisableClientState(GL_COLOR_ARRAY);glError();
\r
207 if (CSTEXTURE==0) glEnableClientState(GL_TEXTURE_COORD_ARRAY);glError();
\r
208 if (CSVERTEX==0) glEnableClientState(GL_VERTEX_ARRAY);glError();
\r
209 glTexCoordPointer(2, GL_FLOAT, sizeof(v[0]), &v[0].st);glError();
\r
210 glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0].xyz);glError();
\r
211 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);glError();
\r
212 CSTEXTURE=CSVERTEX=1;
\r
216 /////////////////////////////////////////////////////////
\r
218 void PRIMdrawTexturedTri(OGLVertex* vertex1, OGLVertex* vertex2,
\r
219 OGLVertex* vertex3)
\r
222 if (vertex1->x==0&&vertex1->y==0&&vertex2->x==0&&vertex2->y==0&&vertex3->x==0&&vertex3->y==0) return;
\r
224 v[0].xyz.x = fpoint(vertex1->x);
\r
225 v[0].xyz.y = fpoint(vertex1->y);
\r
226 v[0].xyz.z = fpoint(vertex1->z);
\r
227 v[0].st.x = fpoint(vertex1->sow);
\r
228 v[0].st.y = fpoint(vertex1->tow);
\r
230 v[1].xyz.x = fpoint(vertex2->x);
\r
231 v[1].xyz.y = fpoint(vertex2->y);
\r
232 v[1].xyz.z = fpoint(vertex2->z);
\r
233 v[1].st.x = fpoint(vertex2->sow);
\r
234 v[1].st.y = fpoint(vertex2->tow);
\r
236 v[2].xyz.x = fpoint(vertex3->x);
\r
237 v[2].xyz.y = fpoint(vertex3->y);
\r
238 v[2].xyz.z = fpoint(vertex3->z);
\r
239 v[2].st.x = fpoint(vertex3->sow);
\r
240 v[2].st.y = fpoint(vertex3->tow);
\r
241 if (CSCOLOR==1) glDisableClientState(GL_COLOR_ARRAY);glError();
\r
242 if (CSTEXTURE==0) glEnableClientState(GL_TEXTURE_COORD_ARRAY);glError();
\r
243 if (CSVERTEX==0) glEnableClientState(GL_VERTEX_ARRAY);glError();
\r
244 glTexCoordPointer(2, GL_FLOAT, sizeof(v[0]), &v[0].st);glError();
\r
245 glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0].xyz);glError();
\r
246 glDrawArrays(GL_TRIANGLES, 0, 3);glError();
\r
247 CSTEXTURE=CSVERTEX=1;
\r
252 /////////////////////////////////////////////////////////
\r
254 void PRIMdrawTexGouraudTriColor(OGLVertex* vertex1, OGLVertex* vertex2,
\r
255 OGLVertex* vertex3)
\r
259 if (vertex1->x==0&&vertex1->y==0&&vertex2->x==0&&vertex2->y==0&&vertex3->x==0&&vertex3->y==0) return;
\r
261 v[0].xyz.x = fpoint(vertex1->x);
\r
262 v[0].xyz.y = fpoint(vertex1->y);
\r
263 v[0].xyz.z = fpoint(vertex1->z);
\r
264 v[0].st.x = fpoint(vertex1->sow);
\r
265 v[0].st.y = fpoint(vertex1->tow);
\r
266 v[0].rgba.r = vertex1->c.col[0];
\r
267 v[0].rgba.g = vertex1->c.col[1];
\r
268 v[0].rgba.b = vertex1->c.col[2];
\r
269 v[0].rgba.a = vertex1->c.col[3];
\r
271 v[1].xyz.x = fpoint(vertex2->x);
\r
272 v[1].xyz.y = fpoint(vertex2->y);
\r
273 v[1].xyz.z = fpoint(vertex2->z);
\r
274 v[1].st.x = fpoint(vertex2->sow);
\r
275 v[1].st.y = fpoint(vertex2->tow);
\r
276 v[1].rgba.r = vertex2->c.col[0];
\r
277 v[1].rgba.g = vertex2->c.col[1];
\r
278 v[1].rgba.b = vertex2->c.col[2];
\r
279 v[1].rgba.a = vertex2->c.col[3];
\r
281 v[2].xyz.x = fpoint(vertex3->x);
\r
282 v[2].xyz.y = fpoint(vertex3->y);
\r
283 v[2].xyz.z = fpoint(vertex3->z);
\r
284 v[2].st.x = fpoint(vertex3->sow);
\r
285 v[2].st.y = fpoint(vertex3->tow);
\r
286 v[2].rgba.r = vertex3->c.col[0];
\r
287 v[2].rgba.g = vertex3->c.col[1];
\r
288 v[2].rgba.b = vertex3->c.col[2];
\r
289 v[2].rgba.a = vertex3->c.col[3];
\r
291 if (CSTEXTURE==0) glEnableClientState(GL_TEXTURE_COORD_ARRAY);glError();
\r
292 if (CSVERTEX==0) glEnableClientState(GL_VERTEX_ARRAY);glError();
\r
293 if (CSCOLOR==0) glEnableClientState(GL_COLOR_ARRAY);glError();
\r
295 glTexCoordPointer(2, GL_FLOAT, sizeof(v[0]), &v[0].st);glError();
\r
296 glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0].xyz);glError();
\r
297 glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(v[0]), &v[0].rgba);glError();
\r
299 glDrawArrays(GL_TRIANGLES, 0, 3);glError();
\r
300 CSTEXTURE=CSVERTEX=CSCOLOR=1;
\r
303 /////////////////////////////////////////////////////////
\r
305 void PRIMdrawTexGouraudTriColorQuad(OGLVertex* vertex1, OGLVertex* vertex2,
\r
306 OGLVertex* vertex3, OGLVertex* vertex4)
\r
309 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
311 v[0].xyz.x = fpoint(vertex1->x);
\r
312 v[0].xyz.y = fpoint(vertex1->y);
\r
313 v[0].xyz.z = fpoint(vertex1->z);
\r
314 v[0].st.x = fpoint(vertex1->sow);
\r
315 v[0].st.y = fpoint(vertex1->tow);
\r
316 v[0].rgba.r = vertex1->c.col[0];
\r
317 v[0].rgba.g = vertex1->c.col[1];
\r
318 v[0].rgba.b = vertex1->c.col[2];
\r
319 v[0].rgba.a = vertex1->c.col[3];
\r
321 v[1].xyz.x = fpoint(vertex2->x);
\r
322 v[1].xyz.y = fpoint(vertex2->y);
\r
323 v[1].xyz.z = fpoint(vertex2->z);
\r
324 v[1].st.x = fpoint(vertex2->sow);
\r
325 v[1].st.y = fpoint(vertex2->tow);
\r
326 v[1].rgba.r = vertex2->c.col[0];
\r
327 v[1].rgba.g = vertex2->c.col[1];
\r
328 v[1].rgba.b = vertex2->c.col[2];
\r
329 v[1].rgba.a = vertex2->c.col[3];
\r
331 v[2].xyz.x = fpoint(vertex4->x);
\r
332 v[2].xyz.y = fpoint(vertex4->y);
\r
333 v[2].xyz.z = fpoint(vertex4->z);
\r
334 v[2].st.x = fpoint(vertex4->sow);
\r
335 v[2].st.y = fpoint(vertex4->tow);
\r
336 v[2].rgba.r = vertex4->c.col[0];
\r
337 v[2].rgba.g = vertex4->c.col[1];
\r
338 v[2].rgba.b = vertex4->c.col[2];
\r
339 v[2].rgba.a = vertex4->c.col[3];
\r
341 v[3].xyz.x = fpoint(vertex3->x);
\r
342 v[3].xyz.y = fpoint(vertex3->y);
\r
343 v[3].xyz.z = fpoint(vertex3->z);
\r
344 v[3].st.x = fpoint(vertex3->sow);
\r
345 v[3].st.y = fpoint(vertex3->tow);
\r
346 v[3].rgba.r = vertex3->c.col[0];
\r
347 v[3].rgba.g = vertex3->c.col[1];
\r
348 v[3].rgba.b = vertex3->c.col[2];
\r
349 v[3].rgba.a = vertex3->c.col[3];
\r
351 if (CSTEXTURE==0) glEnableClientState(GL_TEXTURE_COORD_ARRAY);glError();
\r
352 if (CSVERTEX==0) glEnableClientState(GL_VERTEX_ARRAY);glError();
\r
353 if (CSCOLOR==0) glEnableClientState(GL_COLOR_ARRAY);glError();
\r
355 glTexCoordPointer(2, GL_FLOAT, sizeof(v[0]), &v[0].st);glError();
\r
356 glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0].xyz);glError();
\r
357 glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(v[0]), &v[0].rgba);glError();
\r
359 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);glError();
\r
360 CSTEXTURE=CSVERTEX=CSCOLOR=1;
\r
363 /////////////////////////////////////////////////////////
\r
365 void PRIMdrawTri(OGLVertex* vertex1, OGLVertex* vertex2, OGLVertex* vertex3)
\r
368 if (vertex1->x==0&&vertex1->y==0&&vertex2->x==0&&vertex2->y==0&&vertex3->x==0&&vertex3->y==0) return;
\r
370 v[0].x = fpoint(vertex1->x);
\r
371 v[0].y = fpoint(vertex1->y);
\r
372 v[0].z = fpoint(vertex1->z);
\r
374 v[1].x = fpoint(vertex2->x);
\r
375 v[1].y = fpoint(vertex2->y);
\r
376 v[1].z = fpoint(vertex2->z);
\r
378 v[2].x = fpoint(vertex3->x);
\r
379 v[2].y = fpoint(vertex3->y);
\r
380 v[2].z = fpoint(vertex3->z);
\r
382 if (CSVERTEX==0) glEnableClientState(GL_VERTEX_ARRAY);glError();
\r
383 if (CSTEXTURE==1) glDisableClientState(GL_TEXTURE_COORD_ARRAY);glError();
\r
384 if (CSCOLOR==1) glDisableClientState(GL_COLOR_ARRAY);glError();
\r
386 glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0]);glError();
\r
387 glDrawArrays(GL_TRIANGLES, 0, 3);glError();
\r
389 CSTEXTURE=CSCOLOR=0;
\r
393 /////////////////////////////////////////////////////////
\r
395 void PRIMdrawTri2(OGLVertex* vertex1, OGLVertex* vertex2,
\r
396 OGLVertex* vertex3, OGLVertex* vertex4)
\r
399 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
401 v[0].x = fpoint(vertex1->x);
\r
402 v[0].y = fpoint(vertex1->y);
\r
403 v[0].z = fpoint(vertex1->z);
\r
405 v[1].x = fpoint(vertex3->x);
\r
406 v[1].y = fpoint(vertex3->y);
\r
407 v[1].z = fpoint(vertex3->z);
\r
409 v[2].x = fpoint(vertex2->x);
\r
410 v[2].y = fpoint(vertex2->y);
\r
411 v[2].z = fpoint(vertex2->z);
\r
413 v[3].x = fpoint(vertex4->x);
\r
414 v[3].y = fpoint(vertex4->y);
\r
415 v[3].z = fpoint(vertex4->z);
\r
417 if (CSVERTEX==0) glEnableClientState(GL_VERTEX_ARRAY);glError();
\r
418 if (CSTEXTURE==1) glDisableClientState(GL_TEXTURE_COORD_ARRAY);glError();
\r
419 if (CSCOLOR==1) glDisableClientState(GL_COLOR_ARRAY);glError();
\r
421 glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0]);glError();
\r
422 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);glError();
\r
424 CSTEXTURE=CSCOLOR=0;
\r
427 /////////////////////////////////////////////////////////
\r
429 void PRIMdrawGouraudTriColor(OGLVertex* vertex1, OGLVertex* vertex2,
\r
430 OGLVertex* vertex3)
\r
433 if (vertex1->x==0&&vertex1->y==0&&vertex2->x==0&&vertex2->y==0&&vertex3->x==0&&vertex3->y==0) return;
\r
435 v[0].xyz.x = fpoint(vertex1->x);
\r
436 v[0].xyz.y = fpoint(vertex1->y);
\r
437 v[0].xyz.z = fpoint(vertex1->z);
\r
438 v[0].rgba.r = vertex1->c.col[0];
\r
439 v[0].rgba.g = vertex1->c.col[1];
\r
440 v[0].rgba.b = vertex1->c.col[2];
\r
441 v[0].rgba.a = vertex1->c.col[3];
\r
443 v[1].xyz.x = fpoint(vertex2->x);
\r
444 v[1].xyz.y = fpoint(vertex2->y);
\r
445 v[1].xyz.z = fpoint(vertex2->z);
\r
446 v[1].rgba.r = vertex2->c.col[0];
\r
447 v[1].rgba.g = vertex2->c.col[1];
\r
448 v[1].rgba.b = vertex2->c.col[2];
\r
449 v[1].rgba.a = vertex2->c.col[3];
\r
451 v[2].xyz.x = fpoint(vertex3->x);
\r
452 v[2].xyz.y = fpoint(vertex3->y);
\r
453 v[2].xyz.z = fpoint(vertex3->z);
\r
454 v[2].rgba.r = vertex3->c.col[0];
\r
455 v[2].rgba.g = vertex3->c.col[1];
\r
456 v[2].rgba.b = vertex3->c.col[2];
\r
457 v[2].rgba.a = vertex3->c.col[3];
\r
459 if (CSVERTEX==0) glEnableClientState(GL_VERTEX_ARRAY);glError();
\r
460 if (CSCOLOR==0) glEnableClientState(GL_COLOR_ARRAY);glError();
\r
461 if (CSTEXTURE==1) glDisableClientState(GL_TEXTURE_COORD_ARRAY);glError();
\r
463 glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0].xyz);glError();
\r
464 glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(v[0]), &v[0].rgba);glError();
\r
466 glDrawArrays(GL_TRIANGLES, 0, 3);glError();
\r
467 CSVERTEX=CSCOLOR=1;
\r
471 /////////////////////////////////////////////////////////
\r
473 void PRIMdrawGouraudTri2Color(OGLVertex* vertex1, OGLVertex* vertex2,
\r
474 OGLVertex* vertex3, OGLVertex* vertex4)
\r
477 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
479 v[0].xyz.x = fpoint(vertex1->x);
\r
480 v[0].xyz.y = fpoint(vertex1->y);
\r
481 v[0].xyz.z = fpoint(vertex1->z);
\r
482 v[0].rgba.r = vertex1->c.col[0];
\r
483 v[0].rgba.g = vertex1->c.col[1];
\r
484 v[0].rgba.b = vertex1->c.col[2];
\r
485 v[0].rgba.a = vertex1->c.col[3];
\r
487 v[1].xyz.x = fpoint(vertex2->x);
\r
488 v[1].xyz.y = fpoint(vertex2->y);
\r
489 v[1].xyz.z = fpoint(vertex2->z);
\r
490 v[1].rgba.r = vertex2->c.col[0];
\r
491 v[1].rgba.g = vertex2->c.col[1];
\r
492 v[1].rgba.b = vertex2->c.col[2];
\r
493 v[1].rgba.a = vertex2->c.col[3];
\r
495 v[2].xyz.x = fpoint(vertex3->x);
\r
496 v[2].xyz.y = fpoint(vertex3->y);
\r
497 v[2].xyz.z = fpoint(vertex3->z);
\r
498 v[2].rgba.r = vertex3->c.col[0];
\r
499 v[2].rgba.g = vertex3->c.col[1];
\r
500 v[2].rgba.b = vertex3->c.col[2];
\r
501 v[2].rgba.a = vertex3->c.col[3];
\r
503 v[3].xyz.x = fpoint(vertex4->x);
\r
504 v[3].xyz.y = fpoint(vertex4->y);
\r
505 v[3].xyz.z = fpoint(vertex4->z);
\r
506 v[3].rgba.r = vertex4->c.col[0];
\r
507 v[3].rgba.g = vertex4->c.col[1];
\r
508 v[3].rgba.b = vertex4->c.col[2];
\r
509 v[3].rgba.a = vertex4->c.col[3];
\r
511 if (CSTEXTURE==1) glDisableClientState(GL_TEXTURE_COORD_ARRAY);glError();
\r
512 if (CSVERTEX==0) glEnableClientState(GL_VERTEX_ARRAY);glError();
\r
513 if (CSCOLOR==0) glEnableClientState(GL_COLOR_ARRAY);glError();
\r
515 glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0].xyz);glError();
\r
516 glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(v[0]), &v[0].rgba);glError();
\r
518 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);glError();
\r
520 CSVERTEX=CSCOLOR=1;
\r
523 /////////////////////////////////////////////////////////
\r
525 void PRIMdrawFlatLine(OGLVertex* vertex1, OGLVertex* vertex2,OGLVertex* vertex3, OGLVertex* vertex4)
\r
528 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
530 v[0].xyz.x = fpoint(vertex1->x);
\r
531 v[0].xyz.y = fpoint(vertex1->y);
\r
532 v[0].xyz.z = fpoint(vertex1->z);
\r
533 v[0].rgba.r = vertex1->c.col[0];
\r
534 v[0].rgba.g = vertex1->c.col[1];
\r
535 v[0].rgba.b = vertex1->c.col[2];
\r
536 v[0].rgba.a = vertex1->c.col[3];
\r
538 v[1].xyz.x = fpoint(vertex2->x);
\r
539 v[1].xyz.y = fpoint(vertex2->y);
\r
540 v[1].xyz.z = fpoint(vertex2->z);
\r
541 v[1].rgba.r = vertex1->c.col[0];
\r
542 v[1].rgba.g = vertex1->c.col[1];
\r
543 v[1].rgba.b = vertex1->c.col[2];
\r
544 v[1].rgba.a = vertex1->c.col[3];
\r
546 v[2].xyz.x = fpoint(vertex4->x);
\r
547 v[2].xyz.y = fpoint(vertex4->y);
\r
548 v[2].xyz.z = fpoint(vertex4->z);
\r
549 v[2].rgba.r = vertex1->c.col[0];
\r
550 v[2].rgba.g = vertex1->c.col[1];
\r
551 v[2].rgba.b = vertex1->c.col[2];
\r
552 v[2].rgba.a = vertex1->c.col[3];
\r
554 v[3].xyz.x = fpoint(vertex3->x);
\r
555 v[3].xyz.y = fpoint(vertex3->y);
\r
556 v[3].xyz.z = fpoint(vertex3->z);
\r
557 v[3].rgba.r = vertex1->c.col[0];
\r
558 v[3].rgba.g = vertex1->c.col[1];
\r
559 v[3].rgba.b = vertex1->c.col[2];
\r
560 v[3].rgba.a = vertex1->c.col[3];
\r
562 if (CSTEXTURE==1) glDisableClientState(GL_TEXTURE_COORD_ARRAY);glError();
\r
563 if (CSVERTEX==0) glEnableClientState(GL_VERTEX_ARRAY);glError();
\r
564 if (CSCOLOR==0) glEnableClientState(GL_COLOR_ARRAY);glError();
\r
566 glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0].xyz);glError();
\r
567 glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(v[0]), &v[0].rgba);glError();
\r
569 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);glError();
\r
572 CSVERTEX=CSCOLOR=1;
\r
577 /////////////////////////////////////////////////////////
\r
579 void PRIMdrawGouraudLine(OGLVertex* vertex1, OGLVertex* vertex2,OGLVertex* vertex3, OGLVertex* vertex4)
\r
582 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
584 v[0].xyz.x = fpoint(vertex1->x);
\r
585 v[0].xyz.y = fpoint(vertex1->y);
\r
586 v[0].xyz.z = fpoint(vertex1->z);
\r
587 v[0].rgba.r = vertex1->c.col[0];
\r
588 v[0].rgba.g = vertex1->c.col[1];
\r
589 v[0].rgba.b = vertex1->c.col[2];
\r
590 v[0].rgba.a = vertex1->c.col[3];
\r
592 v[1].xyz.x = fpoint(vertex2->x);
\r
593 v[1].xyz.y = fpoint(vertex2->y);
\r
594 v[1].xyz.z = fpoint(vertex2->z);
\r
595 v[1].rgba.r = vertex2->c.col[0];
\r
596 v[1].rgba.g = vertex2->c.col[1];
\r
597 v[1].rgba.b = vertex2->c.col[2];
\r
598 v[1].rgba.a = vertex2->c.col[3];
\r
600 v[3].xyz.x = fpoint(vertex3->x);
\r
601 v[3].xyz.y = fpoint(vertex3->y);
\r
602 v[3].xyz.z = fpoint(vertex3->z);
\r
603 v[3].rgba.r = vertex3->c.col[0];
\r
604 v[3].rgba.g = vertex3->c.col[1];
\r
605 v[3].rgba.b = vertex3->c.col[2];
\r
606 v[3].rgba.a = vertex3->c.col[3];
\r
608 v[2].xyz.x = fpoint(vertex4->x);
\r
609 v[2].xyz.y = fpoint(vertex4->y);
\r
610 v[2].xyz.z = fpoint(vertex4->z);
\r
611 v[2].rgba.r = vertex4->c.col[0];
\r
612 v[2].rgba.g = vertex4->c.col[1];
\r
613 v[2].rgba.b = vertex4->c.col[2];
\r
614 v[2].rgba.a = vertex4->c.col[3];
\r
616 if (CSTEXTURE==1) glDisableClientState(GL_TEXTURE_COORD_ARRAY);glError();
\r
617 if (CSVERTEX==0) glEnableClientState(GL_VERTEX_ARRAY);glError();
\r
618 if (CSCOLOR==0) glEnableClientState(GL_COLOR_ARRAY);glError();
\r
620 glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0].xyz);glError();
\r
621 glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(v[0]), &v[0].rgba);glError();
\r
623 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);glError();
\r
625 CSVERTEX=CSCOLOR=1;
\r
628 /////////////////////////////////////////////////////////
\r
630 void PRIMdrawQuad(OGLVertex* vertex1, OGLVertex* vertex2,
\r
631 OGLVertex* vertex3, OGLVertex* vertex4)
\r
634 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
636 v[0].x = fpoint(vertex1->x);
\r
637 v[0].y = fpoint(vertex1->y);
\r
638 v[0].z = fpoint(vertex1->z);
\r
640 v[1].x = fpoint(vertex2->x);
\r
641 v[1].y = fpoint(vertex2->y);
\r
642 v[1].z = fpoint(vertex2->z);
\r
644 v[2].x = fpoint(vertex4->x);
\r
645 v[2].y = fpoint(vertex4->y);
\r
646 v[2].z = fpoint(vertex4->z);
\r
648 v[3].x = fpoint(vertex3->x);
\r
649 v[3].y = fpoint(vertex3->y);
\r
650 v[3].z = fpoint(vertex3->z);
\r
652 if (CSTEXTURE==1) glDisableClientState(GL_TEXTURE_COORD_ARRAY);glError();
\r
653 if (CSVERTEX==0) glEnableClientState(GL_VERTEX_ARRAY);glError();
\r
654 if (CSCOLOR==1) glDisableClientState(GL_COLOR_ARRAY);glError();
\r
656 glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0]);glError();
\r
657 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);glError();
\r
663 ////////////////////////////////////////////////////////////////////////
\r
664 // Transparent blending settings
\r
665 ////////////////////////////////////////////////////////////////////////
\r
667 static GLenum obm1=GL_ZERO;
\r
668 static GLenum obm2=GL_ZERO;
\r
670 typedef struct SEMITRANSTAG
\r
677 SemiTransParams TransSets[4]=
\r
679 {GL_SRC_ALPHA,GL_SRC_ALPHA, 127},
\r
680 {GL_ONE, GL_ONE, 255},
\r
681 {GL_ZERO, GL_ONE_MINUS_SRC_COLOR,255},
\r
682 {GL_ONE_MINUS_SRC_ALPHA,GL_ONE, 192}
\r
685 ////////////////////////////////////////////////////////////////////////
\r
687 void SetSemiTrans(void)
\r
690 * 0.5 x B + 0.5 x F
\r
691 * 1.0 x B + 1.0 x F
\r
692 * 1.0 x B - 1.0 x F
\r
693 * 1.0 x B +0.25 x F
\r
696 if(!DrawSemiTrans) // no semi trans at all?
\r
699 {glDisable(GL_BLEND);glError();bBlendEnable=FALSE;}// -> don't wanna blend
\r
700 ubGloAlpha=ubGloColAlpha=255; // -> full alpha
\r
701 return; // -> and bye
\r
704 ubGloAlpha=ubGloColAlpha=TransSets[GlobalTextABR].alpha;
\r
707 {glEnable(GL_BLEND);glError();bBlendEnable=TRUE;} // wanna blend
\r
709 if(TransSets[GlobalTextABR].srcFac!=obm1 ||
\r
710 TransSets[GlobalTextABR].dstFac!=obm2)
\r
712 //if(glBlendEquationEXTEx==NULL)
\r
714 obm1=TransSets[GlobalTextABR].srcFac;
\r
715 obm2=TransSets[GlobalTextABR].dstFac;
\r
716 glBlendFunc(obm1,obm2); glError(); // set blend func
\r
719 if(TransSets[GlobalTextABR].dstFac !=GL_ONE_MINUS_SRC_COLOR)
\r
721 if(obm2==GL_ONE_MINUS_SRC_COLOR)
\r
722 glBlendEquationEXTEx(FUNC_ADD_EXT);
\r
723 obm1=TransSets[GlobalTextABR].srcFac;
\r
724 obm2=TransSets[GlobalTextABR].dstFac;
\r
725 glBlendFunc(obm1,obm2); // set blend func
\r
729 glBlendEquationEXTEx(FUNC_REVERSESUBTRACT_EXT);
\r
730 obm1=TransSets[GlobalTextABR].srcFac;
\r
731 obm2=TransSets[GlobalTextABR].dstFac;
\r
732 glBlendFunc(GL_ONE,GL_ONE); // set blend func
\r
737 void SetScanTrans(void) // blending for scan lines
\r
739 /* if(glBlendEquationEXTEx!=NULL)
\r
741 if(obm2==GL_ONE_MINUS_SRC_COLOR)
\r
742 glBlendEquationEXTEx(FUNC_ADD_EXT);
\r
745 obm1=TransSets[0].srcFac;
\r
746 obm2=TransSets[0].dstFac;
\r
747 glBlendFunc(obm1,obm2); glError(); // set blend func
\r
750 void SetScanTexTrans(void) // blending for scan mask texture
\r
752 /* if(glBlendEquationEXTEx!=NULL)
\r
754 if(obm2==GL_ONE_MINUS_SRC_COLOR)
\r
755 glBlendEquationEXTEx(FUNC_ADD_EXT);
\r
758 obm1=TransSets[2].srcFac;
\r
759 obm2=TransSets[2].dstFac;
\r
760 glBlendFunc(obm1,obm2); glError(); // set blend func
\r
763 ////////////////////////////////////////////////////////////////////////
\r
764 // multi pass in old 'Advanced blending' mode... got it from Lewpy :)
\r
765 ////////////////////////////////////////////////////////////////////////
\r
767 SemiTransParams MultiTexTransSets[4][2]=
\r
770 {GL_ONE ,GL_SRC_ALPHA, 127},
\r
771 {GL_SRC_ALPHA,GL_ONE, 127}
\r
774 {GL_ONE, GL_SRC_ALPHA, 255},
\r
775 {GL_SRC_ALPHA,GL_ONE, 255}
\r
778 {GL_ZERO, GL_ONE_MINUS_SRC_COLOR,255},
\r
779 {GL_ZERO, GL_ONE_MINUS_SRC_COLOR,255}
\r
782 {GL_SRC_ALPHA,GL_ONE, 127},
\r
783 {GL_ONE_MINUS_SRC_ALPHA,GL_ONE, 255}
\r
787 ////////////////////////////////////////////////////////////////////////
\r
789 SemiTransParams MultiColTransSets[4]=
\r
791 {GL_ONE_MINUS_SRC_ALPHA,GL_SRC_ALPHA,127},
\r
792 {GL_ONE, GL_ONE, 255},
\r
793 {GL_ZERO, GL_ONE_MINUS_SRC_COLOR,255},
\r
794 {GL_SRC_ALPHA,GL_ONE, 127}
\r
797 ////////////////////////////////////////////////////////////////////////
\r
799 void SetSemiTransMulti(int Pass)
\r
801 static GLenum bm1=GL_ZERO;
\r
802 static GLenum bm2=GL_ONE;
\r
807 // are we enabling SemiTransparent mode?
\r
812 bm1=MultiTexTransSets[GlobalTextABR][Pass].srcFac;
\r
813 bm2=MultiTexTransSets[GlobalTextABR][Pass].dstFac;
\r
814 ubGloAlpha=MultiTexTransSets[GlobalTextABR][Pass].alpha;
\r
819 bm1=MultiColTransSets[GlobalTextABR].srcFac;
\r
820 bm2=MultiColTransSets[GlobalTextABR].dstFac;
\r
821 ubGloColAlpha=MultiColTransSets[GlobalTextABR].alpha;
\r
829 // disable blending
\r
830 bm1=GL_ONE;bm2=GL_ZERO;
\r
834 // disable blending, but add src col a second time
\r
835 bm1=GL_ONE;bm2=GL_ONE;
\r
840 {glEnable(GL_BLEND);glError();bBlendEnable=TRUE;} // wanna blend
\r
842 if(bm1!=obm1 || bm2!=obm2)
\r
844 glBlendFunc(bm1,bm2); glError(); // set blend func
\r
849 ////////////////////////////////////////////////////////////////////////
\r
850 // Set several rendering stuff including blending
\r
851 ////////////////////////////////////////////////////////////////////////
\r
853 void SetZMask3O(void)
\r
855 if(iUseMask && DrawSemiTrans && !iSetMask)
\r
857 vertex[0].z=vertex[1].z=vertex[2].z=gl_z;
\r
862 void SetZMask3(void)
\r
866 if(iSetMask || DrawSemiTrans)
\r
867 {vertex[0].z=vertex[1].z=vertex[2].z=0.95f;}
\r
870 vertex[0].z=vertex[1].z=vertex[2].z=gl_z;
\r
876 void SetZMask3NT(void)
\r
881 {vertex[0].z=vertex[1].z=vertex[2].z=0.95f;}
\r
884 vertex[0].z=vertex[1].z=vertex[2].z=gl_z;
\r
890 ////////////////////////////////////////////////////////////////////////
\r
892 void SetZMask4O(void)
\r
894 if(iUseMask && DrawSemiTrans && !iSetMask)
\r
896 vertex[0].z=vertex[1].z=vertex[2].z=vertex[3].z=gl_z;
\r
901 void SetZMask4(void)
\r
905 if(iSetMask || DrawSemiTrans)
\r
906 {vertex[0].z=vertex[1].z=vertex[2].z=vertex[3].z=0.95f;}
\r
909 vertex[0].z=vertex[1].z=vertex[2].z=vertex[3].z=gl_z;
\r
915 void SetZMask4NT(void)
\r
920 {vertex[0].z=vertex[1].z=vertex[2].z=vertex[3].z=0.95f;}
\r
923 vertex[0].z=vertex[1].z=vertex[2].z=vertex[3].z=gl_z;
\r
929 void SetZMask4SP(void)
\r
934 {vertex[0].z=vertex[1].z=vertex[2].z=vertex[3].z=0.95f;}
\r
939 vertex[0].z=vertex[1].z=vertex[2].z=vertex[3].z=gl_z;
\r
943 {vertex[0].z=vertex[1].z=vertex[2].z=vertex[3].z=0.95f;}
\r
948 ////////////////////////////////////////////////////////////////////////
\r
950 void SetRenderState(unsigned int DrawAttributes)
\r
952 bDrawNonShaded = (SHADETEXBIT(DrawAttributes)) ? TRUE : FALSE;
\r
953 DrawSemiTrans = (SEMITRANSBIT(DrawAttributes)) ? TRUE : FALSE;
\r
956 ////////////////////////////////////////////////////////////////////////
\r
958 void SetRenderColor(unsigned int DrawAttributes)
\r
960 if(bDrawNonShaded) {g_m1=g_m2=g_m3=128;}
\r
963 g_m1=DrawAttributes&0xff;
\r
964 g_m2=(DrawAttributes>>8)&0xff;
\r
965 g_m3=(DrawAttributes>>16)&0xff;
\r
969 ////////////////////////////////////////////////////////////////////////
\r
971 void SetRenderMode(unsigned int DrawAttributes,BOOL bSCol)
\r
973 if((bUseMultiPass) && (bDrawTextured) && !(bDrawNonShaded))
\r
974 {bDrawMultiPass = TRUE; SetSemiTransMulti(0);}
\r
975 else {bDrawMultiPass = FALSE;SetSemiTrans();}
\r
977 if(bDrawTextured) // texture ? build it/get it from cache
\r
980 if(bUsingTWin) currTex=LoadTextureWnd(GlobalTexturePage,GlobalTextTP, ulClutID);
\r
981 else if(bUsingMovie) currTex=LoadTextureMovie();
\r
982 else currTex=SelectSubTextureS(GlobalTextTP,ulClutID);
\r
984 if(gTexName!=currTex)
\r
985 {gTexName=currTex;glBindTexture(GL_TEXTURE_2D,currTex); glError();}
\r
987 if(!bTexEnabled) // -> turn texturing on
\r
988 {bTexEnabled=TRUE;glEnable(GL_TEXTURE_2D); glError();}
\r
990 else // no texture ?
\r
992 {bTexEnabled=FALSE;glDisable(GL_TEXTURE_2D); glError();} // -> turn texturing off
\r
994 if(bSCol) // also set color ?
\r
996 if((dwActFixes&4) && ((DrawAttributes&0x00ffffff)==0))
\r
997 DrawAttributes|=0x007f7f7f;
\r
999 if(bDrawNonShaded) // -> non shaded?
\r
1001 /* if(bGLBlend) vertex[0].c.lcol=0x7f7f7f; // --> solid color...
\r
1002 else */vertex[0].c.lcol=0xffffff;
\r
1004 else // -> shaded?
\r
1006 // if(!bUseMultiPass && !bGLBlend) // --> given color...
\r
1007 vertex[0].c.lcol=DoubleBGR2RGB(DrawAttributes);
\r
1008 // else vertex[0].c.lcol=DrawAttributes;
\r
1010 vertex[0].c.col[3]=ubGloAlpha; // -> set color with
\r
1011 SETCOL(vertex[0]); // texture alpha
\r
1014 if(bDrawSmoothShaded!=bOldSmoothShaded) // shading changed?
\r
1016 if(bDrawSmoothShaded) glShadeModel(GL_SMOOTH); // -> set actual shading
\r
1017 else glShadeModel(GL_FLAT);
\r
1019 bOldSmoothShaded=bDrawSmoothShaded;
\r
1023 ////////////////////////////////////////////////////////////////////////
\r
1024 // Set Opaque multipass color
\r
1025 ////////////////////////////////////////////////////////////////////////
\r
1027 void SetOpaqueColor(unsigned int DrawAttributes)
\r
1029 if(bDrawNonShaded) return; // no shading? bye
\r
1031 DrawAttributes=DoubleBGR2RGB(DrawAttributes); // multipass is just half color, so double it on opaque pass
\r
1032 vertex[0].c.lcol=DrawAttributes|0xff000000;
\r
1033 SETCOL(vertex[0]); // set color
\r
1036 ////////////////////////////////////////////////////////////////////////
\r
1037 // Fucking stupid screen coord checking
\r
1038 ////////////////////////////////////////////////////////////////////////
\r
1040 BOOL ClipVertexListScreen(void)
\r
1042 if (lx0 >= PSXDisplay.DisplayEnd.x) goto NEXTSCRTEST;
\r
1043 if (ly0 >= PSXDisplay.DisplayEnd.y) goto NEXTSCRTEST;
\r
1044 if (lx2 < PSXDisplay.DisplayPosition.x) goto NEXTSCRTEST;
\r
1045 if (ly2 < PSXDisplay.DisplayPosition.y) goto NEXTSCRTEST;
\r
1050 if(PSXDisplay.InterlacedTest) return FALSE;
\r
1052 if (lx0 >= PreviousPSXDisplay.DisplayEnd.x) return FALSE;
\r
1053 if (ly0 >= PreviousPSXDisplay.DisplayEnd.y) return FALSE;
\r
1054 if (lx2 < PreviousPSXDisplay.DisplayPosition.x) return FALSE;
\r
1055 if (ly2 < PreviousPSXDisplay.DisplayPosition.y) return FALSE;
\r
1060 ////////////////////////////////////////////////////////////////////////
\r
1062 BOOL bDrawOffscreenFront(void)
\r
1064 if(sxmin < PSXDisplay.DisplayPosition.x) return FALSE; // must be complete in front
\r
1065 if(symin < PSXDisplay.DisplayPosition.y) return FALSE;
\r
1066 if(sxmax > PSXDisplay.DisplayEnd.x) return FALSE;
\r
1067 if(symax > PSXDisplay.DisplayEnd.y) return FALSE;
\r
1071 BOOL bOnePointInFront(void)
\r
1073 if(sxmax< PSXDisplay.DisplayPosition.x)
\r
1076 if(symax< PSXDisplay.DisplayPosition.y)
\r
1079 if(sxmin>=PSXDisplay.DisplayEnd.x)
\r
1082 if(symin>=PSXDisplay.DisplayEnd.y)
\r
1089 BOOL bOnePointInBack(void)
\r
1091 if(sxmax< PreviousPSXDisplay.DisplayPosition.x)
\r
1094 if(symax< PreviousPSXDisplay.DisplayPosition.y)
\r
1097 if(sxmin>=PreviousPSXDisplay.DisplayEnd.x)
\r
1100 if(symin>=PreviousPSXDisplay.DisplayEnd.y)
\r
1106 BOOL bDrawOffscreen4(void)
\r
1108 BOOL bFront;short sW,sH;
\r
1110 sxmax=max(lx0,max(lx1,max(lx2,lx3)));
\r
1111 if(sxmax<drawX) return FALSE;
\r
1112 sxmin=min(lx0,min(lx1,min(lx2,lx3)));
\r
1113 if(sxmin>drawW) return FALSE;
\r
1114 symax=max(ly0,max(ly1,max(ly2,ly3)));
\r
1115 if(symax<drawY) return FALSE;
\r
1116 symin=min(ly0,min(ly1,min(ly2,ly3)));
\r
1117 if(symin>drawH) return FALSE;
\r
1119 if(PSXDisplay.Disabled) return TRUE; // disabled? ever
\r
1121 if(iOffscreenDrawing==1) return bFullVRam;
\r
1123 if(dwActFixes&1 && iOffscreenDrawing==4)
\r
1125 if(PreviousPSXDisplay.DisplayPosition.x==PSXDisplay.DisplayPosition.x &&
\r
1126 PreviousPSXDisplay.DisplayPosition.y==PSXDisplay.DisplayPosition.y &&
\r
1127 PreviousPSXDisplay.DisplayEnd.x==PSXDisplay.DisplayEnd.x &&
\r
1128 PreviousPSXDisplay.DisplayEnd.y==PSXDisplay.DisplayEnd.y)
\r
1130 bRenderFrontBuffer=TRUE;
\r
1135 sW=drawW-1;sH=drawH-1;
\r
1137 sxmin=min(sW,max(sxmin,drawX));
\r
1138 sxmax=max(drawX,min(sxmax,sW));
\r
1139 symin=min(sH,max(symin,drawY));
\r
1140 symax=max(drawY,min(symax,sH));
\r
1142 if(bOnePointInBack()) return bFullVRam;
\r
1144 if(iOffscreenDrawing==2)
\r
1145 bFront=bDrawOffscreenFront();
\r
1146 else bFront=bOnePointInFront();
\r
1150 if(PSXDisplay.InterlacedTest) return bFullVRam; // -> ok, no need for adjust
\r
1152 vertex[0].x=lx0 - PSXDisplay.DisplayPosition.x+PreviousPSXDisplay.Range.x0;
\r
1153 vertex[1].x=lx1 - PSXDisplay.DisplayPosition.x+PreviousPSXDisplay.Range.x0;
\r
1154 vertex[2].x=lx2 - PSXDisplay.DisplayPosition.x+PreviousPSXDisplay.Range.x0;
\r
1155 vertex[3].x=lx3 - PSXDisplay.DisplayPosition.x+PreviousPSXDisplay.Range.x0;
\r
1156 vertex[0].y=ly0 - PSXDisplay.DisplayPosition.y+PreviousPSXDisplay.Range.y0;
\r
1157 vertex[1].y=ly1 - PSXDisplay.DisplayPosition.y+PreviousPSXDisplay.Range.y0;
\r
1158 vertex[2].y=ly2 - PSXDisplay.DisplayPosition.y+PreviousPSXDisplay.Range.y0;
\r
1159 vertex[3].y=ly3 - PSXDisplay.DisplayPosition.y+PreviousPSXDisplay.Range.y0;
\r
1161 if(iOffscreenDrawing==4 && !(dwActFixes&1)) // -> frontbuffer wanted
\r
1163 bRenderFrontBuffer=TRUE;
\r
1166 return bFullVRam; // -> but no od
\r
1172 ////////////////////////////////////////////////////////////////////////
\r
1174 BOOL bDrawOffscreen3(void)
\r
1176 BOOL bFront;short sW,sH;
\r
1178 sxmax=max(lx0,max(lx1,lx2));
\r
1179 if(sxmax<drawX) return FALSE;
\r
1180 sxmin=min(lx0,min(lx1,lx2));
\r
1181 if(sxmin>drawW) return FALSE;
\r
1182 symax=max(ly0,max(ly1,ly2));
\r
1183 if(symax<drawY) return FALSE;
\r
1184 symin=min(ly0,min(ly1,ly2));
\r
1185 if(symin>drawH) return FALSE;
\r
1187 if(PSXDisplay.Disabled) return TRUE; // disabled? ever
\r
1189 if(iOffscreenDrawing==1) return bFullVRam;
\r
1191 sW=drawW-1;sH=drawH-1;
\r
1192 sxmin=min(sW,max(sxmin,drawX));
\r
1193 sxmax=max(drawX,min(sxmax,sW));
\r
1194 symin=min(sH,max(symin,drawY));
\r
1195 symax=max(drawY,min(symax,sH));
\r
1197 if(bOnePointInBack()) return bFullVRam;
\r
1199 if(iOffscreenDrawing==2)
\r
1200 bFront=bDrawOffscreenFront();
\r
1201 else bFront=bOnePointInFront();
\r
1205 if(PSXDisplay.InterlacedTest) return bFullVRam; // -> ok, no need for adjust
\r
1207 vertex[0].x=lx0 - PSXDisplay.DisplayPosition.x+PreviousPSXDisplay.Range.x0;
\r
1208 vertex[1].x=lx1 - PSXDisplay.DisplayPosition.x+PreviousPSXDisplay.Range.x0;
\r
1209 vertex[2].x=lx2 - PSXDisplay.DisplayPosition.x+PreviousPSXDisplay.Range.x0;
\r
1210 vertex[0].y=ly0 - PSXDisplay.DisplayPosition.y+PreviousPSXDisplay.Range.y0;
\r
1211 vertex[1].y=ly1 - PSXDisplay.DisplayPosition.y+PreviousPSXDisplay.Range.y0;
\r
1212 vertex[2].y=ly2 - PSXDisplay.DisplayPosition.y+PreviousPSXDisplay.Range.y0;
\r
1214 if(iOffscreenDrawing==4) // -> frontbuffer wanted
\r
1216 bRenderFrontBuffer=TRUE;
\r
1220 return bFullVRam; // -> but no od
\r
1226 ////////////////////////////////////////////////////////////////////////
\r
1228 BOOL FastCheckAgainstScreen(short imageX0,short imageY0,short imageX1,short imageY1)
\r
1230 PSXRect_t xUploadArea;
\r
1232 imageX1 += imageX0;
\r
1233 imageY1 += imageY0;
\r
1235 if (imageX0 < PreviousPSXDisplay.DisplayPosition.x)
\r
1236 xUploadArea.x0 = PreviousPSXDisplay.DisplayPosition.x;
\r
1238 if (imageX0 > PreviousPSXDisplay.DisplayEnd.x)
\r
1239 xUploadArea.x0 = PreviousPSXDisplay.DisplayEnd.x;
\r
1241 xUploadArea.x0 = imageX0;
\r
1243 if(imageX1 < PreviousPSXDisplay.DisplayPosition.x)
\r
1244 xUploadArea.x1 = PreviousPSXDisplay.DisplayPosition.x;
\r
1246 if (imageX1 > PreviousPSXDisplay.DisplayEnd.x)
\r
1247 xUploadArea.x1 = PreviousPSXDisplay.DisplayEnd.x;
\r
1249 xUploadArea.x1 = imageX1;
\r
1251 if (imageY0 < PreviousPSXDisplay.DisplayPosition.y)
\r
1252 xUploadArea.y0 = PreviousPSXDisplay.DisplayPosition.y;
\r
1254 if (imageY0 > PreviousPSXDisplay.DisplayEnd.y)
\r
1255 xUploadArea.y0 = PreviousPSXDisplay.DisplayEnd.y;
\r
1257 xUploadArea.y0 = imageY0;
\r
1259 if (imageY1 < PreviousPSXDisplay.DisplayPosition.y)
\r
1260 xUploadArea.y1 = PreviousPSXDisplay.DisplayPosition.y;
\r
1262 if (imageY1 > PreviousPSXDisplay.DisplayEnd.y)
\r
1263 xUploadArea.y1 = PreviousPSXDisplay.DisplayEnd.y;
\r
1265 xUploadArea.y1 = imageY1;
\r
1267 if ((xUploadArea.x0 != xUploadArea.x1) && (xUploadArea.y0 != xUploadArea.y1))
\r
1269 else return FALSE;
\r
1272 BOOL CheckAgainstScreen(short imageX0,short imageY0,short imageX1,short imageY1)
\r
1274 imageX1 += imageX0;
\r
1275 imageY1 += imageY0;
\r
1277 if (imageX0 < PreviousPSXDisplay.DisplayPosition.x)
\r
1278 xrUploadArea.x0 = PreviousPSXDisplay.DisplayPosition.x;
\r
1280 if (imageX0 > PreviousPSXDisplay.DisplayEnd.x)
\r
1281 xrUploadArea.x0 = PreviousPSXDisplay.DisplayEnd.x;
\r
1283 xrUploadArea.x0 = imageX0;
\r
1285 if(imageX1 < PreviousPSXDisplay.DisplayPosition.x)
\r
1286 xrUploadArea.x1 = PreviousPSXDisplay.DisplayPosition.x;
\r
1288 if (imageX1 > PreviousPSXDisplay.DisplayEnd.x)
\r
1289 xrUploadArea.x1 = PreviousPSXDisplay.DisplayEnd.x;
\r
1291 xrUploadArea.x1 = imageX1;
\r
1293 if (imageY0 < PreviousPSXDisplay.DisplayPosition.y)
\r
1294 xrUploadArea.y0 = PreviousPSXDisplay.DisplayPosition.y;
\r
1296 if (imageY0 > PreviousPSXDisplay.DisplayEnd.y)
\r
1297 xrUploadArea.y0 = PreviousPSXDisplay.DisplayEnd.y;
\r
1299 xrUploadArea.y0 = imageY0;
\r
1301 if (imageY1 < PreviousPSXDisplay.DisplayPosition.y)
\r
1302 xrUploadArea.y1 = PreviousPSXDisplay.DisplayPosition.y;
\r
1304 if (imageY1 > PreviousPSXDisplay.DisplayEnd.y)
\r
1305 xrUploadArea.y1 = PreviousPSXDisplay.DisplayEnd.y;
\r
1307 xrUploadArea.y1 = imageY1;
\r
1309 if ((xrUploadArea.x0 != xrUploadArea.x1) && (xrUploadArea.y0 != xrUploadArea.y1))
\r
1311 else return FALSE;
\r
1314 BOOL FastCheckAgainstFrontScreen(short imageX0,short imageY0,short imageX1,short imageY1)
\r
1316 PSXRect_t xUploadArea;
\r
1318 imageX1 += imageX0;
\r
1319 imageY1 += imageY0;
\r
1321 if (imageX0 < PSXDisplay.DisplayPosition.x)
\r
1322 xUploadArea.x0 = PSXDisplay.DisplayPosition.x;
\r
1324 if (imageX0 > PSXDisplay.DisplayEnd.x)
\r
1325 xUploadArea.x0 = PSXDisplay.DisplayEnd.x;
\r
1327 xUploadArea.x0 = imageX0;
\r
1329 if(imageX1 < PSXDisplay.DisplayPosition.x)
\r
1330 xUploadArea.x1 = PSXDisplay.DisplayPosition.x;
\r
1332 if (imageX1 > PSXDisplay.DisplayEnd.x)
\r
1333 xUploadArea.x1 = PSXDisplay.DisplayEnd.x;
\r
1335 xUploadArea.x1 = imageX1;
\r
1337 if (imageY0 < PSXDisplay.DisplayPosition.y)
\r
1338 xUploadArea.y0 = PSXDisplay.DisplayPosition.y;
\r
1340 if (imageY0 > PSXDisplay.DisplayEnd.y)
\r
1341 xUploadArea.y0 = PSXDisplay.DisplayEnd.y;
\r
1343 xUploadArea.y0 = imageY0;
\r
1345 if (imageY1 < PSXDisplay.DisplayPosition.y)
\r
1346 xUploadArea.y1 = PSXDisplay.DisplayPosition.y;
\r
1348 if (imageY1 > PSXDisplay.DisplayEnd.y)
\r
1349 xUploadArea.y1 = PSXDisplay.DisplayEnd.y;
\r
1351 xUploadArea.y1 = imageY1;
\r
1353 if ((xUploadArea.x0 != xUploadArea.x1) && (xUploadArea.y0 != xUploadArea.y1))
\r
1355 else return FALSE;
\r
1358 BOOL CheckAgainstFrontScreen(short imageX0,short imageY0,short imageX1,short imageY1)
\r
1360 imageX1 += imageX0;
\r
1361 imageY1 += imageY0;
\r
1363 if (imageX0 < PSXDisplay.DisplayPosition.x)
\r
1364 xrUploadArea.x0 = PSXDisplay.DisplayPosition.x;
\r
1366 if (imageX0 > PSXDisplay.DisplayEnd.x)
\r
1367 xrUploadArea.x0 = PSXDisplay.DisplayEnd.x;
\r
1369 xrUploadArea.x0 = imageX0;
\r
1371 if(imageX1 < PSXDisplay.DisplayPosition.x)
\r
1372 xrUploadArea.x1 = PSXDisplay.DisplayPosition.x;
\r
1374 if (imageX1 > PSXDisplay.DisplayEnd.x)
\r
1375 xrUploadArea.x1 = PSXDisplay.DisplayEnd.x;
\r
1377 xrUploadArea.x1 = imageX1;
\r
1379 if (imageY0 < PSXDisplay.DisplayPosition.y)
\r
1380 xrUploadArea.y0 = PSXDisplay.DisplayPosition.y;
\r
1382 if (imageY0 > PSXDisplay.DisplayEnd.y)
\r
1383 xrUploadArea.y0 = PSXDisplay.DisplayEnd.y;
\r
1385 xrUploadArea.y0 = imageY0;
\r
1387 if (imageY1 < PSXDisplay.DisplayPosition.y)
\r
1388 xrUploadArea.y1 = PSXDisplay.DisplayPosition.y;
\r
1390 if (imageY1 > PSXDisplay.DisplayEnd.y)
\r
1391 xrUploadArea.y1 = PSXDisplay.DisplayEnd.y;
\r
1393 xrUploadArea.y1 = imageY1;
\r
1395 if ((xrUploadArea.x0 != xrUploadArea.x1) && (xrUploadArea.y0 != xrUploadArea.y1))
\r
1397 else return FALSE;
\r
1400 ////////////////////////////////////////////////////////////////////////
\r
1402 void PrepareFullScreenUpload (int Position)
\r
1404 if (Position==-1) // rgb24
\r
1406 if(PSXDisplay.Interlaced)
\r
1408 xrUploadArea.x0 = PSXDisplay.DisplayPosition.x;
\r
1409 xrUploadArea.x1 = PSXDisplay.DisplayEnd.x;
\r
1410 xrUploadArea.y0 = PSXDisplay.DisplayPosition.y;
\r
1411 xrUploadArea.y1 = PSXDisplay.DisplayEnd.y;
\r
1415 xrUploadArea.x0 = PreviousPSXDisplay.DisplayPosition.x;
\r
1416 xrUploadArea.x1 = PreviousPSXDisplay.DisplayEnd.x;
\r
1417 xrUploadArea.y0 = PreviousPSXDisplay.DisplayPosition.y;
\r
1418 xrUploadArea.y1 = PreviousPSXDisplay.DisplayEnd.y;
\r
1421 if(bNeedRGB24Update)
\r
1425 // lClearOnSwap=0;
\r
1428 if(PSXDisplay.Interlaced && PreviousPSXDisplay.RGB24<2) // in interlaced mode we upload at least two full frames (GT1 menu)
\r
1430 PreviousPSXDisplay.RGB24++;
\r
1434 xrUploadArea.y1 = min(xrUploadArea.y0+xrUploadAreaRGB24.y1,xrUploadArea.y1);
\r
1435 xrUploadArea.y0+=xrUploadAreaRGB24.y0;
\r
1442 xrUploadArea.x0 = PSXDisplay.DisplayPosition.x;
\r
1443 xrUploadArea.x1 = PSXDisplay.DisplayEnd.x;
\r
1444 xrUploadArea.y0 = PSXDisplay.DisplayPosition.y;
\r
1445 xrUploadArea.y1 = PSXDisplay.DisplayEnd.y;
\r
1449 xrUploadArea.x0 = PreviousPSXDisplay.DisplayPosition.x;
\r
1450 xrUploadArea.x1 = PreviousPSXDisplay.DisplayEnd.x;
\r
1451 xrUploadArea.y0 = PreviousPSXDisplay.DisplayPosition.y;
\r
1452 xrUploadArea.y1 = PreviousPSXDisplay.DisplayEnd.y;
\r
1455 if (xrUploadArea.x0 < 0) xrUploadArea.x0 = 0;
\r
1457 if (xrUploadArea.x0 > 1023) xrUploadArea.x0 = 1023;
\r
1459 if (xrUploadArea.x1 < 0) xrUploadArea.x1 = 0;
\r
1461 if (xrUploadArea.x1 > 1024) xrUploadArea.x1 = 1024;
\r
1463 if (xrUploadArea.y0 < 0) xrUploadArea.y0 = 0;
\r
1465 if (xrUploadArea.y0 > iGPUHeightMask) xrUploadArea.y0 = iGPUHeightMask;
\r
1467 if (xrUploadArea.y1 < 0) xrUploadArea.y1 = 0;
\r
1469 if (xrUploadArea.y1 > iGPUHeight) xrUploadArea.y1 = iGPUHeight;
\r
1471 if (PSXDisplay.RGB24)
\r
1473 InvalidateTextureArea(xrUploadArea.x0,xrUploadArea.y0,xrUploadArea.x1-xrUploadArea.x0,xrUploadArea.y1-xrUploadArea.y0);
\r
1477 ////////////////////////////////////////////////////////////////////////
\r
1478 // Upload screen (MDEC and such)
\r
1479 ////////////////////////////////////////////////////////////////////////
\r
1480 ////////////////////////////////////////////////////////////////////////
\r
1482 unsigned char * LoadDirectMovieFast(void);
\r
1484 void UploadScreenEx(int Position)
\r
1486 short ya,yb,xa,xb,x, y, YStep, XStep, U, UStep,ux[4],vy[4];
\r
1488 if(!PSXDisplay.DisplayMode.x) return;
\r
1489 if(!PSXDisplay.DisplayMode.y) return;
\r
1491 glDisable(GL_SCISSOR_TEST); glError();
\r
1492 glShadeModel(GL_FLAT); glError();
\r
1493 bOldSmoothShaded=FALSE;
\r
1494 glDisable(GL_BLEND); glError();
\r
1495 bBlendEnable=FALSE;
\r
1496 glDisable(GL_TEXTURE_2D); glError();
\r
1497 bTexEnabled=FALSE;
\r
1498 glDisable(GL_ALPHA_TEST); glError();
\r
1500 //glPixelZoom(((float)rRatioRect.right)/((float)PSXDisplay.DisplayMode.x),
\r
1501 // -1.0f*(((float)rRatioRect.bottom)/((float)PSXDisplay.DisplayMode.y)));
\r
1503 //----------------------------------------------------//
\r
1505 YStep = 256; // max texture size
\r
1507 UStep = (PSXDisplay.RGB24 ? 128 : 0);
\r
1508 ya = xrUploadArea.y0;
\r
1509 yb = xrUploadArea.y1;
\r
1510 xa = xrUploadArea.x0;
\r
1511 xb = xrUploadArea.x1;
\r
1513 for(y=ya;y<=yb;y+=YStep) // loop y
\r
1516 for(x=xa;x<=xb;x+=XStep) // loop x
\r
1518 ly0 = ly1 = y; // -> get y coords
\r
1520 if (ly2 > yb) ly2 = yb;
\r
1523 lx0 = lx3 = x; // -> get x coords
\r
1525 if (lx1 > xb) lx1 = xb;
\r
1529 ux[0]=ux[3]=(xa - x); // -> set tex x coords
\r
1530 if (ux[0] < 0) ux[0]=ux[3]=0;
\r
1531 ux[2]=ux[1]=(xb - x);
\r
1532 if (ux[2] > 256) ux[2]=ux[1]=256;
\r
1534 vy[0]=vy[1]=(ya - y); // -> set tex y coords
\r
1535 if (vy[0] < 0) vy[0]=vy[1]=0;
\r
1536 vy[2]=vy[3]=(yb - y);
\r
1537 if (vy[2] > 256) vy[2]=vy[3]=256;
\r
1539 if ((ux[0] >= ux[2]) || // -> cheaters never win...
\r
1540 (vy[0] >= vy[2])) continue; // (but winners always cheat...)
\r
1542 xrMovieArea.x0=lx0+U; xrMovieArea.y0=ly0;
\r
1543 xrMovieArea.x1=lx2+U; xrMovieArea.y1=ly2;
\r
1545 offsetScreenUpload(Position);
\r
1547 //glRasterPos2f(vertex[0].x,vertex[0].y);
\r
1549 //glDrawPixels(xrMovieArea.x1-xrMovieArea.x0,
\r
1550 // xrMovieArea.y1-xrMovieArea.y0,
\r
1551 // GL_RGBA,GL_UNSIGNED_BYTE,
\r
1552 LoadDirectMovieFast();//);
\r
1558 //----------------------------------------------------//
\r
1560 // glPixelZoom(1.0F,1.0F);
\r
1562 glEnable(GL_ALPHA_TEST); glError();
\r
1563 glEnable(GL_SCISSOR_TEST); glError();
\r
1566 ////////////////////////////////////////////////////////////////////////
\r
1568 void UploadScreen(int Position)
\r
1570 short x, y, YStep, XStep, U, s, UStep,ux[4],vy[4];
\r
1571 short xa,xb,ya,yb;
\r
1573 if(xrUploadArea.x0>1023) xrUploadArea.x0=1023;
\r
1574 if(xrUploadArea.x1>1024) xrUploadArea.x1=1024;
\r
1575 if(xrUploadArea.y0>iGPUHeightMask) xrUploadArea.y0=iGPUHeightMask;
\r
1576 if(xrUploadArea.y1>iGPUHeight) xrUploadArea.y1=iGPUHeight;
\r
1578 if(xrUploadArea.x0==xrUploadArea.x1) return;
\r
1579 if(xrUploadArea.y0==xrUploadArea.y1) return;
\r
1581 if(PSXDisplay.Disabled && iOffscreenDrawing<4) return;
\r
1583 iDrawnSomething = 2;
\r
1584 iLastRGB24=PSXDisplay.RGB24+1;
\r
1586 if(bSkipNextFrame) return;
\r
1588 if(dwActFixes & 2) {UploadScreenEx(Position);return;}
\r
1590 bUsingMovie = TRUE;
\r
1591 bDrawTextured = TRUE; // just doing textures
\r
1592 bDrawSmoothShaded = FALSE;
\r
1594 /* if(bGLBlend) vertex[0].c.lcol=0xff7f7f7f; // set solid col
\r
1595 else */vertex[0].c.lcol=0xffffffff;
\r
1596 SETCOL(vertex[0]);
\r
1598 SetOGLDisplaySettings(0);
\r
1600 YStep = 256; // max texture size
\r
1603 UStep = (PSXDisplay.RGB24 ? 128 : 0);
\r
1605 ya=xrUploadArea.y0;
\r
1606 yb=xrUploadArea.y1;
\r
1607 xa=xrUploadArea.x0;
\r
1608 xb=xrUploadArea.x1;
\r
1610 for(y=ya;y<=yb;y+=YStep) // loop y
\r
1613 for(x=xa;x<=xb;x+=XStep) // loop x
\r
1615 ly0 = ly1 = y; // -> get y coords
\r
1617 if (ly2 > yb) ly2 = yb;
\r
1620 lx0 = lx3 = x; // -> get x coords
\r
1622 if (lx1 > xb) lx1 = xb;
\r
1626 ux[0]=ux[3]=(xa - x); // -> set tex x coords
\r
1627 if (ux[0] < 0) ux[0]=ux[3]=0;
\r
1628 ux[2]=ux[1]=(xb - x);
\r
1629 if (ux[2] > 256) ux[2]=ux[1]=256;
\r
1631 vy[0]=vy[1]=(ya - y); // -> set tex y coords
\r
1632 if (vy[0] < 0) vy[0]=vy[1]=0;
\r
1633 vy[2]=vy[3]=(yb - y);
\r
1634 if (vy[2] > 256) vy[2]=vy[3]=256;
\r
1636 if ((ux[0] >= ux[2]) || // -> cheaters never win...
\r
1637 (vy[0] >= vy[2])) continue; // (but winners always cheat...)
\r
1639 xrMovieArea.x0=lx0+U; xrMovieArea.y0=ly0;
\r
1640 xrMovieArea.x1=lx2+U; xrMovieArea.y1=ly2;
\r
1642 s=ux[2] - ux[0]; if(s>255) s=255;
\r
1644 gl_ux[2] = gl_ux[1] = s;
\r
1645 s=vy[2] - vy[0]; if(s>255) s=255;
\r
1646 gl_vy[2] = gl_vy[3] = s;
\r
1647 gl_ux[0] = gl_ux[3] = gl_vy[0] = gl_vy[1] = 0;
\r
1649 SetRenderState((unsigned int)0x01000000);
\r
1650 SetRenderMode((unsigned int)0x01000000, FALSE); // upload texture data
\r
1651 offsetScreenUpload(Position);
\r
1652 assignTextureVRAMWrite();
\r
1654 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
1660 bUsingMovie=FALSE; // done...
\r
1661 bDisplayNotSet = TRUE;
\r
1664 ////////////////////////////////////////////////////////////////////////
\r
1665 // Detect next screen
\r
1666 ////////////////////////////////////////////////////////////////////////
\r
1668 BOOL IsCompleteInsideNextScreen(short x, short y, short xoff, short yoff)
\r
1670 if (x > PSXDisplay.DisplayPosition.x+1) return FALSE;
\r
1671 if ((x + xoff) < PSXDisplay.DisplayEnd.x-1) return FALSE;
\r
1673 if (y >= PSXDisplay.DisplayPosition.y &&
\r
1674 y <= PSXDisplay.DisplayEnd.y )
\r
1676 if ((yoff) >= PSXDisplay.DisplayPosition.y &&
\r
1677 (yoff) <= PSXDisplay.DisplayEnd.y ) return TRUE;
\r
1679 if (y > PSXDisplay.DisplayPosition.y+1) return FALSE;
\r
1680 if (yoff < PSXDisplay.DisplayEnd.y-1) return FALSE;
\r
1684 BOOL IsPrimCompleteInsideNextScreen(short x, short y, short xoff, short yoff)
\r
1686 x+=PSXDisplay.DrawOffset.x;
\r
1687 if (x > PSXDisplay.DisplayPosition.x+1) return FALSE;
\r
1688 y+=PSXDisplay.DrawOffset.y;
\r
1689 if (y > PSXDisplay.DisplayPosition.y+1) return FALSE;
\r
1690 xoff+=PSXDisplay.DrawOffset.x;
\r
1691 if (xoff < PSXDisplay.DisplayEnd.x-1) return FALSE;
\r
1692 yoff+=PSXDisplay.DrawOffset.y;
\r
1693 if (yoff < PSXDisplay.DisplayEnd.y-1) return FALSE;
\r
1697 BOOL IsInsideNextScreen(short x, short y, short xoff, short yoff)
\r
1699 if (x > PSXDisplay.DisplayEnd.x) return FALSE;
\r
1700 if (y > PSXDisplay.DisplayEnd.y) return FALSE;
\r
1701 if ((x + xoff) < PSXDisplay.DisplayPosition.x) return FALSE;
\r
1702 if ((y + yoff) < PSXDisplay.DisplayPosition.y) return FALSE;
\r
1706 ////////////////////////////////////////////////////////////////////////
\r
1708 ////////////////////////////////////////////////////////////////////////
\r
1710 //Mask1 Set mask bit while drawing. 1 = on
\r
1711 //Mask2 Do not draw to mask areas. 1= on
\r
1713 void cmdSTP(unsigned char * baseAddr)
\r
1715 unsigned int gdata = ((unsigned int*)baseAddr)[0];
\r
1717 STATUSREG&=~0x1800; // clear the necessary bits
\r
1718 STATUSREG|=((gdata & 0x03) << 11); // set the current bits
\r
1720 if(!iUseMask) return;
\r
1722 if(gdata&1) {sSetMask=0x8000;lSetMask=0x80008000;iSetMask=1;}
\r
1723 else {sSetMask=0; lSetMask=0; iSetMask=0;}
\r
1727 if(!(gdata&1)) iSetMask=2;
\r
1729 if(iDepthFunc==0) return;
\r
1731 glDepthFunc(GL_LESS); glError();
\r
1736 if(iDepthFunc==1) return;
\r
1737 glDepthFunc(GL_ALWAYS); glError();
\r
1742 ////////////////////////////////////////////////////////////////////////
\r
1743 // cmd: Set texture page infos
\r
1744 ////////////////////////////////////////////////////////////////////////
\r
1746 void cmdTexturePage(unsigned char * baseAddr)
\r
1748 unsigned int gdata = ((unsigned int*)baseAddr)[0];
\r
1749 UpdateGlobalTP((unsigned short)gdata);
\r
1750 GlobalTextREST = (gdata&0x00ffffff)>>9;
\r
1753 ////////////////////////////////////////////////////////////////////////
\r
1754 // cmd: turn on/off texture window
\r
1755 ////////////////////////////////////////////////////////////////////////
\r
1757 void cmdTextureWindow(unsigned char *baseAddr)
\r
1759 unsigned int gdata = ((unsigned int*)baseAddr)[0];
\r
1761 unsigned int YAlign,XAlign;
\r
1763 ulGPUInfoVals[INFO_TW]=gdata&0xFFFFF;
\r
1766 TWin.Position.y1 = 8; // xxxx1
\r
1767 else if (gdata & 0x040)
\r
1768 TWin.Position.y1 = 16; // xxx10
\r
1769 else if (gdata & 0x080)
\r
1770 TWin.Position.y1 = 32; // xx100
\r
1771 else if (gdata & 0x100)
\r
1772 TWin.Position.y1 = 64; // x1000
\r
1773 else if (gdata & 0x200)
\r
1774 TWin.Position.y1 = 128; // 10000
\r
1776 TWin.Position.y1 = 256; // 00000
\r
1778 // Texture window size is determined by the least bit set of the relevant 5 bits
\r
1780 if (gdata & 0x001)
\r
1781 TWin.Position.x1 = 8; // xxxx1
\r
1782 else if (gdata & 0x002)
\r
1783 TWin.Position.x1 = 16; // xxx10
\r
1784 else if (gdata & 0x004)
\r
1785 TWin.Position.x1 = 32; // xx100
\r
1786 else if (gdata & 0x008)
\r
1787 TWin.Position.x1 = 64; // x1000
\r
1788 else if (gdata & 0x010)
\r
1789 TWin.Position.x1 = 128; // 10000
\r
1791 TWin.Position.x1 = 256; // 00000
\r
1793 // Re-calculate the bit field, because we can't trust what is passed in the data
\r
1795 YAlign = (unsigned int)(32 - (TWin.Position.y1 >> 3));
\r
1796 XAlign = (unsigned int)(32 - (TWin.Position.x1 >> 3));
\r
1798 // Absolute position of the start of the texture window
\r
1800 TWin.Position.y0 = (short)(((gdata >> 15) & YAlign) << 3);
\r
1801 TWin.Position.x0 = (short)(((gdata >> 10) & XAlign) << 3);
\r
1803 if((TWin.Position.x0 == 0 && // tw turned off
\r
1804 TWin.Position.y0 == 0 &&
\r
1805 TWin.Position.x1 == 0 &&
\r
1806 TWin.Position.y1 == 0) ||
\r
1807 (TWin.Position.x1 == 256 &&
\r
1808 TWin.Position.y1 == 256))
\r
1810 bUsingTWin = FALSE; // -> just do it
\r
1813 TWin.UScaleFactor = 1.0f;
\r
1814 TWin.VScaleFactor = 1.0f;
\r
1816 TWin.UScaleFactor =
\r
1817 TWin.VScaleFactor = 1.0f/256.0f;
\r
1820 else // tw turned on
\r
1822 bUsingTWin = TRUE;
\r
1824 TWin.OPosition.y1 = TWin.Position.y1; // -> get psx sizes
\r
1825 TWin.OPosition.x1 = TWin.Position.x1;
\r
1827 if(TWin.Position.x1<=2) TWin.Position.x1=2; // -> set OGL sizes
\r
1829 if(TWin.Position.x1<=4) TWin.Position.x1=4;
\r
1831 if(TWin.Position.x1<=8) TWin.Position.x1=8;
\r
1833 if(TWin.Position.x1<=16) TWin.Position.x1=16;
\r
1835 if(TWin.Position.x1<=32) TWin.Position.x1=32;
\r
1837 if(TWin.Position.x1<=64) TWin.Position.x1=64;
\r
1839 if(TWin.Position.x1<=128) TWin.Position.x1=128;
\r
1841 if(TWin.Position.x1<=256) TWin.Position.x1=256;
\r
1843 if(TWin.Position.y1<=2) TWin.Position.y1=2;
\r
1845 if(TWin.Position.y1<=4) TWin.Position.y1=4;
\r
1847 if(TWin.Position.y1<=8) TWin.Position.y1=8;
\r
1849 if(TWin.Position.y1<=16) TWin.Position.y1=16;
\r
1851 if(TWin.Position.y1<=32) TWin.Position.y1=32;
\r
1853 if(TWin.Position.y1<=64) TWin.Position.y1=64;
\r
1855 if(TWin.Position.y1<=128) TWin.Position.y1=128;
\r
1857 if(TWin.Position.y1<=256) TWin.Position.y1=256;
\r
1860 TWin.UScaleFactor = (float)TWin.Position.x1;
\r
1861 TWin.VScaleFactor = (float)TWin.Position.y1;
\r
1863 TWin.UScaleFactor = ((float)TWin.Position.x1)/256.0f; // -> set scale factor
\r
1864 TWin.VScaleFactor = ((float)TWin.Position.y1)/256.0f;
\r
1869 ////////////////////////////////////////////////////////////////////////
\r
1870 // mmm, Lewpy uses that in TileS ... I don't ;)
\r
1871 ////////////////////////////////////////////////////////////////////////
\r
1874 void ClampToPSXDrawAreaOffset(short *x0, short *y0, short *x1, short *y1)
\r
1876 if (*x0 < PSXDisplay.DrawArea.x0)
\r
1878 *x1 -= (PSXDisplay.DrawArea.x0 - *x0);
\r
1879 *x0 = PSXDisplay.DrawArea.x0;
\r
1882 if (*x0 > PSXDisplay.DrawArea.x1)
\r
1884 *x0 = PSXDisplay.DrawArea.x1;
\r
1888 if (*y0 < PSXDisplay.DrawArea.y0)
\r
1890 *y1 -= (PSXDisplay.DrawArea.y0 - *y0);
\r
1891 *y0 = PSXDisplay.DrawArea.y0;
\r
1894 if (*y0 > PSXDisplay.DrawArea.y1)
\r
1896 *y0 = PSXDisplay.DrawArea.y1;
\r
1900 if (*x1 < 0) *x1 = 0;
\r
1902 if ((*x1 + *x0) > PSXDisplay.DrawArea.x1)
\r
1903 *x1 = (PSXDisplay.DrawArea.x1 - *x0 + 1);
\r
1905 if (*y1 < 0) *y1 = 0;
\r
1907 if ((*y1 + *y0) > PSXDisplay.DrawArea.y1)
\r
1908 *y1 = (PSXDisplay.DrawArea.y1 - *y0 + 1);
\r
1912 ////////////////////////////////////////////////////////////////////////
\r
1913 // Check draw area dimensions
\r
1914 ////////////////////////////////////////////////////////////////////////
\r
1916 void ClampToPSXScreen(short *x0, short *y0, short *x1, short *y1)
\r
1918 if (*x0 < 0) *x0 = 0;
\r
1920 if (*x0 > 1023) *x0 = 1023;
\r
1922 if (*x1 < 0) *x1 = 0;
\r
1924 if (*x1 > 1023) *x1 = 1023;
\r
1926 if (*y0 < 0) *y0 = 0;
\r
1928 if (*y0 > iGPUHeightMask) *y0 = iGPUHeightMask;
\r
1930 if (*y1 < 0) *y1 = 0;
\r
1932 if (*y1 > iGPUHeightMask) *y1 = iGPUHeightMask;
\r
1935 ////////////////////////////////////////////////////////////////////////
\r
1936 // Used in Load Image and Blk Fill
\r
1937 ////////////////////////////////////////////////////////////////////////
\r
1939 void ClampToPSXScreenOffset(short *x0, short *y0, short *x1, short *y1)
\r
1942 { *x1 += *x0; *x0 = 0; }
\r
1945 { *x0 = 1023; *x1 = 0; }
\r
1948 { *y1 += *y0; *y0 = 0; }
\r
1950 if (*y0 > iGPUHeightMask)
\r
1951 { *y0 = iGPUHeightMask; *y1 = 0; }
\r
1953 if (*x1 < 0) *x1 = 0;
\r
1955 if ((*x1 + *x0) > 1024) *x1 = (1024 - *x0);
\r
1957 if (*y1 < 0) *y1 = 0;
\r
1959 if ((*y1 + *y0) > iGPUHeight) *y1 = (iGPUHeight - *y0);
\r
1962 ////////////////////////////////////////////////////////////////////////
\r
1963 // cmd: start of drawing area... primitives will be clipped inside
\r
1964 ////////////////////////////////////////////////////////////////////////
\r
1966 void cmdDrawAreaStart(unsigned char * baseAddr)
\r
1968 unsigned int gdata = ((unsigned int*)baseAddr)[0];
\r
1970 drawX = gdata & 0x3ff; // for soft drawing
\r
1971 if(drawX>=1024) drawX=1023;
\r
1973 if(dwGPUVersion==2)
\r
1975 ulGPUInfoVals[INFO_DRAWSTART]=gdata&0x3FFFFF;
\r
1976 drawY = (gdata>>12)&0x3ff;
\r
1980 ulGPUInfoVals[INFO_DRAWSTART]=gdata&0xFFFFF;
\r
1981 drawY = (gdata>>10)&0x3ff;
\r
1984 if(drawY>=iGPUHeight) drawY=iGPUHeightMask;
\r
1986 PreviousPSXDisplay.DrawArea.y0=PSXDisplay.DrawArea.y0;
\r
1987 PreviousPSXDisplay.DrawArea.x0=PSXDisplay.DrawArea.x0;
\r
1989 PSXDisplay.DrawArea.y0 = (short)drawY; // for OGL drawing
\r
1990 PSXDisplay.DrawArea.x0 = (short)drawX;
\r
1993 ////////////////////////////////////////////////////////////////////////
\r
1994 // cmd: end of drawing area... primitives will be clipped inside
\r
1995 ////////////////////////////////////////////////////////////////////////
\r
1997 void cmdDrawAreaEnd(unsigned char * baseAddr)
\r
1999 unsigned int gdata = ((unsigned int*)baseAddr)[0];
\r
2001 drawW = gdata & 0x3ff; // for soft drawing
\r
2002 if(drawW>=1024) drawW=1023;
\r
2004 if(dwGPUVersion==2)
\r
2006 ulGPUInfoVals[INFO_DRAWEND]=gdata&0x3FFFFF;
\r
2007 drawH = (gdata>>12)&0x3ff;
\r
2011 ulGPUInfoVals[INFO_DRAWEND]=gdata&0xFFFFF;
\r
2012 drawH = (gdata>>10)&0x3ff;
\r
2015 if(drawH>=iGPUHeight) drawH=iGPUHeightMask;
\r
2017 PSXDisplay.DrawArea.y1 = (short)drawH; // for OGL drawing
\r
2018 PSXDisplay.DrawArea.x1 = (short)drawW;
\r
2020 ClampToPSXScreen(&PSXDisplay.DrawArea.x0, // clamp
\r
2021 &PSXDisplay.DrawArea.y0,
\r
2022 &PSXDisplay.DrawArea.x1,
\r
2023 &PSXDisplay.DrawArea.y1);
\r
2025 bDisplayNotSet = TRUE;
\r
2028 ////////////////////////////////////////////////////////////////////////
\r
2029 // cmd: draw offset... will be added to prim coords
\r
2030 ////////////////////////////////////////////////////////////////////////
\r
2032 void cmdDrawOffset(unsigned char * baseAddr)
\r
2034 unsigned int gdata = ((unsigned int*)baseAddr)[0];
\r
2036 PreviousPSXDisplay.DrawOffset.x =
\r
2037 PSXDisplay.DrawOffset.x = (short)(gdata & 0x7ff);
\r
2039 if(dwGPUVersion==2)
\r
2041 ulGPUInfoVals[INFO_DRAWOFF]=gdata&0x7FFFFF;
\r
2042 PSXDisplay.DrawOffset.y = (short)((gdata>>12) & 0x7ff);
\r
2046 ulGPUInfoVals[INFO_DRAWOFF]=gdata&0x3FFFFF;
\r
2047 PSXDisplay.DrawOffset.y = (short)((gdata>>11) & 0x7ff);
\r
2050 PSXDisplay.DrawOffset.x=(short)(((int)PSXDisplay.DrawOffset.x<<21)>>21);
\r
2051 PSXDisplay.DrawOffset.y=(short)(((int)PSXDisplay.DrawOffset.y<<21)>>21);
\r
2053 PSXDisplay.CumulOffset.x = // new OGL prim offsets
\r
2054 PSXDisplay.DrawOffset.x - PSXDisplay.GDrawOffset.x + PreviousPSXDisplay.Range.x0;
\r
2055 PSXDisplay.CumulOffset.y =
\r
2056 PSXDisplay.DrawOffset.y - PSXDisplay.GDrawOffset.y + PreviousPSXDisplay.Range.y0;
\r
2059 ////////////////////////////////////////////////////////////////////////
\r
2060 // cmd: load image to vram
\r
2061 ////////////////////////////////////////////////////////////////////////
\r
2063 void primLoadImage(unsigned char * baseAddr)
\r
2065 unsigned short *sgpuData = ((unsigned short *) baseAddr);
\r
2067 VRAMWrite.x = sgpuData[2]&0x03ff;
\r
2068 VRAMWrite.y = sgpuData[3]&iGPUHeightMask;
\r
2069 VRAMWrite.Width = sgpuData[4];
\r
2070 VRAMWrite.Height = sgpuData[5];
\r
2072 iDataWriteMode = DR_VRAMTRANSFER;
\r
2073 VRAMWrite.ImagePtr = psxVuw + (VRAMWrite.y<<10) + VRAMWrite.x;
\r
2074 VRAMWrite.RowsRemaining = VRAMWrite.Width;
\r
2075 VRAMWrite.ColsRemaining = VRAMWrite.Height;
\r
2077 bNeedWriteUpload=TRUE;
\r
2080 ////////////////////////////////////////////////////////////////////////
\r
2082 void PrepareRGB24Upload(void)
\r
2084 VRAMWrite.x=(VRAMWrite.x*2)/3;
\r
2085 VRAMWrite.Width=(VRAMWrite.Width*2)/3;
\r
2087 if(!PSXDisplay.InterlacedTest && // NEW
\r
2088 CheckAgainstScreen(VRAMWrite.x, VRAMWrite.y, VRAMWrite.Width, VRAMWrite.Height))
\r
2090 xrUploadArea.x0-=PreviousPSXDisplay.DisplayPosition.x;
\r
2091 xrUploadArea.x1-=PreviousPSXDisplay.DisplayPosition.x;
\r
2092 xrUploadArea.y0-=PreviousPSXDisplay.DisplayPosition.y;
\r
2093 xrUploadArea.y1-=PreviousPSXDisplay.DisplayPosition.y;
\r
2096 if(CheckAgainstFrontScreen(VRAMWrite.x, VRAMWrite.y, VRAMWrite.Width, VRAMWrite.Height))
\r
2098 xrUploadArea.x0-=PSXDisplay.DisplayPosition.x;
\r
2099 xrUploadArea.x1-=PSXDisplay.DisplayPosition.x;
\r
2100 xrUploadArea.y0-=PSXDisplay.DisplayPosition.y;
\r
2101 xrUploadArea.y1-=PSXDisplay.DisplayPosition.y;
\r
2105 if(bRenderFrontBuffer)
\r
2107 updateFrontDisplay();
\r
2110 if(bNeedRGB24Update==FALSE)
\r
2112 xrUploadAreaRGB24=xrUploadArea;
\r
2113 bNeedRGB24Update=TRUE;
\r
2117 xrUploadAreaRGB24.x0=min(xrUploadAreaRGB24.x0,xrUploadArea.x0);
\r
2118 xrUploadAreaRGB24.x1=max(xrUploadAreaRGB24.x1,xrUploadArea.x1);
\r
2119 xrUploadAreaRGB24.y0=min(xrUploadAreaRGB24.y0,xrUploadArea.y0);
\r
2120 xrUploadAreaRGB24.y1=max(xrUploadAreaRGB24.y1,xrUploadArea.y1);
\r
2124 ////////////////////////////////////////////////////////////////////////
\r
2126 void CheckWriteUpdate()
\r
2130 if(VRAMWrite.Width) iX=1;
\r
2131 if(VRAMWrite.Height) iY=1;
\r
2133 InvalidateTextureArea(VRAMWrite.x, VRAMWrite.y, VRAMWrite.Width-iX, VRAMWrite.Height-iY);
\r
2135 if(PSXDisplay.Interlaced && !iOffscreenDrawing) return;
\r
2137 if(PSXDisplay.RGB24) {PrepareRGB24Upload();return;}
\r
2139 if(!PSXDisplay.InterlacedTest &&
\r
2140 CheckAgainstScreen(VRAMWrite.x, VRAMWrite.y, VRAMWrite.Width, VRAMWrite.Height))
\r
2142 if(dwActFixes&0x800) return;
\r
2144 if(bRenderFrontBuffer)
\r
2146 updateFrontDisplay();
\r
2149 UploadScreen(FALSE);
\r
2151 bNeedUploadTest=TRUE;
\r
2154 if(iOffscreenDrawing)
\r
2156 if (CheckAgainstFrontScreen(VRAMWrite.x, VRAMWrite.y, VRAMWrite.Width, VRAMWrite.Height))
\r
2158 if(PSXDisplay.InterlacedTest)
\r
2160 if(PreviousPSXDisplay.InterlacedNew)
\r
2162 PreviousPSXDisplay.InterlacedNew=FALSE;
\r
2163 bNeedInterlaceUpdate=TRUE;
\r
2164 xrUploadAreaIL.x0=PSXDisplay.DisplayPosition.x;
\r
2165 xrUploadAreaIL.y0=PSXDisplay.DisplayPosition.y;
\r
2166 xrUploadAreaIL.x1=PSXDisplay.DisplayPosition.x+PSXDisplay.DisplayModeNew.x;
\r
2167 xrUploadAreaIL.y1=PSXDisplay.DisplayPosition.y+PSXDisplay.DisplayModeNew.y;
\r
2168 if(xrUploadAreaIL.x1>1023) xrUploadAreaIL.x1=1023;
\r
2169 if(xrUploadAreaIL.y1>511) xrUploadAreaIL.y1=511;
\r
2172 if(bNeedInterlaceUpdate==FALSE)
\r
2174 xrUploadAreaIL=xrUploadArea;
\r
2175 bNeedInterlaceUpdate=TRUE;
\r
2179 xrUploadAreaIL.x0=min(xrUploadAreaIL.x0,xrUploadArea.x0);
\r
2180 xrUploadAreaIL.x1=max(xrUploadAreaIL.x1,xrUploadArea.x1);
\r
2181 xrUploadAreaIL.y0=min(xrUploadAreaIL.y0,xrUploadArea.y0);
\r
2182 xrUploadAreaIL.y1=max(xrUploadAreaIL.y1,xrUploadArea.y1);
\r
2187 if(!bNeedUploadAfter)
\r
2189 bNeedUploadAfter = TRUE;
\r
2190 xrUploadArea.x0=VRAMWrite.x;
\r
2191 xrUploadArea.x1=VRAMWrite.x+VRAMWrite.Width;
\r
2192 xrUploadArea.y0=VRAMWrite.y;
\r
2193 xrUploadArea.y1=VRAMWrite.y+VRAMWrite.Height;
\r
2197 xrUploadArea.x0=min(xrUploadArea.x0,VRAMWrite.x);
\r
2198 xrUploadArea.x1=max(xrUploadArea.x1,VRAMWrite.x+VRAMWrite.Width);
\r
2199 xrUploadArea.y0=min(xrUploadArea.y0,VRAMWrite.y);
\r
2200 xrUploadArea.y1=max(xrUploadArea.y1,VRAMWrite.y+VRAMWrite.Height);
\r
2203 if(dwActFixes&0x8000)
\r
2205 if((xrUploadArea.x1-xrUploadArea.x0)>=(PSXDisplay.DisplayMode.x-32) &&
\r
2206 (xrUploadArea.y1-xrUploadArea.y0)>=(PSXDisplay.DisplayMode.y-32))
\r
2209 updateFrontDisplay();
\r
2216 ////////////////////////////////////////////////////////////////////////
\r
2217 // cmd: vram -> psx mem
\r
2218 ////////////////////////////////////////////////////////////////////////
\r
2220 void primStoreImage(unsigned char * baseAddr)
\r
2222 unsigned short *sgpuData = ((unsigned short *) baseAddr);
\r
2224 VRAMRead.x = sgpuData[2]&0x03ff;
\r
2225 VRAMRead.y = sgpuData[3]&iGPUHeightMask;
\r
2226 VRAMRead.Width = sgpuData[4];
\r
2227 VRAMRead.Height = sgpuData[5];
\r
2229 VRAMRead.ImagePtr = psxVuw + (VRAMRead.y<<10) + VRAMRead.x;
\r
2230 VRAMRead.RowsRemaining = VRAMRead.Width;
\r
2231 VRAMRead.ColsRemaining = VRAMRead.Height;
\r
2233 iDataReadMode = DR_VRAMTRANSFER;
\r
2235 STATUSREG |= GPUSTATUS_READYFORVRAM;
\r
2238 ////////////////////////////////////////////////////////////////////////
\r
2239 // cmd: blkfill - NO primitive! Doesn't care about draw areas...
\r
2240 ////////////////////////////////////////////////////////////////////////
\r
2242 void primBlkFill(unsigned char * baseAddr)
\r
2244 unsigned int *gpuData = ((unsigned int *) baseAddr);
\r
2245 short *sgpuData = ((short *) baseAddr);
\r
2247 iDrawnSomething=1;
\r
2249 sprtX = sgpuData[2];
\r
2250 sprtY = sgpuData[3];
\r
2251 sprtW = sgpuData[4] & 0x3ff;
\r
2252 sprtH = sgpuData[5] & iGPUHeightMask;
\r
2254 sprtW = (sprtW+15) & ~15;
\r
2256 // Increase H & W if they are one short of full values, because they never can be full values
\r
2257 if (sprtH == iGPUHeightMask) sprtH=iGPUHeight;
\r
2258 if (sprtW == 1023) sprtW=1024;
\r
2260 // x and y of start
\r
2261 ly0 = ly1 = sprtY;
\r
2262 ly2 = ly3 = (sprtY+sprtH);
\r
2263 lx0 = lx3 = sprtX;
\r
2264 lx1 = lx2 = (sprtX+sprtW);
\r
2268 if(ClipVertexListScreen())
\r
2270 PSXDisplay_t * pd;
\r
2271 if(PSXDisplay.InterlacedTest) pd=&PSXDisplay;
\r
2272 else pd=&PreviousPSXDisplay;
\r
2274 if ((lx0 <= pd->DisplayPosition.x+16) &&
\r
2275 (ly0 <= pd->DisplayPosition.y+16) &&
\r
2276 (lx2 >= pd->DisplayEnd.x-16) &&
\r
2277 (ly2 >= pd->DisplayEnd.y-16))
\r
2280 g=((GLclampf)GREEN(gpuData[0]))/255.0f;
\r
2281 b=((GLclampf)BLUE(gpuData[0]))/255.0f;
\r
2282 r=((GLclampf)RED(gpuData[0]))/255.0f;
\r
2284 //glDisable(GL_SCISSOR_TEST); glError();
\r
2285 glClearColor(r,g,b,1.0f); glError();
\r
2286 glClear(uiBufferBits); glError();
\r
2289 if(gpuData[0]!=0x02000000 &&
\r
2290 (ly0>pd->DisplayPosition.y ||
\r
2291 ly2<pd->DisplayEnd.y))
\r
2293 bDrawTextured = FALSE;
\r
2294 bDrawSmoothShaded = FALSE;
\r
2295 SetRenderState((unsigned int)0x01000000);
\r
2296 SetRenderMode((unsigned int)0x01000000, FALSE);
\r
2297 vertex[0].c.lcol=0xff000000;
\r
2298 SETCOL(vertex[0]);
\r
2299 if(ly0>pd->DisplayPosition.y)
\r
2301 vertex[0].x=0;vertex[0].y=0;
\r
2302 vertex[1].x=pd->DisplayEnd.x-pd->DisplayPosition.x;vertex[1].y=0;
\r
2303 vertex[2].x=vertex[1].x;vertex[2].y=ly0-pd->DisplayPosition.y;
\r
2304 vertex[3].x=0;vertex[3].y=vertex[2].y;
\r
2305 PRIMdrawQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
2307 if(ly2<pd->DisplayEnd.y)
\r
2309 vertex[0].x=0;vertex[0].y=(pd->DisplayEnd.y-pd->DisplayPosition.y)-(pd->DisplayEnd.y-ly2);
\r
2310 vertex[1].x=pd->DisplayEnd.x-pd->DisplayPosition.x;vertex[1].y=vertex[0].y;
\r
2311 vertex[2].x=vertex[1].x;vertex[2].y=pd->DisplayEnd.y;
\r
2312 vertex[3].x=0;vertex[3].y=vertex[2].y;
\r
2313 PRIMdrawQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
2317 //glEnable(GL_SCISSOR_TEST); glError();
\r
2321 bDrawTextured = FALSE;
\r
2322 bDrawSmoothShaded = FALSE;
\r
2323 SetRenderState((unsigned int)0x01000000);
\r
2324 SetRenderMode((unsigned int)0x01000000, FALSE);
\r
2325 vertex[0].c.lcol=gpuData[0]|0xff000000;
\r
2326 SETCOL(vertex[0]);
\r
2327 //glDisable(GL_SCISSOR_TEST); glError();
\r
2328 PRIMdrawQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
2329 //glEnable(GL_SCISSOR_TEST); glError();
\r
2333 //mmm... will clean all stuff, also if not all _should_ be cleaned...
\r
2334 //if (IsInsideNextScreen(sprtX, sprtY, sprtW, sprtH))
\r
2336 if (IsCompleteInsideNextScreen(sprtX, sprtY, sprtW, sprtH))
\r
2338 lClearOnSwapColor = COLOR(gpuData[0]);
\r
2342 /* if(iOffscreenDrawing)
\r
2344 ClampToPSXScreenOffset( &sprtX, &sprtY, &sprtW, &sprtH);
\r
2345 if ((sprtW == 0) || (sprtH == 0)) return;
\r
2346 InvalidateTextureArea(sprtX, sprtY, sprtW-1, sprtH-1);
\r
2351 FillSoftwareArea(sprtX, sprtY, sprtW, sprtH, BGR24to16(gpuData[0]));
\r
2355 ////////////////////////////////////////////////////////////////////////
\r
2356 // cmd: move image vram -> vram
\r
2357 ////////////////////////////////////////////////////////////////////////
\r
2359 void MoveImageWrapped(short imageX0,short imageY0,
\r
2360 short imageX1,short imageY1,
\r
2361 short imageSX,short imageSY)
\r
2363 int i,j,imageXE,imageYE;
\r
2365 if(iFrameReadType&2)
\r
2367 imageXE=imageX0+imageSX;
\r
2368 imageYE=imageY0+imageSY;
\r
2370 if(imageYE>iGPUHeight && imageXE>1024)
\r
2372 CheckVRamRead(0,0,
\r
2374 (imageY0&iGPUHeightMask),
\r
2380 CheckVRamRead(0,imageY0,
\r
2382 (imageYE>iGPUHeight)?iGPUHeight:imageYE,
\r
2386 if(imageYE>iGPUHeight)
\r
2388 CheckVRamRead(imageX0,0,
\r
2389 (imageXE>1024)?1024:imageXE,
\r
2390 imageYE&iGPUHeightMask,
\r
2394 CheckVRamRead(imageX0,imageY0,
\r
2395 (imageXE>1024)?1024:imageXE,
\r
2396 (imageYE>iGPUHeight)?iGPUHeight:imageYE,
\r
2400 for(j=0;j<imageSY;j++)
\r
2401 for(i=0;i<imageSX;i++)
\r
2402 psxVuw [(1024*((imageY1+j)&iGPUHeightMask))+((imageX1+i)&0x3ff)]=
\r
2403 psxVuw[(1024*((imageY0+j)&iGPUHeightMask))+((imageX0+i)&0x3ff)];
\r
2405 if(!PSXDisplay.RGB24)
\r
2407 imageXE=imageX1+imageSX;
\r
2408 imageYE=imageY1+imageSY;
\r
2410 if(imageYE>iGPUHeight && imageXE>1024)
\r
2412 InvalidateTextureArea(0,0,
\r
2413 (imageXE&0x3ff)-1,
\r
2414 (imageYE&iGPUHeightMask)-1);
\r
2419 InvalidateTextureArea(0,imageY1,
\r
2420 (imageXE&0x3ff)-1,
\r
2421 ((imageYE>iGPUHeight)?iGPUHeight:imageYE)-imageY1-1);
\r
2424 if(imageYE>iGPUHeight)
\r
2426 InvalidateTextureArea(imageX1,0,
\r
2427 ((imageXE>1024)?1024:imageXE)-imageX1-1,
\r
2428 (imageYE&iGPUHeightMask)-1);
\r
2431 InvalidateTextureArea(imageX1,imageY1,
\r
2432 ((imageXE>1024)?1024:imageXE)-imageX1-1,
\r
2433 ((imageYE>iGPUHeight)?iGPUHeight:imageYE)-imageY1-1);
\r
2437 ////////////////////////////////////////////////////////////////////////
\r
2439 void primMoveImage(unsigned char * baseAddr)
\r
2441 short *sgpuData = ((short *) baseAddr);
\r
2442 short imageY0,imageX0,imageY1,imageX1,imageSX,imageSY,i,j;
\r
2444 imageX0 = sgpuData[2]&0x03ff;
\r
2445 imageY0 = sgpuData[3]&iGPUHeightMask;
\r
2446 imageX1 = sgpuData[4]&0x03ff;
\r
2447 imageY1 = sgpuData[5]&iGPUHeightMask;
\r
2448 imageSX = sgpuData[6];
\r
2449 imageSY = sgpuData[7];
\r
2451 if((imageX0 == imageX1) && (imageY0 == imageY1)) return;
\r
2452 if(imageSX<=0) return;
\r
2453 if(imageSY<=0) return;
\r
2455 if(iGPUHeight==1024 && sgpuData[7]>1024) return;
\r
2457 if((imageY0+imageSY)>iGPUHeight ||
\r
2458 (imageX0+imageSX)>1024 ||
\r
2459 (imageY1+imageSY)>iGPUHeight ||
\r
2460 (imageX1+imageSX)>1024)
\r
2462 MoveImageWrapped(imageX0,imageY0,imageX1,imageY1,imageSX,imageSY);
\r
2463 if((imageY0+imageSY)>iGPUHeight) imageSY=iGPUHeight-imageY0;
\r
2464 if((imageX0+imageSX)>1024) imageSX=1024-imageX0;
\r
2465 if((imageY1+imageSY)>iGPUHeight) imageSY=iGPUHeight-imageY1;
\r
2466 if((imageX1+imageSX)>1024) imageSX=1024-imageX1;
\r
2469 if(iFrameReadType&2)
\r
2470 CheckVRamRead(imageX0,imageY0,
\r
2477 unsigned short *SRCPtr, *DSTPtr;
\r
2478 unsigned short LineOffset;
\r
2480 SRCPtr = psxVuw + (1024*imageY0) + imageX0;
\r
2481 DSTPtr = psxVuw + (1024*imageY1) + imageX1;
\r
2483 LineOffset = 1024 - imageSX;
\r
2485 for(j=0;j<imageSY;j++)
\r
2487 for(i=0;i<imageSX;i++) *DSTPtr++ = *SRCPtr++;
\r
2488 SRCPtr += LineOffset;
\r
2489 DSTPtr += LineOffset;
\r
2494 unsigned int *SRCPtr, *DSTPtr;
\r
2495 unsigned short LineOffset;
\r
2496 int dx=imageSX>>1;
\r
2498 SRCPtr = (unsigned int *)(psxVuw + (1024*imageY0) + imageX0);
\r
2499 DSTPtr = (unsigned int *)(psxVuw + (1024*imageY1) + imageX1);
\r
2501 LineOffset = 512 - dx;
\r
2503 for(j=0;j<imageSY;j++)
\r
2505 for(i=0;i<dx;i++) *DSTPtr++ = *SRCPtr++;
\r
2506 SRCPtr += LineOffset;
\r
2507 DSTPtr += LineOffset;
\r
2511 if (!PSXDisplay.RGB24)
\r
2513 InvalidateTextureArea(imageX1,imageY1,imageSX-1,imageSY-1);
\r
2515 if (CheckAgainstScreen(imageX1,imageY1,imageSX,imageSY))
\r
2517 if(imageX1>=PreviousPSXDisplay.DisplayPosition.x &&
\r
2518 imageX1<PreviousPSXDisplay.DisplayEnd.x &&
\r
2519 imageY1>=PreviousPSXDisplay.DisplayPosition.y &&
\r
2520 imageY1<PreviousPSXDisplay.DisplayEnd.y)
\r
2522 imageX1 += imageSX;
\r
2523 imageY1 += imageSY;
\r
2525 if(imageX1>=PreviousPSXDisplay.DisplayPosition.x &&
\r
2526 imageX1<=PreviousPSXDisplay.DisplayEnd.x &&
\r
2527 imageY1>=PreviousPSXDisplay.DisplayPosition.y &&
\r
2528 imageY1<=PreviousPSXDisplay.DisplayEnd.y)
\r
2531 imageX0>=PSXDisplay.DisplayPosition.x &&
\r
2532 imageX0<PSXDisplay.DisplayEnd.x &&
\r
2533 imageY0>=PSXDisplay.DisplayPosition.y &&
\r
2534 imageY0<PSXDisplay.DisplayEnd.y
\r
2537 if(bRenderFrontBuffer)
\r
2539 updateFrontDisplay();
\r
2542 UploadScreen(FALSE);
\r
2544 else bFakeFrontBuffer=TRUE;
\r
2548 bNeedUploadTest=TRUE;
\r
2551 if(iOffscreenDrawing)
\r
2553 if (CheckAgainstFrontScreen(imageX1,imageY1,imageSX,imageSY))
\r
2555 if(!PSXDisplay.InterlacedTest &&
\r
2558 imageX0>=PreviousPSXDisplay.DisplayPosition.x &&
\r
2559 imageX0<PreviousPSXDisplay.DisplayEnd.x &&
\r
2560 imageY0>=PreviousPSXDisplay.DisplayPosition.y &&
\r
2561 imageY0<PreviousPSXDisplay.DisplayEnd.y
\r
2564 imageX0>=PSXDisplay.DisplayPosition.x &&
\r
2565 imageX0<PSXDisplay.DisplayEnd.x &&
\r
2566 imageY0>=PSXDisplay.DisplayPosition.y &&
\r
2567 imageY0<PSXDisplay.DisplayEnd.y
\r
2571 bNeedUploadTest=TRUE;
\r
2573 if(!bNeedUploadAfter)
\r
2575 bNeedUploadAfter = TRUE;
\r
2576 xrUploadArea.x0=imageX0;
\r
2577 xrUploadArea.x1=imageX0+imageSX;
\r
2578 xrUploadArea.y0=imageY0;
\r
2579 xrUploadArea.y1=imageY0+imageSY;
\r
2583 xrUploadArea.x0=min(xrUploadArea.x0,imageX0);
\r
2584 xrUploadArea.x1=max(xrUploadArea.x1,imageX0+imageSX);
\r
2585 xrUploadArea.y0=min(xrUploadArea.y0,imageY0);
\r
2586 xrUploadArea.y1=max(xrUploadArea.y1,imageY0+imageSY);
\r
2594 ////////////////////////////////////////////////////////////////////////
\r
2595 // cmd: draw free-size Tile
\r
2596 ////////////////////////////////////////////////////////////////////////
\r
2598 void primTileS(unsigned char * baseAddr)
\r
2600 unsigned int *gpuData = ((unsigned int*)baseAddr);
\r
2601 short *sgpuData = ((short *) baseAddr);
\r
2603 sprtX = sgpuData[2];
\r
2604 sprtY = sgpuData[3];
\r
2605 sprtW = sgpuData[4] & 0x3ff;
\r
2606 sprtH = sgpuData[5] & iGPUHeightMask;
\r
2608 // x and y of start
\r
2615 if((dwActFixes&1) && // FF7 special game gix (battle cursor)
\r
2616 sprtX==0 && sprtY==0 && sprtW==24 && sprtH==16)
\r
2619 bDrawTextured = FALSE;
\r
2620 bDrawSmoothShaded = FALSE;
\r
2622 SetRenderState(gpuData[0]);
\r
2624 /* if(iOffscreenDrawing)
\r
2626 if(IsPrimCompleteInsideNextScreen(lx0,ly0,lx2,ly2) ||
\r
2627 (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
2629 lClearOnSwapColor = COLOR(gpuData[0]);
\r
2634 if(bDrawOffscreen4())
\r
2636 if(!(iTileCheat && sprtH==32 && gpuData[0]==0x60ffffff)) // special cheat for certain ZiNc games
\r
2638 InvalidateTextureAreaEx();
\r
2639 FillSoftwareAreaTrans(lx0,ly0,lx2,ly2,
\r
2640 BGR24to16(gpuData[0]));
\r
2645 SetRenderMode(gpuData[0], FALSE);
\r
2648 if(bIgnoreNextTile) {bIgnoreNextTile=FALSE;return;}
\r
2650 vertex[0].c.lcol=gpuData[0];
\r
2651 vertex[0].c.col[3]=ubGloColAlpha;
\r
2652 SETCOL(vertex[0]);
\r
2654 PRIMdrawQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
2656 iDrawnSomething=1;
\r
2659 ////////////////////////////////////////////////////////////////////////
\r
2660 // cmd: draw 1 dot Tile (point)
\r
2661 ////////////////////////////////////////////////////////////////////////
\r
2663 void primTile1(unsigned char * baseAddr)
\r
2665 unsigned int *gpuData = ((unsigned int*)baseAddr);
\r
2666 short *sgpuData = ((short *) baseAddr);
\r
2668 sprtX = sgpuData[2];
\r
2669 sprtY = sgpuData[3];
\r
2678 bDrawTextured = FALSE;
\r
2679 bDrawSmoothShaded = FALSE;
\r
2681 SetRenderState(gpuData[0]);
\r
2683 /* if(iOffscreenDrawing)
\r
2687 if(bDrawOffscreen4())
\r
2689 InvalidateTextureAreaEx();
\r
2690 FillSoftwareAreaTrans(lx0,ly0,lx2,ly2,
\r
2691 BGR24to16(gpuData[0]));
\r
2695 SetRenderMode(gpuData[0], FALSE);
\r
2698 vertex[0].c.lcol=gpuData[0];vertex[0].c.col[3]=ubGloColAlpha;
\r
2699 SETCOL(vertex[0]);
\r
2701 PRIMdrawQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
2703 iDrawnSomething=1;
\r
2706 ////////////////////////////////////////////////////////////////////////
\r
2707 // cmd: draw 8 dot Tile (small rect)
\r
2708 ////////////////////////////////////////////////////////////////////////
\r
2710 void primTile8(unsigned char * baseAddr)
\r
2712 unsigned int *gpuData = ((unsigned int*)baseAddr);
\r
2713 short *sgpuData = ((short *) baseAddr);
\r
2715 sprtX = sgpuData[2];
\r
2716 sprtY = sgpuData[3];
\r
2725 bDrawTextured = FALSE;
\r
2726 bDrawSmoothShaded = FALSE;
\r
2727 SetRenderState(gpuData[0]);
\r
2729 /* if(iOffscreenDrawing)
\r
2733 if(bDrawOffscreen4())
\r
2735 InvalidateTextureAreaEx();
\r
2736 FillSoftwareAreaTrans(lx0,ly0,lx2,ly2,
\r
2737 BGR24to16(gpuData[0]));
\r
2741 SetRenderMode(gpuData[0], FALSE);
\r
2744 vertex[0].c.lcol=gpuData[0];
\r
2745 vertex[0].c.col[3]=ubGloColAlpha;
\r
2746 SETCOL(vertex[0]);
\r
2748 PRIMdrawQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
2750 iDrawnSomething=1;
\r
2753 ////////////////////////////////////////////////////////////////////////
\r
2754 // cmd: draw 16 dot Tile (medium rect)
\r
2755 ////////////////////////////////////////////////////////////////////////
\r
2757 void primTile16(unsigned char * baseAddr)
\r
2759 unsigned int *gpuData = ((unsigned int*)baseAddr);
\r
2760 short *sgpuData = ((short *) baseAddr);
\r
2762 sprtX = sgpuData[2];
\r
2763 sprtY = sgpuData[3];
\r
2766 // x and y of start
\r
2772 bDrawTextured = FALSE;
\r
2773 bDrawSmoothShaded = FALSE;
\r
2774 SetRenderState(gpuData[0]);
\r
2776 /* if(iOffscreenDrawing)
\r
2780 if(bDrawOffscreen4())
\r
2782 InvalidateTextureAreaEx();
\r
2783 FillSoftwareAreaTrans(lx0,ly0,lx2,ly2,
\r
2784 BGR24to16(gpuData[0]));
\r
2788 SetRenderMode(gpuData[0], FALSE);
\r
2791 vertex[0].c.lcol=gpuData[0];
\r
2792 vertex[0].c.col[3]=ubGloColAlpha;
\r
2793 SETCOL(vertex[0]);
\r
2795 PRIMdrawQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
2797 iDrawnSomething=1;
\r
2800 ////////////////////////////////////////////////////////////////////////
\r
2801 // helper: filter effect by multipass rendering
\r
2802 ////////////////////////////////////////////////////////////////////////
\r
2804 /*void DrawMultiBlur(void)
\r
2806 int lABR,lDST;float fx,fy;
\r
2808 lABR=GlobalTextABR;
\r
2809 lDST=DrawSemiTrans;
\r
2811 fx=(float)PSXDisplay.DisplayMode.x/(float)(iResX);
\r
2812 fy=(float)PSXDisplay.DisplayMode.y/(float)(iResY);
\r
2814 vertex[0].x+=fx;vertex[1].x+=fx;
\r
2815 vertex[2].x+=fx;vertex[3].x+=fx;
\r
2821 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
2823 vertex[0].y+=fy;vertex[1].y+=fy;
\r
2824 vertex[2].y+=fy;vertex[3].y+=fy;
\r
2825 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
2827 if(bDrawMultiPass) {obm1=obm2=GL_SRC_ALPHA;}
\r
2829 GlobalTextABR=lABR;
\r
2830 DrawSemiTrans=lDST;
\r
2833 ////////////////////////////////////////////////////////////////////////
\r
2835 #define POFF 0.375f
\r
2837 void DrawMultiFilterSprite(void)
\r
2841 if(bUseMultiPass || DrawSemiTrans || ubOpaqueDraw)
\r
2843 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
2847 lABR=GlobalTextABR;
\r
2848 lDST=DrawSemiTrans;
\r
2849 vertex[0].c.col[3]=ubGloAlpha/2; // -> set color with
\r
2850 SETCOL(vertex[0]); // texture alpha
\r
2851 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
2852 vertex[0].x+=POFF;vertex[1].x+=POFF;
\r
2853 vertex[2].x+=POFF;vertex[3].x+=POFF;
\r
2854 vertex[0].y+=POFF;vertex[1].y+=POFF;
\r
2855 vertex[2].y+=POFF;vertex[3].y+=POFF;
\r
2859 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
2860 GlobalTextABR=lABR;
\r
2861 DrawSemiTrans=lDST;
\r
2864 ////////////////////////////////////////////////////////////////////////
\r
2865 // cmd: small sprite (textured rect)
\r
2866 ////////////////////////////////////////////////////////////////////////
\r
2868 void primSprt8(unsigned char * baseAddr)
\r
2870 unsigned int *gpuData = ((unsigned int *) baseAddr);
\r
2871 short *sgpuData = ((short *) baseAddr);
\r
2876 sprtX = sgpuData[2];
\r
2877 sprtY = sgpuData[3];
\r
2886 // do texture stuff
\r
2887 gl_ux[0]=gl_ux[3]=baseAddr[8];//gpuData[2]&0xff;
\r
2889 if(usMirror & 0x1000)
\r
2894 gl_ux[0]=gl_ux[3]=s;
\r
2897 sSprite_ux2=s=gl_ux[0]+sprtW;
\r
2900 gl_ux[1]=gl_ux[2]=s;
\r
2902 gl_vy[0]=gl_vy[1]=baseAddr[9];//(gpuData[2]>>8)&0xff;
\r
2904 if(usMirror & 0x2000)
\r
2909 gl_vy[0]=gl_vy[1]=s;
\r
2912 sSprite_vy2=s=gl_vy[0]+sprtH;
\r
2915 gl_vy[2]=gl_vy[3]=s;
\r
2917 ulClutID=(gpuData[2]>>16);
\r
2919 bDrawTextured = TRUE;
\r
2920 bDrawSmoothShaded = FALSE;
\r
2921 SetRenderState(gpuData[0]);
\r
2923 /* if(iOffscreenDrawing)
\r
2927 if(bDrawOffscreen4())
\r
2929 InvalidateTextureAreaEx();
\r
2930 SetRenderColor(gpuData[0]);
\r
2931 lx0-=PSXDisplay.DrawOffset.x;
\r
2932 ly0-=PSXDisplay.DrawOffset.y;
\r
2934 if(bUsingTWin) DrawSoftwareSpriteTWin(baseAddr,8,8);
\r
2936 if(usMirror) DrawSoftwareSpriteMirror(baseAddr,8,8);
\r
2938 DrawSoftwareSprite(baseAddr,8,8,baseAddr[8],baseAddr[9]);
\r
2942 SetRenderMode(gpuData[0], TRUE);
\r
2945 sSprite_ux2=gl_ux[0]+sprtW;
\r
2946 sSprite_vy2=gl_vy[0]+sprtH;
\r
2948 assignTextureSprite();
\r
2950 if(iFilterType>4)
\r
2951 DrawMultiFilterSprite();
\r
2953 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
2955 if(bDrawMultiPass)
\r
2957 SetSemiTransMulti(1);
\r
2958 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
2964 if(bUseMultiPass) SetOpaqueColor(gpuData[0]);
\r
2967 /* if(bSmallAlpha && iFilterType<=2)
\r
2969 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
\r
2970 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
\r
2971 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\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
2977 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
2982 iDrawnSomething=1;
\r
2985 ////////////////////////////////////////////////////////////////////////
\r
2986 // cmd: medium sprite (textured rect)
\r
2987 ////////////////////////////////////////////////////////////////////////
\r
2989 void primSprt16(unsigned char * baseAddr)
\r
2991 unsigned int *gpuData = ((unsigned int *) baseAddr);
\r
2992 short *sgpuData = ((short *) baseAddr);
\r
2997 sprtX = sgpuData[2];
\r
2998 sprtY = sgpuData[3];
\r
3007 // do texture stuff
\r
3008 gl_ux[0]=gl_ux[3]=baseAddr[8];//gpuData[2]&0xff;
\r
3010 if(usMirror & 0x1000)
\r
3015 gl_ux[0]=gl_ux[3]=s;
\r
3018 sSprite_ux2=s=gl_ux[0]+sprtW;
\r
3021 gl_ux[1]=gl_ux[2]=s;
\r
3023 gl_vy[0]=gl_vy[1]=baseAddr[9];//(gpuData[2]>>8)&0xff;
\r
3025 if(usMirror & 0x2000)
\r
3030 gl_vy[0]=gl_vy[1]=s;
\r
3033 sSprite_vy2=s=gl_vy[0]+sprtH;
\r
3036 gl_vy[2]=gl_vy[3]=s;
\r
3038 ulClutID=(gpuData[2]>>16);
\r
3040 bDrawTextured = TRUE;
\r
3041 bDrawSmoothShaded = FALSE;
\r
3042 SetRenderState(gpuData[0]);
\r
3044 /* if(iOffscreenDrawing)
\r
3048 if(bDrawOffscreen4())
\r
3050 InvalidateTextureAreaEx();
\r
3051 SetRenderColor(gpuData[0]);
\r
3052 lx0-=PSXDisplay.DrawOffset.x;
\r
3053 ly0-=PSXDisplay.DrawOffset.y;
\r
3054 if(bUsingTWin) DrawSoftwareSpriteTWin(baseAddr,16,16);
\r
3056 if(usMirror) DrawSoftwareSpriteMirror(baseAddr,16,16);
\r
3058 DrawSoftwareSprite(baseAddr,16,16,baseAddr[8],baseAddr[9]);
\r
3062 SetRenderMode(gpuData[0], TRUE);
\r
3065 sSprite_ux2=gl_ux[0]+sprtW;
\r
3066 sSprite_vy2=gl_vy[0]+sprtH;
\r
3068 assignTextureSprite();
\r
3070 if(iFilterType>4)
\r
3071 DrawMultiFilterSprite();
\r
3073 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
3075 if(bDrawMultiPass)
\r
3077 SetSemiTransMulti(1);
\r
3078 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
3084 if(bUseMultiPass) SetOpaqueColor(gpuData[0]);
\r
3087 /* if(bSmallAlpha && iFilterType<=2)
\r
3089 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
\r
3090 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
\r
3091 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\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
3097 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
3102 iDrawnSomething=1;
\r
3105 ////////////////////////////////////////////////////////////////////////
\r
3106 // cmd: free-size sprite (textured rect)
\r
3107 ////////////////////////////////////////////////////////////////////////
\r
3109 void primSprtSRest(unsigned char * baseAddr,unsigned short type)
\r
3111 unsigned int *gpuData = ((unsigned int *) baseAddr);
\r
3112 short *sgpuData = ((short *) baseAddr);
\r
3113 short s;unsigned short sTypeRest=0;
\r
3115 sprtX = sgpuData[2];
\r
3116 sprtY = sgpuData[3];
\r
3117 sprtW = sgpuData[6] & 0x3ff;
\r
3118 sprtH = sgpuData[7] & 0x1ff;
\r
3121 // do texture stuff
\r
3125 gl_vy[0]=gl_vy[1]=baseAddr[9];
\r
3126 s=256-baseAddr[8];
\r
3129 gl_ux[0]=gl_ux[3]=0;
\r
3132 gl_ux[0]=gl_ux[3]=baseAddr[8];
\r
3133 s=256-baseAddr[9];
\r
3136 gl_vy[0]=gl_vy[1]=0;
\r
3139 s=256-baseAddr[8];
\r
3142 gl_ux[0]=gl_ux[3]=0;
\r
3143 s=256-baseAddr[9];
\r
3146 gl_vy[0]=gl_vy[1]=0;
\r
3150 gl_vy[0]=gl_vy[1]=baseAddr[9];
\r
3151 s=512-baseAddr[8];
\r
3154 gl_ux[0]=gl_ux[3]=0;
\r
3157 gl_ux[0]=gl_ux[3]=baseAddr[8];
\r
3158 s=512-baseAddr[9];
\r
3161 gl_vy[0]=gl_vy[1]=0;
\r
3164 s=512-baseAddr[8];
\r
3167 gl_ux[0]=gl_ux[3]=0;
\r
3168 s=512-baseAddr[9];
\r
3171 gl_vy[0]=gl_vy[1]=0;
\r
3176 if(usMirror & 0x1000)
\r
3179 s-=sprtW-1;if(s<0) s=0;
\r
3180 gl_ux[0]=gl_ux[3]=s;
\r
3182 if(usMirror & 0x2000)
\r
3185 s-=sprtH-1;if(s<0) {s=0;}
\r
3186 gl_vy[0]=gl_vy[1]=s;
\r
3189 sSprite_ux2=s=gl_ux[0]+sprtW;
\r
3191 gl_ux[1]=gl_ux[2]=s;
\r
3192 sSprite_vy2=s=gl_vy[0]+sprtH;
\r
3194 gl_vy[2]=gl_vy[3]=s;
\r
3198 if(sSprite_ux2>256)
\r
3199 {sprtW=256-gl_ux[0];sSprite_ux2=256;sTypeRest+=1;}
\r
3200 if(sSprite_vy2>256)
\r
3201 {sprtH=256-gl_vy[0];sSprite_vy2=256;sTypeRest+=2;}
\r
3209 ulClutID=(gpuData[2]>>16);
\r
3211 bDrawTextured = TRUE;
\r
3212 bDrawSmoothShaded = FALSE;
\r
3213 SetRenderState(gpuData[0]);
\r
3215 /* if(iOffscreenDrawing)
\r
3219 if(bDrawOffscreen4())
\r
3221 InvalidateTextureAreaEx();
\r
3222 SetRenderColor(gpuData[0]);
\r
3223 lx0-=PSXDisplay.DrawOffset.x;
\r
3224 ly0-=PSXDisplay.DrawOffset.y;
\r
3225 if(bUsingTWin) DrawSoftwareSpriteTWin(baseAddr,sprtW,sprtH);
\r
3227 if(usMirror) DrawSoftwareSpriteMirror(baseAddr,sprtW,sprtH);
\r
3229 DrawSoftwareSprite(baseAddr,sprtW,sprtH,baseAddr[8],baseAddr[9]);
\r
3233 SetRenderMode(gpuData[0], TRUE);
\r
3236 sSprite_ux2=gl_ux[0]+sprtW;
\r
3237 sSprite_vy2=gl_vy[0]+sprtH;
\r
3239 assignTextureSprite();
\r
3241 if(iFilterType>4)
\r
3242 DrawMultiFilterSprite();
\r
3244 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
3246 if(bDrawMultiPass)
\r
3248 SetSemiTransMulti(1);
\r
3249 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
3255 if(bUseMultiPass) SetOpaqueColor(gpuData[0]);
\r
3258 /* if(bSmallAlpha && iFilterType<=2)
\r
3260 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
\r
3261 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
\r
3262 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\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
3268 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
3272 if(sTypeRest && type<4)
\r
3274 if(sTypeRest&1 && type==1) primSprtSRest(baseAddr,4);
\r
3275 if(sTypeRest&2 && type==2) primSprtSRest(baseAddr,5);
\r
3276 if(sTypeRest==3 && type==3) primSprtSRest(baseAddr,6);
\r
3280 void primSprtS(unsigned char * baseAddr)
\r
3282 unsigned int *gpuData = ((unsigned int *) baseAddr);
\r
3283 short *sgpuData = ((short *) baseAddr);
\r
3285 short s;unsigned short sTypeRest=0;
\r
3287 sprtX = sgpuData[2];
\r
3288 sprtY = sgpuData[3];
\r
3289 sprtW = sgpuData[6] & 0x3ff;
\r
3290 sprtH = sgpuData[7] & 0x1ff;
\r
3292 if(!sprtH) return;
\r
3293 if(!sprtW) return;
\r
3297 // do texture stuff
\r
3298 gl_ux[0]=gl_ux[3]=baseAddr[8];//gpuData[2]&0xff;
\r
3299 gl_vy[0]=gl_vy[1]=baseAddr[9];//(gpuData[2]>>8)&0xff;
\r
3301 if(usMirror & 0x1000)
\r
3306 gl_ux[0]=gl_ux[3]=s;
\r
3308 if(usMirror & 0x2000)
\r
3313 gl_vy[0]=gl_vy[1]=s;
\r
3316 sSprite_ux2=s=gl_ux[0]+sprtW;
\r
3319 gl_ux[1]=gl_ux[2]=s;
\r
3320 sSprite_vy2=s=gl_vy[0]+sprtH;
\r
3323 gl_vy[2]=gl_vy[3]=s;
\r
3327 if(sSprite_ux2>256)
\r
3328 {sprtW=256-gl_ux[0];sSprite_ux2=256;sTypeRest+=1;}
\r
3329 if(sSprite_vy2>256)
\r
3330 {sprtH=256-gl_vy[0];sSprite_vy2=256;sTypeRest+=2;}
\r
3338 ulClutID=(gpuData[2]>>16);
\r
3340 bDrawTextured = TRUE;
\r
3341 bDrawSmoothShaded = FALSE;
\r
3342 SetRenderState(gpuData[0]);
\r
3344 /* if(iOffscreenDrawing)
\r
3348 if(bDrawOffscreen4())
\r
3350 InvalidateTextureAreaEx();
\r
3351 SetRenderColor(gpuData[0]);
\r
3352 lx0-=PSXDisplay.DrawOffset.x;
\r
3353 ly0-=PSXDisplay.DrawOffset.y;
\r
3354 if(bUsingTWin) DrawSoftwareSpriteTWin(baseAddr,sprtW,sprtH);
\r
3356 if(usMirror) DrawSoftwareSpriteMirror(baseAddr,sprtW,sprtH);
\r
3358 DrawSoftwareSprite(baseAddr,sprtW,sprtH,baseAddr[8],baseAddr[9]);
\r
3362 SetRenderMode(gpuData[0], TRUE);
\r
3365 if((dwActFixes&1) && gTexFrameName && gTexName==gTexFrameName)
\r
3366 {iSpriteTex=0;return;}
\r
3368 sSprite_ux2=gl_ux[0]+sprtW;
\r
3369 sSprite_vy2=gl_vy[0]+sprtH;
\r
3371 assignTextureSprite();
\r
3373 if(iFilterType>4)
\r
3374 DrawMultiFilterSprite();
\r
3376 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
3378 if(bDrawMultiPass)
\r
3380 SetSemiTransMulti(1);
\r
3381 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
3387 if(bUseMultiPass) SetOpaqueColor(gpuData[0]);
\r
3390 /* if(bSmallAlpha && iFilterType<=2)
\r
3392 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
\r
3393 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
\r
3394 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\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
3400 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
3406 if(sTypeRest&1) primSprtSRest(baseAddr,1);
\r
3407 if(sTypeRest&2) primSprtSRest(baseAddr,2);
\r
3408 if(sTypeRest==3) primSprtSRest(baseAddr,3);
\r
3412 iDrawnSomething=1;
\r
3415 ////////////////////////////////////////////////////////////////////////
\r
3416 // cmd: flat shaded Poly4
\r
3417 ////////////////////////////////////////////////////////////////////////
\r
3419 void primPolyF4(unsigned char *baseAddr)
\r
3421 unsigned int *gpuData = ((unsigned int *) baseAddr);
\r
3422 short *sgpuData = ((short *) baseAddr);
\r
3424 lx0 = sgpuData[2];
\r
3425 ly0 = sgpuData[3];
\r
3426 lx1 = sgpuData[4];
\r
3427 ly1 = sgpuData[5];
\r
3428 lx2 = sgpuData[6];
\r
3429 ly2 = sgpuData[7];
\r
3430 lx3 = sgpuData[8];
\r
3431 ly3 = sgpuData[9];
\r
3433 if(offset4()) return;
\r
3435 bDrawTextured = FALSE;
\r
3436 bDrawSmoothShaded = FALSE;
\r
3437 SetRenderState(gpuData[0]);
\r
3439 /* if(iOffscreenDrawing)
\r
3442 if(bDrawOffscreen4())
\r
3444 InvalidateTextureAreaEx();
\r
3445 drawPoly4F(gpuData[0]);
\r
3449 SetRenderMode(gpuData[0], FALSE);
\r
3452 vertex[0].c.lcol=gpuData[0];vertex[0].c.col[3]=ubGloColAlpha;
\r
3453 SETCOL(vertex[0]);
\r
3455 PRIMdrawTri2(&vertex[0], &vertex[1], &vertex[2],&vertex[3]);
\r
3457 iDrawnSomething=1;
\r
3460 ////////////////////////////////////////////////////////////////////////
\r
3461 // cmd: smooth shaded Poly4
\r
3462 ////////////////////////////////////////////////////////////////////////
\r
3464 void primPolyG4(unsigned char * baseAddr);
\r
3466 BOOL bDrawOffscreenFrontFF9G4(void)
\r
3468 if(lx0< PSXDisplay.DisplayPosition.x) return FALSE; // must be complete in front
\r
3469 if(lx0> PSXDisplay.DisplayEnd.x) return FALSE;
\r
3470 if(ly0< PSXDisplay.DisplayPosition.y) return FALSE;
\r
3471 if(ly0> PSXDisplay.DisplayEnd.y) return FALSE;
\r
3472 if(lx1< PSXDisplay.DisplayPosition.x) return FALSE;
\r
3473 if(lx1> PSXDisplay.DisplayEnd.x) return FALSE;
\r
3474 if(ly1< PSXDisplay.DisplayPosition.y) return FALSE;
\r
3475 if(ly1> PSXDisplay.DisplayEnd.y) return FALSE;
\r
3476 if(lx2< PSXDisplay.DisplayPosition.x) return FALSE;
\r
3477 if(lx2> PSXDisplay.DisplayEnd.x) return FALSE;
\r
3478 if(ly2< PSXDisplay.DisplayPosition.y) return FALSE;
\r
3479 if(ly2> PSXDisplay.DisplayEnd.y) return FALSE;
\r
3480 if(lx3< PSXDisplay.DisplayPosition.x) return FALSE;
\r
3481 if(lx3> PSXDisplay.DisplayEnd.x) return FALSE;
\r
3482 if(ly3< PSXDisplay.DisplayPosition.y) return FALSE;
\r
3483 if(ly3> PSXDisplay.DisplayEnd.y) return FALSE;
\r
3487 BOOL bCheckFF9G4(unsigned char * baseAddr)
\r
3489 static unsigned char pFF9G4Cache[32];
\r
3490 static int iFF9Fix=0;
\r
3496 if(bDrawOffscreenFrontFF9G4())
\r
3498 short *sgpuData = ((short *) pFF9G4Cache);
\r
3500 memcpy(pFF9G4Cache,baseAddr,32);
\r
3502 if(sgpuData[2]==142)
\r
3516 int labr=GlobalTextABR;
\r
3518 primPolyG4(pFF9G4Cache);
\r
3519 GlobalTextABR=labr;
\r
3526 ////////////////////////////////////////////////////////////////////////
\r
3528 void primPolyG4(unsigned char * baseAddr)
\r
3530 unsigned int *gpuData = (unsigned int *)baseAddr;
\r
3531 short *sgpuData = ((short *) baseAddr);
\r
3533 lx0 = sgpuData[2];
\r
3534 ly0 = sgpuData[3];
\r
3535 lx1 = sgpuData[6];
\r
3536 ly1 = sgpuData[7];
\r
3537 lx2 = sgpuData[10];
\r
3538 ly2 = sgpuData[11];
\r
3539 lx3 = sgpuData[14];
\r
3540 ly3 = sgpuData[15];
\r
3542 if(offset4()) return;
\r
3544 bDrawTextured = FALSE;
\r
3545 bDrawSmoothShaded = TRUE;
\r
3546 SetRenderState(gpuData[0]);
\r
3548 /* if(iOffscreenDrawing)
\r
3552 if((dwActFixes&512) && bCheckFF9G4(baseAddr)) return;
\r
3554 if(bDrawOffscreen4())
\r
3556 InvalidateTextureAreaEx();
\r
3557 drawPoly4G(gpuData[0], gpuData[2], gpuData[4], gpuData[6]);
\r
3561 SetRenderMode(gpuData[0], FALSE);
\r
3564 vertex[0].c.lcol=gpuData[0];
\r
3565 vertex[1].c.lcol=gpuData[2];
\r
3566 vertex[2].c.lcol=gpuData[4];
\r
3567 vertex[3].c.lcol=gpuData[6];
\r
3569 vertex[0].c.col[3]=vertex[1].c.col[3]=vertex[2].c.col[3]=vertex[3].c.col[3]=ubGloAlpha;
\r
3572 PRIMdrawGouraudTri2Color(&vertex[0],&vertex[1], &vertex[2], &vertex[3]);
\r
3574 iDrawnSomething=1;
\r
3577 ////////////////////////////////////////////////////////////////////////
\r
3578 // cmd: flat shaded Texture3
\r
3579 ////////////////////////////////////////////////////////////////////////
\r
3581 BOOL DoLineCheck(unsigned int * gpuData)
\r
3583 BOOL bQuad=FALSE;short dx,dy;
\r
3587 dx=lx0-lx2;if(dx<0) dx=-dx;
\r
3591 dy=ly1-ly0;if(dy<0) dy=-dy;
\r
3594 vertex[3]=vertex[2];
\r
3595 vertex[2]=vertex[0];
\r
3596 vertex[2].x=vertex[3].x;
\r
3601 vertex[3]=vertex[2];
\r
3602 vertex[2].y=vertex[0].y;
\r
3604 else return FALSE;
\r
3611 dy=ly0-ly1;if(dy<0) dy=-dy;
\r
3614 vertex[3]=vertex[1];
\r
3615 vertex[3].x=vertex[2].x;
\r
3620 vertex[3]=vertex[2];
\r
3621 vertex[3].y=vertex[1].y;
\r
3623 else return FALSE;
\r
3631 dx=lx0-lx1;if(dx<0) dx=-dx;
\r
3635 dy=ly2-ly0;if(dy<0) dy=-dy;
\r
3638 vertex[3]=vertex[1];
\r
3639 vertex[1]=vertex[0];
\r
3640 vertex[1].x=vertex[3].x;
\r
3645 vertex[3]=vertex[1];
\r
3646 vertex[1].y=vertex[0].y;
\r
3648 else return FALSE;
\r
3655 dy=ly2-ly0;if(dy<0) dy=-dy;
\r
3658 vertex[3]=vertex[2];
\r
3659 vertex[3].x=vertex[1].x;
\r
3664 vertex[3]=vertex[1];
\r
3665 vertex[3].y=vertex[2].y;
\r
3667 else return FALSE;
\r
3675 dx=lx1-lx0;if(dx<0) dx=-dx;
\r
3679 dy=ly1-ly2;if(dy<0) dy=-dy;
\r
3683 vertex[3]=vertex[2];
\r
3684 vertex[2].x=vertex[0].x;
\r
3689 vertex[3]=vertex[2];
\r
3690 vertex[2]=vertex[0];
\r
3691 vertex[2].y=vertex[3].y;
\r
3693 else return FALSE;
\r
3700 dy=ly2-ly1;if(dy<0) dy=-dy;
\r
3704 vertex[3]=vertex[1];
\r
3705 vertex[1].x=vertex[0].x;
\r
3710 vertex[3]=vertex[1];
\r
3711 vertex[1]=vertex[0];
\r
3712 vertex[1].y=vertex[3].y;
\r
3714 else return FALSE;
\r
3720 if(!bQuad) return FALSE;
\r
3722 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[3], &vertex[2]);
\r
3724 if(bDrawMultiPass)
\r
3726 SetSemiTransMulti(1);
\r
3727 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[3], &vertex[2]);
\r
3733 if(bUseMultiPass) SetOpaqueColor(gpuData[0]);
\r
3735 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[3], &vertex[2]);
\r
3739 iDrawnSomething=1;
\r
3744 ////////////////////////////////////////////////////////////////////////
\r
3746 void primPolyFT3(unsigned char * baseAddr)
\r
3748 unsigned int *gpuData = ((unsigned int *) baseAddr);
\r
3749 short *sgpuData = ((short *) baseAddr);
\r
3751 lx0 = sgpuData[2];
\r
3752 ly0 = sgpuData[3];
\r
3753 lx1 = sgpuData[6];
\r
3754 ly1 = sgpuData[7];
\r
3755 lx2 = sgpuData[10];
\r
3756 ly2 = sgpuData[11];
\r
3758 if(offset3()) return;
\r
3760 // do texture UV coordinates stuff
\r
3761 gl_ux[0]=gl_ux[3]=baseAddr[8];//gpuData[2]&0xff;
\r
3762 gl_vy[0]=gl_vy[3]=baseAddr[9];//(gpuData[2]>>8)&0xff;
\r
3763 gl_ux[1]=baseAddr[16];//gpuData[4]&0xff;
\r
3764 gl_vy[1]=baseAddr[17];//(gpuData[4]>>8)&0xff;
\r
3765 gl_ux[2]=baseAddr[24];//gpuData[6]&0xff;
\r
3766 gl_vy[2]=baseAddr[25];//(gpuData[6]>>8)&0xff;
\r
3768 UpdateGlobalTP((unsigned short)(gpuData[4]>>16));
\r
3769 ulClutID=gpuData[2]>>16;
\r
3771 bDrawTextured = TRUE;
\r
3772 bDrawSmoothShaded = FALSE;
\r
3773 SetRenderState(gpuData[0]);
\r
3775 /* if(iOffscreenDrawing)
\r
3778 if(bDrawOffscreen3())
\r
3780 InvalidateTextureAreaEx();
\r
3781 SetRenderColor(gpuData[0]);
\r
3782 drawPoly3FT(baseAddr);
\r
3786 SetRenderMode(gpuData[0], TRUE);
\r
3791 if(!(dwActFixes&0x10))
\r
3793 if(DoLineCheck(gpuData)) return;
\r
3796 PRIMdrawTexturedTri(&vertex[0], &vertex[1], &vertex[2]);
\r
3798 if(bDrawMultiPass)
\r
3800 SetSemiTransMulti(1);
\r
3801 PRIMdrawTexturedTri(&vertex[0], &vertex[1], &vertex[2]);
\r
3807 if(bUseMultiPass) SetOpaqueColor(gpuData[0]);
\r
3809 PRIMdrawTexturedTri(&vertex[0], &vertex[1], &vertex[2]);
\r
3813 iDrawnSomething=1;
\r
3816 ////////////////////////////////////////////////////////////////////////
\r
3817 // cmd: flat shaded Texture4
\r
3818 ////////////////////////////////////////////////////////////////////////
\r
3820 #define ST_FAC 255.99f
\r
3822 void RectTexAlign(void)
\r
3824 int UFlipped = FALSE;
\r
3825 int VFlipped = FALSE;
\r
3827 if(gTexName==gTexFrameName) return;
\r
3831 if(!((lx1==lx3 && ly3==ly2 && lx2==lx0) ||
\r
3832 (lx1==lx2 && ly2==ly3 && lx3==lx0)))
\r
3837 if (vertex[0].tow > vertex[2].tow)
\r
3842 if (vertex[0].tow < vertex[2].tow)
\r
3849 if(!((lx2==lx3 && ly3==ly1 && lx1==lx0) ||
\r
3850 (lx2==lx1 && ly1==ly3 && lx3==lx0)))
\r
3855 if (vertex[0].tow > vertex[1].tow)
\r
3860 if (vertex[0].tow < vertex[1].tow)
\r
3867 if(!((lx3==lx2 && ly2==ly1 && lx1==lx0) ||
\r
3868 (lx3==lx1 && ly1==ly2 && lx2==lx0)))
\r
3873 if (vertex[0].tow > vertex[1].tow)
\r
3878 if (vertex[0].tow < vertex[1].tow)
\r
3888 if (vertex[0].sow > vertex[2].sow)
\r
3893 if (vertex[0].sow < vertex[2].sow)
\r
3902 if (vertex[0].sow > vertex[1].sow)
\r
3907 if (vertex[0].sow < vertex[1].sow)
\r
3916 if (vertex[0].sow > vertex[1].sow)
\r
3921 if (vertex[0].sow < vertex[1].sow)
\r
3934 vertex[2].sow+=0.95f/TWin.UScaleFactor;
\r
3935 vertex[3].sow+=0.95f/TWin.UScaleFactor;
\r
3938 vertex[0].sow+=0.95f/TWin.UScaleFactor;
\r
3939 vertex[1].sow+=0.95f/TWin.UScaleFactor;
\r
3942 vertex[1].sow+=0.95f/TWin.UScaleFactor;
\r
3943 vertex[3].sow+=0.95f/TWin.UScaleFactor;
\r
3946 vertex[0].sow+=0.95f/TWin.UScaleFactor;
\r
3947 vertex[2].sow+=0.95f/TWin.UScaleFactor;
\r
3950 vertex[1].sow+=0.95f/TWin.UScaleFactor;
\r
3951 vertex[2].sow+=0.95f/TWin.UScaleFactor;
\r
3954 vertex[0].sow+=0.95f/TWin.UScaleFactor;
\r
3955 vertex[3].sow+=0.95f/TWin.UScaleFactor;
\r
3964 vertex[2].sow+=1.0f/ST_FAC;
\r
3965 vertex[3].sow+=1.0f/ST_FAC;
\r
3968 vertex[0].sow+=1.0f/ST_FAC;
\r
3969 vertex[1].sow+=1.0f/ST_FAC;
\r
3972 vertex[1].sow+=1.0f/ST_FAC;
\r
3973 vertex[3].sow+=1.0f/ST_FAC;
\r
3976 vertex[0].sow+=1.0f/ST_FAC;
\r
3977 vertex[2].sow+=1.0f/ST_FAC;
\r
3980 vertex[1].sow+=1.0f/ST_FAC;
\r
3981 vertex[2].sow+=1.0f/ST_FAC;
\r
3984 vertex[0].sow+=1.0f/ST_FAC;
\r
3985 vertex[3].sow+=1.0f/ST_FAC;
\r
3995 vertex[2].sow+=1.0f/TWin.UScaleFactor;
\r
3996 vertex[3].sow+=1.0f/TWin.UScaleFactor;
\r
3999 vertex[0].sow+=1.0f/TWin.UScaleFactor;
\r
4000 vertex[1].sow+=1.0f/TWin.UScaleFactor;
\r
4003 vertex[1].sow+=1.0f/TWin.UScaleFactor;
\r
4004 vertex[3].sow+=1.0f/TWin.UScaleFactor;
\r
4007 vertex[0].sow+=1.0f/TWin.UScaleFactor;
\r
4008 vertex[2].sow+=1.0f/TWin.UScaleFactor;
\r
4011 vertex[1].sow+=1.0f/TWin.UScaleFactor;
\r
4012 vertex[2].sow+=1.0f/TWin.UScaleFactor;
\r
4015 vertex[0].sow+=1.0f/TWin.UScaleFactor;
\r
4016 vertex[3].sow+=1.0f/TWin.UScaleFactor;
\r
4025 vertex[2].sow+=1.0f;
\r
4026 vertex[3].sow+=1.0f;
\r
4029 vertex[0].sow+=1.0f;
\r
4030 vertex[1].sow+=1.0f;
\r
4033 vertex[1].sow+=1.0f;
\r
4034 vertex[3].sow+=1.0f;
\r
4037 vertex[0].sow+=1.0f;
\r
4038 vertex[2].sow+=1.0f;
\r
4041 vertex[1].sow+=1.0f;
\r
4042 vertex[2].sow+=1.0f;
\r
4045 vertex[0].sow+=1.0f;
\r
4046 vertex[3].sow+=1.0f;
\r
4061 vertex[2].tow+=0.95f/TWin.VScaleFactor;
\r
4062 vertex[3].tow+=0.95f/TWin.VScaleFactor;
\r
4065 vertex[0].tow+=0.95f/TWin.VScaleFactor;
\r
4066 vertex[1].tow+=0.95f/TWin.VScaleFactor;
\r
4069 vertex[1].tow+=0.95f/TWin.VScaleFactor;
\r
4070 vertex[3].tow+=0.95f/TWin.VScaleFactor;
\r
4073 vertex[0].tow+=0.95f/TWin.VScaleFactor;
\r
4074 vertex[2].tow+=0.95f/TWin.VScaleFactor;
\r
4077 vertex[1].tow+=0.95f/TWin.VScaleFactor;
\r
4078 vertex[2].tow+=0.95f/TWin.VScaleFactor;
\r
4081 vertex[0].tow+=0.95f/TWin.VScaleFactor;
\r
4082 vertex[3].tow+=0.95f/TWin.VScaleFactor;
\r
4091 vertex[2].tow+=1.0f/ST_FAC;
\r
4092 vertex[3].tow+=1.0f/ST_FAC;
\r
4095 vertex[0].tow+=1.0f/ST_FAC;
\r
4096 vertex[1].tow+=1.0f/ST_FAC;
\r
4099 vertex[1].tow+=1.0f/ST_FAC;
\r
4100 vertex[3].tow+=1.0f/ST_FAC;
\r
4103 vertex[0].tow+=1.0f/ST_FAC;
\r
4104 vertex[2].tow+=1.0f/ST_FAC;
\r
4107 vertex[1].tow+=1.0f/ST_FAC;
\r
4108 vertex[2].tow+=1.0f/ST_FAC;
\r
4111 vertex[0].tow+=1.0f/ST_FAC;
\r
4112 vertex[3].tow+=1.0f/ST_FAC;
\r
4122 vertex[2].tow+=1.0f/TWin.VScaleFactor;
\r
4123 vertex[3].tow+=1.0f/TWin.VScaleFactor;
\r
4126 vertex[0].tow+=1.0f/TWin.VScaleFactor;
\r
4127 vertex[1].tow+=1.0f/TWin.VScaleFactor;
\r
4130 vertex[1].tow+=1.0f/TWin.VScaleFactor;
\r
4131 vertex[3].tow+=1.0f/TWin.VScaleFactor;
\r
4134 vertex[0].tow+=1.0f/TWin.VScaleFactor;
\r
4135 vertex[2].tow+=1.0f/TWin.VScaleFactor;
\r
4138 vertex[1].tow+=1.0f/TWin.VScaleFactor;
\r
4139 vertex[2].tow+=1.0f/TWin.VScaleFactor;
\r
4142 vertex[0].tow+=1.0f/TWin.VScaleFactor;
\r
4143 vertex[3].tow+=1.0f/TWin.VScaleFactor;
\r
4152 vertex[2].tow+=1.0f;
\r
4153 vertex[3].tow+=1.0f;
\r
4156 vertex[0].tow+=1.0f;
\r
4157 vertex[1].tow+=1.0f;
\r
4160 vertex[1].tow+=1.0f;
\r
4161 vertex[3].tow+=1.0f;
\r
4164 vertex[0].tow+=1.0f;
\r
4165 vertex[2].tow+=1.0f;
\r
4168 vertex[1].tow+=1.0f;
\r
4169 vertex[2].tow+=1.0f;
\r
4172 vertex[0].tow+=1.0f;
\r
4173 vertex[3].tow+=1.0f;
\r
4182 void primPolyFT4(unsigned char * baseAddr)
\r
4184 unsigned int *gpuData = ((unsigned int *) baseAddr);
\r
4185 short *sgpuData = ((short *) baseAddr);
\r
4187 lx0 = sgpuData[2];
\r
4188 ly0 = sgpuData[3];
\r
4189 lx1 = sgpuData[6];
\r
4190 ly1 = sgpuData[7];
\r
4191 lx2 = sgpuData[10];
\r
4192 ly2 = sgpuData[11];
\r
4193 lx3 = sgpuData[14];
\r
4194 ly3 = sgpuData[15];
\r
4196 if(offset4()) return;
\r
4198 gl_vy[0]=baseAddr[9];//((gpuData[2]>>8)&0xff);
\r
4199 gl_vy[1]=baseAddr[17];//((gpuData[4]>>8)&0xff);
\r
4200 gl_vy[2]=baseAddr[25];//((gpuData[6]>>8)&0xff);
\r
4201 gl_vy[3]=baseAddr[33];//((gpuData[8]>>8)&0xff);
\r
4203 gl_ux[0]=baseAddr[8];//(gpuData[2]&0xff);
\r
4204 gl_ux[1]=baseAddr[16];//(gpuData[4]&0xff);
\r
4205 gl_ux[2]=baseAddr[24];//(gpuData[6]&0xff);
\r
4206 gl_ux[3]=baseAddr[32];//(gpuData[8]&0xff);
\r
4208 UpdateGlobalTP((unsigned short)(gpuData[4]>>16));
\r
4209 ulClutID=(gpuData[2]>>16);
\r
4211 bDrawTextured = TRUE;
\r
4212 bDrawSmoothShaded = FALSE;
\r
4213 SetRenderState(gpuData[0]);
\r
4215 /* if(iOffscreenDrawing)
\r
4218 if(bDrawOffscreen4())
\r
4220 InvalidateTextureAreaEx();
\r
4221 SetRenderColor(gpuData[0]);
\r
4222 drawPoly4FT(baseAddr);
\r
4226 SetRenderMode(gpuData[0], TRUE);
\r
4234 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[3], &vertex[2]);
\r
4236 if(bDrawMultiPass)
\r
4238 SetSemiTransMulti(1);
\r
4239 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[3], &vertex[2]);
\r
4245 if(bUseMultiPass) SetOpaqueColor(gpuData[0]);
\r
4248 /* if(bSmallAlpha && iFilterType<=2)
\r
4250 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
\r
4251 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
\r
4252 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[3], &vertex[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
4259 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[3], &vertex[2]);
\r
4263 iDrawnSomething=1;
\r
4266 ////////////////////////////////////////////////////////////////////////
\r
4267 // cmd: smooth shaded Texture3
\r
4268 ////////////////////////////////////////////////////////////////////////
\r
4270 void primPolyGT3(unsigned char *baseAddr)
\r
4272 unsigned int *gpuData = ((unsigned int *) baseAddr);
\r
4273 short *sgpuData = ((short *) baseAddr);
\r
4275 lx0 = sgpuData[2];
\r
4276 ly0 = sgpuData[3];
\r
4277 lx1 = sgpuData[8];
\r
4278 ly1 = sgpuData[9];
\r
4279 lx2 = sgpuData[14];
\r
4280 ly2 = sgpuData[15];
\r
4282 if(offset3()) return;
\r
4284 // do texture stuff
\r
4285 gl_ux[0]=gl_ux[3]=baseAddr[8];//gpuData[2]&0xff;
\r
4286 gl_vy[0]=gl_vy[3]=baseAddr[9];//(gpuData[2]>>8)&0xff;
\r
4287 gl_ux[1]=baseAddr[20];//gpuData[5]&0xff;
\r
4288 gl_vy[1]=baseAddr[21];//(gpuData[5]>>8)&0xff;
\r
4289 gl_ux[2]=baseAddr[32];//gpuData[8]&0xff;
\r
4290 gl_vy[2]=baseAddr[33];//(gpuData[8]>>8)&0xff;
\r
4292 UpdateGlobalTP((unsigned short)(gpuData[5]>>16));
\r
4293 ulClutID=(gpuData[2]>>16);
\r
4295 bDrawTextured = TRUE;
\r
4296 bDrawSmoothShaded = TRUE;
\r
4297 SetRenderState(gpuData[0]);
\r
4299 /* if(iOffscreenDrawing)
\r
4302 if(bDrawOffscreen3())
\r
4304 InvalidateTextureAreaEx();
\r
4305 drawPoly3GT(baseAddr);
\r
4309 SetRenderMode(gpuData[0], FALSE);
\r
4314 if(bDrawNonShaded)
\r
4316 //if(!bUseMultiPass) vertex[0].lcol=DoubleBGR2RGB(gpuData[0]); else vertex[0].lcol=gpuData[0];
\r
4318 /* if(bGLBlend) vertex[0].c.lcol=0x7f7f7f;
\r
4319 else */vertex[0].c.lcol=0xffffff;
\r
4320 vertex[0].c.col[3]=ubGloAlpha;
\r
4321 SETCOL(vertex[0]);
\r
4323 PRIMdrawTexturedTri(&vertex[0], &vertex[1], &vertex[2]);
\r
4329 PRIMdrawTexturedTri(&vertex[0], &vertex[1], &vertex[2]);
\r
4335 /* if(!bUseMultiPass && !bGLBlend)
\r
4337 */ vertex[0].c.lcol=DoubleBGR2RGB(gpuData[0]);
\r
4338 vertex[1].c.lcol=DoubleBGR2RGB(gpuData[3]);
\r
4339 vertex[2].c.lcol=DoubleBGR2RGB(gpuData[6]);
\r
4343 vertex[0].c.lcol=gpuData[0];
\r
4344 vertex[1].c.lcol=gpuData[3];
\r
4345 vertex[2].c.lcol=gpuData[6];
\r
4347 vertex[0].c.col[3]=vertex[1].c.col[3]=vertex[2].c.col[3]=ubGloAlpha;
\r
4349 PRIMdrawTexGouraudTriColor(&vertex[0], &vertex[1], &vertex[2]);
\r
4351 if(bDrawMultiPass)
\r
4353 SetSemiTransMulti(1);
\r
4354 PRIMdrawTexGouraudTriColor(&vertex[0], &vertex[1], &vertex[2]);
\r
4360 if(bUseMultiPass)
\r
4362 vertex[0].c.lcol=DoubleBGR2RGB(gpuData[0]);
\r
4363 vertex[1].c.lcol=DoubleBGR2RGB(gpuData[3]);
\r
4364 vertex[2].c.lcol=DoubleBGR2RGB(gpuData[6]);
\r
4365 vertex[0].c.col[3]=vertex[1].c.col[3]=vertex[2].c.col[3]=ubGloAlpha;
\r
4368 PRIMdrawTexGouraudTriColor(&vertex[0], &vertex[1], &vertex[2]);
\r
4372 iDrawnSomething=1;
\r
4375 ////////////////////////////////////////////////////////////////////////
\r
4376 // cmd: smooth shaded Poly3
\r
4377 ////////////////////////////////////////////////////////////////////////
\r
4379 void primPolyG3(unsigned char *baseAddr)
\r
4381 unsigned int *gpuData = ((unsigned int *) baseAddr);
\r
4382 short *sgpuData = ((short *) baseAddr);
\r
4384 lx0 = sgpuData[2];
\r
4385 ly0 = sgpuData[3];
\r
4386 lx1 = sgpuData[6];
\r
4387 ly1 = sgpuData[7];
\r
4388 lx2 = sgpuData[10];
\r
4389 ly2 = sgpuData[11];
\r
4391 if(offset3()) return;
\r
4393 bDrawTextured = FALSE;
\r
4394 bDrawSmoothShaded = TRUE;
\r
4395 SetRenderState(gpuData[0]);
\r
4397 /* if(iOffscreenDrawing)
\r
4400 if(bDrawOffscreen3())
\r
4402 InvalidateTextureAreaEx();
\r
4403 drawPoly3G(gpuData[0], gpuData[2], gpuData[4]);
\r
4407 SetRenderMode(gpuData[0], FALSE);
\r
4410 vertex[0].c.lcol=gpuData[0];
\r
4411 vertex[1].c.lcol=gpuData[2];
\r
4412 vertex[2].c.lcol=gpuData[4];
\r
4413 vertex[0].c.col[3]=vertex[1].c.col[3]=vertex[2].c.col[3]=ubGloColAlpha;
\r
4415 PRIMdrawGouraudTriColor(&vertex[0], &vertex[1], &vertex[2]);
\r
4417 iDrawnSomething=1;
\r
4420 ////////////////////////////////////////////////////////////////////////
\r
4421 // cmd: smooth shaded Texture4
\r
4422 ////////////////////////////////////////////////////////////////////////
\r
4424 void primPolyGT4(unsigned char *baseAddr)
\r
4426 unsigned int *gpuData = ((unsigned int *) baseAddr);
\r
4427 short *sgpuData = ((short *) baseAddr);
\r
4429 lx0 = sgpuData[2];
\r
4430 ly0 = sgpuData[3];
\r
4431 lx1 = sgpuData[8];
\r
4432 ly1 = sgpuData[9];
\r
4433 lx2 = sgpuData[14];
\r
4434 ly2 = sgpuData[15];
\r
4435 lx3 = sgpuData[20];
\r
4436 ly3 = sgpuData[21];
\r
4438 if(offset4()) return;
\r
4440 // do texture stuff
\r
4441 gl_ux[0]=baseAddr[8];//gpuData[2]&0xff;
\r
4442 gl_vy[0]=baseAddr[9];//(gpuData[2]>>8)&0xff;
\r
4443 gl_ux[1]=baseAddr[20];//gpuData[5]&0xff;
\r
4444 gl_vy[1]=baseAddr[21];//(gpuData[5]>>8)&0xff;
\r
4445 gl_ux[2]=baseAddr[32];//gpuData[8]&0xff;
\r
4446 gl_vy[2]=baseAddr[33];//(gpuData[8]>>8)&0xff;
\r
4447 gl_ux[3]=baseAddr[44];//gpuData[11]&0xff;
\r
4448 gl_vy[3]=baseAddr[45];//(gpuData[11]>>8)&0xff;
\r
4450 UpdateGlobalTP((unsigned short)(gpuData[5]>>16));
\r
4451 ulClutID=(gpuData[2]>>16);
\r
4453 bDrawTextured = TRUE;
\r
4454 bDrawSmoothShaded = TRUE;
\r
4455 SetRenderState(gpuData[0]);
\r
4457 /* if(iOffscreenDrawing)
\r
4460 if(bDrawOffscreen4())
\r
4462 InvalidateTextureAreaEx();
\r
4463 drawPoly4GT(baseAddr);
\r
4467 SetRenderMode(gpuData[0], FALSE);
\r
4474 if(bDrawNonShaded)
\r
4476 //if(!bUseMultiPass) vertex[0].lcol=DoubleBGR2RGB(gpuData[0]); else vertex[0].lcol=gpuData[0];
\r
4477 /* if(bGLBlend) vertex[0].c.lcol=0x7f7f7f;
\r
4478 else */vertex[0].c.lcol=0xffffff;
\r
4479 vertex[0].c.col[3]=ubGloAlpha;
\r
4480 SETCOL(vertex[0]);
\r
4482 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[3], &vertex[2]);
\r
4487 ubGloAlpha=ubGloColAlpha=0xff;
\r
4489 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[3], &vertex[2]);
\r
4495 // if(!bUseMultiPass && !bGLBlend)
\r
4497 vertex[0].c.lcol=DoubleBGR2RGB(gpuData[0]);
\r
4498 vertex[1].c.lcol=DoubleBGR2RGB(gpuData[3]);
\r
4499 vertex[2].c.lcol=DoubleBGR2RGB(gpuData[6]);
\r
4500 vertex[3].c.lcol=DoubleBGR2RGB(gpuData[9]);
\r
4504 vertex[0].c.lcol=gpuData[0];
\r
4505 vertex[1].c.lcol=gpuData[3];
\r
4506 vertex[2].c.lcol=gpuData[6];
\r
4507 vertex[3].c.lcol=gpuData[9];
\r
4510 vertex[0].c.col[3]=vertex[1].c.col[3]=vertex[2].c.col[3]=vertex[3].c.col[3]=ubGloAlpha;
\r
4512 PRIMdrawTexGouraudTriColorQuad(&vertex[0], &vertex[1], &vertex[3],&vertex[2]);
\r
4514 if(bDrawMultiPass)
\r
4516 SetSemiTransMulti(1);
\r
4517 PRIMdrawTexGouraudTriColorQuad(&vertex[0], &vertex[1], &vertex[3],&vertex[2]);
\r
4523 if(bUseMultiPass)
\r
4525 vertex[0].c.lcol=DoubleBGR2RGB(gpuData[0]);
\r
4526 vertex[1].c.lcol=DoubleBGR2RGB(gpuData[3]);
\r
4527 vertex[2].c.lcol=DoubleBGR2RGB(gpuData[6]);
\r
4528 vertex[3].c.lcol=DoubleBGR2RGB(gpuData[9]);
\r
4529 vertex[0].c.col[3]=vertex[1].c.col[3]=vertex[2].c.col[3]=vertex[3].c.col[3]=ubGloAlpha;
\r
4531 ubGloAlpha=ubGloColAlpha=0xff;
\r
4533 PRIMdrawTexGouraudTriColorQuad(&vertex[0], &vertex[1], &vertex[3],&vertex[2]);
\r
4537 iDrawnSomething=1;
\r
4540 ////////////////////////////////////////////////////////////////////////
\r
4541 // cmd: smooth shaded Poly3
\r
4542 ////////////////////////////////////////////////////////////////////////
\r
4544 void primPolyF3(unsigned char *baseAddr)
\r
4546 unsigned int *gpuData = ((unsigned int *) baseAddr);
\r
4547 short *sgpuData = ((short *) baseAddr);
\r
4549 lx0 = sgpuData[2];
\r
4550 ly0 = sgpuData[3];
\r
4551 lx1 = sgpuData[4];
\r
4552 ly1 = sgpuData[5];
\r
4553 lx2 = sgpuData[6];
\r
4554 ly2 = sgpuData[7];
\r
4556 if(offset3()) return;
\r
4558 bDrawTextured = FALSE;
\r
4559 bDrawSmoothShaded = FALSE;
\r
4560 SetRenderState(gpuData[0]);
\r
4562 /* if(iOffscreenDrawing)
\r
4565 if(bDrawOffscreen3())
\r
4567 InvalidateTextureAreaEx();
\r
4568 drawPoly3F(gpuData[0]);
\r
4572 SetRenderMode(gpuData[0], FALSE);
\r
4575 vertex[0].c.lcol=gpuData[0];
\r
4576 vertex[0].c.col[3]=ubGloColAlpha;
\r
4577 SETCOL(vertex[0]);
\r
4579 PRIMdrawTri(&vertex[0], &vertex[1], &vertex[2]);
\r
4581 iDrawnSomething=1;
\r
4584 ////////////////////////////////////////////////////////////////////////
\r
4585 // cmd: skipping shaded polylines
\r
4586 ////////////////////////////////////////////////////////////////////////
\r
4588 void primLineGSkip(unsigned char *baseAddr)
\r
4590 unsigned int *gpuData = ((unsigned int *) baseAddr);
\r
4591 short *sgpuData = ((short *) baseAddr);
\r
4595 lx1 = sgpuData[2];
\r
4596 ly1 = sgpuData[3];
\r
4598 while(!(((gpuData[i] & 0xF000F000) == 0x50005000) && i>=4))
\r
4602 ly1 = (short)((gpuData[i]>>16) & 0xffff);
\r
4603 lx1 = (short)(gpuData[i] & 0xffff);
\r
4605 i++;if(i>iMax) break;
\r
4609 ////////////////////////////////////////////////////////////////////////
\r
4610 // cmd: shaded polylines
\r
4611 ////////////////////////////////////////////////////////////////////////
\r
4613 void primLineGEx(unsigned char *baseAddr)
\r
4615 unsigned int *gpuData = ((unsigned int *) baseAddr);
\r
4617 short cx0,cx1,cy0,cy1;int i;BOOL bDraw=TRUE;
\r
4619 bDrawTextured = FALSE;
\r
4620 bDrawSmoothShaded = TRUE;
\r
4621 SetRenderState(gpuData[0]);
\r
4622 SetRenderMode(gpuData[0], FALSE);
\r
4625 vertex[0].c.lcol=vertex[3].c.lcol=gpuData[0];
\r
4626 vertex[0].c.col[3]=vertex[3].c.col[3]=ubGloColAlpha;
\r
4627 ly1 = (short)((gpuData[1]>>16) & 0xffff);
\r
4628 lx1 = (short)(gpuData[1] & 0xffff);
\r
4632 //while((gpuData[i]>>24)!=0x55)
\r
4633 //while((gpuData[i]&0x50000000)!=0x50000000)
\r
4634 // currently best way to check for poly line end:
\r
4635 while(!(((gpuData[i] & 0xF000F000) == 0x50005000) && i>=4))
\r
4637 ly0 = ly1;lx0=lx1;
\r
4638 vertex[1].c.lcol=vertex[2].c.lcol=vertex[0].c.lcol;
\r
4639 vertex[0].c.lcol=vertex[3].c.lcol=gpuData[i];
\r
4640 vertex[0].c.col[3]=vertex[3].c.col[3]=ubGloColAlpha;
\r
4644 ly1 = (short)((gpuData[i]>>16) & 0xffff);
\r
4645 lx1 = (short)(gpuData[i] & 0xffff);
\r
4647 if(offsetline()) bDraw=FALSE; else bDraw=TRUE;
\r
4649 if (bDraw && ((lx0 != lx1) || (ly0 != ly1)))
\r
4651 /* if(iOffscreenDrawing)
\r
4653 cx0=lx0;cx1=lx1;cy0=ly0;cy1=ly1;
\r
4655 if(bDrawOffscreen4())
\r
4657 InvalidateTextureAreaEx();
\r
4658 drawPoly4G(gpuData[i-3],gpuData[i-1],gpuData[i-3],gpuData[i-1]);
\r
4660 lx0=cx0;lx1=cx1;ly0=cy0;ly1=cy1;
\r
4663 PRIMdrawGouraudLine(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
4670 iDrawnSomething=1;
\r
4673 ////////////////////////////////////////////////////////////////////////
\r
4674 // cmd: shaded polyline2
\r
4675 ////////////////////////////////////////////////////////////////////////
\r
4677 void primLineG2(unsigned char *baseAddr)
\r
4679 unsigned int *gpuData = ((unsigned int *) baseAddr);
\r
4680 short *sgpuData = ((short *) baseAddr);
\r
4682 lx0 = sgpuData[2];
\r
4683 ly0 = sgpuData[3];
\r
4684 lx1 = sgpuData[6];
\r
4685 ly1 = sgpuData[7];
\r
4687 vertex[0].c.lcol=vertex[3].c.lcol=gpuData[0];
\r
4688 vertex[1].c.lcol=vertex[2].c.lcol=gpuData[2];
\r
4689 vertex[0].c.col[3]=vertex[1].c.col[3]=vertex[2].c.col[3]=vertex[3].c.col[3]=ubGloColAlpha;
\r
4691 bDrawTextured = FALSE;
\r
4692 bDrawSmoothShaded = TRUE;
\r
4694 if((lx0 == lx1) && (ly0 == ly1)) return;
\r
4696 if(offsetline()) return;
\r
4698 SetRenderState(gpuData[0]);
\r
4699 SetRenderMode(gpuData[0], FALSE);
\r
4702 /* if(iOffscreenDrawing)
\r
4705 if(bDrawOffscreen4())
\r
4707 InvalidateTextureAreaEx();
\r
4708 drawPoly4G(gpuData[0],gpuData[2],gpuData[0],gpuData[2]);
\r
4712 //if(ClipVertexList4())
\r
4713 PRIMdrawGouraudLine(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
4715 iDrawnSomething=1;
\r
4718 ////////////////////////////////////////////////////////////////////////
\r
4719 // cmd: skipping flat polylines
\r
4720 ////////////////////////////////////////////////////////////////////////
\r
4722 void primLineFSkip(unsigned char *baseAddr)
\r
4724 unsigned int *gpuData = ((unsigned int *) baseAddr);
\r
4727 ly1 = (short)((gpuData[1]>>16) & 0xffff);
\r
4728 lx1 = (short)(gpuData[1] & 0xffff);
\r
4730 while(!(((gpuData[i] & 0xF000F000) == 0x50005000) && i>=3))
\r
4732 ly1 = (short)((gpuData[i]>>16) & 0xffff);
\r
4733 lx1 = (short)(gpuData[i] & 0xffff);
\r
4734 i++;if(i>iMax) break;
\r
4738 ////////////////////////////////////////////////////////////////////////
\r
4739 // cmd: drawing flat polylines
\r
4740 ////////////////////////////////////////////////////////////////////////
\r
4742 void primLineFEx(unsigned char *baseAddr)
\r
4744 unsigned int *gpuData = ((unsigned int *) baseAddr);
\r
4746 short cx0,cx1,cy0,cy1;int i;
\r
4750 bDrawTextured = FALSE;
\r
4751 bDrawSmoothShaded = FALSE;
\r
4752 SetRenderState(gpuData[0]);
\r
4753 SetRenderMode(gpuData[0], FALSE);
\r
4756 vertex[0].c.lcol=gpuData[0];
\r
4757 vertex[0].c.col[3]=ubGloColAlpha;
\r
4759 ly1 = (short)((gpuData[1]>>16) & 0xffff);
\r
4760 lx1 = (short)(gpuData[1] & 0xffff);
\r
4764 // while(!(gpuData[i]&0x40000000))
\r
4765 // while((gpuData[i]>>24)!=0x55)
\r
4766 // while((gpuData[i]&0x50000000)!=0x50000000)
\r
4767 // currently best way to check for poly line end:
\r
4768 while(!(((gpuData[i] & 0xF000F000) == 0x50005000) && i>=3))
\r
4770 ly0 = ly1;lx0=lx1;
\r
4771 ly1 = (short)((gpuData[i]>>16) & 0xffff);
\r
4772 lx1 = (short)(gpuData[i] & 0xffff);
\r
4776 /* if(iOffscreenDrawing)
\r
4778 cx0=lx0;cx1=lx1;cy0=ly0;cy1=ly1;
\r
4780 if(bDrawOffscreen4())
\r
4782 InvalidateTextureAreaEx();
\r
4783 drawPoly4F(gpuData[0]);
\r
4785 lx0=cx0;lx1=cx1;ly0=cy0;ly1=cy1;
\r
4787 PRIMdrawFlatLine(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
4790 i++;if(i>iMax) break;
\r
4793 iDrawnSomething=1;
\r
4796 ////////////////////////////////////////////////////////////////////////
\r
4797 // cmd: drawing flat polyline2
\r
4798 ////////////////////////////////////////////////////////////////////////
\r
4800 void primLineF2(unsigned char *baseAddr)
\r
4802 unsigned int *gpuData = ((unsigned int *) baseAddr);
\r
4803 short *sgpuData = ((short *) baseAddr);
\r
4805 lx0 = sgpuData[2];
\r
4806 ly0 = sgpuData[3];
\r
4807 lx1 = sgpuData[4];
\r
4808 ly1 = sgpuData[5];
\r
4810 if(offsetline()) return;
\r
4812 bDrawTextured = FALSE;
\r
4813 bDrawSmoothShaded = FALSE;
\r
4814 SetRenderState(gpuData[0]);
\r
4815 SetRenderMode(gpuData[0], FALSE);
\r
4818 vertex[0].c.lcol=gpuData[0];
\r
4819 vertex[0].c.col[3]=ubGloColAlpha;
\r
4821 /* if(iOffscreenDrawing)
\r
4824 if(bDrawOffscreen4())
\r
4826 InvalidateTextureAreaEx();
\r
4827 drawPoly4F(gpuData[0]);
\r
4831 //if(ClipVertexList4())
\r
4832 PRIMdrawFlatLine(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
4834 iDrawnSomething=1;
\r
4837 ////////////////////////////////////////////////////////////////////////
\r
4838 // cmd: well, easiest command... not implemented
\r
4839 ////////////////////////////////////////////////////////////////////////
\r
4841 void primNI(unsigned char *bA)
\r
4845 ////////////////////////////////////////////////////////////////////////
\r
4846 // cmd func ptr table
\r
4847 ////////////////////////////////////////////////////////////////////////
\r
4849 void (*primTableJ[256])(unsigned char *) =
\r
4852 primNI,primNI,primBlkFill,primNI,primNI,primNI,primNI,primNI,
\r
4854 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4856 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4858 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4860 primPolyF3,primPolyF3,primPolyF3,primPolyF3,primPolyFT3,primPolyFT3,primPolyFT3,primPolyFT3,
\r
4862 primPolyF4,primPolyF4,primPolyF4,primPolyF4,primPolyFT4,primPolyFT4,primPolyFT4,primPolyFT4,
\r
4864 primPolyG3,primPolyG3,primPolyG3,primPolyG3,primPolyGT3,primPolyGT3,primPolyGT3,primPolyGT3,
\r
4866 primPolyG4,primPolyG4,primPolyG4,primPolyG4,primPolyGT4,primPolyGT4,primPolyGT4,primPolyGT4,
\r
4868 primLineF2,primLineF2,primLineF2,primLineF2,primNI,primNI,primNI,primNI,
\r
4870 primLineFEx,primLineFEx,primLineFEx,primLineFEx,primLineFEx,primLineFEx,primLineFEx,primLineFEx,
\r
4872 primLineG2,primLineG2,primLineG2,primLineG2,primNI,primNI,primNI,primNI,
\r
4874 primLineGEx,primLineGEx,primLineGEx,primLineGEx,primLineGEx,primLineGEx,primLineGEx,primLineGEx,
\r
4876 primTileS,primTileS,primTileS,primTileS,primSprtS,primSprtS,primSprtS,primSprtS,
\r
4878 primTile1,primTile1,primTile1,primTile1,primNI,primNI,primNI,primNI,
\r
4880 primTile8,primTile8,primTile8,primTile8,primSprt8,primSprt8,primSprt8,primSprt8,
\r
4882 primTile16,primTile16,primTile16,primTile16,primSprt16,primSprt16,primSprt16,primSprt16,
\r
4884 primMoveImage,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4886 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4888 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4890 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4892 primLoadImage,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4894 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4896 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4898 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4900 primStoreImage,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4902 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4904 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4906 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4908 primNI,cmdTexturePage,cmdTextureWindow,cmdDrawAreaStart,cmdDrawAreaEnd,cmdDrawOffset,cmdSTP,primNI,
\r
4910 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4912 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4914 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI
\r
4917 ////////////////////////////////////////////////////////////////////////
\r
4918 // cmd func ptr table for skipping
\r
4919 ////////////////////////////////////////////////////////////////////////
\r
4921 void (*primTableSkip[256])(unsigned char *) =
\r
4924 primNI,primNI,primBlkFill,primNI,primNI,primNI,primNI,primNI,
\r
4926 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4928 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4930 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4932 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4934 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4936 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4938 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4940 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4942 primLineFSkip,primLineFSkip,primLineFSkip,primLineFSkip,primLineFSkip,primLineFSkip,primLineFSkip,primLineFSkip,
\r
4944 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4946 primLineGSkip,primLineGSkip,primLineGSkip,primLineGSkip,primLineGSkip,primLineGSkip,primLineGSkip,primLineGSkip,
\r
4948 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4950 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4952 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4954 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4956 primMoveImage,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4958 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4960 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4962 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4964 primLoadImage,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4966 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4968 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4970 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4972 primStoreImage,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4974 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4976 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4978 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4980 primNI,cmdTexturePage,cmdTextureWindow,cmdDrawAreaStart,cmdDrawAreaEnd,cmdDrawOffset,cmdSTP,primNI,
\r
4982 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4984 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4986 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI
\r