1 /* $NetBSD: ite_hy.c,v 1.7 2006/03/19 19:17:01 tsutsui Exp $ */
4 * Copyright (c) 1990, 1993
5 * The Regents of the University of California. All rights reserved.
7 * This code is derived from software contributed to Berkeley by
8 * the Systems Programming Group of the University of Utah Computer
9 * Science Department and Mark Davies of the Department of Computer
10 * Science, Victoria University of Wellington, New Zealand.
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
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. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * from: Utah $Hdr: ite_hy.c 1.1 92/01/22$
38 * @(#)ite_hy.c 8.1 (Berkeley) 6/10/93
42 * Copyright (c) 1988 University of Utah.
44 * This code is derived from software contributed to Berkeley by
45 * the Systems Programming Group of the University of Utah Computer
46 * Science Department and Mark Davies of the Department of Computer
47 * Science, Victoria University of Wellington, New Zealand.
49 * Redistribution and use in source and binary forms, with or without
50 * modification, are permitted provided that the following conditions
52 * 1. Redistributions of source code must retain the above copyright
53 * notice, this list of conditions and the following disclaimer.
54 * 2. Redistributions in binary form must reproduce the above copyright
55 * notice, this list of conditions and the following disclaimer in the
56 * documentation and/or other materials provided with the distribution.
57 * 3. All advertising materials mentioning features or use of this software
58 * must display the following acknowledgement:
59 * This product includes software developed by the University of
60 * California, Berkeley and its contributors.
61 * 4. Neither the name of the University nor the names of its contributors
62 * may be used to endorse or promote products derived from this software
63 * without specific prior written permission.
65 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
66 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
67 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
68 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
69 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
70 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
71 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
72 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
73 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
74 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
77 * from: Utah $Hdr: ite_hy.c 1.1 92/01/22$
79 * @(#)ite_hy.c 8.1 (Berkeley) 6/10/93
84 #include <sys/param.h>
86 #include <hp300/dev/itereg.h>
87 #include <hp300/dev/grf_hyreg.h>
89 #include <hp300/stand/common/samachdep.h>
90 #include <hp300/stand/common/itevar.h>
92 #define WINDOWMOVER hyper_windowmove
96 (((c) % (ip)->cpl) * ((((ip)->ftwidth + 7) / 8) * 8) + (ip)->fontx)
98 void hyper_ite_fontinit(struct ite_data
*);
99 void hyper_windowmove(struct ite_data
*, int, int, int, int, int, int, int);
102 hyper_init(struct ite_data
*ip
)
104 struct hyboxfb
*regbase
= (void *)ip
->regbase
;
108 width
= ((ip
->ftwidth
+ 7) / 8) * 8;
109 ip
->cpl
= (ip
->fbwidth
- ip
->dwidth
) / width
;
110 ip
->cblanky
= ip
->fonty
+ ((128 / ip
->cpl
) +1) * ip
->ftheight
;
112 regbase
->nblank
= 0x05;
115 * Clear the framebuffer on all planes.
117 hyper_windowmove(ip
, 0, 0, 0, 0, ip
->fbheight
, ip
->fbwidth
, RR_CLEAR
);
119 hyper_ite_fontinit(ip
);
122 * Stash the inverted cursor.
124 hyper_windowmove(ip
, charY(ip
, ' '), charX(ip
, ' '),
125 ip
->cblanky
, ip
->cblankx
, ip
->ftheight
,
126 ip
->ftwidth
, RR_COPYINVERTED
);
130 hyper_ite_fontinit(struct ite_data
*ip
)
136 dp
= (u_char
*)(getword(ip
, getword(ip
, FONTROM
) + FONTADDR
) +
137 (char *)ip
->regbase
) + FONTDATA
;
138 stride
= ip
->fbwidth
>> 3;
139 width
= (ip
->ftwidth
+ 7) / 8;
141 for (c
= 0; c
< 128; c
++) {
142 fbmem
= (u_char
*) FBBASE
+
143 (ip
->fonty
+ (c
/ ip
->cpl
) * ip
->ftheight
) *
145 fbmem
+= (ip
->fontx
>> 3) + (c
% ip
->cpl
) * width
;
146 for (l
= 0; l
< ip
->ftheight
; l
++) {
147 for (b
= 0; b
< width
; b
++) {
158 hyper_putc(struct ite_data
*ip
, int c
, int dy
, int dx
, int mode
)
161 hyper_windowmove(ip
, charY(ip
, c
), charX(ip
, c
),
162 dy
* ip
->ftheight
, dx
* ip
->ftwidth
,
163 ip
->ftheight
, ip
->ftwidth
, RR_COPY
);
167 hyper_cursor(struct ite_data
*ip
, int flag
)
173 /* fall through ... */
184 hyper_clear(struct ite_data
*ip
, int sy
, int sx
, int h
, int w
)
187 hyper_windowmove(ip
, sy
* ip
->ftheight
, sx
* ip
->ftwidth
,
188 sy
* ip
->ftheight
, sx
* ip
->ftwidth
,
189 h
* ip
->ftheight
, w
* ip
->ftwidth
,
194 hyper_scroll(struct ite_data
*ip
, int sy
, int sx
, int count
, int dir
)
197 int height
= ip
->rows
- sy
;
199 hyper_cursor(ip
, ERASE_CURSOR
);
201 hyper_windowmove(ip
, sy
* ip
->ftheight
, sx
* ip
->ftwidth
,
202 dy
* ip
->ftheight
, sx
* ip
->ftwidth
,
203 height
* ip
->ftheight
,
204 ip
->cols
* ip
->ftwidth
, RR_COPY
);
207 #include <hp300/dev/maskbits.h>
210 * the first element in starttab could be 0xffffffff. making it 0
211 * lets us deal with a full first word in the middle loop, rather
212 * than having to do the multiple reads and masks that we'd
213 * have to do if we thought it was partial.
286 hyper_windowmove(struct ite_data
*ip
, int sy
, int sx
, int dy
, int dx
,
287 int h
, int w
, int func
)
289 int width
; /* add to get to same position in next line */
291 unsigned int *psrcLine
, *pdstLine
;
292 /* pointers to line with current src and dst */
293 unsigned int *psrc
; /* pointer to current src longword */
294 unsigned int *pdst
; /* pointer to current dst longword */
296 /* following used for looping through a line */
297 unsigned int startmask
, endmask
; /* masks for writing ends of dst */
298 int nlMiddle
; /* whole longwords in dst */
299 int nl
; /* temp copy of nlMiddle */
301 /* place to store full source word */
302 int xoffSrc
; /* offset (>= 0, < 32) from which to
303 fetch whole longwords fetched
305 int nstart
; /* number of ragged bits at start of dst */
306 int nend
; /* number of ragged bits at end of dst */
307 int srcStartOver
; /* pulling nstart bits from src
308 overflows into the next word? */
310 if (h
== 0 || w
== 0)
313 width
= ip
->fbwidth
>> 5;
314 psrcLine
= ((unsigned int *) ip
->fbbase
) + (sy
* width
);
315 pdstLine
= ((unsigned int *) ip
->fbbase
) + (dy
* width
);
317 /* x direction doesn't matter for < 1 longword */
319 int srcBit
, dstBit
; /* bit offset of src and dst */
321 pdstLine
+= (dx
>> 5);
322 psrcLine
+= (sx
>> 5);
330 getandputrop(psrc
, srcBit
, dstBit
, w
, pdst
, func
);
335 maskbits(dx
, w
, startmask
, endmask
, nlMiddle
);
337 nstart
= 32 - (dx
& 0x1f);
341 nend
= (dx
+ w
) & 0x1f;
345 xoffSrc
= ((sx
& 0x1f) + nstart
) & 0x1f;
346 srcStartOver
= ((sx
& 0x1f) + nstart
) > 31;
348 pdstLine
+= (dx
>> 5);
349 psrcLine
+= (sx
>> 5);
356 getandputrop(psrc
, (sx
& 0x1f),
357 (dx
& 0x1f), nstart
, pdst
, func
);
363 /* special case for aligned operations */
367 DoRop (*pdst
, func
, *psrc
++, *pdst
);
373 getunalignedword(psrc
, xoffSrc
, tmpSrc
);
374 DoRop(*pdst
, func
, tmpSrc
, *pdst
);
381 getandputrop0(psrc
, xoffSrc
, nend
, pdst
, func
);