plan 9 kernel history: overview | file list | diff list

1993/0907/carrera/screen.c (diff list | history)

1993/0906/sys/src/9/carrera/screen.c:43,481993/0907/sys/src/9/carrera/screen.c:43,62 (short | long)
1993/0906    
	uchar	graphics[9]; 
	uchar	attribute[0x15]; 
	uchar	special[12]; 
1993/0907    
	struct { 
		uchar viden; 
		uchar sr6; 
		uchar sr7; 
		uchar ar16; 
		uchar ar17; 
		uchar crt31; 
		uchar crt32; 
		uchar crt33; 
		uchar crt34; 
		uchar crt35; 
		uchar crt36; 
		uchar crt37; 
	} tseng; 
1993/0906    
}; 
 
void	setmode(VGAmode*); 
1993/0906/sys/src/9/carrera/screen.c:86,921993/0907/sys/src/9/carrera/screen.c:100,106
1993/0906    
 
GBitmap	gscreen = 
{ 
	EISAUNCACHED(0xA0000), 
1993/0907    
	EISA(0xA0000), 
1993/0906    
	0, 
	(1024*(1<<3))/32, 
	3, 
1993/0906/sys/src/9/carrera/screen.c:95,1101993/0907/sys/src/9/carrera/screen.c:109,114
1993/0906    
	0 
}; 
 
static GBitmap hwcursor= 
{ 
	0,		/* base filled in by malloc when needed */ 
	0, 
	4, 
	1, 
	{0, 0, 64, 64}, 
	{0, 0, 64, 64} 
}; 
                 
uchar bdata[] = 
{ 
	0xC0, 
1993/0906/sys/src/9/carrera/screen.c:121,1291993/0907/sys/src/9/carrera/screen.c:125,130
1993/0906    
	0 
}; 
 
/* 
 *  a fatter than usual cursor for the safari 
 */ 
