ite_cc.c revision 1.2 1 1.2 mycroft /* $Id: ite_cc.c,v 1.2 1993/08/02 18:33:34 mycroft Exp $ */
2 1.2 mycroft
3 1.1 mw #include "ite.h"
4 1.1 mw #if NITE > 0
5 1.1 mw
6 1.1 mw #include "param.h"
7 1.1 mw #include "conf.h"
8 1.1 mw #include "proc.h"
9 1.1 mw #include "ioctl.h"
10 1.1 mw #include "tty.h"
11 1.1 mw #include "systm.h"
12 1.1 mw
13 1.1 mw #include "itevar.h"
14 1.1 mw
15 1.1 mw #include "machine/cpu.h"
16 1.1 mw
17 1.1 mw /* XXX */
18 1.1 mw #include "grfioctl.h"
19 1.1 mw #include "grfvar.h"
20 1.1 mw #include "grf_ccreg.h"
21 1.1 mw
22 1.1 mw extern unsigned char kernel_font_width, kernel_font_height;
23 1.1 mw extern unsigned char kernel_font_lo, kernel_font_hi;
24 1.1 mw extern unsigned char kernel_font[], kernel_cursor[];
25 1.1 mw
26 1.1 mw
27 1.1 mw customc_init(ip)
28 1.1 mw register struct ite_softc *ip;
29 1.1 mw {
30 1.1 mw struct ccfb *fb;
31 1.1 mw int fboff, fbsize;
32 1.1 mw
33 1.1 mw if (ip->grf == 0)
34 1.1 mw ip->grf = &grf_softc[ip - ite_softc];
35 1.1 mw
36 1.1 mw ip->priv = ip->grf->g_display.gd_regaddr;
37 1.1 mw fb = (struct ccfb *) ip->priv;
38 1.1 mw fbsize = ip->grf->g_display.gd_fbsize;
39 1.1 mw
40 1.1 mw #if 0
41 1.1 mw /* already done in the grf layer */
42 1.1 mw
43 1.1 mw /* clear the display. bzero only likes regions up to 64k, so call multiple times */
44 1.1 mw for (fboff = 0; fboff < fbsize; fboff += 64*1024)
45 1.1 mw bzero (fb->fb + fboff, fbsize - fboff > 64*1024 ? 64*1024 : fbsize - fboff);
46 1.1 mw #endif
47 1.1 mw
48 1.1 mw /* this is a dreadful font, but I don't have an alternative at the moment.. */
49 1.1 mw ip->font = kernel_font;
50 1.1 mw ip->font_lo = kernel_font_lo;
51 1.1 mw ip->font_hi = kernel_font_hi;
52 1.1 mw ip->ftwidth = kernel_font_width;
53 1.1 mw ip->ftheight = kernel_font_height;
54 1.1 mw ip->cursor = kernel_cursor;
55 1.1 mw
56 1.1 mw ip->rows = fb->disp_height / ip->ftheight;
57 1.1 mw ip->cols = fb->disp_width / ip->ftwidth;
58 1.1 mw
59 1.1 mw
60 1.1 mw #if 0
61 1.1 mw printf ("font@%x, cursor@%x\n", ip->font, ip->cursor);
62 1.1 mw dump_copperlist (fb->cop1);
63 1.1 mw dump_copperlist (fb->cop2);
64 1.1 mw #endif
65 1.1 mw }
66 1.1 mw
67 1.1 mw customc_deinit(ip)
68 1.1 mw struct ite_softc *ip;
69 1.1 mw {
70 1.1 mw ip->flags &= ~ITE_INITED;
71 1.1 mw }
72 1.1 mw
73 1.1 mw
74 1.1 mw void static inline
75 1.1 mw customc_windowmove (src, srcx, srcy, srcmod,
76 1.1 mw dst, dstx, dsty, dstmod, h, w, op)
77 1.1 mw unsigned char *src, *dst;
78 1.1 mw unsigned short srcx, srcy, srcmod;
79 1.1 mw unsigned short dstx, dsty, dstmod;
80 1.1 mw unsigned short h, w;
81 1.1 mw unsigned char op;
82 1.1 mw {
83 1.1 mw int i;
84 1.1 mw
85 1.1 mw src += srcmod*srcy + (srcx >> 3);
86 1.1 mw dst += dstmod*dsty + (dstx >> 3);
87 1.1 mw
88 1.1 mw #if 0
89 1.1 mw printf("ccwm: %x-%x-%x-%x-%c\n", src, dst, h, w,
90 1.1 mw op == RR_XOR ? '^' : op == RR_COPY ? '|' : op == RR_CLEAR ? 'C' : 'I');
91 1.1 mw #endif
92 1.1 mw
93 1.1 mw /* currently, only drawing to byte slots is supported... */
94 1.1 mw if ((srcx & 07) || (dstx & 07) || (w & 07))
95 1.1 mw panic ("customc_windowmove: odd offset");
96 1.1 mw
97 1.1 mw w >>= 3;
98 1.1 mw while (h--)
99 1.1 mw {
100 1.1 mw if (src > dst)
101 1.1 mw for (i = 0; i < w; i++)
102 1.1 mw switch (op)
103 1.1 mw {
104 1.1 mw case RR_COPY:
105 1.1 mw dst[i] = src[i];
106 1.1 mw break;
107 1.1 mw
108 1.1 mw case RR_CLEAR:
109 1.1 mw dst[i] = 0;
110 1.1 mw break;
111 1.1 mw
112 1.1 mw case RR_XOR:
113 1.1 mw dst[i] ^= src[i];
114 1.1 mw break;
115 1.1 mw
116 1.1 mw case RR_COPYINVERTED:
117 1.1 mw dst[i] = ~src[i];
118 1.1 mw break;
119 1.1 mw }
120 1.1 mw else
121 1.1 mw for (i = w - 1; i >= 0; i--)
122 1.1 mw switch (op)
123 1.1 mw {
124 1.1 mw case RR_COPY:
125 1.1 mw dst[i] = src[i];
126 1.1 mw break;
127 1.1 mw
128 1.1 mw case RR_CLEAR:
129 1.1 mw dst[i] = 0;
130 1.1 mw break;
131 1.1 mw
132 1.1 mw case RR_XOR:
133 1.1 mw dst[i] ^= src[i];
134 1.1 mw break;
135 1.1 mw
136 1.1 mw case RR_COPYINVERTED:
137 1.1 mw dst[i] = ~src[i];
138 1.1 mw break;
139 1.1 mw }
140 1.1 mw
141 1.1 mw
142 1.1 mw src += srcmod;
143 1.1 mw dst += dstmod;
144 1.1 mw }
145 1.1 mw
146 1.1 mw }
147 1.1 mw
148 1.1 mw
149 1.1 mw customc_putc(ip, c, dy, dx, mode)
150 1.1 mw register struct ite_softc *ip;
151 1.1 mw register int dy, dx;
152 1.1 mw int c, mode;
153 1.1 mw {
154 1.1 mw register int wrr = ((mode == ATTR_INV) ? RR_COPYINVERTED : RR_COPY);
155 1.1 mw struct ccfb *fb = (struct ccfb *) ip->priv;
156 1.1 mw
157 1.1 mw if (c >= ip->font_lo && c <= ip->font_hi)
158 1.1 mw {
159 1.1 mw c -= ip->font_lo;
160 1.1 mw
161 1.1 mw customc_windowmove (ip->font, 0, c * ip->ftheight, 1,
162 1.1 mw fb->fb, fb->fb_x + dx * ip->ftwidth,
163 1.1 mw fb->fb_y + dy * ip->ftheight,
164 1.1 mw fb->fb_width >> 3,
165 1.1 mw ip->ftheight, ip->ftwidth, wrr);
166 1.1 mw }
167 1.1 mw }
168 1.1 mw
169 1.1 mw customc_cursor(ip, flag)
170 1.1 mw register struct ite_softc *ip;
171 1.1 mw register int flag;
172 1.1 mw {
173 1.1 mw struct ccfb *fb = (struct ccfb *) ip->priv;
174 1.1 mw
175 1.1 mw if (flag != DRAW_CURSOR)
176 1.1 mw {
177 1.1 mw /* erase it */
178 1.1 mw customc_windowmove (ip->cursor, 0, 0, 1,
179 1.1 mw fb->fb, fb->fb_x + ip->cursorx * ip->ftwidth,
180 1.1 mw fb->fb_y + ip->cursory * ip->ftheight,
181 1.1 mw fb->fb_width >> 3,
182 1.1 mw ip->ftheight, ip->ftwidth, RR_XOR);
183 1.1 mw }
184 1.1 mw if (flag == DRAW_CURSOR || flag == MOVE_CURSOR)
185 1.1 mw {
186 1.1 mw /* draw it */
187 1.1 mw customc_windowmove (ip->cursor, 0, 0, 1,
188 1.1 mw fb->fb, fb->fb_x + ip->curx * ip->ftwidth,
189 1.1 mw fb->fb_y + ip->cury * ip->ftheight,
190 1.1 mw fb->fb_width >> 3,
191 1.1 mw ip->ftheight, ip->ftwidth, RR_XOR);
192 1.1 mw ip->cursorx = ip->curx;
193 1.1 mw ip->cursory = ip->cury;
194 1.1 mw }
195 1.1 mw }
196 1.1 mw
197 1.1 mw customc_clear(ip, sy, sx, h, w)
198 1.1 mw struct ite_softc *ip;
199 1.1 mw register int sy, sx, h, w;
200 1.1 mw {
201 1.1 mw struct ccfb *fb = (struct ccfb *) ip->priv;
202 1.1 mw
203 1.1 mw customc_windowmove (0, 0, 0, 0,
204 1.1 mw fb->fb, fb->fb_x + sx * ip->ftwidth,
205 1.1 mw fb->fb_y + sy * ip->ftheight,
206 1.1 mw fb->fb_width >> 3,
207 1.1 mw h * ip->ftheight, w * ip->ftwidth, RR_CLEAR);
208 1.1 mw }
209 1.1 mw
210 1.1 mw customc_blockmove(ip, sy, sx, dy, dx, h, w)
211 1.1 mw register struct ite_softc *ip;
212 1.1 mw int sy, sx, dy, dx, h, w;
213 1.1 mw {
214 1.1 mw struct ccfb *fb = (struct ccfb *) ip->priv;
215 1.1 mw
216 1.1 mw customc_windowmove(fb->fb, fb->fb_x + sx * ip->ftwidth,
217 1.1 mw fb->fb_y + sy * ip->ftheight,
218 1.1 mw fb->fb_width >> 3,
219 1.1 mw fb->fb, fb->fb_x + dx * ip->ftwidth,
220 1.1 mw fb->fb_y + dy * ip->ftheight,
221 1.1 mw fb->fb_width >> 3,
222 1.1 mw h * ip->ftheight, w * ip->ftwidth, RR_COPY);
223 1.1 mw }
224 1.1 mw
225 1.1 mw customc_scroll(ip, sy, sx, count, dir)
226 1.1 mw register struct ite_softc *ip;
227 1.1 mw register int sy;
228 1.1 mw int dir, sx, count;
229 1.1 mw {
230 1.1 mw register int height, dy, i;
231 1.1 mw
232 1.1 mw customc_cursor(ip, ERASE_CURSOR);
233 1.1 mw
234 1.1 mw if (dir == SCROLL_UP)
235 1.1 mw {
236 1.1 mw dy = sy - count;
237 1.1 mw height = ip->bottom_margin - sy + 1;
238 1.1 mw for (i = 0; i < height; i++)
239 1.1 mw customc_blockmove(ip, sy + i, sx, dy + i, 0, 1, ip->cols);
240 1.1 mw }
241 1.1 mw else if (dir == SCROLL_DOWN)
242 1.1 mw {
243 1.1 mw dy = sy + count;
244 1.1 mw height = ip->bottom_margin - dy + 1;
245 1.1 mw for (i = (height - 1); i >= 0; i--)
246 1.1 mw customc_blockmove(ip, sy + i, sx, dy + i, 0, 1, ip->cols);
247 1.1 mw }
248 1.1 mw else if (dir == SCROLL_RIGHT)
249 1.1 mw {
250 1.1 mw customc_blockmove(ip, sy, sx, sy, sx + count, 1, ip->cols - (sx + count));
251 1.1 mw }
252 1.1 mw else
253 1.1 mw {
254 1.1 mw customc_blockmove(ip, sy, sx, sy, sx - count, 1, ip->cols - sx);
255 1.1 mw }
256 1.1 mw }
257 1.1 mw
258 1.1 mw #endif
259