Index: apps//tree.c =================================================================== RCS file: /cvsroot/rockbox/apps/tree.c,v retrieving revision 1.118 diff -u -b -r1.118 tree.c --- apps//tree.c 6 Sep 2002 06:02:02 -0000 1.118 +++ apps//tree.c 8 Sep 2002 17:41:48 -0000 @@ -63,8 +63,15 @@ }; static struct entry dircache[MAX_FILES_IN_DIR]; +static int dircursor; +static int dirstart; +static int dirlevel; static int filesindir; -static char lastdir[MAX_PATH] = {0}; +static int dirpos[MAX_DIR_LEVELS]; +static int cursorpos[MAX_DIR_LEVELS]; +static char lastdir[MAX_PATH]; +static char lastfile[MAX_PATH]; +static char currdir[MAX_PATH]; void browse_root(void) { @@ -294,6 +301,20 @@ } } + if (start == -1) + { + /* use lastfile to determine start (default=0) */ + start = dirstart = 0; + for (i=0; iattr & ATTR_DIRECTORY) { memcpy(currdir,buf,sizeof(currdir)); if ( dirlevel < MAX_DIR_LEVELS ) { - dirpos[dirlevel] = start; + dirpos[dirlevel] = dirstart; cursorpos[dirlevel] = dircursor; } dirlevel++; dircursor=0; - start=0; + dirstart=0; } else { int seed = current_tick; bool play = false; @@ -603,7 +670,7 @@ if ( global_settings.resume ) strncpy(global_settings.resume_file, currdir, MAX_PATH); - start_index = build_playlist(dircursor+start); + start_index = build_playlist(dircursor+dirstart); /* it is important that we get back the index in the (shuffled) list and stor that */ @@ -675,9 +742,9 @@ put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true); } else { - if (start) { - start--; - numentries = showdir(currdir, start); + if (dirstart) { + dirstart--; + numentries = showdir(currdir, dirstart); put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true); } else { @@ -689,9 +756,9 @@ true); } else { - start = numentries - tree_max_on_screen; + dirstart = numentries - tree_max_on_screen; dircursor = tree_max_on_screen - 1; - numentries = showdir(currdir, start); + numentries = showdir(currdir, dirstart); put_cursorxy(CURSOR_X, CURSOR_Y + tree_max_on_screen - 1, true); } @@ -706,7 +773,7 @@ case BUTTON_VOL_DOWN: if(filesindir) { - if (dircursor + start + 1 < numentries ) { + if (dircursor + dirstart + 1 < numentries ) { if(dircursor+1 < tree_max_on_screen) { put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, false); @@ -714,8 +781,8 @@ put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true); } else { - start++; - numentries = showdir(currdir, start); + dirstart++; + numentries = showdir(currdir, dirstart); put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true); } } @@ -723,12 +790,12 @@ if(numentries < tree_max_on_screen) { put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, false); - start = dircursor = 0; + dirstart = dircursor = 0; put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true); } else { - start = dircursor = 0; - numentries = showdir(currdir, start); + dirstart = dircursor = 0; + numentries = showdir(currdir, dirstart); put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true); } } @@ -811,7 +878,7 @@ reload_root = false; } dircursor = 0; - start = 0; + dirstart = 0; lastdir[0] = 0; lastfilter = global_settings.mp3filter; lastsortcase = global_settings.sort_case; @@ -824,15 +891,15 @@ /* We need to adjust if the number of lines on screen have changed because of a status bar change */ if(CURSOR_Y+LINE_Y+dircursor>tree_max_on_screen) { - start++; + dirstart++; dircursor--; } - numentries = showdir(currdir, start); + numentries = showdir(currdir, dirstart); put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true); } if ( numentries ) { - i = start+dircursor; + i = dirstart+dircursor; /* if MP3 filter is on, cut off the extension */ if(lasti!=i || restore) { Index: apps//tree.h =================================================================== RCS file: /cvsroot/rockbox/apps/tree.h,v retrieving revision 1.1.1.1 diff -u -b -r1.1.1.1 tree.h --- apps//tree.h 16 May 2002 12:53:41 -0000 1.1.1.1 +++ apps//tree.h 8 Sep 2002 17:41:48 -0000 @@ -22,6 +22,7 @@ #include void browse_root(void); +void set_current_file(char *path); bool dirbrowse(char *root); #endif Index: apps//wps.c =================================================================== RCS file: /cvsroot/rockbox/apps/wps.c,v retrieving revision 1.140 diff -u -b -r1.140 wps.c --- apps//wps.c 6 Sep 2002 05:33:57 -0000 1.140 +++ apps//wps.c 8 Sep 2002 17:41:50 -0000 @@ -922,6 +922,10 @@ lcd_icon(ICON_RECORD, false); lcd_icon(ICON_AUDIO, false); #endif + /* set dir browser to current playing song */ + if (id3) + set_current_file(id3->path); + mpeg_stop(); status_set_playmode(STATUS_STOP); button_set_release(old_release_mask);