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

1991/0727/pc/vga.c (diff list | history)

1991/0723/sys/src/9/pc/vga.c:9,161991/0724/sys/src/9/pc/vga.c:9,32 (short | long)
1991/0723    
{ 
	GRX=		0x3CE,		/* index to graphics registers */ 
	GR=		0x3CF,		/* graphics registers 0-8 */ 
1991/0724    
	SRX=		0x3C4,		/* index to sequence registers */ 
	SR=		0x3C5,		/* sequence registers 0-7 */ 
1991/0723    
}; 
 
1991/0724    
void 
srout(int reg, int val) 
{ 
	outb(SRX, reg); 
	outb(SR, val); 
} 
 
void 
grout(int reg, int val) 
{ 
	outb(GRX, reg); 
	outb(GR, val); 
} 
 
1991/0723    
/* 
 *  look at VGA registers 
 */ 
1991/0723/sys/src/9/pc/vga.c:17,291991/0724/sys/src/9/pc/vga.c:33,51
1991/0723    
void 
vgainit(void) 
{ 
1991/0724    
	uchar *display; 
1991/0723    
	int i; 
	uchar x; 
 
	for(i = 0; i < 9; i++){ 
		outb(GRX, i); 
		x = inb(GR); 
		print("GR%d == %ux\n", i, x); 
	} 
	panic("for the hell of it"); 
1991/0724    
	srout(2, 0x0f);		/* enable all 4 color planes */ 
	srout(4, 0x08);		/* quad mode */ 
	grout(5, 0x40);		/* pixel bits are sequential */ 
	grout(6, 0x01);		/* graphics mode - display starts at 0xA0000 */ 
 
	for(;;); 
	display = (uchar*)(0xA0000 | KZERO); 
	for(i = 0; i < 128*1024; i++) 
		display[i] = 0x00; 
 
	for(i = 0; i < 4*640; i++) 
		display[i] = 0xff; 
1991/0723    
} 
1991/0724/sys/src/9/pc/vga.c:8,181991/0727/sys/src/9/pc/vga.c:8,42 (short | long)
1991/0723    
enum 
{ 
	GRX=		0x3CE,		/* index to graphics registers */ 
	GR=		0x3CF,		/* graphics registers 0-8 */ 
1991/0727    
	GR=		0x3CF,		/* graphics registers */ 
	 Grot=		 0x03,		/*  data rotate register */ 
	 Gmode=		 0x05,		/*  mode register */ 
	 Gmisc=		 0x06,		/*  miscillaneous register */ 
	 Grms=		 0x04,		/*  read map select register */ 
1991/0724    
	SRX=		0x3C4,		/* index to sequence registers */ 
	SR=		0x3C5,		/* sequence registers 0-7 */ 
1991/0727    
	SR=		0x3C5,		/* sequence registers */ 
	 Sclock=	 0x01,		/*  clocking register */ 
	 Smode=		 0x04,		/*  mode register */ 
	 Smmask=	 0x02,		/*  map mask */ 
	CRX=		0x3D4,		/* index to crt registers */ 
	CR=		0x3D5,		/* crt registers */ 
	 Cmode=		 0x17,		/*  mode register */ 
	 Cmsl=		 0x09,		/*  max scan line */ 
	ARX=		0x3C0,		/* index to attribute registers */ 
	AR=		0x3C1,		/* attribute registers */ 
	 Amode=		 0x10,		/*  mode register */ 
	 Acpe=		 0x12,		/*  color plane enable */ 
1991/0723    
}; 
 
1991/0727    
/* 
 *  screen dimensions 
 */ 
#define MAXX	640 
#define MAXY	480 
 
/* 
 *  routines for setting vga registers 
 */ 
1991/0724    
void 
srout(int reg, int val) 
{ 
1991/0724/sys/src/9/pc/vga.c:19,251991/0727/sys/src/9/pc/vga.c:43,48
1991/0724    
	outb(SRX, reg); 
	outb(SR, val); 
} 
                 
void 
grout(int reg, int val) 
{ 
1991/0724/sys/src/9/pc/vga.c:26,511991/0727/sys/src/9/pc/vga.c:49,149
1991/0724    
	outb(GRX, reg); 
	outb(GR, val); 
} 
1991/0727    
void 
arout(int reg, int val) 
{ 
	inb(0x3DA); 
	outb(ARX, reg | 0x20); 
	outb(AR, val); 
} 
void 
crout(int reg, int val) 
{ 
	outb(CRX, reg); 
	outb(CR, val); 
} 
1991/0724    
 
1991/0723    
/* 
 *  look at VGA registers 
1991/0727    
 *  m is a bit mask of planes to be affected by CPU writes 
1991/0723    
 */ 
1991/0727    
vgawrmask(int m) 
{ 
	srout(Smmask, m&0xf); 
} 
 
/* 
 *  p is the plane that will respond to CPU reads 
 */ 
vgardplane(int p) 
{ 
	grout(Grms, p&3); 
} 
 
/* 
 *  partial screen munching squares 
 */ 
#define	DELTA	1 
#define	DADDR	((long *) 0) 
#define	SIDE	256 
1991/0723    
void 
1991/0727    
munch(void) 
{ 
	ulong x,y,i,d; 
	uchar *screen, tab[8], *p; 
 
	screen = (uchar *)(0xA0000 | KZERO); 
	d=0; 
	tab[0] = 0x80; 
	tab[1] = 0x40; 
	tab[2] = 0x20; 
	tab[3] = 0x10; 
	tab[4] = 0x08; 
	tab[5] = 0x04; 
	tab[6] = 0x02; 
	tab[7] = 0x01; 
 
	for(i=0; i<MAXY*(MAXX/8); i++) 
		screen[i]=0; 
 
	for(;;){ 
		for(x=0; x<SIDE; x++){ 
			y = (x^d) % SIDE; 
			p = &screen[y*(MAXX/8) + (x/8)]; 
			y = *p; 
			*p = y ^ tab[x&7]; 
		} 
		d+=DELTA; 
	} 
} 
 
/* 
 *  Set up for 4 separately addressed bit planes.  Each plane is  
 */ 
void 
1991/0723    
vgainit(void) 
{ 
1991/0724    
	uchar *display; 
1991/0723    
	int i; 
1991/0727    
	int i, j, k; 
	int c; 
1991/0723    
 
1991/0724    
	srout(2, 0x0f);		/* enable all 4 color planes */ 
	srout(4, 0x08);		/* quad mode */ 
	grout(5, 0x40);		/* pixel bits are sequential */ 
	grout(6, 0x01);		/* graphics mode - display starts at 0xA0000 */ 
1991/0727    
	display = (uchar *)(0xA0000 | KZERO); 
	arout(Acpe, 0x0f);	/* enable all planes */ 
	arout(Amode, 0x01);	/* graphics mode - 4 bit pixels */ 
	grout(Gmisc, 0x01);	/* graphics mode */ 
	grout(Gmode, 0x00);	/* write mode 0, read mode 0 */ 
	grout(Grot, 0x00);	/* CPU writes bytes to video mem without modifications */ 
	crout(Cmode, 0xe3);	/* turn off address wrap & word mode */ 
	crout(Cmsl, 0x40);	/* 1 pixel per scan line */ 
	srout(Smode, 0x06);	/* extended memory, odd/even off */ 
	srout(Sclock, 0x01);	/* 8 bits/char */ 
1991/0724    
 
	for(;;); 
	display = (uchar*)(0xA0000 | KZERO); 
	for(i = 0; i < 128*1024; i++) 
		display[i] = 0x00; 
                 
	for(i = 0; i < 4*640; i++) 
		display[i] = 0xff; 
1991/0727    
	/* 
	 *  zero out display 
	 */ 
	srout(Smmask, 0x0f);	/* enable all 4 color planes for writing */ 
	for(i=0; i<MAXY*(MAXX/8); i++) 
		display[i] = 0; 
	 
	munch(); 
1991/0723    
} 
1991/0727    
 
1991/0727/sys/src/9/pc/vga.c:5,101991/0730/sys/src/9/pc/vga.c:5,42 (short | long)
1991/0723    
#include	"fns.h" 
#include	"io.h" 
 
1991/0730    
#include	<libg.h> 
#include	<gnot.h> 
#include	"screen.h" 
 
