Added support for serial port 2 (SP2 / SD2SP2) on Gamecube (#884)

This commit is contained in:
Pwedge 2019-12-23 21:30:59 -08:00 committed by dborth
parent abbf71f2d9
commit cd264c16da
5 changed files with 39 additions and 5 deletions

View File

@ -71,6 +71,8 @@ int autoLoadMethod()
device = DEVICE_SD_SLOTA; device = DEVICE_SD_SLOTA;
else if(ChangeInterface(DEVICE_SD_SLOTB, SILENT)) else if(ChangeInterface(DEVICE_SD_SLOTB, SILENT))
device = DEVICE_SD_SLOTB; device = DEVICE_SD_SLOTB;
else if(ChangeInterface(DEVICE_SD_PORT2, SILENT))
device = DEVICE_SD_PORT2;
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))
@ -104,6 +106,8 @@ int autoSaveMethod(bool silent)
device = DEVICE_SD_SLOTA; device = DEVICE_SD_SLOTA;
else if(ChangeInterface(DEVICE_SD_SLOTB, SILENT)) else if(ChangeInterface(DEVICE_SD_SLOTB, SILENT))
device = DEVICE_SD_SLOTB; device = DEVICE_SD_SLOTB;
else if(ChangeInterface(DEVICE_SD_PORT2, SILENT))
device = DEVICE_SD_PORT2;
else if(ChangeInterface(DEVICE_SMB, SILENT)) else if(ChangeInterface(DEVICE_SMB, SILENT))
device = DEVICE_SMB; device = DEVICE_SMB;
else if(!silent) else if(!silent)
@ -173,7 +177,8 @@ bool IsDeviceRoot(char * path)
strcmp(path, "dvd:/") == 0 || strcmp(path, "dvd:/") == 0 ||
strcmp(path, "smb:/") == 0 || strcmp(path, "smb:/") == 0 ||
strcmp(path, "carda:/") == 0 || strcmp(path, "carda:/") == 0 ||
strcmp(path, "cardb:/") == 0) strcmp(path, "cardb:/") == 0 ||
strcmp(path, "port2:/") == 0)
{ {
return true; return true;
} }
@ -618,6 +623,14 @@ int BrowserChangeFolder()
browserList[i].isdir = 1; browserList[i].isdir = 1;
browserList[i].icon = ICON_SD; browserList[i].icon = ICON_SD;
i++; i++;
AddBrowserEntry();
sprintf(browserList[i].filename, "port2:/");
sprintf(browserList[i].displayname, "SD in SP2");
browserList[i].length = 0;
browserList[i].isdir = 1;
browserList[i].icon = ICON_SD;
i++;
#endif #endif
AddBrowserEntry(); AddBrowserEntry();
sprintf(browserList[i].filename, "smb:/"); sprintf(browserList[i].filename, "smb:/");

View File

