Module Name:    src
Committed By:   macallan
Date:           Tue May  4 05:10:25 UTC 2010

Modified Files:
        src/sys/dev/sbus: p9100.c tcx.c zx.c

Log Message:
use box drawing font if needed


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sys/dev/sbus/p9100.c
cvs rdiff -u -r1.42 -r1.43 src/sys/dev/sbus/tcx.c
cvs rdiff -u -r1.35 -r1.36 src/sys/dev/sbus/zx.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/sbus/p9100.c
diff -u src/sys/dev/sbus/p9100.c:1.54 src/sys/dev/sbus/p9100.c:1.55
--- src/sys/dev/sbus/p9100.c:1.54	Mon Mar  1 05:42:08 2010
+++ src/sys/dev/sbus/p9100.c	Tue May  4 05:10:25 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: p9100.c,v 1.54 2010/03/01 05:42:08 macallan Exp $ */
+/*	$NetBSD: p9100.c,v 1.55 2010/05/04 05:10:25 macallan Exp $ */
 
 /*-
  * Copyright (c) 1998, 2005, 2006 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: p9100.c,v 1.54 2010/03/01 05:42:08 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: p9100.c,v 1.55 2010/05/04 05:10:25 macallan Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1085,6 +1085,7 @@
 p9100_putchar(void *cookie, int row, int col, u_int c, long attr)
 {
 	struct rasops_info *ri = cookie;
+	struct wsdisplay_font *font = PICK_FONT(ri, c);
 	struct vcons_screen *scr = ri->ri_hw;
 	struct p9100_softc *sc = scr->scr_cookie;
 
@@ -1092,10 +1093,10 @@
 	uint8_t *data;
 	int x, y, wi, he;
 
-	wi = ri->ri_font->fontwidth;
-	he = ri->ri_font->fontheight;
+	wi = font->fontwidth;
+	he = font->fontheight;
 
-	if (!CHAR_IN_FONT(c, ri->ri_font))
+	if (!CHAR_IN_FONT(c, font))
 		return;
 
 	bg = (u_char)ri->ri_devcmap[(attr >> 16) & 0xff];
@@ -1106,15 +1107,15 @@
 	if (c == 0x20) {
 		p9100_rectfill(sc, x, y, wi, he, bg);
 	} else {
-		uc = c-ri->ri_font->firstchar;
-		data = (uint8_t *)ri->ri_font->data + uc *
+		uc = c - font->firstchar;
+		data = (uint8_t *)font->data + uc *
 		    ri->ri_fontscale;
 
 		p9100_setup_mono(sc, x, y, wi, 1, fg, bg);
 		for (i = 0; i < he; i++) {
-			p9100_feed_line(sc, ri->ri_font->stride,
+			p9100_feed_line(sc, font->stride,
 			    data);
-			data += ri->ri_font->stride;
+			data += font->stride;
 		}
 	}
 }

Index: src/sys/dev/sbus/tcx.c
diff -u src/sys/dev/sbus/tcx.c:1.42 src/sys/dev/sbus/tcx.c:1.43
--- src/sys/dev/sbus/tcx.c:1.42	Thu Sep 17 16:39:48 2009
+++ src/sys/dev/sbus/tcx.c	Tue May  4 05:10:25 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcx.c,v 1.42 2009/09/17 16:39:48 tsutsui Exp $ */
+/*	$NetBSD: tcx.c,v 1.43 2010/05/04 05:10:25 macallan Exp $ */
 
 /*
  *  Copyright (c) 1996, 1998, 2009 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tcx.c,v 1.42 2009/09/17 16:39:48 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcx.c,v 1.43 2010/05/04 05:10:25 macallan Exp $");
 
 /*
  * define for cg8 emulation on S24 (24-bit version of tcx) for the SS5;
@@ -931,6 +931,7 @@
 tcx_putchar(void *cookie, int row, int col, u_int c, long attr)
 {
 	struct rasops_info *ri = cookie;
+	struct wsdisplay_font *font = PICK_FONT(ri, c);
 	struct vcons_screen *scr = ri->ri_hw;
 	struct tcx_softc *sc = scr->scr_cookie;
 	uint64_t bg, fg, temp, mask;
@@ -939,18 +940,17 @@
 	uint8_t *cdata;
 	uint16_t *wdata;
 
-	addr = ri->ri_xorigin +
-	    col * ri->ri_font->fontwidth +
-	    (ri->ri_yorigin + row * ri->ri_font->fontheight) * ri->ri_width;
+	addr = ri->ri_xorigin + col * font->fontwidth +
+	    (ri->ri_yorigin + row * font->fontheight) * ri->ri_width;
 
 	/* check if the character is crossing a 32 pixel boundary */
 	if ((addr & 0xffffe0) ==
-	    ((addr + ri->ri_font->fontwidth - 1) & 0xffffe0)) {
+	    ((addr + font->fontwidth - 1) & 0xffffe0)) {
 		/* phew, not split */
 		shift = addr & 0x1f;
 		addr &= 0xffffe0;
-		fmask = 0xffffffff >> (32 - ri->ri_font->fontwidth);
-		fmask = fmask << (32 - ri->ri_font->fontwidth - shift);
+		fmask = 0xffffffff >> (32 - font->fontwidth);
+		fmask = fmask << (32 - font->fontwidth - shift);
 		mask = fmask;
 		bg = 0x3000000000000000LL |
 		    ((uint64_t)ri->ri_devcmap[(attr >> 16) & 0xff] &
@@ -959,12 +959,12 @@
 		temp = 0x3000000000000000LL |
 		    ((uint64_t)ri->ri_devcmap[(attr >> 24) & 0xff] & 0xff) << 
 		    	32;
-		uc = c - ri->ri_font->firstchar;
-		cdata = (uint8_t *)ri->ri_font->data + uc * ri->ri_fontscale;
+		uc = c - font->firstchar;
+		cdata = (uint8_t *)font->data + uc * ri->ri_fontscale;
 
-		if (ri->ri_font->fontwidth < 9) {
+		if (font->fontwidth < 9) {
 			/* byte by byte */
-			for (i = 0; i < ri->ri_font->fontheight; i++) {
+			for (i = 0; i < font->fontheight; i++) {
 				sc->sc_rstip[addr] = bg;
 				if (*cdata != 0) {
 					if (shift > 24) {
@@ -979,10 +979,10 @@
 				cdata++;
 				addr += ri->ri_width;
 			}
-		} else if (ri->ri_font->fontwidth < 17) {
+		} else if (font->fontwidth < 17) {
 			/* short by short */
 			wdata = (uint16_t *)cdata;
-			for (i = 0; i < ri->ri_font->fontheight; i++) {
+			for (i = 0; i < font->fontheight; i++) {
 				sc->sc_rstip[addr] = bg;
 				if (*wdata != 0) {
 					if (shift > 16) {
@@ -1007,7 +1007,7 @@
 		addr &= 0xffffe0;
 		mask = 0xffffffff >> shift;
 		maskr = (uint64_t)(0xffffffffUL << 
-		    (32 - (ri->ri_font->fontwidth + shift - 32)));
+		    (32 - (font->fontwidth + shift - 32)));
 		bg = 0x3000000000000000LL |
 		    ((uint64_t)ri->ri_devcmap[(attr >> 16) & 0xff] &
 		      0xff) << 32;
@@ -1017,12 +1017,12 @@
 		    ((uint64_t)ri->ri_devcmap[(attr >> 24) & 0xff] & 0xff) << 
 		      32;
 
-		uc = c - ri->ri_font->firstchar;
-		cdata = (uint8_t *)ri->ri_font->data + uc * ri->ri_fontscale;
+		uc = c - font->firstchar;
+		cdata = (uint8_t *)font->data + uc * ri->ri_fontscale;
 
-		if (ri->ri_font->fontwidth < 9) {
+		if (font->fontwidth < 9) {
 			/* byte by byte */
-			for (i = 0; i < ri->ri_font->fontheight; i++) {
+			for (i = 0; i < font->fontheight; i++) {
 				sc->sc_rstip[addr] = bg;
 				sc->sc_rstip[addr + 32] = bgr;
 				bork = *cdata;
@@ -1035,10 +1035,10 @@
 				cdata++;
 				addr += ri->ri_width;
 			}
-		} else if (ri->ri_font->fontwidth < 17) {
+		} else if (font->fontwidth < 17) {
 			/* short by short */
 			wdata = (uint16_t *)cdata;
-			for (i = 0; i < ri->ri_font->fontheight; i++) {
+			for (i = 0; i < font->fontheight; i++) {
 				sc->sc_rstip[addr] = bg;
 				sc->sc_rstip[addr + 32] = bgr;
 				bork = *wdata;

Index: src/sys/dev/sbus/zx.c
diff -u src/sys/dev/sbus/zx.c:1.35 src/sys/dev/sbus/zx.c:1.36
--- src/sys/dev/sbus/zx.c:1.35	Tue Jan  5 05:04:38 2010
+++ src/sys/dev/sbus/zx.c	Tue May  4 05:10:25 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: zx.c,v 1.35 2010/01/05 05:04:38 macallan Exp $	*/
+/*	$NetBSD: zx.c,v 1.36 2010/05/04 05:10:25 macallan Exp $	*/
 
 /*
  *  Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -45,7 +45,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: zx.c,v 1.35 2010/01/05 05:04:38 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: zx.c,v 1.36 2010/05/04 05:10:25 macallan Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -993,9 +993,9 @@
 zx_putchar(void *cookie, int row, int col, u_int uc, long attr)
 {
 	struct rasops_info *ri = cookie;
+	struct wsdisplay_font *font = PICK_FONT(ri, uc);
 	struct vcons_screen *scr = ri->ri_hw;
 	struct zx_softc *sc = scr->scr_cookie;
-	struct wsdisplay_font *font;
 	volatile uint32_t *dp;
 	uint8_t *fb;
 	int fs, i, ul;
@@ -1007,15 +1007,13 @@
 	if (uc == ' ') {
 		int x, y;
 
-		x = ri->ri_xorigin + ri->ri_font->fontwidth * col;
-		y = ri->ri_yorigin + ri->ri_font->fontheight * row;
-		zx_fillrect(sc, x, y, ri->ri_font->fontwidth,
-			    ri->ri_font->fontheight, bg, ZX_STD_ROP);
+		x = ri->ri_xorigin + font->fontwidth * col;
+		y = ri->ri_yorigin + font->fontheight * row;
+		zx_fillrect(sc, x, y, font->fontwidth,
+			    font->fontheight, bg, ZX_STD_ROP);
 		return;
 	}
 
-	font = ri->ri_font;
-
 	dp = (volatile uint32_t *)sc->sc_pixels +
 	    ((row * font->fontheight + ri->ri_yorigin) << 11) +
 	    (col * font->fontwidth + ri->ri_xorigin);

Reply via email to