From a8caf2309f85d7d50bf54d6a37473fc90fc0e53d Mon Sep 17 00:00:00 2001 From: Pwedge Date: Mon, 23 Dec 2019 21:31:53 -0800 Subject: [PATCH] Added support for serial port 2 (SP2 / SD2SP2) on Gamecube (#394) --- source/fceugx.h | 5 +++-- source/filebrowser.cpp | 15 ++++++++++++++- source/fileop.cpp | 15 +++++++++++++++ source/menu.cpp | 6 ++++++ source/preferences.cpp | 3 ++- 5 files changed, 40 insertions(+), 4 deletions(-) diff --git a/source/fceugx.h b/source/fceugx.h index 4e331ea..6bb5e9d 100644 --- a/source/fceugx.h +++ b/source/fceugx.h @@ -26,7 +26,7 @@ #define SILENT 1 const char pathPrefix[9][8] = -{ "", "sd:/", "usb:/", "dvd:/", "smb:/", "carda:/", "cardb:/" }; +{ "", "sd:/", "usb:/", "dvd:/", "smb:/", "carda:/", "cardb:/", "port2:/" }; enum { @@ -36,7 +36,8 @@ enum DEVICE_DVD, DEVICE_SMB, DEVICE_SD_SLOTA, - DEVICE_SD_SLOTB + DEVICE_SD_SLOTB, + DEVICE_SD_PORT2 }; enum diff --git a/source/filebrowser.cpp b/source/filebrowser.cpp index 0f202d1..5afa637 100644 --- a/source/filebrowser.cpp +++ b/source/filebrowser.cpp @@ -67,6 +67,8 @@ int autoLoadMethod() device = DEVICE_SD_SLOTA; else if(ChangeInterface(DEVICE_SD_SLOTB, SILENT)) device = DEVICE_SD_SLOTB; + else if(ChangeInterface(DEVICE_SD_PORT2, SILENT)) + device = DEVICE_SD_PORT2; else if(ChangeInterface(DEVICE_DVD, SILENT)) device = DEVICE_DVD; else if(ChangeInterface(DEVICE_SMB, SILENT)) @@ -100,6 +102,8 @@ int autoSaveMethod(bool silent) device = DEVICE_SD_SLOTA; else if(ChangeInterface(DEVICE_SD_SLOTB, SILENT)) device = DEVICE_SD_SLOTB; + else if(ChangeInterface(DEVICE_SD_PORT2, SILENT)) + device = DEVICE_SD_PORT2; else if(ChangeInterface(DEVICE_SMB, SILENT)) device = DEVICE_SMB; else if(!silent) @@ -169,7 +173,8 @@ bool IsDeviceRoot(char * path) strcmp(path, "dvd:/") == 0 || strcmp(path, "smb:/") == 0 || strcmp(path, "carda:/") == 0 || - strcmp(path, "cardb:/") == 0) + strcmp(path, "cardb:/") == 0 || + strcmp(path, "port2:/") ) { return true; } @@ -628,6 +633,14 @@ int BrowserChangeFolder() browserList[i].isdir = 1; browserList[i].icon = ICON_SD; 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 AddBrowserEntry(); sprintf(browserList[i].filename, "smb:/"); diff --git a/source/fileop.cpp b/source/fileop.cpp index 2bc1b72..94ed0ef 100644 --- a/source/fileop.cpp +++ b/source/fileop.cpp @@ -55,6 +55,7 @@ bool isMounted[7] = { false, false, false, false, false, false, false }; #else const DISC_INTERFACE* carda = &__io_gcsda; const DISC_INTERFACE* cardb = &__io_gcsdb; + const DISC_INTERFACE* port2 = &__io_gcsd2; const DISC_INTERFACE* dvd = &__io_gcdvd; #endif @@ -207,6 +208,7 @@ void UnmountAllFAT() #else fatUnmount("carda:"); fatUnmount("cardb:"); + fatUnmount("port2:"); #endif } @@ -250,6 +252,12 @@ static bool MountFAT(int device, int silent) sprintf(name2, "cardb:"); disc = cardb; break; + + case DEVICE_SD_PORT2: + sprintf(name, "port2"); + sprintf(name2, "port2:"); + disc = port2; + break; #endif default: return false; // unknown device @@ -293,6 +301,7 @@ void MountAllFAT() #else MountFAT(DEVICE_SD_SLOTA, SILENT); MountFAT(DEVICE_SD_SLOTB, SILENT); + MountFAT(DEVICE_SD_PORT2, SILENT); #endif } @@ -371,6 +380,11 @@ bool FindDevice(char * filepath, int * device) *device = DEVICE_SD_SLOTB; return true; } + else if(strncmp(filepath, "port2:", 6) == 0) + { + *device = DEVICE_SD_PORT2; + return true; + } else if(strncmp(filepath, "dvd:", 4) == 0) { *device = DEVICE_DVD; @@ -411,6 +425,7 @@ bool ChangeInterface(int device, bool silent) #else case DEVICE_SD_SLOTA: case DEVICE_SD_SLOTB: + case DEVICE_SD_PORT2: #endif mounted = MountFAT(device, silent); break; diff --git a/source/menu.cpp b/source/menu.cpp index 4ab5b11..dc5ce0e 100644 --- a/source/menu.cpp +++ b/source/menu.cpp @@ -3727,6 +3727,10 @@ static int MenuSettingsFile() GCSettings.LoadMethod++; if(GCSettings.SaveMethod == DEVICE_SD_SLOTB) GCSettings.SaveMethod++; + if(GCSettings.LoadMethod == DEVICE_SD_PORT2) + GCSettings.LoadMethod++; + if(GCSettings.SaveMethod == DEVICE_SD_PORT2) + GCSettings.SaveMethod++; #endif // correct load/save methods out of bounds @@ -3742,6 +3746,7 @@ static int MenuSettingsFile() 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_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"); else if (GCSettings.SaveMethod == DEVICE_SD) sprintf (options.value[1],"SD"); @@ -3749,6 +3754,7 @@ static int MenuSettingsFile() 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_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[3], 35, "%s", GCSettings.SaveFolder); diff --git a/source/preferences.cpp b/source/preferences.cpp index 39e7114..a1c815c 100644 --- a/source/preferences.cpp +++ b/source/preferences.cpp @@ -593,9 +593,10 @@ bool LoadPrefs() sprintf(filepath[3], "sd:/%s", APPFOLDER); sprintf(filepath[4], "usb:/%s", APPFOLDER); #else - numDevices = 2; + numDevices = 3; sprintf(filepath[0], "carda:/%s", APPFOLDER); sprintf(filepath[1], "cardb:/%s", APPFOLDER); + sprintf(filepath[2], "port2:/%s", APPFOLDER); #endif for(int i=0; i