ite_gb.c revision 1.1.60.1 1 /* $NetBSD: ite_gb.c,v 1.1.60.1 2004/08/03 10:34:37 skrll Exp $ */
2
3 /*
4 * Copyright (c) 1990, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * This code is derived from software contributed to Berkeley by
8 * the Systems Programming Group of the University of Utah Computer
9 * Science Department.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 *
35 * from: Utah $Hdr: ite_gb.c 1.9 92/01/20$
36 *
37 * @(#)ite_gb.c 8.1 (Berkeley) 6/10/93
38 */
39 /*
40 * Copyright (c) 1988 University of Utah.
41 *
42 * This code is derived from software contributed to Berkeley by
43 * the Systems Programming Group of the University of Utah Computer
44 * Science Department.
45 *
46 * Redistribution and use in source and binary forms, with or without
47 * modification, are permitted provided that the following conditions
48 * are met:
49 * 1. Redistributions of source code must retain the above copyright
50 * notice, this list of conditions and the following disclaimer.
51 * 2. Redistributions in binary form must reproduce the above copyright
52 * notice, this list of conditions and the following disclaimer in the
53 * documentation and/or other materials provided with the distribution.
54 * 3. All advertising materials mentioning features or use of this software
55 * must display the following acknowledgement:
56 * This product includes software developed by the University of
57 * California, Berkeley and its contributors.
58 * 4. Neither the name of the University nor the names of its contributors
59 * may be used to endorse or promote products derived from this software
60 * without specific prior written permission.
61 *
62 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
63 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
64 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
65 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
66 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
67 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
68 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
69 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
70 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
71 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
72 * SUCH DAMAGE.
73 *
74 * from: Utah $Hdr: ite_gb.c 1.9 92/01/20$
75 *
76 * @(#)ite_gb.c 8.1 (Berkeley) 6/10/93
77 */
78
79 #ifdef ITECONSOLE
80
81 #include <sys/param.h>
82
83 #include <hp300/dev/itereg.h>
84 #include <hp300/dev/grf_gbreg.h>
85
86 #include <hp300/stand/common/samachdep.h>
87 #include <hp300/stand/common/itevar.h>
88
89 #define WINDOWMOVER gbox_windowmove
90
91 void gbox_windowmove(struct ite_data *, int, int, int, int, int, int, int);
92
93 void
94 gbox_init(ip)
95 struct ite_data *ip;
96 {
97 struct gboxfb *regbase = (void *)ip->regbase;
98
99 regbase->write_protect = 0x0;
100 regbase->interrupt = 0x4;
101 regbase->rep_rule = RR_COPY;
102 regbase->blink1 = 0xff;
103 regbase->blink2 = 0xff;
104 regbase->sec_interrupt = 0x01;
105
106 /*
107 * Set up the color map entries. We use three entries in the
108 * color map. The first, is for black, the second is for
109 * white, and the very last entry is for the inverted cursor.
110 */
111 regbase->creg_select = 0x00;
112 regbase->cmap_red = 0x00;
113 regbase->cmap_grn = 0x00;
114 regbase->cmap_blu = 0x00;
115 regbase->cmap_write = 0x00;
116 gbcm_waitbusy(regbase);
117
118 regbase->creg_select = 0x01;
119 regbase->cmap_red = 0xFF;
120 regbase->cmap_grn = 0xFF;
121 regbase->cmap_blu = 0xFF;
122 regbase->cmap_write = 0x01;
123 gbcm_waitbusy(regbase);
124
125 regbase->creg_select = 0xFF;
126 regbase->cmap_red = 0xFF;
127 regbase->cmap_grn = 0xFF;
128 regbase->cmap_blu = 0xFF;
129 regbase->cmap_write = 0x01;
130 gbcm_waitbusy(regbase);
131
132 ite_fontinfo(ip);
133 ite_fontinit(ip);
134
135 /*
136 * Clear the display. This used to be before the font unpacking
137 * but it crashes. Figure it out later.
138 */
139 gbox_windowmove(ip, 0, 0, 0, 0, ip->dheight, ip->dwidth, RR_CLEAR);
140 tile_mover_waitbusy(regbase);
141
142 /*
143 * Stash the inverted cursor.
144 */
145 gbox_windowmove(ip, charY(ip, ' '), charX(ip, ' '),
146 ip->cblanky, ip->cblankx, ip->ftheight,
147 ip->ftwidth, RR_COPYINVERTED);
148 }
149
150 void
151 gbox_putc(ip, c, dy, dx, mode)
152 struct ite_data *ip;
153 int dy, dx;
154 int c, mode;
155 {
156 gbox_windowmove(ip, charY(ip, c), charX(ip, c),
157 dy * ip->ftheight, dx * ip->ftwidth,
158 ip->ftheight, ip->ftwidth, RR_COPY);
159 }
160
161 void
162 gbox_cursor(ip, flag)
163 struct ite_data *ip;
164 int flag;
165 {
166 if (flag == DRAW_CURSOR)
167 draw_cursor(ip)
168 else if (flag == MOVE_CURSOR) {
169 erase_cursor(ip)
170 draw_cursor(ip)
171 } else
172 erase_cursor(ip)
173 }
174
175 void
176 gbox_clear(ip, sy, sx, h, w)
177 struct ite_data *ip;
178 int sy, sx, h, w;
179 {
180 gbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
181 sy * ip->ftheight, sx * ip->ftwidth,
182 h * ip->ftheight, w * ip->ftwidth,
183 RR_CLEAR);
184 }
185
186 #define gbox_blockmove(ip, sy, sx, dy, dx, h, w) \
187 gbox_windowmove((ip), \
188 (sy) * ip->ftheight, \
189 (sx) * ip->ftwidth, \
190 (dy) * ip->ftheight, \
191 (dx) * ip->ftwidth, \
192 (h) * ip->ftheight, \
193 (w) * ip->ftwidth, \
194 RR_COPY)
195
196 void
197 gbox_scroll(ip, sy, sx, count, dir)
198 struct ite_data *ip;
199 int sy;
200 int dir, sx, count;
201 {
202 struct gboxfb *regbase = (void *)ip->regbase;
203 int height, dy, i;
204
205 tile_mover_waitbusy(regbase);
206 regbase->write_protect = 0x0;
207
208 gbox_cursor(ip, ERASE_CURSOR);
209
210 dy = sy - count;
211 height = ip->rows - sy;
212 for (i = 0; i < height; i++)
213 gbox_blockmove(ip, sy + i, sx, dy + i, 0, 1, ip->cols);
214 }
215
216 void
217 gbox_windowmove(ip, sy, sx, dy, dx, h, w, mask)
218 struct ite_data *ip;
219 int sy, sx, dy, dx, mask;
220 int h, w;
221 {
222 struct gboxfb *regbase = (void *)ip->regbase;
223 int src, dest;
224
225 src = (sy * 1024) + sx; /* upper left corner in pixels */
226 dest = (dy * 1024) + dx;
227
228 tile_mover_waitbusy(regbase);
229 regbase->width = -(w / 4);
230 regbase->height = -(h / 4);
231 if (src < dest)
232 regbase->rep_rule = MOVE_DOWN_RIGHT|mask;
233 else {
234 regbase->rep_rule = MOVE_UP_LEFT|mask;
235 /*
236 * Adjust to top of lower right tile of the block.
237 */
238 src = src + ((h - 4) * 1024) + (w - 4);
239 dest= dest + ((h - 4) * 1024) + (w - 4);
240 }
241 FBBASE[dest] = FBBASE[src];
242 }
243 #endif
244