7 static unsigned char _font[256 * 32];
9 /* Must be called from a firstrun context, where we don't care about saving
13 unsigned char oldread;
14 outb(0x3CE, 0x05 /* Mode register */);
15 outb(0x3CF, inb(0x3CF) & ~(0x10 /* Odd/even */));
16 outb(0x3CE, 0x04 /* Read register */);
18 outb(0x3CF, 0x02 /* Font plane */);
19 memcpy(_font, p2v(0xB8000), sizeof(_font));
23 void text_render(char *buf, int x, int y, int w, int h)
25 unsigned char *video = p2v(0xB8000);
26 unsigned int textx = x / 9;
27 unsigned int texty = y / 14;
29 unsigned char ch, at, font;
31 for (cy = y; cy < (y + h); cy++)
35 ch = video[texty * 50 + textx * 2];
36 at = video[texty * 50 + textx * 2 + 1];
37 font = _font[ch * 32 + cy % 14];
38 for (cx = x; cx < (x + w); cx++)
40 unsigned int pos = cx % 9;
44 ch = video[texty * 50 + textx * 2];
45 at = video[texty * 50 + textx * 2 + 1];
46 font = _font[ch * 32 + cy % 14];
48 /* XXX always BGR888 */
49 if (pos == 8) /* 9th pixel is cloned */
51 if ((font >> (7 - pos)) & 1)
53 *(buf++) = (at & 0x01) ? 0xFF : 0x00;
54 *(buf++) = (at & 0x02) ? 0xFF : 0x00;
55 *(buf++) = (at & 0x04) ? 0xFF : 0x00;
57 *(buf++) = (at & 0x10) ? 0xFF : 0x00;
58 *(buf++) = (at & 0x20) ? 0xFF : 0x00;
59 *(buf++) = (at & 0x40) ? 0xFF : 0x00;
66 uint32_t text_checksum(int x, int y, int w, int h)
68 unsigned char *video = p2v(0xB8000);
69 unsigned int textx = x / 9;
70 unsigned int texty = y / 14;
75 for (cy = y; cy < (y + h); cy++)
79 ch = video[texty * 50 + textx * 2];
80 at = video[texty * 50 + textx * 2 + 1];
81 for (cx = x; cx < (x + w); cx++)
83 unsigned int pos = cx % 9;
87 ch = video[texty * 50 + textx * 2];
88 at = video[texty * 50 + textx * 2 + 1];
91 cksm += ch + (at << 16);