1 /***************************************************************************
4 begin : Sun Oct 28 2001
5 copyright : (C) 2001 by Pete Bernert
6 email : BlackDove@addcom.de
7 ***************************************************************************/
8 /***************************************************************************
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. See also the license.txt file for *
14 * additional informations. *
16 ***************************************************************************/
18 // switches for painting textured quads as 2 triangles (small glitches, but better shading!)
19 // can be toggled by game fix 0x200 in version 1.17 anyway, so let the defines enabled!
23 // fast solid loops... a bit more additional code, of course
26 // psx blending mode 3 with 25% incoming color (instead 50% without the define)
27 #define HALFBRIGHTMODE3
29 // color decode defines
31 #define XCOL1(x) (x & 0x1f)
32 #define XCOL2(x) (x & 0x3e0)
33 #define XCOL3(x) (x & 0x7c00)
35 #define XCOL1D(x) (x & 0x1f)
36 #define XCOL2D(x) ((x>>5) & 0x1f)
37 #define XCOL3D(x) ((x>>10) & 0x1f)
39 #define X32TCOL1(x) ((x & 0x001f001f)<<7)
40 #define X32TCOL2(x) ((x & 0x03e003e0)<<2)
41 #define X32TCOL3(x) ((x & 0x7c007c00)>>3)
43 #define X32COL1(x) (x & 0x001f001f)
44 #define X32COL2(x) ((x>>5) & 0x001f001f)
45 #define X32COL3(x) ((x>>10) & 0x001f001f)
47 #define X32ACOL1(x) (x & 0x001e001e)
48 #define X32ACOL2(x) ((x>>5) & 0x001e001e)
49 #define X32ACOL3(x) ((x>>10) & 0x001e001e)
51 #define X32BCOL1(x) (x & 0x001c001c)
52 #define X32BCOL2(x) ((x>>5) & 0x001c001c)
53 #define X32BCOL3(x) ((x>>10) & 0x001c001c)
55 #define X32PSXCOL(r,g,b) ((g<<10)|(b<<5)|r)
57 #define XPSXCOL(r,g,b) ((g&0x7c00)|(b&0x3e0)|(r&0x1f))
60 short g_m1=255,g_m2=255,g_m3=255;
61 short DrawSemiTrans=FALSE;
64 short ly0,lx0,ly1,lx1,ly2,lx2,ly3,lx3; // global psx vertex coords
65 int32_t GlobalTextAddrX,GlobalTextAddrY,GlobalTextTP;
66 int32_t GlobalTextABR,GlobalTextPAGE;
68 ////////////////////////////////////////////////////////////////////////
69 // POLYGON OFFSET FUNCS
70 ////////////////////////////////////////////////////////////////////////
72 static void offsetPSX2(void)
74 lx0 += PSXDisplay.DrawOffset.x;
75 ly0 += PSXDisplay.DrawOffset.y;
76 lx1 += PSXDisplay.DrawOffset.x;
77 ly1 += PSXDisplay.DrawOffset.y;
80 static void offsetPSX3(void)
82 lx0 += PSXDisplay.DrawOffset.x;
83 ly0 += PSXDisplay.DrawOffset.y;
84 lx1 += PSXDisplay.DrawOffset.x;
85 ly1 += PSXDisplay.DrawOffset.y;
86 lx2 += PSXDisplay.DrawOffset.x;
87 ly2 += PSXDisplay.DrawOffset.y;
90 static void offsetPSX4(void)
92 lx0 += PSXDisplay.DrawOffset.x;
93 ly0 += PSXDisplay.DrawOffset.y;
94 lx1 += PSXDisplay.DrawOffset.x;
95 ly1 += PSXDisplay.DrawOffset.y;
96 lx2 += PSXDisplay.DrawOffset.x;
97 ly2 += PSXDisplay.DrawOffset.y;
98 lx3 += PSXDisplay.DrawOffset.x;
99 ly3 += PSXDisplay.DrawOffset.y;
102 /////////////////////////////////////////////////////////////////
103 /////////////////////////////////////////////////////////////////
104 /////////////////////////////////////////////////////////////////
106 ////////////////////////////////////////////////////////////////////////
107 /////////////////////////////////////////////////////////////////
108 /////////////////////////////////////////////////////////////////
111 unsigned char dithertable[16] =
119 static inline void Dither16(unsigned short * pdest,uint32_t r,uint32_t g,uint32_t b,unsigned short sM)
122 unsigned char rlow, glow, blow;
129 coeff = dithertable[(y&3)*4+(x&3)];
131 rlow = r&7; glow = g&7; blow = b&7;
135 if ((r < 0x1F) && rlow > coeff) r++;
136 if ((g < 0x1F) && glow > coeff) g++;
137 if ((b < 0x1F) && blow > coeff) b++;
139 PUTLE16(pdest, ((unsigned short)b<<10) |
140 ((unsigned short)g<<5) |
141 (unsigned short)r | sM);
144 /////////////////////////////////////////////////////////////////
145 /////////////////////////////////////////////////////////////////
146 /////////////////////////////////////////////////////////////////
148 static inline void GetShadeTransCol_Dither(unsigned short * pdest, int32_t m1, int32_t m2, int32_t m3)
152 if(bCheckMask && (*pdest & HOST2LE16(0x8000))) return;
156 r=((XCOL1D(GETLE16(pdest)))<<3);
157 b=((XCOL2D(GETLE16(pdest)))<<3);
158 g=((XCOL3D(GETLE16(pdest)))<<3);
179 if(r&0x80000000) r=0;
180 if(b&0x80000000) b=0;
181 if(g&0x80000000) g=0;
185 #ifdef HALFBRIGHTMODE3
203 if(r&0x7FFFFF00) r=0xff;
204 if(b&0x7FFFFF00) b=0xff;
205 if(g&0x7FFFFF00) g=0xff;
207 Dither16(pdest,r,b,g,sSetMask);
210 ////////////////////////////////////////////////////////////////////////
212 static inline void GetShadeTransCol(unsigned short * pdest,unsigned short color)
214 if(bCheckMask && (*pdest & HOST2LE16(0x8000))) return;
222 PUTLE16(pdest, (((GETLE16(pdest)&0x7bde)>>1)+(((color)&0x7bde)>>1))|sSetMask);//0x8000;
228 r=(XCOL1(GETLE16(pdest)))+((XCOL1(color)));
229 b=(XCOL2(GETLE16(pdest)))+((XCOL2(color)));
230 g=(XCOL3(GETLE16(pdest)))+((XCOL3(color)));
235 r=(XCOL1(GETLE16(pdest)))-((XCOL1(color)));
236 b=(XCOL2(GETLE16(pdest)))-((XCOL2(color)));
237 g=(XCOL3(GETLE16(pdest)))-((XCOL3(color)));
238 if(r&0x80000000) r=0;
239 if(b&0x80000000) b=0;
240 if(g&0x80000000) g=0;
244 #ifdef HALFBRIGHTMODE3
245 r=(XCOL1(GETLE16(pdest)))+((XCOL1(color))>>2);
246 b=(XCOL2(GETLE16(pdest)))+((XCOL2(color))>>2);
247 g=(XCOL3(GETLE16(pdest)))+((XCOL3(color))>>2);
249 r=(XCOL1(GETLE16(pdest)))+((XCOL1(color))>>1);
250 b=(XCOL2(GETLE16(pdest)))+((XCOL2(color))>>1);
251 g=(XCOL3(GETLE16(pdest)))+((XCOL3(color))>>1);
255 if(r&0x7FFFFFE0) r=0x1f;
256 if(b&0x7FFFFC00) b=0x3e0;
257 if(g&0x7FFF8000) g=0x7c00;
259 PUTLE16(pdest, (XPSXCOL(r,g,b))|sSetMask);//0x8000;
261 else PUTLE16(pdest, color|sSetMask);
264 ////////////////////////////////////////////////////////////////////////
266 static inline void GetShadeTransCol32(uint32_t * pdest,uint32_t color)
276 PUTLE32(pdest, (((GETLE32(pdest)&0x7bde7bde)>>1)+(((color)&0x7bde7bde)>>1))|lSetMask);//0x80008000;
279 r=(X32ACOL1(GETLE32(pdest))>>1)+((X32ACOL1(color))>>1);
280 b=(X32ACOL2(GETLE32(pdest))>>1)+((X32ACOL2(color))>>1);
281 g=(X32ACOL3(GETLE32(pdest))>>1)+((X32ACOL3(color))>>1);
286 r=(X32COL1(GETLE32(pdest)))+((X32COL1(color)));
287 b=(X32COL2(GETLE32(pdest)))+((X32COL2(color)));
288 g=(X32COL3(GETLE32(pdest)))+((X32COL3(color)));
293 int32_t sr,sb,sg,src,sbc,sgc,c;
294 src=XCOL1(color);sbc=XCOL2(color);sgc=XCOL3(color);
295 c=GETLE32(pdest)>>16;
296 sr=(XCOL1(c))-src; if(sr&0x8000) sr=0;
297 sb=(XCOL2(c))-sbc; if(sb&0x8000) sb=0;
298 sg=(XCOL3(c))-sgc; if(sg&0x8000) sg=0;
299 r=((int32_t)sr)<<16;b=((int32_t)sb)<<11;g=((int32_t)sg)<<6;
300 c=LOWORD(GETLE32(pdest));
301 sr=(XCOL1(c))-src; if(sr&0x8000) sr=0;
302 sb=(XCOL2(c))-sbc; if(sb&0x8000) sb=0;
303 sg=(XCOL3(c))-sgc; if(sg&0x8000) sg=0;
304 r|=sr;b|=sb>>5;g|=sg>>10;
308 #ifdef HALFBRIGHTMODE3
309 r=(X32COL1(GETLE32(pdest)))+((X32BCOL1(color))>>2);
310 b=(X32COL2(GETLE32(pdest)))+((X32BCOL2(color))>>2);
311 g=(X32COL3(GETLE32(pdest)))+((X32BCOL3(color))>>2);
313 r=(X32COL1(GETLE32(pdest)))+((X32ACOL1(color))>>1);
314 b=(X32COL2(GETLE32(pdest)))+((X32ACOL2(color))>>1);
315 g=(X32COL3(GETLE32(pdest)))+((X32ACOL3(color))>>1);
319 if(r&0x7FE00000) r=0x1f0000|(r&0xFFFF);
320 if(r&0x7FE0) r=0x1f |(r&0xFFFF0000);
321 if(b&0x7FE00000) b=0x1f0000|(b&0xFFFF);
322 if(b&0x7FE0) b=0x1f |(b&0xFFFF0000);
323 if(g&0x7FE00000) g=0x1f0000|(g&0xFFFF);
324 if(g&0x7FE0) g=0x1f |(g&0xFFFF0000);
328 uint32_t ma=GETLE32(pdest);
329 PUTLE32(pdest, (X32PSXCOL(r,g,b))|lSetMask);//0x80008000;
330 if(ma&0x80000000) PUTLE32(pdest, (ma&0xFFFF0000)|(*pdest&0xFFFF));
331 if(ma&0x00008000) PUTLE32(pdest, (ma&0xFFFF) |(*pdest&0xFFFF0000));
334 PUTLE32(pdest, (X32PSXCOL(r,g,b))|lSetMask);//0x80008000;
340 uint32_t ma=GETLE32(pdest);
341 PUTLE32(pdest, color|lSetMask);//0x80008000;
342 if(ma&0x80000000) PUTLE32(pdest, (ma&0xFFFF0000)|(GETLE32(pdest)&0xFFFF));
343 if(ma&0x00008000) PUTLE32(pdest, (ma&0xFFFF) |(GETLE32(pdest)&0xFFFF0000));
347 PUTLE32(pdest, color|lSetMask);//0x80008000;
351 ////////////////////////////////////////////////////////////////////////
353 static inline void GetTextureTransColG(unsigned short * pdest,unsigned short color)
355 int32_t r,g,b;unsigned short l;
359 if(bCheckMask && (*pdest & HOST2LE16(0x8000))) return;
361 l=sSetMask|(color&0x8000);
363 if(DrawSemiTrans && (color&0x8000))
368 d =(GETLE16(pdest)&0x7bde)>>1;
369 color =((color) &0x7bde)>>1;
370 r=(XCOL1(d))+((((XCOL1(color)))* g_m1)>>7);
371 b=(XCOL2(d))+((((XCOL2(color)))* g_m2)>>7);
372 g=(XCOL3(d))+((((XCOL3(color)))* g_m3)>>7);
377 r=(XCOL1(GETLE16(pdest)))+((((XCOL1(color)))* g_m1)>>7);
378 b=(XCOL2(GETLE16(pdest)))+((((XCOL2(color)))* g_m2)>>7);
379 g=(XCOL3(GETLE16(pdest)))+((((XCOL3(color)))* g_m3)>>7);
384 r=(XCOL1(GETLE16(pdest)))-((((XCOL1(color)))* g_m1)>>7);
385 b=(XCOL2(GETLE16(pdest)))-((((XCOL2(color)))* g_m2)>>7);
386 g=(XCOL3(GETLE16(pdest)))-((((XCOL3(color)))* g_m3)>>7);
387 if(r&0x80000000) r=0;
388 if(b&0x80000000) b=0;
389 if(g&0x80000000) g=0;
393 #ifdef HALFBRIGHTMODE3
394 r=(XCOL1(GETLE16(pdest)))+((((XCOL1(color))>>2)* g_m1)>>7);
395 b=(XCOL2(GETLE16(pdest)))+((((XCOL2(color))>>2)* g_m2)>>7);
396 g=(XCOL3(GETLE16(pdest)))+((((XCOL3(color))>>2)* g_m3)>>7);
398 r=(XCOL1(GETLE16(pdest)))+((((XCOL1(color))>>1)* g_m1)>>7);
399 b=(XCOL2(GETLE16(pdest)))+((((XCOL2(color))>>1)* g_m2)>>7);
400 g=(XCOL3(GETLE16(pdest)))+((((XCOL3(color))>>1)* g_m3)>>7);
406 r=((XCOL1(color))* g_m1)>>7;
407 b=((XCOL2(color))* g_m2)>>7;
408 g=((XCOL3(color))* g_m3)>>7;
411 if(r&0x7FFFFFE0) r=0x1f;
412 if(b&0x7FFFFC00) b=0x3e0;
413 if(g&0x7FFF8000) g=0x7c00;
415 PUTLE16(pdest, (XPSXCOL(r,g,b))|l);
418 ////////////////////////////////////////////////////////////////////////
420 static inline void GetTextureTransColG_S(unsigned short * pdest,unsigned short color)
422 int32_t r,g,b;unsigned short l;
426 l=sSetMask|(color&0x8000);
428 r=((XCOL1(color))* g_m1)>>7;
429 b=((XCOL2(color))* g_m2)>>7;
430 g=((XCOL3(color))* g_m3)>>7;
432 if(r&0x7FFFFFE0) r=0x1f;
433 if(b&0x7FFFFC00) b=0x3e0;
434 if(g&0x7FFF8000) g=0x7c00;
436 PUTLE16(pdest, (XPSXCOL(r,g,b))|l);
439 ////////////////////////////////////////////////////////////////////////
441 static inline void GetTextureTransColG_SPR(unsigned short * pdest,unsigned short color)
443 int32_t r,g,b;unsigned short l;
447 if(bCheckMask && (GETLE16(pdest) & 0x8000)) return;
449 l=sSetMask|(color&0x8000);
451 if(DrawSemiTrans && (color&0x8000))
456 d =(GETLE16(pdest)&0x7bde)>>1;
457 color =((color) &0x7bde)>>1;
458 r=(XCOL1(d))+((((XCOL1(color)))* g_m1)>>7);
459 b=(XCOL2(d))+((((XCOL2(color)))* g_m2)>>7);
460 g=(XCOL3(d))+((((XCOL3(color)))* g_m3)>>7);
465 r=(XCOL1(GETLE16(pdest)))+((((XCOL1(color)))* g_m1)>>7);
466 b=(XCOL2(GETLE16(pdest)))+((((XCOL2(color)))* g_m2)>>7);
467 g=(XCOL3(GETLE16(pdest)))+((((XCOL3(color)))* g_m3)>>7);
472 r=(XCOL1(GETLE16(pdest)))-((((XCOL1(color)))* g_m1)>>7);
473 b=(XCOL2(GETLE16(pdest)))-((((XCOL2(color)))* g_m2)>>7);
474 g=(XCOL3(GETLE16(pdest)))-((((XCOL3(color)))* g_m3)>>7);
475 if(r&0x80000000) r=0;
476 if(b&0x80000000) b=0;
477 if(g&0x80000000) g=0;
481 #ifdef HALFBRIGHTMODE3
482 r=(XCOL1(GETLE16(pdest)))+((((XCOL1(color))>>2)* g_m1)>>7);
483 b=(XCOL2(GETLE16(pdest)))+((((XCOL2(color))>>2)* g_m2)>>7);
484 g=(XCOL3(GETLE16(pdest)))+((((XCOL3(color))>>2)* g_m3)>>7);
486 r=(XCOL1(GETLE16(pdest)))+((((XCOL1(color))>>1)* g_m1)>>7);
487 b=(XCOL2(GETLE16(pdest)))+((((XCOL2(color))>>1)* g_m2)>>7);
488 g=(XCOL3(GETLE16(pdest)))+((((XCOL3(color))>>1)* g_m3)>>7);
494 r=((XCOL1(color))* g_m1)>>7;
495 b=((XCOL2(color))* g_m2)>>7;
496 g=((XCOL3(color))* g_m3)>>7;
499 if(r&0x7FFFFFE0) r=0x1f;
500 if(b&0x7FFFFC00) b=0x3e0;
501 if(g&0x7FFF8000) g=0x7c00;
503 PUTLE16(pdest, (XPSXCOL(r,g,b))|l);
506 ////////////////////////////////////////////////////////////////////////
508 static inline void GetTextureTransColG32(uint32_t * pdest,uint32_t color)
514 l=lSetMask|(color&0x80008000);
516 if(DrawSemiTrans && (color&0x80008000))
520 r=((((X32TCOL1(GETLE32(pdest)))+((X32COL1(color)) * g_m1))&0xFF00FF00)>>8);
521 b=((((X32TCOL2(GETLE32(pdest)))+((X32COL2(color)) * g_m2))&0xFF00FF00)>>8);
522 g=((((X32TCOL3(GETLE32(pdest)))+((X32COL3(color)) * g_m3))&0xFF00FF00)>>8);
527 r=(X32COL1(GETLE32(pdest)))+(((((X32COL1(color)))* g_m1)&0xFF80FF80)>>7);
528 b=(X32COL2(GETLE32(pdest)))+(((((X32COL2(color)))* g_m2)&0xFF80FF80)>>7);
529 g=(X32COL3(GETLE32(pdest)))+(((((X32COL3(color)))* g_m3)&0xFF80FF80)>>7);
535 r=(((((X32COL1(color)))* g_m1)&0xFF80FF80)>>7);
536 t=(GETLE32(pdest)&0x001f0000)-(r&0x003f0000); if(t&0x80000000) t=0;
537 r=(GETLE32(pdest)&0x0000001f)-(r&0x0000003f); if(r&0x80000000) r=0;
540 b=(((((X32COL2(color)))* g_m2)&0xFF80FF80)>>7);
541 t=((GETLE32(pdest)>>5)&0x001f0000)-(b&0x003f0000); if(t&0x80000000) t=0;
542 b=((GETLE32(pdest)>>5)&0x0000001f)-(b&0x0000003f); if(b&0x80000000) b=0;
545 g=(((((X32COL3(color)))* g_m3)&0xFF80FF80)>>7);
546 t=((GETLE32(pdest)>>10)&0x001f0000)-(g&0x003f0000); if(t&0x80000000) t=0;
547 g=((GETLE32(pdest)>>10)&0x0000001f)-(g&0x0000003f); if(g&0x80000000) g=0;
552 #ifdef HALFBRIGHTMODE3
553 r=(X32COL1(GETLE32(pdest)))+(((((X32BCOL1(color))>>2)* g_m1)&0xFF80FF80)>>7);
554 b=(X32COL2(GETLE32(pdest)))+(((((X32BCOL2(color))>>2)* g_m2)&0xFF80FF80)>>7);
555 g=(X32COL3(GETLE32(pdest)))+(((((X32BCOL3(color))>>2)* g_m3)&0xFF80FF80)>>7);
557 r=(X32COL1(GETLE32(pdest)))+(((((X32ACOL1(color))>>1)* g_m1)&0xFF80FF80)>>7);
558 b=(X32COL2(GETLE32(pdest)))+(((((X32ACOL2(color))>>1)* g_m2)&0xFF80FF80)>>7);
559 g=(X32COL3(GETLE32(pdest)))+(((((X32ACOL3(color))>>1)* g_m3)&0xFF80FF80)>>7);
565 r=(r&0xffff0000)|((((X32COL1(color))* g_m1)&0x0000FF80)>>7);
566 b=(b&0xffff0000)|((((X32COL2(color))* g_m2)&0x0000FF80)>>7);
567 g=(g&0xffff0000)|((((X32COL3(color))* g_m3)&0x0000FF80)>>7);
569 if(!(color&0x80000000))
571 r=(r&0xffff)|((((X32COL1(color))* g_m1)&0xFF800000)>>7);
572 b=(b&0xffff)|((((X32COL2(color))* g_m2)&0xFF800000)>>7);
573 g=(g&0xffff)|((((X32COL3(color))* g_m3)&0xFF800000)>>7);
579 r=(((X32COL1(color))* g_m1)&0xFF80FF80)>>7;
580 b=(((X32COL2(color))* g_m2)&0xFF80FF80)>>7;
581 g=(((X32COL3(color))* g_m3)&0xFF80FF80)>>7;
584 if(r&0x7FE00000) r=0x1f0000|(r&0xFFFF);
585 if(r&0x7FE0) r=0x1f |(r&0xFFFF0000);
586 if(b&0x7FE00000) b=0x1f0000|(b&0xFFFF);
587 if(b&0x7FE0) b=0x1f |(b&0xFFFF0000);
588 if(g&0x7FE00000) g=0x1f0000|(g&0xFFFF);
589 if(g&0x7FE0) g=0x1f |(g&0xFFFF0000);
593 uint32_t ma=GETLE32(pdest);
595 PUTLE32(pdest, (X32PSXCOL(r,g,b))|l);
597 if((color&0xffff)==0 ) PUTLE32(pdest, (ma&0xffff)|(GETLE32(pdest)&0xffff0000));
598 if((color&0xffff0000)==0) PUTLE32(pdest, (ma&0xffff0000)|(GETLE32(pdest)&0xffff));
599 if(ma&0x80000000) PUTLE32(pdest, (ma&0xFFFF0000)|(GETLE32(pdest)&0xFFFF));
600 if(ma&0x00008000) PUTLE32(pdest, (ma&0xFFFF) |(GETLE32(pdest)&0xFFFF0000));
604 if((color&0xffff)==0 ) {PUTLE32(pdest, (GETLE32(pdest)&0xffff)|(((X32PSXCOL(r,g,b))|l)&0xffff0000));return;}
605 if((color&0xffff0000)==0) {PUTLE32(pdest, (GETLE32(pdest)&0xffff0000)|(((X32PSXCOL(r,g,b))|l)&0xffff));return;}
607 PUTLE32(pdest, (X32PSXCOL(r,g,b))|l);
610 ////////////////////////////////////////////////////////////////////////
612 static inline void GetTextureTransColG32_S(uint32_t * pdest,uint32_t color)
618 r=(((X32COL1(color))* g_m1)&0xFF80FF80)>>7;
619 b=(((X32COL2(color))* g_m2)&0xFF80FF80)>>7;
620 g=(((X32COL3(color))* g_m3)&0xFF80FF80)>>7;
622 if(r&0x7FE00000) r=0x1f0000|(r&0xFFFF);
623 if(r&0x7FE0) r=0x1f |(r&0xFFFF0000);
624 if(b&0x7FE00000) b=0x1f0000|(b&0xFFFF);
625 if(b&0x7FE0) b=0x1f |(b&0xFFFF0000);
626 if(g&0x7FE00000) g=0x1f0000|(g&0xFFFF);
627 if(g&0x7FE0) g=0x1f |(g&0xFFFF0000);
629 if((color&0xffff)==0) {PUTLE32(pdest, (GETLE32(pdest)&0xffff)|(((X32PSXCOL(r,g,b))|lSetMask|(color&0x80008000))&0xffff0000));return;}
630 if((color&0xffff0000)==0) {PUTLE32(pdest, (GETLE32(pdest)&0xffff0000)|(((X32PSXCOL(r,g,b))|lSetMask|(color&0x80008000))&0xffff));return;}
632 PUTLE32(pdest, (X32PSXCOL(r,g,b))|lSetMask|(color&0x80008000));
635 ////////////////////////////////////////////////////////////////////////
637 static inline void GetTextureTransColG32_SPR(uint32_t * pdest,uint32_t color)
643 if(DrawSemiTrans && (color&0x80008000))
647 r=((((X32TCOL1(GETLE32(pdest)))+((X32COL1(color)) * g_m1))&0xFF00FF00)>>8);
648 b=((((X32TCOL2(GETLE32(pdest)))+((X32COL2(color)) * g_m2))&0xFF00FF00)>>8);
649 g=((((X32TCOL3(GETLE32(pdest)))+((X32COL3(color)) * g_m3))&0xFF00FF00)>>8);
654 r=(X32COL1(GETLE32(pdest)))+(((((X32COL1(color)))* g_m1)&0xFF80FF80)>>7);
655 b=(X32COL2(GETLE32(pdest)))+(((((X32COL2(color)))* g_m2)&0xFF80FF80)>>7);
656 g=(X32COL3(GETLE32(pdest)))+(((((X32COL3(color)))* g_m3)&0xFF80FF80)>>7);
662 r=(((((X32COL1(color)))* g_m1)&0xFF80FF80)>>7);
663 t=(GETLE32(pdest)&0x001f0000)-(r&0x003f0000); if(t&0x80000000) t=0;
664 r=(GETLE32(pdest)&0x0000001f)-(r&0x0000003f); if(r&0x80000000) r=0;
667 b=(((((X32COL2(color)))* g_m2)&0xFF80FF80)>>7);
668 t=((GETLE32(pdest)>>5)&0x001f0000)-(b&0x003f0000); if(t&0x80000000) t=0;
669 b=((GETLE32(pdest)>>5)&0x0000001f)-(b&0x0000003f); if(b&0x80000000) b=0;
672 g=(((((X32COL3(color)))* g_m3)&0xFF80FF80)>>7);
673 t=((GETLE32(pdest)>>10)&0x001f0000)-(g&0x003f0000); if(t&0x80000000) t=0;
674 g=((GETLE32(pdest)>>10)&0x0000001f)-(g&0x0000003f); if(g&0x80000000) g=0;
679 #ifdef HALFBRIGHTMODE3
680 r=(X32COL1(GETLE32(pdest)))+(((((X32BCOL1(color))>>2)* g_m1)&0xFF80FF80)>>7);
681 b=(X32COL2(GETLE32(pdest)))+(((((X32BCOL2(color))>>2)* g_m2)&0xFF80FF80)>>7);
682 g=(X32COL3(GETLE32(pdest)))+(((((X32BCOL3(color))>>2)* g_m3)&0xFF80FF80)>>7);
684 r=(X32COL1(GETLE32(pdest)))+(((((X32ACOL1(color))>>1)* g_m1)&0xFF80FF80)>>7);
685 b=(X32COL2(GETLE32(pdest)))+(((((X32ACOL2(color))>>1)* g_m2)&0xFF80FF80)>>7);
686 g=(X32COL3(GETLE32(pdest)))+(((((X32ACOL3(color))>>1)* g_m3)&0xFF80FF80)>>7);
692 r=(r&0xffff0000)|((((X32COL1(color))* g_m1)&0x0000FF80)>>7);
693 b=(b&0xffff0000)|((((X32COL2(color))* g_m2)&0x0000FF80)>>7);
694 g=(g&0xffff0000)|((((X32COL3(color))* g_m3)&0x0000FF80)>>7);
696 if(!(color&0x80000000))
698 r=(r&0xffff)|((((X32COL1(color))* g_m1)&0xFF800000)>>7);
699 b=(b&0xffff)|((((X32COL2(color))* g_m2)&0xFF800000)>>7);
700 g=(g&0xffff)|((((X32COL3(color))* g_m3)&0xFF800000)>>7);
706 r=(((X32COL1(color))* g_m1)&0xFF80FF80)>>7;
707 b=(((X32COL2(color))* g_m2)&0xFF80FF80)>>7;
708 g=(((X32COL3(color))* g_m3)&0xFF80FF80)>>7;
711 if(r&0x7FE00000) r=0x1f0000|(r&0xFFFF);
712 if(r&0x7FE0) r=0x1f |(r&0xFFFF0000);
713 if(b&0x7FE00000) b=0x1f0000|(b&0xFFFF);
714 if(b&0x7FE0) b=0x1f |(b&0xFFFF0000);
715 if(g&0x7FE00000) g=0x1f0000|(g&0xFFFF);
716 if(g&0x7FE0) g=0x1f |(g&0xFFFF0000);
720 uint32_t ma=GETLE32(pdest);
722 PUTLE32(pdest, (X32PSXCOL(r,g,b))|lSetMask|(color&0x80008000));
724 if((color&0xffff)==0 ) PUTLE32(pdest, (ma&0xffff)|(GETLE32(pdest)&0xffff0000));
725 if((color&0xffff0000)==0) PUTLE32(pdest, (ma&0xffff0000)|(GETLE32(pdest)&0xffff));
726 if(ma&0x80000000) PUTLE32(pdest, (ma&0xFFFF0000)|(GETLE32(pdest)&0xFFFF));
727 if(ma&0x00008000) PUTLE32(pdest, (ma&0xFFFF) |(GETLE32(pdest)&0xFFFF0000));
731 if((color&0xffff)==0 ) {PUTLE32(pdest, (GETLE32(pdest)&0xffff)|(((X32PSXCOL(r,g,b))|lSetMask|(color&0x80008000))&0xffff0000));return;}
732 if((color&0xffff0000)==0) {PUTLE32(pdest, (GETLE32(pdest)&0xffff0000)|(((X32PSXCOL(r,g,b))|lSetMask|(color&0x80008000))&0xffff));return;}
734 PUTLE32(pdest, (X32PSXCOL(r,g,b))|lSetMask|(color&0x80008000));
737 ////////////////////////////////////////////////////////////////////////
739 static inline void GetTextureTransColGX_Dither(unsigned short * pdest,unsigned short color,int32_t m1,int32_t m2,int32_t m3)
745 if(bCheckMask && (*pdest & HOST2LE16(0x8000))) return;
747 m1=(((XCOL1D(color)))*m1)>>4;
748 m2=(((XCOL2D(color)))*m2)>>4;
749 m3=(((XCOL3D(color)))*m3)>>4;
751 if(DrawSemiTrans && (color&0x8000))
753 r=((XCOL1D(GETLE16(pdest)))<<3);
754 b=((XCOL2D(GETLE16(pdest)))<<3);
755 g=((XCOL3D(GETLE16(pdest)))<<3);
776 if(r&0x80000000) r=0;
777 if(b&0x80000000) b=0;
778 if(g&0x80000000) g=0;
782 #ifdef HALFBRIGHTMODE3
800 if(r&0x7FFFFF00) r=0xff;
801 if(b&0x7FFFFF00) b=0xff;
802 if(g&0x7FFFFF00) g=0xff;
804 Dither16(pdest,r,b,g,sSetMask|(color&0x8000));
808 ////////////////////////////////////////////////////////////////////////
810 static inline void GetTextureTransColGX(unsigned short * pdest,unsigned short color,short m1,short m2,short m3)
812 int32_t r,g,b;unsigned short l;
816 if(bCheckMask && (*pdest & HOST2LE16(0x8000))) return;
818 l=sSetMask|(color&0x8000);
820 if(DrawSemiTrans && (color&0x8000))
825 d =(GETLE16(pdest)&0x7bde)>>1;
826 color =((color) &0x7bde)>>1;
827 r=(XCOL1(d))+((((XCOL1(color)))* m1)>>7);
828 b=(XCOL2(d))+((((XCOL2(color)))* m2)>>7);
829 g=(XCOL3(d))+((((XCOL3(color)))* m3)>>7);
834 r=(XCOL1(GETLE16(pdest)))+((((XCOL1(color)))* m1)>>7);
835 b=(XCOL2(GETLE16(pdest)))+((((XCOL2(color)))* m2)>>7);
836 g=(XCOL3(GETLE16(pdest)))+((((XCOL3(color)))* m3)>>7);
841 r=(XCOL1(GETLE16(pdest)))-((((XCOL1(color)))* m1)>>7);
842 b=(XCOL2(GETLE16(pdest)))-((((XCOL2(color)))* m2)>>7);
843 g=(XCOL3(GETLE16(pdest)))-((((XCOL3(color)))* m3)>>7);
844 if(r&0x80000000) r=0;
845 if(b&0x80000000) b=0;
846 if(g&0x80000000) g=0;
850 #ifdef HALFBRIGHTMODE3
851 r=(XCOL1(GETLE16(pdest)))+((((XCOL1(color))>>2)* m1)>>7);
852 b=(XCOL2(GETLE16(pdest)))+((((XCOL2(color))>>2)* m2)>>7);
853 g=(XCOL3(GETLE16(pdest)))+((((XCOL3(color))>>2)* m3)>>7);
855 r=(XCOL1(GETLE16(pdest)))+((((XCOL1(color))>>1)* m1)>>7);
856 b=(XCOL2(GETLE16(pdest)))+((((XCOL2(color))>>1)* m2)>>7);
857 g=(XCOL3(GETLE16(pdest)))+((((XCOL3(color))>>1)* m3)>>7);
863 r=((XCOL1(color))* m1)>>7;
864 b=((XCOL2(color))* m2)>>7;
865 g=((XCOL3(color))* m3)>>7;
868 if(r&0x7FFFFFE0) r=0x1f;
869 if(b&0x7FFFFC00) b=0x3e0;
870 if(g&0x7FFF8000) g=0x7c00;
872 PUTLE16(pdest, (XPSXCOL(r,g,b))|l);
875 ////////////////////////////////////////////////////////////////////////
877 static inline void GetTextureTransColGX_S(unsigned short * pdest,unsigned short color,short m1,short m2,short m3)
883 r=((XCOL1(color))* m1)>>7;
884 b=((XCOL2(color))* m2)>>7;
885 g=((XCOL3(color))* m3)>>7;
887 if(r&0x7FFFFFE0) r=0x1f;
888 if(b&0x7FFFFC00) b=0x3e0;
889 if(g&0x7FFF8000) g=0x7c00;
891 PUTLE16(pdest, (XPSXCOL(r,g,b))|sSetMask|(color&0x8000));
894 ////////////////////////////////////////////////////////////////////////
896 static inline void GetTextureTransColGX32_S(uint32_t * pdest,uint32_t color,short m1,short m2,short m3)
902 r=(((X32COL1(color))* m1)&0xFF80FF80)>>7;
903 b=(((X32COL2(color))* m2)&0xFF80FF80)>>7;
904 g=(((X32COL3(color))* m3)&0xFF80FF80)>>7;
906 if(r&0x7FE00000) r=0x1f0000|(r&0xFFFF);
907 if(r&0x7FE0) r=0x1f |(r&0xFFFF0000);
908 if(b&0x7FE00000) b=0x1f0000|(b&0xFFFF);
909 if(b&0x7FE0) b=0x1f |(b&0xFFFF0000);
910 if(g&0x7FE00000) g=0x1f0000|(g&0xFFFF);
911 if(g&0x7FE0) g=0x1f |(g&0xFFFF0000);
913 if((color&0xffff)==0) {PUTLE32(pdest, (GETLE32(pdest)&0xffff)|(((X32PSXCOL(r,g,b))|lSetMask|(color&0x80008000))&0xffff0000));return;}
914 if((color&0xffff0000)==0) {PUTLE32(pdest, (GETLE32(pdest)&0xffff0000)|(((X32PSXCOL(r,g,b))|lSetMask|(color&0x80008000))&0xffff));return;}
916 PUTLE32(pdest, (X32PSXCOL(r,g,b))|lSetMask|(color&0x80008000));
919 ////////////////////////////////////////////////////////////////////////
921 ////////////////////////////////////////////////////////////////////////
923 static void FillSoftwareAreaTrans(short x0,short y0,short x1, // FILL AREA TRANS
924 short y1,unsigned short col)
949 if(dx==1 && dy==1 && x0==1020 && y0==511) // special fix for pinball game... emu protection???
953 if(iCheat==1) iCheat=0; else iCheat=1;
957 if(dx&1) // slow fill
959 unsigned short *DSTPtr;
960 unsigned short LineOffset;
961 DSTPtr = psxVuw + (1024*y0) + x0;
962 LineOffset = 1024 - dx;
966 GetShadeTransCol(DSTPtr++,col);
967 DSTPtr += LineOffset;
973 unsigned short LineOffset;
974 uint32_t lcol=lSetMask|(((uint32_t)(col))<<16)|col;
976 DSTPtr = (uint32_t *)(psxVuw + (1024*y0) + x0);
977 LineOffset = 512 - dx;
979 if(!bCheckMask && !DrawSemiTrans)
983 for(j=0;j<dx;j++) { PUTLE32(DSTPtr, lcol); DSTPtr++; }
984 DSTPtr += LineOffset;
992 GetShadeTransCol32(DSTPtr++,lcol);
993 DSTPtr += LineOffset;
999 ////////////////////////////////////////////////////////////////////////
1001 static void FillSoftwareArea(short x0,short y0,short x1, // FILL AREA (BLK FILL)
1002 short y1,unsigned short col) // no draw area check here!
1006 // ?? ff9 pal hooligan crack sets nonsense x0
1017 if(x1>1024) x1=1024;
1022 unsigned short *DSTPtr;
1023 unsigned short LineOffset;
1025 DSTPtr = psxVuw + (1024*y0) + x0;
1026 LineOffset = 1024 - dx;
1030 for(j=0;j<dx;j++) { PUTLE16(DSTPtr, col); DSTPtr++; }
1031 DSTPtr += LineOffset;
1037 unsigned short LineOffset;
1038 uint32_t lcol=(((int32_t)col)<<16)|col;
1040 DSTPtr = (uint32_t *)(psxVuw + (1024*y0) + x0);
1041 LineOffset = 512 - dx;
1045 for(j=0;j<dx;j++) { PUTLE32(DSTPtr, lcol); DSTPtr++; }
1046 DSTPtr += LineOffset;
1051 ////////////////////////////////////////////////////////////////////////
1052 ////////////////////////////////////////////////////////////////////////
1053 ////////////////////////////////////////////////////////////////////////
1054 // EDGE INTERPOLATION
1055 ////////////////////////////////////////////////////////////////////////
1056 ////////////////////////////////////////////////////////////////////////
1057 ////////////////////////////////////////////////////////////////////////
1059 typedef struct SOFTVTAG
1066 static soft_vertex vtx[4];
1067 static soft_vertex * left_array[4], * right_array[4];
1068 static int left_section, right_section;
1069 static int left_section_height, right_section_height;
1070 static int left_x, delta_left_x, right_x, delta_right_x;
1071 static int left_u, delta_left_u, left_v, delta_left_v;
1072 static int right_u, delta_right_u, right_v, delta_right_v;
1073 static int left_R, delta_left_R, right_R, delta_right_R;
1074 static int left_G, delta_left_G, right_G, delta_right_G;
1075 static int left_B, delta_left_B, right_B, delta_right_B;
1078 static inline int shl10idiv(int x, int y)
1080 #ifdef __ARM_ARCH_7A__
1081 // rearmed: let's use VFP divider instead
1082 float r = 1024.0f * (float)x / (float)y;
1091 ////////////////////////////////////////////////////////////////////////
1092 ////////////////////////////////////////////////////////////////////////
1093 ////////////////////////////////////////////////////////////////////////
1095 static inline int RightSection_F(void)
1097 soft_vertex * v1 = right_array[ right_section ];
1098 soft_vertex * v2 = right_array[ right_section-1 ];
1100 int height = v2->y - v1->y;
1101 if(height == 0) return 0;
1102 delta_right_x = (v2->x - v1->x) / height;
1105 right_section_height = height;
1109 ////////////////////////////////////////////////////////////////////////
1111 static inline int LeftSection_F(void)
1113 soft_vertex * v1 = left_array[ left_section ];
1114 soft_vertex * v2 = left_array[ left_section-1 ];
1116 int height = v2->y - v1->y;
1117 if(height == 0) return 0;
1118 delta_left_x = (v2->x - v1->x) / height;
1121 left_section_height = height;
1125 ////////////////////////////////////////////////////////////////////////
1127 static inline BOOL NextRow_F(void)
1129 if(--left_section_height<=0)
1131 if(--left_section <= 0) {return TRUE;}
1132 if(LeftSection_F() <= 0) {return TRUE;}
1136 left_x += delta_left_x;
1139 if(--right_section_height<=0)
1141 if(--right_section<=0) {return TRUE;}
1142 if(RightSection_F() <=0) {return TRUE;}
1146 right_x += delta_right_x;
1151 ////////////////////////////////////////////////////////////////////////
1153 static inline BOOL SetupSections_F(short x1, short y1, short x2, short y2, short x3, short y3)
1155 soft_vertex * v1, * v2, * v3;
1158 v1 = vtx; v1->x=x1<<16;v1->y=y1;
1159 v2 = vtx+1; v2->x=x2<<16;v2->y=y2;
1160 v3 = vtx+2; v3->x=x3<<16;v3->y=y3;
1162 if(v1->y > v2->y) { soft_vertex * v = v1; v1 = v2; v2 = v; }
1163 if(v1->y > v3->y) { soft_vertex * v = v1; v1 = v3; v3 = v; }
1164 if(v2->y > v3->y) { soft_vertex * v = v2; v2 = v3; v3 = v; }
1166 height = v3->y - v1->y;
1167 if(height == 0) {return FALSE;}
1168 longest = (((v2->y - v1->y) << 16) / height) * ((v3->x - v1->x)>>16) + (v1->x - v2->x);
1169 if(longest == 0) {return FALSE;}
1173 right_array[0] = v3;
1174 right_array[1] = v2;
1175 right_array[2] = v1;
1181 if(LeftSection_F() <= 0) return FALSE;
1182 if(RightSection_F() <= 0)
1185 if(RightSection_F() <= 0) return FALSE;
1194 right_array[0] = v3;
1195 right_array[1] = v1;
1198 if(RightSection_F() <= 0) return FALSE;
1199 if(LeftSection_F() <= 0)
1202 if(LeftSection_F() <= 0) return FALSE;
1207 Ymax=min(v3->y-1,drawH);
1212 ////////////////////////////////////////////////////////////////////////
1213 ////////////////////////////////////////////////////////////////////////
1215 static inline int RightSection_G(void)
1217 soft_vertex * v1 = right_array[ right_section ];
1218 soft_vertex * v2 = right_array[ right_section-1 ];
1220 int height = v2->y - v1->y;
1221 if(height == 0) return 0;
1222 delta_right_x = (v2->x - v1->x) / height;
1225 right_section_height = height;
1229 ////////////////////////////////////////////////////////////////////////
1231 static inline int LeftSection_G(void)
1233 soft_vertex * v1 = left_array[ left_section ];
1234 soft_vertex * v2 = left_array[ left_section-1 ];
1236 int height = v2->y - v1->y;
1237 if(height == 0) return 0;
1238 delta_left_x = (v2->x - v1->x) / height;
1241 delta_left_R = ((v2->R - v1->R)) / height;
1243 delta_left_G = ((v2->G - v1->G)) / height;
1245 delta_left_B = ((v2->B - v1->B)) / height;
1248 left_section_height = height;
1252 ////////////////////////////////////////////////////////////////////////
1254 static inline BOOL NextRow_G(void)
1256 if(--left_section_height<=0)
1258 if(--left_section <= 0) {return TRUE;}
1259 if(LeftSection_G() <= 0) {return TRUE;}
1263 left_x += delta_left_x;
1264 left_R += delta_left_R;
1265 left_G += delta_left_G;
1266 left_B += delta_left_B;
1269 if(--right_section_height<=0)
1271 if(--right_section<=0) {return TRUE;}
1272 if(RightSection_G() <=0) {return TRUE;}
1276 right_x += delta_right_x;
1281 ////////////////////////////////////////////////////////////////////////
1283 static inline BOOL SetupSections_G(short x1,short y1,short x2,short y2,short x3,short y3,int32_t rgb1, int32_t rgb2, int32_t rgb3)
1285 soft_vertex * v1, * v2, * v3;
1286 int height,longest,temp;
1288 v1 = vtx; v1->x=x1<<16;v1->y=y1;
1289 v1->R=(rgb1) & 0x00ff0000;
1290 v1->G=(rgb1<<8) & 0x00ff0000;
1291 v1->B=(rgb1<<16) & 0x00ff0000;
1292 v2 = vtx+1; v2->x=x2<<16;v2->y=y2;
1293 v2->R=(rgb2) & 0x00ff0000;
1294 v2->G=(rgb2<<8) & 0x00ff0000;
1295 v2->B=(rgb2<<16) & 0x00ff0000;
1296 v3 = vtx+2; v3->x=x3<<16;v3->y=y3;
1297 v3->R=(rgb3) & 0x00ff0000;
1298 v3->G=(rgb3<<8) & 0x00ff0000;
1299 v3->B=(rgb3<<16) & 0x00ff0000;
1301 if(v1->y > v2->y) { soft_vertex * v = v1; v1 = v2; v2 = v; }
1302 if(v1->y > v3->y) { soft_vertex * v = v1; v1 = v3; v3 = v; }
1303 if(v2->y > v3->y) { soft_vertex * v = v2; v2 = v3; v3 = v; }
1305 height = v3->y - v1->y;
1306 if(height == 0) {return FALSE;}
1307 temp=(((v2->y - v1->y) << 16) / height);
1308 longest = temp * ((v3->x - v1->x)>>16) + (v1->x - v2->x);
1309 if(longest == 0) {return FALSE;}
1313 right_array[0] = v3;
1314 right_array[1] = v2;
1315 right_array[2] = v1;
1321 if(LeftSection_G() <= 0) return FALSE;
1322 if(RightSection_G() <= 0)
1325 if(RightSection_G() <= 0) return FALSE;
1327 if(longest > -0x1000) longest = -0x1000;
1335 right_array[0] = v3;
1336 right_array[1] = v1;
1339 if(RightSection_G() <= 0) return FALSE;
1340 if(LeftSection_G() <= 0)
1343 if(LeftSection_G() <= 0) return FALSE;
1345 if(longest < 0x1000) longest = 0x1000;
1349 Ymax=min(v3->y-1,drawH);
1351 delta_right_R=shl10idiv(temp*((v3->R - v1->R)>>10)+((v1->R - v2->R)<<6),longest);
1352 delta_right_G=shl10idiv(temp*((v3->G - v1->G)>>10)+((v1->G - v2->G)<<6),longest);
1353 delta_right_B=shl10idiv(temp*((v3->B - v1->B)>>10)+((v1->B - v2->B)<<6),longest);
1358 ////////////////////////////////////////////////////////////////////////
1359 ////////////////////////////////////////////////////////////////////////
1361 static inline int RightSection_FT(void)
1363 soft_vertex * v1 = right_array[ right_section ];
1364 soft_vertex * v2 = right_array[ right_section-1 ];
1366 int height = v2->y - v1->y;
1367 if(height == 0) return 0;
1368 delta_right_x = (v2->x - v1->x) / height;
1371 right_section_height = height;
1375 ////////////////////////////////////////////////////////////////////////
1377 static inline int LeftSection_FT(void)
1379 soft_vertex * v1 = left_array[ left_section ];
1380 soft_vertex * v2 = left_array[ left_section-1 ];
1382 int height = v2->y - v1->y;
1383 if(height == 0) return 0;
1384 delta_left_x = (v2->x - v1->x) / height;
1387 delta_left_u = ((v2->u - v1->u)) / height;
1389 delta_left_v = ((v2->v - v1->v)) / height;
1392 left_section_height = height;
1396 ////////////////////////////////////////////////////////////////////////
1398 static inline BOOL NextRow_FT(void)
1400 if(--left_section_height<=0)
1402 if(--left_section <= 0) {return TRUE;}
1403 if(LeftSection_FT() <= 0) {return TRUE;}
1407 left_x += delta_left_x;
1408 left_u += delta_left_u;
1409 left_v += delta_left_v;
1412 if(--right_section_height<=0)
1414 if(--right_section<=0) {return TRUE;}
1415 if(RightSection_FT() <=0) {return TRUE;}
1419 right_x += delta_right_x;
1424 ////////////////////////////////////////////////////////////////////////
1426 static inline BOOL SetupSections_FT(short x1, short y1, short x2, short y2, short x3, short y3, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3)
1428 soft_vertex * v1, * v2, * v3;
1429 int height,longest,temp;
1431 v1 = vtx; v1->x=x1<<16;v1->y=y1;
1432 v1->u=tx1<<16;v1->v=ty1<<16;
1433 v2 = vtx+1; v2->x=x2<<16;v2->y=y2;
1434 v2->u=tx2<<16;v2->v=ty2<<16;
1435 v3 = vtx+2; v3->x=x3<<16;v3->y=y3;
1436 v3->u=tx3<<16;v3->v=ty3<<16;
1438 if(v1->y > v2->y) { soft_vertex * v = v1; v1 = v2; v2 = v; }
1439 if(v1->y > v3->y) { soft_vertex * v = v1; v1 = v3; v3 = v; }
1440 if(v2->y > v3->y) { soft_vertex * v = v2; v2 = v3; v3 = v; }
1442 height = v3->y - v1->y;
1443 if(height == 0) {return FALSE;}
1445 temp=(((v2->y - v1->y) << 16) / height);
1446 longest = temp * ((v3->x - v1->x)>>16) + (v1->x - v2->x);
1448 if(longest == 0) {return FALSE;}
1452 right_array[0] = v3;
1453 right_array[1] = v2;
1454 right_array[2] = v1;
1460 if(LeftSection_FT() <= 0) return FALSE;
1461 if(RightSection_FT() <= 0)
1464 if(RightSection_FT() <= 0) return FALSE;
1466 if(longest > -0x1000) longest = -0x1000;
1474 right_array[0] = v3;
1475 right_array[1] = v1;
1478 if(RightSection_FT() <= 0) return FALSE;
1479 if(LeftSection_FT() <= 0)
1482 if(LeftSection_FT() <= 0) return FALSE;
1484 if(longest < 0x1000) longest = 0x1000;
1488 Ymax=min(v3->y-1,drawH);
1490 delta_right_u=shl10idiv(temp*((v3->u - v1->u)>>10)+((v1->u - v2->u)<<6),longest);
1491 delta_right_v=shl10idiv(temp*((v3->v - v1->v)>>10)+((v1->v - v2->v)<<6),longest);
1496 ////////////////////////////////////////////////////////////////////////
1497 ////////////////////////////////////////////////////////////////////////
1499 static inline int RightSection_GT(void)
1501 soft_vertex * v1 = right_array[ right_section ];
1502 soft_vertex * v2 = right_array[ right_section-1 ];
1504 int height = v2->y - v1->y;
1505 if(height == 0) return 0;
1506 delta_right_x = (v2->x - v1->x) / height;
1509 right_section_height = height;
1513 ////////////////////////////////////////////////////////////////////////
1515 static inline int LeftSection_GT(void)
1517 soft_vertex * v1 = left_array[ left_section ];
1518 soft_vertex * v2 = left_array[ left_section-1 ];
1520 int height = v2->y - v1->y;
1521 if(height == 0) return 0;
1522 delta_left_x = (v2->x - v1->x) / height;
1525 delta_left_u = ((v2->u - v1->u)) / height;
1527 delta_left_v = ((v2->v - v1->v)) / height;
1530 delta_left_R = ((v2->R - v1->R)) / height;
1532 delta_left_G = ((v2->G - v1->G)) / height;
1534 delta_left_B = ((v2->B - v1->B)) / height;
1537 left_section_height = height;
1541 ////////////////////////////////////////////////////////////////////////
1543 static inline BOOL NextRow_GT(void)
1545 if(--left_section_height<=0)
1547 if(--left_section <= 0) {return TRUE;}
1548 if(LeftSection_GT() <= 0) {return TRUE;}
1552 left_x += delta_left_x;
1553 left_u += delta_left_u;
1554 left_v += delta_left_v;
1555 left_R += delta_left_R;
1556 left_G += delta_left_G;
1557 left_B += delta_left_B;
1560 if(--right_section_height<=0)
1562 if(--right_section<=0) {return TRUE;}
1563 if(RightSection_GT() <=0) {return TRUE;}
1567 right_x += delta_right_x;
1572 ////////////////////////////////////////////////////////////////////////
1574 static inline BOOL SetupSections_GT(short x1, short y1, short x2, short y2, short x3, short y3, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, int32_t rgb1, int32_t rgb2, int32_t rgb3)
1576 soft_vertex * v1, * v2, * v3;
1577 int height,longest,temp;
1579 v1 = vtx; v1->x=x1<<16;v1->y=y1;
1580 v1->u=tx1<<16;v1->v=ty1<<16;
1581 v1->R=(rgb1) & 0x00ff0000;
1582 v1->G=(rgb1<<8) & 0x00ff0000;
1583 v1->B=(rgb1<<16) & 0x00ff0000;
1585 v2 = vtx+1; v2->x=x2<<16;v2->y=y2;
1586 v2->u=tx2<<16;v2->v=ty2<<16;
1587 v2->R=(rgb2) & 0x00ff0000;
1588 v2->G=(rgb2<<8) & 0x00ff0000;
1589 v2->B=(rgb2<<16) & 0x00ff0000;
1591 v3 = vtx+2; v3->x=x3<<16;v3->y=y3;
1592 v3->u=tx3<<16;v3->v=ty3<<16;
1593 v3->R=(rgb3) & 0x00ff0000;
1594 v3->G=(rgb3<<8) & 0x00ff0000;
1595 v3->B=(rgb3<<16) & 0x00ff0000;
1597 if(v1->y > v2->y) { soft_vertex * v = v1; v1 = v2; v2 = v; }
1598 if(v1->y > v3->y) { soft_vertex * v = v1; v1 = v3; v3 = v; }
1599 if(v2->y > v3->y) { soft_vertex * v = v2; v2 = v3; v3 = v; }
1601 height = v3->y - v1->y;
1602 if(height == 0) {return FALSE;}
1604 temp=(((v2->y - v1->y) << 16) / height);
1605 longest = temp * ((v3->x - v1->x)>>16) + (v1->x - v2->x);
1607 if(longest == 0) {return FALSE;}
1611 right_array[0] = v3;
1612 right_array[1] = v2;
1613 right_array[2] = v1;
1619 if(LeftSection_GT() <= 0) return FALSE;
1620 if(RightSection_GT() <= 0)
1623 if(RightSection_GT() <= 0) return FALSE;
1626 if(longest > -0x1000) longest = -0x1000;
1634 right_array[0] = v3;
1635 right_array[1] = v1;
1638 if(RightSection_GT() <= 0) return FALSE;
1639 if(LeftSection_GT() <= 0)
1642 if(LeftSection_GT() <= 0) return FALSE;
1644 if(longest < 0x1000) longest = 0x1000;
1648 Ymax=min(v3->y-1,drawH);
1650 delta_right_R=shl10idiv(temp*((v3->R - v1->R)>>10)+((v1->R - v2->R)<<6),longest);
1651 delta_right_G=shl10idiv(temp*((v3->G - v1->G)>>10)+((v1->G - v2->G)<<6),longest);
1652 delta_right_B=shl10idiv(temp*((v3->B - v1->B)>>10)+((v1->B - v2->B)<<6),longest);
1654 delta_right_u=shl10idiv(temp*((v3->u - v1->u)>>10)+((v1->u - v2->u)<<6),longest);
1655 delta_right_v=shl10idiv(temp*((v3->v - v1->v)>>10)+((v1->v - v2->v)<<6),longest);
1660 ////////////////////////////////////////////////////////////////////////
1661 ////////////////////////////////////////////////////////////////////////
1663 static inline int RightSection_F4(void)
1665 soft_vertex * v1 = right_array[ right_section ];
1666 soft_vertex * v2 = right_array[ right_section-1 ];
1668 int height = v2->y - v1->y;
1669 right_section_height = height;
1675 delta_right_x = (v2->x - v1->x) / height;
1680 ////////////////////////////////////////////////////////////////////////
1682 static inline int LeftSection_F4(void)
1684 soft_vertex * v1 = left_array[ left_section ];
1685 soft_vertex * v2 = left_array[ left_section-1 ];
1687 int height = v2->y - v1->y;
1688 left_section_height = height;
1694 delta_left_x = (v2->x - v1->x) / height;
1699 ////////////////////////////////////////////////////////////////////////
1701 static inline BOOL NextRow_F4(void)
1703 if(--left_section_height<=0)
1705 if(--left_section > 0)
1706 while(LeftSection_F4()<=0)
1708 if(--left_section <= 0) break;
1713 left_x += delta_left_x;
1716 if(--right_section_height<=0)
1718 if(--right_section > 0)
1719 while(RightSection_F4()<=0)
1721 if(--right_section<=0) break;
1726 right_x += delta_right_x;
1731 ////////////////////////////////////////////////////////////////////////
1733 static inline BOOL SetupSections_F4(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4)
1735 soft_vertex * v1, * v2, * v3, * v4;
1736 int height,width,longest1,longest2;
1738 v1 = vtx; v1->x=x1<<16;v1->y=y1;
1739 v2 = vtx+1; v2->x=x2<<16;v2->y=y2;
1740 v3 = vtx+2; v3->x=x3<<16;v3->y=y3;
1741 v4 = vtx+3; v4->x=x4<<16;v4->y=y4;
1743 if(v1->y > v2->y) { soft_vertex * v = v1; v1 = v2; v2 = v; }
1744 if(v1->y > v3->y) { soft_vertex * v = v1; v1 = v3; v3 = v; }
1745 if(v1->y > v4->y) { soft_vertex * v = v1; v1 = v4; v4 = v; }
1746 if(v2->y > v3->y) { soft_vertex * v = v2; v2 = v3; v3 = v; }
1747 if(v2->y > v4->y) { soft_vertex * v = v2; v2 = v4; v4 = v; }
1748 if(v3->y > v4->y) { soft_vertex * v = v3; v3 = v4; v4 = v; }
1750 height = v4->y - v1->y; if(height == 0) height =1;
1751 width = (v4->x - v1->x)>>16;
1752 longest1 = (((v2->y - v1->y) << 16) / height) * width + (v1->x - v2->x);
1753 longest2 = (((v3->y - v1->y) << 16) / height) * width + (v1->x - v3->x);
1755 if(longest1 < 0) // 2 is right
1757 if(longest2 < 0) // 3 is right
1763 height = v3->y - v1->y; if(height == 0) height=1;
1764 longest1 = (((v2->y - v1->y) << 16) / height) * ((v3->x - v1->x)>>16) + (v1->x - v2->x);
1767 right_array[0] = v4; // 1
1768 right_array[1] = v3; // 3
1769 right_array[2] = v1; // 4
1774 height = v4->y - v2->y; if(height == 0) height=1;
1775 longest1 = (((v3->y - v2->y) << 16) / height) * ((v4->x - v2->x)>>16) + (v2->x - v3->x);
1778 right_array[0] = v4; // 1
1779 right_array[1] = v2; // 2
1780 right_array[2] = v1; // 4
1785 right_array[0] = v4; // 1
1786 right_array[1] = v3; // 2
1787 right_array[2] = v2; // 3
1788 right_array[3] = v1; // 4
1796 left_array[1] = v3; // 1
1797 left_array[2] = v1; // 2
1798 left_section = 2; // 3
1799 right_array[0] = v4; // 4
1800 right_array[1] = v2;
1801 right_array[2] = v1;
1809 left_array[0] = v4; // 1
1810 left_array[1] = v2; // 2
1811 left_array[2] = v1; // 3
1812 left_section = 2; // 4
1813 right_array[0] = v4;
1814 right_array[1] = v3;
1815 right_array[2] = v1;
1820 right_array[0] = v4;
1821 right_array[1] = v1;
1824 height = v3->y - v1->y; if(height == 0) height=1;
1825 longest1 = (((v2->y - v1->y) << 16) / height) * ((v3->x - v1->x)>>16) + (v1->x - v2->x);
1828 left_array[0] = v4; // 1
1829 left_array[1] = v3; // 3
1830 left_array[2] = v1; // 4
1835 height = v4->y - v2->y; if(height == 0) height=1;
1836 longest1 = (((v3->y - v2->y) << 16) / height) * ((v4->x - v2->x)>>16) + (v2->x - v3->x);
1839 left_array[0] = v4; // 1
1840 left_array[1] = v2; // 2
1841 left_array[2] = v1; // 4
1846 left_array[0] = v4; // 1
1847 left_array[1] = v3; // 2
1848 left_array[2] = v2; // 3
1849 left_array[3] = v1; // 4
1856 while(LeftSection_F4()<=0)
1858 if(--left_section <= 0) break;
1861 while(RightSection_F4()<=0)
1863 if(--right_section <= 0) break;
1867 Ymax=min(v4->y-1,drawH);
1872 ////////////////////////////////////////////////////////////////////////
1873 ////////////////////////////////////////////////////////////////////////
1875 static inline int RightSection_FT4(void)
1877 soft_vertex * v1 = right_array[ right_section ];
1878 soft_vertex * v2 = right_array[ right_section-1 ];
1880 int height = v2->y - v1->y;
1881 right_section_height = height;
1889 delta_right_x = (v2->x - v1->x) / height;
1890 delta_right_u = (v2->u - v1->u) / height;
1891 delta_right_v = (v2->v - v1->v) / height;
1896 ////////////////////////////////////////////////////////////////////////
1898 static inline int LeftSection_FT4(void)
1900 soft_vertex * v1 = left_array[ left_section ];
1901 soft_vertex * v2 = left_array[ left_section-1 ];
1903 int height = v2->y - v1->y;
1904 left_section_height = height;
1912 delta_left_x = (v2->x - v1->x) / height;
1913 delta_left_u = (v2->u - v1->u) / height;
1914 delta_left_v = (v2->v - v1->v) / height;
1919 ////////////////////////////////////////////////////////////////////////
1921 static inline BOOL NextRow_FT4(void)
1923 if(--left_section_height<=0)
1925 if(--left_section > 0)
1926 while(LeftSection_FT4()<=0)
1928 if(--left_section <= 0) break;
1933 left_x += delta_left_x;
1934 left_u += delta_left_u;
1935 left_v += delta_left_v;
1938 if(--right_section_height<=0)
1940 if(--right_section > 0)
1941 while(RightSection_FT4()<=0)
1943 if(--right_section<=0) break;
1948 right_x += delta_right_x;
1949 right_u += delta_right_u;
1950 right_v += delta_right_v;
1955 ////////////////////////////////////////////////////////////////////////
1957 static inline BOOL SetupSections_FT4(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4)
1959 soft_vertex * v1, * v2, * v3, * v4;
1960 int height,width,longest1,longest2;
1962 v1 = vtx; v1->x=x1<<16;v1->y=y1;
1963 v1->u=tx1<<16;v1->v=ty1<<16;
1965 v2 = vtx+1; v2->x=x2<<16;v2->y=y2;
1966 v2->u=tx2<<16;v2->v=ty2<<16;
1968 v3 = vtx+2; v3->x=x3<<16;v3->y=y3;
1969 v3->u=tx3<<16;v3->v=ty3<<16;
1971 v4 = vtx+3; v4->x=x4<<16;v4->y=y4;
1972 v4->u=tx4<<16;v4->v=ty4<<16;
1974 if(v1->y > v2->y) { soft_vertex * v = v1; v1 = v2; v2 = v; }
1975 if(v1->y > v3->y) { soft_vertex * v = v1; v1 = v3; v3 = v; }
1976 if(v1->y > v4->y) { soft_vertex * v = v1; v1 = v4; v4 = v; }
1977 if(v2->y > v3->y) { soft_vertex * v = v2; v2 = v3; v3 = v; }
1978 if(v2->y > v4->y) { soft_vertex * v = v2; v2 = v4; v4 = v; }
1979 if(v3->y > v4->y) { soft_vertex * v = v3; v3 = v4; v4 = v; }
1981 height = v4->y - v1->y; if(height == 0) height =1;
1982 width = (v4->x - v1->x)>>16;
1983 longest1 = (((v2->y - v1->y) << 16) / height) * width + (v1->x - v2->x);
1984 longest2 = (((v3->y - v1->y) << 16) / height) * width + (v1->x - v3->x);
1986 if(longest1 < 0) // 2 is right
1988 if(longest2 < 0) // 3 is right
1994 height = v3->y - v1->y; if(height == 0) height=1;
1995 longest1 = (((v2->y - v1->y) << 16) / height) * ((v3->x - v1->x)>>16) + (v1->x - v2->x);
1998 right_array[0] = v4; // 1
1999 right_array[1] = v3; // 3
2000 right_array[2] = v1; // 4
2005 height = v4->y - v2->y; if(height == 0) height=1;
2006 longest1 = (((v3->y - v2->y) << 16) / height) * ((v4->x - v2->x)>>16) + (v2->x - v3->x);
2009 right_array[0] = v4; // 1
2010 right_array[1] = v2; // 2
2011 right_array[2] = v1; // 4
2016 right_array[0] = v4; // 1
2017 right_array[1] = v3; // 2
2018 right_array[2] = v2; // 3
2019 right_array[3] = v1; // 4
2027 left_array[1] = v3; // 1
2028 left_array[2] = v1; // 2
2029 left_section = 2; // 3
2030 right_array[0] = v4; // 4
2031 right_array[1] = v2;
2032 right_array[2] = v1;
2040 left_array[0] = v4; // 1
2041 left_array[1] = v2; // 2
2042 left_array[2] = v1; // 3
2043 left_section = 2; // 4
2044 right_array[0] = v4;
2045 right_array[1] = v3;
2046 right_array[2] = v1;
2051 right_array[0] = v4;
2052 right_array[1] = v1;
2055 height = v3->y - v1->y; if(height == 0) height=1;
2056 longest1 = (((v2->y - v1->y) << 16) / height) * ((v3->x - v1->x)>>16) + (v1->x - v2->x);
2059 left_array[0] = v4; // 1
2060 left_array[1] = v3; // 3
2061 left_array[2] = v1; // 4
2066 height = v4->y - v2->y; if(height == 0) height=1;
2067 longest1 = (((v3->y - v2->y) << 16) / height) * ((v4->x - v2->x)>>16) + (v2->x - v3->x);
2070 left_array[0] = v4; // 1
2071 left_array[1] = v2; // 2
2072 left_array[2] = v1; // 4
2077 left_array[0] = v4; // 1
2078 left_array[1] = v3; // 2
2079 left_array[2] = v2; // 3
2080 left_array[3] = v1; // 4
2087 while(LeftSection_FT4()<=0)
2089 if(--left_section <= 0) break;
2092 while(RightSection_FT4()<=0)
2094 if(--right_section <= 0) break;
2098 Ymax=min(v4->y-1,drawH);
2103 ////////////////////////////////////////////////////////////////////////
2104 ////////////////////////////////////////////////////////////////////////
2106 static inline int RightSection_GT4(void)
2108 soft_vertex * v1 = right_array[ right_section ];
2109 soft_vertex * v2 = right_array[ right_section-1 ];
2111 int height = v2->y - v1->y;
2112 right_section_height = height;
2124 delta_right_x = (v2->x - v1->x) / height;
2125 delta_right_u = (v2->u - v1->u) / height;
2126 delta_right_v = (v2->v - v1->v) / height;
2127 delta_right_R = (v2->R - v1->R) / height;
2128 delta_right_G = (v2->G - v1->G) / height;
2129 delta_right_B = (v2->B - v1->B) / height;
2134 ////////////////////////////////////////////////////////////////////////
2136 static inline int LeftSection_GT4(void)
2138 soft_vertex * v1 = left_array[ left_section ];
2139 soft_vertex * v2 = left_array[ left_section-1 ];
2141 int height = v2->y - v1->y;
2142 left_section_height = height;
2154 delta_left_x = (v2->x - v1->x) / height;
2155 delta_left_u = (v2->u - v1->u) / height;
2156 delta_left_v = (v2->v - v1->v) / height;
2157 delta_left_R = (v2->R - v1->R) / height;
2158 delta_left_G = (v2->G - v1->G) / height;
2159 delta_left_B = (v2->B - v1->B) / height;
2164 ////////////////////////////////////////////////////////////////////////
2166 static inline BOOL NextRow_GT4(void)
2168 if(--left_section_height<=0)
2170 if(--left_section > 0)
2171 while(LeftSection_GT4()<=0)
2173 if(--left_section <= 0) break;
2178 left_x += delta_left_x;
2179 left_u += delta_left_u;
2180 left_v += delta_left_v;
2181 left_R += delta_left_R;
2182 left_G += delta_left_G;
2183 left_B += delta_left_B;
2186 if(--right_section_height<=0)
2188 if(--right_section > 0)
2189 while(RightSection_GT4()<=0)
2191 if(--right_section<=0) break;
2196 right_x += delta_right_x;
2197 right_u += delta_right_u;
2198 right_v += delta_right_v;
2199 right_R += delta_right_R;
2200 right_G += delta_right_G;
2201 right_B += delta_right_B;
2206 ////////////////////////////////////////////////////////////////////////
2208 static inline BOOL SetupSections_GT4(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4,int32_t rgb1,int32_t rgb2,int32_t rgb3,int32_t rgb4)
2210 soft_vertex * v1, * v2, * v3, * v4;
2211 int height,width,longest1,longest2;
2213 v1 = vtx; v1->x=x1<<16;v1->y=y1;
2214 v1->u=tx1<<16;v1->v=ty1<<16;
2215 v1->R=(rgb1) & 0x00ff0000;
2216 v1->G=(rgb1<<8) & 0x00ff0000;
2217 v1->B=(rgb1<<16) & 0x00ff0000;
2219 v2 = vtx+1; v2->x=x2<<16;v2->y=y2;
2220 v2->u=tx2<<16;v2->v=ty2<<16;
2221 v2->R=(rgb2) & 0x00ff0000;
2222 v2->G=(rgb2<<8) & 0x00ff0000;
2223 v2->B=(rgb2<<16) & 0x00ff0000;
2225 v3 = vtx+2; v3->x=x3<<16;v3->y=y3;
2226 v3->u=tx3<<16;v3->v=ty3<<16;
2227 v3->R=(rgb3) & 0x00ff0000;
2228 v3->G=(rgb3<<8) & 0x00ff0000;
2229 v3->B=(rgb3<<16) & 0x00ff0000;
2231 v4 = vtx+3; v4->x=x4<<16;v4->y=y4;
2232 v4->u=tx4<<16;v4->v=ty4<<16;
2233 v4->R=(rgb4) & 0x00ff0000;
2234 v4->G=(rgb4<<8) & 0x00ff0000;
2235 v4->B=(rgb4<<16) & 0x00ff0000;
2237 if(v1->y > v2->y) { soft_vertex * v = v1; v1 = v2; v2 = v; }
2238 if(v1->y > v3->y) { soft_vertex * v = v1; v1 = v3; v3 = v; }
2239 if(v1->y > v4->y) { soft_vertex * v = v1; v1 = v4; v4 = v; }
2240 if(v2->y > v3->y) { soft_vertex * v = v2; v2 = v3; v3 = v; }
2241 if(v2->y > v4->y) { soft_vertex * v = v2; v2 = v4; v4 = v; }
2242 if(v3->y > v4->y) { soft_vertex * v = v3; v3 = v4; v4 = v; }
2244 height = v4->y - v1->y; if(height == 0) height =1;
2245 width = (v4->x - v1->x)>>16;
2246 longest1 = (((v2->y - v1->y) << 16) / height) * width + (v1->x - v2->x);
2247 longest2 = (((v3->y - v1->y) << 16) / height) * width + (v1->x - v3->x);
2249 if(longest1 < 0) // 2 is right
2251 if(longest2 < 0) // 3 is right
2257 height = v3->y - v1->y; if(height == 0) height=1;
2258 longest1 = (((v2->y - v1->y) << 16) / height) * ((v3->x - v1->x)>>16) + (v1->x - v2->x);
2261 right_array[0] = v4; // 1
2262 right_array[1] = v3; // 3
2263 right_array[2] = v1; // 4
2268 height = v4->y - v2->y; if(height == 0) height=1;
2269 longest1 = (((v3->y - v2->y) << 16) / height) * ((v4->x - v2->x)>>16) + (v2->x - v3->x);
2272 right_array[0] = v4; // 1
2273 right_array[1] = v2; // 2
2274 right_array[2] = v1; // 4
2279 right_array[0] = v4; // 1
2280 right_array[1] = v3; // 2
2281 right_array[2] = v2; // 3
2282 right_array[3] = v1; // 4
2290 left_array[1] = v3; // 1
2291 left_array[2] = v1; // 2
2292 left_section = 2; // 3
2293 right_array[0] = v4; // 4
2294 right_array[1] = v2;
2295 right_array[2] = v1;
2303 left_array[0] = v4; // 1
2304 left_array[1] = v2; // 2
2305 left_array[2] = v1; // 3
2306 left_section = 2; // 4
2307 right_array[0] = v4;
2308 right_array[1] = v3;
2309 right_array[2] = v1;
2314 right_array[0] = v4;
2315 right_array[1] = v1;
2318 height = v3->y - v1->y; if(height == 0) height=1;
2319 longest1 = (((v2->y - v1->y) << 16) / height) * ((v3->x - v1->x)>>16) + (v1->x - v2->x);
2322 left_array[0] = v4; // 1
2323 left_array[1] = v3; // 3
2324 left_array[2] = v1; // 4
2329 height = v4->y - v2->y; if(height == 0) height=1;
2330 longest1 = (((v3->y - v2->y) << 16) / height) * ((v4->x - v2->x)>>16) + (v2->x - v3->x);
2333 left_array[0] = v4; // 1
2334 left_array[1] = v2; // 2
2335 left_array[2] = v1; // 4
2340 left_array[0] = v4; // 1
2341 left_array[1] = v3; // 2
2342 left_array[2] = v2; // 3
2343 left_array[3] = v1; // 4
2350 while(LeftSection_GT4()<=0)
2352 if(--left_section <= 0) break;
2355 while(RightSection_GT4()<=0)
2357 if(--right_section <= 0) break;
2361 Ymax=min(v4->y-1,drawH);
2366 ////////////////////////////////////////////////////////////////////////
2367 ////////////////////////////////////////////////////////////////////////
2368 ////////////////////////////////////////////////////////////////////////
2370 ////////////////////////////////////////////////////////////////////////
2371 ////////////////////////////////////////////////////////////////////////
2372 ////////////////////////////////////////////////////////////////////////
2374 ////////////////////////////////////////////////////////////////////////
2375 // POLY 3/4 FLAT SHADED
2376 ////////////////////////////////////////////////////////////////////////
2378 static inline void drawPoly3Fi(short x1,short y1,short x2,short y2,short x3,short y3,int32_t rgb)
2380 int i,j,xmin,xmax,ymin,ymax;
2381 unsigned short color;uint32_t lcolor;
2383 if(x1>drawW && x2>drawW && x3>drawW) return;
2384 if(y1>drawH && y2>drawH && y3>drawH) return;
2385 if(x1<drawX && x2<drawX && x3<drawX) return;
2386 if(y1<drawY && y2<drawY && y3<drawY) return;
2387 if(drawY>=drawH) return;
2388 if(drawX>=drawW) return;
2390 if(!SetupSections_F(x1,y1,x2,y2,x3,y3)) return;
2394 color = ((rgb & 0x00f80000)>>9) | ((rgb & 0x0000f800)>>6) | ((rgb & 0x000000f8)>>3);
2395 lcolor=lSetMask|(((uint32_t)(color))<<16)|color;
2397 for(ymin=Ymin;ymin<drawY;ymin++)
2398 if(NextRow_F()) return;
2402 if(!bCheckMask && !DrawSemiTrans)
2405 for (i=ymin;i<=ymax;i++)
2407 xmin=left_x >> 16; if(drawX>xmin) xmin=drawX;
2408 xmax=(right_x >> 16)-1; if(drawW<xmax) xmax=drawW;
2410 for(j=xmin;j<xmax;j+=2)
2412 PUTLE32(((uint32_t *)&psxVuw[(i<<10)+j]), lcolor);
2414 if(j==xmax) PUTLE16(&psxVuw[(i<<10)+j], color);
2416 if(NextRow_F()) return;
2423 for (i=ymin;i<=ymax;i++)
2425 xmin=left_x >> 16; if(drawX>xmin) xmin=drawX;
2426 xmax=(right_x >> 16)-1; if(drawW<xmax) xmax=drawW;
2428 for(j=xmin;j<xmax;j+=2)
2430 GetShadeTransCol32((uint32_t *)&psxVuw[(i<<10)+j],lcolor);
2433 GetShadeTransCol(&psxVuw[(i<<10)+j],color);
2435 if(NextRow_F()) return;
2439 ////////////////////////////////////////////////////////////////////////
2441 static void drawPoly3F(int32_t rgb)
2443 drawPoly3Fi(lx0,ly0,lx1,ly1,lx2,ly2,rgb);
2448 static void drawPoly4F_TRI(int32_t rgb)
2450 drawPoly3Fi(lx1,ly1,lx3,ly3,lx2,ly2,rgb);
2451 drawPoly3Fi(lx0,ly0,lx1,ly1,lx2,ly2,rgb);
2458 static void drawPoly4F(int32_t rgb)
2460 int i,j,xmin,xmax,ymin,ymax;
2461 unsigned short color;uint32_t lcolor;
2463 if(lx0>drawW && lx1>drawW && lx2>drawW && lx3>drawW) return;
2464 if(ly0>drawH && ly1>drawH && ly2>drawH && ly3>drawH) return;
2465 if(lx0<drawX && lx1<drawX && lx2<drawX && lx3<drawX) return;
2466 if(ly0<drawY && ly1<drawY && ly2<drawY && ly3<drawY) return;
2467 if(drawY>=drawH) return;
2468 if(drawX>=drawW) return;
2470 if(!SetupSections_F4(lx0,ly0,lx1,ly1,lx2,ly2,lx3,ly3)) return;
2474 for(ymin=Ymin;ymin<drawY;ymin++)
2475 if(NextRow_F4()) return;
2477 color = ((rgb & 0x00f80000)>>9) | ((rgb & 0x0000f800)>>6) | ((rgb & 0x000000f8)>>3);
2478 lcolor= lSetMask|(((uint32_t)(color))<<16)|color;
2482 if(!bCheckMask && !DrawSemiTrans)
2485 for (i=ymin;i<=ymax;i++)
2487 xmin=left_x >> 16; if(drawX>xmin) xmin=drawX;
2488 xmax=(right_x >> 16)-1; if(drawW<xmax) xmax=drawW;
2490 for(j=xmin;j<xmax;j+=2)
2492 PUTLE32(((uint32_t *)&psxVuw[(i<<10)+j]), lcolor);
2494 if(j==xmax) PUTLE16(&psxVuw[(i<<10)+j], color);
2496 if(NextRow_F4()) return;
2503 for (i=ymin;i<=ymax;i++)
2505 xmin=left_x >> 16; if(drawX>xmin) xmin=drawX;
2506 xmax=(right_x >> 16)-1; if(drawW<xmax) xmax=drawW;
2508 for(j=xmin;j<xmax;j+=2)
2510 GetShadeTransCol32((uint32_t *)&psxVuw[(i<<10)+j],lcolor);
2512 if(j==xmax) GetShadeTransCol(&psxVuw[(i<<10)+j],color);
2514 if(NextRow_F4()) return;
2518 ////////////////////////////////////////////////////////////////////////
2519 // POLY 3/4 F-SHADED TEX PAL 4
2520 ////////////////////////////////////////////////////////////////////////
2522 static void drawPoly3TEx4(short x1, short y1, short x2, short y2, short x3, short y3, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3,short clX, short clY)
2524 int i,j,xmin,xmax,ymin,ymax;
2525 int32_t difX, difY,difX2, difY2;
2526 int32_t posX,posY,YAdjust,XAdjust;
2530 if(x1>drawW && x2>drawW && x3>drawW) return;
2531 if(y1>drawH && y2>drawH && y3>drawH) return;
2532 if(x1<drawX && x2<drawX && x3<drawX) return;
2533 if(y1<drawY && y2<drawY && y3<drawY) return;
2534 if(drawY>=drawH) return;
2535 if(drawX>=drawW) return;
2537 if(!SetupSections_FT(x1,y1,x2,y2,x3,y3,tx1,ty1,tx2,ty2,tx3,ty3)) return;
2541 for(ymin=Ymin;ymin<drawY;ymin++)
2542 if(NextRow_FT()) return;
2544 clutP=(clY<<10)+clX;
2546 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
2548 difX=delta_right_u;difX2=difX<<1;
2549 difY=delta_right_v;difY2=difY<<1;
2553 if(!bCheckMask && !DrawSemiTrans)
2555 for (i=ymin;i<=ymax;i++)
2557 xmin=(left_x >> 16);
2558 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!!
2559 if(drawW<xmax) xmax=drawW;
2567 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
2569 for(j=xmin;j<xmax;j+=2)
2572 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(XAdjust>>1)];
2573 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
2574 XAdjust=((posX+difX)>>16);
2575 tC2 = psxVub[(((posY+difY)>>5)&(int32_t)0xFFFFF800)+YAdjust+
2577 tC2=(tC2>>((XAdjust&1)<<2))&0xf;
2579 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
2580 GETLE16(&psxVuw[clutP+tC1])|
2581 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
2589 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+
2591 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
2592 GetTextureTransColG_S(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
2605 for (i=ymin;i<=ymax;i++)
2607 xmin=(left_x >> 16);
2608 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!!!!
2609 if(drawW<xmax) xmax=drawW;
2617 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
2619 for(j=xmin;j<xmax;j+=2)
2622 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(XAdjust>>1)];
2623 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
2624 XAdjust=((posX+difX)>>16);
2625 tC2 = psxVub[(((posY+difY)>>5)&(int32_t)0xFFFFF800)+YAdjust+
2627 tC2=(tC2>>((XAdjust&1)<<2))&0xf;
2629 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
2630 GETLE16(&psxVuw[clutP+tC1])|
2631 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
2639 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+
2641 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
2642 GetTextureTransColG(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
2652 ////////////////////////////////////////////////////////////////////////
2654 static void drawPoly3TEx4_TW(short x1, short y1, short x2, short y2, short x3, short y3, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3,short clX, short clY)
2656 int i,j,xmin,xmax,ymin,ymax;
2657 int32_t difX, difY,difX2, difY2;
2658 int32_t posX,posY,YAdjust,XAdjust;
2662 if(x1>drawW && x2>drawW && x3>drawW) return;
2663 if(y1>drawH && y2>drawH && y3>drawH) return;
2664 if(x1<drawX && x2<drawX && x3<drawX) return;
2665 if(y1<drawY && y2<drawY && y3<drawY) return;
2666 if(drawY>=drawH) return;
2667 if(drawX>=drawW) return;
2669 if(!SetupSections_FT(x1,y1,x2,y2,x3,y3,tx1,ty1,tx2,ty2,tx3,ty3)) return;
2673 for(ymin=Ymin;ymin<drawY;ymin++)
2674 if(NextRow_FT()) return;
2676 clutP=(clY<<10)+clX;
2678 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
2679 YAdjust+=(TWin.Position.y0<<11)+(TWin.Position.x0>>1);
2681 difX=delta_right_u;difX2=difX<<1;
2682 difY=delta_right_v;difY2=difY<<1;
2686 if(!bCheckMask && !DrawSemiTrans)
2688 for (i=ymin;i<=ymax;i++)
2690 xmin=(left_x >> 16);
2691 xmax=(right_x >> 16);//-1; //!!!!!!!!!!!!!!!!
2692 if(xmax>xmin) xmax--;
2694 if(drawW<xmax) xmax=drawW;
2702 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
2704 for(j=xmin;j<xmax;j+=2)
2706 XAdjust=(posX>>16)&TWin.xmask;
2707 tC1 = psxVub[(((posY>>16)&TWin.ymask)<<11)+
2708 YAdjust+(XAdjust>>1)];
2709 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
2710 XAdjust=((posX+difX)>>16)&TWin.xmask;
2711 tC2 = psxVub[((((posY+difY)>>16)&TWin.ymask)<<11)+
2712 YAdjust+(XAdjust>>1)];
2713 tC2=(tC2>>((XAdjust&1)<<2))&0xf;
2715 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
2716 GETLE16(&psxVuw[clutP+tC1])|
2717 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
2724 XAdjust=(posX>>16)&TWin.xmask;
2725 tC1 = psxVub[(((posY>>16)&TWin.ymask)<<11)+
2726 YAdjust+(XAdjust>>1)];
2727 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
2728 GetTextureTransColG_S(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
2741 for (i=ymin;i<=ymax;i++)
2743 xmin=(left_x >> 16);
2744 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!!!!
2745 if(drawW<xmax) xmax=drawW;
2753 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
2755 for(j=xmin;j<xmax;j+=2)
2757 XAdjust=(posX>>16)&TWin.xmask;
2758 tC1 = psxVub[(((posY>>16)&TWin.ymask)<<11)+
2759 YAdjust+(XAdjust>>1)];
2760 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
2761 XAdjust=((posX+difX)>>16)&TWin.xmask;
2762 tC2 = psxVub[((((posY+difY)>>16)&TWin.ymask)<<11)+
2763 YAdjust+(XAdjust>>1)];
2764 tC2=(tC2>>((XAdjust&1)<<2))&0xf;
2766 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
2767 GETLE16(&psxVuw[clutP+tC1])|
2768 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
2775 XAdjust=(posX>>16)&TWin.xmask;
2776 tC1 = psxVub[(((posY>>16)&TWin.ymask)<<11)+
2777 YAdjust+(XAdjust>>1)];
2778 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
2779 GetTextureTransColG(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
2789 ////////////////////////////////////////////////////////////////////////
2793 static void drawPoly4TEx4_TRI(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4,short clX, short clY)
2795 drawPoly3TEx4(x2,y2,x3,y3,x4,y4,
2796 tx2,ty2,tx3,ty3,tx4,ty4,
2798 drawPoly3TEx4(x1,y1,x2,y2,x4,y4,
2799 tx1,ty1,tx2,ty2,tx4,ty4,
2807 static void drawPoly4TEx4(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4,short clX, short clY)
2810 int32_t i,j,xmin,xmax,ymin,ymax;
2811 int32_t difX, difY, difX2, difY2;
2812 int32_t posX,posY,YAdjust,clutP,XAdjust;
2815 if(x1>drawW && x2>drawW && x3>drawW && x4>drawW) return;
2816 if(y1>drawH && y2>drawH && y3>drawH && y4>drawH) return;
2817 if(x1<drawX && x2<drawX && x3<drawX && x4<drawX) return;
2818 if(y1<drawY && y2<drawY && y3<drawY && y4<drawY) return;
2819 if(drawY>=drawH) return;
2820 if(drawX>=drawW) return;
2822 if(!SetupSections_FT4(x1,y1,x2,y2,x3,y3,x4,y4,tx1,ty1,tx2,ty2,tx3,ty3,tx4,ty4)) return;
2826 for(ymin=Ymin;ymin<drawY;ymin++)
2827 if(NextRow_FT4()) return;
2829 clutP=(clY<<10)+clX;
2831 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
2835 if(!bCheckMask && !DrawSemiTrans)
2837 for (i=ymin;i<=ymax;i++)
2839 xmin=(left_x >> 16);
2840 xmax=(right_x >> 16);
2849 difX=(right_u-posX)/num;
2850 difY=(right_v-posY)/num;
2855 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
2856 xmax--;if(drawW<xmax) xmax=drawW;
2858 for(j=xmin;j<xmax;j+=2)
2861 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(XAdjust>>1)];
2862 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
2863 XAdjust=((posX+difX)>>16);
2864 tC2 = psxVub[(((posY+difY)>>5)&(int32_t)0xFFFFF800)+YAdjust+
2866 tC2=(tC2>>((XAdjust&1)<<2))&0xf;
2868 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
2869 GETLE16(&psxVuw[clutP+tC1])|
2870 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
2877 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+
2879 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
2880 GetTextureTransColG_S(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
2884 if(NextRow_FT4()) return;
2891 for (i=ymin;i<=ymax;i++)
2893 xmin=(left_x >> 16);
2894 xmax=(right_x >> 16);
2903 difX=(right_u-posX)/num;
2904 difY=(right_v-posY)/num;
2909 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
2910 xmax--;if(drawW<xmax) xmax=drawW;
2912 for(j=xmin;j<xmax;j+=2)
2915 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(XAdjust>>1)];
2916 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
2917 XAdjust=((posX+difX)>>16);
2918 tC2 = psxVub[(((posY+difY)>>5)&(int32_t)0xFFFFF800)+YAdjust+
2920 tC2=(tC2>>((XAdjust&1)<<2))&0xf;
2922 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
2923 GETLE16(&psxVuw[clutP+tC1])|
2924 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
2931 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+
2933 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
2934 GetTextureTransColG(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
2937 if(NextRow_FT4()) return;
2941 ////////////////////////////////////////////////////////////////////////
2943 static void drawPoly4TEx4_TW(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4,short clX, short clY)
2946 int32_t i,j,xmin,xmax,ymin,ymax;
2947 int32_t difX, difY, difX2, difY2;
2948 int32_t posX,posY,YAdjust,clutP,XAdjust;
2951 if(x1>drawW && x2>drawW && x3>drawW && x4>drawW) return;
2952 if(y1>drawH && y2>drawH && y3>drawH && y4>drawH) return;
2953 if(x1<drawX && x2<drawX && x3<drawX && x4<drawX) return;
2954 if(y1<drawY && y2<drawY && y3<drawY && y4<drawY) return;
2955 if(drawY>=drawH) return;
2956 if(drawX>=drawW) return;
2958 if(!SetupSections_FT4(x1,y1,x2,y2,x3,y3,x4,y4,tx1,ty1,tx2,ty2,tx3,ty3,tx4,ty4)) return;
2962 for(ymin=Ymin;ymin<drawY;ymin++)
2963 if(NextRow_FT4()) return;
2965 clutP=(clY<<10)+clX;
2967 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
2968 YAdjust+=(TWin.Position.y0<<11)+(TWin.Position.x0>>1);
2972 if(!bCheckMask && !DrawSemiTrans)
2974 for (i=ymin;i<=ymax;i++)
2976 xmin=(left_x >> 16);
2977 xmax=(right_x >> 16);
2986 difX=(right_u-posX)/num;
2987 difY=(right_v-posY)/num;
2992 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
2993 xmax--;if(drawW<xmax) xmax=drawW;
2995 for(j=xmin;j<xmax;j+=2)
2997 XAdjust=(posX>>16)&TWin.xmask;
2998 tC1 = psxVub[(((posY>>16)&TWin.ymask)<<11)+
2999 YAdjust+(XAdjust>>1)];
3000 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
3001 XAdjust=((posX+difX)>>16)&TWin.xmask;
3002 tC2 = psxVub[((((posY+difY)>>16)&TWin.ymask)<<11)+
3003 YAdjust+(XAdjust>>1)];
3004 tC2=(tC2>>((XAdjust&1)<<2))&0xf;
3006 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
3007 GETLE16(&psxVuw[clutP+tC1])|
3008 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3014 XAdjust=(posX>>16)&TWin.xmask;
3015 tC1 = psxVub[(((posY>>16)&TWin.ymask)<<11)+
3016 YAdjust+(XAdjust>>1)];
3017 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
3018 GetTextureTransColG_S(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3021 if(NextRow_FT4()) return;
3028 for (i=ymin;i<=ymax;i++)
3030 xmin=(left_x >> 16);
3031 xmax=(right_x >> 16);
3040 difX=(right_u-posX)/num;
3041 difY=(right_v-posY)/num;
3046 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3047 xmax--;if(drawW<xmax) xmax=drawW;
3049 for(j=xmin;j<xmax;j+=2)
3051 XAdjust=(posX>>16)&TWin.xmask;
3052 tC1 = psxVub[(((posY>>16)&TWin.ymask)<<11)+
3053 YAdjust+(XAdjust>>1)];
3054 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
3055 XAdjust=((posX+difX)>>16)&TWin.xmask;
3056 tC2 = psxVub[((((posY+difY)>>16)&TWin.ymask)<<11)+
3057 YAdjust+(XAdjust>>1)];
3058 tC2=(tC2>>((XAdjust&1)<<2))&0xf;
3060 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
3061 GETLE16(&psxVuw[clutP+tC1])|
3062 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3068 XAdjust=(posX>>16)&TWin.xmask;
3069 tC1 = psxVub[(((posY>>16)&TWin.ymask)<<11)+
3070 YAdjust+(XAdjust>>1)];
3071 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
3072 GetTextureTransColG(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3075 if(NextRow_FT4()) return;
3079 ////////////////////////////////////////////////////////////////////////
3081 static void drawPoly4TEx4_TW_S(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4,short clX, short clY)
3084 int32_t i,j,xmin,xmax,ymin,ymax;
3085 int32_t difX, difY, difX2, difY2;
3086 int32_t posX,posY,YAdjust,clutP,XAdjust;
3089 if(x1>drawW && x2>drawW && x3>drawW && x4>drawW) return;
3090 if(y1>drawH && y2>drawH && y3>drawH && y4>drawH) return;
3091 if(x1<drawX && x2<drawX && x3<drawX && x4<drawX) return;
3092 if(y1<drawY && y2<drawY && y3<drawY && y4<drawY) return;
3093 if(drawY>=drawH) return;
3094 if(drawX>=drawW) return;
3096 if(!SetupSections_FT4(x1,y1,x2,y2,x3,y3,x4,y4,tx1,ty1,tx2,ty2,tx3,ty3,tx4,ty4)) return;
3100 for(ymin=Ymin;ymin<drawY;ymin++)
3101 if(NextRow_FT4()) return;
3103 clutP=(clY<<10)+clX;
3105 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
3106 YAdjust+=(TWin.Position.y0<<11)+(TWin.Position.x0>>1);
3110 if(!bCheckMask && !DrawSemiTrans)
3112 for (i=ymin;i<=ymax;i++)
3114 xmin=(left_x >> 16);
3115 xmax=(right_x >> 16);
3124 difX=(right_u-posX)/num;
3125 difY=(right_v-posY)/num;
3130 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3131 xmax--;if(drawW<xmax) xmax=drawW;
3133 for(j=xmin;j<xmax;j+=2)
3135 XAdjust=(posX>>16)&TWin.xmask;
3136 tC1 = psxVub[(((posY>>16)&TWin.ymask)<<11)+
3137 YAdjust+(XAdjust>>1)];
3138 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
3139 XAdjust=((posX+difX)>>16)&TWin.xmask;
3140 tC2 = psxVub[((((posY+difY)>>16)&TWin.ymask)<<11)+
3141 YAdjust+(XAdjust>>1)];
3142 tC2=(tC2>>((XAdjust&1)<<2))&0xf;
3144 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
3145 GETLE16(&psxVuw[clutP+tC1])|
3146 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3152 XAdjust=(posX>>16)&TWin.xmask;
3153 tC1 = psxVub[(((posY>>16)&TWin.ymask)<<11)+
3154 YAdjust+(XAdjust>>1)];
3155 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
3156 GetTextureTransColG_S(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3159 if(NextRow_FT4()) return;
3166 for (i=ymin;i<=ymax;i++)
3168 xmin=(left_x >> 16);
3169 xmax=(right_x >> 16);
3178 difX=(right_u-posX)/num;
3179 difY=(right_v-posY)/num;
3184 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3185 xmax--;if(drawW<xmax) xmax=drawW;
3187 for(j=xmin;j<xmax;j+=2)
3189 XAdjust=(posX>>16)&TWin.xmask;
3190 tC1 = psxVub[(((posY>>16)&TWin.ymask)<<11)+
3191 YAdjust+(XAdjust>>1)];
3192 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
3193 XAdjust=((posX+difX)>>16)&TWin.xmask;
3194 tC2 = psxVub[((((posY+difY)>>16)&TWin.ymask)<<11)+
3195 YAdjust+(XAdjust>>1)];
3196 tC2=(tC2>>((XAdjust&1)<<2))&0xf;
3198 GetTextureTransColG32_SPR((uint32_t *)&psxVuw[(i<<10)+j],
3199 GETLE16(&psxVuw[clutP+tC1])|
3200 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3206 XAdjust=(posX>>16)&TWin.xmask;
3207 tC1 = psxVub[(((posY>>16)&TWin.ymask)<<11)+
3208 YAdjust+(XAdjust>>1)];
3209 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
3210 GetTextureTransColG_SPR(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3213 if(NextRow_FT4()) return;
3216 ////////////////////////////////////////////////////////////////////////
3217 // POLY 3 F-SHADED TEX PAL 8
3218 ////////////////////////////////////////////////////////////////////////
3220 static void drawPoly3TEx8(short x1, short y1, short x2, short y2, short x3, short y3, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3,short clX, short clY)
3222 int i,j,xmin,xmax,ymin,ymax;
3223 int32_t difX, difY,difX2, difY2;
3224 int32_t posX,posY,YAdjust,clutP;
3227 if(x1>drawW && x2>drawW && x3>drawW) return;
3228 if(y1>drawH && y2>drawH && y3>drawH) return;
3229 if(x1<drawX && x2<drawX && x3<drawX) return;
3230 if(y1<drawY && y2<drawY && y3<drawY) return;
3231 if(drawY>=drawH) return;
3232 if(drawX>=drawW) return;
3234 if(!SetupSections_FT(x1,y1,x2,y2,x3,y3,tx1,ty1,tx2,ty2,tx3,ty3)) return;
3238 for(ymin=Ymin;ymin<drawY;ymin++)
3239 if(NextRow_FT()) return;
3241 clutP=(clY<<10)+clX;
3243 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
3245 difX=delta_right_u;difX2=difX<<1;
3246 difY=delta_right_v;difY2=difY<<1;
3250 if(!bCheckMask && !DrawSemiTrans)
3252 for (i=ymin;i<=ymax;i++)
3254 xmin=(left_x >> 16);
3255 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!
3256 if(drawW<xmax) xmax=drawW;
3264 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3266 for(j=xmin;j<xmax;j+=2)
3268 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(posX>>16)];
3269 tC2 = psxVub[(((posY+difY)>>5)&(int32_t)0xFFFFF800)+YAdjust+
3271 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
3272 GETLE16(&psxVuw[clutP+tC1])|
3273 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3280 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(posX>>16)];
3281 GetTextureTransColG_S(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3294 for (i=ymin;i<=ymax;i++)
3296 xmin=(left_x >> 16);
3297 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!!!
3298 if(drawW<xmax) xmax=drawW;
3306 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3308 for(j=xmin;j<xmax;j+=2)
3310 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(posX>>16)];
3311 tC2 = psxVub[(((posY+difY)>>5)&(int32_t)0xFFFFF800)+YAdjust+
3313 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
3314 GETLE16(&psxVuw[clutP+tC1])|
3315 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3322 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(posX>>16)];
3323 GetTextureTransColG(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3334 ////////////////////////////////////////////////////////////////////////
3336 static void drawPoly3TEx8_TW(short x1, short y1, short x2, short y2, short x3, short y3, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3,short clX, short clY)
3338 int i,j,xmin,xmax,ymin,ymax;
3339 int32_t difX, difY,difX2, difY2;
3340 int32_t posX,posY,YAdjust,clutP;
3343 if(x1>drawW && x2>drawW && x3>drawW) return;
3344 if(y1>drawH && y2>drawH && y3>drawH) return;
3345 if(x1<drawX && x2<drawX && x3<drawX) return;
3346 if(y1<drawY && y2<drawY && y3<drawY) return;
3347 if(drawY>=drawH) return;
3348 if(drawX>=drawW) return;
3350 if(!SetupSections_FT(x1,y1,x2,y2,x3,y3,tx1,ty1,tx2,ty2,tx3,ty3)) return;
3354 for(ymin=Ymin;ymin<drawY;ymin++)
3355 if(NextRow_FT()) return;
3357 clutP=(clY<<10)+clX;
3359 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
3360 YAdjust+=(TWin.Position.y0<<11)+(TWin.Position.x0);
3362 difX=delta_right_u;difX2=difX<<1;
3363 difY=delta_right_v;difY2=difY<<1;
3367 if(!bCheckMask && !DrawSemiTrans)
3369 for (i=ymin;i<=ymax;i++)
3371 xmin=(left_x >> 16);
3372 xmax=(right_x >> 16);//-1; //!!!!!!!!!!!!!!!!
3373 if(xmax>xmin) xmax--;
3375 if(drawW<xmax) xmax=drawW;
3383 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3385 for(j=xmin;j<xmax;j+=2)
3387 tC1 = psxVub[(((posY>>16)&TWin.ymask)<<11)+
3388 YAdjust+((posX>>16)&TWin.xmask)];
3389 tC2 = psxVub[((((posY+difY)>>16)&TWin.ymask)<<11)+
3390 YAdjust+(((posX+difX)>>16)&TWin.xmask)];
3391 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
3392 GETLE16(&psxVuw[clutP+tC1])|
3393 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3400 tC1 = psxVub[(((posY>>16)&TWin.ymask)<<11)+
3401 YAdjust+((posX>>16)&TWin.xmask)];
3402 GetTextureTransColG_S(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3415 for (i=ymin;i<=ymax;i++)
3417 xmin=(left_x >> 16);
3418 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!!!
3419 if(drawW<xmax) xmax=drawW;
3427 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3429 for(j=xmin;j<xmax;j+=2)
3431 tC1 = psxVub[(((posY>>16)&TWin.ymask)<<11)+
3432 YAdjust+((posX>>16)&TWin.xmask)];
3433 tC2 = psxVub[((((posY+difY)>>16)&TWin.ymask)<<11)+
3434 YAdjust+(((posX+difX)>>16)&TWin.xmask)];
3435 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
3436 GETLE16(&psxVuw[clutP+tC1])|
3437 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3444 tC1 = psxVub[(((posY>>16)&TWin.ymask)<<11)+
3445 YAdjust+((posX>>16)&TWin.xmask)];
3446 GetTextureTransColG(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3457 ////////////////////////////////////////////////////////////////////////
3461 static void drawPoly4TEx8_TRI(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4,short clX, short clY)
3463 drawPoly3TEx8(x2,y2,x3,y3,x4,y4,
3464 tx2,ty2,tx3,ty3,tx4,ty4,
3467 drawPoly3TEx8(x1,y1,x2,y2,x4,y4,
3468 tx1,ty1,tx2,ty2,tx4,ty4,
3476 static void drawPoly4TEx8(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4,short clX, short clY)
3479 int32_t i,j,xmin,xmax,ymin,ymax;
3480 int32_t difX, difY, difX2, difY2;
3481 int32_t posX,posY,YAdjust,clutP;
3484 if(x1>drawW && x2>drawW && x3>drawW && x4>drawW) return;
3485 if(y1>drawH && y2>drawH && y3>drawH && y4>drawH) return;
3486 if(x1<drawX && x2<drawX && x3<drawX && x4<drawX) return;
3487 if(y1<drawY && y2<drawY && y3<drawY && y4<drawY) return;
3488 if(drawY>=drawH) return;
3489 if(drawX>=drawW) return;
3491 if(!SetupSections_FT4(x1,y1,x2,y2,x3,y3,x4,y4,tx1,ty1,tx2,ty2,tx3,ty3,tx4,ty4)) return;
3495 for(ymin=Ymin;ymin<drawY;ymin++)
3496 if(NextRow_FT4()) return;
3498 clutP=(clY<<10)+clX;
3500 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
3504 if(!bCheckMask && !DrawSemiTrans)
3506 for (i=ymin;i<=ymax;i++)
3508 xmin=(left_x >> 16);
3509 xmax=(right_x >> 16);
3518 difX=(right_u-posX)/num;
3519 difY=(right_v-posY)/num;
3524 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3525 xmax--;if(drawW<xmax) xmax=drawW;
3527 for(j=xmin;j<xmax;j+=2)
3529 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(posX>>16)];
3530 tC2 = psxVub[(((posY+difY)>>5)&(int32_t)0xFFFFF800)+YAdjust+
3532 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
3533 GETLE16(&psxVuw[clutP+tC1])|
3534 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3540 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(posX>>16)];
3541 GetTextureTransColG_S(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3544 if(NextRow_FT4()) return;
3551 for (i=ymin;i<=ymax;i++)
3553 xmin=(left_x >> 16);
3554 xmax=(right_x >> 16);
3563 difX=(right_u-posX)/num;
3564 difY=(right_v-posY)/num;
3569 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3570 xmax--;if(drawW<xmax) xmax=drawW;
3572 for(j=xmin;j<xmax;j+=2)
3574 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(posX>>16)];
3575 tC2 = psxVub[(((posY+difY)>>5)&(int32_t)0xFFFFF800)+YAdjust+
3577 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
3578 GETLE16(&psxVuw[clutP+tC1])|
3579 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3585 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(posX>>16)];
3586 GetTextureTransColG(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3589 if(NextRow_FT4()) return;
3593 ////////////////////////////////////////////////////////////////////////
3595 static void drawPoly4TEx8_TW(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4,short clX, short clY)
3598 int32_t i,j,xmin,xmax,ymin,ymax;
3599 int32_t difX, difY, difX2, difY2;
3600 int32_t posX,posY,YAdjust,clutP;
3603 if(x1>drawW && x2>drawW && x3>drawW && x4>drawW) return;
3604 if(y1>drawH && y2>drawH && y3>drawH && y4>drawH) return;
3605 if(x1<drawX && x2<drawX && x3<drawX && x4<drawX) return;
3606 if(y1<drawY && y2<drawY && y3<drawY && y4<drawY) return;
3607 if(drawY>=drawH) return;
3608 if(drawX>=drawW) return;
3610 if(!SetupSections_FT4(x1,y1,x2,y2,x3,y3,x4,y4,tx1,ty1,tx2,ty2,tx3,ty3,tx4,ty4)) return;
3614 for(ymin=Ymin;ymin<drawY;ymin++)
3615 if(NextRow_FT4()) return;
3617 clutP=(clY<<10)+clX;
3619 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
3620 YAdjust+=(TWin.Position.y0<<11)+(TWin.Position.x0);
3624 if(!bCheckMask && !DrawSemiTrans)
3626 for (i=ymin;i<=ymax;i++)
3628 xmin=(left_x >> 16);
3629 xmax=(right_x >> 16);
3638 difX=(right_u-posX)/num;
3639 difY=(right_v-posY)/num;
3644 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3645 xmax--;if(drawW<xmax) xmax=drawW;
3647 for(j=xmin;j<xmax;j+=2)
3649 tC1 = psxVub[(((posY>>16)&TWin.ymask)<<11)+
3650 YAdjust+((posX>>16)&TWin.xmask)];
3651 tC2 = psxVub[((((posY+difY)>>16)&TWin.ymask)<<11)+
3652 YAdjust+(((posX+difX)>>16)&TWin.xmask)];
3653 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
3654 GETLE16(&psxVuw[clutP+tC1])|
3655 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3661 tC1 = psxVub[((((posY+difY)>>16)&TWin.ymask)<<11)+
3662 YAdjust+((posX>>16)&TWin.xmask)];
3663 GetTextureTransColG_S(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3666 if(NextRow_FT4()) return;
3674 for (i=ymin;i<=ymax;i++)
3676 xmin=(left_x >> 16);
3677 xmax=(right_x >> 16);
3686 difX=(right_u-posX)/num;
3687 difY=(right_v-posY)/num;
3692 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3693 xmax--;if(drawW<xmax) xmax=drawW;
3695 for(j=xmin;j<xmax;j+=2)
3697 tC1 = psxVub[(((posY>>16)&TWin.ymask)<<11)+
3698 YAdjust+((posX>>16)&TWin.xmask)];
3699 tC2 = psxVub[((((posY+difY)>>16)&TWin.ymask)<<11)+
3700 YAdjust+(((posX+difX)>>16)&TWin.xmask)];
3701 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
3702 GETLE16(&psxVuw[clutP+tC1])|
3703 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3709 tC1 = psxVub[((((posY+difY)>>16)&TWin.ymask)<<11)+
3710 YAdjust+((posX>>16)&TWin.xmask)];
3711 GetTextureTransColG(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3714 if(NextRow_FT4()) return;
3718 ////////////////////////////////////////////////////////////////////////
3720 static void drawPoly4TEx8_TW_S(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4,short clX, short clY)
3723 int32_t i,j,xmin,xmax,ymin,ymax;
3724 int32_t difX, difY, difX2, difY2;
3725 int32_t posX,posY,YAdjust,clutP;
3728 if(x1>drawW && x2>drawW && x3>drawW && x4>drawW) return;
3729 if(y1>drawH && y2>drawH && y3>drawH && y4>drawH) return;
3730 if(x1<drawX && x2<drawX && x3<drawX && x4<drawX) return;
3731 if(y1<drawY && y2<drawY && y3<drawY && y4<drawY) return;
3732 if(drawY>=drawH) return;
3733 if(drawX>=drawW) return;
3735 if(!SetupSections_FT4(x1,y1,x2,y2,x3,y3,x4,y4,tx1,ty1,tx2,ty2,tx3,ty3,tx4,ty4)) return;
3739 for(ymin=Ymin;ymin<drawY;ymin++)
3740 if(NextRow_FT4()) return;
3742 clutP=(clY<<10)+clX;
3744 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
3745 YAdjust+=(TWin.Position.y0<<11)+(TWin.Position.x0);
3749 if(!bCheckMask && !DrawSemiTrans)
3751 for (i=ymin;i<=ymax;i++)
3753 xmin=(left_x >> 16);
3754 xmax=(right_x >> 16);
3763 difX=(right_u-posX)/num;
3764 difY=(right_v-posY)/num;
3769 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3770 xmax--;if(drawW<xmax) xmax=drawW;
3772 for(j=xmin;j<xmax;j+=2)
3774 tC1 = psxVub[(((posY>>16)&TWin.ymask)<<11)+
3775 YAdjust+((posX>>16)&TWin.xmask)];
3776 tC2 = psxVub[((((posY+difY)>>16)&TWin.ymask)<<11)+
3777 YAdjust+(((posX+difX)>>16)&TWin.xmask)];
3778 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
3779 GETLE16(&psxVuw[clutP+tC1])|
3780 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3786 tC1 = psxVub[((((posY+difY)>>16)&TWin.ymask)<<11)+
3787 YAdjust+((posX>>16)&TWin.xmask)];
3788 GetTextureTransColG_S(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3791 if(NextRow_FT4()) return;
3799 for (i=ymin;i<=ymax;i++)
3801 xmin=(left_x >> 16);
3802 xmax=(right_x >> 16);
3811 difX=(right_u-posX)/num;
3812 difY=(right_v-posY)/num;
3817 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3818 xmax--;if(drawW<xmax) xmax=drawW;
3820 for(j=xmin;j<xmax;j+=2)
3822 tC1 = psxVub[(((posY>>16)&TWin.ymask)<<11)+
3823 YAdjust+((posX>>16)&TWin.xmask)];
3824 tC2 = psxVub[((((posY+difY)>>16)&TWin.ymask)<<11)+
3825 YAdjust+(((posX+difX)>>16)&TWin.xmask)];
3826 GetTextureTransColG32_SPR((uint32_t *)&psxVuw[(i<<10)+j],
3827 GETLE16(&psxVuw[clutP+tC1])|
3828 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16);
3834 tC1 = psxVub[((((posY+difY)>>16)&TWin.ymask)<<11)+
3835 YAdjust+((posX>>16)&TWin.xmask)];
3836 GetTextureTransColG_SPR(&psxVuw[(i<<10)+j],GETLE16(&psxVuw[clutP+tC1]));
3839 if(NextRow_FT4()) return;
3843 ////////////////////////////////////////////////////////////////////////
3844 // POLY 3 F-SHADED TEX 15 BIT
3845 ////////////////////////////////////////////////////////////////////////
3847 static void drawPoly3TD(short x1, short y1, short x2, short y2, short x3, short y3, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3)
3849 int i,j,xmin,xmax,ymin,ymax;
3850 int32_t difX, difY,difX2, difY2;
3853 if(x1>drawW && x2>drawW && x3>drawW) return;
3854 if(y1>drawH && y2>drawH && y3>drawH) return;
3855 if(x1<drawX && x2<drawX && x3<drawX) return;
3856 if(y1<drawY && y2<drawY && y3<drawY) return;
3857 if(drawY>=drawH) return;
3858 if(drawX>=drawW) return;
3860 if(!SetupSections_FT(x1,y1,x2,y2,x3,y3,tx1,ty1,tx2,ty2,tx3,ty3)) return;
3864 for(ymin=Ymin;ymin<drawY;ymin++)
3865 if(NextRow_FT()) return;
3867 difX=delta_right_u;difX2=difX<<1;
3868 difY=delta_right_v;difY2=difY<<1;
3872 if(!bCheckMask && !DrawSemiTrans)
3874 for (i=ymin;i<=ymax;i++)
3876 xmin=(left_x >> 16);
3877 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!
3878 if(drawW<xmax) xmax=drawW;
3886 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3888 for(j=xmin;j<xmax;j+=2)
3890 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
3891 (((int32_t)GETLE16(&psxVuw[((((posY+difY)>>16)+GlobalTextAddrY)<<10)+((posX+difX)>>16)+GlobalTextAddrX]))<<16)|
3892 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+((posX)>>16)+GlobalTextAddrX]));
3898 GetTextureTransColG_S(&psxVuw[(i<<10)+j],
3899 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+(posX>>16)+GlobalTextAddrX]));
3911 for (i=ymin;i<=ymax;i++)
3913 xmin=(left_x >> 16);
3914 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!
3915 if(drawW<xmax) xmax=drawW;
3923 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3925 for(j=xmin;j<xmax;j+=2)
3927 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
3928 (((int32_t)GETLE16(&psxVuw[((((posY+difY)>>16)+GlobalTextAddrY)<<10)+((posX+difX)>>16)+GlobalTextAddrX]))<<16)|
3929 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+((posX)>>16)+GlobalTextAddrX]));
3935 GetTextureTransColG(&psxVuw[(i<<10)+j],
3936 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+(posX>>16)+GlobalTextAddrX]));
3945 ////////////////////////////////////////////////////////////////////////
3947 static void drawPoly3TD_TW(short x1, short y1, short x2, short y2, short x3, short y3, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3)
3949 int i,j,xmin,xmax,ymin,ymax;
3950 int32_t difX, difY,difX2, difY2;
3953 if(x1>drawW && x2>drawW && x3>drawW) return;
3954 if(y1>drawH && y2>drawH && y3>drawH) return;
3955 if(x1<drawX && x2<drawX && x3<drawX) return;
3956 if(y1<drawY && y2<drawY && y3<drawY) return;
3957 if(drawY>=drawH) return;
3958 if(drawX>=drawW) return;
3960 if(!SetupSections_FT(x1,y1,x2,y2,x3,y3,tx1,ty1,tx2,ty2,tx3,ty3)) return;
3964 for(ymin=Ymin;ymin<drawY;ymin++)
3965 if(NextRow_FT()) return;
3967 difX=delta_right_u;difX2=difX<<1;
3968 difY=delta_right_v;difY2=difY<<1;
3972 if(!bCheckMask && !DrawSemiTrans)
3974 for (i=ymin;i<=ymax;i++)
3976 xmin=(left_x >> 16);
3977 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!
3978 if(drawW<xmax) xmax=drawW;
3986 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
3988 for(j=xmin;j<xmax;j+=2)
3990 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
3991 (((int32_t)GETLE16(&psxVuw[(((((posY+difY)>>16)&TWin.ymask)+GlobalTextAddrY+TWin.Position.y0)<<10)+
3992 (((posX+difX)>>16)&TWin.xmask)+GlobalTextAddrX+TWin.Position.x0]))<<16)|
3993 GETLE16(&psxVuw[((((posY>>16)&TWin.ymask)+GlobalTextAddrY+TWin.Position.y0)<<10)+
3994 (((posX)>>16)&TWin.xmask)+GlobalTextAddrX+TWin.Position.x0]));
4000 GetTextureTransColG_S(&psxVuw[(i<<10)+j],
4001 GETLE16(&psxVuw[((((posY>>16)&TWin.ymask)+GlobalTextAddrY+TWin.Position.y0)<<10)+
4002 ((posX>>16)&TWin.xmask)+GlobalTextAddrX+TWin.Position.x0]));
4014 for (i=ymin;i<=ymax;i++)
4016 xmin=(left_x >> 16);
4017 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!
4018 if(drawW<xmax) xmax=drawW;
4026 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
4028 for(j=xmin;j<xmax;j+=2)
4030 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
4031 (((int32_t)GETLE16(&psxVuw[(((((posY+difY)>>16)&TWin.ymask)+GlobalTextAddrY+TWin.Position.y0)<<10)+
4032 (((posX+difX)>>16)&TWin.xmask)+GlobalTextAddrX+TWin.Position.x0]))<<16)|
4033 GETLE16(&psxVuw[((((posY>>16)&TWin.ymask)+GlobalTextAddrY+TWin.Position.y0)<<10)+
4034 (((posX)>>16)&TWin.xmask)+GlobalTextAddrX+TWin.Position.x0]));
4040 GetTextureTransColG(&psxVuw[(i<<10)+j],
4041 GETLE16(&psxVuw[((((posY>>16)&TWin.ymask)+GlobalTextAddrY+TWin.Position.y0)<<10)+
4042 ((posX>>16)&TWin.xmask)+GlobalTextAddrX+TWin.Position.x0]));
4052 ////////////////////////////////////////////////////////////////////////
4056 static void drawPoly4TD_TRI(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4)
4058 drawPoly3TD(x2,y2,x3,y3,x4,y4,
4059 tx2,ty2,tx3,ty3,tx4,ty4);
4060 drawPoly3TD(x1,y1,x2,y2,x4,y4,
4061 tx1,ty1,tx2,ty2,tx4,ty4);
4068 static void drawPoly4TD(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4)
4071 int32_t i,j,xmin,xmax,ymin,ymax;
4072 int32_t difX, difY, difX2, difY2;
4075 if(x1>drawW && x2>drawW && x3>drawW && x4>drawW) return;
4076 if(y1>drawH && y2>drawH && y3>drawH && y4>drawH) return;
4077 if(x1<drawX && x2<drawX && x3<drawX && x4<drawX) return;
4078 if(y1<drawY && y2<drawY && y3<drawY && y4<drawY) return;
4079 if(drawY>=drawH) return;
4080 if(drawX>=drawW) return;
4082 if(!SetupSections_FT4(x1,y1,x2,y2,x3,y3,x4,y4,tx1,ty1,tx2,ty2,tx3,ty3,tx4,ty4)) return;
4086 for(ymin=Ymin;ymin<drawY;ymin++)
4087 if(NextRow_FT4()) return;
4091 if(!bCheckMask && !DrawSemiTrans)
4093 for (i=ymin;i<=ymax;i++)
4095 xmin=(left_x >> 16);
4096 xmax=(right_x >> 16);
4105 difX=(right_u-posX)/num;
4106 difY=(right_v-posY)/num;
4111 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
4112 xmax--;if(drawW<xmax) xmax=drawW;
4114 for(j=xmin;j<xmax;j+=2)
4116 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
4117 (((int32_t)GETLE16(&psxVuw[((((posY+difY)>>16)+GlobalTextAddrY)<<10)+((posX+difX)>>16)+GlobalTextAddrX]))<<16)|
4118 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+((posX)>>16)+GlobalTextAddrX]));
4124 GetTextureTransColG_S(&psxVuw[(i<<10)+j],
4125 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+(posX>>16)+GlobalTextAddrX]));
4127 if(NextRow_FT4()) return;
4134 for (i=ymin;i<=ymax;i++)
4136 xmin=(left_x >> 16);
4137 xmax=(right_x >> 16);
4146 difX=(right_u-posX)/num;
4147 difY=(right_v-posY)/num;
4152 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
4153 xmax--;if(drawW<xmax) xmax=drawW;
4155 for(j=xmin;j<xmax;j+=2)
4157 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
4158 (((int32_t)GETLE16(&psxVuw[((((posY+difY)>>16)+GlobalTextAddrY)<<10)+((posX+difX)>>16)+GlobalTextAddrX]))<<16)|
4159 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+((posX)>>16)+GlobalTextAddrX]));
4165 GetTextureTransColG(&psxVuw[(i<<10)+j],
4166 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+(posX>>16)+GlobalTextAddrX]));
4168 if(NextRow_FT4()) return;
4172 ////////////////////////////////////////////////////////////////////////
4174 static void drawPoly4TD_TW(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4)
4177 int32_t i,j,xmin,xmax,ymin,ymax;
4178 int32_t difX, difY, difX2, difY2;
4181 if(x1>drawW && x2>drawW && x3>drawW && x4>drawW) return;
4182 if(y1>drawH && y2>drawH && y3>drawH && y4>drawH) return;
4183 if(x1<drawX && x2<drawX && x3<drawX && x4<drawX) return;
4184 if(y1<drawY && y2<drawY && y3<drawY && y4<drawY) return;
4185 if(drawY>=drawH) return;
4186 if(drawX>=drawW) return;
4188 if(!SetupSections_FT4(x1,y1,x2,y2,x3,y3,x4,y4,tx1,ty1,tx2,ty2,tx3,ty3,tx4,ty4)) return;
4192 for(ymin=Ymin;ymin<drawY;ymin++)
4193 if(NextRow_FT4()) return;
4197 if(!bCheckMask && !DrawSemiTrans)
4199 for (i=ymin;i<=ymax;i++)
4201 xmin=(left_x >> 16);
4202 xmax=(right_x >> 16);
4211 difX=(right_u-posX)/num;
4212 difY=(right_v-posY)/num;
4217 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
4218 xmax--;if(drawW<xmax) xmax=drawW;
4220 for(j=xmin;j<xmax;j+=2)
4222 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
4223 (((int32_t)GETLE16(&psxVuw[(((((posY+difY)>>16)&TWin.ymask)+GlobalTextAddrY+TWin.Position.y0)<<10)+
4224 (((posX+difX)>>16)&TWin.xmask)+GlobalTextAddrX+TWin.Position.x0]))<<16)|
4225 GETLE16(&psxVuw[((((posY>>16)&TWin.ymask)+GlobalTextAddrY)<<10)+TWin.Position.y0+
4226 ((posX>>16)&TWin.xmask)+GlobalTextAddrX+TWin.Position.x0]));
4232 GetTextureTransColG_S(&psxVuw[(i<<10)+j],
4233 GETLE16(&psxVuw[((((posY>>16)&TWin.ymask)+GlobalTextAddrY+TWin.Position.y0)<<10)+
4234 ((posX>>16)&TWin.xmask)+GlobalTextAddrX+TWin.Position.x0]));
4236 if(NextRow_FT4()) return;
4243 for (i=ymin;i<=ymax;i++)
4245 xmin=(left_x >> 16);
4246 xmax=(right_x >> 16);
4255 difX=(right_u-posX)/num;
4256 difY=(right_v-posY)/num;
4261 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
4262 xmax--;if(drawW<xmax) xmax=drawW;
4264 for(j=xmin;j<xmax;j+=2)
4266 GetTextureTransColG32((uint32_t *)&psxVuw[(i<<10)+j],
4267 (((int32_t)GETLE16(&psxVuw[(((((posY+difY)>>16)&TWin.ymask)+GlobalTextAddrY+TWin.Position.y0)<<10)+
4268 (((posX+difX)>>16)&TWin.xmask)+GlobalTextAddrX+TWin.Position.x0]))<<16)|
4269 GETLE16(&psxVuw[((((posY>>16)&TWin.ymask)+GlobalTextAddrY+TWin.Position.y0)<<10)+
4270 ((posX>>16)&TWin.xmask)+GlobalTextAddrX+TWin.Position.x0]));
4276 GetTextureTransColG(&psxVuw[(i<<10)+j],
4277 GETLE16(&psxVuw[((((posY>>16)&TWin.ymask)+GlobalTextAddrY+TWin.Position.y0)<<10)+
4278 ((posX>>16)&TWin.xmask)+GlobalTextAddrX+TWin.Position.x0]));
4280 if(NextRow_FT4()) return;
4284 ////////////////////////////////////////////////////////////////////////
4286 static void drawPoly4TD_TW_S(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4)
4289 int32_t i,j,xmin,xmax,ymin,ymax;
4290 int32_t difX, difY, difX2, difY2;
4293 if(x1>drawW && x2>drawW && x3>drawW && x4>drawW) return;
4294 if(y1>drawH && y2>drawH && y3>drawH && y4>drawH) return;
4295 if(x1<drawX && x2<drawX && x3<drawX && x4<drawX) return;
4296 if(y1<drawY && y2<drawY && y3<drawY && y4<drawY) return;
4297 if(drawY>=drawH) return;
4298 if(drawX>=drawW) return;
4300 if(!SetupSections_FT4(x1,y1,x2,y2,x3,y3,x4,y4,tx1,ty1,tx2,ty2,tx3,ty3,tx4,ty4)) return;
4304 for(ymin=Ymin;ymin<drawY;ymin++)
4305 if(NextRow_FT4()) return;
4309 if(!bCheckMask && !DrawSemiTrans)
4311 for (i=ymin;i<=ymax;i++)
4313 xmin=(left_x >> 16);
4314 xmax=(right_x >> 16);
4323 difX=(right_u-posX)/num;
4324 difY=(right_v-posY)/num;
4329 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
4330 xmax--;if(drawW<xmax) xmax=drawW;
4332 for(j=xmin;j<xmax;j+=2)
4334 GetTextureTransColG32_S((uint32_t *)&psxVuw[(i<<10)+j],
4335 (((int32_t)GETLE16(&psxVuw[(((((posY+difY)>>16)&TWin.ymask)+GlobalTextAddrY+TWin.Position.y0)<<10)+
4336 (((posX+difX)>>16)&TWin.xmask)+GlobalTextAddrX+TWin.Position.x0]))<<16)|
4337 GETLE16(&psxVuw[((((posY>>16)&TWin.ymask)+GlobalTextAddrY)<<10)+TWin.Position.y0+
4338 ((posX>>16)&TWin.xmask)+GlobalTextAddrX+TWin.Position.x0]));
4344 GetTextureTransColG_S(&psxVuw[(i<<10)+j],
4345 GETLE16(&psxVuw[((((posY>>16)&TWin.ymask)+GlobalTextAddrY+TWin.Position.y0)<<10)+
4346 ((posX>>16)&TWin.xmask)+GlobalTextAddrX+TWin.Position.x0]));
4348 if(NextRow_FT4()) return;
4355 for (i=ymin;i<=ymax;i++)
4357 xmin=(left_x >> 16);
4358 xmax=(right_x >> 16);
4367 difX=(right_u-posX)/num;
4368 difY=(right_v-posY)/num;
4373 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;}
4374 xmax--;if(drawW<xmax) xmax=drawW;
4376 for(j=xmin;j<xmax;j+=2)
4378 GetTextureTransColG32_SPR((uint32_t *)&psxVuw[(i<<10)+j],
4379 (((int32_t)GETLE16(&psxVuw[(((((posY+difY)>>16)&TWin.ymask)+GlobalTextAddrY+TWin.Position.y0)<<10)+
4380 (((posX+difX)>>16)&TWin.xmask)+GlobalTextAddrX+TWin.Position.x0]))<<16)|
4381 GETLE16(&psxVuw[((((posY>>16)&TWin.ymask)+GlobalTextAddrY+TWin.Position.y0)<<10)+
4382 ((posX>>16)&TWin.xmask)+GlobalTextAddrX+TWin.Position.x0]));
4388 GetTextureTransColG_SPR(&psxVuw[(i<<10)+j],
4389 GETLE16(&psxVuw[((((posY>>16)&TWin.ymask)+GlobalTextAddrY+TWin.Position.y0)<<10)+
4390 ((posX>>16)&TWin.xmask)+GlobalTextAddrX+TWin.Position.x0]));
4392 if(NextRow_FT4()) return;
4396 ////////////////////////////////////////////////////////////////////////
4397 // POLY 3/4 G-SHADED
4398 ////////////////////////////////////////////////////////////////////////
4400 static inline void drawPoly3Gi(short x1,short y1,short x2,short y2,short x3,short y3,int32_t rgb1, int32_t rgb2, int32_t rgb3)
4402 int i,j,xmin,xmax,ymin,ymax;
4403 int32_t cR1,cG1,cB1;
4404 int32_t difR,difB,difG,difR2,difB2,difG2;
4406 if(x1>drawW && x2>drawW && x3>drawW) return;
4407 if(y1>drawH && y2>drawH && y3>drawH) return;
4408 if(x1<drawX && x2<drawX && x3<drawX) return;
4409 if(y1<drawY && y2<drawY && y3<drawY) return;
4410 if(drawY>=drawH) return;
4411 if(drawX>=drawW) return;
4413 if(!SetupSections_G(x1,y1,x2,y2,x3,y3,rgb1,rgb2,rgb3)) return;
4417 for(ymin=Ymin;ymin<drawY;ymin++)
4418 if(NextRow_G()) return;
4429 if(!bCheckMask && !DrawSemiTrans && iDither!=2)
4431 for (i=ymin;i<=ymax;i++)
4433 xmin=(left_x >> 16);
4434 xmax=(right_x >> 16)-1;if(drawW<xmax) xmax=drawW;
4443 {j=drawX-xmin;xmin=drawX;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
4445 for(j=xmin;j<xmax;j+=2)
4447 PUTLE32(((uint32_t *)&psxVuw[(i<<10)+j]),
4448 ((((cR1+difR) <<7)&0x7c000000)|(((cG1+difG) << 2)&0x03e00000)|(((cB1+difB)>>3)&0x001f0000)|
4449 (((cR1) >> 9)&0x7c00)|(((cG1) >> 14)&0x03e0)|(((cB1) >> 19)&0x001f))|lSetMask);
4456 PUTLE16(&psxVuw[(i<<10)+j], (((cR1 >> 9)&0x7c00)|((cG1 >> 14)&0x03e0)|((cB1 >> 19)&0x001f))|sSetMask);
4458 if(NextRow_G()) return;
4466 for (i=ymin;i<=ymax;i++)
4468 xmin=(left_x >> 16);
4469 xmax=(right_x >> 16)-1;if(drawW<xmax) xmax=drawW;
4478 {j=drawX-xmin;xmin=drawX;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
4480 for(j=xmin;j<=xmax;j++)
4482 GetShadeTransCol_Dither(&psxVuw[(i<<10)+j],(cB1>>16),(cG1>>16),(cR1>>16));
4489 if(NextRow_G()) return;
4492 for (i=ymin;i<=ymax;i++)
4494 xmin=(left_x >> 16);
4495 xmax=(right_x >> 16)-1;if(drawW<xmax) xmax=drawW;
4504 {j=drawX-xmin;xmin=drawX;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
4506 for(j=xmin;j<=xmax;j++)
4508 GetShadeTransCol(&psxVuw[(i<<10)+j],((cR1 >> 9)&0x7c00)|((cG1 >> 14)&0x03e0)|((cB1 >> 19)&0x001f));
4515 if(NextRow_G()) return;
4520 ////////////////////////////////////////////////////////////////////////
4522 static void drawPoly3G(int32_t rgb1, int32_t rgb2, int32_t rgb3)
4524 drawPoly3Gi(lx0,ly0,lx1,ly1,lx2,ly2,rgb1,rgb2,rgb3);
4527 // draw two g-shaded tris for right psx shading emulation
4529 static void drawPoly4G(int32_t rgb1, int32_t rgb2, int32_t rgb3, int32_t rgb4)
4531 drawPoly3Gi(lx1,ly1,lx3,ly3,lx2,ly2,
4533 drawPoly3Gi(lx0,ly0,lx1,ly1,lx2,ly2,
4537 ////////////////////////////////////////////////////////////////////////
4538 // POLY 3/4 G-SHADED TEX PAL4
4539 ////////////////////////////////////////////////////////////////////////
4541 static void drawPoly3TGEx4(short x1, short y1, short x2, short y2, short x3, short y3, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short clX, short clY,int32_t col1, int32_t col2, int32_t col3)
4543 int i,j,xmin,xmax,ymin,ymax;
4544 int32_t cR1,cG1,cB1;
4545 int32_t difR,difB,difG,difR2,difB2,difG2;
4546 int32_t difX, difY,difX2, difY2;
4547 int32_t posX,posY,YAdjust,clutP,XAdjust;
4550 if(x1>drawW && x2>drawW && x3>drawW) return;
4551 if(y1>drawH && y2>drawH && y3>drawH) return;
4552 if(x1<drawX && x2<drawX && x3<drawX) return;
4553 if(y1<drawY && y2<drawY && y3<drawY) return;
4554 if(drawY>=drawH) return;
4555 if(drawX>=drawW) return;
4557 if(!SetupSections_GT(x1,y1,x2,y2,x3,y3,tx1,ty1,tx2,ty2,tx3,ty3,col1,col2,col3)) return;
4561 for(ymin=Ymin;ymin<drawY;ymin++)
4562 if(NextRow_GT()) return;
4564 clutP=(clY<<10)+clX;
4566 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
4575 difX=delta_right_u;difX2=difX<<1;
4576 difY=delta_right_v;difY2=difY<<1;
4580 if(!bCheckMask && !DrawSemiTrans && !iDither)
4582 for (i=ymin;i<=ymax;i++)
4584 xmin=((left_x) >> 16);
4585 xmax=((right_x) >> 16)-1; //!!!!!!!!!!!!!
4586 if(drawW<xmax) xmax=drawW;
4597 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
4599 for(j=xmin;j<xmax;j+=2)
4602 tC1 = psxVub[((posY>>5)&0xFFFFF800)+YAdjust+(XAdjust>>1)];
4603 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
4604 XAdjust=((posX+difX)>>16);
4605 tC2 = psxVub[(((posY+difY)>>5)&(int32_t)0xFFFFF800)+YAdjust+
4607 tC2=(tC2>>((XAdjust&1)<<2))&0xf;
4609 GetTextureTransColGX32_S((uint32_t *)&psxVuw[(i<<10)+j],
4610 GETLE16(&psxVuw[clutP+tC1])|
4611 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16,
4612 (cB1>>16)|((cB1+difB)&0xff0000),
4613 (cG1>>16)|((cG1+difG)&0xff0000),
4614 (cR1>>16)|((cR1+difR)&0xff0000));
4624 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(XAdjust>>1)];
4625 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
4626 GetTextureTransColGX_S(&psxVuw[(i<<10)+j],
4627 GETLE16(&psxVuw[clutP+tC1]),
4628 (cB1>>16),(cG1>>16),(cR1>>16));
4641 for (i=ymin;i<=ymax;i++)
4643 xmin=(left_x >> 16);
4644 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!!
4645 if(drawW<xmax) xmax=drawW;
4656 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
4658 for(j=xmin;j<=xmax;j++)
4661 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(XAdjust>>1)];
4662 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
4664 GetTextureTransColGX_Dither(&psxVuw[(i<<10)+j],
4665 GETLE16(&psxVuw[clutP+tC1]),
4666 (cB1>>16),(cG1>>16),(cR1>>16));
4668 GetTextureTransColGX(&psxVuw[(i<<10)+j],
4669 GETLE16(&psxVuw[clutP+tC1]),
4670 (cB1>>16),(cG1>>16),(cR1>>16));
4685 ////////////////////////////////////////////////////////////////////////
4687 static void drawPoly3TGEx4_TW(short x1, short y1, short x2, short y2, short x3, short y3, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short clX, short clY,int32_t col1, int32_t col2, int32_t col3)
4689 int i,j,xmin,xmax,ymin,ymax;
4690 int32_t cR1,cG1,cB1;
4691 int32_t difR,difB,difG,difR2,difB2,difG2;
4692 int32_t difX, difY,difX2, difY2;
4693 int32_t posX,posY,YAdjust,clutP,XAdjust;
4696 if(x1>drawW && x2>drawW && x3>drawW) return;
4697 if(y1>drawH && y2>drawH && y3>drawH) return;
4698 if(x1<drawX && x2<drawX && x3<drawX) return;
4699 if(y1<drawY && y2<drawY && y3<drawY) return;
4700 if(drawY>=drawH) return;
4701 if(drawX>=drawW) return;
4703 if(!SetupSections_GT(x1,y1,x2,y2,x3,y3,tx1,ty1,tx2,ty2,tx3,ty3,col1,col2,col3)) return;
4707 for(ymin=Ymin;ymin<drawY;ymin++)
4708 if(NextRow_GT()) return;
4710 clutP=(clY<<10)+clX;
4712 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
4713 YAdjust+=(TWin.Position.y0<<11)+(TWin.Position.x0>>1);
4722 difX=delta_right_u;difX2=difX<<1;
4723 difY=delta_right_v;difY2=difY<<1;
4727 if(!bCheckMask && !DrawSemiTrans && !iDither)
4729 for (i=ymin;i<=ymax;i++)
4731 xmin=((left_x) >> 16);
4732 xmax=((right_x) >> 16)-1; //!!!!!!!!!!!!!
4733 if(drawW<xmax) xmax=drawW;
4744 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
4746 for(j=xmin;j<xmax;j+=2)
4748 XAdjust=(posX>>16)&TWin.xmask;
4749 tC1 = psxVub[(((posY>>16)&TWin.ymask)<<11)+
4750 YAdjust+(XAdjust>>1)];
4751 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
4752 XAdjust=((posX+difX)>>16)&TWin.xmask;
4753 tC2 = psxVub[((((posY+difY)>>16)&TWin.ymask)<<11)+
4754 YAdjust+(XAdjust>>1)];
4755 tC2=(tC2>>((XAdjust&1)<<2))&0xf;
4756 GetTextureTransColGX32_S((uint32_t *)&psxVuw[(i<<10)+j],
4757 GETLE16(&psxVuw[clutP+tC1])|
4758 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16,
4759 (cB1>>16)|((cB1+difB)&0xff0000),
4760 (cG1>>16)|((cG1+difG)&0xff0000),
4761 (cR1>>16)|((cR1+difR)&0xff0000));
4770 XAdjust=(posX>>16)&TWin.xmask;
4771 tC1 = psxVub[(((posY>>16)&TWin.ymask)<<11)+
4772 YAdjust+(XAdjust>>1)];
4773 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
4774 GetTextureTransColGX_S(&psxVuw[(i<<10)+j],
4775 GETLE16(&psxVuw[clutP+tC1]),
4776 (cB1>>16),(cG1>>16),(cR1>>16));
4789 for (i=ymin;i<=ymax;i++)
4791 xmin=(left_x >> 16);
4792 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!!
4793 if(drawW<xmax) xmax=drawW;
4804 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
4806 for(j=xmin;j<=xmax;j++)
4808 XAdjust=(posX>>16)&TWin.xmask;
4809 tC1 = psxVub[(((posY>>16)&TWin.ymask)<<11)+
4810 YAdjust+(XAdjust>>1)];
4811 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
4813 GetTextureTransColGX_Dither(&psxVuw[(i<<10)+j],
4814 GETLE16(&psxVuw[clutP+tC1]),
4815 (cB1>>16),(cG1>>16),(cR1>>16));
4817 GetTextureTransColGX(&psxVuw[(i<<10)+j],
4818 GETLE16(&psxVuw[clutP+tC1]),
4819 (cB1>>16),(cG1>>16),(cR1>>16));
4834 ////////////////////////////////////////////////////////////////////////
4836 // note: the psx is doing g-shaded quads as two g-shaded tris,
4837 // like the following func... sadly texturing is not 100%
4838 // correct that way, so small texture distortions can
4843 static void drawPoly4TGEx4_TRI(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4,
4844 short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4,
4845 short clX, short clY,
4846 int32_t col1, int32_t col2, int32_t col3, int32_t col4)
4848 drawPoly3TGEx4(x2,y2,x3,y3,x4,y4,
4849 tx2,ty2,tx3,ty3,tx4,ty4,
4852 drawPoly3TGEx4(x1,y1,x2,y2,x4,y4,
4853 tx1,ty1,tx2,ty2,tx4,ty4,
4860 ////////////////////////////////////////////////////////////////////////
4862 static void drawPoly4TGEx4(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4,
4863 short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4,
4864 short clX, short clY,
4865 int32_t col1, int32_t col2, int32_t col4, int32_t col3)
4868 int32_t i,j,xmin,xmax,ymin,ymax;
4869 int32_t cR1,cG1,cB1;
4870 int32_t difR,difB,difG,difR2,difB2,difG2;
4871 int32_t difX, difY, difX2, difY2;
4872 int32_t posX,posY,YAdjust,clutP,XAdjust;
4875 if(x1>drawW && x2>drawW && x3>drawW && x4>drawW) return;
4876 if(y1>drawH && y2>drawH && y3>drawH && y4>drawH) return;
4877 if(x1<drawX && x2<drawX && x3<drawX && x4<drawX) return;
4878 if(y1<drawY && y2<drawY && y3<drawY && y4<drawY) return;
4879 if(drawY>=drawH) return;
4880 if(drawX>=drawW) return;
4882 if(!SetupSections_GT4(x1,y1,x2,y2,x3,y3,x4,y4,tx1,ty1,tx2,ty2,tx3,ty3,tx4,ty4,col1,col2,col3,col4)) return;
4886 for(ymin=Ymin;ymin<drawY;ymin++)
4887 if(NextRow_GT4()) return;
4889 clutP=(clY<<10)+clX;
4891 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
4896 if(!bCheckMask && !DrawSemiTrans && !iDither)
4898 for (i=ymin;i<=ymax;i++)
4900 xmin=(left_x >> 16);
4901 xmax=(right_x >> 16);
4910 difX=(right_u-posX)/num;
4911 difY=(right_v-posY)/num;
4918 difR=(right_R-cR1)/num;
4919 difG=(right_G-cG1)/num;
4920 difB=(right_B-cB1)/num;
4926 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
4927 xmax--;if(drawW<xmax) xmax=drawW;
4929 for(j=xmin;j<xmax;j+=2)
4932 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(XAdjust>>1)];
4933 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
4934 XAdjust=((posX+difX)>>16);
4935 tC2 = psxVub[(((posY+difY)>>5)&(int32_t)0xFFFFF800)+YAdjust+
4937 tC2=(tC2>>((XAdjust&1)<<2))&0xf;
4939 GetTextureTransColGX32_S((uint32_t *)&psxVuw[(i<<10)+j],
4940 GETLE16(&psxVuw[clutP+tC1])|
4941 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16,
4942 (cB1>>16)|((cB1+difB)&0xff0000),
4943 (cG1>>16)|((cG1+difG)&0xff0000),
4944 (cR1>>16)|((cR1+difR)&0xff0000));
4954 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+
4956 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
4958 GetTextureTransColGX_S(&psxVuw[(i<<10)+j],
4959 GETLE16(&psxVuw[clutP+tC1]),
4960 (cB1>>16),(cG1>>16),(cR1>>16));
4963 if(NextRow_GT4()) return;
4970 for (i=ymin;i<=ymax;i++)
4972 xmin=(left_x >> 16);
4973 xmax=(right_x >> 16);
4982 difX=(right_u-posX)/num;
4983 difY=(right_v-posY)/num;
4990 difR=(right_R-cR1)/num;
4991 difG=(right_G-cG1)/num;
4992 difB=(right_B-cB1)/num;
4998 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
4999 xmax--;if(drawW<xmax) xmax=drawW;
5001 for(j=xmin;j<=xmax;j++)
5004 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+
5006 tC1=(tC1>>((XAdjust&1)<<2))&0xf;
5008 GetTextureTransColGX_Dither(&psxVuw[(i<<10)+j],
5009 GETLE16(&psxVuw[clutP+tC1]),
5010 (cB1>>16),(cG1>>16),(cR1>>16));
5012 GetTextureTransColGX(&psxVuw[(i<<10)+j],
5013 GETLE16(&psxVuw[clutP+tC1]),
5014 (cB1>>16),(cG1>>16),(cR1>>16));
5022 if(NextRow_GT4()) return;
5026 ////////////////////////////////////////////////////////////////////////
5028 static void drawPoly4TGEx4_TW(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4,
5029 short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4,
5030 short clX, short clY,
5031 int32_t col1, int32_t col2, int32_t col3, int32_t col4)
5033 drawPoly3TGEx4_TW(x2,y2,x3,y3,x4,y4,
5034 tx2,ty2,tx3,ty3,tx4,ty4,
5038 drawPoly3TGEx4_TW(x1,y1,x2,y2,x4,y4,
5039 tx1,ty1,tx2,ty2,tx4,ty4,
5044 ////////////////////////////////////////////////////////////////////////
5045 // POLY 3/4 G-SHADED TEX PAL8
5046 ////////////////////////////////////////////////////////////////////////
5048 static void drawPoly3TGEx8(short x1, short y1, short x2, short y2, short x3, short y3, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short clX, short clY,int32_t col1, int32_t col2, int32_t col3)
5050 int i,j,xmin,xmax,ymin,ymax;
5051 int32_t cR1,cG1,cB1;
5052 int32_t difR,difB,difG,difR2,difB2,difG2;
5053 int32_t difX, difY,difX2, difY2;
5054 int32_t posX,posY,YAdjust,clutP;
5057 if(x1>drawW && x2>drawW && x3>drawW) return;
5058 if(y1>drawH && y2>drawH && y3>drawH) return;
5059 if(x1<drawX && x2<drawX && x3<drawX) return;
5060 if(y1<drawY && y2<drawY && y3<drawY) return;
5061 if(drawY>=drawH) return;
5062 if(drawX>=drawW) return;
5064 if(!SetupSections_GT(x1,y1,x2,y2,x3,y3,tx1,ty1,tx2,ty2,tx3,ty3,col1,col2,col3)) return;
5068 for(ymin=Ymin;ymin<drawY;ymin++)
5069 if(NextRow_GT()) return;
5071 clutP=(clY<<10)+clX;
5073 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
5081 difX=delta_right_u;difX2=difX<<1;
5082 difY=delta_right_v;difY2=difY<<1;
5086 if(!bCheckMask && !DrawSemiTrans && !iDither)
5088 for (i=ymin;i<=ymax;i++)
5090 xmin=(left_x >> 16);
5091 xmax=(right_x >> 16)-1; // !!!!!!!!!!!!!
5092 if(drawW<xmax) xmax=drawW;
5103 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
5105 for(j=xmin;j<xmax;j+=2)
5107 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+((posX>>16))];
5108 tC2 = psxVub[(((posY+difY)>>5)&(int32_t)0xFFFFF800)+YAdjust+
5109 (((posX+difX)>>16))];
5110 GetTextureTransColGX32_S((uint32_t *)&psxVuw[(i<<10)+j],
5111 GETLE16(&psxVuw[clutP+tC1])|
5112 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16,
5113 (cB1>>16)|((cB1+difB)&0xff0000),
5114 (cG1>>16)|((cG1+difG)&0xff0000),
5115 (cR1>>16)|((cR1+difR)&0xff0000));
5124 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+((posX>>16))];
5125 GetTextureTransColGX_S(&psxVuw[(i<<10)+j],
5126 GETLE16(&psxVuw[clutP+tC1]),
5127 (cB1>>16),(cG1>>16),(cR1>>16));
5140 for (i=ymin;i<=ymax;i++)
5142 xmin=(left_x >> 16);
5143 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!!!!!!!!!
5144 if(drawW<xmax) xmax=drawW;
5155 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
5157 for(j=xmin;j<=xmax;j++)
5159 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+((posX>>16))];
5161 GetTextureTransColGX_Dither(&psxVuw[(i<<10)+j],
5162 GETLE16(&psxVuw[clutP+tC1]),
5163 (cB1>>16),(cG1>>16),(cR1>>16));
5165 GetTextureTransColGX(&psxVuw[(i<<10)+j],
5166 GETLE16(&psxVuw[clutP+tC1]),
5167 (cB1>>16),(cG1>>16),(cR1>>16));
5182 ////////////////////////////////////////////////////////////////////////
5184 static void drawPoly3TGEx8_TW(short x1, short y1, short x2, short y2, short x3, short y3, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short clX, short clY,int32_t col1, int32_t col2, int32_t col3)
5186 int i,j,xmin,xmax,ymin,ymax;
5187 int32_t cR1,cG1,cB1;
5188 int32_t difR,difB,difG,difR2,difB2,difG2;
5189 int32_t difX, difY,difX2, difY2;
5190 int32_t posX,posY,YAdjust,clutP;
5193 if(x1>drawW && x2>drawW && x3>drawW) return;
5194 if(y1>drawH && y2>drawH && y3>drawH) return;
5195 if(x1<drawX && x2<drawX && x3<drawX) return;
5196 if(y1<drawY && y2<drawY && y3<drawY) return;
5197 if(drawY>=drawH) return;
5198 if(drawX>=drawW) return;
5200 if(!SetupSections_GT(x1,y1,x2,y2,x3,y3,tx1,ty1,tx2,ty2,tx3,ty3,col1,col2,col3)) return;
5204 for(ymin=Ymin;ymin<drawY;ymin++)
5205 if(NextRow_GT()) return;
5207 clutP=(clY<<10)+clX;
5209 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
5210 YAdjust+=(TWin.Position.y0<<11)+(TWin.Position.x0);
5218 difX=delta_right_u;difX2=difX<<1;
5219 difY=delta_right_v;difY2=difY<<1;
5223 if(!bCheckMask && !DrawSemiTrans && !iDither)
5225 for (i=ymin;i<=ymax;i++)
5227 xmin=(left_x >> 16);
5228 xmax=(right_x >> 16)-1; // !!!!!!!!!!!!!
5229 if(drawW<xmax) xmax=drawW;
5240 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
5242 for(j=xmin;j<xmax;j+=2)
5244 tC1 = psxVub[(((posY>>16)&TWin.ymask)<<11)+
5245 YAdjust+((posX>>16)&TWin.xmask)];
5246 tC2 = psxVub[((((posY+difY)>>16)&TWin.ymask)<<11)+
5247 YAdjust+(((posX+difX)>>16)&TWin.xmask)];
5249 GetTextureTransColGX32_S((uint32_t *)&psxVuw[(i<<10)+j],
5250 GETLE16(&psxVuw[clutP+tC1])|
5251 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16,
5252 (cB1>>16)|((cB1+difB)&0xff0000),
5253 (cG1>>16)|((cG1+difG)&0xff0000),
5254 (cR1>>16)|((cR1+difR)&0xff0000));
5263 tC1 = psxVub[(((posY>>16)&TWin.ymask)<<11)+
5264 YAdjust+((posX>>16)&TWin.xmask)];
5265 GetTextureTransColGX_S(&psxVuw[(i<<10)+j],
5266 GETLE16(&psxVuw[clutP+tC1]),
5267 (cB1>>16),(cG1>>16),(cR1>>16));
5280 for (i=ymin;i<=ymax;i++)
5282 xmin=(left_x >> 16);
5283 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!!!!!!!!!
5284 if(drawW<xmax) xmax=drawW;
5295 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
5297 for(j=xmin;j<=xmax;j++)
5299 tC1 = psxVub[(((posY>>16)&TWin.ymask)<<11)+
5300 YAdjust+((posX>>16)&TWin.xmask)];
5302 GetTextureTransColGX_Dither(&psxVuw[(i<<10)+j],
5303 GETLE16(&psxVuw[clutP+tC1]),
5304 (cB1>>16),(cG1>>16),(cR1>>16));
5306 GetTextureTransColGX(&psxVuw[(i<<10)+j],
5307 GETLE16(&psxVuw[clutP+tC1]),
5308 (cB1>>16),(cG1>>16),(cR1>>16));
5323 ////////////////////////////////////////////////////////////////////////
5325 // note: two g-shaded tris: small texture distortions can happen
5329 static void drawPoly4TGEx8_TRI(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4,
5330 short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4,
5331 short clX, short clY,
5332 int32_t col1, int32_t col2, int32_t col3, int32_t col4)
5334 drawPoly3TGEx8(x2,y2,x3,y3,x4,y4,
5335 tx2,ty2,tx3,ty3,tx4,ty4,
5338 drawPoly3TGEx8(x1,y1,x2,y2,x4,y4,
5339 tx1,ty1,tx2,ty2,tx4,ty4,
5346 static void drawPoly4TGEx8(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4,
5347 short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4,
5348 short clX, short clY,
5349 int32_t col1, int32_t col2, int32_t col4, int32_t col3)
5352 int32_t i,j,xmin,xmax,ymin,ymax;
5353 int32_t cR1,cG1,cB1;
5354 int32_t difR,difB,difG,difR2,difB2,difG2;
5355 int32_t difX, difY, difX2, difY2;
5356 int32_t posX,posY,YAdjust,clutP;
5359 if(x1>drawW && x2>drawW && x3>drawW && x4>drawW) return;
5360 if(y1>drawH && y2>drawH && y3>drawH && y4>drawH) return;
5361 if(x1<drawX && x2<drawX && x3<drawX && x4<drawX) return;
5362 if(y1<drawY && y2<drawY && y3<drawY && y4<drawY) return;
5363 if(drawY>=drawH) return;
5364 if(drawX>=drawW) return;
5366 if(!SetupSections_GT4(x1,y1,x2,y2,x3,y3,x4,y4,tx1,ty1,tx2,ty2,tx3,ty3,tx4,ty4,col1,col2,col3,col4)) return;
5370 for(ymin=Ymin;ymin<drawY;ymin++)
5371 if(NextRow_GT4()) return;
5373 clutP=(clY<<10)+clX;
5375 YAdjust=((GlobalTextAddrY)<<11)+(GlobalTextAddrX<<1);
5379 if(!bCheckMask && !DrawSemiTrans && !iDither)
5381 for (i=ymin;i<=ymax;i++)
5383 xmin=(left_x >> 16);
5384 xmax=(right_x >> 16);
5393 difX=(right_u-posX)/num;
5394 difY=(right_v-posY)/num;
5401 difR=(right_R-cR1)/num;
5402 difG=(right_G-cG1)/num;
5403 difB=(right_B-cB1)/num;
5409 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
5410 xmax--;if(drawW<xmax) xmax=drawW;
5412 for(j=xmin;j<xmax;j+=2)
5414 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(posX>>16)];
5415 tC2 = psxVub[(((posY+difY)>>5)&(int32_t)0xFFFFF800)+YAdjust+
5418 GetTextureTransColGX32_S((uint32_t *)&psxVuw[(i<<10)+j],
5419 GETLE16(&psxVuw[clutP+tC1])|
5420 ((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16,
5421 (cB1>>16)|((cB1+difB)&0xff0000),
5422 (cG1>>16)|((cG1+difG)&0xff0000),
5423 (cR1>>16)|((cR1+difR)&0xff0000));
5432 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(posX>>16)];
5433 GetTextureTransColGX_S(&psxVuw[(i<<10)+j],
5434 GETLE16(&psxVuw[clutP+tC1]),
5435 (cB1>>16),(cG1>>16),(cR1>>16));
5438 if(NextRow_GT4()) return;
5445 for (i=ymin;i<=ymax;i++)
5447 xmin=(left_x >> 16);
5448 xmax=(right_x >> 16);
5457 difX=(right_u-posX)/num;
5458 difY=(right_v-posY)/num;
5465 difR=(right_R-cR1)/num;
5466 difG=(right_G-cG1)/num;
5467 difB=(right_B-cB1)/num;
5473 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
5474 xmax--;if(drawW<xmax) xmax=drawW;
5476 for(j=xmin;j<=xmax;j++)
5478 tC1 = psxVub[((posY>>5)&(int32_t)0xFFFFF800)+YAdjust+(posX>>16)];
5480 GetTextureTransColGX_Dither(&psxVuw[(i<<10)+j],
5481 GETLE16(&psxVuw[clutP+tC1]),
5482 (cB1>>16),(cG1>>16),(cR1>>16));
5484 GetTextureTransColGX(&psxVuw[(i<<10)+j],
5485 GETLE16(&psxVuw[clutP+tC1]),
5486 (cB1>>16),(cG1>>16),(cR1>>16));
5494 if(NextRow_GT4()) return;
5498 ////////////////////////////////////////////////////////////////////////
5500 static void drawPoly4TGEx8_TW(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4,
5501 short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4,
5502 short clX, short clY,
5503 int32_t col1, int32_t col2, int32_t col3, int32_t col4)
5505 drawPoly3TGEx8_TW(x2,y2,x3,y3,x4,y4,
5506 tx2,ty2,tx3,ty3,tx4,ty4,
5509 drawPoly3TGEx8_TW(x1,y1,x2,y2,x4,y4,
5510 tx1,ty1,tx2,ty2,tx4,ty4,
5515 ////////////////////////////////////////////////////////////////////////
5516 // POLY 3 G-SHADED TEX 15 BIT
5517 ////////////////////////////////////////////////////////////////////////
5519 static void drawPoly3TGD(short x1, short y1, short x2, short y2, short x3, short y3, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3,int32_t col1, int32_t col2, int32_t col3)
5521 int i,j,xmin,xmax,ymin,ymax;
5522 int32_t cR1,cG1,cB1;
5523 int32_t difR,difB,difG,difR2,difB2,difG2;
5524 int32_t difX, difY,difX2, difY2;
5527 if(x1>drawW && x2>drawW && x3>drawW) return;
5528 if(y1>drawH && y2>drawH && y3>drawH) return;
5529 if(x1<drawX && x2<drawX && x3<drawX) return;
5530 if(y1<drawY && y2<drawY && y3<drawY) return;
5531 if(drawY>=drawH) return;
5532 if(drawX>=drawW) return;
5534 if(!SetupSections_GT(x1,y1,x2,y2,x3,y3,tx1,ty1,tx2,ty2,tx3,ty3,col1,col2,col3)) return;
5538 for(ymin=Ymin;ymin<drawY;ymin++)
5539 if(NextRow_GT()) return;
5547 difX=delta_right_u;difX2=difX<<1;
5548 difY=delta_right_v;difY2=difY<<1;
5552 if(!bCheckMask && !DrawSemiTrans && !iDither)
5554 for (i=ymin;i<=ymax;i++)
5556 xmin=(left_x >> 16);
5557 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!!!!!!
5558 if(drawW<xmax) xmax=drawW;
5569 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
5571 for(j=xmin;j<xmax;j+=2)
5573 GetTextureTransColGX32_S((uint32_t *)&psxVuw[(i<<10)+j],
5574 (((int32_t)GETLE16(&psxVuw[((((posY+difY)>>16)+GlobalTextAddrY)<<10)+((posX+difX)>>16)+GlobalTextAddrX]))<<16)|
5575 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+((posX)>>16)+GlobalTextAddrX]),
5576 (cB1>>16)|((cB1+difB)&0xff0000),
5577 (cG1>>16)|((cG1+difG)&0xff0000),
5578 (cR1>>16)|((cR1+difR)&0xff0000));
5586 GetTextureTransColGX_S(&psxVuw[(i<<10)+j],
5587 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+(posX>>16)+GlobalTextAddrX]),
5588 (cB1>>16),(cG1>>16),(cR1>>16));
5600 for (i=ymin;i<=ymax;i++)
5602 xmin=(left_x >> 16);
5603 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!!!!
5604 if(drawW<xmax) xmax=drawW;
5615 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
5617 for(j=xmin;j<=xmax;j++)
5620 GetTextureTransColGX_Dither(&psxVuw[(i<<10)+j],
5621 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+(posX>>16)+GlobalTextAddrX]),
5622 (cB1>>16),(cG1>>16),(cR1>>16));
5624 GetTextureTransColGX(&psxVuw[(i<<10)+j],
5625 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+(posX>>16)+GlobalTextAddrX]),
5626 (cB1>>16),(cG1>>16),(cR1>>16));
5641 ////////////////////////////////////////////////////////////////////////
5643 static void drawPoly3TGD_TW(short x1, short y1, short x2, short y2, short x3, short y3, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3,int32_t col1, int32_t col2, int32_t col3)
5645 int i,j,xmin,xmax,ymin,ymax;
5646 int32_t cR1,cG1,cB1;
5647 int32_t difR,difB,difG,difR2,difB2,difG2;
5648 int32_t difX, difY,difX2, difY2;
5651 if(x1>drawW && x2>drawW && x3>drawW) return;
5652 if(y1>drawH && y2>drawH && y3>drawH) return;
5653 if(x1<drawX && x2<drawX && x3<drawX) return;
5654 if(y1<drawY && y2<drawY && y3<drawY) return;
5655 if(drawY>=drawH) return;
5656 if(drawX>=drawW) return;
5658 if(!SetupSections_GT(x1,y1,x2,y2,x3,y3,tx1,ty1,tx2,ty2,tx3,ty3,col1,col2,col3)) return;
5662 for(ymin=Ymin;ymin<drawY;ymin++)
5663 if(NextRow_GT()) return;
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 GetTextureTransColGX32_S((uint32_t *)&psxVuw[(i<<10)+j],
5698 (((int32_t)GETLE16(&psxVuw[(((((posY+difY)>>16)&TWin.ymask)+GlobalTextAddrY+TWin.Position.y0)<<10)+
5699 (((posX+difX)>>16)&TWin.xmask)+GlobalTextAddrX+TWin.Position.x0]))<<16)|
5700 GETLE16(&psxVuw[((((posY>>16)&TWin.ymask)+GlobalTextAddrY+TWin.Position.y0)<<10)+
5701 (((posX)>>16)&TWin.xmask)+GlobalTextAddrX+TWin.Position.x0]),
5702 (cB1>>16)|((cB1+difB)&0xff0000),
5703 (cG1>>16)|((cG1+difG)&0xff0000),
5704 (cR1>>16)|((cR1+difR)&0xff0000));
5712 GetTextureTransColGX_S(&psxVuw[(i<<10)+j],
5713 GETLE16(&psxVuw[((((posY>>16)&TWin.ymask)+GlobalTextAddrY+TWin.Position.y0)<<10)+
5714 ((posX>>16)&TWin.xmask)+GlobalTextAddrX+TWin.Position.x0]),
5715 (cB1>>16),(cG1>>16),(cR1>>16));
5727 for (i=ymin;i<=ymax;i++)
5729 xmin=(left_x >> 16);
5730 xmax=(right_x >> 16)-1; //!!!!!!!!!!!!!!!!!!
5731 if(drawW<xmax) xmax=drawW;
5742 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
5744 for(j=xmin;j<=xmax;j++)
5747 GetTextureTransColGX_Dither(&psxVuw[(i<<10)+j],
5748 GETLE16(&psxVuw[((((posY>>16)&TWin.ymask)+GlobalTextAddrY+TWin.Position.y0)<<10)+
5749 ((posX>>16)&TWin.xmask)+GlobalTextAddrX+TWin.Position.x0]),
5750 (cB1>>16),(cG1>>16),(cR1>>16));
5752 GetTextureTransColGX(&psxVuw[(i<<10)+j],
5753 GETLE16(&psxVuw[((((posY>>16)&TWin.ymask)+GlobalTextAddrY+TWin.Position.y0)<<10)+
5754 ((posX>>16)&TWin.xmask)+GlobalTextAddrX+TWin.Position.x0]),
5755 (cB1>>16),(cG1>>16),(cR1>>16));
5770 ////////////////////////////////////////////////////////////////////////
5772 // note: two g-shaded tris: small texture distortions can happen
5776 static void drawPoly4TGD_TRI(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4, int32_t col1, int32_t col2, int32_t col3, int32_t col4)
5778 drawPoly3TGD(x2,y2,x3,y3,x4,y4,
5779 tx2,ty2,tx3,ty3,tx4,ty4,
5781 drawPoly3TGD(x1,y1,x2,y2,x4,y4,
5782 tx1,ty1,tx2,ty2,tx4,ty4,
5788 static void drawPoly4TGD(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4, int32_t col1, int32_t col2, int32_t col4, int32_t col3)
5791 int32_t i,j,xmin,xmax,ymin,ymax;
5792 int32_t cR1,cG1,cB1;
5793 int32_t difR,difB,difG,difR2,difB2,difG2;
5794 int32_t difX, difY, difX2, difY2;
5797 if(x1>drawW && x2>drawW && x3>drawW && x4>drawW) return;
5798 if(y1>drawH && y2>drawH && y3>drawH && y4>drawH) return;
5799 if(x1<drawX && x2<drawX && x3<drawX && x4<drawX) return;
5800 if(y1<drawY && y2<drawY && y3<drawY && y4<drawY) return;
5801 if(drawY>=drawH) return;
5802 if(drawX>=drawW) return;
5804 if(!SetupSections_GT4(x1,y1,x2,y2,x3,y3,x4,y4,tx1,ty1,tx2,ty2,tx3,ty3,tx4,ty4,col1,col2,col3,col4)) return;
5808 for(ymin=Ymin;ymin<drawY;ymin++)
5809 if(NextRow_GT4()) return;
5813 if(!bCheckMask && !DrawSemiTrans && !iDither)
5815 for (i=ymin;i<=ymax;i++)
5817 xmin=(left_x >> 16);
5818 xmax=(right_x >> 16);
5827 difX=(right_u-posX)/num;
5828 difY=(right_v-posY)/num;
5835 difR=(right_R-cR1)/num;
5836 difG=(right_G-cG1)/num;
5837 difB=(right_B-cB1)/num;
5843 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
5844 xmax--;if(drawW<xmax) xmax=drawW;
5846 for(j=xmin;j<xmax;j+=2)
5848 GetTextureTransColGX32_S((uint32_t *)&psxVuw[(i<<10)+j],
5849 (((int32_t)GETLE16(&psxVuw[((((posY+difY)>>16)+GlobalTextAddrY)<<10)+((posX+difX)>>16)+GlobalTextAddrX]))<<16)|
5850 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+((posX)>>16)+GlobalTextAddrX]),
5851 (cB1>>16)|((cB1+difB)&0xff0000),
5852 (cG1>>16)|((cG1+difG)&0xff0000),
5853 (cR1>>16)|((cR1+difR)&0xff0000));
5861 GetTextureTransColGX_S(&psxVuw[(i<<10)+j],
5862 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+(posX>>16)+GlobalTextAddrX]),
5863 (cB1>>16),(cG1>>16),(cR1>>16));
5865 if(NextRow_GT4()) return;
5872 for (i=ymin;i<=ymax;i++)
5874 xmin=(left_x >> 16);
5875 xmax=(right_x >> 16);
5884 difX=(right_u-posX)/num;
5885 difY=(right_v-posY)/num;
5892 difR=(right_R-cR1)/num;
5893 difG=(right_G-cG1)/num;
5894 difB=(right_B-cB1)/num;
5900 {j=drawX-xmin;xmin=drawX;posX+=j*difX;posY+=j*difY;cR1+=j*difR;cG1+=j*difG;cB1+=j*difB;}
5901 xmax--;if(drawW<xmax) xmax=drawW;
5903 for(j=xmin;j<=xmax;j++)
5906 GetTextureTransColGX(&psxVuw[(i<<10)+j],
5907 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+(posX>>16)+GlobalTextAddrX]),
5908 (cB1>>16),(cG1>>16),(cR1>>16));
5910 GetTextureTransColGX(&psxVuw[(i<<10)+j],
5911 GETLE16(&psxVuw[(((posY>>16)+GlobalTextAddrY)<<10)+(posX>>16)+GlobalTextAddrX]),
5912 (cB1>>16),(cG1>>16),(cR1>>16));
5920 if(NextRow_GT4()) return;
5924 ////////////////////////////////////////////////////////////////////////
5926 static void drawPoly4TGD_TW(short x1, short y1, short x2, short y2, short x3, short y3, short x4, short y4, short tx1, short ty1, short tx2, short ty2, short tx3, short ty3, short tx4, short ty4, int32_t col1, int32_t col2, int32_t col3, int32_t col4)
5928 drawPoly3TGD_TW(x2,y2,x3,y3,x4,y4,
5929 tx2,ty2,tx3,ty3,tx4,ty4,
5931 drawPoly3TGD_TW(x1,y1,x2,y2,x4,y4,
5932 tx1,ty1,tx2,ty2,tx4,ty4,
5936 ////////////////////////////////////////////////////////////////////////
5937 ////////////////////////////////////////////////////////////////////////
5938 ////////////////////////////////////////////////////////////////////////
5939 ////////////////////////////////////////////////////////////////////////
5940 ////////////////////////////////////////////////////////////////////////
5941 ////////////////////////////////////////////////////////////////////////
5945 // no real rect test, but it does its job the way I need it
5946 static inline BOOL IsNoRect(void)
5948 if(lx0==lx1 && lx2==lx3) return FALSE;
5949 if(lx0==lx2 && lx1==lx3) return FALSE;
5950 if(lx0==lx3 && lx1==lx2) return FALSE;
5956 static inline BOOL IsNoRect(void)
5958 if(!(dwActFixes&0x200)) return FALSE;
5962 if(lx1==lx3 && ly3==ly2 && lx2==lx0) return FALSE;
5963 if(lx1==lx2 && ly2==ly3 && lx3==lx0) return FALSE;
5969 if(lx2==lx3 && ly3==ly1 && lx1==lx0) return FALSE;
5970 if(lx2==lx1 && ly1==ly3 && lx3==lx0) return FALSE;
5976 if(lx3==lx2 && ly2==ly1 && lx1==lx0) return FALSE;
5977 if(lx3==lx1 && ly1==ly2 && lx2==lx0) return FALSE;
5983 ////////////////////////////////////////////////////////////////////////
5985 static void drawPoly3FT(unsigned char * baseAddr)
5987 uint32_t *gpuData = ((uint32_t *) baseAddr);
5989 if(!bUsingTWin && !(dwActFixes&0x100))
5991 switch(GlobalTextTP) // depending on texture mode
5994 drawPoly3TEx4(lx0,ly0,lx1,ly1,lx2,ly2,
5995 (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),
5996 ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & 511));
5999 drawPoly3TEx8(lx0,ly0,lx1,ly1,lx2,ly2,
6000 (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),
6001 ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & 511));
6004 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));
6010 switch(GlobalTextTP) // depending on texture mode
6013 drawPoly3TEx4_TW(lx0,ly0,lx1,ly1,lx2,ly2,
6014 (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),
6015 ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & 511));
6018 drawPoly3TEx8_TW(lx0,ly0,lx1,ly1,lx2,ly2,
6019 (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),
6020 ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & 511));
6023 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));
6028 ////////////////////////////////////////////////////////////////////////
6030 static void drawPoly4FT(unsigned char * baseAddr)
6032 uint32_t *gpuData = ((uint32_t *) baseAddr);
6039 switch (GlobalTextTP)
6042 drawPoly4TEx4_TRI(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,
6043 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[4]) & 0x000000ff), ((GETLE32(&gpuData[4])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),(GETLE32(&gpuData[6]) & 0x000000ff), ((GETLE32(&gpuData[6])>>8) & 0x000000ff), ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & 511));
6046 drawPoly4TEx8_TRI(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,
6047 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[4]) & 0x000000ff), ((GETLE32(&gpuData[4])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),(GETLE32(&gpuData[6]) & 0x000000ff), ((GETLE32(&gpuData[6])>>8) & 0x000000ff), ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & 511));
6050 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));
6057 switch (GlobalTextTP)
6059 case 0: // grandia investigations needed
6060 drawPoly4TEx4(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,
6061 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[4]) & 0x000000ff), ((GETLE32(&gpuData[4])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),(GETLE32(&gpuData[6]) & 0x000000ff), ((GETLE32(&gpuData[6])>>8) & 0x000000ff), ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & 511));
6064 drawPoly4TEx8(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,
6065 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[4]) & 0x000000ff), ((GETLE32(&gpuData[4])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),(GETLE32(&gpuData[6]) & 0x000000ff), ((GETLE32(&gpuData[6])>>8) & 0x000000ff), ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & 511));
6068 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));
6074 switch (GlobalTextTP)
6077 drawPoly4TEx4_TW(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,
6078 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[4]) & 0x000000ff), ((GETLE32(&gpuData[4])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),(GETLE32(&gpuData[6]) & 0x000000ff), ((GETLE32(&gpuData[6])>>8) & 0x000000ff), ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & 511));
6081 drawPoly4TEx8_TW(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,
6082 (GETLE32(&gpuData[2]) & 0x000000ff), ((GETLE32(&gpuData[2])>>8) & 0x000000ff), (GETLE32(&gpuData[4]) & 0x000000ff), ((GETLE32(&gpuData[4])>>8) & 0x000000ff),(GETLE32(&gpuData[8]) & 0x000000ff), ((GETLE32(&gpuData[8])>>8) & 0x000000ff),(GETLE32(&gpuData[6]) & 0x000000ff), ((GETLE32(&gpuData[6])>>8) & 0x000000ff), ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & 511));
6085 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));
6090 ////////////////////////////////////////////////////////////////////////
6092 static void drawPoly3GT(unsigned char * baseAddr)
6094 uint32_t *gpuData = ((uint32_t *) baseAddr);
6098 switch (GlobalTextTP)
6101 drawPoly3TGEx4(lx0,ly0,lx1,ly1,lx2,ly2,
6102 (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),
6103 ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & 511),
6104 GETLE32(&gpuData[0]),GETLE32(&gpuData[3]),GETLE32(&gpuData[6]));
6107 drawPoly3TGEx8(lx0,ly0,lx1,ly1,lx2,ly2,
6108 (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),
6109 ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & 511),
6110 GETLE32(&gpuData[0]),GETLE32(&gpuData[3]),GETLE32(&gpuData[6]));
6113 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]));
6119 switch(GlobalTextTP)
6122 drawPoly3TGEx4_TW(lx0,ly0,lx1,ly1,lx2,ly2,
6123 (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),
6124 ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & 511),
6125 GETLE32(&gpuData[0]),GETLE32(&gpuData[3]),GETLE32(&gpuData[6]));
6128 drawPoly3TGEx8_TW(lx0,ly0,lx1,ly1,lx2,ly2,
6129 (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),
6130 ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & 511),
6131 GETLE32(&gpuData[0]),GETLE32(&gpuData[3]),GETLE32(&gpuData[6]));
6134 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]));
6139 ////////////////////////////////////////////////////////////////////////
6141 static void drawPoly4GT(unsigned char *baseAddr)
6143 uint32_t *gpuData = ((uint32_t *) baseAddr);
6150 switch (GlobalTextTP)
6153 drawPoly4TGEx4_TRI(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,
6154 (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),
6155 ((GETLE32(&gpuData[2])>>12) & 0x3f0),((GETLE32(&gpuData[2])>>22) & 511),
6156 GETLE32(&gpuData[0]),GETLE32(&gpuData[3]),GETLE32(&gpuData[6]),GETLE32(&gpuData[9]));
6160 drawPoly4TGEx8_TRI(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,
6161 (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),
6162 ((GETLE32(&gpuData[2])>>12) & 0x3f0),((GETLE32(&gpuData[2])>>22) & 511),
6163 GETLE32(&gpuData[0]),GETLE32(&gpuData[3]),GETLE32(&gpuData[6]),GETLE32(&gpuData[9]));
6166 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]));
6173 switch (GlobalTextTP)
6176 drawPoly4TGEx4(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,
6177 (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),
6178 ((GETLE32(&gpuData[2])>>12) & 0x3f0),((GETLE32(&gpuData[2])>>22) & 511),
6179 GETLE32(&gpuData[0]),GETLE32(&gpuData[3]),GETLE32(&gpuData[6]),GETLE32(&gpuData[9]));
6183 drawPoly4TGEx8(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,
6184 (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),
6185 ((GETLE32(&gpuData[2])>>12) & 0x3f0),((GETLE32(&gpuData[2])>>22) & 511),
6186 GETLE32(&gpuData[0]),GETLE32(&gpuData[3]),GETLE32(&gpuData[6]),GETLE32(&gpuData[9]));
6189 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]));
6195 switch (GlobalTextTP)
6198 drawPoly4TGEx4_TW(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,
6199 (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),
6200 ((GETLE32(&gpuData[2])>>12) & 0x3f0),((GETLE32(&gpuData[2])>>22) & 511),
6201 GETLE32(&gpuData[0]),GETLE32(&gpuData[3]),GETLE32(&gpuData[6]),GETLE32(&gpuData[9]));
6204 drawPoly4TGEx8_TW(lx0,ly0,lx1,ly1,lx3,ly3,lx2,ly2,
6205 (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),
6206 ((GETLE32(&gpuData[2])>>12) & 0x3f0),((GETLE32(&gpuData[2])>>22) & 511),
6207 GETLE32(&gpuData[0]),GETLE32(&gpuData[3]),GETLE32(&gpuData[6]),GETLE32(&gpuData[9]));
6210 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]));
6215 ////////////////////////////////////////////////////////////////////////
6217 ////////////////////////////////////////////////////////////////////////
6219 static void DrawSoftwareSpriteTWin(unsigned char * baseAddr,int32_t w,int32_t h)
6221 uint32_t *gpuData = (uint32_t *)baseAddr;
6222 short sx0,sy0,sx1,sy1,sx2,sy2,sx3,sy3;
6223 short tx0,ty0,tx1,ty1,tx2,ty2,tx3,ty3;
6228 sx0=sx3=sx0+PSXDisplay.DrawOffset.x;
6230 sy0=sy1=sy0+PSXDisplay.DrawOffset.y;
6233 tx0=tx3=GETLE32(&gpuData[2])&0xff;
6235 ty0=ty1=(GETLE32(&gpuData[2])>>8)&0xff;
6238 switch (GlobalTextTP)
6241 drawPoly4TEx4_TW_S(sx0,sy0,sx1,sy1,sx2,sy2,sx3,sy3,
6242 tx0,ty0,tx1,ty1,tx2,ty2,tx3,ty3,
6243 ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & 511));
6246 drawPoly4TEx8_TW_S(sx0,sy0,sx1,sy1,sx2,sy2,sx3,sy3,
6247 tx0,ty0,tx1,ty1,tx2,ty2,tx3,ty3,
6248 ((GETLE32(&gpuData[2])>>12) & 0x3f0), ((GETLE32(&gpuData[2])>>22) & 511));
6251 drawPoly4TD_TW_S(sx0,sy0,sx1,sy1,sx2,sy2,sx3,sy3,
6252 tx0,ty0,tx1,ty1,tx2,ty2,tx3,ty3);
6257 ////////////////////////////////////////////////////////////////////////
6259 static void DrawSoftwareSpriteMirror(unsigned char * baseAddr,int32_t w,int32_t h)
6261 int32_t sprtY,sprtX,sprtW,sprtH,lXDir,lYDir;
6262 int32_t clutY0,clutX0,clutP,textX0,textY0,sprtYa,sprCY,sprCX,sprA;
6264 uint32_t *gpuData = (uint32_t *)baseAddr;
6269 clutY0 = (GETLE32(&gpuData[2])>>22) & 511;
6270 clutX0 = (GETLE32(&gpuData[2])>>12) & 0x3f0;
6271 clutP = (clutY0<<11) + (clutX0<<1);
6272 textY0 = ((GETLE32(&gpuData[2])>>8) & 0x000000ff) + GlobalTextAddrY;
6273 textX0 = (GETLE32(&gpuData[2]) & 0x000000ff);
6275 sprtX+=PSXDisplay.DrawOffset.x;
6276 sprtY+=PSXDisplay.DrawOffset.y;
6290 if((sprtY+sprtH)<drawY) return;
6291 sprtH-=(drawY-sprtY);
6292 textY0+=(drawY-sprtY);
6298 if((sprtX+sprtW)<drawX) return;
6299 sprtW-=(drawX-sprtX);
6300 textX0+=(drawX-sprtX);
6304 if((sprtY+sprtH)>drawH) sprtH=drawH-sprtY+1;
6305 if((sprtX+sprtW)>drawW) sprtW=drawW-sprtX+1;
6307 if(usMirror&0x1000) lXDir=-1; else lXDir=1;
6308 if(usMirror&0x2000) lYDir=-1; else lYDir=1;
6310 switch (GlobalTextTP)
6312 case 0: // texture is 4-bit
6315 textX0=(GlobalTextAddrX<<1)+(textX0>>1);
6317 clutP=(clutY0<<10)+clutX0;
6318 for (sprCY=0;sprCY<sprtH;sprCY++)
6320 for (sprCX=0;sprCX<sprtW;sprCX++)
6322 tC= psxVub[((textY0+(sprCY*lYDir))<<11) + textX0 +(sprCX*lXDir)];
6323 sprA=sprtYa+(sprCY<<10)+sprtX + (sprCX<<1);
6324 GetTextureTransColG_SPR(&psxVuw[sprA],GETLE16(&psxVuw[clutP+((tC>>4)&0xf)]));
6325 GetTextureTransColG_SPR(&psxVuw[sprA+1],GETLE16(&psxVuw[clutP+(tC&0xf)]));
6333 for(sprCY=0;sprCY<sprtH;sprCY++)
6335 for(sprCX=0;sprCX<sprtW;sprCX++)
6337 tC = psxVub[((textY0+(sprCY*lYDir))<<11)+(GlobalTextAddrX<<1) + textX0 + (sprCX*lXDir)] & 0xff;
6338 GetTextureTransColG_SPR(&psxVuw[((sprtY+sprCY)<<10)+sprtX + sprCX],psxVuw[clutP+tC]);
6345 for (sprCY=0;sprCY<sprtH;sprCY++)
6347 for (sprCX=0;sprCX<sprtW;sprCX++)
6349 GetTextureTransColG_SPR(&psxVuw[((sprtY+sprCY)<<10)+sprtX+sprCX],
6350 GETLE16(&psxVuw[((textY0+(sprCY*lYDir))<<10)+GlobalTextAddrX + textX0 +(sprCX*lXDir)]));
6357 ////////////////////////////////////////////////////////////////////////
6359 static void DrawSoftwareSprite(unsigned char * baseAddr,short w,short h,int32_t tx,int32_t ty)
6361 int32_t sprtY,sprtX,sprtW,sprtH;
6362 int32_t clutY0,clutX0,clutP,textX0,textY0,sprtYa,sprCY,sprCX,sprA;
6364 uint32_t *gpuData = (uint32_t *)baseAddr;
6372 clutY0 = (GETLE32(&gpuData[2])>>22) & 511;
6373 clutX0 = (GETLE32(&gpuData[2])>>12) & 0x3f0;
6375 clutP = (clutY0<<11) + (clutX0<<1);
6377 textY0 =ty+ GlobalTextAddrY;
6380 sprtX+=PSXDisplay.DrawOffset.x;
6381 sprtY+=PSXDisplay.DrawOffset.y;
6395 if((sprtY+sprtH)<drawY) return;
6396 sprtH-=(drawY-sprtY);
6397 textY0+=(drawY-sprtY);
6403 if((sprtX+sprtW)<drawX) return;
6405 sprtW-=(drawX-sprtX);
6406 textX0+=(drawX-sprtX);
6410 if((sprtY+sprtH)>drawH) sprtH=drawH-sprtY+1;
6411 if((sprtX+sprtW)>drawW) sprtW=drawW-sprtX+1;
6417 switch (GlobalTextTP)
6421 if(textX0&1) {bWS=TRUE;sprtW--;}
6422 if(sprtW&1) bWT=TRUE;
6425 textX0=(GlobalTextAddrX<<1)+(textX0>>1)+(textY0<<11);
6426 sprtYa=(sprtY<<10)+sprtX;
6427 clutP=(clutY0<<10)+clutX0;
6431 if(!bCheckMask && !DrawSemiTrans)
6433 for (sprCY=0;sprCY<sprtH;sprCY++)
6435 sprA=sprtYa+(sprCY<<10);
6436 pV=&psxVub[(sprCY<<11)+textX0];
6441 GetTextureTransColG_S(&psxVuw[sprA++],GETLE16(&psxVuw[clutP+((tC>>4)&0xf)]));
6444 for (sprCX=0;sprCX<sprtW;sprCX++,sprA+=2)
6448 GetTextureTransColG32_S((uint32_t *)&psxVuw[sprA],
6449 (((int32_t)GETLE16(&psxVuw[clutP+((tC>>4)&0xf)]))<<16)|
6450 GETLE16(&psxVuw[clutP+(tC&0x0f)]));
6456 GetTextureTransColG_S(&psxVuw[sprA],GETLE16(&psxVuw[clutP+(tC&0x0f)]));
6464 for (sprCY=0;sprCY<sprtH;sprCY++)
6466 sprA=sprtYa+(sprCY<<10);
6467 pV=&psxVub[(sprCY<<11)+textX0];
6472 GetTextureTransColG_SPR(&psxVuw[sprA++],GETLE16(&psxVuw[clutP+((tC>>4)&0xf)]));
6475 for (sprCX=0;sprCX<sprtW;sprCX++,sprA+=2)
6479 GetTextureTransColG32_SPR((uint32_t *)&psxVuw[sprA],
6480 (((int32_t)GETLE16(&psxVuw[clutP+((tC>>4)&0xf)])<<16))|
6481 GETLE16(&psxVuw[clutP+(tC&0x0f)]));
6487 GetTextureTransColG_SPR(&psxVuw[sprA],GETLE16(&psxVuw[clutP+(tC&0x0f)]));
6494 textX0+=(GlobalTextAddrX<<1) + (textY0<<11);
6498 if(!bCheckMask && !DrawSemiTrans)
6500 for(sprCY=0;sprCY<sprtH;sprCY++)
6502 sprA=((sprtY+sprCY)<<10)+sprtX;
6503 pV=&psxVub[(sprCY<<11)+textX0];
6504 for(sprCX=0;sprCX<sprtW;sprCX+=2,sprA+=2)
6506 tC = *pV++;tC2 = *pV++;
6507 GetTextureTransColG32_S((uint32_t *)&psxVuw[sprA],
6508 (((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16)|
6509 GETLE16(&psxVuw[clutP+tC]));
6512 GetTextureTransColG_S(&psxVuw[sprA],GETLE16(&psxVuw[clutP+(*pV)]));
6519 for(sprCY=0;sprCY<sprtH;sprCY++)
6521 sprA=((sprtY+sprCY)<<10)+sprtX;
6522 pV=&psxVub[(sprCY<<11)+textX0];
6523 for(sprCX=0;sprCX<sprtW;sprCX+=2,sprA+=2)
6525 tC = *pV++;tC2 = *pV++;
6526 GetTextureTransColG32_SPR((uint32_t *)&psxVuw[sprA],
6527 (((int32_t)GETLE16(&psxVuw[clutP+tC2]))<<16)|
6528 GETLE16(&psxVuw[clutP+tC]));
6531 GetTextureTransColG_SPR(&psxVuw[sprA],GETLE16(&psxVuw[clutP+(*pV)]));
6537 textX0+=(GlobalTextAddrX) + (textY0<<10);
6542 if(!bCheckMask && !DrawSemiTrans)
6544 for (sprCY=0;sprCY<sprtH;sprCY++)
6546 sprA=((sprtY+sprCY)<<10)+sprtX;
6548 for (sprCX=0;sprCX<sprtW;sprCX+=2,sprA+=2)
6550 GetTextureTransColG32_S((uint32_t *)&psxVuw[sprA],
6551 (((int32_t)GETLE16(&psxVuw[(sprCY<<10) + textX0 + sprCX +1]))<<16)|
6552 GETLE16(&psxVuw[(sprCY<<10) + textX0 + sprCX]));
6555 GetTextureTransColG_S(&psxVuw[sprA],
6556 GETLE16(&psxVuw[(sprCY<<10) + textX0 + sprCX]));
6564 for (sprCY=0;sprCY<sprtH;sprCY++)
6566 sprA=((sprtY+sprCY)<<10)+sprtX;
6568 for (sprCX=0;sprCX<sprtW;sprCX+=2,sprA+=2)
6570 GetTextureTransColG32_SPR((uint32_t *)&psxVuw[sprA],
6571 (((int32_t)GETLE16(&psxVuw[(sprCY<<10) + textX0 + sprCX +1]))<<16)|
6572 GETLE16(&psxVuw[(sprCY<<10) + textX0 + sprCX]));
6575 GetTextureTransColG_SPR(&psxVuw[sprA],
6576 GETLE16(&psxVuw[(sprCY<<10) + textX0 + sprCX]));
6583 ///////////////////////////////////////////////////////////////////////
6585 /////////////////////////////////////////////////////////////////
6586 /////////////////////////////////////////////////////////////////
6587 /////////////////////////////////////////////////////////////////
6589 ////////////////////////////////////////////////////////////////////////
6590 /////////////////////////////////////////////////////////////////
6591 /////////////////////////////////////////////////////////////////
6594 ///////////////////////////////////////////////////////////////////////
6596 static void Line_E_SE_Shade(int x0, int y0, int x1, int y1, uint32_t rgb0, uint32_t rgb1)
6598 int dx, dy, incrE, incrSE, d;
6599 uint32_t r0, g0, b0, r1, g1, b1;
6602 r0 = (rgb0 & 0x00ff0000);
6603 g0 = (rgb0 & 0x0000ff00) << 8;
6604 b0 = (rgb0 & 0x000000ff) << 16;
6605 r1 = (rgb1 & 0x00ff0000);
6606 g1 = (rgb1 & 0x0000ff00) << 8;
6607 b1 = (rgb1 & 0x000000ff) << 16;
6614 dr = ((int32_t)r1 - (int32_t)r0) / dx;
6615 dg = ((int32_t)g1 - (int32_t)g0) / dx;
6616 db = ((int32_t)b1 - (int32_t)b0) / dx;
6620 dr = ((int32_t)r1 - (int32_t)r0);
6621 dg = ((int32_t)g1 - (int32_t)g0);
6622 db = ((int32_t)b1 - (int32_t)b0);
6625 d = 2*dy - dx; /* Initial value of d */
6626 incrE = 2*dy; /* incr. used for move to E */
6627 incrSE = 2*(dy - dx); /* incr. used for move to SE */
6629 if ((x0>=drawX)&&(x0<drawW)&&(y0>=drawY)&&(y0<drawH))
6630 GetShadeTransCol(&psxVuw[(y0<<10)+x0],(unsigned short)(((r0 >> 9)&0x7c00)|((g0 >> 14)&0x03e0)|((b0 >> 19)&0x001f)));
6635 d = d + incrE; /* Choose E */
6639 d = d + incrSE; /* Choose SE */
6648 if ((x0>=drawX)&&(x0<drawW)&&(y0>=drawY)&&(y0<drawH))
6649 GetShadeTransCol(&psxVuw[(y0<<10)+x0],(unsigned short)(((r0 >> 9)&0x7c00)|((g0 >> 14)&0x03e0)|((b0 >> 19)&0x001f)));
6653 ///////////////////////////////////////////////////////////////////////
6655 static void Line_S_SE_Shade(int x0, int y0, int x1, int y1, uint32_t rgb0, uint32_t rgb1)
6657 int dx, dy, incrS, incrSE, d;
6658 uint32_t r0, g0, b0, r1, g1, b1;
6661 r0 = (rgb0 & 0x00ff0000);
6662 g0 = (rgb0 & 0x0000ff00) << 8;
6663 b0 = (rgb0 & 0x000000ff) << 16;
6664 r1 = (rgb1 & 0x00ff0000);
6665 g1 = (rgb1 & 0x0000ff00) << 8;
6666 b1 = (rgb1 & 0x000000ff) << 16;
6673 dr = ((int32_t)r1 - (int32_t)r0) / dy;
6674 dg = ((int32_t)g1 - (int32_t)g0) / dy;
6675 db = ((int32_t)b1 - (int32_t)b0) / dy;
6679 dr = ((int32_t)r1 - (int32_t)r0);
6680 dg = ((int32_t)g1 - (int32_t)g0);
6681 db = ((int32_t)b1 - (int32_t)b0);
6684 d = 2*dx - dy; /* Initial value of d */
6685 incrS = 2*dx; /* incr. used for move to S */
6686 incrSE = 2*(dx - dy); /* incr. used for move to SE */
6688 if ((x0>=drawX)&&(x0<drawW)&&(y0>=drawY)&&(y0<drawH))
6689 GetShadeTransCol(&psxVuw[(y0<<10)+x0],(unsigned short)(((r0 >> 9)&0x7c00)|((g0 >> 14)&0x03e0)|((b0 >> 19)&0x001f)));
6694 d = d + incrS; /* Choose S */
6698 d = d + incrSE; /* Choose SE */
6707 if ((x0>=drawX)&&(x0<drawW)&&(y0>=drawY)&&(y0<drawH))
6708 GetShadeTransCol(&psxVuw[(y0<<10)+x0],(unsigned short)(((r0 >> 9)&0x7c00)|((g0 >> 14)&0x03e0)|((b0 >> 19)&0x001f)));
6712 ///////////////////////////////////////////////////////////////////////
6714 static void Line_N_NE_Shade(int x0, int y0, int x1, int y1, uint32_t rgb0, uint32_t rgb1)
6716 int dx, dy, incrN, incrNE, d;
6717 uint32_t r0, g0, b0, r1, g1, b1;
6720 r0 = (rgb0 & 0x00ff0000);
6721 g0 = (rgb0 & 0x0000ff00) << 8;
6722 b0 = (rgb0 & 0x000000ff) << 16;
6723 r1 = (rgb1 & 0x00ff0000);
6724 g1 = (rgb1 & 0x0000ff00) << 8;
6725 b1 = (rgb1 & 0x000000ff) << 16;
6732 dr = ((int32_t)r1 - (int32_t)r0) / dy;
6733 dg = ((int32_t)g1 - (int32_t)g0) / dy;
6734 db = ((int32_t)b1 - (int32_t)b0) / dy;
6738 dr = ((int32_t)r1 - (int32_t)r0);
6739 dg = ((int32_t)g1 - (int32_t)g0);
6740 db = ((int32_t)b1 - (int32_t)b0);
6743 d = 2*dx - dy; /* Initial value of d */
6744 incrN = 2*dx; /* incr. used for move to N */
6745 incrNE = 2*(dx - dy); /* incr. used for move to NE */
6747 if ((x0>=drawX)&&(x0<drawW)&&(y0>=drawY)&&(y0<drawH))
6748 GetShadeTransCol(&psxVuw[(y0<<10)+x0],(unsigned short)(((r0 >> 9)&0x7c00)|((g0 >> 14)&0x03e0)|((b0 >> 19)&0x001f)));
6753 d = d + incrN; /* Choose N */
6757 d = d + incrNE; /* Choose NE */
6766 if ((x0>=drawX)&&(x0<drawW)&&(y0>=drawY)&&(y0<drawH))
6767 GetShadeTransCol(&psxVuw[(y0<<10)+x0],(unsigned short)(((r0 >> 9)&0x7c00)|((g0 >> 14)&0x03e0)|((b0 >> 19)&0x001f)));
6771 ///////////////////////////////////////////////////////////////////////
6773 static void Line_E_NE_Shade(int x0, int y0, int x1, int y1, uint32_t rgb0, uint32_t rgb1)
6775 int dx, dy, incrE, incrNE, d;
6776 uint32_t r0, g0, b0, r1, g1, b1;
6779 r0 = (rgb0 & 0x00ff0000);
6780 g0 = (rgb0 & 0x0000ff00) << 8;
6781 b0 = (rgb0 & 0x000000ff) << 16;
6782 r1 = (rgb1 & 0x00ff0000);
6783 g1 = (rgb1 & 0x0000ff00) << 8;
6784 b1 = (rgb1 & 0x000000ff) << 16;
6791 dr = ((int32_t)r1 - (int32_t)r0) / dx;
6792 dg = ((int32_t)g1 - (int32_t)g0) / dx;
6793 db = ((int32_t)b1 - (int32_t)b0) / dx;
6797 dr = ((int32_t)r1 - (int32_t)r0);
6798 dg = ((int32_t)g1 - (int32_t)g0);
6799 db = ((int32_t)b1 - (int32_t)b0);
6802 d = 2*dy - dx; /* Initial value of d */
6803 incrE = 2*dy; /* incr. used for move to E */
6804 incrNE = 2*(dy - dx); /* incr. used for move to NE */
6806 if ((x0>=drawX)&&(x0<drawW)&&(y0>=drawY)&&(y0<drawH))
6807 GetShadeTransCol(&psxVuw[(y0<<10)+x0],(unsigned short)(((r0 >> 9)&0x7c00)|((g0 >> 14)&0x03e0)|((b0 >> 19)&0x001f)));
6812 d = d + incrE; /* Choose E */
6816 d = d + incrNE; /* Choose NE */
6825 if ((x0>=drawX)&&(x0<drawW)&&(y0>=drawY)&&(y0<drawH))
6826 GetShadeTransCol(&psxVuw[(y0<<10)+x0],(unsigned short)(((r0 >> 9)&0x7c00)|((g0 >> 14)&0x03e0)|((b0 >> 19)&0x001f)));
6830 ///////////////////////////////////////////////////////////////////////
6832 static void VertLineShade(int x, int y0, int y1, uint32_t rgb0, uint32_t rgb1)
6835 uint32_t r0, g0, b0, r1, g1, b1;
6838 r0 = (rgb0 & 0x00ff0000);
6839 g0 = (rgb0 & 0x0000ff00) << 8;
6840 b0 = (rgb0 & 0x000000ff) << 16;
6841 r1 = (rgb1 & 0x00ff0000);
6842 g1 = (rgb1 & 0x0000ff00) << 8;
6843 b1 = (rgb1 & 0x000000ff) << 16;
6849 dr = ((int32_t)r1 - (int32_t)r0) / dy;
6850 dg = ((int32_t)g1 - (int32_t)g0) / dy;
6851 db = ((int32_t)b1 - (int32_t)b0) / dy;
6855 dr = ((int32_t)r1 - (int32_t)r0);
6856 dg = ((int32_t)g1 - (int32_t)g0);
6857 db = ((int32_t)b1 - (int32_t)b0);
6862 r0+=dr*(drawY - y0);
6863 g0+=dg*(drawY - y0);
6864 b0+=db*(drawY - y0);
6871 for (y = y0; y <= y1; y++)
6873 GetShadeTransCol(&psxVuw[(y<<10)+x],(unsigned short)(((r0 >> 9)&0x7c00)|((g0 >> 14)&0x03e0)|((b0 >> 19)&0x001f)));
6880 ///////////////////////////////////////////////////////////////////////
6882 static void HorzLineShade(int y, int x0, int x1, uint32_t rgb0, uint32_t rgb1)
6885 uint32_t r0, g0, b0, r1, g1, b1;
6888 r0 = (rgb0 & 0x00ff0000);
6889 g0 = (rgb0 & 0x0000ff00) << 8;
6890 b0 = (rgb0 & 0x000000ff) << 16;
6891 r1 = (rgb1 & 0x00ff0000);
6892 g1 = (rgb1 & 0x0000ff00) << 8;
6893 b1 = (rgb1 & 0x000000ff) << 16;
6899 dr = ((int32_t)r1 - (int32_t)r0) / dx;
6900 dg = ((int32_t)g1 - (int32_t)g0) / dx;
6901 db = ((int32_t)b1 - (int32_t)b0) / dx;
6905 dr = ((int32_t)r1 - (int32_t)r0);
6906 dg = ((int32_t)g1 - (int32_t)g0);
6907 db = ((int32_t)b1 - (int32_t)b0);
6912 r0+=dr*(drawX - x0);
6913 g0+=dg*(drawX - x0);
6914 b0+=db*(drawX - x0);
6921 for (x = x0; x <= x1; x++)
6923 GetShadeTransCol(&psxVuw[(y<<10)+x],(unsigned short)(((r0 >> 9)&0x7c00)|((g0 >> 14)&0x03e0)|((b0 >> 19)&0x001f)));
6930 ///////////////////////////////////////////////////////////////////////
6932 static void Line_E_SE_Flat(int x0, int y0, int x1, int y1, unsigned short colour)
6934 int dx, dy, incrE, incrSE, d, x, y;
6938 d = 2*dy - dx; /* Initial value of d */
6939 incrE = 2*dy; /* incr. used for move to E */
6940 incrSE = 2*(dy - dx); /* incr. used for move to SE */
6943 if ((x>=drawX)&&(x<drawW)&&(y>=drawY)&&(y<drawH))
6944 GetShadeTransCol(&psxVuw[(y<<10)+x], colour);
6949 d = d + incrE; /* Choose E */
6954 d = d + incrSE; /* Choose SE */
6958 if ((x>=drawX)&&(x<drawW)&&(y>=drawY)&&(y<drawH))
6959 GetShadeTransCol(&psxVuw[(y<<10)+x], colour);
6963 ///////////////////////////////////////////////////////////////////////
6965 static void Line_S_SE_Flat(int x0, int y0, int x1, int y1, unsigned short colour)
6967 int dx, dy, incrS, incrSE, d, x, y;
6971 d = 2*dx - dy; /* Initial value of d */
6972 incrS = 2*dx; /* incr. used for move to S */
6973 incrSE = 2*(dx - dy); /* incr. used for move to SE */
6976 if ((x>=drawX)&&(x<drawW)&&(y>=drawY)&&(y<drawH))
6977 GetShadeTransCol(&psxVuw[(y<<10)+x], colour);
6982 d = d + incrS; /* Choose S */
6987 d = d + incrSE; /* Choose SE */
6991 if ((x>=drawX)&&(x<drawW)&&(y>=drawY)&&(y<drawH))
6992 GetShadeTransCol(&psxVuw[(y<<10)+x], colour);
6996 ///////////////////////////////////////////////////////////////////////
6998 static void Line_N_NE_Flat(int x0, int y0, int x1, int y1, unsigned short colour)
7000 int dx, dy, incrN, incrNE, d, x, y;
7004 d = 2*dx - dy; /* Initial value of d */
7005 incrN = 2*dx; /* incr. used for move to N */
7006 incrNE = 2*(dx - dy); /* incr. used for move to NE */
7009 if ((x>=drawX)&&(x<drawW)&&(y>=drawY)&&(y<drawH))
7010 GetShadeTransCol(&psxVuw[(y<<10)+x], colour);
7015 d = d + incrN; /* Choose N */
7020 d = d + incrNE; /* Choose NE */
7024 if ((x>=drawX)&&(x<drawW)&&(y>=drawY)&&(y<drawH))
7025 GetShadeTransCol(&psxVuw[(y<<10)+x], colour);
7029 ///////////////////////////////////////////////////////////////////////
7031 static void Line_E_NE_Flat(int x0, int y0, int x1, int y1, unsigned short colour)
7033 int dx, dy, incrE, incrNE, d, x, y;
7037 d = 2*dy - dx; /* Initial value of d */
7038 incrE = 2*dy; /* incr. used for move to E */
7039 incrNE = 2*(dy - dx); /* incr. used for move to NE */
7042 if ((x>=drawX)&&(x<drawW)&&(y>=drawY)&&(y<drawH))
7043 GetShadeTransCol(&psxVuw[(y<<10)+x], colour);
7048 d = d + incrE; /* Choose E */
7053 d = d + incrNE; /* Choose NE */
7057 if ((x>=drawX)&&(x<drawW)&&(y>=drawY)&&(y<drawH))
7058 GetShadeTransCol(&psxVuw[(y<<10)+x], colour);
7062 ///////////////////////////////////////////////////////////////////////
7064 static void VertLineFlat(int x, int y0, int y1, unsigned short colour)
7074 for (y = y0; y <= y1; y++)
7075 GetShadeTransCol(&psxVuw[(y<<10)+x], colour);
7078 ///////////////////////////////////////////////////////////////////////
7080 static void HorzLineFlat(int y, int x0, int x1, unsigned short colour)
7090 for (x = x0; x <= x1; x++)
7091 GetShadeTransCol(&psxVuw[(y << 10) + x], colour);
7094 ///////////////////////////////////////////////////////////////////////
7096 /* Bresenham Line drawing function */
7097 static void DrawSoftwareLineShade(int32_t rgb0, int32_t rgb1)
7099 short x0, y0, x1, y1, xt, yt;
7103 if (lx0 > drawW && lx1 > drawW) return;
7104 if (ly0 > drawH && ly1 > drawH) return;
7105 if (lx0 < drawX && lx1 < drawX) return;
7106 if (ly0 < drawY && ly1 < drawY) return;
7107 if (drawY >= drawH) return;
7108 if (drawX >= drawW) return;
7121 VertLineShade(x0, y0, y1, rgb0, rgb1);
7123 VertLineShade(x0, y1, y0, rgb1, rgb0);
7129 HorzLineShade(y0, x0, x1, rgb0, rgb1);
7131 HorzLineShade(y0, x1, x0, rgb1, rgb0);
7151 if ((dx >= 0 && dy >= 0) || (dx < 0 && dy < 0))
7153 if (abs(dy) > abs(dx))
7154 Line_S_SE_Shade(x0, y0, x1, y1, rgb0, rgb1);
7156 Line_E_SE_Shade(x0, y0, x1, y1, rgb0, rgb1);
7159 if (abs(dy) > abs(dx))
7160 Line_N_NE_Shade(x0, y0, x1, y1, rgb0, rgb1);
7162 Line_E_NE_Shade(x0, y0, x1, y1, rgb0, rgb1);
7166 ///////////////////////////////////////////////////////////////////////
7168 static void DrawSoftwareLineFlat(int32_t rgb)
7170 short x0, y0, x1, y1, xt, yt;
7172 unsigned short colour = 0;
7174 if (lx0 > drawW && lx1 > drawW) return;
7175 if (ly0 > drawH && ly1 > drawH) return;
7176 if (lx0 < drawX && lx1 < drawX) return;
7177 if (ly0 < drawY && ly1 < drawY) return;
7178 if (drawY >= drawH) return;
7179 if (drawX >= drawW) return;
7181 colour = ((rgb & 0x00f80000) >> 9) | ((rgb & 0x0000f800) >> 6) | ((rgb & 0x000000f8) >> 3);
7194 return; // Nothing to draw
7196 VertLineFlat(x0, y0, y1, colour);
7198 VertLineFlat(x0, y1, y0, colour);
7204 HorzLineFlat(y0, x0, x1, colour);
7206 HorzLineFlat(y0, x1, x0, colour);
7223 if ((dx >= 0 && dy >= 0) || (dx < 0 && dy < 0))
7225 if (abs(dy) > abs(dx))
7226 Line_S_SE_Flat(x0, y0, x1, y1, colour);
7228 Line_E_SE_Flat(x0, y0, x1, y1, colour);
7231 if (abs(dy) > abs(dx))
7232 Line_N_NE_Flat(x0, y0, x1, y1, colour);
7234 Line_E_NE_Flat(x0, y0, x1, y1, colour);
7238 ///////////////////////////////////////////////////////////////////////