-fixed booting wii games from disc

-moved a few debug prints, also added disc id check for wii games
playing from a wbfs partition (before it just checked on fat32,
ntfs and ext2 if the readed in disc is correctly opened from cIOS)
-made ogg lib using MEM2 only (as we did in the previous update
with the sound buffers)
This commit is contained in:
fix94.1 2012-08-05 16:10:32 +00:00
parent 971b5bdb52
commit 4932949a3a
6 changed files with 41 additions and 33 deletions

Binary file not shown.

View File

@ -198,7 +198,7 @@ s32 Disc_FindPartition(u64 *outbuf)
u64 offset = 0; u64 offset = 0;
u32 cnt; u32 cnt;
u32 *TMP_Buffer = (u32*)malloc(TMP_Buffer_size); u32 *TMP_Buffer = (u32*)memalign(32, TMP_Buffer_size);
if(!TMP_Buffer) if(!TMP_Buffer)
return -1; return -1;
@ -303,13 +303,18 @@ s32 Disc_Wait(void)
s32 Disc_SetUSB(const u8 *id, bool frag) s32 Disc_SetUSB(const u8 *id, bool frag)
{ {
if(id && frag) /* ENABLE USB in cIOS */
return set_frag_list((u8 *) id); if(id)
{
if(frag)
return set_frag_list();
s32 part = -1; s32 part = -1;
if(is_ios_type(IOS_TYPE_HERMES, IOS_GetVersion())) if(is_ios_type(IOS_TYPE_HERMES, IOS_GetVersion()))
part = wbfs_part_idx ? wbfs_part_idx - 1 : 0; part = wbfs_part_idx ? wbfs_part_idx - 1 : 0;
return WDVD_SetUSBMode(wbfsDev, (u8*)id, part); return WDVD_SetUSBMode(wbfsDev, (u8*)id, part);
}
/* DISABLE USB in cIOS */
return WDVD_SetUSBMode(0, NULL, -1);
} }
s32 Disc_ReadHeader(void *outbuf) s32 Disc_ReadHeader(void *outbuf)

View File

@ -241,7 +241,7 @@ int get_frag_list(u8 *id, char *path, const u32 hdd_sector_size)
frag_concat(fa, fs); frag_concat(fa, fs);
} }
frag_list = malloc(ALIGN32(sizeof(FragList))); frag_list = malloc(sizeof(FragList));
if(frag_list == NULL) if(frag_list == NULL)
goto out; goto out;
@ -297,7 +297,7 @@ out:
return ret_val; return ret_val;
} }
int set_frag_list(u8 *id) int set_frag_list()
{ {
if (frag_list == NULL) if (frag_list == NULL)
return -2; return -2;
@ -317,12 +317,5 @@ int set_frag_list(u8 *id)
if(ret) if(ret)
return ret; return ret;
return 0;
// verify id matches
char discid[32] ATTRIBUTE_ALIGN(32);
memset(discid, 0, sizeof(discid));
ret = WDVD_UnencryptedRead(discid, 32, 0);
gprintf("Reading ID after setting fraglist: %s (expected: %s)\n", discid, id);
return (strncasecmp((char *) id, discid, 6) != 0) ? -3 : 0;
} }

View File

@ -44,7 +44,7 @@ int frag_get(FragList *ff, u32 offset, u32 count,
int frag_remap(FragList *ff, FragList *log, FragList *phy); int frag_remap(FragList *ff, FragList *log, FragList *phy);
int get_frag_list(u8 *id, char *path, const u32 hdd_sector_size); int get_frag_list(u8 *id, char *path, const u32 hdd_sector_size);
int set_frag_list(u8 *id); int set_frag_list();
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -300,19 +300,21 @@ s32 WDVD_SetUSBMode(u32 mode, const u8 *id, s32 partition)
/* Set USB mode */ /* Set USB mode */
inbuf[0] = IOCTL_DI_SETWBFSMODE << 24; inbuf[0] = IOCTL_DI_SETWBFSMODE << 24;
inbuf[1] = (id) ? mode : 0; inbuf[1] = mode;
/* Copy ID */ /* Copy ID */
if (id) if(id)
{ {
memcpy(&inbuf[2], id, 6); memcpy(&inbuf[2], id, 6);
if(partition >= 0) inbuf[5] = partition; if(partition >= 0)
inbuf[5] = partition;
} }
s32 ret = IOS_Ioctl(di_fd, IOCTL_DI_SETWBFSMODE, inbuf, sizeof(inbuf), outbuf, sizeof(outbuf)); s32 ret = IOS_Ioctl(di_fd, IOCTL_DI_SETWBFSMODE, inbuf, sizeof(inbuf), outbuf, sizeof(outbuf));
if (ret < 0) return ret; if(ret < 0)
return (ret == 1) ? 0 : -ret; return ret;
return(ret == 1) ? 0 : -ret;
} }
s32 WDVD_Read_Disc_BCA(void *buf) s32 WDVD_Read_Disc_BCA(void *buf)

