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