From f3dfae985da2862cdba19d973e1f0cdcca0d816b Mon Sep 17 00:00:00 2001 From: "fabio.olimpieri" Date: Sat, 19 Jan 2013 23:05:17 +0000 Subject: [PATCH] Optimization for install on usb device, case insensitive file order --- src/cfgfile.c | 2 +- src/gui-sdl/gui-sdl.c | 14 +++++++++++--- src/gui-sdl/menu.c | 2 +- src/include/options.h | 1 + src/main.c | 23 ++++++++++++++++++----- src/targets/t-wii.h | 1 + 6 files changed, 33 insertions(+), 10 deletions(-) diff --git a/src/cfgfile.c b/src/cfgfile.c index a416aaf..e053b78 100644 --- a/src/cfgfile.c +++ b/src/cfgfile.c @@ -2495,7 +2495,7 @@ void default_prefs (struct uae_prefs *p, int type) strcpy (p->SmbPwd, "Password"); strcpy (p->SmbShare, "Share"); strcpy (p->SmbIp, "192.168.0.1"); - p->Port= PORT_SD; + p->Port= PORT_DEFAULT; p->rumble= 0; p->gfx_correct_ratio = 100; #endif diff --git a/src/gui-sdl/gui-sdl.c b/src/gui-sdl/gui-sdl.c index d3b1173..15d813d 100644 --- a/src/gui-sdl/gui-sdl.c +++ b/src/gui-sdl/gui-sdl.c @@ -32,7 +32,7 @@ #define DEBUG_LOG(...) do ; while(0) #endif -extern int usbismount, smbismount; +extern int usbismount, smbismount, sdismount; extern const char *strdup_path_expand (const char *src); @@ -156,7 +156,7 @@ static const char *graphic_messages[] = { /*06*/ "Floppy sound", /*07*/ "^|on|off", /*08*/ "Port", - /*09*/ "^|SD|USB|SMB", + /*09*/ "^|DEFAULT|SD|USB|SMB", /*10*/ "Rumble", /*11*/ "^|on|off", NULL @@ -488,11 +488,19 @@ static void set_Port(int which) { switch (which) { - case PORT_SD: + case PORT_DEFAULT: prefs_set_attr ("floppy_path", strdup_path_expand (TARGET_FLOPPY_PATH)); changed_prefs.Port = which; currprefs.Port = changed_prefs.Port; break; + case PORT_SD: + if (sdismount) { + prefs_set_attr ("floppy_path", strdup_path_expand (TARGET_SD_PATH)); + changed_prefs.Port = which; + currprefs.Port = changed_prefs.Port;} + else + msgInfo("SD is not mounted",3000,NULL); + break; case PORT_USB: if (usbismount) { prefs_set_attr ("floppy_path", strdup_path_expand (TARGET_USB_PATH)); diff --git a/src/gui-sdl/menu.c b/src/gui-sdl/menu.c index 7f882d9..7be1917 100644 --- a/src/gui-sdl/menu.c +++ b/src/gui-sdl/menu.c @@ -229,7 +229,7 @@ static int cmpstringp(const void *p1, const void *p2) return -1; if (*p1_s != '[' && *p2_s == '[') return 1; - return strcmp(* (char * const *) p1, * (char * const *) p2); + return strcasecmp(* (char * const *) p1, * (char * const *) p2); } /* Return true if name ends with ext (for filenames) */ diff --git a/src/include/options.h b/src/include/options.h index 3d2c22b..213bbe8 100644 --- a/src/include/options.h +++ b/src/include/options.h @@ -19,6 +19,7 @@ struct strlist { // Device Port enum Porttype { + PORT_DEFAULT, // Load from device of dol file PORT_SD, // Load from SD card PORT_USB, // Load from USB port PORT_SMB //Load from network diff --git a/src/main.c b/src/main.c index aba85cd..deebe19 100644 --- a/src/main.c +++ b/src/main.c @@ -78,6 +78,7 @@ struct gui_info gui_data; bool usbismount = false; bool networkisinit = false; bool smbismount = false; +bool sdismount = false; #if defined(GEKKO) @@ -1092,14 +1093,26 @@ int main (int argc, char **argv) printf("\x1b[2;0H"); //initialize libfat library - if (!fatInitDefault()) - { - printf("Couldn't initialize SD fat subsytem\n"); + if (fatInitDefault()) + printf("FAT subsytem initialized\n\n"); + else + { + printf("Couldn't initialize FAT subsytem\n\n"); sleep(3); exit(0); - } - else + } + + DIR *dp; + + dp = opendir ("sd:/"); + if (dp) sdismount = 1; else sdismount = 0; + + if (sdismount) printf("SD FAT subsytem initialized\n\n"); + else + printf("Couldn't initialize SD fat subsytem\n\n"); + + if (sdismount) closedir (dp); usbismount = InitUSB(); diff --git a/src/targets/t-wii.h b/src/targets/t-wii.h index 93e1ec7..c6c34de 100644 --- a/src/targets/t-wii.h +++ b/src/targets/t-wii.h @@ -12,6 +12,7 @@ #define TARGET_FLOPPY_PATH "/uae/floppies" #define TARGET_HARDFILE_PATH "/uae/harddisks" #define TARGET_SAVESTATE_PATH "/uae/saves" +#define TARGET_SD_PATH "sd:/" #define TARGET_USB_PATH "usb:/" #define TARGET_SMB_PATH "smb:/"