diff options
author | Linus Nielsen Feltzing <linus@haxx.se> | 2004-07-09 11:21:13 +0000 |
---|---|---|
committer | Linus Nielsen Feltzing <linus@haxx.se> | 2004-07-09 11:21:13 +0000 |
commit | 7c931a12ec3747f7822dcd5ff1dd3255344a46f6 (patch) | |
tree | 247fb6d30bcfd1c81d516b6ea7c6a86c7fa933e6 | |
parent | 6b559b1f976387a93f9ccc692eaea9dd8f9f5fc4 (diff) | |
download | rockbox-7c931a12ec3747f7822dcd5ff1dd3255344a46f6.tar.gz rockbox-7c931a12ec3747f7822dcd5ff1dd3255344a46f6.zip |
Simplified the recorder scrolling code a little
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4860 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | firmware/drivers/lcd-recorder.c | 65 |
1 files changed, 10 insertions, 55 deletions
diff --git a/firmware/drivers/lcd-recorder.c b/firmware/drivers/lcd-recorder.c index 598571d63f..8c3f573039 100644 --- a/firmware/drivers/lcd-recorder.c +++ b/firmware/drivers/lcd-recorder.c | |||
@@ -75,7 +75,7 @@ | |||
75 | 75 | ||
76 | #define SCROLL_SPACING 3 | 76 | #define SCROLL_SPACING 3 |
77 | 77 | ||
78 | #define SCROLLABLE_LINES 10 | 78 | #define SCROLLABLE_LINES 13 |
79 | 79 | ||
80 | struct scrollinfo { | 80 | struct scrollinfo { |
81 | char line[MAX_PATH + LCD_WIDTH/2 + SCROLL_SPACING + 2]; | 81 | char line[MAX_PATH + LCD_WIDTH/2 + SCROLL_SPACING + 2]; |
@@ -83,7 +83,6 @@ struct scrollinfo { | |||
83 | int width; /* length of line in pixels */ | 83 | int width; /* length of line in pixels */ |
84 | int offset; | 84 | int offset; |
85 | int startx; | 85 | int startx; |
86 | int starty; | ||
87 | bool backward; /* scroll presently forward or backward? */ | 86 | bool backward; /* scroll presently forward or backward? */ |
88 | bool bidir; | 87 | bool bidir; |
89 | bool invert; /* invert the scrolled text */ | 88 | bool invert; /* invert the scrolled text */ |
@@ -337,8 +336,6 @@ void lcd_puts(int x, int y, unsigned char *str) | |||
337 | void lcd_puts_style(int x, int y, unsigned char *str, int style) | 336 | void lcd_puts_style(int x, int y, unsigned char *str, int style) |
338 | { | 337 | { |
339 | int xpos,ypos,w,h; | 338 | int xpos,ypos,w,h; |
340 | struct scrollinfo* s; | ||
341 | int index; | ||
342 | 339 | ||
343 | #if defined(SIMULATOR) && defined(HAVE_LCD_CHARCELLS) | 340 | #if defined(SIMULATOR) && defined(HAVE_LCD_CHARCELLS) |
344 | /* We make the simulator truncate the string if it reaches the right edge, | 341 | /* We make the simulator truncate the string if it reaches the right edge, |
@@ -355,17 +352,7 @@ void lcd_puts_style(int x, int y, unsigned char *str, int style) | |||
355 | #endif | 352 | #endif |
356 | 353 | ||
357 | /* make sure scrolling is turned off on the line we are updating */ | 354 | /* make sure scrolling is turned off on the line we are updating */ |
358 | if (scrolling_lines) { | 355 | scrolling_lines &= ~(1 << y); |
359 | for (index = 0; index < SCROLLABLE_LINES; index++) { | ||
360 | if (scrolling_lines&(1<<index)) { | ||
361 | s = &scroll[index]; | ||
362 | if (s->starty == y) { | ||
363 | scrolling_lines &= ~(1<<index); | ||
364 | break; | ||
365 | } | ||
366 | } | ||
367 | } | ||
368 | } | ||
369 | 356 | ||
370 | if(!str || !str[0]) | 357 | if(!str || !str[0]) |
371 | return; | 358 | return; |
@@ -625,22 +612,11 @@ void lcd_invertrect (int x, int y, int nx, int ny) | |||
625 | void lcd_invertscroll(int x, int y) | 612 | void lcd_invertscroll(int x, int y) |
626 | { | 613 | { |
627 | struct scrollinfo* s; | 614 | struct scrollinfo* s; |
628 | int index; | ||
629 | 615 | ||
630 | for ( index = 0; index < SCROLLABLE_LINES; index++ ) { | 616 | (void)x; |
631 | /* is this a scrolling line? */ | ||
632 | if ( !(scrolling_lines&(1<<index)) ) | ||
633 | continue; | ||
634 | |||
635 | s = &scroll[index]; | ||
636 | 617 | ||
637 | if (s->startx == x && s->starty == y) | 618 | s = &scroll[y]; |
638 | { | 619 | s->invert = !s->invert; |
639 | /* Found the line */ | ||
640 | s->invert = !s->invert; | ||
641 | break; | ||
642 | } | ||
643 | } | ||
644 | } | 620 | } |
645 | 621 | ||
646 | void lcd_drawline( int x1, int y1, int x2, int y2 ) | 622 | void lcd_drawline( int x1, int y1, int x2, int y2 ) |
@@ -816,29 +792,9 @@ void lcd_puts_scroll_style(int x, int y, unsigned char *string, int style) | |||
816 | { | 792 | { |
817 | struct scrollinfo* s; | 793 | struct scrollinfo* s; |
818 | int w, h; | 794 | int w, h; |
819 | int index; | ||
820 | int free_index=0; | ||
821 | 795 | ||
822 | DEBUGF("puts_scroll_style: %s\n", string); | 796 | s = &scroll[y]; |
823 | 797 | ||
824 | for (index = 0; index < SCROLLABLE_LINES; index++) { | ||
825 | s = &scroll[index]; | ||
826 | |||
827 | if (scrolling_lines&(1<<index)) { | ||
828 | if (s->starty == y) { | ||
829 | /* we prefer to re-use an existing index with the | ||
830 | same y-position */ | ||
831 | free_index=index; | ||
832 | break; | ||
833 | } | ||
834 | } | ||
835 | else { | ||
836 | /* remember the last unused one */ | ||
837 | free_index=index; | ||
838 | } | ||
839 | } | ||
840 | index=free_index; | ||
841 | s = &scroll[index]; /* get the proper 's' */ | ||
842 | s->start_tick = current_tick + scroll_delay; | 798 | s->start_tick = current_tick + scroll_delay; |
843 | s->invert = false; | 799 | s->invert = false; |
844 | if (style & STYLE_INVERT) { | 800 | if (style & STYLE_INVERT) { |
@@ -881,13 +837,12 @@ void lcd_puts_scroll_style(int x, int y, unsigned char *string, int style) | |||
881 | s->len = strlen(string); | 837 | s->len = strlen(string); |
882 | s->offset = 0; | 838 | s->offset = 0; |
883 | s->startx = x; | 839 | s->startx = x; |
884 | s->starty = y; | ||
885 | s->backward = false; | 840 | s->backward = false; |
886 | scrolling_lines |= (1<<index); | 841 | scrolling_lines |= (1<<y); |
887 | } | 842 | } |
888 | else | 843 | else |
889 | /* force a bit switch-off since it doesn't scroll */ | 844 | /* force a bit switch-off since it doesn't scroll */ |
890 | scrolling_lines &= ~(1<<index); | 845 | scrolling_lines &= ~(1<<y); |
891 | } | 846 | } |
892 | 847 | ||
893 | void lcd_stop_scroll(void) | 848 | void lcd_stop_scroll(void) |
@@ -943,7 +898,7 @@ static void scroll_thread(void) | |||
943 | 898 | ||
944 | pf = font_get(curfont); | 899 | pf = font_get(curfont); |
945 | xpos = xmargin + s->startx * s->width / s->len; | 900 | xpos = xmargin + s->startx * s->width / s->len; |
946 | ypos = ymargin + s->starty * pf->height; | 901 | ypos = ymargin + index * pf->height; |
947 | 902 | ||
948 | if (s->bidir) { /* scroll bidirectional */ | 903 | if (s->bidir) { /* scroll bidirectional */ |
949 | if (s->offset <= 0) { | 904 | if (s->offset <= 0) { |