~kris/9p

9hist

7693c636d4c136c74a3c265e2c175ffc2cc23c1c — David du Colombier 33 years ago aec8a87
Plan 9 from Bell Labs 1992-11-15
4 files changed, 217 insertions(+), 135 deletions(-)

M pc/l.s
M pc/vga.c
M port/devbit.c
M port/portfns.h
M pc/l.s => pc/l.s +1 -1
@@ 646,7 646,7 @@ TEXT	l0update(SB),$0
	MOVL	to+4(FP),DI
l00:
	MOVB	-1(SI)(CX*1),AL
	MOVB	bitrevtab(SB)(AX*1),AL
	MOVB	revtab0(SB)(AX*1),AL
	MOVB	AL,-1(DI)(CX*1)
	LOOP	l00
	RET

M pc/vga.c => pc/vga.c +91 -92
@@ 148,11 148,17 @@ setmode(VGAmode *v)
{
	int i;

	/* turn screen off (to avoid damage) */
	srout(1, 0x21);

	for(i = 0; i < sizeof(v->general); i++)
		genout(i, v->general[i]);

	for(i = 0; i < sizeof(v->sequencer); i++)
		srout(i, v->sequencer[i]);
		if(i == 1)
			srout(i, v->sequencer[i]|0x20);		/* avoid enabling screen */
		else
			srout(i, v->sequencer[i]);

	crout(Cvre, 0);	/* allow writes to CRT registers 0-7 */
	for(i = 0; i < sizeof(v->crt); i++)


@@ 163,6 169,9 @@ setmode(VGAmode *v)

	for(i = 0; i < sizeof(v->attribute); i++)
		arout(i, v->attribute[i]);

	/* turn screen on */
	srout(1, v->sequencer[1]);
}

void


@@ 276,14 285,6 @@ setscreen(int maxx, int maxy, int ldepth)
	vgascreen.r.max = Pt(maxx, vgamaxy);
	vgascreen.clipr = vgascreen.r;
	memset(vgascreen.base, 0xff, vgascreen.width * BY2WD * vgamaxy);
	if(ldepth == 3){
		uchar *v;

		v = (uchar*)vgascreen.base;
		for(x = 0; x < vgamaxy; x++)
			for(i = 0; i < vgascreen.width*BY2WD; i+=8)
				*v = 0;
	}

	/*
	 *  setup new soft screen, free memory for old screen


@@ 340,8 341,8 @@ screeninit(void)
	/*
	 *  arrow is defined as a big endian
	 */
	bitreverse(arrow.set, 2*16);
	bitreverse(arrow.clr, 2*16);
	pixreverse(arrow.set, 2*16, 0);
	pixreverse(arrow.clr, 2*16, 0);

	/*
	 *  swizzle the font longs.  we do both byte and bit swizzling


@@ 351,8 352,8 @@ screeninit(void)
	l = defont->bits->base;
	for(i = defont->bits->width*Dy(defont->bits->r); i > 0; i--, l++)
		*l = (*l<<24) | ((*l>>8)&0x0000ff00) | ((*l<<8)&0x00ff0000) | (*l>>24);
	bitreverse((uchar*)defont->bits->base,
		defont->bits->width*BY2WD*Dy(defont->bits->r));
	pixreverse((uchar*)defont->bits->base,
		defont->bits->width*BY2WD*Dy(defont->bits->r), 0);

	/*
	 *  set up 'soft' and hard screens


@@ 544,8 545,8 @@ screenputs(char *s, int n)
	Rune r;
	int i;
	char buf[4];
	Rectangle rect;

	mbbpt(out.pos);
	while(n > 0){
		i = chartorune(&r, s);
		if(i == 0){


@@ 568,12 569,16 @@ screenputs(char *s, int n)
				out.pos.x -= out.bwid;
				gsubfstring(&gscreen, out.pos, defont, " ", flipD[S]);
			}
			mbbpt(Pt(out.pos.x + out.bwid, out.pos.y+defont0.height));
			rect.min = Pt(out.pos.x, out.pos.y);
			rect.max = Pt(out.pos.x+out.bwid, out.pos.y+defont0.height);
			mbbrect(rect);
		}else{
			if(out.pos.x >= gscreen.r.max.x-out.bwid)
				screenputnl();
			rect.min = Pt(out.pos.x, out.pos.y);
			rect.max = Pt(out.pos.x+out.bwid, out.pos.y+defont0.height);
			out.pos = gsubfstring(&gscreen, out.pos, defont, buf, flipD[S]);
			mbbpt(Pt(out.pos.x, out.pos.y+defont0.height));
			mbbrect(rect);
		}
	}
	vgaupdate();


@@ 599,15 604,11 @@ getcolor(ulong p, ulong *pr, ulong *pg, ulong *pb)
int
setcolor(ulong p, ulong r, ulong g, ulong b)
{
	extern uchar bitrevtab[];

	p &= (1<<(1<<gscreen.ldepth))-1;
	lock(&vgalock);
	colormap[p][0] = r;
	colormap[p][1] = g;
	colormap[p][2] = b;
	if(vgascreen.ldepth == 3)
		p = bitrevtab[p];
	outb(CMWX, p);
	outb(CM, r>>(32-6));
	outb(CM, g>>(32-6));


@@ 660,8 661,8 @@ void
bigcursor(void)
{
	memmove(&arrow, &fatarrow, sizeof(fatarrow));
	bitreverse(arrow.set, 2*16);
	bitreverse(arrow.clr, 2*16);
	pixreverse(arrow.set, 2*16, 0);
	pixreverse(arrow.clr, 2*16, 0);
}

/*


@@ 672,47 673,46 @@ bigcursor(void)
 *	if the bits in uchar x are labeled
 *		76543210
 *	then l1revsep[x] yields a ushort with bits
 *		________0246________1357
 *		________1357________0246
 *	where _ represents a bit whose value is 0.
 *
 *  This table is used by l1update() in l.s.  l1update is implemented
 *  in assembler for speed.
 *
 */
