code: drawterm

Download patch

ref: a08fb2286d2d908bb8088f46a74b0460d4f7779f
parent: 5dc9cad6a69e06717ebe294735579a189bb010e0
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sat Feb 27 20:13:17 EST 2016

update libdraw code to 9front version, cleanup x11 code

--- a/gui-win32/Makefile
+++ b/gui-win32/Makefile
@@ -3,10 +3,6 @@
 LIB=libgui.a
 
 OFILES=\
-	alloc.$O\
-	cload.$O\
-	draw.$O\
-	load.$O\
 	screen.$O\
 	r16.$O
 
--- a/gui-win32/alloc.c
+++ /dev/null
@@ -1,23 +1,0 @@
-#include <u.h>
-#include <libc.h>
-#include <draw.h>
-#include <memdraw.h>
-
-Memimage*
-allocmemimage(Rectangle r, ulong chan)
-{
-	return _allocmemimage(r, chan);
-}
-
-void
-freememimage(Memimage *i)
-{
-	_freememimage(i);
-}
-
-void
-memfillcolor(Memimage *i, ulong val)
-{
-	_memfillcolor(i, val);
-}
-
--- a/gui-win32/cload.c
+++ /dev/null
@@ -1,10 +1,0 @@
-#include <u.h>
-#include <libc.h>
-#include <draw.h>
-#include <memdraw.h>
-
-int
-cloadmemimage(Memimage *i, Rectangle r, uchar *data, int ndata)
-{
-	return _cloadmemimage(i, r, data, ndata);
-}
--- a/gui-win32/draw.c
+++ /dev/null
@@ -1,22 +1,0 @@
-#include <u.h>
-#include <libc.h>
-#include <draw.h>
-#include <memdraw.h>
-
-void
-memimagedraw(Memimage *dst, Rectangle r, Memimage *src, Point sp, Memimage *mask, Point mp, int op)
-{
-	_memimagedraw(_memimagedrawsetup(dst, r, src, sp, mask, mp, op));
-}
-
-ulong
-pixelbits(Memimage *m, Point p)
-{
-	return _pixelbits(m, p);
-}
-
-void
-memimageinit(void)
-{
-	_memimageinit();
-}
--- a/gui-win32/load.c
+++ /dev/null
@@ -1,10 +1,0 @@
-#include <u.h>
-#include <libc.h>
-#include <draw.h>
-#include <memdraw.h>
-
-int
-loadmemimage(Memimage *i, Rectangle r, uchar *data, int ndata)
-{
-	return _loadmemimage(i, r, data, ndata);
-}
--- a/gui-win32/screen.c
+++ b/gui-win32/screen.c
@@ -88,7 +88,7 @@
 }
 
 uchar*
-attachscreen(Rectangle *r, ulong *chan, int *depth, int *width, int *softscreen, void **X)
+attachscreen(Rectangle *r, ulong *chan, int *depth, int *width, int *softscreen)
 {
 	*r = gscreen->r;
 	*chan = gscreen->chan;
--- a/gui-x11/x11.c
+++ b/gui-x11/x11.c
@@ -37,42 +37,16 @@
 /* perfect approximation to NTSC = .299r+.587g+.114b when 0 ≤ r,g,b < 256 */
 #define RGB2K(r,g,b)	((156763*(r)+307758*(g)+59769*(b))>>19)
 
-enum
-{
-	PMundef	= ~0		/* undefined pixmap id */
-};
-
-/*
- * Structure pointed to by X field of Memimage
- */
-typedef struct Xmem Xmem;
-struct Xmem
-{
-	int	pmid;	/* pixmap id for screen ldepth instance */
-	XImage *xi;	/* local image if we currenty have the data */
-	int	dirty;
-	Rectangle dirtyr;
-	Rectangle r;
-	uintptr pc;	/* who wrote into xi */
-};
-
-static int	xgcfillcolor;
-static int	xgcfillcolor0;
-static int	xgcsimplecolor0;
-static int	xgcsimplepm0;
-
 static	XDisplay*	xdisplay;	/* used holding draw lock */
-static int				xtblbit;
-static int 			plan9tox11[256]; /* Values for mapping between */
-static int 			x11toplan9[256]; /* X11 and Plan 9 */
-static	GC		xgcfill, xgccopy, xgcsimplesrc, xgczero, xgcreplsrc;
-static	GC		xgcfill0, xgccopy0, xgcsimplesrc0, xgczero0, xgcreplsrc0;
+static int		xtblbit;
+static int 		plan9tox11[256]; /* Values for mapping between */
+static int 		x11toplan9[256]; /* X11 and Plan 9 */
+static	GC		xgccopy;
 static	ulong	xscreenchan;
 static	Drawable	xscreenid;
+static	XImage*		xscreenimage;
 static	Visual		*xvis;
 
-static int xdraw(Memdrawparam*);
-
 #define glenda_width 48
 #define glenda_height 48
 static unsigned short glenda_bits[] = {
@@ -94,117 +68,15 @@
    0xffff, 0x8807, 0xffe0, 0xffff, 0x003f, 0xfff0, 0xffff, 0x1fff, 0xfffe
 };
 
-/*
- * Synchronize images between X bitmaps and in-memory bitmaps.
- */
-static void
-addrect(Rectangle *rp, Rectangle r)
-{
-	if(rp->min.x >= rp->max.x)
-		*rp = r;
-	else
-		combinerect(rp, r);
-}
-
-static XImage*
-getXdata(Memimage *m, Rectangle r)
-{
-	uchar *p;
-	int x, y;
-	Xmem *xm;
-	Point xdelta, delta;
-	Point tp;
-
- 	xm = m->X;
- 	if(xm == nil)
- 		return nil;
- 
-	assert(xm != nil && xm->xi != nil);
-	
- 	if(xm->dirty == 0)
- 		return xm->xi;
- 		
- 	r = xm->dirtyr;
-	if(Dx(r)==0 || Dy(r)==0)
-		return xm->xi;
-
-	delta = subpt(r.min, m->r.min);
-	tp = xm->r.min;	/* avoid unaligned access on digital unix */
-	xdelta = subpt(r.min, tp);
-	
-	XGetSubImage(xdisplay, xm->pmid, delta.x, delta.y, Dx(r), Dy(r),
-		AllPlanes, ZPixmap, xm->xi, xdelta.x, xdelta.y);
-		
-	if(xtblbit && m->chan == CMAP8)
-		for(y=r.min.y; y<r.max.y; y++)
-			for(x=r.min.x, p=byteaddr(m, Pt(x,y)); x<r.max.x; x++, p++)
-				*p = x11toplan9[*p];
-				
-	xm->dirty = 0;
-	xm->dirtyr = Rect(0,0,0,0);
-	return xm->xi;
-}
-
-static void
-putXdata(Memimage *m, Rectangle r)
-{
-	Xmem *xm;
-	XImage *xi;
-	GC g;
-	Point xdelta, delta;
-	Point tp;
-	int x, y;
-	uchar *p;
-
-	xm = m->X;
-	if(xm == nil)
-		return;
-		
-	assert(xm != nil);
-	assert(xm->xi != nil);
-
-	xi = xm->xi;
-
-	g = (m->chan == GREY1) ? xgccopy0 : xgccopy;
-
-	delta = subpt(r.min, m->r.min);
-	tp = xm->r.min;	/* avoid unaligned access on digital unix */
-	xdelta = subpt(r.min, tp);
-	
-	if(xtblbit && m->chan == CMAP8)
-		for(y=r.min.y; y<r.max.y; y++)
-			for(x=r.min.x, p=byteaddr(m, Pt(x,y)); x<r.max.x; x++, p++)
-				*p = plan9tox11[*p];
-	
-	XPutImage(xdisplay, xm->pmid, g, xi, xdelta.x, xdelta.y, delta.x, delta.y, Dx(r), Dy(r));
-
-	if(xtblbit && m->chan == CMAP8)
-		for(y=r.min.y; y<r.max.y; y++)
-			for(x=r.min.x, p=byteaddr(m, Pt(x,y)); x<r.max.x; x++, p++)
-				*p = x11toplan9[*p];
-}
-
-static void
-dirtyXdata(Memimage *m, Rectangle r)
-{
-	Xmem *xm;
-	
-	if((xm = m->X) != nil){
-		xm->dirty = 1;
-		addrect(&xm->dirtyr, r);
-	}
-}
-
 Memimage*
-xallocmemimage(Rectangle r, ulong chan, int pmid)
+xallocmemimage(Rectangle r, ulong chan, int pmid, XImage **X)
 {
 	Memimage *m;
-	Xmem *xm;
 	XImage *xi;
 	int offset;
 	int d;
-	
-	m = _allocmemimage(r, chan);
+
+	m = allocmemimage(r, chan);
 	if(m == nil)
 		return nil;
 	if(chan != GREY1 && chan != xscreenchan)
@@ -211,16 +83,10 @@
 		return m;
 
 	d = m->depth;
-	xm = mallocz(sizeof(Xmem), 1);
-	if(pmid != PMundef)
-		xm->pmid = pmid;
-	else
-		xm->pmid = XCreatePixmap(xdisplay, xscreenid, Dx(r), Dy(r), (d==32) ? 24 : d);
-		
-	if(m->depth == 24)
+	if(d == 24)
 		offset = r.min.x&(4-1);
 	else
-		offset = r.min.x&(31/m->depth);
+		offset = r.min.x&(31/d);
 	r.min.x -= offset;
 	
 	assert(wordsperline(r, m->depth) <= m->width);
@@ -229,14 +95,10 @@
 		(char*)m->data->bdata, Dx(r), Dy(r), 32, m->width*sizeof(ulong));
 	
 	if(xi == nil){
-		_freememimage(m);
+		freememimage(m);
 		return nil;
 	}
 
-	xm->xi = xi;
-	xm->pc = getcallerpc(&r);
-	xm->r = r;
-	
 	/*
 	 * Set the parameters of the XImage so its memory looks exactly like a
 	 * Memimage, so we can call _memimagedraw on the same data.  All frame
@@ -247,259 +109,15 @@
 	xi->byte_order = LSBFirst;
 	xi->bitmap_bit_order = MSBFirst;
 	xi->bitmap_pad = 32;
-	xm->r = Rect(0,0,0,0);
 	XInitImage(xi);
 	XFlush(xdisplay);
 
-	m->X = xm;
+	*X = xi;
+
 	return m;
 }
 
-void
-xfillcolor(Memimage *m, Rectangle r, ulong v)
-{
-	GC gc;
-	Xmem *dxm;
-
-	dxm = m->X;
-	assert(dxm != nil);
-	r = rectsubpt(r, m->r.min);
-		
-	if(m->chan == GREY1){
-		gc = xgcfill0;
-		if(xgcfillcolor0 != v){
-			XSetForeground(xdisplay, gc, v);
-			xgcfillcolor0 = v;
-		}
-	}else{
-		if(m->chan == CMAP8 && xtblbit)
-			v = plan9tox11[v];
-				
-		gc = xgcfill;
-		if(xgcfillcolor != v){
-			XSetForeground(xdisplay, gc, v);
-			xgcfillcolor = v;
-		}
-	}
-	XFillRectangle(xdisplay, dxm->pmid, gc, r.min.x, r.min.y, Dx(r), Dy(r));
-}
-
 /*
- * Replacements for libmemdraw routines.
- * (They've been underscored.)
- */
-Memimage*
-allocmemimage(Rectangle r, ulong chan)
-{
-	return xallocmemimage(r, chan, PMundef);
-}
-
-void
-freememimage(Memimage *m)
-{
-	Xmem *xm;
-	
-	if(m == nil)
-		return;
-		
-	if(m->data->ref == 1){
-		if((xm = m->X) != nil){
-			if(xm->xi){
-				xm->xi->data = nil;
-				XFree(xm->xi);
-			}
-			XFreePixmap(xdisplay, xm->pmid);
-			free(xm);
-			m->X = nil;
-		}
-	}
-	_freememimage(m);
-}
-
-void
-memfillcolor(Memimage *m, ulong val)
-{
-	_memfillcolor(m, val);
-	if(m->X){
-		if((val & 0xFF) == 0xFF)
-			xfillcolor(m, m->r, _rgbatoimg(m, val));
-		else
-			putXdata(m, m->r);
-	}
-}
-
-int
-loadmemimage(Memimage *i, Rectangle r, uchar *data, int ndata)
-{
-	int n;
-
-	n = _loadmemimage(i, r, data, ndata);
-	if(n > 0 && i->X)
-		putXdata(i, r);
-	return n;
-}
-
-int
-cloadmemimage(Memimage *i, Rectangle r, uchar *data, int ndata)
-{
-	int n;
-
-	n = _cloadmemimage(i, r, data, ndata);
-	if(n > 0 && i->X)
-		putXdata(i, r);
-	return n;
-}
-
-ulong
-pixelbits(Memimage *m, Point p)
-{
-	if(m->X)
-		getXdata(m, Rect(p.x, p.y, p.x+1, p.y+1));
-	return _pixelbits(m, p);
-}
-
-void
-memimageinit(void)
-{
-	static int didinit = 0;
-	
-	if(didinit)
-		return;
-
-	didinit = 1;
-	_memimageinit();
-	
-	xfillcolor(memblack, memblack->r, 0);
-	xfillcolor(memwhite, memwhite->r, 1);
-}
-
-void
-memimagedraw(Memimage *dst, Rectangle r, Memimage *src, Point sp, Memimage *mask, Point mp, int op)
-{
-	Memdrawparam *par;
-	
-	if((par = _memimagedrawsetup(dst, r, src, sp, mask, mp, op)) == nil)
-		return;
-	_memimagedraw(par);
-	if(!xdraw(par))
-		putXdata(dst, par->r);
-}
-
-static int
-xdraw(Memdrawparam *par)
-{
-	return 0;
-}
-
-static int
-xdraw_broken(Memdrawparam *par)
-{
-	int dy, dx;
-	unsigned m;
-	Memimage *src, *dst, *mask;
-	Xmem *dxm, *sxm, *mxm;
-	GC gc;
-	Rectangle r, sr, mr;
-	ulong sdval;
-
-	dx = Dx(par->r);
-	dy = Dy(par->r);
-	src = par->src;
-	dst = par->dst;
-	mask = par->mask;
-	r = par->r;
-	sr = par->sr;
-	mr = par->mr;
-	sdval = par->sdval;
-
-	/*
-	 * drawterm was distributed for years with
-	 * "return 0;" right here.
-	 * maybe we should give up on all this?
-	 */
-
-	if((dxm = dst->X) == nil)
-		return 0;
-
-	/*
-	 * If we have an opaque mask and source is one opaque pixel we can convert to the
-	 * destination format and just XFillRectangle.
-	 */
-	m = Simplesrc|Simplemask|Fullmask;
-	if((par->state&m)==m){
-		xfillcolor(dst, r, sdval);
-		dirtyXdata(dst, par->r);
-		return 1;
-	}
-
-	/*
-	 * If no source alpha, an opaque mask, we can just copy the
-	 * source onto the destination.  If the channels are the same and
-	 * the source is not replicated, XCopyArea suffices.
-	 */
-	m = Simplemask|Fullmask;
-	if((par->state&(m|Replsrc))==m && src->chan == dst->chan && src->X){
-		sxm = src->X;
-		r = rectsubpt(r, dst->r.min);		
-		sr = rectsubpt(sr, src->r.min);
-		if(dst->chan == GREY1)
-			gc = xgccopy0;
-		else
-			gc = xgccopy;
-		XCopyArea(xdisplay, sxm->pmid, dxm->pmid, gc, 
-			sr.min.x, sr.min.y, dx, dy, r.min.x, r.min.y);
-		dirtyXdata(dst, par->r);
-		return 1;
-	}
-	
-	/*
-	 * If no source alpha, a 1-bit mask, and a simple source
-	 * we can just copy through the mask onto the destination.
-	 */
-	if(dst->X && mask->X && !(mask->flags&Frepl)
-	&& mask->chan == GREY1 && (par->state&Simplesrc)){
-		Point p;
-
-		mxm = mask->X;
-		r = rectsubpt(r, dst->r.min);		
-		mr = rectsubpt(mr, mask->r.min);
-		p = subpt(r.min, mr.min);
-		if(dst->chan == GREY1){
-			gc = xgcsimplesrc0;
-			if(xgcsimplecolor0 != sdval){
-				XSetForeground(xdisplay, gc, sdval);
-				xgcsimplecolor0 = sdval;
-			}
-			if(xgcsimplepm0 != mxm->pmid){
-				XSetStipple(xdisplay, gc, mxm->pmid);
-				xgcsimplepm0 = mxm->pmid;
-			}
-		}else{
-		/* somehow this doesn't work on rob's mac 
-			gc = xgcsimplesrc;
-			if(dst->chan == CMAP8 && xtblbit)
-				sdval = plan9tox11[sdval];
-				
-			if(xgcsimplecolor != sdval){
-				XSetForeground(xdisplay, gc, sdval);
-				xgcsimplecolor = sdval;
-			}
-			if(xgcsimplepm != mxm->pmid){
-				XSetStipple(xdisplay, gc, mxm->pmid);
-				xgcsimplepm = mxm->pmid;
-			}
-		*/
-			return 0;
-		}
-		XSetTSOrigin(xdisplay, gc, p.x, p.y);
-		XFillRectangle(xdisplay, dxm->pmid, gc, r.min.x, r.min.y, dx, dy);
-		dirtyXdata(dst, par->r);
-		return 1;
-	}
-	return 0;
-}
-
-/*
  * X11 window management and kernel hooks.
  * Oh, how I loathe this code!
  */
@@ -507,7 +125,7 @@
 static XColor			map[256];	/* Plan 9 colormap array */
 static XColor			map7[128];	/* Plan 9 colormap array */
 static uchar			map7to8[128][2];
-static Colormap		xcmap;		/* Default shared colormap  */
+static Colormap			xcmap;		/* Default shared colormap  */
 
 extern int mousequeue;
 
@@ -533,20 +151,34 @@
 static	int		xscreendepth;
 static	XDisplay*	xkmcon;	/* used only in xproc */
 static	XDisplay*	xsnarfcon;	/* used holding clip.lk */
-static	ulong		xblack;
-static	ulong		xwhite;
 
 static	int	putsnarf, assertsnarf;
 
-	Memimage *gscreen;
-	Screeninfo screen;
+Memimage *gscreen;
+Screeninfo screen;
 
 void
 flushmemscreen(Rectangle r)
 {
+	int x, y;
+	uchar *p;
+
 	assert(!drawcanqlock());
 	if(r.min.x >= r.max.x || r.min.y >= r.max.y)
 		return;
+
+	if(xtblbit && gscreen->chan == CMAP8)
+		for(y=r.min.y; y<r.max.y; y++)
+			for(x=r.min.x, p=byteaddr(gscreen, Pt(x,y)); x<r.max.x; x++, p++)
+				*p = plan9tox11[*p];
+	
+	XPutImage(xdisplay, xscreenid, xgccopy, xscreenimage, r.min.x, r.min.y, r.min.x, r.min.y, Dx(r), Dy(r));
+
+	if(xtblbit && gscreen->chan == CMAP8)
+		for(y=r.min.y; y<r.max.y; y++)
+			for(x=r.min.x, p=byteaddr(gscreen, Pt(x,y)); x<r.max.x; x++, p++)
+				*p = x11toplan9[*p];
+
 	XCopyArea(xdisplay, xscreenid, xdrawable, xgccopy, r.min.x, r.min.y, Dx(r), Dy(r), r.min.x, r.min.y);
 	XFlush(xdisplay);
 }
@@ -567,14 +199,12 @@
 }
 
 uchar*
-attachscreen(Rectangle *r, ulong *chan, int *depth,
-	int *width, int *softscreen, void **X)
+attachscreen(Rectangle *r, ulong *chan, int *depth, int *width, int *softscreen)
 {
 	*r = gscreen->r;
 	*chan = gscreen->chan;
 	*depth = gscreen->depth;
 	*width = gscreen->width;
-	*X = gscreen->X;
 	*softscreen = 1;
 
 	return gscreen->data->bdata;
@@ -708,7 +338,7 @@
 xinitscreen(void)
 {
 	Memimage *gscreen;
-	int i, xsize, ysize, pmid;
+	int i, xsize, ysize;
 	char *argv[2];
 	char *disp_val;
 	Window rootwin;
@@ -868,32 +498,9 @@
 	XFlush(xdisplay);
 
 	xscreenid = XCreatePixmap(xdisplay, xdrawable, Dx(r), Dy(r), xscreendepth);
-	gscreen = xallocmemimage(r, xscreenchan, xscreenid);
-	
-	xgcfill = creategc(xscreenid);
-	XSetFillStyle(xdisplay, xgcfill, FillSolid);
+	gscreen = xallocmemimage(r, xscreenchan, xscreenid, &xscreenimage);
 	xgccopy = creategc(xscreenid);
-	xgcsimplesrc = creategc(xscreenid);
-	XSetFillStyle(xdisplay, xgcsimplesrc, FillStippled);
-	xgczero = creategc(xscreenid);
-	xgcreplsrc = creategc(xscreenid);
-	XSetFillStyle(xdisplay, xgcreplsrc, FillTiled);
 
-	pmid = XCreatePixmap(xdisplay, xdrawable, 1, 1, 1);
-	xgcfill0 = creategc(pmid);
-	XSetForeground(xdisplay, xgcfill0, 0);
-	XSetFillStyle(xdisplay, xgcfill0, FillSolid);
-	xgccopy0 = creategc(pmid);
-	xgcsimplesrc0 = creategc(pmid);
-	XSetFillStyle(xdisplay, xgcsimplesrc0, FillStippled);
-	xgczero0 = creategc(pmid);
-	xgcreplsrc0 = creategc(pmid);
-	XSetFillStyle(xdisplay, xgcreplsrc0, FillTiled);
-	XFreePixmap(xdisplay, pmid);
-
-	XSetForeground(xdisplay, xgccopy, plan9tox11[0]);
-	XFillRectangle(xdisplay, xscreenid, xgccopy, 0, 0, xsize, ysize);
-
 	xkmcon = XOpenDisplay(NULL);
 	if(xkmcon == 0){
 		disp_val = getenv("DISPLAY");
@@ -917,8 +524,6 @@
 	text = XInternAtom(xkmcon, "TEXT", False);
 	compoundtext = XInternAtom(xkmcon, "COMPOUND_TEXT", False);
 
-	xblack = screen->black_pixel;
-	xwhite = screen->white_pixel;
 	return gscreen;
 }
 
--- a/include/draw.h
+++ b/include/draw.h
@@ -1,8 +1,3 @@
-#ifdef PLAN9
-#pragma src "/sys/src/libdraw"
-#pragma lib "libdraw.a"
-#endif
-
 typedef struct	Cachefont Cachefont;
 typedef struct	Cacheinfo Cacheinfo;
 typedef struct	Cachesubf Cachesubf;
@@ -17,10 +12,6 @@
 typedef struct	Screen Screen;
 typedef struct	Subfont Subfont;
 
-#ifdef VARARGCK
-#pragma varargck	type	"R"	Rectangle
-#pragma varargck	type	"P"	Point
-#endif
 extern	int	Rfmt(Fmt*);
 extern	int	Pfmt(Fmt*);
 
@@ -140,11 +131,12 @@
 	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),
-	BGR24	= CHAN3(CBlue, 8, CGreen, 8, CRed, 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),
-	XBGR32  = CHAN4(CIgnore, 8, CBlue, 8, CGreen, 8, CRed, 8),
+	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);
@@ -175,7 +167,7 @@
 
 struct Display
 {
-	QLock	qlock;
+	QLock		qlock;
 	int		locking;	/*program is using lockdisplay */
 	int		dirno;
 	int		fd;
@@ -194,13 +186,13 @@
 	Image		*transparent;
 	Image		*image;
 	uchar		*buf;
-	int			bufsize;
+	int		bufsize;
 	uchar		*bufp;
 	Font		*defaultfont;
 	Subfont		*defaultsubfont;
 	Image		*windows;
 	Image		*screenimage;
-	int			_isnewdisplay;
+	int		_isnewdisplay;
 };
 
 struct Image
