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
31 #include "externals.h"
\r
34 #include "texture.h"
\r
36 #include "gpuStdafx.h"
\r
37 #include "gpuExternals.h"
\r
38 #include "gpuPlugin.h"
\r
39 #include "gpuDraw.h"
\r
40 #include "gpuTexture.h"
\r
41 #include "gpuPrim.h"
\r
45 ////////////////////////////////////////////////////////////////////////
\r
47 ////////////////////////////////////////////////////////////////////////
\r
49 #define DEFOPAQUEON glAlphaFunc(GL_EQUAL,0.0f);bBlendEnable=FALSE;glDisable(GL_BLEND);
\r
50 #define DEFOPAQUEOFF glAlphaFunc(GL_GREATER,0.49f);
\r
52 ////////////////////////////////////////////////////////////////////////
\r
54 ////////////////////////////////////////////////////////////////////////
\r
57 //EGLSurface surface;
\r
58 //EGLDisplay display;
\r
61 BOOL bDrawTextured; // current active drawing states
\r
62 BOOL bDrawSmoothShaded;
\r
63 BOOL bOldSmoothShaded;
\r
64 BOOL bDrawNonShaded;
\r
65 BOOL bDrawMultiPass;
\r
66 int iOffscreenDrawing;
\r
67 int iDrawnSomething=0;
\r
69 BOOL bRenderFrontBuffer=FALSE; // flag for front buffer rendering
\r
71 GLubyte ubGloAlpha; // texture alpha
\r
72 GLubyte ubGloColAlpha; // color alpha
\r
73 int iFilterType; // type of filter
\r
74 BOOL bFullVRam=FALSE; // sign for tex win
\r
75 BOOL bDrawDither; // sign for dither
\r
76 BOOL bUseMultiPass; // sign for multi pass
\r
77 GLuint gTexName; // binded texture
\r
78 BOOL bTexEnabled; // texture enable flag
\r
79 BOOL bBlendEnable; // blend enable flag
\r
80 PSXRect_t xrUploadArea; // rect to upload
\r
81 PSXRect_t xrUploadAreaIL; // rect to upload
\r
82 PSXRect_t xrUploadAreaRGB24; // rect to upload rgb24
\r
83 int iSpriteTex=0; // flag for "hey, it's a sprite"
\r
84 unsigned short usMirror; // mirror, mirror on the wall
\r
86 BOOL bNeedUploadAfter=FALSE; // sign for uploading in next frame
\r
87 BOOL bNeedUploadTest=FALSE; // sign for upload test
\r
88 BOOL bUsingTWin=FALSE; // tex win active flag
\r
89 BOOL bUsingMovie=FALSE; // movie active flag
\r
90 PSXRect_t xrMovieArea; // rect for movie upload
\r
91 short sSprite_ux2; // needed for sprire adjust
\r
92 short sSprite_vy2; //
\r
93 unsigned long ulOLDCOL=0; // active color
\r
94 unsigned long ulClutID; // clut
\r
96 unsigned long dwCfgFixes; // game fixes
\r
97 unsigned long dwActFixes=0;
\r
98 unsigned long dwEmuFixes=0;
\r
101 long drawX,drawY,drawW,drawH; // offscreen drawing checkers
\r
102 short sxmin,sxmax,symin,symax;
\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 #pragma warning (disable : 4035)
\r
152 unsigned long DoubleBGR2RGB (unsigned long BGR)
\r
157 mov eax, BGR /* this can hold the G value */
\r
158 mov ebx, eax /* this can hold the R value */
\r
159 mov edx, eax /* this can hold the B value */
\r
160 and ebx, 000000ffh /* mask the R value */
\r
162 test ebx, 00000100h
\r
167 and eax, 0000ff00h /* mask the G value */
\r
169 test eax, 00010000h
\r
174 and edx, 00ff0000h /* mask the B value */
\r
176 test edx, 01000000h
\r
181 or eax, ebx /* add R to G value */
\r
182 or eax, edx /* add B to RG value */
\r
184 /* Result returned in EAX */
\r
187 unsigned short BGR24to16 (unsigned long BGR)
\r
191 mov eax, BGR /* this can hold the G value */
\r
192 mov ebx, eax /* this can hold the R value */
\r
193 mov edx, eax /* this can hold the B value */
\r
194 shr ebx, 3 /* move the R value */
\r
195 and edx, 00f80000h /* mask the B value */
\r
196 shr edx, 9 /* move the B value */
\r
197 and eax, 00f800h /* mask the G value */
\r
198 shr eax, 6 /* move the G value */
\r
199 and ebx, 0000001fh /* mask the R value */
\r
200 or eax, ebx /* add R to G value */
\r
201 or eax, edx /* add B to RG value */
\r
203 /* Result returned in AX */
\r
206 #pragma warning (default : 4035)
\r
210 unsigned long DoubleBGR2RGB (unsigned long BGR)
\r
212 unsigned long ebx,eax,edx;
\r
214 ebx=(BGR&0x000000ff)<<1;
\r
215 if(ebx&0x00000100) ebx=0x000000ff;
\r
217 eax=(BGR&0x0000ff00)<<1;
\r
218 if(eax&0x00010000) eax=0x0000ff00;
\r
220 edx=(BGR&0x00ff0000)<<1;
\r
221 if(edx&0x01000000) edx=0x00ff0000;
\r
223 return (ebx|eax|edx);
\r
226 unsigned short BGR24to16 (unsigned long BGR)
\r
228 return ((BGR>>3)&0x1f)|((BGR&0xf80000)>>9)|((BGR&0xf800)>>6);
\r
233 ////////////////////////////////////////////////////////////////////////
\r
234 // OpenGL primitive drawing commands
\r
235 ////////////////////////////////////////////////////////////////////////
\r
237 __inline void PRIMdrawTexturedQuad(OGLVertex* vertex1, OGLVertex* vertex2,
\r
238 OGLVertex* vertex3, OGLVertex* vertex4)
\r
244 v[0].xyz.x = fpoint(vertex1->x);
\r
245 v[0].xyz.y = fpoint(vertex1->y);
\r
246 v[0].xyz.z = fpoint(vertex1->z);
\r
247 v[0].st.x = fpoint(vertex1->sow);
\r
248 v[0].st.y = fpoint(vertex1->tow);
\r
250 v[1].xyz.x = fpoint(vertex2->x);
\r
251 v[1].xyz.y = fpoint(vertex2->y);
\r
252 v[1].xyz.z = fpoint(vertex2->z);
\r
253 v[1].st.x = fpoint(vertex2->sow);
\r
254 v[1].st.y = fpoint(vertex2->tow);
\r
256 v[2].xyz.x = fpoint(vertex4->x);
\r
257 v[2].xyz.y = fpoint(vertex4->y);
\r
258 v[2].xyz.z = fpoint(vertex4->z);
\r
259 v[2].st.x = fpoint(vertex4->sow);
\r
260 v[2].st.y = fpoint(vertex4->tow);
\r
262 v[3].xyz.x = fpoint(vertex3->x);
\r
263 v[3].xyz.y = fpoint(vertex3->y);
\r
264 v[3].xyz.z = fpoint(vertex3->z);
\r
265 v[3].st.x = fpoint(vertex3->sow);
\r
266 v[3].st.y = fpoint(vertex3->tow);
\r
268 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
\r
269 glEnableClientState(GL_VERTEX_ARRAY);
\r
270 glTexCoordPointer(2, GL_FLOAT, sizeof(v[0]), &v[0].st);
\r
271 glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0].xyz);
\r
272 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
\r
273 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
\r
274 glDisableClientState(GL_VERTEX_ARRAY);
\r
277 /////////////////////////////////////////////////////////
\r
279 __inline void PRIMdrawTexturedTri(OGLVertex* vertex1, OGLVertex* vertex2,
\r
280 OGLVertex* vertex3)
\r
284 v[0].xyz.x = fpoint(vertex1->x);
\r
285 v[0].xyz.y = fpoint(vertex1->y);
\r
286 v[0].xyz.z = fpoint(vertex1->z);
\r
287 v[0].st.x = fpoint(vertex1->sow);
\r
288 v[0].st.y = fpoint(vertex1->tow);
\r
290 v[1].xyz.x = fpoint(vertex2->x);
\r
291 v[1].xyz.y = fpoint(vertex2->y);
\r
292 v[1].xyz.z = fpoint(vertex2->z);
\r
293 v[1].st.x = fpoint(vertex2->sow);
\r
294 v[1].st.y = fpoint(vertex2->tow);
\r
296 v[2].xyz.x = fpoint(vertex3->x);
\r
297 v[2].xyz.y = fpoint(vertex3->y);
\r
298 v[2].xyz.z = fpoint(vertex3->z);
\r
299 v[2].st.x = fpoint(vertex3->sow);
\r
300 v[2].st.y = fpoint(vertex3->tow);
\r
302 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
\r
303 glEnableClientState(GL_VERTEX_ARRAY);
\r
304 glTexCoordPointer(2, GL_FLOAT, sizeof(v[0]), &v[0].st);
\r
305 glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0].xyz);
\r
306 glDrawArrays(GL_TRIANGLES, 0, 3);
\r
307 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
\r
308 glDisableClientState(GL_VERTEX_ARRAY);
\r
312 /////////////////////////////////////////////////////////
\r
314 __inline void PRIMdrawTexGouraudTriColor(OGLVertex* vertex1, OGLVertex* vertex2,
\r
315 OGLVertex* vertex3)
\r
320 v[0].xyz.x = fpoint(vertex1->x);
\r
321 v[0].xyz.y = fpoint(vertex1->y);
\r
322 v[0].xyz.z = fpoint(vertex1->z);
\r
323 v[0].st.x = fpoint(vertex1->sow);
\r
324 v[0].st.y = fpoint(vertex1->tow);
\r
325 v[0].rgba.r = vertex1->c.col[0];
\r
326 v[0].rgba.g = vertex1->c.col[1];
\r
327 v[0].rgba.b = vertex1->c.col[2];
\r
328 v[0].rgba.a = vertex1->c.col[3];
\r
330 v[1].xyz.x = fpoint(vertex2->x);
\r
331 v[1].xyz.y = fpoint(vertex2->y);
\r
332 v[1].xyz.z = fpoint(vertex2->z);
\r
333 v[1].st.x = fpoint(vertex2->sow);
\r
334 v[1].st.y = fpoint(vertex2->tow);
\r
335 v[1].rgba.r = vertex2->c.col[0];
\r
336 v[1].rgba.g = vertex2->c.col[1];
\r
337 v[1].rgba.b = vertex2->c.col[2];
\r
338 v[1].rgba.a = vertex2->c.col[3];
\r
340 v[2].xyz.x = fpoint(vertex3->x);
\r
341 v[2].xyz.y = fpoint(vertex3->y);
\r
342 v[2].xyz.z = fpoint(vertex3->z);
\r
343 v[2].st.x = fpoint(vertex3->sow);
\r
344 v[2].st.y = fpoint(vertex3->tow);
\r
345 v[2].rgba.r = vertex3->c.col[0];
\r
346 v[2].rgba.g = vertex3->c.col[1];
\r
347 v[2].rgba.b = vertex3->c.col[2];
\r
348 v[2].rgba.a = vertex3->c.col[3];
\r
350 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
\r
351 glEnableClientState(GL_VERTEX_ARRAY);
\r
352 glEnableClientState(GL_COLOR_ARRAY);
\r
354 glTexCoordPointer(2, GL_FLOAT, sizeof(v[0]), &v[0].st);
\r
355 glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0].xyz);
\r
356 glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(v[0]), &v[0].rgba);
\r
358 glDrawArrays(GL_TRIANGLES, 0, 3);
\r
359 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
\r
360 glDisableClientState(GL_VERTEX_ARRAY);
\r
361 glDisableClientState(GL_COLOR_ARRAY);
\r
364 /////////////////////////////////////////////////////////
\r
366 __inline void PRIMdrawTexGouraudTriColorQuad(OGLVertex* vertex1, OGLVertex* vertex2,
\r
367 OGLVertex* vertex3, OGLVertex* vertex4)
\r
371 v[0].xyz.x = fpoint(vertex1->x);
\r
372 v[0].xyz.y = fpoint(vertex1->y);
\r
373 v[0].xyz.z = fpoint(vertex1->z);
\r
374 v[0].st.x = fpoint(vertex1->sow);
\r
375 v[0].st.y = fpoint(vertex1->tow);
\r
376 v[0].rgba.r = vertex1->c.col[0];
\r
377 v[0].rgba.g = vertex1->c.col[1];
\r
378 v[0].rgba.b = vertex1->c.col[2];
\r
379 v[0].rgba.a = vertex1->c.col[3];
\r
381 v[1].xyz.x = fpoint(vertex2->x);
\r
382 v[1].xyz.y = fpoint(vertex2->y);
\r
383 v[1].xyz.z = fpoint(vertex2->z);
\r
384 v[1].st.x = fpoint(vertex2->sow);
\r
385 v[1].st.y = fpoint(vertex2->tow);
\r
386 v[1].rgba.r = vertex2->c.col[0];
\r
387 v[1].rgba.g = vertex2->c.col[1];
\r
388 v[1].rgba.b = vertex2->c.col[2];
\r
389 v[1].rgba.a = vertex2->c.col[3];
\r
391 v[2].xyz.x = fpoint(vertex4->x);
\r
392 v[2].xyz.y = fpoint(vertex4->y);
\r
393 v[2].xyz.z = fpoint(vertex4->z);
\r
394 v[2].st.x = fpoint(vertex4->sow);
\r
395 v[2].st.y = fpoint(vertex4->tow);
\r
396 v[2].rgba.r = vertex4->c.col[0];
\r
397 v[2].rgba.g = vertex4->c.col[1];
\r
398 v[2].rgba.b = vertex4->c.col[2];
\r
399 v[2].rgba.a = vertex4->c.col[3];
\r
401 v[3].xyz.x = fpoint(vertex3->x);
\r
402 v[3].xyz.y = fpoint(vertex3->y);
\r
403 v[3].xyz.z = fpoint(vertex3->z);
\r
404 v[3].st.x = fpoint(vertex3->sow);
\r
405 v[3].st.y = fpoint(vertex3->tow);
\r
406 v[3].rgba.r = vertex3->c.col[0];
\r
407 v[3].rgba.g = vertex3->c.col[1];
\r
408 v[3].rgba.b = vertex3->c.col[2];
\r
409 v[3].rgba.a = vertex3->c.col[3];
\r
411 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
\r
412 glEnableClientState(GL_VERTEX_ARRAY);
\r
413 glEnableClientState(GL_COLOR_ARRAY);
\r
415 glTexCoordPointer(2, GL_FLOAT, sizeof(v[0]), &v[0].st);
\r
416 glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0].xyz);
\r
417 glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(v[0]), &v[0].rgba);
\r
419 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
\r
420 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
\r
421 glDisableClientState(GL_VERTEX_ARRAY);
\r
422 glDisableClientState(GL_COLOR_ARRAY);
\r
425 /////////////////////////////////////////////////////////
\r
427 __inline void PRIMdrawTri(OGLVertex* vertex1, OGLVertex* vertex2, OGLVertex* vertex3)
\r
431 v[0].x = fpoint(vertex1->x);
\r
432 v[0].y = fpoint(vertex1->y);
\r
433 v[0].z = fpoint(vertex1->z);
\r
435 v[1].x = fpoint(vertex2->x);
\r
436 v[1].y = fpoint(vertex2->y);
\r
437 v[1].z = fpoint(vertex2->z);
\r
439 v[2].x = fpoint(vertex3->x);
\r
440 v[2].y = fpoint(vertex3->y);
\r
441 v[2].z = fpoint(vertex3->z);
\r
443 glEnableClientState(GL_VERTEX_ARRAY);
\r
444 glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0]);
\r
445 glDrawArrays(GL_TRIANGLES, 0, 3);
\r
446 glDisableClientState(GL_VERTEX_ARRAY);
\r
449 /////////////////////////////////////////////////////////
\r
451 __inline void PRIMdrawTri2(OGLVertex* vertex1, OGLVertex* vertex2,
\r
452 OGLVertex* vertex3, OGLVertex* vertex4)
\r
456 v[0].x = fpoint(vertex1->x);
\r
457 v[0].y = fpoint(vertex1->y);
\r
458 v[0].z = fpoint(vertex1->z);
\r
460 v[1].x = fpoint(vertex3->x);
\r
461 v[1].y = fpoint(vertex3->y);
\r
462 v[1].z = fpoint(vertex3->z);
\r
464 v[2].x = fpoint(vertex2->x);
\r
465 v[2].y = fpoint(vertex2->y);
\r
466 v[2].z = fpoint(vertex2->z);
\r
468 v[3].x = fpoint(vertex4->x);
\r
469 v[3].y = fpoint(vertex4->y);
\r
470 v[3].z = fpoint(vertex4->z);
\r
472 glEnableClientState(GL_VERTEX_ARRAY);
\r
473 glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0]);
\r
474 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
\r
475 glDisableClientState(GL_VERTEX_ARRAY);
\r
478 /////////////////////////////////////////////////////////
\r
480 __inline void PRIMdrawGouraudTriColor(OGLVertex* vertex1, OGLVertex* vertex2,
\r
481 OGLVertex* vertex3)
\r
485 v[0].xyz.x = fpoint(vertex1->x);
\r
486 v[0].xyz.y = fpoint(vertex1->y);
\r
487 v[0].xyz.z = fpoint(vertex1->z);
\r
488 v[0].rgba.r = vertex1->c.col[0];
\r
489 v[0].rgba.g = vertex1->c.col[1];
\r
490 v[0].rgba.b = vertex1->c.col[2];
\r
491 v[0].rgba.a = vertex1->c.col[3];
\r
493 v[1].xyz.x = fpoint(vertex2->x);
\r
494 v[1].xyz.y = fpoint(vertex2->y);
\r
495 v[1].xyz.z = fpoint(vertex2->z);
\r
496 v[1].rgba.r = vertex2->c.col[0];
\r
497 v[1].rgba.g = vertex2->c.col[1];
\r
498 v[1].rgba.b = vertex2->c.col[2];
\r
499 v[1].rgba.a = vertex2->c.col[3];
\r
501 v[2].xyz.x = fpoint(vertex3->x);
\r
502 v[2].xyz.y = fpoint(vertex3->y);
\r
503 v[2].xyz.z = fpoint(vertex3->z);
\r
504 v[2].rgba.r = vertex3->c.col[0];
\r
505 v[2].rgba.g = vertex3->c.col[1];
\r
506 v[2].rgba.b = vertex3->c.col[2];
\r
507 v[2].rgba.a = vertex3->c.col[3];
\r
509 glEnableClientState(GL_VERTEX_ARRAY);
\r
510 glEnableClientState(GL_COLOR_ARRAY);
\r
512 glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0].xyz);
\r
513 glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(v[0]), &v[0].rgba);
\r
515 glDrawArrays(GL_TRIANGLES, 0, 3);
\r
516 glDisableClientState(GL_VERTEX_ARRAY);
\r
517 glDisableClientState(GL_COLOR_ARRAY);
\r
520 /////////////////////////////////////////////////////////
\r
522 __inline void PRIMdrawGouraudTri2Color(OGLVertex* vertex1, OGLVertex* vertex2,
\r
523 OGLVertex* vertex3, OGLVertex* vertex4)
\r
527 v[0].xyz.x = fpoint(vertex1->x);
\r
528 v[0].xyz.y = fpoint(vertex1->y);
\r
529 v[0].xyz.z = fpoint(vertex1->z);
\r
530 v[0].rgba.r = vertex1->c.col[0];
\r
531 v[0].rgba.g = vertex1->c.col[1];
\r
532 v[0].rgba.b = vertex1->c.col[2];
\r
533 v[0].rgba.a = vertex1->c.col[3];
\r
535 v[1].xyz.x = fpoint(vertex2->x);
\r
536 v[1].xyz.y = fpoint(vertex2->y);
\r
537 v[1].xyz.z = fpoint(vertex2->z);
\r
538 v[1].rgba.r = vertex2->c.col[0];
\r
539 v[1].rgba.g = vertex2->c.col[1];
\r
540 v[1].rgba.b = vertex2->c.col[2];
\r
541 v[1].rgba.a = vertex2->c.col[3];
\r
543 v[2].xyz.x = fpoint(vertex3->x);
\r
544 v[2].xyz.y = fpoint(vertex3->y);
\r
545 v[2].xyz.z = fpoint(vertex3->z);
\r
546 v[2].rgba.r = vertex3->c.col[0];
\r
547 v[2].rgba.g = vertex3->c.col[1];
\r
548 v[2].rgba.b = vertex3->c.col[2];
\r
549 v[2].rgba.a = vertex3->c.col[3];
\r
551 v[3].xyz.x = fpoint(vertex4->x);
\r
552 v[3].xyz.y = fpoint(vertex4->y);
\r
553 v[3].xyz.z = fpoint(vertex4->z);
\r
554 v[3].rgba.r = vertex4->c.col[0];
\r
555 v[3].rgba.g = vertex4->c.col[1];
\r
556 v[3].rgba.b = vertex4->c.col[2];
\r
557 v[3].rgba.a = vertex4->c.col[3];
\r
559 glEnableClientState(GL_VERTEX_ARRAY);
\r
560 glEnableClientState(GL_COLOR_ARRAY);
\r
562 glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0].xyz);
\r
563 glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(v[0]), &v[0].rgba);
\r
565 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
\r
566 glDisableClientState(GL_VERTEX_ARRAY);
\r
567 glDisableClientState(GL_COLOR_ARRAY);
\r
570 /////////////////////////////////////////////////////////
\r
572 __inline void PRIMdrawFlatLine(OGLVertex* vertex1, OGLVertex* vertex2,OGLVertex* vertex3, OGLVertex* vertex4)
\r
576 v[0].xyz.x = fpoint(vertex1->x);
\r
577 v[0].xyz.y = fpoint(vertex1->y);
\r
578 v[0].xyz.z = fpoint(vertex1->z);
\r
579 v[0].rgba.r = vertex1->c.col[0];
\r
580 v[0].rgba.g = vertex1->c.col[1];
\r
581 v[0].rgba.b = vertex1->c.col[2];
\r
582 v[0].rgba.a = vertex1->c.col[3];
\r
584 v[1].xyz.x = fpoint(vertex2->x);
\r
585 v[1].xyz.y = fpoint(vertex2->y);
\r
586 v[1].xyz.z = fpoint(vertex2->z);
\r
587 v[1].rgba.r = vertex1->c.col[0];
\r
588 v[1].rgba.g = vertex1->c.col[1];
\r
589 v[1].rgba.b = vertex1->c.col[2];
\r
590 v[1].rgba.a = vertex1->c.col[3];
\r
592 v[2].xyz.x = fpoint(vertex4->x);
\r
593 v[2].xyz.y = fpoint(vertex4->y);
\r
594 v[2].xyz.z = fpoint(vertex4->z);
\r
595 v[2].rgba.r = vertex1->c.col[0];
\r
596 v[2].rgba.g = vertex1->c.col[1];
\r
597 v[2].rgba.b = vertex1->c.col[2];
\r
598 v[2].rgba.a = vertex1->c.col[3];
\r
600 v[3].xyz.x = fpoint(vertex3->x);
\r
601 v[3].xyz.y = fpoint(vertex3->y);
\r
602 v[3].xyz.z = fpoint(vertex3->z);
\r
603 v[3].rgba.r = vertex1->c.col[0];
\r
604 v[3].rgba.g = vertex1->c.col[1];
\r
605 v[3].rgba.b = vertex1->c.col[2];
\r
606 v[3].rgba.a = vertex1->c.col[3];
\r
608 glEnableClientState(GL_VERTEX_ARRAY);
\r
609 glEnableClientState(GL_COLOR_ARRAY);
\r
611 glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0].xyz);
\r
612 glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(v[0]), &v[0].rgba);
\r
614 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
\r
615 glDisableClientState(GL_VERTEX_ARRAY);
\r
616 glDisableClientState(GL_COLOR_ARRAY);
\r
621 /////////////////////////////////////////////////////////
\r
623 __inline void PRIMdrawGouraudLine(OGLVertex* vertex1, OGLVertex* vertex2,OGLVertex* vertex3, OGLVertex* vertex4)
\r
627 v[0].xyz.x = fpoint(vertex1->x);
\r
628 v[0].xyz.y = fpoint(vertex1->y);
\r
629 v[0].xyz.z = fpoint(vertex1->z);
\r
630 v[0].rgba.r = vertex1->c.col[0];
\r
631 v[0].rgba.g = vertex1->c.col[1];
\r
632 v[0].rgba.b = vertex1->c.col[2];
\r
633 v[0].rgba.a = vertex1->c.col[3];
\r
635 v[1].xyz.x = fpoint(vertex2->x);
\r
636 v[1].xyz.y = fpoint(vertex2->y);
\r
637 v[1].xyz.z = fpoint(vertex2->z);
\r
638 v[1].rgba.r = vertex2->c.col[0];
\r
639 v[1].rgba.g = vertex2->c.col[1];
\r
640 v[1].rgba.b = vertex2->c.col[2];
\r
641 v[1].rgba.a = vertex2->c.col[3];
\r
643 v[3].xyz.x = fpoint(vertex3->x);
\r
644 v[3].xyz.y = fpoint(vertex3->y);
\r
645 v[3].xyz.z = fpoint(vertex3->z);
\r
646 v[3].rgba.r = vertex3->c.col[0];
\r
647 v[3].rgba.g = vertex3->c.col[1];
\r
648 v[3].rgba.b = vertex3->c.col[2];
\r
649 v[3].rgba.a = vertex3->c.col[3];
\r
651 v[2].xyz.x = fpoint(vertex4->x);
\r
652 v[2].xyz.y = fpoint(vertex4->y);
\r
653 v[2].xyz.z = fpoint(vertex4->z);
\r
654 v[2].rgba.r = vertex4->c.col[0];
\r
655 v[2].rgba.g = vertex4->c.col[1];
\r
656 v[2].rgba.b = vertex4->c.col[2];
\r
657 v[2].rgba.a = vertex4->c.col[3];
\r
659 glEnableClientState(GL_VERTEX_ARRAY);
\r
660 glEnableClientState(GL_COLOR_ARRAY);
\r
662 glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0].xyz);
\r
663 glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(v[0]), &v[0].rgba);
\r
665 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
\r
666 glDisableClientState(GL_VERTEX_ARRAY);
\r
667 glDisableClientState(GL_COLOR_ARRAY);
\r
670 /////////////////////////////////////////////////////////
\r
672 __inline void PRIMdrawQuad(OGLVertex* vertex1, OGLVertex* vertex2,
\r
673 OGLVertex* vertex3, OGLVertex* vertex4)
\r
677 v[0].x = fpoint(vertex1->x);
\r
678 v[0].y = fpoint(vertex1->y);
\r
679 v[0].z = fpoint(vertex1->z);
\r
681 v[1].x = fpoint(vertex2->x);
\r
682 v[1].y = fpoint(vertex2->y);
\r
683 v[1].z = fpoint(vertex2->z);
\r
685 v[2].x = fpoint(vertex4->x);
\r
686 v[2].y = fpoint(vertex4->y);
\r
687 v[2].z = fpoint(vertex4->z);
\r
689 v[3].x = fpoint(vertex3->x);
\r
690 v[3].y = fpoint(vertex3->y);
\r
691 v[3].z = fpoint(vertex3->z);
\r
693 glEnableClientState(GL_VERTEX_ARRAY);
\r
694 glVertexPointer(3, GL_FLOAT, sizeof(v[0]), &v[0]);
\r
695 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
\r
696 glDisableClientState(GL_VERTEX_ARRAY);
\r
699 ////////////////////////////////////////////////////////////////////////
\r
700 // Transparent blending settings
\r
701 ////////////////////////////////////////////////////////////////////////
\r
703 static GLenum obm1=GL_ZERO;
\r
704 static GLenum obm2=GL_ZERO;
\r
706 typedef struct SEMITRANSTAG
\r
713 SemiTransParams TransSets[4]=
\r
715 {GL_SRC_ALPHA,GL_SRC_ALPHA, 127},
\r
716 {GL_ONE, GL_ONE, 255},
\r
717 {GL_ZERO, GL_ONE_MINUS_SRC_COLOR,255},
\r
718 {GL_ONE_MINUS_SRC_ALPHA,GL_ONE, 192}
\r
721 ////////////////////////////////////////////////////////////////////////
\r
723 void SetSemiTrans(void)
\r
726 * 0.5 x B + 0.5 x F
\r
727 * 1.0 x B + 1.0 x F
\r
728 * 1.0 x B - 1.0 x F
\r
729 * 1.0 x B +0.25 x F
\r
732 if(!DrawSemiTrans) // no semi trans at all?
\r
735 {glDisable(GL_BLEND);bBlendEnable=FALSE;} // -> don't wanna blend
\r
736 ubGloAlpha=ubGloColAlpha=255; // -> full alpha
\r
737 return; // -> and bye
\r
740 ubGloAlpha=ubGloColAlpha=TransSets[GlobalTextABR].alpha;
\r
743 {glEnable(GL_BLEND);bBlendEnable=TRUE;} // wanna blend
\r
745 if(TransSets[GlobalTextABR].srcFac!=obm1 ||
\r
746 TransSets[GlobalTextABR].dstFac!=obm2)
\r
748 //if(glBlendEquationEXTEx==NULL)
\r
750 obm1=TransSets[GlobalTextABR].srcFac;
\r
751 obm2=TransSets[GlobalTextABR].dstFac;
\r
752 glBlendFunc(obm1,obm2); // set blend func
\r
755 if(TransSets[GlobalTextABR].dstFac !=GL_ONE_MINUS_SRC_COLOR)
\r
757 if(obm2==GL_ONE_MINUS_SRC_COLOR)
\r
758 glBlendEquationEXTEx(FUNC_ADD_EXT);
\r
759 obm1=TransSets[GlobalTextABR].srcFac;
\r
760 obm2=TransSets[GlobalTextABR].dstFac;
\r
761 glBlendFunc(obm1,obm2); // set blend func
\r
765 glBlendEquationEXTEx(FUNC_REVERSESUBTRACT_EXT);
\r
766 obm1=TransSets[GlobalTextABR].srcFac;
\r
767 obm2=TransSets[GlobalTextABR].dstFac;
\r
768 glBlendFunc(GL_ONE,GL_ONE); // set blend func
\r
773 void SetScanTrans(void) // blending for scan lines
\r
775 /* if(glBlendEquationEXTEx!=NULL)
\r
777 if(obm2==GL_ONE_MINUS_SRC_COLOR)
\r
778 glBlendEquationEXTEx(FUNC_ADD_EXT);
\r
781 obm1=TransSets[0].srcFac;
\r
782 obm2=TransSets[0].dstFac;
\r
783 glBlendFunc(obm1,obm2); // set blend func
\r
786 void SetScanTexTrans(void) // blending for scan mask texture
\r
788 /* if(glBlendEquationEXTEx!=NULL)
\r
790 if(obm2==GL_ONE_MINUS_SRC_COLOR)
\r
791 glBlendEquationEXTEx(FUNC_ADD_EXT);
\r
794 obm1=TransSets[2].srcFac;
\r
795 obm2=TransSets[2].dstFac;
\r
796 glBlendFunc(obm1,obm2); // set blend func
\r
799 ////////////////////////////////////////////////////////////////////////
\r
800 // multi pass in old 'Advanced blending' mode... got it from Lewpy :)
\r
801 ////////////////////////////////////////////////////////////////////////
\r
803 SemiTransParams MultiTexTransSets[4][2]=
\r
806 {GL_ONE ,GL_SRC_ALPHA, 127},
\r
807 {GL_SRC_ALPHA,GL_ONE, 127}
\r
810 {GL_ONE, GL_SRC_ALPHA, 255},
\r
811 {GL_SRC_ALPHA,GL_ONE, 255}
\r
814 {GL_ZERO, GL_ONE_MINUS_SRC_COLOR,255},
\r
815 {GL_ZERO, GL_ONE_MINUS_SRC_COLOR,255}
\r
818 {GL_SRC_ALPHA,GL_ONE, 127},
\r
819 {GL_ONE_MINUS_SRC_ALPHA,GL_ONE, 255}
\r
823 ////////////////////////////////////////////////////////////////////////
\r
825 SemiTransParams MultiColTransSets[4]=
\r
827 {GL_ONE_MINUS_SRC_ALPHA,GL_SRC_ALPHA,127},
\r
828 {GL_ONE, GL_ONE, 255},
\r
829 {GL_ZERO, GL_ONE_MINUS_SRC_COLOR,255},
\r
830 {GL_SRC_ALPHA,GL_ONE, 127}
\r
833 ////////////////////////////////////////////////////////////////////////
\r
835 void SetSemiTransMulti(int Pass)
\r
837 static GLenum bm1=GL_ZERO;
\r
838 static GLenum bm2=GL_ONE;
\r
843 // are we enabling SemiTransparent mode?
\r
848 bm1=MultiTexTransSets[GlobalTextABR][Pass].srcFac;
\r
849 bm2=MultiTexTransSets[GlobalTextABR][Pass].dstFac;
\r
850 ubGloAlpha=MultiTexTransSets[GlobalTextABR][Pass].alpha;
\r
855 bm1=MultiColTransSets[GlobalTextABR].srcFac;
\r
856 bm2=MultiColTransSets[GlobalTextABR].dstFac;
\r
857 ubGloColAlpha=MultiColTransSets[GlobalTextABR].alpha;
\r
865 // disable blending
\r
866 bm1=GL_ONE;bm2=GL_ZERO;
\r
870 // disable blending, but add src col a second time
\r
871 bm1=GL_ONE;bm2=GL_ONE;
\r
876 {glEnable(GL_BLEND);bBlendEnable=TRUE;} // wanna blend
\r
878 if(bm1!=obm1 || bm2!=obm2)
\r
880 glBlendFunc(bm1,bm2); // set blend func
\r
885 ////////////////////////////////////////////////////////////////////////
\r
886 // Set several rendering stuff including blending
\r
887 ////////////////////////////////////////////////////////////////////////
\r
889 __inline void SetZMask3O(void)
\r
891 if(iUseMask && DrawSemiTrans && !iSetMask)
\r
893 vertex[0].z=vertex[1].z=vertex[2].z=gl_z;
\r
898 __inline void SetZMask3(void)
\r
902 if(iSetMask || DrawSemiTrans)
\r
903 {vertex[0].z=vertex[1].z=vertex[2].z=0.95f;}
\r
906 vertex[0].z=vertex[1].z=vertex[2].z=gl_z;
\r
912 __inline void SetZMask3NT(void)
\r
917 {vertex[0].z=vertex[1].z=vertex[2].z=0.95f;}
\r
920 vertex[0].z=vertex[1].z=vertex[2].z=gl_z;
\r
926 ////////////////////////////////////////////////////////////////////////
\r
928 __inline void SetZMask4O(void)
\r
930 if(iUseMask && DrawSemiTrans && !iSetMask)
\r
932 vertex[0].z=vertex[1].z=vertex[2].z=vertex[3].z=gl_z;
\r
937 __inline void SetZMask4(void)
\r
941 if(iSetMask || DrawSemiTrans)
\r
942 {vertex[0].z=vertex[1].z=vertex[2].z=vertex[3].z=0.95f;}
\r
945 vertex[0].z=vertex[1].z=vertex[2].z=vertex[3].z=gl_z;
\r
951 __inline void SetZMask4NT(void)
\r
956 {vertex[0].z=vertex[1].z=vertex[2].z=vertex[3].z=0.95f;}
\r
959 vertex[0].z=vertex[1].z=vertex[2].z=vertex[3].z=gl_z;
\r
965 __inline void SetZMask4SP(void)
\r
970 {vertex[0].z=vertex[1].z=vertex[2].z=vertex[3].z=0.95f;}
\r
975 vertex[0].z=vertex[1].z=vertex[2].z=vertex[3].z=gl_z;
\r
979 {vertex[0].z=vertex[1].z=vertex[2].z=vertex[3].z=0.95f;}
\r
984 ////////////////////////////////////////////////////////////////////////
\r
986 __inline void SetRenderState(unsigned long DrawAttributes)
\r
988 bDrawNonShaded = (SHADETEXBIT(DrawAttributes)) ? TRUE : FALSE;
\r
989 DrawSemiTrans = (SEMITRANSBIT(DrawAttributes)) ? TRUE : FALSE;
\r
992 ////////////////////////////////////////////////////////////////////////
\r
994 __inline void SetRenderColor(unsigned long DrawAttributes)
\r
996 if(bDrawNonShaded) {g_m1=g_m2=g_m3=128;}
\r
999 g_m1=DrawAttributes&0xff;
\r
1000 g_m2=(DrawAttributes>>8)&0xff;
\r
1001 g_m3=(DrawAttributes>>16)&0xff;
\r
1005 ////////////////////////////////////////////////////////////////////////
\r
1007 void SetRenderMode(unsigned long DrawAttributes,BOOL bSCol)
\r
1009 if((bUseMultiPass) && (bDrawTextured) && !(bDrawNonShaded))
\r
1010 {bDrawMultiPass = TRUE; SetSemiTransMulti(0);}
\r
1011 else {bDrawMultiPass = FALSE;SetSemiTrans();}
\r
1013 if(bDrawTextured) // texture ? build it/get it from cache
\r
1016 if(bUsingTWin) currTex=LoadTextureWnd(GlobalTexturePage,GlobalTextTP, ulClutID);
\r
1017 else if(bUsingMovie) currTex=LoadTextureMovie();
\r
1018 else currTex=SelectSubTextureS(GlobalTextTP,ulClutID);
\r
1020 if(gTexName!=currTex)
\r
1021 {gTexName=currTex;glBindTexture(GL_TEXTURE_2D,currTex);}
\r
1023 if(!bTexEnabled) // -> turn texturing on
\r
1024 {bTexEnabled=TRUE;glEnable(GL_TEXTURE_2D);}
\r
1026 else // no texture ?
\r
1028 {bTexEnabled=FALSE;glDisable(GL_TEXTURE_2D);} // -> turn texturing off
\r
1030 if(bSCol) // also set color ?
\r
1032 if((dwActFixes&4) && ((DrawAttributes&0x00ffffff)==0))
\r
1033 DrawAttributes|=0x007f7f7f;
\r
1035 if(bDrawNonShaded) // -> non shaded?
\r
1037 /* if(bGLBlend) vertex[0].c.lcol=0x7f7f7f; // --> solid color...
\r
1038 else */vertex[0].c.lcol=0xffffff;
\r
1040 else // -> shaded?
\r
1042 // if(!bUseMultiPass && !bGLBlend) // --> given color...
\r
1043 vertex[0].c.lcol=DoubleBGR2RGB(DrawAttributes);
\r
1044 // else vertex[0].c.lcol=DrawAttributes;
\r
1046 vertex[0].c.col[3]=ubGloAlpha; // -> set color with
\r
1047 SETCOL(vertex[0]); // texture alpha
\r
1050 if(bDrawSmoothShaded!=bOldSmoothShaded) // shading changed?
\r
1052 if(bDrawSmoothShaded) glShadeModel(GL_SMOOTH); // -> set actual shading
\r
1053 else glShadeModel(GL_FLAT);
\r
1054 bOldSmoothShaded=bDrawSmoothShaded;
\r
1058 ////////////////////////////////////////////////////////////////////////
\r
1059 // Set Opaque multipass color
\r
1060 ////////////////////////////////////////////////////////////////////////
\r
1062 void SetOpaqueColor(unsigned long DrawAttributes)
\r
1064 if(bDrawNonShaded) return; // no shading? bye
\r
1066 DrawAttributes=DoubleBGR2RGB(DrawAttributes); // multipass is just half color, so double it on opaque pass
\r
1067 vertex[0].c.lcol=DrawAttributes|0xff000000;
\r
1068 SETCOL(vertex[0]); // set color
\r
1071 ////////////////////////////////////////////////////////////////////////
\r
1072 // Fucking stupid screen coord checking
\r
1073 ////////////////////////////////////////////////////////////////////////
\r
1075 BOOL ClipVertexListScreen(void)
\r
1077 if (lx0 >= PSXDisplay.DisplayEnd.x) goto NEXTSCRTEST;
\r
1078 if (ly0 >= PSXDisplay.DisplayEnd.y) goto NEXTSCRTEST;
\r
1079 if (lx2 < PSXDisplay.DisplayPosition.x) goto NEXTSCRTEST;
\r
1080 if (ly2 < PSXDisplay.DisplayPosition.y) goto NEXTSCRTEST;
\r
1085 if(PSXDisplay.InterlacedTest) return FALSE;
\r
1087 if (lx0 >= PreviousPSXDisplay.DisplayEnd.x) return FALSE;
\r
1088 if (ly0 >= PreviousPSXDisplay.DisplayEnd.y) return FALSE;
\r
1089 if (lx2 < PreviousPSXDisplay.DisplayPosition.x) return FALSE;
\r
1090 if (ly2 < PreviousPSXDisplay.DisplayPosition.y) return FALSE;
\r
1095 ////////////////////////////////////////////////////////////////////////
\r
1097 BOOL bDrawOffscreenFront(void)
\r
1099 if(sxmin < PSXDisplay.DisplayPosition.x) return FALSE; // must be complete in front
\r
1100 if(symin < PSXDisplay.DisplayPosition.y) return FALSE;
\r
1101 if(sxmax > PSXDisplay.DisplayEnd.x) return FALSE;
\r
1102 if(symax > PSXDisplay.DisplayEnd.y) return FALSE;
\r
1106 BOOL bOnePointInFront(void)
\r
1108 if(sxmax< PSXDisplay.DisplayPosition.x)
\r
1111 if(symax< PSXDisplay.DisplayPosition.y)
\r
1114 if(sxmin>=PSXDisplay.DisplayEnd.x)
\r
1117 if(symin>=PSXDisplay.DisplayEnd.y)
\r
1124 BOOL bOnePointInBack(void)
\r
1126 if(sxmax< PreviousPSXDisplay.DisplayPosition.x)
\r
1129 if(symax< PreviousPSXDisplay.DisplayPosition.y)
\r
1132 if(sxmin>=PreviousPSXDisplay.DisplayEnd.x)
\r
1135 if(symin>=PreviousPSXDisplay.DisplayEnd.y)
\r
1141 BOOL bDrawOffscreen4(void)
\r
1143 BOOL bFront;short sW,sH;
\r
1145 sxmax=max(lx0,max(lx1,max(lx2,lx3)));
\r
1146 if(sxmax<drawX) return FALSE;
\r
1147 sxmin=min(lx0,min(lx1,min(lx2,lx3)));
\r
1148 if(sxmin>drawW) return FALSE;
\r
1149 symax=max(ly0,max(ly1,max(ly2,ly3)));
\r
1150 if(symax<drawY) return FALSE;
\r
1151 symin=min(ly0,min(ly1,min(ly2,ly3)));
\r
1152 if(symin>drawH) return FALSE;
\r
1154 if(PSXDisplay.Disabled) return TRUE; // disabled? ever
\r
1156 if(iOffscreenDrawing==1) return bFullVRam;
\r
1158 if(dwActFixes&1 && iOffscreenDrawing==4)
\r
1160 if(PreviousPSXDisplay.DisplayPosition.x==PSXDisplay.DisplayPosition.x &&
\r
1161 PreviousPSXDisplay.DisplayPosition.y==PSXDisplay.DisplayPosition.y &&
\r
1162 PreviousPSXDisplay.DisplayEnd.x==PSXDisplay.DisplayEnd.x &&
\r
1163 PreviousPSXDisplay.DisplayEnd.y==PSXDisplay.DisplayEnd.y)
\r
1165 bRenderFrontBuffer=TRUE;
\r
1170 sW=drawW-1;sH=drawH-1;
\r
1172 sxmin=min(sW,max(sxmin,drawX));
\r
1173 sxmax=max(drawX,min(sxmax,sW));
\r
1174 symin=min(sH,max(symin,drawY));
\r
1175 symax=max(drawY,min(symax,sH));
\r
1177 if(bOnePointInBack()) return bFullVRam;
\r
1179 if(iOffscreenDrawing==2)
\r
1180 bFront=bDrawOffscreenFront();
\r
1181 else bFront=bOnePointInFront();
\r
1185 if(PSXDisplay.InterlacedTest) return bFullVRam; // -> ok, no need for adjust
\r
1187 vertex[0].x=lx0 - PSXDisplay.DisplayPosition.x+PreviousPSXDisplay.Range.x0;
\r
1188 vertex[1].x=lx1 - PSXDisplay.DisplayPosition.x+PreviousPSXDisplay.Range.x0;
\r
1189 vertex[2].x=lx2 - PSXDisplay.DisplayPosition.x+PreviousPSXDisplay.Range.x0;
\r
1190 vertex[3].x=lx3 - PSXDisplay.DisplayPosition.x+PreviousPSXDisplay.Range.x0;
\r
1191 vertex[0].y=ly0 - PSXDisplay.DisplayPosition.y+PreviousPSXDisplay.Range.y0;
\r
1192 vertex[1].y=ly1 - PSXDisplay.DisplayPosition.y+PreviousPSXDisplay.Range.y0;
\r
1193 vertex[2].y=ly2 - PSXDisplay.DisplayPosition.y+PreviousPSXDisplay.Range.y0;
\r
1194 vertex[3].y=ly3 - PSXDisplay.DisplayPosition.y+PreviousPSXDisplay.Range.y0;
\r
1196 if(iOffscreenDrawing==4 && !(dwActFixes&1)) // -> frontbuffer wanted
\r
1198 bRenderFrontBuffer=TRUE;
\r
1201 return bFullVRam; // -> but no od
\r
1207 ////////////////////////////////////////////////////////////////////////
\r
1209 BOOL bDrawOffscreen3(void)
\r
1211 BOOL bFront;short sW,sH;
\r
1213 sxmax=max(lx0,max(lx1,lx2));
\r
1214 if(sxmax<drawX) return FALSE;
\r
1215 sxmin=min(lx0,min(lx1,lx2));
\r
1216 if(sxmin>drawW) return FALSE;
\r
1217 symax=max(ly0,max(ly1,ly2));
\r
1218 if(symax<drawY) return FALSE;
\r
1219 symin=min(ly0,min(ly1,ly2));
\r
1220 if(symin>drawH) return FALSE;
\r
1222 if(PSXDisplay.Disabled) return TRUE; // disabled? ever
\r
1224 if(iOffscreenDrawing==1) return bFullVRam;
\r
1226 sW=drawW-1;sH=drawH-1;
\r
1227 sxmin=min(sW,max(sxmin,drawX));
\r
1228 sxmax=max(drawX,min(sxmax,sW));
\r
1229 symin=min(sH,max(symin,drawY));
\r
1230 symax=max(drawY,min(symax,sH));
\r
1232 if(bOnePointInBack()) return bFullVRam;
\r
1234 if(iOffscreenDrawing==2)
\r
1235 bFront=bDrawOffscreenFront();
\r
1236 else bFront=bOnePointInFront();
\r
1240 if(PSXDisplay.InterlacedTest) return bFullVRam; // -> ok, no need for adjust
\r
1242 vertex[0].x=lx0 - PSXDisplay.DisplayPosition.x+PreviousPSXDisplay.Range.x0;
\r
1243 vertex[1].x=lx1 - PSXDisplay.DisplayPosition.x+PreviousPSXDisplay.Range.x0;
\r
1244 vertex[2].x=lx2 - PSXDisplay.DisplayPosition.x+PreviousPSXDisplay.Range.x0;
\r
1245 vertex[0].y=ly0 - PSXDisplay.DisplayPosition.y+PreviousPSXDisplay.Range.y0;
\r
1246 vertex[1].y=ly1 - PSXDisplay.DisplayPosition.y+PreviousPSXDisplay.Range.y0;
\r
1247 vertex[2].y=ly2 - PSXDisplay.DisplayPosition.y+PreviousPSXDisplay.Range.y0;
\r
1249 if(iOffscreenDrawing==4) // -> frontbuffer wanted
\r
1251 bRenderFrontBuffer=TRUE;
\r
1255 return bFullVRam; // -> but no od
\r
1261 ////////////////////////////////////////////////////////////////////////
\r
1263 BOOL FastCheckAgainstScreen(short imageX0,short imageY0,short imageX1,short imageY1)
\r
1265 PSXRect_t xUploadArea;
\r
1267 imageX1 += imageX0;
\r
1268 imageY1 += imageY0;
\r
1270 if (imageX0 < PreviousPSXDisplay.DisplayPosition.x)
\r
1271 xUploadArea.x0 = PreviousPSXDisplay.DisplayPosition.x;
\r
1273 if (imageX0 > PreviousPSXDisplay.DisplayEnd.x)
\r
1274 xUploadArea.x0 = PreviousPSXDisplay.DisplayEnd.x;
\r
1276 xUploadArea.x0 = imageX0;
\r
1278 if(imageX1 < PreviousPSXDisplay.DisplayPosition.x)
\r
1279 xUploadArea.x1 = PreviousPSXDisplay.DisplayPosition.x;
\r
1281 if (imageX1 > PreviousPSXDisplay.DisplayEnd.x)
\r
1282 xUploadArea.x1 = PreviousPSXDisplay.DisplayEnd.x;
\r
1284 xUploadArea.x1 = imageX1;
\r
1286 if (imageY0 < PreviousPSXDisplay.DisplayPosition.y)
\r
1287 xUploadArea.y0 = PreviousPSXDisplay.DisplayPosition.y;
\r
1289 if (imageY0 > PreviousPSXDisplay.DisplayEnd.y)
\r
1290 xUploadArea.y0 = PreviousPSXDisplay.DisplayEnd.y;
\r
1292 xUploadArea.y0 = imageY0;
\r
1294 if (imageY1 < PreviousPSXDisplay.DisplayPosition.y)
\r
1295 xUploadArea.y1 = PreviousPSXDisplay.DisplayPosition.y;
\r
1297 if (imageY1 > PreviousPSXDisplay.DisplayEnd.y)
\r
1298 xUploadArea.y1 = PreviousPSXDisplay.DisplayEnd.y;
\r
1300 xUploadArea.y1 = imageY1;
\r
1302 if ((xUploadArea.x0 != xUploadArea.x1) && (xUploadArea.y0 != xUploadArea.y1))
\r
1304 else return FALSE;
\r
1307 BOOL CheckAgainstScreen(short imageX0,short imageY0,short imageX1,short imageY1)
\r
1309 imageX1 += imageX0;
\r
1310 imageY1 += imageY0;
\r
1312 if (imageX0 < PreviousPSXDisplay.DisplayPosition.x)
\r
1313 xrUploadArea.x0 = PreviousPSXDisplay.DisplayPosition.x;
\r
1315 if (imageX0 > PreviousPSXDisplay.DisplayEnd.x)
\r
1316 xrUploadArea.x0 = PreviousPSXDisplay.DisplayEnd.x;
\r
1318 xrUploadArea.x0 = imageX0;
\r
1320 if(imageX1 < PreviousPSXDisplay.DisplayPosition.x)
\r
1321 xrUploadArea.x1 = PreviousPSXDisplay.DisplayPosition.x;
\r
1323 if (imageX1 > PreviousPSXDisplay.DisplayEnd.x)
\r
1324 xrUploadArea.x1 = PreviousPSXDisplay.DisplayEnd.x;
\r
1326 xrUploadArea.x1 = imageX1;
\r
1328 if (imageY0 < PreviousPSXDisplay.DisplayPosition.y)
\r
1329 xrUploadArea.y0 = PreviousPSXDisplay.DisplayPosition.y;
\r
1331 if (imageY0 > PreviousPSXDisplay.DisplayEnd.y)
\r
1332 xrUploadArea.y0 = PreviousPSXDisplay.DisplayEnd.y;
\r
1334 xrUploadArea.y0 = imageY0;
\r
1336 if (imageY1 < PreviousPSXDisplay.DisplayPosition.y)
\r
1337 xrUploadArea.y1 = PreviousPSXDisplay.DisplayPosition.y;
\r
1339 if (imageY1 > PreviousPSXDisplay.DisplayEnd.y)
\r
1340 xrUploadArea.y1 = PreviousPSXDisplay.DisplayEnd.y;
\r
1342 xrUploadArea.y1 = imageY1;
\r
1344 if ((xrUploadArea.x0 != xrUploadArea.x1) && (xrUploadArea.y0 != xrUploadArea.y1))
\r
1346 else return FALSE;
\r
1349 BOOL FastCheckAgainstFrontScreen(short imageX0,short imageY0,short imageX1,short imageY1)
\r
1351 PSXRect_t xUploadArea;
\r
1353 imageX1 += imageX0;
\r
1354 imageY1 += imageY0;
\r
1356 if (imageX0 < PSXDisplay.DisplayPosition.x)
\r
1357 xUploadArea.x0 = PSXDisplay.DisplayPosition.x;
\r
1359 if (imageX0 > PSXDisplay.DisplayEnd.x)
\r
1360 xUploadArea.x0 = PSXDisplay.DisplayEnd.x;
\r
1362 xUploadArea.x0 = imageX0;
\r
1364 if(imageX1 < PSXDisplay.DisplayPosition.x)
\r
1365 xUploadArea.x1 = PSXDisplay.DisplayPosition.x;
\r
1367 if (imageX1 > PSXDisplay.DisplayEnd.x)
\r
1368 xUploadArea.x1 = PSXDisplay.DisplayEnd.x;
\r
1370 xUploadArea.x1 = imageX1;
\r
1372 if (imageY0 < PSXDisplay.DisplayPosition.y)
\r
1373 xUploadArea.y0 = PSXDisplay.DisplayPosition.y;
\r
1375 if (imageY0 > PSXDisplay.DisplayEnd.y)
\r
1376 xUploadArea.y0 = PSXDisplay.DisplayEnd.y;
\r
1378 xUploadArea.y0 = imageY0;
\r
1380 if (imageY1 < PSXDisplay.DisplayPosition.y)
\r
1381 xUploadArea.y1 = PSXDisplay.DisplayPosition.y;
\r
1383 if (imageY1 > PSXDisplay.DisplayEnd.y)
\r
1384 xUploadArea.y1 = PSXDisplay.DisplayEnd.y;
\r
1386 xUploadArea.y1 = imageY1;
\r
1388 if ((xUploadArea.x0 != xUploadArea.x1) && (xUploadArea.y0 != xUploadArea.y1))
\r
1390 else return FALSE;
\r
1393 BOOL CheckAgainstFrontScreen(short imageX0,short imageY0,short imageX1,short imageY1)
\r
1395 imageX1 += imageX0;
\r
1396 imageY1 += imageY0;
\r
1398 if (imageX0 < PSXDisplay.DisplayPosition.x)
\r
1399 xrUploadArea.x0 = PSXDisplay.DisplayPosition.x;
\r
1401 if (imageX0 > PSXDisplay.DisplayEnd.x)
\r
1402 xrUploadArea.x0 = PSXDisplay.DisplayEnd.x;
\r
1404 xrUploadArea.x0 = imageX0;
\r
1406 if(imageX1 < PSXDisplay.DisplayPosition.x)
\r
1407 xrUploadArea.x1 = PSXDisplay.DisplayPosition.x;
\r
1409 if (imageX1 > PSXDisplay.DisplayEnd.x)
\r
1410 xrUploadArea.x1 = PSXDisplay.DisplayEnd.x;
\r
1412 xrUploadArea.x1 = imageX1;
\r
1414 if (imageY0 < PSXDisplay.DisplayPosition.y)
\r
1415 xrUploadArea.y0 = PSXDisplay.DisplayPosition.y;
\r
1417 if (imageY0 > PSXDisplay.DisplayEnd.y)
\r
1418 xrUploadArea.y0 = PSXDisplay.DisplayEnd.y;
\r
1420 xrUploadArea.y0 = imageY0;
\r
1422 if (imageY1 < PSXDisplay.DisplayPosition.y)
\r
1423 xrUploadArea.y1 = PSXDisplay.DisplayPosition.y;
\r
1425 if (imageY1 > PSXDisplay.DisplayEnd.y)
\r
1426 xrUploadArea.y1 = PSXDisplay.DisplayEnd.y;
\r
1428 xrUploadArea.y1 = imageY1;
\r
1430 if ((xrUploadArea.x0 != xrUploadArea.x1) && (xrUploadArea.y0 != xrUploadArea.y1))
\r
1432 else return FALSE;
\r
1435 ////////////////////////////////////////////////////////////////////////
\r
1437 void PrepareFullScreenUpload (long Position)
\r
1439 if (Position==-1) // rgb24
\r
1441 if(PSXDisplay.Interlaced)
\r
1443 xrUploadArea.x0 = PSXDisplay.DisplayPosition.x;
\r
1444 xrUploadArea.x1 = PSXDisplay.DisplayEnd.x;
\r
1445 xrUploadArea.y0 = PSXDisplay.DisplayPosition.y;
\r
1446 xrUploadArea.y1 = PSXDisplay.DisplayEnd.y;
\r
1450 xrUploadArea.x0 = PreviousPSXDisplay.DisplayPosition.x;
\r
1451 xrUploadArea.x1 = PreviousPSXDisplay.DisplayEnd.x;
\r
1452 xrUploadArea.y0 = PreviousPSXDisplay.DisplayPosition.y;
\r
1453 xrUploadArea.y1 = PreviousPSXDisplay.DisplayEnd.y;
\r
1456 if(bNeedRGB24Update)
\r
1460 // lClearOnSwap=0;
\r
1463 if(PSXDisplay.Interlaced && PreviousPSXDisplay.RGB24<2) // in interlaced mode we upload at least two full frames (GT1 menu)
\r
1465 PreviousPSXDisplay.RGB24++;
\r
1469 xrUploadArea.y1 = min(xrUploadArea.y0+xrUploadAreaRGB24.y1,xrUploadArea.y1);
\r
1470 xrUploadArea.y0+=xrUploadAreaRGB24.y0;
\r
1477 xrUploadArea.x0 = PSXDisplay.DisplayPosition.x;
\r
1478 xrUploadArea.x1 = PSXDisplay.DisplayEnd.x;
\r
1479 xrUploadArea.y0 = PSXDisplay.DisplayPosition.y;
\r
1480 xrUploadArea.y1 = PSXDisplay.DisplayEnd.y;
\r
1484 xrUploadArea.x0 = PreviousPSXDisplay.DisplayPosition.x;
\r
1485 xrUploadArea.x1 = PreviousPSXDisplay.DisplayEnd.x;
\r
1486 xrUploadArea.y0 = PreviousPSXDisplay.DisplayPosition.y;
\r
1487 xrUploadArea.y1 = PreviousPSXDisplay.DisplayEnd.y;
\r
1490 if (xrUploadArea.x0 < 0) xrUploadArea.x0 = 0;
\r
1492 if (xrUploadArea.x0 > 1023) xrUploadArea.x0 = 1023;
\r
1494 if (xrUploadArea.x1 < 0) xrUploadArea.x1 = 0;
\r
1496 if (xrUploadArea.x1 > 1024) xrUploadArea.x1 = 1024;
\r
1498 if (xrUploadArea.y0 < 0) xrUploadArea.y0 = 0;
\r
1500 if (xrUploadArea.y0 > iGPUHeightMask) xrUploadArea.y0 = iGPUHeightMask;
\r
1502 if (xrUploadArea.y1 < 0) xrUploadArea.y1 = 0;
\r
1504 if (xrUploadArea.y1 > iGPUHeight) xrUploadArea.y1 = iGPUHeight;
\r
1506 if (PSXDisplay.RGB24)
\r
1508 InvalidateTextureArea(xrUploadArea.x0,xrUploadArea.y0,xrUploadArea.x1-xrUploadArea.x0,xrUploadArea.y1-xrUploadArea.y0);
\r
1512 ////////////////////////////////////////////////////////////////////////
\r
1513 // Upload screen (MDEC and such)
\r
1514 ////////////////////////////////////////////////////////////////////////
\r
1515 ////////////////////////////////////////////////////////////////////////
\r
1517 u8 * LoadDirectMovieFast(void);
\r
1519 void UploadScreenEx(long Position)
\r
1521 short ya,yb,xa,xb,x, y, YStep, XStep, U, UStep,ux[4],vy[4];
\r
1523 if(!PSXDisplay.DisplayMode.x) return;
\r
1524 if(!PSXDisplay.DisplayMode.y) return;
\r
1526 glDisable(GL_SCISSOR_TEST);
\r
1527 glShadeModel(GL_FLAT);
\r
1528 bOldSmoothShaded=FALSE;
\r
1529 glDisable(GL_BLEND);
\r
1530 bBlendEnable=FALSE;
\r
1531 glDisable(GL_TEXTURE_2D);
\r
1532 bTexEnabled=FALSE;
\r
1533 glDisable(GL_ALPHA_TEST);
\r
1535 //glPixelZoom(((float)rRatioRect.right)/((float)PSXDisplay.DisplayMode.x),
\r
1536 // -1.0f*(((float)rRatioRect.bottom)/((float)PSXDisplay.DisplayMode.y)));
\r
1538 //----------------------------------------------------//
\r
1540 YStep = 256; // max texture size
\r
1542 UStep = (PSXDisplay.RGB24 ? 128 : 0);
\r
1543 ya = xrUploadArea.y0;
\r
1544 yb = xrUploadArea.y1;
\r
1545 xa = xrUploadArea.x0;
\r
1546 xb = xrUploadArea.x1;
\r
1548 for(y=ya;y<=yb;y+=YStep) // loop y
\r
1551 for(x=xa;x<=xb;x+=XStep) // loop x
\r
1553 ly0 = ly1 = y; // -> get y coords
\r
1555 if (ly2 > yb) ly2 = yb;
\r
1558 lx0 = lx3 = x; // -> get x coords
\r
1560 if (lx1 > xb) lx1 = xb;
\r
1564 ux[0]=ux[3]=(xa - x); // -> set tex x coords
\r
1565 if (ux[0] < 0) ux[0]=ux[3]=0;
\r
1566 ux[2]=ux[1]=(xb - x);
\r
1567 if (ux[2] > 256) ux[2]=ux[1]=256;
\r
1569 vy[0]=vy[1]=(ya - y); // -> set tex y coords
\r
1570 if (vy[0] < 0) vy[0]=vy[1]=0;
\r
1571 vy[2]=vy[3]=(yb - y);
\r
1572 if (vy[2] > 256) vy[2]=vy[3]=256;
\r
1574 if ((ux[0] >= ux[2]) || // -> cheaters never win...
\r
1575 (vy[0] >= vy[2])) continue; // (but winners always cheat...)
\r
1577 xrMovieArea.x0=lx0+U; xrMovieArea.y0=ly0;
\r
1578 xrMovieArea.x1=lx2+U; xrMovieArea.y1=ly2;
\r
1580 offsetScreenUpload(Position);
\r
1582 //glRasterPos2f(vertex[0].x,vertex[0].y);
\r
1584 //glDrawPixels(xrMovieArea.x1-xrMovieArea.x0,
\r
1585 // xrMovieArea.y1-xrMovieArea.y0,
\r
1586 // GL_RGBA,GL_UNSIGNED_BYTE,
\r
1587 LoadDirectMovieFast();//);
\r
1593 //----------------------------------------------------//
\r
1595 // glPixelZoom(1.0F,1.0F);
\r
1597 glEnable(GL_ALPHA_TEST);
\r
1598 glEnable(GL_SCISSOR_TEST);
\r
1601 ////////////////////////////////////////////////////////////////////////
\r
1603 void UploadScreen(long Position)
\r
1605 short x, y, YStep, XStep, U, s, UStep,ux[4],vy[4];
\r
1606 short xa,xb,ya,yb;
\r
1608 if(xrUploadArea.x0>1023) xrUploadArea.x0=1023;
\r
1609 if(xrUploadArea.x1>1024) xrUploadArea.x1=1024;
\r
1610 if(xrUploadArea.y0>iGPUHeightMask) xrUploadArea.y0=iGPUHeightMask;
\r
1611 if(xrUploadArea.y1>iGPUHeight) xrUploadArea.y1=iGPUHeight;
\r
1613 if(xrUploadArea.x0==xrUploadArea.x1) return;
\r
1614 if(xrUploadArea.y0==xrUploadArea.y1) return;
\r
1616 if(PSXDisplay.Disabled && iOffscreenDrawing<4) return;
\r
1618 iDrawnSomething = 2;
\r
1619 iLastRGB24=PSXDisplay.RGB24+1;
\r
1621 if(bSkipNextFrame) return;
\r
1623 if(dwActFixes & 2) {UploadScreenEx(Position);return;}
\r
1625 bUsingMovie = TRUE;
\r
1626 bDrawTextured = TRUE; // just doing textures
\r
1627 bDrawSmoothShaded = FALSE;
\r
1629 /* if(bGLBlend) vertex[0].c.lcol=0xff7f7f7f; // set solid col
\r
1630 else */vertex[0].c.lcol=0xffffffff;
\r
1631 SETCOL(vertex[0]);
\r
1633 SetOGLDisplaySettings(0);
\r
1635 YStep = 256; // max texture size
\r
1638 UStep = (PSXDisplay.RGB24 ? 128 : 0);
\r
1640 ya=xrUploadArea.y0;
\r
1641 yb=xrUploadArea.y1;
\r
1642 xa=xrUploadArea.x0;
\r
1643 xb=xrUploadArea.x1;
\r
1645 for(y=ya;y<=yb;y+=YStep) // loop y
\r
1648 for(x=xa;x<=xb;x+=XStep) // loop x
\r
1650 ly0 = ly1 = y; // -> get y coords
\r
1652 if (ly2 > yb) ly2 = yb;
\r
1655 lx0 = lx3 = x; // -> get x coords
\r
1657 if (lx1 > xb) lx1 = xb;
\r
1661 ux[0]=ux[3]=(xa - x); // -> set tex x coords
\r
1662 if (ux[0] < 0) ux[0]=ux[3]=0;
\r
1663 ux[2]=ux[1]=(xb - x);
\r
1664 if (ux[2] > 256) ux[2]=ux[1]=256;
\r
1666 vy[0]=vy[1]=(ya - y); // -> set tex y coords
\r
1667 if (vy[0] < 0) vy[0]=vy[1]=0;
\r
1668 vy[2]=vy[3]=(yb - y);
\r
1669 if (vy[2] > 256) vy[2]=vy[3]=256;
\r
1671 if ((ux[0] >= ux[2]) || // -> cheaters never win...
\r
1672 (vy[0] >= vy[2])) continue; // (but winners always cheat...)
\r
1674 xrMovieArea.x0=lx0+U; xrMovieArea.y0=ly0;
\r
1675 xrMovieArea.x1=lx2+U; xrMovieArea.y1=ly2;
\r
1677 s=ux[2] - ux[0]; if(s>255) s=255;
\r
1679 gl_ux[2] = gl_ux[1] = s;
\r
1680 s=vy[2] - vy[0]; if(s>255) s=255;
\r
1681 gl_vy[2] = gl_vy[3] = s;
\r
1682 gl_ux[0] = gl_ux[3] = gl_vy[0] = gl_vy[1] = 0;
\r
1684 SetRenderState((unsigned long)0x01000000);
\r
1685 SetRenderMode((unsigned long)0x01000000, FALSE); // upload texture data
\r
1686 offsetScreenUpload(Position);
\r
1687 assignTextureVRAMWrite();
\r
1689 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
1695 bUsingMovie=FALSE; // done...
\r
1696 bDisplayNotSet = TRUE;
\r
1699 ////////////////////////////////////////////////////////////////////////
\r
1700 // Detect next screen
\r
1701 ////////////////////////////////////////////////////////////////////////
\r
1703 BOOL IsCompleteInsideNextScreen(short x, short y, short xoff, short yoff)
\r
1705 if (x > PSXDisplay.DisplayPosition.x+1) return FALSE;
\r
1706 if ((x + xoff) < PSXDisplay.DisplayEnd.x-1) return FALSE;
\r
1708 if (y >= PSXDisplay.DisplayPosition.y &&
\r
1709 y <= PSXDisplay.DisplayEnd.y )
\r
1711 if ((yoff) >= PSXDisplay.DisplayPosition.y &&
\r
1712 (yoff) <= PSXDisplay.DisplayEnd.y ) return TRUE;
\r
1714 if (y > PSXDisplay.DisplayPosition.y+1) return FALSE;
\r
1715 if (yoff < PSXDisplay.DisplayEnd.y-1) return FALSE;
\r
1719 BOOL IsPrimCompleteInsideNextScreen(short x, short y, short xoff, short yoff)
\r
1721 x+=PSXDisplay.DrawOffset.x;
\r
1722 if (x > PSXDisplay.DisplayPosition.x+1) return FALSE;
\r
1723 y+=PSXDisplay.DrawOffset.y;
\r
1724 if (y > PSXDisplay.DisplayPosition.y+1) return FALSE;
\r
1725 xoff+=PSXDisplay.DrawOffset.x;
\r
1726 if (xoff < PSXDisplay.DisplayEnd.x-1) return FALSE;
\r
1727 yoff+=PSXDisplay.DrawOffset.y;
\r
1728 if (yoff < PSXDisplay.DisplayEnd.y-1) return FALSE;
\r
1732 BOOL IsInsideNextScreen(short x, short y, short xoff, short yoff)
\r
1734 if (x > PSXDisplay.DisplayEnd.x) return FALSE;
\r
1735 if (y > PSXDisplay.DisplayEnd.y) return FALSE;
\r
1736 if ((x + xoff) < PSXDisplay.DisplayPosition.x) return FALSE;
\r
1737 if ((y + yoff) < PSXDisplay.DisplayPosition.y) return FALSE;
\r
1741 ////////////////////////////////////////////////////////////////////////
\r
1743 ////////////////////////////////////////////////////////////////////////
\r
1745 //Mask1 Set mask bit while drawing. 1 = on
\r
1746 //Mask2 Do not draw to mask areas. 1= on
\r
1748 void cmdSTP(u8 * baseAddr)
\r
1750 unsigned long gdata = ((unsigned long*)baseAddr)[0];
\r
1752 STATUSREG&=~0x1800; // clear the necessary bits
\r
1753 STATUSREG|=((gdata & 0x03) << 11); // set the current bits
\r
1755 if(!iUseMask) return;
\r
1757 if(gdata&1) {sSetMask=0x8000;lSetMask=0x80008000;iSetMask=1;}
\r
1758 else {sSetMask=0; lSetMask=0; iSetMask=0;}
\r
1762 if(!(gdata&1)) iSetMask=2;
\r
1764 if(iDepthFunc==0) return;
\r
1766 glDepthFunc(GL_LESS);
\r
1771 if(iDepthFunc==1) return;
\r
1772 glDepthFunc(GL_ALWAYS);
\r
1777 ////////////////////////////////////////////////////////////////////////
\r
1778 // cmd: Set texture page infos
\r
1779 ////////////////////////////////////////////////////////////////////////
\r
1781 void cmdTexturePage(u8 * baseAddr)
\r
1783 unsigned long gdata = ((unsigned long*)baseAddr)[0];
\r
1784 UpdateGlobalTP((unsigned short)gdata);
\r
1785 GlobalTextREST = (gdata&0x00ffffff)>>9;
\r
1788 ////////////////////////////////////////////////////////////////////////
\r
1789 // cmd: turn on/off texture window
\r
1790 ////////////////////////////////////////////////////////////////////////
\r
1792 void cmdTextureWindow(u8 *baseAddr)
\r
1794 unsigned long gdata = ((unsigned long*)baseAddr)[0];
\r
1796 unsigned long YAlign,XAlign;
\r
1798 ulGPUInfoVals[INFO_TW]=gdata&0xFFFFF;
\r
1801 TWin.Position.y1 = 8; // xxxx1
\r
1802 else if (gdata & 0x040)
\r
1803 TWin.Position.y1 = 16; // xxx10
\r
1804 else if (gdata & 0x080)
\r
1805 TWin.Position.y1 = 32; // xx100
\r
1806 else if (gdata & 0x100)
\r
1807 TWin.Position.y1 = 64; // x1000
\r
1808 else if (gdata & 0x200)
\r
1809 TWin.Position.y1 = 128; // 10000
\r
1811 TWin.Position.y1 = 256; // 00000
\r
1813 // Texture window size is determined by the least bit set of the relevant 5 bits
\r
1815 if (gdata & 0x001)
\r
1816 TWin.Position.x1 = 8; // xxxx1
\r
1817 else if (gdata & 0x002)
\r
1818 TWin.Position.x1 = 16; // xxx10
\r
1819 else if (gdata & 0x004)
\r
1820 TWin.Position.x1 = 32; // xx100
\r
1821 else if (gdata & 0x008)
\r
1822 TWin.Position.x1 = 64; // x1000
\r
1823 else if (gdata & 0x010)
\r
1824 TWin.Position.x1 = 128; // 10000
\r
1826 TWin.Position.x1 = 256; // 00000
\r
1828 // Re-calculate the bit field, because we can't trust what is passed in the data
\r
1830 YAlign = (unsigned long)(32 - (TWin.Position.y1 >> 3));
\r
1831 XAlign = (unsigned long)(32 - (TWin.Position.x1 >> 3));
\r
1833 // Absolute position of the start of the texture window
\r
1835 TWin.Position.y0 = (short)(((gdata >> 15) & YAlign) << 3);
\r
1836 TWin.Position.x0 = (short)(((gdata >> 10) & XAlign) << 3);
\r
1838 if((TWin.Position.x0 == 0 && // tw turned off
\r
1839 TWin.Position.y0 == 0 &&
\r
1840 TWin.Position.x1 == 0 &&
\r
1841 TWin.Position.y1 == 0) ||
\r
1842 (TWin.Position.x1 == 256 &&
\r
1843 TWin.Position.y1 == 256))
\r
1845 bUsingTWin = FALSE; // -> just do it
\r
1848 TWin.UScaleFactor = 1.0f;
\r
1849 TWin.VScaleFactor = 1.0f;
\r
1851 TWin.UScaleFactor =
\r
1852 TWin.VScaleFactor = 1.0f/256.0f;
\r
1855 else // tw turned on
\r
1857 bUsingTWin = TRUE;
\r
1859 TWin.OPosition.y1 = TWin.Position.y1; // -> get psx sizes
\r
1860 TWin.OPosition.x1 = TWin.Position.x1;
\r
1862 if(TWin.Position.x1<=2) TWin.Position.x1=2; // -> set OGL sizes
\r
1864 if(TWin.Position.x1<=4) TWin.Position.x1=4;
\r
1866 if(TWin.Position.x1<=8) TWin.Position.x1=8;
\r
1868 if(TWin.Position.x1<=16) TWin.Position.x1=16;
\r
1870 if(TWin.Position.x1<=32) TWin.Position.x1=32;
\r
1872 if(TWin.Position.x1<=64) TWin.Position.x1=64;
\r
1874 if(TWin.Position.x1<=128) TWin.Position.x1=128;
\r
1876 if(TWin.Position.x1<=256) TWin.Position.x1=256;
\r
1878 if(TWin.Position.y1<=2) TWin.Position.y1=2;
\r
1880 if(TWin.Position.y1<=4) TWin.Position.y1=4;
\r
1882 if(TWin.Position.y1<=8) TWin.Position.y1=8;
\r
1884 if(TWin.Position.y1<=16) TWin.Position.y1=16;
\r
1886 if(TWin.Position.y1<=32) TWin.Position.y1=32;
\r
1888 if(TWin.Position.y1<=64) TWin.Position.y1=64;
\r
1890 if(TWin.Position.y1<=128) TWin.Position.y1=128;
\r
1892 if(TWin.Position.y1<=256) TWin.Position.y1=256;
\r
1895 TWin.UScaleFactor = (float)TWin.Position.x1;
\r
1896 TWin.VScaleFactor = (float)TWin.Position.y1;
\r
1898 TWin.UScaleFactor = ((float)TWin.Position.x1)/256.0f; // -> set scale factor
\r
1899 TWin.VScaleFactor = ((float)TWin.Position.y1)/256.0f;
\r
1904 ////////////////////////////////////////////////////////////////////////
\r
1905 // mmm, Lewpy uses that in TileS ... I don't ;)
\r
1906 ////////////////////////////////////////////////////////////////////////
\r
1909 void ClampToPSXDrawAreaOffset(short *x0, short *y0, short *x1, short *y1)
\r
1911 if (*x0 < PSXDisplay.DrawArea.x0)
\r
1913 *x1 -= (PSXDisplay.DrawArea.x0 - *x0);
\r
1914 *x0 = PSXDisplay.DrawArea.x0;
\r
1917 if (*x0 > PSXDisplay.DrawArea.x1)
\r
1919 *x0 = PSXDisplay.DrawArea.x1;
\r
1923 if (*y0 < PSXDisplay.DrawArea.y0)
\r
1925 *y1 -= (PSXDisplay.DrawArea.y0 - *y0);
\r
1926 *y0 = PSXDisplay.DrawArea.y0;
\r
1929 if (*y0 > PSXDisplay.DrawArea.y1)
\r
1931 *y0 = PSXDisplay.DrawArea.y1;
\r
1935 if (*x1 < 0) *x1 = 0;
\r
1937 if ((*x1 + *x0) > PSXDisplay.DrawArea.x1)
\r
1938 *x1 = (PSXDisplay.DrawArea.x1 - *x0 + 1);
\r
1940 if (*y1 < 0) *y1 = 0;
\r
1942 if ((*y1 + *y0) > PSXDisplay.DrawArea.y1)
\r
1943 *y1 = (PSXDisplay.DrawArea.y1 - *y0 + 1);
\r
1947 ////////////////////////////////////////////////////////////////////////
\r
1948 // Check draw area dimensions
\r
1949 ////////////////////////////////////////////////////////////////////////
\r
1951 void ClampToPSXScreen(short *x0, short *y0, short *x1, short *y1)
\r
1953 if (*x0 < 0) *x0 = 0;
\r
1955 if (*x0 > 1023) *x0 = 1023;
\r
1957 if (*x1 < 0) *x1 = 0;
\r
1959 if (*x1 > 1023) *x1 = 1023;
\r
1961 if (*y0 < 0) *y0 = 0;
\r
1963 if (*y0 > iGPUHeightMask) *y0 = iGPUHeightMask;
\r
1965 if (*y1 < 0) *y1 = 0;
\r
1967 if (*y1 > iGPUHeightMask) *y1 = iGPUHeightMask;
\r
1970 ////////////////////////////////////////////////////////////////////////
\r
1971 // Used in Load Image and Blk Fill
\r
1972 ////////////////////////////////////////////////////////////////////////
\r
1974 void ClampToPSXScreenOffset(short *x0, short *y0, short *x1, short *y1)
\r
1977 { *x1 += *x0; *x0 = 0; }
\r
1980 { *x0 = 1023; *x1 = 0; }
\r
1983 { *y1 += *y0; *y0 = 0; }
\r
1985 if (*y0 > iGPUHeightMask)
\r
1986 { *y0 = iGPUHeightMask; *y1 = 0; }
\r
1988 if (*x1 < 0) *x1 = 0;
\r
1990 if ((*x1 + *x0) > 1024) *x1 = (1024 - *x0);
\r
1992 if (*y1 < 0) *y1 = 0;
\r
1994 if ((*y1 + *y0) > iGPUHeight) *y1 = (iGPUHeight - *y0);
\r
1997 ////////////////////////////////////////////////////////////////////////
\r
1998 // cmd: start of drawing area... primitives will be clipped inside
\r
1999 ////////////////////////////////////////////////////////////////////////
\r
2001 void cmdDrawAreaStart(u8 * baseAddr)
\r
2003 unsigned long gdata = ((unsigned long*)baseAddr)[0];
\r
2005 drawX = gdata & 0x3ff; // for soft drawing
\r
2006 if(drawX>=1024) drawX=1023;
\r
2008 if(dwGPUVersion==2)
\r
2010 ulGPUInfoVals[INFO_DRAWSTART]=gdata&0x3FFFFF;
\r
2011 drawY = (gdata>>12)&0x3ff;
\r
2015 ulGPUInfoVals[INFO_DRAWSTART]=gdata&0xFFFFF;
\r
2016 drawY = (gdata>>10)&0x3ff;
\r
2019 if(drawY>=iGPUHeight) drawY=iGPUHeightMask;
\r
2021 PreviousPSXDisplay.DrawArea.y0=PSXDisplay.DrawArea.y0;
\r
2022 PreviousPSXDisplay.DrawArea.x0=PSXDisplay.DrawArea.x0;
\r
2024 PSXDisplay.DrawArea.y0 = (short)drawY; // for OGL drawing
\r
2025 PSXDisplay.DrawArea.x0 = (short)drawX;
\r
2028 ////////////////////////////////////////////////////////////////////////
\r
2029 // cmd: end of drawing area... primitives will be clipped inside
\r
2030 ////////////////////////////////////////////////////////////////////////
\r
2032 void cmdDrawAreaEnd(u8 * baseAddr)
\r
2034 unsigned long gdata = ((unsigned long*)baseAddr)[0];
\r
2036 drawW = gdata & 0x3ff; // for soft drawing
\r
2037 if(drawW>=1024) drawW=1023;
\r
2039 if(dwGPUVersion==2)
\r
2041 ulGPUInfoVals[INFO_DRAWEND]=gdata&0x3FFFFF;
\r
2042 drawH = (gdata>>12)&0x3ff;
\r
2046 ulGPUInfoVals[INFO_DRAWEND]=gdata&0xFFFFF;
\r
2047 drawH = (gdata>>10)&0x3ff;
\r
2050 if(drawH>=iGPUHeight) drawH=iGPUHeightMask;
\r
2052 PSXDisplay.DrawArea.y1 = (short)drawH; // for OGL drawing
\r
2053 PSXDisplay.DrawArea.x1 = (short)drawW;
\r
2055 ClampToPSXScreen(&PSXDisplay.DrawArea.x0, // clamp
\r
2056 &PSXDisplay.DrawArea.y0,
\r
2057 &PSXDisplay.DrawArea.x1,
\r
2058 &PSXDisplay.DrawArea.y1);
\r
2060 bDisplayNotSet = TRUE;
\r
2063 ////////////////////////////////////////////////////////////////////////
\r
2064 // cmd: draw offset... will be added to prim coords
\r
2065 ////////////////////////////////////////////////////////////////////////
\r
2067 void cmdDrawOffset(u8 * baseAddr)
\r
2069 unsigned long gdata = ((unsigned long*)baseAddr)[0];
\r
2071 PreviousPSXDisplay.DrawOffset.x =
\r
2072 PSXDisplay.DrawOffset.x = (short)(gdata & 0x7ff);
\r
2074 if(dwGPUVersion==2)
\r
2076 ulGPUInfoVals[INFO_DRAWOFF]=gdata&0x7FFFFF;
\r
2077 PSXDisplay.DrawOffset.y = (short)((gdata>>12) & 0x7ff);
\r
2081 ulGPUInfoVals[INFO_DRAWOFF]=gdata&0x3FFFFF;
\r
2082 PSXDisplay.DrawOffset.y = (short)((gdata>>11) & 0x7ff);
\r
2085 PSXDisplay.DrawOffset.x=(short)(((int)PSXDisplay.DrawOffset.x<<21)>>21);
\r
2086 PSXDisplay.DrawOffset.y=(short)(((int)PSXDisplay.DrawOffset.y<<21)>>21);
\r
2088 PSXDisplay.CumulOffset.x = // new OGL prim offsets
\r
2089 PSXDisplay.DrawOffset.x - PSXDisplay.GDrawOffset.x + PreviousPSXDisplay.Range.x0;
\r
2090 PSXDisplay.CumulOffset.y =
\r
2091 PSXDisplay.DrawOffset.y - PSXDisplay.GDrawOffset.y + PreviousPSXDisplay.Range.y0;
\r
2094 ////////////////////////////////////////////////////////////////////////
\r
2095 // cmd: load image to vram
\r
2096 ////////////////////////////////////////////////////////////////////////
\r
2098 void primLoadImage(u8 * baseAddr)
\r
2100 unsigned short *sgpuData = ((unsigned short *) baseAddr);
\r
2102 VRAMWrite.x = sgpuData[2]&0x03ff;
\r
2103 VRAMWrite.y = sgpuData[3]&iGPUHeightMask;
\r
2104 VRAMWrite.Width = sgpuData[4];
\r
2105 VRAMWrite.Height = sgpuData[5];
\r
2107 iDataWriteMode = DR_VRAMTRANSFER;
\r
2108 VRAMWrite.ImagePtr = psxVuw + (VRAMWrite.y<<10) + VRAMWrite.x;
\r
2109 VRAMWrite.RowsRemaining = VRAMWrite.Width;
\r
2110 VRAMWrite.ColsRemaining = VRAMWrite.Height;
\r
2112 bNeedWriteUpload=TRUE;
\r
2115 ////////////////////////////////////////////////////////////////////////
\r
2117 void PrepareRGB24Upload(void)
\r
2119 VRAMWrite.x=(VRAMWrite.x*2)/3;
\r
2120 VRAMWrite.Width=(VRAMWrite.Width*2)/3;
\r
2122 if(!PSXDisplay.InterlacedTest && // NEW
\r
2123 CheckAgainstScreen(VRAMWrite.x, VRAMWrite.y, VRAMWrite.Width, VRAMWrite.Height))
\r
2125 xrUploadArea.x0-=PreviousPSXDisplay.DisplayPosition.x;
\r
2126 xrUploadArea.x1-=PreviousPSXDisplay.DisplayPosition.x;
\r
2127 xrUploadArea.y0-=PreviousPSXDisplay.DisplayPosition.y;
\r
2128 xrUploadArea.y1-=PreviousPSXDisplay.DisplayPosition.y;
\r
2131 if(CheckAgainstFrontScreen(VRAMWrite.x, VRAMWrite.y, VRAMWrite.Width, VRAMWrite.Height))
\r
2133 xrUploadArea.x0-=PSXDisplay.DisplayPosition.x;
\r
2134 xrUploadArea.x1-=PSXDisplay.DisplayPosition.x;
\r
2135 xrUploadArea.y0-=PSXDisplay.DisplayPosition.y;
\r
2136 xrUploadArea.y1-=PSXDisplay.DisplayPosition.y;
\r
2140 if(bRenderFrontBuffer)
\r
2142 updateFrontDisplay();
\r
2145 if(bNeedRGB24Update==FALSE)
\r
2147 xrUploadAreaRGB24=xrUploadArea;
\r
2148 bNeedRGB24Update=TRUE;
\r
2152 xrUploadAreaRGB24.x0=min(xrUploadAreaRGB24.x0,xrUploadArea.x0);
\r
2153 xrUploadAreaRGB24.x1=max(xrUploadAreaRGB24.x1,xrUploadArea.x1);
\r
2154 xrUploadAreaRGB24.y0=min(xrUploadAreaRGB24.y0,xrUploadArea.y0);
\r
2155 xrUploadAreaRGB24.y1=max(xrUploadAreaRGB24.y1,xrUploadArea.y1);
\r
2159 ////////////////////////////////////////////////////////////////////////
\r
2161 void CheckWriteUpdate()
\r
2165 if(VRAMWrite.Width) iX=1;
\r
2166 if(VRAMWrite.Height) iY=1;
\r
2168 InvalidateTextureArea(VRAMWrite.x, VRAMWrite.y, VRAMWrite.Width-iX, VRAMWrite.Height-iY);
\r
2170 if(PSXDisplay.Interlaced && !iOffscreenDrawing) return;
\r
2172 if(PSXDisplay.RGB24) {PrepareRGB24Upload();return;}
\r
2174 if(!PSXDisplay.InterlacedTest &&
\r
2175 CheckAgainstScreen(VRAMWrite.x, VRAMWrite.y, VRAMWrite.Width, VRAMWrite.Height))
\r
2177 if(dwActFixes&0x800) return;
\r
2179 if(bRenderFrontBuffer)
\r
2181 updateFrontDisplay();
\r
2184 UploadScreen(FALSE);
\r
2186 bNeedUploadTest=TRUE;
\r
2189 if(iOffscreenDrawing)
\r
2191 if (CheckAgainstFrontScreen(VRAMWrite.x, VRAMWrite.y, VRAMWrite.Width, VRAMWrite.Height))
\r
2193 if(PSXDisplay.InterlacedTest)
\r
2195 if(PreviousPSXDisplay.InterlacedNew)
\r
2197 PreviousPSXDisplay.InterlacedNew=FALSE;
\r
2198 bNeedInterlaceUpdate=TRUE;
\r
2199 xrUploadAreaIL.x0=PSXDisplay.DisplayPosition.x;
\r
2200 xrUploadAreaIL.y0=PSXDisplay.DisplayPosition.y;
\r
2201 xrUploadAreaIL.x1=PSXDisplay.DisplayPosition.x+PSXDisplay.DisplayModeNew.x;
\r
2202 xrUploadAreaIL.y1=PSXDisplay.DisplayPosition.y+PSXDisplay.DisplayModeNew.y;
\r
2203 if(xrUploadAreaIL.x1>1023) xrUploadAreaIL.x1=1023;
\r
2204 if(xrUploadAreaIL.y1>511) xrUploadAreaIL.y1=511;
\r
2207 if(bNeedInterlaceUpdate==FALSE)
\r
2209 xrUploadAreaIL=xrUploadArea;
\r
2210 bNeedInterlaceUpdate=TRUE;
\r
2214 xrUploadAreaIL.x0=min(xrUploadAreaIL.x0,xrUploadArea.x0);
\r
2215 xrUploadAreaIL.x1=max(xrUploadAreaIL.x1,xrUploadArea.x1);
\r
2216 xrUploadAreaIL.y0=min(xrUploadAreaIL.y0,xrUploadArea.y0);
\r
2217 xrUploadAreaIL.y1=max(xrUploadAreaIL.y1,xrUploadArea.y1);
\r
2222 if(!bNeedUploadAfter)
\r
2224 bNeedUploadAfter = TRUE;
\r
2225 xrUploadArea.x0=VRAMWrite.x;
\r
2226 xrUploadArea.x1=VRAMWrite.x+VRAMWrite.Width;
\r
2227 xrUploadArea.y0=VRAMWrite.y;
\r
2228 xrUploadArea.y1=VRAMWrite.y+VRAMWrite.Height;
\r
2232 xrUploadArea.x0=min(xrUploadArea.x0,VRAMWrite.x);
\r
2233 xrUploadArea.x1=max(xrUploadArea.x1,VRAMWrite.x+VRAMWrite.Width);
\r
2234 xrUploadArea.y0=min(xrUploadArea.y0,VRAMWrite.y);
\r
2235 xrUploadArea.y1=max(xrUploadArea.y1,VRAMWrite.y+VRAMWrite.Height);
\r
2238 if(dwActFixes&0x8000)
\r
2240 if((xrUploadArea.x1-xrUploadArea.x0)>=(PSXDisplay.DisplayMode.x-32) &&
\r
2241 (xrUploadArea.y1-xrUploadArea.y0)>=(PSXDisplay.DisplayMode.y-32))
\r
2244 updateFrontDisplay();
\r
2251 ////////////////////////////////////////////////////////////////////////
\r
2252 // cmd: vram -> psx mem
\r
2253 ////////////////////////////////////////////////////////////////////////
\r
2255 void primStoreImage(u8 * baseAddr)
\r
2257 unsigned short *sgpuData = ((unsigned short *) baseAddr);
\r
2259 VRAMRead.x = sgpuData[2]&0x03ff;
\r
2260 VRAMRead.y = sgpuData[3]&iGPUHeightMask;
\r
2261 VRAMRead.Width = sgpuData[4];
\r
2262 VRAMRead.Height = sgpuData[5];
\r
2264 VRAMRead.ImagePtr = psxVuw + (VRAMRead.y<<10) + VRAMRead.x;
\r
2265 VRAMRead.RowsRemaining = VRAMRead.Width;
\r
2266 VRAMRead.ColsRemaining = VRAMRead.Height;
\r
2268 iDataReadMode = DR_VRAMTRANSFER;
\r
2270 STATUSREG |= GPUSTATUS_READYFORVRAM;
\r
2273 ////////////////////////////////////////////////////////////////////////
\r
2274 // cmd: blkfill - NO primitive! Doesn't care about draw areas...
\r
2275 ////////////////////////////////////////////////////////////////////////
\r
2277 void primBlkFill(u8 * baseAddr)
\r
2279 unsigned long *gpuData = ((unsigned long *) baseAddr);
\r
2280 short *sgpuData = ((short *) baseAddr);
\r
2282 iDrawnSomething=1;
\r
2284 sprtX = sgpuData[2];
\r
2285 sprtY = sgpuData[3];
\r
2286 sprtW = sgpuData[4] & 0x3ff;
\r
2287 sprtH = sgpuData[5] & iGPUHeightMask;
\r
2289 sprtW = (sprtW+15) & ~15;
\r
2291 // Increase H & W if they are one short of full values, because they never can be full values
\r
2292 if (sprtH == iGPUHeightMask) sprtH=iGPUHeight;
\r
2293 if (sprtW == 1023) sprtW=1024;
\r
2295 // x and y of start
\r
2296 ly0 = ly1 = sprtY;
\r
2297 ly2 = ly3 = (sprtY+sprtH);
\r
2298 lx0 = lx3 = sprtX;
\r
2299 lx1 = lx2 = (sprtX+sprtW);
\r
2303 if(ClipVertexListScreen())
\r
2305 PSXDisplay_t * pd;
\r
2306 if(PSXDisplay.InterlacedTest) pd=&PSXDisplay;
\r
2307 else pd=&PreviousPSXDisplay;
\r
2309 if ((lx0 <= pd->DisplayPosition.x+16) &&
\r
2310 (ly0 <= pd->DisplayPosition.y+16) &&
\r
2311 (lx2 >= pd->DisplayEnd.x-16) &&
\r
2312 (ly2 >= pd->DisplayEnd.y-16))
\r
2315 g=((GLclampf)GREEN(gpuData[0]))/255.0f;
\r
2316 b=((GLclampf)BLUE(gpuData[0]))/255.0f;
\r
2317 r=((GLclampf)RED(gpuData[0]))/255.0f;
\r
2319 glDisable(GL_SCISSOR_TEST);
\r
2320 glClearColor(r,g,b,1.0f);
\r
2321 glClear(uiBufferBits);
\r
2324 if(gpuData[0]!=0x02000000 &&
\r
2325 (ly0>pd->DisplayPosition.y ||
\r
2326 ly2<pd->DisplayEnd.y))
\r
2328 bDrawTextured = FALSE;
\r
2329 bDrawSmoothShaded = FALSE;
\r
2330 SetRenderState((unsigned long)0x01000000);
\r
2331 SetRenderMode((unsigned long)0x01000000, FALSE);
\r
2332 vertex[0].c.lcol=0xff000000;
\r
2333 SETCOL(vertex[0]);
\r
2334 if(ly0>pd->DisplayPosition.y)
\r
2336 vertex[0].x=0;vertex[0].y=0;
\r
2337 vertex[1].x=pd->DisplayEnd.x-pd->DisplayPosition.x;vertex[1].y=0;
\r
2338 vertex[2].x=vertex[1].x;vertex[2].y=ly0-pd->DisplayPosition.y;
\r
2339 vertex[3].x=0;vertex[3].y=vertex[2].y;
\r
2340 PRIMdrawQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
2342 if(ly2<pd->DisplayEnd.y)
\r
2344 vertex[0].x=0;vertex[0].y=(pd->DisplayEnd.y-pd->DisplayPosition.y)-(pd->DisplayEnd.y-ly2);
\r
2345 vertex[1].x=pd->DisplayEnd.x-pd->DisplayPosition.x;vertex[1].y=vertex[0].y;
\r
2346 vertex[2].x=vertex[1].x;vertex[2].y=pd->DisplayEnd.y;
\r
2347 vertex[3].x=0;vertex[3].y=vertex[2].y;
\r
2348 PRIMdrawQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
2352 glEnable(GL_SCISSOR_TEST);
\r
2356 bDrawTextured = FALSE;
\r
2357 bDrawSmoothShaded = FALSE;
\r
2358 SetRenderState((unsigned long)0x01000000);
\r
2359 SetRenderMode((unsigned long)0x01000000, FALSE);
\r
2360 vertex[0].c.lcol=gpuData[0]|0xff000000;
\r
2361 SETCOL(vertex[0]);
\r
2362 glDisable(GL_SCISSOR_TEST);
\r
2363 PRIMdrawQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
2364 glEnable(GL_SCISSOR_TEST);
\r
2368 //mmm... will clean all stuff, also if not all _should_ be cleaned...
\r
2369 //if (IsInsideNextScreen(sprtX, sprtY, sprtW, sprtH))
\r
2371 if (IsCompleteInsideNextScreen(sprtX, sprtY, sprtW, sprtH))
\r
2373 lClearOnSwapColor = COLOR(gpuData[0]);
\r
2377 /* if(iOffscreenDrawing)
\r
2379 ClampToPSXScreenOffset( &sprtX, &sprtY, &sprtW, &sprtH);
\r
2380 if ((sprtW == 0) || (sprtH == 0)) return;
\r
2381 InvalidateTextureArea(sprtX, sprtY, sprtW-1, sprtH-1);
\r
2386 FillSoftwareArea(sprtX, sprtY, sprtW, sprtH, BGR24to16(gpuData[0]));
\r
2390 ////////////////////////////////////////////////////////////////////////
\r
2391 // cmd: move image vram -> vram
\r
2392 ////////////////////////////////////////////////////////////////////////
\r
2394 void MoveImageWrapped(short imageX0,short imageY0,
\r
2395 short imageX1,short imageY1,
\r
2396 short imageSX,short imageSY)
\r
2398 int i,j,imageXE,imageYE;
\r
2400 if(iFrameReadType&2)
\r
2402 imageXE=imageX0+imageSX;
\r
2403 imageYE=imageY0+imageSY;
\r
2405 if(imageYE>iGPUHeight && imageXE>1024)
\r
2407 CheckVRamRead(0,0,
\r
2409 (imageY0&iGPUHeightMask),
\r
2415 CheckVRamRead(0,imageY0,
\r
2417 (imageYE>iGPUHeight)?iGPUHeight:imageYE,
\r
2421 if(imageYE>iGPUHeight)
\r
2423 CheckVRamRead(imageX0,0,
\r
2424 (imageXE>1024)?1024:imageXE,
\r
2425 imageYE&iGPUHeightMask,
\r
2429 CheckVRamRead(imageX0,imageY0,
\r
2430 (imageXE>1024)?1024:imageXE,
\r
2431 (imageYE>iGPUHeight)?iGPUHeight:imageYE,
\r
2435 for(j=0;j<imageSY;j++)
\r
2436 for(i=0;i<imageSX;i++)
\r
2437 psxVuw [(1024*((imageY1+j)&iGPUHeightMask))+((imageX1+i)&0x3ff)]=
\r
2438 psxVuw[(1024*((imageY0+j)&iGPUHeightMask))+((imageX0+i)&0x3ff)];
\r
2440 if(!PSXDisplay.RGB24)
\r
2442 imageXE=imageX1+imageSX;
\r
2443 imageYE=imageY1+imageSY;
\r
2445 if(imageYE>iGPUHeight && imageXE>1024)
\r
2447 InvalidateTextureArea(0,0,
\r
2448 (imageXE&0x3ff)-1,
\r
2449 (imageYE&iGPUHeightMask)-1);
\r
2454 InvalidateTextureArea(0,imageY1,
\r
2455 (imageXE&0x3ff)-1,
\r
2456 ((imageYE>iGPUHeight)?iGPUHeight:imageYE)-imageY1-1);
\r
2459 if(imageYE>iGPUHeight)
\r
2461 InvalidateTextureArea(imageX1,0,
\r
2462 ((imageXE>1024)?1024:imageXE)-imageX1-1,
\r
2463 (imageYE&iGPUHeightMask)-1);
\r
2466 InvalidateTextureArea(imageX1,imageY1,
\r
2467 ((imageXE>1024)?1024:imageXE)-imageX1-1,
\r
2468 ((imageYE>iGPUHeight)?iGPUHeight:imageYE)-imageY1-1);
\r
2472 ////////////////////////////////////////////////////////////////////////
\r
2474 void primMoveImage(u8 * baseAddr)
\r
2476 short *sgpuData = ((short *) baseAddr);
\r
2477 short imageY0,imageX0,imageY1,imageX1,imageSX,imageSY,i,j;
\r
2479 imageX0 = sgpuData[2]&0x03ff;
\r
2480 imageY0 = sgpuData[3]&iGPUHeightMask;
\r
2481 imageX1 = sgpuData[4]&0x03ff;
\r
2482 imageY1 = sgpuData[5]&iGPUHeightMask;
\r
2483 imageSX = sgpuData[6];
\r
2484 imageSY = sgpuData[7];
\r
2486 if((imageX0 == imageX1) && (imageY0 == imageY1)) return;
\r
2487 if(imageSX<=0) return;
\r
2488 if(imageSY<=0) return;
\r
2490 if(iGPUHeight==1024 && sgpuData[7]>1024) return;
\r
2492 if((imageY0+imageSY)>iGPUHeight ||
\r
2493 (imageX0+imageSX)>1024 ||
\r
2494 (imageY1+imageSY)>iGPUHeight ||
\r
2495 (imageX1+imageSX)>1024)
\r
2497 MoveImageWrapped(imageX0,imageY0,imageX1,imageY1,imageSX,imageSY);
\r
2498 if((imageY0+imageSY)>iGPUHeight) imageSY=iGPUHeight-imageY0;
\r
2499 if((imageX0+imageSX)>1024) imageSX=1024-imageX0;
\r
2500 if((imageY1+imageSY)>iGPUHeight) imageSY=iGPUHeight-imageY1;
\r
2501 if((imageX1+imageSX)>1024) imageSX=1024-imageX1;
\r
2504 if(iFrameReadType&2)
\r
2505 CheckVRamRead(imageX0,imageY0,
\r
2512 unsigned short *SRCPtr, *DSTPtr;
\r
2513 unsigned short LineOffset;
\r
2515 SRCPtr = psxVuw + (1024*imageY0) + imageX0;
\r
2516 DSTPtr = psxVuw + (1024*imageY1) + imageX1;
\r
2518 LineOffset = 1024 - imageSX;
\r
2520 for(j=0;j<imageSY;j++)
\r
2522 for(i=0;i<imageSX;i++) *DSTPtr++ = *SRCPtr++;
\r
2523 SRCPtr += LineOffset;
\r
2524 DSTPtr += LineOffset;
\r
2529 unsigned long *SRCPtr, *DSTPtr;
\r
2530 unsigned short LineOffset;
\r
2531 int dx=imageSX>>1;
\r
2533 SRCPtr = (unsigned long *)(psxVuw + (1024*imageY0) + imageX0);
\r
2534 DSTPtr = (unsigned long *)(psxVuw + (1024*imageY1) + imageX1);
\r
2536 LineOffset = 512 - dx;
\r
2538 for(j=0;j<imageSY;j++)
\r
2540 for(i=0;i<dx;i++) *DSTPtr++ = *SRCPtr++;
\r
2541 SRCPtr += LineOffset;
\r
2542 DSTPtr += LineOffset;
\r
2546 if (!PSXDisplay.RGB24)
\r
2548 InvalidateTextureArea(imageX1,imageY1,imageSX-1,imageSY-1);
\r
2550 if (CheckAgainstScreen(imageX1,imageY1,imageSX,imageSY))
\r
2552 if(imageX1>=PreviousPSXDisplay.DisplayPosition.x &&
\r
2553 imageX1<PreviousPSXDisplay.DisplayEnd.x &&
\r
2554 imageY1>=PreviousPSXDisplay.DisplayPosition.y &&
\r
2555 imageY1<PreviousPSXDisplay.DisplayEnd.y)
\r
2557 imageX1 += imageSX;
\r
2558 imageY1 += imageSY;
\r
2560 if(imageX1>=PreviousPSXDisplay.DisplayPosition.x &&
\r
2561 imageX1<=PreviousPSXDisplay.DisplayEnd.x &&
\r
2562 imageY1>=PreviousPSXDisplay.DisplayPosition.y &&
\r
2563 imageY1<=PreviousPSXDisplay.DisplayEnd.y)
\r
2566 imageX0>=PSXDisplay.DisplayPosition.x &&
\r
2567 imageX0<PSXDisplay.DisplayEnd.x &&
\r
2568 imageY0>=PSXDisplay.DisplayPosition.y &&
\r
2569 imageY0<PSXDisplay.DisplayEnd.y
\r
2572 if(bRenderFrontBuffer)
\r
2574 updateFrontDisplay();
\r
2577 UploadScreen(FALSE);
\r
2579 else bFakeFrontBuffer=TRUE;
\r
2583 bNeedUploadTest=TRUE;
\r
2586 if(iOffscreenDrawing)
\r
2588 if (CheckAgainstFrontScreen(imageX1,imageY1,imageSX,imageSY))
\r
2590 if(!PSXDisplay.InterlacedTest &&
\r
2593 imageX0>=PreviousPSXDisplay.DisplayPosition.x &&
\r
2594 imageX0<PreviousPSXDisplay.DisplayEnd.x &&
\r
2595 imageY0>=PreviousPSXDisplay.DisplayPosition.y &&
\r
2596 imageY0<PreviousPSXDisplay.DisplayEnd.y
\r
2599 imageX0>=PSXDisplay.DisplayPosition.x &&
\r
2600 imageX0<PSXDisplay.DisplayEnd.x &&
\r
2601 imageY0>=PSXDisplay.DisplayPosition.y &&
\r
2602 imageY0<PSXDisplay.DisplayEnd.y
\r
2606 bNeedUploadTest=TRUE;
\r
2608 if(!bNeedUploadAfter)
\r
2610 bNeedUploadAfter = TRUE;
\r
2611 xrUploadArea.x0=imageX0;
\r
2612 xrUploadArea.x1=imageX0+imageSX;
\r
2613 xrUploadArea.y0=imageY0;
\r
2614 xrUploadArea.y1=imageY0+imageSY;
\r
2618 xrUploadArea.x0=min(xrUploadArea.x0,imageX0);
\r
2619 xrUploadArea.x1=max(xrUploadArea.x1,imageX0+imageSX);
\r
2620 xrUploadArea.y0=min(xrUploadArea.y0,imageY0);
\r
2621 xrUploadArea.y1=max(xrUploadArea.y1,imageY0+imageSY);
\r
2629 ////////////////////////////////////////////////////////////////////////
\r
2630 // cmd: draw free-size Tile
\r
2631 ////////////////////////////////////////////////////////////////////////
\r
2633 void primTileS(u8 * baseAddr)
\r
2635 unsigned long *gpuData = ((unsigned long*)baseAddr);
\r
2636 short *sgpuData = ((short *) baseAddr);
\r
2638 sprtX = sgpuData[2];
\r
2639 sprtY = sgpuData[3];
\r
2640 sprtW = sgpuData[4] & 0x3ff;
\r
2641 sprtH = sgpuData[5] & iGPUHeightMask;
\r
2643 // x and y of start
\r
2650 if((dwActFixes&1) && // FF7 special game gix (battle cursor)
\r
2651 sprtX==0 && sprtY==0 && sprtW==24 && sprtH==16)
\r
2654 bDrawTextured = FALSE;
\r
2655 bDrawSmoothShaded = FALSE;
\r
2657 SetRenderState(gpuData[0]);
\r
2659 /* if(iOffscreenDrawing)
\r
2661 if(IsPrimCompleteInsideNextScreen(lx0,ly0,lx2,ly2) ||
\r
2662 (ly0==-6 && ly2==10)) // OH MY GOD... I DIDN'T WANT TO DO IT... BUT I'VE FOUND NO OTHER WAY... HACK FOR GRADIUS SHOOTER :(
\r
2664 lClearOnSwapColor = COLOR(gpuData[0]);
\r
2669 if(bDrawOffscreen4())
\r
2671 if(!(iTileCheat && sprtH==32 && gpuData[0]==0x60ffffff)) // special cheat for certain ZiNc games
\r
2673 InvalidateTextureAreaEx();
\r
2674 FillSoftwareAreaTrans(lx0,ly0,lx2,ly2,
\r
2675 BGR24to16(gpuData[0]));
\r
2680 SetRenderMode(gpuData[0], FALSE);
\r
2683 if(bIgnoreNextTile) {bIgnoreNextTile=FALSE;return;}
\r
2685 vertex[0].c.lcol=gpuData[0];
\r
2686 vertex[0].c.col[3]=ubGloColAlpha;
\r
2687 SETCOL(vertex[0]);
\r
2689 PRIMdrawQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
2691 iDrawnSomething=1;
\r
2694 ////////////////////////////////////////////////////////////////////////
\r
2695 // cmd: draw 1 dot Tile (point)
\r
2696 ////////////////////////////////////////////////////////////////////////
\r
2698 void primTile1(u8 * baseAddr)
\r
2700 unsigned long *gpuData = ((unsigned long*)baseAddr);
\r
2701 short *sgpuData = ((short *) baseAddr);
\r
2703 sprtX = sgpuData[2];
\r
2704 sprtY = sgpuData[3];
\r
2713 bDrawTextured = FALSE;
\r
2714 bDrawSmoothShaded = FALSE;
\r
2716 SetRenderState(gpuData[0]);
\r
2718 /* if(iOffscreenDrawing)
\r
2722 if(bDrawOffscreen4())
\r
2724 InvalidateTextureAreaEx();
\r
2725 FillSoftwareAreaTrans(lx0,ly0,lx2,ly2,
\r
2726 BGR24to16(gpuData[0]));
\r
2730 SetRenderMode(gpuData[0], FALSE);
\r
2733 vertex[0].c.lcol=gpuData[0];vertex[0].c.col[3]=ubGloColAlpha;
\r
2734 SETCOL(vertex[0]);
\r
2736 PRIMdrawQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
2738 iDrawnSomething=1;
\r
2741 ////////////////////////////////////////////////////////////////////////
\r
2742 // cmd: draw 8 dot Tile (small rect)
\r
2743 ////////////////////////////////////////////////////////////////////////
\r
2745 void primTile8(u8 * baseAddr)
\r
2747 unsigned long *gpuData = ((unsigned long*)baseAddr);
\r
2748 short *sgpuData = ((short *) baseAddr);
\r
2750 sprtX = sgpuData[2];
\r
2751 sprtY = sgpuData[3];
\r
2760 bDrawTextured = FALSE;
\r
2761 bDrawSmoothShaded = FALSE;
\r
2762 SetRenderState(gpuData[0]);
\r
2764 /* if(iOffscreenDrawing)
\r
2768 if(bDrawOffscreen4())
\r
2770 InvalidateTextureAreaEx();
\r
2771 FillSoftwareAreaTrans(lx0,ly0,lx2,ly2,
\r
2772 BGR24to16(gpuData[0]));
\r
2776 SetRenderMode(gpuData[0], FALSE);
\r
2779 vertex[0].c.lcol=gpuData[0];
\r
2780 vertex[0].c.col[3]=ubGloColAlpha;
\r
2781 SETCOL(vertex[0]);
\r
2783 PRIMdrawQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
2785 iDrawnSomething=1;
\r
2788 ////////////////////////////////////////////////////////////////////////
\r
2789 // cmd: draw 16 dot Tile (medium rect)
\r
2790 ////////////////////////////////////////////////////////////////////////
\r
2792 void primTile16(u8 * baseAddr)
\r
2794 unsigned long *gpuData = ((unsigned long*)baseAddr);
\r
2795 short *sgpuData = ((short *) baseAddr);
\r
2797 sprtX = sgpuData[2];
\r
2798 sprtY = sgpuData[3];
\r
2801 // x and y of start
\r
2807 bDrawTextured = FALSE;
\r
2808 bDrawSmoothShaded = FALSE;
\r
2809 SetRenderState(gpuData[0]);
\r
2811 /* if(iOffscreenDrawing)
\r
2815 if(bDrawOffscreen4())
\r
2817 InvalidateTextureAreaEx();
\r
2818 FillSoftwareAreaTrans(lx0,ly0,lx2,ly2,
\r
2819 BGR24to16(gpuData[0]));
\r
2823 SetRenderMode(gpuData[0], FALSE);
\r
2826 vertex[0].c.lcol=gpuData[0];
\r
2827 vertex[0].c.col[3]=ubGloColAlpha;
\r
2828 SETCOL(vertex[0]);
\r
2830 PRIMdrawQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
2832 iDrawnSomething=1;
\r
2835 ////////////////////////////////////////////////////////////////////////
\r
2836 // helper: filter effect by multipass rendering
\r
2837 ////////////////////////////////////////////////////////////////////////
\r
2839 /*void DrawMultiBlur(void)
\r
2841 long lABR,lDST;float fx,fy;
\r
2843 lABR=GlobalTextABR;
\r
2844 lDST=DrawSemiTrans;
\r
2846 fx=(float)PSXDisplay.DisplayMode.x/(float)(iResX);
\r
2847 fy=(float)PSXDisplay.DisplayMode.y/(float)(iResY);
\r
2849 vertex[0].x+=fx;vertex[1].x+=fx;
\r
2850 vertex[2].x+=fx;vertex[3].x+=fx;
\r
2856 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
2858 vertex[0].y+=fy;vertex[1].y+=fy;
\r
2859 vertex[2].y+=fy;vertex[3].y+=fy;
\r
2860 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
2862 if(bDrawMultiPass) {obm1=obm2=GL_SRC_ALPHA;}
\r
2864 GlobalTextABR=lABR;
\r
2865 DrawSemiTrans=lDST;
\r
2868 ////////////////////////////////////////////////////////////////////////
\r
2870 #define POFF 0.375f
\r
2872 void DrawMultiFilterSprite(void)
\r
2876 if(bUseMultiPass || DrawSemiTrans || ubOpaqueDraw)
\r
2878 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
2882 lABR=GlobalTextABR;
\r
2883 lDST=DrawSemiTrans;
\r
2884 vertex[0].c.col[3]=ubGloAlpha/2; // -> set color with
\r
2885 SETCOL(vertex[0]); // texture alpha
\r
2886 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
2887 vertex[0].x+=POFF;vertex[1].x+=POFF;
\r
2888 vertex[2].x+=POFF;vertex[3].x+=POFF;
\r
2889 vertex[0].y+=POFF;vertex[1].y+=POFF;
\r
2890 vertex[2].y+=POFF;vertex[3].y+=POFF;
\r
2894 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
2895 GlobalTextABR=lABR;
\r
2896 DrawSemiTrans=lDST;
\r
2899 ////////////////////////////////////////////////////////////////////////
\r
2900 // cmd: small sprite (textured rect)
\r
2901 ////////////////////////////////////////////////////////////////////////
\r
2903 void primSprt8(u8 * baseAddr)
\r
2905 unsigned long *gpuData = ((unsigned long *) baseAddr);
\r
2906 short *sgpuData = ((short *) baseAddr);
\r
2911 sprtX = sgpuData[2];
\r
2912 sprtY = sgpuData[3];
\r
2921 // do texture stuff
\r
2922 gl_ux[0]=gl_ux[3]=baseAddr[8];//gpuData[2]&0xff;
\r
2924 if(usMirror & 0x1000)
\r
2929 gl_ux[0]=gl_ux[3]=s;
\r
2932 sSprite_ux2=s=gl_ux[0]+sprtW;
\r
2935 gl_ux[1]=gl_ux[2]=s;
\r
2937 gl_vy[0]=gl_vy[1]=baseAddr[9];//(gpuData[2]>>8)&0xff;
\r
2939 if(usMirror & 0x2000)
\r
2944 gl_vy[0]=gl_vy[1]=s;
\r
2947 sSprite_vy2=s=gl_vy[0]+sprtH;
\r
2950 gl_vy[2]=gl_vy[3]=s;
\r
2952 ulClutID=(gpuData[2]>>16);
\r
2954 bDrawTextured = TRUE;
\r
2955 bDrawSmoothShaded = FALSE;
\r
2956 SetRenderState(gpuData[0]);
\r
2958 /* if(iOffscreenDrawing)
\r
2962 if(bDrawOffscreen4())
\r
2964 InvalidateTextureAreaEx();
\r
2965 SetRenderColor(gpuData[0]);
\r
2966 lx0-=PSXDisplay.DrawOffset.x;
\r
2967 ly0-=PSXDisplay.DrawOffset.y;
\r
2969 if(bUsingTWin) DrawSoftwareSpriteTWin(baseAddr,8,8);
\r
2971 if(usMirror) DrawSoftwareSpriteMirror(baseAddr,8,8);
\r
2973 DrawSoftwareSprite(baseAddr,8,8,baseAddr[8],baseAddr[9]);
\r
2977 SetRenderMode(gpuData[0], TRUE);
\r
2980 sSprite_ux2=gl_ux[0]+sprtW;
\r
2981 sSprite_vy2=gl_vy[0]+sprtH;
\r
2983 assignTextureSprite();
\r
2985 if(iFilterType>4)
\r
2986 DrawMultiFilterSprite();
\r
2988 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
2990 if(bDrawMultiPass)
\r
2992 SetSemiTransMulti(1);
\r
2993 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
2999 if(bUseMultiPass) SetOpaqueColor(gpuData[0]);
\r
3002 /* if(bSmallAlpha && iFilterType<=2)
\r
3004 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
\r
3005 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
\r
3006 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
3007 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
\r
3008 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
\r
3012 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
3017 iDrawnSomething=1;
\r
3020 ////////////////////////////////////////////////////////////////////////
\r
3021 // cmd: medium sprite (textured rect)
\r
3022 ////////////////////////////////////////////////////////////////////////
\r
3024 void primSprt16(u8 * baseAddr)
\r
3026 unsigned long *gpuData = ((unsigned long *) baseAddr);
\r
3027 short *sgpuData = ((short *) baseAddr);
\r
3032 sprtX = sgpuData[2];
\r
3033 sprtY = sgpuData[3];
\r
3042 // do texture stuff
\r
3043 gl_ux[0]=gl_ux[3]=baseAddr[8];//gpuData[2]&0xff;
\r
3045 if(usMirror & 0x1000)
\r
3050 gl_ux[0]=gl_ux[3]=s;
\r
3053 sSprite_ux2=s=gl_ux[0]+sprtW;
\r
3056 gl_ux[1]=gl_ux[2]=s;
\r
3058 gl_vy[0]=gl_vy[1]=baseAddr[9];//(gpuData[2]>>8)&0xff;
\r
3060 if(usMirror & 0x2000)
\r
3065 gl_vy[0]=gl_vy[1]=s;
\r
3068 sSprite_vy2=s=gl_vy[0]+sprtH;
\r
3071 gl_vy[2]=gl_vy[3]=s;
\r
3073 ulClutID=(gpuData[2]>>16);
\r
3075 bDrawTextured = TRUE;
\r
3076 bDrawSmoothShaded = FALSE;
\r
3077 SetRenderState(gpuData[0]);
\r
3079 /* if(iOffscreenDrawing)
\r
3083 if(bDrawOffscreen4())
\r
3085 InvalidateTextureAreaEx();
\r
3086 SetRenderColor(gpuData[0]);
\r
3087 lx0-=PSXDisplay.DrawOffset.x;
\r
3088 ly0-=PSXDisplay.DrawOffset.y;
\r
3089 if(bUsingTWin) DrawSoftwareSpriteTWin(baseAddr,16,16);
\r
3091 if(usMirror) DrawSoftwareSpriteMirror(baseAddr,16,16);
\r
3093 DrawSoftwareSprite(baseAddr,16,16,baseAddr[8],baseAddr[9]);
\r
3097 SetRenderMode(gpuData[0], TRUE);
\r
3100 sSprite_ux2=gl_ux[0]+sprtW;
\r
3101 sSprite_vy2=gl_vy[0]+sprtH;
\r
3103 assignTextureSprite();
\r
3105 if(iFilterType>4)
\r
3106 DrawMultiFilterSprite();
\r
3108 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
3110 if(bDrawMultiPass)
\r
3112 SetSemiTransMulti(1);
\r
3113 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
3119 if(bUseMultiPass) SetOpaqueColor(gpuData[0]);
\r
3122 /* if(bSmallAlpha && iFilterType<=2)
\r
3124 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
\r
3125 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
\r
3126 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
3127 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
\r
3128 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
\r
3132 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
3137 iDrawnSomething=1;
\r
3140 ////////////////////////////////////////////////////////////////////////
\r
3141 // cmd: free-size sprite (textured rect)
\r
3142 ////////////////////////////////////////////////////////////////////////
\r
3144 void primSprtSRest(u8 * baseAddr,unsigned short type)
\r
3146 unsigned long *gpuData = ((unsigned long *) baseAddr);
\r
3147 short *sgpuData = ((short *) baseAddr);
\r
3148 short s;unsigned short sTypeRest=0;
\r
3150 sprtX = sgpuData[2];
\r
3151 sprtY = sgpuData[3];
\r
3152 sprtW = sgpuData[6] & 0x3ff;
\r
3153 sprtH = sgpuData[7] & 0x1ff;
\r
3156 // do texture stuff
\r
3160 gl_vy[0]=gl_vy[1]=baseAddr[9];
\r
3161 s=256-baseAddr[8];
\r
3164 gl_ux[0]=gl_ux[3]=0;
\r
3167 gl_ux[0]=gl_ux[3]=baseAddr[8];
\r
3168 s=256-baseAddr[9];
\r
3171 gl_vy[0]=gl_vy[1]=0;
\r
3174 s=256-baseAddr[8];
\r
3177 gl_ux[0]=gl_ux[3]=0;
\r
3178 s=256-baseAddr[9];
\r
3181 gl_vy[0]=gl_vy[1]=0;
\r
3185 gl_vy[0]=gl_vy[1]=baseAddr[9];
\r
3186 s=512-baseAddr[8];
\r
3189 gl_ux[0]=gl_ux[3]=0;
\r
3192 gl_ux[0]=gl_ux[3]=baseAddr[8];
\r
3193 s=512-baseAddr[9];
\r
3196 gl_vy[0]=gl_vy[1]=0;
\r
3199 s=512-baseAddr[8];
\r
3202 gl_ux[0]=gl_ux[3]=0;
\r
3203 s=512-baseAddr[9];
\r
3206 gl_vy[0]=gl_vy[1]=0;
\r
3211 if(usMirror & 0x1000)
\r
3214 s-=sprtW-1;if(s<0) s=0;
\r
3215 gl_ux[0]=gl_ux[3]=s;
\r
3217 if(usMirror & 0x2000)
\r
3220 s-=sprtH-1;if(s<0) {s=0;}
\r
3221 gl_vy[0]=gl_vy[1]=s;
\r
3224 sSprite_ux2=s=gl_ux[0]+sprtW;
\r
3226 gl_ux[1]=gl_ux[2]=s;
\r
3227 sSprite_vy2=s=gl_vy[0]+sprtH;
\r
3229 gl_vy[2]=gl_vy[3]=s;
\r
3233 if(sSprite_ux2>256)
\r
3234 {sprtW=256-gl_ux[0];sSprite_ux2=256;sTypeRest+=1;}
\r
3235 if(sSprite_vy2>256)
\r
3236 {sprtH=256-gl_vy[0];sSprite_vy2=256;sTypeRest+=2;}
\r
3244 ulClutID=(gpuData[2]>>16);
\r
3246 bDrawTextured = TRUE;
\r
3247 bDrawSmoothShaded = FALSE;
\r
3248 SetRenderState(gpuData[0]);
\r
3250 /* if(iOffscreenDrawing)
\r
3254 if(bDrawOffscreen4())
\r
3256 InvalidateTextureAreaEx();
\r
3257 SetRenderColor(gpuData[0]);
\r
3258 lx0-=PSXDisplay.DrawOffset.x;
\r
3259 ly0-=PSXDisplay.DrawOffset.y;
\r
3260 if(bUsingTWin) DrawSoftwareSpriteTWin(baseAddr,sprtW,sprtH);
\r
3262 if(usMirror) DrawSoftwareSpriteMirror(baseAddr,sprtW,sprtH);
\r
3264 DrawSoftwareSprite(baseAddr,sprtW,sprtH,baseAddr[8],baseAddr[9]);
\r
3268 SetRenderMode(gpuData[0], TRUE);
\r
3271 sSprite_ux2=gl_ux[0]+sprtW;
\r
3272 sSprite_vy2=gl_vy[0]+sprtH;
\r
3274 assignTextureSprite();
\r
3276 if(iFilterType>4)
\r
3277 DrawMultiFilterSprite();
\r
3279 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
3281 if(bDrawMultiPass)
\r
3283 SetSemiTransMulti(1);
\r
3284 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
3290 if(bUseMultiPass) SetOpaqueColor(gpuData[0]);
\r
3293 /* if(bSmallAlpha && iFilterType<=2)
\r
3295 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
\r
3296 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
\r
3297 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
3298 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
\r
3299 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
\r
3303 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
3307 if(sTypeRest && type<4)
\r
3309 if(sTypeRest&1 && type==1) primSprtSRest(baseAddr,4);
\r
3310 if(sTypeRest&2 && type==2) primSprtSRest(baseAddr,5);
\r
3311 if(sTypeRest==3 && type==3) primSprtSRest(baseAddr,6);
\r
3315 void primSprtS(u8 * baseAddr)
\r
3317 unsigned long *gpuData = ((unsigned long *) baseAddr);
\r
3318 short *sgpuData = ((short *) baseAddr);
\r
3320 short s;unsigned short sTypeRest=0;
\r
3322 sprtX = sgpuData[2];
\r
3323 sprtY = sgpuData[3];
\r
3324 sprtW = sgpuData[6] & 0x3ff;
\r
3325 sprtH = sgpuData[7] & 0x1ff;
\r
3327 if(!sprtH) return;
\r
3328 if(!sprtW) return;
\r
3332 // do texture stuff
\r
3333 gl_ux[0]=gl_ux[3]=baseAddr[8];//gpuData[2]&0xff;
\r
3334 gl_vy[0]=gl_vy[1]=baseAddr[9];//(gpuData[2]>>8)&0xff;
\r
3336 if(usMirror & 0x1000)
\r
3341 gl_ux[0]=gl_ux[3]=s;
\r
3343 if(usMirror & 0x2000)
\r
3348 gl_vy[0]=gl_vy[1]=s;
\r
3351 sSprite_ux2=s=gl_ux[0]+sprtW;
\r
3354 gl_ux[1]=gl_ux[2]=s;
\r
3355 sSprite_vy2=s=gl_vy[0]+sprtH;
\r
3358 gl_vy[2]=gl_vy[3]=s;
\r
3362 if(sSprite_ux2>256)
\r
3363 {sprtW=256-gl_ux[0];sSprite_ux2=256;sTypeRest+=1;}
\r
3364 if(sSprite_vy2>256)
\r
3365 {sprtH=256-gl_vy[0];sSprite_vy2=256;sTypeRest+=2;}
\r
3373 ulClutID=(gpuData[2]>>16);
\r
3375 bDrawTextured = TRUE;
\r
3376 bDrawSmoothShaded = FALSE;
\r
3377 SetRenderState(gpuData[0]);
\r
3379 /* if(iOffscreenDrawing)
\r
3383 if(bDrawOffscreen4())
\r
3385 InvalidateTextureAreaEx();
\r
3386 SetRenderColor(gpuData[0]);
\r
3387 lx0-=PSXDisplay.DrawOffset.x;
\r
3388 ly0-=PSXDisplay.DrawOffset.y;
\r
3389 if(bUsingTWin) DrawSoftwareSpriteTWin(baseAddr,sprtW,sprtH);
\r
3391 if(usMirror) DrawSoftwareSpriteMirror(baseAddr,sprtW,sprtH);
\r
3393 DrawSoftwareSprite(baseAddr,sprtW,sprtH,baseAddr[8],baseAddr[9]);
\r
3397 SetRenderMode(gpuData[0], TRUE);
\r
3400 if((dwActFixes&1) && gTexFrameName && gTexName==gTexFrameName)
\r
3401 {iSpriteTex=0;return;}
\r
3403 sSprite_ux2=gl_ux[0]+sprtW;
\r
3404 sSprite_vy2=gl_vy[0]+sprtH;
\r
3406 assignTextureSprite();
\r
3408 if(iFilterType>4)
\r
3409 DrawMultiFilterSprite();
\r
3411 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
3413 if(bDrawMultiPass)
\r
3415 SetSemiTransMulti(1);
\r
3416 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
3422 if(bUseMultiPass) SetOpaqueColor(gpuData[0]);
\r
3425 /* if(bSmallAlpha && iFilterType<=2)
\r
3427 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
\r
3428 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
\r
3429 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
3430 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
\r
3431 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
\r
3435 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
3441 if(sTypeRest&1) primSprtSRest(baseAddr,1);
\r
3442 if(sTypeRest&2) primSprtSRest(baseAddr,2);
\r
3443 if(sTypeRest==3) primSprtSRest(baseAddr,3);
\r
3447 iDrawnSomething=1;
\r
3450 ////////////////////////////////////////////////////////////////////////
\r
3451 // cmd: flat shaded Poly4
\r
3452 ////////////////////////////////////////////////////////////////////////
\r
3454 void primPolyF4(u8 *baseAddr)
\r
3456 unsigned long *gpuData = ((unsigned long *) baseAddr);
\r
3457 short *sgpuData = ((short *) baseAddr);
\r
3459 lx0 = sgpuData[2];
\r
3460 ly0 = sgpuData[3];
\r
3461 lx1 = sgpuData[4];
\r
3462 ly1 = sgpuData[5];
\r
3463 lx2 = sgpuData[6];
\r
3464 ly2 = sgpuData[7];
\r
3465 lx3 = sgpuData[8];
\r
3466 ly3 = sgpuData[9];
\r
3468 if(offset4()) return;
\r
3470 bDrawTextured = FALSE;
\r
3471 bDrawSmoothShaded = FALSE;
\r
3472 SetRenderState(gpuData[0]);
\r
3474 /* if(iOffscreenDrawing)
\r
3477 if(bDrawOffscreen4())
\r
3479 InvalidateTextureAreaEx();
\r
3480 drawPoly4F(gpuData[0]);
\r
3484 SetRenderMode(gpuData[0], FALSE);
\r
3487 vertex[0].c.lcol=gpuData[0];vertex[0].c.col[3]=ubGloColAlpha;
\r
3488 SETCOL(vertex[0]);
\r
3490 PRIMdrawTri2(&vertex[0], &vertex[1], &vertex[2],&vertex[3]);
\r
3492 iDrawnSomething=1;
\r
3495 ////////////////////////////////////////////////////////////////////////
\r
3496 // cmd: smooth shaded Poly4
\r
3497 ////////////////////////////////////////////////////////////////////////
\r
3499 void primPolyG4(u8 * baseAddr);
\r
3501 BOOL bDrawOffscreenFrontFF9G4(void)
\r
3503 if(lx0< PSXDisplay.DisplayPosition.x) return FALSE; // must be complete in front
\r
3504 if(lx0> PSXDisplay.DisplayEnd.x) return FALSE;
\r
3505 if(ly0< PSXDisplay.DisplayPosition.y) return FALSE;
\r
3506 if(ly0> PSXDisplay.DisplayEnd.y) return FALSE;
\r
3507 if(lx1< PSXDisplay.DisplayPosition.x) return FALSE;
\r
3508 if(lx1> PSXDisplay.DisplayEnd.x) return FALSE;
\r
3509 if(ly1< PSXDisplay.DisplayPosition.y) return FALSE;
\r
3510 if(ly1> PSXDisplay.DisplayEnd.y) return FALSE;
\r
3511 if(lx2< PSXDisplay.DisplayPosition.x) return FALSE;
\r
3512 if(lx2> PSXDisplay.DisplayEnd.x) return FALSE;
\r
3513 if(ly2< PSXDisplay.DisplayPosition.y) return FALSE;
\r
3514 if(ly2> PSXDisplay.DisplayEnd.y) return FALSE;
\r
3515 if(lx3< PSXDisplay.DisplayPosition.x) return FALSE;
\r
3516 if(lx3> PSXDisplay.DisplayEnd.x) return FALSE;
\r
3517 if(ly3< PSXDisplay.DisplayPosition.y) return FALSE;
\r
3518 if(ly3> PSXDisplay.DisplayEnd.y) return FALSE;
\r
3522 BOOL bCheckFF9G4(u8 * baseAddr)
\r
3524 static u8 pFF9G4Cache[32];
\r
3525 static int iFF9Fix=0;
\r
3531 if(bDrawOffscreenFrontFF9G4())
\r
3533 short *sgpuData = ((short *) pFF9G4Cache);
\r
3535 memcpy(pFF9G4Cache,baseAddr,32);
\r
3537 if(sgpuData[2]==142)
\r
3551 long labr=GlobalTextABR;
\r
3553 primPolyG4(pFF9G4Cache);
\r
3554 GlobalTextABR=labr;
\r
3561 ////////////////////////////////////////////////////////////////////////
\r
3563 void primPolyG4(u8 * baseAddr)
\r
3565 unsigned long *gpuData = (unsigned long *)baseAddr;
\r
3566 short *sgpuData = ((short *) baseAddr);
\r
3568 lx0 = sgpuData[2];
\r
3569 ly0 = sgpuData[3];
\r
3570 lx1 = sgpuData[6];
\r
3571 ly1 = sgpuData[7];
\r
3572 lx2 = sgpuData[10];
\r
3573 ly2 = sgpuData[11];
\r
3574 lx3 = sgpuData[14];
\r
3575 ly3 = sgpuData[15];
\r
3577 if(offset4()) return;
\r
3579 bDrawTextured = FALSE;
\r
3580 bDrawSmoothShaded = TRUE;
\r
3581 SetRenderState(gpuData[0]);
\r
3583 /* if(iOffscreenDrawing)
\r
3587 if((dwActFixes&512) && bCheckFF9G4(baseAddr)) return;
\r
3589 if(bDrawOffscreen4())
\r
3591 InvalidateTextureAreaEx();
\r
3592 drawPoly4G(gpuData[0], gpuData[2], gpuData[4], gpuData[6]);
\r
3596 SetRenderMode(gpuData[0], FALSE);
\r
3599 vertex[0].c.lcol=gpuData[0];
\r
3600 vertex[1].c.lcol=gpuData[2];
\r
3601 vertex[2].c.lcol=gpuData[4];
\r
3602 vertex[3].c.lcol=gpuData[6];
\r
3604 vertex[0].c.col[3]=vertex[1].c.col[3]=vertex[2].c.col[3]=vertex[3].c.col[3]=ubGloAlpha;
\r
3607 PRIMdrawGouraudTri2Color(&vertex[0],&vertex[1], &vertex[2], &vertex[3]);
\r
3609 iDrawnSomething=1;
\r
3612 ////////////////////////////////////////////////////////////////////////
\r
3613 // cmd: flat shaded Texture3
\r
3614 ////////////////////////////////////////////////////////////////////////
\r
3616 BOOL DoLineCheck(unsigned long * gpuData)
\r
3618 BOOL bQuad=FALSE;short dx,dy;
\r
3622 dx=lx0-lx2;if(dx<0) dx=-dx;
\r
3626 dy=ly1-ly0;if(dy<0) dy=-dy;
\r
3629 vertex[3]=vertex[2];
\r
3630 vertex[2]=vertex[0];
\r
3631 vertex[2].x=vertex[3].x;
\r
3636 vertex[3]=vertex[2];
\r
3637 vertex[2].y=vertex[0].y;
\r
3639 else return FALSE;
\r
3646 dy=ly0-ly1;if(dy<0) dy=-dy;
\r
3649 vertex[3]=vertex[1];
\r
3650 vertex[3].x=vertex[2].x;
\r
3655 vertex[3]=vertex[2];
\r
3656 vertex[3].y=vertex[1].y;
\r
3658 else return FALSE;
\r
3666 dx=lx0-lx1;if(dx<0) dx=-dx;
\r
3670 dy=ly2-ly0;if(dy<0) dy=-dy;
\r
3673 vertex[3]=vertex[1];
\r
3674 vertex[1]=vertex[0];
\r
3675 vertex[1].x=vertex[3].x;
\r
3680 vertex[3]=vertex[1];
\r
3681 vertex[1].y=vertex[0].y;
\r
3683 else return FALSE;
\r
3690 dy=ly2-ly0;if(dy<0) dy=-dy;
\r
3693 vertex[3]=vertex[2];
\r
3694 vertex[3].x=vertex[1].x;
\r
3699 vertex[3]=vertex[1];
\r
3700 vertex[3].y=vertex[2].y;
\r
3702 else return FALSE;
\r
3710 dx=lx1-lx0;if(dx<0) dx=-dx;
\r
3714 dy=ly1-ly2;if(dy<0) dy=-dy;
\r
3718 vertex[3]=vertex[2];
\r
3719 vertex[2].x=vertex[0].x;
\r
3724 vertex[3]=vertex[2];
\r
3725 vertex[2]=vertex[0];
\r
3726 vertex[2].y=vertex[3].y;
\r
3728 else return FALSE;
\r
3735 dy=ly2-ly1;if(dy<0) dy=-dy;
\r
3739 vertex[3]=vertex[1];
\r
3740 vertex[1].x=vertex[0].x;
\r
3745 vertex[3]=vertex[1];
\r
3746 vertex[1]=vertex[0];
\r
3747 vertex[1].y=vertex[3].y;
\r
3749 else return FALSE;
\r
3755 if(!bQuad) return FALSE;
\r
3757 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[3], &vertex[2]);
\r
3759 if(bDrawMultiPass)
\r
3761 SetSemiTransMulti(1);
\r
3762 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[3], &vertex[2]);
\r
3768 if(bUseMultiPass) SetOpaqueColor(gpuData[0]);
\r
3770 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[3], &vertex[2]);
\r
3774 iDrawnSomething=1;
\r
3779 ////////////////////////////////////////////////////////////////////////
\r
3781 void primPolyFT3(u8 * baseAddr)
\r
3783 unsigned long *gpuData = ((unsigned long *) baseAddr);
\r
3784 short *sgpuData = ((short *) baseAddr);
\r
3786 lx0 = sgpuData[2];
\r
3787 ly0 = sgpuData[3];
\r
3788 lx1 = sgpuData[6];
\r
3789 ly1 = sgpuData[7];
\r
3790 lx2 = sgpuData[10];
\r
3791 ly2 = sgpuData[11];
\r
3793 if(offset3()) return;
\r
3795 // do texture UV coordinates stuff
\r
3796 gl_ux[0]=gl_ux[3]=baseAddr[8];//gpuData[2]&0xff;
\r
3797 gl_vy[0]=gl_vy[3]=baseAddr[9];//(gpuData[2]>>8)&0xff;
\r
3798 gl_ux[1]=baseAddr[16];//gpuData[4]&0xff;
\r
3799 gl_vy[1]=baseAddr[17];//(gpuData[4]>>8)&0xff;
\r
3800 gl_ux[2]=baseAddr[24];//gpuData[6]&0xff;
\r
3801 gl_vy[2]=baseAddr[25];//(gpuData[6]>>8)&0xff;
\r
3803 UpdateGlobalTP((unsigned short)(gpuData[4]>>16));
\r
3804 ulClutID=gpuData[2]>>16;
\r
3806 bDrawTextured = TRUE;
\r
3807 bDrawSmoothShaded = FALSE;
\r
3808 SetRenderState(gpuData[0]);
\r
3810 /* if(iOffscreenDrawing)
\r
3813 if(bDrawOffscreen3())
\r
3815 InvalidateTextureAreaEx();
\r
3816 SetRenderColor(gpuData[0]);
\r
3817 drawPoly3FT(baseAddr);
\r
3821 SetRenderMode(gpuData[0], TRUE);
\r
3826 if(!(dwActFixes&0x10))
\r
3828 if(DoLineCheck(gpuData)) return;
\r
3831 PRIMdrawTexturedTri(&vertex[0], &vertex[1], &vertex[2]);
\r
3833 if(bDrawMultiPass)
\r
3835 SetSemiTransMulti(1);
\r
3836 PRIMdrawTexturedTri(&vertex[0], &vertex[1], &vertex[2]);
\r
3842 if(bUseMultiPass) SetOpaqueColor(gpuData[0]);
\r
3844 PRIMdrawTexturedTri(&vertex[0], &vertex[1], &vertex[2]);
\r
3848 iDrawnSomething=1;
\r
3851 ////////////////////////////////////////////////////////////////////////
\r
3852 // cmd: flat shaded Texture4
\r
3853 ////////////////////////////////////////////////////////////////////////
\r
3855 #define ST_FAC 255.99f
\r
3857 void RectTexAlign(void)
\r
3859 int UFlipped = FALSE;
\r
3860 int VFlipped = FALSE;
\r
3862 if(gTexName==gTexFrameName) return;
\r
3866 if(!((lx1==lx3 && ly3==ly2 && lx2==lx0) ||
\r
3867 (lx1==lx2 && ly2==ly3 && lx3==lx0)))
\r
3872 if (vertex[0].tow > vertex[2].tow)
\r
3877 if (vertex[0].tow < vertex[2].tow)
\r
3884 if(!((lx2==lx3 && ly3==ly1 && lx1==lx0) ||
\r
3885 (lx2==lx1 && ly1==ly3 && lx3==lx0)))
\r
3890 if (vertex[0].tow > vertex[1].tow)
\r
3895 if (vertex[0].tow < vertex[1].tow)
\r
3902 if(!((lx3==lx2 && ly2==ly1 && lx1==lx0) ||
\r
3903 (lx3==lx1 && ly1==ly2 && lx2==lx0)))
\r
3908 if (vertex[0].tow > vertex[1].tow)
\r
3913 if (vertex[0].tow < vertex[1].tow)
\r
3923 if (vertex[0].sow > vertex[2].sow)
\r
3928 if (vertex[0].sow < vertex[2].sow)
\r
3937 if (vertex[0].sow > vertex[1].sow)
\r
3942 if (vertex[0].sow < vertex[1].sow)
\r
3951 if (vertex[0].sow > vertex[1].sow)
\r
3956 if (vertex[0].sow < vertex[1].sow)
\r
3969 vertex[2].sow+=0.95f/TWin.UScaleFactor;
\r
3970 vertex[3].sow+=0.95f/TWin.UScaleFactor;
\r
3973 vertex[0].sow+=0.95f/TWin.UScaleFactor;
\r
3974 vertex[1].sow+=0.95f/TWin.UScaleFactor;
\r
3977 vertex[1].sow+=0.95f/TWin.UScaleFactor;
\r
3978 vertex[3].sow+=0.95f/TWin.UScaleFactor;
\r
3981 vertex[0].sow+=0.95f/TWin.UScaleFactor;
\r
3982 vertex[2].sow+=0.95f/TWin.UScaleFactor;
\r
3985 vertex[1].sow+=0.95f/TWin.UScaleFactor;
\r
3986 vertex[2].sow+=0.95f/TWin.UScaleFactor;
\r
3989 vertex[0].sow+=0.95f/TWin.UScaleFactor;
\r
3990 vertex[3].sow+=0.95f/TWin.UScaleFactor;
\r
3999 vertex[2].sow+=1.0f/ST_FAC;
\r
4000 vertex[3].sow+=1.0f/ST_FAC;
\r
4003 vertex[0].sow+=1.0f/ST_FAC;
\r
4004 vertex[1].sow+=1.0f/ST_FAC;
\r
4007 vertex[1].sow+=1.0f/ST_FAC;
\r
4008 vertex[3].sow+=1.0f/ST_FAC;
\r
4011 vertex[0].sow+=1.0f/ST_FAC;
\r
4012 vertex[2].sow+=1.0f/ST_FAC;
\r
4015 vertex[1].sow+=1.0f/ST_FAC;
\r
4016 vertex[2].sow+=1.0f/ST_FAC;
\r
4019 vertex[0].sow+=1.0f/ST_FAC;
\r
4020 vertex[3].sow+=1.0f/ST_FAC;
\r
4030 vertex[2].sow+=1.0f/TWin.UScaleFactor;
\r
4031 vertex[3].sow+=1.0f/TWin.UScaleFactor;
\r
4034 vertex[0].sow+=1.0f/TWin.UScaleFactor;
\r
4035 vertex[1].sow+=1.0f/TWin.UScaleFactor;
\r
4038 vertex[1].sow+=1.0f/TWin.UScaleFactor;
\r
4039 vertex[3].sow+=1.0f/TWin.UScaleFactor;
\r
4042 vertex[0].sow+=1.0f/TWin.UScaleFactor;
\r
4043 vertex[2].sow+=1.0f/TWin.UScaleFactor;
\r
4046 vertex[1].sow+=1.0f/TWin.UScaleFactor;
\r
4047 vertex[2].sow+=1.0f/TWin.UScaleFactor;
\r
4050 vertex[0].sow+=1.0f/TWin.UScaleFactor;
\r
4051 vertex[3].sow+=1.0f/TWin.UScaleFactor;
\r
4060 vertex[2].sow+=1.0f;
\r
4061 vertex[3].sow+=1.0f;
\r
4064 vertex[0].sow+=1.0f;
\r
4065 vertex[1].sow+=1.0f;
\r
4068 vertex[1].sow+=1.0f;
\r
4069 vertex[3].sow+=1.0f;
\r
4072 vertex[0].sow+=1.0f;
\r
4073 vertex[2].sow+=1.0f;
\r
4076 vertex[1].sow+=1.0f;
\r
4077 vertex[2].sow+=1.0f;
\r
4080 vertex[0].sow+=1.0f;
\r
4081 vertex[3].sow+=1.0f;
\r
4096 vertex[2].tow+=0.95f/TWin.VScaleFactor;
\r
4097 vertex[3].tow+=0.95f/TWin.VScaleFactor;
\r
4100 vertex[0].tow+=0.95f/TWin.VScaleFactor;
\r
4101 vertex[1].tow+=0.95f/TWin.VScaleFactor;
\r
4104 vertex[1].tow+=0.95f/TWin.VScaleFactor;
\r
4105 vertex[3].tow+=0.95f/TWin.VScaleFactor;
\r
4108 vertex[0].tow+=0.95f/TWin.VScaleFactor;
\r
4109 vertex[2].tow+=0.95f/TWin.VScaleFactor;
\r
4112 vertex[1].tow+=0.95f/TWin.VScaleFactor;
\r
4113 vertex[2].tow+=0.95f/TWin.VScaleFactor;
\r
4116 vertex[0].tow+=0.95f/TWin.VScaleFactor;
\r
4117 vertex[3].tow+=0.95f/TWin.VScaleFactor;
\r
4126 vertex[2].tow+=1.0f/ST_FAC;
\r
4127 vertex[3].tow+=1.0f/ST_FAC;
\r
4130 vertex[0].tow+=1.0f/ST_FAC;
\r
4131 vertex[1].tow+=1.0f/ST_FAC;
\r
4134 vertex[1].tow+=1.0f/ST_FAC;
\r
4135 vertex[3].tow+=1.0f/ST_FAC;
\r
4138 vertex[0].tow+=1.0f/ST_FAC;
\r
4139 vertex[2].tow+=1.0f/ST_FAC;
\r
4142 vertex[1].tow+=1.0f/ST_FAC;
\r
4143 vertex[2].tow+=1.0f/ST_FAC;
\r
4146 vertex[0].tow+=1.0f/ST_FAC;
\r
4147 vertex[3].tow+=1.0f/ST_FAC;
\r
4157 vertex[2].tow+=1.0f/TWin.VScaleFactor;
\r
4158 vertex[3].tow+=1.0f/TWin.VScaleFactor;
\r
4161 vertex[0].tow+=1.0f/TWin.VScaleFactor;
\r
4162 vertex[1].tow+=1.0f/TWin.VScaleFactor;
\r
4165 vertex[1].tow+=1.0f/TWin.VScaleFactor;
\r
4166 vertex[3].tow+=1.0f/TWin.VScaleFactor;
\r
4169 vertex[0].tow+=1.0f/TWin.VScaleFactor;
\r
4170 vertex[2].tow+=1.0f/TWin.VScaleFactor;
\r
4173 vertex[1].tow+=1.0f/TWin.VScaleFactor;
\r
4174 vertex[2].tow+=1.0f/TWin.VScaleFactor;
\r
4177 vertex[0].tow+=1.0f/TWin.VScaleFactor;
\r
4178 vertex[3].tow+=1.0f/TWin.VScaleFactor;
\r
4187 vertex[2].tow+=1.0f;
\r
4188 vertex[3].tow+=1.0f;
\r
4191 vertex[0].tow+=1.0f;
\r
4192 vertex[1].tow+=1.0f;
\r
4195 vertex[1].tow+=1.0f;
\r
4196 vertex[3].tow+=1.0f;
\r
4199 vertex[0].tow+=1.0f;
\r
4200 vertex[2].tow+=1.0f;
\r
4203 vertex[1].tow+=1.0f;
\r
4204 vertex[2].tow+=1.0f;
\r
4207 vertex[0].tow+=1.0f;
\r
4208 vertex[3].tow+=1.0f;
\r
4217 void primPolyFT4(u8 * baseAddr)
\r
4219 unsigned long *gpuData = ((unsigned long *) baseAddr);
\r
4220 short *sgpuData = ((short *) baseAddr);
\r
4222 lx0 = sgpuData[2];
\r
4223 ly0 = sgpuData[3];
\r
4224 lx1 = sgpuData[6];
\r
4225 ly1 = sgpuData[7];
\r
4226 lx2 = sgpuData[10];
\r
4227 ly2 = sgpuData[11];
\r
4228 lx3 = sgpuData[14];
\r
4229 ly3 = sgpuData[15];
\r
4231 if(offset4()) return;
\r
4233 gl_vy[0]=baseAddr[9];//((gpuData[2]>>8)&0xff);
\r
4234 gl_vy[1]=baseAddr[17];//((gpuData[4]>>8)&0xff);
\r
4235 gl_vy[2]=baseAddr[25];//((gpuData[6]>>8)&0xff);
\r
4236 gl_vy[3]=baseAddr[33];//((gpuData[8]>>8)&0xff);
\r
4238 gl_ux[0]=baseAddr[8];//(gpuData[2]&0xff);
\r
4239 gl_ux[1]=baseAddr[16];//(gpuData[4]&0xff);
\r
4240 gl_ux[2]=baseAddr[24];//(gpuData[6]&0xff);
\r
4241 gl_ux[3]=baseAddr[32];//(gpuData[8]&0xff);
\r
4243 UpdateGlobalTP((unsigned short)(gpuData[4]>>16));
\r
4244 ulClutID=(gpuData[2]>>16);
\r
4246 bDrawTextured = TRUE;
\r
4247 bDrawSmoothShaded = FALSE;
\r
4248 SetRenderState(gpuData[0]);
\r
4250 /* if(iOffscreenDrawing)
\r
4253 if(bDrawOffscreen4())
\r
4255 InvalidateTextureAreaEx();
\r
4256 SetRenderColor(gpuData[0]);
\r
4257 drawPoly4FT(baseAddr);
\r
4261 SetRenderMode(gpuData[0], TRUE);
\r
4269 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[3], &vertex[2]);
\r
4271 if(bDrawMultiPass)
\r
4273 SetSemiTransMulti(1);
\r
4274 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[3], &vertex[2]);
\r
4280 if(bUseMultiPass) SetOpaqueColor(gpuData[0]);
\r
4283 /* if(bSmallAlpha && iFilterType<=2)
\r
4285 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
\r
4286 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
\r
4287 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[3], &vertex[2]);
\r
4288 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
\r
4289 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
\r
4294 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[3], &vertex[2]);
\r
4298 iDrawnSomething=1;
\r
4301 ////////////////////////////////////////////////////////////////////////
\r
4302 // cmd: smooth shaded Texture3
\r
4303 ////////////////////////////////////////////////////////////////////////
\r
4305 void primPolyGT3(u8 *baseAddr)
\r
4307 unsigned long *gpuData = ((unsigned long *) baseAddr);
\r
4308 short *sgpuData = ((short *) baseAddr);
\r
4310 lx0 = sgpuData[2];
\r
4311 ly0 = sgpuData[3];
\r
4312 lx1 = sgpuData[8];
\r
4313 ly1 = sgpuData[9];
\r
4314 lx2 = sgpuData[14];
\r
4315 ly2 = sgpuData[15];
\r
4317 if(offset3()) return;
\r
4319 // do texture stuff
\r
4320 gl_ux[0]=gl_ux[3]=baseAddr[8];//gpuData[2]&0xff;
\r
4321 gl_vy[0]=gl_vy[3]=baseAddr[9];//(gpuData[2]>>8)&0xff;
\r
4322 gl_ux[1]=baseAddr[20];//gpuData[5]&0xff;
\r
4323 gl_vy[1]=baseAddr[21];//(gpuData[5]>>8)&0xff;
\r
4324 gl_ux[2]=baseAddr[32];//gpuData[8]&0xff;
\r
4325 gl_vy[2]=baseAddr[33];//(gpuData[8]>>8)&0xff;
\r
4327 UpdateGlobalTP((unsigned short)(gpuData[5]>>16));
\r
4328 ulClutID=(gpuData[2]>>16);
\r
4330 bDrawTextured = TRUE;
\r
4331 bDrawSmoothShaded = TRUE;
\r
4332 SetRenderState(gpuData[0]);
\r
4334 /* if(iOffscreenDrawing)
\r
4337 if(bDrawOffscreen3())
\r
4339 InvalidateTextureAreaEx();
\r
4340 drawPoly3GT(baseAddr);
\r
4344 SetRenderMode(gpuData[0], FALSE);
\r
4349 if(bDrawNonShaded)
\r
4351 //if(!bUseMultiPass) vertex[0].lcol=DoubleBGR2RGB(gpuData[0]); else vertex[0].lcol=gpuData[0];
\r
4353 /* if(bGLBlend) vertex[0].c.lcol=0x7f7f7f;
\r
4354 else */vertex[0].c.lcol=0xffffff;
\r
4355 vertex[0].c.col[3]=ubGloAlpha;
\r
4356 SETCOL(vertex[0]);
\r
4358 PRIMdrawTexturedTri(&vertex[0], &vertex[1], &vertex[2]);
\r
4364 PRIMdrawTexturedTri(&vertex[0], &vertex[1], &vertex[2]);
\r
4370 /* if(!bUseMultiPass && !bGLBlend)
\r
4372 */ vertex[0].c.lcol=DoubleBGR2RGB(gpuData[0]);
\r
4373 vertex[1].c.lcol=DoubleBGR2RGB(gpuData[3]);
\r
4374 vertex[2].c.lcol=DoubleBGR2RGB(gpuData[6]);
\r
4378 vertex[0].c.lcol=gpuData[0];
\r
4379 vertex[1].c.lcol=gpuData[3];
\r
4380 vertex[2].c.lcol=gpuData[6];
\r
4382 vertex[0].c.col[3]=vertex[1].c.col[3]=vertex[2].c.col[3]=ubGloAlpha;
\r
4384 PRIMdrawTexGouraudTriColor(&vertex[0], &vertex[1], &vertex[2]);
\r
4386 if(bDrawMultiPass)
\r
4388 SetSemiTransMulti(1);
\r
4389 PRIMdrawTexGouraudTriColor(&vertex[0], &vertex[1], &vertex[2]);
\r
4395 if(bUseMultiPass)
\r
4397 vertex[0].c.lcol=DoubleBGR2RGB(gpuData[0]);
\r
4398 vertex[1].c.lcol=DoubleBGR2RGB(gpuData[3]);
\r
4399 vertex[2].c.lcol=DoubleBGR2RGB(gpuData[6]);
\r
4400 vertex[0].c.col[3]=vertex[1].c.col[3]=vertex[2].c.col[3]=ubGloAlpha;
\r
4403 PRIMdrawTexGouraudTriColor(&vertex[0], &vertex[1], &vertex[2]);
\r
4407 iDrawnSomething=1;
\r
4410 ////////////////////////////////////////////////////////////////////////
\r
4411 // cmd: smooth shaded Poly3
\r
4412 ////////////////////////////////////////////////////////////////////////
\r
4414 void primPolyG3(u8 *baseAddr)
\r
4416 unsigned long *gpuData = ((unsigned long *) baseAddr);
\r
4417 short *sgpuData = ((short *) baseAddr);
\r
4419 lx0 = sgpuData[2];
\r
4420 ly0 = sgpuData[3];
\r
4421 lx1 = sgpuData[6];
\r
4422 ly1 = sgpuData[7];
\r
4423 lx2 = sgpuData[10];
\r
4424 ly2 = sgpuData[11];
\r
4426 if(offset3()) return;
\r
4428 bDrawTextured = FALSE;
\r
4429 bDrawSmoothShaded = TRUE;
\r
4430 SetRenderState(gpuData[0]);
\r
4432 /* if(iOffscreenDrawing)
\r
4435 if(bDrawOffscreen3())
\r
4437 InvalidateTextureAreaEx();
\r
4438 drawPoly3G(gpuData[0], gpuData[2], gpuData[4]);
\r
4442 SetRenderMode(gpuData[0], FALSE);
\r
4445 vertex[0].c.lcol=gpuData[0];
\r
4446 vertex[1].c.lcol=gpuData[2];
\r
4447 vertex[2].c.lcol=gpuData[4];
\r
4448 vertex[0].c.col[3]=vertex[1].c.col[3]=vertex[2].c.col[3]=ubGloColAlpha;
\r
4450 PRIMdrawGouraudTriColor(&vertex[0], &vertex[1], &vertex[2]);
\r
4452 iDrawnSomething=1;
\r
4455 ////////////////////////////////////////////////////////////////////////
\r
4456 // cmd: smooth shaded Texture4
\r
4457 ////////////////////////////////////////////////////////////////////////
\r
4459 void primPolyGT4(u8 *baseAddr)
\r
4461 unsigned long *gpuData = ((unsigned long *) baseAddr);
\r
4462 short *sgpuData = ((short *) baseAddr);
\r
4464 lx0 = sgpuData[2];
\r
4465 ly0 = sgpuData[3];
\r
4466 lx1 = sgpuData[8];
\r
4467 ly1 = sgpuData[9];
\r
4468 lx2 = sgpuData[14];
\r
4469 ly2 = sgpuData[15];
\r
4470 lx3 = sgpuData[20];
\r
4471 ly3 = sgpuData[21];
\r
4473 if(offset4()) return;
\r
4475 // do texture stuff
\r
4476 gl_ux[0]=baseAddr[8];//gpuData[2]&0xff;
\r
4477 gl_vy[0]=baseAddr[9];//(gpuData[2]>>8)&0xff;
\r
4478 gl_ux[1]=baseAddr[20];//gpuData[5]&0xff;
\r
4479 gl_vy[1]=baseAddr[21];//(gpuData[5]>>8)&0xff;
\r
4480 gl_ux[2]=baseAddr[32];//gpuData[8]&0xff;
\r
4481 gl_vy[2]=baseAddr[33];//(gpuData[8]>>8)&0xff;
\r
4482 gl_ux[3]=baseAddr[44];//gpuData[11]&0xff;
\r
4483 gl_vy[3]=baseAddr[45];//(gpuData[11]>>8)&0xff;
\r
4485 UpdateGlobalTP((unsigned short)(gpuData[5]>>16));
\r
4486 ulClutID=(gpuData[2]>>16);
\r
4488 bDrawTextured = TRUE;
\r
4489 bDrawSmoothShaded = TRUE;
\r
4490 SetRenderState(gpuData[0]);
\r
4492 /* if(iOffscreenDrawing)
\r
4495 if(bDrawOffscreen4())
\r
4497 InvalidateTextureAreaEx();
\r
4498 drawPoly4GT(baseAddr);
\r
4502 SetRenderMode(gpuData[0], FALSE);
\r
4509 if(bDrawNonShaded)
\r
4511 //if(!bUseMultiPass) vertex[0].lcol=DoubleBGR2RGB(gpuData[0]); else vertex[0].lcol=gpuData[0];
\r
4512 /* if(bGLBlend) vertex[0].c.lcol=0x7f7f7f;
\r
4513 else */vertex[0].c.lcol=0xffffff;
\r
4514 vertex[0].c.col[3]=ubGloAlpha;
\r
4515 SETCOL(vertex[0]);
\r
4517 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[3], &vertex[2]);
\r
4522 ubGloAlpha=ubGloColAlpha=0xff;
\r
4524 PRIMdrawTexturedQuad(&vertex[0], &vertex[1], &vertex[3], &vertex[2]);
\r
4530 // if(!bUseMultiPass && !bGLBlend)
\r
4532 vertex[0].c.lcol=DoubleBGR2RGB(gpuData[0]);
\r
4533 vertex[1].c.lcol=DoubleBGR2RGB(gpuData[3]);
\r
4534 vertex[2].c.lcol=DoubleBGR2RGB(gpuData[6]);
\r
4535 vertex[3].c.lcol=DoubleBGR2RGB(gpuData[9]);
\r
4539 vertex[0].c.lcol=gpuData[0];
\r
4540 vertex[1].c.lcol=gpuData[3];
\r
4541 vertex[2].c.lcol=gpuData[6];
\r
4542 vertex[3].c.lcol=gpuData[9];
\r
4545 vertex[0].c.col[3]=vertex[1].c.col[3]=vertex[2].c.col[3]=vertex[3].c.col[3]=ubGloAlpha;
\r
4547 PRIMdrawTexGouraudTriColorQuad(&vertex[0], &vertex[1], &vertex[3],&vertex[2]);
\r
4549 if(bDrawMultiPass)
\r
4551 SetSemiTransMulti(1);
\r
4552 PRIMdrawTexGouraudTriColorQuad(&vertex[0], &vertex[1], &vertex[3],&vertex[2]);
\r
4558 if(bUseMultiPass)
\r
4560 vertex[0].c.lcol=DoubleBGR2RGB(gpuData[0]);
\r
4561 vertex[1].c.lcol=DoubleBGR2RGB(gpuData[3]);
\r
4562 vertex[2].c.lcol=DoubleBGR2RGB(gpuData[6]);
\r
4563 vertex[3].c.lcol=DoubleBGR2RGB(gpuData[9]);
\r
4564 vertex[0].c.col[3]=vertex[1].c.col[3]=vertex[2].c.col[3]=vertex[3].c.col[3]=ubGloAlpha;
\r
4566 ubGloAlpha=ubGloColAlpha=0xff;
\r
4568 PRIMdrawTexGouraudTriColorQuad(&vertex[0], &vertex[1], &vertex[3],&vertex[2]);
\r
4572 iDrawnSomething=1;
\r
4575 ////////////////////////////////////////////////////////////////////////
\r
4576 // cmd: smooth shaded Poly3
\r
4577 ////////////////////////////////////////////////////////////////////////
\r
4579 void primPolyF3(u8 *baseAddr)
\r
4581 unsigned long *gpuData = ((unsigned long *) baseAddr);
\r
4582 short *sgpuData = ((short *) baseAddr);
\r
4584 lx0 = sgpuData[2];
\r
4585 ly0 = sgpuData[3];
\r
4586 lx1 = sgpuData[4];
\r
4587 ly1 = sgpuData[5];
\r
4588 lx2 = sgpuData[6];
\r
4589 ly2 = sgpuData[7];
\r
4591 if(offset3()) return;
\r
4593 bDrawTextured = FALSE;
\r
4594 bDrawSmoothShaded = FALSE;
\r
4595 SetRenderState(gpuData[0]);
\r
4597 /* if(iOffscreenDrawing)
\r
4600 if(bDrawOffscreen3())
\r
4602 InvalidateTextureAreaEx();
\r
4603 drawPoly3F(gpuData[0]);
\r
4607 SetRenderMode(gpuData[0], FALSE);
\r
4610 vertex[0].c.lcol=gpuData[0];
\r
4611 vertex[0].c.col[3]=ubGloColAlpha;
\r
4612 SETCOL(vertex[0]);
\r
4614 PRIMdrawTri(&vertex[0], &vertex[1], &vertex[2]);
\r
4616 iDrawnSomething=1;
\r
4619 ////////////////////////////////////////////////////////////////////////
\r
4620 // cmd: skipping shaded polylines
\r
4621 ////////////////////////////////////////////////////////////////////////
\r
4623 void primLineGSkip(u8 *baseAddr)
\r
4625 unsigned long *gpuData = ((unsigned long *) baseAddr);
\r
4626 short *sgpuData = ((short *) baseAddr);
\r
4630 lx1 = sgpuData[2];
\r
4631 ly1 = sgpuData[3];
\r
4633 while(!(((gpuData[i] & 0xF000F000) == 0x50005000) && i>=4))
\r
4637 ly1 = (short)((gpuData[i]>>16) & 0xffff);
\r
4638 lx1 = (short)(gpuData[i] & 0xffff);
\r
4640 i++;if(i>iMax) break;
\r
4644 ////////////////////////////////////////////////////////////////////////
\r
4645 // cmd: shaded polylines
\r
4646 ////////////////////////////////////////////////////////////////////////
\r
4648 void primLineGEx(u8 *baseAddr)
\r
4650 unsigned long *gpuData = ((unsigned long *) baseAddr);
\r
4652 short cx0,cx1,cy0,cy1;int i;BOOL bDraw=TRUE;
\r
4654 bDrawTextured = FALSE;
\r
4655 bDrawSmoothShaded = TRUE;
\r
4656 SetRenderState(gpuData[0]);
\r
4657 SetRenderMode(gpuData[0], FALSE);
\r
4660 vertex[0].c.lcol=vertex[3].c.lcol=gpuData[0];
\r
4661 vertex[0].c.col[3]=vertex[3].c.col[3]=ubGloColAlpha;
\r
4662 ly1 = (short)((gpuData[1]>>16) & 0xffff);
\r
4663 lx1 = (short)(gpuData[1] & 0xffff);
\r
4667 //while((gpuData[i]>>24)!=0x55)
\r
4668 //while((gpuData[i]&0x50000000)!=0x50000000)
\r
4669 // currently best way to check for poly line end:
\r
4670 while(!(((gpuData[i] & 0xF000F000) == 0x50005000) && i>=4))
\r
4672 ly0 = ly1;lx0=lx1;
\r
4673 vertex[1].c.lcol=vertex[2].c.lcol=vertex[0].c.lcol;
\r
4674 vertex[0].c.lcol=vertex[3].c.lcol=gpuData[i];
\r
4675 vertex[0].c.col[3]=vertex[3].c.col[3]=ubGloColAlpha;
\r
4679 ly1 = (short)((gpuData[i]>>16) & 0xffff);
\r
4680 lx1 = (short)(gpuData[i] & 0xffff);
\r
4682 if(offsetline()) bDraw=FALSE; else bDraw=TRUE;
\r
4684 if (bDraw && ((lx0 != lx1) || (ly0 != ly1)))
\r
4686 /* if(iOffscreenDrawing)
\r
4688 cx0=lx0;cx1=lx1;cy0=ly0;cy1=ly1;
\r
4690 if(bDrawOffscreen4())
\r
4692 InvalidateTextureAreaEx();
\r
4693 drawPoly4G(gpuData[i-3],gpuData[i-1],gpuData[i-3],gpuData[i-1]);
\r
4695 lx0=cx0;lx1=cx1;ly0=cy0;ly1=cy1;
\r
4698 PRIMdrawGouraudLine(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
4705 iDrawnSomething=1;
\r
4708 ////////////////////////////////////////////////////////////////////////
\r
4709 // cmd: shaded polyline2
\r
4710 ////////////////////////////////////////////////////////////////////////
\r
4712 void primLineG2(u8 *baseAddr)
\r
4714 unsigned long *gpuData = ((unsigned long *) baseAddr);
\r
4715 short *sgpuData = ((short *) baseAddr);
\r
4717 lx0 = sgpuData[2];
\r
4718 ly0 = sgpuData[3];
\r
4719 lx1 = sgpuData[6];
\r
4720 ly1 = sgpuData[7];
\r
4722 vertex[0].c.lcol=vertex[3].c.lcol=gpuData[0];
\r
4723 vertex[1].c.lcol=vertex[2].c.lcol=gpuData[2];
\r
4724 vertex[0].c.col[3]=vertex[1].c.col[3]=vertex[2].c.col[3]=vertex[3].c.col[3]=ubGloColAlpha;
\r
4726 bDrawTextured = FALSE;
\r
4727 bDrawSmoothShaded = TRUE;
\r
4729 if((lx0 == lx1) && (ly0 == ly1)) return;
\r
4731 if(offsetline()) return;
\r
4733 SetRenderState(gpuData[0]);
\r
4734 SetRenderMode(gpuData[0], FALSE);
\r
4737 /* if(iOffscreenDrawing)
\r
4740 if(bDrawOffscreen4())
\r
4742 InvalidateTextureAreaEx();
\r
4743 drawPoly4G(gpuData[0],gpuData[2],gpuData[0],gpuData[2]);
\r
4747 //if(ClipVertexList4())
\r
4748 PRIMdrawGouraudLine(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
4750 iDrawnSomething=1;
\r
4753 ////////////////////////////////////////////////////////////////////////
\r
4754 // cmd: skipping flat polylines
\r
4755 ////////////////////////////////////////////////////////////////////////
\r
4757 void primLineFSkip(u8 *baseAddr)
\r
4759 unsigned long *gpuData = ((unsigned long *) baseAddr);
\r
4762 ly1 = (short)((gpuData[1]>>16) & 0xffff);
\r
4763 lx1 = (short)(gpuData[1] & 0xffff);
\r
4765 while(!(((gpuData[i] & 0xF000F000) == 0x50005000) && i>=3))
\r
4767 ly1 = (short)((gpuData[i]>>16) & 0xffff);
\r
4768 lx1 = (short)(gpuData[i] & 0xffff);
\r
4769 i++;if(i>iMax) break;
\r
4773 ////////////////////////////////////////////////////////////////////////
\r
4774 // cmd: drawing flat polylines
\r
4775 ////////////////////////////////////////////////////////////////////////
\r
4777 void primLineFEx(u8 *baseAddr)
\r
4779 unsigned long *gpuData = ((unsigned long *) baseAddr);
\r
4781 short cx0,cx1,cy0,cy1;int i;
\r
4785 bDrawTextured = FALSE;
\r
4786 bDrawSmoothShaded = FALSE;
\r
4787 SetRenderState(gpuData[0]);
\r
4788 SetRenderMode(gpuData[0], FALSE);
\r
4791 vertex[0].c.lcol=gpuData[0];
\r
4792 vertex[0].c.col[3]=ubGloColAlpha;
\r
4794 ly1 = (short)((gpuData[1]>>16) & 0xffff);
\r
4795 lx1 = (short)(gpuData[1] & 0xffff);
\r
4799 // while(!(gpuData[i]&0x40000000))
\r
4800 // while((gpuData[i]>>24)!=0x55)
\r
4801 // while((gpuData[i]&0x50000000)!=0x50000000)
\r
4802 // currently best way to check for poly line end:
\r
4803 while(!(((gpuData[i] & 0xF000F000) == 0x50005000) && i>=3))
\r
4805 ly0 = ly1;lx0=lx1;
\r
4806 ly1 = (short)((gpuData[i]>>16) & 0xffff);
\r
4807 lx1 = (short)(gpuData[i] & 0xffff);
\r
4811 /* if(iOffscreenDrawing)
\r
4813 cx0=lx0;cx1=lx1;cy0=ly0;cy1=ly1;
\r
4815 if(bDrawOffscreen4())
\r
4817 InvalidateTextureAreaEx();
\r
4818 drawPoly4F(gpuData[0]);
\r
4820 lx0=cx0;lx1=cx1;ly0=cy0;ly1=cy1;
\r
4822 PRIMdrawFlatLine(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
4825 i++;if(i>iMax) break;
\r
4828 iDrawnSomething=1;
\r
4831 ////////////////////////////////////////////////////////////////////////
\r
4832 // cmd: drawing flat polyline2
\r
4833 ////////////////////////////////////////////////////////////////////////
\r
4835 void primLineF2(u8 *baseAddr)
\r
4837 unsigned long *gpuData = ((unsigned long *) baseAddr);
\r
4838 short *sgpuData = ((short *) baseAddr);
\r
4840 lx0 = sgpuData[2];
\r
4841 ly0 = sgpuData[3];
\r
4842 lx1 = sgpuData[4];
\r
4843 ly1 = sgpuData[5];
\r
4845 if(offsetline()) return;
\r
4847 bDrawTextured = FALSE;
\r
4848 bDrawSmoothShaded = FALSE;
\r
4849 SetRenderState(gpuData[0]);
\r
4850 SetRenderMode(gpuData[0], FALSE);
\r
4853 vertex[0].c.lcol=gpuData[0];
\r
4854 vertex[0].c.col[3]=ubGloColAlpha;
\r
4856 /* if(iOffscreenDrawing)
\r
4859 if(bDrawOffscreen4())
\r
4861 InvalidateTextureAreaEx();
\r
4862 drawPoly4F(gpuData[0]);
\r
4866 //if(ClipVertexList4())
\r
4867 PRIMdrawFlatLine(&vertex[0], &vertex[1], &vertex[2], &vertex[3]);
\r
4869 iDrawnSomething=1;
\r
4872 ////////////////////////////////////////////////////////////////////////
\r
4873 // cmd: well, easiest command... not implemented
\r
4874 ////////////////////////////////////////////////////////////////////////
\r
4876 void primNI(u8 *bA)
\r
4880 ////////////////////////////////////////////////////////////////////////
\r
4881 // cmd func ptr table
\r
4882 ////////////////////////////////////////////////////////////////////////
\r
4884 void (*primTableJ[256])(u8 *) =
\r
4887 primNI,primNI,primBlkFill,primNI,primNI,primNI,primNI,primNI,
\r
4889 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4891 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4893 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4895 primPolyF3,primPolyF3,primPolyF3,primPolyF3,primPolyFT3,primPolyFT3,primPolyFT3,primPolyFT3,
\r
4897 primPolyF4,primPolyF4,primPolyF4,primPolyF4,primPolyFT4,primPolyFT4,primPolyFT4,primPolyFT4,
\r
4899 primPolyG3,primPolyG3,primPolyG3,primPolyG3,primPolyGT3,primPolyGT3,primPolyGT3,primPolyGT3,
\r
4901 primPolyG4,primPolyG4,primPolyG4,primPolyG4,primPolyGT4,primPolyGT4,primPolyGT4,primPolyGT4,
\r
4903 primLineF2,primLineF2,primLineF2,primLineF2,primNI,primNI,primNI,primNI,
\r
4905 primLineFEx,primLineFEx,primLineFEx,primLineFEx,primLineFEx,primLineFEx,primLineFEx,primLineFEx,
\r
4907 primLineG2,primLineG2,primLineG2,primLineG2,primNI,primNI,primNI,primNI,
\r
4909 primLineGEx,primLineGEx,primLineGEx,primLineGEx,primLineGEx,primLineGEx,primLineGEx,primLineGEx,
\r
4911 primTileS,primTileS,primTileS,primTileS,primSprtS,primSprtS,primSprtS,primSprtS,
\r
4913 primTile1,primTile1,primTile1,primTile1,primNI,primNI,primNI,primNI,
\r
4915 primTile8,primTile8,primTile8,primTile8,primSprt8,primSprt8,primSprt8,primSprt8,
\r
4917 primTile16,primTile16,primTile16,primTile16,primSprt16,primSprt16,primSprt16,primSprt16,
\r
4919 primMoveImage,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4921 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4923 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4925 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4927 primLoadImage,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4929 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4931 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4933 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4935 primStoreImage,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4937 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4939 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4941 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4943 primNI,cmdTexturePage,cmdTextureWindow,cmdDrawAreaStart,cmdDrawAreaEnd,cmdDrawOffset,cmdSTP,primNI,
\r
4945 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4947 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4949 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI
\r
4952 ////////////////////////////////////////////////////////////////////////
\r
4953 // cmd func ptr table for skipping
\r
4954 ////////////////////////////////////////////////////////////////////////
\r
4956 void (*primTableSkip[256])(u8 *) =
\r
4959 primNI,primNI,primBlkFill,primNI,primNI,primNI,primNI,primNI,
\r
4961 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4963 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4965 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4967 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4969 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4971 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4973 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4975 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4977 primLineFSkip,primLineFSkip,primLineFSkip,primLineFSkip,primLineFSkip,primLineFSkip,primLineFSkip,primLineFSkip,
\r
4979 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4981 primLineGSkip,primLineGSkip,primLineGSkip,primLineGSkip,primLineGSkip,primLineGSkip,primLineGSkip,primLineGSkip,
\r
4983 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4985 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4987 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4989 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4991 primMoveImage,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4993 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4995 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4997 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
4999 primLoadImage,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
5001 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
5003 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
5005 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
5007 primStoreImage,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
5009 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
5011 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
5013 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
5015 primNI,cmdTexturePage,cmdTextureWindow,cmdDrawAreaStart,cmdDrawAreaEnd,cmdDrawOffset,cmdSTP,primNI,
\r
5017 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
5019 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI,
\r
5021 primNI,primNI,primNI,primNI,primNI,primNI,primNI,primNI
\r