@ -53,6 +53,7 @@ bool isMounted[7] = { false, false, false, false, false, false, false };
#else #else
const DISC_INTERFACE* carda = &__io_gcsda; const DISC_INTERFACE* carda = &__io_gcsda;
const DISC_INTERFACE* cardb = &__io_gcsdb; const DISC_INTERFACE* cardb = &__io_gcsdb;
const DISC_INTERFACE* port2 = &__io_gcsd2;
const DISC_INTERFACE* dvd = &__io_gcdvd; const DISC_INTERFACE* dvd = &__io_gcdvd;
#endif #endif
@ -205,6 +206,7 @@ void UnmountAllFAT()
#else #else
fatUnmount("carda:"); fatUnmount("carda:");
fatUnmount("cardb:"); fatUnmount("cardb:");
fatUnmount("port2:");
#endif #endif
} }
@ -242,12 +244,16 @@ static bool MountFAT(int device, int silent)
sprintf(name2, "carda:"); sprintf(name2, "carda:");
disc = carda; disc = carda;
break; break;
case DEVICE_SD_SLOTB: case DEVICE_SD_SLOTB:
sprintf(name, "cardb"); sprintf(name, "cardb");
sprintf(name2, "cardb:"); sprintf(name2, "cardb:");
disc = cardb; disc = cardb;
break; break;
case DEVICE_SD_PORT2:
sprintf(name, "port2");
sprintf(name2, "port2:");
disc = port2;
break;
#endif #endif
default: default:
return false; // unknown device return false; // unknown device
@ -291,6 +297,7 @@ void MountAllFAT()
#else #else
MountFAT(DEVICE_SD_SLOTA, SILENT); MountFAT(DEVICE_SD_SLOTA, SILENT);
MountFAT(DEVICE_SD_SLOTB, SILENT); MountFAT(DEVICE_SD_SLOTB, SILENT);
MountFAT(DEVICE_SD_PORT2, SILENT);
#endif #endif
} }
@ -369,6 +376,11 @@ bool FindDevice(char * filepath, int * device)
*device = DEVICE_SD_SLOTB; *device = DEVICE_SD_SLOTB;
return true; return true;
} }
else if(strncmp(filepath, "port2:", 6) == 0)
{
*device = DEVICE_SD_PORT2;
return true;
}
else if(strncmp(filepath, "dvd:", 4) == 0) else if(strncmp(filepath, "dvd:", 4) == 0)
{ {
*device = DEVICE_DVD; *device = DEVICE_DVD;
@ -409,6 +421,7 @@ bool ChangeInterface(int device, bool silent)
#else #else
case DEVICE_SD_SLOTA: case DEVICE_SD_SLOTA:
case DEVICE_SD_SLOTB: case DEVICE_SD_SLOTB:
case DEVICE_SD_PORT2:
#endif #endif
mounted = MountFAT(device, silent); mounted = MountFAT(device, silent);
break; break;

View File

@ -3844,6 +3844,10 @@ static int MenuSettingsFile()
GCSettings.LoadMethod++; GCSettings.LoadMethod++;
if(GCSettings.SaveMethod == DEVICE_SD_SLOTB) if(GCSettings.SaveMethod == DEVICE_SD_SLOTB)
GCSettings.SaveMethod++; GCSettings.SaveMethod++;
if(GCSettings.LoadMethod == DEVICE_SD_PORT2)
GCSettings.LoadMethod++;
if(GCSettings.SaveMethod == DEVICE_SD_PORT2)
GCSettings.SaveMethod++;
#endif #endif
// correct load/save methods out of bounds // correct load/save methods out of bounds
@ -3859,6 +3863,7 @@ static int MenuSettingsFile()
else if (GCSettings.LoadMethod == DEVICE_SMB) sprintf (options.value[0],"Network"); else if (GCSettings.LoadMethod == DEVICE_SMB) sprintf (options.value[0],"Network");
else if (GCSettings.LoadMethod == DEVICE_SD_SLOTA) sprintf (options.value[0],"SD Gecko Slot A"); else if (GCSettings.LoadMethod == DEVICE_SD_SLOTA) sprintf (options.value[0],"SD Gecko Slot A");
else if (GCSettings.LoadMethod == DEVICE_SD_SLOTB) sprintf (options.value[0],"SD Gecko Slot B"); else if (GCSettings.LoadMethod == DEVICE_SD_SLOTB) sprintf (options.value[0],"SD Gecko Slot B");
else if (GCSettings.LoadMethod == DEVICE_SD_PORT2) sprintf (options.value[0],"SD in SP2");
if (GCSettings.SaveMethod == DEVICE_AUTO) sprintf (options.value[1],"Auto Detect"); if (GCSettings.SaveMethod == DEVICE_AUTO) sprintf (options.value[1],"Auto Detect");
else if (GCSettings.SaveMethod == DEVICE_SD) sprintf (options.value[1],"SD"); else if (GCSettings.SaveMethod == DEVICE_SD) sprintf (options.value[1],"SD");
@ -3866,6 +3871,7 @@ static int MenuSettingsFile()
else if (GCSettings.SaveMethod == DEVICE_SMB) sprintf (options.value[1],"Network"); else if (GCSettings.SaveMethod == DEVICE_SMB) sprintf (options.value[1],"Network");
else if (GCSettings.SaveMethod == DEVICE_SD_SLOTA) sprintf (options.value[1],"SD Gecko Slot A"); else if (GCSettings.SaveMethod == DEVICE_SD_SLOTA) sprintf (options.value[1],"SD Gecko Slot A");
else if (GCSettings.SaveMethod == DEVICE_SD_SLOTB) sprintf (options.value[1],"SD Gecko Slot B"); else if (GCSettings.SaveMethod == DEVICE_SD_SLOTB) sprintf (options.value[1],"SD Gecko Slot B");
else if (GCSettings.SaveMethod == DEVICE_SD_PORT2) sprintf (options.value[1],"SD in SP2");
snprintf (options.value[2], 35, "%s", GCSettings.LoadFolder); snprintf (options.value[2], 35, "%s", GCSettings.LoadFolder);
snprintf (options.value[3], 35, "%s", GCSettings.SaveFolder); snprintf (options.value[3], 35, "%s", GCSettings.SaveFolder);

View File

@ -666,9 +666,10 @@ bool LoadPrefs()
sprintf(filepath[3], "sd:/%s", APPFOLDER); sprintf(filepath[3], "sd:/%s", APPFOLDER);
sprintf(filepath[4], "usb:/%s", APPFOLDER); sprintf(filepath[4], "usb:/%s", APPFOLDER);
#else #else
numDevices = 2; numDevices = 3;
sprintf(filepath[0], "carda:/%s", APPFOLDER); sprintf(filepath[0], "carda:/%s", APPFOLDER);
sprintf(filepath[1], "cardb:/%s", APPFOLDER); sprintf(filepath[1], "cardb:/%s", APPFOLDER);
sprintf(filepath[2], "port2:/%s", APPFOLDER);
#endif #endif
for(int i=0; i<numDevices; i++) for(int i=0; i<numDevices; i++)

View File

@ -29,7 +29,7 @@
#define SILENT 1 #define SILENT 1
const char pathPrefix[9][8] = const char pathPrefix[9][8] =
{ "", "sd:/", "usb:/", "dvd:/", "smb:/", "carda:/", "cardb:/" }; { "", "sd:/", "usb:/", "dvd:/", "smb:/", "carda:/", "cardb:/", "port2:/" };
enum { enum {
DEVICE_AUTO, DEVICE_AUTO,
@ -38,7 +38,8 @@ enum {
DEVICE_DVD, DEVICE_DVD,
DEVICE_SMB, DEVICE_SMB,
DEVICE_SD_SLOTA, DEVICE_SD_SLOTA,
DEVICE_SD_SLOTB DEVICE_SD_SLOTB,
DEVICE_SD_PORT2
}; };
enum { enum {