@@ -210,7 +202,7 @@
 	Rectangle	r;		/* rectangle in data area, local coords */
 	Rectangle 	clipr;		/* clipping region */
 	int		depth;		/* number of bits per pixel */
-	ulong	chan;
+	ulong		chan;
 	int		repl;		/* flag: data replicates to tile clipr */
 	Screen		*screen;	/* 0 if not a window */
 	Image		*next;	/* next in list of windows */
@@ -397,6 +389,7 @@
 extern int		cmap2rgba(int);
 extern void		icossin(int, int*, int*);
 extern void		icossin2(int, int, int*, int*);
+extern int		badrect(Rectangle);
 
 /*
  * Graphics
@@ -480,7 +473,6 @@
 extern Subfont*	getdefont(Display*);
 extern void		lockdisplay(Display*);
 extern void	unlockdisplay(Display*);
-extern int		drawlsetrefresh(ulong, int, void*, void*);
 
 /*
  * Predefined 
@@ -495,7 +487,7 @@
  */
 extern	Display	*display;
 extern	Font		*font;
-/* extern	Image	*screen; */
+// extern	Image	*screen;
 extern	Screen	*_screen;
 extern	int	_cursorfd;
 extern	int	_drawdebug;	/* set to 1 to see errors from flushimage */
@@ -518,6 +510,6 @@
 extern	int	_compblocksize(Rectangle, int);
 
 /* XXX backwards helps; should go */
-extern	int		log2[];
+// extern	int		log2[];	/* was used by libmemlayer/line.c */
 extern	ulong	drawld2chan[];
 extern	void		drawsetdebug(int);
--- a/include/memdraw.h
+++ b/include/memdraw.h
@@ -1,8 +1,3 @@
-#ifdef PLAN9
-#pragma	src	"/sys/src/libmemdraw"
-#pragma	lib	"libmemdraw.a"
-#endif
-
 typedef struct	Memimage Memimage;
 typedef struct	Memdata Memdata;
 typedef struct	Memsubfont Memsubfont;
@@ -54,8 +49,6 @@
 	int		shift[NChan];
 	int		mask[NChan];
 	int		nbits[NChan];
-
-	void	*X;
 };
 
 struct Memcmap
@@ -119,26 +112,20 @@
  */
 
 extern Memimage*	allocmemimage(Rectangle, ulong);
-extern Memimage*	_allocmemimage(Rectangle, ulong);
-extern Memimage*	allocmemimaged(Rectangle, ulong, Memdata*, void*);
+extern Memimage*	allocmemimaged(Rectangle, ulong, Memdata*);
 extern Memimage*	readmemimage(int);
 extern Memimage*	creadmemimage(int);
 extern int	writememimage(int, Memimage*);
 extern void	freememimage(Memimage*);
-extern void	_freememimage(Memimage*);
-extern int		_loadmemimage(Memimage*, Rectangle, uchar*, int);
-extern int		_cloadmemimage(Memimage*, Rectangle, uchar*, int);
-extern int		_unloadmemimage(Memimage*, Rectangle, uchar*, int);
 extern int		loadmemimage(Memimage*, Rectangle, uchar*, int);
 extern int		cloadmemimage(Memimage*, Rectangle, uchar*, int);
 extern int		unloadmemimage(Memimage*, Rectangle, uchar*, int);
 extern ulong*	wordaddr(Memimage*, Point);
 extern uchar*	byteaddr(Memimage*, Point);
+extern int		drawclipnorepl(Memimage*, Rectangle*, Memimage*, Point*, Memimage*, Point*, Rectangle*, Rectangle*);
 extern int		drawclip(Memimage*, Rectangle*, Memimage*, Point*, Memimage*, Point*, Rectangle*, Rectangle*);
 extern void	memfillcolor(Memimage*, ulong);
-extern void	_memfillcolor(Memimage*, ulong);
 extern int		memsetchan(Memimage*, ulong);
