2 * Copyright (c) 1999 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer as
10 * the first lines of this file unmodified.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 * $FreeBSD: src/sys/dev/syscons/scvgarndr.c,v 1.5.2.3 2001/07/28 12:51:47 yokota Exp $
27 * $DragonFly: src/sys/dev/misc/syscons/scvgarndr.c,v 1.3 2003/08/07 21:16:59 dillon Exp $
30 #include "opt_syscons.h"
33 #include <sys/param.h>
34 #include <sys/systm.h>
35 #include <sys/kernel.h>
37 #include <machine/console.h>
39 #include <dev/video/fb/fbreg.h>
40 #include <dev/video/fb/vgareg.h>
43 #include <bus/isa/isareg.h>
45 #ifndef SC_RENDER_DEBUG
46 #define SC_RENDER_DEBUG 0
49 static vr_clear_t vga_txtclear;
50 static vr_draw_border_t vga_txtborder;
51 static vr_draw_t vga_txtdraw;
52 static vr_set_cursor_t vga_txtcursor_shape;
53 static vr_draw_cursor_t vga_txtcursor;
54 static vr_blink_cursor_t vga_txtblink;
55 #ifndef SC_NO_CUTPASTE
56 static vr_draw_mouse_t vga_txtmouse;
58 #define vga_txtmouse (vr_draw_mouse_t *)vga_nop
62 static vr_clear_t vga_pxlclear;
63 static vr_draw_border_t vga_pxlborder;
64 static vr_draw_t vga_egadraw;
65 static vr_draw_t vga_vgadraw;
66 static vr_set_cursor_t vga_pxlcursor_shape;
67 static vr_draw_cursor_t vga_pxlcursor;
68 static vr_blink_cursor_t vga_pxlblink;
69 #ifndef SC_NO_CUTPASTE
70 static vr_draw_mouse_t vga_pxlmouse;
72 #define vga_pxlmouse (vr_draw_mouse_t *)vga_nop
74 #endif /* SC_PIXEL_MODE */
76 #ifndef SC_NO_MODE_CHANGE
77 static vr_draw_border_t vga_grborder;
80 static void vga_nop(scr_stat *scp, ...);
82 static struct linker_set vga_set;
84 static sc_rndr_sw_t txtrndrsw = {
91 (vr_set_mouse_t *)vga_nop,
94 RENDERER(mda, 0, txtrndrsw, vga_set);
95 RENDERER(cga, 0, txtrndrsw, vga_set);
96 RENDERER(ega, 0, txtrndrsw, vga_set);
97 RENDERER(vga, 0, txtrndrsw, vga_set);
100 static sc_rndr_sw_t egarndrsw = {
107 (vr_set_mouse_t *)vga_nop,
110 RENDERER(ega, PIXEL_MODE, egarndrsw, vga_set);
112 static sc_rndr_sw_t vgarndrsw = {
119 (vr_set_mouse_t *)vga_nop,
122 RENDERER(vga, PIXEL_MODE, vgarndrsw, vga_set);
123 #endif /* SC_PIXEL_MODE */
125 #ifndef SC_NO_MODE_CHANGE
126 static sc_rndr_sw_t grrndrsw = {
127 (vr_clear_t *)vga_nop,
129 (vr_draw_t *)vga_nop,
130 (vr_set_cursor_t *)vga_nop,
131 (vr_draw_cursor_t *)vga_nop,
132 (vr_blink_cursor_t *)vga_nop,
133 (vr_set_mouse_t *)vga_nop,
134 (vr_draw_mouse_t *)vga_nop,
136 RENDERER(cga, GRAPHICS_MODE, grrndrsw, vga_set);
137 RENDERER(ega, GRAPHICS_MODE, grrndrsw, vga_set);
138 RENDERER(vga, GRAPHICS_MODE, grrndrsw, vga_set);
139 #endif /* SC_NO_MODE_CHANGE */
141 RENDERER_MODULE(vga, vga_set);
143 #ifndef SC_NO_CUTPASTE
144 static u_short mouse_and_mask[16] = {
145 0xc000, 0xe000, 0xf000, 0xf800, 0xfc00, 0xfe00, 0xff00, 0xff80,
146 0xfe00, 0x1e00, 0x1f00, 0x0f00, 0x0f00, 0x0000, 0x0000, 0x0000
148 static u_short mouse_or_mask[16] = {
149 0x0000, 0x4000, 0x6000, 0x7000, 0x7800, 0x7c00, 0x7e00, 0x6800,
150 0x0c00, 0x0c00, 0x0600, 0x0600, 0x0000, 0x0000, 0x0000, 0x0000
155 vga_nop(scr_stat *scp, ...)
159 /* text mode renderer */
162 vga_txtclear(scr_stat *scp, int c, int attr)
164 sc_vtb_clear(&scp->scr, c, attr);
168 vga_txtborder(scr_stat *scp, int color)
170 (*vidsw[scp->sc->adapter]->set_border)(scp->sc->adp, color);
174 vga_txtdraw(scr_stat *scp, int from, int count, int flip)
180 if (from + count > scp->xsize*scp->ysize)
181 count = scp->xsize*scp->ysize - from;
184 for (p = sc_vtb_pointer(&scp->scr, from); count-- > 0; ++from) {
185 c = sc_vtb_getc(&scp->vtb, from);
186 a = sc_vtb_geta(&scp->vtb, from);
187 a = (a & 0x8800) | ((a & 0x7000) >> 4)
188 | ((a & 0x0700) << 4);
189 p = sc_vtb_putchar(&scp->scr, p, c, a);
192 sc_vtb_copy(&scp->vtb, from, &scp->scr, from, count);
197 vga_txtcursor_shape(scr_stat *scp, int base, int height, int blink)
199 if (base < 0 || base >= scp->font_size)
201 /* the caller may set height <= 0 in order to disable the cursor */
203 scp->cursor_base = base;
204 scp->cursor_height = height;
206 (*vidsw[scp->sc->adapter]->set_hw_cursor_shape)(scp->sc->adp,
208 scp->font_size, blink);
212 draw_txtcharcursor(scr_stat *scp, int at, u_short c, u_short a, int flip)
217 scp->cursor_saveunder_char = c;
218 scp->cursor_saveunder_attr = a;
220 #ifndef SC_NO_FONT_LOADING
221 if (sc->flags & SC_CHAR_CURSOR) {
226 if (scp->font_size < 14) {
229 } else if (scp->font_size >= 16) {
236 if (scp->cursor_base >= h)
240 | ((a & 0x7000) >> 4) | ((a & 0x0700) << 4);
241 bcopy(font + c*h, font + sc->cursor_char*h, h);
242 font = font + sc->cursor_char*h;
243 for (i = imax(h - scp->cursor_base - scp->cursor_height, 0);
244 i < h - scp->cursor_base; ++i) {
247 sc->font_loading_in_progress = TRUE;
249 (*vidsw[sc->adapter]->load_font)(sc->adp, 0, h, font,
251 sc->font_loading_in_progress = FALSE;
252 sc_vtb_putc(&scp->scr, at, sc->cursor_char, a);
254 #endif /* SC_NO_FONT_LOADING */
256 if ((a & 0x7000) == 0x7000) {
258 if ((a & 0x0700) == 0)
262 if ((a & 0x0700) == 0x0700)
267 | ((a & 0x7000) >> 4) | ((a & 0x0700) << 4);
268 sc_vtb_putc(&scp->scr, at, c, a);
273 vga_txtcursor(scr_stat *scp, int at, int blink, int on, int flip)
275 video_adapter_t *adp;
278 if (scp->cursor_height <= 0) /* the text cursor is disabled */
283 scp->status |= VR_CURSOR_BLINK;
285 scp->status |= VR_CURSOR_ON;
286 (*vidsw[adp->va_index]->set_hw_cursor)(adp,
290 if (scp->status & VR_CURSOR_ON)
291 (*vidsw[adp->va_index]->set_hw_cursor)(adp,
293 scp->status &= ~VR_CURSOR_ON;
296 scp->status &= ~VR_CURSOR_BLINK;
298 scp->status |= VR_CURSOR_ON;
299 draw_txtcharcursor(scp, at,
300 sc_vtb_getc(&scp->scr, at),
301 sc_vtb_geta(&scp->scr, at),
304 cursor_attr = scp->cursor_saveunder_attr;
306 cursor_attr = (cursor_attr & 0x8800)
307 | ((cursor_attr & 0x7000) >> 4)
308 | ((cursor_attr & 0x0700) << 4);
309 if (scp->status & VR_CURSOR_ON)
310 sc_vtb_putc(&scp->scr, at,
311 scp->cursor_saveunder_char,
313 scp->status &= ~VR_CURSOR_ON;
319 vga_txtblink(scr_stat *scp, int at, int flip)
323 #ifndef SC_NO_CUTPASTE
326 draw_txtmouse(scr_stat *scp, int x, int y)
328 #ifndef SC_ALT_MOUSE_IMAGE
329 if (ISMOUSEAVAIL(scp->sc->adp->va_flags)) {
330 u_char font_buf[128];
334 int xoffset, yoffset;
338 /* prepare mousepointer char's bitmaps */
339 pos = (y/scp->font_size - scp->yoff)*scp->xsize + x/8 - scp->xoff;
340 bcopy(scp->font + sc_vtb_getc(&scp->scr, pos)*scp->font_size,
341 &font_buf[0], scp->font_size);
342 bcopy(scp->font + sc_vtb_getc(&scp->scr, pos + 1)*scp->font_size,
343 &font_buf[32], scp->font_size);
345 + sc_vtb_getc(&scp->scr, pos + scp->xsize)*scp->font_size,
346 &font_buf[64], scp->font_size);
348 + sc_vtb_getc(&scp->scr, pos + scp->xsize + 1)*scp->font_size,
349 &font_buf[96], scp->font_size);
350 for (i = 0; i < scp->font_size; ++i) {
351 cursor[i] = font_buf[i]<<8 | font_buf[i+32];
352 cursor[i + scp->font_size] = font_buf[i+64]<<8 | font_buf[i+96];
355 /* now and-or in the mousepointer image */
357 yoffset = y%scp->font_size;
358 for (i = 0; i < 16; ++i) {
359 cursor[i + yoffset] =
360 (cursor[i + yoffset] & ~(mouse_and_mask[i] >> xoffset))
361 | (mouse_or_mask[i] >> xoffset);
363 for (i = 0; i < scp->font_size; ++i) {
364 font_buf[i] = (cursor[i] & 0xff00) >> 8;
365 font_buf[i + 32] = cursor[i] & 0xff;
366 font_buf[i + 64] = (cursor[i + scp->font_size] & 0xff00) >> 8;
367 font_buf[i + 96] = cursor[i + scp->font_size] & 0xff;
371 /* wait for vertical retrace to avoid jitter on some videocards */
372 crtc_addr = scp->sc->adp->va_crtc_addr;
373 while (!(inb(crtc_addr + 6) & 0x08)) /* idle */ ;
375 c = scp->sc->mouse_char;
376 (*vidsw[scp->sc->adapter]->load_font)(scp->sc->adp, 0, 32, font_buf,
379 sc_vtb_putc(&scp->scr, pos, c, sc_vtb_geta(&scp->scr, pos));
380 /* FIXME: may be out of range! */
381 sc_vtb_putc(&scp->scr, pos + scp->xsize, c + 2,
382 sc_vtb_geta(&scp->scr, pos + scp->xsize));
383 if (x < (scp->xsize - 1)*8) {
384 sc_vtb_putc(&scp->scr, pos + 1, c + 1,
385 sc_vtb_geta(&scp->scr, pos + 1));
386 sc_vtb_putc(&scp->scr, pos + scp->xsize + 1, c + 3,
387 sc_vtb_geta(&scp->scr, pos + scp->xsize + 1));
390 #endif /* SC_ALT_MOUSE_IMAGE */
392 /* Red, magenta and brown are mapped to green to to keep it readable */
393 static const int col_conv[16] = {
394 6, 6, 6, 6, 2, 2, 2, 6, 14, 14, 14, 14, 10, 10, 10, 14
400 pos = (y/scp->font_size - scp->yoff)*scp->xsize + x/8 - scp->xoff;
401 a = sc_vtb_geta(&scp->scr, pos);
402 if (scp->sc->adp->va_flags & V_ADP_COLOR)
403 color = (col_conv[(a & 0xf000) >> 12] << 12)
404 | ((a & 0x0f00) | 0x0800);
406 color = ((a & 0xf000) >> 4) | ((a & 0x0f00) << 4);
407 sc_vtb_putc(&scp->scr, pos, sc_vtb_getc(&scp->scr, pos), color);
412 remove_txtmouse(scr_stat *scp, int x, int y)
417 vga_txtmouse(scr_stat *scp, int x, int y, int on)
420 draw_txtmouse(scp, x, y);
422 remove_txtmouse(scp, x, y);
425 #endif /* SC_NO_CUTPASTE */
429 /* pixel (raster text) mode renderer */
432 vga_pxlclear(scr_stat *scp, int c, int attr)
439 /* XXX: we are just filling the screen with the background color... */
440 outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */
441 outw(GDCIDX, 0x0003); /* data rotate/function select */
442 outw(GDCIDX, 0x0f01); /* set/reset enable */
443 outw(GDCIDX, 0xff08); /* bit mask */
444 outw(GDCIDX, ((attr & 0xf000) >> 4) | 0x00); /* set/reset */
445 line_width = scp->sc->adp->va_line_width;
446 lines = scp->ysize*scp->font_size;
447 p = scp->sc->adp->va_window + line_width*scp->yoff*scp->font_size
449 for (i = 0; i < lines; ++i) {
450 bzero_io((void *)p, scp->xsize);
453 outw(GDCIDX, 0x0000); /* set/reset */
454 outw(GDCIDX, 0x0001); /* set/reset enable */
458 vga_pxlborder(scr_stat *scp, int color)
466 (*vidsw[scp->sc->adapter]->set_border)(scp->sc->adp, color);
468 outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */
469 outw(GDCIDX, 0x0003); /* data rotate/function select */
470 outw(GDCIDX, 0x0f01); /* set/reset enable */
471 outw(GDCIDX, 0xff08); /* bit mask */
472 outw(GDCIDX, (color << 8) | 0x00); /* set/reset */
473 line_width = scp->sc->adp->va_line_width;
474 p = scp->sc->adp->va_window;
476 bzero_io((void *)p, line_width*scp->yoff*scp->font_size);
477 y = (scp->yoff + scp->ysize)*scp->font_size;
479 bzero_io((void *)(p + line_width*y), line_width*(scp->ypixel - y));
480 y = scp->yoff*scp->font_size;
481 x = scp->xpixel/8 - scp->xoff - scp->xsize;
482 for (i = 0; i < scp->ysize*scp->font_size; ++i) {
484 bzero_io((void *)(p + line_width*(y + i)), scp->xoff);
486 bzero_io((void *)(p + line_width*(y + i)
487 + scp->xoff + scp->xsize), x);
489 outw(GDCIDX, 0x0000); /* set/reset */
490 outw(GDCIDX, 0x0001); /* set/reset enable */
494 vga_egadraw(scr_stat *scp, int from, int count, int flip)
506 line_width = scp->sc->adp->va_line_width;
507 d = scp->sc->adp->va_window
509 + scp->yoff*scp->font_size*line_width
511 + scp->font_size*line_width*(from/scp->xsize);
513 outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */
514 outw(GDCIDX, 0x0003); /* data rotate/function select */
515 outw(GDCIDX, 0x0f01); /* set/reset enable */
517 if (from + count > scp->xsize*scp->ysize)
518 count = scp->xsize*scp->ysize - from;
519 for (i = from; count-- > 0; ++i) {
520 a = sc_vtb_geta(&scp->vtb, i);
522 col1 = ((a & 0x7000) >> 4) | (a & 0x0800);
523 col2 = ((a & 0x8000) >> 4) | (a & 0x0700);
526 col2 = (a & 0xf000) >> 4;
528 /* set background color in EGA/VGA latch */
531 outw(GDCIDX, bg | 0x00); /* set/reset */
532 outw(GDCIDX, 0xff08); /* bit mask */
534 c = readb(d); /* set bg color in the latch */
536 /* foreground color */
537 outw(GDCIDX, col1 | 0x00); /* set/reset */
539 f = &(scp->font[sc_vtb_getc(&scp->vtb, i)*scp->font_size]);
540 for (j = 0; j < scp->font_size; ++j, ++f) {
541 outw(GDCIDX, (*f << 8) | 0x08); /* bit mask */
546 if ((i % scp->xsize) == scp->xsize - 1)
548 + (scp->font_size - 1)*line_width;
550 outw(GDCIDX, 0x0000); /* set/reset */
551 outw(GDCIDX, 0x0001); /* set/reset enable */
552 outw(GDCIDX, 0xff08); /* bit mask */
556 vga_vgadraw(scr_stat *scp, int from, int count, int flip)
568 line_width = scp->sc->adp->va_line_width;
569 d = scp->sc->adp->va_window
571 + scp->yoff*scp->font_size*line_width
573 + scp->font_size*line_width*(from/scp->xsize);
575 outw(GDCIDX, 0x0305); /* read mode 0, write mode 3 */
576 outw(GDCIDX, 0x0003); /* data rotate/function select */
577 outw(GDCIDX, 0x0f01); /* set/reset enable */
578 outw(GDCIDX, 0xff08); /* bit mask */
580 if (from + count > scp->xsize*scp->ysize)
581 count = scp->xsize*scp->ysize - from;
582 for (i = from; count-- > 0; ++i) {
583 a = sc_vtb_geta(&scp->vtb, i);
585 col1 = ((a & 0x7000) >> 4) | (a & 0x0800);
586 col2 = ((a & 0x8000) >> 4) | (a & 0x0700);
589 col2 = (a & 0xf000) >> 4;
591 /* set background color in EGA/VGA latch */
594 outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */
595 outw(GDCIDX, bg | 0x00); /* set/reset */
597 c = readb(d); /* set bg color in the latch */
598 outw(GDCIDX, 0x0305); /* read mode 0, write mode 3 */
600 /* foreground color */
601 outw(GDCIDX, col1 | 0x00); /* set/reset */
603 f = &(scp->font[sc_vtb_getc(&scp->vtb, i)*scp->font_size]);
604 for (j = 0; j < scp->font_size; ++j, ++f) {
609 if ((i % scp->xsize) == scp->xsize - 1)
611 + (scp->font_size - 1)*line_width;
613 outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */
614 outw(GDCIDX, 0x0000); /* set/reset */
615 outw(GDCIDX, 0x0001); /* set/reset enable */
619 vga_pxlcursor_shape(scr_stat *scp, int base, int height, int blink)
621 if (base < 0 || base >= scp->font_size)
623 /* the caller may set height <= 0 in order to disable the cursor */
625 scp->cursor_base = base;
626 scp->cursor_height = height;
631 draw_pxlcursor(scr_stat *scp, int at, int on, int flip)
642 line_width = scp->sc->adp->va_line_width;
643 d = scp->sc->adp->va_window
645 + scp->yoff*scp->font_size*line_width
647 + scp->font_size*line_width*(at/scp->xsize)
648 + (scp->font_size - scp->cursor_base - 1)*line_width;
650 outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */
651 outw(GDCIDX, 0x0003); /* data rotate/function select */
652 outw(GDCIDX, 0x0f01); /* set/reset enable */
653 /* set background color in EGA/VGA latch */
654 a = sc_vtb_geta(&scp->vtb, at);
656 col = (on) ? ((a & 0xf000) >> 4) : (a & 0x0f00);
658 col = (on) ? (a & 0x0f00) : ((a & 0xf000) >> 4);
659 outw(GDCIDX, col | 0x00); /* set/reset */
660 outw(GDCIDX, 0xff08); /* bit mask */
662 c = readb(d); /* set bg color in the latch */
663 /* foreground color */
665 col = (on) ? (a & 0x0f00) : ((a & 0xf000) >> 4);
667 col = (on) ? ((a & 0xf000) >> 4) : (a & 0x0f00);
668 outw(GDCIDX, col | 0x00); /* set/reset */
669 f = &(scp->font[sc_vtb_getc(&scp->vtb, at)*scp->font_size
670 + scp->font_size - scp->cursor_base - 1]);
671 height = imin(scp->cursor_height, scp->font_size);
672 for (i = 0; i < height; ++i, --f) {
673 outw(GDCIDX, (*f << 8) | 0x08); /* bit mask */
677 outw(GDCIDX, 0x0000); /* set/reset */
678 outw(GDCIDX, 0x0001); /* set/reset enable */
679 outw(GDCIDX, 0xff08); /* bit mask */
682 static int pxlblinkrate = 0;
685 vga_pxlcursor(scr_stat *scp, int at, int blink, int on, int flip)
687 if (scp->cursor_height <= 0) /* the text cursor is disabled */
692 scp->status |= VR_CURSOR_ON;
693 draw_pxlcursor(scp, at, on, flip);
694 } else if (++pxlblinkrate & 4) {
696 scp->status ^= VR_CURSOR_ON;
697 draw_pxlcursor(scp, at,
698 scp->status & VR_CURSOR_ON,
702 if (scp->status & VR_CURSOR_ON)
703 draw_pxlcursor(scp, at, on, flip);
704 scp->status &= ~VR_CURSOR_ON;
707 scp->status |= VR_CURSOR_BLINK;
709 scp->status &= ~VR_CURSOR_BLINK;
713 vga_pxlblink(scr_stat *scp, int at, int flip)
715 if (!(scp->status & VR_CURSOR_BLINK))
717 if (!(++pxlblinkrate & 4))
720 scp->status ^= VR_CURSOR_ON;
721 draw_pxlcursor(scp, at, scp->status & VR_CURSOR_ON, flip);
724 #ifndef SC_NO_CUTPASTE
727 draw_pxlmouse(scr_stat *scp, int x, int y)
736 line_width = scp->sc->adp->va_line_width;
737 xoff = (x - scp->xoff*8)%8;
738 yoff = y - (y/line_width)*line_width;
739 ymax = imin(y + 16, scp->ypixel);
741 outw(GDCIDX, 0x0805); /* read mode 1, write mode 0 */
742 outw(GDCIDX, 0x0001); /* set/reset enable */
743 outw(GDCIDX, 0x0002); /* color compare */
744 outw(GDCIDX, 0x0007); /* color don't care */
745 outw(GDCIDX, 0xff08); /* bit mask */
746 outw(GDCIDX, 0x0803); /* data rotate/function select (and) */
747 p = scp->sc->adp->va_window + line_width*y + x/8;
748 if (x < scp->xpixel - 8) {
749 for (i = y, j = 0; i < ymax; ++i, ++j) {
750 m = ~(mouse_and_mask[j] >> xoff);
752 *(u_char *)p &= m >> 8;
753 *(u_char *)(p + 1) &= m;
754 #elif defined(__alpha__)
755 writeb(p, readb(p) & (m >> 8));
756 writeb(p + 1, readb(p + 1) & (m >> 8));
762 for (i = y, j = 0; i < ymax; ++i, ++j) {
763 m = ~(mouse_and_mask[j] >> xoff);
766 #elif defined(__alpha__)
767 writeb(p, readb(p) & (m >> 8));
772 outw(GDCIDX, 0x1003); /* data rotate/function select (or) */
773 p = scp->sc->adp->va_window + line_width*y + x/8;
774 if (x < scp->xpixel - 8) {
775 for (i = y, j = 0; i < ymax; ++i, ++j) {
776 m = mouse_or_mask[j] >> xoff;
778 *(u_char *)p &= m >> 8;
779 *(u_char *)(p + 1) &= m;
780 #elif defined(__alpha__)
781 writeb(p, readb(p) & (m >> 8));
782 writeb(p + 1, readb(p + 1) & (m >> 8));
787 for (i = y, j = 0; i < ymax; ++i, ++j) {
788 m = mouse_or_mask[j] >> xoff;
791 #elif defined(__alpha__)
792 writeb(p, readb(p) & (m >> 8));
797 outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */
798 outw(GDCIDX, 0x0003); /* data rotate/function select */
802 remove_pxlmouse(scr_stat *scp, int x, int y)
811 /* erase the mouse cursor image */
812 col = x/8 - scp->xoff;
813 row = y/scp->font_size - scp->yoff;
814 pos = row*scp->xsize + col;
815 i = (col < scp->xsize - 1) ? 2 : 1;
816 (*scp->rndr->draw)(scp, pos, i, FALSE);
817 if (row < scp->ysize - 1)
818 (*scp->rndr->draw)(scp, pos + scp->xsize, i, FALSE);
820 /* paint border if necessary */
821 line_width = scp->sc->adp->va_line_width;
822 outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */
823 outw(GDCIDX, 0x0003); /* data rotate/function select */
824 outw(GDCIDX, 0x0f01); /* set/reset enable */
825 outw(GDCIDX, 0xff08); /* bit mask */
826 outw(GDCIDX, (scp->border << 8) | 0x00); /* set/reset */
827 if (row == scp->ysize - 1) {
828 i = (scp->ysize + scp->yoff)*scp->font_size;
829 ymax = imin(i + scp->font_size, scp->ypixel);
830 p = scp->sc->adp->va_window + i*line_width + scp->xoff + col;
831 if (col < scp->xsize - 1) {
832 for (; i < ymax; ++i) {
838 for (; i < ymax; ++i) {
844 if ((col == scp->xsize - 1) && (scp->xoff > 0)) {
845 i = (row + scp->yoff)*scp->font_size;
846 ymax = imin(i + scp->font_size*2, scp->ypixel);
847 p = scp->sc->adp->va_window + i*line_width
848 + scp->xoff + scp->xsize;
849 for (; i < ymax; ++i) {
854 outw(GDCIDX, 0x0000); /* set/reset */
855 outw(GDCIDX, 0x0001); /* set/reset enable */
859 vga_pxlmouse(scr_stat *scp, int x, int y, int on)
862 draw_pxlmouse(scp, x, y);
864 remove_pxlmouse(scp, x, y);
867 #endif /* SC_NO_CUTPASTE */
868 #endif /* SC_PIXEL_MODE */
870 #ifndef SC_NO_MODE_CHANGE
872 /* graphics mode renderer */
875 vga_grborder(scr_stat *scp, int color)
877 (*vidsw[scp->sc->adapter]->set_border)(scp->sc->adp, color);