M carrera/main.c => carrera/main.c +1 -1
@@ 503,7 503,7 @@ rdbginit(void)
{
uchar *vec;
ulong jba;
-/*return;/**/
+return;/**/
/* Only interested in the PC */
Mipsjmpbuf.pc = 0x8001C020;
M carrera/screen.c => carrera/screen.c +32 -50
@@ 8,7 8,6 @@
#include "../port/error.h"
#include <libg.h>
-#include <gnot.h>
#include "screen.h"
#define MINX 8
@@ 29,8 28,7 @@ struct Dac
char s1[] = { 0x00, 0x00, 0xC0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
- GSubfont* defont;
-extern GSubfont defont0;
+extern Subfont defont0;
static ulong rep(ulong, int);
struct{
@@ 40,25 38,26 @@ struct{
Lock screenlock;
-GBitmap gscreen =
+Bitmap gscreen =
{
+ { 0, 0, 1600, 1240 },
+ { 0, 0, 1600, 1240 },
+ 3,
Screenvirt+0x00017924,
0,
512,
- 3,
- { 0, 0, 1600, 1240 },
- { 0, 0, 1600, 1240 },
0
};
-static GBitmap hwcursor=
+static Bitmap hwcursor=
{
+ {0, 0, 64, 64},
+ {0, 0, 64, 64},
+ 1,
0, /* base filled in by malloc when needed */
0,
4,
- 1,
- {0, 0, 64, 64},
- {0, 0, 64, 64}
+ 0,
};
uchar bdata[] =
@@ 66,14 65,14 @@ uchar bdata[] =
0xC0,
};
-GBitmap bgrnd =
+Bitmap bgrnd =
{
+ { 0, 0, 1, 1 },
+ { 0, 0, 1, 1 },
+ 3,
(ulong*)bdata,
0,
4,
- 3,
- { 0, 0, 1, 1 },
- { 0, 0, 1, 1 },
0
};
@@ 99,22 98,6 @@ static int h, w;
extern Cursor arrow;
void
-gborder(GBitmap *l, Rectangle r, int i, Fcode c)
-{
- if(i < 0){
- r = inset(r, i);
- i = -i;
- }
- gbitblt(l, r.min, l, Rect(r.min.x, r.min.y, r.max.x, r.min.y+i), c);
- gbitblt(l, Pt(r.min.x, r.max.y-i),
- l, Rect(r.min.x, r.max.y-i, r.max.x, r.max.y), c);
- gbitblt(l, Pt(r.min.x, r.min.y+i),
- l, Rect(r.min.x, r.min.y+i, r.min.x+i, r.max.y-i), c);
- gbitblt(l, Pt(r.max.x-i, r.min.y+i),
- l, Rect(r.max.x-i, r.min.y+i, r.max.x, r.max.y-i), c);
-}
-
-void
screenwin(void)
{
Dac *d;
@@ 124,23 107,24 @@ screenwin(void)
memset((void*)Screenvirt, 0xff, 3*1024*1024);
- gtexture(&gscreen, gscreen.r, &bgrnd, S);
+ texture(&gscreen, gscreen.r, &bgrnd, S);
w = defont0.info[' '].width;
h = defont0.height;
window.min = Pt(100, 100);
window.max = add(window.min, Pt(10+w*120, 10+h*60));
- gbitblt(&gscreen, add(window.min, Pt(5, 5)), &gscreen, window, F);
- gbitblt(&gscreen, window.min, &gscreen, window, Zero);
- gborder(&gscreen, window, 4, F);
+ bitblt(&gscreen, add(window.min, Pt(5, 5)), &gscreen, window, F);
+ bitblt(&gscreen, window.min, &gscreen, window, Zero);
+ border(&gscreen, window, 4, F);
window = inset(window, 5);
for(i = 0; i < h+6; i += 2) {
y = window.min.y+i;
- gsegment(&gscreen, Pt(window.min.x, y), Pt(window.max.x, y), ~0, F);
+ bitblt(&gscreen, Pt(window.min.x, y),
+ &gscreen, Rect(window.min.x, y, window.max.x, y+1), F);
}
p = add(window.min, Pt(10, 2));
- gsubfstring(&gscreen, p, &defont0, "Brazil Console ", S);
+ subfstring(&gscreen, p, &defont0, "Brazil Console ", S);
window.min.y += h+6;
cursor = window.min;
window.max.y = window.min.y+((window.max.y-window.min.y)/h)*h;
@@ 240,8 224,7 @@ screeninit(void)
memmove(&arrow, &fatarrow, sizeof(fatarrow));
- defont = &defont0;
- gbitblt(&gscreen, Pt(0, 0), &gscreen, gscreen.r, 0);
+ bitblt(&gscreen, Pt(0, 0), &gscreen, gscreen.r, 0);
out.pos.x = MINX;
out.pos.y = 0;
out.bwid = defont0.info[' '].width;
@@ 266,9 249,9 @@ scroll(void)
o = 5*h;
r = Rpt(Pt(window.min.x, window.min.y+o), window.max);
- gbitblt(&gscreen, window.min, &gscreen, r, S);
+ bitblt(&gscreen, window.min, &gscreen, r, S);
r = Rpt(Pt(window.min.x, window.max.y-o), window.max);
- gbitblt(&gscreen, r.min, &gscreen, r, Zero);
+ bitblt(&gscreen, r.min, &gscreen, r, Zero);
cursor.y -= o;
}
@@ 299,14 282,14 @@ screenputc(char *buf)
r.max.x = cursor.x;
r.min.y = cursor.y;
r.max.y = cursor.y+defont0.height;
- gbitblt(&gscreen, r.min, &gscreen, r, Zero);
+ bitblt(&gscreen, r.min, &gscreen, r, Zero);
cursor.x -= w;
}
break;
default:
if(cursor.x >= window.max.x-w)
screenputc("\n");
- cursor = gsubfstring(&gscreen, cursor, &defont0, buf, S);
+ cursor = subfstring(&gscreen, cursor, &defont0, buf, S);
}
}
@@ 443,7 426,7 @@ hwcursset(ulong *s, ulong *c, int offx, int offy)
spix = (s[y]>>(31-(x&0x1F)))&1;
cpix = (c[y]>>(31-(x&0x1F)))&1;
dpix = (spix<<1) | cpix;
- gpoint(&hwcursor, add(Pt(x,y), org), dpix, S);
+ point(&hwcursor, add(Pt(x,y), org), dpix, S);
}
d = DAC;
@@ 514,7 497,7 @@ screenload(Rectangle r, uchar *data, int tl, int l, int dolock)
return;
lock(&screenlock);
- q = gbaddr(&gscreen, r.min);
+ q = byteaddr(&gscreen, r.min);
for(y=r.min.y; y<r.max.y; y++){
memmove(q, data, tl);
q += gscreen.width*sizeof(ulong);
@@ 528,7 511,9 @@ screenload(Rectangle r, uchar *data, int tl, int l, int dolock)
* 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.
- * gscreen.ldepth is known to be >= 3
+ * gscreen.ldepth is known to be >= 3.
+ * screenunload() doesn't clip, so must be
+ * called correctly.
*/
void
screenunload(Rectangle r, uchar *data, int tl, int l, int dolock)
@@ 538,11 523,8 @@ screenunload(Rectangle r, uchar *data, int tl, int l, int dolock)
USED(dolock);
- if(!rectclip(&r, gscreen.r) || tl<=0)
- return;
-
lock(&screenlock);
- q = gbaddr(&gscreen, r.min);
+ q = byteaddr(&gscreen, r.min);
for(y=r.min.y; y<r.max.y; y++){
memmove(data, q, tl);
q += gscreen.width*sizeof(ulong);
D pc/bbmalloc.c => pc/bbmalloc.c +0 -81
@@ 1,81 0,0 @@
-#include "u.h"
-#include "../port/lib.h"
-#include "mem.h"
-#include "dat.h"
-#include "fns.h"
-#include "io.h"
-
-#define LINEWORDS (0)
-
-/*
- * Allocate memory for use in kernel bitblts.
- * The allocated memory must have a flushed instruction
- * cache, and the data cache must be flushed by bbdflush().
- * To avoid the need for frequent cache flushes, the memory
- * is allocated out of an arena, and the i-cache is only
- * flushed when it has to be reused
- *
- * This code will have to be interlocked if we ever get
- * a multiprocessor with a bitmapped display.
- */
-
-/* a 0->3 bitblt can take 900 words */
-enum {
- narena=2, /* put interrupt time stuff in separate arena */
- nbbarena=4096 /* number of words in an arena */
-};
-
-static ulong bbarena[narena][nbbarena+LINEWORDS];
-static ulong *bbcur[narena] = {&bbarena[0][0], &bbarena[1][0]};
-static ulong *bblast[narena] = {0, 0};
-
-#define INTLEVEL(v) (((v)&(1<<9)) == 0)
-void *
-bbmalloc(int nbytes)
-{
- int nw, a;
- int s;
- ulong *ans;
-
- nw = nbytes/sizeof(long);
- s = splhi();
- a = INTLEVEL(s)? 1 : 0;
- if(bbcur[a] + nw > &bbarena[a][nbbarena])
- ans = bbarena[a];
- else
- ans = bbcur[a];
- bbcur[a] = ans + nw + (LINEWORDS);
- splx(s);
-
- bblast[a] = ans;
- return ans;
-}
-
-void
-bbfree(void *p, int n)
-{
- int a, s;
-
- s = splhi();
- a = INTLEVEL(s)? 1 : 0;
- if(p == bblast[a])
- bbcur[a] = (ulong *)(((char *)bblast[a]) + n + LINEWORDS*sizeof(long));
- splx(s);
-}
-
-int
-bbonstack(void)
-{
- /*if(u)
- return 1;*/
- return 0;
-}
-
-void
-bbexec(void (*memstart)(void), int len, int onstack)
-{
- memstart();
- if(onstack)
- return;
- bbfree(memstart, len);
-}
M pc/devconfig.c => pc/devconfig.c +0 -1
@@ 7,7 7,6 @@
#include "../port/error.h"
#include <libg.h>
-#include <gnot.h>
#include "devtab.h"
#include "vga.h"
M pc/devhard.c => pc/devhard.c +9 -7
@@ 993,6 993,15 @@ hardintr(Ureg *ur, void *arg)
break;
case Cread:
case Cident:
+ loop = 0;
+ while((cp->status & (Serr|Sdrq)) == 0){
+ if(++loop > 10000) {
+ DPRINT("cmd=%lux status=%lux\n",
+ cp->cmd, inb(cp->pbase+Pstatus));
+ panic("hardintr: read/ident");
+ }
+ cp->status = inb(cp->pbase+Pstatus);
+ }
if(cp->status & Serr){
cp->lastcmd = cp->cmd;
cp->cmd = 0;
@@ 1000,13 1009,6 @@ hardintr(Ureg *ur, void *arg)
wakeup(&cp->r);
return;
}
- loop = 0;
- while((inb(cp->pbase+Pstatus) & Sdrq) == 0)
- if(++loop > 10000) {
- DPRINT("cmd=%lux status=%lux\n",
- cp->cmd, inb(cp->pbase+Pstatus));
- panic("hardintr: read/ident");
- }
addr = cp->buf;
if(addr){
addr += cp->sofar*dp->bytes;
M pc/devvga.c => pc/devvga.c +27 -29
@@ 7,7 7,6 @@
#include "../port/error.h"
#include <libg.h>
-#include <gnot.h>
enum
{
@@ 38,12 37,12 @@ enum
};
/* imported */
-extern GSubfont defont0;
+extern Subfont defont0;
extern Cursor arrow;
/* exported */
-GSubfont *defont;
-GBitmap gscreen;
+Subfont *defont;
+Bitmap gscreen;
/* vga screen */
static Lock screenlock;
@@ 55,7 54,7 @@ static int cga = 1; /* true if in cga mode */
/* system window */
static Rectangle window;
static int h, w;
-static Point cursor;
+static Point curpos;
/*
* screen dimensions
@@ 184,6 183,9 @@ static void scroll(void);
static ulong x3to32(uchar);
static ulong x6to32(uchar);
+extern void cursorlock(Rectangle);
+extern void cursorunlock(void);
+
/*
* vga device
*/
@@ 392,9 394,8 @@ screeninit(void)
/*
* swizzle the font longs.
*/
- defont = &defont0;
- l = defont->bits->base;
- for(i = defont->bits->width*Dy(defont->bits->r); i > 0; i--, l++)
+ l = defont0.bits->base;
+ for(i = defont0.bits->width*Dy(defont0.bits->r); i > 0; i--, l++)
*l = (*l<<24) | ((*l>>8)&0x0000ff00) | ((*l<<8)&0x00ff0000) | (*l>>24);
/*
@@ 498,9 499,9 @@ setscreen(int maxx, int maxy, int ldepth)
window.max = add(window.min, Pt(10+w*64, Footprint/(BY2WD*gscreen.width)));
vgacard->setpage(0);
- gbitblt(&gscreen, window.min, &gscreen, window, Zero);
+ bitblt(&gscreen, window.min, &gscreen, window, Zero);
window = inset(window, 5);
- cursor = window.min;
+ curpos = window.min;
window.max.y = window.min.y+((window.max.y-window.min.y)/h)*h;
hwcurs = 0;
}
@@ 570,8 571,6 @@ screenload(Rectangle r, uchar *data, int tl, int l, int dolock)
int y, lpart, rpart, mx, m, mr, page, sw;
ulong off;
uchar *q, *e;
- extern void cursorlock(Rectangle);
- extern void cursorunlock(void);
if(!rectclip(&r, gscreen.r) || tl<=0)
return;
@@ 580,7 579,7 @@ screenload(Rectangle r, uchar *data, int tl, int l, int dolock)
cursorlock(r);
lock(&screenlock);
- q = gbaddr(&gscreen, r.min);
+ q = byteaddr(&gscreen, r.min);
mx = 7>>gscreen.ldepth;
lpart = (r.min.x & mx) << gscreen.ldepth;
rpart = (r.max.x & mx) << gscreen.ldepth;
@@ 728,8 727,6 @@ screenunload(Rectangle r, uchar *data, int tl, int l, int dolock)
int y, lpart, rpart, mx, m, mr, page, sw;
ulong off;
uchar *q, *e;
- extern void cursorlock(Rectangle);
- extern void cursorunlock(void);
if(!rectclip(&r, gscreen.r) || tl<=0)
return;
@@ 738,7 735,7 @@ screenunload(Rectangle r, uchar *data, int tl, int l, int dolock)
cursorlock(r);
lock(&screenlock);
- q = gbaddr(&gscreen, r.min);
+ q = byteaddr(&gscreen, r.min);
mx = 7>>gscreen.ldepth;
lpart = (r.min.x & mx) << gscreen.ldepth;
rpart = (r.max.x & mx) << gscreen.ldepth;
@@ 1072,12 1069,13 @@ scroll(void)
int o;
Rectangle r;
+ o = 2*h;
vgacard->setpage(0);
- r = Rpt(Pt(window.min.x, window.max.y+h), window.max);
- gbitblt(&gscreen, window.min, &gscreen, r, S);
+ r = Rpt(Pt(window.min.x, window.min.y+o), window.max);
+ bitblt(&gscreen, window.min, &gscreen, r, S);
r = Rpt(Pt(window.min.x, window.max.y-o), window.max);
- gbitblt(&gscreen, r.min, &gscreen, r, Zero);
- cursor.y -= o;
+ bitblt(&gscreen, r.min, &gscreen, r, Zero);
+ curpos.y -= o;
}
static void
@@ 1087,28 1085,28 @@ screenputc(char *buf)
switch(buf[0]) {
case '\n':
- if(cursor.y+h >= window.max.y)
+ if(curpos.y+h >= window.max.y)
scroll();
- cursor.y += h;
+ curpos.y += h;
screenputc("\r");
break;
case '\r':
- cursor.x = window.min.x;
+ curpos.x = window.min.x;
break;
case '\t':
- pos = (cursor.x-window.min.x)/w;
+ pos = (curpos.x-window.min.x)/w;
pos = 8-(pos%8);
- cursor.x += pos*w;
+ curpos.x += pos*w;
break;
case '\b':
- if(cursor.x-w >= window.min.x)
- cursor.x -= w;
+ if(curpos.x-w >= window.min.x)
+ curpos.x -= w;
break;
default:
- if(cursor.x >= window.max.x-w)
+ if(curpos.x >= window.max.x-w)
screenputc("\n");
- cursor = gsubfstring(&gscreen, cursor, &defont0, buf, S);
+ curpos = subfstring(&gscreen, curpos, &defont0, buf, S);
}
}
M pc/kbd.c => pc/kbd.c +0 -1
@@ 7,7 7,6 @@
#include "../port/error.h"
#include <libg.h>
-#include <gnot.h>
enum {
Data= 0x60, /* data port */
M port/devcons.c => port/devcons.c +13 -0
@@ 120,6 120,19 @@ print(char *fmt, ...)
}
int
+fprint(int fd, char *fmt, ...) /* needed so we can use user-level libg */
+{
+ char buf[PRINTSIZE];
+ int n;
+
+ USED(fd);
+ n = doprint(buf, buf+sizeof(buf), fmt, (&fmt+1)) - buf;
+ putstrn(buf, n);
+
+ return n;
+}
+
+int
kprint(char *fmt, ...)
{
char buf[PRINTSIZE];
M port/devmouse.c => port/devmouse.c +91 -46
@@ 1,7 1,6 @@
#include "u.h"
#include "../port/lib.h"
#include <libg.h>
-#include <gnot.h>
#include "mem.h"
#include "dat.h"
#include "fns.h"
@@ 57,6 56,12 @@ struct Cursorinfo
int disable; /* from being used */
int frozen; /* from being used */
Rectangle r; /* location */
+
+ int l;
+ int tl;
+ int setop;
+ int clrop;
+ Rectangle clipr;
};
Mouseinfo mouse;
@@ 83,47 88,37 @@ Cursor arrow =
};
ulong setbits[16];
-GBitmap set =
+Bitmap set =
{
- setbits,
+ {0, 0, 16, 16},
+ {0, 0, 16, 16},
0,
+ setbits,
1,
0,
- {0, 0, 16, 16},
- {0, 0, 16, 16}
};
ulong clrbits[16];
-GBitmap clr =
+Bitmap clr =
{
- clrbits,
- 0,
- 1,
- 0,
{0, 0, 16, 16},
- {0, 0, 16, 16}
-};
-
-ulong cursorbackbits[16*4];
-GBitmap cursorback =
-{
- cursorbackbits,
+ {0, 0, 16, 16},
0,
+ clrbits,
1,
0,
- {0, 0, 16, 16},
- {0, 0, 16, 16}
};
-ulong cursorworkbits[16*4];
-GBitmap cursorwork =
+ulong backbits[16*5];
+ulong workbits[16*5];
+Bitmap cursorwork =
{
- cursorworkbits,
+ {0, 0, 16+8, 16},
+ {0, 0, 16+8, 16},
0,
+ workbits,
1,
0,
- {0, 0, 16, 16},
- {0, 0, 16, 16}
};
void Cursortocursor(Cursor*);
@@ 147,7 142,7 @@ Dirtab mousedir[]={
#define NMOUSE (sizeof(mousedir)/sizeof(Dirtab))
-extern GBitmap gscreen;
+extern Bitmap gscreen;
void
mousereset(void)
@@ 166,19 161,35 @@ mousereset(void)
}
void
+cursorinit(void)
+{
+ cursorwork.ldepth = gscreen.ldepth;
+ cursorwork.width = ((cursorwork.r.max.x << gscreen.ldepth) + 31) >> 5;
+
+ cursor.l = cursorwork.width*BY2WD;
+
+ if(flipping){
+ cursor.setop = flipD[S|D];
+ cursor.clrop = flipD[D&~S];
+ } else {
+ cursor.setop = S|D;
+ cursor.clrop = D&~S;
+ }
+}
+
+void
mouseinit(void)
{
if(!conf.monitor)
return;
+
if(gscreen.ldepth > 3){
- cursorback.ldepth = 0;
- cursorwork.ldepth = 0;
- }else{
- cursorback.ldepth = gscreen.ldepth;
- cursorback.width = ((16 << gscreen.ldepth) + 31) >> 5;
- cursorwork.ldepth = gscreen.ldepth;
- cursorwork.width = ((16 << gscreen.ldepth) + 31) >> 5;
+ print("mouse can't work ldepth > 3");
+ cursor.disable = 1;
}
+
+ cursorinit();
+
cursoron(1);
}
@@ 187,6 198,7 @@ mouseattach(char *spec)
{
if(!conf.monitor)
error(Egreg);
+ cursorinit();
return devattach('m', spec);
}
@@ 437,9 449,24 @@ cursorunlock(void)
unlock(&cursor);
}
+typedef struct
+{
+ Bitmap *dm;
+ Point p;
+ Bitmap *sm;
+ Rectangle r;
+ Fcode f;
+} XXX;
+
void
cursoron(int dolock)
{
+ int off;
+ Rectangle r;
+ uchar *a;
+ XXX x;
+ extern int graphicssubtile(uchar*, int, int, Rectangle, Rectangle, uchar**);
+
if(cursor.disable)
return;
if(dolock)
@@ 451,15 478,36 @@ cursoron(int dolock)
cursor.r.min = mouse.xy;
cursor.r.max = add(mouse.xy, Pt(16, 16));
cursor.r = raddp(cursor.r, cursor.offset);
- screenunload(cursor.r, (uchar*)cursorworkbits,
- (16>>3) << gscreen.ldepth, cursorwork.width*BY2WD, 0);
- memmove(cursorbackbits, cursorworkbits, 16*cursorback.width*BY2WD);
- gbitblt(&cursorwork, cursorwork.r.min,
- &clr, Rect(0, 0, 16, 16), flipping? flipD[D&~S] : D&~S);
- gbitblt(&cursorwork, cursorwork.r.min,
- &set, Rect(0, 0, 16, 16), flipping? flipD[S|D] : S|D);
- screenload(cursor.r, (uchar*)cursorworkbits,
- (16>>3) << gscreen.ldepth, cursorwork.width*BY2WD, 0);
+
+ /* bit offset into backup area */
+ off = ((1<<gscreen.ldepth)*cursor.r.min.x) & 7;
+
+ /* clip the cursor rectangle */
+ x.dm = &cursorwork;
+ x.p = Pt(off, 0);
+ x.sm = &gscreen;
+ x.r = cursor.r;
+ bitbltclip(&x);
+
+ /* tile width */
+ cursor.tl = graphicssubtile(0, cursor.l, gscreen.ldepth,
+ gscreen.r, x.r, &a);
+ if(cursor.tl > 0){
+ /* get tile */
+ screenunload(x.r, (uchar*)workbits, cursor.tl, cursor.l, 0);
+
+ /* save for cursoroff */
+ memmove(backbits, workbits, cursor.l*16);
+
+ /* add mouse into work area */
+ r = Rect(0, 0, Dx(x.r), Dy(x.r));
+ bitblt(&cursorwork, x.p, &clr, r, cursor.clrop);
+ bitblt(&cursorwork, x.p, &set, r, cursor.setop);
+
+ /* put back tile */
+ cursor.clipr = x.r;
+ screenload(x.r, (uchar*)workbits, cursor.tl, cursor.l, 0);
+ }
}
}
if(dolock)
@@ 473,11 521,8 @@ cursoroff(int dolock)
return;
if(dolock)
lock(&cursor);
- if(--cursor.visible == 0) {
- if(!hwcurs)
- screenload(cursor.r, (uchar*)cursorbackbits,
- (16>>3) << gscreen.ldepth, cursorback.width*BY2WD, 0);
- }
+ if(--cursor.visible == 0 && !hwcurs && cursor.tl > 0)
+ screenload(cursor.clipr, (uchar*)backbits, cursor.tl, cursor.l, 0);
if(dolock)
unlock(&cursor);
}