ite_hy.c revision 1.3 1 1.3 tsutsui /* $NetBSD: ite_hy.c,v 1.3 2003/11/14 16:52:40 tsutsui 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 WINDOWMOVER hyper_windowmove
93 1.1 thorpej
94 1.1 thorpej #undef charX
95 1.1 thorpej #define charX(ip,c) \
96 1.1 thorpej (((c) % (ip)->cpl) * ((((ip)->ftwidth + 7) / 8) * 8) + (ip)->fontx)
97 1.1 thorpej
98 1.3 tsutsui void hyper_ite_fontinit(struct ite_data *);
99 1.3 tsutsui void hyper_windowmove(struct ite_data *, int, int, int, int, int, int, int);
100 1.1 thorpej
101 1.1 thorpej void
102 1.1 thorpej hyper_init(ip)
103 1.3 tsutsui struct ite_data *ip;
104 1.1 thorpej {
105 1.3 tsutsui struct hyboxfb *regbase = (void *)ip->regbase;
106 1.1 thorpej int width;
107 1.1 thorpej
108 1.1 thorpej ite_fontinfo(ip);
109 1.1 thorpej width = ((ip->ftwidth + 7) / 8) * 8;
110 1.1 thorpej ip->cpl = (ip->fbwidth - ip->dwidth) / width;
111 1.1 thorpej ip->cblanky = ip->fonty + ((128 / ip->cpl) +1) * ip->ftheight;
112 1.1 thorpej
113 1.3 tsutsui regbase->nblank = 0x05;
114 1.1 thorpej
115 1.1 thorpej /*
116 1.1 thorpej * Clear the framebuffer on all planes.
117 1.1 thorpej */
118 1.1 thorpej hyper_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR);
119 1.1 thorpej
120 1.1 thorpej hyper_ite_fontinit(ip);
121 1.1 thorpej
122 1.1 thorpej /*
123 1.1 thorpej * Stash the inverted cursor.
124 1.1 thorpej */
125 1.1 thorpej hyper_windowmove(ip, charY(ip, ' '), charX(ip, ' '),
126 1.1 thorpej ip->cblanky, ip->cblankx, ip->ftheight,
127 1.1 thorpej ip->ftwidth, RR_COPYINVERTED);
128 1.1 thorpej }
129 1.1 thorpej
130 1.1 thorpej void
131 1.1 thorpej hyper_ite_fontinit(ip)
132 1.3 tsutsui struct ite_data *ip;
133 1.1 thorpej {
134 1.3 tsutsui u_char *fbmem, *dp;
135 1.1 thorpej int c, l, b;
136 1.1 thorpej int stride, width;
137 1.1 thorpej
138 1.1 thorpej dp = (u_char *)(getword(ip, getword(ip, FONTROM) + FONTADDR) +
139 1.1 thorpej ip->regbase) + FONTDATA;
140 1.1 thorpej stride = ip->fbwidth >> 3;
141 1.1 thorpej width = (ip->ftwidth + 7) / 8;
142 1.1 thorpej
143 1.1 thorpej for (c = 0; c < 128; c++) {
144 1.1 thorpej fbmem = (u_char *) FBBASE +
145 1.1 thorpej (ip->fonty + (c / ip->cpl) * ip->ftheight) *
146 1.1 thorpej stride;
147 1.1 thorpej fbmem += (ip->fontx >> 3) + (c % ip->cpl) * width;
148 1.1 thorpej for (l = 0; l < ip->ftheight; l++) {
149 1.1 thorpej for (b = 0; b < width; b++) {
150 1.1 thorpej *fbmem++ = *dp;
151 1.1 thorpej dp += 2;
152 1.1 thorpej }
153 1.1 thorpej fbmem -= width;
154 1.1 thorpej fbmem += stride;
155 1.1 thorpej }
156 1.1 thorpej }
157 1.1 thorpej }
158 1.1 thorpej
159 1.1 thorpej void
160 1.1 thorpej hyper_putc(ip, c, dy, dx, mode)
161 1.3 tsutsui struct ite_data *ip;
162 1.3 tsutsui int dy, dx;
163 1.1 thorpej int c, mode;
164 1.1 thorpej {
165 1.1 thorpej hyper_windowmove(ip, charY(ip, c), charX(ip, c),
166 1.1 thorpej dy * ip->ftheight, dx * ip->ftwidth,
167 1.1 thorpej ip->ftheight, ip->ftwidth, RR_COPY);
168 1.1 thorpej }
169 1.1 thorpej
170 1.1 thorpej void
171 1.1 thorpej hyper_cursor(ip, flag)
172 1.3 tsutsui struct ite_data *ip;
173 1.3 tsutsui int flag;
174 1.1 thorpej {
175 1.1 thorpej switch (flag) {
176 1.1 thorpej case MOVE_CURSOR:
177 1.1 thorpej erase_cursor(ip);
178 1.1 thorpej /* fall through ... */
179 1.1 thorpej case DRAW_CURSOR:
180 1.1 thorpej draw_cursor(ip);
181 1.1 thorpej break;
182 1.1 thorpej default:
183 1.1 thorpej erase_cursor(ip);
184 1.1 thorpej break;
185 1.1 thorpej }
186 1.1 thorpej }
187 1.1 thorpej
188 1.1 thorpej void
189 1.1 thorpej hyper_clear(ip, sy, sx, h, w)
190 1.1 thorpej struct ite_data *ip;
191 1.3 tsutsui int sy, sx, h, w;
192 1.1 thorpej {
193 1.1 thorpej hyper_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
194 1.1 thorpej sy * ip->ftheight, sx * ip->ftwidth,
195 1.1 thorpej h * ip->ftheight, w * ip->ftwidth,
196 1.1 thorpej RR_CLEAR);
197 1.1 thorpej }
198 1.1 thorpej
199 1.1 thorpej void
200 1.1 thorpej hyper_scroll(ip, sy, sx, count, dir)
201 1.3 tsutsui struct ite_data *ip;
202 1.3 tsutsui int sy, count;
203 1.3 tsutsui int dir, sx;
204 1.1 thorpej {
205 1.3 tsutsui int dy = sy - count;
206 1.3 tsutsui int height = ip->rows - sy;
207 1.1 thorpej
208 1.1 thorpej hyper_cursor(ip, ERASE_CURSOR);
209 1.1 thorpej
210 1.1 thorpej hyper_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
211 1.1 thorpej dy * ip->ftheight, sx * ip->ftwidth,
212 1.1 thorpej height * ip->ftheight,
213 1.1 thorpej ip->cols * ip->ftwidth, RR_COPY);
214 1.1 thorpej }
215 1.1 thorpej
216 1.1 thorpej #include <hp300/dev/maskbits.h>
217 1.1 thorpej
218 1.1 thorpej /* NOTE:
219 1.1 thorpej * the first element in starttab could be 0xffffffff. making it 0
220 1.1 thorpej * lets us deal with a full first word in the middle loop, rather
221 1.1 thorpej * than having to do the multiple reads and masks that we'd
222 1.1 thorpej * have to do if we thought it was partial.
223 1.1 thorpej */
224 1.3 tsutsui int starttab[32] = {
225 1.1 thorpej 0x00000000,
226 1.1 thorpej 0x7FFFFFFF,
227 1.1 thorpej 0x3FFFFFFF,
228 1.1 thorpej 0x1FFFFFFF,
229 1.1 thorpej 0x0FFFFFFF,
230 1.1 thorpej 0x07FFFFFF,
231 1.1 thorpej 0x03FFFFFF,
232 1.1 thorpej 0x01FFFFFF,
233 1.1 thorpej 0x00FFFFFF,
234 1.1 thorpej 0x007FFFFF,
235 1.1 thorpej 0x003FFFFF,
236 1.1 thorpej 0x001FFFFF,
237 1.1 thorpej 0x000FFFFF,
238 1.1 thorpej 0x0007FFFF,
239 1.1 thorpej 0x0003FFFF,
240 1.1 thorpej 0x0001FFFF,
241 1.1 thorpej 0x0000FFFF,
242 1.1 thorpej 0x00007FFF,
243 1.1 thorpej 0x00003FFF,
244 1.1 thorpej 0x00001FFF,
245 1.1 thorpej 0x00000FFF,
246 1.1 thorpej 0x000007FF,
247 1.1 thorpej 0x000003FF,
248 1.1 thorpej 0x000001FF,
249 1.1 thorpej 0x000000FF,
250 1.1 thorpej 0x0000007F,
251 1.1 thorpej 0x0000003F,
252 1.1 thorpej 0x0000001F,
253 1.1 thorpej 0x0000000F,
254 1.1 thorpej 0x00000007,
255 1.1 thorpej 0x00000003,
256 1.1 thorpej 0x00000001
257 1.3 tsutsui };
258 1.1 thorpej
259 1.3 tsutsui int endtab[32] = {
260 1.1 thorpej 0x00000000,
261 1.1 thorpej 0x80000000,
262 1.1 thorpej 0xC0000000,
263 1.1 thorpej 0xE0000000,
264 1.1 thorpej 0xF0000000,
265 1.1 thorpej 0xF8000000,
266 1.1 thorpej 0xFC000000,
267 1.1 thorpej 0xFE000000,
268 1.1 thorpej 0xFF000000,
269 1.1 thorpej 0xFF800000,
270 1.1 thorpej 0xFFC00000,
271 1.1 thorpej 0xFFE00000,
272 1.1 thorpej 0xFFF00000,
273 1.1 thorpej 0xFFF80000,
274 1.1 thorpej 0xFFFC0000,
275 1.1 thorpej 0xFFFE0000,
276 1.1 thorpej 0xFFFF0000,
277 1.1 thorpej 0xFFFF8000,
278 1.1 thorpej 0xFFFFC000,
279 1.1 thorpej 0xFFFFE000,
280 1.1 thorpej 0xFFFFF000,
281 1.1 thorpej 0xFFFFF800,
282 1.1 thorpej 0xFFFFFC00,
283 1.1 thorpej 0xFFFFFE00,
284 1.1 thorpej 0xFFFFFF00,
285 1.1 thorpej 0xFFFFFF80,
286 1.1 thorpej 0xFFFFFFC0,
287 1.1 thorpej 0xFFFFFFE0,
288 1.1 thorpej 0xFFFFFFF0,
289 1.1 thorpej 0xFFFFFFF8,
290 1.1 thorpej 0xFFFFFFFC,
291 1.1 thorpej 0xFFFFFFFE
292 1.3 tsutsui };
293 1.1 thorpej
294 1.1 thorpej void
295 1.1 thorpej hyper_windowmove(ip, sy, sx, dy, dx, h, w, func)
296 1.1 thorpej struct ite_data *ip;
297 1.1 thorpej int sy, sx, dy, dx, h, w, func;
298 1.1 thorpej {
299 1.1 thorpej int width; /* add to get to same position in next line */
300 1.1 thorpej
301 1.1 thorpej unsigned int *psrcLine, *pdstLine;
302 1.3 tsutsui /* pointers to line with current src and dst */
303 1.3 tsutsui unsigned int *psrc; /* pointer to current src longword */
304 1.3 tsutsui unsigned int *pdst; /* pointer to current dst longword */
305 1.1 thorpej
306 1.3 tsutsui /* following used for looping through a line */
307 1.1 thorpej unsigned int startmask, endmask; /* masks for writing ends of dst */
308 1.1 thorpej int nlMiddle; /* whole longwords in dst */
309 1.3 tsutsui int nl; /* temp copy of nlMiddle */
310 1.3 tsutsui unsigned int tmpSrc;
311 1.3 tsutsui /* place to store full source word */
312 1.3 tsutsui int xoffSrc; /* offset (>= 0, < 32) from which to
313 1.3 tsutsui fetch whole longwords fetched
314 1.3 tsutsui in src */
315 1.1 thorpej int nstart; /* number of ragged bits at start of dst */
316 1.1 thorpej int nend; /* number of ragged bits at end of dst */
317 1.1 thorpej int srcStartOver; /* pulling nstart bits from src
318 1.3 tsutsui overflows into the next word? */
319 1.1 thorpej
320 1.1 thorpej if (h == 0 || w == 0)
321 1.1 thorpej return;
322 1.1 thorpej
323 1.1 thorpej width = ip->fbwidth >> 5;
324 1.1 thorpej psrcLine = ((unsigned int *) ip->fbbase) + (sy * width);
325 1.1 thorpej pdstLine = ((unsigned int *) ip->fbbase) + (dy * width);
326 1.1 thorpej
327 1.1 thorpej /* x direction doesn't matter for < 1 longword */
328 1.3 tsutsui if (w <= 32) {
329 1.3 tsutsui int srcBit, dstBit; /* bit offset of src and dst */
330 1.3 tsutsui
331 1.3 tsutsui pdstLine += (dx >> 5);
332 1.3 tsutsui psrcLine += (sx >> 5);
333 1.3 tsutsui psrc = psrcLine;
334 1.1 thorpej pdst = pdstLine;
335 1.1 thorpej
336 1.3 tsutsui srcBit = sx & 0x1f;
337 1.3 tsutsui dstBit = dx & 0x1f;
338 1.1 thorpej
339 1.3 tsutsui while (h--) {
340 1.3 tsutsui getandputrop(psrc, srcBit, dstBit, w, pdst, func)
341 1.3 tsutsui pdst += width;
342 1.3 tsutsui psrc += width;
343 1.1 thorpej }
344 1.3 tsutsui } else {
345 1.3 tsutsui maskbits(dx, w, startmask, endmask, nlMiddle)
346 1.3 tsutsui if (startmask)
347 1.3 tsutsui nstart = 32 - (dx & 0x1f);
348 1.3 tsutsui else
349 1.3 tsutsui nstart = 0;
350 1.3 tsutsui if (endmask)
351 1.3 tsutsui nend = (dx + w) & 0x1f;
352 1.1 thorpej else
353 1.3 tsutsui nend = 0;
354 1.3 tsutsui
355 1.3 tsutsui xoffSrc = ((sx & 0x1f) + nstart) & 0x1f;
356 1.3 tsutsui srcStartOver = ((sx & 0x1f) + nstart) > 31;
357 1.3 tsutsui
358 1.3 tsutsui pdstLine += (dx >> 5);
359 1.3 tsutsui psrcLine += (sx >> 5);
360 1.3 tsutsui
361 1.3 tsutsui while (h--) {
362 1.3 tsutsui psrc = psrcLine;
363 1.3 tsutsui pdst = pdstLine;
364 1.3 tsutsui
365 1.3 tsutsui if (startmask) {
366 1.3 tsutsui getandputrop(psrc, (sx & 0x1f),
367 1.3 tsutsui (dx & 0x1f), nstart, pdst, func)
368 1.3 tsutsui pdst++;
369 1.3 tsutsui if (srcStartOver)
370 1.3 tsutsui psrc++;
371 1.3 tsutsui }
372 1.3 tsutsui
373 1.3 tsutsui /* special case for aligned operations */
374 1.3 tsutsui if (xoffSrc == 0) {
375 1.3 tsutsui nl = nlMiddle;
376 1.3 tsutsui while (nl--) {
377 1.3 tsutsui DoRop (*pdst, func, *psrc++, *pdst);
378 1.3 tsutsui pdst++;
379 1.3 tsutsui }
380 1.3 tsutsui } else {
381 1.3 tsutsui nl = nlMiddle + 1;
382 1.3 tsutsui while (--nl) {
383 1.3 tsutsui getunalignedword(psrc, xoffSrc, tmpSrc)
384 1.3 tsutsui DoRop(*pdst, func, tmpSrc, *pdst);
385 1.3 tsutsui pdst++;
386 1.3 tsutsui psrc++;
387 1.3 tsutsui }
388 1.3 tsutsui }
389 1.3 tsutsui
390 1.3 tsutsui if (endmask) {
391 1.3 tsutsui getandputrop0(psrc, xoffSrc, nend, pdst, func);
392 1.3 tsutsui }
393 1.1 thorpej
394 1.3 tsutsui pdstLine += width;
395 1.3 tsutsui psrcLine += width;
396 1.1 thorpej }
397 1.1 thorpej }
398 1.1 thorpej }
399 1.1 thorpej #endif
400