diff --git a/src/blitter/common.hpp b/src/blitter/common.hpp index 6b36feb980..0347aa8002 100644 --- a/src/blitter/common.hpp +++ b/src/blitter/common.hpp @@ -90,13 +90,14 @@ void Blitter::DrawLineGeneric(int x1, int y1, int x2, int y2, int screen_width, if (x1 < 0) { dash_count = (-x1) % (dash + gap); auto adjust_frac = [&](int64_t frac, int &y_bound) -> int { - frac -= ((int64_t) dy) * ((int64_t) x1); + frac -= ((int64_t) dy) * ((int64_t) (x1 + 1)); if (frac >= 0) { int quotient = frac / dx; int remainder = frac % dx; y_bound += (1 + quotient) * stepy; frac = remainder - dx; } + frac += dy; return frac; }; frac_low = adjust_frac(frac_low, y_low); @@ -152,13 +153,14 @@ void Blitter::DrawLineGeneric(int x1, int y1, int x2, int y2, int screen_width, if (y1 < 0) { dash_count = (-y1) % (dash + gap); auto adjust_frac = [&](int64_t frac, int &x_bound) -> int { - frac -= ((int64_t) dx) * ((int64_t) y1); + frac -= ((int64_t) dx) * ((int64_t) (y1 + 1)); if (frac >= 0) { int quotient = frac / dy; int remainder = frac % dy; x_bound += (1 + quotient) * stepx; frac = remainder - dy; } + frac += dx; return frac; }; frac_low = adjust_frac(frac_low, x_low);