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 #ifndef __GPU_UNAI_GPU_RASTER_SPRITE_H__
22 #define __GPU_UNAI_GPU_RASTER_SPRITE_H__
24 ///////////////////////////////////////////////////////////////////////////////
25 // GPU internal sprite drawing functions
27 void gpuDrawS(PtrUnion packet, const PS gpuSpriteDriver, s32 *w_out, s32 *h_out)
32 //NOTE: Must 11-bit sign-extend the whole sum here, not just packet X/Y,
33 // or sprites in 1st level of SkullMonkeys disappear when walking right.
34 // This now matches behavior of Mednafen and PCSX Rearmed's gpu_neon:
35 x0 = GPU_EXPANDSIGN(le16_to_s16(packet.U2[2]) + gpu_unai.DrawingOffset[0]);
36 y0 = GPU_EXPANDSIGN(le16_to_s16(packet.U2[3]) + gpu_unai.DrawingOffset[1]);
38 u32 w = le16_to_u16(packet.U2[6]) & 0x3ff; // Max width is 1023
39 u32 h = le16_to_u16(packet.U2[7]) & 0x1ff; // Max height is 511
43 s32 xmin, xmax, ymin, ymax;
44 xmin = gpu_unai.DrawingArea[0]; xmax = gpu_unai.DrawingArea[2];
45 ymin = gpu_unai.DrawingArea[1]; ymax = gpu_unai.DrawingArea[3];
52 if (temp > 0) { y0 = ymin; v0 += temp; }
53 if (y1 > ymax) y1 = ymax;
57 if (temp > 0) { x0 = xmin; u0 += temp; }
58 if (x1 > xmax) x1 = xmax;
64 le16_t *Pixel = &gpu_unai.vram[FRAME_OFFSET(x0, y0)];
66 gpu_unai.inn.r5 = packet.U1[0] >> 3;
67 gpu_unai.inn.g5 = packet.U1[1] >> 3;
68 gpu_unai.inn.b5 = packet.U1[2] >> 3;
73 gpuSpriteDriver(Pixel, x1, (u8 *)gpu_unai.inn.TBA, gpu_unai.inn);
76 void gpuDrawT(PtrUnion packet, const PT gpuTileDriver, s32 *w_out, s32 *h_out)
80 // This now matches behavior of Mednafen and PCSX Rearmed's gpu_neon:
81 x0 = GPU_EXPANDSIGN(le16_to_s16(packet.U2[2]) + gpu_unai.DrawingOffset[0]);
82 y0 = GPU_EXPANDSIGN(le16_to_s16(packet.U2[3]) + gpu_unai.DrawingOffset[1]);
84 u32 w = le16_to_u16(packet.U2[4]) & 0x3ff; // Max width is 1023
85 u32 h = le16_to_u16(packet.U2[5]) & 0x1ff; // Max height is 511
89 s32 xmin, xmax, ymin, ymax;
90 xmin = gpu_unai.DrawingArea[0]; xmax = gpu_unai.DrawingArea[2];
91 ymin = gpu_unai.DrawingArea[1]; ymax = gpu_unai.DrawingArea[3];
93 if (y0 < ymin) y0 = ymin;
94 if (y1 > ymax) y1 = ymax;
97 if (x0 < xmin) x0 = xmin;
98 if (x1 > xmax) x1 = xmax;
104 const u16 Data = GPU_RGB16(le32_to_u32(packet.U4[0]));
105 le16_t *Pixel = &gpu_unai.vram[FRAME_OFFSET(x0, y0)];
107 gpu_unai.inn.y0 = y0;
108 gpu_unai.inn.y1 = y1;
109 gpuTileDriver(Pixel, Data, x1, gpu_unai.inn);
112 #endif /* __GPU_UNAI_GPU_RASTER_SPRITE_H__ */