? build ? wps-load-new.patch ? wps_sb_tag_fix.patch ? apps/gui/combined-bmp-tmp.c ? tools/iaudio ? tools/rdf2binary ? tools/mkboot ? tools/ipod_fw Index: apps/gui/gwps-common.c =================================================================== RCS file: /cvsroot/rockbox/apps/gui/gwps-common.c,v retrieving revision 1.10 diff -u -r1.10 gwps-common.c --- apps/gui/gwps-common.c 22 Nov 2005 03:38:07 -0000 1.10 +++ apps/gui/gwps-common.c 24 Nov 2005 19:57:30 -0000 @@ -55,11 +55,314 @@ /* 3% of 30min file == 54s step size */ #define MIN_FF_REWIND_STEP 500 + +/* +* parse the given buffer for following static tags: +* %x - load image for always display +* %xl - preload image +* %we - enable statusbar on wps regardless of the global setting +* %wd - disable statusbar on wps regardless of the global setting +* and also for: +* # - a comment line +* +* it returns true if one of these tags is found and handled +* false otherwise +*/ +bool wps_data_preload_tags(struct wps_data *data, char *buf, + const char *bmpdir, size_t bmpdirlen) +{ + if(!data || !buf) return false; + + bool wps_tag_found = false; + char c, lastc = 0; +#ifndef HAVE_LCD_BITMAP + /* no bitmap-lcd == no bitmap loading */ + (void)bmpdir; + (void)bmpdirlen; +#endif + if(*buf == '#') + return true; + while((*buf)) + { + c = *buf; + switch (c) + { +#ifdef HAVE_LCD_BITMAP + case '%': + /* + * if tag found then return because these two tags must be on + * must be on their own line + */ + if(*(buf+1) == 'w' && (*(buf+2) == 'd' || *(buf+2) == 'e') + && !wps_tag_found) + { + data->wps_sb_tag = true; + if( *(buf+1) == 'w' && *(buf+2) == 'e' ) + data->show_sb_on_wps = true; + wps_tag_found = true; + return true; + } + if (*(buf+1) != 'x') + buf++; + break; + + case 'x': + /* Preload images so the %xd# tag can display it */ + { + int ret = 0; + int n; + char *ptr = buf+1; + char *pos = NULL; + char imgname[MAX_PATH]; + char qual = *ptr; + + if(lastc != '%') + break; + if(qual == 'p') + { + ptr = strchr(ptr, '|') + 1; + pos = strchr(ptr, '|'); + int src = -1; + if (pos) + { + /* get the image ID */ + n = get_image_id(*ptr); + + + if(n < 0 || n >= MAX_IMAGES) + { + /* Skip the rest of the line */ + while(*buf != '\n') + buf++; + break; + } + ptr = pos+1; + + /* check the image number and load state */ + if (data->img[n].loaded) + { + /* Skip the rest of the line */ + while(*buf != '\n') + buf++; + break; + } + else + { + /* get the source image ID */ + src = get_image_id(*ptr); + + if(src < 0 || src >= MAX_IMAGES + || !data->img[src].loaded) + { + /* Skip the rest of the line */ + while(*buf != '\n') + buf++; + break; + } + pos = strchr(ptr, '|'); + ptr = pos+1; + + /* get src_x */ + pos = strchr(ptr, '|'); + if (pos) + data->img[n].src_x = atoi(ptr); + else + { + /* weird syntax, bail out */ + buf++; + break; + } + ptr = pos+1; + + /* get src_y */ + pos = strchr(ptr, '|'); + if (pos) + data->img[n].src_y = atoi(ptr); + else + { + /* weird syntax, bail out */ + buf++; + break; + } + ptr = pos+1; + + /* get width */ + pos = strchr(ptr, '|'); + if (pos) + data->img[n].w = atoi(ptr); + else + { + /* weird syntax, bail out */ + buf++; + break; + } + ptr = pos+1; + + /* get height */ + pos = strchr(ptr, '|'); + if (pos) + data->img[n].h = atoi(ptr); + else + { + /* weird syntax, bail out */ + buf++; + break; + } + ptr = pos+1; + + /* get x-position */ + pos = strchr(ptr, '|'); + if (pos) + data->img[n].x = atoi(ptr); + else + { + /* weird syntax, bail out */ + buf++; + break; + } + + /* get y-position */ + ptr = pos+1; + pos = strchr(ptr, '|'); + if (pos) + data->img[n].y = atoi(ptr); + else + { + /* weird syntax, bail out */ + buf++; + break; + } + + pos++; + + /* reposition buf pointer to next WPS element */ + while (*pos && *pos != ';' && *pos != '\n') + pos++; + + + data->img[n].ptr = data->img[src].ptr; + data->img[n].stride = data->img[src].w; + data->img[n].loaded = true; + return true; + } + } + } + if (qual == 'l' || qual == '|') /* format: + %x|n|filename.bmp|x|y| + or + %xl|n|filename.bmp|x|y| + */ + { + ptr = strchr(ptr, '|') + 1; + pos = strchr(ptr, '|'); + if (pos) + { + /* get the image ID */ + n = get_image_id(*ptr); + + if(n < 0 || n >= MAX_IMAGES) + { + /* Skip the rest of the line */ + while(*buf != '\n') + buf++; + break; + } + ptr = pos+1; + + /* check the image number and load state */ + if (data->img[n].loaded) + { + /* Skip the rest of the line */ + while(*buf != '\n') + buf++; + break; + } + else + { + /* get filename */ + pos = strchr(ptr, '|'); + if ((pos - ptr) < + (int)sizeof(imgname)-ROCKBOX_DIR_LEN-2) + { + memcpy(imgname, bmpdir, bmpdirlen); + imgname[bmpdirlen] = '/'; + memcpy(&imgname[bmpdirlen+1], + ptr, pos - ptr); + imgname[bmpdirlen+1+pos-ptr] = 0; + } + else + /* filename too long */ + imgname[0] = 0; + + ptr = pos+1; + + /* get x-position */ + pos = strchr(ptr, '|'); + if (pos) + data->img[n].x = atoi(ptr); + else + { + /* weird syntax, bail out */ + buf++; + break; + } + + /* get y-position */ + ptr = pos+1; + pos = strchr(ptr, '|'); + if (pos) + data->img[n].y = atoi(ptr); + else + { + /* weird syntax, bail out */ + buf++; + break; + } + + pos++; + + /* reposition buf pointer to next WPS element */ + while (*pos && *pos != ';' && *pos != '\n') + pos++; + + buf = pos; + + /* load the image */ + ret = read_bmp_file(imgname, &data->img[n].w, + &data->img[n].h, data->img_buf_ptr, + data->img_buf_free); + if (ret > 0) + { + data->img[n].ptr = data->img_buf_ptr; + data->img_buf_ptr += ret; + data->img_buf_free -= ret; + data->img[n].loaded = true; + if(qual == '|') + data->img[n].always_display = true; + } + return true; + } + } + } + } + + break; +#endif + } + lastc = c; + buf++; + } + /* no of these tags found */ + return false; +} + + /* draws the statusbar on the given wps-screen */ #ifdef HAVE_LCD_BITMAP static void gui_wps_statusbar_draw(struct gui_wps *wps, bool force) { bool draw = global_settings.statusbar; + if(wps->data->wps_sb_tag && wps->data->show_sb_on_wps) draw = true; @@ -781,13 +1084,7 @@ case 'x': /* image support */ #ifdef HAVE_LCD_BITMAP - /* skip preload or regular image tag */ - if ('l' == *(fmt+1) || '|' == *(fmt+1)) - { - while (*fmt && *fmt != '\n') - fmt++; - } - else if ('d' == *(fmt+1) ) + if ('d' == *(fmt+1) ) { fmt+=2; @@ -925,23 +1222,13 @@ } /* Set format string to use for WPS, splitting it into lines */ -void gui_wps_format(struct wps_data *data, const char *bmpdir, - size_t bmpdirlen) +void gui_wps_format(struct wps_data *data) { char* buf = data->format_buffer; char* start_of_line = data->format_buffer; int line = 0; int subline; - char c, lastc = 0; -#ifndef HAVE_LCD_BITMAP - /* no bitmap lcd == no bitmap loading */ - (void)bmpdir; - (void)bmpdirlen; -#else - unsigned char* img_buf_ptr = data->img_buf; /* where in image buffer */ - - int img_buf_free = IMG_BUFSIZE; /* free space in image buffer */ -#endif + char c; if(!data) return; @@ -960,35 +1247,13 @@ subline = 0; data->format_lines[line][subline] = buf; -#ifdef HAVE_LCD_BITMAP - bool wps_tag_found = false; - data->wps_sb_tag = false; - data->show_sb_on_wps = false; -#endif while ((*buf) && (line < WPS_MAX_LINES)) { c = *buf; switch (c) { - /* - * skip % sequences so "%;" doesn't start a new subline - * don't skip %x lines (pre-load bitmaps) - */ case '%': -#ifdef HAVE_LCD_BITMAP - if(*(buf+1) == 'w' && (*(buf+2) == 'd' || *(buf+2) == 'e') - && !wps_tag_found) - { - data->wps_sb_tag = true; - if( *(buf+1) == 'w' && *(buf+2) == 'e' ) - data->show_sb_on_wps = true; - wps_tag_found = true; - } - if (*(buf+1) != 'x') - buf++; - break; -#endif case '\r': /* CR */ *buf = 0; break; @@ -1028,126 +1293,7 @@ subline = 0; } break; - - case 'x': -#ifdef HAVE_LCD_BITMAP - /* Preload images so the %xd# tag can display it */ - { - int ret = 0; - int n; - char *ptr = buf+1; - char *pos = NULL; - char imgname[MAX_PATH]; - char qual = *ptr; - - if(lastc != '%') - break; - - if (qual == 'l' || qual == '|') /* format: - %x|n|filename.bmp|x|y| - or - %xl|n|filename.bmp|x|y| - */ - { - ptr = strchr(ptr, '|') + 1; - pos = strchr(ptr, '|'); - if (pos) - { - /* get the image ID */ - n = *ptr; - if(n >= 'a' && n <= 'z') - n -= 'a'; - if(n >= 'A' && n <= 'Z') - n = n - 'A' + 26; - - if(n < 0 || n >= MAX_IMAGES) - { - /* Skip the rest of the line */ - while(*buf != '\n') - buf++; - break; - } - ptr = pos+1; - - /* check the image number and load state */ - if (data->img[n].loaded) - { - /* Skip the rest of the line */ - while(*buf != '\n') - buf++; - break; - } - else - { - /* get filename */ - pos = strchr(ptr, '|'); - if ((pos - ptr) < - (int)sizeof(imgname)-ROCKBOX_DIR_LEN-2) - { - memcpy(imgname, bmpdir, bmpdirlen); - imgname[bmpdirlen] = '/'; - memcpy(&imgname[bmpdirlen+1], - ptr, pos - ptr); - imgname[bmpdirlen+1+pos-ptr] = 0; - } - else - /* filename too long */ - imgname[0] = 0; - - ptr = pos+1; - - /* get x-position */ - pos = strchr(ptr, '|'); - if (pos) - data->img[n].x = atoi(ptr); - else - { - /* weird syntax, bail out */ - buf++; - break; - } - - /* get y-position */ - ptr = pos+1; - pos = strchr(ptr, '|'); - if (pos) - data->img[n].y = atoi(ptr); - else - { - /* weird syntax, bail out */ - buf++; - break; - } - - pos++; - - /* reposition buf pointer to next WPS element */ - while (*pos && *pos != ';' && *pos != '\n') - pos++; - - buf = pos; - - /* load the image */ - ret = read_bmp_file(imgname, &data->img[n].w, - &data->img[n].h, img_buf_ptr, - img_buf_free); - if (ret > 0) - { - data->img[n].ptr = img_buf_ptr; - img_buf_ptr += ret; - img_buf_free -= ret; - data->img[n].loaded = true; - if(qual == '|') - data->img[n].always_display = true; - } - } - } - } - } -#endif - break; } - lastc = c; buf++; } } Index: apps/gui/gwps-common.h =================================================================== RCS file: /cvsroot/rockbox/apps/gui/gwps-common.h,v retrieving revision 1.3 diff -u -r1.3 gwps-common.h --- apps/gui/gwps-common.h 20 Nov 2005 22:13:52 -0000 1.3 +++ apps/gui/gwps-common.h 24 Nov 2005 19:57:30 -0000 @@ -25,8 +25,7 @@ void gui_wps_format_time(char* buf, int buf_size, long time); void fade(bool fade_in); -void gui_wps_format(struct wps_data *data, const char *bmpdir, - size_t bmpdirlen); +void gui_wps_format(struct wps_data *data); bool gui_wps_refresh(struct gui_wps *gwps, int ffwd_offset, unsigned char refresh_mode); bool gui_wps_display(void); @@ -34,6 +33,8 @@ bool update_onvol_change(struct gui_wps * gwps); bool update(struct gui_wps *gwps); bool ffwd_rew(int button); +bool wps_data_preload_tags(struct wps_data *data, char *buf, + const char *bmpdir, size_t bmpdirlen); #ifdef WPS_KEYLOCK void display_keylock_text(bool locked); void waitfor_nokey(void); Index: apps/gui/gwps.c =================================================================== RCS file: /cvsroot/rockbox/apps/gui/gwps.c,v retrieving revision 1.8 diff -u -r1.8 gwps.c --- apps/gui/gwps.c 22 Nov 2005 21:55:04 -0000 1.8 +++ apps/gui/gwps.c 24 Nov 2005 19:57:32 -0000 @@ -726,6 +726,8 @@ data->img[i].display = false; data->img[i].always_display = false; } + data->wps_sb_tag = false; + data->show_sb_on_wps = false; } #else #define wps_clear(a) @@ -769,17 +771,17 @@ if (! strcmp(buf, WPS_DEFAULTCFG) ) { wps_reset(wps_data); - global_settings.wps_file[0] = 0; + global_settings.wps_file[0] = 0; return false; } #ifdef HAVE_REMOTE_LCD - if (! strcmp(buf, RWPS_DEFAULTCFG) ) + if (! strcmp(buf, RWPS_DEFAULTCFG) ) { wps_reset(wps_data); - global_settings.rwps_file[0] = 0; - return false; - } + global_settings.rwps_file[0] = 0; + return false; + } #endif size_t bmpdirlen; @@ -790,16 +792,31 @@ if (fd >= 0) { - int numread = read(fd, wps_data->format_buffer, - sizeof(wps_data->format_buffer) - 1); - - if (numread > 0) - { + int start = 0; + int numread = 0; + char temp[512]; + + wps_reset(wps_data); #ifdef HAVE_LCD_BITMAP - wps_clear(wps_data); + wps_data->img_buf_ptr = wps_data->img_buf; /* where in image buffer */ + + wps_data->img_buf_free = IMG_BUFSIZE; /* free space in image buffer */ #endif - wps_data->format_buffer[numread] = 0; - gui_wps_format(wps_data, buf, bmpdirlen); + while( (numread = read_line(fd, &wps_data->format_buffer[start], + sizeof(wps_data->format_buffer)-start) ) ) + { + if(!wps_data->format_buffer[numread+start-1]) + wps_data->format_buffer[numread+start-1]='\n'; + if(!wps_data_preload_tags(wps_data, + &wps_data->format_buffer[start], + buf, bmpdirlen)) + start += numread; + } + + if (start > 0) + { + wps_data->format_buffer[start] = 0; + gui_wps_format(wps_data); } close(fd); Index: apps/gui/gwps.h =================================================================== RCS file: /cvsroot/rockbox/apps/gui/gwps.h,v retrieving revision 1.7 diff -u -r1.7 gwps.h --- apps/gui/gwps.h 22 Nov 2005 03:38:07 -0000 1.7 +++ apps/gui/gwps.h 24 Nov 2005 19:57:32 -0000 @@ -255,6 +255,8 @@ #ifdef HAVE_LCD_BITMAP struct gui_img img[MAX_IMAGES]; unsigned char img_buf[IMG_BUFSIZE]; + unsigned char* img_buf_ptr; + int img_buf_free; bool wps_sb_tag; bool show_sb_on_wps; #endif