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