From f26fd3564a2664fe3deea5b86bd46e8dad8209ac Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Thu, 31 Jan 2013 04:03:31 -0300 Subject: [PATCH] ubb-la/gui.c (show_map): keep view rectangle size constant Before, we had rounding effects that could make the rectangle width vary by one pixel, depending on position. --- ubb-la/gui.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ubb-la/gui.c b/ubb-la/gui.c index dc6e2a4..0743e97 100644 --- a/ubb-la/gui.c +++ b/ubb-la/gui.c @@ -177,6 +177,7 @@ static void show_map(int skip, int nibbles, int s0, int s1) int w = nibbles-skip; int m = (nibbles+skip) >> 1; int scale = 0; + int x0, x1; while (w >= XWIDTH/2) { w >>= 1; @@ -184,8 +185,9 @@ static void show_map(int skip, int nibbles, int s0, int s1) } boxColor(surf, XCENTER-(w >> 1), MAP_BUF_Y0, XCENTER+(w >> 1), MAP_BUF_Y1, MAP_BUF_RGBA); - rectangleColor(surf, (s0-m+(XCENTER << scale)) >> scale, MAP_VIEW_Y0, - (s1-m+(XCENTER << scale)) >> scale, MAP_VIEW_Y1, MAP_VIEW_RGBA); + x0 = (s0-m+(XCENTER << scale)) >> scale; + x1 = x0+((s1-s0) >> scale); + rectangleColor(surf, x0, MAP_VIEW_Y0, x1, MAP_VIEW_Y1, MAP_VIEW_RGBA); }