ite_cv.c revision 1.1 1 /* $NetBSD: ite_cv.c,v 1.1 1996/03/02 14:28:51 veego Exp $ */
2
3 /*
4 * Copyright (c) 1995 Michael Teske
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Christian E. Hopps
18 * and Michael Teske.
19 * 4. The name of the author may not be used to endorse or promote products
20 * derived from this software without specific prior written permission
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34 /*
35 * This code is based on ite_cc.c from Christian E. Hopps.
36 */
37
38 #include "grfcv.h"
39 #if NGRFCV > 0
40
41 #include <sys/param.h>
42 #include <sys/conf.h>
43 #include <sys/proc.h>
44 #include <sys/device.h>
45 #include <sys/ioctl.h>
46 #include <sys/tty.h>
47 #include <sys/systm.h>
48 #include <sys/queue.h>
49 #include <sys/termios.h>
50 #include <sys/malloc.h>
51 #include <dev/cons.h>
52 #include <machine/cpu.h>
53 #include <amiga/dev/itevar.h>
54 #include <amiga/dev/iteioctl.h>
55 #include <amiga/amiga/device.h>
56 #include <amiga/dev/grfioctl.h>
57 #include <amiga/dev/grfvar.h>
58 #include <amiga/dev/grf_cvreg.h>
59
60
61 #ifndef KFONT_CUSTOM
62 #ifdef KFONT_8X11
63 #define kernel_font_width kernel_font_width_8x11
64 #define kernel_font_height kernel_font_height_8x11
65 #define kernel_font_baseline kernel_font_baseline_8x11
66 #define kernel_font_boldsmear kernel_font_boldsmear_8x11
67 #define kernel_font_lo kernel_font_lo_8x11
68 #define kernel_font_hi kernel_font_hi_8x11
69 #define kernel_font kernel_font_8x11
70 #define kernel_cursor kernel_cursor_8x11
71 #else
72 #define kernel_font_width kernel_font_width_8x8
73 #define kernel_font_height kernel_font_height_8x8
74 #define kernel_font_baseline kernel_font_baseline_8x8
75 #define kernel_font_boldsmear kernel_font_boldsmear_8x8
76 #define kernel_font_lo kernel_font_lo_8x8
77 #define kernel_font_hi kernel_font_hi_8x8
78 #define kernel_font kernel_font_8x8
79 #define kernel_cursor kernel_cursor_8x8
80 #endif
81 #endif
82
83 extern u_char kernel_font_width, kernel_font_height, kernel_font_baseline;
84 extern short kernel_font_boldsmear;
85 extern u_char kernel_font_lo, kernel_font_hi;
86 extern u_char kernel_font[], kernel_cursor[];
87
88
89 /*
90 * This is what ip->priv points to;
91 * it contains local variables for CV64 ite in gfx mode.
92 */
93 #define MAXCOLS 200 /* Does someone use more than this? */
94 #define MAXROWS 200
95
96 struct ite_priv {
97 u_int rowc[MAXROWS]; /* row coordinates */
98 u_int colc[MAXCOLS]; /* column coods */
99 u_long row_bytes;
100 u_long cursor_opt;
101 u_int row_offset; /* the row offset */
102 u_short width; /* the framebuffer width */
103 u_short height;
104 u_short underline; /* where the underline goes */
105 u_short ft_x; /* the font width */
106 u_short ft_y; /* the font height */
107 u_short font_srcx[256]; /* the font source */
108 u_short font_srcy[256];
109 };
110 typedef struct ite_priv ipriv_t;
111
112 void cv_load_font __P((struct ite_softc *));
113 void cv_ite_init __P((struct ite_softc *));
114 void cv_ite_deinit __P((struct ite_softc *));
115 void cv_inv_rect __P((volatile caddr_t, u_short, u_short, u_short, u_short));
116 static void cv_cursor __P((struct ite_softc *, int));
117 static inline void cv_blt_font __P((volatile caddr_t, int, int, int,
118 int, int, int, int, int, int, int));
119 void cv_uline __P((volatile caddr_t, int, int, int, int));
120 void cv_putc_nm __P((struct ite_softc *, int, int, int));
121 void cv_putc_ul __P((struct ite_softc *, int, int, int));
122 void cv_putc_bd __P((struct ite_softc *, int, int, int));
123 void cv_putc_bd_ul __P((struct ite_softc *, int, int, int));
124 void cv_putc_in __P((struct ite_softc *, int, int, int));
125 void cv_putc_ul_in __P((struct ite_softc *, int, int, int));
126 void cv_putc_bd_in __P((struct ite_softc *, int, int, int));
127 void cv_putc_bd_ul_in __P((struct ite_softc *, int, int, int));
128 static void cv_putc __P((struct ite_softc *, int, int, int, int));
129 void cv_clr_rect __P((volatile caddr_t, u_short, u_short, u_short, u_short));
130 static void cv_clear __P((struct ite_softc *, int, int, int, int));
131 void cv_bitblt __P((volatile caddr_t, int, int, int, int, int, int));
132 static void cv_scroll __P((struct ite_softc *, int, int, int, int));
133
134
135 /*
136 * called from grf_cv to return console priority
137 */
138 int
139 grfcv_cnprobe()
140 {
141 static int done;
142 int rv;
143
144 if (done == 0)
145 #ifdef CV64CONSOLE
146 rv = CN_INTERNAL;
147 #else
148 rv = CN_DEAD;
149 #endif
150 else
151 #ifdef CV64CONSOLE
152 rv = CN_NORMAL;
153 #else
154 rv = CN_DEAD;
155 #endif
156 done = 1;
157 return(rv);
158 }
159
160
161 /*
162 * called from grf_cv to init ite portion of
163 * grf_softc struct
164 */
165 void
166 grfcv_iteinit(gp)
167 struct grf_softc *gp;
168 {
169 gp->g_itecursor = cv_cursor;
170 gp->g_iteputc = cv_putc;
171 gp->g_iteclear = cv_clear;
172 gp->g_itescroll = cv_scroll;
173 gp->g_iteinit = cv_ite_init;
174 gp->g_itedeinit = cv_ite_deinit;
175 }
176
177
178 /*
179 * Load font into display memory (behind visible area!)
180 * Could be faster, but it's called only on ite init, so who cares?
181 */
182 void
183 cv_load_font(ip)
184 register struct ite_softc *ip;
185 {
186 int w, h;
187 int i,j,k,l;
188 int ncol;
189 volatile caddr_t a, font_loc, ba, fb;
190 ipriv_t *cvi;
191
192 ba = (volatile caddr_t)ip->grf->g_regkva;
193 fb = (volatile caddr_t)ip->grf->g_fbkva;
194
195 cvi = ip->priv;
196 w = cvi->width;
197 h = cvi->height + 30; /* 30 lines space, to be sure:-) */
198
199 font_loc = (volatile caddr_t)ip->grf->g_fbkva + w*h;
200 ncol = ip->cols;
201
202 if (ncol == 0)
203 return;
204 a = font_loc;
205 j=0;
206 for (i = 0 ;i <= ip->font_hi - ip->font_lo; i++) {
207
208 /* Font location in memory */
209 a = font_loc+(i%ncol)*ip->ftwidth+(i/ncol)*w*ip->ftheight;
210
211 /* P2C conversion */
212 for (k=0; k < ip->ftheight; k++) {
213 for (l = ip->ftwidth - 1; l >= 0; l--) {
214 /* XXX depends on fwidth = 8 !!!!! */
215 if (ip->font[i*ip->ftheight+k] & (1 << l))
216 *a++ = 1;
217 else
218 *a++ = 0;
219 }
220 a += w - ip->ftwidth; /* next line */
221 }
222 }
223
224 /* set up the font source */
225 for (i = 0; i <= ip->font_hi; i++) {
226 j = i - ip->font_lo;
227 if (i < ip->font_lo) {
228 cvi->font_srcx[i] = 0;
229 cvi->font_srcy[i] = h ;
230 } else {
231 cvi->font_srcx[i] = (j%ncol) * ip->ftwidth;
232 cvi->font_srcy[i] = h + (j/ncol)*ip->ftheight;
233 }
234 }
235
236 /* set up column and row coordinates */
237
238 if (ip->cols > MAXCOLS)
239 panic ("ite_cv: too many columns");
240 if (ip->rows > MAXROWS)
241 panic ("ite_cv: too many rows");
242
243 for (i = 0; i <= ip->cols; i++)
244 cvi->colc[i] = i * ip->ftwidth;
245 for (i = 0; i <= ip->rows; i++)
246 cvi->rowc[i] = i * ip->ftheight;
247 }
248
249
250 void
251 cv_ite_init(ip)
252 register struct ite_softc *ip;
253 {
254 struct grfcvtext_mode *md;
255 static ipriv_t cv_priv;
256 volatile caddr_t vgaba, fb;
257
258 ipriv_t *cvi;
259 int i;
260
261 cvi = ip->priv ;
262 if (cvi == NULL) { /* first time */
263 cvi = &cv_priv;
264 ip->priv = cvi;
265 }
266
267 md = (struct grfcvtext_mode *) ip->grf->g_data;
268
269 ip->font = md->fdata; /*kernel_font;*/
270 ip->font_lo = md->fdstart; /*kernel_font_lo;*/
271 ip->font_hi = md->fdend; /* kernel_font_hi;*/
272 ip->ftwidth = md->fx; /*kernel_font_width;*/
273 ip->ftheight = md->fy; /*kernel_font_height;*/
274
275 ip->ftbaseline = kernel_font_baseline;
276 ip->ftboldsmear = kernel_font_boldsmear;
277
278 /* Find the correct set of rendering routines for this font. */
279 if (ip->ftwidth > 8)
280 panic("kernel font size not supported");
281
282 cvi->cursor_opt = 0;
283
284 ip->cols = md->cols;
285 ip->rows = md->rows;
286
287 cvi->width = md->gv.disp_width;
288 cvi->height = md->gv.disp_height;
289 cvi->underline = ip->ftbaseline + 1;
290 cvi->row_offset = md->gv.disp_width;
291 cvi->ft_x = ip->ftwidth;
292 cvi->ft_y = ip->ftheight;
293 cvi->row_bytes = cvi->row_offset * ip->ftheight;
294
295 vgaba = (volatile caddr_t)ip->grf->g_regkva;
296
297 vgaw16(vgaba, ECR_READ_REG_DATA, 0x1000);
298 delay(200000);
299 vgaw16(vgaba, ECR_READ_REG_DATA, 0x2000);
300 GfxBusyWait(vgaba);
301 vgaw16(vgaba, ECR_READ_REG_DATA, 0x3fff);
302 GfxBusyWait(vgaba);
303 delay(200000);
304 vgaw16(vgaba, ECR_READ_REG_DATA, 0x4fff);
305 vgaw16(vgaba, ECR_READ_REG_DATA, 0xe000);
306 vgaw16(vgaba, ECR_CURRENT_Y_POS2, 0x0);
307 vgaw16(vgaba, ECR_CURRENT_X_POS2, 0x0);
308 vgaw16(vgaba, ECR_DEST_Y__AX_STEP, 0x0);
309 vgaw16(vgaba, ECR_DEST_Y2__AX_STEP2, 0x0);
310 vgaw16(vgaba, ECR_DEST_X__DIA_STEP, 0x0);
311 vgaw16(vgaba, ECR_DEST_X2__DIA_STEP2, 0x0);
312 vgaw16(vgaba, ECR_SHORT_STROKE, 0x0);
313 vgaw16(vgaba, ECR_DRAW_CMD, 0x01);
314
315 /* It ain't easy to write here, so let's do it again */
316 vgaw16(vgaba, ECR_READ_REG_DATA, 0x4fff);
317
318 /* Clear with brute force... */
319 fb = (volatile caddr_t) ip->grf->g_fbkva;
320 for (i = 0; i < cvi->width * cvi->height; i++)
321 *fb++=0;
322 cv_clr_rect (vgaba, 0, 0, cvi->width, cvi->height);
323 cv_load_font(ip);
324 }
325
326
327 void
328 cv_ite_deinit(ip)
329 struct ite_softc *ip;
330 {
331 ip->flags &= ~ITE_INITED;
332 }
333
334
335 /* Draws inverted rectangle (cursor) */
336 void
337 cv_inv_rect(vgaba, x, y, w, h)
338 volatile caddr_t vgaba;
339 u_short x, y, w, h;
340 {
341 GfxBusyWait(vgaba);
342 vgaw16 (vgaba, ECR_FRGD_MIX, 0x0025);
343 vgaw32 (vgaba, ECR_FRGD_COLOR, 0x02);
344
345 vgaw16 (vgaba, ECR_READ_REG_DATA, 0xA000);
346 vgaw16 (vgaba, ECR_CURRENT_Y_POS , y);
347 vgaw16 (vgaba, ECR_CURRENT_X_POS , x);
348 vgaw16 (vgaba, ECR_READ_REG_DATA, h - 1);
349 vgaw16 (vgaba, ECR_MAJ_AXIS_PIX_CNT, w - 1);
350 vgaw16 (vgaba, ECR_DRAW_CMD, 0x40B1);
351
352 }
353
354
355 /*** (M<8)-by-N routines ***/
356 static void
357 cv_cursor(ip, flag)
358 struct ite_softc *ip;
359 int flag;
360 {
361 int cend, cstart;
362 struct grfcvtext_mode *md;
363 volatile caddr_t ba, fb;
364 ipriv_t *cvi;
365
366 ba = ip->grf->g_regkva;
367 fb = ip->grf->g_fbkva;
368
369 md = (struct grfcvtext_mode *) ip->grf->g_data;
370
371 cvi = ip->priv;
372
373 if (flag == END_CURSOROPT)
374 cvi->cursor_opt--;
375 else if (flag == START_CURSOROPT) {
376 if (!cvi->cursor_opt)
377 cv_cursor (ip, ERASE_CURSOR);
378 cvi->cursor_opt++;
379 return; /* if we are already opted. */
380 }
381
382 if (cvi->cursor_opt)
383 return; /* if we are still nested. */
384 /* else we draw the cursor. */
385 cstart = 0;
386 cend = ip->ftheight;
387
388 if (flag != DRAW_CURSOR && flag != END_CURSOROPT) {
389 /*
390 * erase the cursor by drawing again
391 */
392 cv_inv_rect (ba, ip->cursorx * ip->ftwidth,
393 ip->cursory * ip->ftheight + cstart,
394 ip->ftwidth, cend);
395 }
396
397 if (flag != DRAW_CURSOR && flag != MOVE_CURSOR &&
398 flag != END_CURSOROPT)
399 return;
400
401 /*
402 * draw the cursor
403 */
404
405 ip->cursorx = min(ip->curx, ip->cols-1);
406 ip->cursory = ip->cury;
407 cstart = 0;
408 cend = ip->ftheight;
409
410 cv_inv_rect (ba, ip->cursorx * ip->ftwidth,
411 ip->cursory * ip->ftheight + cstart,
412 ip->ftwidth, cend);
413
414 }
415
416
417 static inline void
418 cv_blt_font(vgaba, sx, sy, dx, dy, fw, fh, fg, bg, fmix, bmix)
419 register volatile caddr_t vgaba;
420 register int sx, sy, dx, dy, fw, fh;
421 int fg, bg, fmix, bmix;
422 {
423
424 GfxBusyWait(vgaba);
425
426 vgaw16 (vgaba, ECR_READ_REG_DATA, 0xA0C0);
427 vgaw16 (vgaba, ECR_BKGD_MIX, bmix);
428 vgaw16 (vgaba, ECR_FRGD_MIX, fmix);
429 vgaw16 (vgaba, ECR_BKGD_COLOR, bg);
430 vgaw16 (vgaba, ECR_FRGD_COLOR, fg);
431 vgaw16 (vgaba, ECR_BITPLANE_READ_MASK, 0x1);
432 vgaw16 (vgaba, ECR_BITPLANE_WRITE_MASK, 0xfff);
433 vgaw16 (vgaba, ECR_CURRENT_Y_POS , sy);
434 vgaw16 (vgaba, ECR_CURRENT_X_POS , sx);
435 vgaw16 (vgaba, ECR_DEST_Y__AX_STEP, dy);
436 vgaw16 (vgaba, ECR_DEST_X__DIA_STEP, dx);
437 vgaw16 (vgaba, ECR_READ_REG_DATA, fh);
438 vgaw16 (vgaba, ECR_MAJ_AXIS_PIX_CNT, fw);
439 vgaw16 (vgaba, ECR_DRAW_CMD, 0xc0f1);
440 }
441
442
443 /* Draws horizontal line */
444 void
445 cv_uline(vgaba, x, y, x2, fgcol)
446 volatile caddr_t vgaba;
447 int x, y, x2, fgcol;
448 {
449
450 GfxBusyWait(vgaba);
451 vgaw16 (vgaba, ECR_FRGD_MIX, 0x27);
452 vgaw16 (vgaba, ECR_FRGD_COLOR, fgcol);
453 vgaw16 (vgaba, ECR_READ_REG_DATA, 0xA000);
454 vgaw16 (vgaba, ECR_CURRENT_Y_POS , y);
455 vgaw16 (vgaba, ECR_CURRENT_X_POS , x);
456 vgaw16 (vgaba, ECR_DEST_Y__AX_STEP, y);
457 vgaw16 (vgaba, ECR_DEST_X__DIA_STEP, x2);
458 GfxBusyWait(vgaba);
459 vgaw16 (vgaba, ECR_DRAW_CMD, 0x2811);
460 }
461
462
463 void
464 cv_putc_nm(ip, c, dy, dx)
465 struct ite_softc *ip;
466 int c, dy, dx;
467 {
468 ipriv_t *cvi = (ipriv_t *)ip->priv;
469
470 cv_blt_font (ip->grf->g_regkva, cvi->font_srcx[c],
471 cvi->font_srcy[c], cvi->colc[dx], cvi->rowc[dy],
472 cvi->ft_x-1, cvi->ft_y-1, 1, 0, 0x27, 0x7);
473 }
474
475
476 void
477 cv_putc_ul(ip, c, dy, dx)
478 struct ite_softc *ip;
479 int c, dy, dx;
480 {
481 ipriv_t *cvi = (ipriv_t *)ip->priv;
482
483 cv_blt_font (ip->grf->g_regkva, cvi->font_srcx[c],
484 cvi->font_srcy[c], cvi->colc[dx], cvi->rowc[dy],
485 cvi->ft_x-1, cvi->ft_y-1, 1, 0, 0x27, 0x7);
486
487 cv_uline (ip->grf->g_regkva,cvi->colc[dx], cvi->rowc[dy] +
488 cvi->underline, cvi->colc[dx] + cvi->ft_x-1, 1);
489 }
490
491
492 void
493 cv_putc_bd(ip, c, dy, dx)
494 struct ite_softc *ip;
495 int c, dy, dx;
496 {
497 ipriv_t *cvi = (ipriv_t *)ip->priv;
498
499 cv_blt_font (ip->grf->g_regkva, cvi->font_srcx[c],
500 cvi->font_srcy[c], cvi->colc[dx], cvi->rowc[dy],
501 cvi->ft_x-1, cvi->ft_y-1, 1, 0, 0x27,0x7);
502 /* smear bold with OR mix */
503 cv_blt_font (ip->grf->g_regkva, cvi->font_srcx[c],
504 cvi->font_srcy[c], cvi->colc[dx]+1, cvi->rowc[dy],
505 cvi->ft_x-2, cvi->ft_y-1, 1, 0, 0x2b,0x5);
506 }
507
508
509 void
510 cv_putc_bd_ul(ip, c, dy, dx)
511 struct ite_softc *ip;
512 int c, dy, dx;
513 {
514 ipriv_t *cvi = (ipriv_t *)ip->priv;
515
516 cv_putc_bd(ip, c, dy, dx);
517 cv_uline (ip->grf->g_regkva,cvi->colc[dx], cvi->rowc[dy] +
518 cvi->underline, cvi->colc[dx] + cvi->ft_x-1, 1);
519 }
520
521
522 void
523 cv_putc_in(ip, c, dy, dx)
524 struct ite_softc *ip;
525 int c, dy, dx;
526 {
527 ipriv_t *cvi = (ipriv_t *)ip->priv;
528
529 cv_blt_font (ip->grf->g_regkva, cvi->font_srcx[c],
530 cvi->font_srcy[c], cvi->colc[dx], cvi->rowc[dy],
531 cvi->ft_x-1, cvi->ft_y-1, 0, 1, 0x27,0x7);
532 }
533
534
535 void
536 cv_putc_ul_in(ip, c, dy, dx)
537 struct ite_softc *ip;
538 int c, dy, dx;
539 {
540 ipriv_t *cvi = (ipriv_t *)ip->priv;
541
542 cv_blt_font (ip->grf->g_regkva, cvi->font_srcx[c],
543 cvi->font_srcy[c], cvi->colc[dx], cvi->rowc[dy],
544 cvi->ft_x-1, cvi->ft_y-1, 0, 1, 0x27,0x7);
545
546 cv_uline (ip->grf->g_regkva,cvi->colc[dx], cvi->rowc[dy] +
547 cvi->underline, cvi->colc[dx] + cvi->ft_x-1, 0);
548 }
549
550
551 void
552 cv_putc_bd_in(ip, c, dy, dx)
553 struct ite_softc *ip;
554 int c, dy, dx;
555 {
556 ipriv_t *cvi = (ipriv_t *)ip->priv;
557
558 cv_blt_font (ip->grf->g_regkva, cvi->font_srcx[c],
559 cvi->font_srcy[c], cvi->colc[dx], cvi->rowc[dy],
560 cvi->ft_x-1, cvi->ft_y-1, 0, 1, 0x27,0x7);
561
562 /* smear bold with AND mix */
563 cv_blt_font (ip->grf->g_regkva, cvi->font_srcx[c],
564 cvi->font_srcy[c], cvi->colc[dx]+1, cvi->rowc[dy],
565 cvi->ft_x-2, cvi->ft_y-1, 0, 1, 0x27, 0xc);
566 }
567
568
569 void
570 cv_putc_bd_ul_in(ip, c, dy, dx)
571 struct ite_softc *ip;
572 int c, dy, dx;
573 {
574 ipriv_t *cvi = (ipriv_t *)ip->priv;
575
576 cv_putc_bd_in(ip, c, dy, dx);
577
578 cv_uline(ip->grf->g_regkva,cvi->colc[dx], cvi->rowc[dy] +
579 cvi->underline, cvi->colc[dx] + cvi->ft_x-1, 0);
580 }
581
582
583 typedef void cv_putc_func ();
584
585 cv_putc_func *cv_put_func[ATTR_ALL+1] = {
586 cv_putc_nm,
587 cv_putc_in,
588 cv_putc_ul,
589 cv_putc_ul_in,
590 cv_putc_bd,
591 cv_putc_bd_in,
592 cv_putc_bd_ul,
593 cv_putc_bd_ul_in,
594 /* no support for blink */
595 cv_putc_nm,
596 cv_putc_in,
597 cv_putc_ul,
598 cv_putc_ul_in,
599 cv_putc_bd,
600 cv_putc_bd_in,
601 cv_putc_bd_ul,
602 cv_putc_bd_ul_in
603 };
604
605
606 static void
607 cv_putc(ip, c, dy, dx, mode)
608 struct ite_softc *ip;
609 int c, dy, dx, mode;
610 {
611
612 c = (u_char)c;
613 if (c < ip->font_lo || c > ip->font_hi)
614 c = ip->font_hi;
615 cv_put_func[mode](ip, c, dy, dx);
616 }
617
618
619 void
620 cv_clr_rect (vgaba, x, y, w, h)
621 volatile caddr_t vgaba;
622 u_short x, y, w, h;
623 {
624
625 GfxBusyWait(vgaba);
626 vgaw16 (vgaba, ECR_FRGD_MIX, 0x0027);
627 vgaw32 (vgaba, ECR_FRGD_COLOR, 0x00);
628 vgaw16 (vgaba, ECR_READ_REG_DATA, 0xA000);
629 vgaw16 (vgaba, ECR_CURRENT_Y_POS , y);
630 vgaw16 (vgaba, ECR_CURRENT_X_POS , x);
631 vgaw16 (vgaba, ECR_READ_REG_DATA, h - 1);
632 vgaw16 (vgaba, ECR_MAJ_AXIS_PIX_CNT, w - 1);
633 vgaw16 (vgaba, ECR_DRAW_CMD, 0x40B1);
634 }
635
636
637 static void
638 cv_clear(ip, sy, sx, h, w)
639 struct ite_softc *ip;
640 int sy, sx, h, w;
641 {
642
643 cv_clr_rect (ip->grf->g_regkva, sx*ip->ftwidth,
644 sy*ip->ftheight, w*ip->ftwidth,
645 h*ip->ftheight);
646 }
647
648
649 void
650 cv_bitblt(vgaba, sx, sy, dx, dy, fw, fh)
651 volatile caddr_t vgaba;
652 int sx, sy, dx, dy, fw, fh;
653 {
654 unsigned short drawdir = 0;
655
656 /* Assume overlap */
657 if (sx > dx)
658 drawdir |=1<<5; /* X positive */
659 else {
660 sx += fw -1;
661 dx += fw -1;
662 }
663 if (sy > dy)
664 drawdir |=1<<7; /* Y positive */
665 else {
666 sy += fh - 1;
667 dy += fh - 1;
668 }
669 GfxBusyWait (vgaba);
670 vgaw16 (vgaba, ECR_READ_REG_DATA, 0xA000);
671 vgaw16 (vgaba, ECR_BKGD_MIX, 0x7);
672 vgaw16 (vgaba, ECR_FRGD_MIX, 0x67);
673 vgaw16 (vgaba, ECR_BKGD_COLOR, 0x0);
674 vgaw16 (vgaba, ECR_FRGD_COLOR, 0x1);
675
676 vgaw16 (vgaba, ECR_BITPLANE_READ_MASK, 0x1);
677 vgaw16 (vgaba, ECR_BITPLANE_WRITE_MASK, 0xfff);
678 vgaw16 (vgaba, ECR_CURRENT_Y_POS , sy);
679 vgaw16 (vgaba, ECR_CURRENT_X_POS , sx);
680 vgaw16 (vgaba, ECR_DEST_Y__AX_STEP, dy);
681 vgaw16 (vgaba, ECR_DEST_X__DIA_STEP, dx);
682 vgaw16 (vgaba, ECR_READ_REG_DATA, fh - 1);
683 vgaw16 (vgaba, ECR_MAJ_AXIS_PIX_CNT, fw - 1);
684 vgaw16 (vgaba, ECR_DRAW_CMD, 0xc051 | drawdir);
685 }
686
687
688 /* Note: sx is only relevant for SCROLL_LEFT or SCROLL_RIGHT. */
689 static void
690 cv_scroll(ip, sy, sx, count, dir)
691 register struct ite_softc *ip;
692 register int sy;
693 int dir, sx, count;
694
695 {
696 int dy, dx;
697 ipriv_t *cvi = (ipriv_t *) ip->priv;
698
699 cv_cursor(ip, ERASE_CURSOR);
700 switch (dir) {
701 case SCROLL_UP:
702 dy = sy - count;
703
704 cv_bitblt(ip->grf->g_regkva,
705 0,sy*ip->ftheight,
706 0, dy*ip->ftheight,
707 cvi->width,
708 (ip->bottom_margin-dy+1)*ip->ftheight);
709
710 break;
711 case SCROLL_DOWN:
712 dy = sy + count;
713
714 cv_bitblt(ip->grf->g_regkva,
715 0,sy*ip->ftheight,
716 0, dy*ip->ftheight,
717 cvi->width,
718 (ip->bottom_margin-dy+1)*ip->ftheight);
719 break;
720 case SCROLL_RIGHT: /* one line */
721 dx = sx + count;
722 cv_bitblt(ip->grf->g_regkva,
723 sx*ip->ftwidth, sy*ip->ftheight,
724 dx*ip->ftwidth, sy*ip->ftheight,
725 (ip->cols-dx-1)*ip->ftwidth,
726 ip->ftheight);
727 break;
728 case SCROLL_LEFT:
729 dx = sx - count;
730 cv_bitblt(ip->grf->g_regkva,
731 sx*ip->ftwidth, sy*ip->ftheight,
732 dx*ip->ftwidth, sy*ip->ftheight,
733 (ip->cols-dx-1)*ip->ftwidth,
734 ip->ftheight);
735 break;
736 }
737 }
738
739 #endif /* NGRFCV */
740