Fix removal of the keyboard cursor image in text mode, especially

in the vga renderer.  Removal used stale attributes and didn't try to
merge with the current attribute for cut marking, so special rendering
of cut marking was lost in many cases.  The gfb renderer is too broken
to support special rendering of cut marking at all, so this change is
supposed to be just a style fix for it.  Remove all traces of the
saveunder method which was used to implement this bug.

Fix drawing of the cursor image in text mode, only in the vga
renderer.  This used a stale attribute from the frame buffer instead
of from the saveunder, but did merge with the current attribute for
cut marking so it caused less obvious bugs (subtle misrendering for
the character under the cursor).

The saveunder method may be good in simpler drivers, but in syscons
the 'under' is already saved in a better way in the vtb.  Just redraw
it from there, with visible complications for cut marking and
invisible complications for mouse cursors.  Almost all drawing
requests are passed a flag 'flip' which currently means to flip to
reverse video for characters in the cut marking region, but should
mean that the the characters are in the cut marking regions so should
be rendered specially, preferably using something better than reverse
video.  The gfb renderer always ignores this flag.  The vga renderer
ignored it for removal of the text cursor -- the saveunder gave the
stale rendering at the time the cursor was drawn.  Mouse cursors need
even more complicated methods.  They are handled by drawing them last
and removing them first.  Removing them usually redraws many other
characters with the correct cut marking (but transiently loses the
keyboard cursor, which is redrawn soon).  This tended to hide the
saveunder bug for forward motions of the keyboard cursor.  But slow
backward motions of the keyboard cursor always lost the cut marking,
and fast backwards motions lost in for about 4 in every 5 characters,
depending on races with the scrn_update() timeout handler.  This is
because the forward motions are usually into the region redrawn for
the mouse cursor, while backwards motions rarely are.

Text cursor drawing in the vga renderer used also used a
possibly-stale copy of the character and its attribute.  The vga
render has the "optimization" of sometimes reading characters from the
screen instead of from the vtb (this was not so good even in 1990 when
main memory was only a few times faster than video RAM).  Due to care
in update orders, the character is never stale, but its attribute
might be (just the cut marking part, again due to care in order).

gfb doesn't have the scp->scr pointer used for the "optimization", and
vga only uses this pointer for text mode.  So most cases have to
refresh from the vtb, and we can be sure that the ordering of vtb
updates and drawing is as required for this to work.
This commit is contained in:
Bruce Evans 2017-04-08 08:24:25 +00:00
parent 7250d89e54
commit e53fbbe661
3 changed files with 6 additions and 12 deletions

View File

@ -271,13 +271,11 @@ gfb_cursor(scr_stat *scp, int at, int blink, int on, int flip)
c = sc_vtb_getc(&scp->vtb, at);
vidd_putc(scp->sc->adp, at, c,
(a >> 4) | ((a & 0xf) << 4));
scp->cursor_saveunder_attr = a;
scp->cursor_saveunder_char = c;
} else {
if (scp->status & VR_CURSOR_ON)
vidd_putc(scp->sc->adp, at,
scp->cursor_saveunder_char,
scp->cursor_saveunder_attr);
sc_vtb_getc(&scp->vtb, at),
sc_vtb_geta(&scp->vtb, at) >> 8);
scp->status &= ~VR_CURSOR_ON;
}
}

View File

@ -294,8 +294,6 @@ draw_txtcharcursor(scr_stat *scp, int at, u_short c, u_short a, int flip)
sc_softc_t *sc;
sc = scp->sc;
scp->cursor_saveunder_char = c;
scp->cursor_saveunder_attr = a;
#ifndef SC_NO_FONT_LOADING
if (scp->curs_attr.flags & CONS_CHAR_CURSOR) {
@ -372,18 +370,18 @@ vga_txtcursor(scr_stat *scp, int at, int blink, int on, int flip)
if (on) {
scp->status |= VR_CURSOR_ON;
draw_txtcharcursor(scp, at,
sc_vtb_getc(&scp->scr, at),
sc_vtb_geta(&scp->scr, at),
sc_vtb_getc(&scp->vtb, at),
sc_vtb_geta(&scp->vtb, at),
flip);
} else {
cursor_attr = scp->cursor_saveunder_attr;
cursor_attr = sc_vtb_geta(&scp->vtb, at);
if (flip)
cursor_attr = (cursor_attr & 0x8800)
| ((cursor_attr & 0x7000) >> 4)
| ((cursor_attr & 0x0700) << 4);
if (scp->status & VR_CURSOR_ON)
sc_vtb_putc(&scp->scr, at,
scp->cursor_saveunder_char,
sc_vtb_getc(&scp->vtb, at),
cursor_attr);
scp->status &= ~VR_CURSOR_ON;
}

View File

@ -312,8 +312,6 @@ typedef struct scr_stat {
int cursor_pos; /* cursor buffer position */
int cursor_oldpos; /* cursor old buffer position */
u_short cursor_saveunder_char; /* saved char under cursor */
u_short cursor_saveunder_attr; /* saved attr under cursor */
struct cursor_attr dflt_curs_attr;
struct cursor_attr curr_curs_attr;
struct cursor_attr curs_attr;