Changeset 6e71a9d8 in mainline


Ignore:
Timestamp:
2008-12-16T21:25:16Z (16 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
feaa871
Parents:
882d7a8
Message:

resurrect kernel logo

Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • kernel/genarch/Makefile.inc

    r882d7a8 r6e71a9d8  
    6161        GENARCH_SOURCES += \
    6262                genarch/src/fb/font-8x16.c \
     63                genarch/src/fb/logo-196x66.c \
    6364                genarch/src/fb/fb.c
    6465        DEFS += -DCONFIG_FB
  • kernel/genarch/src/fb/fb.c

    r882d7a8 r6e71a9d8  
    3535
    3636#include <genarch/fb/font-8x16.h>
     37#include <genarch/fb/logo-196x66.h>
    3738#include <genarch/fb/visuals.h>
    3839#include <genarch/fb/fb.h>
     
    5859static uint8_t *backbuf;
    5960static uint8_t *glyphs;
    60 
    61 static void *bgpixel;
     61static uint8_t *bgscan;
    6262
    6363static unsigned int xres;
    6464static unsigned int yres;
    6565
     66static unsigned int ylogo;
     67static unsigned int ytrim;
     68static unsigned int rowtrim;
     69
    6670static unsigned int scanline;
    6771static unsigned int glyphscanline;
     
    6973static unsigned int pixelbytes;
    7074static unsigned int glyphbytes;
     75static unsigned int bgscanbytes;
    7176
    7277static unsigned int cols;
     
    122127{
    123128#if defined(FB_INVERT_ENDIAN)
    124         *((uint32_t *) dst)
    125             = (BLUE(rgb, 8) << 16) | (GREEN(rgb, 8) << 8) | RED(rgb, 8)
    126             | (*((uint32_t *) dst) & 0xff0000);
     129        ((uint8_t *) dst)[0] = RED(rgb, 8);
     130        ((uint8_t *) dst)[1] = GREEN(rgb, 8);
     131        ((uint8_t *) dst)[2] = BLUE(rgb, 8);
    127132#else
    128         *((uint32_t *) dst)
    129             = (rgb & 0xffffff) | (*((uint32_t *) dst) & 0xff0000);
     133        ((uint8_t *) dst)[0] = BLUE(rgb, 8);
     134        ((uint8_t *) dst)[1] = GREEN(rgb, 8);
     135        ((uint8_t *) dst)[2] = RED(rgb, 8);
    130136#endif
    131137}
     
    176182
    177183
     184/** Hide logo and refresh screen
     185 *
     186 */
     187static void logo_hide(void)
     188{
     189        ylogo = 0;
     190        ytrim = yres;
     191        rowtrim = rows;
     192        fb_redraw();
     193}
     194
     195
    178196/** Draw character at given position
    179197 *
    180198 */
    181 static void draw_glyph(uint8_t glyph, unsigned int col, unsigned int row)
     199static void glyph_draw(uint8_t glyph, unsigned int col, unsigned int row)
    182200{
    183201        unsigned int x = COL2X(col);
     
    185203        unsigned int yd;
    186204       
     205        if (y >= ytrim)
     206                logo_hide();
     207       
    187208        backbuf[BB_POS(col, row)] = glyph;
    188209       
    189210        for (yd = 0; yd < FONT_SCANLINES; yd++)
    190                 memcpy(&fb_addr[FB_POS(x, y + yd)],
     211                memcpy(&fb_addr[FB_POS(x, y + yd + ylogo)],
    191212                    &glyphs[GLYPH_POS(glyph, yd)], glyphscanline);
    192213}
     
    197218 *
    198219 */
    199 static void scroll_screen(void)
    200 {
     220static void screen_scroll(void)
     221{
     222        if (ylogo > 0)
     223                logo_hide();
     224       
    201225        unsigned int row;
    202226       
     
    233257static void cursor_put(void)
    234258{
    235         draw_glyph(CURSOR, position % cols, position / cols);
     259        glyph_draw(CURSOR, position % cols, position / cols);
    236260}
    237261
     
    239263static void cursor_remove(void)
    240264{
    241         draw_glyph(0, position % cols, position / cols);
     265        glyph_draw(0, position % cols, position / cols);
    242266}
    243267
     
    270294                cursor_remove();
    271295                do {
    272                         draw_glyph((uint8_t) ' ', position % cols, position / cols);
     296                        glyph_draw((uint8_t) ' ', position % cols, position / cols);
    273297                        position++;
    274298                } while ((position % 8) && (position < cols * rows));
    275299                break;
    276300        default:
    277                 draw_glyph((uint8_t) ch, position % cols, position / cols);
     301                glyph_draw((uint8_t) ch, position % cols, position / cols);
    278302                position++;
    279303        }
     
    281305        if (position >= cols * rows) {
    282306                position -= cols;
    283                 scroll_screen();
     307                screen_scroll();
    284308        }
    285309       
     
    301325 *
    302326 */
    303 static void render_glyphs(void)
    304 {
     327static void glyphs_render(void)
     328{
     329        /* Prerender glyphs */
    305330        unsigned int glyph;
    306331       
     
    313338                        for (x = 0; x < FONT_WIDTH; x++)
    314339                                rgb_conv(&glyphs[GLYPH_POS(glyph, y) + x * pixelbytes],
    315                                     (fb_font[glyph * FONT_SCANLINES + y] & (1 << (7 - x))) ? FG_COLOR : BG_COLOR);
     340                                    (fb_font[ROW2Y(glyph) + y] & (1 << (7 - x))) ? FG_COLOR : BG_COLOR);
    316341                }
    317342        }
    318343       
    319         rgb_conv(bgpixel, BG_COLOR);
     344        /* Prerender background scanline */
     345        unsigned int x;
     346       
     347        for (x = 0; x < xres; x++)
     348                rgb_conv(&bgscan[x * pixelbytes], BG_COLOR);
    320349}
    321350
     
    326355void fb_redraw(void)
    327356{
     357        if (ylogo > 0) {
     358                unsigned int y;
     359               
     360                for (y = 0; y < LOGO_HEIGHT; y++) {
     361                        unsigned int x;
     362                       
     363                        for (x = 0; x < xres; x++)
     364                                rgb_conv(&fb_addr[FB_POS(x, y)],
     365                                    (x < LOGO_WIDTH) ? fb_logo[y * LOGO_WIDTH + x] : LOGO_COLOR);
     366                }
     367        }
     368       
    328369        unsigned int row;
    329370       
    330         for (row = 0; row < rows; row++) {
    331                 unsigned int y = ROW2Y(row);
     371        for (row = 0; row < rowtrim; row++) {
     372                unsigned int y = ylogo + ROW2Y(row);
    332373                unsigned int yd;
    333374               
     
    345386        if (COL2X(cols) < xres) {
    346387                unsigned int y;
     388                unsigned int size = (xres - COL2X(cols)) * pixelbytes;
    347389               
    348                 for (y = 0; y < yres; y++) {
    349                         unsigned int x;
    350                        
    351                         for (x = COL2X(cols); x < xres; x++)
    352                                 memcpy(&fb_addr[FB_POS(x, y)], bgpixel, pixelbytes);
    353                 }
    354         }
    355        
    356         if (ROW2Y(rows) < yres) {
     390                for (y = ylogo; y < yres; y++)
     391                        memcpy(&fb_addr[FB_POS(COL2X(cols), y)], bgscan, size);
     392        }
     393       
     394        if (ROW2Y(rowtrim) < yres) {
    357395                unsigned int y;
    358396               
    359                 for (y = ROW2Y(rows); y < yres; y++) {
    360                         unsigned int x;
    361                        
    362                         for (x = 0; x < xres; x++)
    363                                 memcpy(&fb_addr[FB_POS(x, y)], bgpixel, pixelbytes);
    364                 }
     397                for (y = ROW2Y(rowtrim); y < yres; y++)
     398                        memcpy(&fb_addr[FB_POS(0, y)], bgscan, bgscanbytes);
    365399        }
    366400}
     
    415449        scanline = props->scan;
    416450       
    417         cols = xres / FONT_WIDTH;
    418         rows = yres / FONT_SCANLINES;
     451        cols = X2COL(xres);
     452        rows = Y2ROW(yres);
     453       
     454        if (yres > ylogo) {
     455                ylogo = LOGO_HEIGHT;
     456                rowtrim = rows - Y2ROW(ylogo);
     457                if (ylogo % FONT_SCANLINES > 0)
     458                        rowtrim--;
     459                ytrim = ROW2Y(rowtrim);
     460        } else {
     461                ylogo = 0;
     462                ytrim = yres;
     463                rowtrim = rows;
     464        }
    419465       
    420466        glyphscanline = FONT_WIDTH * pixelbytes;
    421         glyphbytes = glyphscanline * FONT_SCANLINES;
     467        glyphbytes = ROW2Y(glyphscanline);
     468        bgscanbytes = xres * pixelbytes;
    422469       
    423470        unsigned int fbsize = scanline * yres;
     
    433480                panic("Unable to allocate glyphs.\n");
    434481       
    435         bgpixel = malloc(pixelbytes, 0);
    436         if (!bgpixel)
     482        bgscan = malloc(bgscanbytes, 0);
     483        if (!bgscan)
    437484                panic("Unable to allocate background pixel.\n");
    438485       
    439486        memsetb(backbuf, bbsize, 0);
    440         memsetb(glyphs, glyphsize, 0);
    441         memsetb(bgpixel, pixelbytes, 0);
    442        
    443         render_glyphs();
     487       
     488        glyphs_render();
    444489       
    445490        fb_addr = (uint8_t *) hw_map((uintptr_t) props->addr, fbsize);
  • kernel/genarch/src/fb/font-8x16.c

    r882d7a8 r6e71a9d8  
    2727 */
    2828
    29 /** @addtogroup genarch 
     29/** @addtogroup genarch
    3030 * @{
    3131 */
  • kernel/generic/include/macros.h

    r882d7a8 r6e71a9d8  
    4646                            ((c) == '\r'))
    4747
    48 #define min(a,b)        ((a) < (b) ? (a) : (b))
    49 #define max(a,b)        ((a) > (b) ? (a) : (b))
     48#define min(a, b)       ((a) < (b) ? (a) : (b))
     49#define max(a, b)       ((a) > (b) ? (a) : (b))
    5050
    5151/** Return true if the intervals overlap.
  • uspace/srv/fb/fb.c

    r882d7a8 r6e71a9d8  
    180180{
    181181#if defined(FB_INVERT_ENDIAN)
    182         *((uint32_t *) dst)
    183             = (BLUE(rgb, 8) << 16) | (GREEN(rgb, 8) << 8) | RED(rgb, 8)
    184             | (*((uint32_t *) dst) & 0xff0000);
     182        ((uint8_t *) dst)[0] = RED(rgb, 8);
     183        ((uint8_t *) dst)[1] = GREEN(rgb, 8);
     184        ((uint8_t *) dst)[2] = BLUE(rgb, 8);
    185185#else
    186         *((uint32_t *) dst)
    187             = (rgb & 0xffffff) | (*((uint32_t *) dst) & 0xff0000);
     186        ((uint8_t *) dst)[0] = BLUE(rgb, 8);
     187        ((uint8_t *) dst)[1] = GREEN(rgb, 8);
     188        ((uint8_t *) dst)[2] = RED(rgb, 8);
    188189#endif
    189190}
Note: See TracChangeset for help on using the changeset viewer.