xref: /csrg-svn/sys/hp300/stand/ite_subr.c (revision 41488)
1*41488Smckusick /*
2*41488Smckusick  * Copyright (c) 1988 University of Utah.
3*41488Smckusick  * Copyright (c) 1990 The Regents of the University of California.
4*41488Smckusick  * All rights reserved.
5*41488Smckusick  *
6*41488Smckusick  * This code is derived from software contributed to Berkeley by
7*41488Smckusick  * the Systems Programming Group of the University of Utah Computer
8*41488Smckusick  * Science Department.
9*41488Smckusick  *
10*41488Smckusick  * %sccs.include.redist.c%
11*41488Smckusick  *
12*41488Smckusick  * from: Utah $Hdr: ite_subr.c 1.1 89/02/17$
13*41488Smckusick  *
14*41488Smckusick  *	@(#)ite_subr.c	7.1 (Berkeley) 05/08/90
15*41488Smckusick  */
16*41488Smckusick 
17*41488Smckusick #include "samachdep.h"
18*41488Smckusick 
19*41488Smckusick #ifdef ITECONSOLE
20*41488Smckusick 
21*41488Smckusick #include "param.h"
22*41488Smckusick #include "../hpdev/itevar.h"
23*41488Smckusick #include "../hpdev/itereg.h"
24*41488Smckusick 
25*41488Smckusick ite_devinfo(ip)
26*41488Smckusick 	struct ite_softc *ip;
27*41488Smckusick {
28*41488Smckusick 	struct fontinfo *fi;
29*41488Smckusick 	struct font *fd;
30*41488Smckusick 
31*41488Smckusick 	fi = (struct fontinfo *) ((*FONTROM << 8 | *(FONTROM + 2)) + REGADDR);
32*41488Smckusick 	fd = (struct font *) ((fi->haddr << 8 | fi->laddr) + REGADDR);
33*41488Smckusick 
34*41488Smckusick 	ip->ftheight = fd->fh;
35*41488Smckusick 	ip->ftwidth  = fd->fw;
36*41488Smckusick 	ip->fbwidth  = ITEREGS->fbwidth_h << 8 | ITEREGS->fbwidth_l;
37*41488Smckusick 	ip->fbheight = ITEREGS->fbheight_h << 8 | ITEREGS->fbheight_l;
38*41488Smckusick 	ip->dwidth   = ITEREGS->dispwidth_h << 8 | ITEREGS->dispwidth_l;
39*41488Smckusick 	ip->dheight  = ITEREGS->dispheight_h << 8 | ITEREGS->dispheight_l;
40*41488Smckusick 	ip->rows     = ip->dheight / ip->ftheight;
41*41488Smckusick 	ip->cols     = ip->dwidth / ip->ftwidth;
42*41488Smckusick 
43*41488Smckusick 	if (ip->fbwidth > ip->dwidth) {
44*41488Smckusick 		/*
45*41488Smckusick 		 * Stuff goes to right of display.
46*41488Smckusick 		 */
47*41488Smckusick 		ip->fontx    = ip->dwidth;
48*41488Smckusick 		ip->fonty    = 0;
49*41488Smckusick 		ip->cpl      = (ip->fbwidth - ip->dwidth) / ip->ftwidth;
50*41488Smckusick 		ip->cblankx  = ip->dwidth;
51*41488Smckusick 		ip->cblanky  = ip->fonty + ((128 / ip->cpl) +1) * ip->ftheight;
52*41488Smckusick 	}
53*41488Smckusick 	else {
54*41488Smckusick 		/*
55*41488Smckusick 		 * Stuff goes below the display.
56*41488Smckusick 		 */
57*41488Smckusick 		ip->fontx   = 0;
58*41488Smckusick 		ip->fonty   = ip->dheight;
59*41488Smckusick 		ip->cpl     = ip->fbwidth / ip->ftwidth;
60*41488Smckusick 		ip->cblankx = 0;
61*41488Smckusick 		ip->cblanky = ip->fonty + ((128 / ip->cpl) + 1) * ip->ftheight;
62*41488Smckusick 	}
63*41488Smckusick }
64*41488Smckusick 
65*41488Smckusick ite_fontinit(ip)
66*41488Smckusick 	register struct ite_softc *ip;
67*41488Smckusick {
68*41488Smckusick 	struct fontinfo *fi;
69*41488Smckusick 	struct font *fd;
70*41488Smckusick 	register u_char *fbmem, *dp;
71*41488Smckusick 	register int bn;
72*41488Smckusick 	int c, l, b;
73*41488Smckusick 
74*41488Smckusick 	fi = (struct fontinfo *) ((*FONTROM << 8 | *(FONTROM + 2)) + REGADDR);
75*41488Smckusick 	fd = (struct font *) ((fi->haddr << 8 | fi->laddr) + REGADDR);
76*41488Smckusick 
77*41488Smckusick 	dp = fd->data;
78*41488Smckusick 
79*41488Smckusick 	for (c = 0; c < 128; c++) {
80*41488Smckusick 		fbmem = (u_char *) FBBASE +
81*41488Smckusick 			(ip->fonty + (c / ip->cpl) * ip->ftheight) *
82*41488Smckusick 			ip->fbwidth;
83*41488Smckusick 		fbmem += ip->fontx + (c % ip->cpl) * ip->ftwidth;
84*41488Smckusick 		for (l = 0; l < ip->ftheight; l++) {
85*41488Smckusick 			bn = 7;
86*41488Smckusick 			for (b = 0; b < ip->ftwidth; b++) {
87*41488Smckusick 				if ((1 << bn) & *dp)
88*41488Smckusick 					*fbmem++ = 1;
89*41488Smckusick 				else
90*41488Smckusick 					*fbmem++ = 0;
91*41488Smckusick 				if (--bn < 0) {
92*41488Smckusick 					bn = 7;
93*41488Smckusick 					dp += 2;
94*41488Smckusick 				}
95*41488Smckusick 			}
96*41488Smckusick 			if (bn < 7)
97*41488Smckusick 				dp += 2;
98*41488Smckusick 			fbmem -= ip->ftwidth;
99*41488Smckusick 			fbmem += ip->fbwidth;
100*41488Smckusick 		}
101*41488Smckusick 	}
102*41488Smckusick 
103*41488Smckusick }
104*41488Smckusick #endif
105