#define	MINX	8 
 
extern	GFont	defont0; 
GFont		*defont; 
 
struct{ 
	Point	pos; 
	int	bwid; 
}out; 
 
/* 
 *  screen dimensions 
 */ 
#define MAXX	640 
#define MAXY	480 
 
#define SCREENMEM	(0xA0000 | KZERO) 
 
GBitmap	gscreen = 
{ 
	(ulong*)SCREENMEM, 
	0, 
	640/32, 
	0, 
	0, 0, MAXX, MAXY, 
	0 
}; 
 
1991/0723    
enum 
{ 
	GRX=		0x3CE,		/* index to graphics registers */ 
1991/0727/sys/src/9/pc/vga.c:29,401991/0730/sys/src/9/pc/vga.c:61,66
1991/0723    
}; 
 
1991/0727    
/* 
 *  screen dimensions 
 */ 
#define MAXX	640 
#define MAXY	480 
                 
/* 
 *  routines for setting vga registers 
 */ 
1991/0724    
void 
1991/0727/sys/src/9/pc/vga.c:91,971991/0730/sys/src/9/pc/vga.c:117,123
1991/0727    
	ulong x,y,i,d; 
	uchar *screen, tab[8], *p; 
 
	screen = (uchar *)(0xA0000 | KZERO); 
1991/0730    
	screen = (uchar *)SCREENMEM; 
1991/0727    
	d=0; 
	tab[0] = 0x80; 
	tab[1] = 0x40; 
1991/0727/sys/src/9/pc/vga.c:120,1321991/0730/sys/src/9/pc/vga.c:146,160
1991/0727    
 *  Set up for 4 separately addressed bit planes.  Each plane is  
 */ 
void 
1991/0723    
vgainit(void) 
1991/0730    
screeninit(void) 
1991/0723    
{ 
1991/0724    
	uchar *display; 
1991/0727    
	int i, j, k; 
	int c; 
1991/0730    
	ulong *l; 
1991/0723    
 
1991/0727    
	display = (uchar *)(0xA0000 | KZERO); 
1991/0730    
	display = (uchar *)SCREENMEM; 
 
1991/0727    
	arout(Acpe, 0x0f);	/* enable all planes */ 
	arout(Amode, 0x01);	/* graphics mode - 4 bit pixels */ 
	grout(Gmisc, 0x01);	/* graphics mode */ 
1991/0727/sys/src/9/pc/vga.c:136,1491991/0730/sys/src/9/pc/vga.c:164,275
1991/0727    
	crout(Cmsl, 0x40);	/* 1 pixel per scan line */ 
	srout(Smode, 0x06);	/* extended memory, odd/even off */ 
	srout(Sclock, 0x01);	/* 8 bits/char */ 
1991/0730    
	srout(Smmask, 0x0f);	/* enable all 4 color planes for writing */ 
1991/0724    
 
1991/0727    
	/* 
	 *  zero out display 
	 */ 
	srout(Smmask, 0x0f);	/* enable all 4 color planes for writing */ 
	for(i=0; i<MAXY*(MAXX/8); i++) 
		display[i] = 0; 
	                 
	munch(); 
1991/0730    
	defont = &defont0;	/* save space; let bitblt do the conversion work */ 
	gbitblt(&gscreen, Pt(0, 0), &gscreen, gscreen.r, 0); /**/ 
 
	/* 
	 *  stick print at the top 
	 */ 
	out.pos.x = MINX; 
	out.pos.y = 0; 
	out.bwid = defont0.info[' '].width; 
 
	/* 
	 *  swizzle the damn font longs. 
	 *  we do it here since the font is in a machine independent (i.e. 
	 *  made for the 68020) format. 
	 */ 
	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); 
1991/0723    
} 
1991/0727    
 
1991/0730    
void 
screenputc(int c) 
{ 
	char buf[2]; 
	int nx; 
 
	if(c == '\n'){ 
		out.pos.x = MINX; 
		out.pos.y += defont0.height; 
		if(out.pos.y > gscreen.r.max.y-defont0.height) 
			out.pos.y = gscreen.r.min.y; 
		gbitblt(&gscreen, Pt(0, out.pos.y), &gscreen, 
		    Rect(0, out.pos.y, gscreen.r.max.x, out.pos.y+2*defont0.height), 0); 
	}else if(c == '\t'){ 
		out.pos.x += (8-((out.pos.x-MINX)/out.bwid&7))*out.bwid; 
		if(out.pos.x >= gscreen.r.max.x) 
			screenputc('\n'); 
	}else if(c == '\b'){ 
		if(out.pos.x >= out.bwid+MINX){ 
			out.pos.x -= out.bwid; 
			screenputc(' '); 
			out.pos.x -= out.bwid; 
		} 
	}else{ 
		if(out.pos.x >= gscreen.r.max.x-out.bwid) 
			screenputc('\n'); 
		buf[0] = c&0x7F; 
		buf[1] = 0; 
		out.pos = gstring(&gscreen, out.pos, defont, buf, S); 
	} 
} 
 
void 
screenputs(char *s, int n) 
{ 
	while(n-- > 0) 
		screenputc(*s++); 
} 
 
int 
screenbits(void) 
{ 
	return 1;	/* bits per pixel */ 
} 
 
void 
getcolor(ulong p, ulong *pr, ulong *pg, ulong *pb) 
{ 
	ulong ans; 
 
	/* 
	 * The magnum monochrome says 0 is black (zero intensity) 
	 */ 
	if(p == 0) 
		ans = 0; 
	else 
		ans = ~0; 
	*pr = *pg = *pb = ans; 
} 
 
 
int 
setcolor(ulong p, ulong r, ulong g, ulong b) 
{ 
	return 0;	/* can't change mono screen colormap */ 
} 
 
int 
hwcursset(uchar *s, uchar *c, int ox, int oy) 
{ 
	return 0; 
} 
 
int 
hwcursmove(int x, int y) 
{ 
	return 0; 
} 
 
void 
mouseclock(void)	/* called splhi */ 
{ 
	mouseupdate(1); 
} 
1991/0730/sys/src/9/pc/vga.c:240,2461991/0731/sys/src/9/pc/vga.c:240,246 (short | long)
1991/0730    
	ulong ans; 
 
	/* 
	 * The magnum monochrome says 0 is black (zero intensity) 
1991/0731    
	 * The safari monochrome says 0 is black (zero intensity) 
1991/0730    
	 */ 
	if(p == 0) 
		ans = 0; 
1991/0731/sys/src/9/pc/vga.c:167,1921991/0801/sys/src/9/pc/vga.c:167,191 (short | long)
1991/0730    
	srout(Smmask, 0x0f);	/* enable all 4 color planes for writing */ 
1991/0724    
 
1991/0727    
	/* 
1991/0801    
	 *  swizzle the font longs. 
	 *  we do it here since the font is initialized with big endian longs. 
	 */ 
	defont = &defont0; 
	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); 
 
	/* 
1991/0727    
	 *  zero out display 
	 */ 
1991/0730    
	defont = &defont0;	/* save space; let bitblt do the conversion work */ 
	gbitblt(&gscreen, Pt(0, 0), &gscreen, gscreen.r, 0); /**/ 
1991/0801    
	gbitblt(&gscreen, Pt(0, 0), &gscreen, gscreen.r, flipD[0]); 
1991/0730    
 
	/* 
	 *  stick print at the top 
1991/0801    
	 *  start printing at the top of screen 
1991/0730    
	 */ 
	out.pos.x = MINX; 
	out.pos.y = 0; 
	out.bwid = defont0.info[' '].width; 
                 
	/* 
	 *  swizzle the damn font longs. 
	 *  we do it here since the font is in a machine independent (i.e. 
	 *  made for the 68020) format. 
	 */ 
	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); 
1991/0723    
} 
1991/0727    
 
1991/0730    
void 
1991/0731/sys/src/9/pc/vga.c:201,2071991/0801/sys/src/9/pc/vga.c:200,206
1991/0730    
		if(out.pos.y > gscreen.r.max.y-defont0.height) 
			out.pos.y = gscreen.r.min.y; 
		gbitblt(&gscreen, Pt(0, out.pos.y), &gscreen, 
		    Rect(0, out.pos.y, gscreen.r.max.x, out.pos.y+2*defont0.height), 0); 
