Rockbox.org home
release
dev builds
extras
themes manual
wiki
device status forums
mailing lists
IRC bugs
patches
dev guide



Rockbox mail archive

Subject: Re: Patch to allow wrapping around in directories
From: Bill Napier (napier_at_pobox.com)
Date: 2002-07-02


Well, thankfully Mats pointed out to me a rather rough problem in the
dir wrapping code for the recorder (basically, it crashed the
simulator). I had only test stuff on my player (Since that's all I
had) and had no easy way of building a simulator. So I bit the bullet
and got a cross compiled build of a win32 simulator under Linux (build
under linux, run under windows) and debugged the simulator problem
that way. (BTW - Look for a patch with the changes I made for this
build for those who are interested). Back to the point, here is a new
patch that has been tested under both the recorder and the player
simulator and has the crash fixed.

Any questions/comments/problems, you know how to reach me,

Bill

Index: apps/tree.c
===================================================================
RCS file: /cvsroot/rockbox/apps/tree.c,v
retrieving revision 1.51
diff -d -u -r1.51 tree.c
--- apps/tree.c 27 Jun 2002 09:12:29 -0000 1.51
+++ apps/tree.c 2 Jul 2002 15:45:20 -0000
@@ -168,15 +168,17 @@
 
     for ( i=start; i < start+TREE_MAX_ON_SCREEN; i++ ) {
         int len;
+ int offset=i;
 
- if ( i >= filesindir )
- break;
+ if ( offset >= filesindir ) {
+ offset-=filesindir;
+ }
 
- len = strlen(dircacheptr[i]->name);
+ len = strlen(dircacheptr[offset]->name);
 
 #ifdef HAVE_LCD_BITMAP
- if ( dircacheptr[i]->file ) {
- if(!strcasecmp(&dircacheptr[i]->name[len-4], ".m3u"))
+ if ( dircacheptr[offset]->file ) {
+ if(!strcasecmp(&dircacheptr[offset]->name[len-4], ".m3u"))
                 icon_type = Playlist;
             else
                 icon_type=File;
@@ -186,7 +188,7 @@
                    6, MARGIN_Y+(i-start)*LINE_HEIGTH, 6, 8, true);
 #endif
 
- lcd_puts(LINE_X, LINE_Y+i-start, dircacheptr[i]->name);
+ lcd_puts(LINE_X, LINE_Y+i-start, dircacheptr[offset]->name);
     }
 
     return filesindir;
@@ -354,24 +356,26 @@
                 else {
                     if (start) {
                         start--;
+ } else {
+ start=numentries-1;
+ }
                         numentries = showdir(currdir, start);
                         put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true);
                     }
- }
                 break;
 
             case TREE_NEXT:
- if (dircursor + start + 1 < numentries ) {
- if(dircursor+1 < TREE_MAX_ON_SCREEN) {
- put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, false);
- dircursor++;
- put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true);
- }
- else {
- start++;
- numentries = showdir(currdir, start);
- put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true);
+ if(dircursor+1 < TREE_MAX_ON_SCREEN) {
+ put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, false);
+ dircursor++;
+ put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true);
+ } else {
+ start++;
+ if (start>=numentries) {
+ start=0;
                     }
+ numentries = showdir(currdir, start);
+ put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true);
                 }
                 break;
 
@@ -403,9 +407,16 @@
         }
 
         lcd_stop_scroll();
- if ( numentries )
+
+ if ( numentries ) {
+ int offset=start+dircursor;
+
+ if ( offset >= filesindir ) {
+ offset-=filesindir;
+ }
             lcd_puts_scroll(LINE_X, LINE_Y+dircursor,
- dircacheptr[start+dircursor]->name);
+ dircacheptr[offset]->name);
+ }
         lcd_update();
     }
 



Page was last modified "Jan 10 2012" The Rockbox Crew
aaa