///////////////////////////////////////////////////////////////////////////////
// GPU internal sprite drawing functions
-void gpuDrawS(PtrUnion packet, const PS gpuSpriteSpanDriver)
+void gpuDrawS(PtrUnion packet, const PS gpuSpriteDriver, s32 *w_out, s32 *h_out)
{
s32 x0, x1, y0, y1;
u32 u0, v0;
if (x1 > xmax) x1 = xmax;
x1 -= x0;
if (x1 <= 0) return;
-
- gpu_unai.r5 = packet.U1[0] >> 3;
- gpu_unai.g5 = packet.U1[1] >> 3;
- gpu_unai.b5 = packet.U1[2] >> 3;
+ *w_out = x1;
+ *h_out = y1 - y0;
le16_t *Pixel = &gpu_unai.vram[FRAME_OFFSET(x0, y0)];
- const int li=gpu_unai.ilace_mask;
- const int pi=(ProgressiveInterlaceEnabled()?(gpu_unai.ilace_mask+1):0);
- const int pif=(ProgressiveInterlaceEnabled()?(gpu_unai.prog_ilace_flag?(gpu_unai.ilace_mask+1):0):1);
- unsigned int tmode = gpu_unai.TEXT_MODE >> 5;
- const u32 v0_mask = gpu_unai.TextureWindow[3];
- u8* pTxt_base = (u8*)gpu_unai.TBA;
-
- // Texture is accessed byte-wise, so adjust idx if 16bpp
- if (tmode == 3) u0 <<= 1;
-
- for (; y0<y1; ++y0) {
- u8* pTxt = pTxt_base + ((v0 & v0_mask) * 2048);
- if (!(y0&li) && (y0&pi)!=pif)
- gpuSpriteSpanDriver(Pixel, x1, pTxt, u0);
- Pixel += FRAME_WIDTH;
- v0++;
- }
-}
-
-#ifdef __arm__
-#include "gpu_arm.h"
-
-/* Notaz 4bit sprites optimization */
-void gpuDrawS16(PtrUnion packet)
-{
- s32 x0, y0;
- s32 u0, v0;
- s32 xmin, xmax;
- s32 ymin, ymax;
- u32 h = 16;
- //NOTE: Must 11-bit sign-extend the whole sum here, not just packet X/Y,
- // or sprites in 1st level of SkullMonkeys disappear when walking right.
- // This now matches behavior of Mednafen and PCSX Rearmed's gpu_neon:
- x0 = GPU_EXPANDSIGN(le16_to_s16(packet.U2[2]) + gpu_unai.DrawingOffset[0]);
- y0 = GPU_EXPANDSIGN(le16_to_s16(packet.U2[3]) + gpu_unai.DrawingOffset[1]);
-
- xmin = gpu_unai.DrawingArea[0]; xmax = gpu_unai.DrawingArea[2];
- ymin = gpu_unai.DrawingArea[1]; ymax = gpu_unai.DrawingArea[3];
- u0 = packet.U1[8];
- v0 = packet.U1[9];
-
- if (x0 > xmax - 16 || x0 < xmin ||
- ((u0 | v0) & 15) || !(gpu_unai.TextureWindow[2] & gpu_unai.TextureWindow[3] & 8)) {
- // send corner cases to general handler
- packet.U4[3] = u32_to_le32(0x00100010);
- gpuDrawS(packet, gpuSpriteSpanFn<0x20>);
- return;
- }
-
- if (y0 >= ymax || y0 <= ymin - 16)
- return;
- if (y0 < ymin) {
- h -= ymin - y0;
- v0 += ymin - y0;
- y0 = ymin;
- }
- else if (ymax - y0 < 16)
- h = ymax - y0;
-
- draw_spr16_full(&gpu_unai.vram[FRAME_OFFSET(x0, y0)], &gpu_unai.TBA[FRAME_OFFSET(u0/4, v0)], gpu_unai.CBA, h);
+ gpu_unai.inn.r5 = packet.U1[0] >> 3;
+ gpu_unai.inn.g5 = packet.U1[1] >> 3;
+ gpu_unai.inn.b5 = packet.U1[2] >> 3;
+ gpu_unai.inn.u = u0;
+ gpu_unai.inn.v = v0;
+ gpu_unai.inn.y0 = y0;
+ gpu_unai.inn.y1 = y1;
+ gpuSpriteDriver(Pixel, x1, (u8 *)gpu_unai.inn.TBA, gpu_unai.inn);
}
-#endif // __arm__
-void gpuDrawT(PtrUnion packet, const PT gpuTileSpanDriver)
+void gpuDrawT(PtrUnion packet, const PT gpuTileDriver, s32 *w_out, s32 *h_out)
{
s32 x0, x1, y0, y1;
if (x1 > xmax) x1 = xmax;
x1 -= x0;
if (x1 <= 0) return;
+ *w_out = x1;
+ *h_out = y1 - y0;
const u16 Data = GPU_RGB16(le32_to_u32(packet.U4[0]));
le16_t *Pixel = &gpu_unai.vram[FRAME_OFFSET(x0, y0)];
- const int li=gpu_unai.ilace_mask;
- const int pi=(ProgressiveInterlaceEnabled()?(gpu_unai.ilace_mask+1):0);
- const int pif=(ProgressiveInterlaceEnabled()?(gpu_unai.prog_ilace_flag?(gpu_unai.ilace_mask+1):0):1);
-
- for (; y0<y1; ++y0) {
- if (!(y0&li) && (y0&pi)!=pif)
- gpuTileSpanDriver(Pixel,x1,Data);
- Pixel += FRAME_WIDTH;
- }
+
+ gpu_unai.inn.y0 = y0;
+ gpu_unai.inn.y1 = y1;
+ gpuTileDriver(Pixel, Data, x1, gpu_unai.inn);
}
#endif /* __GPU_UNAI_GPU_RASTER_SPRITE_H__ */