1991/0801    
		    Rect(0, out.pos.y, gscreen.r.max.x, out.pos.y+2*defont0.height), flipD[0]); 
1991/0730    
	}else if(c == '\t'){ 
		out.pos.x += (8-((out.pos.x-MINX)/out.bwid&7))*out.bwid; 
		if(out.pos.x >= gscreen.r.max.x) 
1991/0731/sys/src/9/pc/vga.c:217,2231991/0801/sys/src/9/pc/vga.c:216,222
1991/0730    
			screenputc('\n'); 
		buf[0] = c&0x7F; 
		buf[1] = 0; 
		out.pos = gstring(&gscreen, out.pos, defont, buf, S); 
1991/0801    
		out.pos = gstring(&gscreen, out.pos, defont, buf, flipD[S]); 
1991/0730    
	} 
} 
 
1991/0801/sys/src/9/pc/vga.c:148,1601991/0904/sys/src/9/pc/vga.c:148,157 (short | long)
1991/0727    
void 
1991/0730    
screeninit(void) 
1991/0723    
{ 
1991/0724    
	uchar *display; 
1991/0727    
	int i, j, k; 
	int c; 
1991/0730    
	ulong *l; 
1991/0723    
 
1991/0730    
	display = (uchar *)SCREENMEM; 
                 
1991/0727    
	arout(Acpe, 0x0f);	/* enable all planes */ 
	arout(Amode, 0x01);	/* graphics mode - 4 bit pixels */ 
	grout(Gmisc, 0x01);	/* graphics mode */ 
1991/0801/sys/src/9/pc/vga.c:268,2741991/0904/sys/src/9/pc/vga.c:265,271
1991/0730    
} 
 
void 
mouseclock(void)	/* called splhi */ 
1991/0904    
mouseclock(void) 
1991/0730    
{ 
	mouseupdate(1); 
} 
1991/0904/sys/src/9/pc/vga.c:165,1711991/0921/sys/src/9/pc/vga.c:165,172 (short | long)
1991/0724    
 
1991/0727    
	/* 
1991/0801    
	 *  swizzle the font longs. 
	 *  we do it here since the font is initialized with big endian longs. 
1991/0921    
	 *  we do it here since the font is initialized with big 
	 *  endian longs. 
1991/0801    
	 */ 
	defont = &defont0; 
	l = defont->bits->base; 
1991/0921/sys/src/9/pc/vga.c:106,1481991/0927/sys/src/9/pc/vga.c:106,111 (short | long)
1991/0727    
} 
 
/* 
 *  partial screen munching squares 
 */ 
#define	DELTA	1 
#define	DADDR	((long *) 0) 
#define	SIDE	256 
1991/0723    
void 
1991/0727    
munch(void) 
{ 
	ulong x,y,i,d; 
	uchar *screen, tab[8], *p; 
                 
1991/0730    
	screen = (uchar *)SCREENMEM; 
1991/0727    
	d=0; 
	tab[0] = 0x80; 
	tab[1] = 0x40; 
	tab[2] = 0x20; 
	tab[3] = 0x10; 
	tab[4] = 0x08; 
	tab[5] = 0x04; 
	tab[6] = 0x02; 
	tab[7] = 0x01; 
                 
	for(i=0; i<MAXY*(MAXX/8); i++) 
		screen[i]=0; 
                 
	for(;;){ 
		for(x=0; x<SIDE; x++){ 
			y = (x^d) % SIDE; 
			p = &screen[y*(MAXX/8) + (x/8)]; 
			y = *p; 
			*p = y ^ tab[x&7]; 
		} 
		d+=DELTA; 
	} 
} 
                 
/* 
 *  Set up for 4 separately addressed bit planes.  Each plane is  
 */ 
void 
1991/0921/sys/src/9/pc/vga.c:269,2721991/0927/sys/src/9/pc/vga.c:232,262
1991/0904    
mouseclock(void) 
1991/0730    
{ 
	mouseupdate(1); 
1991/0927    
} 
 
vgaset(char *cmd) 
{ 
	int set; 
	int reg; 
	int val; 
 
	set = *cmd++; 
	cmd++; 
	reg = strtoul(cmd, &cmd, 0); 
	cmd++; 
	val = strtoul(cmd, &cmd, 0); 
	switch(set){ 
	case 'a': 
		arout(reg, val); 
		break; 
	case 'g': 
		grout(reg, val); 
		break; 
	case 'c': 
		crout(reg, val); 
		break; 
	case 's': 
		srout(reg, val); 
		break; 
	} 
1991/0730    
} 
1991/0927/sys/src/9/pc/vga.c:52,571991/0928/sys/src/9/pc/vga.c:52,58 (short | long)
1991/0727    
	 Smmask=	 0x02,		/*  map mask */ 
	CRX=		0x3D4,		/* index to crt registers */ 
	CR=		0x3D5,		/* crt registers */ 
1991/0928    
	 Cvertend=	 0x12,		/*  vertical display end */ 
1991/0727    
	 Cmode=		 0x17,		/*  mode register */ 
	 Cmsl=		 0x09,		/*  max scan line */ 
	ARX=		0x3C0,		/* index to attribute registers */ 
1991/0927/sys/src/9/pc/vga.c:106,1111991/0928/sys/src/9/pc/vga.c:107,174
1991/0727    
} 
 
/* 
1991/0928    
 *  2 bit deep display.  the bits are adjacent.  maybe this 
 *  will work 
 *	4 color 
 *	640x480 
 */ 
vga2(void) 
{ 
	int i; 
	arout(Acpe, 0x00);	/* disable planes for output */ 
 
	gscreen.ldepth = 1; 
	arout(Amode, 0x01);	/* color graphics mode */ 
	grout(Gmisc, 0x01);	/* graphics mode */ 
	grout(Gmode, 0x30);	/* 2 bits deep, even bytes are 
				 * planes 0 and 2, odd are planes 
				 * 1 and 3 */ 
	grout(Grot, 0x00);	/* CPU writes bytes to video 
				 * mem without modifications */ 
	crout(Cmode, 0xe3);	/* turn off address wrap & 
				 * word mode */ 
	crout(Cmsl, 0x40);	/* 1 pixel per scan line */ 
	crout(Cvertend, MAXY);	/* 480 lne display */ 
	srout(Smode, 0x06);	/* extended memory, odd/even */ 
	srout(Sclock, 0x01);	/* 8 bits/char */ 
	srout(Smmask, 0x0f);	/* enable 2 planes for writing */ 
 
	arout(Acpe, 0x0f);	/* enable 2 planes for output */ 
	for(i = 0; i < 128*1024;){ 
		((uchar*)SCREENMEM)[i++] = 0x1b; 
		((uchar*)SCREENMEM)[i++] = 0xe4; 
	} 
	for(;;); 
} 
 
/* 
 *  set up like vga mode 0x11 
 *	2 color 
 *	640x480 
 */ 
vga1(void) 
{ 
	arout(Acpe, 0x00);	/* disable planes for output */ 
 
	gscreen.ldepth = 0; 
	arout(Amode, 0x01);	/* color graphics mode */ 
	grout(Gmisc, 0x01);	/* graphics mode */ 
	grout(Gmode, 0x00);	/* 1 bit deep */ 
	grout(Grot, 0x00);	/* CPU writes bytes to video 
				 * mem without modifications */ 
	crout(Cmode, 0xe3);	/* turn off address wrap & 
				 * word mode */ 
	crout(Cmsl, 0x40);	/* 1 pixel per scan line */ 
	crout(Cvertend, MAXY);	/* 480 lne display */ 
	srout(Smode, 0x06);	/* extended memory, 
				 * odd/even off */ 
	srout(Sclock, 0x01);	/* 8 bits/char */ 
	srout(Smmask, 0x0f);	/* enable 4 planes for writing */ 
 
	arout(Acpe, 0x0f);	/* enable 4 planes for output */ 
} 
 
/* 
1991/0727    
 *  Set up for 4 separately addressed bit planes.  Each plane is  
 */ 
void 
1991/0927/sys/src/9/pc/vga.c:115,1311991/0928/sys/src/9/pc/vga.c:178,184
1991/0727    
	int c; 