-extern ulong	_rgbatoimg(Memimage*, ulong);
 
 /*
  * Graphics
@@ -148,8 +135,6 @@
 extern void	mempoly(Memimage*, Point*, int, int, int, int, Memimage*, Point, int);
 extern void	memfillpoly(Memimage*, Point*, int, int, Memimage*, Point, int);
 extern void	_memfillpolysc(Memimage*, Point*, int, int, Memimage*, Point, int, int, int, int);
-extern Memdrawparam*	_memimagedrawsetup(Memimage*, Rectangle, Memimage*, Point, Memimage*, Point, int);
-extern void	_memimagedraw(Memdrawparam*);
 extern void	memimagedraw(Memimage*, Rectangle, Memimage*, Point, Memimage*, Point, int);
 extern int	hwdraw(Memdrawparam*);
 extern void	memimageline(Memimage*, Point, Point, int, int, int, Memimage*, Point, int);
@@ -160,8 +145,7 @@
 extern Rectangle	memlinebbox(Point, Point, int, int, int);
 extern int	memlineendsize(int);
 extern void	_memmkcmap(void);
-extern void	_memimageinit(void);
-extern void	memimageinit(void);
+extern int	memimageinit(void);
 
 /*
  * Subfont management
@@ -193,18 +177,4 @@
 extern int		iprint(char*, ...);
 extern int		drawdebug;
 
-/*
- * doprint interface: numbconv bit strings
- */
-#ifdef VARARGCK
-#pragma varargck argpos iprint 1
-#pragma varargck type "llb" vlong
-#pragma varargck type "llb" uvlong
-#pragma varargck type "lb" long
-#pragma varargck type "lb" ulong
-#pragma varargck type "b" int
-#pragma varargck type "b" uint
-#endif
-
-extern ulong _pixelbits(Memimage*,Point);
-extern ulong pixelbits(Memimage*, Point);
+extern ulong	pixelbits(Memimage*, Point);
--- a/kern/devdraw.c
+++ b/kern/devdraw.c
@@ -921,7 +921,6 @@
 {
 	int width, depth;
 	ulong chan;
-	void *X;
 	Rectangle r;
 
 	if(screenimage != nil)
@@ -928,12 +927,12 @@
 		return 1;
 
 	screendata.base = nil;
-	screendata.bdata = attachscreen(&r, &chan, &depth, &width, &sdraw.softscreen, &X);
-	if(screendata.bdata == nil && X == nil)
+	screendata.bdata = attachscreen(&r, &chan, &depth, &width, &sdraw.softscreen);
+	if(screendata.bdata == nil)
 		return 0;
 	screendata.ref = 1;
 
-	screenimage = allocmemimaged(r, chan, &screendata, X);
+	screenimage = allocmemimaged(r, chan, &screendata);
 	if(screenimage == nil){
 		/* RSC: BUG: detach screen */
 		return 0;
--- a/kern/devkbd.c
+++ b/kern/devkbd.c
@@ -117,6 +117,7 @@
 	USED(n);
 	USED(off);
 	error(Eperm);
+	return -1;		/* never reached */
 }
 
 Dev kbddevtab = {
--- a/kern/screen.h
+++ b/kern/screen.h
@@ -55,7 +55,7 @@
 void	mouseset(Point);
 void	drawflushr(Rectangle);
 void	flushmemscreen(Rectangle);
-uchar *attachscreen(Rectangle*, ulong*, int*, int*, int*, void**);
+uchar *attachscreen(Rectangle*, ulong*, int*, int*, int*);
 
 void	drawqlock(void);
 void	drawqunlock(void);
--- a/libdraw/Makefile
+++ b/libdraw/Makefile
@@ -5,10 +5,12 @@
 OFILES=\
 	alloc.$O\
 	arith.$O\
+	badrect.$O\
 	bytesperline.$O\
 	chan.$O\
 	defont.$O\
 	drawrepl.$O\
+	fmt.$O\
 	icossin.$O\
 	icossin2.$O\
 	rectclip.$O\
--- a/libdraw/alloc.c
+++ b/libdraw/alloc.c
@@ -3,13 +3,18 @@
 #include <draw.h>
 
 Image*
-allocimage(Display *d, Rectangle r, ulong chan, int repl, ulong val)
+allocimage(Display *d, Rectangle r, ulong chan, int repl, ulong col)
 {
-	return _allocimage(nil, d, r, chan, repl, val, 0, 0);
+	Image *i;
+
+	i = _allocimage(nil, d, r, chan, repl, col, 0, 0);
+	if(i != nil)
+		setmalloctag(i, getcallerpc(&d));
+	return i;
 }
 
 Image*
-_allocimage(Image *ai, Display *d, Rectangle r, ulong chan, int repl, ulong val, int screenid, int refresh)
+_allocimage(Image *ai, Display *d, Rectangle r, ulong chan, int repl, ulong col, int screenid, int refresh)
 {
 	uchar *a;
 	char *err;
@@ -18,9 +23,13 @@
 	int id;
 	int depth;
 
-	err = 0;
-	i = 0;
+	err = nil;
+	i = nil;
 
+	if(badrect(r)){
+		werrstr("bad rectangle");
+		return nil;
+	}
 	if(chan == 0){
 		werrstr("bad channel descriptor");
 		return nil;
@@ -30,18 +39,18 @@
 	if(depth == 0){
 		err = "bad channel descriptor";
     Error:
-		if(err)
+		if(err != nil)
 			werrstr("allocimage: %s", err);
 		else
 			werrstr("allocimage: %r");
 		free(i);
-		return 0;
+		return nil;
 	}
 
 	/* flush pending data so we don't get error allocating the image */
 	flushimage(d, 0);
 	a = bufimage(d, 1+4+4+1+4+1+4*4+4*4+4);
-	if(a == 0)
+	if(a == nil)
 		goto Error;
 	d->imageid++;
 	id = d->imageid;
@@ -64,17 +73,17 @@
 	BPLONG(a+35, clipr.min.y);
 	BPLONG(a+39, clipr.max.x);
 	BPLONG(a+43, clipr.max.y);
-	BPLONG(a+47, val);
+	BPLONG(a+47, col);
 	if(flushimage(d, 0) < 0)
 		goto Error;
 
-	if(ai)
+	if(ai != nil)
 		i = ai;
 	else{
 		i = malloc(sizeof(Image));
 		if(i == nil){
 			a = bufimage(d, 1+4);
-			if(a){
+			if(a != nil){
 				a[0] = 'f';
 				BPLONG(a+1, id);
 				flushimage(d, 0);
@@ -89,8 +98,8 @@
 	i->r = r;
 	i->clipr = clipr;
 	i->repl = repl;
-	i->screen = 0;
-	i->next = 0;
+	i->screen = nil;
+	i->next = nil;
 	return i;
 }
 
@@ -103,25 +112,24 @@
 	int id, n;
 	ulong chan;
 
-	err = 0;
-	i = 0;
+	err = nil;
+	i = nil;
 
 	n = strlen(name);
 	if(n >= 256){
 		err = "name too long";
     Error:
-		if(err)
+		if(err != nil)
 			werrstr("namedimage: %s", err);
 		else
 			werrstr("namedimage: %r");
-		if(i)
-			free(i);
-		return 0;
+		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 == 0)
+	if(a == nil)
 		goto Error;
 	d->imageid++;
 	id = d->imageid;
@@ -140,7 +148,7 @@
 	if(i == nil){
 	Error1:
 		a = bufimage(d, 1+4);
-		if(a){
+		if(a != nil){
 			a[0] = 'f';
 			BPLONG(a+1, id);
 			flushimage(d, 0);
@@ -164,8 +172,8 @@
 	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 = 0;
-	i->next = 0;
+	i->screen = nil;
+	i->next = nil;
 	return i;
 }
 
@@ -177,7 +185,7 @@
 
 	n = strlen(name);
 	a = bufimage(i->display, 1+4+1+1+n);
-	if(a == 0)
+	if(a == nil)
 		return 0;
 	a[0] = 'N';
 	BPLONG(a+1, i->id);
@@ -196,23 +204,16 @@
 	Display *d;
 	Image *w;
 
-	if(i == 0)
+	if(i == nil || i->display == nil)
 		return 0;
-	/* make sure no refresh events occur on this if we block in the write */
 	d = i->display;
-	/* flush pending data so we don't get error deleting the image */
 	flushimage(d, 0);
-	a = bufimage(d, 1+4);
-	if(a == 0)
-		return -1;
-	a[0] = 'f';
-	BPLONG(a+1, i->id);
-	if(i->screen){
+	if(i->screen != nil){
 		w = d->windows;
 		if(w == i)
 			d->windows = i->next;
 		else
-			while(w){
+			while(w != nil){
 				if(w->next == i){
 					w->next = i->next;
 					break;
@@ -220,7 +221,12 @@
 				w = w->next;
 			}
 	}
-	if(flushimage(d, i->screen!=0) < 0)
+	a = bufimage(d, 1+4);
+	if(a == nil)
+		return -1;
+	a[0] = 'f';
+	BPLONG(a+1, i->id);
+	if(flushimage(d, i->screen!=nil) < 0)
 		return -1;
 
 	return 0;
--- a/libdraw/arith.c
+++ b/libdraw/arith.c
@@ -159,8 +159,7 @@
 		r1->max.y = r2.max.y;
 }
 
-ulong
-drawld2chan[] = {
+ulong drawld2chan[] = {
 	GREY1,
 	GREY2,
 	GREY4,
@@ -167,7 +166,11 @@
 	CMAP8,
 };
 
-int log2[] = { -1, 0, 1, -1, 2, -1, -1, -1, 3, -1, -1, -1, -1, -1, -1, -1, 4, -1, -1, -1, -1, -1, -1, -1, 4 /* BUG */, -1, -1, -1, -1, -1, -1, -1, 5 };
+/*
+ * was used by libmemlayer/line.c; made static, instead of deleting it,
+ * to avoid updating many binaries on sources.
+ */
+static int log2[] = { -1, 0, 1, -1, 2, -1, -1, -1, 3, -1, -1, -1, -1, -1, -1, -1, 4, -1, -1, -1, -1, -1, -1, -1, 4 /* BUG */, -1, -1, -1, -1, -1, -1, -1, 5 };
 
 ulong
 setalpha(ulong color, uchar alpha)
@@ -186,21 +189,3 @@
 
 Point	ZP;
 Rectangle ZR;
-int
-Rfmt(Fmt *f)
-{
-	Rectangle r;
-
-	r = va_arg(f->args, Rectangle);
-	return fmtprint(f, "%P %P", r.min, r.max);
-}
-
-int
-Pfmt(Fmt *f)
-{
-	Point p;
-
-	p = va_arg(f->args, Point);
-	return fmtprint(f, "[%d %d]", p.x, p.y);
-}
-
--- /dev/null
+++ b/libdraw/badrect.c
@@ -1,0 +1,22 @@
+#include <u.h>
+#include <libc.h>
+#include <draw.h>
+
+/*
+ * check for zero, negative size or insanely huge rectangle.
+ */
+int
+badrect(Rectangle r)
+{
+	int x, y;
+	uint 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/chan.c
+++ b/libdraw/chan.c
@@ -41,9 +41,10 @@
 {
 	char *p, *q;
 	ulong c;
-	int t, n;
+	int t, n, d;
 
 	c = 0;
+	d = 0;
 	p=s;
 	while(*p && xisspace(*p))
 		p++;
@@ -55,9 +56,12 @@
 		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;
 }
 
--- a/libdraw/defont.c
+++ b/libdraw/defont.c
@@ -3,7 +3,7 @@
 #include <draw.h>
 
 /*
- * lucm/latin1.9, in uncompressed form
+ * vga/vga00, in uncompressed form
  */
 uchar
 defontdata[] =
@@ -10,377 +10,363 @@
 {
 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,0x33,0x30,0x34,0x20,
-0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x31,0x35,0x20,0x00,0x00,0x00,0x00,
+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,0xff,0xff,0xff,0xff,
-0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
-0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
-0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,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,0x30,0x06,0x06,0x03,0x42,0x40,0x00,0x00,0x00,0x18,0x03,0x03,
-0x02,0x43,0x00,0x60,0x60,0x48,0x00,0x0d,0x0c,0x01,0x81,0x80,0xd0,0x90,0x00,0x00,
-0x18,0x01,0x81,0x81,0x40,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 0x00,0x00,0x00,0x00,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,0x7f,0x9c,0x1c,
-0x0e,0x07,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x70,
-0x38,0x1c,0x0e,0x04,0x81,0xc1,0xc0,0x70,0x00,0x1c,0x1c,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,0xaa,0x80,0xc0,0x63,0xe3,
-0xf1,0xf8,0xfe,0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xfc,0x7f,0xff,0xff,0x1f,0x8f,
-0xc7,0xe3,0xf1,0xfb,0x7e,0x3e,0x3f,0x8f,0xff,0xe3,0xe3,0xff,0xff,0xff,0xff,0xff,
+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,0x0c,0x18,0x09,0x05,0x82,0x40,0xc0,0x00,0x00,0x06,0x0c,0x04,
-0x82,0x40,0xc1,0x80,0x90,0x48,0x00,0x16,0x03,0x06,0x02,0x41,0x60,0x90,0x00,0x00,
-0x06,0x06,0x02,0x41,0x41,0x80,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,0x3e,0x7f,0xa0,0x10,
-0x08,0x04,0x02,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x90,0x48,
-0x24,0x12,0x09,0x06,0x82,0x01,0x00,0x90,0x00,0x20,0x10,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x04,0x80,0x00,0x40,0x00,0x00,0x38,0x06,0x18,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,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,0x07,0xc6,0x01,0xf0,0x00,0x00,0x0c,0x00,0x18,0x00,0x00,0x30,0x00,0x3c,
-0x00,0x60,0x06,0x01,0x8c,0x07,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xe0,0xc3,0xc0,0x01,0x54,0x9c,0xc0,0x5f,0xef,
-0xf7,0xfb,0xfd,0xbf,0xff,0xff,0xff,0xff,0xff,0xff,0xfb,0x7f,0xff,0xff,0x6f,0xb7,
-0xdb,0xed,0xf6,0xf9,0x7d,0xfe,0xff,0x6f,0xff,0xdf,0xef,0xff,0xff,0xff,0xff,0xff,
-0xff,0x00,0x01,0x00,0x00,0x00,0x00,0x30,0x00,0x14,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x20,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,0x78,0x30,0x06,0x06,0x06,0x82,0x80,0xc0,0x00,
-0x00,0x18,0x03,0x03,0x02,0x41,0x80,0x30,0x30,0x24,0x76,0x0d,0x0c,0x00,0xc0,0xc0,
-0xd0,0x50,0x00,0x00,0x18,0x01,0x81,0x81,0x40,0x30,0x00,0x28,0x0f,0x7f,0xbc,0x1c,
-0x0e,0x07,0x03,0xc0,0x10,0x70,0x24,0x10,0x09,0x07,0x03,0x80,0xe0,0x70,0x90,0x48,
-0x24,0x12,0x09,0x05,0x81,0x81,0xc0,0x80,0x70,0x18,0x1c,0x07,0x01,0xc1,0xc0,0x90,
-0x00,0x0c,0x04,0x84,0x83,0xe1,0xc0,0xe0,0x38,0x0c,0x0c,0x02,0x00,0x00,0x00,0x00,
-0x00,0x06,0x1c,0x06,0x0f,0x87,0xc0,0x63,0xf8,0x78,0xfe,0x3e,0x0e,0x00,0x00,0x00,
-0x00,0x00,0x00,0x7c,0x1c,0x0c,0x1f,0x03,0xc7,0xc3,0xf1,0xf8,0x3c,0x63,0x3f,0x0f,
-0x8c,0x66,0x06,0x19,0x84,0x78,0x7e,0x1e,0x1f,0x07,0xcf,0xf3,0x1b,0x0d,0x86,0x63,
-0x61,0x9f,0xc6,0x06,0x00,0x30,0x00,0x00,0x10,0x00,0x18,0x00,0x00,0x30,0x00,0x60,
-0x00,0x60,0x06,0x01,0x8c,0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,
-0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0xc0,0x60,0x00,0xaa,0xb6,0xc0,0x43,0xe3,
-0xf1,0xf8,0xfc,0x3f,0xef,0x8f,0xdb,0xef,0xf6,0xf8,0xfb,0xff,0x1f,0x8f,0x6f,0xb7,
-0xdb,0xed,0xf6,0xfa,0x7e,0x7e,0x3f,0x7f,0x8f,0xe7,0xe3,0xf8,0xfe,0x3e,0x3f,0x6f,
-0x00,0x00,0x01,0x01,0xc8,0x0b,0x0c,0x30,0x7c,0x14,0x0f,0x0f,0x00,0x00,0x00,0x00,
-0x78,0x00,0x1c,0x00,0x0f,0x07,0x81,0x80,0x00,0x7c,0x00,0x00,0x1c,0x0f,0x80,0x04,
-0x42,0x23,0x90,0x00,0x18,0x0c,0x06,0x03,0x01,0x80,0xc0,0x3c,0x3c,0x3f,0x1f,0x8f,
-0xc7,0xe7,0xe3,0xf1,0xf8,0xfc,0x7c,0x30,0x8f,0x07,0x83,0xc1,0xe0,0xf0,0x00,0x3d,
-0x31,0x98,0xcc,0x66,0x36,0x19,0x80,0xcc,0x0c,0x18,0x09,0x0b,0x02,0x81,0x20,0x00,
-0x00,0x06,0x0c,0x04,0x82,0x40,0x60,0xc0,0x48,0x24,0x18,0x16,0x03,0x03,0x01,0x21,
-0x60,0x50,0x00,0x00,0x06,0x06,0x02,0x41,0x40,0xc1,0x80,0x28,0x87,0x7f,0x84,0x10,
-0x08,0x04,0x02,0x40,0x38,0x48,0x24,0x10,0x09,0x04,0x04,0x81,0x00,0x80,0x90,0x48,
-0x24,0x12,0x09,0x04,0x80,0x41,0x00,0x80,0x40,0x04,0x10,0x04,0x02,0x01,0x20,0x90,
-0x00,0x0c,0x04,0x84,0x86,0x53,0x65,0xb0,0x08,0x18,0x06,0x0a,0x80,0x00,0x00,0x00,
-0x00,0x0c,0x36,0x0e,0x19,0xcc,0xe0,0xe3,0xf8,0xcc,0xfe,0x63,0x1b,0x00,0x00,0x00,
-0x00,0x00,0x00,0xc6,0x62,0x0c,0x19,0x86,0x66,0x63,0x01,0x80,0x66,0x63,0x0c,0x01,
-0x8c,0xc6,0x06,0x19,0xc4,0xcc,0x63,0x33,0x19,0x8c,0x61,0x83,0x1b,0x0d,0x86,0x63,
-0x61,0x80,0xc6,0x03,0x00,0x30,0x30,0x00,0x1c,0x00,0x18,0x00,0x00,0x30,0x00,0x60,
-0x00,0x60,0x00,0x00,0x0c,0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,
-0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0xc0,0x60,0x01,0x54,0x86,0xc0,0x7b,0xef,
-0xf7,0xfb,0xfd,0xbf,0xc7,0xb7,0xdb,0xef,0xf6,0xfb,0xfb,0x7e,0xff,0x7f,0x6f,0xb7,
-0xdb,0xed,0xf6,0xfb,0x7f,0xbe,0xff,0x7f,0xbf,0xfb,0xef,0xfb,0xfd,0xfe,0xdf,0x6f,
-0xff,0x00,0x07,0x83,0x24,0x13,0x0c,0x30,0xc6,0x00,0x10,0x81,0x80,0x00,0x00,0x00,
-0x84,0x00,0x22,0x00,0x01,0x80,0xc0,0x00,0x00,0xf4,0x00,0x00,0x2c,0x18,0xc0,0x0c,
-0x46,0x20,0x90,0x00,0x18,0x0c,0x06,0x03,0x01,0x80,0xc0,0x70,0x66,0x30,0x18,0x0c,
-0x06,0x01,0x80,0xc0,0x60,0x30,0x66,0x38,0x99,0x8c,0xc6,0x63,0x31,0x98,0x00,0x66,
-0x31,0x98,0xcc,0x66,0x36,0x19,0x80,0xcc,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6c,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0xff,0x7f,0xb8,0x1c,
-0x0e,0x07,0x02,0x40,0x7c,0x70,0x3c,0x10,0x09,0x07,0x04,0x00,0xc0,0x60,0xe0,0x70,
-0x38,0x1c,0x0e,0x04,0x83,0x81,0xc0,0x70,0x70,0x38,0x1c,0x07,0x02,0xc1,0xc0,0x90,
-0x00,0x0c,0x00,0x04,0x86,0x43,0x69,0xb0,0x30,0x18,0x06,0x07,0x01,0x00,0x00,0x00,
-0x00,0x0c,0x63,0x16,0x00,0xc0,0x61,0x62,0x01,0x80,0x06,0x63,0x31,0x80,0x00,0x00,
-0x60,0x00,0xc0,0x06,0x43,0x16,0x19,0x8c,0x06,0x33,0x01,0x80,0xc0,0x63,0x0c,0x01,
-0x8c,0x86,0x07,0x39,0xc5,0x86,0x63,0x61,0x99,0x8c,0x01,0x83,0x1b,0x0d,0xb6,0x63,
-0x31,0x01,0x86,0x03,0x00,0x30,0x30,0x00,0x1c,0x3e,0x1b,0x03,0xc1,0xf0,0xf0,0x60,
-0x3e,0x6e,0x3e,0x0f,0x8c,0x60,0xc5,0xb1,0xb8,0x38,0x6c,0x0f,0x8c,0xc7,0xc1,0x83,
-0x19,0x8d,0x82,0x63,0x31,0x9f,0xc1,0x80,0xc0,0xc0,0x00,0xaa,0x86,0xc0,0x47,0xe3,
-0xf1,0xf8,0xfd,0xbf,0x83,0x8f,0xc3,0xef,0xf6,0xf8,0xfc,0xff,0x3f,0x9f,0x1f,0x8f,
-0xc7,0xe3,0xf1,0xfb,0x7c,0x7e,0x3f,0x8f,0x8f,0xc7,0xe3,0xf8,0xfd,0x3e,0x3f,0x6f,
-0x00,0x0c,0x0d,0x43,0x03,0xe1,0x88,0x30,0xc0,0x00,0x27,0x41,0x80,0x00,0x00,0x01,
-0x72,0x00,0x22,0x04,0x01,0x80,0xc0,0x03,0x18,0xf4,0x00,0x00,0x0c,0x18,0xc0,0x04,
-0x82,0x43,0x20,0x18,0x2c,0x16,0x0b,0x05,0x82,0xc1,0x60,0xb0,0xc0,0x30,0x18,0x0c,
-0x06,0x01,0x80,0xc0,0x60,0x30,0x63,0x38,0xb0,0xd8,0x6c,0x36,0x1b,0x0c,0x00,0xc7,
-0x31,0x98,0xcc,0x66,0x33,0x11,0xf8,0xc8,0x7c,0x3e,0x1f,0x0f,0x87,0xc3,0xe1,0xd8,
-0x3c,0x1e,0x0f,0x07,0x83,0xc7,0xc3,0xe1,0xf0,0xf8,0x06,0x37,0x07,0x03,0x81,0xc0,
-0xe0,0x70,0x10,0x1d,0x31,0x98,0xcc,0x66,0x33,0x19,0xb0,0xc6,0x8f,0x7f,0x87,0x03,
-0x81,0x80,0x90,0x30,0x6c,0x48,0x24,0x10,0x06,0x04,0x04,0x80,0x20,0x10,0x10,0x0e,
-0x07,0x03,0x81,0xc0,0x60,0x88,0x38,0x0c,0x40,0x09,0x03,0x84,0x02,0x41,0x40,0x90,
-0x00,0x0c,0x00,0x1f,0xe7,0x41,0xd1,0xa0,0x00,0x30,0x03,0x0a,0x81,0x00,0x00,0x00,
-0x00,0x18,0x63,0x06,0x00,0xc0,0xc2,0x62,0x01,0xb0,0x0c,0x72,0x31,0x86,0x03,0x00,
-0xc0,0x00,0x60,0x06,0x8f,0x16,0x19,0x0c,0x06,0x33,0x01,0x80,0xc0,0x63,0x0c,0x01,
-0x8d,0x06,0x07,0x39,0x65,0x86,0x63,0x61,0x99,0x0e,0x01,0x83,0x19,0x89,0xb6,0x32,
-0x33,0x03,0x06,0x01,0x80,0x30,0x78,0x00,0x00,0x03,0x1d,0x86,0x23,0x31,0x99,0xfc,
-0x66,0x77,0x06,0x01,0x8c,0x40,0xc6,0xd9,0xdc,0x6c,0x76,0x19,0x8d,0xcc,0x27,0xf3,
-0x19,0x8d,0x82,0x63,0x31,0x80,0xc0,0x80,0xc0,0x80,0x01,0x54,0x8c,0xc0,0x78,0xfc,
-0x7e,0x7f,0x6f,0xcf,0x93,0xb7,0xdb,0xef,0xf9,0xfb,0xff,0xff,0xdf,0xef,0xef,0xf1,
-0xf8,0xfc,0x7e,0x3f,0x9f,0x77,0xc7,0xf3,0xbf,0xf6,0xfc,0x7b,0xfd,0xbe,0xbf,0x6f,
-0xff,0x0c,0x19,0x03,0x03,0x61,0x98,0x30,0x78,0x00,0x28,0x4f,0x83,0x30,0x00,0x01,
-0x4a,0x00,0x1c,0x04,0x03,0x03,0x80,0x03,0x18,0xf4,0x00,0x00,0x0c,0x18,0xd9,0x84,
-0x82,0x40,0xa0,0x18,0x2c,0x16,0x0b,0x05,0x82,0xc1,0x60,0xb0,0xc0,0x30,0x18,0x0c,
-0x06,0x01,0x80,0xc0,0x60,0x30,0x63,0x2c,0xb0,0xd8,0x6c,0x36,0x1b,0x0c,0x64,0xcb,
-0x31,0x98,0xcc,0x66,0x33,0x31,0x8c,0xd8,0x06,0x03,0x01,0x80,0xc0,0x60,0x30,0x6c,
-0x62,0x33,0x19,0x8c,0xc6,0x60,0xc0,0x60,0x30,0x18,0x1e,0x3b,0x8d,0x86,0xc3,0x61,
-0xb0,0xd8,0x10,0x36,0x31,0x98,0xcc,0x66,0x33,0x19,0xd8,0xc6,0x0f,0x7f,0x82,0x01,
-0x02,0x40,0xd0,0x40,0x6c,0x70,0x24,0x1c,0x06,0x04,0x03,0x01,0xc0,0xe0,0x10,0x12,
-0x09,0x04,0x82,0x40,0x90,0x50,0x10,0x12,0x70,0x09,0x04,0x04,0x01,0xc1,0x20,0x60,
-0x00,0x0c,0x00,0x04,0x83,0xc0,0x20,0xcc,0x00,0x30,0x03,0x02,0x01,0x00,0x00,0x00,
-0x00,0x18,0x63,0x06,0x01,0x83,0x84,0x63,0xf1,0xd8,0x18,0x3c,0x31,0x86,0x03,0x01,
-0x83,0xf8,0x30,0x1c,0x9b,0x33,0x1e,0x0c,0x06,0x33,0xe1,0x80,0xc0,0x7f,0x0c,0x01,
-0x8f,0x06,0x07,0x79,0x65,0x86,0x66,0x61,0x9e,0x07,0x81,0x83,0x19,0x89,0xb6,0x1c,
-0x1a,0x03,0x06,0x01,0x80,0x30,0x48,0x00,0x00,0x03,0x18,0xcc,0x06,0x33,0x18,0x60,
-0xc6,0x63,0x06,0x01,0x8c,0x80,0xc6,0xd9,0x8c,0xc6,0x63,0x31,0x8e,0x4c,0x01,0x83,
-0x19,0x8d,0x92,0x32,0x31,0x81,0x87,0x00,0xc0,0x70,0xe4,0xaa,0x98,0xc0,0x7d,0xfe,
-0xfd,0xbf,0x2f,0xbf,0x93,0x8f,0xdb,0xe3,0xf9,0xfb,0xff,0x1e,0x3f,0x1f,0xef,0xed,
-0xf6,0xfb,0x7d,0xbf,0x6f,0xaf,0xef,0xed,0x8f,0xf6,0xfb,0xfb,0xfe,0x3e,0xdf,0x9f,
-0x00,0x00,0x19,0x0f,0xc6,0x30,0xd0,0x00,0xcc,0x00,0x28,0x59,0x86,0x67,0xf0,0x01,
-0x72,0x00,0x00,0x3f,0x86,0x00,0xc0,0x03,0x18,0xf4,0x00,0x00,0x0c,0x18,0xcc,0xc5,
-0x32,0x83,0x4c,0x00,0x66,0x33,0x19,0x8c,0xc6,0x63,0x31,0xbc,0xc0,0x3e,0x1f,0x0f,
-0x87,0xc1,0x80,0xc0,0x60,0x30,0xfb,0x2c,0xb0,0xd8,0x6c,0x36,0x1b,0x0c,0x38,0xcb,
-0x31,0x98,0xcc,0x66,0x31,0xa1,0x8c,0xcc,0x06,0x03,0x01,0x80,0xc0,0x60,0x30,0x6c,
-0xc0,0x63,0x31,0x98,0xcc,0x60,0xc0,0x60,0x30,0x18,0x37,0x31,0x98,0xcc,0x66,0x33,
-0x19,0x8c,0x00,0x67,0x31,0x98,0xcc,0x66,0x33,0x19,0x8c,0xc6,0x1f,0x7f,0x82,0x01,
-0x02,0x40,0xb0,0x40,0x6c,0x07,0x03,0x83,0x80,0xe0,0xe0,0x00,0x18,0x0e,0x10,0x10,
-0x08,0x04,0x02,0x00,0xf0,0x20,0x10,0x1e,0x08,0x89,0x03,0x00,0xe0,0x38,0x1c,0x0e,
-0x00,0x0c,0x00,0x04,0x81,0xe0,0x41,0x6c,0x00,0x30,0x03,0x00,0x0f,0xe0,0x03,0xf8,
-0x00,0x30,0x63,0x06,0x03,0x00,0xc7,0xf0,0x39,0x8c,0x30,0x3e,0x1b,0x80,0x00,0x03,
-0x00,0x00,0x18,0x30,0x9b,0x23,0x19,0x0c,0x06,0x33,0x01,0xf8,0xc6,0x63,0x0c,0x01,
-0x8d,0x86,0x05,0xd9,0x35,0x86,0x7c,0x61,0x9b,0x01,0xc1,0x83,0x19,0x99,0xb4,0x1c,
-0x0c,0x06,0x06,0x00,0xc0,0x30,0xcc,0x00,0x00,0x3f,0x18,0xcc,0x06,0x33,0xf8,0x60,
-0xc6,0x63,0x06,0x01,0x8f,0x00,0xc6,0xd9,0x8c,0xc6,0x63,0x31,0x8c,0x0f,0x81,0x83,
-0x18,0xd9,0xba,0x1c,0x1b,0x03,0x00,0x80,0xc0,0x81,0x75,0x54,0x98,0xc0,0x7d,0xfe,
-0xfd,0xbf,0x4f,0xbf,0x93,0xf8,0xfc,0x7c,0x7f,0x1f,0x1f,0x6f,0xe7,0xf1,0xef,0xef,
-0xf7,0xfb,0xfd,0xff,0x0f,0xdf,0xef,0xe1,0xf7,0x76,0xfc,0xff,0x1f,0xc7,0xe3,0xf1,
-0xff,0x08,0x19,0x03,0x06,0x31,0xf8,0x00,0xc6,0x00,0x28,0x5b,0x8c,0xc0,0x11,0xf1,
-0x4a,0x00,0x00,0x04,0x0c,0x00,0xc0,0x03,0x18,0x74,0x38,0x00,0x0c,0x18,0xc6,0x65,
-0x52,0xb8,0x54,0x18,0x46,0x23,0x11,0x88,0xc4,0x62,0x31,0x30,0xc0,0x30,0x18,0x0c,
-0x06,0x01,0x80,0xc0,0x60,0x30,0x63,0x26,0xb0,0xd8,0x6c,0x36,0x1b,0x0c,0x10,0xd3,
-0x31,0x98,0xcc,0x66,0x30,0xc1,0x8c,0xc6,0x7e,0x3f,0x1f,0x8f,0xc7,0xe3,0xf1,0xfc,
-0xc0,0x7f,0x3f,0x9f,0xcf,0xe0,0xc0,0x60,0x30,0x18,0x63,0x31,0x98,0xcc,0x66,0x33,
-0x19,0x8c,0xfe,0x6b,0x31,0x98,0xcc,0x66,0x31,0xb1,0x8c,0x6c,0x0e,0x7f,0x82,0x01,
-0x01,0x80,0x90,0x30,0xc6,0x08,0x01,0x02,0x00,0x40,0x80,0xe0,0x24,0x04,0x1c,0x10,
-0x08,0x04,0x02,0x00,0x90,0x20,0x10,0x12,0x0d,0x86,0x00,0x81,0x00,0x40,0x20,0x10,
-0x00,0x04,0x00,0x1f,0xe1,0x70,0xbb,0x28,0x00,0x30,0x03,0x00,0x01,0x00,0x00,0x00,
-0x00,0x30,0x63,0x06,0x06,0x00,0x67,0xf0,0x19,0x8c,0x30,0x67,0x0d,0x80,0x00,0x01,
-0x83,0xf8,0x30,0x30,0x9b,0x7f,0x19,0x8c,0x06,0x33,0x01,0x80,0xc6,0x63,0x0c,0x01,
-0x8c,0xc6,0x05,0xd9,0x35,0x86,0x60,0x61,0x99,0x80,0xe1,0x83,0x18,0xd0,0xdc,0x26,
-0x0c,0x0c,0x06,0x00,0xc0,0x30,0x84,0x00,0x00,0x63,0x18,0xcc,0x06,0x33,0x00,0x60,
-0xc6,0x63,0x06,0x01,0x8d,0x80,0xc6,0xd9,0x8c,0xc6,0x63,0x31,0x8c,0x03,0xe1,0x83,
-0x18,0xd9,0xba,0x1c,0x1b,0x06,0x01,0x80,0xc0,0xc1,0x38,0xaa,0x80,0xc0,0x7d,0xfe,
-0xfe,0x7f,0x6f,0xcf,0x39,0xf7,0xfe,0xfd,0xff,0xbf,0x7f,0x0f,0xdb,0xfb,0xe3,0xef,
-0xf7,0xfb,0xfd,0xff,0x6f,0xdf,0xef,0xed,0xf2,0x79,0xff,0x7e,0xff,0xbf,0xdf,0xef,
-0x00,0x0c,0x19,0x03,0x03,0x60,0x60,0x30,0x66,0x00,0x28,0x4d,0xc6,0x60,0x10,0x00,
-0x84,0x00,0x00,0x04,0x0f,0x87,0x80,0x03,0x18,0x14,0x38,0x00,0x3f,0x0f,0x8c,0xc2,
-0x90,0x84,0xa4,0x18,0xfe,0x7f,0x3f,0x9f,0xcf,0xe7,0xf1,0xf0,0xc0,0x30,0x18,0x0c,
-0x06,0x01,0x80,0xc0,0x60,0x30,0x63,0x26,0xb0,0xd8,0x6c,0x36,0x1b,0x0c,0x38,0xd3,
-0x31,0x98,0xcc,0x66,0x30,0xc1,0x98,0xc6,0xc6,0x63,0x31,0x98,0xcc,0x66,0x33,0x60,
-0xc0,0x60,0x30,0x18,0x0c,0x00,0xc0,0x60,0x30,0x18,0x63,0x31,0x98,0xcc,0x66,0x33,
-0x19,0x8c,0x00,0x6b,0x31,0x98,0xcc,0x66,0x31,0xb1,0x8c,0x6c,0x1c,0x7f,0x81,0x20,
-0x90,0x38,0x18,0x0b,0x83,0x06,0x01,0x03,0x80,0x40,0xe0,0x90,0x24,0x04,0x03,0x8e,
-0x86,0xc3,0x61,0x90,0x24,0x12,0x0e,0x04,0x8a,0x81,0xc7,0x70,0xc0,0x30,0x18,0x0c,
-0x00,0x00,0x00,0x04,0x81,0x31,0x6f,0x30,0x00,0x18,0x06,0x00,0x01,0x00,0x00,0x00,
-0x00,0x60,0x63,0x06,0x0c,0x00,0x60,0x60,0x19,0x8c,0x60,0x63,0x01,0x80,0x00,0x00,
-0xc0,0x00,0x60,0x00,0x4d,0xe1,0x99,0x8c,0x06,0x33,0x01,0x80,0xc6,0x63,0x0c,0x01,
-0x8c,0xc6,0x04,0x99,0x1d,0x86,0x60,0x61,0x99,0x80,0x61,0x83,0x18,0xd0,0xdc,0x63,
-0x0c,0x0c,0x06,0x00,0x60,0x30,0x84,0x00,0x00,0x63,0x18,0xcc,0x06,0x33,0x00,0x60,
-0x6e,0x63,0x06,0x01,0x8c,0xc0,0xc6,0xd9,0x8c,0xc6,0x63,0x31,0x8c,0x00,0x61,0x83,
-0x18,0xd0,0xcc,0x26,0x0e,0x0c,0x03,0x00,0xc0,0x60,0x01,0x54,0x98,0xc0,0x7e,0xdf,
-0x6f,0xc7,0xe7,0xf4,0x7c,0xf9,0xfe,0xfc,0x7f,0xbf,0x1f,0x5f,0xdb,0xfb,0xfc,0x71,
-0x79,0x3c,0x9e,0x6f,0xdb,0xed,0xf1,0xfb,0x75,0x7e,0x38,0x8f,0x3f,0xcf,0xe7,0xf3,
-0xff,0x0c,0x0d,0x03,0x03,0xe1,0xf8,0x30,0x3c,0x00,0x27,0x40,0x03,0x30,0x00,0x00,
-0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x18,0x14,0x00,0x00,0x00,0x00,0x19,0x82,
-0xf8,0x98,0xbe,0x70,0xc3,0x61,0xb0,0xd8,0x6c,0x36,0x1b,0x30,0xc0,0x30,0x18,0x0c,
-0x06,0x01,0x80,0xc0,0x60,0x30,0x63,0x23,0xb0,0xd8,0x6c,0x36,0x1b,0x0c,0x4c,0xe3,
-0x31,0x98,0xcc,0x66,0x30,0xc1,0xf0,0xc6,0xc6,0x63,0x31,0x98,0xcc,0x66,0x33,0x60,
-0xc0,0x60,0x30,0x18,0x0c,0x00,0xc0,0x60,0x30,0x18,0x63,0x31,0x98,0xcc,0x66,0x33,
-0x19,0x8c,0x10,0x73,0x31,0x98,0xcc,0x66,0x30,0xe1,0x8c,0x38,0x1c,0x7f,0x80,0xa0,
-0x50,0x10,0x24,0x0d,0xff,0x01,0x01,0x02,0x00,0x40,0x80,0xf0,0x24,0x04,0x02,0x01,
-0x81,0x20,0x10,0x30,0x28,0x1a,0x09,0x06,0x8a,0x81,0x20,0x90,0x20,0x08,0x04,0x02,
-0x00,0x0c,0x00,0x04,0x85,0x32,0x6f,0xb8,0x00,0x18,0x06,0x00,0x01,0x01,0xc0,0x00,
-0x70,0x60,0x36,0x06,0x1f,0xcc,0xe0,0x63,0x30,0xd8,0x60,0x63,0x33,0x06,0x03,0x00,
-0x60,0x00,0xc0,0x30,0x60,0x61,0x99,0x86,0x66,0x63,0x01,0x80,0x66,0x63,0x0c,0x03,
-0x0c,0x66,0x04,0x19,0x1c,0xcc,0x60,0x33,0x18,0xcc,0x61,0x81,0xb0,0x60,0xcc,0x63,
-0x0c,0x18,0x06,0x00,0x60,0x30,0x00,0x00,0x00,0x67,0x19,0x86,0x23,0x71,0x88,0x60,
-0x36,0x63,0x06,0x01,0x8c,0x60,0xc6,0xd9,0x8c,0x6c,0x66,0x1b,0x8c,0x08,0x61,0x83,
-0xb8,0x70,0xcc,0x63,0x0c,0x18,0x03,0x00,0xc0,0x60,0x00,0xaa,0x98,0xc0,0x7f,0x5f,
-0xaf,0xef,0xdb,0xf2,0x00,0xfe,0xfe,0xfd,0xff,0xbf,0x7f,0x6f,0xdb,0xfb,0xfd,0xfe,
-0x7e,0xdf,0xef,0xcf,0xd7,0xe5,0xf6,0xf9,0x75,0x7e,0xdf,0x6f,0xdf,0xf7,0xfb,0xfd,
-0x00,0x0c,0x07,0xc6,0x04,0x10,0x60,0x30,0x06,0x00,0x10,0x80,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x3f,0x80,0x00,0x00,0x03,0xb8,0x14,0x00,0x00,0x00,0x00,0x00,0x04,
-0x11,0x21,0x04,0xc0,0xc3,0x61,0xb0,0xd8,0x6c,0x36,0x1b,0x30,0x66,0x30,0x18,0x0c,
-0x06,0x01,0x80,0xc0,0x60,0x30,0x66,0x23,0x99,0x8c,0xc6,0x63,0x31,0x98,0x00,0x66,
-0x1b,0x0d,0x86,0xc3,0x60,0xc1,0x80,0xc6,0xce,0x67,0x33,0x99,0xcc,0xe6,0x73,0x74,
-0x62,0x31,0x18,0x8c,0x46,0x20,0xc0,0x60,0x30,0x18,0x36,0x31,0x8d,0x86,0xc3,0x61,
-0xb0,0xd8,0x10,0x36,0x3b,0x9d,0xce,0xe7,0x70,0xc1,0x98,0x30,0x00,0x7f,0x80,0xc0,
-0x60,0x10,0x24,0x0c,0x38,0x0e,0x01,0x02,0x00,0x40,0x80,0xa0,0x18,0x0e,0x03,0x00,
-0x80,0x40,0x60,0x50,0x30,0x16,0x0e,0x05,0x88,0x81,0xc0,0x81,0xc0,0x70,0x38,0x1c,
-0x00,0x0c,0x00,0x04,0x83,0xe0,0x39,0xcc,0x00,0x0c,0x0c,0x00,0x00,0x01,0xc0,0x00,
-0x70,0xc0,0x1c,0x06,0x1f,0xc7,0xc0,0x61,0xe0,0x70,0x60,0x3e,0x1e,0x06,0x03,0x00,
-0x00,0x00,0x00,0x30,0x1e,0x61,0x9f,0x03,0xc7,0xc3,0xf1,0x80,0x3e,0x63,0x3f,0x1e,
-0x0c,0x67,0xe4,0x19,0x0c,0x78,0x60,0x1e,0x18,0xc7,0xc1,0x80,0xe0,0x60,0xcc,0x63,
-0x0c,0x1f,0xc6,0x00,0x30,0x30,0x00,0x00,0x00,0x3b,0x9f,0x03,0xc1,0xb0,0xf0,0x60,
-0x06,0x63,0x06,0x01,0x8c,0x70,0xc6,0xd9,0x8c,0x38,0x7c,0x0d,0x8c,0x07,0xc0,0xf1,
-0xd8,0x60,0xcc,0x63,0x0c,0x1f,0xc3,0x00,0xc0,0x60,0x01,0x54,0x80,0xc0,0x7f,0x3f,
-0x9f,0xef,0xdb,0xf3,0xc7,0xf1,0xfe,0xfd,0xff,0xbf,0x7f,0xff,0xe7,0xf1,0xfc,0xff,
-0x7f,0xbf,0x9f,0xaf,0xcf,0xe9,0xf1,0xfa,0x77,0x7e,0x3f,0x7e,0x3f,0x8f,0xc7,0xe3,
-0xff,0x0c,0x01,0x0f,0xe8,0x08,0x60,0x30,0xc6,0x00,0x0f,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xd8,0x14,0x00,0x00,0x00,0x00,0x00,0x04,
-0x11,0x3d,0x04,0xc0,0xc3,0x61,0xb0,0xd8,0x6c,0x36,0x1b,0x3c,0x3c,0x3f,0x1f,0x8f,
-0xc7,0xe7,0xe3,0xf1,0xf8,0xfc,0x7c,0x21,0x8f,0x07,0x83,0xc1,0xe0,0xf0,0x00,0xbc,
-0x0e,0x07,0x03,0x81,0xc0,0xc1,0x80,0xcc,0x77,0x3b,0x9d,0xce,0xe7,0x73,0xb9,0x98,
-0x3c,0x1e,0x0f,0x07,0x83,0xc0,0xc0,0x60,0x30,0x18,0x1c,0x31,0x87,0x03,0x81,0xc0,
-0xe0,0x70,0x00,0x5c,0x1d,0x8e,0xc7,0x63,0xb0,0xc1,0xf0,0x30,0x00,0x7f,0x81,0x40,
-0xa0,0x10,0x28,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x90,0x00,0x00,0x02,0x00,
-0x80,0x80,0x10,0xf8,0x28,0x12,0x09,0x04,0x80,0x01,0x20,0x80,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x06,0x18,0x00,0x00,0x00,0x40,0x00,
-0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,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,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x07,0xc0,0x31,0xf0,0x01,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0xcc,0x00,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x60,0x01,0x80,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x18,0x00,0x01,0xe0,0xc3,0xc0,0x00,0x00,0xff,0xc0,0x7e,0xbf,
-0x5f,0xef,0xd7,0xf5,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfd,0xff,
-0x7f,0x7f,0xef,0x07,0xd7,0xed,0xf6,0xfb,0x7f,0xfe,0xdf,0x7f,0xff,0xff,0xff,0xff,
-0x00,0x0c,0x01,0x00,0x00,0x00,0x00,0x30,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x14,0x00,0x08,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0xc6,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,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,
-0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x81,0x80,0x60,0x00,0x7f,0x81,0x20,
-0x90,0x10,0x1c,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x80,
-0x81,0xe0,0x60,0x10,0x24,0x12,0x0e,0x04,0x80,0x01,0xc0,0x70,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,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,0x01,0x80,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,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x01,0x80,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0xfe,0xdf,
-0x6f,0xef,0xe3,0xf5,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfc,0x7f,
-0x7e,0x1f,0x9f,0xef,0xdb,0xed,0xf1,0xfb,0x7f,0xfe,0x3f,0x8f,0xff,0xff,0xff,0xff,
-0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,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,
-0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x81,0x80,0x60,0x20,0x20,0x20,0x20,
-0x20,0x20,0x20,0x20,0x32,0x35,0x36,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
-0x20,0x31,0x35,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x31,0x33,0x20,
-0x00,0x00,0x01,0x0c,0x00,0x09,0x09,0x00,0x01,0x0f,0x00,0x09,0x12,0x00,0x01,0x0f,
-0x00,0x09,0x1b,0x00,0x01,0x0f,0x00,0x09,0x24,0x00,0x01,0x0f,0x00,0x09,0x2d,0x00,
-0x01,0x0f,0x00,0x09,0x36,0x00,0x01,0x0f,0x00,0x09,0x3f,0x00,0x03,0x0d,0x00,0x09,
-0x48,0x00,0x03,0x0d,0x00,0x09,0x51,0x00,0x03,0x0d,0x00,0x09,0x5a,0x00,0x03,0x0d,
-0x00,0x09,0x63,0x00,0x03,0x0d,0x00,0x09,0x6c,0x00,0x03,0x0d,0x00,0x09,0x75,0x00,
-0x03,0x0e,0x00,0x09,0x7e,0x00,0x03,0x0d,0x00,0x09,0x87,0x00,0x03,0x0d,0x00,0x09,
-0x90,0x00,0x01,0x0f,0x00,0x09,0x99,0x00,0x01,0x0f,0x00,0x09,0xa2,0x00,0x01,0x0f,
-0x00,0x09,0xab,0x00,0x01,0x0f,0x00,0x09,0xb4,0x00,0x01,0x0f,0x00,0x09,0xbd,0x00,
-0x01,0x0f,0x00,0x09,0xc6,0x00,0x01,0x0f,0x00,0x09,0xcf,0x00,0x01,0x0f,0x00,0x09,
-0xd8,0x00,0x01,0x0f,0x00,0x09,0xe1,0x00,0x03,0x0d,0x00,0x09,0xea,0x00,0x01,0x0f,
-0x00,0x09,0xf3,0x00,0x01,0x0f,0x00,0x09,0xfc,0x00,0x03,0x0d,0x00,0x09,0x05,0x01,
-0x03,0x0d,0x00,0x09,0x0e,0x01,0x03,0x0d,0x00,0x09,0x17,0x01,0x03,0x0d,0x00,0x09,
-0x20,0x01,0x00,0x00,0x00,0x09,0x29,0x01,0x03,0x0d,0x00,0x09,0x32,0x01,0x02,0x05,
-0x00,0x09,0x3b,0x01,0x03,0x0d,0x00,0x09,0x44,0x01,0x02,0x0e,0x00,0x09,0x4d,0x01,
-0x03,0x0d,0x00,0x09,0x56,0x01,0x03,0x0d,0x00,0x09,0x5f,0x01,0x02,0x06,0x00,0x09,
-0x68,0x01,0x02,0x0e,0x00,0x09,0x71,0x01,0x02,0x0e,0x00,0x09,0x7a,0x01,0x03,0x08,
-0x00,0x09,0x83,0x01,0x05,0x0c,0x00,0x09,0x8c,0x01,0x0b,0x0f,0x00,0x09,0x95,0x01,
-0x08,0x09,0x00,0x09,0x9e,0x01,0x0b,0x0d,0x00,0x09,0xa7,0x01,0x02,0x0e,0x00,0x09,
-0xb0,0x01,0x03,0x0d,0x00,0x09,0xb9,0x01,0x03,0x0d,0x00,0x09,0xc2,0x01,0x03,0x0d,
-0x00,0x09,0xcb,0x01,0x03,0x0d,0x00,0x09,0xd4,0x01,0x03,0x0d,0x00,0x09,0xdd,0x01,
-0x03,0x0d,0x00,0x09,0xe6,0x01,0x03,0x0d,0x00,0x09,0xef,0x01,0x03,0x0d,0x00,0x09,
-0xf8,0x01,0x03,0x0d,0x00,0x09,0x01,0x02,0x03,0x0d,0x00,0x09,0x0a,0x02,0x06,0x0d,
-0x00,0x09,0x13,0x02,0x06,0x0f,0x00,0x09,0x1c,0x02,0x05,0x0c,0x00,0x09,0x25,0x02,
-0x07,0x0a,0x00,0x09,0x2e,0x02,0x05,0x0c,0x00,0x09,0x37,0x02,0x03,0x0d,0x00,0x09,
-0x40,0x02,0x03,0x0d,0x00,0x09,0x49,0x02,0x03,0x0d,0x00,0x09,0x52,0x02,0x03,0x0d,
-0x00,0x09,0x5b,0x02,0x03,0x0d,0x00,0x09,0x64,0x02,0x03,0x0d,0x00,0x09,0x6d,0x02,
-0x03,0x0d,0x00,0x09,0x76,0x02,0x03,0x0d,0x00,0x09,0x7f,0x02,0x03,0x0d,0x00,0x09,
-0x88,0x02,0x03,0x0d,0x00,0x09,0x91,0x02,0x03,0x0d,0x00,0x09,0x9a,0x02,0x03,0x0d,
-0x00,0x09,0xa3,0x02,0x03,0x0d,0x00,0x09,0xac,0x02,0x03,0x0d,0x00,0x09,0xb5,0x02,
-0x03,0x0d,0x00,0x09,0xbe,0x02,0x03,0x0d,0x00,0x09,0xc7,0x02,0x03,0x0d,0x00,0x09,
-0xd0,0x02,0x03,0x0d,0x00,0x09,0xd9,0x02,0x03,0x0f,0x00,0x09,0xe2,0x02,0x03,0x0d,
-0x00,0x09,0xeb,0x02,0x03,0x0d,0x00,0x09,0xf4,0x02,0x03,0x0d,0x00,0x09,0xfd,0x02,
-0x03,0x0d,0x00,0x09,0x06,0x03,0x03,0x0d,0x00,0x09,0x0f,0x03,0x03,0x0d,0x00,0x09,
-0x18,0x03,0x03,0x0d,0x00,0x09,0x21,0x03,0x03,0x0d,0x00,0x09,0x2a,0x03,0x03,0x0d,
-0x00,0x09,0x33,0x03,0x02,0x0e,0x00,0x09,0x3c,0x03,0x02,0x0e,0x00,0x09,0x45,0x03,
-0x02,0x0e,0x00,0x09,0x4e,0x03,0x04,0x0b,0x00,0x09,0x57,0x03,0x0d,0x0e,0x00,0x09,
-0x60,0x03,0x02,0x06,0x00,0x09,0x69,0x03,0x05,0x0d,0x00,0x09,0x72,0x03,0x02,0x0d,
-0x00,0x09,0x7b,0x03,0x05,0x0d,0x00,0x09,0x84,0x03,0x02,0x0d,0x00,0x09,0x8d,0x03,
-0x05,0x0d,0x00,0x09,0x96,0x03,0x02,0x0d,0x00,0x09,0x9f,0x03,0x05,0x0f,0x00,0x09,
-0xa8,0x03,0x02,0x0d,0x00,0x09,0xb1,0x03,0x02,0x0d,0x00,0x09,0xba,0x03,0x02,0x0f,
-0x00,0x09,0xc3,0x03,0x02,0x0d,0x00,0x09,0xcc,0x03,0x02,0x0d,0x00,0x09,0xd5,0x03,
-0x05,0x0d,0x00,0x09,0xde,0x03,0x05,0x0d,0x00,0x09,0xe7,0x03,0x05,0x0d,0x00,0x09,
-0xf0,0x03,0x05,0x0f,0x00,0x09,0xf9,0x03,0x05,0x0f,0x00,0x09,0x02,0x04,0x05,0x0d,
-0x00,0x09,0x0b,0x04,0x05,0x0d,0x00,0x09,0x14,0x04,0x03,0x0d,0x00,0x09,0x1d,0x04,
-0x05,0x0d,0x00,0x09,0x26,0x04,0x05,0x0d,0x00,0x09,0x2f,0x04,0x05,0x0d,0x00,0x09,
-0x38,0x04,0x05,0x0d,0x00,0x09,0x41,0x04,0x05,0x0f,0x00,0x09,0x4a,0x04,0x05,0x0d,
-0x00,0x09,0x53,0x04,0x02,0x0e,0x00,0x09,0x5c,0x04,0x02,0x0e,0x00,0x09,0x65,0x04,
-0x02,0x0e,0x00,0x09,0x6e,0x04,0x07,0x0a,0x00,0x09,0x77,0x04,0x01,0x0d,0x00,0x09,
-0x80,0x04,0x00,0x0e,0x00,0x09,0x89,0x04,0x00,0x0f,0x00,0x09,0x92,0x04,0x00,0x0f,
-0x00,0x09,0x9b,0x04,0x00,0x0f,0x00,0x09,0xa4,0x04,0x00,0x0f,0x00,0x09,0xad,0x04,
-0x00,0x0f,0x00,0x09,0xb6,0x04,0x00,0x0f,0x00,0x09,0xbf,0x04,0x00,0x0f,0x00,0x09,
-0xc8,0x04,0x00,0x0f,0x00,0x09,0xd1,0x04,0x00,0x0f,0x00,0x09,0xda,0x04,0x00,0x0f,
-0x00,0x09,0xe3,0x04,0x00,0x0f,0x00,0x09,0xec,0x04,0x00,0x0f,0x00,0x09,0xf5,0x04,
-0x00,0x0f,0x00,0x09,0xfe,0x04,0x00,0x0f,0x00,0x09,0x07,0x05,0x00,0x0f,0x00,0x09,
-0x10,0x05,0x00,0x0f,0x00,0x09,0x19,0x05,0x00,0x0f,0x00,0x09,0x22,0x05,0x00,0x0f,
-0x00,0x09,0x2b,0x05,0x00,0x0f,0x00,0x09,0x34,0x05,0x00,0x0f,0x00,0x09,0x3d,0x05,
-0x00,0x0f,0x00,0x09,0x46,0x05,0x00,0x0f,0x00,0x09,0x4f,0x05,0x00,0x0f,0x00,0x09,
-0x58,0x05,0x00,0x0f,0x00,0x09,0x61,0x05,0x00,0x0f,0x00,0x09,0x6a,0x05,0x00,0x0f,
-0x00,0x09,0x73,0x05,0x00,0x0f,0x00,0x09,0x7c,0x05,0x00,0x0f,0x00,0x09,0x85,0x05,
-0x00,0x0f,0x00,0x09,0x8e,0x05,0x00,0x0f,0x00,0x09,0x97,0x05,0x00,0x0f,0x00,0x09,
-0xa0,0x05,0x00,0x0d,0x00,0x09,0xa9,0x05,0x05,0x0f,0x00,0x09,0xb2,0x05,0x02,0x0e,
-0x00,0x09,0xbb,0x05,0x03,0x0d,0x00,0x09,0xc4,0x05,0x03,0x0d,0x00,0x09,0xcd,0x05,
-0x03,0x0d,0x00,0x09,0xd6,0x05,0x02,0x0e,0x00,0x09,0xdf,0x05,0x03,0x0e,0x00,0x09,
-0xe8,0x05,0x02,0x04,0x00,0x09,0xf1,0x05,0x03,0x0d,0x00,0x09,0xfa,0x05,0x03,0x0a,
-0x00,0x09,0x03,0x06,0x06,0x0b,0x00,0x09,0x0c,0x06,0x07,0x0a,0x00,0x09,0x15,0x06,
-0x08,0x09,0x00,0x09,0x1e,0x06,0x03,0x0b,0x00,0x09,0x27,0x06,0x02,0x03,0x00,0x09,
-0x30,0x06,0x03,0x07,0x00,0x09,0x39,0x06,0x05,0x0c,0x00,0x09,0x42,0x06,0x03,0x0a,
-0x00,0x09,0x4b,0x06,0x03,0x0a,0x00,0x09,0x54,0x06,0x02,0x04,0x00,0x09,0x5d,0x06,
-0x05,0x0f,0x00,0x09,0x66,0x06,0x03,0x0e,0x00,0x09,0x6f,0x06,0x08,0x0a,0x00,0x09,
-0x78,0x06,0x0d,0x0f,0x00,0x09,0x81,0x06,0x03,0x0a,0x00,0x09,0x8a,0x06,0x03,0x0a,
-0x00,0x09,0x93,0x06,0x06,0x0b,0x00,0x09,0x9c,0x06,0x03,0x0d,0x00,0x09,0xa5,0x06,
-0x03,0x0d,0x00,0x09,0xae,0x06,0x03,0x0d,0x00,0x09,0xb7,0x06,0x05,0x0f,0x00,0x09,
-0xc0,0x06,0x00,0x0d,0x00,0x09,0xc9,0x06,0x00,0x0d,0x00,0x09,0xd2,0x06,0x00,0x0d,
-0x00,0x09,0xdb,0x06,0x00,0x0d,0x00,0x09,0xe4,0x06,0x00,0x0d,0x00,0x09,0xed,0x06,
-0x01,0x0d,0x00,0x09,0xf6,0x06,0x03,0x0d,0x00,0x09,0xff,0x06,0x03,0x0f,0x00,0x09,
-0x08,0x07,0x00,0x0d,0x00,0x09,0x11,0x07,0x00,0x0d,0x00,0x09,0x1a,0x07,0x00,0x0d,
-0x00,0x09,0x23,0x07,0x00,0x0d,0x00,0x09,0x2c,0x07,0x00,0x0d,0x00,0x09,0x35,0x07,
-0x00,0x0d,0x00,0x09,0x3e,0x07,0x00,0x0d,0x00,0x09,0x47,0x07,0x00,0x0d,0x00,0x09,
-0x50,0x07,0x03,0x0d,0x00,0x09,0x59,0x07,0x00,0x0d,0x00,0x09,0x62,0x07,0x00,0x0d,
-0x00,0x09,0x6b,0x07,0x00,0x0d,0x00,0x09,0x74,0x07,0x00,0x0d,0x00,0x09,0x7d,0x07,
-0x00,0x0d,0x00,0x09,0x86,0x07,0x00,0x0d,0x00,0x09,0x8f,0x07,0x06,0x0b,0x00,0x09,
-0x98,0x07,0x03,0x0d,0x00,0x09,0xa1,0x07,0x00,0x0d,0x00,0x09,0xaa,0x07,0x00,0x0d,
-0x00,0x09,0xb3,0x07,0x00,0x0d,0x00,0x09,0xbc,0x07,0x00,0x0d,0x00,0x09,0xc5,0x07,
-0x00,0x0d,0x00,0x09,0xce,0x07,0x03,0x0d,0x00,0x09,0xd7,0x07,0x02,0x0d,0x00,0x09,
-0xe0,0x07,0x02,0x0d,0x00,0x09,0xe9,0x07,0x02,0x0d,0x00,0x09,0xf2,0x07,0x02,0x0d,
-0x00,0x09,0xfb,0x07,0x02,0x0d,0x00,0x09,0x04,0x08,0x02,0x0d,0x00,0x09,0x0d,0x08,
-0x02,0x0d,0x00,0x09,0x16,0x08,0x05,0x0d,0x00,0x09,0x1f,0x08,0x05,0x0f,0x00,0x09,
-0x28,0x08,0x02,0x0d,0x00,0x09,0x31,0x08,0x02,0x0d,0x00,0x09,0x3a,0x08,0x02,0x0d,
-0x00,0x09,0x43,0x08,0x02,0x0d,0x00,0x09,0x4c,0x08,0x02,0x0d,0x00,0x09,0x55,0x08,
-0x02,0x0d,0x00,0x09,0x5e,0x08,0x02,0x0d,0x00,0x09,0x67,0x08,0x02,0x0d,0x00,0x09,
-0x70,0x08,0x02,0x0d,0x00,0x09,0x79,0x08,0x02,0x0d,0x00,0x09,0x82,0x08,0x02,0x0d,
-0x00,0x09,0x8b,0x08,0x02,0x0d,0x00,0x09,0x94,0x08,0x02,0x0d,0x00,0x09,0x9d,0x08,
-0x02,0x0d,0x00,0x09,0xa6,0x08,0x02,0x0d,0x00,0x09,0xaf,0x08,0x05,0x0c,0x00,0x09,
-0xb8,0x08,0x05,0x0d,0x00,0x09,0xc1,0x08,0x02,0x0d,0x00,0x09,0xca,0x08,0x02,0x0d,
-0x00,0x09,0xd3,0x08,0x02,0x0d,0x00,0x09,0xdc,0x08,0x02,0x0d,0x00,0x09,0xe5,0x08,
-0x02,0x0f,0x00,0x09,0xee,0x08,0x03,0x0f,0x00,0x09,0xf7,0x08,0x02,0x0f,0x00,0x09,
-0x00,0x09,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;
--- /dev/null
+++ b/libdraw/fmt.c
@@ -1,0 +1,22 @@
+#include <u.h>
+#include <libc.h>
+#include <draw.h>
+
+int
+Rfmt(Fmt *f)
+{
+	Rectangle r;
+
+	r = va_arg(f->args, Rectangle);
+	return fmtprint(f, "%P %P", r.min, r.max);
+}
+
+int
+Pfmt(Fmt *f)
+{
+	Point p;
+
+	p = va_arg(f->args, Point);
+	return fmtprint(f, "[%d %d]", p.x, p.y);
+}
+
--- a/libmemdraw/alloc.c
+++ b/libmemdraw/alloc.c
@@ -23,20 +23,20 @@
 }
 
 Memimage*
-allocmemimaged(Rectangle r, ulong chan, Memdata *md, void *X)
+allocmemimaged(Rectangle r, ulong chan, Memdata *md)
 {
 	int d;
 	ulong l;
 	Memimage *i;
 
-	if(Dx(r) <= 0 || Dy(r) <= 0){
-		werrstr("bad rectangle %R", r);
-		return nil;
-	}
 	if((d = chantodepth(chan)) == 0) {
 		werrstr("bad channel descriptor %.8lux", chan);
 		return nil;
 	}
+	if(badrect(r)){
+		werrstr("bad rectangle %R", r);
+		return nil;
+	}
 
 	l = wordsperline(r, d);
 
@@ -44,7 +44,6 @@
 	if(i == nil)
 		return nil;
 
-	i->X = X;
 	i->data = md;
 	i->zero = sizeof(ulong)*l*r.min.y;
 	
@@ -67,11 +66,11 @@
 }
 
 Memimage*
-_allocmemimage(Rectangle r, ulong chan)
+allocmemimage(Rectangle r, ulong chan)
 {
 	int d;
-	u32int l, nw;
 	uchar *p;
+	ulong l, nw;
 	Memdata *md;
 	Memimage *i;
 
@@ -79,8 +78,13 @@
 		werrstr("bad channel descriptor %.8lux", chan);
 		return nil;
 	}
+	if(badrect(r)){
+		werrstr("bad rectangle %R", r);
+		return nil;
+	}
 
 	l = wordsperline(r, d);
+
 	nw = l*Dy(r);
 	md = malloc(sizeof(Memdata));
 	if(md == nil)
@@ -104,7 +108,7 @@
 	md->bdata = p;
 	md->allocd = 1;
 
-	i = allocmemimaged(r, chan, md, nil);
+	i = allocmemimaged(r, chan, md);
 	if(i == nil){
 		poolfree(imagmem, md->base);
 		free(md);
@@ -115,11 +119,11 @@
 }
 
 void
-_freememimage(Memimage *i)
+freememimage(Memimage *i)
 {
 	if(i == nil)
 		return;
-	if(i->data->ref-- == 1 && i->data->allocd){
+	if(--i->data->ref == 0 && i->data->allocd){
 		if(i->data->base)
 			poolfree(imagmem, i->data->base);
 		free(i->data);
@@ -141,8 +145,7 @@
 {
 	uchar *a;
 
-	a = i->data->bdata+i->zero+sizeof(ulong)*p.y*i->width;
-
+	a = i->data->bdata+i->zero+(int)(sizeof(ulong)*p.y*i->width);
 	if(i->depth < 8){
 		/*
 		 * We need to always round down,
--- a/libmemdraw/arctest.c
+++ /dev/null
@@ -1,62 +1,0 @@
-#include <u.h>
-#include <libc.h>
-#include <draw.h>
-#include <memdraw.h>
-#include <memlayer.h>
-
-extern int drawdebug;
-void
-main(int argc, char **argv)
-{
-	char cc;
-	Memimage *x;
-	Point c = {208,871};
-	int a = 441;
-	int b = 441;
-	int thick = 0;
-	Point sp = {0,0};
-	int alpha = 51;
-	int phi = 3;
-	vlong t0, t1;
-	int i, n;
-	vlong del;
-
-	memimageinit();
-
-	x = allocmemimage(Rect(0,0,1000,1000), CMAP8);
-	n = atoi(argv[1]);
-
-	t0 = nsec();
-	t0 = nsec();
-	t0 = nsec();
-	t1 = nsec();
-	del = t1-t0;
-	t0 = nsec();
-	for(i=0; i<n; i++)
-		memarc(x, c, a, b, thick, memblack, sp, alpha, phi, SoverD);
-	t1 = nsec();
-	print("%lld %lld\n", t1-t0-del, del);
-}
-
-int drawdebug = 0;
-
-void
-rdb(void)
-{
-}
-
-int
-iprint(char *fmt, ...)
-{
-	int n;	
-	va_list va;
-	char buf[1024];
-
-	va_start(va, fmt);
-	n = doprint(buf, buf+sizeof buf, fmt, va) - buf;
-	va_end(va);
-
-	write(1,buf,n);
-	return 1;
-}
-
--- a/libmemdraw/cload.c
+++ b/libmemdraw/cload.c
@@ -4,12 +4,12 @@
 #include <memdraw.h>
 
 int
-_cloadmemimage(Memimage *i, Rectangle r, uchar *data, int ndata)
+cloadmemimage(Memimage *i, Rectangle r, uchar *data, int ndata)
 {
 	int y, bpl, c, cnt, offs;
 	uchar mem[NMEM], *memp, *omemp, *emem, *linep, *elinep, *u, *eu;
 
-	if(!rectinrect(r, i->r))
+	if(badrect(r) || !rectinrect(r, i->r))
 		return -1;
 	bpl = bytesperline(r, i->depth);
 	u = data;
--- a/libmemdraw/defont.c
+++ b/libmemdraw/defont.c
@@ -43,7 +43,7 @@
 	md->ref = 1;
 	md->allocd = 1;		/* so freememimage does free md */
 
-	i = allocmemimaged(r, drawld2chan[ld], md, nil);
+	i = allocmemimaged(r, drawld2chan[ld], md);
 	if(i == nil){
 		free(md);
 		return nil;
--- a/libmemdraw/draw.c
+++ b/libmemdraw/draw.c
@@ -4,7 +4,6 @@
 #include <memdraw.h>
 
 int drawdebug;
-static int	tablesbuilt;
 
 /* perfect approximation to NTSC = .299r+.587g+.114b when 0 ≤ r,g,b < 256 */
 #define RGB2K(r,g,b)	((156763*(r)+307758*(g)+59769*(b))>>19)
@@ -52,16 +51,14 @@
 
 int	_ifmt(Fmt*);
 
-void
-_memimageinit(void)
+int
+memimageinit(void)
 {
 	static int didinit = 0;
 
 	if(didinit)
-		return;
+		return 0;
 
-	didinit = 1;
-
 	mktables();
 	_memmkcmap();
 
@@ -69,34 +66,36 @@
 	fmtinstall('P', Pfmt);
 
 	memones = allocmemimage(Rect(0,0,1,1), GREY1);
+	memzeros = allocmemimage(Rect(0,0,1,1), GREY1);
+	if(memones == nil || memzeros == nil)
+		return -1;
+
 	memones->flags |= Frepl;
 	memones->clipr = Rect(-0x3FFFFFF, -0x3FFFFFF, 0x3FFFFFF, 0x3FFFFFF);
 	*byteaddr(memones, ZP) = ~0;
 
-	memzeros = allocmemimage(Rect(0,0,1,1), GREY1);
 	memzeros->flags |= Frepl;
 	memzeros->clipr = Rect(-0x3FFFFFF, -0x3FFFFFF, 0x3FFFFFF, 0x3FFFFFF);
 	*byteaddr(memzeros, ZP) = 0;
 
-	if(memones == nil || memzeros == nil)
-		assert(0 /*cannot initialize memimage library */);	/* RSC BUG */
-
 	memwhite = memones;
 	memblack = memzeros;
 	memopaque = memones;
 	memtransparent = memzeros;
+
+	didinit = 1;
+	return 0;
 }
 
-ulong _imgtorgba(Memimage*, ulong);
-ulong _rgbatoimg(Memimage*, ulong);
-ulong _pixelbits(Memimage*, Point);
+static ulong imgtorgba(Memimage*, ulong);
+static ulong rgbatoimg(Memimage*, ulong);
 
 #define DBG if(0)
-static Memdrawparam par;
-
-Memdrawparam*
-_memimagedrawsetup(Memimage *dst, Rectangle r, Memimage *src, Point p0, Memimage *mask, Point p1, int op)
+void
+memimagedraw(Memimage *dst, Rectangle r, Memimage *src, Point p0, Memimage *mask, Point p1, int op)
 {
+	static int n = 0;
+	Memdrawparam par;
 
 	if(mask == nil)
 		mask = memopaque;
@@ -106,13 +105,13 @@
 	if(drawclip(dst, &r, src, &p0, mask, &p1, &par.sr, &par.mr) == 0){
 //		if(drawdebug)
 //			iprint("empty clipped rectangle\n");
-		return nil;
+		return;
 	}
 
 	if(op < Clear || op > SoverD){
 //		if(drawdebug)
 //			iprint("op out of range: %d\n", op);
-		return nil;
+		return;
 	}
 
 	par.op = op;
@@ -127,13 +126,13 @@
 	if(src->flags&Frepl){
 		par.state |= Replsrc;
 		if(Dx(src->r)==1 && Dy(src->r)==1){
-			par.sval = _pixelbits(src, src->r.min);
+			par.sval = pixelbits(src, src->r.min);
 			par.state |= Simplesrc;
-			par.srgba = _imgtorgba(src, par.sval);
-			par.sdval = _rgbatoimg(dst, par.srgba);
+			par.srgba = imgtorgba(src, par.sval);
+			par.sdval = rgbatoimg(dst, par.srgba);
 			if((par.srgba&0xFF) == 0 && (op&DoutS)){
 //				if (drawdebug) iprint("fill with transparent source\n");
-				return nil;	/* no-op successfully handled */
+				return;	/* no-op successfully handled */
 			}
 		}
 	}
@@ -141,15 +140,15 @@
 	if(mask->flags & Frepl){
 		par.state |= Replmask;
 		if(Dx(mask->r)==1 && Dy(mask->r)==1){
-			par.mval = _pixelbits(mask, mask->r.min);
+			par.mval = pixelbits(mask, mask->r.min);
 			if(par.mval == 0 && (op&DoutS)){
 //				if(drawdebug) iprint("fill with zero mask\n");
-				return nil;	/* no-op successfully handled */
+				return;	/* no-op successfully handled */
 			}
 			par.state |= Simplemask;
 			if(par.mval == ~0)
 				par.state |= Fullmask;
-			par.mrgba = _imgtorgba(mask, par.mval);
+			par.mrgba = imgtorgba(mask, par.mval);
 		}
 	}
 
@@ -157,15 +156,6 @@
 //		iprint("dr %R sr %R mr %R...", r, par.sr, par.mr);
 DBG print("draw dr %R sr %R mr %R %lux\n", r, par.sr, par.mr, par.state);
 
-	return &par;
-}
-
-void
-_memimagedraw(Memdrawparam *par)
-{
-	if (par == nil)
-		return;
-
 	/*
 	 * Now that we've clipped the parameters down to be consistent, we 
 	 * simply try sub-drawing routines in order until we find one that was able
@@ -179,7 +169,7 @@
 	 * There could be an if around this checking to see if dst is in video memory.
 	 */
 DBG print("test hwdraw\n");
-	if(hwdraw(par)){
+	if(hwdraw(&par)){
 //if(drawdebug) iprint("hw handled\n");
 DBG print("hwdraw handled\n");
 		return;
@@ -188,7 +178,7 @@
 	 * Optimizations using memmove and memset.
 	 */
 DBG print("test memoptdraw\n");
-	if(memoptdraw(par)){
+	if(memoptdraw(&par)){
 //if(drawdebug) iprint("memopt handled\n");
 DBG print("memopt handled\n");
 		return;
@@ -199,7 +189,7 @@
 	 * Solid source color being painted through a boolean mask onto a high res image.
 	 */
 DBG print("test chardraw\n");
-	if(chardraw(par)){
+	if(chardraw(&par)){
 //if(drawdebug) iprint("chardraw handled\n");
 DBG print("chardraw handled\n");
 		return;
@@ -209,29 +199,28 @@
 	 * General calculation-laden case that does alpha for each pixel.
 	 */
 DBG print("do alphadraw\n");
-	alphadraw(par);
+	alphadraw(&par);
 //if(drawdebug) iprint("alphadraw handled\n");
 DBG print("alphadraw handled\n");
 }
 #undef DBG
 
+
 /*
  * Clip the destination rectangle further based on the properties of the 
  * source and mask rectangles.  Once the destination rectangle is properly
  * clipped, adjust the source and mask rectangles to be the same size.
- * Then if source or mask is replicated, move its clipped rectangle
- * so that its minimum point falls within the repl rectangle.
  *
  * Return zero if the final rectangle is null.
  */
 int
-drawclip(Memimage *dst, Rectangle *r, Memimage *src, Point *p0, Memimage *mask, Point *p1, Rectangle *sr, Rectangle *mr)
+drawclipnorepl(Memimage *dst, Rectangle *r, Memimage *src, Point *p0, Memimage *mask, Point *p1, Rectangle *sr, Rectangle *mr)
 {
 	Point rmin, delta;
 	int splitcoords;
 	Rectangle omr;
 
-	if(r->min.x>=r->max.x || r->min.y>=r->max.y)
+	if(badrect(*r))
 		return 0;
 	splitcoords = (p0->x!=p1->x) || (p0->y!=p1->y);
 	/* clip to destination */
@@ -272,15 +261,13 @@
 		sr->min.y += mr->min.y-omr.min.y;
 		sr->max.x += mr->max.x-omr.max.x;
 		sr->max.y += mr->max.y-omr.max.y;
-		*p1 = mr->min;
 	}else{
 		if(!(mask->flags&Frepl) && !rectclip(sr, mask->r))
 			return 0;
 		if(!rectclip(sr, mask->clipr))
 			return 0;
-		*p1 = sr->min;
+		*mr = *sr;
 	}
-
 	/* move source clipping back to destination */
 	delta.x = r->min.x - p0->x;
 	delta.y = r->min.y - p0->y;
@@ -288,7 +275,31 @@
 	r->min.y = sr->min.y + delta.y;
 	r->max.x = sr->max.x + delta.x;
 	r->max.y = sr->max.y + delta.y;
+	*p0 = sr->min;
+	*p1 = mr->min;
 
+	assert(Dx(*sr) == Dx(*mr) && Dx(*mr) == Dx(*r));
+	assert(Dy(*sr) == Dy(*mr) && Dy(*mr) == Dy(*r));
+	assert(ptinrect(r->min, dst->r));
+
+	return 1;
+}
+
+/*
+ * like drawclipnorepl() above, but if source or mask is replicated,
+ * move its clipped rectangle so that its minimum point falls within
+ * the repl rectangle.
+ *
+ * Return zero if the final rectangle is null.
+ */
+int
+drawclip(Memimage *dst, Rectangle *r, Memimage *src, Point *p0, Memimage *mask, Point *p1, Rectangle *sr, Rectangle *mr)
+{
+	Point delta;
+
+	if(!drawclipnorepl(dst, r, src, p0, mask, p1, sr, mr))
+		return 0;
+
 	/* move source rectangle so sr->min is in src->r */
 	if(src->flags&Frepl) {
 		delta.x = drawreplxy(src->r.min.x, src->r.max.x, sr->min.x) - sr->min.x;
@@ -297,8 +308,8 @@
 		sr->min.y += delta.y;
 		sr->max.x += delta.x;
 		sr->max.y += delta.y;
+		*p0 = sr->min;
 	}
-	*p0 = sr->min;
 
 	/* move mask point so it is in mask->r */
 	*p1 = drawrepl(mask->r, *p1);
@@ -306,11 +317,8 @@
 	mr->max.x = p1->x+Dx(*sr);
 	mr->max.y = p1->y+Dy(*sr);
 
-	assert(Dx(*sr) == Dx(*mr) && Dx(*mr) == Dx(*r));
-	assert(Dy(*sr) == Dy(*mr) && Dy(*mr) == Dy(*r));
 	assert(ptinrect(*p0, src->r));
 	assert(ptinrect(*p1, mask->r));
-	assert(ptinrect(r->min, dst->r));
 
 	return 1;
 }
@@ -357,13 +365,6 @@
 {
 	int i, j, mask, sh, small;
 		
-	if(tablesbuilt)
-		return;
-
-	fmtinstall('R', Rfmt);
-	fmtinstall('P', Pfmt);
-	tablesbuilt = 1;
-
 	/* bit replication up to 8 bits */
 	for(i=0; i<256; i++){
 		for(j=0; j<=8; j++){	/* j <= 8 [sic] */
@@ -396,7 +397,7 @@
 	uchar	*red;
 	uchar	*grn;
 	uchar	*blu;
-	uchar	*alpha;
+	uchar	*alpha;	/* is &ones when unused, never nil */
 	uchar	*grey;
 	ulong	*rgba;
 	int	delta;	/* number of bytes to add to pointer to get next pixel to the right */
@@ -456,7 +457,6 @@
 static uchar *drawbuf;
 static int	ndrawbuf;
 static int	mdrawbuf;
-static Param spar, mpar, dpar;	/* easier on the stacks */
 static Readfn	greymaskread, replread, readptr;
 static Writefn	nullwrite;
 static Calcfn	alphacalc0, alphacalc14, alphacalc2810, alphacalc3679, alphacalc5, alphacalc11, alphacalcS;
@@ -467,7 +467,8 @@
 static Writefn*	writefn(Memimage*);
 
 static Calcfn*	boolcopyfn(Memimage*, Memimage*);
-static Readfn*	convfn(Memimage*, Param*, Memimage*, Param*);
+static Readfn*	convfn(Memimage*, Param*, Memimage*, Param*, int*);
+static Readfn*	ptrfn(Memimage*);
 
 static Calcfn *alphacalc[Ncomp] = 
 {
@@ -501,59 +502,66 @@
 	boolcalc1011,		/* SoverD */
 };
 
-static int
-allocdrawbuf(void)
+/*
+ * Avoid standard Lock, QLock so that can be used in kernel.
+ */
+typedef struct Dbuf Dbuf;
+struct Dbuf
 {
 	uchar *p;
+	int n;
+	Param spar, mpar, dpar;
+	int inuse;
+};
+static Dbuf dbuf[10];
 
-	if(ndrawbuf > mdrawbuf){
-		p = realloc(drawbuf, ndrawbuf);
-		if(p == nil){
-			werrstr("memimagedraw out of memory");
-			return -1;
-		}
-		drawbuf = p;
-		mdrawbuf = ndrawbuf;
+static Dbuf*
+allocdbuf(void)
+{
+	int i;
+
+	for(i=0; i<nelem(dbuf); i++){
+		if(dbuf[i].inuse)
+			continue;
+		if(!tas(&dbuf[i].inuse))
+			return &dbuf[i];
 	}
-	return 0;
+	return nil;
 }
 
-static Param
-getparam(Memimage *img, Rectangle r, int convgrey, int needbuf)
+static void
+getparam(Param *p, Memimage *img, Rectangle r, int convgrey, int needbuf, int *ndrawbuf)
 {
-	Param p;
 	int nbuf;
 
-	memset(&p, 0, sizeof p);
+	memset(p, 0, sizeof *p);
 
-	p.img = img;
-	p.r = r;
-	p.dx = Dx(r);
-	p.needbuf = needbuf;
-	p.convgrey = convgrey;
+	p->img = img;
+	p->r = r;
+	p->dx = Dx(r);
+	p->needbuf = needbuf;
+	p->convgrey = convgrey;
 
 	assert(img->r.min.x <= r.min.x && r.min.x < img->r.max.x);
 
-	p.bytey0s = byteaddr(img, Pt(img->r.min.x, img->r.min.y));
-	p.bytermin = byteaddr(img, Pt(r.min.x, img->r.min.y));
-	p.bytey0e = byteaddr(img, Pt(img->r.max.x, img->r.min.y));
-	p.bwidth = sizeof(ulong)*img->width;
+	p->bytey0s = byteaddr(img, Pt(img->r.min.x, img->r.min.y));
+	p->bytermin = byteaddr(img, Pt(r.min.x, img->r.min.y));
+	p->bytey0e = byteaddr(img, Pt(img->r.max.x, img->r.min.y));
+	p->bwidth = sizeof(ulong)*img->width;
 
-	assert(p.bytey0s <= p.bytermin && p.bytermin <= p.bytey0e);
+	assert(p->bytey0s <= p->bytermin && p->bytermin <= p->bytey0e);
 
-	if(p.r.min.x == p.img->r.min.x)
-		assert(p.bytermin == p.bytey0s);
+	if(p->r.min.x == p->img->r.min.x)
+		assert(p->bytermin == p->bytey0s);
 
 	nbuf = 1;
 	if((img->flags&Frepl) && Dy(img->r) <= MAXBCACHE && Dy(img->r) < Dy(r)){
-		p.replcache = 1;
+		p->replcache = 1;
 		nbuf = Dy(img->r);
 	}
-	p.bufdelta = 4*p.dx;
-	p.bufoff = ndrawbuf;
-	ndrawbuf += p.bufdelta*nbuf;
-
-	return p;
+	p->bufdelta = 4*p->dx;
+	p->bufoff = *ndrawbuf;
+	*ndrawbuf += p->bufdelta*nbuf;
 }
 
 static void
@@ -578,19 +586,19 @@
 	print("%s", s);
 	for(i=0; i<n; i++){
 		print(" ");
-		if((p=b.grey)){
+		if(p=b.grey){
 			print(" k%.2uX", *p);
 			b.grey += b.delta;
 		}else{	
-			if((p=b.red)){
+			if(p=b.red){
 				print(" r%.2uX", *p);
 				b.red += b.delta;
 			}
-			if((p=b.grn)){
+			if(p=b.grn){
 				print(" g%.2uX", *p);
 				b.grn += b.delta;
 			}
-			if((p=b.blu)){
+			if(p=b.blu){
 				print(" b%.2uX", *p);
 				b.blu += b.delta;
 			}
@@ -624,7 +632,8 @@
 {
 	int isgrey, starty, endy, op;
 	int needbuf, dsty, srcy, masky;
-	int y, dir, dx, dy;
+	int y, dir, dx, dy, ndrawbuf;
+	uchar *drawbuf;
 	Buffer bsrc, bdst, bmask;
 	Readfn *rdsrc, *rdmask, *rddst;
 	Calcfn *calc;
@@ -631,12 +640,15 @@
 	Writefn *wrdst;
 	Memimage *src, *mask, *dst;
 	Rectangle r, sr, mr;
+	Dbuf *z;
 
 	r = par->r;
 	dx = Dx(r);
 	dy = Dy(r);
 
-	ndrawbuf = 0;
+	z = allocdbuf();
+	if(z == nil)
+		return 0;
 
 	src = par->src;
 	mask = par->mask;	
@@ -655,12 +667,13 @@
 	 */
 	needbuf = (src->data == dst->data);
 
-	spar = getparam(src, sr, isgrey, needbuf);
-	dpar = getparam(dst, r, isgrey, needbuf);
-	mpar = getparam(mask, mr, 0, needbuf);
+	ndrawbuf = 0;
+	getparam(&z->spar, src, sr, isgrey, needbuf, &ndrawbuf);
+	getparam(&z->dpar, dst, r, isgrey, needbuf, &ndrawbuf);
+	getparam(&z->mpar, mask, mr, 0, needbuf, &ndrawbuf);
 
 	dir = (needbuf && byteaddr(dst, r.min) > byteaddr(src, sr.min)) ? -1 : 1;
-	spar.dir = mpar.dir = dpar.dir = dir;
+	z->spar.dir = z->mpar.dir = z->dpar.dir = dir;
 
 	/*
 	 * If the mask is purely boolean, we can convert from src to dst format
@@ -680,7 +693,7 @@
 //if(drawdebug) iprint("flag %lud mchan %lux=?%x dd %d\n", src->flags&Falpha, mask->chan, GREY1, dst->depth);
 	if(!(src->flags&Falpha) && mask->chan == GREY1 && dst->depth >= 8 && op == SoverD){
 //if(drawdebug) iprint("boolcopy...");
-		rdsrc = convfn(dst, &dpar, src, &spar);
+		rdsrc = convfn(dst, &z->dpar, src, &z->spar, &ndrawbuf);
 		rddst = readptr;
 		rdmask = readfn(mask);
 		calc = boolcopyfn(dst, mask);
@@ -698,10 +711,10 @@
 		 */
 		if(mask->flags&Falpha){
 			rdmask = readalphafn(mask);
-			mpar.alphaonly = 1;
+			z->mpar.alphaonly = 1;
 		}else{
-			mpar.greymaskcall = readfn(mask);
-			mpar.convgrey = 1;
+			z->mpar.greymaskcall = readfn(mask);
+			z->mpar.convgrey = 1;
 			rdmask = greymaskread;
 
 			/*
@@ -723,17 +736,24 @@
 	 * If the image has a small enough repl rectangle,
 	 * we can just read each line once and cache them.
 	 */
-	if(spar.replcache){
-		spar.replcall = rdsrc;
+	if(z->spar.replcache){
+		z->spar.replcall = rdsrc;
 		rdsrc = replread;
 	}
-	if(mpar.replcache){
-		mpar.replcall = rdmask;
+	if(z->mpar.replcache){
+		z->mpar.replcall = rdmask;
 		rdmask = replread;
 	}
 
-	if(allocdrawbuf() < 0)
-		return 0;
+	if(z->n < ndrawbuf){
+		free(z->p);
+		if((z->p = mallocz(ndrawbuf, 0)) == nil){
+			z->inuse = 0;
+			return 0;
+		}
+		z->n = ndrawbuf;
+	}
+	drawbuf = z->p;
 
 	/*
 	 * Before we were saving only offsets from drawbuf in the parameter
@@ -740,10 +760,10 @@
 	 * structures; now that drawbuf has been grown to accomodate us,
 	 * we can fill in the pointers.
 	 */
-	spar.bufbase = drawbuf+spar.bufoff;
-	mpar.bufbase = drawbuf+mpar.bufoff;
-	dpar.bufbase = drawbuf+dpar.bufoff;
-	spar.convbuf = drawbuf+spar.convbufoff;
+	z->spar.bufbase = drawbuf+z->spar.bufoff;
+	z->mpar.bufbase = drawbuf+z->mpar.bufoff;
+	z->dpar.bufbase = drawbuf+z->dpar.bufoff;
+	z->spar.convbuf = drawbuf+z->spar.convbufoff;
 
 	if(dir == 1){
 		starty = 0;
@@ -771,18 +791,19 @@
 		clipy(dst, &dsty);
 		clipy(mask, &masky);
 
-		bsrc = rdsrc(&spar, spar.bufbase, srcy);
+		bsrc = rdsrc(&z->spar, z->spar.bufbase, srcy);
 DBG print("[");
-		bmask = rdmask(&mpar, mpar.bufbase, masky);
+		bmask = rdmask(&z->mpar, z->mpar.bufbase, masky);
 DBG print("]\n");
-		bdst = rddst(&dpar, dpar.bufbase, dsty);
+		bdst = rddst(&z->dpar, z->dpar.bufbase, dsty);
 DBG		dumpbuf("src", bsrc, dx);
 DBG		dumpbuf("mask", bmask, dx);
 DBG		dumpbuf("dst", bdst, dx);
 		bdst = calc(bdst, bsrc, bmask, dx, isgrey, op);
-		wrdst(&dpar, dpar.bytermin+dsty*dpar.bwidth, bdst);
+		wrdst(&z->dpar, z->dpar.bytermin+dsty*z->dpar.bwidth, bdst);
 	}
 
+	z->inuse = 0;
 	return 1;
 }
 #undef DBG
@@ -1344,7 +1365,7 @@
 DBG print("readnbit dx %d %p=%p+%d*%d, *r=%d fetch %d ", dx, r, p->bytermin, y, p->bwidth, *r, n);
 	bits = *r++;
 	nbits = 8;
-	if((i=x&(npack-1))){
+	if(i=x&(npack-1)){
 DBG print("throwaway %d...", i);
 		bits <<= depth*i;
 		nbits -= depth*i;
@@ -1376,7 +1397,7 @@
 DBG print("x=%d r=%p...", x, r);
 	bits = *r++;
 	nbits = 8;
-	if((i=x&(npack-1))){
+	if(i=x&(npack-1)){
 		bits <<= depth*i;
 		nbits -= depth*i;
 	}
@@ -1461,7 +1482,7 @@
 	end = p->bytey0e + y*p->bwidth;
 	cmap = p->img->cmap->cmap2rgb;
 	convgrey = p->convgrey;
-	copyalpha = (p->img->flags&Falpha) ? 1 : 0;
+	copyalpha = (p->img->flags&Falpha) != 0;
 
 	w = buf;
 	dx = p->dx;
@@ -1518,8 +1539,8 @@
 static void
 writecmap(Param *p, uchar *w, Buffer src)
 {
-	uchar *cmap, *red, *grn, *blu;
-	int i, dx, delta;
+	uchar *cmap, *red, *grn, *blu, *alpha;
+	int i, dx, delta, a, m;
 
 	cmap = p->img->cmap->rgb2cmap;
 	
@@ -1529,8 +1550,20 @@
 	blu = src.blu;
 
 	dx = p->dx;
-	for(i=0; i<dx; i++, red+=delta, grn+=delta, blu+=delta)
-		*w++ = cmap[(*red>>4)*256+(*grn>>4)*16+(*blu>>4)];
+	if(p->img->flags&Falpha){
+		alpha = src.alpha;
+		m = p->img->shift[CMap]/8;
+		a = p->img->shift[CAlpha]/8;
+		for(i=0; i<dx; i++, red+=delta, grn+=delta, blu+=delta, w+=2){
+			w[a] = *alpha;
+			if(alpha != &ones)
+				alpha+=delta;
+			w[m] = cmap[(*red>>4)*256+(*grn>>4)*16+(*blu>>4)];
+		}
+	} else {
+		for(i=0; i<dx; i++, red+=delta, grn+=delta, blu+=delta)
+			*w++ = cmap[(*red>>4)*256+(*grn>>4)*16+(*blu>>4)];
+	}
 }
 
 #define DBG if(0)
@@ -1556,7 +1589,7 @@
 	convgrey = p->convgrey;	/* convert rgb to grey */
 	isgrey = img->flags&Fgrey;
 	alphaonly = p->alphaonly;
-	copyalpha = (img->flags&Falpha) ? 1 : 0;
+	copyalpha = (img->flags&Falpha) != 0;
 
 DBG print("copyalpha %d alphaonly %d convgrey %d isgrey %d\n", copyalpha, alphaonly, convgrey, isgrey);
 	/* if we can, avoid processing everything */
@@ -1608,9 +1641,10 @@
 				*w++ = RGB2K(ured, ugrn, ublu);
 DBG print("%x\n", w[-1]);
 			}else{
-				*w++ = brepl[(u >> img->shift[CBlue]) & img->mask[CBlue]];
-				*w++ = grepl[(u >> img->shift[CGreen]) & img->mask[CGreen]];
-				*w++ = rrepl[(u >> img->shift[CRed]) & img->mask[CRed]];
+				w[0] = ublu;
+				w[1] = ugrn;
+				w[2] = ured;
+				w += 3;
 			}
 		}
 		r += nb;
@@ -1617,7 +1651,7 @@
 		if(r == end)
 			r = begin;
 	}
-	
+
 	b.alpha = copyalpha ? buf : &ones;
 	b.rgba = (ulong*)buf;
 	if(alphaonly){
@@ -1629,7 +1663,7 @@
 		b.grey = buf+copyalpha;
 		b.red = b.grn = b.blu = buf+copyalpha;
 		b.delta = copyalpha+1;
-DBG print("alpha %x grey %x\n", b.alpha ? *b.alpha : 0xFF, *b.grey);
+DBG print("alpha %x grey %x\n", *b.alpha, *b.grey);
 	}else{
 		b.blu = buf+copyalpha;
 		b.grn = buf+copyalpha+1;
@@ -1647,7 +1681,7 @@
 {
 	Memimage *img;
 	int i, isalpha, isgrey, nb, delta, dx, adelta;
-	uchar ff, *red, *grn, *blu, *grey, *alpha;
+	uchar *red, *grn, *blu, *grey, *alpha;
 	ulong u, mask;
 
 	img = p->img;
@@ -1661,18 +1695,45 @@
 	dx = p->dx;
 
 	nb = img->depth/8;
-	mask = (nb==4) ? 0 : ~((1<<img->depth)-1);
 
 	isalpha = img->flags&Falpha;
 	isgrey = img->flags&Fgrey;
 	adelta = src.delta;
 
-	if(isalpha && (alpha == nil || alpha == &ones)){
-		ff = 0xFF;
-		alpha = &ff;
+	if(isalpha && alpha == &ones)
 		adelta = 0;
+
+	if((img->flags&Fbytes) != 0){
+		int ogry, ored, ogrn, oblu, oalp;
+
+		ogry = img->shift[CGrey]/8;
+		ored = img->shift[CRed]/8;
+		ogrn = img->shift[CGreen]/8;
+		oblu = img->shift[CBlue]/8;
+		oalp = img->shift[CAlpha]/8;
+
+		for(i=0; i<dx; i++){
+			if(isgrey){
+				w[ogry] = *grey;
+				grey += delta;
+			} else {
+				w[ored] = *red;
+				w[ogrn] = *grn;
+				w[oblu] = *blu;
+				red += delta;
+				grn += delta;
+				blu += delta;
+			}
+			if(isalpha){
+				w[oalp] = *alpha;
+				alpha += adelta;
+			}
+			w += nb;
+		}
+		return;
 	}
 
+	mask = (nb==4) ? 0 : ~((1<<img->depth)-1);
 	for(i=0; i<dx; i++){
 		u = w[0] | (w[1]<<8) | (w[2]<<16) | (w[3]<<24);
 DBG print("u %.8lux...", u);
@@ -1729,7 +1790,7 @@
 {
 	if(img->depth < 8)
 		return writenbit;
-	if(img->chan == CMAP8)
+	if(img->nbits[CMap] == 8)
 		return writecmap;
 	return writebyte;
 }
@@ -1750,7 +1811,8 @@
 	USED(s);
 	q = p->bytermin + y*p->bwidth;
 	b.red = q;	/* ptr to data */
-	b.grn = b.blu = b.grey = b.alpha = nil;
+	b.grn = b.blu = b.grey = nil;
+	b.alpha = &ones;
 	b.rgba = (ulong*)q;
 	b.delta = p->img->depth/8;
 	return b;
@@ -1866,7 +1928,8 @@
 	}
 
 	b.red = buf;
-	b.blu = b.grn = b.grey = b.alpha = nil;
+	b.blu = b.grn = b.grey = nil;
+	b.alpha = &ones;
 	b.rgba = (ulong*)buf;
 	b.delta = 0;
 	
@@ -1874,7 +1937,7 @@
 }
 
 static Readfn*
-convfn(Memimage *dst, Param *dpar, Memimage *src, Param *spar)
+convfn(Memimage *dst, Param *dpar, Memimage *src, Param *spar, int *ndrawbuf)
 {
 	if(dst->chan == src->chan && !(src->flags&Frepl)){
 //if(drawdebug) iprint("readptr...");
@@ -1892,8 +1955,8 @@
 	spar->convdpar = dpar;
 
 	/* allocate a conversion buffer */
-	spar->convbufoff = ndrawbuf;
-	ndrawbuf += spar->dx*4;
+	spar->convbufoff = *ndrawbuf;
+	*ndrawbuf += spar->dx*4;
 
 	if(spar->dx > Dx(spar->img->r)){
 		spar->convdx = spar->dx;
@@ -1905,7 +1968,7 @@
 }
 
 ulong
-_pixelbits(Memimage *i, Point pt)
+pixelbits(Memimage *i, Point pt)
 {
 	uchar *p;
 	ulong val;
@@ -1965,24 +2028,18 @@
 
 /*
  * Optimized draw for filling and scrolling; uses memset and memmove.
- *
+ */
 static void
-memsetb(void *vp, uchar val, int n)
-{
-	uchar *p, *ep;
-
-	p = vp;
-	ep = p+n;
-	while(p<ep)
-		*p++ = val;
-}
-*/
-
-static void
 memsets(void *vp, ushort val, int n)
 {
 	ushort *p, *ep;
+	uchar b[2];
 
+	/* make little endian */
+	b[0] = val;
+	b[1] = val>>8;
+	val = *(ushort*)b;
+
 	p = vp;
 	ep = p+n;
 	while(p<ep)
@@ -1993,7 +2050,15 @@
 memsetl(void *vp, ulong val, int n)
 {
 	ulong *p, *ep;
+	uchar b[4];
 
+	/* make little endian */
+	b[0] = val;
+	b[1] = val>>8;
+	b[2] = val>>16;
+	b[3] = val>>24;
+	val = *(ulong*)b;
+
 	p = vp;
 	ep = p+n;
 	while(p<ep)
@@ -2006,20 +2071,22 @@
 	uchar *p, *ep;
 	uchar a,b,c;
 
-	p = vp;
-	ep = p+3*n;
 	a = val;
 	b = val>>8;
 	c = val>>16;
+
+	p = vp;
+	ep = p+3*n;
 	while(p<ep){
-		*p++ = a;
-		*p++ = b;
-		*p++ = c;
+		p[0] = a;
+		p[1] = b;
+		p[2] = c;
+		p += 3;
 	}
 }
 
-ulong
-_imgtorgba(Memimage *img, ulong val)
+static ulong
+imgtorgba(Memimage *img, ulong val)
 {
 	uchar r, g, b, a;
 	int nb, ov, v;
@@ -2057,9 +2124,9 @@
 			break;
 		case CMap:
 			p = img->cmap->cmap2rgb+3*ov;
-			r = *p++;
-			g = *p++;	
-			b = *p;
+			r = p[0];
+			g = p[1];
+			b = p[2];
 			break;
 		}
 	}
@@ -2066,8 +2133,8 @@
 	return (r<<24)|(g<<16)|(b<<8)|a;	
 }
 
-ulong
-_rgbatoimg(Memimage *img, ulong rgba)
+static ulong
+rgbatoimg(Memimage *img, ulong rgba)
 {
 	ulong chan;
 	int d, nb;
@@ -2133,9 +2200,8 @@
 	 */
 	m = Simplesrc|Simplemask|Fullmask;
 	if((par->state&m)==m && (par->srgba&0xFF) == 0xFF && (op ==S || op == SoverD)){
-		uchar *dp, p[4];
 		int d, dwid, ppb, np, nb;
-		uchar lm, rm;
+		uchar *dp, lm, rm;
 
 DBG print("memopt, dst %p, dst->data->bdata %p\n", dst, dst->data->bdata);
 		dwid = dst->width*sizeof(ulong);
@@ -2204,11 +2270,6 @@
 				memset(dp, v, dx);
 			return 1;
 		case 16:
-			p[0] = v;		/* make little endian */
-			p[1] = v>>8;
-			v = *(ushort*)p;
-DBG print("dp=%p; dx=%d; for(y=0; y<%d; y++, dp+=%d)\nmemsets(dp, v, dx);\n",
-	dp, dx, dy, dwid);
 			for(y=0; y<dy; y++, dp+=dwid)
 				memsets(dp, v, dx);
 			return 1;
@@ -2217,11 +2278,6 @@
 				memset24(dp, v, dx);
 			return 1;
 		case 32:
-			p[0] = v;		/* make little endian */
-			p[1] = v>>8;
-			p[2] = v>>16;
-			p[3] = v>>24;
-			v = *(ulong*)p;
 			for(y=0; y<dy; y++, dp+=dwid)
 				memsetl(dp, v, dx);
 			return 1;
@@ -2370,9 +2426,8 @@
 static int
 chardraw(Memdrawparam *par)
 {
-	ulong bits;
 	int i, ddepth, dy, dx, x, bx, ex, y, npack, bsh, depth, op;
-	ulong v, maskwid, dstwid;
+	ulong bits, v, maskwid, dstwid;
 	uchar *wp, *rp, *q, *wc;
 	ushort *ws;
 	ulong *wl;
@@ -2513,7 +2568,7 @@
 	bpp = src->depth;
 	uc <<= (src->r.min.x&(7/src->depth))*src->depth;
 	uc &= ~(0xFF>>bpp);
-	// pixel value is now in high part of byte. repeat throughout byte 
+	/* pixel value is now in high part of byte. repeat throughout byte 
 	val = uc;
 	for(i=bpp; i<8; i<<=1)
 		val |= val>>i;
@@ -2523,7 +2578,7 @@
  */
 
 void
-_memfillcolor(Memimage *i, ulong val)
+memfillcolor(Memimage *i, ulong val)
 {
 	ulong bits;
 	int d, y;
@@ -2531,7 +2586,7 @@
 	if(val == DNofill)
 		return;
 
-	bits = _rgbatoimg(i, val);
+	bits = rgbatoimg(i, val);
 	switch(i->depth){
 	case 24:	/* 24-bit images suck */
 		for(y=i->r.min.y; y<i->r.max.y; y++)
--- a/libmemdraw/drawtest.c
+++ /dev/null
@@ -1,1004 +1,0 @@
-#include <u.h>
-#include <libc.h>
-#include <bio.h>
-#include <draw.h>
-#include <memdraw.h>
-
-#define DBG if(0)
-#define RGB2K(r,g,b)	((299*((ulong)(r))+587*((ulong)(g))+114*((ulong)(b)))/1000)
-
-/*
- * This program tests the 'memimagedraw' primitive stochastically.
- * It tests the combination aspects of it thoroughly, but since the
- * three images it uses are disjoint, it makes no check of the
- * correct behavior when images overlap.  That is, however, much
- * easier to get right and to test.
- */
-
-void	drawonepixel(Memimage*, Point, Memimage*, Point, Memimage*, Point);
-void	verifyone(void);
-void	verifyline(void);
-void	verifyrect(void);
-void	verifyrectrepl(int, int);
-void putpixel(Memimage *img, Point pt, ulong nv);
-ulong rgbatopix(uchar, uchar, uchar, uchar);
-
-char *dchan, *schan, *mchan;
-int dbpp, sbpp, mbpp;
-
-int drawdebug=0;
-int	seed;
-int	niters = 100;
-int	dbpp;	/* bits per pixel in destination */
-int	sbpp;	/* bits per pixel in src */
-int	mbpp;	/* bits per pixel in mask */
-int	dpm;	/* pixel mask at high part of byte, in destination */
-int	nbytes;	/* in destination */
-
-int	Xrange	= 64;
-int	Yrange	= 8;
-
-Memimage	*dst;
-Memimage	*src;
-Memimage	*mask;
-Memimage	*stmp;
-Memimage	*mtmp;
-Memimage	*ones;
-uchar	*dstbits;
-uchar	*srcbits;
-uchar	*maskbits;
-ulong	*savedstbits;
-
-void
-rdb(void)
-{
-}
-
-int
-iprint(char *fmt, ...)
-{
-	int n;	
-	va_list va;
-	char buf[1024];
-
-	va_start(va, fmt);
-	n = doprint(buf, buf+sizeof buf, fmt, va) - buf;
-	va_end(va);
-
-	write(1,buf,n);
-	return 1;
-}
-
-void
-main(int argc, char *argv[])
-{
-	memimageinit();
-	seed = time(0);
-
-	ARGBEGIN{
-	case 'x':
-		Xrange = atoi(ARGF());
-		break;
-	case 'y':
-		Yrange = atoi(ARGF());
-		break;
-	case 'n':
-		niters = atoi(ARGF());
-		break;
-	case 's':
-		seed = atoi(ARGF());
-		break;
-	}ARGEND
-
-	dchan = "r8g8b8";
-	schan = "r8g8b8";
-	mchan = "r8g8b8";
-	switch(argc){
-	case 3:	mchan = argv[2];
-	case 2:	schan = argv[1];
-	case 1:	dchan = argv[0];
-	case 0:	break;
-	default:	goto Usage;
-	Usage:
-		fprint(2, "usage: dtest [dchan [schan [mchan]]]\n");
-		exits("usage");
-	}
-
-	fmtinstall('b', numbconv);	/* binary! */
-
-	fprint(2, "%s -x %d -y %d -s 0x%x %s %s %s\n", argv0, Xrange, Yrange, seed, dchan, schan, mchan);
-	srand(seed);
-
-	dst = allocmemimage(Rect(0, 0, Xrange, Yrange), strtochan(dchan));
-	src = allocmemimage(Rect(0, 0, Xrange, Yrange), strtochan(schan));
-	mask = allocmemimage(Rect(0, 0, Xrange, Yrange), strtochan(mchan));
-	stmp = allocmemimage(Rect(0, 0, Xrange, Yrange), strtochan(schan));
-	mtmp = allocmemimage(Rect(0, 0, Xrange, Yrange), strtochan(mchan));
-	ones = allocmemimage(Rect(0, 0, Xrange, Yrange), strtochan(mchan));
-//	print("chan %lux %lux %lux %lux %lux %lux\n", dst->chan, src->chan, mask->chan, stmp->chan, mtmp->chan, ones->chan);
-	if(dst==0 || src==0 || mask==0 || mtmp==0 || ones==0) {
-	Alloc:
-		fprint(2, "dtest: allocation failed: %r\n");
-		exits("alloc");
-	}
-	nbytes = (4*Xrange+4)*Yrange;
-	srcbits = malloc(nbytes);
-	dstbits = malloc(nbytes);
-	maskbits = malloc(nbytes);
-	savedstbits = malloc(nbytes);
-	if(dstbits==0 || srcbits==0 || maskbits==0 || savedstbits==0)
-		goto Alloc;
-	dbpp = dst->depth;
-	sbpp = src->depth;
-	mbpp = mask->depth;
-	dpm = 0xFF ^ (0xFF>>dbpp);
-	memset(ones->data->bdata, 0xFF, ones->width*sizeof(ulong)*Yrange);
-
-
-	fprint(2, "dtest: verify single pixel operation\n");
-	verifyone();
-
-	fprint(2, "dtest: verify full line non-replicated\n");
-	verifyline();
-
-	fprint(2, "dtest: verify full rectangle non-replicated\n");
-	verifyrect();
-
-	fprint(2, "dtest: verify full rectangle source replicated\n");
-	verifyrectrepl(1, 0);
-
-	fprint(2, "dtest: verify full rectangle mask replicated\n");
-	verifyrectrepl(0, 1);
-
-	fprint(2, "dtest: verify full rectangle source and mask replicated\n");
-	verifyrectrepl(1, 1);
-
-	exits(0);
-}
-
-/*
- * Dump out an ASCII representation of an image.  The label specifies
- * a list of characters to put at various points in the picture.
- */
-static void
-Bprintr5g6b5(Biobuf *bio, char*, ulong v)
-{
-	int r,g,b;
-	r = (v>>11)&31;
-	g = (v>>5)&63;
-	b = v&31;
-	Bprint(bio, "%.2x%.2x%.2x", r,g,b);
-}
-
-static void
-Bprintr5g5b5a1(Biobuf *bio, char*, ulong v)
-{
-	int r,g,b,a;
-	r = (v>>11)&31;
-	g = (v>>6)&31;
-	b = (v>>1)&31;
-	a = v&1;
-	Bprint(bio, "%.2x%.2x%.2x%.2x", r,g,b,a);
-}
-
-void
-dumpimage(char *name, Memimage *img, void *vdata, Point labelpt)
-{
-	Biobuf b;
-	uchar *data;
-	uchar *p;
-	char *arg;
-	void (*fmt)(Biobuf*, char*, ulong);
-	int npr, x, y, nb, bpp;
-	ulong v, mask;
-	Rectangle r;
-
-	fmt = nil;
-	arg = nil;
-	switch(img->depth){
-	case 1:
-	case 2:
-	case 4:
-		fmt = (void(*)(Biobuf*,char*,ulong))Bprint;
-		arg = "%.1ux";
-		break;
-	case 8:
-		fmt = (void(*)(Biobuf*,char*,ulong))Bprint;
-		arg = "%.2ux";
-		break;
-	case 16:
-		arg = nil;
-		if(img->chan == RGB16)
-			fmt = Bprintr5g6b5;
-		else{
-			fmt = (void(*)(Biobuf*,char*,ulong))Bprint;
-			arg = "%.4ux";
-		}
-		break;
-	case 24:
-		fmt = (void(*)(Biobuf*,char*,ulong))Bprint;
-		arg = "%.6lux";
-		break;
-	case 32:
-		fmt = (void(*)(Biobuf*,char*,ulong))Bprint;
-		arg = "%.8lux";
-		break;
-	}
-	if(fmt == nil){
-		fprint(2, "bad format\n");
-		abort();
-	}
-
-	r  = img->r;
-	Binit(&b, 2, OWRITE);
-	data = vdata;
-	bpp = img->depth;
-	Bprint(&b, "%s\t%d\tr %R clipr %R repl %d data %p *%P\n", name, r.min.x, r, img->clipr, (img->flags&Frepl) ? 1 : 0, vdata, labelpt);
-	mask = (1ULL<<bpp)-1;
-//	for(y=r.min.y; y<r.max.y; y++){
-	for(y=0; y<Yrange; y++){
-		nb = 0;
-		v = 0;
-		p = data+(byteaddr(img, Pt(0,y))-(uchar*)img->data->bdata);
-		Bprint(&b, "%-4d\t", y);
-//		for(x=r.min.x; x<r.max.x; x++){
-		for(x=0; x<Xrange; x++){
-			if(x==0)
-				Bprint(&b, "\t");
-
-			if(x != 0 && (x%8)==0)
-				Bprint(&b, " ");
-
-			npr = 0;
-			if(x==labelpt.x && y==labelpt.y){
-				Bprint(&b, "*");
-				npr++;
-			}
-			if(npr == 0)
-				Bprint(&b, " ");
-
-			while(nb < bpp){
-				v &= (1<<nb)-1;
-				v |= (ulong)(*p++) << nb;
-				nb += 8;
-			}
-			nb -= bpp;
-//			print("bpp %d v %.8lux mask %.8lux nb %d\n", bpp, v, mask, nb);
-			fmt(&b, arg, (v>>nb)&mask);
-		}
-		Bprint(&b, "\n");
-	}
-	Bterm(&b);
-}
-
-/*
- * Verify that the destination pixel has the specified value.
- * The value is in the high bits of v, suitably masked, but must
- * be extracted from the destination Memimage.
- */
-void
-checkone(Point p, Point sp, Point mp)
-{
-	int delta;
-	uchar *dp, *sdp;
-
-	delta = (uchar*)byteaddr(dst, p)-(uchar*)dst->data->bdata;
-	dp = (uchar*)dst->data->bdata+delta;
-	sdp = (uchar*)savedstbits+delta;
-
-	if(memcmp(dp, sdp, (dst->depth+7)/8) != 0) {
-		fprint(2, "dtest: one bad pixel drawing at dst %P from source %P mask %P\n", p, sp, mp);
-		fprint(2, " %.2ux %.2ux %.2ux %.2ux should be %.2ux %.2ux %.2ux %.2ux\n",
-			dp[0], dp[1], dp[2], dp[3], sdp[0], sdp[1], sdp[2], sdp[3]);
-		fprint(2, "addresses dst %p src %p mask %p\n", dp, byteaddr(src, sp), byteaddr(mask, mp));
-		dumpimage("src", src, src->data->bdata, sp);
-		dumpimage("mask", mask, mask->data->bdata, mp);
-		dumpimage("origdst", dst, dstbits, p);
-		dumpimage("dst", dst, dst->data->bdata, p);
-		dumpimage("gooddst", dst, savedstbits, p);
-		abort();
-	}
-}
-
-/*
- * Verify that the destination line has the same value as the saved line.
- */
-#define RECTPTS(r) (r).min.x, (r).min.y, (r).max.x, (r).max.y
-void
-checkline(Rectangle r, Point sp, Point mp, int y, Memimage *stmp, Memimage *mtmp)
-{
-	ulong *dp;
-	int nb;
-	ulong *saved;
-
-	dp = wordaddr(dst, Pt(0, y));
-	saved = savedstbits + y*dst->width;
-	if(dst->depth < 8)
-		nb = Xrange/(8/dst->depth);
-	else
-		nb = Xrange*(dst->depth/8);
-	if(memcmp(dp, saved, nb) != 0){
-		fprint(2, "dtest: bad line at y=%d; saved %p dp %p\n", y, saved, dp);
-		fprint(2, "draw dst %R src %P mask %P\n", r, sp, mp);
-		dumpimage("src", src, src->data->bdata, sp);
-		if(stmp) dumpimage("stmp", stmp, stmp->data->bdata, sp);
-		dumpimage("mask", mask, mask->data->bdata, mp);
-		if(mtmp) dumpimage("mtmp", mtmp, mtmp->data->bdata, mp);
-		dumpimage("origdst", dst, dstbits, r.min);
-		dumpimage("dst", dst, dst->data->bdata, r.min);
-		dumpimage("gooddst", dst, savedstbits, r.min);
-		abort();
-	}
-}
-
-/*
- * Fill the bits of an image with random data.
- * The Memimage parameter is used only to make sure
- * the data is well formatted: only ucbits is written.
- */
-void
-fill(Memimage *img, uchar *ucbits)
-{
-	int i, x, y;
-	ushort *up;
-	uchar alpha, r, g, b;
-	void *data;
-
-	if((img->flags&Falpha) == 0){
-		up = (ushort*)ucbits;
-		for(i=0; i<nbytes/2; i++)
-			*up++ = lrand() >> 7;
-		if(i+i != nbytes)
-			*(uchar*)up = lrand() >> 7;
-	}else{
-		data = img->data->bdata;
-		img->data->bdata = ucbits;
-
-		for(x=img->r.min.x; x<img->r.max.x; x++)
-		for(y=img->r.min.y; y<img->r.max.y; y++){
-			alpha = rand() >> 4;
-			r = rand()%(alpha+1);
-			g = rand()%(alpha+1);
-			b = rand()%(alpha+1);
-			putpixel(img, Pt(x,y), rgbatopix(r,g,b,alpha));
-		}
-		img->data->bdata = data;
-	}
-		
-}
-
-/*
- * Mask is preset; do the rest
- */
-void
-verifyonemask(void)
-{
-	Point dp, sp, mp;
-
-	fill(dst, dstbits);
-	fill(src, srcbits);
-	memmove(dst->data->bdata, dstbits, dst->width*sizeof(ulong)*Yrange);
-	memmove(src->data->bdata, srcbits, src->width*sizeof(ulong)*Yrange);
-	memmove(mask->data->bdata, maskbits, mask->width*sizeof(ulong)*Yrange);
-
-	dp.x = nrand(Xrange);
-	dp.y = nrand(Yrange);
-
-	sp.x = nrand(Xrange);
-	sp.y = nrand(Yrange);
-
-	mp.x = nrand(Xrange);
-	mp.y = nrand(Yrange);
-
-	drawonepixel(dst, dp, src, sp, mask, mp);
-	memmove(mask->data->bdata, maskbits, mask->width*sizeof(ulong)*Yrange);
-	memmove(savedstbits, dst->data->bdata, dst->width*sizeof(ulong)*Yrange);
-	
-	memmove(dst->data->bdata, dstbits, dst->width*sizeof(ulong)*Yrange);
-	memimagedraw(dst, Rect(dp.x, dp.y, dp.x+1, dp.y+1), src, sp, mask, mp, SoverD);
-	memmove(mask->data->bdata, maskbits, mask->width*sizeof(ulong)*Yrange);
-
-	checkone(dp, sp, mp);
-}
-
-void
-verifyone(void)
-{
-	int i;
-
-	/* mask all zeros */
-	memset(maskbits, 0, nbytes);
-	for(i=0; i<niters; i++)
-		verifyonemask();
-
-	/* mask all ones */
-	memset(maskbits, 0xFF, nbytes);
-	for(i=0; i<niters; i++)
-		verifyonemask();
-
-	/* random mask */
-	for(i=0; i<niters; i++){
-		fill(mask, maskbits);
-		verifyonemask();
-	}
-}
-
-/*
- * Mask is preset; do the rest
- */
-void
-verifylinemask(void)
-{
-	Point sp, mp, tp, up;
-	Rectangle dr;
-	int x;
-
-	fill(dst, dstbits);
-	fill(src, srcbits);
-	memmove(dst->data->bdata, dstbits, dst->width*sizeof(ulong)*Yrange);
-	memmove(src->data->bdata, srcbits, src->width*sizeof(ulong)*Yrange);
-	memmove(mask->data->bdata, maskbits, mask->width*sizeof(ulong)*Yrange);
-
-	dr.min.x = nrand(Xrange-1);
-	dr.min.y = nrand(Yrange-1);
-	dr.max.x = dr.min.x + 1 + nrand(Xrange-1-dr.min.x);
-	dr.max.y = dr.min.y + 1;
-
-	sp.x = nrand(Xrange);
-	sp.y = nrand(Yrange);
-
-	mp.x = nrand(Xrange);
-	mp.y = nrand(Yrange);
-
-	tp = sp;
-	up = mp;
-	for(x=dr.min.x; x<dr.max.x && tp.x<Xrange && up.x<Xrange; x++,tp.x++,up.x++)
-		memimagedraw(dst, Rect(x, dr.min.y, x+1, dr.min.y+1), src, tp, mask, up, SoverD);
-	memmove(savedstbits, dst->data->bdata, dst->width*sizeof(ulong)*Yrange);
-
-	memmove(dst->data->bdata, dstbits, dst->width*sizeof(ulong)*Yrange);
-
-	memimagedraw(dst, dr, src, sp, mask, mp, SoverD);
-	checkline(dr, drawrepl(src->r, sp), drawrepl(mask->r, mp), dr.min.y, nil, nil);
-}
-
-void
-verifyline(void)
-{
-	int i;
-
-	/* mask all ones */
-	memset(maskbits, 0xFF, nbytes);
-	for(i=0; i<niters; i++)
-		verifylinemask();
-
-	/* mask all zeros */
-	memset(maskbits, 0, nbytes);
-	for(i=0; i<niters; i++)
-		verifylinemask();
-
-	/* random mask */
-	for(i=0; i<niters; i++){
-		fill(mask, maskbits);
-		verifylinemask();
-	}
-}
-
-/*
- * Mask is preset; do the rest
- */
-void
-verifyrectmask(void)
-{
-	Point sp, mp, tp, up;
-	Rectangle dr;
-	int x, y;
-
-	fill(dst, dstbits);
-	fill(src, srcbits);
-	memmove(dst->data->bdata, dstbits, dst->width*sizeof(ulong)*Yrange);
-	memmove(src->data->bdata, srcbits, src->width*sizeof(ulong)*Yrange);
-	memmove(mask->data->bdata, maskbits, mask->width*sizeof(ulong)*Yrange);
-
-	dr.min.x = nrand(Xrange-1);
-	dr.min.y = nrand(Yrange-1);
-	dr.max.x = dr.min.x + 1 + nrand(Xrange-1-dr.min.x);
-	dr.max.y = dr.min.y + 1 + nrand(Yrange-1-dr.min.y);
-
-	sp.x = nrand(Xrange);
-	sp.y = nrand(Yrange);
-
-	mp.x = nrand(Xrange);
-	mp.y = nrand(Yrange);
-
-	tp = sp;
-	up = mp;
-	for(y=dr.min.y; y<dr.max.y && tp.y<Yrange && up.y<Yrange; y++,tp.y++,up.y++){
-		for(x=dr.min.x; x<dr.max.x && tp.x<Xrange && up.x<Xrange; x++,tp.x++,up.x++)
-			memimagedraw(dst, Rect(x, y, x+1, y+1), src, tp, mask, up, SoverD);
-		tp.x = sp.x;
-		up.x = mp.x;
-	}
-	memmove(savedstbits, dst->data->bdata, dst->width*sizeof(ulong)*Yrange);
-
-	memmove(dst->data->bdata, dstbits, dst->width*sizeof(ulong)*Yrange);
-
-	memimagedraw(dst, dr, src, sp, mask, mp, SoverD);
-	for(y=0; y<Yrange; y++)
-		checkline(dr, drawrepl(src->r, sp), drawrepl(mask->r, mp), y, nil, nil);
-}
-
-void
-verifyrect(void)
-{
-	int i;
-
-	/* mask all zeros */
-	memset(maskbits, 0, nbytes);
-	for(i=0; i<niters; i++)
-		verifyrectmask();
-
-	/* mask all ones */
-	memset(maskbits, 0xFF, nbytes);
-	for(i=0; i<niters; i++)
-		verifyrectmask();
-
-	/* random mask */
-	for(i=0; i<niters; i++){
-		fill(mask, maskbits);
-		verifyrectmask();
-	}
-}
-
-Rectangle
-randrect(void)
-{
-	Rectangle r;
-
-	r.min.x = nrand(Xrange-1);
-	r.min.y = nrand(Yrange-1);
-	r.max.x = r.min.x + 1 + nrand(Xrange-1-r.min.x);
-	r.max.y = r.min.y + 1 + nrand(Yrange-1-r.min.y);
-	return r;
-}
-
-/*
- * Return coordinate corresponding to x withing range [minx, maxx)
- */
-int
-tilexy(int minx, int maxx, int x)
-{
-	int sx;
-
-	sx = (x-minx) % (maxx-minx);
-	if(sx < 0)
-		sx += maxx-minx;
-	return sx+minx;
-}
-
-void
-replicate(Memimage *i, Memimage *tmp)
-{
-	Rectangle r, r1;
-	int x, y, nb;
-
-	/* choose the replication window (i->r) */
-	r.min.x = nrand(Xrange-1);
-	r.min.y = nrand(Yrange-1);
-	/* make it trivial more often than pure chance allows */
-	switch(lrand()&0){
-	case 1:
-		r.max.x = r.min.x + 2;
-		r.max.y = r.min.y + 2;
-		if(r.max.x < Xrange && r.max.y < Yrange)
-			break;
-		/* fall through */
-	case 0:
-		r.max.x = r.min.x + 1;
-		r.max.y = r.min.y + 1;
-		break;
-	default:
-		if(r.min.x+3 >= Xrange)
-			r.max.x = Xrange;
-		else
-			r.max.x = r.min.x+3 + nrand(Xrange-(r.min.x+3));
-
-		if(r.min.y+3 >= Yrange)
-			r.max.y = Yrange;
-		else
-			r.max.y = r.min.y+3 + nrand(Yrange-(r.min.y+3));
-	}
-	assert(r.min.x >= 0);	
-	assert(r.max.x <= Xrange);
-	assert(r.min.y >= 0);
-	assert(r.max.y <= Yrange);
-	/* copy from i to tmp so we have just the replicated bits */
-	nb = tmp->width*sizeof(ulong)*Yrange;
-	memset(tmp->data->bdata, 0, nb);
-	memimagedraw(tmp, r, i, r.min, ones, r.min, SoverD);
-	memmove(i->data->bdata, tmp->data->bdata, nb);
-	/* i is now a non-replicated instance of the replication */
-	/* replicate it by hand through tmp */
-	memset(tmp->data->bdata, 0, nb);
-	x = -(tilexy(r.min.x, r.max.x, 0)-r.min.x);
-	for(; x<Xrange; x+=Dx(r)){
-		y = -(tilexy(r.min.y, r.max.y, 0)-r.min.y);
-		for(; y<Yrange; y+=Dy(r)){
-			/* set r1 to instance of tile by translation */
-			r1.min.x = x;
-			r1.min.y = y;
-			r1.max.x = r1.min.x+Dx(r);
-			r1.max.y = r1.min.y+Dy(r);
-			memimagedraw(tmp, r1, i, r.min, ones, r.min, SoverD);
-		}
-	}
-	i->flags |= Frepl;
-	i->r = r;
-	i->clipr = randrect();
-//	fprint(2, "replicate [[%d %d] [%d %d]] [[%d %d][%d %d]]\n", r.min.x, r.min.y, r.max.x, r.max.y,
-//		i->clipr.min.x, i->clipr.min.y, i->clipr.max.x, i->clipr.max.y);
-	tmp->clipr = i->clipr;
-}
-
-/*
- * Mask is preset; do the rest
- */
-void
-verifyrectmaskrepl(int srcrepl, int maskrepl)
-{
-	Point sp, mp, tp, up;
-	Rectangle dr;
-	int x, y;
-	Memimage *s, *m;
-
-//	print("verfrect %d %d\n", srcrepl, maskrepl);
-	src->flags &= ~Frepl;
-	src->r = Rect(0, 0, Xrange, Yrange);
-	src->clipr = src->r;
-	stmp->flags &= ~Frepl;
-	stmp->r = Rect(0, 0, Xrange, Yrange);
-	stmp->clipr = src->r;
-	mask->flags &= ~Frepl;
-	mask->r = Rect(0, 0, Xrange, Yrange);
-	mask->clipr = mask->r;
-	mtmp->flags &= ~Frepl;
-	mtmp->r = Rect(0, 0, Xrange, Yrange);
-	mtmp->clipr = mask->r;
-
-	fill(dst, dstbits);
-	fill(src, srcbits);
-
-	memmove(dst->data->bdata, dstbits, dst->width*sizeof(ulong)*Yrange);
-	memmove(src->data->bdata, srcbits, src->width*sizeof(ulong)*Yrange);
-	memmove(mask->data->bdata, maskbits, mask->width*sizeof(ulong)*Yrange);
-
-	if(srcrepl){
-		replicate(src, stmp);
-		s = stmp;
-	}else
-		s = src;
-	if(maskrepl){
-		replicate(mask, mtmp);
-		m = mtmp;
-	}else
-		m = mask;
-
-	dr = randrect();
-
-	sp.x = nrand(Xrange);
-	sp.y = nrand(Yrange);
-
-	mp.x = nrand(Xrange);
-	mp.y = nrand(Yrange);
-
-DBG	print("smalldraws\n");
-	for(tp.y=sp.y,up.y=mp.y,y=dr.min.y; y<dr.max.y && tp.y<Yrange && up.y<Yrange; y++,tp.y++,up.y++)
-		for(tp.x=sp.x,up.x=mp.x,x=dr.min.x; x<dr.max.x && tp.x<Xrange && up.x<Xrange; x++,tp.x++,up.x++)
-			memimagedraw(dst, Rect(x, y, x+1, y+1), s, tp, m, up, SoverD);
-	memmove(savedstbits, dst->data->bdata, dst->width*sizeof(ulong)*Yrange);
-
-	memmove(dst->data->bdata, dstbits, dst->width*sizeof(ulong)*Yrange);
-
-DBG	print("bigdraw\n");
-	memimagedraw(dst, dr, src, sp, mask, mp, SoverD);
-	for(y=0; y<Yrange; y++)
-		checkline(dr, drawrepl(src->r, sp), drawrepl(mask->r, mp), y, srcrepl?stmp:nil, maskrepl?mtmp:nil);
-}
-
-void
-verifyrectrepl(int srcrepl, int maskrepl)
-{
-	int i;
-
-	/* mask all ones */
-	memset(maskbits, 0xFF, nbytes);
-	for(i=0; i<niters; i++)
-		verifyrectmaskrepl(srcrepl, maskrepl);
-
-	/* mask all zeros */
-	memset(maskbits, 0, nbytes);
-	for(i=0; i<niters; i++)
-		verifyrectmaskrepl(srcrepl, maskrepl);
-
-	/* random mask */
-	for(i=0; i<niters; i++){
-		fill(mask, maskbits);
-		verifyrectmaskrepl(srcrepl, maskrepl);
-	}
-}
-
-/*
- * Trivial draw implementation.
- * Color values are passed around as ulongs containing ααRRGGBB
- */
-
-/*
- * Convert v, which is nhave bits wide, into its nwant bits wide equivalent.
- * Replicates to widen the value, truncates to narrow it.
- */
-ulong
-replbits(ulong v, int nhave, int nwant)
-{
-	v &= (1<<nhave)-1;
-	for(; nhave<nwant; nhave*=2)
-		v |= v<<nhave;
-	v >>= (nhave-nwant);
-	return v & ((1<<nwant)-1);
-}
-
-/*
- * Decode a pixel into the uchar* values.
- */
-void
-pixtorgba(ulong v, uchar *r, uchar *g, uchar *b, uchar *a)
-{
-	*a = v>>24;
-	*r = v>>16;
-	*g = v>>8;
-	*b = v;
-}
-
-/*
- * Convert uchar channels into ulong pixel.
- */
-ulong
-rgbatopix(uchar r, uchar g, uchar b, uchar a)
-{
-	return (a<<24)|(r<<16)|(g<<8)|b;
-}
-
-/*
- * Retrieve the pixel value at pt in the image.
- */
-ulong
-getpixel(Memimage *img, Point pt)
-{
-	uchar r, g, b, a, *p;
-	int nbits, npack, bpp;
-	ulong v, c, rbits, bits;
-
-	r = g = b = 0;
-	a = ~0;	/* default alpha is full */
-
-	p = byteaddr(img, pt);
-	v = p[0]|(p[1]<<8)|(p[2]<<16)|(p[3]<<24);
-	bpp = img->depth;
-	if(bpp<8){
-		/*
-		 * Sub-byte greyscale pixels.
-		 *
-		 * We want to throw away the top pt.x%npack pixels and then use the next bpp bits
-		 * in the bottom byte of v.  This madness is due to having big endian bits
-		 * but little endian bytes.
-		 */
-		npack = 8/bpp;
-		v >>= 8 - bpp*(pt.x%npack+1);
-		v &= (1<<bpp)-1;
-		r = g = b = replbits(v, bpp, 8);
-	}else{
-		/*
-		 * General case.  We need to parse the channel descriptor and do what it says.
-		 * In all channels but the color map, we replicate to 8 bits because that's the
-		 * precision that all calculations are done at.
-		 *
-		 * In the case of the color map, we leave the bits alone, in case a color map
-		 * with less than 8 bits of index is used.  This is currently disallowed, so it's
-		 * sort of silly.
-		 */
-
-		for(c=img->chan; c; c>>=8){
-			nbits = NBITS(c);
-			bits = v & ((1<<nbits)-1);
-			rbits = replbits(bits, nbits, 8);
-			v >>= nbits;
-			switch(TYPE(c)){
-			case CRed:
-				r = rbits;
-				break;
-			case CGreen:
-				g = rbits;
-				break;
-			case CBlue:
-				b = rbits;
-				break;
-			case CGrey:
-				r = g = b = rbits;
-				break;
-			case CAlpha:
-				a = rbits;
-				break;
-			case CMap:
-				p = img->cmap->cmap2rgb + 3*bits;
-				r = p[0];
-				g = p[1];
-				b = p[2];
-				break;
-			case CIgnore:
-				break;
-			default:
-				fprint(2, "unknown channel type %lud\n", TYPE(c));
-				abort();
-			}
-		}
-	}
-	return rgbatopix(r, g, b, a);
-}
-
-/*
- * Return the greyscale equivalent of a pixel.
- */
-uchar
-getgrey(Memimage *img, Point pt)
-{
-	uchar r, g, b, a;
-	pixtorgba(getpixel(img, pt), &r, &g, &b, &a);
-	return RGB2K(r, g, b);
-}
-
-/*
- * Return the value at pt in image, if image is interpreted
- * as a mask.  This means the alpha channel if present, else
- * the greyscale or its computed equivalent.
- */
-uchar
-getmask(Memimage *img, Point pt)
-{
-	if(img->flags&Falpha)
-		return getpixel(img, pt)>>24;
-	else
-		return getgrey(img, pt);
-}
-#undef DBG
-
-#define DBG if(0)
-/*
- * Write a pixel to img at point pt.
- * 
- * We do this by reading a 32-bit little endian
- * value from p and then writing it back
- * after tweaking the appropriate bits.  Because
- * the data is little endian, we don't have to worry
- * about what the actual depth is, as long as it is
- * less than 32 bits.
- */
-void
-putpixel(Memimage *img, Point pt, ulong nv)
-{
-	uchar r, g, b, a, *p, *q;
-	ulong c, mask, bits, v;
-	int bpp, sh, npack, nbits;
-
-	pixtorgba(nv, &r, &g, &b, &a);
-
-	p = byteaddr(img, pt);
-	v = p[0]|(p[1]<<8)|(p[2]<<16)|(p[3]<<24);
-	bpp = img->depth;
-DBG print("v %.8lux...", v);
-	if(bpp < 8){
-		/*
-		 * Sub-byte greyscale pixels.  We need to skip the leftmost pt.x%npack pixels,
-		 * which is equivalent to skipping the rightmost npack - pt.x%npack - 1 pixels.
-		 */	
-		npack = 8/bpp;
-		sh = bpp*(npack - pt.x%npack - 1);
-		bits = RGB2K(r,g,b);
-DBG print("repl %lux 8 %d = %lux...", bits, bpp, replbits(bits, 8, bpp));
-		bits = replbits(bits, 8, bpp);
-		mask = (1<<bpp)-1;
-DBG print("bits %lux mask %lux sh %d...", bits, mask, sh);
-		mask <<= sh;
-		bits <<= sh;
-DBG print("(%lux & %lux) | (%lux & %lux)", v, ~mask, bits, mask);
-		v = (v & ~mask) | (bits & mask);
-	} else {
-		/*
-		 * General case.  We need to parse the channel descriptor again.
-		 */
-		sh = 0;
-		for(c=img->chan; c; c>>=8){
-			nbits = NBITS(c);
-			switch(TYPE(c)){
-			case CRed:
-				bits = r;
-				break;
-			case CGreen:
-				bits = g;
-				break;
-			case CBlue:
-				bits = b;
-				break;
-			case CGrey:
-				bits = RGB2K(r, g, b);
-				break;
-			case CAlpha:
-				bits = a;
-				break;
-			case CIgnore:
-				bits = 0;
-				break;
-			case CMap:
-				q = img->cmap->rgb2cmap;
-				bits = q[(r>>4)*16*16+(g>>4)*16+(b>>4)];
-				break;
-			default:
-				SET(bits);
-				fprint(2, "unknown channel type %lud\n", TYPE(c));
-				abort();
-			}
-
-DBG print("repl %lux 8 %d = %lux...", bits, nbits, replbits(bits, 8, nbits));
-			if(TYPE(c) != CMap)
-				bits = replbits(bits, 8, nbits);
-			mask = (1<<nbits)-1;
-DBG print("bits %lux mask %lux sh %d...", bits, mask, sh);
-			bits <<= sh;
-			mask <<= sh;
-			v = (v & ~mask) | (bits & mask);
-			sh += nbits;
-		}
-	}
-DBG print("v %.8lux\n", v);
-	p[0] = v;
-	p[1] = v>>8;
-	p[2] = v>>16;
-	p[3] = v>>24;	
-}
-#undef DBG
-
-#define DBG if(0)
-void
-drawonepixel(Memimage *dst, Point dp, Memimage *src, Point sp, Memimage *mask, Point mp)
-{
-	uchar m, M, sr, sg, sb, sa, sk, dr, dg, db, da, dk;
-
-	pixtorgba(getpixel(dst, dp), &dr, &dg, &db, &da);
-	pixtorgba(getpixel(src, sp), &sr, &sg, &sb, &sa);
-	m = getmask(mask, mp);
-	M = 255-(sa*m)/255;
-
-DBG print("dst %x %x %x %x src %x %x %x %x m %x = ", dr,dg,db,da, sr,sg,sb,sa, m);
-	if(dst->flags&Fgrey){
-		/*
-		 * We need to do the conversion to grey before the alpha calculation
-		 * because the draw operator does this, and we need to be operating
-		 * at the same precision so we get exactly the same answers.
-		 */
-		sk = RGB2K(sr, sg, sb);
-		dk = RGB2K(dr, dg, db);
-		dk = (sk*m + dk*M)/255;
-		dr = dg = db = dk;
-		da = (sa*m + da*M)/255;
-	}else{
-		/*
-		 * True color alpha calculation treats all channels (including alpha)
-		 * the same.  It might have been nice to use an array, but oh well.
-		 */
-		dr = (sr*m + dr*M)/255;
-		dg = (sg*m + dg*M)/255;
-		db = (sb*m + db*M)/255;
-		da = (sa*m + da*M)/255;
-	}
-
-DBG print("%x %x %x %x\n", dr,dg,db,da);
-	putpixel(dst, dp, rgbatopix(dr, dg, db, da));
-}
--- a/libmemdraw/ellipse.c
+++ b/libmemdraw/ellipse.c
@@ -124,7 +124,7 @@
 	p.op = op;
 
 	u = (t<<1)*(a-b);
-	if((b<a && u>b*b) || (a<b && -u>a*a)) {
+	if(b<a && u>b*b || a<b && -u>a*a) {
 /*	if(b<a&&(t<<1)>b*b/a || a<b&&(t<<1)>a*a/b)	# very thick */
 		bellipse(b, newstate(&in, a, b), &p);
 		return;
@@ -209,7 +209,7 @@
 {
 	Rectangle r;
 
-/*	print("R %d,%d %d,%d\n", x0, y0, x1, y1); */
+/*	print("R %d,%d %d,%d\n", x0, y0, x1, y1); /**/
 	r = Rect(p->c.x+x0, p->c.y+y0, p->c.x+x1+1, p->c.y+y1+1);
 	memdraw(p->dst, r, p->src, addpt(p->sp, r.min), memopaque, p00, p->op);
 }
@@ -224,7 +224,7 @@
 	Point p0;
 	Rectangle r;
 
-/*	print("P%d %d,%d\n", p->t, x, y);	*/
+/*	print("P%d %d,%d\n", p->t, x, y);	/**/
 	p0 = Pt(p->c.x+x, p->c.y+y);
 	r = Rpt(addpt(p0, p->disc->r.min), addpt(p0, p->disc->r.max));
 	memdraw(p->dst, r, p->src, addpt(p->sp, r.min), p->disc, p->disc->r.min, p->op);
@@ -237,7 +237,7 @@
 void
 eline(int x0, int y0, int x1, int y1, Param *p)
 {
-/*	print("L%d %d,%d %d,%d\n", p->t, x0, y0, x1, y1); */
+/*	print("L%d %d,%d %d,%d\n", p->t, x0, y0, x1, y1); /**/
 	if(x1 > x0+1)
 		erect(x0+1, y0-p->t, x1-1, y1+p->t, p);
 	else if(y1 > y0+1)
--- a/libmemdraw/fillpoly.c
+++ b/libmemdraw/fillpoly.c
@@ -26,7 +26,6 @@
 static	void	xscan(Memimage *dst, Seg **seg, Seg *segtab, int nseg, int wind, Memimage *src, Point sp, int, int, int, int);
 static	void	yscan(Memimage *dst, Seg **seg, Seg *segtab, int nseg, int wind, Memimage *src, Point sp, int, int);
 
-#ifdef NOT
 static void
 fillcolor(Memimage *dst, int left, int right, int y, Memimage *src, Point p)
 {
@@ -38,7 +37,6 @@
 	p.y = y;
 	memset(byteaddr(dst, p), srcval, right-left);
 }
-#endif
 
 static void
 fillline(Memimage *dst, int left, int right, int y, Memimage *src, Point p, int op)
@@ -81,7 +79,7 @@
 	Point p0;
 	int i;
 
-	if(nvert == 0)
+	if(nvert <= 0)
 		return;
 
 	seg = malloc((nvert+2)*sizeof(Seg*));
--- a/libmemdraw/line.c
+++ b/libmemdraw/line.c
@@ -11,7 +11,6 @@
 	Arrow3 = 3,
 };
 
-#ifdef NOT
 static
 int
 lmin(int a, int b)
@@ -20,7 +19,6 @@
 		return a;
 	return b;
 }
-#endif
 
 static
 int
@@ -370,6 +368,7 @@
 			r.max.y += radius+1;
 		}
 		oclipr = dst->clipr;
+		sp = addpt(r.min, d);
 		dst->clipr = clipr;
 		memimagedraw(dst, r, src, sp, memopaque, sp, op);
 		dst->clipr = oclipr;
@@ -422,7 +421,7 @@
 		break;
 	case Endarrow:
 		arrowend(q, pp, end1, sin, cos, radius);
-		_memfillpolysc(dst, pp, 5, ~0, src, addpt(pts[0], mulpt(d, ICOSSCALE)), 1, 10, 1, op);
+		_memfillpolysc(dst, pp, 5, ~0, src, addpt(pp[0], mulpt(d, ICOSSCALE)), 1, 10, 1, op);
 		pp[1] = pp[4];
 		pp += 2;
 	}
--- a/libmemdraw/load.c
+++ b/libmemdraw/load.c
@@ -4,13 +4,20 @@
 #include <memdraw.h>
 
 int
-_loadmemimage(Memimage *i, Rectangle r, uchar *data, int ndata)
+loadmemimage(Memimage *i, Rectangle r, uchar *data, int ndata)
 {
 	int y, l, lpart, rpart, mx, m, mr;
+	Memdrawparam par;
 	uchar *q;
 
-	if(!rectinrect(r, i->r))
+	if(badrect(r) || !rectinrect(r, i->r))
 		return -1;
+
+	memset(&par, 0, sizeof par);
+	par.dst = i;
+	par.r = r;
+	hwdraw(&par);
+
 	l = bytesperline(r, i->depth);
 	if(ndata < l*Dy(r))
 		return -1;
--- a/libmemdraw/openmemsubfont.c
+++ b/libmemdraw/openmemsubfont.c
@@ -20,15 +20,19 @@
 	i = readmemimage(fd);
 	if(i == nil)
 		goto Err;
-	if(read(fd, hdr, 3*12) != 3*12){
+	if(readn(fd, hdr, 3*12) != 3*12){
 		werrstr("openmemsubfont: header read error: %r");
 		goto Err;
 	}
 	n = atoi(hdr);
+	if(n <= 0 || n > 0x7fff){
+		werrstr("openmemsubfont: bad fontchar count %d", n);
+		goto Err;
+	}
 	p = malloc(6*(n+1));
 	if(p == nil)
 		goto Err;
-	if(read(fd, p, 6*(n+1)) != 6*(n+1)){
+	if(readn(fd, p, 6*(n+1)) != 6*(n+1)){
 		werrstr("openmemsubfont: fontchar read error: %r");
 		goto Err;
 	}
@@ -41,13 +45,12 @@
 		free(fc);
 		goto Err;
 	}
+	close(fd);
 	free(p);
 	return sf;
 Err:
 	close(fd);
-	if (i != nil)
-		freememimage(i);
-	if (p != nil)
-		free(p);
+	free(p);
+	freememimage(i);
 	return nil;
 }
--- a/libmemdraw/read.c
+++ b/libmemdraw/read.c
@@ -85,10 +85,6 @@
 		dy = maxy - miny;
 		if(dy*l > chunk)
 			dy = chunk/l;
-		if(dy <= 0){
-			werrstr("readmemimage: image too wide for buffer");
-			goto Err;
-		}
 		n = dy*l;
 		m = readn(fd, tmp, n);
 		if(m != n){
--- a/libmemdraw/string.c
+++ b/libmemdraw/string.c
@@ -13,7 +13,7 @@
 	Fontchar *i;
 
 	s = (uchar*)cs;
-	for(; (c=*s); p.x+=width, cp.x+=width){
+	for(; c=*s; p.x+=width, cp.x+=width){
 		width = 0;
 		if(c < Runeself)
 			s++;
@@ -27,8 +27,7 @@
 		}
 		if(c >= f->n)
 			continue;
-//		i = f->info+c;
-		i = &(f->info[c]);
+		i = f->info+c;
 		width = i->width;
 		memdraw(b, Rect(p.x+i->left, p.y+i->top, p.x+i->left+(i[1].x-i[0].x), p.y+i->bottom),
 			color, cp, f->bits, Pt(i->x, i->top), SoverD);
@@ -47,7 +46,7 @@
 
 	p = Pt(0, f->height);
 	s = (uchar*)cs;
-	for(; (c=*s); p.x+=width){
+	for(; c=*s; p.x+=width){
 		width = 0;
 		if(c < Runeself)
 			s++;
--- a/libmemdraw/subfont.c
+++ b/libmemdraw/subfont.c
@@ -30,5 +30,6 @@
 		return;
 	free(f->info);	/* note: f->info must have been malloc'ed! */
 	freememimage(f->bits);
+	free(f->name);
 	free(f);
 }
--- a/libmemdraw/unload.c
+++ b/libmemdraw/unload.c
@@ -9,7 +9,7 @@
 	int y, l;
 	uchar *q;
 
-	if(!rectinrect(r, i->r))
+	if(badrect(r) || !rectinrect(r, i->r))
 		return -1;
 	l = bytesperline(r, i->depth);
 	if(ndata < l*Dy(r))
--- a/libmemdraw/write.c
+++ b/libmemdraw/write.c
@@ -27,12 +27,10 @@
 	uchar *line, *eline;			/* input line, end pointer */
 	uchar *data, *edata;			/* input buffer, end pointer */
 	ulong n;				/* length of input buffer */
-	ulong nb;				/* # of bytes returned by unloadimage */
 	int bpl;				/* input line length */
 	int offs, runlen;			/* offset, length of consumed data */
 	uchar dumpbuf[NDUMP];			/* dump accumulator */
 	int ndump;				/* length of dump accumulator */
-	int miny, dy;				/* y values while unloading input */
 	int ncblock;				/* size of compressed blocks */
 	Rectangle r;
 	uchar *p, *q, *s, *es, *t;
@@ -41,28 +39,36 @@
 
 	r = i->r;
 	bpl = bytesperline(r, i->depth);
+	ncblock = _compblocksize(r, i->depth);
+	if(ncblock > CHUNK){
+		sprint(hdr, "%11s %11d %11d %11d %11d ",
+			chantostr(cbuf, i->chan), r.min.x, r.min.y, r.max.x, r.max.y);
+		if(write(fd, hdr, 5*12) != 5*12)
+			return -1;
+		for(; r.min.y < r.max.y; r.min.y++)
+			if(write(fd, byteaddr(i, r.min), bpl) != bpl)
+				return -1;
+		return 0;
+	}
+
 	n = Dy(r)*bpl;
 	data = malloc(n);
-	ncblock = _compblocksize(r, i->depth);
+	if(data == 0){
+	ErrOut0:
+		free(data);
+		return -1;
+	}
+	if(unloadmemimage(i, r, data, n) != n)
+		goto ErrOut0;
 	outbuf = malloc(ncblock);
 	hash = malloc(NHASH*sizeof(Hlist));
 	chain = malloc(NMEM*sizeof(Hlist));
-	if(data == 0 || outbuf == 0 || hash == 0 || chain == 0){
+	if(outbuf == 0 || hash == 0 || chain == 0){
 	ErrOut:
-		free(data);
 		free(outbuf);
 		free(hash);
 		free(chain);
-		return -1;
-	}
-	for(miny = r.min.y; miny != r.max.y; miny += dy){
-		dy = r.max.y-miny;
-		if(dy*bpl > CHUNK)
-			dy = CHUNK/bpl;
-		nb = unloadmemimage(i, Rect(r.min.x, miny, r.max.x, miny+dy),
-			data+(miny-r.min.y)*bpl, dy*bpl);
-		if(nb != dy*bpl)
-			goto ErrOut;
+		goto ErrOut0;
 	}
 	sprint(hdr, "compressed\n%11s %11d %11d %11d %11d ",
 		chantostr(cbuf, i->chan), r.min.x, r.min.y, r.max.x, r.max.y);
--- a/libmemlayer/draw.c
+++ b/libmemlayer/draw.c
@@ -42,7 +42,7 @@
 	if(!rectinrect(r, clipr)){
 		oclipr = dst->clipr;
 		dst->clipr = clipr;
-		ok = drawclip(dst, &r, d->src, &p0, d->mask, &p1, &srcr, &mr);
+		ok = drawclipnorepl(dst, &r, d->src, &p0, d->mask, &p1, &srcr, &mr);
 		dst->clipr = oclipr;
 		if(!ok)
 			return;
@@ -74,7 +74,7 @@
 		return;
 	}
 
-	if(drawclip(dst, &r, src, &p0, mask, &p1, &srcr, &mr) == 0){
+	if(drawclipnorepl(dst, &r, src, &p0, mask, &p1, &srcr, &mr) == 0){
 if(drawdebug)	iprint("drawclip dstcr %R srccr %R maskcr %R\n", dst->clipr, src->clipr, mask->clipr);
 		return;
 	}
--- a/libmemlayer/lalloc.c
+++ b/libmemlayer/lalloc.c
@@ -19,7 +19,7 @@
 		paint->clipr = Rect(-0x3FFFFFF, -0x3FFFFFF, 0x3FFFFFF, 0x3FFFFFF);
 	}
 
-	n = allocmemimaged(screenr, s->image->chan, s->image->data, s->image->X);
+	n = allocmemimaged(screenr, s->image->chan, s->image->data);
 	if(n == nil)
 		return nil;
 	l = malloc(sizeof(Memlayer));
--- a/libmemlayer/lsetrefresh.c
+++ b/libmemlayer/lsetrefresh.c
@@ -10,13 +10,13 @@
 	Memlayer *l;
 
 	l = i->layer;
-	if(l->refreshfn!=0 && fn!=0){	/* just change functions */
+	if(l->refreshfn!=nil && fn!=nil){	/* just change functions */
 		l->refreshfn = fn;
 		l->refreshptr = ptr;
 		return 1;
 	}
 
-	if(l->refreshfn == 0){	/* is using backup image; just free it */
+	if(l->refreshfn == nil){	/* is using backup image; just free it */
 		freememimage(l->save);
 		l->save = nil;
 		l->refreshfn = fn;
@@ -29,7 +29,7 @@
 		return 0;
 	/* easiest way is just to update the entire save area */
 	l->refreshfn(i, i->r, l->refreshptr);
-	l->refreshfn = 0;
+	l->refreshfn = nil;
 	l->refreshptr = nil;
 	return 1;
 }
--- a/libmemlayer/unload.c
+++ b/libmemlayer/unload.c
@@ -35,7 +35,7 @@
 	 * src is an obscured layer or data is unaligned
 	 */
 	if(dl->save && dx==0){
-		if(dl->refreshfn != 0)
+		if(dl->refreshfn != nil)
 			return -1;	/* can't unload window if it's not Refbackup */
 		if(n > 0)
 			memlhide(src, r);