From 9ed778807ac6f88db5e776e61f62d9f1a5f9921d Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Tue, 26 Oct 1993 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1993-10-26 --- carrera/screen.c | 49 +++++++++++++++++++++--------------------------- port/devmouse.c | 28 +++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 28 deletions(-) diff --git a/carrera/screen.c b/carrera/screen.c index 34494df3fb994c5790a1b703d9fc1926ac948b4d..6c05f6ef2e6c716c9d53c1c238f4d81d4ffcf4c6 100644 --- a/carrera/screen.c +++ b/carrera/screen.c @@ -534,32 +534,24 @@ mousescreenupdate(void) unlock(&screenlock); } +extern cursorlock(Rectangle); +extern cursorunlock(void); /* - * graphics + * paste tile into screen. + * tile is at location r, first pixel in *data. tl is length of scan line to insert, + * l is amount to advance data after each scan line. */ void -screenload(Rectangle r, uchar *data, long n) +screenload(Rectangle r, uchar *data, int tl, int l) { - int y, ws, l, t, lpart, rpart, mx, m, mr; + int y, lpart, rpart, mx, m, mr; uchar *q; - if(!rectclip(&r, gscreen.r)) + if(!rectclip(&r, gscreen.r) || tl<=0) return; lock(&screenlock); - ws = 8>>gscreen.ldepth; /* pixels per byte */ - /* set l to number of bytes of data per scan line */ - if(r.min.x >= 0) - l = (r.max.x+ws-1)/ws - r.min.x/ws; - else{ /* make positive before divide */ - t = (-r.min.x)+ws-1; - t = (t/ws)*ws; - l = (t+r.max.x+ws-1)/ws; - } - if(n != l*Dy(r)){ - unlock(&screenlock); - error("bad tile size"); - } - cursoroff(1); + cursorlock(r); + screenupdate(); q = gbaddr(&gscreen, r.min); mx = 7>>gscreen.ldepth; lpart = (r.min.x & mx) << gscreen.ldepth; @@ -573,40 +565,41 @@ screenload(Rectangle r, uchar *data, long n) for(y=r.min.y; y 1) - memmove(q+1, data+1, l-1); + if(tl > 1) + memmove(q+1, data+1, tl-1); q += gscreen.width*sizeof(ulong); data += l; } }else if(lpart == 0){ for(y=r.min.y; y 1) - memmove(q, data, l-1); - q[l-1] ^= (data[l-1]^q[l-1]) & mr; + if(tl > 1) + memmove(q, data, tl-1); + q[tl-1] ^= (data[tl-1]^q[tl-1]) & mr; q += gscreen.width*sizeof(ulong); data += l; } }else for(y=r.min.y; y 2) - memmove(q+1, data+1, l-2); - q[l-1] ^= (data[l-1]^q[l-1]) & mr; + memmove(q+1, data+1, tl-2); + q[tl-1] ^= (data[tl-1]^q[l-1]) & mr; q += gscreen.width*sizeof(ulong); data += l; } mbbrect(r); - cursoron(1); + screenupdate(); + cursorunlock(); screenupdate(); unlock(&screenlock); } diff --git a/port/devmouse.c b/port/devmouse.c index f92a7d35c5d23c42fc9070b63f9a5671d5f7b5fa..9fc9ed2902d072fece7395667649cfbcb66c4dad 100644 --- a/port/devmouse.c +++ b/port/devmouse.c @@ -54,6 +54,7 @@ struct Cursorinfo Lock; int visible; /* on screen */ int disable; /* from being used */ + int frozen; /* from being used */ Rectangle r; /* location */ }; @@ -382,6 +383,33 @@ Cursortocursor(Cursor *c) unlock(&cursor); } +void +cursorlock(Rectangle r) +{ + if(hwcurs) + return; + lock(&cursor); + if(rectXrect(cursor.r, r)){ + cursoroff(0); + cursor.frozen = 1; + } + cursor.disable++; + unlock(&cursor); +} + +void +cursorunlock(void) +{ + if(hwcurs) + return; + lock(&cursor); + cursor.disable--; + if(cursor.frozen) + cursoron(0); + cursor.frozen = 0; + unlock(&cursor); +} + void cursoron(int dolock) {