1991/0730    
	ulong *l; 
1991/0723    
 
1991/0727    
	arout(Acpe, 0x0f);	/* enable all planes */ 
	arout(Amode, 0x01);	/* graphics mode - 4 bit pixels */ 
	grout(Gmisc, 0x01);	/* graphics mode */ 
	grout(Gmode, 0x00);	/* write mode 0, read mode 0 */ 
	grout(Grot, 0x00);	/* CPU writes bytes to video mem without modifications */ 
	crout(Cmode, 0xe3);	/* turn off address wrap & word mode */ 
	crout(Cmsl, 0x40);	/* 1 pixel per scan line */ 
	srout(Smode, 0x06);	/* extended memory, odd/even off */ 
	srout(Sclock, 0x01);	/* 8 bits/char */ 
1991/0730    
	srout(Smmask, 0x0f);	/* enable all 4 color planes for writing */ 
1991/0724    
                 
1991/0928    
	vga1(); 
1991/0727    
	/* 
1991/0801    
	 *  swizzle the font longs. 
1991/0921    
	 *  we do it here since the font is initialized with big 
1991/0928/sys/src/9/pc/vga.c:168,1761991/0929/sys/src/9/pc/vga.c:168,173 (short | long)
1991/0928    
	arout(Acpe, 0x0f);	/* enable 4 planes for output */ 
} 
 
/* 
1991/0727    
 *  Set up for 4 separately addressed bit planes.  Each plane is  
 */ 
void 
1991/0730    
screeninit(void) 
1991/0723    
{ 
1991/0928/sys/src/9/pc/vga.c:179,1841991/0929/sys/src/9/pc/vga.c:176,182
1991/0730    
	ulong *l; 
1991/0723    
 
1991/0928    
	vga1(); 
1991/0929    
 
1991/0727    
	/* 
1991/0801    
	 *  swizzle the font longs. 
1991/0921    
	 *  we do it here since the font is initialized with big 
1991/0928/sys/src/9/pc/vga.c:189,2021991/0929/sys/src/9/pc/vga.c:187,193
1991/0801    
	for(i = defont->bits->width*Dy(defont->bits->r); i > 0; i--, l++) 
		*l = (*l<<24) | ((*l>>8)&0x0000ff00) | ((*l<<8)&0x00ff0000) | (*l>>24); 
 
	/* 
1991/0727    
	 *  zero out display 
	 */ 
1991/0801    
	gbitblt(&gscreen, Pt(0, 0), &gscreen, gscreen.r, flipD[0]); 
1991/0730    
                 
	/* 
1991/0801    
	 *  start printing at the top of screen 
1991/0730    
	 */ 
	out.pos.x = MINX; 
	out.pos.y = 0; 
	out.bwid = defont0.info[' '].width; 
1991/0929/sys/src/9/pc/vga.c:159,1651991/1002/sys/src/9/pc/vga.c:159,165 (short | long)
1991/0928    
	crout(Cmode, 0xe3);	/* turn off address wrap & 
				 * word mode */ 
	crout(Cmsl, 0x40);	/* 1 pixel per scan line */ 
	crout(Cvertend, MAXY);	/* 480 lne display */ 
1991/1002    
	crout(Cvertend, MAXY-1);	/* 480 lne display */ 
1991/0928    
	srout(Smode, 0x06);	/* extended memory, 
				 * odd/even off */ 
	srout(Sclock, 0x01);	/* 8 bits/char */ 
1991/1002/sys/src/9/pc/vga.c:89,941991/1107/sys/src/9/pc/vga.c:89,105 (short | long)
1991/0727    
	outb(CRX, reg); 
	outb(CR, val); 
} 
1991/1107    
crdump(void) 
{ 
	uchar x; 
	int i; 
 
	for(i = 0; i < 0x16; i++){ 
		outb(CRX, i); 
		x = inb(CR); 
		print("cr[0x%lux] = %ux\n", i, x); 
	} 
} 
1991/0724    
 
1991/0723    
/* 
1991/0727    
 *  m is a bit mask of planes to be affected by CPU writes 
1991/1107/sys/src/9/pc/vga.c:24,291991/1109/sys/src/9/pc/vga.c:24,32 (short | long)
1991/0730    
 */ 
#define MAXX	640 
#define MAXY	480 
1991/1109    
#define XPERIOD	800	/* Hsync freq == 31.47 KHZ */ 
#define YPERIOD	525	/* Vsync freq == 59.9 HZ */ 
#define YBORDER 2 
1991/0730    
 
#define SCREENMEM	(0xA0000 | KZERO) 
 
1991/1107/sys/src/9/pc/vga.c:52,601991/1109/sys/src/9/pc/vga.c:55,69
1991/0727    
	 Smmask=	 0x02,		/*  map mask */ 
	CRX=		0x3D4,		/* index to crt registers */ 
	CR=		0x3D5,		/* crt registers */ 
1991/0928    
	 Cvertend=	 0x12,		/*  vertical display end */ 
1991/0727    
	 Cmode=		 0x17,		/*  mode register */ 
1991/1109    
	 Cvt=		 0x06,		/*  vertical total */ 
	 Cvover=	 0x07,		/*  bits that didn't fit elsewhere */ 
1991/0727    
	 Cmsl=		 0x09,		/*  max scan line */ 
1991/1109    
	 Cvrs=		 0x10,		/*  vertical retrace start */ 
	 Cvre=		 0x11,		/*  vertical retrace end */ 
	 Cvde=	 	 0x12,		/*  vertical display end */ 
	 Cvbs=		 0x15,		/*  vertical blank start */ 
	 Cvbe=		 0x16,		/*  vertical blank end */ 
	 Cmode=		 0x17,		/*  mode register */ 
1991/0727    
	ARX=		0x3C0,		/* index to attribute registers */ 
	AR=		0x3C1,		/* attribute registers */ 
	 Amode=		 0x10,		/*  mode register */ 
1991/1107/sys/src/9/pc/vga.c:89,1061991/1109/sys/src/9/pc/vga.c:98,104
1991/0727    
	outb(CRX, reg); 
	outb(CR, val); 
} 
1991/1107    
crdump(void) 
{ 
	uchar x; 
	int i; 
 
	for(i = 0; i < 0x16; i++){ 
		outb(CRX, i); 
		x = inb(CR); 
		print("cr[0x%lux] = %ux\n", i, x); 
	} 
} 
1991/0724    
                 
1991/0723    
/* 
1991/0727    
 *  m is a bit mask of planes to be affected by CPU writes 
1991/0723    
 */ 
1991/1107/sys/src/9/pc/vga.c:118,1641991/1109/sys/src/9/pc/vga.c:116,133
1991/0727    
} 
 
/* 
1991/0928    
 *  2 bit deep display.  the bits are adjacent.  maybe this 
 *  will work 
 *	4 color 
1991/1109    
 *  set up like vga mode 0x12 
 *	16 color (though we only use values 0x0 and 0xf) 
1991/0928    
 *	640x480 
1991/1109    
 * 
 *  we assume the BIOS left the registers in a 
 *  CGA-like mode.  Thus we don't set all the registers. 
1991/0928    
 */ 
vga2(void) 
1991/1109    
vga12(void) 
1991/0928    
{ 
	int i; 
	arout(Acpe, 0x00);	/* disable planes for output */ 
1991/1109    
	int overflow; 
	int msl; 
1991/0928    
 
	gscreen.ldepth = 1; 
	arout(Amode, 0x01);	/* color graphics mode */ 
	grout(Gmisc, 0x01);	/* graphics mode */ 
	grout(Gmode, 0x30);	/* 2 bits deep, even bytes are 
				 * planes 0 and 2, odd are planes 
				 * 1 and 3 */ 
	grout(Grot, 0x00);	/* CPU writes bytes to video 
				 * mem without modifications */ 
	crout(Cmode, 0xe3);	/* turn off address wrap & 
				 * word mode */ 
	crout(Cmsl, 0x40);	/* 1 pixel per scan line */ 
	crout(Cvertend, MAXY);	/* 480 lne display */ 
	srout(Smode, 0x06);	/* extended memory, odd/even */ 
	srout(Sclock, 0x01);	/* 8 bits/char */ 
	srout(Smmask, 0x0f);	/* enable 2 planes for writing */ 
                 
	arout(Acpe, 0x0f);	/* enable 2 planes for output */ 
	for(i = 0; i < 128*1024;){ 
		((uchar*)SCREENMEM)[i++] = 0x1b; 
		((uchar*)SCREENMEM)[i++] = 0xe4; 
	} 
	for(;;); 
} 
                 
