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

1992/1111/pc/vga.c (diff list | history)

1992/1111/sys/src/9/pc/vga.c:12,201992/1112/sys/src/9/pc/vga.c:12,17 (short | long | prev | next)
1991/0730    
 
#define	MINX	8 
 
1992/0208    
extern	GSubfont	defont0; 
GSubfont		*defont; 
1991/0730    
                 
struct{ 
	Point	pos; 
	int	bwid; 
1992/1111/sys/src/9/pc/vga.c:22,311992/1112/sys/src/9/pc/vga.c:19,30
1991/0730    
 
1992/1106    
int islittle = 1;		/* little endian bit ordering in bytes */ 
 
extern Cursor arrow; 
extern uchar cswizzle[256]; 
1992/1112    
extern	GSubfont defont0; 
GSubfont *defont; 
extern	Cursor arrow; 
extern	GBitmap cursorback; 
static	Lock colorlock;		/* color map lock */ 
1992/1106    
 
                 
1991/0730    
/* 
 *  screen dimensions 
 */ 
1992/1111/sys/src/9/pc/vga.c:67,731992/1112/sys/src/9/pc/vga.c:66,72
1992/0414    
	0xff, 
	/* attribute */ 
1992/0418    
	0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 
1992/0423    
	0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x3f, 
1992/1112    
	0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 
1992/1015    
	0x01, 0x10, 0x0f, 0x00, 0x00, 
1992/0414    
}; 
1992/0418    
 
1992/1111/sys/src/9/pc/vga.c:238,2441992/1112/sys/src/9/pc/vga.c:237,242
1992/1106    
	/* 
1992/1109    
	 *  zero hard screen and setup a bitmap for the new size 
1992/1106    
	 */ 
	memset((void*)SCREENMEM, 0xff, 64*1024); 
1992/1109    
	if(ldepth == 3) 
		vgascreen.ldepth = 3; 
	else 
1992/1111/sys/src/9/pc/vga.c:245,2521992/1112/sys/src/9/pc/vga.c:243,251
1992/1109    
		vgascreen.ldepth = 0; 
1992/1106    
	vgascreen.base = (void*)SCREENMEM; 
1992/1110    
	vgascreen.width = (maxx*(1<<vgascreen.ldepth))/32; 
1992/1112    
	vgascreen.r.min = Pt(0, 0); 
1992/1106    
	vgascreen.r.max = Pt(maxx, maxy); 
	vgascreen.clipr.max = vgascreen.r.max; 
1992/1112    
	vgascreen.clipr = vgascreen.r; 
1992/1106    
 
	/* 
1992/1109    
	 *  setup new soft screen, free memory for old screen 
1992/1111/sys/src/9/pc/vga.c:253,2761992/1112/sys/src/9/pc/vga.c:252,280
1992/1106    
	 */ 
	gscreen.ldepth = ldepth; 
	gscreen.width = (maxx*(1<<ldepth))/32; 
1992/1112    
	gscreen.r.min = Pt(0, 0); 
1992/0603    
	gscreen.r.max = Pt(maxx, maxy); 
1992/0604    
	gscreen.clipr.max = gscreen.r.max; 
1992/1112    
	gscreen.clipr = gscreen.r; 
1992/1110    
	len = gscreen.width * BY2WD * maxy; 
1992/1109    
	if(gscreen.base){ 
		free(gscreen.base); 
1992/1111    
		p = smalloc(len+2*1024)); 
		gscreen.base = ((ulong*)p) + 256; 
	} else { 
		p = malloc(len+2*1024)); 
		gscreen.base = ((ulong*)p) + 256; 
	} 
1992/1112    
		p = smalloc(len + 2*1024); 
	} else 
		p = malloc(len + 2*1024); 
1992/1111    
	pad1 = p; 
	pad2 = p + len + 1024; 
1992/1112    
	pad2 = p + 1024 + len; 
1992/1111    
	memset(pad1, 0, 1024); 
	memset(pad2, 0, 1024); 
1992/1112    
	gscreen.base = (ulong*)(p+1024); 
1992/1107    
	memset((char*)gscreen.base, 0xff, len); 
1992/1112    
	memset((void*)SCREENMEM, 0xff, vgascreen.width * BY2WD * maxy); 
1992/1106    
 
	/* 
1992/1112    
	 *  set depth of cursor backup area 
	 */ 
	bitdepth(); 
 
	/* 
1992/1106    
	 *  set string pointer to upper left 
	 */ 
1992/0603    
	out.pos.x = MINX; 
1992/1111/sys/src/9/pc/vga.c:278,2901992/1112/sys/src/9/pc/vga.c:282,287
1992/0603    
	out.bwid = defont0.info[' '].width; 
} 
 
1992/1111    
int 
colourxpnd(int x) 
{ 
	x &= 3; 
	return (x<<4)|(x<<2)|x; 
} 
                 
