Ejemplo n.º 1
0
static void ethLaunchGame(int id, config_set_t* configSet) {
	int i, compatmask;
	int EnablePS2Logo = 0;
#ifdef CHEAT
	int result;
#endif
	char filename[32], partname[256];
	base_game_info_t* game = &ethGames[id];
	struct cdvdman_settings_smb *settings;
	u32 layer1_start, layer1_offset;
	unsigned short int layer1_part;

	if (!gPCShareName[0]) {
		memcpy(gPCShareName, game->name, 32);
		ethULSizePrev = -2;
		ethGameCount = 0;
		ioPutRequest(IO_MENU_UPDATE_DEFFERED, &ethGameList.mode); // clear the share list
		ioPutRequest(IO_CUSTOM_SIMPLEACTION, &ethInitSMB);
		ioPutRequest(IO_MENU_UPDATE_DEFFERED, &ethGameList.mode); // reload the game list
		return;
	}

#ifdef VMC
	char vmc_name[32];
	int vmc_id, size_mcemu_irx = 0;
	smb_vmc_infos_t smb_vmc_infos;
	vmc_superblock_t vmc_superblock;

	for (vmc_id = 0; vmc_id < 2; vmc_id++) {
		memset(&smb_vmc_infos, 0, sizeof(smb_vmc_infos_t));
		configGetVMC(configSet, vmc_name, sizeof(vmc_name), vmc_id);
		if (vmc_name[0]) {
			if (sysCheckVMC(ethPrefix, "\\", vmc_name, 0, &vmc_superblock) > 0) {
				smb_vmc_infos.flags = vmc_superblock.mc_flag & 0xFF;
				smb_vmc_infos.flags |= 0x100;
				smb_vmc_infos.specs.page_size = vmc_superblock.page_size;
				smb_vmc_infos.specs.block_size = vmc_superblock.pages_per_block;
				smb_vmc_infos.specs.card_size = vmc_superblock.pages_per_cluster * vmc_superblock.clusters_per_card;
				smb_vmc_infos.active = 1;
				smb_vmc_infos.fid = 0xFFFF;
				if (gETHPrefix[0])
					snprintf(smb_vmc_infos.fname, sizeof(smb_vmc_infos.fname), "%s\\VMC\\%s.bin", gETHPrefix, vmc_name);
				else
					snprintf(smb_vmc_infos.fname, sizeof(smb_vmc_infos.fname), "VMC\\%s.bin", vmc_name);
			} else {
				char error[256];
				snprintf(error, sizeof(error), _l(_STR_ERR_VMC_CONTINUE), vmc_name, (vmc_id + 1));
				if (!guiMsgBox(error, 1, NULL))
					return;
			}
		}

		for (i = 0; i < size_smb_mcemu_irx; i++) {
			if (((u32*)&smb_mcemu_irx)[i] == (0xC0DEFAC0 + vmc_id)) {
				if (smb_vmc_infos.active)
					size_mcemu_irx = size_smb_mcemu_irx;
				memcpy(&((u32*)&smb_mcemu_irx)[i], &smb_vmc_infos, sizeof(smb_vmc_infos_t));
				break;
			}
		}
	}
#endif

#ifdef CHEAT
	if((result = sbLoadCheats(ethPrefix, game->startup)) < 0)
	{
		switch(result)
		{
			case -ENOENT:
				guiWarning(_l(_STR_NO_CHEATS_FOUND), 10);
				break;
			default:
				guiWarning(_l(_STR_ERR_CHEATS_LOAD_FAILED), 10);
		}
	}
#endif

	if (gRememberLastPlayed) {
		configSetStr(configGetByType(CONFIG_LAST), "last_played", game->startup);
		saveConfig(CONFIG_LAST, 0);
	}

	compatmask = sbPrepare(game, configSet, size_smb_cdvdman_irx, &smb_cdvdman_irx, &i);
	settings = (struct cdvdman_settings_smb *)((u8*)(&smb_cdvdman_irx)+i);

	switch(game->format) {
		case GAME_FORMAT_OLD_ISO:
			sprintf(settings->filename, "%s.%s%s", game->startup, game->name, game->extension);
			break;
		case GAME_FORMAT_ISO:
			sprintf(settings->filename, "%s%s", game->name, game->extension);
			break;
		default:	//USBExtreme format.
			sprintf(settings->filename, "ul.%08X.%s", USBA_crc32(game->name), game->startup);
			settings->common.flags |= IOPCORE_SMB_FORMAT_USBLD;
	}

	sprintf(settings->smb_ip, "%u.%u.%u.%u", pc_ip[0], pc_ip[1], pc_ip[2], pc_ip[3]);
	settings->smb_port=gPCPort;
	strcpy(settings->smb_share, gPCShareName);
	strcpy(settings->smb_prefix, gETHPrefix);
	strcpy(settings->smb_user, gPCUserName);
	strcpy(settings->smb_password, gPCPassword);

	//Initialize layer 1 information.
	switch(game->format) {
		case GAME_FORMAT_USBLD:
			sprintf(partname, "%s%s.00", ethPrefix, settings->filename);
			break;
		default:	//Raw ISO9660 disc image; one part.
			sprintf(partname, "%s%s\\%s", ethPrefix, game->media == 0x12?"CD":"DVD", settings->filename);
	}

	if (gPS2Logo) {
		int fd = fileXioOpen(partname, O_RDONLY, 0666);
		if (fd >= 0) {
			EnablePS2Logo = CheckPS2Logo(fd, 0);
			fileXioClose(fd);
		}
	}

	layer1_start = sbGetISO9660MaxLBA(partname);

	switch(game->format) {
		case GAME_FORMAT_USBLD:
			layer1_part = layer1_start / 0x80000;
			layer1_offset = layer1_start % 0x80000;
			sprintf(partname, "%s%s.%02x", ethPrefix, settings->filename, layer1_part);
			break;
		default:	//Raw ISO9660 disc image; one part.
			layer1_part = 0;
			layer1_offset = layer1_start;
	}

	if(sbProbeISO9660_64(partname, game, layer1_offset) != 0)
	{
		layer1_start = 0;
		LOG("DVD detected.\n");
	} else {
		layer1_start -= 16;
		LOG("DVD-DL layer 1 @ part %u sector 0x%lx.\n", layer1_part, layer1_offset);
	}
	settings->common.layer1_start = layer1_start;

	// disconnect from the active SMB session
	ethSMBDisconnect();

	if (configGetStrCopy(configSet, CONFIG_ITEM_ALTSTARTUP, filename, sizeof(filename)) == 0)
		strcpy(filename, game->startup);
	deinit(NO_EXCEPTION); // CAREFUL: deinit will call ethCleanUp, so ethGames/game will be freed

#ifdef VMC
#define ETH_MCEMU	size_mcemu_irx,&smb_mcemu_irx,
#else
#define ETH_MCEMU
#endif

	sysLaunchLoaderElf(filename, "ETH_MODE", size_smb_cdvdman_irx, &smb_cdvdman_irx, ETH_MCEMU EnablePS2Logo, compatmask);
}
Ejemplo n.º 2
0
static int ethPrepareMcemu(base_game_info_t* game) {
	char vmc[2][32];
	char vmc_path[255];
	u32 vmc_size;
	int i, j, fd, size_mcemu_irx = 0;
	smb_vmc_infos_t smb_vmc_infos;
	vmc_superblock_t vmc_superblock;

	configGetVMC(game->startup, vmc[0], ETH_MODE, 0);
	configGetVMC(game->startup, vmc[1], ETH_MODE, 1);

	for(i=0; i<2; i++) {
		if(!vmc[i][0]) // skip if empty
			continue;

		memset(&smb_vmc_infos, 0, sizeof(smb_vmc_infos_t));
		memset(&vmc_superblock, 0, sizeof(vmc_superblock_t));

		snprintf(vmc_path, 255, "%s\\VMC\\%s.bin", ethPrefix, vmc[i]);

		fd = fileXioOpen(vmc_path, O_RDONLY, 0666);
		if (fd >= 0) {
			size_mcemu_irx = -1;
			LOG("%s open\n", vmc_path);

			vmc_size = fileXioLseek(fd, 0, SEEK_END);
			fileXioLseek(fd, 0, SEEK_SET);
			fileXioRead(fd, (void*)&vmc_superblock, sizeof(vmc_superblock_t));

			LOG("File size : 0x%X\n", vmc_size);
			LOG("Magic     : %s\n", vmc_superblock.magic);
			LOG("Card type : %d\n", vmc_superblock.mc_type);

			if(!strncmp(vmc_superblock.magic, "Sony PS2 Memory Card Format", 27) && vmc_superblock.mc_type == 0x2) {
				smb_vmc_infos.flags            = vmc_superblock.mc_flag & 0xFF;
				smb_vmc_infos.flags           |= 0x100;
				smb_vmc_infos.specs.page_size  = vmc_superblock.page_size;                                       
				smb_vmc_infos.specs.block_size = vmc_superblock.pages_per_block;                                 
				smb_vmc_infos.specs.card_size  = vmc_superblock.pages_per_cluster * vmc_superblock.clusters_per_card;

				LOG("flags            : 0x%X\n", smb_vmc_infos.flags           );
				LOG("specs.page_size  : 0x%X\n", smb_vmc_infos.specs.page_size );
				LOG("specs.block_size : 0x%X\n", smb_vmc_infos.specs.block_size);
				LOG("specs.card_size  : 0x%X\n", smb_vmc_infos.specs.card_size );

				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, 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 );
				}
			}
			fileXioClose(fd);
		}
		for (j=0; j<size_smb_mcemu_irx; j++) {
			if (((u32*)&smb_mcemu_irx)[j] == (0xC0DEFAC0 + i)) {
				if(smb_vmc_infos.active)
					size_mcemu_irx = size_smb_mcemu_irx;
				memcpy(&((u32*)&smb_mcemu_irx)[j], &smb_vmc_infos, sizeof(smb_vmc_infos_t));
				break;
			}
		}
	}
	return size_mcemu_irx;
}