loader: FB console does leave garbage on screen while scrolling

Scrolling screen will leave "trail" of chars from first column.
Apparently caused by cursor location mismanagement.
Make sure we do not [attempt to] set cursor out of the screen.

MFC after:	1 week
This commit is contained in:
Toomas Soome 2021-08-21 14:25:36 +03:00
parent f3dcedd3de
commit e5a50b0329

View File

@ -976,20 +976,26 @@ gfx_fb_fill(void *arg, const teken_rect_t *r, teken_char_t c,
}
static void
gfx_fb_cursor_draw(teken_gfx_t *state, const teken_pos_t *p, bool on)
gfx_fb_cursor_draw(teken_gfx_t *state, const teken_pos_t *pos, bool on)
{
unsigned x, y, width, height;
const uint8_t *glyph;
teken_pos_t p;
int idx;
idx = p->tp_col + p->tp_row * state->tg_tp.tp_col;
p = *pos;
if (p.tp_col >= state->tg_tp.tp_col)
p.tp_col = state->tg_tp.tp_col - 1;
if (p.tp_row >= state->tg_tp.tp_row)
p.tp_row = state->tg_tp.tp_row - 1;
idx = p.tp_col + p.tp_row * state->tg_tp.tp_col;
if (idx >= state->tg_tp.tp_col * state->tg_tp.tp_row)
return;
width = state->tg_font.vf_width;
height = state->tg_font.vf_height;
x = state->tg_origin.tp_col + p->tp_col * width;
y = state->tg_origin.tp_row + p->tp_row * height;
x = state->tg_origin.tp_col + p.tp_col * width;
y = state->tg_origin.tp_row + p.tp_row * height;
/*
* Save original display content to preserve image data.
@ -1017,7 +1023,7 @@ gfx_fb_cursor_draw(teken_gfx_t *state, const teken_pos_t *p, bool on)
if (state->tg_cursor_image != NULL &&
gfxfb_blt(state->tg_cursor_image, GfxFbBltBufferToVideo,
0, 0, x, y, width, height, 0) == 0) {
state->tg_cursor = *p;
state->tg_cursor = p;
return;
}
}
@ -1025,9 +1031,9 @@ gfx_fb_cursor_draw(teken_gfx_t *state, const teken_pos_t *p, bool on)
glyph = font_lookup(&state->tg_font, screen_buffer[idx].c,
&screen_buffer[idx].a);
gfx_bitblt_bitmap(state, glyph, &screen_buffer[idx].a, 0xff, on);
gfx_fb_printchar(state, p);
gfx_fb_printchar(state, &p);
state->tg_cursor = *p;
state->tg_cursor = p;
}
void