diff --git a/ubb-la/gui.c b/ubb-la/gui.c index 0c0f3f7..9b235a6 100644 --- a/ubb-la/gui.c +++ b/ubb-la/gui.c @@ -159,13 +159,14 @@ static void show_buffer(const uint8_t *buf, int skip, int nibbles, int x0, int x1, int zoom, int pos) { int xm, w, p0, p1; - int d; + int d, dp; xm = (x0+x1) >> 1; + dp = pos-((nibbles+skip) >> 1); if (zoom < 0) { w = (nibbles-skip) >> -zoom; - p0 = xm-(w >> 1); - p1 = xm+((w+1) >> 1); + p0 = xm-(w >> 1)-(dp >> -zoom); + p1 = xm+((w+1) >> 1)-(dp >> -zoom); if (p0 < x0) { skip += (x0-p0) << -zoom; p0 = x0; @@ -177,8 +178,8 @@ static void show_buffer(const uint8_t *buf, int skip, int nibbles, show_buffer_zoom_out(buf, skip, nibbles, p0, p1); } else { w = (nibbles-skip) << zoom; - p0 = xm-(w >> 1); - p1 = xm+((w+1) >> 1); + p0 = xm-(w >> 1)-(dp << zoom); + p1 = xm+((w+1) >> 1)-(dp << zoom); if (p0 < x0) { d = ((x0-p0)+(1 << zoom)-1) >> zoom; skip += d; @@ -229,6 +230,14 @@ void gui(const uint8_t *buf, int skip, int nibbles) if (zoom > min_zoom) zoom--; break; + case SDLK_LEFT: + if (pos) + pos--; + break; + case SDLK_RIGHT: + if (pos < nibbles-1) + pos++; + break; case SDLK_RETURN: case SDLK_q: return;