ulong l1revsep[] =
{
	0x00000, 0x80000, 0x00008, 0x80008, 0x40000, 0xc0000, 0x40008, 0xc0008,
	0x00004, 0x80004, 0x0000c, 0x8000c, 0x40004, 0xc0004, 0x4000c, 0xc000c,
	0x20000, 0xa0000, 0x20008, 0xa0008, 0x60000, 0xe0000, 0x60008, 0xe0008,
	0x20004, 0xa0004, 0x2000c, 0xa000c, 0x60004, 0xe0004, 0x6000c, 0xe000c,
	0x00002, 0x80002, 0x0000a, 0x8000a, 0x40002, 0xc0002, 0x4000a, 0xc000a,
	0x00006, 0x80006, 0x0000e, 0x8000e, 0x40006, 0xc0006, 0x4000e, 0xc000e,
	0x20002, 0xa0002, 0x2000a, 0xa000a, 0x60002, 0xe0002, 0x6000a, 0xe000a,
	0x20006, 0xa0006, 0x2000e, 0xa000e, 0x60006, 0xe0006, 0x6000e, 0xe000e,
	0x10000, 0x90000, 0x10008, 0x90008, 0x50000, 0xd0000, 0x50008, 0xd0008,
	0x10004, 0x90004, 0x1000c, 0x9000c, 0x50004, 0xd0004, 0x5000c, 0xd000c,
	0x30000, 0xb0000, 0x30008, 0xb0008, 0x70000, 0xf0000, 0x70008, 0xf0008,
	0x30004, 0xb0004, 0x3000c, 0xb000c, 0x70004, 0xf0004, 0x7000c, 0xf000c,
	0x10002, 0x90002, 0x1000a, 0x9000a, 0x50002, 0xd0002, 0x5000a, 0xd000a,
	0x10006, 0x90006, 0x1000e, 0x9000e, 0x50006, 0xd0006, 0x5000e, 0xd000e,
	0x30002, 0xb0002, 0x3000a, 0xb000a, 0x70002, 0xf0002, 0x7000a, 0xf000a,
	0x30006, 0xb0006, 0x3000e, 0xb000e, 0x70006, 0xf0006, 0x7000e, 0xf000e,
	0x00001, 0x80001, 0x00009, 0x80009, 0x40001, 0xc0001, 0x40009, 0xc0009,
	0x00005, 0x80005, 0x0000d, 0x8000d, 0x40005, 0xc0005, 0x4000d, 0xc000d,
	0x20001, 0xa0001, 0x20009, 0xa0009, 0x60001, 0xe0001, 0x60009, 0xe0009,
	0x20005, 0xa0005, 0x2000d, 0xa000d, 0x60005, 0xe0005, 0x6000d, 0xe000d,
	0x00003, 0x80003, 0x0000b, 0x8000b, 0x40003, 0xc0003, 0x4000b, 0xc000b,
	0x00007, 0x80007, 0x0000f, 0x8000f, 0x40007, 0xc0007, 0x4000f, 0xc000f,
	0x20003, 0xa0003, 0x2000b, 0xa000b, 0x60003, 0xe0003, 0x6000b, 0xe000b,
	0x20007, 0xa0007, 0x2000f, 0xa000f, 0x60007, 0xe0007, 0x6000f, 0xe000f,
	0x10001, 0x90001, 0x10009, 0x90009, 0x50001, 0xd0001, 0x50009, 0xd0009,
	0x10005, 0x90005, 0x1000d, 0x9000d, 0x50005, 0xd0005, 0x5000d, 0xd000d,
	0x30001, 0xb0001, 0x30009, 0xb0009, 0x70001, 0xf0001, 0x70009, 0xf0009,
	0x30005, 0xb0005, 0x3000d, 0xb000d, 0x70005, 0xf0005, 0x7000d, 0xf000d,
	0x10003, 0x90003, 0x1000b, 0x9000b, 0x50003, 0xd0003, 0x5000b, 0xd000b,
	0x10007, 0x90007, 0x1000f, 0x9000f, 0x50007, 0xd0007, 0x5000f, 0xd000f,
	0x30003, 0xb0003, 0x3000b, 0xb000b, 0x70003, 0xf0003, 0x7000b, 0xf000b,
	0x30007, 0xb0007, 0x3000f, 0xb000f, 0x70007, 0xf0007, 0x7000f, 0xf000f,
ulong l1revsep[] = {
 0x00000, 0x00008, 0x80000, 0x80008, 0x00004, 0x0000c, 0x80004, 0x8000c,
 0x40000, 0x40008, 0xc0000, 0xc0008, 0x40004, 0x4000c, 0xc0004, 0xc000c,
 0x00002, 0x0000a, 0x80002, 0x8000a, 0x00006, 0x0000e, 0x80006, 0x8000e,
 0x40002, 0x4000a, 0xc0002, 0xc000a, 0x40006, 0x4000e, 0xc0006, 0xc000e,
 0x20000, 0x20008, 0xa0000, 0xa0008, 0x20004, 0x2000c, 0xa0004, 0xa000c,
 0x60000, 0x60008, 0xe0000, 0xe0008, 0x60004, 0x6000c, 0xe0004, 0xe000c,
 0x20002, 0x2000a, 0xa0002, 0xa000a, 0x20006, 0x2000e, 0xa0006, 0xa000e,
 0x60002, 0x6000a, 0xe0002, 0xe000a, 0x60006, 0x6000e, 0xe0006, 0xe000e,
 0x00001, 0x00009, 0x80001, 0x80009, 0x00005, 0x0000d, 0x80005, 0x8000d,
 0x40001, 0x40009, 0xc0001, 0xc0009, 0x40005, 0x4000d, 0xc0005, 0xc000d,
 0x00003, 0x0000b, 0x80003, 0x8000b, 0x00007, 0x0000f, 0x80007, 0x8000f,
 0x40003, 0x4000b, 0xc0003, 0xc000b, 0x40007, 0x4000f, 0xc0007, 0xc000f,
 0x20001, 0x20009, 0xa0001, 0xa0009, 0x20005, 0x2000d, 0xa0005, 0xa000d,
 0x60001, 0x60009, 0xe0001, 0xe0009, 0x60005, 0x6000d, 0xe0005, 0xe000d,
 0x20003, 0x2000b, 0xa0003, 0xa000b, 0x20007, 0x2000f, 0xa0007, 0xa000f,
 0x60003, 0x6000b, 0xe0003, 0xe000b, 0x60007, 0x6000f, 0xe0007, 0xe000f,
 0x10000, 0x10008, 0x90000, 0x90008, 0x10004, 0x1000c, 0x90004, 0x9000c,
 0x50000, 0x50008, 0xd0000, 0xd0008, 0x50004, 0x5000c, 0xd0004, 0xd000c,
 0x10002, 0x1000a, 0x90002, 0x9000a, 0x10006, 0x1000e, 0x90006, 0x9000e,
 0x50002, 0x5000a, 0xd0002, 0xd000a, 0x50006, 0x5000e, 0xd0006, 0xd000e,
 0x30000, 0x30008, 0xb0000, 0xb0008, 0x30004, 0x3000c, 0xb0004, 0xb000c,
 0x70000, 0x70008, 0xf0000, 0xf0008, 0x70004, 0x7000c, 0xf0004, 0xf000c,
 0x30002, 0x3000a, 0xb0002, 0xb000a, 0x30006, 0x3000e, 0xb0006, 0xb000e,
 0x70002, 0x7000a, 0xf0002, 0xf000a, 0x70006, 0x7000e, 0xf0006, 0xf000e,
 0x10001, 0x10009, 0x90001, 0x90009, 0x10005, 0x1000d, 0x90005, 0x9000d,
 0x50001, 0x50009, 0xd0001, 0xd0009, 0x50005, 0x5000d, 0xd0005, 0xd000d,
 0x10003, 0x1000b, 0x90003, 0x9000b, 0x10007, 0x1000f, 0x90007, 0x9000f,
 0x50003, 0x5000b, 0xd0003, 0xd000b, 0x50007, 0x5000f, 0xd0007, 0xd000f,
 0x30001, 0x30009, 0xb0001, 0xb0009, 0x30005, 0x3000d, 0xb0005, 0xb000d,
 0x70001, 0x70009, 0xf0001, 0xf0009, 0x70005, 0x7000d, 0xf0005, 0xf000d,
 0x30003, 0x3000b, 0xb0003, 0xb000b, 0x30007, 0x3000f, 0xb0007, 0xb000f,
 0x70003, 0x7000b, 0xf0003, 0xf000b, 0x70007, 0x7000f, 0xf0007, 0xf000f,
};

/*


@@ 723,45 723,44 @@ ulong l1revsep[] =
 *	if the bits in uchar x are labeled
 *		76543210
 *	then l1revsep[x] yields a ushort with bits
 *		______04______15______26______37
 *		______37______26______15______04
 *	where _ represents a bit whose value is 0.
 *
 *  This table is used by l2update() in l.s.  l2update is implemented
 *  in assembler for speed.
 *
 */
ulong l2revsep[] =
{
 0x0000000, 0x2000000, 0x0020000, 0x2020000, 0x0000200, 0x2000200, 0x0020200, 0x2020200,
 0x0000002, 0x2000002, 0x0020002, 0x2020002, 0x0000202, 0x2000202, 0x0020202, 0x2020202,
 0x1000000, 0x3000000, 0x1020000, 0x3020000, 0x1000200, 0x3000200, 0x1020200, 0x3020200,
 0x1000002, 0x3000002, 0x1020002, 0x3020002, 0x1000202, 0x3000202, 0x1020202, 0x3020202,
 0x0010000, 0x2010000, 0x0030000, 0x2030000, 0x0010200, 0x2010200, 0x0030200, 0x2030200,
 0x0010002, 0x2010002, 0x0030002, 0x2030002, 0x0010202, 0x2010202, 0x0030202, 0x2030202,
 0x1010000, 0x3010000, 0x1030000, 0x3030000, 0x1010200, 0x3010200, 0x1030200, 0x3030200,
 0x1010002, 0x3010002, 0x1030002, 0x3030002, 0x1010202, 0x3010202, 0x1030202, 0x3030202,
 0x0000100, 0x2000100, 0x0020100, 0x2020100, 0x0000300, 0x2000300, 0x0020300, 0x2020300,
 0x0000102, 0x2000102, 0x0020102, 0x2020102, 0x0000302, 0x2000302, 0x0020302, 0x2020302,
 0x1000100, 0x3000100, 0x1020100, 0x3020100, 0x1000300, 0x3000300, 0x1020300, 0x3020300,
 0x1000102, 0x3000102, 0x1020102, 0x3020102, 0x1000302, 0x3000302, 0x1020302, 0x3020302,
 0x0010100, 0x2010100, 0x0030100, 0x2030100, 0x0010300, 0x2010300, 0x0030300, 0x2030300,
 0x0010102, 0x2010102, 0x0030102, 0x2030102, 0x0010302, 0x2010302, 0x0030302, 0x2030302,
 0x1010100, 0x3010100, 0x1030100, 0x3030100, 0x1010300, 0x3010300, 0x1030300, 0x3030300,
 0x1010102, 0x3010102, 0x1030102, 0x3030102, 0x1010302, 0x3010302, 0x1030302, 0x3030302,
 0x0000001, 0x2000001, 0x0020001, 0x2020001, 0x0000201, 0x2000201, 0x0020201, 0x2020201,
 0x0000003, 0x2000003, 0x0020003, 0x2020003, 0x0000203, 0x2000203, 0x0020203, 0x2020203,
 0x1000001, 0x3000001, 0x1020001, 0x3020001, 0x1000201, 0x3000201, 0x1020201, 0x3020201,
 0x1000003, 0x3000003, 0x1020003, 0x3020003, 0x1000203, 0x3000203, 0x1020203, 0x3020203,
 0x0010001, 0x2010001, 0x0030001, 0x2030001, 0x0010201, 0x2010201, 0x0030201, 0x2030201,
 0x0010003, 0x2010003, 0x0030003, 0x2030003, 0x0010203, 0x2010203, 0x0030203, 0x2030203,
 0x1010001, 0x3010001, 0x1030001, 0x3030001, 0x1010201, 0x3010201, 0x1030201, 0x3030201,
 0x1010003, 0x3010003, 0x1030003, 0x3030003, 0x1010203, 0x3010203, 0x1030203, 0x3030203,
 0x0000101, 0x2000101, 0x0020101, 0x2020101, 0x0000301, 0x2000301, 0x0020301, 0x2020301,
 0x0000103, 0x2000103, 0x0020103, 0x2020103, 0x0000303, 0x2000303, 0x0020303, 0x2020303,
 0x1000101, 0x3000101, 0x1020101, 0x3020101, 0x1000301, 0x3000301, 0x1020301, 0x3020301,
 0x1000103, 0x3000103, 0x1020103, 0x3020103, 0x1000303, 0x3000303, 0x1020303, 0x3020303,
 0x0010101, 0x2010101, 0x0030101, 0x2030101, 0x0010301, 0x2010301, 0x0030301, 0x2030301,
 0x0010103, 0x2010103, 0x0030103, 0x2030103, 0x0010303, 0x2010303, 0x0030303, 0x2030303,
 0x1010101, 0x3010101, 0x1030101, 0x3030101, 0x1010301, 0x3010301, 0x1030301, 0x3030301,
 0x1010103, 0x3010103, 0x1030103, 0x3030103, 0x1010303, 0x3010303, 0x1030303, 0x3030303,
ulong l2revsep[] = {
 0x0000000, 0x0000002, 0x0000200, 0x0000202, 0x0020000, 0x0020002, 0x0020200, 0x0020202,
 0x2000000, 0x2000002, 0x2000200, 0x2000202, 0x2020000, 0x2020002, 0x2020200, 0x2020202,
 0x0000001, 0x0000003, 0x0000201, 0x0000203, 0x0020001, 0x0020003, 0x0020201, 0x0020203,
 0x2000001, 0x2000003, 0x2000201, 0x2000203, 0x2020001, 0x2020003, 0x2020201, 0x2020203,
 0x0000100, 0x0000102, 0x0000300, 0x0000302, 0x0020100, 0x0020102, 0x0020300, 0x0020302,
 0x2000100, 0x2000102, 0x2000300, 0x2000302, 0x2020100, 0x2020102, 0x2020300, 0x2020302,
 0x0000101, 0x0000103, 0x0000301, 0x0000303, 0x0020101, 0x0020103, 0x0020301, 0x0020303,
 0x2000101, 0x2000103, 0x2000301, 0x2000303, 0x2020101, 0x2020103, 0x2020301, 0x2020303,
 0x0010000, 0x0010002, 0x0010200, 0x0010202, 0x0030000, 0x0030002, 0x0030200, 0x0030202,
 0x2010000, 0x2010002, 0x2010200, 0x2010202, 0x2030000, 0x2030002, 0x2030200, 0x2030202,
 0x0010001, 0x0010003, 0x0010201, 0x0010203, 0x0030001, 0x0030003, 0x0030201, 0x0030203,
 0x2010001, 0x2010003, 0x2010201, 0x2010203, 0x2030001, 0x2030003, 0x2030201, 0x2030203,
 0x0010100, 0x0010102, 0x0010300, 0x0010302, 0x0030100, 0x0030102, 0x0030300, 0x0030302,
 0x2010100, 0x2010102, 0x2010300, 0x2010302, 0x2030100, 0x2030102, 0x2030300, 0x2030302,
 0x0010101, 0x0010103, 0x0010301, 0x0010303, 0x0030101, 0x0030103, 0x0030301, 0x0030303,
 0x2010101, 0x2010103, 0x2010301, 0x2010303, 0x2030101, 0x2030103, 0x2030301, 0x2030303,
 0x1000000, 0x1000002, 0x1000200, 0x1000202, 0x1020000, 0x1020002, 0x1020200, 0x1020202,
 0x3000000, 0x3000002, 0x3000200, 0x3000202, 0x3020000, 0x3020002, 0x3020200, 0x3020202,
 0x1000001, 0x1000003, 0x1000201, 0x1000203, 0x1020001, 0x1020003, 0x1020201, 0x1020203,
 0x3000001, 0x3000003, 0x3000201, 0x3000203, 0x3020001, 0x3020003, 0x3020201, 0x3020203,
 0x1000100, 0x1000102, 0x1000300, 0x1000302, 0x1020100, 0x1020102, 0x1020300, 0x1020302,
 0x3000100, 0x3000102, 0x3000300, 0x3000302, 0x3020100, 0x3020102, 0x3020300, 0x3020302,
 0x1000101, 0x1000103, 0x1000301, 0x1000303, 0x1020101, 0x1020103, 0x1020301, 0x1020303,
 0x3000101, 0x3000103, 0x3000301, 0x3000303, 0x3020101, 0x3020103, 0x3020301, 0x3020303,
 0x1010000, 0x1010002, 0x1010200, 0x1010202, 0x1030000, 0x1030002, 0x1030200, 0x1030202,
 0x3010000, 0x3010002, 0x3010200, 0x3010202, 0x3030000, 0x3030002, 0x3030200, 0x3030202,
 0x1010001, 0x1010003, 0x1010201, 0x1010203, 0x1030001, 0x1030003, 0x1030201, 0x1030203,
 0x3010001, 0x3010003, 0x3010201, 0x3010203, 0x3030001, 0x3030003, 0x3030201, 0x3030203,
 0x1010100, 0x1010102, 0x1010300, 0x1010302, 0x1030100, 0x1030102, 0x1030300, 0x1030302,
 0x3010100, 0x3010102, 0x3010300, 0x3010302, 0x3030100, 0x3030102, 0x3030300, 0x3030302,
 0x1010101, 0x1010103, 0x1010301, 0x1010303, 0x1030101, 0x1030103, 0x1030301, 0x1030303,
 0x3010101, 0x3010103, 0x3010301, 0x3010303, 0x3030101, 0x3030103, 0x3030301, 0x3030303,
};

M port/devbit.c => port/devbit.c +124 -42
@@ 763,7 763,7 @@ bitread(Chan *c, void *va, long n, ulong offset)
			q += (src->r.min.x&((sizeof(ulong))*ws-1))/ws;
			memmove(p, q, l);
			if(islittle)
				bitreverse(p, l);
				pixreverse(p, l, src->ldepth);
			if(bit.rid==0 && flipping)
				/* is screen, so must be word aligned */
				for(x=0; x<l; x+=sizeof(ulong),p+=sizeof(ulong))


@@ 968,8 968,8 @@ bitwrite(Chan *c, void *va, long n, ulong offset)
			memmove(curs.clr, p+9, 2*16);
			memmove(curs.set, p+41, 2*16);
			if(islittle){
				bitreverse(curs.clr, 2*16);
				bitreverse(curs.set, 2*16);
				pixreverse(curs.clr, 2*16, 0);
				pixreverse(curs.set, 2*16, 0);
			}
			if(!isoff){
				cursoroff(1);


@@ 1504,7 1504,7 @@ bitwrite(Chan *c, void *va, long n, ulong offset)
				q = oq + (dst->r.min.x&((sizeof(ulong))*ws-1))/ws;
				memmove(q, p, l);
				if(islittle)
					bitreverse(q, l);
					pixreverse(q, l, dst->ldepth);
				if(v==0 && flipping){	/* flip bits */
					/* we know it's all word aligned */
					lp = (ulong*)oq;


@@ 2119,49 2119,131 @@ mousechanged(void *m)
}

/*
 *  reverse the bits in a bitmap (converting between little & big endian)
 *  reverse pixels into little endian order
 */
uchar bitrevtab[] = {
	0x00,	0x80,	0x40,	0xc0,	0x20,	0xa0,	0x60,	0xe0,
	0x10,	0x90,	0x50,	0xd0,	0x30,	0xb0,	0x70,	0xf0,
	0x08,	0x88,	0x48,	0xc8,	0x28,	0xa8,	0x68,	0xe8,
	0x18,	0x98,	0x58,	0xd8,	0x38,	0xb8,	0x78,	0xf8,
	0x04,	0x84,	0x44,	0xc4,	0x24,	0xa4,	0x64,	0xe4,
	0x14,	0x94,	0x54,	0xd4,	0x34,	0xb4,	0x74,	0xf4,
	0x0c,	0x8c,	0x4c,	0xcc,	0x2c,	0xac,	0x6c,	0xec,
	0x1c,	0x9c,	0x5c,	0xdc,	0x3c,	0xbc,	0x7c,	0xfc,
	0x02,	0x82,	0x42,	0xc2,	0x22,	0xa2,	0x62,	0xe2,
	0x12,	0x92,	0x52,	0xd2,	0x32,	0xb2,	0x72,	0xf2,
	0x0a,	0x8a,	0x4a,	0xca,	0x2a,	0xaa,	0x6a,	0xea,
	0x1a,	0x9a,	0x5a,	0xda,	0x3a,	0xba,	0x7a,	0xfa,
	0x06,	0x86,	0x46,	0xc6,	0x26,	0xa6,	0x66,	0xe6,
	0x16,	0x96,	0x56,	0xd6,	0x36,	0xb6,	0x76,	0xf6,
	0x0e,	0x8e,	0x4e,	0xce,	0x2e,	0xae,	0x6e,	0xee,
	0x1e,	0x9e,	0x5e,	0xde,	0x3e,	0xbe,	0x7e,	0xfe,
	0x01,	0x81,	0x41,	0xc1,	0x21,	0xa1,	0x61,	0xe1,
	0x11,	0x91,	0x51,	0xd1,	0x31,	0xb1,	0x71,	0xf1,
	0x09,	0x89,	0x49,	0xc9,	0x29,	0xa9,	0x69,	0xe9,
	0x19,	0x99,	0x59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ce, 0x1e, 0x5e, 0x9e, 0xde,
 0x2e, 0x6e, 0xae, 0xee, 0x3e, 0x7e, 0xbe, 0xfe,
 0x03, 0x43, 0x83, 0xc3, 0x13, 0x53, 0x93, 0xd3,
 0x23, 0x63, 0xa3, 0xe3, 0x33, 0x73, 0xb3, 0xf3,
 0x07, 0x47, 0x87, 0xc7, 0x17, 0x57, 0x97, 0xd7,
 0x27, 0x67, 0xa7, 0xe7, 0x37, 0x77, 0xb7, 0xf7,
 0x0b, 0x4b, 0x8b, 0xcb, 0x1b, 0x5b, 0x9b, 0xdb,
 0x2b, 0x6b, 0xab, 0xeb, 0x3b, 0x7b, 0xbb, 0xfb,
 0x0f, 0x4f, 0x8f, 0xcf, 0x1f, 0x5f, 0x9f, 0xdf,
 0x2f, 0x6f, 0xaf, 0xef, 0x3f, 0x7f, 0xbf, 0xff,
};
uchar revtab2[] = {
 0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70,
 0x80, 0x90, 0xa0, 0xb0, 0xc0, 0xd0, 0xe0, 0xf0,
 0x01, 0x11, 0x21, 0x31, 0x41, 0x51, 0x61, 0x71,
 0x81, 0x91, 0xa1, 0xb1, 0xc1, 0xd1, 0xe1, 0xf1,
 0x02, 0x12, 0x22, 0x32, 0x42, 0x52, 0x62, 0x72,
 0x82, 0x92, 0xa2, 0xb2, 0xc2, 0xd2, 0xe2, 0xf2,
 0x03, 0x13, 0x23, 0x33, 0x43, 0x53, 0x63, 0x73,
 0x83, 0x93, 0xa3, 0xb3, 0xc3, 0xd3, 0xe3, 0xf3,
 0x04, 0x14, 0x24, 0x34, 0x44, 0x54, 0x64, 0x74,
 0x84, 0x94, 0xa4, 0xb4, 0xc4, 0xd4, 0xe4, 0xf4,
 0x05, 0x15, 0x25, 0x35, 0x45, 0x55, 0x65, 0x75,
 0x85, 0x95, 0xa5, 0xb5, 0xc5, 0xd5, 0xe5, 0xf5,
 0x06, 0x16, 0x26, 0x36, 0x46, 0x56, 0x66, 0x76,
 0x86, 0x96, 0xa6, 0xb6, 0xc6, 0xd6, 0xe6, 0xf6,
 0x07, 0x17, 0x27, 0x37, 0x47, 0x57, 0x67, 0x77,
 0x87, 0x97, 0xa7, 0xb7, 0xc7, 0xd7, 0xe7, 0xf7,
 0x08, 0x18, 0x28, 0x38, 0x48, 0x58, 0x68, 0x78,
 0x88, 0x98, 0xa8, 0xb8, 0xc8, 0xd8, 0xe8, 0xf8,
 0x09, 0x19, 0x29, 0x39, 0x49, 0x59, 0x69, 0x79,
 0x89, 0x99, 0xa9, 0xb9, 0xc9, 0xd9, 0xe9, 0xf9,
 0x0a, 0x1a, 0x2a, 0x3a, 0x4a, 0x5a, 0x6a, 0x7a,
 0x8a, 0x9a, 0xaa, 0xba, 0xca, 0xda, 0xea, 0xfa,
 0x0b, 0x1b, 0x2b, 0x3b, 0x4b, 0x5b, 0x6b, 0x7b,
 0x8b, 0x9b, 0xab, 0xbb, 0xcb, 0xdb, 0xeb, 0xfb,
 0x0c, 0x1c, 0x2c, 0x3c, 0x4c, 0x5c, 0x6c, 0x7c,
 0x8c, 0x9c, 0xac, 0xbc, 0xcc, 0xdc, 0xec, 0xfc,
 0x0d, 0x1d, 0x2d, 0x3d, 0x4d, 0x5d, 0x6d, 0x7d,
 0x8d, 0x9d, 0xad, 0xbd, 0xcd, 0xdd, 0xed, 0xfd,
 0x0e, 0x1e, 0x2e, 0x3e, 0x4e, 0x5e, 0x6e, 0x7e,
 0x8e, 0x9e, 0xae, 0xbe, 0xce, 0xde, 0xee, 0xfe,
 0x0f, 0x1f, 0x2f, 0x3f, 0x4f, 0x5f, 0x6f, 0x7f,
 0x8f, 0x9f, 0xaf, 0xbf, 0xcf, 0xdf, 0xef, 0xff,
};

void
bitreverse(uchar *p, int l)
pixreverse(uchar *p, int len, int ldepth)
{
	uchar *e;
	uchar *tab;

	switch(ldepth){
	case 0:
		tab = revtab0;
		break;
	case 1:
		tab = revtab1;
		break;
	case 2:
		tab = revtab2;
		break;
	default:
		return;
	}

	e = p + l;
	for(; p < e; p++)
		*p = bitrevtab[*p];
	for(e = p + len; p < e; p++)
		*p = tab[*p];
}

M port/portfns.h => port/portfns.h +1 -0
@@ 157,6 157,7 @@ void		pgrpcpy(Pgrp*, Pgrp*);
void		pgrpnote(ulong, char*, long, int);
Pgrp*		pgrptab(int);
void		pio(Segment *, ulong, ulong, Page **);
void		pixreverse(uchar*, int, int);
#define		poperror()		u->nerrlab--
int		postnote(Proc*, int, char*, int);
int		pprint(char*, ...);