Lines Matching +full:cp437 +full:- +full:8 +full:x16

1 /*-
65 bus_space_read_1(sc->vga_fb_tag, sc->vga_fb_handle, ofs)
67 bus_space_write_1(sc->vga_fb_tag, sc->vga_fb_handle, ofs, val)
69 bus_space_write_2(sc->vga_fb_tag, sc->vga_fb_handle, ofs, val)
71 bus_space_read_1(sc->vga_reg_tag, sc->vga_reg_handle, reg)
73 bus_space_write_1(sc->vga_reg_tag, sc->vga_reg_handle, reg, val)
77 #define VT_VGA_MEMSIZE (VT_VGA_WIDTH * VT_VGA_HEIGHT / 8)
80 * VGA is designed to handle 8 pixels at a time (8 pixels in one byte of
83 #define VT_VGA_PIXELS_BLOCK 8
86 * We use an off-screen addresses to:
129 struct vga_softc *sc = vd->vd_softc; in vga_setwmode()
131 if (sc->vga_wmode == wmode) in vga_setwmode()
136 sc->vga_wmode = wmode; in vga_setwmode()
140 /* Re-enable all planes. */ in vga_setwmode()
151 struct vga_softc *sc = vd->vd_softc; in vga_setfg()
155 if (sc->vga_curfg == color) in vga_setfg()
160 sc->vga_curfg = color; in vga_setfg()
166 struct vga_softc *sc = vd->vd_softc; in vga_setbg()
170 if (sc->vga_curbg == color) in vga_setbg()
177 * Write 8 pixels using the background color to an off-screen in vga_setbg()
183 * Read those 8 pixels back to load the background color in the in vga_setbg()
188 sc->vga_curbg = color; in vga_setbg()
194 sc->vga_curfg = 0xff; in vga_setbg()
198 * Binary searchable table for Unicode to CP437 conversion.
286 { 0x25ac, 0x16, 0x00 }, { 0x25b2, 0x1e, 0x00 },
304 max = nitems(cp437table) - 1; in vga_get_cp437()
313 max = mid - 1; in vga_get_cp437()
318 return (c - cp437table[mid].unicode_base + in vga_get_cp437()
328 struct vga_softc *sc = vd->vd_softc; in vga_blank()
340 struct vga_softc *sc = vd->vd_softc; in vga_bitblt_put()
348 * set of 8 pixels that are about to be changed. There in vga_bitblt_put()
356 sc->vga_curbg = 0xff; in vga_bitblt_put()
366 if (vd->vd_flags & VDF_TEXTMODE) in vga_setpixel()
369 vga_bitblt_put(vd, (y * VT_VGA_WIDTH / 8) + (x / 8), color, in vga_setpixel()
370 0x80 >> (x % 8)); in vga_setpixel()
379 if (vd->vd_flags & VDF_TEXTMODE) in vga_drawrect()
400 n = src_x / 8; in vga_compute_shifted_pattern()
408 >> (8 - x_count)) in vga_compute_shifted_pattern()
409 << (8 - x_count - dst_x); in vga_compute_shifted_pattern()
412 if (n == (src_x + x_count - 1) / 8) { in vga_compute_shifted_pattern()
416 *pattern >>= (dst_x - src_x % 8); in vga_compute_shifted_pattern()
418 *pattern <<= (src_x % 8 - dst_x); in vga_compute_shifted_pattern()
421 if (dst_x >= src_x % 8) { in vga_compute_shifted_pattern()
423 src[n] << (8 - dst_x - src_x % 8) | in vga_compute_shifted_pattern()
424 src[n + 1] >> (dst_x - src_x % 8); in vga_compute_shifted_pattern()
427 src[n] << (src_x % 8 - dst_x) | in vga_compute_shifted_pattern()
428 src[n + 1] >> (8 - src_x % 8 - dst_x); in vga_compute_shifted_pattern()
443 bytes = (src_width + 7) / 8; in vga_copy_bitmap_portion()
475 /* Set the bits in the 2-colors array. */ in vga_copy_bitmap_portion()
484 * Set the same bits in the n-colors array. This one in vga_copy_bitmap_portion()
523 sc = vd->vd_softc; in vga_bitblt_pixels_block_2colors()
524 offset = (VT_VGA_WIDTH * y + x) / 8; in vga_bitblt_pixels_block_2colors()
526 for (i = 0; i < height; ++i, offset += VT_VGA_WIDTH / 8) { in vga_bitblt_pixels_block_2colors()
539 sc = vd->vd_softc; in vga_bitblt_pixels_block_ncolors()
550 * color code for each of the 8 pixels. in vga_bitblt_pixels_block_ncolors()
552 * For example, if the 8 pixels are like this: in vga_bitblt_pixels_block_ncolors()
566 * | | +-> 0b0011 (Y) in vga_bitblt_pixels_block_ncolors()
567 * | +-----> 0b0000 (B) in vga_bitblt_pixels_block_ncolors()
568 * +--------> 0b0111 (G) in vga_bitblt_pixels_block_ncolors()
577 for (j = 0; j < 8; ++j) { in vga_bitblt_pixels_block_ncolors()
578 if (!((mask >> (7 - j)) & 0x1)) in vga_bitblt_pixels_block_ncolors()
585 plane) & 0x1) << (7 - j); in vga_bitblt_pixels_block_ncolors()
603 offset = (VT_VGA_WIDTH * (y + i) + x) / 8; in vga_bitblt_pixels_block_ncolors()
617 uint8_t pattern_2colors[vw->vw_font->vf_height]; in vga_bitblt_one_text_pixels_block()
618 uint8_t pattern_ncolors[vw->vw_font->vf_height * 16]; in vga_bitblt_one_text_pixels_block()
623 vb = &vw->vw_buf; in vga_bitblt_one_text_pixels_block()
624 vf = vw->vw_font; in vga_bitblt_one_text_pixels_block()
641 if (i < vw->vw_draw_area.tr_begin.tp_col) { in vga_bitblt_one_text_pixels_block()
647 i = vw->vw_draw_area.tr_begin.tp_col; in vga_bitblt_one_text_pixels_block()
651 i < vw->vw_draw_area.tr_end.tp_col) { in vga_bitblt_one_text_pixels_block()
659 col = (i - vw->vw_draw_area.tr_begin.tp_col) / vf->vf_width; in vga_bitblt_one_text_pixels_block()
660 row = (y - vw->vw_draw_area.tr_begin.tp_row) / vf->vf_height; in vga_bitblt_one_text_pixels_block()
679 * the current position - in vga_bitblt_one_text_pixels_block()
683 * - the last pixel of the character, or in vga_bitblt_one_text_pixels_block()
684 * - the pixel of the character matching the end of in vga_bitblt_one_text_pixels_block()
691 src_x = i - in vga_bitblt_one_text_pixels_block()
692 (col * vf->vf_width + vw->vw_draw_area.tr_begin.tp_col); in vga_bitblt_one_text_pixels_block()
694 (col + 1) * vf->vf_width + in vga_bitblt_one_text_pixels_block()
695 vw->vw_draw_area.tr_begin.tp_col, in vga_bitblt_one_text_pixels_block()
697 vw->vw_draw_area.tr_end.tp_col); in vga_bitblt_one_text_pixels_block()
698 x_count -= col * vf->vf_width + in vga_bitblt_one_text_pixels_block()
699 vw->vw_draw_area.tr_begin.tp_col; in vga_bitblt_one_text_pixels_block()
700 x_count -= src_x; in vga_bitblt_one_text_pixels_block()
704 src, NULL, vf->vf_width, in vga_bitblt_one_text_pixels_block()
706 0, 0, vf->vf_height, fg, bg, 0); in vga_bitblt_one_text_pixels_block()
726 drawn_area.tr_end.tp_row = y + vf->vf_height; in vga_bitblt_one_text_pixels_block()
727 if (vd->vd_mshown && vt_is_cursor_in_area(vd, &drawn_area)) { in vga_bitblt_one_text_pixels_block()
732 cursor = vd->vd_mcursor; in vga_bitblt_one_text_pixels_block()
733 mx = vd->vd_mx_drawn + vw->vw_draw_area.tr_begin.tp_col; in vga_bitblt_one_text_pixels_block()
734 my = vd->vd_my_drawn + vw->vw_draw_area.tr_begin.tp_row; in vga_bitblt_one_text_pixels_block()
737 src_x = x > mx ? x - mx : 0; in vga_bitblt_one_text_pixels_block()
738 dst_x = mx > x ? mx - x : 0; in vga_bitblt_one_text_pixels_block()
740 cursor->width - src_x, in vga_bitblt_one_text_pixels_block()
741 x + VT_VGA_PIXELS_BLOCK - mx), in vga_bitblt_one_text_pixels_block()
742 vw->vw_draw_area.tr_end.tp_col - mx), in vga_bitblt_one_text_pixels_block()
746 * The cursor isn't aligned on the Y-axis with in vga_bitblt_one_text_pixels_block()
750 src_y = y > my ? y - my : 0; in vga_bitblt_one_text_pixels_block()
751 dst_y = my > y ? my - y : 0; in vga_bitblt_one_text_pixels_block()
753 min(cursor->height - src_y, y + vf->vf_height - my), in vga_bitblt_one_text_pixels_block()
754 vf->vf_height); in vga_bitblt_one_text_pixels_block()
758 cursor->map, cursor->mask, cursor->width, in vga_bitblt_one_text_pixels_block()
760 vd->vd_mcursor_fg, vd->vd_mcursor_bg, 1); in vga_bitblt_one_text_pixels_block()
762 if ((used_colors_list[vd->vd_mcursor_fg] & 0x1) != 0x1) in vga_bitblt_one_text_pixels_block()
764 if ((used_colors_list[vd->vd_mcursor_bg] & 0x2) != 0x2) in vga_bitblt_one_text_pixels_block()
775 x, y, vf->vf_height); in vga_bitblt_one_text_pixels_block()
778 x, y, vf->vf_height); in vga_bitblt_one_text_pixels_block()
789 vf = vw->vw_font; in vga_bitblt_text_gfxmode()
792 * Compute the top-left pixel position aligned with the video in vga_bitblt_text_gfxmode()
795 * This is calculated from the top-left column of te dirty area: in vga_bitblt_text_gfxmode()
797 * 1. Compute the top-left pixel of the character: in vga_bitblt_text_gfxmode()
805 * an aligned pixels block (eg. chunk of 8 pixels): in vga_bitblt_text_gfxmode()
811 * For the Y-axis, we need to compute the character's y in vga_bitblt_text_gfxmode()
815 col = area->tr_begin.tp_col; in vga_bitblt_text_gfxmode()
816 row = area->tr_begin.tp_row; in vga_bitblt_text_gfxmode()
817 x1 = (int)((col * vf->vf_width + vw->vw_draw_area.tr_begin.tp_col) in vga_bitblt_text_gfxmode()
820 y1 = row * vf->vf_height + vw->vw_draw_area.tr_begin.tp_row; in vga_bitblt_text_gfxmode()
830 col = area->tr_end.tp_col; in vga_bitblt_text_gfxmode()
831 row = area->tr_end.tp_row; in vga_bitblt_text_gfxmode()
832 x2 = (int)howmany(col * vf->vf_width + vw->vw_draw_area.tr_begin.tp_col, in vga_bitblt_text_gfxmode()
835 y2 = row * vf->vf_height + vw->vw_draw_area.tr_begin.tp_row; in vga_bitblt_text_gfxmode()
838 x2 = min(x2, vw->vw_draw_area.tr_end.tp_col); in vga_bitblt_text_gfxmode()
839 y2 = min(y2, vw->vw_draw_area.tr_end.tp_row); in vga_bitblt_text_gfxmode()
847 * Therefore, on the X-axis, characters my be drawn partially if in vga_bitblt_text_gfxmode()
848 * they are not aligned on 8-pixels boundary. in vga_bitblt_text_gfxmode()
856 for (y = y1; y < y2; y += vf->vf_height) { in vga_bitblt_text_gfxmode()
875 sc = vd->vd_softc; in vga_bitblt_text_txtmode()
876 vb = &vw->vw_buf; in vga_bitblt_text_txtmode()
878 for (row = area->tr_begin.tp_row; row < area->tr_end.tp_row; ++row) { in vga_bitblt_text_txtmode()
879 for (col = area->tr_begin.tp_col; in vga_bitblt_text_txtmode()
880 col < area->tr_end.tp_col; in vga_bitblt_text_txtmode()
894 if (vd->vd_drawn && (vd->vd_drawn[z] == c) && in vga_bitblt_text_txtmode()
895 vd->vd_drawnfg && (vd->vd_drawnfg[z] == fg) && in vga_bitblt_text_txtmode()
896 vd->vd_drawnbg && (vd->vd_drawnbg[z] == bg)) in vga_bitblt_text_txtmode()
900 * Convert character to CP437, which is the in vga_bitblt_text_txtmode()
912 ch + ((uint16_t)(attr) << 8)); in vga_bitblt_text_txtmode()
914 if (vd->vd_drawn) in vga_bitblt_text_txtmode()
915 vd->vd_drawn[z] = c; in vga_bitblt_text_txtmode()
916 if (vd->vd_drawnfg) in vga_bitblt_text_txtmode()
917 vd->vd_drawnfg[z] = fg; in vga_bitblt_text_txtmode()
918 if (vd->vd_drawnbg) in vga_bitblt_text_txtmode()
919 vd->vd_drawnbg[z] = bg; in vga_bitblt_text_txtmode()
929 if (!(vd->vd_flags & VDF_TEXTMODE)) { in vga_bitblt_text()
942 for (row = area->tr_begin.tp_row; row < area->tr_end.tp_row; ++row) { in vga_invalidate_text()
943 for (col = area->tr_begin.tp_col; in vga_invalidate_text()
944 col < area->tr_end.tp_col; in vga_invalidate_text()
950 if (vd->vd_drawn) in vga_invalidate_text()
951 vd->vd_drawn[z] = 0; in vga_invalidate_text()
952 if (vd->vd_drawnfg) in vga_invalidate_text()
953 vd->vd_drawnfg[z] = 0; in vga_invalidate_text()
954 if (vd->vd_drawnbg) in vga_invalidate_text()
955 vd->vd_drawnbg[z] = 0; in vga_invalidate_text()
969 /* Align coordinates with the 8-pxels grid. */ in vga_bitblt_bitmap()
975 x2 = min(x2, vd->vd_width - 1); in vga_bitblt_bitmap()
976 y2 = min(y2, vd->vd_height - 1); in vga_bitblt_bitmap()
980 dst_x = x - x1; in vga_bitblt_bitmap()
981 x_count = VT_VGA_PIXELS_BLOCK - dst_x; in vga_bitblt_bitmap()
990 j - y1, 0, 1, fg, bg, 0); in vga_bitblt_bitmap()
998 x_count = min(width - src_x, VT_VGA_PIXELS_BLOCK); in vga_bitblt_bitmap()
1016 struct vga_softc *sc = vd->vd_softc; in vga_initialize_graphics()
1034 REG_WRITE1(sc, VGA_CRTC_DATA, 0x4f); /* 640 - 8 */ in vga_initialize_graphics()
1055 REG_WRITE1(sc, VGA_CRTC_DATA, 0xdf); /* 480 - 1*/ in vga_initialize_graphics()
1097 struct vga_softc *sc = vd->vd_softc; in vga_initialize()
1105 /* Unprotect CRTC registers 0-7. */ in vga_initialize()
1113 * the side-effect of clearing the internal flip-flip of the attribute in vga_initialize()
1125 } while (x != (VGA_GEN_IS1_VR | VGA_GEN_IS1_DE) && --timeout != 0); in vga_initialize()
1188 REG_WRITE1(sc, VGA_AC_WRITE, VGA_AC_PALETTE(8)); in vga_initialize()
1225 * enabled, so a single-paged loop should clear all in vga_initialize()
1233 /* Re-enable the sequencer. */ in vga_initialize()
1236 /* Re-enable the sync signals. */ in vga_initialize()
1245 sc->vga_wmode = 3; in vga_initialize()
1249 * use Write Mode 0 to write a group of 8 pixels using in vga_initialize()
1260 sc->vga_curfg = sc->vga_curbg = 0xff; in vga_initialize()
1300 if (vd->vd_softc == NULL) in vga_init()
1301 vd->vd_softc = (void *)&vga_conssoftc; in vga_init()
1302 sc = vd->vd_softc; in vga_init()
1304 if (vd->vd_flags & VDF_DOWNGRADE && vd->vd_video_dev != NULL) in vga_init()
1305 vga_pci_repost(vd->vd_video_dev); in vga_init()
1308 sc->vga_fb_tag = X86_BUS_SPACE_MEM; in vga_init()
1309 sc->vga_reg_tag = X86_BUS_SPACE_IO; in vga_init()
1314 bus_space_map(sc->vga_reg_tag, VGA_REG_BASE, VGA_REG_SIZE, 0, in vga_init()
1315 &sc->vga_reg_handle); in vga_init()
1321 * in text mode, especially when we're on Hyper-V. in vga_init()
1326 vd->vd_flags |= VDF_TEXTMODE; in vga_init()
1327 vd->vd_width = 80; in vga_init()
1328 vd->vd_height = 25; in vga_init()
1329 bus_space_map(sc->vga_fb_tag, VGA_TXT_BASE, VGA_TXT_SIZE, 0, in vga_init()
1330 &sc->vga_fb_handle); in vga_init()
1332 vd->vd_width = VT_VGA_WIDTH; in vga_init()
1333 vd->vd_height = VT_VGA_HEIGHT; in vga_init()
1334 bus_space_map(sc->vga_fb_tag, VGA_MEM_BASE, VGA_MEM_SIZE, 0, in vga_init()
1335 &sc->vga_fb_handle); in vga_init()
1339 sc->vga_enabled = true; in vga_init()
1349 vga_initialize(vd, (vd->vd_flags & VDF_TEXTMODE)); in vga_postswitch()
1351 vd->vd_flags |= VDF_INVALID; in vga_postswitch()
1362 if (BUS_ADD_CHILD(parent, 0, driver->name, 0) == NULL) in vtvga_identify()
1383 &res_id, VGA_MEM_BASE, VGA_MEM_BASE + VGA_MEM_SIZE - 1, in vtvga_attach()
1390 /*-------------------- Private Device Attachment Data -----------------------*/