/* 
 *  set up like vga mode 0x11 
 *	2 color 
 *	640x480 
 */ 
vga1(void) 
{ 
	arout(Acpe, 0x00);	/* disable planes for output */ 
 
	gscreen.ldepth = 0; 
1991/1107/sys/src/9/pc/vga.c:167,1761991/1109/sys/src/9/pc/vga.c:136,168
1991/0928    
	grout(Gmode, 0x00);	/* 1 bit deep */ 
	grout(Grot, 0x00);	/* CPU writes bytes to video 
				 * mem without modifications */ 
1991/1109    
 
	msl = overflow = 0; 
1991/0928    
	crout(Cmode, 0xe3);	/* turn off address wrap & 
				 * word mode */ 
	crout(Cmsl, 0x40);	/* 1 pixel per scan line */ 
1991/1002    
	crout(Cvertend, MAXY-1);	/* 480 lne display */ 
1991/1109    
	/* last scan line displayed (first is 0) */ 
	crout(Cvde, MAXY-1); 
	overflow |= ((MAXY-1)&0x200) ? 0x40 : 0; 
	overflow |= ((MAXY-1)&0x100) ? 0x2 : 0; 
	/* total scan lines (including retrace) - 2 */ 
	crout(Cvt, (YPERIOD-2)); 
	overflow |= ((YPERIOD-2)&0x200) ? 0x20 : 0; 
	overflow |= ((YPERIOD-2)&0x100) ? 0x1 : 0; 
	/* scan lines at which vertcal retrace starts & ends */ 
	crout(Cvrs, (MAXY+10)); 
	overflow |= ((MAXY+10)&0x200) ? 0x80 : 0; 
	overflow |= ((MAXY+10)&0x100) ? 0x4 : 0; 
	crout(Cvre, ((YPERIOD-1)&0xf)|0xa0);	/* also disable vertical interrupts */ 
	/* scan lines at which vertical blanking starts & ends */ 
	crout(Cvbs, (MAXY+YBORDER)); 
	msl |= ((MAXY+YBORDER)&0x200) ? 0x20 : 0; 
	overflow |= ((MAXY+YBORDER)&0x100) ? 0x8 : 0; 
	crout(Cvbe, (YPERIOD-YBORDER)&0x7f); 
	/* pixels per scan line (always 0 for graphics) */ 
	crout(Cmsl, 0x40|msl);	/* also 10th bit of line compare */ 
	/* the overflow bits from the other registers */ 
	crout(Cvover, 0x10|overflow);	/* also 9th bit of line compare */ 
 
1991/0928    
	srout(Smode, 0x06);	/* extended memory, 
				 * odd/even off */ 
	srout(Sclock, 0x01);	/* 8 bits/char */ 
1991/1107/sys/src/9/pc/vga.c:186,1921991/1109/sys/src/9/pc/vga.c:178,184
1991/0727    
	int c; 
1991/0730    
	ulong *l; 
1991/0723    
 
1991/0928    
	vga1(); 
1991/1109    
	vga12(); 
1991/0929    
 
1991/0727    
	/* 
1991/0801    
	 *  swizzle the font longs. 
1991/1109/sys/src/9/pc/vga.c:24,321991/1112/sys/src/9/pc/vga.c:24,32 (short | long)
1991/0730    
 */ 
#define MAXX	640 
#define MAXY	480 
1991/1109    
#define XPERIOD	800	/* Hsync freq == 31.47 KHZ */ 
#define YPERIOD	525	/* Vsync freq == 59.9 HZ */ 
#define YBORDER 2 
1991/1112    
int	xperiod = 800;	/* Hsync freq == 31.47 KHZ */ 
int	yperiod	= 525;	/* Vsync freq == 59.9 HZ */ 
int	yborder = 7;	/* top/bottom border of screen */ 
1991/0730    
 
#define SCREENMEM	(0xA0000 | KZERO) 
 
1991/1109/sys/src/9/pc/vga.c:42,471991/1112/sys/src/9/pc/vga.c:42,51
1991/0730    
 
1991/0723    
enum 
{ 
1991/1112    
	EMISCR=		0x3CC,		/* control sync polarity */ 
	EMISCW=		0x3C2, 
	EFCW=		0x3DA,		/* feature control */ 
	EFCR=		0x3CA, 
1991/0723    
	GRX=		0x3CE,		/* index to graphics registers */ 
1991/0727    
	GR=		0x3CF,		/* graphics registers */ 
	 Grot=		 0x03,		/*  data rotate register */ 
1991/1109/sys/src/9/pc/vga.c:115,1201991/1112/sys/src/9/pc/vga.c:119,135
1991/0727    
	grout(Grms, p&3); 
} 
 
1991/1112    
vgadump(void) 
{ 
	print("misc is 0x%ux fc is 0x%ux\n", inb(EMISCR), inb(EFCR)); 
	outb(EMISCW, 0xc7);/**/ 
} 
 
vgaclock(void) 
{ 
	outb(EMISCW, 0xc7);/**/ 
} 
 
1991/0727    
/* 
1991/1109    
 *  set up like vga mode 0x12 
 *	16 color (though we only use values 0x0 and 0xf) 
1991/1109/sys/src/9/pc/vga.c:138,1671991/1112/sys/src/9/pc/vga.c:153,182
1991/0928    
				 * mem without modifications */ 
1991/1109    
 
	msl = overflow = 0; 
1991/0928    
	crout(Cmode, 0xe3);	/* turn off address wrap & 
				 * word mode */ 
1991/1112    
	/* turn off address wrap & word mode */ 
	crout(Cmode, 0xe3); 
1991/1109    
	/* last scan line displayed (first is 0) */ 
	crout(Cvde, MAXY-1); 
	overflow |= ((MAXY-1)&0x200) ? 0x40 : 0; 
	overflow |= ((MAXY-1)&0x100) ? 0x2 : 0; 
	/* total scan lines (including retrace) - 2 */ 
	crout(Cvt, (YPERIOD-2)); 
	overflow |= ((YPERIOD-2)&0x200) ? 0x20 : 0; 
	overflow |= ((YPERIOD-2)&0x100) ? 0x1 : 0; 
1991/1112    
	crout(Cvt, (yperiod-2)); 
	overflow |= ((yperiod-2)&0x200) ? 0x20 : 0; 
	overflow |= ((yperiod-2)&0x100) ? 0x1 : 0; 
1991/1109    
	/* scan lines at which vertcal retrace starts & ends */ 
	crout(Cvrs, (MAXY+10)); 
	overflow |= ((MAXY+10)&0x200) ? 0x80 : 0; 
	overflow |= ((MAXY+10)&0x100) ? 0x4 : 0; 
	crout(Cvre, ((YPERIOD-1)&0xf)|0xa0);	/* also disable vertical interrupts */ 
1991/1112    
	crout(Cvrs, (MAXY+0x0a)); /**/ 
	overflow |= ((MAXY+0x0a)&0x200) ? 0x80 : 0; 
	overflow |= ((MAXY+0x0a)&0x100) ? 0x4 : 0; 
	crout(Cvre, ((yperiod-1)&0xf)|0xa0);	/* also disable vertical interrupts */ 
1991/1109    
	/* scan lines at which vertical blanking starts & ends */ 
	crout(Cvbs, (MAXY+YBORDER)); 
	msl |= ((MAXY+YBORDER)&0x200) ? 0x20 : 0; 
	overflow |= ((MAXY+YBORDER)&0x100) ? 0x8 : 0; 
	crout(Cvbe, (YPERIOD-YBORDER)&0x7f); 
	/* pixels per scan line (always 0 for graphics) */ 
	crout(Cmsl, 0x40|msl);	/* also 10th bit of line compare */ 
1991/1112    
	crout(Cvbs, (MAXY+yborder)); 
	msl |= ((MAXY+yborder)&0x100) ? 0x20 : 0; 
	overflow |= ((MAXY+yborder)&0x100) ? 0x8 : 0; 
	crout(Cvbe, (yperiod-yborder)&0x7f); 
1991/1109    
	/* the overflow bits from the other registers */ 
	crout(Cvover, 0x10|overflow);	/* also 9th bit of line compare */ 
1991/1112    
	/* pixels per scan line (always 0 for graphics) */ 
	crout(Cmsl, 0x40|msl);	/* also 10th bit of line compare */ 
1991/1109    
 
1991/0928    
	srout(Smode, 0x06);	/* extended memory, 
				 * odd/even off */ 
1991/1112/sys/src/9/pc/vga.c:24,321991/1113/sys/src/9/pc/vga.c:24,29 (short | long)
1991/0730    
 */ 
#define MAXX	640 
#define MAXY	480 
1991/1112    
int	xperiod = 800;	/* Hsync freq == 31.47 KHZ */ 
int	yperiod	= 525;	/* Vsync freq == 59.9 HZ */ 
int	yborder = 7;	/* top/bottom border of screen */ 
1991/0730    
 
#define SCREENMEM	(0xA0000 | KZERO) 
 
1991/1112/sys/src/9/pc/vga.c:48,831991/1113/sys/src/9/pc/vga.c:45,103
1991/1112    
	EFCR=		0x3CA, 
1991/0723    
	GRX=		0x3CE,		/* index to graphics registers */ 
1991/0727    
	GR=		0x3CF,		/* graphics registers */ 
	 Grot=		 0x03,		/*  data rotate register */ 
	 Gmode=		 0x05,		/*  mode register */ 
	 Gmisc=		 0x06,		/*  miscillaneous register */ 
	 Grms=		 0x04,		/*  read map select register */ 
1991/0724    
	SRX=		0x3C4,		/* index to sequence registers */ 
1991/0727    
	SR=		0x3C5,		/* sequence registers */ 
	 Sclock=	 0x01,		/*  clocking register */ 
	 Smode=		 0x04,		/*  mode register */ 
	 Smmask=	 0x02,		/*  map mask */ 
	CRX=		0x3D4,		/* index to crt registers */ 
	CR=		0x3D5,		/* crt registers */ 
1991/1109    
	 Cvt=		 0x06,		/*  vertical total */ 
	 Cvover=	 0x07,		/*  bits that didn't fit elsewhere */ 
1991/0727    
	 Cmsl=		 0x09,		/*  max scan line */ 
1991/1109    
	 Cvrs=		 0x10,		/*  vertical retrace start */ 
	 Cvre=		 0x11,		/*  vertical retrace end */ 
	 Cvde=	 	 0x12,		/*  vertical display end */ 
	 Cvbs=		 0x15,		/*  vertical blank start */ 
	 Cvbe=		 0x16,		/*  vertical blank end */ 
	 Cmode=		 0x17,		/*  mode register */ 
1991/0727    
	ARX=		0x3C0,		/* index to attribute registers */ 
	AR=		0x3C1,		/* attribute registers */ 
	 Amode=		 0x10,		/*  mode register */ 
	 Acpe=		 0x12,		/*  color plane enable */ 
1991/0723    
}; 
 
