GameListCtrl: fixes progress bar for extracting multiple files (cant mix ascii with unicode wxstring:format)

use appropriate extensions extracting compressed wii discs
check for tmd+tik for each title and list titles correctly for sysmenu versions <=0xE0
this will allow viewing of installed channels but they will not launch until ES_Launch is emulated
so far I have not been able to determine why later sysmenu versions do not display channels correctly
switching between system menu versions is as simple as rightclicking a system menu wad in the gamelist and installing to wiimenu than restarting

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5524 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
LPFaint99 2010-05-28 05:30:03 +00:00
parent 99d9aa0613
commit ffc0c37365
5 changed files with 79 additions and 58 deletions

View File

@ -79,6 +79,16 @@ bool CWII_IPC_HLE_Device_es::Open(u32 _CommandAddress, u32 _Mode)
if (m_pContentLoader->IsValid())
{
m_TitleID = m_pContentLoader->GetTitleID();
// System menu versions about 0xE0 will indicate that system files are corrupted if there is more than one title
// TODO: fix System menu versions above this and remove this check
if (m_pContentLoader->GetTitleVersion() <= 0xE0)
{
DiscIO::cUIDsys::AccessInstance().GetTitleIDs(m_TitleIDs);
}
else
{
m_TitleIDs.push_back(0x0000000100000002ULL);
}
}
else if (VolumeHandler::IsValid())
{
@ -92,18 +102,6 @@ bool CWII_IPC_HLE_Device_es::Open(u32 _CommandAddress, u32 _Mode)
m_TitleID = ((u64)0x00010000 << 32) | 0xF00DBEEF;
}
// TODO: when dev/fs IOCTLV_GETUSAGE is correct (wii doesnt report fs as corrupt) uncomment this line
// title ids are all listed in sys/uid.sys - lpfaint99
//DiscIO::cUIDsys::AccessInstance().GetTitleIDs(m_TitleIDs);
m_TitleIDs.push_back(0x0000000100000002ULL);
//m_TitleIDs.push_back(0x0001000248414741ULL);
//m_TitleIDs.push_back(0x0001000248414341ULL);
//m_TitleIDs.push_back(0x0001000248414241ULL);
//m_TitleIDs.push_back(0x0001000248414141ULL);
// scan for the title ids listed in TMDs within /title/
//FindValidTitleIDs();
INFO_LOG(WII_IPC_ES, "Set default title to %08x/%08x", (u32)(m_TitleID>>32), (u32)m_TitleID);
Memory::Write_U32(GetDeviceID(), _CommandAddress+4);
@ -772,36 +770,3 @@ std::string CWII_IPC_HLE_Device_es::CreateTitleContentPath(u64 _TitleID) const
return TicketFilename;
}
void CWII_IPC_HLE_Device_es::FindValidTitleIDs()
{
m_TitleIDs.clear();
char TitlePath[1024];
sprintf(TitlePath, "%stitle", File::GetUserPath(D_WIIUSER_IDX));
File::FSTEntry ParentEntry;
(void)ScanDirectoryTree(TitlePath, ParentEntry);
for(std::vector<File::FSTEntry>::iterator Level1 = ParentEntry.children.begin(); Level1 != ParentEntry.children.end(); ++Level1)
{
if (Level1->isDirectory)
{
for(std::vector<File::FSTEntry>::iterator Level2 = Level1->children.begin(); Level2 != Level1->children.end(); ++Level2)
{
if (Level2->isDirectory)
{
// finally at /title/*/*/
// ...get titleID from content/title.tmd
std::string CurrentTMD(Level2->physicalName + DIR_SEP + "content" + DIR_SEP + "title.tmd");
if (File::Exists(CurrentTMD.c_str()))
{
FILE* pTMDFile = fopen(CurrentTMD.c_str(), "rb");
u64 TitleID = 0xDEADBEEFDEADBEEFULL;
fseek(pTMDFile, 0x18C, SEEK_SET);
fread(&TitleID, 8, 1, pTMDFile);
m_TitleIDs.push_back(Common::swap64(TitleID));
fclose(pTMDFile);
}
}
}
}
}
}

View File

@ -144,7 +144,6 @@ private:
std::string CreateTicketFileName(u64 _TitleID) const;
std::string CreateTitleContentPath(u64 _TitleID) const;
void FindValidTitleIDs();
};
#endif

View File

