xref: /original-bsd/sys/hp300/stand/ite_rb.c (revision 52960f3f)
1 /*
2  * Copyright (c) 1988 University of Utah.
3  * Copyright (c) 1990, 1993
4  *	The Regents of the University of California.  All rights reserved.
5  *
6  * This code is derived from software contributed to Berkeley by
7  * the Systems Programming Group of the University of Utah Computer
8  * Science Department.
9  *
10  * %sccs.include.redist.c%
11  *
12  * from: Utah $Hdr: ite_rb.c 1.6 92/01/20$
13  *
14  *	@(#)ite_rb.c	8.1 (Berkeley) 06/10/93
15  */
16 
17 #include <hp300/stand/samachdep.h>
18 
19 #ifdef ITECONSOLE
20 
21 #include <sys/param.h>
22 #include <hp/dev/itevar.h>
23 #include <hp/dev/itereg.h>
24 
25 #include <hp300/dev/grf_rbreg.h>
26 
27 #define REGBASE		((struct rboxfb *)(ip->regbase))
28 #define WINDOWMOVER	rbox_windowmove
29 
30 rbox_init(ip)
31 	struct ite_softc *ip;
32 {
33 	int i;
34 
35 	rb_waitbusy(ip->regbase);
36 	DELAY(3000);
37 
38 	REGBASE->interrupt = 0x04;
39 	REGBASE->display_enable = 0x01;
40 	REGBASE->video_enable = 0x01;
41 	REGBASE->drive = 0x01;
42 	REGBASE->vdrive = 0x0;
43 
44 	ite_fontinfo(ip);
45 
46 	REGBASE->opwen = 0xFF;
47 
48 	/*
49 	 * Clear the framebuffer.
50 	 */
51 	rbox_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR);
52 	rb_waitbusy(ip->regbase);
53 
54 	for(i = 0; i < 16; i++) {
55 		*(ip->regbase + 0x63c3 + i*4) = 0x0;
56 		*(ip->regbase + 0x6403 + i*4) = 0x0;
57 		*(ip->regbase + 0x6803 + i*4) = 0x0;
58 		*(ip->regbase + 0x6c03 + i*4) = 0x0;
59 		*(ip->regbase + 0x73c3 + i*4) = 0x0;
60 		*(ip->regbase + 0x7403 + i*4) = 0x0;
61 		*(ip->regbase + 0x7803 + i*4) = 0x0;
62 		*(ip->regbase + 0x7c03 + i*4) = 0x0;
63 	}
64 
65 	REGBASE->rep_rule = 0x33;
66 
67 	/*
68 	 * I cannot figure out how to make the blink planes stop. So, we
69 	 * must set both colormaps so that when the planes blink, and
70 	 * the secondary colormap is active, we still get text.
71 	 */
72 	CM1RED[0x00].value = 0x00;
73 	CM1GRN[0x00].value = 0x00;
74 	CM1BLU[0x00].value = 0x00;
75 	CM1RED[0x01].value = 0xFF;
76 	CM1GRN[0x01].value = 0xFF;
77 	CM1BLU[0x01].value = 0xFF;
78 
79 	CM2RED[0x00].value = 0x00;
80 	CM2GRN[0x00].value = 0x00;
81 	CM2BLU[0x00].value = 0x00;
82 	CM2RED[0x01].value = 0xFF;
83 	CM2GRN[0x01].value = 0xFF;
84 	CM2BLU[0x01].value = 0xFF;
85 
86  	REGBASE->blink = 0x00;
87 	REGBASE->write_enable = 0x01;
88 	REGBASE->opwen = 0x00;
89 
90 	ite_fontinit(ip);
91 
92 	/*
93 	 * Stash the inverted cursor.
94 	 */
95 	rbox_windowmove(ip, charY(ip, ' '), charX(ip, ' '),
96 			    ip->cblanky, ip->cblankx, ip->ftheight,
97 			    ip->ftwidth, RR_COPYINVERTED);
98 }
99 
100 rbox_putc(ip, c, dy, dx, mode)
101 	register struct ite_softc *ip;
102         register int dy, dx;
103 	int c, mode;
104 {
105 	rbox_windowmove(ip, charY(ip, c), charX(ip, c),
106 			dy * ip->ftheight, dx * ip->ftwidth,
107 			ip->ftheight, ip->ftwidth, RR_COPY);
108 }
109 
110 rbox_cursor(ip, flag)
111 	register struct ite_softc *ip;
112         register int flag;
113 {
114 	if (flag == DRAW_CURSOR)
115 		draw_cursor(ip)
116 	else if (flag == MOVE_CURSOR) {
117 		erase_cursor(ip)
118 		draw_cursor(ip)
119 	}
120 	else
121 		erase_cursor(ip)
122 }
123 
124 rbox_clear(ip, sy, sx, h, w)
125 	struct ite_softc *ip;
126 	register int sy, sx, h, w;
127 {
128 	rbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
129 			sy * ip->ftheight, sx * ip->ftwidth,
130 			h  * ip->ftheight, w  * ip->ftwidth,
131 			RR_CLEAR);
132 }
133 
134 rbox_scroll(ip, sy, sx, count, dir)
135         register struct ite_softc *ip;
136         register int sy, count;
137         int dir, sx;
138 {
139 	register int dy = sy - count;
140 	register int height = ip->rows - sy;
141 
142 	rbox_cursor(ip, ERASE_CURSOR);
143 
144 	rbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
145 			dy * ip->ftheight, sx * ip->ftwidth,
146 			height * ip->ftheight,
147 			ip->cols * ip->ftwidth, RR_COPY);
148 }
149 
150 rbox_windowmove(ip, sy, sx, dy, dx, h, w, func)
151 	struct ite_softc *ip;
152 	int sy, sx, dy, dx, h, w, func;
153 {
154 	register struct rboxfb *rp = REGBASE;
155 	if (h == 0 || w == 0)
156 		return;
157 
158 	rb_waitbusy(ip->regbase);
159 	rp->rep_rule = func << 4 | func;
160 	rp->source_y = sy;
161 	rp->source_x = sx;
162 	rp->dest_y = dy;
163 	rp->dest_x = dx;
164 	rp->wheight = h;
165 	rp->wwidth  = w;
166 	rp->wmove = 1;
167 }
168 #endif
169