From 4c26c55f23c35b5571f6b4756af4fcd2cd5f5bf0 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Thu, 12 Nov 1992 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1992-11-12 --- pc/devconfig.c | 4 ++ pc/l.s | 4 +- pc/main.c | 2 +- pc/vga.c | 117 ++++++++++++++++++++++++++++--------------------- port/devbit.c | 16 +++++++ port/portfns.h | 1 + 6 files changed, 91 insertions(+), 53 deletions(-) diff --git a/pc/devconfig.c b/pc/devconfig.c index 64ecf65e3118088e15f28e6836d1c77d24fb7978..ee0e90da931f715fe0c4a54523a16d7d6c122003 100644 --- a/pc/devconfig.c +++ b/pc/devconfig.c @@ -164,7 +164,11 @@ configwrite(Chan *c, void *buf, long n, ulong offset) cbuf[n] = 0; cp = cbuf; maxx = strtoul(cp, &cp, 0); + if(*cp!=0) + cp++; maxy = strtoul(cp, &cp, 0); + if(*cp!=0) + cp++; ldepth = strtoul(cp, &cp, 0); if(maxx == 0 || maxy == 0 || maxx > 1280 || maxy > 1024 diff --git a/pc/l.s b/pc/l.s index be3bde309e4ae66096b21a6aed6e83594160b332..db859989b8ec07332c4839095473c2fa18192ca5 100644 --- a/pc/l.s +++ b/pc/l.s @@ -645,7 +645,7 @@ TEXT l0update(SB),$0 MOVL from+0(FP),SI MOVL to+4(FP),DI l00: - MOVB -2(SI)(CX*2),AL + MOVB -1(SI)(CX*1),AL MOVB bitrevtab(SB)(AX*1),AL MOVB AL,-1(DI)(CX*1) LOOP l00 @@ -687,7 +687,7 @@ l10: MOVB $0x5,AL /* write lo order bits to bit planes 1 & 3 */ OUTB MOVW BX,-2(DI)(CX*1) - SHRL $16,BX /* write hi order bits to bit planes 1 & 3 */ + SHRL $16,BX /* write hi order bits to bit planes 0 & 2 */ MOVB $0xA,AL OUTB MOVW BX,-2(DI)(CX*1) diff --git a/pc/main.c b/pc/main.c index 708024078412096c8462df875a6d3069d6258a3c..86cecf94b014eb475772cc6a675d0ecb39a0341d 100644 --- a/pc/main.c +++ b/pc/main.c @@ -271,7 +271,7 @@ confinit(void) conf.npage1 = (i*MB - conf.base1)/BY2PG; conf.npage = conf.npage0 + conf.npage1; - conf.ldepth = 2; + conf.ldepth = 1; pcnt = screenbits()-1; /* Calculate % of memory for page pool */ pcnt = 70 - (pcnt*10); conf.upages = (conf.npage*pcnt)/100; diff --git a/pc/vga.c b/pc/vga.c index 41f4a70090c4d041d83645f35cf09bd63a84a419..260792fb270ff0b7d860020e76c3a468a2f41c76 100644 --- a/pc/vga.c +++ b/pc/vga.c @@ -12,9 +12,6 @@ #define MINX 8 -extern GSubfont defont0; -GSubfont *defont; - struct{ Point pos; int bwid; @@ -22,9 +19,11 @@ struct{ int islittle = 1; /* little endian bit ordering in bytes */ -extern Cursor arrow; -extern uchar cswizzle[256]; - +extern GSubfont defont0; +GSubfont *defont; +extern Cursor arrow; +extern GBitmap cursorback; +static Lock colorlock; /* color map lock */ /* * screen dimensions @@ -67,7 +66,7 @@ VGAmode mode12 = 0xff, /* attribute */ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x3f, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x01, 0x10, 0x0f, 0x00, 0x00, }; @@ -238,37 +237,42 @@ setscreen(int maxx, int maxy, int ldepth) /* * zero hard screen and setup a bitmap for the new size */ - memset((void*)SCREENMEM, 0xff, 64*1024); if(ldepth == 3) vgascreen.ldepth = 3; else vgascreen.ldepth = 0; vgascreen.base = (void*)SCREENMEM; vgascreen.width = (maxx*(1<>2)); - outb(CM, colourxpnd(i&~1)); + x = (i*63)/15; + outb(CM, x); + outb(CM, x); + outb(CM, x); } - outb(CMWX, 5); - outb(CM, 21); - outb(CM, 21); - outb(CM, 21); - outb(CMWX, 0xa); - outb(CM, 42); - outb(CM, 42); - outb(CM, 42); + unlock(&colorlock); } /* @@ -383,10 +375,19 @@ screenupdate(void) uchar *sp, *hp; int y, len, incs, inch, off, page, y2pg, ey; Rectangle r; + static int nocheck; r = mbb; mbb = NULLMBB; + if(nocheck==0 && memcmp(pad1, pad2, 1024)){ + nocheck = 1; + print("b: %d %d %d %d\n", r.min.x, r.min.y, r.max.x, r.max.y); + nocheck = 0; + memset(pad1, 0, 1024); + memset(pad2, 0, 1024); + } + if(Dy(r) < 0) return; @@ -424,8 +425,8 @@ screenupdate(void) hp = (uchar*)(vgascreen.base+(r.min.y*vgascreen.width)) + off; sp = (uchar*)(gscreen.base+(r.min.y*gscreen.width)) + 2*off; len = (r.max.x + 15)/8 - r.min.x/8; - if(len < 2) - len = 2; + if(len < 0) + return; /* reverse the bits and split into 2 bit planes */ for (y = r.min.y; y < r.max.y; y++){ @@ -474,6 +475,14 @@ screenupdate(void) } break; } + + if(nocheck==0 && memcmp(pad1, pad2, 1024)){ + nocheck = 1; + print("a: %d %d %d %d\n", r.min.x, r.min.y, r.max.x, r.max.y); + nocheck = 0; + memset(pad1, 0, 1024); + memset(pad2, 0, 1024); + } } void @@ -548,27 +557,35 @@ mousescreenupdate(void) screenupdate(); } +static ulong +expand(uchar x) +{ + return (x<<(32-6))|(x<<(32-12))|(x<<(32-18))|(x<<(32-24)); +} + void getcolor(ulong p, ulong *pr, ulong *pg, ulong *pb) { - ulong ans; - - /* - * The safari monochrome says 0 is black (zero intensity) - */ - if(p == 0) - ans = 0; - else - ans = ~0; - *pr = *pg = *pb = ans; + p &= (1<<(1<>(32-6)); + outb(CM, g>>(32-6)); + outb(CM, b>>(32-6)); + unlock(&colorlock); + return ~0; } int diff --git a/port/devbit.c b/port/devbit.c index dc9a13c3ed9d6daedc4fac1f6dd1224d1e5efbcf..76c1697feb04521b65c7e9cf19794e3ce0b55472 100644 --- a/port/devbit.c +++ b/port/devbit.c @@ -309,6 +309,22 @@ bitreset(void) Cursortocursor(&arrow); } +/* + * screen bit depth changed, reset backup map for cursor + */ +void +bitdepth(void) +{ + cursoroff(1); + if(gscreen.ldepth > 3) + cursorback.ldepth = 0; + else{ + cursorback.ldepth = gscreen.ldepth; + cursorback.width = ((16 << gscreen.ldepth) + 31) >> 5; + } + cursoron(1); +} + void bitinit(void) { diff --git a/port/portfns.h b/port/portfns.h index 1f8111925cde8cd66d8bb82046eb24dbdcaaa5f5..5bc3987ff3fde1aff1ffac91af9167b173f7f8e4 100644 --- a/port/portfns.h +++ b/port/portfns.h @@ -3,6 +3,7 @@ Block* allocb(ulong); int anyready(void); Image* attachimage(int, Chan*, ulong, ulong); void bitdebug(void); +void bitdepth(void); void bitreverse(uchar*, int); int blen(Block *); int bround(Block *, int);