changes for SD Gecko / DVD support on GameCube (thanks emukidid!)

This commit is contained in:
dborth 2010-04-02 21:02:27 +00:00
parent ff72b9024f
commit 3823996f63
2 changed files with 71 additions and 44 deletions

View File

@ -56,6 +56,10 @@ int autoLoadMethod()
device = DEVICE_SD;
else if(ChangeInterface(DEVICE_USB, SILENT))
device = DEVICE_USB;
else if(ChangeInterface(DEVICE_SD_SLOTA, SILENT))
device = DEVICE_SD_SLOTA;
else if(ChangeInterface(DEVICE_SD_SLOTB, SILENT))
device = DEVICE_SD_SLOTB;
else if(ChangeInterface(DEVICE_DVD, SILENT))
device = DEVICE_DVD;
else if(ChangeInterface(DEVICE_SMB, SILENT))
@ -85,6 +89,10 @@ int autoSaveMethod(bool silent)
device = DEVICE_SD;
else if(ChangeInterface(DEVICE_USB, SILENT))
device = DEVICE_USB;
else if(ChangeInterface(DEVICE_SD_SLOTA, SILENT))
device = DEVICE_SD_SLOTA;
else if(ChangeInterface(DEVICE_SD_SLOTB, SILENT))
device = DEVICE_SD_SLOTB;
else if(ChangeInterface(DEVICE_SMB, SILENT))
device = DEVICE_SMB;
else if(!silent)
@ -165,10 +173,12 @@ bool IsDeviceRoot(char * path)
if(path == NULL || path[0] == 0)
return false;
if(strcmp(path, "sd:/") == 0 ||
if( strcmp(path, "sd:/") == 0 ||
strcmp(path, "usb:/") == 0 ||
strcmp(path, "dvd:/") == 0 ||
strcmp(path, "smb:/") == 0)
strcmp(path, "smb:/") == 0 ||
strcmp(path, "carda:/") == 0 ||
strcmp(path, "cardb:/") == 0)
{
return true;
}
@ -558,6 +568,7 @@ int BrowserChangeFolder()
browser.dir[0] = 0;
int i=0;
#ifdef HW_RVL
AddBrowserEntry();
sprintf(browserList[i].filename, "sd:/");
sprintf(browserList[i].displayname, "SD Card");
@ -576,7 +587,6 @@ int BrowserChangeFolder()
browserList[i].icon = ICON_USB;
i++;
#ifdef HW_RVL
AddBrowserEntry();
sprintf(browserList[i].filename, "smb:/");
sprintf(browserList[i].displayname, "Network Share");
@ -585,8 +595,25 @@ int BrowserChangeFolder()
browserList[i].isdir = 1;
browserList[i].icon = ICON_SMB;
i++;
#endif
#else
AddBrowserEntry();
sprintf(browserList[i].filename, "carda:/");
sprintf(browserList[i].displayname, "SD Gecko Slot A");
browserList[i].length = 0;
browserList[i].mtime = 0;
browserList[i].isdir = 1;
browserList[i].icon = ICON_SD;
i++;
AddBrowserEntry();
sprintf(browserList[i].filename, "cardb:/");
sprintf(browserList[i].displayname, "SD Gecko Slot B");
browserList[i].length = 0;
browserList[i].mtime = 0;
browserList[i].isdir = 1;
browserList[i].icon = ICON_SD;
i++;
#endif
AddBrowserEntry();
sprintf(browserList[i].filename, "dvd:/");
sprintf(browserList[i].displayname, "Data DVD");

View File

