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.4 2003/11/10 06:12:06 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 sc_rndr_sw_t txtrndrsw = {
89 (vr_set_mouse_t *)vga_nop,
92 RENDERER(mda, 0, txtrndrsw, vga_set);
93 RENDERER(cga, 0, txtrndrsw, vga_set);
94 RENDERER(ega, 0, txtrndrsw, vga_set);
95 RENDERER(vga, 0, txtrndrsw, vga_set);
98 static sc_rndr_sw_t egarndrsw = {
105 (vr_set_mouse_t *)vga_nop,
108 RENDERER(ega, PIXEL_MODE, egarndrsw, vga_set);
110 static sc_rndr_sw_t vgarndrsw = {
117 (vr_set_mouse_t *)vga_nop,
120 RENDERER(vga, PIXEL_MODE, vgarndrsw, vga_set);
121 #endif /* SC_PIXEL_MODE */
123 #ifndef SC_NO_MODE_CHANGE
124 static sc_rndr_sw_t grrndrsw = {
125 (vr_clear_t *)vga_nop,
127 (vr_draw_t *)vga_nop,
128 (vr_set_cursor_t *)vga_nop,
129 (vr_draw_cursor_t *)vga_nop,
130 (vr_blink_cursor_t *)vga_nop,
131 (vr_set_mouse_t *)vga_nop,
132 (vr_draw_mouse_t *)vga_nop,
134 RENDERER(cga, GRAPHICS_MODE, grrndrsw, vga_set);
135 RENDERER(ega, GRAPHICS_MODE, grrndrsw, vga_set);
136 RENDERER(vga, GRAPHICS_MODE, grrndrsw, vga_set);
137 #endif /* SC_NO_MODE_CHANGE */
139 RENDERER_MODULE(vga, vga_set);
141 #ifndef SC_NO_CUTPASTE
142 static u_short mouse_and_mask[16] = {
143 0xc000, 0xe000, 0xf000, 0xf800, 0xfc00, 0xfe00, 0xff00, 0xff80,
144 0xfe00, 0x1e00, 0x1f00, 0x0f00, 0x0f00, 0x0000, 0x0000, 0x0000
146 static u_short mouse_or_mask[16] = {
147 0x0000, 0x4000, 0x6000, 0x7000, 0x7800, 0x7c00, 0x7e00, 0x6800,
148 0x0c00, 0x0c00, 0x0600, 0x0600, 0x0000, 0x0000, 0x0000, 0x0000
153 vga_nop(scr_stat *scp, ...)
157 /* text mode renderer */
160 vga_txtclear(scr_stat *scp, int c, int attr)
162 sc_vtb_clear(&scp->scr, c, attr);
166 vga_txtborder(scr_stat *scp, int color)
168 (*vidsw[scp->sc->adapter]->set_border)(scp->sc->adp, color);
172 vga_txtdraw(scr_stat *scp, int from, int count, int flip)
178 if (from + count > scp->xsize*scp->ysize)
179 count = scp->xsize*scp->ysize - from;
182 for (p = sc_vtb_pointer(&scp->scr, from); count-- > 0; ++from) {
183 c = sc_vtb_getc(&scp->vtb, from);
184 a = sc_vtb_geta(&scp->vtb, from);
185 a = (a & 0x8800) | ((a & 0x7000) >> 4)
186 | ((a & 0x0700) << 4);
187 p = sc_vtb_putchar(&scp->scr, p, c, a);
190 sc_vtb_copy(&scp->vtb, from, &scp->scr, from, count);
195 vga_txtcursor_shape(scr_stat *scp, int base, int height, int blink)
197 if (base < 0 || base >= scp->font_size)
199 /* the caller may set height <= 0 in order to disable the cursor */
201 scp->cursor_base = base;
202 scp->cursor_height = height;
204 (*vidsw[scp->sc->adapter]->set_hw_cursor_shape)(scp->sc->adp,
206 scp->font_size, blink);
210 draw_txtcharcursor(scr_stat *scp, int at, u_short c, u_short a, int flip)
215 scp->cursor_saveunder_char = c;
216 scp->cursor_saveunder_attr = a;
218 #ifndef SC_NO_FONT_LOADING
219 if (sc->flags & SC_CHAR_CURSOR) {
224 if (scp->font_size < 14) {
227 } else if (scp->font_size >= 16) {
234 if (scp->cursor_base >= h)
238 | ((a & 0x7000) >> 4) | ((a & 0x0700) << 4);
239 bcopy(font + c*h, font + sc->cursor_char*h, h);
240 font = font + sc->cursor_char*h;
241 for (i = imax(h - scp->cursor_base - scp->cursor_height, 0);
242 i < h - scp->cursor_base; ++i) {
245 sc->font_loading_in_progress = TRUE;
247 (*vidsw[sc->adapter]->load_font)(sc->adp, 0, h, font,
249 sc->font_loading_in_progress = FALSE;
250 sc_vtb_putc(&scp->scr, at, sc->cursor_char, a);
252 #endif /* SC_NO_FONT_LOADING */
254 if ((a & 0x7000) == 0x7000) {
256 if ((a & 0x0700) == 0)
260 if ((a & 0x0700) == 0x0700)
265 | ((a & 0x7000) >> 4) | ((a & 0x0700) << 4);
266 sc_vtb_putc(&scp->scr, at, c, a);
271 vga_txtcursor(scr_stat *scp, int at, int blink, int on, int flip)
273 video_adapter_t *adp;
276 if (scp->cursor_height <= 0) /* the text cursor is disabled */
281 scp->status |= VR_CURSOR_BLINK;
283 scp->status |= VR_CURSOR_ON;
284 (*vidsw[adp->va_index]->set_hw_cursor)(adp,
288 if (scp->status & VR_CURSOR_ON)
289 (*vidsw[adp->va_index]->set_hw_cursor)(adp,
291 scp->status &= ~VR_CURSOR_ON;
294 scp->status &= ~VR_CURSOR_BLINK;
296 scp->status |= VR_CURSOR_ON;
297 draw_txtcharcursor(scp, at,
298 sc_vtb_getc(&scp->scr, at),
299 sc_vtb_geta(&scp->scr, at),
302 cursor_attr = scp->cursor_saveunder_attr;
304 cursor_attr = (cursor_attr & 0x8800)
305 | ((cursor_attr & 0x7000) >> 4)
306 | ((cursor_attr & 0x0700) << 4);
307 if (scp->status & VR_CURSOR_ON)
308 sc_vtb_putc(&scp->scr, at,
309 scp->cursor_saveunder_char,
311 scp->status &= ~VR_CURSOR_ON;
317 vga_txtblink(scr_stat *scp, int at, int flip)
321 #ifndef SC_NO_CUTPASTE
324 draw_txtmouse(scr_stat *scp, int x, int y)
326 #ifndef SC_ALT_MOUSE_IMAGE
327 if (ISMOUSEAVAIL(scp->sc->adp->va_flags)) {
328 u_char font_buf[128];
332 int xoffset, yoffset;
336 /* prepare mousepointer char's bitmaps */
337 pos = (y/scp->font_size - scp->yoff)*scp->xsize + x/8 - scp->xoff;
338 bcopy(scp->font + sc_vtb_getc(&scp->scr, pos)*scp->font_size,
339 &font_buf[0], scp->font_size);
340 bcopy(scp->font + sc_vtb_getc(&scp->scr, pos + 1)*scp->font_size,
341 &font_buf[32], scp->font_size);
343 + sc_vtb_getc(&scp->scr, pos + scp->xsize)*scp->font_size,
344 &font_buf[64], scp->font_size);
346 + sc_vtb_getc(&scp->scr, pos + scp->xsize + 1)*scp->font_size,
347 &font_buf[96], scp->font_size);
348 for (i = 0; i < scp->font_size; ++i) {
349 cursor[i] = font_buf[i]<<8 | font_buf[i+32];
350 cursor[i + scp->font_size] = font_buf[i+64]<<8 | font_buf[i+96];
353 /* now and-or in the mousepointer image */
355 yoffset = y%scp->font_size;
356 for (i = 0; i < 16; ++i) {
357 cursor[i + yoffset] =
358 (cursor[i + yoffset] & ~(mouse_and_mask[i] >> xoffset))
359 | (mouse_or_mask[i] >> xoffset);
361 for (i = 0; i < scp->font_size; ++i) {
362 font_buf[i] = (cursor[i] & 0xff00) >> 8;
363 font_buf[i + 32] = cursor[i] & 0xff;
364 font_buf[i + 64] = (cursor[i + scp->font_size] & 0xff00) >> 8;
365 font_buf[i + 96] = cursor[i + scp->font_size] & 0xff;
369 /* wait for vertical retrace to avoid jitter on some videocards */
370 crtc_addr = scp->sc->adp->va_crtc_addr;
371 while (!(inb(crtc_addr + 6) & 0x08)) /* idle */ ;
373 c = scp->sc->mouse_char;
374 (*vidsw[scp->sc->adapter]->load_font)(scp->sc->adp, 0, 32, font_buf,
377 sc_vtb_putc(&scp->scr, pos, c, sc_vtb_geta(&scp->scr, pos));
378 /* FIXME: may be out of range! */
379 sc_vtb_putc(&scp->scr, pos + scp->xsize, c + 2,
380 sc_vtb_geta(&scp->scr, pos + scp->xsize));
381 if (x < (scp->xsize - 1)*8) {
382 sc_vtb_putc(&scp->scr, pos + 1, c + 1,
383 sc_vtb_geta(&scp->scr, pos + 1));
384 sc_vtb_putc(&scp->scr, pos + scp->xsize + 1, c + 3,
385 sc_vtb_geta(&scp->scr, pos + scp->xsize + 1));
388 #endif /* SC_ALT_MOUSE_IMAGE */
390 /* Red, magenta and brown are mapped to green to to keep it readable */
391 static const int col_conv[16] = {
392 6, 6, 6, 6, 2, 2, 2, 6, 14, 14, 14, 14, 10, 10, 10, 14
398 pos = (y/scp->font_size - scp->yoff)*scp->xsize + x/8 - scp->xoff;
399 a = sc_vtb_geta(&scp->scr, pos);
400 if (scp->sc->adp->va_flags & V_ADP_COLOR)
401 color = (col_conv[(a & 0xf000) >> 12] << 12)
402 | ((a & 0x0f00) | 0x0800);
404 color = ((a & 0xf000) >> 4) | ((a & 0x0f00) << 4);
405 sc_vtb_putc(&scp->scr, pos, sc_vtb_getc(&scp->scr, pos), color);
410 remove_txtmouse(scr_stat *scp, int x, int y)
415 vga_txtmouse(scr_stat *scp, int x, int y, int on)
418 draw_txtmouse(scp, x, y);
420 remove_txtmouse(scp, x, y);
423 #endif /* SC_NO_CUTPASTE */
427 /* pixel (raster text) mode renderer */
430 vga_pxlclear(scr_stat *scp, int c, int attr)
437 /* XXX: we are just filling the screen with the background color... */
438 outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */
439 outw(GDCIDX, 0x0003); /* data rotate/function select */
440 outw(GDCIDX, 0x0f01); /* set/reset enable */
441 outw(GDCIDX, 0xff08); /* bit mask */
442 outw(GDCIDX, ((attr & 0xf000) >> 4) | 0x00); /* set/reset */
443 line_width = scp->sc->adp->va_line_width;
444 lines = scp->ysize*scp->font_size;
445 p = scp->sc->adp->va_window + line_width*scp->yoff*scp->font_size
447 for (i = 0; i < lines; ++i) {
448 bzero_io((void *)p, scp->xsize);
451 outw(GDCIDX, 0x0000); /* set/reset */
452 outw(GDCIDX, 0x0001); /* set/reset enable */
456 vga_pxlborder(scr_stat *scp, int color)
464 (*vidsw[scp->sc->adapter]->set_border)(scp->sc->adp, color);
466 outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */
467 outw(GDCIDX, 0x0003); /* data rotate/function select */
468 outw(GDCIDX, 0x0f01); /* set/reset enable */
469 outw(GDCIDX, 0xff08); /* bit mask */
470 outw(GDCIDX, (color << 8) | 0x00); /* set/reset */
471 line_width = scp->sc->adp->va_line_width;
472 p = scp->sc->adp->va_window;
474 bzero_io((void *)p, line_width*scp->yoff*scp->font_size);
475 y = (scp->yoff + scp->ysize)*scp->font_size;
477 bzero_io((void *)(p + line_width*y), line_width*(scp->ypixel - y));
478 y = scp->yoff*scp->font_size;
479 x = scp->xpixel/8 - scp->xoff - scp->xsize;
480 for (i = 0; i < scp->ysize*scp->font_size; ++i) {
482 bzero_io((void *)(p + line_width*(y + i)), scp->xoff);
484 bzero_io((void *)(p + line_width*(y + i)
485 + scp->xoff + scp->xsize), x);
487 outw(GDCIDX, 0x0000); /* set/reset */
488 outw(GDCIDX, 0x0001); /* set/reset enable */
492 vga_egadraw(scr_stat *scp, int from, int count, int flip)
504 line_width = scp->sc->adp->va_line_width;
505 d = scp->sc->adp->va_window
507 + scp->yoff*scp->font_size*line_width
509 + scp->font_size*line_width*(from/scp->xsize);
511 outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */
512 outw(GDCIDX, 0x0003); /* data rotate/function select */
513 outw(GDCIDX, 0x0f01); /* set/reset enable */
515 if (from + count > scp->xsize*scp->ysize)
516 count = scp->xsize*scp->ysize - from;
517 for (i = from; count-- > 0; ++i) {
518 a = sc_vtb_geta(&scp->vtb, i);
520 col1 = ((a & 0x7000) >> 4) | (a & 0x0800);
521 col2 = ((a & 0x8000) >> 4) | (a & 0x0700);
524 col2 = (a & 0xf000) >> 4;
526 /* set background color in EGA/VGA latch */
529 outw(GDCIDX, bg | 0x00); /* set/reset */
530 outw(GDCIDX, 0xff08); /* bit mask */
532 c = readb(d); /* set bg color in the latch */
534 /* foreground color */
535 outw(GDCIDX, col1 | 0x00); /* set/reset */
537 f = &(scp->font[sc_vtb_getc(&scp->vtb, i)*scp->font_size]);
538 for (j = 0; j < scp->font_size; ++j, ++f) {
539 outw(GDCIDX, (*f << 8) | 0x08); /* bit mask */
544 if ((i % scp->xsize) == scp->xsize - 1)
546 + (scp->font_size - 1)*line_width;
548 outw(GDCIDX, 0x0000); /* set/reset */
549 outw(GDCIDX, 0x0001); /* set/reset enable */
550 outw(GDCIDX, 0xff08); /* bit mask */
554 vga_vgadraw(scr_stat *scp, int from, int count, int flip)
566 line_width = scp->sc->adp->va_line_width;
567 d = scp->sc->adp->va_window
569 + scp->yoff*scp->font_size*line_width
571 + scp->font_size*line_width*(from/scp->xsize);
573 outw(GDCIDX, 0x0305); /* read mode 0, write mode 3 */
574 outw(GDCIDX, 0x0003); /* data rotate/function select */
575 outw(GDCIDX, 0x0f01); /* set/reset enable */
576 outw(GDCIDX, 0xff08); /* bit mask */
578 if (from + count > scp->xsize*scp->ysize)
579 count = scp->xsize*scp->ysize - from;
580 for (i = from; count-- > 0; ++i) {
581 a = sc_vtb_geta(&scp->vtb, i);
583 col1 = ((a & 0x7000) >> 4) | (a & 0x0800);
584 col2 = ((a & 0x8000) >> 4) | (a & 0x0700);
587 col2 = (a & 0xf000) >> 4;
589 /* set background color in EGA/VGA latch */
592 outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */
593 outw(GDCIDX, bg | 0x00); /* set/reset */
595 c = readb(d); /* set bg color in the latch */
596 outw(GDCIDX, 0x0305); /* read mode 0, write mode 3 */
598 /* foreground color */
599 outw(GDCIDX, col1 | 0x00); /* set/reset */
601 f = &(scp->font[sc_vtb_getc(&scp->vtb, i)*scp->font_size]);
602 for (j = 0; j < scp->font_size; ++j, ++f) {
607 if ((i % scp->xsize) == scp->xsize - 1)
609 + (scp->font_size - 1)*line_width;
611 outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */
612 outw(GDCIDX, 0x0000); /* set/reset */
613 outw(GDCIDX, 0x0001); /* set/reset enable */
617 vga_pxlcursor_shape(scr_stat *scp, int base, int height, int blink)
619 if (base < 0 || base >= scp->font_size)
621 /* the caller may set height <= 0 in order to disable the cursor */
623 scp->cursor_base = base;
624 scp->cursor_height = height;
629 draw_pxlcursor(scr_stat *scp, int at, int on, int flip)
640 line_width = scp->sc->adp->va_line_width;
641 d = scp->sc->adp->va_window
643 + scp->yoff*scp->font_size*line_width
645 + scp->font_size*line_width*(at/scp->xsize)
646 + (scp->font_size - scp->cursor_base - 1)*line_width;
648 outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */
649 outw(GDCIDX, 0x0003); /* data rotate/function select */
650 outw(GDCIDX, 0x0f01); /* set/reset enable */
651 /* set background color in EGA/VGA latch */
652 a = sc_vtb_geta(&scp->vtb, at);
654 col = (on) ? ((a & 0xf000) >> 4) : (a & 0x0f00);
656 col = (on) ? (a & 0x0f00) : ((a & 0xf000) >> 4);
657 outw(GDCIDX, col | 0x00); /* set/reset */
658 outw(GDCIDX, 0xff08); /* bit mask */
660 c = readb(d); /* set bg color in the latch */
661 /* foreground color */
663 col = (on) ? (a & 0x0f00) : ((a & 0xf000) >> 4);
665 col = (on) ? ((a & 0xf000) >> 4) : (a & 0x0f00);
666 outw(GDCIDX, col | 0x00); /* set/reset */
667 f = &(scp->font[sc_vtb_getc(&scp->vtb, at)*scp->font_size
668 + scp->font_size - scp->cursor_base - 1]);
669 height = imin(scp->cursor_height, scp->font_size);
670 for (i = 0; i < height; ++i, --f) {
671 outw(GDCIDX, (*f << 8) | 0x08); /* bit mask */
675 outw(GDCIDX, 0x0000); /* set/reset */
676 outw(GDCIDX, 0x0001); /* set/reset enable */
677 outw(GDCIDX, 0xff08); /* bit mask */
680 static int pxlblinkrate = 0;
683 vga_pxlcursor(scr_stat *scp, int at, int blink, int on, int flip)
685 if (scp->cursor_height <= 0) /* the text cursor is disabled */
690 scp->status |= VR_CURSOR_ON;
691 draw_pxlcursor(scp, at, on, flip);
692 } else if (++pxlblinkrate & 4) {
694 scp->status ^= VR_CURSOR_ON;
695 draw_pxlcursor(scp, at,
696 scp->status & VR_CURSOR_ON,
700 if (scp->status & VR_CURSOR_ON)
701 draw_pxlcursor(scp, at, on, flip);
702 scp->status &= ~VR_CURSOR_ON;
705 scp->status |= VR_CURSOR_BLINK;
707 scp->status &= ~VR_CURSOR_BLINK;
711 vga_pxlblink(scr_stat *scp, int at, int flip)
713 if (!(scp->status & VR_CURSOR_BLINK))
715 if (!(++pxlblinkrate & 4))
718 scp->status ^= VR_CURSOR_ON;
719 draw_pxlcursor(scp, at, scp->status & VR_CURSOR_ON, flip);
722 #ifndef SC_NO_CUTPASTE
725 draw_pxlmouse(scr_stat *scp, int x, int y)
734 line_width = scp->sc->adp->va_line_width;
735 xoff = (x - scp->xoff*8)%8;
736 yoff = y - (y/line_width)*line_width;
737 ymax = imin(y + 16, scp->ypixel);
739 outw(GDCIDX, 0x0805); /* read mode 1, write mode 0 */
740 outw(GDCIDX, 0x0001); /* set/reset enable */
741 outw(GDCIDX, 0x0002); /* color compare */
742 outw(GDCIDX, 0x0007); /* color don't care */
743 outw(GDCIDX, 0xff08); /* bit mask */
744 outw(GDCIDX, 0x0803); /* data rotate/function select (and) */
745 p = scp->sc->adp->va_window + line_width*y + x/8;
746 if (x < scp->xpixel - 8) {
747 for (i = y, j = 0; i < ymax; ++i, ++j) {
748 m = ~(mouse_and_mask[j] >> xoff);
750 *(u_char *)p &= m >> 8;
751 *(u_char *)(p + 1) &= m;
752 #elif defined(__alpha__)
753 writeb(p, readb(p) & (m >> 8));
754 writeb(p + 1, readb(p + 1) & (m >> 8));
760 for (i = y, j = 0; i < ymax; ++i, ++j) {
761 m = ~(mouse_and_mask[j] >> xoff);
764 #elif defined(__alpha__)
765 writeb(p, readb(p) & (m >> 8));
770 outw(GDCIDX, 0x1003); /* data rotate/function select (or) */
771 p = scp->sc->adp->va_window + line_width*y + x/8;
772 if (x < scp->xpixel - 8) {
773 for (i = y, j = 0; i < ymax; ++i, ++j) {
774 m = mouse_or_mask[j] >> xoff;
776 *(u_char *)p &= m >> 8;
777 *(u_char *)(p + 1) &= m;
778 #elif defined(__alpha__)
779 writeb(p, readb(p) & (m >> 8));
780 writeb(p + 1, readb(p + 1) & (m >> 8));
785 for (i = y, j = 0; i < ymax; ++i, ++j) {
786 m = mouse_or_mask[j] >> xoff;
789 #elif defined(__alpha__)
790 writeb(p, readb(p) & (m >> 8));
795 outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */
796 outw(GDCIDX, 0x0003); /* data rotate/function select */
800 remove_pxlmouse(scr_stat *scp, int x, int y)
809 /* erase the mouse cursor image */
810 col = x/8 - scp->xoff;
811 row = y/scp->font_size - scp->yoff;
812 pos = row*scp->xsize + col;
813 i = (col < scp->xsize - 1) ? 2 : 1;
814 (*scp->rndr->draw)(scp, pos, i, FALSE);
815 if (row < scp->ysize - 1)
816 (*scp->rndr->draw)(scp, pos + scp->xsize, i, FALSE);
818 /* paint border if necessary */
819 line_width = scp->sc->adp->va_line_width;
820 outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */
821 outw(GDCIDX, 0x0003); /* data rotate/function select */
822 outw(GDCIDX, 0x0f01); /* set/reset enable */
823 outw(GDCIDX, 0xff08); /* bit mask */
824 outw(GDCIDX, (scp->border << 8) | 0x00); /* set/reset */
825 if (row == scp->ysize - 1) {
826 i = (scp->ysize + scp->yoff)*scp->font_size;
827 ymax = imin(i + scp->font_size, scp->ypixel);
828 p = scp->sc->adp->va_window + i*line_width + scp->xoff + col;
829 if (col < scp->xsize - 1) {
830 for (; i < ymax; ++i) {
836 for (; i < ymax; ++i) {
842 if ((col == scp->xsize - 1) && (scp->xoff > 0)) {
843 i = (row + scp->yoff)*scp->font_size;
844 ymax = imin(i + scp->font_size*2, scp->ypixel);
845 p = scp->sc->adp->va_window + i*line_width
846 + scp->xoff + scp->xsize;
847 for (; i < ymax; ++i) {
852 outw(GDCIDX, 0x0000); /* set/reset */
853 outw(GDCIDX, 0x0001); /* set/reset enable */
857 vga_pxlmouse(scr_stat *scp, int x, int y, int on)
860 draw_pxlmouse(scp, x, y);
862 remove_pxlmouse(scp, x, y);
865 #endif /* SC_NO_CUTPASTE */
866 #endif /* SC_PIXEL_MODE */
868 #ifndef SC_NO_MODE_CHANGE
870 /* graphics mode renderer */
873 vga_grborder(scr_stat *scp, int color)
875 (*vidsw[scp->sc->adapter]->set_border)(scp->sc->adp, color);