ite_subr.c revision 1.8 1 /* $NetBSD: ite_subr.c,v 1.8 2011/02/10 10:44:22 tsutsui Exp $ */
2
3 /*
4 * Copyright (c) 1988 University of Utah.
5 * Copyright (c) 1990, 1993
6 * The Regents of the University of California. All rights reserved.
7 *
8 * This code is derived from software contributed to Berkeley by
9 * the Systems Programming Group of the University of Utah Computer
10 * Science Department.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * from: Utah $Hdr: ite_subr.c 1.2 92/01/20$
37 *
38 * @(#)ite_subr.c 8.1 (Berkeley) 6/10/93
39 */
40
41 #ifdef ITECONSOLE
42
43 #include <sys/param.h>
44
45 #include <hp300/stand/common/itereg.h>
46
47 #include <hp300/stand/common/samachdep.h>
48 #include <hp300/stand/common/itevar.h>
49
50 static void ite_writeglyph(struct ite_data *, u_char *, u_char *);
51
52 void
53 ite_fontinfo(struct ite_data *ip)
54 {
55 u_long fontaddr = getword(ip, getword(ip, FONTROM) + FONTADDR);
56
57 ip->ftheight = getbyte(ip, fontaddr + FONTHEIGHT);
58 ip->ftwidth = getbyte(ip, fontaddr + FONTWIDTH);
59 ip->rows = ip->dheight / ip->ftheight;
60 ip->cols = ip->dwidth / ip->ftwidth;
61
62 if (ip->fbwidth > ip->dwidth) {
63 /*
64 * Stuff goes to right of display.
65 */
66 ip->fontx = ip->dwidth;
67 ip->fonty = 0;
68 ip->cpl = (ip->fbwidth - ip->dwidth) / ip->ftwidth;
69 ip->cblankx = ip->dwidth;
70 ip->cblanky = ip->fonty + ((128 / ip->cpl) +1) * ip->ftheight;
71 }
72 else {
73 /*
74 * Stuff goes below the display.
75 */
76 ip->fontx = 0;
77 ip->fonty = ip->dheight;
78 ip->cpl = ip->fbwidth / ip->ftwidth;
79 ip->cblankx = 0;
80 ip->cblanky = ip->fonty + ((128 / ip->cpl) + 1) * ip->ftheight;
81 }
82 }
83
84 void
85 ite_fontinit(struct ite_data *ip)
86 {
87 int bytewidth = (((ip->ftwidth - 1) / 8) + 1);
88 int glyphsize = bytewidth * ip->ftheight;
89 u_char fontbuf[500];
90 u_char *dp, *fbmem;
91 int c, i, romp;
92
93 romp = getword(ip, getword(ip, FONTROM) + FONTADDR) + FONTDATA;
94 for (c = 0; c < 128; c++) {
95 fbmem = (u_char *)
96 (FBBASE +
97 (ip->fonty + (c / ip->cpl) * ip->ftheight) * ip->fbwidth +
98 (ip->fontx + (c % ip->cpl) * ip->ftwidth));
99 dp = fontbuf;
100 for (i = 0; i < glyphsize; i++) {
101 *dp++ = getbyte(ip, romp);
102 romp += 2;
103 }
104 ite_writeglyph(ip, fbmem, fontbuf);
105 }
106 }
107
108 static void
109 ite_writeglyph(struct ite_data *ip, u_char *fbmem, u_char *glyphp)
110 {
111 int bn;
112 int l, b;
113
114 for (l = 0; l < ip->ftheight; l++) {
115 bn = 7;
116 for (b = 0; b < ip->ftwidth; b++) {
117 if ((1 << bn) & *glyphp)
118 *fbmem++ = 1;
119 else
120 *fbmem++ = 0;
121 if (--bn < 0) {
122 bn = 7;
123 glyphp++;
124 }
125 }
126 if (bn < 7)
127 glyphp++;
128 fbmem -= ip->ftwidth;
129 fbmem += ip->fbwidth;
130 }
131 }
132 #endif
133