From edf4d8ce0f81727479e75032e49c9557fcb3ac14 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 28 Jan 2003 15:23:48 +0000 Subject: Scrolling business is my name and scrolling is what I do when I don't crash because of silly people doing silly programming and not setting the variables to correct values. Now, any other WPS-related scrolling bugs left? git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3175 a1c6a512-1295-4272-9138-f99709370657 --- firmware/drivers/lcd-recorder.c | 52 ++++++++++++++--------------------------- 1 file changed, 18 insertions(+), 34 deletions(-) (limited to 'firmware') diff --git a/firmware/drivers/lcd-recorder.c b/firmware/drivers/lcd-recorder.c index 6a73c07f70..d1e2a6b0da 100644 --- a/firmware/drivers/lcd-recorder.c +++ b/firmware/drivers/lcd-recorder.c @@ -84,7 +84,7 @@ struct scrollinfo { long start_tick; }; -static int scrolling_lines=0; /* Bitpattern of which lines are scrolling */ +static volatile int scrolling_lines=0; /* Bitpattern of which lines are scrolling */ static void scroll_thread(void); static char scroll_stack[DEFAULT_STACK_SIZE]; @@ -212,7 +212,6 @@ void lcd_roll(int lines) void lcd_clear_display (void) { - DEBUGF("lcd_clear_display()\n"); memset (lcd_framebuffer, 0, sizeof lcd_framebuffer); scrolling_lines = 0; } @@ -244,7 +243,6 @@ int lcd_getstringsize(unsigned char *str, int *w, int *h) int ch; int width = 0; - /* DEBUGF("lcd_getstringsize('%s')\n", str); */ while((ch = *str++)) { /* check input range*/ if (ch < pf->firstchar || ch >= pf->firstchar+pf->size) @@ -671,19 +669,24 @@ void lcd_puts_scroll(int x, int y, unsigned char* string) int index; int free_index=0; - DEBUGF("lcd_puts_scroll(%d, %d, %s)\n", x, y, string); for (index = 0; index < SCROLLABLE_LINES; index++) { s = &scroll[index]; + if (scrolling_lines&(1<starty == y) { + /* we prefer to re-use an existing index with the + same y-position */ free_index=index; break; } - } else + } + else { + /* remember the last unused one */ free_index=index; + } } index=free_index; - + s = &scroll[index]; /* get the proper 's' */ s->start_tick = current_tick + scroll_delay; lcd_puts(x,y,string); @@ -693,14 +696,14 @@ void lcd_puts_scroll(int x, int y, unsigned char* string) /* prepare scroll line */ char *end; - scrolling_lines|=(1<line, 0, sizeof s->line); strcpy(s->line, string); /* get width */ s->width = lcd_getstringsize(s->line, &w, &h); - /* scroll bidirectional or forward only depending on the string width */ + /* scroll bidirectional or forward only depending on the string + width */ if ( bidir_limit ) { s->bidir = s->width < (LCD_WIDTH - xmargin) * (100 + bidir_limit) / 100; @@ -714,7 +717,7 @@ void lcd_puts_scroll(int x, int y, unsigned char* string) s->width = lcd_getstringsize(s->line, &w, &h); } - for (end = s->line; *end; end++); + end = strchr(s->line, '\0'); strncpy(end, string, LCD_WIDTH/2); s->len = strlen(string); @@ -722,34 +725,15 @@ void lcd_puts_scroll(int x, int y, unsigned char* string) s->startx = x; s->starty = y; s->backward = false; + scrolling_lines |= (1<line, &w, &h); - lcd_clearrect(xmargin + s->startx * w / s->len, - ymargin + s->starty * h, - LCD_WIDTH - xmargin, - h); - - /* restore scrolled row */ - lcd_puts(s->startx, s->starty, s->line); - update++; - } - } - if(update) - lcd_update(); /* update only if needed */ -#endif scrolling_lines=0; } @@ -784,12 +768,12 @@ static void scroll_thread(void) while ( 1 ) { for ( index = 0; index < SCROLLABLE_LINES; index++ ) { - s = &scroll[index]; - /* really scroll? */ if ( !(scrolling_lines&(1<start_tick)) continue; -- cgit v1.2.3