View File

@ -1185,7 +1185,7 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd)
else else
{ {
/* Read GC disc header */ /* Read GC disc header */
struct gc_discHdr *gcHeader = (struct gc_discHdr *)malloc(sizeof(struct gc_discHdr)); struct gc_discHdr *gcHeader = (struct gc_discHdr *)memalign(32, sizeof(struct gc_discHdr));
Disc_ReadGCHeader(gcHeader); Disc_ReadGCHeader(gcHeader);
strncpy(hdr->id, (char*)gcHeader->id, 6); strncpy(hdr->id, (char*)gcHeader->id, 6);
free(gcHeader); free(gcHeader);
@ -1196,7 +1196,7 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd)
else else
{ {
/* Read header */ /* Read header */
struct discHdr *header = (struct discHdr *)malloc(sizeof(struct discHdr)); struct discHdr *header = (struct discHdr *)memalign(32, sizeof(struct discHdr));
Disc_ReadHeader(header); Disc_ReadHeader(header);
id = string((const char*)header->id); id = string((const char*)header->id);
free(header); free(header);
@ -1358,7 +1358,6 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd)
} }
IOSReloadBlock(IOS_GetVersion(), true); IOSReloadBlock(IOS_GetVersion(), true);
} }
if(emulate_mode && !neek2o()) if(emulate_mode && !neek2o())
{ {
Nand::Instance()->Init(emuPath.c_str(), emuPartition, false); Nand::Instance()->Init(emuPath.c_str(), emuPartition, false);
@ -1370,7 +1369,6 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd)
Nand::Instance()->Set_FullMode(true); Nand::Instance()->Set_FullMode(true);
else else
Nand::Instance()->Set_FullMode(false); Nand::Instance()->Set_FullMode(false);
if(Nand::Instance()->Enable_Emu() < 0) if(Nand::Instance()->Enable_Emu() < 0)
{ {
Nand::Instance()->Disable_Emu(); Nand::Instance()->Disable_Emu();
@ -1385,21 +1383,23 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd)
if(!dvd) if(!dvd)
{ {
s32 ret = Disc_SetUSB((u8*)id.c_str(), !wbfs_partition); s32 ret = Disc_SetUSB((u8*)id.c_str(), !wbfs_partition);
if (ret < 0) if(ret < 0)
{ {
gprintf("Set USB failed: %d\n", ret); gprintf("Set USB failed: %d\n", ret);
error(wfmt(_fmt("errgame10", L"Set USB failed: %d"), ret)); error(wfmt(_fmt("errgame10", L"Set USB failed: %d"), ret));
if (iosLoaded) Sys_LoadMenu(); if(iosLoaded)
Sys_LoadMenu();
return; return;
} }
if(Disc_Open(false) < 0)
if (Disc_Open(false) < 0)
{ {
error(_t("wbfsoperr2", L"Disc_Open failed")); error(_t("wbfsoperr2", L"Disc_Open failed"));
if (iosLoaded) Sys_LoadMenu(); if(iosLoaded)
Sys_LoadMenu();
return; return;
} }
} }
/* Find game partition offset */ /* Find game partition offset */
u64 offset; u64 offset;
s32 ret = Disc_FindPartition(&offset); s32 ret = Disc_FindPartition(&offset);
@ -1412,6 +1412,14 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd)
shadow_mload(); shadow_mload();
#endif #endif
/* Last check if the Disc ID is correct */
char discid[32] ATTRIBUTE_ALIGN(32);
memset(discid, 0, sizeof(discid));
WDVD_UnencryptedRead(discid, 32, 0);
gprintf("WDVD_UnencryptedRead ID: %s (expected: %s)\n", discid, id.c_str());
if(strncasecmp(id.c_str(), discid, 6) != 0)
return;
RunApploader(offset, videoMode, vipatch, countryPatch, patchVidMode, aspectRatio, returnTo); RunApploader(offset, videoMode, vipatch, countryPatch, patchVidMode, aspectRatio, returnTo);
gprintf("Booting game\n"); gprintf("Booting game\n");
Disc_BootPartition(); Disc_BootPartition();