Commits

izdubar  committed 59bb658

* add configurable USB delay (3 is the default value currently used). If you have OPL stuck on yellow or orange screen (when using USB mode only), try increasing this value
* you can now configure an USB prefix folder. This is useful for people wanting to use the same external USB device either connected on their NAS and accessed through SMB, or directly (in traveler mode) to the PS2.

Usually NAS don't allow to share the "root" of the device, so you have to put your games into, let's say a "PS2SMB" folder.

When using this same device in USB mode, simply enter "PS2SMB" as USB prefix and your gone.

(The prefix is limited to 32 characters)

  • Participants
  • Parent commits cf10640

Comments (0)

Files changed (15)

File include/dialogs.h

 #define CFG_CHECKUSBFRAG		37
 #define CFG_LASTPLAYED			38
 #define CFG_DANDROP				39
+#define CFG_USBDELAY			40
+#define CFG_USBPREFIX			41
 
 extern struct UIItem diaIPConfig[];
 extern struct UIItem diaCompatConfig[];

File include/lang.h

 #define _STR_AUTOREFRESH			101
 #define _STR_ABOUT					102
 #define _STR_DEVS					103
-#define LANG_STR_COUNT 104
+#define _STR_USB_DELAY				104
+#define _STR_USB_PREFIX				105
+#define _STR_HINT_NEED_RESTART		106
+#define LANG_STR_COUNT 107
 
 // Maximum external languages supported
 #define MAX_LANGUAGE_FILES 15

File include/usbld.h

 int gEnableDandR;
 
 int gCheckUSBFragmentation;
+int gUSBDelay;
+char gUSBPrefix[32];
 
 int gRememberLastPlayed;
 