@ -34,8 +34,9 @@ cUIDsys cUIDsys::m_Instance;
CSharedContent::CSharedContent()
{
sprintf(contentMap, "%sshared1/content.map", File::GetUserPath(D_WIIUSER_IDX));
lastID = 0;
sprintf(contentMap, "%sshared1/content.map", File::GetUserPath(D_WIIUSER_IDX));
if (File::Exists(contentMap))
{
FILE* pFile = fopen(contentMap, "rb");
@ -267,6 +268,7 @@ bool CNANDContentLoader::CreateFromDirectory(const std::string& _rPath)
else
{
ERROR_LOG(DISCIO, "NANDContentLoader: error opening %s", szFilename);
return false;
}
}
@ -378,6 +380,8 @@ cUIDsys::cUIDsys()
{
sprintf(uidSys, "%ssys/uid.sys", File::GetUserPath(D_WIIUSER_IDX));
lastUID = 0x00001000;
bool validTMD;
bool validTIK;
if (File::Exists(uidSys))
{
FILE* pFile = fopen(uidSys, "rb");
@ -386,10 +390,13 @@ cUIDsys::cUIDsys()
SElement Element;
if (fread(&Element, sizeof(SElement), 1, pFile) == 1)
{
if (CheckValidTitle(Common::swap64(Element.titleID)))
validTMD = CheckTitleTMD(Common::swap64(Element.titleID));
validTIK = CheckTitleTIK(Common::swap64(Element.titleID));
if (validTMD && validTIK)
{
*(u32*)&(Element.UID) = Common::swap32(lastUID++);
m_Elements.push_back(Element);
lastUID++;
}
}
}
@ -397,7 +404,18 @@ cUIDsys::cUIDsys()
}
else
{
SElement Element;
*(u64*)&(Element.titleID) = Common::swap64(0x0000000100000002ull);
*(u32*)&(Element.UID) = Common::swap32(lastUID++);
File::CreateFullPath(uidSys);
FILE* pFile = fopen(uidSys, "wb");
if (pFile)
{
if (fwrite(&Element, sizeof(SElement), 1, pFile) != 1)
ERROR_LOG(DISCIO, "fwrite failed");
fclose(pFile);
}
}
}
@ -424,9 +442,8 @@ bool cUIDsys::AddTitle(u64 _TitleID)
{
SElement Element;
*(u64*)&(Element.titleID) = Common::swap64(_TitleID);
*(u32*)&(Element.UID) = Common::swap32(lastUID);
*(u32*)&(Element.UID) = Common::swap32(lastUID++);
m_Elements.push_back(Element);
lastUID++;
FILE* pFile = fopen(uidSys, "ab");
if (pFile)
{
@ -447,7 +464,7 @@ void cUIDsys::GetTitleIDs(std::vector<u64>& _TitleIDs)
}
}
bool cUIDsys::CheckValidTitle(u64 _TitleID)
bool cUIDsys::CheckTitleTMD(u64 _TitleID)
{
char TitlePath[1024];
sprintf(TitlePath, "%stitle/%08x/%08x/content/title.tmd", File::GetUserPath(D_WIIUSER_IDX),
@ -466,6 +483,30 @@ bool cUIDsys::CheckValidTitle(u64 _TitleID)
return true;
}
}
INFO_LOG(DISCIO, "Invalid or no tmd for title %08x %08x", (u32)(_TitleID >> 32), (u32)(_TitleID & 0xFFFFFFFF));
return false;
}
bool cUIDsys::CheckTitleTIK(u64 _TitleID)
{
char TitlePath[1024];
sprintf(TitlePath, "%sticket/%08x/%08x.tik", File::GetUserPath(D_WIIUSER_IDX),
(u32)(_TitleID >> 32), (u32)(_TitleID & 0xFFFFFFFF));
if (File::Exists(TitlePath))
{
FILE* pTIKFile = fopen(TitlePath, "rb");
if(pTIKFile)
{
u64 TitleID = 0xDEADBEEFDEADBEEFULL;
fseek(pTIKFile, 0x1dC, SEEK_SET);
fread(&TitleID, 8, 1, pTIKFile);
fclose(pTIKFile);
if (_TitleID == Common::swap64(TitleID))
return true;
}
}
INFO_LOG(DISCIO, "Invalid or no tik for title %08x %08x", (u32)(_TitleID >> 32), (u32)(_TitleID & 0xFFFFFFFF));
return false;
}

View File

@ -132,7 +132,8 @@ public:
u32 GetUIDFromTitle(u64 _Title);
bool AddTitle(u64 _Title);
bool CheckValidTitle(u64 _TitleID);
bool cUIDsys::CheckTitleTMD(u64 _TitleID);
bool cUIDsys::CheckTitleTIK(u64 _TitleID);
void GetTitleIDs(std::vector<u64>& _TitleIDs);
private:

View File

@ -1078,8 +1078,7 @@ void CGameListCtrl::OnInstallWAD(wxCommandEvent& WXUNUSED (event))
void CGameListCtrl::MultiCompressCB(const char* text, float percent, void* arg)
{
percent = (((float)m_currentItem) + percent) / (float)m_numberItem;
wxString textString(wxString::Format(wxT("%s (%i/%i) - %s"), m_currentFilename.c_str(), (int)m_currentItem+1, (int)m_numberItem, text));
wxString textString(StringFromFormat("%s (%i/%i) - %s", m_currentFilename.c_str(), (int)m_currentItem+1, (int)m_numberItem, text).c_str(), *wxConvCurrent);
((wxProgressDialog*)arg)->Update((int)(percent*1000), textString);
}
@ -1141,7 +1140,14 @@ void CGameListCtrl::CompressSelection(bool _compress)
std::string FileName;
SplitPath(iso->GetFileName(), NULL, &FileName, NULL);
m_currentFilename = FileName;
if (iso->GetPlatform() == GameListItem::WII_DISC)
{
FileName.append(".iso");
}
else
{
FileName.append(".gcm");
}
std::string OutputFileName;
BuildCompleteFilename(OutputFileName, (const char *)browseDialog.GetPath().mb_str(wxConvUTF8), FileName);
@ -1164,19 +1170,28 @@ void CGameListCtrl::OnCompressGCM(wxCommandEvent& WXUNUSED (event))
if (!iso)
return;
wxString path;
wxString path, Ext;
std::string FileName;
SplitPath(iso->GetFileName(), NULL, &FileName, NULL);
if (iso->IsCompressed())
{
if (iso->GetPlatform() == GameListItem::WII_DISC)
{
Ext = wxT("*.iso");
}
else
{
Ext = wxT("*.gcm");
}
path = wxFileSelector(
_T("Save decompressed ISO"),
wxEmptyString, wxString(FileName.c_str(), *wxConvCurrent), wxEmptyString,
wxString::Format
(
_T("All GC/Wii ISO files (gcm)|*.gcm|All files (%s)|%s"),
_T("All GC/Wii ISO files (%s)|%s|All files (%s)|%s"),
Ext.After('.'), Ext,
wxFileSelectorDefaultWildcardStr,
wxFileSelectorDefaultWildcardStr
),