Rev 4263 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4263 | Rev 4327 | ||
---|---|---|---|
Line 76... | Line 76... | ||
76 | #define MAX_VIEWPORTS 128 /**< Viewport is a rectangular area on the screen */ |
76 | #define MAX_VIEWPORTS 128 /**< Viewport is a rectangular area on the screen */ |
77 | 77 | ||
78 | /** Function to render a pixel from a RGB value. */ |
78 | /** Function to render a pixel from a RGB value. */ |
79 | typedef void (*rgb_conv_t)(void *, uint32_t); |
79 | typedef void (*rgb_conv_t)(void *, uint32_t); |
80 | 80 | ||
- | 81 | /** Function to render a bit mask. */ |
|
- | 82 | typedef void (*mask_conv_t)(void *, bool); |
|
- | 83 | ||
81 | /** Function to draw a glyph. */ |
84 | /** Function to draw a glyph. */ |
82 | typedef void (*dg_t)(unsigned int x, unsigned int y, bool cursor, |
85 | typedef void (*dg_t)(unsigned int x, unsigned int y, bool cursor, |
83 | uint8_t *glyphs, uint32_t glyph, uint32_t fg_color, uint32_t bg_color); |
86 | uint8_t *glyphs, uint32_t glyph, uint32_t fg_color, uint32_t bg_color); |
84 | 87 | ||
85 | struct { |
88 | struct { |
Line 96... | Line 99... | ||
96 | 99 | ||
97 | /** Pre-rendered mask for rendering glyphs. Specific for the visual. */ |
100 | /** Pre-rendered mask for rendering glyphs. Specific for the visual. */ |
98 | uint8_t *glyphs; |
101 | uint8_t *glyphs; |
99 | 102 | ||
100 | rgb_conv_t rgb_conv; |
103 | rgb_conv_t rgb_conv; |
- | 104 | mask_conv_t mask_conv; |
|
101 | } screen; |
105 | } screen; |
102 | 106 | ||
103 | /** Backbuffer character cell. */ |
107 | /** Backbuffer character cell. */ |
104 | typedef struct { |
108 | typedef struct { |
105 | uint32_t glyph; |
109 | uint32_t glyph; |
Line 224... | Line 228... | ||
224 | /** ARGB 8:8:8:8 conversion |
228 | /** ARGB 8:8:8:8 conversion |
225 | * |
229 | * |
226 | */ |
230 | */ |
227 | static void rgb_0888(void *dst, uint32_t rgb) |
231 | static void rgb_0888(void *dst, uint32_t rgb) |
228 | { |
232 | { |
229 | *((uint32_t *) dst) = rgb & 0xffffff; |
233 | *((uint32_t *) dst) = rgb & 0x00ffffff; |
- | 234 | } |
|
- | 235 | ||
- | 236 | static void mask_0888(void *dst, bool mask) |
|
- | 237 | { |
|
- | 238 | *((uint32_t *) dst) = (mask ? 0x00ffffff : 0); |
|
230 | } |
239 | } |
231 | 240 | ||
232 | 241 | ||
233 | /** ABGR 8:8:8:8 conversion |
242 | /** ABGR 8:8:8:8 conversion |
234 | * |
243 | * |
Line 248... | Line 257... | ||
248 | ((uint8_t *) dst)[0] = BLUE(rgb, 8); |
257 | ((uint8_t *) dst)[0] = BLUE(rgb, 8); |
249 | ((uint8_t *) dst)[1] = GREEN(rgb, 8); |
258 | ((uint8_t *) dst)[1] = GREEN(rgb, 8); |
250 | ((uint8_t *) dst)[2] = RED(rgb, 8); |
259 | ((uint8_t *) dst)[2] = RED(rgb, 8); |
251 | } |
260 | } |
252 | 261 | ||
- | 262 | static void mask_888(void *dst, bool mask) |
|
- | 263 | { |
|
- | 264 | if (mask) { |
|
- | 265 | ((uint8_t *) dst)[0] = 0xff; |
|
- | 266 | ((uint8_t *) dst)[1] = 0xff; |
|
- | 267 | ((uint8_t *) dst)[2] = 0xff; |
|
- | 268 | } else { |
|
- | 269 | ((uint8_t *) dst)[0] = 0; |
|
- | 270 | ((uint8_t *) dst)[1] = 0; |
|
- | 271 | ((uint8_t *) dst)[2] = 0; |
|
- | 272 | } |
|
- | 273 | } |
|
- | 274 | ||
253 | 275 | ||
254 | /** BGR 8:8:8 conversion |
276 | /** BGR 8:8:8 conversion |
255 | * |
277 | * |
256 | */ |
278 | */ |
257 | static void bgr_888(void *dst, uint32_t rgb) |
279 | static void bgr_888(void *dst, uint32_t rgb) |
Line 269... | Line 291... | ||
269 | { |
291 | { |
270 | *((uint16_t *) dst) |
292 | *((uint16_t *) dst) |
271 | = (RED(rgb, 5) << 10) | (GREEN(rgb, 5) << 5) | BLUE(rgb, 5); |
293 | = (RED(rgb, 5) << 10) | (GREEN(rgb, 5) << 5) | BLUE(rgb, 5); |
272 | } |
294 | } |
273 | 295 | ||
- | 296 | static void mask_555(void *dst, bool mask) |
|
- | 297 | { |
|
- | 298 | *((uint16_t *) dst) = (mask ? 0x7fff : 0); |
|
- | 299 | } |
|
- | 300 | ||
274 | 301 | ||
275 | /** RGB 5:6:5 conversion |
302 | /** RGB 5:6:5 conversion |
276 | * |
303 | * |
277 | */ |
304 | */ |
278 | static void rgb_565(void *dst, uint32_t rgb) |
305 | static void rgb_565(void *dst, uint32_t rgb) |
279 | { |
306 | { |
280 | *((uint16_t *) dst) |
307 | *((uint16_t *) dst) |
281 | = (RED(rgb, 5) << 11) | (GREEN(rgb, 6) << 5) | BLUE(rgb, 5); |
308 | = (RED(rgb, 5) << 11) | (GREEN(rgb, 6) << 5) | BLUE(rgb, 5); |
282 | } |
309 | } |
283 | 310 | ||
- | 311 | static void mask_565(void *dst, bool mask) |
|
- | 312 | { |
|
- | 313 | *((uint16_t *) dst) = (mask ? 0xffff : 0); |
|
- | 314 | } |
|
- | 315 | ||
284 | 316 | ||
285 | /** RGB 3:2:3 |
317 | /** RGB 3:2:3 |
286 | * |
318 | * |
287 | */ |
319 | */ |
288 | static void rgb_323(void *dst, uint32_t rgb) |
320 | static void rgb_323(void *dst, uint32_t rgb) |
289 | { |
321 | { |
290 | *((uint8_t *) dst) |
322 | *((uint8_t *) dst) |
291 | = ~((RED(rgb, 3) << 5) | (GREEN(rgb, 2) << 3) | BLUE(rgb, 3)); |
323 | = ~((RED(rgb, 3) << 5) | (GREEN(rgb, 2) << 3) | BLUE(rgb, 3)); |
292 | } |
324 | } |
293 | 325 | ||
- | 326 | static void mask_323(void *dst, bool mask) |
|
- | 327 | { |
|
- | 328 | *((uint8_t *) dst) = (mask ? 0xff : 0); |
|
- | 329 | } |
|
- | 330 | ||
294 | /** Draw a filled rectangle. |
331 | /** Draw a filled rectangle. |
295 | * |
332 | * |
296 | * @note Need real implementation that does not access VRAM twice. |
333 | * @note Need real implementation that does not access VRAM twice. |
- | 334 | * |
|
297 | */ |
335 | */ |
298 | static void draw_filled_rect(unsigned int x0, unsigned int y0, unsigned int x1, |
336 | static void draw_filled_rect(unsigned int x0, unsigned int y0, unsigned int x1, |
299 | unsigned int y1, uint32_t color) |
337 | unsigned int y1, uint32_t color) |
300 | { |
338 | { |
- | 339 | unsigned int x; |
|
301 | unsigned int x, y; |
340 | unsigned int y; |
302 | unsigned int copy_bytes; |
341 | unsigned int copy_bytes; |
303 | 342 | ||
- | 343 | uint8_t *sp; |
|
304 | uint8_t *sp, *dp; |
344 | uint8_t *dp; |
305 | uint8_t cbuf[4]; |
345 | uint8_t cbuf[4]; |
306 | 346 | ||
307 | if (y0 >= y1 || x0 >= x1) return; |
347 | if ((y0 >= y1) || (x0 >= x1)) |
- | 348 | return; |
|
- | 349 | ||
308 | screen.rgb_conv(cbuf, color); |
350 | screen.rgb_conv(cbuf, color); |
309 | 351 | ||
310 | sp = &screen.fb_addr[FB_POS(x0, y0)]; |
352 | sp = &screen.fb_addr[FB_POS(x0, y0)]; |
311 | dp = sp; |
353 | dp = sp; |
312 | 354 | ||
Line 331... | Line 373... | ||
331 | * @param vport Viewport to redraw |
373 | * @param vport Viewport to redraw |
332 | * |
374 | * |
333 | */ |
375 | */ |
334 | static void vport_redraw(viewport_t *vport) |
376 | static void vport_redraw(viewport_t *vport) |
335 | { |
377 | { |
- | 378 | unsigned int row; |
|
336 | unsigned int row, col; |
379 | unsigned int col; |
337 | 380 | ||
338 | for (row = 0; row < vport->rows; row++) { |
381 | for (row = 0; row < vport->rows; row++) { |
339 | for (col = 0; col < vport->cols; col++) { |
382 | for (col = 0; col < vport->cols; col++) { |
340 | draw_vp_glyph(vport, false, col, row); |
383 | draw_vp_glyph(vport, false, col, row); |
341 | } |
384 | } |
Line 357... | Line 400... | ||
357 | } |
400 | } |
358 | 401 | ||
359 | static void backbuf_clear(bb_cell_t *backbuf, size_t len, uint32_t fg_color, |
402 | static void backbuf_clear(bb_cell_t *backbuf, size_t len, uint32_t fg_color, |
360 | uint32_t bg_color) |
403 | uint32_t bg_color) |
361 | { |
404 | { |
362 | unsigned i; |
405 | size_t i; |
363 | 406 | ||
364 | for (i = 0; i < len; i++) { |
407 | for (i = 0; i < len; i++) { |
365 | backbuf[i].glyph = 0; |
408 | backbuf[i].glyph = 0; |
366 | backbuf[i].fg_color = fg_color; |
409 | backbuf[i].fg_color = fg_color; |
367 | backbuf[i].bg_color = bg_color; |
410 | backbuf[i].bg_color = bg_color; |
Line 386... | Line 429... | ||
386 | * @param lines Number of lines to scroll |
429 | * @param lines Number of lines to scroll |
387 | * |
430 | * |
388 | */ |
431 | */ |
389 | static void vport_scroll(viewport_t *vport, int lines) |
432 | static void vport_scroll(viewport_t *vport, int lines) |
390 | { |
433 | { |
- | 434 | unsigned int row; |
|
391 | unsigned int row, col; |
435 | unsigned int col; |
- | 436 | unsigned int x; |
|
392 | unsigned int x, y; |
437 | unsigned int y; |
393 | uint32_t glyph; |
438 | uint32_t glyph; |
394 | uint32_t fg_color; |
439 | uint32_t fg_color; |
395 | uint32_t bg_color; |
440 | uint32_t bg_color; |
- | 441 | bb_cell_t *bbp; |
|
396 | bb_cell_t *bbp, *xbp; |
442 | bb_cell_t *xbp; |
397 | 443 | ||
398 | /* |
444 | /* |
399 | * Redraw. |
445 | * Redraw. |
400 | */ |
446 | */ |
401 | 447 | ||
Line 409... | Line 455... | ||
409 | 455 | ||
410 | glyph = xbp->glyph; |
456 | glyph = xbp->glyph; |
411 | fg_color = xbp->fg_color; |
457 | fg_color = xbp->fg_color; |
412 | bg_color = xbp->bg_color; |
458 | bg_color = xbp->bg_color; |
413 | 459 | ||
414 | if (bbp->glyph == glyph && |
460 | if ((bbp->glyph == glyph) |
415 | bbp->fg_color == xbp->fg_color && |
461 | && (bbp->fg_color == xbp->fg_color) |
416 | bbp->bg_color == xbp->bg_color) { |
462 | && (bbp->bg_color == xbp->bg_color)) { |
417 | x += FONT_WIDTH; |
463 | x += FONT_WIDTH; |
418 | continue; |
464 | continue; |
419 | } |
465 | } |
420 | } else { |
466 | } else { |
421 | glyph = 0; |
467 | glyph = 0; |
Line 449... | Line 495... | ||
449 | 495 | ||
450 | /** Render glyphs |
496 | /** Render glyphs |
451 | * |
497 | * |
452 | * Convert glyphs from device independent font |
498 | * Convert glyphs from device independent font |
453 | * description to current visual representation. |
499 | * description to current visual representation. |
- | 500 | * |
|
454 | */ |
501 | */ |
455 | static void render_glyphs(void) |
502 | static void render_glyphs(void) |
456 | { |
503 | { |
457 | unsigned int glyph; |
504 | unsigned int glyph; |
458 | 505 | ||
Line 461... | Line 508... | ||
461 | 508 | ||
462 | for (y = 0; y < FONT_SCANLINES; y++) { |
509 | for (y = 0; y < FONT_SCANLINES; y++) { |
463 | unsigned int x; |
510 | unsigned int x; |
464 | 511 | ||
465 | for (x = 0; x < FONT_WIDTH; x++) { |
512 | for (x = 0; x < FONT_WIDTH; x++) { |
466 | screen.rgb_conv(&screen.glyphs[GLYPH_POS(glyph, y, false) + x * screen.pixelbytes], |
513 | screen.mask_conv(&screen.glyphs[GLYPH_POS(glyph, y, false) + x * screen.pixelbytes], |
467 | (fb_font[glyph][y] & (1 << (7 - x))) |
514 | (fb_font[glyph][y] & (1 << (7 - x))) ? true : false); |
468 | ? 0xffffff : 0x000000); |
- | |
469 | 515 | ||
470 | screen.rgb_conv(&screen.glyphs[GLYPH_POS(glyph, y, true) + x * screen.pixelbytes], |
516 | screen.mask_conv(&screen.glyphs[GLYPH_POS(glyph, y, true) + x * screen.pixelbytes], |
471 | (fb_font[glyph][y] & (1 << (7 - x))) |
517 | (fb_font[glyph][y] & (1 << (7 - x))) ? false : true); |
472 | ? 0x000000 : 0xffffff); |
- | |
473 | } |
518 | } |
474 | } |
519 | } |
475 | } |
520 | } |
476 | } |
521 | } |
477 | 522 | ||
478 | - | ||
479 | /** Create new viewport |
523 | /** Create new viewport |
480 | * |
524 | * |
481 | * @param x Origin of the viewport (x). |
525 | * @param x Origin of the viewport (x). |
482 | * @param y Origin of the viewport (y). |
526 | * @param y Origin of the viewport (y). |
483 | * @param width Width of the viewport. |
527 | * @param width Width of the viewport. |
Line 493... | Line 537... | ||
493 | 537 | ||
494 | for (i = 0; i < MAX_VIEWPORTS; i++) { |
538 | for (i = 0; i < MAX_VIEWPORTS; i++) { |
495 | if (!viewports[i].initialized) |
539 | if (!viewports[i].initialized) |
496 | break; |
540 | break; |
497 | } |
541 | } |
- | 542 | ||
498 | if (i == MAX_VIEWPORTS) |
543 | if (i == MAX_VIEWPORTS) |
499 | return ELIMIT; |
544 | return ELIMIT; |
500 | 545 | ||
501 | unsigned int cols = width / FONT_WIDTH; |
546 | unsigned int cols = width / FONT_WIDTH; |
502 | unsigned int rows = height / FONT_SCANLINES; |
547 | unsigned int rows = height / FONT_SCANLINES; |
Line 529... | Line 574... | ||
529 | 574 | ||
530 | viewports[i].bgpixel = bgpixel; |
575 | viewports[i].bgpixel = bgpixel; |
531 | 576 | ||
532 | /* |
577 | /* |
533 | * Conditions necessary to select aligned version: |
578 | * Conditions necessary to select aligned version: |
534 | * |
- | |
535 | * - word size is divisible by pixelbytes |
579 | * - word size is divisible by pixelbytes |
536 | * - cell scanline size is divisible by word size |
580 | * - cell scanline size is divisible by word size |
537 | * - cell scanlines are word-aligned |
581 | * - cell scanlines are word-aligned |
- | 582 | * |
|
538 | */ |
583 | */ |
539 | if ((word_size % screen.pixelbytes) == 0 && |
584 | if (((word_size % screen.pixelbytes) == 0) |
540 | (FONT_WIDTH * screen.pixelbytes) % word_size == 0 && |
585 | && ((FONT_WIDTH * screen.pixelbytes) % word_size == 0) |
541 | (x * screen.pixelbytes) % word_size == 0 && |
586 | && ((x * screen.pixelbytes) % word_size == 0) |
542 | screen.scanline % word_size == 0) { |
587 | && (screen.scanline % word_size == 0)) { |
543 | - | ||
544 | viewports[i].dglyph = draw_glyph_aligned; |
588 | viewports[i].dglyph = draw_glyph_aligned; |
545 | } else { |
589 | } else { |
546 | viewports[i].dglyph = draw_glyph_fallback; |
590 | viewports[i].dglyph = draw_glyph_fallback; |
547 | } |
591 | } |
548 | 592 | ||
Line 572... | Line 616... | ||
572 | * |
616 | * |
573 | */ |
617 | */ |
574 | static bool screen_init(void *addr, unsigned int xres, unsigned int yres, |
618 | static bool screen_init(void *addr, unsigned int xres, unsigned int yres, |
575 | unsigned int scan, unsigned int visual) |
619 | unsigned int scan, unsigned int visual) |
576 | { |
620 | { |
577 | unsigned int glyphsize; |
621 | |
578 | uint8_t *glyphs; |
622 | |
579 | switch (visual) { |
623 | switch (visual) { |
580 | case VISUAL_INDIRECT_8: |
624 | case VISUAL_INDIRECT_8: |
581 | screen.rgb_conv = rgb_323; |
625 | screen.rgb_conv = rgb_323; |
- | 626 | screen.mask_conv = mask_323; |
|
582 | screen.pixelbytes = 1; |
627 | screen.pixelbytes = 1; |
583 | break; |
628 | break; |
584 | case VISUAL_RGB_5_5_5: |
629 | case VISUAL_RGB_5_5_5: |
585 | screen.rgb_conv = rgb_555; |
630 | screen.rgb_conv = rgb_555; |
- | 631 | screen.mask_conv = mask_555; |
|
586 | screen.pixelbytes = 2; |
632 | screen.pixelbytes = 2; |
587 | break; |
633 | break; |
588 | case VISUAL_RGB_5_6_5: |
634 | case VISUAL_RGB_5_6_5: |
589 | screen.rgb_conv = rgb_565; |
635 | screen.rgb_conv = rgb_565; |
- | 636 | screen.mask_conv = mask_565; |
|
590 | screen.pixelbytes = 2; |
637 | screen.pixelbytes = 2; |
591 | break; |
638 | break; |
592 | case VISUAL_RGB_8_8_8: |
639 | case VISUAL_RGB_8_8_8: |
593 | screen.rgb_conv = rgb_888; |
640 | screen.rgb_conv = rgb_888; |
- | 641 | screen.mask_conv = mask_888; |
|
594 | screen.pixelbytes = 3; |
642 | screen.pixelbytes = 3; |
595 | break; |
643 | break; |
596 | case VISUAL_BGR_8_8_8: |
644 | case VISUAL_BGR_8_8_8: |
597 | screen.rgb_conv = bgr_888; |
645 | screen.rgb_conv = bgr_888; |
- | 646 | screen.mask_conv = mask_888; |
|
598 | screen.pixelbytes = 3; |
647 | screen.pixelbytes = 3; |
599 | break; |
648 | break; |
600 | case VISUAL_RGB_8_8_8_0: |
649 | case VISUAL_RGB_8_8_8_0: |
601 | screen.rgb_conv = rgb_888; |
650 | screen.rgb_conv = rgb_888; |
- | 651 | screen.mask_conv = mask_888; |
|
602 | screen.pixelbytes = 4; |
652 | screen.pixelbytes = 4; |
603 | break; |
653 | break; |
604 | case VISUAL_RGB_0_8_8_8: |
654 | case VISUAL_RGB_0_8_8_8: |
605 | screen.rgb_conv = rgb_0888; |
655 | screen.rgb_conv = rgb_0888; |
- | 656 | screen.mask_conv = mask_0888; |
|
606 | screen.pixelbytes = 4; |
657 | screen.pixelbytes = 4; |
607 | break; |
658 | break; |
608 | case VISUAL_BGR_0_8_8_8: |
659 | case VISUAL_BGR_0_8_8_8: |
609 | screen.rgb_conv = bgr_0888; |
660 | screen.rgb_conv = bgr_0888; |
- | 661 | screen.mask_conv = mask_0888; |
|
610 | screen.pixelbytes = 4; |
662 | screen.pixelbytes = 4; |
611 | break; |
663 | break; |
612 | default: |
664 | default: |
613 | return false; |
665 | return false; |
614 | } |
666 | } |
Line 619... | Line 671... | ||
619 | screen.scanline = scan; |
671 | screen.scanline = scan; |
620 | 672 | ||
621 | screen.glyphscanline = FONT_WIDTH * screen.pixelbytes; |
673 | screen.glyphscanline = FONT_WIDTH * screen.pixelbytes; |
622 | screen.glyphbytes = screen.glyphscanline * FONT_SCANLINES; |
674 | screen.glyphbytes = screen.glyphscanline * FONT_SCANLINES; |
623 | 675 | ||
624 | glyphsize = 2 * FONT_GLYPHS * screen.glyphbytes; |
676 | size_t glyphsize = 2 * FONT_GLYPHS * screen.glyphbytes; |
625 | glyphs = (uint8_t *) malloc(glyphsize); |
677 | uint8_t *glyphs = (uint8_t *) malloc(glyphsize); |
626 | if (!glyphs) |
678 | if (!glyphs) |
627 | return false; |
679 | return false; |
628 | 680 | ||
629 | memset(glyphs, 0, glyphsize); |
681 | memset(glyphs, 0, glyphsize); |
630 | screen.glyphs = glyphs; |
682 | screen.glyphs = glyphs; |
Line 656... | Line 708... | ||
656 | * @param cursor Draw glyph with cursor |
708 | * @param cursor Draw glyph with cursor |
657 | * @param glyphs Pointer to font bitmap. |
709 | * @param glyphs Pointer to font bitmap. |
658 | * @param glyph Code of the glyph to draw. |
710 | * @param glyph Code of the glyph to draw. |
659 | * @param fg_color Foreground color. |
711 | * @param fg_color Foreground color. |
660 | * @param bg_color Backgroudn color. |
712 | * @param bg_color Backgroudn color. |
- | 713 | * |
|
661 | */ |
714 | */ |
662 | static void draw_glyph_aligned(unsigned int x, unsigned int y, bool cursor, |
715 | static void draw_glyph_aligned(unsigned int x, unsigned int y, bool cursor, |
663 | uint8_t *glyphs, uint32_t glyph, uint32_t fg_color, uint32_t bg_color) |
716 | uint8_t *glyphs, uint32_t glyph, uint32_t fg_color, uint32_t bg_color) |
664 | { |
717 | { |
- | 718 | unsigned int i; |
|
665 | unsigned int i, yd; |
719 | unsigned int yd; |
666 | unsigned long fg_buf, bg_buf; |
720 | unsigned long fg_buf; |
667 | unsigned long *maskp, *dp; |
721 | unsigned long bg_buf; |
668 | unsigned long mask; |
722 | unsigned long mask; |
669 | unsigned int ww, d_add; |
- | |
670 | 723 | ||
671 | /* |
724 | /* |
672 | * Prepare a pair of words, one filled with foreground-color |
725 | * Prepare a pair of words, one filled with foreground-color |
673 | * pattern and the other filled with background-color pattern. |
726 | * pattern and the other filled with background-color pattern. |
674 | */ |
727 | */ |
Line 678... | Line 731... | ||
678 | screen.rgb_conv(&((uint8_t *)&bg_buf)[i * screen.pixelbytes], |
731 | screen.rgb_conv(&((uint8_t *) &bg_buf)[i * screen.pixelbytes], |
679 | bg_color); |
732 | bg_color); |
680 | } |
733 | } |
681 | 734 | ||
682 | /* Pointer to the current position in the mask. */ |
735 | /* Pointer to the current position in the mask. */ |
683 | maskp = (unsigned long *) &glyphs[GLYPH_POS(glyph, 0, cursor)]; |
736 | unsigned long *maskp = (unsigned long *) &glyphs[GLYPH_POS(glyph, 0, cursor)]; |
684 | 737 | ||
685 | /* Pointer to the current position on the screen. */ |
738 | /* Pointer to the current position on the screen. */ |
686 | dp = (unsigned long *) &screen.fb_addr[FB_POS(x, y)]; |
739 | unsigned long *dp = (unsigned long *) &screen.fb_addr[FB_POS(x, y)]; |
687 | 740 | ||
688 | /* Width of the character cell in words. */ |
741 | /* Width of the character cell in words. */ |
689 | ww = FONT_WIDTH * screen.pixelbytes / sizeof(unsigned long); |
742 | unsigned int ww = FONT_WIDTH * screen.pixelbytes / sizeof(unsigned long); |
690 | 743 | ||
691 | /* Offset to add when moving to another screen scanline. */ |
744 | /* Offset to add when moving to another screen scanline. */ |
692 | d_add = screen.scanline - FONT_WIDTH * screen.pixelbytes; |
745 | unsigned int d_add = screen.scanline - FONT_WIDTH * screen.pixelbytes; |
693 | 746 | ||
694 | for (yd = 0; yd < FONT_SCANLINES; yd++) { |
747 | for (yd = 0; yd < FONT_SCANLINES; yd++) { |
695 | /* |
748 | /* |
696 | * Now process the cell scanline, combining foreground |
749 | * Now process the cell scanline, combining foreground |
697 | * and background color patters using the pre-rendered mask. |
750 | * and background color patters using the pre-rendered mask. |
Line 716... | Line 769... | ||
716 | * @param cursor Draw glyph with cursor |
769 | * @param cursor Draw glyph with cursor |
717 | * @param glyphs Pointer to font bitmap. |
770 | * @param glyphs Pointer to font bitmap. |
718 | * @param glyph Code of the glyph to draw. |
771 | * @param glyph Code of the glyph to draw. |
719 | * @param fg_color Foreground color. |
772 | * @param fg_color Foreground color. |
720 | * @param bg_color Backgroudn color. |
773 | * @param bg_color Backgroudn color. |
- | 774 | * |
|
721 | */ |
775 | */ |
722 | void draw_glyph_fallback(unsigned int x, unsigned int y, bool cursor, |
776 | void draw_glyph_fallback(unsigned int x, unsigned int y, bool cursor, |
723 | uint8_t *glyphs, uint32_t glyph, uint32_t fg_color, uint32_t bg_color) |
777 | uint8_t *glyphs, uint32_t glyph, uint32_t fg_color, uint32_t bg_color) |
724 | { |
778 | { |
- | 779 | unsigned int i; |
|
- | 780 | unsigned int j; |
|
725 | unsigned int i, j, yd; |
781 | unsigned int yd; |
726 | uint8_t fg_buf[4], bg_buf[4]; |
782 | uint8_t fg_buf[4]; |
727 | uint8_t *dp, *sp; |
783 | uint8_t bg_buf[4]; |
728 | unsigned int d_add; |
784 | uint8_t *sp; |
729 | uint8_t b; |
785 | uint8_t b; |
730 | 786 | ||
731 | /* Pre-render 1x the foreground and background color pixels. */ |
787 | /* Pre-render 1x the foreground and background color pixels. */ |
732 | if (cursor) { |
788 | if (cursor) { |
733 | screen.rgb_conv(fg_buf, bg_color); |
789 | screen.rgb_conv(fg_buf, bg_color); |
Line 736... | Line 792... | ||
736 | screen.rgb_conv(fg_buf, fg_color); |
792 | screen.rgb_conv(fg_buf, fg_color); |
737 | screen.rgb_conv(bg_buf, bg_color); |
793 | screen.rgb_conv(bg_buf, bg_color); |
738 | } |
794 | } |
739 | 795 | ||
740 | /* Pointer to the current position on the screen. */ |
796 | /* Pointer to the current position on the screen. */ |
741 | dp = (uint8_t *) &screen.fb_addr[FB_POS(x, y)]; |
797 | uint8_t *dp = (uint8_t *) &screen.fb_addr[FB_POS(x, y)]; |
742 | 798 | ||
743 | /* Offset to add when moving to another screen scanline. */ |
799 | /* Offset to add when moving to another screen scanline. */ |
744 | d_add = screen.scanline - FONT_WIDTH * screen.pixelbytes; |
800 | unsigned int d_add = screen.scanline - FONT_WIDTH * screen.pixelbytes; |
745 | 801 | ||
746 | for (yd = 0; yd < FONT_SCANLINES; yd++) { |
802 | for (yd = 0; yd < FONT_SCANLINES; yd++) { |
747 | /* Byte containing bits of the glyph scanline. */ |
803 | /* Byte containing bits of the glyph scanline. */ |
748 | b = fb_font[glyph][yd]; |
804 | b = fb_font[glyph][yd]; |
749 | 805 | ||
Line 777... | Line 833... | ||
777 | unsigned int row) |
833 | unsigned int row) |
778 | { |
834 | { |
779 | unsigned int x = vport->x + COL2X(col); |
835 | unsigned int x = vport->x + COL2X(col); |
780 | unsigned int y = vport->y + ROW2Y(row); |
836 | unsigned int y = vport->y + ROW2Y(row); |
781 | 837 | ||
782 | uint32_t glyph; |
- | |
783 | uint32_t fg_color; |
- | |
784 | uint32_t bg_color; |
- | |
785 | - | ||
786 | glyph = vport->backbuf[BB_POS(vport, col, row)].glyph; |
838 | uint32_t glyph = vport->backbuf[BB_POS(vport, col, row)].glyph; |
787 | fg_color = vport->backbuf[BB_POS(vport, col, row)].fg_color; |
839 | uint32_t fg_color = vport->backbuf[BB_POS(vport, col, row)].fg_color; |
788 | bg_color = vport->backbuf[BB_POS(vport, col, row)].bg_color; |
840 | uint32_t bg_color = vport->backbuf[BB_POS(vport, col, row)].bg_color; |
789 | 841 | ||
790 | (*vport->dglyph)(x, y, cursor, screen.glyphs, glyph, |
842 | (*vport->dglyph)(x, y, cursor, screen.glyphs, glyph, |
791 | fg_color, bg_color); |
843 | fg_color, bg_color); |
792 | } |
844 | } |
793 | 845 | ||
Line 872... | Line 924... | ||
872 | * @param data Text data. |
924 | * @param data Text data. |
873 | * @param x Leftmost column of the area. |
925 | * @param x Leftmost column of the area. |
874 | * @param y Topmost row of the area. |
926 | * @param y Topmost row of the area. |
875 | * @param w Number of rows. |
927 | * @param w Number of rows. |
876 | * @param h Number of columns. |
928 | * @param h Number of columns. |
- | 929 | * |
|
877 | */ |
930 | */ |
878 | static void draw_text_data(viewport_t *vport, keyfield_t *data, unsigned int x, |
931 | static void draw_text_data(viewport_t *vport, keyfield_t *data, unsigned int x, |
879 | unsigned int y, unsigned int w, unsigned int h) |
932 | unsigned int y, unsigned int w, unsigned int h) |
880 | { |
933 | { |
- | 934 | unsigned int i; |
|
881 | unsigned int i, j; |
935 | unsigned int j; |
882 | bb_cell_t *bbp; |
936 | bb_cell_t *bbp; |
883 | attrs_t *a; |
937 | attrs_t *a; |
884 | attr_rgb_t rgb; |
938 | attr_rgb_t rgb; |
885 | 939 | ||
886 | for (j = 0; j < h; j++) { |
940 | for (j = 0; j < h; j++) { |
Line 1657... | Line 1711... | ||
1657 | case FB_POINTER_MOVE: |
1711 | case FB_POINTER_MOVE: |
1658 | pointer_enabled = true; |
1712 | pointer_enabled = true; |
1659 | mouse_move(IPC_GET_ARG1(call), IPC_GET_ARG2(call)); |
1713 | mouse_move(IPC_GET_ARG1(call), IPC_GET_ARG2(call)); |
1660 | retval = EOK; |
1714 | retval = EOK; |
1661 | break; |
1715 | break; |
- | 1716 | case FB_SCREEN_YIELD: |
|
- | 1717 | case FB_SCREEN_RECLAIM: |
|
- | 1718 | retval = EOK; |
|
- | 1719 | break; |
|
1662 | default: |
1720 | default: |
1663 | retval = ENOENT; |
1721 | retval = ENOENT; |
1664 | } |
1722 | } |
1665 | ipc_answer_0(callid, retval); |
1723 | ipc_answer_0(callid, retval); |
1666 | } |
1724 | } |