Home | History | Annotate | Line # | Download | only in common
ite_gb.c revision 1.2
      1 /*	$NetBSD: ite_gb.c,v 1.2 2003/08/07 16:27:41 agc Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1990, 1993
      5  *	The Regents of the University of California.  All rights reserved.
      6  *
      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.
     10  *
     11  * Redistribution and use in source and binary forms, with or without
     12  * modification, are permitted provided that the following conditions
     13  * are met:
     14  * 1. Redistributions of source code must retain the above copyright
     15  *    notice, this list of conditions and the following disclaimer.
     16  * 2. Redistributions in binary form must reproduce the above copyright
     17  *    notice, this list of conditions and the following disclaimer in the
     18  *    documentation and/or other materials provided with the distribution.
     19  * 3. Neither the name of the University nor the names of its contributors
     20  *    may be used to endorse or promote products derived from this software
     21  *    without specific prior written permission.
     22  *
     23  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     26  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     33  * SUCH DAMAGE.
     34  *
     35  * from: Utah $Hdr: ite_gb.c 1.9 92/01/20$
     36  *
     37  *	@(#)ite_gb.c	8.1 (Berkeley) 6/10/93
     38  */
     39 /*
     40  * Copyright (c) 1988 University of Utah.
     41  *
     42  * This code is derived from software contributed to Berkeley by
     43  * the Systems Programming Group of the University of Utah Computer
     44  * Science Department.
     45  *
     46  * Redistribution and use in source and binary forms, with or without
     47  * modification, are permitted provided that the following conditions
     48  * are met:
     49  * 1. Redistributions of source code must retain the above copyright
     50  *    notice, this list of conditions and the following disclaimer.
     51  * 2. Redistributions in binary form must reproduce the above copyright
     52  *    notice, this list of conditions and the following disclaimer in the
     53  *    documentation and/or other materials provided with the distribution.
     54  * 3. All advertising materials mentioning features or use of this software
     55  *    must display the following acknowledgement:
     56  *	This product includes software developed by the University of
     57  *	California, Berkeley and its contributors.
     58  * 4. Neither the name of the University nor the names of its contributors
     59  *    may be used to endorse or promote products derived from this software
     60  *    without specific prior written permission.
     61  *
     62  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     63  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     64  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     65  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     66  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     67  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     68  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     69  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     70  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     71  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     72  * SUCH DAMAGE.
     73  *
     74  * from: Utah $Hdr: ite_gb.c 1.9 92/01/20$
     75  *
     76  *	@(#)ite_gb.c	8.1 (Berkeley) 6/10/93
     77  */
     78 
     79 #ifdef ITECONSOLE
     80 
     81 #include <sys/param.h>
     82 
     83 #include <hp300/dev/itereg.h>
     84 #include <hp300/dev/grf_gbreg.h>
     85 
     86 #include <hp300/stand/common/samachdep.h>
     87 #include <hp300/stand/common/itevar.h>
     88 
     89 #define REGBASE     	((struct gboxfb *)(ip->regbase))
     90 #define WINDOWMOVER 	gbox_windowmove
     91 
     92 void	gbox_windowmove __P((struct ite_data *, int, int, int, int,
     93 	    int, int, int));
     94 
     95 void
     96 gbox_init(ip)
     97 	register struct ite_data *ip;
     98 {
     99 	REGBASE->write_protect = 0x0;
    100 	REGBASE->interrupt = 0x4;
    101 	REGBASE->rep_rule = RR_COPY;
    102 	REGBASE->blink1 = 0xff;
    103 	REGBASE->blink2 = 0xff;
    104 	REGBASE->sec_interrupt = 0x01;
    105 
    106 	/*
    107 	 * Set up the color map entries. We use three entries in the
    108 	 * color map. The first, is for black, the second is for
    109 	 * white, and the very last entry is for the inverted cursor.
    110 	 */
    111 	REGBASE->creg_select = 0x00;
    112 	REGBASE->cmap_red    = 0x00;
    113 	REGBASE->cmap_grn    = 0x00;
    114 	REGBASE->cmap_blu    = 0x00;
    115 	REGBASE->cmap_write  = 0x00;
    116 	gbcm_waitbusy(ip->regbase);
    117 
    118 	REGBASE->creg_select = 0x01;
    119 	REGBASE->cmap_red    = 0xFF;
    120 	REGBASE->cmap_grn    = 0xFF;
    121 	REGBASE->cmap_blu    = 0xFF;
    122 	REGBASE->cmap_write  = 0x01;
    123 	gbcm_waitbusy(ip->regbase);
    124 
    125 	REGBASE->creg_select = 0xFF;
    126 	REGBASE->cmap_red    = 0xFF;
    127 	REGBASE->cmap_grn    = 0xFF;
    128 	REGBASE->cmap_blu    = 0xFF;
    129 	REGBASE->cmap_write  = 0x01;
    130 	gbcm_waitbusy(ip->regbase);
    131 
    132 	ite_fontinfo(ip);
    133 	ite_fontinit(ip);
    134 
    135 	/*
    136 	 * Clear the display. This used to be before the font unpacking
    137 	 * but it crashes. Figure it out later.
    138 	 */
    139 	gbox_windowmove(ip, 0, 0, 0, 0, ip->dheight, ip->dwidth, RR_CLEAR);
    140 	tile_mover_waitbusy(ip->regbase);
    141 
    142 	/*
    143 	 * Stash the inverted cursor.
    144 	 */
    145 	gbox_windowmove(ip, charY(ip, ' '), charX(ip, ' '),
    146 			ip->cblanky, ip->cblankx, ip->ftheight,
    147 			ip->ftwidth, RR_COPYINVERTED);
    148 }
    149 
    150 void
    151 gbox_putc(ip, c, dy, dx, mode)
    152 	register struct ite_data *ip;
    153         register int dy, dx;
    154 	int c, mode;
    155 {
    156 	gbox_windowmove(ip, charY(ip, c), charX(ip, c),
    157 			dy * ip->ftheight, dx * ip->ftwidth,
    158 			ip->ftheight, ip->ftwidth, RR_COPY);
    159 }
    160 
    161 void
    162 gbox_cursor(ip, flag)
    163 	register struct ite_data *ip;
    164         register int flag;
    165 {
    166 	if (flag == DRAW_CURSOR)
    167 		draw_cursor(ip)
    168 	else if (flag == MOVE_CURSOR) {
    169 		erase_cursor(ip)
    170 		draw_cursor(ip)
    171 	}
    172 	else
    173 		erase_cursor(ip)
    174 }
    175 
    176 void
    177 gbox_clear(ip, sy, sx, h, w)
    178 	struct ite_data *ip;
    179 	register int sy, sx, h, w;
    180 {
    181 	gbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
    182 			sy * ip->ftheight, sx * ip->ftwidth,
    183 			h  * ip->ftheight, w  * ip->ftwidth,
    184 			RR_CLEAR);
    185 }
    186 
    187 #define	gbox_blockmove(ip, sy, sx, dy, dx, h, w) \
    188 	gbox_windowmove((ip), \
    189 			(sy) * ip->ftheight, \
    190 			(sx) * ip->ftwidth, \
    191 			(dy) * ip->ftheight, \
    192 			(dx) * ip->ftwidth, \
    193 			(h)  * ip->ftheight, \
    194 			(w)  * ip->ftwidth, \
    195 			RR_COPY)
    196 
    197 void
    198 gbox_scroll(ip, sy, sx, count, dir)
    199         register struct ite_data *ip;
    200         register int sy;
    201         int dir, sx, count;
    202 {
    203 	register int height, dy, i;
    204 
    205 	tile_mover_waitbusy(ip->regbase);
    206 	REGBASE->write_protect = 0x0;
    207 
    208 	gbox_cursor(ip, ERASE_CURSOR);
    209 
    210 	dy = sy - count;
    211 	height = ip->rows - sy;
    212 	for (i = 0; i < height; i++)
    213 		gbox_blockmove(ip, sy + i, sx, dy + i, 0, 1, ip->cols);
    214 }
    215 
    216 void
    217 gbox_windowmove(ip, sy, sx, dy, dx, h, w, mask)
    218      register struct ite_data *ip;
    219      int sy, sx, dy, dx, mask;
    220      register int h, w;
    221 {
    222 	register int src, dest;
    223 
    224 	src  = (sy * 1024) + sx;	/* upper left corner in pixels */
    225 	dest = (dy * 1024) + dx;
    226 
    227 	tile_mover_waitbusy(ip->regbase);
    228 	REGBASE->width = -(w / 4);
    229 	REGBASE->height = -(h / 4);
    230 	if (src < dest)
    231 		REGBASE->rep_rule = MOVE_DOWN_RIGHT|mask;
    232 	else {
    233 		REGBASE->rep_rule = MOVE_UP_LEFT|mask;
    234 		/*
    235 		 * Adjust to top of lower right tile of the block.
    236 		 */
    237 		src = src + ((h - 4) * 1024) + (w - 4);
    238 		dest= dest + ((h - 4) * 1024) + (w - 4);
    239 	}
    240 	FBBASE[dest] = FBBASE[src];
    241 }
    242 #endif
    243