xref: /csrg-svn/sys/hp300/stand/ite_gb.c (revision 54073)
141488Smckusick /*
241488Smckusick  * Copyright (c) 1988 University of Utah.
341488Smckusick  * Copyright (c) 1990 The Regents of the University of California.
441488Smckusick  * All rights reserved.
541488Smckusick  *
641488Smckusick  * This code is derived from software contributed to Berkeley by
741488Smckusick  * the Systems Programming Group of the University of Utah Computer
841488Smckusick  * Science Department.
941488Smckusick  *
1041488Smckusick  * %sccs.include.redist.c%
1141488Smckusick  *
12*54073Shibler  * from: Utah $Hdr: ite_gb.c 1.9 92/01/20$
1341488Smckusick  *
14*54073Shibler  *	@(#)ite_gb.c	7.3 (Berkeley) 06/18/92
1541488Smckusick  */
1641488Smckusick 
1741488Smckusick #include "samachdep.h"
1841488Smckusick 
1941488Smckusick #ifdef ITECONSOLE
2041488Smckusick 
2145790Sbostic #include "sys/param.h"
2241488Smckusick 
23*54073Shibler #include "hp/dev/itevar.h"
24*54073Shibler #include "hp/dev/itereg.h"
2545790Sbostic #include "../dev/grf_gbreg.h"
2641488Smckusick 
2741488Smckusick #define REGBASE     	((struct gboxfb *)(ip->regbase))
28*54073Shibler #define WINDOWMOVER 	gbox_windowmove
2941488Smckusick 
30*54073Shibler gbox_init(ip)
3141488Smckusick 	register struct ite_softc *ip;
3241488Smckusick {
3341488Smckusick 	REGBASE->write_protect = 0x0;
3441488Smckusick 	REGBASE->interrupt = 0x4;
3541488Smckusick 	REGBASE->rep_rule = RR_COPY;
3641488Smckusick 	REGBASE->blink1 = 0xff;
3741488Smckusick 	REGBASE->blink2 = 0xff;
3841488Smckusick 	REGBASE->sec_interrupt = 0x01;
3941488Smckusick 
4041488Smckusick 	/*
4141488Smckusick 	 * Set up the color map entries. We use three entries in the
4241488Smckusick 	 * color map. The first, is for black, the second is for
4341488Smckusick 	 * white, and the very last entry is for the inverted cursor.
4441488Smckusick 	 */
4541488Smckusick 	REGBASE->creg_select = 0x00;
4641488Smckusick 	REGBASE->cmap_red    = 0x00;
4741488Smckusick 	REGBASE->cmap_grn    = 0x00;
4841488Smckusick 	REGBASE->cmap_blu    = 0x00;
4941488Smckusick 	REGBASE->cmap_write  = 0x00;
50*54073Shibler 	gbcm_waitbusy(ip->regbase);
5141488Smckusick 
5241488Smckusick 	REGBASE->creg_select = 0x01;
5341488Smckusick 	REGBASE->cmap_red    = 0xFF;
5441488Smckusick 	REGBASE->cmap_grn    = 0xFF;
5541488Smckusick 	REGBASE->cmap_blu    = 0xFF;
5641488Smckusick 	REGBASE->cmap_write  = 0x01;
57*54073Shibler 	gbcm_waitbusy(ip->regbase);
5841488Smckusick 
5941488Smckusick 	REGBASE->creg_select = 0xFF;
6041488Smckusick 	REGBASE->cmap_red    = 0xFF;
6141488Smckusick 	REGBASE->cmap_grn    = 0xFF;
6241488Smckusick 	REGBASE->cmap_blu    = 0xFF;
6341488Smckusick 	REGBASE->cmap_write  = 0x01;
64*54073Shibler 	gbcm_waitbusy(ip->regbase);
6541488Smckusick 
66*54073Shibler 	ite_fontinfo(ip);
6741488Smckusick 	ite_fontinit(ip);
6841488Smckusick 
6941488Smckusick 	/*
7041488Smckusick 	 * Clear the display. This used to be before the font unpacking
7141488Smckusick 	 * but it crashes. Figure it out later.
7241488Smckusick 	 */
73*54073Shibler 	gbox_windowmove(ip, 0, 0, 0, 0, ip->dheight, ip->dwidth, RR_CLEAR);
74*54073Shibler 	tile_mover_waitbusy(ip->regbase);
7541488Smckusick 
7641488Smckusick 	/*
7741488Smckusick 	 * Stash the inverted cursor.
7841488Smckusick 	 */
79*54073Shibler 	gbox_windowmove(ip, charY(ip, ' '), charX(ip, ' '),
80*54073Shibler 			ip->cblanky, ip->cblankx, ip->ftheight,
81*54073Shibler 			ip->ftwidth, RR_COPYINVERTED);
8241488Smckusick }
8341488Smckusick 
84*54073Shibler gbox_putc(ip, c, dy, dx, mode)
8541488Smckusick 	register struct ite_softc *ip;
8641488Smckusick         register int dy, dx;
8741488Smckusick 	int c, mode;
8841488Smckusick {
89*54073Shibler 	gbox_windowmove(ip, charY(ip, c), charX(ip, c),
90*54073Shibler 			dy * ip->ftheight, dx * ip->ftwidth,
91*54073Shibler 			ip->ftheight, ip->ftwidth, RR_COPY);
9241488Smckusick }
9341488Smckusick 
94*54073Shibler gbox_cursor(ip, flag)
9541488Smckusick 	register struct ite_softc *ip;
9641488Smckusick         register int flag;
9741488Smckusick {
9841488Smckusick 	if (flag == DRAW_CURSOR)
9941488Smckusick 		draw_cursor(ip)
10041488Smckusick 	else if (flag == MOVE_CURSOR) {
10141488Smckusick 		erase_cursor(ip)
10241488Smckusick 		draw_cursor(ip)
10341488Smckusick 	}
10441488Smckusick 	else
10541488Smckusick 		erase_cursor(ip)
10641488Smckusick }
10741488Smckusick 
108*54073Shibler gbox_clear(ip, sy, sx, h, w)
10941488Smckusick 	struct ite_softc *ip;
11041488Smckusick 	register int sy, sx, h, w;
11141488Smckusick {
112*54073Shibler 	gbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
113*54073Shibler 			sy * ip->ftheight, sx * ip->ftwidth,
114*54073Shibler 			h  * ip->ftheight, w  * ip->ftwidth,
115*54073Shibler 			RR_CLEAR);
11641488Smckusick }
11741488Smckusick 
118*54073Shibler #define	gbox_blockmove(ip, sy, sx, dy, dx, h, w) \
119*54073Shibler 	gbox_windowmove((ip), \
120*54073Shibler 			(sy) * ip->ftheight, \
121*54073Shibler 			(sx) * ip->ftwidth, \
122*54073Shibler 			(dy) * ip->ftheight, \
123*54073Shibler 			(dx) * ip->ftwidth, \
124*54073Shibler 			(h)  * ip->ftheight, \
125*54073Shibler 			(w)  * ip->ftwidth, \
126*54073Shibler 			RR_COPY)
12741488Smckusick 
128*54073Shibler gbox_scroll(ip, sy, sx, count, dir)
12941488Smckusick         register struct ite_softc *ip;
13041488Smckusick         register int sy;
13141488Smckusick         int dir, sx, count;
13241488Smckusick {
13341488Smckusick 	register int height, dy, i;
13441488Smckusick 
135*54073Shibler 	tile_mover_waitbusy(ip->regbase);
13641488Smckusick 	REGBASE->write_protect = 0x0;
13741488Smckusick 
138*54073Shibler 	gbox_cursor(ip, ERASE_CURSOR);
13941488Smckusick 
14041488Smckusick 	dy = sy - count;
14141488Smckusick 	height = ip->rows - sy;
14241488Smckusick 	for (i = 0; i < height; i++)
143*54073Shibler 		gbox_blockmove(ip, sy + i, sx, dy + i, 0, 1, ip->cols);
14441488Smckusick }
14541488Smckusick 
146*54073Shibler gbox_windowmove(ip, sy, sx, dy, dx, h, w, mask)
14741488Smckusick      register struct ite_softc *ip;
14841488Smckusick      int sy, sx, dy, dx, mask;
14941488Smckusick      register int h, w;
15041488Smckusick {
15141488Smckusick 	register int src, dest;
15241488Smckusick 
15341488Smckusick 	src  = (sy * 1024) + sx;	/* upper left corner in pixels */
15441488Smckusick 	dest = (dy * 1024) + dx;
15541488Smckusick 
156*54073Shibler 	tile_mover_waitbusy(ip->regbase);
15741488Smckusick 	REGBASE->width = -(w / 4);
15841488Smckusick 	REGBASE->height = -(h / 4);
15941488Smckusick 	if (src < dest)
16041488Smckusick 		REGBASE->rep_rule = MOVE_DOWN_RIGHT|mask;
16141488Smckusick 	else {
16241488Smckusick 		REGBASE->rep_rule = MOVE_UP_LEFT|mask;
16341488Smckusick 		/*
16441488Smckusick 		 * Adjust to top of lower right tile of the block.
16541488Smckusick 		 */
16641488Smckusick 		src = src + ((h - 4) * 1024) + (w - 4);
16741488Smckusick 		dest= dest + ((h - 4) * 1024) + (w - 4);
16841488Smckusick 	}
16941488Smckusick 	FBBASE[dest] = FBBASE[src];
17041488Smckusick }
17141488Smckusick #endif
172