1 /***************************************************************************
4 begin : Sun Oct 28 2001
5 copyright : (C) 2001 by Pete Bernert
6 email : BlackDove@addcom.de
7 ***************************************************************************/
8 /***************************************************************************
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. See also the license.txt file for *
14 * additional informations. *
16 ***************************************************************************/
18 // switches for painting textured quads as 2 triangles (small glitches, but better shading!)
19 // can be toggled by game fix 0x200 in version 1.17 anyway, so let the defines enabled!
23 // fast solid loops... a bit more additional code, of course
26 // psx blending mode 3 with 25% incoming color (instead 50% without the define)
27 #define HALFBRIGHTMODE3
29 // color decode defines
31 #define XCOL1(x) (x & 0x1f)
32 #define XCOL2(x) (x & 0x3e0)
33 #define XCOL3(x) (x & 0x7c00)
35 #define XCOL1D(x) (x & 0x1f)
36 #define XCOL2D(x) ((x>>5) & 0x1f)
37 #define XCOL3D(x) ((x>>10) & 0x1f)
39 #define X32TCOL1(x) ((x & 0x001f001f)<<7)
40 #define X32TCOL2(x) ((x & 0x03e003e0)<<2)
41 #define X32TCOL3(x) ((x & 0x7c007c00)>>3)
43 #define X32COL1(x) (x & 0x001f001f)
44 #define X32COL2(x) ((x>>5) & 0x001f001f)
45 #define X32COL3(x) ((x>>10) & 0x001f001f)
47 #define X32ACOL1(x) (x & 0x001e001e)
48 #define X32ACOL2(x) ((x>>5) & 0x001e001e)
49 #define X32ACOL3(x) ((x>>10) & 0x001e001e)
51 #define X32BCOL1(x) (x & 0x001c001c)
52 #define X32BCOL2(x) ((x>>5) & 0x001c001c)
53 #define X32BCOL3(x) ((x>>10) & 0x001c001c)
55 #define X32PSXCOL(r,g,b) ((g<<10)|(b<<5)|r)
57 #define XPSXCOL(r,g,b) ((g&0x7c00)|(b&0x3e0)|(r&0x1f))
60 short g_m1=255,g_m2=255,g_m3=255;
61 short DrawSemiTrans=FALSE;
64 short ly0,lx0,ly1,lx1,ly2,lx2,ly3,lx3; // global psx vertex coords
65 int32_t GlobalTextAddrX,GlobalTextAddrY,GlobalTextTP,GlobalTextIL;
66 int32_t GlobalTextREST,GlobalTextABR,GlobalTextPAGE;
68 ////////////////////////////////////////////////////////////////////////
69 // POLYGON OFFSET FUNCS
70 ////////////////////////////////////////////////////////////////////////
72 static void offsetPSX2(void)
74 lx0 += PSXDisplay.DrawOffset.x;
75 ly0 += PSXDisplay.DrawOffset.y;
76 lx1 += PSXDisplay.DrawOffset.x;
77 ly1 += PSXDisplay.DrawOffset.y;
80 static void offsetPSX3(void)
82 lx0 += PSXDisplay.DrawOffset.x;
83 ly0 += PSXDisplay.DrawOffset.y;
84 lx1 += PSXDisplay.DrawOffset.x;
85 ly1 += PSXDisplay.DrawOffset.y;
86 lx2 += PSXDisplay.DrawOffset.x;
87 ly2 += PSXDisplay.DrawOffset.y;
90 static void offsetPSX4(void)
92 lx0 += PSXDisplay.DrawOffset.x;
93 ly0 += PSXDisplay.DrawOffset.y;
94 lx1 += PSXDisplay.DrawOffset.x;
95 ly1 += PSXDisplay.DrawOffset.y;
96 lx2 += PSXDisplay.DrawOffset.x;
97 ly2 += PSXDisplay.DrawOffset.y;
98 lx3 += PSXDisplay.DrawOffset.x;
99 ly3 += PSXDisplay.DrawOffset.y;
102 /////////////////////////////////////////////////////////////////
103 /////////////////////////////////////////////////////////////////
104 /////////////////////////////////////////////////////////////////
106 ////////////////////////////////////////////////////////////////////////
107 /////////////////////////////////////////////////////////////////
108 /////////////////////////////////////////////////////////////////
111 unsigned char dithertable[16] =
119 static inline void Dither16(unsigned short * pdest,uint32_t r,uint32_t g,uint32_t b,unsigned short sM)
122 unsigned char rlow, glow, blow;
129 coeff = dithertable[(y&3)*4+(x&3)];
131 rlow = r&7; glow = g&7; blow = b&7;
135 if ((r < 0x1F) && rlow > coeff) r++;
136 if ((g < 0x1F) && glow > coeff) g++;
137 if ((b < 0x1F) && blow > coeff) b++;
139 PUTLE16(pdest, ((unsigned short)b<<10) |
140 ((unsigned short)g<<5) |
141 (unsigned short)r | sM);
144 /////////////////////////////////////////////////////////////////
145 /////////////////////////////////////////////////////////////////
146 /////////////////////////////////////////////////////////////////
148 static inline void GetShadeTransCol_Dither(unsigned short * pdest, int32_t m1, int32_t m2, int32_t m3)
152 if(bCheckMask && (*pdest & HOST2LE16(0x8000))) return;
156 r=((XCOL1D(GETLE16(pdest)))<<3);
157 b=((XCOL2D(GETLE16(pdest)))<<3);
158 g=((XCOL3D(GETLE16(pdest)))<<3);
179 if(r&0x80000000) r=0;
180 if(b&0x80000000) b=0;
181 if(g&0x80000000) g=0;
185 #ifdef HALFBRIGHTMODE3
203 if(r&0x7FFFFF00) r=0xff;
204 if(b&0x7FFFFF00) b=0xff;
205 if(g&0x7FFFFF00) g=0xff;
207 Dither16(pdest,r,b,g,sSetMask);
210 ////////////////////////////////////////////////////////////////////////
212 static inline void GetShadeTransCol(unsigned short * pdest,unsigned short color)
214 if(bCheckMask && (*pdest & HOST2LE16(0x8000))) return;
222 PUTLE16(pdest, (((GETLE16(pdest)&0x7bde)>>1)+(((color)&0x7bde)>>1))|sSetMask);//0x8000;
228 r=(XCOL1(GETLE16(pdest)))+((XCOL1(color)));
229 b=(XCOL2(GETLE16(pdest)))+((XCOL2(color)));
230 g=(XCOL3(GETLE16(pdest)))+((XCOL3(color)));
235 r=(XCOL1(GETLE16(pdest)))-((XCOL1(color)));
236 b=(XCOL2(GETLE16(pdest)))-((XCOL2(color)));
237 g=(XCOL3(GETLE16(pdest)))-((XCOL3(color)));
238 if(r&0x80000000) r=0;
239 if(b&0x80000000) b=0;
240 if(g&0x80000000) g=0;
244 #ifdef HALFBRIGHTMODE3
245 r=(XCOL1(GETLE16(pdest)))+((XCOL1(color))>>2);
246 b=(XCOL2(GETLE16(pdest)))+((XCOL2(color))>>2);
247 g=(XCOL3(GETLE16(pdest)))+((XCOL3(color))>>2);
249 r=(XCOL1(GETLE16(pdest)))+((XCOL1(color))>>1);
250 b=(XCOL2(GETLE16(pdest)))+((XCOL2(color))>>1);
251 g=(XCOL3(GETLE16(pdest)))+((XCOL3(color))>>1);
255 if(r&0x7FFFFFE0) r=0x1f;
256 if(b&0x7FFFFC00) b=0x3e0;
257 if(g&0x7FFF8000) g=0x7c00;
259 PUTLE16(pdest, (XPSXCOL(r,g,b))|sSetMask);//0x8000;
261 else PUTLE16(pdest, color|sSetMask);
264 ////////////////////////////////////////////////////////////////////////
266 static inline void GetShadeTransCol32(uint32_t * pdest,uint32_t color)
276 PUTLE32(pdest, (((GETLE32(pdest)&0x7bde7bde)>>1)+(((color)&0x7bde7bde)>>1))|lSetMask);//0x80008000;
279 r=(X32ACOL1(GETLE32(pdest))>>1)+((X32ACOL1(color))>>1);
280 b=(X32ACOL2(GETLE32(pdest))>>1)+((X32ACOL2(color))>>1);
281 g=(X32ACOL3(GETLE32(pdest))>>1)+((X32ACOL3(color))>>1);
286 r=(X32COL1(GETLE32(pdest)))+((X32COL1(color)));
287 b=(X32COL2(GETLE32(pdest)))+((X32COL2(color)));
288 g=(X32COL3(GETLE32(pdest)))+((X32COL3(color)));
293 int32_t sr,sb,sg,src,sbc,sgc,c;
294 src=XCOL1(color);sbc=XCOL2(color);sgc=XCOL3(color);
295 c=GETLE32(pdest)>>16;
296 sr=(XCOL1(c))-src; if(sr&0x8000) sr=0;
297 sb=(XCOL2(c))-sbc; if(sb&0x8000) sb=0;
298 sg=(XCOL3(c))-sgc; if(sg&0x8000) sg=0;
299 r=((int32_t)sr)<<16;b=((int32_t)sb)<<11;g=((int32_t)sg)<<6;
300 c=LOWORD(GETLE32(pdest));
301 sr=(XCOL1(c))-src; if(sr&0x8000) sr=0;
302 sb=(XCOL2(c))-sbc; if(sb&0x8000) sb=0;
303 sg=(XCOL3(c))-sgc; if(sg&0x8000) sg=0;
304 r|=sr;b|=sb>>5;g|=sg>>10;
308 #ifdef HALFBRIGHTMODE3
309 r=(X32COL1(GETLE32(pdest)))+((X32BCOL1(color))>>2);
310 b=(X32COL2(GETLE32(pdest)))+((X32BCOL2(color))>>2);
311 g=(X32COL3(GETLE32(pdest)))+((X32BCOL3(color))>>2);
313 r=(X32COL1(GETLE32(pdest)))+((X32ACOL1(color))>>1);
314 b=(X32COL2(GETLE32(pdest)))+((X32ACOL2(color))>>1);
315 g=(X32COL3(GETLE32(pdest)))+((X32ACOL3(color))>>1);
319 if(r&0x7FE00000) r=0x1f0000|(r&0xFFFF);
320 if(r&0x7FE0) r=0x1f |(r&0xFFFF0000);
321 if(b&0x7FE00000) b=0x1f0000|(b&0xFFFF);
322 if(b&0x7FE0) b=0x1f |(b&0xFFFF0000);
323 if(g&0x7FE00000) g=0x1f0000|(g&0xFFFF);
324 if(g&0x7FE0) g=0x1f |(g&0xFFFF0000);
328 uint32_t ma=GETLE32(pdest);
329 PUTLE32(pdest, (X32PSXCOL(r,g,b))|lSetMask);//0x80008000;
330 if(ma&0x80000000) PUTLE32(pdest, (ma&0xFFFF0000)|(*pdest&0xFFFF));
331 if(ma&0x00008000) PUTLE32(pdest, (ma&0xFFFF) |(*pdest&0xFFFF0000));
334 PUTLE32(pdest, (X32PSXCOL(r,g,b))|lSetMask);//0x80008000;
340 uint32_t ma=GETLE32(pdest);
341 PUTLE32(pdest, color|lSetMask);//0x80008000;
342 if(ma&0x80000000) PUTLE32(pdest, (ma&0xFFFF0000)|(GETLE32(pdest)&0xFFFF));
343 if(ma&0x00008000) PUTLE32(pdest, (ma&0xFFFF) |(GETLE32(pdest)&0xFFFF0000));
347 PUTLE32(pdest, color|lSetMask);//0x80008000;
351 ////////////////////////////////////////////////////////////////////////
353 static inline void GetTextureTransColG(unsigned short * pdest,unsigned short color)
355 int32_t r,g,b;unsigned short l;
359 if(bCheckMask && (*pdest & HOST2LE16(0x8000))) return;
361 l=sSetMask|(color&0x8000);
363 if(DrawSemiTrans && (color&0x8000))
368 d =(GETLE16(pdest)&0x7bde)>>1;
369 color =((color) &0x7bde)>>1;
370 r=(XCOL1(d))+((((XCOL1(color)))* g_m1)>>7);
371 b=(XCOL2(d))+((((XCOL2(color)))* g_m2)>>7);
372 g=(XCOL3(d))+((((XCOL3(color)))* g_m3)>>7);
377 r=(XCOL1(GETLE16(pdest)))+((((XCOL1(color)))* g_m1)>>7);
378 b=(XCOL2(GETLE16(pdest)))+((((XCOL2(color)))* g_m2)>>7);
379 g=(XCOL3(GETLE16(pdest)))+((((XCOL3(color)))* g_m3)>>7);
384 r=(XCOL1(GETLE16(pdest)))-((((XCOL1(color)))* g_m1)>>7);
385 b=(XCOL2(GETLE16(pdest)))-((((XCOL2(color)))* g_m2)>>7);
386 g=(XCOL3(GETLE16(pdest)))-((((XCOL3(color)))* g_m3)>>7);
387 if(r&0x80000000) r=0;
388 if(b&0x80000000) b=0;
389 if(g&0x80000000) g=0;
393 #ifdef HALFBRIGHTMODE3
394 r=(XCOL1(GETLE16(pdest)))+((((XCOL1(color))>>2)* g_m1)>>7);
395 b=(XCOL2(GETLE16(pdest)))+((((XCOL2(color))>>2)* g_m2)>>7);
396 g=(XCOL3(GETLE16(pdest)))+((((XCOL3(color))>>2)* g_m3)>>7);
398 r=(XCOL1(GETLE16(pdest)))+((((XCOL1(color))>>1)* g_m1)>>7);
399 b=(XCOL2(GETLE16(pdest)))+((((XCOL2(color))>>1)* g_m2)>>7);
400 g=(XCOL3(GETLE16(pdest)))+((((XCOL3(color))>>1)* g_m3)>>7);
406 r=((XCOL1(color))* g_m1)>>7;
407 b=((XCOL2(color))* g_m2)>>7;
408 g=((XCOL3(color))* g_m3)>>7;
411 if(r&0x7FFFFFE0) r=0x1f;
412 if(b&0x7FFFFC00) b=0x3e0;
413 if(g&0x7FFF8000) g=0x7c00;
415 PUTLE16(pdest, (XPSXCOL(r,g,b))|l);
418 ////////////////////////////////////////////////////////////////////////
420 static inline void GetTextureTransColG_S(unsigned short * pdest,unsigned short color)
422 int32_t r,g,b;unsigned short l;
426 l=sSetMask|(color&0x8000);
428 r=((XCOL1(color))* g_m1)>>7;
429 b=((XCOL2(color))* g_m2)>>7;
430 g=((XCOL3(color))* g_m3)>>7;
432 if(r&0x7FFFFFE0) r=0x1f;
433 if(b&0x7FFFFC00) b=0x3e0;
434 if(g&0x7FFF8000) g=0x7c00;
436 PUTLE16(pdest, (XPSXCOL(r,g,b))|l);
439 ////////////////////////////////////////////////////////////////////////
441 static inline void GetTextureTransColG_SPR(unsigned short * pdest,unsigned short color)
443 int32_t r,g,b;unsigned short l;
447 if(bCheckMask && (GETLE16(pdest) & 0x8000)) return;
449 l=sSetMask|(color&0x8000);
451 if(DrawSemiTrans && (color&0x8000))
456 d =(GETLE16(pdest)&0x7bde)>>1;
457 color =((color) &0x7bde)>>1;
458 r=(XCOL1(d))+((((XCOL1(color)))* g_m1)>>7);
459 b=(XCOL2(d))+((((XCOL2(color)))* g_m2)>>7);
460 g=(XCOL3(d))+((((XCOL3(color)))* g_m3)>>7);
465 r=(XCOL1(GETLE16(pdest)))+((((XCOL1(color)))* g_m1)>>7);
466 b=(XCOL2(GETLE16(pdest)))+((((XCOL2(color)))* g_m2)>>7);
467 g=(XCOL3(GETLE16(pdest)))+((((XCOL3(color)))* g_m3)>>7);
472 r=(XCOL1(GETLE16(pdest)))-((((XCOL1(color)))* g_m1)>>7);
473 b=(XCOL2(GETLE16(pdest)))-((((XCOL2(color)))* g_m2)>>7);
474 g=(XCOL3(GETLE16(pdest)))-((((XCOL3(color)))* g_m3)>>7);
475 if(r&0x80000000) r=0;
476 if(b&0x80000000) b=0;
477 if(g&0x80000000) g=0;
481 #ifdef HALFBRIGHTMODE3
482 r=(XCOL1(GETLE16(pdest)))+((((XCOL1(color))>>2)* g_m1)>>7);
483 b=(XCOL2(GETLE16(pdest)))+((((XCOL2(color))>>2)* g_m2)>>7);
484 g=(XCOL3(GETLE16(pdest)))+((((XCOL3(color))>>2)* g_m3)>>7);
486 r=(XCOL1(GETLE16(pdest)))+((((XCOL1(color))>>1)* g_m1)>>7);
487 b=(XCOL2(GETLE16(pdest)))+((((XCOL2(color))>>1)* g_m2)>>7);
488 g=(XCOL3(GETLE16(pdest)))+((((XCOL3(color))>>1)* g_m3)>>7);
494 r=((XCOL1(color))* g_m1)>>7;
495 b=((XCOL2(color))* g_m2)>>7;
496 g=((XCOL3(color))* g_m3)>>7;
499 if(r&0x7FFFFFE0) r=0x1f;
500 if(b&0x7FFFFC00) b=0x3e0;
501 if(g&0x7FFF8000) g=0x7c00;
503 PUTLE16(pdest, (XPSXCOL(r,g,b))|l);
506 ////////////////////////////////////////////////////////////////////////
508 static inline void GetTextureTransColG32(uint32_t * pdest,uint32_t color)
514 l=lSetMask|(color&0x80008000);
516 if(DrawSemiTrans && (color&0x80008000))
520 r=((((X32TCOL1(GETLE32(pdest)))+((X32COL1(color)) * g_m1))&0xFF00FF00)>>8);
521 b=((((X32TCOL2(GETLE32(pdest)))+((X32COL2(color)) * g_m2))&0xFF00FF00)>>8);
522 g=((((X32TCOL3(GETLE32(pdest)))+((X32COL3(color)) * g_m3))&0xFF00FF00)>>8);
527 r=(X32COL1(GETLE32(pdest)))+(((((X32COL1(color)))* g_m1)&0xFF80FF80)>>7);
528 b=(X32COL2(GETLE32(pdest)))+(((((X32COL2(color)))* g_m2)&0xFF80FF80)>>7);
529 g=(X32COL3(GETLE32(pdest)))+(((((X32COL3(color)))* g_m3)&0xFF80FF80)>>7);
535 r=(((((X32COL1(color)))* g_m1)&0xFF80FF80)>>7);
536 t=(GETLE32(pdest)&0x001f0000)-(r&0x003f0000); if(t&0x80000000) t=0;
537 r=(GETLE32(pdest)&0x0000001f)-(r&0x0000003f); if(r&0x80000000) r=0;
540 b=(((((X32COL2(color)))* g_m2)&0xFF80FF80)>>7);
541 t=((GETLE32(pdest)>>5)&0x001f0000)-(b&0x003f0000); if(t&0x80000000) t=0;
542 b=((GETLE32(pdest)>>5)&0x0000001f)-(b&0x0000003f); if(b&0x80000000) b=0;
545 g=(((((X32COL3(color)))* g_m3)&0xFF80FF80)>>7);
546 t=((GETLE32(pdest)>>10)&0x001f0000)-(g&0x003f0000); if(t&0x80000000) t=0;
547 g=((GETLE32(pdest)>>10)&0x0000001f)-(g&0x0000003f); if(g&0x80000000) g=0;
552 #ifdef HALFBRIGHTMODE3
553 r=(X32COL1(GETLE32(pdest)))+(((((X32BCOL1(color))>>2)* g_m1)&0xFF80FF80)>>7);
554 b=(X32COL2(GETLE32(pdest)))+(((((X32BCOL2(color))>>2)* g_m2)&0xFF80FF80)>>7);
555 g=(X32COL3(GETLE32(pdest)))+(((((X32BCOL3(color))>>2)* g_m3)&0xFF80FF80)>>7);
557 r=(X32COL1(GETLE32(pdest)))+(((((X32ACOL1(color))>>1)* g_m1)&0xFF80FF80)>>7);
558 b=(X32COL2(GETLE32(pdest)))+(((((X32ACOL2(color))>>1)* g_m2)&0xFF80FF80)>>7);
559 g=(X32COL3(GETLE32(pdest)))+(((((X32ACOL3(color))>>1)* g_m3)&0xFF80FF80)>>7);
565 r=(r&0xffff0000)|((((X32COL1(color))* g_m1)&0x0000FF80)>>7);
566 b=(b&0xffff0000)|((((X32COL2(color))* g_m2)&0x0000FF80)>>7);
567 g=(g&0xffff0000)|((((X32COL3(color))* g_m3)&0x0000FF80)>>7);
569 if(!(color&0x80000000))
571 r=(r&0xffff)|((((X32COL1(color))* g_m1)&0xFF800000)>>7);
572 b=(b&0xffff)|((((X32COL2(color))* g_m2)&0xFF800000)>>7);
573 g=(g&0xffff)|((((X32COL3(color))* g_m3)&0xFF800000)>>7);
579 r=(((X32COL1(color))* g_m1)&0xFF80FF80)>>7;
580 b=(((X32COL2(color))* g_m2)&0xFF80FF80)>>7;
581 g=(((X32COL3(color))* g_m3)&0xFF80FF80)>>7;
584 if(r&0x7FE00000) r=0x1f0000|(r&0xFFFF);
585 if(r&0x7FE0) r=0x1f |(r&0xFFFF0000);
586 if(b&0x7FE00000) b=0x1f0000|(b&0xFFFF);
587 if(b&0x7FE0) b=0x1f |(b&0xFFFF0000);
588 if(g&0x7FE00000) g=0x1f0000|(g&0xFFFF);
589 if(g&0x7FE0) g=0x1f |(g&0xFFFF0000);
593 uint32_t ma=GETLE32(pdest);
595 PUTLE32(pdest, (X32PSXCOL(r,g,b))|l);
597 if((color&0xffff)==0 ) PUTLE32(pdest, (ma&0xffff)|(GETLE32(pdest)&0xffff0000));
598 if((color&0xffff0000)==0) PUTLE32(pdest, (ma&0xffff0000)|(GETLE32(pdest)&0xffff));
599 if(ma&0x80000000) PUTLE32(pdest, (ma&0xFFFF0000)|(GETLE32(pdest)&0xFFFF));
600 if(ma&0x00008000) PUTLE32(pdest, (ma&0xFFFF) |(GETLE32(pdest)&0xFFFF0000));
604 if((color&0xffff)==0 ) {PUTLE32(pdest, (GETLE32(pdest)&0xffff)|(((X32PSXCOL(r,g,b))|l)&0xffff0000));return;}
605 if((color&0xffff0000)==0) {PUTLE32(pdest, (GETLE32(pdest)&0xffff0000)|(((X32PSXCOL(r,g,b))|l)&0xffff));return;}
607 PUTLE32(pdest, (X32PSXCOL(r,g,b))|l);
610 ////////////////////////////////////////////////////////////////////////
612 static inline void GetTextureTransColG32_S(uint32_t * pdest,uint32_t color)
618 r=(((X32COL1(color))* g_m1)&0xFF80FF80)>>7;
619 b=(((X32COL2(color))* g_m2)&0xFF80FF80)>>7;
620 g=(((X32COL3(color))* g_m3)&0xFF80FF80)>>7;
622 if(r&0x7FE00000) r=0x1f0000|(r&0xFFFF);
623 if(r&0x7FE0) r=0x1f |(r&0xFFFF0000);
624 if(b&0x7FE00000) b=0x1f0000|(b&0xFFFF);
625 if(b&0x7FE0) b=0x1f |(b&0xFFFF0000);
626 if(g&0x7FE00000) g=0x1f0000|(g&0xFFFF);
627 if(g&0x7FE0) g=0x1f |(g&0xFFFF0000);
629 if((color&0xffff)==0) {PUTLE32(pdest, (GETLE32(pdest)&0xffff)|(((X32PSXCOL(r,g,b))|lSetMask|(color&0x80008000))&0xffff0000));return;}
630 if((color&0xffff0000)==0) {PUTLE32(pdest, (GETLE32(pdest)&0xffff0000)|(((X32PSXCOL(r,g,b))|lSetMask|(color&0x80008000))&0xffff));return;}
632 PUTLE32(pdest, (X32PSXCOL(r,g,b))|lSetMask|(color&0x80008000));
635 ////////////////////////////////////////////////////////////////////////
637 static inline void GetTextureTransColG32_SPR(uint32_t * pdest,uint32_t color)
643 if(DrawSemiTrans && (color&0x80008000))
647 r=((((X32TCOL1(GETLE32(pdest)))+((X32COL1(color)) * g_m1))&0xFF00FF00)>>8);
648 b=((((X32TCOL2(GETLE32(pdest)))+((X32COL2(color)) * g_m2))&0xFF00FF00)>>8);
649 g=((((X32TCOL3(GETLE32(pdest)))+((X32COL3(color)) * g_m3))&0xFF00FF00)>>8);
654 r=(X32COL1(GETLE32(pdest)))+(((((X32COL1(color)))* g_m1)&0xFF80FF80)>>7);
655 b=(X32COL2(GETLE32(pdest)))+(((((X32COL2(color)))* g_m2)&0xFF80FF80)>>7);
656 g=(X32COL3(GETLE32(pdest)))+(((((X32COL3(color)))* g_m3)&0xFF80FF80)>>7);
662 r=(((((X32COL1(color)))* g_m1)&0xFF80FF80)>>7);
663 t=(GETLE32(pdest)&0x001f0000)-(r&0x003f0000); if(t&0x80000000) t=0;
664 r=(GETLE32(pdest)&0x0000001f)-(r&0x0000003f); if(r&0x80000000) r=0;
667 b=(((((X32COL2(color)))* g_m2)&0xFF80FF80)>>7);
668 t=((GETLE32(pdest)>>5)&0x001f0000)-(b&0x003f0000); if(t&0x80000000) t=0;
669 b=((GETLE32(pdest)>>5)&0x0000001f)-(b&0x0000003f); if(b&0x80000000) b=0;
672 g=(((((X32COL3(color)))* g_m3)&0xFF80FF80)>>7);
673 t=((GETLE32(pdest)>>10)&0x001f0000)-(g&0x003f0000); if(t&0x80000000) t=0;
674 g=((GETLE32(pdest)>>10)&0x0000001f)-(g&0x0000003f); if(g&0x80000000) g=0;
679 #ifdef HALFBRIGHTMODE3
680 r=(X32COL1(GETLE32(pdest)))+(((((X32BCOL1(color))>>2)* g_m1)&0xFF80FF80)>>7);
681 b=(X32COL2(GETLE32(pdest)))+(((((X32BCOL2(color))>>2)* g_m2)&0xFF80FF80)>>7);
682 g=(X32COL3(GETLE32(pdest)))+(((((X32BCOL3(color))>>2)* g_m3)&0xFF80FF80)>>7);
684 r=(X32COL1(GETLE32(pdest)))+(((((X32ACOL1(color))>>1)* g_m1)&0xFF80FF80)>>7);
685 b=(X32COL2(GETLE32(pdest)))+(((((X32ACOL2(color))>>1)* g_m2)&0xFF80FF80)>>7);
686 g=(X32COL3(GETLE32(pdest)))+(((((X32ACOL3(color))>>1)* g_m3)&0xFF80FF80)>>7);
692 r=(r&0xffff0000)|((((X32COL1(color))* g_m1)&0x0000FF80)>>7);
693 b=(b&0xffff0000)|((((X32COL2(color))* g_m2)&0x0000FF80)>>7);
694 g=(g&0xffff0000)|((((X32COL3(color))* g_m3)&0x0000FF80)>>7);
696 if(!(color&0x80000000))
698 r=(r&0xffff)|((((X32COL1(color))* g_m1)&0xFF800000)>>7);
699 b=(b&0xffff)|((((X32COL2(color))* g_m2)&0xFF800000)>>7);
700 g=(g&0xffff)|((((X32COL3(color))* g_m3)&0xFF800000)>>7);
706 r=(((X32COL1(color))* g_m1)&0xFF80FF80)>>7;
707 b=(((X32COL2(color))* g_m2)&0xFF80FF80)>>7;
708 g=(((X32COL3(color))* g_m3)&0xFF80FF80)>>7;
711 if(r&0x7FE00000) r=0x1f0000|(r&0xFFFF);
712 if(r&0x7FE0) r=0x1f |(r&0xFFFF0000);
713 if(b&0x7FE00000) b=0x1f0000|(b&0xFFFF);
714 if(b&0x7FE0) b=0x1f |(b&0xFFFF0000);
715 if(g&0x7FE00000) g=0x1f0000|(g&0xFFFF);
716 if(g&0x7FE0) g=0x1f |(g&0xFFFF0000);
720 uint32_t ma=GETLE32(pdest);
722 PUTLE32(pdest, (X32PSXCOL(r,g,b))|lSetMask|(color&0x80008000));
724 if((color&0xffff)==0 ) PUTLE32(pdest, (ma&0xffff)|(GETLE32(pdest)&0xffff0000));
725 if((color&0xffff0000)==0) PUTLE32(pdest, (ma&0xffff0000)|(GETLE32(pdest)&0xffff));
726 if(ma&0x80000000) PUTLE32(pdest, (ma&0xFFFF0000)|(GETLE32(pdest)&0xFFFF));
727 if(ma&0x00008000) PUTLE32(pdest, (ma&0xFFFF) |(GETLE32(pdest)&0xFFFF0000));
731 if((color&0xffff)==0 ) {PUTLE32(pdest, (GETLE32(pdest)&0xffff)|(((X32PSXCOL(r,g,b))|lSetMask|(color&0x80008000))&0xffff0000));return;}
732 if((color&0xffff0000)==0) {PUTLE32(pdest, (GETLE32(pdest)&0xffff0000)|(((X32PSXCOL(r,g,b))|lSetMask|(color&0x80008000))&0xffff));return;}
734 PUTLE32(pdest, (X32PSXCOL(r,g,b))|lSetMask|(color&0x80008000));
737 ////////////////////////////////////////////////////////////////////////
739 static inline void GetTextureTransColGX_Dither(unsigned short * pdest,unsigned short color,int32_t m1,int32_t m2,int32_t m3)
745 if(bCheckMask && (*pdest & HOST2LE16(0x8000))) return;
747 m1=(((XCOL1D(color)))*m1)>>4;
748 m2=(((XCOL2D(color)))*m2)>>4;
749 m3=(((XCOL3D(color)))*m3)>>4;
751 if(DrawSemiTrans && (color&0x8000))
753 r=((XCOL1D(GETLE16(pdest)))<<3);
754 b=((XCOL2D(GETLE16(pdest)))<<3);
755 g=((XCOL3D(GETLE16(pdest)))<<3);
776 if(r&0x80000000) r=0;
777 if(b&0x80000000) b=0;
778 if(g&0x80000000) g=0;
782 #ifdef HALFBRIGHTMODE3
800 if(r&0x7FFFFF00) r=0xff;
801 if(b&0x7FFFFF00) b=0xff;
802 if(g&0x7FFFFF00) g=0xff;
804 Dither16(pdest,r,b,g,sSetMask|(color&0x8000));
808 ////////////////////////////////////////////////////////////////////////
810 static inline void GetTextureTransColGX(unsigned short * pdest,unsigned short color,short m1,short m2,short m3)
812 int32_t r,g,b;unsigned short l;
816 if(bCheckMask && (*pdest & HOST2LE16(0x8000))) return;
818 l=sSetMask|(color&0x8000);
820 if(DrawSemiTrans && (color&0x8000))
825 d =(GETLE16(pdest)&0x7bde)>>1;
826 color =((color) &0x7bde)>>1;
827 r=(XCOL1(d))+((((XCOL1(color)))* m1)>>7);
828 b=(XCOL2(d))+((((XCOL2(color)))* m2)>>7);
829 g=(XCOL3(d))+((((XCOL3(color)))* m3)>>7);
834 r=(XCOL1(GETLE16(pdest)))+((((XCOL1(color)))* m1)>>7);
835 b=(XCOL2(GETLE16(pdest)))+((((XCOL2(color)))* m2)>>7);
836 g=(XCOL3(GETLE16(pdest)))+((((XCOL3(color)))* m3)>>7);
841 r=(XCOL1(GETLE16(pdest)))-((((XCOL1(color)))* m1)>>7);
842 b=(XCOL2(GETLE16(pdest)))-((((XCOL2(color)))* m2)>>7);
843 g=(XCOL3(GETLE16(pdest)))-((((XCOL3(color)))* m3)>>7);
844 if(r&0x80000000) r=0;
845 if(b&0x80000000) b=0;
846 if(g&0x80000000) g=0;
850 #ifdef HALFBRIGHTMODE3
851 r=(XCOL1(GETLE16(pdest)))+((((XCOL1(color))>>2)* m1)>>7);
852 b=(XCOL2(GETLE16(pdest)))+((((XCOL2(color))>>2)* m2)>>7);
853 g=(XCOL3(GETLE16(pdest)))+((((XCOL3(color))>>2)* m3)>>7);
855 r=(XCOL1(GETLE16(pdest)))+((((XCOL1(color))>>1)* m1)>>7);
856 b=(XCOL2(GETLE16(pdest)))+((((XCOL2(color))>>1)* m2)>>7);
857 g=(XCOL3(GETLE16(pdest)))+((((XCOL3(color))>>1)* m3)>>7);
863 r=((XCOL1(color))* m1)>>7;
864 b=((XCOL2(color))* m2)>>7;
865 g=((XCOL3(color))* m3)>>7;
868 if(r&0x7FFFFFE0) r=0x1f;
869 if(b&0x7FFFFC00) b=0x3e0;
870 if(g&0x7FFF8000) g=0x7c00;
872 PUTLE16(pdest, (XPSXCOL(r,g,b))|l);
875 ////////////////////////////////////////////////////////////////////////
877 static inline void GetTextureTransColGX_S(unsigned short * pdest,unsigned short color,short m1,short m2,short m3)
883 r=((XCOL1(color))* m1)>>7;
884 b=((XCOL2(color))* m2)>>7;
885 g=((XCOL3(color))* m3)>>7;
887 if(r&0x7FFFFFE0) r=0x1f;
888 if(b&0x7FFFFC00) b=0x3e0;
889 if(g&0x7FFF8000) g=0x7c00;
891 PUTLE16(pdest, (XPSXCOL(r,g,b))|sSetMask|(color&0x8000));
894 ////////////////////////////////////////////////////////////////////////
896 static inline void GetTextureTransColGX32_S(uint32_t * pdest,uint32_t color,short m1,short m2,short m3)
902 r=(((X32COL1(color))* m1)&0xFF80FF80)>>7;
903 b=(((X32COL2(color))* m2)&0xFF80FF80)>>7;
904 g=(((X32COL3(color))* m3)&0xFF80FF80)>>7;
906 if(r&0x7FE00000) r=0x1f0000|(r&0xFFFF);
907 if(r&0x7FE0) r=0x1f |(r&0xFFFF0000);
908 if(b&0x7FE00000) b=0x1f0000|(b&0xFFFF);
909 if(b&0x7FE0) b=0x1f |(b&0xFFFF0000);
910 if(g&0x7FE00000) g=0x1f0000|(g&0xFFFF);
911 if(g&0x7FE0) g=0x1f |(g&0xFFFF0000);
913 if((color&0xffff)==0) {PUTLE32(pdest, (GETLE32(pdest)&0xffff)|(((X32PSXCOL(r,g,b))|lSetMask|(color&0x80008000))&0xffff0000));return;}
914 if((color&0xffff0000)==0) {PUTLE32(pdest, (GETLE32(pdest)&0xffff0000)|(((X32PSXCOL(r,g,b))|lSetMask|(color&0x80008000))&0xffff));return;}
916 PUTLE32(pdest, (X32PSXCOL(r,g,b))|lSetMask|(color&0x80008000));
919 ////////////////////////////////////////////////////////////////////////
921 ////////////////////////////////////////////////////////////////////////
923 static void FillSoftwareAreaTrans(short x0,short y0,short x1, // FILL AREA TRANS
924 short y1,unsigned short col)
949 if(dx==1 && dy==1 && x0==1020 && y0==511) // special fix for pinball game... emu protection???
953 if(iCheat==1) iCheat=0; else iCheat=1;
957 if(dx&1) // slow fill
959 unsigned short *DSTPtr;
960 unsigned short LineOffset;
961 DSTPtr = psxVuw + (1024*y0) + x0;
962 LineOffset = 1024 - dx;
966 GetShadeTransCol(DSTPtr++,col);
967 DSTPtr += LineOffset;
973 unsigned short LineOffset;
974 uint32_t lcol=lSetMask|(((uint32_t)(col))<<16)|col;
976 DSTPtr = (uint32_t *)(psxVuw + (1024*y0) + x0);
977 LineOffset = 512 - dx;
979 if(!bCheckMask && !DrawSemiTrans)
983 for(j=0;j<dx;j++) { PUTLE32(DSTPtr, lcol); DSTPtr++; }
984 DSTPtr += LineOffset;
992 GetShadeTransCol32(DSTPtr++,lcol);
993 DSTPtr += LineOffset;
999 ////////////////////////////////////////////////////////////////////////
1001 static void FillSoftwareArea(short x0,short y0,short x1, // FILL AREA (BLK FILL)
1002 short y1,unsigned short col) // no draw area check here!
1013 if(x1>1024) x1=1024;
1018 unsigned short *DSTPtr;
1019 unsigned short LineOffset;
1021 DSTPtr = psxVuw + (1024*y0) + x0;
1022 LineOffset = 1024 - dx;
1026 for(j=0;j<dx;j++) { PUTLE16(DSTPtr, col); DSTPtr++; }
1027 DSTPtr += LineOffset;
1033 unsigned short LineOffset;
1034 uint32_t lcol=(((int32_t)col)<<16)|col;
1036 DSTPtr = (uint32_t *)(psxVuw + (1024*y0) + x0);
1037 LineOffset = 512 - dx;
1041 for(j=0;j<dx;j++) { PUTLE32(DSTPtr, lcol); DSTPtr++; }
1042 DSTPtr += LineOffset;
1047 ////////////////////////////////////////////////////////////////////////
1048 ////////////////////////////////////////////////////////////////////////
1049 ////////////////////////////////////////////////////////////////////////
1050 // EDGE INTERPOLATION
1051 ////////////////////////////////////////////////////////////////////////
1052 ////////////////////////////////////////////////////////////////////////
1053 ////////////////////////////////////////////////////////////////////////
1055 typedef struct SOFTVTAG
1062 static soft_vertex vtx[4];
1063 static soft_vertex * left_array[4], * right_array[4];
1064 static int left_section, right_section;
1065 static int left_section_height, right_section_height;
1066 static int left_x, delta_left_x, right_x, delta_right_x;
1067 static int left_u, delta_left_u, left_v, delta_left_v;
1068 static int right_u, delta_right_u, right_v, delta_right_v;
1069 static int left_R, delta_left_R, right_R, delta_right_R;
1070 static int left_G, delta_left_G, right_G, delta_right_G;
1071 static int left_B, delta_left_B, right_B, delta_right_B;
1074 static inline int shl10idiv(int x, int y)
1081 ////////////////////////////////////////////////////////////////////////
1082 ////////////////////////////////////////////////////////////////////////
1083 ////////////////////////////////////////////////////////////////////////
1085 static inline int RightSection_F(void)
1087 soft_vertex * v1 = right_array[ right_section ];
1088 soft_vertex * v2 = right_array[ right_section-1 ];
1090 int height = v2->y - v1->y;
1091 if(height == 0) return 0;
1092 delta_right_x = (v2->x - v1->x) / height;
1095 right_section_height = height;
1099 ////////////////////////////////////////////////////////////////////////
1101 static inline int LeftSection_F(void)
1103 soft_vertex * v1 = left_array[ left_section ];
1104 soft_vertex * v2 = left_array[ left_section-1 ];
1106 int height = v2->y - v1->y;
1107 if(height == 0) return 0;
1108 delta_left_x = (v2->x - v1->x) / height;
1111 left_section_height = height;
1115 ////////////////////////////////////////////////////////////////////////
1117 static inline BOOL NextRow_F(void)
1119 if(--left_section_height<=0)
1121 if(--left_section <= 0) {return TRUE;}
1122 if(LeftSection_F() <= 0) {return TRUE;}
1126 left_x += delta_left_x;
1129 if(--right_section_height<=0)
1131 if(--right_section<=0) {return TRUE;}
1132 if(RightSection_F() <=0) {return TRUE;}
1136 right_x += delta_right_x;
1141 ////////////////////////////////////////////////////////////////////////
1143 static inline BOOL SetupSections_F(short x1, short y1, short x2, short y2, short x3, short y3)
1145 soft_vertex * v1, * v2, * v3;
1148 v1 = vtx; v1->x=x1<<16;v1->y=y1;
1149 v2 = vtx+1; v2->x=x2<<16;v2->y=y2;
1150 v3 = vtx+2; v3->x=x3<<16;v3->y=y3;
1152 if(v1->y > v2->y) { soft_vertex * v = v1; v1 = v2; v2 = v; }
1153 if(v1->y > v3->y) { soft_vertex * v = v1; v1 = v3; v3 = v; }
1154 if(v2->y > v3->y) { soft_vertex * v = v2; v2 = v3; v3 = v; }
1156 height = v3->y - v1->y;
1157 if(height == 0) {return FALSE;}
1158 longest = (((v2->y - v1->y) << 16) / height) * ((v3->x - v1->x)>>16) + (v1->x - v2->x);
1159 if(longest == 0) {return FALSE;}
1163 right_array[0] = v3;
1164 right_array[1] = v2;
1165 right_array[2] = v1;
1171 if(LeftSection_F() <= 0) return FALSE;
1172 if(RightSection_F() <= 0)
1175 if(RightSection_F() <= 0) return FALSE;
1184 right_array[0] = v3;
1185 right_array[1] = v1;
1188 if(RightSection_F() <= 0) return FALSE;
1189 if(LeftSection_F() <= 0)
1192 if(LeftSection_F() <= 0) return FALSE;
1197 Ymax=min(v3->y-1,drawH);
1202 ////////////////////////////////////////////////////////////////////////
1203 ////////////////////////////////////////////////////////////////////////
1205 static inline int RightSection_G(void)
1207 soft_vertex * v1 = right_array[ right_section ];
1208 soft_vertex * v2 = right_array[ right_section-1 ];
1210 int height = v2->y - v1->y;
1211 if(height == 0) return 0;
1212 delta_right_x = (v2->x - v1->x) / height;
1215 right_section_height = height;
1219 ////////////////////////////////////////////////////////////////////////
1221 static inline int LeftSection_G(void)
1223 soft_vertex * v1 = left_array[ left_section ];
1224 soft_vertex * v2 = left_array[ left_section-1 ];
1226 int height = v2->y - v1->y;
1227 if(height == 0) return 0;
1228 delta_left_x = (v2->x - v1->x) / height;
1231 delta_left_R = ((v2->R - v1->R)) / height;
1233 delta_left_G = ((v2->G - v1->G)) / height;
1235 delta_left_B = ((v2->B - v1->B)) / height;
1238 left_section_height = height;
1242 ////////////////////////////////////////////////////////////////////////
1244 static inline BOOL NextRow_G(void)
1246 if(--left_section_height<=0)
1248 if(--left_section <= 0) {return TRUE;}
1249 if(LeftSection_G() <= 0) {return TRUE;}
1253 left_x += delta_left_x;
1254 left_R += delta_left_R;
1255 left_G += delta_left_G;
1256 left_B += delta_left_B;
1259 if(--right_section_height<=0)
1261 if(--right_section<=0) {return TRUE;}
1262 if(RightSection_G() <=0) {return TRUE;}
1266 right_x += delta_right_x;
1271 ////////////////////////////////////////////////////////////////////////
1273 static inline BOOL SetupSections_G(short x1,short y1,short x2,short y2,short x3,short y3,int32_t rgb1, int32_t rgb2, int32_t rgb3)
1275 soft_vertex * v1, * v2, * v3;
1276 int height,longest,temp;
1278 v1 = vtx; v1->x=x1<<16;v1->y=y1;
1279 v1->R=(rgb1) & 0x00ff0000;
1280 v1->G=(rgb1<<8) & 0x00ff0000;
1281 v1->B=(rgb1<<16) & 0x00ff0000;
1282 v2 = vtx+1; v2->x=x2<<16;v2->y=y2;
1283 v2->R=(rgb2) & 0x00ff0000;
1284 v2->G=(rgb2<<8) & 0x00ff0000;
1285 v2->B=(rgb2<<16) & 0x00ff0000;
1286 v3 = vtx+2; v3->x=x3<<16;v3->y=y3;
1287 v3->R=(rgb3) & 0x00ff0000;
1288 v3->G=(rgb3<<8) & 0x00ff0000;
1289 v3->B=(rgb3<<16) & 0x00ff0000;
1291 if(v1->y > v2->y) { soft_vertex * v = v1; v1 = v2; v2 = v; }
1292 if(v1->y > v3->y) { soft_vertex * v = v1; v1 = v3; v3 = v; }
1293 if(v2->y > v3->y) { soft_vertex * v = v2; v2 = v3; v3 = v; }
1295 height = v3->y - v1->y;
1296 if(height == 0) {return FALSE;}
1297 temp=(((v2->y - v1->y) << 16) / height);
1298 longest = temp * ((v3->x - v1->x)>>16) + (v1->x - v2->x);
1299 if(longest == 0) {return FALSE;}
1303 right_array[0] = v3;
1304 right_array[1] = v2;
1305 right_array[2] = v1;
1311 if(LeftSection_G() <= 0) return FALSE;
1312 if(RightSection_G() <= 0)
1315 if(RightSection_G() <= 0) return FALSE;
1317 if(longest > -0x1000) longest = -0x1000;
1325 right_array[0] = v3;
1326 right_array[1] = v1;
1329 if(RightSection_G() <= 0) return FALSE;
1330 if(LeftSection_G() <= 0)
1333 if(LeftSection_G() <= 0) return FALSE;
1335 if(longest < 0x1000) longest = 0x1000;
1339 Ymax=min(v3->y-1,drawH);
1341 delta_right_R=shl10idiv(temp*((v3->R - v1->R)>>10)+((v1->R - v2->R)<<6),longest);
1342 delta_right_G=shl10idiv(temp*((v3->G - v1->G)>>10)+((v1->G - v2->G)<<6),longest);
1343 delta_right_B=shl10idiv(temp*((v3->B - v1->B)>>10)+((v1->B - v2->B)<<6),longest);
1348 ////////////////////////////////////////////////////////////////////////
1349 ////////////////////////////////////////////////////////////////////////
1351 static inline int RightSection_FT(void)
1353 soft_vertex * v1 = right_array[ right_section ];
1354 soft_vertex * v2 = right_array[ right_section-1 ];
1356 int height = v2->y - v1->y;
1357 if(height == 0) return 0;
1358 delta_right_x = (v2->x - v1->x) / height;
1361 right_section_height = height;
1365 ////////////////////////////////////////////////////////////////////////
1367 static inline int LeftSection_FT(void)
1369 soft_vertex * v1 = left_array[ left_section ];
1370 soft_vertex * v2 = left_array[ left_section-1 ];
1372 int height = v2->y - v1->y;
1373 if(height == 0) return 0;
1374 delta_left_x = (v2->x - v1->x) / height;
1377 delta_left_u = ((v2->u - v1->u)) / height;
1379 delta_left_v = ((v2->v - v1->v)) / height;
1382 left_section_height = height;
1386 ////////////////////////////////////////////////////////////////////////
1388 static inline BOOL NextRow_FT(void)
1390 if(--left_section_height<=0)
1392 if(--left_section <= 0) {return TRUE;}
1393 if(LeftSection_FT() <= 0) {return TRUE;}
1397 left_x += delta_left_x;
1398 left_u += delta_left_u;
1399 left_v += delta_left_v;
1402 if(--right_section_height<=0)
1404 if(--right_section<=0) {return TRUE;}
1405 if(RightSection_FT() <=0) {return TRUE;}
1409 right_x += delta_right_x;
1414 ////////////////////////////////////////////////////////////////////////
1416 static inline BOOL SetupSections_FT(short x1, short y1, short x2, short y2, short x3, short y3, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3)
1418 soft_vertex * v1, * v2, * v3;
1419 int height,longest,temp;
1421 v1 = vtx; v1->x=x1<<16;v1->y=y1;
1422 v1->u=tx1<<16;v1->v=ty1<<16;
1423 v2 = vtx+1; v2->x=x2<<16;v2->y=y2;
1424 v2->u=tx2<<16;v2->v=ty2<<16;
1425 v3 = vtx+2; v3->x=x3<<16;v3->y=y3;
1426 v3->u=tx3<<16;v3->v=ty3<<16;
1428 if(v1->y > v2->y) { soft_vertex * v = v1; v1 = v2; v2 = v; }
1429 if(v1->y > v3->y) { soft_vertex * v = v1; v1 = v3; v3 = v; }
1430 if(v2->y > v3->y) { soft_vertex * v = v2; v2 = v3; v3 = v; }
1432 height = v3->y - v1->y;
1433 if(height == 0) {return FALSE;}
1435 temp=(((v2->y - v1->y) << 16) / height);
1436 longest = temp * ((v3->x - v1->x)>>16) + (v1->x - v2->x);
1438 if(longest == 0) {return FALSE;}
1442 right_array[0] = v3;
1443 right_array[1] = v2;
1444 right_array[2] = v1;
1450 if(LeftSection_FT() <= 0) return FALSE;
1451 if(RightSection_FT() <= 0)
1454 if(RightSection_FT() <= 0) return FALSE;
1456 if(longest > -0x1000) longest = -0x1000;
1464 right_array[0] = v3;
1465 right_array[1] = v1;
1468 if(RightSection_FT() <= 0) return FALSE;
1469 if(LeftSection_FT() <= 0)
1472 if(LeftSection_FT() <= 0) return FALSE;
1474 if(longest < 0x1000) longest = 0x1000;
1478 Ymax=min(v3->y-1,drawH);
1480 delta_right_u=shl10idiv(temp*((v3->u - v1->u)>>10)+((v1->u - v2->u)<<6),longest);
1481 delta_right_v=shl10idiv(temp*((v3->v - v1->v)>>10)+((v1->v - v2->v)<<6),longest);
1486 ////////////////////////////////////////////////////////////////////////
1487 ////////////////////////////////////////////////////////////////////////
1489 static inline int RightSection_GT(void)
1491 soft_vertex * v1 = right_array[ right_section ];
1492 soft_vertex * v2 = right_array[ right_section-1 ];
1494 int height = v2->y - v1->y;
1495 if(height == 0) return 0;
1496 delta_right_x = (v2->x - v1->x) / height;
1499 right_section_height = height;
1503 ////////////////////////////////////////////////////////////////////////
1505 static inline int LeftSection_GT(void)
1507 soft_vertex * v1 = left_array[ left_section ];
1508 soft_vertex * v2 = left_array[ left_section-1 ];
1510 int height = v2->y - v1->y;
1511 if(height == 0) return 0;
1512 delta_left_x = (v2->x - v1->x) / height;
1515 delta_left_u = ((v2->u - v1->u)) / height;
1517 delta_left_v = ((v2->v - v1->v)) / height;
1520 delta_left_R = ((v2->R - v1->R)) / height;
1522 delta_left_G = ((v2->G - v1->G)) / height;
1524 delta_left_B = ((v2->B - v1->B)) / height;
1527 left_section_height = height;
1531 ////////////////////////////////////////////////////////////////////////
1533 static inline BOOL NextRow_GT(void)
1535 if(--left_section_height<=0)
1537 if(--left_section <= 0) {return TRUE;}
1538 if(LeftSection_GT() <= 0) {return TRUE;}
1542 left_x += delta_left_x;
1543 left_u += delta_left_u;
1544 left_v += delta_left_v;
1545 left_R += delta_left_R;
1546 left_G += delta_left_G;
1547 left_B += delta_left_B;
1550 if(--right_section_height<=0)
1552 if(--right_section<=0) {return TRUE;}
1553 if(RightSection_GT() <=0) {return TRUE;}
1557 right_x += delta_right_x;
1562 ////////////////////////////////////////////////////////////////////////
1564 static inline BOOL SetupSections_GT(short x1, short y1, short x2, short y2, short x3, short y3, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, int32_t rgb1, int32_t rgb2, int32_t rgb3)
1566 soft_vertex * v1, * v2, * v3;
1567 int height,longest,temp;
1569 v1 = vtx; v1->x=x1<<16;v1->y=y1;
1570 v1->u=tx1<<16;v1->v=ty1<<16;
1571 v1->R=(rgb1) & 0x00ff0000;
1572 v1->G=(rgb1<<8) & 0x00ff0000;
1573 v1->B=(rgb1<<16) & 0x00ff0000;
1575 v2 = vtx+1; v2->x=x2<<16;v2->y=y2;
1576 v2->u=tx2<<16;v2->v=ty2<<16;
1577 v2->R=(rgb2) & 0x00ff0000;
1578 v2->G=(rgb2<<8) & 0x00ff0000;
1579 v2->B=(rgb2<<16) & 0x00ff0000;
1581 v3 = vtx+2; v3->x=x3<<16;v3->y=y3;
1582 v3->u=tx3<<16;v3->v=ty3<<16;
1583 v3->R=(rgb3) & 0x00ff0000;
1584 v3->G=(rgb3<<8) & 0x00ff0000;
1585 v3->B=(rgb3<<16) & 0x00ff0000;
1587 if(v1->y > v2->y) { soft_vertex * v = v1; v1 = v2; v2 = v; }
1588 if(v1->y > v3->y) { soft_vertex * v = v1; v1 = v3; v3 = v; }
1589 if(v2->y > v3->y) { soft_vertex * v = v2; v2 = v3; v3 = v; }
1591 height = v3->y - v1->y;
1592 if(height == 0) {return FALSE;}
1594 temp=(((v2->y - v1->y) << 16) / height);
1595 longest = temp * ((v3->x - v1->x)>>16) + (v1->x - v2->x);
1597 if(longest == 0) {return FALSE;}
1601 right_array[0] = v3;
1602 right_array[1] = v2;
1603 right_array[2] = v1;
1609 if(LeftSection_GT() <= 0) return FALSE;
1610 if(RightSection_GT() <= 0)
1613 if(RightSection_GT() <= 0) return FALSE;
1616 if(longest > -0x1000) longest = -0x1000;
1624 right_array[0] = v3;
1625 right_array[1] = v1;
1628 if(RightSection_GT() <= 0) return FALSE;
1629 if(LeftSection_GT() <= 0)
1632 if(LeftSection_GT() <= 0) return FALSE;
1634 if(longest < 0x1000) longest = 0x1000;
1638 Ymax=min(v3->y-1,drawH);
1640 delta_right_R=shl10idiv(temp*((v3->R - v1->R)>>10)+((v1->R - v2->R)<<6),longest);
1641 delta_right_G=shl10idiv(temp*((v3->G - v1->G)>>10)+((v1->G - v2->G)<<6),longest);
1642 delta_right_B=shl10idiv(temp*((v3->B - v1->B)>>10)+((v1->B - v2->B)<<6),longest);
1644 delta_right_u=shl10idiv(temp*((v3->u - v1->u)>>10)+((v1->u - v2->u)<<6),longest);
1645 delta_right_v=shl10idiv(temp*((v3->v - v1->v)>>10)+((v1->v - v2->v)<<6),longest);
1650 ////////////////////////////////////////////////////////////////////////
1651 ////////////////////////////////////////////////////////////////////////
1653 static inline int RightSection_F4(void)
1655 soft_vertex * v1 = right_array[ right_section ];
1656 soft_vertex * v2 = right_array[ right_section-1 ];
1658 int height = v2->y - v1->y;
1659 right_section_height = height;
1665 delta_right_x = (v2->x - v1->x) / height;
1670 ////////////////////////////////////////////////////////////////////////
1672 static inline int LeftSection_F4(void)
1674 soft_vertex * v1 = left_array[ left_section ];
1675 soft_vertex * v2 = left_array[ left_section-1 ];
1677 int height = v2->y - v1->y;
1678 left_section_height = height;
1684 delta_left_x = (v2->x - v1->x) / height;
1689 ////////////////////////////////////////////////////////////////////////
1691 static inline BOOL NextRow_F4(void)
1693 if(--left_section_height<=0)
1695 if(--left_section > 0)
1696 while(LeftSection_F4()<=0)
1698 if(--left_section <= 0) break;
1703 left_x += delta_left_x;
1706 if(--right_section_height<=0)
1708 if(--right_section > 0)
1709 while(RightSection_F4()<=0)
1711 if(--right_section<=0) break;
1716 right_x += delta_right_x;
1721 ////////////////////////////////////////////////////////////////////////
1723 static inline BOOL SetupSections_F4(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4)
1725 soft_vertex * v1, * v2, * v3, * v4;
1726 int height,width,longest1,longest2;
1728 v1 = vtx; v1->x=x1<<16;v1->y=y1;
1729 v2 = vtx+1; v2->x=x2<<16;v2->y=y2;
1730 v3 = vtx+2; v3->x=x3<<16;v3->y=y3;
1731 v4 = vtx+3; v4->x=x4<<16;v4->y=y4;
1733 if(v1->y > v2->y) { soft_vertex * v = v1; v1 = v2; v2 = v; }
1734 if(v1->y > v3->y) { soft_vertex * v = v1; v1 = v3; v3 = v; }
1735 if(v1->y > v4->y) { soft_vertex * v = v1; v1 = v4; v4 = v; }
1736 if(v2->y > v3->y) { soft_vertex * v = v2; v2 = v3; v3 = v; }
1737 if(v2->y > v4->y) { soft_vertex * v = v2; v2 = v4; v4 = v; }
1738 if(v3->y > v4->y) { soft_vertex * v = v3; v3 = v4; v4 = v; }
1740 height = v4->y - v1->y; if(height == 0) height =1;
1741 width = (v4->x - v1->x)>>16;
1742 longest1 = (((v2->y - v1->y) << 16) / height) * width + (v1->x - v2->x);
1743 longest2 = (((v3->y - v1->y) << 16) / height) * width + (v1->x - v3->x);
1745 if(longest1 < 0) // 2 is right
1747 if(longest2 < 0) // 3 is right
1753 height = v3->y - v1->y; if(height == 0) height=1;
1754 longest1 = (((v2->y - v1->y) << 16) / height) * ((v3->x - v1->x)>>16) + (v1->x - v2->x);
1757 right_array[0] = v4; // 1
1758 right_array[1] = v3; // 3
1759 right_array[2] = v1; // 4
1764 height = v4->y - v2->y; if(height == 0) height=1;
1765 longest1 = (((v3->y - v2->y) << 16) / height) * ((v4->x - v2->x)>>16) + (v2->x - v3->x);
1768 right_array[0] = v4; // 1
1769 right_array[1] = v2; // 2
1770 right_array[2] = v1; // 4
1775 right_array[0] = v4; // 1
1776 right_array[1] = v3; // 2
1777 right_array[2] = v2; // 3
1778 right_array[3] = v1; // 4
1786 left_array[1] = v3; // 1
1787 left_array[2] = v1; // 2
1788 left_section = 2; // 3
1789 right_array[0] = v4; // 4
1790 right_array[1] = v2;
1791 right_array[2] = v1;
1799 left_array[0] = v4; // 1
1800 left_array[1] = v2; // 2
1801 left_array[2] = v1; // 3
1802 left_section = 2; // 4
1803 right_array[0] = v4;
1804 right_array[1] = v3;
1805 right_array[2] = v1;
1810 right_array[0] = v4;
1811 right_array[1] = v1;
1814 height = v3->y - v1->y; if(height == 0) height=1;
1815 longest1 = (((v2->y - v1->y) << 16) / height) * ((v3->x - v1->x)>>16) + (v1->x - v2->x);
1818 left_array[0] = v4; // 1
1819 left_array[1] = v3; // 3
1820 left_array[2] = v1; // 4
1825 height = v4->y - v2->y; if(height == 0) height=1;
1826 longest1 = (((v3->y - v2->y) << 16) / height) * ((v4->x - v2->x)>>16) + (v2->x - v3->x);
1829 left_array[0] = v4; // 1
1830 left_array[1] = v2; // 2
1831 left_array[2] = v1; // 4
1836 left_array[0] = v4; // 1
1837 left_array[1] = v3; // 2
1838 left_array[2] = v2; // 3
1839 left_array[3] = v1; // 4
1846 while(LeftSection_F4()<=0)
1848 if(--left_section <= 0) break;
1851 while(RightSection_F4()<=0)
1853 if(--right_section <= 0) break;
1857 Ymax=min(v4->y-1,drawH);
1862 ////////////////////////////////////////////////////////////////////////
1863 ////////////////////////////////////////////////////////////////////////
1865 static inline int RightSection_FT4(void)
1867 soft_vertex * v1 = right_array[ right_section ];
1868 soft_vertex * v2 = right_array[ right_section-1 ];
1870 int height = v2->y - v1->y;
1871 right_section_height = height;
1879 delta_right_x = (v2->x - v1->x) / height;
1880 delta_right_u = (v2->u - v1->u) / height;
1881 delta_right_v = (v2->v - v1->v) / height;
1886 ////////////////////////////////////////////////////////////////////////
1888 static inline int LeftSection_FT4(void)
1890 soft_vertex * v1 = left_array[ left_section ];
1891 soft_vertex * v2 = left_array[ left_section-1 ];
1893 int height = v2->y - v1->y;
1894 left_section_height = height;
1902 delta_left_x = (v2->x - v1->x) / height;
1903 delta_left_u = (v2->u - v1->u) / height;
1904 delta_left_v = (v2->v - v1->v) / height;
1909 ////////////////////////////////////////////////////////////////////////
1911 static inline BOOL NextRow_FT4(void)
1913 if(--left_section_height<=0)
1915 if(--left_section > 0)
1916 while(LeftSection_FT4()<=0)
1918 if(--left_section <= 0) break;
1923 left_x += delta_left_x;
1924 left_u += delta_left_u;
1925 left_v += delta_left_v;
1928 if(--right_section_height<=0)
1930 if(--right_section > 0)
1931 while(RightSection_FT4()<=0)
1933 if(--right_section<=0) break;
1938 right_x += delta_right_x;
1939 right_u += delta_right_u;
1940 right_v += delta_right_v;
1945 ////////////////////////////////////////////////////////////////////////
1947 static inline BOOL SetupSections_FT4(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4)
1949 soft_vertex * v1, * v2, * v3, * v4;
1950 int height,width,longest1,longest2;
1952 v1 = vtx; v1->x=x1<<16;v1->y=y1;
1953 v1->u=tx1<<16;v1->v=ty1<<16;
1955 v2 = vtx+1; v2->x=x2<<16;v2->y=y2;
1956 v2->u=tx2<<16;v2->v=ty2<<16;
1958 v3 = vtx+2; v3->x=x3<<16;v3->y=y3;
1959 v3->u=tx3<<16;v3->v=ty3<<16;
1961 v4 = vtx+3; v4->x=x4<<16;v4->y=y4;
1962 v4->u=tx4<<16;v4->v=ty4<<16;
1964 if(v1->y > v2->y) { soft_vertex * v = v1; v1 = v2; v2 = v; }
1965 if(v1->y > v3->y) { soft_vertex * v = v1; v1 = v3; v3 = v; }
1966 if(v1->y > v4->y) { soft_vertex * v = v1; v1 = v4; v4 = v; }
1967 if(v2->y > v3->y) { soft_vertex * v = v2; v2 = v3; v3 = v; }
1968 if(v2->y > v4->y) { soft_vertex * v = v2; v2 = v4; v4 = v; }
1969 if(v3->y > v4->y) { soft_vertex * v = v3; v3 = v4; v4 = v; }
1971 height = v4->y - v1->y; if(height == 0) height =1;
1972 width = (v4->x - v1->x)>>16;
1973 longest1 = (((v2->y - v1->y) << 16) / height) * width + (v1->x - v2->x);
1974 longest2 = (((v3->y - v1->y) << 16) / height) * width + (v1->x - v3->x);
1976 if(longest1 < 0) // 2 is right
1978 if(longest2 < 0) // 3 is right
1984 height = v3->y - v1->y; if(height == 0) height=1;
1985 longest1 = (((v2->y - v1->y) << 16) / height) * ((v3->x - v1->x)>>16) + (v1->x - v2->x);
1988 right_array[0] = v4; // 1
1989 right_array[1] = v3; // 3
1990 right_array[2] = v1; // 4
1995 height = v4->y - v2->y; if(height == 0) height=1;
1996 longest1 = (((v3->y - v2->y) << 16) / height) * ((v4->x - v2->x)>>16) + (v2->x - v3->x);
1999 right_array[0] = v4; // 1
2000 right_array[1] = v2; // 2
2001 right_array[2] = v1; // 4
2006 right_array[0] = v4; // 1
2007 right_array[1] = v3; // 2
2008 right_array[2] = v2; // 3
2009 right_array[3] = v1; // 4
2017 left_array[1] = v3; // 1
2018 left_array[2] = v1; // 2
2019 left_section = 2; // 3
2020 right_array[0] = v4; // 4
2021 right_array[1] = v2;
2022 right_array[2] = v1;
2030 left_array[0] = v4; // 1
2031 left_array[1] = v2; // 2
2032 left_array[2] = v1; // 3
2033 left_section = 2; // 4
2034 right_array[0] = v4;
2035 right_array[1] = v3;
2036 right_array[2] = v1;
2041 right_array[0] = v4;
2042 right_array[1] = v1;
2045 height = v3->y - v1->y; if(height == 0) height=1;
2046 longest1 = (((v2->y - v1->y) << 16) / height) * ((v3->x - v1->x)>>16) + (v1->x - v2->x);
2049 left_array[0] = v4; // 1
2050 left_array[1] = v3; // 3
2051 left_array[2] = v1; // 4
2056 height = v4->y - v2->y; if(height == 0) height=1;
2057 longest1 = (((v3->y - v2->y) << 16) / height) * ((v4->x - v2->x)>>16) + (v2->x - v3->x);
2060 left_array[0] = v4; // 1
2061 left_array[1] = v2; // 2
2062 left_array[2] = v1; // 4
2067 left_array[0] = v4; // 1
2068 left_array[1] = v3; // 2
2069 left_array[2] = v2; // 3
2070 left_array[3] = v1; // 4
2077 while(LeftSection_FT4()<=0)
2079 if(--left_section <= 0) break;
2082 while(RightSection_FT4()<=0)
2084 if(--right_section <= 0) break;
2088 Ymax=min(v4->y-1,drawH);
2093 ////////////////////////////////////////////////////////////////////////
2094 ////////////////////////////////////////////////////////////////////////
2096 static inline int RightSection_GT4(void)
2098 soft_vertex * v1 = right_array[ right_section ];
2099 soft_vertex * v2 = right_array[ right_section-1 ];
2101 int height = v2->y - v1->y;
2102 right_section_height = height;
2114 delta_right_x = (v2->x - v1->x) / height;
2115 delta_right_u = (v2->u - v1->u) / height;
2116 delta_right_v = (v2->v - v1->v) / height;
2117 delta_right_R = (v2->R - v1->R) / height;
2118 delta_right_G = (v2->G - v1->G) / height;
2119 delta_right_B = (v2->B - v1->B) / height;
2124 ////////////////////////////////////////////////////////////////////////
2126 static inline int LeftSection_GT4(void)
2128 soft_vertex * v1 = left_array[ left_section ];
2129 soft_vertex * v2 = left_array[ left_section-1 ];
2131 int height = v2->y - v1->y;
2132 left_section_height = height;
2144 delta_left_x = (v2->x - v1->x) / height;
2145 delta_left_u = (v2->u - v1->u) / height;
2146 delta_left_v = (v2->v - v1->v) / height;
2147 delta_left_R = (v2->R - v1->R) / height;
2148 delta_left_G = (v2->G - v1->G) / height;
2149 delta_left_B = (v2->B - v1->B) / height;
2154 ////////////////////////////////////////////////////////////////////////
2156 static inline BOOL NextRow_GT4(void)
2158 if(--left_section_height<=0)
2160 if(--left_section > 0)
2161 while(LeftSection_GT4()<=0)
2163 if(--left_section <= 0) break;
2168 left_x += delta_left_x;
2169 left_u += delta_left_u;
2170 left_v += delta_left_v;
2171 left_R += delta_left_R;
2172 left_G += delta_left_G;
2173 left_B += delta_left_B;
2176 if(--right_section_height<=0)
2178 if(--right_section > 0)
2179 while(RightSection_GT4()<=0)
2181 if(--right_section<=0) break;
2186 right_x += delta_right_x;
2187 right_u += delta_right_u;
2188 right_v += delta_right_v;
2189 right_R += delta_right_R;
2190 right_G += delta_right_G;
2191 right_B += delta_right_B;
2196 ////////////////////////////////////////////////////////////////////////
2198 static inline BOOL SetupSections_GT4(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4,int32_t rgb1,int32_t rgb2,int32_t rgb3,int32_t rgb4)
2200 soft_vertex * v1, * v2, * v3, * v4;
2201 int height,width,longest1,longest2;
2203 v1 = vtx; v1->x=x1<<16;v1->y=y1;
2204 v1->u=tx1<<16;v1->v=ty1<<16;
2205 v1->R=(rgb1) & 0x00ff0000;
2206 v1->G=(rgb1<<8) & 0x00ff0000;
2207 v1->B=(rgb1<<16) & 0x00ff0000;
2209 v2 = vtx+1; v2->x=x2<<16;v2->y=y2;
2210 v2->u=tx2<<16;v2->v=ty2<<16;
2211 v2->R=(rgb2) & 0x00ff0000;
2212 v2->G=(rgb2<<8) & 0x00ff0000;
2213 v2->B=(rgb2<<16) & 0x00ff0000;
2215 v3 = vtx+2; v3->x=x3<<16;v3->y=y3;
2216 v3->u=tx3<<16;v3->v=ty3<<16;
2217 v3->R=(rgb3) & 0x00ff0000;
2218 v3->G=(rgb3<<8) & 0x00ff0000;
2219 v3->B=(rgb3<<16) & 0x00ff0000;
2221 v4 = vtx+3; v4->x=x4<<16;v4->y=y4;
2222 v4->u=tx4<<16;v4->v=ty4<<16;
2223 v4->R=(rgb4) & 0x00ff0000;
2224 v4->G=(rgb4<<8) & 0x00ff0000;
2225 v4->B=(rgb4<<16) & 0x00ff0000;
2227 if(v1->y > v2->y) { soft_vertex * v = v1; v1 = v2; v2 = v; }
2228 if(v1->y > v3->y) { soft_vertex * v = v1; v1 = v3; v3 = v; }
2229 if(v1->y > v4->y) { soft_vertex * v = v1; v1 = v4; v4 = v; }
2230 if(v2->y > v3->y) { soft_vertex * v = v2; v2 = v3; v3 = v; }
2231 if(v2->y > v4->y) { soft_vertex * v = v2; v2 = v4; v4 = v; }
2232 if(v3->y > v4->y) { soft_vertex * v = v3; v3 = v4; v4 = v; }
2234 height = v4->y - v1->y; if(height == 0) height =1;
2235 width = (v4->x - v1->x)>>16;
2236 longest1 = (((v2->y - v1->y) << 16) / height) * width + (v1->x - v2->x);
2237 longest2 = (((v3->y - v1->y) << 16) / height) * width + (v1->x - v3->x);
2239 if(longest1 < 0) // 2 is right
2241 if(longest2 < 0) // 3 is right
2247 height = v3->y - v1->y; if(height == 0) height=1;
2248 longest1 = (((v2->y - v1->y) << 16) / height) * ((v3->x - v1->x)>>16) + (v1->x - v2->x);
2251 right_array[0] = v4; // 1
2252 right_array[1] = v3; // 3
2253 right_array[2] = v1; // 4
2258 height = v4->y - v2->y; if(height == 0) height=1;
2259 longest1 = (((v3->y - v2->y) << 16) / height) * ((v4->x - v2->x)>>16) + (v2->x - v3->x);
2262 right_array[0] = v4; // 1
2263 right_array[1] = v2; // 2
2264 right_array[2] = v1; // 4
2269 right_array[0] = v4; // 1
2270 right_array[1] = v3; // 2
2271 right_array[2] = v2; // 3
2272 right_array[3] = v1; // 4
2280 left_array[1] = v3; // 1
2281 left_array[2] = v1; // 2
2282 left_section = 2; // 3
2283 right_array[0] = v4; // 4
2284 right_array[1] = v2;
2285 right_array[2] = v1;
2293 left_array[0] = v4; // 1
2294 left_array[1] = v2; // 2
2295 left_array[2] = v1; // 3
2296 left_section = 2; // 4
2297 right_array[0] = v4;
2298 right_array[1] = v3;
2299 right_array[2] = v1;
2304 right_array[0] = v4;
2305 right_array[1] = v1;
2308 height = v3->y - v1->y; if(height == 0) height=1;
2309 longest1 = (((v2->y - v1->y) << 16) / height) * ((v3->x - v1->x)>>16) + (v1->x - v2->x);
2312 left_array[0] = v4; // 1
2313 left_array[1] = v3; // 3
2314 left_array[2] = v1; // 4
2319 height = v4->y - v2->y; if(height == 0) height=1;
2320 longest1 = (((v3->y - v2->y) << 16) / height) * ((v4->x - v2->x)>>16) + (v2->x - v3->x);
2323 left_array[0] = v4; // 1
2324 left_array[1] = v2; // 2
2325 left_array[2] = v1; // 4
2330 left_array[0] = v4; // 1
2331 left_array[1] = v3; // 2
2332 left_array[2] = v2; // 3
2333 left_array[3] = v1; // 4
2340 while(LeftSection_GT4()<=0)
2342 if(--left_section <= 0) break;
2345 while(RightSection_GT4()<=0)
2347 if(--right_section <= 0) break;
2351 Ymax=min(v4->y-1,drawH);
2356 ////////////////////////////////////////////////////////////////////////
2357 ////////////////////////////////////////////////////////////////////////
2358 ////////////////////////////////////////////////////////////////////////
2360 ////////////////////////////////////////////////////////////////////////
2361 ////////////////////////////////////////////////////////////////////////
2362 ////////////////////////////////////////////////////////////////////////
2364 ////////////////////////////////////////////////////////////////////////
2365 // POLY 3/4 FLAT SHADED
2366 ////////////////////////////////////////////////////////////////////////
2368 static inline void drawPoly3Fi(short x1,short y1,short x2,short y2,short x3,short y3,int32_t rgb)
2370 int i,j,xmin,xmax,ymin,ymax;
2371 unsigned short color;uint32_t lcolor;
2373 if(x1>drawW && x2>drawW && x3>drawW) return;
2374 if(y1>drawH && y2>drawH && y3>drawH) return;
2375 if(x1<drawX && x2<drawX && x3<drawX) return;
2376 if(y1<drawY && y2<drawY && y3<drawY) return;
2377 if(drawY>=drawH) return;
2378 if(drawX>=drawW) return;
2380 if(!SetupSections_F(x1,y1,x2,y2,x3,y3)) return;
2384 color = ((rgb & 0x00f80000)>>9) | ((rgb & 0x0000f800)>>6) | ((rgb & 0x000000f8)>>3);
2385 lcolor=lSetMask|(((uint32_t)(color))<<16)|color;
2387 for(ymin=Ymin;ymin<drawY;ymin++)
2388 if(NextRow_F()) return;
2392 if(!bCheckMask && !DrawSemiTrans)
2395 for (i=ymin;i<=ymax;i++)
2397 xmin=left_x >> 16; if(drawX>xmin) xmin=drawX;
2398 xmax=(right_x >> 16)-1; if(drawW<xmax) xmax=drawW;
2400 for(j=xmin;j<xmax;j+=2)
2402 PUTLE32(((uint32_t *)&psxVuw[(i<<10)+j]), lcolor);
2404 if(j==xmax) PUTLE16(&psxVuw[(i<<10)+j], color);
2406 if(NextRow_F()) return;
2413 for (i=ymin;i<=ymax;i++)
2415 xmin=left_x >> 16; if(drawX>xmin) xmin=drawX;
2416 xmax=(right_x >> 16)-1; if(drawW<xmax) xmax=drawW;
2418 for(j=xmin;j<xmax;j+=2)
2420 GetShadeTransCol32((uint32_t *)&psxVuw[(i<<10)+j],lcolor);
2423 GetShadeTransCol(&psxVuw[(i<<10)+j],color);
2425 if(NextRow_F()) return;
2429 ////////////////////////////////////////////////////////////////////////
2431 static void drawPoly3F(int32_t rgb)
2433 drawPoly3Fi(lx0,ly0,lx1,ly1,lx2,ly2,rgb);
2438 static void drawPoly4F_TRI(int32_t rgb)
2440 drawPoly3Fi(lx1,ly1,lx3,ly3,lx2,ly2,rgb);
2441 drawPoly3Fi(lx0,ly0,lx1,ly1,lx2,ly2,rgb);
2448 static void drawPoly4F(int32_t rgb)
2450 int i,j,xmin,xmax,ymin,ymax;
2451 unsigned short color;uint32_t lcolor;
2453 if(lx0>drawW && lx1>drawW && lx2>drawW && lx3>drawW) return;
2454 if(ly0>drawH && ly1>drawH && ly2>drawH && ly3>drawH) return;
2455 if(lx0<drawX && lx1<drawX && lx2<drawX && lx3<drawX) return;
2456 if(ly0<drawY && ly1<drawY && ly2<drawY && ly3<drawY) return;
2457 if(drawY>=drawH) return;
2458 if(drawX>=drawW) return;
2460 if(!SetupSections_F4(lx0,ly0,lx1,ly1,lx2,ly2,lx3,ly3)) return;
2464 for(ymin=Ymin;ymin<drawY;ymin++)
2465 if(NextRow_F4()) return;
2467 color = ((rgb & 0x00f80000)>>9) | ((rgb & 0x0000f800)>>6) | ((rgb & 0x000000f8)>>3);
2468 lcolor= lSetMask|(((uint32_t)(color))<<16)|color;
2472 if(!bCheckMask && !DrawSemiTrans)
2475 for (i=ymin;i<=ymax;i++)
2477 xmin=left_x >> 16; if(drawX>xmin) xmin=drawX;
2478 xmax=(right_x >> 16)-1; if(drawW<xmax) xmax=drawW;
2480 for(j=xmin;j<xmax;j+=2)
2482 PUTLE32(((uint32_t *)&psxVuw[(i<<10)+j]), lcolor);
2484 if(j==xmax) PUTLE16(&psxVuw[(i<<10)+j], color);
2486 if(NextRow_F4()) return;
2493 for (i=ymin;i<=ymax;i++)
2495 xmin=left_x >> 16; if(drawX>xmin) xmin=drawX;
2496 xmax=(right_x >> 16)-1; if(drawW<xmax) xmax=drawW;
2498 for(j=xmin;j<xmax;j+=2)
2500 GetShadeTransCol32((uint32_t *)&psxVuw[(i<<10)+j],lcolor);
2502 if(j==xmax) GetShadeTransCol(&psxVuw[(i<<10)+j],color);
2504 if(NextRow_F4()) return;
2508 ////////////////////////////////////////////////////////////////////////
2509 // POLY 3/4 F-SHADED TEX PAL 4
2510 ////////////////////////////////////////////////////////////////////////
2512 static void drawPoly3TEx4(short x1, short y1, short x2, short y2, short x3, short y3, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3,short clX, short clY)
2514 int i,j,xmin,xmax,ymin,ymax;
2515 int32_t difX, difY,difX2, difY2;
2516 int32_t posX,posY,YAdjust,XAdjust;
2520 if(x1>drawW && x2>drawW && x3>drawW) return;
2521 if(y1>drawH && y2>drawH && y3>drawH) return;
2522 if(x1<drawX && x2<drawX && x3<drawX) return;
2523 if(y1<drawY && y2<drawY && y3<drawY) return;
2524 if(drawY>=drawH) return;
2525 if(drawX>=drawW) return;
2527 if(!SetupSections_FT(x1,y1,x2,y2,x3,y3,tx1,ty1,tx2,ty2,tx3,ty3)) return;
2531 for(ymin=Ymin;ymin<drawY;ymin++)
2532 if(NextRow_FT()) return;
2534 clutP=(clY<<10)+clX;
2536 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
2538 difX=delta_right_u;difX2=difX<<1;
2539 difY=delta_right_v;difY2=difY<<1;
2543 if(!bCheckMask && !DrawSemiTrans)
2545 for (i=ymin;i<=ymax;i++)
2547 xmin=(left_x >> 16);
2548 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!!
2549 if(drawW<xmax) xmax=drawW;
2557 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
2559 for(j=xmin;j<xmax;j+=2)
2562 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(XAdjust>>1)];
2563 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
2564 XAdjust=((posX+difX)>>16);
2565 tC2 = psxVub[(((posY+difY)>>5)&(int32_t)0xFFFFF800)+YAdjust+
2567 tC2=(tC2>>((XAdjust&1)<<2))&0xf;
2569 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
2570 GETLE16(&psxVuw[clutP+tC1])|
2571 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
2579 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+
2581 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
2582 GetTextureTransColG_S(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
2595 for (i=ymin;i<=ymax;i++)
2597 xmin=(left_x >> 16);
2598 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!!!!
2599 if(drawW<xmax) xmax=drawW;
2607 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
2609 for(j=xmin;j<xmax;j+=2)
2612 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(XAdjust>>1)];
2613 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
2614 XAdjust=((posX+difX)>>16);
2615 tC2 = psxVub[(((posY+difY)>>5)&(int32_t)0xFFFFF800)+YAdjust+
2617 tC2=(tC2>>((XAdjust&1)<<2))&0xf;
2619 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
2620 GETLE16(&psxVuw[clutP+tC1])|
2621 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
2629 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+
2631 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
2632 GetTextureTransColG(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
2642 ////////////////////////////////////////////////////////////////////////
2644 static void drawPoly3TEx4_IL(short x1, short y1, short x2, short y2, short x3, short y3, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3,short clX, short clY)
2646 int i,j,xmin,xmax,ymin,ymax,n_xi,n_yi,TXV;
2647 int32_t difX, difY,difX2, difY2;
2648 int32_t posX,posY,YAdjust,XAdjust;
2652 if(x1>drawW && x2>drawW && x3>drawW) return;
2653 if(y1>drawH && y2>drawH && y3>drawH) return;
2654 if(x1<drawX && x2<drawX && x3<drawX) return;
2655 if(y1<drawY && y2<drawY && y3<drawY) return;
2656 if(drawY>=drawH) return;
2657 if(drawX>=drawW) return;
2659 if(!SetupSections_FT(x1,y1,x2,y2,x3,y3,tx1,ty1,tx2,ty2,tx3,ty3)) return;
2663 for(ymin=Ymin;ymin<drawY;ymin++)
2664 if(NextRow_FT()) return;
2666 clutP=(clY<<10)+clX;
2668 YAdjust=(GlobalTextAddrY<<10)+GlobalTextAddrX;
2670 difX=delta_right_u;difX2=difX<<1;
2671 difY=delta_right_v;difY2=difY<<1;
2675 if(!bCheckMask && !DrawSemiTrans)
2677 for (i=ymin;i<=ymax;i++)
2679 xmin=(left_x >> 16);
2680 xmax=(right_x >> 16)-1;
2681 if(drawW<xmax) xmax=drawW;
2689 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
2691 for(j=xmin;j<xmax;j+=2)
2696 n_xi = ( ( XAdjust >> 2 ) & ~0x3c ) + ( ( TXV << 2 ) & 0x3c );
2697 n_yi = ( TXV & ~0xf ) + ( ( XAdjust >> 4 ) & 0xf );
2699 tC1= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((XAdjust & 0x03)<<2)) & 0x0f ;
2701 XAdjust=((posX+difX)>>16);
2703 TXV=(posY+difY)>>16;
2704 n_xi = ( ( XAdjust >> 2 ) & ~0x3c ) + ( ( TXV << 2 ) & 0x3c );
2705 n_yi = ( TXV & ~0xf ) + ( ( XAdjust >> 4 ) & 0xf );
2707 tC2= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((XAdjust & 0x03)<<2)) & 0x0f ;
2709 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
2710 GETLE16(&psxVuw[clutP+tC1])|
2711 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
2721 n_xi = ( ( XAdjust >> 2 ) & ~0x3c ) + ( ( TXV << 2 ) & 0x3c );
2722 n_yi = ( TXV & ~0xf ) + ( ( XAdjust >> 4 ) & 0xf );
2724 tC1= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((XAdjust & 0x03)<<2)) & 0x0f ;
2726 GetTextureTransColG_S(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
2739 for (i=ymin;i<=ymax;i++)
2741 xmin=(left_x >> 16);
2742 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!!!!
2743 if(drawW<xmax) xmax=drawW;
2751 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
2753 for(j=xmin;j<xmax;j+=2)
2758 n_xi = ( ( XAdjust >> 2 ) & ~0x3c ) + ( ( TXV << 2 ) & 0x3c );
2759 n_yi = ( TXV & ~0xf ) + ( ( XAdjust >> 4 ) & 0xf );
2761 tC1= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((XAdjust & 0x03)<<2)) & 0x0f ;
2763 XAdjust=((posX+difX)>>16);
2765 TXV=(posY+difY)>>16;
2766 n_xi = ( ( XAdjust >> 2 ) & ~0x3c ) + ( ( TXV << 2 ) & 0x3c );
2767 n_yi = ( TXV & ~0xf ) + ( ( XAdjust >> 4 ) & 0xf );
2769 tC2= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((XAdjust & 0x03)<<2)) & 0x0f ;
2771 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
2772 GETLE16(&psxVuw[clutP+tC1])|
2773 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
2783 n_xi = ( ( XAdjust >> 2 ) & ~0x3c ) + ( ( TXV << 2 ) & 0x3c );
2784 n_yi = ( TXV & ~0xf ) + ( ( XAdjust >> 4 ) & 0xf );
2786 tC1= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((XAdjust & 0x03)<<2)) & 0x0f ;
2788 GetTextureTransColG(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
2798 ////////////////////////////////////////////////////////////////////////
2800 static void drawPoly3TEx4_TW(short x1, short y1, short x2, short y2, short x3, short y3, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3,short clX, short clY)
2802 int i,j,xmin,xmax,ymin,ymax;
2803 int32_t difX, difY,difX2, difY2;
2804 int32_t posX,posY,YAdjust,XAdjust;
2808 if(x1>drawW && x2>drawW && x3>drawW) return;
2809 if(y1>drawH && y2>drawH && y3>drawH) return;
2810 if(x1<drawX && x2<drawX && x3<drawX) return;
2811 if(y1<drawY && y2<drawY && y3<drawY) return;
2812 if(drawY>=drawH) return;
2813 if(drawX>=drawW) return;
2815 if(!SetupSections_FT(x1,y1,x2,y2,x3,y3,tx1,ty1,tx2,ty2,tx3,ty3)) return;
2819 for(ymin=Ymin;ymin<drawY;ymin++)
2820 if(NextRow_FT()) return;
2822 clutP=(clY<<10)+clX;
2824 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
2825 YAdjust+=(TWin.Position.y0<<11)+(TWin.Position.x0>>1);
2827 difX=delta_right_u;difX2=difX<<1;
2828 difY=delta_right_v;difY2=difY<<1;
2832 if(!bCheckMask && !DrawSemiTrans)
2834 for (i=ymin;i<=ymax;i++)
2836 xmin=(left_x >> 16);
2837 xmax=(right_x >> 16);//-1; //!!!!!!!!!!!!!!!!
2838 if(xmax>xmin) xmax--;
2840 if(drawW<xmax) xmax=drawW;
2848 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
2850 for(j=xmin;j<xmax;j+=2)
2852 XAdjust=(posX>>16)%TWin.Position.x1;
2853 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
2854 YAdjust+(XAdjust>>1)];
2855 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
2856 XAdjust=((posX+difX)>>16)%TWin.Position.x1;
2857 tC2 = psxVub[((((posY+difY)>>16)%TWin.Position.y1)<<11)+
2858 YAdjust+(XAdjust>>1)];
2859 tC2=(tC2>>((XAdjust&1)<<2))&0xf;
2861 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
2862 GETLE16(&psxVuw[clutP+tC1])|
2863 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
2870 XAdjust=(posX>>16)%TWin.Position.x1;
2871 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
2872 YAdjust+(XAdjust>>1)];
2873 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
2874 GetTextureTransColG_S(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
2887 for (i=ymin;i<=ymax;i++)
2889 xmin=(left_x >> 16);
2890 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!!!!
2891 if(drawW<xmax) xmax=drawW;
2899 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
2901 for(j=xmin;j<xmax;j+=2)
2903 XAdjust=(posX>>16)%TWin.Position.x1;
2904 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
2905 YAdjust+(XAdjust>>1)];
2906 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
2907 XAdjust=((posX+difX)>>16)%TWin.Position.x1;
2908 tC2 = psxVub[((((posY+difY)>>16)%TWin.Position.y1)<<11)+
2909 YAdjust+(XAdjust>>1)];
2910 tC2=(tC2>>((XAdjust&1)<<2))&0xf;
2912 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
2913 GETLE16(&psxVuw[clutP+tC1])|
2914 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
2921 XAdjust=(posX>>16)%TWin.Position.x1;
2922 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
2923 YAdjust+(XAdjust>>1)];
2924 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
2925 GetTextureTransColG(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
2935 ////////////////////////////////////////////////////////////////////////
2939 static void drawPoly4TEx4_TRI(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4,short clX, short clY)
2941 drawPoly3TEx4(x2,y2,x3,y3,x4,y4,
2942 tx2,ty2,tx3,ty3,tx4,ty4,
2944 drawPoly3TEx4(x1,y1,x2,y2,x4,y4,
2945 tx1,ty1,tx2,ty2,tx4,ty4,
2953 static void drawPoly4TEx4(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4,short clX, short clY)
2956 int32_t i,j,xmin,xmax,ymin,ymax;
2957 int32_t difX, difY, difX2, difY2;
2958 int32_t posX,posY,YAdjust,clutP,XAdjust;
2961 if(x1>drawW && x2>drawW && x3>drawW && x4>drawW) return;
2962 if(y1>drawH && y2>drawH && y3>drawH && y4>drawH) return;
2963 if(x1<drawX && x2<drawX && x3<drawX && x4<drawX) return;
2964 if(y1<drawY && y2<drawY && y3<drawY && y4<drawY) return;
2965 if(drawY>=drawH) return;
2966 if(drawX>=drawW) return;
2968 if(!SetupSections_FT4(x1,y1,x2,y2,x3,y3,x4,y4,tx1,ty1,tx2,ty2,tx3,ty3,tx4,ty4)) return;
2972 for(ymin=Ymin;ymin<drawY;ymin++)
2973 if(NextRow_FT4()) return;
2975 clutP=(clY<<10)+clX;
2977 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
2981 if(!bCheckMask && !DrawSemiTrans)
2983 for (i=ymin;i<=ymax;i++)
2985 xmin=(left_x >> 16);
2986 xmax=(right_x >> 16);
2995 difX=(right_u-posX)/num;
2996 difY=(right_v-posY)/num;
3001 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3002 xmax--;if(drawW<xmax) xmax=drawW;
3004 for(j=xmin;j<xmax;j+=2)
3007 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(XAdjust>>1)];
3008 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
3009 XAdjust=((posX+difX)>>16);
3010 tC2 = psxVub[(((posY+difY)>>5)&(int32_t)0xFFFFF800)+YAdjust+
3012 tC2=(tC2>>((XAdjust&1)<<2))&0xf;
3014 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
3015 GETLE16(&psxVuw[clutP+tC1])|
3016 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3023 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+
3025 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
3026 GetTextureTransColG_S(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3030 if(NextRow_FT4()) return;
3037 for (i=ymin;i<=ymax;i++)
3039 xmin=(left_x >> 16);
3040 xmax=(right_x >> 16);
3049 difX=(right_u-posX)/num;
3050 difY=(right_v-posY)/num;
3055 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3056 xmax--;if(drawW<xmax) xmax=drawW;
3058 for(j=xmin;j<xmax;j+=2)
3061 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(XAdjust>>1)];
3062 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
3063 XAdjust=((posX+difX)>>16);
3064 tC2 = psxVub[(((posY+difY)>>5)&(int32_t)0xFFFFF800)+YAdjust+
3066 tC2=(tC2>>((XAdjust&1)<<2))&0xf;
3068 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
3069 GETLE16(&psxVuw[clutP+tC1])|
3070 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3077 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+
3079 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
3080 GetTextureTransColG(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3083 if(NextRow_FT4()) return;
3087 ////////////////////////////////////////////////////////////////////////
3089 static void drawPoly4TEx4_IL(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4,short clX, short clY)
3092 int32_t i,j=0,xmin,xmax,ymin,ymax,n_xi,n_yi,TXV;
3093 int32_t difX, difY, difX2, difY2;
3094 int32_t posX=0,posY=0,YAdjust,clutP,XAdjust;
3097 if(x1>drawW && x2>drawW && x3>drawW && x4>drawW) return;
3098 if(y1>drawH && y2>drawH && y3>drawH && y4>drawH) return;
3099 if(x1<drawX && x2<drawX && x3<drawX && x4<drawX) return;
3100 if(y1<drawY && y2<drawY && y3<drawY && y4<drawY) return;
3101 if(drawY>=drawH) return;
3102 if(drawX>=drawW) return;
3104 if(!SetupSections_FT4(x1,y1,x2,y2,x3,y3,x4,y4,tx1,ty1,tx2,ty2,tx3,ty3,tx4,ty4)) return;
3108 for(ymin=Ymin;ymin<drawY;ymin++)
3109 if(NextRow_FT4()) return;
3111 clutP=(clY<<10)+clX;
3113 YAdjust=((GlobalTextAddrY)<<10)+GlobalTextAddrX;
3117 if(!bCheckMask && !DrawSemiTrans)
3119 for (i=ymin;i<=ymax;i++)
3121 xmin=(left_x >> 16);
3122 xmax=(right_x >> 16);
3131 difX=(right_u-posX)/num;
3132 difY=(right_v-posY)/num;
3137 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3138 xmax--;if(drawW<xmax) xmax=drawW;
3140 for(j=xmin;j<xmax;j+=2)
3145 n_xi = ( ( XAdjust >> 2 ) & ~0x3c ) + ( ( TXV << 2 ) & 0x3c );
3146 n_yi = ( TXV & ~0xf ) + ( ( XAdjust >> 4 ) & 0xf );
3148 tC1= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((XAdjust & 0x03)<<2)) & 0x0f ;
3150 XAdjust=((posX+difX)>>16);
3152 TXV=(posY+difY)>>16;
3153 n_xi = ( ( XAdjust >> 2 ) & ~0x3c ) + ( ( TXV << 2 ) & 0x3c );
3154 n_yi = ( TXV & ~0xf ) + ( ( XAdjust >> 4 ) & 0xf );
3156 tC2= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((XAdjust & 0x03)<<2)) & 0x0f ;
3158 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
3159 GETLE16(&psxVuw[clutP+tC1])|
3160 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3172 n_xi = ( ( XAdjust >> 2 ) & ~0x3c ) + ( ( TXV << 2 ) & 0x3c );
3173 n_yi = ( TXV & ~0xf ) + ( ( XAdjust >> 4 ) & 0xf );
3175 tC1= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((XAdjust & 0x03)<<2)) & 0x0f ;
3177 GetTextureTransColG_S(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3181 if(NextRow_FT4()) return;
3185 for (i=ymin;i<=ymax;i++)
3187 xmin=(left_x >> 16);
3188 xmax=(right_x >> 16);
3197 difX=(right_u-posX)/num;
3198 difY=(right_v-posY)/num;
3203 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3204 xmax--;if(drawW<xmax) xmax=drawW;
3206 for(j=xmin;j<xmax;j+=2)
3211 n_xi = ( ( XAdjust >> 2 ) & ~0x3c ) + ( ( TXV << 2 ) & 0x3c );
3212 n_yi = ( TXV & ~0xf ) + ( ( XAdjust >> 4 ) & 0xf );
3214 tC1= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((XAdjust & 0x03)<<2)) & 0x0f ;
3216 XAdjust=((posX+difX)>>16);
3218 TXV=(posY+difY)>>16;
3219 n_xi = ( ( XAdjust >> 2 ) & ~0x3c ) + ( ( TXV << 2 ) & 0x3c );
3220 n_yi = ( TXV & ~0xf ) + ( ( XAdjust >> 4 ) & 0xf );
3222 tC2= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((XAdjust & 0x03)<<2)) & 0x0f ;
3224 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
3225 GETLE16(&psxVuw[clutP+tC1])|
3226 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3234 n_xi = ( ( XAdjust >> 2 ) & ~0x3c ) + ( ( TXV << 2 ) & 0x3c );
3235 n_yi = ( TXV & ~0xf ) + ( ( XAdjust >> 4 ) & 0xf );
3237 tC1= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((XAdjust & 0x03)<<2)) & 0x0f ;
3239 GetTextureTransColG(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3242 if(NextRow_FT4()) return;
3246 ////////////////////////////////////////////////////////////////////////
3248 static void drawPoly4TEx4_TW(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4,short clX, short clY)
3251 int32_t i,j,xmin,xmax,ymin,ymax;
3252 int32_t difX, difY, difX2, difY2;
3253 int32_t posX,posY,YAdjust,clutP,XAdjust;
3256 if(x1>drawW && x2>drawW && x3>drawW && x4>drawW) return;
3257 if(y1>drawH && y2>drawH && y3>drawH && y4>drawH) return;
3258 if(x1<drawX && x2<drawX && x3<drawX && x4<drawX) return;
3259 if(y1<drawY && y2<drawY && y3<drawY && y4<drawY) return;
3260 if(drawY>=drawH) return;
3261 if(drawX>=drawW) return;
3263 if(!SetupSections_FT4(x1,y1,x2,y2,x3,y3,x4,y4,tx1,ty1,tx2,ty2,tx3,ty3,tx4,ty4)) return;
3267 for(ymin=Ymin;ymin<drawY;ymin++)
3268 if(NextRow_FT4()) return;
3270 clutP=(clY<<10)+clX;
3272 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
3273 YAdjust+=(TWin.Position.y0<<11)+(TWin.Position.x0>>1);
3277 if(!bCheckMask && !DrawSemiTrans)
3279 for (i=ymin;i<=ymax;i++)
3281 xmin=(left_x >> 16);
3282 xmax=(right_x >> 16);
3291 difX=(right_u-posX)/num;
3292 difY=(right_v-posY)/num;
3297 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3298 xmax--;if(drawW<xmax) xmax=drawW;
3300 for(j=xmin;j<xmax;j+=2)
3302 XAdjust=(posX>>16)%TWin.Position.x1;
3303 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
3304 YAdjust+(XAdjust>>1)];
3305 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
3306 XAdjust=((posX+difX)>>16)%TWin.Position.x1;
3307 tC2 = psxVub[((((posY+difY)>>16)%TWin.Position.y1)<<11)+
3308 YAdjust+(XAdjust>>1)];
3309 tC2=(tC2>>((XAdjust&1)<<2))&0xf;
3311 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
3312 GETLE16(&psxVuw[clutP+tC1])|
3313 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3319 XAdjust=(posX>>16)%TWin.Position.x1;
3320 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
3321 YAdjust+(XAdjust>>1)];
3322 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
3323 GetTextureTransColG_S(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3326 if(NextRow_FT4()) return;
3333 for (i=ymin;i<=ymax;i++)
3335 xmin=(left_x >> 16);
3336 xmax=(right_x >> 16);
3345 difX=(right_u-posX)/num;
3346 difY=(right_v-posY)/num;
3351 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3352 xmax--;if(drawW<xmax) xmax=drawW;
3354 for(j=xmin;j<xmax;j+=2)
3356 XAdjust=(posX>>16)%TWin.Position.x1;
3357 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
3358 YAdjust+(XAdjust>>1)];
3359 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
3360 XAdjust=((posX+difX)>>16)%TWin.Position.x1;
3361 tC2 = psxVub[((((posY+difY)>>16)%TWin.Position.y1)<<11)+
3362 YAdjust+(XAdjust>>1)];
3363 tC2=(tC2>>((XAdjust&1)<<2))&0xf;
3365 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
3366 GETLE16(&psxVuw[clutP+tC1])|
3367 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3373 XAdjust=(posX>>16)%TWin.Position.x1;
3374 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
3375 YAdjust+(XAdjust>>1)];
3376 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
3377 GetTextureTransColG(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3380 if(NextRow_FT4()) return;
3384 ////////////////////////////////////////////////////////////////////////
3386 static void drawPoly4TEx4_TW_S(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4,short clX, short clY)
3389 int32_t i,j,xmin,xmax,ymin,ymax;
3390 int32_t difX, difY, difX2, difY2;
3391 int32_t posX,posY,YAdjust,clutP,XAdjust;
3394 if(x1>drawW && x2>drawW && x3>drawW && x4>drawW) return;
3395 if(y1>drawH && y2>drawH && y3>drawH && y4>drawH) return;
3396 if(x1<drawX && x2<drawX && x3<drawX && x4<drawX) return;
3397 if(y1<drawY && y2<drawY && y3<drawY && y4<drawY) return;
3398 if(drawY>=drawH) return;
3399 if(drawX>=drawW) return;
3401 if(!SetupSections_FT4(x1,y1,x2,y2,x3,y3,x4,y4,tx1,ty1,tx2,ty2,tx3,ty3,tx4,ty4)) return;
3405 for(ymin=Ymin;ymin<drawY;ymin++)
3406 if(NextRow_FT4()) return;
3408 clutP=(clY<<10)+clX;
3410 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
3411 YAdjust+=(TWin.Position.y0<<11)+(TWin.Position.x0>>1);
3415 if(!bCheckMask && !DrawSemiTrans)
3417 for (i=ymin;i<=ymax;i++)
3419 xmin=(left_x >> 16);
3420 xmax=(right_x >> 16);
3429 difX=(right_u-posX)/num;
3430 difY=(right_v-posY)/num;
3435 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3436 xmax--;if(drawW<xmax) xmax=drawW;
3438 for(j=xmin;j<xmax;j+=2)
3440 XAdjust=(posX>>16)%TWin.Position.x1;
3441 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
3442 YAdjust+(XAdjust>>1)];
3443 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
3444 XAdjust=((posX+difX)>>16)%TWin.Position.x1;
3445 tC2 = psxVub[((((posY+difY)>>16)%TWin.Position.y1)<<11)+
3446 YAdjust+(XAdjust>>1)];
3447 tC2=(tC2>>((XAdjust&1)<<2))&0xf;
3449 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
3450 GETLE16(&psxVuw[clutP+tC1])|
3451 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3457 XAdjust=(posX>>16)%TWin.Position.x1;
3458 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
3459 YAdjust+(XAdjust>>1)];
3460 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
3461 GetTextureTransColG_S(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3464 if(NextRow_FT4()) return;
3471 for (i=ymin;i<=ymax;i++)
3473 xmin=(left_x >> 16);
3474 xmax=(right_x >> 16);
3483 difX=(right_u-posX)/num;
3484 difY=(right_v-posY)/num;
3489 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3490 xmax--;if(drawW<xmax) xmax=drawW;
3492 for(j=xmin;j<xmax;j+=2)
3494 XAdjust=(posX>>16)%TWin.Position.x1;
3495 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
3496 YAdjust+(XAdjust>>1)];
3497 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
3498 XAdjust=((posX+difX)>>16)%TWin.Position.x1;
3499 tC2 = psxVub[((((posY+difY)>>16)%TWin.Position.y1)<<11)+
3500 YAdjust+(XAdjust>>1)];
3501 tC2=(tC2>>((XAdjust&1)<<2))&0xf;
3503 GetTextureTransColG32_SPR((uint32_t *)&psxVuw[(i<<10)+j],
3504 GETLE16(&psxVuw[clutP+tC1])|
3505 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3511 XAdjust=(posX>>16)%TWin.Position.x1;
3512 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
3513 YAdjust+(XAdjust>>1)];
3514 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
3515 GetTextureTransColG_SPR(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3518 if(NextRow_FT4()) return;
3521 ////////////////////////////////////////////////////////////////////////
3522 // POLY 3 F-SHADED TEX PAL 8
3523 ////////////////////////////////////////////////////////////////////////
3525 static void drawPoly3TEx8(short x1, short y1, short x2, short y2, short x3, short y3, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3,short clX, short clY)
3527 int i,j,xmin,xmax,ymin,ymax;
3528 int32_t difX, difY,difX2, difY2;
3529 int32_t posX,posY,YAdjust,clutP;
3532 if(x1>drawW && x2>drawW && x3>drawW) return;
3533 if(y1>drawH && y2>drawH && y3>drawH) return;
3534 if(x1<drawX && x2<drawX && x3<drawX) return;
3535 if(y1<drawY && y2<drawY && y3<drawY) return;
3536 if(drawY>=drawH) return;
3537 if(drawX>=drawW) return;
3539 if(!SetupSections_FT(x1,y1,x2,y2,x3,y3,tx1,ty1,tx2,ty2,tx3,ty3)) return;
3543 for(ymin=Ymin;ymin<drawY;ymin++)
3544 if(NextRow_FT()) return;
3546 clutP=(clY<<10)+clX;
3548 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
3550 difX=delta_right_u;difX2=difX<<1;
3551 difY=delta_right_v;difY2=difY<<1;
3555 if(!bCheckMask && !DrawSemiTrans)
3557 for (i=ymin;i<=ymax;i++)
3559 xmin=(left_x >> 16);
3560 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!
3561 if(drawW<xmax) xmax=drawW;
3569 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3571 for(j=xmin;j<xmax;j+=2)
3573 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(posX>>16)];
3574 tC2 = psxVub[(((posY+difY)>>5)&(int32_t)0xFFFFF800)+YAdjust+
3576 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
3577 GETLE16(&psxVuw[clutP+tC1])|
3578 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3585 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(posX>>16)];
3586 GetTextureTransColG_S(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3599 for (i=ymin;i<=ymax;i++)
3601 xmin=(left_x >> 16);
3602 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!!!
3603 if(drawW<xmax) xmax=drawW;
3611 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3613 for(j=xmin;j<xmax;j+=2)
3615 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(posX>>16)];
3616 tC2 = psxVub[(((posY+difY)>>5)&(int32_t)0xFFFFF800)+YAdjust+
3618 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
3619 GETLE16(&psxVuw[clutP+tC1])|
3620 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3627 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(posX>>16)];
3628 GetTextureTransColG(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3639 ////////////////////////////////////////////////////////////////////////
3641 static void drawPoly3TEx8_IL(short x1, short y1, short x2, short y2, short x3, short y3, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3,short clX, short clY)
3643 int i,j,xmin,xmax,ymin,ymax,n_xi,n_yi,TXV,TXU;
3644 int32_t difX, difY,difX2, difY2;
3645 int32_t posX,posY,YAdjust,clutP;
3648 if(x1>drawW && x2>drawW && x3>drawW) return;
3649 if(y1>drawH && y2>drawH && y3>drawH) return;
3650 if(x1<drawX && x2<drawX && x3<drawX) return;
3651 if(y1<drawY && y2<drawY && y3<drawY) return;
3652 if(drawY>=drawH) return;
3653 if(drawX>=drawW) return;
3655 if(!SetupSections_FT(x1,y1,x2,y2,x3,y3,tx1,ty1,tx2,ty2,tx3,ty3)) return;
3659 for(ymin=Ymin;ymin<drawY;ymin++)
3660 if(NextRow_FT()) return;
3662 clutP=(clY<<10)+clX;
3664 YAdjust=(GlobalTextAddrY<<10)+GlobalTextAddrX;
3666 difX=delta_right_u;difX2=difX<<1;
3667 difY=delta_right_v;difY2=difY<<1;
3671 if(!bCheckMask && !DrawSemiTrans)
3673 for (i=ymin;i<=ymax;i++)
3675 xmin=(left_x >> 16);
3676 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!
3677 if(drawW<xmax) xmax=drawW;
3685 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3687 for(j=xmin;j<xmax;j+=2)
3691 n_xi = ( ( TXU >> 1 ) & ~0x78 ) + ( ( TXU << 2 ) & 0x40 ) + ( ( TXV << 3 ) & 0x38 );
3692 n_yi = ( TXV & ~0x7 ) + ( ( TXU >> 5 ) & 0x7 );
3694 tC1= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((TXU & 0x01)<<3)) & 0xff;
3696 TXU=(posX+difX)>>16;
3697 TXV=(posY+difY)>>16;
3698 n_xi = ( ( TXU >> 1 ) & ~0x78 ) + ( ( TXU << 2 ) & 0x40 ) + ( ( TXV << 3 ) & 0x38 );
3699 n_yi = ( TXV & ~0x7 ) + ( ( TXU >> 5 ) & 0x7 );
3701 tC2= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((TXU & 0x01)<<3)) & 0xff;
3703 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
3704 GETLE16(&psxVuw[clutP+tC1])|
3705 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3714 n_xi = ( ( TXU >> 1 ) & ~0x78 ) + ( ( TXU << 2 ) & 0x40 ) + ( ( TXV << 3 ) & 0x38 );
3715 n_yi = ( TXV & ~0x7 ) + ( ( TXU >> 5 ) & 0x7 );
3717 tC1= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((TXU & 0x01)<<3)) & 0xff;
3719 GetTextureTransColG_S(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3732 for (i=ymin;i<=ymax;i++)
3734 xmin=(left_x >> 16);
3735 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!!!
3736 if(drawW<xmax) xmax=drawW;
3744 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3746 for(j=xmin;j<xmax;j+=2)
3750 n_xi = ( ( TXU >> 1 ) & ~0x78 ) + ( ( TXU << 2 ) & 0x40 ) + ( ( TXV << 3 ) & 0x38 );
3751 n_yi = ( TXV & ~0x7 ) + ( ( TXU >> 5 ) & 0x7 );
3753 tC1= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((TXU & 0x01)<<3)) & 0xff;
3755 TXU=(posX+difX)>>16;
3756 TXV=(posY+difY)>>16;
3757 n_xi = ( ( TXU >> 1 ) & ~0x78 ) + ( ( TXU << 2 ) & 0x40 ) + ( ( TXV << 3 ) & 0x38 );
3758 n_yi = ( TXV & ~0x7 ) + ( ( TXU >> 5 ) & 0x7 );
3760 tC2= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((TXU & 0x01)<<3)) & 0xff;
3762 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
3763 GETLE16(&psxVuw[clutP+tC1])|
3764 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3773 n_xi = ( ( TXU >> 1 ) & ~0x78 ) + ( ( TXU << 2 ) & 0x40 ) + ( ( TXV << 3 ) & 0x38 );
3774 n_yi = ( TXV & ~0x7 ) + ( ( TXU >> 5 ) & 0x7 );
3776 tC1= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((TXU & 0x01)<<3)) & 0xff;
3778 GetTextureTransColG(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3789 ////////////////////////////////////////////////////////////////////////
3791 static void drawPoly3TEx8_TW(short x1, short y1, short x2, short y2, short x3, short y3, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3,short clX, short clY)
3793 int i,j,xmin,xmax,ymin,ymax;
3794 int32_t difX, difY,difX2, difY2;
3795 int32_t posX,posY,YAdjust,clutP;
3798 if(x1>drawW && x2>drawW && x3>drawW) return;
3799 if(y1>drawH && y2>drawH && y3>drawH) return;
3800 if(x1<drawX && x2<drawX && x3<drawX) return;
3801 if(y1<drawY && y2<drawY && y3<drawY) return;
3802 if(drawY>=drawH) return;
3803 if(drawX>=drawW) return;
3805 if(!SetupSections_FT(x1,y1,x2,y2,x3,y3,tx1,ty1,tx2,ty2,tx3,ty3)) return;
3809 for(ymin=Ymin;ymin<drawY;ymin++)
3810 if(NextRow_FT()) return;
3812 clutP=(clY<<10)+clX;
3814 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
3815 YAdjust+=(TWin.Position.y0<<11)+(TWin.Position.x0);
3817 difX=delta_right_u;difX2=difX<<1;
3818 difY=delta_right_v;difY2=difY<<1;
3822 if(!bCheckMask && !DrawSemiTrans)
3824 for (i=ymin;i<=ymax;i++)
3826 xmin=(left_x >> 16);
3827 xmax=(right_x >> 16);//-1; //!!!!!!!!!!!!!!!!
3828 if(xmax>xmin) xmax--;
3830 if(drawW<xmax) xmax=drawW;
3838 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3840 for(j=xmin;j<xmax;j+=2)
3842 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
3843 YAdjust+((posX>>16)%TWin.Position.x1)];
3844 tC2 = psxVub[((((posY+difY)>>16)%TWin.Position.y1)<<11)+
3845 YAdjust+(((posX+difX)>>16)%TWin.Position.x1)];
3846 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
3847 GETLE16(&psxVuw[clutP+tC1])|
3848 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3855 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
3856 YAdjust+((posX>>16)%TWin.Position.x1)];
3857 GetTextureTransColG_S(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3870 for (i=ymin;i<=ymax;i++)
3872 xmin=(left_x >> 16);
3873 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!!!
3874 if(drawW<xmax) xmax=drawW;
3882 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3884 for(j=xmin;j<xmax;j+=2)
3886 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
3887 YAdjust+((posX>>16)%TWin.Position.x1)];
3888 tC2 = psxVub[((((posY+difY)>>16)%TWin.Position.y1)<<11)+
3889 YAdjust+(((posX+difX)>>16)%TWin.Position.x1)];
3890 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
3891 GETLE16(&psxVuw[clutP+tC1])|
3892 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3899 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
3900 YAdjust+((posX>>16)%TWin.Position.x1)];
3901 GetTextureTransColG(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3912 ////////////////////////////////////////////////////////////////////////
3916 static void drawPoly4TEx8_TRI(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4,short clX, short clY)
3918 drawPoly3TEx8(x2,y2,x3,y3,x4,y4,
3919 tx2,ty2,tx3,ty3,tx4,ty4,
3922 drawPoly3TEx8(x1,y1,x2,y2,x4,y4,
3923 tx1,ty1,tx2,ty2,tx4,ty4,
3931 static void drawPoly4TEx8(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4,short clX, short clY)
3934 int32_t i,j,xmin,xmax,ymin,ymax;
3935 int32_t difX, difY, difX2, difY2;
3936 int32_t posX,posY,YAdjust,clutP;
3939 if(x1>drawW && x2>drawW && x3>drawW && x4>drawW) return;
3940 if(y1>drawH && y2>drawH && y3>drawH && y4>drawH) return;
3941 if(x1<drawX && x2<drawX && x3<drawX && x4<drawX) return;
3942 if(y1<drawY && y2<drawY && y3<drawY && y4<drawY) return;
3943 if(drawY>=drawH) return;
3944 if(drawX>=drawW) return;
3946 if(!SetupSections_FT4(x1,y1,x2,y2,x3,y3,x4,y4,tx1,ty1,tx2,ty2,tx3,ty3,tx4,ty4)) return;
3950 for(ymin=Ymin;ymin<drawY;ymin++)
3951 if(NextRow_FT4()) return;
3953 clutP=(clY<<10)+clX;
3955 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
3959 if(!bCheckMask && !DrawSemiTrans)
3961 for (i=ymin;i<=ymax;i++)
3963 xmin=(left_x >> 16);
3964 xmax=(right_x >> 16);
3973 difX=(right_u-posX)/num;
3974 difY=(right_v-posY)/num;
3979 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3980 xmax--;if(drawW<xmax) xmax=drawW;
3982 for(j=xmin;j<xmax;j+=2)
3984 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(posX>>16)];
3985 tC2 = psxVub[(((posY+difY)>>5)&(int32_t)0xFFFFF800)+YAdjust+
3987 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
3988 GETLE16(&psxVuw[clutP+tC1])|
3989 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3995 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(posX>>16)];
3996 GetTextureTransColG_S(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3999 if(NextRow_FT4()) return;
4006 for (i=ymin;i<=ymax;i++)
4008 xmin=(left_x >> 16);
4009 xmax=(right_x >> 16);
4018 difX=(right_u-posX)/num;
4019 difY=(right_v-posY)/num;
4024 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
4025 xmax--;if(drawW<xmax) xmax=drawW;
4027 for(j=xmin;j<xmax;j+=2)
4029 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(posX>>16)];
4030 tC2 = psxVub[(((posY+difY)>>5)&(int32_t)0xFFFFF800)+YAdjust+
4032 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
4033 GETLE16(&psxVuw[clutP+tC1])|
4034 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
4040 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(posX>>16)];
4041 GetTextureTransColG(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
4044 if(NextRow_FT4()) return;
4048 ////////////////////////////////////////////////////////////////////////
4050 static void drawPoly4TEx8_IL(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4,short clX, short clY)
4053 int32_t i,j,xmin,xmax,ymin,ymax,n_xi,n_yi,TXV,TXU;
4054 int32_t difX, difY, difX2, difY2;
4055 int32_t posX,posY,YAdjust,clutP;
4058 if(x1>drawW && x2>drawW && x3>drawW && x4>drawW) return;
4059 if(y1>drawH && y2>drawH && y3>drawH && y4>drawH) return;
4060 if(x1<drawX && x2<drawX && x3<drawX && x4<drawX) return;
4061 if(y1<drawY && y2<drawY && y3<drawY && y4<drawY) return;
4062 if(drawY>=drawH) return;
4063 if(drawX>=drawW) return;
4065 if(!SetupSections_FT4(x1,y1,x2,y2,x3,y3,x4,y4,tx1,ty1,tx2,ty2,tx3,ty3,tx4,ty4)) return;
4069 for(ymin=Ymin;ymin<drawY;ymin++)
4070 if(NextRow_FT4()) return;
4072 clutP=(clY<<10)+clX;
4074 YAdjust=(GlobalTextAddrY<<10)+GlobalTextAddrX;
4078 if(!bCheckMask && !DrawSemiTrans)
4080 for (i=ymin;i<=ymax;i++)
4082 xmin=(left_x >> 16);
4083 xmax=(right_x >> 16);
4092 difX=(right_u-posX)/num;
4093 difY=(right_v-posY)/num;
4098 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
4099 xmax--;if(drawW<xmax) xmax=drawW;
4101 for(j=xmin;j<xmax;j+=2)
4105 n_xi = ( ( TXU >> 1 ) & ~0x78 ) + ( ( TXU << 2 ) & 0x40 ) + ( ( TXV << 3 ) & 0x38 );
4106 n_yi = ( TXV & ~0x7 ) + ( ( TXU >> 5 ) & 0x7 );
4108 tC1= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((TXU & 0x01)<<3)) & 0xff;
4110 TXU=(posX+difX)>>16;
4111 TXV=(posY+difY)>>16;
4112 n_xi = ( ( TXU >> 1 ) & ~0x78 ) + ( ( TXU << 2 ) & 0x40 ) + ( ( TXV << 3 ) & 0x38 );
4113 n_yi = ( TXV & ~0x7 ) + ( ( TXU >> 5 ) & 0x7 );
4115 tC2= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((TXU & 0x01)<<3)) & 0xff;
4117 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
4118 GETLE16(&psxVuw[clutP+tC1])|
4119 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
4127 n_xi = ( ( TXU >> 1 ) & ~0x78 ) + ( ( TXU << 2 ) & 0x40 ) + ( ( TXV << 3 ) & 0x38 );
4128 n_yi = ( TXV & ~0x7 ) + ( ( TXU >> 5 ) & 0x7 );
4130 tC1= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((TXU & 0x01)<<3)) & 0xff;
4132 GetTextureTransColG_S(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
4135 if(NextRow_FT4()) return;
4142 for (i=ymin;i<=ymax;i++)
4144 xmin=(left_x >> 16);
4145 xmax=(right_x >> 16);
4154 difX=(right_u-posX)/num;
4155 difY=(right_v-posY)/num;
4160 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
4161 xmax--;if(drawW<xmax) xmax=drawW;
4163 for(j=xmin;j<xmax;j+=2)
4167 n_xi = ( ( TXU >> 1 ) & ~0x78 ) + ( ( TXU << 2 ) & 0x40 ) + ( ( TXV << 3 ) & 0x38 );
4168 n_yi = ( TXV & ~0x7 ) + ( ( TXU >> 5 ) & 0x7 );
4170 tC1= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((TXU & 0x01)<<3)) & 0xff;
4172 TXU=(posX+difX)>>16;
4173 TXV=(posY+difY)>>16;
4174 n_xi = ( ( TXU >> 1 ) & ~0x78 ) + ( ( TXU << 2 ) & 0x40 ) + ( ( TXV << 3 ) & 0x38 );
4175 n_yi = ( TXV & ~0x7 ) + ( ( TXU >> 5 ) & 0x7 );
4177 tC2= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((TXU & 0x01)<<3)) & 0xff;
4179 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
4180 GETLE16(&psxVuw[clutP+tC1])|
4181 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
4189 n_xi = ( ( TXU >> 1 ) & ~0x78 ) + ( ( TXU << 2 ) & 0x40 ) + ( ( TXV << 3 ) & 0x38 );
4190 n_yi = ( TXV & ~0x7 ) + ( ( TXU >> 5 ) & 0x7 );
4191 tC1= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((TXU & 0x01)<<3)) & 0xff;
4192 GetTextureTransColG(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
4195 if(NextRow_FT4()) return;
4199 ////////////////////////////////////////////////////////////////////////
4201 static void drawPoly4TEx8_TW(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4,short clX, short clY)
4204 int32_t i,j,xmin,xmax,ymin,ymax;
4205 int32_t difX, difY, difX2, difY2;
4206 int32_t posX,posY,YAdjust,clutP;
4209 if(x1>drawW && x2>drawW && x3>drawW && x4>drawW) return;
4210 if(y1>drawH && y2>drawH && y3>drawH && y4>drawH) return;
4211 if(x1<drawX && x2<drawX && x3<drawX && x4<drawX) return;
4212 if(y1<drawY && y2<drawY && y3<drawY && y4<drawY) return;
4213 if(drawY>=drawH) return;
4214 if(drawX>=drawW) return;
4216 if(!SetupSections_FT4(x1,y1,x2,y2,x3,y3,x4,y4,tx1,ty1,tx2,ty2,tx3,ty3,tx4,ty4)) return;
4220 for(ymin=Ymin;ymin<drawY;ymin++)
4221 if(NextRow_FT4()) return;
4223 clutP=(clY<<10)+clX;
4225 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
4226 YAdjust+=(TWin.Position.y0<<11)+(TWin.Position.x0);
4230 if(!bCheckMask && !DrawSemiTrans)
4232 for (i=ymin;i<=ymax;i++)
4234 xmin=(left_x >> 16);
4235 xmax=(right_x >> 16);
4244 difX=(right_u-posX)/num;
4245 difY=(right_v-posY)/num;
4250 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
4251 xmax--;if(drawW<xmax) xmax=drawW;
4253 for(j=xmin;j<xmax;j+=2)
4255 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
4256 YAdjust+((posX>>16)%TWin.Position.x1)];
4257 tC2 = psxVub[((((posY+difY)>>16)%TWin.Position.y1)<<11)+
4258 YAdjust+(((posX+difX)>>16)%TWin.Position.x1)];
4259 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
4260 GETLE16(&psxVuw[clutP+tC1])|
4261 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
4267 tC1 = psxVub[((((posY+difY)>>16)%TWin.Position.y1)<<11)+
4268 YAdjust+((posX>>16)%TWin.Position.x1)];
4269 GetTextureTransColG_S(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
4272 if(NextRow_FT4()) return;
4280 for (i=ymin;i<=ymax;i++)
4282 xmin=(left_x >> 16);
4283 xmax=(right_x >> 16);
4292 difX=(right_u-posX)/num;
4293 difY=(right_v-posY)/num;
4298 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
4299 xmax--;if(drawW<xmax) xmax=drawW;
4301 for(j=xmin;j<xmax;j+=2)
4303 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
4304 YAdjust+((posX>>16)%TWin.Position.x1)];
4305 tC2 = psxVub[((((posY+difY)>>16)%TWin.Position.y1)<<11)+
4306 YAdjust+(((posX+difX)>>16)%TWin.Position.x1)];
4307 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
4308 GETLE16(&psxVuw[clutP+tC1])|
4309 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
4315 tC1 = psxVub[((((posY+difY)>>16)%TWin.Position.y1)<<11)+
4316 YAdjust+((posX>>16)%TWin.Position.x1)];
4317 GetTextureTransColG(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
4320 if(NextRow_FT4()) return;
4324 ////////////////////////////////////////////////////////////////////////
4326 static void drawPoly4TEx8_TW_S(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4,short clX, short clY)
4329 int32_t i,j,xmin,xmax,ymin,ymax;
4330 int32_t difX, difY, difX2, difY2;
4331 int32_t posX,posY,YAdjust,clutP;
4334 if(x1>drawW && x2>drawW && x3>drawW && x4>drawW) return;
4335 if(y1>drawH && y2>drawH && y3>drawH && y4>drawH) return;
4336 if(x1<drawX && x2<drawX && x3<drawX && x4<drawX) return;
4337 if(y1<drawY && y2<drawY && y3<drawY && y4<drawY) return;
4338 if(drawY>=drawH) return;
4339 if(drawX>=drawW) return;
4341 if(!SetupSections_FT4(x1,y1,x2,y2,x3,y3,x4,y4,tx1,ty1,tx2,ty2,tx3,ty3,tx4,ty4)) return;
4345 for(ymin=Ymin;ymin<drawY;ymin++)
4346 if(NextRow_FT4()) return;
4348 clutP=(clY<<10)+clX;
4350 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
4351 YAdjust+=(TWin.Position.y0<<11)+(TWin.Position.x0);
4355 if(!bCheckMask && !DrawSemiTrans)
4357 for (i=ymin;i<=ymax;i++)
4359 xmin=(left_x >> 16);
4360 xmax=(right_x >> 16);
4369 difX=(right_u-posX)/num;
4370 difY=(right_v-posY)/num;
4375 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
4376 xmax--;if(drawW<xmax) xmax=drawW;
4378 for(j=xmin;j<xmax;j+=2)
4380 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
4381 YAdjust+((posX>>16)%TWin.Position.x1)];
4382 tC2 = psxVub[((((posY+difY)>>16)%TWin.Position.y1)<<11)+
4383 YAdjust+(((posX+difX)>>16)%TWin.Position.x1)];
4384 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
4385 GETLE16(&psxVuw[clutP+tC1])|
4386 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
4392 tC1 = psxVub[((((posY+difY)>>16)%TWin.Position.y1)<<11)+
4393 YAdjust+((posX>>16)%TWin.Position.x1)];
4394 GetTextureTransColG_S(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
4397 if(NextRow_FT4()) return;
4405 for (i=ymin;i<=ymax;i++)
4407 xmin=(left_x >> 16);
4408 xmax=(right_x >> 16);
4417 difX=(right_u-posX)/num;
4418 difY=(right_v-posY)/num;
4423 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
4424 xmax--;if(drawW<xmax) xmax=drawW;
4426 for(j=xmin;j<xmax;j+=2)
4428 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
4429 YAdjust+((posX>>16)%TWin.Position.x1)];
4430 tC2 = psxVub[((((posY+difY)>>16)%TWin.Position.y1)<<11)+
4431 YAdjust+(((posX+difX)>>16)%TWin.Position.x1)];
4432 GetTextureTransColG32_SPR((uint32_t *)&psxVuw[(i<<10)+j],
4433 GETLE16(&psxVuw[clutP+tC1])|
4434 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
4440 tC1 = psxVub[((((posY+difY)>>16)%TWin.Position.y1)<<11)+
4441 YAdjust+((posX>>16)%TWin.Position.x1)];
4442 GetTextureTransColG_SPR(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
4445 if(NextRow_FT4()) return;
4449 ////////////////////////////////////////////////////////////////////////
4450 // POLY 3 F-SHADED TEX 15 BIT
4451 ////////////////////////////////////////////////////////////////////////
4453 static void drawPoly3TD(short x1, short y1, short x2, short y2, short x3, short y3, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3)
4455 int i,j,xmin,xmax,ymin,ymax;
4456 int32_t difX, difY,difX2, difY2;
4459 if(x1>drawW && x2>drawW && x3>drawW) return;
4460 if(y1>drawH && y2>drawH && y3>drawH) return;
4461 if(x1<drawX && x2<drawX && x3<drawX) return;
4462 if(y1<drawY && y2<drawY && y3<drawY) return;
4463 if(drawY>=drawH) return;
4464 if(drawX>=drawW) return;
4466 if(!SetupSections_FT(x1,y1,x2,y2,x3,y3,tx1,ty1,tx2,ty2,tx3,ty3)) return;
4470 for(ymin=Ymin;ymin<drawY;ymin++)
4471 if(NextRow_FT()) return;
4473 difX=delta_right_u;difX2=difX<<1;
4474 difY=delta_right_v;difY2=difY<<1;
4478 if(!bCheckMask && !DrawSemiTrans)
4480 for (i=ymin;i<=ymax;i++)
4482 xmin=(left_x >> 16);
4483 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!
4484 if(drawW<xmax) xmax=drawW;
4492 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
4494 for(j=xmin;j<xmax;j+=2)
4496 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
4497 (((int32_t)GETLE16(&psxVuw[((((posY+difY)>>16)+GlobalTextAddrY)<<10)+((posX+difX)>>16)+GlobalTextAddrX]))<<16)|
4498 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+((posX)>>16)+GlobalTextAddrX]));
4504 GetTextureTransColG_S(&psxVuw[(i<<10)+j],
4505 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+(posX>>16)+GlobalTextAddrX]));
4517 for (i=ymin;i<=ymax;i++)
4519 xmin=(left_x >> 16);
4520 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!
4521 if(drawW<xmax) xmax=drawW;
4529 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
4531 for(j=xmin;j<xmax;j+=2)
4533 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
4534 (((int32_t)GETLE16(&psxVuw[((((posY+difY)>>16)+GlobalTextAddrY)<<10)+((posX+difX)>>16)+GlobalTextAddrX]))<<16)|
4535 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+((posX)>>16)+GlobalTextAddrX]));
4541 GetTextureTransColG(&psxVuw[(i<<10)+j],
4542 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+(posX>>16)+GlobalTextAddrX]));
4551 ////////////////////////////////////////////////////////////////////////
4553 static void drawPoly3TD_TW(short x1, short y1, short x2, short y2, short x3, short y3, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3)
4555 int i,j,xmin,xmax,ymin,ymax;
4556 int32_t difX, difY,difX2, difY2;
4559 if(x1>drawW && x2>drawW && x3>drawW) return;
4560 if(y1>drawH && y2>drawH && y3>drawH) return;
4561 if(x1<drawX && x2<drawX && x3<drawX) return;
4562 if(y1<drawY && y2<drawY && y3<drawY) return;
4563 if(drawY>=drawH) return;
4564 if(drawX>=drawW) return;
4566 if(!SetupSections_FT(x1,y1,x2,y2,x3,y3,tx1,ty1,tx2,ty2,tx3,ty3)) return;
4570 for(ymin=Ymin;ymin<drawY;ymin++)
4571 if(NextRow_FT()) return;
4573 difX=delta_right_u;difX2=difX<<1;
4574 difY=delta_right_v;difY2=difY<<1;
4578 if(!bCheckMask && !DrawSemiTrans)
4580 for (i=ymin;i<=ymax;i++)
4582 xmin=(left_x >> 16);
4583 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!
4584 if(drawW<xmax) xmax=drawW;
4592 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
4594 for(j=xmin;j<xmax;j+=2)
4596 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
4597 (((int32_t)GETLE16(&psxVuw[(((((posY+difY)>>16)%TWin.Position.y1)+GlobalTextAddrY+TWin.Position.y0)<<10)+
4598 (((posX+difX)>>16)%TWin.Position.x1)+GlobalTextAddrX+TWin.Position.x0]))<<16)|
4599 GETLE16(&psxVuw[((((posY>>16)%TWin.Position.y1)+GlobalTextAddrY+TWin.Position.y0)<<10)+
4600 (((posX)>>16)%TWin.Position.x1)+GlobalTextAddrX+TWin.Position.x0]));
4606 GetTextureTransColG_S(&psxVuw[(i<<10)+j],
4607 GETLE16(&psxVuw[((((posY>>16)%TWin.Position.y1)+GlobalTextAddrY+TWin.Position.y0)<<10)+
4608 ((posX>>16)%TWin.Position.x1)+GlobalTextAddrX+TWin.Position.x0]));
4620 for (i=ymin;i<=ymax;i++)
4622 xmin=(left_x >> 16);
4623 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!
4624 if(drawW<xmax) xmax=drawW;
4632 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
4634 for(j=xmin;j<xmax;j+=2)
4636 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
4637 (((int32_t)GETLE16(&psxVuw[(((((posY+difY)>>16)%TWin.Position.y1)+GlobalTextAddrY+TWin.Position.y0)<<10)+
4638 (((posX+difX)>>16)%TWin.Position.x1)+GlobalTextAddrX+TWin.Position.x0]))<<16)|
4639 GETLE16(&psxVuw[((((posY>>16)%TWin.Position.y1)+GlobalTextAddrY+TWin.Position.y0)<<10)+
4640 (((posX)>>16)%TWin.Position.x1)+GlobalTextAddrX+TWin.Position.x0]));
4646 GetTextureTransColG(&psxVuw[(i<<10)+j],
4647 GETLE16(&psxVuw[((((posY>>16)%TWin.Position.y1)+GlobalTextAddrY+TWin.Position.y0)<<10)+
4648 ((posX>>16)%TWin.Position.x1)+GlobalTextAddrX+TWin.Position.x0]));
4658 ////////////////////////////////////////////////////////////////////////
4662 static void drawPoly4TD_TRI(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4)
4664 drawPoly3TD(x2,y2,x3,y3,x4,y4,
4665 tx2,ty2,tx3,ty3,tx4,ty4);
4666 drawPoly3TD(x1,y1,x2,y2,x4,y4,
4667 tx1,ty1,tx2,ty2,tx4,ty4);
4674 static void drawPoly4TD(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4)
4677 int32_t i,j,xmin,xmax,ymin,ymax;
4678 int32_t difX, difY, difX2, difY2;
4681 if(x1>drawW && x2>drawW && x3>drawW && x4>drawW) return;
4682 if(y1>drawH && y2>drawH && y3>drawH && y4>drawH) return;
4683 if(x1<drawX && x2<drawX && x3<drawX && x4<drawX) return;
4684 if(y1<drawY && y2<drawY && y3<drawY && y4<drawY) return;
4685 if(drawY>=drawH) return;
4686 if(drawX>=drawW) return;
4688 if(!SetupSections_FT4(x1,y1,x2,y2,x3,y3,x4,y4,tx1,ty1,tx2,ty2,tx3,ty3,tx4,ty4)) return;
4692 for(ymin=Ymin;ymin<drawY;ymin++)
4693 if(NextRow_FT4()) return;
4697 if(!bCheckMask && !DrawSemiTrans)
4699 for (i=ymin;i<=ymax;i++)
4701 xmin=(left_x >> 16);
4702 xmax=(right_x >> 16);
4711 difX=(right_u-posX)/num;
4712 difY=(right_v-posY)/num;
4717 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
4718 xmax--;if(drawW<xmax) xmax=drawW;
4720 for(j=xmin;j<xmax;j+=2)
4722 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
4723 (((int32_t)GETLE16(&psxVuw[((((posY+difY)>>16)+GlobalTextAddrY)<<10)+((posX+difX)>>16)+GlobalTextAddrX]))<<16)|
4724 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+((posX)>>16)+GlobalTextAddrX]));
4730 GetTextureTransColG_S(&psxVuw[(i<<10)+j],
4731 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+(posX>>16)+GlobalTextAddrX]));
4733 if(NextRow_FT4()) return;
4740 for (i=ymin;i<=ymax;i++)
4742 xmin=(left_x >> 16);
4743 xmax=(right_x >> 16);
4752 difX=(right_u-posX)/num;
4753 difY=(right_v-posY)/num;
4758 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
4759 xmax--;if(drawW<xmax) xmax=drawW;
4761 for(j=xmin;j<xmax;j+=2)
4763 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
4764 (((int32_t)GETLE16(&psxVuw[((((posY+difY)>>16)+GlobalTextAddrY)<<10)+((posX+difX)>>16)+GlobalTextAddrX]))<<16)|
4765 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+((posX)>>16)+GlobalTextAddrX]));
4771 GetTextureTransColG(&psxVuw[(i<<10)+j],
4772 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+(posX>>16)+GlobalTextAddrX]));
4774 if(NextRow_FT4()) return;
4778 ////////////////////////////////////////////////////////////////////////
4780 static void drawPoly4TD_TW(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4)
4783 int32_t i,j,xmin,xmax,ymin,ymax;
4784 int32_t difX, difY, difX2, difY2;
4787 if(x1>drawW && x2>drawW && x3>drawW && x4>drawW) return;
4788 if(y1>drawH && y2>drawH && y3>drawH && y4>drawH) return;
4789 if(x1<drawX && x2<drawX && x3<drawX && x4<drawX) return;
4790 if(y1<drawY && y2<drawY && y3<drawY && y4<drawY) return;
4791 if(drawY>=drawH) return;
4792 if(drawX>=drawW) return;
4794 if(!SetupSections_FT4(x1,y1,x2,y2,x3,y3,x4,y4,tx1,ty1,tx2,ty2,tx3,ty3,tx4,ty4)) return;
4798 for(ymin=Ymin;ymin<drawY;ymin++)
4799 if(NextRow_FT4()) return;
4803 if(!bCheckMask && !DrawSemiTrans)
4805 for (i=ymin;i<=ymax;i++)
4807 xmin=(left_x >> 16);
4808 xmax=(right_x >> 16);
4817 difX=(right_u-posX)/num;
4818 difY=(right_v-posY)/num;
4823 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
4824 xmax--;if(drawW<xmax) xmax=drawW;
4826 for(j=xmin;j<xmax;j+=2)
4828 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
4829 (((int32_t)GETLE16(&psxVuw[(((((posY+difY)>>16)%TWin.Position.y1)+GlobalTextAddrY+TWin.Position.y0)<<10)+
4830 (((posX+difX)>>16)%TWin.Position.x1)+GlobalTextAddrX+TWin.Position.x0]))<<16)|
4831 GETLE16(&psxVuw[((((posY>>16)%TWin.Position.y1)+GlobalTextAddrY)<<10)+TWin.Position.y0+
4832 ((posX>>16)%TWin.Position.x1)+GlobalTextAddrX+TWin.Position.x0]));
4838 GetTextureTransColG_S(&psxVuw[(i<<10)+j],
4839 GETLE16(&psxVuw[((((posY>>16)%TWin.Position.y1)+GlobalTextAddrY+TWin.Position.y0)<<10)+
4840 ((posX>>16)%TWin.Position.x1)+GlobalTextAddrX+TWin.Position.x0]));
4842 if(NextRow_FT4()) return;
4849 for (i=ymin;i<=ymax;i++)
4851 xmin=(left_x >> 16);
4852 xmax=(right_x >> 16);
4861 difX=(right_u-posX)/num;
4862 difY=(right_v-posY)/num;
4867 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
4868 xmax--;if(drawW<xmax) xmax=drawW;
4870 for(j=xmin;j<xmax;j+=2)
4872 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
4873 (((int32_t)GETLE16(&psxVuw[(((((posY+difY)>>16)%TWin.Position.y1)+GlobalTextAddrY+TWin.Position.y0)<<10)+
4874 (((posX+difX)>>16)%TWin.Position.x1)+GlobalTextAddrX+TWin.Position.x0]))<<16)|
4875 GETLE16(&psxVuw[((((posY>>16)%TWin.Position.y1)+GlobalTextAddrY+TWin.Position.y0)<<10)+
4876 ((posX>>16)%TWin.Position.x1)+GlobalTextAddrX+TWin.Position.x0]));
4882 GetTextureTransColG(&psxVuw[(i<<10)+j],
4883 GETLE16(&psxVuw[((((posY>>16)%TWin.Position.y1)+GlobalTextAddrY+TWin.Position.y0)<<10)+
4884 ((posX>>16)%TWin.Position.x1)+GlobalTextAddrX+TWin.Position.x0]));
4886 if(NextRow_FT4()) return;
4890 ////////////////////////////////////////////////////////////////////////
4892 static void drawPoly4TD_TW_S(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4)
4895 int32_t i,j,xmin,xmax,ymin,ymax;
4896 int32_t difX, difY, difX2, difY2;
4899 if(x1>drawW && x2>drawW && x3>drawW && x4>drawW) return;
4900 if(y1>drawH && y2>drawH && y3>drawH && y4>drawH) return;
4901 if(x1<drawX && x2<drawX && x3<drawX && x4<drawX) return;
4902 if(y1<drawY && y2<drawY && y3<drawY && y4<drawY) return;
4903 if(drawY>=drawH) return;
4904 if(drawX>=drawW) return;
4906 if(!SetupSections_FT4(x1,y1,x2,y2,x3,y3,x4,y4,tx1,ty1,tx2,ty2,tx3,ty3,tx4,ty4)) return;
4910 for(ymin=Ymin;ymin<drawY;ymin++)
4911 if(NextRow_FT4()) return;
4915 if(!bCheckMask && !DrawSemiTrans)
4917 for (i=ymin;i<=ymax;i++)
4919 xmin=(left_x >> 16);
4920 xmax=(right_x >> 16);
4929 difX=(right_u-posX)/num;
4930 difY=(right_v-posY)/num;
4935 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
4936 xmax--;if(drawW<xmax) xmax=drawW;
4938 for(j=xmin;j<xmax;j+=2)
4940 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
4941 (((int32_t)GETLE16(&psxVuw[(((((posY+difY)>>16)%TWin.Position.y1)+GlobalTextAddrY+TWin.Position.y0)<<10)+
4942 (((posX+difX)>>16)%TWin.Position.x1)+GlobalTextAddrX+TWin.Position.x0]))<<16)|
4943 GETLE16(&psxVuw[((((posY>>16)%TWin.Position.y1)+GlobalTextAddrY)<<10)+TWin.Position.y0+
4944 ((posX>>16)%TWin.Position.x1)+GlobalTextAddrX+TWin.Position.x0]));
4950 GetTextureTransColG_S(&psxVuw[(i<<10)+j],
4951 GETLE16(&psxVuw[((((posY>>16)%TWin.Position.y1)+GlobalTextAddrY+TWin.Position.y0)<<10)+
4952 ((posX>>16)%TWin.Position.x1)+GlobalTextAddrX+TWin.Position.x0]));
4954 if(NextRow_FT4()) return;
4961 for (i=ymin;i<=ymax;i++)
4963 xmin=(left_x >> 16);
4964 xmax=(right_x >> 16);
4973 difX=(right_u-posX)/num;
4974 difY=(right_v-posY)/num;
4979 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
4980 xmax--;if(drawW<xmax) xmax=drawW;
4982 for(j=xmin;j<xmax;j+=2)
4984 GetTextureTransColG32_SPR((uint32_t *)&psxVuw[(i<<10)+j],
4985 (((int32_t)GETLE16(&psxVuw[(((((posY+difY)>>16)%TWin.Position.y1)+GlobalTextAddrY+TWin.Position.y0)<<10)+
4986 (((posX+difX)>>16)%TWin.Position.x1)+GlobalTextAddrX+TWin.Position.x0]))<<16)|
4987 GETLE16(&psxVuw[((((posY>>16)%TWin.Position.y1)+GlobalTextAddrY+TWin.Position.y0)<<10)+
4988 ((posX>>16)%TWin.Position.x1)+GlobalTextAddrX+TWin.Position.x0]));
4994 GetTextureTransColG_SPR(&psxVuw[(i<<10)+j],
4995 GETLE16(&psxVuw[((((posY>>16)%TWin.Position.y1)+GlobalTextAddrY+TWin.Position.y0)<<10)+
4996 ((posX>>16)%TWin.Position.x1)+GlobalTextAddrX+TWin.Position.x0]));
4998 if(NextRow_FT4()) return;
5002 ////////////////////////////////////////////////////////////////////////
5003 // POLY 3/4 G-SHADED
5004 ////////////////////////////////////////////////////////////////////////
5006 static inline void drawPoly3Gi(short x1,short y1,short x2,short y2,short x3,short y3,int32_t rgb1, int32_t rgb2, int32_t rgb3)
5008 int i,j,xmin,xmax,ymin,ymax;
5009 int32_t cR1,cG1,cB1;
5010 int32_t difR,difB,difG,difR2,difB2,difG2;
5012 if(x1>drawW && x2>drawW && x3>drawW) return;
5013 if(y1>drawH && y2>drawH && y3>drawH) return;
5014 if(x1<drawX && x2<drawX && x3<drawX) return;
5015 if(y1<drawY && y2<drawY && y3<drawY) return;
5016 if(drawY>=drawH) return;
5017 if(drawX>=drawW) return;
5019 if(!SetupSections_G(x1,y1,x2,y2,x3,y3,rgb1,rgb2,rgb3)) return;
5023 for(ymin=Ymin;ymin<drawY;ymin++)
5024 if(NextRow_G()) return;
5035 if(!bCheckMask && !DrawSemiTrans && iDither!=2)
5037 for (i=ymin;i<=ymax;i++)
5039 xmin=(left_x >> 16);
5040 xmax=(right_x >> 16)-1;if(drawW<xmax) xmax=drawW;
5049 {j=drawX-xmin;xmin=drawX;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
5051 for(j=xmin;j<xmax;j+=2)
5053 PUTLE32(((uint32_t *)&psxVuw[(i<<10)+j]),
5054 ((((cR1+difR) <<7)&0x7c000000)|(((cG1+difG) << 2)&0x03e00000)|(((cB1+difB)>>3)&0x001f0000)|
5055 (((cR1) >> 9)&0x7c00)|(((cG1) >> 14)&0x03e0)|(((cB1) >> 19)&0x001f))|lSetMask);
5062 PUTLE16(&psxVuw[(i<<10)+j], (((cR1 >> 9)&0x7c00)|((cG1 >> 14)&0x03e0)|((cB1 >> 19)&0x001f))|sSetMask);
5064 if(NextRow_G()) return;
5072 for (i=ymin;i<=ymax;i++)
5074 xmin=(left_x >> 16);
5075 xmax=(right_x >> 16)-1;if(drawW<xmax) xmax=drawW;
5084 {j=drawX-xmin;xmin=drawX;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
5086 for(j=xmin;j<=xmax;j++)
5088 GetShadeTransCol_Dither(&psxVuw[(i<<10)+j],(cB1>>16),(cG1>>16),(cR1>>16));
5095 if(NextRow_G()) return;
5098 for (i=ymin;i<=ymax;i++)
5100 xmin=(left_x >> 16);
5101 xmax=(right_x >> 16)-1;if(drawW<xmax) xmax=drawW;
5110 {j=drawX-xmin;xmin=drawX;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
5112 for(j=xmin;j<=xmax;j++)
5114 GetShadeTransCol(&psxVuw[(i<<10)+j],((cR1 >> 9)&0x7c00)|((cG1 >> 14)&0x03e0)|((cB1 >> 19)&0x001f));
5121 if(NextRow_G()) return;
5126 ////////////////////////////////////////////////////////////////////////
5128 static void drawPoly3G(int32_t rgb1, int32_t rgb2, int32_t rgb3)
5130 drawPoly3Gi(lx0,ly0,lx1,ly1,lx2,ly2,rgb1,rgb2,rgb3);
5133 // draw two g-shaded tris for right psx shading emulation
5135 static void drawPoly4G(int32_t rgb1, int32_t rgb2, int32_t rgb3, int32_t rgb4)
5137 drawPoly3Gi(lx1,ly1,lx3,ly3,lx2,ly2,
5139 drawPoly3Gi(lx0,ly0,lx1,ly1,lx2,ly2,
5143 ////////////////////////////////////////////////////////////////////////
5144 // POLY 3/4 G-SHADED TEX PAL4
5145 ////////////////////////////////////////////////////////////////////////
5147 static void drawPoly3TGEx4(short x1, short y1, short x2, short y2, short x3, short y3, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short clX, short clY,int32_t col1, int32_t col2, int32_t col3)
5149 int i,j,xmin,xmax,ymin,ymax;
5150 int32_t cR1,cG1,cB1;
5151 int32_t difR,difB,difG,difR2,difB2,difG2;
5152 int32_t difX, difY,difX2, difY2;
5153 int32_t posX,posY,YAdjust,clutP,XAdjust;
5156 if(x1>drawW && x2>drawW && x3>drawW) return;
5157 if(y1>drawH && y2>drawH && y3>drawH) return;
5158 if(x1<drawX && x2<drawX && x3<drawX) return;
5159 if(y1<drawY && y2<drawY && y3<drawY) return;
5160 if(drawY>=drawH) return;
5161 if(drawX>=drawW) return;
5163 if(!SetupSections_GT(x1,y1,x2,y2,x3,y3,tx1,ty1,tx2,ty2,tx3,ty3,col1,col2,col3)) return;
5167 for(ymin=Ymin;ymin<drawY;ymin++)
5168 if(NextRow_GT()) return;
5170 clutP=(clY<<10)+clX;
5172 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
5181 difX=delta_right_u;difX2=difX<<1;
5182 difY=delta_right_v;difY2=difY<<1;
5186 if(!bCheckMask && !DrawSemiTrans && !iDither)
5188 for (i=ymin;i<=ymax;i++)
5190 xmin=((left_x) >> 16);
5191 xmax=((right_x) >> 16)-1; //!!!!!!!!!!!!!
5192 if(drawW<xmax) xmax=drawW;
5203 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
5205 for(j=xmin;j<xmax;j+=2)
5208 tC1 = psxVub[((posY>>5)&0xFFFFF800)+YAdjust+(XAdjust>>1)];
5209 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
5210 XAdjust=((posX+difX)>>16);
5211 tC2 = psxVub[(((posY+difY)>>5)&(int32_t)0xFFFFF800)+YAdjust+
5213 tC2=(tC2>>((XAdjust&1)<<2))&0xf;
5215 GetTextureTransColGX32_S((uint32_t *)&psxVuw[(i<<10)+j],
5216 GETLE16(&psxVuw[clutP+tC1])|
5217 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16,
5218 (cB1>>16)|((cB1+difB)&0xff0000),
5219 (cG1>>16)|((cG1+difG)&0xff0000),
5220 (cR1>>16)|((cR1+difR)&0xff0000));
5230 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(XAdjust>>1)];
5231 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
5232 GetTextureTransColGX_S(&psxVuw[(i<<10)+j],
5233 GETLE16(&psxVuw[clutP+tC1]),
5234 (cB1>>16),(cG1>>16),(cR1>>16));
5247 for (i=ymin;i<=ymax;i++)
5249 xmin=(left_x >> 16);
5250 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!!
5251 if(drawW<xmax) xmax=drawW;
5262 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
5264 for(j=xmin;j<=xmax;j++)
5267 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(XAdjust>>1)];
5268 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
5270 GetTextureTransColGX_Dither(&psxVuw[(i<<10)+j],
5271 GETLE16(&psxVuw[clutP+tC1]),
5272 (cB1>>16),(cG1>>16),(cR1>>16));
5274 GetTextureTransColGX(&psxVuw[(i<<10)+j],
5275 GETLE16(&psxVuw[clutP+tC1]),
5276 (cB1>>16),(cG1>>16),(cR1>>16));
5291 ////////////////////////////////////////////////////////////////////////
5293 static void drawPoly3TGEx4_IL(short x1, short y1, short x2, short y2, short x3, short y3, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short clX, short clY,int32_t col1, int32_t col2, int32_t col3)
5295 int i,j,xmin,xmax,ymin,ymax,n_xi,n_yi,TXV;
5296 int32_t cR1,cG1,cB1;
5297 int32_t difR,difB,difG,difR2,difB2,difG2;
5298 int32_t difX, difY,difX2, difY2;
5299 int32_t posX,posY,YAdjust,clutP,XAdjust;
5302 if(x1>drawW && x2>drawW && x3>drawW) return;
5303 if(y1>drawH && y2>drawH && y3>drawH) return;
5304 if(x1<drawX && x2<drawX && x3<drawX) return;
5305 if(y1<drawY && y2<drawY && y3<drawY) return;
5306 if(drawY>=drawH) return;
5307 if(drawX>=drawW) return;
5309 if(!SetupSections_GT(x1,y1,x2,y2,x3,y3,tx1,ty1,tx2,ty2,tx3,ty3,col1,col2,col3)) return;
5313 for(ymin=Ymin;ymin<drawY;ymin++)
5314 if(NextRow_GT()) return;
5316 clutP=(clY<<10)+clX;
5318 YAdjust=(GlobalTextAddrY<<10)+GlobalTextAddrX;
5327 difX=delta_right_u;difX2=difX<<1;
5328 difY=delta_right_v;difY2=difY<<1;
5332 if(!bCheckMask && !DrawSemiTrans && !iDither)
5334 for (i=ymin;i<=ymax;i++)
5336 xmin=((left_x) >> 16);
5337 xmax=((right_x) >> 16)-1; //!!!!!!!!!!!!!
5338 if(drawW<xmax) xmax=drawW;
5349 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
5351 for(j=xmin;j<xmax;j+=2)
5356 n_xi = ( ( XAdjust >> 2 ) & ~0x3c ) + ( ( TXV << 2 ) & 0x3c );
5357 n_yi = ( TXV & ~0xf ) + ( ( XAdjust >> 4 ) & 0xf );
5359 tC1= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((XAdjust & 0x03)<<2)) & 0x0f ;
5361 XAdjust=((posX+difX)>>16);
5363 TXV=(posY+difY)>>16;
5364 n_xi = ( ( XAdjust >> 2 ) & ~0x3c ) + ( ( TXV << 2 ) & 0x3c );
5365 n_yi = ( TXV & ~0xf ) + ( ( XAdjust >> 4 ) & 0xf );
5367 tC2= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((XAdjust & 0x03)<<2)) & 0x0f ;
5369 GetTextureTransColGX32_S((uint32_t *)&psxVuw[(i<<10)+j],
5370 GETLE16(&psxVuw[clutP+tC1])|
5371 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16,
5372 (cB1>>16)|((cB1+difB)&0xff0000),
5373 (cG1>>16)|((cG1+difG)&0xff0000),
5374 (cR1>>16)|((cR1+difR)&0xff0000));
5386 n_xi = ( ( XAdjust >> 2 ) & ~0x3c ) + ( ( TXV << 2 ) & 0x3c );
5387 n_yi = ( TXV & ~0xf ) + ( ( XAdjust >> 4 ) & 0xf );
5389 tC1= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((XAdjust & 0x03)<<2)) & 0x0f ;
5391 GetTextureTransColGX_S(&psxVuw[(i<<10)+j],
5392 GETLE16(&psxVuw[clutP+tC1]),
5393 (cB1>>16),(cG1>>16),(cR1>>16));
5406 for (i=ymin;i<=ymax;i++)
5408 xmin=(left_x >> 16);
5409 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!!
5410 if(drawW<xmax) xmax=drawW;
5421 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
5423 for(j=xmin;j<=xmax;j++)
5428 n_xi = ( ( XAdjust >> 2 ) & ~0x3c ) + ( ( TXV << 2 ) & 0x3c );
5429 n_yi = ( TXV & ~0xf ) + ( ( XAdjust >> 4 ) & 0xf );
5431 tC1= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((XAdjust & 0x03)<<2)) & 0x0f ;
5434 GetTextureTransColGX_Dither(&psxVuw[(i<<10)+j],
5435 GETLE16(&psxVuw[clutP+tC1]),
5436 (cB1>>16),(cG1>>16),(cR1>>16));
5438 GetTextureTransColGX(&psxVuw[(i<<10)+j],
5439 GETLE16(&psxVuw[clutP+tC1]),
5440 (cB1>>16),(cG1>>16),(cR1>>16));
5455 ////////////////////////////////////////////////////////////////////////
5457 static void drawPoly3TGEx4_TW(short x1, short y1, short x2, short y2, short x3, short y3, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short clX, short clY,int32_t col1, int32_t col2, int32_t col3)
5459 int i,j,xmin,xmax,ymin,ymax;
5460 int32_t cR1,cG1,cB1;
5461 int32_t difR,difB,difG,difR2,difB2,difG2;
5462 int32_t difX, difY,difX2, difY2;
5463 int32_t posX,posY,YAdjust,clutP,XAdjust;
5466 if(x1>drawW && x2>drawW && x3>drawW) return;
5467 if(y1>drawH && y2>drawH && y3>drawH) return;
5468 if(x1<drawX && x2<drawX && x3<drawX) return;
5469 if(y1<drawY && y2<drawY && y3<drawY) return;
5470 if(drawY>=drawH) return;
5471 if(drawX>=drawW) return;
5473 if(!SetupSections_GT(x1,y1,x2,y2,x3,y3,tx1,ty1,tx2,ty2,tx3,ty3,col1,col2,col3)) return;
5477 for(ymin=Ymin;ymin<drawY;ymin++)
5478 if(NextRow_GT()) return;
5480 clutP=(clY<<10)+clX;
5482 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
5483 YAdjust+=(TWin.Position.y0<<11)+(TWin.Position.x0>>1);
5492 difX=delta_right_u;difX2=difX<<1;
5493 difY=delta_right_v;difY2=difY<<1;
5497 if(!bCheckMask && !DrawSemiTrans && !iDither)
5499 for (i=ymin;i<=ymax;i++)
5501 xmin=((left_x) >> 16);
5502 xmax=((right_x) >> 16)-1; //!!!!!!!!!!!!!
5503 if(drawW<xmax) xmax=drawW;
5514 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
5516 for(j=xmin;j<xmax;j+=2)
5518 XAdjust=(posX>>16)%TWin.Position.x1;
5519 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
5520 YAdjust+(XAdjust>>1)];
5521 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
5522 XAdjust=((posX+difX)>>16)%TWin.Position.x1;
5523 tC2 = psxVub[((((posY+difY)>>16)%TWin.Position.y1)<<11)+
5524 YAdjust+(XAdjust>>1)];
5525 tC2=(tC2>>((XAdjust&1)<<2))&0xf;
5526 GetTextureTransColGX32_S((uint32_t *)&psxVuw[(i<<10)+j],
5527 GETLE16(&psxVuw[clutP+tC1])|
5528 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16,
5529 (cB1>>16)|((cB1+difB)&0xff0000),
5530 (cG1>>16)|((cG1+difG)&0xff0000),
5531 (cR1>>16)|((cR1+difR)&0xff0000));
5540 XAdjust=(posX>>16)%TWin.Position.x1;
5541 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
5542 YAdjust+(XAdjust>>1)];
5543 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
5544 GetTextureTransColGX_S(&psxVuw[(i<<10)+j],
5545 GETLE16(&psxVuw[clutP+tC1]),
5546 (cB1>>16),(cG1>>16),(cR1>>16));
5559 for (i=ymin;i<=ymax;i++)
5561 xmin=(left_x >> 16);
5562 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!!
5563 if(drawW<xmax) xmax=drawW;
5574 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
5576 for(j=xmin;j<=xmax;j++)
5578 XAdjust=(posX>>16)%TWin.Position.x1;
5579 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
5580 YAdjust+(XAdjust>>1)];
5581 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
5583 GetTextureTransColGX_Dither(&psxVuw[(i<<10)+j],
5584 GETLE16(&psxVuw[clutP+tC1]),
5585 (cB1>>16),(cG1>>16),(cR1>>16));
5587 GetTextureTransColGX(&psxVuw[(i<<10)+j],
5588 GETLE16(&psxVuw[clutP+tC1]),
5589 (cB1>>16),(cG1>>16),(cR1>>16));
5604 ////////////////////////////////////////////////////////////////////////
5606 // note: the psx is doing g-shaded quads as two g-shaded tris,
5607 // like the following func... sadly texturing is not 100%
5608 // correct that way, so small texture distortions can
5611 static void drawPoly4TGEx4_TRI_IL(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4,
5612 short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4,
5613 short clX, short clY,
5614 int32_t col1, int32_t col2, int32_t col3, int32_t col4)
5616 drawPoly3TGEx4_IL(x2,y2,x3,y3,x4,y4,
5617 tx2,ty2,tx3,ty3,tx4,ty4,
5620 drawPoly3TGEx4_IL(x1,y1,x2,y2,x4,y4,
5621 tx1,ty1,tx2,ty2,tx4,ty4,
5628 static void drawPoly4TGEx4_TRI(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4,
5629 short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4,
5630 short clX, short clY,
5631 int32_t col1, int32_t col2, int32_t col3, int32_t col4)
5633 drawPoly3TGEx4(x2,y2,x3,y3,x4,y4,
5634 tx2,ty2,tx3,ty3,tx4,ty4,
5637 drawPoly3TGEx4(x1,y1,x2,y2,x4,y4,
5638 tx1,ty1,tx2,ty2,tx4,ty4,
5645 ////////////////////////////////////////////////////////////////////////
5647 static void drawPoly4TGEx4(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4,
5648 short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4,
5649 short clX, short clY,
5650 int32_t col1, int32_t col2, int32_t col4, int32_t col3)
5653 int32_t i,j,xmin,xmax,ymin,ymax;
5654 int32_t cR1,cG1,cB1;
5655 int32_t difR,difB,difG,difR2,difB2,difG2;
5656 int32_t difX, difY, difX2, difY2;
5657 int32_t posX,posY,YAdjust,clutP,XAdjust;
5660 if(x1>drawW && x2>drawW && x3>drawW && x4>drawW) return;
5661 if(y1>drawH && y2>drawH && y3>drawH && y4>drawH) return;
5662 if(x1<drawX && x2<drawX && x3<drawX && x4<drawX) return;
5663 if(y1<drawY && y2<drawY && y3<drawY && y4<drawY) return;
5664 if(drawY>=drawH) return;
5665 if(drawX>=drawW) return;
5667 if(!SetupSections_GT4(x1,y1,x2,y2,x3,y3,x4,y4,tx1,ty1,tx2,ty2,tx3,ty3,tx4,ty4,col1,col2,col3,col4)) return;
5671 for(ymin=Ymin;ymin<drawY;ymin++)
5672 if(NextRow_GT4()) return;
5674 clutP=(clY<<10)+clX;
5676 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
5681 if(!bCheckMask && !DrawSemiTrans && !iDither)
5683 for (i=ymin;i<=ymax;i++)
5685 xmin=(left_x >> 16);
5686 xmax=(right_x >> 16);
5695 difX=(right_u-posX)/num;
5696 difY=(right_v-posY)/num;
5703 difR=(right_R-cR1)/num;
5704 difG=(right_G-cG1)/num;
5705 difB=(right_B-cB1)/num;
5711 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
5712 xmax--;if(drawW<xmax) xmax=drawW;
5714 for(j=xmin;j<xmax;j+=2)
5717 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(XAdjust>>1)];
5718 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
5719 XAdjust=((posX+difX)>>16);
5720 tC2 = psxVub[(((posY+difY)>>5)&(int32_t)0xFFFFF800)+YAdjust+
5722 tC2=(tC2>>((XAdjust&1)<<2))&0xf;
5724 GetTextureTransColGX32_S((uint32_t *)&psxVuw[(i<<10)+j],
5725 GETLE16(&psxVuw[clutP+tC1])|
5726 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16,
5727 (cB1>>16)|((cB1+difB)&0xff0000),
5728 (cG1>>16)|((cG1+difG)&0xff0000),
5729 (cR1>>16)|((cR1+difR)&0xff0000));
5739 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+
5741 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
5743 GetTextureTransColGX_S(&psxVuw[(i<<10)+j],
5744 GETLE16(&psxVuw[clutP+tC1]),
5745 (cB1>>16),(cG1>>16),(cR1>>16));
5748 if(NextRow_GT4()) return;
5755 for (i=ymin;i<=ymax;i++)
5757 xmin=(left_x >> 16);
5758 xmax=(right_x >> 16);
5767 difX=(right_u-posX)/num;
5768 difY=(right_v-posY)/num;
5775 difR=(right_R-cR1)/num;
5776 difG=(right_G-cG1)/num;
5777 difB=(right_B-cB1)/num;
5783 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
5784 xmax--;if(drawW<xmax) xmax=drawW;
5786 for(j=xmin;j<=xmax;j++)
5789 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+
5791 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
5793 GetTextureTransColGX_Dither(&psxVuw[(i<<10)+j],
5794 GETLE16(&psxVuw[clutP+tC1]),
5795 (cB1>>16),(cG1>>16),(cR1>>16));
5797 GetTextureTransColGX(&psxVuw[(i<<10)+j],
5798 GETLE16(&psxVuw[clutP+tC1]),
5799 (cB1>>16),(cG1>>16),(cR1>>16));
5807 if(NextRow_GT4()) return;
5811 ////////////////////////////////////////////////////////////////////////
5813 static void drawPoly4TGEx4_TW(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4,
5814 short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4,
5815 short clX, short clY,
5816 int32_t col1, int32_t col2, int32_t col3, int32_t col4)
5818 drawPoly3TGEx4_TW(x2,y2,x3,y3,x4,y4,
5819 tx2,ty2,tx3,ty3,tx4,ty4,
5823 drawPoly3TGEx4_TW(x1,y1,x2,y2,x4,y4,
5824 tx1,ty1,tx2,ty2,tx4,ty4,
5829 ////////////////////////////////////////////////////////////////////////
5830 // POLY 3/4 G-SHADED TEX PAL8
5831 ////////////////////////////////////////////////////////////////////////
5833 static void drawPoly3TGEx8(short x1, short y1, short x2, short y2, short x3, short y3, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short clX, short clY,int32_t col1, int32_t col2, int32_t col3)
5835 int i,j,xmin,xmax,ymin,ymax;
5836 int32_t cR1,cG1,cB1;
5837 int32_t difR,difB,difG,difR2,difB2,difG2;
5838 int32_t difX, difY,difX2, difY2;
5839 int32_t posX,posY,YAdjust,clutP;
5842 if(x1>drawW && x2>drawW && x3>drawW) return;
5843 if(y1>drawH && y2>drawH && y3>drawH) return;
5844 if(x1<drawX && x2<drawX && x3<drawX) return;
5845 if(y1<drawY && y2<drawY && y3<drawY) return;
5846 if(drawY>=drawH) return;
5847 if(drawX>=drawW) return;
5849 if(!SetupSections_GT(x1,y1,x2,y2,x3,y3,tx1,ty1,tx2,ty2,tx3,ty3,col1,col2,col3)) return;
5853 for(ymin=Ymin;ymin<drawY;ymin++)
5854 if(NextRow_GT()) return;
5856 clutP=(clY<<10)+clX;
5858 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
5866 difX=delta_right_u;difX2=difX<<1;
5867 difY=delta_right_v;difY2=difY<<1;
5871 if(!bCheckMask && !DrawSemiTrans && !iDither)
5873 for (i=ymin;i<=ymax;i++)
5875 xmin=(left_x >> 16);
5876 xmax=(right_x >> 16)-1; // !!!!!!!!!!!!!
5877 if(drawW<xmax) xmax=drawW;
5888 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
5890 for(j=xmin;j<xmax;j+=2)
5892 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+((posX>>16))];
5893 tC2 = psxVub[(((posY+difY)>>5)&(int32_t)0xFFFFF800)+YAdjust+
5894 (((posX+difX)>>16))];
5895 GetTextureTransColGX32_S((uint32_t *)&psxVuw[(i<<10)+j],
5896 GETLE16(&psxVuw[clutP+tC1])|
5897 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16,
5898 (cB1>>16)|((cB1+difB)&0xff0000),
5899 (cG1>>16)|((cG1+difG)&0xff0000),
5900 (cR1>>16)|((cR1+difR)&0xff0000));
5909 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+((posX>>16))];
5910 GetTextureTransColGX_S(&psxVuw[(i<<10)+j],
5911 GETLE16(&psxVuw[clutP+tC1]),
5912 (cB1>>16),(cG1>>16),(cR1>>16));
5925 for (i=ymin;i<=ymax;i++)
5927 xmin=(left_x >> 16);
5928 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!!!!!!!!!
5929 if(drawW<xmax) xmax=drawW;
5940 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
5942 for(j=xmin;j<=xmax;j++)
5944 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+((posX>>16))];
5946 GetTextureTransColGX_Dither(&psxVuw[(i<<10)+j],
5947 GETLE16(&psxVuw[clutP+tC1]),
5948 (cB1>>16),(cG1>>16),(cR1>>16));
5950 GetTextureTransColGX(&psxVuw[(i<<10)+j],
5951 GETLE16(&psxVuw[clutP+tC1]),
5952 (cB1>>16),(cG1>>16),(cR1>>16));
5967 ////////////////////////////////////////////////////////////////////////
5969 static void drawPoly3TGEx8_IL(short x1, short y1, short x2, short y2, short x3, short y3, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short clX, short clY,int32_t col1, int32_t col2, int32_t col3)
5971 int i,j,xmin,xmax,ymin,ymax,n_xi,n_yi,TXV,TXU;
5972 int32_t cR1,cG1,cB1;
5973 int32_t difR,difB,difG,difR2,difB2,difG2;
5974 int32_t difX, difY,difX2, difY2;
5975 int32_t posX,posY,YAdjust,clutP;
5978 if(x1>drawW && x2>drawW && x3>drawW) return;
5979 if(y1>drawH && y2>drawH && y3>drawH) return;
5980 if(x1<drawX && x2<drawX && x3<drawX) return;
5981 if(y1<drawY && y2<drawY && y3<drawY) return;
5982 if(drawY>=drawH) return;
5983 if(drawX>=drawW) return;
5985 if(!SetupSections_GT(x1,y1,x2,y2,x3,y3,tx1,ty1,tx2,ty2,tx3,ty3,col1,col2,col3)) return;
5989 for(ymin=Ymin;ymin<drawY;ymin++)
5990 if(NextRow_GT()) return;
5992 clutP=(clY<<10)+clX;
5994 YAdjust=(GlobalTextAddrY<<10)+GlobalTextAddrX;
6002 difX=delta_right_u;difX2=difX<<1;
6003 difY=delta_right_v;difY2=difY<<1;
6007 if(!bCheckMask && !DrawSemiTrans && !iDither)
6009 for (i=ymin;i<=ymax;i++)
6011 xmin=(left_x >> 16);
6012 xmax=(right_x >> 16)-1; // !!!!!!!!!!!!!
6013 if(drawW<xmax) xmax=drawW;
6024 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
6026 for(j=xmin;j<xmax;j+=2)
6030 n_xi = ( ( TXU >> 1 ) & ~0x78 ) + ( ( TXU << 2 ) & 0x40 ) + ( ( TXV << 3 ) & 0x38 );
6031 n_yi = ( TXV & ~0x7 ) + ( ( TXU >> 5 ) & 0x7 );
6033 tC1= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((TXU & 0x01)<<3)) & 0xff;
6035 TXU=(posX+difX)>>16;
6036 TXV=(posY+difY)>>16;
6037 n_xi = ( ( TXU >> 1 ) & ~0x78 ) + ( ( TXU << 2 ) & 0x40 ) + ( ( TXV << 3 ) & 0x38 );
6038 n_yi = ( TXV & ~0x7 ) + ( ( TXU >> 5 ) & 0x7 );
6040 tC2= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((TXU & 0x01)<<3)) & 0xff;
6042 GetTextureTransColGX32_S((uint32_t *)&psxVuw[(i<<10)+j],
6043 GETLE16(&psxVuw[clutP+tC1])|
6044 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16,
6045 (cB1>>16)|((cB1+difB)&0xff0000),
6046 (cG1>>16)|((cG1+difG)&0xff0000),
6047 (cR1>>16)|((cR1+difR)&0xff0000));
6058 n_xi = ( ( TXU >> 1 ) & ~0x78 ) + ( ( TXU << 2 ) & 0x40 ) + ( ( TXV << 3 ) & 0x38 );
6059 n_yi = ( TXV & ~0x7 ) + ( ( TXU >> 5 ) & 0x7 );
6061 tC1= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((TXU & 0x01)<<3)) & 0xff;
6063 GetTextureTransColGX_S(&psxVuw[(i<<10)+j],
6064 GETLE16(&psxVuw[clutP+tC1]),
6065 (cB1>>16),(cG1>>16),(cR1>>16));
6078 for (i=ymin;i<=ymax;i++)
6080 xmin=(left_x >> 16);
6081 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!!!!!!!!!
6082 if(drawW<xmax) xmax=drawW;
6093 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
6095 for(j=xmin;j<=xmax;j++)
6099 n_xi = ( ( TXU >> 1 ) & ~0x78 ) + ( ( TXU << 2 ) & 0x40 ) + ( ( TXV << 3 ) & 0x38 );
6100 n_yi = ( TXV & ~0x7 ) + ( ( TXU >> 5 ) & 0x7 );
6102 tC1= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((TXU & 0x01)<<3)) & 0xff;
6105 GetTextureTransColGX_Dither(&psxVuw[(i<<10)+j],
6106 GETLE16(&psxVuw[clutP+tC1]),
6107 (cB1>>16),(cG1>>16),(cR1>>16));
6109 GetTextureTransColGX(&psxVuw[(i<<10)+j],
6110 GETLE16(&psxVuw[clutP+tC1]),
6111 (cB1>>16),(cG1>>16),(cR1>>16));
6126 ////////////////////////////////////////////////////////////////////////
6128 static void drawPoly3TGEx8_TW(short x1, short y1, short x2, short y2, short x3, short y3, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short clX, short clY,int32_t col1, int32_t col2, int32_t col3)
6130 int i,j,xmin,xmax,ymin,ymax;
6131 int32_t cR1,cG1,cB1;
6132 int32_t difR,difB,difG,difR2,difB2,difG2;
6133 int32_t difX, difY,difX2, difY2;
6134 int32_t posX,posY,YAdjust,clutP;
6137 if(x1>drawW && x2>drawW && x3>drawW) return;
6138 if(y1>drawH && y2>drawH && y3>drawH) return;
6139 if(x1<drawX && x2<drawX && x3<drawX) return;
6140 if(y1<drawY && y2<drawY && y3<drawY) return;
6141 if(drawY>=drawH) return;
6142 if(drawX>=drawW) return;
6144 if(!SetupSections_GT(x1,y1,x2,y2,x3,y3,tx1,ty1,tx2,ty2,tx3,ty3,col1,col2,col3)) return;
6148 for(ymin=Ymin;ymin<drawY;ymin++)
6149 if(NextRow_GT()) return;
6151 clutP=(clY<<10)+clX;
6153 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
6154 YAdjust+=(TWin.Position.y0<<11)+(TWin.Position.x0);
6162 difX=delta_right_u;difX2=difX<<1;
6163 difY=delta_right_v;difY2=difY<<1;
6167 if(!bCheckMask && !DrawSemiTrans && !iDither)
6169 for (i=ymin;i<=ymax;i++)
6171 xmin=(left_x >> 16);
6172 xmax=(right_x >> 16)-1; // !!!!!!!!!!!!!
6173 if(drawW<xmax) xmax=drawW;
6184 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
6186 for(j=xmin;j<xmax;j+=2)
6188 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
6189 YAdjust+((posX>>16)%TWin.Position.x1)];
6190 tC2 = psxVub[((((posY+difY)>>16)%TWin.Position.y1)<<11)+
6191 YAdjust+(((posX+difX)>>16)%TWin.Position.x1)];
6193 GetTextureTransColGX32_S((uint32_t *)&psxVuw[(i<<10)+j],
6194 GETLE16(&psxVuw[clutP+tC1])|
6195 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16,
6196 (cB1>>16)|((cB1+difB)&0xff0000),
6197 (cG1>>16)|((cG1+difG)&0xff0000),
6198 (cR1>>16)|((cR1+difR)&0xff0000));
6207 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
6208 YAdjust+((posX>>16)%TWin.Position.x1)];
6209 GetTextureTransColGX_S(&psxVuw[(i<<10)+j],
6210 GETLE16(&psxVuw[clutP+tC1]),
6211 (cB1>>16),(cG1>>16),(cR1>>16));
6224 for (i=ymin;i<=ymax;i++)
6226 xmin=(left_x >> 16);
6227 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!!!!!!!!!
6228 if(drawW<xmax) xmax=drawW;
6239 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
6241 for(j=xmin;j<=xmax;j++)
6243 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
6244 YAdjust+((posX>>16)%TWin.Position.x1)];
6246 GetTextureTransColGX_Dither(&psxVuw[(i<<10)+j],
6247 GETLE16(&psxVuw[clutP+tC1]),
6248 (cB1>>16),(cG1>>16),(cR1>>16));
6250 GetTextureTransColGX(&psxVuw[(i<<10)+j],
6251 GETLE16(&psxVuw[clutP+tC1]),
6252 (cB1>>16),(cG1>>16),(cR1>>16));
6267 ////////////////////////////////////////////////////////////////////////
6269 // note: two g-shaded tris: small texture distortions can happen
6271 static void drawPoly4TGEx8_TRI_IL(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4,
6272 short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4,
6273 short clX, short clY,
6274 int32_t col1, int32_t col2, int32_t col3, int32_t col4)
6276 drawPoly3TGEx8_IL(x2,y2,x3,y3,x4,y4,
6277 tx2,ty2,tx3,ty3,tx4,ty4,
6280 drawPoly3TGEx8_IL(x1,y1,x2,y2,x4,y4,
6281 tx1,ty1,tx2,ty2,tx4,ty4,
6288 static void drawPoly4TGEx8_TRI(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4,
6289 short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4,
6290 short clX, short clY,
6291 int32_t col1, int32_t col2, int32_t col3, int32_t col4)
6293 drawPoly3TGEx8(x2,y2,x3,y3,x4,y4,
6294 tx2,ty2,tx3,ty3,tx4,ty4,
6297 drawPoly3TGEx8(x1,y1,x2,y2,x4,y4,
6298 tx1,ty1,tx2,ty2,tx4,ty4,
6305 static void drawPoly4TGEx8(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4,
6306 short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4,
6307 short clX, short clY,
6308 int32_t col1, int32_t col2, int32_t col4, int32_t col3)
6311 int32_t i,j,xmin,xmax,ymin,ymax;
6312 int32_t cR1,cG1,cB1;
6313 int32_t difR,difB,difG,difR2,difB2,difG2;
6314 int32_t difX, difY, difX2, difY2;
6315 int32_t posX,posY,YAdjust,clutP;
6318 if(x1>drawW && x2>drawW && x3>drawW && x4>drawW) return;
6319 if(y1>drawH && y2>drawH && y3>drawH && y4>drawH) return;
6320 if(x1<drawX && x2<drawX && x3<drawX && x4<drawX) return;
6321 if(y1<drawY && y2<drawY && y3<drawY && y4<drawY) return;
6322 if(drawY>=drawH) return;
6323 if(drawX>=drawW) return;
6325 if(!SetupSections_GT4(x1,y1,x2,y2,x3,y3,x4,y4,tx1,ty1,tx2,ty2,tx3,ty3,tx4,ty4,col1,col2,col3,col4)) return;
6329 for(ymin=Ymin;ymin<drawY;ymin++)
6330 if(NextRow_GT4()) return;
6332 clutP=(clY<<10)+clX;
6334 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
6338 if(!bCheckMask && !DrawSemiTrans && !iDither)
6340 for (i=ymin;i<=ymax;i++)
6342 xmin=(left_x >> 16);
6343 xmax=(right_x >> 16);
6352 difX=(right_u-posX)/num;
6353 difY=(right_v-posY)/num;
6360 difR=(right_R-cR1)/num;
6361 difG=(right_G-cG1)/num;
6362 difB=(right_B-cB1)/num;
6368 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
6369 xmax--;if(drawW<xmax) xmax=drawW;
6371 for(j=xmin;j<xmax;j+=2)
6373 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(posX>>16)];
6374 tC2 = psxVub[(((posY+difY)>>5)&(int32_t)0xFFFFF800)+YAdjust+
6377 GetTextureTransColGX32_S((uint32_t *)&psxVuw[(i<<10)+j],
6378 GETLE16(&psxVuw[clutP+tC1])|
6379 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16,
6380 (cB1>>16)|((cB1+difB)&0xff0000),
6381 (cG1>>16)|((cG1+difG)&0xff0000),
6382 (cR1>>16)|((cR1+difR)&0xff0000));
6391 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(posX>>16)];
6392 GetTextureTransColGX_S(&psxVuw[(i<<10)+j],
6393 GETLE16(&psxVuw[clutP+tC1]),
6394 (cB1>>16),(cG1>>16),(cR1>>16));
6397 if(NextRow_GT4()) return;
6404 for (i=ymin;i<=ymax;i++)
6406 xmin=(left_x >> 16);
6407 xmax=(right_x >> 16);
6416 difX=(right_u-posX)/num;
6417 difY=(right_v-posY)/num;
6424 difR=(right_R-cR1)/num;
6425 difG=(right_G-cG1)/num;
6426 difB=(right_B-cB1)/num;
6432 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
6433 xmax--;if(drawW<xmax) xmax=drawW;
6435 for(j=xmin;j<=xmax;j++)
6437 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(posX>>16)];
6439 GetTextureTransColGX_Dither(&psxVuw[(i<<10)+j],
6440 GETLE16(&psxVuw[clutP+tC1]),
6441 (cB1>>16),(cG1>>16),(cR1>>16));
6443 GetTextureTransColGX(&psxVuw[(i<<10)+j],
6444 GETLE16(&psxVuw[clutP+tC1]),
6445 (cB1>>16),(cG1>>16),(cR1>>16));
6453 if(NextRow_GT4()) return;
6457 ////////////////////////////////////////////////////////////////////////
6459 static void drawPoly4TGEx8_TW(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4,
6460 short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4,
6461 short clX, short clY,
6462 int32_t col1, int32_t col2, int32_t col3, int32_t col4)
6464 drawPoly3TGEx8_TW(x2,y2,x3,y3,x4,y4,
6465 tx2,ty2,tx3,ty3,tx4,ty4,
6468 drawPoly3TGEx8_TW(x1,y1,x2,y2,x4,y4,
6469 tx1,ty1,tx2,ty2,tx4,ty4,
6474 ////////////////////////////////////////////////////////////////////////
6475 // POLY 3 G-SHADED TEX 15 BIT
6476 ////////////////////////////////////////////////////////////////////////
6478 static void drawPoly3TGD(short x1, short y1, short x2, short y2, short x3, short y3, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3,int32_t col1, int32_t col2, int32_t col3)
6480 int i,j,xmin,xmax,ymin,ymax;
6481 int32_t cR1,cG1,cB1;
6482 int32_t difR,difB,difG,difR2,difB2,difG2;
6483 int32_t difX, difY,difX2, difY2;
6486 if(x1>drawW && x2>drawW && x3>drawW) return;
6487 if(y1>drawH && y2>drawH && y3>drawH) return;
6488 if(x1<drawX && x2<drawX && x3<drawX) return;
6489 if(y1<drawY && y2<drawY && y3<drawY) return;
6490 if(drawY>=drawH) return;
6491 if(drawX>=drawW) return;
6493 if(!SetupSections_GT(x1,y1,x2,y2,x3,y3,tx1,ty1,tx2,ty2,tx3,ty3,col1,col2,col3)) return;
6497 for(ymin=Ymin;ymin<drawY;ymin++)
6498 if(NextRow_GT()) return;
6506 difX=delta_right_u;difX2=difX<<1;
6507 difY=delta_right_v;difY2=difY<<1;
6511 if(!bCheckMask && !DrawSemiTrans && !iDither)
6513 for (i=ymin;i<=ymax;i++)
6515 xmin=(left_x >> 16);
6516 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!!!!!!
6517 if(drawW<xmax) xmax=drawW;
6528 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
6530 for(j=xmin;j<xmax;j+=2)
6532 GetTextureTransColGX32_S((uint32_t *)&psxVuw[(i<<10)+j],
6533 (((int32_t)GETLE16(&psxVuw[((((posY+difY)>>16)+GlobalTextAddrY)<<10)+((posX+difX)>>16)+GlobalTextAddrX]))<<16)|
6534 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+((posX)>>16)+GlobalTextAddrX]),
6535 (cB1>>16)|((cB1+difB)&0xff0000),
6536 (cG1>>16)|((cG1+difG)&0xff0000),
6537 (cR1>>16)|((cR1+difR)&0xff0000));
6545 GetTextureTransColGX_S(&psxVuw[(i<<10)+j],
6546 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+(posX>>16)+GlobalTextAddrX]),
6547 (cB1>>16),(cG1>>16),(cR1>>16));
6559 for (i=ymin;i<=ymax;i++)
6561 xmin=(left_x >> 16);
6562 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!!!!
6563 if(drawW<xmax) xmax=drawW;
6574 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
6576 for(j=xmin;j<=xmax;j++)
6579 GetTextureTransColGX_Dither(&psxVuw[(i<<10)+j],
6580 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+(posX>>16)+GlobalTextAddrX]),
6581 (cB1>>16),(cG1>>16),(cR1>>16));
6583 GetTextureTransColGX(&psxVuw[(i<<10)+j],
6584 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+(posX>>16)+GlobalTextAddrX]),
6585 (cB1>>16),(cG1>>16),(cR1>>16));
6600 ////////////////////////////////////////////////////////////////////////
6602 static void drawPoly3TGD_TW(short x1, short y1, short x2, short y2, short x3, short y3, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3,int32_t col1, int32_t col2, int32_t col3)
6604 int i,j,xmin,xmax,ymin,ymax;
6605 int32_t cR1,cG1,cB1;
6606 int32_t difR,difB,difG,difR2,difB2,difG2;
6607 int32_t difX, difY,difX2, difY2;
6610 if(x1>drawW && x2>drawW && x3>drawW) return;
6611 if(y1>drawH && y2>drawH && y3>drawH) return;
6612 if(x1<drawX && x2<drawX && x3<drawX) return;
6613 if(y1<drawY && y2<drawY && y3<drawY) return;
6614 if(drawY>=drawH) return;
6615 if(drawX>=drawW) return;
6617 if(!SetupSections_GT(x1,y1,x2,y2,x3,y3,tx1,ty1,tx2,ty2,tx3,ty3,col1,col2,col3)) return;
6621 for(ymin=Ymin;ymin<drawY;ymin++)
6622 if(NextRow_GT()) return;
6630 difX=delta_right_u;difX2=difX<<1;
6631 difY=delta_right_v;difY2=difY<<1;
6635 if(!bCheckMask && !DrawSemiTrans && !iDither)
6637 for (i=ymin;i<=ymax;i++)
6639 xmin=(left_x >> 16);
6640 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!!!!!!
6641 if(drawW<xmax) xmax=drawW;
6652 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
6654 for(j=xmin;j<xmax;j+=2)
6656 GetTextureTransColGX32_S((uint32_t *)&psxVuw[(i<<10)+j],
6657 (((int32_t)GETLE16(&psxVuw[(((((posY+difY)>>16)%TWin.Position.y1)+GlobalTextAddrY+TWin.Position.y0)<<10)+
6658 (((posX+difX)>>16)%TWin.Position.x1)+GlobalTextAddrX+TWin.Position.x0]))<<16)|
6659 GETLE16(&psxVuw[((((posY>>16)%TWin.Position.y1)+GlobalTextAddrY+TWin.Position.y0)<<10)+
6660 (((posX)>>16)%TWin.Position.x1)+GlobalTextAddrX+TWin.Position.x0]),
6661 (cB1>>16)|((cB1+difB)&0xff0000),
6662 (cG1>>16)|((cG1+difG)&0xff0000),
6663 (cR1>>16)|((cR1+difR)&0xff0000));
6671 GetTextureTransColGX_S(&psxVuw[(i<<10)+j],
6672 GETLE16(&psxVuw[((((posY>>16)%TWin.Position.y1)+GlobalTextAddrY+TWin.Position.y0)<<10)+
6673 ((posX>>16)%TWin.Position.x1)+GlobalTextAddrX+TWin.Position.x0]),
6674 (cB1>>16),(cG1>>16),(cR1>>16));
6686 for (i=ymin;i<=ymax;i++)
6688 xmin=(left_x >> 16);
6689 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!!!!
6690 if(drawW<xmax) xmax=drawW;
6701 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
6703 for(j=xmin;j<=xmax;j++)
6706 GetTextureTransColGX_Dither(&psxVuw[(i<<10)+j],
6707 GETLE16(&psxVuw[((((posY>>16)%TWin.Position.y1)+GlobalTextAddrY+TWin.Position.y0)<<10)+
6708 ((posX>>16)%TWin.Position.x1)+GlobalTextAddrX+TWin.Position.x0]),
6709 (cB1>>16),(cG1>>16),(cR1>>16));
6711 GetTextureTransColGX(&psxVuw[(i<<10)+j],
6712 GETLE16(&psxVuw[((((posY>>16)%TWin.Position.y1)+GlobalTextAddrY+TWin.Position.y0)<<10)+
6713 ((posX>>16)%TWin.Position.x1)+GlobalTextAddrX+TWin.Position.x0]),
6714 (cB1>>16),(cG1>>16),(cR1>>16));
6729 ////////////////////////////////////////////////////////////////////////
6731 // note: two g-shaded tris: small texture distortions can happen
6735 static void drawPoly4TGD_TRI(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4, int32_t col1, int32_t col2, int32_t col3, int32_t col4)
6737 drawPoly3TGD(x2,y2,x3,y3,x4,y4,
6738 tx2,ty2,tx3,ty3,tx4,ty4,
6740 drawPoly3TGD(x1,y1,x2,y2,x4,y4,
6741 tx1,ty1,tx2,ty2,tx4,ty4,
6747 static void drawPoly4TGD(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4, int32_t col1, int32_t col2, int32_t col4, int32_t col3)
6750 int32_t i,j,xmin,xmax,ymin,ymax;
6751 int32_t cR1,cG1,cB1;
6752 int32_t difR,difB,difG,difR2,difB2,difG2;
6753 int32_t difX, difY, difX2, difY2;
6756 if(x1>drawW && x2>drawW && x3>drawW && x4>drawW) return;
6757 if(y1>drawH && y2>drawH && y3>drawH && y4>drawH) return;
6758 if(x1<drawX && x2<drawX && x3<drawX && x4<drawX) return;
6759 if(y1<drawY && y2<drawY && y3<drawY && y4<drawY) return;
6760 if(drawY>=drawH) return;
6761 if(drawX>=drawW) return;
6763 if(!SetupSections_GT4(x1,y1,x2,y2,x3,y3,x4,y4,tx1,ty1,tx2,ty2,tx3,ty3,tx4,ty4,col1,col2,col3,col4)) return;
6767 for(ymin=Ymin;ymin<drawY;ymin++)
6768 if(NextRow_GT4()) return;
6772 if(!bCheckMask && !DrawSemiTrans && !iDither)
6774 for (i=ymin;i<=ymax;i++)
6776 xmin=(left_x >> 16);
6777 xmax=(right_x >> 16);
6786 difX=(right_u-posX)/num;
6787 difY=(right_v-posY)/num;
6794 difR=(right_R-cR1)/num;
6795 difG=(right_G-cG1)/num;
6796 difB=(right_B-cB1)/num;
6802 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
6803 xmax--;if(drawW<xmax) xmax=drawW;
6805 for(j=xmin;j<xmax;j+=2)
6807 GetTextureTransColGX32_S((uint32_t *)&psxVuw[(i<<10)+j],
6808 (((int32_t)GETLE16(&psxVuw[((((posY+difY)>>16)+GlobalTextAddrY)<<10)+((posX+difX)>>16)+GlobalTextAddrX]))<<16)|
6809 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+((posX)>>16)+GlobalTextAddrX]),
6810 (cB1>>16)|((cB1+difB)&0xff0000),
6811 (cG1>>16)|((cG1+difG)&0xff0000),
6812 (cR1>>16)|((cR1+difR)&0xff0000));
6820 GetTextureTransColGX_S(&psxVuw[(i<<10)+j],
6821 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+(posX>>16)+GlobalTextAddrX]),
6822 (cB1>>16),(cG1>>16),(cR1>>16));
6824 if(NextRow_GT4()) return;
6831 for (i=ymin;i<=ymax;i++)
6833 xmin=(left_x >> 16);
6834 xmax=(right_x >> 16);
6843 difX=(right_u-posX)/num;
6844 difY=(right_v-posY)/num;
6851 difR=(right_R-cR1)/num;
6852 difG=(right_G-cG1)/num;
6853 difB=(right_B-cB1)/num;
6859 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
6860 xmax--;if(drawW<xmax) xmax=drawW;
6862 for(j=xmin;j<=xmax;j++)
6865 GetTextureTransColGX(&psxVuw[(i<<10)+j],
6866 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+(posX>>16)+GlobalTextAddrX]),
6867 (cB1>>16),(cG1>>16),(cR1>>16));
6869 GetTextureTransColGX(&psxVuw[(i<<10)+j],
6870 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+(posX>>16)+GlobalTextAddrX]),
6871 (cB1>>16),(cG1>>16),(cR1>>16));
6879 if(NextRow_GT4()) return;
6883 ////////////////////////////////////////////////////////////////////////
6885 static void drawPoly4TGD_TW(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4, int32_t col1, int32_t col2, int32_t col3, int32_t col4)
6887 drawPoly3TGD_TW(x2,y2,x3,y3,x4,y4,
6888 tx2,ty2,tx3,ty3,tx4,ty4,
6890 drawPoly3TGD_TW(x1,y1,x2,y2,x4,y4,
6891 tx1,ty1,tx2,ty2,tx4,ty4,
6895 ////////////////////////////////////////////////////////////////////////
6896 ////////////////////////////////////////////////////////////////////////
6897 ////////////////////////////////////////////////////////////////////////
6898 ////////////////////////////////////////////////////////////////////////
6899 ////////////////////////////////////////////////////////////////////////
6900 ////////////////////////////////////////////////////////////////////////
6904 // no real rect test, but it does its job the way I need it
6905 static inline BOOL IsNoRect(void)
6907 if(lx0==lx1 && lx2==lx3) return FALSE;
6908 if(lx0==lx2 && lx1==lx3) return FALSE;
6909 if(lx0==lx3 && lx1==lx2) return FALSE;
6915 static inline BOOL IsNoRect(void)
6917 if(!(dwActFixes&0x200)) return FALSE;
6921 if(lx1==lx3 && ly3==ly2 && lx2==lx0) return FALSE;
6922 if(lx1==lx2 && ly2==ly3 && lx3==lx0) return FALSE;
6928 if(lx2==lx3 && ly3==ly1 && lx1==lx0) return FALSE;
6929 if(lx2==lx1 && ly1==ly3 && lx3==lx0) return FALSE;
6935 if(lx3==lx2 && ly2==ly1 && lx1==lx0) return FALSE;
6936 if(lx3==lx1 && ly1==ly2 && lx2==lx0) return FALSE;
6942 ////////////////////////////////////////////////////////////////////////
6944 static void drawPoly3FT(unsigned char * baseAddr)
6946 uint32_t *gpuData = ((uint32_t *) baseAddr);
6948 if(GlobalTextIL && GlobalTextTP<2)
6951 drawPoly3TEx4_IL(lx0,ly0,lx1,ly1,lx2,ly2,
6952 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[4]) & 0x000000ff), ((GETLE32(&gpuData[4])>>8) & 0x000000ff),(GETLE32(&gpuData[6]) & 0x000000ff), ((GETLE32(&gpuData[6])>>8) & 0x000000ff),
6953 ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & 511));
6955 drawPoly3TEx8_IL(lx0,ly0,lx1,ly1,lx2,ly2,
6956 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[4]) & 0x000000ff), ((GETLE32(&gpuData[4])>>8) & 0x000000ff),(GETLE32(&gpuData[6]) & 0x000000ff), ((GETLE32(&gpuData[6])>>8) & 0x000000ff),
6957 ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & 511));
6961 if(!bUsingTWin && !(dwActFixes&0x100))
6963 switch(GlobalTextTP) // depending on texture mode
6966 drawPoly3TEx4(lx0,ly0,lx1,ly1,lx2,ly2,
6967 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[4]) & 0x000000ff), ((GETLE32(&gpuData[4])>>8) & 0x000000ff),(GETLE32(&gpuData[6]) & 0x000000ff), ((GETLE32(&gpuData[6])>>8) & 0x000000ff),
6968 ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & 511));
6971 drawPoly3TEx8(lx0,ly0,lx1,ly1,lx2,ly2,
6972 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[4]) & 0x000000ff), ((GETLE32(&gpuData[4])>>8) & 0x000000ff),(GETLE32(&gpuData[6]) & 0x000000ff), ((GETLE32(&gpuData[6])>>8) & 0x000000ff),
6973 ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & 511));
6976 drawPoly3TD(lx0,ly0,lx1,ly1,lx2,ly2,(GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[4]) & 0x000000ff), ((GETLE32(&gpuData[4])>>8) & 0x000000ff),(GETLE32(&gpuData[6]) & 0x000000ff), ((GETLE32(&gpuData[6])>>8) & 0x000000ff));
6982 switch(GlobalTextTP) // depending on texture mode
6985 drawPoly3TEx4_TW(lx0,ly0,lx1,ly1,lx2,ly2,
6986 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[4]) & 0x000000ff), ((GETLE32(&gpuData[4])>>8) & 0x000000ff),(GETLE32(&gpuData[6]) & 0x000000ff), ((GETLE32(&gpuData[6])>>8) & 0x000000ff),
6987 ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & 511));
6990 drawPoly3TEx8_TW(lx0,ly0,lx1,ly1,lx2,ly2,
6991 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[4]) & 0x000000ff), ((GETLE32(&gpuData[4])>>8) & 0x000000ff),(GETLE32(&gpuData[6]) & 0x000000ff), ((GETLE32(&gpuData[6])>>8) & 0x000000ff),
6992 ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & 511));
6995 drawPoly3TD_TW(lx0,ly0,lx1,ly1,lx2,ly2,(GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[4]) & 0x000000ff), ((GETLE32(&gpuData[4])>>8) & 0x000000ff),(GETLE32(&gpuData[6]) & 0x000000ff), ((GETLE32(&gpuData[6])>>8) & 0x000000ff));
7000 ////////////////////////////////////////////////////////////////////////
7002 static void drawPoly4FT(unsigned char * baseAddr)
7004 uint32_t *gpuData = ((uint32_t *) baseAddr);
7006 if(GlobalTextIL && GlobalTextTP<2)
7009 drawPoly4TEx4_IL(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,
7010 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[4]) & 0x000000ff), ((GETLE32(&gpuData[4])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),(GETLE32(&gpuData[6]) & 0x000000ff), ((GETLE32(&gpuData[6])>>8) & 0x000000ff), ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & 511));
7012 drawPoly4TEx8_IL(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,
7013 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[4]) & 0x000000ff), ((GETLE32(&gpuData[4])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),(GETLE32(&gpuData[6]) & 0x000000ff), ((GETLE32(&gpuData[6])>>8) & 0x000000ff), ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & 511));
7022 switch (GlobalTextTP)
7025 drawPoly4TEx4_TRI(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,
7026 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[4]) & 0x000000ff), ((GETLE32(&gpuData[4])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),(GETLE32(&gpuData[6]) & 0x000000ff), ((GETLE32(&gpuData[6])>>8) & 0x000000ff), ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & 511));
7029 drawPoly4TEx8_TRI(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,
7030 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[4]) & 0x000000ff), ((GETLE32(&gpuData[4])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),(GETLE32(&gpuData[6]) & 0x000000ff), ((GETLE32(&gpuData[6])>>8) & 0x000000ff), ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & 511));
7033 drawPoly4TD_TRI(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,(GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[4]) & 0x000000ff), ((GETLE32(&gpuData[4])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),(GETLE32(&gpuData[6]) & 0x000000ff), ((GETLE32(&gpuData[6])>>8) & 0x000000ff));
7040 switch (GlobalTextTP)
7042 case 0: // grandia investigations needed
7043 drawPoly4TEx4(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,
7044 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[4]) & 0x000000ff), ((GETLE32(&gpuData[4])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),(GETLE32(&gpuData[6]) & 0x000000ff), ((GETLE32(&gpuData[6])>>8) & 0x000000ff), ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & 511));
7047 drawPoly4TEx8(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,
7048 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[4]) & 0x000000ff), ((GETLE32(&gpuData[4])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),(GETLE32(&gpuData[6]) & 0x000000ff), ((GETLE32(&gpuData[6])>>8) & 0x000000ff), ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & 511));
7051 drawPoly4TD(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,(GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[4]) & 0x000000ff), ((GETLE32(&gpuData[4])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),(GETLE32(&gpuData[6]) & 0x000000ff), ((GETLE32(&gpuData[6])>>8) & 0x000000ff));
7057 switch (GlobalTextTP)
7060 drawPoly4TEx4_TW(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,
7061 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[4]) & 0x000000ff), ((GETLE32(&gpuData[4])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),(GETLE32(&gpuData[6]) & 0x000000ff), ((GETLE32(&gpuData[6])>>8) & 0x000000ff), ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & 511));
7064 drawPoly4TEx8_TW(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,
7065 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[4]) & 0x000000ff), ((GETLE32(&gpuData[4])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),(GETLE32(&gpuData[6]) & 0x000000ff), ((GETLE32(&gpuData[6])>>8) & 0x000000ff), ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & 511));
7068 drawPoly4TD_TW(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,(GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[4]) & 0x000000ff), ((GETLE32(&gpuData[4])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),(GETLE32(&gpuData[6]) & 0x000000ff), ((GETLE32(&gpuData[6])>>8) & 0x000000ff));
7073 ////////////////////////////////////////////////////////////////////////
7075 static void drawPoly3GT(unsigned char * baseAddr)
7077 uint32_t *gpuData = ((uint32_t *) baseAddr);
7079 if(GlobalTextIL && GlobalTextTP<2)
7082 drawPoly3TGEx4_IL(lx0,ly0,lx1,ly1,lx2,ly2,
7083 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[5]) & 0x000000ff), ((GETLE32(&gpuData[5])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),
7084 ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & 511),
7085 GETLE32(&gpuData[0]),GETLE32(&gpuData[3]),GETLE32(&gpuData[6]));
7087 drawPoly3TGEx8_IL(lx0,ly0,lx1,ly1,lx2,ly2,
7088 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[5]) & 0x000000ff), ((GETLE32(&gpuData[5])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),
7089 ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & 511),
7090 GETLE32(&gpuData[0]),GETLE32(&gpuData[3]),GETLE32(&gpuData[6]));
7096 switch (GlobalTextTP)
7099 drawPoly3TGEx4(lx0,ly0,lx1,ly1,lx2,ly2,
7100 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[5]) & 0x000000ff), ((GETLE32(&gpuData[5])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),
7101 ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & 511),
7102 GETLE32(&gpuData[0]),GETLE32(&gpuData[3]),GETLE32(&gpuData[6]));
7105 drawPoly3TGEx8(lx0,ly0,lx1,ly1,lx2,ly2,
7106 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[5]) & 0x000000ff), ((GETLE32(&gpuData[5])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),
7107 ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & 511),
7108 GETLE32(&gpuData[0]),GETLE32(&gpuData[3]),GETLE32(&gpuData[6]));
7111 drawPoly3TGD(lx0,ly0,lx1,ly1,lx2,ly2,(GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[5]) & 0x000000ff), ((GETLE32(&gpuData[5])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),GETLE32(&gpuData[0]),GETLE32(&gpuData[3]),GETLE32(&gpuData[6]));
7117 switch(GlobalTextTP)
7120 drawPoly3TGEx4_TW(lx0,ly0,lx1,ly1,lx2,ly2,
7121 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[5]) & 0x000000ff), ((GETLE32(&gpuData[5])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),
7122 ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & 511),
7123 GETLE32(&gpuData[0]),GETLE32(&gpuData[3]),GETLE32(&gpuData[6]));
7126 drawPoly3TGEx8_TW(lx0,ly0,lx1,ly1,lx2,ly2,
7127 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[5]) & 0x000000ff), ((GETLE32(&gpuData[5])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),
7128 ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & 511),
7129 GETLE32(&gpuData[0]),GETLE32(&gpuData[3]),GETLE32(&gpuData[6]));
7132 drawPoly3TGD_TW(lx0,ly0,lx1,ly1,lx2,ly2,(GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[5]) & 0x000000ff), ((GETLE32(&gpuData[5])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),GETLE32(&gpuData[0]),GETLE32(&gpuData[3]),GETLE32(&gpuData[6]));
7137 ////////////////////////////////////////////////////////////////////////
7139 static void drawPoly4GT(unsigned char *baseAddr)
7141 uint32_t *gpuData = ((uint32_t *) baseAddr);
7143 if(GlobalTextIL && GlobalTextTP<2)
7146 drawPoly4TGEx4_TRI_IL(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,
7147 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[5]) & 0x000000ff), ((GETLE32(&gpuData[5])>>8) & 0x000000ff),(GETLE32(&gpuData[11]) & 0x000000ff), ((GETLE32(&gpuData[11])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),
7148 ((GETLE32(&gpuData[2])>>12) & 0x3f0),((GETLE32(&gpuData[2])>>22) & 511),
7149 GETLE32(&gpuData[0]),GETLE32(&gpuData[3]),GETLE32(&gpuData[6]),GETLE32(&gpuData[9]));
7151 drawPoly4TGEx8_TRI_IL(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,
7152 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[5]) & 0x000000ff), ((GETLE32(&gpuData[5])>>8) & 0x000000ff),(GETLE32(&gpuData[11]) & 0x000000ff), ((GETLE32(&gpuData[11])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),
7153 ((GETLE32(&gpuData[2])>>12) & 0x3f0),((GETLE32(&gpuData[2])>>22) & 511),
7154 GETLE32(&gpuData[0]),GETLE32(&gpuData[3]),GETLE32(&gpuData[6]),GETLE32(&gpuData[9]));
7163 switch (GlobalTextTP)
7166 drawPoly4TGEx4_TRI(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,
7167 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[5]) & 0x000000ff), ((GETLE32(&gpuData[5])>>8) & 0x000000ff),(GETLE32(&gpuData[11]) & 0x000000ff), ((GETLE32(&gpuData[11])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),
7168 ((GETLE32(&gpuData[2])>>12) & 0x3f0),((GETLE32(&gpuData[2])>>22) & 511),
7169 GETLE32(&gpuData[0]),GETLE32(&gpuData[3]),GETLE32(&gpuData[6]),GETLE32(&gpuData[9]));
7173 drawPoly4TGEx8_TRI(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,
7174 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[5]) & 0x000000ff), ((GETLE32(&gpuData[5])>>8) & 0x000000ff),(GETLE32(&gpuData[11]) & 0x000000ff), ((GETLE32(&gpuData[11])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),
7175 ((GETLE32(&gpuData[2])>>12) & 0x3f0),((GETLE32(&gpuData[2])>>22) & 511),
7176 GETLE32(&gpuData[0]),GETLE32(&gpuData[3]),GETLE32(&gpuData[6]),GETLE32(&gpuData[9]));
7179 drawPoly4TGD_TRI(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,(GETLE32(&gpuData[2]) & 0x000000ff),((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[5]) & 0x000000ff), ((GETLE32(&gpuData[5])>>8) & 0x000000ff),(GETLE32(&gpuData[11]) & 0x000000ff), ((GETLE32(&gpuData[11])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),GETLE32(&gpuData[0]),GETLE32(&gpuData[3]),GETLE32(&gpuData[6]),GETLE32(&gpuData[9]));
7186 switch (GlobalTextTP)
7189 drawPoly4TGEx4(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,
7190 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[5]) & 0x000000ff), ((GETLE32(&gpuData[5])>>8) & 0x000000ff),(GETLE32(&gpuData[11]) & 0x000000ff), ((GETLE32(&gpuData[11])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),
7191 ((GETLE32(&gpuData[2])>>12) & 0x3f0),((GETLE32(&gpuData[2])>>22) & 511),
7192 GETLE32(&gpuData[0]),GETLE32(&gpuData[3]),GETLE32(&gpuData[6]),GETLE32(&gpuData[9]));
7196 drawPoly4TGEx8(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,
7197 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[5]) & 0x000000ff), ((GETLE32(&gpuData[5])>>8) & 0x000000ff),(GETLE32(&gpuData[11]) & 0x000000ff), ((GETLE32(&gpuData[11])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),
7198 ((GETLE32(&gpuData[2])>>12) & 0x3f0),((GETLE32(&gpuData[2])>>22) & 511),
7199 GETLE32(&gpuData[0]),GETLE32(&gpuData[3]),GETLE32(&gpuData[6]),GETLE32(&gpuData[9]));
7202 drawPoly4TGD(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,(GETLE32(&gpuData[2]) & 0x000000ff),((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[5]) & 0x000000ff), ((GETLE32(&gpuData[5])>>8) & 0x000000ff),(GETLE32(&gpuData[11]) & 0x000000ff), ((GETLE32(&gpuData[11])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),GETLE32(&gpuData[0]),GETLE32(&gpuData[3]),GETLE32(&gpuData[6]),GETLE32(&gpuData[9]));
7208 switch (GlobalTextTP)
7211 drawPoly4TGEx4_TW(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,
7212 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[5]) & 0x000000ff), ((GETLE32(&gpuData[5])>>8) & 0x000000ff),(GETLE32(&gpuData[11]) & 0x000000ff), ((GETLE32(&gpuData[11])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),
7213 ((GETLE32(&gpuData[2])>>12) & 0x3f0),((GETLE32(&gpuData[2])>>22) & 511),
7214 GETLE32(&gpuData[0]),GETLE32(&gpuData[3]),GETLE32(&gpuData[6]),GETLE32(&gpuData[9]));
7217 drawPoly4TGEx8_TW(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,
7218 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[5]) & 0x000000ff), ((GETLE32(&gpuData[5])>>8) & 0x000000ff),(GETLE32(&gpuData[11]) & 0x000000ff), ((GETLE32(&gpuData[11])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),
7219 ((GETLE32(&gpuData[2])>>12) & 0x3f0),((GETLE32(&gpuData[2])>>22) & 511),
7220 GETLE32(&gpuData[0]),GETLE32(&gpuData[3]),GETLE32(&gpuData[6]),GETLE32(&gpuData[9]));
7223 drawPoly4TGD_TW(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,(GETLE32(&gpuData[2]) & 0x000000ff),((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[5]) & 0x000000ff), ((GETLE32(&gpuData[5])>>8) & 0x000000ff),(GETLE32(&gpuData[11]) & 0x000000ff), ((GETLE32(&gpuData[11])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),GETLE32(&gpuData[0]),GETLE32(&gpuData[3]),GETLE32(&gpuData[6]),GETLE32(&gpuData[9]));
7228 ////////////////////////////////////////////////////////////////////////
7230 ////////////////////////////////////////////////////////////////////////
7232 static void DrawSoftwareSpriteTWin(unsigned char * baseAddr,int32_t w,int32_t h)
7234 uint32_t *gpuData = (uint32_t *)baseAddr;
7235 short sx0,sy0,sx1,sy1,sx2,sy2,sx3,sy3;
7236 short tx0,ty0,tx1,ty1,tx2,ty2,tx3,ty3;
7241 sx0=sx3=sx0+PSXDisplay.DrawOffset.x;
7243 sy0=sy1=sy0+PSXDisplay.DrawOffset.y;
7246 tx0=tx3=GETLE32(&gpuData[2])&0xff;
7248 ty0=ty1=(GETLE32(&gpuData[2])>>8)&0xff;
7251 switch (GlobalTextTP)
7254 drawPoly4TEx4_TW_S(sx0,sy0,sx1,sy1,sx2,sy2,sx3,sy3,
7255 tx0,ty0,tx1,ty1,tx2,ty2,tx3,ty3,
7256 ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & 511));
7259 drawPoly4TEx8_TW_S(sx0,sy0,sx1,sy1,sx2,sy2,sx3,sy3,
7260 tx0,ty0,tx1,ty1,tx2,ty2,tx3,ty3,
7261 ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & 511));
7264 drawPoly4TD_TW_S(sx0,sy0,sx1,sy1,sx2,sy2,sx3,sy3,
7265 tx0,ty0,tx1,ty1,tx2,ty2,tx3,ty3);
7270 ////////////////////////////////////////////////////////////////////////
7272 static void DrawSoftwareSpriteMirror(unsigned char * baseAddr,int32_t w,int32_t h)
7274 int32_t sprtY,sprtX,sprtW,sprtH,lXDir,lYDir;
7275 int32_t clutY0,clutX0,clutP,textX0,textY0,sprtYa,sprCY,sprCX,sprA;
7277 uint32_t *gpuData = (uint32_t *)baseAddr;
7282 clutY0 = (GETLE32(&gpuData[2])>>22) & 511;
7283 clutX0 = (GETLE32(&gpuData[2])>>12) & 0x3f0;
7284 clutP = (clutY0<<11) + (clutX0<<1);
7285 textY0 = ((GETLE32(&gpuData[2])>>8) & 0x000000ff) + GlobalTextAddrY;
7286 textX0 = (GETLE32(&gpuData[2]) & 0x000000ff);
7288 sprtX+=PSXDisplay.DrawOffset.x;
7289 sprtY+=PSXDisplay.DrawOffset.y;
7303 if((sprtY+sprtH)<drawY) return;
7304 sprtH-=(drawY-sprtY);
7305 textY0+=(drawY-sprtY);
7311 if((sprtX+sprtW)<drawX) return;
7312 sprtW-=(drawX-sprtX);
7313 textX0+=(drawX-sprtX);
7317 if((sprtY+sprtH)>drawH) sprtH=drawH-sprtY+1;
7318 if((sprtX+sprtW)>drawW) sprtW=drawW-sprtX+1;
7320 if(usMirror&0x1000) lXDir=-1; else lXDir=1;
7321 if(usMirror&0x2000) lYDir=-1; else lYDir=1;
7323 switch (GlobalTextTP)
7325 case 0: // texture is 4-bit
7328 textX0=(GlobalTextAddrX<<1)+(textX0>>1);
7330 clutP=(clutY0<<10)+clutX0;
7331 for (sprCY=0;sprCY<sprtH;sprCY++)
7332 for (sprCX=0;sprCX<sprtW;sprCX++)
7334 tC= psxVub[((textY0+(sprCY*lYDir))<<11) + textX0 +(sprCX*lXDir)];
7335 sprA=sprtYa+(sprCY<<10)+sprtX + (sprCX<<1);
7336 GetTextureTransColG_SPR(&psxVuw[sprA],GETLE16(&psxVuw[clutP+((tC>>4)&0xf)]));
7337 GetTextureTransColG_SPR(&psxVuw[sprA+1],GETLE16(&psxVuw[clutP+(tC&0xf)]));
7344 for(sprCY=0;sprCY<sprtH;sprCY++)
7345 for(sprCX=0;sprCX<sprtW;sprCX++)
7347 tC = psxVub[((textY0+(sprCY*lYDir))<<11)+(GlobalTextAddrX<<1) + textX0 + (sprCX*lXDir)] & 0xff;
7348 GetTextureTransColG_SPR(&psxVuw[((sprtY+sprCY)<<10)+sprtX + sprCX],psxVuw[clutP+tC]);
7354 for (sprCY=0;sprCY<sprtH;sprCY++)
7355 for (sprCX=0;sprCX<sprtW;sprCX++)
7357 GetTextureTransColG_SPR(&psxVuw[((sprtY+sprCY)<<10)+sprtX+sprCX],
7358 GETLE16(&psxVuw[((textY0+(sprCY*lYDir))<<10)+GlobalTextAddrX + textX0 +(sprCX*lXDir)]));
7364 ////////////////////////////////////////////////////////////////////////
7366 void DrawSoftwareSprite_IL(unsigned char * baseAddr,short w,short h,int32_t tx,int32_t ty)
7368 int32_t sprtY,sprtX,sprtW,sprtH,tdx,tdy;
7369 uint32_t *gpuData = (uint32_t *)baseAddr;
7376 sprtX+=PSXDisplay.DrawOffset.x;
7377 sprtY+=PSXDisplay.DrawOffset.y;
7379 if(sprtX>drawW) return;
7380 if(sprtY>drawH) return;
7388 // Pete is too lazy to make a faster version ;)
7391 drawPoly4TEx4_IL(sprtX,sprtY,sprtX,sprtH,sprtW,sprtH,sprtW,sprtY,
7392 tx,ty, tx,tdy, tdx,tdy, tdx,ty,
7393 (GETLE32(&gpuData[2])>>12) & 0x3f0, ((GETLE32(&gpuData[2])>>22) & 511));
7397 drawPoly4TEx8_IL(sprtX,sprtY,sprtX,sprtH,sprtW,sprtH,sprtW,sprtY,
7398 tx,ty, tx,tdy, tdx,tdy, tdx,ty,
7399 (GETLE32(&gpuData[2])>>12) & 0x3f0, ((GETLE32(&gpuData[2])>>22) & 511));
7402 ////////////////////////////////////////////////////////////////////////
7404 static void DrawSoftwareSprite(unsigned char * baseAddr,short w,short h,int32_t tx,int32_t ty)
7406 int32_t sprtY,sprtX,sprtW,sprtH;
7407 int32_t clutY0,clutX0,clutP,textX0,textY0,sprtYa,sprCY,sprCX,sprA;
7409 uint32_t *gpuData = (uint32_t *)baseAddr;
7413 if(GlobalTextIL && GlobalTextTP<2)
7414 {DrawSoftwareSprite_IL(baseAddr,w,h,tx,ty);return;}
7420 clutY0 = (GETLE32(&gpuData[2])>>22) & 511;
7421 clutX0 = (GETLE32(&gpuData[2])>>12) & 0x3f0;
7423 clutP = (clutY0<<11) + (clutX0<<1);
7425 textY0 =ty+ GlobalTextAddrY;
7428 sprtX+=PSXDisplay.DrawOffset.x;
7429 sprtY+=PSXDisplay.DrawOffset.y;
7443 if((sprtY+sprtH)<drawY) return;
7444 sprtH-=(drawY-sprtY);
7445 textY0+=(drawY-sprtY);
7451 if((sprtX+sprtW)<drawX) return;
7453 sprtW-=(drawX-sprtX);
7454 textX0+=(drawX-sprtX);
7458 if((sprtY+sprtH)>drawH) sprtH=drawH-sprtY+1;
7459 if((sprtX+sprtW)>drawW) sprtW=drawW-sprtX+1;
7465 switch (GlobalTextTP)
7469 if(textX0&1) {bWS=TRUE;sprtW--;}
7470 if(sprtW&1) bWT=TRUE;
7473 textX0=(GlobalTextAddrX<<1)+(textX0>>1)+(textY0<<11);
7474 sprtYa=(sprtY<<10)+sprtX;
7475 clutP=(clutY0<<10)+clutX0;
7479 if(!bCheckMask && !DrawSemiTrans)
7481 for (sprCY=0;sprCY<sprtH;sprCY++)
7483 sprA=sprtYa+(sprCY<<10);
7484 pV=&psxVub[(sprCY<<11)+textX0];
7489 GetTextureTransColG_S(&psxVuw[sprA++],GETLE16(&psxVuw[clutP+((tC>>4)&0xf)]));
7492 for (sprCX=0;sprCX<sprtW;sprCX++,sprA+=2)
7496 GetTextureTransColG32_S((uint32_t *)&psxVuw[sprA],
7497 (((int32_t)GETLE16(&psxVuw[clutP+((tC>>4)&0xf)]))<<16)|
7498 GETLE16(&psxVuw[clutP+(tC&0x0f)]));
7504 GetTextureTransColG_S(&psxVuw[sprA],GETLE16(&psxVuw[clutP+(tC&0x0f)]));
7512 for (sprCY=0;sprCY<sprtH;sprCY++)
7514 sprA=sprtYa+(sprCY<<10);
7515 pV=&psxVub[(sprCY<<11)+textX0];
7520 GetTextureTransColG_SPR(&psxVuw[sprA++],GETLE16(&psxVuw[clutP+((tC>>4)&0xf)]));
7523 for (sprCX=0;sprCX<sprtW;sprCX++,sprA+=2)
7527 GetTextureTransColG32_SPR((uint32_t *)&psxVuw[sprA],
7528 (((int32_t)GETLE16(&psxVuw[clutP+((tC>>4)&0xf)])<<16))|
7529 GETLE16(&psxVuw[clutP+(tC&0x0f)]));
7535 GetTextureTransColG_SPR(&psxVuw[sprA],GETLE16(&psxVuw[clutP+(tC&0x0f)]));
7542 textX0+=(GlobalTextAddrX<<1) + (textY0<<11);
7546 if(!bCheckMask && !DrawSemiTrans)
7548 for(sprCY=0;sprCY<sprtH;sprCY++)
7550 sprA=((sprtY+sprCY)<<10)+sprtX;
7551 pV=&psxVub[(sprCY<<11)+textX0];
7552 for(sprCX=0;sprCX<sprtW;sprCX+=2,sprA+=2)
7554 tC = *pV++;tC2 = *pV++;
7555 GetTextureTransColG32_S((uint32_t *)&psxVuw[sprA],
7556 (((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16)|
7557 GETLE16(&psxVuw[clutP+tC]));
7560 GetTextureTransColG_S(&psxVuw[sprA],GETLE16(&psxVuw[clutP+(*pV)]));
7567 for(sprCY=0;sprCY<sprtH;sprCY++)
7569 sprA=((sprtY+sprCY)<<10)+sprtX;
7570 pV=&psxVub[(sprCY<<11)+textX0];
7571 for(sprCX=0;sprCX<sprtW;sprCX+=2,sprA+=2)
7573 tC = *pV++;tC2 = *pV++;
7574 GetTextureTransColG32_SPR((uint32_t *)&psxVuw[sprA],
7575 (((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16)|
7576 GETLE16(&psxVuw[clutP+tC]));
7579 GetTextureTransColG_SPR(&psxVuw[sprA],GETLE16(&psxVuw[clutP+(*pV)]));
7585 textX0+=(GlobalTextAddrX) + (textY0<<10);
7590 if(!bCheckMask && !DrawSemiTrans)
7592 for (sprCY=0;sprCY<sprtH;sprCY++)
7594 sprA=((sprtY+sprCY)<<10)+sprtX;
7596 for (sprCX=0;sprCX<sprtW;sprCX+=2,sprA+=2)
7598 GetTextureTransColG32_S((uint32_t *)&psxVuw[sprA],
7599 (((int32_t)GETLE16(&psxVuw[(sprCY<<10) + textX0 + sprCX +1]))<<16)|
7600 GETLE16(&psxVuw[(sprCY<<10) + textX0 + sprCX]));
7603 GetTextureTransColG_S(&psxVuw[sprA],
7604 GETLE16(&psxVuw[(sprCY<<10) + textX0 + sprCX]));
7612 for (sprCY=0;sprCY<sprtH;sprCY++)
7614 sprA=((sprtY+sprCY)<<10)+sprtX;
7616 for (sprCX=0;sprCX<sprtW;sprCX+=2,sprA+=2)
7618 GetTextureTransColG32_SPR((uint32_t *)&psxVuw[sprA],
7619 (((int32_t)GETLE16(&psxVuw[(sprCY<<10) + textX0 + sprCX +1]))<<16)|
7620 GETLE16(&psxVuw[(sprCY<<10) + textX0 + sprCX]));
7623 GetTextureTransColG_SPR(&psxVuw[sprA],
7624 GETLE16(&psxVuw[(sprCY<<10) + textX0 + sprCX]));
7631 ///////////////////////////////////////////////////////////////////////
7633 /////////////////////////////////////////////////////////////////
7634 /////////////////////////////////////////////////////////////////
7635 /////////////////////////////////////////////////////////////////
7637 ////////////////////////////////////////////////////////////////////////
7638 /////////////////////////////////////////////////////////////////
7639 /////////////////////////////////////////////////////////////////
7642 ///////////////////////////////////////////////////////////////////////
7644 static void Line_E_SE_Shade(int x0, int y0, int x1, int y1, uint32_t rgb0, uint32_t rgb1)
7646 int dx, dy, incrE, incrSE, d;
7647 uint32_t r0, g0, b0, r1, g1, b1;
7650 r0 = (rgb0 & 0x00ff0000);
7651 g0 = (rgb0 & 0x0000ff00) << 8;
7652 b0 = (rgb0 & 0x000000ff) << 16;
7653 r1 = (rgb1 & 0x00ff0000);
7654 g1 = (rgb1 & 0x0000ff00) << 8;
7655 b1 = (rgb1 & 0x000000ff) << 16;
7662 dr = ((int32_t)r1 - (int32_t)r0) / dx;
7663 dg = ((int32_t)g1 - (int32_t)g0) / dx;
7664 db = ((int32_t)b1 - (int32_t)b0) / dx;
7668 dr = ((int32_t)r1 - (int32_t)r0);
7669 dg = ((int32_t)g1 - (int32_t)g0);
7670 db = ((int32_t)b1 - (int32_t)b0);
7673 d = 2*dy - dx; /* Initial value of d */
7674 incrE = 2*dy; /* incr. used for move to E */
7675 incrSE = 2*(dy - dx); /* incr. used for move to SE */
7677 if ((x0>=drawX)&&(x0<drawW)&&(y0>=drawY)&&(y0<drawH))
7678 GetShadeTransCol(&psxVuw[(y0<<10)+x0],(unsigned short)(((r0 >> 9)&0x7c00)|((g0 >> 14)&0x03e0)|((b0 >> 19)&0x001f)));
7683 d = d + incrE; /* Choose E */
7687 d = d + incrSE; /* Choose SE */
7696 if ((x0>=drawX)&&(x0<drawW)&&(y0>=drawY)&&(y0<drawH))
7697 GetShadeTransCol(&psxVuw[(y0<<10)+x0],(unsigned short)(((r0 >> 9)&0x7c00)|((g0 >> 14)&0x03e0)|((b0 >> 19)&0x001f)));
7701 ///////////////////////////////////////////////////////////////////////
7703 static void Line_S_SE_Shade(int x0, int y0, int x1, int y1, uint32_t rgb0, uint32_t rgb1)
7705 int dx, dy, incrS, incrSE, d;
7706 uint32_t r0, g0, b0, r1, g1, b1;
7709 r0 = (rgb0 & 0x00ff0000);
7710 g0 = (rgb0 & 0x0000ff00) << 8;
7711 b0 = (rgb0 & 0x000000ff) << 16;
7712 r1 = (rgb1 & 0x00ff0000);
7713 g1 = (rgb1 & 0x0000ff00) << 8;
7714 b1 = (rgb1 & 0x000000ff) << 16;
7721 dr = ((int32_t)r1 - (int32_t)r0) / dy;
7722 dg = ((int32_t)g1 - (int32_t)g0) / dy;
7723 db = ((int32_t)b1 - (int32_t)b0) / dy;
7727 dr = ((int32_t)r1 - (int32_t)r0);
7728 dg = ((int32_t)g1 - (int32_t)g0);
7729 db = ((int32_t)b1 - (int32_t)b0);
7732 d = 2*dx - dy; /* Initial value of d */
7733 incrS = 2*dx; /* incr. used for move to S */
7734 incrSE = 2*(dx - dy); /* incr. used for move to SE */
7736 if ((x0>=drawX)&&(x0<drawW)&&(y0>=drawY)&&(y0<drawH))
7737 GetShadeTransCol(&psxVuw[(y0<<10)+x0],(unsigned short)(((r0 >> 9)&0x7c00)|((g0 >> 14)&0x03e0)|((b0 >> 19)&0x001f)));
7742 d = d + incrS; /* Choose S */
7746 d = d + incrSE; /* Choose SE */
7755 if ((x0>=drawX)&&(x0<drawW)&&(y0>=drawY)&&(y0<drawH))
7756 GetShadeTransCol(&psxVuw[(y0<<10)+x0],(unsigned short)(((r0 >> 9)&0x7c00)|((g0 >> 14)&0x03e0)|((b0 >> 19)&0x001f)));
7760 ///////////////////////////////////////////////////////////////////////
7762 static void Line_N_NE_Shade(int x0, int y0, int x1, int y1, uint32_t rgb0, uint32_t rgb1)
7764 int dx, dy, incrN, incrNE, d;
7765 uint32_t r0, g0, b0, r1, g1, b1;
7768 r0 = (rgb0 & 0x00ff0000);
7769 g0 = (rgb0 & 0x0000ff00) << 8;
7770 b0 = (rgb0 & 0x000000ff) << 16;
7771 r1 = (rgb1 & 0x00ff0000);
7772 g1 = (rgb1 & 0x0000ff00) << 8;
7773 b1 = (rgb1 & 0x000000ff) << 16;
7780 dr = ((int32_t)r1 - (int32_t)r0) / dy;
7781 dg = ((int32_t)g1 - (int32_t)g0) / dy;
7782 db = ((int32_t)b1 - (int32_t)b0) / dy;
7786 dr = ((int32_t)r1 - (int32_t)r0);
7787 dg = ((int32_t)g1 - (int32_t)g0);
7788 db = ((int32_t)b1 - (int32_t)b0);
7791 d = 2*dx - dy; /* Initial value of d */
7792 incrN = 2*dx; /* incr. used for move to N */
7793 incrNE = 2*(dx - dy); /* incr. used for move to NE */
7795 if ((x0>=drawX)&&(x0<drawW)&&(y0>=drawY)&&(y0<drawH))
7796 GetShadeTransCol(&psxVuw[(y0<<10)+x0],(unsigned short)(((r0 >> 9)&0x7c00)|((g0 >> 14)&0x03e0)|((b0 >> 19)&0x001f)));
7801 d = d + incrN; /* Choose N */
7805 d = d + incrNE; /* Choose NE */
7814 if ((x0>=drawX)&&(x0<drawW)&&(y0>=drawY)&&(y0<drawH))
7815 GetShadeTransCol(&psxVuw[(y0<<10)+x0],(unsigned short)(((r0 >> 9)&0x7c00)|((g0 >> 14)&0x03e0)|((b0 >> 19)&0x001f)));
7819 ///////////////////////////////////////////////////////////////////////
7821 static void Line_E_NE_Shade(int x0, int y0, int x1, int y1, uint32_t rgb0, uint32_t rgb1)
7823 int dx, dy, incrE, incrNE, d;
7824 uint32_t r0, g0, b0, r1, g1, b1;
7827 r0 = (rgb0 & 0x00ff0000);
7828 g0 = (rgb0 & 0x0000ff00) << 8;
7829 b0 = (rgb0 & 0x000000ff) << 16;
7830 r1 = (rgb1 & 0x00ff0000);
7831 g1 = (rgb1 & 0x0000ff00) << 8;
7832 b1 = (rgb1 & 0x000000ff) << 16;
7839 dr = ((int32_t)r1 - (int32_t)r0) / dx;
7840 dg = ((int32_t)g1 - (int32_t)g0) / dx;
7841 db = ((int32_t)b1 - (int32_t)b0) / dx;
7845 dr = ((int32_t)r1 - (int32_t)r0);
7846 dg = ((int32_t)g1 - (int32_t)g0);
7847 db = ((int32_t)b1 - (int32_t)b0);
7850 d = 2*dy - dx; /* Initial value of d */
7851 incrE = 2*dy; /* incr. used for move to E */
7852 incrNE = 2*(dy - dx); /* incr. used for move to NE */
7854 if ((x0>=drawX)&&(x0<drawW)&&(y0>=drawY)&&(y0<drawH))
7855 GetShadeTransCol(&psxVuw[(y0<<10)+x0],(unsigned short)(((r0 >> 9)&0x7c00)|((g0 >> 14)&0x03e0)|((b0 >> 19)&0x001f)));
7860 d = d + incrE; /* Choose E */
7864 d = d + incrNE; /* Choose NE */
7873 if ((x0>=drawX)&&(x0<drawW)&&(y0>=drawY)&&(y0<drawH))
7874 GetShadeTransCol(&psxVuw[(y0<<10)+x0],(unsigned short)(((r0 >> 9)&0x7c00)|((g0 >> 14)&0x03e0)|((b0 >> 19)&0x001f)));
7878 ///////////////////////////////////////////////////////////////////////
7880 static void VertLineShade(int x, int y0, int y1, uint32_t rgb0, uint32_t rgb1)
7883 uint32_t r0, g0, b0, r1, g1, b1;
7886 r0 = (rgb0 & 0x00ff0000);
7887 g0 = (rgb0 & 0x0000ff00) << 8;
7888 b0 = (rgb0 & 0x000000ff) << 16;
7889 r1 = (rgb1 & 0x00ff0000);
7890 g1 = (rgb1 & 0x0000ff00) << 8;
7891 b1 = (rgb1 & 0x000000ff) << 16;
7897 dr = ((int32_t)r1 - (int32_t)r0) / dy;
7898 dg = ((int32_t)g1 - (int32_t)g0) / dy;
7899 db = ((int32_t)b1 - (int32_t)b0) / dy;
7903 dr = ((int32_t)r1 - (int32_t)r0);
7904 dg = ((int32_t)g1 - (int32_t)g0);
7905 db = ((int32_t)b1 - (int32_t)b0);
7910 r0+=dr*(drawY - y0);
7911 g0+=dg*(drawY - y0);
7912 b0+=db*(drawY - y0);
7919 for (y = y0; y <= y1; y++)
7921 GetShadeTransCol(&psxVuw[(y<<10)+x],(unsigned short)(((r0 >> 9)&0x7c00)|((g0 >> 14)&0x03e0)|((b0 >> 19)&0x001f)));
7928 ///////////////////////////////////////////////////////////////////////
7930 static void HorzLineShade(int y, int x0, int x1, uint32_t rgb0, uint32_t rgb1)
7933 uint32_t r0, g0, b0, r1, g1, b1;
7936 r0 = (rgb0 & 0x00ff0000);
7937 g0 = (rgb0 & 0x0000ff00) << 8;
7938 b0 = (rgb0 & 0x000000ff) << 16;
7939 r1 = (rgb1 & 0x00ff0000);
7940 g1 = (rgb1 & 0x0000ff00) << 8;
7941 b1 = (rgb1 & 0x000000ff) << 16;
7947 dr = ((int32_t)r1 - (int32_t)r0) / dx;
7948 dg = ((int32_t)g1 - (int32_t)g0) / dx;
7949 db = ((int32_t)b1 - (int32_t)b0) / dx;
7953 dr = ((int32_t)r1 - (int32_t)r0);
7954 dg = ((int32_t)g1 - (int32_t)g0);
7955 db = ((int32_t)b1 - (int32_t)b0);
7960 r0+=dr*(drawX - x0);
7961 g0+=dg*(drawX - x0);
7962 b0+=db*(drawX - x0);
7969 for (x = x0; x <= x1; x++)
7971 GetShadeTransCol(&psxVuw[(y<<10)+x],(unsigned short)(((r0 >> 9)&0x7c00)|((g0 >> 14)&0x03e0)|((b0 >> 19)&0x001f)));
7978 ///////////////////////////////////////////////////////////////////////
7980 static void Line_E_SE_Flat(int x0, int y0, int x1, int y1, unsigned short colour)
7982 int dx, dy, incrE, incrSE, d, x, y;
7986 d = 2*dy - dx; /* Initial value of d */
7987 incrE = 2*dy; /* incr. used for move to E */
7988 incrSE = 2*(dy - dx); /* incr. used for move to SE */
7991 if ((x>=drawX)&&(x<drawW)&&(y>=drawY)&&(y<drawH))
7992 GetShadeTransCol(&psxVuw[(y<<10)+x], colour);
7997 d = d + incrE; /* Choose E */
8002 d = d + incrSE; /* Choose SE */
8006 if ((x>=drawX)&&(x<drawW)&&(y>=drawY)&&(y<drawH))
8007 GetShadeTransCol(&psxVuw[(y<<10)+x], colour);
8011 ///////////////////////////////////////////////////////////////////////
8013 static void Line_S_SE_Flat(int x0, int y0, int x1, int y1, unsigned short colour)
8015 int dx, dy, incrS, incrSE, d, x, y;
8019 d = 2*dx - dy; /* Initial value of d */
8020 incrS = 2*dx; /* incr. used for move to S */
8021 incrSE = 2*(dx - dy); /* incr. used for move to SE */
8024 if ((x>=drawX)&&(x<drawW)&&(y>=drawY)&&(y<drawH))
8025 GetShadeTransCol(&psxVuw[(y<<10)+x], colour);
8030 d = d + incrS; /* Choose S */
8035 d = d + incrSE; /* Choose SE */
8039 if ((x>=drawX)&&(x<drawW)&&(y>=drawY)&&(y<drawH))
8040 GetShadeTransCol(&psxVuw[(y<<10)+x], colour);
8044 ///////////////////////////////////////////////////////////////////////
8046 static void Line_N_NE_Flat(int x0, int y0, int x1, int y1, unsigned short colour)
8048 int dx, dy, incrN, incrNE, d, x, y;
8052 d = 2*dx - dy; /* Initial value of d */
8053 incrN = 2*dx; /* incr. used for move to N */
8054 incrNE = 2*(dx - dy); /* incr. used for move to NE */
8057 if ((x>=drawX)&&(x<drawW)&&(y>=drawY)&&(y<drawH))
8058 GetShadeTransCol(&psxVuw[(y<<10)+x], colour);
8063 d = d + incrN; /* Choose N */
8068 d = d + incrNE; /* Choose NE */
8072 if ((x>=drawX)&&(x<drawW)&&(y>=drawY)&&(y<drawH))
8073 GetShadeTransCol(&psxVuw[(y<<10)+x], colour);
8077 ///////////////////////////////////////////////////////////////////////
8079 static void Line_E_NE_Flat(int x0, int y0, int x1, int y1, unsigned short colour)
8081 int dx, dy, incrE, incrNE, d, x, y;
8085 d = 2*dy - dx; /* Initial value of d */
8086 incrE = 2*dy; /* incr. used for move to E */
8087 incrNE = 2*(dy - dx); /* incr. used for move to NE */
8090 if ((x>=drawX)&&(x<drawW)&&(y>=drawY)&&(y<drawH))
8091 GetShadeTransCol(&psxVuw[(y<<10)+x], colour);
8096 d = d + incrE; /* Choose E */
8101 d = d + incrNE; /* Choose NE */
8105 if ((x>=drawX)&&(x<drawW)&&(y>=drawY)&&(y<drawH))
8106 GetShadeTransCol(&psxVuw[(y<<10)+x], colour);
8110 ///////////////////////////////////////////////////////////////////////
8112 static void VertLineFlat(int x, int y0, int y1, unsigned short colour)
8122 for (y = y0; y <= y1; y++)
8123 GetShadeTransCol(&psxVuw[(y<<10)+x], colour);
8126 ///////////////////////////////////////////////////////////////////////
8128 static void HorzLineFlat(int y, int x0, int x1, unsigned short colour)
8138 for (x = x0; x <= x1; x++)
8139 GetShadeTransCol(&psxVuw[(y << 10) + x], colour);
8142 ///////////////////////////////////////////////////////////////////////
8144 /* Bresenham Line drawing function */
8145 static void DrawSoftwareLineShade(int32_t rgb0, int32_t rgb1)
8147 short x0, y0, x1, y1, xt, yt;
8151 if (lx0 > drawW && lx1 > drawW) return;
8152 if (ly0 > drawH && ly1 > drawH) return;
8153 if (lx0 < drawX && lx1 < drawX) return;
8154 if (ly0 < drawY && ly1 < drawY) return;
8155 if (drawY >= drawH) return;
8156 if (drawX >= drawW) return;
8169 VertLineShade(x0, y0, y1, rgb0, rgb1);
8171 VertLineShade(x0, y1, y0, rgb1, rgb0);
8177 HorzLineShade(y0, x0, x1, rgb0, rgb1);
8179 HorzLineShade(y0, x1, x0, rgb1, rgb0);
8204 Line_S_SE_Shade(x0, y0, x1, y1, rgb0, rgb1);
8206 Line_E_SE_Shade(x0, y0, x1, y1, rgb0, rgb1);
8210 Line_N_NE_Shade(x0, y0, x1, y1, rgb0, rgb1);
8212 Line_E_NE_Shade(x0, y0, x1, y1, rgb0, rgb1);
8216 ///////////////////////////////////////////////////////////////////////
8218 static void DrawSoftwareLineFlat(int32_t rgb)
8220 short x0, y0, x1, y1, xt, yt;
8222 unsigned short colour = 0;
8224 if (lx0 > drawW && lx1 > drawW) return;
8225 if (ly0 > drawH && ly1 > drawH) return;
8226 if (lx0 < drawX && lx1 < drawX) return;
8227 if (ly0 < drawY && ly1 < drawY) return;
8228 if (drawY >= drawH) return;
8229 if (drawX >= drawW) return;
8231 colour = ((rgb & 0x00f80000) >> 9) | ((rgb & 0x0000f800) >> 6) | ((rgb & 0x000000f8) >> 3);
8244 return; // Nothing to draw
8246 VertLineFlat(x0, y0, y1, colour);
8248 VertLineFlat(x0, y1, y0, colour);
8254 HorzLineFlat(y0, x0, x1, colour);
8256 HorzLineFlat(y0, x1, x0, colour);
8278 Line_S_SE_Flat(x0, y0, x1, y1, colour);
8280 Line_E_SE_Flat(x0, y0, x1, y1, colour);
8284 Line_N_NE_Flat(x0, y0, x1, y1, colour);
8286 Line_E_NE_Flat(x0, y0, x1, y1, colour);
8290 ///////////////////////////////////////////////////////////////////////