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