xref: /original-bsd/sys/hp300/stand/ite_subr.c (revision bacd16ee)
1 /*
2  * Copyright (c) 1988 University of Utah.
3  * Copyright (c) 1990, 1993
4  *	The Regents of the University of California.  All rights reserved.
5  *
6  * This code is derived from software contributed to Berkeley by
7  * the Systems Programming Group of the University of Utah Computer
8  * Science Department.
9  *
10  * %sccs.include.redist.c%
11  *
12  * from: Utah $Hdr: ite_subr.c 1.2 92/01/20$
13  *
14  *	@(#)ite_subr.c	8.1 (Berkeley) 06/10/93
15  */
16 
17 #include <hp300/stand/samachdep.h>
18 
19 #ifdef ITECONSOLE
20 
21 #include <sys/param.h>
22 #include <hp/dev/itevar.h>
23 #include <hp/dev/itereg.h>
24 
25 ite_fontinfo(ip)
26 	struct ite_softc *ip;
27 {
28 	u_long fontaddr = getword(ip, getword(ip, FONTROM) + FONTADDR);
29 
30 	ip->ftheight = getbyte(ip, fontaddr + FONTHEIGHT);
31 	ip->ftwidth  = getbyte(ip, fontaddr + FONTWIDTH);
32 	ip->rows     = ip->dheight / ip->ftheight;
33 	ip->cols     = ip->dwidth / ip->ftwidth;
34 
35 	if (ip->fbwidth > ip->dwidth) {
36 		/*
37 		 * Stuff goes to right of display.
38 		 */
39 		ip->fontx    = ip->dwidth;
40 		ip->fonty    = 0;
41 		ip->cpl      = (ip->fbwidth - ip->dwidth) / ip->ftwidth;
42 		ip->cblankx  = ip->dwidth;
43 		ip->cblanky  = ip->fonty + ((128 / ip->cpl) +1) * ip->ftheight;
44 	}
45 	else {
46 		/*
47 		 * Stuff goes below the display.
48 		 */
49 		ip->fontx   = 0;
50 		ip->fonty   = ip->dheight;
51 		ip->cpl     = ip->fbwidth / ip->ftwidth;
52 		ip->cblankx = 0;
53 		ip->cblanky = ip->fonty + ((128 / ip->cpl) + 1) * ip->ftheight;
54 	}
55 }
56 
57 ite_fontinit(ip)
58 	register struct ite_softc *ip;
59 {
60 	int bytewidth = (((ip->ftwidth - 1) / 8) + 1);
61 	int glyphsize = bytewidth * ip->ftheight;
62 	u_char fontbuf[500];
63 	u_char *dp, *fbmem;
64 	int c, i, romp;
65 
66 	romp = getword(ip, getword(ip, FONTROM) + FONTADDR) + FONTDATA;
67 	for (c = 0; c < 128; c++) {
68 		fbmem = (u_char *)
69 		    (FBBASE +
70 		     (ip->fonty + (c / ip->cpl) * ip->ftheight) * ip->fbwidth +
71 		     (ip->fontx + (c % ip->cpl) * ip->ftwidth));
72 		dp = fontbuf;
73 		for (i = 0; i < glyphsize; i++) {
74 			*dp++ = getbyte(ip, romp);
75 			romp += 2;
76 		}
77 		writeglyph(ip, fbmem, fontbuf);
78 	}
79 }
80 
81 /*
82  * Display independent versions of the readbyte and writeglyph routines.
83  */
84 u_char
85 ite_readbyte(ip, disp)
86 	struct ite_softc *ip;
87 	int disp;
88 {
89 	return((u_char) *(((u_char *)ip->regbase) + disp));
90 }
91 
92 ite_writeglyph(ip, fbmem, glyphp)
93 	register struct ite_softc *ip;
94 	register u_char *fbmem, *glyphp;
95 {
96 	register int bn;
97 	int c, l, b;
98 
99 	for (l = 0; l < ip->ftheight; l++) {
100 		bn = 7;
101 		for (b = 0; b < ip->ftwidth; b++) {
102 			if ((1 << bn) & *glyphp)
103 				*fbmem++ = 1;
104 			else
105 				*fbmem++ = 0;
106 			if (--bn < 0) {
107 				bn = 7;
108 				glyphp++;
109 			}
110 		}
111 		if (bn < 7)
112 			glyphp++;
113 		fbmem -= ip->ftwidth;
114 		fbmem += ip->fbwidth;
115 	}
116 }
117 #endif
118