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.
29 #include "opt_syscons.h"
32 #include <sys/param.h>
33 #include <sys/systm.h>
34 #include <sys/kernel.h>
36 #include <sys/consio.h>
38 #include <machine/bus.h>
40 #include <dev/fb/fbreg.h>
41 #include <dev/fb/vgareg.h>
42 #include <dev/syscons/syscons.h>
44 #include <isa/isareg.h>
46 #ifndef SC_RENDER_DEBUG
47 #define SC_RENDER_DEBUG 0
50 static vr_clear_t vga_txtclear;
51 static vr_draw_border_t vga_txtborder;
52 static vr_draw_t vga_txtdraw;
53 static vr_set_cursor_t vga_txtcursor_shape;
54 static vr_draw_cursor_t vga_txtcursor;
55 static vr_blink_cursor_t vga_txtblink;
56 #ifndef SC_NO_CUTPASTE
57 static vr_draw_mouse_t vga_txtmouse;
59 #define vga_txtmouse (vr_draw_mouse_t *)vga_nop
63 static vr_clear_t vga_pxlclear;
64 static vr_draw_border_t vga_pxlborder;
65 static vr_draw_t vga_egadraw;
66 static vr_draw_t vga_vgadraw;
67 static vr_set_cursor_t vga_pxlcursor_shape;
68 static vr_draw_cursor_t vga_pxlcursor;
69 static vr_blink_cursor_t vga_pxlblink;
70 #ifndef SC_NO_CUTPASTE
71 static vr_draw_mouse_t vga_pxlmouse;
73 #define vga_pxlmouse (vr_draw_mouse_t *)vga_nop
75 #endif /* SC_PIXEL_MODE */
77 #ifndef SC_NO_MODE_CHANGE
78 static vr_draw_border_t vga_grborder;
81 static void vga_nop(scr_stat *scp, ...);
83 static sc_rndr_sw_t txtrndrsw = {
90 (vr_set_mouse_t *)vga_nop,
93 RENDERER(mda, 0, txtrndrsw, vga_set);
94 RENDERER(cga, 0, txtrndrsw, vga_set);
95 RENDERER(ega, 0, txtrndrsw, vga_set);
96 RENDERER(vga, 0, txtrndrsw, vga_set);
99 static sc_rndr_sw_t egarndrsw = {
106 (vr_set_mouse_t *)vga_nop,
109 RENDERER(ega, PIXEL_MODE, egarndrsw, vga_set);
111 static sc_rndr_sw_t vgarndrsw = {
118 (vr_set_mouse_t *)vga_nop,
121 RENDERER(vga, PIXEL_MODE, vgarndrsw, vga_set);
122 #endif /* SC_PIXEL_MODE */
124 #ifndef SC_NO_MODE_CHANGE
125 static sc_rndr_sw_t grrndrsw = {
126 (vr_clear_t *)vga_nop,
128 (vr_draw_t *)vga_nop,
129 (vr_set_cursor_t *)vga_nop,
130 (vr_draw_cursor_t *)vga_nop,
131 (vr_blink_cursor_t *)vga_nop,
132 (vr_set_mouse_t *)vga_nop,
133 (vr_draw_mouse_t *)vga_nop,
135 RENDERER(cga, GRAPHICS_MODE, grrndrsw, vga_set);
136 RENDERER(ega, GRAPHICS_MODE, grrndrsw, vga_set);
137 RENDERER(vga, GRAPHICS_MODE, grrndrsw, vga_set);
138 #endif /* SC_NO_MODE_CHANGE */
140 RENDERER_MODULE(vga, vga_set);
142 #ifndef SC_NO_CUTPASTE
143 #if !defined(SC_ALT_MOUSE_IMAGE) || defined(SC_PIXEL_MODE)
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
156 vga_nop(scr_stat *scp, ...)
160 /* text mode renderer */
163 vga_txtclear(scr_stat *scp, int c, int attr)
165 sc_vtb_clear(&scp->scr, c, attr);
169 vga_txtborder(scr_stat *scp, int color)
171 (*vidsw[scp->sc->adapter]->set_border)(scp->sc->adp, color);
175 vga_txtdraw(scr_stat *scp, int from, int count, int flip)
181 if (from + count > scp->xsize*scp->ysize)
182 count = scp->xsize*scp->ysize - from;
185 for (p = sc_vtb_pointer(&scp->scr, from); count-- > 0; ++from) {
186 c = sc_vtb_getc(&scp->vtb, from);
187 a = sc_vtb_geta(&scp->vtb, from);
188 a = (a & 0x8800) | ((a & 0x7000) >> 4)
189 | ((a & 0x0700) << 4);
190 p = sc_vtb_putchar(&scp->scr, p, c, a);
193 sc_vtb_copy(&scp->vtb, from, &scp->scr, from, count);
198 vga_txtcursor_shape(scr_stat *scp, int base, int height, int blink)
200 if (base < 0 || base >= scp->font_size)
202 /* the caller may set height <= 0 in order to disable the cursor */
204 scp->curs_attr.base = base;
205 scp->curs_attr.height = height;
207 (*vidsw[scp->sc->adapter]->set_hw_cursor_shape)(scp->sc->adp,
209 scp->font_size, blink);
213 draw_txtcharcursor(scr_stat *scp, int at, u_short c, u_short a, int flip)
218 scp->cursor_saveunder_char = c;
219 scp->cursor_saveunder_attr = a;
221 #ifndef SC_NO_FONT_LOADING
222 if (scp->curs_attr.flags & CONS_CHAR_CURSOR) {
227 if (scp->font_size < 14) {
230 } else if (scp->font_size >= 16) {
237 if (scp->curs_attr.base >= h)
241 | ((a & 0x7000) >> 4) | ((a & 0x0700) << 4);
242 bcopy(font + c*h, font + sc->cursor_char*h, h);
243 font = font + sc->cursor_char*h;
244 for (i = imax(h - scp->curs_attr.base - scp->curs_attr.height, 0);
245 i < h - scp->curs_attr.base; ++i) {
249 (*vidsw[sc->adapter]->load_font)(sc->adp, 0, h, font,
251 sc_vtb_putc(&scp->scr, at, sc->cursor_char, a);
253 #endif /* SC_NO_FONT_LOADING */
255 if ((a & 0x7000) == 0x7000) {
257 if ((a & 0x0700) == 0)
261 if ((a & 0x0700) == 0x0700)
266 | ((a & 0x7000) >> 4) | ((a & 0x0700) << 4);
267 sc_vtb_putc(&scp->scr, at, c, a);
272 vga_txtcursor(scr_stat *scp, int at, int blink, int on, int flip)
274 video_adapter_t *adp;
277 if (scp->curs_attr.height <= 0) /* the text cursor is disabled */
282 scp->status |= VR_CURSOR_BLINK;
284 scp->status |= VR_CURSOR_ON;
285 (*vidsw[adp->va_index]->set_hw_cursor)(adp,
289 if (scp->status & VR_CURSOR_ON)
290 (*vidsw[adp->va_index]->set_hw_cursor)(adp,
292 scp->status &= ~VR_CURSOR_ON;
295 scp->status &= ~VR_CURSOR_BLINK;
297 scp->status |= VR_CURSOR_ON;
298 draw_txtcharcursor(scp, at,
299 sc_vtb_getc(&scp->scr, at),
300 sc_vtb_geta(&scp->scr, at),
303 cursor_attr = scp->cursor_saveunder_attr;
305 cursor_attr = (cursor_attr & 0x8800)
306 | ((cursor_attr & 0x7000) >> 4)
307 | ((cursor_attr & 0x0700) << 4);
308 if (scp->status & VR_CURSOR_ON)
309 sc_vtb_putc(&scp->scr, at,
310 scp->cursor_saveunder_char,
312 scp->status &= ~VR_CURSOR_ON;
318 vga_txtblink(scr_stat *scp, int at, int flip)
322 #ifndef SC_NO_CUTPASTE
325 draw_txtmouse(scr_stat *scp, int x, int y)
327 #ifndef SC_ALT_MOUSE_IMAGE
328 if (ISMOUSEAVAIL(scp->sc->adp->va_flags)) {
329 u_char font_buf[128];
333 int xoffset, yoffset;
337 /* prepare mousepointer char's bitmaps */
338 pos = (y/scp->font_size - scp->yoff)*scp->xsize + x/8 - scp->xoff;
339 bcopy(scp->font + sc_vtb_getc(&scp->scr, pos)*scp->font_size,
340 &font_buf[0], scp->font_size);
341 bcopy(scp->font + sc_vtb_getc(&scp->scr, pos + 1)*scp->font_size,
342 &font_buf[32], scp->font_size);
344 + sc_vtb_getc(&scp->scr, pos + scp->xsize)*scp->font_size,
345 &font_buf[64], scp->font_size);
347 + sc_vtb_getc(&scp->scr, pos + scp->xsize + 1)*scp->font_size,
348 &font_buf[96], scp->font_size);
349 for (i = 0; i < scp->font_size; ++i) {
350 cursor[i] = font_buf[i]<<8 | font_buf[i+32];
351 cursor[i + scp->font_size] = font_buf[i+64]<<8 | font_buf[i+96];
354 /* now and-or in the mousepointer image */
356 yoffset = y%scp->font_size;
357 for (i = 0; i < 16; ++i) {
358 cursor[i + yoffset] =
359 (cursor[i + yoffset] & ~(mouse_and_mask[i] >> xoffset))
360 | (mouse_or_mask[i] >> xoffset);
362 for (i = 0; i < scp->font_size; ++i) {
363 font_buf[i] = (cursor[i] & 0xff00) >> 8;
364 font_buf[i + 32] = cursor[i] & 0xff;
365 font_buf[i + 64] = (cursor[i + scp->font_size] & 0xff00) >> 8;
366 font_buf[i + 96] = cursor[i + scp->font_size] & 0xff;
370 /* wait for vertical retrace to avoid jitter on some videocards */
371 crtc_addr = scp->sc->adp->va_crtc_addr;
372 while (!(inb(crtc_addr + 6) & 0x08)) /* idle */ ;
374 c = scp->sc->mouse_char;
375 (*vidsw[scp->sc->adapter]->load_font)(scp->sc->adp, 0, 32, font_buf,
378 sc_vtb_putc(&scp->scr, pos, c, sc_vtb_geta(&scp->scr, pos));
379 /* FIXME: may be out of range! */
380 sc_vtb_putc(&scp->scr, pos + scp->xsize, c + 2,
381 sc_vtb_geta(&scp->scr, pos + scp->xsize));
382 if (x < (scp->xsize - 1)*8) {
383 sc_vtb_putc(&scp->scr, pos + 1, c + 1,
384 sc_vtb_geta(&scp->scr, pos + 1));
385 sc_vtb_putc(&scp->scr, pos + scp->xsize + 1, c + 3,
386 sc_vtb_geta(&scp->scr, pos + scp->xsize + 1));
389 #endif /* SC_ALT_MOUSE_IMAGE */
391 /* Red, magenta and brown are mapped to green to to keep it readable */
392 static const int col_conv[16] = {
393 6, 6, 6, 6, 2, 2, 2, 6, 14, 14, 14, 14, 10, 10, 10, 14
399 pos = (y/scp->font_size - scp->yoff)*scp->xsize + x/8 - scp->xoff;
400 a = sc_vtb_geta(&scp->scr, pos);
401 if (scp->sc->adp->va_flags & V_ADP_COLOR)
402 color = (col_conv[(a & 0xf000) >> 12] << 12)
403 | ((a & 0x0f00) | 0x0800);
405 color = ((a & 0xf000) >> 4) | ((a & 0x0f00) << 4);
406 sc_vtb_putc(&scp->scr, pos, sc_vtb_getc(&scp->scr, pos), color);
411 remove_txtmouse(scr_stat *scp, int x, int y)
416 vga_txtmouse(scr_stat *scp, int x, int y, int on)
419 draw_txtmouse(scp, x, y);
421 remove_txtmouse(scp, x, y);
424 #endif /* SC_NO_CUTPASTE */
428 /* pixel (raster text) mode renderer */
431 vga_pxlclear(scr_stat *scp, int c, int attr)
438 /* XXX: we are just filling the screen with the background color... */
439 outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */
440 outw(GDCIDX, 0x0003); /* data rotate/function select */
441 outw(GDCIDX, 0x0f01); /* set/reset enable */
442 outw(GDCIDX, 0xff08); /* bit mask */
443 outw(GDCIDX, ((attr & 0xf000) >> 4) | 0x00); /* set/reset */
444 line_width = scp->sc->adp->va_line_width;
445 lines = scp->ysize*scp->font_size;
446 p = scp->sc->adp->va_window + line_width*scp->yoff*scp->font_size
448 for (i = 0; i < lines; ++i) {
449 bzero_io((void *)p, scp->xsize);
452 outw(GDCIDX, 0x0000); /* set/reset */
453 outw(GDCIDX, 0x0001); /* set/reset enable */
457 vga_pxlborder(scr_stat *scp, int color)
465 (*vidsw[scp->sc->adapter]->set_border)(scp->sc->adp, color);
467 outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */
468 outw(GDCIDX, 0x0003); /* data rotate/function select */
469 outw(GDCIDX, 0x0f01); /* set/reset enable */
470 outw(GDCIDX, 0xff08); /* bit mask */
471 outw(GDCIDX, (color << 8) | 0x00); /* set/reset */
472 line_width = scp->sc->adp->va_line_width;
473 p = scp->sc->adp->va_window;
475 bzero_io((void *)p, line_width*scp->yoff*scp->font_size);
476 y = (scp->yoff + scp->ysize)*scp->font_size;
478 bzero_io((void *)(p + line_width*y), line_width*(scp->ypixel - y));
479 y = scp->yoff*scp->font_size;
480 x = scp->xpixel/8 - scp->xoff - scp->xsize;
481 for (i = 0; i < scp->ysize*scp->font_size; ++i) {
483 bzero_io((void *)(p + line_width*(y + i)), scp->xoff);
485 bzero_io((void *)(p + line_width*(y + i)
486 + scp->xoff + scp->xsize), x);
488 outw(GDCIDX, 0x0000); /* set/reset */
489 outw(GDCIDX, 0x0001); /* set/reset enable */
493 vga_egadraw(scr_stat *scp, int from, int count, int flip)
505 line_width = scp->sc->adp->va_line_width;
506 d = scp->sc->adp->va_window
508 + scp->yoff*scp->font_size*line_width
510 + scp->font_size*line_width*(from/scp->xsize);
512 outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */
513 outw(GDCIDX, 0x0003); /* data rotate/function select */
514 outw(GDCIDX, 0x0f01); /* set/reset enable */
516 if (from + count > scp->xsize*scp->ysize)
517 count = scp->xsize*scp->ysize - from;
518 for (i = from; count-- > 0; ++i) {
519 a = sc_vtb_geta(&scp->vtb, i);
521 col1 = ((a & 0x7000) >> 4) | (a & 0x0800);
522 col2 = ((a & 0x8000) >> 4) | (a & 0x0700);
525 col2 = (a & 0xf000) >> 4;
527 /* set background color in EGA/VGA latch */
530 outw(GDCIDX, bg | 0x00); /* set/reset */
531 outw(GDCIDX, 0xff08); /* bit mask */
533 c = readb(d); /* set bg color in the latch */
535 /* foreground color */
536 outw(GDCIDX, col1 | 0x00); /* set/reset */
538 f = &(scp->font[sc_vtb_getc(&scp->vtb, i)*scp->font_size]);
539 for (j = 0; j < scp->font_size; ++j, ++f) {
540 outw(GDCIDX, (*f << 8) | 0x08); /* bit mask */
545 if ((i % scp->xsize) == scp->xsize - 1)
547 + (scp->font_size - 1)*line_width;
549 outw(GDCIDX, 0x0000); /* set/reset */
550 outw(GDCIDX, 0x0001); /* set/reset enable */
551 outw(GDCIDX, 0xff08); /* bit mask */
555 vga_vgadraw(scr_stat *scp, int from, int count, int flip)
567 line_width = scp->sc->adp->va_line_width;
568 d = scp->sc->adp->va_window
570 + scp->yoff*scp->font_size*line_width
572 + scp->font_size*line_width*(from/scp->xsize);
574 outw(GDCIDX, 0x0305); /* read mode 0, write mode 3 */
575 outw(GDCIDX, 0x0003); /* data rotate/function select */
576 outw(GDCIDX, 0x0f01); /* set/reset enable */
577 outw(GDCIDX, 0xff08); /* bit mask */
579 if (from + count > scp->xsize*scp->ysize)
580 count = scp->xsize*scp->ysize - from;
581 for (i = from; count-- > 0; ++i) {
582 a = sc_vtb_geta(&scp->vtb, i);
584 col1 = ((a & 0x7000) >> 4) | (a & 0x0800);
585 col2 = ((a & 0x8000) >> 4) | (a & 0x0700);
588 col2 = (a & 0xf000) >> 4;
590 /* set background color in EGA/VGA latch */
593 outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */
594 outw(GDCIDX, bg | 0x00); /* set/reset */
596 c = readb(d); /* set bg color in the latch */
597 outw(GDCIDX, 0x0305); /* read mode 0, write mode 3 */
599 /* foreground color */
600 outw(GDCIDX, col1 | 0x00); /* set/reset */
602 f = &(scp->font[sc_vtb_getc(&scp->vtb, i)*scp->font_size]);
603 for (j = 0; j < scp->font_size; ++j, ++f) {
608 if ((i % scp->xsize) == scp->xsize - 1)
610 + (scp->font_size - 1)*line_width;
612 outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */
613 outw(GDCIDX, 0x0000); /* set/reset */
614 outw(GDCIDX, 0x0001); /* set/reset enable */
618 vga_pxlcursor_shape(scr_stat *scp, int base, int height, int blink)
620 if (base < 0 || base >= scp->font_size)
622 /* the caller may set height <= 0 in order to disable the cursor */
624 scp->curs_attr.base = base;
625 scp->curs_attr.height = height;
630 draw_pxlcursor(scr_stat *scp, int at, int on, int flip)
641 line_width = scp->sc->adp->va_line_width;
642 d = scp->sc->adp->va_window
644 + scp->yoff*scp->font_size*line_width
646 + scp->font_size*line_width*(at/scp->xsize)
647 + (scp->font_size - scp->curs_attr.base - 1)*line_width;
649 outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */
650 outw(GDCIDX, 0x0003); /* data rotate/function select */
651 outw(GDCIDX, 0x0f01); /* set/reset enable */
652 /* set background color in EGA/VGA latch */
653 a = sc_vtb_geta(&scp->vtb, at);
655 col = (on) ? ((a & 0xf000) >> 4) : (a & 0x0f00);
657 col = (on) ? (a & 0x0f00) : ((a & 0xf000) >> 4);
658 outw(GDCIDX, col | 0x00); /* set/reset */
659 outw(GDCIDX, 0xff08); /* bit mask */
661 c = readb(d); /* set bg color in the latch */
662 /* foreground color */
664 col = (on) ? (a & 0x0f00) : ((a & 0xf000) >> 4);
666 col = (on) ? ((a & 0xf000) >> 4) : (a & 0x0f00);
667 outw(GDCIDX, col | 0x00); /* set/reset */
668 f = &(scp->font[sc_vtb_getc(&scp->vtb, at)*scp->font_size
669 + scp->font_size - scp->curs_attr.base - 1]);
670 height = imin(scp->curs_attr.height, scp->font_size);
671 for (i = 0; i < height; ++i, --f) {
672 outw(GDCIDX, (*f << 8) | 0x08); /* bit mask */
676 outw(GDCIDX, 0x0000); /* set/reset */
677 outw(GDCIDX, 0x0001); /* set/reset enable */
678 outw(GDCIDX, 0xff08); /* bit mask */
681 static int pxlblinkrate = 0;
684 vga_pxlcursor(scr_stat *scp, int at, int blink, int on, int flip)
686 if (scp->curs_attr.height <= 0) /* the text cursor is disabled */
691 scp->status |= VR_CURSOR_ON;
692 draw_pxlcursor(scp, at, on, flip);
693 } else if (++pxlblinkrate & 4) {
695 scp->status ^= VR_CURSOR_ON;
696 draw_pxlcursor(scp, at,
697 scp->status & VR_CURSOR_ON,
701 if (scp->status & VR_CURSOR_ON)
702 draw_pxlcursor(scp, at, on, flip);
703 scp->status &= ~VR_CURSOR_ON;
706 scp->status |= VR_CURSOR_BLINK;
708 scp->status &= ~VR_CURSOR_BLINK;
712 vga_pxlblink(scr_stat *scp, int at, int flip)
714 if (!(scp->status & VR_CURSOR_BLINK))
716 if (!(++pxlblinkrate & 4))
719 scp->status ^= VR_CURSOR_ON;
720 draw_pxlcursor(scp, at, scp->status & VR_CURSOR_ON, flip);
723 #ifndef SC_NO_CUTPASTE
726 draw_pxlmouse(scr_stat *scp, int x, int y)
735 line_width = scp->sc->adp->va_line_width;
736 xoff = (x - scp->xoff*8)%8;
737 yoff = y - (y/line_width)*line_width;
738 ymax = imin(y + 16, scp->ypixel);
740 outw(GDCIDX, 0x0805); /* read mode 1, write mode 0 */
741 outw(GDCIDX, 0x0001); /* set/reset enable */
742 outw(GDCIDX, 0x0002); /* color compare */
743 outw(GDCIDX, 0x0007); /* color don't care */
744 outw(GDCIDX, 0xff08); /* bit mask */
745 outw(GDCIDX, 0x0803); /* data rotate/function select (and) */
746 p = scp->sc->adp->va_window + line_width*y + x/8;
747 if (x < scp->xpixel - 8) {
748 for (i = y, j = 0; i < ymax; ++i, ++j) {
749 m = ~(mouse_and_mask[j] >> xoff);
751 *(u_char *)p &= m >> 8;
752 *(u_char *)(p + 1) &= m;
753 #elif defined(__alpha__)
754 writeb(p, readb(p) & (m >> 8));
755 writeb(p + 1, readb(p + 1) & (m >> 8));
761 for (i = y, j = 0; i < ymax; ++i, ++j) {
762 m = ~(mouse_and_mask[j] >> xoff);
765 #elif defined(__alpha__)
766 writeb(p, readb(p) & (m >> 8));
771 outw(GDCIDX, 0x1003); /* data rotate/function select (or) */
772 p = scp->sc->adp->va_window + line_width*y + x/8;
773 if (x < scp->xpixel - 8) {
774 for (i = y, j = 0; i < ymax; ++i, ++j) {
775 m = mouse_or_mask[j] >> xoff;
777 *(u_char *)p &= m >> 8;
778 *(u_char *)(p + 1) &= m;
779 #elif defined(__alpha__)
780 writeb(p, readb(p) & (m >> 8));
781 writeb(p + 1, readb(p + 1) & (m >> 8));
786 for (i = y, j = 0; i < ymax; ++i, ++j) {
787 m = mouse_or_mask[j] >> xoff;
790 #elif defined(__alpha__)
791 writeb(p, readb(p) & (m >> 8));
796 outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */
797 outw(GDCIDX, 0x0003); /* data rotate/function select */
801 remove_pxlmouse(scr_stat *scp, int x, int y)
810 /* erase the mouse cursor image */
811 col = x/8 - scp->xoff;
812 row = y/scp->font_size - scp->yoff;
813 pos = row*scp->xsize + col;
814 i = (col < scp->xsize - 1) ? 2 : 1;
815 (*scp->rndr->draw)(scp, pos, i, FALSE);
816 if (row < scp->ysize - 1)
817 (*scp->rndr->draw)(scp, pos + scp->xsize, i, FALSE);
819 /* paint border if necessary */
820 line_width = scp->sc->adp->va_line_width;
821 outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */
822 outw(GDCIDX, 0x0003); /* data rotate/function select */
823 outw(GDCIDX, 0x0f01); /* set/reset enable */
824 outw(GDCIDX, 0xff08); /* bit mask */
825 outw(GDCIDX, (scp->border << 8) | 0x00); /* set/reset */
826 if (row == scp->ysize - 1) {
827 i = (scp->ysize + scp->yoff)*scp->font_size;
828 ymax = imin(i + scp->font_size, scp->ypixel);
829 p = scp->sc->adp->va_window + i*line_width + scp->xoff + col;
830 if (col < scp->xsize - 1) {
831 for (; i < ymax; ++i) {
837 for (; i < ymax; ++i) {
843 if ((col == scp->xsize - 1) && (scp->xoff > 0)) {
844 i = (row + scp->yoff)*scp->font_size;
845 ymax = imin(i + scp->font_size*2, scp->ypixel);
846 p = scp->sc->adp->va_window + i*line_width
847 + scp->xoff + scp->xsize;
848 for (; i < ymax; ++i) {
853 outw(GDCIDX, 0x0000); /* set/reset */
854 outw(GDCIDX, 0x0001); /* set/reset enable */
858 vga_pxlmouse(scr_stat *scp, int x, int y, int on)
861 draw_pxlmouse(scp, x, y);
863 remove_pxlmouse(scp, x, y);
866 #endif /* SC_NO_CUTPASTE */
867 #endif /* SC_PIXEL_MODE */
869 #ifndef SC_NO_MODE_CHANGE
871 /* graphics mode renderer */
874 vga_grborder(scr_stat *scp, int color)
876 (*vidsw[scp->sc->adapter]->set_border)(scp->sc->adp, color);