1 /***************************************************************************
2 * Copyright (C) 2010 PCSX4ALL Team *
3 * Copyright (C) 2010 Unai *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. *
19 ***************************************************************************/
21 ///////////////////////////////////////////////////////////////////////////////
22 // GPU internal sprite drawing functions
24 ///////////////////////////////////////////////////////////////////////////////
25 void gpuDrawS(const PS gpuSpriteSpanDriver)
32 x1 = x0 = GPU_EXPANDSIGN_SPRT(PacketBuffer.S2[2]) + DrawingOffset[0];
33 y1 = y0 = GPU_EXPANDSIGN_SPRT(PacketBuffer.S2[3]) + DrawingOffset[1];
34 x1+= PacketBuffer.S2[6];
35 y1+= PacketBuffer.S2[7];
40 xmin = DrawingArea[0]; xmax = DrawingArea[2];
41 ymin = DrawingArea[1]; ymax = DrawingArea[3];
44 int rx0 = Max2(xmin,Min2(x0,x1));
45 int ry0 = Max2(ymin,Min2(y0,y1));
46 int rx1 = Min2(xmax,Max2(x0,x1));
47 int ry1 = Min2(ymax,Max2(y0,y1));
48 if( rx0>=rx1 || ry0>=ry1) return;
51 u0 = PacketBuffer.U1[8];
52 v0 = PacketBuffer.U1[9];
54 r4 = s32(PacketBuffer.U1[0]);
55 g4 = s32(PacketBuffer.U1[1]);
56 b4 = s32(PacketBuffer.U1[2]);
61 if (temp > 0) { y0 = ymin; v0 += temp; }
62 if (y1 > ymax) y1 = ymax;
66 if (temp > 0) { x0 = xmin; u0 += temp; }
67 if (x1 > xmax) x1 = xmax;
74 u16 *Pixel = &((u16*)GPU_FrameBuffer)[FRAME_OFFSET(x0, y0)];
75 const int li=linesInterlace;
76 const u32 masku=TextureWindow[2];
77 const u32 maskv=TextureWindow[3];
80 if( 0 == (y0&li) ) gpuSpriteSpanDriver(Pixel,x1,FRAME_OFFSET(u0,v0),masku);
98 x0 = GPU_EXPANDSIGN_SPRT(PacketBuffer.S2[2]) + DrawingOffset[0];
99 y0 = GPU_EXPANDSIGN_SPRT(PacketBuffer.S2[3]) + DrawingOffset[1];
101 xmin = DrawingArea[0]; xmax = DrawingArea[2];
102 ymin = DrawingArea[1]; ymax = DrawingArea[3];
103 u0 = PacketBuffer.U1[8];
104 v0 = PacketBuffer.U1[9];
106 if (x0 > xmax - 16 || x0 < xmin ||
107 ((u0 | v0) & 15) || !(TextureWindow[2] & TextureWindow[3] & 8)) {
108 // send corner cases to general handler
109 PacketBuffer.U4[3] = 0x00100010;
110 gpuDrawS(gpuSpriteSpanFn<0x20>);
114 if (y0 >= ymax || y0 <= ymin - 16)
121 else if (ymax - y0 < 16)
124 draw_spr16_full(&GPU_FrameBuffer[FRAME_OFFSET(x0, y0)], &TBA[FRAME_OFFSET(u0/4, v0)], CBA, h);
128 ///////////////////////////////////////////////////////////////////////////////
129 void gpuDrawT(const PT gpuTileSpanDriver)
134 x1 = x0 = GPU_EXPANDSIGN_SPRT(PacketBuffer.S2[2]) + DrawingOffset[0];
135 y1 = y0 = GPU_EXPANDSIGN_SPRT(PacketBuffer.S2[3]) + DrawingOffset[1];
136 x1+= PacketBuffer.S2[4];
137 y1+= PacketBuffer.S2[5];
142 xmin = DrawingArea[0]; xmax = DrawingArea[2];
143 ymin = DrawingArea[1]; ymax = DrawingArea[3];
146 int rx0 = Max2(xmin,Min2(x0,x1));
147 int ry0 = Max2(ymin,Min2(y0,y1));
148 int rx1 = Min2(xmax,Max2(x0,x1));
149 int ry1 = Min2(ymax,Max2(y0,y1));
150 if(rx0>=rx1 || ry0>=ry1) return;
153 if (y0 < ymin) y0 = ymin;
154 if (y1 > ymax) y1 = ymax;
155 if (y1 <= y0) return;
157 if (x0 < xmin) x0 = xmin;
158 if (x1 > xmax) x1 = xmax;
164 u16 *Pixel = &((u16*)GPU_FrameBuffer)[FRAME_OFFSET(x0, y0)];
165 const u16 Data = GPU_RGB16(PacketBuffer.U4[0]);
166 const int li=linesInterlace;
170 if( 0 == (y0&li) ) gpuTileSpanDriver(Pixel,x1,Data);
171 Pixel += FRAME_WIDTH;