Rev 4232 | Rev 4316 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4232 | Rev 4233 | ||
---|---|---|---|
Line 91... | Line 91... | ||
91 | unsigned int scanline; |
91 | unsigned int scanline; |
92 | unsigned int glyphscanline; |
92 | unsigned int glyphscanline; |
93 | 93 | ||
94 | unsigned int pixelbytes; |
94 | unsigned int pixelbytes; |
95 | unsigned int glyphbytes; |
95 | unsigned int glyphbytes; |
- | 96 | ||
- | 97 | /** Pre-rendered mask for rendering glyphs. Specific for the visual. */ |
|
- | 98 | uint8_t *glyphs; |
|
96 | 99 | ||
97 | rgb_conv_t rgb_conv; |
100 | rgb_conv_t rgb_conv; |
98 | } screen; |
101 | } screen; |
99 | 102 | ||
100 | /** Backbuffer character cell. */ |
103 | /** Backbuffer character cell. */ |
Line 120... | Line 123... | ||
120 | */ |
123 | */ |
121 | 124 | ||
122 | /** Current attributes. */ |
125 | /** Current attributes. */ |
123 | attr_rgb_t attr; |
126 | attr_rgb_t attr; |
124 | 127 | ||
125 | /** Pre-rendered mask for rendering glyphs. Different viewports |
- | |
126 | * might use different drawing functions depending on whether their |
- | |
127 | * scanlines are aligned on a word boundary.*/ |
- | |
128 | uint8_t *glyphs; |
- | |
129 | - | ||
130 | uint8_t *bgpixel; |
128 | uint8_t *bgpixel; |
131 | 129 | ||
- | 130 | /** |
|
132 | /** Glyph drawing function for this viewport. */ |
131 | * Glyph drawing function for this viewport. Different viewports |
- | 132 | * might use different drawing functions depending on whether their |
|
- | 133 | * scanlines are aligned on a word boundary. |
|
- | 134 | */ |
|
133 | dg_t dglyph; |
135 | dg_t dglyph; |
134 | 136 | ||
135 | /* Auto-cursor position */ |
137 | /* Auto-cursor position */ |
136 | bool cursor_active; |
138 | bool cursor_active; |
137 | unsigned int cur_col; |
139 | unsigned int cur_col; |
Line 419... | Line 421... | ||
419 | glyph = 0; |
421 | glyph = 0; |
420 | fg_color = vport->attr.fg_color; |
422 | fg_color = vport->attr.fg_color; |
421 | bg_color = vport->attr.bg_color; |
423 | bg_color = vport->attr.bg_color; |
422 | } |
424 | } |
423 | 425 | ||
424 | (*vport->dglyph)(x, y, false, vport->glyphs, glyph, |
426 | (*vport->dglyph)(x, y, false, screen.glyphs, glyph, |
425 | fg_color, bg_color); |
427 | fg_color, bg_color); |
426 | x += FONT_WIDTH; |
428 | x += FONT_WIDTH; |
427 | } |
429 | } |
428 | y += FONT_SCANLINES; |
430 | y += FONT_SCANLINES; |
429 | } |
431 | } |
Line 447... | Line 449... | ||
447 | 449 | ||
448 | /** Render glyphs |
450 | /** Render glyphs |
449 | * |
451 | * |
450 | * Convert glyphs from device independent font |
452 | * Convert glyphs from device independent font |
451 | * description to current visual representation. |
453 | * description to current visual representation. |
452 | * |
- | |
453 | * @param vport Viewport |
- | |
454 | * |
- | |
455 | */ |
454 | */ |
456 | static void render_glyphs(viewport_t* vport) |
455 | static void render_glyphs(void) |
457 | { |
456 | { |
458 | unsigned int glyph; |
457 | unsigned int glyph; |
459 | 458 | ||
460 | for (glyph = 0; glyph < FONT_GLYPHS; glyph++) { |
459 | for (glyph = 0; glyph < FONT_GLYPHS; glyph++) { |
461 | unsigned int y; |
460 | unsigned int y; |
462 | 461 | ||
463 | for (y = 0; y < FONT_SCANLINES; y++) { |
462 | for (y = 0; y < FONT_SCANLINES; y++) { |
464 | unsigned int x; |
463 | unsigned int x; |
465 | 464 | ||
466 | for (x = 0; x < FONT_WIDTH; x++) { |
465 | for (x = 0; x < FONT_WIDTH; x++) { |
467 | screen.rgb_conv(&vport->glyphs[GLYPH_POS(glyph, y, false) + x * screen.pixelbytes], |
466 | screen.rgb_conv(&screen.glyphs[GLYPH_POS(glyph, y, false) + x * screen.pixelbytes], |
468 | (fb_font[glyph][y] & (1 << (7 - x))) |
467 | (fb_font[glyph][y] & (1 << (7 - x))) |
469 | ? 0xffffff : 0x000000); |
468 | ? 0xffffff : 0x000000); |
470 | 469 | ||
471 | screen.rgb_conv(&vport->glyphs[GLYPH_POS(glyph, y, true) + x * screen.pixelbytes], |
470 | screen.rgb_conv(&screen.glyphs[GLYPH_POS(glyph, y, true) + x * screen.pixelbytes], |
472 | (fb_font[glyph][y] & (1 << (7 - x))) |
471 | (fb_font[glyph][y] & (1 << (7 - x))) |
473 | ? 0x000000 : 0xffffff); |
472 | ? 0x000000 : 0xffffff); |
474 | } |
473 | } |
475 | } |
474 | } |
476 | } |
475 | } |
477 | - | ||
478 | screen.rgb_conv(vport->bgpixel, vport->attr.bg_color); |
- | |
479 | } |
476 | } |
480 | 477 | ||
481 | 478 | ||
482 | /** Create new viewport |
479 | /** Create new viewport |
483 | * |
480 | * |
Line 502... | Line 499... | ||
502 | return ELIMIT; |
499 | return ELIMIT; |
503 | 500 | ||
504 | unsigned int cols = width / FONT_WIDTH; |
501 | unsigned int cols = width / FONT_WIDTH; |
505 | unsigned int rows = height / FONT_SCANLINES; |
502 | unsigned int rows = height / FONT_SCANLINES; |
506 | unsigned int bbsize = cols * rows * sizeof(bb_cell_t); |
503 | unsigned int bbsize = cols * rows * sizeof(bb_cell_t); |
507 | unsigned int glyphsize = 2 * FONT_GLYPHS * screen.glyphbytes; |
- | |
508 | unsigned int word_size = sizeof(unsigned long); |
504 | unsigned int word_size = sizeof(unsigned long); |
509 | 505 | ||
510 | bb_cell_t *backbuf = (bb_cell_t *) malloc(bbsize); |
506 | bb_cell_t *backbuf = (bb_cell_t *) malloc(bbsize); |
511 | if (!backbuf) |
507 | if (!backbuf) |
512 | return ENOMEM; |
508 | return ENOMEM; |
513 | 509 | ||
514 | uint8_t *glyphs = (uint8_t *) malloc(glyphsize); |
- | |
515 | if (!glyphs) { |
- | |
516 | free(backbuf); |
- | |
517 | return ENOMEM; |
- | |
518 | } |
- | |
519 | - | ||
520 | uint8_t *bgpixel = (uint8_t *) malloc(screen.pixelbytes); |
510 | uint8_t *bgpixel = (uint8_t *) malloc(screen.pixelbytes); |
521 | if (!bgpixel) { |
511 | if (!bgpixel) { |
522 | free(glyphs); |
- | |
523 | free(backbuf); |
512 | free(backbuf); |
524 | return ENOMEM; |
513 | return ENOMEM; |
525 | } |
514 | } |
526 | 515 | ||
527 | backbuf_clear(backbuf, cols * rows, DEFAULT_FGCOLOR, DEFAULT_BGCOLOR); |
516 | backbuf_clear(backbuf, cols * rows, DEFAULT_FGCOLOR, DEFAULT_BGCOLOR); |
528 | memset(glyphs, 0, glyphsize); |
- | |
529 | memset(bgpixel, 0, screen.pixelbytes); |
517 | memset(bgpixel, 0, screen.pixelbytes); |
530 | 518 | ||
531 | viewports[i].x = x; |
519 | viewports[i].x = x; |
532 | viewports[i].y = y; |
520 | viewports[i].y = y; |
533 | viewports[i].width = width; |
521 | viewports[i].width = width; |
Line 537... | Line 525... | ||
537 | viewports[i].rows = rows; |
525 | viewports[i].rows = rows; |
538 | 526 | ||
539 | viewports[i].attr.bg_color = DEFAULT_BGCOLOR; |
527 | viewports[i].attr.bg_color = DEFAULT_BGCOLOR; |
540 | viewports[i].attr.fg_color = DEFAULT_FGCOLOR; |
528 | viewports[i].attr.fg_color = DEFAULT_FGCOLOR; |
541 | 529 | ||
542 | viewports[i].glyphs = glyphs; |
- | |
543 | viewports[i].bgpixel = bgpixel; |
530 | viewports[i].bgpixel = bgpixel; |
544 | 531 | ||
545 | /* |
532 | /* |
546 | * Conditions necessary to select aligned version: |
533 | * Conditions necessary to select aligned version: |
547 | * |
534 | * |
Line 567... | Line 554... | ||
567 | viewports[i].bbsize = bbsize; |
554 | viewports[i].bbsize = bbsize; |
568 | viewports[i].backbuf = backbuf; |
555 | viewports[i].backbuf = backbuf; |
569 | 556 | ||
570 | viewports[i].initialized = true; |
557 | viewports[i].initialized = true; |
571 | 558 | ||
572 | render_glyphs(&viewports[i]); |
559 | screen.rgb_conv(viewports[i].bgpixel, viewports[i].attr.bg_color); |
573 | 560 | ||
574 | return i; |
561 | return i; |
575 | } |
562 | } |
576 | 563 | ||
577 | 564 | ||
Line 585... | Line 572... | ||
585 | * |
572 | * |
586 | */ |
573 | */ |
587 | static bool screen_init(void *addr, unsigned int xres, unsigned int yres, |
574 | static bool screen_init(void *addr, unsigned int xres, unsigned int yres, |
588 | unsigned int scan, unsigned int visual) |
575 | unsigned int scan, unsigned int visual) |
589 | { |
576 | { |
- | 577 | unsigned int glyphsize; |
|
- | 578 | uint8_t *glyphs; |
|
590 | switch (visual) { |
579 | switch (visual) { |
591 | case VISUAL_INDIRECT_8: |
580 | case VISUAL_INDIRECT_8: |
592 | screen.rgb_conv = rgb_323; |
581 | screen.rgb_conv = rgb_323; |
593 | screen.pixelbytes = 1; |
582 | screen.pixelbytes = 1; |
594 | break; |
583 | break; |
Line 629... | Line 618... | ||
629 | screen.yres = yres; |
618 | screen.yres = yres; |
630 | screen.scanline = scan; |
619 | screen.scanline = scan; |
631 | 620 | ||
632 | screen.glyphscanline = FONT_WIDTH * screen.pixelbytes; |
621 | screen.glyphscanline = FONT_WIDTH * screen.pixelbytes; |
633 | screen.glyphbytes = screen.glyphscanline * FONT_SCANLINES; |
622 | screen.glyphbytes = screen.glyphscanline * FONT_SCANLINES; |
- | 623 | ||
- | 624 | glyphsize = 2 * FONT_GLYPHS * screen.glyphbytes; |
|
- | 625 | glyphs = (uint8_t *) malloc(glyphsize); |
|
- | 626 | if (!glyphs) |
|
- | 627 | return false; |
|
- | 628 | ||
- | 629 | memset(glyphs, 0, glyphsize); |
|
- | 630 | screen.glyphs = glyphs; |
|
- | 631 | ||
- | 632 | render_glyphs(); |
|
634 | 633 | ||
635 | /* Create first viewport */ |
634 | /* Create first viewport */ |
636 | vport_create(0, 0, xres, yres); |
635 | vport_create(0, 0, xres, yres); |
637 | 636 | ||
638 | return true; |
637 | return true; |
Line 786... | Line 785... | ||
786 | 785 | ||
787 | glyph = vport->backbuf[BB_POS(vport, col, row)].glyph; |
786 | glyph = vport->backbuf[BB_POS(vport, col, row)].glyph; |
788 | fg_color = vport->backbuf[BB_POS(vport, col, row)].fg_color; |
787 | fg_color = vport->backbuf[BB_POS(vport, col, row)].fg_color; |
789 | bg_color = vport->backbuf[BB_POS(vport, col, row)].bg_color; |
788 | bg_color = vport->backbuf[BB_POS(vport, col, row)].bg_color; |
790 | 789 | ||
791 | (*vport->dglyph)(x, y, cursor, vport->glyphs, glyph, |
790 | (*vport->dglyph)(x, y, cursor, screen.glyphs, glyph, |
792 | fg_color, bg_color); |
791 | fg_color, bg_color); |
793 | } |
792 | } |
794 | 793 | ||
795 | /** Hide cursor if it is shown |
794 | /** Hide cursor if it is shown |
796 | * |
795 | * |
Line 1632... | Line 1631... | ||
1632 | if (!viewports[i].initialized) { |
1631 | if (!viewports[i].initialized) { |
1633 | retval = EADDRNOTAVAIL; |
1632 | retval = EADDRNOTAVAIL; |
1634 | break; |
1633 | break; |
1635 | } |
1634 | } |
1636 | viewports[i].initialized = false; |
1635 | viewports[i].initialized = false; |
1637 | if (viewports[i].glyphs) |
- | |
1638 | free(viewports[i].glyphs); |
- | |
1639 | if (viewports[i].bgpixel) |
1636 | if (viewports[i].bgpixel) |
1640 | free(viewports[i].bgpixel); |
1637 | free(viewports[i].bgpixel); |
1641 | if (viewports[i].backbuf) |
1638 | if (viewports[i].backbuf) |
1642 | free(viewports[i].backbuf); |
1639 | free(viewports[i].backbuf); |
1643 | retval = EOK; |
1640 | retval = EOK; |