~kris/9p

9hist

54e4676a0be40e4fdc56bd4427695ae3935113af — David du Colombier 33 years ago e5cde67
Plan 9 from Bell Labs 1992-11-08
3 files changed, 145 insertions(+), 48 deletions(-)

M pc/l.s
M pc/vga.c
M port/devbit.c
M pc/l.s => pc/l.s +39 -2
@@ 635,7 635,9 @@ TEXT	config(SB),$0
	RET

/*
 *  copy bytes to screen memory for ldepth 0 screen
 *  copy bitmap changes to screen memory for ldepth 0 screen
 *  reverse the bits since the screen is big-endian
 *  and the bitmaps are little.
 */
TEXT	l0update(SB),$0
	XORL	AX,AX


@@ 644,7 646,42 @@ TEXT	l0update(SB),$0
	MOVL	to+4(FP),DX
l00:
	MOVB	-1(BX)(CX*1),AL
	MOVB	cswizzle(SB)(AX*1),AL
	MOVB	bitrevtab(SB)(AX*1),AL
	MOVB	AL,-1(DX)(CX*1)
	LOOP	l00
	RET

#define SRX	0x3C4		/* index to sequence registers */
#define	SR	0x3C5		/* sequence registers */
#define Smmask	0x02		/*  map mask */

/*
 *  same as l0update but for ldepth 1 (2 bit plane) screens
 */
TEXT	l1update(SB),$0
	MOVL	from+0(FP),SI
	MOVL	to+4(FP),DI
	MOVL	len+8(FP),CX
l10:
	XORL	DX,DX
	MOVB	-2(SI)(CX*2),DL		/* high order nibbles */
	MOVW	l1revsep(SB)(DX*2),BX
	SHLW	$4,BX
	MOVB	-1(SI)(CX*2),DL		/* low order nibbles */
	ORW	l1revsep(SB)(DX*2),BX
	MOVB	$(Smmask),AL		/* write hi order bits to bit planes 0 & 2 */
	MOVW	$(SRX),DX
	OUTB
	MOVB	$0xA,AL
	MOVW	$(SR),DX
	OUTB
	MOVB	BH,-1(DI)(CX*1)
	MOVB	$(Smmask),AL		/* write lo order bits to bit planes 1 & 3 */
	MOVW	$(SRX),DX
	OUTB
	MOVB	$0x5,AL
	MOVW	$(SR),DX
	OUTB
	MOVB	BL,-1(DI)(CX*1)
	LOOP	l10
	RET

M pc/vga.c => pc/vga.c +103 -43
@@ 327,6 327,59 @@ mbbpt(Point p)
		mbb.max.y = p.y+1;
}

/*
 *  copy litte endian soft screen to big endian hard screen
 */
void
screenupdate(void)
{
	uchar *sp, *hp;
	int y, len, incs, inch;
	Rectangle r;

	r = mbb;
	mbb = NULLMBB;

	if(Dy(r) < 0)
		return;

	if(r.min.x < 0)
		r.min.x = 0;
	if(r.min.y < 0)
		r.min.y = 0;
	if(r.max.x > gscreen.r.max.x)
		r.max.x = gscreen.r.max.x;
	if(r.max.y > gscreen.r.max.y)
		r.max.y = gscreen.r.max.y;

	sp = (uchar*)gaddr(&gscreen, r.min);
	hp = (uchar*)gaddr(&vgascreen, r.min);
	len = (r.max.x + 31)/32 - r.min.x/32;
	len *= BY2WD;
	if(len <= 0)
		return;

	incs = gscreen.width * BY2WD;
	inch = vgascreen.width * BY2WD;

	switch(gscreen.ldepth){
	case 0:
		for (y = r.min.y; y < r.max.y; y++){
			l0update(sp, hp, len);
			sp += incs;
			hp += inch;
		}
		break;
	case 1:
		for (y = r.min.y; y < r.max.y; y++){
			l1update(sp, hp, len);
			sp += incs;
			hp += inch;
		}
		break;
	}
}

void
screenputnl(void)
{


@@ 394,49 447,6 @@ screenbits(void)
}


/*
 *  copy litte endian soft screen to big endian hard screen
 */
void
screenupdate(void)
{
	uchar *sp, *hp, *se;
	int y, len, inc;
	Rectangle r;

	r = mbb;
	mbb = NULLMBB;

	if(Dy(r) < 0)
		return;

	if(r.min.x < 0)
		r.min.x = 0;
	if(r.min.y < 0)
		r.min.y = 0;
	if(r.max.x > gscreen.r.max.x)
		r.max.x = gscreen.r.max.x;
	if(r.max.y > gscreen.r.max.y)
		r.max.y = gscreen.r.max.y;

	sp = (uchar*)gaddr(&gscreen, r.min);
	hp = (uchar*)gaddr(&vgascreen, r.min);

	len = (r.max.x * (1<<gscreen.ldepth) + 31)/32
		- (r.min.x * (1<<gscreen.ldepth))/32;
	len *= BY2WD;
	if(len <= 0)
		return;

	inc = gscreen.width * BY2WD - len;

	for (y = r.min.y; y < r.max.y; y++){
		l0update(sp, hp, len);
		sp += inc+len;
		hp += inc+len;
	}
}

