Index: wps-display.c =================================================================== RCS file: /cvsroot/rockbox/apps/wps-display.c,v retrieving revision 1.18 diff -u -r1.18 wps-display.c --- wps-display.c 7 Sep 2002 12:34:10 -0000 1.18 +++ wps-display.c 7 Sep 2002 23:10:59 -0000 @@ -46,8 +46,6 @@ #include "ajf.h" #endif -#define WPS_CONFIG ROCKBOX_DIR "/default.wps" - #ifdef HAVE_LCD_BITMAP #define MAX_LINES 10 #else @@ -110,50 +108,6 @@ } } -bool wps_load_custom(char* file) -{ - char buffer[FORMAT_BUFFER_SIZE]; - int fd; - bool special = true; - - /* default wps file? */ - if (!file) { - file = WPS_CONFIG; - special = false; - } - - fd = open(file, O_RDONLY); - - if (-1 != fd) - { - int numread = read(fd, buffer, sizeof(buffer) - 1); - - if (numread > 0) - { - buffer[numread] = 0; - wps_format(buffer); - } - - close(fd); - - if ( special ) { - int i; - lcd_clear_display(); -#ifdef HAVE_LCD_BITMAP - lcd_setmargins(0,0); -#endif - for (i=0; i 0; - } - - return false; -} - /* Format time into buf. * * buf - buffer to format to. @@ -579,6 +533,61 @@ return true; } +/* Load custom wps from a file. + * + * file - the file to load from + * verbose - dump the file contents to the screen + */ +bool wps_load_custom(char* file, bool verbose) +{ + char buffer[FORMAT_BUFFER_SIZE]; + int fd; + + fd = open(file, O_RDONLY); + + if (-1 != fd) + { + int numread = read(fd, buffer, sizeof(buffer) - 1); + + if (numread > 0) + { + buffer[numread] = 0; + wps_format(buffer); + } + + close(fd); + + if (get_dir(global_settings.wps_file, MAX_WPS_FILENAME+1, file, 0)) + { + /* Remove extension */ + char* sep = strrchr(global_settings.wps_file, '.'); + + if (NULL != sep) + { + *sep = 0; + } + + settings_save(); + } + + if ( verbose ) { + int i; + lcd_clear_display(); +#ifdef HAVE_LCD_BITMAP + lcd_setmargins(0,0); +#endif + for (i=0; i 0; + } + + return false; +} + void wps_display(struct mp3entry* id3) { int font_height; @@ -607,7 +616,13 @@ static bool wps_loaded = false; if (!wps_loaded) { - wps_load_custom(NULL); + char filebuf[25]; + snprintf(filebuf, 24, "%s%s%s%s", + ROCKBOX_DIR, "/", + global_settings.wps_file, + ".wps"); + filebuf[25] = 0; + wps_load_custom(filebuf, false); wps_loaded = true; if ( !format_buffer[0] ) { Index: wps-display.h =================================================================== RCS file: /cvsroot/rockbox/apps/wps-display.h,v retrieving revision 1.4 diff -u -r1.4 wps-display.h --- wps-display.h 2 Sep 2002 12:46:31 -0000 1.4 +++ wps-display.h 7 Sep 2002 23:10:59 -0000 @@ -24,7 +24,7 @@ bool wps_refresh(struct mp3entry* id3, int ffwd_offset, bool refresh_scroll); void wps_display(struct mp3entry* id3); -bool wps_load_custom(char* file); +bool wps_load_custom(char* file, bool verbose); #ifdef HAVE_LCD_CHARCELLS bool draw_player_progress(struct mp3entry* id3, int ff_rewind_count); Index: settings.c =================================================================== RCS file: /cvsroot/rockbox/apps/settings.c,v retrieving revision 1.50 diff -u -r1.50 settings.c --- settings.c 6 Sep 2002 06:02:02 -0000 1.50 +++ settings.c 7 Sep 2002 23:11:01 -0000 @@ -281,6 +281,9 @@ memcpy(&config_block[0xF8], &global_settings.resume_seed, 4); memcpy(&config_block[0x24], &global_settings.total_uptime, 4); + + strncpy(&config_block[0xEE], global_settings.wps_file, MAX_WPS_FILENAME); + strncpy(&config_block[0xFC], global_settings.resume_file, MAX_PATH); DEBUGF("+Resume file %s\n",global_settings.resume_file); @@ -290,7 +293,7 @@ DEBUGF("+Resume shuffle %s seed %X\n", global_settings.playlist_shuffle?"on":"off", global_settings.resume_seed); - + if(save_config_buffer()) { lcd_clear_display(); @@ -378,11 +381,14 @@ if (config_block[0x1a] != 0xFF) global_settings.disk_spindown = config_block[0x1a]; - memcpy(&global_settings.resume_seed, &config_block[0xF8], 4); - if (config_block[0x24] != 0xFF) memcpy(&global_settings.total_uptime, &config_block[0x24], 4); + strncpy(global_settings.wps_file, &config_block[0xEE], MAX_WPS_FILENAME); + global_settings.wps_file[MAX_WPS_FILENAME]=0; + + memcpy(&global_settings.resume_seed, &config_block[0xF8], 4); + strncpy(global_settings.resume_file, &config_block[0xFC], MAX_PATH); global_settings.resume_file[MAX_PATH]=0; } @@ -543,6 +549,8 @@ global_settings.resume_index = -1; global_settings.resume_offset = -1; global_settings.disk_spindown = 5; + strncpy(global_settings.wps_file, DEFAULT_WPS_FILE, MAX_WPS_FILENAME); + global_settings.wps_file[MAX_WPS_FILENAME]=0; } Index: settings.h =================================================================== RCS file: /cvsroot/rockbox/apps/settings.h,v retrieving revision 1.38 diff -u -r1.38 settings.h --- settings.h 5 Sep 2002 04:47:24 -0000 1.38 +++ settings.h 7 Sep 2002 23:11:01 -0000 @@ -46,6 +46,8 @@ #define FF_REWIND_45000 12 #define FF_REWIND_60000 13 +#define MAX_WPS_FILENAME 10 + struct user_settings { /* audio settings */ @@ -65,6 +67,10 @@ int backlight; /* backlight off timer: 0-100 0=never:each 1% = 10 secs */ bool discharge; /* maintain charge of at least: false = 90%, true = 10% */ + /* wps settings */ + + unsigned char wps_file[MAX_WPS_FILENAME+1]; /* name of custom wps in /.rockbox (no extension) */ + /* resume settings */ int resume; /* resume option: 0=off, 1=ask, 2=on */ @@ -139,5 +145,6 @@ #define DEFAULT_BACKLIGHT_SETTING 5 #define DEFAULT_FF_REWIND_MIN_STEP FF_REWIND_1000 #define DEFAULT_FF_REWIND_ACCEL_SETTING 3 +#define DEFAULT_WPS_FILE "default" #endif /* __SETTINGS_H__ */ Index: tree.c =================================================================== RCS file: /cvsroot/rockbox/apps/tree.c,v retrieving revision 1.118 diff -u -r1.118 tree.c --- tree.c 6 Sep 2002 06:02:02 -0000 1.118 +++ tree.c 7 Sep 2002 23:11:02 -0000 @@ -617,7 +617,7 @@ case TREE_ATTR_WPS: snprintf(buf, sizeof buf, "%s/%s", currdir, file->name); - wps_load_custom(buf); + wps_load_custom(buf, true); restore = true; break;