From 4a690a4a5268847c24e8edb08ba558a36bbd6d3c Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Mon, 3 Jul 2023 13:10:15 +0300 Subject: [PATCH] fixed some UI glitches --- src/dos/drv_vbe.c | 2 +- src/dos/main.c | 44 ++++++++++++++++++++------------------------ src/scr_mod.c | 3 +-- 3 files changed, 22 insertions(+), 27 deletions(-) diff --git a/src/dos/drv_vbe.c b/src/dos/drv_vbe.c index 093d03c..ae36be8 100644 --- a/src/dos/drv_vbe.c +++ b/src/dos/drv_vbe.c @@ -375,7 +375,7 @@ static void blit_lfb(int x, int y, int w, int h, void *fb, int pitch) int i, pixsz, spansz; unsigned char *dest, *src; - dbgmsg("blit: %d,%d (%dx%d)\n", x, y, w, h); + /*dbgmsg("blit: %d,%d (%dx%d)\n", x, y, w, h);*/ pixsz = (cur_mi->bpp + 7) >> 3; spansz = w * pixsz; diff --git a/src/dos/main.c b/src/dos/main.c index e6e2346..e7aae2c 100644 --- a/src/dos/main.c +++ b/src/dos/main.c @@ -39,11 +39,12 @@ static INLINE int clamp(int x, int a, int b) } static void draw_cursor(int x, int y); +static void draw_rband(rtk_rect *r); static uint32_t *vmem; -static int quit, disp_pending, dirty_valid; +static int quit, dirty_valid; static rtk_rect dirty; -static int mx, my; +static int mx, my, prev_mx, prev_my; static rtk_rect rband, prev_rband; @@ -51,7 +52,7 @@ int main(int argc, char **argv) { int i; int vmidx; - int mdx, mdy, prev_mx, prev_my, bnstate, bndiff; + int mdx, mdy, bnstate, bndiff; static int prev_bnstate; char *env; @@ -104,6 +105,7 @@ int main(int argc, char **argv) app_reshape(win_width, win_height); mx = win_width / 2; my = win_height / 2; + prev_mx = prev_my = -1; for(;;) { int key; @@ -133,8 +135,6 @@ int main(int argc, char **argv) prev_bnstate = bnstate; read_mouse_rel(&mdx, &mdy); - prev_mx = mx; - prev_my = my; mx = clamp(mx + mdx, 0, win_width - 1); my = clamp(my + mdy, 0, win_height - 1); mdx = mx - prev_mx; @@ -148,15 +148,8 @@ int main(int argc, char **argv) app_motion(mx, my); } - if(disp_pending) { - disp_pending = 0; - app_display(); - } - + app_display(); app_swap_buffers(); - - draw_cursor(prev_mx, prev_my); - draw_cursor(mx, my); } break_evloop: @@ -191,7 +184,6 @@ void app_redisplay(int x, int y, int w, int h) } else { dirty = r; } - disp_pending = 1; dirty_valid = 1; } @@ -204,24 +196,25 @@ void app_swap_buffers(void) if(dirty.width < win_width || dirty.height < win_height) { uint32_t *src = framebuf + dirty.y * win_width + dirty.x; vid_blit32(dirty.x, dirty.y, dirty.width, dirty.height, src, 0); - - if(mx >= dirty.x && my >= dirty.y && mx < dirty.x + dirty.width && my < dirty.y + dirty.height) { - draw_cursor(mx, my); - } } else { vid_blitfb32(framebuf, 0); - draw_cursor(mx, my); } dirty_valid = 0; } + if(prev_mx >= 0) { + draw_cursor(prev_mx, prev_my); + } + draw_cursor(mx, my); + prev_mx = mx; + prev_my = my; + if(prev_rband.width) { + draw_rband(&prev_rband); + } if(rband.width) { - if(prev_rband.width) { - draw_rband(&prev_rband); - } draw_rband(&rband); - prev_rband = rband; } + prev_rband = rband; } void app_quit(void) @@ -245,7 +238,6 @@ void app_rband(int x, int y, int w, int h) { if(!(w | h)) { w = h = 0; - prev_rband.width = 0; } rband.x = x; @@ -277,6 +269,10 @@ static void draw_rband(rtk_rect *r) rect = *r; rtk_fix_rect(&rect); + if(rect.width <= 0 || rect.height <= 0) { + return; + } + fbptr = vmem + rect.y * win_width + rect.x; bptr = fbptr + win_width * (rect.height - 1); diff --git a/src/scr_mod.c b/src/scr_mod.c index ae6de9b..efa4cb0 100644 --- a/src/scr_mod.c +++ b/src/scr_mod.c @@ -90,7 +90,6 @@ static void act_settool(int tidx); static void act_addobj(void); static void act_rmobj(void); -static void draw_rband(void); static void moveobj(struct object *obj, int px0, int py0, int px1, int py1); static void inval_vport(void); @@ -397,8 +396,8 @@ static void mdl_mouse(int bn, int press, int x, int y) rtk_fix_rect(&rband); rendrect = rband; rend_begin(rband.x, rband.y, rband.width, rband.height); + app_redisplay(rband.x, rband.y, rband.width, rband.height); } - app_redisplay(rband.x, rband.y, rband.width, rband.height); } else if(bn == 0 && x == rband.x && y == rband.y) { primray(&pickray, x, y); -- 1.7.10.4