void
mousescreenupdate(void)
{


@@ 512,3 522,53 @@ bigcursor(void)
	bitreverse(arrow.set, 2*16);
	bitreverse(arrow.clr, 2*16);
}

/*
 *  Table for separating and reversing bits in a ldepth 1 bitmap.
 *  This aids in coverting a little endian ldepth 1 bitmap into the
 *  2 big-endian ldepth 0 bitmaps used for the VGA bit planes.
 *
 *	if the bits in uchar x are labeled
 *		76543210
 *	then l1revsep[x] yields a ushort with bits
 *		____0246____1357
 *	where _ represents a bit whose value is 0.
 *
 *  This table is used by l1update() in l.s.  l1update is implemented
 *  in assembler for speed (yech).
 *
 */
ushort l1revsep[] = {
	0x0000,	0x0800,	0x0008,	0x0808,	0x0400,	0x0c00,	0x0408,	0x0c08,
	0x0004,	0x0804,	0x000c,	0x080c,	0x0404,	0x0c04,	0x040c,	0x0c0c,
	0x0200,	0x0a00,	0x0208,	0x0a08,	0x0600,	0x0e00,	0x0608,	0x0e08,
	0x0204,	0x0a04,	0x020c,	0x0a0c,	0x0604,	0x0e04,	0x060c,	0x0e0c,
	0x0002,	0x0802,	0x000a,	0x080a,	0x0402,	0x0c02,	0x040a,	0x0c0a,
	0x0006,	0x0806,	0x000e,	0x080e,	0x0406,	0x0c06,	0x040e,	0x0c0e,
	0x0202,	0x0a02,	0x020a,	0x0a0a,	0x0602,	0x0e02,	0x060a,	0x0e0a,
	0x0206,	0x0a06,	0x020e,	0x0a0e,	0x0606,	0x0e06,	0x060e,	0x0e0e,
	0x0100,	0x0900,	0x0108,	0x0908,	0x0500,	0x0d00,	0x0508,	0x0d08,
	0x0104,	0x0904,	0x010c,	0x090c,	0x0504,	0x0d04,	0x050c,	0x0d0c,
	0x0300,	0x0b00,	0x0308,	0x0b08,	0x0700,	0x0f00,	0x0708,	0x0f08,
	0x0304,	0x0b04,	0x030c,	0x0b0c,	0x0704,	0x0f04,	0x070c,	0x0f0c,
	0x0102,	0x0902,	0x010a,	0x090a,	0x0502,	0x0d02,	0x050a,	0x0d0a,
	0x0106,	0x0906,	0x010e,	0x090e,	0x0506,	0x0d06,	0x050e,	0x0d0e,
	0x0302,	0x0b02,	0x030a,	0x0b0a,	0x0702,	0x0f02,	0x070a,	0x0f0a,
	0x0306,	0x0b06,	0x030e,	0x0b0e,	0x0706,	0x0f06,	0x070e,	0x0f0e,
	0x0001,	0x0801,	0x0009,	0x0809,	0x0401,	0x0c01,	0x0409,	0x0c09,
	0x0005,	0x0805,	0x000d,	0x080d,	0x0405,	0x0c05,	0x040d,	0x0c0d,
	0x0201,	0x0a01,	0x0209,	0x0a09,	0x0601,	0x0e01,	0x0609,	0x0e09,
	0x0205,	0x0a05,	0x020d,	0x0a0d,	0x0605,	0x0e05,	0x060d,	0x0e0d,
	0x0003,	0x0803,	0x000b,	0x080b,	0x0403,	0x0c03,	0x040b,	0x0c0b,
	0x0007,	0x0807,	0x000f,	0x080f,	0x0407,	0x0c07,	0x040f,	0x0c0f,
	0x0203,	0x0a03,	0x020b,	0x0a0b,	0x0603,	0x0e03,	0x060b,	0x0e0b,
	0x0207,	0x0a07,	0x020f,	0x0a0f,	0x0607,	0x0e07,	0x060f,	0x0e0f,
	0x0101,	0x0901,	0x0109,	0x0909,	0x0501,	0x0d01,	0x0509,	0x0d09,
	0x0105,	0x0905,	0x010d,	0x090d,	0x0505,	0x0d05,	0x050d,	0x0d0d,
	0x0301,	0x0b01,	0x0309,	0x0b09,	0x0701,	0x0f01,	0x0709,	0x0f09,
	0x0305,	0x0b05,	0x030d,	0x0b0d,	0x0705,	0x0f05,	0x070d,	0x0f0d,
	0x0103,	0x0903,	0x010b,	0x090b,	0x0503,	0x0d03,	0x050b,	0x0d0b,
	0x0107,	0x0907,	0x010f,	0x090f,	0x0507,	0x0d07,	0x050f,	0x0d0f,
	0x0303,	0x0b03,	0x030b,	0x0b0b,	0x0703,	0x0f03,	0x070b,	0x0f0b,
	0x0307,	0x0b07,	0x030f,	0x0b0f,	0x0707,	0x0f07,	0x070f,	0x0f0f,
};

M port/devbit.c => port/devbit.c +3 -3
@@ 2104,9 2104,9 @@ mousechanged(void *m)
}

/*
 *  swizzle a bitmap
 *  reverse the bits in a bitmap (converting between little & big endian)
 */
uchar cswizzle[] = {
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,


@@ 2148,5 2148,5 @@ bitreverse(uchar *p, int l)

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