diff options
author | Jens Arnold <amiconn@rockbox.org> | 2008-01-13 18:39:09 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2008-01-13 18:39:09 +0000 |
commit | fa7eb56c84f2e338ed5ff62dfb79e6bf513ddcdb (patch) | |
tree | acbb1d90194a63e32fff0baade56c6985ba12ac5 /apps | |
parent | 071c2ac339b4b10610f083b9d0ca253d99d3efb2 (diff) | |
download | rockbox-fa7eb56c84f2e338ed5ff62dfb79e6bf513ddcdb.tar.gz rockbox-fa7eb56c84f2e338ed5ff62dfb79e6bf513ddcdb.zip |
Greyscale library: * Defer application of lcd linearisation + gamma in buffered mode to the actual update. This simplifies the update function (grey_update() and grey_update_rect() now are just calls to grey_ub_gray_bitmap_part()), and makes DRMODE_COMPLEMENT work properly. * Make the simulator version work and behave more similar to the target version.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16080 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/plugins/lib/grey.h | 4 | ||||
-rw-r--r-- | apps/plugins/lib/grey_core.c | 133 | ||||
-rw-r--r-- | apps/plugins/lib/grey_draw.c | 78 | ||||
-rw-r--r-- | apps/plugins/lib/grey_parm.c | 6 | ||||
-rw-r--r-- | apps/plugins/lib/grey_scroll.c | 80 |
5 files changed, 95 insertions, 206 deletions
diff --git a/apps/plugins/lib/grey.h b/apps/plugins/lib/grey.h index 84b6687de3..4fc47e1886 100644 --- a/apps/plugins/lib/grey.h +++ b/apps/plugins/lib/grey.h | |||
@@ -155,14 +155,10 @@ struct _grey_info | |||
155 | #endif | 155 | #endif |
156 | unsigned long flags; /* various flags, see #defines */ | 156 | unsigned long flags; /* various flags, see #defines */ |
157 | struct plugin_api *rb; /* plugin API pointer */ | 157 | struct plugin_api *rb; /* plugin API pointer */ |
158 | #ifndef SIMULATOR | ||
159 | unsigned char *values; /* start of greyscale pixel values */ | 158 | unsigned char *values; /* start of greyscale pixel values */ |
160 | unsigned char *phases; /* start of greyscale pixel phases */ | 159 | unsigned char *phases; /* start of greyscale pixel phases */ |
161 | #endif | ||
162 | unsigned char *buffer; /* start of chunky pixel buffer (for buffered mode) */ | 160 | unsigned char *buffer; /* start of chunky pixel buffer (for buffered mode) */ |
163 | unsigned char gvalue[256]; /* calculated brightness -> greyvalue table */ | 161 | unsigned char gvalue[256]; /* calculated brightness -> greyvalue table */ |
164 | int fg_val; /* current foreground value */ | ||
165 | int bg_val; /* current background value */ | ||
166 | int fg_brightness; /* current foreground brightness */ | 162 | int fg_brightness; /* current foreground brightness */ |
167 | int bg_brightness; /* current background brightness */ | 163 | int bg_brightness; /* current background brightness */ |
168 | int drawmode; /* current draw mode */ | 164 | int drawmode; /* current draw mode */ |
diff --git a/apps/plugins/lib/grey_core.c b/apps/plugins/lib/grey_core.c index 395a1130d5..0e2408b107 100644 --- a/apps/plugins/lib/grey_core.c +++ b/apps/plugins/lib/grey_core.c | |||
@@ -214,7 +214,27 @@ static inline void _deferred_update(void) | |||
214 | _grey_info.rb->lcd_update_rect(x2, y1, LCD_WIDTH - x2, y2 - y1); | 214 | _grey_info.rb->lcd_update_rect(x2, y1, LCD_WIDTH - x2, y2 - y1); |
215 | } | 215 | } |
216 | 216 | ||
217 | #ifndef SIMULATOR | 217 | #ifdef SIMULATOR |
218 | |||
219 | /* Callback function for grey_ub_gray_bitmap_part() to read a pixel from the | ||
220 | * greybuffer. Note that x and y are in LCD coordinates, not greybuffer | ||
221 | * coordinates! */ | ||
222 | static unsigned long _grey_get_pixel(int x, int y) | ||
223 | { | ||
224 | int xg = x - _grey_info.x; | ||
225 | int yg = y - _grey_info.y; | ||
226 | #if LCD_PIXELFORMAT == HORIZONTAL_PACKING | ||
227 | int idx = _grey_info.width * yg + xg; | ||
228 | #else | ||
229 | int idx = _grey_info.width * (yg & ~_GREY_BMASK) | ||
230 | + (xg << _GREY_BSHIFT) + (~yg & _GREY_BMASK); | ||
231 | #endif | ||
232 | |||
233 | return _grey_info.values[idx] + (1 << LCD_DEPTH); | ||
234 | } | ||
235 | |||
236 | #else /* !SIMULATOR */ | ||
237 | |||
218 | /* Timer interrupt handler: display next frame */ | 238 | /* Timer interrupt handler: display next frame */ |
219 | static void _timer_isr(void) | 239 | static void _timer_isr(void) |
220 | { | 240 | { |
@@ -236,6 +256,7 @@ static void _timer_isr(void) | |||
236 | _grey_info.flags &= ~_GREY_DEFERRED_UPDATE; /* clear request */ | 256 | _grey_info.flags &= ~_GREY_DEFERRED_UPDATE; /* clear request */ |
237 | } | 257 | } |
238 | } | 258 | } |
259 | |||
239 | #endif /* !SIMULATOR */ | 260 | #endif /* !SIMULATOR */ |
240 | 261 | ||
241 | /* fixed point exp() */ | 262 | /* fixed point exp() */ |
@@ -357,22 +378,18 @@ bool grey_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size, | |||
357 | gbuf += plane_size; | 378 | gbuf += plane_size; |
358 | buftaken += plane_size; | 379 | buftaken += plane_size; |
359 | } | 380 | } |
360 | #ifdef SIMULATOR | ||
361 | _grey_info.buffer = gbuf; | ||
362 | #else | ||
363 | _grey_info.values = gbuf; | 381 | _grey_info.values = gbuf; |
364 | gbuf += plane_size; | 382 | gbuf += plane_size; |
365 | _grey_info.phases = gbuf; | 383 | _grey_info.phases = gbuf; |
366 | #endif | ||
367 | buftaken += 2 * plane_size; | 384 | buftaken += 2 * plane_size; |
368 | 385 | ||
369 | if (buftaken > gbuf_size) | 386 | if (buftaken > gbuf_size) |
370 | return false; | 387 | return false; |
371 | 388 | ||
372 | #ifndef SIMULATOR | ||
373 | /* Init to white */ | 389 | /* Init to white */ |
374 | _grey_info.rb->memset(_grey_info.values, 0x80, plane_size); | 390 | _grey_info.rb->memset(_grey_info.values, 0x80, plane_size); |
375 | 391 | ||
392 | #ifndef SIMULATOR | ||
376 | /* Init phases with random bits */ | 393 | /* Init phases with random bits */ |
377 | dst = (unsigned*)(_grey_info.phases); | 394 | dst = (unsigned*)(_grey_info.phases); |
378 | end = (unsigned*)(_grey_info.phases + plane_size); | 395 | end = (unsigned*)(_grey_info.phases + plane_size); |
@@ -394,8 +411,6 @@ bool grey_init(struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size, | |||
394 | _grey_info.bheight = bdim; | 411 | _grey_info.bheight = bdim; |
395 | #endif | 412 | #endif |
396 | _grey_info.flags = 0; | 413 | _grey_info.flags = 0; |
397 | _grey_info.fg_val = 0; | ||
398 | _grey_info.bg_val = 128; | ||
399 | _grey_info.fg_brightness = 0; | 414 | _grey_info.fg_brightness = 0; |
400 | _grey_info.bg_brightness = 255; | 415 | _grey_info.bg_brightness = 255; |
401 | _grey_info.drawmode = DRMODE_SOLID; | 416 | _grey_info.drawmode = DRMODE_SOLID; |
@@ -442,7 +457,8 @@ void grey_show(bool enable) | |||
442 | _grey_info.flags |= _GREY_RUNNING; | 457 | _grey_info.flags |= _GREY_RUNNING; |
443 | #ifdef SIMULATOR | 458 | #ifdef SIMULATOR |
444 | _grey_info.rb->sim_lcd_ex_init(129, _grey_get_pixel); | 459 | _grey_info.rb->sim_lcd_ex_init(129, _grey_get_pixel); |
445 | grey_update(); | 460 | _grey_info.rb->sim_lcd_ex_update_rect(_grey_info.x, _grey_info.y, |
461 | _grey_info.width, _grey_info.height); | ||
446 | #else /* !SIMULATOR */ | 462 | #else /* !SIMULATOR */ |
447 | #ifdef NEED_BOOST | 463 | #ifdef NEED_BOOST |
448 | _grey_info.rb->cpu_boost(true); | 464 | _grey_info.rb->cpu_boost(true); |
@@ -484,91 +500,17 @@ void grey_show(bool enable) | |||
484 | } | 500 | } |
485 | } | 501 | } |
486 | 502 | ||
487 | #ifdef SIMULATOR | ||
488 | /* Callback function for grey_update_rect() to read a pixel from the greybuffer. | ||
489 | Note that x and y are in LCD coordinates, not greybuffer coordinates! */ | ||
490 | static unsigned long _grey_get_pixel(int x, int y) | ||
491 | { | ||
492 | return _grey_info.buffer[(y - _grey_info.y) * _grey_info.width | ||
493 | + x - _grey_info.x] + (1 << LCD_DEPTH); | ||
494 | } | ||
495 | |||
496 | /* Update a rectangular area of the greyscale overlay */ | ||
497 | void grey_update_rect(int x, int y, int width, int height) | ||
498 | { | ||
499 | if (x + width > _grey_info.width) | ||
500 | width = _grey_info.width - x; | ||
501 | if (y + height > _grey_info.height) | ||
502 | height = _grey_info.height - y; | ||
503 | |||
504 | x += _grey_info.x; | ||
505 | y += _grey_info.y; | ||
506 | |||
507 | if (x + width > LCD_WIDTH) | ||
508 | width = LCD_WIDTH - x; | ||
509 | if (y + height > LCD_HEIGHT) | ||
510 | height = LCD_HEIGHT - y; | ||
511 | |||
512 | _grey_info.rb->sim_lcd_ex_update_rect(x, y, width, height); | ||
513 | } | ||
514 | |||
515 | #else /* !SIMULATOR */ | ||
516 | |||
517 | void grey_update_rect(int x, int y, int width, int height) | 503 | void grey_update_rect(int x, int y, int width, int height) |
518 | { | 504 | { |
519 | unsigned char *src, *dst; | 505 | grey_ub_gray_bitmap_part(_grey_info.buffer, x, y, _grey_info.width, |
520 | 506 | x, y, width, height); | |
521 | if ((width <= 0) || (height <= 0)) | ||
522 | return; /* nothing to do */ | ||
523 | |||
524 | if (y + height > _grey_info.height) | ||
525 | height = _grey_info.height - y; | ||
526 | if (x + width > _grey_info.width) | ||
527 | width = _grey_info.width - x; | ||
528 | |||
529 | src = _grey_info.buffer + _GREY_MULUQ(_grey_info.width, y) + x; | ||
530 | |||
531 | #if LCD_PIXELFORMAT == HORIZONTAL_PACKING | ||
532 | dst = _grey_info.values + _GREY_MULUQ(_grey_info.width, y) + x; | ||
533 | |||
534 | do | ||
535 | { | ||
536 | _grey_info.rb->memcpy(dst, src, width); | ||
537 | dst += _grey_info.width; | ||
538 | src += _grey_info.width; | ||
539 | } | ||
540 | while (--height > 0); | ||
541 | |||
542 | #else /* LCD_PIXELFORMAT == VRTICAL_PACKING */ | ||
543 | do | ||
544 | { | ||
545 | unsigned char *src_row = src; | ||
546 | unsigned char *src_end = src + width; | ||
547 | |||
548 | dst = _grey_info.values | ||
549 | + _GREY_MULUQ(_grey_info.width, y & ~_GREY_BMASK) | ||
550 | + (x << _GREY_BSHIFT) + (~y & _GREY_BMASK); | ||
551 | do | ||
552 | { | ||
553 | *dst = *src_row++; | ||
554 | dst += _GREY_BSIZE; | ||
555 | } | ||
556 | while (src_row < src_end); | ||
557 | |||
558 | y++; | ||
559 | src += _grey_info.width; | ||
560 | } | ||
561 | while (--height > 0); | ||
562 | |||
563 | #endif /* LCD_PIXELFORMAT */ | ||
564 | } | 507 | } |
565 | 508 | ||
566 | #endif /* !SIMULATOR */ | ||
567 | |||
568 | /* Update the whole greyscale overlay */ | 509 | /* Update the whole greyscale overlay */ |
569 | void grey_update(void) | 510 | void grey_update(void) |
570 | { | 511 | { |
571 | grey_update_rect(0, 0, _grey_info.width, _grey_info.height); | 512 | grey_ub_gray_bitmap_part(_grey_info.buffer, 0, 0, _grey_info.width, |
513 | 0, 0, _grey_info.width, _grey_info.height); | ||
572 | } | 514 | } |
573 | 515 | ||
574 | /* Do an lcd_update() to show changes done by rb->lcd_xxx() functions | 516 | /* Do an lcd_update() to show changes done by rb->lcd_xxx() functions |
@@ -691,13 +633,8 @@ static void grey_screendump_hook(int fd) | |||
691 | if (((unsigned)gy < (unsigned)_grey_info.height) | 633 | if (((unsigned)gy < (unsigned)_grey_info.height) |
692 | && ((unsigned)gx < (unsigned)_grey_info.width)) | 634 | && ((unsigned)gx < (unsigned)_grey_info.width)) |
693 | { | 635 | { |
694 | #ifdef SIMULATOR | ||
695 | unsigned char *src = _grey_info.buffer | ||
696 | + _GREY_MULUQ(_grey_info.width, gy) + gx; | ||
697 | #else | ||
698 | unsigned char *src = _grey_info.values | 636 | unsigned char *src = _grey_info.values |
699 | + _GREY_MULUQ(_grey_info.width, gy) + gx; | 637 | + _GREY_MULUQ(_grey_info.width, gy) + gx; |
700 | #endif | ||
701 | for (i = 0; i < 4; i++) | 638 | for (i = 0; i < 4; i++) |
702 | linebuf[x + i] = BMP_FIXEDCOLORS + *src++; | 639 | linebuf[x + i] = BMP_FIXEDCOLORS + *src++; |
703 | } | 640 | } |
@@ -724,17 +661,11 @@ static void grey_screendump_hook(int fd) | |||
724 | if (((unsigned)gy < (unsigned)_grey_info.height) | 661 | if (((unsigned)gy < (unsigned)_grey_info.height) |
725 | && ((unsigned)gx < (unsigned)_grey_info.width)) | 662 | && ((unsigned)gx < (unsigned)_grey_info.width)) |
726 | { | 663 | { |
727 | #ifdef SIMULATOR | ||
728 | linebuf[x] = BMP_FIXEDCOLORS | ||
729 | + _grey_info.buffer[_GREY_MULUQ(_grey_info.width, | ||
730 | gy) + gx]; | ||
731 | #else | ||
732 | linebuf[x] = BMP_FIXEDCOLORS | 664 | linebuf[x] = BMP_FIXEDCOLORS |
733 | + _grey_info.values[_GREY_MULUQ(_grey_info.width, | 665 | + _grey_info.values[_GREY_MULUQ(_grey_info.width, |
734 | gy & ~_GREY_BMASK) | 666 | gy & ~_GREY_BMASK) |
735 | + (gx << _GREY_BSHIFT) | 667 | + (gx << _GREY_BSHIFT) |
736 | + (~gy & _GREY_BMASK)]; | 668 | + (~gy & _GREY_BMASK)]; |
737 | #endif | ||
738 | } | 669 | } |
739 | else | 670 | else |
740 | { | 671 | { |
@@ -753,17 +684,11 @@ static void grey_screendump_hook(int fd) | |||
753 | if (((unsigned)gy < (unsigned)_grey_info.height) | 684 | if (((unsigned)gy < (unsigned)_grey_info.height) |
754 | && ((unsigned)gx < (unsigned)_grey_info.width)) | 685 | && ((unsigned)gx < (unsigned)_grey_info.width)) |
755 | { | 686 | { |
756 | #ifdef SIMULATOR | ||
757 | linebuf[x] = BMP_FIXEDCOLORS | ||
758 | + _grey_info.buffer[_GREY_MULUQ(_grey_info.width, | ||
759 | gy) + gx]; | ||
760 | #else | ||
761 | linebuf[x] = BMP_FIXEDCOLORS | 687 | linebuf[x] = BMP_FIXEDCOLORS |
762 | + _grey_info.values[_GREY_MULUQ(_grey_info.width, | 688 | + _grey_info.values[_GREY_MULUQ(_grey_info.width, |
763 | gy & ~_GREY_BMASK) | 689 | gy & ~_GREY_BMASK) |
764 | + (gx << _GREY_BSHIFT) | 690 | + (gx << _GREY_BSHIFT) |
765 | + (~gy & _GREY_BMASK)]; | 691 | + (~gy & _GREY_BMASK)]; |
766 | #endif | ||
767 | } | 692 | } |
768 | else | 693 | else |
769 | { | 694 | { |
diff --git a/apps/plugins/lib/grey_draw.c b/apps/plugins/lib/grey_draw.c index 9b8acd4c37..335d6d1b20 100644 --- a/apps/plugins/lib/grey_draw.c +++ b/apps/plugins/lib/grey_draw.c | |||
@@ -30,17 +30,17 @@ | |||
30 | 30 | ||
31 | static void setpixel(unsigned char *address) | 31 | static void setpixel(unsigned char *address) |
32 | { | 32 | { |
33 | *address = _grey_info.fg_val; | 33 | *address = _grey_info.fg_brightness; |
34 | } | 34 | } |
35 | 35 | ||
36 | static void clearpixel(unsigned char *address) | 36 | static void clearpixel(unsigned char *address) |
37 | { | 37 | { |
38 | *address = _grey_info.bg_val; | 38 | *address = _grey_info.bg_brightness; |
39 | } | 39 | } |
40 | 40 | ||
41 | static void flippixel(unsigned char *address) | 41 | static void flippixel(unsigned char *address) |
42 | { | 42 | { |
43 | *address = 128 - *address; | 43 | *address = ~(*address); |
44 | } | 44 | } |
45 | 45 | ||
46 | static void nopixel(unsigned char *address) | 46 | static void nopixel(unsigned char *address) |
@@ -59,7 +59,7 @@ void (* const _grey_pixelfuncs[8])(unsigned char *address) = { | |||
59 | void grey_clear_display(void) | 59 | void grey_clear_display(void) |
60 | { | 60 | { |
61 | int value = (_grey_info.drawmode & DRMODE_INVERSEVID) ? | 61 | int value = (_grey_info.drawmode & DRMODE_INVERSEVID) ? |
62 | _grey_info.fg_val : _grey_info.bg_val; | 62 | _grey_info.fg_brightness : _grey_info.bg_brightness; |
63 | 63 | ||
64 | _grey_info.rb->memset(_grey_info.buffer, value, | 64 | _grey_info.rb->memset(_grey_info.buffer, value, |
65 | _GREY_MULUQ(_grey_info.width, _grey_info.height)); | 65 | _GREY_MULUQ(_grey_info.width, _grey_info.height)); |
@@ -179,7 +179,7 @@ void grey_hline(int x1, int x2, int y) | |||
179 | if (_grey_info.drawmode & DRMODE_BG) | 179 | if (_grey_info.drawmode & DRMODE_BG) |
180 | { | 180 | { |
181 | fillopt = true; | 181 | fillopt = true; |
182 | value = _grey_info.bg_val; | 182 | value = _grey_info.bg_brightness; |
183 | } | 183 | } |
184 | } | 184 | } |
185 | else | 185 | else |
@@ -187,7 +187,7 @@ void grey_hline(int x1, int x2, int y) | |||
187 | if (_grey_info.drawmode & DRMODE_FG) | 187 | if (_grey_info.drawmode & DRMODE_FG) |
188 | { | 188 | { |
189 | fillopt = true; | 189 | fillopt = true; |
190 | value = _grey_info.fg_val; | 190 | value = _grey_info.fg_brightness; |
191 | } | 191 | } |
192 | } | 192 | } |
193 | pfunc = _grey_pixelfuncs[_grey_info.drawmode]; | 193 | pfunc = _grey_pixelfuncs[_grey_info.drawmode]; |
@@ -361,7 +361,7 @@ void grey_fillrect(int x, int y, int width, int height) | |||
361 | if (_grey_info.drawmode & DRMODE_BG) | 361 | if (_grey_info.drawmode & DRMODE_BG) |
362 | { | 362 | { |
363 | fillopt = true; | 363 | fillopt = true; |
364 | value = _grey_info.bg_val; | 364 | value = _grey_info.bg_brightness; |
365 | } | 365 | } |
366 | } | 366 | } |
367 | else | 367 | else |
@@ -369,7 +369,7 @@ void grey_fillrect(int x, int y, int width, int height) | |||
369 | if (_grey_info.drawmode & DRMODE_FG) | 369 | if (_grey_info.drawmode & DRMODE_FG) |
370 | { | 370 | { |
371 | fillopt = true; | 371 | fillopt = true; |
372 | value = _grey_info.fg_val; | 372 | value = _grey_info.fg_brightness; |
373 | } | 373 | } |
374 | } | 374 | } |
375 | pfunc = _grey_pixelfuncs[_grey_info.drawmode]; | 375 | pfunc = _grey_pixelfuncs[_grey_info.drawmode]; |
@@ -514,16 +514,9 @@ void grey_gray_bitmap_part(const unsigned char *src, int src_x, int src_y, | |||
514 | 514 | ||
515 | do | 515 | do |
516 | { | 516 | { |
517 | const unsigned char *src_row = src; | 517 | _grey_info.rb->memcpy(dst, src, width); |
518 | unsigned char *dst_row = dst; | ||
519 | unsigned char *row_end = dst_row + width; | ||
520 | |||
521 | do | ||
522 | *dst_row++ = _grey_info.gvalue[*src_row++]; | ||
523 | while (dst_row < row_end); | ||
524 | |||
525 | src += stride; | ||
526 | dst += _grey_info.width; | 518 | dst += _grey_info.width; |
519 | src += stride; | ||
527 | } | 520 | } |
528 | while (dst < dst_end); | 521 | while (dst < dst_end); |
529 | } | 522 | } |
@@ -578,39 +571,27 @@ void grey_putsxy(int x, int y, const unsigned char *str) | |||
578 | 571 | ||
579 | /*** Unbuffered drawing functions ***/ | 572 | /*** Unbuffered drawing functions ***/ |
580 | 573 | ||
581 | #ifdef SIMULATOR | ||
582 | |||
583 | /* Clear the whole display */ | ||
584 | void grey_ub_clear_display(void) | ||
585 | { | ||
586 | grey_clear_display(); | ||
587 | grey_update(); | ||
588 | } | ||
589 | |||
590 | /* Draw a partial greyscale bitmap, canonical format */ | ||
591 | void grey_ub_gray_bitmap_part(const unsigned char *src, int src_x, int src_y, | ||
592 | int stride, int x, int y, int width, int height) | ||
593 | { | ||
594 | grey_gray_bitmap_part(src, src_x, src_y, stride, x, y, width, height); | ||
595 | grey_update_rect(x, y, width, height); | ||
596 | } | ||
597 | |||
598 | #else /* !SIMULATOR */ | ||
599 | |||
600 | /* Clear the greyscale display (sets all pixels to white) */ | 574 | /* Clear the greyscale display (sets all pixels to white) */ |
601 | void grey_ub_clear_display(void) | 575 | void grey_ub_clear_display(void) |
602 | { | 576 | { |
603 | int value = (_grey_info.drawmode & DRMODE_INVERSEVID) ? | 577 | int value = _grey_info.gvalue[(_grey_info.drawmode & DRMODE_INVERSEVID) ? |
604 | _grey_info.fg_val : _grey_info.bg_val; | 578 | _grey_info.fg_brightness : |
605 | 579 | _grey_info.bg_brightness]; | |
580 | |||
606 | _grey_info.rb->memset(_grey_info.values, value, | 581 | _grey_info.rb->memset(_grey_info.values, value, |
607 | _GREY_MULUQ(_grey_info.width, _grey_info.height)); | 582 | _GREY_MULUQ(_grey_info.width, _grey_info.height)); |
583 | #ifdef SIMULATOR | ||
584 | _grey_info.rb->sim_lcd_ex_update_rect(_grey_info.x, _grey_info.y, | ||
585 | _grey_info.width, _grey_info.height); | ||
586 | #endif | ||
608 | } | 587 | } |
609 | 588 | ||
610 | /* Draw a partial greyscale bitmap, canonical format */ | 589 | /* Draw a partial greyscale bitmap, canonical format */ |
611 | void grey_ub_gray_bitmap_part(const unsigned char *src, int src_x, int src_y, | 590 | void grey_ub_gray_bitmap_part(const unsigned char *src, int src_x, int src_y, |
612 | int stride, int x, int y, int width, int height) | 591 | int stride, int x, int y, int width, int height) |
613 | { | 592 | { |
593 | int yc, ye; | ||
594 | |||
614 | /* nothing to draw? */ | 595 | /* nothing to draw? */ |
615 | if ((width <= 0) || (height <= 0) || (x >= _grey_info.width) | 596 | if ((width <= 0) || (height <= 0) || (x >= _grey_info.width) |
616 | || (y >= _grey_info.height) || (x + width <= 0) || (y + height <= 0)) | 597 | || (y >= _grey_info.height) || (x + width <= 0) || (y + height <= 0)) |
@@ -634,15 +615,17 @@ void grey_ub_gray_bitmap_part(const unsigned char *src, int src_x, int src_y, | |||
634 | if (y + height > _grey_info.height) | 615 | if (y + height > _grey_info.height) |
635 | height = _grey_info.height - y; | 616 | height = _grey_info.height - y; |
636 | 617 | ||
637 | src += _GREY_MULUQ(stride, src_y) + src_x; /* move starting point */ | 618 | src += _GREY_MULUQ(stride, src_y) + src_x; /* move starting point */ |
619 | yc = y; | ||
620 | ye = y + height; | ||
638 | 621 | ||
639 | do | 622 | do |
640 | { | 623 | { |
641 | #if LCD_PIXELFORMAT == HORIZONTAL_PACKING | 624 | #if LCD_PIXELFORMAT == HORIZONTAL_PACKING |
642 | int idx = _GREY_MULUQ(_grey_info.width, y) + x; | 625 | int idx = _GREY_MULUQ(_grey_info.width, yc) + x; |
643 | #else | 626 | #else |
644 | int idx = _GREY_MULUQ(_grey_info.width, y & ~_GREY_BMASK) | 627 | int idx = _GREY_MULUQ(_grey_info.width, yc & ~_GREY_BMASK) |
645 | + (x << _GREY_BSHIFT) + (~y & _GREY_BMASK); | 628 | + (x << _GREY_BSHIFT) + (~yc & _GREY_BMASK); |
646 | #endif /* LCD_PIXELFORMAT */ | 629 | #endif /* LCD_PIXELFORMAT */ |
647 | unsigned char *dst_row = _grey_info.values + idx; | 630 | unsigned char *dst_row = _grey_info.values + idx; |
648 | const unsigned char *src_row = src; | 631 | const unsigned char *src_row = src; |
@@ -655,14 +638,15 @@ void grey_ub_gray_bitmap_part(const unsigned char *src, int src_x, int src_y, | |||
655 | } | 638 | } |
656 | while (src_row < src_end); | 639 | while (src_row < src_end); |
657 | 640 | ||
658 | y++; | ||
659 | src += stride; | 641 | src += stride; |
660 | } | 642 | } |
661 | while (--height > 0); | 643 | while (++yc < ye); |
644 | #ifdef SIMULATOR | ||
645 | _grey_info.rb->sim_lcd_ex_update_rect(_grey_info.x + x, _grey_info.y + y, | ||
646 | width, height); | ||
647 | #endif | ||
662 | } | 648 | } |
663 | 649 | ||
664 | #endif /* !SIMULATOR */ | ||
665 | |||
666 | /* Draw a full greyscale bitmap, canonical format */ | 650 | /* Draw a full greyscale bitmap, canonical format */ |
667 | void grey_ub_gray_bitmap(const unsigned char *src, int x, int y, int width, | 651 | void grey_ub_gray_bitmap(const unsigned char *src, int x, int y, int width, |
668 | int height) | 652 | int height) |
diff --git a/apps/plugins/lib/grey_parm.c b/apps/plugins/lib/grey_parm.c index e2accee518..63d09dfd72 100644 --- a/apps/plugins/lib/grey_parm.c +++ b/apps/plugins/lib/grey_parm.c | |||
@@ -49,8 +49,10 @@ void grey_set_position(int x, int y) | |||
49 | if (_grey_info.flags & _GREY_RUNNING) | 49 | if (_grey_info.flags & _GREY_RUNNING) |
50 | { | 50 | { |
51 | #ifdef SIMULATOR | 51 | #ifdef SIMULATOR |
52 | _grey_info.rb->sim_lcd_ex_update_rect(_grey_info.x, _grey_info.y, | ||
53 | _grey_info.width, | ||
54 | _grey_info.height); | ||
52 | grey_deferred_lcd_update(); | 55 | grey_deferred_lcd_update(); |
53 | grey_update(); | ||
54 | #else | 56 | #else |
55 | _grey_info.flags |= _GREY_DEFERRED_UPDATE; | 57 | _grey_info.flags |= _GREY_DEFERRED_UPDATE; |
56 | #endif | 58 | #endif |
@@ -72,7 +74,6 @@ int grey_get_drawmode(void) | |||
72 | /* Set the foreground shade for subsequent drawing operations */ | 74 | /* Set the foreground shade for subsequent drawing operations */ |
73 | void grey_set_foreground(unsigned brightness) | 75 | void grey_set_foreground(unsigned brightness) |
74 | { | 76 | { |
75 | _grey_info.fg_val = _grey_info.gvalue[brightness]; | ||
76 | _grey_info.fg_brightness = brightness; | 77 | _grey_info.fg_brightness = brightness; |
77 | } | 78 | } |
78 | 79 | ||
@@ -85,7 +86,6 @@ unsigned grey_get_foreground(void) | |||
85 | /* Set the background shade for subsequent drawing operations */ | 86 | /* Set the background shade for subsequent drawing operations */ |
86 | void grey_set_background(unsigned brightness) | 87 | void grey_set_background(unsigned brightness) |
87 | { | 88 | { |
88 | _grey_info.bg_val = _grey_info.gvalue[brightness]; | ||
89 | _grey_info.bg_brightness = brightness; | 89 | _grey_info.bg_brightness = brightness; |
90 | } | 90 | } |
91 | 91 | ||
diff --git a/apps/plugins/lib/grey_scroll.c b/apps/plugins/lib/grey_scroll.c index 5040dd4c74..12a27daf23 100644 --- a/apps/plugins/lib/grey_scroll.c +++ b/apps/plugins/lib/grey_scroll.c | |||
@@ -41,7 +41,7 @@ void grey_scroll_left(int count) | |||
41 | data_end = data + _GREY_MULUQ(_grey_info.width, _grey_info.height); | 41 | data_end = data + _GREY_MULUQ(_grey_info.width, _grey_info.height); |
42 | length = _grey_info.width - count; | 42 | length = _grey_info.width - count; |
43 | blank = (_grey_info.drawmode & DRMODE_INVERSEVID) ? | 43 | blank = (_grey_info.drawmode & DRMODE_INVERSEVID) ? |
44 | _grey_info.fg_val : _grey_info.bg_val; | 44 | _grey_info.fg_brightness : _grey_info.bg_brightness; |
45 | 45 | ||
46 | do | 46 | do |
47 | { | 47 | { |
@@ -66,7 +66,7 @@ void grey_scroll_right(int count) | |||
66 | data_end = data + _GREY_MULUQ(_grey_info.width, _grey_info.height); | 66 | data_end = data + _GREY_MULUQ(_grey_info.width, _grey_info.height); |
67 | length = _grey_info.width - count; | 67 | length = _grey_info.width - count; |
68 | blank = (_grey_info.drawmode & DRMODE_INVERSEVID) ? | 68 | blank = (_grey_info.drawmode & DRMODE_INVERSEVID) ? |
69 | _grey_info.fg_val : _grey_info.bg_val; | 69 | _grey_info.fg_brightness : _grey_info.bg_brightness; |
70 | 70 | ||
71 | do | 71 | do |
72 | { | 72 | { |
@@ -89,7 +89,7 @@ void grey_scroll_up(int count) | |||
89 | shift = _GREY_MULUQ(_grey_info.width, count); | 89 | shift = _GREY_MULUQ(_grey_info.width, count); |
90 | length = _GREY_MULUQ(_grey_info.width, _grey_info.height - count); | 90 | length = _GREY_MULUQ(_grey_info.width, _grey_info.height - count); |
91 | blank = (_grey_info.drawmode & DRMODE_INVERSEVID) ? | 91 | blank = (_grey_info.drawmode & DRMODE_INVERSEVID) ? |
92 | _grey_info.fg_val : _grey_info.bg_val; | 92 | _grey_info.fg_brightness : _grey_info.bg_brightness; |
93 | 93 | ||
94 | _grey_info.rb->memmove(_grey_info.buffer, _grey_info.buffer + shift, | 94 | _grey_info.rb->memmove(_grey_info.buffer, _grey_info.buffer + shift, |
95 | length); | 95 | length); |
@@ -108,7 +108,7 @@ void grey_scroll_down(int count) | |||
108 | shift = _GREY_MULUQ(_grey_info.width, count); | 108 | shift = _GREY_MULUQ(_grey_info.width, count); |
109 | length = _GREY_MULUQ(_grey_info.width, _grey_info.height - count); | 109 | length = _GREY_MULUQ(_grey_info.width, _grey_info.height - count); |
110 | blank = (_grey_info.drawmode & DRMODE_INVERSEVID) ? | 110 | blank = (_grey_info.drawmode & DRMODE_INVERSEVID) ? |
111 | _grey_info.fg_val : _grey_info.bg_val; | 111 | _grey_info.fg_brightness : _grey_info.bg_brightness; |
112 | 112 | ||
113 | _grey_info.rb->memmove(_grey_info.buffer + shift, _grey_info.buffer, | 113 | _grey_info.rb->memmove(_grey_info.buffer + shift, _grey_info.buffer, |
114 | length); | 114 | length); |
@@ -117,38 +117,6 @@ void grey_scroll_down(int count) | |||
117 | 117 | ||
118 | /*** Unbuffered scrolling functions ***/ | 118 | /*** Unbuffered scrolling functions ***/ |
119 | 119 | ||
120 | #ifdef SIMULATOR | ||
121 | |||
122 | /* Scroll left */ | ||
123 | void grey_ub_scroll_left(int count) | ||
124 | { | ||
125 | grey_scroll_left(count); | ||
126 | grey_update(); | ||
127 | } | ||
128 | |||
129 | /* Scroll right */ | ||
130 | void grey_ub_scroll_right(int count) | ||
131 | { | ||
132 | grey_scroll_right(count); | ||
133 | grey_update(); | ||
134 | } | ||
135 | |||
136 | /* Scroll up */ | ||
137 | void grey_ub_scroll_up(int count) | ||
138 | { | ||
139 | grey_scroll_up(count); | ||
140 | grey_update(); | ||
141 | } | ||
142 | |||
143 | /* Scroll down */ | ||
144 | void grey_ub_scroll_down(int count) | ||
145 | { | ||
146 | grey_scroll_down(count); | ||
147 | grey_update(); | ||
148 | } | ||
149 | |||
150 | #else /* !SIMULATOR */ | ||
151 | |||
152 | /* Scroll left */ | 120 | /* Scroll left */ |
153 | void grey_ub_scroll_left(int count) | 121 | void grey_ub_scroll_left(int count) |
154 | { | 122 | { |
@@ -162,9 +130,9 @@ void grey_ub_scroll_left(int count) | |||
162 | data_end = data + _GREY_MULUQ(_grey_info.width, _grey_info.height); | 130 | data_end = data + _GREY_MULUQ(_grey_info.width, _grey_info.height); |
163 | length = (_grey_info.width - count) << _GREY_BSHIFT; | 131 | length = (_grey_info.width - count) << _GREY_BSHIFT; |
164 | count <<= _GREY_BSHIFT; | 132 | count <<= _GREY_BSHIFT; |
165 | blank = (_grey_info.drawmode & DRMODE_INVERSEVID) ? | 133 | blank = _grey_info.gvalue[(_grey_info.drawmode & DRMODE_INVERSEVID) ? |
166 | _grey_info.fg_val : _grey_info.bg_val; | 134 | _grey_info.fg_brightness : |
167 | 135 | _grey_info.bg_brightness]; | |
168 | do | 136 | do |
169 | { | 137 | { |
170 | _grey_info.rb->memmove(data, data + count, length); | 138 | _grey_info.rb->memmove(data, data + count, length); |
@@ -173,6 +141,10 @@ void grey_ub_scroll_left(int count) | |||
173 | data += count; | 141 | data += count; |
174 | } | 142 | } |
175 | while (data < data_end); | 143 | while (data < data_end); |
144 | #ifdef SIMULATOR | ||
145 | _grey_info.rb->sim_lcd_ex_update_rect(_grey_info.x, _grey_info.y, | ||
146 | _grey_info.width, _grey_info.height); | ||
147 | #endif | ||
176 | } | 148 | } |
177 | 149 | ||
178 | /* Scroll right */ | 150 | /* Scroll right */ |
@@ -188,9 +160,9 @@ void grey_ub_scroll_right(int count) | |||
188 | data_end = data + _GREY_MULUQ(_grey_info.width, _grey_info.height); | 160 | data_end = data + _GREY_MULUQ(_grey_info.width, _grey_info.height); |
189 | length = (_grey_info.width - count) << _GREY_BSHIFT; | 161 | length = (_grey_info.width - count) << _GREY_BSHIFT; |
190 | count <<= _GREY_BSHIFT; | 162 | count <<= _GREY_BSHIFT; |
191 | blank = (_grey_info.drawmode & DRMODE_INVERSEVID) ? | 163 | blank = _grey_info.gvalue[(_grey_info.drawmode & DRMODE_INVERSEVID) ? |
192 | _grey_info.fg_val : _grey_info.bg_val; | 164 | _grey_info.fg_brightness : |
193 | 165 | _grey_info.bg_brightness]; | |
194 | do | 166 | do |
195 | { | 167 | { |
196 | _grey_info.rb->memmove(data + count, data, length); | 168 | _grey_info.rb->memmove(data + count, data, length); |
@@ -198,6 +170,10 @@ void grey_ub_scroll_right(int count) | |||
198 | data += _grey_info.width << _GREY_BSHIFT; | 170 | data += _grey_info.width << _GREY_BSHIFT; |
199 | } | 171 | } |
200 | while (data < data_end); | 172 | while (data < data_end); |
173 | #ifdef SIMULATOR | ||
174 | _grey_info.rb->sim_lcd_ex_update_rect(_grey_info.x, _grey_info.y, | ||
175 | _grey_info.width, _grey_info.height); | ||
176 | #endif | ||
201 | } | 177 | } |
202 | 178 | ||
203 | /* Scroll up */ | 179 | /* Scroll up */ |
@@ -211,8 +187,9 @@ void grey_ub_scroll_up(int count) | |||
211 | 187 | ||
212 | dst = _grey_info.values; | 188 | dst = _grey_info.values; |
213 | end = dst + _GREY_MULUQ(_grey_info.height, _grey_info.width); | 189 | end = dst + _GREY_MULUQ(_grey_info.height, _grey_info.width); |
214 | blank = (_grey_info.drawmode & DRMODE_INVERSEVID) ? | 190 | blank = _grey_info.gvalue[(_grey_info.drawmode & DRMODE_INVERSEVID) ? |
215 | _grey_info.fg_val : _grey_info.bg_val; | 191 | _grey_info.fg_brightness : |
192 | _grey_info.bg_brightness]; | ||
216 | 193 | ||
217 | #if LCD_PIXELFORMAT == VERTICAL_PACKING | 194 | #if LCD_PIXELFORMAT == VERTICAL_PACKING |
218 | if (count & _GREY_BMASK) | 195 | if (count & _GREY_BMASK) |
@@ -264,6 +241,10 @@ void grey_ub_scroll_up(int count) | |||
264 | dst += blen; | 241 | dst += blen; |
265 | } | 242 | } |
266 | _grey_info.rb->memset(dst, blank, end - dst); /* Fill remainder at once. */ | 243 | _grey_info.rb->memset(dst, blank, end - dst); /* Fill remainder at once. */ |
244 | #ifdef SIMULATOR | ||
245 | _grey_info.rb->sim_lcd_ex_update_rect(_grey_info.x, _grey_info.y, | ||
246 | _grey_info.width, _grey_info.height); | ||
247 | #endif | ||
267 | } | 248 | } |
268 | 249 | ||
269 | /* Scroll down */ | 250 | /* Scroll down */ |
@@ -277,8 +258,9 @@ void grey_ub_scroll_down(int count) | |||
277 | 258 | ||
278 | start = _grey_info.values; | 259 | start = _grey_info.values; |
279 | dst = start + _GREY_MULUQ(_grey_info.height, _grey_info.width); | 260 | dst = start + _GREY_MULUQ(_grey_info.height, _grey_info.width); |
280 | blank = (_grey_info.drawmode & DRMODE_INVERSEVID) ? | 261 | blank = _grey_info.gvalue[(_grey_info.drawmode & DRMODE_INVERSEVID) ? |
281 | _grey_info.fg_val : _grey_info.bg_val; | 262 | _grey_info.fg_brightness : |
263 | _grey_info.bg_brightness]; | ||
282 | 264 | ||
283 | #if LCD_PIXELFORMAT == VERTICAL_PACKING | 265 | #if LCD_PIXELFORMAT == VERTICAL_PACKING |
284 | if (count & _GREY_BMASK) | 266 | if (count & _GREY_BMASK) |
@@ -331,6 +313,8 @@ void grey_ub_scroll_down(int count) | |||
331 | } | 313 | } |
332 | _grey_info.rb->memset(start, blank, dst - start); | 314 | _grey_info.rb->memset(start, blank, dst - start); |
333 | /* Fill remainder at once. */ | 315 | /* Fill remainder at once. */ |
316 | #ifdef SIMULATOR | ||
317 | _grey_info.rb->sim_lcd_ex_update_rect(_grey_info.x, _grey_info.y, | ||
318 | _grey_info.width, _grey_info.height); | ||
319 | #endif | ||
334 | } | 320 | } |
335 | |||
336 | #endif /* !SIMULATOR */ | ||