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;
66 int32_t 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!
1006 // ?? ff9 pal hooligan crack sets nonsense x0
1017 if(x1>1024) x1=1024;
1022 unsigned short *DSTPtr;
1023 unsigned short LineOffset;
1025 DSTPtr = psxVuw + (1024*y0) + x0;
1026 LineOffset = 1024 - dx;
1030 for(j=0;j<dx;j++) { PUTLE16(DSTPtr, col); DSTPtr++; }
1031 DSTPtr += LineOffset;
1037 unsigned short LineOffset;
1038 uint32_t lcol=(((int32_t)col)<<16)|col;
1040 DSTPtr = (uint32_t *)(psxVuw + (1024*y0) + x0);
1041 LineOffset = 512 - dx;
1045 for(j=0;j<dx;j++) { PUTLE32(DSTPtr, lcol); DSTPtr++; }
1046 DSTPtr += LineOffset;
1051 ////////////////////////////////////////////////////////////////////////
1052 ////////////////////////////////////////////////////////////////////////
1053 ////////////////////////////////////////////////////////////////////////
1054 // EDGE INTERPOLATION
1055 ////////////////////////////////////////////////////////////////////////
1056 ////////////////////////////////////////////////////////////////////////
1057 ////////////////////////////////////////////////////////////////////////
1059 typedef struct SOFTVTAG
1066 static soft_vertex vtx[4];
1067 static soft_vertex * left_array[4], * right_array[4];
1068 static int left_section, right_section;
1069 static int left_section_height, right_section_height;
1070 static int left_x, delta_left_x, right_x, delta_right_x;
1071 static int left_u, delta_left_u, left_v, delta_left_v;
1072 static int right_u, delta_right_u, right_v, delta_right_v;
1073 static int left_R, delta_left_R, right_R, delta_right_R;
1074 static int left_G, delta_left_G, right_G, delta_right_G;
1075 static int left_B, delta_left_B, right_B, delta_right_B;
1078 static inline int shl10idiv(int x, int y)
1080 #ifdef __ARM_ARCH_7A__
1081 // rearmed: let's use VFP divider instead
1082 float r = 1024.0f * (float)x / (float)y;
1091 ////////////////////////////////////////////////////////////////////////
1092 ////////////////////////////////////////////////////////////////////////
1093 ////////////////////////////////////////////////////////////////////////
1095 static inline int RightSection_F(void)
1097 soft_vertex * v1 = right_array[ right_section ];
1098 soft_vertex * v2 = right_array[ right_section-1 ];
1100 int height = v2->y - v1->y;
1101 if(height == 0) return 0;
1102 delta_right_x = (v2->x - v1->x) / height;
1105 right_section_height = height;
1109 ////////////////////////////////////////////////////////////////////////
1111 static inline int LeftSection_F(void)
1113 soft_vertex * v1 = left_array[ left_section ];
1114 soft_vertex * v2 = left_array[ left_section-1 ];
1116 int height = v2->y - v1->y;
1117 if(height == 0) return 0;
1118 delta_left_x = (v2->x - v1->x) / height;
1121 left_section_height = height;
1125 ////////////////////////////////////////////////////////////////////////
1127 static inline BOOL NextRow_F(void)
1129 if(--left_section_height<=0)
1131 if(--left_section <= 0) {return TRUE;}
1132 if(LeftSection_F() <= 0) {return TRUE;}
1136 left_x += delta_left_x;
1139 if(--right_section_height<=0)
1141 if(--right_section<=0) {return TRUE;}
1142 if(RightSection_F() <=0) {return TRUE;}
1146 right_x += delta_right_x;
1151 ////////////////////////////////////////////////////////////////////////
1153 static inline BOOL SetupSections_F(short x1, short y1, short x2, short y2, short x3, short y3)
1155 soft_vertex * v1, * v2, * v3;
1158 v1 = vtx; v1->x=x1<<16;v1->y=y1;
1159 v2 = vtx+1; v2->x=x2<<16;v2->y=y2;
1160 v3 = vtx+2; v3->x=x3<<16;v3->y=y3;
1162 if(v1->y > v2->y) { soft_vertex * v = v1; v1 = v2; v2 = v; }
1163 if(v1->y > v3->y) { soft_vertex * v = v1; v1 = v3; v3 = v; }
1164 if(v2->y > v3->y) { soft_vertex * v = v2; v2 = v3; v3 = v; }
1166 height = v3->y - v1->y;
1167 if(height == 0) {return FALSE;}
1168 longest = (((v2->y - v1->y) << 16) / height) * ((v3->x - v1->x)>>16) + (v1->x - v2->x);
1169 if(longest == 0) {return FALSE;}
1173 right_array[0] = v3;
1174 right_array[1] = v2;
1175 right_array[2] = v1;
1181 if(LeftSection_F() <= 0) return FALSE;
1182 if(RightSection_F() <= 0)
1185 if(RightSection_F() <= 0) return FALSE;
1194 right_array[0] = v3;
1195 right_array[1] = v1;
1198 if(RightSection_F() <= 0) return FALSE;
1199 if(LeftSection_F() <= 0)
1202 if(LeftSection_F() <= 0) return FALSE;
1207 Ymax=min(v3->y-1,drawH);
1212 ////////////////////////////////////////////////////////////////////////
1213 ////////////////////////////////////////////////////////////////////////
1215 static inline int RightSection_G(void)
1217 soft_vertex * v1 = right_array[ right_section ];
1218 soft_vertex * v2 = right_array[ right_section-1 ];
1220 int height = v2->y - v1->y;
1221 if(height == 0) return 0;
1222 delta_right_x = (v2->x - v1->x) / height;
1225 right_section_height = height;
1229 ////////////////////////////////////////////////////////////////////////
1231 static inline int LeftSection_G(void)
1233 soft_vertex * v1 = left_array[ left_section ];
1234 soft_vertex * v2 = left_array[ left_section-1 ];
1236 int height = v2->y - v1->y;
1237 if(height == 0) return 0;
1238 delta_left_x = (v2->x - v1->x) / height;
1241 delta_left_R = ((v2->R - v1->R)) / height;
1243 delta_left_G = ((v2->G - v1->G)) / height;
1245 delta_left_B = ((v2->B - v1->B)) / height;
1248 left_section_height = height;
1252 ////////////////////////////////////////////////////////////////////////
1254 static inline BOOL NextRow_G(void)
1256 if(--left_section_height<=0)
1258 if(--left_section <= 0) {return TRUE;}
1259 if(LeftSection_G() <= 0) {return TRUE;}
1263 left_x += delta_left_x;
1264 left_R += delta_left_R;
1265 left_G += delta_left_G;
1266 left_B += delta_left_B;
1269 if(--right_section_height<=0)
1271 if(--right_section<=0) {return TRUE;}
1272 if(RightSection_G() <=0) {return TRUE;}
1276 right_x += delta_right_x;
1281 ////////////////////////////////////////////////////////////////////////
1283 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)
1285 soft_vertex * v1, * v2, * v3;
1286 int height,longest,temp;
1288 v1 = vtx; v1->x=x1<<16;v1->y=y1;
1289 v1->R=(rgb1) & 0x00ff0000;
1290 v1->G=(rgb1<<8) & 0x00ff0000;
1291 v1->B=(rgb1<<16) & 0x00ff0000;
1292 v2 = vtx+1; v2->x=x2<<16;v2->y=y2;
1293 v2->R=(rgb2) & 0x00ff0000;
1294 v2->G=(rgb2<<8) & 0x00ff0000;
1295 v2->B=(rgb2<<16) & 0x00ff0000;
1296 v3 = vtx+2; v3->x=x3<<16;v3->y=y3;
1297 v3->R=(rgb3) & 0x00ff0000;
1298 v3->G=(rgb3<<8) & 0x00ff0000;
1299 v3->B=(rgb3<<16) & 0x00ff0000;
1301 if(v1->y > v2->y) { soft_vertex * v = v1; v1 = v2; v2 = v; }
1302 if(v1->y > v3->y) { soft_vertex * v = v1; v1 = v3; v3 = v; }
1303 if(v2->y > v3->y) { soft_vertex * v = v2; v2 = v3; v3 = v; }
1305 height = v3->y - v1->y;
1306 if(height == 0) {return FALSE;}
1307 temp=(((v2->y - v1->y) << 16) / height);
1308 longest = temp * ((v3->x - v1->x)>>16) + (v1->x - v2->x);
1309 if(longest == 0) {return FALSE;}
1313 right_array[0] = v3;
1314 right_array[1] = v2;
1315 right_array[2] = v1;
1321 if(LeftSection_G() <= 0) return FALSE;
1322 if(RightSection_G() <= 0)
1325 if(RightSection_G() <= 0) return FALSE;
1327 if(longest > -0x1000) longest = -0x1000;
1335 right_array[0] = v3;
1336 right_array[1] = v1;
1339 if(RightSection_G() <= 0) return FALSE;
1340 if(LeftSection_G() <= 0)
1343 if(LeftSection_G() <= 0) return FALSE;
1345 if(longest < 0x1000) longest = 0x1000;
1349 Ymax=min(v3->y-1,drawH);
1351 delta_right_R=shl10idiv(temp*((v3->R - v1->R)>>10)+((v1->R - v2->R)<<6),longest);
1352 delta_right_G=shl10idiv(temp*((v3->G - v1->G)>>10)+((v1->G - v2->G)<<6),longest);
1353 delta_right_B=shl10idiv(temp*((v3->B - v1->B)>>10)+((v1->B - v2->B)<<6),longest);
1358 ////////////////////////////////////////////////////////////////////////
1359 ////////////////////////////////////////////////////////////////////////
1361 static inline int RightSection_FT(void)
1363 soft_vertex * v1 = right_array[ right_section ];
1364 soft_vertex * v2 = right_array[ right_section-1 ];
1366 int height = v2->y - v1->y;
1367 if(height == 0) return 0;
1368 delta_right_x = (v2->x - v1->x) / height;
1371 right_section_height = height;
1375 ////////////////////////////////////////////////////////////////////////
1377 static inline int LeftSection_FT(void)
1379 soft_vertex * v1 = left_array[ left_section ];
1380 soft_vertex * v2 = left_array[ left_section-1 ];
1382 int height = v2->y - v1->y;
1383 if(height == 0) return 0;
1384 delta_left_x = (v2->x - v1->x) / height;
1387 delta_left_u = ((v2->u - v1->u)) / height;
1389 delta_left_v = ((v2->v - v1->v)) / height;
1392 left_section_height = height;
1396 ////////////////////////////////////////////////////////////////////////
1398 static inline BOOL NextRow_FT(void)
1400 if(--left_section_height<=0)
1402 if(--left_section <= 0) {return TRUE;}
1403 if(LeftSection_FT() <= 0) {return TRUE;}
1407 left_x += delta_left_x;
1408 left_u += delta_left_u;
1409 left_v += delta_left_v;
1412 if(--right_section_height<=0)
1414 if(--right_section<=0) {return TRUE;}
1415 if(RightSection_FT() <=0) {return TRUE;}
1419 right_x += delta_right_x;
1424 ////////////////////////////////////////////////////////////////////////
1426 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)
1428 soft_vertex * v1, * v2, * v3;
1429 int height,longest,temp;
1431 v1 = vtx; v1->x=x1<<16;v1->y=y1;
1432 v1->u=tx1<<16;v1->v=ty1<<16;
1433 v2 = vtx+1; v2->x=x2<<16;v2->y=y2;
1434 v2->u=tx2<<16;v2->v=ty2<<16;
1435 v3 = vtx+2; v3->x=x3<<16;v3->y=y3;
1436 v3->u=tx3<<16;v3->v=ty3<<16;
1438 if(v1->y > v2->y) { soft_vertex * v = v1; v1 = v2; v2 = v; }
1439 if(v1->y > v3->y) { soft_vertex * v = v1; v1 = v3; v3 = v; }
1440 if(v2->y > v3->y) { soft_vertex * v = v2; v2 = v3; v3 = v; }
1442 height = v3->y - v1->y;
1443 if(height == 0) {return FALSE;}
1445 temp=(((v2->y - v1->y) << 16) / height);
1446 longest = temp * ((v3->x - v1->x)>>16) + (v1->x - v2->x);
1448 if(longest == 0) {return FALSE;}
1452 right_array[0] = v3;
1453 right_array[1] = v2;
1454 right_array[2] = v1;
1460 if(LeftSection_FT() <= 0) return FALSE;
1461 if(RightSection_FT() <= 0)
1464 if(RightSection_FT() <= 0) return FALSE;
1466 if(longest > -0x1000) longest = -0x1000;
1474 right_array[0] = v3;
1475 right_array[1] = v1;
1478 if(RightSection_FT() <= 0) return FALSE;
1479 if(LeftSection_FT() <= 0)
1482 if(LeftSection_FT() <= 0) return FALSE;
1484 if(longest < 0x1000) longest = 0x1000;
1488 Ymax=min(v3->y-1,drawH);
1490 delta_right_u=shl10idiv(temp*((v3->u - v1->u)>>10)+((v1->u - v2->u)<<6),longest);
1491 delta_right_v=shl10idiv(temp*((v3->v - v1->v)>>10)+((v1->v - v2->v)<<6),longest);
1496 ////////////////////////////////////////////////////////////////////////
1497 ////////////////////////////////////////////////////////////////////////
1499 static inline int RightSection_GT(void)
1501 soft_vertex * v1 = right_array[ right_section ];
1502 soft_vertex * v2 = right_array[ right_section-1 ];
1504 int height = v2->y - v1->y;
1505 if(height == 0) return 0;
1506 delta_right_x = (v2->x - v1->x) / height;
1509 right_section_height = height;
1513 ////////////////////////////////////////////////////////////////////////
1515 static inline int LeftSection_GT(void)
1517 soft_vertex * v1 = left_array[ left_section ];
1518 soft_vertex * v2 = left_array[ left_section-1 ];
1520 int height = v2->y - v1->y;
1521 if(height == 0) return 0;
1522 delta_left_x = (v2->x - v1->x) / height;
1525 delta_left_u = ((v2->u - v1->u)) / height;
1527 delta_left_v = ((v2->v - v1->v)) / height;
1530 delta_left_R = ((v2->R - v1->R)) / height;
1532 delta_left_G = ((v2->G - v1->G)) / height;
1534 delta_left_B = ((v2->B - v1->B)) / height;
1537 left_section_height = height;
1541 ////////////////////////////////////////////////////////////////////////
1543 static inline BOOL NextRow_GT(void)
1545 if(--left_section_height<=0)
1547 if(--left_section <= 0) {return TRUE;}
1548 if(LeftSection_GT() <= 0) {return TRUE;}
1552 left_x += delta_left_x;
1553 left_u += delta_left_u;
1554 left_v += delta_left_v;
1555 left_R += delta_left_R;
1556 left_G += delta_left_G;
1557 left_B += delta_left_B;
1560 if(--right_section_height<=0)
1562 if(--right_section<=0) {return TRUE;}
1563 if(RightSection_GT() <=0) {return TRUE;}
1567 right_x += delta_right_x;
1572 ////////////////////////////////////////////////////////////////////////
1574 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)
1576 soft_vertex * v1, * v2, * v3;
1577 int height,longest,temp;
1579 v1 = vtx; v1->x=x1<<16;v1->y=y1;
1580 v1->u=tx1<<16;v1->v=ty1<<16;
1581 v1->R=(rgb1) & 0x00ff0000;
1582 v1->G=(rgb1<<8) & 0x00ff0000;
1583 v1->B=(rgb1<<16) & 0x00ff0000;
1585 v2 = vtx+1; v2->x=x2<<16;v2->y=y2;
1586 v2->u=tx2<<16;v2->v=ty2<<16;
1587 v2->R=(rgb2) & 0x00ff0000;
1588 v2->G=(rgb2<<8) & 0x00ff0000;
1589 v2->B=(rgb2<<16) & 0x00ff0000;
1591 v3 = vtx+2; v3->x=x3<<16;v3->y=y3;
1592 v3->u=tx3<<16;v3->v=ty3<<16;
1593 v3->R=(rgb3) & 0x00ff0000;
1594 v3->G=(rgb3<<8) & 0x00ff0000;
1595 v3->B=(rgb3<<16) & 0x00ff0000;
1597 if(v1->y > v2->y) { soft_vertex * v = v1; v1 = v2; v2 = v; }
1598 if(v1->y > v3->y) { soft_vertex * v = v1; v1 = v3; v3 = v; }
1599 if(v2->y > v3->y) { soft_vertex * v = v2; v2 = v3; v3 = v; }
1601 height = v3->y - v1->y;
1602 if(height == 0) {return FALSE;}
1604 temp=(((v2->y - v1->y) << 16) / height);
1605 longest = temp * ((v3->x - v1->x)>>16) + (v1->x - v2->x);
1607 if(longest == 0) {return FALSE;}
1611 right_array[0] = v3;
1612 right_array[1] = v2;
1613 right_array[2] = v1;
1619 if(LeftSection_GT() <= 0) return FALSE;
1620 if(RightSection_GT() <= 0)
1623 if(RightSection_GT() <= 0) return FALSE;
1626 if(longest > -0x1000) longest = -0x1000;
1634 right_array[0] = v3;
1635 right_array[1] = v1;
1638 if(RightSection_GT() <= 0) return FALSE;
1639 if(LeftSection_GT() <= 0)
1642 if(LeftSection_GT() <= 0) return FALSE;
1644 if(longest < 0x1000) longest = 0x1000;
1648 Ymax=min(v3->y-1,drawH);
1650 delta_right_R=shl10idiv(temp*((v3->R - v1->R)>>10)+((v1->R - v2->R)<<6),longest);
1651 delta_right_G=shl10idiv(temp*((v3->G - v1->G)>>10)+((v1->G - v2->G)<<6),longest);
1652 delta_right_B=shl10idiv(temp*((v3->B - v1->B)>>10)+((v1->B - v2->B)<<6),longest);
1654 delta_right_u=shl10idiv(temp*((v3->u - v1->u)>>10)+((v1->u - v2->u)<<6),longest);
1655 delta_right_v=shl10idiv(temp*((v3->v - v1->v)>>10)+((v1->v - v2->v)<<6),longest);
1660 ////////////////////////////////////////////////////////////////////////
1661 ////////////////////////////////////////////////////////////////////////
1663 static inline int RightSection_F4(void)
1665 soft_vertex * v1 = right_array[ right_section ];
1666 soft_vertex * v2 = right_array[ right_section-1 ];
1668 int height = v2->y - v1->y;
1669 right_section_height = height;
1675 delta_right_x = (v2->x - v1->x) / height;
1680 ////////////////////////////////////////////////////////////////////////
1682 static inline int LeftSection_F4(void)
1684 soft_vertex * v1 = left_array[ left_section ];
1685 soft_vertex * v2 = left_array[ left_section-1 ];
1687 int height = v2->y - v1->y;
1688 left_section_height = height;
1694 delta_left_x = (v2->x - v1->x) / height;
1699 ////////////////////////////////////////////////////////////////////////
1701 static inline BOOL NextRow_F4(void)
1703 if(--left_section_height<=0)
1705 if(--left_section > 0)
1706 while(LeftSection_F4()<=0)
1708 if(--left_section <= 0) break;
1713 left_x += delta_left_x;
1716 if(--right_section_height<=0)
1718 if(--right_section > 0)
1719 while(RightSection_F4()<=0)
1721 if(--right_section<=0) break;
1726 right_x += delta_right_x;
1731 ////////////////////////////////////////////////////////////////////////
1733 static inline BOOL SetupSections_F4(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4)
1735 soft_vertex * v1, * v2, * v3, * v4;
1736 int height,width,longest1,longest2;
1738 v1 = vtx; v1->x=x1<<16;v1->y=y1;
1739 v2 = vtx+1; v2->x=x2<<16;v2->y=y2;
1740 v3 = vtx+2; v3->x=x3<<16;v3->y=y3;
1741 v4 = vtx+3; v4->x=x4<<16;v4->y=y4;
1743 if(v1->y > v2->y) { soft_vertex * v = v1; v1 = v2; v2 = v; }
1744 if(v1->y > v3->y) { soft_vertex * v = v1; v1 = v3; v3 = v; }
1745 if(v1->y > v4->y) { soft_vertex * v = v1; v1 = v4; v4 = v; }
1746 if(v2->y > v3->y) { soft_vertex * v = v2; v2 = v3; v3 = v; }
1747 if(v2->y > v4->y) { soft_vertex * v = v2; v2 = v4; v4 = v; }
1748 if(v3->y > v4->y) { soft_vertex * v = v3; v3 = v4; v4 = v; }
1750 height = v4->y - v1->y; if(height == 0) height =1;
1751 width = (v4->x - v1->x)>>16;
1752 longest1 = (((v2->y - v1->y) << 16) / height) * width + (v1->x - v2->x);
1753 longest2 = (((v3->y - v1->y) << 16) / height) * width + (v1->x - v3->x);
1755 if(longest1 < 0) // 2 is right
1757 if(longest2 < 0) // 3 is right
1763 height = v3->y - v1->y; if(height == 0) height=1;
1764 longest1 = (((v2->y - v1->y) << 16) / height) * ((v3->x - v1->x)>>16) + (v1->x - v2->x);
1767 right_array[0] = v4; // 1
1768 right_array[1] = v3; // 3
1769 right_array[2] = v1; // 4
1774 height = v4->y - v2->y; if(height == 0) height=1;
1775 longest1 = (((v3->y - v2->y) << 16) / height) * ((v4->x - v2->x)>>16) + (v2->x - v3->x);
1778 right_array[0] = v4; // 1
1779 right_array[1] = v2; // 2
1780 right_array[2] = v1; // 4
1785 right_array[0] = v4; // 1
1786 right_array[1] = v3; // 2
1787 right_array[2] = v2; // 3
1788 right_array[3] = v1; // 4
1796 left_array[1] = v3; // 1
1797 left_array[2] = v1; // 2
1798 left_section = 2; // 3
1799 right_array[0] = v4; // 4
1800 right_array[1] = v2;
1801 right_array[2] = v1;
1809 left_array[0] = v4; // 1
1810 left_array[1] = v2; // 2
1811 left_array[2] = v1; // 3
1812 left_section = 2; // 4
1813 right_array[0] = v4;
1814 right_array[1] = v3;
1815 right_array[2] = v1;
1820 right_array[0] = v4;
1821 right_array[1] = v1;
1824 height = v3->y - v1->y; if(height == 0) height=1;
1825 longest1 = (((v2->y - v1->y) << 16) / height) * ((v3->x - v1->x)>>16) + (v1->x - v2->x);
1828 left_array[0] = v4; // 1
1829 left_array[1] = v3; // 3
1830 left_array[2] = v1; // 4
1835 height = v4->y - v2->y; if(height == 0) height=1;
1836 longest1 = (((v3->y - v2->y) << 16) / height) * ((v4->x - v2->x)>>16) + (v2->x - v3->x);
1839 left_array[0] = v4; // 1
1840 left_array[1] = v2; // 2
1841 left_array[2] = v1; // 4
1846 left_array[0] = v4; // 1
1847 left_array[1] = v3; // 2
1848 left_array[2] = v2; // 3
1849 left_array[3] = v1; // 4
1856 while(LeftSection_F4()<=0)
1858 if(--left_section <= 0) break;
1861 while(RightSection_F4()<=0)
1863 if(--right_section <= 0) break;
1867 Ymax=min(v4->y-1,drawH);
1872 ////////////////////////////////////////////////////////////////////////
1873 ////////////////////////////////////////////////////////////////////////
1875 static inline int RightSection_FT4(void)
1877 soft_vertex * v1 = right_array[ right_section ];
1878 soft_vertex * v2 = right_array[ right_section-1 ];
1880 int height = v2->y - v1->y;
1881 right_section_height = height;
1889 delta_right_x = (v2->x - v1->x) / height;
1890 delta_right_u = (v2->u - v1->u) / height;
1891 delta_right_v = (v2->v - v1->v) / height;
1896 ////////////////////////////////////////////////////////////////////////
1898 static inline int LeftSection_FT4(void)
1900 soft_vertex * v1 = left_array[ left_section ];
1901 soft_vertex * v2 = left_array[ left_section-1 ];
1903 int height = v2->y - v1->y;
1904 left_section_height = height;
1912 delta_left_x = (v2->x - v1->x) / height;
1913 delta_left_u = (v2->u - v1->u) / height;
1914 delta_left_v = (v2->v - v1->v) / height;
1919 ////////////////////////////////////////////////////////////////////////
1921 static inline BOOL NextRow_FT4(void)
1923 if(--left_section_height<=0)
1925 if(--left_section > 0)
1926 while(LeftSection_FT4()<=0)
1928 if(--left_section <= 0) break;
1933 left_x += delta_left_x;
1934 left_u += delta_left_u;
1935 left_v += delta_left_v;
1938 if(--right_section_height<=0)
1940 if(--right_section > 0)
1941 while(RightSection_FT4()<=0)
1943 if(--right_section<=0) break;
1948 right_x += delta_right_x;
1949 right_u += delta_right_u;
1950 right_v += delta_right_v;
1955 ////////////////////////////////////////////////////////////////////////
1957 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)
1959 soft_vertex * v1, * v2, * v3, * v4;
1960 int height,width,longest1,longest2;
1962 v1 = vtx; v1->x=x1<<16;v1->y=y1;
1963 v1->u=tx1<<16;v1->v=ty1<<16;
1965 v2 = vtx+1; v2->x=x2<<16;v2->y=y2;
1966 v2->u=tx2<<16;v2->v=ty2<<16;
1968 v3 = vtx+2; v3->x=x3<<16;v3->y=y3;
1969 v3->u=tx3<<16;v3->v=ty3<<16;
1971 v4 = vtx+3; v4->x=x4<<16;v4->y=y4;
1972 v4->u=tx4<<16;v4->v=ty4<<16;
1974 if(v1->y > v2->y) { soft_vertex * v = v1; v1 = v2; v2 = v; }
1975 if(v1->y > v3->y) { soft_vertex * v = v1; v1 = v3; v3 = v; }
1976 if(v1->y > v4->y) { soft_vertex * v = v1; v1 = v4; v4 = v; }
1977 if(v2->y > v3->y) { soft_vertex * v = v2; v2 = v3; v3 = v; }
1978 if(v2->y > v4->y) { soft_vertex * v = v2; v2 = v4; v4 = v; }
1979 if(v3->y > v4->y) { soft_vertex * v = v3; v3 = v4; v4 = v; }
1981 height = v4->y - v1->y; if(height == 0) height =1;
1982 width = (v4->x - v1->x)>>16;
1983 longest1 = (((v2->y - v1->y) << 16) / height) * width + (v1->x - v2->x);
1984 longest2 = (((v3->y - v1->y) << 16) / height) * width + (v1->x - v3->x);
1986 if(longest1 < 0) // 2 is right
1988 if(longest2 < 0) // 3 is right
1994 height = v3->y - v1->y; if(height == 0) height=1;
1995 longest1 = (((v2->y - v1->y) << 16) / height) * ((v3->x - v1->x)>>16) + (v1->x - v2->x);
1998 right_array[0] = v4; // 1
1999 right_array[1] = v3; // 3
2000 right_array[2] = v1; // 4
2005 height = v4->y - v2->y; if(height == 0) height=1;
2006 longest1 = (((v3->y - v2->y) << 16) / height) * ((v4->x - v2->x)>>16) + (v2->x - v3->x);
2009 right_array[0] = v4; // 1
2010 right_array[1] = v2; // 2
2011 right_array[2] = v1; // 4
2016 right_array[0] = v4; // 1
2017 right_array[1] = v3; // 2
2018 right_array[2] = v2; // 3
2019 right_array[3] = v1; // 4
2027 left_array[1] = v3; // 1
2028 left_array[2] = v1; // 2
2029 left_section = 2; // 3
2030 right_array[0] = v4; // 4
2031 right_array[1] = v2;
2032 right_array[2] = v1;
2040 left_array[0] = v4; // 1
2041 left_array[1] = v2; // 2
2042 left_array[2] = v1; // 3
2043 left_section = 2; // 4
2044 right_array[0] = v4;
2045 right_array[1] = v3;
2046 right_array[2] = v1;
2051 right_array[0] = v4;
2052 right_array[1] = v1;
2055 height = v3->y - v1->y; if(height == 0) height=1;
2056 longest1 = (((v2->y - v1->y) << 16) / height) * ((v3->x - v1->x)>>16) + (v1->x - v2->x);
2059 left_array[0] = v4; // 1
2060 left_array[1] = v3; // 3
2061 left_array[2] = v1; // 4
2066 height = v4->y - v2->y; if(height == 0) height=1;
2067 longest1 = (((v3->y - v2->y) << 16) / height) * ((v4->x - v2->x)>>16) + (v2->x - v3->x);
2070 left_array[0] = v4; // 1
2071 left_array[1] = v2; // 2
2072 left_array[2] = v1; // 4
2077 left_array[0] = v4; // 1
2078 left_array[1] = v3; // 2
2079 left_array[2] = v2; // 3
2080 left_array[3] = v1; // 4
2087 while(LeftSection_FT4()<=0)
2089 if(--left_section <= 0) break;
2092 while(RightSection_FT4()<=0)
2094 if(--right_section <= 0) break;
2098 Ymax=min(v4->y-1,drawH);
2103 ////////////////////////////////////////////////////////////////////////
2104 ////////////////////////////////////////////////////////////////////////
2106 static inline int RightSection_GT4(void)
2108 soft_vertex * v1 = right_array[ right_section ];
2109 soft_vertex * v2 = right_array[ right_section-1 ];
2111 int height = v2->y - v1->y;
2112 right_section_height = height;
2124 delta_right_x = (v2->x - v1->x) / height;
2125 delta_right_u = (v2->u - v1->u) / height;
2126 delta_right_v = (v2->v - v1->v) / height;
2127 delta_right_R = (v2->R - v1->R) / height;
2128 delta_right_G = (v2->G - v1->G) / height;
2129 delta_right_B = (v2->B - v1->B) / height;
2134 ////////////////////////////////////////////////////////////////////////
2136 static inline int LeftSection_GT4(void)
2138 soft_vertex * v1 = left_array[ left_section ];
2139 soft_vertex * v2 = left_array[ left_section-1 ];
2141 int height = v2->y - v1->y;
2142 left_section_height = height;
2154 delta_left_x = (v2->x - v1->x) / height;
2155 delta_left_u = (v2->u - v1->u) / height;
2156 delta_left_v = (v2->v - v1->v) / height;
2157 delta_left_R = (v2->R - v1->R) / height;
2158 delta_left_G = (v2->G - v1->G) / height;
2159 delta_left_B = (v2->B - v1->B) / height;
2164 ////////////////////////////////////////////////////////////////////////
2166 static inline BOOL NextRow_GT4(void)
2168 if(--left_section_height<=0)
2170 if(--left_section > 0)
2171 while(LeftSection_GT4()<=0)
2173 if(--left_section <= 0) break;
2178 left_x += delta_left_x;
2179 left_u += delta_left_u;
2180 left_v += delta_left_v;
2181 left_R += delta_left_R;
2182 left_G += delta_left_G;
2183 left_B += delta_left_B;
2186 if(--right_section_height<=0)
2188 if(--right_section > 0)
2189 while(RightSection_GT4()<=0)
2191 if(--right_section<=0) break;
2196 right_x += delta_right_x;
2197 right_u += delta_right_u;
2198 right_v += delta_right_v;
2199 right_R += delta_right_R;
2200 right_G += delta_right_G;
2201 right_B += delta_right_B;
2206 ////////////////////////////////////////////////////////////////////////
2208 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)
2210 soft_vertex * v1, * v2, * v3, * v4;
2211 int height,width,longest1,longest2;
2213 v1 = vtx; v1->x=x1<<16;v1->y=y1;
2214 v1->u=tx1<<16;v1->v=ty1<<16;
2215 v1->R=(rgb1) & 0x00ff0000;
2216 v1->G=(rgb1<<8) & 0x00ff0000;
2217 v1->B=(rgb1<<16) & 0x00ff0000;
2219 v2 = vtx+1; v2->x=x2<<16;v2->y=y2;
2220 v2->u=tx2<<16;v2->v=ty2<<16;
2221 v2->R=(rgb2) & 0x00ff0000;
2222 v2->G=(rgb2<<8) & 0x00ff0000;
2223 v2->B=(rgb2<<16) & 0x00ff0000;
2225 v3 = vtx+2; v3->x=x3<<16;v3->y=y3;
2226 v3->u=tx3<<16;v3->v=ty3<<16;
2227 v3->R=(rgb3) & 0x00ff0000;
2228 v3->G=(rgb3<<8) & 0x00ff0000;
2229 v3->B=(rgb3<<16) & 0x00ff0000;
2231 v4 = vtx+3; v4->x=x4<<16;v4->y=y4;
2232 v4->u=tx4<<16;v4->v=ty4<<16;
2233 v4->R=(rgb4) & 0x00ff0000;
2234 v4->G=(rgb4<<8) & 0x00ff0000;
2235 v4->B=(rgb4<<16) & 0x00ff0000;
2237 if(v1->y > v2->y) { soft_vertex * v = v1; v1 = v2; v2 = v; }
2238 if(v1->y > v3->y) { soft_vertex * v = v1; v1 = v3; v3 = v; }
2239 if(v1->y > v4->y) { soft_vertex * v = v1; v1 = v4; v4 = v; }
2240 if(v2->y > v3->y) { soft_vertex * v = v2; v2 = v3; v3 = v; }
2241 if(v2->y > v4->y) { soft_vertex * v = v2; v2 = v4; v4 = v; }
2242 if(v3->y > v4->y) { soft_vertex * v = v3; v3 = v4; v4 = v; }
2244 height = v4->y - v1->y; if(height == 0) height =1;
2245 width = (v4->x - v1->x)>>16;
2246 longest1 = (((v2->y - v1->y) << 16) / height) * width + (v1->x - v2->x);
2247 longest2 = (((v3->y - v1->y) << 16) / height) * width + (v1->x - v3->x);
2249 if(longest1 < 0) // 2 is right
2251 if(longest2 < 0) // 3 is right
2257 height = v3->y - v1->y; if(height == 0) height=1;
2258 longest1 = (((v2->y - v1->y) << 16) / height) * ((v3->x - v1->x)>>16) + (v1->x - v2->x);
2261 right_array[0] = v4; // 1
2262 right_array[1] = v3; // 3
2263 right_array[2] = v1; // 4
2268 height = v4->y - v2->y; if(height == 0) height=1;
2269 longest1 = (((v3->y - v2->y) << 16) / height) * ((v4->x - v2->x)>>16) + (v2->x - v3->x);
2272 right_array[0] = v4; // 1
2273 right_array[1] = v2; // 2
2274 right_array[2] = v1; // 4
2279 right_array[0] = v4; // 1
2280 right_array[1] = v3; // 2
2281 right_array[2] = v2; // 3
2282 right_array[3] = v1; // 4
2290 left_array[1] = v3; // 1
2291 left_array[2] = v1; // 2
2292 left_section = 2; // 3
2293 right_array[0] = v4; // 4
2294 right_array[1] = v2;
2295 right_array[2] = v1;
2303 left_array[0] = v4; // 1
2304 left_array[1] = v2; // 2
2305 left_array[2] = v1; // 3
2306 left_section = 2; // 4
2307 right_array[0] = v4;
2308 right_array[1] = v3;
2309 right_array[2] = v1;
2314 right_array[0] = v4;
2315 right_array[1] = v1;
2318 height = v3->y - v1->y; if(height == 0) height=1;
2319 longest1 = (((v2->y - v1->y) << 16) / height) * ((v3->x - v1->x)>>16) + (v1->x - v2->x);
2322 left_array[0] = v4; // 1
2323 left_array[1] = v3; // 3
2324 left_array[2] = v1; // 4
2329 height = v4->y - v2->y; if(height == 0) height=1;
2330 longest1 = (((v3->y - v2->y) << 16) / height) * ((v4->x - v2->x)>>16) + (v2->x - v3->x);
2333 left_array[0] = v4; // 1
2334 left_array[1] = v2; // 2
2335 left_array[2] = v1; // 4
2340 left_array[0] = v4; // 1
2341 left_array[1] = v3; // 2
2342 left_array[2] = v2; // 3
2343 left_array[3] = v1; // 4
2350 while(LeftSection_GT4()<=0)
2352 if(--left_section <= 0) break;
2355 while(RightSection_GT4()<=0)
2357 if(--right_section <= 0) break;
2361 Ymax=min(v4->y-1,drawH);
2366 ////////////////////////////////////////////////////////////////////////
2367 ////////////////////////////////////////////////////////////////////////
2368 ////////////////////////////////////////////////////////////////////////
2370 ////////////////////////////////////////////////////////////////////////
2371 ////////////////////////////////////////////////////////////////////////
2372 ////////////////////////////////////////////////////////////////////////
2374 ////////////////////////////////////////////////////////////////////////
2375 // POLY 3/4 FLAT SHADED
2376 ////////////////////////////////////////////////////////////////////////
2378 static inline void drawPoly3Fi(short x1,short y1,short x2,short y2,short x3,short y3,int32_t rgb)
2380 int i,j,xmin,xmax,ymin,ymax;
2381 unsigned short color;uint32_t lcolor;
2383 if(x1>drawW && x2>drawW && x3>drawW) return;
2384 if(y1>drawH && y2>drawH && y3>drawH) return;
2385 if(x1<drawX && x2<drawX && x3<drawX) return;
2386 if(y1<drawY && y2<drawY && y3<drawY) return;
2387 if(drawY>=drawH) return;
2388 if(drawX>=drawW) return;
2390 if(!SetupSections_F(x1,y1,x2,y2,x3,y3)) return;
2394 color = ((rgb & 0x00f80000)>>9) | ((rgb & 0x0000f800)>>6) | ((rgb & 0x000000f8)>>3);
2395 lcolor=lSetMask|(((uint32_t)(color))<<16)|color;
2397 for(ymin=Ymin;ymin<drawY;ymin++)
2398 if(NextRow_F()) return;
2402 if(!bCheckMask && !DrawSemiTrans)
2405 for (i=ymin;i<=ymax;i++)
2407 xmin=left_x >> 16; if(drawX>xmin) xmin=drawX;
2408 xmax=(right_x >> 16)-1; if(drawW<xmax) xmax=drawW;
2410 for(j=xmin;j<xmax;j+=2)
2412 PUTLE32(((uint32_t *)&psxVuw[(i<<10)+j]), lcolor);
2414 if(j==xmax) PUTLE16(&psxVuw[(i<<10)+j], color);
2416 if(NextRow_F()) return;
2423 for (i=ymin;i<=ymax;i++)
2425 xmin=left_x >> 16; if(drawX>xmin) xmin=drawX;
2426 xmax=(right_x >> 16)-1; if(drawW<xmax) xmax=drawW;
2428 for(j=xmin;j<xmax;j+=2)
2430 GetShadeTransCol32((uint32_t *)&psxVuw[(i<<10)+j],lcolor);
2433 GetShadeTransCol(&psxVuw[(i<<10)+j],color);
2435 if(NextRow_F()) return;
2439 ////////////////////////////////////////////////////////////////////////
2441 static void drawPoly3F(int32_t rgb)
2443 drawPoly3Fi(lx0,ly0,lx1,ly1,lx2,ly2,rgb);
2448 static void drawPoly4F_TRI(int32_t rgb)
2450 drawPoly3Fi(lx1,ly1,lx3,ly3,lx2,ly2,rgb);
2451 drawPoly3Fi(lx0,ly0,lx1,ly1,lx2,ly2,rgb);
2458 static void drawPoly4F(int32_t rgb)
2460 int i,j,xmin,xmax,ymin,ymax;
2461 unsigned short color;uint32_t lcolor;
2463 if(lx0>drawW && lx1>drawW && lx2>drawW && lx3>drawW) return;
2464 if(ly0>drawH && ly1>drawH && ly2>drawH && ly3>drawH) return;
2465 if(lx0<drawX && lx1<drawX && lx2<drawX && lx3<drawX) return;
2466 if(ly0<drawY && ly1<drawY && ly2<drawY && ly3<drawY) return;
2467 if(drawY>=drawH) return;
2468 if(drawX>=drawW) return;
2470 if(!SetupSections_F4(lx0,ly0,lx1,ly1,lx2,ly2,lx3,ly3)) return;
2474 for(ymin=Ymin;ymin<drawY;ymin++)
2475 if(NextRow_F4()) return;
2477 color = ((rgb & 0x00f80000)>>9) | ((rgb & 0x0000f800)>>6) | ((rgb & 0x000000f8)>>3);
2478 lcolor= lSetMask|(((uint32_t)(color))<<16)|color;
2482 if(!bCheckMask && !DrawSemiTrans)
2485 for (i=ymin;i<=ymax;i++)
2487 xmin=left_x >> 16; if(drawX>xmin) xmin=drawX;
2488 xmax=(right_x >> 16)-1; if(drawW<xmax) xmax=drawW;
2490 for(j=xmin;j<xmax;j+=2)
2492 PUTLE32(((uint32_t *)&psxVuw[(i<<10)+j]), lcolor);
2494 if(j==xmax) PUTLE16(&psxVuw[(i<<10)+j], color);
2496 if(NextRow_F4()) return;
2503 for (i=ymin;i<=ymax;i++)
2505 xmin=left_x >> 16; if(drawX>xmin) xmin=drawX;
2506 xmax=(right_x >> 16)-1; if(drawW<xmax) xmax=drawW;
2508 for(j=xmin;j<xmax;j+=2)
2510 GetShadeTransCol32((uint32_t *)&psxVuw[(i<<10)+j],lcolor);
2512 if(j==xmax) GetShadeTransCol(&psxVuw[(i<<10)+j],color);
2514 if(NextRow_F4()) return;
2518 ////////////////////////////////////////////////////////////////////////
2519 // POLY 3/4 F-SHADED TEX PAL 4
2520 ////////////////////////////////////////////////////////////////////////
2522 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)
2524 int i,j,xmin,xmax,ymin,ymax;
2525 int32_t difX, difY,difX2, difY2;
2526 int32_t posX,posY,YAdjust,XAdjust;
2530 if(x1>drawW && x2>drawW && x3>drawW) return;
2531 if(y1>drawH && y2>drawH && y3>drawH) return;
2532 if(x1<drawX && x2<drawX && x3<drawX) return;
2533 if(y1<drawY && y2<drawY && y3<drawY) return;
2534 if(drawY>=drawH) return;
2535 if(drawX>=drawW) return;
2537 if(!SetupSections_FT(x1,y1,x2,y2,x3,y3,tx1,ty1,tx2,ty2,tx3,ty3)) return;
2541 for(ymin=Ymin;ymin<drawY;ymin++)
2542 if(NextRow_FT()) return;
2544 clutP=(clY<<10)+clX;
2546 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
2548 difX=delta_right_u;difX2=difX<<1;
2549 difY=delta_right_v;difY2=difY<<1;
2553 if(!bCheckMask && !DrawSemiTrans)
2555 for (i=ymin;i<=ymax;i++)
2557 xmin=(left_x >> 16);
2558 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!!
2559 if(drawW<xmax) xmax=drawW;
2567 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
2569 for(j=xmin;j<xmax;j+=2)
2572 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(XAdjust>>1)];
2573 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
2574 XAdjust=((posX+difX)>>16);
2575 tC2 = psxVub[(((posY+difY)>>5)&(int32_t)0xFFFFF800)+YAdjust+
2577 tC2=(tC2>>((XAdjust&1)<<2))&0xf;
2579 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
2580 GETLE16(&psxVuw[clutP+tC1])|
2581 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
2589 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+
2591 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
2592 GetTextureTransColG_S(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
2605 for (i=ymin;i<=ymax;i++)
2607 xmin=(left_x >> 16);
2608 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!!!!
2609 if(drawW<xmax) xmax=drawW;
2617 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
2619 for(j=xmin;j<xmax;j+=2)
2622 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(XAdjust>>1)];
2623 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
2624 XAdjust=((posX+difX)>>16);
2625 tC2 = psxVub[(((posY+difY)>>5)&(int32_t)0xFFFFF800)+YAdjust+
2627 tC2=(tC2>>((XAdjust&1)<<2))&0xf;
2629 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
2630 GETLE16(&psxVuw[clutP+tC1])|
2631 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
2639 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+
2641 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
2642 GetTextureTransColG(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
2652 ////////////////////////////////////////////////////////////////////////
2654 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)
2656 int i,j,xmin,xmax,ymin,ymax;
2657 int32_t difX, difY,difX2, difY2;
2658 int32_t posX,posY,YAdjust,XAdjust;
2662 if(x1>drawW && x2>drawW && x3>drawW) return;
2663 if(y1>drawH && y2>drawH && y3>drawH) return;
2664 if(x1<drawX && x2<drawX && x3<drawX) return;
2665 if(y1<drawY && y2<drawY && y3<drawY) return;
2666 if(drawY>=drawH) return;
2667 if(drawX>=drawW) return;
2669 if(!SetupSections_FT(x1,y1,x2,y2,x3,y3,tx1,ty1,tx2,ty2,tx3,ty3)) return;
2673 for(ymin=Ymin;ymin<drawY;ymin++)
2674 if(NextRow_FT()) return;
2676 clutP=(clY<<10)+clX;
2678 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
2679 YAdjust+=(TWin.Position.y0<<11)+(TWin.Position.x0>>1);
2681 difX=delta_right_u;difX2=difX<<1;
2682 difY=delta_right_v;difY2=difY<<1;
2686 if(!bCheckMask && !DrawSemiTrans)
2688 for (i=ymin;i<=ymax;i++)
2690 xmin=(left_x >> 16);
2691 xmax=(right_x >> 16);//-1; //!!!!!!!!!!!!!!!!
2692 if(xmax>xmin) xmax--;
2694 if(drawW<xmax) xmax=drawW;
2702 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
2704 for(j=xmin;j<xmax;j+=2)
2706 XAdjust=(posX>>16)&TWin.xmask;
2707 tC1 = psxVub[(((posY>>16)&TWin.ymask)<<11)+
2708 YAdjust+(XAdjust>>1)];
2709 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
2710 XAdjust=((posX+difX)>>16)&TWin.xmask;
2711 tC2 = psxVub[((((posY+difY)>>16)&TWin.ymask)<<11)+
2712 YAdjust+(XAdjust>>1)];
2713 tC2=(tC2>>((XAdjust&1)<<2))&0xf;
2715 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
2716 GETLE16(&psxVuw[clutP+tC1])|
2717 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
2724 XAdjust=(posX>>16)&TWin.xmask;
2725 tC1 = psxVub[(((posY>>16)&TWin.ymask)<<11)+
2726 YAdjust+(XAdjust>>1)];
2727 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
2728 GetTextureTransColG_S(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
2741 for (i=ymin;i<=ymax;i++)
2743 xmin=(left_x >> 16);
2744 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!!!!
2745 if(drawW<xmax) xmax=drawW;
2753 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
2755 for(j=xmin;j<xmax;j+=2)
2757 XAdjust=(posX>>16)&TWin.xmask;
2758 tC1 = psxVub[(((posY>>16)&TWin.ymask)<<11)+
2759 YAdjust+(XAdjust>>1)];
2760 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
2761 XAdjust=((posX+difX)>>16)&TWin.xmask;
2762 tC2 = psxVub[((((posY+difY)>>16)&TWin.ymask)<<11)+
2763 YAdjust+(XAdjust>>1)];
2764 tC2=(tC2>>((XAdjust&1)<<2))&0xf;
2766 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
2767 GETLE16(&psxVuw[clutP+tC1])|
2768 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
2775 XAdjust=(posX>>16)&TWin.xmask;
2776 tC1 = psxVub[(((posY>>16)&TWin.ymask)<<11)+
2777 YAdjust+(XAdjust>>1)];
2778 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
2779 GetTextureTransColG(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
2789 ////////////////////////////////////////////////////////////////////////
2793 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)
2795 drawPoly3TEx4(x2,y2,x3,y3,x4,y4,
2796 tx2,ty2,tx3,ty3,tx4,ty4,
2798 drawPoly3TEx4(x1,y1,x2,y2,x4,y4,
2799 tx1,ty1,tx2,ty2,tx4,ty4,
2807 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)
2810 int32_t i,j,xmin,xmax,ymin,ymax;
2811 int32_t difX, difY, difX2, difY2;
2812 int32_t posX,posY,YAdjust,clutP,XAdjust;
2815 if(x1>drawW && x2>drawW && x3>drawW && x4>drawW) return;
2816 if(y1>drawH && y2>drawH && y3>drawH && y4>drawH) return;
2817 if(x1<drawX && x2<drawX && x3<drawX && x4<drawX) return;
2818 if(y1<drawY && y2<drawY && y3<drawY && y4<drawY) return;
2819 if(drawY>=drawH) return;
2820 if(drawX>=drawW) return;
2822 if(!SetupSections_FT4(x1,y1,x2,y2,x3,y3,x4,y4,tx1,ty1,tx2,ty2,tx3,ty3,tx4,ty4)) return;
2826 for(ymin=Ymin;ymin<drawY;ymin++)
2827 if(NextRow_FT4()) return;
2829 clutP=(clY<<10)+clX;
2831 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
2835 if(!bCheckMask && !DrawSemiTrans)
2837 for (i=ymin;i<=ymax;i++)
2839 xmin=(left_x >> 16);
2840 xmax=(right_x >> 16);
2849 difX=(right_u-posX)/num;
2850 difY=(right_v-posY)/num;
2855 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
2856 xmax--;if(drawW<xmax) xmax=drawW;
2858 for(j=xmin;j<xmax;j+=2)
2861 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(XAdjust>>1)];
2862 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
2863 XAdjust=((posX+difX)>>16);
2864 tC2 = psxVub[(((posY+difY)>>5)&(int32_t)0xFFFFF800)+YAdjust+
2866 tC2=(tC2>>((XAdjust&1)<<2))&0xf;
2868 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
2869 GETLE16(&psxVuw[clutP+tC1])|
2870 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
2877 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+
2879 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
2880 GetTextureTransColG_S(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
2884 if(NextRow_FT4()) return;
2891 for (i=ymin;i<=ymax;i++)
2893 xmin=(left_x >> 16);
2894 xmax=(right_x >> 16);
2903 difX=(right_u-posX)/num;
2904 difY=(right_v-posY)/num;
2909 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
2910 xmax--;if(drawW<xmax) xmax=drawW;
2912 for(j=xmin;j<xmax;j+=2)
2915 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(XAdjust>>1)];
2916 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
2917 XAdjust=((posX+difX)>>16);
2918 tC2 = psxVub[(((posY+difY)>>5)&(int32_t)0xFFFFF800)+YAdjust+
2920 tC2=(tC2>>((XAdjust&1)<<2))&0xf;
2922 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
2923 GETLE16(&psxVuw[clutP+tC1])|
2924 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
2931 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+
2933 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
2934 GetTextureTransColG(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
2937 if(NextRow_FT4()) return;
2941 ////////////////////////////////////////////////////////////////////////
2943 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)
2946 int32_t i,j,xmin,xmax,ymin,ymax;
2947 int32_t difX, difY, difX2, difY2;
2948 int32_t posX,posY,YAdjust,clutP,XAdjust;
2951 if(x1>drawW && x2>drawW && x3>drawW && x4>drawW) return;
2952 if(y1>drawH && y2>drawH && y3>drawH && y4>drawH) return;
2953 if(x1<drawX && x2<drawX && x3<drawX && x4<drawX) return;
2954 if(y1<drawY && y2<drawY && y3<drawY && y4<drawY) return;
2955 if(drawY>=drawH) return;
2956 if(drawX>=drawW) return;
2958 if(!SetupSections_FT4(x1,y1,x2,y2,x3,y3,x4,y4,tx1,ty1,tx2,ty2,tx3,ty3,tx4,ty4)) return;
2962 for(ymin=Ymin;ymin<drawY;ymin++)
2963 if(NextRow_FT4()) return;
2965 clutP=(clY<<10)+clX;
2967 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
2968 YAdjust+=(TWin.Position.y0<<11)+(TWin.Position.x0>>1);
2972 if(!bCheckMask && !DrawSemiTrans)
2974 for (i=ymin;i<=ymax;i++)
2976 xmin=(left_x >> 16);
2977 xmax=(right_x >> 16);
2986 difX=(right_u-posX)/num;
2987 difY=(right_v-posY)/num;
2992 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
2993 xmax--;if(drawW<xmax) xmax=drawW;
2995 for(j=xmin;j<xmax;j+=2)
2997 XAdjust=(posX>>16)&TWin.xmask;
2998 tC1 = psxVub[(((posY>>16)&TWin.ymask)<<11)+
2999 YAdjust+(XAdjust>>1)];
3000 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
3001 XAdjust=((posX+difX)>>16)&TWin.xmask;
3002 tC2 = psxVub[((((posY+difY)>>16)&TWin.ymask)<<11)+
3003 YAdjust+(XAdjust>>1)];
3004 tC2=(tC2>>((XAdjust&1)<<2))&0xf;
3006 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
3007 GETLE16(&psxVuw[clutP+tC1])|
3008 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3014 XAdjust=(posX>>16)&TWin.xmask;
3015 tC1 = psxVub[(((posY>>16)&TWin.ymask)<<11)+
3016 YAdjust+(XAdjust>>1)];
3017 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
3018 GetTextureTransColG_S(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3021 if(NextRow_FT4()) return;
3028 for (i=ymin;i<=ymax;i++)
3030 xmin=(left_x >> 16);
3031 xmax=(right_x >> 16);
3040 difX=(right_u-posX)/num;
3041 difY=(right_v-posY)/num;
3046 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3047 xmax--;if(drawW<xmax) xmax=drawW;
3049 for(j=xmin;j<xmax;j+=2)
3051 XAdjust=(posX>>16)&TWin.xmask;
3052 tC1 = psxVub[(((posY>>16)&TWin.ymask)<<11)+
3053 YAdjust+(XAdjust>>1)];
3054 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
3055 XAdjust=((posX+difX)>>16)&TWin.xmask;
3056 tC2 = psxVub[((((posY+difY)>>16)&TWin.ymask)<<11)+
3057 YAdjust+(XAdjust>>1)];
3058 tC2=(tC2>>((XAdjust&1)<<2))&0xf;
3060 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
3061 GETLE16(&psxVuw[clutP+tC1])|
3062 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3068 XAdjust=(posX>>16)&TWin.xmask;
3069 tC1 = psxVub[(((posY>>16)&TWin.ymask)<<11)+
3070 YAdjust+(XAdjust>>1)];
3071 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
3072 GetTextureTransColG(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3075 if(NextRow_FT4()) return;
3079 ////////////////////////////////////////////////////////////////////////
3081 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)
3084 int32_t i,j,xmin,xmax,ymin,ymax;
3085 int32_t difX, difY, difX2, difY2;
3086 int32_t posX,posY,YAdjust,clutP,XAdjust;
3089 if(x1>drawW && x2>drawW && x3>drawW && x4>drawW) return;
3090 if(y1>drawH && y2>drawH && y3>drawH && y4>drawH) return;
3091 if(x1<drawX && x2<drawX && x3<drawX && x4<drawX) return;
3092 if(y1<drawY && y2<drawY && y3<drawY && y4<drawY) return;
3093 if(drawY>=drawH) return;
3094 if(drawX>=drawW) return;
3096 if(!SetupSections_FT4(x1,y1,x2,y2,x3,y3,x4,y4,tx1,ty1,tx2,ty2,tx3,ty3,tx4,ty4)) return;
3100 for(ymin=Ymin;ymin<drawY;ymin++)
3101 if(NextRow_FT4()) return;
3103 clutP=(clY<<10)+clX;
3105 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
3106 YAdjust+=(TWin.Position.y0<<11)+(TWin.Position.x0>>1);
3110 if(!bCheckMask && !DrawSemiTrans)
3112 for (i=ymin;i<=ymax;i++)
3114 xmin=(left_x >> 16);
3115 xmax=(right_x >> 16);
3124 difX=(right_u-posX)/num;
3125 difY=(right_v-posY)/num;
3130 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3131 xmax--;if(drawW<xmax) xmax=drawW;
3133 for(j=xmin;j<xmax;j+=2)
3135 XAdjust=(posX>>16)&TWin.xmask;
3136 tC1 = psxVub[(((posY>>16)&TWin.ymask)<<11)+
3137 YAdjust+(XAdjust>>1)];
3138 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
3139 XAdjust=((posX+difX)>>16)&TWin.xmask;
3140 tC2 = psxVub[((((posY+difY)>>16)&TWin.ymask)<<11)+
3141 YAdjust+(XAdjust>>1)];
3142 tC2=(tC2>>((XAdjust&1)<<2))&0xf;
3144 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
3145 GETLE16(&psxVuw[clutP+tC1])|
3146 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3152 XAdjust=(posX>>16)&TWin.xmask;
3153 tC1 = psxVub[(((posY>>16)&TWin.ymask)<<11)+
3154 YAdjust+(XAdjust>>1)];
3155 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
3156 GetTextureTransColG_S(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3159 if(NextRow_FT4()) return;
3166 for (i=ymin;i<=ymax;i++)
3168 xmin=(left_x >> 16);
3169 xmax=(right_x >> 16);
3178 difX=(right_u-posX)/num;
3179 difY=(right_v-posY)/num;
3184 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3185 xmax--;if(drawW<xmax) xmax=drawW;
3187 for(j=xmin;j<xmax;j+=2)
3189 XAdjust=(posX>>16)&TWin.xmask;
3190 tC1 = psxVub[(((posY>>16)&TWin.ymask)<<11)+
3191 YAdjust+(XAdjust>>1)];
3192 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
3193 XAdjust=((posX+difX)>>16)&TWin.xmask;
3194 tC2 = psxVub[((((posY+difY)>>16)&TWin.ymask)<<11)+
3195 YAdjust+(XAdjust>>1)];
3196 tC2=(tC2>>((XAdjust&1)<<2))&0xf;
3198 GetTextureTransColG32_SPR((uint32_t *)&psxVuw[(i<<10)+j],
3199 GETLE16(&psxVuw[clutP+tC1])|
3200 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3206 XAdjust=(posX>>16)&TWin.xmask;
3207 tC1 = psxVub[(((posY>>16)&TWin.ymask)<<11)+
3208 YAdjust+(XAdjust>>1)];
3209 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
3210 GetTextureTransColG_SPR(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3213 if(NextRow_FT4()) return;
3216 ////////////////////////////////////////////////////////////////////////
3217 // POLY 3 F-SHADED TEX PAL 8
3218 ////////////////////////////////////////////////////////////////////////
3220 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)
3222 int i,j,xmin,xmax,ymin,ymax;
3223 int32_t difX, difY,difX2, difY2;
3224 int32_t posX,posY,YAdjust,clutP;
3227 if(x1>drawW && x2>drawW && x3>drawW) return;
3228 if(y1>drawH && y2>drawH && y3>drawH) return;
3229 if(x1<drawX && x2<drawX && x3<drawX) return;
3230 if(y1<drawY && y2<drawY && y3<drawY) return;
3231 if(drawY>=drawH) return;
3232 if(drawX>=drawW) return;
3234 if(!SetupSections_FT(x1,y1,x2,y2,x3,y3,tx1,ty1,tx2,ty2,tx3,ty3)) return;
3238 for(ymin=Ymin;ymin<drawY;ymin++)
3239 if(NextRow_FT()) return;
3241 clutP=(clY<<10)+clX;
3243 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
3245 difX=delta_right_u;difX2=difX<<1;
3246 difY=delta_right_v;difY2=difY<<1;
3250 if(!bCheckMask && !DrawSemiTrans)
3252 for (i=ymin;i<=ymax;i++)
3254 xmin=(left_x >> 16);
3255 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!
3256 if(drawW<xmax) xmax=drawW;
3264 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3266 for(j=xmin;j<xmax;j+=2)
3268 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(posX>>16)];
3269 tC2 = psxVub[(((posY+difY)>>5)&(int32_t)0xFFFFF800)+YAdjust+
3271 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
3272 GETLE16(&psxVuw[clutP+tC1])|
3273 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3280 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(posX>>16)];
3281 GetTextureTransColG_S(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3294 for (i=ymin;i<=ymax;i++)
3296 xmin=(left_x >> 16);
3297 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!!!
3298 if(drawW<xmax) xmax=drawW;
3306 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3308 for(j=xmin;j<xmax;j+=2)
3310 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(posX>>16)];
3311 tC2 = psxVub[(((posY+difY)>>5)&(int32_t)0xFFFFF800)+YAdjust+
3313 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
3314 GETLE16(&psxVuw[clutP+tC1])|
3315 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3322 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(posX>>16)];
3323 GetTextureTransColG(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3334 ////////////////////////////////////////////////////////////////////////
3336 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)
3338 int i,j,xmin,xmax,ymin,ymax;
3339 int32_t difX, difY,difX2, difY2;
3340 int32_t posX,posY,YAdjust,clutP;
3343 if(x1>drawW && x2>drawW && x3>drawW) return;
3344 if(y1>drawH && y2>drawH && y3>drawH) return;
3345 if(x1<drawX && x2<drawX && x3<drawX) return;
3346 if(y1<drawY && y2<drawY && y3<drawY) return;
3347 if(drawY>=drawH) return;
3348 if(drawX>=drawW) return;
3350 if(!SetupSections_FT(x1,y1,x2,y2,x3,y3,tx1,ty1,tx2,ty2,tx3,ty3)) return;
3354 for(ymin=Ymin;ymin<drawY;ymin++)
3355 if(NextRow_FT()) return;
3357 clutP=(clY<<10)+clX;
3359 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
3360 YAdjust+=(TWin.Position.y0<<11)+(TWin.Position.x0);
3362 difX=delta_right_u;difX2=difX<<1;
3363 difY=delta_right_v;difY2=difY<<1;
3367 if(!bCheckMask && !DrawSemiTrans)
3369 for (i=ymin;i<=ymax;i++)
3371 xmin=(left_x >> 16);
3372 xmax=(right_x >> 16);//-1; //!!!!!!!!!!!!!!!!
3373 if(xmax>xmin) xmax--;
3375 if(drawW<xmax) xmax=drawW;
3383 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3385 for(j=xmin;j<xmax;j+=2)
3387 tC1 = psxVub[(((posY>>16)&TWin.ymask)<<11)+
3388 YAdjust+((posX>>16)&TWin.xmask)];
3389 tC2 = psxVub[((((posY+difY)>>16)&TWin.ymask)<<11)+
3390 YAdjust+(((posX+difX)>>16)&TWin.xmask)];
3391 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
3392 GETLE16(&psxVuw[clutP+tC1])|
3393 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3400 tC1 = psxVub[(((posY>>16)&TWin.ymask)<<11)+
3401 YAdjust+((posX>>16)&TWin.xmask)];
3402 GetTextureTransColG_S(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3415 for (i=ymin;i<=ymax;i++)
3417 xmin=(left_x >> 16);
3418 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!!!
3419 if(drawW<xmax) xmax=drawW;
3427 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3429 for(j=xmin;j<xmax;j+=2)
3431 tC1 = psxVub[(((posY>>16)&TWin.ymask)<<11)+
3432 YAdjust+((posX>>16)&TWin.xmask)];
3433 tC2 = psxVub[((((posY+difY)>>16)&TWin.ymask)<<11)+
3434 YAdjust+(((posX+difX)>>16)&TWin.xmask)];
3435 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
3436 GETLE16(&psxVuw[clutP+tC1])|
3437 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3444 tC1 = psxVub[(((posY>>16)&TWin.ymask)<<11)+
3445 YAdjust+((posX>>16)&TWin.xmask)];
3446 GetTextureTransColG(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3457 ////////////////////////////////////////////////////////////////////////
3461 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)
3463 drawPoly3TEx8(x2,y2,x3,y3,x4,y4,
3464 tx2,ty2,tx3,ty3,tx4,ty4,
3467 drawPoly3TEx8(x1,y1,x2,y2,x4,y4,
3468 tx1,ty1,tx2,ty2,tx4,ty4,
3476 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)
3479 int32_t i,j,xmin,xmax,ymin,ymax;
3480 int32_t difX, difY, difX2, difY2;
3481 int32_t posX,posY,YAdjust,clutP;
3484 if(x1>drawW && x2>drawW && x3>drawW && x4>drawW) return;
3485 if(y1>drawH && y2>drawH && y3>drawH && y4>drawH) return;
3486 if(x1<drawX && x2<drawX && x3<drawX && x4<drawX) return;
3487 if(y1<drawY && y2<drawY && y3<drawY && y4<drawY) return;
3488 if(drawY>=drawH) return;
3489 if(drawX>=drawW) return;
3491 if(!SetupSections_FT4(x1,y1,x2,y2,x3,y3,x4,y4,tx1,ty1,tx2,ty2,tx3,ty3,tx4,ty4)) return;
3495 for(ymin=Ymin;ymin<drawY;ymin++)
3496 if(NextRow_FT4()) return;
3498 clutP=(clY<<10)+clX;
3500 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
3504 if(!bCheckMask && !DrawSemiTrans)
3506 for (i=ymin;i<=ymax;i++)
3508 xmin=(left_x >> 16);
3509 xmax=(right_x >> 16);
3518 difX=(right_u-posX)/num;
3519 difY=(right_v-posY)/num;
3524 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3525 xmax--;if(drawW<xmax) xmax=drawW;
3527 for(j=xmin;j<xmax;j+=2)
3529 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(posX>>16)];
3530 tC2 = psxVub[(((posY+difY)>>5)&(int32_t)0xFFFFF800)+YAdjust+
3532 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
3533 GETLE16(&psxVuw[clutP+tC1])|
3534 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3540 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(posX>>16)];
3541 GetTextureTransColG_S(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3544 if(NextRow_FT4()) return;
3551 for (i=ymin;i<=ymax;i++)
3553 xmin=(left_x >> 16);
3554 xmax=(right_x >> 16);
3563 difX=(right_u-posX)/num;
3564 difY=(right_v-posY)/num;
3569 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3570 xmax--;if(drawW<xmax) xmax=drawW;
3572 for(j=xmin;j<xmax;j+=2)
3574 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(posX>>16)];
3575 tC2 = psxVub[(((posY+difY)>>5)&(int32_t)0xFFFFF800)+YAdjust+
3577 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
3578 GETLE16(&psxVuw[clutP+tC1])|
3579 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3585 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(posX>>16)];
3586 GetTextureTransColG(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3589 if(NextRow_FT4()) return;
3593 ////////////////////////////////////////////////////////////////////////
3595 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)
3598 int32_t i,j,xmin,xmax,ymin,ymax;
3599 int32_t difX, difY, difX2, difY2;
3600 int32_t posX,posY,YAdjust,clutP;
3603 if(x1>drawW && x2>drawW && x3>drawW && x4>drawW) return;
3604 if(y1>drawH && y2>drawH && y3>drawH && y4>drawH) return;
3605 if(x1<drawX && x2<drawX && x3<drawX && x4<drawX) return;
3606 if(y1<drawY && y2<drawY && y3<drawY && y4<drawY) return;
3607 if(drawY>=drawH) return;
3608 if(drawX>=drawW) return;
3610 if(!SetupSections_FT4(x1,y1,x2,y2,x3,y3,x4,y4,tx1,ty1,tx2,ty2,tx3,ty3,tx4,ty4)) return;
3614 for(ymin=Ymin;ymin<drawY;ymin++)
3615 if(NextRow_FT4()) return;
3617 clutP=(clY<<10)+clX;
3619 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
3620 YAdjust+=(TWin.Position.y0<<11)+(TWin.Position.x0);
3624 if(!bCheckMask && !DrawSemiTrans)
3626 for (i=ymin;i<=ymax;i++)
3628 xmin=(left_x >> 16);
3629 xmax=(right_x >> 16);
3638 difX=(right_u-posX)/num;
3639 difY=(right_v-posY)/num;
3644 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3645 xmax--;if(drawW<xmax) xmax=drawW;
3647 for(j=xmin;j<xmax;j+=2)
3649 tC1 = psxVub[(((posY>>16)&TWin.ymask)<<11)+
3650 YAdjust+((posX>>16)&TWin.xmask)];
3651 tC2 = psxVub[((((posY+difY)>>16)&TWin.ymask)<<11)+
3652 YAdjust+(((posX+difX)>>16)&TWin.xmask)];
3653 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
3654 GETLE16(&psxVuw[clutP+tC1])|
3655 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3661 tC1 = psxVub[((((posY+difY)>>16)&TWin.ymask)<<11)+
3662 YAdjust+((posX>>16)&TWin.xmask)];
3663 GetTextureTransColG_S(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3666 if(NextRow_FT4()) return;
3674 for (i=ymin;i<=ymax;i++)
3676 xmin=(left_x >> 16);
3677 xmax=(right_x >> 16);
3686 difX=(right_u-posX)/num;
3687 difY=(right_v-posY)/num;
3692 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3693 xmax--;if(drawW<xmax) xmax=drawW;
3695 for(j=xmin;j<xmax;j+=2)
3697 tC1 = psxVub[(((posY>>16)&TWin.ymask)<<11)+
3698 YAdjust+((posX>>16)&TWin.xmask)];
3699 tC2 = psxVub[((((posY+difY)>>16)&TWin.ymask)<<11)+
3700 YAdjust+(((posX+difX)>>16)&TWin.xmask)];
3701 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
3702 GETLE16(&psxVuw[clutP+tC1])|
3703 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3709 tC1 = psxVub[((((posY+difY)>>16)&TWin.ymask)<<11)+
3710 YAdjust+((posX>>16)&TWin.xmask)];
3711 GetTextureTransColG(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3714 if(NextRow_FT4()) return;
3718 ////////////////////////////////////////////////////////////////////////
3720 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)
3723 int32_t i,j,xmin,xmax,ymin,ymax;
3724 int32_t difX, difY, difX2, difY2;
3725 int32_t posX,posY,YAdjust,clutP;
3728 if(x1>drawW && x2>drawW && x3>drawW && x4>drawW) return;
3729 if(y1>drawH && y2>drawH && y3>drawH && y4>drawH) return;
3730 if(x1<drawX && x2<drawX && x3<drawX && x4<drawX) return;
3731 if(y1<drawY && y2<drawY && y3<drawY && y4<drawY) return;
3732 if(drawY>=drawH) return;
3733 if(drawX>=drawW) return;
3735 if(!SetupSections_FT4(x1,y1,x2,y2,x3,y3,x4,y4,tx1,ty1,tx2,ty2,tx3,ty3,tx4,ty4)) return;
3739 for(ymin=Ymin;ymin<drawY;ymin++)
3740 if(NextRow_FT4()) return;
3742 clutP=(clY<<10)+clX;
3744 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
3745 YAdjust+=(TWin.Position.y0<<11)+(TWin.Position.x0);
3749 if(!bCheckMask && !DrawSemiTrans)
3751 for (i=ymin;i<=ymax;i++)
3753 xmin=(left_x >> 16);
3754 xmax=(right_x >> 16);
3763 difX=(right_u-posX)/num;
3764 difY=(right_v-posY)/num;
3769 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3770 xmax--;if(drawW<xmax) xmax=drawW;
3772 for(j=xmin;j<xmax;j+=2)
3774 tC1 = psxVub[(((posY>>16)&TWin.ymask)<<11)+
3775 YAdjust+((posX>>16)&TWin.xmask)];
3776 tC2 = psxVub[((((posY+difY)>>16)&TWin.ymask)<<11)+
3777 YAdjust+(((posX+difX)>>16)&TWin.xmask)];
3778 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
3779 GETLE16(&psxVuw[clutP+tC1])|
3780 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3786 tC1 = psxVub[((((posY+difY)>>16)&TWin.ymask)<<11)+
3787 YAdjust+((posX>>16)&TWin.xmask)];
3788 GetTextureTransColG_S(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3791 if(NextRow_FT4()) return;
3799 for (i=ymin;i<=ymax;i++)
3801 xmin=(left_x >> 16);
3802 xmax=(right_x >> 16);
3811 difX=(right_u-posX)/num;
3812 difY=(right_v-posY)/num;
3817 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3818 xmax--;if(drawW<xmax) xmax=drawW;
3820 for(j=xmin;j<xmax;j+=2)
3822 tC1 = psxVub[(((posY>>16)&TWin.ymask)<<11)+
3823 YAdjust+((posX>>16)&TWin.xmask)];
3824 tC2 = psxVub[((((posY+difY)>>16)&TWin.ymask)<<11)+
3825 YAdjust+(((posX+difX)>>16)&TWin.xmask)];
3826 GetTextureTransColG32_SPR((uint32_t *)&psxVuw[(i<<10)+j],
3827 GETLE16(&psxVuw[clutP+tC1])|
3828 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3834 tC1 = psxVub[((((posY+difY)>>16)&TWin.ymask)<<11)+
3835 YAdjust+((posX>>16)&TWin.xmask)];
3836 GetTextureTransColG_SPR(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3839 if(NextRow_FT4()) return;
3843 ////////////////////////////////////////////////////////////////////////
3844 // POLY 3 F-SHADED TEX 15 BIT
3845 ////////////////////////////////////////////////////////////////////////
3847 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)
3849 int i,j,xmin,xmax,ymin,ymax;
3850 int32_t difX, difY,difX2, difY2;
3853 if(x1>drawW && x2>drawW && x3>drawW) return;
3854 if(y1>drawH && y2>drawH && y3>drawH) return;
3855 if(x1<drawX && x2<drawX && x3<drawX) return;
3856 if(y1<drawY && y2<drawY && y3<drawY) return;
3857 if(drawY>=drawH) return;
3858 if(drawX>=drawW) return;
3860 if(!SetupSections_FT(x1,y1,x2,y2,x3,y3,tx1,ty1,tx2,ty2,tx3,ty3)) return;
3864 for(ymin=Ymin;ymin<drawY;ymin++)
3865 if(NextRow_FT()) return;
3867 difX=delta_right_u;difX2=difX<<1;
3868 difY=delta_right_v;difY2=difY<<1;
3872 if(!bCheckMask && !DrawSemiTrans)
3874 for (i=ymin;i<=ymax;i++)
3876 xmin=(left_x >> 16);
3877 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!
3878 if(drawW<xmax) xmax=drawW;
3886 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3888 for(j=xmin;j<xmax;j+=2)
3890 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
3891 (((int32_t)GETLE16(&psxVuw[((((posY+difY)>>16)+GlobalTextAddrY)<<10)+((posX+difX)>>16)+GlobalTextAddrX]))<<16)|
3892 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+((posX)>>16)+GlobalTextAddrX]));
3898 GetTextureTransColG_S(&psxVuw[(i<<10)+j],
3899 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+(posX>>16)+GlobalTextAddrX]));
3911 for (i=ymin;i<=ymax;i++)
3913 xmin=(left_x >> 16);
3914 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!
3915 if(drawW<xmax) xmax=drawW;
3923 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3925 for(j=xmin;j<xmax;j+=2)
3927 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
3928 (((int32_t)GETLE16(&psxVuw[((((posY+difY)>>16)+GlobalTextAddrY)<<10)+((posX+difX)>>16)+GlobalTextAddrX]))<<16)|
3929 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+((posX)>>16)+GlobalTextAddrX]));
3935 GetTextureTransColG(&psxVuw[(i<<10)+j],
3936 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+(posX>>16)+GlobalTextAddrX]));
3945 ////////////////////////////////////////////////////////////////////////
3947 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)
3949 int i,j,xmin,xmax,ymin,ymax;
3950 int32_t difX, difY,difX2, difY2;
3953 if(x1>drawW && x2>drawW && x3>drawW) return;
3954 if(y1>drawH && y2>drawH && y3>drawH) return;
3955 if(x1<drawX && x2<drawX && x3<drawX) return;
3956 if(y1<drawY && y2<drawY && y3<drawY) return;
3957 if(drawY>=drawH) return;
3958 if(drawX>=drawW) return;
3960 if(!SetupSections_FT(x1,y1,x2,y2,x3,y3,tx1,ty1,tx2,ty2,tx3,ty3)) return;
3964 for(ymin=Ymin;ymin<drawY;ymin++)
3965 if(NextRow_FT()) return;
3967 difX=delta_right_u;difX2=difX<<1;
3968 difY=delta_right_v;difY2=difY<<1;
3972 if(!bCheckMask && !DrawSemiTrans)
3974 for (i=ymin;i<=ymax;i++)
3976 xmin=(left_x >> 16);
3977 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!
3978 if(drawW<xmax) xmax=drawW;
3986 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3988 for(j=xmin;j<xmax;j+=2)
3990 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
3991 (((int32_t)GETLE16(&psxVuw[(((((posY+difY)>>16)&TWin.ymask)+GlobalTextAddrY+TWin.Position.y0)<<10)+
3992 (((posX+difX)>>16)&TWin.xmask)+GlobalTextAddrX+TWin.Position.x0]))<<16)|
3993 GETLE16(&psxVuw[((((posY>>16)&TWin.ymask)+GlobalTextAddrY+TWin.Position.y0)<<10)+
3994 (((posX)>>16)&TWin.xmask)+GlobalTextAddrX+TWin.Position.x0]));
4000 GetTextureTransColG_S(&psxVuw[(i<<10)+j],
4001 GETLE16(&psxVuw[((((posY>>16)&TWin.ymask)+GlobalTextAddrY+TWin.Position.y0)<<10)+
4002 ((posX>>16)&TWin.xmask)+GlobalTextAddrX+TWin.Position.x0]));
4014 for (i=ymin;i<=ymax;i++)
4016 xmin=(left_x >> 16);
4017 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!
4018 if(drawW<xmax) xmax=drawW;
4026 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
4028 for(j=xmin;j<xmax;j+=2)
4030 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
4031 (((int32_t)GETLE16(&psxVuw[(((((posY+difY)>>16)&TWin.ymask)+GlobalTextAddrY+TWin.Position.y0)<<10)+
4032 (((posX+difX)>>16)&TWin.xmask)+GlobalTextAddrX+TWin.Position.x0]))<<16)|
4033 GETLE16(&psxVuw[((((posY>>16)&TWin.ymask)+GlobalTextAddrY+TWin.Position.y0)<<10)+
4034 (((posX)>>16)&TWin.xmask)+GlobalTextAddrX+TWin.Position.x0]));
4040 GetTextureTransColG(&psxVuw[(i<<10)+j],
4041 GETLE16(&psxVuw[((((posY>>16)&TWin.ymask)+GlobalTextAddrY+TWin.Position.y0)<<10)+
4042 ((posX>>16)&TWin.xmask)+GlobalTextAddrX+TWin.Position.x0]));
4052 ////////////////////////////////////////////////////////////////////////
4056 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)
4058 drawPoly3TD(x2,y2,x3,y3,x4,y4,
4059 tx2,ty2,tx3,ty3,tx4,ty4);
4060 drawPoly3TD(x1,y1,x2,y2,x4,y4,
4061 tx1,ty1,tx2,ty2,tx4,ty4);
4068 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)
4071 int32_t i,j,xmin,xmax,ymin,ymax;
4072 int32_t difX, difY, difX2, difY2;
4075 if(x1>drawW && x2>drawW && x3>drawW && x4>drawW) return;
4076 if(y1>drawH && y2>drawH && y3>drawH && y4>drawH) return;
4077 if(x1<drawX && x2<drawX && x3<drawX && x4<drawX) return;
4078 if(y1<drawY && y2<drawY && y3<drawY && y4<drawY) return;
4079 if(drawY>=drawH) return;
4080 if(drawX>=drawW) return;
4082 if(!SetupSections_FT4(x1,y1,x2,y2,x3,y3,x4,y4,tx1,ty1,tx2,ty2,tx3,ty3,tx4,ty4)) return;
4086 for(ymin=Ymin;ymin<drawY;ymin++)
4087 if(NextRow_FT4()) return;
4091 if(!bCheckMask && !DrawSemiTrans)
4093 for (i=ymin;i<=ymax;i++)
4095 xmin=(left_x >> 16);
4096 xmax=(right_x >> 16);
4105 difX=(right_u-posX)/num;
4106 difY=(right_v-posY)/num;
4111 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
4112 xmax--;if(drawW<xmax) xmax=drawW;
4114 for(j=xmin;j<xmax;j+=2)
4116 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
4117 (((int32_t)GETLE16(&psxVuw[((((posY+difY)>>16)+GlobalTextAddrY)<<10)+((posX+difX)>>16)+GlobalTextAddrX]))<<16)|
4118 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+((posX)>>16)+GlobalTextAddrX]));
4124 GetTextureTransColG_S(&psxVuw[(i<<10)+j],
4125 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+(posX>>16)+GlobalTextAddrX]));
4127 if(NextRow_FT4()) return;
4134 for (i=ymin;i<=ymax;i++)
4136 xmin=(left_x >> 16);
4137 xmax=(right_x >> 16);
4146 difX=(right_u-posX)/num;
4147 difY=(right_v-posY)/num;
4152 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
4153 xmax--;if(drawW<xmax) xmax=drawW;
4155 for(j=xmin;j<xmax;j+=2)
4157 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
4158 (((int32_t)GETLE16(&psxVuw[((((posY+difY)>>16)+GlobalTextAddrY)<<10)+((posX+difX)>>16)+GlobalTextAddrX]))<<16)|
4159 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+((posX)>>16)+GlobalTextAddrX]));
4165 GetTextureTransColG(&psxVuw[(i<<10)+j],
4166 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+(posX>>16)+GlobalTextAddrX]));
4168 if(NextRow_FT4()) return;
4172 ////////////////////////////////////////////////////////////////////////
4174 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)
4177 int32_t i,j,xmin,xmax,ymin,ymax;
4178 int32_t difX, difY, difX2, difY2;
4181 if(x1>drawW && x2>drawW && x3>drawW && x4>drawW) return;
4182 if(y1>drawH && y2>drawH && y3>drawH && y4>drawH) return;
4183 if(x1<drawX && x2<drawX && x3<drawX && x4<drawX) return;
4184 if(y1<drawY && y2<drawY && y3<drawY && y4<drawY) return;
4185 if(drawY>=drawH) return;
4186 if(drawX>=drawW) return;
4188 if(!SetupSections_FT4(x1,y1,x2,y2,x3,y3,x4,y4,tx1,ty1,tx2,ty2,tx3,ty3,tx4,ty4)) return;
4192 for(ymin=Ymin;ymin<drawY;ymin++)
4193 if(NextRow_FT4()) return;
4197 if(!bCheckMask && !DrawSemiTrans)
4199 for (i=ymin;i<=ymax;i++)
4201 xmin=(left_x >> 16);
4202 xmax=(right_x >> 16);
4211 difX=(right_u-posX)/num;
4212 difY=(right_v-posY)/num;
4217 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
4218 xmax--;if(drawW<xmax) xmax=drawW;
4220 for(j=xmin;j<xmax;j+=2)