1992/0603    
void 
1991/0730    
screeninit(void) 
1991/0723    
{ 
1992/1111/sys/src/9/pc/vga.c:322,3411992/1112/sys/src/9/pc/vga.c:319,333
1992/1110    
	/* 
1992/1111    
	 *  set up color map 
1992/1110    
	 */ 
1992/1112    
	lock(&colorlock); 
1992/1110    
	outb(CMWX, 0); 
	for(i = 0; i < 16; i++){ 
1992/1111    
		outb(CM, colourxpnd(i<<1)); 
		outb(CM, colourxpnd(i>>2)); 
		outb(CM, colourxpnd(i&~1)); 
1992/1112    
		x = (i*63)/15; 
		outb(CM, x); 
		outb(CM, x); 
		outb(CM, x); 
1992/1110    
	} 
1992/1111    
	outb(CMWX, 5); 
	outb(CM, 21); 
	outb(CM, 21); 
	outb(CM, 21); 
	outb(CMWX, 0xa); 
	outb(CM, 42); 
	outb(CM, 42); 
	outb(CM, 42); 
1992/1112    
	unlock(&colorlock); 
1991/0723    
} 
1991/0727    
 
1992/1106    
/* 
1992/1111/sys/src/9/pc/vga.c:383,3921992/1112/sys/src/9/pc/vga.c:375,393
1992/1108    
	uchar *sp, *hp; 
1992/1111    
	int y, len, incs, inch, off, page, y2pg, ey; 
1992/1108    
	Rectangle r; 
1992/1112    
	static int nocheck; 
1992/1108    
 
	r = mbb; 
	mbb = NULLMBB; 
 
1992/1112    
	if(nocheck==0 && memcmp(pad1, pad2, 1024)){ 
		nocheck = 1; 
		print("b: %d %d %d %d\n", r.min.x, r.min.y, r.max.x, r.max.y); 
		nocheck = 0; 
		memset(pad1, 0, 1024); 
		memset(pad2, 0, 1024); 
	} 
 
1992/1108    
	if(Dy(r) < 0) 
		return; 
 
1992/1111/sys/src/9/pc/vga.c:424,4311992/1112/sys/src/9/pc/vga.c:425,432
1992/1111    
		hp = (uchar*)(vgascreen.base+(r.min.y*vgascreen.width)) + off; 
		sp = (uchar*)(gscreen.base+(r.min.y*gscreen.width)) + 2*off; 
		len = (r.max.x + 15)/8 - r.min.x/8; 
		if(len < 2) 
			len = 2; 
1992/1112    
		if(len < 0) 
			return; 
1992/1111    
 
		/* reverse the bits and split into 2 bit planes */ 
1992/1108    
		for (y = r.min.y; y < r.max.y; y++){ 
1992/1111/sys/src/9/pc/vga.c:474,4791992/1112/sys/src/9/pc/vga.c:475,488
1992/1111    
		} 
		break; 
1992/1108    
	} 
1992/1112    
 
	if(nocheck==0 && memcmp(pad1, pad2, 1024)){ 
		nocheck = 1; 
		print("a: %d %d %d %d\n", r.min.x, r.min.y, r.max.x, r.max.y); 
		nocheck = 0; 
		memset(pad1, 0, 1024); 
		memset(pad2, 0, 1024); 
	} 
1992/1108    
} 
 
void 
1992/1111/sys/src/9/pc/vga.c:548,5741992/1112/sys/src/9/pc/vga.c:557,591
1992/1106    
	screenupdate(); 
} 
 
1992/1112    
static ulong 
expand(uchar x) 
{ 
	return (x<<(32-6))|(x<<(32-12))|(x<<(32-18))|(x<<(32-24)); 
} 
 
1992/1106    
void 
1991/0730    
getcolor(ulong p, ulong *pr, ulong *pg, ulong *pb) 
{ 
	ulong ans; 
                 
	/* 
1991/0731    
	 * The safari monochrome says 0 is black (zero intensity) 
1991/0730    
	 */ 
	if(p == 0) 
		ans = 0; 
	else 
		ans = ~0; 
	*pr = *pg = *pb = ans; 
1992/1112    
	p &= (1<<(1<<gscreen.ldepth))-1; 
	lock(&colorlock); 
	outb(CMRX, p); 
	*pr = expand(inb(CM)); 
	*pg = expand(inb(CM)); 
	*pb = expand(inb(CM)); 
	unlock(&colorlock); 
1991/0730    
} 
 
                 
int 
setcolor(ulong p, ulong r, ulong g, ulong b) 
{ 
1992/0711    
	USED(p, r, g, b); 
1991/0730    
	return 0;	/* can't change mono screen colormap */ 
1992/1112    
	p &= (1<<(1<<gscreen.ldepth))-1; 
	lock(&colorlock); 
	outb(CMWX, p); 
	outb(CM, r>>(32-6)); 
	outb(CM, g>>(32-6)); 
	outb(CM, b>>(32-6)); 
	unlock(&colorlock); 
	return ~0; 
1991/0730    
} 
 
int 


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