xref: /csrg-svn/sys/hp300/stand/ite_subr.c (revision 63165)
141488Smckusick /*
241488Smckusick  * Copyright (c) 1988 University of Utah.
3*63165Sbostic  * Copyright (c) 1990, 1993
4*63165Sbostic  *	The Regents of the University of California.  All rights reserved.
541488Smckusick  *
641488Smckusick  * This code is derived from software contributed to Berkeley by
741488Smckusick  * the Systems Programming Group of the University of Utah Computer
841488Smckusick  * Science Department.
941488Smckusick  *
1041488Smckusick  * %sccs.include.redist.c%
1141488Smckusick  *
1254073Shibler  * from: Utah $Hdr: ite_subr.c 1.2 92/01/20$
1341488Smckusick  *
14*63165Sbostic  *	@(#)ite_subr.c	8.1 (Berkeley) 06/10/93
1541488Smckusick  */
1641488Smckusick 
1756510Sbostic #include <hp300/stand/samachdep.h>
1841488Smckusick 
1941488Smckusick #ifdef ITECONSOLE
2041488Smckusick 
2156510Sbostic #include <sys/param.h>
2256510Sbostic #include <hp/dev/itevar.h>
2356510Sbostic #include <hp/dev/itereg.h>
2441488Smckusick 
2554073Shibler ite_fontinfo(ip)
2641488Smckusick 	struct ite_softc *ip;
2741488Smckusick {
2854073Shibler 	u_long fontaddr = getword(ip, getword(ip, FONTROM) + FONTADDR);
2941488Smckusick 
3054073Shibler 	ip->ftheight = getbyte(ip, fontaddr + FONTHEIGHT);
3154073Shibler 	ip->ftwidth  = getbyte(ip, fontaddr + FONTWIDTH);
3241488Smckusick 	ip->rows     = ip->dheight / ip->ftheight;
3341488Smckusick 	ip->cols     = ip->dwidth / ip->ftwidth;
3441488Smckusick 
3541488Smckusick 	if (ip->fbwidth > ip->dwidth) {
3641488Smckusick 		/*
3741488Smckusick 		 * Stuff goes to right of display.
3841488Smckusick 		 */
3941488Smckusick 		ip->fontx    = ip->dwidth;
4041488Smckusick 		ip->fonty    = 0;
4141488Smckusick 		ip->cpl      = (ip->fbwidth - ip->dwidth) / ip->ftwidth;
4241488Smckusick 		ip->cblankx  = ip->dwidth;
4341488Smckusick 		ip->cblanky  = ip->fonty + ((128 / ip->cpl) +1) * ip->ftheight;
4441488Smckusick 	}
4541488Smckusick 	else {
4641488Smckusick 		/*
4741488Smckusick 		 * Stuff goes below the display.
4841488Smckusick 		 */
4941488Smckusick 		ip->fontx   = 0;
5041488Smckusick 		ip->fonty   = ip->dheight;
5141488Smckusick 		ip->cpl     = ip->fbwidth / ip->ftwidth;
5241488Smckusick 		ip->cblankx = 0;
5341488Smckusick 		ip->cblanky = ip->fonty + ((128 / ip->cpl) + 1) * ip->ftheight;
5441488Smckusick 	}
5541488Smckusick }
5641488Smckusick 
ite_fontinit(ip)5741488Smckusick ite_fontinit(ip)
5841488Smckusick 	register struct ite_softc *ip;
5941488Smckusick {
6054073Shibler 	int bytewidth = (((ip->ftwidth - 1) / 8) + 1);
6154073Shibler 	int glyphsize = bytewidth * ip->ftheight;
6254073Shibler 	u_char fontbuf[500];
6354073Shibler 	u_char *dp, *fbmem;
6454073Shibler 	int c, i, romp;
6554073Shibler 
6654073Shibler 	romp = getword(ip, getword(ip, FONTROM) + FONTADDR) + FONTDATA;
6754073Shibler 	for (c = 0; c < 128; c++) {
6854073Shibler 		fbmem = (u_char *)
6954073Shibler 		    (FBBASE +
7054073Shibler 		     (ip->fonty + (c / ip->cpl) * ip->ftheight) * ip->fbwidth +
7154073Shibler 		     (ip->fontx + (c % ip->cpl) * ip->ftwidth));
7254073Shibler 		dp = fontbuf;
7354073Shibler 		for (i = 0; i < glyphsize; i++) {
7454073Shibler 			*dp++ = getbyte(ip, romp);
7554073Shibler 			romp += 2;
7654073Shibler 		}
7754073Shibler 		writeglyph(ip, fbmem, fontbuf);
7854073Shibler 	}
7954073Shibler }
8054073Shibler 
8154073Shibler /*
8254073Shibler  * Display independent versions of the readbyte and writeglyph routines.
8354073Shibler  */
8454073Shibler u_char
ite_readbyte(ip,disp)8554073Shibler ite_readbyte(ip, disp)
8654073Shibler 	struct ite_softc *ip;
8754073Shibler 	int disp;
8854073Shibler {
8954073Shibler 	return((u_char) *(((u_char *)ip->regbase) + disp));
9054073Shibler }
9154073Shibler 
ite_writeglyph(ip,fbmem,glyphp)9254073Shibler ite_writeglyph(ip, fbmem, glyphp)
9354073Shibler 	register struct ite_softc *ip;
9454073Shibler 	register u_char *fbmem, *glyphp;
9554073Shibler {
9641488Smckusick 	register int bn;
9741488Smckusick 	int c, l, b;
9841488Smckusick 
9954073Shibler 	for (l = 0; l < ip->ftheight; l++) {
10054073Shibler 		bn = 7;
10154073Shibler 		for (b = 0; b < ip->ftwidth; b++) {
10254073Shibler 			if ((1 << bn) & *glyphp)
10354073Shibler 				*fbmem++ = 1;
10454073Shibler 			else
10554073Shibler 				*fbmem++ = 0;
10654073Shibler 			if (--bn < 0) {
10754073Shibler 				bn = 7;
10854073Shibler 				glyphp++;
10941488Smckusick 			}
11041488Smckusick 		}
11154073Shibler 		if (bn < 7)
11254073Shibler 			glyphp++;
11354073Shibler 		fbmem -= ip->ftwidth;
11454073Shibler 		fbmem += ip->fbwidth;
11541488Smckusick 	}
11641488Smckusick }
11741488Smckusick #endif
118