Commits

hominem_te_esse committed cf18247

* CRITICAL FIX for 4K disk. It was broken since the beginning for both UL and ISO (2 bugs, one when checking for the cluster size for UL, and one for UL/ISO when patching the usb_cdvdman_irx)
* Fix for the ISO games filename extension that was required to be lowercase ".iso" (impact on Linux only). Now you can have any extension case you want.

Comments (0)

Files changed (6)

include/supportbase.h

 {
 	char name[ISO_GAME_NAME_MAX + 1]; // MUST be the higher value from UL / ISO
 	char startup[GAME_STARTUP_MAX + 1];
+	char extension[5];
 	unsigned char parts;
 	unsigned char media;
 	unsigned short isISO;
 
 int sbIsSameSize(const char* prefix, int prevSize);
 void sbReadList(base_game_info_t **list, const char* prefix, int *fsize, int* gamecount);
-int sbPrepare(base_game_info_t* game, config_set_t* configSet, char* isoname, int size_cdvdman, void** cdvdman_irx, int* patchindex);
+int sbPrepare(base_game_info_t* game, config_set_t* configSet, int size_cdvdman, void** cdvdman_irx, int* patchindex);
 void sbDelete(base_game_info_t **list, const char* prefix, const char* sep, int gamecount, int id);
 void sbRename(base_game_info_t **list, const char* prefix, const char* sep, int gamecount, int id, char* newname);
 config_set_t* sbPopulateConfig(base_game_info_t* game, const char* prefix, const char* sep);
 #include "include/mcemu.h"
 #endif
 
-#define SYS_LOAD_MC_MODULES	0x01
+#define SYS_LOAD_MC_MODULES		0x01
 #define SYS_LOAD_PAD_MODULES	0x02
 
 void delay(int count);

modules/iopcore/cdvdman/cdvdman.c

 	if (g_part_start[0]) {
 		char *game_name = (char *)&g_part_start[0];
 		if (g_pc_prefix[0]) {
-			path_str = (g_ISO_media == 0x12) ? "%s\\CD\\%s.%s.iso" : "%s\\DVD\\%s.%s.iso";
-			sprintf(tmp_str, path_str, g_pc_prefix, g_ISO_name, game_name);
+			path_str = (g_ISO_media == 0x12) ? "%s\\CD\\%s.%s%s" : "%s\\DVD\\%s.%s%s";
+			sprintf(tmp_str, path_str, g_pc_prefix, g_ISO_name + 5, game_name, g_ISO_name);
 		} else {
-			path_str = (g_ISO_media == 0x12) ? "CD\\%s.%s.iso" : "DVD\\%s.%s.iso";
-			sprintf(tmp_str, path_str, g_ISO_name, game_name);
+			path_str = (g_ISO_media == 0x12) ? "CD\\%s.%s%s" : "DVD\\%s.%s%s";
+			sprintf(tmp_str, path_str, g_ISO_name + 5, game_name, g_ISO_name);
 		}
 		smb_OpenAndX(tmp_str, (u16 *)&g_part_start[i++], 0);
 	} else {
 				memcpy(g->name, sharelist[i].ShareName, 32);
 				g->name[31] = '\0';
 				sprintf(g->startup, "SHARE");
+				g->extension[0] = '\0';
 				g->parts = 0x00;
 				g->media = 0x00;
 				g->isISO = 0;
 static void ethLaunchGame(int id, config_set_t* configSet) {
 	int i, compatmask, size_irx = 0;
 	void** irx = NULL;
-	char isoname[32], filename[32];
+	char filename[32];
 	base_game_info_t* game = &ethGames[id];
 
 	if (!gPCShareName[0]) {
 		irx = &smb_cdvdman_irx;
 	}
 
-	compatmask = sbPrepare(game, configSet, isoname, size_irx, irx, &i);
+	compatmask = sbPrepare(game, configSet, size_irx, irx, &i);
 
 	// For ISO we use the part table to store the "long" name (only for init)
 	if (game->isISO)

src/supportbase.c

 				game->name[size] = '\0';
 				strncpy(game->startup, record.name, GAME_STARTUP_MAX - 1);
 				game->startup[GAME_STARTUP_MAX - 1] = '\0';
+				strncpy(game->extension, &record.name[GAME_STARTUP_MAX + size], 4);
+				game->extension[4] = '\0';
 				game->parts = 0x01;
 				game->media = type;
 				game->isISO = 1;
 				g->name[UL_GAME_NAME_MAX] = '\0';
 				memcpy(g->startup, &buffer[UL_GAME_NAME_MAX + 3], GAME_STARTUP_MAX);
 				g->startup[GAME_STARTUP_MAX] = '\0';
+				g->extension[0] = '\0';
 				memcpy(&g->parts, &buffer[47], 1);
 				memcpy(&g->media, &buffer[48], 1);
 				g->isISO = 0;
 	*gamecount = count;
 }
 
-int sbPrepare(base_game_info_t* game, config_set_t* configSet, char* isoname, int size_cdvdman, void** cdvdman_irx, int* patchindex) {
+int sbPrepare(base_game_info_t* game, config_set_t* configSet, int size_cdvdman, void** cdvdman_irx, int* patchindex) {
 	int i;
 
 	unsigned int compatmask = 0;
 	char gameid[5];
 	configGetDiscIDBinary(configSet, gameid);
 
-	if (game->isISO)
-		strcpy(isoname, game->startup);
-	else {
-		char gamename[UL_GAME_NAME_MAX + 1];
-		memset(gamename, 0, UL_GAME_NAME_MAX + 1);
-		strncpy(gamename, game->name, UL_GAME_NAME_MAX);
-		sprintf(isoname,"ul.%08X.%s", USBA_crc32(gamename), game->startup);
-	}
 
 	for (i = 0; i < size_cdvdman; i++) {
 		if (!strcmp((const char*)((u32)cdvdman_irx + i),"######    GAMESETTINGS    ######")) {
 		}
 	}
 
-	memcpy((void*)((u32)cdvdman_irx + i), isoname, strlen(isoname) + 1);
+	memcpy((void*)((u32)cdvdman_irx + i), game->extension, 5);
+	strcpy((void*)((u32)cdvdman_irx + i + 5), game->startup);
 	memcpy((void*)((u32)cdvdman_irx + i + 33), &game->parts, 1);
 	memcpy((void*)((u32)cdvdman_irx + i + 34), &game->media, 1);
 	if (compatmask & COMPAT_MODE_2) {
 
 	if (game->isISO) {
 		if (game->media == 0x12)
-			snprintf(path, 255, "%sCD%s%s.%s.iso", prefix, sep, game->startup, game->name);
+			snprintf(path, 255, "%sCD%s%s.%s%s", prefix, sep, game->startup, game->name, game->extension);
 		else
-			snprintf(path, 255, "%sDVD%s%s.%s.iso", prefix, sep, game->startup, game->name);
+			snprintf(path, 255, "%sDVD%s%s.%s%s", prefix, sep, game->startup, game->name, game->extension);
 		fileXioRemove(path);
 	} else {
 		char *pathStr = "%sul.%08X.%s.%02x";
 
 	if (game->isISO) {
 		if (game->media == 0x12) {
-			snprintf(oldpath, 255, "%sCD%s%s.%s.iso", prefix, sep, game->startup, game->name);
-			snprintf(newpath, 255, "%sCD%s%s.%s.iso", prefix, sep, game->startup, newname);
+			snprintf(oldpath, 255, "%sCD%s%s.%s%s", prefix, sep, game->startup, game->name, game->extension);
+			snprintf(newpath, 255, "%sCD%s%s.%s%s", prefix, sep, game->startup, newname, game->extension);
 		} else {
-			snprintf(oldpath, 255, "%sDVD%s%s.%s.iso", prefix, sep, game->startup, game->name);
-			snprintf(newpath, 255, "%sDVD%s%s.%s.iso", prefix, sep, game->startup, newname);
+			snprintf(oldpath, 255, "%sDVD%s%s.%s%s", prefix, sep, game->startup, game->name, game->extension);
+			snprintf(newpath, 255, "%sDVD%s%s.%s%s", prefix, sep, game->startup, newname, game->extension);
 		}
 		fileXioRename(oldpath, newpath);
 	} else {
 
 static void usbLaunchGame(int id, config_set_t* configSet) {
 	int i, fd, val, index, compatmask;
-	char isoname[32], partname[255], filename[32];
+	char partname[255], filename[32];
 	base_game_info_t* game = &usbGames[id];
 
 	fd = fioDopen(usbPrefix);
 	}
 #endif
 
-	if (game->isISO)
-		sprintf(partname, "%s/%s/%s.%s.iso", gUSBPrefix, (game->media == 0x12) ? "CD" : "DVD", game->startup, game->name);
-	else
-		sprintf(partname, "%s/%s.00", gUSBPrefix, isoname);
-
-	val = fioIoctl(fd, 0xDEADC0DE, partname);
-	LOG("USBSUPPORT Mass storage device sectorsize = %d\n", val);
 	void** irx = &usb_cdvdman_irx;
 	int irx_size = size_usb_cdvdman_irx;
-	if (val == 4096) {
-		irx = &usb_4Ksectors_cdvdman_irx;
-		irx_size = size_usb_4Ksectors_cdvdman_irx;
-	}
+	for (i = 0; i < game->parts; i++) {
+		if (game->isISO)
+			sprintf(partname, "%s/%s/%s.%s%s", gUSBPrefix, (game->media == 0x12) ? "CD" : "DVD", game->startup, game->name, game->extension);
+		else
+			sprintf(partname, "%s/ul.%08X.%s.%02x", gUSBPrefix, USBA_crc32(game->name), game->startup, i);
 
-	compatmask = sbPrepare(game, configSet, isoname, irx_size, irx, &index);
-
-	if (gCheckUSBFragmentation)
-		for (i = 0; i < game->parts; i++) {
-			if (!game->isISO)
-				sprintf(partname, "%s/%s.%02x", gUSBPrefix, isoname, i);
-
+		if (gCheckUSBFragmentation) {
 			if (fioIoctl(fd, 0xCAFEC0DE, partname) == 0) {
 				fioDclose(fd);
 				guiMsgBox(_l(_STR_ERR_FRAGMENTED), 0, NULL);
 			}
 		}
 
+		if (i == 0) {
+			val = fioIoctl(fd, 0xDEADC0DE, partname);
+			LOG("USBSUPPORT Mass storage device sector size = %d\n", val);
+			if (val == 4096) {
+				irx = &usb_4Ksectors_cdvdman_irx;
+				irx_size = size_usb_4Ksectors_cdvdman_irx;
+			}
+			compatmask = sbPrepare(game, configSet, irx_size, irx, &index);
+		}
+
+		val = fioIoctl(fd, 0xBEEFC0DE, partname);
+		memcpy((void*)((u32)irx + index + 44 + 4 * i), &val, 4);
+	}
+
 	if (gRememberLastPlayed) {
 		configSetStr(configGetByType(CONFIG_LAST), "last_played", game->startup);
 		saveConfig(CONFIG_LAST, 0);
 	}
 
-	int offset = 44;
-	for (i = 0; i < game->parts; i++) {
-		if (!game->isISO)
-			sprintf(partname, "%s/%s.%02x", gUSBPrefix, isoname, i);
-
-		val = fioIoctl(fd, 0xBEEFC0DE, partname);
-		memcpy((void*)((u32)&usb_cdvdman_irx + index + offset), &val, 4);
-		offset += 4;
-	}
-
 	fioDclose(fd);
 
 	char *altStartup = NULL;