From 27fa333ea16e6635a0b7172b023ba7106f927505 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Thu, 4 Aug 1994 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1994-08-04 --- pc/vgas3.c | 70 +++++++++++++++++++++++++++++++++++--------------- port/devpipe.c | 24 ++++------------- port/qio.c | 9 +++++-- 3 files changed, 61 insertions(+), 42 deletions(-) diff --git a/pc/vgas3.c b/pc/vgas3.c index fab090d20e1b935713bb4cce964f051df0930544..b85e43f3bff21888fd3a0c6701cb457163a21273 100644 --- a/pc/vgas3.c +++ b/pc/vgas3.c @@ -16,6 +16,7 @@ */ static Lock s3pagelock; static ulong storage; +static Point hotpoint; extern Bitmap gscreen; @@ -80,15 +81,16 @@ enable(void) /* * Cursor colours. Set both the CR0[EF] and the colour * stack in case we are using a 16-bit RAMDAC. + * Why are these colours reversed? */ - vgaxo(Crtx, 0x0E, 0x00); - vgaxo(Crtx, 0x0F, 0xFF); + vgaxo(Crtx, 0x0E, 0xFF); + vgaxo(Crtx, 0x0F, 0x00); vgaxi(Crtx, 0x45); for(i = 0; i < 4; i++) - vgaxo(Crtx, 0x4A, 0x00); + vgaxo(Crtx, 0x4A, 0xFF); vgaxi(Crtx, 0x45); for(i = 0; i < 4; i++) - vgaxo(Crtx, 0x4B, 0xFF); + vgaxo(Crtx, 0x4B, 0x00); /* * Find a place for the cursor data in display memory. @@ -110,7 +112,7 @@ enable(void) static void load(Cursor *c) { - uchar *and, *xor; + uchar *p; int x, y; /* @@ -118,14 +120,14 @@ load(Cursor *c) * memory so we can update the cursor bitmap. * Set the display page (do we need to restore * the current contents when done?) and the - * pointers to the two planes. + * pointer to the two planes. What if this crosses + * into a new page? */ disable(); lock(&s3pagelock); sets3page(storage>>16); - and = ((uchar*)gscreen.base) + (storage & 0xFFFF); - xor = and + 512; + p = ((uchar*)gscreen.base) + (storage & 0xFFFF); /* * The cursor is set in X11 mode which gives the following @@ -138,24 +140,27 @@ load(Cursor *c) * Put the cursor into the top-left of the 64x64 array. */ for(y = 0; y < 64; y++){ - for(x = 0; x < 8; x++){ - if(y < 16 && x < 2){ - and[8*y + x] = c->clr[2*y + x]^c->set[2*y + x]; - xor[8*y + x] = c->set[2*y + x]; + for(x = 0; x < 64/8; x += 2){ + if(x < 16/8 && y < 16){ + *p++ = c->clr[2*y + x]|c->set[2*y + x]; + *p++ = c->clr[2*y + x+1]|c->set[2*y + x+1]; + *p++ = c->set[2*y + x]; + *p++ = c->set[2*y + x+1]; } else { - and[8*y + x] = 0; - xor[8*y + x] = 0; + *p++ = 0x00; + *p++ = 0x00; + *p++ = 0x00; + *p++ = 0x00; } } } unlock(&s3pagelock); /* - * Set the cursor offset and enable the cursor. + * Set the cursor hotpoint and enable the cursor. */ - vgaxo(Crtx, 0x4E, -c->offset.x); - vgaxo(Crtx, 0x4F, -c->offset.y); + hotpoint = c->offset; vsyncactive(); vgaxo(Crtx, 0x45, 0x01); } @@ -163,10 +168,33 @@ load(Cursor *c) static int move(Point p) { - vgaxo(Crtx, 0x46, (p.x>>8) & 0x07); - vgaxo(Crtx, 0x47, p.x & 0xFF); - vgaxo(Crtx, 0x49, p.y & 0xFF); - vgaxo(Crtx, 0x48, (p.y>>8) & 0x07); + int x, xo, y, yo; + + /* + * Mustn't position the cursor offscreen even partially, + * or it disappears. Therefore, if x or y is -ve, adjust the + * cursor offset instead. + */ + if((x = p.x+hotpoint.x) < 0){ + xo = -x; + xo = ((xo+1)/2)*2; + x = 0; + } + else + xo = 0; + if((y = p.y+hotpoint.y) < 0){ + yo = -y; + y = 0; + } + else + yo = 0; + + vgaxo(Crtx, 0x46, (x>>8) & 0x07); + vgaxo(Crtx, 0x47, x & 0xFF); + vgaxo(Crtx, 0x49, y & 0xFF); + vgaxo(Crtx, 0x4E, xo); + vgaxo(Crtx, 0x4F, yo); + vgaxo(Crtx, 0x48, (y>>8) & 0x07); return 0; } diff --git a/port/devpipe.c b/port/devpipe.c index 847255b525bdeede8218c7091130682d51aefaca..8f99eeefbb52ad3bc2f2de47bca61dfe618b7dd6 100644 --- a/port/devpipe.c +++ b/port/devpipe.c @@ -22,7 +22,6 @@ struct Pipe struct { Lock; - Pipe *pipe; ulong path; } pipealloc; @@ -85,8 +84,6 @@ pipeattach(char *spec) lock(&pipealloc); p->path = ++pipealloc.path; - p->next = pipealloc.pipe; - pipealloc.pipe = p; unlock(&pipealloc); c->qid = (Qid){CHDIR|NETQID(2*p->path, Qdir), 0}; @@ -223,7 +220,7 @@ pipewstat(Chan *c, char *db) void pipeclose(Chan *c) { - Pipe *p, *f, **l; + Pipe *p; p = c->aux; qlock(p); @@ -236,15 +233,15 @@ pipeclose(Chan *c) case Qdata0: p->qref[0]--; if(p->qref[0] == 0){ - qclose(p->q[0]); qhangup(p->q[1]); + qclose(p->q[0]); } break; case Qdata1: p->qref[1]--; if(p->qref[1] == 0){ - qclose(p->q[1]); qhangup(p->q[0]); + qclose(p->q[1]); } break; } @@ -265,22 +262,11 @@ pipeclose(Chan *c) p->ref--; if(p->ref == 0){ qunlock(p); - lock(&pipealloc); - l = &pipealloc.pipe; - for(f = *l; f; f = f->next) { - if(f == p) { - *l = p->next; - break; - } - l = &f->next; - } - unlock(&pipealloc); free(p->q[0]); free(p->q[1]); free(p); - } - - qunlock(p); + } else + qunlock(p); } long diff --git a/port/qio.c b/port/qio.c index c0e57b5b8dfdf3df1bd1d9933af4cd507c2556a8..75e0a8a9cc0fd3c370caab92a882e9f55b7821aa 100644 --- a/port/qio.c +++ b/port/qio.c @@ -337,7 +337,6 @@ qopen(int limit, int msg, void (*kick)(void*), void *arg) if(q == 0) return 0; - memset(q, 0, sizeof(Queue)); q->limit = limit; q->kick = kick; q->arg = arg; @@ -494,7 +493,7 @@ qwrite(Queue *q, void *vp, int len, int nowait) if(waserror()){ qunlock(&q->wlock); nexterror(); - }; + } qlock(&q->wlock); sofar = 0; @@ -522,6 +521,10 @@ qwrite(Queue *q, void *vp, int len, int nowait) n = 128*1024; b = allocb(n); + if(waserror()){ + freeb(b); + nexterror(); + } memmove(b->wp, p+sofar, n); b->wp += n; @@ -531,6 +534,7 @@ qwrite(Queue *q, void *vp, int len, int nowait) freeb(b); qunlock(&q->wlock); poperror(); + poperror(); return len; } q->state |= Qflow; @@ -543,6 +547,7 @@ qwrite(Queue *q, void *vp, int len, int nowait) iunlock(q); error(Ehungup); } + poperror(); checkb(b, "qwrite"); if(q->syncbuf){