fixed support for GetTMDViewSize and GetTMDView

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2637 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
fires.gc 2009-03-09 23:21:05 +00:00
parent 375c732f11
commit 220c11a3d5
4 changed files with 137 additions and 27 deletions

View File

@ -79,11 +79,11 @@ CWII_IPC_HLE_Device_es::CWII_IPC_HLE_Device_es(u32 _DeviceID, const std::string&
// here should be code to scan for the title ids in the NAND
m_TitleIDs.clear();
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);*/
/*m_TitleIDs.push_back(0x0000000100000002ULL);
m_TitleIDs.push_back(0x0001000248414741ULL); // TMD Size: 0x8c
m_TitleIDs.push_back(0x0001000248414341ULL); // TMD Size: 0xac
/* m_TitleIDs.push_back(0x0001000248414241ULL);
m_TitleIDs.push_back(0x0001000248414141ULL); */
INFO_LOG(WII_IPC_ES, "Set default title to %08x/%08x", m_TitleID>>32, m_TitleID);
@ -140,8 +140,9 @@ bool CWII_IPC_HLE_Device_es::IOCtlV(u32 _CommandAddress)
u64 TitleID = Memory::Read_U64(Buffer.InBuffer[0].m_Address);
DiscIO::CNANDContentLoader& rNANDCOntent = AccessContentDevice(TitleID);
_dbg_assert_(WII_IPC_ES, rNANDCOntent.IsValid());
Memory::Write_U32(rNANDCOntent.GetContentSize(), Buffer.PayloadBuffer[0].m_Address);
Memory::Write_U32((u32)rNANDCOntent.GetContentSize(), Buffer.PayloadBuffer[0].m_Address);
INFO_LOG(WII_IPC_ES, "ES: IOCTL_ES_GETTITLECONTENTSCNT: TitleID: %08x/%08x content count %i",
TitleID>>32, TitleID, rNANDCOntent.GetContentSize());
@ -151,6 +152,38 @@ bool CWII_IPC_HLE_Device_es::IOCtlV(u32 _CommandAddress)
}
break;
case IOCTL_ES_GETTITLECONTENTS:
{
_dbg_assert_msg_(WII_IPC_ES, Buffer.NumberInBuffer == 2, "CWII_IPC_HLE_Device_es: IOCTL_ES_GETTITLECONTENTS no in buffer");
_dbg_assert_msg_(WII_IPC_ES, Buffer.NumberPayloadBuffer == 1, "CWII_IPC_HLE_Device_es: IOCTL_ES_GETTITLECONTENTS no out buffer");
u64 TitleID = Memory::Read_U64(Buffer.InBuffer[0].m_Address);
u32 MaxCount = Memory::Read_U32(Buffer.InBuffer[1].m_Address);
std::string TitleFilename = CreateTitleContentPath(TitleID);
DiscIO::CNANDContentLoader Loader(TitleFilename);
ERROR_LOG(WII_IPC_ES, "IOCTL_ES_GETTITLECONTENTS: title: %08x/%08x buffersize: %i", TitleID >> 32, TitleID, MaxCount);
u32 Count = 0;
if (Loader.IsValid())
{
const std::vector<DiscIO::SNANDContent>& rContent = Loader.GetContent();
for (size_t i=0; i<Loader.GetContentSize(); i++)
{
Memory::Write_U32(rContent[i].m_Index, Buffer.PayloadBuffer[0].m_Address+i*4);
ERROR_LOG(WII_IPC_ES, "IOCTL_ES_GETTITLECONTENTS: Index 0x%x", rContent[i].m_ContentID);
Count++;
if (Count>=MaxCount)
break;
}
}
Memory::Write_U32(0, _CommandAddress + 0x4);
ERROR_LOG(WII_IPC_ES, "IOCTL_ES_GETTITLECONTENTS: Count %i", Count);
return true;
}
break;
case IOCTL_ES_OPENTITLECONTENT:
{
_dbg_assert_(WII_IPC_ES, Buffer.NumberInBuffer == 3);
@ -318,7 +351,7 @@ bool CWII_IPC_HLE_Device_es::IOCtlV(u32 _CommandAddress)
_dbg_assert_msg_(WII_IPC_ES, Buffer.NumberPayloadBuffer == 1, "IOCTL_ES_GETTITLECNT has no out buffer");
_dbg_assert_msg_(WII_IPC_ES, Buffer.PayloadBuffer[0].m_Size == 4, "IOCTL_ES_GETTITLECNT payload[0].size != 4");
Memory::Write_U32(m_TitleIDs.size(), Buffer.PayloadBuffer[0].m_Address);
Memory::Write_U32((u32)m_TitleIDs.size(), Buffer.PayloadBuffer[0].m_Address);
ERROR_LOG(WII_IPC_ES, "IOCTL_ES_GETTITLECNT: Number of Titles %i", m_TitleIDs.size());
@ -431,6 +464,76 @@ bool CWII_IPC_HLE_Device_es::IOCtlV(u32 _CommandAddress)
}
break;
case IOCTL_ES_GETTMDVIEWCNT:
{
_dbg_assert_msg_(WII_IPC_ES, Buffer.NumberInBuffer == 1, "CWII_IPC_HLE_Device_es: IOCTL_ES_GETTMDVIEWCNT no in buffer");
_dbg_assert_msg_(WII_IPC_ES, Buffer.NumberPayloadBuffer == 1, "CWII_IPC_HLE_Device_es: IOCTL_ES_GETTMDVIEWCNT no out buffer");
u64 TitleID = Memory::Read_U64(Buffer.InBuffer[0].m_Address);
std::string TitleFilename = CreateTitleContentPath(TitleID);
DiscIO::CNANDContentLoader Loader(TitleFilename);
_dbg_assert_(WII_IPC_ES, Loader.IsValid());
u32 TMDViewCnt = 0;
if (Loader.IsValid())
{
TMDViewCnt += DiscIO::CNANDContentLoader::TICKET_VIEW_SIZE;
TMDViewCnt += 2; // title version
TMDViewCnt += 2; // num entries
TMDViewCnt += Loader.GetContentSize() * (4+2+2+8); // content id, index, type, size
}
Memory::Write_U32(TMDViewCnt, Buffer.PayloadBuffer[0].m_Address);
Memory::Write_U32(0, _CommandAddress + 0x4);
INFO_LOG(WII_IPC_ES, "IOCTL_ES_GETTMDVIEWCNT: title: %08x/%08x -> count %i", TitleID >> 32, TitleID, TMDViewCnt);
return true;
}
break;
case IOCTL_ES_GETTMDVIEWS:
{
_dbg_assert_msg_(WII_IPC_ES, Buffer.NumberInBuffer == 2, "CWII_IPC_HLE_Device_es: IOCTL_ES_GETTMDVIEWCNT no in buffer");
_dbg_assert_msg_(WII_IPC_ES, Buffer.NumberPayloadBuffer == 1, "CWII_IPC_HLE_Device_es: IOCTL_ES_GETTMDVIEWCNT no out buffer");
u64 TitleID = Memory::Read_U64(Buffer.InBuffer[0].m_Address);
u32 MaxCount = Memory::Read_U32(Buffer.InBuffer[1].m_Address);
std::string TitleFilename = CreateTitleContentPath(TitleID);
DiscIO::CNANDContentLoader Loader(TitleFilename);
INFO_LOG(WII_IPC_ES, "IOCTL_ES_GETTMDVIEWCNT: title: %08x/%08x buffersize: %i", TitleID >> 32, TitleID, MaxCount);
u32 Count = 0;
u8* p = Memory::GetPointer(Buffer.PayloadBuffer[0].m_Address);
if (Loader.IsValid())
{
u32 Address = Buffer.PayloadBuffer[0].m_Address;
Memory::WriteBigEData(Loader.GetTicket(), Address, DiscIO::CNANDContentLoader::TICKET_VIEW_SIZE);
Address += DiscIO::CNANDContentLoader::TICKET_VIEW_SIZE;
Memory::Write_U16(Loader.GetTitleVersion(), Address); Address += 2;
Memory::Write_U16(Loader.GetNumEntries(), Address); Address += 2;
const std::vector<DiscIO::SNANDContent>& rContent = Loader.GetContent();
for (size_t i=0; i<Loader.GetContentSize(); i++)
{
Memory::Write_U32(rContent[i].m_ContentID, Address); Address += 4;
Memory::Write_U16(rContent[i].m_Index, Address); Address += 2;
Memory::Write_U16(rContent[i].m_Type, Address); Address += 2;
Memory::Write_U64(rContent[i].m_Size, Address); Address += 8;
}
_dbg_assert_(WII_IPC_ES, (Address-Buffer.PayloadBuffer[0].m_Address) == Buffer.PayloadBuffer[0].m_Size);
}
Memory::Write_U32(0, _CommandAddress + 0x4);
INFO_LOG(WII_IPC_ES, "IOCTL_ES_GETTMDVIEWCNT: Count %i", Count);
return true;
}
break;
// ===============================================================================================
// unsupported functions
// ===============================================================================================
@ -464,17 +567,6 @@ bool CWII_IPC_HLE_Device_es::IOCtlV(u32 _CommandAddress)
_dbg_assert_msg_(WII_IPC_ES, 0, "IOCTL_ES_GETSTOREDTMDSIZE: this looks really wrong...");
break;
case IOCTL_ES_GETTMDVIEWCNT:
{
_dbg_assert_msg_(WII_IPC_ES, Buffer.NumberInBuffer == 1, "CWII_IPC_HLE_Device_es: IOCTL_ES_GETTMDVIEWCNT no in buffer");
_dbg_assert_msg_(WII_IPC_ES, Buffer.NumberPayloadBuffer == 1, "CWII_IPC_HLE_Device_es: IOCTL_ES_GETTMDVIEWCNT no out buffer");
u64 TitleID = Memory::Read_U64(Buffer.InBuffer[0].m_Address);
PanicAlert("IOCTL_ES_GETTMDVIEWCNT: Try to get data from an unknown title: %08x/%08x", TitleID >> 32, TitleID);
}
break;
case IOCTL_ES_GETCONSUMPTION: // (Input: 8 bytes, Output: 0 bytes, 4 bytes)
_dbg_assert_msg_(WII_IPC_ES, 0, "IOCTL_ES_GETCONSUMPTION: this looks really wrong...");
break;
@ -483,7 +575,6 @@ bool CWII_IPC_HLE_Device_es::IOCtlV(u32 _CommandAddress)
_dbg_assert_msg_(WII_IPC_ES, 0, "IOCTL_ES_DIGETTICKETVIEW: this looks really wrong...");
break;
default:
_dbg_assert_msg_(WII_IPC_ES, 0, "CWII_IPC_HLE_Device_es: 0x%x", Buffer.Parameter);
@ -510,7 +601,7 @@ DiscIO::CNANDContentLoader& CWII_IPC_HLE_Device_es::AccessContentDevice(u64 _Tit
if (itr != m_NANDContent.end())
return *itr->second;
std::string TitleFilename = CreateTitleFileName(_TitleID);
std::string TitleFilename = CreateTitleContentPath(_TitleID);
m_NANDContent[_TitleID] = new DiscIO::CNANDContentLoader(TitleFilename);
_dbg_assert_(WII_IPC_ES, m_NANDContent[_TitleID]->IsValid());
@ -533,10 +624,11 @@ std::string CWII_IPC_HLE_Device_es::CreateTicketFileName(u64 _TitleID) const
return TicketFilename;
}
std::string CWII_IPC_HLE_Device_es::CreateTitleFileName(u64 _TitleID) const
std::string CWII_IPC_HLE_Device_es::CreateTitleContentPath(u64 _TitleID) const
{
char TicketFilename[1024];
sprintf(TicketFilename, "%stitle/%08x/%08x.app", FULL_WII_USER_DIR, (u32)(_TitleID >> 32), (u32)_TitleID);
sprintf(TicketFilename, "%stitle/%08x/%08x/content", FULL_WII_USER_DIR, (u32)(_TitleID >> 32), (u32)_TitleID);
return TicketFilename;
}
}

