From 8ad30adaf112b14dbc8cb79bb7463091e9913840 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Fri, 6 May 1994 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1994-05-06 --- pc/devvga.c | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/pc/devvga.c b/pc/devvga.c index ff9ed7f9087922955b66d3de7dd4e1713c3b60bf..4ce7b388d781923daf20f9128f2f509f294fb3e7 100644 --- a/pc/devvga.c +++ b/pc/devvga.c @@ -134,6 +134,7 @@ static void screenputc(char*); static void scroll(void); static ulong x3to32(uchar); static ulong x6to32(uchar); +static void greyscale(void); static void workinit(Bitmap*, int, int); extern void screenload(Rectangle, uchar*, int, int, int); extern void screenunload(Rectangle, uchar*, int, int, int); @@ -308,6 +309,8 @@ vgawrite(Chan *c, void *buf, long n, ulong offset) cbuf[n] = 0; if(strncmp(cbuf, "hwcursor", 8) == 0) hwcursor = 1; + else if(strncmp(cbuf, "grey", 4) == 0) + greyscale(); break; case Qvgasize: if(offset != 0 || n >= sizeof(cbuf)) @@ -588,7 +591,7 @@ setscreen(int maxx, int maxy, int ldepth) switch(ldepth){ case 3: for(i = 0; i < 256; i++) - setcolor(i, x3to32(i>>5), x3to32(i>>2), x3to32(i<<1)); + setcolor(i, x3to32(i>>5), x3to32(i>>2), x3to32(i|(i<<1))); break; case 2: case 1: @@ -994,6 +997,39 @@ x6to32(uchar x) y = (x<<(32-6))|(x<<(32-12))|(x<<(32-18))|(x<<(32-24))|(x<<(32-30)); return y; } +static ulong +x8to32(uchar x) +{ + ulong y; + + x = x&0xff; + y = (x<<(32-8))|(x<<(32-16))|(x<<(32-24))|x; + return y; +} +static void +greyscale(void) +{ + int i; + ulong x; + + /* default color map (has to be outside the lock) */ + switch(gscreen.ldepth){ + case 3: + for(i = 0; i < 256; i++){ + x = x8to32(i); + setcolor(i, x, x, x); + } + break; + case 2: + case 1: + case 0: + for(i = 0; i < 16; i++){ + x = x6to32((i*63)/15); + setcolor(i, x, x, x); + } + break; + } +} /* * paging routines for different cards