summaryrefslogtreecommitdiff
path: root/sys/dev/ic/vga.c
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2006-11-29 19:08:24 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2006-11-29 19:08:24 +0000
commitf1383d2d04a9e6ec1da4df59ac0ff1478bb10f9b (patch)
tree512b51f4e326e33ded20210f85a3a55fcc606db9 /sys/dev/ic/vga.c
parent1b439ba33ce246b10f77ec8ccd4790e890966526 (diff)
Add an unpack_attr function to struct wsdisplay_emulops, to match the
existing alloc_attr function. This allows rasops_unpack_attr to be kept private to rasops, yet available to the screen drivers.
Diffstat (limited to 'sys/dev/ic/vga.c')
-rw-r--r--sys/dev/ic/vga.c46
1 files changed, 43 insertions, 3 deletions
diff --git a/sys/dev/ic/vga.c b/sys/dev/ic/vga.c
index c5489d3df46..d6a58b4b81d 100644
--- a/sys/dev/ic/vga.c
+++ b/sys/dev/ic/vga.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vga.c,v 1.40 2006/11/29 12:13:54 miod Exp $ */
+/* $OpenBSD: vga.c,v 1.41 2006/11/29 19:08:22 miod Exp $ */
/* $NetBSD: vga.c,v 1.28.2.1 2000/06/30 16:27:47 simonb Exp $ */
/*
@@ -102,6 +102,7 @@ int vga_mapchar(void *, int, unsigned int *);
void vga_putchar(void *, int, int, u_int, long);
int vga_alloc_attr(void *, int, int, int, long *);
void vga_copyrows(void *, int, int, int);
+void vga_unpack_attr(void *, long, int *, int *, int *);
static const struct wsdisplay_emulops vga_emulops = {
pcdisplay_cursor,
@@ -111,13 +112,14 @@ static const struct wsdisplay_emulops vga_emulops = {
pcdisplay_erasecols,
vga_copyrows,
pcdisplay_eraserows,
- vga_alloc_attr
+ vga_alloc_attr,
+ vga_unpack_attr
};
/*
* translate WS(=ANSI) color codes to standard pc ones
*/
-static unsigned char fgansitopc[] = {
+static const unsigned char fgansitopc[] = {
#ifdef __alpha__
/*
* XXX DEC HAS SWITCHED THE CODES FOR BLUE AND RED!!!
@@ -140,6 +142,20 @@ static unsigned char fgansitopc[] = {
#endif
};
+/*
+ * translate standard pc color codes to WS(=ANSI) ones
+ */
+static const u_int8_t pctoansi[] = {
+#ifdef __alpha__
+ WSCOL_BLACK, WSCOL_RED, WSCOL_GREEN, WSCOL_BROWN,
+ WSCOL_BLUE, WSCOL_MAGENTA, WSCOL_CYAN, WSCOL_WHITE
+#else
+ WSCOL_BLACK, WSCOL_BLUE, WSCOL_GREEN, WSCOL_CYAN,
+ WSCOL_RED, WSCOL_MAGENTA, WSCOL_BROWN, WSCOL_WHITE
+#endif
+};
+
+
const struct wsscreen_descr vga_stdscreen = {
"80x25", 80, 25,
&vga_emulops,
@@ -980,6 +996,30 @@ vga_alloc_attr(id, fg, bg, flags, attrp)
}
void
+vga_unpack_attr(id, attr, fg, bg, ul)
+ void *id;
+ long attr;
+ int *fg, *bg, *ul;
+{
+ struct vgascreen *scr = id;
+ struct vga_config *vc = scr->cfg;
+
+ if (vc->hdl.vh_mono) {
+ *fg = (attr & 0x07) == 0x07 ? WSCOL_WHITE : WSCOL_BLACK;
+ *bg = attr & 0x70 ? WSCOL_WHITE : WSCOL_BLACK;
+ if (ul != NULL)
+ *ul = *fg != WSCOL_WHITE && (attr & 0x01) ? 1 : 0;
+ } else {
+ *fg = pctoansi[attr & 0x07];
+ *bg = pctoansi[(attr & 0x70) >> 4];
+ if (*ul != NULL)
+ *ul = 0;
+ }
+ if (attr & FG_INTENSE)
+ *fg += 8;
+}
+
+void
vga_copyrows(id, srcrow, dstrow, nrows)
void *id;
int srcrow, dstrow, nrows;