del ability, adjustments, 1.40 release?
authornotaz <notasas@gmail.com>
Fri, 28 Mar 2008 20:59:30 +0000 (20:59 +0000)
committernotaz <notasas@gmail.com>
Fri, 28 Mar 2008 20:59:30 +0000 (20:59 +0000)
git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@400 be3aeb3a-fb24-0410-a615-afba39da0efa

base_readme.txt
gp2x/Makefile
gp2x/emu.c
gp2x/menu.c

index 3d59588..34341f8 100644 (file)
@@ -650,6 +650,7 @@ Changelog
   + PicoDrive now comes with a game config file for some games which need\r
     special settings, so they should now work out-of-the-box. More games will\r
     be added with later updates.\r
+  + Files now can be deleted by pressing A+SELECT in the file browser.\r
 \r
 1.35b\r
   * PSP: mp3 code should no longer fail on 1.5 firmware.\r
index e96126d..210e139 100644 (file)
@@ -232,7 +232,7 @@ $(error need VER)
 endif\r
 endif\r
 \r
-rel: PicoDrive.gpe code940/pico940_v2.bin readme.txt PicoDrive.man.txt PicoDrive.png\r
+rel: PicoDrive.gpe code940/pico940_v2.bin readme.txt PicoDrive.man.txt PicoDrive.png game.cfg\r
        zip -9 -j ../../PicoDrive_$(VER).zip $^ mmuhack.o\r
        zip -9 -r ../../PicoDrive_$(VER).zip skin -i \*.png -i \*.txt\r
 \r
index e329b5a..f2867fc 100644 (file)
@@ -865,9 +865,10 @@ void emu_Loop(void)
                        bench_fps += frames_shown;\r
                        sprintf(fpsbuff, "%02i/%02i/%02i", frames_shown, bench_fps_s, (bf[0]+bf[1]+bf[2]+bf[3])>>2);\r
 #else\r
-                       if (currentConfig.EmuOpt & 2)\r
+                       if (currentConfig.EmuOpt & 2) {\r
                                sprintf(fpsbuff, "%02i/%02i", frames_shown, frames_done);\r
-                       if (fpsbuff[5] == 0) { fpsbuff[5] = fpsbuff[6] = ' '; fpsbuff[7] = 0; }\r
+                               if (fpsbuff[5] == 0) { fpsbuff[5] = fpsbuff[6] = ' '; fpsbuff[7] = 0; }\r
+                       }\r
 #endif\r
                        frames_shown = frames_done = 0;\r
                        thissec = tval.tv_sec;\r
index 5039cab..506b7c4 100644 (file)
@@ -275,6 +275,31 @@ static int scandir_filter(const struct dirent *ent)
        return 1;\r
 }\r
 \r
