Changeset 6e71a9d8 in mainline
- Timestamp:
- 2008-12-16T21:25:16Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- feaa871
- Parents:
- 882d7a8
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/genarch/Makefile.inc
r882d7a8 r6e71a9d8 61 61 GENARCH_SOURCES += \ 62 62 genarch/src/fb/font-8x16.c \ 63 genarch/src/fb/logo-196x66.c \ 63 64 genarch/src/fb/fb.c 64 65 DEFS += -DCONFIG_FB -
kernel/genarch/src/fb/fb.c
r882d7a8 r6e71a9d8 35 35 36 36 #include <genarch/fb/font-8x16.h> 37 #include <genarch/fb/logo-196x66.h> 37 38 #include <genarch/fb/visuals.h> 38 39 #include <genarch/fb/fb.h> … … 58 59 static uint8_t *backbuf; 59 60 static uint8_t *glyphs; 60 61 static void *bgpixel; 61 static uint8_t *bgscan; 62 62 63 63 static unsigned int xres; 64 64 static unsigned int yres; 65 65 66 static unsigned int ylogo; 67 static unsigned int ytrim; 68 static unsigned int rowtrim; 69 66 70 static unsigned int scanline; 67 71 static unsigned int glyphscanline; … … 69 73 static unsigned int pixelbytes; 70 74 static unsigned int glyphbytes; 75 static unsigned int bgscanbytes; 71 76 72 77 static unsigned int cols; … … 122 127 { 123 128 #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); 127 132 #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); 130 136 #endif 131 137 } … … 176 182 177 183 184 /** Hide logo and refresh screen 185 * 186 */ 187 static void logo_hide(void) 188 { 189 ylogo = 0; 190 ytrim = yres; 191 rowtrim = rows; 192 fb_redraw(); 193 } 194 195 178 196 /** Draw character at given position 179 197 * 180 198 */ 181 static void draw_glyph(uint8_t glyph, unsigned int col, unsigned int row)199 static void glyph_draw(uint8_t glyph, unsigned int col, unsigned int row) 182 200 { 183 201 unsigned int x = COL2X(col); … … 185 203 unsigned int yd; 186 204 205 if (y >= ytrim) 206 logo_hide(); 207 187 208 backbuf[BB_POS(col, row)] = glyph; 188 209 189 210 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)], 191 212 &glyphs[GLYPH_POS(glyph, yd)], glyphscanline); 192 213 } … … 197 218 * 198 219 */ 199 static void scroll_screen(void) 200 { 220 static void screen_scroll(void) 221 { 222 if (ylogo > 0) 223 logo_hide(); 224 201 225 unsigned int row; 202 226 … … 233 257 static void cursor_put(void) 234 258 { 235 draw_glyph(CURSOR, position % cols, position / cols);259 glyph_draw(CURSOR, position % cols, position / cols); 236 260 } 237 261 … … 239 263 static void cursor_remove(void) 240 264 { 241 draw_glyph(0, position % cols, position / cols);265 glyph_draw(0, position % cols, position / cols); 242 266 } 243 267 … … 270 294 cursor_remove(); 271 295 do { 272 draw_glyph((uint8_t) ' ', position % cols, position / cols);296 glyph_draw((uint8_t) ' ', position % cols, position / cols); 273 297 position++; 274 298 } while ((position % 8) && (position < cols * rows)); 275 299 break; 276 300 default: 277 draw_glyph((uint8_t) ch, position % cols, position / cols);301 glyph_draw((uint8_t) ch, position % cols, position / cols); 278 302 position++; 279 303 } … … 281 305 if (position >= cols * rows) { 282 306 position -= cols; 283 scr oll_screen();307 screen_scroll(); 284 308 } 285 309 … … 301 325 * 302 326 */ 303 static void render_glyphs(void) 304 { 327 static void glyphs_render(void) 328 { 329 /* Prerender glyphs */ 305 330 unsigned int glyph; 306 331 … … 313 338 for (x = 0; x < FONT_WIDTH; x++) 314 339 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); 316 341 } 317 342 } 318 343 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); 320 349 } 321 350 … … 326 355 void fb_redraw(void) 327 356 { 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 328 369 unsigned int row; 329 370 330 for (row = 0; row < row s; row++) {331 unsigned int y = ROW2Y(row);371 for (row = 0; row < rowtrim; row++) { 372 unsigned int y = ylogo + ROW2Y(row); 332 373 unsigned int yd; 333 374 … … 345 386 if (COL2X(cols) < xres) { 346 387 unsigned int y; 388 unsigned int size = (xres - COL2X(cols)) * pixelbytes; 347 389 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) { 357 395 unsigned int y; 358 396 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); 365 399 } 366 400 } … … 415 449 scanline = props->scan; 416 450 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 } 419 465 420 466 glyphscanline = FONT_WIDTH * pixelbytes; 421 glyphbytes = glyphscanline * FONT_SCANLINES; 467 glyphbytes = ROW2Y(glyphscanline); 468 bgscanbytes = xres * pixelbytes; 422 469 423 470 unsigned int fbsize = scanline * yres; … … 433 480 panic("Unable to allocate glyphs.\n"); 434 481 435 bg pixel = malloc(pixelbytes, 0);436 if (!bg pixel)482 bgscan = malloc(bgscanbytes, 0); 483 if (!bgscan) 437 484 panic("Unable to allocate background pixel.\n"); 438 485 439 486 memsetb(backbuf, bbsize, 0); 440 memsetb(glyphs, glyphsize, 0); 441 memsetb(bgpixel, pixelbytes, 0); 442 443 render_glyphs(); 487 488 glyphs_render(); 444 489 445 490 fb_addr = (uint8_t *) hw_map((uintptr_t) props->addr, fbsize); -
kernel/genarch/src/fb/font-8x16.c
r882d7a8 r6e71a9d8 27 27 */ 28 28 29 /** @addtogroup genarch 29 /** @addtogroup genarch 30 30 * @{ 31 31 */ -
kernel/generic/include/macros.h
r882d7a8 r6e71a9d8 46 46 ((c) == '\r')) 47 47 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)) 50 50 51 51 /** Return true if the intervals overlap. -
uspace/srv/fb/fb.c
r882d7a8 r6e71a9d8 180 180 { 181 181 #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); 185 185 #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); 188 189 #endif 189 190 }
Note:
See TracChangeset
for help on using the changeset viewer.