@ -39,8 +39,8 @@
unsigned char savebuffer[SAVEBUFFERSIZE] ATTRIBUTE_ALIGN(32);
static mutex_t bufferLock = LWP_MUTEX_NULL;
FILE * file; // file pointer - the only one we should ever use!
bool unmountRequired[9] = { false, false, false, false, false, false, false, false, false };
bool isMounted[9] = { false, false, false, false, false, false, false, false, false };
bool unmountRequired[7] = { false, false, false, false, false, false, false };
bool isMounted[7] = { false, false, false, false, false, false, false };
#ifdef HW_RVL
const DISC_INTERFACE* sd = &__io_wiisd;
@ -83,6 +83,7 @@ ResumeDeviceThread()
void
HaltDeviceThread()
{
#ifdef HW_RVL
deviceHalt = true;
#ifdef HW_RVL
@ -93,6 +94,7 @@ HaltDeviceThread()
// wait for thread to finish
while(!LWP_ThreadIsSuspended(devicethread))
usleep(THREAD_SLEEP);
#endif
}
/****************************************************************************
@ -109,12 +111,14 @@ HaltParseThread()
usleep(THREAD_SLEEP);
}
/****************************************************************************
* devicecallback
*
* This checks our devices for changes (SD/USB removed) and
* initializes the network in the background
***************************************************************************/
#ifdef HW_RVL
static int devsleep = 1*1000*1000;
static void *
@ -130,7 +134,6 @@ devicecallback (void *arg)
while (1)
{
#ifdef HW_RVL
if(isMounted[DEVICE_SD])
{
if(!sd->isInserted()) // check if the device was removed
@ -151,24 +154,7 @@ devicecallback (void *arg)
UpdateCheck();
InitializeNetwork(SILENT);
#else
if(isMounted[DEVICE_SD_SLOTA])
{
if(!carda->isInserted()) // check if the device was removed
{
unmountRequired[DEVICE_SD_SLOTA] = true;
isMounted[DEVICE_SD_SLOTA] = false;
}
}
if(isMounted[DEVICE_SD_SLOTB])
{
if(!cardb->isInserted()) // check if the device was removed
{
unmountRequired[DEVICE_SD_SLOTB] = true;
isMounted[DEVICE_SD_SLOTB] = false;
}
}
#endif
if(isMounted[DEVICE_DVD])
{
if(!dvd->isInserted()) // check if the device was removed
@ -190,6 +176,7 @@ devicecallback (void *arg)
}
return NULL;
}
#endif
static void *
parsecallback (void *arg)
@ -212,7 +199,9 @@ parsecallback (void *arg)
void
InitDeviceThread()
{
#ifdef HW_RVL
LWP_CreateThread (&devicethread, devicecallback, NULL, NULL, 0, 40);
#endif
LWP_CreateThread (&parsethread, parsecallback, NULL, NULL, 0, 80);
}
@ -292,10 +281,14 @@ static bool MountFAT(int device, int silent)
if(mounted || silent)
break;
#ifdef HW_RVL
if(device == DEVICE_SD)
retry = ErrorPromptRetry("SD card not found!");
else
retry = ErrorPromptRetry("USB drive not found!");
#else
retry = ErrorPromptRetry("SD card not found!");
#endif
}
isMounted[device] = mounted;
@ -381,26 +374,26 @@ bool FindDevice(char * filepath, int * device)
*device = DEVICE_USB;
return true;
}
else if(strncmp(filepath, "dvd:", 4) == 0)
{
*device = DEVICE_DVD;
return true;
}
else if(strncmp(filepath, "smb:", 4) == 0)
{
*device = DEVICE_SMB;
return true;
}
else if(strncmp(filepath, "carda:", 5) == 0)
else if(strncmp(filepath, "carda:", 6) == 0)
{
*device = DEVICE_SD_SLOTA;
return true;
}
else if(strncmp(filepath, "cardb:", 5) == 0)
else if(strncmp(filepath, "cardb:", 6) == 0)
{
*device = DEVICE_SD_SLOTB;
return true;
}
else if(strncmp(filepath, "dvd:", 4) == 0)
{
*device = DEVICE_DVD;
return true;
}
return false;
}
@ -430,16 +423,23 @@ bool ChangeInterface(int device, bool silent)
switch(device)
{
#ifdef HW_RVL
case DEVICE_SD:
case DEVICE_USB:
#else
case DEVICE_SD_SLOTA:
case DEVICE_SD_SLOTB:
#endif
mounted = MountFAT(device, silent);
break;
case DEVICE_DVD:
mounted = MountDVD(silent);
break;
#ifdef HW_RVL
case DEVICE_SMB:
mounted = ConnectShare(silent);
break;
#endif
}
return mounted;
@ -642,12 +642,12 @@ ParseDirectory(bool waitParse)
parseHalt = false;
ParseDirEntries(); // index first 20 entries
LWP_ResumeThread(parsethread); // index remaining entries
if(waitParse) // wait for complete parsing
{
ShowAction("Loading...");
while(!LWP_ThreadIsSuspended(parsethread))
usleep(THREAD_SLEEP);