Plan 9 from Bell Labs’s /usr/web/sources/contrib/uriel/changes/2005/1229/5

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


Your text here.
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 9326 Dec 29 18:55 sys/src/cmd/unix/drawterm/9ball.ico
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 39 Dec 29 18:55 sys/src/cmd/unix/drawterm/9ball.rc
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 12184 Dec 29 18:55 sys/src/cmd/unix/drawterm/LICENSE
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 29 Dec 29 18:55 sys/src/cmd/unix/drawterm/Make.config
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 429 Dec 29 18:55 sys/src/cmd/unix/drawterm/Make.unix
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 816 Dec 29 18:55 sys/src/cmd/unix/drawterm/Make.win32
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1112 Dec 29 18:55 sys/src/cmd/unix/drawterm/Makefile
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 925 Dec 29 18:55 sys/src/cmd/unix/drawterm/README
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/README:1,9 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/README:1,37
	- This is drawterm, enough of a Plan 9 kernel to provide
	- an environment under which ``cpu'' can run, so that you
	- can access Plan 9 from Windows and various flavors
	- of Unix.  See the manual page for more information.
	+ INSTALLATION
	+ --------------
	+ To build on Unix, run CONF=unix make.
	  
	- This drawterm still uses the old (third edition) 9P, aka 9P1.
	- A 9P2000 version of drawterm and many other tools is in 
	- progress.  See ../README for details.
	+ To build on Windows, you need Mingw.  See http://www.mingw.org.
	+ Edit Make.config to uncomment the Windows section
	+ and comment out the rest.  Then run CONF=windows make.
	+ 
	+ (You can download nmake from 
	+ http://support.microsoft.com/default.aspx?scid=kb;en-us;Q132084
	+ Rename it to make.exe and put it in your path somewhere.
	+ )
	+ 
	+ I haven't tested the Windows build on Windows itself.
	+ I cross-compile using mingw32 on Linux.
	+ 
	+ 
	+ BINARIES
	+ ---------
	+ See http://swtch.com/drawterm/
	+ 
	+ SOURCE
	+ ------
	+ Use CVS: cvs -d :pserver:[email protected]:/cvs co drawterm
	+ On the web at http://cvs.pdos.csail.mit.edu/cvs/drawterm
	+ In the Plan 9 distribution: /sys/src/cmd/unix/drawterm
	+ 
	+ TO DO:
	+ ------
	+ 
	+ - Should import latest /dev/draw to allow resize of window
	+ 
	+ - Should copy 9term code and make console window a real
	+ 	9term window instead.
	+ 
	+ - Should implement /dev/label.
	  
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 709 Dec 29 18:55 sys/src/cmd/unix/drawterm/args.h
 [rsc] --rw-r--r-- M 1092710 rsc drawterm 14118 Dec 29 18:55 sys/src/cmd/unix/drawterm/cpu-bl.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 13988 Dec 29 18:55 sys/src/cmd/unix/drawterm/cpu.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 472 Dec 29 18:55 sys/src/cmd/unix/drawterm/drawterm.h
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1662 Dec 29 18:55 sys/src/cmd/unix/drawterm/drawterm.ico
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1713 Dec 29 18:55 sys/src/cmd/unix/drawterm/drawterm.rc
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1756 Dec 29 18:55 sys/src/cmd/unix/drawterm/drawterm.res
 [rsc] d-rwxrwxr-x M 1092710 rsc drawterm 0 Dec 29 18:55 sys/src/cmd/unix/drawterm/exportfs
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 200 Dec 29 18:55 sys/src/cmd/unix/drawterm/exportfs/Makefile
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 8412 Dec 29 18:55 sys/src/cmd/unix/drawterm/exportfs/exportfs.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 2738 Dec 29 18:55 sys/src/cmd/unix/drawterm/exportfs/exportfs.h
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 10966 Dec 29 18:55 sys/src/cmd/unix/drawterm/exportfs/exportsrv.c
 [rsc] d-rwxrwxr-x M 1092710 rsc drawterm 0 Dec 29 18:55 sys/src/cmd/unix/drawterm/gui-win32
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 220 Dec 29 18:55 sys/src/cmd/unix/drawterm/gui-win32/Makefile
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 286 Dec 29 18:55 sys/src/cmd/unix/drawterm/gui-win32/alloc.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 188 Dec 29 18:55 sys/src/cmd/unix/drawterm/gui-win32/cload.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 365 Dec 29 18:55 sys/src/cmd/unix/drawterm/gui-win32/draw.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 186 Dec 29 18:55 sys/src/cmd/unix/drawterm/gui-win32/load.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 11539 Dec 29 18:55 sys/src/cmd/unix/drawterm/gui-win32/screen.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 408 Dec 29 18:55 sys/src/cmd/unix/drawterm/gui-win32/wstrtoutf.c
 [rsc] d-rwxrwxr-x M 1092710 rsc drawterm 0 Dec 29 18:55 sys/src/cmd/unix/drawterm/gui-x11
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 207 Dec 29 18:55 sys/src/cmd/unix/drawterm/gui-x11/Makefile
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 3941 Dec 29 18:55 sys/src/cmd/unix/drawterm/gui-x11/alloc.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 260 Dec 29 18:55 sys/src/cmd/unix/drawterm/gui-x11/cload.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 3896 Dec 29 18:55 sys/src/cmd/unix/drawterm/gui-x11/draw.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 67008 Dec 29 18:55 sys/src/cmd/unix/drawterm/gui-x11/keysym2ucs-x11.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 244 Dec 29 18:55 sys/src/cmd/unix/drawterm/gui-x11/keysym2ucs.h
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 13549 Dec 29 18:55 sys/src/cmd/unix/drawterm/gui-x11/ksym2utf.h
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 258 Dec 29 18:55 sys/src/cmd/unix/drawterm/gui-x11/load.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 24932 Dec 29 18:55 sys/src/cmd/unix/drawterm/gui-x11/screen.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1508 Dec 29 18:55 sys/src/cmd/unix/drawterm/gui-x11/xmem.h
 [rsc] d-rwxrwxr-x M 1092710 rsc drawterm 0 Dec 29 18:59 sys/src/cmd/unix/drawterm/include
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 420 Dec 29 18:59 sys/src/cmd/unix/drawterm/include/9windows.h
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 4522 Dec 29 18:59 sys/src/cmd/unix/drawterm/include/a.out
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 3536 Dec 29 18:59 sys/src/cmd/unix/drawterm/include/auth.h
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 4562 Dec 29 18:59 sys/src/cmd/unix/drawterm/include/authsrv.h
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 70 Dec 29 18:59 sys/src/cmd/unix/drawterm/include/cursor.h
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 16052 Dec 29 18:59 sys/src/cmd/unix/drawterm/include/draw.h
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 358 Dec 29 18:59 sys/src/cmd/unix/drawterm/include/dtos.h
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 2676 Dec 29 18:59 sys/src/cmd/unix/drawterm/include/fcall.h
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 920 Dec 29 18:59 sys/src/cmd/unix/drawterm/include/keyboard.h
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 7449 Dec 29 18:59 sys/src/cmd/unix/drawterm/include/lib.h
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 36 Dec 29 18:59 sys/src/cmd/unix/drawterm/include/libc.h
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 8861 Dec 29 18:59 sys/src/cmd/unix/drawterm/include/libsec.h
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 6306 Dec 29 18:59 sys/src/cmd/unix/drawterm/include/memdraw.h
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1871 Dec 29 18:59 sys/src/cmd/unix/drawterm/include/memlayer.h
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 4524 Dec 29 18:59 sys/src/cmd/unix/drawterm/include/mp.h
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 336 Dec 29 18:59 sys/src/cmd/unix/drawterm/include/u.h
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 263 Dec 29 18:59 sys/src/cmd/unix/drawterm/include/unix.h
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 2532 Dec 29 18:59 sys/src/cmd/unix/drawterm/include/user.h
 [rsc] d-rwxrwxr-x M 1092710 rsc drawterm 0 Dec 29 19:00 sys/src/cmd/unix/drawterm/kern
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 571 Dec 29 18:59 sys/src/cmd/unix/drawterm/kern/Makefile
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 3172 Dec 29 18:59 sys/src/cmd/unix/drawterm/kern/allocb.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 466 Dec 29 18:59 sys/src/cmd/unix/drawterm/kern/cache.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 29593 Dec 29 18:59 sys/src/cmd/unix/drawterm/kern/chan.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 10716 Dec 29 18:59 sys/src/cmd/unix/drawterm/kern/dat.h
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 423 Dec 29 18:59 sys/src/cmd/unix/drawterm/kern/data.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 8523 Dec 29 18:59 sys/src/cmd/unix/drawterm/kern/dev.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 19526 Dec 29 18:59 sys/src/cmd/unix/drawterm/kern/devcons.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 42481 Dec 29 18:59 sys/src/cmd/unix/drawterm/kern/devdraw.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 9772 Dec 29 18:59 sys/src/cmd/unix/drawterm/kern/devfs-posix.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 10723 Dec 29 18:59 sys/src/cmd/unix/drawterm/kern/devfs-win32.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 3488 Dec 29 18:59 sys/src/cmd/unix/drawterm/kern/devip-posix.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 3534 Dec 29 18:59 sys/src/cmd/unix/drawterm/kern/devip-win32.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 16045 Dec 29 18:59 sys/src/cmd/unix/drawterm/kern/devip.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 469 Dec 29 18:59 sys/src/cmd/unix/drawterm/kern/devip.h
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1534 Dec 29 18:59 sys/src/cmd/unix/drawterm/kern/devlfd.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 21739 Dec 29 18:59 sys/src/cmd/unix/drawterm/kern/devmnt.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 3799 Dec 29 18:59 sys/src/cmd/unix/drawterm/kern/devmouse.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 5927 Dec 29 18:59 sys/src/cmd/unix/drawterm/kern/devpipe.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 4717 Dec 29 18:59 sys/src/cmd/unix/drawterm/kern/devroot.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 26455 Dec 29 18:59 sys/src/cmd/unix/drawterm/kern/devssl.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 470 Dec 29 18:59 sys/src/cmd/unix/drawterm/kern/devtab.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 2100 Dec 29 18:59 sys/src/cmd/unix/drawterm/kern/error.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 2583 Dec 29 18:59 sys/src/cmd/unix/drawterm/kern/error.h
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 13444 Dec 29 18:59 sys/src/cmd/unix/drawterm/kern/exportfs.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 10731 Dec 29 18:59 sys/src/cmd/unix/drawterm/kern/fns.h
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 2950 Dec 29 18:59 sys/src/cmd/unix/drawterm/kern/netif.h
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1993 Dec 29 18:59 sys/src/cmd/unix/drawterm/kern/parse.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 4017 Dec 29 18:59 sys/src/cmd/unix/drawterm/kern/pgrp.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 3149 Dec 29 18:59 sys/src/cmd/unix/drawterm/kern/posix.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1039 Dec 29 18:59 sys/src/cmd/unix/drawterm/kern/procinit.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 23496 Dec 29 18:59 sys/src/cmd/unix/drawterm/kern/qio.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1119 Dec 29 18:59 sys/src/cmd/unix/drawterm/kern/qlock.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1293 Dec 29 18:59 sys/src/cmd/unix/drawterm/kern/rendez.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 634 Dec 29 18:59 sys/src/cmd/unix/drawterm/kern/rwlock.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1151 Dec 29 18:59 sys/src/cmd/unix/drawterm/kern/screen.h
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1293 Dec 29 18:59 sys/src/cmd/unix/drawterm/kern/sleep.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 187 Dec 29 18:59 sys/src/cmd/unix/drawterm/kern/smalloc.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1273 Dec 29 18:59 sys/src/cmd/unix/drawterm/kern/stub.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 12876 Dec 29 18:59 sys/src/cmd/unix/drawterm/kern/syscall.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 18035 Dec 29 18:59 sys/src/cmd/unix/drawterm/kern/sysfile.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 498 Dec 29 18:59 sys/src/cmd/unix/drawterm/kern/sysproc.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 3962 Dec 29 18:59 sys/src/cmd/unix/drawterm/kern/term.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 0 Dec 29 18:59 sys/src/cmd/unix/drawterm/kern/todo.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 178 Dec 29 18:59 sys/src/cmd/unix/drawterm/kern/uart.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 382 Dec 29 18:59 sys/src/cmd/unix/drawterm/kern/waserror.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 7800 Dec 29 18:59 sys/src/cmd/unix/drawterm/kern/win32.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 7806 Dec 29 18:55 sys/src/cmd/unix/drawterm/latin1.c
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/latin1.c:1,5 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/latin1.c:1,5
	- #include "lib9.h"
	- #include "sys.h"
	+ #include "u.h"
	+ #include "libc.h"
	  
	  /*
	   * The code makes two assumptions: strlen(ld) is 1 or 2; latintab[i].ld can be a
 [rsc] d-rwxrwxr-x M 1092710 rsc drawterm 0 Dec 29 18:56 sys/src/cmd/unix/drawterm/libauth
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 306 Dec 29 18:55 sys/src/cmd/unix/drawterm/libauth/Makefile
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 2857 Dec 29 18:55 sys/src/cmd/unix/drawterm/libauth/attr.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 217 Dec 29 18:55 sys/src/cmd/unix/drawterm/libauth/auth_attr.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1976 Dec 29 18:55 sys/src/cmd/unix/drawterm/libauth/auth_challenge.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1363 Dec 29 18:55 sys/src/cmd/unix/drawterm/libauth/auth_getuserpasswd.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 3606 Dec 29 18:55 sys/src/cmd/unix/drawterm/libauth/auth_proxy.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1420 Dec 29 18:56 sys/src/cmd/unix/drawterm/libauth/auth_respond.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 2064 Dec 29 18:56 sys/src/cmd/unix/drawterm/libauth/auth_rpc.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1097 Dec 29 18:56 sys/src/cmd/unix/drawterm/libauth/auth_userpasswd.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 87 Dec 29 18:56 sys/src/cmd/unix/drawterm/libauth/authlocal.h
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1059 Dec 29 18:56 sys/src/cmd/unix/drawterm/libauth/httpauth.c
 [rsc] d-rwxrwxr-x M 1092710 rsc drawterm 0 Dec 29 18:56 sys/src/cmd/unix/drawterm/libauthsrv
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 355 Dec 29 18:56 sys/src/cmd/unix/drawterm/libauthsrv/Makefile
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 280 Dec 29 18:56 sys/src/cmd/unix/drawterm/libauthsrv/_asgetticket.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 874 Dec 29 18:56 sys/src/cmd/unix/drawterm/libauthsrv/_asrdresp.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 711 Dec 29 18:56 sys/src/cmd/unix/drawterm/libauthsrv/authdial.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 501 Dec 29 18:56 sys/src/cmd/unix/drawterm/libauthsrv/convA2M.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 470 Dec 29 18:56 sys/src/cmd/unix/drawterm/libauthsrv/convM2A.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 610 Dec 29 18:56 sys/src/cmd/unix/drawterm/libauthsrv/convM2PR.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 579 Dec 29 18:56 sys/src/cmd/unix/drawterm/libauthsrv/convM2T.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 617 Dec 29 18:56 sys/src/cmd/unix/drawterm/libauthsrv/convM2TR.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 563 Dec 29 18:56 sys/src/cmd/unix/drawterm/libauthsrv/convPR2M.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 558 Dec 29 18:56 sys/src/cmd/unix/drawterm/libauthsrv/convT2M.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 562 Dec 29 18:56 sys/src/cmd/unix/drawterm/libauthsrv/convTR2M.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 192 Dec 29 18:56 sys/src/cmd/unix/drawterm/libauthsrv/nvcsum.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 448 Dec 29 18:56 sys/src/cmd/unix/drawterm/libauthsrv/opasstokey.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 517 Dec 29 18:56 sys/src/cmd/unix/drawterm/libauthsrv/passtokey.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 8446 Dec 29 18:56 sys/src/cmd/unix/drawterm/libauthsrv/readnvram.c
 [rsc] d-rwxrwxr-x M 1092710 rsc drawterm 0 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1097 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/Makefile
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1661 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/charstod.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1199 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/cleanname.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1398 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/convD2M.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1419 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/convM2D.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 4969 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/convM2S.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 5014 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/convS2M.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1045 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/crypt.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 3703 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/dial.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 676 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/dirfstat.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 242 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/dirfwstat.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 581 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/dirmodefmt.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 688 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/dirstat.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 246 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/dirwstat.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 8626 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/dofmt.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 777 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/dorfmt.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 175 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/errfmt.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 5740 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/fcallfmt.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 4345 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/fltfmt.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 2940 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/fmt.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 3075 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/fmt.h
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1808 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/fmtdef.h
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 508 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/fmtfd.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 134 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/fmtlock.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 465 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/fmtprint.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 4732 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/fmtquote.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 314 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/fmtrune.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 140 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/fmtstr.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 449 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/fmtvprint.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 174 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/fprint.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 210 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/frand.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 516 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/getfields.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 198 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/getpid.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 194 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/lnrand.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 774 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/lock.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1109 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/lrand.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 141 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/mallocz.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 114 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/nan.h
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 921 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/nan64.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 863 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/netmkaddr.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 191 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/nrand.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1196 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/nsec.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1946 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/pow10.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 164 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/print.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 905 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/pushssl.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 79 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/rand.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 462 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/read9pmsg.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 234 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/readn.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 2306 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/rune.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 144 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/runefmtstr.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 204 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/runeseprint.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 176 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/runesmprint.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 203 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/runesnprint.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 192 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/runesprint.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 124 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/runestrcat.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 207 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/runestrchr.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 221 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/runestrcmp.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 138 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/runestrcpy.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 180 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/runestrdup.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 202 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/runestrecpy.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 94 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/runestrlen.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 213 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/runestrncat.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 250 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/runestrncmp.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 234 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/runestrncpy.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 182 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/runestrrchr.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 397 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/runestrstr.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 29655 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/runetype.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 313 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/runevseprint.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1043 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/runevsmprint.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 330 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/runevsnprint.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 196 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/seprint.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 168 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/smprint.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 195 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/snprint.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 236 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/sprint.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 223 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/strecpy.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 8558 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/strtod.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 120 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/strtod.h
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1302 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/strtoll.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 479 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/sysfatal.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 878 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/time.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1691 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/tokenize.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 306 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/truerand.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 823 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/u16.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 2414 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/u32.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 3282 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/u64.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1442 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/utf.h
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 335 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/utfdef.h
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 284 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/utfecpy.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 242 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/utflen.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 317 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/utfnlen.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 414 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/utfrrune.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 401 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/utfrune.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 391 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/utfutf.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 518 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/vfprint.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 309 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/vseprint.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 997 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/vsmprint.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 326 Dec 29 18:56 sys/src/cmd/unix/drawterm/libc/vsnprint.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 293 Dec 29 18:56 sys/src/cmd/unix/drawterm/libdraw/Makefile
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 4095 Dec 29 18:56 sys/src/cmd/unix/drawterm/libdraw/alloc.c
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libdraw/alloc.c:1,11 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libdraw/alloc.c:1,237
	- #include "../lib9.h"
	+ #include <u.h>
	+ #include <libc.h>
	+ #include <draw.h>
	  
	- #include "../libdraw/draw.h"
	+ Image*
	+ allocimage(Display *d, Rectangle r, ulong chan, int repl, ulong val)
	+ {
	+ 	return _allocimage(nil, d, r, chan, repl, val, 0, 0);
	+ }
	  
	- ulong
	- drawld2chan[] = {
	- 	GREY1,
	- 	GREY2,
	- 	GREY4,
	- 	CMAP8,
	- };
	+ Image*
	+ _allocimage(Image *ai, Display *d, Rectangle r, ulong chan, int repl, ulong val, int screenid, int refresh)
	+ {
	+ 	uchar *a;
	+ 	char *err;
	+ 	Image *i;
	+ 	Rectangle clipr;
	+ 	int id;
	+ 	int depth;
	+ 
	+ 	err = 0;
	+ 	i = 0;
	+ 
	+ 	if(chan == 0){
	+ 		werrstr("bad channel descriptor");
	+ 		return nil;
	+ 	}
	+ 
	+ 	depth = chantodepth(chan);
	+ 	if(depth == 0){
	+ 		err = "bad channel descriptor";
	+     Error:
	+ 		if(err)
	+ 			werrstr("allocimage: %s", err);
	+ 		else
	+ 			werrstr("allocimage: %r");
	+ 		free(i);
	+ 		return 0;
	+ 	}
	+ 
	+ 	/* 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)
	+ 		goto Error;
	+ 	d->imageid++;
	+ 	id = d->imageid;
	+ 	a[0] = 'b';
	+ 	BPLONG(a+1, id);
	+ 	BPLONG(a+5, screenid);
	+ 	a[9] = refresh;
	+ 	BPLONG(a+10, chan);
	+ 	a[14] = repl;
	+ 	BPLONG(a+15, r.min.x);
	+ 	BPLONG(a+19, r.min.y);
	+ 	BPLONG(a+23, r.max.x);
	+ 	BPLONG(a+27, r.max.y);
	+ 	if(repl)
	+ 		/* huge but not infinite, so various offsets will leave it huge, not overflow */
	+ 		clipr = Rect(-0x3FFFFFFF, -0x3FFFFFFF, 0x3FFFFFFF, 0x3FFFFFFF);
	+ 	else
	+ 		clipr = r;
	+ 	BPLONG(a+31, clipr.min.x);
	+ 	BPLONG(a+35, clipr.min.y);
	+ 	BPLONG(a+39, clipr.max.x);
	+ 	BPLONG(a+43, clipr.max.y);
	+ 	BPLONG(a+47, val);
	+ 	if(flushimage(d, 0) < 0)
	+ 		goto Error;
	+ 
	+ 	if(ai)
	+ 		i = ai;
	+ 	else{
	+ 		i = malloc(sizeof(Image));
	+ 		if(i == nil){
	+ 			a = bufimage(d, 1+4);
	+ 			if(a){
	+ 				a[0] = 'f';
	+ 				BPLONG(a+1, id);
	+ 				flushimage(d, 0);
	+ 			}
	+ 			goto Error;
	+ 		}
	+ 	}
	+ 	i->display = d;
	+ 	i->id = id;
	+ 	i->depth = depth;
	+ 	i->chan = chan;
	+ 	i->r = r;
	+ 	i->clipr = clipr;
	+ 	i->repl = repl;
	+ 	i->screen = 0;
	+ 	i->next = 0;
	+ 	return i;
	+ }
	+ 
	+ Image*
	+ namedimage(Display *d, char *name)
	+ {
	+ 	uchar *a;
	+ 	char *err, buf[12*12+1];
	+ 	Image *i;
	+ 	int id, n;
	+ 	ulong chan;
	+ 
	+ 	err = 0;
	+ 	i = 0;
	+ 
	+ 	n = strlen(name);
	+ 	if(n >= 256){
	+ 		err = "name too long";
	+     Error:
	+ 		if(err)
	+ 			werrstr("namedimage: %s", err);
	+ 		else
	+ 			werrstr("namedimage: %r");
	+ 		if(i)
	+ 			free(i);
	+ 		return 0;
	+ 	}
	+ 	/* 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)
	+ 		goto Error;
	+ 	d->imageid++;
	+ 	id = d->imageid;
	+ 	a[0] = 'n';
	+ 	BPLONG(a+1, id);
	+ 	a[5] = n;
	+ 	memmove(a+6, name, n);
	+ 	if(flushimage(d, 0) < 0)
	+ 		goto Error;
	+ 
	+ 	if(pread(d->ctlfd, buf, sizeof buf, 0) < 12*12)
	+ 		goto Error;
	+ 	buf[12*12] = '\0';
	+ 
	+ 	i = malloc(sizeof(Image));
	+ 	if(i == nil){
	+ 	Error1:
	+ 		a = bufimage(d, 1+4);
	+ 		if(a){
	+ 			a[0] = 'f';
	+ 			BPLONG(a+1, id);
	+ 			flushimage(d, 0);
	+ 		}
	+ 		goto Error;
	+ 	}
	+ 	i->display = d;
	+ 	i->id = id;
	+ 	if((chan=strtochan(buf+2*12))==0){
	+ 		werrstr("bad channel '%.12s' from devdraw", buf+2*12);
	+ 		goto Error1;
	+ 	}
	+ 	i->chan = chan;
	+ 	i->depth = chantodepth(chan);
	+ 	i->repl = atoi(buf+3*12);
	+ 	i->r.min.x = atoi(buf+4*12);
	+ 	i->r.min.y = atoi(buf+5*12);
	+ 	i->r.max.x = atoi(buf+6*12);
	+ 	i->r.max.y = atoi(buf+7*12);
	+ 	i->clipr.min.x = atoi(buf+8*12);
	+ 	i->clipr.min.y = atoi(buf+9*12);
	+ 	i->clipr.max.x = atoi(buf+10*12);
	+ 	i->clipr.max.y = atoi(buf+11*12);
	+ 	i->screen = 0;
	+ 	i->next = 0;
	+ 	return i;
	+ }
	+ 
	+ int
	+ nameimage(Image *i, char *name, int in)
	+ {
	+ 	uchar *a;
	+ 	int n;
	+ 
	+ 	n = strlen(name);
	+ 	a = bufimage(i->display, 1+4+1+1+n);
	+ 	if(a == 0)
	+ 		return 0;
	+ 	a[0] = 'N';
	+ 	BPLONG(a+1, i->id);
	+ 	a[5] = in;
	+ 	a[6] = n;
	+ 	memmove(a+7, name, n);
	+ 	if(flushimage(i->display, 0) < 0)
	+ 		return 0;
	+ 	return 1;
	+ }
	+ 
	+ int
	+ _freeimage1(Image *i)
	+ {
	+ 	uchar *a;
	+ 	Display *d;
	+ 	Image *w;
	+ 
	+ 	if(i == 0)
	+ 		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){
	+ 		w = d->windows;
	+ 		if(w == i)
	+ 			d->windows = i->next;
	+ 		else
	+ 			while(w){
	+ 				if(w->next == i){
	+ 					w->next = i->next;
	+ 					break;
	+ 				}
	+ 				w = w->next;
	+ 			}
	+ 	}
	+ 	if(flushimage(d, i->screen!=0) < 0)
	+ 		return -1;
	+ 
	+ 	return 0;
	+ }
	+ 
	+ int
	+ freeimage(Image *i)
	+ {
	+ 	int ret;
	+ 
	+ 	ret = _freeimage1(i);
	+ 	free(i);
	+ 	return ret;
	+ }
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 2839 Dec 29 18:56 sys/src/cmd/unix/drawterm/libdraw/arith.c
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libdraw/arith.c:1,7 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libdraw/arith.c:1,7
	- #include "../lib9.h"
	+ #include <u.h>
	+ #include <libc.h>
	+ #include <draw.h>
	  
	- #include "../libdraw/draw.h"
	- 
	  Point
	  Pt(int x, int y)
	  {
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libdraw/arith.c:158,160 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libdraw/arith.c:158,206
	  	if(r1->max.y < r2.max.y)
	  		r1->max.y = r2.max.y;
	  }
	+ 
	+ ulong
	+ drawld2chan[] = {
	+ 	GREY1,
	+ 	GREY2,
	+ 	GREY4,
	+ 	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 };
	+ 
	+ ulong
	+ setalpha(ulong color, uchar alpha)
	+ {
	+ 	int red, green, blue;
	+ 
	+ 	red = (color >> 3*8) & 0xFF;
	+ 	green = (color >> 2*8) & 0xFF;
	+ 	blue = (color >> 1*8) & 0xFF;
	+ 	/* ignore incoming alpha */
	+ 	red = (red * alpha)/255;
	+ 	green = (green * alpha)/255;
	+ 	blue = (blue * alpha)/255;
	+ 	return (red<<3*8) | (green<<2*8) | (blue<<1*8) | (alpha<<0*8);
	+ }
	+ 
	+ Point	ZP;
	+ Rectangle ZR;
	+ 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);
	+ }
	+ 
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 617 Dec 29 18:56 sys/src/cmd/unix/drawterm/libdraw/bytesperline.c
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libdraw/bytesperline.c:1,12 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libdraw/bytesperline.c:1,15
	- #include "../lib9.h"
	+ #include <u.h>
	+ #include <libc.h>
	+ #include <draw.h>
	  
	- #include "../libdraw/draw.h"
	- 
	  static
	  int
	  unitsperline(Rectangle r, int d, int bitsperunit)
	  {
	  	ulong l, t;
	+ 
	+ 	if(d <= 0 || d > 32)	/* being called wrong.  d is image depth. */
	+ 		abort();
	  
	  	if(r.min.x >= 0){
	  		l = (r.max.x*d+bitsperunit-1)/bitsperunit;
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1151 Dec 29 18:56 sys/src/cmd/unix/drawterm/libdraw/chan.c
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libdraw/chan.c:1,8 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libdraw/chan.c:1,7
	- #include "../lib9.h"
	+ #include <u.h>
	+ #include <libc.h>
	+ #include <draw.h>
	  
	- #include "../libdraw/draw.h"
	- #include <ctype.h>
	- 
	  static char channames[] = "rgbkamx";
	  char*
	  chantostr(char *buf, ulong cc)
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libdraw/chan.c:30,35 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libdraw/chan.c:29,41
	  	return buf;
	  }
	  
	+ /* avoid pulling in ctype when using with drawterm etc. */
	+ static int
	+ xisspace(char c)
	+ {
	+ 	return c==' ' || c== '\t' || c=='\r' || c=='\n';
	+ }
	+ 
	  ulong
	  strtochan(char *s)
	  {
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libdraw/chan.c:39,48 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libdraw/chan.c:45,54
	  
	  	c = 0;
	  	p=s;
	- 	while(*p && isspace(*p))
	+ 	while(*p && xisspace(*p))
	  		p++;
	  
	- 	while(*p && !isspace(*p)){
	+ 	while(*p && !xisspace(*p)){
	  		if((q = strchr(channames, p[0])) == nil) 
	  			return 0;
	  		t = q-channames;
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libdraw/chan.c:59,70 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libdraw/chan.c:65,77
	  chantodepth(ulong c)
	  {
	  	int n;
	+ 
	  	for(n=0; c; c>>=8){
	  		if(TYPE(c) >= NChan || NBITS(c) > 8 || NBITS(c) <= 0)
	  			return 0;
	  		n += NBITS(c);
	  	}
	- 	if((n>8 && n%8) || (n<8 && 8%n))
	+ 	if(n==0 || (n>8 && n%8) || (n<8 && 8%n))
	  		return 0;
	  	return n;
	  }
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 30537 Dec 29 18:56 sys/src/cmd/unix/drawterm/libdraw/defont.c
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libdraw/defont.c:1,6 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libdraw/defont.c:1,6
	- #include "../lib9.h"
	- 
	- #include "../libdraw/draw.h"
	+ #include <u.h>
	+ #include <libc.h>
	+ #include <draw.h>
	  
	  /*
	   * lucm/latin1.9, in uncompressed form
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 314 Dec 29 18:56 sys/src/cmd/unix/drawterm/libdraw/drawrepl.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 2117 Dec 29 18:56 sys/src/cmd/unix/drawterm/libdraw/icossin.c
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libdraw/icossin.c:1,5 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libdraw/icossin.c:1,6
	- #include	"../lib9.h"
	- #include	"../libdraw/draw.h"
	+ #include	<u.h>
	+ #include	<libc.h>
	+ #include	<draw.h>
	  
	  /*
	   * Integer sine and cosine for integral degree argument.
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 4587 Dec 29 18:56 sys/src/cmd/unix/drawterm/libdraw/icossin2.c
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libdraw/icossin2.c:1,5 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libdraw/icossin2.c:1,6
	- #include	"../lib9.h"
	- #include	"../libdraw/draw.h"
	+ #include	<u.h>
	+ #include	<libc.h>
	+ #include	<draw.h>
	  
	  /*
	   * Sine and Cosine of arctangents, calculated by 
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 571 Dec 29 18:56 sys/src/cmd/unix/drawterm/libdraw/rectclip.c
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libdraw/rectclip.c:1,6 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libdraw/rectclip.c:1,6
	- #include "../lib9.h"
	- 
	- #include "../libdraw/draw.h"
	+ #include <u.h>
	+ #include <libc.h>
	+ #include <draw.h>
	  
	  int
	  rectclip(Rectangle *rp, Rectangle b)		/* first by reference, second by value */
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1679 Dec 29 18:56 sys/src/cmd/unix/drawterm/libdraw/rgb.c
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libdraw/rgb.c:1,7 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libdraw/rgb.c:1,18
	- #include "../lib9.h"
	+ #include <u.h>
	+ #include <libc.h>
	+ #include <draw.h>
	  
	- #include "../libdraw/draw.h"
	- 
	+ /*
	+  * This original version, although fast and a true inverse of
	+  * cmap2rgb, in the sense that rgb2cmap(cmap2rgb(c))
	+  * returned the original color, does a terrible job for RGB
	+  * triples that do not appear in the color map, so it has been
	+  * replaced by the much slower version below, that loops
	+  * over the color map looking for the nearest point in RGB
	+  * space.  There is no visual psychology reason for that
	+  * criterion, but it's easy to implement and the results are
	+  * far more pleasing. 
	+  *
	  int
	  rgb2cmap(int cr, int cg, int cb)
	  {
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libdraw/rgb.c:29,34 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libdraw/rgb.c:40,69
	  		cv = cb;
	  	v = (cv>>4)&3;
	  	return ((((r<<2)+v)<<4)+(((g<<2)+b+v-r)&15));
	+ }
	+ */
	+ 
	+ int
	+ rgb2cmap(int cr, int cg, int cb)
	+ {
	+ 	int i, r, g, b, sq;
	+ 	ulong rgb;
	+ 	int best, bestsq;
	+ 
	+ 	best = 0;
	+ 	bestsq = 0x7FFFFFFF;
	+ 	for(i=0; i<256; i++){
	+ 		rgb = cmap2rgb(i);
	+ 		r = (rgb>>16) & 0xFF;
	+ 		g = (rgb>>8) & 0xFF;
	+ 		b = (rgb>>0) & 0xFF;
	+ 		sq = (r-cr)*(r-cr)+(g-cg)*(g-cg)+(b-cb)*(b-cb);
	+ 		if(sq < bestsq){
	+ 			bestsq = sq;
	+ 			best = i;
	+ 		}
	+ 	}
	+ 	return best;
	  }
	  
	  int
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 391 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmemdraw/Makefile
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 3309 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmemdraw/alloc.c
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/alloc.c:1,7 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/alloc.c:1,10
	- #include "../lib9.h"
	+ #include <u.h>
	+ #include <libc.h>
	+ #include <draw.h>
	+ #include <memdraw.h>
	  
	- #include "../libdraw/draw.h"
	- #include "../libmemdraw/memdraw.h"
	+ #define poolalloc(a, b) malloc(b)
	+ #define poolfree(a, b) free(b)
	  
	  void
	  memimagemove(void *from, void *to)
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/alloc.c:26,31 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/alloc.c:29,38
	  	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;
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/alloc.c:33,42 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/alloc.c:40,50
	  
	  	l = wordsperline(r, d);
	  
	- 	i = mallocz(sizeof(Memimage));
	+ 	i = mallocz(sizeof(Memimage), 1);
	  	if(i == nil)
	  		return nil;
	  
	+ 	i->X = X;
	  	i->data = md;
	  	i->zero = sizeof(ulong)*l*r.min.y;
	  	
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/alloc.c:55,61 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/alloc.c:63,68
	  		free(i);
	  		return nil;
	  	}
	- 	i->X = X;
	  	return i;
	  }
	  
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/alloc.c:79,85 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/alloc.c:86,92
	  		return nil;
	  
	  	md->ref = 1;
	- 	md->base = mallocz((2+nw)*sizeof(ulong));
	+ 	md->base = poolalloc(imagmem, (2+nw)*sizeof(ulong));
	  	if(md->base == nil){
	  		free(md);
	  		return nil;
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/alloc.c:95,100 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/alloc.c:102,108
	  
	  	i = allocmemimaged(r, chan, md, nil);
	  	if(i == nil){
	+ 		poolfree(imagmem, md->base);
	  		free(md);
	  		return nil;
	  	}
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/alloc.c:109,115 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/alloc.c:117,123
	  		return;
	  	if(i->data->ref-- == 1 && i->data->allocd){
	  		if(i->data->base)
	- 			free(i->data->base);
	+ 			poolfree(imagmem, i->data->base);
	  		free(i->data);
	  	}
	  	free(i);
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/alloc.c:155,161 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/alloc.c:163,168
	  	ulong cc;
	  	int bytes;
	  
	- 	assert(i->X == nil);
	  	if((d = chantodepth(chan)) == 0) {
	  		werrstr("bad channel descriptor");
	  		return -1;
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 3309 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmemdraw/alloc.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 220 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmemdraw/alpha.hoc
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 2608 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmemdraw/arc.c
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/arc.c:1,9 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/arc.c:1,9
	- #include "../lib9.h"
	+ #include <u.h>
	+ #include <libc.h>
	+ #include <draw.h>
	+ #include <memdraw.h>
	+ #include <memlayer.h>
	  
	- #include "../libdraw/draw.h"
	- #include "../libmemdraw/memdraw.h"
	- #include "../libmemlayer/memlayer.h"
	- 
	  /*
	   * elarc(dst,c,a,b,t,src,sp,alpha,phi)
	   *   draws the part of an ellipse between rays at angles alpha and alpha+phi
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/arc.c:33,39 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/arc.c:33,39
	   * wedge to make a mask through which to copy src to dst.
	   */
	  void
	- memarc(Memimage *dst, Point c, int a, int b, int t, Memimage *src, Point sp, int alpha, int phi)
	+ memarc(Memimage *dst, Point c, int a, int b, int t, Memimage *src, Point sp, int alpha, int phi, int op)
	  {
	  	int i, w, beta, tmp, c1, c2, m, m1;
	  	Rectangle rect;
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/arc.c:57,63 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/arc.c:57,63
	  		phi = -phi;
	  	}
	  	if(phi >= 360){
	- 		memellipse(dst, c, a, b, t, src, sp);
	+ 		memellipse(dst, c, a, b, t, src, sp, op);
	  		return;
	  	}
	  	while(alpha < 0)
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/arc.c:96,114 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/arc.c:96,114
	  	if(wedge == nil)
	  		goto Return;
	  	memfillcolor(wedge, DTransparent);
	- 	memfillpoly(wedge, bnd, i, ~0, memopaque, p00);
	+ 	memfillpoly(wedge, bnd, i, ~0, memopaque, p00, S);
	  	figure = allocmemimage(rect, GREY1);
	  	if(figure == nil)
	  		goto Return;
	  	memfillcolor(figure, DTransparent);
	- 	memellipse(figure, p00, a, b, t, memopaque, p00);
	+ 	memellipse(figure, p00, a, b, t, memopaque, p00, S);
	  	mask = allocmemimage(rect, GREY1);
	  	if(mask == nil)
	  		goto Return;
	  	memfillcolor(mask, DTransparent);
	- 	memimagedraw(mask, rect, figure, rect.min, wedge, rect.min);
	+ 	memimagedraw(mask, rect, figure, rect.min, wedge, rect.min, S);
	  	c = subpt(c, dst->r.min);
	- 	memdraw(dst, dst->r, src, subpt(sp, c), mask, subpt(p00, c));
	+ 	memdraw(dst, dst->r, src, subpt(sp, c), mask, subpt(p00, c), op);
	  
	      Return:
	  	freememimage(wedge);
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 865 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmemdraw/arctest.c
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/arctest.c:1,9 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/arctest.c:1,9
	- #include "../lib9.h"
	+ #include <u.h>
	+ #include <libc.h>
	+ #include <draw.h>
	+ #include <memdraw.h>
	+ #include <memlayer.h>
	  
	- #include "../libdraw/draw.h"
	- #include "../libmemdraw/memdraw.h"
	- #include "../libmemlayer/memlayer.h"
	- 
	  extern int drawdebug;
	  void
	  main(int argc, char **argv)
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/arctest.c:33,39 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/arctest.c:33,39
	  	del = t1-t0;
	  	t0 = nsec();
	  	for(i=0; i<n; i++)
	- 		memarc(x, c, a, b, thick, memblack, sp, alpha, phi);
	+ 		memarc(x, c, a, b, thick, memblack, sp, alpha, phi, SoverD);
	  	t1 = nsec();
	  	print("%lld %lld\n", t1-t0-del, del);
	  }
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1338 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmemdraw/cload.c
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/cload.c:1,7 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/cload.c:1,7
	- #include "../lib9.h"
	- 
	- #include "../libdraw/draw.h"
	- #include "../libmemdraw/memdraw.h"
	+ #include <u.h>
	+ #include <libc.h>
	+ #include <draw.h>
	+ #include <memdraw.h>
	  
	  int
	  _cloadmemimage(Memimage *i, Rectangle r, uchar *data, int ndata)
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1338 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmemdraw/cload.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 25150 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmemdraw/cmap.c
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/cmap.c:1,34 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/cmap.c:1,320
	- #include "../lib9.h"
	+ /*
	+  * generated by mkcmap.c
	+  */
	+ #include <u.h>
	+ #include <libc.h>
	+ #include <draw.h>
	+ #include <memdraw.h>
	  
	- #include "../libdraw/draw.h"
	- #include "../libmemdraw/memdraw.h"
	- 
	- Memcmap*	memdefcmap;
	- 
	- static Memcmap	def;
	- 
	- void
	- memmkcmap(void)
	- {
	- 
	- 	int i, rgb, r, g, b;
	- 
	- 	if(memdefcmap)
	- 		return;
	- 
	- 	for(i=0; i<256; i++){
	- 		rgb = cmap2rgb(i);
	- 		r = (rgb>>16)&0xff;
	- 		g = (rgb>>8)&0xff;
	- 		b = rgb&0xff;
	- 		def.cmap2rgb[3*i] = r;
	- 		def.cmap2rgb[3*i+1] = g;
	- 		def.cmap2rgb[3*i+2] = b;
	- 	}
	- 
	- 	for(r=0; r<16; r++)
	- 	for(g=0; g<16; g++)
	- 	for(b=0; b<16; b++)
	- 		def.rgb2cmap[r*16*16+g*16+b] = rgb2cmap(r*0x11, g*0x11, b*0x11);
	- 	memdefcmap = &def;
	+ static Memcmap def = {
	+ /* cmap2rgb */ {
	+ 	0x00,0x00,0x00,0x00,0x00,0x44,0x00,0x00,0x88,0x00,0x00,0xcc,0x00,0x44,0x00,0x00,
	+ 	0x44,0x44,0x00,0x44,0x88,0x00,0x44,0xcc,0x00,0x88,0x00,0x00,0x88,0x44,0x00,0x88,
	+ 	0x88,0x00,0x88,0xcc,0x00,0xcc,0x00,0x00,0xcc,0x44,0x00,0xcc,0x88,0x00,0xcc,0xcc,
	+ 	0x00,0xdd,0xdd,0x11,0x11,0x11,0x00,0x00,0x55,0x00,0x00,0x99,0x00,0x00,0xdd,0x00,
	+ 	0x55,0x00,0x00,0x55,0x55,0x00,0x4c,0x99,0x00,0x49,0xdd,0x00,0x99,0x00,0x00,0x99,
	+ 	0x4c,0x00,0x99,0x99,0x00,0x93,0xdd,0x00,0xdd,0x00,0x00,0xdd,0x49,0x00,0xdd,0x93,
	+ 	0x00,0xee,0x9e,0x00,0xee,0xee,0x22,0x22,0x22,0x00,0x00,0x66,0x00,0x00,0xaa,0x00,
	+ 	0x00,0xee,0x00,0x66,0x00,0x00,0x66,0x66,0x00,0x55,0xaa,0x00,0x4f,0xee,0x00,0xaa,
	+ 	0x00,0x00,0xaa,0x55,0x00,0xaa,0xaa,0x00,0x9e,0xee,0x00,0xee,0x00,0x00,0xee,0x4f,
	+ 	0x00,0xff,0x55,0x00,0xff,0xaa,0x00,0xff,0xff,0x33,0x33,0x33,0x00,0x00,0x77,0x00,
	+ 	0x00,0xbb,0x00,0x00,0xff,0x00,0x77,0x00,0x00,0x77,0x77,0x00,0x5d,0xbb,0x00,0x55,
	+ 	0xff,0x00,0xbb,0x00,0x00,0xbb,0x5d,0x00,0xbb,0xbb,0x00,0xaa,0xff,0x00,0xff,0x00,
	+ 	0x44,0x00,0x44,0x44,0x00,0x88,0x44,0x00,0xcc,0x44,0x44,0x00,0x44,0x44,0x44,0x44,
	+ 	0x44,0x88,0x44,0x44,0xcc,0x44,0x88,0x00,0x44,0x88,0x44,0x44,0x88,0x88,0x44,0x88,
	+ 	0xcc,0x44,0xcc,0x00,0x44,0xcc,0x44,0x44,0xcc,0x88,0x44,0xcc,0xcc,0x44,0x00,0x00,
	+ 	0x55,0x00,0x00,0x55,0x00,0x55,0x4c,0x00,0x99,0x49,0x00,0xdd,0x55,0x55,0x00,0x55,
	+ 	0x55,0x55,0x4c,0x4c,0x99,0x49,0x49,0xdd,0x4c,0x99,0x00,0x4c,0x99,0x4c,0x4c,0x99,
	+ 	0x99,0x49,0x93,0xdd,0x49,0xdd,0x00,0x49,0xdd,0x49,0x49,0xdd,0x93,0x49,0xdd,0xdd,
	+ 	0x4f,0xee,0xee,0x66,0x00,0x00,0x66,0x00,0x66,0x55,0x00,0xaa,0x4f,0x00,0xee,0x66,
	+ 	0x66,0x00,0x66,0x66,0x66,0x55,0x55,0xaa,0x4f,0x4f,0xee,0x55,0xaa,0x00,0x55,0xaa,
	+ 	0x55,0x55,0xaa,0xaa,0x4f,0x9e,0xee,0x4f,0xee,0x00,0x4f,0xee,0x4f,0x4f,0xee,0x9e,
	+ 	0x55,0xff,0xaa,0x55,0xff,0xff,0x77,0x00,0x00,0x77,0x00,0x77,0x5d,0x00,0xbb,0x55,
	+ 	0x00,0xff,0x77,0x77,0x00,0x77,0x77,0x77,0x5d,0x5d,0xbb,0x55,0x55,0xff,0x5d,0xbb,
	+ 	0x00,0x5d,0xbb,0x5d,0x5d,0xbb,0xbb,0x55,0xaa,0xff,0x55,0xff,0x00,0x55,0xff,0x55,
	+ 	0x88,0x00,0x88,0x88,0x00,0xcc,0x88,0x44,0x00,0x88,0x44,0x44,0x88,0x44,0x88,0x88,
	+ 	0x44,0xcc,0x88,0x88,0x00,0x88,0x88,0x44,0x88,0x88,0x88,0x88,0x88,0xcc,0x88,0xcc,
	+ 	0x00,0x88,0xcc,0x44,0x88,0xcc,0x88,0x88,0xcc,0xcc,0x88,0x00,0x00,0x88,0x00,0x44,
	+ 	0x99,0x00,0x4c,0x99,0x00,0x99,0x93,0x00,0xdd,0x99,0x4c,0x00,0x99,0x4c,0x4c,0x99,
	+ 	0x4c,0x99,0x93,0x49,0xdd,0x99,0x99,0x00,0x99,0x99,0x4c,0x99,0x99,0x99,0x93,0x93,
	+ 	0xdd,0x93,0xdd,0x00,0x93,0xdd,0x49,0x93,0xdd,0x93,0x93,0xdd,0xdd,0x99,0x00,0x00,
	+ 	0xaa,0x00,0x00,0xaa,0x00,0x55,0xaa,0x00,0xaa,0x9e,0x00,0xee,0xaa,0x55,0x00,0xaa,
	+ 	0x55,0x55,0xaa,0x55,0xaa,0x9e,0x4f,0xee,0xaa,0xaa,0x00,0xaa,0xaa,0x55,0xaa,0xaa,
	+ 	0xaa,0x9e,0x9e,0xee,0x9e,0xee,0x00,0x9e,0xee,0x4f,0x9e,0xee,0x9e,0x9e,0xee,0xee,
	+ 	0xaa,0xff,0xff,0xbb,0x00,0x00,0xbb,0x00,0x5d,0xbb,0x00,0xbb,0xaa,0x00,0xff,0xbb,
	+ 	0x5d,0x00,0xbb,0x5d,0x5d,0xbb,0x5d,0xbb,0xaa,0x55,0xff,0xbb,0xbb,0x00,0xbb,0xbb,
	+ 	0x5d,0xbb,0xbb,0xbb,0xaa,0xaa,0xff,0xaa,0xff,0x00,0xaa,0xff,0x55,0xaa,0xff,0xaa,
	+ 	0xcc,0x00,0xcc,0xcc,0x44,0x00,0xcc,0x44,0x44,0xcc,0x44,0x88,0xcc,0x44,0xcc,0xcc,
	+ 	0x88,0x00,0xcc,0x88,0x44,0xcc,0x88,0x88,0xcc,0x88,0xcc,0xcc,0xcc,0x00,0xcc,0xcc,
	+ 	0x44,0xcc,0xcc,0x88,0xcc,0xcc,0xcc,0xcc,0x00,0x00,0xcc,0x00,0x44,0xcc,0x00,0x88,
	+ 	0xdd,0x00,0x93,0xdd,0x00,0xdd,0xdd,0x49,0x00,0xdd,0x49,0x49,0xdd,0x49,0x93,0xdd,
	+ 	0x49,0xdd,0xdd,0x93,0x00,0xdd,0x93,0x49,0xdd,0x93,0x93,0xdd,0x93,0xdd,0xdd,0xdd,
	+ 	0x00,0xdd,0xdd,0x49,0xdd,0xdd,0x93,0xdd,0xdd,0xdd,0xdd,0x00,0x00,0xdd,0x00,0x49,
	+ 	0xee,0x00,0x4f,0xee,0x00,0x9e,0xee,0x00,0xee,0xee,0x4f,0x00,0xee,0x4f,0x4f,0xee,
	+ 	0x4f,0x9e,0xee,0x4f,0xee,0xee,0x9e,0x00,0xee,0x9e,0x4f,0xee,0x9e,0x9e,0xee,0x9e,
	+ 	0xee,0xee,0xee,0x00,0xee,0xee,0x4f,0xee,0xee,0x9e,0xee,0xee,0xee,0xee,0x00,0x00,
	+ 	0xff,0x00,0x00,0xff,0x00,0x55,0xff,0x00,0xaa,0xff,0x00,0xff,0xff,0x55,0x00,0xff,
	+ 	0x55,0x55,0xff,0x55,0xaa,0xff,0x55,0xff,0xff,0xaa,0x00,0xff,0xaa,0x55,0xff,0xaa,
	+ 	0xaa,0xff,0xaa,0xff,0xff,0xff,0x00,0xff,0xff,0x55,0xff,0xff,0xaa,0xff,0xff,0xff,
	+ },
	+ /* rgb2cmap */ {
	+ 	0x00,0x00,0x11,0x01,0x01,0x12,0x23,0x34,0x02,0x13,0x24,0x35,0x03,0x14,0x25,0x36,
	+ 	0x00,0x11,0x11,0x01,0x01,0x12,0x23,0x34,0x02,0x13,0x24,0x35,0x03,0x14,0x25,0x36,
	+ 	0x11,0x11,0x11,0x01,0x01,0x12,0x23,0x34,0x02,0x13,0x24,0x35,0x03,0x14,0x25,0x36,
	+ 	0x04,0x04,0x04,0x05,0x05,0x05,0x05,0x06,0x06,0x06,0x17,0x07,0x07,0x18,0x18,0x29,
	+ 	0x04,0x04,0x04,0x05,0x05,0x05,0x16,0x06,0x06,0x17,0x28,0x07,0x07,0x18,0x29,0x3a,
	+ 	0x15,0x15,0x15,0x05,0x05,0x16,0x16,0x06,0x06,0x17,0x28,0x39,0x07,0x18,0x29,0x3a,
	+ 	0x26,0x26,0x26,0x05,0x16,0x16,0x27,0x27,0x38,0x28,0x28,0x39,0x39,0x29,0x29,0x3a,
	+ 	0x37,0x37,0x37,0x09,0x09,0x09,0x27,0x38,0x0a,0x0a,0x39,0x0b,0x0b,0x0b,0x1c,0x3a,
	+ 	0x08,0x08,0x08,0x09,0x09,0x09,0x38,0x0a,0x0a,0x0a,0x1b,0x0b,0x0b,0x1c,0x1c,0x2d,
	+ 	0x19,0x19,0x19,0x09,0x1a,0x1a,0x2b,0x0a,0x0a,0x1b,0x1b,0x0b,0x0b,0x1c,0x2d,0x3e,
	+ 	0x2a,0x2a,0x2a,0x1a,0x2b,0x2b,0x2b,0x3c,0x1b,0x1b,0x2c,0x2c,0x3d,0x2d,0x2d,0x3e,
	+ 	0x3b,0x3b,0x3b,0x0d,0x0d,0x3c,0x3c,0x0e,0x0e,0x0e,0x2c,0x3d,0x0f,0x0f,0x3e,0x3e,
	+ 	0x0c,0x0c,0x0c,0x0d,0x0d,0x0d,0x3c,0x0e,0x0e,0x0e,0x3d,0x0f,0x0f,0x0f,0x10,0x3e,
	+ 	0x1d,0x1d,0x1d,0x1e,0x1e,0x1e,0x2f,0x0e,0x1f,0x1f,0x20,0x0f,0x0f,0x10,0x10,0x21,
	+ 	0x2e,0x2e,0x2e,0x1e,0x2f,0x2f,0x2f,0x1f,0x1f,0x20,0x20,0x31,0x10,0x10,0x21,0x21,
	+ 	0x3f,0x3f,0x3f,0x2f,0x30,0x30,0x30,0x30,0x20,0x31,0x31,0x31,0x31,0x21,0x21,0x32,
	+ 	0x00,0x11,0x11,0x01,0x01,0x12,0x23,0x34,0x02,0x13,0x24,0x35,0x03,0x14,0x25,0x36,
	+ 	0x11,0x11,0x11,0x01,0x01,0x12,0x23,0x34,0x02,0x13,0x24,0x35,0x03,0x14,0x25,0x36,
	+ 	0x11,0x11,0x22,0x22,0x01,0x12,0x23,0x34,0x02,0x13,0x24,0x35,0x03,0x14,0x25,0x36,
	+ 	0x04,0x04,0x22,0x05,0x05,0x05,0x05,0x06,0x06,0x06,0x17,0x07,0x07,0x18,0x18,0x29,
	+ 	0x04,0x04,0x04,0x05,0x05,0x05,0x16,0x06,0x06,0x17,0x28,0x07,0x07,0x18,0x29,0x3a,
	+ 	0x15,0x15,0x15,0x05,0x05,0x16,0x16,0x06,0x06,0x17,0x28,0x39,0x07,0x18,0x29,0x3a,
	+ 	0x26,0x26,0x26,0x05,0x16,0x16,0x27,0x27,0x38,0x28,0x28,0x39,0x39,0x29,0x29,0x3a,
	+ 	0x37,0x37,0x37,0x09,0x09,0x09,0x27,0x38,0x0a,0x0a,0x39,0x0b,0x0b,0x0b,0x1c,0x3a,
	+ 	0x08,0x08,0x08,0x09,0x09,0x09,0x38,0x0a,0x0a,0x0a,0x1b,0x0b,0x0b,0x1c,0x1c,0x2d,
	+ 	0x19,0x19,0x19,0x09,0x1a,0x1a,0x2b,0x0a,0x0a,0x1b,0x1b,0x0b,0x0b,0x1c,0x2d,0x3e,
	+ 	0x2a,0x2a,0x2a,0x1a,0x2b,0x2b,0x2b,0x3c,0x1b,0x1b,0x2c,0x2c,0x3d,0x2d,0x2d,0x3e,
	+ 	0x3b,0x3b,0x3b,0x0d,0x0d,0x3c,0x3c,0x0e,0x0e,0x0e,0x2c,0x3d,0x0f,0x0f,0x3e,0x3e,
	+ 	0x0c,0x0c,0x0c,0x0d,0x0d,0x0d,0x3c,0x0e,0x0e,0x0e,0x3d,0x0f,0x0f,0x0f,0x10,0x3e,
	+ 	0x1d,0x1d,0x1d,0x1e,0x1e,0x1e,0x2f,0x0e,0x1f,0x1f,0x20,0x0f,0x0f,0x10,0x10,0x21,
	+ 	0x2e,0x2e,0x2e,0x1e,0x2f,0x2f,0x2f,0x1f,0x1f,0x20,0x20,0x31,0x10,0x10,0x21,0x21,
	+ 	0x3f,0x3f,0x3f,0x2f,0x30,0x30,0x30,0x30,0x20,0x31,0x31,0x31,0x31,0x21,0x21,0x32,
	+ 	0x11,0x11,0x11,0x01,0x01,0x12,0x23,0x34,0x02,0x13,0x24,0x35,0x03,0x14,0x25,0x36,
	+ 	0x11,0x11,0x22,0x22,0x01,0x12,0x23,0x34,0x02,0x13,0x24,0x35,0x03,0x14,0x25,0x36,
	+ 	0x11,0x22,0x22,0x22,0x33,0x33,0x23,0x34,0x02,0x13,0x24,0x35,0x03,0x14,0x25,0x36,
	+ 	0x04,0x22,0x22,0x33,0x33,0x33,0x05,0x06,0x06,0x06,0x17,0x07,0x07,0x18,0x18,0x29,
	+ 	0x04,0x04,0x33,0x33,0x33,0x05,0x16,0x06,0x06,0x17,0x28,0x07,0x07,0x18,0x29,0x3a,
	+ 	0x15,0x15,0x33,0x33,0x05,0x16,0x16,0x06,0x06,0x17,0x28,0x39,0x07,0x18,0x29,0x3a,
	+ 	0x26,0x26,0x26,0x05,0x16,0x16,0x27,0x27,0x38,0x28,0x28,0x39,0x39,0x29,0x29,0x3a,
	+ 	0x37,0x37,0x37,0x09,0x09,0x09,0x27,0x38,0x0a,0x0a,0x39,0x0b,0x0b,0x0b,0x1c,0x3a,
	+ 	0x08,0x08,0x08,0x09,0x09,0x09,0x38,0x0a,0x0a,0x0a,0x1b,0x0b,0x0b,0x1c,0x1c,0x2d,
	+ 	0x19,0x19,0x19,0x09,0x1a,0x1a,0x2b,0x0a,0x0a,0x1b,0x1b,0x0b,0x0b,0x1c,0x2d,0x3e,
	+ 	0x2a,0x2a,0x2a,0x1a,0x2b,0x2b,0x2b,0x3c,0x1b,0x1b,0x2c,0x2c,0x3d,0x2d,0x2d,0x3e,
	+ 	0x3b,0x3b,0x3b,0x0d,0x0d,0x3c,0x3c,0x0e,0x0e,0x0e,0x2c,0x3d,0x0f,0x0f,0x3e,0x3e,
	+ 	0x0c,0x0c,0x0c,0x0d,0x0d,0x0d,0x3c,0x0e,0x0e,0x0e,0x3d,0x0f,0x0f,0x0f,0x10,0x3e,
	+ 	0x1d,0x1d,0x1d,0x1e,0x1e,0x1e,0x2f,0x0e,0x1f,0x1f,0x20,0x0f,0x0f,0x10,0x10,0x21,
	+ 	0x2e,0x2e,0x2e,0x1e,0x2f,0x2f,0x2f,0x1f,0x1f,0x20,0x20,0x31,0x10,0x10,0x21,0x21,
	+ 	0x3f,0x3f,0x3f,0x2f,0x30,0x30,0x30,0x30,0x20,0x31,0x31,0x31,0x31,0x21,0x21,0x32,
	+ 	0x4f,0x4f,0x22,0x40,0x40,0x40,0x40,0x41,0x41,0x41,0x52,0x42,0x42,0x53,0x53,0x64,
	+ 	0x4f,0x22,0x22,0x22,0x40,0x40,0x40,0x41,0x41,0x41,0x52,0x42,0x42,0x53,0x53,0x64,
	+ 	0x22,0x22,0x22,0x33,0x33,0x33,0x40,0x41,0x41,0x41,0x52,0x42,0x42,0x53,0x53,0x64,
	+ 	0x43,0x22,0x33,0x33,0x33,0x44,0x44,0x45,0x45,0x45,0x56,0x46,0x46,0x46,0x57,0x68,
	+ 	0x43,0x43,0x33,0x33,0x44,0x44,0x44,0x45,0x45,0x45,0x56,0x46,0x46,0x57,0x57,0x68,
	+ 	0x43,0x43,0x33,0x44,0x44,0x44,0x55,0x45,0x45,0x56,0x56,0x46,0x46,0x57,0x68,0x68,
	+ 	0x43,0x43,0x43,0x44,0x44,0x55,0x55,0x45,0x45,0x56,0x67,0x46,0x46,0x57,0x68,0x79,
	+ 	0x47,0x47,0x47,0x48,0x48,0x48,0x48,0x49,0x49,0x49,0x49,0x4a,0x4a,0x4a,0x5b,0x79,
	+ 	0x47,0x47,0x47,0x48,0x48,0x48,0x48,0x49,0x49,0x49,0x5a,0x4a,0x4a,0x4a,0x5b,0x6c,
	+ 	0x47,0x47,0x47,0x48,0x48,0x59,0x59,0x49,0x49,0x5a,0x5a,0x4a,0x4a,0x5b,0x5b,0x6c,
	+ 	0x58,0x58,0x58,0x59,0x59,0x59,0x6a,0x49,0x5a,0x5a,0x6b,0x6b,0x5b,0x5b,0x6c,0x7d,
	+ 	0x4b,0x4b,0x4b,0x4c,0x4c,0x4c,0x4c,0x4d,0x4d,0x4d,0x6b,0x4e,0x4e,0x4e,0x6c,0x7d,
	+ 	0x4b,0x4b,0x4b,0x4c,0x4c,0x4c,0x4c,0x4d,0x4d,0x4d,0x5e,0x4e,0x4e,0x4e,0x5f,0x5f,
	+ 	0x5c,0x5c,0x5c,0x4c,0x5d,0x5d,0x5d,0x4d,0x4d,0x5e,0x5e,0x4e,0x4e,0x5f,0x5f,0x60,
	+ 	0x5c,0x5c,0x5c,0x5d,0x5d,0x6e,0x6e,0x5e,0x5e,0x5e,0x6f,0x6f,0x5f,0x5f,0x60,0x60,
	+ 	0x6d,0x6d,0x6d,0x6e,0x6e,0x6e,0x7f,0x7f,0x6f,0x6f,0x70,0x70,0x5f,0x60,0x60,0x71,
	+ 	0x4f,0x4f,0x40,0x40,0x40,0x40,0x51,0x41,0x41,0x52,0x63,0x42,0x42,0x53,0x64,0x75,
	+ 	0x4f,0x4f,0x22,0x40,0x40,0x40,0x51,0x41,0x41,0x52,0x63,0x42,0x42,0x53,0x64,0x75,
	+ 	0x43,0x22,0x33,0x33,0x33,0x40,0x51,0x41,0x41,0x52,0x63,0x42,0x42,0x53,0x64,0x75,
	+ 	0x43,0x43,0x33,0x33,0x44,0x44,0x44,0x45,0x45,0x45,0x56,0x46,0x46,0x57,0x57,0x68,
	+ 	0x43,0x43,0x33,0x44,0x44,0x44,0x55,0x45,0x45,0x56,0x56,0x46,0x46,0x57,0x68,0x68,
	+ 	0x43,0x43,0x43,0x44,0x44,0x55,0x55,0x45,0x45,0x56,0x67,0x46,0x46,0x57,0x68,0x79,
	+ 	0x54,0x54,0x54,0x44,0x55,0x55,0x55,0x45,0x56,0x56,0x67,0x78,0x78,0x57,0x68,0x79,
	+ 	0x47,0x47,0x47,0x48,0x48,0x48,0x48,0x49,0x49,0x49,0x49,0x4a,0x4a,0x4a,0x5b,0x79,
	+ 	0x47,0x47,0x47,0x48,0x48,0x48,0x59,0x49,0x49,0x49,0x5a,0x4a,0x4a,0x5b,0x5b,0x6c,
	+ 	0x58,0x58,0x58,0x48,0x59,0x59,0x59,0x49,0x49,0x5a,0x5a,0x4a,0x4a,0x5b,0x6c,0x6c,
	+ 	0x69,0x69,0x69,0x59,0x59,0x6a,0x6a,0x49,0x5a,0x5a,0x6b,0x6b,0x5b,0x5b,0x6c,0x7d,
	+ 	0x4b,0x4b,0x4b,0x4c,0x4c,0x4c,0x7b,0x4d,0x4d,0x4d,0x6b,0x4e,0x4e,0x4e,0x7d,0x7d,
	+ 	0x4b,0x4b,0x4b,0x4c,0x4c,0x4c,0x7b,0x4d,0x4d,0x4d,0x5e,0x4e,0x4e,0x4e,0x5f,0x7d,
	+ 	0x5c,0x5c,0x5c,0x5d,0x5d,0x5d,0x5d,0x4d,0x5e,0x5e,0x5e,0x4e,0x4e,0x5f,0x5f,0x60,
	+ 	0x6d,0x6d,0x6d,0x5d,0x6e,0x6e,0x6e,0x5e,0x5e,0x6f,0x6f,0x70,0x5f,0x5f,0x60,0x60,
	+ 	0x7e,0x7e,0x7e,0x6e,0x6e,0x7f,0x7f,0x7f,0x6f,0x6f,0x70,0x70,0x70,0x60,0x60,0x71,
	+ 	0x50,0x50,0x50,0x40,0x40,0x51,0x51,0x41,0x41,0x52,0x63,0x74,0x42,0x53,0x64,0x75,
	+ 	0x50,0x50,0x50,0x40,0x40,0x51,0x51,0x41,0x41,0x52,0x63,0x74,0x42,0x53,0x64,0x75,
	+ 	0x50,0x50,0x33,0x33,0x40,0x51,0x51,0x41,0x41,0x52,0x63,0x74,0x42,0x53,0x64,0x75,
	+ 	0x43,0x43,0x33,0x44,0x44,0x44,0x55,0x45,0x45,0x56,0x56,0x46,0x46,0x57,0x68,0x68,
	+ 	0x43,0x43,0x43,0x44,0x44,0x55,0x55,0x45,0x45,0x56,0x67,0x46,0x46,0x57,0x68,0x79,
	+ 	0x54,0x54,0x54,0x44,0x55,0x55,0x55,0x45,0x56,0x56,0x67,0x78,0x78,0x57,0x68,0x79,
	+ 	0x54,0x54,0x54,0x55,0x55,0x55,0x66,0x66,0x56,0x67,0x67,0x78,0x78,0x68,0x68,0x79,
	+ 	0x47,0x47,0x47,0x48,0x48,0x48,0x66,0x49,0x49,0x49,0x78,0x78,0x4a,0x4a,0x5b,0x79,
	+ 	0x47,0x47,0x47,0x48,0x48,0x59,0x59,0x49,0x49,0x5a,0x5a,0x4a,0x4a,0x5b,0x6c,0x6c,
	+ 	0x58,0x58,0x58,0x59,0x59,0x59,0x6a,0x49,0x5a,0x5a,0x6b,0x6b,0x5b,0x5b,0x6c,0x7d,
	+ 	0x69,0x69,0x69,0x59,0x6a,0x6a,0x6a,0x7b,0x5a,0x6b,0x6b,0x6b,0x7c,0x6c,0x6c,0x7d,
	+ 	0x7a,0x7a,0x7a,0x4c,0x4c,0x7b,0x7b,0x7b,0x4d,0x6b,0x6b,0x7c,0x7c,0x4e,0x7d,0x7d,
	+ 	0x4b,0x4b,0x4b,0x4c,0x4c,0x7b,0x7b,0x4d,0x4d,0x5e,0x7c,0x7c,0x4e,0x5f,0x5f,0x7d,
	+ 	0x5c,0x5c,0x5c,0x5d,0x5d,0x5d,0x6e,0x4d,0x5e,0x5e,0x6f,0x4e,0x5f,0x5f,0x60,0x60,
	+ 	0x6d,0x6d,0x6d,0x6e,0x6e,0x6e,0x6e,0x5e,0x6f,0x6f,0x6f,0x70,0x5f,0x60,0x60,0x71,
	+ 	0x7e,0x7e,0x7e,0x6e,0x7f,0x7f,0x7f,0x7f,0x6f,0x70,0x70,0x70,0x70,0x60,0x71,0x71,
	+ 	0x61,0x61,0x61,0x40,0x51,0x51,0x62,0x62,0x73,0x63,0x63,0x74,0x74,0x64,0x64,0x75,
	+ 	0x61,0x61,0x61,0x40,0x51,0x51,0x62,0x62,0x73,0x63,0x63,0x74,0x74,0x64,0x64,0x75,
	+ 	0x61,0x61,0x61,0x40,0x51,0x51,0x62,0x62,0x73,0x63,0x63,0x74,0x74,0x64,0x64,0x75,
	+ 	0x43,0x43,0x43,0x44,0x44,0x55,0x55,0x45,0x45,0x56,0x67,0x46,0x46,0x57,0x68,0x79,
	+ 	0x54,0x54,0x54,0x44,0x55,0x55,0x55,0x45,0x56,0x56,0x67,0x78,0x78,0x57,0x68,0x79,
	+ 	0x54,0x54,0x54,0x55,0x55,0x55,0x66,0x66,0x56,0x67,0x67,0x78,0x78,0x68,0x68,0x79,
	+ 	0x65,0x65,0x65,0x55,0x55,0x66,0x66,0x66,0x77,0x67,0x78,0x78,0x78,0x78,0x79,0x79,
	+ 	0x65,0x65,0x65,0x48,0x48,0x66,0x66,0x77,0x77,0x77,0x78,0x78,0x78,0x5b,0x79,0x79,
	+ 	0x76,0x76,0x76,0x48,0x59,0x59,0x77,0x77,0x77,0x5a,0x5a,0x4a,0x4a,0x5b,0x6c,0x6c,
	+ 	0x69,0x69,0x69,0x59,0x59,0x6a,0x6a,0x77,0x5a,0x5a,0x6b,0x6b,0x5b,0x6c,0x6c,0x7d,
	+ 	0x69,0x69,0x69,0x6a,0x6a,0x6a,0x7b,0x7b,0x5a,0x6b,0x6b,0x7c,0x7c,0x6c,0x7d,0x7d,
	+ 	0x7a,0x7a,0x7a,0x4c,0x7b,0x7b,0x7b,0x7b,0x4d,0x6b,0x7c,0x7c,0x7c,0x7c,0x7d,0x7d,
	+ 	0x7a,0x7a,0x7a,0x4c,0x7b,0x7b,0x7b,0x7b,0x4d,0x5e,0x7c,0x7c,0x7c,0x5f,0x5f,0x7d,
	+ 	0x6d,0x6d,0x6d,0x5d,0x5d,0x6e,0x7b,0x5e,0x5e,0x6f,0x6f,0x7c,0x5f,0x5f,0x60,0x60,
	+ 	0x6d,0x6d,0x6d,0x6e,0x6e,0x6e,0x7f,0x7f,0x6f,0x6f,0x70,0x70,0x5f,0x60,0x60,0x71,
	+ 	0x7e,0x7e,0x7e,0x7f,0x7f,0x7f,0x7f,0x7f,0x6f,0x70,0x70,0x70,0x70,0x60,0x71,0x71,
	+ 	0x72,0x72,0x72,0x8f,0x8f,0x62,0x62,0x73,0x73,0x80,0x74,0x81,0x81,0x81,0x92,0x75,
	+ 	0x72,0x72,0x72,0x8f,0x8f,0x62,0x62,0x73,0x73,0x80,0x74,0x81,0x81,0x81,0x92,0x75,
	+ 	0x72,0x72,0x72,0x83,0x83,0x62,0x62,0x73,0x73,0x80,0x74,0x81,0x81,0x81,0x92,0x75,
	+ 	0x82,0x82,0x82,0x83,0x83,0x83,0x83,0x84,0x84,0x84,0x84,0x85,0x85,0x85,0x96,0x79,
	+ 	0x82,0x82,0x82,0x83,0x83,0x83,0x66,0x84,0x84,0x84,0x67,0x85,0x85,0x85,0x96,0x79,
	+ 	0x65,0x65,0x65,0x83,0x83,0x66,0x66,0x66,0x84,0x84,0x78,0x78,0x85,0x85,0x96,0x79,
	+ 	0x65,0x65,0x65,0x83,0x66,0x66,0x66,0x77,0x77,0x77,0x78,0x78,0x78,0x96,0x79,0x79,
	+ 	0x76,0x76,0x76,0x87,0x87,0x66,0x77,0x77,0x77,0x88,0x78,0x89,0x89,0x89,0x89,0x79,
	+ 	0x76,0x76,0x76,0x87,0x87,0x87,0x77,0x77,0x88,0x88,0x88,0x89,0x89,0x89,0x9a,0x9a,
	+ 	0x86,0x86,0x86,0x87,0x87,0x87,0x77,0x88,0x88,0x88,0x6b,0x89,0x89,0x9a,0x9a,0x7d,
	+ 	0x7a,0x7a,0x7a,0x87,0x6a,0x7b,0x7b,0x7b,0x88,0x6b,0x6b,0x7c,0x7c,0x9a,0x7d,0x7d,
	+ 	0x8a,0x8a,0x8a,0x8b,0x8b,0x7b,0x7b,0x8c,0x8c,0x8c,0x7c,0x7c,0x8d,0x8d,0x7d,0x7d,
	+ 	0x8a,0x8a,0x8a,0x8b,0x8b,0x8b,0x7b,0x8c,0x8c,0x8c,0x7c,0x8d,0x8d,0x8d,0x9e,0x9e,
	+ 	0x8a,0x8a,0x8a,0x8b,0x8b,0x8b,0x9c,0x8c,0x8c,0x9d,0x9d,0x8d,0x8d,0x9e,0x9e,0x9e,
	+ 	0x9b,0x9b,0x9b,0x9c,0x9c,0x9c,0x7f,0x8c,0x9d,0x9d,0x70,0x70,0x9e,0x9e,0x9e,0x71,
	+ 	0x7e,0x7e,0x7e,0x7f,0x7f,0x7f,0x7f,0x7f,0x9d,0x70,0x70,0x70,0x9e,0x9e,0x71,0x71,
	+ 	0x8e,0x8e,0x8e,0x8f,0x8f,0x8f,0x73,0x73,0x80,0x80,0x91,0x81,0x81,0x92,0x92,0xa3,
	+ 	0x8e,0x8e,0x8e,0x8f,0x8f,0x8f,0x73,0x73,0x80,0x80,0x91,0x81,0x81,0x92,0x92,0xa3,
	+ 	0x82,0x82,0x82,0x83,0x83,0x83,0x73,0x73,0x80,0x80,0x91,0x81,0x81,0x92,0x92,0xa3,
	+ 	0x82,0x82,0x82,0x83,0x83,0x83,0x83,0x84,0x84,0x84,0x95,0x85,0x85,0x85,0x96,0xa7,
	+ 	0x82,0x82,0x82,0x83,0x83,0x83,0x94,0x84,0x84,0x84,0x95,0x85,0x85,0x96,0x96,0xa7,
	+ 	0x82,0x82,0x82,0x83,0x83,0x94,0x94,0x84,0x84,0x95,0x95,0x85,0x85,0x96,0xa7,0xa7,
	+ 	0x76,0x76,0x76,0x83,0x94,0x94,0x77,0x77,0x77,0x95,0x95,0x85,0x85,0x96,0xa7,0xa7,
	+ 	0x76,0x76,0x76,0x87,0x87,0x87,0x77,0x77,0x88,0x88,0x88,0x89,0x89,0x89,0x9a,0x9a,
	+ 	0x86,0x86,0x86,0x87,0x87,0x87,0x77,0x88,0x88,0x88,0x99,0x89,0x89,0x9a,0x9a,0xab,
	+ 	0x86,0x86,0x86,0x87,0x87,0x98,0x98,0x88,0x88,0x99,0x99,0x89,0x89,0x9a,0x9a,0xab,
	+ 	0x97,0x97,0x97,0x98,0x98,0x98,0x98,0x88,0x99,0x99,0x99,0x89,0x9a,0x9a,0xab,0xab,
	+ 	0x8a,0x8a,0x8a,0x8b,0x8b,0x8b,0x8b,0x8c,0x8c,0x8c,0x8c,0x8d,0x8d,0x8d,0xab,0xbc,
	+ 	0x8a,0x8a,0x8a,0x8b,0x8b,0x8b,0x8b,0x8c,0x8c,0x8c,0x9d,0x8d,0x8d,0x8d,0x9e,0x9e,
	+ 	0x9b,0x9b,0x9b,0x8b,0x9c,0x9c,0x9c,0x8c,0x9d,0x9d,0x9d,0x8d,0x8d,0x9e,0x9e,0xaf,
	+ 	0x9b,0x9b,0x9b,0x9c,0x9c,0xad,0xad,0x9d,0x9d,0x9d,0xae,0xae,0x9e,0x9e,0xaf,0xaf,
	+ 	0xac,0xac,0xac,0xad,0xad,0xad,0xad,0x9d,0xae,0xae,0xae,0xbf,0x9e,0xaf,0xaf,0xaf,
	+ 	0x9f,0x9f,0x9f,0x8f,0x90,0x90,0xa1,0x80,0x80,0x91,0x91,0x81,0x81,0x92,0xa3,0xb4,
	+ 	0x9f,0x9f,0x9f,0x8f,0x90,0x90,0xa1,0x80,0x80,0x91,0x91,0x81,0x81,0x92,0xa3,0xb4,
	+ 	0x9f,0x9f,0x9f,0x83,0x90,0x90,0xa1,0x80,0x80,0x91,0x91,0x81,0x81,0x92,0xa3,0xb4,
	+ 	0x82,0x82,0x82,0x83,0x83,0x94,0x94,0x84,0x84,0x95,0x95,0x85,0x85,0x96,0x96,0xa7,
	+ 	0x93,0x93,0x93,0x83,0x94,0x94,0x94,0x84,0x84,0x95,0x95,0x85,0x85,0x96,0xa7,0xa7,
	+ 	0x93,0x93,0x93,0x94,0x94,0x94,0xa5,0x84,0x95,0x95,0xa6,0xa6,0x96,0x96,0xa7,0xb8,
	+ 	0xa4,0xa4,0xa4,0x94,0x94,0xa5,0xa5,0x77,0x95,0x95,0xa6,0xa6,0x96,0xa7,0xa7,0xb8,
	+ 	0x86,0x86,0x86,0x87,0x87,0x87,0x77,0x88,0x88,0x88,0x99,0x89,0x89,0x9a,0x9a,0xb8,
	+ 	0x86,0x86,0x86,0x87,0x87,0x98,0x98,0x88,0x88,0x99,0x99,0x89,0x89,0x9a,0x9a,0xab,
	+ 	0x97,0x97,0x97,0x98,0x98,0x98,0x98,0x88,0x99,0x99,0x99,0x89,0x9a,0x9a,0xab,0xab,
	+ 	0x97,0x97,0x97,0x98,0x98,0xa9,0xa9,0x99,0x99,0x99,0xaa,0xaa,0x9a,0xab,0xab,0xbc,
	+ 	0x8a,0x8a,0x8a,0x8b,0x8b,0xa9,0xa9,0x8c,0x8c,0x8c,0xaa,0x8d,0x8d,0x8d,0xab,0xbc,
	+ 	0x8a,0x8a,0x8a,0x8b,0x8b,0x9c,0x9c,0x8c,0x8c,0x9d,0x9d,0x8d,0x8d,0x9e,0x9e,0xbc,
	+ 	0x9b,0x9b,0x9b,0x9c,0x9c,0x9c,0xad,0x9d,0x9d,0x9d,0xae,0x8d,0x9e,0x9e,0xaf,0xaf,
	+ 	0xac,0xac,0xac,0x9c,0xad,0xad,0xad,0x9d,0x9d,0xae,0xae,0xae,0x9e,0xaf,0xaf,0xaf,
	+ 	0xbd,0xbd,0xbd,0xad,0xad,0xbe,0xbe,0xbe,0xae,0xae,0xbf,0xbf,0xbf,0xaf,0xaf,0xb0,
	+ 	0xa0,0xa0,0xa0,0x90,0xa1,0xa1,0xa1,0xb2,0x91,0x91,0xa2,0xa2,0xb3,0xa3,0xa3,0xb4,
	+ 	0xa0,0xa0,0xa0,0x90,0xa1,0xa1,0xa1,0xb2,0x91,0x91,0xa2,0xa2,0xb3,0xa3,0xa3,0xb4,
	+ 	0xa0,0xa0,0xa0,0x90,0xa1,0xa1,0xa1,0xb2,0x91,0x91,0xa2,0xa2,0xb3,0xa3,0xa3,0xb4,
	+ 	0x93,0x93,0x93,0x94,0x94,0x94,0xa5,0x84,0x95,0x95,0xa6,0xa6,0x96,0x96,0xa7,0xb8,
	+ 	0xa4,0xa4,0xa4,0x94,0x94,0xa5,0xa5,0x84,0x95,0x95,0xa6,0xa6,0x96,0x96,0xa7,0xb8,
	+ 	0xa4,0xa4,0xa4,0x94,0xa5,0xa5,0xa5,0xb6,0x95,0xa6,0xa6,0xa6,0xb7,0xa7,0xa7,0xb8,
	+ 	0xa4,0xa4,0xa4,0xa5,0xa5,0xa5,0xb6,0xb6,0x95,0xa6,0xa6,0xb7,0xb7,0xa7,0xb8,0xb8,
	+ 	0xb5,0xb5,0xb5,0x87,0x87,0xb6,0xb6,0xb6,0x88,0x99,0xa6,0xb7,0xb7,0x9a,0xb8,0xb8,
	+ 	0x97,0x97,0x97,0x98,0x98,0x98,0x98,0x88,0x99,0x99,0x99,0x89,0x9a,0x9a,0xab,0xab,
	+ 	0x97,0x97,0x97,0x98,0x98,0xa9,0xa9,0x99,0x99,0x99,0xaa,0xaa,0x9a,0xab,0xab,0xbc,
	+ 	0xa8,0xa8,0xa8,0xa9,0xa9,0xa9,0xa9,0xa9,0x99,0xaa,0xaa,0xaa,0xbb,0xab,0xab,0xbc,
	+ 	0xa8,0xa8,0xa8,0xa9,0xa9,0xa9,0xba,0xba,0x8c,0xaa,0xaa,0xbb,0xbb,0xab,0xbc,0xbc,
	+ 	0xb9,0xb9,0xb9,0x9c,0x9c,0xba,0xba,0xba,0x9d,0x9d,0xbb,0xbb,0xbb,0x9e,0x9e,0xbc,
	+ 	0xac,0xac,0xac,0x9c,0x9c,0xad,0xad,0x9d,0x9d,0xae,0xae,0xae,0x9e,0x9e,0xaf,0xaf,
	+ 	0xac,0xac,0xac,0xad,0xad,0xad,0xbe,0xbe,0xae,0xae,0xae,0xbf,0x9e,0xaf,0xaf,0xb0,
	+ 	0xbd,0xbd,0xbd,0xbe,0xbe,0xbe,0xbe,0xbe,0xae,0xbf,0xbf,0xbf,0xbf,0xaf,0xb0,0xb0,
	+ 	0xb1,0xb1,0xb1,0xce,0xce,0xb2,0xb2,0xcf,0xcf,0xa2,0xa2,0xb3,0xb3,0xc0,0xb4,0xb4,
	+ 	0xb1,0xb1,0xb1,0xce,0xce,0xb2,0xb2,0xcf,0xcf,0xa2,0xa2,0xb3,0xb3,0xc0,0xb4,0xb4,
	+ 	0xb1,0xb1,0xb1,0xc2,0xc2,0xb2,0xb2,0xc3,0xc3,0xa2,0xa2,0xb3,0xb3,0xc0,0xb4,0xb4,
	+ 	0xc1,0xc1,0xc1,0xc2,0xc2,0xc2,0xa5,0xc3,0xc3,0xc3,0xa6,0xc4,0xc4,0xc4,0xa7,0xb8,
	+ 	0xc1,0xc1,0xc1,0xc2,0xc2,0xa5,0xb6,0xc3,0xc3,0xc3,0xa6,0xc4,0xc4,0xc4,0xb8,0xb8,
	+ 	0xb5,0xb5,0xb5,0xc2,0xa5,0xb6,0xb6,0xb6,0xc3,0xa6,0xa6,0xb7,0xb7,0xc4,0xb8,0xb8,
	+ 	0xb5,0xb5,0xb5,0xa5,0xb6,0xb6,0xb6,0xb6,0xc3,0xa6,0xb7,0xb7,0xb7,0xb7,0xb8,0xb8,
	+ 	0xc5,0xc5,0xc5,0xc6,0xc6,0xb6,0xb6,0xc7,0xc7,0xc7,0xb7,0xb7,0xc8,0xc8,0xb8,0xb8,
	+ 	0xc5,0xc5,0xc5,0xc6,0xc6,0xc6,0xc6,0xc7,0xc7,0xc7,0xaa,0xc8,0xc8,0xc8,0xab,0xbc,
	+ 	0xa8,0xa8,0xa8,0xc6,0xc6,0xa9,0xa9,0xc7,0xc7,0xaa,0xaa,0xaa,0xc8,0xc8,0xab,0xbc,
	+ 	0xa8,0xa8,0xa8,0xa9,0xa9,0xa9,0xba,0xba,0xaa,0xaa,0xaa,0xbb,0xbb,0xab,0xbc,0xbc,
	+ 	0xb9,0xb9,0xb9,0xca,0xca,0xba,0xba,0xba,0xcb,0xaa,0xbb,0xbb,0xbb,0xcc,0xbc,0xbc,
	+ 	0xb9,0xb9,0xb9,0xca,0xca,0xba,0xba,0xcb,0xcb,0xcb,0xbb,0xbb,0xcc,0xcc,0xcc,0xbc,
	+ 	0xc9,0xc9,0xc9,0xca,0xca,0xca,0xba,0xcb,0xcb,0xcb,0xae,0xcc,0xcc,0xcc,0xaf,0xaf,
	+ 	0xbd,0xbd,0xbd,0xad,0xbe,0xbe,0xbe,0xbe,0xae,0xae,0xbf,0xbf,0xcc,0xaf,0xaf,0xb0,
	+ 	0xbd,0xbd,0xbd,0xbe,0xbe,0xbe,0xbe,0xbe,0xbf,0xbf,0xbf,0xbf,0xbf,0xaf,0xb0,0xb0,
	+ 	0xcd,0xcd,0xcd,0xce,0xce,0xce,0xb2,0xcf,0xcf,0xcf,0xb3,0xb3,0xc0,0xc0,0xd1,0xb4,
	+ 	0xcd,0xcd,0xcd,0xce,0xce,0xce,0xb2,0xcf,0xcf,0xcf,0xb3,0xb3,0xc0,0xc0,0xd1,0xb4,
	+ 	0xc1,0xc1,0xc1,0xc2,0xc2,0xc2,0xb2,0xc3,0xc3,0xc3,0xb3,0xb3,0xc0,0xc0,0xd1,0xb4,
	+ 	0xc1,0xc1,0xc1,0xc2,0xc2,0xc2,0xc2,0xc3,0xc3,0xc3,0xd4,0xc4,0xc4,0xc4,0xd5,0xd5,
	+ 	0xc1,0xc1,0xc1,0xc2,0xc2,0xc2,0xb6,0xc3,0xc3,0xc3,0xd4,0xc4,0xc4,0xc4,0xd5,0xb8,
	+ 	0xc1,0xc1,0xc1,0xc2,0xc2,0xb6,0xb6,0xc3,0xc3,0xd4,0xb7,0xb7,0xc4,0xd5,0xd5,0xb8,
	+ 	0xb5,0xb5,0xb5,0xc2,0xb6,0xb6,0xb6,0xb6,0xc3,0xd4,0xb7,0xb7,0xb7,0xd5,0xd5,0xb8,
	+ 	0xc5,0xc5,0xc5,0xc6,0xc6,0xc6,0xb6,0xc7,0xc7,0xc7,0xb7,0xc8,0xc8,0xc8,0xd9,0xd9,
	+ 	0xc5,0xc5,0xc5,0xc6,0xc6,0xc6,0xc6,0xc7,0xc7,0xc7,0xd8,0xc8,0xc8,0xc8,0xd9,0xd9,
	+ 	0xc5,0xc5,0xc5,0xc6,0xc6,0xd7,0xd7,0xc7,0xc7,0xd8,0xd8,0xc8,0xc8,0xd9,0xd9,0xbc,
	+ 	0xb9,0xb9,0xb9,0xd7,0xd7,0xba,0xba,0xba,0xd8,0xd8,0xbb,0xbb,0xbb,0xd9,0xd9,0xbc,
	+ 	0xb9,0xb9,0xb9,0xca,0xca,0xba,0xba,0xcb,0xcb,0xcb,0xbb,0xbb,0xcc,0xcc,0xcc,0xbc,
	+ 	0xc9,0xc9,0xc9,0xca,0xca,0xca,0xba,0xcb,0xcb,0xcb,0xbb,0xcc,0xcc,0xcc,0xdd,0xdd,
	+ 	0xc9,0xc9,0xc9,0xca,0xca,0xdb,0xdb,0xcb,0xcb,0xdc,0xdc,0xcc,0xcc,0xdd,0xdd,0xdd,
	+ 	0xda,0xda,0xda,0xdb,0xdb,0xdb,0xdb,0xdc,0xdc,0xdc,0xdc,0xcc,0xdd,0xdd,0xdd,0xb0,
	+ 	0xbd,0xbd,0xbd,0xdb,0xbe,0xbe,0xbe,0xdc,0xdc,0xbf,0xbf,0xbf,0xdd,0xdd,0xb0,0xb0,
	+ 	0xde,0xde,0xde,0xdf,0xdf,0xdf,0xe0,0xcf,0xd0,0xd0,0xe1,0xc0,0xc0,0xd1,0xd1,0xe2,
	+ 	0xde,0xde,0xde,0xdf,0xdf,0xdf,0xe0,0xcf,0xd0,0xd0,0xe1,0xc0,0xc0,0xd1,0xd1,0xe2,
	+ 	0xde,0xde,0xde,0xdf,0xdf,0xdf,0xe0,0xc3,0xd0,0xd0,0xe1,0xc0,0xc0,0xd1,0xd1,0xe2,
	+ 	0xd2,0xd2,0xd2,0xc2,0xd3,0xd3,0xd3,0xc3,0xc3,0xd4,0xd4,0xc4,0xc4,0xd5,0xd5,0xe6,
	+ 	0xd2,0xd2,0xd2,0xd3,0xd3,0xd3,0xd3,0xc3,0xd4,0xd4,0xd4,0xc4,0xc4,0xd5,0xd5,0xe6,
	+ 	0xd2,0xd2,0xd2,0xd3,0xd3,0xd3,0xe4,0xc3,0xd4,0xd4,0xe5,0xc4,0xd5,0xd5,0xe6,0xe6,
	+ 	0xe3,0xe3,0xe3,0xd3,0xd3,0xe4,0xb6,0xd4,0xd4,0xe5,0xe5,0xb7,0xd5,0xd5,0xe6,0xe6,
	+ 	0xc5,0xc5,0xc5,0xc6,0xc6,0xc6,0xd7,0xc7,0xc7,0xd8,0xd8,0xc8,0xc8,0xd9,0xd9,0xd9,
	+ 	0xd6,0xd6,0xd6,0xc6,0xd7,0xd7,0xd7,0xc7,0xd8,0xd8,0xd8,0xc8,0xc8,0xd9,0xd9,0xea,
	+ 	0xd6,0xd6,0xd6,0xd7,0xd7,0xd7,0xe8,0xd8,0xd8,0xd8,0xe9,0xc8,0xd9,0xd9,0xea,0xea,
	+ 	0xe7,0xe7,0xe7,0xd7,0xd7,0xe8,0xe8,0xd8,0xd8,0xe9,0xe9,0xe9,0xd9,0xd9,0xea,0xea,
	+ 	0xc9,0xc9,0xc9,0xca,0xca,0xca,0xba,0xcb,0xcb,0xcb,0xe9,0xcc,0xcc,0xcc,0xea,0xea,
	+ 	0xc9,0xc9,0xc9,0xca,0xca,0xdb,0xdb,0xcb,0xcb,0xdc,0xdc,0xcc,0xcc,0xdd,0xdd,0xdd,
	+ 	0xda,0xda,0xda,0xdb,0xdb,0xdb,0xdb,0xdc,0xdc,0xdc,0xdc,0xcc,0xdd,0xdd,0xdd,0xee,
	+ 	0xda,0xda,0xda,0xdb,0xdb,0xec,0xec,0xdc,0xdc,0xed,0xed,0xed,0xdd,0xdd,0xee,0xee,
	+ 	0xeb,0xeb,0xeb,0xec,0xec,0xec,0xec,0xdc,0xed,0xed,0xed,0xed,0xdd,0xee,0xee,0xee,
	+ 	0xef,0xef,0xef,0xdf,0xe0,0xe0,0xe0,0xd0,0xd0,0xe1,0xe1,0xf2,0xd1,0xd1,0xe2,0xe2,
	+ 	0xef,0xef,0xef,0xdf,0xe0,0xe0,0xe0,0xd0,0xd0,0xe1,0xe1,0xf2,0xd1,0xd1,0xe2,0xe2,
	+ 	0xef,0xef,0xef,0xdf,0xe0,0xe0,0xe0,0xd0,0xd0,0xe1,0xe1,0xf2,0xd1,0xd1,0xe2,0xe2,
	+ 	0xd2,0xd2,0xd2,0xd3,0xd3,0xe4,0xe4,0xd4,0xd4,0xd4,0xe5,0xe5,0xd5,0xd5,0xe6,0xe6,
	+ 	0xe3,0xe3,0xe3,0xd3,0xe4,0xe4,0xe4,0xd4,0xd4,0xe5,0xe5,0xf6,0xd5,0xd5,0xe6,0xe6,
	+ 	0xe3,0xe3,0xe3,0xe4,0xe4,0xe4,0xe4,0xd4,0xe5,0xe5,0xe5,0xf6,0xd5,0xe6,0xe6,0xf7,
	+ 	0xe3,0xe3,0xe3,0xe4,0xe4,0xe4,0xf5,0xf5,0xe5,0xe5,0xf6,0xf6,0xd5,0xe6,0xe6,0xf7,
	+ 	0xd6,0xd6,0xd6,0xd7,0xd7,0xd7,0xf5,0xc7,0xd8,0xd8,0xf6,0xc8,0xd9,0xd9,0xd9,0xf7,
	+ 	0xd6,0xd6,0xd6,0xd7,0xd7,0xe8,0xe8,0xd8,0xd8,0xd8,0xe9,0xe9,0xd9,0xd9,0xea,0xea,
	+ 	0xe7,0xe7,0xe7,0xd7,0xe8,0xe8,0xe8,0xd8,0xd8,0xe9,0xe9,0xe9,0xd9,0xea,0xea,0xea,
	+ 	0xe7,0xe7,0xe7,0xe8,0xe8,0xe8,0xf9,0xf9,0xe9,0xe9,0xe9,0xfa,0xd9,0xea,0xea,0xfb,
	+ 	0xf8,0xf8,0xf8,0xe8,0xf9,0xf9,0xf9,0xcb,0xe9,0xe9,0xfa,0xfa,0xcc,0xea,0xea,0xfb,
	+ 	0xda,0xda,0xda,0xdb,0xdb,0xdb,0xdb,0xdc,0xdc,0xdc,0xdc,0xcc,0xdd,0xdd,0xdd,0xee,
	+ 	0xda,0xda,0xda,0xdb,0xdb,0xec,0xec,0xdc,0xdc,0xed,0xed,0xed,0xdd,0xdd,0xee,0xee,
	+ 	0xeb,0xeb,0xeb,0xec,0xec,0xec,0xec,0xdc,0xed,0xed,0xed,0xed,0xdd,0xee,0xee,0xee,
	+ 	0xeb,0xeb,0xeb,0xec,0xec,0xfd,0xfd,0xfd,0xed,0xed,0xfe,0xfe,0xee,0xee,0xee,0xff,
	+ 	0xf0,0xf0,0xf0,0xe0,0xf1,0xf1,0xf1,0xf1,0xe1,0xf2,0xf2,0xf2,0xf2,0xe2,0xe2,0xf3,
	+ 	0xf0,0xf0,0xf0,0xe0,0xf1,0xf1,0xf1,0xf1,0xe1,0xf2,0xf2,0xf2,0xf2,0xe2,0xe2,0xf3,
	+ 	0xf0,0xf0,0xf0,0xe0,0xf1,0xf1,0xf1,0xf1,0xe1,0xf2,0xf2,0xf2,0xf2,0xe2,0xe2,0xf3,
	+ 	0xe3,0xe3,0xe3,0xe4,0xe4,0xe4,0xf5,0xf5,0xe5,0xe5,0xf6,0xf6,0xd5,0xe6,0xe6,0xf7,
	+ 	0xf4,0xf4,0xf4,0xe4,0xe4,0xf5,0xf5,0xf5,0xe5,0xe5,0xf6,0xf6,0xf6,0xe6,0xe6,0xf7,
	+ 	0xf4,0xf4,0xf4,0xe4,0xf5,0xf5,0xf5,0xf5,0xe5,0xf6,0xf6,0xf6,0xf6,0xe6,0xf7,0xf7,
	+ 	0xf4,0xf4,0xf4,0xf5,0xf5,0xf5,0xf5,0xf5,0xe5,0xf6,0xf6,0xf6,0xf6,0xe6,0xf7,0xf7,
	+ 	0xf4,0xf4,0xf4,0xf5,0xf5,0xf5,0xf5,0xf5,0xd8,0xf6,0xf6,0xf6,0xd9,0xd9,0xf7,0xf7,
	+ 	0xe7,0xe7,0xe7,0xe8,0xe8,0xe8,0xe8,0xd8,0xe9,0xe9,0xe9,0xfa,0xd9,0xea,0xea,0xea,
	+ 	0xf8,0xf8,0xf8,0xe8,0xe8,0xf9,0xf9,0xf9,0xe9,0xe9,0xfa,0xfa,0xfa,0xea,0xea,0xfb,
	+ 	0xf8,0xf8,0xf8,0xf9,0xf9,0xf9,0xf9,0xf9,0xe9,0xfa,0xfa,0xfa,0xfa,0xea,0xfb,0xfb,
	+ 	0xf8,0xf8,0xf8,0xf9,0xf9,0xf9,0xf9,0xf9,0xfa,0xfa,0xfa,0xfa,0xfa,0xea,0xfb,0xfb,
	+ 	0xf8,0xf8,0xf8,0xdb,0xf9,0xf9,0xf9,0xdc,0xdc,0xfa,0xfa,0xfa,0xdd,0xdd,0xee,0xfb,
	+ 	0xeb,0xeb,0xeb,0xec,0xec,0xec,0xec,0xdc,0xed,0xed,0xed,0xed,0xdd,0xee,0xee,0xee,
	+ 	0xeb,0xeb,0xeb,0xec,0xec,0xfd,0xfd,0xfd,0xed,0xed,0xfe,0xfe,0xee,0xee,0xee,0xff,
	+ 	0xfc,0xfc,0xfc,0xfd,0xfd,0xfd,0xfd,0xfd,0xed,0xfe,0xfe,0xfe,0xfe,0xee,0xff,0xff,
	  }
	+ };
	+ Memcmap *memdefcmap = &def;
	+ void _memmkcmap(void){}
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1982 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmemdraw/cread.c
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/cread.c:1,43 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/cread.c:1,22
	- #include "../lib9.h"
	+ #include <u.h>
	+ #include <libc.h>
	+ #include <draw.h>
	+ #include <memdraw.h>
	  
	- #include "../libdraw/draw.h"
	- #include "../libmemdraw/memdraw.h"
	- 
	- /*
	-  * compressed data are sequences of byte codes.  
	-  * if the first byte b has the 0x80 bit set, the next (b^0x80)+1 bytes
	-  * are data.  otherwise, it's two bytes specifying a previous string to repeat.
	-  */
	- static void
	- twiddlecompressed(uchar *buf, int n)
	- {
	- 	uchar *ebuf;
	- 	int j, k, c;
	- 
	- 	ebuf = buf+n;
	- 	while(buf < ebuf){
	- 		c = *buf++;
	- 		if(c >= 128){
	- 			k = c-128+1;
	- 			for(j=0; j<k; j++, buf++)
	- 				*buf ^= 0xFF;
	- 		}else
	- 			buf++;
	- 	}
	- }
	- 
	  Memimage*
	  creadmemimage(int fd)
	  {
	  	char hdr[5*12+1];
	  	Rectangle r;
	- 	int m, nb, miny, maxy, new, ldepth;
	+ 	int m, nb, miny, maxy, new, ldepth, ncblock;
	  	uchar *buf;
	  	Memimage *i;
	  	ulong chan;
	  
	- 	if(readn(fd, hdr, 5*12) != 5*12)
	+ 	if(readn(fd, hdr, 5*12) != 5*12){
	+ 		werrstr("readmemimage: short header (2)");
	  		return nil;
	+ 	}
	  
	  	/*
	  	 * distinguish new channel descriptor from old ldepth.
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/cread.c:81,92 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/cread.c:60,74
	  	i = allocmemimage(r, chan);
	  	if(i == nil)
	  		return nil;
	- 	buf = malloc(NCBLOCK);
	+ 	ncblock = _compblocksize(r, i->depth);
	+ 	buf = malloc(ncblock);
	  	if(buf == nil)
	  		goto Errout;
	  	miny = r.min.y;
	  	while(miny != r.max.y){
	  		if(readn(fd, hdr, 2*12) != 2*12){
	+ 		Shortread:
	+ 			werrstr("readmemimage: short read");
	  		Errout:
	  			freememimage(i);
	  			free(buf);
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/cread.c:98,111 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/cread.c:80,93
	  			werrstr("readimage: bad maxy %d", maxy);
	  			goto Errout;
	  		}
	- 		if(nb<=0 || NCBLOCK<nb){
	+ 		if(nb<=0 || ncblock<nb){
	  			werrstr("readimage: bad count %d", nb);
	  			goto Errout;
	  		}
	  		if(readn(fd, buf, nb)!=nb)
	- 			goto Errout;
	+ 			goto Shortread;
	  		if(!new)	/* old image: flip the data bits */
	- 			twiddlecompressed(buf, nb);
	+ 			_twiddlecompressed(buf, nb);
	  		cloadmemimage(i, Rect(r.min.x, miny, r.max.x, maxy), buf, nb);
	  		miny = maxy;
	  	}
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1293 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmemdraw/defont.c
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/defont.c:1,8 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/defont.c:1,8
	- #include "../lib9.h"
	+ #include <u.h>
	+ #include <libc.h>
	+ #include <draw.h>
	+ #include <memdraw.h>
	  
	- #include "../libdraw/draw.h"
	- #include "../libmemdraw/memdraw.h"
	- 
	  Memsubfont*
	  getmemdefont(void)
	  {
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/defont.c:12,17 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/defont.c:12,18
	  	Memsubfont *f;
	  	int ld;
	  	Rectangle r;
	+ 	Memdata *md;
	  	Memimage *i;
	  
	  	/*
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/defont.c:31,44 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/defont.c:32,54
	  	r.max.x = atoi(p+3*12);
	  	r.max.y = atoi(p+4*12);
	  
	+ 	md = mallocz(sizeof(Memdata), 1);
	+ 	if(md == nil)
	+ 		return nil;
	+ 	
	  	p += 5*12;
	  
	- 	i = allocmemimage(r, drawld2chan[ld]);
	- 	if(i == nil)
	+ 	md->base = nil;		/* so freememimage doesn't free p */
	+ 	md->bdata = (uchar*)p;	/* ick */
	+ 	md->ref = 1;
	+ 	md->allocd = 1;		/* so freememimage does free md */
	+ 
	+ 	i = allocmemimaged(r, drawld2chan[ld], md, nil);
	+ 	if(i == nil){
	+ 		free(md);
	  		return nil;
	- 		
	- 	loadmemimage(i, i->r, (uchar*)p, Dy(r)*i->width*sizeof(ulong));
	- 	
	+ 	}
	+ 
	  	hdr = p+Dy(r)*i->width*sizeof(ulong);
	  	n = atoi(hdr);
	  	p = hdr+3*12;
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 54684 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmemdraw/draw.c
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1,7 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1,10
	- #include "../lib9.h"
	+ #include <u.h>
	+ #include <libc.h>
	+ #include <draw.h>
	+ #include <memdraw.h>
	  
	- #include "../libdraw/draw.h"
	- #include "../libmemdraw/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)
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:15,20 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:18,32
	  #define DIV255(x) ((((x)+1)*257)>>16)
	  /* #define DIV255(x) (tmp=(x)+1, (tmp+(tmp>>8))>>8) */
	  
	+ #define MUL(x, y, t)	(t = (x)*(y)+128, (t+(t>>8))>>8)
	+ #define MASK13	0xFF00FF00
	+ #define MASK02	0x00FF00FF
	+ #define MUL13(a, x, t)		(t = (a)*(((x)&MASK13)>>8)+128, ((t+((t>>8)&MASK02))>>8)&MASK02)
	+ #define MUL02(a, x, t)		(t = (a)*(((x)&MASK02)>>0)+128, ((t+((t>>8)&MASK02))>>8)&MASK02)
	+ #define MUL0123(a, x, s, t)	((MUL13(a, x, s)<<8)|MUL02(a, x, t))
	+ 
	+ #define MUL2(u, v, x, y)	(t = (u)*(v)+(x)*(y)+256, (t+(t>>8))>>8)
	+ 
	  static void mktables(void);
	  typedef int Subdraw(Memdrawparam*);
	  static Subdraw chardraw, alphadraw, memoptdraw;
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:26,55 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:38,45
	  Memimage *memtransparent;
	  Memimage *memopaque;
	  
	- int
	- Rconv(va_list *o, Fconv *f)
	- {
	- 	Rectangle r;
	- 	char buf[128];
	+ int	_ifmt(Fmt*);
	  
	- 	r = va_arg(*o, Rectangle);
	- 	sprint(buf, "%P %P", r.min, r.max);
	- 	strconv(buf, f);
	- 	return sizeof r;
	- }
	- 
	- int
	- Pconv(va_list *o, Fconv *f)
	- {
	- 	Point p;
	- 	char buf[64];
	- 
	- 	p = va_arg(*o, Point);
	- 	sprint(buf, "[%d %d]", p.x, p.y);
	- 	strconv(buf, f);
	- 	return sizeof p;
	- }
	- 
	  void
	  _memimageinit(void)
	  {
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:60,71 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:50,62
	  
	  	didinit = 1;
	  
	- 	fmtinstall('R', Rconv);
	- 	fmtinstall('P', Pconv);
	- 
	  	mktables();
	- 	memmkcmap();
	+ 	_memmkcmap();
	  
	+ 	fmtinstall('R', Rfmt); 
	+ 	fmtinstall('P', Pfmt);
	+ 	fmtinstall('b', _ifmt);
	+ 
	  	memones = allocmemimage(Rect(0,0,1,1), GREY1);
	  	memones->flags |= Frepl;
	  	memones->clipr = Rect(-0x3FFFFFF, -0x3FFFFFF, 0x3FFFFFF, 0x3FFFFFF);
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:85,128 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:76,110
	  	memtransparent = memzeros;
	  }
	  
	- int
	- drawreplxy(int min, int max, int x)
	- {
	- 	int sx;
	+ ulong _imgtorgba(Memimage*, ulong);
	+ ulong _rgbatoimg(Memimage*, ulong);
	+ ulong _pixelbits(Memimage*, Point);
	  
	- 	sx = (x-min)%(max-min);
	- 	if(sx < 0)
	- 		sx += max-min;
	- 	return sx+min;
	- }
	- 
	- Point
	- drawrepl(Rectangle r, Point p)
	- {
	- 	p.x = drawreplxy(r.min.x, r.max.x, p.x);
	- 	p.y = drawreplxy(r.min.y, r.max.y, p.y);
	- 	return p;
	- }
	- 
	  #define DBG if(0)
	- static	Memdrawparam par;	/* sleazily left for the X implementation */
	+ static Memdrawparam par;
	+ 
	  Memdrawparam*
	- _memimagedrawsetup(Memimage *dst, Rectangle r, Memimage *src, Point p0, Memimage *mask, Point p1)
	+ _memimagedrawsetup(Memimage *dst, Rectangle r, Memimage *src, Point p0, Memimage *mask, Point p1, int op)
	  {
	- 	static int n = 0;
	  
	  	if(mask == nil)
	  		mask = memopaque;
	  
	- 	if(drawdebug)
	- 		iprint("memimagedraw %p/%luX %R %p/%luX %P %p/%luX %P... ", dst, dst->chan, r, src, src->chan, p0, mask, mask->chan, p1);
	+ DBG	print("memimagedraw %p/%luX %R @ %p %p/%luX %P %p/%luX %P... ", dst, dst->chan, r, dst->data->bdata, src, src->chan, p0, mask, mask->chan, p1);
	  
	  	if(drawclip(dst, &r, src, &p0, mask, &p1, &par.sr, &par.mr) == 0){
	- 		if(drawdebug)
	- 			iprint("empty clipped rectangle\n");
	+ //		if(drawdebug)
	+ //			iprint("empty clipped rectangle\n");
	  		return nil;
	  	}
	  
	+ 	if(op < Clear || op > SoverD){
	+ //		if(drawdebug)
	+ //			iprint("op out of range: %d\n", op);
	+ 		return nil;
	+ 	}
	+ 
	+ 	par.op = op;
	  	par.dst = dst;
	  	par.r = r;
	  	par.src = src;
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:134,143 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:116,129
	  	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);
	+ 			if((par.srgba&0xFF) == 0 && (op&DoutS)){
	+ //				if (drawdebug) iprint("fill with transparent source\n");
	+ 				return nil;	/* no-op successfully handled */
	+ 			}
	  		}
	  	}
	  
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:144,152 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:130,138
	  	if(mask->flags & Frepl){
	  		par.state |= Replmask;
	  		if(Dx(mask->r)==1 && Dy(mask->r)==1){
	- 			par.mval = pixelbits(mask, mask->r.min);
	- 			if(par.mval == 0){
	- 				if(drawdebug) iprint("fill with zero mask\n");
	+ 			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 */
	  			}
	  			par.state |= Simplemask;
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:156,164 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:142,150
	  		}
	  	}
	  
	- 	if(drawdebug)
	- 		iprint("dr %R sr %R mr %R...", r, par.sr, par.mr);
	- DBG print("draw dr %R sr %R mr %R\n", r, par.sr, par.mr);
	+ //	if(drawdebug)
	+ //		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;
	  }
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:166,174 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:152,160
	  void
	  _memimagedraw(Memdrawparam *par)
	  {
	- 	if(par == nil)
	+ 	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
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:181,199 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:167,186
	  	 * which checks to see if there is anything it can help with.
	  	 * There could be an if around this checking to see if dst is in video memory.
	  	 */
	- 	if(hwdraw(par))
	- {
	- if(drawdebug) iprint("hw handled\n");
	+ DBG print("test hwdraw\n");
	+ 	if(hwdraw(par)){
	+ //if(drawdebug) iprint("hw handled\n");
	+ DBG print("hwdraw handled\n");
	  		return;
	- }
	+ 	}
	  	/*
	  	 * Optimizations using memmove and memset.
	  	 */
	+ DBG print("test memoptdraw\n");
	  	if(memoptdraw(par)){
	- if(drawdebug) iprint("memopt handled\n");
	- {
	+ //if(drawdebug) iprint("memopt handled\n");
	+ DBG print("memopt handled\n");
	  		return;
	- }
	  	}
	  
	  	/*
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:200,207 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:187,196
	  	 * Character drawing.
	  	 * Solid source color being painted through a boolean mask onto a high res image.
	  	 */
	+ DBG print("test chardraw\n");
	  	if(chardraw(par)){
	- if(drawdebug) iprint("chardraw handled\n");
	+ //if(drawdebug) iprint("chardraw handled\n");
	+ DBG print("chardraw handled\n");
	  		return;
	  	}
	  
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:208,216 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:197,206
	  	/*
	  	 * General calculation-laden case that does alpha for each pixel.
	  	 */
	+ DBG print("do alphadraw\n");
	  	alphadraw(par);
	- if(drawdebug) iprint("alphadraw handled\n");
	- 	return;
	+ //if(drawdebug) iprint("alphadraw handled\n");
	+ DBG print("alphadraw handled\n");
	  }
	  #undef DBG
	  
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:229,235 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:219,224
	  	Point rmin, delta;
	  	int splitcoords;
	  	Rectangle omr;
	- 	Point p;
	  
	  	if(r->min.x>=r->max.x || r->min.y>=r->max.y)
	  		return 0;
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:301,310 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:290,296
	  	*p0 = sr->min;
	  
	  	/* move mask point so it is in mask->r */
	- 	/* use temporary point p to avoid warnings about unaligned volatiles on digital unix */
	- 	p = *p1;
	- 	p = drawrepl(mask->r, p);
	- 	*p1 = p;
	+ 	*p1 = drawrepl(mask->r, *p1);
	  	mr->min = *p1;
	  	mr->max.x = p1->x+Dx(*sr);
	  	mr->max.y = p1->y+Dy(*sr);
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:311,319 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:297,305
	  
	  	assert(Dx(*sr) == Dx(*mr) && Dx(*mr) == Dx(*r));
	  	assert(Dy(*sr) == Dy(*mr) && Dy(*mr) == Dy(*r));
	- 	assert((p=*p0, ptinrect(p, src->r)));
	- 	assert((p=*p1, ptinrect(p, mask->r)));
	- 	assert((p=r->min, ptinrect(p, dst->r)));
	+ 	assert(ptinrect(*p0, src->r));
	+ 	assert(ptinrect(*p1, mask->r));
	+ 	assert(ptinrect(r->min, dst->r));
	  
	  	return 1;
	  }
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:322,331 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:308,313
	   * Conversion tables.
	   */
	  static uchar replbit[1+8][256];		/* replbit[x][y] is the replication of the x-bit quantity y to 8-bit depth */
	- static uchar conv18[256][8];		/* conv18[x][y] is the yth pixel in the depth-1 pixel x */
	- static uchar conv28[256][4];		/* ... */
	- static uchar conv48[256][2];
	- static int	tablesbuilt;
	  
	  /*
	   * bitmap of how to replicate n bits to fill 8, for 1 ≤ n ≤ 8.
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:359,370 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:341,355
	  static void
	  mktables(void)
	  {
	- 	int i, j, mask, sh, small;
	+ 	int i, j, 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] */
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:373,403 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:358,382
	  		}
	  	}
	  
	- 	/* bit unpacking up to 8 bits, only powers of 2 */
	- 	for(i=0; i<256; i++){
	- 		for(j=0, sh=7, mask=1; j<8; j++, sh--)
	- 			conv18[i][j] = replbit[1][(i>>sh)&mask];
	- 
	- 		for(j=0, sh=6, mask=3; j<4; j++, sh-=2)
	- 			conv28[i][j] = replbit[2][(i>>sh)&mask];
	- 
	- 		for(j=0, sh=4, mask=15; j<2; j++, sh-=4)
	- 			conv48[i][j] = replbit[4][(i>>sh)&mask];
	- 	}
	  }
	  
	+ static uchar ones = 0xff;
	+ 
	  /*
	   * General alpha drawing case.  Can handle anything.
	   */
	  typedef struct	Buffer	Buffer;
	  struct Buffer {
	+ 	/* used by most routines */
	  	uchar	*red;
	  	uchar	*grn;
	  	uchar	*blu;
	  	uchar	*alpha;
	  	uchar	*grey;
	- 
	+ 	ulong	*rgba;
	  	int	delta;	/* number of bytes to add to pointer to get next pixel to the right */
	+ 
	+ 	/* used by boolcalc* for mask data */
	  	uchar	*m;		/* ptr to mask data r.min byte; like p->bytermin */
	  	int		mskip;	/* no. of left bits to skip in *m */
	  	uchar	*bm;		/* ptr to mask data img->r.min byte; like p->bytey0s */
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:407,415 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:386,394
	  };
	  
	  typedef struct	Param	Param;
	- typedef Buffer	Readfn(Param *notusedpar, uchar *notusedbuf, int notusedi);
	- typedef void	Writefn(Param *notusedpar, uchar *notusedbuf, Buffer notusedb);
	- typedef Buffer	Calcfn(Buffer, Buffer, Buffer, int, int notusedi);
	+ typedef Buffer	Readfn(Param*, uchar*, int);
	+ typedef void	Writefn(Param*, uchar*, Buffer);
	+ typedef Buffer	Calcfn(Buffer, Buffer, Buffer, int, int, int);
	  
	  enum {
	  	MAXBCACHE = 16
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:455,462 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:434,441
	  static Param spar, mpar, dpar;	/* easier on the stacks */
	  static Readfn	greymaskread, replread, readptr;
	  static Writefn	nullwrite;
	- static Calcfn	alphacalc;
	- static Calcfn	boolcalc;
	+ static Calcfn	alphacalc0, alphacalc14, alphacalc2810, alphacalc3679, alphacalc5, alphacalc11, alphacalcS;
	+ static Calcfn	boolcalc14, boolcalc236789, boolcalc1011;
	  
	  static Readfn*	readfn(Memimage*);
	  static Readfn*	readalphafn(Memimage*);
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:463,471 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:442,481
	  static Writefn*	writefn(Memimage*);
	  
	  static Calcfn*	boolcopyfn(Memimage*, Memimage*);
	- static Readfn*	convfn(Memimage*, Param *notusedpar, Memimage*, Param*);
	- static Readfn*	ptrfn(Memimage*);
	+ static Readfn*	convfn(Memimage*, Param*, Memimage*, Param*);
	  
	+ static Calcfn *alphacalc[Ncomp] = 
	+ {
	+ 	alphacalc0,		/* Clear */
	+ 	alphacalc14,		/* DoutS */
	+ 	alphacalc2810,		/* SoutD */
	+ 	alphacalc3679,		/* DxorS */
	+ 	alphacalc14,		/* DinS */
	+ 	alphacalc5,		/* D */
	+ 	alphacalc3679,		/* DatopS */
	+ 	alphacalc3679,		/* DoverS */
	+ 	alphacalc2810,		/* SinD */
	+ 	alphacalc3679,		/* SatopD */
	+ 	alphacalc2810,		/* S */
	+ 	alphacalc11,		/* SoverD */
	+ };
	+ 
	+ static Calcfn *boolcalc[Ncomp] =
	+ {
	+ 	alphacalc0,		/* Clear */
	+ 	boolcalc14,		/* DoutS */
	+ 	boolcalc236789,		/* SoutD */
	+ 	boolcalc236789,		/* DxorS */
	+ 	boolcalc14,		/* DinS */
	+ 	alphacalc5,		/* D */
	+ 	boolcalc236789,		/* DatopS */
	+ 	boolcalc236789,		/* DoverS */
	+ 	boolcalc236789,		/* SinD */
	+ 	boolcalc236789,		/* SatopD */
	+ 	boolcalc1011,		/* S */
	+ 	boolcalc1011,		/* SoverD */
	+ };
	+ 
	  static int
	  allocdrawbuf(void)
	  {
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:543,566 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:553,576
	  	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;
	  			}
	  		}
	- 		if(p=b.alpha){
	+ 		if((p=b.alpha) != &ones){
	  			print(" α%.2uX", *p);
	  			b.alpha += b.delta;
	  		}
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:587,593 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:597,603
	  static int
	  alphadraw(Memdrawparam *par)
	  {
	- 	int isgrey, starty, endy;
	+ 	int isgrey, starty, endy, op;
	  	int needbuf, dsty, srcy, masky;
	  	int y, dir, dx, dy;
	  	Buffer bsrc, bdst, bmask;
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:608,613 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:618,624
	  	dst = par->dst;
	  	sr = par->sr;
	  	mr = par->mr;
	+ 	op = par->op;
	  
	  	isgrey = dst->flags&Fgrey;
	  
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:620,627 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:631,638
	  	needbuf = (src->data == dst->data);
	  
	  	spar = getparam(src, sr, isgrey, needbuf);
	- 	mpar = getparam(mask, mr, isgrey, needbuf);
	  	dpar = getparam(dst, r, isgrey, needbuf);
	+ 	mpar = getparam(mask, mr, 0, needbuf);
	  
	  	dir = (needbuf && byteaddr(dst, r.min) > byteaddr(src, sr.min)) ? -1 : 1;
	  	spar.dir = mpar.dir = dpar.dir = dir;
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:641,649 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:652,660
	  	 * but it avoids a fair amount of code duplication to make this a case here
	  	 * rather than have a separate booldraw.
	  	 */
	- 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){
	- if(drawdebug) iprint("boolcopy...");
	+ //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);
	  		rddst = readptr;
	  		rdmask = readfn(mask);
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:654,660 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:665,671
	  		rdsrc = readfn(src);
	  		rddst = readfn(dst);
	  		wrdst = writefn(dst);
	- 		calc = alphacalc;
	+ 		calc = alphacalc[op];
	  
	  		/*
	  		 * If there is no alpha channel, we'll ask for a grey channel
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:677,683 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:688,696
	  			 * we can avoid all the division and multiplication.
	  			 */
	  			if(mask->chan == GREY1 && !(src->flags&Falpha))
	- 				calc = boolcalc;
	+ 				calc = boolcalc[op];
	+ 			else if(op == SoverD && !(src->flags&Falpha))
	+ 				calc = alphacalcS;
	  		}
	  	}
	  
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:741,747 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:754,760
	  DBG		dumpbuf("src", bsrc, dx);
	  DBG		dumpbuf("mask", bmask, dx);
	  DBG		dumpbuf("dst", bdst, dx);
	- 		bdst = calc(bdst, bsrc, bmask, dx, isgrey);
	+ 		bdst = calc(bdst, bsrc, bmask, dx, isgrey, op);
	  		wrdst(&dpar, dpar.bytermin+dsty*dpar.bwidth, bdst);
	  	}
	  
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:749,861 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:762,1227
	  }
	  #undef DBG
	  
	- #define DBG if(0)
	  static Buffer
	- alphacalc(Buffer bdst, Buffer bsrc, Buffer bmask, int dx, int grey)
	+ alphacalc0(Buffer bdst, Buffer b1, Buffer b2, int dx, int grey, int op)
	  {
	+ 	USED(grey);
	+ 	USED(op);
	+ 	memset(bdst.rgba, 0, dx*bdst.delta);
	+ 	return bdst;
	+ }
	+ 
	+ static Buffer
	+ alphacalc14(Buffer bdst, Buffer bsrc, Buffer bmask, int dx, int grey, int op)
	+ {
	  	Buffer obdst;
	- 	uchar *salpha, ones = ~0;
	- 	int antialpha, sadelta;
	- 	int i, sa, ma;
	+ 	int fd, sadelta;
	+ 	int i, sa, ma, q;
	+ 	ulong s, t;
	  
	  	obdst = bdst;
	- 	if((salpha = bsrc.alpha) == nil)
	- 		salpha = &ones, sadelta = 0;
	- 	else
	- 		sadelta = bsrc.delta;
	+ 	sadelta = bsrc.alpha == &ones ? 0 : bsrc.delta;
	+ 	q = bsrc.delta == 4 && bdst.delta == 4;
	  
	  	for(i=0; i<dx; i++){
	- 		sa = *salpha;
	+ 		sa = *bsrc.alpha;
	  		ma = *bmask.alpha;
	- 		antialpha = 255-DIV255(ma*sa);
	+ 		fd = MUL(sa, ma, t);
	+ 		if(op == DoutS)
	+ 			fd = 255-fd;
	  
	  		if(grey){
	- DBG print("(%d %d in %d) over %d =", *bsrc.grey, sa, ma, *bdst.grey);
	- 			*bdst.grey = DIV255(*bsrc.grey*ma+*bdst.grey*antialpha);
	- DBG print(" %d\n", *bdst.grey);
	+ 			*bdst.grey = MUL(fd, *bdst.grey, t);
	  			bsrc.grey += bsrc.delta;
	  			bdst.grey += bdst.delta;
	  		}else{
	- 			*bdst.red = DIV255(*bsrc.red*ma+*bdst.red*antialpha);
	- 			*bdst.grn = DIV255(*bsrc.grn*ma+*bdst.grn*antialpha);
	- 			*bdst.blu = DIV255(*bsrc.blu*ma+*bdst.blu*antialpha);
	+ 			if(q){
	+ 				*bdst.rgba = MUL0123(fd, *bdst.rgba, s, t);
	+ 				bsrc.rgba++;
	+ 				bdst.rgba++;
	+ 				bsrc.alpha += sadelta;
	+ 				bmask.alpha += bmask.delta;
	+ 				continue;
	+ 			}
	+ 			*bdst.red = MUL(fd, *bdst.red, t);
	+ 			*bdst.grn = MUL(fd, *bdst.grn, t);
	+ 			*bdst.blu = MUL(fd, *bdst.blu, t);
	+ 			bsrc.red += bsrc.delta;
	+ 			bsrc.blu += bsrc.delta;
	+ 			bsrc.grn += bsrc.delta;
	+ 			bdst.red += bdst.delta;
	+ 			bdst.blu += bdst.delta;
	+ 			bdst.grn += bdst.delta;
	+ 		}
	+ 		if(bdst.alpha != &ones){
	+ 			*bdst.alpha = MUL(fd, *bdst.alpha, t);
	+ 			bdst.alpha += bdst.delta;
	+ 		}
	+ 		bmask.alpha += bmask.delta;
	+ 		bsrc.alpha += sadelta;
	+ 	}
	+ 	return obdst;
	+ }
	  
	+ static Buffer
	+ alphacalc2810(Buffer bdst, Buffer bsrc, Buffer bmask, int dx, int grey, int op)
	+ {
	+ 	Buffer obdst;
	+ 	int fs, sadelta;
	+ 	int i, ma, da, q;
	+ 	ulong s, t;
	+ 
	+ 	obdst = bdst;
	+ 	sadelta = bsrc.alpha == &ones ? 0 : bsrc.delta;
	+ 	q = bsrc.delta == 4 && bdst.delta == 4;
	+ 
	+ 	for(i=0; i<dx; i++){
	+ 		ma = *bmask.alpha;
	+ 		da = *bdst.alpha;
	+ 		if(op == SoutD)
	+ 			da = 255-da;
	+ 		fs = ma;
	+ 		if(op != S)
	+ 			fs = MUL(fs, da, t);
	+ 
	+ 		if(grey){
	+ 			*bdst.grey = MUL(fs, *bsrc.grey, t);
	+ 			bsrc.grey += bsrc.delta;
	+ 			bdst.grey += bdst.delta;
	+ 		}else{
	+ 			if(q){
	+ 				*bdst.rgba = MUL0123(fs, *bsrc.rgba, s, t);
	+ 				bsrc.rgba++;
	+ 				bdst.rgba++;
	+ 				bmask.alpha += bmask.delta;
	+ 				bdst.alpha += bdst.delta;
	+ 				continue;
	+ 			}
	+ 			*bdst.red = MUL(fs, *bsrc.red, t);
	+ 			*bdst.grn = MUL(fs, *bsrc.grn, t);
	+ 			*bdst.blu = MUL(fs, *bsrc.blu, t);
	  			bsrc.red += bsrc.delta;
	  			bsrc.blu += bsrc.delta;
	  			bsrc.grn += bsrc.delta;
	+ 			bdst.red += bdst.delta;
	+ 			bdst.blu += bdst.delta;
	+ 			bdst.grn += bdst.delta;
	+ 		}
	+ 		if(bdst.alpha != &ones){
	+ 			*bdst.alpha = MUL(fs, *bsrc.alpha, t);
	+ 			bdst.alpha += bdst.delta;
	+ 		}
	+ 		bmask.alpha += bmask.delta;
	+ 		bsrc.alpha += sadelta;
	+ 	}
	+ 	return obdst;
	+ }
	  
	+ static Buffer
	+ alphacalc3679(Buffer bdst, Buffer bsrc, Buffer bmask, int dx, int grey, int op)
	+ {
	+ 	Buffer obdst;
	+ 	int fs, fd, sadelta;
	+ 	int i, sa, ma, da, q;
	+ 	ulong s, t, u, v;
	+ 
	+ 	obdst = bdst;
	+ 	sadelta = bsrc.alpha == &ones ? 0 : bsrc.delta;
	+ 	q = bsrc.delta == 4 && bdst.delta == 4;
	+ 
	+ 	for(i=0; i<dx; i++){
	+ 		sa = *bsrc.alpha;
	+ 		ma = *bmask.alpha;
	+ 		da = *bdst.alpha;
	+ 		if(op == SatopD)
	+ 			fs = MUL(ma, da, t);
	+ 		else
	+ 			fs = MUL(ma, 255-da, t);
	+ 		if(op == DoverS)
	+ 			fd = 255;
	+ 		else{
	+ 			fd = MUL(sa, ma, t);
	+ 			if(op != DatopS)
	+ 				fd = 255-fd;
	+ 		}
	+ 
	+ 		if(grey){
	+ 			*bdst.grey = MUL(fs, *bsrc.grey, s)+MUL(fd, *bdst.grey, t);
	+ 			bsrc.grey += bsrc.delta;
	+ 			bdst.grey += bdst.delta;
	+ 		}else{
	+ 			if(q){
	+ 				*bdst.rgba = MUL0123(fs, *bsrc.rgba, s, t)+MUL0123(fd, *bdst.rgba, u, v);
	+ 				bsrc.rgba++;
	+ 				bdst.rgba++;
	+ 				bsrc.alpha += sadelta;
	+ 				bmask.alpha += bmask.delta;
	+ 				bdst.alpha += bdst.delta;
	+ 				continue;
	+ 			}
	+ 			*bdst.red = MUL(fs, *bsrc.red, s)+MUL(fd, *bdst.red, t);
	+ 			*bdst.grn = MUL(fs, *bsrc.grn, s)+MUL(fd, *bdst.grn, t);
	+ 			*bdst.blu = MUL(fs, *bsrc.blu, s)+MUL(fd, *bdst.blu, t);
	+ 			bsrc.red += bsrc.delta;
	+ 			bsrc.blu += bsrc.delta;
	+ 			bsrc.grn += bsrc.delta;
	  			bdst.red += bdst.delta;
	  			bdst.blu += bdst.delta;
	  			bdst.grn += bdst.delta;
	  		}
	+ 		if(bdst.alpha != &ones){
	+ 			*bdst.alpha = MUL(fs, sa, s)+MUL(fd, da, t);
	+ 			bdst.alpha += bdst.delta;
	+ 		}
	+ 		bmask.alpha += bmask.delta;
	+ 		bsrc.alpha += sadelta;
	+ 	}
	+ 	return obdst;
	+ }
	  
	- 		salpha += sadelta;
	+ static Buffer
	+ alphacalc5(Buffer bdst, Buffer b1, Buffer b2, int dx, int grey, int op)
	+ {
	+ 	USED(dx);
	+ 	USED(grey);
	+ 	USED(op);
	+ 	return bdst;
	+ }
	+ 
	+ static Buffer
	+ alphacalc11(Buffer bdst, Buffer bsrc, Buffer bmask, int dx, int grey, int op)
	+ {
	+ 	Buffer obdst;
	+ 	int fd, sadelta;
	+ 	int i, sa, ma, q;
	+ 	ulong s, t, u, v;
	+ 
	+ 	USED(op);
	+ 	obdst = bdst;
	+ 	sadelta = bsrc.alpha == &ones ? 0 : bsrc.delta;
	+ 	q = bsrc.delta == 4 && bdst.delta == 4;
	+ 
	+ 	for(i=0; i<dx; i++){
	+ 		sa = *bsrc.alpha;
	+ 		ma = *bmask.alpha;
	+ 		fd = 255-MUL(sa, ma, t);
	+ 
	+ 		if(grey){
	+ 			*bdst.grey = MUL(ma, *bsrc.grey, s)+MUL(fd, *bdst.grey, t);
	+ 			bsrc.grey += bsrc.delta;
	+ 			bdst.grey += bdst.delta;
	+ 		}else{
	+ 			if(q){
	+ 				*bdst.rgba = MUL0123(ma, *bsrc.rgba, s, t)+MUL0123(fd, *bdst.rgba, u, v);
	+ 				bsrc.rgba++;
	+ 				bdst.rgba++;
	+ 				bsrc.alpha += sadelta;
	+ 				bmask.alpha += bmask.delta;
	+ 				continue;
	+ 			}
	+ 			*bdst.red = MUL(ma, *bsrc.red, s)+MUL(fd, *bdst.red, t);
	+ 			*bdst.grn = MUL(ma, *bsrc.grn, s)+MUL(fd, *bdst.grn, t);
	+ 			*bdst.blu = MUL(ma, *bsrc.blu, s)+MUL(fd, *bdst.blu, t);
	+ 			bsrc.red += bsrc.delta;
	+ 			bsrc.blu += bsrc.delta;
	+ 			bsrc.grn += bsrc.delta;
	+ 			bdst.red += bdst.delta;
	+ 			bdst.blu += bdst.delta;
	+ 			bdst.grn += bdst.delta;
	+ 		}
	+ 		if(bdst.alpha != &ones){
	+ 			*bdst.alpha = MUL(ma, sa, s)+MUL(fd, *bdst.alpha, t);
	+ 			bdst.alpha += bdst.delta;
	+ 		}
	  		bmask.alpha += bmask.delta;
	+ 		bsrc.alpha += sadelta;
	+ 	}
	+ 	return obdst;
	+ }
	  
	- 		if(bdst.alpha) {
	- 			*bdst.alpha = DIV255(sa*ma+*bdst.alpha*(antialpha));
	+ /*
	+ not used yet
	+ source and mask alpha 1
	+ static Buffer
	+ alphacalcS0(Buffer bdst, Buffer bsrc, Buffer bmask, int dx, int grey, int op)
	+ {
	+ 	Buffer obdst;
	+ 	int i;
	+ 
	+ 	USED(op);
	+ 	obdst = bdst;
	+ 	if(bsrc.delta == bdst.delta){
	+ 		memmove(bdst.rgba, bsrc.rgba, dx*bdst.delta);
	+ 		return obdst;
	+ 	}
	+ 	for(i=0; i<dx; i++){
	+ 		if(grey){
	+ 			*bdst.grey = *bsrc.grey;
	+ 			bsrc.grey += bsrc.delta;
	+ 			bdst.grey += bdst.delta;
	+ 		}else{
	+ 			*bdst.red = *bsrc.red;
	+ 			*bdst.grn = *bsrc.grn;
	+ 			*bdst.blu = *bsrc.blu;
	+ 			bsrc.red += bsrc.delta;
	+ 			bsrc.blu += bsrc.delta;
	+ 			bsrc.grn += bsrc.delta;
	+ 			bdst.red += bdst.delta;
	+ 			bdst.blu += bdst.delta;
	+ 			bdst.grn += bdst.delta;
	+ 		}
	+ 		if(bdst.alpha != &ones){
	+ 			*bdst.alpha = 255;
	  			bdst.alpha += bdst.delta;
	  		}
	  	}
	  	return obdst;
	  }
	- #undef DBG
	+ */
	  
	- #define DBG if(0)
	+ /* source alpha 1 */
	  static Buffer
	- boolcalc(Buffer bdst, Buffer bsrc, Buffer bmask, int dx, int grey)
	+ alphacalcS(Buffer bdst, Buffer bsrc, Buffer bmask, int dx, int grey, int op)
	  {
	  	Buffer obdst;
	+ 	int fd;
	  	int i, ma;
	+ 	ulong s, t;
	  
	+ 	USED(op);
	  	obdst = bdst;
	+ 
	  	for(i=0; i<dx; i++){
	  		ma = *bmask.alpha;
	+ 		fd = 255-ma;
	  
	  		if(grey){
	- DBG print("(%d) in %d over %d =", *bsrc.grey, ma, *bdst.grey);
	+ 			*bdst.grey = MUL(ma, *bsrc.grey, s)+MUL(fd, *bdst.grey, t);
	+ 			bsrc.grey += bsrc.delta;
	+ 			bdst.grey += bdst.delta;
	+ 		}else{
	+ 			*bdst.red = MUL(ma, *bsrc.red, s)+MUL(fd, *bdst.red, t);
	+ 			*bdst.grn = MUL(ma, *bsrc.grn, s)+MUL(fd, *bdst.grn, t);
	+ 			*bdst.blu = MUL(ma, *bsrc.blu, s)+MUL(fd, *bdst.blu, t);
	+ 			bsrc.red += bsrc.delta;
	+ 			bsrc.blu += bsrc.delta;
	+ 			bsrc.grn += bsrc.delta;
	+ 			bdst.red += bdst.delta;
	+ 			bdst.blu += bdst.delta;
	+ 			bdst.grn += bdst.delta;
	+ 		}
	+ 		if(bdst.alpha != &ones){
	+ 			*bdst.alpha = ma+MUL(fd, *bdst.alpha, t);
	+ 			bdst.alpha += bdst.delta;
	+ 		}
	+ 		bmask.alpha += bmask.delta;
	+ 	}
	+ 	return obdst;
	+ }
	+ 
	+ static Buffer
	+ boolcalc14(Buffer bdst, Buffer b1, Buffer bmask, int dx, int grey, int op)
	+ {
	+ 	Buffer obdst;
	+ 	int i, ma, zero;
	+ 
	+ 	obdst = bdst;
	+ 
	+ 	for(i=0; i<dx; i++){
	+ 		ma = *bmask.alpha;
	+ 		zero = ma ? op == DoutS : op == DinS;
	+ 
	+ 		if(grey){
	+ 			if(zero)
	+ 				*bdst.grey = 0;
	+ 			bdst.grey += bdst.delta;
	+ 		}else{
	+ 			if(zero)
	+ 				*bdst.red = *bdst.grn = *bdst.blu = 0;
	+ 			bdst.red += bdst.delta;
	+ 			bdst.blu += bdst.delta;
	+ 			bdst.grn += bdst.delta;
	+ 		}
	+ 		bmask.alpha += bmask.delta;
	+ 		if(bdst.alpha != &ones){
	+ 			if(zero)
	+ 				*bdst.alpha = 0;
	+ 			bdst.alpha += bdst.delta;
	+ 		}
	+ 	}
	+ 	return obdst;
	+ }
	+ 
	+ static Buffer
	+ boolcalc236789(Buffer bdst, Buffer bsrc, Buffer bmask, int dx, int grey, int op)
	+ {
	+ 	Buffer obdst;
	+ 	int fs, fd;
	+ 	int i, ma, da, zero;
	+ 	ulong s, t;
	+ 
	+ 	obdst = bdst;
	+ 	zero = !(op&1);
	+ 
	+ 	for(i=0; i<dx; i++){
	+ 		ma = *bmask.alpha;
	+ 		da = *bdst.alpha;
	+ 		fs = da;
	+ 		if(op&2)
	+ 			fs = 255-da;
	+ 		fd = 0;
	+ 		if(op&4)
	+ 			fd = 255;
	+ 
	+ 		if(grey){
	  			if(ma)
	- 				*bdst.grey = *bsrc.grey;
	- DBG print(" %d\n", *bdst.grey);
	+ 				*bdst.grey = MUL(fs, *bsrc.grey, s)+MUL(fd, *bdst.grey, t);
	+ 			else if(zero)
	+ 				*bdst.grey = 0;
	  			bsrc.grey += bsrc.delta;
	  			bdst.grey += bdst.delta;
	  		}else{
	  			if(ma){
	- 				*bdst.red = *bsrc.red*ma;
	- 				*bdst.grn = *bsrc.grn*ma;
	- 				*bdst.blu = *bsrc.blu*ma;
	+ 				*bdst.red = MUL(fs, *bsrc.red, s)+MUL(fd, *bdst.red, t);
	+ 				*bdst.grn = MUL(fs, *bsrc.grn, s)+MUL(fd, *bdst.grn, t);
	+ 				*bdst.blu = MUL(fs, *bsrc.blu, s)+MUL(fd, *bdst.blu, t);
	  			}
	- 
	+ 			else if(zero)
	+ 				*bdst.red = *bdst.grn = *bdst.blu = 0;
	  			bsrc.red += bsrc.delta;
	  			bsrc.blu += bsrc.delta;
	  			bsrc.grn += bsrc.delta;
	- 
	  			bdst.red += bdst.delta;
	  			bdst.blu += bdst.delta;
	  			bdst.grn += bdst.delta;
	  		}
	- 
	  		bmask.alpha += bmask.delta;
	- 
	- 		if(bdst.alpha) {
	+ 		if(bdst.alpha != &ones){
	  			if(ma)
	- 				*bdst.alpha = ma;
	+ 				*bdst.alpha = fs+MUL(fd, da, t);
	+ 			else if(zero)
	+ 				*bdst.alpha = 0;
	  			bdst.alpha += bdst.delta;
	  		}
	  	}
	  	return obdst;
	  }
	- #undef DBG
	  
	+ static Buffer
	+ boolcalc1011(Buffer bdst, Buffer bsrc, Buffer bmask, int dx, int grey, int op)
	+ {
	+ 	Buffer obdst;
	+ 	int i, ma, zero;
	+ 
	+ 	obdst = bdst;
	+ 	zero = !(op&1);
	+ 
	+ 	for(i=0; i<dx; i++){
	+ 		ma = *bmask.alpha;
	+ 
	+ 		if(grey){
	+ 			if(ma)
	+ 				*bdst.grey = *bsrc.grey;
	+ 			else if(zero)
	+ 				*bdst.grey = 0;
	+ 			bsrc.grey += bsrc.delta;
	+ 			bdst.grey += bdst.delta;
	+ 		}else{
	+ 			if(ma){
	+ 				*bdst.red = *bsrc.red;
	+ 				*bdst.grn = *bsrc.grn;
	+ 				*bdst.blu = *bsrc.blu;
	+ 			}
	+ 			else if(zero)
	+ 				*bdst.red = *bdst.grn = *bdst.blu = 0;
	+ 			bsrc.red += bsrc.delta;
	+ 			bsrc.blu += bsrc.delta;
	+ 			bsrc.grn += bsrc.delta;
	+ 			bdst.red += bdst.delta;
	+ 			bdst.blu += bdst.delta;
	+ 			bdst.grn += bdst.delta;
	+ 		}
	+ 		bmask.alpha += bmask.delta;
	+ 		if(bdst.alpha != &ones){
	+ 			if(ma)
	+ 				*bdst.alpha = 255;
	+ 			else if(zero)
	+ 				*bdst.alpha = 0;
	+ 			bdst.alpha += bdst.delta;
	+ 		}
	+ 	}
	+ 	return obdst;
	+ }
	  /*
	   * Replicated cached scan line read.  Call the function listed in the Param,
	   * but cache the result so that for replicated images we only do the work once.
	   */
	  static Buffer
	- replread(Param *p, uchar *notusedbuf, int y)
	+ replread(Param *p, uchar *s, int y)
	  {
	  	Buffer *b;
	  
	+ 	USED(s);
	  	b = &p->bcache[y];
	  	if((p->bfilled & (1<<y)) == 0){
	  		p->bfilled |= 1<<y;
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:886,894 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1252,1261
	  	uchar *repl, *r, *w, *ow, bits;
	  	int i, n, sh, depth, x, dx, npack, nbits;
	  
	+ 	b.rgba = (ulong*)buf;
	  	b.grey = w = buf;
	  	b.red = b.blu = b.grn = w;
	- 	b.alpha = nil;
	+ 	b.alpha = &ones;
	  	b.delta = 1;
	  
	  	dx = p->dx;
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:908,914 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1275,1281
	  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;
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:940,946 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1307,1313
	  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;
	  	}
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1017,1023 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1384,1390
	  readcmap(Param *p, uchar *buf, int y)
	  {
	  	Buffer b;
	- 	int i, dx, convgrey;
	+ 	int a, convgrey, copyalpha, dx, i, m;
	  	uchar *q, *cmap, *begin, *end, *r, *w;
	  
	  	begin = p->bytey0s + y*p->bwidth;
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1025,1058 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1392,1447
	  	end = p->bytey0e + y*p->bwidth;
	  	cmap = p->img->cmap->cmap2rgb;
	  	convgrey = p->convgrey;
	+ 	copyalpha = (p->img->flags&Falpha) ? 1 : 0;
	  
	  	w = buf;
	  	dx = p->dx;
	- 	for(i=0; i<dx; i++){
	- 		q = cmap+*r++*3;
	- 		if(r == end)
	- 			r = begin;
	- 		if(convgrey){
	- 			*w++ = RGB2K(q[0], q[1], q[2]);
	- 		}else{
	- 			*w++ = q[2];	/* blue */
	- 			*w++ = q[1];	/* green */
	- 			*w++ = q[0];	/* red */
	+ 	if(copyalpha){
	+ 		b.alpha = buf++;
	+ 		a = p->img->shift[CAlpha]/8;
	+ 		m = p->img->shift[CMap]/8;
	+ 		for(i=0; i<dx; i++){
	+ 			*w++ = r[a];
	+ 			q = cmap+r[m]*3;
	+ 			r += 2;
	+ 			if(r == end)
	+ 				r = begin;
	+ 			if(convgrey){
	+ 				*w++ = RGB2K(q[0], q[1], q[2]);
	+ 			}else{
	+ 				*w++ = q[2];	/* blue */
	+ 				*w++ = q[1];	/* green */
	+ 				*w++ = q[0];	/* red */
	+ 			}
	+ 		}
	+ 	}else{
	+ 		b.alpha = &ones;
	+ 		for(i=0; i<dx; i++){
	+ 			q = cmap+*r++*3;
	+ 			if(r == end)
	+ 				r = begin;
	+ 			if(convgrey){
	+ 				*w++ = RGB2K(q[0], q[1], q[2]);
	+ 			}else{
	+ 				*w++ = q[2];	/* blue */
	+ 				*w++ = q[1];	/* green */
	+ 				*w++ = q[0];	/* red */
	+ 			}
	  		}
	  	}
	  
	+ 	b.rgba = (ulong*)(buf-copyalpha);
	+ 
	  	if(convgrey){
	- 		b.alpha = nil;
	  		b.grey = buf;
	  		b.red = b.blu = b.grn = buf;
	- 		b.delta = 1;
	+ 		b.delta = 1+copyalpha;
	  	}else{
	  		b.blu = buf;
	  		b.grn = buf+1;
	  		b.red = buf+2;
	- 		b.alpha = nil;
	  		b.grey = nil;
	- 		b.delta = 3;
	+ 		b.delta = 3+copyalpha;
	  	}
	  	return b;
	  }
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1075,1080 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1464,1470
	  		*w++ = cmap[(*red>>4)*256+(*grn>>4)*16+(*blu>>4)];
	  }
	  
	+ #define DBG if(0)
	  static Buffer
	  readbyte(Param *p, uchar *buf, int y)
	  {
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1099,1104 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1489,1495
	  	alphaonly = p->alphaonly;
	  	copyalpha = (img->flags&Falpha) ? 1 : 0;
	  
	+ DBG print("copyalpha %d alphaonly %d convgrey %d isgrey %d\n", copyalpha, alphaonly, convgrey, isgrey);
	  	/* if we can, avoid processing everything */
	  	if(!(img->flags&Frepl) && !convgrey && (img->flags&Fbytes)){
	  		memset(&b, 0, sizeof b);
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1106,1113 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1497,1507
	  			memmove(buf, r, dx*nb);
	  			r = buf;
	  		}
	+ 		b.rgba = (ulong*)r;
	  		if(copyalpha)
	  			b.alpha = r+img->shift[CAlpha]/8;
	+ 		else
	+ 			b.alpha = &ones;
	  		if(isgrey){
	  			b.grey = r+img->shift[CGrey]/8;
	  			b.red = b.grn = b.blu = b.grey;
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1120,1125 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1514,1520
	  		return b;
	  	}
	  
	+ DBG print("2\n");
	  	rrepl = replbit[img->nbits[CRed]];
	  	grepl = replbit[img->nbits[CGreen]];
	  	brepl = replbit[img->nbits[CBlue]];
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1128,1135 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1523,1532
	  
	  	for(i=0; i<dx; i++){
	  		u = r[0] | (r[1]<<8) | (r[2]<<16) | (r[3]<<24);
	- 		if(copyalpha)
	+ 		if(copyalpha) {
	  			*w++ = arepl[(u>>img->shift[CAlpha]) & img->mask[CAlpha]];
	+ DBG print("a %x\n", w[-1]);
	+ 		}
	  
	  		if(isgrey)
	  			*w++ = krepl[(u >> img->shift[CGrey]) & img->mask[CGrey]];
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1138,1144 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1535,1543
	  			ugrn = grepl[(u >> img->shift[CGreen]) & img->mask[CGreen]];
	  			ublu = brepl[(u >> img->shift[CBlue]) & img->mask[CBlue]];
	  			if(convgrey){
	+ DBG print("g %x %x %x\n", ured, ugrn, ublu);
	  				*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]];
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1150,1163 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1549,1566
	  			r = begin;
	  	}
	  	
	- 	b.alpha = copyalpha ? buf : nil;
	+ 	b.alpha = copyalpha ? buf : &ones;
	+ 	b.rgba = (ulong*)buf;
	  	if(alphaonly){
	  		b.red = b.grn = b.blu = b.grey = nil;
	+ 		if(!copyalpha)
	+ 			b.rgba = nil;
	  		b.delta = 1;
	  	}else if(isgrey || convgrey){
	  		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);
	  	}else{
	  		b.blu = buf+copyalpha;
	  		b.grn = buf+copyalpha+1;
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1167,1172 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1570,1576
	  	}
	  	return b;
	  }
	+ #undef DBG
	  
	  #define DBG if(0)
	  static void
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1194,1200 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1598,1604
	  	isgrey = img->flags&Fgrey;
	  	adelta = src.delta;
	  
	- 	if(isalpha && alpha == nil){
	+ 	if(isalpha && (alpha == nil || alpha == &ones)){
	  		ff = 0xFF;
	  		alpha = &ff;
	  		adelta = 0;
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1239,1252 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1643,1657
	  {
	  	if(img->depth < 8)
	  		return readnbit;
	- 	if(img->chan == CMAP8)
	+ 	if(img->nbits[CMap] == 8)
	  		return readcmap;
	  	return readbyte;
	  }
	  
	  static Readfn*
	- readalphafn(Memimage *notused)
	+ readalphafn(Memimage *m)
	  {
	+ 	USED(m);
	  	return readbyte;
	  }
	  
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1261,1295 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1666,1708
	  }
	  
	  static void
	- nullwrite(Param *notusedpar, uchar *notusedbuf, Buffer notusedb)
	+ nullwrite(Param *p, uchar *s, Buffer b)
	  {
	+ 	USED(p);
	+ 	USED(s);
	  }
	  
	  static Buffer
	- readptr(Param *p, uchar *notusedbuf, int y)
	+ readptr(Param *p, uchar *s, int y)
	  {
	  	Buffer b;
	  	uchar *q;
	  
	+ 	USED(s);
	  	q = p->bytermin + y*p->bwidth;
	  	b.red = q;	/* ptr to data */
	  	b.grn = b.blu = b.grey = b.alpha = nil;
	+ 	b.rgba = (ulong*)q;
	  	b.delta = p->img->depth/8;
	  	return b;
	  }
	  
	  static Buffer
	- boolmemmove(Buffer bdst, Buffer bsrc, Buffer notusedb, int dx, int notusedi)
	+ boolmemmove(Buffer bdst, Buffer bsrc, Buffer b1, int dx, int i, int o)
	  {
	+ 	USED(i);
	+ 	USED(o);
	  	memmove(bdst.red, bsrc.red, dx*bdst.delta);
	  	return bdst;
	  }
	  
	  static Buffer
	- boolcopy8(Buffer bdst, Buffer bsrc, Buffer bmask, int dx, int notusedi)
	+ boolcopy8(Buffer bdst, Buffer bsrc, Buffer bmask, int dx, int i, int o)
	  {
	  	uchar *m, *r, *w, *ew;
	  
	+ 	USED(i);
	+ 	USED(o);
	  	m = bmask.grey;
	  	w = bdst.red;
	  	r = bsrc.red;
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1301,1311 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1714,1726
	  }
	  
	  static Buffer
	- boolcopy16(Buffer bdst, Buffer bsrc, Buffer bmask, int dx, int notusedi)
	+ boolcopy16(Buffer bdst, Buffer bsrc, Buffer bmask, int dx, int i, int o)
	  {
	  	uchar *m;
	  	ushort *r, *w, *ew;
	  
	+ 	USED(i);
	+ 	USED(o);
	  	m = bmask.grey;
	  	w = (ushort*)bdst.red;
	  	r = (ushort*)bsrc.red;
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1317,1327 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1732,1744
	  }
	  
	  static Buffer
	- boolcopy24(Buffer bdst, Buffer bsrc, Buffer bmask, int dx, int notusedi)
	+ boolcopy24(Buffer bdst, Buffer bsrc, Buffer bmask, int dx, int i, int o)
	  {
	  	uchar *m;
	  	uchar *r, *w, *ew;
	  
	+ 	USED(i);
	+ 	USED(o);
	  	m = bmask.grey;
	  	w = bdst.red;
	  	r = bsrc.red;
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1340,1350 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1757,1769
	  }
	  
	  static Buffer
	- boolcopy32(Buffer bdst, Buffer bsrc, Buffer bmask, int dx, int notusedi)
	+ boolcopy32(Buffer bdst, Buffer bsrc, Buffer bmask, int dx, int i, int o)
	  {
	  	uchar *m;
	  	ulong *r, *w, *ew;
	  
	+ 	USED(i);
	+ 	USED(o);
	  	m = bmask.grey;
	  	w = (ulong*)bdst.red;
	  	r = (ulong*)bsrc.red;
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1379,1384 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1798,1804
	  
	  	b.red = buf;
	  	b.blu = b.grn = b.grey = b.alpha = nil;
	+ 	b.rgba = (ulong*)buf;
	  	b.delta = 0;
	  	
	  	return b;
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1388,1398 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1808,1820
	  convfn(Memimage *dst, Param *dpar, Memimage *src, Param *spar)
	  {
	  	if(dst->chan == src->chan && !(src->flags&Frepl)){
	+ //if(drawdebug) iprint("readptr...");
	  		return readptr;
	  	}
	  
	  	if(dst->chan==CMAP8 && (src->chan==GREY1||src->chan==GREY2||src->chan==GREY4)){
	  		/* cheat because we know the replicated value is exactly the color map entry. */
	+ //if(drawdebug) iprint("Readnbit...");
	  		return readnbit;
	  	}
	  
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1409,1414 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1831,1837
	  		spar->dx = Dx(spar->img->r);
	  	}
	  
	+ //if(drawdebug) iprint("genconv...");
	  	return genconv;
	  }
	  
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1453,1459 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1876,1882
	  static Calcfn*
	  boolcopyfn(Memimage *img, Memimage *mask)
	  {
	- 	if(mask->flags&Frepl && Dx(mask->r)==1 && Dy(mask->r)==1 && _pixelbits(mask, mask->r.min)==~0)
	+ 	if(mask->flags&Frepl && Dx(mask->r)==1 && Dy(mask->r)==1 && pixelbits(mask, mask->r.min)==~0)
	  		return boolmemmove;
	  
	  	switch(img->depth){
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1473,1479 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1896,1902
	  
	  /*
	   * Optimized draw for filling and scrolling; uses memset and memmove.
	-  */
	+  *
	  static void
	  memsetb(void *vp, uchar val, int n)
	  {
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1484,1489 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1907,1913
	  	while(p<ep)
	  		*p++ = val;
	  }
	+ */
	  
	  static void
	  memsets(void *vp, ushort val, int n)
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1507,1513 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1931,1937
	  		*p++ = val;
	  }
	  
	- void
	+ static void
	  memset24(void *vp, ulong val, int n)
	  {
	  	uchar *p, *ep;
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1614,1628 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:2038,2053
	  		}
	  		d += nb;
	  	}
	+ //	print("rgba2img %.8lux = %.*lux\n", rgba, 2*d/8, v);
	  	return v;
	  }
	  
	+ #define DBG if(0)
	  static int
	  memoptdraw(Memdrawparam *par)
	  {
	- 	int y, dy, dx;
	+ 	int m, y, dy, dx, op;
	  	ulong v;
	- 	unsigned m;
	  	Memimage *src;
	  	Memimage *dst;
	  
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1630,1649 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:2055,2078
	  	dy = Dy(par->r);
	  	src = par->src;
	  	dst = par->dst;
	+ 	op = par->op;
	  
	+ DBG print("state %lux mval %lux dd %d\n", par->state, par->mval, dst->depth);
	  	/*
	  	 * If we have an opaque mask and source is one opaque pixel we can convert to the
	  	 * destination format and just replicate with memset.
	  	 */
	  	m = Simplesrc|Simplemask|Fullmask;
	- 	if((par->state&m)==m && ((par->srgba&0xFF) == 0xFF)){
	+ 	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;
	  
	+ DBG print("memopt, dst %p, dst->data->bdata %p\n", dst, dst->data->bdata);
	  		dwid = dst->width*sizeof(ulong);
	  		dp = byteaddr(dst, par->r.min);
	  		v = par->sdval;
	+ DBG print("sdval %lud, depth %d\n", v, dst->depth);
	  		switch(dst->depth){
	  		case 1:
	  		case 2:
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1657,1662 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:2086,2092
	  			dx -= (ppb-np);
	  			nb = 8 - np * dst->depth;		/* no. bits used on right side of word */
	  			lm = (1<<nb)-1;
	+ DBG print("np %d x %d nb %d lm %ux ppb %d m %ux\n", np, par->r.min.x, nb, lm, ppb, m);	
	  
	  			/* right edge */
	  			np = par->r.max.x&m;	/* no. pixels used on left side of word */
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1663,1669 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:2093,2101
	  			dx -= np;
	  			nb = 8 - np * dst->depth;		/* no. bits unused on right side of word */
	  			rm = ~((1<<nb)-1);
	+ DBG print("np %d x %d nb %d rm %ux ppb %d m %ux\n", np, par->r.max.x, nb, rm, ppb, m);	
	  
	+ DBG print("dx %d Dx %d\n", dx, Dx(par->r));
	  			/* lm, rm are masks that are 1 where we should touch the bits */
	  			if(dx < 0){	/* just one byte */
	  				lm &= rm;
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1675,1680 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:2107,2113
	  
	  				for(y=0; y<dy; y++, dp+=dwid){
	  					if(lm){
	+ DBG print("dp %p v %lux lm %ux (v ^ *dp) & lm %lux\n", dp, v, lm, (v^*dp)&lm);
	  						*dp ^= (v ^ *dp) & lm;
	  						dp++;
	  					}
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1705,1710 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:2138,2145
	  			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;
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1733,1739 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:2168,2174
	  	 */
	  	m = Simplemask|Fullmask;
	  	if((par->state&(m|Replsrc))==m && src->depth >= 8 
	- 	&& src->chan == dst->chan && !(src->flags&Falpha)){
	+ 	&& src->chan == dst->chan && !(src->flags&Falpha) && (op == S || op == SoverD)){
	  		uchar *sp, *dp;
	  		long swid, dwid, nb;
	  		int dir;
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1856,1861 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:2291,2297
	  	}
	  	return 0;	
	  }
	+ #undef DBG
	  
	  /*
	   * Boolean character drawing.
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1866,1872 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:2302,2308
	  chardraw(Memdrawparam *par)
	  {
	  	ulong bits;
	- 	int i, ddepth, dy, dx, x, bx, ex, y, npack, bsh, depth;
	+ 	int i, ddepth, dy, dx, x, bx, ex, y, npack, bsh, depth, op;
	  	ulong v, maskwid, dstwid;
	  	uchar *wp, *rp, *q, *wc;
	  	ushort *ws;
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1884,1894 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:2320,2334
	  	dst = par->dst;
	  	r = par->r;
	  	mr = par->mr;
	+ 	op = par->op;
	  
	  	if((par->state&(Replsrc|Simplesrc|Replmask)) != (Replsrc|Simplesrc)
	- 	|| mask->depth != 1 || src->flags&Falpha || dst->depth<8 || dst->data==src->data)
	+ 	|| mask->depth != 1 || src->flags&Falpha || dst->depth<8 || dst->data==src->data
	+ 	|| op != SoverD)
	  		return 0;
	  
	+ //if(drawdebug) iprint("chardraw...");
	+ 
	  	depth = mask->depth;
	  	maskwid = mask->width*sizeof(ulong);
	  	rp = byteaddr(mask, mr.min);
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1914,1920 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:2354,2360
	  
	  	bx = -bsh-1;
	  	ex = -bsh-1-dx;
	- 	SET(bits);
	+ 	bits = 0;
	  	v = par->sdval;
	  
	  	/* make little endian */
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1923,1928 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:2363,2369
	  	sp[2] = v>>16;
	  	sp[3] = v>>24;
	  
	+ //print("sp %x %x %x %x\n", sp[0], sp[1], sp[2], sp[3]);
	  	for(y=0; y<dy; y++, rp+=maskwid, wp+=dstwid){
	  		q = rp;
	  		if(bsh)
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1929,1934 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:2370,2376
	  			bits = *q++;
	  		switch(ddepth){
	  		case 8:
	+ //if(drawdebug) iprint("8loop...");
	  			wc = wp;
	  			for(x=bx; x>ex; x--, wc++){
	  				i = x&7;
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:1985,1995 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:2427,2464
	  }
	  #undef DBG
	  
	+ 
	+ /*
	+  * Fill entire byte with replicated (if necessary) copy of source pixel,
	+  * assuming destination ldepth is >= source ldepth.
	+  *
	+  * This code is just plain wrong for >8bpp.
	+  *
	+ ulong
	+ membyteval(Memimage *src)
	+ {
	+ 	int i, val, bpp;
	+ 	uchar uc;
	+ 
	+ 	unloadmemimage(src, src->r, &uc, 1);
	+ 	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 
	+ 	val = uc;
	+ 	for(i=bpp; i<8; i<<=1)
	+ 		val |= val>>i;
	+ 	return val;
	+ }
	+  * 
	+  */
	+ 
	  void
	  _memfillcolor(Memimage *i, ulong val)
	  {
	  	ulong bits;
	  	int d, y;
	+ 	uchar p[4];
	  
	  	if(val == DNofill)
	  		return;
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:2003,2009 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/draw.c:2472,2484
	  	default:	/* 1, 2, 4, 8, 16, 32 */
	  		for(d=i->depth; d<32; d*=2)
	  			bits = (bits << d) | bits;
	+ 		p[0] = bits;		/* make little endian */
	+ 		p[1] = bits>>8;
	+ 		p[2] = bits>>16;
	+ 		p[3] = bits>>24;
	+ 		bits = *(ulong*)p;
	  		memsetl(wordaddr(i, i->r.min), bits, i->width*Dy(i->r));
	  		break;
	  	}
	  }
	+ 
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 54684 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmemdraw/draw.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 23441 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmemdraw/drawtest.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 4864 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmemdraw/ellipse.c
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/ellipse.c:1,9 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/ellipse.c:1,9
	- #include "../lib9.h"
	+ #include <u.h>
	+ #include <libc.h>
	+ #include <draw.h>
	+ #include <memdraw.h>
	+ #include <memlayer.h>
	  
	- #include "../libdraw/draw.h"
	- #include "../libmemdraw/memdraw.h"
	- #include "../libmemlayer/memlayer.h"
	- 
	  /*
	   * ellipse(dst, c, a, b, t, src, sp)
	   *   draws an ellipse centered at c with semiaxes a,b>=0
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/ellipse.c:30,35 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/ellipse.c:30,36
	  	int			t;
	  	Point			sp;
	  	Memimage	*disc;
	+ 	int			op;
	  };
	  
	  /*
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/ellipse.c:104,110 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/ellipse.c:105,111
	  }
	  
	  void
	- memellipse(Memimage *dst, Point c, int a, int b, int t, Memimage *src, Point sp)
	+ memellipse(Memimage *dst, Point c, int a, int b, int t, Memimage *src, Point sp, int op)
	  {
	  	State in, out;
	  	int y, inb, inx, outx, u;
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/ellipse.c:120,125 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/ellipse.c:121,127
	  	p.t = t;
	  	p.sp = subpt(sp, c);
	  	p.disc = nil;
	+ 	p.op = op;
	  
	  	u = (t<<1)*(a-b);
	  	if((b<a && u>b*b) || (a<b && -u>a*a)) {
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/ellipse.c:178,184 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/ellipse.c:180,186
	  	if(p->disc == nil)
	  		return;
	  	memfillcolor(p->disc, DTransparent);
	- 	memellipse(p->disc, p00, t, t, -1, memopaque, p00);
	+ 	memellipse(p->disc, p00, t, t, -1, memopaque, p00, p->op);
	  	oy = y;
	  	ox = 0;
	  	nx = x = step(s);
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/ellipse.c:209,215 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/ellipse.c:211,217
	  
	  /*	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);
	+ 	memdraw(p->dst, r, p->src, addpt(p->sp, r.min), memopaque, p00, p->op);
	  }
	  
	  /*
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/ellipse.c:225,231 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/ellipse.c:227,233
	  /*	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);
	+ 	memdraw(p->dst, r, p->src, addpt(p->sp, r.min), p->disc, p->disc->r.min, p->op);
	  }
	  
	  /* 
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 9973 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmemdraw/fillpoly.c
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/fillpoly.c:1,9 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/fillpoly.c:1,9
	- #include "../lib9.h"
	+ #include <u.h>
	+ #include <libc.h>
	+ #include <draw.h>
	+ #include <memdraw.h>
	+ #include <memlayer.h>
	  
	- #include "../libdraw/draw.h"
	- #include "../libmemdraw/memdraw.h"
	- #include "../libmemlayer/memlayer.h"
	- 
	  typedef struct Seg	Seg;
	  
	  struct Seg
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/fillpoly.c:20,32 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/fillpoly.c:20,32
	  };
	  
	  static	void	zsort(Seg **seg, Seg **ep);
	- static	int	ycompare(void*, void*);
	- static	int	xcompare(void*, void*);
	- static	int	zcompare(void*, void*);
	- static	void	xscan(Memimage *dst, Seg **seg, Seg *segtab, int nseg, int wind, Memimage *src, Point sp, int, int, int);
	- static	void	yscan(Memimage *dst, Seg **seg, Seg *segtab, int nseg, int wind, Memimage *src, Point sp, int);
	+ static	int	ycompare(const void*, const void*);
	+ static	int	xcompare(const void*, const void*);
	+ static	int	zcompare(const void*, const void*);
	+ 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)
	  {
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/fillpoly.c:38,47 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/fillpoly.c:38,47
	  	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)
	+ fillline(Memimage *dst, int left, int right, int y, Memimage *src, Point p, int op)
	  {
	  	Rectangle r;
	  
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/fillpoly.c:51,61 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/fillpoly.c:51,61
	  	r.max.y = y+1;
	  	p.x += left;
	  	p.y += y;
	- 	memdraw(dst, r, src, p, memopaque, p);
	+ 	memdraw(dst, r, src, p, memopaque, p, op);
	  }
	  
	  static void
	- fillpoint(Memimage *dst, int x, int y, Memimage *src, Point p)
	+ fillpoint(Memimage *dst, int x, int y, Memimage *src, Point p, int op)
	  {
	  	Rectangle r;
	  
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/fillpoly.c:65,81 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/fillpoly.c:65,81
	  	r.max.y = y+1;
	  	p.x += x;
	  	p.y += y;
	- 	memdraw(dst, r, src, p, memopaque, p);
	+ 	memdraw(dst, r, src, p, memopaque, p, op);
	  }
	  
	  void
	- memfillpoly(Memimage *dst, Point *vert, int nvert, int w, Memimage *src, Point sp)
	+ memfillpoly(Memimage *dst, Point *vert, int nvert, int w, Memimage *src, Point sp, int op)
	  {
	- 	memfillpolysc(dst, vert, nvert, w, src, sp, 0, 0, 0);
	+ 	_memfillpolysc(dst, vert, nvert, w, src, sp, 0, 0, 0, op);
	  }
	  
	  void
	- memfillpolysc(Memimage *dst, Point *vert, int nvert, int w, Memimage *src, Point sp, int detail, int fixshift, int clipped)
	+ _memfillpolysc(Memimage *dst, Point *vert, int nvert, int w, Memimage *src, Point sp, int detail, int fixshift, int clipped, int op)
	  {
	  	Seg **seg, *segtab;
	  	Point p0;
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/fillpoly.c:113,121 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/fillpoly.c:113,121
	  	if(!fixshift)
	  		fixshift = 1;
	  
	- 	xscan(dst, seg, segtab, nvert, w, src, sp, detail, fixshift, clipped);
	+ 	xscan(dst, seg, segtab, nvert, w, src, sp, detail, fixshift, clipped, op);
	  	if(detail)
	- 		yscan(dst, seg, segtab, nvert, w, src, sp, fixshift);
	+ 		yscan(dst, seg, segtab, nvert, w, src, sp, fixshift, op);
	  
	  	free(seg);
	  	free(segtab);
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/fillpoly.c:161,173 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/fillpoly.c:161,173
	  }
	  
	  static void
	- xscan(Memimage *dst, Seg **seg, Seg *segtab, int nseg, int wind, Memimage *src, Point sp, int detail, int fixshift, int clipped)
	+ xscan(Memimage *dst, Seg **seg, Seg *segtab, int nseg, int wind, Memimage *src, Point sp, int detail, int fixshift, int clipped, int op)
	  {
	  	long y, maxy, x, x2, xerr, xden, onehalf;
	  	Seg **ep, **next, **p, **q, *s;
	  	long n, i, iy, cnt, ix, ix2, minx, maxx;
	  	Point pt;
	- 	void	(*fill)(Memimage*, int, int, int, Memimage*, Point);
	+ 	void	(*fill)(Memimage*, int, int, int, Memimage*, Point, int);
	  
	  	fill = fillline;
	  /*
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/fillpoly.c:209,216 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/fillpoly.c:209,215
	  	if(n == 0)
	  		return;
	  	*p = 0;
	- 	qsort(seg, p-seg , sizeof(Seg*), 
	- 		(int(*)(const void*, const void*))ycompare);
	+ 	qsort(seg, p-seg , sizeof(Seg*), ycompare);
	  
	  	onehalf = 0;
	  	if(fixshift)
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/fillpoly.c:303,309 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/fillpoly.c:302,308
	  				ix = (x + x2) >> (fixshift+1);
	  				ix2 = ix+1;
	  			}
	- 			(*fill)(dst, ix, ix2, iy, src, sp);
	+ 			(*fill)(dst, ix, ix2, iy, src, sp, op);
	  		}
	  		y += (1<<fixshift);
	  		iy++;
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/fillpoly.c:311,317 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/fillpoly.c:310,316
	  }
	  
	  static void
	- yscan(Memimage *dst, Seg **seg, Seg *segtab, int nseg, int wind, Memimage *src, Point sp, int fixshift)
	+ yscan(Memimage *dst, Seg **seg, Seg *segtab, int nseg, int wind, Memimage *src, Point sp, int fixshift, int op)
	  {
	  	long x, maxx, y, y2, yerr, yden, onehalf;
	  	Seg **ep, **next, **p, **q, *s;
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/fillpoly.c:340,347 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/fillpoly.c:339,345
	  	if(n == 0)
	  		return;
	  	*p = 0;
	- 	qsort(seg, n , sizeof(Seg*), 
	- 		(int(*)(const void*, const void*))xcompare);
	+ 	qsort(seg, n , sizeof(Seg*), xcompare);
	  
	  	onehalf = 0;
	  	if(fixshift)
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/fillpoly.c:432,438 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/fillpoly.c:430,436
	  				if(yerr*p[0]->den + p[0]->zerr*yden > p[0]->den*yden)
	  					y++;
	  				iy = (y + y2) >> (fixshift+1);
	- 				fillpoint(dst, ix, iy, src, sp);
	+ 				fillpoint(dst, ix, iy, src, sp, op);
	  			}
	  		}
	  		x += (1<<fixshift);
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/fillpoly.c:465,472 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/fillpoly.c:463,469
	  		q = ep-1;
	  		for(p = seg; p < q; p++) {
	  			if(p[0]->z > p[1]->z) {
	- 				qsort(seg, ep-seg, sizeof(Seg*), 
	- 					(int(*)(const void*, const void*))zcompare);
	+ 				qsort(seg, ep-seg, sizeof(Seg*), zcompare);
	  				break;
	  			}
	  		}
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/fillpoly.c:474,486 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/fillpoly.c:471,483
	  }
	  
	  static int
	- ycompare(void *a, void *b)
	+ ycompare(const void *a, const void *b)
	  {
	  	Seg **s0, **s1;
	  	long y0, y1;
	  
	- 	s0 = a;
	- 	s1 = b;
	+ 	s0 = (Seg**)a;
	+ 	s1 = (Seg**)b;
	  	y0 = (*s0)->p0.y;
	  	y1 = (*s1)->p0.y;
	  
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/fillpoly.c:492,504 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/fillpoly.c:489,501
	  }
	  
	  static int
	- xcompare(void *a, void *b)
	+ xcompare(const void *a, const void *b)
	  {
	  	Seg **s0, **s1;
	  	long x0, x1;
	  
	- 	s0 = a;
	- 	s1 = b;
	+ 	s0 = (Seg**)a;
	+ 	s1 = (Seg**)b;
	  	x0 = (*s0)->p0.x;
	  	x1 = (*s1)->p0.x;
	  
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/fillpoly.c:510,522 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/fillpoly.c:507,519
	  }
	  
	  static int
	- zcompare(void *a, void *b)
	+ zcompare(const void *a, const void *b)
	  {
	  	Seg **s0, **s1;
	  	long z0, z1;
	  
	- 	s0 = a;
	- 	s1 = b;
	+ 	s0 = (Seg**)a;
	+ 	s1 = (Seg**)b;
	  	z0 = (*s0)->z;
	  	z1 = (*s1)->z;
	  
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 159 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmemdraw/hwdraw.c
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/hwdraw.c:1,11 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/hwdraw.c:1,12
	- #include "../lib9.h"
	+ #include <u.h>
	+ #include <libc.h>
	+ #include <draw.h>
	+ #include <memdraw.h>
	  
	- #include "../libdraw/draw.h"
	- #include "../libmemdraw/memdraw.h"
	- 
	  int
	- hwdraw(Memdrawparam *notused)
	+ hwdraw(Memdrawparam *p)
	  {
	+ 	USED(p);
	  	return 0;	/* could not satisfy request */
	  }
	  
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 128 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmemdraw/iprint.c
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/iprint.c:1,20 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/iprint.c:1,12
	- #include "../lib9.h"
	+ #include <u.h>
	+ #include <libc.h>
	+ #include <draw.h>
	+ #include <memdraw.h>
	  
	- #include "../libdraw/draw.h"
	- #include "../libmemdraw/memdraw.h"
	- 
	- #undef write
	- int drawdebug;
	  int
	  iprint(char *fmt,...)
	  {
	- 	char buf[128];
	- 	int n;
	- 	va_list va;
	- 
	- 	va_start(va, fmt);
	- 	n = doprint(buf, buf+sizeof buf, fmt, va) - buf;
	- 	va_end(va);
	- 	write(1, buf, n);
	- 	return n;
	+ 	USED(fmt);
	+ 	return -1;
	  }
	+ 
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 11059 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmemdraw/line.c
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/line.c:1,18 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/line.c:1,17
	- #include "../lib9.h"
	+ #include <u.h>
	+ #include <libc.h>
	+ #include <draw.h>
	+ #include <memdraw.h>
	+ #include <memlayer.h>
	  
	- #include "../libdraw/draw.h"
	- #include "../libmemdraw/memdraw.h"
	- #include "../libmemlayer/memlayer.h"
	- 
	  enum
	  {
	  	Arrow1 = 8,
	  	Arrow2 = 10,
	- 	Arrow3 = 3
	+ 	Arrow3 = 3,
	  };
	  
	- /*
	-  * not used
	+ #ifdef NOT
	  static
	  int
	  lmin(int a, int b)
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/line.c:21,27 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/line.c:20,26
	  		return a;
	  	return b;
	  }
	- */
	+ #endif
	  
	  static
	  int
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/line.c:32,37 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/line.c:31,37
	  	return b;
	  }
	  
	+ #ifdef NOTUSED
	  /*
	   * Rather than line clip, we run the Bresenham loop over the full line,
	   * and clip on each pixel.  This is more expensive but means that
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/line.c:40,46 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/line.c:40,45
	   * test easy when possible.
	   */
	  
	- #ifdef NOTUSED
	  static
	  void
	  horline1(Memimage *dst, Point p0, Point p1, int srcval, Rectangle clipr)
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/line.c:246,252 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/line.c:245,251
	  }
	  #endif /* NOTUSED */
	  
	- Memimage*
	+ static Memimage*
	  membrush(int radius)
	  {
	  	static Memimage *brush;
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/line.c:257,263 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/line.c:256,262
	  		brush = allocmemimage(Rect(0, 0, 2*radius+1, 2*radius+1), memopaque->chan);
	  		if(brush != nil){
	  			memfillcolor(brush, DTransparent);	/* zeros */
	- 			memellipse(brush, Pt(radius, radius), radius, radius, -1, memopaque, Pt(radius, radius));
	+ 			memellipse(brush, Pt(radius, radius), radius, radius, -1, memopaque, Pt(radius, radius), S);
	  		}
	  		brushradius = radius;
	  	}
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/line.c:266,272 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/line.c:265,271
	  
	  static
	  void
	- discend(Point p, int radius, Memimage *dst, Memimage *src, Point dsrc)
	+ discend(Point p, int radius, Memimage *dst, Memimage *src, Point dsrc, int op)
	  {
	  	Memimage *disc;
	  	Rectangle r;
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/line.c:277,283 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/line.c:276,282
	  		r.min.y = p.y - radius;
	  		r.max.x = p.x + radius+1;
	  		r.max.y = p.y + radius+1;
	- 		memdraw(dst, r, src, addpt(r.min, dsrc), disc, Pt(0,0));
	+ 		memdraw(dst, r, src, addpt(r.min, dsrc), disc, Pt(0,0), op);
	  	}
	  }
	  
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/line.c:316,322 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/line.c:315,321
	  }
	  
	  void
	- _memimageline(Memimage *dst, Point p0, Point p1, int end0, int end1, int radius, Memimage *src, Point sp, Rectangle clipr)
	+ _memimageline(Memimage *dst, Point p0, Point p1, int end0, int end1, int radius, Memimage *src, Point sp, Rectangle clipr, int op)
	  {
	  	/*
	  	 * BUG: We should really really pick off purely horizontal and purely
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/line.c:326,332 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/line.c:325,331
	  
	  	int hor;
	  	int sin, cos, dx, dy, t;
	- 	Rectangle oclipr;
	+ 	Rectangle oclipr, r;
	  	Point q, pts[10], *pp, d;
	  
	  	if(radius < 0)
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/line.c:359,364 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/line.c:358,381
	  		end1 = t;
	  	}
	  
	+ 	if((p0.x == p1.x || p0.y == p1.y) && (end0&0x1F) == Endsquare && (end1&0x1F) == Endsquare){
	+ 		r.min = p0;
	+ 		r.max = p1;
	+ 		if(p0.x == p1.x){
	+ 			r.min.x -= radius;
	+ 			r.max.x += radius+1;
	+ 		}
	+ 		else{
	+ 			r.min.y -= radius;
	+ 			r.max.y += radius+1;
	+ 		}
	+ 		oclipr = dst->clipr;
	+ 		dst->clipr = clipr;
	+ 		memimagedraw(dst, r, src, sp, memopaque, sp, op);
	+ 		dst->clipr = oclipr;
	+ 		return;
	+ 	}
	+ 
	  /*    Hard: */
	  	/* draw thick line using polygon fill */
	  	icossin2(p1.x-p0.x, p1.y-p0.y, &cos, &sin);
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/line.c:371,377 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/line.c:388,394
	  	q.y = ICOSSCALE*p0.y+ICOSSCALE/2-sin/2;
	  	switch(end0 & 0x1F){
	  	case Enddisc:
	- 		discend(p0, radius, dst, src, d);
	+ 		discend(p0, radius, dst, src, d, op);
	  		/* fall through */
	  	case Endsquare:
	  	default:
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/line.c:384,390 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/line.c:401,407
	  		break;
	  	case Endarrow:
	  		arrowend(q, pp, end0, -sin, -cos, radius);
	- 		memfillpolysc(dst, pts, 5, ~0, src, addpt(pts[0], mulpt(d, ICOSSCALE)), 1, 10, 1);
	+ 		_memfillpolysc(dst, pts, 5, ~0, src, addpt(pts[0], mulpt(d, ICOSSCALE)), 1, 10, 1, op);
	  		pp[1] = pp[4];
	  		pp += 2;
	  	}
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/line.c:392,398 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/line.c:409,415
	  	q.y = ICOSSCALE*p1.y+ICOSSCALE/2+sin/2;
	  	switch(end1 & 0x1F){
	  	case Enddisc:
	- 		discend(p1, radius, dst, src, d);
	+ 		discend(p1, radius, dst, src, d, op);
	  		/* fall through */
	  	case Endsquare:
	  	default:
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/line.c:405,423 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/line.c:422,440
	  		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);
	+ 		_memfillpolysc(dst, pp, 5, ~0, src, addpt(pts[0], mulpt(d, ICOSSCALE)), 1, 10, 1, op);
	  		pp[1] = pp[4];
	  		pp += 2;
	  	}
	- 	memfillpolysc(dst, pts, pp-pts, ~0, src, addpt(pts[0], mulpt(d, ICOSSCALE)), 0, 10, 1);
	+ 	_memfillpolysc(dst, pts, pp-pts, ~0, src, addpt(pts[0], mulpt(d, ICOSSCALE)), 0, 10, 1, op);
	  	dst->clipr = oclipr;
	  	return;
	  }
	  
	  void
	- memimageline(Memimage *dst, Point p0, Point p1, int end0, int end1, int radius, Memimage *src, Point sp)
	+ memimageline(Memimage *dst, Point p0, Point p1, int end0, int end1, int radius, Memimage *src, Point sp, int op)
	  {
	- 	_memimageline(dst, p0, p1, end0, end1, radius, src, sp, dst->clipr);
	+ 	_memimageline(dst, p0, p1, end0, end1, radius, src, sp, dst->clipr, op);
	  }
	  
	  /*
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1496 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmemdraw/load.c
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/load.c:1,7 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/load.c:1,7
	- #include "../lib9.h"
	- 
	- #include "../libdraw/draw.h"
	- #include "../libmemdraw/memdraw.h"
	+ #include <u.h>
	+ #include <libc.h>
	+ #include <draw.h>
	+ #include <memdraw.h>
	  
	  int
	  _loadmemimage(Memimage *i, Rectangle r, uchar *data, int ndata)
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1496 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmemdraw/load.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1394 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmemdraw/mkcmap.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 900 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmemdraw/openmemsubfont.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 484 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmemdraw/poly.c
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/poly.c:1,21 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/poly.c:1,18
	- #include "../lib9.h"
	+ #include <u.h>
	+ #include <libc.h>
	+ #include <draw.h>
	+ #include <memdraw.h>
	+ #include <memlayer.h>
	  
	- #include "../libdraw/draw.h"
	- #include "../libmemdraw/memdraw.h"
	- 
	  void
	- mempoly(Memimage *dst, Point *vert, int nvert, int end0, int end1, int radius, Memimage *src, Point sp)
	+ mempoly(Memimage *dst, Point *vert, int nvert, int end0, int end1, int radius, Memimage *src, Point sp, int op)
	  {
	  	int i, e0, e1;
	  	Point d;
	- 	Point tp, tp_1;
	  
	  	if(nvert < 2)
	  		return;
	- 
	- 	/* use temp tp to avoid unaligned volatile warning on digital unix */
	- 	tp = vert[0];
	- 	d = subpt(sp, tp);
	+ 	d = subpt(sp, vert[0]);
	  	for(i=1; i<nvert; i++){
	  		e0 = e1 = Enddisc;
	  		if(i == 1)
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/poly.c:22,30 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/poly.c:19,24
	  			e0 = end0;
	  		if(i == nvert-1)
	  			e1 = end1;
	- 		tp = vert[i];
	- 		tp_1 = vert[i-1];
	- 		memline(dst, tp_1, tp, e0, e1, radius, src, addpt(d, tp_1));
	- 	/*	memline(dst, vert[i-1], vert[i], e0, e1, radius, src, addpt(d, vert[i-1])); */
	+ 		memline(dst, vert[i-1], vert[i], e0, e1, radius, src, addpt(d, vert[i-1]), op);
	  	}
	  }
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 2159 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmemdraw/read.c
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/read.c:1,10 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/read.c:1,8
	- #include "../lib9.h"
	+ #include <u.h>
	+ #include <libc.h>
	+ #include <draw.h>
	+ #include <memdraw.h>
	  
	- #include "../libdraw/draw.h"
	- #include "../libmemdraw/memdraw.h"
	- 
	- #define	CHUNK	8000
	- 
	  Memimage*
	  readmemimage(int fd)
	  {
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/read.c:11,30 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/read.c:9,32
	  	char hdr[5*12+1];
	  	int dy;
	  	ulong chan;
	- 	uint l, m, n;
	- 	int j;
	+ 	uint l, n;
	+ 	int m, j;
	  	int new, miny, maxy;
	  	Rectangle r;
	  	uchar *tmp;
	- 	int ldepth;
	+ 	int ldepth, chunk;
	  	Memimage *i;
	  
	- 	if(readn(fd, hdr, 11) != 11)
	+ 	if(readn(fd, hdr, 11) != 11){
	+ 		werrstr("readimage: short header");
	  		return nil;
	+ 	}
	  	if(memcmp(hdr, "compressed\n", 11) == 0)
	  		return creadmemimage(fd);
	- 	if(readn(fd, hdr+11, 5*12-11) != 5*12-11)
	+ 	if(readn(fd, hdr+11, 5*12-11) != 5*12-11){
	+ 		werrstr("readimage: short header (2)");
	  		return nil;
	+ 	}
	  
	  	/*
	  	 * distinguish new channel descriptor from old ldepth.
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/read.c:73,85 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/read.c:75,90
	  	i = allocmemimage(r, chan);
	  	if(i == nil)
	  		return nil;
	- 	tmp = malloc(CHUNK);
	+ 	chunk = 32*1024;
	+ 	if(chunk < l)
	+ 		chunk = l;
	+ 	tmp = malloc(chunk);
	  	if(tmp == nil)
	  		goto Err;
	  	while(maxy > miny){
	  		dy = maxy - miny;
	- 		if(dy*l > CHUNK)
	- 			dy = CHUNK/l;
	+ 		if(dy*l > chunk)
	+ 			dy = chunk/l;
	  		if(dy <= 0){
	  			werrstr("readmemimage: image too wide for buffer");
	  			goto Err;
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/read.c:94,103 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/read.c:99,108
	  			return nil;
	  		}
	  		if(!new)	/* an old image: must flip all the bits */
	- 			for(j=0; j<CHUNK; j++)
	+ 			for(j=0; j<chunk; j++)
	  				tmp[j] ^= 0xFF;
	  
	- 		if(loadmemimage(i, Rect(r.min.x, miny, r.max.x, miny+dy), tmp, CHUNK) <= 0)
	+ 		if(loadmemimage(i, Rect(r.min.x, miny, r.max.x, miny+dy), tmp, chunk) <= 0)
	  			goto Err;
	  		miny += dy;
	  	}
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1081 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmemdraw/string.c
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/string.c:1,11 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/string.c:1,11
	- #include "../lib9.h"
	+ #include <u.h>
	+ #include <libc.h>
	+ #include <draw.h>
	+ #include <memdraw.h>
	+ #include <memlayer.h>
	  
	- #include "../libdraw/draw.h"
	- #include "../libmemdraw/memdraw.h"
	- #include "../libmemlayer/memlayer.h"
	- 
	  Point
	- memimagestring(Memimage *b, Point p, Memimage *color, Memsubfont *f, char *cs)
	+ memimagestring(Memimage *b, Point p, Memimage *color, Point cp, Memsubfont *f, char *cs)
	  {
	  	int w, width;
	  	uchar *s;
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/string.c:13,19 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/string.c:13,19
	  	Fontchar *i;
	  
	  	s = (uchar*)cs;
	- 	for(; (c=*s) != 0; p.x+=width){
	+ 	for(; (c=*s); p.x+=width, cp.x+=width){
	  		width = 0;
	  		if(c < Runeself)
	  			s++;
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/string.c:27,36 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/string.c:27,37
	  		}
	  		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, Pt(i->x, i->top), f->bits, Pt(i->x, i->top));
	+ 			color, cp, f->bits, Pt(i->x, i->top), SoverD);
	  	}
	  	return p;
	  }
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/string.c:46,52 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/string.c:47,53
	  
	  	p = Pt(0, f->height);
	  	s = (uchar*)cs;
	- 	for(; (c=*s) != 0; p.x+=width){
	+ 	for(; (c=*s); p.x+=width){
	  		width = 0;
	  		if(c < Runeself)
	  			s++;
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 561 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmemdraw/subfont.c
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/subfont.c:1,7 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/subfont.c:1,7
	- #include "../lib9.h"
	- 
	- #include "../libdraw/draw.h"
	- #include "../libmemdraw/memdraw.h"
	+ #include <u.h>
	+ #include <libc.h>
	+ #include <draw.h>
	+ #include <memdraw.h>
	  
	  Memsubfont*
	  allocmemsubfont(char *name, int n, int height, int ascent, Fontchar *info, Memimage *i)
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 586 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmemdraw/times
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 435 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmemdraw/unload.c
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemdraw/unload.c:1,7 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemdraw/unload.c:1,7
	- #include "../lib9.h"
	- 
	- #include "../libdraw/draw.h"
	- #include "../libmemdraw/memdraw.h"
	+ #include <u.h>
	+ #include <libc.h>
	+ #include <draw.h>
	+ #include <memdraw.h>
	  
	  int
	  unloadmemimage(Memimage *i, Rectangle r, uchar *data, int ndata)
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 435 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmemdraw/unload.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 4375 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmemdraw/write.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 319 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmemlayer/Makefile
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 4064 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmemlayer/draw.c
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemlayer/draw.c:1,9 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemlayer/draw.c:1,9
	- #include "../lib9.h"
	+ #include <u.h>
	+ #include <libc.h>
	+ #include <draw.h>
	+ #include <memdraw.h>
	+ #include <memlayer.h>
	  
	- #include "../libdraw/draw.h"
	- #include "../libmemdraw/memdraw.h"
	- #include "../libmemlayer/memlayer.h"
	- 
	  struct Draw
	  {
	  	Point	deltas;
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemlayer/draw.c:11,16 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemlayer/draw.c:11,17
	  	Memlayer		*dstlayer;
	  	Memimage	*src;
	  	Memimage	*mask;
	+ 	int	op;
	  };
	  
	  static
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemlayer/draw.c:46,56 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemlayer/draw.c:47,57
	  		if(!ok)
	  			return;
	  	}
	- 	memdraw(dst, r, d->src, p0, d->mask, p1);
	+ 	memdraw(dst, r, d->src, p0, d->mask, p1, d->op);
	  }
	  
	  void
	- memdraw(Memimage *dst, Rectangle r, Memimage *src, Point p0, Memimage *mask, Point p1)
	+ memdraw(Memimage *dst, Rectangle r, Memimage *src, Point p0, Memimage *mask, Point p1, int op)
	  {
	  	struct Draw d;
	  	Rectangle srcr, tr, mr;
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemlayer/draw.c:69,75 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemlayer/draw.c:70,76
	  
	      Top:
	  	if(dst->layer==nil && src->layer==nil){
	- 		memimagedraw(dst, r, src, p0, mask, p1);
	+ 		memimagedraw(dst, r, src, p0, mask, p1, op);
	  		return;
	  	}
	  
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemlayer/draw.c:140,146 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemlayer/draw.c:141,147
	  			memlhide(dst, srcr);
	  		}
	  		memdraw(dl->save, rectsubpt(r, dl->delta), dl->save,
	- 			subpt(srcr.min, src->layer->delta), mask, p1);
	+ 			subpt(srcr.min, src->layer->delta), mask, p1, op);
	  		memlexpose(dst, r);
	  		return;
	  	}
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemlayer/draw.c:148,153 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemlayer/draw.c:149,160
	  	if(sl){
	  		if(sl->clear){
	  			src = sl->screen->image;
	+ 			if(dl != nil){
	+ 				r.min.x -= dl->delta.x;
	+ 				r.min.y -= dl->delta.y;
	+ 				r.max.x -= dl->delta.x;
	+ 				r.max.y -= dl->delta.y;
	+ 			}
	  			goto Top;
	  		}
	  		/* relatively rare case; use save area */
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemlayer/draw.c:179,184 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemlayer/draw.c:186,192
	  	d.deltam = subpt(p1, r.min);
	  	d.dstlayer = dl;
	  	d.src = src;
	+ 	d.op = op;
	  	d.mask = mask;
	- 	memlayerop(ldrawop, dst, r, r, &d);
	+ 	_memlayerop(ldrawop, dst, r, r, &d);
	  }
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1794 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmemlayer/lalloc.c
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemlayer/lalloc.c:1,9 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemlayer/lalloc.c:1,9
	- #include "../lib9.h"
	+ #include <u.h>
	+ #include <libc.h>
	+ #include <draw.h>
	+ #include <memdraw.h>
	+ #include <memlayer.h>
	  
	- #include "../libdraw/draw.h"
	- #include "../libmemdraw/memdraw.h"
	- #include "../libmemlayer/memlayer.h"
	- 
	  Memimage*
	  memlalloc(Memscreen *s, Rectangle screenr, Refreshfn refreshfn, void *refreshptr, ulong val)
	  {
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemlayer/lalloc.c:63,69 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemlayer/lalloc.c:63,69
	  	l->clear = 0;
	  
	  	/* now pull new window to front */
	- 	memltofront(n);
	+ 	_memltofrontfill(n, val != DNofill);
	  	l->refreshptr = refreshptr;
	  
	  	/*
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemlayer/lalloc.c:73,79 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemlayer/lalloc.c:73,79
	  	if(val != DNofill){
	  		memsetchan(paint, n->chan);
	  		memfillcolor(paint, val);
	- 		memdraw(n, n->r, paint, n->r.min, nil, n->r.min);
	+ 		memdraw(n, n->r, paint, n->r.min, nil, n->r.min, S);
	  	}
	  	return n;
	  }
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1794 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmemlayer/lalloc.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 2641 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmemlayer/layerop.c
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemlayer/layerop.c:1,9 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemlayer/layerop.c:1,9
	- #include "../lib9.h"
	+ #include <u.h>
	+ #include <libc.h>
	+ #include <draw.h>
	+ #include <memdraw.h>
	+ #include <memlayer.h>
	  
	- #include "../libdraw/draw.h"
	- #include "../libmemdraw/memdraw.h"
	- #include "../libmemlayer/memlayer.h"
	- 
	  #define	RECUR(a,b,c,d)	_layerop(fn, i, Rect(a.x, b.y, c.x, d.y), clipr, etc, front->layer->rear);
	  
	  static void
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemlayer/layerop.c:26,31 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemlayer/layerop.c:26,32
	  	fr = front->layer->screenr;
	  	if(rectXrect(r, fr) == 0){
	  		/* r doesn't touch this window; continue on next rearmost */
	+ 		// assert(front && front->layer && front->layer->screen && front->layer->rear);
	  		front = front->layer->rear;
	  		goto Top;
	  	}
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemlayer/layerop.c:53,59 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemlayer/layerop.c:54,60
	   * Assumes incoming rectangle has already been clipped to i's logical r and clipr
	   */
	  void
	- memlayerop(
	+ _memlayerop(
	  	void (*fn)(Memimage*, Rectangle, Rectangle, void*, int),
	  	Memimage *i,
	  	Rectangle screenr,	/* clipped to window boundaries */
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1183 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmemlayer/ldelete.c
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemlayer/ldelete.c:1,9 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemlayer/ldelete.c:1,9
	- #include "../lib9.h"
	+ #include <u.h>
	+ #include <libc.h>
	+ #include <draw.h>
	+ #include <memdraw.h>
	+ #include <memlayer.h>
	  
	- #include "../libdraw/draw.h"
	- #include "../libmemdraw/memdraw.h"
	- #include "../libmemlayer/memlayer.h"
	- 
	  void
	  memldelete(Memimage *i)
	  {
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemlayer/ldelete.c:21,27 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemlayer/ldelete.c:21,27
	  	s = i->layer->screen;
	  	if(s->fill){
	  		i->clipr = i->r;
	- 		memdraw(i, i->r, s->fill, i->r.min, nil, i->r.min);
	+ 		memdraw(i, i->r, s->fill, i->r.min, nil, i->r.min, S);
	  	}
	  	if(l->front){
	  		l->front->layer->rear = nil;
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemlayer/ldelete.c:49,55 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemlayer/ldelete.c:49,55
	  }
	  
	  void
	- memlsetclear(Memscreen *s)
	+ _memlsetclear(Memscreen *s)
	  {
	  	Memimage *i, *j;
	  	Memlayer *l;
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1675 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmemlayer/lhide.c
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemlayer/lhide.c:1,9 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemlayer/lhide.c:1,9
	- #include "../lib9.h"
	+ #include <u.h>
	+ #include <libc.h>
	+ #include <draw.h>
	+ #include <memdraw.h>
	+ #include <memlayer.h>
	  
	- #include "../libdraw/draw.h"
	- #include "../libmemdraw/memdraw.h"
	- #include "../libmemlayer/memlayer.h"
	- 
	  /*
	   * Hide puts that portion of screenr now on the screen into the window's save area.
	   * Expose puts that portion of screenr now in the save area onto the screen.
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemlayer/lhide.c:26,32 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemlayer/lhide.c:26,32
	  	l = etc;
	  	if(src != l->save){	/* do nothing if src is already in save area */
	  		r = rectsubpt(screenr, l->delta);
	- 		memdraw(l->save, r, src, screenr.min, nil, screenr.min);
	+ 		memdraw(l->save, r, src, screenr.min, nil, screenr.min, S);
	  	}
	  }
	  
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemlayer/lhide.c:37,45 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemlayer/lhide.c:37,46
	  		return;
	  	if(rectclip(&screenr, i->layer->screen->image->r) == 0)
	  		return;
	- 	memlayerop(lhideop, i, screenr, screenr, i->layer);
	+ 	_memlayerop(lhideop, i, screenr, screenr, i->layer);
	  }
	  
	+ static
	  void
	  lexposeop(Memimage *dst, Rectangle screenr, Rectangle clipr, void *etc, int insave)
	  {
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemlayer/lhide.c:52,58 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemlayer/lhide.c:53,59
	  	l = etc;
	  	r = rectsubpt(screenr, l->delta);
	  	if(l->save)
	- 		memdraw(dst, screenr, l->save, r.min, nil, r.min);
	+ 		memdraw(dst, screenr, l->save, r.min, nil, r.min, S);
	  	else
	  		l->refreshfn(dst, r, l->refreshptr);
	  }
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemlayer/lhide.c:62,66 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemlayer/lhide.c:63,67
	  {
	  	if(rectclip(&screenr, i->layer->screen->image->r) == 0)
	  		return;
	- 	memlayerop(lexposeop, i, screenr, screenr, i->layer);
	+ 	_memlayerop(lexposeop, i, screenr, screenr, i->layer);
	  }
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 2587 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmemlayer/line.c
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemlayer/line.c:1,9 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemlayer/line.c:1,9
	- #include "../lib9.h"
	+ #include <u.h>
	+ #include <libc.h>
	+ #include <draw.h>
	+ #include <memdraw.h>
	+ #include <memlayer.h>
	  
	- #include "../libdraw/draw.h"
	- #include "../libmemdraw/memdraw.h"
	- #include "../libmemlayer/memlayer.h"
	- 
	  struct Lline
	  {
	  	Point			p0;
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemlayer/line.c:15,20 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemlayer/line.c:15,21
	  	Point			sp;
	  	Memlayer		*dstlayer;
	  	Memimage	*src;
	+ 	int			op;
	  };
	  
	  static void llineop(Memimage*, Rectangle, Rectangle, void*, int);
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemlayer/line.c:21,27 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemlayer/line.c:22,28
	  
	  static
	  void
	- _memline(Memimage *dst, Point p0, Point p1, int end0, int end1, int radius, Memimage *src, Point sp, Rectangle clipr)
	+ _memline(Memimage *dst, Point p0, Point p1, int end0, int end1, int radius, Memimage *src, Point sp, Rectangle clipr, int op)
	  {
	  	Rectangle r;
	  	struct Lline ll;
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemlayer/line.c:38,44 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemlayer/line.c:39,45
	     Top:
	  	dl = dst->layer;
	  	if(dl == nil){
	- 		_memimageline(dst, p0, p1, end0, end1, radius, src, sp, clipr);
	+ 		_memimageline(dst, p0, p1, end0, end1, radius, src, sp, clipr, op);
	  		return;
	  	}
	  	if(!srcclipped){
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemlayer/line.c:66,75 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemlayer/line.c:67,74
	  
	  	/* XXX */
	  	/* this is not the correct set of tests */
	- /*
	- 	if(log2[dst->depth] != log2[src->depth] || log2[dst->depth]!=3)
	- 		return;
	- */
	+ //	if(log2[dst->depth] != log2[src->depth] || log2[dst->depth]!=3)
	+ //		return;
	  
	  	/* can't use sutherland-cohen clipping because lines are wide */
	  	r = memlinebbox(p0, p1, end0, end1, radius);
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemlayer/line.c:88,94 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemlayer/line.c:87,94
	  	ll.src = src;
	  	ll.radius = radius;
	  	ll.delta = dl->delta;
	- 	memlayerop(llineop, dst, r, r, &ll);
	+ 	ll.op = op;
	+ 	_memlayerop(llineop, dst, r, r, &ll);
	  }
	  
	  static
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemlayer/line.c:112,122 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemlayer/line.c:112,122
	  		p0 = ll->p0;
	  		p1 = ll->p1;
	  	}
	- 	_memline(dst, p0, p1, ll->end0, ll->end1, ll->radius, ll->src, ll->sp, clipr);
	+ 	_memline(dst, p0, p1, ll->end0, ll->end1, ll->radius, ll->src, ll->sp, clipr, ll->op);
	  }
	  
	  void
	- memline(Memimage *dst, Point p0, Point p1, int end0, int end1, int radius, Memimage *src, Point sp)
	+ memline(Memimage *dst, Point p0, Point p1, int end0, int end1, int radius, Memimage *src, Point sp, int op)
	  {
	- 	_memline(dst, p0, p1, end0, end1, radius, src, sp, dst->clipr);
	+ 	_memline(dst, p0, p1, end0, end1, radius, src, sp, dst->clipr, op);
	  }
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1032 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmemlayer/load.c
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemlayer/load.c:1,9 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemlayer/load.c:1,9
	- #include "../lib9.h"
	+ #include <u.h>
	+ #include <libc.h>
	+ #include <draw.h>
	+ #include <memdraw.h>
	+ #include <memlayer.h>
	  
	- #include "../libdraw/draw.h"
	- #include "../libmemdraw/memdraw.h"
	- #include "../libmemlayer/memlayer.h"
	- 
	  int
	  memload(Memimage *dst, Rectangle r, uchar *data, int n, int iscompressed)
	  {
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemlayer/load.c:49,55 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemlayer/load.c:49,55
	  	if(tmp == nil)
	  		return -1;
	  	n = loadfn(tmp, lr, data, n);
	- 	memdraw(dst, lr, tmp, lr.min, nil, lr.min);
	+ 	memdraw(dst, lr, tmp, lr.min, nil, lr.min, S);
	  	freememimage(tmp);
	  	return n;
	  }
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 2507 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmemlayer/lorigin.c
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemlayer/lorigin.c:1,9 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemlayer/lorigin.c:1,9
	- #include "../lib9.h"
	+ #include <u.h>
	+ #include <libc.h>
	+ #include <draw.h>
	+ #include <memdraw.h>
	+ #include <memlayer.h>
	  
	- #include "../libdraw/draw.h"
	- #include "../libmemdraw/memdraw.h"
	- #include "../libmemlayer/memlayer.h"
	- 
	  /*
	   * Place i so i->r.min = log, i->layer->screenr.min == scr.
	  */
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemlayer/lorigin.c:39,45 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemlayer/lorigin.c:39,45
	  	wasclear = l->clear;
	  	if(nsave){
	  		if(!wasclear)
	- 			memimagedraw(nsave, nsave->r, l->save, l->save->r.min, nil, Pt(0,0));
	+ 			memimagedraw(nsave, nsave->r, l->save, l->save->r.min, nil, Pt(0,0), S);
	  		freememimage(l->save);
	  		l->save = nsave;
	  	}
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemlayer/lorigin.c:90,96 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemlayer/lorigin.c:90,96
	  	 * Everything's covered.  Copy to new position and delete shadow window.
	  	 */
	  	if(wasclear)
	- 		memdraw(s->image, newr, s->image, oldr.min, nil, Pt(0,0));
	+ 		memdraw(s->image, newr, s->image, oldr.min, nil, Pt(0,0), S);
	  	else
	  		memlexpose(i, newr);
	  	memldelete(shad);
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 703 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmemlayer/lsetrefresh.c
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemlayer/lsetrefresh.c:1,8 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemlayer/lsetrefresh.c:1,8
	- #include "../lib9.h"
	- 
	- #include "../libdraw/draw.h"
	- #include "../libmemdraw/memdraw.h"
	- #include "../libmemlayer/memlayer.h"
	+ #include <u.h>
	+ #include <libc.h>
	+ #include <draw.h>
	+ #include <memdraw.h>
	+ #include <memlayer.h>
	  
	  int
	  memlsetrefresh(Memimage *i, Refreshfn fn, void *ptr)
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1289 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmemlayer/ltofront.c
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemlayer/ltofront.c:1,15 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemlayer/ltofront.c:1,15
	- #include "../lib9.h"
	+ #include <u.h>
	+ #include <libc.h>
	+ #include <draw.h>
	+ #include <memdraw.h>
	+ #include <memlayer.h>
	  
	- #include "../libdraw/draw.h"
	- #include "../libmemdraw/memdraw.h"
	- #include "../libmemlayer/memlayer.h"
	- 
	  /*
	   * Pull i towards top of screen, just behind front
	  */
	  static
	  void
	- _memltofront(Memimage *i, Memimage *front)
	+ _memltofront(Memimage *i, Memimage *front, int fill)
	  {
	  	Memlayer *l;
	  	Memscreen *s;
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemlayer/ltofront.c:42,57 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemlayer/ltofront.c:42,64
	  		l->rear = f;
	  		f->layer->front = i;
	  		f->layer->rear = rr;
	- 		if(overlap)
	+ 		if(overlap && fill)
	  			memlexpose(i, x);
	  	}
	  }
	  
	  void
	+ _memltofrontfill(Memimage *i, int fill)
	+ {
	+ 	_memltofront(i, nil, fill);
	+ 	_memlsetclear(i->layer->screen);
	+ }
	+ 
	+ void
	  memltofront(Memimage *i)
	  {
	- 	_memltofront(i, nil);
	- 	memlsetclear(i->layer->screen);
	+ 	_memltofront(i, nil, 1);
	+ 	_memlsetclear(i->layer->screen);
	  }
	  
	  void
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemlayer/ltofront.c:65,73 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemlayer/ltofront.c:72,80
	  	front = nil;
	  	while(--n >= 0){
	  		i = *ip++;
	- 		_memltofront(i, front);
	+ 		_memltofront(i, front, 1);
	  		front = i;
	  	}
	  	s = front->layer->screen;
	- 	memlsetclear(s);
	+ 	_memlsetclear(s);
	  }
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1062 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmemlayer/ltorear.c
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemlayer/ltorear.c:1,9 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemlayer/ltorear.c:1,9
	- #include "../lib9.h"
	+ #include <u.h>
	+ #include <libc.h>
	+ #include <draw.h>
	+ #include <memdraw.h>
	+ #include <memlayer.h>
	  
	- #include "../libdraw/draw.h"
	- #include "../libmemdraw/memdraw.h"
	- #include "../libmemlayer/memlayer.h"
	- 
	  void
	  _memltorear(Memimage *i, Memimage *rear)
	  {
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemlayer/ltorear.c:47,53 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemlayer/ltorear.c:47,53
	  memltorear(Memimage *i)
	  {
	  	_memltorear(i, nil);
	- 	memlsetclear(i->layer->screen);
	+ 	_memlsetclear(i->layer->screen);
	  }
	  
	  void
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libmemlayer/ltorear.c:65,69 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libmemlayer/ltorear.c:65,69
	  		rear = i;
	  	}
	  	s = rear->layer->screen;
	- 	memlsetclear(s);
	+ 	_memlsetclear(s);
	  }
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1007 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmemlayer/unload.c
 [rsc] d-rwxrwxr-x M 1092710 rsc drawterm 0 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmp
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 602 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmp/Makefile
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 577 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmp/betomp.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 2050 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmp/crt.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 813 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmp/crttest.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 464 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmp/dat.h
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 455 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmp/letomp.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 783 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmp/mpadd.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 2564 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmp/mpaux.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 462 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmp/mpcmp.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 732 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmp/mpdigdiv.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 2423 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmp/mpdiv.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1226 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmp/mpeuclid.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1149 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmp/mpexp.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1613 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmp/mpextendedgcd.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 2729 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmp/mpfmt.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 394 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmp/mpinvert.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 838 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmp/mpleft.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 247 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmp/mpmod.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 3110 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmp/mpmul.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 584 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmp/mprand.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 695 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmp/mpright.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 792 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmp/mpsub.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 879 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmp/mptobe.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 553 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmp/mptoi.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 786 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmp/mptole.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 413 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmp/mptoui.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 727 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmp/mptouv.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 995 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmp/mptov.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 519 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmp/mpvecadd.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 402 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmp/mpveccmp.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1582 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmp/mpvecdigmuladd.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 523 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmp/mpvecsub.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 34 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmp/os.h
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 306 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmp/reduce
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 3026 Dec 29 18:56 sys/src/cmd/unix/drawterm/libmp/strtomp.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 771 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/Makefile
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 64145 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/aes.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 19676 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/blowfish.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1371 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/decodepem.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 17496 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/des.c
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libsec/des.c:1,5 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libsec/des.c:1,5
	- #include "../lib9.h"
	- #include "../libsec/libsec.h"
	+ #include "os.h"
	+ #include <libsec.h>
	  
	  /*
	   * integrated sbox & p perm
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1135 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/des3CBC.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 917 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/des3ECB.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1079 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/desCBC.c
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libsec/desCBC.c:1,5 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libsec/desCBC.c:1,6
	- #include "../lib9.h"
	- #include "../libsec/libsec.h"
	+ #include "os.h"
	+ #include <mp.h>
	+ #include <libsec.h>
	  
	  // Because of the way that non multiple of 8
	  // buffers are handled, the decryptor must
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 861 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/desECB.c
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libsec/desECB.c:1,5 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libsec/desECB.c:1,6
	- #include "../lib9.h"
	- #include "../libsec/libsec.h"
	+ #include "os.h"
	+ #include <mp.h>
	+ #include <libsec.h>
	  
	  // I wasn't sure what to do when the buffer was not
	  // a multiple of 8.  I did what lacy's cryptolib did
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 647 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/desmodes.c
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libsec/desmodes.c:1,5 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libsec/desmodes.c:1,5
	- #include "../lib9.h"
	- #include "../libsec/libsec.h"
	+ #include "os.h"
	+ #include <libsec.h>
	  
	  /*
	   *  these routines use the 64bit format for
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 864 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/dsaalloc.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1237 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/dsagen.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1881 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/dsaprimes.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 279 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/dsaprivtopub.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 934 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/dsasign.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 909 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/dsaverify.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 778 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/egalloc.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 564 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/egdecrypt.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 806 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/egencrypt.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 413 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/eggen.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 273 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/egprivtopub.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 807 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/egsign.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 655 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/egtest.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 519 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/egverify.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 258 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/fastrand.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 535 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/genprime.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1171 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/genrandom.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 741 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/gensafeprime.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1039 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/genstrongprime.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1167 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/hmac.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 344 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/hmactest.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 4260 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/md4.c
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libsec/md4.c:1,5 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libsec/md4.c:1,5
	- #include "../lib9.h"
	- #include "../libsec/libsec.h"
	+ #include "os.h"
	+ #include <libsec.h>
	  
	  /*
	   *  This MD4 is implemented from the description in Stinson's Cryptography,
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 537 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/md4test.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 3254 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/md5.c
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libsec/md5.c:1,5 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libsec/md5.c:1,5
	- #include "../lib9.h"
	- #include "../libsec/libsec.h"
	+ #include "os.h"
	+ #include <libsec.h>
	  
	  /*
	   *  rfc1321 requires that I include this.  The code is new.  The constants
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libsec/md5.c:28,34 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libsec/md5.c:28,33
	   */
	  
	  static void encode(uchar*, u32int*, ulong);
	- static void decode(u32int*, uchar*, ulong);
	  
	  extern void _md5block(uchar*, ulong, u32int*);
	  
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 5015 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/md5block.c
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libsec/md5block.c:1,5 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libsec/md5block.c:1,5
	- #include "../lib9.h"
	- #include "../libsec/libsec.h"
	+ #include "os.h"
	+ #include <libsec.h>
	  
	  /*
	   *  rfc1321 requires that I include this.  The code is new.  The constants
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 657 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/md5pickle.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 327 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/nfastrand.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 33 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/os.h
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 2486 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/primetest.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 187 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/prng.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1567 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/probably_prime.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 430080 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/ranlib.core
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1415 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/rc4.c
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libsec/rc4.c:1,5 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libsec/rc4.c:1,5
	- #include "../lib9.h"
	- #include "../libsec/libsec.h"
	+ #include "os.h"
	+ #include <libsec.h>
	  
	  void
	  setupRC4state(RC4state *key, uchar *start, int n)
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 759 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/readcert.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 657 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/rsaalloc.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 749 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/rsadecrypt.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 192 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/rsaencrypt.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1104 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/rsafill.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1451 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/rsagen.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 237 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/rsaprivtopub.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1095 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/rsatest.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 2279 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/sha1.c
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libsec/sha1.c:1,5 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libsec/sha1.c:1,5
	- #include "../lib9.h"
	- #include "../libsec/libsec.h"
	+ #include "os.h"
	+ #include <libsec.h>
	  
	  static void encode(uchar*, u32int*, ulong);
	  
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 4673 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/sha1block.c
	/n/sourcesdump/2005/1229/plan9/sys/src/cmd/unix/drawterm/libsec/sha1block.c:1,4 - 
	/n/sourcesdump/2005/1230/plan9/sys/src/cmd/unix/drawterm/libsec/sha1block.c:1,4
	- #include "../lib9.h"
	+ #include "os.h"
	  
	  void
	  _sha1block(uchar *p, ulong len, u32int *s)
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 717 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/sha1pickle.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 6851 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/smallprimes.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 70640 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/smallprimetest.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1891 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/thumb.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 53926 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/tlshand.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 50237 Dec 29 18:56 sys/src/cmd/unix/drawterm/libsec/x509.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 2440 Dec 29 18:55 sys/src/cmd/unix/drawterm/main.c
 [rsc] d-rwxrwxr-x M 1092710 rsc drawterm 0 Dec 29 18:55 sys/src/cmd/unix/drawterm/posix-386
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 378 Dec 29 18:55 sys/src/cmd/unix/drawterm/posix-386/Makefile
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 90 Dec 29 18:55 sys/src/cmd/unix/drawterm/posix-386/getcallerpc.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 6472 Dec 29 18:55 sys/src/cmd/unix/drawterm/posix-386/md5block.spp
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 4749 Dec 29 18:55 sys/src/cmd/unix/drawterm/posix-386/sha1block.spp
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 270 Dec 29 18:55 sys/src/cmd/unix/drawterm/posix-386/tas.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1880 Dec 29 18:55 sys/src/cmd/unix/drawterm/posix-factotum.c
 [rsc] d-rwxrwxr-x M 1092710 rsc drawterm 0 Dec 29 18:47 sys/src/cmd/unix/drawterm/posix-mips
 [rsc] d-rwxrwxr-x M 1092710 rsc drawterm 0 Dec 29 18:55 sys/src/cmd/unix/drawterm/posix-power
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 291 Dec 29 18:55 sys/src/cmd/unix/drawterm/posix-power/Makefile
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 90 Dec 29 18:55 sys/src/cmd/unix/drawterm/posix-power/getcallerpc.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 5032 Dec 29 18:55 sys/src/cmd/unix/drawterm/posix-power/md5block.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 4710 Dec 29 18:55 sys/src/cmd/unix/drawterm/posix-power/sha1block.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 943 Dec 29 18:55 sys/src/cmd/unix/drawterm/posix-power/tas.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 1842 Dec 29 18:55 sys/src/cmd/unix/drawterm/readcons.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 457 Dec 29 18:55 sys/src/cmd/unix/drawterm/resource.h
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 15742 Dec 29 18:55 sys/src/cmd/unix/drawterm/secstore.c
 [rsc] d-rwxrwxr-x M 1092710 rsc drawterm 0 Dec 29 18:55 sys/src/cmd/unix/drawterm/win32-386
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 291 Dec 29 18:55 sys/src/cmd/unix/drawterm/win32-386/Makefile
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 90 Dec 29 18:55 sys/src/cmd/unix/drawterm/win32-386/getcallerpc.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 6591 Dec 29 18:55 sys/src/cmd/unix/drawterm/win32-386/md5block.spp
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 4912 Dec 29 18:55 sys/src/cmd/unix/drawterm/win32-386/sha1block.spp
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 270 Dec 29 18:55 sys/src/cmd/unix/drawterm/win32-386/tas.c
 [rsc] --rw-rw-r-- M 1092710 rsc drawterm 238 Dec 29 18:55 sys/src/cmd/unix/drawterm/win32-factotum.c
 [rsc] --rw-rw-r-- M 1092710 glenda sys 1741 Dec 29 19:06 sys/man/8/drawterm
	/n/sourcesdump/2005/1229/plan9/sys/man/8/drawterm:4,9 - 
	/n/sourcesdump/2005/1230/plan9/sys/man/8/drawterm:4,12
	  .SH SYNOPSIS
	  .B drawterm
	  [
	+ .B -d
	+ ]
	+ [
	  .B -a
	  .I authaddr
	  ]
	/n/sourcesdump/2005/1229/plan9/sys/man/8/drawterm:12,27 - 
	/n/sourcesdump/2005/1230/plan9/sys/man/8/drawterm:15,39
	  .I cpuaddr
	  ]
	  [
	- .B -d
	- depth
	+ .B -e
	+ .I encryption-hash-algs
	  ]
	  [
	- .B -r
	- root
	+ .B -k
	+ .I keypattern
	  ]
	  [
	- .B -nm
	+ .B -s
	+ .I secstoreaddr
	  ]
	+ [
	+ .B -u
	+ .I user
	+ ]
	+ [
	+ .B -C
	+ .I cmd args ...
	+ ]
	  .SH DESCRIPTION
	  .I Drawterm
	  is
	/n/sourcesdump/2005/1229/plan9/sys/man/8/drawterm:46,111 - 
	/n/sourcesdump/2005/1230/plan9/sys/man/8/drawterm:58,90
	  By default, 
	  drawterm
	  uses the CPU server
	- .B CPUSERV
	+ .B $cpu
	+ or
	+ .BR cpu .
	  and the authentication server
	- .BR AUTHSERV .
	+ .B $auth
	+ or
	+ .BR auth .
	  The 
	  .B -a
	  and
	  .B -c
	  options specify alternate servers.
	- (Edit the source to set appropriate local values  for the variables
	- .B AUTHSERV
	- and
	- .BR CPUSERV ).
	+ (Edit the source to set appropriate local defaults.)
	  .PP
	- On Windows systems, the file system served by the
	- terminal (and mounted on
	- .BR /mnt/term )
	- is the tree rooted at
	- .BR c:/ .
	- The
	- .B -r
	- option specifies a different file system root.
	- In Windows, the depth of the virtual screen
	- provided by
	- drawterm
	- matches the depth of the actual screen.
	- To present a screen with a different depth, use the
	- .B -d
	- option.
	- Both options do nothing on non-Windows systems.
	- .PP
	- The 
	- .B -n
	- option causes 
	- drawterm to prompt for authentication via
	- .IR netkey -style
	- challenge/response rather than using
	- the password-based protocol typically used
	- by terminals.
	- .PP
	- By default, drawterm queues mouse events to
	- guard against lost events due to network latency.
	- The
	- .B -m
	- option turns this behavior off.
	- .PP
	  Drawterm has been ported to
	- Digital Unix,
	+ FreeBSD,
	  Irix,
	  Linux,
	- Solaris,
	+ NetBSD,
	  and
	  Windows.
	- Binaries are kept in
	- .BR /sys/src/cmd/unix/drawterm/bin .
	+ Binaries can be downloaded from
	+ .BR http://swtch.com/drawterm/ .
	  .SH SOURCE
	  .B /sys/src/cmd/unix/drawterm
	  .SH DIAGNOSTICS
	- The Unix versions of drawterm print diagnostics
	- to standard error.
	- The Windows version displays message boxes.
	+ Drawterm prints most diagnostics in its own window.
	  .SH "SEE ALSO
	  .IR cpu (1),
	  .IR rio (1)


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].