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

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

1992/1105/sys/src/9/pc/vga.c:20,421992/1106/sys/src/9/pc/vga.c:20,42 (short | long | prev | next)
1991/0730    
	int	bwid; 
}out; 
 
1992/1106    
int islittle = 1;		/* little endian bit ordering in bytes */ 
 
extern Cursor arrow; 
extern uchar cswizzle[256]; 
 
 
1991/0730    
/* 
 *  screen dimensions 
 */ 
1992/0502    
                 
#define MAXX	640 
#define MAXY	480 
1991/0730    
 
GBitmap	gscreen = 
{ 
	(ulong*)SCREENMEM, 
	0, 
	640/32, 
	0, 
1992/0604    
	{ 0, 0, MAXX, MAXY, }, 
	{ 0, 0, MAXX, MAXY, }, 
1991/0730    
	0 
}; 
1992/1106    
/* 
 *  'soft' screen bitmap 
 */ 
GBitmap	gscreen; 
GBitmap	vgascreen; 
1991/0730    
 
1991/1113    
typedef struct VGAmode	VGAmode; 
struct VGAmode 
1992/1105/sys/src/9/pc/vga.c:71,761992/1106/sys/src/9/pc/vga.c:71,78
1992/1015    
	0x01, 0x10, 0x0f, 0x00, 0x00, 
1992/0414    
}; 
1992/0418    
 
1992/1106    
static Rectangle mbb; 
static Rectangle NULLMBB = {10000, 10000, -10000, -10000}; 
1992/0430    
 
1991/0724    
void 
1991/1113    
genout(int reg, int val) 
1992/1105/sys/src/9/pc/vga.c:224,2371992/1106/sys/src/9/pc/vga.c:226,261
1992/0423    
#endif 
 
void 
1992/0711    
setscreen(int maxx, int maxy, int bpp) 
1992/1106    
setscreen(int maxx, int maxy, int ldepth) 
1992/0711    
{ 
	USED(bpp); 
1992/0603    
	gbitblt(&gscreen, Pt(0, 0), &gscreen, gscreen.r, flipD[S]); 
	gscreen.width = maxx/32; 
1992/1106    
	int len; 
 
	mbb = NULLMBB; 
 
	/* 
	 *  zero hard screen 
	 */ 
	memset((void*)SCREENMEM, 0xff, 64*1024); 
	vgascreen.ldepth = 0; 
	vgascreen.base = (void*)SCREENMEM; 
	vgascreen.width = (maxx*(1<<ldepth))/32; 
	vgascreen.r.max = Pt(maxx, maxy); 
	vgascreen.clipr.max = vgascreen.r.max; 
 
	/* 
	 *  setup new soft screen 
	 */ 
	gscreen.ldepth = ldepth; 
	gscreen.width = (maxx*(1<<ldepth))/32; 
1992/0603    
	gscreen.r.max = Pt(maxx, maxy); 
1992/0604    
	gscreen.clipr.max = gscreen.r.max; 
1992/0603    
	gbitblt(&gscreen, Pt(0, 0), &gscreen, gscreen.r, flipD[0]); 
1992/1106    
	len = gscreen.width * 4 * maxy; 
	gscreen.base = malloc(len); 
	memset((void*)gscreen.base, 0xff, len); 
 
	/* 
	 *  set string pointer to upper left 
	 */ 
1992/0603    
	out.pos.x = MINX; 
	out.pos.y = 0; 
	out.bwid = defont0.info[' '].width; 
1992/1105/sys/src/9/pc/vga.c:246,2711992/1106/sys/src/9/pc/vga.c:270,346
1992/0527    
	setmode(&mode12); 
1991/0929    
 
1991/0727    
	/* 
1991/0801    
	 *  swizzle the font longs. 
1991/0921    
	 *  we do it here since the font is initialized with big 
	 *  endian longs. 
1992/1106    
	 *  arrow is defined as a big endian 
1991/0801    
	 */ 
1992/1106    
	bitreverse(arrow.set, 2*16); 
	bitreverse(arrow.clr, 2*16); 
 
	/* 
	 *  swizzle the font longs.  we do both byte and bit swizzling 
	 *  since the font is initialized with big endian longs. 
	 */ 
1991/0801    
	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); 
1992/0603    
	setscreen(MAXX, MAXY, 1); 
