ite_hy.c revision 1.11 1 1.11 tsutsui /* $NetBSD: ite_hy.c,v 1.11 2011/02/10 11:08:23 tsutsui Exp $ */
2 1.1 thorpej
3 1.1 thorpej /*
4 1.10 rmind * Copyright (c) 1988 University of Utah.
5 1.1 thorpej * Copyright (c) 1990, 1993
6 1.1 thorpej * The Regents of the University of California. All rights reserved.
7 1.2 agc *
8 1.2 agc * This code is derived from software contributed to Berkeley by
9 1.2 agc * the Systems Programming Group of the University of Utah Computer
10 1.2 agc * Science Department and Mark Davies of the Department of Computer
11 1.2 agc * Science, Victoria University of Wellington, New Zealand.
12 1.2 agc *
13 1.2 agc * Redistribution and use in source and binary forms, with or without
14 1.2 agc * modification, are permitted provided that the following conditions
15 1.2 agc * are met:
16 1.2 agc * 1. Redistributions of source code must retain the above copyright
17 1.2 agc * notice, this list of conditions and the following disclaimer.
18 1.2 agc * 2. Redistributions in binary form must reproduce the above copyright
19 1.2 agc * notice, this list of conditions and the following disclaimer in the
20 1.2 agc * documentation and/or other materials provided with the distribution.
21 1.2 agc * 3. Neither the name of the University nor the names of its contributors
22 1.2 agc * may be used to endorse or promote products derived from this software
23 1.2 agc * without specific prior written permission.
24 1.2 agc *
25 1.2 agc * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26 1.2 agc * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 1.2 agc * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 1.2 agc * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 1.2 agc * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 1.2 agc * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 1.2 agc * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 1.2 agc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 1.2 agc * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 1.2 agc * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 1.2 agc * SUCH DAMAGE.
36 1.2 agc *
37 1.2 agc * from: Utah $Hdr: ite_hy.c 1.1 92/01/22$
38 1.2 agc *
39 1.2 agc * @(#)ite_hy.c 8.1 (Berkeley) 6/10/93
40 1.2 agc */
41 1.2 agc
42 1.1 thorpej #ifdef ITECONSOLE
43 1.1 thorpej
44 1.1 thorpej #include <sys/param.h>
45 1.1 thorpej
46 1.9 tsutsui #include <hp300/stand/common/itereg.h>
47 1.9 tsutsui #include <hp300/stand/common/grf_hyreg.h>
48 1.1 thorpej
49 1.1 thorpej #include <hp300/stand/common/samachdep.h>
50 1.1 thorpej #include <hp300/stand/common/itevar.h>
51 1.1 thorpej
52 1.1 thorpej #define WINDOWMOVER hyper_windowmove
53 1.1 thorpej
54 1.1 thorpej #undef charX
55 1.1 thorpej #define charX(ip,c) \
56 1.1 thorpej (((c) % (ip)->cpl) * ((((ip)->ftwidth + 7) / 8) * 8) + (ip)->fontx)
57 1.1 thorpej
58 1.3 tsutsui void hyper_windowmove(struct ite_data *, int, int, int, int, int, int, int);
59 1.1 thorpej
60 1.1 thorpej void
61 1.4 tsutsui hyper_init(struct ite_data *ip)
62 1.1 thorpej {
63 1.3 tsutsui struct hyboxfb *regbase = (void *)ip->regbase;
64 1.1 thorpej int width;
65 1.1 thorpej
66 1.1 thorpej ite_fontinfo(ip);
67 1.1 thorpej width = ((ip->ftwidth + 7) / 8) * 8;
68 1.1 thorpej ip->cpl = (ip->fbwidth - ip->dwidth) / width;
69 1.1 thorpej ip->cblanky = ip->fonty + ((128 / ip->cpl) +1) * ip->ftheight;
70 1.1 thorpej
71 1.3 tsutsui regbase->nblank = 0x05;
72 1.1 thorpej
73 1.1 thorpej /*
74 1.1 thorpej * Clear the framebuffer on all planes.
75 1.1 thorpej */
76 1.1 thorpej hyper_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR);
77 1.1 thorpej
78 1.11 tsutsui ite_fontinit1bpp(ip);
79 1.1 thorpej
80 1.1 thorpej /*
81 1.1 thorpej * Stash the inverted cursor.
82 1.1 thorpej */
83 1.1 thorpej hyper_windowmove(ip, charY(ip, ' '), charX(ip, ' '),
84 1.1 thorpej ip->cblanky, ip->cblankx, ip->ftheight,
85 1.1 thorpej ip->ftwidth, RR_COPYINVERTED);
86 1.1 thorpej }
87 1.1 thorpej
88 1.1 thorpej void
89 1.6 tsutsui hyper_putc(struct ite_data *ip, int c, int dy, int dx, int mode)
90 1.1 thorpej {
91 1.4 tsutsui
92 1.1 thorpej hyper_windowmove(ip, charY(ip, c), charX(ip, c),
93 1.1 thorpej dy * ip->ftheight, dx * ip->ftwidth,
94 1.1 thorpej ip->ftheight, ip->ftwidth, RR_COPY);
95 1.1 thorpej }
96 1.1 thorpej
97 1.1 thorpej void
98 1.4 tsutsui hyper_cursor(struct ite_data *ip, int flag)
99 1.1 thorpej {
100 1.4 tsutsui
101 1.1 thorpej switch (flag) {
102 1.1 thorpej case MOVE_CURSOR:
103 1.1 thorpej erase_cursor(ip);
104 1.1 thorpej /* fall through ... */
105 1.1 thorpej case DRAW_CURSOR:
106 1.1 thorpej draw_cursor(ip);
107 1.1 thorpej break;
108 1.1 thorpej default:
109 1.1 thorpej erase_cursor(ip);
110 1.1 thorpej break;
111 1.1 thorpej }
112 1.1 thorpej }
113 1.1 thorpej
114 1.1 thorpej void
115 1.4 tsutsui hyper_clear(struct ite_data *ip, int sy, int sx, int h, int w)
116 1.1 thorpej {
117 1.4 tsutsui
118 1.1 thorpej hyper_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
119 1.1 thorpej sy * ip->ftheight, sx * ip->ftwidth,
120 1.1 thorpej h * ip->ftheight, w * ip->ftwidth,
121 1.1 thorpej RR_CLEAR);
122 1.1 thorpej }
123 1.1 thorpej
124 1.1 thorpej void
125 1.6 tsutsui hyper_scroll(struct ite_data *ip, int sy, int sx, int count, int dir)
126 1.1 thorpej {
127 1.3 tsutsui int dy = sy - count;
128 1.3 tsutsui int height = ip->rows - sy;
129 1.1 thorpej
130 1.1 thorpej hyper_cursor(ip, ERASE_CURSOR);
131 1.1 thorpej
132 1.1 thorpej hyper_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
133 1.1 thorpej dy * ip->ftheight, sx * ip->ftwidth,
134 1.1 thorpej height * ip->ftheight,
135 1.1 thorpej ip->cols * ip->ftwidth, RR_COPY);
136 1.1 thorpej }
137 1.1 thorpej
138 1.9 tsutsui #include <hp300/stand/common/maskbits.h>
139 1.1 thorpej
140 1.1 thorpej /* NOTE:
141 1.1 thorpej * the first element in starttab could be 0xffffffff. making it 0
142 1.1 thorpej * lets us deal with a full first word in the middle loop, rather
143 1.1 thorpej * than having to do the multiple reads and masks that we'd
144 1.1 thorpej * have to do if we thought it was partial.
145 1.1 thorpej */
146 1.3 tsutsui int starttab[32] = {
147 1.1 thorpej 0x00000000,
148 1.1 thorpej 0x7FFFFFFF,
149 1.1 thorpej 0x3FFFFFFF,
150 1.1 thorpej 0x1FFFFFFF,
151 1.1 thorpej 0x0FFFFFFF,
152 1.1 thorpej 0x07FFFFFF,
153 1.1 thorpej 0x03FFFFFF,
154 1.1 thorpej 0x01FFFFFF,
155 1.1 thorpej 0x00FFFFFF,
156 1.1 thorpej 0x007FFFFF,
157 1.1 thorpej 0x003FFFFF,
158 1.1 thorpej 0x001FFFFF,
159 1.1 thorpej 0x000FFFFF,
160 1.1 thorpej 0x0007FFFF,
161 1.1 thorpej 0x0003FFFF,
162 1.1 thorpej 0x0001FFFF,
163 1.1 thorpej 0x0000FFFF,
164 1.1 thorpej 0x00007FFF,
165 1.1 thorpej 0x00003FFF,
166 1.1 thorpej 0x00001FFF,
167 1.1 thorpej 0x00000FFF,
168 1.1 thorpej 0x000007FF,
169 1.1 thorpej 0x000003FF,
170 1.1 thorpej 0x000001FF,
171 1.1 thorpej 0x000000FF,
172 1.1 thorpej 0x0000007F,
173 1.1 thorpej 0x0000003F,
174 1.1 thorpej 0x0000001F,
175 1.1 thorpej 0x0000000F,
176 1.1 thorpej 0x00000007,
177 1.1 thorpej 0x00000003,
178 1.1 thorpej 0x00000001
179 1.3 tsutsui };
180 1.1 thorpej
181 1.3 tsutsui int endtab[32] = {
182 1.1 thorpej 0x00000000,
183 1.1 thorpej 0x80000000,
184 1.1 thorpej 0xC0000000,
185 1.1 thorpej 0xE0000000,
186 1.1 thorpej 0xF0000000,
187 1.1 thorpej 0xF8000000,
188 1.1 thorpej 0xFC000000,
189 1.1 thorpej 0xFE000000,
190 1.1 thorpej 0xFF000000,
191 1.1 thorpej 0xFF800000,
192 1.1 thorpej 0xFFC00000,
193 1.1 thorpej 0xFFE00000,
194 1.1 thorpej 0xFFF00000,
195 1.1 thorpej 0xFFF80000,
196 1.1 thorpej 0xFFFC0000,
197 1.1 thorpej 0xFFFE0000,
198 1.1 thorpej 0xFFFF0000,
199 1.1 thorpej 0xFFFF8000,
200 1.1 thorpej 0xFFFFC000,
201 1.1 thorpej 0xFFFFE000,
202 1.1 thorpej 0xFFFFF000,
203 1.1 thorpej 0xFFFFF800,
204 1.1 thorpej 0xFFFFFC00,
205 1.1 thorpej 0xFFFFFE00,
206 1.1 thorpej 0xFFFFFF00,
207 1.1 thorpej 0xFFFFFF80,
208 1.1 thorpej 0xFFFFFFC0,
209 1.1 thorpej 0xFFFFFFE0,
210 1.1 thorpej 0xFFFFFFF0,
211 1.1 thorpej 0xFFFFFFF8,
212 1.1 thorpej 0xFFFFFFFC,
213 1.1 thorpej 0xFFFFFFFE
214 1.3 tsutsui };
215 1.1 thorpej
216 1.1 thorpej void
217 1.4 tsutsui hyper_windowmove(struct ite_data *ip, int sy, int sx, int dy, int dx,
218 1.4 tsutsui int h, int w, int func)
219 1.1 thorpej {
220 1.1 thorpej int width; /* add to get to same position in next line */
221 1.1 thorpej
222 1.1 thorpej unsigned int *psrcLine, *pdstLine;
223 1.3 tsutsui /* pointers to line with current src and dst */
224 1.3 tsutsui unsigned int *psrc; /* pointer to current src longword */
225 1.3 tsutsui unsigned int *pdst; /* pointer to current dst longword */
226 1.1 thorpej
227 1.3 tsutsui /* following used for looping through a line */
228 1.1 thorpej unsigned int startmask, endmask; /* masks for writing ends of dst */
229 1.1 thorpej int nlMiddle; /* whole longwords in dst */
230 1.3 tsutsui int nl; /* temp copy of nlMiddle */
231 1.3 tsutsui unsigned int tmpSrc;
232 1.3 tsutsui /* place to store full source word */
233 1.3 tsutsui int xoffSrc; /* offset (>= 0, < 32) from which to
234 1.3 tsutsui fetch whole longwords fetched
235 1.3 tsutsui in src */
236 1.1 thorpej int nstart; /* number of ragged bits at start of dst */
237 1.1 thorpej int nend; /* number of ragged bits at end of dst */
238 1.1 thorpej int srcStartOver; /* pulling nstart bits from src
239 1.3 tsutsui overflows into the next word? */
240 1.1 thorpej
241 1.1 thorpej if (h == 0 || w == 0)
242 1.1 thorpej return;
243 1.1 thorpej
244 1.1 thorpej width = ip->fbwidth >> 5;
245 1.1 thorpej psrcLine = ((unsigned int *) ip->fbbase) + (sy * width);
246 1.1 thorpej pdstLine = ((unsigned int *) ip->fbbase) + (dy * width);
247 1.1 thorpej
248 1.1 thorpej /* x direction doesn't matter for < 1 longword */
249 1.3 tsutsui if (w <= 32) {
250 1.3 tsutsui int srcBit, dstBit; /* bit offset of src and dst */
251 1.3 tsutsui
252 1.3 tsutsui pdstLine += (dx >> 5);
253 1.3 tsutsui psrcLine += (sx >> 5);
254 1.3 tsutsui psrc = psrcLine;
255 1.1 thorpej pdst = pdstLine;
256 1.1 thorpej
257 1.3 tsutsui srcBit = sx & 0x1f;
258 1.3 tsutsui dstBit = dx & 0x1f;
259 1.1 thorpej
260 1.3 tsutsui while (h--) {
261 1.7 tsutsui getandputrop(psrc, srcBit, dstBit, w, pdst, func);
262 1.3 tsutsui pdst += width;
263 1.3 tsutsui psrc += width;
264 1.1 thorpej }
265 1.3 tsutsui } else {
266 1.7 tsutsui maskbits(dx, w, startmask, endmask, nlMiddle);
267 1.3 tsutsui if (startmask)
268 1.3 tsutsui nstart = 32 - (dx & 0x1f);
269 1.3 tsutsui else
270 1.3 tsutsui nstart = 0;
271 1.3 tsutsui if (endmask)
272 1.3 tsutsui nend = (dx + w) & 0x1f;
273 1.1 thorpej else
274 1.3 tsutsui nend = 0;
275 1.3 tsutsui
276 1.3 tsutsui xoffSrc = ((sx & 0x1f) + nstart) & 0x1f;
277 1.3 tsutsui srcStartOver = ((sx & 0x1f) + nstart) > 31;
278 1.3 tsutsui
279 1.3 tsutsui pdstLine += (dx >> 5);
280 1.3 tsutsui psrcLine += (sx >> 5);
281 1.3 tsutsui
282 1.3 tsutsui while (h--) {
283 1.3 tsutsui psrc = psrcLine;
284 1.3 tsutsui pdst = pdstLine;
285 1.3 tsutsui
286 1.3 tsutsui if (startmask) {
287 1.3 tsutsui getandputrop(psrc, (sx & 0x1f),
288 1.7 tsutsui (dx & 0x1f), nstart, pdst, func);
289 1.3 tsutsui pdst++;
290 1.3 tsutsui if (srcStartOver)
291 1.3 tsutsui psrc++;
292 1.3 tsutsui }
293 1.3 tsutsui
294 1.3 tsutsui /* special case for aligned operations */
295 1.3 tsutsui if (xoffSrc == 0) {
296 1.3 tsutsui nl = nlMiddle;
297 1.3 tsutsui while (nl--) {
298 1.3 tsutsui DoRop (*pdst, func, *psrc++, *pdst);
299 1.3 tsutsui pdst++;
300 1.3 tsutsui }
301 1.3 tsutsui } else {
302 1.3 tsutsui nl = nlMiddle + 1;
303 1.3 tsutsui while (--nl) {
304 1.7 tsutsui getunalignedword(psrc, xoffSrc, tmpSrc);
305 1.3 tsutsui DoRop(*pdst, func, tmpSrc, *pdst);
306 1.3 tsutsui pdst++;
307 1.3 tsutsui psrc++;
308 1.3 tsutsui }
309 1.3 tsutsui }
310 1.3 tsutsui
311 1.3 tsutsui if (endmask) {
312 1.3 tsutsui getandputrop0(psrc, xoffSrc, nend, pdst, func);
313 1.3 tsutsui }
314 1.1 thorpej
315 1.3 tsutsui pdstLine += width;
316 1.3 tsutsui psrcLine += width;
317 1.1 thorpej }
318 1.1 thorpej }
319 1.1 thorpej }
320 1.1 thorpej #endif
321