X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=plugins%2Fgpu_unai%2Fgpu_raster_line.h;h=a338f974e5dc5aba6e5006cb1c236fe8973e2f67;hb=0e4366b6f4f0b4077970334f25bec9e00efe16a7;hp=28ea074ed6b3c896b562fa92e2464d198e37e66c;hpb=28d1bea2e828cd079593abc8c97ea6ff4fd7d4f4;p=pcsx_rearmed.git diff --git a/plugins/gpu_unai/gpu_raster_line.h b/plugins/gpu_unai/gpu_raster_line.h index 28ea074e..a338f974 100644 --- a/plugins/gpu_unai/gpu_raster_line.h +++ b/plugins/gpu_unai/gpu_raster_line.h @@ -19,6 +19,9 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. * ***************************************************************************/ +#ifndef __GPU_UNAI_GPU_RASTER_LINE_H__ +#define __GPU_UNAI_GPU_RASTER_LINE_H__ + /////////////////////////////////////////////////////////////////////////////// // GPU internal line drawing functions // @@ -71,10 +74,10 @@ void gpuDrawLineF(PtrUnion packet, const PSD gpuPixelSpanDriver) const int xmax = gpu_unai.DrawingArea[2] - 1; const int ymax = gpu_unai.DrawingArea[3] - 1; - x0 = GPU_EXPANDSIGN(packet.S2[2]) + gpu_unai.DrawingOffset[0]; - y0 = GPU_EXPANDSIGN(packet.S2[3]) + gpu_unai.DrawingOffset[1]; - x1 = GPU_EXPANDSIGN(packet.S2[4]) + gpu_unai.DrawingOffset[0]; - y1 = GPU_EXPANDSIGN(packet.S2[5]) + gpu_unai.DrawingOffset[1]; + 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]; + x1 = GPU_EXPANDSIGN(le16_to_s16(packet.U2[4])) + gpu_unai.DrawingOffset[0]; + y1 = GPU_EXPANDSIGN(le16_to_s16(packet.U2[5])) + gpu_unai.DrawingOffset[1]; // Always draw top to bottom, so ensure y0 <= y1 if (y0 > y1) { @@ -174,12 +177,9 @@ void gpuDrawLineF(PtrUnion packet, const PSD gpuPixelSpanDriver) err_adjdown; // Subract this from err_term after drawing longer run // Color to draw with (16 bits, highest of which is unset mask bit) - uintptr_t col16 = GPU_RGB16(packet.U4[0]); + uintptr_t col16 = GPU_RGB16(le32_to_u32(packet.U4[0])); - // We use u8 pointers even though PS1 has u16 framebuffer. - // This allows pixel-drawing functions to increment dst pointer - // directly by the passed 'incr' value, not having to shift it first. - u8 *dst = (u8*)gpu_unai.vram + y0 * dst_stride + x0 * dst_depth; + le16_t *dst = gpu_unai.vram + (y0 * dst_stride + x0 * dst_depth) / FRAME_BYTES_PER_PIXEL; // SPECIAL CASE: Vertical line if (dx == 0) { @@ -275,7 +275,7 @@ void gpuDrawLineF(PtrUnion packet, const PSD gpuPixelSpanDriver) // First run of pixels dst = gpuPixelSpanDriver(dst, col16, incr_major, start_length); - dst += incr_minor; + dst += incr_minor / 2; // Middle runs of pixels while (--minor > 0) { @@ -289,7 +289,7 @@ void gpuDrawLineF(PtrUnion packet, const PSD gpuPixelSpanDriver) } dst = gpuPixelSpanDriver(dst, col16, incr_major, run_length); - dst += incr_minor; + dst += incr_minor / 2; } // Final run of pixels @@ -318,13 +318,13 @@ void gpuDrawLineG(PtrUnion packet, const PSD gpuPixelSpanDriver) const int xmax = gpu_unai.DrawingArea[2] - 1; const int ymax = gpu_unai.DrawingArea[3] - 1; - x0 = GPU_EXPANDSIGN(packet.S2[2]) + gpu_unai.DrawingOffset[0]; - y0 = GPU_EXPANDSIGN(packet.S2[3]) + gpu_unai.DrawingOffset[1]; - x1 = GPU_EXPANDSIGN(packet.S2[6]) + gpu_unai.DrawingOffset[0]; - y1 = GPU_EXPANDSIGN(packet.S2[7]) + gpu_unai.DrawingOffset[1]; + 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]; + x1 = GPU_EXPANDSIGN(le16_to_s16(packet.U2[6])) + gpu_unai.DrawingOffset[0]; + y1 = GPU_EXPANDSIGN(le16_to_s16(packet.U2[7])) + gpu_unai.DrawingOffset[1]; - u32 col0 = packet.U4[0]; - u32 col1 = packet.U4[2]; + u32 col0 = le32_to_u32(packet.U4[0]); + u32 col1 = le32_to_u32(packet.U4[2]); // Always draw top to bottom, so ensure y0 <= y1 if (y0 > y1) { @@ -516,10 +516,7 @@ void gpuDrawLineG(PtrUnion packet, const PSD gpuPixelSpanDriver) gcol.g = g0 << GPU_GOURAUD_FIXED_BITS; gcol.b = b0 << GPU_GOURAUD_FIXED_BITS; - // We use u8 pointers even though PS1 has u16 framebuffer. - // This allows pixel-drawing functions to increment dst pointer - // directly by the passed 'incr' value, not having to shift it first. - u8 *dst = (u8*)gpu_unai.vram + y0 * dst_stride + x0 * dst_depth; + le16_t *dst = gpu_unai.vram + (y0 * dst_stride + x0 * dst_depth) / FRAME_BYTES_PER_PIXEL; // SPECIAL CASE: Vertical line if (dx == 0) { @@ -544,7 +541,7 @@ void gpuDrawLineG(PtrUnion packet, const PSD gpuPixelSpanDriver) if (db) gcol.b_incr /= dy; } #endif - + gpuPixelSpanDriver(dst, (uintptr_t)&gcol, dst_stride, dy+1); return; } @@ -693,7 +690,7 @@ void gpuDrawLineG(PtrUnion packet, const PSD gpuPixelSpanDriver) // First run of pixels dst = gpuPixelSpanDriver(dst, (uintptr_t)&gcol, incr_major, start_length); - dst += incr_minor; + dst += incr_minor / 2; // Middle runs of pixels while (--minor > 0) { @@ -707,9 +704,11 @@ void gpuDrawLineG(PtrUnion packet, const PSD gpuPixelSpanDriver) } dst = gpuPixelSpanDriver(dst, (uintptr_t)&gcol, incr_major, run_length); - dst += incr_minor; + dst += incr_minor / 2; } // Final run of pixels gpuPixelSpanDriver(dst, (uintptr_t)&gcol, incr_major, end_length); } + +#endif /* __GPU_UNAI_GPU_RASTER_LINE_H__ */