From 1b986d6aea57dd3a243e7635061e750e881d3696 Mon Sep 17 00:00:00 2001 From: Bruce Evans Date: Wed, 12 Apr 2017 20:18:38 +0000 Subject: [PATCH] Improve drawing of the vga planar mode mouse image a little. Unobfuscate the method a lot. Reduce the AND mask to the complement of the cursor's frame, so that area inside the frame is not drawn first in black and then in lightwhite. The AND-OR method is only directly suitable for the text mouse image, since it doesn't go to the hardware there. Planar mode Mouse cursor drawing takes 10-20 usec on my Haswell system (approx. 100 graphics accesses at 130 nsec each), so the transient was not visible. The method used the fancy read mode 1 and its color compare and color don't care registers with value 0 in them so that all colors matched. All that this did was make byte reads of frame buffer memory return 0xff, so that the x86 case could obfuscate read+write as "and". The read must be done for its side effect on the graphics controller but is not used, except it must return 0xff to avoid affecting the write when the write is obfuscated as a read-modify-write "and". Perhaps that was a good optimization for 8088 CPUs where each extra instruction byte took as long as a byte memory access. Just use read+write after removing the fancy read mode. Remove x86 ifdefs that did the "and". After removing the "and" in the non-x86 part of the ifdefs, fix 4 of 6 cases where the shift was wrong. --- sys/dev/syscons/scvgarndr.c | 45 +++++++++++++------------------------ 1 file changed, 15 insertions(+), 30 deletions(-) diff --git a/sys/dev/syscons/scvgarndr.c b/sys/dev/syscons/scvgarndr.c index 50f9a7463dfe..2ec06a514b6c 100644 --- a/sys/dev/syscons/scvgarndr.c +++ b/sys/dev/syscons/scvgarndr.c @@ -1038,34 +1038,26 @@ draw_pxlmouse_planar(scr_stat *scp, int x, int y) yoff = y - rounddown(y, line_width); ymax = imin(y + 16, scp->ypixel); - outw(GDCIDX, 0x0805); /* read mode 1, write mode 0 */ + outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */ outw(GDCIDX, 0x0001); /* set/reset enable */ - outw(GDCIDX, 0x0002); /* color compare */ - outw(GDCIDX, 0x0007); /* color don't care */ outw(GDCIDX, 0xff08); /* bit mask */ outw(GDCIDX, 0x0803); /* data rotate/function select (and) */ p = scp->sc->adp->va_window + line_width*y + x/8; if (x < scp->xpixel - 8) { for (i = y, j = 0; i < ymax; ++i, ++j) { - m = ~(mouse_and_mask[j] >> xoff); -#if defined(__i386__) || defined(__amd64__) - *(u_char *)p &= m >> 8; - *(u_char *)(p + 1) &= m; -#else - writeb(p, readb(p) & (m >> 8)); - writeb(p + 1, readb(p + 1) & (m >> 8)); -#endif + m = ~((mouse_and_mask[j] & ~mouse_or_mask[j]) >> xoff); + readb(p); + writeb(p, m >> 8); + readb(p + 1); + writeb(p + 1, m); p += line_width; } } else { xoff += 8; for (i = y, j = 0; i < ymax; ++i, ++j) { - m = ~(mouse_and_mask[j] >> xoff); -#if defined(__i386__) || defined(__amd64__) - *(u_char *)p &= m; -#else - writeb(p, readb(p) & (m >> 8)); -#endif + m = ~((mouse_and_mask[j] & ~mouse_or_mask[j]) >> xoff); + readb(p); + writeb(p, m); p += line_width; } } @@ -1074,27 +1066,20 @@ draw_pxlmouse_planar(scr_stat *scp, int x, int y) if (x < scp->xpixel - 8) { for (i = y, j = 0; i < ymax; ++i, ++j) { m = mouse_or_mask[j] >> xoff; -#if defined(__i386__) || defined(__amd64__) - *(u_char *)p &= m >> 8; - *(u_char *)(p + 1) &= m; -#else - writeb(p, readb(p) & (m >> 8)); - writeb(p + 1, readb(p + 1) & (m >> 8)); -#endif + readb(p); + writeb(p, m >> 8); + readb(p + 1); + writeb(p + 1, m); p += line_width; } } else { for (i = y, j = 0; i < ymax; ++i, ++j) { m = mouse_or_mask[j] >> xoff; -#if defined(__i386__) || defined(__amd64__) - *(u_char *)p &= m; -#else - writeb(p, readb(p) & (m >> 8)); -#endif + readb(p); + writeb(p, m); p += line_width; } } - outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */ outw(GDCIDX, 0x0003); /* data rotate/function select */ }