1991/1113    
typedef struct VGAmode	VGAmode; 
struct VGAmode 
{ 
	uchar	general[4]; 
	uchar	sequencer[5]; 
	uchar	crt[0x19]; 
	uchar	graphics[9]; 
	uchar	attribute[0x15]; 
}; 
 
1991/0727    
/* 
 *  routines for setting vga registers 
1991/1113    
 *  640x480 display, 16 bit color 
1991/0727    
 */ 
1991/1113    
VGAmode mode12 =  
{ 
	/* general */ 
	0xe3, 0x00, 0x70, 0x04, 
	/* sequence */ 
	0x03, 0x01, 0x0f, 0x00, 0x06, 
	/* crt */ 
	0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0x0b, 0x3e, 
	0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x59, 
	0xea, 0x0c, 0xdf, 0x28, 0x00, 0xe7, 0x04, 0xe3, 
	0xff, 
	/* graphics */ 
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 
	0xff, 
	/* attribute */ 
	0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, 
	0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 
	0x01, 0x00, 0x0f, 0x00, 0x00, 
}; 
 
1991/0724    
void 
1991/1113    
genout(int reg, int val) 
{ 
	if(reg == 0) 
		outb(EMISCW, val); 
	else if (reg == 1) 
		outb(EFCW, val); 
} 
void 
1991/0724    
srout(int reg, int val) 
{ 
	outb(SRX, reg); 
1991/1112/sys/src/9/pc/vga.c:122,1891991/1113/sys/src/9/pc/vga.c:142,169
1991/1112    
vgadump(void) 
{ 
	print("misc is 0x%ux fc is 0x%ux\n", inb(EMISCR), inb(EFCR)); 
	outb(EMISCW, 0xc7);/**/ 
} 
 
vgaclock(void) 
1991/1113    
void 
setmode(VGAmode *v) 
1991/1112    
{ 
	outb(EMISCW, 0xc7);/**/ 
} 
1991/1113    
	int i; 
1991/1112    
 
1991/0727    
/* 
1991/1109    
 *  set up like vga mode 0x12 
 *	16 color (though we only use values 0x0 and 0xf) 
1991/0928    
 *	640x480 
1991/1109    
 * 
 *  we assume the BIOS left the registers in a 
 *  CGA-like mode.  Thus we don't set all the registers. 
1991/0928    
 */ 
1991/1109    
vga12(void) 
1991/0928    
{ 
1991/1109    
	int overflow; 
	int msl; 
1991/1113    
	for(i = 0; i < sizeof(v->general); i++) 
		genout(i, v->general[i]); 
1991/0928    
 
	arout(Acpe, 0x00);	/* disable planes for output */ 
1991/1113    
	for(i = 0; i < sizeof(v->sequencer); i++) 
		srout(i, v->sequencer[i]); 
1991/0928    
 
	gscreen.ldepth = 0; 
	arout(Amode, 0x01);	/* color graphics mode */ 
	grout(Gmisc, 0x01);	/* graphics mode */ 
	grout(Gmode, 0x00);	/* 1 bit deep */ 
	grout(Grot, 0x00);	/* CPU writes bytes to video 
				 * mem without modifications */ 
1991/1113    
	crout(Cvre, 0);	/* allow writes to CRT registers 0-7 */ 
	for(i = 0; i < sizeof(v->crt); i++) 
		crout(i, v->crt[i]); 
1991/1109    
 
	msl = overflow = 0; 
1991/1112    
	/* turn off address wrap & word mode */ 
	crout(Cmode, 0xe3); 
1991/1109    
	/* last scan line displayed (first is 0) */ 
	crout(Cvde, MAXY-1); 
	overflow |= ((MAXY-1)&0x200) ? 0x40 : 0; 
	overflow |= ((MAXY-1)&0x100) ? 0x2 : 0; 
	/* total scan lines (including retrace) - 2 */ 
1991/1112    
	crout(Cvt, (yperiod-2)); 
	overflow |= ((yperiod-2)&0x200) ? 0x20 : 0; 
	overflow |= ((yperiod-2)&0x100) ? 0x1 : 0; 
1991/1109    
	/* scan lines at which vertcal retrace starts & ends */ 
1991/1112    
	crout(Cvrs, (MAXY+0x0a)); /**/ 
	overflow |= ((MAXY+0x0a)&0x200) ? 0x80 : 0; 
	overflow |= ((MAXY+0x0a)&0x100) ? 0x4 : 0; 
	crout(Cvre, ((yperiod-1)&0xf)|0xa0);	/* also disable vertical interrupts */ 
1991/1109    
	/* scan lines at which vertical blanking starts & ends */ 
1991/1112    
	crout(Cvbs, (MAXY+yborder)); 
	msl |= ((MAXY+yborder)&0x100) ? 0x20 : 0; 
	overflow |= ((MAXY+yborder)&0x100) ? 0x8 : 0; 
	crout(Cvbe, (yperiod-yborder)&0x7f); 
1991/1109    
	/* the overflow bits from the other registers */ 
	crout(Cvover, 0x10|overflow);	/* also 9th bit of line compare */ 
1991/1112    
	/* pixels per scan line (always 0 for graphics) */ 
	crout(Cmsl, 0x40|msl);	/* also 10th bit of line compare */ 
1991/1113    
	for(i = 0; i < sizeof(v->graphics); i++) 
		grout(i, v->graphics[i]); 
1991/1109    
 
1991/0928    
	srout(Smode, 0x06);	/* extended memory, 
				 * odd/even off */ 
	srout(Sclock, 0x01);	/* 8 bits/char */ 
	srout(Smmask, 0x0f);	/* enable 4 planes for writing */ 
                 
	arout(Acpe, 0x0f);	/* enable 4 planes for output */ 
1991/1113    
	for(i = 0; i < sizeof(v->attribute); i++) 
		arout(i, v->attribute[i]); 
1991/0928    
} 
 
1991/0727    
void 
1991/1112/sys/src/9/pc/vga.c:193,1991991/1113/sys/src/9/pc/vga.c:173,180
1991/0727    
	int c; 
1991/0730    
	ulong *l; 
1991/0723    
 
1991/1109    
	vga12(); 
1991/1113    
	setmode(&mode12); 
	bigcursor(); 
1991/0929    
 
1991/0727    
	/* 
1991/0801    
	 *  swizzle the font longs. 
1991/1112/sys/src/9/pc/vga.c:321,3241991/1113/sys/src/9/pc/vga.c:302,332
1991/0927    
		srout(reg, val); 
		break; 
	} 
1991/1113    
} 
 
 
/* 
 *  a fatter than usual cursor for the safari 
 */ 
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,  
	}, 
}; 
void 
bigcursor(void) 
{ 
	extern Cursor arrow; 
 
	memmove(&arrow, &fatarrow, sizeof(fatarrow)); 
1991/0730    
} 
1991/1113/sys/src/9/pc/vga.c:52,591991/1211/sys/src/9/pc/vga.c:52,59 (short | long)
1991/0727    
	CRX=		0x3D4,		/* index to crt registers */ 
	CR=		0x3D5,		/* crt registers */ 