Cursor fatarrow = { 
	{ -1, -1 }, 
	{ 
1993/0906/sys/src/9/carrera/screen.c:182,1941993/0907/sys/src/9/carrera/screen.c:183,213
1993/0906    
void 
screeninit(void) 
{ 
1993/0907    
	int i, j; 
	uchar *scr; 
 
1993/0906    
	setmode(&dfltmode); 
 
	memmove(&arrow, &fatarrow, sizeof(fatarrow)); 
 
1993/0907    
	scr = (uchar*)EISA(0xA0000); 
iprint("%lux\n", scr); 
*scr = 0xaa; 
i = *scr; 
iprint("%2.2ux\n", i); 
*scr = 0x55; 
i = *scr; 
iprint("%2.2ux\n", i); 
 
	for(j = 0; j < 768; j++) 
		for(i = 0; i < 1024; i++) 
			*(scr+i+(j*1024)) = i; 
 
1993/0906    
	/* save space; let bitblt do the conversion work */ 
	defont = &defont0;	 
1993/0907    
	defont = &defont0; 
iprint("gbitblt\n");	 
1993/0906    
	gbitblt(&gscreen, Pt(0, 0), &gscreen, gscreen.r, 0); 
1993/0907    
iprint("done\n"); 
1993/0906    
	out.pos.x = MINX; 
	out.pos.y = 0; 
	out.bwid = defont0.info[' '].width; 
1993/0906/sys/src/9/carrera/screen.c:363,3681993/0907/sys/src/9/carrera/screen.c:382,393
1993/0906    
	EISAOUTB(SR, val); 
} 
 
1993/0907    
uchar 
srin(ushort i) { 
        EISAOUTB(SRX, i); 
        return EISAINB(SR); 
} 
 
1993/0906    
void 
grout(int reg, int val) 
{ 
1993/0906/sys/src/9/carrera/screen.c:375,3811993/0907/sys/src/9/carrera/screen.c:400,407
1993/0906    
{ 
	if(reg == 0) 
		EISAOUTB(EMISCW, val); 
	else if (reg == 1) 
1993/0907    
	else 
	if (reg == 1) 
1993/0906    
		EISAOUTB(EFCW, val); 
} 
 
1993/0906/sys/src/9/carrera/screen.c:393,3991993/0907/sys/src/9/carrera/screen.c:419,426
1993/0906    
		junk = EISAINB(0x3DA); 
		USED(junk); 
		EISAOUTB(ARW, reg | 0x20); 
	} else { 
1993/0907    
	} 
	else { 
1993/0906    
		EISAOUTB(ARW, reg | 0x20); 
		EISAOUTB(ARW, val); 
	} 
1993/0906/sys/src/9/carrera/screen.c:414,4191993/0907/sys/src/9/carrera/screen.c:441,452
1993/0906    
	/* turn screen off (to avoid damage) */ 
	srout(1, 0x21); 
 
1993/0907    
	EISAOUTB(0x3bf, 0x03);		/* hercules compatibility reg */ 
	EISAOUTB(0x3d8, 0xa0);		/* display mode control register */ 
	EISAOUTB(0x3cd, 0x00);		/* segment select */ 
 
	srout(0x00, srin(0x00) & 0xFD);	/* synchronous reset*/ 
 
1993/0906    
	for(i = 0; i < sizeof(v->general); i++) 
		genout(i, v->general[i]); 
 
1993/0906/sys/src/9/carrera/screen.c:423,4291993/0907/sys/src/9/carrera/screen.c:456,463
1993/0906    
		else 
			srout(i, v->sequencer[i]); 
 
	crout(Cvre, 0);	/* allow writes to CRT registers 0-7 */ 
1993/0907    
	/* allow writes to CRT registers 0-7 */ 
	crout(Cvre, 0); 
1993/0906    
	for(i = 0; i < sizeof(v->crt); i++) 
		crout(i, v->crt[i]); 
 
1993/0906/sys/src/9/carrera/screen.c:432,4371993/0907/sys/src/9/carrera/screen.c:466,491
1993/0906    
 
	for(i = 0; i < sizeof(v->attribute); i++) 
		arout(i, v->attribute[i]); 
1993/0907    
 
	EISAOUTB(0x3C6, 0xFF);	/* pel mask */ 
	EISAOUTB(0x3C8, 0x00);	/* pel write address */ 
	EISAOUTB(0x3bf, 0x03);	/* hercules compatibility reg */ 
	EISAOUTB(0x3d8, 0xa0);	/* display mode control register */ 
 
	srout(0x06, v->tseng.sr6); 
	srout(0x07, v->tseng.sr7); 
	i = EISAINB(0x3da); /* reset flip-flop. inp stat 1*/ 
	USED(i); 
	arout(0x16, v->tseng.ar16);	/* misc */ 
	arout(0x17, v->tseng.ar17);	/* misc 1*/ 
	crout(0x31, v->tseng.crt31);	/* extended start. */ 
	crout(0x32, v->tseng.crt32);	/* extended start. */ 
	crout(0x33, v->tseng.crt33);	/* extended start. */ 
	crout(0x34, v->tseng.crt34);	/* stub: 46ee + other bits */ 
	crout(0x35, v->tseng.crt35);	/* overflow bits */ 
	crout(0x36, v->tseng.crt36);	/* overflow bits */ 
	crout(0x37, v->tseng.crt37);	/* overflow bits */ 
	EISAOUTB(0x3c3, v->tseng.viden);/* video enable */ 
1993/0906    
 
	/* turn screen on */ 
	srout(1, v->sequencer[1]); 
1993/0907/sys/src/9/carrera/screen.c:180,1851993/0908/sys/src/9/carrera/screen.c:180,189 (short | long)
1993/0906    
	hwcurs = 0; 
} 
 
1993/0908    
void	getvmode(VGAmode *v); 
void	writeregisters(VGAmode *v); 
VGAmode x; 
 
1993/0906    
void 
screeninit(void) 
{ 
1993/0907/sys/src/9/carrera/screen.c:187,1961993/0908/sys/src/9/carrera/screen.c:191,202
1993/0907    
	uchar *scr; 
 
1993/0906    
	setmode(&dfltmode); 
                 
1993/0908    
	getvmode(&x); 
	writeregisters(&x); 
return; 
1993/0906    
	memmove(&arrow, &fatarrow, sizeof(fatarrow)); 
 
1993/0907    
	scr = (uchar*)EISA(0xA0000); 
1993/0908    
	scr = (uchar*)EISA(0xC0000); 
1993/0907    
iprint("%lux\n", scr); 
*scr = 0xaa; 
i = *scr; 
1993/0907/sys/src/9/carrera/screen.c:383,3891993/0908/sys/src/9/carrera/screen.c:389,396
1993/0906    
} 
 
1993/0907    
uchar 
srin(ushort i) { 
1993/0908    
srin(ushort i) 
{ 
1993/0907    
        EISAOUTB(SRX, i); 
        return EISAINB(SR); 
} 
1993/0907/sys/src/9/carrera/screen.c:438,4431993/0908/sys/src/9/carrera/screen.c:445,453
1993/0906    
{ 
	int i; 
 
1993/0908    
	for(i = 0; i < sizeof(v->general); i++) 
		genout(i, v->general[i]); 
 
1993/0906    
	/* turn screen off (to avoid damage) */ 
	srout(1, 0x21); 
 
1993/0907/sys/src/9/carrera/screen.c:447,4551993/0908/sys/src/9/carrera/screen.c:457,462
1993/0907    
 
	srout(0x00, srin(0x00) & 0xFD);	/* synchronous reset*/ 
 
1993/0906    
	for(i = 0; i < sizeof(v->general); i++) 
		genout(i, v->general[i]); 
                 
	for(i = 0; i < sizeof(v->sequencer); i++) 
		if(i == 1) 
			srout(i, v->sequencer[i]|0x20); 
1993/0907/sys/src/9/carrera/screen.c:489,4921993/0908/sys/src/9/carrera/screen.c:496,595
1993/0906    
 
	/* turn screen on */ 
	srout(1, v->sequencer[1]); 
1993/0908    
} 
 
uchar 
grin(ushort i) 
{ 
	EISAOUTB(GRX, i); 
	return EISAINB(GR); 
} 
 
uchar 
arin(ushort i) 
{ 
	uchar junk; 
	junk = EISAINB(0x3DA); 
	USED(junk); 
	EISAOUTB(ARW, i | 0x20); 
	return EISAINB(ARR); 
} 
 
uchar 
crin(ushort i) { 
	EISAOUTB(CRX, i); 
	return EISAINB(CR); 
} 
 
void 
getvmode(VGAmode *v) 
{ 
	int i; 
 
	v->general[0] = EISAINB(EMISCR);	/* misc output */ 
	v->general[1] = EISAINB(EFCR);	/* feature control */ 
	for(i = 0; i < sizeof(v->sequencer); i++) 
		v->sequencer[i] = srin(i); 
	for(i = 0; i < sizeof(v->crt); i++)  
		v->crt[i] = crin(i); 
	for(i = 0; i < sizeof(v->graphics); i++)  
		v->graphics[i] = grin(i); 
	for(i = 0; i < sizeof(v->attribute); i++) 
		v->attribute[i] = arin(i); 
 
	v->tseng.viden = EISAINB(0x3c3); 
	v->tseng.sr6  = srin(6); 
	v->tseng.sr7  = srin(7); 
	v->tseng.ar16 = arin(0x16); 
	v->tseng.ar17 = arin(0x17); 
	v->tseng.crt31= crin(0x31); 
	v->tseng.crt32= crin(0x32); 
	v->tseng.crt33= crin(0x33); 
	v->tseng.crt34= crin(0x34); 
	v->tseng.crt35= crin(0x35); 
	v->tseng.crt36= crin(0x36); 
	v->tseng.crt37= crin(0x37); 
} 
 
void 
writeregisters(VGAmode *v) 
{ 
	int i; 
 
	print("\t/* general */\n\t"); 
	for (i=0; i<sizeof(v->general); i++) 
		print("0x%.2x, ", v->general[i]); 
	print("\n\t/* sequence */\n\t"); 
	for (i=0; i<sizeof(v->sequencer); i++) { 
		if (i>0 && i%8 == 0) 
			print("\n\t"); 
		print("0x%.2x, ", v->sequencer[i]); 
	} 
	print("\n\t/* crt */\n\t"); 
	for (i=0; i<sizeof(v->crt); i++) { 
		if (i>0 && i%8 == 0) 
			print("\n\t"); 
		print("0x%.2x, ", v->crt[i]); 
	} 
	print("\n\t/* graphics */\n\t"); 
	for (i=0; i<sizeof(v->graphics); i++) { 
		if (i>0 && i%8 == 0) 
			print("\n\t"); 
		print("0x%.2x, ", v->graphics[i]); 
	} 
	print("\n\t/* attribute */\n\t"); 
	for (i=0; i<sizeof(v->attribute); i++) { 
		if (i>0 && i%8 == 0) 
			print("\n\t"); 
		print("0x%.2x, ", v->attribute[i]); 
	} 
	print("\n"); 
	print("\t/* special */\n"); 
 
	for (i=0; i<12; i++) { 
		if (i%8 == 0) 
			print("\n\t"); 
		print("0x%.2x, ", ((uchar*)(&v->tseng))[i]); 
	} 
	print("\n"); 
1993/0906    
} 
1993/0908/sys/src/9/carrera/screen.c:190,1951993/0909/sys/src/9/carrera/screen.c:190,199 (short | long)
1993/0907    
	int i, j; 
	uchar *scr; 
 
1993/0909    
	EISAOUTB(0x3c3, 1); 
	delay(1); 
	EISAOUTB(0x46e8, 0x8); 
 
1993/0906    
	setmode(&dfltmode); 
1993/0908    
	getvmode(&x); 
	writeregisters(&x); 
1993/0908/sys/src/9/carrera/screen.c:445,4531993/0909/sys/src/9/carrera/screen.c:449,454
1993/0906    
{ 
	int i; 
 
1993/0908    
	for(i = 0; i < sizeof(v->general); i++) 
		genout(i, v->general[i]); 
                 
1993/0906    
	/* turn screen off (to avoid damage) */ 
	srout(1, 0x21); 
 
1993/0908/sys/src/9/carrera/screen.c:456,4611993/0909/sys/src/9/carrera/screen.c:457,465
1993/0907    
	EISAOUTB(0x3cd, 0x00);		/* segment select */ 
 
	srout(0x00, srin(0x00) & 0xFD);	/* synchronous reset*/ 
1993/0909    
 
	for(i = 0; i < sizeof(v->general); i++) 
		genout(i, v->general[i]); 
1993/0907    
 
1993/0906    
	for(i = 0; i < sizeof(v->sequencer); i++) 
		if(i == 1) 
1993/0909/sys/src/9/carrera/screen.c:190,1991993/0910/sys/src/9/carrera/screen.c:190,212 (short | long)
1993/0907    
	int i, j; 
	uchar *scr; 
 
1993/0909    
	EISAOUTB(0x3c3, 1); 
	delay(1); 
	EISAOUTB(0x46e8, 0x8); 
1993/0910    
EISAOUTB(0x3C3, 1); 
EISAOUTB(0x46e8, 8); 
EISAOUTB(0x3bf, 1); 
i = EISAINB(0x3b8); 
print("=%2.2ux\n", i); 
EISAOUTB(0x3bf, 3); 
i = EISAINB(0x3b8); 
print("=%2.2ux\n", i); 
EISAOUTB(0x3bf, 1); 
i = EISAINB(0x3d8); 
print("=%2.2ux\n", i); 
EISAOUTB(0x3bf, 3); 
i = EISAINB(0x3d8); 
print("=%2.2ux\n", i); 
EISAOUTB(0x3d8, 0xa0); 
1993/0909    
 
1993/0910    
	setmode(&dfltmode); 
1993/0906    
	setmode(&dfltmode); 
1993/0908    
	getvmode(&x); 
	writeregisters(&x); 
1993/0910/sys/src/9/carrera/screen.c:146,1511993/0916/sys/src/9/carrera/screen.c:146,165 (short | long)
1993/0906    
static int h, w; 
extern Cursor arrow; 
 
1993/0916    
#define IOPORT	((uchar*)0xE0010000) 
 
static uchar 
inb(int port) 
{ 
	return IOPORT[port^7]; 
} 
 
static void 
outb(int port, int val) 
{ 
	IOPORT[port^7] = val; 
} 
 
1993/0906    
void 
gborder(GBitmap *l, Rectangle r, int i, Fcode c) 
{ 
1993/0910/sys/src/9/carrera/screen.c:190,2121993/0916/sys/src/9/carrera/screen.c:204,209
1993/0907    
	int i, j; 
	uchar *scr; 
 
1993/0910    
EISAOUTB(0x3C3, 1); 
EISAOUTB(0x46e8, 8); 
EISAOUTB(0x3bf, 1); 
i = EISAINB(0x3b8); 
print("=%2.2ux\n", i); 
EISAOUTB(0x3bf, 3); 
i = EISAINB(0x3b8); 
print("=%2.2ux\n", i); 
EISAOUTB(0x3bf, 1); 
i = EISAINB(0x3d8); 
print("=%2.2ux\n", i); 
EISAOUTB(0x3bf, 3); 
i = EISAINB(0x3d8); 
print("=%2.2ux\n", i); 
EISAOUTB(0x3d8, 0xa0); 
1993/0909    
                 
1993/0910    
	setmode(&dfltmode); 
1993/0906    
	setmode(&dfltmode); 
1993/0908    
	getvmode(&x); 
	writeregisters(&x); 
1993/0916/sys/src/9/carrera/screen.c:42,481993/0918/sys/src/9/carrera/screen.c:42,47 (short | long)
1993/0906    
	uchar	crt[0x19]; 
	uchar	graphics[9]; 
	uchar	attribute[0x15]; 
	uchar	special[12]; 
1993/0907    
	struct { 
		uchar viden; 
		uchar sr6; 
1993/0916/sys/src/9/carrera/screen.c:89,1051993/0918/sys/src/9/carrera/screen.c:88,108
1993/0906    
extern	GSubfont	defont0; 
GSubfont		*defont; 
 
static ulong rep(ulong, int); 
                 
struct{ 
	Point	pos; 
	int	bwid; 
}out; 
                 
Lock	screenlock; 
 
GBitmap	gscreen = 
{ 
1993/0918    
	0, 
	0, 
	(1024*(1<<3))/32, 
	3, 
	{ 0, 0, 1024, 768 }, 
	{ 0, 0, 1024, 768 }, 
	0 
}; 
 
GBitmap	vgascreen = 
{ 
1993/0907    
	EISA(0xA0000), 
1993/0906    
	0, 
	(1024*(1<<3))/32, 
1993/0916/sys/src/9/carrera/screen.c:145,2371993/0918/sys/src/9/carrera/screen.c:148,209
1993/0906    
static Point cursor; 
static int h, w; 
extern Cursor arrow; 
1993/0918    
static ulong colormap[256][3]; 
static Rectangle mbb; 
static Rectangle NULLMBB = {10000, 10000, -10000, -10000}; 
static int isscroll; 
1993/0906    
 
1993/0916    
#define IOPORT	((uchar*)0xE0010000) 
                 
static uchar 
inb(int port) 
{ 
	return IOPORT[port^7]; 
} 
                 
static void 
outb(int port, int val) 
{ 
	IOPORT[port^7] = val; 
} 
                 
1993/0906    
void 
gborder(GBitmap *l, Rectangle r, int i, Fcode c) 
{ 
	if(i < 0){ 
		r = inset(r, i); 
		i = -i; 
	} 
	gbitblt(l, r.min, l, Rect(r.min.x, r.min.y, r.max.x, r.min.y+i), c); 
	gbitblt(l, Pt(r.min.x, r.max.y-i), 
		l, Rect(r.min.x, r.max.y-i, r.max.x, r.max.y), c); 
	gbitblt(l, Pt(r.min.x, r.min.y+i), 
		l, Rect(r.min.x, r.min.y+i, r.min.x+i, r.max.y-i), c); 
	gbitblt(l, Pt(r.max.x-i, r.min.y+i), 
		l, Rect(r.max.x-i, r.min.y+i, r.max.x, r.max.y-i), c); 
} 
                 
void 
screenwin(void) 
{ 
	gtexture(&gscreen, gscreen.r, &bgrnd, S); 
	w = defont0.info[' '].width; 
	h = defont0.height; 
1993/0918    
	defont = &defont0;	 
1993/0906    
 
	window.min = Pt(100, 100); 
	window.max = add(window.min, Pt(10+w*120, 10+h*60)); 
1993/0918    
	window.min = Pt(50, 50); 
	window.max = add(window.min, Pt(10+w*100, 10+h*40)); 
1993/0906    
 
	gbitblt(&gscreen, window.min, &gscreen, window, Zero); 
	window = inset(window, 5); 
	cursor = window.min; 
	window.max.y = window.min.y+((window.max.y-window.min.y)/h)*h; 
                 
	hwcurs = 0; 
1993/0918    
 
	mbb = gscreen.r; 
	screenupdate(); 
1993/0906    
} 
 
1993/0908    
void	getvmode(VGAmode *v); 
void	writeregisters(VGAmode *v); 
VGAmode x; 
1993/0918    
/* 
 *  expand 3 and 6 bits of color to 32 
 */ 
static ulong 
x3to32(uchar x) 
{ 
	ulong y; 
1993/0908    
 
1993/0918    
	x = x&7; 
	x= (x<<3)|x; 
	y = (x<<(32-6))|(x<<(32-12))|(x<<(32-18))|(x<<(32-24))|(x<<(32-30)); 
	return y; 
} 
 
1993/0906    
void 
screeninit(void) 
{ 
1993/0907    
	int i, j; 
	uchar *scr; 
1993/0918    
	int i; 
1993/0907    
 
1993/0906    
	setmode(&dfltmode); 
1993/0908    
	getvmode(&x); 
	writeregisters(&x); 
return; 
1993/0906    
	memmove(&arrow, &fatarrow, sizeof(fatarrow)); 
1993/0918    
	for(i = 0; i < 256; i++) 
		setcolor(i, x3to32(i>>5), x3to32(i>>2), x3to32(i<<1)); 
1993/0906    
 
1993/0908    
	scr = (uchar*)EISA(0xC0000); 
1993/0907    
iprint("%lux\n", scr); 
*scr = 0xaa; 
i = *scr; 
iprint("%2.2ux\n", i); 
*scr = 0x55; 
i = *scr; 
iprint("%2.2ux\n", i); 
1993/0918    
	/* allocate a new soft bitmap area */ 
	gscreen.base = xalloc(1024*1024); 
1993/0907    
 
	for(j = 0; j < 768; j++) 
		for(i = 0; i < 1024; i++) 
			*(scr+i+(j*1024)) = i; 
                 
1993/0906    
	/* save space; let bitblt do the conversion work */ 
1993/0907    
	defont = &defont0; 
iprint("gbitblt\n");	 
1993/0906    
	gbitblt(&gscreen, Pt(0, 0), &gscreen, gscreen.r, 0); 
1993/0907    
iprint("done\n"); 
1993/0906    
	out.pos.x = MINX; 
	out.pos.y = 0; 
	out.bwid = defont0.info[' '].width; 
 
1993/0918    
	memmove(&arrow, &fatarrow, sizeof(fatarrow)); 
 
1993/0906    
	screenwin(); 
} 
 
1993/0916/sys/src/9/carrera/screen.c:247,2541993/0918/sys/src/9/carrera/screen.c:219,253
1993/0906    
	r = Rpt(Pt(window.min.x, window.max.y-o), window.max); 
	gbitblt(&gscreen, r.min, &gscreen, r, Zero); 
	cursor.y -= o; 
1993/0918    
	isscroll = 1; 
1993/0906    
} 
 
1993/0918    
void 
mbbrect(Rectangle r) 
{ 
	if (r.min.x < mbb.min.x) 
		mbb.min.x = r.min.x; 
	if (r.min.y < mbb.min.y) 
		mbb.min.y = r.min.y; 
	if (r.max.x > mbb.max.x) 
		mbb.max.x = r.max.x; 
	if (r.max.y > mbb.max.y) 
		mbb.max.y = r.max.y; 
} 
 
void 
mbbpt(Point p) 
{ 
	if (p.x < mbb.min.x) 
		mbb.min.x = p.x; 
	if (p.y < mbb.min.y) 
		mbb.min.y = p.y; 
	if (p.x >= mbb.max.x) 
		mbb.max.x = p.x+1; 
	if (p.y >= mbb.max.y) 
		mbb.max.y = p.y+1; 
} 
 
1993/0906    
static void 
screenputc(char *buf) 
{ 
1993/0916/sys/src/9/carrera/screen.c:276,2861993/0918/sys/src/9/carrera/screen.c:275,285
1993/0906    
	default: 
		if(cursor.x >= window.max.x-w) 
			screenputc("\n"); 
1993/0918    
 
1993/0906    
		cursor = gsubfstring(&gscreen, cursor, &defont0, buf, S); 
	} 
} 
 
#ifdef USEME 
void 
screenputs(char *s, int n) 
{ 
1993/0916/sys/src/9/carrera/screen.c:288,2941993/0918/sys/src/9/carrera/screen.c:287,293
1993/0906    
	Rune r; 
	char buf[4]; 
 
	if((getstatus() & IEC) == 0) { 
1993/0918    
	if((getstatus() & IE) == 0) { 
1993/0906    
		/* don't deadlock trying to print in interrupt */ 
		if(!canlock(&screenlock)) 
			return;	 
1993/0916/sys/src/9/carrera/screen.c:296,3021993/0918/sys/src/9/carrera/screen.c:295,302
1993/0906    
	else 
		lock(&screenlock); 
 
	while(n > 0){ 
1993/0918    
	mbbpt(cursor); 
	while(n > 0) { 
1993/0906    
		i = chartorune(&r, s); 
		if(i == 0){ 
			s++; 
1993/0916/sys/src/9/carrera/screen.c:309,3601993/0918/sys/src/9/carrera/screen.c:309,346
1993/0906    
		s += i; 
		screenputc(buf); 
	} 
1993/0918    
	if(isscroll) { 
		mbb = window; 
		isscroll = 0; 
	} 
	else 
		mbbpt(Pt(cursor.x, cursor.y+h)); 
 
	screenupdate(); 
1993/0906    
	unlock(&screenlock); 
} 
#endif 
 
/* replicate (from top) value in v (n bits) until it fills a ulong */ 
static ulong 
rep(ulong v, int n) 
{ 
	int o; 
	ulong rv; 
                 
	rv = 0; 
	for(o = 32 - n; o >= 0; o -= n) 
		rv |= (v << o); 
	return rv; 
} 
                 
void 
getcolor(ulong p, ulong *pr, ulong *pg, ulong *pb) 
{ 
	ulong ans; 
                 
	/* 
	 * The gnot says 0 is white (max intensity) 
	 */ 
	if(gscreen.ldepth == 0){ 
		if(p == 0) 
				ans = ~0; 
		else 
				ans = 0; 
	}else{ 
		switch(p){ 
		case 0:		ans = ~0;		break; 
		case 1:		ans = 0xAAAAAAAA;	break; 
		case 2:		ans = 0x55555555;	break; 
		default:	ans = 0;		break; 
		} 
	} 
	*pr = *pg = *pb = ans; 
1993/0918    
	p &= (1<<(1<<gscreen.ldepth))-1; 
	*pr = colormap[p][0]; 
	*pg = colormap[p][1]; 
	*pb = colormap[p][2]; 
1993/0906    
} 
 
int 
setcolor(ulong p, ulong r, ulong g, ulong b) 
{ 
	USED(p, r, g, b); 
	return 0;	/* can't change mono screen colormap */ 
1993/0918    
	p &= (1<<(1<<gscreen.ldepth))-1; 
	colormap[p][0] = r; 
	colormap[p][1] = g; 
	colormap[p][2] = b; 
	EISAOUTB(CMWX, 255-p); 
	EISAOUTB(CM, r>>(32-6)); 
	EISAOUTB(CM, g>>(32-6)); 
	EISAOUTB(CM, b>>(32-6)); 
	return ~0; 
1993/0906    
} 
 
void 
1993/0916/sys/src/9/carrera/screen.c:384,4011993/0918/sys/src/9/carrera/screen.c:370,375
1993/0906    
} 
 
void 
mbbrect(Rectangle r) 
{ 
	USED(r); 
} 
                 
void 
mbbpt(Point p) 
{ 
	USED(p); 
} 
                 
void 
srout(int reg, int val) 
{ 
	EISAOUTB(SRX, reg); 
1993/0916/sys/src/9/carrera/screen.c:490,4951993/0918/sys/src/9/carrera/screen.c:464,470
1993/0907    
 
	EISAOUTB(0x3C6, 0xFF);	/* pel mask */ 
	EISAOUTB(0x3C8, 0x00);	/* pel write address */ 
1993/0918    
 
1993/0907    
	EISAOUTB(0x3bf, 0x03);	/* hercules compatibility reg */ 
	EISAOUTB(0x3d8, 0xa0);	/* display mode control register */ 
 
1993/0916/sys/src/9/carrera/screen.c:512,6091993/0918/sys/src/9/carrera/screen.c:487,551
1993/0906    
	srout(1, v->sequencer[1]); 
1993/0908    
} 
 
uchar 
grin(ushort i) 
{ 
	EISAOUTB(GRX, i); 
	return EISAINB(GR); 
} 
1993/0918    
#define swiz(s)	(s<<24)|((s>>8)&0xff00)|((s<<8)&0xff0000)|(s>>24) 
1993/0908    
 
uchar 
arin(ushort i) 
1993/0918    
void 
twizzle(uchar *f, uchar *t) 
1993/0908    
{ 
	uchar junk; 
	junk = EISAINB(0x3DA); 
	USED(junk); 
	EISAOUTB(ARW, i | 0x20); 
	return EISAINB(ARR); 
} 
1993/0918    
	ulong in1, in2; 
1993/0908    
 
uchar 
crin(ushort i) { 
	EISAOUTB(CRX, i); 
	return EISAINB(CR); 
1993/0918    
	in1 = *(ulong*)f; 
	in2 = *(ulong*)(f+4); 
	*(ulong*)t = swiz(in2); 
	*(ulong*)(t+4) = swiz(in1); 
1993/0908    
} 
 
void 
getvmode(VGAmode *v) 
1993/0918    
screenupdate(void) 
1993/0908    
{ 
	int i; 
1993/0918    
	uchar *sp, *hp, *edisp; 
	int i, y, len, off, page, inc; 
	Rectangle r; 
1993/0908    
 
	v->general[0] = EISAINB(EMISCR);	/* misc output */ 
	v->general[1] = EISAINB(EFCR);	/* feature control */ 
	for(i = 0; i < sizeof(v->sequencer); i++) 
		v->sequencer[i] = srin(i); 
	for(i = 0; i < sizeof(v->crt); i++)  
		v->crt[i] = crin(i); 
	for(i = 0; i < sizeof(v->graphics); i++)  
		v->graphics[i] = grin(i); 
	for(i = 0; i < sizeof(v->attribute); i++) 
		v->attribute[i] = arin(i); 
1993/0918    
	r = mbb; 
	mbb = NULLMBB; 
1993/0908    
 
	v->tseng.viden = EISAINB(0x3c3); 
	v->tseng.sr6  = srin(6); 
	v->tseng.sr7  = srin(7); 
	v->tseng.ar16 = arin(0x16); 
	v->tseng.ar17 = arin(0x17); 
	v->tseng.crt31= crin(0x31); 
	v->tseng.crt32= crin(0x32); 
	v->tseng.crt33= crin(0x33); 
	v->tseng.crt34= crin(0x34); 
	v->tseng.crt35= crin(0x35); 
	v->tseng.crt36= crin(0x36); 
	v->tseng.crt37= crin(0x37); 
} 
1993/0918    
	if(Dy(r) < 0) 
		return; 
1993/0908    
 
void 
writeregisters(VGAmode *v) 
{ 
	int i; 
1993/0918    
	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; 
1993/0908    
 
	print("\t/* general */\n\t"); 
	for (i=0; i<sizeof(v->general); i++) 
		print("0x%.2x, ", v->general[i]); 
	print("\n\t/* sequence */\n\t"); 
	for (i=0; i<sizeof(v->sequencer); i++) { 
		if (i>0 && i%8 == 0) 
			print("\n\t"); 
		print("0x%.2x, ", v->sequencer[i]); 
	} 
	print("\n\t/* crt */\n\t"); 
	for (i=0; i<sizeof(v->crt); i++) { 
		if (i>0 && i%8 == 0) 
			print("\n\t"); 
		print("0x%.2x, ", v->crt[i]); 
	} 
	print("\n\t/* graphics */\n\t"); 
	for (i=0; i<sizeof(v->graphics); i++) { 
		if (i>0 && i%8 == 0) 
			print("\n\t"); 
		print("0x%.2x, ", v->graphics[i]); 
	} 
	print("\n\t/* attribute */\n\t"); 
	for (i=0; i<sizeof(v->attribute); i++) { 
		if (i>0 && i%8 == 0) 
			print("\n\t"); 
		print("0x%.2x, ", v->attribute[i]); 
	} 
	print("\n"); 
	print("\t/* special */\n"); 
1993/0918    
	r.min.x &= ~7; 
	len = r.max.x - r.min.x; 
	len = (len+7)&~7; 
	if(len <= 0) 
		return; 
1993/0908    
 
	for (i=0; i<12; i++) { 
		if (i%8 == 0) 
			print("\n\t"); 
		print("0x%.2x, ", ((uchar*)(&v->tseng))[i]); 
1993/0918    
	inc = gscreen.width*4; 
	off = r.min.y * inc + r.min.x; 
	sp = ((uchar*)gscreen.base) + off; 
 
	page = off>>16; 
	off &= (1<<16)-1; 
	hp = edisp = 0; 
	for(y = r.min.y; y < r.max.y; y++){ 
		if(hp >= edisp){ 
			hp = ((uchar*)vgascreen.base) + off; 
			edisp = ((uchar*)vgascreen.base) + 64*1024; 
			EISAOUTB(0x3cd, (page<<4) | page); 
			off = r.min.x; 
			page++; 
		} 
		for(i = 0; i < len; i += 8) 
			twizzle(sp+i, hp+i); 
		hp += inc; 
		sp += inc; 
1993/0908    
	} 
	print("\n"); 
1993/0906    
} 
1993/0918/sys/src/9/carrera/screen.c:253,2581993/0930/sys/src/9/carrera/screen.c:253,259 (short | long)
1993/0906    
{ 
	int pos; 
 
1993/0930    
	mbbpt(cursor); 
1993/0906    
	switch(buf[0]) { 
	case '\n': 
		if(cursor.y+h >= window.max.y) 
1993/0918/sys/src/9/carrera/screen.c:278,2831993/0930/sys/src/9/carrera/screen.c:279,285
1993/0918    
 
1993/0906    
		cursor = gsubfstring(&gscreen, cursor, &defont0, buf, S); 
	} 
1993/0930    
	mbbpt(Pt(cursor.x, cursor.y+h)); 
1993/0906    
} 
 
void 
1993/0918/sys/src/9/carrera/screen.c:295,3011993/0930/sys/src/9/carrera/screen.c:297,302
1993/0906    
	else 
		lock(&screenlock); 
 
1993/0918    
	mbbpt(cursor); 
	while(n > 0) { 
1993/0906    
		i = chartorune(&r, s); 
		if(i == 0){ 
1993/0918/sys/src/9/carrera/screen.c:313,3201993/0930/sys/src/9/carrera/screen.c:314,319
1993/0918    
		mbb = window; 
		isscroll = 0; 
	} 
	else 
		mbbpt(Pt(cursor.x, cursor.y+h)); 
 
	screenupdate(); 
1993/0906    
	unlock(&screenlock); 
1993/0918/sys/src/9/carrera/screen.c:548,5511993/0930/sys/src/9/carrera/screen.c:547,625
1993/0918    
		hp += inc; 
		sp += inc; 
1993/0908    
	} 
1993/0930    
} 
 
/* 
 * graphics 
 */ 
void 
screenload(Rectangle r, uchar *data, long n) 
{ 
	int y, ws, l, t, lpart, rpart, mx, m, mr; 
	uchar *q; 
 
	if(!rectclip(&r, gscreen.r)) 
		return; 
	lock(&screenlock); 
	ws = 8>>gscreen.ldepth;	/* pixels per byte */ 
	/* set l to number of bytes of data per scan line */ 
	if(r.min.x >= 0) 
		l = (r.max.x+ws-1)/ws - r.min.x/ws; 
	else{		/* make positive before divide */ 
		t = (-r.min.x)+ws-1; 
		t = (t/ws)*ws; 
		l = (t+r.max.x+ws-1)/ws; 
	} 
	if(n != l*Dy(r)){ 
		unlock(&screenlock); 
		error("bad tile size"); 
	} 
	q = gbaddr(&gscreen, r.min); 
	mx = 7>>gscreen.ldepth; 
	lpart = (r.min.x & mx) << gscreen.ldepth; 
	rpart = (r.max.x & mx) << gscreen.ldepth; 
	m = 0xFF >> lpart; 
	mr = 0xFF ^ (0xFF >> rpart); 
	/* may need to do bit insertion on edges */ 
	if(l == 1){	/* all in one byte */ 
		if(rpart) 
			m ^= 0xFF >> rpart; 
		for(y=r.min.y; y<r.max.y; y++){ 
			*q ^= (*data^*q) & m; 
			q += gscreen.width*sizeof(ulong); 
			data++; 
		} 
	}else if(lpart==0 && rpart==0){	/* easy case */ 
		for(y=r.min.y; y<r.max.y; y++){ 
			memmove(q, data, l); 
			q += gscreen.width*sizeof(ulong); 
			data += l; 
		} 
	}else if(rpart==0){ 
		for(y=r.min.y; y<r.max.y; y++){ 
			*q ^= (*data^*q) & m; 
			if(l > 1) 
				memmove(q+1, data+1, l-1); 
			q += gscreen.width*sizeof(ulong); 
			data += l; 
		} 
	}else if(lpart == 0){ 
		for(y=r.min.y; y<r.max.y; y++){ 
			if(l > 1) 
				memmove(q, data, l-1); 
			q[l-1] ^= (data[l-1]^q[l-1]) & mr; 
			q += gscreen.width*sizeof(ulong); 
			data += l; 
		} 
	}else for(y=r.min.y; y<r.max.y; y++){ 
			*q ^= (*data^*q) & m; 
			if(l > 2) 
				memmove(q+1, data+1, l-2); 
			q[l-1] ^= (data[l-1]^q[l-1]) & mr; 
			q += gscreen.width*sizeof(ulong); 
			data += l; 
		} 
	mbbrect(r); 
	screenupdate(); 
	unlock(&screenlock); 
1993/0906    
} 
1993/0930/sys/src/9/carrera/screen.c:270,2761993/1001/sys/src/9/carrera/screen.c:270,276 (short | long)
1993/0906    
		cursor.x += pos*w; 
		break; 
	case '\b': 
		if(cursor.x-w >= 0) 
1993/1001    
		if(cursor.x-w >= window.min.x) 
1993/0906    
			cursor.x -= w; 
		break; 
	default: 
1993/1001/sys/src/9/carrera/screen.c:128,1491993/1003/sys/src/9/carrera/screen.c:128,133 (short | long)
1993/0906    
	0 
}; 
 
Cursor fatarrow = { 
	{ -1, -1 }, 
	{ 
		0xff, 0xff, 0x80, 0x01, 0x80, 0x02, 0x80, 0x0c,  
		0x80, 0x10, 0x80, 0x10, 0x80, 0x08, 0x80, 0x04,  
		0x80, 0x02, 0x80, 0x01, 0x80, 0x02, 0x8c, 0x04,  
		0x92, 0x08, 0x91, 0x10, 0xa0, 0xa0, 0xc0, 0x40,  
	}, 
	{ 
		0x00, 0x00, 0x7f, 0xfe, 0x7f, 0xfc, 0x7f, 0xf0,  
		0x7f, 0xe0, 0x7f, 0xe0, 0x7f, 0xf0, 0x7f, 0xf8,  
		0x7f, 0xfc, 0x7f, 0xfe, 0x7f, 0xfc, 0x73, 0xf8,  
		0x61, 0xf0, 0x60, 0xe0, 0x40, 0x40, 0x00, 0x00,  
	}, 
}; 
                 
static Rectangle window; 
static Point cursor; 
static int h, w; 
1993/1001/sys/src/9/carrera/screen.c:202,2091993/1003/sys/src/9/carrera/screen.c:186,191
1993/0907    
 
1993/0906    
	gbitblt(&gscreen, Pt(0, 0), &gscreen, gscreen.r, 0); 
 
1993/0918    
	memmove(&arrow, &fatarrow, sizeof(fatarrow)); 
                 
1993/0906    
	screenwin(); 
} 
 
1993/1001/sys/src/9/carrera/screen.c:502,5101993/1003/sys/src/9/carrera/screen.c:484,493
1993/0908    
void 
1993/0918    
screenupdate(void) 
1993/0908    
{ 
1993/1003    
	Rectangle r; 
	ulong *s, *h, in1, in2; 
1993/0918    
	uchar *sp, *hp, *edisp; 
	int i, y, len, off, page, inc; 
	Rectangle r; 
1993/0908    
 
1993/0918    
	r = mbb; 
	mbb = NULLMBB; 
1993/1001/sys/src/9/carrera/screen.c:529,5391993/1003/sys/src/9/carrera/screen.c:512,524
1993/0908    
 
1993/0918    
	inc = gscreen.width*4; 
	off = r.min.y * inc + r.min.x; 
1993/1003    
 
1993/0918    
	sp = ((uchar*)gscreen.base) + off; 
 
	page = off>>16; 
	off &= (1<<16)-1; 
	hp = edisp = 0; 
1993/1003    
	hp = 0; 
	edisp = 0; 
1993/0918    
	for(y = r.min.y; y < r.max.y; y++){ 
		if(hp >= edisp){ 
			hp = ((uchar*)vgascreen.base) + off; 
1993/1001/sys/src/9/carrera/screen.c:542,5521993/1003/sys/src/9/carrera/screen.c:527,553
1993/0918    
			off = r.min.x; 
			page++; 
		} 
		for(i = 0; i < len; i += 8) 
			twizzle(sp+i, hp+i); 
1993/1003    
		for(i = 0; i < len; i += 8) { 
			s = (ulong*)(sp+i); 
			h = (ulong*)(hp+i); 
			in1 = s[0]; 
			in2 = s[1]; 
			h[0] = swiz(in2); 
			h[1] = swiz(in1); 
		} 
1993/0918    
		hp += inc; 
		sp += inc; 
1993/0908    
	} 
1993/1003    
} 
 
void 
mousescreenupdate(void) 
{ 
	if(canlock(&screenlock) == 0) 
		return; 
 
	screenupdate(); 
	unlock(&screenlock); 
1993/0930    
} 
 
/* 
1993/1003/sys/src/9/carrera/screen.c:112,1331993/1006/sys/src/9/carrera/screen.c:112,117 (short | long)
1993/0906    
	0 
}; 
 
uchar bdata[] = 
{ 
	0xC0, 
}; 
                 
GBitmap bgrnd = 
{ 
	(ulong*)bdata, 
	0, 
	4, 
	3, 
	{ 0, 0, 1, 1 }, 
	{ 0, 0, 1, 1 }, 
	0 
}; 
                 
static Rectangle window; 
static Point cursor; 
static int h, w; 
1993/1003/sys/src/9/carrera/screen.c:140,1461993/1006/sys/src/9/carrera/screen.c:124,130
1993/0906    
void 
screenwin(void) 
{ 
	gtexture(&gscreen, gscreen.r, &bgrnd, S); 
1993/1006    
	memset(gscreen.base, 0xC0, gscreen.width*sizeof(ulong)*Dy(gscreen.r)); 
1993/0906    
	w = defont0.info[' '].width; 
	h = defont0.height; 
1993/0918    
	defont = &defont0;	 
1993/1006/sys/src/9/carrera/screen.c:559,5641993/1008/sys/src/9/carrera/screen.c:559,565 (short | long)
1993/0930    
		unlock(&screenlock); 
		error("bad tile size"); 
	} 
1993/1008    
	cursoroff(1); 
1993/0930    
	q = gbaddr(&gscreen, r.min); 
	mx = 7>>gscreen.ldepth; 
	lpart = (r.min.x & mx) << gscreen.ldepth; 
1993/1006/sys/src/9/carrera/screen.c:605,6101993/1008/sys/src/9/carrera/screen.c:606,612
1993/0930    
			data += l; 
		} 
	mbbrect(r); 
1993/1008    
	cursoron(1); 
1993/0930    
	screenupdate(); 
	unlock(&screenlock); 
1993/0906    
} 
1993/1008/sys/src/9/carrera/screen.c:534,5651993/1026/sys/src/9/carrera/screen.c:534,557 (short | long)
1993/1003    
	unlock(&screenlock); 
1993/0930    
} 
 
1993/1026    
extern	cursorlock(Rectangle); 
extern	cursorunlock(void); 
1993/0930    
/* 
 * graphics 
1993/1026    
 * paste tile into screen. 
 * tile is at location r, first pixel in *data.  tl is length of scan line to insert, 
 * l is amount to advance data after each scan line. 
1993/0930    
 */ 
void 
screenload(Rectangle r, uchar *data, long n) 
1993/1026    
screenload(Rectangle r, uchar *data, int tl, int l) 
1993/0930    
{ 
	int y, ws, l, t, lpart, rpart, mx, m, mr; 
1993/1026    
	int y, lpart, rpart, mx, m, mr; 
1993/0930    
	uchar *q; 
 
	if(!rectclip(&r, gscreen.r)) 
1993/1026    
	if(!rectclip(&r, gscreen.r) || tl<=0) 
1993/0930    
		return; 
	lock(&screenlock); 
	ws = 8>>gscreen.ldepth;	/* pixels per byte */ 
	/* set l to number of bytes of data per scan line */ 
	if(r.min.x >= 0) 
		l = (r.max.x+ws-1)/ws - r.min.x/ws; 
	else{		/* make positive before divide */ 
		t = (-r.min.x)+ws-1; 
		t = (t/ws)*ws; 
		l = (t+r.max.x+ws-1)/ws; 
	} 
	if(n != l*Dy(r)){ 
		unlock(&screenlock); 
		error("bad tile size"); 
	} 
1993/1008    
	cursoroff(1); 
1993/1026    
	cursorlock(r); 
	screenupdate(); 
1993/0930    
	q = gbaddr(&gscreen, r.min); 
	mx = 7>>gscreen.ldepth; 
	lpart = (r.min.x & mx) << gscreen.ldepth; 
1993/1008/sys/src/9/carrera/screen.c:573,5831993/1026/sys/src/9/carrera/screen.c:565,575
1993/0930    
		for(y=r.min.y; y<r.max.y; y++){ 
			*q ^= (*data^*q) & m; 
			q += gscreen.width*sizeof(ulong); 
			data++; 
1993/1026    
			data += l; 
1993/0930    
		} 
	}else if(lpart==0 && rpart==0){	/* easy case */ 
		for(y=r.min.y; y<r.max.y; y++){ 
			memmove(q, data, l); 
1993/1026    
			memmove(q, data, tl); 
1993/0930    
			q += gscreen.width*sizeof(ulong); 
			data += l; 
		} 
1993/1008/sys/src/9/carrera/screen.c:584,5991993/1026/sys/src/9/carrera/screen.c:576,591
1993/0930    
	}else if(rpart==0){ 
		for(y=r.min.y; y<r.max.y; y++){ 
			*q ^= (*data^*q) & m; 
			if(l > 1) 
				memmove(q+1, data+1, l-1); 
1993/1026    
			if(tl > 1) 
				memmove(q+1, data+1, tl-1); 
1993/0930    
			q += gscreen.width*sizeof(ulong); 
			data += l; 
		} 
	}else if(lpart == 0){ 
		for(y=r.min.y; y<r.max.y; y++){ 
			if(l > 1) 
				memmove(q, data, l-1); 
			q[l-1] ^= (data[l-1]^q[l-1]) & mr; 
1993/1026    
			if(tl > 1) 
				memmove(q, data, tl-1); 
			q[tl-1] ^= (data[tl-1]^q[tl-1]) & mr; 
1993/0930    
			q += gscreen.width*sizeof(ulong); 
			data += l; 
		} 
1993/1008/sys/src/9/carrera/screen.c:600,6121993/1026/sys/src/9/carrera/screen.c:592,605
1993/0930    
	}else for(y=r.min.y; y<r.max.y; y++){ 
			*q ^= (*data^*q) & m; 
			if(l > 2) 
				memmove(q+1, data+1, l-2); 
			q[l-1] ^= (data[l-1]^q[l-1]) & mr; 
1993/1026    
				memmove(q+1, data+1, tl-2); 
			q[tl-1] ^= (data[tl-1]^q[l-1]) & mr; 
1993/0930    
			q += gscreen.width*sizeof(ulong); 
			data += l; 
		} 
	mbbrect(r); 
1993/1008    
	cursoron(1); 
1993/1026    
	screenupdate(); 
	cursorunlock(); 
1993/0930    
	screenupdate(); 
	unlock(&screenlock); 
1993/0906    
} 
1993/1026/sys/src/9/carrera/screen.c:10,171993/1221/sys/src/9/carrera/screen.c:10,15 (short | long)
1993/0906    
#include	<libg.h> 
#include	<gnot.h> 
 
#define	MINX	8 
                 
enum 
{ 
	EMISCR=		0x3CC,		/* control sync polarity */ 
1993/1026/sys/src/9/carrera/screen.c:65,881993/1221/sys/src/9/carrera/screen.c:63,86
1993/0906    
VGAmode dfltmode =  
{ 
	/* general */ 
	0xef, 0x00,  
1993/1221    
	0x23, 0x00,  
1993/0906    
	/* sequence */ 
	0x03, 0x01, 0x0f, 0x00, 0x0e,  
1993/1221    
	0x03, 0x01, 0x0f, 0x00, 0x06,  
1993/0906    
	/* crt */ 
	0xa1, 0x7f, 0x7f, 0x85, 0x85, 0x96, 0x24, 0xf5,  
	0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  
	0x02, 0x88, 0xff, 0x80, 0x60, 0xff, 0x25, 0xab,  
1993/1221    
	0xcb, 0x9f, 0xa0, 0x8e, 0xa9, 0x04, 0x4f, 0x52,  
	0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  
	0x11, 0x89, 0xff, 0x50, 0x00, 0x09, 0x46, 0xc3,  
1993/0906    
	0xff,  
	/* graphics */ 
	0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0f,  
1993/1221    
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f,  
1993/0906    
	0xff,  
	/* attribute */ 
	0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,  
	0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,  
	0x01, 0x00, 0x0f, 0x00, 0x00, 
1993/1221    
	0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07,  
	0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,  
	0x01, 0x00, 0x0f, 0x00, 0x00,  
1993/0906    
	/* special */ 
	0x00, 0x00, 0xbc, 0x00, 0x00, 0x00, 0x28, 0x00,  
	0x0a, 0x00, 0x43, 0x1f,  
1993/1221    
	0x0a, 0x9b, 0x43, 0x1f,  
1993/0906    
}; 
 
extern	GSubfont	defont0; 
1993/1026/sys/src/9/carrera/screen.c:94,1031993/1221/sys/src/9/carrera/screen.c:92,101
1993/0906    
{ 
1993/0918    
	0, 
	0, 
	(1024*(1<<3))/32, 
	3, 
	{ 0, 0, 1024, 768 }, 
	{ 0, 0, 1024, 768 }, 
1993/1221    
	(1280*(1<<0))/32, 
	0, 
	{ 0, 0, 1280, 1024 }, 
	{ 0, 0, 1280, 1024 }, 
1993/0918    
	0 
}; 
 
1993/1026/sys/src/9/carrera/screen.c:105,1141993/1221/sys/src/9/carrera/screen.c:103,112
1993/0918    
{ 
1993/0907    
	EISA(0xA0000), 
1993/0906    
	0, 
	(1024*(1<<3))/32, 
	3, 
	{ 0, 0, 1024, 768 }, 
	{ 0, 0, 1024, 768 }, 
1993/1221    
	(1280*(1<<0))/32, 
	0, 
	{ 0, 0, 1280, 1024 }, 
	{ 0, 0, 1280, 1024 }, 
1993/0906    
	0 
}; 
 
1993/1026/sys/src/9/carrera/screen.c:124,1301993/1221/sys/src/9/carrera/screen.c:122,127
1993/0906    
void 
screenwin(void) 
{ 
1993/1006    
	memset(gscreen.base, 0xC0, gscreen.width*sizeof(ulong)*Dy(gscreen.r)); 
1993/0906    
	w = defont0.info[' '].width; 
	h = defont0.height; 
1993/0918    
	defont = &defont0;	 
1993/1026/sys/src/9/carrera/screen.c:455,4711993/1221/sys/src/9/carrera/screen.c:452,457
1993/0918    
#define swiz(s)	(s<<24)|((s>>8)&0xff00)|((s<<8)&0xff0000)|(s>>24) 
1993/0908    
 
1993/0918    
void 
twizzle(uchar *f, uchar *t) 
1993/0908    
{ 
1993/0918    
	ulong in1, in2; 
1993/0908    
                 
1993/0918    
	in1 = *(ulong*)f; 
	in2 = *(ulong*)(f+4); 
	*(ulong*)t = swiz(in2); 
	*(ulong*)(t+4) = swiz(in1); 
1993/0908    
} 
                 
void 
1993/0918    
screenupdate(void) 
1993/0908    
{ 
1993/1003    
	Rectangle r; 
1993/1026/sys/src/9/carrera/screen.c:561,5671993/1221/sys/src/9/carrera/screen.c:547,553
1993/0930    
	/* may need to do bit insertion on edges */ 
	if(l == 1){	/* all in one byte */ 
		if(rpart) 
			m ^= 0xFF >> rpart; 
1993/1221    
			m &= mr; 
1993/0930    
		for(y=r.min.y; y<r.max.y; y++){ 
			*q ^= (*data^*q) & m; 
			q += gscreen.width*sizeof(ulong); 
1993/1026/sys/src/9/carrera/screen.c:591,5971993/1221/sys/src/9/carrera/screen.c:577,583
1993/0930    
		} 
	}else for(y=r.min.y; y<r.max.y; y++){ 
			*q ^= (*data^*q) & m; 
			if(l > 2) 
1993/1221    
			if(tl > 2) 
1993/1026    
				memmove(q+1, data+1, tl-2); 
			q[tl-1] ^= (data[tl-1]^q[l-1]) & mr; 
1993/0930    
			q += gscreen.width*sizeof(ulong); 
1993/1221/sys/src/9/carrera/screen.c:62,751993/1222/sys/src/9/carrera/screen.c:62,74 (short | long)
1993/0906    
 
VGAmode dfltmode =  
{ 
	/* general */ 
1993/1221    
	0x23, 0x00,  
1993/1222    
	0xef, 0x00,  
1993/0906    
	/* sequence */ 
1993/1221    
	0x03, 0x01, 0x0f, 0x00, 0x06,  
1993/0906    
	/* crt */ 
1993/1221    
	0xcb, 0x9f, 0xa0, 0x8e, 0xa9, 0x04, 0x4f, 0x52,  
	0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  
	0x11, 0x89, 0xff, 0x50, 0x00, 0x09, 0x46, 0xc3,  
1993/1222    
	0xa1, 0x7f, 0x7f, 0x85, 0x85, 0x96, 0x24, 0xf5,  
	0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  
	0x02, 0x88, 0xff, 0x40, 0x00, 0xff, 0x25, 0xc3,  
1993/0906    
	0xff,  
	/* graphics */ 
1993/1221    
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f,  
1993/1221/sys/src/9/carrera/screen.c:80,861993/1222/sys/src/9/carrera/screen.c:79,85
1993/1221    
	0x01, 0x00, 0x0f, 0x00, 0x00,  
1993/0906    
	/* special */ 
	0x00, 0x00, 0xbc, 0x00, 0x00, 0x00, 0x28, 0x00,  
1993/1221    
	0x0a, 0x9b, 0x43, 0x1f,  
1993/1222    
	0x0a, 0x00, 0x43, 0x1f,  
1993/0906    
}; 
 
extern	GSubfont	defont0; 
1993/1221/sys/src/9/carrera/screen.c:92,1011993/1222/sys/src/9/carrera/screen.c:91,100
1993/0906    
{ 
1993/0918    
	0, 
	0, 
1993/1221    
	(1280*(1<<0))/32, 
1993/1222    
	(1024*(1<<0))/32, 
1993/1221    
	0, 
	{ 0, 0, 1280, 1024 }, 
	{ 0, 0, 1280, 1024 }, 
1993/1222    
	{ 0, 0, 1024, 768 }, 
	{ 0, 0, 1024, 768 }, 
1993/0918    
	0 
}; 
 
1993/1221/sys/src/9/carrera/screen.c:103,1121993/1222/sys/src/9/carrera/screen.c:102,111
1993/0918    
{ 
1993/0907    
	EISA(0xA0000), 
1993/0906    
	0, 
1993/1221    
	(1280*(1<<0))/32, 
1993/1222    
	(1024*(1<<0))/32, 
1993/1221    
	0, 
	{ 0, 0, 1280, 1024 }, 
	{ 0, 0, 1280, 1024 }, 
1993/1222    
	{ 0, 0, 1024, 768 }, 
	{ 0, 0, 1024, 768 }, 
1993/0906    
	0 
}; 
 
1993/1221/sys/src/9/carrera/screen.c:122,1271993/1222/sys/src/9/carrera/screen.c:121,132
1993/0906    
void 
screenwin(void) 
{ 
1993/1222    
	int i; 
 
	for(i = 0; i < 768; i += 2) { 
		memset(gscreen.base+(i*gscreen.width), 0xCC, 160); 
		memset(gscreen.base+((i+1)*gscreen.width), 0xCC^0xff, 160); 
	} 
1993/0906    
	w = defont0.info[' '].width; 
	h = defont0.height; 
1993/0918    
	defont = &defont0;	 
1993/1221/sys/src/9/carrera/screen.c:152,1671993/1222/sys/src/9/carrera/screen.c:157,186
1993/0918    
	y = (x<<(32-6))|(x<<(32-12))|(x<<(32-18))|(x<<(32-24))|(x<<(32-30)); 
	return y; 
} 
1993/1222    
static ulong 
x6to32(uchar x) 
{ 
	ulong y; 
1993/0918    
 
1993/1222    
	x = x&0x3f; 
	y = (x<<(32-6))|(x<<(32-12))|(x<<(32-18))|(x<<(32-24))|(x<<(32-30)); 
	return y; 
} 
 
1993/0906    
void 
screeninit(void) 
{ 
1993/0918    
	int i; 
1993/1222    
	int i, x; 
1993/0907    
 
1993/0906    
	setmode(&dfltmode); 
1993/0918    
	for(i = 0; i < 256; i++) 
		setcolor(i, x3to32(i>>5), x3to32(i>>2), x3to32(i<<1)); 
1993/0906    
 
1993/1222    
	gscreen.ldepth = 3; 
	for(i = 0; i < 16; i++){ 
		x = x6to32((i*63)/15); 
		setcolor(i, x, x, x); 
	} 
	gscreen.ldepth = 0; 
 
1993/0918    
	/* allocate a new soft bitmap area */ 
	gscreen.base = xalloc(1024*1024); 
1993/0907    
 
1993/1221/sys/src/9/carrera/screen.c:298,3041993/1222/sys/src/9/carrera/screen.c:317,323
1993/0918    
	colormap[p][0] = r; 
	colormap[p][1] = g; 
	colormap[p][2] = b; 
	EISAOUTB(CMWX, 255-p); 
1993/1222    
	EISAOUTB(CMWX, p); 
1993/0918    
	EISAOUTB(CM, r>>(32-6)); 
	EISAOUTB(CM, g>>(32-6)); 
	EISAOUTB(CM, b>>(32-6)); 
1993/1221/sys/src/9/carrera/screen.c:457,4631993/1222/sys/src/9/carrera/screen.c:476,482
1993/1003    
	Rectangle r; 
	ulong *s, *h, in1, in2; 
1993/0918    
	uchar *sp, *hp, *edisp; 
	int i, y, len, off, page, inc; 
1993/1222    
	int i, y, len, off, page, inc, pixshft; 
1993/0908    
 
1993/0918    
	r = mbb; 
	mbb = NULLMBB; 
1993/1221/sys/src/9/carrera/screen.c:480,4851993/1222/sys/src/9/carrera/screen.c:499,508
1993/0918    
	if(len <= 0) 
		return; 
1993/0908    
 
1993/1222    
	pixshft = 3-gscreen.ldepth; 
	len = (len>>pixshft)+8; 
	r.min.x = (r.min.x>>pixshft) & ~7; 
	 
1993/0918    
	inc = gscreen.width*4; 
	off = r.min.y * inc + r.min.x; 
1993/1003    
 
1993/1221/sys/src/9/carrera/screen.c:489,4961993/1222/sys/src/9/carrera/screen.c:512,519
1993/0918    
	off &= (1<<16)-1; 
1993/1003    
	hp = 0; 
	edisp = 0; 
1993/0918    
	for(y = r.min.y; y < r.max.y; y++){ 
		if(hp >= edisp){ 
1993/1222    
	for(y = r.min.y; y < r.max.y; y++) { 
		if(hp >= edisp) { 
1993/0918    
			hp = ((uchar*)vgascreen.base) + off; 
			edisp = ((uchar*)vgascreen.base) + 64*1024; 
			EISAOUTB(0x3cd, (page<<4) | page); 
1993/1221/sys/src/9/carrera/screen.c:579,5851993/1222/sys/src/9/carrera/screen.c:602,608
1993/0930    
			*q ^= (*data^*q) & m; 
1993/1221    
			if(tl > 2) 
1993/1026    
				memmove(q+1, data+1, tl-2); 
			q[tl-1] ^= (data[tl-1]^q[l-1]) & mr; 
1993/1222    
			q[tl-1] ^= (data[tl-1]^q[tl-1]) & mr; 
1993/0930    
			q += gscreen.width*sizeof(ulong); 
			data += l; 
		} 
1993/1222/sys/src/9/carrera/screen.c:74,811993/1224/sys/src/9/carrera/screen.c:74,81 (short | long)
1993/1221    
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f,  
1993/0906    
	0xff,  
	/* attribute */ 
1993/1221    
	0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07,  
	0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,  
1993/1224    
	0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,  
	0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,  
1993/1221    
	0x01, 0x00, 0x0f, 0x00, 0x00,  
1993/0906    
	/* special */ 
	0x00, 0x00, 0xbc, 0x00, 0x00, 0x00, 0x28, 0x00,  
1993/1222/sys/src/9/carrera/screen.c:443,4491993/1224/sys/src/9/carrera/screen.c:443,449
1993/0906    
	for(i = 0; i < sizeof(v->attribute); i++) 
		arout(i, v->attribute[i]); 
1993/0907    
 
	EISAOUTB(0x3C6, 0xFF);	/* pel mask */ 
1993/1224    
	EISAOUTB(0x3C6, 0x0F);	/* pel mask */ 
1993/0907    
	EISAOUTB(0x3C8, 0x00);	/* pel write address */ 
1993/0918    
 
1993/0907    
	EISAOUTB(0x3bf, 0x03);	/* hercules compatibility reg */ 
1993/1222/sys/src/9/carrera/screen.c:523,5301993/1224/sys/src/9/carrera/screen.c:523,530
1993/1003    
		for(i = 0; i < len; i += 8) { 
			s = (ulong*)(sp+i); 
			h = (ulong*)(hp+i); 
			in1 = s[0]; 
			in2 = s[1]; 
1993/1224    
			in1 = ~s[0]; 
			in2 = ~s[1]; 
1993/1003    
			h[0] = swiz(in2); 
			h[1] = swiz(in1); 
		} 
1993/1224/sys/src/9/carrera/screen.c:82,921993/1228/sys/src/9/carrera/screen.c:82,91 (short | long)
1993/1222    
	0x0a, 0x00, 0x43, 0x1f,  
1993/0906    
}; 
 
1993/1228    
	Lock		screenlock; 
	GSubfont*	defont; 
1993/0906    
extern	GSubfont	defont0; 
GSubfont		*defont; 
 
Lock	screenlock; 
                 
GBitmap	gscreen = 
{ 
1993/0918    
	0, 
1993/1224/sys/src/9/carrera/screen.c:157,1621993/1228/sys/src/9/carrera/screen.c:156,162
1993/0918    
	y = (x<<(32-6))|(x<<(32-12))|(x<<(32-18))|(x<<(32-24))|(x<<(32-30)); 
	return y; 
} 
1993/1228    
 
1993/1222    
static ulong 
x6to32(uchar x) 
{ 
1993/1224/sys/src/9/carrera/screen.c:183,1891993/1228/sys/src/9/carrera/screen.c:183,188
1993/1222    
 
1993/0918    
	/* allocate a new soft bitmap area */ 
	gscreen.base = xalloc(1024*1024); 
1993/0907    
                 
1993/0906    
	gbitblt(&gscreen, Pt(0, 0), &gscreen, gscreen.r, 0); 
 
	screenwin(); 
1993/1224/sys/src/9/carrera/screen.c:547,5531993/1228/sys/src/9/carrera/screen.c:546,553
1993/1026    
extern	cursorunlock(void); 
1993/0930    
/* 
1993/1026    
 * paste tile into screen. 
 * tile is at location r, first pixel in *data.  tl is length of scan line to insert, 
1993/1228    
 * tile is at location r, first pixel in *data.  
 * tl is length of scan line to insert, 
1993/1026    
 * l is amount to advance data after each scan line. 
1993/0930    
 */ 
void 
1993/1228/sys/src/9/carrera/screen.c:172,1851993/1230/sys/src/9/carrera/screen.c:172,185 (short | long)
1993/0906    
{ 
1993/1222    
	int i, x; 
1993/0907    
 
1993/1230    
	gscreen.ldepth = 0; 
 
1993/0906    
	setmode(&dfltmode); 
 
1993/1222    
	gscreen.ldepth = 3; 
	for(i = 0; i < 16; i++){ 
		x = x6to32((i*63)/15); 
		setcolor(i, x, x, x); 
	} 
	gscreen.ldepth = 0; 
 
1993/0918    
	/* allocate a new soft bitmap area */ 
	gscreen.base = xalloc(1024*1024); 
1993/1228/sys/src/9/carrera/screen.c:303,3091993/1230/sys/src/9/carrera/screen.c:303,320
1993/0906    
void 
getcolor(ulong p, ulong *pr, ulong *pg, ulong *pb) 
{ 
1993/0918    
	p &= (1<<(1<<gscreen.ldepth))-1; 
1993/1230    
	ulong x; 
 
	switch(gscreen.ldepth){ 
	default: 
		x = 0xf; 
		break; 
	case 3: 
		x = 0xff; 
		break; 
	} 
	p &= x; 
	p ^= x; 
1993/0918    
	*pr = colormap[p][0]; 
	*pg = colormap[p][1]; 
	*pb = colormap[p][2]; 
1993/1228/sys/src/9/carrera/screen.c:312,3181993/1230/sys/src/9/carrera/screen.c:323,340
1993/0906    
int 
setcolor(ulong p, ulong r, ulong g, ulong b) 
{ 
1993/0918    
	p &= (1<<(1<<gscreen.ldepth))-1; 
1993/1230    
	ulong x; 
 
	switch(gscreen.ldepth){ 
	default: 
		x = 0xf; 
		break; 
	case 3: 
		x = 0xff; 
		break; 
	} 
	p &= x; 
	p ^= x; 
1993/0918    
	colormap[p][0] = r; 
	colormap[p][1] = g; 
	colormap[p][2] = b; 
1993/1228/sys/src/9/carrera/screen.c:442,4481993/1230/sys/src/9/carrera/screen.c:464,477
1993/0906    
	for(i = 0; i < sizeof(v->attribute); i++) 
		arout(i, v->attribute[i]); 
1993/0907    
 
1993/1224    
	EISAOUTB(0x3C6, 0x0F);	/* pel mask */ 
1993/1230    
	switch(gscreen.ldepth){ 
	case 3: 
		EISAOUTB(0x3C6, 0xFF);	/* pel mask */ 
		break; 
	default: 
		EISAOUTB(0x3C6, 0x0F);	/* pel mask */ 
		break; 
	} 
1993/0907    
	EISAOUTB(0x3C8, 0x00);	/* pel write address */ 
1993/0918    
 
1993/0907    
	EISAOUTB(0x3bf, 0x03);	/* hercules compatibility reg */ 
1993/1228/sys/src/9/carrera/screen.c:522,5291993/1230/sys/src/9/carrera/screen.c:551,558
1993/1003    
		for(i = 0; i < len; i += 8) { 
			s = (ulong*)(sp+i); 
			h = (ulong*)(hp+i); 
1993/1224    
			in1 = ~s[0]; 
			in2 = ~s[1]; 
1993/1230    
			in1 = s[0]; 
			in2 = s[1]; 
1993/1003    
			h[0] = swiz(in2); 
			h[1] = swiz(in1); 
		} 
1993/1230/sys/src/9/carrera/screen.c:9,1901994/0210/sys/src/9/carrera/screen.c:9,247 (short | long)
1993/0906    
 
#include	<libg.h> 
#include	<gnot.h> 
1994/0210    
#include	"screen.h" 
1993/0906    
 
enum 
{ 
	EMISCR=		0x3CC,		/* control sync polarity */ 
	EMISCW=		0x3C2, 
	EFCW=		0x3DA,		/* feature control */ 
	EFCR=		0x3CA, 
	GRX=		0x3CE,		/* index to graphics registers */ 
	GR=		0x3CF,		/* graphics registers */ 
	 Grms=		 0x04,		/*  read map select register */ 
	SRX=		0x3C4,		/* index to sequence registers */ 
	SR=		0x3C5,		/* sequence registers */ 
	 Smmask=	 0x02,		/*  map mask */ 
	CRX=		0x3D4,		/* index to crt registers */ 
	CR=		0x3D5,		/* crt registers */ 
	 Cvre=		 0x11,		/*  vertical retrace end */ 
	ARW=		0x3C0,		/* attribute registers (writing) */ 
	ARR=		0x3C1,		/* attribute registers (reading) */ 
	CMRX=		0x3C7,		/* color map read index */ 
	CMWX=		0x3C8,		/* color map write index */ 
	CM=		0x3C9,		/* color map data reg */ 
}; 
1994/0210    
#define	MINX	8 
1993/0906    
 
typedef struct VGAmode	VGAmode; 
struct VGAmode 
1994/0210    
#define DAC	((Dac*)BTDac) 
typedef struct Dac Dac; 
struct Dac 
1993/0906    
{ 
	uchar	general[2]; 
	uchar	sequencer[5]; 
	uchar	crt[0x19]; 
	uchar	graphics[9]; 
	uchar	attribute[0x15]; 
1993/0907    
	struct { 
		uchar viden; 
		uchar sr6; 
		uchar sr7; 
		uchar ar16; 
		uchar ar17; 
		uchar crt31; 
		uchar crt32; 
		uchar crt33; 
		uchar crt34; 
		uchar crt35; 
		uchar crt36; 
		uchar crt37; 
	} tseng; 
1994/0210    
	uchar	pad0[7]; 
	uchar	cr0; 
	uchar	pad1[7]; 
	uchar	cr1; 
	uchar	pad2[7]; 
	uchar	cr2; 
	uchar	pad3[7]; 
	uchar	cr3; 
1993/0906    
}; 
 
void	setmode(VGAmode*); 
1994/0210    
char s1[] = { 0x40, 0x00, 0xC0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; 
1993/0906    
 
extern	struct GBitmap	gscreen; 
                 
VGAmode dfltmode =  
{ 
1993/1222    
	0xef, 0x00,  
1993/0906    
	/* sequence */ 
1993/1221    
	0x03, 0x01, 0x0f, 0x00, 0x06,  
1993/0906    
	/* crt */ 
1993/1222    
	0xa1, 0x7f, 0x7f, 0x85, 0x85, 0x96, 0x24, 0xf5,  
	0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  
	0x02, 0x88, 0xff, 0x40, 0x00, 0xff, 0x25, 0xc3,  
1993/0906    
	0xff,  
	/* graphics */ 
1993/1221    
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f,  
1993/0906    
	0xff,  
	/* attribute */ 
1993/1224    
	0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,  
	0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,  
1993/1221    
	0x01, 0x00, 0x0f, 0x00, 0x00,  
1993/0906    
	/* special */ 
	0x00, 0x00, 0xbc, 0x00, 0x00, 0x00, 0x28, 0x00,  
1993/1222    
	0x0a, 0x00, 0x43, 0x1f,  
1993/0906    
}; 
                 
1993/1228    
	Lock		screenlock; 
	GSubfont*	defont; 
1993/0906    
extern	GSubfont	defont0; 
1994/0210    
static	ulong		rep(ulong, int); 
1993/0906    
 
1994/0210    
struct{ 
	Point	pos; 
	int	bwid; 
}out; 
 
Lock	screenlock; 
 
1993/0906    
GBitmap	gscreen = 
{ 
1994/0210    
	Screenvirt+0x00017924, 
1993/0918    
	0, 
	0, 
1993/1222    
	(1024*(1<<0))/32, 
1993/1221    
	0, 
1993/1222    
	{ 0, 0, 1024, 768 }, 
	{ 0, 0, 1024, 768 }, 
1994/0210    
	512, 
	3, 
	{ 0, 0, 1599, 1239 }, 
	{ 0, 0, 1599, 1239 }, 
1993/0918    
	0 
}; 
 
GBitmap	vgascreen = 
1994/0210    
static GBitmap hwcursor= 
1993/0918    
{ 
1993/0907    
	EISA(0xA0000), 
1994/0210    
	0,		/* base filled in by malloc when needed */ 
1993/0906    
	0, 
1993/1222    
	(1024*(1<<0))/32, 
1994/0210    
	4, 
	1, 
	{0, 0, 64, 64}, 
	{0, 0, 64, 64} 
}; 
 
uchar bdata[] = 
{ 
	0xC0, 
}; 
 
GBitmap bgrnd = 
{ 
	(ulong*)bdata, 
1993/1221    
	0, 
1993/1222    
	{ 0, 0, 1024, 768 }, 
	{ 0, 0, 1024, 768 }, 
1994/0210    
	4, 
	3, 
	{ 0, 0, 1, 1 }, 
	{ 0, 0, 1, 1 }, 
1993/0906    
	0 
}; 
 
1994/0210    
Cursor fatarrow = { 
	{ -1, -1 }, 
	{ 
		0xff, 0xff, 0x80, 0x01, 0x80, 0x02, 0x80, 0x0c,  
		0x80, 0x10, 0x80, 0x10, 0x80, 0x08, 0x80, 0x04,  
		0x80, 0x02, 0x80, 0x01, 0x80, 0x02, 0x8c, 0x04,  
		0x92, 0x08, 0x91, 0x10, 0xa0, 0xa0, 0xc0, 0x40,  
	}, 
	{ 
		0x00, 0x00, 0x7f, 0xfe, 0x7f, 0xfc, 0x7f, 0xf0,  
		0x7f, 0xe0, 0x7f, 0xe0, 0x7f, 0xf0, 0x7f, 0xf8,  
		0x7f, 0xfc, 0x7f, 0xfe, 0x7f, 0xfc, 0x73, 0xf8,  
		0x61, 0xf0, 0x60, 0xe0, 0x40, 0x40, 0x00, 0x00,  
	}, 
}; 
 
1993/0906    
static Rectangle window; 
static Point cursor; 
static int h, w; 
extern Cursor arrow; 
1993/0918    
static ulong colormap[256][3]; 
static Rectangle mbb; 
static Rectangle NULLMBB = {10000, 10000, -10000, -10000}; 
static int isscroll; 
1993/0906    
 
void 
1994/0210    
gborder(GBitmap *l, Rectangle r, int i, Fcode c) 
{ 
	if(i < 0){ 
		r = inset(r, i); 
		i = -i; 
	} 
	gbitblt(l, r.min, l, Rect(r.min.x, r.min.y, r.max.x, r.min.y+i), c); 
	gbitblt(l, Pt(r.min.x, r.max.y-i), 
		l, Rect(r.min.x, r.max.y-i, r.max.x, r.max.y), c); 
	gbitblt(l, Pt(r.min.x, r.min.y+i), 
		l, Rect(r.min.x, r.min.y+i, r.min.x+i, r.max.y-i), c); 
	gbitblt(l, Pt(r.max.x-i, r.min.y+i), 
		l, Rect(r.max.x-i, r.min.y+i, r.max.x, r.max.y-i), c); 
} 
 
void 
1993/0906    
screenwin(void) 
{ 
1993/1222    
	int i; 
1994/0210    
	Dac *d; 
	ulong zbuf[16]; 
1993/1222    
 
	for(i = 0; i < 768; i += 2) { 
		memset(gscreen.base+(i*gscreen.width), 0xCC, 160); 
		memset(gscreen.base+((i+1)*gscreen.width), 0xCC^0xff, 160); 
	} 
1994/0210    
	gtexture(&gscreen, gscreen.r, &bgrnd, S); 
1993/0906    
	w = defont0.info[' '].width; 
	h = defont0.height; 
1993/0918    
	defont = &defont0;	 
1993/0906    
 
1993/0918    
	window.min = Pt(50, 50); 
	window.max = add(window.min, Pt(10+w*100, 10+h*40)); 
1994/0210    
	window.min = Pt(100, 100); 
	window.max = add(window.min, Pt(10+w*120, 10+h*60)); 
1993/0906    
 
	gbitblt(&gscreen, window.min, &gscreen, window, Zero); 
	window = inset(window, 5); 
	cursor = window.min; 
	window.max.y = window.min.y+((window.max.y-window.min.y)/h)*h; 
	hwcurs = 0; 
1993/0918    
 
	mbb = gscreen.r; 
	screenupdate(); 
1994/0210    
	hwcurs = 1; 
	d = DAC; 
	/* cursor color 1: white */ 
	d->cr1 = 0x01; 
	d->cr0 = 0x81; 
	d->cr2 = 0xFF; 
	d->cr2 = 0xFF; 
	d->cr2 = 0xFF; 
	/* cursor color 2: noir */ 
	d->cr1 = 0x01; 
	d->cr0 = 0x82; 
	d->cr2 = 0; 
	d->cr2 = 0; 
	d->cr2 = 0; 
	/* cursor color 3: schwarz */ 
	d->cr1 = 0x01; 
	d->cr0 = 0x83; 
	d->cr2 = 0; 
	d->cr2 = 0; 
	d->cr2 = 0; 
	/* initialize with all-transparent cursor */ 
	memset(zbuf, 0, sizeof zbuf); 
	hwcursset(zbuf, zbuf, 0, 0); 
	/* enable both planes of cursor */ 
	d->cr1 = 0x03; 
	d->cr0 = 0x00; 
	d->cr2 = 0xc0; 
1993/0906    
} 
 
1993/0918    
/* 
 *  expand 3 and 6 bits of color to 32 
 */ 
static ulong 
x3to32(uchar x) 
1994/0210    
void 
dacinit(void) 
1993/0918    
{ 
	ulong y; 
1994/0210    
	Dac *d; 
	int i; 
	ulong r, g, b; 
1993/0908    
 
1993/0918    
	x = x&7; 
	x= (x<<3)|x; 
	y = (x<<(32-6))|(x<<(32-12))|(x<<(32-18))|(x<<(32-24))|(x<<(32-30)); 
	return y; 
} 
1994/0210    
	d = DAC; 
1993/1228    
 
1993/1222    
static ulong 
x6to32(uchar x) 
{ 
	ulong y; 
1994/0210    
	/* Control registers */ 
	d->cr0 = 0x01; 
	d->cr1 = 0x02; 
	for(i = 0; i < sizeof s1; i++) 
		d->cr2 = s1[i]; 
1993/0918    
 
1993/1222    
	x = x&0x3f; 
	y = (x<<(32-6))|(x<<(32-12))|(x<<(32-18))|(x<<(32-24))|(x<<(32-30)); 
	return y; 
1994/0210    
	/* Cursor programming */ 
	d->cr0 = 0x00; 
	d->cr1 = 0x03; 
	d->cr2 = 0xC0; 
	for(i = 0; i < 12; i++) 
		d->cr2 = 0; 
 
	/* Load Cursor Ram */ 
	d->cr0 = 0x00; 
	d->cr1 = 0x04; 
	for(i = 0; i < 0x400; i++) 
		d->cr2 = 0xff; 
 
	for(i = 0; i<256; i++) { 
		r = ~rep((i>>5) & 7, 3); 
		g = ~rep((i>>2) & 7, 3); 
		b = ~rep(i & 3, 2); 
		setcolor(i, r, g, b); 
	} 
	setcolor(85, 0xAAAAAAAA, 0xAAAAAAAA, 0xAAAAAAAA); 
	setcolor(170, 0x55555555, 0x55555555, 0x55555555); 
 
	/* Overlay Palette Ram */ 
	d->cr0 = 0x00; 
	d->cr1 = 0x01; 
	for(i = 0; i < 0x10; i++) { 
		d->cr2 = 0xff; 
		d->cr2 = 0xff; 
		d->cr2 = 0xff; 
	} 
 
	/* Overlay Palette Ram */ 
	d->cr0 = 0x81; 
	d->cr1 = 0x01; 
	for(i = 0; i < 3; i++) { 
		d->cr2 = 0xff; 
		d->cr2 = 0xff; 
		d->cr2 = 0xff; 
	} 
1993/1222    
} 
 
1993/0906    
void 
screeninit(void) 
{ 
1993/1222    
	int i, x; 
1994/0210    
	int i; 
	ulong r, g, b; 
1993/0907    
 
1993/1230    
	gscreen.ldepth = 0; 
1994/0210    
	dacinit(); 
1993/1230    
 
1993/0906    
	setmode(&dfltmode); 
1994/0210    
	memmove(&arrow, &fatarrow, sizeof(fatarrow)); 
1993/0906    
 
1993/1222    
	for(i = 0; i < 16; i++){ 
		x = x6to32((i*63)/15); 
		setcolor(i, x, x, x); 
	} 
                 
1993/0918    
	/* allocate a new soft bitmap area */ 
	gscreen.base = xalloc(1024*1024); 
1994/0210    
	defont = &defont0;	 
1993/0906    
	gbitblt(&gscreen, Pt(0, 0), &gscreen, gscreen.r, 0); 
1994/0210    
	out.pos.x = MINX; 
	out.pos.y = 0; 
	out.bwid = defont0.info[' '].width; 
1993/0906    
 
1994/0210    
	for(i = 0; i<256; i++) { 
		r = ~rep((i>>5) & 7, 3); 
		g = ~rep((i>>2) & 7, 3); 
		b = ~rep(i & 3, 2); 
		setcolor(i, r, g, b); 
	} 
	setcolor(85, 0xAAAAAAAA, 0xAAAAAAAA, 0xAAAAAAAA); 
	setcolor(170, 0x55555555, 0x55555555, 0x55555555); 
 
1993/0906    
	screenwin(); 
} 
 
1993/1230/sys/src/9/carrera/screen.c:200,2401994/0210/sys/src/9/carrera/screen.c:257,269
1993/0906    
	r = Rpt(Pt(window.min.x, window.max.y-o), window.max); 
	gbitblt(&gscreen, r.min, &gscreen, r, Zero); 
	cursor.y -= o; 
1993/0918    
	isscroll = 1; 
1993/0906    
} 
 
1993/0918    
void 
mbbrect(Rectangle r) 
{ 
	if (r.min.x < mbb.min.x) 
		mbb.min.x = r.min.x; 
	if (r.min.y < mbb.min.y) 
		mbb.min.y = r.min.y; 
	if (r.max.x > mbb.max.x) 
		mbb.max.x = r.max.x; 
	if (r.max.y > mbb.max.y) 
		mbb.max.y = r.max.y; 
} 
                 
void 
mbbpt(Point p) 
{ 
	if (p.x < mbb.min.x) 
		mbb.min.x = p.x; 
	if (p.y < mbb.min.y) 
		mbb.min.y = p.y; 
	if (p.x >= mbb.max.x) 
		mbb.max.x = p.x+1; 
	if (p.y >= mbb.max.y) 
		mbb.max.y = p.y+1; 
} 
                 
1993/0906    
static void 
screenputc(char *buf) 
{ 
	int pos; 
 
1993/0930    
	mbbpt(cursor); 
1993/0906    
	switch(buf[0]) { 
	case '\n': 
		if(cursor.y+h >= window.max.y) 
1993/1230/sys/src/9/carrera/screen.c:251,2661994/0210/sys/src/9/carrera/screen.c:280,293
1993/0906    
		cursor.x += pos*w; 
		break; 
	case '\b': 
1993/1001    
		if(cursor.x-w >= window.min.x) 
1994/0210    
		if(cursor.x-w >= 0) 
1993/0906    
			cursor.x -= w; 
		break; 
	default: 
		if(cursor.x >= window.max.x-w) 
			screenputc("\n"); 
1993/0918    
                 
1993/0906    
		cursor = gsubfstring(&gscreen, cursor, &defont0, buf, S); 
	} 
1993/0930    
	mbbpt(Pt(cursor.x, cursor.y+h)); 
1993/0906    
} 
 
void 
1993/1230/sys/src/9/carrera/screen.c:278,2841994/0210/sys/src/9/carrera/screen.c:305,311
1993/0906    
	else 
		lock(&screenlock); 
 
1993/0918    
	while(n > 0) { 
1994/0210    
	while(n > 0){ 
1993/0906    
		i = chartorune(&r, s); 
		if(i == 0){ 
			s++; 
1993/1230/sys/src/9/carrera/screen.c:291,5781994/0210/sys/src/9/carrera/screen.c:318,480
1993/0906    
		s += i; 
		screenputc(buf); 
	} 
1993/0918    
	if(isscroll) { 
		mbb = window; 
		isscroll = 0; 
	} 
                 
	screenupdate(); 
1993/0906    
	unlock(&screenlock); 
} 
 
1994/0210    
uchar revtab0[] = { 
 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, 0xd9, 0x39, 0xb9, 0x79, 0xf9, 
 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, 
 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, 
 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, 
 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, 
 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, 
 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, 
 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, 
 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, 
 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, 
 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, 
 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, 
 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff, 
}; 
 
1993/0906    
void 
getcolor(ulong p, ulong *pr, ulong *pg, ulong *pb) 
{ 
1993/1230    
	ulong x; 
1994/0210    
	Dac *d; 
	uchar r, g, b; 
	extern uchar revtab0[]; 
1993/1230    
 
	switch(gscreen.ldepth){ 
	default: 
		x = 0xf; 
		break; 
	case 3: 
		x = 0xff; 
		break; 
	} 
	p &= x; 
	p ^= x; 
1993/0918    
	*pr = colormap[p][0]; 
	*pg = colormap[p][1]; 
	*pb = colormap[p][2]; 
1994/0210    
	d = DAC; 
 
	d->cr0 = revtab0[p & 0xFF]; 
	d->cr1 = 0; 
	r = d->cr3; 
	g = d->cr3; 
	b = d->cr3; 
	*pr = (r<<24) | (r<<16) | (r<<8) | r; 
	*pg = (g<<24) | (g<<16) | (g<<8) | g; 
	*pb = (b<<24) | (b<<16) | (b<<8) | b; 
1993/0906    
} 
 
int 
setcolor(ulong p, ulong r, ulong g, ulong b) 
{ 
1993/1230    
	ulong x; 
1994/0210    
	Dac *d; 
	extern uchar revtab0[]; 
1993/1230    
 
	switch(gscreen.ldepth){ 
	default: 
		x = 0xf; 
		break; 
	case 3: 
		x = 0xff; 
		break; 
	} 
	p &= x; 
	p ^= x; 
1993/0918    
	colormap[p][0] = r; 
	colormap[p][1] = g; 
	colormap[p][2] = b; 
1993/1222    
	EISAOUTB(CMWX, p); 
1993/0918    
	EISAOUTB(CM, r>>(32-6)); 
	EISAOUTB(CM, g>>(32-6)); 
	EISAOUTB(CM, b>>(32-6)); 
	return ~0; 
1993/0906    
} 
1994/0210    
	d = DAC; 
1993/0906    
 
void 
hwcursset(ulong *s, ulong *c, int ox, int oy) 
{ 
	USED(s, c, ox, oy); 
1994/0210    
	d->cr0 = revtab0[p & 0xFF]; 
	d->cr1 = 0; 
	d->cr3 = r >> 24; 
	d->cr3 = g >> 24; 
	d->cr3 = b >> 24; 
	return 1; 
1993/0906    
} 
 
void 
hwcursmove(int x, int y) 
1994/0210    
/* replicate (from top) value in v (n bits) until it fills a ulong */ 
static ulong 
rep(ulong v, int n) 
1993/0906    
{ 
	USED(x, y); 
} 
1994/0210    
	int o; 
	ulong rv; 
1993/0906    
 
/* only 1 flavor mouse */ 
void 
mousectl(char *x) 
{ 
	USED(x); 
1994/0210    
	rv = 0; 
	for(o = 32 - n; o >= 0; o -= n) 
		rv |= (v << o); 
	return rv; 
1993/0906    
} 
 
/* bits per pixel */ 
int 
screenbits(void) 
{ 
	return 1<<gscreen.ldepth; 
} 
                 
void 
srout(int reg, int val) 
1994/0210    
hwcursset(ulong *s, ulong *c, int offx, int offy) 
1993/0906    
{ 
	EISAOUTB(SRX, reg); 
	EISAOUTB(SR, val); 
} 
1994/0210    
	Dac *d; 
	int x, y; 
	Point org; 
	uchar ylow, yhigh; 
	ulong spix, cpix, dpix; 
1993/0906    
 
1993/0907    
uchar 
1993/0908    
srin(ushort i) 
{ 
1993/0907    
        EISAOUTB(SRX, i); 
        return EISAINB(SR); 
} 
1994/0210    
	hwcursor.base = (ulong *)malloc(1024); 
	if(hwcursor.base == 0) 
		error(Enomem); 
	/* hw cursor is 64x64 with hot point at (32,32) */ 
	org = add(Pt(32,32), Pt(offx,offy));  
	for(x = 0; x < 16; x++) 
		for(y = 0; y < 16; y++) { 
			spix = (s[y]>>(31-(x&0x1F)))&1; 
			cpix = (c[y]>>(31-(x&0x1F)))&1; 
			dpix = (spix<<1) | cpix; 
			gpoint(&hwcursor, add(Pt(x,y), org), dpix, S); 
		} 
1993/0907    
 
1993/0906    
void 
grout(int reg, int val) 
{ 
	EISAOUTB(GRX, reg); 
	EISAOUTB(GR, val); 
1994/0210    
	d = DAC; 
	/* have to set y offscreen before writing cursor bits */ 
	d->cr1 = 0x03; 
	d->cr0 = 0x03; 
	ylow = d->cr2; 
	yhigh = d->cr2; 
	d->cr1 = 0x03; 
	d->cr0 = 0x03; 
	d->cr2 = 0xFF; 
	d->cr2 = 0xFF; 
	/* now set the bits */ 
	d->cr1 = 0x04; 
	d->cr0 = 0x00; 
	for(x = 0; x < 1024; x++) 
		d->cr2 = ((uchar *)hwcursor.base)[x]; 
	/* set y back */ 
	d->cr1 = 0x03; 
	d->cr0 = 0x03; 
	d->cr2 = ylow; 
	d->cr2 = yhigh; 
	free(hwcursor.base); 
1993/0906    
} 
 
void 
genout(int reg, int val) 
1994/0210    
hwcursmove(int x, int y) 
1993/0906    
{ 
	if(reg == 0) 
		EISAOUTB(EMISCW, val); 
1993/0907    
	else 
	if (reg == 1) 
1993/0906    
		EISAOUTB(EFCW, val); 
} 
1994/0210    
	Dac *d; 
1993/0906    
 
void 
arout(int reg, int val) 
{ 
	uchar junk; 
1994/0210    
	d = DAC; 
1993/0906    
 
	junk = EISAINB(0x3DA); 
	USED(junk); 
                 
	if (reg <= 0xf) { 
		EISAOUTB(ARW, reg | 0x0); 
		EISAOUTB(ARW, val); 
		junk = EISAINB(0x3DA); 
		USED(junk); 
		EISAOUTB(ARW, reg | 0x20); 
1993/0907    
	} 
	else { 
1993/0906    
		EISAOUTB(ARW, reg | 0x20); 
		EISAOUTB(ARW, val); 
	} 
1994/0210    
	x += 379;		/* adjusted by experiment */ 
	y += 11;		/* adjusted by experiment */ 
	d->cr1 = 03; 
	d->cr0 = 01; 
	d->cr2 = x&0xFF; 
	d->cr2 = (x>>8)&0xF; 
	d->cr2 = y&0xFF; 
	d->cr2 = (y>>8)&0xF; 
1993/0906    
} 
 
void 
crout(int reg, int val) 
1994/0210    
int 
screenbits(void) 
1993/0906    
{ 
	EISAOUTB(CRX, reg); 
	EISAOUTB(CR, val); 
1994/0210    
	return 1<<gscreen.ldepth; 
1993/0906    
} 
 
void 
setmode(VGAmode *v) 
{ 
	int i; 
                 
	/* turn screen off (to avoid damage) */ 
	srout(1, 0x21); 
                 
1993/0907    
	EISAOUTB(0x3bf, 0x03);		/* hercules compatibility reg */ 
	EISAOUTB(0x3d8, 0xa0);		/* display mode control register */ 
	EISAOUTB(0x3cd, 0x00);		/* segment select */ 
                 
	srout(0x00, srin(0x00) & 0xFD);	/* synchronous reset*/ 
1993/0909    
                 
	for(i = 0; i < sizeof(v->general); i++) 
		genout(i, v->general[i]); 
1993/0907    
                 
1993/0906    
	for(i = 0; i < sizeof(v->sequencer); i++) 
		if(i == 1) 
			srout(i, v->sequencer[i]|0x20); 
		else 
			srout(i, v->sequencer[i]); 
                 
1993/0907    
	/* allow writes to CRT registers 0-7 */ 
	crout(Cvre, 0); 
1993/0906    
	for(i = 0; i < sizeof(v->crt); i++) 
		crout(i, v->crt[i]); 
                 
	for(i = 0; i < sizeof(v->graphics); i++) 
		grout(i, v->graphics[i]); 
                 
	for(i = 0; i < sizeof(v->attribute); i++) 
		arout(i, v->attribute[i]); 
1993/0907    
                 
1993/1230    
	switch(gscreen.ldepth){ 
	case 3: 
		EISAOUTB(0x3C6, 0xFF);	/* pel mask */ 
		break; 
	default: 
		EISAOUTB(0x3C6, 0x0F);	/* pel mask */ 
		break; 
	} 
1993/0907    
	EISAOUTB(0x3C8, 0x00);	/* pel write address */ 
1993/0918    
                 
1993/0907    
	EISAOUTB(0x3bf, 0x03);	/* hercules compatibility reg */ 
	EISAOUTB(0x3d8, 0xa0);	/* display mode control register */ 
                 
	srout(0x06, v->tseng.sr6); 
	srout(0x07, v->tseng.sr7); 
	i = EISAINB(0x3da); /* reset flip-flop. inp stat 1*/ 
	USED(i); 
	arout(0x16, v->tseng.ar16);	/* misc */ 
	arout(0x17, v->tseng.ar17);	/* misc 1*/ 
	crout(0x31, v->tseng.crt31);	/* extended start. */ 
	crout(0x32, v->tseng.crt32);	/* extended start. */ 
	crout(0x33, v->tseng.crt33);	/* extended start. */ 
	crout(0x34, v->tseng.crt34);	/* stub: 46ee + other bits */ 
	crout(0x35, v->tseng.crt35);	/* overflow bits */ 
	crout(0x36, v->tseng.crt36);	/* overflow bits */ 
	crout(0x37, v->tseng.crt37);	/* overflow bits */ 
	EISAOUTB(0x3c3, v->tseng.viden);/* video enable */ 
1993/0906    
                 
	/* turn screen on */ 
	srout(1, v->sequencer[1]); 
1993/0908    
} 
                 
1993/0918    
#define swiz(s)	(s<<24)|((s>>8)&0xff00)|((s<<8)&0xff0000)|(s>>24) 
1993/0908    
                 
1993/0918    
void 
screenupdate(void) 
1993/0908    
{ 
1993/1003    
	Rectangle r; 
	ulong *s, *h, in1, in2; 
1993/0918    
	uchar *sp, *hp, *edisp; 
1993/1222    
	int i, y, len, off, page, inc, pixshft; 
1993/0908    
                 
1993/0918    
	r = mbb; 
	mbb = NULLMBB; 
1993/0908    
                 
1993/0918    
	if(Dy(r) < 0) 
		return; 
1993/0908    
                 
1993/0918    
	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; 
1993/0908    
                 
1993/0918    
	r.min.x &= ~7; 
	len = r.max.x - r.min.x; 
	len = (len+7)&~7; 
	if(len <= 0) 
		return; 
1993/0908    
                 
1993/1222    
	pixshft = 3-gscreen.ldepth; 
	len = (len>>pixshft)+8; 
	r.min.x = (r.min.x>>pixshft) & ~7; 
	                 
1993/0918    
	inc = gscreen.width*4; 
	off = r.min.y * inc + r.min.x; 
1993/1003    
                 
1993/0918    
	sp = ((uchar*)gscreen.base) + off; 
                 
	page = off>>16; 
	off &= (1<<16)-1; 
1993/1003    
	hp = 0; 
	edisp = 0; 
1993/1222    
	for(y = r.min.y; y < r.max.y; y++) { 
		if(hp >= edisp) { 
1993/0918    
			hp = ((uchar*)vgascreen.base) + off; 
			edisp = ((uchar*)vgascreen.base) + 64*1024; 
			EISAOUTB(0x3cd, (page<<4) | page); 
			off = r.min.x; 
			page++; 
		} 
1993/1003    
		for(i = 0; i < len; i += 8) { 
			s = (ulong*)(sp+i); 
			h = (ulong*)(hp+i); 
1993/1230    
			in1 = s[0]; 
			in2 = s[1]; 
1993/1003    
			h[0] = swiz(in2); 
			h[1] = swiz(in1); 
		} 
1993/0918    
		hp += inc; 
		sp += inc; 
1993/0908    
	} 
1993/1003    
} 
                 
void 
mousescreenupdate(void) 
{ 
	if(canlock(&screenlock) == 0) 
		return; 
                 
	screenupdate(); 
	unlock(&screenlock); 
1993/0930    
} 
                 
1993/1026    
extern	cursorlock(Rectangle); 
extern	cursorunlock(void); 
1994/0210    
 
1993/0930    
/* 
1993/1026    
 * paste tile into screen. 
1993/1228    
 * tile is at location r, first pixel in *data.  
1993/1230/sys/src/9/carrera/screen.c:582,5951994/0210/sys/src/9/carrera/screen.c:484,497
1993/0930    
void 
1993/1026    
screenload(Rectangle r, uchar *data, int tl, int l) 
1993/0930    
{ 
1993/1026    
	int y, lpart, rpart, mx, m, mr; 
1993/0930    
	uchar *q; 
1994/0210    
	int y, lpart, rpart, mx, m, mr; 
1993/0930    
 
1993/1026    
	if(!rectclip(&r, gscreen.r) || tl<=0) 
1993/0930    
		return; 
1994/0210    
 
1993/0930    
	lock(&screenlock); 
1993/1026    
	cursorlock(r); 
	screenupdate(); 
1994/0210    
 
1993/0930    
	q = gbaddr(&gscreen, r.min); 
	mx = 7>>gscreen.ldepth; 
	lpart = (r.min.x & mx) << gscreen.ldepth; 
1993/1230/sys/src/9/carrera/screen.c:635,6431994/0210/sys/src/9/carrera/screen.c:537,541
1993/0930    
			q += gscreen.width*sizeof(ulong); 
			data += l; 
		} 
	mbbrect(r); 
1993/1026    
	screenupdate(); 
	cursorunlock(); 
1993/0930    
	screenupdate(); 
	unlock(&screenlock); 
1993/0906    
} 
1994/0210/sys/src/9/carrera/screen.c:27,331994/0211/sys/src/9/carrera/screen.c:27,33 (short | long)
1994/0210    
	uchar	cr3; 
1993/0906    
}; 
 
1994/0210    
char s1[] = { 0x40, 0x00, 0xC0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; 
1994/0211    
char s1[] = { 0x00, 0x00, 0xC0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; 
1993/0906    
 
1993/1228    
	GSubfont*	defont; 
1993/0906    
extern	GSubfont	defont0; 
1994/0211/sys/src/9/carrera/screen.c:42,481994/0213/sys/src/9/carrera/screen.c:42,48 (short | long)
1994/0210    
 
1993/0906    
GBitmap	gscreen = 
{ 
1994/0210    
	Screenvirt+0x00017924, 
1994/0213    
	Screenvirt+0x00017918, 
1993/0918    
	0, 
1994/0210    
	512, 
	3, 
1994/0211/sys/src/9/carrera/screen.c:456,4621994/0213/sys/src/9/carrera/screen.c:456,462
1993/0906    
 
1994/0210    
	d = DAC; 
1993/0906    
 
1994/0210    
	x += 379;		/* adjusted by experiment */ 
1994/0213    
	x += 371;		/* adjusted by experiment */ 
1994/0210    
	y += 11;		/* adjusted by experiment */ 
	d->cr1 = 03; 
	d->cr0 = 01; 
1994/0213/sys/src/9/carrera/screen.c:120,1251994/0215/sys/src/9/carrera/screen.c:120,127 (short | long)
1994/0210    
	Dac *d; 
	ulong zbuf[16]; 
1993/1222    
 
1994/0215    
	memset(Screenvirt, 0, 3*1024*1024); 
 
1994/0210    
	gtexture(&gscreen, gscreen.r, &bgrnd, S); 
1993/0906    
	w = defont0.info[' '].width; 
	h = defont0.height; 
1994/0215/sys/src/9/carrera/screen.c:118,1261994/0216/sys/src/9/carrera/screen.c:118,128 (short | long)
1993/0906    
screenwin(void) 
{ 
1994/0210    
	Dac *d; 
1994/0216    
	Point p; 
	int i, y; 
1994/0210    
	ulong zbuf[16]; 
1993/1222    
 
1994/0215    
	memset(Screenvirt, 0, 3*1024*1024); 
1994/0216    
	memset((void*)Screenvirt, 0xff, 3*1024*1024); 
1994/0215    
 
1994/0210    
	gtexture(&gscreen, gscreen.r, &bgrnd, S); 
1993/0906    
	w = defont0.info[' '].width; 
1994/0215/sys/src/9/carrera/screen.c:127,1361994/0216/sys/src/9/carrera/screen.c:129,147
1993/0906    
	h = defont0.height; 
 
1994/0210    
	window.min = Pt(100, 100); 
	window.max = add(window.min, Pt(10+w*120, 10+h*60)); 
1994/0216    
	window.max = add(window.min, Pt(10+w*80, 10+h*40)); 
1993/0906    
 
1994/0216    
	gbitblt(&gscreen, add(window.min, Pt(5, 5)), &gscreen, window, F); 
1993/0906    
	gbitblt(&gscreen, window.min, &gscreen, window, Zero); 
1994/0216    
	gborder(&gscreen, window, 4, F); 
1993/0906    
	window = inset(window, 5); 
1994/0216    
	for(i = 0; i < h+6; i += 2) { 
		y = window.min.y+i; 
		gsegment(&gscreen, Pt(window.min.x, y), Pt(window.max.x, y), ~0, F); 
	} 
	p = add(window.min, Pt(10, 2)); 
	gsubfstring(&gscreen, p, &defont0, "Brazil Console ", S); 
	window.min.y += h+6; 
1993/0906    
	cursor = window.min; 
	window.max.y = window.min.y+((window.max.y-window.min.y)/h)*h; 
1993/0918    
 
1994/0216/sys/src/9/carrera/screen.c:129,1351994/0227/sys/src/9/carrera/screen.c:129,135 (short | long)
1993/0906    
	h = defont0.height; 
 
1994/0210    
	window.min = Pt(100, 100); 
1994/0216    
	window.max = add(window.min, Pt(10+w*80, 10+h*40)); 
1994/0227    
	window.max = add(window.min, Pt(10+w*120, 10+h*60)); 
1993/0906    
 
1994/0216    
	gbitblt(&gscreen, add(window.min, Pt(5, 5)), &gscreen, window, F); 
1993/0906    
	gbitblt(&gscreen, window.min, &gscreen, window, Zero); 
1994/0227/sys/src/9/carrera/screen.c:42,531994/0228/sys/src/9/carrera/screen.c:42,53 (short | long)
1994/0210    
 
1993/0906    
GBitmap	gscreen = 
{ 
1994/0213    
	Screenvirt+0x00017918, 
1994/0228    
	Screenvirt+0x000178cc, 
1993/0918    
	0, 
1994/0210    
	512, 
	3, 
	{ 0, 0, 1599, 1239 }, 
	{ 0, 0, 1599, 1239 }, 
1994/0228    
	{ 0, 0, 1599, 1240 }, 
	{ 0, 0, 1599, 1240 }, 
1993/0918    
	0 
}; 
 
1994/0227/sys/src/9/carrera/screen.c:469,4751994/0228/sys/src/9/carrera/screen.c:469,475
1993/0906    
 
1994/0210    
	d = DAC; 
1993/0906    
 
1994/0213    
	x += 371;		/* adjusted by experiment */ 
1994/0228    
	x += 295;		/* adjusted by experiment */ 
1994/0210    
	y += 11;		/* adjusted by experiment */ 
	d->cr1 = 03; 
	d->cr0 = 01; 
1994/0228/sys/src/9/carrera/screen.c:42,531994/0306/sys/src/9/carrera/screen.c:42,53 (short | long)
1994/0210    
 
1993/0906    
GBitmap	gscreen = 
{ 
1994/0228    
	Screenvirt+0x000178cc, 
1994/0306    
	Screenvirt+0x00017924, 
1993/0918    
	0, 
1994/0210    
	512, 
	3, 
1994/0228    
	{ 0, 0, 1599, 1240 }, 
	{ 0, 0, 1599, 1240 }, 
1994/0306    
	{ 0, 0, 1599, 1239 }, 
	{ 0, 0, 1599, 1239 }, 
1993/0918    
	0 
}; 
 
1994/0228/sys/src/9/carrera/screen.c:469,4751994/0306/sys/src/9/carrera/screen.c:469,475
1993/0906    
 
1994/0210    
	d = DAC; 
1993/0906    
 
1994/0228    
	x += 295;		/* adjusted by experiment */ 
1994/0306    
	x += 380;		/* adjusted by experiment */ 
1994/0210    
	y += 11;		/* adjusted by experiment */ 
	d->cr1 = 03; 
	d->cr0 = 01; 
Too many diffs (26 > 25). Stopping.


source code copyright © 1990-2005 Lucent Technologies; see license
Plan 9 distribution
comments to russ cox (rsc@swtch.com)