xref: /csrg-svn/sys/hp300/stand/ite_gb.c (revision 41488)
1*41488Smckusick /*
2*41488Smckusick  * Copyright (c) 1988 University of Utah.
3*41488Smckusick  * Copyright (c) 1990 The Regents of the University of California.
4*41488Smckusick  * All rights reserved.
5*41488Smckusick  *
6*41488Smckusick  * This code is derived from software contributed to Berkeley by
7*41488Smckusick  * the Systems Programming Group of the University of Utah Computer
8*41488Smckusick  * Science Department.
9*41488Smckusick  *
10*41488Smckusick  * %sccs.include.redist.c%
11*41488Smckusick  *
12*41488Smckusick  * from: Utah $Hdr: ite_gb.c 1.8 89/02/23$
13*41488Smckusick  *
14*41488Smckusick  *	@(#)ite_gb.c	7.1 (Berkeley) 05/08/90
15*41488Smckusick  */
16*41488Smckusick 
17*41488Smckusick #include "samachdep.h"
18*41488Smckusick 
19*41488Smckusick #ifdef ITECONSOLE
20*41488Smckusick 
21*41488Smckusick #include "param.h"
22*41488Smckusick 
23*41488Smckusick #include "../hpdev/itevar.h"
24*41488Smckusick #include "../hpdev/itereg.h"
25*41488Smckusick #include "../hpdev/grfvar.h"
26*41488Smckusick #include "../hpdev/grf_gbreg.h"
27*41488Smckusick 
28*41488Smckusick #define REGBASE     	((struct gboxfb *)(ip->regbase))
29*41488Smckusick #define WINDOWMOVER 	gatorbox_windowmove
30*41488Smckusick 
31*41488Smckusick gatorbox_init(ip)
32*41488Smckusick 	register struct ite_softc *ip;
33*41488Smckusick {
34*41488Smckusick 	REGBASE->write_protect = 0x0;
35*41488Smckusick 	REGBASE->interrupt = 0x4;
36*41488Smckusick 	REGBASE->rep_rule = RR_COPY;
37*41488Smckusick 	REGBASE->blink1 = 0xff;
38*41488Smckusick 	REGBASE->blink2 = 0xff;
39*41488Smckusick 	REGBASE->sec_interrupt = 0x01;
40*41488Smckusick 
41*41488Smckusick 	/*
42*41488Smckusick 	 * Set up the color map entries. We use three entries in the
43*41488Smckusick 	 * color map. The first, is for black, the second is for
44*41488Smckusick 	 * white, and the very last entry is for the inverted cursor.
45*41488Smckusick 	 */
46*41488Smckusick 	REGBASE->creg_select = 0x00;
47*41488Smckusick 	REGBASE->cmap_red    = 0x00;
48*41488Smckusick 	REGBASE->cmap_grn    = 0x00;
49*41488Smckusick 	REGBASE->cmap_blu    = 0x00;
50*41488Smckusick 	REGBASE->cmap_write  = 0x00;
51*41488Smckusick 	gbcm_waitbusy(REGADDR);
52*41488Smckusick 
53*41488Smckusick 	REGBASE->creg_select = 0x01;
54*41488Smckusick 	REGBASE->cmap_red    = 0xFF;
55*41488Smckusick 	REGBASE->cmap_grn    = 0xFF;
56*41488Smckusick 	REGBASE->cmap_blu    = 0xFF;
57*41488Smckusick 	REGBASE->cmap_write  = 0x01;
58*41488Smckusick 	gbcm_waitbusy(REGADDR);
59*41488Smckusick 
60*41488Smckusick 	REGBASE->creg_select = 0xFF;
61*41488Smckusick 	REGBASE->cmap_red    = 0xFF;
62*41488Smckusick 	REGBASE->cmap_grn    = 0xFF;
63*41488Smckusick 	REGBASE->cmap_blu    = 0xFF;
64*41488Smckusick 	REGBASE->cmap_write  = 0x01;
65*41488Smckusick 	gbcm_waitbusy(REGADDR);
66*41488Smckusick 
67*41488Smckusick 	ite_devinfo(ip);
68*41488Smckusick 	ite_fontinit(ip);
69*41488Smckusick 
70*41488Smckusick 	/*
71*41488Smckusick 	 * Clear the display. This used to be before the font unpacking
72*41488Smckusick 	 * but it crashes. Figure it out later.
73*41488Smckusick 	 */
74*41488Smckusick 	gatorbox_windowmove(ip, 0, 0, 0, 0, ip->dheight, ip->dwidth, RR_CLEAR);
75*41488Smckusick 	tile_mover_waitbusy(REGADDR);
76*41488Smckusick 
77*41488Smckusick 	/*
78*41488Smckusick 	 * Stash the inverted cursor.
79*41488Smckusick 	 */
80*41488Smckusick 	gatorbox_windowmove(ip, charY(ip, ' '), charX(ip, ' '),
81*41488Smckusick 			    ip->cblanky, ip->cblankx, ip->ftheight,
82*41488Smckusick 			    ip->ftwidth, RR_COPYINVERTED);
83*41488Smckusick }
84*41488Smckusick 
85*41488Smckusick gatorbox_putc(ip, c, dy, dx, mode)
86*41488Smckusick 	register struct ite_softc *ip;
87*41488Smckusick         register int dy, dx;
88*41488Smckusick 	int c, mode;
89*41488Smckusick {
90*41488Smckusick 	gatorbox_windowmove(ip, charY(ip, c), charX(ip, c),
91*41488Smckusick 			    dy * ip->ftheight, dx * ip->ftwidth,
92*41488Smckusick 			    ip->ftheight, ip->ftwidth, RR_COPY);
93*41488Smckusick }
94*41488Smckusick 
95*41488Smckusick gatorbox_cursor(ip, flag)
96*41488Smckusick 	register struct ite_softc *ip;
97*41488Smckusick         register int flag;
98*41488Smckusick {
99*41488Smckusick 	if (flag == DRAW_CURSOR)
100*41488Smckusick 		draw_cursor(ip)
101*41488Smckusick 	else if (flag == MOVE_CURSOR) {
102*41488Smckusick 		erase_cursor(ip)
103*41488Smckusick 		draw_cursor(ip)
104*41488Smckusick 	}
105*41488Smckusick 	else
106*41488Smckusick 		erase_cursor(ip)
107*41488Smckusick }
108*41488Smckusick 
109*41488Smckusick gatorbox_clear(ip, sy, sx, h, w)
110*41488Smckusick 	struct ite_softc *ip;
111*41488Smckusick 	register int sy, sx, h, w;
112*41488Smckusick {
113*41488Smckusick 	gatorbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
114*41488Smckusick 			    sy * ip->ftheight, sx * ip->ftwidth,
115*41488Smckusick 			    h  * ip->ftheight, w  * ip->ftwidth,
116*41488Smckusick 			    RR_CLEAR);
117*41488Smckusick }
118*41488Smckusick 
119*41488Smckusick #define	gatorbox_blockmove(ip, sy, sx, dy, dx, h, w) \
120*41488Smckusick 	gatorbox_windowmove((ip), \
121*41488Smckusick 			    (sy) * ip->ftheight, \
122*41488Smckusick 			    (sx) * ip->ftwidth, \
123*41488Smckusick 			    (dy) * ip->ftheight, \
124*41488Smckusick 			    (dx) * ip->ftwidth, \
125*41488Smckusick 			    (h)  * ip->ftheight, \
126*41488Smckusick 			    (w)  * ip->ftwidth, \
127*41488Smckusick 			    RR_COPY)
128*41488Smckusick 
129*41488Smckusick gatorbox_scroll(ip, sy, sx, count, dir)
130*41488Smckusick         register struct ite_softc *ip;
131*41488Smckusick         register int sy;
132*41488Smckusick         int dir, sx, count;
133*41488Smckusick {
134*41488Smckusick 	register int height, dy, i;
135*41488Smckusick 
136*41488Smckusick 	tile_mover_waitbusy(REGADDR);
137*41488Smckusick 	REGBASE->write_protect = 0x0;
138*41488Smckusick 
139*41488Smckusick 	gatorbox_cursor(ip, ERASE_CURSOR);
140*41488Smckusick 
141*41488Smckusick 	dy = sy - count;
142*41488Smckusick 	height = ip->rows - sy;
143*41488Smckusick 	for (i = 0; i < height; i++)
144*41488Smckusick 		gatorbox_blockmove(ip, sy + i, sx, dy + i, 0, 1, ip->cols);
145*41488Smckusick }
146*41488Smckusick 
147*41488Smckusick gatorbox_windowmove(ip, sy, sx, dy, dx, h, w, mask)
148*41488Smckusick      register struct ite_softc *ip;
149*41488Smckusick      int sy, sx, dy, dx, mask;
150*41488Smckusick      register int h, w;
151*41488Smckusick {
152*41488Smckusick 	register int src, dest;
153*41488Smckusick 
154*41488Smckusick 	src  = (sy * 1024) + sx;	/* upper left corner in pixels */
155*41488Smckusick 	dest = (dy * 1024) + dx;
156*41488Smckusick 
157*41488Smckusick 	tile_mover_waitbusy(REGADDR);
158*41488Smckusick 	REGBASE->width = -(w / 4);
159*41488Smckusick 	REGBASE->height = -(h / 4);
160*41488Smckusick 	if (src < dest)
161*41488Smckusick 		REGBASE->rep_rule = MOVE_DOWN_RIGHT|mask;
162*41488Smckusick 	else {
163*41488Smckusick 		REGBASE->rep_rule = MOVE_UP_LEFT|mask;
164*41488Smckusick 		/*
165*41488Smckusick 		 * Adjust to top of lower right tile of the block.
166*41488Smckusick 		 */
167*41488Smckusick 		src = src + ((h - 4) * 1024) + (w - 4);
168*41488Smckusick 		dest= dest + ((h - 4) * 1024) + (w - 4);
169*41488Smckusick 	}
170*41488Smckusick 	FBBASE[dest] = FBBASE[src];
171*41488Smckusick }
172*41488Smckusick #endif
173