From 2673f2361219bc3174de83a234c7d5d514584a68 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Sun, 7 Jul 1991 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1991-07-07 --- gnot/screen.c | 29 +++++++++++++++++++++ port/devbit.c | 69 ++++++++++++++++++++++---------------------------- port/sysproc.c | 2 +- power/main.c | 2 +- ss/screen.c | 47 ++++++++++++++++++++++++++++++++++ 5 files changed, 108 insertions(+), 41 deletions(-) diff --git a/gnot/screen.c b/gnot/screen.c index 80f202d9bdeac10dc007fe1b431b11d68049c766..eca37739670013b7e53b488148bc576f01c02463 100644 --- a/gnot/screen.c +++ b/gnot/screen.c @@ -9,6 +9,7 @@ #include #include +#include "mouse.h" #define MINX 8 @@ -77,6 +78,13 @@ screenputc(int c) } } +/* Use the balu version */ +void +gbitblt(GBitmap *d, Point p, GBitmap *s, Rectangle r, Fcode f) +{ + balubitblt(d, p, s, r, f); +} + void screenputs(char *s, int n) { @@ -112,6 +120,7 @@ getcolor(ulong p, ulong *pr, ulong *pg, ulong *pb) case 1: ans = 0xAAAAAAAA; break; case 2: ans = 0x55555555; break; default: ans = 0; break; + } } *pr = *pg = *pb = ans; } @@ -133,3 +142,23 @@ hwcursmove(int x, int y) { return 0; } + +void +mouseclock(void) /* called spl6 */ +{ + ++mouse.clock; +} + +void +mousetry(Ureg *ur) +{ + int s; + + if(mouse.clock && mouse.track && (ur->sr&SPL(7)) == 0 && canlock(&cursor)){ + s = spl1(); + mouseupdate(0); + splx(s); + unlock(&cursor); + wakeup(&mouse.r); + } +} diff --git a/port/devbit.c b/port/devbit.c index fc886a6b5b42a07005a1fa299515fb9d659c9f6d..4defc08a7248a1ddc8a64d04fdc1b5b91db5eaa0 100644 --- a/port/devbit.c +++ b/port/devbit.c @@ -9,6 +9,7 @@ #include #include +#include "mouse.h" extern GFont *defont; @@ -67,18 +68,8 @@ void bitcompact(void); void bitfree(GBitmap*); extern GBitmap gscreen; -struct{ - /* - * First four fields are known in screen.c - */ - int dx; /* interrupt-time delta */ - int dy; - int track; /* update cursor on screen */ - Mouse; - int changed; /* mouse structure changed since last read */ - Rendez r; - int newbuttons; /* interrupt time access only */ -}mouse; +Mouseinfo mouse; +Cursorinfo cursor; Cursor arrow = { @@ -95,13 +86,6 @@ Cursor arrow = } }; -struct{ - Cursor; - Lock; - int visible; /* on screen */ - Rectangle r; /* location */ -}cursor; - ulong setbits[16]; GBitmap set = { @@ -1211,29 +1195,36 @@ mousebuttons(int b) /* called at higher priority */ mouseclock(); } + void -mouseclock(void) /* called splhi */ +mouseupdate(int dolock) { int x, y; - if(mouse.track && canlock(&cursor)){ - x = mouse.xy.x + mouse.dx; - if(x < gscreen.r.min.x) - x = gscreen.r.min.x; - if(x >= gscreen.r.max.x) - x = gscreen.r.max.x; - y = mouse.xy.y + mouse.dy; - if(y < gscreen.r.min.y) - y = gscreen.r.min.y; - if(y >= gscreen.r.max.y) - y = gscreen.r.max.y; - cursoroff(0); - mouse.xy = Pt(x, y); - cursoron(0); - mouse.dx = 0; - mouse.dy = 0; - mouse.track = 0; - mouse.buttons = mouse.newbuttons; - mouse.changed = 1; + + if(!mouse.track || (dolock && !canlock(&cursor))) + return; + + x = mouse.xy.x + mouse.dx; + if(x < gscreen.r.min.x) + x = gscreen.r.min.x; + if(x >= gscreen.r.max.x) + x = gscreen.r.max.x; + y = mouse.xy.y + mouse.dy; + if(y < gscreen.r.min.y) + y = gscreen.r.min.y; + if(y >= gscreen.r.max.y) + y = gscreen.r.max.y; + cursoroff(0); + mouse.xy = Pt(x, y); + cursoron(0); + mouse.dx = 0; + mouse.dy = 0; + mouse.clock = 0; + mouse.track = 0; + mouse.buttons = mouse.newbuttons; + mouse.changed = 1; + + if(dolock){ unlock(&cursor); wakeup(&mouse.r); } diff --git a/port/sysproc.c b/port/sysproc.c index 6cc152c3fea37c4148889890c130b646fd7be922..a13019ebbbe1fea5ca58ffb4dda2bd6ab3e518a9 100644 --- a/port/sysproc.c +++ b/port/sysproc.c @@ -279,11 +279,11 @@ sysexec(ulong *arg) * Move the stack */ s = p->seg[ESEG]; + p->seg[ESEG] = 0; p->seg[SSEG] = s; s->base = USTKTOP-USTKSIZE; s->top = USTKTOP; relocateseg(s, TSTKTOP-USTKTOP); - p->seg[ESEG] = 0; close(tc); poperror(); diff --git a/power/main.c b/power/main.c index 92cb5fcddc8099c860ed61400e131aaa5bb74e04..8d7b44fe76f3d46ce0bcce6fb8ac87bad2c80745 100644 --- a/power/main.c +++ b/power/main.c @@ -377,7 +377,7 @@ exit(void) splhi(); for(i=0; i<2000000; i++) ; - duartreset(); +/* duartreset(); /**/ firmware(); } diff --git a/ss/screen.c b/ss/screen.c index 5ed294d8eff6e9d74dd2b6929341f1a79e6fa495..2672b81f6c65f647b027682f179073bf4cc2ba94 100644 --- a/ss/screen.c +++ b/ss/screen.c @@ -9,6 +9,7 @@ #include #include +#include "mouse.h" #define MINX 8 @@ -471,3 +472,49 @@ void lights(int mask) { } + +int +screenbits(void) +{ + return 1; /* bits per pixel */ +} + +void +getcolor(ulong p, ulong *pr, ulong *pg, ulong *pb) +{ + ulong ans; + + /* + * The slc monochrome says 0 is white (max intensity) + */ + if(p == 0) + ans = ~0; + else + ans = 0; + *pr = *pg = *pb = ans; +} + + +int +setcolor(ulong p, ulong r, ulong g, ulong b) +{ + return 0; /* can't change mono screen colormap */ +} + +int +hwcursset(uchar *s, uchar *c, int ox, int oy) +{ + return 0; +} + +int +hwcursmove(int x, int y) +{ + return 0; +} + +void +mouseclock(void) /* called splhi */ +{ + mouseupdate(1); +}