hlfw.ca

x9dev

Download patch

ref: a1500f0da30314afbdad648f2324f51fea1625e6
parent: 294895f1868c8bbf9e14654655563fb737d82696
author: Michael Misch <michealmisch1985@gmail.com>
date: Tue Jul 27 12:18:48 PDT 2021

Make it build again

--- /dev/null
+++ b/draw/alloc.c
@@ -1,0 +1,224 @@
+
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include "draw.h"
+
+Image*
+allocimage(Display *d, Rectangle r, ulong chan, int repl, ulong col)
+{
+	Image *i;
+
+	i = _allocimage(nil, d, r, chan, repl, col, 0, 0);
+	return i;
+}
+
+Image*
+_allocimage(Image *ai, Display *d, Rectangle r, ulong chan, int repl, ulong col, int screenid, int refresh)
+{
+	uchar *a;
+	char *err;
+	Image *i;
+	Rectangle clipr;
+	int id;
+	int depth;
+
+	err = nil;
+	i = nil;
+
+	if(badrect(r)){
+		return nil;
+	}
+	if(chan == 0){
+		return nil;
+	}
+
+	depth = chantodepth(chan);
+	if(depth == 0){
+    Error:
+		free(i);
+		return nil;
+	}
+
+	a = bufimage(d, 1+4+4+1+4+1+4*4+4*4+4);
+	if(a == nil)
+		goto Error;
+	d->imageid++;
+	id = d->imageid;
+	a[0] = 'b';
+	BPLONG(a+1, id);
+	BPLONG(a+5, screenid);
+	a[9] = refresh;
+	BPLONG(a+10, chan);
+	a[14] = repl;
+	BPLONG(a+15, r.min.x);
+	BPLONG(a+19, r.min.y);
+	BPLONG(a+23, r.max.x);
+	BPLONG(a+27, r.max.y);
+	if(repl)
+		/* huge but not infinite, so various offsets will leave it huge, not overflow */
+		clipr = Rect(-0x3FFFFFFF, -0x3FFFFFFF, 0x3FFFFFFF, 0x3FFFFFFF);
+	else
+		clipr = r;
+	BPLONG(a+31, clipr.min.x);
+	BPLONG(a+35, clipr.min.y);
+	BPLONG(a+39, clipr.max.x);
+	BPLONG(a+43, clipr.max.y);
+	BPLONG(a+47, col);
+
+	if(ai != nil)
+		i = ai;
+	else{
+		i = malloc(sizeof(Image));
+		if(i == nil){
+			a = bufimage(d, 1+4);
+			if(a != nil){
+				a[0] = 'f';
+				BPLONG(a+1, id);
+				flushimage(d, 0);
+			}
+			goto Error;
+		}
+	}
+	i->display = d;
+	i->id = id;
+	i->depth = depth;
+	i->chan = chan;
+	i->r = r;
+	i->clipr = clipr;
+	i->repl = repl;
+	i->screen = nil;
+	i->next = nil;
+	return i;
+}
+
+Image*
+namedimage(Display *d, char *name)
+{
+	uchar *a;
+	char *err, buf[12*12+1];
+	Image *i;
+	int id, n;
+	ulong chan;
+
+	err = nil;
+	i = nil;
+
+	n = strlen(name);
+	if(n >= 256){
+    Error:
+		free(i);
+		return nil;
+	}
+	/* flush pending data so we don't get error allocating the image */
+	flushimage(d, 0);
+	a = bufimage(d, 1+4+1+n);
+	if(a == nil)
+		goto Error;
+	d->imageid++;
+	id = d->imageid;
+	a[0] = 'n';
+	BPLONG(a+1, id);
+	a[5] = n;
+	memmove(a+6, name, n);
+	if(flushimage(d, 0) < 0)
+		goto Error;
+
+	lseek(d->ctlfd, 0, SEEK_SET);
+	if(read(d->ctlfd, buf, sizeof buf) < 12*12)
+		goto Error;
+	buf[12*12] = '\0';
+
+	i = malloc(sizeof(Image));
+	if(i == nil){
+	Error1:
+		a = bufimage(d, 1+4);
+		if(a != nil){
+			a[0] = 'f';
+			BPLONG(a+1, id);
+			flushimage(d, 0);
+		}
+		goto Error;
+	}
+	i->display = d;
+	i->id = id;
+	if((chan=strtochan(buf+2*12))==0){
+		goto Error1;
+	}
+	i->chan = chan;
+	i->depth = chantodepth(chan);
+	i->repl = atoi(buf+3*12);
+	i->r.min.x = atoi(buf+4*12);
+	i->r.min.y = atoi(buf+5*12);
+	i->r.max.x = atoi(buf+6*12);
+	i->r.max.y = atoi(buf+7*12);
+	i->clipr.min.x = atoi(buf+8*12);
+	i->clipr.min.y = atoi(buf+9*12);
+	i->clipr.max.x = atoi(buf+10*12);
+	i->clipr.max.y = atoi(buf+11*12);
+	i->screen = nil;
+	i->next = nil;
+	return i;
+}
+
+int
+nameimage(Image *i, char *name, int in)
+{
+	uchar *a;
+	int n;
+
+	n = strlen(name);
+	a = bufimage(i->display, 1+4+1+1+n);
+	if(a == nil)
+		return 0;
+	a[0] = 'N';
+	BPLONG(a+1, i->id);
+	a[5] = in;
+	a[6] = n;
+	memmove(a+7, name, n);
+	if(flushimage(i->display, 0) < 0)
+		return 0;
+	return 1;
+}
+
+int
+_freeimage1(Image *i)
+{
+	uchar *a;
+	Display *d;
+	Image *w;
+
+	if(i == nil || i->display == nil)
+		return 0;
+	d = i->display;
+	if(i->screen != nil){
+		w = d->windows;
+		if(w == i)
+			d->windows = i->next;
+		else
+			while(w != nil){
+				if(w->next == i){
+					w->next = i->next;
+					break;
+				}
+				w = w->next;
+			}
+	}
+	a = bufimage(d, 1+4);
+	if(a == nil)
+		return -1;
+	a[0] = 'f';
+	BPLONG(a+1, i->id);
+	return 0;
+}
+
+int
+freeimage(Image *i)
+{
+	int ret;
+
+	ret = _freeimage1(i);
+	free(i);
+	return ret;
+}
--- /dev/null
+++ b/draw/arith.c
@@ -1,0 +1,183 @@
+#include "draw.h"
+
+Point
+Pt(int x, int y)
+{
+	Point p;
+
+	p.x = x;
+	p.y = y;
+	return p;
+}
+
+Rectangle
+Rect(int x, int y, int bx, int by)
+{
+	Rectangle r;
+
+	r.min.x = x;
+	r.min.y = y;
+	r.max.x = bx;
+	r.max.y = by;
+	return r;
+}
+
+Rectangle
+Rpt(Point min, Point max)
+{
+	Rectangle r;
+
+	r.min = min;
+	r.max = max;
+	return r;
+}
+
+Point
+addpt(Point a, Point b)
+{
+	a.x += b.x;
+	a.y += b.y;
+	return a;
+}
+
+Point
+subpt(Point a, Point b)
+{
+	a.x -= b.x;
+	a.y -= b.y;
+	return a;
+}
+
+Rectangle
+insetrect(Rectangle r, int n)
+{
+	r.min.x += n;
+	r.min.y += n;
+	r.max.x -= n;
+	r.max.y -= n;
+	return r;
+}
+
+Point
+divpt(Point a, int b)
+{
+	a.x /= b;
+	a.y /= b;
+	return a;
+}
+
+Point
+mulpt(Point a, int b)
+{
+	a.x *= b;
+	a.y *= b;
+	return a;
+}
+
+Rectangle
+rectsubpt(Rectangle r, Point p)
+{
+	r.min.x -= p.x;
+	r.min.y -= p.y;
+	r.max.x -= p.x;
+	r.max.y -= p.y;
+	return r;
+}
+
+Rectangle
+rectaddpt(Rectangle r, Point p)
+{
+	r.min.x += p.x;
+	r.min.y += p.y;
+	r.max.x += p.x;
+	r.max.y += p.y;
+	return r;
+}
+
+int
+eqpt(Point p, Point q)
+{
+	return p.x==q.x && p.y==q.y;
+}
+
+int
+eqrect(Rectangle r, Rectangle s)
+{
+	return r.min.x==s.min.x && r.max.x==s.max.x &&
+	       r.min.y==s.min.y && r.max.y==s.max.y;
+}
+
+int
+rectXrect(Rectangle r, Rectangle s)
+{
+	return r.min.x<s.max.x && s.min.x<r.max.x &&
+	       r.min.y<s.max.y && s.min.y<r.max.y;
+}
+
+int
+rectinrect(Rectangle r, Rectangle s)
+{
+	return s.min.x<=r.min.x && r.max.x<=s.max.x && s.min.y<=r.min.y && r.max.y<=s.max.y;
+}
+
+int
+ptinrect(Point p, Rectangle r)
+{
+	return p.x>=r.min.x && p.x<r.max.x &&
+	       p.y>=r.min.y && p.y<r.max.y;
+}
+
+Rectangle
+canonrect(Rectangle r)
+{
+	int t;
+	if (r.max.x < r.min.x) {
+		t = r.min.x;
+		r.min.x = r.max.x;
+		r.max.x = t;
+	}
+	if (r.max.y < r.min.y) {
+		t = r.min.y;
+		r.min.y = r.max.y;
+		r.max.y = t;
+	}
+	return r;
+}
+
+void
+combinerect(Rectangle *r1, Rectangle r2)
+{
+	if(r1->min.x > r2.min.x)
+		r1->min.x = r2.min.x;
+	if(r1->min.y > r2.min.y)
+		r1->min.y = r2.min.y;
+	if(r1->max.x < r2.max.x)
+		r1->max.x = r2.max.x;
+	if(r1->max.y < r2.max.y)
+		r1->max.y = r2.max.y;
+}
+
+ulong drawld2chan[] = {
+	GREY1,
+	GREY2,
+	GREY4,
+	CMAP8,
+};
+
+ulong
+setalpha(ulong color, uchar alpha)
+{
+	int red, green, blue;
+
+	red = (color >> 3*8) & 0xFF;
+	green = (color >> 2*8) & 0xFF;
+	blue = (color >> 1*8) & 0xFF;
+	/* ignore incoming alpha */
+	red = (red * alpha)/255;
+	green = (green * alpha)/255;
+	blue = (blue * alpha)/255;
+	return (red<<3*8) | (green<<2*8) | (blue<<1*8) | (alpha<<0*8);
+}
+
+Point	ZP;
+Rectangle ZR;
--- /dev/null
+++ b/draw/badrect.c
@@ -1,0 +1,20 @@
+#include "draw.h"
+
+/*
+ * check for zero, negative size or insanely huge rectangle.
+ */
+int
+badrect(Rectangle r)
+{
+	int x, y;
+	unsigned int z;
+
+	x = Dx(r);
+	y = Dy(r);
+	if(x > 0 && y > 0){
+		z = x*y;
+		if(z/x == y && z < 0x10000000)
+			return 0;
+	}
+	return 1;
+}
--- /dev/null
+++ b/draw/buildfont.c
@@ -1,0 +1,136 @@
+#include <stdlib.h>
+#include <string.h>
+#include "draw.h"
+
+static char*
+skip(char *s)
+{
+	while(*s==' ' || *s=='\n' || *s=='\t')
+		s++;
+	return s;
+}
+
+_Font*
+buildfont(Display *d, char *buf, char *name)
+{
+	_Font *fnt;
+	Cachefont *c, **sub;
+	char *s, *t;
+	ulong min, max;
+	int offset;
+	char badform[] = "bad font format: number expected (char position %d)";
+
+	s = buf;
+	fnt = malloc(sizeof(_Font));
+	if(fnt == nil)
+		return nil;
+	memset(fnt, 0, sizeof(_Font));
+	fnt->display = d;
+	fnt->name = strdup(name);
+	fnt->ncache = NFCACHE+NFLOOK;
+	fnt->nsubf = NFSUBF;
+	fnt->cache = malloc(fnt->ncache * sizeof(fnt->cache[0]));
+	fnt->subf = malloc(fnt->nsubf * sizeof(fnt->subf[0]));
+	if(fnt->name==nil || fnt->cache==nil || fnt->subf==nil){
+    Err2:
+		free(fnt->name);
+		free(fnt->cache);
+		free(fnt->subf);
+		free(fnt->sub);
+		free(fnt);
+		return nil;
+	}
+	fnt->height = strtol(s, &s, 0);
+	s = skip(s);
+	fnt->ascent = strtol(s, &s, 0);
+	s = skip(s);
+	if(fnt->height<=0 || fnt->ascent<=0){
+		goto Err2;
+	}
+	fnt->width = 0;
+	fnt->nsub = 0;
+	fnt->sub = nil;
+
+	memset(fnt->subf, 0, fnt->nsubf * sizeof(fnt->subf[0]));
+	memset(fnt->cache, 0, fnt->ncache*sizeof(fnt->cache[0]));
+	fnt->age = 1;
+	do{
+		/* must be looking at a number now */
+		if(*s<'0' || '9'<*s){
+			goto Err3;
+		}
+		min = strtol(s, &s, 0);
+		s = skip(s);
+		/* must be looking at a number now */
+		if(*s<'0' || '9'<*s){
+			goto Err3;
+		}
+		max = strtol(s, &s, 0);
+		s = skip(s);
+		if(*s==0 || min>Runemax || max>Runemax || min>max){
+    Err3:
+			freefont(fnt);
+			return 0;
+		}
+		t = s;
+		offset = strtol(s, &t, 0);
+		if(t>s && (*t==' ' || *t=='\t' || *t=='\n'))
+			s = skip(t);
+		else
+			offset = 0;
+		sub = realloc(fnt->sub, (fnt->nsub+1)*sizeof(Cachefont*));
+		if(sub == nil)
+			goto Err3;
+		fnt->sub = sub;
+		c = malloc(sizeof(Cachefont));
+		if(c == nil)
+			goto Err3;
+		c->min = min;
+		c->max = max;
+		c->offset = offset;
+		t = s;
+		while(*s && *s!=' ' && *s!='\n' && *s!='\t')
+			s++;
+		*s++ = 0;
+		c->subfontname = nil;
+		c->name = strdup(t);
+		if(c->name == nil){
+			free(c);
+			goto Err3;
+		}
+		sub[fnt->nsub++] = c;
+		s = skip(s);
+	}while(*s);
+	return fnt;
+}
+
+void
+freefont(_Font *f)
+{
+	int i;
+	Cachefont *c;
+	Subfont *s;
+
+	if(f == nil)
+		return;
+
+	for(i=0; i<f->nsub; i++){
+		c = f->sub[i];
+		free(c->subfontname);
+		free(c->name);
+		free(c);
+	}
+	for(i=0; i<f->nsubf; i++){
+		s = f->subf[i].f;
+		if(s != nil){
+			if(f->display == nil || s != f->display->defaultsubfont)
+				freesubfont(s);
+		}
+	}
+	freeimage(f->cacheimage);
+	free(f->name);
+	free(f->cache);
+	free(f->subf);
+	free(f->sub);
+	free(f);
+}
--- /dev/null
+++ b/draw/bytesperline.c
@@ -1,0 +1,33 @@
+/* From 9front */
+#include <stdlib.h>
+#include "draw.h"
+
+static int
+unitsperline(Rectangle r, int d, int bitsperunit)
+{
+	ulong l, t;
+
+	if(d <= 0 || d > 32)	/* being called wrong.  d is image depth. */
+		abort();
+
+	if(r.min.x >= 0){
+		l = (r.max.x*d+bitsperunit-1)/bitsperunit;
+		l -= (r.min.x*d)/bitsperunit;
+	}else{			/* make positive before divide */
+		t = (-r.min.x*d+bitsperunit-1)/bitsperunit;
+		l = t+(r.max.x*d+bitsperunit-1)/bitsperunit;
+	}
+	return l;
+}
+
+int
+wordsperline(Rectangle r, int d)
+{
+	return unitsperline(r, d, 8*sizeof(ulong));
+}
+
+int
+bytesperline(Rectangle r, int d)
+{
+	return unitsperline(r, d, 8);
+}
\ No newline at end of file
--- /dev/null
+++ b/draw/chan.c
@@ -1,0 +1,80 @@
+#include <string.h>
+#include "draw.h"
+
+static char channames[] = "rgbkamx";
+char*
+chantostr(char *buf, ulong cc)
+{
+	ulong c, rc;
+	char *p;
+
+	if(chantodepth(cc) == 0)
+		return nil;
+
+	/* reverse the channel descriptor so we can easily generate the string in the right order */
+	rc = 0;
+	for(c=cc; c; c>>=8){
+		rc <<= 8;
+		rc |= c&0xFF;
+	}
+
+	p = buf;
+	for(c=rc; c; c>>=8) {
+		*p++ = channames[TYPE(c)];
+		*p++ = '0'+NBITS(c);
+	}
+	*p = 0;
+
+	return buf;
+}
+
+/* avoid pulling in ctype when using with drawterm etc. */
+static int
+isspace(char c)
+{
+	return c==' ' || c== '\t' || c=='\r' || c=='\n';
+}
+
+ulong
+strtochan(char *s)
+{
+	char *p, *q;
+	ulong c;
+	int t, n, d;
+
+	c = 0;
+	d = 0;
+	p=s;
+	while(*p && isspace(*p))
+		p++;
+
+	while(*p && !isspace(*p)){
+		if((q = strchr(channames, p[0])) == nil) 
+			return 0;
+		t = q-channames;
+		if(p[1] < '0' || p[1] > '9')
+			return 0;
+		n = p[1]-'0';
+		d += n;
+		c = (c<<8) | __DC(t, n);
+		p += 2;
+	}
+	if(d==0 || (d>8 && d%8) || (d<8 && 8%d))
+		return 0;
+	return c;
+}
+
+int
+chantodepth(ulong c)
+{
+	int n;
+
+	for(n=0; c; c>>=8){
+		if(TYPE(c) >= NChan || NBITS(c) > 8 || NBITS(c) <= 0)
+			return 0;
+		n += NBITS(c);
+	}
+	if(n==0 || (n>8 && n%8) || (n<8 && 8%n))
+		return 0;
+	return n;
+}
--- /dev/null
+++ b/draw/defont.c
@@ -1,0 +1,386 @@
+#include "draw.h"
+
+/*
+ * vga/vga00, in uncompressed form
+ */
+uchar
+defontdata[] =
+{
+0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x30,0x20,0x20,0x20,0x20,0x20,
+0x20,0x20,0x20,0x20,0x20,0x20,0x30,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
+0x20,0x20,0x30,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x32,0x30,0x34,0x38,0x20,
+0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x31,0x36,0x20,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x30,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x0c,0x10,0x76,
+0x6c,0x38,0x00,0x00,0x30,0x0c,0x10,0x6c,0x30,0x0c,0x18,0x66,0x00,0x76,0x60,0x0c,
+0x10,0x76,0x6c,0x00,0x00,0x60,0x0c,0x10,0x6c,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0xe0,
+0xe0,0xe0,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xe0,0xe0,0xe0,
+0xe0,0x90,0x70,0xe0,0x70,0x00,0x70,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x66,0x00,
+0x18,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x30,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x38,
+0x00,0x00,0x00,0x7c,0x00,0x00,0x3c,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x70,0x70,
+0x00,0x00,0x00,0x00,0x00,0x30,0x38,0x00,0xc0,0xc0,0xe0,0x00,0x30,0x18,0x38,0xdc,
+0x6c,0x6c,0x00,0x00,0x18,0x18,0x38,0x6c,0x18,0x18,0x3c,0x66,0x00,0xdc,0x30,0x18,
+0x38,0xdc,0x6c,0x00,0x00,0x30,0x18,0x38,0x6c,0x18,0x00,0x00,0x00,0x00,0x10,0x00,
+0x00,0x38,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,
+0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0xda,0x00,0x80,0x80,
+0x80,0x80,0x90,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x90,0x90,0x90,0x90,
+0x90,0xd0,0x80,0x80,0x90,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x18,0x66,0x00,
+0x7c,0x00,0x38,0x30,0x0c,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x18,0x7c,0x7c,
+0x0c,0xfe,0x38,0xfe,0x7c,0x7c,0x00,0x00,0x00,0x00,0x00,0x7c,0x00,0x10,0xfc,0x3c,
+0xf8,0xfe,0xfe,0x3c,0xc6,0x3c,0x1e,0xe6,0xf0,0xc6,0xc6,0x7c,0xfc,0x7c,0xfc,0x7c,
+0x7e,0xc6,0xc6,0xc6,0xc6,0x66,0xfe,0x3c,0x00,0x3c,0x6c,0x00,0x18,0x00,0xe0,0x00,
+0x1c,0x00,0x38,0x00,0xe0,0x18,0x06,0xe0,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x0e,0x18,0x70,0x76,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x6c,
+0x00,0x66,0x18,0xc6,0x6c,0x3c,0x6c,0x00,0x00,0x00,0x38,0x00,0x6c,0x00,0xd8,0xd8,
+0x0c,0x00,0x7f,0x00,0x00,0x70,0x6c,0x00,0xc0,0xc0,0x30,0x30,0x00,0x00,0x6c,0x00,
+0x00,0x38,0x3e,0x3c,0x00,0x00,0x44,0x00,0x00,0x00,0x42,0x00,0xf8,0x00,0x00,0x00,
+0x44,0x00,0x00,0x00,0x7a,0x00,0x00,0x44,0x00,0x00,0xf0,0x3c,0x60,0x18,0x38,0x76,
+0x6c,0x6c,0x00,0x00,0x60,0x0c,0x38,0x6c,0x30,0x0c,0x38,0x66,0x76,0x76,0x60,0x0c,
+0x38,0x76,0x6c,0x00,0x00,0x60,0x18,0x38,0xcc,0x0c,0xe0,0x6c,0x02,0x00,0xe0,0xe0,
+0xe0,0xe0,0xf0,0x18,0x70,0x48,0x20,0x48,0x70,0x38,0x38,0x38,0x90,0x90,0x90,0x90,
+0x90,0xb0,0x60,0xe0,0x80,0xe0,0x60,0xe0,0x70,0x38,0x70,0x48,0x00,0x3c,0x66,0x6c,
+0xc6,0x00,0x6c,0x30,0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x6c,0x38,0xc6,0xc6,
+0x1c,0xc0,0x60,0xc6,0xc6,0xc6,0x00,0x00,0x06,0x00,0x60,0xc6,0x7c,0x38,0x66,0x66,
+0x6c,0x66,0x66,0x66,0xc6,0x18,0x0c,0x66,0x60,0xee,0xe6,0xc6,0x66,0xc6,0x66,0xc6,
+0x7e,0xc6,0xc6,0xc6,0xc6,0x66,0xc6,0x30,0x80,0x0c,0xc6,0x00,0x00,0x00,0x60,0x00,
+0x0c,0x00,0x6c,0x00,0x60,0x18,0x06,0x60,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x18,0xdc,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x3c,0x64,
+0x00,0x66,0x18,0x60,0x6c,0x42,0x6c,0x00,0x00,0x00,0x44,0x7c,0x6c,0x00,0x30,0x30,
+0x18,0x00,0xdb,0x00,0x00,0x30,0x6c,0x00,0xc2,0xc2,0x62,0x30,0x10,0x10,0x10,0x10,
+0x10,0x10,0x6c,0x66,0xfe,0xfe,0xfe,0xfe,0x3c,0x3c,0x3c,0x3c,0x6c,0xc6,0x7c,0x7c,
+0x7c,0x7c,0x7c,0x00,0xc4,0xc6,0xc6,0xc6,0xc6,0x66,0x60,0x66,0x30,0x30,0x6c,0xdc,
+0x6c,0x38,0x00,0x00,0x30,0x18,0x6c,0x6c,0x18,0x18,0x6c,0x66,0x1c,0xdc,0x30,0x18,
+0x6c,0xdc,0x6c,0x00,0x00,0x30,0x30,0x6c,0xcc,0x18,0x60,0x6c,0x80,0x00,0x10,0x80,
+0x80,0x80,0x90,0x3c,0x48,0x48,0x20,0x48,0x40,0x48,0x40,0x40,0x90,0x90,0x90,0x90,
+0x90,0x90,0x10,0x80,0x80,0x80,0x10,0x80,0x40,0x40,0x48,0x48,0x00,0x3c,0x24,0x6c,
+0xc2,0xc2,0x6c,0x20,0x30,0x0c,0x00,0x00,0x00,0x00,0x00,0x02,0xc6,0x78,0x06,0x06,
+0x3c,0xc0,0xc0,0x06,0xc6,0xc6,0x18,0x18,0x0c,0x00,0x30,0xc6,0xc6,0x6c,0x66,0xc2,
+0x66,0x62,0x62,0xc2,0xc6,0x18,0x0c,0x66,0x60,0xfe,0xf6,0xc6,0x66,0xc6,0x66,0xc6,
+0x5a,0xc6,0xc6,0xc6,0x6c,0x66,0x86,0x30,0xc0,0x0c,0x00,0x00,0x00,0x00,0x60,0x00,
+0x0c,0x00,0x64,0x00,0x60,0x00,0x00,0x60,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x18,0x00,0x10,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x66,0x60,
+0x66,0x3c,0x18,0x38,0x00,0x99,0x3e,0x00,0x00,0x00,0xba,0x00,0x38,0x18,0x60,0x18,
+0x00,0x00,0xdb,0x00,0x00,0x30,0x38,0x00,0xc6,0xc6,0x36,0x00,0x38,0x38,0x38,0x38,
+0x38,0x38,0xcc,0xc2,0x66,0x66,0x66,0x66,0x18,0x18,0x18,0x18,0x66,0xe6,0xc6,0xc6,
+0xc6,0xc6,0xc6,0x00,0xce,0xc6,0xc6,0xc6,0xc6,0x66,0x7c,0x66,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3c,0x00,0x00,0x00,
+0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x82,0x00,0xe0,0xe0,
+0xe0,0xe0,0x90,0x3c,0x70,0x78,0x20,0x48,0x70,0x40,0x30,0x30,0xe0,0xe0,0xe0,0xe0,
+0xe0,0x90,0xe0,0xe0,0x70,0xe0,0xe0,0xe0,0x70,0x58,0x70,0x48,0x00,0x3c,0x00,0xfe,
+0xc0,0xc6,0x38,0x00,0x30,0x0c,0x66,0x18,0x00,0x00,0x00,0x06,0xc6,0x18,0x0c,0x06,
+0x6c,0xc0,0xc0,0x06,0xc6,0xc6,0x18,0x18,0x18,0x7e,0x18,0x0c,0xc6,0xc6,0x66,0xc0,
+0x66,0x68,0x68,0xc0,0xc6,0x18,0x0c,0x6c,0x60,0xfe,0xfe,0xc6,0x66,0xc6,0x66,0x60,
+0x18,0xc6,0xc6,0xc6,0x7c,0x66,0x0c,0x30,0xe0,0x0c,0x00,0x00,0x00,0x78,0x78,0x7c,
+0x3c,0x7c,0x60,0x76,0x6c,0x38,0x0e,0x66,0x18,0xec,0xdc,0x7c,0xdc,0x76,0xdc,0x7c,
+0xfc,0xcc,0x66,0xc6,0xc6,0xc6,0xfe,0x18,0x18,0x18,0x00,0x38,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x60,0xf0,
+0x3c,0x18,0x18,0x6c,0x00,0xa5,0x00,0x36,0x00,0x00,0xb2,0x00,0x00,0x18,0xc8,0xd8,
+0x00,0xcc,0xdb,0x00,0x00,0x30,0x00,0xd8,0xcc,0xcc,0xec,0x30,0x6c,0x6c,0x6c,0x6c,
+0x6c,0x6c,0xcc,0xc0,0x62,0x62,0x62,0x62,0x18,0x18,0x18,0x18,0x66,0xf6,0xc6,0xc6,
+0xc6,0xc6,0xc6,0x66,0xce,0xc6,0xc6,0xc6,0xc6,0x66,0x66,0x66,0x78,0x78,0x78,0x78,
+0x78,0x78,0xcc,0x7c,0x7c,0x7c,0x7c,0x7c,0x38,0x38,0x38,0x38,0x06,0xdc,0x7c,0x7c,
+0x7c,0x7c,0x7c,0x18,0x7a,0xcc,0xcc,0xcc,0xcc,0xc6,0x7c,0xc6,0x02,0x00,0x1c,0x1c,
+0x18,0x24,0x1c,0x3c,0x48,0x48,0x20,0x30,0x40,0x40,0x08,0x08,0x10,0x1c,0x1c,0x1c,
+0x1c,0x0c,0x44,0x1c,0x0c,0x80,0x24,0x1c,0x40,0x48,0x50,0x48,0x00,0x18,0x00,0x6c,
+0x7c,0x0c,0x76,0x00,0x30,0x0c,0x3c,0x18,0x00,0x00,0x00,0x0c,0xd6,0x18,0x18,0x3c,
+0xcc,0xfc,0xfc,0x0c,0x7c,0x7e,0x00,0x00,0x30,0x00,0x0c,0x18,0xde,0xc6,0x7c,0xc0,
+0x66,0x78,0x78,0xc0,0xfe,0x18,0x0c,0x78,0x60,0xd6,0xde,0xc6,0x7c,0xc6,0x7c,0x38,
+0x18,0xc6,0xc6,0xd6,0x38,0x3c,0x18,0x30,0x70,0x0c,0x00,0x00,0x00,0x0c,0x6c,0xc6,
+0x6c,0xc6,0xf0,0xcc,0x76,0x18,0x06,0x6c,0x18,0xfe,0x66,0xc6,0x66,0xcc,0x76,0xc6,
+0x30,0xcc,0x66,0xc6,0x6c,0xc6,0xcc,0x70,0x00,0x0e,0x00,0x6c,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x60,0x60,
+0x66,0x7e,0x00,0xc6,0x00,0xa1,0x7e,0x6c,0xfe,0x00,0xaa,0x00,0x00,0x7e,0xf8,0x70,
+0x00,0xcc,0x7b,0x00,0x00,0x78,0x7c,0x6c,0x18,0x18,0x18,0x30,0xc6,0xc6,0xc6,0xc6,
+0xc6,0xc6,0xfe,0xc0,0x68,0x68,0x68,0x68,0x18,0x18,0x18,0x18,0xf6,0xfe,0xc6,0xc6,
+0xc6,0xc6,0xc6,0x3c,0xd6,0xc6,0xc6,0xc6,0xc6,0x3c,0x66,0x6c,0x0c,0x0c,0x0c,0x0c,
+0x0c,0x0c,0x76,0xc6,0xc6,0xc6,0xc6,0xc6,0x18,0x18,0x18,0x18,0x7e,0x66,0xc6,0xc6,
+0xc6,0xc6,0xc6,0x00,0xc4,0xcc,0xcc,0xcc,0xcc,0xc6,0x66,0xc6,0x80,0x00,0x08,0x08,
+0x24,0x34,0x24,0x3c,0x70,0x48,0x38,0x30,0x40,0x38,0x70,0x70,0x10,0x24,0x24,0x24,
+0x24,0x12,0x28,0x08,0x12,0xe0,0x24,0x20,0x40,0x38,0x48,0x30,0x00,0x18,0x00,0x6c,
+0x06,0x18,0xdc,0x00,0x30,0x0c,0xff,0x7e,0x00,0xfe,0x00,0x18,0xd6,0x18,0x30,0x06,
+0xfe,0x06,0xc6,0x18,0xc6,0x06,0x00,0x00,0x60,0x00,0x06,0x18,0xde,0xfe,0x66,0xc0,
+0x66,0x68,0x68,0xde,0xc6,0x18,0x0c,0x78,0x60,0xc6,0xce,0xc6,0x60,0xc6,0x6c,0x0c,
+0x18,0xc6,0xc6,0xd6,0x38,0x18,0x30,0x30,0x38,0x0c,0x00,0x00,0x00,0x7c,0x66,0xc0,
+0xcc,0xfe,0x60,0xcc,0x66,0x18,0x06,0x78,0x18,0xd6,0x66,0xc6,0x66,0xcc,0x66,0x60,
+0x30,0xcc,0x66,0xd6,0x38,0xc6,0x18,0x18,0x18,0x18,0x00,0xc6,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x60,0x60,
+0x66,0x18,0x18,0xc6,0x00,0xa1,0x00,0xd8,0x06,0x3c,0x44,0x00,0x00,0x18,0x00,0x00,
+0x00,0xcc,0x1b,0x00,0x00,0x00,0x00,0x36,0x30,0x30,0x30,0x60,0xc6,0xc6,0xc6,0xc6,
+0xc6,0xc6,0xcc,0xc0,0x78,0x78,0x78,0x78,0x18,0x18,0x18,0x18,0x66,0xde,0xc6,0xc6,
+0xc6,0xc6,0xc6,0x18,0xd6,0xc6,0xc6,0xc6,0xc6,0x18,0x66,0x66,0x7c,0x7c,0x7c,0x7c,
+0x7c,0x7c,0x36,0xc0,0xfe,0xfe,0xfe,0xfe,0x18,0x18,0x18,0x18,0xc6,0x66,0xc6,0xc6,
+0xc6,0xc6,0xc6,0x7e,0xce,0xcc,0xcc,0xcc,0xcc,0xc6,0x66,0xc6,0x82,0x00,0x08,0x08,
+0x24,0x2c,0x20,0x66,0x07,0x07,0x07,0x07,0x0e,0x00,0x06,0x07,0x10,0x20,0x20,0x20,
+0x20,0x1e,0x10,0x08,0x1e,0x11,0x24,0x18,0x0e,0x07,0x07,0x07,0x00,0x18,0x00,0x6c,
+0x06,0x30,0xcc,0x00,0x30,0x0c,0x3c,0x18,0x00,0x00,0x00,0x30,0xc6,0x18,0x60,0x06,
+0x0c,0x06,0xc6,0x30,0xc6,0x06,0x00,0x00,0x30,0x7e,0x0c,0x18,0xde,0xc6,0x66,0xc0,
+0x66,0x60,0x60,0xc6,0xc6,0x18,0xcc,0x6c,0x60,0xc6,0xc6,0xc6,0x60,0xc6,0x66,0x06,
+0x18,0xc6,0xc6,0xd6,0x7c,0x18,0x60,0x30,0x1c,0x0c,0x00,0x00,0x00,0xcc,0x66,0xc0,
+0xcc,0xc0,0x60,0xcc,0x66,0x18,0x06,0x78,0x18,0xd6,0x66,0xc6,0x66,0xcc,0x60,0x38,
+0x30,0xcc,0x66,0xd6,0x38,0xc6,0x30,0x18,0x18,0x18,0x00,0xc6,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3c,0x66,0x60,
+0x66,0x7e,0x18,0x6c,0x00,0xa5,0x00,0x6c,0x06,0x00,0x38,0x00,0x00,0x18,0x00,0x00,
+0x00,0xcc,0x1b,0x18,0x00,0x00,0x00,0x6c,0x66,0x60,0x66,0xc0,0xfe,0xfe,0xfe,0xfe,
+0xfe,0xfe,0xcc,0xc0,0x68,0x68,0x68,0x68,0x18,0x18,0x18,0x18,0x66,0xce,0xc6,0xc6,
+0xc6,0xc6,0xc6,0x3c,0xe6,0xc6,0xc6,0xc6,0xc6,0x18,0x66,0x66,0xcc,0xcc,0xcc,0xcc,
+0xcc,0xcc,0x7e,0xc0,0xc0,0xc0,0xc0,0xc0,0x18,0x18,0x18,0x18,0xc6,0x66,0xc6,0xc6,
+0xc6,0xc6,0xc6,0x00,0xd6,0xcc,0xcc,0xcc,0xcc,0xc6,0x66,0xc6,0x02,0x00,0x08,0x08,
+0x24,0x24,0x20,0xc3,0x08,0x02,0x04,0x02,0x08,0x0e,0x09,0x02,0x10,0x20,0x20,0x20,
+0x20,0x12,0x10,0x08,0x12,0x1b,0x24,0x04,0x10,0x08,0x08,0x08,0x00,0x00,0x00,0xfe,
+0x86,0x60,0xcc,0x00,0x30,0x0c,0x66,0x18,0x18,0x00,0x00,0x60,0xc6,0x18,0xc0,0x06,
+0x0c,0x06,0xc6,0x30,0xc6,0x06,0x18,0x18,0x18,0x00,0x18,0x00,0xdc,0xc6,0x66,0xc2,
+0x66,0x62,0x60,0xc6,0xc6,0x18,0xcc,0x66,0x62,0xc6,0xc6,0xc6,0x60,0xd6,0x66,0xc6,
+0x18,0xc6,0x6c,0xfe,0x6c,0x18,0xc2,0x30,0x0e,0x0c,0x00,0x00,0x00,0xcc,0x66,0xc0,
+0xcc,0xc0,0x60,0xcc,0x66,0x18,0x06,0x6c,0x18,0xd6,0x66,0xc6,0x66,0xcc,0x60,0x0c,
+0x30,0xcc,0x66,0xd6,0x38,0xc6,0x60,0x18,0x18,0x18,0x00,0xc6,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3c,0x3c,0x60,
+0x3c,0x18,0x18,0x38,0x00,0x99,0x00,0x36,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0xcc,0x1b,0x00,0x00,0x00,0x00,0xd8,0xce,0xdc,0xce,0xc6,0xc6,0xc6,0xc6,0xc6,
+0xc6,0xc6,0xcc,0xc2,0x62,0x62,0x62,0x62,0x18,0x18,0x18,0x18,0x66,0xc6,0xc6,0xc6,
+0xc6,0xc6,0xc6,0x66,0xe6,0xc6,0xc6,0xc6,0xc6,0x18,0x7c,0x66,0xcc,0xcc,0xcc,0xcc,
+0xcc,0xcc,0xd8,0xc0,0xc0,0xc0,0xc0,0xc0,0x18,0x18,0x18,0x18,0xc6,0x66,0xc6,0xc6,
+0xc6,0xc6,0xc6,0x18,0xe6,0xcc,0xcc,0xcc,0xcc,0xc6,0x66,0xc6,0x80,0x00,0x08,0x08,
+0x18,0x24,0x1c,0xff,0x06,0x02,0x07,0x02,0x0e,0x09,0x09,0x02,0x1c,0x1c,0x1c,0x1c,
+0x1c,0x12,0x10,0x08,0x12,0x15,0x18,0x38,0x0c,0x06,0x06,0x06,0x00,0x18,0x00,0x6c,
+0xc6,0xc6,0xcc,0x00,0x18,0x18,0x00,0x00,0x18,0x00,0x18,0xc0,0x6c,0x18,0xc6,0xc6,
+0x0c,0xc6,0xc6,0x30,0xc6,0x0c,0x18,0x18,0x0c,0x00,0x30,0x18,0xc0,0xc6,0x66,0x66,
+0x6c,0x66,0x60,0x66,0xc6,0x18,0xcc,0x66,0x66,0xc6,0xc6,0xc6,0x60,0xde,0x66,0xc6,
+0x18,0xc6,0x38,0xee,0xc6,0x18,0xc6,0x30,0x06,0x0c,0x00,0x00,0x00,0xcc,0x66,0xc6,
+0xcc,0xc6,0x60,0xcc,0x66,0x18,0x06,0x66,0x18,0xd6,0x66,0xc6,0x66,0xcc,0x60,0xc6,
+0x36,0xcc,0x3c,0xfe,0x6c,0xc6,0xc6,0x18,0x18,0x18,0x00,0xfe,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3c,0x18,0xe6,
+0x66,0x18,0x18,0x0c,0x00,0x42,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x7e,0x00,0x00,
+0x00,0xcc,0x1b,0x00,0x00,0x00,0x00,0x00,0x9e,0x86,0x9e,0xc6,0xc6,0xc6,0xc6,0xc6,
+0xc6,0xc6,0xcc,0x66,0x66,0x66,0x66,0x66,0x18,0x18,0x18,0x18,0x6c,0xc6,0xc6,0xc6,
+0xc6,0xc6,0xc6,0x00,0x46,0xc6,0xc6,0xc6,0xc6,0x18,0x60,0x66,0xcc,0xcc,0xcc,0xcc,
+0xcc,0xcc,0xd8,0xc6,0xc6,0xc6,0xc6,0xc6,0x18,0x18,0x18,0x18,0xc6,0x66,0xc6,0xc6,
+0xc6,0xc6,0xc6,0x18,0x46,0xcc,0xcc,0xcc,0xcc,0xc6,0x66,0xc6,0xb6,0x00,0x05,0x05,
+0x07,0x0c,0x09,0x18,0x01,0x02,0x04,0x02,0x08,0x0e,0x09,0x02,0x07,0x02,0x06,0x06,
+0x02,0x09,0x09,0x0e,0x09,0x15,0x0e,0x07,0x02,0x01,0x01,0x01,0x00,0x18,0x00,0x6c,
+0x7c,0x86,0x76,0x00,0x0c,0x30,0x00,0x00,0x18,0x00,0x18,0x80,0x38,0x7e,0xfe,0x7c,
+0x1e,0x7c,0x7c,0x30,0x7c,0x78,0x00,0x30,0x06,0x00,0x60,0x18,0x7c,0xc6,0xfc,0x3c,
+0xf8,0xfe,0xf0,0x3a,0xc6,0x3c,0x78,0xe6,0xfe,0xc6,0xc6,0x7c,0xf0,0x7c,0xe6,0x7c,
+0x3c,0x7c,0x10,0x6c,0xc6,0x3c,0xfe,0x3c,0x02,0x3c,0x00,0x00,0x00,0x76,0x7c,0x7c,
+0x76,0x7c,0xf0,0x7c,0xe6,0x3c,0x06,0xe6,0x3c,0xc6,0x66,0x7c,0x7c,0x7c,0xf0,0x7c,
+0x1c,0x76,0x18,0x6c,0xc6,0x7e,0xfe,0x0e,0x18,0x70,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0xfc,
+0x00,0x18,0x18,0xc6,0x00,0x3c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0xf6,0x1b,0x00,0x00,0x00,0x00,0x00,0x3e,0x0c,0x3e,0x7c,0xc6,0xc6,0xc6,0xc6,
+0xc6,0xc6,0xce,0x3c,0xfe,0xfe,0xfe,0xfe,0x3c,0x3c,0x3c,0x3c,0xf8,0xc6,0x7c,0x7c,
+0x7c,0x7c,0x7c,0x00,0xbc,0x7c,0x7c,0x7c,0x7c,0x3c,0xf0,0xec,0x76,0x76,0x76,0x76,
+0x76,0x76,0x6e,0x7c,0x7c,0x7c,0x7c,0x7c,0x3c,0x3c,0x3c,0x3c,0x7c,0x66,0x7c,0x7c,
+0x7c,0x7c,0x7c,0x00,0xbc,0x76,0x76,0x76,0x76,0x7e,0x7c,0x7e,0x00,0x00,0x05,0x05,
+0x02,0x12,0x0a,0x00,0x0e,0x02,0x04,0x02,0x08,0x0a,0x06,0x07,0x04,0x06,0x09,0x01,
+0x06,0x0a,0x0d,0x09,0x0d,0x11,0x09,0x09,0x1c,0x0e,0x0e,0x0e,0x00,0x00,0x00,0x00,
+0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x0c,0x00,0x00,0x66,0x00,0x00,0x00,0x00,0x00,0x60,0x0c,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0xc0,0x00,0x00,0x18,0x00,0x00,0x00,0x06,0x18,0x06,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x60,0x06,0x00,0x00,0x02,0x02,
+0x02,0x12,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x09,0x00,0x00,0x07,0x02,0x02,0x06,
+0x0a,0x0c,0x0b,0x0e,0x0b,0x00,0x0e,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0e,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0xcc,0x00,0x00,0x66,0x00,0x00,0x00,0x00,0x00,0x60,0x0c,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0xc0,0x00,0x00,0x0c,0x00,0x00,0x00,0x06,0x3e,0x06,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x60,0x0c,0x00,0x00,0x05,0x05,
+0x02,0x16,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x02,0x04,0x01,
+0x1f,0x0a,0x09,0x09,0x09,0x00,0x09,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x78,0x00,0x00,0x3c,0x00,0x00,0x00,0x00,0x00,0xf0,0x1e,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0xc0,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xf0,0xf8,0x00,0x00,0x05,0x05,
+0x02,0x0d,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x07,0x0f,0x06,
+0x02,0x09,0x09,0x0e,0x09,0x00,0x0e,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x32,0x35,0x36,0x20,
+0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x31,0x36,0x20,0x20,0x20,0x20,0x20,0x20,
+0x20,0x20,0x20,0x20,0x38,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
+0x00,0x00,0x00,0x0f,0x00,0x08,0x08,0x00,0x00,0x0f,0x00,0x08,0x10,0x00,0x00,0x0f,
+0x00,0x08,0x18,0x00,0x00,0x0f,0x00,0x08,0x20,0x00,0x00,0x0f,0x00,0x08,0x28,0x00,
+0x00,0x0f,0x00,0x08,0x30,0x00,0x00,0x0f,0x00,0x08,0x38,0x00,0x00,0x0f,0x00,0x08,
+0x40,0x00,0x00,0x0f,0x00,0x08,0x48,0x00,0x00,0x0f,0x00,0x08,0x50,0x00,0x00,0x0f,
+0x00,0x08,0x58,0x00,0x00,0x0f,0x00,0x08,0x60,0x00,0x00,0x0f,0x00,0x08,0x68,0x00,
+0x00,0x0f,0x00,0x08,0x70,0x00,0x00,0x0f,0x00,0x08,0x78,0x00,0x00,0x0f,0x00,0x08,
+0x80,0x00,0x00,0x0f,0x00,0x08,0x88,0x00,0x00,0x0f,0x00,0x08,0x90,0x00,0x00,0x0f,
+0x00,0x08,0x98,0x00,0x00,0x0f,0x00,0x08,0xa0,0x00,0x00,0x0f,0x00,0x08,0xa8,0x00,
+0x00,0x0f,0x00,0x08,0xb0,0x00,0x00,0x0f,0x00,0x08,0xb8,0x00,0x00,0x0f,0x00,0x08,
+0xc0,0x00,0x00,0x0f,0x00,0x08,0xc8,0x00,0x00,0x0f,0x00,0x08,0xd0,0x00,0x00,0x0f,
+0x00,0x08,0xd8,0x00,0x00,0x0f,0x00,0x08,0xe0,0x00,0x00,0x0f,0x00,0x08,0xe8,0x00,
+0x00,0x0f,0x00,0x08,0xf0,0x00,0x00,0x0f,0x00,0x08,0xf8,0x00,0x00,0x0f,0x00,0x08,
+0x00,0x01,0x00,0x0f,0x00,0x08,0x08,0x01,0x00,0x0f,0x00,0x08,0x10,0x01,0x00,0x0f,
+0x00,0x08,0x18,0x01,0x00,0x0f,0x00,0x08,0x20,0x01,0x00,0x0f,0x00,0x08,0x28,0x01,
+0x00,0x0f,0x00,0x08,0x30,0x01,0x00,0x0f,0x00,0x08,0x38,0x01,0x00,0x0f,0x00,0x08,
+0x40,0x01,0x00,0x0f,0x00,0x08,0x48,0x01,0x00,0x0f,0x00,0x08,0x50,0x01,0x00,0x0f,
+0x00,0x08,0x58,0x01,0x00,0x0f,0x00,0x08,0x60,0x01,0x00,0x0f,0x00,0x08,0x68,0x01,
+0x00,0x0f,0x00,0x08,0x70,0x01,0x00,0x0f,0x00,0x08,0x78,0x01,0x00,0x0f,0x00,0x08,
+0x80,0x01,0x00,0x0f,0x00,0x08,0x88,0x01,0x00,0x0f,0x00,0x08,0x90,0x01,0x00,0x0f,
+0x00,0x08,0x98,0x01,0x00,0x0f,0x00,0x08,0xa0,0x01,0x00,0x0f,0x00,0x08,0xa8,0x01,
+0x00,0x0f,0x00,0x08,0xb0,0x01,0x00,0x0f,0x00,0x08,0xb8,0x01,0x00,0x0f,0x00,0x08,
+0xc0,0x01,0x00,0x0f,0x00,0x08,0xc8,0x01,0x00,0x0f,0x00,0x08,0xd0,0x01,0x00,0x0f,
+0x00,0x08,0xd8,0x01,0x00,0x0f,0x00,0x08,0xe0,0x01,0x00,0x0f,0x00,0x08,0xe8,0x01,
+0x00,0x0f,0x00,0x08,0xf0,0x01,0x00,0x0f,0x00,0x08,0xf8,0x01,0x00,0x0f,0x00,0x08,
+0x00,0x02,0x00,0x0f,0x00,0x08,0x08,0x02,0x00,0x0f,0x00,0x08,0x10,0x02,0x00,0x0f,
+0x00,0x08,0x18,0x02,0x00,0x0f,0x00,0x08,0x20,0x02,0x00,0x0f,0x00,0x08,0x28,0x02,
+0x00,0x0f,0x00,0x08,0x30,0x02,0x00,0x0f,0x00,0x08,0x38,0x02,0x00,0x0f,0x00,0x08,
+0x40,0x02,0x00,0x0f,0x00,0x08,0x48,0x02,0x00,0x0f,0x00,0x08,0x50,0x02,0x00,0x0f,
+0x00,0x08,0x58,0x02,0x00,0x0f,0x00,0x08,0x60,0x02,0x00,0x0f,0x00,0x08,0x68,0x02,
+0x00,0x0f,0x00,0x08,0x70,0x02,0x00,0x0f,0x00,0x08,0x78,0x02,0x00,0x0f,0x00,0x08,
+0x80,0x02,0x00,0x0f,0x00,0x08,0x88,0x02,0x00,0x0f,0x00,0x08,0x90,0x02,0x00,0x0f,
+0x00,0x08,0x98,0x02,0x00,0x0f,0x00,0x08,0xa0,0x02,0x00,0x0f,0x00,0x08,0xa8,0x02,
+0x00,0x0f,0x00,0x08,0xb0,0x02,0x00,0x0f,0x00,0x08,0xb8,0x02,0x00,0x0f,0x00,0x08,
+0xc0,0x02,0x00,0x0f,0x00,0x08,0xc8,0x02,0x00,0x0f,0x00,0x08,0xd0,0x02,0x00,0x0f,
+0x00,0x08,0xd8,0x02,0x00,0x0f,0x00,0x08,0xe0,0x02,0x00,0x0f,0x00,0x08,0xe8,0x02,
+0x00,0x0f,0x00,0x08,0xf0,0x02,0x00,0x0f,0x00,0x08,0xf8,0x02,0x00,0x0f,0x00,0x08,
+0x00,0x03,0x00,0x0f,0x00,0x08,0x08,0x03,0x00,0x0f,0x00,0x08,0x10,0x03,0x00,0x0f,
+0x00,0x08,0x18,0x03,0x00,0x0f,0x00,0x08,0x20,0x03,0x00,0x0f,0x00,0x08,0x28,0x03,
+0x00,0x0f,0x00,0x08,0x30,0x03,0x00,0x0f,0x00,0x08,0x38,0x03,0x00,0x0f,0x00,0x08,
+0x40,0x03,0x00,0x0f,0x00,0x08,0x48,0x03,0x00,0x0f,0x00,0x08,0x50,0x03,0x00,0x0f,
+0x00,0x08,0x58,0x03,0x00,0x0f,0x00,0x08,0x60,0x03,0x00,0x0f,0x00,0x08,0x68,0x03,
+0x00,0x0f,0x00,0x08,0x70,0x03,0x00,0x0f,0x00,0x08,0x78,0x03,0x00,0x0f,0x00,0x08,
+0x80,0x03,0x00,0x0f,0x00,0x08,0x88,0x03,0x00,0x0f,0x00,0x08,0x90,0x03,0x00,0x0f,
+0x00,0x08,0x98,0x03,0x00,0x0f,0x00,0x08,0xa0,0x03,0x00,0x0f,0x00,0x08,0xa8,0x03,
+0x00,0x0f,0x00,0x08,0xb0,0x03,0x00,0x0f,0x00,0x08,0xb8,0x03,0x00,0x0f,0x00,0x08,
+0xc0,0x03,0x00,0x0f,0x00,0x08,0xc8,0x03,0x00,0x0f,0x00,0x08,0xd0,0x03,0x00,0x0f,
+0x00,0x08,0xd8,0x03,0x00,0x0f,0x00,0x08,0xe0,0x03,0x00,0x0f,0x00,0x08,0xe8,0x03,
+0x00,0x0f,0x00,0x08,0xf0,0x03,0x00,0x0f,0x00,0x08,0xf8,0x03,0x00,0x0f,0x00,0x08,
+0x00,0x04,0x00,0x0f,0x00,0x08,0x08,0x04,0x00,0x0f,0x00,0x08,0x10,0x04,0x00,0x0f,
+0x00,0x08,0x18,0x04,0x00,0x0f,0x00,0x08,0x20,0x04,0x00,0x0f,0x00,0x08,0x28,0x04,
+0x00,0x0f,0x00,0x08,0x30,0x04,0x00,0x0f,0x00,0x08,0x38,0x04,0x00,0x0f,0x00,0x08,
+0x40,0x04,0x00,0x0f,0x00,0x08,0x48,0x04,0x00,0x0f,0x00,0x08,0x50,0x04,0x00,0x0f,
+0x00,0x08,0x58,0x04,0x00,0x0f,0x00,0x08,0x60,0x04,0x00,0x0f,0x00,0x08,0x68,0x04,
+0x00,0x0f,0x00,0x08,0x70,0x04,0x00,0x0f,0x00,0x08,0x78,0x04,0x00,0x0f,0x00,0x08,
+0x80,0x04,0x00,0x0f,0x00,0x08,0x88,0x04,0x00,0x0f,0x00,0x08,0x90,0x04,0x00,0x0f,
+0x00,0x08,0x98,0x04,0x00,0x0f,0x00,0x08,0xa0,0x04,0x00,0x0f,0x00,0x08,0xa8,0x04,
+0x00,0x0f,0x00,0x08,0xb0,0x04,0x00,0x0f,0x00,0x08,0xb8,0x04,0x00,0x0f,0x00,0x08,
+0xc0,0x04,0x00,0x0f,0x00,0x08,0xc8,0x04,0x00,0x0f,0x00,0x08,0xd0,0x04,0x00,0x0f,
+0x00,0x08,0xd8,0x04,0x00,0x0f,0x00,0x08,0xe0,0x04,0x00,0x0f,0x00,0x08,0xe8,0x04,
+0x00,0x0f,0x00,0x08,0xf0,0x04,0x00,0x0f,0x00,0x08,0xf8,0x04,0x00,0x0f,0x00,0x08,
+0x00,0x05,0x00,0x0f,0x00,0x08,0x08,0x05,0x00,0x0f,0x00,0x08,0x10,0x05,0x00,0x0f,
+0x00,0x08,0x18,0x05,0x00,0x0f,0x00,0x08,0x20,0x05,0x00,0x0f,0x00,0x08,0x28,0x05,
+0x00,0x0f,0x00,0x08,0x30,0x05,0x00,0x0f,0x00,0x08,0x38,0x05,0x00,0x0f,0x00,0x08,
+0x40,0x05,0x00,0x0f,0x00,0x08,0x48,0x05,0x00,0x0f,0x00,0x08,0x50,0x05,0x00,0x0f,
+0x00,0x08,0x58,0x05,0x00,0x0f,0x00,0x08,0x60,0x05,0x00,0x0f,0x00,0x08,0x68,0x05,
+0x00,0x0f,0x00,0x08,0x70,0x05,0x00,0x0f,0x00,0x08,0x78,0x05,0x00,0x0f,0x00,0x08,
+0x80,0x05,0x00,0x0f,0x00,0x08,0x88,0x05,0x00,0x0f,0x00,0x08,0x90,0x05,0x00,0x0f,
+0x00,0x08,0x98,0x05,0x00,0x0f,0x00,0x08,0xa0,0x05,0x00,0x0f,0x00,0x08,0xa8,0x05,
+0x00,0x0f,0x00,0x08,0xb0,0x05,0x00,0x0f,0x00,0x08,0xb8,0x05,0x00,0x0f,0x00,0x08,
+0xc0,0x05,0x00,0x0f,0x00,0x08,0xc8,0x05,0x00,0x0f,0x00,0x08,0xd0,0x05,0x00,0x0f,
+0x00,0x08,0xd8,0x05,0x00,0x0f,0x00,0x08,0xe0,0x05,0x00,0x0f,0x00,0x08,0xe8,0x05,
+0x00,0x0f,0x00,0x08,0xf0,0x05,0x00,0x0f,0x00,0x08,0xf8,0x05,0x00,0x0f,0x00,0x08,
+0x00,0x06,0x00,0x0f,0x00,0x08,0x08,0x06,0x00,0x0f,0x00,0x08,0x10,0x06,0x00,0x0f,
+0x00,0x08,0x18,0x06,0x00,0x0f,0x00,0x08,0x20,0x06,0x00,0x0f,0x00,0x08,0x28,0x06,
+0x00,0x0f,0x00,0x08,0x30,0x06,0x00,0x0f,0x00,0x08,0x38,0x06,0x00,0x0f,0x00,0x08,
+0x40,0x06,0x00,0x0f,0x00,0x08,0x48,0x06,0x00,0x0f,0x00,0x08,0x50,0x06,0x00,0x0f,
+0x00,0x08,0x58,0x06,0x00,0x0f,0x00,0x08,0x60,0x06,0x00,0x0f,0x00,0x08,0x68,0x06,
+0x00,0x0f,0x00,0x08,0x70,0x06,0x00,0x0f,0x00,0x08,0x78,0x06,0x00,0x0f,0x00,0x08,
+0x80,0x06,0x00,0x0f,0x00,0x08,0x88,0x06,0x00,0x0f,0x00,0x08,0x90,0x06,0x00,0x0f,
+0x00,0x08,0x98,0x06,0x00,0x0f,0x00,0x08,0xa0,0x06,0x00,0x0f,0x00,0x08,0xa8,0x06,
+0x00,0x0f,0x00,0x08,0xb0,0x06,0x00,0x0f,0x00,0x08,0xb8,0x06,0x00,0x0f,0x00,0x08,
+0xc0,0x06,0x00,0x0f,0x00,0x08,0xc8,0x06,0x00,0x0f,0x00,0x08,0xd0,0x06,0x00,0x0f,
+0x00,0x08,0xd8,0x06,0x00,0x0f,0x00,0x08,0xe0,0x06,0x00,0x0f,0x00,0x08,0xe8,0x06,
+0x00,0x0f,0x00,0x08,0xf0,0x06,0x00,0x0f,0x00,0x08,0xf8,0x06,0x00,0x0f,0x00,0x08,
+0x00,0x07,0x00,0x0f,0x00,0x08,0x08,0x07,0x00,0x0f,0x00,0x08,0x10,0x07,0x00,0x0f,
+0x00,0x08,0x18,0x07,0x00,0x0f,0x00,0x08,0x20,0x07,0x00,0x0f,0x00,0x08,0x28,0x07,
+0x00,0x0f,0x00,0x08,0x30,0x07,0x00,0x0f,0x00,0x08,0x38,0x07,0x00,0x0f,0x00,0x08,
+0x40,0x07,0x00,0x0f,0x00,0x08,0x48,0x07,0x00,0x0f,0x00,0x08,0x50,0x07,0x00,0x0f,
+0x00,0x08,0x58,0x07,0x00,0x0f,0x00,0x08,0x60,0x07,0x00,0x0f,0x00,0x08,0x68,0x07,
+0x00,0x0f,0x00,0x08,0x70,0x07,0x00,0x0f,0x00,0x08,0x78,0x07,0x00,0x0f,0x00,0x08,
+0x80,0x07,0x00,0x0f,0x00,0x08,0x88,0x07,0x00,0x0f,0x00,0x08,0x90,0x07,0x00,0x0f,
+0x00,0x08,0x98,0x07,0x00,0x0f,0x00,0x08,0xa0,0x07,0x00,0x0f,0x00,0x08,0xa8,0x07,
+0x00,0x0f,0x00,0x08,0xb0,0x07,0x00,0x0f,0x00,0x08,0xb8,0x07,0x00,0x0f,0x00,0x08,
+0xc0,0x07,0x00,0x0f,0x00,0x08,0xc8,0x07,0x00,0x0f,0x00,0x08,0xd0,0x07,0x00,0x0f,
+0x00,0x08,0xd8,0x07,0x00,0x0f,0x00,0x08,0xe0,0x07,0x00,0x0f,0x00,0x08,0xe8,0x07,
+0x00,0x0f,0x00,0x08,0xf0,0x07,0x00,0x0f,0x00,0x08,0xf8,0x07,0x00,0x0f,0x00,0x08,
+0x00,0x08,0x00,0x0f,0x00,0x08,
+};
+
+int	sizeofdefont = sizeof defontdata;
+
+void
+_unpackinfo(Fontchar *fc, uchar *p, int n)
+{
+	int j;
+
+	for(j=0;  j<=n;  j++){
+		fc->x = p[0]|(p[1]<<8);
+		fc->top = p[2];
+		fc->bottom = p[3];
+		fc->left = p[4];
+		fc->width = p[5];
+		fc++;
+		p += 6;
+	}
+}
--- /dev/null
+++ b/draw/draw.c
@@ -1,0 +1,67 @@
+#include "draw.h"
+
+void
+_setdrawop(Display *d, Drawop op)
+{
+	uchar *a;
+
+	if(op != SoverD){
+		a = bufimage(d, 1+1);
+		if(a == nil)
+			return;
+		a[0] = 'O';
+		a[1] = op;
+	}
+}
+		
+static void
+draw1(Image *dst, Rectangle *r, Image *src, Point *p0, Image *mask, Point *p1, Drawop op)
+{
+	uchar *a;
+
+	_setdrawop(dst->display, op);
+
+	a = bufimage(dst->display, 1+4+4+4+4*4+2*4+2*4);
+	if(a == nil)
+		return;
+	if(src == nil)
+		src = dst->display->black;
+	if(mask == nil)
+		mask = dst->display->opaque;
+	a[0] = 'd';
+	BPLONG(a+1, dst->id);
+	BPLONG(a+5, src->id);
+	BPLONG(a+9, mask->id);
+	BPLONG(a+13, r->min.x);
+	BPLONG(a+17, r->min.y);
+	BPLONG(a+21, r->max.x);
+	BPLONG(a+25, r->max.y);
+	BPLONG(a+29, p0->x);
+	BPLONG(a+33, p0->y);
+	BPLONG(a+37, p1->x);
+	BPLONG(a+41, p1->y);
+}
+
+void
+draw(Image *dst, Rectangle r, Image *src, Image *mask, Point p1)
+{
+	draw1(dst, &r, src, &p1, mask, &p1, SoverD);
+}
+
+void
+drawop(Image *dst, Rectangle r, Image *src, Image *mask, Point p1, Drawop op)
+{
+	draw1(dst, &r, src, &p1, mask, &p1, op);
+}
+
+void
+gendraw(Image *dst, Rectangle r, Image *src, Point p0, Image *mask, Point p1)
+{
+	draw1(dst, &r, src, &p0, mask, &p1, SoverD);
+}
+
+void
+gendrawop(Image *dst, Rectangle r, Image *src, Point p0, Image *mask, Point p1, Drawop op)
+{
+	draw1(dst, &r, src, &p0, mask, &p1, op);
+}
--- /dev/null
+++ b/draw/draw.h
@@ -1,0 +1,531 @@
+#include <pthread.h>
+
+typedef struct	Cachefont Cachefont;
+typedef struct	Cacheinfo Cacheinfo;
+typedef struct	Cachesubf Cachesubf;
+typedef struct	Display Display;
+typedef struct	_Font _Font;
+typedef struct	Fontchar Fontchar;
+typedef struct	Image Image;
+typedef struct	Mouse Mouse;
+typedef struct	Point Point;
+typedef struct	Rectangle Rectangle;
+typedef struct	RGB RGB;
+typedef struct	Screen Screen;
+typedef struct	Subfont Subfont;
+
+typedef unsigned long ulong;
+typedef unsigned char uchar;
+typedef unsigned short ushort;
+typedef unsigned int Rune;
+#define nil ((void*)0)
+
+enum
+{
+	UTFmax		= 4,		/* maximum bytes per rune */
+	Runesync	= 0x80,		/* cannot represent part of a UTF sequence (<) */
+	Runeself	= 0x80,		/* rune and UTF sequences are the same (<) */
+	Runeerror	= 0xFFFD,	/* decoding error in UTF */
+	Runemax		= 0x10FFFF,	/* 21 bit rune */
+};
+
+enum
+{
+	DOpaque		= 0xFFFFFFFF,
+	DTransparent	= 0x00000000,		/* only useful for allocimage, memfillcolor */
+	DBlack		= 0x000000FF,
+	DWhite		= 0xFFFFFFFF,
+	DRed		= 0xFF0000FF,
+	DGreen		= 0x00FF00FF,
+	DBlue		= 0x0000FFFF,
+	DCyan		= 0x00FFFFFF,
+	DMagenta		= 0xFF00FFFF,
+	DYellow		= 0xFFFF00FF,
+	DPaleyellow	= 0xFFFFAAFF,
+	DDarkyellow	= 0xEEEE9EFF,
+	DDarkgreen	= 0x448844FF,
+	DPalegreen	= 0xAAFFAAFF,
+	DMedgreen	= 0x88CC88FF,
+	DDarkblue	= 0x000055FF,
+	DPalebluegreen= 0xAAFFFFFF,
+	DPaleblue		= 0x0000BBFF,
+	DBluegreen	= 0x008888FF,
+	DGreygreen	= 0x55AAAAFF,
+	DPalegreygreen	= 0x9EEEEEFF,
+	DYellowgreen	= 0x99994CFF,
+	DMedblue		= 0x000099FF,
+	DGreyblue	= 0x005DBBFF,
+	DPalegreyblue	= 0x4993DDFF,
+	DPurpleblue	= 0x8888CCFF,
+
+	DNotacolor	= 0xFFFFFF00,
+	DNofill		= DNotacolor,
+	
+};
+
+enum
+{
+	Displaybufsize	= 8000,
+	ICOSSCALE	= 1024,
+	Borderwidth =	4,
+};
+
+enum
+{
+	/* refresh methods */
+	Refbackup	= 0,
+	Refnone		= 1,
+	Refmesg		= 2
+};
+#define	NOREFRESH	((void*)-1)
+
+enum
+{
+	/* line ends */
+	Endsquare	= 0,
+	Enddisc		= 1,
+	Endarrow	= 2,
+	Endmask		= 0x1F
+};
+
+#define	ARROW(a, b, c)	(Endarrow|((a)<<5)|((b)<<14)|((c)<<23))
+
+typedef enum
+{
+	/* Porter-Duff compositing operators */
+	Clear	= 0,
+
+	SinD	= 8,
+	DinS	= 4,
+	SoutD	= 2,
+	DoutS	= 1,
+
+	S		= SinD|SoutD,
+	SoverD	= SinD|SoutD|DoutS,
+	SatopD	= SinD|DoutS,
+	SxorD	= SoutD|DoutS,
+
+	D		= DinS|DoutS,
+	DoverS	= DinS|DoutS|SoutD,
+	DatopS	= DinS|SoutD,
+	DxorS	= DoutS|SoutD,	/* == SxorD */
+
+	Ncomp = 12,
+} Drawop;
+
+/*
+ * image channel descriptors 
+ */
+enum {
+	CRed = 0,
+	CGreen,
+	CBlue,
+	CGrey,
+	CAlpha,
+	CMap,
+	CIgnore,
+	NChan,
+};
+
+#define __DC(type, nbits)	((((type)&15)<<4)|((nbits)&15))
+#define CHAN1(a,b)	__DC(a,b)
+#define CHAN2(a,b,c,d)	(CHAN1((a),(b))<<8|__DC((c),(d)))
+#define CHAN3(a,b,c,d,e,f)	(CHAN2((a),(b),(c),(d))<<8|__DC((e),(f)))
+#define CHAN4(a,b,c,d,e,f,g,h)	(CHAN3((a),(b),(c),(d),(e),(f))<<8|__DC((g),(h)))
+
+#define NBITS(c) ((c)&15)
+#define TYPE(c) (((c)>>4)&15)
+
+enum {
+	GREY1	= CHAN1(CGrey, 1),
+	GREY2	= CHAN1(CGrey, 2),
+	GREY4	= CHAN1(CGrey, 4),
+	GREY8	= CHAN1(CGrey, 8),
+	CMAP8	= CHAN1(CMap, 8),
+	RGB15	= CHAN4(CIgnore, 1, CRed, 5, CGreen, 5, CBlue, 5),
+	RGB16	= CHAN3(CRed, 5, CGreen, 6, CBlue, 5),
+	RGB24	= CHAN3(CRed, 8, CGreen, 8, CBlue, 8),
+	RGBA32	= CHAN4(CRed, 8, CGreen, 8, CBlue, 8, CAlpha, 8),
+	ARGB32	= CHAN4(CAlpha, 8, CRed, 8, CGreen, 8, CBlue, 8),	/* stupid VGAs */
+	XRGB32	= CHAN4(CIgnore, 8, CRed, 8, CGreen, 8, CBlue, 8),
+	BGR24	= CHAN3(CBlue, 8, CGreen, 8, CRed, 8),
+	ABGR32	= CHAN4(CAlpha, 8, CBlue, 8, CGreen, 8, CRed, 8),
+	XBGR32	= CHAN4(CIgnore, 8, CBlue, 8, CGreen, 8, CRed, 8),
+};
+
+extern	char*	chantostr(char*, ulong);
+extern	ulong	strtochan(char*);
+extern	int		chantodepth(ulong);
+
+struct	Point
+{
+	int	x;
+	int	y;
+};
+
+struct Rectangle
+{
+	Point	min;
+	Point	max;
+};
+
+typedef void	(*Reffn)(Image*, Rectangle, void*);
+
+struct Screen
+{
+	Display	*display;	/* display holding data */
+	int		id;			/* id of system-held Screen */
+	Image	*image;		/* unused; for reference only */
+	Image	*fill;		/* color to paint behind windows */
+};
+
+struct Display
+{
+	int		locking;	/*program is using lockdisplay */
+	int		dirno;
+	int		fd;
+	int		reffd;
+	int		ctlfd;
+	int		imageid;
+	int		local;
+	void		(*error)(Display*, char*);
+	char		*devdir;
+	char		*windir;
+	char		oldlabel[64];
+	ulong		dataqid;
+	Image		*white;
+	Image		*black;
+	Image		*opaque;
+	Image		*transparent;
+	Image		*image;
+	uchar		*buf;
+	int			bufsize;
+	uchar		*bufp;
+	_Font		*defaultfont;
+	Subfont		*defaultsubfont;
+	Image		*windows;
+	Image		*screenimage;
+	int		_isnewdisplay;
+	pthread_mutex_t qlock;
+};
+
+struct Image
+{
+	Display		*display;	/* display holding data */
+	int			id;			/* id of system-held Image */
+	Rectangle	r;			/* rectangle in data area, local coords */
+	Rectangle 	clipr;		/* clipping region */
+	int			depth;		/* number of bits per pixel */
+	ulong		chan;
+	int			repl;		/* flag: data replicates to tile clipr */
+	Screen		*screen;	/* 0 if not a window */
+	Image		*next;		/* next in list of windows */
+};
+
+struct RGB
+{
+	ulong	red;
+	ulong	green;
+	ulong	blue;
+};
+
+/*
+ * Subfonts
+ *
+ * given char c, Subfont *f, Fontchar *i, and Point p, one says
+ *	i = f->info+c;
+ *	draw(b, Rect(p.x+i->left, p.y+i->top,
+ *		p.x+i->left+((i+1)->x-i->x), p.y+i->bottom),
+ *		color, f->bits, Pt(i->x, i->top));
+ *	p.x += i->width;
+ * to draw characters in the specified color (itself an Image) in Image b.
+ */
+
+struct	Fontchar
+{
+	int		x;		/* left edge of bits */
+	uchar	top;	/* first non-zero scan-line */
+	uchar	bottom;	/* last non-zero scan-line + 1 */
+	char	left;	/* offset of baseline */
+	uchar	width;	/* width of baseline */
+};
+
+struct	Subfont
+{
+	char		*name;
+	short		n;		/* number of chars in font */
+	uchar		height;	/* height of image */
+	char		ascent;	/* top of image to baseline */
+	Fontchar 	*info;	/* n+1 character descriptors */
+	Image		*bits;	/* of font */
+	int		ref;
+};
+
+enum
+{
+	/* starting values */
+	LOG2NFCACHE =	6,
+	NFCACHE =	(1<<LOG2NFCACHE),	/* #chars cached */
+	NFLOOK =	5,			/* #chars to scan in cache */
+	NFSUBF =	2,			/* #subfonts to cache */
+	/* max value */
+	MAXFCACHE =	1024+NFLOOK,		/* upper limit */
+	MAXSUBF =	50,			/* generous upper limit */
+	/* deltas */
+	DSUBF = 	4,
+	/* expiry ages */
+	SUBFAGE	=	10000,
+	CACHEAGE =	10000
+};
+
+struct Cachefont
+{
+	Rune	min;			/* lowest rune value to be taken from subfont */
+	Rune	max;			/* highest rune value+1 to be taken from subfont */
+	int		offset;			/* position in subfont of character at min */
+	char	*name;			/* stored in font */
+	char	*subfontname;	/* to access subfont */
+};
+
+struct Cacheinfo
+{
+	ushort		x;		/* left edge of bits */
+	uchar		width;	/* width of baseline */
+	char		left;	/* offset of baseline */
+	Rune		value;	/* value of character at this slot in cache */
+	ushort		age;
+};
+
+struct Cachesubf
+{
+	ulong		age;	/* for replacement */
+	Cachefont	*cf;	/* font info that owns us */
+	Subfont		*f;		/* attached subfont */
+};
+
+struct _Font
+{
+	char		*name;
+	Display		*display;
+	short		height;	/* max height of image, interline spacing */
+	short		ascent;	/* top of image to baseline */
+	short		width;	/* widest so far; used in caching only */	
+	short		nsub;	/* number of subfonts */
+	ulong		age;	/* increasing counter; used for LRU */
+	int		maxdepth;	/* maximum depth of all loaded subfonts */
+	int		ncache;	/* size of cache */
+	int		nsubf;	/* size of subfont list */
+	Cacheinfo	*cache;
+	Cachesubf	*subf;
+	Cachefont	**sub;	/* as read from file */
+	Image		*cacheimage;
+};
+
+#define	Dx(r)	((r).max.x-(r).min.x)
+#define	Dy(r)	((r).max.y-(r).min.y)
+
+/*
+ * One of a kind
+ */
+extern int		mousescrollsize(int);
+
+/*
+ * Image management
+ */
+extern Image*	_allocimage(Image*, Display*, Rectangle, ulong, int, ulong, int, int);
+extern Image*	allocimage(Display*, Rectangle, ulong, int, ulong);
+extern uchar*	bufimage(Display*, int);
+extern int	bytesperline(Rectangle, int);
+extern void	closedisplay(Display*);
+extern void	drawerror(Display*, char*);
+extern int	flushimage(Display*, int);
+extern int	freeimage(Image*);
+extern int	_freeimage1(Image*);
+extern int	geninitdraw(char*, void(*)(Display*, char*), char*, char*, int);
+extern int	initdraw(void(*)(Display*, char*), char*, char*);
+extern int	newwindow(char*);
+extern Display*	initdisplay(char*, char*, void(*)(Display*, char*));
+extern int	loadimage(Image*, Rectangle, uchar*, int);
+extern int	cloadimage(Image*, Rectangle, uchar*, int);
+extern int	getwindow(Display*, int);
+extern int	gengetwindow(Display*, char*, Image**, Screen**, int);
+extern Image* readimage(Display*, int, int);
+extern Image* creadimage(Display*, int, int);
+extern int	unloadimage(Image*, Rectangle, uchar*, int);
+extern int	wordsperline(Rectangle, int);
+extern int	writeimage(int, Image*, int);
+extern Image*	namedimage(Display*, char*);
+extern int	nameimage(Image*, char*, int);
+extern Image* allocimagemix(Display*, ulong, ulong);
+
+/*
+ * Colors
+ */
+extern	void	readcolmap(Display*, RGB*);
+extern	void	writecolmap(Display*, RGB*);
+extern	ulong	setalpha(ulong, uchar);
+
+/*
+ * Windows
+ */
+extern Screen*	allocscreen(Image*, Image*, int);
+extern Image*	_allocwindow(Image*, Screen*, Rectangle, int, ulong);
+extern Image*	allocwindow(Screen*, Rectangle, int, ulong);
+extern void	bottomnwindows(Image**, int);
+extern void	bottomwindow(Image*);
+extern int	freescreen(Screen*);
+extern Screen*	publicscreen(Display*, int, ulong);
+extern void	topnwindows(Image**, int);
+extern void	topwindow(Image*);
+extern int	originwindow(Image*, Point, Point);
+
+/*
+ * Geometry
+ */
+extern Point		Pt(int, int);
+extern Rectangle	Rect(int, int, int, int);
+extern Rectangle	Rpt(Point, Point);
+extern Point		addpt(Point, Point);
+extern Point		subpt(Point, Point);
+extern Point		divpt(Point, int);
+extern Point		mulpt(Point, int);
+extern int		eqpt(Point, Point);
+extern int		eqrect(Rectangle, Rectangle);
+extern Rectangle	insetrect(Rectangle, int);
+extern Rectangle	rectaddpt(Rectangle, Point);
+extern Rectangle	rectsubpt(Rectangle, Point);
+extern Rectangle	canonrect(Rectangle);
+extern int		rectXrect(Rectangle, Rectangle);
+extern int		rectinrect(Rectangle, Rectangle);
+extern void		combinerect(Rectangle*, Rectangle);
+extern int		rectclip(Rectangle*, Rectangle);
+extern int		ptinrect(Point, Rectangle);
+extern void		replclipr(Image*, int, Rectangle);
+extern int		drawreplxy(int, int, int);	/* used to be drawsetxy */
+extern Point	drawrepl(Rectangle, Point);
+extern int		rgb2cmap(int, int, int);
+extern int		cmap2rgb(int);
+extern int		cmap2rgba(int);
+extern void		icossin(int, int*, int*);
+extern void		icossin2(int, int, int*, int*);
+extern int		badrect(Rectangle);
+
+/*
+ * Graphics
+ */
+extern void	draw(Image*, Rectangle, Image*, Image*, Point);
+extern void	drawop(Image*, Rectangle, Image*, Image*, Point, Drawop);
+extern void	gendraw(Image*, Rectangle, Image*, Point, Image*, Point);
+extern void	gendrawop(Image*, Rectangle, Image*, Point, Image*, Point, Drawop);
+extern void	line(Image*, Point, Point, int, int, int, Image*, Point);
+extern void	lineop(Image*, Point, Point, int, int, int, Image*, Point, Drawop);
+extern void	poly(Image*, Point*, int, int, int, int, Image*, Point);
+extern void	polyop(Image*, Point*, int, int, int, int, Image*, Point, Drawop);
+extern void	fillpoly(Image*, Point*, int, int, Image*, Point);
+extern void	fillpolyop(Image*, Point*, int, int, Image*, Point, Drawop);
+extern Point	string(Image*, Point, Image*, Point, _Font*, char*);
+extern Point	stringop(Image*, Point, Image*, Point, _Font*, char*, Drawop);
+extern Point	stringn(Image*, Point, Image*, Point, _Font*, char*, int);
+extern Point	stringnop(Image*, Point, Image*, Point, _Font*, char*, int, Drawop);
+extern Point	runestring(Image*, Point, Image*, Point, _Font*, Rune*);
+extern Point	runestringop(Image*, Point, Image*, Point, _Font*, Rune*, Drawop);
+extern Point	runestringn(Image*, Point, Image*, Point, _Font*, Rune*, int);
+extern Point	runestringnop(Image*, Point, Image*, Point, _Font*, Rune*, int, Drawop);
+extern Point	stringbg(Image*, Point, Image*, Point, _Font*, char*, Image*, Point);
+extern Point	stringbgop(Image*, Point, Image*, Point, _Font*, char*, Image*, Point, Drawop);
+extern Point	stringnbg(Image*, Point, Image*, Point, _Font*, char*, int, Image*, Point);
+extern Point	stringnbgop(Image*, Point, Image*, Point, _Font*, char*, int, Image*, Point, Drawop);
+extern Point	runestringbg(Image*, Point, Image*, Point, _Font*, Rune*, Image*, Point);
+extern Point	runestringbgop(Image*, Point, Image*, Point, _Font*, Rune*, Image*, Point, Drawop);
+extern Point	runestringnbg(Image*, Point, Image*, Point, _Font*, Rune*, int, Image*, Point);
+extern Point	runestringnbgop(Image*, Point, Image*, Point, _Font*, Rune*, int, Image*, Point, Drawop);
+extern Point	_string(Image*, Point, Image*, Point, _Font*, char*, Rune*, int, Rectangle, Image*, Point, Drawop);
+extern Point	stringsubfont(Image*, Point, Image*, Subfont*, char*);
+extern int		bezier(Image*, Point, Point, Point, Point, int, int, int, Image*, Point);
+extern int		bezierop(Image*, Point, Point, Point, Point, int, int, int, Image*, Point, Drawop);
+extern int		bezspline(Image*, Point*, int, int, int, int, Image*, Point);
+extern int		bezsplineop(Image*, Point*, int, int, int, int, Image*, Point, Drawop);
+extern int		bezsplinepts(Point*, int, Point**);
+extern int		fillbezier(Image*, Point, Point, Point, Point, int, Image*, Point);
+extern int		fillbezierop(Image*, Point, Point, Point, Point, int, Image*, Point, Drawop);
+extern int		fillbezspline(Image*, Point*, int, int, Image*, Point);
+extern int		fillbezsplineop(Image*, Point*, int, int, Image*, Point, Drawop);
+extern void	ellipse(Image*, Point, int, int, int, Image*, Point);
+extern void	ellipseop(Image*, Point, int, int, int, Image*, Point, Drawop);
+extern void	fillellipse(Image*, Point, int, int, Image*, Point);
+extern void	fillellipseop(Image*, Point, int, int, Image*, Point, Drawop);
+extern void	arc(Image*, Point, int, int, int, Image*, Point, int, int);
+extern void	arcop(Image*, Point, int, int, int, Image*, Point, int, int, Drawop);
+extern void	fillarc(Image*, Point, int, int, Image*, Point, int, int);
+extern void	fillarcop(Image*, Point, int, int, Image*, Point, int, int, Drawop);
+extern void	border(Image*, Rectangle, int, Image*, Point);
+extern void	borderop(Image*, Rectangle, int, Image*, Point, Drawop);
+
+/*
+ * Font management
+ */
+extern _Font*	openfont(Display*, char*);
+extern _Font*	buildfont(Display*, char*, char*);
+extern void	freefont(_Font*);
+extern _Font*	mkfont(Subfont*, Rune);
+extern int	cachechars(_Font*, char**, Rune**, ushort*, int, int*, char**);
+extern void	agefont(_Font*);
+extern Subfont*	allocsubfont(char*, int, int, int, Fontchar*, Image*);
+extern Subfont*	lookupsubfont(Display*, char*);
+extern void	installsubfont(char*, Subfont*);
+extern void	uninstallsubfont(Subfont*);
+extern void	freesubfont(Subfont*);
+extern Subfont*	readsubfont(Display*, char*, int, int);
+extern Subfont*	readsubfonti(Display*, char*, int, Image*, int);
+extern int	writesubfont(int, Subfont*);
+extern void	_unpackinfo(Fontchar*, uchar*, int);
+extern Point	stringsize(_Font*, char*);
+extern int	stringwidth(_Font*, char*);
+extern int	stringnwidth(_Font*, char*, int);
+extern Point	runestringsize(_Font*, Rune*);
+extern int	runestringwidth(_Font*, Rune*);
+extern int	runestringnwidth(_Font*, Rune*, int);
+extern Point	strsubfontwidth(Subfont*, char*);
+extern int	loadchar(_Font*, Rune, Cacheinfo*, int, int, char**);
+extern char*	subfontname(char*, char*, int);
+extern Subfont*	_getsubfont(Display*, char*);
+extern Subfont*	getdefont(Display*);
+extern void		lockdisplay(Display*);
+extern void	unlockdisplay(Display*);
+
+/*
+ * Predefined 
+ */
+extern	uchar	defontdata[];
+extern	int		sizeofdefont;
+extern	Point		ZP;
+extern	Rectangle	ZR;
+
+/*
+ * Set up by initdraw()
+ */
+extern	Display	*_display; /* opaque.h defines display */
+extern	_Font		*font;
+extern	Image	*screen;
+extern	Screen	*_screen;
+extern	int	_cursorfd;
+extern	void	_setdrawop(Display*, Drawop);
+
+#define	BGSHORT(p)	((p)[0]|((p)[1]<<8))
+#define	BGLONG(p)	((p)[0]|((p)[1]<<8)|((p)[2]<<16)|((p)[3]<<24))
+#define BPSHORT(p,v)	do{ushort _v_=(v);(p)[0]=_v_;(p)[1]=_v_>>8;}while(0)
+#define BPLONG(p,v)	do{ulong _v_=(v);(p)[0]=_v_;(p)[1]=_v_>>8;(p)[2]=_v_>>16;(p)[3]=_v_>>24;}while(0)
+
+/*
+ * Compressed image file parameters and helper routines
+ */
+#define	NMATCH	3		/* shortest match possible */
+#define	NRUN	(NMATCH+31)	/* longest match possible */
+#define	NMEM	1024		/* window size */
+#define	NDUMP	128		/* maximum length of dump */
+#define	NCBLOCK	6000		/* size of compressed blocks */
+extern	void	_twiddlecompressed(uchar*, int);
+extern	int	_compblocksize(Rectangle, int);
+
+extern	ulong	drawld2chan[];
+extern	void	drawsetdebug(int);
--- /dev/null
+++ b/draw/freesubfont.c
@@ -1,0 +1,14 @@
+#include <stdlib.h>
+#include "draw.h"
+
+void
+freesubfont(Subfont *f)
+{
+	if(f == nil || --f->ref)
+		return;
+	uninstallsubfont(f);
+	free(f->name);
+	free(f->info);	/* note: f->info must have been malloc'ed! */
+	freeimage(f->bits);
+	free(f);
+}
--- /dev/null
+++ b/draw/getdefont.c
@@ -1,0 +1,60 @@
+#include <stdlib.h>
+#include <string.h>
+#include "draw.h"
+
+Subfont*
+getdefont(Display *d)
+{
+	char *hdr, *p;
+	int n;
+	Fontchar *fc;
+	Subfont *f;
+	int ld;
+	Rectangle r;
+	Image *i;
+
+	/*
+	 * make sure data is word-aligned.  this is true with Plan 9 compilers
+	 * but not in general.  the byte order is right because the data is
+	 * declared as char*, not ulong*.
+	 */
+	p = (char*)defontdata;
+	n = (int)(unsigned long long)p & 3;				/* stupid ape */
+	if(n != 0){
+		memmove(p+(4-n), p, sizeofdefont-n);
+		p += 4-n;
+	}
+	ld = atoi(p+0*12);
+	r.min.x = atoi(p+1*12);
+	r.min.y = atoi(p+2*12);
+	r.max.x = atoi(p+3*12);
+	r.max.y = atoi(p+4*12);
+
+	i = allocimage(d, r, drawld2chan[ld], 0, 0);
+	if(i == 0)
+		return 0;
+
+	p += 5*12;
+	n = loadimage(i, r, (uchar*)p, (defontdata+sizeofdefont)-(uchar*)p);
+	if(n < 0){
+		freeimage(i);
+		return 0;
+	}
+
+	hdr = p+n;
+	n = atoi(hdr);
+	p = hdr+3*12;
+	fc = malloc(sizeof(Fontchar)*(n+1));
+	if(fc == 0){
+		freeimage(i);
+		return 0;
+	}
+	_unpackinfo(fc, (uchar*)p, n);
+	f = allocsubfont("*default*", n, atoi(hdr+12), atoi(hdr+24), fc, i);
+	if(f == 0){
+		freeimage(i);
+		free(fc);
+		return 0;
+	}
+	return f;
+}
--- /dev/null
+++ b/draw/init.c
@@ -1,0 +1,451 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+#include <fcntl.h>
+#include "draw.h"
+
+Display	*_display;
+_Font	*font;
+Image	*screen;
+
+enum{
+	DISP_BUFSIZE = 8000, /* Play with this some, see if changes much */
+};
+
+static char deffontname[] = "*default*";
+Screen	*_screen;
+
+int	debuglockdisplay = 0;
+
+static void _closedisplay(Display*, int);
+
+/* note handler */
+static void
+drawshutdown(void)
+{
+	Display *d;
+
+	d = _display;
+	if(d != nil){
+		_display = nil;
+		_closedisplay(d, 1);
+	}
+}
+
+int
+geninitdraw(char *devdir, void(*error)(Display*, char*), char *label, char *windir, int ref)
+{
+	int fd;
+	char *fontname;
+	char buf[128];
+	Subfont *df;
+
+	_display = initdisplay(devdir, windir, error);
+	if(_display == nil)
+		return -1;
+
+	/*
+	 * Set up default font
+	 */
+	df = getdefont(_display);
+	_display->defaultsubfont = df;
+	if(df == nil){
+    Error:
+		closedisplay(_display);
+		_display = nil;
+		return -1;
+	}
+
+	fd = open("/env/font", O_RDONLY);
+	read(fd, buf, sizeof(buf));
+	fontname = buf;
+
+	/*
+	 * Build fonts with caches==depth of screen, for speed.
+	 * If conversion were faster, we'd use 0 and save memory.
+	 */
+	if(strcmp(fontname, "") != 0){
+		snprintf(buf, sizeof buf, "%d %d\n0 %d\t%s\n", df->height, df->ascent,
+			df->n-1, deffontname);
+//BUG: Need something better for this	installsubfont("*default*", df);
+		font = buildfont(_display, buf, deffontname);
+		if(font == nil)
+			goto Error;
+	}else{
+		font = openfont(_display, fontname);	/* BUG: grey fonts */
+		if(font == nil)
+			goto Error;
+	}
+	_display->defaultfont = font;
+
+	/*
+	 * Write label; ignore errors (we might not be running under rio)
+	 */
+	if(label != nil){
+		snprintf(buf, sizeof buf, "%s/label", _display->windir);
+		fd = open(buf, O_RDONLY);
+		if(fd >= 0){
+			read(fd, _display->oldlabel, (sizeof _display->oldlabel)-1);
+			close(fd);
+			fd = open(buf, O_CREAT|O_WRONLY, 0666);
+			if(fd >= 0){
+				write(fd, label, strlen(label));
+				close(fd);
+			}
+		}
+	}
+
+	snprintf(buf, sizeof buf, "%s/winname", _display->windir);
+	if(gengetwindow(_display, buf, &screen, &_screen, ref) < 0)
+		goto Error;
+
+	atexit(drawshutdown);
+
+	return 1;
+}
+
+int
+initdraw(void(*error)(Display*, char*), char *chroot, char *label)
+{
+	char *dev;
+	sprintf(dev, "%s/dev/", chroot);
+	return geninitdraw(dev, error, label, dev, Refnone);
+}
+
+/*
+ * Attach, or possibly reattach, to window.
+ * If reattaching, maintain value of screen pointer.
+ */
+int
+gengetwindow(Display *d, char *winname, Image **winp, Screen **scrp, int ref)
+{
+	int n, fd;
+	char buf[64+1], obuf[64+1];
+	Image *image;
+	Rectangle r;
+
+	obuf[0] = 0;
+retry:
+	fd = open(winname, O_RDONLY);
+	if(fd<0 || (n=read(fd, buf, sizeof buf-1))<=0){
+		if((image=d->image) == nil){
+			*winp = nil;
+			d->screenimage = nil;
+			return -1;
+		}
+		strcpy(buf, "noborder");
+	}else{
+		close(fd);
+		buf[n] = '\0';
+		image = namedimage(d, buf);
+		if(image == nil){
+			/*
+			 * theres a race where the winname can change after
+			 * we read it, so keep trying as long as the name
+			 * keeps changing.
+			 */
+			if(strcmp(buf, obuf) != 0){
+				strcpy(obuf, buf);
+				goto retry;
+			}
+		}
+		if(*winp != nil){
+			_freeimage1(*winp);
+			freeimage((*scrp)->image);
+			freescreen(*scrp);
+			*scrp = nil;
+		}
+		if(image == nil){
+			*winp = nil;
+			d->screenimage = nil;
+			return -1;
+		}
+	}
+
+	d->screenimage = image;
+	*scrp = allocscreen(image, d->white, 0);
+	if(*scrp == nil){
+		*winp = nil;
+		d->screenimage = nil;
+		freeimage(image);
+		return -1;
+	}
+
+	r = image->r;
+	if(strncmp(buf, "noborder", 8) != 0)
+		r = insetrect(image->r, Borderwidth);
+	*winp = _allocwindow(*winp, *scrp, r, ref, DWhite);
+	if(*winp == nil){
+		freescreen(*scrp);
+		*scrp = nil;
+		d->screenimage = nil;
+		freeimage(image);
+		return -1;
+	}
+	d->screenimage = *winp;
+	return 1;
+}
+
+int
+getwindow(Display *d, int ref)
+{
+	char winname[128];
+
+	snprintf(winname, sizeof winname, "%s/winname", d->windir);
+	return gengetwindow(d, winname, &screen, &_screen, ref);
+}
+
+#define	NINFO	12*12
+
+Display*
+initdisplay(char *dev, char *win, void(*error)(Display*, char*))
+{
+	char buf[128], info[NINFO+1], *t, isnew;
+	int n, datafd, ctlfd, reffd;
+	Display *disp;
+	Image *image;
+
+	if(dev == nil)
+		dev = "/dev";
+	if(win == nil)
+		win = "/dev";
+	if(strlen(dev)>sizeof buf-25 || strlen(win)>sizeof buf-25){
+		return nil;
+	}
+	t = strdup(win);
+	if(t == nil)
+		return nil;
+
+	sprintf(buf, "%s/draw/new", dev);
+	ctlfd = open(buf, O_RDWR);
+	if(ctlfd < 0){
+    Error1:
+		free(t);
+
+		return nil;
+	}
+	if((n=read(ctlfd, info, sizeof info)) < 12){
+    Error2:
+		close(ctlfd);
+		goto Error1;
+	}
+	if(n==NINFO+1)
+		n = NINFO;
+	info[n] = '\0';
+	isnew = 0;
+	if(n < NINFO)	/* this will do for now, we need something better here */
+		isnew = 1;
+	sprintf(buf, "%s/draw/%d/data", dev, atoi(info+0*12));
+	datafd = open(buf, O_RDWR);
+	if(datafd < 0)
+		goto Error2;
+	sprintf(buf, "%s/draw/%d/refresh", dev, atoi(info+0*12));
+	reffd = open(buf, O_RDWR);
+	if(reffd < 0){
+    Error3:
+		close(datafd);
+		goto Error2;
+	}
+	disp = calloc(sizeof(Display), 1);
+	if(disp == nil){
+    Error4:
+		close(reffd);
+		goto Error3;
+	}
+	image = nil;
+	if(0){
+    Error5:
+		free(image);
+		free(disp);
+		goto Error4;
+	}
+	if(n >= NINFO){
+		image = calloc(sizeof(Image), 1);
+		if(image == nil)
+			goto Error5;
+		image->display = disp;
+		image->id = 0;
+		image->chan = strtochan(info+2*12);
+		image->depth = chantodepth(image->chan);
+		image->repl = atoi(info+3*12);
+		image->r.min.x = atoi(info+4*12);
+		image->r.min.y = atoi(info+5*12);
+		image->r.max.x = atoi(info+6*12);
+		image->r.max.y = atoi(info+7*12);
+		image->clipr.min.x = atoi(info+8*12);
+		image->clipr.min.y = atoi(info+9*12);
+		image->clipr.max.x = atoi(info+10*12);
+		image->clipr.max.y = atoi(info+11*12);
+	}
+
+	disp->_isnewdisplay = isnew;
+	disp->bufsize = DISP_BUFSIZE;
+	disp->buf = malloc(disp->bufsize+5);	/* +5 for flush message */
+	if(disp->buf == nil)
+		goto Error5;
+
+	disp->image = image;
+	disp->dirno = atoi(info+0*12);
+	disp->fd = datafd;
+	disp->ctlfd = ctlfd;
+	disp->reffd = reffd;
+	disp->bufp = disp->buf;
+	disp->error = error;
+	disp->windir = t;
+	disp->devdir = strdup(dev);
+	pthread_mutex_lock(&disp->qlock);
+	disp->white = allocimage(disp, Rect(0, 0, 1, 1), GREY1, 1, DWhite);
+	disp->black = allocimage(disp, Rect(0, 0, 1, 1), GREY1, 1, DBlack);
+	if(disp->white == nil || disp->black == nil){
+		free(disp->devdir);
+		free(disp->white);
+		free(disp->black);
+		goto Error5;
+	}
+	disp->opaque = disp->white;
+	disp->transparent = disp->black;
+
+	/* We still need this */
+	//dir = dirfstat(ctlfd);
+	//if(dir!=nil && dir->type=='i'){
+	//	disp->local = 1;
+	//	disp->dataqid = dir->qid.path;
+	//}
+	//if(dir!=nil && dir->qid.vers==1)	/* other way to tell */
+	//	disp->_isnewdisplay = 1;
+	//free(dir);
+
+	return disp;
+}
+
+/*
+ * Call with d unlocked.
+ * Note that disp->defaultfont and defaultsubfont are not freed here.
+ */
+void
+closedisplay(Display *disp)
+{
+	_closedisplay(disp, 0);
+}
+
+static void
+_closedisplay(Display *disp, int isshutdown)
+{
+	int fd;
+	char buf[128];
+
+	if(disp == nil)
+		return;
+	if(disp == _display)
+		_display = nil;
+	if(disp->oldlabel[0]){
+		snprintf(buf, sizeof buf, "%s/label", disp->windir);
+		fd = open(buf, O_WRONLY);
+		if(fd >= 0){
+			write(fd, disp->oldlabel, strlen(disp->oldlabel));
+			close(fd);
+		}
+	}
+
+	/*
+	 * if we're shutting down, don't free all the resources.
+	 * if other procs are getting shot down by notes too,
+	 * one might get shot down while holding the malloc lock.
+	 * just let the kernel clean things up when we exit.
+	 */
+	if(isshutdown)
+		return;
+
+	free(disp->devdir);
+	free(disp->windir);
+	freeimage(disp->white);
+	freeimage(disp->black);
+	close(disp->fd);
+	close(disp->ctlfd);
+	/* should cause refresh slave to shut down */
+	close(disp->reffd);
+	pthread_mutex_unlock(&disp->qlock);
+	free(disp);
+}
+
+void
+lockdisplay(Display *disp)
+{
+	if(debuglockdisplay){
+		/* avoid busy looping; it's rare we collide anyway */
+		while(!pthread_mutex_trylock(&disp->qlock))
+			sleep(1000);
+	}else
+		pthread_mutex_lock(&disp->qlock);
+}
+
+void
+unlockdisplay(Display *disp)
+{
+	pthread_mutex_unlock(&disp->qlock);
+}
+
+void
+drawerror(Display *d, char *s)
+{
+	char err[128]; /* ERRMAX */
+
+	if(d != nil && d->error != nil)
+		(*d->error)(d, s);
+	else{
+		fprintf(stderr, "draw: %s: %s\n", s, err);
+		exit(1);
+	}
+}
+
+static
+int
+doflush(Display *d)
+{
+	int n;
+
+	n = d->bufp-d->buf;
+	if(n <= 0)
+		return 1;
+
+	if(write(d->fd, d->buf, n) != n){
+		d->bufp = d->buf;	/* might as well; chance of continuing */
+		return -1;
+	}
+	d->bufp = d->buf;
+	return 1;
+}
+
+int
+flushimage(Display *d, int visible)
+{
+	if(d == nil)
+		return 0;
+	if(visible){
+		*d->bufp++ = 'v';	/* five bytes always reserved for this */
+		if(d->_isnewdisplay){
+			BPLONG(d->bufp, d->screenimage->id);
+			d->bufp += 4;
+		}
+	}
+	return doflush(d);
+}
+
+uchar*
+bufimage(Display *d, int n)
+{
+	uchar *p;
+
+	if(n<0 || n>d->bufsize){
+		return nil;
+	}
+	if(d->bufp+n > d->buf+d->bufsize)
+		if(doflush(d) < 0)
+			return nil;
+	p = d->bufp;
+	d->bufp += n;
+	return p;
+}
+
--- /dev/null
+++ b/draw/loadimage.c
@@ -1,0 +1,53 @@
+#include <stdio.h>
+#include <string.h>
+#include "draw.h"
+
+int
+loadimage(Image *i, Rectangle r, uchar *data, int ndata)
+{
+	long dx, dy;
+	int n, bpl;
+	uchar *a;
+	int chunk;
+
+	chunk = i->display->bufsize - 64;
+
+	if(!rectinrect(r, i->r)){
+		return -1;
+	}
+	bpl = bytesperline(r, i->depth);
+	n = bpl*Dy(r);
+	if(n > ndata){
+		return -1;
+	}
+	ndata = 0;
+	while(r.max.y > r.min.y){
+		dy = Dy(r);
+		dx = Dx(r);
+		if(dy*bpl > chunk)
+			dy = chunk/bpl;
+		if(dy <= 0){
+			dy = 1;
+			dx = ((chunk*dx)/bpl) & ~7;
+			n = bytesperline(Rect(r.min.x, r.min.y, r.min.x+dx, r.min.y+dy), i->depth);
+			if(loadimage(i, Rect(r.min.x+dx, r.min.y, r.max.x, r.min.y+dy), data+n, bpl-n) < 0)
+				return -1;
+		} else
+			n = dy*bpl;
+		a = bufimage(i->display, 21+n);
+		if(a == nil){
+			return -1;
+		}
+		a[0] = 'y';
+		BPLONG(a+1, i->id);
+		BPLONG(a+5, r.min.x);
+		BPLONG(a+9, r.min.y);
+		BPLONG(a+13, r.min.x+dx);
+		BPLONG(a+17, r.min.y+dy);
+		memmove(a+21, data, n);
+		ndata += dy*bpl;
+		data += dy*bpl;
+		r.min.y += dy;
+	}
+	return ndata;
+}
--- /dev/null
+++ b/draw/meson.build
@@ -1,0 +1,28 @@
+draw_src = [
+    'alloc.c',
+    'arith.c',
+    'badrect.c',
+    'buildfont.c',
+    'bytesperline.c',
+    'chan.c',
+    'defont.c',
+    'draw.c',
+    'freesubfont.c',
+    'getdefont.c',
+    'init.c',
+    'loadimage.c',
+    'openfont.c',
+    'subfont.c',
+    'subfontcache.c',
+    'window.c',
+]
+
+draw = static_library(
+    'draw',
+    draw_src,
+    include_directories: inc,
+    dependencies: common_dep,
+    install: true,
+)
+
+install_data('draw.h', install_dir: xorgsdkdir)
--- /dev/null
+++ b/draw/openfont.c
@@ -1,0 +1,47 @@
+#include <unistd.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include "draw.h"
+
+static char*
+readfile(char *name)
+{
+	enum { HUNK = 8*1024, };
+	int f, n, r;
+	char *s, *p;
+
+	n = 0;
+	r = -1;
+	if((s = malloc(HUNK)) != nil){
+		if((f = open(name, O_RDONLY)) >= 0){
+			while((r = read(f, s+n, HUNK)) > 0){
+				n += r;
+				r = -1;
+				if((p = realloc(s, n+HUNK)) == nil)
+					break;
+				s = p;
+			}
+			close(f);
+		}
+	}
+	if(r < 0 || (p = realloc(s, n+1)) == nil){
+		free(s);
+		return nil;
+	}
+	p[n] = 0;
+	return p;
+}
+
+_Font*
+openfont(Display *d, char *name)
+{
+	_Font *fnt;
+	char *buf;
+
+	if((buf = readfile(name)) == nil){
+		return nil;
+	}
+	fnt = buildfont(d, buf, name);
+	free(buf);
+	return fnt;
+}
--- /dev/null
+++ b/draw/subfont.c
@@ -1,0 +1,32 @@
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include "draw.h"
+
+Subfont*
+allocsubfont(char *name, int n, int height, int ascent, Fontchar *info, Image *i)
+{
+	Subfont *f;
+
+	assert(height != 0 /* allocsubfont */);
+
+	f = malloc(sizeof(Subfont));
+	if(f == nil)
+		return nil;
+	f->n = n;
+	f->height = height;
+	f->ascent = ascent;
+	f->info = info;
+	f->bits = i;
+	f->ref = 1;
+	if(name){
+		f->name = strdup(name);
+		if(f->name == nil){
+			free(f);
+			return nil;
+		}
+		installsubfont(name, f);
+	}else
+		f->name = nil;
+	return f;
+}
--- /dev/null
+++ b/draw/subfontcache.c
@@ -1,0 +1,41 @@
+#include <stdlib.h>
+#include <string.h>
+#include "draw.h"
+
+/*
+ * Easy versions of the cache routines; may be substituted by fancier ones for other purposes
+ */
+
+static char	*lastname;
+static Subfont	*lastsubfont;
+
+Subfont*
+lookupsubfont(Display *d, char *name)
+{
+	if(d && strcmp(name, "*default*") == 0)
+		return d->defaultsubfont;
+	if(lastname && strcmp(name, lastname)==0)
+	if(d==lastsubfont->bits->display){
+		lastsubfont->ref++;
+		return lastsubfont;
+	}
+	return 0;
+}
+
+void
+installsubfont(char *name, Subfont *subfont)
+{
+	free(lastname);
+	lastname = strdup(name);
+	lastsubfont = subfont;	/* notice we don't free the old one; that's your business */
+}
+
+void
+uninstallsubfont(Subfont *subfont)
+{
+	if(subfont == lastsubfont){
+		free(lastname);
+		lastname = 0;
+		lastsubfont = 0;
+	}
+}
--- /dev/null
+++ b/draw/window.c
@@ -1,0 +1,219 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <assert.h>
+#include "draw.h"
+
+typedef struct Memimage Memimage;
+
+static int	screenid;
+
+Screen*
+allocscreen(Image *image, Image *fill, int public)
+{
+	uchar *a;
+	Screen *s;
+	int id, try;
+	Display *d;
+
+	d = image->display;
+	if(d != fill->display){
+		return nil;
+	}
+	s = malloc(sizeof(Screen));
+	if(s == nil)
+		return nil;
+	if(!screenid)
+		screenid = getpid();
+	for(try=0; try<25; try++){
+		/* loop until find a free id */
+		a = bufimage(d, 1+4+4+4+1);
+		if(a == nil)
+			break;
+		id = ++screenid & 0xffff;	/* old devdraw bug */
+		a[0] = 'A';
+		BPLONG(a+1, id);
+		BPLONG(a+5, image->id);
+		BPLONG(a+9, fill->id);
+		a[13] = public;
+		if(flushimage(d, 0) != -1)
+			goto Found;
+	}
+	free(s);
+	return nil;
+
+    Found:
+	s->display = d;
+	s->id = id;
+	s->image = image;
+	assert(s->image != nil && s->image->chan != 0);
+
+	s->fill = fill;
+	return s;
+}
+
+Screen*
+publicscreen(Display *d, int id, ulong chan)
+{
+	uchar *a;
+	Screen *s;
+
+	s = malloc(sizeof(Screen));
+	if(s == nil)
+		return nil;
+	a = bufimage(d, 1+4+4);
+	if(a == nil){
+Error:
+		free(s);
+		return nil;
+	}
+	a[0] = 'S';
+	BPLONG(a+1, id);
+	BPLONG(a+5, chan);
+	if(flushimage(d, 0) < 0)
+		goto Error;
+
+	s->display = d;
+	s->id = id;
+	s->image = nil;
+	s->fill = nil;
+	return s;
+}
+
+int
+freescreen(Screen *s)
+{
+	uchar *a;
+	Display *d;
+
+	if(s == nil)
+		return 0;
+	d = s->display;
+	a = bufimage(d, 1+4);
+	if(a == nil){
+Error:
+		free(s);
+		return -1;
+	}
+	a[0] = 'F';
+	BPLONG(a+1, s->id);
+	/*
+	 * flush(1) because screen is likely holding last reference to
+	 * window, and want it to disappear visually.
+	 */
+	if(flushimage(d, 1) < 0)
+		goto Error;
+	free(s);
+	return 1;
+}
+
+Image*
+allocwindow(Screen *s, Rectangle r, int ref, ulong col)
+{
+	return _allocwindow(nil, s, r, ref, col);
+}
+
+Image*
+_allocwindow(Image *i, Screen *s, Rectangle r, int ref, ulong col)
+{
+	Display *d;
+
+	d = s->display;
+	i = _allocimage(i, d, r, d->screenimage->chan, 0, col, s->id, ref);
+	if(i == nil)
+		return nil;
+	i->screen = s;
+	i->next = s->display->windows;
+	s->display->windows = i;
+	return i;
+}
+
+static
+void
+topbottom(Image **w, int n, int top)
+{
+	int i;
+	uchar *b;
+	Display *d;
+
+	if(n < 0){
+    Ridiculous:
+		fprintf(2, "top/bottom: ridiculous number of windows\n");
+		return;
+	}
+	if(n == 0)
+		return;
+	if(n > (w[0]->display->bufsize-100)/4)
+		goto Ridiculous;
+	/*
+	 * this used to check that all images were on the same screen.
+	 * we don't know the screen associated with images we acquired
+	 * by name.  instead, check that all images are on the same display.
+	 * the display will check that they are all on the same screen.
+	 */
+	d = w[0]->display;
+	for(i=1; i<n; i++)
+		if(w[i]->display != d){
+			fprintf(2, "top/bottom: windows not on same screen\n");
+			return;
+		}
+
+	if(n==0)
+		return;
+	b = bufimage(d, 1+1+2+4*n);
+	if(b == nil)
+		return;
+	b[0] = 't';
+	b[1] = top;
+	BPSHORT(b+2, n);
+	for(i=0; i<n; i++)
+		BPLONG(b+4+4*i, w[i]->id);
+}
+
+void
+bottomwindow(Image *w)
+{
+	if(w->screen != nil)
+		topbottom(&w, 1, 0);
+}
+
+void
+topwindow(Image *w)
+{
+	if(w->screen != nil)
+		topbottom(&w, 1, 1);
+}
+
+void
+bottomnwindows(Image **w, int n)
+{
+	topbottom(w, n, 0);
+}
+
+void
+topnwindows(Image **w, int n)
+{
+	topbottom(w, n, 1);
+}
+
+int
+originwindow(Image *w, Point log, Point scr)
+{
+	uchar *b;
+	Point delta;
+
+	b = bufimage(w->display, 1+4+2*4+2*4);
+	if(b == nil)
+		return 0;
+	b[0] = 'o';
+	BPLONG(b+1, w->id);
+	BPLONG(b+5, log.x);
+	BPLONG(b+9, log.y);
+	BPLONG(b+13, scr.x);
+	BPLONG(b+17, scr.y);
+	delta = subpt(log, w->r.min);
+	w->r = rectaddpt(w->r, delta);
+	w->clipr = rectaddpt(w->clipr, delta);
+	return 1;
+}
--- /dev/null
+++ b/keyboard.c
@@ -1,0 +1,164 @@
+/*
+ * Copyright (c) 2008 Federico G. Benavento <benavento@gmail.com>
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "x9dev.h"
+#include "keymap.h"
+
+#define KF      0xF000
+#define Kdown   0x80
+
+extern x9devInfo x9di;
+extern DeviceIntPtr x9devKeybd;
+static CARD8 modmap[MAP_LENGTH];
+
+#define e    ev.u.u
+#define ek    ev.u.keyButtonPointer
+
+static void
+x9devSendKeybdEvent(int k, int t)
+{
+    xEvent ev;
+
+    memset(&ev, 0, sizeof(xEvent));
+    e.type = t;
+    e.detail = k + MIN_KEYCODE;
+    ek.time = GetTimeInMillis();
+    mieqEnqueue(x9devKeybd, (InternalEvent *)&ev);
+}
+
+#undef ek
+#undef e
+
+static wchar_t
+x9devKeybdRead(void)
+{
+    static char s[3];
+    static int  n = 0;
+    wchar_t rune;
+
+    if(read(x9di.kfd, s+n, 1) != 1)
+        return 0;
+
+    rune = s[0];
+
+    if (n > 0 || (rune & 0x80) != 0x00) {
+        if (mbtowc(&rune, s, n + 1) == -1) {
+            if (++n == 3)
+                n = 0;
+            return 0;
+        }
+        n = 0;
+    }
+
+    if (rune == Kdown)
+        rune = 0x99;
+    else if (rune & KF)
+        rune = (rune&~KF) + 0x80;
+
+    return rune;
+}
+
+int  
+x9devKeybdHandle(void)
+{
+    unsigned char   k, m;
+    int c;
+
+    c = x9devKeybdRead();
+    if (c == 0 || c > sizeof(rune2keycode))
+        return 0;
+
+    k = rune2keycode[c].key;
+    if (k == 0)
+        return 0;
+
+    m = rune2keycode[c].mod;
+    if (m) 
+        x9devSendKeybdEvent(m, KeyPress);
+
+    x9devSendKeybdEvent(k, KeyPress);
+    x9devSendKeybdEvent(k, KeyRelease);
+    if (m) 
+        x9devSendKeybdEvent(m, KeyRelease);
+
+    return 1;
+}
+
+static void
+x9devInitModmap(void)
+{
+    KeySym * ks;
+    int i;
+
+    for (i = 0; i < MAP_LENGTH; i++)
+        modmap[i] = NoSymbol;
+
+    for (i = MIN_KEYCODE, ks = map; i < (MIN_KEYCODE + NUM_KEYCODES); i++, ks += MAP_WIDTH)
+        switch (*ks) {
+        case XK_Shift_L:
+        case XK_Shift_R:
+            modmap[i] = ShiftMask;
+            break;
+        case XK_Control_L:
+        case XK_Control_R:
+            modmap[i] = ControlMask;
+            break;
+        case XK_Alt_L:
+        case XK_Alt_R:
+            modmap[i] = Mod1Mask;
+            break;
+        }
+}
+
+int  
+x9devKeybdProc(DeviceIntPtr pDev, int what)
+{
+    switch (what) {
+    case DEVICE_INIT:
+        x9devInitModmap();
+        if (!InitKeyboardDeviceStruct(pDev, NULL, 
+            (BellProcPtr)NoopDDA, (KbdCtrlProcPtr)NoopDDA))
+            FatalError("can't init keyboard");
+	pDev->inited = TRUE;
+        break;
+    case DEVICE_ON:
+        pDev->enabled = TRUE;
+        break;
+    case DEVICE_CLOSE:
+	break;
+    case DEVICE_OFF:
+        pDev->enabled = FALSE;
+        break;
+    }
+    return Success;
+}
+
+Bool
+x9checkmod(unsigned int k, DeviceIntPtr pDev)
+{
+    return modmap[k] != 0;
+}
--- /dev/null
+++ b/keymap.h
@@ -1,0 +1,560 @@
+/* the key names define come from xwin/winkeynames.h, hence the NOTICE */
+
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Thomas Roell not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Thomas Roell makes no representations
+ * about the suitability of this software for any purpose.  It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+#define MAP_WIDTH   4
+#define NUM_KEYCODES    248
+#define MIN_KEYCODE     8
+#define MAX_KEYCODE     (NUM_KEYCODES + MIN_KEYCODE-1)
+
+/*
+ * definition of the AT84/MF101/MF102 Keyboard:
+ * ============================================================
+ *       Defined             Key Cap Glyphs       Pressed value
+ *      Key Name            Main       Also       (hex)    (dec)
+ *      ----------------   ---------- -------    ------    ------
+ */
+
+#define KEY_Escape       /* Escape                0x01  */    1  
+#define KEY_1            /* 1           !         0x02  */    2 
+#define KEY_2            /* 2           @         0x03  */    3 
+#define KEY_3            /* 3           #         0x04  */    4 
+#define KEY_4            /* 4           $         0x05  */    5 
+#define KEY_5            /* 5           %         0x06  */    6 
+#define KEY_6            /* 6           ^         0x07  */    7 
+#define KEY_7            /* 7           &         0x08  */    8 
+#define KEY_8            /* 8           *         0x09  */    9 
+#define KEY_9            /* 9           (         0x0a  */   10 
+#define KEY_0            /* 0           )         0x0b  */   11 
+#define KEY_Minus        /* - (Minus)   _ (Under) 0x0c  */   12
+#define KEY_Equal        /* = (Equal)   +         0x0d  */   13 
+#define KEY_BackSpace    /* Back Space            0x0e  */   14 
+#define KEY_Tab          /* Tab                   0x0f  */   15
+#define KEY_Q            /* Q                     0x10  */   16
+#define KEY_W            /* W                     0x11  */   17
+#define KEY_E            /* E                     0x12  */   18
+#define KEY_R            /* R                     0x13  */   19
+#define KEY_T            /* T                     0x14  */   20
+#define KEY_Y            /* Y                     0x15  */   21
+#define KEY_U            /* U                     0x16  */   22
+#define KEY_I            /* I                     0x17  */   23
+#define KEY_O            /* O                     0x18  */   24
+#define KEY_P            /* P                     0x19  */   25
+#define KEY_LBrace       /* [           {         0x1a  */   26
+#define KEY_RBrace       /* ]           }         0x1b  */   27 
+#define KEY_Enter        /* Enter                 0x1c  */   28
+#define KEY_LCtrl        /* Ctrl(left)            0x1d  */   29
+#define KEY_A            /* A                     0x1e  */   30
+#define KEY_S            /* S                     0x1f  */   31
+#define KEY_D            /* D                     0x20  */   32 
+#define KEY_F            /* F                     0x21  */   33
+#define KEY_G            /* G                     0x22  */   34
+#define KEY_H            /* H                     0x23  */   35
+#define KEY_J            /* J                     0x24  */   36
+#define KEY_K            /* K                     0x25  */   37
+#define KEY_L            /* L                     0x26  */   38
+#define KEY_SemiColon    /* ;(SemiColon) :(Colon) 0x27  */   39
+#define KEY_Quote        /* ' (Apostr)  " (Quote) 0x28  */   40
+#define KEY_Tilde        /* ` (Accent)  ~ (Tilde) 0x29  */   41
+#define KEY_ShiftL       /* Shift(left)           0x2a  */   42
+#define KEY_BSlash       /* \(BckSlash) |(VertBar)0x2b  */   43
+#define KEY_Z            /* Z                     0x2c  */   44
+#define KEY_X            /* X                     0x2d  */   45
+#define KEY_C            /* C                     0x2e  */   46
+#define KEY_V            /* V                     0x2f  */   47
+#define KEY_B            /* B                     0x30  */   48
+#define KEY_N            /* N                     0x31  */   49
+#define KEY_M            /* M                     0x32  */   50
+#define KEY_Comma        /* , (Comma)   < (Less)  0x33  */   51
+#define KEY_Period       /* . (Period)  >(Greater)0x34  */   52
+#define KEY_Slash        /* / (Slash)   ?         0x35  */   53
+#define KEY_ShiftR       /* Shift(right)          0x36  */   54
+#define KEY_KP_Multiply  /* *                     0x37  */   55
+#define KEY_Alt          /* Alt(left)             0x38  */   56
+#define KEY_Space        /*   (SpaceBar)          0x39  */   57
+#define KEY_CapsLock     /* CapsLock              0x3a  */   58
+#define KEY_F1           /* F1                    0x3b  */   59
+#define KEY_F2           /* F2                    0x3c  */   60
+#define KEY_F3           /* F3                    0x3d  */   61
+#define KEY_F4           /* F4                    0x3e  */   62
+#define KEY_F5           /* F5                    0x3f  */   63
+#define KEY_F6           /* F6                    0x40  */   64
+#define KEY_F7           /* F7                    0x41  */   65
+#define KEY_F8           /* F8                    0x42  */   66
+#define KEY_F9           /* F9                    0x43  */   67
+#define KEY_F10          /* F10                   0x44  */   68
+#define KEY_NumLock      /* NumLock               0x45  */   69
+#define KEY_ScrollLock   /* ScrollLock            0x46  */   70
+#define KEY_KP_7         /* 7           Home      0x47  */   71 
+#define KEY_KP_8         /* 8           Up        0x48  */   72 
+#define KEY_KP_9         /* 9           PgUp      0x49  */   73 
+#define KEY_KP_Minus     /* - (Minus)             0x4a  */   74
+#define KEY_KP_4         /* 4           Left      0x4b  */   75
+#define KEY_KP_5         /* 5                     0x4c  */   76
+#define KEY_KP_6         /* 6           Right     0x4d  */   77
+#define KEY_KP_Plus      /* + (Plus)              0x4e  */   78
+#define KEY_KP_1         /* 1           End       0x4f  */   79
+#define KEY_KP_2         /* 2           Down      0x50  */   80
+#define KEY_KP_3         /* 3           PgDown    0x51  */   81
+#define KEY_KP_0         /* 0           Insert    0x52  */   82
+#define KEY_KP_Decimal   /* . (Decimal) Delete    0x53  */   83 
+#define KEY_SysReqest    /* SysReqest             0x54  */   84
+                         /* NOTUSED               0x55  */
+#define KEY_Less         /* < (Less)   >(Greater) 0x56  */   86
+#define KEY_F11          /* F11                   0x57  */   87
+#define KEY_F12          /* F12                   0x58  */   88
+
+#define KEY_Prefix0      /* special               0x60  */   96
+#define KEY_Prefix1      /* specail               0x61  */   97
+
+/*
+ * The 'scancodes' below are generated by the server, because the MF101/102
+ * keyboard sends them as sequence of other scancodes
+ */
+#define KEY_Home         /* Home                  0x59  */   89
+#define KEY_Up           /* Up                    0x5a  */   90
+#define KEY_PgUp         /* PgUp                  0x5b  */   91
+#define KEY_Left         /* Left                  0x5c  */   92
+#define KEY_Begin        /* Begin                 0x5d  */   93
+#define KEY_Right        /* Right                 0x5e  */   94
+#define KEY_End          /* End                   0x5f  */   95
+#define KEY_Down         /* Down                  0x60  */   96
+#define KEY_PgDown       /* PgDown                0x61  */   97
+#define KEY_Insert       /* Insert                0x62  */   98
+#define KEY_Delete       /* Delete                0x63  */   99
+#define KEY_KP_Enter     /* Enter                 0x64  */  100
+#define KEY_RCtrl        /* Ctrl(right)           0x65  */  101
+#define KEY_Pause        /* Pause                 0x66  */  102
+#define KEY_Print        /* Print                 0x67  */  103
+#define KEY_KP_Divide    /* Divide                0x68  */  104
+#define KEY_AltLang      /* AtlLang(right)        0x69  */  105
+#define KEY_Break        /* Break                 0x6a  */  106
+#define KEY_LMeta        /* Left Meta             0x6b  */  107
+#define KEY_RMeta        /* Right Meta            0x6c  */  108
+#define KEY_Menu         /* Menu                  0x6d  */  109
+#define KEY_F13          /* F13                   0x6e  */  110
+#define KEY_F14          /* F14                   0x6f  */  111
+#define KEY_F15          /* F15                   0x70  */  112
+#define KEY_F16          /* F16                   0x71  */  113
+#define KEY_F17          /* F17                   0x72  */  114
+#define KEY_KP_DEC       /* KP_DEC                0x73  */  115
+#define KEY_KP_Equal     /* Equal (Keypad)        0x76  */  118
+#define KEY_XFER         /* Kanji Transfer        0x79  */  121
+#define KEY_NFER         /* No Kanji Transfer     0x7b  */  123
+#define KEY_Yen          /* Yen                   0x7d  */  125
+#define KEY_HKTG         /* Hirugana/Katakana tog 0xc8  */  200
+#define KEY_BSlash2      /* \           _         0xcb  */  203
+
+struct{
+    unsigned char key, mod;
+}rune2keycode[] = {
+    KEY_Delete, KEY_ShiftL, /* 0x000 */
+    KEY_A,  KEY_LCtrl,  /* 0x001 */
+    KEY_B,  KEY_LCtrl,  /* 0x002 */
+    KEY_C,  KEY_LCtrl,  /* 0x003 */
+    KEY_D,  KEY_LCtrl,  /* 0x004 */
+    KEY_E,  KEY_LCtrl,  /* 0x005 */
+    KEY_F,  KEY_LCtrl,  /* 0x006 */
+    KEY_G,  KEY_LCtrl,  /* 0x007 */
+    KEY_BackSpace,  0,  /* 0x008 */
+    KEY_Tab,    0,  /* 0x009 */
+    KEY_Enter,  0,  /* 0x00a */
+    KEY_K,  KEY_LCtrl,  /* 0x00b */
+    KEY_L,  KEY_LCtrl,  /* 0x00c */
+    KEY_M,    KEY_LCtrl,  /* 0x00d */
+    KEY_N,  KEY_LCtrl,  /* 0x00e */
+    KEY_O,  KEY_LCtrl,  /* 0x00f */
+    KEY_P,  KEY_LCtrl,  /* 0x010 */
+    KEY_Q,  KEY_LCtrl,  /* 0x011 */
+    KEY_R,  KEY_LCtrl,  /* 0x012 */
+    KEY_S,  KEY_LCtrl,  /* 0x013 */
+    KEY_T,  KEY_LCtrl,  /* 0x014 */
+    KEY_U,  KEY_LCtrl,  /* 0x015 */
+    KEY_V,  KEY_LCtrl,  /* 0x016 */
+    KEY_W,  KEY_LCtrl,  /* 0x017 */
+    KEY_X,  KEY_LCtrl,  /* 0x018 */
+    KEY_Y,  KEY_LCtrl,  /* 0x019 */
+    KEY_Z,  KEY_LCtrl,  /* 0x01a */
+    KEY_Escape, 0,  /* 0x01b */
+    KEY_BSlash, KEY_LCtrl,  /* 0x01c */
+    KEY_RBrace, KEY_LCtrl,  /* 0x01d */
+    KEY_Period, KEY_LCtrl,  /* 0x01e */
+    KEY_Slash,  KEY_LCtrl,  /* 0x01f */
+    KEY_Space,  0,  /* 0x020 */
+    KEY_1,  KEY_ShiftL, /* 0x021 */
+    KEY_Quote,  KEY_ShiftL, /* 0x022 */
+    KEY_3,  KEY_ShiftL, /* 0x023 */
+    KEY_4,  KEY_ShiftL, /* 0x024 */
+    KEY_5,  KEY_ShiftL, /* 0x025 */
+    KEY_7,  KEY_ShiftL, /* 0x026 */
+    KEY_Quote,  0,  /* 0x027 */
+    KEY_9,  KEY_ShiftL, /* 0x028 */
+    KEY_0,  KEY_ShiftL, /* 0x029 */
+    KEY_8,  KEY_ShiftL, /* 0x02a */
+    KEY_Equal,  KEY_ShiftL, /* 0x02b */
+    KEY_Comma,  0,  /* 0x02c */
+    KEY_KP_Minus,   0,  /* 0x02d */
+    KEY_Period,0,   /* 0x02e */
+    KEY_Slash,  0,  /* 0x02f */
+    KEY_0,  0,  /* 0x030 */
+    KEY_1,  0,  /* 0x031 */
+    KEY_2,  0,  /* 0x032 */
+    KEY_3,  0,  /* 0x033 */
+    KEY_4,  0,  /* 0x034 */
+    KEY_5,  0,  /* 0x035 */
+    KEY_6,  0,  /* 0x036 */
+    KEY_7,  0,  /* 0x037 */
+    KEY_8,  0,  /* 0x038 */
+    KEY_9,  0,  /* 0x039 */
+    KEY_SemiColon,  KEY_ShiftL, /* 0x03a */
+    KEY_SemiColon,  0,  /* 0x03b */
+    KEY_Comma,  KEY_ShiftL, /* 0x03c */
+    KEY_Equal,  0,  /* 0x03d */
+    KEY_Period, KEY_ShiftL, /* 0x03e */
+    KEY_Slash,  KEY_ShiftL, /* 0x03f */
+    KEY_2,  KEY_ShiftL, /* 0x040 */
+    KEY_A,  KEY_ShiftL, /* 0x041 */
+    KEY_B,  KEY_ShiftL, /* 0x042 */
+    KEY_C,  KEY_ShiftL, /* 0x043 */
+    KEY_D,  KEY_ShiftL, /* 0x044 */
+    KEY_E,  KEY_ShiftL, /* 0x045 */
+    KEY_F,  KEY_ShiftL, /* 0x046 */
+    KEY_G,  KEY_ShiftL, /* 0x047 */
+    KEY_H,  KEY_ShiftL, /* 0x048 */
+    KEY_I,  KEY_ShiftL, /* 0x049 */
+    KEY_J,  KEY_ShiftL, /* 0x04a */
+    KEY_K,  KEY_ShiftL, /* 0x04b */
+    KEY_L,  KEY_ShiftL, /* 0x04c */
+    KEY_M,  KEY_ShiftL, /* 0x04d */
+    KEY_N,  KEY_ShiftL, /* 0x04e */
+    KEY_O,  KEY_ShiftL, /* 0x04f */
+    KEY_P,  KEY_ShiftL, /* 0x050 */
+    KEY_Q,  KEY_ShiftL, /* 0x051 */
+    KEY_R,  KEY_ShiftL, /* 0x052 */
+    KEY_S,  KEY_ShiftL, /* 0x053 */
+    KEY_T,  KEY_ShiftL, /* 0x054 */
+    KEY_U,  KEY_ShiftL, /* 0x055 */
+    KEY_V,  KEY_ShiftL, /* 0x056 */
+    KEY_W,  KEY_ShiftL, /* 0x057 */
+    KEY_X,  KEY_ShiftL, /* 0x058 */
+    KEY_Y,  KEY_ShiftL, /* 0x059 */
+    KEY_Z,  KEY_ShiftL, /* 0x05a */
+    KEY_LBrace, 0,  /* 0x05b */
+    KEY_BSlash, 0,  /* 0x05c */
+    KEY_RBrace, 0,  /* 0x05d */
+    KEY_6,  KEY_ShiftL, /* 0x05e */
+    KEY_Minus,  KEY_ShiftL, /* 0x05f */
+    KEY_Tilde,0,    /* 0x060 */
+    KEY_A,  0,  /* 0x061 */
+    KEY_B,  0,  /* 0x062 */
+    KEY_C,  0,  /* 0x063 */
+    KEY_D,  0,  /* 0x064 */
+    KEY_E,  0,  /* 0x065 */
+    KEY_F,  0,  /* 0x066 */
+    KEY_G,  0,  /* 0x067 */
+    KEY_H,  0,  /* 0x068 */
+    KEY_I,  0,  /* 0x069 */
+    KEY_J,  0,  /* 0x06a */
+    KEY_K,  0,  /* 0x06b */
+    KEY_L,  0,  /* 0x06c */
+    KEY_M,  0,  /* 0x06d */
+    KEY_N,  0,  /* 0x06e */
+    KEY_O,  0,  /* 0x06f */
+    KEY_P,  0,  /* 0x070 */
+    KEY_Q,  0,  /* 0x071 */
+    KEY_R,  0,  /* 0x072 */
+    KEY_S,  0,  /* 0x073 */
+    KEY_T,  0,  /* 0x074 */
+    KEY_U,  0,  /* 0x075 */
+    KEY_V,  0,  /* 0x076 */
+    KEY_W,  0,  /* 0x077 */
+    KEY_X,  0,  /* 0x078 */
+    KEY_Y,  0,  /* 0x079 */
+    KEY_Z,  0,  /* 0x07a */
+    KEY_LBrace, KEY_ShiftL, /* 0x07b */
+    KEY_BSlash, KEY_ShiftL, /* 0x07c */
+    KEY_RBrace, KEY_ShiftL, /* 0x07d */
+    KEY_Tilde,  KEY_ShiftL, /* 0x07e */
+    KEY_Delete, 0,  /* 0x07f */
+    0,   0,  /* 0x080 */
+    KEY_F1,  0,  /* 0x081 */
+    KEY_F2,  0,  /* 0x082 */
+    KEY_F3,  0,  /* 0x083 */
+    KEY_F4,  0,  /* 0x084 */
+    KEY_F5,  0,  /* 0x085 */
+    KEY_F6,  0,  /* 0x086 */
+    KEY_F7,  0,  /* 0x087 */
+    KEY_F8,  0,  /* 0x088 */
+    KEY_F9,  0,  /* 0x089 */
+    KEY_F10,  0,  /* 0x08a */
+    KEY_F11,  0,  /* 0x08b */
+    KEY_F12,  0,  /* 0x08c */
+    KEY_Home,  0,  /* 0x08d */
+    KEY_Up,  0,  /* 0x08e */
+    KEY_PgUp,  0,  /* 0x08f */
+    KEY_Print,  0,  /* 0x090 */
+    KEY_Left,  0,  /* 0x091 */
+    KEY_Right,  0,  /* 0x092 */
+    KEY_PgDown,  0,  /* 0x093 */
+    KEY_Insert,  0,  /* 0x094 */
+    0,  0,  /* 0x095 */
+    0,  0,  /* 0x096 */
+    0,  0,  /* 0x097 */
+    KEY_End,  0,  /* 0x098 */
+    KEY_Down,  0,  /* 0x099 */
+    0,  0,  /* 0x09a */
+    0,  0,  /* 0x09b */
+    0,  0,  /* 0x09c */
+    0,  0,  /* 0x09d */
+    0,  0,  /* 0x09e */
+    0,  0,  /* 0x09f */
+    0,  0,  /* 0x0a0 */
+    0,  0,  /* 0x0a1 */
+    0,  0,  /* 0x0a2 */
+    0,  0,  /* 0x0a3 */
+    0,  0,  /* 0x0a4 */
+    0,  0,  /* 0x0a5 */
+    0,  0,  /* 0x0a6 */
+    0,  0,  /* 0x0a7 */
+    0,  0,  /* 0x0a8 */
+    0,  0,  /* 0x0a9 */
+    0,  0,  /* 0x0aa */
+    0,  0,  /* 0x0ab */
+    0,  0,  /* 0x0ac */
+    0,  0,  /* 0x0ad */
+    0,  0,  /* 0x0ae */
+    0,  0,  /* 0x0af */
+    0,  0,  /* 0x0b0 */
+    0,  0,  /* 0x0b1 */
+    0,  0,  /* 0x0b2 */
+    0,  0,  /* 0x0b3 */
+    0,  0,  /* 0x0b4 */
+    0,  0,  /* 0x0b5 */
+    0,  0,  /* 0x0b6 */
+    0,  0,  /* 0x0b7 */
+    0,  0,  /* 0x0b8 */
+    0,  0,  /* 0x0b9 */
+    0,  0,  /* 0x0ba */
+    0,  0,  /* 0x0bb */
+    0,  0,  /* 0x0bc */
+    0,  0,  /* 0x0bd */
+    0,  0,  /* 0x0be */
+    0,  0,  /* 0x0bf */
+    0,  0,  /* 0x0c0 */
+    0,  0,  /* 0x0c1 */
+    0,  0,  /* 0x0c2 */
+    0,  0,  /* 0x0c3 */
+    0,  0,  /* 0x0c4 */
+    0,  0,  /* 0x0c5 */
+    0,  0,  /* 0x0c6 */
+    0,  0,  /* 0x0c7 */
+    0,  0,  /* 0x0c8 */
+    0,  0,  /* 0x0c9 */
+    0,  0,  /* 0x0ca */
+    0,  0,  /* 0x0cb */
+    0,  0,  /* 0x0cc */
+    0,  0,  /* 0x0cd */
+    0,  0,  /* 0x0ce */
+    0,  0,  /* 0x0cf */
+    0,  0,  /* 0x0d0 */
+    0,  0,  /* 0x0d1 */
+    0,  0,  /* 0x0d2 */
+    0,  0,  /* 0x0d3 */
+    0,  0,  /* 0x0d4 */
+    0,  0,  /* 0x0d5 */
+    0,  0,  /* 0x0d6 */
+    0,  0,  /* 0x0d7 */
+    0,  0,  /* 0x0d8 */
+    0,  0,  /* 0x0d9 */
+    0,  0,  /* 0x0da */
+    0,  0,  /* 0x0db */
+    0,  0,  /* 0x0dc */
+    0,  0,  /* 0x0dd */
+    0,  0,  /* 0x0de */
+    0,  0,  /* 0x0df */
+    0,  0,  /* 0x0e0 */
+    0,  0,  /* 0x0e1 */
+    0,  0,  /* 0x0e2 */
+    0,  0,  /* 0x0e3 */
+    0,  0,  /* 0x0e4 */
+    0,  0,  /* 0x0e5 */
+    0,  0,  /* 0x0e6 */
+    0,  0,  /* 0x0e7 */
+    0,  0,  /* 0x0e8 */
+    0,  0,  /* 0x0e9 */
+    0,  0,  /* 0x0ea */
+    0,  0,  /* 0x0eb */
+    0,  0,  /* 0x0ec */
+    0,  0,  /* 0x0ed */
+    0,  0,  /* 0x0ee */
+    0,  0,  /* 0x0ef */
+    0,  0,  /* 0x0f0 */
+    0,  0,  /* 0x0f1 */
+    0,  0,  /* 0x0f2 */
+    0,  0,  /* 0x0f3 */
+    0,  0,  /* 0x0f4 */
+    0,  0,  /* 0x0f5 */
+    0,  0,  /* 0x0f6 */
+    0,  0,  /* 0x0f7 */
+    0,  0,  /* 0x0f8 */
+    0,  0,  /* 0x0f9 */
+    0,  0,  /* 0x0fa */
+    0,  0,  /* 0x0fb */
+    0,  0,  /* 0x0fc */
+    0,  0,  /* 0x0fd */
+    0,  0,  /* 0x0fe */
+    0,  0,  /* 0x0ff */
+};
+
+/* from xwin/winkeymap.h */
+static KeySym map[NUM_KEYCODES*MAP_WIDTH]={
+    /* 0x00 */  NoSymbol,       NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x01 */  XK_Escape,      NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x02 */  XK_1,           XK_exclam,  NoSymbol,   NoSymbol,
+    /* 0x03 */  XK_2,           XK_at,      NoSymbol,   NoSymbol,
+    /* 0x04 */  XK_3,           XK_numbersign,  NoSymbol,   NoSymbol,
+    /* 0x05 */  XK_4,           XK_dollar,  NoSymbol,   NoSymbol,
+    /* 0x06 */  XK_5,           XK_percent, NoSymbol,   NoSymbol,
+    /* 0x07 */  XK_6,           XK_asciicircum, NoSymbol,   NoSymbol,
+    /* 0x08 */  XK_7,           XK_ampersand,   NoSymbol,   NoSymbol,
+    /* 0x09 */  XK_8,           XK_asterisk,    NoSymbol,   NoSymbol,
+    /* 0x0a */  XK_9,           XK_parenleft,   NoSymbol,   NoSymbol,
+    /* 0x0b */  XK_0,           XK_parenright,  NoSymbol,   NoSymbol,
+    /* 0x0c */  XK_minus,       XK_underscore,  NoSymbol,   NoSymbol,
+    /* 0x0d */  XK_equal,       XK_plus,    NoSymbol,   NoSymbol,
+    /* 0x0e */  XK_BackSpace,   NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x0f */  XK_Tab,         XK_ISO_Left_Tab,NoSymbol,   NoSymbol,
+    /* 0x10 */  XK_Q,           NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x11 */  XK_W,           NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x12 */  XK_E,           NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x13 */  XK_R,           NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x14 */  XK_T,           NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x15 */  XK_Y,           NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x16 */  XK_U,           NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x17 */  XK_I,           NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x18 */  XK_O,           NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x19 */  XK_P,           NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x1a */  XK_bracketleft, XK_braceleft,   NoSymbol,   NoSymbol,
+    /* 0x1b */  XK_bracketright,XK_braceright,  NoSymbol,   NoSymbol,
+    /* 0x1c */  XK_Return,      NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x1d */  XK_Control_L,   NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x1e */  XK_A,           NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x1f */  XK_S,           NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x20 */  XK_D,           NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x21 */  XK_F,           NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x22 */  XK_G,           NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x23 */  XK_H,           NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x24 */  XK_J,           NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x25 */  XK_K,           NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x26 */  XK_L,           NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x27 */  XK_semicolon,   XK_colon,   NoSymbol,   NoSymbol,
+    /* 0x28 */  XK_quoteright,  XK_quotedbl,    NoSymbol,   NoSymbol,
+    /* 0x29 */  XK_quoteleft,   XK_asciitilde,  NoSymbol,   NoSymbol,
+    /* 0x2a */  XK_Shift_L,     NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x2b */  XK_backslash,   XK_bar,     NoSymbol,   NoSymbol,
+    /* 0x2c */  XK_Z,           NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x2d */  XK_X,           NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x2e */  XK_C,           NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x2f */  XK_V,           NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x30 */  XK_B,           NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x31 */  XK_N,           NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x32 */  XK_M,           NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x33 */  XK_comma,       XK_less,    NoSymbol,   NoSymbol,
+    /* 0x34 */  XK_period,      XK_greater, NoSymbol,   NoSymbol,
+    /* 0x35 */  XK_slash,       XK_question,    NoSymbol,   NoSymbol,
+    /* 0x36 */  XK_Shift_R,     NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x37 */  XK_KP_Multiply, NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x38 */  XK_Alt_L,   XK_Meta_L,  NoSymbol,   NoSymbol,
+    /* 0x39 */  XK_space,       NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x3a */  XK_Caps_Lock,   NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x3b */  XK_F1,          NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x3c */  XK_F2,          NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x3d */  XK_F3,          NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x3e */  XK_F4,          NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x3f */  XK_F5,          NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x40 */  XK_F6,          NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x41 */  XK_F7,          NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x42 */  XK_F8,          NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x43 */  XK_F9,          NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x44 */  XK_F10,         NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x45 */  XK_Num_Lock,    NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x46 */  XK_Scroll_Lock, NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x47 */  XK_KP_Home, XK_KP_7,    NoSymbol,   NoSymbol,
+    /* 0x48 */  XK_KP_Up,   XK_KP_8,    NoSymbol,   NoSymbol,
+    /* 0x49 */  XK_KP_Prior,    XK_KP_9,    NoSymbol,   NoSymbol,
+    /* 0x4a */  XK_KP_Subtract, NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x4b */  XK_KP_Left, XK_KP_4,    NoSymbol,   NoSymbol,
+    /* 0x4c */  XK_KP_Begin,    XK_KP_5,    NoSymbol,   NoSymbol,
+    /* 0x4d */  XK_KP_Right,    XK_KP_6,    NoSymbol,   NoSymbol,
+    /* 0x4e */  XK_KP_Add,      NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x4f */  XK_KP_End,  XK_KP_1,    NoSymbol,   NoSymbol,
+    /* 0x50 */  XK_KP_Down, XK_KP_2,    NoSymbol,   NoSymbol,
+    /* 0x51 */  XK_KP_Next, XK_KP_3,    NoSymbol,   NoSymbol,
+    /* 0x52 */  XK_KP_Insert,   XK_KP_0,    NoSymbol,   NoSymbol,
+    /* 0x53 */  XK_KP_Delete,   XK_KP_Decimal,  NoSymbol,   NoSymbol,
+    /* 0x54 */  XK_Sys_Req, NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x55 */  NoSymbol,   NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x56 */  XK_less,    XK_greater, NoSymbol,   NoSymbol,
+    /* 0x57 */  XK_F11,     NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x58 */  XK_F12,     NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x59 */  XK_Home,    NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x5a */  XK_Up,      NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x5b */  XK_Prior,   NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x5c */  XK_Left,    NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x5d */  XK_Begin,   NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x5e */  XK_Right,   NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x5f */  XK_End,     NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x60 */  XK_Down,    NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x61 */  XK_Next,    NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x62 */  XK_Insert,  NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x63 */  XK_Delete,  NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x64 */  XK_KP_Enter,    NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x65 */  XK_Control_R,   NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x66 */  XK_Pause,   NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x67 */  XK_Print,   NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x68 */  XK_KP_Divide,   NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x69 */  XK_Alt_R,   XK_Meta_R,  NoSymbol,   NoSymbol,
+    /* 0x6a */  XK_Break,   NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x6b */  XK_Meta_L,  NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x6c */  XK_Meta_R,  NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x6d */  XK_Menu,    NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x6e */  XK_F13,     NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x6f */  XK_F14,     NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x70 */  XK_F15,     NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x71 */  XK_F16,     NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x72 */  XK_F17,     NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x73 */  XK_backslash,   XK_underscore,  NoSymbol,   NoSymbol,
+    /* 0x74 */  NoSymbol,   NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x75 */  NoSymbol,   NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x76 */  NoSymbol,   NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x77 */  NoSymbol,   NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x78 */  NoSymbol,   NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x79 */  XK_Henkan,  XK_Mode_switch, NoSymbol,   NoSymbol,
+    /* 0x7a */  NoSymbol,   NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x7b */  XK_Muhenkan,    NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x7c */  NoSymbol,   NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x7d */  XK_backslash,   XK_bar,     NoSymbol,   NoSymbol,
+    /* 0x7e */  NoSymbol,   NoSymbol,   NoSymbol,   NoSymbol,
+    /* 0x7f */  NoSymbol,   NoSymbol,   NoSymbol,   NoSymbol,
+};
--- a/libc9/LICENSE
+++ /dev/null
@@ -1,1 +1,0 @@
-Public domain.
--- a/libc9/README.md
+++ /dev/null
@@ -1,8 +1,0 @@
-# c9
-
-Low level 9p client and server.
-
-## Examples
-
-Until I have time to write a minimal example you could take a look at 
-https://git.sr.ht/~ft/9pro/blob/master/9pex.c
--- a/libc9/c9.c
+++ /dev/null
@@ -1,1170 +1,0 @@
-/*
- * This is 9p client and server implementation which aims to be
- * correct, small and secure. It's the lowest level implementation.
- * It doesn't have much comments, mostly because it doesn't make
- * any sense to copy-paste protocol documentation, which
- * you can read at http://man.cat-v.org/plan_9/5/, see 'intro'.
- */
-#include <stdint.h>
-#include <string.h>
-#include "c9.h"
-
-enum
-{
-	Svver = 1<<0,
-};
-
-#define safestrlen(s) (s == NULL ? 0 : (uint32_t)strlen(s))
-#define maxread(c) (c->msize-4-4-1-2)
-#define maxwrite(c) maxread(c)
-
-static void
-w08(uint8_t **p, uint8_t x)
-{
-	(*p)[0] = x;
-	*p += 1;
-}
-
-static void
-w16(uint8_t **p, uint16_t x)
-{
-	(*p)[0] = x;
-	(*p)[1] = x>>8;
-	*p += 2;
-}
-
-static void
-w32(uint8_t **p, uint32_t x)
-{
-	(*p)[0] = x;
-	(*p)[1] = x>>8;
-	(*p)[2] = x>>16;
-	(*p)[3] = x>>24;
-	*p += 4;
-}
-
-static void
-w64(uint8_t **p, uint64_t x)
-{
-	(*p)[0] = x;
-	(*p)[1] = x>>8;
-	(*p)[2] = x>>16;
-	(*p)[3] = x>>24;
-	(*p)[4] = x>>32;
-	(*p)[5] = x>>40;
-	(*p)[6] = x>>48;
-	(*p)[7] = x>>56;
-	*p += 8;
-}
-
-static void
-wcs(uint8_t **p, const char *s, int len)
-{
-	w16(p, len);
-	if(s != NULL){
-		memmove(*p, s, len);
-		*p += len;
-	}
-}
-
-static uint8_t
-r08(uint8_t **p)
-{
-	*p += 1;
-	return (*p)[-1];
-}
-
-static uint16_t
-r16(uint8_t **p)
-{
-	*p += 2;
-	return (uint16_t)(*p)[-2]<<0 | (uint16_t)(*p)[-1]<<8;
-}
-
-static uint32_t
-r32(uint8_t **p)
-{
-	return r16(p) | (uint32_t)r16(p)<<16;
-}
-
-static uint64_t
-r64(uint8_t **p)
-{
-	return r32(p) | (uint64_t)r32(p)<<32;
-}
-
-#ifndef C9_NO_CLIENT
-
-static C9error
-newtag(C9ctx *c, C9ttype type, C9tag *tag)
-{
-	uint32_t i;
-
-	if(type == Tversion){
-		*tag = 0xffff;
-		return 0;
-	}
-
-	if(c->lowfreetag < C9maxtags){
-		uint32_t d = c->lowfreetag / C9tagsbits, m = c->lowfreetag % C9tagsbits;
-		if((c->tags[d] & 1<<m) != 0){
-			c->tags[d] &= ~(1<<m);
-			*tag = c->lowfreetag++;
-			return 0;
-		}
-	}
-
-	for(i = 0; i < (int)sizeof(c->tags)/sizeof(c->tags[0]); i++){
-		uint32_t x, j;
-		if((x = c->tags[i]) == 0)
-			continue;
-		for(j = 0; j < C9tagsbits; j++){
-			if((x & (1<<j)) != 0){
-				c->tags[i] &= ~(1<<j);
-				*tag = i*C9tagsbits + j;
-				c->lowfreetag = *tag + 1;
-				return 0;
-			}
-		}
-	}
-
-	c->error("newtag: no free tags");
-	return C9Etag;
-}
-
-static int
-freetag(C9ctx *c, C9tag tag)
-{
-	if(tag != 0xffff){
-		uint32_t d = tag / C9tagsbits, m = tag % C9tagsbits;
-		if(tag >= C9maxtags){
-			c->error("freetag: invalid tag %u", (uint32_t)tag);
-			return -1;
-		}
-		if((c->tags[d] & 1<<m) != 0){
-			c->error("freetag: double free for tag %u", (uint32_t)tag);
-			return -1;
-		}
-		if(c->lowfreetag > tag)
-			c->lowfreetag = tag;
-		c->tags[d] |= 1<<m;
-	}
-	return 0;
-}
-
-static uint8_t *
-T(C9ctx *c, uint32_t size, C9ttype type, C9tag *tag, C9error *err)
-{
-	uint8_t *p = NULL;
-
-	if(size > c->msize-4-1-2){
-		c->error("T: invalid size %u", size);
-		*err = C9Esize;
-	}else if((*err = newtag(c, type, tag)) == 0){
-		size += 4+1+2;
-		if((p = c->begin(c, size)) == NULL){
-			c->error("T: no buffer for %u bytes", size);
-			freetag(c, *tag);
-			*err = C9Ebuf;
-		}else{
-			*err = 0;
-			w32(&p, size);
-			w08(&p, type);
-			w16(&p, *tag);
-		}
-	}
-	return p;
-}
-
-C9error
-c9version(C9ctx *c, C9tag *tag, uint32_t msize)
-{
-	uint8_t *b;
-	C9error err;
-
-	if(msize < C9minmsize){
-		c->error("c9version: msize too small: %u", msize);
-		return C9Einit;
-	}
-	memset(c->tags, 0xff, sizeof(c->tags));
-	memset(c->flush, 0xff, sizeof(c->flush));
-	c->lowfreetag = 0;
-	c->msize = msize;
-
-	if((b = T(c, 4+2+6, Tversion, tag, &err)) != NULL){
-		w32(&b, msize);
-		wcs(&b, "9P2000", 6);
-		err = c->end(c);
-	}
-	return err;
-}
-
-C9error
-c9auth(C9ctx *c, C9tag *tag, C9fid afid, const char *uname, const char *aname)
-{
-	uint8_t *b;
-	uint32_t ulen = safestrlen(uname), alen = safestrlen(aname);
-	C9error err;
-
-	if(ulen > C9maxstr || alen > C9maxstr){
-		c->error("c9auth: string too long: %u chars", ulen > alen ? ulen : alen);
-		return C9Estr;
-	}
-	if((b = T(c, 4+2+ulen+2+alen, Tauth, tag, &err)) != NULL){
-		w32(&b, afid);
-		wcs(&b, uname, ulen);
-		wcs(&b, aname, alen);
-		err = c->end(c);
-	}
-	return err;
-}
-
-C9error
-c9flush(C9ctx *c, C9tag *tag, C9tag oldtag)
-{
-	uint8_t *b;
-	C9error err;
-	int i;
-
-	for(i = 0; i < C9maxflush && c->flush[i] != (uint32_t)~0; i++);
-	if(i == C9maxflush){
-		c->error("c9flush: no free flush slots");
-		return C9Eflush;
-	}
-	if((b = T(c, 2, Tflush, tag, &err)) != NULL){
-		w16(&b, oldtag);
-		err = c->end(c);
-		if(err == 0)
-			c->flush[i] = (uint32_t)oldtag<<16 | *tag;
-	}
-	return err;
-}
-
-C9error
-c9attach(C9ctx *c, C9tag *tag, C9fid fid, C9fid afid, const char *uname, const char *aname)
-{
-	uint32_t ulen = safestrlen(uname), alen = safestrlen(aname);
-	uint8_t *b;
-	C9error err;
-
-	if(ulen > C9maxstr || alen > C9maxstr){
-		c->error("c9attach: string too long: %u chars", ulen > alen ? ulen : alen);
-		return C9Estr;
-	}
-	if((b = T(c, 4+4+2+ulen+2+alen, Tattach, tag, &err)) != NULL){
-		w32(&b, fid);
-		w32(&b, afid);
-		wcs(&b, uname, ulen);
-		wcs(&b, aname, alen);
-		err = c->end(c);
-	}
-	return err;
-}
-
-C9error
-c9walk(C9ctx *c, C9tag *tag, C9fid fid, C9fid newfid, const char *path[])
-{
-	uint32_t i, j, sz;
-	uint32_t len[C9maxpathel];
-	uint8_t *b;
-	C9error err;
-
-	for(sz = i = 0; i < (int)sizeof(len)/sizeof(len[0]) && path[i] != NULL; i++){
-		len[i] = safestrlen(path[i]);
-		if(len[i] == 0 || len[i] > C9maxstr){
-			c->error("c9walk: invalid path element: %u chars", len[i]);
-			return C9Epath;
-		}
-		sz += 2 + len[i];
-	}
-	if(path[i] != NULL){
-		c->error("c9walk: invalid elements !(0 <= %u <= %u)", i, C9maxpathel);
-		return C9Epath;
-	}
-
-	if((b = T(c, 4+4+2+sz, Twalk, tag, &err)) != NULL){
-		w32(&b, fid);
-		w32(&b, newfid);
-		w16(&b, i);
-		for(j = 0; j < i; j++)
-			wcs(&b, path[j], len[j]);
-		err = c->end(c);
-	}
-	return err;
-}
-
-C9error
-c9open(C9ctx *c, C9tag *tag, C9fid fid, C9mode mode)
-{
-	uint8_t *b;
-	C9error err;
-
-	if((b = T(c, 4+1, Topen, tag, &err)) != NULL){
-		w32(&b, fid);
-		w08(&b, mode);
-		err = c->end(c);
-	}
-	return err;
-}
-
-C9error
-c9create(C9ctx *c, C9tag *tag, C9fid fid, const char *name, uint32_t perm, C9mode mode)
-{
-	uint32_t nlen = strlen(name);
-	uint8_t *b;
-	C9error err;
-
-	if(nlen == 0 || nlen > C9maxstr){
-		c->error("c9create: invalid name: %u chars", nlen);
-		return C9Epath;
-	}
-	if((b = T(c, 4+2+nlen+4+1, Tcreate, tag, &err)) != NULL){
-		w32(&b, fid);
-		wcs(&b, name, nlen);
-		w32(&b, perm);
-		w08(&b, mode);
-		err = c->end(c);
-	}
-	return err;
-}
-
-C9error
-c9read(C9ctx *c, C9tag *tag, C9fid fid, uint64_t offset, uint32_t count)
-{
-	uint8_t *b;
-	C9error err;
-
-	if((b = T(c, 4+8+4, Tread, tag, &err)) != NULL){
-		w32(&b, fid);
-		w64(&b, offset);
-		w32(&b, count);
-		err = c->end(c);
-	}
-	return err;
-}
-
-C9error
-c9write(C9ctx *c, C9tag *tag, C9fid fid, uint64_t offset, const void *in, uint32_t count)
-{
-	uint8_t *b;
-	C9error err;
-
-	if((b = T(c, 4+8+4+count, Twrite, tag, &err)) != NULL){
-		w32(&b, fid);
-		w64(&b, offset);
-		w32(&b, count);
-		memmove(b, in, count);
-		err = c->end(c);
-	}
-	return err;
-}
-
-C9error
-c9wrstr(C9ctx *c, C9tag *tag, C9fid fid, const char *s)
-{
-	return c9write(c, tag, fid, 0, s, strlen(s));
-}
-
-C9error
-c9clunk(C9ctx *c, C9tag *tag, C9fid fid)
-{
-	uint8_t *b;
-	C9error err;
-
-	if((b = T(c, 4, Tclunk, tag, &err)) != NULL){
-		w32(&b, fid);
-		err = c->end(c);
-	}
-	return err;
-}
-
-C9error
-c9remove(C9ctx *c, C9tag *tag, C9fid fid)
-{
-	uint8_t *b;
-	C9error err;
-
-	if((b = T(c, 4, Tremove, tag, &err)) != NULL){
-		w32(&b, fid);
-		err = c->end(c);
-	}
-	return err;
-}
-
-C9error
-c9stat(C9ctx *c, C9tag *tag, C9fid fid)
-{
-	uint8_t *b;
-	C9error err;
-
-	if((b = T(c, 4, Tstat, tag, &err)) != NULL){
-		w32(&b, fid);
-		err = c->end(c);
-	}
-	return err;
-}
-
-C9error
-c9wstat(C9ctx *c, C9tag *tag, C9fid fid, const C9stat *s)
-{
-	uint32_t nlen = safestrlen(s->name), ulen = safestrlen(s->uid), glen = safestrlen(s->gid);
-	uint32_t unusedsz = 2+4+13, statsz = unusedsz+4+4+4+8+2+nlen+2+ulen+2+glen+2;
-	uint8_t *b;
-	C9error err;
-
-	if(nlen == 0 || nlen > C9maxstr){
-		c->error("c9wstat: invalid name: %u chars", nlen);
-		return C9Epath;
-	}
-	if(ulen > C9maxstr || glen > C9maxstr){
-		c->error("c9wstat: string too long: %u chars", ulen > glen ? ulen : glen);
-		return C9Estr;
-	}
-	if((b = T(c, 4+2+2+statsz, Twstat, tag, &err)) != NULL){
-		w32(&b, fid);
-		w16(&b, statsz+2);
-		w16(&b, statsz);
-		memset(b, 0xff, unusedsz); /* leave type(2), dev(4) and qid(13) unchanged */
-		b += unusedsz;
-		w32(&b, s->mode);
-		w32(&b, s->atime);
-		w32(&b, s->mtime);
-		w64(&b, s->size);
-		wcs(&b, s->name, nlen);
-		wcs(&b, s->uid, ulen);
-		wcs(&b, s->gid, glen);
-		wcs(&b, NULL, 0); /* muid unchanged */
-		err = c->end(c);
-	}
-	return err;
-}
-
-C9error
-c9proc(C9ctx *c)
-{
-	uint32_t i, sz, cnt, msize;
-	uint8_t *b;
-	int err;
-	C9r r;
-
-	err = -1;
-	if((b = c->read(c, 4, &err)) == NULL){
-		if(err != 0)
-			c->error("c9proc: short read");
-		return err == 0 ? 0 : C9Epkt;
-	}
-
-	sz = r32(&b);
-	if(sz < 7 || sz > c->msize){
-		c->error("c9proc: invalid packet size !(7 <= %u <= %u)", sz, c->msize);
-		return C9Epkt;
-	}
-	sz -= 4;
-	err = -1;
-	if((b = c->read(c, sz, &err)) == NULL){
-		if(err != 0)
-			c->error("c9proc: short read");
-		return err == 0 ? 0 : C9Epkt;
-	}
-
-	r.type = r08(&b);
-	r.tag = r16(&b);
-	if(r.type != Rversion){
-		if(r.tag >= C9maxtags){
-			c->error("c9proc: invalid tag %u", (uint32_t)r.tag);
-			return C9Epkt;
-		}
-		if(freetag(c, r.tag) != 0)
-			return C9Etag;
-	}
-	sz -= 3;
-	r.numqid = 0;
-
-	switch(r.type){
-	case Rread:
-		if(sz < 4 || (cnt = r32(&b)) > sz-4)
-			goto error;
-		r.read.data = b;
-		r.read.size = cnt;
-		c->r(c, &r);
-		break;
-
-	case Rwrite:
-		if(sz < 4 || (cnt = r32(&b)) > c->msize)
-			goto error;
-		r.write.size = cnt;
-		c->r(c, &r);
-		break;
-
-	case Rwalk:
-		if(sz < 2 || (cnt = r16(&b))*13 > sz-2)
-			goto error;
-		if(cnt > C9maxpathel){
-			c->error("c9proc: Rwalk !(%u <= %u)", cnt, C9maxpathel);
-			return C9Epath;
-		}
-		for(i = 0; i < cnt; i++){
-			r.qid[i].type = r08(&b);
-			r.qid[i].version = r32(&b);
-			r.qid[i].path = r64(&b);
-		}
-		r.numqid = cnt;
-		c->r(c, &r);
-		break;
-
-	case Rstat:
-		b += 2; sz -= 2;
-		if((err = c9parsedir(c, &r.stat, &b, &sz)) != 0)
-			return err;
-		r.numqid = 1;
-		c->r(c, &r);
-		break;
-
-	case Rflush:
-		for(i = 0; i < C9maxflush; i++){
-			if((c->flush[i] & 0xffff) == r.tag){
-				freetag(c, c->flush[i]>>16);
-				c->flush[i] = 0xffffffff;
-				break;
-			}
-		}
-		/* fallthrough */
-	case Rclunk:
-	case Rremove:
-	case Rwstat:
-		c->r(c, &r);
-		break;
-
-	case Ropen:
-	case Rcreate:
-		if(sz < 17)
-			goto error;
-		r.qid[0].type = r08(&b);
-		r.qid[0].version = r32(&b);
-		r.qid[0].path = r64(&b);
-		r.iounit = r32(&b);
-		r.numqid = 1;
-		c->r(c, &r);
-		break;
-
-	case Rerror:
-		if(sz < 2 || (cnt = r16(&b)) > sz-2)
-			goto error;
-		r.error = memmove(b-1, b, cnt);
-		r.error[cnt] = 0;
-		c->r(c, &r);
-		break;
-
-	case Rauth:
-	case Rattach:
-		if(sz < 13)
-			goto error;
-		r.qid[0].type = r08(&b);
-		r.qid[0].version = r32(&b);
-		r.qid[0].path = r64(&b);
-		r.numqid = 1;
-		c->r(c, &r);
-		break;
-
-	case Rversion:
-		if(sz < 4+2 || (msize = r32(&b)) < C9minmsize || (cnt = r16(&b)) > sz-4-2)
-			goto error;
-		if(cnt < 6 || memcmp(b, "9P2000", 6) != 0){
-			c->error("invalid version");
-			return C9Ever;
-		}
-		if(msize < c->msize)
-			c->msize = msize;
-		c->r(c, &r);
-		break;
-
-	default:
-		goto error;
-	}
-	return 0;
-error:
-	c->error("c9proc: invalid packet type %u", r.type);
-	return C9Epkt;
-}
-
-#endif /* C9_NO_CLIENT */
-
-C9error
-c9parsedir(C9ctx *c, C9stat *stat, uint8_t **t, uint32_t *size)
-{
-	uint8_t *b;
-	uint32_t cnt, sz;
-
-	sz = 0;
-	if(*size < 49 || (sz = r16(t)) < 47 || *size < 2+sz)
-		goto error;
-	*size -= 2+sz;
-	*t += 6; /* skip type(2) and dev(4) */
-	stat->qid.type = r08(t);
-	stat->qid.version = r32(t);
-	stat->qid.path = r64(t);
-	stat->mode = r32(t);
-	stat->atime = r32(t);
-	stat->mtime = r32(t);
-	stat->size = r64(t);
-	sz -= 39;
-	if((cnt = r16(t)) > sz-2)
-		goto error;
-	stat->name = (char*)*t; b = *t = *t+cnt; sz -= 2+cnt;
-	if(sz < 2 || (cnt = r16(t)) > sz-2)
-		goto error;
-	stat->uid = (char*)*t; *b = 0; b = *t = *t+cnt; sz -= 2+cnt;
-	if(sz < 2 || (cnt = r16(t)) > sz-2)
-		goto error;
-	stat->gid = (char*)*t; *b = 0; b = *t = *t+cnt; sz -= 2+cnt;
-	if(sz < 2 || (cnt = r16(t)) > sz-2)
-		goto error;
-	stat->muid = memmove(*t-1, *t, cnt); *b = stat->muid[cnt] = 0; *t = *t+cnt; sz -= 2+cnt;
-	*t += sz;
-	return 0;
-error:
-	c->error("c9parsedir: invalid size: size=%u sz=%u", *size, sz);
-	return C9Epkt;
-}
-
-#ifndef C9_NO_SERVER
-
-static uint8_t *
-R(C9ctx *c, uint32_t size, C9rtype type, C9tag tag, C9error *err)
-{
-	uint8_t *p = NULL;
-
-	if(size > c->msize-4-1-2){
-		c->error("R: invalid size %u", size);
-		*err = C9Esize;
-	}else{
-		size += 4+1+2;
-		if((p = c->begin(c, size)) == NULL){
-			c->error("R: no buffer for %u bytes", size);
-			*err = C9Ebuf;
-		}else{
-			*err = 0;
-			w32(&p, size);
-			w08(&p, type);
-			w16(&p, tag);
-		}
-	}
-	return p;
-}
-
-C9error
-s9version(C9ctx *c)
-{
-	uint8_t *b;
-	C9error err;
-
-	if((b = R(c, 4+2+6, Rversion, 0xffff, &err)) != NULL){
-		w32(&b, c->msize);
-		wcs(&b, "9P2000", 6);
-		err = c->end(c);
-	};
-	return err;
-}
-
-C9error
-s9auth(C9ctx *c, C9tag tag, const C9qid *aqid)
-{
-	uint8_t *b;
-	C9error err;
-
-	if((b = R(c, 13, Rauth, tag, &err)) != NULL){
-		w08(&b, aqid->type);
-		w32(&b, aqid->version);
-		w64(&b, aqid->path);
-		err = c->end(c);
-	}
-	return err;
-}
-
-C9error
-s9error(C9ctx *c, C9tag tag, const char *ename)
-{
-	uint32_t len = safestrlen(ename);
-	uint8_t *b;
-	C9error err;
-
-	if(len > C9maxstr){
-		c->error("s9error: invalid ename: %u chars", len);
-		return C9Estr;
-	}
-	if((b = R(c, 2+len, Rerror, tag, &err)) != NULL){
-		wcs(&b, ename, len);
-		err = c->end(c);
-	}
-	return err;
-}
-
-C9error
-s9attach(C9ctx *c, C9tag tag, const C9qid *qid)
-{
-	uint8_t *b;
-	C9error err;
-
-	if((b = R(c, 13, Rattach, tag, &err)) != NULL){
-		w08(&b, qid->type);
-		w32(&b, qid->version);
-		w64(&b, qid->path);
-		err = c->end(c);
-	}
-	return err;
-}
-
-C9error
-s9flush(C9ctx *c, C9tag tag)
-{
-	uint8_t *b;
-	C9error err;
-
-	if((b = R(c, 0, Rflush, tag, &err)) != NULL)
-		err = c->end(c);
-	return err;
-}
-
-C9error
-s9walk(C9ctx *c, C9tag tag, C9qid *qids[])
-{
-	uint32_t i, n;
-	uint8_t *b;
-	C9error err;
-
-	for(n = 0; n < C9maxpathel && qids[n] != NULL; n++);
-	if(n > C9maxpathel){
-		c->error("s9walk: invalid elements !(0 <= %u <= %u)", n, C9maxpathel);
-		return C9Epath;
-	}
-
-	if((b = R(c, 2+n*13, Rwalk, tag, &err)) != NULL){
-		w16(&b, n);
-		for(i = 0; i < n; i++){
-			w08(&b, qids[i]->type);
-			w32(&b, qids[i]->version);
-			w64(&b, qids[i]->path);
-		}
-		err = c->end(c);
-	}
-	return err;
-}
-
-C9error
-s9open(C9ctx *c, C9tag tag, const C9qid *qid, uint32_t iounit)
-{
-	uint8_t *b;
-	C9error err;
-
-	if((b = R(c, 13+4, Ropen, tag, &err)) != NULL){
-		w08(&b, qid->type);
-		w32(&b, qid->version);
-		w64(&b, qid->path);
-		w32(&b, iounit);
-		err = c->end(c);
-	}
-	return err;
-}
-
-C9error
-s9create(C9ctx *c, C9tag tag, const C9qid *qid, uint32_t iounit)
-{
-	uint8_t *b;
-	C9error err;
-
-	if((b = R(c, 13+4, Rcreate, tag, &err)) != NULL){
-		w08(&b, qid->type);
-		w32(&b, qid->version);
-		w64(&b, qid->path);
-		w32(&b, iounit);
-		err = c->end(c);
-	}
-	return err;
-}
-
-C9error
-s9read(C9ctx *c, C9tag tag, const void *data, uint32_t size)
-{
-	uint8_t *b;
-	C9error err;
-
-	if((b = R(c, 4+size, Rread, tag, &err)) != NULL){
-		w32(&b, size);
-		memmove(b, data, size);
-		err = c->end(c);
-	}
-	return err;
-}
-
-C9error
-s9write(C9ctx *c, C9tag tag, uint32_t size)
-{
-	uint8_t *b;
-	C9error err;
-
-	if((b = R(c, 4, Rwrite, tag, &err)) != NULL){
-		w32(&b, size);
-		err = c->end(c);
-	}
-	return err;
-}
-
-C9error
-s9readdir(C9ctx *c, C9tag tag, C9stat *st[], int *num, uint64_t *offset, uint32_t size)
-{
-	uint8_t *b;
-	const C9stat *s;
-	uint32_t nlen, ulen, glen, mulen, m, n;
-	C9error err;
-	int i;
-
-	if(size > c->msize-4-1-2)
-		size = c->msize-4-1-2;
-
-	m = 0;
-	for(i = 0; i < *num; i++){
-		s = st[i];
-		nlen = safestrlen(s->name);
-		ulen = safestrlen(s->uid);
-		glen = safestrlen(s->gid);
-		mulen = safestrlen(s->muid);
-
-		if(nlen == 0 || nlen > C9maxstr){
-			c->error("s9readdir: invalid name: %u chars", nlen);
-			return C9Epath;
-		}
-		if(ulen > C9maxstr || glen > C9maxstr || mulen > C9maxstr){
-			ulen = ulen > glen ? ulen : glen;
-			ulen = ulen > mulen ? ulen : mulen;
-			c->error("s9readdir: string too long: %u chars", ulen);
-			return C9Estr;
-		}
-
-		n = 2 + 2+4+13+4+4+4+8+2+nlen+2+ulen+2+glen+2+mulen;
-		if(4+m+n > size)
-			break;
-		m += n;
-	}
-
-	if((b = R(c, 4+m, Rread, tag, &err)) != NULL){
-		*num = i;
-		w32(&b, m);
-		for(i = 0; i < *num; i++){
-			s = st[i];
-			nlen = safestrlen(s->name);
-			ulen = safestrlen(s->uid);
-			glen = safestrlen(s->gid);
-			mulen = safestrlen(s->muid);
-			w16(&b, 2+4+13+4+4+4+8+2+nlen+2+ulen+2+glen+2+mulen);
-			w16(&b, 0xffff); /* type */
-			w32(&b, 0xffffffff); /* dev */
-			w08(&b, s->qid.type);
-			w32(&b, s->qid.version);
-			w64(&b, s->qid.path);
-			w32(&b, s->mode);
-			w32(&b, s->atime);
-			w32(&b, s->mtime);
-			w64(&b, s->size);
-			wcs(&b, s->name, nlen);
-			wcs(&b, s->uid, ulen);
-			wcs(&b, s->gid, glen);
-			wcs(&b, s->muid, mulen);
-		}
-		err = c->end(c);
-		if(err == 0)
-			*offset += m;
-	}
-	return err;
-}
-
-C9error
-s9clunk(C9ctx *c, C9tag tag)
-{
-	uint8_t *b;
-	C9error err;
-
-	if((b = R(c, 0, Rclunk, tag, &err)) != NULL)
-		err = c->end(c);
-	return err;
-}
-
-C9error
-s9remove(C9ctx *c, C9tag tag)
-{
-	uint8_t *b;
-	C9error err;
-
-	if((b = R(c, 0, Rremove, tag, &err)) != NULL)
-		err = c->end(c);
-	return err;
-}
-
-C9error
-s9stat(C9ctx *c, C9tag tag, const C9stat *s)
-{
-	uint32_t nlen = safestrlen(s->name), ulen = safestrlen(s->uid);
-	uint32_t glen = safestrlen(s->gid), mulen = safestrlen(s->name);
-	uint32_t statsz = 2+4+13+4+4+4+8+2+nlen+2+ulen+2+glen+2+mulen;
-	uint8_t *b;
-	C9error err;
-
-	if(nlen == 0 || nlen > C9maxstr){
-		c->error("s9stat: invalid name: %u chars", nlen);
-		return C9Epath;
-	}
-	if(ulen > C9maxstr || glen > C9maxstr || mulen > C9maxstr){
-		ulen = ulen > glen ? ulen : glen;
-		ulen = ulen > mulen ? ulen : mulen;
-		c->error("s9stat: string too long: %u chars", ulen);
-		return C9Estr;
-	}
-
-	if((b = R(c, 2+2+statsz, Rstat, tag, &err)) != NULL){
-		w16(&b, statsz+2);
-		w16(&b, statsz);
-		w16(&b, 0xffff); /* type */
-		w32(&b, 0xffffffff); /* dev */
-		w08(&b, s->qid.type);
-		w32(&b, s->qid.version);
-		w64(&b, s->qid.path);
-		w32(&b, s->mode);
-		w32(&b, s->atime);
-		w32(&b, s->mtime);
-		w64(&b, s->size);
-		wcs(&b, s->name, nlen);
-		wcs(&b, s->uid, ulen);
-		wcs(&b, s->gid, glen);
-		wcs(&b, s->muid, mulen);
-		err = c->end(c);
-	}
-	return err;
-}
-
-C9error
-s9wstat(C9ctx *c, C9tag tag)
-{
-	uint8_t *b;
-	C9error err;
-
-	if((b = R(c, 0, Rwstat, tag, &err)) != NULL)
-		err = c->end(c);
-	return err;
-}
-
-C9error
-s9proc(C9ctx *c)
-{
-	uint32_t i, sz, cnt, n, msize;
-	int readerr;
-	uint8_t *b;
-	C9error err;
-	C9t t;
-
-	readerr = -1;
-	if((b = c->read(c, 4, &readerr)) == NULL){
-		if(readerr != 0)
-			c->error("s9proc: short read");
-		return readerr == 0 ? 0 : C9Epkt;
-	}
-
-	sz = r32(&b);
-	if(sz < 7 || sz > c->msize){
-		c->error("s9proc: invalid packet size !(7 <= %u <= %u)", sz, c->msize);
-		return C9Epkt;
-	}
-	sz -= 4;
-	readerr = -1;
-	if((b = c->read(c, sz, &readerr)) == NULL){
-		if(readerr != 0)
-			c->error("s9proc: short read");
-		return readerr == 0 ? 0 : C9Epkt;
-	}
-
-	t.type = r08(&b);
-	t.tag = r16(&b);
-	sz -= 3;
-
-	if((c->svflags & Svver) == 0 && t.type != Tversion){
-		c->error("s9proc: expected Tversion, got %u", t.type);
-		return C9Epkt;
-	}
-
-	switch(t.type){
-	case Tread:
-		if(sz < 4+8+4)
-			goto error;
-		t.fid = r32(&b);
-		t.read.offset = r64(&b);
-		t.read.size = r32(&b);
-		if(t.read.size > maxread(c))
-		  t.read.size = maxread(c);
-		c->t(c, &t);
-		break;
-
-	case Twrite:
-		if(sz < 4+8+4)
-			goto error;
-		t.fid = r32(&b);
-		t.write.offset = r64(&b);
-		if((t.write.size = r32(&b)) < sz-4-8-4)
-			goto error;
-		if(t.write.size > maxwrite(c))
-		  t.write.size = maxwrite(c);
-		t.write.data = b;
-		c->t(c, &t);
-		break;
-
-	case Tclunk:
-	case Tstat:
-	case Tremove:
-		if(sz < 4)
-			goto error;
-		t.fid = r32(&b);
-		c->t(c, &t);
-		break;
-
-	case Twalk:
-		if(sz < 4+4+2)
-			goto error;
-		t.fid = r32(&b);
-		t.walk.newfid = r32(&b);
-		if((n = r16(&b)) > 16){
-			c->error("s9proc: Twalk !(%u <= 16)", n);
-			return C9Epath;
-		}
-		sz -= 4+4+2;
-		if(n > 0){
-			for(i = 0; i < n; i++){
-				if(sz < 2 || (cnt = r16(&b)) > sz-2)
-					goto error;
-				if(cnt < 1){
-					c->error("s9proc: Twalk invalid element [%u]", i);
-					return C9Epath;
-				}
-				b[-2] = 0;
-				t.walk.wname[i] = (char*)b;
-				b += cnt;
-				sz -= 2 + cnt;
-			}
-			memmove(t.walk.wname[i-1]-1, t.walk.wname[i-1], (char*)b - t.walk.wname[i-1]);
-			t.walk.wname[i-1]--;
-			b[-1] = 0;
-		}else
-			i = 0;
-		t.walk.wname[i] = NULL;
-		c->t(c, &t);
-		break;
-
-	case Topen:
-		if(sz < 4+1)
-			goto error;
-		t.fid = r32(&b);
-		t.open.mode = r08(&b);
-		c->t(c, &t);
-		break;
-
-	case Twstat:
-		if(sz < 4+2)
-			goto error;
-		t.fid = r32(&b);
-		if((cnt = r16(&b)) > sz-4)
-			goto error;
-		if((err = c9parsedir(c, &t.wstat, &b, &cnt)) != 0){
-			c->error("s9proc");
-			return err;
-		}
-		c->t(c, &t);
-		break;
-
-	case Tcreate:
-		if(sz < 4+2+4+1)
-			goto error;
-		t.fid = r32(&b);
-		if((cnt = r16(&b)) < 1 || cnt > sz-4-2-4-1)
-			goto error;
-		t.create.name = (char*)b;
-		b += cnt;
-		t.create.perm = r32(&b);
-		t.create.mode = r08(&b);
-		t.create.name[cnt] = 0;
-		c->t(c, &t);
-		break;
-
-	case Tflush:
-		if(sz < 2)
-			goto error;
-		t.flush.oldtag = r16(&b);
-		c->t(c, &t);
-		break;
-
-	case Tversion:
-		if(sz < 4+2 || (msize = r32(&b)) < C9minmsize || (cnt = r16(&b)) > sz-4-2)
-			goto error;
-		if(cnt < 6 || memcmp(b, "9P2000", 6) != 0){
-			if((b = R(c, 4+2+7, Rversion, 0xffff, &err)) != NULL){
-				w32(&b, 0);
-				wcs(&b, "unknown", 7);
-				err = c->end(c);
-				c->error("s9proc: invalid version");
-			}
-			return C9Ever;
-		}
-		if(msize < c->msize)
-			c->msize = msize;
-		c->svflags |= Svver;
-		c->t(c, &t);
-		break;
-
-	case Tattach:
-		if(sz < 4+4+2+2)
-			goto error;
-		t.fid = r32(&b);
-		t.attach.afid = r32(&b);
-		cnt = r16(&b);
-		sz -= 4+4+2;
-		if(cnt+2 > sz)
-			goto error;
-		t.attach.uname = (char*)b;
-		b += cnt;
-		cnt = r16(&b);
-		b[-2] = 0;
-		sz -= cnt+2;
-		if(cnt > sz)
-			goto error;
-		memmove(b-1, b, cnt);
-		t.attach.aname = (char*)b-1;
-		t.attach.aname[cnt] = 0;
-		c->t(c, &t);
-		break;
-
-	case Tauth:
-		if(sz < 4+2+2)
-			goto error;
-		t.auth.afid = r32(&b);
-		cnt = r16(&b);
-		sz -= 4+2;
-		if(cnt+2 > sz)
-			goto error;
-		t.auth.uname = (char*)b;
-		b += cnt;
-		cnt = r16(&b);
-		b[-2] = 0;
-		sz -= cnt+2;
-		if(cnt > sz)
-			goto error;
-		memmove(b-1, b, cnt);
-		t.auth.aname = (char*)b-1;
-		t.auth.aname[cnt] = 0;
-		c->t(c, &t);
-		break;
-
-	default:
-		goto error;
-	}
-	return 0;
-error:
-	c->error("s9proc: invalid packet (type=%u)", t.type);
-	return C9Epkt;
-}
-
-#endif /* C9_NO_SERVER */
--- a/libc9/c9.h
+++ /dev/null
@@ -1,355 +1,0 @@
-struct C9aux;
-
-typedef struct C9r C9r;
-typedef struct C9t C9t;
-typedef struct C9stat C9stat;
-typedef struct C9ctx C9ctx;
-typedef struct C9qid C9qid;
-typedef uint32_t C9fid;
-typedef uint16_t C9tag;
-
-/* Stat field is not changed if it's set to this value when calling c9wstat. */
-#define C9nochange (~0)
-
-/* Special fid used with auth/attach to basically avoid authentication. */
-#define C9nofid ((C9fid)~0)
-
-/* C9modes for opening a file. */
-typedef enum
-{
-	C9read = 0,
-	C9write = 1,
-	C9rdwr = 2,
-	C9exec = 3,
-	C9trunc = 0x10,
-	C9rclose = 0x40,
-}C9mode;
-
-typedef enum
-{
-	/* User/owner. */
-	C9permur = 1<<8, /* Readable. */
-	C9permuw = 1<<7, /* Writable. */
-	C9permux = 1<<6, /* Executable. */
-
-	/* Group. */
-	C9permgr = 1<<5,
-	C9permgw = 1<<4,
-	C9permgx = 1<<3,
-
-	/* Other. */
-	C9permor = 1<<2,
-	C9permow = 1<<1,
-	C9permox = 1<<0,
-}C9perm;
-
-/* Directory. */
-#define C9permdir 0x80000000
-
-/* Bitmask of stat.mode. */
-#define C9stdir 0x80000000
-#define C9stappend 0x40000000
-#define C9stexcl 0x20000000
-#define C9sttmp 0x04000000
-
-/* Limits. */
-enum
-{
-	C9maxtags = 64,    /* Maximal number of outstanding requests. [1-65535] */
-	C9maxflush = 8,    /* Maximal number of outstanding flushes. [1-65535] */
-	C9maxstr = 0xffff, /* Maximal string length. [1-65535] */
-	C9minmsize = 4096, /* Minimal sane msize. [4096-...] */
-	C9maxpathel = 16,  /* Maximal number of elements in a path. Do not change. */
-};
-
-/* Errors. */
-typedef enum
-{
-	C9Einit = -1,  /* Initialization failed. */
-	C9Ever = -2,   /* Protocol version doesn't match. */
-	C9Epkt = -3,   /* Incoming packet error. */
-	C9Etag = -4,   /* No free tags or bad tag. */
-	C9Ebuf = -5,   /* No buffer space enough for a message. */
-	C9Epath = -6,  /* Path is too long or just invalid. */
-	C9Eflush = -7, /* Limit of outstanding flushes reached. */
-	C9Esize = -8,  /* Can't fit data in one message. */
-	C9Estr = -9    /* Bad string. */
-}C9error;
-
-/* Request types. */
-typedef enum
-{
-	Tversion = 100,
-	Tauth = 102,
-	Tattach = 104,
-	Tflush = 108,
-	Twalk = 110,
-	Topen = 112,
-	Tcreate = 114,
-	Tread = 116,
-	Twrite = 118,
-	Tclunk = 120,
-	Tremove = 122,
-	Tstat = 124,
-	Twstat = 126
-}C9ttype;
-
-/* Response types. */
-typedef enum
-{
-	Rversion = 101,
-	Rauth = 103,
-	Rattach = 105,
-	Rerror = 107,
-	Rflush = 109,
-	Rwalk = 111,
-	Ropen = 113,
-	Rcreate = 115,
-	Rread = 117,
-	Rwrite = 119,
-	Rclunk = 121,
-	Rremove = 123,
-	Rstat = 125,
-	Rwstat = 127
-}C9rtype;
-
-/* Unique file id type. */
-typedef enum
-{
-	C9qtdir = 1<<7,
-	C9qtappend = 1<<6,
-	C9qtexcl = 1<<5,
-	C9qtauth = 1<<3,
-	C9qttmp = 1<<2,
-	C9qtfile = 0
-}C9qt;
-
-/* Unique file id. */
-struct C9qid
-{
-	uint64_t path;
-	uint32_t version;
-	C9qt type;
-};
-
-/*
- * File stats. Version and muid are ignored on wstat. Dmdir bit
- * change in mode won't work on wstat. Set any integer field to
- * C9nochange to keep it unchanged on wstat. Set any string to NULL to
- * keep it unchanged. Strings can be empty (""), but never NULL after
- * stat call.
- */
-struct C9stat
-{
-	uint64_t size; /* Size of the file (in bytes). */
-	char *name;  /* Name of the file. */
-	char *uid;   /* Owner of the file. */
-	char *gid;   /* Group of the file. */
-	char *muid;  /* The user who modified the file last. */
-	C9qid qid;   /* Same as qid[0]. */
-	uint32_t mode;   /* Permissions. See C9st* and C9perm. */
-	uint32_t atime;  /* Last access time. */
-	uint32_t mtime;  /* Last modification time. */
-};
-
-/* Response data. */
-struct C9r
-{
-	union
-	{
-		char *error;
-
-		struct
-		{
-			uint8_t *data;
-			uint32_t size;
-		}read;
-
-		struct
-		{
-			uint32_t size;
-		}write;
-
-		/* File stats (only valid if type is Rstat). */
-		C9stat stat;
-
-		/*
-		 * Qid(s). qid[0] is valid for auth/attach/create/stat/open.
-		 * More ids may be a result of a walk, see numqid.
-		 */
-		C9qid qid[C9maxpathel];
-	};
-	C9rtype type; /* Response type. */
-
-	/*
-	 * If not zero, is the maximum number of bytes that are guaranteed
-	 * to be read or written atomically, without breaking into multiple
-	 * messages.
-	 */
-	uint32_t iounit;
-
-	int numqid; /* Number of valid unique ids in qid array. */
-	C9tag tag;  /* Tag number. */
-};
-
-/* Request data. */
-struct C9t
-{
-	C9ttype type;
-	C9tag tag;
-	union
-	{
-		struct
-		{
-			char *uname;
-			char *aname;
-			C9fid afid;
-		}attach;
-
-		struct
-		{
-			char *uname;
-			char *aname;
-			C9fid afid;
-		}auth;
-
-		struct
-		{
-			char *name;
-			uint32_t perm;
-			C9mode mode;
-		}create;
-
-		struct
-		{
-			C9tag oldtag;
-		}flush;
-
-		struct
-		{
-			C9mode mode;
-		}open;
-
-		struct
-		{
-			uint64_t offset;
-			uint32_t size;
-		}read;
-
-		struct
-		{
-			char *wname[C9maxpathel+1]; /* wname[16] is always NULL */
-			C9fid newfid;
-		}walk;
-
-		struct
-		{
-			uint64_t offset;
-			uint8_t *data;
-			uint32_t size;
-		}write;
-
-		C9stat wstat;
-	};
-	C9fid fid;
-};
-
-enum
-{
-	C9tagsbits = sizeof(uint32_t) * 8,
-};
-
-struct C9ctx
-{
-	/*
-	 * Should return a pointer to the data (exactly 'size' bytes) read.
-	 * Set 'err' to non-zero and return NULL in case of error.
-	 * 'err' set to zero (no error) should be used to return from c9process
-	 * early (timeout on read to do non-blocking operations, for example).
-	 */
-	uint8_t *(*read)(C9ctx *ctx, uint32_t size, int *err) __attribute__((nonnull(1, 3)));
-
-	/* Should return a buffer to store 'size' bytes. Nil means no memory. */
-	uint8_t *(*begin)(C9ctx *ctx, uint32_t size) __attribute__((nonnull(1)));
-
-	/*
-	 * Marks the end of a message. Callback may decide if any accumulated
-	 * messages should be sent to the server/client.
-	 */
-	int (*end)(C9ctx *ctx) __attribute__((nonnull(1)));
-
-	/* Callback called every time a new R-message is received. */
-	void (*r)(C9ctx *ctx, C9r *r) __attribute__((nonnull(1, 2)));
-
-	/* Callback called every time a new T-message is received. */
-	void (*t)(C9ctx *ctx, C9t *t) __attribute__((nonnull(1, 2)));
-
-	/* Callback for error messages. */
-	void (*error)(const char *fmt, ...) __attribute__((nonnull(1), format(printf, 1, 2)));
-
-	/* Auxiliary data, can be used by any of above callbacks. */
-	struct C9aux *aux;
-
-	/* private stuff */
-	uint32_t msize;
-#ifndef C9_NO_CLIENT
-	uint32_t flush[C9maxflush];
-	uint32_t tags[C9maxtags/C9tagsbits];
-#endif
-	union
-	{
-		C9tag lowfreetag;
-		uint16_t svflags;
-	};
-};
-
-/* Parse one directory entry. */
-extern C9error c9parsedir(C9ctx *c, C9stat *stat, uint8_t **data, uint32_t *size) __attribute__((nonnull(1, 2, 3)));
-
-#ifndef C9_NO_CLIENT
-
-extern C9error c9version(C9ctx *c, C9tag *tag, uint32_t msize) __attribute__((nonnull(1, 2)));
-extern C9error c9auth(C9ctx *c, C9tag *tag, C9fid afid, const char *uname, const char *aname) __attribute__((nonnull(1, 2)));
-extern C9error c9flush(C9ctx *c, C9tag *tag, C9tag oldtag) __attribute__((nonnull(1, 2)));
-extern C9error c9attach(C9ctx *c, C9tag *tag, C9fid fid, C9fid afid, const char *uname, const char *aname) __attribute__((nonnull(1, 2)));
-extern C9error c9walk(C9ctx *c, C9tag *tag, C9fid fid, C9fid newfid, const char *path[]) __attribute__((nonnull(1, 2, 5)));
-extern C9error c9open(C9ctx *c, C9tag *tag, C9fid fid, C9mode mode) __attribute__((nonnull(1, 2)));
-extern C9error c9create(C9ctx *c, C9tag *tag, C9fid fid, const char *name, uint32_t perm, C9mode mode) __attribute__((nonnull(1, 2, 4)));
-extern C9error c9read(C9ctx *c, C9tag *tag, C9fid fid, uint64_t offset, uint32_t count) __attribute__((nonnull(1, 2)));
-extern C9error c9write(C9ctx *c, C9tag *tag, C9fid fid, uint64_t offset, const void *in, uint32_t count) __attribute__((nonnull(1, 2, 5)));
-extern C9error c9wrstr(C9ctx *c, C9tag *tag, C9fid fid, const char *s) __attribute__((nonnull(1, 2, 4)));
-extern C9error c9clunk(C9ctx *c, C9tag *tag, C9fid fid) __attribute__((nonnull(1, 2)));
-extern C9error c9remove(C9ctx *c, C9tag *tag, C9fid fid) __attribute__((nonnull(1, 2)));
-extern C9error c9stat(C9ctx *c, C9tag *tag, C9fid fid) __attribute__((nonnull(1, 2)));
-extern C9error c9wstat(C9ctx *c, C9tag *tag, C9fid fid, const C9stat *s) __attribute__((nonnull(1, 2, 4)));
-
-/*
- * Wait until a response comes and process it. If the function returns
- * any error, context must be treated as 'broken' and no subsequent calls
- * should be made without reinitialization (c9version).
- */
-extern C9error c9proc(C9ctx *c) __attribute__((nonnull(1)));
-
-#endif /* C9_NO_CLIENT */
-
-#ifndef C9_NO_SERVER
-
-extern C9error s9version(C9ctx *c) __attribute__((nonnull(1)));
-extern C9error s9auth(C9ctx *c, C9tag tag, const C9qid *aqid) __attribute__((nonnull(1, 3)));
-extern C9error s9error(C9ctx *c, C9tag tag, const char *err) __attribute__((nonnull(1)));
-extern C9error s9attach(C9ctx *c, C9tag tag, const C9qid *qid) __attribute__((nonnull(1, 3)));
-extern C9error s9flush(C9ctx *c, C9tag tag) __attribute__((nonnull(1)));
-extern C9error s9walk(C9ctx *c, C9tag tag, C9qid *qids[]) __attribute__((nonnull(1, 3)));
-extern C9error s9open(C9ctx *c, C9tag tag, const C9qid *qid, uint32_t iounit) __attribute__((nonnull(1, 3)));
-extern C9error s9create(C9ctx *c, C9tag tag, const C9qid *qid, uint32_t iounit) __attribute__((nonnull(1, 3)));
-extern C9error s9read(C9ctx *c, C9tag tag, const void *data, uint32_t size) __attribute__((nonnull(1, 3)));
-extern C9error s9readdir(C9ctx *c, C9tag tag, C9stat *st[], int *num, uint64_t *offset, uint32_t size) __attribute__((nonnull(1, 3, 4)));
-extern C9error s9write(C9ctx *c, C9tag tag, uint32_t size) __attribute__((nonnull(1)));
-extern C9error s9clunk(C9ctx *c, C9tag tag) __attribute__((nonnull(1)));
-extern C9error s9remove(C9ctx *c, C9tag tag) __attribute__((nonnull(1)));
-extern C9error s9stat(C9ctx *c, C9tag tag, const C9stat *s) __attribute__((nonnull(1, 3)));
-extern C9error s9wstat(C9ctx *c, C9tag tag) __attribute__((nonnull(1)));
-
-extern C9error s9proc(C9ctx *c) __attribute__((nonnull(1)));
-
-#endif /* C9_NO_SERVER */
--- a/libc9/meson.build
+++ /dev/null
@@ -1,4 +1,0 @@
-libc9 = static_library(
-    'libc9',
-    'c9.c',    
-)
--- a/libdraw/alloc.c
+++ /dev/null
@@ -1,224 +1,0 @@
-
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include "draw.h"
-
-Image*
-allocimage(Display *d, Rectangle r, ulong chan, int repl, ulong col)
-{
-	Image *i;
-
-	i = _allocimage(nil, d, r, chan, repl, col, 0, 0);
-	return i;
-}
-
-Image*
-_allocimage(Image *ai, Display *d, Rectangle r, ulong chan, int repl, ulong col, int screenid, int refresh)
-{
-	uchar *a;
-	char *err;
-	Image *i;
-	Rectangle clipr;
-	int id;
-	int depth;
-
-	err = nil;
-	i = nil;
-
-	if(badrect(r)){
-		return nil;
-	}
-	if(chan == 0){
-		return nil;
-	}
-
-	depth = chantodepth(chan);
-	if(depth == 0){
-    Error:
-		free(i);
-		return nil;
-	}
-
-	a = bufimage(d, 1+4+4+1+4+1+4*4+4*4+4);
-	if(a == nil)
-		goto Error;
-	d->imageid++;
-	id = d->imageid;
-	a[0] = 'b';
-	BPLONG(a+1, id);
-	BPLONG(a+5, screenid);
-	a[9] = refresh;
-	BPLONG(a+10, chan);
-	a[14] = repl;
-	BPLONG(a+15, r.min.x);
-	BPLONG(a+19, r.min.y);
-	BPLONG(a+23, r.max.x);
-	BPLONG(a+27, r.max.y);
-	if(repl)
-		/* huge but not infinite, so various offsets will leave it huge, not overflow */
-		clipr = Rect(-0x3FFFFFFF, -0x3FFFFFFF, 0x3FFFFFFF, 0x3FFFFFFF);
-	else
-		clipr = r;
-	BPLONG(a+31, clipr.min.x);
-	BPLONG(a+35, clipr.min.y);
-	BPLONG(a+39, clipr.max.x);
-	BPLONG(a+43, clipr.max.y);
-	BPLONG(a+47, col);
-
-	if(ai != nil)
-		i = ai;
-	else{
-		i = malloc(sizeof(Image));
-		if(i == nil){
-			a = bufimage(d, 1+4);
-			if(a != nil){
-				a[0] = 'f';
-				BPLONG(a+1, id);
-				flushimage(d, 0);
-			}
-			goto Error;
-		}
-	}
-	i->display = d;
-	i->id = id;
-	i->depth = depth;
-	i->chan = chan;
-	i->r = r;
-	i->clipr = clipr;
-	i->repl = repl;
-	i->screen = nil;
-	i->next = nil;
-	return i;
-}
-
-Image*
-namedimage(Display *d, char *name)
-{
-	uchar *a;
-	char *err, buf[12*12+1];
-	Image *i;
-	int id, n;
-	ulong chan;
-
-	err = nil;
-	i = nil;
-
-	n = strlen(name);
-	if(n >= 256){
-    Error:
-		free(i);
-		return nil;
-	}
-	/* flush pending data so we don't get error allocating the image */
-	flushimage(d, 0);
-	a = bufimage(d, 1+4+1+n);
-	if(a == nil)
-		goto Error;
-	d->imageid++;
-	id = d->imageid;
-	a[0] = 'n';
-	BPLONG(a+1, id);
-	a[5] = n;
-	memmove(a+6, name, n);
-	if(flushimage(d, 0) < 0)
-		goto Error;
-
-	lseek(d->ctlfd, 0, SEEK_SET);
-	if(read(d->ctlfd, buf, sizeof buf) < 12*12)
-		goto Error;
-	buf[12*12] = '\0';
-
-	i = malloc(sizeof(Image));
-	if(i == nil){
-	Error1:
-		a = bufimage(d, 1+4);
-		if(a != nil){
-			a[0] = 'f';
-			BPLONG(a+1, id);
-			flushimage(d, 0);
-		}
-		goto Error;
-	}
-	i->display = d;
-	i->id = id;
-	if((chan=strtochan(buf+2*12))==0){
-		goto Error1;
-	}
-	i->chan = chan;
-	i->depth = chantodepth(chan);
-	i->repl = atoi(buf+3*12);
-	i->r.min.x = atoi(buf+4*12);
-	i->r.min.y = atoi(buf+5*12);
-	i->r.max.x = atoi(buf+6*12);
-	i->r.max.y = atoi(buf+7*12);
-	i->clipr.min.x = atoi(buf+8*12);
-	i->clipr.min.y = atoi(buf+9*12);
-	i->clipr.max.x = atoi(buf+10*12);
-	i->clipr.max.y = atoi(buf+11*12);
-	i->screen = nil;
-	i->next = nil;
-	return i;
-}
-
-int
-nameimage(Image *i, char *name, int in)
-{
-	uchar *a;
-	int n;
-
-	n = strlen(name);
-	a = bufimage(i->display, 1+4+1+1+n);
-	if(a == nil)
-		return 0;
-	a[0] = 'N';
-	BPLONG(a+1, i->id);
-	a[5] = in;
-	a[6] = n;
-	memmove(a+7, name, n);
-	if(flushimage(i->display, 0) < 0)
-		return 0;
-	return 1;
-}
-
-int
-_freeimage1(Image *i)
-{
-	uchar *a;
-	Display *d;
-	Image *w;
-
-	if(i == nil || i->display == nil)
-		return 0;
-	d = i->display;
-	if(i->screen != nil){
-		w = d->windows;
-		if(w == i)
-			d->windows = i->next;
-		else
-			while(w != nil){
-				if(w->next == i){
-					w->next = i->next;
-					break;
-				}
-				w = w->next;
-			}
-	}
-	a = bufimage(d, 1+4);
-	if(a == nil)
-		return -1;
-	a[0] = 'f';
-	BPLONG(a+1, i->id);
-	return 0;
-}
-
-int
-freeimage(Image *i)
-{
-	int ret;
-
-	ret = _freeimage1(i);
-	free(i);
-	return ret;
-}
--- a/libdraw/arith.c
+++ /dev/null
@@ -1,183 +1,0 @@
-#include "draw.h"
-
-Point
-Pt(int x, int y)
-{
-	Point p;
-
-	p.x = x;
-	p.y = y;
-	return p;
-}
-
-Rectangle
-Rect(int x, int y, int bx, int by)
-{
-	Rectangle r;
-
-	r.min.x = x;
-	r.min.y = y;
-	r.max.x = bx;
-	r.max.y = by;
-	return r;
-}
-
-Rectangle
-Rpt(Point min, Point max)
-{
-	Rectangle r;
-
-	r.min = min;
-	r.max = max;
-	return r;
-}
-
-Point
-addpt(Point a, Point b)
-{
-	a.x += b.x;
-	a.y += b.y;
-	return a;
-}
-
-Point
-subpt(Point a, Point b)
-{
-	a.x -= b.x;
-	a.y -= b.y;
-	return a;
-}
-
-Rectangle
-insetrect(Rectangle r, int n)
-{
-	r.min.x += n;
-	r.min.y += n;
-	r.max.x -= n;
-	r.max.y -= n;
-	return r;
-}
-
-Point
-divpt(Point a, int b)
-{
-	a.x /= b;
-	a.y /= b;
-	return a;
-}
-
-Point
-mulpt(Point a, int b)
-{
-	a.x *= b;
-	a.y *= b;
-	return a;
-}
-
-Rectangle
-rectsubpt(Rectangle r, Point p)
-{
-	r.min.x -= p.x;
-	r.min.y -= p.y;
-	r.max.x -= p.x;
-	r.max.y -= p.y;
-	return r;
-}
-
-Rectangle
-rectaddpt(Rectangle r, Point p)
-{
-	r.min.x += p.x;
-	r.min.y += p.y;
-	r.max.x += p.x;
-	r.max.y += p.y;
-	return r;
-}
-
-int
-eqpt(Point p, Point q)
-{
-	return p.x==q.x && p.y==q.y;
-}
-
-int
-eqrect(Rectangle r, Rectangle s)
-{
-	return r.min.x==s.min.x && r.max.x==s.max.x &&
-	       r.min.y==s.min.y && r.max.y==s.max.y;
-}
-
-int
-rectXrect(Rectangle r, Rectangle s)
-{
-	return r.min.x<s.max.x && s.min.x<r.max.x &&
-	       r.min.y<s.max.y && s.min.y<r.max.y;
-}
-
-int
-rectinrect(Rectangle r, Rectangle s)
-{
-	return s.min.x<=r.min.x && r.max.x<=s.max.x && s.min.y<=r.min.y && r.max.y<=s.max.y;
-}
-
-int
-ptinrect(Point p, Rectangle r)
-{
-	return p.x>=r.min.x && p.x<r.max.x &&
-	       p.y>=r.min.y && p.y<r.max.y;
-}
-
-Rectangle
-canonrect(Rectangle r)
-{
-	int t;
-	if (r.max.x < r.min.x) {
-		t = r.min.x;
-		r.min.x = r.max.x;
-		r.max.x = t;
-	}
-	if (r.max.y < r.min.y) {
-		t = r.min.y;
-		r.min.y = r.max.y;
-		r.max.y = t;
-	}
-	return r;
-}
-
-void
-combinerect(Rectangle *r1, Rectangle r2)
-{
-	if(r1->min.x > r2.min.x)
-		r1->min.x = r2.min.x;
-	if(r1->min.y > r2.min.y)
-		r1->min.y = r2.min.y;
-	if(r1->max.x < r2.max.x)
-		r1->max.x = r2.max.x;
-	if(r1->max.y < r2.max.y)
-		r1->max.y = r2.max.y;
-}
-
-ulong drawld2chan[] = {
-	GREY1,
-	GREY2,
-	GREY4,
-	CMAP8,
-};
-
-ulong
-setalpha(ulong color, uchar alpha)
-{
-	int red, green, blue;
-
-	red = (color >> 3*8) & 0xFF;
-	green = (color >> 2*8) & 0xFF;
-	blue = (color >> 1*8) & 0xFF;
-	/* ignore incoming alpha */
-	red = (red * alpha)/255;
-	green = (green * alpha)/255;
-	blue = (blue * alpha)/255;
-	return (red<<3*8) | (green<<2*8) | (blue<<1*8) | (alpha<<0*8);
-}
-
-Point	ZP;
-Rectangle ZR;
--- a/libdraw/badrect.c
+++ /dev/null
@@ -1,20 +1,0 @@
-#include "draw.h"
-
-/*
- * check for zero, negative size or insanely huge rectangle.
- */
-int
-badrect(Rectangle r)
-{
-	int x, y;
-	unsigned int z;
-
-	x = Dx(r);
-	y = Dy(r);
-	if(x > 0 && y > 0){
-		z = x*y;
-		if(z/x == y && z < 0x10000000)
-			return 0;
-	}
-	return 1;
-}
--- a/libdraw/buildfont.c
+++ /dev/null
@@ -1,136 +1,0 @@
-#include <stdlib.h>
-#include <string.h>
-#include "draw.h"
-
-static char*
-skip(char *s)
-{
-	while(*s==' ' || *s=='\n' || *s=='\t')
-		s++;
-	return s;
-}
-
-_Font*
-buildfont(Display *d, char *buf, char *name)
-{
-	_Font *fnt;
-	Cachefont *c, **sub;
-	char *s, *t;
-	ulong min, max;
-	int offset;
-	char badform[] = "bad font format: number expected (char position %d)";
-
-	s = buf;
-	fnt = malloc(sizeof(_Font));
-	if(fnt == nil)
-		return nil;
-	memset(fnt, 0, sizeof(_Font));
-	fnt->display = d;
-	fnt->name = strdup(name);
-	fnt->ncache = NFCACHE+NFLOOK;
-	fnt->nsubf = NFSUBF;
-	fnt->cache = malloc(fnt->ncache * sizeof(fnt->cache[0]));
-	fnt->subf = malloc(fnt->nsubf * sizeof(fnt->subf[0]));
-	if(fnt->name==nil || fnt->cache==nil || fnt->subf==nil){
-    Err2:
-		free(fnt->name);
-		free(fnt->cache);
-		free(fnt->subf);
-		free(fnt->sub);
-		free(fnt);
-		return nil;
-	}
-	fnt->height = strtol(s, &s, 0);
-	s = skip(s);
-	fnt->ascent = strtol(s, &s, 0);
-	s = skip(s);
-	if(fnt->height<=0 || fnt->ascent<=0){
-		goto Err2;
-	}
-	fnt->width = 0;
-	fnt->nsub = 0;
-	fnt->sub = nil;
-
-	memset(fnt->subf, 0, fnt->nsubf * sizeof(fnt->subf[0]));
-	memset(fnt->cache, 0, fnt->ncache*sizeof(fnt->cache[0]));
-	fnt->age = 1;
-	do{
-		/* must be looking at a number now */
-		if(*s<'0' || '9'<*s){
-			goto Err3;
-		}
-		min = strtol(s, &s, 0);
-		s = skip(s);
-		/* must be looking at a number now */
-		if(*s<'0' || '9'<*s){
-			goto Err3;
-		}
-		max = strtol(s, &s, 0);
-		s = skip(s);
-		if(*s==0 || min>Runemax || max>Runemax || min>max){
-    Err3:
-			freefont(fnt);
-			return 0;
-		}
-		t = s;
-		offset = strtol(s, &t, 0);
-		if(t>s && (*t==' ' || *t=='\t' || *t=='\n'))
-			s = skip(t);
-		else
-			offset = 0;
-		sub = realloc(fnt->sub, (fnt->nsub+1)*sizeof(Cachefont*));
-		if(sub == nil)
-			goto Err3;
-		fnt->sub = sub;
-		c = malloc(sizeof(Cachefont));
-		if(c == nil)
-			goto Err3;
-		c->min = min;
-		c->max = max;
-		c->offset = offset;
-		t = s;
-		while(*s && *s!=' ' && *s!='\n' && *s!='\t')
-			s++;
-		*s++ = 0;
-		c->subfontname = nil;
-		c->name = strdup(t);
-		if(c->name == nil){
-			free(c);
-			goto Err3;
-		}
-		sub[fnt->nsub++] = c;
-		s = skip(s);
-	}while(*s);
-	return fnt;
-}
-
-void
-freefont(_Font *f)
-{
-	int i;
-	Cachefont *c;
-	Subfont *s;
-
-	if(f == nil)
-		return;
-
-	for(i=0; i<f->nsub; i++){
-		c = f->sub[i];
-		free(c->subfontname);
-		free(c->name);
-		free(c);
-	}
-	for(i=0; i<f->nsubf; i++){
-		s = f->subf[i].f;
-		if(s != nil){
-			if(f->display == nil || s != f->display->defaultsubfont)
-				freesubfont(s);
-		}
-	}
-	freeimage(f->cacheimage);
-	free(f->name);
-	free(f->cache);
-	free(f->subf);
-	free(f->sub);
-	free(f);
-}
--- a/libdraw/bytesperline.c
+++ /dev/null
@@ -1,33 +1,0 @@
-/* From 9front */
-#include <stdlib.h>
-#include "draw.h"
-
-static int
-unitsperline(Rectangle r, int d, int bitsperunit)
-{
-	ulong l, t;
-
-	if(d <= 0 || d > 32)	/* being called wrong.  d is image depth. */
-		abort();
-
-	if(r.min.x >= 0){
-		l = (r.max.x*d+bitsperunit-1)/bitsperunit;
-		l -= (r.min.x*d)/bitsperunit;
-	}else{			/* make positive before divide */
-		t = (-r.min.x*d+bitsperunit-1)/bitsperunit;
-		l = t+(r.max.x*d+bitsperunit-1)/bitsperunit;
-	}
-	return l;
-}
-
-int
-wordsperline(Rectangle r, int d)
-{
-	return unitsperline(r, d, 8*sizeof(ulong));
-}
-
-int
-bytesperline(Rectangle r, int d)
-{
-	return unitsperline(r, d, 8);
-}
\ No newline at end of file
--- a/libdraw/chan.c
+++ /dev/null
@@ -1,80 +1,0 @@
-#include <string.h>
-#include "draw.h"
-
-static char channames[] = "rgbkamx";
-char*
-chantostr(char *buf, ulong cc)
-{
-	ulong c, rc;
-	char *p;
-
-	if(chantodepth(cc) == 0)
-		return nil;
-
-	/* reverse the channel descriptor so we can easily generate the string in the right order */
-	rc = 0;
-	for(c=cc; c; c>>=8){
-		rc <<= 8;
-		rc |= c&0xFF;
-	}
-
-	p = buf;
-	for(c=rc; c; c>>=8) {
-		*p++ = channames[TYPE(c)];
-		*p++ = '0'+NBITS(c);
-	}
-	*p = 0;
-
-	return buf;
-}
-
-/* avoid pulling in ctype when using with drawterm etc. */
-static int
-isspace(char c)
-{
-	return c==' ' || c== '\t' || c=='\r' || c=='\n';
-}
-
-ulong
-strtochan(char *s)
-{
-	char *p, *q;
-	ulong c;
-	int t, n, d;
-
-	c = 0;
-	d = 0;
-	p=s;
-	while(*p && isspace(*p))
-		p++;
-
-	while(*p && !isspace(*p)){
-		if((q = strchr(channames, p[0])) == nil) 
-			return 0;
-		t = q-channames;
-		if(p[1] < '0' || p[1] > '9')
-			return 0;
-		n = p[1]-'0';
-		d += n;
-		c = (c<<8) | __DC(t, n);
-		p += 2;
-	}
-	if(d==0 || (d>8 && d%8) || (d<8 && 8%d))
-		return 0;
-	return c;
-}
-
-int
-chantodepth(ulong c)
-{
-	int n;
-
-	for(n=0; c; c>>=8){
-		if(TYPE(c) >= NChan || NBITS(c) > 8 || NBITS(c) <= 0)
-			return 0;
-		n += NBITS(c);
-	}
-	if(n==0 || (n>8 && n%8) || (n<8 && 8%n))
-		return 0;
-	return n;
-}
--- a/libdraw/defont.c
+++ /dev/null
@@ -1,386 +1,0 @@
-#include "draw.h"
-
-/*
- * vga/vga00, in uncompressed form
- */
-uchar
-defontdata[] =
-{
-0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x30,0x20,0x20,0x20,0x20,0x20,
-0x20,0x20,0x20,0x20,0x20,0x20,0x30,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
-0x20,0x20,0x30,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x32,0x30,0x34,0x38,0x20,
-0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x31,0x36,0x20,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x30,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x0c,0x10,0x76,
-0x6c,0x38,0x00,0x00,0x30,0x0c,0x10,0x6c,0x30,0x0c,0x18,0x66,0x00,0x76,0x60,0x0c,
-0x10,0x76,0x6c,0x00,0x00,0x60,0x0c,0x10,0x6c,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0xe0,
-0xe0,0xe0,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xe0,0xe0,0xe0,
-0xe0,0x90,0x70,0xe0,0x70,0x00,0x70,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x66,0x00,
-0x18,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x30,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x38,
-0x00,0x00,0x00,0x7c,0x00,0x00,0x3c,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x70,0x70,
-0x00,0x00,0x00,0x00,0x00,0x30,0x38,0x00,0xc0,0xc0,0xe0,0x00,0x30,0x18,0x38,0xdc,
-0x6c,0x6c,0x00,0x00,0x18,0x18,0x38,0x6c,0x18,0x18,0x3c,0x66,0x00,0xdc,0x30,0x18,
-0x38,0xdc,0x6c,0x00,0x00,0x30,0x18,0x38,0x6c,0x18,0x00,0x00,0x00,0x00,0x10,0x00,
-0x00,0x38,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,
-0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0xda,0x00,0x80,0x80,
-0x80,0x80,0x90,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x90,0x90,0x90,0x90,
-0x90,0xd0,0x80,0x80,0x90,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x18,0x66,0x00,
-0x7c,0x00,0x38,0x30,0x0c,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x18,0x7c,0x7c,
-0x0c,0xfe,0x38,0xfe,0x7c,0x7c,0x00,0x00,0x00,0x00,0x00,0x7c,0x00,0x10,0xfc,0x3c,
-0xf8,0xfe,0xfe,0x3c,0xc6,0x3c,0x1e,0xe6,0xf0,0xc6,0xc6,0x7c,0xfc,0x7c,0xfc,0x7c,
-0x7e,0xc6,0xc6,0xc6,0xc6,0x66,0xfe,0x3c,0x00,0x3c,0x6c,0x00,0x18,0x00,0xe0,0x00,
-0x1c,0x00,0x38,0x00,0xe0,0x18,0x06,0xe0,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x0e,0x18,0x70,0x76,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x6c,
-0x00,0x66,0x18,0xc6,0x6c,0x3c,0x6c,0x00,0x00,0x00,0x38,0x00,0x6c,0x00,0xd8,0xd8,
-0x0c,0x00,0x7f,0x00,0x00,0x70,0x6c,0x00,0xc0,0xc0,0x30,0x30,0x00,0x00,0x6c,0x00,
-0x00,0x38,0x3e,0x3c,0x00,0x00,0x44,0x00,0x00,0x00,0x42,0x00,0xf8,0x00,0x00,0x00,
-0x44,0x00,0x00,0x00,0x7a,0x00,0x00,0x44,0x00,0x00,0xf0,0x3c,0x60,0x18,0x38,0x76,
-0x6c,0x6c,0x00,0x00,0x60,0x0c,0x38,0x6c,0x30,0x0c,0x38,0x66,0x76,0x76,0x60,0x0c,
-0x38,0x76,0x6c,0x00,0x00,0x60,0x18,0x38,0xcc,0x0c,0xe0,0x6c,0x02,0x00,0xe0,0xe0,
-0xe0,0xe0,0xf0,0x18,0x70,0x48,0x20,0x48,0x70,0x38,0x38,0x38,0x90,0x90,0x90,0x90,
-0x90,0xb0,0x60,0xe0,0x80,0xe0,0x60,0xe0,0x70,0x38,0x70,0x48,0x00,0x3c,0x66,0x6c,
-0xc6,0x00,0x6c,0x30,0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x6c,0x38,0xc6,0xc6,
-0x1c,0xc0,0x60,0xc6,0xc6,0xc6,0x00,0x00,0x06,0x00,0x60,0xc6,0x7c,0x38,0x66,0x66,
-0x6c,0x66,0x66,0x66,0xc6,0x18,0x0c,0x66,0x60,0xee,0xe6,0xc6,0x66,0xc6,0x66,0xc6,
-0x7e,0xc6,0xc6,0xc6,0xc6,0x66,0xc6,0x30,0x80,0x0c,0xc6,0x00,0x00,0x00,0x60,0x00,
-0x0c,0x00,0x6c,0x00,0x60,0x18,0x06,0x60,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x18,0xdc,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x3c,0x64,
-0x00,0x66,0x18,0x60,0x6c,0x42,0x6c,0x00,0x00,0x00,0x44,0x7c,0x6c,0x00,0x30,0x30,
-0x18,0x00,0xdb,0x00,0x00,0x30,0x6c,0x00,0xc2,0xc2,0x62,0x30,0x10,0x10,0x10,0x10,
-0x10,0x10,0x6c,0x66,0xfe,0xfe,0xfe,0xfe,0x3c,0x3c,0x3c,0x3c,0x6c,0xc6,0x7c,0x7c,
-0x7c,0x7c,0x7c,0x00,0xc4,0xc6,0xc6,0xc6,0xc6,0x66,0x60,0x66,0x30,0x30,0x6c,0xdc,
-0x6c,0x38,0x00,0x00,0x30,0x18,0x6c,0x6c,0x18,0x18,0x6c,0x66,0x1c,0xdc,0x30,0x18,
-0x6c,0xdc,0x6c,0x00,0x00,0x30,0x30,0x6c,0xcc,0x18,0x60,0x6c,0x80,0x00,0x10,0x80,
-0x80,0x80,0x90,0x3c,0x48,0x48,0x20,0x48,0x40,0x48,0x40,0x40,0x90,0x90,0x90,0x90,
-0x90,0x90,0x10,0x80,0x80,0x80,0x10,0x80,0x40,0x40,0x48,0x48,0x00,0x3c,0x24,0x6c,
-0xc2,0xc2,0x6c,0x20,0x30,0x0c,0x00,0x00,0x00,0x00,0x00,0x02,0xc6,0x78,0x06,0x06,
-0x3c,0xc0,0xc0,0x06,0xc6,0xc6,0x18,0x18,0x0c,0x00,0x30,0xc6,0xc6,0x6c,0x66,0xc2,
-0x66,0x62,0x62,0xc2,0xc6,0x18,0x0c,0x66,0x60,0xfe,0xf6,0xc6,0x66,0xc6,0x66,0xc6,
-0x5a,0xc6,0xc6,0xc6,0x6c,0x66,0x86,0x30,0xc0,0x0c,0x00,0x00,0x00,0x00,0x60,0x00,
-0x0c,0x00,0x64,0x00,0x60,0x00,0x00,0x60,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x18,0x00,0x10,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x66,0x60,
-0x66,0x3c,0x18,0x38,0x00,0x99,0x3e,0x00,0x00,0x00,0xba,0x00,0x38,0x18,0x60,0x18,
-0x00,0x00,0xdb,0x00,0x00,0x30,0x38,0x00,0xc6,0xc6,0x36,0x00,0x38,0x38,0x38,0x38,
-0x38,0x38,0xcc,0xc2,0x66,0x66,0x66,0x66,0x18,0x18,0x18,0x18,0x66,0xe6,0xc6,0xc6,
-0xc6,0xc6,0xc6,0x00,0xce,0xc6,0xc6,0xc6,0xc6,0x66,0x7c,0x66,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3c,0x00,0x00,0x00,
-0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x82,0x00,0xe0,0xe0,
-0xe0,0xe0,0x90,0x3c,0x70,0x78,0x20,0x48,0x70,0x40,0x30,0x30,0xe0,0xe0,0xe0,0xe0,
-0xe0,0x90,0xe0,0xe0,0x70,0xe0,0xe0,0xe0,0x70,0x58,0x70,0x48,0x00,0x3c,0x00,0xfe,
-0xc0,0xc6,0x38,0x00,0x30,0x0c,0x66,0x18,0x00,0x00,0x00,0x06,0xc6,0x18,0x0c,0x06,
-0x6c,0xc0,0xc0,0x06,0xc6,0xc6,0x18,0x18,0x18,0x7e,0x18,0x0c,0xc6,0xc6,0x66,0xc0,
-0x66,0x68,0x68,0xc0,0xc6,0x18,0x0c,0x6c,0x60,0xfe,0xfe,0xc6,0x66,0xc6,0x66,0x60,
-0x18,0xc6,0xc6,0xc6,0x7c,0x66,0x0c,0x30,0xe0,0x0c,0x00,0x00,0x00,0x78,0x78,0x7c,
-0x3c,0x7c,0x60,0x76,0x6c,0x38,0x0e,0x66,0x18,0xec,0xdc,0x7c,0xdc,0x76,0xdc,0x7c,
-0xfc,0xcc,0x66,0xc6,0xc6,0xc6,0xfe,0x18,0x18,0x18,0x00,0x38,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x60,0xf0,
-0x3c,0x18,0x18,0x6c,0x00,0xa5,0x00,0x36,0x00,0x00,0xb2,0x00,0x00,0x18,0xc8,0xd8,
-0x00,0xcc,0xdb,0x00,0x00,0x30,0x00,0xd8,0xcc,0xcc,0xec,0x30,0x6c,0x6c,0x6c,0x6c,
-0x6c,0x6c,0xcc,0xc0,0x62,0x62,0x62,0x62,0x18,0x18,0x18,0x18,0x66,0xf6,0xc6,0xc6,
-0xc6,0xc6,0xc6,0x66,0xce,0xc6,0xc6,0xc6,0xc6,0x66,0x66,0x66,0x78,0x78,0x78,0x78,
-0x78,0x78,0xcc,0x7c,0x7c,0x7c,0x7c,0x7c,0x38,0x38,0x38,0x38,0x06,0xdc,0x7c,0x7c,
-0x7c,0x7c,0x7c,0x18,0x7a,0xcc,0xcc,0xcc,0xcc,0xc6,0x7c,0xc6,0x02,0x00,0x1c,0x1c,
-0x18,0x24,0x1c,0x3c,0x48,0x48,0x20,0x30,0x40,0x40,0x08,0x08,0x10,0x1c,0x1c,0x1c,
-0x1c,0x0c,0x44,0x1c,0x0c,0x80,0x24,0x1c,0x40,0x48,0x50,0x48,0x00,0x18,0x00,0x6c,
-0x7c,0x0c,0x76,0x00,0x30,0x0c,0x3c,0x18,0x00,0x00,0x00,0x0c,0xd6,0x18,0x18,0x3c,
-0xcc,0xfc,0xfc,0x0c,0x7c,0x7e,0x00,0x00,0x30,0x00,0x0c,0x18,0xde,0xc6,0x7c,0xc0,
-0x66,0x78,0x78,0xc0,0xfe,0x18,0x0c,0x78,0x60,0xd6,0xde,0xc6,0x7c,0xc6,0x7c,0x38,
-0x18,0xc6,0xc6,0xd6,0x38,0x3c,0x18,0x30,0x70,0x0c,0x00,0x00,0x00,0x0c,0x6c,0xc6,
-0x6c,0xc6,0xf0,0xcc,0x76,0x18,0x06,0x6c,0x18,0xfe,0x66,0xc6,0x66,0xcc,0x76,0xc6,
-0x30,0xcc,0x66,0xc6,0x6c,0xc6,0xcc,0x70,0x00,0x0e,0x00,0x6c,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x60,0x60,
-0x66,0x7e,0x00,0xc6,0x00,0xa1,0x7e,0x6c,0xfe,0x00,0xaa,0x00,0x00,0x7e,0xf8,0x70,
-0x00,0xcc,0x7b,0x00,0x00,0x78,0x7c,0x6c,0x18,0x18,0x18,0x30,0xc6,0xc6,0xc6,0xc6,
-0xc6,0xc6,0xfe,0xc0,0x68,0x68,0x68,0x68,0x18,0x18,0x18,0x18,0xf6,0xfe,0xc6,0xc6,
-0xc6,0xc6,0xc6,0x3c,0xd6,0xc6,0xc6,0xc6,0xc6,0x3c,0x66,0x6c,0x0c,0x0c,0x0c,0x0c,
-0x0c,0x0c,0x76,0xc6,0xc6,0xc6,0xc6,0xc6,0x18,0x18,0x18,0x18,0x7e,0x66,0xc6,0xc6,
-0xc6,0xc6,0xc6,0x00,0xc4,0xcc,0xcc,0xcc,0xcc,0xc6,0x66,0xc6,0x80,0x00,0x08,0x08,
-0x24,0x34,0x24,0x3c,0x70,0x48,0x38,0x30,0x40,0x38,0x70,0x70,0x10,0x24,0x24,0x24,
-0x24,0x12,0x28,0x08,0x12,0xe0,0x24,0x20,0x40,0x38,0x48,0x30,0x00,0x18,0x00,0x6c,
-0x06,0x18,0xdc,0x00,0x30,0x0c,0xff,0x7e,0x00,0xfe,0x00,0x18,0xd6,0x18,0x30,0x06,
-0xfe,0x06,0xc6,0x18,0xc6,0x06,0x00,0x00,0x60,0x00,0x06,0x18,0xde,0xfe,0x66,0xc0,
-0x66,0x68,0x68,0xde,0xc6,0x18,0x0c,0x78,0x60,0xc6,0xce,0xc6,0x60,0xc6,0x6c,0x0c,
-0x18,0xc6,0xc6,0xd6,0x38,0x18,0x30,0x30,0x38,0x0c,0x00,0x00,0x00,0x7c,0x66,0xc0,
-0xcc,0xfe,0x60,0xcc,0x66,0x18,0x06,0x78,0x18,0xd6,0x66,0xc6,0x66,0xcc,0x66,0x60,
-0x30,0xcc,0x66,0xd6,0x38,0xc6,0x18,0x18,0x18,0x18,0x00,0xc6,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x60,0x60,
-0x66,0x18,0x18,0xc6,0x00,0xa1,0x00,0xd8,0x06,0x3c,0x44,0x00,0x00,0x18,0x00,0x00,
-0x00,0xcc,0x1b,0x00,0x00,0x00,0x00,0x36,0x30,0x30,0x30,0x60,0xc6,0xc6,0xc6,0xc6,
-0xc6,0xc6,0xcc,0xc0,0x78,0x78,0x78,0x78,0x18,0x18,0x18,0x18,0x66,0xde,0xc6,0xc6,
-0xc6,0xc6,0xc6,0x18,0xd6,0xc6,0xc6,0xc6,0xc6,0x18,0x66,0x66,0x7c,0x7c,0x7c,0x7c,
-0x7c,0x7c,0x36,0xc0,0xfe,0xfe,0xfe,0xfe,0x18,0x18,0x18,0x18,0xc6,0x66,0xc6,0xc6,
-0xc6,0xc6,0xc6,0x7e,0xce,0xcc,0xcc,0xcc,0xcc,0xc6,0x66,0xc6,0x82,0x00,0x08,0x08,
-0x24,0x2c,0x20,0x66,0x07,0x07,0x07,0x07,0x0e,0x00,0x06,0x07,0x10,0x20,0x20,0x20,
-0x20,0x1e,0x10,0x08,0x1e,0x11,0x24,0x18,0x0e,0x07,0x07,0x07,0x00,0x18,0x00,0x6c,
-0x06,0x30,0xcc,0x00,0x30,0x0c,0x3c,0x18,0x00,0x00,0x00,0x30,0xc6,0x18,0x60,0x06,
-0x0c,0x06,0xc6,0x30,0xc6,0x06,0x00,0x00,0x30,0x7e,0x0c,0x18,0xde,0xc6,0x66,0xc0,
-0x66,0x60,0x60,0xc6,0xc6,0x18,0xcc,0x6c,0x60,0xc6,0xc6,0xc6,0x60,0xc6,0x66,0x06,
-0x18,0xc6,0xc6,0xd6,0x7c,0x18,0x60,0x30,0x1c,0x0c,0x00,0x00,0x00,0xcc,0x66,0xc0,
-0xcc,0xc0,0x60,0xcc,0x66,0x18,0x06,0x78,0x18,0xd6,0x66,0xc6,0x66,0xcc,0x60,0x38,
-0x30,0xcc,0x66,0xd6,0x38,0xc6,0x30,0x18,0x18,0x18,0x00,0xc6,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3c,0x66,0x60,
-0x66,0x7e,0x18,0x6c,0x00,0xa5,0x00,0x6c,0x06,0x00,0x38,0x00,0x00,0x18,0x00,0x00,
-0x00,0xcc,0x1b,0x18,0x00,0x00,0x00,0x6c,0x66,0x60,0x66,0xc0,0xfe,0xfe,0xfe,0xfe,
-0xfe,0xfe,0xcc,0xc0,0x68,0x68,0x68,0x68,0x18,0x18,0x18,0x18,0x66,0xce,0xc6,0xc6,
-0xc6,0xc6,0xc6,0x3c,0xe6,0xc6,0xc6,0xc6,0xc6,0x18,0x66,0x66,0xcc,0xcc,0xcc,0xcc,
-0xcc,0xcc,0x7e,0xc0,0xc0,0xc0,0xc0,0xc0,0x18,0x18,0x18,0x18,0xc6,0x66,0xc6,0xc6,
-0xc6,0xc6,0xc6,0x00,0xd6,0xcc,0xcc,0xcc,0xcc,0xc6,0x66,0xc6,0x02,0x00,0x08,0x08,
-0x24,0x24,0x20,0xc3,0x08,0x02,0x04,0x02,0x08,0x0e,0x09,0x02,0x10,0x20,0x20,0x20,
-0x20,0x12,0x10,0x08,0x12,0x1b,0x24,0x04,0x10,0x08,0x08,0x08,0x00,0x00,0x00,0xfe,
-0x86,0x60,0xcc,0x00,0x30,0x0c,0x66,0x18,0x18,0x00,0x00,0x60,0xc6,0x18,0xc0,0x06,
-0x0c,0x06,0xc6,0x30,0xc6,0x06,0x18,0x18,0x18,0x00,0x18,0x00,0xdc,0xc6,0x66,0xc2,
-0x66,0x62,0x60,0xc6,0xc6,0x18,0xcc,0x66,0x62,0xc6,0xc6,0xc6,0x60,0xd6,0x66,0xc6,
-0x18,0xc6,0x6c,0xfe,0x6c,0x18,0xc2,0x30,0x0e,0x0c,0x00,0x00,0x00,0xcc,0x66,0xc0,
-0xcc,0xc0,0x60,0xcc,0x66,0x18,0x06,0x6c,0x18,0xd6,0x66,0xc6,0x66,0xcc,0x60,0x0c,
-0x30,0xcc,0x66,0xd6,0x38,0xc6,0x60,0x18,0x18,0x18,0x00,0xc6,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3c,0x3c,0x60,
-0x3c,0x18,0x18,0x38,0x00,0x99,0x00,0x36,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0xcc,0x1b,0x00,0x00,0x00,0x00,0xd8,0xce,0xdc,0xce,0xc6,0xc6,0xc6,0xc6,0xc6,
-0xc6,0xc6,0xcc,0xc2,0x62,0x62,0x62,0x62,0x18,0x18,0x18,0x18,0x66,0xc6,0xc6,0xc6,
-0xc6,0xc6,0xc6,0x66,0xe6,0xc6,0xc6,0xc6,0xc6,0x18,0x7c,0x66,0xcc,0xcc,0xcc,0xcc,
-0xcc,0xcc,0xd8,0xc0,0xc0,0xc0,0xc0,0xc0,0x18,0x18,0x18,0x18,0xc6,0x66,0xc6,0xc6,
-0xc6,0xc6,0xc6,0x18,0xe6,0xcc,0xcc,0xcc,0xcc,0xc6,0x66,0xc6,0x80,0x00,0x08,0x08,
-0x18,0x24,0x1c,0xff,0x06,0x02,0x07,0x02,0x0e,0x09,0x09,0x02,0x1c,0x1c,0x1c,0x1c,
-0x1c,0x12,0x10,0x08,0x12,0x15,0x18,0x38,0x0c,0x06,0x06,0x06,0x00,0x18,0x00,0x6c,
-0xc6,0xc6,0xcc,0x00,0x18,0x18,0x00,0x00,0x18,0x00,0x18,0xc0,0x6c,0x18,0xc6,0xc6,
-0x0c,0xc6,0xc6,0x30,0xc6,0x0c,0x18,0x18,0x0c,0x00,0x30,0x18,0xc0,0xc6,0x66,0x66,
-0x6c,0x66,0x60,0x66,0xc6,0x18,0xcc,0x66,0x66,0xc6,0xc6,0xc6,0x60,0xde,0x66,0xc6,
-0x18,0xc6,0x38,0xee,0xc6,0x18,0xc6,0x30,0x06,0x0c,0x00,0x00,0x00,0xcc,0x66,0xc6,
-0xcc,0xc6,0x60,0xcc,0x66,0x18,0x06,0x66,0x18,0xd6,0x66,0xc6,0x66,0xcc,0x60,0xc6,
-0x36,0xcc,0x3c,0xfe,0x6c,0xc6,0xc6,0x18,0x18,0x18,0x00,0xfe,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3c,0x18,0xe6,
-0x66,0x18,0x18,0x0c,0x00,0x42,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x7e,0x00,0x00,
-0x00,0xcc,0x1b,0x00,0x00,0x00,0x00,0x00,0x9e,0x86,0x9e,0xc6,0xc6,0xc6,0xc6,0xc6,
-0xc6,0xc6,0xcc,0x66,0x66,0x66,0x66,0x66,0x18,0x18,0x18,0x18,0x6c,0xc6,0xc6,0xc6,
-0xc6,0xc6,0xc6,0x00,0x46,0xc6,0xc6,0xc6,0xc6,0x18,0x60,0x66,0xcc,0xcc,0xcc,0xcc,
-0xcc,0xcc,0xd8,0xc6,0xc6,0xc6,0xc6,0xc6,0x18,0x18,0x18,0x18,0xc6,0x66,0xc6,0xc6,
-0xc6,0xc6,0xc6,0x18,0x46,0xcc,0xcc,0xcc,0xcc,0xc6,0x66,0xc6,0xb6,0x00,0x05,0x05,
-0x07,0x0c,0x09,0x18,0x01,0x02,0x04,0x02,0x08,0x0e,0x09,0x02,0x07,0x02,0x06,0x06,
-0x02,0x09,0x09,0x0e,0x09,0x15,0x0e,0x07,0x02,0x01,0x01,0x01,0x00,0x18,0x00,0x6c,
-0x7c,0x86,0x76,0x00,0x0c,0x30,0x00,0x00,0x18,0x00,0x18,0x80,0x38,0x7e,0xfe,0x7c,
-0x1e,0x7c,0x7c,0x30,0x7c,0x78,0x00,0x30,0x06,0x00,0x60,0x18,0x7c,0xc6,0xfc,0x3c,
-0xf8,0xfe,0xf0,0x3a,0xc6,0x3c,0x78,0xe6,0xfe,0xc6,0xc6,0x7c,0xf0,0x7c,0xe6,0x7c,
-0x3c,0x7c,0x10,0x6c,0xc6,0x3c,0xfe,0x3c,0x02,0x3c,0x00,0x00,0x00,0x76,0x7c,0x7c,
-0x76,0x7c,0xf0,0x7c,0xe6,0x3c,0x06,0xe6,0x3c,0xc6,0x66,0x7c,0x7c,0x7c,0xf0,0x7c,
-0x1c,0x76,0x18,0x6c,0xc6,0x7e,0xfe,0x0e,0x18,0x70,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0xfc,
-0x00,0x18,0x18,0xc6,0x00,0x3c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0xf6,0x1b,0x00,0x00,0x00,0x00,0x00,0x3e,0x0c,0x3e,0x7c,0xc6,0xc6,0xc6,0xc6,
-0xc6,0xc6,0xce,0x3c,0xfe,0xfe,0xfe,0xfe,0x3c,0x3c,0x3c,0x3c,0xf8,0xc6,0x7c,0x7c,
-0x7c,0x7c,0x7c,0x00,0xbc,0x7c,0x7c,0x7c,0x7c,0x3c,0xf0,0xec,0x76,0x76,0x76,0x76,
-0x76,0x76,0x6e,0x7c,0x7c,0x7c,0x7c,0x7c,0x3c,0x3c,0x3c,0x3c,0x7c,0x66,0x7c,0x7c,
-0x7c,0x7c,0x7c,0x00,0xbc,0x76,0x76,0x76,0x76,0x7e,0x7c,0x7e,0x00,0x00,0x05,0x05,
-0x02,0x12,0x0a,0x00,0x0e,0x02,0x04,0x02,0x08,0x0a,0x06,0x07,0x04,0x06,0x09,0x01,
-0x06,0x0a,0x0d,0x09,0x0d,0x11,0x09,0x09,0x1c,0x0e,0x0e,0x0e,0x00,0x00,0x00,0x00,
-0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x0c,0x00,0x00,0x66,0x00,0x00,0x00,0x00,0x00,0x60,0x0c,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0xc0,0x00,0x00,0x18,0x00,0x00,0x00,0x06,0x18,0x06,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x60,0x06,0x00,0x00,0x02,0x02,
-0x02,0x12,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x09,0x00,0x00,0x07,0x02,0x02,0x06,
-0x0a,0x0c,0x0b,0x0e,0x0b,0x00,0x0e,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0e,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0xcc,0x00,0x00,0x66,0x00,0x00,0x00,0x00,0x00,0x60,0x0c,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0xc0,0x00,0x00,0x0c,0x00,0x00,0x00,0x06,0x3e,0x06,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x60,0x0c,0x00,0x00,0x05,0x05,
-0x02,0x16,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x02,0x04,0x01,
-0x1f,0x0a,0x09,0x09,0x09,0x00,0x09,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x78,0x00,0x00,0x3c,0x00,0x00,0x00,0x00,0x00,0xf0,0x1e,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0xc0,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xf0,0xf8,0x00,0x00,0x05,0x05,
-0x02,0x0d,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x07,0x0f,0x06,
-0x02,0x09,0x09,0x0e,0x09,0x00,0x0e,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x32,0x35,0x36,0x20,
-0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x31,0x36,0x20,0x20,0x20,0x20,0x20,0x20,
-0x20,0x20,0x20,0x20,0x38,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
-0x00,0x00,0x00,0x0f,0x00,0x08,0x08,0x00,0x00,0x0f,0x00,0x08,0x10,0x00,0x00,0x0f,
-0x00,0x08,0x18,0x00,0x00,0x0f,0x00,0x08,0x20,0x00,0x00,0x0f,0x00,0x08,0x28,0x00,
-0x00,0x0f,0x00,0x08,0x30,0x00,0x00,0x0f,0x00,0x08,0x38,0x00,0x00,0x0f,0x00,0x08,
-0x40,0x00,0x00,0x0f,0x00,0x08,0x48,0x00,0x00,0x0f,0x00,0x08,0x50,0x00,0x00,0x0f,
-0x00,0x08,0x58,0x00,0x00,0x0f,0x00,0x08,0x60,0x00,0x00,0x0f,0x00,0x08,0x68,0x00,
-0x00,0x0f,0x00,0x08,0x70,0x00,0x00,0x0f,0x00,0x08,0x78,0x00,0x00,0x0f,0x00,0x08,
-0x80,0x00,0x00,0x0f,0x00,0x08,0x88,0x00,0x00,0x0f,0x00,0x08,0x90,0x00,0x00,0x0f,
-0x00,0x08,0x98,0x00,0x00,0x0f,0x00,0x08,0xa0,0x00,0x00,0x0f,0x00,0x08,0xa8,0x00,
-0x00,0x0f,0x00,0x08,0xb0,0x00,0x00,0x0f,0x00,0x08,0xb8,0x00,0x00,0x0f,0x00,0x08,
-0xc0,0x00,0x00,0x0f,0x00,0x08,0xc8,0x00,0x00,0x0f,0x00,0x08,0xd0,0x00,0x00,0x0f,
-0x00,0x08,0xd8,0x00,0x00,0x0f,0x00,0x08,0xe0,0x00,0x00,0x0f,0x00,0x08,0xe8,0x00,
-0x00,0x0f,0x00,0x08,0xf0,0x00,0x00,0x0f,0x00,0x08,0xf8,0x00,0x00,0x0f,0x00,0x08,
-0x00,0x01,0x00,0x0f,0x00,0x08,0x08,0x01,0x00,0x0f,0x00,0x08,0x10,0x01,0x00,0x0f,
-0x00,0x08,0x18,0x01,0x00,0x0f,0x00,0x08,0x20,0x01,0x00,0x0f,0x00,0x08,0x28,0x01,
-0x00,0x0f,0x00,0x08,0x30,0x01,0x00,0x0f,0x00,0x08,0x38,0x01,0x00,0x0f,0x00,0x08,
-0x40,0x01,0x00,0x0f,0x00,0x08,0x48,0x01,0x00,0x0f,0x00,0x08,0x50,0x01,0x00,0x0f,
-0x00,0x08,0x58,0x01,0x00,0x0f,0x00,0x08,0x60,0x01,0x00,0x0f,0x00,0x08,0x68,0x01,
-0x00,0x0f,0x00,0x08,0x70,0x01,0x00,0x0f,0x00,0x08,0x78,0x01,0x00,0x0f,0x00,0x08,
-0x80,0x01,0x00,0x0f,0x00,0x08,0x88,0x01,0x00,0x0f,0x00,0x08,0x90,0x01,0x00,0x0f,
-0x00,0x08,0x98,0x01,0x00,0x0f,0x00,0x08,0xa0,0x01,0x00,0x0f,0x00,0x08,0xa8,0x01,
-0x00,0x0f,0x00,0x08,0xb0,0x01,0x00,0x0f,0x00,0x08,0xb8,0x01,0x00,0x0f,0x00,0x08,
-0xc0,0x01,0x00,0x0f,0x00,0x08,0xc8,0x01,0x00,0x0f,0x00,0x08,0xd0,0x01,0x00,0x0f,
-0x00,0x08,0xd8,0x01,0x00,0x0f,0x00,0x08,0xe0,0x01,0x00,0x0f,0x00,0x08,0xe8,0x01,
-0x00,0x0f,0x00,0x08,0xf0,0x01,0x00,0x0f,0x00,0x08,0xf8,0x01,0x00,0x0f,0x00,0x08,
-0x00,0x02,0x00,0x0f,0x00,0x08,0x08,0x02,0x00,0x0f,0x00,0x08,0x10,0x02,0x00,0x0f,
-0x00,0x08,0x18,0x02,0x00,0x0f,0x00,0x08,0x20,0x02,0x00,0x0f,0x00,0x08,0x28,0x02,
-0x00,0x0f,0x00,0x08,0x30,0x02,0x00,0x0f,0x00,0x08,0x38,0x02,0x00,0x0f,0x00,0x08,
-0x40,0x02,0x00,0x0f,0x00,0x08,0x48,0x02,0x00,0x0f,0x00,0x08,0x50,0x02,0x00,0x0f,
-0x00,0x08,0x58,0x02,0x00,0x0f,0x00,0x08,0x60,0x02,0x00,0x0f,0x00,0x08,0x68,0x02,
-0x00,0x0f,0x00,0x08,0x70,0x02,0x00,0x0f,0x00,0x08,0x78,0x02,0x00,0x0f,0x00,0x08,
-0x80,0x02,0x00,0x0f,0x00,0x08,0x88,0x02,0x00,0x0f,0x00,0x08,0x90,0x02,0x00,0x0f,
-0x00,0x08,0x98,0x02,0x00,0x0f,0x00,0x08,0xa0,0x02,0x00,0x0f,0x00,0x08,0xa8,0x02,
-0x00,0x0f,0x00,0x08,0xb0,0x02,0x00,0x0f,0x00,0x08,0xb8,0x02,0x00,0x0f,0x00,0x08,
-0xc0,0x02,0x00,0x0f,0x00,0x08,0xc8,0x02,0x00,0x0f,0x00,0x08,0xd0,0x02,0x00,0x0f,
-0x00,0x08,0xd8,0x02,0x00,0x0f,0x00,0x08,0xe0,0x02,0x00,0x0f,0x00,0x08,0xe8,0x02,
-0x00,0x0f,0x00,0x08,0xf0,0x02,0x00,0x0f,0x00,0x08,0xf8,0x02,0x00,0x0f,0x00,0x08,
-0x00,0x03,0x00,0x0f,0x00,0x08,0x08,0x03,0x00,0x0f,0x00,0x08,0x10,0x03,0x00,0x0f,
-0x00,0x08,0x18,0x03,0x00,0x0f,0x00,0x08,0x20,0x03,0x00,0x0f,0x00,0x08,0x28,0x03,
-0x00,0x0f,0x00,0x08,0x30,0x03,0x00,0x0f,0x00,0x08,0x38,0x03,0x00,0x0f,0x00,0x08,
-0x40,0x03,0x00,0x0f,0x00,0x08,0x48,0x03,0x00,0x0f,0x00,0x08,0x50,0x03,0x00,0x0f,
-0x00,0x08,0x58,0x03,0x00,0x0f,0x00,0x08,0x60,0x03,0x00,0x0f,0x00,0x08,0x68,0x03,
-0x00,0x0f,0x00,0x08,0x70,0x03,0x00,0x0f,0x00,0x08,0x78,0x03,0x00,0x0f,0x00,0x08,
-0x80,0x03,0x00,0x0f,0x00,0x08,0x88,0x03,0x00,0x0f,0x00,0x08,0x90,0x03,0x00,0x0f,
-0x00,0x08,0x98,0x03,0x00,0x0f,0x00,0x08,0xa0,0x03,0x00,0x0f,0x00,0x08,0xa8,0x03,
-0x00,0x0f,0x00,0x08,0xb0,0x03,0x00,0x0f,0x00,0x08,0xb8,0x03,0x00,0x0f,0x00,0x08,
-0xc0,0x03,0x00,0x0f,0x00,0x08,0xc8,0x03,0x00,0x0f,0x00,0x08,0xd0,0x03,0x00,0x0f,
-0x00,0x08,0xd8,0x03,0x00,0x0f,0x00,0x08,0xe0,0x03,0x00,0x0f,0x00,0x08,0xe8,0x03,
-0x00,0x0f,0x00,0x08,0xf0,0x03,0x00,0x0f,0x00,0x08,0xf8,0x03,0x00,0x0f,0x00,0x08,
-0x00,0x04,0x00,0x0f,0x00,0x08,0x08,0x04,0x00,0x0f,0x00,0x08,0x10,0x04,0x00,0x0f,
-0x00,0x08,0x18,0x04,0x00,0x0f,0x00,0x08,0x20,0x04,0x00,0x0f,0x00,0x08,0x28,0x04,
-0x00,0x0f,0x00,0x08,0x30,0x04,0x00,0x0f,0x00,0x08,0x38,0x04,0x00,0x0f,0x00,0x08,
-0x40,0x04,0x00,0x0f,0x00,0x08,0x48,0x04,0x00,0x0f,0x00,0x08,0x50,0x04,0x00,0x0f,
-0x00,0x08,0x58,0x04,0x00,0x0f,0x00,0x08,0x60,0x04,0x00,0x0f,0x00,0x08,0x68,0x04,
-0x00,0x0f,0x00,0x08,0x70,0x04,0x00,0x0f,0x00,0x08,0x78,0x04,0x00,0x0f,0x00,0x08,
-0x80,0x04,0x00,0x0f,0x00,0x08,0x88,0x04,0x00,0x0f,0x00,0x08,0x90,0x04,0x00,0x0f,
-0x00,0x08,0x98,0x04,0x00,0x0f,0x00,0x08,0xa0,0x04,0x00,0x0f,0x00,0x08,0xa8,0x04,
-0x00,0x0f,0x00,0x08,0xb0,0x04,0x00,0x0f,0x00,0x08,0xb8,0x04,0x00,0x0f,0x00,0x08,
-0xc0,0x04,0x00,0x0f,0x00,0x08,0xc8,0x04,0x00,0x0f,0x00,0x08,0xd0,0x04,0x00,0x0f,
-0x00,0x08,0xd8,0x04,0x00,0x0f,0x00,0x08,0xe0,0x04,0x00,0x0f,0x00,0x08,0xe8,0x04,
-0x00,0x0f,0x00,0x08,0xf0,0x04,0x00,0x0f,0x00,0x08,0xf8,0x04,0x00,0x0f,0x00,0x08,
-0x00,0x05,0x00,0x0f,0x00,0x08,0x08,0x05,0x00,0x0f,0x00,0x08,0x10,0x05,0x00,0x0f,
-0x00,0x08,0x18,0x05,0x00,0x0f,0x00,0x08,0x20,0x05,0x00,0x0f,0x00,0x08,0x28,0x05,
-0x00,0x0f,0x00,0x08,0x30,0x05,0x00,0x0f,0x00,0x08,0x38,0x05,0x00,0x0f,0x00,0x08,
-0x40,0x05,0x00,0x0f,0x00,0x08,0x48,0x05,0x00,0x0f,0x00,0x08,0x50,0x05,0x00,0x0f,
-0x00,0x08,0x58,0x05,0x00,0x0f,0x00,0x08,0x60,0x05,0x00,0x0f,0x00,0x08,0x68,0x05,
-0x00,0x0f,0x00,0x08,0x70,0x05,0x00,0x0f,0x00,0x08,0x78,0x05,0x00,0x0f,0x00,0x08,
-0x80,0x05,0x00,0x0f,0x00,0x08,0x88,0x05,0x00,0x0f,0x00,0x08,0x90,0x05,0x00,0x0f,
-0x00,0x08,0x98,0x05,0x00,0x0f,0x00,0x08,0xa0,0x05,0x00,0x0f,0x00,0x08,0xa8,0x05,
-0x00,0x0f,0x00,0x08,0xb0,0x05,0x00,0x0f,0x00,0x08,0xb8,0x05,0x00,0x0f,0x00,0x08,
-0xc0,0x05,0x00,0x0f,0x00,0x08,0xc8,0x05,0x00,0x0f,0x00,0x08,0xd0,0x05,0x00,0x0f,
-0x00,0x08,0xd8,0x05,0x00,0x0f,0x00,0x08,0xe0,0x05,0x00,0x0f,0x00,0x08,0xe8,0x05,
-0x00,0x0f,0x00,0x08,0xf0,0x05,0x00,0x0f,0x00,0x08,0xf8,0x05,0x00,0x0f,0x00,0x08,
-0x00,0x06,0x00,0x0f,0x00,0x08,0x08,0x06,0x00,0x0f,0x00,0x08,0x10,0x06,0x00,0x0f,
-0x00,0x08,0x18,0x06,0x00,0x0f,0x00,0x08,0x20,0x06,0x00,0x0f,0x00,0x08,0x28,0x06,
-0x00,0x0f,0x00,0x08,0x30,0x06,0x00,0x0f,0x00,0x08,0x38,0x06,0x00,0x0f,0x00,0x08,
-0x40,0x06,0x00,0x0f,0x00,0x08,0x48,0x06,0x00,0x0f,0x00,0x08,0x50,0x06,0x00,0x0f,
-0x00,0x08,0x58,0x06,0x00,0x0f,0x00,0x08,0x60,0x06,0x00,0x0f,0x00,0x08,0x68,0x06,
-0x00,0x0f,0x00,0x08,0x70,0x06,0x00,0x0f,0x00,0x08,0x78,0x06,0x00,0x0f,0x00,0x08,
-0x80,0x06,0x00,0x0f,0x00,0x08,0x88,0x06,0x00,0x0f,0x00,0x08,0x90,0x06,0x00,0x0f,
-0x00,0x08,0x98,0x06,0x00,0x0f,0x00,0x08,0xa0,0x06,0x00,0x0f,0x00,0x08,0xa8,0x06,
-0x00,0x0f,0x00,0x08,0xb0,0x06,0x00,0x0f,0x00,0x08,0xb8,0x06,0x00,0x0f,0x00,0x08,
-0xc0,0x06,0x00,0x0f,0x00,0x08,0xc8,0x06,0x00,0x0f,0x00,0x08,0xd0,0x06,0x00,0x0f,
-0x00,0x08,0xd8,0x06,0x00,0x0f,0x00,0x08,0xe0,0x06,0x00,0x0f,0x00,0x08,0xe8,0x06,
-0x00,0x0f,0x00,0x08,0xf0,0x06,0x00,0x0f,0x00,0x08,0xf8,0x06,0x00,0x0f,0x00,0x08,
-0x00,0x07,0x00,0x0f,0x00,0x08,0x08,0x07,0x00,0x0f,0x00,0x08,0x10,0x07,0x00,0x0f,
-0x00,0x08,0x18,0x07,0x00,0x0f,0x00,0x08,0x20,0x07,0x00,0x0f,0x00,0x08,0x28,0x07,
-0x00,0x0f,0x00,0x08,0x30,0x07,0x00,0x0f,0x00,0x08,0x38,0x07,0x00,0x0f,0x00,0x08,
-0x40,0x07,0x00,0x0f,0x00,0x08,0x48,0x07,0x00,0x0f,0x00,0x08,0x50,0x07,0x00,0x0f,
-0x00,0x08,0x58,0x07,0x00,0x0f,0x00,0x08,0x60,0x07,0x00,0x0f,0x00,0x08,0x68,0x07,
-0x00,0x0f,0x00,0x08,0x70,0x07,0x00,0x0f,0x00,0x08,0x78,0x07,0x00,0x0f,0x00,0x08,
-0x80,0x07,0x00,0x0f,0x00,0x08,0x88,0x07,0x00,0x0f,0x00,0x08,0x90,0x07,0x00,0x0f,
-0x00,0x08,0x98,0x07,0x00,0x0f,0x00,0x08,0xa0,0x07,0x00,0x0f,0x00,0x08,0xa8,0x07,
-0x00,0x0f,0x00,0x08,0xb0,0x07,0x00,0x0f,0x00,0x08,0xb8,0x07,0x00,0x0f,0x00,0x08,
-0xc0,0x07,0x00,0x0f,0x00,0x08,0xc8,0x07,0x00,0x0f,0x00,0x08,0xd0,0x07,0x00,0x0f,
-0x00,0x08,0xd8,0x07,0x00,0x0f,0x00,0x08,0xe0,0x07,0x00,0x0f,0x00,0x08,0xe8,0x07,
-0x00,0x0f,0x00,0x08,0xf0,0x07,0x00,0x0f,0x00,0x08,0xf8,0x07,0x00,0x0f,0x00,0x08,
-0x00,0x08,0x00,0x0f,0x00,0x08,
-};
-
-int	sizeofdefont = sizeof defontdata;
-
-void
-_unpackinfo(Fontchar *fc, uchar *p, int n)
-{
-	int j;
-
-	for(j=0;  j<=n;  j++){
-		fc->x = p[0]|(p[1]<<8);
-		fc->top = p[2];
-		fc->bottom = p[3];
-		fc->left = p[4];
-		fc->width = p[5];
-		fc++;
-		p += 6;
-	}
-}
--- a/libdraw/draw.c
+++ /dev/null
@@ -1,67 +1,0 @@
-#include "draw.h"
-
-void
-_setdrawop(Display *d, Drawop op)
-{
-	uchar *a;
-
-	if(op != SoverD){
-		a = bufimage(d, 1+1);
-		if(a == nil)
-			return;
-		a[0] = 'O';
-		a[1] = op;
-	}
-}
-		
-static void
-draw1(Image *dst, Rectangle *r, Image *src, Point *p0, Image *mask, Point *p1, Drawop op)
-{
-	uchar *a;
-
-	_setdrawop(dst->display, op);
-
-	a = bufimage(dst->display, 1+4+4+4+4*4+2*4+2*4);
-	if(a == nil)
-		return;
-	if(src == nil)
-		src = dst->display->black;
-	if(mask == nil)
-		mask = dst->display->opaque;
-	a[0] = 'd';
-	BPLONG(a+1, dst->id);
-	BPLONG(a+5, src->id);
-	BPLONG(a+9, mask->id);
-	BPLONG(a+13, r->min.x);
-	BPLONG(a+17, r->min.y);
-	BPLONG(a+21, r->max.x);
-	BPLONG(a+25, r->max.y);
-	BPLONG(a+29, p0->x);
-	BPLONG(a+33, p0->y);
-	BPLONG(a+37, p1->x);
-	BPLONG(a+41, p1->y);
-}
-
-void
-draw(Image *dst, Rectangle r, Image *src, Image *mask, Point p1)
-{
-	draw1(dst, &r, src, &p1, mask, &p1, SoverD);
-}
-
-void
-drawop(Image *dst, Rectangle r, Image *src, Image *mask, Point p1, Drawop op)
-{
-	draw1(dst, &r, src, &p1, mask, &p1, op);
-}
-
-void
-gendraw(Image *dst, Rectangle r, Image *src, Point p0, Image *mask, Point p1)
-{
-	draw1(dst, &r, src, &p0, mask, &p1, SoverD);
-}
-
-void
-gendrawop(Image *dst, Rectangle r, Image *src, Point p0, Image *mask, Point p1, Drawop op)
-{
-	draw1(dst, &r, src, &p0, mask, &p1, op);
-}
--- a/libdraw/draw.h
+++ /dev/null
@@ -1,531 +1,0 @@
-#include <pthread.h>
-
-typedef struct	Cachefont Cachefont;
-typedef struct	Cacheinfo Cacheinfo;
-typedef struct	Cachesubf Cachesubf;
-typedef struct	Display Display;
-typedef struct	_Font _Font;
-typedef struct	Fontchar Fontchar;
-typedef struct	Image Image;
-typedef struct	Mouse Mouse;
-typedef struct	Point Point;
-typedef struct	Rectangle Rectangle;
-typedef struct	RGB RGB;
-typedef struct	Screen Screen;
-typedef struct	Subfont Subfont;
-
-typedef unsigned long ulong;
-typedef unsigned char uchar;
-typedef unsigned short ushort;
-typedef unsigned int Rune;
-#define nil ((void*)0)
-
-enum
-{
-	UTFmax		= 4,		/* maximum bytes per rune */
-	Runesync	= 0x80,		/* cannot represent part of a UTF sequence (<) */
-	Runeself	= 0x80,		/* rune and UTF sequences are the same (<) */
-	Runeerror	= 0xFFFD,	/* decoding error in UTF */
-	Runemax		= 0x10FFFF,	/* 21 bit rune */
-};
-
-enum
-{
-	DOpaque		= 0xFFFFFFFF,
-	DTransparent	= 0x00000000,		/* only useful for allocimage, memfillcolor */
-	DBlack		= 0x000000FF,
-	DWhite		= 0xFFFFFFFF,
-	DRed		= 0xFF0000FF,
-	DGreen		= 0x00FF00FF,
-	DBlue		= 0x0000FFFF,
-	DCyan		= 0x00FFFFFF,
-	DMagenta		= 0xFF00FFFF,
-	DYellow		= 0xFFFF00FF,
-	DPaleyellow	= 0xFFFFAAFF,
-	DDarkyellow	= 0xEEEE9EFF,
-	DDarkgreen	= 0x448844FF,
-	DPalegreen	= 0xAAFFAAFF,
-	DMedgreen	= 0x88CC88FF,
-	DDarkblue	= 0x000055FF,
-	DPalebluegreen= 0xAAFFFFFF,
-	DPaleblue		= 0x0000BBFF,
-	DBluegreen	= 0x008888FF,
-	DGreygreen	= 0x55AAAAFF,
-	DPalegreygreen	= 0x9EEEEEFF,
-	DYellowgreen	= 0x99994CFF,
-	DMedblue		= 0x000099FF,
-	DGreyblue	= 0x005DBBFF,
-	DPalegreyblue	= 0x4993DDFF,
-	DPurpleblue	= 0x8888CCFF,
-
-	DNotacolor	= 0xFFFFFF00,
-	DNofill		= DNotacolor,
-	
-};
-
-enum
-{
-	Displaybufsize	= 8000,
-	ICOSSCALE	= 1024,
-	Borderwidth =	4,
-};
-
-enum
-{
-	/* refresh methods */
-	Refbackup	= 0,
-	Refnone		= 1,
-	Refmesg		= 2
-};
-#define	NOREFRESH	((void*)-1)
-
-enum
-{
-	/* line ends */
-	Endsquare	= 0,
-	Enddisc		= 1,
-	Endarrow	= 2,
-	Endmask		= 0x1F
-};
-
-#define	ARROW(a, b, c)	(Endarrow|((a)<<5)|((b)<<14)|((c)<<23))
-
-typedef enum
-{
-	/* Porter-Duff compositing operators */
-	Clear	= 0,
-
-	SinD	= 8,
-	DinS	= 4,
-	SoutD	= 2,
-	DoutS	= 1,
-
-	S		= SinD|SoutD,
-	SoverD	= SinD|SoutD|DoutS,
-	SatopD	= SinD|DoutS,
-	SxorD	= SoutD|DoutS,
-
-	D		= DinS|DoutS,
-	DoverS	= DinS|DoutS|SoutD,
-	DatopS	= DinS|SoutD,
-	DxorS	= DoutS|SoutD,	/* == SxorD */
-
-	Ncomp = 12,
-} Drawop;
-
-/*
- * image channel descriptors 
- */
-enum {
-	CRed = 0,
-	CGreen,
-	CBlue,
-	CGrey,
-	CAlpha,
-	CMap,
-	CIgnore,
-	NChan,
-};
-
-#define __DC(type, nbits)	((((type)&15)<<4)|((nbits)&15))
-#define CHAN1(a,b)	__DC(a,b)
-#define CHAN2(a,b,c,d)	(CHAN1((a),(b))<<8|__DC((c),(d)))
-#define CHAN3(a,b,c,d,e,f)	(CHAN2((a),(b),(c),(d))<<8|__DC((e),(f)))
-#define CHAN4(a,b,c,d,e,f,g,h)	(CHAN3((a),(b),(c),(d),(e),(f))<<8|__DC((g),(h)))
-
-#define NBITS(c) ((c)&15)
-#define TYPE(c) (((c)>>4)&15)
-
-enum {
-	GREY1	= CHAN1(CGrey, 1),
-	GREY2	= CHAN1(CGrey, 2),
-	GREY4	= CHAN1(CGrey, 4),
-	GREY8	= CHAN1(CGrey, 8),
-	CMAP8	= CHAN1(CMap, 8),
-	RGB15	= CHAN4(CIgnore, 1, CRed, 5, CGreen, 5, CBlue, 5),
-	RGB16	= CHAN3(CRed, 5, CGreen, 6, CBlue, 5),
-	RGB24	= CHAN3(CRed, 8, CGreen, 8, CBlue, 8),
-	RGBA32	= CHAN4(CRed, 8, CGreen, 8, CBlue, 8, CAlpha, 8),
-	ARGB32	= CHAN4(CAlpha, 8, CRed, 8, CGreen, 8, CBlue, 8),	/* stupid VGAs */
-	XRGB32	= CHAN4(CIgnore, 8, CRed, 8, CGreen, 8, CBlue, 8),
-	BGR24	= CHAN3(CBlue, 8, CGreen, 8, CRed, 8),
-	ABGR32	= CHAN4(CAlpha, 8, CBlue, 8, CGreen, 8, CRed, 8),
-	XBGR32	= CHAN4(CIgnore, 8, CBlue, 8, CGreen, 8, CRed, 8),
-};
-
-extern	char*	chantostr(char*, ulong);
-extern	ulong	strtochan(char*);
-extern	int		chantodepth(ulong);
-
-struct	Point
-{
-	int	x;
-	int	y;
-};
-
-struct Rectangle
-{
-	Point	min;
-	Point	max;
-};
-
-typedef void	(*Reffn)(Image*, Rectangle, void*);
-
-struct Screen
-{
-	Display	*display;	/* display holding data */
-	int		id;			/* id of system-held Screen */
-	Image	*image;		/* unused; for reference only */
-	Image	*fill;		/* color to paint behind windows */
-};
-
-struct Display
-{
-	int		locking;	/*program is using lockdisplay */
-	int		dirno;
-	int		fd;
-	int		reffd;
-	int		ctlfd;
-	int		imageid;
-	int		local;
-	void		(*error)(Display*, char*);
-	char		*devdir;
-	char		*windir;
-	char		oldlabel[64];
-	ulong		dataqid;
-	Image		*white;
-	Image		*black;
-	Image		*opaque;
-	Image		*transparent;
-	Image		*image;
-	uchar		*buf;
-	int			bufsize;
-	uchar		*bufp;
-	_Font		*defaultfont;
-	Subfont		*defaultsubfont;
-	Image		*windows;
-	Image		*screenimage;
-	int		_isnewdisplay;
-	pthread_mutex_t qlock;
-};
-
-struct Image
-{
-	Display		*display;	/* display holding data */
-	int			id;			/* id of system-held Image */
-	Rectangle	r;			/* rectangle in data area, local coords */
-	Rectangle 	clipr;		/* clipping region */
-	int			depth;		/* number of bits per pixel */
-	ulong		chan;
-	int			repl;		/* flag: data replicates to tile clipr */
-	Screen		*screen;	/* 0 if not a window */
-	Image		*next;		/* next in list of windows */
-};
-
-struct RGB
-{
-	ulong	red;
-	ulong	green;
-	ulong	blue;
-};
-
-/*
- * Subfonts
- *
- * given char c, Subfont *f, Fontchar *i, and Point p, one says
- *	i = f->info+c;
- *	draw(b, Rect(p.x+i->left, p.y+i->top,
- *		p.x+i->left+((i+1)->x-i->x), p.y+i->bottom),
- *		color, f->bits, Pt(i->x, i->top));
- *	p.x += i->width;
- * to draw characters in the specified color (itself an Image) in Image b.
- */
-
-struct	Fontchar
-{
-	int		x;		/* left edge of bits */
-	uchar	top;	/* first non-zero scan-line */
-	uchar	bottom;	/* last non-zero scan-line + 1 */
-	char	left;	/* offset of baseline */
-	uchar	width;	/* width of baseline */
-};
-
-struct	Subfont
-{
-	char		*name;
-	short		n;		/* number of chars in font */
-	uchar		height;	/* height of image */
-	char		ascent;	/* top of image to baseline */
-	Fontchar 	*info;	/* n+1 character descriptors */
-	Image		*bits;	/* of font */
-	int		ref;
-};
-
-enum
-{
-	/* starting values */
-	LOG2NFCACHE =	6,
-	NFCACHE =	(1<<LOG2NFCACHE),	/* #chars cached */
-	NFLOOK =	5,			/* #chars to scan in cache */
-	NFSUBF =	2,			/* #subfonts to cache */
-	/* max value */
-	MAXFCACHE =	1024+NFLOOK,		/* upper limit */
-	MAXSUBF =	50,			/* generous upper limit */
-	/* deltas */
-	DSUBF = 	4,
-	/* expiry ages */
-	SUBFAGE	=	10000,
-	CACHEAGE =	10000
-};
-
-struct Cachefont
-{
-	Rune	min;			/* lowest rune value to be taken from subfont */
-	Rune	max;			/* highest rune value+1 to be taken from subfont */
-	int		offset;			/* position in subfont of character at min */
-	char	*name;			/* stored in font */
-	char	*subfontname;	/* to access subfont */
-};
-
-struct Cacheinfo
-{
-	ushort		x;		/* left edge of bits */
-	uchar		width;	/* width of baseline */
-	char		left;	/* offset of baseline */
-	Rune		value;	/* value of character at this slot in cache */
-	ushort		age;
-};
-
-struct Cachesubf
-{
-	ulong		age;	/* for replacement */
-	Cachefont	*cf;	/* font info that owns us */
-	Subfont		*f;		/* attached subfont */
-};
-
-struct _Font
-{
-	char		*name;
-	Display		*display;
-	short		height;	/* max height of image, interline spacing */
-	short		ascent;	/* top of image to baseline */
-	short		width;	/* widest so far; used in caching only */	
-	short		nsub;	/* number of subfonts */
-	ulong		age;	/* increasing counter; used for LRU */
-	int		maxdepth;	/* maximum depth of all loaded subfonts */
-	int		ncache;	/* size of cache */
-	int		nsubf;	/* size of subfont list */
-	Cacheinfo	*cache;
-	Cachesubf	*subf;
-	Cachefont	**sub;	/* as read from file */
-	Image		*cacheimage;
-};
-
-#define	Dx(r)	((r).max.x-(r).min.x)
-#define	Dy(r)	((r).max.y-(r).min.y)
-
-/*
- * One of a kind
- */
-extern int		mousescrollsize(int);
-
-/*
- * Image management
- */
-extern Image*	_allocimage(Image*, Display*, Rectangle, ulong, int, ulong, int, int);
-extern Image*	allocimage(Display*, Rectangle, ulong, int, ulong);
-extern uchar*	bufimage(Display*, int);
-extern int	bytesperline(Rectangle, int);
-extern void	closedisplay(Display*);
-extern void	drawerror(Display*, char*);
-extern int	flushimage(Display*, int);
-extern int	freeimage(Image*);
-extern int	_freeimage1(Image*);
-extern int	geninitdraw(char*, void(*)(Display*, char*), char*, char*, int);
-extern int	initdraw(void(*)(Display*, char*), char*, char*);
-extern int	newwindow(char*);
-extern Display*	initdisplay(char*, char*, void(*)(Display*, char*));
-extern int	loadimage(Image*, Rectangle, uchar*, int);
-extern int	cloadimage(Image*, Rectangle, uchar*, int);
-extern int	getwindow(Display*, int);
-extern int	gengetwindow(Display*, char*, Image**, Screen**, int);
-extern Image* readimage(Display*, int, int);
-extern Image* creadimage(Display*, int, int);
-extern int	unloadimage(Image*, Rectangle, uchar*, int);
-extern int	wordsperline(Rectangle, int);
-extern int	writeimage(int, Image*, int);
-extern Image*	namedimage(Display*, char*);
-extern int	nameimage(Image*, char*, int);
-extern Image* allocimagemix(Display*, ulong, ulong);
-
-/*
- * Colors
- */
-extern	void	readcolmap(Display*, RGB*);
-extern	void	writecolmap(Display*, RGB*);
-extern	ulong	setalpha(ulong, uchar);
-
-/*
- * Windows
- */
-extern Screen*	allocscreen(Image*, Image*, int);
-extern Image*	_allocwindow(Image*, Screen*, Rectangle, int, ulong);
-extern Image*	allocwindow(Screen*, Rectangle, int, ulong);
-extern void	bottomnwindows(Image**, int);
-extern void	bottomwindow(Image*);
-extern int	freescreen(Screen*);
-extern Screen*	publicscreen(Display*, int, ulong);
-extern void	topnwindows(Image**, int);
-extern void	topwindow(Image*);
-extern int	originwindow(Image*, Point, Point);
-
-/*
- * Geometry
- */
-extern Point		Pt(int, int);
-extern Rectangle	Rect(int, int, int, int);
-extern Rectangle	Rpt(Point, Point);
-extern Point		addpt(Point, Point);
-extern Point		subpt(Point, Point);
-extern Point		divpt(Point, int);
-extern Point		mulpt(Point, int);
-extern int		eqpt(Point, Point);
-extern int		eqrect(Rectangle, Rectangle);
-extern Rectangle	insetrect(Rectangle, int);
-extern Rectangle	rectaddpt(Rectangle, Point);
-extern Rectangle	rectsubpt(Rectangle, Point);
-extern Rectangle	canonrect(Rectangle);
-extern int		rectXrect(Rectangle, Rectangle);
-extern int		rectinrect(Rectangle, Rectangle);
-extern void		combinerect(Rectangle*, Rectangle);
-extern int		rectclip(Rectangle*, Rectangle);
-extern int		ptinrect(Point, Rectangle);
-extern void		replclipr(Image*, int, Rectangle);
-extern int		drawreplxy(int, int, int);	/* used to be drawsetxy */
-extern Point	drawrepl(Rectangle, Point);
-extern int		rgb2cmap(int, int, int);
-extern int		cmap2rgb(int);
-extern int		cmap2rgba(int);
-extern void		icossin(int, int*, int*);
-extern void		icossin2(int, int, int*, int*);
-extern int		badrect(Rectangle);
-
-/*
- * Graphics
- */
-extern void	draw(Image*, Rectangle, Image*, Image*, Point);
-extern void	drawop(Image*, Rectangle, Image*, Image*, Point, Drawop);
-extern void	gendraw(Image*, Rectangle, Image*, Point, Image*, Point);
-extern void	gendrawop(Image*, Rectangle, Image*, Point, Image*, Point, Drawop);
-extern void	line(Image*, Point, Point, int, int, int, Image*, Point);
-extern void	lineop(Image*, Point, Point, int, int, int, Image*, Point, Drawop);
-extern void	poly(Image*, Point*, int, int, int, int, Image*, Point);
-extern void	polyop(Image*, Point*, int, int, int, int, Image*, Point, Drawop);
-extern void	fillpoly(Image*, Point*, int, int, Image*, Point);
-extern void	fillpolyop(Image*, Point*, int, int, Image*, Point, Drawop);
-extern Point	string(Image*, Point, Image*, Point, _Font*, char*);
-extern Point	stringop(Image*, Point, Image*, Point, _Font*, char*, Drawop);
-extern Point	stringn(Image*, Point, Image*, Point, _Font*, char*, int);
-extern Point	stringnop(Image*, Point, Image*, Point, _Font*, char*, int, Drawop);
-extern Point	runestring(Image*, Point, Image*, Point, _Font*, Rune*);
-extern Point	runestringop(Image*, Point, Image*, Point, _Font*, Rune*, Drawop);
-extern Point	runestringn(Image*, Point, Image*, Point, _Font*, Rune*, int);
-extern Point	runestringnop(Image*, Point, Image*, Point, _Font*, Rune*, int, Drawop);
-extern Point	stringbg(Image*, Point, Image*, Point, _Font*, char*, Image*, Point);
-extern Point	stringbgop(Image*, Point, Image*, Point, _Font*, char*, Image*, Point, Drawop);
-extern Point	stringnbg(Image*, Point, Image*, Point, _Font*, char*, int, Image*, Point);
-extern Point	stringnbgop(Image*, Point, Image*, Point, _Font*, char*, int, Image*, Point, Drawop);
-extern Point	runestringbg(Image*, Point, Image*, Point, _Font*, Rune*, Image*, Point);
-extern Point	runestringbgop(Image*, Point, Image*, Point, _Font*, Rune*, Image*, Point, Drawop);
-extern Point	runestringnbg(Image*, Point, Image*, Point, _Font*, Rune*, int, Image*, Point);
-extern Point	runestringnbgop(Image*, Point, Image*, Point, _Font*, Rune*, int, Image*, Point, Drawop);
-extern Point	_string(Image*, Point, Image*, Point, _Font*, char*, Rune*, int, Rectangle, Image*, Point, Drawop);
-extern Point	stringsubfont(Image*, Point, Image*, Subfont*, char*);
-extern int		bezier(Image*, Point, Point, Point, Point, int, int, int, Image*, Point);
-extern int		bezierop(Image*, Point, Point, Point, Point, int, int, int, Image*, Point, Drawop);
-extern int		bezspline(Image*, Point*, int, int, int, int, Image*, Point);
-extern int		bezsplineop(Image*, Point*, int, int, int, int, Image*, Point, Drawop);
-extern int		bezsplinepts(Point*, int, Point**);
-extern int		fillbezier(Image*, Point, Point, Point, Point, int, Image*, Point);
-extern int		fillbezierop(Image*, Point, Point, Point, Point, int, Image*, Point, Drawop);
-extern int		fillbezspline(Image*, Point*, int, int, Image*, Point);
-extern int		fillbezsplineop(Image*, Point*, int, int, Image*, Point, Drawop);
-extern void	ellipse(Image*, Point, int, int, int, Image*, Point);
-extern void	ellipseop(Image*, Point, int, int, int, Image*, Point, Drawop);
-extern void	fillellipse(Image*, Point, int, int, Image*, Point);
-extern void	fillellipseop(Image*, Point, int, int, Image*, Point, Drawop);
-extern void	arc(Image*, Point, int, int, int, Image*, Point, int, int);
-extern void	arcop(Image*, Point, int, int, int, Image*, Point, int, int, Drawop);
-extern void	fillarc(Image*, Point, int, int, Image*, Point, int, int);
-extern void	fillarcop(Image*, Point, int, int, Image*, Point, int, int, Drawop);
-extern void	border(Image*, Rectangle, int, Image*, Point);
-extern void	borderop(Image*, Rectangle, int, Image*, Point, Drawop);
-
-/*
- * Font management
- */
-extern _Font*	openfont(Display*, char*);
-extern _Font*	buildfont(Display*, char*, char*);
-extern void	freefont(_Font*);
-extern _Font*	mkfont(Subfont*, Rune);
-extern int	cachechars(_Font*, char**, Rune**, ushort*, int, int*, char**);
-extern void	agefont(_Font*);
-extern Subfont*	allocsubfont(char*, int, int, int, Fontchar*, Image*);
-extern Subfont*	lookupsubfont(Display*, char*);
-extern void	installsubfont(char*, Subfont*);
-extern void	uninstallsubfont(Subfont*);
-extern void	freesubfont(Subfont*);
-extern Subfont*	readsubfont(Display*, char*, int, int);
-extern Subfont*	readsubfonti(Display*, char*, int, Image*, int);
-extern int	writesubfont(int, Subfont*);
-extern void	_unpackinfo(Fontchar*, uchar*, int);
-extern Point	stringsize(_Font*, char*);
-extern int	stringwidth(_Font*, char*);
-extern int	stringnwidth(_Font*, char*, int);
-extern Point	runestringsize(_Font*, Rune*);
-extern int	runestringwidth(_Font*, Rune*);
-extern int	runestringnwidth(_Font*, Rune*, int);
-extern Point	strsubfontwidth(Subfont*, char*);
-extern int	loadchar(_Font*, Rune, Cacheinfo*, int, int, char**);
-extern char*	subfontname(char*, char*, int);
-extern Subfont*	_getsubfont(Display*, char*);
-extern Subfont*	getdefont(Display*);
-extern void		lockdisplay(Display*);
-extern void	unlockdisplay(Display*);
-
-/*
- * Predefined 
- */
-extern	uchar	defontdata[];
-extern	int		sizeofdefont;
-extern	Point		ZP;
-extern	Rectangle	ZR;
-
-/*
- * Set up by initdraw()
- */
-extern	Display	*_display; /* opaque.h defines display */
-extern	_Font		*font;
-extern	Image	*screen;
-extern	Screen	*_screen;
-extern	int	_cursorfd;
-extern	void	_setdrawop(Display*, Drawop);
-
-#define	BGSHORT(p)	((p)[0]|((p)[1]<<8))
-#define	BGLONG(p)	((p)[0]|((p)[1]<<8)|((p)[2]<<16)|((p)[3]<<24))
-#define BPSHORT(p,v)	do{ushort _v_=(v);(p)[0]=_v_;(p)[1]=_v_>>8;}while(0)
-#define BPLONG(p,v)	do{ulong _v_=(v);(p)[0]=_v_;(p)[1]=_v_>>8;(p)[2]=_v_>>16;(p)[3]=_v_>>24;}while(0)
-
-/*
- * Compressed image file parameters and helper routines
- */
-#define	NMATCH	3		/* shortest match possible */
-#define	NRUN	(NMATCH+31)	/* longest match possible */
-#define	NMEM	1024		/* window size */
-#define	NDUMP	128		/* maximum length of dump */
-#define	NCBLOCK	6000		/* size of compressed blocks */
-extern	void	_twiddlecompressed(uchar*, int);
-extern	int	_compblocksize(Rectangle, int);
-
-extern	ulong	drawld2chan[];
-extern	void	drawsetdebug(int);
--- a/libdraw/freesubfont.c
+++ /dev/null
@@ -1,14 +1,0 @@
-#include <stdlib.h>
-#include "draw.h"
-
-void
-freesubfont(Subfont *f)
-{
-	if(f == nil || --f->ref)
-		return;
-	uninstallsubfont(f);
-	free(f->name);
-	free(f->info);	/* note: f->info must have been malloc'ed! */
-	freeimage(f->bits);
-	free(f);
-}
--- a/libdraw/getdefont.c
+++ /dev/null
@@ -1,60 +1,0 @@
-#include <stdlib.h>
-#include <string.h>
-#include "draw.h"
-
-Subfont*
-getdefont(Display *d)
-{
-	char *hdr, *p;
-	int n;
-	Fontchar *fc;
-	Subfont *f;
-	int ld;
-	Rectangle r;
-	Image *i;
-
-	/*
-	 * make sure data is word-aligned.  this is true with Plan 9 compilers
-	 * but not in general.  the byte order is right because the data is
-	 * declared as char*, not ulong*.
-	 */
-	p = (char*)defontdata;
-	n = (int)(unsigned long long)p & 3;				/* stupid ape */
-	if(n != 0){
-		memmove(p+(4-n), p, sizeofdefont-n);
-		p += 4-n;
-	}
-	ld = atoi(p+0*12);
-	r.min.x = atoi(p+1*12);
-	r.min.y = atoi(p+2*12);
-	r.max.x = atoi(p+3*12);
-	r.max.y = atoi(p+4*12);
-
-	i = allocimage(d, r, drawld2chan[ld], 0, 0);
-	if(i == 0)
-		return 0;
-
-	p += 5*12;
-	n = loadimage(i, r, (uchar*)p, (defontdata+sizeofdefont)-(uchar*)p);
-	if(n < 0){
-		freeimage(i);
-		return 0;
-	}
-
-	hdr = p+n;
-	n = atoi(hdr);
-	p = hdr+3*12;
-	fc = malloc(sizeof(Fontchar)*(n+1));
-	if(fc == 0){
-		freeimage(i);
-		return 0;
-	}
-	_unpackinfo(fc, (uchar*)p, n);
-	f = allocsubfont("*default*", n, atoi(hdr+12), atoi(hdr+24), fc, i);
-	if(f == 0){
-		freeimage(i);
-		free(fc);
-		return 0;
-	}
-	return f;
-}
--- a/libdraw/init.c
+++ /dev/null
@@ -1,451 +1,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <errno.h>
-#include <string.h>
-#include <fcntl.h>
-#include "draw.h"
-
-Display	*_display;
-_Font	*font;
-Image	*screen;
-
-enum{
-	DISP_BUFSIZE = 8000, /* Play with this some, see if changes much */
-};
-
-static char deffontname[] = "*default*";
-Screen	*_screen;
-
-int	debuglockdisplay = 0;
-
-static void _closedisplay(Display*, int);
-
-/* note handler */
-static void
-drawshutdown(void)
-{
-	Display *d;
-
-	d = _display;
-	if(d != nil){
-		_display = nil;
-		_closedisplay(d, 1);
-	}
-}
-
-int
-geninitdraw(char *devdir, void(*error)(Display*, char*), char *label, char *windir, int ref)
-{
-	int fd;
-	char *fontname;
-	char buf[128];
-	Subfont *df;
-
-	_display = initdisplay(devdir, windir, error);
-	if(_display == nil)
-		return -1;
-
-	/*
-	 * Set up default font
-	 */
-	df = getdefont(_display);
-	_display->defaultsubfont = df;
-	if(df == nil){
-    Error:
-		closedisplay(_display);
-		_display = nil;
-		return -1;
-	}
-
-	fd = open("/env/font", O_RDONLY);
-	read(fd, buf, sizeof(buf));
-	fontname = buf;
-
-	/*
-	 * Build fonts with caches==depth of screen, for speed.
-	 * If conversion were faster, we'd use 0 and save memory.
-	 */
-	if(strcmp(fontname, "") != 0){
-		snprintf(buf, sizeof buf, "%d %d\n0 %d\t%s\n", df->height, df->ascent,
-			df->n-1, deffontname);
-//BUG: Need something better for this	installsubfont("*default*", df);
-		font = buildfont(_display, buf, deffontname);
-		if(font == nil)
-			goto Error;
-	}else{
-		font = openfont(_display, fontname);	/* BUG: grey fonts */
-		if(font == nil)
-			goto Error;
-	}
-	_display->defaultfont = font;
-
-	/*
-	 * Write label; ignore errors (we might not be running under rio)
-	 */
-	if(label != nil){
-		snprintf(buf, sizeof buf, "%s/label", _display->windir);
-		fd = open(buf, O_RDONLY);
-		if(fd >= 0){
-			read(fd, _display->oldlabel, (sizeof _display->oldlabel)-1);
-			close(fd);
-			fd = open(buf, O_CREAT|O_WRONLY, 0666);
-			if(fd >= 0){
-				write(fd, label, strlen(label));
-				close(fd);
-			}
-		}
-	}
-
-	snprintf(buf, sizeof buf, "%s/winname", _display->windir);
-	if(gengetwindow(_display, buf, &screen, &_screen, ref) < 0)
-		goto Error;
-
-	atexit(drawshutdown);
-
-	return 1;
-}
-
-int
-initdraw(void(*error)(Display*, char*), char *chroot, char *label)
-{
-	char *dev;
-	sprintf(dev, "%s/dev/", chroot);
-	return geninitdraw(dev, error, label, dev, Refnone);
-}
-
-/*
- * Attach, or possibly reattach, to window.
- * If reattaching, maintain value of screen pointer.
- */
-int
-gengetwindow(Display *d, char *winname, Image **winp, Screen **scrp, int ref)
-{
-	int n, fd;
-	char buf[64+1], obuf[64+1];
-	Image *image;
-	Rectangle r;
-
-	obuf[0] = 0;
-retry:
-	fd = open(winname, O_RDONLY);
-	if(fd<0 || (n=read(fd, buf, sizeof buf-1))<=0){
-		if((image=d->image) == nil){
-			*winp = nil;
-			d->screenimage = nil;
-			return -1;
-		}
-		strcpy(buf, "noborder");
-	}else{
-		close(fd);
-		buf[n] = '\0';
-		image = namedimage(d, buf);
-		if(image == nil){
-			/*
-			 * theres a race where the winname can change after
-			 * we read it, so keep trying as long as the name
-			 * keeps changing.
-			 */
-			if(strcmp(buf, obuf) != 0){
-				strcpy(obuf, buf);
-				goto retry;
-			}
-		}
-		if(*winp != nil){
-			_freeimage1(*winp);
-			freeimage((*scrp)->image);
-			freescreen(*scrp);
-			*scrp = nil;
-		}
-		if(image == nil){
-			*winp = nil;
-			d->screenimage = nil;
-			return -1;
-		}
-	}
-
-	d->screenimage = image;
-	*scrp = allocscreen(image, d->white, 0);
-	if(*scrp == nil){
-		*winp = nil;
-		d->screenimage = nil;
-		freeimage(image);
-		return -1;
-	}
-
-	r = image->r;
-	if(strncmp(buf, "noborder", 8) != 0)
-		r = insetrect(image->r, Borderwidth);
-	*winp = _allocwindow(*winp, *scrp, r, ref, DWhite);
-	if(*winp == nil){
-		freescreen(*scrp);
-		*scrp = nil;
-		d->screenimage = nil;
-		freeimage(image);
-		return -1;
-	}
-	d->screenimage = *winp;
-	return 1;
-}
-
-int
-getwindow(Display *d, int ref)
-{
-	char winname[128];
-
-	snprintf(winname, sizeof winname, "%s/winname", d->windir);
-	return gengetwindow(d, winname, &screen, &_screen, ref);
-}
-
-#define	NINFO	12*12
-
-Display*
-initdisplay(char *dev, char *win, void(*error)(Display*, char*))
-{
-	char buf[128], info[NINFO+1], *t, isnew;
-	int n, datafd, ctlfd, reffd;
-	Display *disp;
-	Image *image;
-
-	if(dev == nil)
-		dev = "/dev";
-	if(win == nil)
-		win = "/dev";
-	if(strlen(dev)>sizeof buf-25 || strlen(win)>sizeof buf-25){
-		return nil;
-	}
-	t = strdup(win);
-	if(t == nil)
-		return nil;
-
-	sprintf(buf, "%s/draw/new", dev);
-	ctlfd = open(buf, O_RDWR);
-	if(ctlfd < 0){
-    Error1:
-		free(t);
-
-		return nil;
-	}
-	if((n=read(ctlfd, info, sizeof info)) < 12){
-    Error2:
-		close(ctlfd);
-		goto Error1;
-	}
-	if(n==NINFO+1)
-		n = NINFO;
-	info[n] = '\0';
-	isnew = 0;
-	if(n < NINFO)	/* this will do for now, we need something better here */
-		isnew = 1;
-	sprintf(buf, "%s/draw/%d/data", dev, atoi(info+0*12));
-	datafd = open(buf, O_RDWR);
-	if(datafd < 0)
-		goto Error2;
-	sprintf(buf, "%s/draw/%d/refresh", dev, atoi(info+0*12));
-	reffd = open(buf, O_RDWR);
-	if(reffd < 0){
-    Error3:
-		close(datafd);
-		goto Error2;
-	}
-	disp = calloc(sizeof(Display), 1);
-	if(disp == nil){
-    Error4:
-		close(reffd);
-		goto Error3;
-	}
-	image = nil;
-	if(0){
-    Error5:
-		free(image);
-		free(disp);
-		goto Error4;
-	}
-	if(n >= NINFO){
-		image = calloc(sizeof(Image), 1);
-		if(image == nil)
-			goto Error5;
-		image->display = disp;
-		image->id = 0;
-		image->chan = strtochan(info+2*12);
-		image->depth = chantodepth(image->chan);
-		image->repl = atoi(info+3*12);
-		image->r.min.x = atoi(info+4*12);
-		image->r.min.y = atoi(info+5*12);
-		image->r.max.x = atoi(info+6*12);
-		image->r.max.y = atoi(info+7*12);
-		image->clipr.min.x = atoi(info+8*12);
-		image->clipr.min.y = atoi(info+9*12);
-		image->clipr.max.x = atoi(info+10*12);
-		image->clipr.max.y = atoi(info+11*12);
-	}
-
-	disp->_isnewdisplay = isnew;
-	disp->bufsize = DISP_BUFSIZE;
-	disp->buf = malloc(disp->bufsize+5);	/* +5 for flush message */
-	if(disp->buf == nil)
-		goto Error5;
-
-	disp->image = image;
-	disp->dirno = atoi(info+0*12);
-	disp->fd = datafd;
-	disp->ctlfd = ctlfd;
-	disp->reffd = reffd;
-	disp->bufp = disp->buf;
-	disp->error = error;
-	disp->windir = t;
-	disp->devdir = strdup(dev);
-	pthread_mutex_lock(&disp->qlock);
-	disp->white = allocimage(disp, Rect(0, 0, 1, 1), GREY1, 1, DWhite);
-	disp->black = allocimage(disp, Rect(0, 0, 1, 1), GREY1, 1, DBlack);
-	if(disp->white == nil || disp->black == nil){
-		free(disp->devdir);
-		free(disp->white);
-		free(disp->black);
-		goto Error5;
-	}
-	disp->opaque = disp->white;
-	disp->transparent = disp->black;
-
-	/* We still need this */
-	//dir = dirfstat(ctlfd);
-	//if(dir!=nil && dir->type=='i'){
-	//	disp->local = 1;
-	//	disp->dataqid = dir->qid.path;
-	//}
-	//if(dir!=nil && dir->qid.vers==1)	/* other way to tell */
-	//	disp->_isnewdisplay = 1;
-	//free(dir);
-
-	return disp;
-}
-
-/*
- * Call with d unlocked.
- * Note that disp->defaultfont and defaultsubfont are not freed here.
- */
-void
-closedisplay(Display *disp)
-{
-	_closedisplay(disp, 0);
-}
-
-static void
-_closedisplay(Display *disp, int isshutdown)
-{
-	int fd;
-	char buf[128];
-
-	if(disp == nil)
-		return;
-	if(disp == _display)
-		_display = nil;
-	if(disp->oldlabel[0]){
-		snprintf(buf, sizeof buf, "%s/label", disp->windir);
-		fd = open(buf, O_WRONLY);
-		if(fd >= 0){
-			write(fd, disp->oldlabel, strlen(disp->oldlabel));
-			close(fd);
-		}
-	}
-
-	/*
-	 * if we're shutting down, don't free all the resources.
-	 * if other procs are getting shot down by notes too,
-	 * one might get shot down while holding the malloc lock.
-	 * just let the kernel clean things up when we exit.
-	 */
-	if(isshutdown)
-		return;
-
-	free(disp->devdir);
-	free(disp->windir);
-	freeimage(disp->white);
-	freeimage(disp->black);
-	close(disp->fd);
-	close(disp->ctlfd);
-	/* should cause refresh slave to shut down */
-	close(disp->reffd);
-	pthread_mutex_unlock(&disp->qlock);
-	free(disp);
-}
-
-void
-lockdisplay(Display *disp)
-{
-	if(debuglockdisplay){
-		/* avoid busy looping; it's rare we collide anyway */
-		while(!pthread_mutex_trylock(&disp->qlock))
-			sleep(1000);
-	}else
-		pthread_mutex_lock(&disp->qlock);
-}
-
-void
-unlockdisplay(Display *disp)
-{
-	pthread_mutex_unlock(&disp->qlock);
-}
-
-void
-drawerror(Display *d, char *s)
-{
-	char err[128]; /* ERRMAX */
-
-	if(d != nil && d->error != nil)
-		(*d->error)(d, s);
-	else{
-		fprintf(stderr, "draw: %s: %s\n", s, err);
-		exit(1);
-	}
-}
-
-static
-int
-doflush(Display *d)
-{
-	int n;
-
-	n = d->bufp-d->buf;
-	if(n <= 0)
-		return 1;
-
-	if(write(d->fd, d->buf, n) != n){
-		d->bufp = d->buf;	/* might as well; chance of continuing */
-		return -1;
-	}
-	d->bufp = d->buf;
-	return 1;
-}
-
-int
-flushimage(Display *d, int visible)
-{
-	if(d == nil)
-		return 0;
-	if(visible){
-		*d->bufp++ = 'v';	/* five bytes always reserved for this */
-		if(d->_isnewdisplay){
-			BPLONG(d->bufp, d->screenimage->id);
-			d->bufp += 4;
-		}
-	}
-	return doflush(d);
-}
-
-uchar*
-bufimage(Display *d, int n)
-{
-	uchar *p;
-
-	if(n<0 || n>d->bufsize){
-		return nil;
-	}
-	if(d->bufp+n > d->buf+d->bufsize)
-		if(doflush(d) < 0)
-			return nil;
-	p = d->bufp;
-	d->bufp += n;
-	return p;
-}
-
--- a/libdraw/loadimage.c
+++ /dev/null
@@ -1,53 +1,0 @@
-#include <stdio.h>
-#include <string.h>
-#include "draw.h"
-
-int
-loadimage(Image *i, Rectangle r, uchar *data, int ndata)
-{
-	long dx, dy;
-	int n, bpl;
-	uchar *a;
-	int chunk;
-
-	chunk = i->display->bufsize - 64;
-
-	if(!rectinrect(r, i->r)){
-		return -1;
-	}
-	bpl = bytesperline(r, i->depth);
-	n = bpl*Dy(r);
-	if(n > ndata){
-		return -1;
-	}
-	ndata = 0;
-	while(r.max.y > r.min.y){
-		dy = Dy(r);
-		dx = Dx(r);
-		if(dy*bpl > chunk)
-			dy = chunk/bpl;
-		if(dy <= 0){
-			dy = 1;
-			dx = ((chunk*dx)/bpl) & ~7;
-			n = bytesperline(Rect(r.min.x, r.min.y, r.min.x+dx, r.min.y+dy), i->depth);
-			if(loadimage(i, Rect(r.min.x+dx, r.min.y, r.max.x, r.min.y+dy), data+n, bpl-n) < 0)
-				return -1;
-		} else
-			n = dy*bpl;
-		a = bufimage(i->display, 21+n);
-		if(a == nil){
-			return -1;
-		}
-		a[0] = 'y';
-		BPLONG(a+1, i->id);
-		BPLONG(a+5, r.min.x);
-		BPLONG(a+9, r.min.y);
-		BPLONG(a+13, r.min.x+dx);
-		BPLONG(a+17, r.min.y+dy);
-		memmove(a+21, data, n);
-		ndata += dy*bpl;
-		data += dy*bpl;
-		r.min.y += dy;
-	}
-	return ndata;
-}
--- a/libdraw/meson.build
+++ /dev/null
@@ -1,27 +1,0 @@
-libdraw_src = [
-    'alloc.c',
-    'arith.c',
-    'badrect.c',
-    'buildfont.c',
-    'bytesperline.c',
-    'chan.c',
-    'defont.c',
-    'draw.c',
-    'freesubfont.c',
-    'getdefont.c',
-    'init.c',
-    'loadimage.c',
-    'openfont.c',
-    'subfont.c',
-    'subfontcache.c',
-    'window.c',
-]
-
-libdraw = static_library(
-    'libdraw',
-    libdraw_src,
-    include_directories: inc,
-    dependencies: common_dep,
-)
-
-install_data('draw.h', install_dir: xorgsdkdir)
--- a/libdraw/openfont.c
+++ /dev/null
@@ -1,47 +1,0 @@
-#include <unistd.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include "draw.h"
-
-static char*
-readfile(char *name)
-{
-	enum { HUNK = 8*1024, };
-	int f, n, r;
-	char *s, *p;
-
-	n = 0;
-	r = -1;
-	if((s = malloc(HUNK)) != nil){
-		if((f = open(name, O_RDONLY)) >= 0){
-			while((r = read(f, s+n, HUNK)) > 0){
-				n += r;
-				r = -1;
-				if((p = realloc(s, n+HUNK)) == nil)
-					break;
-				s = p;
-			}
-			close(f);
-		}
-	}
-	if(r < 0 || (p = realloc(s, n+1)) == nil){
-		free(s);
-		return nil;
-	}
-	p[n] = 0;
-	return p;
-}
-
-_Font*
-openfont(Display *d, char *name)
-{
-	_Font *fnt;
-	char *buf;
-
-	if((buf = readfile(name)) == nil){
-		return nil;
-	}
-	fnt = buildfont(d, buf, name);
-	free(buf);
-	return fnt;
-}
--- a/libdraw/subfont.c
+++ /dev/null
@@ -1,32 +1,0 @@
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include "draw.h"
-
-Subfont*
-allocsubfont(char *name, int n, int height, int ascent, Fontchar *info, Image *i)
-{
-	Subfont *f;
-
-	assert(height != 0 /* allocsubfont */);
-
-	f = malloc(sizeof(Subfont));
-	if(f == nil)
-		return nil;
-	f->n = n;
-	f->height = height;
-	f->ascent = ascent;
-	f->info = info;
-	f->bits = i;
-	f->ref = 1;
-	if(name){
-		f->name = strdup(name);
-		if(f->name == nil){
-			free(f);
-			return nil;
-		}
-		installsubfont(name, f);
-	}else
-		f->name = nil;
-	return f;
-}
--- a/libdraw/subfontcache.c
+++ /dev/null
@@ -1,41 +1,0 @@
-#include <stdlib.h>
-#include <string.h>
-#include "draw.h"
-
-/*
- * Easy versions of the cache routines; may be substituted by fancier ones for other purposes
- */
-
-static char	*lastname;
-static Subfont	*lastsubfont;
-
-Subfont*
-lookupsubfont(Display *d, char *name)
-{
-	if(d && strcmp(name, "*default*") == 0)
-		return d->defaultsubfont;
-	if(lastname && strcmp(name, lastname)==0)
-	if(d==lastsubfont->bits->display){
-		lastsubfont->ref++;
-		return lastsubfont;
-	}
-	return 0;
-}
-
-void
-installsubfont(char *name, Subfont *subfont)
-{
-	free(lastname);
-	lastname = strdup(name);
-	lastsubfont = subfont;	/* notice we don't free the old one; that's your business */
-}
-
-void
-uninstallsubfont(Subfont *subfont)
-{
-	if(subfont == lastsubfont){
-		free(lastname);
-		lastname = 0;
-		lastsubfont = 0;
-	}
-}
--- a/libdraw/window.c
+++ /dev/null
@@ -1,219 +1,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <assert.h>
-#include "draw.h"
-
-typedef struct Memimage Memimage;
-
-static int	screenid;
-
-Screen*
-allocscreen(Image *image, Image *fill, int public)
-{
-	uchar *a;
-	Screen *s;
-	int id, try;
-	Display *d;
-
-	d = image->display;
-	if(d != fill->display){
-		return nil;
-	}
-	s = malloc(sizeof(Screen));
-	if(s == nil)
-		return nil;
-	if(!screenid)
-		screenid = getpid();
-	for(try=0; try<25; try++){
-		/* loop until find a free id */
-		a = bufimage(d, 1+4+4+4+1);
-		if(a == nil)
-			break;
-		id = ++screenid & 0xffff;	/* old devdraw bug */
-		a[0] = 'A';
-		BPLONG(a+1, id);
-		BPLONG(a+5, image->id);
-		BPLONG(a+9, fill->id);
-		a[13] = public;
-		if(flushimage(d, 0) != -1)
-			goto Found;
-	}
-	free(s);
-	return nil;
-
-    Found:
-	s->display = d;
-	s->id = id;
-	s->image = image;
-	assert(s->image != nil && s->image->chan != 0);
-
-	s->fill = fill;
-	return s;
-}
-
-Screen*
-publicscreen(Display *d, int id, ulong chan)
-{
-	uchar *a;
-	Screen *s;
-
-	s = malloc(sizeof(Screen));
-	if(s == nil)
-		return nil;
-	a = bufimage(d, 1+4+4);
-	if(a == nil){
-Error:
-		free(s);
-		return nil;
-	}
-	a[0] = 'S';
-	BPLONG(a+1, id);
-	BPLONG(a+5, chan);
-	if(flushimage(d, 0) < 0)
-		goto Error;
-
-	s->display = d;
-	s->id = id;
-	s->image = nil;
-	s->fill = nil;
-	return s;
-}
-
-int
-freescreen(Screen *s)
-{
-	uchar *a;
-	Display *d;
-
-	if(s == nil)
-		return 0;
-	d = s->display;
-	a = bufimage(d, 1+4);
-	if(a == nil){
-Error:
-		free(s);
-		return -1;
-	}
-	a[0] = 'F';
-	BPLONG(a+1, s->id);
-	/*
-	 * flush(1) because screen is likely holding last reference to
-	 * window, and want it to disappear visually.
-	 */
-	if(flushimage(d, 1) < 0)
-		goto Error;
-	free(s);
-	return 1;
-}
-
-Image*
-allocwindow(Screen *s, Rectangle r, int ref, ulong col)
-{
-	return _allocwindow(nil, s, r, ref, col);
-}
-
-Image*
-_allocwindow(Image *i, Screen *s, Rectangle r, int ref, ulong col)
-{
-	Display *d;
-
-	d = s->display;
-	i = _allocimage(i, d, r, d->screenimage->chan, 0, col, s->id, ref);
-	if(i == nil)
-		return nil;
-	i->screen = s;
-	i->next = s->display->windows;
-	s->display->windows = i;
-	return i;
-}
-
-static
-void
-topbottom(Image **w, int n, int top)
-{
-	int i;
-	uchar *b;
-	Display *d;
-
-	if(n < 0){
-    Ridiculous:
-		fprintf(2, "top/bottom: ridiculous number of windows\n");
-		return;
-	}
-	if(n == 0)
-		return;
-	if(n > (w[0]->display->bufsize-100)/4)
-		goto Ridiculous;
-	/*
-	 * this used to check that all images were on the same screen.
-	 * we don't know the screen associated with images we acquired
-	 * by name.  instead, check that all images are on the same display.
-	 * the display will check that they are all on the same screen.
-	 */
-	d = w[0]->display;
-	for(i=1; i<n; i++)
-		if(w[i]->display != d){
-			fprintf(2, "top/bottom: windows not on same screen\n");
-			return;
-		}
-
-	if(n==0)
-		return;
-	b = bufimage(d, 1+1+2+4*n);
-	if(b == nil)
-		return;
-	b[0] = 't';
-	b[1] = top;
-	BPSHORT(b+2, n);
-	for(i=0; i<n; i++)
-		BPLONG(b+4+4*i, w[i]->id);
-}
-
-void
-bottomwindow(Image *w)
-{
-	if(w->screen != nil)
-		topbottom(&w, 1, 0);
-}
-
-void
-topwindow(Image *w)
-{
-	if(w->screen != nil)
-		topbottom(&w, 1, 1);
-}
-
-void
-bottomnwindows(Image **w, int n)
-{
-	topbottom(w, n, 0);
-}
-
-void
-topnwindows(Image **w, int n)
-{
-	topbottom(w, n, 1);
-}
-
-int
-originwindow(Image *w, Point log, Point scr)
-{
-	uchar *b;
-	Point delta;
-
-	b = bufimage(w->display, 1+4+2*4+2*4);
-	if(b == nil)
-		return 0;
-	b[0] = 'o';
-	BPLONG(b+1, w->id);
-	BPLONG(b+5, log.x);
-	BPLONG(b+9, log.y);
-	BPLONG(b+13, scr.x);
-	BPLONG(b+17, scr.y);
-	delta = subpt(log, w->r.min);
-	w->r = rectaddpt(w->r, delta);
-	w->clipr = rectaddpt(w->clipr, delta);
-	return 1;
-}
--- a/meson.build
+++ b/meson.build
@@ -1,5 +1,38 @@
-subdir('libdraw')
-subdir('src')
+subdir('draw')
+
+srcs = [
+    'x9dev.c',
+    'keyboard.c',
+    'mouse.c',
+    'screen.c',
+    'x9dev.h',
+    'keymap.h',
+    '../../mi/miinitext.c',
+]
+
+cc_args = [
+    '-Wno-missing-braces',
+]
+
+x9dev_server = executable('x9dev',
+    srcs,
+    include_directories: inc, 
+    dependencies: common_dep, 
+    link_with: [
+        draw,
+        libxserver_mi,
+        libxserver_main,
+        libxserver_fb,
+        libxserver,
+        libxserver_xkb_stubs,
+        libxserver_xi_stubs,
+        libxserver_glx,
+        libglxvnd,
+        libxserver_miext_shadow,
+    ],
+    c_args: cc_args,
+    install: true,
+)
 
 install_man(configure_file(
     input: 'man/x9dev.man',
--- /dev/null
+++ b/mouse.c
@@ -1,0 +1,145 @@
+/*
+ * Copyright (c) 2008 Federico G. Benavento <benavento@gmail.com>
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "x9dev.h"
+
+extern DeviceIntPtr x9devMouse;
+int oldx, oldy, oldbut;
+
+#define e    ev.u.u
+#define ek    ev.u.keyButtonPointer
+static void
+x9devSendMouseEvent(int x, int y, int b, int t)
+{
+    xEvent ev;
+
+    memset(&ev, 0, sizeof(xEvent));
+    e.type = t;
+    e.detail = b;
+    ek.rootX = x;
+    ek.rootY = y;
+    ek.time = GetTimeInMillis();
+    mieqEnqueue(x9devMouse, (InternalEvent *)&ev);
+}
+#undef ek
+#undef e
+
+static int
+x9devMouseRead(int *x, int *y, int *b)
+{
+    int n;
+    char buf[1+4*12];
+
+    if((n = read(x9di.mfd, buf, 1 + 4 * 12)) <= 0)
+        return 0;
+
+    if (n != 1 + 4 * 12)
+        FatalError("Bad mouse event");
+
+    if (buf[0] == 'r') {
+        x9devResize();
+        return 0;
+    }
+
+    *x = atoi(buf + 1 + 0 * 12) - screen->r.min.x;
+    *y = atoi(buf + 1 + 1 * 12) - screen->r.min.y;
+    *b = atoi(buf + 1 + 2 * 12);
+
+    return 1;
+}
+
+
+int  
+x9devMouseHandle(void)
+{
+    int x, y, b, but, t;
+
+    if (!x9devMouseRead(&x, &y, &but))
+        return 0;
+
+    t = b = 0;
+    if (x != oldx || y != oldy) {
+        t = MotionNotify;
+        oldx = x, oldy = y;
+    }
+    if (but != oldbut) {
+        b = oldbut ^ but;
+        t = ButtonPress;
+        if (oldbut & b)
+            t = ButtonRelease;
+        if (b == 4)
+            b = 3;
+        if (but & (8 | 16)) {
+            if (b & 8)
+                b = 4;
+            else
+                b = 5;
+            x9devSendMouseEvent(x, y, b, ButtonPress);
+            x9devSendMouseEvent(x, y, b, ButtonRelease);
+            return 1;
+        }
+    }
+    x9devSendMouseEvent(x, y, b, t);
+    oldbut = but;
+
+    return 1;
+}
+
+int  
+x9devMouseProc(DeviceIntPtr pDevice, int what)
+{
+    static unsigned char    map[] = {0, 1, 2, 3, 4, 5};
+    DevicePtr pDev = (DevicePtr)pDevice;
+    Atom btn_labels[3] = {0};
+    Atom axes_labels[2] = {0};
+
+    /* Init our globals */
+    oldx = oldy = oldbut = 0;
+
+    switch (what) {
+    case DEVICE_INIT:
+        btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
+        btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
+        btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
+
+        axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
+        axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
+        InitPointerDeviceStruct(pDev, map, 3, btn_labels,
+            (PtrCtrlProcPtr)NoopDDA, GetMotionHistorySize(), 2, axes_labels);
+        break;
+
+    case DEVICE_ON:
+        pDev->on = TRUE;
+        break;
+
+    case DEVICE_CLOSE:
+    case DEVICE_OFF:
+        pDev->on = FALSE;
+        break;
+    }
+    return Success;
+}
\ No newline at end of file
--- /dev/null
+++ b/screen.c
@@ -1,0 +1,187 @@
+/*
+ * Copyright (c) 2008 Federico G. Benavento <benavento@gmail.com>
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "x9dev.h"
+
+static void
+x9devRefreshScreen(int x1, int y1, int x2, int y2)
+{ 
+    Rectangle r;
+    uchar *p;
+    int n;
+
+    p = (uchar *)x9di.fb+(y1*x9di.width+x1)*(x9di.depth/8);
+    r = rectaddpt(Rect(x1, y1, x2, y2), screen->r.min);
+    if (Dx(r) == x9di.width) {
+        if (loadimage(screen, r, p, x9di.bpl * Dy(r)) < 0)
+            FatalError("can't load image");
+        goto End;
+    }
+    n = Dx(r)*(x9di.depth/8);
+    y2 += screen->r.min.y;
+       while(r.min.y < y2) {
+        r.max.y = r.min.y+1;
+        if (loadimage(screen, r, p, n) < 0)
+            FatalError("can't load image");
+        p += x9di.bpl;
+        r.min.y++;
+    }
+End:
+    flushimage(_display, 1);
+}
+
+
+void
+x9devResize(void)
+{
+    if (getwindow(_display, Refnone) < 0)
+        FatalError("can't reattach to window");
+
+    draw(screen, screen->r, _display->white, NULL, ZP);
+    x9devRefreshScreen(0, 0, x9di.width, x9di.height);
+}
+
+static void
+x9devWakeupHandler(ScreenPtr scr, int result)
+{
+    if (result <= 0)
+        return;
+
+    while (x9devMouseHandle())
+        ;
+    while (x9devKeybdHandle())
+        ;
+}
+
+static void
+x9devShadowUpdate(ScreenPtr pScreen, shadowBufPtr pBuf)
+{
+    BoxPtr pbox;
+
+    pbox = REGION_EXTENTS(pScreen, &pBuf->pDamage);
+    x9devRefreshScreen(pbox->x1, pbox->y1, pbox->x2, pbox->y2);
+}
+
+
+static void
+x9devCursorLimits(DeviceIntPtr dptr, ScreenPtr spr, CursorPtr cpr, BoxPtr hot, BoxPtr topleft)
+{
+    *topleft = *hot;
+}
+
+
+/* callback dance... */
+static CreateScreenResourcesProcPtr x9devCreateResourcesPtr;
+
+static Bool
+x9devCreateResources(ScreenPtr pScreen)
+{
+    Bool ret = 0;
+
+    pScreen->CreateScreenResources = x9devCreateResourcesPtr;
+    if (pScreen->CreateScreenResources)
+        ret = pScreen->CreateScreenResources(pScreen);
+
+    x9devCreateResourcesPtr = pScreen->CreateScreenResources;
+    pScreen->CreateScreenResources = x9devCreateResourcesPtr;
+    if (ret == FALSE)
+        return FALSE;
+
+    shadowRemove(pScreen, pScreen->GetScreenPixmap(pScreen));
+    if (!shadowAdd(pScreen, pScreen->GetScreenPixmap(pScreen), x9devShadowUpdate, NULL, SHADOW_ROTATE_0, 0))
+        return FALSE;
+
+    return ret;
+}
+
+Bool
+x9devScreenInit(ScreenPtr pScreen, int argc, char *argv[])
+{
+    int v, i;
+    unsigned long   r, g, b;
+    static int  first = 1;
+
+    if (first) {
+        x9devInfoInit();
+        first = 0;
+    }
+
+    for (i = 0; i < NUMFORMATS; i++)
+        fbSetVisualTypes(formats[i].depth, 0, 8);
+
+    switch (x9di.depth) {
+    case 16:
+        r = 0xF800, g = 0x07E0, b = 0x001F;
+        v = 1 << TrueColor;
+        break;
+    case 24:
+    case 32:
+        r = 0xFF0000, g = 0x00FF00, b = 0x0000FF;
+        v = 1 << TrueColor;
+        break;
+    default:
+        r = g = b = 0;
+        v = 1 << PseudoColor;
+    }
+    if (!fbSetVisualTypesAndMasks(x9di.depth, v, 8, r, g, b))
+        return FALSE;
+
+    if (!fbScreenInit(pScreen, x9di.fb, x9di.width, x9di.height,
+        x9di.dpi, x9di.dpi, x9di.width, x9di.depth))
+        return FALSE;
+
+    pScreen->mmWidth = x9di.width * 25.4 / x9di.dpi;
+    pScreen->mmHeight = x9di.height * 25.4 / x9di.dpi;
+
+    /* cursor */
+    pScreen->ConstrainCursor = x9devConstrainCursor;
+    pScreen->CursorLimits = x9devCursorLimits;
+    pScreen->DisplayCursor = x9devDisplayCursor;
+    pScreen->RealizeCursor = x9devRealizeCursor;
+    pScreen->UnrealizeCursor = x9devUnrealizeCursor;
+    pScreen->RecolorCursor = x9devRecolorCursor;
+    pScreen->SetCursorPosition = x9devSetCursorPosition;
+
+    pScreen->SaveScreen = x9devSaveScreen;
+    pScreen->WakeupHandler = x9devWakeupHandler;
+
+#ifdef RENDER
+    if (!fbPictureInit(pScreen, 0, 0))
+        return FALSE;
+#endif
+
+   if (!shadowSetup(pScreen))
+        return FALSE;
+
+    x9devCreateResourcesPtr = pScreen->CreateScreenResources;
+    pScreen->CreateScreenResources = x9devCreateResources;
+
+    if (!fbCreateDefColormap(pScreen))
+        return FALSE;
+
+    return TRUE;
+}
--- a/src/keyboard.c
+++ /dev/null
@@ -1,164 +1,0 @@
-/*
- * Copyright (c) 2008 Federico G. Benavento <benavento@gmail.com>
- * 
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- * 
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "x9dev.h"
-#include "keymap.h"
-
-#define KF      0xF000
-#define Kdown   0x80
-
-extern x9devInfo x9di;
-extern DeviceIntPtr x9devKeybd;
-static CARD8 modmap[MAP_LENGTH];
-
-#define e    ev.u.u
-#define ek    ev.u.keyButtonPointer
-
-static void
-x9devSendKeybdEvent(int k, int t)
-{
-    xEvent ev;
-
-    memset(&ev, 0, sizeof(xEvent));
-    e.type = t;
-    e.detail = k + MIN_KEYCODE;
-    ek.time = GetTimeInMillis();
-    mieqEnqueue(x9devKeybd, (InternalEvent *)&ev);
-}
-
-#undef ek
-#undef e
-
-static wchar_t
-x9devKeybdRead(void)
-{
-    static char s[3];
-    static int  n = 0;
-    wchar_t rune;
-
-    if(read(x9di.kfd, s+n, 1) != 1)
-        return 0;
-
-    rune = s[0];
-
-    if (n > 0 || (rune & 0x80) != 0x00) {
-        if (mbtowc(&rune, s, n + 1) == -1) {
-            if (++n == 3)
-                n = 0;
-            return 0;
-        }
-        n = 0;
-    }
-
-    if (rune == Kdown)
-        rune = 0x99;
-    else if (rune & KF)
-        rune = (rune&~KF) + 0x80;
-
-    return rune;
-}
-
-int  
-x9devKeybdHandle(void)
-{
-    unsigned char   k, m;
-    int c;
-
-    c = x9devKeybdRead();
-    if (c == 0 || c > sizeof(rune2keycode))
-        return 0;
-
-    k = rune2keycode[c].key;
-    if (k == 0)
-        return 0;
-
-    m = rune2keycode[c].mod;
-    if (m) 
-        x9devSendKeybdEvent(m, KeyPress);
-
-    x9devSendKeybdEvent(k, KeyPress);
-    x9devSendKeybdEvent(k, KeyRelease);
-    if (m) 
-        x9devSendKeybdEvent(m, KeyRelease);
-
-    return 1;
-}
-
-static void
-x9devInitModmap(void)
-{
-    KeySym * ks;
-    int i;
-
-    for (i = 0; i < MAP_LENGTH; i++)
-        modmap[i] = NoSymbol;
-
-    for (i = MIN_KEYCODE, ks = map; i < (MIN_KEYCODE + NUM_KEYCODES); i++, ks += MAP_WIDTH)
-        switch (*ks) {
-        case XK_Shift_L:
-        case XK_Shift_R:
-            modmap[i] = ShiftMask;
-            break;
-        case XK_Control_L:
-        case XK_Control_R:
-            modmap[i] = ControlMask;
-            break;
-        case XK_Alt_L:
-        case XK_Alt_R:
-            modmap[i] = Mod1Mask;
-            break;
-        }
-}
-
-int  
-x9devKeybdProc(DeviceIntPtr pDev, int what)
-{
-    switch (what) {
-    case DEVICE_INIT:
-        x9devInitModmap();
-        if (!InitKeyboardDeviceStruct(pDev, NULL, 
-            (BellProcPtr)NoopDDA, (KbdCtrlProcPtr)NoopDDA))
-            FatalError("can't init keyboard");
-	pDev->inited = TRUE;
-        break;
-    case DEVICE_ON:
-        pDev->enabled = TRUE;
-        break;
-    case DEVICE_CLOSE:
-	break;
-    case DEVICE_OFF:
-        pDev->enabled = FALSE;
-        break;
-    }
-    return Success;
-}
-
-Bool
-x9checkmod(unsigned int k, DeviceIntPtr pDev)
-{
-    return modmap[k] != 0;
-}
--- a/src/keymap.h
+++ /dev/null
@@ -1,560 +1,0 @@
-/* the key names define come from xwin/winkeynames.h, hence the NOTICE */
-
-/*
- * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Thomas Roell not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Thomas Roell makes no representations
- * about the suitability of this software for any purpose.  It is provided
- * "as is" without express or implied warranty.
- *
- * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- */
-
-#define MAP_WIDTH   4
-#define NUM_KEYCODES    248
-#define MIN_KEYCODE     8
-#define MAX_KEYCODE     (NUM_KEYCODES + MIN_KEYCODE-1)
-
-/*
- * definition of the AT84/MF101/MF102 Keyboard:
- * ============================================================
- *       Defined             Key Cap Glyphs       Pressed value
- *      Key Name            Main       Also       (hex)    (dec)
- *      ----------------   ---------- -------    ------    ------
- */
-
-#define KEY_Escape       /* Escape                0x01  */    1  
-#define KEY_1            /* 1           !         0x02  */    2 
-#define KEY_2            /* 2           @         0x03  */    3 
-#define KEY_3            /* 3           #         0x04  */    4 
-#define KEY_4            /* 4           $         0x05  */    5 
-#define KEY_5            /* 5           %         0x06  */    6 
-#define KEY_6            /* 6           ^         0x07  */    7 
-#define KEY_7            /* 7           &         0x08  */    8 
-#define KEY_8            /* 8           *         0x09  */    9 
-#define KEY_9            /* 9           (         0x0a  */   10 
-#define KEY_0            /* 0           )         0x0b  */   11 
-#define KEY_Minus        /* - (Minus)   _ (Under) 0x0c  */   12
-#define KEY_Equal        /* = (Equal)   +         0x0d  */   13 
-#define KEY_BackSpace    /* Back Space            0x0e  */   14 
-#define KEY_Tab          /* Tab                   0x0f  */   15
-#define KEY_Q            /* Q                     0x10  */   16
-#define KEY_W            /* W                     0x11  */   17
-#define KEY_E            /* E                     0x12  */   18
-#define KEY_R            /* R                     0x13  */   19
-#define KEY_T            /* T                     0x14  */   20
-#define KEY_Y            /* Y                     0x15  */   21
-#define KEY_U            /* U                     0x16  */   22
-#define KEY_I            /* I                     0x17  */   23
-#define KEY_O            /* O                     0x18  */   24
-#define KEY_P            /* P                     0x19  */   25
-#define KEY_LBrace       /* [           {         0x1a  */   26
-#define KEY_RBrace       /* ]           }         0x1b  */   27 
-#define KEY_Enter        /* Enter                 0x1c  */   28
-#define KEY_LCtrl        /* Ctrl(left)            0x1d  */   29
-#define KEY_A            /* A                     0x1e  */   30
-#define KEY_S            /* S                     0x1f  */   31
-#define KEY_D            /* D                     0x20  */   32 
-#define KEY_F            /* F                     0x21  */   33
-#define KEY_G            /* G                     0x22  */   34
-#define KEY_H            /* H                     0x23  */   35
-#define KEY_J            /* J                     0x24  */   36
-#define KEY_K            /* K                     0x25  */   37
-#define KEY_L            /* L                     0x26  */   38
-#define KEY_SemiColon    /* ;(SemiColon) :(Colon) 0x27  */   39
-#define KEY_Quote        /* ' (Apostr)  " (Quote) 0x28  */   40
-#define KEY_Tilde        /* ` (Accent)  ~ (Tilde) 0x29  */   41
-#define KEY_ShiftL       /* Shift(left)           0x2a  */   42
-#define KEY_BSlash       /* \(BckSlash) |(VertBar)0x2b  */   43
-#define KEY_Z            /* Z                     0x2c  */   44
-#define KEY_X            /* X                     0x2d  */   45
-#define KEY_C            /* C                     0x2e  */   46
-#define KEY_V            /* V                     0x2f  */   47
-#define KEY_B            /* B                     0x30  */   48
-#define KEY_N            /* N                     0x31  */   49
-#define KEY_M            /* M                     0x32  */   50
-#define KEY_Comma        /* , (Comma)   < (Less)  0x33  */   51
-#define KEY_Period       /* . (Period)  >(Greater)0x34  */   52
-#define KEY_Slash        /* / (Slash)   ?         0x35  */   53
-#define KEY_ShiftR       /* Shift(right)          0x36  */   54
-#define KEY_KP_Multiply  /* *                     0x37  */   55
-#define KEY_Alt          /* Alt(left)             0x38  */   56
-#define KEY_Space        /*   (SpaceBar)          0x39  */   57
-#define KEY_CapsLock     /* CapsLock              0x3a  */   58
-#define KEY_F1           /* F1                    0x3b  */   59
-#define KEY_F2           /* F2                    0x3c  */   60
-#define KEY_F3           /* F3                    0x3d  */   61
-#define KEY_F4           /* F4                    0x3e  */   62
-#define KEY_F5           /* F5                    0x3f  */   63
-#define KEY_F6           /* F6                    0x40  */   64
-#define KEY_F7           /* F7                    0x41  */   65
-#define KEY_F8           /* F8                    0x42  */   66
-#define KEY_F9           /* F9                    0x43  */   67
-#define KEY_F10          /* F10                   0x44  */   68
-#define KEY_NumLock      /* NumLock               0x45  */   69
-#define KEY_ScrollLock   /* ScrollLock            0x46  */   70
-#define KEY_KP_7         /* 7           Home      0x47  */   71 
-#define KEY_KP_8         /* 8           Up        0x48  */   72 
-#define KEY_KP_9         /* 9           PgUp      0x49  */   73 
-#define KEY_KP_Minus     /* - (Minus)             0x4a  */   74
-#define KEY_KP_4         /* 4           Left      0x4b  */   75
-#define KEY_KP_5         /* 5                     0x4c  */   76
-#define KEY_KP_6         /* 6           Right     0x4d  */   77
-#define KEY_KP_Plus      /* + (Plus)              0x4e  */   78
-#define KEY_KP_1         /* 1           End       0x4f  */   79
-#define KEY_KP_2         /* 2           Down      0x50  */   80
-#define KEY_KP_3         /* 3           PgDown    0x51  */   81
-#define KEY_KP_0         /* 0           Insert    0x52  */   82
-#define KEY_KP_Decimal   /* . (Decimal) Delete    0x53  */   83 
-#define KEY_SysReqest    /* SysReqest             0x54  */   84
-                         /* NOTUSED               0x55  */
-#define KEY_Less         /* < (Less)   >(Greater) 0x56  */   86
-#define KEY_F11          /* F11                   0x57  */   87
-#define KEY_F12          /* F12                   0x58  */   88
-
-#define KEY_Prefix0      /* special               0x60  */   96
-#define KEY_Prefix1      /* specail               0x61  */   97
-
-/*
- * The 'scancodes' below are generated by the server, because the MF101/102
- * keyboard sends them as sequence of other scancodes
- */
-#define KEY_Home         /* Home                  0x59  */   89
-#define KEY_Up           /* Up                    0x5a  */   90
-#define KEY_PgUp         /* PgUp                  0x5b  */   91
-#define KEY_Left         /* Left                  0x5c  */   92
-#define KEY_Begin        /* Begin                 0x5d  */   93
-#define KEY_Right        /* Right                 0x5e  */   94
-#define KEY_End          /* End                   0x5f  */   95
-#define KEY_Down         /* Down                  0x60  */   96
-#define KEY_PgDown       /* PgDown                0x61  */   97
-#define KEY_Insert       /* Insert                0x62  */   98
-#define KEY_Delete       /* Delete                0x63  */   99
-#define KEY_KP_Enter     /* Enter                 0x64  */  100
-#define KEY_RCtrl        /* Ctrl(right)           0x65  */  101
-#define KEY_Pause        /* Pause                 0x66  */  102
-#define KEY_Print        /* Print                 0x67  */  103
-#define KEY_KP_Divide    /* Divide                0x68  */  104
-#define KEY_AltLang      /* AtlLang(right)        0x69  */  105
-#define KEY_Break        /* Break                 0x6a  */  106
-#define KEY_LMeta        /* Left Meta             0x6b  */  107
-#define KEY_RMeta        /* Right Meta            0x6c  */  108
-#define KEY_Menu         /* Menu                  0x6d  */  109
-#define KEY_F13          /* F13                   0x6e  */  110
-#define KEY_F14          /* F14                   0x6f  */  111
-#define KEY_F15          /* F15                   0x70  */  112
-#define KEY_F16          /* F16                   0x71  */  113
-#define KEY_F17          /* F17                   0x72  */  114
-#define KEY_KP_DEC       /* KP_DEC                0x73  */  115
-#define KEY_KP_Equal     /* Equal (Keypad)        0x76  */  118
-#define KEY_XFER         /* Kanji Transfer        0x79  */  121
-#define KEY_NFER         /* No Kanji Transfer     0x7b  */  123
-#define KEY_Yen          /* Yen                   0x7d  */  125
-#define KEY_HKTG         /* Hirugana/Katakana tog 0xc8  */  200
-#define KEY_BSlash2      /* \           _         0xcb  */  203
-
-struct{
-    unsigned char key, mod;
-}rune2keycode[] = {
-    KEY_Delete, KEY_ShiftL, /* 0x000 */
-    KEY_A,  KEY_LCtrl,  /* 0x001 */
-    KEY_B,  KEY_LCtrl,  /* 0x002 */
-    KEY_C,  KEY_LCtrl,  /* 0x003 */
-    KEY_D,  KEY_LCtrl,  /* 0x004 */
-    KEY_E,  KEY_LCtrl,  /* 0x005 */
-    KEY_F,  KEY_LCtrl,  /* 0x006 */
-    KEY_G,  KEY_LCtrl,  /* 0x007 */
-    KEY_BackSpace,  0,  /* 0x008 */
-    KEY_Tab,    0,  /* 0x009 */
-    KEY_Enter,  0,  /* 0x00a */
-    KEY_K,  KEY_LCtrl,  /* 0x00b */
-    KEY_L,  KEY_LCtrl,  /* 0x00c */
-    KEY_M,    KEY_LCtrl,  /* 0x00d */
-    KEY_N,  KEY_LCtrl,  /* 0x00e */
-    KEY_O,  KEY_LCtrl,  /* 0x00f */
-    KEY_P,  KEY_LCtrl,  /* 0x010 */
-    KEY_Q,  KEY_LCtrl,  /* 0x011 */
-    KEY_R,  KEY_LCtrl,  /* 0x012 */
-    KEY_S,  KEY_LCtrl,  /* 0x013 */
-    KEY_T,  KEY_LCtrl,  /* 0x014 */
-    KEY_U,  KEY_LCtrl,  /* 0x015 */
-    KEY_V,  KEY_LCtrl,  /* 0x016 */
-    KEY_W,  KEY_LCtrl,  /* 0x017 */
-    KEY_X,  KEY_LCtrl,  /* 0x018 */
-    KEY_Y,  KEY_LCtrl,  /* 0x019 */
-    KEY_Z,  KEY_LCtrl,  /* 0x01a */
-    KEY_Escape, 0,  /* 0x01b */
-    KEY_BSlash, KEY_LCtrl,  /* 0x01c */
-    KEY_RBrace, KEY_LCtrl,  /* 0x01d */
-    KEY_Period, KEY_LCtrl,  /* 0x01e */
-    KEY_Slash,  KEY_LCtrl,  /* 0x01f */
-    KEY_Space,  0,  /* 0x020 */
-    KEY_1,  KEY_ShiftL, /* 0x021 */
-    KEY_Quote,  KEY_ShiftL, /* 0x022 */
-    KEY_3,  KEY_ShiftL, /* 0x023 */
-    KEY_4,  KEY_ShiftL, /* 0x024 */
-    KEY_5,  KEY_ShiftL, /* 0x025 */
-    KEY_7,  KEY_ShiftL, /* 0x026 */
-    KEY_Quote,  0,  /* 0x027 */
-    KEY_9,  KEY_ShiftL, /* 0x028 */
-    KEY_0,  KEY_ShiftL, /* 0x029 */
-    KEY_8,  KEY_ShiftL, /* 0x02a */
-    KEY_Equal,  KEY_ShiftL, /* 0x02b */
-    KEY_Comma,  0,  /* 0x02c */
-    KEY_KP_Minus,   0,  /* 0x02d */
-    KEY_Period,0,   /* 0x02e */
-    KEY_Slash,  0,  /* 0x02f */
-    KEY_0,  0,  /* 0x030 */
-    KEY_1,  0,  /* 0x031 */
-    KEY_2,  0,  /* 0x032 */
-    KEY_3,  0,  /* 0x033 */
-    KEY_4,  0,  /* 0x034 */
-    KEY_5,  0,  /* 0x035 */
-    KEY_6,  0,  /* 0x036 */
-    KEY_7,  0,  /* 0x037 */
-    KEY_8,  0,  /* 0x038 */
-    KEY_9,  0,  /* 0x039 */
-    KEY_SemiColon,  KEY_ShiftL, /* 0x03a */
-    KEY_SemiColon,  0,  /* 0x03b */
-    KEY_Comma,  KEY_ShiftL, /* 0x03c */
-    KEY_Equal,  0,  /* 0x03d */
-    KEY_Period, KEY_ShiftL, /* 0x03e */
-    KEY_Slash,  KEY_ShiftL, /* 0x03f */
-    KEY_2,  KEY_ShiftL, /* 0x040 */
-    KEY_A,  KEY_ShiftL, /* 0x041 */
-    KEY_B,  KEY_ShiftL, /* 0x042 */
-    KEY_C,  KEY_ShiftL, /* 0x043 */
-    KEY_D,  KEY_ShiftL, /* 0x044 */
-    KEY_E,  KEY_ShiftL, /* 0x045 */
-    KEY_F,  KEY_ShiftL, /* 0x046 */
-    KEY_G,  KEY_ShiftL, /* 0x047 */
-    KEY_H,  KEY_ShiftL, /* 0x048 */
-    KEY_I,  KEY_ShiftL, /* 0x049 */
-    KEY_J,  KEY_ShiftL, /* 0x04a */
-    KEY_K,  KEY_ShiftL, /* 0x04b */
-    KEY_L,  KEY_ShiftL, /* 0x04c */
-    KEY_M,  KEY_ShiftL, /* 0x04d */
-    KEY_N,  KEY_ShiftL, /* 0x04e */
-    KEY_O,  KEY_ShiftL, /* 0x04f */
-    KEY_P,  KEY_ShiftL, /* 0x050 */
-    KEY_Q,  KEY_ShiftL, /* 0x051 */
-    KEY_R,  KEY_ShiftL, /* 0x052 */
-    KEY_S,  KEY_ShiftL, /* 0x053 */
-    KEY_T,  KEY_ShiftL, /* 0x054 */
-    KEY_U,  KEY_ShiftL, /* 0x055 */
-    KEY_V,  KEY_ShiftL, /* 0x056 */
-    KEY_W,  KEY_ShiftL, /* 0x057 */
-    KEY_X,  KEY_ShiftL, /* 0x058 */
-    KEY_Y,  KEY_ShiftL, /* 0x059 */
-    KEY_Z,  KEY_ShiftL, /* 0x05a */
-    KEY_LBrace, 0,  /* 0x05b */
-    KEY_BSlash, 0,  /* 0x05c */
-    KEY_RBrace, 0,  /* 0x05d */
-    KEY_6,  KEY_ShiftL, /* 0x05e */
-    KEY_Minus,  KEY_ShiftL, /* 0x05f */
-    KEY_Tilde,0,    /* 0x060 */
-    KEY_A,  0,  /* 0x061 */
-    KEY_B,  0,  /* 0x062 */
-    KEY_C,  0,  /* 0x063 */
-    KEY_D,  0,  /* 0x064 */
-    KEY_E,  0,  /* 0x065 */
-    KEY_F,  0,  /* 0x066 */
-    KEY_G,  0,  /* 0x067 */
-    KEY_H,  0,  /* 0x068 */
-    KEY_I,  0,  /* 0x069 */
-    KEY_J,  0,  /* 0x06a */
-    KEY_K,  0,  /* 0x06b */
-    KEY_L,  0,  /* 0x06c */
-    KEY_M,  0,  /* 0x06d */
-    KEY_N,  0,  /* 0x06e */
-    KEY_O,  0,  /* 0x06f */
-    KEY_P,  0,  /* 0x070 */
-    KEY_Q,  0,  /* 0x071 */
-    KEY_R,  0,  /* 0x072 */
-    KEY_S,  0,  /* 0x073 */
-    KEY_T,  0,  /* 0x074 */
-    KEY_U,  0,  /* 0x075 */
-    KEY_V,  0,  /* 0x076 */
-    KEY_W,  0,  /* 0x077 */
-    KEY_X,  0,  /* 0x078 */
-    KEY_Y,  0,  /* 0x079 */
-    KEY_Z,  0,  /* 0x07a */
-    KEY_LBrace, KEY_ShiftL, /* 0x07b */
-    KEY_BSlash, KEY_ShiftL, /* 0x07c */
-    KEY_RBrace, KEY_ShiftL, /* 0x07d */
-    KEY_Tilde,  KEY_ShiftL, /* 0x07e */
-    KEY_Delete, 0,  /* 0x07f */
-    0,   0,  /* 0x080 */
-    KEY_F1,  0,  /* 0x081 */
-    KEY_F2,  0,  /* 0x082 */
-    KEY_F3,  0,  /* 0x083 */
-    KEY_F4,  0,  /* 0x084 */
-    KEY_F5,  0,  /* 0x085 */
-    KEY_F6,  0,  /* 0x086 */
-    KEY_F7,  0,  /* 0x087 */
-    KEY_F8,  0,  /* 0x088 */
-    KEY_F9,  0,  /* 0x089 */
-    KEY_F10,  0,  /* 0x08a */
-    KEY_F11,  0,  /* 0x08b */
-    KEY_F12,  0,  /* 0x08c */
-    KEY_Home,  0,  /* 0x08d */
-    KEY_Up,  0,  /* 0x08e */
-    KEY_PgUp,  0,  /* 0x08f */
-    KEY_Print,  0,  /* 0x090 */
-    KEY_Left,  0,  /* 0x091 */
-    KEY_Right,  0,  /* 0x092 */
-    KEY_PgDown,  0,  /* 0x093 */
-    KEY_Insert,  0,  /* 0x094 */
-    0,  0,  /* 0x095 */
-    0,  0,  /* 0x096 */
-    0,  0,  /* 0x097 */
-    KEY_End,  0,  /* 0x098 */
-    KEY_Down,  0,  /* 0x099 */
-    0,  0,  /* 0x09a */
-    0,  0,  /* 0x09b */
-    0,  0,  /* 0x09c */
-    0,  0,  /* 0x09d */
-    0,  0,  /* 0x09e */
-    0,  0,  /* 0x09f */
-    0,  0,  /* 0x0a0 */
-    0,  0,  /* 0x0a1 */
-    0,  0,  /* 0x0a2 */
-    0,  0,  /* 0x0a3 */
-    0,  0,  /* 0x0a4 */
-    0,  0,  /* 0x0a5 */
-    0,  0,  /* 0x0a6 */
-    0,  0,  /* 0x0a7 */
-    0,  0,  /* 0x0a8 */
-    0,  0,  /* 0x0a9 */
-    0,  0,  /* 0x0aa */
-    0,  0,  /* 0x0ab */
-    0,  0,  /* 0x0ac */
-    0,  0,  /* 0x0ad */
-    0,  0,  /* 0x0ae */
-    0,  0,  /* 0x0af */
-    0,  0,  /* 0x0b0 */
-    0,  0,  /* 0x0b1 */
-    0,  0,  /* 0x0b2 */
-    0,  0,  /* 0x0b3 */
-    0,  0,  /* 0x0b4 */
-    0,  0,  /* 0x0b5 */
-    0,  0,  /* 0x0b6 */
-    0,  0,  /* 0x0b7 */
-    0,  0,  /* 0x0b8 */
-    0,  0,  /* 0x0b9 */
-    0,  0,  /* 0x0ba */
-    0,  0,  /* 0x0bb */
-    0,  0,  /* 0x0bc */
-    0,  0,  /* 0x0bd */
-    0,  0,  /* 0x0be */
-    0,  0,  /* 0x0bf */
-    0,  0,  /* 0x0c0 */
-    0,  0,  /* 0x0c1 */
-    0,  0,  /* 0x0c2 */
-    0,  0,  /* 0x0c3 */
-    0,  0,  /* 0x0c4 */
-    0,  0,  /* 0x0c5 */
-    0,  0,  /* 0x0c6 */
-    0,  0,  /* 0x0c7 */
-    0,  0,  /* 0x0c8 */
-    0,  0,  /* 0x0c9 */
-    0,  0,  /* 0x0ca */
-    0,  0,  /* 0x0cb */
-    0,  0,  /* 0x0cc */
-    0,  0,  /* 0x0cd */
-    0,  0,  /* 0x0ce */
-    0,  0,  /* 0x0cf */
-    0,  0,  /* 0x0d0 */
-    0,  0,  /* 0x0d1 */
-    0,  0,  /* 0x0d2 */
-    0,  0,  /* 0x0d3 */
-    0,  0,  /* 0x0d4 */
-    0,  0,  /* 0x0d5 */
-    0,  0,  /* 0x0d6 */
-    0,  0,  /* 0x0d7 */
-    0,  0,  /* 0x0d8 */
-    0,  0,  /* 0x0d9 */
-    0,  0,  /* 0x0da */
-    0,  0,  /* 0x0db */
-    0,  0,  /* 0x0dc */
-    0,  0,  /* 0x0dd */
-    0,  0,  /* 0x0de */
-    0,  0,  /* 0x0df */
-    0,  0,  /* 0x0e0 */
-    0,  0,  /* 0x0e1 */
-    0,  0,  /* 0x0e2 */
-    0,  0,  /* 0x0e3 */
-    0,  0,  /* 0x0e4 */
-    0,  0,  /* 0x0e5 */
-    0,  0,  /* 0x0e6 */
-    0,  0,  /* 0x0e7 */
-    0,  0,  /* 0x0e8 */
-    0,  0,  /* 0x0e9 */
-    0,  0,  /* 0x0ea */
-    0,  0,  /* 0x0eb */
-    0,  0,  /* 0x0ec */
-    0,  0,  /* 0x0ed */
-    0,  0,  /* 0x0ee */
-    0,  0,  /* 0x0ef */
-    0,  0,  /* 0x0f0 */
-    0,  0,  /* 0x0f1 */
-    0,  0,  /* 0x0f2 */
-    0,  0,  /* 0x0f3 */
-    0,  0,  /* 0x0f4 */
-    0,  0,  /* 0x0f5 */
-    0,  0,  /* 0x0f6 */
-    0,  0,  /* 0x0f7 */
-    0,  0,  /* 0x0f8 */
-    0,  0,  /* 0x0f9 */
-    0,  0,  /* 0x0fa */
-    0,  0,  /* 0x0fb */
-    0,  0,  /* 0x0fc */
-    0,  0,  /* 0x0fd */
-    0,  0,  /* 0x0fe */
-    0,  0,  /* 0x0ff */
-};
-
-/* from xwin/winkeymap.h */
-static KeySym map[NUM_KEYCODES*MAP_WIDTH]={
-    /* 0x00 */  NoSymbol,       NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x01 */  XK_Escape,      NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x02 */  XK_1,           XK_exclam,  NoSymbol,   NoSymbol,
-    /* 0x03 */  XK_2,           XK_at,      NoSymbol,   NoSymbol,
-    /* 0x04 */  XK_3,           XK_numbersign,  NoSymbol,   NoSymbol,
-    /* 0x05 */  XK_4,           XK_dollar,  NoSymbol,   NoSymbol,
-    /* 0x06 */  XK_5,           XK_percent, NoSymbol,   NoSymbol,
-    /* 0x07 */  XK_6,           XK_asciicircum, NoSymbol,   NoSymbol,
-    /* 0x08 */  XK_7,           XK_ampersand,   NoSymbol,   NoSymbol,
-    /* 0x09 */  XK_8,           XK_asterisk,    NoSymbol,   NoSymbol,
-    /* 0x0a */  XK_9,           XK_parenleft,   NoSymbol,   NoSymbol,
-    /* 0x0b */  XK_0,           XK_parenright,  NoSymbol,   NoSymbol,
-    /* 0x0c */  XK_minus,       XK_underscore,  NoSymbol,   NoSymbol,
-    /* 0x0d */  XK_equal,       XK_plus,    NoSymbol,   NoSymbol,
-    /* 0x0e */  XK_BackSpace,   NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x0f */  XK_Tab,         XK_ISO_Left_Tab,NoSymbol,   NoSymbol,
-    /* 0x10 */  XK_Q,           NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x11 */  XK_W,           NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x12 */  XK_E,           NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x13 */  XK_R,           NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x14 */  XK_T,           NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x15 */  XK_Y,           NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x16 */  XK_U,           NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x17 */  XK_I,           NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x18 */  XK_O,           NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x19 */  XK_P,           NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x1a */  XK_bracketleft, XK_braceleft,   NoSymbol,   NoSymbol,
-    /* 0x1b */  XK_bracketright,XK_braceright,  NoSymbol,   NoSymbol,
-    /* 0x1c */  XK_Return,      NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x1d */  XK_Control_L,   NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x1e */  XK_A,           NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x1f */  XK_S,           NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x20 */  XK_D,           NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x21 */  XK_F,           NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x22 */  XK_G,           NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x23 */  XK_H,           NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x24 */  XK_J,           NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x25 */  XK_K,           NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x26 */  XK_L,           NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x27 */  XK_semicolon,   XK_colon,   NoSymbol,   NoSymbol,
-    /* 0x28 */  XK_quoteright,  XK_quotedbl,    NoSymbol,   NoSymbol,
-    /* 0x29 */  XK_quoteleft,   XK_asciitilde,  NoSymbol,   NoSymbol,
-    /* 0x2a */  XK_Shift_L,     NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x2b */  XK_backslash,   XK_bar,     NoSymbol,   NoSymbol,
-    /* 0x2c */  XK_Z,           NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x2d */  XK_X,           NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x2e */  XK_C,           NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x2f */  XK_V,           NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x30 */  XK_B,           NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x31 */  XK_N,           NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x32 */  XK_M,           NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x33 */  XK_comma,       XK_less,    NoSymbol,   NoSymbol,
-    /* 0x34 */  XK_period,      XK_greater, NoSymbol,   NoSymbol,
-    /* 0x35 */  XK_slash,       XK_question,    NoSymbol,   NoSymbol,
-    /* 0x36 */  XK_Shift_R,     NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x37 */  XK_KP_Multiply, NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x38 */  XK_Alt_L,   XK_Meta_L,  NoSymbol,   NoSymbol,
-    /* 0x39 */  XK_space,       NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x3a */  XK_Caps_Lock,   NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x3b */  XK_F1,          NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x3c */  XK_F2,          NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x3d */  XK_F3,          NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x3e */  XK_F4,          NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x3f */  XK_F5,          NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x40 */  XK_F6,          NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x41 */  XK_F7,          NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x42 */  XK_F8,          NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x43 */  XK_F9,          NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x44 */  XK_F10,         NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x45 */  XK_Num_Lock,    NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x46 */  XK_Scroll_Lock, NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x47 */  XK_KP_Home, XK_KP_7,    NoSymbol,   NoSymbol,
-    /* 0x48 */  XK_KP_Up,   XK_KP_8,    NoSymbol,   NoSymbol,
-    /* 0x49 */  XK_KP_Prior,    XK_KP_9,    NoSymbol,   NoSymbol,
-    /* 0x4a */  XK_KP_Subtract, NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x4b */  XK_KP_Left, XK_KP_4,    NoSymbol,   NoSymbol,
-    /* 0x4c */  XK_KP_Begin,    XK_KP_5,    NoSymbol,   NoSymbol,
-    /* 0x4d */  XK_KP_Right,    XK_KP_6,    NoSymbol,   NoSymbol,
-    /* 0x4e */  XK_KP_Add,      NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x4f */  XK_KP_End,  XK_KP_1,    NoSymbol,   NoSymbol,
-    /* 0x50 */  XK_KP_Down, XK_KP_2,    NoSymbol,   NoSymbol,
-    /* 0x51 */  XK_KP_Next, XK_KP_3,    NoSymbol,   NoSymbol,
-    /* 0x52 */  XK_KP_Insert,   XK_KP_0,    NoSymbol,   NoSymbol,
-    /* 0x53 */  XK_KP_Delete,   XK_KP_Decimal,  NoSymbol,   NoSymbol,
-    /* 0x54 */  XK_Sys_Req, NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x55 */  NoSymbol,   NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x56 */  XK_less,    XK_greater, NoSymbol,   NoSymbol,
-    /* 0x57 */  XK_F11,     NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x58 */  XK_F12,     NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x59 */  XK_Home,    NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x5a */  XK_Up,      NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x5b */  XK_Prior,   NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x5c */  XK_Left,    NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x5d */  XK_Begin,   NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x5e */  XK_Right,   NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x5f */  XK_End,     NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x60 */  XK_Down,    NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x61 */  XK_Next,    NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x62 */  XK_Insert,  NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x63 */  XK_Delete,  NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x64 */  XK_KP_Enter,    NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x65 */  XK_Control_R,   NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x66 */  XK_Pause,   NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x67 */  XK_Print,   NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x68 */  XK_KP_Divide,   NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x69 */  XK_Alt_R,   XK_Meta_R,  NoSymbol,   NoSymbol,
-    /* 0x6a */  XK_Break,   NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x6b */  XK_Meta_L,  NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x6c */  XK_Meta_R,  NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x6d */  XK_Menu,    NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x6e */  XK_F13,     NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x6f */  XK_F14,     NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x70 */  XK_F15,     NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x71 */  XK_F16,     NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x72 */  XK_F17,     NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x73 */  XK_backslash,   XK_underscore,  NoSymbol,   NoSymbol,
-    /* 0x74 */  NoSymbol,   NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x75 */  NoSymbol,   NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x76 */  NoSymbol,   NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x77 */  NoSymbol,   NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x78 */  NoSymbol,   NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x79 */  XK_Henkan,  XK_Mode_switch, NoSymbol,   NoSymbol,
-    /* 0x7a */  NoSymbol,   NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x7b */  XK_Muhenkan,    NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x7c */  NoSymbol,   NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x7d */  XK_backslash,   XK_bar,     NoSymbol,   NoSymbol,
-    /* 0x7e */  NoSymbol,   NoSymbol,   NoSymbol,   NoSymbol,
-    /* 0x7f */  NoSymbol,   NoSymbol,   NoSymbol,   NoSymbol,
-};
--- a/src/meson.build
+++ /dev/null
@@ -1,40 +1,0 @@
-srcs = [
-    'x9dev.c',
-    'keyboard.c',
-    'mouse.c',
-    'screen.c',
-    'x9dev.h',
-    'keymap.h',
-    '../../../mi/miinitext.c',
-]
-
-cc_args = [
-    '-Wno-missing-braces',
-]
-
-x9dev_server = executable(
-    'x9dev',
-    srcs,
-    include_directories: [
-        inc,
-        include_directories('../libdraw'),
-    ],
-    dependencies: [
-        common_dep,
-        dependency('xi', version: '>= 1.2.99.1'),
-    ],
-    link_with: [
-        libdraw,
-        libxserver_mi,
-        libxserver_main,
-        libxserver_fb,
-        libxserver,
-        libxserver_xkb_stubs,
-        libxserver_xi_stubs,
-        libxserver_glx,
-        libglxvnd,
-        libxserver_miext_shadow,
-    ],
-    install: true,
-    c_args: cc_args,
-)
\ No newline at end of file
--- a/src/mouse.c
+++ /dev/null
@@ -1,145 +1,0 @@
-/*
- * Copyright (c) 2008 Federico G. Benavento <benavento@gmail.com>
- * 
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- * 
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "x9dev.h"
-
-extern DeviceIntPtr x9devMouse;
-int oldx, oldy, oldbut;
-
-#define e    ev.u.u
-#define ek    ev.u.keyButtonPointer
-static void
-x9devSendMouseEvent(int x, int y, int b, int t)
-{
-    xEvent ev;
-
-    memset(&ev, 0, sizeof(xEvent));
-    e.type = t;
-    e.detail = b;
-    ek.rootX = x;
-    ek.rootY = y;
-    ek.time = GetTimeInMillis();
-    mieqEnqueue(x9devMouse, (InternalEvent *)&ev);
-}
-#undef ek
-#undef e
-
-static int
-x9devMouseRead(int *x, int *y, int *b)
-{
-    int n;
-    char buf[1+4*12];
-
-    if((n = read(x9di.mfd, buf, 1 + 4 * 12)) <= 0)
-        return 0;
-
-    if (n != 1 + 4 * 12)
-        FatalError("Bad mouse event");
-
-    if (buf[0] == 'r') {
-        x9devResize();
-        return 0;
-    }
-
-    *x = atoi(buf + 1 + 0 * 12) - screen->r.min.x;
-    *y = atoi(buf + 1 + 1 * 12) - screen->r.min.y;
-    *b = atoi(buf + 1 + 2 * 12);
-
-    return 1;
-}
-
-
-int  
-x9devMouseHandle(void)
-{
-    int x, y, b, but, t;
-
-    if (!x9devMouseRead(&x, &y, &but))
-        return 0;
-
-    t = b = 0;
-    if (x != oldx || y != oldy) {
-        t = MotionNotify;
-        oldx = x, oldy = y;
-    }
-    if (but != oldbut) {
-        b = oldbut ^ but;
-        t = ButtonPress;
-        if (oldbut & b)
-            t = ButtonRelease;
-        if (b == 4)
-            b = 3;
-        if (but & (8 | 16)) {
-            if (b & 8)
-                b = 4;
-            else
-                b = 5;
-            x9devSendMouseEvent(x, y, b, ButtonPress);
-            x9devSendMouseEvent(x, y, b, ButtonRelease);
-            return 1;
-        }
-    }
-    x9devSendMouseEvent(x, y, b, t);
-    oldbut = but;
-
-    return 1;
-}
-
-int  
-x9devMouseProc(DeviceIntPtr pDevice, int what)
-{
-    static unsigned char    map[] = {0, 1, 2, 3, 4, 5};
-    DevicePtr pDev = (DevicePtr)pDevice;
-    Atom btn_labels[3] = {0};
-    Atom axes_labels[2] = {0};
-
-    /* Init our globals */
-    oldx = oldy = oldbut = 0;
-
-    switch (what) {
-    case DEVICE_INIT:
-        btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
-        btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
-        btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
-
-        axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
-        axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
-        InitPointerDeviceStruct(pDev, map, 3, btn_labels,
-            (PtrCtrlProcPtr)NoopDDA, GetMotionHistorySize(), 2, axes_labels);
-        break;
-
-    case DEVICE_ON:
-        pDev->on = TRUE;
-        break;
-
-    case DEVICE_CLOSE:
-    case DEVICE_OFF:
-        pDev->on = FALSE;
-        break;
-    }
-    return Success;
-}
\ No newline at end of file
--- a/src/screen.c
+++ /dev/null
@@ -1,187 +1,0 @@
-/*
- * Copyright (c) 2008 Federico G. Benavento <benavento@gmail.com>
- * 
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- * 
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "x9dev.h"
-
-static void
-x9devRefreshScreen(int x1, int y1, int x2, int y2)
-{ 
-    Rectangle r;
-    uchar *p;
-    int n;
-
-    p = (uchar *)x9di.fb+(y1*x9di.width+x1)*(x9di.depth/8);
-    r = rectaddpt(Rect(x1, y1, x2, y2), screen->r.min);
-    if (Dx(r) == x9di.width) {
-        if (loadimage(screen, r, p, x9di.bpl * Dy(r)) < 0)
-            FatalError("can't load image");
-        goto End;
-    }
-    n = Dx(r)*(x9di.depth/8);
-    y2 += screen->r.min.y;
-       while(r.min.y < y2) {
-        r.max.y = r.min.y+1;
-        if (loadimage(screen, r, p, n) < 0)
-            FatalError("can't load image");
-        p += x9di.bpl;
-        r.min.y++;
-    }
-End:
-    flushimage(_display, 1);
-}
-
-
-void
-x9devResize(void)
-{
-    if (getwindow(_display, Refnone) < 0)
-        FatalError("can't reattach to window");
-
-    draw(screen, screen->r, _display->white, NULL, ZP);
-    x9devRefreshScreen(0, 0, x9di.width, x9di.height);
-}
-
-static void
-x9devWakeupHandler(ScreenPtr scr, int result)
-{
-    if (result <= 0)
-        return;
-
-    while (x9devMouseHandle())
-        ;
-    while (x9devKeybdHandle())
-        ;
-}
-
-static void
-x9devShadowUpdate(ScreenPtr pScreen, shadowBufPtr pBuf)
-{
-    BoxPtr pbox;
-
-    pbox = REGION_EXTENTS(pScreen, &pBuf->pDamage);
-    x9devRefreshScreen(pbox->x1, pbox->y1, pbox->x2, pbox->y2);
-}
-
-
-static void
-x9devCursorLimits(DeviceIntPtr dptr, ScreenPtr spr, CursorPtr cpr, BoxPtr hot, BoxPtr topleft)
-{
-    *topleft = *hot;
-}
-
-
-/* callback dance... */
-static CreateScreenResourcesProcPtr x9devCreateResourcesPtr;
-
-static Bool
-x9devCreateResources(ScreenPtr pScreen)
-{
-    Bool ret = 0;
-
-    pScreen->CreateScreenResources = x9devCreateResourcesPtr;
-    if (pScreen->CreateScreenResources)
-        ret = pScreen->CreateScreenResources(pScreen);
-
-    x9devCreateResourcesPtr = pScreen->CreateScreenResources;
-    pScreen->CreateScreenResources = x9devCreateResourcesPtr;
-    if (ret == FALSE)
-        return FALSE;
-
-    shadowRemove(pScreen, pScreen->GetScreenPixmap(pScreen));
-    if (!shadowAdd(pScreen, pScreen->GetScreenPixmap(pScreen), x9devShadowUpdate, NULL, SHADOW_ROTATE_0, 0))
-        return FALSE;
-
-    return ret;
-}
-
-Bool
-x9devScreenInit(ScreenPtr pScreen, int argc, char *argv[])
-{
-    int v, i;
-    unsigned long   r, g, b;
-    static int  first = 1;
-
-    if (first) {
-        x9devInfoInit();
-        first = 0;
-    }
-
-    for (i = 0; i < NUMFORMATS; i++)
-        fbSetVisualTypes(formats[i].depth, 0, 8);
-
-    switch (x9di.depth) {
-    case 16:
-        r = 0xF800, g = 0x07E0, b = 0x001F;
-        v = 1 << TrueColor;
-        break;
-    case 24:
-    case 32:
-        r = 0xFF0000, g = 0x00FF00, b = 0x0000FF;
-        v = 1 << TrueColor;
-        break;
-    default:
-        r = g = b = 0;
-        v = 1 << PseudoColor;
-    }
-    if (!fbSetVisualTypesAndMasks(x9di.depth, v, 8, r, g, b))
-        return FALSE;
-
-    if (!fbScreenInit(pScreen, x9di.fb, x9di.width, x9di.height,
-        x9di.dpi, x9di.dpi, x9di.width, x9di.depth))
-        return FALSE;
-
-    pScreen->mmWidth = x9di.width * 25.4 / x9di.dpi;
-    pScreen->mmHeight = x9di.height * 25.4 / x9di.dpi;
-
-    /* cursor */
-    pScreen->ConstrainCursor = x9devConstrainCursor;
-    pScreen->CursorLimits = x9devCursorLimits;
-    pScreen->DisplayCursor = x9devDisplayCursor;
-    pScreen->RealizeCursor = x9devRealizeCursor;
-    pScreen->UnrealizeCursor = x9devUnrealizeCursor;
-    pScreen->RecolorCursor = x9devRecolorCursor;
-    pScreen->SetCursorPosition = x9devSetCursorPosition;
-
-    pScreen->SaveScreen = x9devSaveScreen;
-    pScreen->WakeupHandler = x9devWakeupHandler;
-
-#ifdef RENDER
-    if (!fbPictureInit(pScreen, 0, 0))
-        return FALSE;
-#endif
-
-   if (!shadowSetup(pScreen))
-        return FALSE;
-
-    x9devCreateResourcesPtr = pScreen->CreateScreenResources;
-    pScreen->CreateScreenResources = x9devCreateResources;
-
-    if (!fbCreateDefColormap(pScreen))
-        return FALSE;
-
-    return TRUE;
-}
--- a/src/x9dev.c
+++ /dev/null
@@ -1,171 +1,0 @@
-/*
- * Copyright (c) 2008 Federico G. Benavento <benavento@gmail.com>
- * 
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- * 
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <errno.h>
-#include "x9dev.h"
-
-extern x9devInfo x9di;
-char *root = "/";
-int debug = 0;
-
-void
-x9devInfoInit(void)
-{
-	int fd;
-    char path[256]; /* Plan9 Maxpath */
-
-    if(initdraw(NULL, root, "x9dev") < 0)
-        FatalError("can't open display");
-
-    x9di.depth = screen->depth;
-    x9di.width = Dx(screen->r);
-    x9di.width -= x9di.width&(screen->depth/8);
-    x9di.dpi = 100;
-    x9di.bpl = bytesperline(Rect(0, 0, x9di.width, x9di.height), x9di.depth);
-    x9di.fb = malloc(x9di.bpl * x9di.height);
-
-    sprintf(path, "%s/mouse", _display->devdir);
-	x9di.mfd = open(path, O_RDWR|O_NONBLOCK);
-
-    sprintf(path, "%s/cons", _display->devdir);
-	x9di.kfd = open(path, O_RDONLY|O_NONBLOCK);
-
-    sprintf(path, "%s/consctl", _display->devdir);
-	fd = open(path, O_WRONLY);
-	write(fd, "rawon", 5);
-	close(fd);
-}
-
-void
-InitOutput(ScreenInfo *si, int argc, char *argv[])
-{
-    int i;
-
-    si->imageByteOrder = IMAGE_BYTE_ORDER;
-    si->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
-    si->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
-    si->bitmapBitOrder = BITMAP_BIT_ORDER;
-    si->numPixmapFormats = NUMFORMATS;
-    for (i = 0; i < NUMFORMATS; i++)
-        si->formats[i] = formats[i];
-    if (AddScreen(x9devScreenInit, argc, argv) < 0)
-        FatalError("InitOutput: can't addscreen");
-}
-
-void
-InitInput(int argc, char *argv[])
-{
-    Atom xiclass;
-    
-    x9devMouse = AddInputDevice(serverClient, x9devMouseProc, TRUE);
-    x9devKeybd = AddInputDevice(serverClient, x9devKeybdProc, TRUE);
-    xiclass = MakeAtom(XI_MOUSE, sizeof(XI_MOUSE) - 1, TRUE);
-    AssignTypeAndName(x9devMouse, xiclass, "x9dev mouse");
-    xiclass = MakeAtom(XI_KEYBOARD, sizeof(XI_KEYBOARD) - 1, TRUE);
-    AssignTypeAndName(x9devKeybd, xiclass, "x9dev keyboard");
-
-    mieqInit();
-}
-
-void
-ddxUseMsg(void)
-{
-    ErrorF("\nx9srv Option Usage:\n");
-    ErrorF("-D enable debug\n");
-}
-
-int
-ddxProcessArgument(int argc, char **argv, int i)
-{
-    if (!strcmp(argv[i], "-D")){
-        debug++;
-        return 1;
-    } else if (!strcmp(argv[i], "-p")){
-        if (argc <= i){
-            sprintf(root, "%s", argv[i+1]);
-            root = argv[i+1];
-        }
-    }
-
-    return 0;
-}
-
-void
-ddxGiveUp(enum ExitCode error)
-{
-}
-
-
-void
-AbortDDX(enum ExitCode error)
-{
-    ;
-}
-
-/* we may need to do some weird stuff here in the future */
-#if defined(DDXBEFORERESET)
-void
-ddxBeforeReset(void)
-{
-}
-#endif
-
-
-void
-DDXRingBell(int volume, int pitch, int duration)
-{
-}
-
-void
-OsVendorInit(void)
-{
-
-}
-
-void
-OsVendorFatalError(const char *f, va_list args)
-{
-
-}
-
-void
-CloseInput(void)
-{
-    mieqFini();
-}
-
-Bool
-LegalModifier(unsigned int k, DeviceIntPtr pDev)
-{
-    return x9checkmod(k, pDev);
-}
-
-void
-ProcessInputEvents(void)
-{
-    mieqProcessInputEvents();
-}
--- a/src/x9dev.h
+++ /dev/null
@@ -1,103 +1,0 @@
-/*
- * Copyright (c) 2008 Federico G. Benavento <benavento@gmail.com>
- * 
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- * 
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#ifndef _X9DEV_H_
-#define _X9DEV_H_
-
-#define NEED_EVENTS
-#include <X11/Xproto.h>
-#include <X11/Xos.h>
-#include <X11/Xpoll.h>
-#define XK_TECHNICA
-#define XK_PUBLISHING
-#include <X11/keysym.h>
-#include <X11/keysymdef.h>
-#define PSZ 8
-#include "fb.h" /* fbSetVisualTypes */
-#include "colormapst.h"
-#include "dix.h"
-#include "exevents.h"
-#include "extinit.h"
-#include "gcstruct.h"
-#include "glx_extinit.h"
-#include "input.h"
-#include "micmap.h"
-#include "mipointer.h"
-#include "miline.h"
-#include "scrnintstr.h"
-#include "servermd.h"
-#include "shadow.h"
-#include "xkbsrv.h"
-#include "xserver-properties.h"
-#include "mi.h" /* miEnqueue mieqProcessInputEvents */
-#include "draw.h"
-
-#define Msize 8192
-#define NUMFORMATS (sizeof(formats)/sizeof((formats)[0]))
-
-/* NOOPs for now */
-#define x9devSaveScreen (void *) NoopDDA
-#define x9devConstrainCursor    (void *) NoopDDA
-#define x9devDisplayCursor  (void *) NoopDDA
-#define x9devRealizeCursor  (void *) NoopDDA
-#define x9devUnrealizeCursor    (void *) NoopDDA
-#define x9devRecolorCursor  (void *) NoopDDA
-#define x9devSetCursorPosition  (void *) NoopDDA
-
-
-typedef struct x9devInfo x9devInfo;
-struct x9devInfo
-{
-    char    *fb;
-    int     depth;
-    int     width;
-    int     height;
-    int     dpi;
-    int     bpl;
-    int     mfd;
-    int     kfd;
-};
-
-static PixmapFormatRec formats[] = {
-    { 1,    1,  BITMAP_SCANLINE_PAD },
-    { 8,    8,  BITMAP_SCANLINE_PAD },
-    { 16,   16,     BITMAP_SCANLINE_PAD },
-    { 24,   24,     BITMAP_SCANLINE_PAD },
-    { 32,   32,     BITMAP_SCANLINE_PAD }
-};
-
-DeviceIntPtr x9devMouse;
-DeviceIntPtr x9devKeybd;
-x9devInfo x9di;
-
-/* Callbacks, etc */
-Bool x9checkmod(unsigned int, DeviceIntPtr);
-Bool x9devScreenInit(ScreenPtr, int, char **);
-void x9devInfoInit(void);
-void x9devResize(void);
-int x9devKeybdProc(DeviceIntPtr, int);
-int x9devMouseProc(DeviceIntPtr, int);
-int x9devMouseHandle(void);
-int x9devKeybdHandle(void);
-
-#endif
--- /dev/null
+++ b/x9dev.c
@@ -1,0 +1,171 @@
+/*
+ * Copyright (c) 2008 Federico G. Benavento <benavento@gmail.com>
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <errno.h>
+#include "x9dev.h"
+
+extern x9devInfo x9di;
+char *root = "/";
+int debug = 0;
+
+void
+x9devInfoInit(void)
+{
+    int fd;
+    char path[256]; /* Plan9 Maxpath */
+
+    if(initdraw(NULL, root, "x9dev") < 0)
+        FatalError("can't open display");
+
+    x9di.depth = screen->depth;
+    x9di.width = Dx(screen->r);
+    x9di.width -= x9di.width&(screen->depth/8);
+    x9di.dpi = 100;
+    x9di.bpl = bytesperline(Rect(0, 0, x9di.width, x9di.height), x9di.depth);
+    x9di.fb = malloc(x9di.bpl * x9di.height);
+
+    sprintf(path, "%s/mouse", _display->devdir);
+	x9di.mfd = open(path, O_RDWR|O_NONBLOCK);
+
+    sprintf(path, "%s/cons", _display->devdir);
+	x9di.kfd = open(path, O_RDONLY|O_NONBLOCK);
+
+    sprintf(path, "%s/consctl", _display->devdir);
+	fd = open(path, O_WRONLY);
+	write(fd, "rawon", 5);
+	close(fd);
+}
+
+void
+InitOutput(ScreenInfo *si, int argc, char *argv[])
+{
+    int i;
+
+    si->imageByteOrder = IMAGE_BYTE_ORDER;
+    si->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
+    si->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
+    si->bitmapBitOrder = BITMAP_BIT_ORDER;
+    si->numPixmapFormats = NUMFORMATS;
+    for (i = 0; i < NUMFORMATS; i++)
+        si->formats[i] = formats[i];
+    if (AddScreen(x9devScreenInit, argc, argv) < 0)
+        FatalError("InitOutput: can't addscreen");
+}
+
+void
+InitInput(int argc, char *argv[])
+{
+    Atom xiclass;
+    
+    x9devMouse = AddInputDevice(serverClient, x9devMouseProc, TRUE);
+    x9devKeybd = AddInputDevice(serverClient, x9devKeybdProc, TRUE);
+    xiclass = MakeAtom(XI_MOUSE, sizeof(XI_MOUSE) - 1, TRUE);
+    AssignTypeAndName(x9devMouse, xiclass, "x9dev mouse");
+    xiclass = MakeAtom(XI_KEYBOARD, sizeof(XI_KEYBOARD) - 1, TRUE);
+    AssignTypeAndName(x9devKeybd, xiclass, "x9dev keyboard");
+
+    mieqInit();
+}
+
+void
+ddxUseMsg(void)
+{
+    ErrorF("\nx9srv Option Usage:\n");
+    ErrorF("-D enable debug\n");
+}
+
+int
+ddxProcessArgument(int argc, char **argv, int i)
+{
+    if (!strcmp(argv[i], "-D")){
+        debug++;
+        return 1;
+    } else if (!strcmp(argv[i], "-p")){
+        if (argc <= i){
+            sprintf(root, "%s", argv[i+1]);
+            root = argv[i+1];
+        }
+    }
+
+    return 0;
+}
+
+void
+ddxGiveUp(enum ExitCode error)
+{
+}
+
+
+void
+AbortDDX(enum ExitCode error)
+{
+    ;
+}
+
+/* we may need to do some weird stuff here in the future */
+#if defined(DDXBEFORERESET)
+void
+ddxBeforeReset(void)
+{
+}
+#endif
+
+
+void
+DDXRingBell(int volume, int pitch, int duration)
+{
+}
+
+void
+OsVendorInit(void)
+{
+
+}
+
+void
+OsVendorFatalError(const char *f, va_list args)
+{
+
+}
+
+void
+CloseInput(void)
+{
+    mieqFini();
+}
+
+Bool
+LegalModifier(unsigned int k, DeviceIntPtr pDev)
+{
+    return x9checkmod(k, pDev);
+}
+
+void
+ProcessInputEvents(void)
+{
+    mieqProcessInputEvents();
+}
--- /dev/null
+++ b/x9dev.h
@@ -1,0 +1,103 @@
+/*
+ * Copyright (c) 2008 Federico G. Benavento <benavento@gmail.com>
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef _X9DEV_H_
+#define _X9DEV_H_
+
+#define NEED_EVENTS
+#include <X11/Xproto.h>
+#include <X11/Xos.h>
+#include <X11/Xpoll.h>
+#define XK_TECHNICA
+#define XK_PUBLISHING
+#include <X11/keysym.h>
+#include <X11/keysymdef.h>
+#define PSZ 8
+#include "fb.h" /* fbSetVisualTypes */
+#include "colormapst.h"
+#include "dix.h"
+#include "exevents.h"
+#include "extinit.h"
+#include "gcstruct.h"
+#include "glx_extinit.h"
+#include "input.h"
+#include "micmap.h"
+#include "mipointer.h"
+#include "miline.h"
+#include "scrnintstr.h"
+#include "servermd.h"
+#include "shadow.h"
+#include "xkbsrv.h"
+#include "xserver-properties.h"
+#include "mi.h" /* miEnqueue mieqProcessInputEvents */
+#include "draw.h"
+
+#define Msize 8192
+#define NUMFORMATS (sizeof(formats)/sizeof((formats)[0]))
+
+/* NOOPs for now */
+#define x9devSaveScreen (void *) NoopDDA
+#define x9devConstrainCursor    (void *) NoopDDA
+#define x9devDisplayCursor  (void *) NoopDDA
+#define x9devRealizeCursor  (void *) NoopDDA
+#define x9devUnrealizeCursor    (void *) NoopDDA
+#define x9devRecolorCursor  (void *) NoopDDA
+#define x9devSetCursorPosition  (void *) NoopDDA
+
+
+typedef struct x9devInfo x9devInfo;
+struct x9devInfo
+{
+    char    *fb;
+    int     depth;
+    int     width;
+    int     height;
+    int     dpi;
+    int     bpl;
+    int     mfd;
+    int     kfd;
+};
+
+static PixmapFormatRec formats[] = {
+    { 1,    1,  BITMAP_SCANLINE_PAD },
+    { 8,    8,  BITMAP_SCANLINE_PAD },
+    { 16,   16,     BITMAP_SCANLINE_PAD },
+    { 24,   24,     BITMAP_SCANLINE_PAD },
+    { 32,   32,     BITMAP_SCANLINE_PAD }
+};
+
+DeviceIntPtr x9devMouse;
+DeviceIntPtr x9devKeybd;
+x9devInfo x9di;
+
+/* Callbacks, etc */
+Bool x9checkmod(unsigned int, DeviceIntPtr);
+Bool x9devScreenInit(ScreenPtr, int, char **);
+void x9devInfoInit(void);
+void x9devResize(void);
+int x9devKeybdProc(DeviceIntPtr, int);
+int x9devMouseProc(DeviceIntPtr, int);
+int x9devMouseHandle(void);
+int x9devKeybdHandle(void);
+
+#endif