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