1992/1106    
	bitreverse((uchar*)defont->bits->base, 
		defont->bits->width*BY2WD*Dy(defont->bits->r)); 
 
	/* 
	 *  set up 'soft' and hard screens 
	 */ 
	if(conf.maxx == 0) 
		conf.maxx = MAXX; 
	if(conf.maxy == 0) 
		conf.maxy = MAXY; 
 
	setscreen(conf.maxx, conf.maxy, conf.ldepth); 
1991/0723    
} 
1991/0727    
 
1992/1106    
/* 
 *  collect changes to the 'soft' screen 
 */ 
1991/0730    
void 
1992/1106    
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; 
	screenupdate(); 
} 
 
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; 
	screenupdate(); 
} 
 
void 
1991/1228    
screenputnl(void) 
1991/0730    
{ 
1992/1106    
	Rectangle r; 
 
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]); 
1992/1106    
	r = Rect(0, out.pos.y, gscreen.r.max.x, out.pos.y+2*defont0.height); 
	gbitblt(&gscreen, r.min, &gscreen, r, flipD[0]); 
	mbbrect(r); 
	screenupdate(); 
1991/0730    
} 
 
1992/0402    
Lock screenlock; 
1992/1105/sys/src/9/pc/vga.c:275,2821992/1106/sys/src/9/pc/vga.c:350,359
1991/0730    
{ 
1991/1228    
	Rune r; 
	int i; 
1992/1106    
	Rectangle rs; 
1991/1228    
	char buf[4]; 
 
1992/1106    
	rs.min = Pt(0, out.pos.y); 
1991/1228    
	while(n > 0){ 
		i = chartorune(&r, s); 
		if(i == 0){ 
1992/1105/sys/src/9/pc/vga.c:305,3101992/1106/sys/src/9/pc/vga.c:382,391
1992/0208    
			out.pos = gsubfstring(&gscreen, out.pos, defont, buf, flipD[S]); 
1991/1228    
		} 
	} 
1992/1106    
	rs.max = Pt(gscreen.r.max.x, out.pos.y+defont0.height); 
	unlock(&screenlock); 
	mbbrect(rs); 
	screenupdate(); 
1991/0730    
} 
 
int 
1992/1105/sys/src/9/pc/vga.c:313,3191992/1106/sys/src/9/pc/vga.c:394,438
1991/0730    
	return 1;	/* bits per pixel */ 
} 
 
1992/1106    
 
/* 
 *  copy litte endian soft screen to big endian hard screen 
 */ 
1991/0730    
void 
1992/1106    
screenupdate(void) 
{ 
	uchar *sp, *hp, *se; 
	int y, len, inc; 
	Rectangle r=mbb; 
 
	if(Dy(r) < 0) 
		return; 
 
	sp = (uchar*)gaddr(&gscreen, r.min); 
	hp = (uchar*)gaddr(&vgascreen, r.min); 
 
	len = (r.max.x * (1<<gscreen.ldepth) + 31)/32 
		- (r.min.x * (1<<gscreen.ldepth))/32; 
	len *= BY2WD; 
 
	inc = gscreen.width * BY2WD - len; 
 
	for (y = r.min.y; y < r.max.y; y++){ 
		for(se = sp + len; sp < se;) 
			*hp++ = cswizzle[*sp++]; 
		sp += inc; 
		hp += inc; 
	} 
	mbb = NULLMBB; 
} 
 
void 
mousescreenupdate(void) 
{ 
	screenupdate(); 
} 
 
void 
1991/0730    
getcolor(ulong p, ulong *pr, ulong *pg, ulong *pb) 
{ 
	ulong ans; 
1992/1105/sys/src/9/pc/vga.c:374,4291992/1106/sys/src/9/pc/vga.c:493,503
1991/1113    
		0x61, 0xf0, 0x60, 0xe0, 0x40, 0x40, 0x00, 0x00,  
	}, 
}; 
1992/1106    
 
1991/1113    
void 
bigcursor(void) 
{ 
	extern Cursor arrow; 
                 
	memmove(&arrow, &fatarrow, sizeof(fatarrow)); 
1992/1106    
	bitreverse(arrow.set, 2*16); 
	bitreverse(arrow.clr, 2*16); 
1991/0730    
} 
1992/1105    
                 
/* 
 *  collect changes to the 'soft' screen 
 */ 
static Rectangle mbb; 
                 
void 
mbbrect(Rectangle r) 
{ 
	if(!islcd) 
		return; 
	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(!islcd) 
		return; 
	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; 
} 
                 
void 
screenupdate(void) 
{ 
} 
                 
void 
mousescreenupdate(void) 
{ 
} 
                 


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