+static void do_delete(const char *fpath, const char *fname)\r
+{\r
+       int len, inp;\r
+\r
+       gp2x_pd_clone_buffer2();\r
+\r
+       if (!rom_loaded)\r
+               menu_darken_bg(gp2x_screen, 320*240, 0);\r
+\r
+       len = strlen(fname);\r
+       if (len > 320/6) len = 320/6;\r
+\r
+       text_out16(320/2 - 15*8/2,  80, "About to delete");\r
+       smalltext_out16_lim(320/2 - len*6/2, 95, fname, 0xbdff, len);\r
+       text_out16(320/2 - 13*8/2, 110, "Are you sure?");\r
+       text_out16(320/2 - 25*8/2, 120, "(Y - confirm, X - cancel)");\r
+       menu_flip();\r
+\r
+\r
+       while (gp2x_joystick_read(1) & (GP2X_A|GP2X_SELECT)) usleep(50*1000);\r
+       inp = wait_for_input(GP2X_Y|GP2X_X);\r
+       if (inp & GP2X_Y)\r
+               remove(fpath);\r
+}\r
+\r
 static char *romsel_loop(char *curr_path)\r
 {\r
        struct dirent **namelist;\r
@@ -283,6 +308,7 @@ static char *romsel_loop(char *curr_path)
        unsigned long inp = 0;\r
        char *ret = NULL, *fname = NULL;\r
 \r
+rescan:\r
        // is this a dir or a full path?\r
        if ((dir = opendir(curr_path))) {\r
                closedir(dir);\r
@@ -319,24 +345,39 @@ static char *romsel_loop(char *curr_path)
        for (;;)\r
        {\r
                draw_dirlist(curr_path, namelist, n, sel);\r
-               inp = wait_for_input(GP2X_UP|GP2X_DOWN|GP2X_LEFT|GP2X_RIGHT|GP2X_L|GP2X_R|GP2X_B|GP2X_X);\r
+               inp = wait_for_input(GP2X_UP|GP2X_DOWN|GP2X_LEFT|GP2X_RIGHT|GP2X_L|GP2X_R|GP2X_A|GP2X_B|GP2X_X|GP2X_SELECT);\r
                if(inp & GP2X_UP  )  { sel--;   if (sel < 0)   sel = n-2; }\r
                if(inp & GP2X_DOWN)  { sel++;   if (sel > n-2) sel = 0; }\r
                if(inp & GP2X_LEFT)  { sel-=10; if (sel < 0)   sel = 0; }\r
                if(inp & GP2X_L)     { sel-=24; if (sel < 0)   sel = 0; }\r
                if(inp & GP2X_RIGHT) { sel+=10; if (sel > n-2) sel = n-2; }\r
                if(inp & GP2X_R)     { sel+=24; if (sel > n-2) sel = n-2; }\r
-               if(inp & GP2X_B)     { // enter dir/select\r
+               if ((inp & GP2X_B) || (inp & (GP2X_SELECT|GP2X_A)) == (GP2X_SELECT|GP2X_A)) // enter dir/select || delete\r
+               {\r
                        again:\r
-                       if (namelist[sel+1]->d_type == DT_REG) {\r
+                       if (namelist[sel+1]->d_type == DT_REG)\r
+                       {\r
                                strcpy(romFileName, curr_path);\r
                                strcat(romFileName, "/");\r
                                strcat(romFileName, namelist[sel+1]->d_name);\r
-                               ret = romFileName;\r
-                               break;\r
-                       } else if (namelist[sel+1]->d_type == DT_DIR) {\r
-                               int newlen = strlen(curr_path) + strlen(namelist[sel+1]->d_name) + 2;\r
-                               char *p, *newdir = malloc(newlen);\r
+                               if (inp & GP2X_B) { // return sel\r
+                                       ret = romFileName;\r
+                                       break;\r
+                               }\r
+                               do_delete(romFileName, namelist[sel+1]->d_name);\r
+                               if (n > 0) {\r
+                                       while (n--) free(namelist[n]);\r
+                                       free(namelist);\r
+                               }\r
+                               goto rescan;\r
+                       }\r
+                       else if (namelist[sel+1]->d_type == DT_DIR)\r
+                       {\r
+                               int newlen;\r
+                               char *p, *newdir;\r
+                               if (!(inp & GP2X_B)) continue;\r
+                               newlen = strlen(curr_path) + strlen(namelist[sel+1]->d_name) + 2;\r
+                               newdir = malloc(newlen);\r
                                if (strcmp(namelist[sel+1]->d_name, "..") == 0) {\r
                                        char *start = curr_path;\r
                                        p = start + strlen(start) - 1;\r
@@ -354,7 +395,9 @@ static char *romsel_loop(char *curr_path)
                                ret = romsel_loop(newdir);\r
                                free(newdir);\r
                                break;\r
-                       } else {\r
+                       }\r
+                       else\r
+                       {\r
                                // unknown file type, happens on NTFS mounts. Try to guess.\r
                                FILE *tstf; int tmp;\r
                                strcpy(romFileName, curr_path);\r
@@ -375,7 +418,7 @@ static char *romsel_loop(char *curr_path)
        }\r
 \r
        if (n > 0) {\r
-               while(n--) free(namelist[n]);\r
+               while (n--) free(namelist[n]);\r
                free(namelist);\r
        }\r
 \r