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 ***************************************************************************/
20 #include "externals.h"
29 ////////////////////////////////////////////////////////////////////////////////////
30 // "NO EDGE BUFFER" POLY VERSION... FUNCS BASED ON FATMAP.TXT FROM MRI / Doomsday
31 ////////////////////////////////////////////////////////////////////////////////////
33 ////////////////////////////////////////////////////////////////////////////////////
35 ////////////////////////////////////////////////////////////////////////////////////
37 // switches for painting textured quads as 2 triangles (small glitches, but better shading!)
38 // can be toggled by game fix 0x200 in version 1.17 anyway, so let the defines enabled!
43 // fast solid loops... a bit more additional code, of course
47 // psx blending mode 3 with 25% incoming color (instead 50% without the define)
49 #define HALFBRIGHTMODE3
51 // color decode defines
53 #define XCOL1(x) (x & 0x1f)
54 #define XCOL2(x) (x & 0x3e0)
55 #define XCOL3(x) (x & 0x7c00)
57 #define XCOL1D(x) (x & 0x1f)
58 #define XCOL2D(x) ((x>>5) & 0x1f)
59 #define XCOL3D(x) ((x>>10) & 0x1f)
61 #define X32TCOL1(x) ((x & 0x001f001f)<<7)
62 #define X32TCOL2(x) ((x & 0x03e003e0)<<2)
63 #define X32TCOL3(x) ((x & 0x7c007c00)>>3)
65 #define X32COL1(x) (x & 0x001f001f)
66 #define X32COL2(x) ((x>>5) & 0x001f001f)
67 #define X32COL3(x) ((x>>10) & 0x001f001f)
69 #define X32ACOL1(x) (x & 0x001e001e)
70 #define X32ACOL2(x) ((x>>5) & 0x001e001e)
71 #define X32ACOL3(x) ((x>>10) & 0x001e001e)
73 #define X32BCOL1(x) (x & 0x001c001c)
74 #define X32BCOL2(x) ((x>>5) & 0x001c001c)
75 #define X32BCOL3(x) ((x>>10) & 0x001c001c)
77 #define X32PSXCOL(r,g,b) ((g<<10)|(b<<5)|r)
79 #define XPSXCOL(r,g,b) ((g&0x7c00)|(b&0x3e0)|(r&0x1f))
81 ////////////////////////////////////////////////////////////////////////////////////
83 ////////////////////////////////////////////////////////////////////////////////////
85 short g_m1=255,g_m2=255,g_m3=255;
86 short DrawSemiTrans=FALSE;
90 short ly0,lx0,ly1,lx1,ly2,lx2,ly3,lx3; // global psx vertex coords
91 int32_t GlobalTextAddrX,GlobalTextAddrY,GlobalTextTP;
92 int32_t GlobalTextREST,GlobalTextABR,GlobalTextPAGE;
94 ////////////////////////////////////////////////////////////////////////
95 // POLYGON OFFSET FUNCS
96 ////////////////////////////////////////////////////////////////////////
98 void offsetPSXLine(void)
100 short x0,x1,y0,y1,dx,dy;float px,py;
102 x0 = lx0+1+PSXDisplay.DrawOffset.x;
103 x1 = lx1+1+PSXDisplay.DrawOffset.x;
104 y0 = ly0+1+PSXDisplay.DrawOffset.y;
105 y1 = ly1+1+PSXDisplay.DrawOffset.y;
110 // tricky line width without sqrt
118 else if(dx<dy) py= 0.5f;
126 else if(dx<dy) px=-0.5f;
137 else if(dx<dy) px= 0.5f;
144 else if(dx<dy) py= 0.5f;
149 lx0=(short)((float)x0-px);
150 lx3=(short)((float)x0+py);
152 ly0=(short)((float)y0-py);
153 ly3=(short)((float)y0-px);
155 lx1=(short)((float)x1-py);
156 lx2=(short)((float)x1+px);
158 ly1=(short)((float)y1+px);
159 ly2=(short)((float)y1+py);
162 void offsetPSX2(void)
164 lx0 += PSXDisplay.DrawOffset.x;
165 ly0 += PSXDisplay.DrawOffset.y;
166 lx1 += PSXDisplay.DrawOffset.x;
167 ly1 += PSXDisplay.DrawOffset.y;
170 void offsetPSX3(void)
172 lx0 += PSXDisplay.DrawOffset.x;
173 ly0 += PSXDisplay.DrawOffset.y;
174 lx1 += PSXDisplay.DrawOffset.x;
175 ly1 += PSXDisplay.DrawOffset.y;
176 lx2 += PSXDisplay.DrawOffset.x;
177 ly2 += PSXDisplay.DrawOffset.y;
180 void offsetPSX4(void)
182 lx0 += PSXDisplay.DrawOffset.x;
183 ly0 += PSXDisplay.DrawOffset.y;
184 lx1 += PSXDisplay.DrawOffset.x;
185 ly1 += PSXDisplay.DrawOffset.y;
186 lx2 += PSXDisplay.DrawOffset.x;
187 ly2 += PSXDisplay.DrawOffset.y;
188 lx3 += PSXDisplay.DrawOffset.x;
189 ly3 += PSXDisplay.DrawOffset.y;
192 /////////////////////////////////////////////////////////////////
193 /////////////////////////////////////////////////////////////////
194 /////////////////////////////////////////////////////////////////
196 ////////////////////////////////////////////////////////////////////////
197 /////////////////////////////////////////////////////////////////
198 /////////////////////////////////////////////////////////////////
201 unsigned char dithertable[16] =
209 void Dither16(unsigned short * pdest,uint32_t r,uint32_t g,uint32_t b,unsigned short sM)
212 unsigned char rlow, glow, blow;
219 coeff = dithertable[(y&3)*4+(x&3)];
221 rlow = r&7; glow = g&7; blow = b&7;
225 if ((r < 0x1F) && rlow > coeff) r++;
226 if ((g < 0x1F) && glow > coeff) g++;
227 if ((b < 0x1F) && blow > coeff) b++;
229 PUTLE16(pdest, ((unsigned short)b<<10) |
230 ((unsigned short)g<<5) |
231 (unsigned short)r | sM);
234 /////////////////////////////////////////////////////////////////
235 /////////////////////////////////////////////////////////////////
236 /////////////////////////////////////////////////////////////////
238 __inline void GetShadeTransCol_Dither(unsigned short * pdest, int32_t m1, int32_t m2, int32_t m3)
242 if(bCheckMask && (*pdest & HOST2LE16(0x8000))) return;
246 r=((XCOL1D(GETLE16(pdest)))<<3);
247 b=((XCOL2D(GETLE16(pdest)))<<3);
248 g=((XCOL3D(GETLE16(pdest)))<<3);
269 if(r&0x80000000) r=0;
270 if(b&0x80000000) b=0;
271 if(g&0x80000000) g=0;
275 #ifdef HALFBRIGHTMODE3
293 if(r&0x7FFFFF00) r=0xff;
294 if(b&0x7FFFFF00) b=0xff;
295 if(g&0x7FFFFF00) g=0xff;
297 Dither16(pdest,r,b,g,sSetMask);
300 ////////////////////////////////////////////////////////////////////////
302 __inline void GetShadeTransCol(unsigned short * pdest,unsigned short color)
304 if(bCheckMask && (*pdest & HOST2LE16(0x8000))) return;
312 PUTLE16(pdest, (((GETLE16(pdest)&0x7bde)>>1)+(((color)&0x7bde)>>1))|sSetMask);//0x8000;
315 r=(XCOL1(*pdest)>>1)+((XCOL1(color))>>1);
316 b=(XCOL2(*pdest)>>1)+((XCOL2(color))>>1);
317 g=(XCOL3(*pdest)>>1)+((XCOL3(color))>>1);
323 r=(XCOL1(GETLE16(pdest)))+((XCOL1(color)));
324 b=(XCOL2(GETLE16(pdest)))+((XCOL2(color)));
325 g=(XCOL3(GETLE16(pdest)))+((XCOL3(color)));
330 r=(XCOL1(GETLE16(pdest)))-((XCOL1(color)));
331 b=(XCOL2(GETLE16(pdest)))-((XCOL2(color)));
332 g=(XCOL3(GETLE16(pdest)))-((XCOL3(color)));
333 if(r&0x80000000) r=0;
334 if(b&0x80000000) b=0;
335 if(g&0x80000000) g=0;
339 #ifdef HALFBRIGHTMODE3
340 r=(XCOL1(GETLE16(pdest)))+((XCOL1(color))>>2);
341 b=(XCOL2(GETLE16(pdest)))+((XCOL2(color))>>2);
342 g=(XCOL3(GETLE16(pdest)))+((XCOL3(color))>>2);
344 r=(XCOL1(GETLE16(pdest)))+((XCOL1(color))>>1);
345 b=(XCOL2(GETLE16(pdest)))+((XCOL2(color))>>1);
346 g=(XCOL3(GETLE16(pdest)))+((XCOL3(color))>>1);
350 if(r&0x7FFFFFE0) r=0x1f;
351 if(b&0x7FFFFC00) b=0x3e0;
352 if(g&0x7FFF8000) g=0x7c00;
354 PUTLE16(pdest, (XPSXCOL(r,g,b))|sSetMask);//0x8000;
356 else PUTLE16(pdest, color|sSetMask);
359 ////////////////////////////////////////////////////////////////////////
361 __inline void GetShadeTransCol32(uint32_t * pdest,uint32_t color)
371 PUTLE32(pdest, (((GETLE32(pdest)&0x7bde7bde)>>1)+(((color)&0x7bde7bde)>>1))|lSetMask);//0x80008000;
374 r=(X32ACOL1(GETLE32(pdest))>>1)+((X32ACOL1(color))>>1);
375 b=(X32ACOL2(GETLE32(pdest))>>1)+((X32ACOL2(color))>>1);
376 g=(X32ACOL3(GETLE32(pdest))>>1)+((X32ACOL3(color))>>1);
381 r=(X32COL1(GETLE32(pdest)))+((X32COL1(color)));
382 b=(X32COL2(GETLE32(pdest)))+((X32COL2(color)));
383 g=(X32COL3(GETLE32(pdest)))+((X32COL3(color)));
388 int32_t sr,sb,sg,src,sbc,sgc,c;
389 src=XCOL1(color);sbc=XCOL2(color);sgc=XCOL3(color);
390 c=GETLE32(pdest)>>16;
391 sr=(XCOL1(c))-src; if(sr&0x8000) sr=0;
392 sb=(XCOL2(c))-sbc; if(sb&0x8000) sb=0;
393 sg=(XCOL3(c))-sgc; if(sg&0x8000) sg=0;
394 r=((int32_t)sr)<<16;b=((int32_t)sb)<<11;g=((int32_t)sg)<<6;
395 c=LOWORD(GETLE32(pdest));
396 sr=(XCOL1(c))-src; if(sr&0x8000) sr=0;
397 sb=(XCOL2(c))-sbc; if(sb&0x8000) sb=0;
398 sg=(XCOL3(c))-sgc; if(sg&0x8000) sg=0;
399 r|=sr;b|=sb>>5;g|=sg>>10;
403 #ifdef HALFBRIGHTMODE3
404 r=(X32COL1(GETLE32(pdest)))+((X32BCOL1(color))>>2);
405 b=(X32COL2(GETLE32(pdest)))+((X32BCOL2(color))>>2);
406 g=(X32COL3(GETLE32(pdest)))+((X32BCOL3(color))>>2);
408 r=(X32COL1(GETLE32(pdest)))+((X32ACOL1(color))>>1);
409 b=(X32COL2(GETLE32(pdest)))+((X32ACOL2(color))>>1);
410 g=(X32COL3(GETLE32(pdest)))+((X32ACOL3(color))>>1);
414 if(r&0x7FE00000) r=0x1f0000|(r&0xFFFF);
415 if(r&0x7FE0) r=0x1f |(r&0xFFFF0000);
416 if(b&0x7FE00000) b=0x1f0000|(b&0xFFFF);
417 if(b&0x7FE0) b=0x1f |(b&0xFFFF0000);
418 if(g&0x7FE00000) g=0x1f0000|(g&0xFFFF);
419 if(g&0x7FE0) g=0x1f |(g&0xFFFF0000);
423 uint32_t ma=GETLE32(pdest);
424 PUTLE32(pdest, (X32PSXCOL(r,g,b))|lSetMask);//0x80008000;
425 if(ma&0x80000000) PUTLE32(pdest, (ma&0xFFFF0000)|(*pdest&0xFFFF));
426 if(ma&0x00008000) PUTLE32(pdest, (ma&0xFFFF) |(*pdest&0xFFFF0000));
429 PUTLE32(pdest, (X32PSXCOL(r,g,b))|lSetMask);//0x80008000;
435 uint32_t ma=GETLE32(pdest);
436 PUTLE32(pdest, color|lSetMask);//0x80008000;
437 if(ma&0x80000000) PUTLE32(pdest, (ma&0xFFFF0000)|(GETLE32(pdest)&0xFFFF));
438 if(ma&0x00008000) PUTLE32(pdest, (ma&0xFFFF) |(GETLE32(pdest)&0xFFFF0000));
442 PUTLE32(pdest, color|lSetMask);//0x80008000;
446 ////////////////////////////////////////////////////////////////////////
448 __inline void GetTextureTransColG(unsigned short * pdest,unsigned short color)
450 int32_t r,g,b;unsigned short l;
454 if(bCheckMask && (*pdest & HOST2LE16(0x8000))) return;
456 l=sSetMask|(color&0x8000);
458 if(DrawSemiTrans && (color&0x8000))
463 d =(GETLE16(pdest)&0x7bde)>>1;
464 color =((color) &0x7bde)>>1;
465 r=(XCOL1(d))+((((XCOL1(color)))* g_m1)>>7);
466 b=(XCOL2(d))+((((XCOL2(color)))* g_m2)>>7);
467 g=(XCOL3(d))+((((XCOL3(color)))* g_m3)>>7);
470 r=(XCOL1(*pdest)>>1)+((((XCOL1(color))>>1)* g_m1)>>7);
471 b=(XCOL2(*pdest)>>1)+((((XCOL2(color))>>1)* g_m2)>>7);
472 g=(XCOL3(*pdest)>>1)+((((XCOL3(color))>>1)* g_m3)>>7);
478 r=(XCOL1(GETLE16(pdest)))+((((XCOL1(color)))* g_m1)>>7);
479 b=(XCOL2(GETLE16(pdest)))+((((XCOL2(color)))* g_m2)>>7);
480 g=(XCOL3(GETLE16(pdest)))+((((XCOL3(color)))* g_m3)>>7);
485 r=(XCOL1(GETLE16(pdest)))-((((XCOL1(color)))* g_m1)>>7);
486 b=(XCOL2(GETLE16(pdest)))-((((XCOL2(color)))* g_m2)>>7);
487 g=(XCOL3(GETLE16(pdest)))-((((XCOL3(color)))* g_m3)>>7);
488 if(r&0x80000000) r=0;
489 if(b&0x80000000) b=0;
490 if(g&0x80000000) g=0;
494 #ifdef HALFBRIGHTMODE3
495 r=(XCOL1(GETLE16(pdest)))+((((XCOL1(color))>>2)* g_m1)>>7);
496 b=(XCOL2(GETLE16(pdest)))+((((XCOL2(color))>>2)* g_m2)>>7);
497 g=(XCOL3(GETLE16(pdest)))+((((XCOL3(color))>>2)* g_m3)>>7);
499 r=(XCOL1(GETLE16(pdest)))+((((XCOL1(color))>>1)* g_m1)>>7);
500 b=(XCOL2(GETLE16(pdest)))+((((XCOL2(color))>>1)* g_m2)>>7);
501 g=(XCOL3(GETLE16(pdest)))+((((XCOL3(color))>>1)* g_m3)>>7);
507 r=((XCOL1(color))* g_m1)>>7;
508 b=((XCOL2(color))* g_m2)>>7;
509 g=((XCOL3(color))* g_m3)>>7;
512 if(r&0x7FFFFFE0) r=0x1f;
513 if(b&0x7FFFFC00) b=0x3e0;
514 if(g&0x7FFF8000) g=0x7c00;
516 PUTLE16(pdest, (XPSXCOL(r,g,b))|l);
519 ////////////////////////////////////////////////////////////////////////
521 __inline void GetTextureTransColG_S(unsigned short * pdest,unsigned short color)
523 int32_t r,g,b;unsigned short l;
527 l=sSetMask|(color&0x8000);
529 r=((XCOL1(color))* g_m1)>>7;
530 b=((XCOL2(color))* g_m2)>>7;
531 g=((XCOL3(color))* g_m3)>>7;
533 if(r&0x7FFFFFE0) r=0x1f;
534 if(b&0x7FFFFC00) b=0x3e0;
535 if(g&0x7FFF8000) g=0x7c00;
537 PUTLE16(pdest, (XPSXCOL(r,g,b))|l);
540 ////////////////////////////////////////////////////////////////////////
542 __inline void GetTextureTransColG_SPR(unsigned short * pdest,unsigned short color)
544 int32_t r,g,b;unsigned short l;
548 if(bCheckMask && (GETLE16(pdest) & 0x8000)) return;
550 l=sSetMask|(color&0x8000);
552 if(DrawSemiTrans && (color&0x8000))
557 d =(GETLE16(pdest)&0x7bde)>>1;
558 color =((color) &0x7bde)>>1;
559 r=(XCOL1(d))+((((XCOL1(color)))* g_m1)>>7);
560 b=(XCOL2(d))+((((XCOL2(color)))* g_m2)>>7);
561 g=(XCOL3(d))+((((XCOL3(color)))* g_m3)>>7);
564 r=(XCOL1(*pdest)>>1)+((((XCOL1(color))>>1)* g_m1)>>7);
565 b=(XCOL2(*pdest)>>1)+((((XCOL2(color))>>1)* g_m2)>>7);
566 g=(XCOL3(*pdest)>>1)+((((XCOL3(color))>>1)* g_m3)>>7);
572 r=(XCOL1(GETLE16(pdest)))+((((XCOL1(color)))* g_m1)>>7);
573 b=(XCOL2(GETLE16(pdest)))+((((XCOL2(color)))* g_m2)>>7);
574 g=(XCOL3(GETLE16(pdest)))+((((XCOL3(color)))* g_m3)>>7);
579 r=(XCOL1(GETLE16(pdest)))-((((XCOL1(color)))* g_m1)>>7);
580 b=(XCOL2(GETLE16(pdest)))-((((XCOL2(color)))* g_m2)>>7);
581 g=(XCOL3(GETLE16(pdest)))-((((XCOL3(color)))* g_m3)>>7);
582 if(r&0x80000000) r=0;
583 if(b&0x80000000) b=0;
584 if(g&0x80000000) g=0;
588 #ifdef HALFBRIGHTMODE3
589 r=(XCOL1(GETLE16(pdest)))+((((XCOL1(color))>>2)* g_m1)>>7);
590 b=(XCOL2(GETLE16(pdest)))+((((XCOL2(color))>>2)* g_m2)>>7);
591 g=(XCOL3(GETLE16(pdest)))+((((XCOL3(color))>>2)* g_m3)>>7);
593 r=(XCOL1(GETLE16(pdest)))+((((XCOL1(color))>>1)* g_m1)>>7);
594 b=(XCOL2(GETLE16(pdest)))+((((XCOL2(color))>>1)* g_m2)>>7);
595 g=(XCOL3(GETLE16(pdest)))+((((XCOL3(color))>>1)* g_m3)>>7);
601 r=((XCOL1(color))* g_m1)>>7;
602 b=((XCOL2(color))* g_m2)>>7;
603 g=((XCOL3(color))* g_m3)>>7;
606 if(r&0x7FFFFFE0) r=0x1f;
607 if(b&0x7FFFFC00) b=0x3e0;
608 if(g&0x7FFF8000) g=0x7c00;
610 PUTLE16(pdest, (XPSXCOL(r,g,b))|l);
613 ////////////////////////////////////////////////////////////////////////
615 __inline void GetTextureTransColG32(uint32_t * pdest,uint32_t color)
621 l=lSetMask|(color&0x80008000);
623 if(DrawSemiTrans && (color&0x80008000))
627 r=((((X32TCOL1(GETLE32(pdest)))+((X32COL1(color)) * g_m1))&0xFF00FF00)>>8);
628 b=((((X32TCOL2(GETLE32(pdest)))+((X32COL2(color)) * g_m2))&0xFF00FF00)>>8);
629 g=((((X32TCOL3(GETLE32(pdest)))+((X32COL3(color)) * g_m3))&0xFF00FF00)>>8);
634 r=(X32COL1(GETLE32(pdest)))+(((((X32COL1(color)))* g_m1)&0xFF80FF80)>>7);
635 b=(X32COL2(GETLE32(pdest)))+(((((X32COL2(color)))* g_m2)&0xFF80FF80)>>7);
636 g=(X32COL3(GETLE32(pdest)))+(((((X32COL3(color)))* g_m3)&0xFF80FF80)>>7);
642 r=(((((X32COL1(color)))* g_m1)&0xFF80FF80)>>7);
643 t=(GETLE32(pdest)&0x001f0000)-(r&0x003f0000); if(t&0x80000000) t=0;
644 r=(GETLE32(pdest)&0x0000001f)-(r&0x0000003f); if(r&0x80000000) r=0;
647 b=(((((X32COL2(color)))* g_m2)&0xFF80FF80)>>7);
648 t=((GETLE32(pdest)>>5)&0x001f0000)-(b&0x003f0000); if(t&0x80000000) t=0;
649 b=((GETLE32(pdest)>>5)&0x0000001f)-(b&0x0000003f); if(b&0x80000000) b=0;
652 g=(((((X32COL3(color)))* g_m3)&0xFF80FF80)>>7);
653 t=((GETLE32(pdest)>>10)&0x001f0000)-(g&0x003f0000); if(t&0x80000000) t=0;
654 g=((GETLE32(pdest)>>10)&0x0000001f)-(g&0x0000003f); if(g&0x80000000) g=0;
659 #ifdef HALFBRIGHTMODE3
660 r=(X32COL1(GETLE32(pdest)))+(((((X32BCOL1(color))>>2)* g_m1)&0xFF80FF80)>>7);
661 b=(X32COL2(GETLE32(pdest)))+(((((X32BCOL2(color))>>2)* g_m2)&0xFF80FF80)>>7);
662 g=(X32COL3(GETLE32(pdest)))+(((((X32BCOL3(color))>>2)* g_m3)&0xFF80FF80)>>7);
664 r=(X32COL1(GETLE32(pdest)))+(((((X32ACOL1(color))>>1)* g_m1)&0xFF80FF80)>>7);
665 b=(X32COL2(GETLE32(pdest)))+(((((X32ACOL2(color))>>1)* g_m2)&0xFF80FF80)>>7);
666 g=(X32COL3(GETLE32(pdest)))+(((((X32ACOL3(color))>>1)* g_m3)&0xFF80FF80)>>7);
672 r=(r&0xffff0000)|((((X32COL1(color))* g_m1)&0x0000FF80)>>7);
673 b=(b&0xffff0000)|((((X32COL2(color))* g_m2)&0x0000FF80)>>7);
674 g=(g&0xffff0000)|((((X32COL3(color))* g_m3)&0x0000FF80)>>7);
676 if(!(color&0x80000000))
678 r=(r&0xffff)|((((X32COL1(color))* g_m1)&0xFF800000)>>7);
679 b=(b&0xffff)|((((X32COL2(color))* g_m2)&0xFF800000)>>7);
680 g=(g&0xffff)|((((X32COL3(color))* g_m3)&0xFF800000)>>7);
686 r=(((X32COL1(color))* g_m1)&0xFF80FF80)>>7;
687 b=(((X32COL2(color))* g_m2)&0xFF80FF80)>>7;
688 g=(((X32COL3(color))* g_m3)&0xFF80FF80)>>7;
691 if(r&0x7FE00000) r=0x1f0000|(r&0xFFFF);
692 if(r&0x7FE0) r=0x1f |(r&0xFFFF0000);
693 if(b&0x7FE00000) b=0x1f0000|(b&0xFFFF);
694 if(b&0x7FE0) b=0x1f |(b&0xFFFF0000);
695 if(g&0x7FE00000) g=0x1f0000|(g&0xFFFF);
696 if(g&0x7FE0) g=0x1f |(g&0xFFFF0000);
700 uint32_t ma=GETLE32(pdest);
702 PUTLE32(pdest, (X32PSXCOL(r,g,b))|l);
704 if((color&0xffff)==0 ) PUTLE32(pdest, (ma&0xffff)|(GETLE32(pdest)&0xffff0000));
705 if((color&0xffff0000)==0) PUTLE32(pdest, (ma&0xffff0000)|(GETLE32(pdest)&0xffff));
706 if(ma&0x80000000) PUTLE32(pdest, (ma&0xFFFF0000)|(GETLE32(pdest)&0xFFFF));
707 if(ma&0x00008000) PUTLE32(pdest, (ma&0xFFFF) |(GETLE32(pdest)&0xFFFF0000));
711 if((color&0xffff)==0 ) {PUTLE32(pdest, (GETLE32(pdest)&0xffff)|(((X32PSXCOL(r,g,b))|l)&0xffff0000));return;}
712 if((color&0xffff0000)==0) {PUTLE32(pdest, (GETLE32(pdest)&0xffff0000)|(((X32PSXCOL(r,g,b))|l)&0xffff));return;}
714 PUTLE32(pdest, (X32PSXCOL(r,g,b))|l);
717 ////////////////////////////////////////////////////////////////////////
719 __inline void GetTextureTransColG32_S(uint32_t * pdest,uint32_t color)
725 r=(((X32COL1(color))* g_m1)&0xFF80FF80)>>7;
726 b=(((X32COL2(color))* g_m2)&0xFF80FF80)>>7;
727 g=(((X32COL3(color))* g_m3)&0xFF80FF80)>>7;
729 if(r&0x7FE00000) r=0x1f0000|(r&0xFFFF);
730 if(r&0x7FE0) r=0x1f |(r&0xFFFF0000);
731 if(b&0x7FE00000) b=0x1f0000|(b&0xFFFF);
732 if(b&0x7FE0) b=0x1f |(b&0xFFFF0000);
733 if(g&0x7FE00000) g=0x1f0000|(g&0xFFFF);
734 if(g&0x7FE0) g=0x1f |(g&0xFFFF0000);
736 if((color&0xffff)==0) {PUTLE32(pdest, (GETLE32(pdest)&0xffff)|(((X32PSXCOL(r,g,b))|lSetMask|(color&0x80008000))&0xffff0000));return;}
737 if((color&0xffff0000)==0) {PUTLE32(pdest, (GETLE32(pdest)&0xffff0000)|(((X32PSXCOL(r,g,b))|lSetMask|(color&0x80008000))&0xffff));return;}
739 PUTLE32(pdest, (X32PSXCOL(r,g,b))|lSetMask|(color&0x80008000));
742 ////////////////////////////////////////////////////////////////////////
744 __inline void GetTextureTransColG32_SPR(uint32_t * pdest,uint32_t color)
750 if(DrawSemiTrans && (color&0x80008000))
754 r=((((X32TCOL1(GETLE32(pdest)))+((X32COL1(color)) * g_m1))&0xFF00FF00)>>8);
755 b=((((X32TCOL2(GETLE32(pdest)))+((X32COL2(color)) * g_m2))&0xFF00FF00)>>8);
756 g=((((X32TCOL3(GETLE32(pdest)))+((X32COL3(color)) * g_m3))&0xFF00FF00)>>8);
761 r=(X32COL1(GETLE32(pdest)))+(((((X32COL1(color)))* g_m1)&0xFF80FF80)>>7);
762 b=(X32COL2(GETLE32(pdest)))+(((((X32COL2(color)))* g_m2)&0xFF80FF80)>>7);
763 g=(X32COL3(GETLE32(pdest)))+(((((X32COL3(color)))* g_m3)&0xFF80FF80)>>7);
769 r=(((((X32COL1(color)))* g_m1)&0xFF80FF80)>>7);
770 t=(GETLE32(pdest)&0x001f0000)-(r&0x003f0000); if(t&0x80000000) t=0;
771 r=(GETLE32(pdest)&0x0000001f)-(r&0x0000003f); if(r&0x80000000) r=0;
774 b=(((((X32COL2(color)))* g_m2)&0xFF80FF80)>>7);
775 t=((GETLE32(pdest)>>5)&0x001f0000)-(b&0x003f0000); if(t&0x80000000) t=0;
776 b=((GETLE32(pdest)>>5)&0x0000001f)-(b&0x0000003f); if(b&0x80000000) b=0;
779 g=(((((X32COL3(color)))* g_m3)&0xFF80FF80)>>7);
780 t=((GETLE32(pdest)>>10)&0x001f0000)-(g&0x003f0000); if(t&0x80000000) t=0;
781 g=((GETLE32(pdest)>>10)&0x0000001f)-(g&0x0000003f); if(g&0x80000000) g=0;
786 #ifdef HALFBRIGHTMODE3
787 r=(X32COL1(GETLE32(pdest)))+(((((X32BCOL1(color))>>2)* g_m1)&0xFF80FF80)>>7);
788 b=(X32COL2(GETLE32(pdest)))+(((((X32BCOL2(color))>>2)* g_m2)&0xFF80FF80)>>7);
789 g=(X32COL3(GETLE32(pdest)))+(((((X32BCOL3(color))>>2)* g_m3)&0xFF80FF80)>>7);
791 r=(X32COL1(GETLE32(pdest)))+(((((X32ACOL1(color))>>1)* g_m1)&0xFF80FF80)>>7);
792 b=(X32COL2(GETLE32(pdest)))+(((((X32ACOL2(color))>>1)* g_m2)&0xFF80FF80)>>7);
793 g=(X32COL3(GETLE32(pdest)))+(((((X32ACOL3(color))>>1)* g_m3)&0xFF80FF80)>>7);
799 r=(r&0xffff0000)|((((X32COL1(color))* g_m1)&0x0000FF80)>>7);
800 b=(b&0xffff0000)|((((X32COL2(color))* g_m2)&0x0000FF80)>>7);
801 g=(g&0xffff0000)|((((X32COL3(color))* g_m3)&0x0000FF80)>>7);
803 if(!(color&0x80000000))
805 r=(r&0xffff)|((((X32COL1(color))* g_m1)&0xFF800000)>>7);
806 b=(b&0xffff)|((((X32COL2(color))* g_m2)&0xFF800000)>>7);
807 g=(g&0xffff)|((((X32COL3(color))* g_m3)&0xFF800000)>>7);
813 r=(((X32COL1(color))* g_m1)&0xFF80FF80)>>7;
814 b=(((X32COL2(color))* g_m2)&0xFF80FF80)>>7;
815 g=(((X32COL3(color))* g_m3)&0xFF80FF80)>>7;
818 if(r&0x7FE00000) r=0x1f0000|(r&0xFFFF);
819 if(r&0x7FE0) r=0x1f |(r&0xFFFF0000);
820 if(b&0x7FE00000) b=0x1f0000|(b&0xFFFF);
821 if(b&0x7FE0) b=0x1f |(b&0xFFFF0000);
822 if(g&0x7FE00000) g=0x1f0000|(g&0xFFFF);
823 if(g&0x7FE0) g=0x1f |(g&0xFFFF0000);
827 uint32_t ma=GETLE32(pdest);
829 PUTLE32(pdest, (X32PSXCOL(r,g,b))|lSetMask|(color&0x80008000));
831 if((color&0xffff)==0 ) PUTLE32(pdest, (ma&0xffff)|(GETLE32(pdest)&0xffff0000));
832 if((color&0xffff0000)==0) PUTLE32(pdest, (ma&0xffff0000)|(GETLE32(pdest)&0xffff));
833 if(ma&0x80000000) PUTLE32(pdest, (ma&0xFFFF0000)|(GETLE32(pdest)&0xFFFF));
834 if(ma&0x00008000) PUTLE32(pdest, (ma&0xFFFF) |(GETLE32(pdest)&0xFFFF0000));
838 if((color&0xffff)==0 ) {PUTLE32(pdest, (GETLE32(pdest)&0xffff)|(((X32PSXCOL(r,g,b))|lSetMask|(color&0x80008000))&0xffff0000));return;}
839 if((color&0xffff0000)==0) {PUTLE32(pdest, (GETLE32(pdest)&0xffff0000)|(((X32PSXCOL(r,g,b))|lSetMask|(color&0x80008000))&0xffff));return;}
841 PUTLE32(pdest, (X32PSXCOL(r,g,b))|lSetMask|(color&0x80008000));
844 ////////////////////////////////////////////////////////////////////////
846 __inline void GetTextureTransColGX_Dither(unsigned short * pdest,unsigned short color,int32_t m1,int32_t m2,int32_t m3)
852 if(bCheckMask && (*pdest & HOST2LE16(0x8000))) return;
854 m1=(((XCOL1D(color)))*m1)>>4;
855 m2=(((XCOL2D(color)))*m2)>>4;
856 m3=(((XCOL3D(color)))*m3)>>4;
858 if(DrawSemiTrans && (color&0x8000))
860 r=((XCOL1D(GETLE16(pdest)))<<3);
861 b=((XCOL2D(GETLE16(pdest)))<<3);
862 g=((XCOL3D(GETLE16(pdest)))<<3);
883 if(r&0x80000000) r=0;
884 if(b&0x80000000) b=0;
885 if(g&0x80000000) g=0;
889 #ifdef HALFBRIGHTMODE3
907 if(r&0x7FFFFF00) r=0xff;
908 if(b&0x7FFFFF00) b=0xff;
909 if(g&0x7FFFFF00) g=0xff;
911 Dither16(pdest,r,b,g,sSetMask|(color&0x8000));
915 ////////////////////////////////////////////////////////////////////////
917 __inline void GetTextureTransColGX(unsigned short * pdest,unsigned short color,short m1,short m2,short m3)
919 int32_t r,g,b;unsigned short l;
923 if(bCheckMask && (*pdest & HOST2LE16(0x8000))) return;
925 l=sSetMask|(color&0x8000);
927 if(DrawSemiTrans && (color&0x8000))
932 d =(GETLE16(pdest)&0x7bde)>>1;
933 color =((color) &0x7bde)>>1;
934 r=(XCOL1(d))+((((XCOL1(color)))* m1)>>7);
935 b=(XCOL2(d))+((((XCOL2(color)))* m2)>>7);
936 g=(XCOL3(d))+((((XCOL3(color)))* m3)>>7);
938 r=(XCOL1(*pdest)>>1)+((((XCOL1(color))>>1)* m1)>>7);
939 b=(XCOL2(*pdest)>>1)+((((XCOL2(color))>>1)* m2)>>7);
940 g=(XCOL3(*pdest)>>1)+((((XCOL3(color))>>1)* m3)>>7);
946 r=(XCOL1(GETLE16(pdest)))+((((XCOL1(color)))* m1)>>7);
947 b=(XCOL2(GETLE16(pdest)))+((((XCOL2(color)))* m2)>>7);
948 g=(XCOL3(GETLE16(pdest)))+((((XCOL3(color)))* m3)>>7);
953 r=(XCOL1(GETLE16(pdest)))-((((XCOL1(color)))* m1)>>7);
954 b=(XCOL2(GETLE16(pdest)))-((((XCOL2(color)))* m2)>>7);
955 g=(XCOL3(GETLE16(pdest)))-((((XCOL3(color)))* m3)>>7);
956 if(r&0x80000000) r=0;
957 if(b&0x80000000) b=0;
958 if(g&0x80000000) g=0;
962 #ifdef HALFBRIGHTMODE3
963 r=(XCOL1(GETLE16(pdest)))+((((XCOL1(color))>>2)* m1)>>7);
964 b=(XCOL2(GETLE16(pdest)))+((((XCOL2(color))>>2)* m2)>>7);
965 g=(XCOL3(GETLE16(pdest)))+((((XCOL3(color))>>2)* m3)>>7);
967 r=(XCOL1(GETLE16(pdest)))+((((XCOL1(color))>>1)* m1)>>7);
968 b=(XCOL2(GETLE16(pdest)))+((((XCOL2(color))>>1)* m2)>>7);
969 g=(XCOL3(GETLE16(pdest)))+((((XCOL3(color))>>1)* m3)>>7);
975 r=((XCOL1(color))* m1)>>7;
976 b=((XCOL2(color))* m2)>>7;
977 g=((XCOL3(color))* m3)>>7;
980 if(r&0x7FFFFFE0) r=0x1f;
981 if(b&0x7FFFFC00) b=0x3e0;
982 if(g&0x7FFF8000) g=0x7c00;
984 PUTLE16(pdest, (XPSXCOL(r,g,b))|l);
987 ////////////////////////////////////////////////////////////////////////
989 __inline void GetTextureTransColGX_S(unsigned short * pdest,unsigned short color,short m1,short m2,short m3)
995 r=((XCOL1(color))* m1)>>7;
996 b=((XCOL2(color))* m2)>>7;
997 g=((XCOL3(color))* m3)>>7;
999 if(r&0x7FFFFFE0) r=0x1f;
1000 if(b&0x7FFFFC00) b=0x3e0;
1001 if(g&0x7FFF8000) g=0x7c00;
1003 PUTLE16(pdest, (XPSXCOL(r,g,b))|sSetMask|(color&0x8000));
1006 ////////////////////////////////////////////////////////////////////////
1008 __inline void GetTextureTransColGX32_S(uint32_t * pdest,uint32_t color,short m1,short m2,short m3)
1012 if(color==0) return;
1014 r=(((X32COL1(color))* m1)&0xFF80FF80)>>7;
1015 b=(((X32COL2(color))* m2)&0xFF80FF80)>>7;
1016 g=(((X32COL3(color))* m3)&0xFF80FF80)>>7;
1018 if(r&0x7FE00000) r=0x1f0000|(r&0xFFFF);
1019 if(r&0x7FE0) r=0x1f |(r&0xFFFF0000);
1020 if(b&0x7FE00000) b=0x1f0000|(b&0xFFFF);
1021 if(b&0x7FE0) b=0x1f |(b&0xFFFF0000);
1022 if(g&0x7FE00000) g=0x1f0000|(g&0xFFFF);
1023 if(g&0x7FE0) g=0x1f |(g&0xFFFF0000);
1025 if((color&0xffff)==0) {PUTLE32(pdest, (GETLE32(pdest)&0xffff)|(((X32PSXCOL(r,g,b))|lSetMask|(color&0x80008000))&0xffff0000));return;}
1026 if((color&0xffff0000)==0) {PUTLE32(pdest, (GETLE32(pdest)&0xffff0000)|(((X32PSXCOL(r,g,b))|lSetMask|(color&0x80008000))&0xffff));return;}
1028 PUTLE32(pdest, (X32PSXCOL(r,g,b))|lSetMask|(color&0x80008000));
1031 ////////////////////////////////////////////////////////////////////////
1033 ////////////////////////////////////////////////////////////////////////
1035 void FillSoftwareAreaTrans(short x0,short y0,short x1, // FILL AREA TRANS
1036 short y1,unsigned short col)
1043 if(x1<drawX) return;
1044 if(y1<drawY) return;
1045 if(x0>drawW) return;
1046 if(y0>drawH) return;
1053 if(y0>=iGPUHeight) return;
1056 if(y1>iGPUHeight) y1=iGPUHeight;
1057 if(x1>1024) x1=1024;
1061 if(dx==1 && dy==1 && x0==1020 && y0==511) // special fix for pinball game... emu protection???
1065 writedatamem 0x00000000 1
1066 tile1 newcol 7fff (orgcol 0xffffff), oldvram 0
1068 readdatamem 0x00007fff 1
1070 writedatamem 0x00000000 1
1071 tile1 newcol 8000 (orgcol 0xffffff), oldvram 0
1073 readdatamem 0x00008000 1
1076 static int iCheat=0;
1078 if(iCheat==1) iCheat=0; else iCheat=1;
1082 if(dx&1) // slow fill
1084 unsigned short *DSTPtr;
1085 unsigned short LineOffset;
1086 DSTPtr = psxVuw + (1024*y0) + x0;
1087 LineOffset = 1024 - dx;
1091 GetShadeTransCol(DSTPtr++,col);
1092 DSTPtr += LineOffset;
1098 unsigned short LineOffset;
1099 uint32_t lcol=lSetMask|(((uint32_t)(col))<<16)|col;
1101 DSTPtr = (uint32_t *)(psxVuw + (1024*y0) + x0);
1102 LineOffset = 512 - dx;
1104 if(!bCheckMask && !DrawSemiTrans)
1108 for(j=0;j<dx;j++) { PUTLE32(DSTPtr, lcol); DSTPtr++; }
1109 DSTPtr += LineOffset;
1117 GetShadeTransCol32(DSTPtr++,lcol);
1118 DSTPtr += LineOffset;
1124 ////////////////////////////////////////////////////////////////////////
1126 void FillSoftwareArea(short x0,short y0,short x1, // FILL AREA (BLK FILL)
1127 short y1,unsigned short col) // no draw area check here!
1134 if(y0>=iGPUHeight) return;
1137 if(y1>iGPUHeight) y1=iGPUHeight;
1138 if(x1>1024) x1=1024;
1143 unsigned short *DSTPtr;
1144 unsigned short LineOffset;
1146 DSTPtr = psxVuw + (1024*y0) + x0;
1147 LineOffset = 1024 - dx;
1151 for(j=0;j<dx;j++) { PUTLE16(DSTPtr, col); DSTPtr++; }
1152 DSTPtr += LineOffset;
1158 unsigned short LineOffset;
1159 uint32_t lcol=(((int32_t)col)<<16)|col;
1161 DSTPtr = (uint32_t *)(psxVuw + (1024*y0) + x0);
1162 LineOffset = 512 - dx;
1166 for(j=0;j<dx;j++) { PUTLE32(DSTPtr, lcol); DSTPtr++; }
1167 DSTPtr += LineOffset;
1172 ////////////////////////////////////////////////////////////////////////
1173 ////////////////////////////////////////////////////////////////////////
1174 ////////////////////////////////////////////////////////////////////////
1175 // EDGE INTERPOLATION
1176 ////////////////////////////////////////////////////////////////////////
1177 ////////////////////////////////////////////////////////////////////////
1178 ////////////////////////////////////////////////////////////////////////
1180 typedef struct SOFTVTAG
1187 static soft_vertex vtx[4];
1188 static soft_vertex * left_array[4], * right_array[4];
1189 static int left_section, right_section;
1190 static int left_section_height, right_section_height;
1191 static int left_x, delta_left_x, right_x, delta_right_x;
1192 static int left_u, delta_left_u, left_v, delta_left_v;
1193 static int right_u, delta_right_u, right_v, delta_right_v;
1194 static int left_R, delta_left_R, right_R, delta_right_R;
1195 static int left_G, delta_left_G, right_G, delta_right_G;
1196 static int left_B, delta_left_B, right_B, delta_right_B;
1200 // NASM version (external):
1201 #define shl10idiv i386_shl10idiv
1203 __inline int shl10idiv(int x, int y);
1207 __inline int shl10idiv(int x, int y)
1218 // GNUC long long int version:
1220 __inline int shl10idiv(int x, int y)
1229 ////////////////////////////////////////////////////////////////////////
1230 ////////////////////////////////////////////////////////////////////////
1231 ////////////////////////////////////////////////////////////////////////
1233 __inline int RightSection_F(void)
1235 soft_vertex * v1 = right_array[ right_section ];
1236 soft_vertex * v2 = right_array[ right_section-1 ];
1238 int height = v2->y - v1->y;
1239 if(height == 0) return 0;
1240 delta_right_x = (v2->x - v1->x) / height;
1243 right_section_height = height;
1247 ////////////////////////////////////////////////////////////////////////
1249 __inline int LeftSection_F(void)
1251 soft_vertex * v1 = left_array[ left_section ];
1252 soft_vertex * v2 = left_array[ left_section-1 ];
1254 int height = v2->y - v1->y;
1255 if(height == 0) return 0;
1256 delta_left_x = (v2->x - v1->x) / height;
1259 left_section_height = height;
1263 ////////////////////////////////////////////////////////////////////////
1265 __inline BOOL NextRow_F(void)
1267 if(--left_section_height<=0)
1269 if(--left_section <= 0) {return TRUE;}
1270 if(LeftSection_F() <= 0) {return TRUE;}
1274 left_x += delta_left_x;
1277 if(--right_section_height<=0)
1279 if(--right_section<=0) {return TRUE;}
1280 if(RightSection_F() <=0) {return TRUE;}
1284 right_x += delta_right_x;
1289 ////////////////////////////////////////////////////////////////////////
1291 __inline BOOL SetupSections_F(short x1, short y1, short x2, short y2, short x3, short y3)
1293 soft_vertex * v1, * v2, * v3;
1296 v1 = vtx; v1->x=x1<<16;v1->y=y1;
1297 v2 = vtx+1; v2->x=x2<<16;v2->y=y2;
1298 v3 = vtx+2; v3->x=x3<<16;v3->y=y3;
1300 if(v1->y > v2->y) { soft_vertex * v = v1; v1 = v2; v2 = v; }
1301 if(v1->y > v3->y) { soft_vertex * v = v1; v1 = v3; v3 = v; }
1302 if(v2->y > v3->y) { soft_vertex * v = v2; v2 = v3; v3 = v; }
1304 height = v3->y - v1->y;
1305 if(height == 0) {return FALSE;}
1306 longest = (((v2->y - v1->y) << 16) / height) * ((v3->x - v1->x)>>16) + (v1->x - v2->x);
1307 if(longest == 0) {return FALSE;}
1311 right_array[0] = v3;
1312 right_array[1] = v2;
1313 right_array[2] = v1;
1319 if(LeftSection_F() <= 0) return FALSE;
1320 if(RightSection_F() <= 0)
1323 if(RightSection_F() <= 0) return FALSE;
1332 right_array[0] = v3;
1333 right_array[1] = v1;
1336 if(RightSection_F() <= 0) return FALSE;
1337 if(LeftSection_F() <= 0)
1340 if(LeftSection_F() <= 0) return FALSE;
1345 Ymax=min(v3->y-1,drawH);
1350 ////////////////////////////////////////////////////////////////////////
1351 ////////////////////////////////////////////////////////////////////////
1353 __inline int RightSection_G(void)
1355 soft_vertex * v1 = right_array[ right_section ];
1356 soft_vertex * v2 = right_array[ right_section-1 ];
1358 int height = v2->y - v1->y;
1359 if(height == 0) return 0;
1360 delta_right_x = (v2->x - v1->x) / height;
1363 right_section_height = height;
1367 ////////////////////////////////////////////////////////////////////////
1369 __inline int LeftSection_G(void)
1371 soft_vertex * v1 = left_array[ left_section ];
1372 soft_vertex * v2 = left_array[ left_section-1 ];
1374 int height = v2->y - v1->y;
1375 if(height == 0) return 0;
1376 delta_left_x = (v2->x - v1->x) / height;
1379 delta_left_R = ((v2->R - v1->R)) / height;
1381 delta_left_G = ((v2->G - v1->G)) / height;
1383 delta_left_B = ((v2->B - v1->B)) / height;
1386 left_section_height = height;
1390 ////////////////////////////////////////////////////////////////////////
1392 __inline BOOL NextRow_G(void)
1394 if(--left_section_height<=0)
1396 if(--left_section <= 0) {return TRUE;}
1397 if(LeftSection_G() <= 0) {return TRUE;}
1401 left_x += delta_left_x;
1402 left_R += delta_left_R;
1403 left_G += delta_left_G;
1404 left_B += delta_left_B;
1407 if(--right_section_height<=0)
1409 if(--right_section<=0) {return TRUE;}
1410 if(RightSection_G() <=0) {return TRUE;}
1414 right_x += delta_right_x;
1419 ////////////////////////////////////////////////////////////////////////
1421 __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)
1423 soft_vertex * v1, * v2, * v3;
1424 int height,longest,temp;
1426 v1 = vtx; v1->x=x1<<16;v1->y=y1;
1427 v1->R=(rgb1) & 0x00ff0000;
1428 v1->G=(rgb1<<8) & 0x00ff0000;
1429 v1->B=(rgb1<<16) & 0x00ff0000;
1430 v2 = vtx+1; v2->x=x2<<16;v2->y=y2;
1431 v2->R=(rgb2) & 0x00ff0000;
1432 v2->G=(rgb2<<8) & 0x00ff0000;
1433 v2->B=(rgb2<<16) & 0x00ff0000;
1434 v3 = vtx+2; v3->x=x3<<16;v3->y=y3;
1435 v3->R=(rgb3) & 0x00ff0000;
1436 v3->G=(rgb3<<8) & 0x00ff0000;
1437 v3->B=(rgb3<<16) & 0x00ff0000;
1439 if(v1->y > v2->y) { soft_vertex * v = v1; v1 = v2; v2 = v; }
1440 if(v1->y > v3->y) { soft_vertex * v = v1; v1 = v3; v3 = v; }
1441 if(v2->y > v3->y) { soft_vertex * v = v2; v2 = v3; v3 = v; }
1443 height = v3->y - v1->y;
1444 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);
1447 if(longest == 0) {return FALSE;}
1451 right_array[0] = v3;
1452 right_array[1] = v2;
1453 right_array[2] = v1;
1459 if(LeftSection_G() <= 0) return FALSE;
1460 if(RightSection_G() <= 0)
1463 if(RightSection_G() <= 0) return FALSE;
1465 if(longest > -0x1000) longest = -0x1000;
1473 right_array[0] = v3;
1474 right_array[1] = v1;
1477 if(RightSection_G() <= 0) return FALSE;
1478 if(LeftSection_G() <= 0)
1481 if(LeftSection_G() <= 0) return FALSE;
1483 if(longest < 0x1000) longest = 0x1000;
1487 Ymax=min(v3->y-1,drawH);
1489 delta_right_R=shl10idiv(temp*((v3->R - v1->R)>>10)+((v1->R - v2->R)<<6),longest);
1490 delta_right_G=shl10idiv(temp*((v3->G - v1->G)>>10)+((v1->G - v2->G)<<6),longest);
1491 delta_right_B=shl10idiv(temp*((v3->B - v1->B)>>10)+((v1->B - v2->B)<<6),longest);
1496 ////////////////////////////////////////////////////////////////////////
1497 ////////////////////////////////////////////////////////////////////////
1499 __inline int RightSection_FT(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 __inline int LeftSection_FT(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 left_section_height = height;
1534 ////////////////////////////////////////////////////////////////////////
1536 __inline BOOL NextRow_FT(void)
1538 if(--left_section_height<=0)
1540 if(--left_section <= 0) {return TRUE;}
1541 if(LeftSection_FT() <= 0) {return TRUE;}
1545 left_x += delta_left_x;
1546 left_u += delta_left_u;
1547 left_v += delta_left_v;
1550 if(--right_section_height<=0)
1552 if(--right_section<=0) {return TRUE;}
1553 if(RightSection_FT() <=0) {return TRUE;}
1557 right_x += delta_right_x;
1562 ////////////////////////////////////////////////////////////////////////
1564 __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)
1566 soft_vertex * v1, * v2, * v3;
1567 int height,longest,temp;
1569 v1 = vtx; v1->x=x1<<16;v1->y=y1;
1570 v1->u=tx1<<16;v1->v=ty1<<16;
1571 v2 = vtx+1; v2->x=x2<<16;v2->y=y2;
1572 v2->u=tx2<<16;v2->v=ty2<<16;
1573 v3 = vtx+2; v3->x=x3<<16;v3->y=y3;
1574 v3->u=tx3<<16;v3->v=ty3<<16;
1576 if(v1->y > v2->y) { soft_vertex * v = v1; v1 = v2; v2 = v; }
1577 if(v1->y > v3->y) { soft_vertex * v = v1; v1 = v3; v3 = v; }
1578 if(v2->y > v3->y) { soft_vertex * v = v2; v2 = v3; v3 = v; }
1580 height = v3->y - v1->y;
1581 if(height == 0) {return FALSE;}
1583 temp=(((v2->y - v1->y) << 16) / height);
1584 longest = temp * ((v3->x - v1->x)>>16) + (v1->x - v2->x);
1586 if(longest == 0) {return FALSE;}
1590 right_array[0] = v3;
1591 right_array[1] = v2;
1592 right_array[2] = v1;
1598 if(LeftSection_FT() <= 0) return FALSE;
1599 if(RightSection_FT() <= 0)
1602 if(RightSection_FT() <= 0) return FALSE;
1604 if(longest > -0x1000) longest = -0x1000;
1612 right_array[0] = v3;
1613 right_array[1] = v1;
1616 if(RightSection_FT() <= 0) return FALSE;
1617 if(LeftSection_FT() <= 0)
1620 if(LeftSection_FT() <= 0) return FALSE;
1622 if(longest < 0x1000) longest = 0x1000;
1626 Ymax=min(v3->y-1,drawH);
1628 delta_right_u=shl10idiv(temp*((v3->u - v1->u)>>10)+((v1->u - v2->u)<<6),longest);
1629 delta_right_v=shl10idiv(temp*((v3->v - v1->v)>>10)+((v1->v - v2->v)<<6),longest);
1632 Mmm... adjust neg tex deltas... will sometimes cause slight
1638 if(longest<0) longest=-longest;
1640 delta_right_u-=delta_right_u/longest;
1642 delta_right_v-=delta_right_v/longest;
1649 ////////////////////////////////////////////////////////////////////////
1650 ////////////////////////////////////////////////////////////////////////
1652 __inline int RightSection_GT(void)
1654 soft_vertex * v1 = right_array[ right_section ];
1655 soft_vertex * v2 = right_array[ right_section-1 ];
1657 int height = v2->y - v1->y;
1658 if(height == 0) return 0;
1659 delta_right_x = (v2->x - v1->x) / height;
1662 right_section_height = height;
1666 ////////////////////////////////////////////////////////////////////////
1668 __inline int LeftSection_GT(void)
1670 soft_vertex * v1 = left_array[ left_section ];
1671 soft_vertex * v2 = left_array[ left_section-1 ];
1673 int height = v2->y - v1->y;
1674 if(height == 0) return 0;
1675 delta_left_x = (v2->x - v1->x) / height;
1678 delta_left_u = ((v2->u - v1->u)) / height;
1680 delta_left_v = ((v2->v - v1->v)) / height;
1683 delta_left_R = ((v2->R - v1->R)) / height;
1685 delta_left_G = ((v2->G - v1->G)) / height;
1687 delta_left_B = ((v2->B - v1->B)) / height;
1690 left_section_height = height;
1694 ////////////////////////////////////////////////////////////////////////
1696 __inline BOOL NextRow_GT(void)
1698 if(--left_section_height<=0)
1700 if(--left_section <= 0) {return TRUE;}
1701 if(LeftSection_GT() <= 0) {return TRUE;}
1705 left_x += delta_left_x;
1706 left_u += delta_left_u;
1707 left_v += delta_left_v;
1708 left_R += delta_left_R;
1709 left_G += delta_left_G;
1710 left_B += delta_left_B;
1713 if(--right_section_height<=0)
1715 if(--right_section<=0) {return TRUE;}
1716 if(RightSection_GT() <=0) {return TRUE;}
1720 right_x += delta_right_x;
1725 ////////////////////////////////////////////////////////////////////////
1727 __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)
1729 soft_vertex * v1, * v2, * v3;
1730 int height,longest,temp;
1732 v1 = vtx; v1->x=x1<<16;v1->y=y1;
1733 v1->u=tx1<<16;v1->v=ty1<<16;
1734 v1->R=(rgb1) & 0x00ff0000;
1735 v1->G=(rgb1<<8) & 0x00ff0000;
1736 v1->B=(rgb1<<16) & 0x00ff0000;
1738 v2 = vtx+1; v2->x=x2<<16;v2->y=y2;
1739 v2->u=tx2<<16;v2->v=ty2<<16;
1740 v2->R=(rgb2) & 0x00ff0000;
1741 v2->G=(rgb2<<8) & 0x00ff0000;
1742 v2->B=(rgb2<<16) & 0x00ff0000;
1744 v3 = vtx+2; v3->x=x3<<16;v3->y=y3;
1745 v3->u=tx3<<16;v3->v=ty3<<16;
1746 v3->R=(rgb3) & 0x00ff0000;
1747 v3->G=(rgb3<<8) & 0x00ff0000;
1748 v3->B=(rgb3<<16) & 0x00ff0000;
1750 if(v1->y > v2->y) { soft_vertex * v = v1; v1 = v2; v2 = v; }
1751 if(v1->y > v3->y) { soft_vertex * v = v1; v1 = v3; v3 = v; }
1752 if(v2->y > v3->y) { soft_vertex * v = v2; v2 = v3; v3 = v; }
1754 height = v3->y - v1->y;
1755 if(height == 0) {return FALSE;}
1757 temp=(((v2->y - v1->y) << 16) / height);
1758 longest = temp * ((v3->x - v1->x)>>16) + (v1->x - v2->x);
1760 if(longest == 0) {return FALSE;}
1764 right_array[0] = v3;
1765 right_array[1] = v2;
1766 right_array[2] = v1;
1772 if(LeftSection_GT() <= 0) return FALSE;
1773 if(RightSection_GT() <= 0)
1776 if(RightSection_GT() <= 0) return FALSE;
1779 if(longest > -0x1000) longest = -0x1000;
1787 right_array[0] = v3;
1788 right_array[1] = v1;
1791 if(RightSection_GT() <= 0) return FALSE;
1792 if(LeftSection_GT() <= 0)
1795 if(LeftSection_GT() <= 0) return FALSE;
1797 if(longest < 0x1000) longest = 0x1000;
1801 Ymax=min(v3->y-1,drawH);
1803 delta_right_R=shl10idiv(temp*((v3->R - v1->R)>>10)+((v1->R - v2->R)<<6),longest);
1804 delta_right_G=shl10idiv(temp*((v3->G - v1->G)>>10)+((v1->G - v2->G)<<6),longest);
1805 delta_right_B=shl10idiv(temp*((v3->B - v1->B)>>10)+((v1->B - v2->B)<<6),longest);
1807 delta_right_u=shl10idiv(temp*((v3->u - v1->u)>>10)+((v1->u - v2->u)<<6),longest);
1808 delta_right_v=shl10idiv(temp*((v3->v - v1->v)>>10)+((v1->v - v2->v)<<6),longest);
1812 Mmm... adjust neg tex deltas... will sometimes cause slight
1817 if(longest<0) longest=-longest;
1819 delta_right_u-=delta_right_u/longest;
1821 delta_right_v-=delta_right_v/longest;
1829 ////////////////////////////////////////////////////////////////////////
1830 ////////////////////////////////////////////////////////////////////////
1832 __inline int RightSection_F4(void)
1834 soft_vertex * v1 = right_array[ right_section ];
1835 soft_vertex * v2 = right_array[ right_section-1 ];
1837 int height = v2->y - v1->y;
1838 right_section_height = height;
1844 delta_right_x = (v2->x - v1->x) / height;
1849 ////////////////////////////////////////////////////////////////////////
1851 __inline int LeftSection_F4(void)
1853 soft_vertex * v1 = left_array[ left_section ];
1854 soft_vertex * v2 = left_array[ left_section-1 ];
1856 int height = v2->y - v1->y;
1857 left_section_height = height;
1863 delta_left_x = (v2->x - v1->x) / height;
1868 ////////////////////////////////////////////////////////////////////////
1870 __inline BOOL NextRow_F4(void)
1872 if(--left_section_height<=0)
1874 if(--left_section > 0)
1875 while(LeftSection_F4()<=0)
1877 if(--left_section <= 0) break;
1882 left_x += delta_left_x;
1885 if(--right_section_height<=0)
1887 if(--right_section > 0)
1888 while(RightSection_F4()<=0)
1890 if(--right_section<=0) break;
1895 right_x += delta_right_x;
1900 ////////////////////////////////////////////////////////////////////////
1902 __inline BOOL SetupSections_F4(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4)
1904 soft_vertex * v1, * v2, * v3, * v4;
1905 int height,width,longest1,longest2;
1907 v1 = vtx; v1->x=x1<<16;v1->y=y1;
1908 v2 = vtx+1; v2->x=x2<<16;v2->y=y2;
1909 v3 = vtx+2; v3->x=x3<<16;v3->y=y3;
1910 v4 = vtx+3; v4->x=x4<<16;v4->y=y4;
1912 if(v1->y > v2->y) { soft_vertex * v = v1; v1 = v2; v2 = v; }
1913 if(v1->y > v3->y) { soft_vertex * v = v1; v1 = v3; v3 = v; }
1914 if(v1->y > v4->y) { soft_vertex * v = v1; v1 = v4; v4 = v; }
1915 if(v2->y > v3->y) { soft_vertex * v = v2; v2 = v3; v3 = v; }
1916 if(v2->y > v4->y) { soft_vertex * v = v2; v2 = v4; v4 = v; }
1917 if(v3->y > v4->y) { soft_vertex * v = v3; v3 = v4; v4 = v; }
1919 height = v4->y - v1->y; if(height == 0) height =1;
1920 width = (v4->x - v1->x)>>16;
1921 longest1 = (((v2->y - v1->y) << 16) / height) * width + (v1->x - v2->x);
1922 longest2 = (((v3->y - v1->y) << 16) / height) * width + (v1->x - v3->x);
1924 if(longest1 < 0) // 2 is right
1926 if(longest2 < 0) // 3 is right
1932 height = v3->y - v1->y; if(height == 0) height=1;
1933 longest1 = (((v2->y - v1->y) << 16) / height) * ((v3->x - v1->x)>>16) + (v1->x - v2->x);
1936 right_array[0] = v4; // 1
1937 right_array[1] = v3; // 3
1938 right_array[2] = v1; // 4
1943 height = v4->y - v2->y; if(height == 0) height=1;
1944 longest1 = (((v3->y - v2->y) << 16) / height) * ((v4->x - v2->x)>>16) + (v2->x - v3->x);
1947 right_array[0] = v4; // 1
1948 right_array[1] = v2; // 2
1949 right_array[2] = v1; // 4
1954 right_array[0] = v4; // 1
1955 right_array[1] = v3; // 2
1956 right_array[2] = v2; // 3
1957 right_array[3] = v1; // 4
1965 left_array[1] = v3; // 1
1966 left_array[2] = v1; // 2
1967 left_section = 2; // 3
1968 right_array[0] = v4; // 4
1969 right_array[1] = v2;
1970 right_array[2] = v1;
1978 left_array[0] = v4; // 1
1979 left_array[1] = v2; // 2
1980 left_array[2] = v1; // 3
1981 left_section = 2; // 4
1982 right_array[0] = v4;
1983 right_array[1] = v3;
1984 right_array[2] = v1;
1989 right_array[0] = v4;
1990 right_array[1] = v1;
1993 height = v3->y - v1->y; if(height == 0) height=1;
1994 longest1 = (((v2->y - v1->y) << 16) / height) * ((v3->x - v1->x)>>16) + (v1->x - v2->x);
1997 left_array[0] = v4; // 1
1998 left_array[1] = v3; // 3
1999 left_array[2] = v1; // 4
2004 height = v4->y - v2->y; if(height == 0) height=1;
2005 longest1 = (((v3->y - v2->y) << 16) / height) * ((v4->x - v2->x)>>16) + (v2->x - v3->x);
2008 left_array[0] = v4; // 1
2009 left_array[1] = v2; // 2
2010 left_array[2] = v1; // 4
2015 left_array[0] = v4; // 1
2016 left_array[1] = v3; // 2
2017 left_array[2] = v2; // 3
2018 left_array[3] = v1; // 4
2025 while(LeftSection_F4()<=0)
2027 if(--left_section <= 0) break;
2030 while(RightSection_F4()<=0)
2032 if(--right_section <= 0) break;
2036 Ymax=min(v4->y-1,drawH);
2041 ////////////////////////////////////////////////////////////////////////
2042 ////////////////////////////////////////////////////////////////////////
2044 __inline int RightSection_FT4(void)
2046 soft_vertex * v1 = right_array[ right_section ];
2047 soft_vertex * v2 = right_array[ right_section-1 ];
2049 int height = v2->y - v1->y;
2050 right_section_height = height;
2058 delta_right_x = (v2->x - v1->x) / height;
2059 delta_right_u = (v2->u - v1->u) / height;
2060 delta_right_v = (v2->v - v1->v) / height;
2065 ////////////////////////////////////////////////////////////////////////
2067 __inline int LeftSection_FT4(void)
2069 soft_vertex * v1 = left_array[ left_section ];
2070 soft_vertex * v2 = left_array[ left_section-1 ];
2072 int height = v2->y - v1->y;
2073 left_section_height = height;
2081 delta_left_x = (v2->x - v1->x) / height;
2082 delta_left_u = (v2->u - v1->u) / height;
2083 delta_left_v = (v2->v - v1->v) / height;
2088 ////////////////////////////////////////////////////////////////////////
2090 __inline BOOL NextRow_FT4(void)
2092 if(--left_section_height<=0)
2094 if(--left_section > 0)
2095 while(LeftSection_FT4()<=0)
2097 if(--left_section <= 0) break;
2102 left_x += delta_left_x;
2103 left_u += delta_left_u;
2104 left_v += delta_left_v;
2107 if(--right_section_height<=0)
2109 if(--right_section > 0)
2110 while(RightSection_FT4()<=0)
2112 if(--right_section<=0) break;
2117 right_x += delta_right_x;
2118 right_u += delta_right_u;
2119 right_v += delta_right_v;
2124 ////////////////////////////////////////////////////////////////////////
2126 __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)
2128 soft_vertex * v1, * v2, * v3, * v4;
2129 int height,width,longest1,longest2;
2131 v1 = vtx; v1->x=x1<<16;v1->y=y1;
2132 v1->u=tx1<<16;v1->v=ty1<<16;
2134 v2 = vtx+1; v2->x=x2<<16;v2->y=y2;
2135 v2->u=tx2<<16;v2->v=ty2<<16;
2137 v3 = vtx+2; v3->x=x3<<16;v3->y=y3;
2138 v3->u=tx3<<16;v3->v=ty3<<16;
2140 v4 = vtx+3; v4->x=x4<<16;v4->y=y4;
2141 v4->u=tx4<<16;v4->v=ty4<<16;
2143 if(v1->y > v2->y) { soft_vertex * v = v1; v1 = v2; v2 = v; }
2144 if(v1->y > v3->y) { soft_vertex * v = v1; v1 = v3; v3 = v; }
2145 if(v1->y > v4->y) { soft_vertex * v = v1; v1 = v4; v4 = v; }
2146 if(v2->y > v3->y) { soft_vertex * v = v2; v2 = v3; v3 = v; }
2147 if(v2->y > v4->y) { soft_vertex * v = v2; v2 = v4; v4 = v; }
2148 if(v3->y > v4->y) { soft_vertex * v = v3; v3 = v4; v4 = v; }
2150 height = v4->y - v1->y; if(height == 0) height =1;
2151 width = (v4->x - v1->x)>>16;
2152 longest1 = (((v2->y - v1->y) << 16) / height) * width + (v1->x - v2->x);
2153 longest2 = (((v3->y - v1->y) << 16) / height) * width + (v1->x - v3->x);
2155 if(longest1 < 0) // 2 is right
2157 if(longest2 < 0) // 3 is right
2163 height = v3->y - v1->y; if(height == 0) height=1;
2164 longest1 = (((v2->y - v1->y) << 16) / height) * ((v3->x - v1->x)>>16) + (v1->x - v2->x);
2167 right_array[0] = v4; // 1
2168 right_array[1] = v3; // 3
2169 right_array[2] = v1; // 4
2174 height = v4->y - v2->y; if(height == 0) height=1;
2175 longest1 = (((v3->y - v2->y) << 16) / height) * ((v4->x - v2->x)>>16) + (v2->x - v3->x);
2178 right_array[0] = v4; // 1
2179 right_array[1] = v2; // 2
2180 right_array[2] = v1; // 4
2185 right_array[0] = v4; // 1
2186 right_array[1] = v3; // 2
2187 right_array[2] = v2; // 3
2188 right_array[3] = v1; // 4
2196 left_array[1] = v3; // 1
2197 left_array[2] = v1; // 2
2198 left_section = 2; // 3
2199 right_array[0] = v4; // 4
2200 right_array[1] = v2;
2201 right_array[2] = v1;
2209 left_array[0] = v4; // 1
2210 left_array[1] = v2; // 2
2211 left_array[2] = v1; // 3
2212 left_section = 2; // 4
2213 right_array[0] = v4;
2214 right_array[1] = v3;
2215 right_array[2] = v1;
2220 right_array[0] = v4;
2221 right_array[1] = v1;
2224 height = v3->y - v1->y; if(height == 0) height=1;
2225 longest1 = (((v2->y - v1->y) << 16) / height) * ((v3->x - v1->x)>>16) + (v1->x - v2->x);
2228 left_array[0] = v4; // 1
2229 left_array[1] = v3; // 3
2230 left_array[2] = v1; // 4
2235 height = v4->y - v2->y; if(height == 0) height=1;
2236 longest1 = (((v3->y - v2->y) << 16) / height) * ((v4->x - v2->x)>>16) + (v2->x - v3->x);
2239 left_array[0] = v4; // 1
2240 left_array[1] = v2; // 2
2241 left_array[2] = v1; // 4
2246 left_array[0] = v4; // 1
2247 left_array[1] = v3; // 2
2248 left_array[2] = v2; // 3
2249 left_array[3] = v1; // 4
2256 while(LeftSection_FT4()<=0)
2258 if(--left_section <= 0) break;
2261 while(RightSection_FT4()<=0)
2263 if(--right_section <= 0) break;
2267 Ymax=min(v4->y-1,drawH);
2272 ////////////////////////////////////////////////////////////////////////
2273 ////////////////////////////////////////////////////////////////////////
2275 __inline int RightSection_GT4(void)
2277 soft_vertex * v1 = right_array[ right_section ];
2278 soft_vertex * v2 = right_array[ right_section-1 ];
2280 int height = v2->y - v1->y;
2281 right_section_height = height;
2293 delta_right_x = (v2->x - v1->x) / height;
2294 delta_right_u = (v2->u - v1->u) / height;
2295 delta_right_v = (v2->v - v1->v) / height;
2296 delta_right_R = (v2->R - v1->R) / height;
2297 delta_right_G = (v2->G - v1->G) / height;
2298 delta_right_B = (v2->B - v1->B) / height;
2303 ////////////////////////////////////////////////////////////////////////
2305 __inline int LeftSection_GT4(void)
2307 soft_vertex * v1 = left_array[ left_section ];
2308 soft_vertex * v2 = left_array[ left_section-1 ];
2310 int height = v2->y - v1->y;
2311 left_section_height = height;
2323 delta_left_x = (v2->x - v1->x) / height;
2324 delta_left_u = (v2->u - v1->u) / height;
2325 delta_left_v = (v2->v - v1->v) / height;
2326 delta_left_R = (v2->R - v1->R) / height;
2327 delta_left_G = (v2->G - v1->G) / height;
2328 delta_left_B = (v2->B - v1->B) / height;
2333 ////////////////////////////////////////////////////////////////////////
2335 __inline BOOL NextRow_GT4(void)
2337 if(--left_section_height<=0)
2339 if(--left_section > 0)
2340 while(LeftSection_GT4()<=0)
2342 if(--left_section <= 0) break;
2347 left_x += delta_left_x;
2348 left_u += delta_left_u;
2349 left_v += delta_left_v;
2350 left_R += delta_left_R;
2351 left_G += delta_left_G;
2352 left_B += delta_left_B;
2355 if(--right_section_height<=0)
2357 if(--right_section > 0)
2358 while(RightSection_GT4()<=0)
2360 if(--right_section<=0) break;
2365 right_x += delta_right_x;
2366 right_u += delta_right_u;
2367 right_v += delta_right_v;
2368 right_R += delta_right_R;
2369 right_G += delta_right_G;
2370 right_B += delta_right_B;
2375 ////////////////////////////////////////////////////////////////////////
2377 __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)
2379 soft_vertex * v1, * v2, * v3, * v4;
2380 int height,width,longest1,longest2;
2382 v1 = vtx; v1->x=x1<<16;v1->y=y1;
2383 v1->u=tx1<<16;v1->v=ty1<<16;
2384 v1->R=(rgb1) & 0x00ff0000;
2385 v1->G=(rgb1<<8) & 0x00ff0000;
2386 v1->B=(rgb1<<16) & 0x00ff0000;
2388 v2 = vtx+1; v2->x=x2<<16;v2->y=y2;
2389 v2->u=tx2<<16;v2->v=ty2<<16;
2390 v2->R=(rgb2) & 0x00ff0000;
2391 v2->G=(rgb2<<8) & 0x00ff0000;
2392 v2->B=(rgb2<<16) & 0x00ff0000;
2394 v3 = vtx+2; v3->x=x3<<16;v3->y=y3;
2395 v3->u=tx3<<16;v3->v=ty3<<16;
2396 v3->R=(rgb3) & 0x00ff0000;
2397 v3->G=(rgb3<<8) & 0x00ff0000;
2398 v3->B=(rgb3<<16) & 0x00ff0000;
2400 v4 = vtx+3; v4->x=x4<<16;v4->y=y4;
2401 v4->u=tx4<<16;v4->v=ty4<<16;
2402 v4->R=(rgb4) & 0x00ff0000;
2403 v4->G=(rgb4<<8) & 0x00ff0000;
2404 v4->B=(rgb4<<16) & 0x00ff0000;
2406 if(v1->y > v2->y) { soft_vertex * v = v1; v1 = v2; v2 = v; }
2407 if(v1->y > v3->y) { soft_vertex * v = v1; v1 = v3; v3 = v; }
2408 if(v1->y > v4->y) { soft_vertex * v = v1; v1 = v4; v4 = v; }
2409 if(v2->y > v3->y) { soft_vertex * v = v2; v2 = v3; v3 = v; }
2410 if(v2->y > v4->y) { soft_vertex * v = v2; v2 = v4; v4 = v; }
2411 if(v3->y > v4->y) { soft_vertex * v = v3; v3 = v4; v4 = v; }
2413 height = v4->y - v1->y; if(height == 0) height =1;
2414 width = (v4->x - v1->x)>>16;
2415 longest1 = (((v2->y - v1->y) << 16) / height) * width + (v1->x - v2->x);
2416 longest2 = (((v3->y - v1->y) << 16) / height) * width + (v1->x - v3->x);
2418 if(longest1 < 0) // 2 is right
2420 if(longest2 < 0) // 3 is right
2426 height = v3->y - v1->y; if(height == 0) height=1;
2427 longest1 = (((v2->y - v1->y) << 16) / height) * ((v3->x - v1->x)>>16) + (v1->x - v2->x);
2430 right_array[0] = v4; // 1
2431 right_array[1] = v3; // 3
2432 right_array[2] = v1; // 4
2437 height = v4->y - v2->y; if(height == 0) height=1;
2438 longest1 = (((v3->y - v2->y) << 16) / height) * ((v4->x - v2->x)>>16) + (v2->x - v3->x);
2441 right_array[0] = v4; // 1
2442 right_array[1] = v2; // 2
2443 right_array[2] = v1; // 4
2448 right_array[0] = v4; // 1
2449 right_array[1] = v3; // 2
2450 right_array[2] = v2; // 3
2451 right_array[3] = v1; // 4
2459 left_array[1] = v3; // 1
2460 left_array[2] = v1; // 2
2461 left_section = 2; // 3
2462 right_array[0] = v4; // 4
2463 right_array[1] = v2;
2464 right_array[2] = v1;
2472 left_array[0] = v4; // 1
2473 left_array[1] = v2; // 2
2474 left_array[2] = v1; // 3
2475 left_section = 2; // 4
2476 right_array[0] = v4;
2477 right_array[1] = v3;
2478 right_array[2] = v1;
2483 right_array[0] = v4;
2484 right_array[1] = v1;
2487 height = v3->y - v1->y; if(height == 0) height=1;
2488 longest1 = (((v2->y - v1->y) << 16) / height) * ((v3->x - v1->x)>>16) + (v1->x - v2->x);
2491 left_array[0] = v4; // 1
2492 left_array[1] = v3; // 3
2493 left_array[2] = v1; // 4
2498 height = v4->y - v2->y; if(height == 0) height=1;
2499 longest1 = (((v3->y - v2->y) << 16) / height) * ((v4->x - v2->x)>>16) + (v2->x - v3->x);
2502 left_array[0] = v4; // 1
2503 left_array[1] = v2; // 2
2504 left_array[2] = v1; // 4
2509 left_array[0] = v4; // 1
2510 left_array[1] = v3; // 2
2511 left_array[2] = v2; // 3
2512 left_array[3] = v1; // 4
2519 while(LeftSection_GT4()<=0)
2521 if(--left_section <= 0) break;
2524 while(RightSection_GT4()<=0)
2526 if(--right_section <= 0) break;
2530 Ymax=min(v4->y-1,drawH);
2535 ////////////////////////////////////////////////////////////////////////
2536 ////////////////////////////////////////////////////////////////////////
2537 ////////////////////////////////////////////////////////////////////////
2539 ////////////////////////////////////////////////////////////////////////
2540 ////////////////////////////////////////////////////////////////////////
2541 ////////////////////////////////////////////////////////////////////////
2543 ////////////////////////////////////////////////////////////////////////
2544 // POLY 3/4 FLAT SHADED
2545 ////////////////////////////////////////////////////////////////////////
2547 __inline void drawPoly3Fi(short x1,short y1,short x2,short y2,short x3,short y3,int32_t rgb)
2549 int i,j,xmin,xmax,ymin,ymax;
2550 unsigned short color;uint32_t lcolor;
2552 if(x1>drawW && x2>drawW && x3>drawW) return;
2553 if(y1>drawH && y2>drawH && y3>drawH) return;
2554 if(x1<drawX && x2<drawX && x3<drawX) return;
2555 if(y1<drawY && y2<drawY && y3<drawY) return;
2556 if(drawY>=drawH) return;
2557 if(drawX>=drawW) return;
2559 if(!SetupSections_F(x1,y1,x2,y2,x3,y3)) return;
2563 color = ((rgb & 0x00f80000)>>9) | ((rgb & 0x0000f800)>>6) | ((rgb & 0x000000f8)>>3);
2564 lcolor=lSetMask|(((uint32_t)(color))<<16)|color;
2566 for(ymin=Ymin;ymin<drawY;ymin++)
2567 if(NextRow_F()) return;
2571 if(!bCheckMask && !DrawSemiTrans)
2574 for (i=ymin;i<=ymax;i++)
2576 xmin=left_x >> 16; if(drawX>xmin) xmin=drawX;
2577 xmax=(right_x >> 16)-1; if(drawW<xmax) xmax=drawW;
2579 for(j=xmin;j<xmax;j+=2)
2581 PUTLE32(((uint32_t *)&psxVuw[(i<<10)+j]), lcolor);
2583 if(j==xmax) PUTLE16(&psxVuw[(i<<10)+j], color);
2585 if(NextRow_F()) return;
2592 for (i=ymin;i<=ymax;i++)
2594 xmin=left_x >> 16; if(drawX>xmin) xmin=drawX;
2595 xmax=(right_x >> 16)-1; if(drawW<xmax) xmax=drawW;
2597 for(j=xmin;j<xmax;j+=2)
2599 GetShadeTransCol32((uint32_t *)&psxVuw[(i<<10)+j],lcolor);
2602 GetShadeTransCol(&psxVuw[(i<<10)+j],color);
2604 if(NextRow_F()) return;
2608 ////////////////////////////////////////////////////////////////////////
2610 void drawPoly3F(int32_t rgb)
2612 drawPoly3Fi(lx0,ly0,lx1,ly1,lx2,ly2,rgb);
2617 void drawPoly4F_TRI(int32_t rgb)
2619 drawPoly3Fi(lx1,ly1,lx3,ly3,lx2,ly2,rgb);
2620 drawPoly3Fi(lx0,ly0,lx1,ly1,lx2,ly2,rgb);
2627 void drawPoly4F(int32_t rgb)
2629 int i,j,xmin,xmax,ymin,ymax;
2630 unsigned short color;uint32_t lcolor;
2632 if(lx0>drawW && lx1>drawW && lx2>drawW && lx3>drawW) return;
2633 if(ly0>drawH && ly1>drawH && ly2>drawH && ly3>drawH) return;
2634 if(lx0<drawX && lx1<drawX && lx2<drawX && lx3<drawX) return;
2635 if(ly0<drawY && ly1<drawY && ly2<drawY && ly3<drawY) return;
2636 if(drawY>=drawH) return;
2637 if(drawX>=drawW) return;
2639 if(!SetupSections_F4(lx0,ly0,lx1,ly1,lx2,ly2,lx3,ly3)) return;
2643 for(ymin=Ymin;ymin<drawY;ymin++)
2644 if(NextRow_F4()) return;
2646 color = ((rgb & 0x00f80000)>>9) | ((rgb & 0x0000f800)>>6) | ((rgb & 0x000000f8)>>3);
2647 lcolor= lSetMask|(((uint32_t)(color))<<16)|color;
2651 if(!bCheckMask && !DrawSemiTrans)
2654 for (i=ymin;i<=ymax;i++)
2656 xmin=left_x >> 16; if(drawX>xmin) xmin=drawX;
2657 xmax=(right_x >> 16)-1; if(drawW<xmax) xmax=drawW;
2659 for(j=xmin;j<xmax;j+=2)
2661 PUTLE32(((uint32_t *)&psxVuw[(i<<10)+j]), lcolor);
2663 if(j==xmax) PUTLE16(&psxVuw[(i<<10)+j], color);
2665 if(NextRow_F4()) return;
2672 for (i=ymin;i<=ymax;i++)
2674 xmin=left_x >> 16; if(drawX>xmin) xmin=drawX;
2675 xmax=(right_x >> 16)-1; if(drawW<xmax) xmax=drawW;
2677 for(j=xmin;j<xmax;j+=2)
2679 GetShadeTransCol32((uint32_t *)&psxVuw[(i<<10)+j],lcolor);
2681 if(j==xmax) GetShadeTransCol(&psxVuw[(i<<10)+j],color);
2683 if(NextRow_F4()) return;
2687 ////////////////////////////////////////////////////////////////////////
2688 // POLY 3/4 F-SHADED TEX PAL 4
2689 ////////////////////////////////////////////////////////////////////////
2691 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)
2693 int i,j,xmin,xmax,ymin,ymax;
2694 int32_t difX, difY,difX2, difY2;
2695 int32_t posX,posY,YAdjust,XAdjust;
2699 if(x1>drawW && x2>drawW && x3>drawW) return;
2700 if(y1>drawH && y2>drawH && y3>drawH) return;
2701 if(x1<drawX && x2<drawX && x3<drawX) return;
2702 if(y1<drawY && y2<drawY && y3<drawY) return;
2703 if(drawY>=drawH) return;
2704 if(drawX>=drawW) return;
2706 if(!SetupSections_FT(x1,y1,x2,y2,x3,y3,tx1,ty1,tx2,ty2,tx3,ty3)) return;
2710 for(ymin=Ymin;ymin<drawY;ymin++)
2711 if(NextRow_FT()) return;
2713 clutP=(clY<<10)+clX;
2715 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
2717 difX=delta_right_u;difX2=difX<<1;
2718 difY=delta_right_v;difY2=difY<<1;
2722 if(!bCheckMask && !DrawSemiTrans)
2724 for (i=ymin;i<=ymax;i++)
2726 xmin=(left_x >> 16);
2727 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!!
2728 if(drawW<xmax) xmax=drawW;
2736 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
2738 for(j=xmin;j<xmax;j+=2)
2741 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(XAdjust>>1)];
2742 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
2743 XAdjust=((posX+difX)>>16);
2744 tC2 = psxVub[(((posY+difY)>>5)&(int32_t)0xFFFFF800)+YAdjust+
2746 tC2=(tC2>>((XAdjust&1)<<2))&0xf;
2748 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
2749 GETLE16(&psxVuw[clutP+tC1])|
2750 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
2758 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+
2760 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
2761 GetTextureTransColG_S(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
2774 for (i=ymin;i<=ymax;i++)
2776 xmin=(left_x >> 16);
2777 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!!!!
2778 if(drawW<xmax) xmax=drawW;
2786 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
2788 for(j=xmin;j<xmax;j+=2)
2791 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(XAdjust>>1)];
2792 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
2793 XAdjust=((posX+difX)>>16);
2794 tC2 = psxVub[(((posY+difY)>>5)&(int32_t)0xFFFFF800)+YAdjust+
2796 tC2=(tC2>>((XAdjust&1)<<2))&0xf;
2798 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
2799 GETLE16(&psxVuw[clutP+tC1])|
2800 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
2808 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+
2810 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
2811 GetTextureTransColG(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
2821 ////////////////////////////////////////////////////////////////////////
2823 void drawPoly3TEx4_IL(short x1, short y1, short x2, short y2, short x3, short y3, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3,short clX, short clY)
2825 int i,j,xmin,xmax,ymin,ymax,n_xi,n_yi,TXV;
2826 int32_t difX, difY,difX2, difY2;
2827 int32_t posX,posY,YAdjust,XAdjust;
2831 if(x1>drawW && x2>drawW && x3>drawW) return;
2832 if(y1>drawH && y2>drawH && y3>drawH) return;
2833 if(x1<drawX && x2<drawX && x3<drawX) return;
2834 if(y1<drawY && y2<drawY && y3<drawY) return;
2835 if(drawY>=drawH) return;
2836 if(drawX>=drawW) return;
2838 if(!SetupSections_FT(x1,y1,x2,y2,x3,y3,tx1,ty1,tx2,ty2,tx3,ty3)) return;
2842 for(ymin=Ymin;ymin<drawY;ymin++)
2843 if(NextRow_FT()) return;
2845 clutP=(clY<<10)+clX;
2847 YAdjust=(GlobalTextAddrY<<10)+GlobalTextAddrX;
2849 difX=delta_right_u;difX2=difX<<1;
2850 difY=delta_right_v;difY2=difY<<1;
2854 if(!bCheckMask && !DrawSemiTrans)
2856 for (i=ymin;i<=ymax;i++)
2858 xmin=(left_x >> 16);
2859 xmax=(right_x >> 16)-1;
2860 if(drawW<xmax) xmax=drawW;
2868 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
2870 for(j=xmin;j<xmax;j+=2)
2875 n_xi = ( ( XAdjust >> 2 ) & ~0x3c ) + ( ( TXV << 2 ) & 0x3c );
2876 n_yi = ( TXV & ~0xf ) + ( ( XAdjust >> 4 ) & 0xf );
2878 tC1= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((XAdjust & 0x03)<<2)) & 0x0f ;
2880 XAdjust=((posX+difX)>>16);
2882 TXV=(posY+difY)>>16;
2883 n_xi = ( ( XAdjust >> 2 ) & ~0x3c ) + ( ( TXV << 2 ) & 0x3c );
2884 n_yi = ( TXV & ~0xf ) + ( ( XAdjust >> 4 ) & 0xf );
2886 tC2= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((XAdjust & 0x03)<<2)) & 0x0f ;
2888 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
2889 GETLE16(&psxVuw[clutP+tC1])|
2890 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
2900 n_xi = ( ( XAdjust >> 2 ) & ~0x3c ) + ( ( TXV << 2 ) & 0x3c );
2901 n_yi = ( TXV & ~0xf ) + ( ( XAdjust >> 4 ) & 0xf );
2903 tC1= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((XAdjust & 0x03)<<2)) & 0x0f ;
2905 GetTextureTransColG_S(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
2918 for (i=ymin;i<=ymax;i++)
2920 xmin=(left_x >> 16);
2921 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!!!!
2922 if(drawW<xmax) xmax=drawW;
2930 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
2932 for(j=xmin;j<xmax;j+=2)
2937 n_xi = ( ( XAdjust >> 2 ) & ~0x3c ) + ( ( TXV << 2 ) & 0x3c );
2938 n_yi = ( TXV & ~0xf ) + ( ( XAdjust >> 4 ) & 0xf );
2940 tC1= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((XAdjust & 0x03)<<2)) & 0x0f ;
2942 XAdjust=((posX+difX)>>16);
2944 TXV=(posY+difY)>>16;
2945 n_xi = ( ( XAdjust >> 2 ) & ~0x3c ) + ( ( TXV << 2 ) & 0x3c );
2946 n_yi = ( TXV & ~0xf ) + ( ( XAdjust >> 4 ) & 0xf );
2948 tC2= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((XAdjust & 0x03)<<2)) & 0x0f ;
2950 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
2951 GETLE16(&psxVuw[clutP+tC1])|
2952 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
2962 n_xi = ( ( XAdjust >> 2 ) & ~0x3c ) + ( ( TXV << 2 ) & 0x3c );
2963 n_yi = ( TXV & ~0xf ) + ( ( XAdjust >> 4 ) & 0xf );
2965 tC1= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((XAdjust & 0x03)<<2)) & 0x0f ;
2967 GetTextureTransColG(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
2977 ////////////////////////////////////////////////////////////////////////
2979 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)
2981 int i,j,xmin,xmax,ymin,ymax;
2982 int32_t difX, difY,difX2, difY2;
2983 int32_t posX,posY,YAdjust,XAdjust;
2987 if(x1>drawW && x2>drawW && x3>drawW) return;
2988 if(y1>drawH && y2>drawH && y3>drawH) return;
2989 if(x1<drawX && x2<drawX && x3<drawX) return;
2990 if(y1<drawY && y2<drawY && y3<drawY) return;
2991 if(drawY>=drawH) return;
2992 if(drawX>=drawW) return;
2994 if(!SetupSections_FT(x1,y1,x2,y2,x3,y3,tx1,ty1,tx2,ty2,tx3,ty3)) return;
2998 for(ymin=Ymin;ymin<drawY;ymin++)
2999 if(NextRow_FT()) return;
3001 clutP=(clY<<10)+clX;
3003 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
3004 YAdjust+=(TWin.Position.y0<<11)+(TWin.Position.x0>>1);
3006 difX=delta_right_u;difX2=difX<<1;
3007 difY=delta_right_v;difY2=difY<<1;
3011 if(!bCheckMask && !DrawSemiTrans)
3013 for (i=ymin;i<=ymax;i++)
3015 xmin=(left_x >> 16);
3016 xmax=(right_x >> 16);//-1; //!!!!!!!!!!!!!!!!
3017 if(xmax>xmin) xmax--;
3019 if(drawW<xmax) xmax=drawW;
3027 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3029 for(j=xmin;j<xmax;j+=2)
3031 XAdjust=(posX>>16)%TWin.Position.x1;
3032 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
3033 YAdjust+(XAdjust>>1)];
3034 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
3035 XAdjust=((posX+difX)>>16)%TWin.Position.x1;
3036 tC2 = psxVub[((((posY+difY)>>16)%TWin.Position.y1)<<11)+
3037 YAdjust+(XAdjust>>1)];
3038 tC2=(tC2>>((XAdjust&1)<<2))&0xf;
3040 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
3041 GETLE16(&psxVuw[clutP+tC1])|
3042 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3049 XAdjust=(posX>>16)%TWin.Position.x1;
3050 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
3051 YAdjust+(XAdjust>>1)];
3052 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
3053 GetTextureTransColG_S(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3066 for (i=ymin;i<=ymax;i++)
3068 xmin=(left_x >> 16);
3069 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!!!!
3070 if(drawW<xmax) xmax=drawW;
3078 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3080 for(j=xmin;j<xmax;j+=2)
3082 XAdjust=(posX>>16)%TWin.Position.x1;
3083 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
3084 YAdjust+(XAdjust>>1)];
3085 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
3086 XAdjust=((posX+difX)>>16)%TWin.Position.x1;
3087 tC2 = psxVub[((((posY+difY)>>16)%TWin.Position.y1)<<11)+
3088 YAdjust+(XAdjust>>1)];
3089 tC2=(tC2>>((XAdjust&1)<<2))&0xf;
3091 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
3092 GETLE16(&psxVuw[clutP+tC1])|
3093 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3100 XAdjust=(posX>>16)%TWin.Position.x1;
3101 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
3102 YAdjust+(XAdjust>>1)];
3103 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
3104 GetTextureTransColG(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3114 ////////////////////////////////////////////////////////////////////////
3118 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)
3120 drawPoly3TEx4(x2,y2,x3,y3,x4,y4,
3121 tx2,ty2,tx3,ty3,tx4,ty4,
3123 drawPoly3TEx4(x1,y1,x2,y2,x4,y4,
3124 tx1,ty1,tx2,ty2,tx4,ty4,
3132 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)
3135 int32_t i,j,xmin,xmax,ymin,ymax;
3136 int32_t difX, difY, difX2, difY2;
3137 int32_t posX,posY,YAdjust,clutP,XAdjust;
3140 if(x1>drawW && x2>drawW && x3>drawW && x4>drawW) return;
3141 if(y1>drawH && y2>drawH && y3>drawH && y4>drawH) return;
3142 if(x1<drawX && x2<drawX && x3<drawX && x4<drawX) return;
3143 if(y1<drawY && y2<drawY && y3<drawY && y4<drawY) return;
3144 if(drawY>=drawH) return;
3145 if(drawX>=drawW) return;
3147 if(!SetupSections_FT4(x1,y1,x2,y2,x3,y3,x4,y4,tx1,ty1,tx2,ty2,tx3,ty3,tx4,ty4)) return;
3151 for(ymin=Ymin;ymin<drawY;ymin++)
3152 if(NextRow_FT4()) return;
3154 clutP=(clY<<10)+clX;
3156 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
3160 if(!bCheckMask && !DrawSemiTrans)
3162 for (i=ymin;i<=ymax;i++)
3164 xmin=(left_x >> 16);
3165 xmax=(right_x >> 16);
3174 difX=(right_u-posX)/num;
3175 difY=(right_v-posY)/num;
3180 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3181 xmax--;if(drawW<xmax) xmax=drawW;
3183 for(j=xmin;j<xmax;j+=2)
3186 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(XAdjust>>1)];
3187 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
3188 XAdjust=((posX+difX)>>16);
3189 tC2 = psxVub[(((posY+difY)>>5)&(int32_t)0xFFFFF800)+YAdjust+
3191 tC2=(tC2>>((XAdjust&1)<<2))&0xf;
3193 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
3194 GETLE16(&psxVuw[clutP+tC1])|
3195 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3202 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+
3204 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
3205 GetTextureTransColG_S(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3209 if(NextRow_FT4()) return;
3216 for (i=ymin;i<=ymax;i++)
3218 xmin=(left_x >> 16);
3219 xmax=(right_x >> 16);
3228 difX=(right_u-posX)/num;
3229 difY=(right_v-posY)/num;
3234 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3235 xmax--;if(drawW<xmax) xmax=drawW;
3237 for(j=xmin;j<xmax;j+=2)
3240 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(XAdjust>>1)];
3241 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
3242 XAdjust=((posX+difX)>>16);
3243 tC2 = psxVub[(((posY+difY)>>5)&(int32_t)0xFFFFF800)+YAdjust+
3245 tC2=(tC2>>((XAdjust&1)<<2))&0xf;
3247 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
3248 GETLE16(&psxVuw[clutP+tC1])|
3249 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3256 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+
3258 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
3259 GetTextureTransColG(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3262 if(NextRow_FT4()) return;
3266 ////////////////////////////////////////////////////////////////////////
3268 void drawPoly4TEx4_IL(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4,short clX, short clY)
3271 int32_t i,j=0,xmin,xmax,ymin,ymax,n_xi,n_yi,TXV;
3272 int32_t difX, difY, difX2, difY2;
3273 int32_t posX=0,posY=0,YAdjust,clutP,XAdjust;
3276 if(x1>drawW && x2>drawW && x3>drawW && x4>drawW) return;
3277 if(y1>drawH && y2>drawH && y3>drawH && y4>drawH) return;
3278 if(x1<drawX && x2<drawX && x3<drawX && x4<drawX) return;
3279 if(y1<drawY && y2<drawY && y3<drawY && y4<drawY) return;
3280 if(drawY>=drawH) return;
3281 if(drawX>=drawW) return;
3283 if(!SetupSections_FT4(x1,y1,x2,y2,x3,y3,x4,y4,tx1,ty1,tx2,ty2,tx3,ty3,tx4,ty4)) return;
3287 for(ymin=Ymin;ymin<drawY;ymin++)
3288 if(NextRow_FT4()) return;
3290 clutP=(clY<<10)+clX;
3292 YAdjust=((GlobalTextAddrY)<<10)+GlobalTextAddrX;
3296 if(!bCheckMask && !DrawSemiTrans)
3298 for (i=ymin;i<=ymax;i++)
3300 xmin=(left_x >> 16);
3301 xmax=(right_x >> 16);
3310 difX=(right_u-posX)/num;
3311 difY=(right_v-posY)/num;
3316 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3317 xmax--;if(drawW<xmax) xmax=drawW;
3319 for(j=xmin;j<xmax;j+=2)
3324 n_xi = ( ( XAdjust >> 2 ) & ~0x3c ) + ( ( TXV << 2 ) & 0x3c );
3325 n_yi = ( TXV & ~0xf ) + ( ( XAdjust >> 4 ) & 0xf );
3327 tC1= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((XAdjust & 0x03)<<2)) & 0x0f ;
3329 XAdjust=((posX+difX)>>16);
3331 TXV=(posY+difY)>>16;
3332 n_xi = ( ( XAdjust >> 2 ) & ~0x3c ) + ( ( TXV << 2 ) & 0x3c );
3333 n_yi = ( TXV & ~0xf ) + ( ( XAdjust >> 4 ) & 0xf );
3335 tC2= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((XAdjust & 0x03)<<2)) & 0x0f ;
3337 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
3338 GETLE16(&psxVuw[clutP+tC1])|
3339 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3351 n_xi = ( ( XAdjust >> 2 ) & ~0x3c ) + ( ( TXV << 2 ) & 0x3c );
3352 n_yi = ( TXV & ~0xf ) + ( ( XAdjust >> 4 ) & 0xf );
3354 tC1= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((XAdjust & 0x03)<<2)) & 0x0f ;
3356 GetTextureTransColG_S(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3360 if(NextRow_FT4()) return;
3364 for (i=ymin;i<=ymax;i++)
3366 xmin=(left_x >> 16);
3367 xmax=(right_x >> 16);
3376 difX=(right_u-posX)/num;
3377 difY=(right_v-posY)/num;
3382 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3383 xmax--;if(drawW<xmax) xmax=drawW;
3385 for(j=xmin;j<xmax;j+=2)
3390 n_xi = ( ( XAdjust >> 2 ) & ~0x3c ) + ( ( TXV << 2 ) & 0x3c );
3391 n_yi = ( TXV & ~0xf ) + ( ( XAdjust >> 4 ) & 0xf );
3393 tC1= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((XAdjust & 0x03)<<2)) & 0x0f ;
3395 XAdjust=((posX+difX)>>16);
3397 TXV=(posY+difY)>>16;
3398 n_xi = ( ( XAdjust >> 2 ) & ~0x3c ) + ( ( TXV << 2 ) & 0x3c );
3399 n_yi = ( TXV & ~0xf ) + ( ( XAdjust >> 4 ) & 0xf );
3401 tC2= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((XAdjust & 0x03)<<2)) & 0x0f ;
3403 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
3404 GETLE16(&psxVuw[clutP+tC1])|
3405 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3413 n_xi = ( ( XAdjust >> 2 ) & ~0x3c ) + ( ( TXV << 2 ) & 0x3c );
3414 n_yi = ( TXV & ~0xf ) + ( ( XAdjust >> 4 ) & 0xf );
3416 tC1= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((XAdjust & 0x03)<<2)) & 0x0f ;
3418 GetTextureTransColG(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3421 if(NextRow_FT4()) return;
3425 ////////////////////////////////////////////////////////////////////////
3427 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)
3430 int32_t i,j,xmin,xmax,ymin,ymax;
3431 int32_t difX, difY, difX2, difY2;
3432 int32_t posX,posY,YAdjust,clutP,XAdjust;
3435 if(x1>drawW && x2>drawW && x3>drawW && x4>drawW) return;
3436 if(y1>drawH && y2>drawH && y3>drawH && y4>drawH) return;
3437 if(x1<drawX && x2<drawX && x3<drawX && x4<drawX) return;
3438 if(y1<drawY && y2<drawY && y3<drawY && y4<drawY) return;
3439 if(drawY>=drawH) return;
3440 if(drawX>=drawW) return;
3442 if(!SetupSections_FT4(x1,y1,x2,y2,x3,y3,x4,y4,tx1,ty1,tx2,ty2,tx3,ty3,tx4,ty4)) return;
3446 for(ymin=Ymin;ymin<drawY;ymin++)
3447 if(NextRow_FT4()) return;
3449 clutP=(clY<<10)+clX;
3451 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
3452 YAdjust+=(TWin.Position.y0<<11)+(TWin.Position.x0>>1);
3456 if(!bCheckMask && !DrawSemiTrans)
3458 for (i=ymin;i<=ymax;i++)
3460 xmin=(left_x >> 16);
3461 xmax=(right_x >> 16);
3470 difX=(right_u-posX)/num;
3471 difY=(right_v-posY)/num;
3476 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3477 xmax--;if(drawW<xmax) xmax=drawW;
3479 for(j=xmin;j<xmax;j+=2)
3481 XAdjust=(posX>>16)%TWin.Position.x1;
3482 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
3483 YAdjust+(XAdjust>>1)];
3484 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
3485 XAdjust=((posX+difX)>>16)%TWin.Position.x1;
3486 tC2 = psxVub[((((posY+difY)>>16)%TWin.Position.y1)<<11)+
3487 YAdjust+(XAdjust>>1)];
3488 tC2=(tC2>>((XAdjust&1)<<2))&0xf;
3490 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
3491 GETLE16(&psxVuw[clutP+tC1])|
3492 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3498 XAdjust=(posX>>16)%TWin.Position.x1;
3499 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
3500 YAdjust+(XAdjust>>1)];
3501 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
3502 GetTextureTransColG_S(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3505 if(NextRow_FT4()) return;
3512 for (i=ymin;i<=ymax;i++)
3514 xmin=(left_x >> 16);
3515 xmax=(right_x >> 16);
3524 difX=(right_u-posX)/num;
3525 difY=(right_v-posY)/num;
3530 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3531 xmax--;if(drawW<xmax) xmax=drawW;
3533 for(j=xmin;j<xmax;j+=2)
3535 XAdjust=(posX>>16)%TWin.Position.x1;
3536 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
3537 YAdjust+(XAdjust>>1)];
3538 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
3539 XAdjust=((posX+difX)>>16)%TWin.Position.x1;
3540 tC2 = psxVub[((((posY+difY)>>16)%TWin.Position.y1)<<11)+
3541 YAdjust+(XAdjust>>1)];
3542 tC2=(tC2>>((XAdjust&1)<<2))&0xf;
3544 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
3545 GETLE16(&psxVuw[clutP+tC1])|
3546 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3552 XAdjust=(posX>>16)%TWin.Position.x1;
3553 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
3554 YAdjust+(XAdjust>>1)];
3555 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
3556 GetTextureTransColG(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3559 if(NextRow_FT4()) return;
3563 ////////////////////////////////////////////////////////////////////////
3565 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)
3568 int32_t i,j,xmin,xmax,ymin,ymax;
3569 int32_t difX, difY, difX2, difY2;
3570 int32_t posX,posY,YAdjust,clutP,XAdjust;
3573 if(x1>drawW && x2>drawW && x3>drawW && x4>drawW) return;
3574 if(y1>drawH && y2>drawH && y3>drawH && y4>drawH) return;
3575 if(x1<drawX && x2<drawX && x3<drawX && x4<drawX) return;
3576 if(y1<drawY && y2<drawY && y3<drawY && y4<drawY) return;
3577 if(drawY>=drawH) return;
3578 if(drawX>=drawW) return;
3580 if(!SetupSections_FT4(x1,y1,x2,y2,x3,y3,x4,y4,tx1,ty1,tx2,ty2,tx3,ty3,tx4,ty4)) return;
3584 for(ymin=Ymin;ymin<drawY;ymin++)
3585 if(NextRow_FT4()) return;
3587 clutP=(clY<<10)+clX;
3589 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
3590 YAdjust+=(TWin.Position.y0<<11)+(TWin.Position.x0>>1);
3594 if(!bCheckMask && !DrawSemiTrans)
3596 for (i=ymin;i<=ymax;i++)
3598 xmin=(left_x >> 16);
3599 xmax=(right_x >> 16);
3608 difX=(right_u-posX)/num;
3609 difY=(right_v-posY)/num;
3614 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3615 xmax--;if(drawW<xmax) xmax=drawW;
3617 for(j=xmin;j<xmax;j+=2)
3619 XAdjust=(posX>>16)%TWin.Position.x1;
3620 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
3621 YAdjust+(XAdjust>>1)];
3622 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
3623 XAdjust=((posX+difX)>>16)%TWin.Position.x1;
3624 tC2 = psxVub[((((posY+difY)>>16)%TWin.Position.y1)<<11)+
3625 YAdjust+(XAdjust>>1)];
3626 tC2=(tC2>>((XAdjust&1)<<2))&0xf;
3628 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
3629 GETLE16(&psxVuw[clutP+tC1])|
3630 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3636 XAdjust=(posX>>16)%TWin.Position.x1;
3637 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
3638 YAdjust+(XAdjust>>1)];
3639 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
3640 GetTextureTransColG_S(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3643 if(NextRow_FT4()) return;
3650 for (i=ymin;i<=ymax;i++)
3652 xmin=(left_x >> 16);
3653 xmax=(right_x >> 16);
3662 difX=(right_u-posX)/num;
3663 difY=(right_v-posY)/num;
3668 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3669 xmax--;if(drawW<xmax) xmax=drawW;
3671 for(j=xmin;j<xmax;j+=2)
3673 XAdjust=(posX>>16)%TWin.Position.x1;
3674 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
3675 YAdjust+(XAdjust>>1)];
3676 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
3677 XAdjust=((posX+difX)>>16)%TWin.Position.x1;
3678 tC2 = psxVub[((((posY+difY)>>16)%TWin.Position.y1)<<11)+
3679 YAdjust+(XAdjust>>1)];
3680 tC2=(tC2>>((XAdjust&1)<<2))&0xf;
3682 GetTextureTransColG32_SPR((uint32_t *)&psxVuw[(i<<10)+j],
3683 GETLE16(&psxVuw[clutP+tC1])|
3684 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3690 XAdjust=(posX>>16)%TWin.Position.x1;
3691 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
3692 YAdjust+(XAdjust>>1)];
3693 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
3694 GetTextureTransColG_SPR(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3697 if(NextRow_FT4()) return;
3700 ////////////////////////////////////////////////////////////////////////
3701 // POLY 3 F-SHADED TEX PAL 8
3702 ////////////////////////////////////////////////////////////////////////
3704 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)
3706 int i,j,xmin,xmax,ymin,ymax;
3707 int32_t difX, difY,difX2, difY2;
3708 int32_t posX,posY,YAdjust,clutP;
3711 if(x1>drawW && x2>drawW && x3>drawW) return;
3712 if(y1>drawH && y2>drawH && y3>drawH) return;
3713 if(x1<drawX && x2<drawX && x3<drawX) return;
3714 if(y1<drawY && y2<drawY && y3<drawY) return;
3715 if(drawY>=drawH) return;
3716 if(drawX>=drawW) return;
3718 if(!SetupSections_FT(x1,y1,x2,y2,x3,y3,tx1,ty1,tx2,ty2,tx3,ty3)) return;
3722 for(ymin=Ymin;ymin<drawY;ymin++)
3723 if(NextRow_FT()) return;
3725 clutP=(clY<<10)+clX;
3727 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
3729 difX=delta_right_u;difX2=difX<<1;
3730 difY=delta_right_v;difY2=difY<<1;
3734 if(!bCheckMask && !DrawSemiTrans)
3736 for (i=ymin;i<=ymax;i++)
3738 xmin=(left_x >> 16);
3739 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!
3740 if(drawW<xmax) xmax=drawW;
3748 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3750 for(j=xmin;j<xmax;j+=2)
3752 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(posX>>16)];
3753 tC2 = psxVub[(((posY+difY)>>5)&(int32_t)0xFFFFF800)+YAdjust+
3755 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
3756 GETLE16(&psxVuw[clutP+tC1])|
3757 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3764 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(posX>>16)];
3765 GetTextureTransColG_S(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3778 for (i=ymin;i<=ymax;i++)
3780 xmin=(left_x >> 16);
3781 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!!!
3782 if(drawW<xmax) xmax=drawW;
3790 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3792 for(j=xmin;j<xmax;j+=2)
3794 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(posX>>16)];
3795 tC2 = psxVub[(((posY+difY)>>5)&(int32_t)0xFFFFF800)+YAdjust+
3797 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
3798 GETLE16(&psxVuw[clutP+tC1])|
3799 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3806 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(posX>>16)];
3807 GetTextureTransColG(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3818 ////////////////////////////////////////////////////////////////////////
3820 void drawPoly3TEx8_IL(short x1, short y1, short x2, short y2, short x3, short y3, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3,short clX, short clY)
3822 int i,j,xmin,xmax,ymin,ymax,n_xi,n_yi,TXV,TXU;
3823 int32_t difX, difY,difX2, difY2;
3824 int32_t posX,posY,YAdjust,clutP;
3827 if(x1>drawW && x2>drawW && x3>drawW) return;
3828 if(y1>drawH && y2>drawH && y3>drawH) return;
3829 if(x1<drawX && x2<drawX && x3<drawX) return;
3830 if(y1<drawY && y2<drawY && y3<drawY) return;
3831 if(drawY>=drawH) return;
3832 if(drawX>=drawW) return;
3834 if(!SetupSections_FT(x1,y1,x2,y2,x3,y3,tx1,ty1,tx2,ty2,tx3,ty3)) return;
3838 for(ymin=Ymin;ymin<drawY;ymin++)
3839 if(NextRow_FT()) return;
3841 clutP=(clY<<10)+clX;
3843 YAdjust=(GlobalTextAddrY<<10)+GlobalTextAddrX;
3845 difX=delta_right_u;difX2=difX<<1;
3846 difY=delta_right_v;difY2=difY<<1;
3850 if(!bCheckMask && !DrawSemiTrans)
3852 for (i=ymin;i<=ymax;i++)
3854 xmin=(left_x >> 16);
3855 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!
3856 if(drawW<xmax) xmax=drawW;
3864 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3866 for(j=xmin;j<xmax;j+=2)
3870 n_xi = ( ( TXU >> 1 ) & ~0x78 ) + ( ( TXU << 2 ) & 0x40 ) + ( ( TXV << 3 ) & 0x38 );
3871 n_yi = ( TXV & ~0x7 ) + ( ( TXU >> 5 ) & 0x7 );
3873 tC1= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((TXU & 0x01)<<3)) & 0xff;
3875 TXU=(posX+difX)>>16;
3876 TXV=(posY+difY)>>16;
3877 n_xi = ( ( TXU >> 1 ) & ~0x78 ) + ( ( TXU << 2 ) & 0x40 ) + ( ( TXV << 3 ) & 0x38 );
3878 n_yi = ( TXV & ~0x7 ) + ( ( TXU >> 5 ) & 0x7 );
3880 tC2= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((TXU & 0x01)<<3)) & 0xff;
3882 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
3883 GETLE16(&psxVuw[clutP+tC1])|
3884 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3893 n_xi = ( ( TXU >> 1 ) & ~0x78 ) + ( ( TXU << 2 ) & 0x40 ) + ( ( TXV << 3 ) & 0x38 );
3894 n_yi = ( TXV & ~0x7 ) + ( ( TXU >> 5 ) & 0x7 );
3896 tC1= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((TXU & 0x01)<<3)) & 0xff;
3898 GetTextureTransColG_S(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
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)
3929 n_xi = ( ( TXU >> 1 ) & ~0x78 ) + ( ( TXU << 2 ) & 0x40 ) + ( ( TXV << 3 ) & 0x38 );
3930 n_yi = ( TXV & ~0x7 ) + ( ( TXU >> 5 ) & 0x7 );
3932 tC1= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((TXU & 0x01)<<3)) & 0xff;
3934 TXU=(posX+difX)>>16;
3935 TXV=(posY+difY)>>16;
3936 n_xi = ( ( TXU >> 1 ) & ~0x78 ) + ( ( TXU << 2 ) & 0x40 ) + ( ( TXV << 3 ) & 0x38 );
3937 n_yi = ( TXV & ~0x7 ) + ( ( TXU >> 5 ) & 0x7 );
3939 tC2= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((TXU & 0x01)<<3)) & 0xff;
3941 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
3942 GETLE16(&psxVuw[clutP+tC1])|
3943 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3952 n_xi = ( ( TXU >> 1 ) & ~0x78 ) + ( ( TXU << 2 ) & 0x40 ) + ( ( TXV << 3 ) & 0x38 );
3953 n_yi = ( TXV & ~0x7 ) + ( ( TXU >> 5 ) & 0x7 );
3955 tC1= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((TXU & 0x01)<<3)) & 0xff;
3957 GetTextureTransColG(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3968 ////////////////////////////////////////////////////////////////////////
3970 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)
3972 int i,j,xmin,xmax,ymin,ymax;
3973 int32_t difX, difY,difX2, difY2;
3974 int32_t posX,posY,YAdjust,clutP;
3977 if(x1>drawW && x2>drawW && x3>drawW) return;
3978 if(y1>drawH && y2>drawH && y3>drawH) return;
3979 if(x1<drawX && x2<drawX && x3<drawX) return;
3980 if(y1<drawY && y2<drawY && y3<drawY) return;
3981 if(drawY>=drawH) return;
3982 if(drawX>=drawW) return;
3984 if(!SetupSections_FT(x1,y1,x2,y2,x3,y3,tx1,ty1,tx2,ty2,tx3,ty3)) return;
3988 for(ymin=Ymin;ymin<drawY;ymin++)
3989 if(NextRow_FT()) return;
3991 clutP=(clY<<10)+clX;
3993 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
3994 YAdjust+=(TWin.Position.y0<<11)+(TWin.Position.x0);
3996 difX=delta_right_u;difX2=difX<<1;
3997 difY=delta_right_v;difY2=difY<<1;
4001 if(!bCheckMask && !DrawSemiTrans)
4003 for (i=ymin;i<=ymax;i++)
4005 xmin=(left_x >> 16);
4006 xmax=(right_x >> 16);//-1; //!!!!!!!!!!!!!!!!
4007 if(xmax>xmin) xmax--;
4009 if(drawW<xmax) xmax=drawW;
4017 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
4019 for(j=xmin;j<xmax;j+=2)
4021 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
4022 YAdjust+((posX>>16)%TWin.Position.x1)];
4023 tC2 = psxVub[((((posY+difY)>>16)%TWin.Position.y1)<<11)+
4024 YAdjust+(((posX+difX)>>16)%TWin.Position.x1)];
4025 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
4026 GETLE16(&psxVuw[clutP+tC1])|
4027 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
4034 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
4035 YAdjust+((posX>>16)%TWin.Position.x1)];
4036 GetTextureTransColG_S(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
4049 for (i=ymin;i<=ymax;i++)
4051 xmin=(left_x >> 16);
4052 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!!!
4053 if(drawW<xmax) xmax=drawW;
4061 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
4063 for(j=xmin;j<xmax;j+=2)
4065 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
4066 YAdjust+((posX>>16)%TWin.Position.x1)];
4067 tC2 = psxVub[((((posY+difY)>>16)%TWin.Position.y1)<<11)+
4068 YAdjust+(((posX+difX)>>16)%TWin.Position.x1)];
4069 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
4070 GETLE16(&psxVuw[clutP+tC1])|
4071 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
4078 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
4079 YAdjust+((posX>>16)%TWin.Position.x1)];
4080 GetTextureTransColG(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
4091 ////////////////////////////////////////////////////////////////////////
4095 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)
4097 drawPoly3TEx8(x2,y2,x3,y3,x4,y4,
4098 tx2,ty2,tx3,ty3,tx4,ty4,
4101 drawPoly3TEx8(x1,y1,x2,y2,x4,y4,
4102 tx1,ty1,tx2,ty2,tx4,ty4,
4110 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)
4113 int32_t i,j,xmin,xmax,ymin,ymax;
4114 int32_t difX, difY, difX2, difY2;
4115 int32_t posX,posY,YAdjust,clutP;
4118 if(x1>drawW && x2>drawW && x3>drawW && x4>drawW) return;
4119 if(y1>drawH && y2>drawH && y3>drawH && y4>drawH) return;
4120 if(x1<drawX && x2<drawX && x3<drawX && x4<drawX) return;
4121 if(y1<drawY && y2<drawY && y3<drawY && y4<drawY) return;
4122 if(drawY>=drawH) return;
4123 if(drawX>=drawW) return;
4125 if(!SetupSections_FT4(x1,y1,x2,y2,x3,y3,x4,y4,tx1,ty1,tx2,ty2,tx3,ty3,tx4,ty4)) return;
4129 for(ymin=Ymin;ymin<drawY;ymin++)
4130 if(NextRow_FT4()) return;
4132 clutP=(clY<<10)+clX;
4134 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
4138 if(!bCheckMask && !DrawSemiTrans)
4140 for (i=ymin;i<=ymax;i++)
4142 xmin=(left_x >> 16);
4143 xmax=(right_x >> 16);
4152 difX=(right_u-posX)/num;
4153 difY=(right_v-posY)/num;
4158 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
4159 xmax--;if(drawW<xmax) xmax=drawW;
4161 for(j=xmin;j<xmax;j+=2)
4163 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(posX>>16)];
4164 tC2 = psxVub[(((posY+difY)>>5)&(int32_t)0xFFFFF800)+YAdjust+
4166 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
4167 GETLE16(&psxVuw[clutP+tC1])|
4168 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
4174 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(posX>>16)];
4175 GetTextureTransColG_S(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
4178 if(NextRow_FT4()) return;
4185 for (i=ymin;i<=ymax;i++)
4187 xmin=(left_x >> 16);
4188 xmax=(right_x >> 16);
4197 difX=(right_u-posX)/num;
4198 difY=(right_v-posY)/num;
4203 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
4204 xmax--;if(drawW<xmax) xmax=drawW;
4206 for(j=xmin;j<xmax;j+=2)
4208 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(posX>>16)];
4209 tC2 = psxVub[(((posY+difY)>>5)&(int32_t)0xFFFFF800)+YAdjust+
4211 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
4212 GETLE16(&psxVuw[clutP+tC1])|
4213 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
4219 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(posX>>16)];
4220 GetTextureTransColG(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
4223 if(NextRow_FT4()) return;
4227 ////////////////////////////////////////////////////////////////////////
4229 void drawPoly4TEx8_IL(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4,short clX, short clY)
4232 int32_t i,j,xmin,xmax,ymin,ymax,n_xi,n_yi,TXV,TXU;
4233 int32_t difX, difY, difX2, difY2;
4234 int32_t posX,posY,YAdjust,clutP;
4237 if(x1>drawW && x2>drawW && x3>drawW && x4>drawW) return;
4238 if(y1>drawH && y2>drawH && y3>drawH && y4>drawH) return;
4239 if(x1<drawX && x2<drawX && x3<drawX && x4<drawX) return;
4240 if(y1<drawY && y2<drawY && y3<drawY && y4<drawY) return;
4241 if(drawY>=drawH) return;
4242 if(drawX>=drawW) return;
4244 if(!SetupSections_FT4(x1,y1,x2,y2,x3,y3,x4,y4,tx1,ty1,tx2,ty2,tx3,ty3,tx4,ty4)) return;
4248 for(ymin=Ymin;ymin<drawY;ymin++)
4249 if(NextRow_FT4()) return;
4251 clutP=(clY<<10)+clX;
4253 YAdjust=(GlobalTextAddrY<<10)+GlobalTextAddrX;
4257 if(!bCheckMask && !DrawSemiTrans)
4259 for (i=ymin;i<=ymax;i++)
4261 xmin=(left_x >> 16);
4262 xmax=(right_x >> 16);
4271 difX=(right_u-posX)/num;
4272 difY=(right_v-posY)/num;
4277 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
4278 xmax--;if(drawW<xmax) xmax=drawW;
4280 for(j=xmin;j<xmax;j+=2)
4284 n_xi = ( ( TXU >> 1 ) & ~0x78 ) + ( ( TXU << 2 ) & 0x40 ) + ( ( TXV << 3 ) & 0x38 );
4285 n_yi = ( TXV & ~0x7 ) + ( ( TXU >> 5 ) & 0x7 );
4287 tC1= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((TXU & 0x01)<<3)) & 0xff;
4289 TXU=(posX+difX)>>16;
4290 TXV=(posY+difY)>>16;
4291 n_xi = ( ( TXU >> 1 ) & ~0x78 ) + ( ( TXU << 2 ) & 0x40 ) + ( ( TXV << 3 ) & 0x38 );
4292 n_yi = ( TXV & ~0x7 ) + ( ( TXU >> 5 ) & 0x7 );
4294 tC2= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((TXU & 0x01)<<3)) & 0xff;
4296 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
4297 GETLE16(&psxVuw[clutP+tC1])|
4298 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
4306 n_xi = ( ( TXU >> 1 ) & ~0x78 ) + ( ( TXU << 2 ) & 0x40 ) + ( ( TXV << 3 ) & 0x38 );
4307 n_yi = ( TXV & ~0x7 ) + ( ( TXU >> 5 ) & 0x7 );
4309 tC1= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((TXU & 0x01)<<3)) & 0xff;
4311 GetTextureTransColG_S(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
4314 if(NextRow_FT4()) return;
4321 for (i=ymin;i<=ymax;i++)
4323 xmin=(left_x >> 16);
4324 xmax=(right_x >> 16);
4333 difX=(right_u-posX)/num;
4334 difY=(right_v-posY)/num;
4339 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
4340 xmax--;if(drawW<xmax) xmax=drawW;
4342 for(j=xmin;j<xmax;j+=2)
4346 n_xi = ( ( TXU >> 1 ) & ~0x78 ) + ( ( TXU << 2 ) & 0x40 ) + ( ( TXV << 3 ) & 0x38 );
4347 n_yi = ( TXV & ~0x7 ) + ( ( TXU >> 5 ) & 0x7 );
4349 tC1= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((TXU & 0x01)<<3)) & 0xff;
4351 TXU=(posX+difX)>>16;
4352 TXV=(posY+difY)>>16;
4353 n_xi = ( ( TXU >> 1 ) & ~0x78 ) + ( ( TXU << 2 ) & 0x40 ) + ( ( TXV << 3 ) & 0x38 );
4354 n_yi = ( TXV & ~0x7 ) + ( ( TXU >> 5 ) & 0x7 );
4356 tC2= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((TXU & 0x01)<<3)) & 0xff;
4358 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
4359 GETLE16(&psxVuw[clutP+tC1])|
4360 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
4368 n_xi = ( ( TXU >> 1 ) & ~0x78 ) + ( ( TXU << 2 ) & 0x40 ) + ( ( TXV << 3 ) & 0x38 );
4369 n_yi = ( TXV & ~0x7 ) + ( ( TXU >> 5 ) & 0x7 );
4370 tC1= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((TXU & 0x01)<<3)) & 0xff;
4371 GetTextureTransColG(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
4374 if(NextRow_FT4()) return;
4378 ////////////////////////////////////////////////////////////////////////
4380 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)
4383 int32_t i,j,xmin,xmax,ymin,ymax;
4384 int32_t difX, difY, difX2, difY2;
4385 int32_t posX,posY,YAdjust,clutP;
4388 if(x1>drawW && x2>drawW && x3>drawW && x4>drawW) return;
4389 if(y1>drawH && y2>drawH && y3>drawH && y4>drawH) return;
4390 if(x1<drawX && x2<drawX && x3<drawX && x4<drawX) return;
4391 if(y1<drawY && y2<drawY && y3<drawY && y4<drawY) return;
4392 if(drawY>=drawH) return;
4393 if(drawX>=drawW) return;
4395 if(!SetupSections_FT4(x1,y1,x2,y2,x3,y3,x4,y4,tx1,ty1,tx2,ty2,tx3,ty3,tx4,ty4)) return;
4399 for(ymin=Ymin;ymin<drawY;ymin++)
4400 if(NextRow_FT4()) return;
4402 clutP=(clY<<10)+clX;
4404 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
4405 YAdjust+=(TWin.Position.y0<<11)+(TWin.Position.x0);
4409 if(!bCheckMask && !DrawSemiTrans)
4411 for (i=ymin;i<=ymax;i++)
4413 xmin=(left_x >> 16);
4414 xmax=(right_x >> 16);
4423 difX=(right_u-posX)/num;
4424 difY=(right_v-posY)/num;
4429 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
4430 xmax--;if(drawW<xmax) xmax=drawW;
4432 for(j=xmin;j<xmax;j+=2)
4434 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
4435 YAdjust+((posX>>16)%TWin.Position.x1)];
4436 tC2 = psxVub[((((posY+difY)>>16)%TWin.Position.y1)<<11)+
4437 YAdjust+(((posX+difX)>>16)%TWin.Position.x1)];
4438 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
4439 GETLE16(&psxVuw[clutP+tC1])|
4440 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
4446 tC1 = psxVub[((((posY+difY)>>16)%TWin.Position.y1)<<11)+
4447 YAdjust+((posX>>16)%TWin.Position.x1)];
4448 GetTextureTransColG_S(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
4451 if(NextRow_FT4()) return;
4459 for (i=ymin;i<=ymax;i++)
4461 xmin=(left_x >> 16);
4462 xmax=(right_x >> 16);
4471 difX=(right_u-posX)/num;
4472 difY=(right_v-posY)/num;
4477 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
4478 xmax--;if(drawW<xmax) xmax=drawW;
4480 for(j=xmin;j<xmax;j+=2)
4482 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
4483 YAdjust+((posX>>16)%TWin.Position.x1)];
4484 tC2 = psxVub[((((posY+difY)>>16)%TWin.Position.y1)<<11)+
4485 YAdjust+(((posX+difX)>>16)%TWin.Position.x1)];
4486 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
4487 GETLE16(&psxVuw[clutP+tC1])|
4488 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
4494 tC1 = psxVub[((((posY+difY)>>16)%TWin.Position.y1)<<11)+
4495 YAdjust+((posX>>16)%TWin.Position.x1)];
4496 GetTextureTransColG(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
4499 if(NextRow_FT4()) return;
4503 ////////////////////////////////////////////////////////////////////////
4505 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)
4508 int32_t i,j,xmin,xmax,ymin,ymax;
4509 int32_t difX, difY, difX2, difY2;
4510 int32_t posX,posY,YAdjust,clutP;
4513 if(x1>drawW && x2>drawW && x3>drawW && x4>drawW) return;
4514 if(y1>drawH && y2>drawH && y3>drawH && y4>drawH) return;
4515 if(x1<drawX && x2<drawX && x3<drawX && x4<drawX) return;
4516 if(y1<drawY && y2<drawY && y3<drawY && y4<drawY) return;
4517 if(drawY>=drawH) return;
4518 if(drawX>=drawW) return;
4520 if(!SetupSections_FT4(x1,y1,x2,y2,x3,y3,x4,y4,tx1,ty1,tx2,ty2,tx3,ty3,tx4,ty4)) return;
4524 for(ymin=Ymin;ymin<drawY;ymin++)
4525 if(NextRow_FT4()) return;
4527 clutP=(clY<<10)+clX;
4529 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
4530 YAdjust+=(TWin.Position.y0<<11)+(TWin.Position.x0);
4534 if(!bCheckMask && !DrawSemiTrans)
4536 for (i=ymin;i<=ymax;i++)
4538 xmin=(left_x >> 16);
4539 xmax=(right_x >> 16);
4548 difX=(right_u-posX)/num;
4549 difY=(right_v-posY)/num;
4554 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
4555 xmax--;if(drawW<xmax) xmax=drawW;
4557 for(j=xmin;j<xmax;j+=2)
4559 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
4560 YAdjust+((posX>>16)%TWin.Position.x1)];
4561 tC2 = psxVub[((((posY+difY)>>16)%TWin.Position.y1)<<11)+
4562 YAdjust+(((posX+difX)>>16)%TWin.Position.x1)];
4563 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
4564 GETLE16(&psxVuw[clutP+tC1])|
4565 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
4571 tC1 = psxVub[((((posY+difY)>>16)%TWin.Position.y1)<<11)+
4572 YAdjust+((posX>>16)%TWin.Position.x1)];
4573 GetTextureTransColG_S(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
4576 if(NextRow_FT4()) return;
4584 for (i=ymin;i<=ymax;i++)
4586 xmin=(left_x >> 16);
4587 xmax=(right_x >> 16);
4596 difX=(right_u-posX)/num;
4597 difY=(right_v-posY)/num;
4602 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
4603 xmax--;if(drawW<xmax) xmax=drawW;
4605 for(j=xmin;j<xmax;j+=2)
4607 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
4608 YAdjust+((posX>>16)%TWin.Position.x1)];
4609 tC2 = psxVub[((((posY+difY)>>16)%TWin.Position.y1)<<11)+
4610 YAdjust+(((posX+difX)>>16)%TWin.Position.x1)];
4611 GetTextureTransColG32_SPR((uint32_t *)&psxVuw[(i<<10)+j],
4612 GETLE16(&psxVuw[clutP+tC1])|
4613 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
4619 tC1 = psxVub[((((posY+difY)>>16)%TWin.Position.y1)<<11)+
4620 YAdjust+((posX>>16)%TWin.Position.x1)];
4621 GetTextureTransColG_SPR(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
4624 if(NextRow_FT4()) return;
4628 ////////////////////////////////////////////////////////////////////////
4629 // POLY 3 F-SHADED TEX 15 BIT
4630 ////////////////////////////////////////////////////////////////////////
4632 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)
4634 int i,j,xmin,xmax,ymin,ymax;
4635 int32_t difX, difY,difX2, difY2;
4638 if(x1>drawW && x2>drawW && x3>drawW) return;
4639 if(y1>drawH && y2>drawH && y3>drawH) return;
4640 if(x1<drawX && x2<drawX && x3<drawX) return;
4641 if(y1<drawY && y2<drawY && y3<drawY) return;
4642 if(drawY>=drawH) return;
4643 if(drawX>=drawW) return;
4645 if(!SetupSections_FT(x1,y1,x2,y2,x3,y3,tx1,ty1,tx2,ty2,tx3,ty3)) return;
4649 for(ymin=Ymin;ymin<drawY;ymin++)
4650 if(NextRow_FT()) return;
4652 difX=delta_right_u;difX2=difX<<1;
4653 difY=delta_right_v;difY2=difY<<1;
4657 if(!bCheckMask && !DrawSemiTrans)
4659 for (i=ymin;i<=ymax;i++)
4661 xmin=(left_x >> 16);
4662 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!
4663 if(drawW<xmax) xmax=drawW;
4671 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
4673 for(j=xmin;j<xmax;j+=2)
4675 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
4676 (((int32_t)GETLE16(&psxVuw[((((posY+difY)>>16)+GlobalTextAddrY)<<10)+((posX+difX)>>16)+GlobalTextAddrX]))<<16)|
4677 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+((posX)>>16)+GlobalTextAddrX]));
4683 GetTextureTransColG_S(&psxVuw[(i<<10)+j],
4684 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+(posX>>16)+GlobalTextAddrX]));
4696 for (i=ymin;i<=ymax;i++)
4698 xmin=(left_x >> 16);
4699 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!
4700 if(drawW<xmax) xmax=drawW;
4708 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
4710 for(j=xmin;j<xmax;j+=2)
4712 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
4713 (((int32_t)GETLE16(&psxVuw[((((posY+difY)>>16)+GlobalTextAddrY)<<10)+((posX+difX)>>16)+GlobalTextAddrX]))<<16)|
4714 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+((posX)>>16)+GlobalTextAddrX]));
4720 GetTextureTransColG(&psxVuw[(i<<10)+j],
4721 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+(posX>>16)+GlobalTextAddrX]));
4730 ////////////////////////////////////////////////////////////////////////
4732 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)
4734 int i,j,xmin,xmax,ymin,ymax;
4735 int32_t difX, difY,difX2, difY2;
4738 if(x1>drawW && x2>drawW && x3>drawW) return;
4739 if(y1>drawH && y2>drawH && y3>drawH) return;
4740 if(x1<drawX && x2<drawX && x3<drawX) return;
4741 if(y1<drawY && y2<drawY && y3<drawY) return;
4742 if(drawY>=drawH) return;
4743 if(drawX>=drawW) return;
4745 if(!SetupSections_FT(x1,y1,x2,y2,x3,y3,tx1,ty1,tx2,ty2,tx3,ty3)) return;
4749 for(ymin=Ymin;ymin<drawY;ymin++)
4750 if(NextRow_FT()) return;
4752 difX=delta_right_u;difX2=difX<<1;
4753 difY=delta_right_v;difY2=difY<<1;
4757 if(!bCheckMask && !DrawSemiTrans)
4759 for (i=ymin;i<=ymax;i++)
4761 xmin=(left_x >> 16);
4762 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!
4763 if(drawW<xmax) xmax=drawW;
4771 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
4773 for(j=xmin;j<xmax;j+=2)
4775 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
4776 (((int32_t)GETLE16(&psxVuw[(((((posY+difY)>>16)%TWin.Position.y1)+GlobalTextAddrY+TWin.Position.y0)<<10)+
4777 (((posX+difX)>>16)%TWin.Position.x1)+GlobalTextAddrX+TWin.Position.x0]))<<16)|
4778 GETLE16(&psxVuw[((((posY>>16)%TWin.Position.y1)+GlobalTextAddrY+TWin.Position.y0)<<10)+
4779 (((posX)>>16)%TWin.Position.x1)+GlobalTextAddrX+TWin.Position.x0]));
4785 GetTextureTransColG_S(&psxVuw[(i<<10)+j],
4786 GETLE16(&psxVuw[((((posY>>16)%TWin.Position.y1)+GlobalTextAddrY+TWin.Position.y0)<<10)+
4787 ((posX>>16)%TWin.Position.x1)+GlobalTextAddrX+TWin.Position.x0]));
4799 for (i=ymin;i<=ymax;i++)
4801 xmin=(left_x >> 16);
4802 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!
4803 if(drawW<xmax) xmax=drawW;
4811 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
4813 for(j=xmin;j<xmax;j+=2)
4815 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
4816 (((int32_t)GETLE16(&psxVuw[(((((posY+difY)>>16)%TWin.Position.y1)+GlobalTextAddrY+TWin.Position.y0)<<10)+
4817 (((posX+difX)>>16)%TWin.Position.x1)+GlobalTextAddrX+TWin.Position.x0]))<<16)|
4818 GETLE16(&psxVuw[((((posY>>16)%TWin.Position.y1)+GlobalTextAddrY+TWin.Position.y0)<<10)+
4819 (((posX)>>16)%TWin.Position.x1)+GlobalTextAddrX+TWin.Position.x0]));
4825 GetTextureTransColG(&psxVuw[(i<<10)+j],
4826 GETLE16(&psxVuw[((((posY>>16)%TWin.Position.y1)+GlobalTextAddrY+TWin.Position.y0)<<10)+
4827 ((posX>>16)%TWin.Position.x1)+GlobalTextAddrX+TWin.Position.x0]));
4837 ////////////////////////////////////////////////////////////////////////
4841 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)
4843 drawPoly3TD(x2,y2,x3,y3,x4,y4,
4844 tx2,ty2,tx3,ty3,tx4,ty4);
4845 drawPoly3TD(x1,y1,x2,y2,x4,y4,
4846 tx1,ty1,tx2,ty2,tx4,ty4);
4853 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)
4856 int32_t i,j,xmin,xmax,ymin,ymax;
4857 int32_t difX, difY, difX2, difY2;
4860 if(x1>drawW && x2>drawW && x3>drawW && x4>drawW) return;
4861 if(y1>drawH && y2>drawH && y3>drawH && y4>drawH) return;
4862 if(x1<drawX && x2<drawX && x3<drawX && x4<drawX) return;
4863 if(y1<drawY && y2<drawY && y3<drawY && y4<drawY) return;
4864 if(drawY>=drawH) return;
4865 if(drawX>=drawW) return;
4867 if(!SetupSections_FT4(x1,y1,x2,y2,x3,y3,x4,y4,tx1,ty1,tx2,ty2,tx3,ty3,tx4,ty4)) return;
4871 for(ymin=Ymin;ymin<drawY;ymin++)
4872 if(NextRow_FT4()) return;
4876 if(!bCheckMask && !DrawSemiTrans)
4878 for (i=ymin;i<=ymax;i++)
4880 xmin=(left_x >> 16);
4881 xmax=(right_x >> 16);
4890 difX=(right_u-posX)/num;
4891 difY=(right_v-posY)/num;
4896 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
4897 xmax--;if(drawW<xmax) xmax=drawW;
4899 for(j=xmin;j<xmax;j+=2)
4901 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
4902 (((int32_t)GETLE16(&psxVuw[((((posY+difY)>>16)+GlobalTextAddrY)<<10)+((posX+difX)>>16)+GlobalTextAddrX]))<<16)|
4903 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+((posX)>>16)+GlobalTextAddrX]));
4909 GetTextureTransColG_S(&psxVuw[(i<<10)+j],
4910 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+(posX>>16)+GlobalTextAddrX]));
4912 if(NextRow_FT4()) return;
4919 for (i=ymin;i<=ymax;i++)
4921 xmin=(left_x >> 16);
4922 xmax=(right_x >> 16);
4931 difX=(right_u-posX)/num;
4932 difY=(right_v-posY)/num;
4937 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
4938 xmax--;if(drawW<xmax) xmax=drawW;
4940 for(j=xmin;j<xmax;j+=2)
4942 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
4943 (((int32_t)GETLE16(&psxVuw[((((posY+difY)>>16)+GlobalTextAddrY)<<10)+((posX+difX)>>16)+GlobalTextAddrX]))<<16)|
4944 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+((posX)>>16)+GlobalTextAddrX]));
4950 GetTextureTransColG(&psxVuw[(i<<10)+j],
4951 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+(posX>>16)+GlobalTextAddrX]));
4953 if(NextRow_FT4()) return;
4957 ////////////////////////////////////////////////////////////////////////
4959 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)
4962 int32_t i,j,xmin,xmax,ymin,ymax;
4963 int32_t difX, difY, difX2, difY2;
4966 if(x1>drawW && x2>drawW && x3>drawW && x4>drawW) return;
4967 if(y1>drawH && y2>drawH && y3>drawH && y4>drawH) return;
4968 if(x1<drawX && x2<drawX && x3<drawX && x4<drawX) return;
4969 if(y1<drawY && y2<drawY && y3<drawY && y4<drawY) return;
4970 if(drawY>=drawH) return;
4971 if(drawX>=drawW) return;
4973 if(!SetupSections_FT4(x1,y1,x2,y2,x3,y3,x4,y4,tx1,ty1,tx2,ty2,tx3,ty3,tx4,ty4)) return;
4977 for(ymin=Ymin;ymin<drawY;ymin++)
4978 if(NextRow_FT4()) return;
4982 if(!bCheckMask && !DrawSemiTrans)
4984 for (i=ymin;i<=ymax;i++)
4986 xmin=(left_x >> 16);
4987 xmax=(right_x >> 16);
4996 difX=(right_u-posX)/num;
4997 difY=(right_v-posY)/num;
5002 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
5003 xmax--;if(drawW<xmax) xmax=drawW;
5005 for(j=xmin;j<xmax;j+=2)
5007 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
5008 (((int32_t)GETLE16(&psxVuw[(((((posY+difY)>>16)%TWin.Position.y1)+GlobalTextAddrY+TWin.Position.y0)<<10)+
5009 (((posX+difX)>>16)%TWin.Position.x1)+GlobalTextAddrX+TWin.Position.x0]))<<16)|
5010 GETLE16(&psxVuw[((((posY>>16)%TWin.Position.y1)+GlobalTextAddrY)<<10)+TWin.Position.y0+
5011 ((posX>>16)%TWin.Position.x1)+GlobalTextAddrX+TWin.Position.x0]));
5017 GetTextureTransColG_S(&psxVuw[(i<<10)+j],
5018 GETLE16(&psxVuw[((((posY>>16)%TWin.Position.y1)+GlobalTextAddrY+TWin.Position.y0)<<10)+
5019 ((posX>>16)%TWin.Position.x1)+GlobalTextAddrX+TWin.Position.x0]));
5021 if(NextRow_FT4()) return;
5028 for (i=ymin;i<=ymax;i++)
5030 xmin=(left_x >> 16);
5031 xmax=(right_x >> 16);
5040 difX=(right_u-posX)/num;
5041 difY=(right_v-posY)/num;
5046 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
5047 xmax--;if(drawW<xmax) xmax=drawW;
5049 for(j=xmin;j<xmax;j+=2)
5051 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
5052 (((int32_t)GETLE16(&psxVuw[(((((posY+difY)>>16)%TWin.Position.y1)+GlobalTextAddrY+TWin.Position.y0)<<10)+
5053 (((posX+difX)>>16)%TWin.Position.x1)+GlobalTextAddrX+TWin.Position.x0]))<<16)|
5054 GETLE16(&psxVuw[((((posY>>16)%TWin.Position.y1)+GlobalTextAddrY+TWin.Position.y0)<<10)+
5055 ((posX>>16)%TWin.Position.x1)+GlobalTextAddrX+TWin.Position.x0]));
5061 GetTextureTransColG(&psxVuw[(i<<10)+j],
5062 GETLE16(&psxVuw[((((posY>>16)%TWin.Position.y1)+GlobalTextAddrY+TWin.Position.y0)<<10)+
5063 ((posX>>16)%TWin.Position.x1)+GlobalTextAddrX+TWin.Position.x0]));
5065 if(NextRow_FT4()) return;
5069 ////////////////////////////////////////////////////////////////////////
5071 void drawPoly4TD_TW_S(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4)
5074 int32_t i,j,xmin,xmax,ymin,ymax;
5075 int32_t difX, difY, difX2, difY2;
5078 if(x1>drawW && x2>drawW && x3>drawW && x4>drawW) return;
5079 if(y1>drawH && y2>drawH && y3>drawH && y4>drawH) return;
5080 if(x1<drawX && x2<drawX && x3<drawX && x4<drawX) return;
5081 if(y1<drawY && y2<drawY && y3<drawY && y4<drawY) return;
5082 if(drawY>=drawH) return;
5083 if(drawX>=drawW) return;
5085 if(!SetupSections_FT4(x1,y1,x2,y2,x3,y3,x4,y4,tx1,ty1,tx2,ty2,tx3,ty3,tx4,ty4)) return;
5089 for(ymin=Ymin;ymin<drawY;ymin++)
5090 if(NextRow_FT4()) return;
5094 if(!bCheckMask && !DrawSemiTrans)
5096 for (i=ymin;i<=ymax;i++)
5098 xmin=(left_x >> 16);
5099 xmax=(right_x >> 16);
5108 difX=(right_u-posX)/num;
5109 difY=(right_v-posY)/num;
5114 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
5115 xmax--;if(drawW<xmax) xmax=drawW;
5117 for(j=xmin;j<xmax;j+=2)
5119 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
5120 (((int32_t)GETLE16(&psxVuw[(((((posY+difY)>>16)%TWin.Position.y1)+GlobalTextAddrY+TWin.Position.y0)<<10)+
5121 (((posX+difX)>>16)%TWin.Position.x1)+GlobalTextAddrX+TWin.Position.x0]))<<16)|
5122 GETLE16(&psxVuw[((((posY>>16)%TWin.Position.y1)+GlobalTextAddrY)<<10)+TWin.Position.y0+
5123 ((posX>>16)%TWin.Position.x1)+GlobalTextAddrX+TWin.Position.x0]));
5129 GetTextureTransColG_S(&psxVuw[(i<<10)+j],
5130 GETLE16(&psxVuw[((((posY>>16)%TWin.Position.y1)+GlobalTextAddrY+TWin.Position.y0)<<10)+
5131 ((posX>>16)%TWin.Position.x1)+GlobalTextAddrX+TWin.Position.x0]));
5133 if(NextRow_FT4()) return;
5140 for (i=ymin;i<=ymax;i++)
5142 xmin=(left_x >> 16);
5143 xmax=(right_x >> 16);
5152 difX=(right_u-posX)/num;
5153 difY=(right_v-posY)/num;
5158 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
5159 xmax--;if(drawW<xmax) xmax=drawW;
5161 for(j=xmin;j<xmax;j+=2)
5163 GetTextureTransColG32_SPR((uint32_t *)&psxVuw[(i<<10)+j],
5164 (((int32_t)GETLE16(&psxVuw[(((((posY+difY)>>16)%TWin.Position.y1)+GlobalTextAddrY+TWin.Position.y0)<<10)+
5165 (((posX+difX)>>16)%TWin.Position.x1)+GlobalTextAddrX+TWin.Position.x0]))<<16)|
5166 GETLE16(&psxVuw[((((posY>>16)%TWin.Position.y1)+GlobalTextAddrY+TWin.Position.y0)<<10)+
5167 ((posX>>16)%TWin.Position.x1)+GlobalTextAddrX+TWin.Position.x0]));
5173 GetTextureTransColG_SPR(&psxVuw[(i<<10)+j],
5174 GETLE16(&psxVuw[((((posY>>16)%TWin.Position.y1)+GlobalTextAddrY+TWin.Position.y0)<<10)+
5175 ((posX>>16)%TWin.Position.x1)+GlobalTextAddrX+TWin.Position.x0]));
5177 if(NextRow_FT4()) return;
5181 ////////////////////////////////////////////////////////////////////////
5182 // POLY 3/4 G-SHADED
5183 ////////////////////////////////////////////////////////////////////////
5185 __inline void drawPoly3Gi(short x1,short y1,short x2,short y2,short x3,short y3,int32_t rgb1, int32_t rgb2, int32_t rgb3)
5187 int i,j,xmin,xmax,ymin,ymax;
5188 int32_t cR1,cG1,cB1;
5189 int32_t difR,difB,difG,difR2,difB2,difG2;
5191 if(x1>drawW && x2>drawW && x3>drawW) return;
5192 if(y1>drawH && y2>drawH && y3>drawH) return;
5193 if(x1<drawX && x2<drawX && x3<drawX) return;
5194 if(y1<drawY && y2<drawY && y3<drawY) return;
5195 if(drawY>=drawH) return;
5196 if(drawX>=drawW) return;
5198 if(!SetupSections_G(x1,y1,x2,y2,x3,y3,rgb1,rgb2,rgb3)) return;
5202 for(ymin=Ymin;ymin<drawY;ymin++)
5203 if(NextRow_G()) return;
5214 if(!bCheckMask && !DrawSemiTrans && iDither!=2)
5216 for (i=ymin;i<=ymax;i++)
5218 xmin=(left_x >> 16);
5219 xmax=(right_x >> 16)-1;if(drawW<xmax) xmax=drawW;
5228 {j=drawX-xmin;xmin=drawX;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
5230 for(j=xmin;j<xmax;j+=2)
5232 PUTLE32(((uint32_t *)&psxVuw[(i<<10)+j]),
5233 ((((cR1+difR) <<7)&0x7c000000)|(((cG1+difG) << 2)&0x03e00000)|(((cB1+difB)>>3)&0x001f0000)|
5234 (((cR1) >> 9)&0x7c00)|(((cG1) >> 14)&0x03e0)|(((cB1) >> 19)&0x001f))|lSetMask);
5241 PUTLE16(&psxVuw[(i<<10)+j], (((cR1 >> 9)&0x7c00)|((cG1 >> 14)&0x03e0)|((cB1 >> 19)&0x001f))|sSetMask);
5243 if(NextRow_G()) return;
5251 for (i=ymin;i<=ymax;i++)
5253 xmin=(left_x >> 16);
5254 xmax=(right_x >> 16)-1;if(drawW<xmax) xmax=drawW;
5263 {j=drawX-xmin;xmin=drawX;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
5265 for(j=xmin;j<=xmax;j++)
5267 GetShadeTransCol_Dither(&psxVuw[(i<<10)+j],(cB1>>16),(cG1>>16),(cR1>>16));
5274 if(NextRow_G()) return;
5277 for (i=ymin;i<=ymax;i++)
5279 xmin=(left_x >> 16);
5280 xmax=(right_x >> 16)-1;if(drawW<xmax) xmax=drawW;
5289 {j=drawX-xmin;xmin=drawX;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
5291 for(j=xmin;j<=xmax;j++)
5293 GetShadeTransCol(&psxVuw[(i<<10)+j],((cR1 >> 9)&0x7c00)|((cG1 >> 14)&0x03e0)|((cB1 >> 19)&0x001f));
5300 if(NextRow_G()) return;
5305 ////////////////////////////////////////////////////////////////////////
5307 void drawPoly3G(int32_t rgb1, int32_t rgb2, int32_t rgb3)
5309 drawPoly3Gi(lx0,ly0,lx1,ly1,lx2,ly2,rgb1,rgb2,rgb3);
5312 // draw two g-shaded tris for right psx shading emulation
5314 void drawPoly4G(int32_t rgb1, int32_t rgb2, int32_t rgb3, int32_t rgb4)
5316 drawPoly3Gi(lx1,ly1,lx3,ly3,lx2,ly2,
5318 drawPoly3Gi(lx0,ly0,lx1,ly1,lx2,ly2,
5322 ////////////////////////////////////////////////////////////////////////
5323 // POLY 3/4 G-SHADED TEX PAL4
5324 ////////////////////////////////////////////////////////////////////////
5326 void drawPoly3TGEx4(short x1, short y1, short x2, short y2, short x3, short y3, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short clX, short clY,int32_t col1, int32_t col2, int32_t col3)
5328 int i,j,xmin,xmax,ymin,ymax;
5329 int32_t cR1,cG1,cB1;
5330 int32_t difR,difB,difG,difR2,difB2,difG2;
5331 int32_t difX, difY,difX2, difY2;
5332 int32_t posX,posY,YAdjust,clutP,XAdjust;
5335 if(x1>drawW && x2>drawW && x3>drawW) return;
5336 if(y1>drawH && y2>drawH && y3>drawH) return;
5337 if(x1<drawX && x2<drawX && x3<drawX) return;
5338 if(y1<drawY && y2<drawY && y3<drawY) return;
5339 if(drawY>=drawH) return;
5340 if(drawX>=drawW) return;
5342 if(!SetupSections_GT(x1,y1,x2,y2,x3,y3,tx1,ty1,tx2,ty2,tx3,ty3,col1,col2,col3)) return;
5346 for(ymin=Ymin;ymin<drawY;ymin++)
5347 if(NextRow_GT()) return;
5349 clutP=(clY<<10)+clX;
5351 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
5360 difX=delta_right_u;difX2=difX<<1;
5361 difY=delta_right_v;difY2=difY<<1;
5365 if(!bCheckMask && !DrawSemiTrans && !iDither)
5367 for (i=ymin;i<=ymax;i++)
5369 xmin=((left_x) >> 16);
5370 xmax=((right_x) >> 16)-1; //!!!!!!!!!!!!!
5371 if(drawW<xmax) xmax=drawW;
5382 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
5384 for(j=xmin;j<xmax;j+=2)
5387 tC1 = psxVub[((posY>>5)&0xFFFFF800)+YAdjust+(XAdjust>>1)];
5388 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
5389 XAdjust=((posX+difX)>>16);
5390 tC2 = psxVub[(((posY+difY)>>5)&(int32_t)0xFFFFF800)+YAdjust+
5392 tC2=(tC2>>((XAdjust&1)<<2))&0xf;
5394 GetTextureTransColGX32_S((uint32_t *)&psxVuw[(i<<10)+j],
5395 GETLE16(&psxVuw[clutP+tC1])|
5396 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16,
5397 (cB1>>16)|((cB1+difB)&0xff0000),
5398 (cG1>>16)|((cG1+difG)&0xff0000),
5399 (cR1>>16)|((cR1+difR)&0xff0000));
5409 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(XAdjust>>1)];
5410 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
5411 GetTextureTransColGX_S(&psxVuw[(i<<10)+j],
5412 GETLE16(&psxVuw[clutP+tC1]),
5413 (cB1>>16),(cG1>>16),(cR1>>16));
5426 for (i=ymin;i<=ymax;i++)
5428 xmin=(left_x >> 16);
5429 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!!
5430 if(drawW<xmax) xmax=drawW;
5441 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
5443 for(j=xmin;j<=xmax;j++)
5446 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(XAdjust>>1)];
5447 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
5449 GetTextureTransColGX_Dither(&psxVuw[(i<<10)+j],
5450 GETLE16(&psxVuw[clutP+tC1]),
5451 (cB1>>16),(cG1>>16),(cR1>>16));
5453 GetTextureTransColGX(&psxVuw[(i<<10)+j],
5454 GETLE16(&psxVuw[clutP+tC1]),
5455 (cB1>>16),(cG1>>16),(cR1>>16));
5470 ////////////////////////////////////////////////////////////////////////
5472 void drawPoly3TGEx4_IL(short x1, short y1, short x2, short y2, short x3, short y3, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short clX, short clY,int32_t col1, int32_t col2, int32_t col3)
5474 int i,j,xmin,xmax,ymin,ymax,n_xi,n_yi,TXV;
5475 int32_t cR1,cG1,cB1;
5476 int32_t difR,difB,difG,difR2,difB2,difG2;
5477 int32_t difX, difY,difX2, difY2;
5478 int32_t posX,posY,YAdjust,clutP,XAdjust;
5481 if(x1>drawW && x2>drawW && x3>drawW) return;
5482 if(y1>drawH && y2>drawH && y3>drawH) return;
5483 if(x1<drawX && x2<drawX && x3<drawX) return;
5484 if(y1<drawY && y2<drawY && y3<drawY) return;
5485 if(drawY>=drawH) return;
5486 if(drawX>=drawW) return;
5488 if(!SetupSections_GT(x1,y1,x2,y2,x3,y3,tx1,ty1,tx2,ty2,tx3,ty3,col1,col2,col3)) return;
5492 for(ymin=Ymin;ymin<drawY;ymin++)
5493 if(NextRow_GT()) return;
5495 clutP=(clY<<10)+clX;
5497 YAdjust=(GlobalTextAddrY<<10)+GlobalTextAddrX;
5506 difX=delta_right_u;difX2=difX<<1;
5507 difY=delta_right_v;difY2=difY<<1;
5511 if(!bCheckMask && !DrawSemiTrans && !iDither)
5513 for (i=ymin;i<=ymax;i++)
5515 xmin=((left_x) >> 16);
5516 xmax=((right_x) >> 16)-1; //!!!!!!!!!!!!!
5517 if(drawW<xmax) xmax=drawW;
5528 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
5530 for(j=xmin;j<xmax;j+=2)
5535 n_xi = ( ( XAdjust >> 2 ) & ~0x3c ) + ( ( TXV << 2 ) & 0x3c );
5536 n_yi = ( TXV & ~0xf ) + ( ( XAdjust >> 4 ) & 0xf );
5538 tC1= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((XAdjust & 0x03)<<2)) & 0x0f ;
5540 XAdjust=((posX+difX)>>16);
5542 TXV=(posY+difY)>>16;
5543 n_xi = ( ( XAdjust >> 2 ) & ~0x3c ) + ( ( TXV << 2 ) & 0x3c );
5544 n_yi = ( TXV & ~0xf ) + ( ( XAdjust >> 4 ) & 0xf );
5546 tC2= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((XAdjust & 0x03)<<2)) & 0x0f ;
5548 GetTextureTransColGX32_S((uint32_t *)&psxVuw[(i<<10)+j],
5549 GETLE16(&psxVuw[clutP+tC1])|
5550 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16,
5551 (cB1>>16)|((cB1+difB)&0xff0000),
5552 (cG1>>16)|((cG1+difG)&0xff0000),
5553 (cR1>>16)|((cR1+difR)&0xff0000));
5565 n_xi = ( ( XAdjust >> 2 ) & ~0x3c ) + ( ( TXV << 2 ) & 0x3c );
5566 n_yi = ( TXV & ~0xf ) + ( ( XAdjust >> 4 ) & 0xf );
5568 tC1= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((XAdjust & 0x03)<<2)) & 0x0f ;
5570 GetTextureTransColGX_S(&psxVuw[(i<<10)+j],
5571 GETLE16(&psxVuw[clutP+tC1]),
5572 (cB1>>16),(cG1>>16),(cR1>>16));
5585 for (i=ymin;i<=ymax;i++)
5587 xmin=(left_x >> 16);
5588 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!!
5589 if(drawW<xmax) xmax=drawW;
5600 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
5602 for(j=xmin;j<=xmax;j++)
5607 n_xi = ( ( XAdjust >> 2 ) & ~0x3c ) + ( ( TXV << 2 ) & 0x3c );
5608 n_yi = ( TXV & ~0xf ) + ( ( XAdjust >> 4 ) & 0xf );
5610 tC1= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((XAdjust & 0x03)<<2)) & 0x0f ;
5613 GetTextureTransColGX_Dither(&psxVuw[(i<<10)+j],
5614 GETLE16(&psxVuw[clutP+tC1]),
5615 (cB1>>16),(cG1>>16),(cR1>>16));
5617 GetTextureTransColGX(&psxVuw[(i<<10)+j],
5618 GETLE16(&psxVuw[clutP+tC1]),
5619 (cB1>>16),(cG1>>16),(cR1>>16));
5634 ////////////////////////////////////////////////////////////////////////
5636 void drawPoly3TGEx4_TW(short x1, short y1, short x2, short y2, short x3, short y3, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short clX, short clY,int32_t col1, int32_t col2, int32_t col3)
5638 int i,j,xmin,xmax,ymin,ymax;
5639 int32_t cR1,cG1,cB1;
5640 int32_t difR,difB,difG,difR2,difB2,difG2;
5641 int32_t difX, difY,difX2, difY2;
5642 int32_t posX,posY,YAdjust,clutP,XAdjust;
5645 if(x1>drawW && x2>drawW && x3>drawW) return;
5646 if(y1>drawH && y2>drawH && y3>drawH) return;
5647 if(x1<drawX && x2<drawX && x3<drawX) return;
5648 if(y1<drawY && y2<drawY && y3<drawY) return;
5649 if(drawY>=drawH) return;
5650 if(drawX>=drawW) return;
5652 if(!SetupSections_GT(x1,y1,x2,y2,x3,y3,tx1,ty1,tx2,ty2,tx3,ty3,col1,col2,col3)) return;
5656 for(ymin=Ymin;ymin<drawY;ymin++)
5657 if(NextRow_GT()) return;
5659 clutP=(clY<<10)+clX;
5661 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
5662 YAdjust+=(TWin.Position.y0<<11)+(TWin.Position.x0>>1);
5671 difX=delta_right_u;difX2=difX<<1;
5672 difY=delta_right_v;difY2=difY<<1;
5676 if(!bCheckMask && !DrawSemiTrans && !iDither)
5678 for (i=ymin;i<=ymax;i++)
5680 xmin=((left_x) >> 16);
5681 xmax=((right_x) >> 16)-1; //!!!!!!!!!!!!!
5682 if(drawW<xmax) xmax=drawW;
5693 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
5695 for(j=xmin;j<xmax;j+=2)
5697 XAdjust=(posX>>16)%TWin.Position.x1;
5698 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
5699 YAdjust+(XAdjust>>1)];
5700 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
5701 XAdjust=((posX+difX)>>16)%TWin.Position.x1;
5702 tC2 = psxVub[((((posY+difY)>>16)%TWin.Position.y1)<<11)+
5703 YAdjust+(XAdjust>>1)];
5704 tC2=(tC2>>((XAdjust&1)<<2))&0xf;
5705 GetTextureTransColGX32_S((uint32_t *)&psxVuw[(i<<10)+j],
5706 GETLE16(&psxVuw[clutP+tC1])|
5707 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16,
5708 (cB1>>16)|((cB1+difB)&0xff0000),
5709 (cG1>>16)|((cG1+difG)&0xff0000),
5710 (cR1>>16)|((cR1+difR)&0xff0000));
5719 XAdjust=(posX>>16)%TWin.Position.x1;
5720 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
5721 YAdjust+(XAdjust>>1)];
5722 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
5723 GetTextureTransColGX_S(&psxVuw[(i<<10)+j],
5724 GETLE16(&psxVuw[clutP+tC1]),
5725 (cB1>>16),(cG1>>16),(cR1>>16));
5738 for (i=ymin;i<=ymax;i++)
5740 xmin=(left_x >> 16);
5741 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!!
5742 if(drawW<xmax) xmax=drawW;
5753 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
5755 for(j=xmin;j<=xmax;j++)
5757 XAdjust=(posX>>16)%TWin.Position.x1;
5758 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
5759 YAdjust+(XAdjust>>1)];
5760 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
5762 GetTextureTransColGX_Dither(&psxVuw[(i<<10)+j],
5763 GETLE16(&psxVuw[clutP+tC1]),
5764 (cB1>>16),(cG1>>16),(cR1>>16));
5766 GetTextureTransColGX(&psxVuw[(i<<10)+j],
5767 GETLE16(&psxVuw[clutP+tC1]),
5768 (cB1>>16),(cG1>>16),(cR1>>16));
5783 ////////////////////////////////////////////////////////////////////////
5785 // note: the psx is doing g-shaded quads as two g-shaded tris,
5786 // like the following func... sadly texturing is not 100%
5787 // correct that way, so small texture distortions can
5790 void drawPoly4TGEx4_TRI_IL(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4,
5791 short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4,
5792 short clX, short clY,
5793 int32_t col1, int32_t col2, int32_t col3, int32_t col4)
5795 drawPoly3TGEx4_IL(x2,y2,x3,y3,x4,y4,
5796 tx2,ty2,tx3,ty3,tx4,ty4,
5799 drawPoly3TGEx4_IL(x1,y1,x2,y2,x4,y4,
5800 tx1,ty1,tx2,ty2,tx4,ty4,
5807 void drawPoly4TGEx4_TRI(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4,
5808 short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4,
5809 short clX, short clY,
5810 int32_t col1, int32_t col2, int32_t col3, int32_t col4)
5812 drawPoly3TGEx4(x2,y2,x3,y3,x4,y4,
5813 tx2,ty2,tx3,ty3,tx4,ty4,
5816 drawPoly3TGEx4(x1,y1,x2,y2,x4,y4,
5817 tx1,ty1,tx2,ty2,tx4,ty4,
5824 ////////////////////////////////////////////////////////////////////////
5826 void drawPoly4TGEx4(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4,
5827 short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4,
5828 short clX, short clY,
5829 int32_t col1, int32_t col2, int32_t col4, int32_t col3)
5832 int32_t i,j,xmin,xmax,ymin,ymax;
5833 int32_t cR1,cG1,cB1;
5834 int32_t difR,difB,difG,difR2,difB2,difG2;
5835 int32_t difX, difY, difX2, difY2;
5836 int32_t posX,posY,YAdjust,clutP,XAdjust;
5839 if(x1>drawW && x2>drawW && x3>drawW && x4>drawW) return;
5840 if(y1>drawH && y2>drawH && y3>drawH && y4>drawH) return;
5841 if(x1<drawX && x2<drawX && x3<drawX && x4<drawX) return;
5842 if(y1<drawY && y2<drawY && y3<drawY && y4<drawY) return;
5843 if(drawY>=drawH) return;
5844 if(drawX>=drawW) return;
5846 if(!SetupSections_GT4(x1,y1,x2,y2,x3,y3,x4,y4,tx1,ty1,tx2,ty2,tx3,ty3,tx4,ty4,col1,col2,col3,col4)) return;
5850 for(ymin=Ymin;ymin<drawY;ymin++)
5851 if(NextRow_GT4()) return;
5853 clutP=(clY<<10)+clX;
5855 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
5860 if(!bCheckMask && !DrawSemiTrans && !iDither)
5862 for (i=ymin;i<=ymax;i++)
5864 xmin=(left_x >> 16);
5865 xmax=(right_x >> 16);
5874 difX=(right_u-posX)/num;
5875 difY=(right_v-posY)/num;
5882 difR=(right_R-cR1)/num;
5883 difG=(right_G-cG1)/num;
5884 difB=(right_B-cB1)/num;
5890 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
5891 xmax--;if(drawW<xmax) xmax=drawW;
5893 for(j=xmin;j<xmax;j+=2)
5896 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(XAdjust>>1)];
5897 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
5898 XAdjust=((posX+difX)>>16);
5899 tC2 = psxVub[(((posY+difY)>>5)&(int32_t)0xFFFFF800)+YAdjust+
5901 tC2=(tC2>>((XAdjust&1)<<2))&0xf;
5903 GetTextureTransColGX32_S((uint32_t *)&psxVuw[(i<<10)+j],
5904 GETLE16(&psxVuw[clutP+tC1])|
5905 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16,
5906 (cB1>>16)|((cB1+difB)&0xff0000),
5907 (cG1>>16)|((cG1+difG)&0xff0000),
5908 (cR1>>16)|((cR1+difR)&0xff0000));
5918 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+
5920 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
5922 GetTextureTransColGX_S(&psxVuw[(i<<10)+j],
5923 GETLE16(&psxVuw[clutP+tC1]),
5924 (cB1>>16),(cG1>>16),(cR1>>16));
5927 if(NextRow_GT4()) return;
5934 for (i=ymin;i<=ymax;i++)
5936 xmin=(left_x >> 16);
5937 xmax=(right_x >> 16);
5946 difX=(right_u-posX)/num;
5947 difY=(right_v-posY)/num;
5954 difR=(right_R-cR1)/num;
5955 difG=(right_G-cG1)/num;
5956 difB=(right_B-cB1)/num;
5962 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
5963 xmax--;if(drawW<xmax) xmax=drawW;
5965 for(j=xmin;j<=xmax;j++)
5968 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+
5970 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
5972 GetTextureTransColGX_Dither(&psxVuw[(i<<10)+j],
5973 GETLE16(&psxVuw[clutP+tC1]),
5974 (cB1>>16),(cG1>>16),(cR1>>16));
5976 GetTextureTransColGX(&psxVuw[(i<<10)+j],
5977 GETLE16(&psxVuw[clutP+tC1]),
5978 (cB1>>16),(cG1>>16),(cR1>>16));
5986 if(NextRow_GT4()) return;
5990 ////////////////////////////////////////////////////////////////////////
5992 void drawPoly4TGEx4_TW(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4,
5993 short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4,
5994 short clX, short clY,
5995 int32_t col1, int32_t col2, int32_t col3, int32_t col4)
5997 drawPoly3TGEx4_TW(x2,y2,x3,y3,x4,y4,
5998 tx2,ty2,tx3,ty3,tx4,ty4,
6002 drawPoly3TGEx4_TW(x1,y1,x2,y2,x4,y4,
6003 tx1,ty1,tx2,ty2,tx4,ty4,
6008 ////////////////////////////////////////////////////////////////////////
6009 // POLY 3/4 G-SHADED TEX PAL8
6010 ////////////////////////////////////////////////////////////////////////
6012 void drawPoly3TGEx8(short x1, short y1, short x2, short y2, short x3, short y3, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short clX, short clY,int32_t col1, int32_t col2, int32_t col3)
6014 int i,j,xmin,xmax,ymin,ymax;
6015 int32_t cR1,cG1,cB1;
6016 int32_t difR,difB,difG,difR2,difB2,difG2;
6017 int32_t difX, difY,difX2, difY2;
6018 int32_t posX,posY,YAdjust,clutP;
6021 if(x1>drawW && x2>drawW && x3>drawW) return;
6022 if(y1>drawH && y2>drawH && y3>drawH) return;
6023 if(x1<drawX && x2<drawX && x3<drawX) return;
6024 if(y1<drawY && y2<drawY && y3<drawY) return;
6025 if(drawY>=drawH) return;
6026 if(drawX>=drawW) return;
6028 if(!SetupSections_GT(x1,y1,x2,y2,x3,y3,tx1,ty1,tx2,ty2,tx3,ty3,col1,col2,col3)) return;
6032 for(ymin=Ymin;ymin<drawY;ymin++)
6033 if(NextRow_GT()) return;
6035 clutP=(clY<<10)+clX;
6037 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
6045 difX=delta_right_u;difX2=difX<<1;
6046 difY=delta_right_v;difY2=difY<<1;
6050 if(!bCheckMask && !DrawSemiTrans && !iDither)
6052 for (i=ymin;i<=ymax;i++)
6054 xmin=(left_x >> 16);
6055 xmax=(right_x >> 16)-1; // !!!!!!!!!!!!!
6056 if(drawW<xmax) xmax=drawW;
6067 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
6069 for(j=xmin;j<xmax;j+=2)
6071 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+((posX>>16))];
6072 tC2 = psxVub[(((posY+difY)>>5)&(int32_t)0xFFFFF800)+YAdjust+
6073 (((posX+difX)>>16))];
6074 GetTextureTransColGX32_S((uint32_t *)&psxVuw[(i<<10)+j],
6075 GETLE16(&psxVuw[clutP+tC1])|
6076 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16,
6077 (cB1>>16)|((cB1+difB)&0xff0000),
6078 (cG1>>16)|((cG1+difG)&0xff0000),
6079 (cR1>>16)|((cR1+difR)&0xff0000));
6088 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+((posX>>16))];
6089 GetTextureTransColGX_S(&psxVuw[(i<<10)+j],
6090 GETLE16(&psxVuw[clutP+tC1]),
6091 (cB1>>16),(cG1>>16),(cR1>>16));
6104 for (i=ymin;i<=ymax;i++)
6106 xmin=(left_x >> 16);
6107 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!!!!!!!!!
6108 if(drawW<xmax) xmax=drawW;
6119 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
6121 for(j=xmin;j<=xmax;j++)
6123 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+((posX>>16))];
6125 GetTextureTransColGX_Dither(&psxVuw[(i<<10)+j],
6126 GETLE16(&psxVuw[clutP+tC1]),
6127 (cB1>>16),(cG1>>16),(cR1>>16));
6129 GetTextureTransColGX(&psxVuw[(i<<10)+j],
6130 GETLE16(&psxVuw[clutP+tC1]),
6131 (cB1>>16),(cG1>>16),(cR1>>16));
6146 ////////////////////////////////////////////////////////////////////////
6148 void drawPoly3TGEx8_IL(short x1, short y1, short x2, short y2, short x3, short y3, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short clX, short clY,int32_t col1, int32_t col2, int32_t col3)
6150 int i,j,xmin,xmax,ymin,ymax,n_xi,n_yi,TXV,TXU;
6151 int32_t cR1,cG1,cB1;
6152 int32_t difR,difB,difG,difR2,difB2,difG2;
6153 int32_t difX, difY,difX2, difY2;
6154 int32_t posX,posY,YAdjust,clutP;
6157 if(x1>drawW && x2>drawW && x3>drawW) return;
6158 if(y1>drawH && y2>drawH && y3>drawH) return;
6159 if(x1<drawX && x2<drawX && x3<drawX) return;
6160 if(y1<drawY && y2<drawY && y3<drawY) return;
6161 if(drawY>=drawH) return;
6162 if(drawX>=drawW) return;
6164 if(!SetupSections_GT(x1,y1,x2,y2,x3,y3,tx1,ty1,tx2,ty2,tx3,ty3,col1,col2,col3)) return;
6168 for(ymin=Ymin;ymin<drawY;ymin++)
6169 if(NextRow_GT()) return;
6171 clutP=(clY<<10)+clX;
6173 YAdjust=(GlobalTextAddrY<<10)+GlobalTextAddrX;
6181 difX=delta_right_u;difX2=difX<<1;
6182 difY=delta_right_v;difY2=difY<<1;
6186 if(!bCheckMask && !DrawSemiTrans && !iDither)
6188 for (i=ymin;i<=ymax;i++)
6190 xmin=(left_x >> 16);
6191 xmax=(right_x >> 16)-1; // !!!!!!!!!!!!!
6192 if(drawW<xmax) xmax=drawW;
6203 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
6205 for(j=xmin;j<xmax;j+=2)
6209 n_xi = ( ( TXU >> 1 ) & ~0x78 ) + ( ( TXU << 2 ) & 0x40 ) + ( ( TXV << 3 ) & 0x38 );
6210 n_yi = ( TXV & ~0x7 ) + ( ( TXU >> 5 ) & 0x7 );
6212 tC1= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((TXU & 0x01)<<3)) & 0xff;
6214 TXU=(posX+difX)>>16;
6215 TXV=(posY+difY)>>16;
6216 n_xi = ( ( TXU >> 1 ) & ~0x78 ) + ( ( TXU << 2 ) & 0x40 ) + ( ( TXV << 3 ) & 0x38 );
6217 n_yi = ( TXV & ~0x7 ) + ( ( TXU >> 5 ) & 0x7 );
6219 tC2= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((TXU & 0x01)<<3)) & 0xff;
6221 GetTextureTransColGX32_S((uint32_t *)&psxVuw[(i<<10)+j],
6222 GETLE16(&psxVuw[clutP+tC1])|
6223 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16,
6224 (cB1>>16)|((cB1+difB)&0xff0000),
6225 (cG1>>16)|((cG1+difG)&0xff0000),
6226 (cR1>>16)|((cR1+difR)&0xff0000));
6237 n_xi = ( ( TXU >> 1 ) & ~0x78 ) + ( ( TXU << 2 ) & 0x40 ) + ( ( TXV << 3 ) & 0x38 );
6238 n_yi = ( TXV & ~0x7 ) + ( ( TXU >> 5 ) & 0x7 );
6240 tC1= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((TXU & 0x01)<<3)) & 0xff;
6242 GetTextureTransColGX_S(&psxVuw[(i<<10)+j],
6243 GETLE16(&psxVuw[clutP+tC1]),
6244 (cB1>>16),(cG1>>16),(cR1>>16));
6257 for (i=ymin;i<=ymax;i++)
6259 xmin=(left_x >> 16);
6260 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!!!!!!!!!
6261 if(drawW<xmax) xmax=drawW;
6272 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
6274 for(j=xmin;j<=xmax;j++)
6278 n_xi = ( ( TXU >> 1 ) & ~0x78 ) + ( ( TXU << 2 ) & 0x40 ) + ( ( TXV << 3 ) & 0x38 );
6279 n_yi = ( TXV & ~0x7 ) + ( ( TXU >> 5 ) & 0x7 );
6281 tC1= (GETLE16(&psxVuw[(n_yi<<10)+YAdjust+n_xi]) >> ((TXU & 0x01)<<3)) & 0xff;
6284 GetTextureTransColGX_Dither(&psxVuw[(i<<10)+j],
6285 GETLE16(&psxVuw[clutP+tC1]),
6286 (cB1>>16),(cG1>>16),(cR1>>16));
6288 GetTextureTransColGX(&psxVuw[(i<<10)+j],
6289 GETLE16(&psxVuw[clutP+tC1]),
6290 (cB1>>16),(cG1>>16),(cR1>>16));
6305 ////////////////////////////////////////////////////////////////////////
6307 void drawPoly3TGEx8_TW(short x1, short y1, short x2, short y2, short x3, short y3, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short clX, short clY,int32_t col1, int32_t col2, int32_t col3)
6309 int i,j,xmin,xmax,ymin,ymax;
6310 int32_t cR1,cG1,cB1;
6311 int32_t difR,difB,difG,difR2,difB2,difG2;
6312 int32_t difX, difY,difX2, difY2;
6313 int32_t posX,posY,YAdjust,clutP;
6316 if(x1>drawW && x2>drawW && x3>drawW) return;
6317 if(y1>drawH && y2>drawH && y3>drawH) return;
6318 if(x1<drawX && x2<drawX && x3<drawX) return;
6319 if(y1<drawY && y2<drawY && y3<drawY) return;
6320 if(drawY>=drawH) return;
6321 if(drawX>=drawW) return;
6323 if(!SetupSections_GT(x1,y1,x2,y2,x3,y3,tx1,ty1,tx2,ty2,tx3,ty3,col1,col2,col3)) return;
6327 for(ymin=Ymin;ymin<drawY;ymin++)
6328 if(NextRow_GT()) return;
6330 clutP=(clY<<10)+clX;
6332 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
6333 YAdjust+=(TWin.Position.y0<<11)+(TWin.Position.x0);
6341 difX=delta_right_u;difX2=difX<<1;
6342 difY=delta_right_v;difY2=difY<<1;
6346 if(!bCheckMask && !DrawSemiTrans && !iDither)
6348 for (i=ymin;i<=ymax;i++)
6350 xmin=(left_x >> 16);
6351 xmax=(right_x >> 16)-1; // !!!!!!!!!!!!!
6352 if(drawW<xmax) xmax=drawW;
6363 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
6365 for(j=xmin;j<xmax;j+=2)
6367 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
6368 YAdjust+((posX>>16)%TWin.Position.x1)];
6369 tC2 = psxVub[((((posY+difY)>>16)%TWin.Position.y1)<<11)+
6370 YAdjust+(((posX+difX)>>16)%TWin.Position.x1)];
6372 GetTextureTransColGX32_S((uint32_t *)&psxVuw[(i<<10)+j],
6373 GETLE16(&psxVuw[clutP+tC1])|
6374 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16,
6375 (cB1>>16)|((cB1+difB)&0xff0000),
6376 (cG1>>16)|((cG1+difG)&0xff0000),
6377 (cR1>>16)|((cR1+difR)&0xff0000));
6386 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
6387 YAdjust+((posX>>16)%TWin.Position.x1)];
6388 GetTextureTransColGX_S(&psxVuw[(i<<10)+j],
6389 GETLE16(&psxVuw[clutP+tC1]),
6390 (cB1>>16),(cG1>>16),(cR1>>16));
6403 for (i=ymin;i<=ymax;i++)
6405 xmin=(left_x >> 16);
6406 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!!!!!!!!!
6407 if(drawW<xmax) xmax=drawW;
6418 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
6420 for(j=xmin;j<=xmax;j++)
6422 tC1 = psxVub[(((posY>>16)%TWin.Position.y1)<<11)+
6423 YAdjust+((posX>>16)%TWin.Position.x1)];
6425 GetTextureTransColGX_Dither(&psxVuw[(i<<10)+j],
6426 GETLE16(&psxVuw[clutP+tC1]),
6427 (cB1>>16),(cG1>>16),(cR1>>16));
6429 GetTextureTransColGX(&psxVuw[(i<<10)+j],
6430 GETLE16(&psxVuw[clutP+tC1]),
6431 (cB1>>16),(cG1>>16),(cR1>>16));
6446 ////////////////////////////////////////////////////////////////////////
6448 // note: two g-shaded tris: small texture distortions can happen
6450 void drawPoly4TGEx8_TRI_IL(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4,
6451 short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4,
6452 short clX, short clY,
6453 int32_t col1, int32_t col2, int32_t col3, int32_t col4)
6455 drawPoly3TGEx8_IL(x2,y2,x3,y3,x4,y4,
6456 tx2,ty2,tx3,ty3,tx4,ty4,
6459 drawPoly3TGEx8_IL(x1,y1,x2,y2,x4,y4,
6460 tx1,ty1,tx2,ty2,tx4,ty4,
6467 void drawPoly4TGEx8_TRI(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4,
6468 short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4,
6469 short clX, short clY,
6470 int32_t col1, int32_t col2, int32_t col3, int32_t col4)
6472 drawPoly3TGEx8(x2,y2,x3,y3,x4,y4,
6473 tx2,ty2,tx3,ty3,tx4,ty4,
6476 drawPoly3TGEx8(x1,y1,x2,y2,x4,y4,
6477 tx1,ty1,tx2,ty2,tx4,ty4,
6484 void drawPoly4TGEx8(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4,
6485 short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4,
6486 short clX, short clY,
6487 int32_t col1, int32_t col2, int32_t col4, int32_t col3)
6490 int32_t i,j,xmin,xmax,ymin,ymax;
6491 int32_t cR1,cG1,cB1;
6492 int32_t difR,difB,difG,difR2,difB2,difG2;
6493 int32_t difX, difY, difX2, difY2;
6494 int32_t posX,posY,YAdjust,clutP;
6497 if(x1>drawW && x2>drawW && x3>drawW && x4>drawW) return;
6498 if(y1>drawH && y2>drawH && y3>drawH && y4>drawH) return;
6499 if(x1<drawX && x2<drawX && x3<drawX && x4<drawX) return;
6500 if(y1<drawY && y2<drawY && y3<drawY && y4<drawY) return;
6501 if(drawY>=drawH) return;
6502 if(drawX>=drawW) return;
6504 if(!SetupSections_GT4(x1,y1,x2,y2,x3,y3,x4,y4,tx1,ty1,tx2,ty2,tx3,ty3,tx4,ty4,col1,col2,col3,col4)) return;
6508 for(ymin=Ymin;ymin<drawY;ymin++)
6509 if(NextRow_GT4()) return;
6511 clutP=(clY<<10)+clX;
6513 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
6517 if(!bCheckMask && !DrawSemiTrans && !iDither)
6519 for (i=ymin;i<=ymax;i++)
6521 xmin=(left_x >> 16);
6522 xmax=(right_x >> 16);
6531 difX=(right_u-posX)/num;
6532 difY=(right_v-posY)/num;
6539 difR=(right_R-cR1)/num;
6540 difG=(right_G-cG1)/num;
6541 difB=(right_B-cB1)/num;
6547 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
6548 xmax--;if(drawW<xmax) xmax=drawW;
6550 for(j=xmin;j<xmax;j+=2)
6552 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(posX>>16)];
6553 tC2 = psxVub[(((posY+difY)>>5)&(int32_t)0xFFFFF800)+YAdjust+
6556 GetTextureTransColGX32_S((uint32_t *)&psxVuw[(i<<10)+j],
6557 GETLE16(&psxVuw[clutP+tC1])|
6558 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16,
6559 (cB1>>16)|((cB1+difB)&0xff0000),
6560 (cG1>>16)|((cG1+difG)&0xff0000),
6561 (cR1>>16)|((cR1+difR)&0xff0000));
6570 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(posX>>16)];
6571 GetTextureTransColGX_S(&psxVuw[(i<<10)+j],
6572 GETLE16(&psxVuw[clutP+tC1]),
6573 (cB1>>16),(cG1>>16),(cR1>>16));
6576 if(NextRow_GT4()) return;
6583 for (i=ymin;i<=ymax;i++)
6585 xmin=(left_x >> 16);
6586 xmax=(right_x >> 16);
6595 difX=(right_u-posX)/num;
6596 difY=(right_v-posY)/num;
6603 difR=(right_R-cR1)/num;
6604 difG=(right_G-cG1)/num;
6605 difB=(right_B-cB1)/num;
6611 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
6612 xmax--;if(drawW<xmax) xmax=drawW;
6614 for(j=xmin;j<=xmax;j++)
6616 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(posX>>16)];
6618 GetTextureTransColGX_Dither(&psxVuw[(i<<10)+j],
6619 GETLE16(&psxVuw[clutP+tC1]),
6620 (cB1>>16),(cG1>>16),(cR1>>16));
6622 GetTextureTransColGX(&psxVuw[(i<<10)+j],
6623 GETLE16(&psxVuw[clutP+tC1]),
6624 (cB1>>16),(cG1>>16),(cR1>>16));
6632 if(NextRow_GT4()) return;
6636 ////////////////////////////////////////////////////////////////////////
6638 void drawPoly4TGEx8_TW(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4,
6639 short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4,
6640 short clX, short clY,
6641 int32_t col1, int32_t col2, int32_t col3, int32_t col4)
6643 drawPoly3TGEx8_TW(x2,y2,x3,y3,x4,y4,
6644 tx2,ty2,tx3,ty3,tx4,ty4,
6647 drawPoly3TGEx8_TW(x1,y1,x2,y2,x4,y4,
6648 tx1,ty1,tx2,ty2,tx4,ty4,
6653 ////////////////////////////////////////////////////////////////////////
6654 // POLY 3 G-SHADED TEX 15 BIT
6655 ////////////////////////////////////////////////////////////////////////
6657 void drawPoly3TGD(short x1, short y1, short x2, short y2, short x3, short y3, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3,int32_t col1, int32_t col2, int32_t col3)
6659 int i,j,xmin,xmax,ymin,ymax;
6660 int32_t cR1,cG1,cB1;
6661 int32_t difR,difB,difG,difR2,difB2,difG2;
6662 int32_t difX, difY,difX2, difY2;
6665 if(x1>drawW && x2>drawW && x3>drawW) return;
6666 if(y1>drawH && y2>drawH && y3>drawH) return;
6667 if(x1<drawX && x2<drawX && x3<drawX) return;
6668 if(y1<drawY && y2<drawY && y3<drawY) return;
6669 if(drawY>=drawH) return;
6670 if(drawX>=drawW) return;
6672 if(!SetupSections_GT(x1,y1,x2,y2,x3,y3,tx1,ty1,tx2,ty2,tx3,ty3,col1,col2,col3)) return;
6676 for(ymin=Ymin;ymin<drawY;ymin++)
6677 if(NextRow_GT()) return;
6685 difX=delta_right_u;difX2=difX<<1;
6686 difY=delta_right_v;difY2=difY<<1;
6690 if(!bCheckMask && !DrawSemiTrans && !iDither)
6692 for (i=ymin;i<=ymax;i++)
6694 xmin=(left_x >> 16);
6695 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!!!!!!
6696 if(drawW<xmax) xmax=drawW;
6707 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
6709 for(j=xmin;j<xmax;j+=2)
6711 GetTextureTransColGX32_S((uint32_t *)&psxVuw[(i<<10)+j],
6712 (((int32_t)GETLE16(&psxVuw[((((posY+difY)>>16)+GlobalTextAddrY)<<10)+((posX+difX)>>16)+GlobalTextAddrX]))<<16)|
6713 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+((posX)>>16)+GlobalTextAddrX]),
6714 (cB1>>16)|((cB1+difB)&0xff0000),
6715 (cG1>>16)|((cG1+difG)&0xff0000),
6716 (cR1>>16)|((cR1+difR)&0xff0000));
6724 GetTextureTransColGX_S(&psxVuw[(i<<10)+j],
6725 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+(posX>>16)+GlobalTextAddrX]),
6726 (cB1>>16),(cG1>>16),(cR1>>16));
6738 for (i=ymin;i<=ymax;i++)
6740 xmin=(left_x >> 16);
6741 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!!!!
6742 if(drawW<xmax) xmax=drawW;
6753 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
6755 for(j=xmin;j<=xmax;j++)
6758 GetTextureTransColGX_Dither(&psxVuw[(i<<10)+j],
6759 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+(posX>>16)+GlobalTextAddrX]),
6760 (cB1>>16),(cG1>>16),(cR1>>16));
6762 GetTextureTransColGX(&psxVuw[(i<<10)+j],
6763 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+(posX>>16)+GlobalTextAddrX]),
6764 (cB1>>16),(cG1>>16),(cR1>>16));
6779 ////////////////////////////////////////////////////////////////////////
6781 void drawPoly3TGD_TW(short x1, short y1, short x2, short y2, short x3, short y3, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3,int32_t col1, int32_t col2, int32_t col3)
6783 int i,j,xmin,xmax,ymin,ymax;
6784 int32_t cR1,cG1,cB1;
6785 int32_t difR,difB,difG,difR2,difB2,difG2;
6786 int32_t difX, difY,difX2, difY2;
6789 if(x1>drawW && x2>drawW && x3>drawW) return;
6790 if(y1>drawH && y2>drawH && y3>drawH) return;
6791 if(x1<drawX && x2<drawX && x3<drawX) return;
6792 if(y1<drawY && y2<drawY && y3<drawY) return;
6793 if(drawY>=drawH) return;
6794 if(drawX>=drawW) return;
6796 if(!SetupSections_GT(x1,y1,x2,y2,x3,y3,tx1,ty1,tx2,ty2,tx3,ty3,col1,col2,col3)) return;
6800 for(ymin=Ymin;ymin<drawY;ymin++)
6801 if(NextRow_GT()) return;
6809 difX=delta_right_u;difX2=difX<<1;
6810 difY=delta_right_v;difY2=difY<<1;
6814 if(!bCheckMask && !DrawSemiTrans && !iDither)
6816 for (i=ymin;i<=ymax;i++)
6818 xmin=(left_x >> 16);
6819 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!!!!!!
6820 if(drawW<xmax) xmax=drawW;
6831 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
6833 for(j=xmin;j<xmax;j+=2)
6835 GetTextureTransColGX32_S((uint32_t *)&psxVuw[(i<<10)+j],
6836 (((int32_t)GETLE16(&psxVuw[(((((posY+difY)>>16)%TWin.Position.y1)+GlobalTextAddrY+TWin.Position.y0)<<10)+
6837 (((posX+difX)>>16)%TWin.Position.x1)+GlobalTextAddrX+TWin.Position.x0]))<<16)|
6838 GETLE16(&psxVuw[((((posY>>16)%TWin.Position.y1)+GlobalTextAddrY+TWin.Position.y0)<<10)+
6839 (((posX)>>16)%TWin.Position.x1)+GlobalTextAddrX+TWin.Position.x0]),
6840 (cB1>>16)|((cB1+difB)&0xff0000),
6841 (cG1>>16)|((cG1+difG)&0xff0000),
6842 (cR1>>16)|((cR1+difR)&0xff0000));
6850 GetTextureTransColGX_S(&psxVuw[(i<<10)+j],
6851 GETLE16(&psxVuw[((((posY>>16)%TWin.Position.y1)+GlobalTextAddrY+TWin.Position.y0)<<10)+
6852 ((posX>>16)%TWin.Position.x1)+GlobalTextAddrX+TWin.Position.x0]),
6853 (cB1>>16),(cG1>>16),(cR1>>16));
6865 for (i=ymin;i<=ymax;i++)
6867 xmin=(left_x >> 16);
6868 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!!!!
6869 if(drawW<xmax) xmax=drawW;
6880 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
6882 for(j=xmin;j<=xmax;j++)
6885 GetTextureTransColGX_Dither(&psxVuw[(i<<10)+j],
6886 GETLE16(&psxVuw[((((posY>>16)%TWin.Position.y1)+GlobalTextAddrY+TWin.Position.y0)<<10)+
6887 ((posX>>16)%TWin.Position.x1)+GlobalTextAddrX+TWin.Position.x0]),
6888 (cB1>>16),(cG1>>16),(cR1>>16));
6890 GetTextureTransColGX(&psxVuw[(i<<10)+j],
6891 GETLE16(&psxVuw[((((posY>>16)%TWin.Position.y1)+GlobalTextAddrY+TWin.Position.y0)<<10)+
6892 ((posX>>16)%TWin.Position.x1)+GlobalTextAddrX+TWin.Position.x0]),
6893 (cB1>>16),(cG1>>16),(cR1>>16));
6908 ////////////////////////////////////////////////////////////////////////
6910 // note: two g-shaded tris: small texture distortions can happen
6914 void drawPoly4TGD_TRI(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4, int32_t col1, int32_t col2, int32_t col3, int32_t col4)
6916 drawPoly3TGD(x2,y2,x3,y3,x4,y4,
6917 tx2,ty2,tx3,ty3,tx4,ty4,
6919 drawPoly3TGD(x1,y1,x2,y2,x4,y4,
6920 tx1,ty1,tx2,ty2,tx4,ty4,
6926 void drawPoly4TGD(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4, int32_t col1, int32_t col2, int32_t col4, int32_t col3)
6929 int32_t i,j,xmin,xmax,ymin,ymax;
6930 int32_t cR1,cG1,cB1;
6931 int32_t difR,difB,difG,difR2,difB2,difG2;
6932 int32_t difX, difY, difX2, difY2;
6935 if(x1>drawW && x2>drawW && x3>drawW && x4>drawW) return;
6936 if(y1>drawH && y2>drawH && y3>drawH && y4>drawH) return;
6937 if(x1<drawX && x2<drawX && x3<drawX && x4<drawX) return;
6938 if(y1<drawY && y2<drawY && y3<drawY && y4<drawY) return;
6939 if(drawY>=drawH) return;
6940 if(drawX>=drawW) return;
6942 if(!SetupSections_GT4(x1,y1,x2,y2,x3,y3,x4,y4,tx1,ty1,tx2,ty2,tx3,ty3,tx4,ty4,col1,col2,col3,col4)) return;
6946 for(ymin=Ymin;ymin<drawY;ymin++)
6947 if(NextRow_GT4()) return;
6951 if(!bCheckMask && !DrawSemiTrans && !iDither)
6953 for (i=ymin;i<=ymax;i++)
6955 xmin=(left_x >> 16);
6956 xmax=(right_x >> 16);
6965 difX=(right_u-posX)/num;
6966 difY=(right_v-posY)/num;
6973 difR=(right_R-cR1)/num;
6974 difG=(right_G-cG1)/num;
6975 difB=(right_B-cB1)/num;
6981 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
6982 xmax--;if(drawW<xmax) xmax=drawW;
6984 for(j=xmin;j<xmax;j+=2)
6986 GetTextureTransColGX32_S((uint32_t *)&psxVuw[(i<<10)+j],
6987 (((int32_t)GETLE16(&psxVuw[((((posY+difY)>>16)+GlobalTextAddrY)<<10)+((posX+difX)>>16)+GlobalTextAddrX]))<<16)|
6988 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+((posX)>>16)+GlobalTextAddrX]),
6989 (cB1>>16)|((cB1+difB)&0xff0000),
6990 (cG1>>16)|((cG1+difG)&0xff0000),
6991 (cR1>>16)|((cR1+difR)&0xff0000));
6999 GetTextureTransColGX_S(&psxVuw[(i<<10)+j],
7000 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+(posX>>16)+GlobalTextAddrX]),
7001 (cB1>>16),(cG1>>16),(cR1>>16));
7003 if(NextRow_GT4()) return;
7010 for (i=ymin;i<=ymax;i++)
7012 xmin=(left_x >> 16);
7013 xmax=(right_x >> 16);
7022 difX=(right_u-posX)/num;
7023 difY=(right_v-posY)/num;
7030 difR=(right_R-cR1)/num;
7031 difG=(right_G-cG1)/num;
7032 difB=(right_B-cB1)/num;
7038 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
7039 xmax--;if(drawW<xmax) xmax=drawW;
7041 for(j=xmin;j<=xmax;j++)
7044 GetTextureTransColGX(&psxVuw[(i<<10)+j],
7045 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+(posX>>16)+GlobalTextAddrX]),
7046 (cB1>>16),(cG1>>16),(cR1>>16));
7048 GetTextureTransColGX(&psxVuw[(i<<10)+j],
7049 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+(posX>>16)+GlobalTextAddrX]),
7050 (cB1>>16),(cG1>>16),(cR1>>16));
7058 if(NextRow_GT4()) return;
7062 ////////////////////////////////////////////////////////////////////////
7064 void drawPoly4TGD_TW(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4, int32_t col1, int32_t col2, int32_t col3, int32_t col4)
7066 drawPoly3TGD_TW(x2,y2,x3,y3,x4,y4,
7067 tx2,ty2,tx3,ty3,tx4,ty4,
7069 drawPoly3TGD_TW(x1,y1,x2,y2,x4,y4,
7070 tx1,ty1,tx2,ty2,tx4,ty4,
7074 ////////////////////////////////////////////////////////////////////////
7075 ////////////////////////////////////////////////////////////////////////
7076 ////////////////////////////////////////////////////////////////////////
7077 ////////////////////////////////////////////////////////////////////////
7078 ////////////////////////////////////////////////////////////////////////
7079 ////////////////////////////////////////////////////////////////////////
7083 // no real rect test, but it does its job the way I need it
7084 __inline BOOL IsNoRect(void)
7086 if(lx0==lx1 && lx2==lx3) return FALSE;
7087 if(lx0==lx2 && lx1==lx3) return FALSE;
7088 if(lx0==lx3 && lx1==lx2) return FALSE;
7094 __inline BOOL IsNoRect(void)
7096 if(!(dwActFixes&0x200)) return FALSE;
7100 if(lx1==lx3 && ly3==ly2 && lx2==lx0) return FALSE;
7101 if(lx1==lx2 && ly2==ly3 && lx3==lx0) return FALSE;
7107 if(lx2==lx3 && ly3==ly1 && lx1==lx0) return FALSE;
7108 if(lx2==lx1 && ly1==ly3 && lx3==lx0) return FALSE;
7114 if(lx3==lx2 && ly2==ly1 && lx1==lx0) return FALSE;
7115 if(lx3==lx1 && ly1==ly2 && lx2==lx0) return FALSE;
7121 ////////////////////////////////////////////////////////////////////////
7123 void drawPoly3FT(unsigned char * baseAddr)
7125 uint32_t *gpuData = ((uint32_t *) baseAddr);
7127 if(GlobalTextIL && GlobalTextTP<2)
7130 drawPoly3TEx4_IL(lx0,ly0,lx1,ly1,lx2,ly2,
7131 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[4]) & 0x000000ff), ((GETLE32(&gpuData[4])>>8) & 0x000000ff),(GETLE32(&gpuData[6]) & 0x000000ff), ((GETLE32(&gpuData[6])>>8) & 0x000000ff),
7132 ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & iGPUHeightMask));
7134 drawPoly3TEx8_IL(lx0,ly0,lx1,ly1,lx2,ly2,
7135 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[4]) & 0x000000ff), ((GETLE32(&gpuData[4])>>8) & 0x000000ff),(GETLE32(&gpuData[6]) & 0x000000ff), ((GETLE32(&gpuData[6])>>8) & 0x000000ff),
7136 ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & iGPUHeightMask));
7140 if(!bUsingTWin && !(dwActFixes&0x100))
7142 switch(GlobalTextTP) // depending on texture mode
7145 drawPoly3TEx4(lx0,ly0,lx1,ly1,lx2,ly2,
7146 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[4]) & 0x000000ff), ((GETLE32(&gpuData[4])>>8) & 0x000000ff),(GETLE32(&gpuData[6]) & 0x000000ff), ((GETLE32(&gpuData[6])>>8) & 0x000000ff),
7147 ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & iGPUHeightMask));
7150 drawPoly3TEx8(lx0,ly0,lx1,ly1,lx2,ly2,
7151 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[4]) & 0x000000ff), ((GETLE32(&gpuData[4])>>8) & 0x000000ff),(GETLE32(&gpuData[6]) & 0x000000ff), ((GETLE32(&gpuData[6])>>8) & 0x000000ff),
7152 ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & iGPUHeightMask));
7155 drawPoly3TD(lx0,ly0,lx1,ly1,lx2,ly2,(GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[4]) & 0x000000ff), ((GETLE32(&gpuData[4])>>8) & 0x000000ff),(GETLE32(&gpuData[6]) & 0x000000ff), ((GETLE32(&gpuData[6])>>8) & 0x000000ff));
7161 switch(GlobalTextTP) // depending on texture mode
7164 drawPoly3TEx4_TW(lx0,ly0,lx1,ly1,lx2,ly2,
7165 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[4]) & 0x000000ff), ((GETLE32(&gpuData[4])>>8) & 0x000000ff),(GETLE32(&gpuData[6]) & 0x000000ff), ((GETLE32(&gpuData[6])>>8) & 0x000000ff),
7166 ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & iGPUHeightMask));
7169 drawPoly3TEx8_TW(lx0,ly0,lx1,ly1,lx2,ly2,
7170 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[4]) & 0x000000ff), ((GETLE32(&gpuData[4])>>8) & 0x000000ff),(GETLE32(&gpuData[6]) & 0x000000ff), ((GETLE32(&gpuData[6])>>8) & 0x000000ff),
7171 ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & iGPUHeightMask));
7174 drawPoly3TD_TW(lx0,ly0,lx1,ly1,lx2,ly2,(GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[4]) & 0x000000ff), ((GETLE32(&gpuData[4])>>8) & 0x000000ff),(GETLE32(&gpuData[6]) & 0x000000ff), ((GETLE32(&gpuData[6])>>8) & 0x000000ff));
7179 ////////////////////////////////////////////////////////////////////////
7181 void drawPoly4FT(unsigned char * baseAddr)
7183 uint32_t *gpuData = ((uint32_t *) baseAddr);
7185 if(GlobalTextIL && GlobalTextTP<2)
7188 drawPoly4TEx4_IL(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,
7189 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[4]) & 0x000000ff), ((GETLE32(&gpuData[4])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),(GETLE32(&gpuData[6]) & 0x000000ff), ((GETLE32(&gpuData[6])>>8) & 0x000000ff), ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & iGPUHeightMask));
7191 drawPoly4TEx8_IL(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,
7192 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[4]) & 0x000000ff), ((GETLE32(&gpuData[4])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),(GETLE32(&gpuData[6]) & 0x000000ff), ((GETLE32(&gpuData[6])>>8) & 0x000000ff), ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & iGPUHeightMask));
7201 switch (GlobalTextTP)
7204 drawPoly4TEx4_TRI(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,
7205 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[4]) & 0x000000ff), ((GETLE32(&gpuData[4])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),(GETLE32(&gpuData[6]) & 0x000000ff), ((GETLE32(&gpuData[6])>>8) & 0x000000ff), ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & iGPUHeightMask));
7208 drawPoly4TEx8_TRI(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,
7209 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[4]) & 0x000000ff), ((GETLE32(&gpuData[4])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),(GETLE32(&gpuData[6]) & 0x000000ff), ((GETLE32(&gpuData[6])>>8) & 0x000000ff), ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & iGPUHeightMask));
7212 drawPoly4TD_TRI(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,(GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[4]) & 0x000000ff), ((GETLE32(&gpuData[4])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),(GETLE32(&gpuData[6]) & 0x000000ff), ((GETLE32(&gpuData[6])>>8) & 0x000000ff));
7219 switch (GlobalTextTP)
7221 case 0: // grandia investigations needed
7222 drawPoly4TEx4(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,
7223 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[4]) & 0x000000ff), ((GETLE32(&gpuData[4])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),(GETLE32(&gpuData[6]) & 0x000000ff), ((GETLE32(&gpuData[6])>>8) & 0x000000ff), ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & iGPUHeightMask));
7226 drawPoly4TEx8(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,
7227 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[4]) & 0x000000ff), ((GETLE32(&gpuData[4])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),(GETLE32(&gpuData[6]) & 0x000000ff), ((GETLE32(&gpuData[6])>>8) & 0x000000ff), ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & iGPUHeightMask));
7230 drawPoly4TD(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,(GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[4]) & 0x000000ff), ((GETLE32(&gpuData[4])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),(GETLE32(&gpuData[6]) & 0x000000ff), ((GETLE32(&gpuData[6])>>8) & 0x000000ff));
7236 switch (GlobalTextTP)
7239 drawPoly4TEx4_TW(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,
7240 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[4]) & 0x000000ff), ((GETLE32(&gpuData[4])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),(GETLE32(&gpuData[6]) & 0x000000ff), ((GETLE32(&gpuData[6])>>8) & 0x000000ff), ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & iGPUHeightMask));
7243 drawPoly4TEx8_TW(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,
7244 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[4]) & 0x000000ff), ((GETLE32(&gpuData[4])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),(GETLE32(&gpuData[6]) & 0x000000ff), ((GETLE32(&gpuData[6])>>8) & 0x000000ff), ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & iGPUHeightMask));
7247 drawPoly4TD_TW(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,(GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[4]) & 0x000000ff), ((GETLE32(&gpuData[4])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),(GETLE32(&gpuData[6]) & 0x000000ff), ((GETLE32(&gpuData[6])>>8) & 0x000000ff));
7252 ////////////////////////////////////////////////////////////////////////
7254 void drawPoly3GT(unsigned char * baseAddr)
7256 uint32_t *gpuData = ((uint32_t *) baseAddr);
7258 if(GlobalTextIL && GlobalTextTP<2)
7261 drawPoly3TGEx4_IL(lx0,ly0,lx1,ly1,lx2,ly2,
7262 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[5]) & 0x000000ff), ((GETLE32(&gpuData[5])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),
7263 ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & iGPUHeightMask),
7264 GETLE32(&gpuData[0]),GETLE32(&gpuData[3]),GETLE32(&gpuData[6]));
7266 drawPoly3TGEx8_IL(lx0,ly0,lx1,ly1,lx2,ly2,
7267 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[5]) & 0x000000ff), ((GETLE32(&gpuData[5])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),
7268 ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & iGPUHeightMask),
7269 GETLE32(&gpuData[0]),GETLE32(&gpuData[3]),GETLE32(&gpuData[6]));
7275 switch (GlobalTextTP)
7278 drawPoly3TGEx4(lx0,ly0,lx1,ly1,lx2,ly2,
7279 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[5]) & 0x000000ff), ((GETLE32(&gpuData[5])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),
7280 ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & iGPUHeightMask),
7281 GETLE32(&gpuData[0]),GETLE32(&gpuData[3]),GETLE32(&gpuData[6]));
7284 drawPoly3TGEx8(lx0,ly0,lx1,ly1,lx2,ly2,
7285 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[5]) & 0x000000ff), ((GETLE32(&gpuData[5])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),
7286 ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & iGPUHeightMask),
7287 GETLE32(&gpuData[0]),GETLE32(&gpuData[3]),GETLE32(&gpuData[6]));
7290 drawPoly3TGD(lx0,ly0,lx1,ly1,lx2,ly2,(GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[5]) & 0x000000ff), ((GETLE32(&gpuData[5])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),GETLE32(&gpuData[0]),GETLE32(&gpuData[3]),GETLE32(&gpuData[6]));
7296 switch(GlobalTextTP)
7299 drawPoly3TGEx4_TW(lx0,ly0,lx1,ly1,lx2,ly2,
7300 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[5]) & 0x000000ff), ((GETLE32(&gpuData[5])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),
7301 ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & iGPUHeightMask),
7302 GETLE32(&gpuData[0]),GETLE32(&gpuData[3]),GETLE32(&gpuData[6]));
7305 drawPoly3TGEx8_TW(lx0,ly0,lx1,ly1,lx2,ly2,
7306 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[5]) & 0x000000ff), ((GETLE32(&gpuData[5])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),
7307 ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & iGPUHeightMask),
7308 GETLE32(&gpuData[0]),GETLE32(&gpuData[3]),GETLE32(&gpuData[6]));
7311 drawPoly3TGD_TW(lx0,ly0,lx1,ly1,lx2,ly2,(GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[5]) & 0x000000ff), ((GETLE32(&gpuData[5])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),GETLE32(&gpuData[0]),GETLE32(&gpuData[3]),GETLE32(&gpuData[6]));
7316 ////////////////////////////////////////////////////////////////////////
7318 void drawPoly4GT(unsigned char *baseAddr)
7320 uint32_t *gpuData = ((uint32_t *) baseAddr);
7322 if(GlobalTextIL && GlobalTextTP<2)
7325 drawPoly4TGEx4_TRI_IL(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,
7326 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[5]) & 0x000000ff), ((GETLE32(&gpuData[5])>>8) & 0x000000ff),(GETLE32(&gpuData[11]) & 0x000000ff), ((GETLE32(&gpuData[11])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),
7327 ((GETLE32(&gpuData[2])>>12) & 0x3f0),((GETLE32(&gpuData[2])>>22) & iGPUHeightMask),
7328 GETLE32(&gpuData[0]),GETLE32(&gpuData[3]),GETLE32(&gpuData[6]),GETLE32(&gpuData[9]));
7330 drawPoly4TGEx8_TRI_IL(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,
7331 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[5]) & 0x000000ff), ((GETLE32(&gpuData[5])>>8) & 0x000000ff),(GETLE32(&gpuData[11]) & 0x000000ff), ((GETLE32(&gpuData[11])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),
7332 ((GETLE32(&gpuData[2])>>12) & 0x3f0),((GETLE32(&gpuData[2])>>22) & iGPUHeightMask),
7333 GETLE32(&gpuData[0]),GETLE32(&gpuData[3]),GETLE32(&gpuData[6]),GETLE32(&gpuData[9]));
7342 switch (GlobalTextTP)
7345 drawPoly4TGEx4_TRI(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,
7346 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[5]) & 0x000000ff), ((GETLE32(&gpuData[5])>>8) & 0x000000ff),(GETLE32(&gpuData[11]) & 0x000000ff), ((GETLE32(&gpuData[11])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),
7347 ((GETLE32(&gpuData[2])>>12) & 0x3f0),((GETLE32(&gpuData[2])>>22) & iGPUHeightMask),
7348 GETLE32(&gpuData[0]),GETLE32(&gpuData[3]),GETLE32(&gpuData[6]),GETLE32(&gpuData[9]));
7352 drawPoly4TGEx8_TRI(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,
7353 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[5]) & 0x000000ff), ((GETLE32(&gpuData[5])>>8) & 0x000000ff),(GETLE32(&gpuData[11]) & 0x000000ff), ((GETLE32(&gpuData[11])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),
7354 ((GETLE32(&gpuData[2])>>12) & 0x3f0),((GETLE32(&gpuData[2])>>22) & iGPUHeightMask),
7355 GETLE32(&gpuData[0]),GETLE32(&gpuData[3]),GETLE32(&gpuData[6]),GETLE32(&gpuData[9]));
7358 drawPoly4TGD_TRI(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,(GETLE32(&gpuData[2]) & 0x000000ff),((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[5]) & 0x000000ff), ((GETLE32(&gpuData[5])>>8) & 0x000000ff),(GETLE32(&gpuData[11]) & 0x000000ff), ((GETLE32(&gpuData[11])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),GETLE32(&gpuData[0]),GETLE32(&gpuData[3]),GETLE32(&gpuData[6]),GETLE32(&gpuData[9]));
7365 switch (GlobalTextTP)
7368 drawPoly4TGEx4(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,
7369 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[5]) & 0x000000ff), ((GETLE32(&gpuData[5])>>8) & 0x000000ff),(GETLE32(&gpuData[11]) & 0x000000ff), ((GETLE32(&gpuData[11])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),
7370 ((GETLE32(&gpuData[2])>>12) & 0x3f0),((GETLE32(&gpuData[2])>>22) & iGPUHeightMask),
7371 GETLE32(&gpuData[0]),GETLE32(&gpuData[3]),GETLE32(&gpuData[6]),GETLE32(&gpuData[9]));
7375 drawPoly4TGEx8(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,
7376 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[5]) & 0x000000ff), ((GETLE32(&gpuData[5])>>8) & 0x000000ff),(GETLE32(&gpuData[11]) & 0x000000ff), ((GETLE32(&gpuData[11])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),
7377 ((GETLE32(&gpuData[2])>>12) & 0x3f0),((GETLE32(&gpuData[2])>>22) & iGPUHeightMask),
7378 GETLE32(&gpuData[0]),GETLE32(&gpuData[3]),GETLE32(&gpuData[6]),GETLE32(&gpuData[9]));
7381 drawPoly4TGD(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,(GETLE32(&gpuData[2]) & 0x000000ff),((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[5]) & 0x000000ff), ((GETLE32(&gpuData[5])>>8) & 0x000000ff),(GETLE32(&gpuData[11]) & 0x000000ff), ((GETLE32(&gpuData[11])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),GETLE32(&gpuData[0]),GETLE32(&gpuData[3]),GETLE32(&gpuData[6]),GETLE32(&gpuData[9]));
7387 switch (GlobalTextTP)
7390 drawPoly4TGEx4_TW(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,
7391 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[5]) & 0x000000ff), ((GETLE32(&gpuData[5])>>8) & 0x000000ff),(GETLE32(&gpuData[11]) & 0x000000ff), ((GETLE32(&gpuData[11])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),
7392 ((GETLE32(&gpuData[2])>>12) & 0x3f0),((GETLE32(&gpuData[2])>>22) & iGPUHeightMask),
7393 GETLE32(&gpuData[0]),GETLE32(&gpuData[3]),GETLE32(&gpuData[6]),GETLE32(&gpuData[9]));
7396 drawPoly4TGEx8_TW(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,
7397 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[5]) & 0x000000ff), ((GETLE32(&gpuData[5])>>8) & 0x000000ff),(GETLE32(&gpuData[11]) & 0x000000ff), ((GETLE32(&gpuData[11])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),
7398 ((GETLE32(&gpuData[2])>>12) & 0x3f0),((GETLE32(&gpuData[2])>>22) & iGPUHeightMask),
7399 GETLE32(&gpuData[0]),GETLE32(&gpuData[3]),GETLE32(&gpuData[6]),GETLE32(&gpuData[9]));
7402 drawPoly4TGD_TW(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,(GETLE32(&gpuData[2]) & 0x000000ff),((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[5]) & 0x000000ff), ((GETLE32(&gpuData[5])>>8) & 0x000000ff),(GETLE32(&gpuData[11]) & 0x000000ff), ((GETLE32(&gpuData[11])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),GETLE32(&gpuData[0]),GETLE32(&gpuData[3]),GETLE32(&gpuData[6]),GETLE32(&gpuData[9]));
7407 ////////////////////////////////////////////////////////////////////////
7409 ////////////////////////////////////////////////////////////////////////
7411 void DrawSoftwareSpriteTWin(unsigned char * baseAddr,int32_t w,int32_t h)
7413 uint32_t *gpuData = (uint32_t *)baseAddr;
7414 short sx0,sy0,sx1,sy1,sx2,sy2,sx3,sy3;
7415 short tx0,ty0,tx1,ty1,tx2,ty2,tx3,ty3;
7420 sx0=sx3=sx0+PSXDisplay.DrawOffset.x;
7422 sy0=sy1=sy0+PSXDisplay.DrawOffset.y;
7425 tx0=tx3=GETLE32(&gpuData[2])&0xff;
7427 ty0=ty1=(GETLE32(&gpuData[2])>>8)&0xff;
7430 switch (GlobalTextTP)
7433 drawPoly4TEx4_TW_S(sx0,sy0,sx1,sy1,sx2,sy2,sx3,sy3,
7434 tx0,ty0,tx1,ty1,tx2,ty2,tx3,ty3,
7435 ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & iGPUHeightMask));
7438 drawPoly4TEx8_TW_S(sx0,sy0,sx1,sy1,sx2,sy2,sx3,sy3,
7439 tx0,ty0,tx1,ty1,tx2,ty2,tx3,ty3,
7440 ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & iGPUHeightMask));
7443 drawPoly4TD_TW_S(sx0,sy0,sx1,sy1,sx2,sy2,sx3,sy3,
7444 tx0,ty0,tx1,ty1,tx2,ty2,tx3,ty3);
7449 ////////////////////////////////////////////////////////////////////////
7451 void DrawSoftwareSpriteMirror(unsigned char * baseAddr,int32_t w,int32_t h)
7453 int32_t sprtY,sprtX,sprtW,sprtH,lXDir,lYDir;
7454 int32_t clutY0,clutX0,clutP,textX0,textY0,sprtYa,sprCY,sprCX,sprA;
7456 uint32_t *gpuData = (uint32_t *)baseAddr;
7461 clutY0 = (GETLE32(&gpuData[2])>>22) & iGPUHeightMask;
7462 clutX0 = (GETLE32(&gpuData[2])>>12) & 0x3f0;
7463 clutP = (clutY0<<11) + (clutX0<<1);
7464 textY0 = ((GETLE32(&gpuData[2])>>8) & 0x000000ff) + GlobalTextAddrY;
7465 textX0 = (GETLE32(&gpuData[2]) & 0x000000ff);
7467 sprtX+=PSXDisplay.DrawOffset.x;
7468 sprtY+=PSXDisplay.DrawOffset.y;
7470 // while (sprtX>1023) sprtX-=1024;
7471 // while (sprtY>MAXYLINESMIN1) sprtY-=MAXYLINES;
7475 // if((sprtX+sprtW)>1023) sprtX-=1024;
7482 // if ((sprtY+sprtH)>MAXYLINESMIN1) sprtY-=MAXYLINES;
7489 if((sprtY+sprtH)<drawY) return;
7490 sprtH-=(drawY-sprtY);
7491 textY0+=(drawY-sprtY);
7497 if((sprtX+sprtW)<drawX) return;
7498 sprtW-=(drawX-sprtX);
7499 textX0+=(drawX-sprtX);
7503 if((sprtY+sprtH)>drawH) sprtH=drawH-sprtY+1;
7504 if((sprtX+sprtW)>drawW) sprtW=drawW-sprtX+1;
7506 if(usMirror&0x1000) lXDir=-1; else lXDir=1;
7507 if(usMirror&0x2000) lYDir=-1; else lYDir=1;
7509 switch (GlobalTextTP)
7511 case 0: // texture is 4-bit
7514 textX0=(GlobalTextAddrX<<1)+(textX0>>1);
7516 clutP=(clutY0<<10)+clutX0;
7517 for (sprCY=0;sprCY<sprtH;sprCY++)
7518 for (sprCX=0;sprCX<sprtW;sprCX++)
7520 tC= psxVub[((textY0+(sprCY*lYDir))<<11) + textX0 +(sprCX*lXDir)];
7521 sprA=sprtYa+(sprCY<<10)+sprtX + (sprCX<<1);
7522 GetTextureTransColG_SPR(&psxVuw[sprA],GETLE16(&psxVuw[clutP+((tC>>4)&0xf)]));
7523 GetTextureTransColG_SPR(&psxVuw[sprA+1],GETLE16(&psxVuw[clutP+(tC&0xf)]));
7530 for(sprCY=0;sprCY<sprtH;sprCY++)
7531 for(sprCX=0;sprCX<sprtW;sprCX++)
7533 tC = psxVub[((textY0+(sprCY*lYDir))<<11)+(GlobalTextAddrX<<1) + textX0 + (sprCX*lXDir)] & 0xff;
7534 GetTextureTransColG_SPR(&psxVuw[((sprtY+sprCY)<<10)+sprtX + sprCX],psxVuw[clutP+tC]);
7540 for (sprCY=0;sprCY<sprtH;sprCY++)
7541 for (sprCX=0;sprCX<sprtW;sprCX++)
7543 GetTextureTransColG_SPR(&psxVuw[((sprtY+sprCY)<<10)+sprtX+sprCX],
7544 GETLE16(&psxVuw[((textY0+(sprCY*lYDir))<<10)+GlobalTextAddrX + textX0 +(sprCX*lXDir)]));
7550 ////////////////////////////////////////////////////////////////////////
7552 void DrawSoftwareSprite_IL(unsigned char * baseAddr,short w,short h,int32_t tx,int32_t ty)
7554 int32_t sprtY,sprtX,sprtW,sprtH,tdx,tdy;
7555 uint32_t *gpuData = (uint32_t *)baseAddr;
7562 sprtX+=PSXDisplay.DrawOffset.x;
7563 sprtY+=PSXDisplay.DrawOffset.y;
7565 if(sprtX>drawW) return;
7566 if(sprtY>drawH) return;
7574 // Pete is too lazy to make a faster version ;)
7577 drawPoly4TEx4_IL(sprtX,sprtY,sprtX,sprtH,sprtW,sprtH,sprtW,sprtY,
7578 tx,ty, tx,tdy, tdx,tdy, tdx,ty,
7579 (GETLE32(&gpuData[2])>>12) & 0x3f0, ((GETLE32(&gpuData[2])>>22) & iGPUHeightMask));
7583 drawPoly4TEx8_IL(sprtX,sprtY,sprtX,sprtH,sprtW,sprtH,sprtW,sprtY,
7584 tx,ty, tx,tdy, tdx,tdy, tdx,ty,
7585 (GETLE32(&gpuData[2])>>12) & 0x3f0, ((GETLE32(&gpuData[2])>>22) & iGPUHeightMask));
7588 ////////////////////////////////////////////////////////////////////////
7590 void DrawSoftwareSprite(unsigned char * baseAddr,short w,short h,int32_t tx,int32_t ty)
7592 int32_t sprtY,sprtX,sprtW,sprtH;
7593 int32_t clutY0,clutX0,clutP,textX0,textY0,sprtYa,sprCY,sprCX,sprA;
7595 uint32_t *gpuData = (uint32_t *)baseAddr;
7599 if(GlobalTextIL && GlobalTextTP<2)
7600 {DrawSoftwareSprite_IL(baseAddr,w,h,tx,ty);return;}
7606 clutY0 = (GETLE32(&gpuData[2])>>22) & iGPUHeightMask;
7607 clutX0 = (GETLE32(&gpuData[2])>>12) & 0x3f0;
7609 clutP = (clutY0<<11) + (clutX0<<1);
7611 textY0 =ty+ GlobalTextAddrY;
7614 sprtX+=PSXDisplay.DrawOffset.x;
7615 sprtY+=PSXDisplay.DrawOffset.y;
7617 //while (sprtX>1023) sprtX-=1024;
7618 //while (sprtY>MAXYLINESMIN1) sprtY-=MAXYLINES;
7622 // if((sprtX+sprtW)>1023) sprtX-=1024;
7629 // if ((sprtY+sprtH)>MAXYLINESMIN1) sprtY-=MAXYLINES;
7636 if((sprtY+sprtH)<drawY) return;
7637 sprtH-=(drawY-sprtY);
7638 textY0+=(drawY-sprtY);
7644 if((sprtX+sprtW)<drawX) return;
7646 sprtW-=(drawX-sprtX);
7647 textX0+=(drawX-sprtX);
7651 if((sprtY+sprtH)>drawH) sprtH=drawH-sprtY+1;
7652 if((sprtX+sprtW)>drawW) sprtW=drawW-sprtX+1;
7658 switch (GlobalTextTP)
7662 if(textX0&1) {bWS=TRUE;sprtW--;}
7663 if(sprtW&1) bWT=TRUE;
7666 textX0=(GlobalTextAddrX<<1)+(textX0>>1)+(textY0<<11);
7667 sprtYa=(sprtY<<10)+sprtX;
7668 clutP=(clutY0<<10)+clutX0;
7672 if(!bCheckMask && !DrawSemiTrans)
7674 for (sprCY=0;sprCY<sprtH;sprCY++)
7676 sprA=sprtYa+(sprCY<<10);
7677 pV=&psxVub[(sprCY<<11)+textX0];
7682 GetTextureTransColG_S(&psxVuw[sprA++],GETLE16(&psxVuw[clutP+((tC>>4)&0xf)]));
7685 for (sprCX=0;sprCX<sprtW;sprCX++,sprA+=2)
7689 GetTextureTransColG32_S((uint32_t *)&psxVuw[sprA],
7690 (((int32_t)GETLE16(&psxVuw[clutP+((tC>>4)&0xf)]))<<16)|
7691 GETLE16(&psxVuw[clutP+(tC&0x0f)]));
7697 GetTextureTransColG_S(&psxVuw[sprA],GETLE16(&psxVuw[clutP+(tC&0x0f)]));
7705 for (sprCY=0;sprCY<sprtH;sprCY++)
7707 sprA=sprtYa+(sprCY<<10);
7708 pV=&psxVub[(sprCY<<11)+textX0];
7713 GetTextureTransColG_SPR(&psxVuw[sprA++],GETLE16(&psxVuw[clutP+((tC>>4)&0xf)]));
7716 for (sprCX=0;sprCX<sprtW;sprCX++,sprA+=2)
7720 GetTextureTransColG32_SPR((uint32_t *)&psxVuw[sprA],
7721 (((int32_t)GETLE16(&psxVuw[clutP+((tC>>4)&0xf)])<<16))|
7722 GETLE16(&psxVuw[clutP+(tC&0x0f)]));
7728 GetTextureTransColG_SPR(&psxVuw[sprA],GETLE16(&psxVuw[clutP+(tC&0x0f)]));
7735 textX0+=(GlobalTextAddrX<<1) + (textY0<<11);
7739 if(!bCheckMask && !DrawSemiTrans)
7741 for(sprCY=0;sprCY<sprtH;sprCY++)
7743 sprA=((sprtY+sprCY)<<10)+sprtX;
7744 pV=&psxVub[(sprCY<<11)+textX0];
7745 for(sprCX=0;sprCX<sprtW;sprCX+=2,sprA+=2)
7747 tC = *pV++;tC2 = *pV++;
7748 GetTextureTransColG32_S((uint32_t *)&psxVuw[sprA],
7749 (((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16)|
7750 GETLE16(&psxVuw[clutP+tC]));
7753 GetTextureTransColG_S(&psxVuw[sprA],GETLE16(&psxVuw[clutP+(*pV)]));
7760 for(sprCY=0;sprCY<sprtH;sprCY++)
7762 sprA=((sprtY+sprCY)<<10)+sprtX;
7763 pV=&psxVub[(sprCY<<11)+textX0];
7764 for(sprCX=0;sprCX<sprtW;sprCX+=2,sprA+=2)
7766 tC = *pV++;tC2 = *pV++;
7767 GetTextureTransColG32_SPR((uint32_t *)&psxVuw[sprA],
7768 (((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16)|
7769 GETLE16(&psxVuw[clutP+tC]));
7772 GetTextureTransColG_SPR(&psxVuw[sprA],GETLE16(&psxVuw[clutP+(*pV)]));
7778 textX0+=(GlobalTextAddrX) + (textY0<<10);
7783 if(!bCheckMask && !DrawSemiTrans)
7785 for (sprCY=0;sprCY<sprtH;sprCY++)
7787 sprA=((sprtY+sprCY)<<10)+sprtX;
7789 for (sprCX=0;sprCX<sprtW;sprCX+=2,sprA+=2)
7791 GetTextureTransColG32_S((uint32_t *)&psxVuw[sprA],
7792 (((int32_t)GETLE16(&psxVuw[(sprCY<<10) + textX0 + sprCX +1]))<<16)|
7793 GETLE16(&psxVuw[(sprCY<<10) + textX0 + sprCX]));
7796 GetTextureTransColG_S(&psxVuw[sprA],
7797 GETLE16(&psxVuw[(sprCY<<10) + textX0 + sprCX]));
7805 for (sprCY=0;sprCY<sprtH;sprCY++)
7807 sprA=((sprtY+sprCY)<<10)+sprtX;
7809 for (sprCX=0;sprCX<sprtW;sprCX+=2,sprA+=2)
7811 GetTextureTransColG32_SPR((uint32_t *)&psxVuw[sprA],
7812 (((int32_t)GETLE16(&psxVuw[(sprCY<<10) + textX0 + sprCX +1]))<<16)|
7813 GETLE16(&psxVuw[(sprCY<<10) + textX0 + sprCX]));
7816 GetTextureTransColG_SPR(&psxVuw[sprA],
7817 GETLE16(&psxVuw[(sprCY<<10) + textX0 + sprCX]));
7824 ///////////////////////////////////////////////////////////////////////
7826 /////////////////////////////////////////////////////////////////
7827 /////////////////////////////////////////////////////////////////
7828 /////////////////////////////////////////////////////////////////
7830 ////////////////////////////////////////////////////////////////////////
7831 /////////////////////////////////////////////////////////////////
7832 /////////////////////////////////////////////////////////////////
7835 ///////////////////////////////////////////////////////////////////////
7837 void Line_E_SE_Shade(int x0, int y0, int x1, int y1, uint32_t rgb0, uint32_t rgb1)
7839 int dx, dy, incrE, incrSE, d;
7840 uint32_t r0, g0, b0, r1, g1, b1;
7843 r0 = (rgb0 & 0x00ff0000);
7844 g0 = (rgb0 & 0x0000ff00) << 8;
7845 b0 = (rgb0 & 0x000000ff) << 16;
7846 r1 = (rgb1 & 0x00ff0000);
7847 g1 = (rgb1 & 0x0000ff00) << 8;
7848 b1 = (rgb1 & 0x000000ff) << 16;
7855 dr = ((int32_t)r1 - (int32_t)r0) / dx;
7856 dg = ((int32_t)g1 - (int32_t)g0) / dx;
7857 db = ((int32_t)b1 - (int32_t)b0) / dx;
7861 dr = ((int32_t)r1 - (int32_t)r0);
7862 dg = ((int32_t)g1 - (int32_t)g0);
7863 db = ((int32_t)b1 - (int32_t)b0);
7866 d = 2*dy - dx; /* Initial value of d */
7867 incrE = 2*dy; /* incr. used for move to E */
7868 incrSE = 2*(dy - dx); /* incr. used for move to SE */
7870 if ((x0>=drawX)&&(x0<drawW)&&(y0>=drawY)&&(y0<drawH))
7871 GetShadeTransCol(&psxVuw[(y0<<10)+x0],(unsigned short)(((r0 >> 9)&0x7c00)|((g0 >> 14)&0x03e0)|((b0 >> 19)&0x001f)));
7876 d = d + incrE; /* Choose E */
7880 d = d + incrSE; /* Choose SE */
7889 if ((x0>=drawX)&&(x0<drawW)&&(y0>=drawY)&&(y0<drawH))
7890 GetShadeTransCol(&psxVuw[(y0<<10)+x0],(unsigned short)(((r0 >> 9)&0x7c00)|((g0 >> 14)&0x03e0)|((b0 >> 19)&0x001f)));
7894 ///////////////////////////////////////////////////////////////////////
7896 void Line_S_SE_Shade(int x0, int y0, int x1, int y1, uint32_t rgb0, uint32_t rgb1)
7898 int dx, dy, incrS, incrSE, d;
7899 uint32_t r0, g0, b0, r1, g1, b1;
7902 r0 = (rgb0 & 0x00ff0000);
7903 g0 = (rgb0 & 0x0000ff00) << 8;
7904 b0 = (rgb0 & 0x000000ff) << 16;
7905 r1 = (rgb1 & 0x00ff0000);
7906 g1 = (rgb1 & 0x0000ff00) << 8;
7907 b1 = (rgb1 & 0x000000ff) << 16;
7914 dr = ((int32_t)r1 - (int32_t)r0) / dy;
7915 dg = ((int32_t)g1 - (int32_t)g0) / dy;
7916 db = ((int32_t)b1 - (int32_t)b0) / dy;
7920 dr = ((int32_t)r1 - (int32_t)r0);
7921 dg = ((int32_t)g1 - (int32_t)g0);
7922 db = ((int32_t)b1 - (int32_t)b0);
7925 d = 2*dx - dy; /* Initial value of d */
7926 incrS = 2*dx; /* incr. used for move to S */
7927 incrSE = 2*(dx - dy); /* incr. used for move to SE */
7929 if ((x0>=drawX)&&(x0<drawW)&&(y0>=drawY)&&(y0<drawH))
7930 GetShadeTransCol(&psxVuw[(y0<<10)+x0],(unsigned short)(((r0 >> 9)&0x7c00)|((g0 >> 14)&0x03e0)|((b0 >> 19)&0x001f)));
7935 d = d + incrS; /* Choose S */
7939 d = d + incrSE; /* Choose SE */
7948 if ((x0>=drawX)&&(x0<drawW)&&(y0>=drawY)&&(y0<drawH))
7949 GetShadeTransCol(&psxVuw[(y0<<10)+x0],(unsigned short)(((r0 >> 9)&0x7c00)|((g0 >> 14)&0x03e0)|((b0 >> 19)&0x001f)));
7953 ///////////////////////////////////////////////////////////////////////
7955 void Line_N_NE_Shade(int x0, int y0, int x1, int y1, uint32_t rgb0, uint32_t rgb1)
7957 int dx, dy, incrN, incrNE, d;
7958 uint32_t r0, g0, b0, r1, g1, b1;
7961 r0 = (rgb0 & 0x00ff0000);
7962 g0 = (rgb0 & 0x0000ff00) << 8;
7963 b0 = (rgb0 & 0x000000ff) << 16;
7964 r1 = (rgb1 & 0x00ff0000);
7965 g1 = (rgb1 & 0x0000ff00) << 8;
7966 b1 = (rgb1 & 0x000000ff) << 16;
7973 dr = ((int32_t)r1 - (int32_t)r0) / dy;
7974 dg = ((int32_t)g1 - (int32_t)g0) / dy;
7975 db = ((int32_t)b1 - (int32_t)b0) / dy;
7979 dr = ((int32_t)r1 - (int32_t)r0);
7980 dg = ((int32_t)g1 - (int32_t)g0);
7981 db = ((int32_t)b1 - (int32_t)b0);
7984 d = 2*dx - dy; /* Initial value of d */
7985 incrN = 2*dx; /* incr. used for move to N */
7986 incrNE = 2*(dx - dy); /* incr. used for move to NE */
7988 if ((x0>=drawX)&&(x0<drawW)&&(y0>=drawY)&&(y0<drawH))
7989 GetShadeTransCol(&psxVuw[(y0<<10)+x0],(unsigned short)(((r0 >> 9)&0x7c00)|((g0 >> 14)&0x03e0)|((b0 >> 19)&0x001f)));
7994 d = d + incrN; /* Choose N */
7998 d = d + incrNE; /* Choose NE */
8007 if ((x0>=drawX)&&(x0<drawW)&&(y0>=drawY)&&(y0<drawH))
8008 GetShadeTransCol(&psxVuw[(y0<<10)+x0],(unsigned short)(((r0 >> 9)&0x7c00)|((g0 >> 14)&0x03e0)|((b0 >> 19)&0x001f)));
8012 ///////////////////////////////////////////////////////////////////////
8014 void Line_E_NE_Shade(int x0, int y0, int x1, int y1, uint32_t rgb0, uint32_t rgb1)
8016 int dx, dy, incrE, incrNE, d;
8017 uint32_t r0, g0, b0, r1, g1, b1;
8020 r0 = (rgb0 & 0x00ff0000);
8021 g0 = (rgb0 & 0x0000ff00) << 8;
8022 b0 = (rgb0 & 0x000000ff) << 16;
8023 r1 = (rgb1 & 0x00ff0000);
8024 g1 = (rgb1 & 0x0000ff00) << 8;
8025 b1 = (rgb1 & 0x000000ff) << 16;
8032 dr = ((int32_t)r1 - (int32_t)r0) / dx;
8033 dg = ((int32_t)g1 - (int32_t)g0) / dx;
8034 db = ((int32_t)b1 - (int32_t)b0) / dx;
8038 dr = ((int32_t)r1 - (int32_t)r0);
8039 dg = ((int32_t)g1 - (int32_t)g0);
8040 db = ((int32_t)b1 - (int32_t)b0);
8043 d = 2*dy - dx; /* Initial value of d */
8044 incrE = 2*dy; /* incr. used for move to E */
8045 incrNE = 2*(dy - dx); /* incr. used for move to NE */
8047 if ((x0>=drawX)&&(x0<drawW)&&(y0>=drawY)&&(y0<drawH))
8048 GetShadeTransCol(&psxVuw[(y0<<10)+x0],(unsigned short)(((r0 >> 9)&0x7c00)|((g0 >> 14)&0x03e0)|((b0 >> 19)&0x001f)));
8053 d = d + incrE; /* Choose E */
8057 d = d + incrNE; /* Choose NE */
8066 if ((x0>=drawX)&&(x0<drawW)&&(y0>=drawY)&&(y0<drawH))
8067 GetShadeTransCol(&psxVuw[(y0<<10)+x0],(unsigned short)(((r0 >> 9)&0x7c00)|((g0 >> 14)&0x03e0)|((b0 >> 19)&0x001f)));
8071 ///////////////////////////////////////////////////////////////////////
8073 void VertLineShade(int x, int y0, int y1, uint32_t rgb0, uint32_t rgb1)
8076 uint32_t r0, g0, b0, r1, g1, b1;
8079 r0 = (rgb0 & 0x00ff0000);
8080 g0 = (rgb0 & 0x0000ff00) << 8;
8081 b0 = (rgb0 & 0x000000ff) << 16;
8082 r1 = (rgb1 & 0x00ff0000);
8083 g1 = (rgb1 & 0x0000ff00) << 8;
8084 b1 = (rgb1 & 0x000000ff) << 16;
8090 dr = ((int32_t)r1 - (int32_t)r0) / dy;
8091 dg = ((int32_t)g1 - (int32_t)g0) / dy;
8092 db = ((int32_t)b1 - (int32_t)b0) / dy;
8096 dr = ((int32_t)r1 - (int32_t)r0);
8097 dg = ((int32_t)g1 - (int32_t)g0);
8098 db = ((int32_t)b1 - (int32_t)b0);
8103 r0+=dr*(drawY - y0);
8104 g0+=dg*(drawY - y0);
8105 b0+=db*(drawY - y0);
8112 for (y = y0; y <= y1; y++)
8114 GetShadeTransCol(&psxVuw[(y<<10)+x],(unsigned short)(((r0 >> 9)&0x7c00)|((g0 >> 14)&0x03e0)|((b0 >> 19)&0x001f)));
8121 ///////////////////////////////////////////////////////////////////////
8123 void HorzLineShade(int y, int x0, int x1, uint32_t rgb0, uint32_t rgb1)
8126 uint32_t r0, g0, b0, r1, g1, b1;
8129 r0 = (rgb0 & 0x00ff0000);
8130 g0 = (rgb0 & 0x0000ff00) << 8;
8131 b0 = (rgb0 & 0x000000ff) << 16;
8132 r1 = (rgb1 & 0x00ff0000);
8133 g1 = (rgb1 & 0x0000ff00) << 8;
8134 b1 = (rgb1 & 0x000000ff) << 16;
8140 dr = ((int32_t)r1 - (int32_t)r0) / dx;
8141 dg = ((int32_t)g1 - (int32_t)g0) / dx;
8142 db = ((int32_t)b1 - (int32_t)b0) / dx;
8146 dr = ((int32_t)r1 - (int32_t)r0);
8147 dg = ((int32_t)g1 - (int32_t)g0);
8148 db = ((int32_t)b1 - (int32_t)b0);
8153 r0+=dr*(drawX - x0);
8154 g0+=dg*(drawX - x0);
8155 b0+=db*(drawX - x0);
8162 for (x = x0; x <= x1; x++)
8164 GetShadeTransCol(&psxVuw[(y<<10)+x],(unsigned short)(((r0 >> 9)&0x7c00)|((g0 >> 14)&0x03e0)|((b0 >> 19)&0x001f)));
8171 ///////////////////////////////////////////////////////////////////////
8173 void Line_E_SE_Flat(int x0, int y0, int x1, int y1, unsigned short colour)
8175 int dx, dy, incrE, incrSE, d, x, y;
8179 d = 2*dy - dx; /* Initial value of d */
8180 incrE = 2*dy; /* incr. used for move to E */
8181 incrSE = 2*(dy - dx); /* incr. used for move to SE */
8184 if ((x>=drawX)&&(x<drawW)&&(y>=drawY)&&(y<drawH))
8185 GetShadeTransCol(&psxVuw[(y<<10)+x], colour);
8190 d = d + incrE; /* Choose E */
8195 d = d + incrSE; /* Choose SE */
8199 if ((x>=drawX)&&(x<drawW)&&(y>=drawY)&&(y<drawH))
8200 GetShadeTransCol(&psxVuw[(y<<10)+x], colour);
8204 ///////////////////////////////////////////////////////////////////////
8206 void Line_S_SE_Flat(int x0, int y0, int x1, int y1, unsigned short colour)
8208 int dx, dy, incrS, incrSE, d, x, y;
8212 d = 2*dx - dy; /* Initial value of d */
8213 incrS = 2*dx; /* incr. used for move to S */
8214 incrSE = 2*(dx - dy); /* incr. used for move to SE */
8217 if ((x>=drawX)&&(x<drawW)&&(y>=drawY)&&(y<drawH))
8218 GetShadeTransCol(&psxVuw[(y<<10)+x], colour);
8223 d = d + incrS; /* Choose S */
8228 d = d + incrSE; /* Choose SE */
8232 if ((x>=drawX)&&(x<drawW)&&(y>=drawY)&&(y<drawH))
8233 GetShadeTransCol(&psxVuw[(y<<10)+x], colour);
8237 ///////////////////////////////////////////////////////////////////////
8239 void Line_N_NE_Flat(int x0, int y0, int x1, int y1, unsigned short colour)
8241 int dx, dy, incrN, incrNE, d, x, y;
8245 d = 2*dx - dy; /* Initial value of d */
8246 incrN = 2*dx; /* incr. used for move to N */
8247 incrNE = 2*(dx - dy); /* incr. used for move to NE */
8250 if ((x>=drawX)&&(x<drawW)&&(y>=drawY)&&(y<drawH))
8251 GetShadeTransCol(&psxVuw[(y<<10)+x], colour);
8256 d = d + incrN; /* Choose N */
8261 d = d + incrNE; /* Choose NE */
8265 if ((x>=drawX)&&(x<drawW)&&(y>=drawY)&&(y<drawH))
8266 GetShadeTransCol(&psxVuw[(y<<10)+x], colour);
8270 ///////////////////////////////////////////////////////////////////////
8272 void Line_E_NE_Flat(int x0, int y0, int x1, int y1, unsigned short colour)
8274 int dx, dy, incrE, incrNE, d, x, y;
8278 d = 2*dy - dx; /* Initial value of d */
8279 incrE = 2*dy; /* incr. used for move to E */
8280 incrNE = 2*(dy - dx); /* incr. used for move to NE */
8283 if ((x>=drawX)&&(x<drawW)&&(y>=drawY)&&(y<drawH))
8284 GetShadeTransCol(&psxVuw[(y<<10)+x], colour);
8289 d = d + incrE; /* Choose E */
8294 d = d + incrNE; /* Choose NE */
8298 if ((x>=drawX)&&(x<drawW)&&(y>=drawY)&&(y<drawH))
8299 GetShadeTransCol(&psxVuw[(y<<10)+x], colour);
8303 ///////////////////////////////////////////////////////////////////////
8305 void VertLineFlat(int x, int y0, int y1, unsigned short colour)
8315 for (y = y0; y <= y1; y++)
8316 GetShadeTransCol(&psxVuw[(y<<10)+x], colour);
8319 ///////////////////////////////////////////////////////////////////////
8321 void HorzLineFlat(int y, int x0, int x1, unsigned short colour)
8331 for (x = x0; x <= x1; x++)
8332 GetShadeTransCol(&psxVuw[(y << 10) + x], colour);
8335 ///////////////////////////////////////////////////////////////////////
8337 /* Bresenham Line drawing function */
8338 void DrawSoftwareLineShade(int32_t rgb0, int32_t rgb1)
8340 short x0, y0, x1, y1, xt, yt;
8344 if (lx0 > drawW && lx1 > drawW) return;
8345 if (ly0 > drawH && ly1 > drawH) return;
8346 if (lx0 < drawX && lx1 < drawX) return;
8347 if (ly0 < drawY && ly1 < drawY) return;
8348 if (drawY >= drawH) return;
8349 if (drawX >= drawW) return;
8362 VertLineShade(x0, y0, y1, rgb0, rgb1);
8364 VertLineShade(x0, y1, y0, rgb1, rgb0);
8370 HorzLineShade(y0, x0, x1, rgb0, rgb1);
8372 HorzLineShade(y0, x1, x0, rgb1, rgb0);
8397 Line_S_SE_Shade(x0, y0, x1, y1, rgb0, rgb1);
8399 Line_E_SE_Shade(x0, y0, x1, y1, rgb0, rgb1);
8403 Line_N_NE_Shade(x0, y0, x1, y1, rgb0, rgb1);
8405 Line_E_NE_Shade(x0, y0, x1, y1, rgb0, rgb1);
8409 ///////////////////////////////////////////////////////////////////////
8411 void DrawSoftwareLineFlat(int32_t rgb)
8413 short x0, y0, x1, y1, xt, yt;
8415 unsigned short colour = 0;
8417 if (lx0 > drawW && lx1 > drawW) return;
8418 if (ly0 > drawH && ly1 > drawH) return;
8419 if (lx0 < drawX && lx1 < drawX) return;
8420 if (ly0 < drawY && ly1 < drawY) return;
8421 if (drawY >= drawH) return;
8422 if (drawX >= drawW) return;
8424 colour = ((rgb & 0x00f80000) >> 9) | ((rgb & 0x0000f800) >> 6) | ((rgb & 0x000000f8) >> 3);
8437 return; // Nothing to draw
8439 VertLineFlat(x0, y0, y1, colour);
8441 VertLineFlat(x0, y1, y0, colour);
8447 HorzLineFlat(y0, x0, x1, colour);
8449 HorzLineFlat(y0, x1, x0, colour);
8471 Line_S_SE_Flat(x0, y0, x1, y1, colour);
8473 Line_E_SE_Flat(x0, y0, x1, y1, colour);
8477 Line_N_NE_Flat(x0, y0, x1, y1, colour);
8479 Line_E_NE_Flat(x0, y0, x1, y1, colour);
8483 ///////////////////////////////////////////////////////////////////////