1991/1109    
	 Cvre=		 0x11,		/*  vertical retrace end */ 
1991/0727    
	ARX=		0x3C0,		/* index to attribute registers */ 
	AR=		0x3C1,		/* attribute registers */ 
1991/1211    
	ARW=		0x3C0,		/* attribute registers (writing) */ 
	ARR=		0x3C1,		/* attribute registers (reading) */ 
1991/0723    
}; 
 
1991/1113    
typedef struct VGAmode	VGAmode; 
1991/1113/sys/src/9/pc/vga.c:113,1201991/1211/sys/src/9/pc/vga.c:113,120
1991/0727    
arout(int reg, int val) 
{ 
	inb(0x3DA); 
	outb(ARX, reg | 0x20); 
	outb(AR, val); 
1991/1211    
	outb(ARW, reg | 0x20); 
	outb(ARW, val); 
1991/0727    
} 
void 
crout(int reg, int val) 
1991/1211/sys/src/9/pc/vga.c:193,2341991/1228/sys/src/9/pc/vga.c:193,245 (short | long)
1991/0723    
} 
1991/0727    
 
1991/0730    
void 
screenputc(int c) 
1991/1228    
screenputnl(void) 
1991/0730    
{ 
	char buf[2]; 
	int nx; 
                 
	if(c == '\n'){ 
		out.pos.x = MINX; 
		out.pos.y += defont0.height; 
		if(out.pos.y > gscreen.r.max.y-defont0.height) 
			out.pos.y = gscreen.r.min.y; 
		gbitblt(&gscreen, Pt(0, out.pos.y), &gscreen, 
1991/0801    
		    Rect(0, out.pos.y, gscreen.r.max.x, out.pos.y+2*defont0.height), flipD[0]); 
1991/0730    
	}else if(c == '\t'){ 
		out.pos.x += (8-((out.pos.x-MINX)/out.bwid&7))*out.bwid; 
		if(out.pos.x >= gscreen.r.max.x) 
			screenputc('\n'); 
	}else if(c == '\b'){ 
		if(out.pos.x >= out.bwid+MINX){ 
			out.pos.x -= out.bwid; 
			screenputc(' '); 
			out.pos.x -= out.bwid; 
		} 
	}else{ 
		if(out.pos.x >= gscreen.r.max.x-out.bwid) 
			screenputc('\n'); 
		buf[0] = c&0x7F; 
		buf[1] = 0; 
1991/0801    
		out.pos = gstring(&gscreen, out.pos, defont, buf, flipD[S]); 
1991/0730    
	} 
1991/1228    
	out.pos.x = MINX; 
	out.pos.y += defont0.height; 
	if(out.pos.y > gscreen.r.max.y-defont0.height) 
		out.pos.y = gscreen.r.min.y; 
	gbitblt(&gscreen, Pt(0, out.pos.y), &gscreen, 
	    Rect(0, out.pos.y, gscreen.r.max.x, out.pos.y+2*defont0.height), flipD[0]); 
1991/0730    
} 
 
void 
screenputs(char *s, int n) 
{ 
	while(n-- > 0) 
		screenputc(*s++); 
1991/1228    
	Rune r; 
	int i; 
	char buf[4]; 
 
	lock(&printq); 
	while(n > 0){ 
		i = chartorune(&r, s); 
		if(i == 0){ 
			s++; 
			--n; 
			continue; 
		} 
		memmove(buf, s, i); 
		buf[i] = 0; 
		n -= i; 
		s += i; 
		if(r == '\n') 
			screenputnl(); 
		else if(r == '\t'){ 
			out.pos.x += (8-((out.pos.x-MINX)/out.bwid&7))*out.bwid; 
			if(out.pos.x >= gscreen.r.max.x) 
				screenputnl(); 
		}else if(r == '\b'){ 
			if(out.pos.x >= out.bwid+MINX){ 
				out.pos.x -= out.bwid; 
				gstring(&gscreen, out.pos, defont, " ", flipD[S]); 
			} 
		}else{ 
			if(out.pos.x >= gscreen.r.max.x-out.bwid) 
				screenputnl(); 
			out.pos = gstring(&gscreen, out.pos, defont, buf, flipD[S]); 
		} 
	} 
	unlock(&printq); 
1991/0730    
} 
 
int 
1991/1228/sys/src/9/pc/vga.c:11,181992/0208/sys/src/9/pc/vga.c:11,18 (short | long)
1991/0730    
 
#define	MINX	8 
 
extern	GFont	defont0; 
GFont		*defont; 
1992/0208    
extern	GSubfont	defont0; 
GSubfont		*defont; 
1991/0730    
 
struct{ 
	Point	pos; 
1991/1228/sys/src/9/pc/vga.c:231,2421992/0208/sys/src/9/pc/vga.c:231,242
1991/1228    
		}else if(r == '\b'){ 
			if(out.pos.x >= out.bwid+MINX){ 
				out.pos.x -= out.bwid; 
				gstring(&gscreen, out.pos, defont, " ", flipD[S]); 
1992/0208    
				gsubfstring(&gscreen, out.pos, defont, " ", flipD[S]); 
1991/1228    
			} 
		}else{ 
			if(out.pos.x >= gscreen.r.max.x-out.bwid) 
				screenputnl(); 
			out.pos = gstring(&gscreen, out.pos, defont, buf, flipD[S]); 
1992/0208    
			out.pos = gsubfstring(&gscreen, out.pos, defont, buf, flipD[S]); 
1991/1228    
		} 
	} 
	unlock(&printq); 
1992/0208/sys/src/9/pc/vga.c:1,51992/0321/sys/src/9/pc/vga.c:1,5 (short | long)
1991/0723    
#include	"u.h" 
#include	"lib.h" 
1992/0321    
#include	"../port/lib.h" 
1991/0723    
#include	"mem.h" 
#include	"dat.h" 
#include	"fns.h" 
1992/0321/sys/src/9/pc/vga.c:187,1921992/0401/sys/src/9/pc/vga.c:187,196 (short | long)
1991/0801    
		*l = (*l<<24) | ((*l>>8)&0x0000ff00) | ((*l<<8)&0x00ff0000) | (*l>>24); 
 
	gbitblt(&gscreen, Pt(0, 0), &gscreen, gscreen.r, flipD[0]); 
