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

This commit is contained in:
dborth 2010-04-02 21:02:38 +00:00
parent 68d4aa225e
commit ad987a37ad
2 changed files with 70 additions and 44 deletions

View File

@ -56,6 +56,10 @@ int autoLoadMethod()
device = DEVICE_SD; device = DEVICE_SD;
else if(ChangeInterface(DEVICE_USB, SILENT)) else if(ChangeInterface(DEVICE_USB, SILENT))
device = DEVICE_USB; 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)) else if(ChangeInterface(DEVICE_DVD, SILENT))
device = DEVICE_DVD; device = DEVICE_DVD;
else if(ChangeInterface(DEVICE_SMB, SILENT)) else if(ChangeInterface(DEVICE_SMB, SILENT))
@ -85,6 +89,10 @@ int autoSaveMethod(bool silent)
device = DEVICE_SD; device = DEVICE_SD;
else if(ChangeInterface(DEVICE_USB, SILENT)) else if(ChangeInterface(DEVICE_USB, SILENT))
device = DEVICE_USB; 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)) else if(ChangeInterface(DEVICE_SMB, SILENT))
device = DEVICE_SMB; device = DEVICE_SMB;
else if(!silent) else if(!silent)
@ -168,7 +176,9 @@ bool IsDeviceRoot(char * path)
if( strcmp(path, "sd:/") == 0 || if( strcmp(path, "sd:/") == 0 ||
strcmp(path, "usb:/") == 0 || strcmp(path, "usb:/") == 0 ||
strcmp(path, "dvd:/") == 0 || strcmp(path, "dvd:/") == 0 ||
strcmp(path, "smb:/") == 0) strcmp(path, "smb:/") == 0 ||
strcmp(path, "carda:/") == 0 ||
strcmp(path, "cardb:/") == 0)
{ {
return true; return true;
} }
@ -489,8 +499,7 @@ int BrowserLoadFile()
browser.selIndex = 0; browser.selIndex = 0;
BrowserChangeFolder(); BrowserChangeFolder();
} }
ErrorPrompt("Error loading game!");
ErrorPrompt("Error loading ROM!");
} }
else else
{ {
@ -535,6 +544,7 @@ int BrowserChangeFolder()
browser.dir[0] = 0; browser.dir[0] = 0;
int i=0; int i=0;
#ifdef HW_RVL
AddBrowserEntry(); AddBrowserEntry();
sprintf(browserList[i].filename, "sd:/"); sprintf(browserList[i].filename, "sd:/");
sprintf(browserList[i].displayname, "SD Card"); sprintf(browserList[i].displayname, "SD Card");
@ -553,7 +563,6 @@ int BrowserChangeFolder()
browserList[i].icon = ICON_USB; browserList[i].icon = ICON_USB;
i++; i++;
#ifdef HW_RVL
AddBrowserEntry(); AddBrowserEntry();
sprintf(browserList[i].filename, "smb:/"); sprintf(browserList[i].filename, "smb:/");
sprintf(browserList[i].displayname, "Network Share"); sprintf(browserList[i].displayname, "Network Share");
@ -562,8 +571,25 @@ int BrowserChangeFolder()
browserList[i].isdir = 1; browserList[i].isdir = 1;
browserList[i].icon = ICON_SMB; browserList[i].icon = ICON_SMB;
i++; 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(); AddBrowserEntry();
sprintf(browserList[i].filename, "dvd:/"); sprintf(browserList[i].filename, "dvd:/");
sprintf(browserList[i].displayname, "Data DVD"); sprintf(browserList[i].displayname, "Data DVD");

View File

@ -38,8 +38,8 @@
unsigned char savebuffer[SAVEBUFFERSIZE] ATTRIBUTE_ALIGN(32); unsigned char savebuffer[SAVEBUFFERSIZE] ATTRIBUTE_ALIGN(32);
static mutex_t bufferLock = LWP_MUTEX_NULL; static mutex_t bufferLock = LWP_MUTEX_NULL;
FILE * file; // file pointer - the only one we should ever use! FILE * file; // file pointer - the only one we should ever use!
bool unmountRequired[9] = { false, false, false, false, false, false, false, false, false }; bool unmountRequired[7] = { false, false, false, false, false, false, false };
bool isMounted[9] = { false, false, false, false, false, false, false, false, false }; bool isMounted[7] = { false, false, false, false, false, false, false };
#ifdef HW_RVL #ifdef HW_RVL
const DISC_INTERFACE* sd = &__io_wiisd; const DISC_INTERFACE* sd = &__io_wiisd;
@ -82,6 +82,7 @@ ResumeDeviceThread()
void void
HaltDeviceThread() HaltDeviceThread()
{ {
#ifdef HW_RVL
deviceHalt = true; deviceHalt = true;
#ifdef HW_RVL #ifdef HW_RVL
@ -92,6 +93,7 @@ HaltDeviceThread()
// wait for thread to finish // wait for thread to finish
while(!LWP_ThreadIsSuspended(devicethread)) while(!LWP_ThreadIsSuspended(devicethread))
usleep(THREAD_SLEEP); usleep(THREAD_SLEEP);
#endif
} }
/**************************************************************************** /****************************************************************************
@ -108,12 +110,14 @@ HaltParseThread()
usleep(THREAD_SLEEP); usleep(THREAD_SLEEP);
} }
/**************************************************************************** /****************************************************************************
* devicecallback * devicecallback
* *
* This checks our devices for changes (SD/USB removed) and * This checks our devices for changes (SD/USB removed) and
* initializes the network in the background * initializes the network in the background
***************************************************************************/ ***************************************************************************/
#ifdef HW_RVL
static int devsleep = 1*1000*1000; static int devsleep = 1*1000*1000;
static void * static void *
@ -129,7 +133,6 @@ devicecallback (void *arg)
while (1) while (1)
{ {
#ifdef HW_RVL
if(isMounted[DEVICE_SD]) if(isMounted[DEVICE_SD])
{ {
if(!sd->isInserted()) // check if the device was removed if(!sd->isInserted()) // check if the device was removed
@ -150,24 +153,7 @@ devicecallback (void *arg)
UpdateCheck(); UpdateCheck();
InitializeNetwork(SILENT); 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(isMounted[DEVICE_DVD])
{ {
if(!dvd->isInserted()) // check if the device was removed if(!dvd->isInserted()) // check if the device was removed
@ -189,6 +175,7 @@ devicecallback (void *arg)
} }
return NULL; return NULL;
} }
#endif
static void * static void *
parsecallback (void *arg) parsecallback (void *arg)
@ -211,7 +198,9 @@ parsecallback (void *arg)
void void
InitDeviceThread() InitDeviceThread()
{ {
#ifdef HW_RVL
LWP_CreateThread (&devicethread, devicecallback, NULL, NULL, 0, 40); LWP_CreateThread (&devicethread, devicecallback, NULL, NULL, 0, 40);
#endif
LWP_CreateThread (&parsethread, parsecallback, NULL, NULL, 0, 80); LWP_CreateThread (&parsethread, parsecallback, NULL, NULL, 0, 80);
} }
@ -291,10 +280,14 @@ static bool MountFAT(int device, int silent)
if(mounted || silent) if(mounted || silent)
break; break;
#ifdef HW_RVL
if(device == DEVICE_SD) if(device == DEVICE_SD)
retry = ErrorPromptRetry("SD card not found!"); retry = ErrorPromptRetry("SD card not found!");
else else
retry = ErrorPromptRetry("USB drive not found!"); retry = ErrorPromptRetry("USB drive not found!");
#else
retry = ErrorPromptRetry("SD card not found!");
#endif
} }
isMounted[device] = mounted; isMounted[device] = mounted;
@ -380,26 +373,26 @@ bool FindDevice(char * filepath, int * device)
*device = DEVICE_USB; *device = DEVICE_USB;
return true; return true;
} }
else if(strncmp(filepath, "dvd:", 4) == 0)
{
*device = DEVICE_DVD;
return true;
}
else if(strncmp(filepath, "smb:", 4) == 0) else if(strncmp(filepath, "smb:", 4) == 0)
{ {
*device = DEVICE_SMB; *device = DEVICE_SMB;
return true; return true;
} }
else if(strncmp(filepath, "carda:", 5) == 0) else if(strncmp(filepath, "carda:", 6) == 0)
{ {
*device = DEVICE_SD_SLOTA; *device = DEVICE_SD_SLOTA;
return true; return true;
} }
else if(strncmp(filepath, "cardb:", 5) == 0) else if(strncmp(filepath, "cardb:", 6) == 0)
{ {
*device = DEVICE_SD_SLOTB; *device = DEVICE_SD_SLOTB;
return true; return true;
} }
else if(strncmp(filepath, "dvd:", 4) == 0)
{
*device = DEVICE_DVD;
return true;
}
return false; return false;
} }
@ -429,16 +422,23 @@ bool ChangeInterface(int device, bool silent)
switch(device) switch(device)
{ {
#ifdef HW_RVL
case DEVICE_SD: case DEVICE_SD:
case DEVICE_USB: case DEVICE_USB:
#else
case DEVICE_SD_SLOTA:
case DEVICE_SD_SLOTB:
#endif
mounted = MountFAT(device, silent); mounted = MountFAT(device, silent);
break; break;
case DEVICE_DVD: case DEVICE_DVD:
mounted = MountDVD(silent); mounted = MountDVD(silent);
break; break;
#ifdef HW_RVL
case DEVICE_SMB: case DEVICE_SMB:
mounted = ConnectShare(silent); mounted = ConnectShare(silent);
break; break;
#endif
} }
return mounted; return mounted;
@ -602,7 +602,7 @@ ParseDirectory(bool waitParse)
return -1; return -1;
if(dirIter == NULL) if(dirIter == NULL)
retry = ErrorPromptRetry("Error opening directory"); retry = ErrorPromptRetry("Error opening directory!");
} }
// if we can't open the dir, try higher levels // if we can't open the dir, try higher levels
@ -641,12 +641,12 @@ ParseDirectory(bool waitParse)
parseHalt = false; parseHalt = false;
ParseDirEntries(); // index first 20 entries ParseDirEntries(); // index first 20 entries
LWP_ResumeThread(parsethread); // index remaining entries LWP_ResumeThread(parsethread); // index remaining entries
if(waitParse) // wait for complete parsing if(waitParse) // wait for complete parsing
{ {
ShowAction("Loading..."); ShowAction("Loading...");
while(!LWP_ThreadIsSuspended(parsethread)) while(!LWP_ThreadIsSuspended(parsethread))
usleep(THREAD_SLEEP); usleep(THREAD_SLEEP);