scvgarndr.c (135692) | scvgarndr.c (146736) |
---|---|
1/*- 2 * Copyright (c) 1999 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp> 3 * All rights reserved. 4 * | 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 * |
|
5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 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 --- 8 unchanged lines hidden (view full) --- 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. 25 * 26 */ 27 28#include <sys/cdefs.h> | 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 --- 8 unchanged lines hidden (view full) --- 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> |
29__FBSDID("$FreeBSD: head/sys/dev/syscons/scvgarndr.c 135692 2004-09-24 01:18:22Z peter $"); | 32__FBSDID("$FreeBSD: head/sys/dev/syscons/scvgarndr.c 146736 2005-05-29 08:43:44Z delphij $"); |
30 31#include "opt_syscons.h" 32#include "opt_vga.h" 33 34#include <sys/param.h> 35#include <sys/systm.h> 36#include <sys/kernel.h> 37#include <sys/module.h> --- 20 unchanged lines hidden (view full) --- 58static vr_blink_cursor_t vga_txtblink; 59#ifndef SC_NO_CUTPASTE 60static vr_draw_mouse_t vga_txtmouse; 61#else 62#define vga_txtmouse (vr_draw_mouse_t *)vga_nop 63#endif 64 65#ifdef SC_PIXEL_MODE | 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> --- 20 unchanged lines hidden (view full) --- 61static vr_blink_cursor_t vga_txtblink; 62#ifndef SC_NO_CUTPASTE 63static 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 |
66static vr_clear_t vga_pxlclear; 67static vr_draw_border_t vga_pxlborder; | 69static vr_init_t vga_rndrinit; 70static vr_clear_t vga_pxlclear_direct; 71static vr_clear_t vga_pxlclear_planar; 72static vr_draw_border_t vga_pxlborder_direct; 73static vr_draw_border_t vga_pxlborder_planar; |
68static vr_draw_t vga_egadraw; | 74static vr_draw_t vga_egadraw; |
69static vr_draw_t vga_vgadraw; | 75static vr_draw_t vga_vgadraw_direct; 76static vr_draw_t vga_vgadraw_planar; |
70static vr_set_cursor_t vga_pxlcursor_shape; | 77static vr_set_cursor_t vga_pxlcursor_shape; |
71static vr_draw_cursor_t vga_pxlcursor; 72static vr_blink_cursor_t vga_pxlblink; | 78static vr_draw_cursor_t vga_pxlcursor_direct; 79static vr_draw_cursor_t vga_pxlcursor_planar; 80static vr_blink_cursor_t vga_pxlblink_direct; 81static vr_blink_cursor_t vga_pxlblink_planar; |
73#ifndef SC_NO_CUTPASTE | 82#ifndef SC_NO_CUTPASTE |
74static vr_draw_mouse_t vga_pxlmouse; | 83static vr_draw_mouse_t vga_pxlmouse_direct; 84static vr_draw_mouse_t vga_pxlmouse_planar; |
75#else 76#define vga_pxlmouse (vr_draw_mouse_t *)vga_nop 77#endif 78#endif /* SC_PIXEL_MODE */ 79 80#ifndef SC_NO_MODE_CHANGE 81static vr_draw_border_t vga_grborder; 82#endif 83 84static void vga_nop(scr_stat *scp, ...); 85 86static sc_rndr_sw_t txtrndrsw = { | 85#else 86#define vga_pxlmouse (vr_draw_mouse_t *)vga_nop 87#endif 88#endif /* SC_PIXEL_MODE */ 89 90#ifndef SC_NO_MODE_CHANGE 91static vr_draw_border_t vga_grborder; 92#endif 93 94static void vga_nop(scr_stat *scp, ...); 95 96static sc_rndr_sw_t txtrndrsw = { |
97 (vr_init_t *)vga_nop, |
|
87 vga_txtclear, 88 vga_txtborder, 89 vga_txtdraw, 90 vga_txtcursor_shape, 91 vga_txtcursor, 92 vga_txtblink, 93 (vr_set_mouse_t *)vga_nop, 94 vga_txtmouse, 95}; 96RENDERER(mda, 0, txtrndrsw, vga_set); 97RENDERER(cga, 0, txtrndrsw, vga_set); 98RENDERER(ega, 0, txtrndrsw, vga_set); 99RENDERER(vga, 0, txtrndrsw, vga_set); 100 101#ifdef SC_PIXEL_MODE 102static sc_rndr_sw_t egarndrsw = { | 98 vga_txtclear, 99 vga_txtborder, 100 vga_txtdraw, 101 vga_txtcursor_shape, 102 vga_txtcursor, 103 vga_txtblink, 104 (vr_set_mouse_t *)vga_nop, 105 vga_txtmouse, 106}; 107RENDERER(mda, 0, txtrndrsw, vga_set); 108RENDERER(cga, 0, txtrndrsw, vga_set); 109RENDERER(ega, 0, txtrndrsw, vga_set); 110RENDERER(vga, 0, txtrndrsw, vga_set); 111 112#ifdef SC_PIXEL_MODE 113static sc_rndr_sw_t egarndrsw = { |
103 vga_pxlclear, 104 vga_pxlborder, | 114 (vr_init_t *)vga_nop, 115 vga_pxlclear_planar, 116 vga_pxlborder_planar, |
105 vga_egadraw, 106 vga_pxlcursor_shape, | 117 vga_egadraw, 118 vga_pxlcursor_shape, |
107 vga_pxlcursor, 108 vga_pxlblink, | 119 vga_pxlcursor_planar, 120 vga_pxlblink_planar, |
109 (vr_set_mouse_t *)vga_nop, | 121 (vr_set_mouse_t *)vga_nop, |
110 vga_pxlmouse, | 122 vga_pxlmouse_planar, |
111}; 112RENDERER(ega, PIXEL_MODE, egarndrsw, vga_set); 113 114static sc_rndr_sw_t vgarndrsw = { | 123}; 124RENDERER(ega, PIXEL_MODE, egarndrsw, vga_set); 125 126static sc_rndr_sw_t vgarndrsw = { |
115 vga_pxlclear, 116 vga_pxlborder, 117 vga_vgadraw, | 127 vga_rndrinit, 128 (vr_clear_t *)vga_nop, 129 (vr_draw_border_t *)vga_nop, 130 (vr_draw_t *)vga_nop, |
118 vga_pxlcursor_shape, | 131 vga_pxlcursor_shape, |
119 vga_pxlcursor, 120 vga_pxlblink, | 132 (vr_draw_cursor_t *)vga_nop, 133 (vr_blink_cursor_t *)vga_nop, |
121 (vr_set_mouse_t *)vga_nop, | 134 (vr_set_mouse_t *)vga_nop, |
122 vga_pxlmouse, | 135 (vr_draw_mouse_t *)vga_nop, |
123}; 124RENDERER(vga, PIXEL_MODE, vgarndrsw, vga_set); 125#endif /* SC_PIXEL_MODE */ 126 127#ifndef SC_NO_MODE_CHANGE 128static sc_rndr_sw_t grrndrsw = { | 136}; 137RENDERER(vga, PIXEL_MODE, vgarndrsw, vga_set); 138#endif /* SC_PIXEL_MODE */ 139 140#ifndef SC_NO_MODE_CHANGE 141static sc_rndr_sw_t grrndrsw = { |
142 (vr_init_t *)vga_nop, |
|
129 (vr_clear_t *)vga_nop, 130 vga_grborder, 131 (vr_draw_t *)vga_nop, 132 (vr_set_cursor_t *)vga_nop, 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, --- 13 unchanged lines hidden (view full) --- 150}; 151static u_short mouse_or_mask[16] = { 152 0x0000, 0x4000, 0x6000, 0x7000, 0x7800, 0x7c00, 0x7e00, 0x6800, 153 0x0c00, 0x0c00, 0x0600, 0x0600, 0x0000, 0x0000, 0x0000, 0x0000 154}; 155#endif 156#endif 157 | 143 (vr_clear_t *)vga_nop, 144 vga_grborder, 145 (vr_draw_t *)vga_nop, 146 (vr_set_cursor_t *)vga_nop, 147 (vr_draw_cursor_t *)vga_nop, 148 (vr_blink_cursor_t *)vga_nop, 149 (vr_set_mouse_t *)vga_nop, 150 (vr_draw_mouse_t *)vga_nop, --- 13 unchanged lines hidden (view full) --- 164}; 165static u_short mouse_or_mask[16] = { 166 0x0000, 0x4000, 0x6000, 0x7000, 0x7800, 0x7c00, 0x7e00, 0x6800, 167 0x0c00, 0x0c00, 0x0600, 0x0600, 0x0000, 0x0000, 0x0000, 0x0000 168}; 169#endif 170#endif 171 |
172#ifdef SC_PIXEL_MODE 173#define VIDEO_MEMORY_POS(scp, pos, x) \ 174 scp->sc->adp->va_window + \ 175 x * scp->xoff + \ 176 scp->yoff * scp->font_size * scp->sc->adp->va_line_width + \ 177 x * (pos % scp->xsize) + \ 178 scp->font_size * scp->sc->adp->va_line_width * (pos / scp->xsize) 179 180#define vga_drawpxl(pos, color) \ 181 switch (scp->sc->adp->va_info.vi_depth) { \ 182 case 32: \ 183 case 24: \ 184 writel(pos, vga_palette32[color]); \ 185 break; \ 186 case 16: \ 187 if (scp->sc->adp->va_info.vi_pixel_fsizes[1] == 5)\ 188 writew(pos, vga_palette15[color]); \ 189 else \ 190 writew(pos, vga_palette16[color]); \ 191 break; \ 192 case 15: \ 193 writew(pos, vga_palette15[color]); \ 194 break; \ 195 } 196 197static uint32_t vga_palette32[16] = { 198 0x000000, 0x0000ad, 0x00ad00, 0x00adad, 199 0xad0000, 0xad00ad, 0xad5200, 0xadadad, 200 0x525252, 0x5252ff, 0x52ff52, 0x52ffff, 201 0xff5252, 0xff52ff, 0xffff52, 0xffffff 202}; 203 204static uint16_t vga_palette16[16] = { 205 0x0000, 0x0016, 0x0560, 0x0576, 0xb000, 0xb016, 0xb2a0, 0xb576, 206 0x52aa, 0x52bf, 0x57ea, 0x57ff, 0xfaaa, 0xfabf, 0xffea, 0xffff 207}; 208 209static uint16_t vga_palette15[16] = { 210 0x0000, 0x0016, 0x02c0, 0x02d6, 0x5800, 0x5816, 0x5940, 0x5ad6, 211 0x294a, 0x295f, 0x2bea, 0x2bff, 0x7d4a, 0x7d5f, 0x7fea, 0x7fff 212}; 213 214#ifndef SC_NO_CUTPASTE 215static uint32_t mouse_buf32[256]; 216static uint16_t mouse_buf16[256]; 217#endif 218#endif 219 |
|
158static void 159vga_nop(scr_stat *scp, ...) 160{ 161} 162 163/* text mode renderer */ 164 165static void --- 260 unchanged lines hidden (view full) --- 426 427#endif /* SC_NO_CUTPASTE */ 428 429#ifdef SC_PIXEL_MODE 430 431/* pixel (raster text) mode renderer */ 432 433static void | 220static void 221vga_nop(scr_stat *scp, ...) 222{ 223} 224 225/* text mode renderer */ 226 227static void --- 260 unchanged lines hidden (view full) --- 488 489#endif /* SC_NO_CUTPASTE */ 490 491#ifdef SC_PIXEL_MODE 492 493/* pixel (raster text) mode renderer */ 494 495static void |
434vga_pxlclear(scr_stat *scp, int c, int attr) | 496vga_rndrinit(scr_stat *scp) |
435{ | 497{ |
498 if (scp->sc->adp->va_info.vi_mem_model == V_INFO_MM_PLANAR) { 499 scp->rndr->clear = vga_pxlclear_planar; 500 scp->rndr->draw_border = vga_pxlborder_planar; 501 scp->rndr->draw = vga_vgadraw_planar; 502 scp->rndr->draw_cursor = vga_pxlcursor_planar; 503 scp->rndr->blink_cursor = vga_pxlblink_planar; 504 scp->rndr->draw_mouse = vga_pxlmouse_planar; 505 } else if (scp->sc->adp->va_info.vi_mem_model == V_INFO_MM_DIRECT) { 506 scp->rndr->clear = vga_pxlclear_direct; 507 scp->rndr->draw_border = vga_pxlborder_direct; 508 scp->rndr->draw = vga_vgadraw_direct; 509 scp->rndr->draw_cursor = vga_pxlcursor_direct; 510 scp->rndr->blink_cursor = vga_pxlblink_direct; 511 scp->rndr->draw_mouse = vga_pxlmouse_direct; 512 } 513} 514 515static void 516vga_pxlclear_direct(scr_stat *scp, int c, int attr) 517{ |
|
436 vm_offset_t p; 437 int line_width; | 518 vm_offset_t p; 519 int line_width; |
520 int pixel_size; |
|
438 int lines; 439 int i; 440 | 521 int lines; 522 int i; 523 |
524 line_width = scp->sc->adp->va_line_width; 525 pixel_size = scp->sc->adp->va_info.vi_pixel_size; 526 lines = scp->ysize * scp->font_size; 527 p = scp->sc->adp->va_window + 528 line_width * scp->yoff * scp->font_size + 529 scp->xoff * 8 * pixel_size; 530 531 for (i = 0; i < lines; ++i) { 532 bzero_io((void *)p, scp->xsize * 8 * pixel_size); 533 p += line_width; 534 } 535} 536 537static void 538vga_pxlclear_planar(scr_stat *scp, int c, int attr) 539{ 540 vm_offset_t p; 541 int line_width; 542 int lines; 543 int i; 544 |
|
441 /* XXX: we are just filling the screen with the background color... */ 442 outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */ 443 outw(GDCIDX, 0x0003); /* data rotate/function select */ 444 outw(GDCIDX, 0x0f01); /* set/reset enable */ 445 outw(GDCIDX, 0xff08); /* bit mask */ 446 outw(GDCIDX, ((attr & 0xf000) >> 4) | 0x00); /* set/reset */ 447 line_width = scp->sc->adp->va_line_width; 448 lines = scp->ysize*scp->font_size; 449 p = scp->sc->adp->va_window + line_width*scp->yoff*scp->font_size 450 + scp->xoff; 451 for (i = 0; i < lines; ++i) { 452 bzero_io((void *)p, scp->xsize); 453 p += line_width; 454 } 455 outw(GDCIDX, 0x0000); /* set/reset */ 456 outw(GDCIDX, 0x0001); /* set/reset enable */ 457} 458 459static void | 545 /* XXX: we are just filling the screen with the background color... */ 546 outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */ 547 outw(GDCIDX, 0x0003); /* data rotate/function select */ 548 outw(GDCIDX, 0x0f01); /* set/reset enable */ 549 outw(GDCIDX, 0xff08); /* bit mask */ 550 outw(GDCIDX, ((attr & 0xf000) >> 4) | 0x00); /* set/reset */ 551 line_width = scp->sc->adp->va_line_width; 552 lines = scp->ysize*scp->font_size; 553 p = scp->sc->adp->va_window + line_width*scp->yoff*scp->font_size 554 + scp->xoff; 555 for (i = 0; i < lines; ++i) { 556 bzero_io((void *)p, scp->xsize); 557 p += line_width; 558 } 559 outw(GDCIDX, 0x0000); /* set/reset */ 560 outw(GDCIDX, 0x0001); /* set/reset enable */ 561} 562 563static void |
460vga_pxlborder(scr_stat *scp, int color) | 564vga_pxlborder_direct(scr_stat *scp, int color) |
461{ | 565{ |
566 vm_offset_t s; 567 vm_offset_t e; 568 vm_offset_t f; 569 int line_width; 570 int pixel_size; 571 int x; 572 int y; 573 int i; 574 575 line_width = scp->sc->adp->va_line_width; 576 pixel_size = scp->sc->adp->va_info.vi_pixel_size; 577 578 if (scp->yoff > 0) { 579 s = scp->sc->adp->va_window; 580 e = s + line_width * scp->yoff * scp->font_size; 581 582 for (f = s; f < e; f += pixel_size) 583 vga_drawpxl(f, color); 584 } 585 586 y = (scp->yoff + scp->ysize) * scp->font_size; 587 588 if (scp->ypixel > y) { 589 s = scp->sc->adp->va_window + line_width * y; 590 e = s + line_width * (scp->ypixel - y); 591 592 for (f = s; f < e; f += pixel_size) 593 vga_drawpxl(f, color); 594 } 595 596 y = scp->yoff * scp->font_size; 597 x = scp->xpixel / 8 - scp->xoff - scp->xsize; 598 599 for (i = 0; i < scp->ysize * scp->font_size; ++i) { 600 if (scp->xoff > 0) { 601 s = scp->sc->adp->va_window + line_width * (y + i); 602 e = s + scp->xoff * 8 * pixel_size; 603 604 for (f = s; f < e; f += pixel_size) 605 vga_drawpxl(f, color); 606 } 607 608 if (x > 0) { 609 s = scp->sc->adp->va_window + line_width * (y + i) + 610 scp->xoff * 8 * pixel_size + 611 scp->xsize * 8 * pixel_size; 612 e = s + x * 8 * pixel_size; 613 614 for (f = s; f < e; f += pixel_size) 615 vga_drawpxl(f, color); 616 } 617 } 618} 619 620static void 621vga_pxlborder_planar(scr_stat *scp, int color) 622{ |
|
462 vm_offset_t p; 463 int line_width; 464 int x; 465 int y; 466 int i; 467 468 (*vidsw[scp->sc->adapter]->set_border)(scp->sc->adp, color); 469 --- 31 unchanged lines hidden (view full) --- 501 u_short bg; 502 u_short col1, col2; 503 int line_width; 504 int i, j; 505 int a; 506 u_char c; 507 508 line_width = scp->sc->adp->va_line_width; | 623 vm_offset_t p; 624 int line_width; 625 int x; 626 int y; 627 int i; 628 629 (*vidsw[scp->sc->adapter]->set_border)(scp->sc->adp, color); 630 --- 31 unchanged lines hidden (view full) --- 662 u_short bg; 663 u_short col1, col2; 664 int line_width; 665 int i, j; 666 int a; 667 u_char c; 668 669 line_width = scp->sc->adp->va_line_width; |
509 d = scp->sc->adp->va_window 510 + scp->xoff 511 + scp->yoff*scp->font_size*line_width 512 + (from%scp->xsize) 513 + scp->font_size*line_width*(from/scp->xsize); | |
514 | 670 |
671 d = VIDEO_MEMORY_POS(scp, from, 1); 672 |
|
515 outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */ 516 outw(GDCIDX, 0x0003); /* data rotate/function select */ 517 outw(GDCIDX, 0x0f01); /* set/reset enable */ 518 bg = -1; 519 if (from + count > scp->xsize*scp->ysize) 520 count = scp->xsize*scp->ysize - from; 521 for (i = from; count-- > 0; ++i) { 522 a = sc_vtb_geta(&scp->vtb, i); --- 26 unchanged lines hidden (view full) --- 549 d += scp->xoff*2 550 + (scp->font_size - 1)*line_width; 551 } 552 outw(GDCIDX, 0x0000); /* set/reset */ 553 outw(GDCIDX, 0x0001); /* set/reset enable */ 554 outw(GDCIDX, 0xff08); /* bit mask */ 555} 556 | 673 outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */ 674 outw(GDCIDX, 0x0003); /* data rotate/function select */ 675 outw(GDCIDX, 0x0f01); /* set/reset enable */ 676 bg = -1; 677 if (from + count > scp->xsize*scp->ysize) 678 count = scp->xsize*scp->ysize - from; 679 for (i = from; count-- > 0; ++i) { 680 a = sc_vtb_geta(&scp->vtb, i); --- 26 unchanged lines hidden (view full) --- 707 d += scp->xoff*2 708 + (scp->font_size - 1)*line_width; 709 } 710 outw(GDCIDX, 0x0000); /* set/reset */ 711 outw(GDCIDX, 0x0001); /* set/reset enable */ 712 outw(GDCIDX, 0xff08); /* bit mask */ 713} 714 |
557static void 558vga_vgadraw(scr_stat *scp, int from, int count, int flip) | 715static void 716vga_vgadraw_direct(scr_stat *scp, int from, int count, int flip) |
559{ | 717{ |
718 vm_offset_t d = 0; 719 vm_offset_t e; 720 u_char *f; 721 u_short col1, col2, color; 722 int line_width, pixel_size; 723 int i, j, k; 724 int a; 725 726 line_width = scp->sc->adp->va_line_width; 727 pixel_size = scp->sc->adp->va_info.vi_pixel_size; 728 729 d = VIDEO_MEMORY_POS(scp, from, 8 * pixel_size); 730 731 if (from + count > scp->xsize * scp->ysize) 732 count = scp->xsize * scp->ysize - from; 733 734 for (i = from; count-- > 0; ++i) { 735 a = sc_vtb_geta(&scp->vtb, i); 736 737 if (flip) { 738 col1 = (((a & 0x7000) >> 4) | (a & 0x0800)) >> 8; 739 col2 = (((a & 0x8000) >> 4) | (a & 0x0700)) >> 8; 740 } else { 741 col1 = (a & 0x0f00) >> 8; 742 col2 = (a & 0xf000) >> 12; 743 } 744 745 e = d; 746 f = &(scp->font[sc_vtb_getc(&scp->vtb, i) * scp->font_size]); 747 748 for (j = 0; j < scp->font_size; ++j, ++f) { 749 for (k = 0; k < 8; ++k) { 750 color = *f & (1 << (7 - k)) ? col1 : col2; 751 vga_drawpxl(e + pixel_size * k, color); 752 } 753 754 e += line_width; 755 } 756 757 d += 8 * pixel_size; 758 759 if ((i % scp->xsize) == scp->xsize - 1) 760 d += scp->xoff * 16 * pixel_size + 761 (scp->font_size - 1) * line_width; 762 } 763} 764 765static void 766vga_vgadraw_planar(scr_stat *scp, int from, int count, int flip) 767{ |
|
560 vm_offset_t d; 561 vm_offset_t e; 562 u_char *f; 563 u_short bg; 564 u_short col1, col2; 565 int line_width; 566 int i, j; 567 int a; 568 u_char c; 569 | 768 vm_offset_t d; 769 vm_offset_t e; 770 u_char *f; 771 u_short bg; 772 u_short col1, col2; 773 int line_width; 774 int i, j; 775 int a; 776 u_char c; 777 |
778 d = VIDEO_MEMORY_POS(scp, from, 1); 779 |
|
570 line_width = scp->sc->adp->va_line_width; | 780 line_width = scp->sc->adp->va_line_width; |
571 d = scp->sc->adp->va_window 572 + scp->xoff 573 + scp->yoff*scp->font_size*line_width 574 + (from%scp->xsize) 575 + scp->font_size*line_width*(from/scp->xsize); | |
576 577 outw(GDCIDX, 0x0305); /* read mode 0, write mode 3 */ 578 outw(GDCIDX, 0x0003); /* data rotate/function select */ 579 outw(GDCIDX, 0x0f01); /* set/reset enable */ 580 outw(GDCIDX, 0xff08); /* bit mask */ 581 bg = -1; 582 if (from + count > scp->xsize*scp->ysize) 583 count = scp->xsize*scp->ysize - from; --- 41 unchanged lines hidden (view full) --- 625 /* the caller may set height <= 0 in order to disable the cursor */ 626#if 0 627 scp->curs_attr.base = base; 628 scp->curs_attr.height = height; 629#endif 630} 631 632static void | 781 782 outw(GDCIDX, 0x0305); /* read mode 0, write mode 3 */ 783 outw(GDCIDX, 0x0003); /* data rotate/function select */ 784 outw(GDCIDX, 0x0f01); /* set/reset enable */ 785 outw(GDCIDX, 0xff08); /* bit mask */ 786 bg = -1; 787 if (from + count > scp->xsize*scp->ysize) 788 count = scp->xsize*scp->ysize - from; --- 41 unchanged lines hidden (view full) --- 830 /* the caller may set height <= 0 in order to disable the cursor */ 831#if 0 832 scp->curs_attr.base = base; 833 scp->curs_attr.height = height; 834#endif 835} 836 837static void |
633draw_pxlcursor(scr_stat *scp, int at, int on, int flip) | 838draw_pxlcursor_direct(scr_stat *scp, int at, int on, int flip) |
634{ | 839{ |
840 vm_offset_t d = 0; 841 u_char *f; 842 int line_width, pixel_size; 843 int height; 844 int col1, col2, color; 845 int a; 846 int i, j; 847 848 line_width = scp->sc->adp->va_line_width; 849 pixel_size = scp->sc->adp->va_info.vi_pixel_size; 850 851 d = VIDEO_MEMORY_POS(scp, at, 8 * pixel_size) + 852 (scp->font_size - scp->curs_attr.base - 1) * line_width; 853 854 a = sc_vtb_geta(&scp->vtb, at); 855 856 if (flip) { 857 col1 = ((on) ? (a & 0x0f00) : ((a & 0xf000) >> 4)) >> 8; 858 col2 = ((on) ? ((a & 0xf000) >> 4) : (a & 0x0f00)) >> 8; 859 } else { 860 col1 = ((on) ? ((a & 0xf000) >> 4) : (a & 0x0f00)) >> 8; 861 col2 = ((on) ? (a & 0x0f00) : ((a & 0xf000) >> 4)) >> 8; 862 } 863 864 f = &(scp->font[sc_vtb_getc(&scp->vtb, at) * scp->font_size + 865 scp->font_size - scp->curs_attr.base - 1]); 866 867 height = imin(scp->curs_attr.height, scp->font_size); 868 869 for (i = 0; i < height; ++i, --f) { 870 for (j = 0; j < 8; ++j) { 871 color = *f & (1 << (7 - j)) ? col1 : col2; 872 vga_drawpxl(d + pixel_size * j, color); 873 } 874 875 d -= line_width; 876 } 877} 878 879static void 880draw_pxlcursor_planar(scr_stat *scp, int at, int on, int flip) 881{ |
|
635 vm_offset_t d; 636 u_char *f; 637 int line_width; 638 int height; 639 int col; 640 int a; 641 int i; 642 u_char c; 643 644 line_width = scp->sc->adp->va_line_width; | 882 vm_offset_t d; 883 u_char *f; 884 int line_width; 885 int height; 886 int col; 887 int a; 888 int i; 889 u_char c; 890 891 line_width = scp->sc->adp->va_line_width; |
645 d = scp->sc->adp->va_window 646 + scp->xoff 647 + scp->yoff*scp->font_size*line_width 648 + (at%scp->xsize) 649 + scp->font_size*line_width*(at/scp->xsize) 650 + (scp->font_size - scp->curs_attr.base - 1)*line_width; | |
651 | 892 |
893 d = VIDEO_MEMORY_POS(scp, at, 1) + 894 (scp->font_size - scp->curs_attr.base - 1) * line_width; 895 |
|
652 outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */ 653 outw(GDCIDX, 0x0003); /* data rotate/function select */ 654 outw(GDCIDX, 0x0f01); /* set/reset enable */ 655 /* set background color in EGA/VGA latch */ 656 a = sc_vtb_geta(&scp->vtb, at); 657 if (flip) 658 col = (on) ? ((a & 0xf000) >> 4) : (a & 0x0f00); 659 else --- 19 unchanged lines hidden (view full) --- 679 outw(GDCIDX, 0x0000); /* set/reset */ 680 outw(GDCIDX, 0x0001); /* set/reset enable */ 681 outw(GDCIDX, 0xff08); /* bit mask */ 682} 683 684static int pxlblinkrate = 0; 685 686static void | 896 outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */ 897 outw(GDCIDX, 0x0003); /* data rotate/function select */ 898 outw(GDCIDX, 0x0f01); /* set/reset enable */ 899 /* set background color in EGA/VGA latch */ 900 a = sc_vtb_geta(&scp->vtb, at); 901 if (flip) 902 col = (on) ? ((a & 0xf000) >> 4) : (a & 0x0f00); 903 else --- 19 unchanged lines hidden (view full) --- 923 outw(GDCIDX, 0x0000); /* set/reset */ 924 outw(GDCIDX, 0x0001); /* set/reset enable */ 925 outw(GDCIDX, 0xff08); /* bit mask */ 926} 927 928static int pxlblinkrate = 0; 929 930static void |
687vga_pxlcursor(scr_stat *scp, int at, int blink, int on, int flip) | 931vga_pxlcursor_direct(scr_stat *scp, int at, int blink, int on, int flip) |
688{ 689 if (scp->curs_attr.height <= 0) /* the text cursor is disabled */ 690 return; 691 692 if (on) { 693 if (!blink) { 694 scp->status |= VR_CURSOR_ON; | 932{ 933 if (scp->curs_attr.height <= 0) /* the text cursor is disabled */ 934 return; 935 936 if (on) { 937 if (!blink) { 938 scp->status |= VR_CURSOR_ON; |
695 draw_pxlcursor(scp, at, on, flip); | 939 draw_pxlcursor_direct(scp, at, on, flip); |
696 } else if (++pxlblinkrate & 4) { 697 pxlblinkrate = 0; 698 scp->status ^= VR_CURSOR_ON; | 940 } else if (++pxlblinkrate & 4) { 941 pxlblinkrate = 0; 942 scp->status ^= VR_CURSOR_ON; |
699 draw_pxlcursor(scp, at, 700 scp->status & VR_CURSOR_ON, 701 flip); | 943 draw_pxlcursor_direct(scp, at, 944 scp->status & VR_CURSOR_ON, 945 flip); |
702 } 703 } else { 704 if (scp->status & VR_CURSOR_ON) | 946 } 947 } else { 948 if (scp->status & VR_CURSOR_ON) |
705 draw_pxlcursor(scp, at, on, flip); | 949 draw_pxlcursor_direct(scp, at, on, flip); |
706 scp->status &= ~VR_CURSOR_ON; 707 } 708 if (blink) 709 scp->status |= VR_CURSOR_BLINK; 710 else 711 scp->status &= ~VR_CURSOR_BLINK; 712} 713 | 950 scp->status &= ~VR_CURSOR_ON; 951 } 952 if (blink) 953 scp->status |= VR_CURSOR_BLINK; 954 else 955 scp->status &= ~VR_CURSOR_BLINK; 956} 957 |
958static void 959vga_pxlcursor_planar(scr_stat *scp, int at, int blink, int on, int flip) 960{ 961 if (scp->curs_attr.height <= 0) /* the text cursor is disabled */ 962 return; 963 964 if (on) { 965 if (!blink) { 966 scp->status |= VR_CURSOR_ON; 967 draw_pxlcursor_planar(scp, at, on, flip); 968 } else if (++pxlblinkrate & 4) { 969 pxlblinkrate = 0; 970 scp->status ^= VR_CURSOR_ON; 971 draw_pxlcursor_planar(scp, at, 972 scp->status & VR_CURSOR_ON, 973 flip); 974 } 975 } else { 976 if (scp->status & VR_CURSOR_ON) 977 draw_pxlcursor_planar(scp, at, on, flip); 978 scp->status &= ~VR_CURSOR_ON; 979 } 980 if (blink) 981 scp->status |= VR_CURSOR_BLINK; 982 else 983 scp->status &= ~VR_CURSOR_BLINK; 984} 985 |
|
714static void | 986static void |
715vga_pxlblink(scr_stat *scp, int at, int flip) | 987vga_pxlblink_direct(scr_stat *scp, int at, int flip) |
716{ 717 if (!(scp->status & VR_CURSOR_BLINK)) 718 return; 719 if (!(++pxlblinkrate & 4)) 720 return; 721 pxlblinkrate = 0; 722 scp->status ^= VR_CURSOR_ON; | 988{ 989 if (!(scp->status & VR_CURSOR_BLINK)) 990 return; 991 if (!(++pxlblinkrate & 4)) 992 return; 993 pxlblinkrate = 0; 994 scp->status ^= VR_CURSOR_ON; |
723 draw_pxlcursor(scp, at, scp->status & VR_CURSOR_ON, flip); | 995 draw_pxlcursor_direct(scp, at, scp->status & VR_CURSOR_ON, flip); |
724} 725 | 996} 997 |
998static void 999vga_pxlblink_planar(scr_stat *scp, int at, int flip) 1000{ 1001 if (!(scp->status & VR_CURSOR_BLINK)) 1002 return; 1003 if (!(++pxlblinkrate & 4)) 1004 return; 1005 pxlblinkrate = 0; 1006 scp->status ^= VR_CURSOR_ON; 1007 draw_pxlcursor_planar(scp, at, scp->status & VR_CURSOR_ON, flip); 1008} 1009 |
|
726#ifndef SC_NO_CUTPASTE 727 728static void | 1010#ifndef SC_NO_CUTPASTE 1011 1012static void |
729draw_pxlmouse(scr_stat *scp, int x, int y) | 1013draw_pxlmouse_planar(scr_stat *scp, int x, int y) |
730{ 731 vm_offset_t p; 732 int line_width; 733 int xoff, yoff; 734 int ymax; 735 u_short m; 736 int i, j; 737 --- 58 unchanged lines hidden (view full) --- 796 p += line_width; 797 } 798 } 799 outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */ 800 outw(GDCIDX, 0x0003); /* data rotate/function select */ 801} 802 803static void | 1014{ 1015 vm_offset_t p; 1016 int line_width; 1017 int xoff, yoff; 1018 int ymax; 1019 u_short m; 1020 int i, j; 1021 --- 58 unchanged lines hidden (view full) --- 1080 p += line_width; 1081 } 1082 } 1083 outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */ 1084 outw(GDCIDX, 0x0003); /* data rotate/function select */ 1085} 1086 1087static void |
804remove_pxlmouse(scr_stat *scp, int x, int y) | 1088remove_pxlmouse_planar(scr_stat *scp, int x, int y) |
805{ 806 vm_offset_t p; 807 int col, row; 808 int pos; 809 int line_width; 810 int ymax; 811 int i; 812 --- 40 unchanged lines hidden (view full) --- 853 p += line_width; 854 } 855 } 856 outw(GDCIDX, 0x0000); /* set/reset */ 857 outw(GDCIDX, 0x0001); /* set/reset enable */ 858} 859 860static void | 1089{ 1090 vm_offset_t p; 1091 int col, row; 1092 int pos; 1093 int line_width; 1094 int ymax; 1095 int i; 1096 --- 40 unchanged lines hidden (view full) --- 1137 p += line_width; 1138 } 1139 } 1140 outw(GDCIDX, 0x0000); /* set/reset */ 1141 outw(GDCIDX, 0x0001); /* set/reset enable */ 1142} 1143 1144static void |
861vga_pxlmouse(scr_stat *scp, int x, int y, int on) | 1145vga_pxlmouse_direct(scr_stat *scp, int x, int y, int on) |
862{ | 1146{ |
1147 vm_offset_t p; 1148 int line_width, pixel_size; 1149 int xend, yend; 1150 static int x_old = 0, xend_old = 0; 1151 static int y_old = 0, yend_old = 0; 1152 int i, j; 1153 uint32_t *u32; 1154 uint16_t *u16; 1155 int bpp; 1156 1157 if (!on) 1158 return; 1159 1160 bpp = scp->sc->adp->va_info.vi_depth; 1161 1162 if ((bpp == 16) && (scp->sc->adp->va_info.vi_pixel_fsizes[1] == 5)) 1163 bpp = 15; 1164 1165 line_width = scp->sc->adp->va_line_width; 1166 pixel_size = scp->sc->adp->va_info.vi_pixel_size; 1167 1168 xend = imin(x + 16, scp->xpixel); 1169 yend = imin(y + 16, scp->ypixel); 1170 1171 p = scp->sc->adp->va_window + y_old * line_width + x_old * pixel_size; 1172 1173 for (i = 0; i < (yend_old - y_old); i++) { 1174 for (j = (xend_old - x_old - 1); j >= 0; j--) { 1175 switch (bpp) { 1176 case 32: 1177 u32 = (uint32_t*)(p + j * pixel_size); 1178 writel(u32, mouse_buf32[i * 16 + j]); 1179 break; 1180 case 16: 1181 /* FALLTHROUGH */ 1182 case 15: 1183 u16 = (uint16_t*)(p + j * pixel_size); 1184 writew(u16, mouse_buf16[i * 16 + j]); 1185 break; 1186 } 1187 } 1188 1189 p += line_width; 1190 } 1191 1192 p = scp->sc->adp->va_window + y * line_width + x * pixel_size; 1193 1194 for (i = 0; i < (yend - y); i++) { 1195 for (j = (xend - x - 1); j >= 0; j--) { 1196 switch (bpp) { 1197 case 32: 1198 u32 = (uint32_t*)(p + j * pixel_size); 1199 mouse_buf32[i * 16 + j] = *u32; 1200 if (mouse_or_mask[i] & (1 << (15 - j))) 1201 writel(u32, vga_palette32[15]); 1202 else if (mouse_and_mask[i] & (1 << (15 - j))) 1203 writel(u32, 0); 1204 break; 1205 case 16: 1206 u16 = (uint16_t*)(p + j * pixel_size); 1207 mouse_buf16[i * 16 + j] = *u16; 1208 if (mouse_or_mask[i] & (1 << (15 - j))) 1209 writew(u16, vga_palette16[15]); 1210 else if (mouse_and_mask[i] & (1 << (15 - j))) 1211 writew(u16, 0); 1212 break; 1213 case 15: 1214 u16 = (uint16_t*)(p + j * pixel_size); 1215 mouse_buf16[i * 16 + j] = *u16; 1216 if (mouse_or_mask[i] & (1 << (15 - j))) 1217 writew(u16, vga_palette15[15]); 1218 else if (mouse_and_mask[i] & (1 << (15 - j))) 1219 writew(u16, 0); 1220 break; 1221 } 1222 } 1223 1224 p += line_width; 1225 } 1226 1227 x_old = x; 1228 y_old = y; 1229 xend_old = xend; 1230 yend_old = yend; 1231} 1232 1233static void 1234vga_pxlmouse_planar(scr_stat *scp, int x, int y, int on) 1235{ |
|
863 if (on) | 1236 if (on) |
864 draw_pxlmouse(scp, x, y); | 1237 draw_pxlmouse_planar(scp, x, y); |
865 else | 1238 else |
866 remove_pxlmouse(scp, x, y); | 1239 remove_pxlmouse_planar(scp, x, y); |
867} 868 869#endif /* SC_NO_CUTPASTE */ 870#endif /* SC_PIXEL_MODE */ 871 872#ifndef SC_NO_MODE_CHANGE 873 874/* graphics mode renderer */ 875 876static void 877vga_grborder(scr_stat *scp, int color) 878{ 879 (*vidsw[scp->sc->adapter]->set_border)(scp->sc->adp, color); 880} 881 882#endif | 1240} 1241 1242#endif /* SC_NO_CUTPASTE */ 1243#endif /* SC_PIXEL_MODE */ 1244 1245#ifndef SC_NO_MODE_CHANGE 1246 1247/* graphics mode renderer */ 1248 1249static void 1250vga_grborder(scr_stat *scp, int color) 1251{ 1252 (*vidsw[scp->sc->adapter]->set_border)(scp->sc->adp, color); 1253} 1254 1255#endif |