summaryrefslogtreecommitdiff
path: root/sys/dev/isa/ega.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/isa/ega.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/isa/ega.c')
-rw-r--r--sys/dev/isa/ega.c44
1 files changed, 41 insertions, 3 deletions
diff --git a/sys/dev/isa/ega.c b/sys/dev/isa/ega.c
index 4be901605cb..3777e5a3f51 100644
--- a/sys/dev/isa/ega.c
+++ b/sys/dev/isa/ega.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ega.c,v 1.9 2006/11/29 12:13:54 miod Exp $ */
+/* $OpenBSD: ega.c,v 1.10 2006/11/29 19:08:22 miod Exp $ */
/* $NetBSD: ega.c,v 1.4.4.1 2000/06/30 16:27:47 simonb Exp $ */
/*
@@ -112,6 +112,7 @@ static void ega_init(struct ega_config *,
bus_space_tag_t, bus_space_tag_t, int);
static void ega_setfont(struct ega_config *, struct egascreen *);
static int ega_alloc_attr(void *, int, int, int, long *);
+static void ega_unpack_attr(void *, long, int *, int *, int *);
void ega_copyrows(void *, int, int, int);
struct cfattach ega_ca = {
@@ -130,13 +131,14 @@ const struct wsdisplay_emulops ega_emulops = {
pcdisplay_erasecols,
ega_copyrows,
pcdisplay_eraserows,
- ega_alloc_attr
+ ega_alloc_attr,
+ ega_unpack_attr
};
/*
* translate WS(=ANSI) color codes to standard pc ones
*/
-static unsigned char fgansitopc[] = {
+static const unsigned char fgansitopc[] = {
FG_BLACK, FG_RED, FG_GREEN, FG_BROWN, FG_BLUE,
FG_MAGENTA, FG_CYAN, FG_LIGHTGREY
}, bgansitopc[] = {
@@ -144,6 +146,18 @@ static unsigned char fgansitopc[] = {
BG_MAGENTA, BG_CYAN, BG_LIGHTGREY
};
+/*
+ * 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 ega_stdscreen = {
"80x25", 80, 25,
&ega_emulops,
@@ -886,6 +900,30 @@ ega_alloc_attr(id, fg, bg, flags, attrp)
}
void
+ega_unpack_attr(id, attr, fg, bg, ul)
+ void *id;
+ long attr;
+ int *fg, *bg, *ul;
+{
+ struct egascreen *scr = id;
+ struct ega_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
ega_copyrows(id, srcrow, dstrow, nrows)
void *id;
int srcrow, dstrow, nrows;