View File

@ -122,7 +122,7 @@ private:
bool IsValid(u64 _TitleID) const;
std::string CreateTicketFileName(u64 _TitleID) const;
std::string CreateTitleFileName(u64 _TitleID) const;
std::string CreateTitleContentPath(u64 _TitleID) const;
};
#endif

View File

@ -177,14 +177,17 @@ bool CNANDContentLoader::CreateFromDirectory(const std::string& _rPath)
fread(pTMD, Size, 1, pTMDFile);
fclose(pTMDFile);
memcpy(m_TicketView, pTMD + 0x180, TICKET_VIEW_SIZE);
//////
u32 numEntries = Common::swap16(pTMD + 0x01de);
m_TileVersion = Common::swap16(pTMD + 0x01dc);
m_numEntries = Common::swap16(pTMD + 0x01de);
m_BootIndex = Common::swap16(pTMD + 0x01e0);
m_TitleID = Common::swap64(pTMD + 0x018C);
m_Content.resize(numEntries);
m_Content.resize(m_numEntries);
for (u32 i = 0; i < numEntries; i++)
for (u32 i = 0; i < m_numEntries; i++)
{
SNANDContent& rContent = m_Content[i];

View File

@ -49,14 +49,29 @@ public:
u32 GetBootIndex() const { return m_BootIndex; }
size_t GetContentSize() const { return m_Content.size(); }
SNANDContent* GetContentByIndex(int _Index);
const u8* GetTicket() const { return m_TicketView; }
const std::vector<SNANDContent>& GetContent() const { return m_Content; }
static bool IsWiiWAD(const std::string& _rName);
const u16 GetTitleVersion() const {return m_TileVersion;}
const u16 GetNumEntries() const {return m_numEntries;}
enum
{
TICKET_VIEW_SIZE = 0x58
};
private:
bool m_Valid;
u64 m_TitleID;
u32 m_BootIndex;
u16 m_numEntries;
u16 m_TileVersion;
u8 m_TicketView[TICKET_VIEW_SIZE];
std::vector<SNANDContent> m_Content;