ite_subr.c revision 1.7 1 /* $NetBSD: ite_subr.c,v 1.7 2011/02/08 20:20:14 rmind 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 void
51 ite_fontinfo(struct ite_data *ip)
52 {
53 u_long fontaddr = getword(ip, getword(ip, FONTROM) + FONTADDR);
54
55 ip->ftheight = getbyte(ip, fontaddr + FONTHEIGHT);
56 ip->ftwidth = getbyte(ip, fontaddr + FONTWIDTH);
57 ip->rows = ip->dheight / ip->ftheight;
58 ip->cols = ip->dwidth / ip->ftwidth;
59
60 if (ip->fbwidth > ip->dwidth) {
61 /*
62 * Stuff goes to right of display.
63 */
64 ip->fontx = ip->dwidth;
65 ip->fonty = 0;
66 ip->cpl = (ip->fbwidth - ip->dwidth) / ip->ftwidth;
67 ip->cblankx = ip->dwidth;
68 ip->cblanky = ip->fonty + ((128 / ip->cpl) +1) * ip->ftheight;
69 }
70 else {
71 /*
72 * Stuff goes below the display.
73 */
74 ip->fontx = 0;
75 ip->fonty = ip->dheight;
76 ip->cpl = ip->fbwidth / ip->ftwidth;
77 ip->cblankx = 0;
78 ip->cblanky = ip->fonty + ((128 / ip->cpl) + 1) * ip->ftheight;
79 }
80 }
81
82 void
83 ite_fontinit(struct ite_data *ip)
84 {
85 int bytewidth = (((ip->ftwidth - 1) / 8) + 1);
86 int glyphsize = bytewidth * ip->ftheight;
87 u_char fontbuf[500];
88 u_char *dp, *fbmem;
89 int c, i, romp;
90
91 romp = getword(ip, getword(ip, FONTROM) + FONTADDR) + FONTDATA;
92 for (c = 0; c < 128; c++) {
93 fbmem = (u_char *)
94 (FBBASE +
95 (ip->fonty + (c / ip->cpl) * ip->ftheight) * ip->fbwidth +
96 (ip->fontx + (c % ip->cpl) * ip->ftwidth));
97 dp = fontbuf;
98 for (i = 0; i < glyphsize; i++) {
99 *dp++ = getbyte(ip, romp);
100 romp += 2;
101 }
102 writeglyph(ip, fbmem, fontbuf);
103 }
104 }
105
106 /*
107 * Display independent versions of the readbyte and writeglyph routines.
108 */
109 u_char
110 ite_readbyte(struct ite_data *ip, int disp)
111 {
112
113 return (u_char)*(((u_char *)ip->regbase) + disp);
114 }
115
116 void
117 ite_writeglyph(struct ite_data *ip, u_char *fbmem, u_char *glyphp)
118 {
119 int bn;
120 int l, b;
121
122 for (l = 0; l < ip->ftheight; l++) {
123 bn = 7;
124 for (b = 0; b < ip->ftwidth; b++) {
125 if ((1 << bn) & *glyphp)
126 *fbmem++ = 1;
127 else
128 *fbmem++ = 0;
129 if (--bn < 0) {
130 bn = 7;
131 glyphp++;
132 }
133 }
134 if (bn < 7)
135 glyphp++;
136 fbmem -= ip->ftwidth;
137 fbmem += ip->fbwidth;
138 }
139 }
140 #endif
141