File loader/iopmgr.c

 
 		if (GameMode == USB_MODE) {
 			LoadIRXfromKernel(usbd_irx, size_usbd_irx, 0, NULL);
-			delay(3);
+			delay(USBDelay);
 #ifdef __LOAD_DEBUG_MODULES
 			LoadIRXfromKernel(smstcpip_irx, size_smstcpip_irx, 0, NULL);
 			LoadIRXfromKernel(smsmap_irx, size_smsmap_irx, g_ipconfig_len, g_ipconfig);
 	DPRINTF("Loading extra IOP modules...\n");
 	if (GameMode == USB_MODE) {
 		LoadIRXfromKernel(usbd_irx, size_usbd_irx, 0, NULL);
-		delay(3);
+		delay(USBDelay);
 #ifdef __LOAD_DEBUG_MODULES
 		LoadIRXfromKernel(smstcpip_irx, size_smstcpip_irx, 0, NULL);
 		LoadIRXfromKernel(smsmap_irx, size_smsmap_irx, g_ipconfig_len, g_ipconfig);

File loader/loader.c

 		GameMode = ETH_MODE;
 	else if (!_strncmp(argv[0], "HDD_MODE", 8))
 		GameMode = HDD_MODE;
-	DPRINTF("Game Mode = %d\n", GameMode);	
+	DPRINTF("Game Mode = %d\n", GameMode);
 
 	if (!_strncmp(&argv[0][9], "0", 1))
 		ExitMode = OSDS_MODE;
 		ExitMode = BOOT_MODE;
 	else if (!_strncmp(&argv[0][9], "2", 1))
 		ExitMode = APPS_MODE;
-	DPRINTF("Exit Mode = %d\n", ExitMode);	
+	DPRINTF("Exit Mode = %d\n", ExitMode);
 	
 	DisableDebug = 0;
-
 	if (!_strncmp(&argv[0][11], "1", 1)) {
 		DisableDebug = 1;
 		DPRINTF("Debug color screens enabled\n");
 	}
 
 	char *p = _strtok(&argv[0][13], " ");
+	USBDelay = _strtoui(p);
+	DPRINTF("USB Delay = %d\n", USBDelay);
+	p = _strtok(NULL, " ");
 	_strcpy(g_ps2_ip, p);
 	p = _strtok(NULL, " ");
 	_strcpy(g_ps2_netmask, p);

File loader/loader.h

 #define OSDS_MODE 0
 #define BOOT_MODE 1
 #define APPS_MODE 2
+int USBDelay;
 
 int DisableDebug;
 #define GS_BGCOLOUR *((volatile unsigned long int*)0x120000E0)

File src/dialogs.c

 	{UI_LABEL, 0, 1, -1, {.label = {NULL, _STR_DEBUG}}}, {UI_SPACER}, {UI_BOOL, CFG_DEBUG, 1, -1, {.intvalue = {0, 0}}}, {UI_BREAK},
 	{UI_LABEL, 0, 1, -1, {.label = {NULL, _STR_EXITTO}}}, {UI_SPACER}, {UI_ENUM, CFG_EXITTO, 1, -1, {.intvalue = {0, 0}}}, {UI_BREAK},
 	{UI_LABEL, 0, 1, -1, {.label = {NULL, _STR_DANDROP}}}, {UI_SPACER}, {UI_BOOL, CFG_DANDROP, 1, -1, {.intvalue = {0, 0}}}, {UI_BREAK},
+	{UI_LABEL, 0, 1, -1, {.label = {NULL, _STR_LASTPLAYED}}}, {UI_SPACER}, {UI_BOOL, CFG_LASTPLAYED, 1, -1, {.intvalue = {0, 0}}}, {UI_BREAK},
+
+	{UI_SPLITTER},
+
 	//{UI_LABEL, 0, 1, -1, {.label = {NULL, _STR_CHECKUSBFRAG}}}, {UI_SPACER}, {UI_BOOL, CFG_CHECKUSBFRAG, 1, -1, {.intvalue = {0, 0}}}, {UI_BREAK},
-	{UI_LABEL, 0, 1, -1, {.label = {NULL, _STR_LASTPLAYED}}}, {UI_SPACER}, {UI_BOOL, CFG_LASTPLAYED, 1, -1, {.intvalue = {0, 0}}}, {UI_BREAK},
+	{UI_LABEL, 0, 1, -1, {.label = {NULL, _STR_USB_DELAY}}}, {UI_SPACER}, {UI_INT, CFG_USBDELAY, 1, -1, {.intvalue = {3, 3, 0, 99}}}, {UI_BREAK},
+	{UI_LABEL, 0, 1, -1, {.label = {NULL, _STR_USB_PREFIX}}}, {UI_SPACER}, {UI_STRING, CFG_USBPREFIX, 1, _STR_HINT_NEED_RESTART, {.stringvalue = {"", "", NULL}}}, {UI_BREAK},
 
 	{UI_SPLITTER},
 

File src/ethsupport.c

 	ethSMBConnect();
 
 	// update Themes
-	char path[32];
+	char path[255];
 	sprintf(path, "%sTHM", ethPrefix);
 	thmAddElements(path, "\\");
 
 #ifdef VMC
 static int ethPrepareMcemu(base_game_info_t* game) {
 	char vmc[2][32];
-	char vmc_path[64];
+	char vmc_path[255];
 	u32 vmc_size;
 	int i, j, fd, size_mcemu_irx = 0;
 	smb_vmc_infos_t smb_vmc_infos;
 		memset(&smb_vmc_infos, 0, sizeof(smb_vmc_infos_t));
 		memset(&vmc_superblock, 0, sizeof(vmc_superblock_t));
 
-		snprintf(vmc_path, 64, "%s\\VMC\\%s.bin", ethPrefix, vmc[i]);
+		snprintf(vmc_path, 255, "%s\\VMC\\%s.bin", ethPrefix, vmc[i]);
 
 		fd = fileXioOpen(vmc_path, O_RDONLY, 0666);
 		if (fd >= 0) {
 				if(vmc_size == smb_vmc_infos.specs.card_size * smb_vmc_infos.specs.page_size) {
 					smb_vmc_infos.active = 1;
 					smb_vmc_infos.fid    = 0xFFFF;
-					snprintf(vmc_path, 64, "VMC\\%s.bin", vmc[i]);
-					strncpy(smb_vmc_infos.fname, vmc_path, 32);
+					snprintf(vmc_path, 255, "VMC\\%s.bin", vmc[i]);
+					strncpy(smb_vmc_infos.fname, vmc_path, 32); // maybe a too small size here ...
 
 					LOG("%s is a valid Vmc file\n", smb_vmc_infos.fname );
 				}
 	diaSetInt(diaConfig, CFG_DEBUG, gDisableDebug);
 	diaSetInt(diaConfig, CFG_EXITTO, gExitMode);
 	diaSetInt(diaConfig, CFG_DANDROP, gEnableDandR);
-	diaSetInt(diaConfig, CFG_CHECKUSBFRAG, gCheckUSBFragmentation);
+	//diaSetInt(diaConfig, CFG_CHECKUSBFRAG, gCheckUSBFragmentation);
+	diaSetInt(diaConfig, CFG_USBDELAY, gUSBDelay);
+	diaSetString(diaConfig, CFG_USBPREFIX, gUSBPrefix);
 	diaSetInt(diaConfig, CFG_LASTPLAYED, gRememberLastPlayed);
 	diaSetInt(diaConfig, CFG_DEFDEVICE, gDefaultDevice);
 	diaSetInt(diaConfig, CFG_USBMODE, gUSBStartMode);
 		diaGetInt(diaConfig, CFG_EXITTO, &gExitMode);
 		diaGetInt(diaConfig, CFG_DEBUG, &gDisableDebug);
 		diaGetInt(diaConfig, CFG_DANDROP, &gEnableDandR);
-		diaGetInt(diaConfig, CFG_CHECKUSBFRAG, &gCheckUSBFragmentation);
+		//diaGetInt(diaConfig, CFG_CHECKUSBFRAG, &gCheckUSBFragmentation);
+		diaGetInt(diaConfig, CFG_USBDELAY, &gUSBDelay);
+		diaGetString(diaConfig, CFG_USBPREFIX, gUSBPrefix);
 		diaGetInt(diaConfig, CFG_LASTPLAYED, &gRememberLastPlayed);
 		diaGetInt(diaConfig, CFG_DEFDEVICE, &gDefaultDevice);
 		diaGetInt(diaConfig, CFG_USBMODE, &gUSBStartMode);

File src/hddsupport.c

 	hddLoadModules();
 
 	// update Themes
-	char path[32];
+	char path[255];
 	sprintf(path, "%sTHM", hddPrefix);
 	thmAddElements(path, "/");
 
 #ifdef VMC
 static int hddPrepareMcemu(hdl_game_info_t* game) {
 	char vmc[2][32];
-	char vmc_path[64];
+	char vmc_path[255];
 	u32 vmc_size;
 	pfs_inode_t pfs_inode;
 	apa_header part_hdr;
 		memset(&vmc_superblock, 0, sizeof(vmc_superblock_t));
 		hdd_vmc_infos.active = 0;
 
-		snprintf(vmc_path, 64, "%sVMC/%s.bin", hddPrefix, vmc[i]);
+		snprintf(vmc_path, 255, "%sVMC/%s.bin", hddPrefix, vmc[i]);
 
 		fd = fileXioOpen(vmc_path, O_RDWR, FIO_S_IRUSR | FIO_S_IWUSR | FIO_S_IXUSR | FIO_S_IRGRP | FIO_S_IWGRP | FIO_S_IXGRP | FIO_S_IROTH | FIO_S_IWOTH | FIO_S_IXOTH);
 
 	"Error with VMC file, continue with physical MC ?",
 	"Automatic refresh",
 	"About",
-	"Coders"
+	"Coders",
+	"USB delay",
+	"USB prefix path",
+	"Restart will be required to apply the option"
 };
 
 static int guiLangID = 0;
 			configGetInt(configOPL, "disable_debug", &gDisableDebug);
 			configGetInt(configOPL, "enable_delete_rename", &gEnableDandR);
 			//configGetInt(configOPL, "check_usb_frag", &gCheckUSBFragmentation);
+			configGetInt(configOPL, "usb_delay", &gUSBDelay);
+			if (configGetStr(configOPL, "usb_prefix", &temp))
+				strncpy(gUSBPrefix, temp, 32);
 			configGetInt(configOPL, "remember_last", &gRememberLastPlayed);
 			configGetInt(configOPL, "usb_mode", &gUSBStartMode);
 			configGetInt(configOPL, "hdd_mode", &gHDDStartMode);
 		configSetInt(configOPL, "disable_debug", gDisableDebug);
 		configSetInt(configOPL, "enable_delete_rename", gEnableDandR);
 		//configSetInt(configOPL, "check_usb_frag", gCheckUSBFragmentation);
+		configSetInt(configOPL, "usb_delay", gUSBDelay);
+		configSetStr(configOPL, "usb_prefix", gUSBPrefix);
 		configSetInt(configOPL, "remember_last", gRememberLastPlayed);
 		configSetInt(configOPL, "usb_mode", gUSBStartMode);
 		configSetInt(configOPL, "hdd_mode", gHDDStartMode);
 	gEnableDandR = 0;
 	gRememberLastPlayed = 0;
 	gCheckUSBFragmentation = 0;
+	gUSBDelay = 3;
+	strncpy(gUSBPrefix, "", 32);
 	// disable art by default
 	gEnableArt = 0;
 	gWideScreen = 0;

File src/supportbase.c

 
 int sbIsSameSize(const char* prefix, int prevSize) {
 	int size = -1;
-	char path[64];
-	snprintf(path, 64, "%sul.cfg", prefix);
+	char path[255];
+	snprintf(path, 255, "%sul.cfg", prefix);
 
 	int fd = openFile(path, O_RDONLY);
 	if (fd >= 0) {
 void sbReadList(base_game_info_t **list, const char* prefix, int *fsize, int* gamecount) {
 	int fd, size, id = 0;
 	size_t count = 0;
-	char path[64];
+	char path[255];
 
 	free(*list);
 	*list = NULL;
 	struct game_list_t *dlist_head = NULL;
 	
 	// count iso games in "cd" directory
-	snprintf(path, 64, "%sCD", prefix);
+	snprintf(path, 255, "%sCD", prefix);
 	count += scanForISO(path, 0x12, &dlist_head);
 
 	// count iso games in "dvd" directory
-	snprintf(path, 64, "%sDVD", prefix);
+	snprintf(path, 255, "%sDVD", prefix);
 	count += scanForISO(path, 0x14, &dlist_head);
         
         
 	// count and process games in ul.cfg
-	snprintf(path, 64, "%sul.cfg", prefix);
+	snprintf(path, 255, "%sul.cfg", prefix);
 	fd = openFile(path, O_RDONLY);
 	if(fd >= 0) {
 		char buffer[0x040];
 }
 
 static void sbRebuildULCfg(base_game_info_t **list, const char* prefix, int gamecount, int excludeID) {
-	char path[64];
-	snprintf(path, 64, "%sul.cfg", prefix);
+	char path[255];
+	snprintf(path, 255, "%sul.cfg", prefix);
 
 	file_buffer_t* fileBuffer = openFileBuffer(path, O_WRONLY | O_CREAT | O_TRUNC, 0, 4096);
 	if (fileBuffer) {

File src/system.c

 	FlushCache(0);
 	FlushCache(2);
 
-	sprintf(config_str, "%s %d %d %d.%d.%d.%d %d.%d.%d.%d %d.%d.%d.%d", mode_str, gExitMode, gDisableDebug, ps2_ip[0], ps2_ip[1], ps2_ip[2], ps2_ip[3], \
+	sprintf(config_str, "%s %d %d %d %d.%d.%d.%d %d.%d.%d.%d %d.%d.%d.%d", mode_str, gExitMode, gDisableDebug, gUSBDelay, \
+		ps2_ip[0], ps2_ip[1], ps2_ip[2], ps2_ip[3], \
 		ps2_netmask[0], ps2_netmask[1], ps2_netmask[2], ps2_netmask[3], \
 		ps2_gateway[0], ps2_gateway[1], ps2_gateway[2], ps2_gateway[3]);
 

File src/usbsupport.c

 void *usbd_irx;
 int size_usbd_irx;
 
-static char usbPrefix[8];
+static char usbPrefix[40];
 static int usbULSizePrev = 0;
 static int usbGameCount = 0;
 static base_game_info_t *usbGames;
 
 int usbFindPartition(char *target, char *name) {
 	int i, fd;
-	char path[64];
+	char path[255];
 
 	for(i=0; i<5; i++) {
-		snprintf(path, 64, "mass%d:%s", i, name);
+		snprintf(path, 255, "mass%d:%s/%s", i, gUSBPrefix, name);
 		fd = fioOpen(path, O_RDONLY);
 
 		if(fd >= 0) {
-			snprintf(target, 8, "mass%d:", i);
+			snprintf(target, 255, "mass%d:%s/", i, gUSBPrefix);
 			fioClose(fd);
 			return 1;
 		}
 	}
 
 	// default to first partition (for themes, ...)
-	sprintf(target, "mass0:");
+	sprintf(target, "mass0:%s/", gUSBPrefix);
 	return 0;
 }
 
 
 	// update Themes
 	usbFindPartition(usbPrefix, "ul.cfg");
-	char path[32];
+	char path[255];
 	sprintf(path, "%sTHM", usbPrefix);
 	thmAddElements(path, "/");
 
 	sysLoadModuleBuffer(usbd_irx, size_usbd_irx, 0, NULL);
 	sysLoadModuleBuffer(&usbhdfsd_irx, size_usbhdfsd_irx, 0, NULL);
 
-	delay(3);
+	delay(gUSBDelay);
 
 	LOG("usbLoadModules: modules loaded\n");
 }
 #ifdef VMC
 static int usbPrepareMcemu(base_game_info_t* game) {
 	char vmc[2][32];
-	char vmc_path[64];
+	char vmc_path[255];
 	u32 vmc_size;
 	int i, j, fd, size_mcemu_irx = 0;
 	usb_vmc_infos_t usb_vmc_infos;
 		memset(&usb_vmc_infos, 0, sizeof(usb_vmc_infos_t));
 		memset(&vmc_superblock, 0, sizeof(vmc_superblock_t));
 
-		snprintf(vmc_path, 64, "%sVMC/%s.bin", usbPrefix, vmc[i]);
+		snprintf(vmc_path, 255, "%sVMC/%s.bin", usbPrefix, vmc[i]);
 
 		fd = fioOpen(vmc_path, O_RDWR);
 		if (fd >= 0) {
 					int fd1 = fioDopen(usbPrefix);
 
 					if (fd1 >= 0) {
-						snprintf(vmc_path, 64, "VMC/%s.bin", vmc[i]);
+						snprintf(vmc_path, 255, "VMC/%s.bin", vmc[i]);
 						// Check vmc cluster chain (write operation can cause dammage)
 						if(fioIoctl(fd1, 0xCAFEC0DE, vmc_path)) {
 							LOG("Cluster Chain OK\n");
 }
 
 static int usbGetArt(char* name, GSTEXTURE* resultTex, const char* type, short psm) {
-	char path[64];
+	char path[255];
 	sprintf(path, "%sART/%s_%s", usbPrefix, name, type);
 	return texDiscoverLoad(resultTex, path, -1, psm);
 }