* 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. *
***************************************************************************/
+#ifndef __GPU_UNAI_GPU_RASTER_POLYGON_H__
+#define __GPU_UNAI_GPU_RASTER_POLYGON_H__
+
//senquack - NOTE: GPU Unai poly routines have been rewritten/adapted
// from DrHell routines to fix multiple issues. See README_senquack.txt
struct PolyVertex {
s32 x, y; // Sign-extended 11-bit X,Y coords
union {
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+ struct { u8 pad[2], v, u; } tex; // Texture coords (if used)
+#else
struct { u8 u, v, pad[2]; } tex; // Texture coords (if used)
+#endif
u32 tex_word;
};
union {
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+ struct { u8 pad, b, g, r; } col; // 24-bit RGB color (if used)
+#else
struct { u8 r, g, b, pad; } col; // 24-bit RGB color (if used)
+#endif
u32 col_word;
};
};
vert_stride++;
int num_verts = (is_quad) ? 4 : 3;
- u32 *ptr;
+ le32_t *ptr;
// X,Y coords, adjusted by draw offsets
s32 x_off = gpu_unai.DrawingOffset[0];
s32 y_off = gpu_unai.DrawingOffset[1];
ptr = &packet.U4[1];
for (int i=0; i < num_verts; ++i, ptr += vert_stride) {
- s16* coord_ptr = (s16*)ptr;
- vbuf[i].x = GPU_EXPANDSIGN(coord_ptr[0]) + x_off;
- vbuf[i].y = GPU_EXPANDSIGN(coord_ptr[1]) + y_off;
+ u32 coords = le32_to_u32(*ptr);
+ vbuf[i].x = GPU_EXPANDSIGN((s16)coords) + x_off;
+ vbuf[i].y = GPU_EXPANDSIGN((s16)(coords >> 16)) + y_off;
}
// U,V texture coords (if applicable)
if (texturing) {
ptr = &packet.U4[2];
for (int i=0; i < num_verts; ++i, ptr += vert_stride)
- vbuf[i].tex_word = *ptr;
+ vbuf[i].tex_word = le32_to_u32(*ptr);
}
// Colors (if applicable)
if (gouraud) {
ptr = &packet.U4[0];
for (int i=0; i < num_verts; ++i, ptr += vert_stride)
- vbuf[i].col_word = *ptr;
+ vbuf[i].col_word = le32_to_u32(*ptr);
}
}
void gpuDrawPolyF(const PtrUnion packet, const PP gpuPolySpanDriver, u32 is_quad)
{
// Set up bgr555 color to be used across calls in inner driver
- gpu_unai.PixelData = GPU_RGB16(packet.U4[0]);
+ gpu_unai.PixelData = GPU_RGB16(le32_to_u32(packet.U4[0]));
PolyVertex vbuf[4];
polyInitVertexBuffer(vbuf, packet, POLYTYPE_F, is_quad);
if (loop1 <= 0)
continue;
- u16* PixelBase = &((u16*)gpu_unai.vram)[FRAME_OFFSET(0, ya)];
+ le16_t* PixelBase = &gpu_unai.vram[FRAME_OFFSET(0, ya)];
int li=gpu_unai.ilace_mask;
int pi=(ProgressiveInterlaceEnabled()?(gpu_unai.ilace_mask+1):0);
int pif=(ProgressiveInterlaceEnabled()?(gpu_unai.prog_ilace_flag?(gpu_unai.ilace_mask+1):0):1);
if (loop1 <= 0)
continue;
- u16* PixelBase = &((u16*)gpu_unai.vram)[FRAME_OFFSET(0, ya)];
+ le16_t* PixelBase = &gpu_unai.vram[FRAME_OFFSET(0, ya)];
int li=gpu_unai.ilace_mask;
int pi=(ProgressiveInterlaceEnabled()?(gpu_unai.ilace_mask+1):0);
int pif=(ProgressiveInterlaceEnabled()?(gpu_unai.prog_ilace_flag?(gpu_unai.ilace_mask+1):0):1);
if (loop1 <= 0)
continue;
- u16* PixelBase = &((u16*)gpu_unai.vram)[FRAME_OFFSET(0, ya)];
+ le16_t* PixelBase = &gpu_unai.vram[FRAME_OFFSET(0, ya)];
int li=gpu_unai.ilace_mask;
int pi=(ProgressiveInterlaceEnabled()?(gpu_unai.ilace_mask+1):0);
int pif=(ProgressiveInterlaceEnabled()?(gpu_unai.prog_ilace_flag?(gpu_unai.ilace_mask+1):0):1);
if (loop1 <= 0)
continue;
- u16* PixelBase = &((u16*)gpu_unai.vram)[FRAME_OFFSET(0, ya)];
+ le16_t* PixelBase = &gpu_unai.vram[FRAME_OFFSET(0, ya)];
int li=gpu_unai.ilace_mask;
int pi=(ProgressiveInterlaceEnabled()?(gpu_unai.ilace_mask+1):0);
int pif=(ProgressiveInterlaceEnabled()?(gpu_unai.prog_ilace_flag?(gpu_unai.ilace_mask+1):0):1);
}
} while (++cur_pass < total_passes);
}
+
+#endif /* __GPU_UNAI_GPU_RASTER_POLYGON_H__ */