Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 23 Apr 2017 08:59:36 +0000 (UTC)
From:      Bruce Evans <bde@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r317334 - head/sys/dev/syscons
Message-ID:  <201704230859.v3N8xaJW080443@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bde
Date: Sun Apr 23 08:59:35 2017
New Revision: 317334
URL: https://svnweb.freebsd.org/changeset/base/317334

Log:
  Change the drawing method for the mouse cursor in planar mode to support
  colors.
  
  Colors are still hard-coded as 15 (normally lightwhite) for the interior
  and 0 (normally black) for the border, but these are now values used in
  2 expressions instead of built in to the algorithm.  The algorithm used
  a fancy and/or method, but this gives no control over the colors except
  and'ing all color planes off gives black and or'ing all color planes on
  gives lightwhite.  Just draw the border and interior in separate colors
  using the same method as for characters, including its complications to
  optimize for VGA adaptors.  Optimization is not really needed here, but
  for the VGA case it avoids being slower than the and/or method.  The
  optimization is worth about 30%.

Modified:
  head/sys/dev/syscons/scvgarndr.c

Modified: head/sys/dev/syscons/scvgarndr.c
==============================================================================
--- head/sys/dev/syscons/scvgarndr.c	Sun Apr 23 08:58:50 2017	(r317333)
+++ head/sys/dev/syscons/scvgarndr.c	Sun Apr 23 08:59:35 2017	(r317334)
@@ -1009,23 +1009,34 @@ draw_pxlmouse_planar(scr_stat *scp, int 
 	yoff = y - rounddown(y, line_width);
 	ymax = imin(y + mdp->md_height, scp->ypixel);
 
-	outw(GDCIDX, 0x0005);		/* read mode 0, write mode 0 */
-	outw(GDCIDX, 0x0001);		/* set/reset enable */
-	outw(GDCIDX, 0xff08);		/* bit mask */
-	outw(GDCIDX, 0x0803);		/* data rotate/function select (and) */
+	if (scp->sc->adp->va_type == KD_VGA) {
+		outw(GDCIDX, 0x0305);	/* read mode 0, write mode 3 */
+		outw(GDCIDX, 0xff08);	/* bit mask */
+	} else
+		outw(GDCIDX, 0x0005);	/* read mode 0, write mode 0 */
+	outw(GDCIDX, 0x0003);		/* data rotate/function select */
+	outw(GDCIDX, 0x0f01);		/* set/reset enable */
+
+	outw(GDCIDX, (0 << 8) | 0x00); /* set/reset */
 	p = scp->sc->adp->va_window + line_width*y + x/8;
 	for (i = y, j = 0; i < ymax; ++i, ++j) {
-		m = ~(mdp->md_border[j] << 8 >> xoff);
+		m = mdp->md_border[j] << 8 >> xoff;
 		for (k = 0; k < 3; ++k) {
 			m1 = m >> (8 * (2 - k));
-			if (m1 != 0xff && x + 8 * k < scp->xpixel) {
+			if (m1 != 0 && x + 8 * k < scp->xpixel) {
 				readb(p + k);
-				writeb(p + k, m1);
- 			}
+				if (scp->sc->adp->va_type == KD_VGA)
+					writeb(p + k, m1);
+				else {
+					/* bit mask: */
+					outw(GDCIDX, (m1 << 8) | 0x08);
+					writeb(p + k, 0);
+				}
+			}
 		}
 		p += line_width;
 	}
-	outw(GDCIDX, 0x1003);		/* data rotate/function select (or) */
+	outw(GDCIDX, (15 << 8) | 0x00); /* set/reset */
 	p = scp->sc->adp->va_window + line_width*y + x/8;
 	for (i = y, j = 0; i < ymax; ++i, ++j) {
 		m = mdp->md_interior[j] << 8 >> xoff;
@@ -1033,12 +1044,23 @@ draw_pxlmouse_planar(scr_stat *scp, int 
 			m1 = m >> (8 * (2 - k));
 			if (m1 != 0 && x + 8 * k < scp->xpixel) {
 				readb(p + k);
-				writeb(p + k, m1);
+				if (scp->sc->adp->va_type == KD_VGA)
+					writeb(p + k, m1);
+				else {
+					/* bit mask: */
+					outw(GDCIDX, (m1 << 8) | 0x08);
+					writeb(p + k, 0);
+				}
 			}
 		}
 		p += line_width;
 	}
-	outw(GDCIDX, 0x0003);		/* data rotate/function select */
+	if (scp->sc->adp->va_type == KD_VGA)
+		outw(GDCIDX, 0x0005);	/* read mode 0, write mode 0 */
+	else
+		outw(GDCIDX, 0xff08);	/* bit mask */
+	outw(GDCIDX, 0x0000);		/* set/reset */
+	outw(GDCIDX, 0x0001);		/* set/reset enable */
 }
 
 static void



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201704230859.v3N8xaJW080443>