1 /*- 2 * Copyright (c) 1999 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp> 3 * All rights reserved. 4 * 5 * This code is derived from software contributed to The DragonFly Project 6 * by Sascha Wildner <saw@online.de> 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer as 13 * the first lines of this file unmodified. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR 19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, 22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * 29 */ 30 31 #include <sys/cdefs.h> 32 __FBSDID("$FreeBSD$"); 33 34 #include "opt_syscons.h" 35 #include "opt_vga.h" 36 37 #include <sys/param.h> 38 #include <sys/systm.h> 39 #include <sys/kernel.h> 40 #include <sys/module.h> 41 #include <sys/fbio.h> 42 #include <sys/consio.h> 43 44 #include <machine/bus.h> 45 46 #include <dev/fb/fbreg.h> 47 #include <dev/fb/vgareg.h> 48 #include <dev/syscons/syscons.h> 49 50 #include <isa/isareg.h> 51 52 #ifndef SC_RENDER_DEBUG 53 #define SC_RENDER_DEBUG 0 54 #endif 55 56 static vr_clear_t vga_txtclear; 57 static vr_draw_border_t vga_txtborder; 58 static vr_draw_t vga_txtdraw; 59 static vr_set_cursor_t vga_txtcursor_shape; 60 static vr_draw_cursor_t vga_txtcursor; 61 static vr_blink_cursor_t vga_txtblink; 62 #ifndef SC_NO_CUTPASTE 63 static vr_draw_mouse_t vga_txtmouse; 64 #else 65 #define vga_txtmouse (vr_draw_mouse_t *)vga_nop 66 #endif 67 68 #ifdef SC_PIXEL_MODE 69 static vr_init_t vga_rndrinit; 70 static vr_clear_t vga_pxlclear_direct; 71 static vr_clear_t vga_pxlclear_planar; 72 static vr_draw_border_t vga_pxlborder_direct; 73 static vr_draw_border_t vga_pxlborder_planar; 74 static vr_draw_t vga_egadraw; 75 static vr_draw_t vga_vgadraw_direct; 76 static vr_draw_t vga_vgadraw_planar; 77 static vr_set_cursor_t vga_pxlcursor_shape; 78 static vr_draw_cursor_t vga_pxlcursor_direct; 79 static vr_draw_cursor_t vga_pxlcursor_planar; 80 static vr_blink_cursor_t vga_pxlblink_direct; 81 static vr_blink_cursor_t vga_pxlblink_planar; 82 #ifndef SC_NO_CUTPASTE 83 static vr_draw_mouse_t vga_pxlmouse_direct; 84 static vr_draw_mouse_t vga_pxlmouse_planar; 85 #else 86 #define vga_pxlmouse_direct (vr_draw_mouse_t *)vga_nop 87 #define vga_pxlmouse_planar (vr_draw_mouse_t *)vga_nop 88 #endif 89 #endif /* SC_PIXEL_MODE */ 90 91 #ifndef SC_NO_MODE_CHANGE 92 static vr_draw_border_t vga_grborder; 93 #endif 94 95 static void vga_nop(scr_stat *scp); 96 97 static sc_rndr_sw_t txtrndrsw = { 98 (vr_init_t *)vga_nop, 99 vga_txtclear, 100 vga_txtborder, 101 vga_txtdraw, 102 vga_txtcursor_shape, 103 vga_txtcursor, 104 vga_txtblink, 105 (vr_set_mouse_t *)vga_nop, 106 vga_txtmouse, 107 }; 108 RENDERER(mda, 0, txtrndrsw, vga_set); 109 RENDERER(cga, 0, txtrndrsw, vga_set); 110 RENDERER(ega, 0, txtrndrsw, vga_set); 111 RENDERER(vga, 0, txtrndrsw, vga_set); 112 113 #ifdef SC_PIXEL_MODE 114 static sc_rndr_sw_t egarndrsw = { 115 (vr_init_t *)vga_nop, 116 vga_pxlclear_planar, 117 vga_pxlborder_planar, 118 vga_egadraw, 119 vga_pxlcursor_shape, 120 vga_pxlcursor_planar, 121 vga_pxlblink_planar, 122 (vr_set_mouse_t *)vga_nop, 123 vga_pxlmouse_planar, 124 }; 125 RENDERER(ega, PIXEL_MODE, egarndrsw, vga_set); 126 127 static sc_rndr_sw_t vgarndrsw = { 128 vga_rndrinit, 129 (vr_clear_t *)vga_nop, 130 (vr_draw_border_t *)vga_nop, 131 (vr_draw_t *)vga_nop, 132 vga_pxlcursor_shape, 133 (vr_draw_cursor_t *)vga_nop, 134 (vr_blink_cursor_t *)vga_nop, 135 (vr_set_mouse_t *)vga_nop, 136 (vr_draw_mouse_t *)vga_nop, 137 }; 138 RENDERER(vga, PIXEL_MODE, vgarndrsw, vga_set); 139 #endif /* SC_PIXEL_MODE */ 140 141 #ifndef SC_NO_MODE_CHANGE 142 static sc_rndr_sw_t grrndrsw = { 143 (vr_init_t *)vga_nop, 144 (vr_clear_t *)vga_nop, 145 vga_grborder, 146 (vr_draw_t *)vga_nop, 147 (vr_set_cursor_t *)vga_nop, 148 (vr_draw_cursor_t *)vga_nop, 149 (vr_blink_cursor_t *)vga_nop, 150 (vr_set_mouse_t *)vga_nop, 151 (vr_draw_mouse_t *)vga_nop, 152 }; 153 RENDERER(cga, GRAPHICS_MODE, grrndrsw, vga_set); 154 RENDERER(ega, GRAPHICS_MODE, grrndrsw, vga_set); 155 RENDERER(vga, GRAPHICS_MODE, grrndrsw, vga_set); 156 #endif /* SC_NO_MODE_CHANGE */ 157 158 RENDERER_MODULE(vga, vga_set); 159 160 #ifndef SC_NO_CUTPASTE 161 #if !defined(SC_ALT_MOUSE_IMAGE) || defined(SC_PIXEL_MODE) 162 struct mousedata { 163 u_short md_border[16]; 164 u_short md_interior[16]; 165 u_short md_width; 166 u_short md_height; 167 }; 168 169 static const struct mousedata mouse9x13 = { { 170 0xc000, 0xa000, 0x9000, 0x8800, 0x8400, 0x8200, 0x8100, 0x9780, 171 0xf200, 0x1200, 0x1900, 0x0900, 0x0f00, 0x0000, 0x0000, 0x0000, }, { 172 0x0000, 0x4000, 0x6000, 0x7000, 0x7800, 0x7c00, 0x7e00, 0x6800, 173 0x0c00, 0x0c00, 0x0600, 0x0600, 0x0000, 0x0000, 0x0000, 0x0000, }, 174 9, 13, 175 }; 176 177 static const struct mousedata mouse10x16 = { { 178 0xc000, 0xa000, 0x9000, 0x8800, 0x8400, 0x8200, 0x8100, 0x8080, 179 0x8040, 0x83c0, 0x9200, 0xa900, 0xc900, 0x0480, 0x0480, 0x0300, }, { 180 0x0000, 0x4000, 0x6000, 0x7000, 0x7800, 0x7c00, 0x7e00, 0x7f00, 181 0x7f80, 0x7c00, 0x6c00, 0x4600, 0x0600, 0x0300, 0x0300, 0x0000, }, 182 10, 16, 183 }; 184 #endif 185 #endif 186 187 #ifdef SC_PIXEL_MODE 188 #define GET_PIXEL(scp, pos, x, w) \ 189 ({ \ 190 (scp)->sc->adp->va_window + \ 191 (x) * (scp)->xoff + \ 192 (scp)->yoff * (scp)->font_size * (w) + \ 193 (x) * ((pos) % (scp)->xsize) + \ 194 (scp)->font_size * (w) * ((pos) / (scp)->xsize); \ 195 }) 196 197 #define DRAW_PIXEL(scp, pos, color) do { \ 198 switch ((scp)->sc->adp->va_info.vi_depth) { \ 199 case 32: \ 200 writel((pos), vga_palette32[color]); \ 201 break; \ 202 case 24: \ 203 if (((pos) & 1) == 0) { \ 204 writew((pos), vga_palette32[color]); \ 205 writeb((pos) + 2, vga_palette32[color] >> 16); \ 206 } else { \ 207 writeb((pos), vga_palette32[color]); \ 208 writew((pos) + 1, vga_palette32[color] >> 8); \ 209 } \ 210 break; \ 211 case 16: \ 212 if ((scp)->sc->adp->va_info.vi_pixel_fsizes[1] == 5) \ 213 writew((pos), vga_palette15[color]); \ 214 else \ 215 writew((pos), vga_palette16[color]); \ 216 break; \ 217 case 15: \ 218 writew((pos), vga_palette15[color]); \ 219 break; \ 220 case 8: \ 221 writeb((pos), (uint8_t)(color)); \ 222 } \ 223 } while (0) 224 225 static uint32_t vga_palette32[16] = { 226 0x000000, 0x0000ad, 0x00ad00, 0x00adad, 227 0xad0000, 0xad00ad, 0xad5200, 0xadadad, 228 0x525252, 0x5252ff, 0x52ff52, 0x52ffff, 229 0xff5252, 0xff52ff, 0xffff52, 0xffffff 230 }; 231 232 static uint16_t vga_palette16[16] = { 233 0x0000, 0x0016, 0x0560, 0x0576, 0xb000, 0xb016, 0xb2a0, 0xb576, 234 0x52aa, 0x52bf, 0x57ea, 0x57ff, 0xfaaa, 0xfabf, 0xffea, 0xffff 235 }; 236 237 static uint16_t vga_palette15[16] = { 238 0x0000, 0x0016, 0x02c0, 0x02d6, 0x5800, 0x5816, 0x5940, 0x5ad6, 239 0x294a, 0x295f, 0x2bea, 0x2bff, 0x7d4a, 0x7d5f, 0x7fea, 0x7fff 240 }; 241 242 #ifndef SC_NO_CUTPASTE 243 static uint32_t mouse_buf32[256]; 244 static uint16_t mouse_buf16[256]; 245 static uint8_t mouse_buf8[256]; 246 #endif 247 #endif 248 249 static void 250 vga_nop(scr_stat *scp) 251 { 252 } 253 254 /* text mode renderer */ 255 256 static void 257 vga_txtclear(scr_stat *scp, int c, int attr) 258 { 259 sc_vtb_clear(&scp->scr, c, attr); 260 } 261 262 static void 263 vga_txtborder(scr_stat *scp, int color) 264 { 265 vidd_set_border(scp->sc->adp, color); 266 } 267 268 static void 269 vga_txtdraw(scr_stat *scp, int from, int count, int flip) 270 { 271 vm_offset_t p; 272 int c; 273 int a; 274 275 if (from + count > scp->xsize*scp->ysize) 276 count = scp->xsize*scp->ysize - from; 277 278 if (flip) { 279 for (p = sc_vtb_pointer(&scp->scr, from); count-- > 0; ++from) { 280 c = sc_vtb_getc(&scp->vtb, from); 281 a = sc_vtb_geta(&scp->vtb, from); 282 a = (a & 0x8800) | ((a & 0x7000) >> 4) 283 | ((a & 0x0700) << 4); 284 p = sc_vtb_putchar(&scp->scr, p, c, a); 285 } 286 } else { 287 sc_vtb_copy(&scp->vtb, from, &scp->scr, from, count); 288 } 289 } 290 291 static void 292 vga_txtcursor_shape(scr_stat *scp, int base, int height, int blink) 293 { 294 if (base < 0 || base >= scp->font_size) 295 return; 296 /* the caller may set height <= 0 in order to disable the cursor */ 297 #if 0 298 scp->curs_attr.base = base; 299 scp->curs_attr.height = height; 300 #endif 301 vidd_set_hw_cursor_shape(scp->sc->adp, base, height, 302 scp->font_size, blink); 303 } 304 305 static void 306 draw_txtcharcursor(scr_stat *scp, int at, u_short c, u_short a, int flip) 307 { 308 sc_softc_t *sc; 309 310 sc = scp->sc; 311 312 #ifndef SC_NO_FONT_LOADING 313 if (scp->curs_attr.flags & CONS_CHAR_CURSOR) { 314 unsigned char *font; 315 int h; 316 int i; 317 318 if (scp->font_size < 14) { 319 font = sc->font_8; 320 h = 8; 321 } else if (scp->font_size >= 16) { 322 font = sc->font_16; 323 h = 16; 324 } else { 325 font = sc->font_14; 326 h = 14; 327 } 328 if (scp->curs_attr.base >= h) 329 return; 330 if (flip) 331 a = (a & 0x8800) 332 | ((a & 0x7000) >> 4) | ((a & 0x0700) << 4); 333 bcopy(font + c*h, font + sc->cursor_char*h, h); 334 font = font + sc->cursor_char*h; 335 for (i = imax(h - scp->curs_attr.base - scp->curs_attr.height, 0); 336 i < h - scp->curs_attr.base; ++i) { 337 font[i] ^= 0xff; 338 } 339 /* XXX */ 340 vidd_load_font(sc->adp, 0, h, 8, font, sc->cursor_char, 1); 341 sc_vtb_putc(&scp->scr, at, sc->cursor_char, a); 342 } else 343 #endif /* SC_NO_FONT_LOADING */ 344 { 345 if ((a & 0x7000) == 0x7000) { 346 a &= 0x8f00; 347 if ((a & 0x0700) == 0) 348 a |= 0x0700; 349 } else { 350 a |= 0x7000; 351 if ((a & 0x0700) == 0x0700) 352 a &= 0xf000; 353 } 354 if (flip) 355 a = (a & 0x8800) 356 | ((a & 0x7000) >> 4) | ((a & 0x0700) << 4); 357 sc_vtb_putc(&scp->scr, at, c, a); 358 } 359 } 360 361 static void 362 vga_txtcursor(scr_stat *scp, int at, int blink, int on, int flip) 363 { 364 video_adapter_t *adp; 365 int cursor_attr; 366 367 if (scp->curs_attr.height <= 0) /* the text cursor is disabled */ 368 return; 369 370 adp = scp->sc->adp; 371 if (blink) { 372 scp->status |= VR_CURSOR_BLINK; 373 if (on) { 374 scp->status |= VR_CURSOR_ON; 375 vidd_set_hw_cursor(adp, at%scp->xsize, 376 at/scp->xsize); 377 } else { 378 if (scp->status & VR_CURSOR_ON) 379 vidd_set_hw_cursor(adp, -1, -1); 380 scp->status &= ~VR_CURSOR_ON; 381 } 382 } else { 383 scp->status &= ~VR_CURSOR_BLINK; 384 if (on) { 385 scp->status |= VR_CURSOR_ON; 386 draw_txtcharcursor(scp, at, 387 sc_vtb_getc(&scp->vtb, at), 388 sc_vtb_geta(&scp->vtb, at), 389 flip); 390 } else { 391 cursor_attr = sc_vtb_geta(&scp->vtb, at); 392 if (flip) 393 cursor_attr = (cursor_attr & 0x8800) 394 | ((cursor_attr & 0x7000) >> 4) 395 | ((cursor_attr & 0x0700) << 4); 396 if (scp->status & VR_CURSOR_ON) 397 sc_vtb_putc(&scp->scr, at, 398 sc_vtb_getc(&scp->vtb, at), 399 cursor_attr); 400 scp->status &= ~VR_CURSOR_ON; 401 } 402 } 403 } 404 405 static void 406 vga_txtblink(scr_stat *scp, int at, int flip) 407 { 408 } 409 410 int sc_txtmouse_no_retrace_wait; 411 412 #ifndef SC_NO_CUTPASTE 413 414 static void 415 draw_txtmouse(scr_stat *scp, int x, int y) 416 { 417 #ifndef SC_ALT_MOUSE_IMAGE 418 if (ISMOUSEAVAIL(scp->sc->adp->va_flags)) { 419 const struct mousedata *mdp; 420 u_char font_buf[128]; 421 u_short cursor[32]; 422 u_char c; 423 int pos; 424 int xoffset, yoffset; 425 int crtc_addr; 426 int i; 427 428 mdp = &mouse9x13; 429 430 /* prepare mousepointer char's bitmaps */ 431 pos = (y/scp->font_size - scp->yoff)*scp->xsize + x/8 - scp->xoff; 432 bcopy(scp->font + sc_vtb_getc(&scp->scr, pos)*scp->font_size, 433 &font_buf[0], scp->font_size); 434 bcopy(scp->font + sc_vtb_getc(&scp->scr, pos + 1)*scp->font_size, 435 &font_buf[32], scp->font_size); 436 bcopy(scp->font 437 + sc_vtb_getc(&scp->scr, pos + scp->xsize)*scp->font_size, 438 &font_buf[64], scp->font_size); 439 bcopy(scp->font 440 + sc_vtb_getc(&scp->scr, pos + scp->xsize + 1)*scp->font_size, 441 &font_buf[96], scp->font_size); 442 for (i = 0; i < scp->font_size; ++i) { 443 cursor[i] = font_buf[i]<<8 | font_buf[i+32]; 444 cursor[i + scp->font_size] = font_buf[i+64]<<8 | font_buf[i+96]; 445 } 446 447 /* now and-or in the mousepointer image */ 448 xoffset = x%8; 449 yoffset = y%scp->font_size; 450 for (i = 0; i < 16; ++i) { 451 cursor[i + yoffset] = 452 (cursor[i + yoffset] & ~(mdp->md_border[i] >> xoffset)) 453 | (mdp->md_interior[i] >> xoffset); 454 } 455 for (i = 0; i < scp->font_size; ++i) { 456 font_buf[i] = (cursor[i] & 0xff00) >> 8; 457 font_buf[i + 32] = cursor[i] & 0xff; 458 font_buf[i + 64] = (cursor[i + scp->font_size] & 0xff00) >> 8; 459 font_buf[i + 96] = cursor[i + scp->font_size] & 0xff; 460 } 461 462 #if 1 463 /* wait for vertical retrace to avoid jitter on some videocards */ 464 crtc_addr = scp->sc->adp->va_crtc_addr; 465 while (!sc_txtmouse_no_retrace_wait && 466 !(inb(crtc_addr + 6) & 0x08)) 467 /* idle */ ; 468 #endif 469 c = scp->sc->mouse_char; 470 vidd_load_font(scp->sc->adp, 0, 32, 8, font_buf, c, 4); 471 472 sc_vtb_putc(&scp->scr, pos, c, sc_vtb_geta(&scp->scr, pos)); 473 /* FIXME: may be out of range! */ 474 sc_vtb_putc(&scp->scr, pos + scp->xsize, c + 2, 475 sc_vtb_geta(&scp->scr, pos + scp->xsize)); 476 if (x < (scp->xsize - 1)*8) { 477 sc_vtb_putc(&scp->scr, pos + 1, c + 1, 478 sc_vtb_geta(&scp->scr, pos + 1)); 479 sc_vtb_putc(&scp->scr, pos + scp->xsize + 1, c + 3, 480 sc_vtb_geta(&scp->scr, pos + scp->xsize + 1)); 481 } 482 } else 483 #endif /* SC_ALT_MOUSE_IMAGE */ 484 { 485 /* Red, magenta and brown are mapped to green to to keep it readable */ 486 static const int col_conv[16] = { 487 6, 6, 6, 6, 2, 2, 2, 6, 14, 14, 14, 14, 10, 10, 10, 14 488 }; 489 int pos; 490 int color; 491 int a; 492 493 pos = (y/scp->font_size - scp->yoff)*scp->xsize + x/8 - scp->xoff; 494 a = sc_vtb_geta(&scp->scr, pos); 495 if (scp->sc->adp->va_flags & V_ADP_COLOR) 496 color = (col_conv[(a & 0xf000) >> 12] << 12) 497 | ((a & 0x0f00) | 0x0800); 498 else 499 color = ((a & 0xf000) >> 4) | ((a & 0x0f00) << 4); 500 sc_vtb_putc(&scp->scr, pos, sc_vtb_getc(&scp->scr, pos), color); 501 } 502 } 503 504 static void 505 remove_txtmouse(scr_stat *scp, int x, int y) 506 { 507 } 508 509 static void 510 vga_txtmouse(scr_stat *scp, int x, int y, int on) 511 { 512 if (on) 513 draw_txtmouse(scp, x, y); 514 else 515 remove_txtmouse(scp, x, y); 516 } 517 518 #endif /* SC_NO_CUTPASTE */ 519 520 #ifdef SC_PIXEL_MODE 521 522 /* pixel (raster text) mode renderer */ 523 524 static void 525 vga_rndrinit(scr_stat *scp) 526 { 527 if (scp->sc->adp->va_info.vi_mem_model == V_INFO_MM_PLANAR) { 528 scp->rndr->clear = vga_pxlclear_planar; 529 scp->rndr->draw_border = vga_pxlborder_planar; 530 scp->rndr->draw = vga_vgadraw_planar; 531 scp->rndr->draw_cursor = vga_pxlcursor_planar; 532 scp->rndr->blink_cursor = vga_pxlblink_planar; 533 scp->rndr->draw_mouse = vga_pxlmouse_planar; 534 } else 535 if (scp->sc->adp->va_info.vi_mem_model == V_INFO_MM_DIRECT || 536 scp->sc->adp->va_info.vi_mem_model == V_INFO_MM_PACKED) { 537 scp->rndr->clear = vga_pxlclear_direct; 538 scp->rndr->draw_border = vga_pxlborder_direct; 539 scp->rndr->draw = vga_vgadraw_direct; 540 scp->rndr->draw_cursor = vga_pxlcursor_direct; 541 scp->rndr->blink_cursor = vga_pxlblink_direct; 542 scp->rndr->draw_mouse = vga_pxlmouse_direct; 543 } 544 } 545 546 static void 547 vga_pxlclear_direct(scr_stat *scp, int c, int attr) 548 { 549 vm_offset_t p; 550 int line_width; 551 int pixel_size; 552 int lines; 553 int i; 554 555 line_width = scp->sc->adp->va_line_width; 556 pixel_size = scp->sc->adp->va_info.vi_pixel_size; 557 lines = scp->ysize * scp->font_size; 558 p = scp->sc->adp->va_window + 559 line_width * scp->yoff * scp->font_size + 560 scp->xoff * 8 * pixel_size; 561 562 for (i = 0; i < lines; ++i) { 563 bzero_io((void *)p, scp->xsize * 8 * pixel_size); 564 p += line_width; 565 } 566 } 567 568 static void 569 vga_pxlclear_planar(scr_stat *scp, int c, int attr) 570 { 571 vm_offset_t p; 572 int line_width; 573 int lines; 574 int i; 575 576 /* XXX: we are just filling the screen with the background color... */ 577 outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */ 578 outw(GDCIDX, 0x0003); /* data rotate/function select */ 579 outw(GDCIDX, 0x0f01); /* set/reset enable */ 580 outw(GDCIDX, 0xff08); /* bit mask */ 581 outw(GDCIDX, ((attr & 0xf000) >> 4) | 0x00); /* set/reset */ 582 line_width = scp->sc->adp->va_line_width; 583 lines = scp->ysize*scp->font_size; 584 p = scp->sc->adp->va_window + line_width*scp->yoff*scp->font_size 585 + scp->xoff; 586 for (i = 0; i < lines; ++i) { 587 bzero_io((void *)p, scp->xsize); 588 p += line_width; 589 } 590 outw(GDCIDX, 0x0000); /* set/reset */ 591 outw(GDCIDX, 0x0001); /* set/reset enable */ 592 } 593 594 static void 595 vga_pxlborder_direct(scr_stat *scp, int color) 596 { 597 vm_offset_t s; 598 vm_offset_t e; 599 vm_offset_t f; 600 int line_width; 601 int pixel_size; 602 int x; 603 int y; 604 int i; 605 606 line_width = scp->sc->adp->va_line_width; 607 pixel_size = scp->sc->adp->va_info.vi_pixel_size; 608 609 if (scp->yoff > 0) { 610 s = scp->sc->adp->va_window; 611 e = s + line_width * scp->yoff * scp->font_size; 612 613 for (f = s; f < e; f += pixel_size) 614 DRAW_PIXEL(scp, f, color); 615 } 616 617 y = (scp->yoff + scp->ysize) * scp->font_size; 618 619 if (scp->ypixel > y) { 620 s = scp->sc->adp->va_window + line_width * y; 621 e = s + line_width * (scp->ypixel - y); 622 623 for (f = s; f < e; f += pixel_size) 624 DRAW_PIXEL(scp, f, color); 625 } 626 627 y = scp->yoff * scp->font_size; 628 x = scp->xpixel / 8 - scp->xoff - scp->xsize; 629 630 for (i = 0; i < scp->ysize * scp->font_size; ++i) { 631 if (scp->xoff > 0) { 632 s = scp->sc->adp->va_window + line_width * (y + i); 633 e = s + scp->xoff * 8 * pixel_size; 634 635 for (f = s; f < e; f += pixel_size) 636 DRAW_PIXEL(scp, f, color); 637 } 638 639 if (x > 0) { 640 s = scp->sc->adp->va_window + line_width * (y + i) + 641 scp->xoff * 8 * pixel_size + 642 scp->xsize * 8 * pixel_size; 643 e = s + x * 8 * pixel_size; 644 645 for (f = s; f < e; f += pixel_size) 646 DRAW_PIXEL(scp, f, color); 647 } 648 } 649 } 650 651 static void 652 vga_pxlborder_planar(scr_stat *scp, int color) 653 { 654 vm_offset_t p; 655 int line_width; 656 int x; 657 int y; 658 int i; 659 660 vidd_set_border(scp->sc->adp, color); 661 662 outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */ 663 outw(GDCIDX, 0x0003); /* data rotate/function select */ 664 outw(GDCIDX, 0x0f01); /* set/reset enable */ 665 outw(GDCIDX, 0xff08); /* bit mask */ 666 outw(GDCIDX, (color << 8) | 0x00); /* set/reset */ 667 line_width = scp->sc->adp->va_line_width; 668 p = scp->sc->adp->va_window; 669 if (scp->yoff > 0) 670 bzero_io((void *)p, line_width*scp->yoff*scp->font_size); 671 y = (scp->yoff + scp->ysize)*scp->font_size; 672 if (scp->ypixel > y) 673 bzero_io((void *)(p + line_width*y), line_width*(scp->ypixel - y)); 674 y = scp->yoff*scp->font_size; 675 x = scp->xpixel/8 - scp->xoff - scp->xsize; 676 for (i = 0; i < scp->ysize*scp->font_size; ++i) { 677 if (scp->xoff > 0) 678 bzero_io((void *)(p + line_width*(y + i)), scp->xoff); 679 if (x > 0) 680 bzero_io((void *)(p + line_width*(y + i) 681 + scp->xoff + scp->xsize), x); 682 } 683 outw(GDCIDX, 0x0000); /* set/reset */ 684 outw(GDCIDX, 0x0001); /* set/reset enable */ 685 } 686 687 static void 688 vga_egadraw(scr_stat *scp, int from, int count, int flip) 689 { 690 vm_offset_t d; 691 vm_offset_t e; 692 u_char *f; 693 u_short bg; 694 u_short col1, col2; 695 int line_width; 696 int i, j; 697 int a; 698 u_char c; 699 700 line_width = scp->sc->adp->va_line_width; 701 702 d = GET_PIXEL(scp, from, 1, line_width); 703 704 outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */ 705 outw(GDCIDX, 0x0003); /* data rotate/function select */ 706 outw(GDCIDX, 0x0f01); /* set/reset enable */ 707 bg = -1; 708 if (from + count > scp->xsize*scp->ysize) 709 count = scp->xsize*scp->ysize - from; 710 for (i = from; count-- > 0; ++i) { 711 a = sc_vtb_geta(&scp->vtb, i); 712 if (flip) { 713 col1 = ((a & 0x7000) >> 4) | (a & 0x0800); 714 col2 = ((a & 0x8000) >> 4) | (a & 0x0700); 715 } else { 716 col1 = (a & 0x0f00); 717 col2 = (a & 0xf000) >> 4; 718 } 719 /* set background color in EGA/VGA latch */ 720 if (bg != col2) { 721 bg = col2; 722 outw(GDCIDX, bg | 0x00); /* set/reset */ 723 outw(GDCIDX, 0xff08); /* bit mask */ 724 writeb(d, 0); 725 c = readb(d); /* set bg color in the latch */ 726 } 727 /* foreground color */ 728 outw(GDCIDX, col1 | 0x00); /* set/reset */ 729 e = d; 730 f = &(scp->font[sc_vtb_getc(&scp->vtb, i)*scp->font_size]); 731 for (j = 0; j < scp->font_size; ++j, ++f) { 732 outw(GDCIDX, (*f << 8) | 0x08); /* bit mask */ 733 writeb(e, 0); 734 e += line_width; 735 } 736 ++d; 737 if ((i % scp->xsize) == scp->xsize - 1) 738 d += scp->font_size * line_width - scp->xsize; 739 } 740 outw(GDCIDX, 0x0000); /* set/reset */ 741 outw(GDCIDX, 0x0001); /* set/reset enable */ 742 outw(GDCIDX, 0xff08); /* bit mask */ 743 } 744 745 static void 746 vga_vgadraw_direct(scr_stat *scp, int from, int count, int flip) 747 { 748 vm_offset_t d; 749 vm_offset_t e; 750 u_char *f; 751 u_short col1, col2, color; 752 int line_width, pixel_size; 753 int i, j, k; 754 int a; 755 756 line_width = scp->sc->adp->va_line_width; 757 pixel_size = scp->sc->adp->va_info.vi_pixel_size; 758 759 d = GET_PIXEL(scp, from, 8 * pixel_size, line_width); 760 761 if (from + count > scp->xsize * scp->ysize) 762 count = scp->xsize * scp->ysize - from; 763 764 for (i = from; count-- > 0; ++i) { 765 a = sc_vtb_geta(&scp->vtb, i); 766 767 if (flip) { 768 col1 = (((a & 0x7000) >> 4) | (a & 0x0800)) >> 8; 769 col2 = (((a & 0x8000) >> 4) | (a & 0x0700)) >> 8; 770 } else { 771 col1 = (a & 0x0f00) >> 8; 772 col2 = (a & 0xf000) >> 12; 773 } 774 775 e = d; 776 f = &(scp->font[sc_vtb_getc(&scp->vtb, i) * scp->font_size]); 777 778 for (j = 0; j < scp->font_size; ++j, ++f) { 779 for (k = 0; k < 8; ++k) { 780 color = *f & (1 << (7 - k)) ? col1 : col2; 781 DRAW_PIXEL(scp, e + pixel_size * k, color); 782 } 783 784 e += line_width; 785 } 786 787 d += 8 * pixel_size; 788 789 if ((i % scp->xsize) == scp->xsize - 1) 790 d += scp->font_size * line_width - 791 scp->xsize * 8 * pixel_size; 792 } 793 } 794 795 static void 796 vga_vgadraw_planar(scr_stat *scp, int from, int count, int flip) 797 { 798 vm_offset_t d; 799 vm_offset_t e; 800 u_char *f; 801 u_short bg; 802 u_short col1, col2; 803 int line_width; 804 int i, j; 805 int a; 806 u_char c; 807 808 line_width = scp->sc->adp->va_line_width; 809 810 d = GET_PIXEL(scp, from, 1, line_width); 811 812 outw(GDCIDX, 0x0305); /* read mode 0, write mode 3 */ 813 outw(GDCIDX, 0x0003); /* data rotate/function select */ 814 outw(GDCIDX, 0x0f01); /* set/reset enable */ 815 outw(GDCIDX, 0xff08); /* bit mask */ 816 bg = -1; 817 if (from + count > scp->xsize*scp->ysize) 818 count = scp->xsize*scp->ysize - from; 819 for (i = from; count-- > 0; ++i) { 820 a = sc_vtb_geta(&scp->vtb, i); 821 if (flip) { 822 col1 = ((a & 0x7000) >> 4) | (a & 0x0800); 823 col2 = ((a & 0x8000) >> 4) | (a & 0x0700); 824 } else { 825 col1 = (a & 0x0f00); 826 col2 = (a & 0xf000) >> 4; 827 } 828 /* set background color in EGA/VGA latch */ 829 if (bg != col2) { 830 bg = col2; 831 outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */ 832 outw(GDCIDX, bg | 0x00); /* set/reset */ 833 writeb(d, 0); 834 c = readb(d); /* set bg color in the latch */ 835 outw(GDCIDX, 0x0305); /* read mode 0, write mode 3 */ 836 } 837 /* foreground color */ 838 outw(GDCIDX, col1 | 0x00); /* set/reset */ 839 e = d; 840 f = &(scp->font[sc_vtb_getc(&scp->vtb, i)*scp->font_size]); 841 for (j = 0; j < scp->font_size; ++j, ++f) { 842 writeb(e, *f); 843 e += line_width; 844 } 845 ++d; 846 if ((i % scp->xsize) == scp->xsize - 1) 847 d += scp->font_size * line_width - scp->xsize; 848 } 849 outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */ 850 outw(GDCIDX, 0x0000); /* set/reset */ 851 outw(GDCIDX, 0x0001); /* set/reset enable */ 852 } 853 854 static void 855 vga_pxlcursor_shape(scr_stat *scp, int base, int height, int blink) 856 { 857 if (base < 0 || base >= scp->font_size) 858 return; 859 /* the caller may set height <= 0 in order to disable the cursor */ 860 #if 0 861 scp->curs_attr.base = base; 862 scp->curs_attr.height = height; 863 #endif 864 } 865 866 static void 867 draw_pxlcursor_direct(scr_stat *scp, int at, int on, int flip) 868 { 869 vm_offset_t d; 870 u_char *f; 871 int line_width, pixel_size; 872 int height; 873 int col1, col2, color; 874 int a; 875 int i, j; 876 877 line_width = scp->sc->adp->va_line_width; 878 pixel_size = scp->sc->adp->va_info.vi_pixel_size; 879 880 d = GET_PIXEL(scp, at, 8 * pixel_size, line_width) + 881 (scp->font_size - scp->curs_attr.base - 1) * line_width; 882 883 a = sc_vtb_geta(&scp->vtb, at); 884 885 if (flip) { 886 col1 = ((on) ? (a & 0x0f00) : ((a & 0xf000) >> 4)) >> 8; 887 col2 = ((on) ? ((a & 0xf000) >> 4) : (a & 0x0f00)) >> 8; 888 } else { 889 col1 = ((on) ? ((a & 0xf000) >> 4) : (a & 0x0f00)) >> 8; 890 col2 = ((on) ? (a & 0x0f00) : ((a & 0xf000) >> 4)) >> 8; 891 } 892 893 f = &(scp->font[sc_vtb_getc(&scp->vtb, at) * scp->font_size + 894 scp->font_size - scp->curs_attr.base - 1]); 895 896 height = imin(scp->curs_attr.height, scp->font_size); 897 898 for (i = 0; i < height; ++i, --f) { 899 for (j = 0; j < 8; ++j) { 900 color = *f & (1 << (7 - j)) ? col1 : col2; 901 DRAW_PIXEL(scp, d + pixel_size * j, color); 902 } 903 904 d -= line_width; 905 } 906 } 907 908 static void 909 draw_pxlcursor_planar(scr_stat *scp, int at, int on, int flip) 910 { 911 vm_offset_t d; 912 u_char *f; 913 int line_width; 914 int height; 915 int col; 916 int a; 917 int i; 918 u_char c; 919 920 line_width = scp->sc->adp->va_line_width; 921 922 d = GET_PIXEL(scp, at, 1, line_width) + 923 (scp->font_size - scp->curs_attr.base - 1) * line_width; 924 925 outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */ 926 outw(GDCIDX, 0x0003); /* data rotate/function select */ 927 outw(GDCIDX, 0x0f01); /* set/reset enable */ 928 /* set background color in EGA/VGA latch */ 929 a = sc_vtb_geta(&scp->vtb, at); 930 if (flip) 931 col = (on) ? ((a & 0xf000) >> 4) : (a & 0x0f00); 932 else 933 col = (on) ? (a & 0x0f00) : ((a & 0xf000) >> 4); 934 outw(GDCIDX, col | 0x00); /* set/reset */ 935 outw(GDCIDX, 0xff08); /* bit mask */ 936 writeb(d, 0); 937 c = readb(d); /* set bg color in the latch */ 938 /* foreground color */ 939 if (flip) 940 col = (on) ? (a & 0x0f00) : ((a & 0xf000) >> 4); 941 else 942 col = (on) ? ((a & 0xf000) >> 4) : (a & 0x0f00); 943 outw(GDCIDX, col | 0x00); /* set/reset */ 944 f = &(scp->font[sc_vtb_getc(&scp->vtb, at)*scp->font_size 945 + scp->font_size - scp->curs_attr.base - 1]); 946 height = imin(scp->curs_attr.height, scp->font_size); 947 for (i = 0; i < height; ++i, --f) { 948 outw(GDCIDX, (*f << 8) | 0x08); /* bit mask */ 949 writeb(d, 0); 950 d -= line_width; 951 } 952 outw(GDCIDX, 0x0000); /* set/reset */ 953 outw(GDCIDX, 0x0001); /* set/reset enable */ 954 outw(GDCIDX, 0xff08); /* bit mask */ 955 } 956 957 static int pxlblinkrate = 0; 958 959 static void 960 vga_pxlcursor_direct(scr_stat *scp, int at, int blink, int on, int flip) 961 { 962 if (scp->curs_attr.height <= 0) /* the text cursor is disabled */ 963 return; 964 965 if (on) { 966 if (!blink) { 967 scp->status |= VR_CURSOR_ON; 968 draw_pxlcursor_direct(scp, at, on, flip); 969 } else if (++pxlblinkrate & 4) { 970 pxlblinkrate = 0; 971 scp->status ^= VR_CURSOR_ON; 972 draw_pxlcursor_direct(scp, at, 973 scp->status & VR_CURSOR_ON, 974 flip); 975 } 976 } else { 977 if (scp->status & VR_CURSOR_ON) 978 draw_pxlcursor_direct(scp, at, on, flip); 979 scp->status &= ~VR_CURSOR_ON; 980 } 981 if (blink) 982 scp->status |= VR_CURSOR_BLINK; 983 else 984 scp->status &= ~VR_CURSOR_BLINK; 985 } 986 987 static void 988 vga_pxlcursor_planar(scr_stat *scp, int at, int blink, int on, int flip) 989 { 990 if (scp->curs_attr.height <= 0) /* the text cursor is disabled */ 991 return; 992 993 if (on) { 994 if (!blink) { 995 scp->status |= VR_CURSOR_ON; 996 draw_pxlcursor_planar(scp, at, on, flip); 997 } else if (++pxlblinkrate & 4) { 998 pxlblinkrate = 0; 999 scp->status ^= VR_CURSOR_ON; 1000 draw_pxlcursor_planar(scp, at, 1001 scp->status & VR_CURSOR_ON, 1002 flip); 1003 } 1004 } else { 1005 if (scp->status & VR_CURSOR_ON) 1006 draw_pxlcursor_planar(scp, at, on, flip); 1007 scp->status &= ~VR_CURSOR_ON; 1008 } 1009 if (blink) 1010 scp->status |= VR_CURSOR_BLINK; 1011 else 1012 scp->status &= ~VR_CURSOR_BLINK; 1013 } 1014 1015 static void 1016 vga_pxlblink_direct(scr_stat *scp, int at, int flip) 1017 { 1018 if (!(scp->status & VR_CURSOR_BLINK)) 1019 return; 1020 if (!(++pxlblinkrate & 4)) 1021 return; 1022 pxlblinkrate = 0; 1023 scp->status ^= VR_CURSOR_ON; 1024 draw_pxlcursor_direct(scp, at, scp->status & VR_CURSOR_ON, flip); 1025 } 1026 1027 static void 1028 vga_pxlblink_planar(scr_stat *scp, int at, int flip) 1029 { 1030 if (!(scp->status & VR_CURSOR_BLINK)) 1031 return; 1032 if (!(++pxlblinkrate & 4)) 1033 return; 1034 pxlblinkrate = 0; 1035 scp->status ^= VR_CURSOR_ON; 1036 draw_pxlcursor_planar(scp, at, scp->status & VR_CURSOR_ON, flip); 1037 } 1038 1039 #ifndef SC_NO_CUTPASTE 1040 1041 static void 1042 draw_pxlmouse_planar(scr_stat *scp, int x, int y) 1043 { 1044 const struct mousedata *mdp; 1045 vm_offset_t p; 1046 int line_width; 1047 int xoff, yoff; 1048 int ymax; 1049 uint32_t m; 1050 int i, j, k; 1051 uint8_t m1; 1052 1053 mdp = (scp->font_size < 14) ? &mouse9x13 : &mouse10x16; 1054 line_width = scp->sc->adp->va_line_width; 1055 xoff = (x - scp->xoff*8)%8; 1056 yoff = y - rounddown(y, line_width); 1057 ymax = imin(y + mdp->md_height, scp->ypixel); 1058 1059 outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */ 1060 outw(GDCIDX, 0x0001); /* set/reset enable */ 1061 outw(GDCIDX, 0xff08); /* bit mask */ 1062 outw(GDCIDX, 0x0803); /* data rotate/function select (and) */ 1063 p = scp->sc->adp->va_window + line_width*y + x/8; 1064 for (i = y, j = 0; i < ymax; ++i, ++j) { 1065 m = ~(mdp->md_border[j] << 8 >> xoff); 1066 for (k = 0; k < 3; ++k) { 1067 m1 = m >> (8 * (2 - k)); 1068 if (m1 != 0xff && x + 8 * k < scp->xpixel) { 1069 readb(p + k); 1070 writeb(p + k, m1); 1071 } 1072 } 1073 p += line_width; 1074 } 1075 outw(GDCIDX, 0x1003); /* data rotate/function select (or) */ 1076 p = scp->sc->adp->va_window + line_width*y + x/8; 1077 for (i = y, j = 0; i < ymax; ++i, ++j) { 1078 m = mdp->md_interior[j] << 8 >> xoff; 1079 for (k = 0; k < 3; ++k) { 1080 m1 = m >> (8 * (2 - k)); 1081 if (m1 != 0 && x + 8 * k < scp->xpixel) { 1082 readb(p + k); 1083 writeb(p + k, m1); 1084 } 1085 } 1086 p += line_width; 1087 } 1088 outw(GDCIDX, 0x0003); /* data rotate/function select */ 1089 } 1090 1091 static void 1092 remove_pxlmouse_planar(scr_stat *scp, int x, int y) 1093 { 1094 const struct mousedata *mdp; 1095 vm_offset_t p; 1096 int bx, by, i, line_width, xend, xoff, yend, yoff; 1097 1098 mdp = (scp->font_size < 14) ? &mouse9x13 : &mouse10x16; 1099 1100 /* 1101 * It is only necessary to remove the mouse image where it overlaps 1102 * the border. Determine the overlap, and do nothing if it is empty. 1103 */ 1104 bx = (scp->xoff + scp->xsize) * 8; 1105 by = (scp->yoff + scp->ysize) * scp->font_size; 1106 xend = imin(x + mdp->md_width, scp->xpixel); 1107 yend = imin(y + mdp->md_height, scp->ypixel); 1108 if (xend <= bx && yend <= by) 1109 return; 1110 1111 /* Repaint the non-empty overlap. */ 1112 line_width = scp->sc->adp->va_line_width; 1113 outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */ 1114 outw(GDCIDX, 0x0003); /* data rotate/function select */ 1115 outw(GDCIDX, 0x0f01); /* set/reset enable */ 1116 outw(GDCIDX, 0xff08); /* bit mask */ 1117 outw(GDCIDX, (scp->border << 8) | 0x00); /* set/reset */ 1118 for (i = x / 8, xoff = i * 8; xoff < xend; ++i, xoff += 8) { 1119 yoff = (xoff >= bx) ? y : by; 1120 p = scp->sc->adp->va_window + yoff * line_width + i; 1121 for (; yoff < yend; ++yoff, p += line_width) 1122 writeb(p, 0); 1123 } 1124 outw(GDCIDX, 0x0000); /* set/reset */ 1125 outw(GDCIDX, 0x0001); /* set/reset enable */ 1126 } 1127 1128 static void 1129 vga_pxlmouse_direct(scr_stat *scp, int x, int y, int on) 1130 { 1131 const struct mousedata *mdp; 1132 vm_offset_t p; 1133 int line_width, pixel_size; 1134 int xend, yend; 1135 static int x_old = 0, xend_old = 0; 1136 static int y_old = 0, yend_old = 0; 1137 int i, j; 1138 uint32_t *u32; 1139 uint16_t *u16; 1140 uint8_t *u8; 1141 int bpp; 1142 1143 mdp = (scp->font_size < 14) ? &mouse9x13 : &mouse10x16; 1144 1145 /* 1146 * Determine overlap with the border and then if removing, do nothing 1147 * if the overlap is empty. 1148 */ 1149 xend = imin(x + mdp->md_width, scp->xpixel); 1150 yend = imin(y + mdp->md_height, scp->ypixel); 1151 if (!on && xend <= (scp->xoff + scp->xsize) * 8 && 1152 yend <= (scp->yoff + scp->ysize) * scp->font_size) 1153 return; 1154 1155 bpp = scp->sc->adp->va_info.vi_depth; 1156 1157 if ((bpp == 16) && (scp->sc->adp->va_info.vi_pixel_fsizes[1] == 5)) 1158 bpp = 15; 1159 1160 line_width = scp->sc->adp->va_line_width; 1161 pixel_size = scp->sc->adp->va_info.vi_pixel_size; 1162 1163 if (on) 1164 goto do_on; 1165 1166 /* 1167 * Repaint overlap with the border and nearby. Unlike in the planar 1168 * case, we kept track of everything under the cursor so can restore 1169 * it all, but we don't completely trust the saved state to be still 1170 * relevant, so do nothing if it is obviously stale. 1171 */ 1172 if (x != x_old || y != y_old || xend != xend_old || yend != yend_old) 1173 return; 1174 1175 p = scp->sc->adp->va_window + y_old * line_width + x_old * pixel_size; 1176 1177 for (i = 0; i < (yend_old - y_old); i++) { 1178 for (j = (xend_old - x_old - 1); j >= 0; j--) { 1179 switch (bpp) { 1180 case 32: 1181 u32 = (uint32_t*)(p + j * pixel_size); 1182 writel(u32, mouse_buf32[i * 16 + j]); 1183 break; 1184 case 16: 1185 /* FALLTHROUGH */ 1186 case 15: 1187 u16 = (uint16_t*)(p + j * pixel_size); 1188 writew(u16, mouse_buf16[i * 16 + j]); 1189 break; 1190 case 8: 1191 u8 = (uint8_t*)(p + j * pixel_size); 1192 writeb(u8, mouse_buf8[i * 16 + j]); 1193 break; 1194 } 1195 } 1196 1197 p += line_width; 1198 } 1199 return; 1200 1201 do_on: 1202 p = scp->sc->adp->va_window + y * line_width + x * pixel_size; 1203 1204 for (i = 0; i < (yend - y); i++) { 1205 for (j = (xend - x - 1); j >= 0; j--) { 1206 switch (bpp) { 1207 case 32: 1208 u32 = (uint32_t*)(p + j * pixel_size); 1209 mouse_buf32[i * 16 + j] = *u32; 1210 if (mdp->md_interior[i] & (1 << (15 - j))) 1211 writel(u32, vga_palette32[15]); 1212 else if (mdp->md_border[i] & (1 << (15 - j))) 1213 writel(u32, 0); 1214 break; 1215 case 16: 1216 u16 = (uint16_t*)(p + j * pixel_size); 1217 mouse_buf16[i * 16 + j] = *u16; 1218 if (mdp->md_interior[i] & (1 << (15 - j))) 1219 writew(u16, vga_palette16[15]); 1220 else if (mdp->md_border[i] & (1 << (15 - j))) 1221 writew(u16, 0); 1222 break; 1223 case 15: 1224 u16 = (uint16_t*)(p + j * pixel_size); 1225 mouse_buf16[i * 16 + j] = *u16; 1226 if (mdp->md_interior[i] & (1 << (15 - j))) 1227 writew(u16, vga_palette15[15]); 1228 else if (mdp->md_border[i] & (1 << (15 - j))) 1229 writew(u16, 0); 1230 break; 1231 case 8: 1232 u8 = (uint8_t*)(p + j * pixel_size); 1233 mouse_buf8[i * 16 + j] = *u8; 1234 if (mdp->md_interior[i] & (1 << (15 - j))) 1235 writeb(u8, 15); 1236 else if (mdp->md_border[i] & (1 << (15 - j))) 1237 writeb(u8, 0); 1238 break; 1239 } 1240 } 1241 1242 p += line_width; 1243 } 1244 1245 x_old = x; 1246 y_old = y; 1247 xend_old = xend; 1248 yend_old = yend; 1249 } 1250 1251 static void 1252 vga_pxlmouse_planar(scr_stat *scp, int x, int y, int on) 1253 { 1254 if (on) 1255 draw_pxlmouse_planar(scp, x, y); 1256 else 1257 remove_pxlmouse_planar(scp, x, y); 1258 } 1259 1260 #endif /* SC_NO_CUTPASTE */ 1261 #endif /* SC_PIXEL_MODE */ 1262 1263 #ifndef SC_NO_MODE_CHANGE 1264 1265 /* graphics mode renderer */ 1266 1267 static void 1268 vga_grborder(scr_stat *scp, int color) 1269 { 1270 vidd_set_border(scp->sc->adp, color); 1271 } 1272 1273 #endif 1274