1992/0401    
	delay(2000); 
	gbitblt(&gscreen, Pt(0, 0), &gscreen, gscreen.r, flipD[F]); 
	delay(2000); 
	gbitblt(&gscreen, Pt(0, 0), &gscreen, gscreen.r, flipD[0]); 
1991/0730    
	out.pos.x = MINX; 
	out.pos.y = 0; 
	out.bwid = defont0.info[' '].width; 
1992/0401/sys/src/9/pc/vga.c:187,1961992/0402/sys/src/9/pc/vga.c:187,192 (short | long)
1991/0801    
		*l = (*l<<24) | ((*l>>8)&0x0000ff00) | ((*l<<8)&0x00ff0000) | (*l>>24); 
 
	gbitblt(&gscreen, Pt(0, 0), &gscreen, gscreen.r, flipD[0]); 
1992/0401    
	delay(2000); 
	gbitblt(&gscreen, Pt(0, 0), &gscreen, gscreen.r, flipD[F]); 
	delay(2000); 
	gbitblt(&gscreen, Pt(0, 0), &gscreen, gscreen.r, flipD[0]); 
1991/0730    
	out.pos.x = MINX; 
	out.pos.y = 0; 
	out.bwid = defont0.info[' '].width; 
1992/0401/sys/src/9/pc/vga.c:207,2121992/0402/sys/src/9/pc/vga.c:203,210
1991/1228    
	    Rect(0, out.pos.y, gscreen.r.max.x, out.pos.y+2*defont0.height), flipD[0]); 
1991/0730    
} 
 
1992/0402    
Lock screenlock; 
 
1991/0730    
void 
screenputs(char *s, int n) 
{ 
1992/0401/sys/src/9/pc/vga.c:214,2201992/0402/sys/src/9/pc/vga.c:212,218
1991/1228    
	int i; 
	char buf[4]; 
 
	lock(&printq); 
1992/0402    
	lock(&screenlock); 
1991/1228    
	while(n > 0){ 
		i = chartorune(&r, s); 
		if(i == 0){ 
1992/0401/sys/src/9/pc/vga.c:243,2491992/0402/sys/src/9/pc/vga.c:241,247
1992/0208    
			out.pos = gsubfstring(&gscreen, out.pos, defont, buf, flipD[S]); 
1991/1228    
		} 
	} 
	unlock(&printq); 
1992/0402    
	unlock(&screenlock); 
1991/0730    
} 
 
int 
1992/0402/sys/src/9/pc/vga.c:174,1801992/0409/sys/src/9/pc/vga.c:174,179 (short | long)
1991/0730    
	ulong *l; 
1991/0723    
 
1991/1113    
	setmode(&mode12); 
	bigcursor(); 
1991/0929    
 
1991/0727    
	/* 
1991/0801    
	 *  swizzle the font longs. 
1992/0409/sys/src/9/pc/vga.c:66,711992/0414/sys/src/9/pc/vga.c:66,72 (short | long)
1991/1113    
	uchar	attribute[0x15]; 
}; 
 
1992/0414    
#ifdef ORIGINALSAFARI 
1991/0727    
/* 
1991/1113    
 *  640x480 display, 16 bit color 
1991/0727    
 */ 
1992/0409/sys/src/9/pc/vga.c:88,971992/0414/sys/src/9/pc/vga.c:89,123
1991/1113    
	0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 
	0x01, 0x00, 0x0f, 0x00, 0x00, 
}; 
1992/0414    
#else 
/* 
 *  640x480 display, 16 bit color - attempt at SVGA version...ches 
 */ 
VGAmode mode12 =  
{ 
	/* general */ 
	0xe7, 0x00, 0x70, 0x04, 
	/* sequence */ 
	0x03, 0x01, 0x0f, 0x00, 0x06, 
	/* crt */ 
	0x65, 0x4f, 0x50, 0x88, 0x55, 0x9a, 0x09, 0x3e, 
	0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
	0xe8, 0x8b, 0xdf, 0x28, 0x00, 0xe7, 0x04, 0xe3, 
	0xff, 
	/* graphics */ 
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 
	0xff, 
	/* attribute */ 
	0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, 
	0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 
	0x01, 0x00, 0x0f, 0x00, 0x00, 
}; 
#endif 
1991/1113    
 
1991/0724    
void 
1991/1113    
genout(int reg, int val) 
{ 
1992/0414    
delay(1000); 
1991/1113    
	if(reg == 0) 
		outb(EMISCW, val); 
	else if (reg == 1) 
1992/0409/sys/src/9/pc/vga.c:100,1051992/0414/sys/src/9/pc/vga.c:126,135
1991/1113    
void 
1991/0724    
srout(int reg, int val) 
{ 
1992/0414    
	/* 
	 * needed or the screen goes blank on an ultra VGA card 
	 */ 
	delay(1000); 
1991/0724    
	outb(SRX, reg); 
	outb(SR, val); 
} 
1992/0409/sys/src/9/pc/vga.c:112,1171992/0414/sys/src/9/pc/vga.c:142,151
1991/0727    
void 
arout(int reg, int val) 
{ 
1992/0414    
	/* 
	 * if this print is missing, we are left with a blank white screen. 
	 */ 
	print("arout %d %2x\n", reg, val); 
1991/0727    
	inb(0x3DA); 
1991/1211    
	outb(ARW, reg | 0x20); 
	outb(ARW, val); 
1992/0409/sys/src/9/pc/vga.c:119,1241992/0414/sys/src/9/pc/vga.c:153,159
1991/0727    
void 
crout(int reg, int val) 
{ 
1992/0414    
	delay(1000);	/* needed for 16bit VGA path on Ultra SVGA */ 
1991/0727    
	outb(CRX, reg); 
	outb(CR, val); 
} 
1992/0414/sys/src/9/pc/vga.c:110,1161992/0417/sys/src/9/pc/vga.c:110,116 (short | long)
1992/0414    
	/* attribute */ 
	0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, 
	0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 
	0x01, 0x00, 0x0f, 0x00, 0x00, 
1992/0417    
	0x01, 0x07, 0x0f, 0x00, 0x00, 
1992/0414    
}; 
#endif 
1991/1113    
 
1992/0417/sys/src/9/pc/vga.c:108,1231992/0418/sys/src/9/pc/vga.c:108,125 (short | long)
1992/0414    
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0f, 
	0xff, 
	/* attribute */ 
	0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, 
	0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 
1992/0417    
	0x01, 0x07, 0x0f, 0x00, 0x00, 
1992/0418    
	0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 
	0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0d, 0x0f, 
	0x01, 0x10, 0x0f, 0x00, 0x00, 
1992/0414    
}; 
#endif 
1991/1113    
 
1992/0418    
#define TESTDELAY	1 
 
1991/0724    
void 
1991/1113    
genout(int reg, int val) 
{ 
1992/0414    
delay(1000); 
1992/0418    
delay(TESTDELAY); 
1991/1113    
	if(reg == 0) 
		outb(EMISCW, val); 
	else if (reg == 1) 
1992/0417/sys/src/9/pc/vga.c:129,1351992/0418/sys/src/9/pc/vga.c:131,137
1992/0414    
	/* 
	 * needed or the screen goes blank on an ultra VGA card 
	 */ 
	delay(1000); 
1992/0418    
	delay(TESTDELAY); 
1991/0724    
	outb(SRX, reg); 
	outb(SR, val); 
} 
1992/0417/sys/src/9/pc/vga.c:153,1591992/0418/sys/src/9/pc/vga.c:155,161
1991/0727    
void 
crout(int reg, int val) 
{ 
1992/0414    
	delay(1000);	/* needed for 16bit VGA path on Ultra SVGA */ 
1992/0418    
	delay(TESTDELAY);	/* needed for 16bit VGA path on Ultra SVGA */ 
1991/0727    
	outb(CRX, reg); 
	outb(CR, val); 
} 
1992/0417/sys/src/9/pc/vga.c:224,2291992/0418/sys/src/9/pc/vga.c:226,232
1991/0730    
	out.pos.x = MINX; 
	out.pos.y = 0; 
	out.bwid = defont0.info[' '].width; 
1992/0418    
print("PEL Mask Register = %02x\n", inb(0x3c6)&0xff); 
1991/0723    
} 
1991/0727    
 
1991/0730    
void 
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)