53,7 → 53,7 |
SPINLOCK_INITIALIZE(fb_lock); |
|
static uint8_t *fb_addr; |
static uint8_t *backbuf; |
static uint16_t *backbuf; |
static uint8_t *glyphs; |
static uint8_t *bgscan; |
|
77,8 → 77,9 |
|
#define BG_COLOR 0x000080 |
#define FG_COLOR 0xffff00 |
#define INV_COLOR 0xaaaaaa |
|
#define CURSOR 219 |
#define CURSOR 0x2588 |
|
#define RED(x, bits) ((x >> (8 + 8 + 8 - bits)) & ((1 << bits) - 1)) |
#define GREEN(x, bits) ((x >> (8 + 8 - bits)) & ((1 << bits) - 1)) |
199,7 → 200,7 |
/** Draw character at given position |
* |
*/ |
static void glyph_draw(uint8_t glyph, unsigned int col, unsigned int row, bool silent) |
static void glyph_draw(uint16_t glyph, unsigned int col, unsigned int row, bool silent) |
{ |
unsigned int x = COL2X(col); |
unsigned int y = ROW2Y(row); |
242,7 → 243,7 |
|
for (col = 0, x = 0; col < cols; col++, |
x += FONT_WIDTH) { |
uint8_t glyph; |
uint16_t glyph; |
|
if (row < rows - 1) { |
if (backbuf[BB_POS(col, row)] == |
261,20 → 262,20 |
} |
} |
|
memmove(backbuf, backbuf + cols, cols * (rows - 1)); |
memsetb(&backbuf[BB_POS(0, rows - 1)], cols, 0); |
memmove(backbuf, &backbuf[BB_POS(0, 1)], cols * (rows - 1) * sizeof(uint16_t)); |
memsetw(&backbuf[BB_POS(0, rows - 1)], cols, 0); |
} |
|
|
static void cursor_put(bool silent) |
{ |
glyph_draw(CURSOR, position % cols, position / cols, silent); |
glyph_draw(fb_font_glyph(CURSOR), position % cols, position / cols, silent); |
} |
|
|
static void cursor_remove(bool silent) |
{ |
glyph_draw(0, position % cols, position / cols, silent); |
glyph_draw(fb_font_glyph(0), position % cols, position / cols, silent); |
} |
|
|
283,7 → 284,7 |
* Emulate basic terminal commands. |
* |
*/ |
static void fb_putchar(outdev_t *dev, char ch, bool silent) |
static void fb_putchar(outdev_t *dev, wchar_t ch, bool silent) |
{ |
spinlock_lock(&fb_lock); |
|
305,13 → 306,13 |
case '\t': |
cursor_remove(silent); |
do { |
glyph_draw((uint8_t) ' ', position % cols, |
glyph_draw(fb_font_glyph(' '), position % cols, |
position / cols, silent); |
position++; |
} while ((position % 8) && (position < cols * rows)); |
break; |
default: |
glyph_draw((uint8_t) ch, position % cols, |
glyph_draw(fb_font_glyph(ch), position % cols, |
position / cols, silent); |
position++; |
} |
341,9 → 342,16 |
static void glyphs_render(void) |
{ |
/* Prerender glyphs */ |
unsigned int glyph; |
uint16_t glyph; |
|
for (glyph = 0; glyph < FONT_GLYPHS; glyph++) { |
uint32_t fg_color; |
|
if (glyph == FONT_GLYPHS - 1) |
fg_color = INV_COLOR; |
else |
fg_color = FG_COLOR; |
|
unsigned int y; |
|
for (y = 0; y < FONT_SCANLINES; y++) { |
352,8 → 360,8 |
for (x = 0; x < FONT_WIDTH; x++) { |
void *dst = &glyphs[GLYPH_POS(glyph, y) + |
x * pixelbytes]; |
uint32_t rgb = (fb_font[ROW2Y(glyph) + y] & |
(1 << (7 - x))) ? FG_COLOR : BG_COLOR; |
uint32_t rgb = (fb_font[glyph][y] & |
(1 << (7 - x))) ? fg_color : BG_COLOR; |
rgb_conv(dst, rgb); |
} |
} |
398,10 → 406,10 |
|
for (col = 0, x = 0; col < cols; |
col++, x += FONT_WIDTH) { |
void *d = &fb_addr[FB_POS(x, y + yd)]; |
void *s = &glyphs[GLYPH_POS(backbuf[BB_POS(col, |
row)], yd)]; |
memcpy(d, s, glyphscanline); |
uint16_t glyph = backbuf[BB_POS(col, row)]; |
void *dst = &fb_addr[FB_POS(x, y + yd)]; |
void *src = &glyphs[GLYPH_POS(glyph, yd)]; |
memcpy(dst, src, glyphscanline); |
} |
} |
} |
494,11 → 502,11 |
glyphbytes = ROW2Y(glyphscanline); |
bgscanbytes = xres * pixelbytes; |
|
unsigned int fbsize = scanline * yres; |
unsigned int bbsize = cols * rows; |
unsigned int glyphsize = FONT_GLYPHS * glyphbytes; |
size_t fbsize = scanline * yres; |
size_t bbsize = cols * rows * sizeof(uint16_t); |
size_t glyphsize = FONT_GLYPHS * glyphbytes; |
|
backbuf = (uint8_t *) malloc(bbsize, 0); |
backbuf = (uint16_t *) malloc(bbsize, 0); |
if (!backbuf) |
panic("Unable to allocate backbuffer."); |
|
510,7 → 518,7 |
if (!bgscan) |
panic("Unable to allocate background pixel."); |
|
memsetb(backbuf, bbsize, 0); |
memsetw(backbuf, cols * rows, 0); |
|
glyphs_render(); |
|