INLINE void PS_GPU::DrawSpan(int y, const int32 x_start, const int32 x_bound, i_group ig, const i_deltas &idl) { if(LineSkipTest(y)) return; int32 x_ig_adjust = x_start; int32 w = x_bound - x_start; int32 x = sign_x_to_s32(11, x_start); if(x < ClipX0) { int32 delta = ClipX0 - x; x_ig_adjust += delta; x += delta; w -= delta; } if((x + w) > (ClipX1 + 1)) w = ClipX1 + 1 - x; if(w <= 0) return; //printf("%d %d %d %d\n", x, w, ClipX0, ClipX1); AddIDeltas_DX<goraud, textured>(ig, idl, x_ig_adjust); AddIDeltas_DY<goraud, textured>(ig, idl, y); if(goraud || textured) DrawTimeAvail -= w * 2; else if((BlendMode >= 0) || MaskEval_TA) DrawTimeAvail -= w + ((w + 1) >> 1); else
void PS_GPU::DrawLine(line_point *points) { int32 i_dx; int32 i_dy; int32 k; line_fxp_coord cur_point; line_fxp_step step; i_dx = abs(points[1].x - points[0].x); i_dy = abs(points[1].y - points[0].y); k = (i_dx > i_dy) ? i_dx : i_dy; if(i_dx >= 1024) return; if(i_dy >= 512) return; if(points[0].x >= points[1].x && k) { line_point tmp = points[1]; points[1] = points[0]; points[0] = tmp; } DrawTimeAvail -= k * 2; // // // LinePointsToFXPStep<goraud>(points[0], points[1], k, step); LinePointToFXPCoord<goraud>(points[0], step, cur_point); // // // for(int32 i = 0; i <= k; i++) // <= is not a typo. { // Sign extension is not necessary here for x and y, due to the maximum values that ClipX1 and ClipY1 can contain. const int32 x = (cur_point.x >> Line_XY_FractBits) & 2047; const int32 y = (cur_point.y >> Line_XY_FractBits) & 2047; uint16 pix = 0x8000; if(!LineSkipTest(y)) { uint8 r, g, b; if(goraud) { r = cur_point.r >> Line_RGB_FractBits; g = cur_point.g >> Line_RGB_FractBits; b = cur_point.b >> Line_RGB_FractBits; } else { r = points[0].r; g = points[0].g; b = points[0].b; } if(dtd) { pix |= DitherLUT[y & 3][x & 3][r] << 0; pix |= DitherLUT[y & 3][x & 3][g] << 5; pix |= DitherLUT[y & 3][x & 3][b] << 10; } else { pix |= (r >> 3) << 0; pix |= (g >> 3) << 5; pix |= (b >> 3) << 10; } // FIXME: There has to be a faster way than checking for being inside the drawing area for each pixel. if(x >= ClipX0 && x <= ClipX1 && y >= ClipY0 && y <= ClipY1) PlotPixel<BlendMode, MaskEval_TA, false>(x, y, pix); }