Add Taiwan to the Country Codes, move all country code switches to one function, add unk country flag and taiwan country flag

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3666 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
LPFaint99
2009-07-03 22:34:51 +00:00
parent 15e4eed7fa
commit 4c86d218c1
15 changed files with 762 additions and 737 deletions

View File

@ -536,6 +536,58 @@
RelativePath=".\Src\Volume.h"
>
</File>
<File
RelativePath=".\Src\VolumeCommon.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
ForcedIncludeFiles="stdafx.h"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
ForcedIncludeFiles="stdafx.h"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
ForcedIncludeFiles="stdafx.h"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
>
<Tool
Name="VCCLCompilerTool"
ForcedIncludeFiles="stdafx.h"
/>
</FileConfiguration>
<FileConfiguration
Name="DebugFast|Win32"
>
<Tool
Name="VCCLCompilerTool"
ForcedIncludeFiles="stdafx.h"
/>
</FileConfiguration>
<FileConfiguration
Name="DebugFast|x64"
>
<Tool
Name="VCCLCompilerTool"
ForcedIncludeFiles="stdafx.h"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\Src\VolumeCreator.cpp"
>

View File

@ -31,48 +31,48 @@ namespace DiscIO
class CSharedContent
{
{
public:
static CSharedContent& AccessInstance() { return m_Instance; }
std::string GetFilenameFromSHA1(u8* _pHash);
static CSharedContent& AccessInstance() { return m_Instance; }
std::string GetFilenameFromSHA1(u8* _pHash);
private:
CSharedContent();
CSharedContent();
virtual ~CSharedContent();
virtual ~CSharedContent();
struct SElement
{
u8 FileName[8];
u8 SHA1Hash[20];
};
struct SElement
{
u8 FileName[8];
u8 SHA1Hash[20];
};
std::vector<SElement> m_Elements;
static CSharedContent m_Instance;
std::vector<SElement> m_Elements;
static CSharedContent m_Instance;
};
CSharedContent CSharedContent::m_Instance;
CSharedContent::CSharedContent()
{
char szFilename[1024];
sprintf(szFilename, "%sshared1/content.map", FULL_WII_USER_DIR);
if (File::Exists(szFilename))
{
FILE* pFile = fopen(szFilename, "rb");
while(!feof(pFile))
{
SElement Element;
if (fread(&Element, sizeof(SElement), 1, pFile) == 1)
{
m_Elements.push_back(Element);
}
}
}
char szFilename[1024];
sprintf(szFilename, "%sshared1/content.map", FULL_WII_USER_DIR);
if (File::Exists(szFilename))
{
FILE* pFile = fopen(szFilename, "rb");
while(!feof(pFile))
{
SElement Element;
if (fread(&Element, sizeof(SElement), 1, pFile) == 1)
{
m_Elements.push_back(Element);
}
}
}
}
CSharedContent::~CSharedContent()
@ -80,18 +80,18 @@ CSharedContent::~CSharedContent()
std::string CSharedContent::GetFilenameFromSHA1(u8* _pHash)
{
for (size_t i=0; i<m_Elements.size(); i++)
{
if (memcmp(_pHash, m_Elements[i].SHA1Hash, 20) == 0)
{
char szFilename[1024];
sprintf(szFilename, "%sshared1/%c%c%c%c%c%c%c%c.app", FULL_WII_USER_DIR,
m_Elements[i].FileName[0], m_Elements[i].FileName[1], m_Elements[i].FileName[2], m_Elements[i].FileName[3],
m_Elements[i].FileName[4], m_Elements[i].FileName[5], m_Elements[i].FileName[6], m_Elements[i].FileName[7]);
return szFilename;
}
}
return "unk";
for (size_t i=0; i<m_Elements.size(); i++)
{
if (memcmp(_pHash, m_Elements[i].SHA1Hash, 20) == 0)
{
char szFilename[1024];
sprintf(szFilename, "%sshared1/%c%c%c%c%c%c%c%c.app", FULL_WII_USER_DIR,
m_Elements[i].FileName[0], m_Elements[i].FileName[1], m_Elements[i].FileName[2], m_Elements[i].FileName[3],
m_Elements[i].FileName[4], m_Elements[i].FileName[5], m_Elements[i].FileName[6], m_Elements[i].FileName[7]);
return szFilename;
}
}
return "unk";
}
@ -101,89 +101,89 @@ class CNANDContentLoader : public INANDContentLoader
{
public:
CNANDContentLoader(const std::string& _rName);
CNANDContentLoader(const std::string& _rName);
virtual ~CNANDContentLoader();
virtual ~CNANDContentLoader();
bool IsValid() const { return m_Valid; }
u64 GetTitleID() const { return m_TitleID; }
bool IsValid() const { return m_Valid; }
u64 GetTitleID() const { return m_TitleID; }
u16 GetIosVersion() const { return m_IosVersion; }
u32 GetBootIndex() const { return m_BootIndex; }
size_t GetContentSize() const { return m_Content.size(); }
const SNANDContent* GetContentByIndex(int _Index) const;
const u8* GetTicketView() const { return m_TicketView; }
const u8* GetTmdHeader() const { return m_TmdHeader; }
u32 GetBootIndex() const { return m_BootIndex; }
size_t GetContentSize() const { return m_Content.size(); }
const SNANDContent* GetContentByIndex(int _Index) const;
const u8* GetTicketView() const { return m_TicketView; }
const u8* GetTmdHeader() const { return m_TmdHeader; }
const std::vector<SNANDContent>& GetContent() const { return m_Content; }
const std::vector<SNANDContent>& GetContent() const { return m_Content; }
const u16 GetTitleVersion() const {return m_TileVersion;}
const u16 GetNumEntries() const {return m_numEntries;}
const DiscIO::IVolume::ECountry GetCountry() const;
const u16 GetTitleVersion() const {return m_TileVersion;}
const u16 GetNumEntries() const {return m_numEntries;}
const DiscIO::IVolume::ECountry GetCountry() const;
private:
bool m_Valid;
u64 m_TitleID;
bool m_Valid;
u64 m_TitleID;
u16 m_IosVersion;
u32 m_BootIndex;
u16 m_numEntries;
u16 m_TileVersion;
u8 m_TicketView[TICKET_VIEW_SIZE];
u32 m_BootIndex;
u16 m_numEntries;
u16 m_TileVersion;
u8 m_TicketView[TICKET_VIEW_SIZE];
u8 m_TmdHeader[TMD_HEADER_SIZE];
std::vector<SNANDContent> m_Content;
std::vector<SNANDContent> m_Content;
bool CreateFromDirectory(const std::string& _rPath);
bool CreateFromWAD(const std::string& _rName);
bool CreateFromDirectory(const std::string& _rPath);
bool CreateFromWAD(const std::string& _rName);
void AESDecode(u8* _pKey, u8* _IV, u8* _pSrc, u32 _Size, u8* _pDest);
void AESDecode(u8* _pKey, u8* _IV, u8* _pSrc, u32 _Size, u8* _pDest);
void GetKeyFromTicket(u8* pTicket, u8* pTicketKey);
void GetKeyFromTicket(u8* pTicket, u8* pTicketKey);
bool ParseTMD(u8* pDataApp, u32 pDataAppSize, u8* pTicket, u8* pTMD);
bool ParseTMD(u8* pDataApp, u32 pDataAppSize, u8* pTicket, u8* pTMD);
};
CNANDContentLoader::CNANDContentLoader(const std::string& _rName)
: m_TitleID(-1)
, m_BootIndex(-1)
, m_Valid(false)
: m_TitleID(-1)
, m_BootIndex(-1)
, m_Valid(false)
, m_IosVersion(0x09)
{
if (File::IsDirectory(_rName.c_str()))
{
m_Valid = CreateFromDirectory(_rName);
}
else if (File::Exists(_rName.c_str()))
{
m_Valid = CreateFromWAD(_rName);
}
else
{
// _dbg_assert_msg_(BOOT, 0, "CNANDContentLoader loads neither folder nor file");
}
if (File::IsDirectory(_rName.c_str()))
{
m_Valid = CreateFromDirectory(_rName);
}
else if (File::Exists(_rName.c_str()))
{
m_Valid = CreateFromWAD(_rName);
}
else
{
// _dbg_assert_msg_(BOOT, 0, "CNANDContentLoader loads neither folder nor file");
}
}
CNANDContentLoader::~CNANDContentLoader()
{
for (size_t i=0; i<m_Content.size(); i++)
{
delete [] m_Content[i].m_pData;
}
m_Content.clear();
for (size_t i=0; i<m_Content.size(); i++)
{
delete [] m_Content[i].m_pData;
}
m_Content.clear();
}
const SNANDContent* CNANDContentLoader::GetContentByIndex(int _Index) const
{
for (size_t i=0; i<m_Content.size(); i++)
{
if (m_Content[i].m_Index == _Index)
return &m_Content[i];
}
return NULL;
for (size_t i=0; i<m_Content.size(); i++)
{
if (m_Content[i].m_Index == _Index)
return &m_Content[i];
}
return NULL;
}
bool CNANDContentLoader::CreateFromWAD(const std::string& _rName)
@ -197,93 +197,93 @@ bool CNANDContentLoader::CreateFromWAD(const std::string& _rName)
bool CNANDContentLoader::CreateFromDirectory(const std::string& _rPath)
{
std::string TMDFileName(_rPath);
std::string TMDFileName(_rPath);
TMDFileName += "/title.tmd";
FILE* pTMDFile = fopen(TMDFileName.c_str(), "rb");
if (pTMDFile == NULL) {
FILE* pTMDFile = fopen(TMDFileName.c_str(), "rb");
if (pTMDFile == NULL) {
ERROR_LOG(DISCIO, "CreateFromDirectory: error opening %s",
TMDFileName.c_str());
return false;
return false;
}
u64 Size = File::GetSize(TMDFileName.c_str());
u8* pTMD = new u8[(u32)Size];
fread(pTMD, (size_t)Size, 1, pTMDFile);
fclose(pTMDFile);
u64 Size = File::GetSize(TMDFileName.c_str());
u8* pTMD = new u8[(u32)Size];
fread(pTMD, (size_t)Size, 1, pTMDFile);
fclose(pTMDFile);
memcpy(m_TicketView, pTMD + 0x180, TICKET_VIEW_SIZE);
memcpy(m_TicketView, pTMD + 0x180, TICKET_VIEW_SIZE);
memcpy(m_TmdHeader, pTMD, TMD_HEADER_SIZE);
//////
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_IosVersion = Common::swap16(pTMD + 0x018a);
//////
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_IosVersion = Common::swap16(pTMD + 0x018a);
m_Content.resize(m_numEntries);
m_Content.resize(m_numEntries);
for (u32 i = 0; i < m_numEntries; i++)
{
SNANDContent& rContent = m_Content[i];
for (u32 i = 0; i < m_numEntries; i++)
{
SNANDContent& rContent = m_Content[i];
rContent.m_ContentID = Common::swap32(pTMD + 0x01e4 + 0x24*i);
rContent.m_Index = Common::swap16(pTMD + 0x01e8 + 0x24*i);
rContent.m_Type = Common::swap16(pTMD + 0x01ea + 0x24*i);
rContent.m_Size = (u32)Common::swap64(pTMD + 0x01ec + 0x24*i);
memcpy(rContent.m_SHA1Hash, pTMD + 0x01f4 + 0x24*i, 20);
memcpy(rContent.m_Header, pTMD + 0x01e4 + 0x24*i, 36);
rContent.m_ContentID = Common::swap32(pTMD + 0x01e4 + 0x24*i);
rContent.m_Index = Common::swap16(pTMD + 0x01e8 + 0x24*i);
rContent.m_Type = Common::swap16(pTMD + 0x01ea + 0x24*i);
rContent.m_Size = (u32)Common::swap64(pTMD + 0x01ec + 0x24*i);
memcpy(rContent.m_SHA1Hash, pTMD + 0x01f4 + 0x24*i, 20);
memcpy(rContent.m_Header, pTMD + 0x01e4 + 0x24*i, 36);
rContent.m_pData = NULL;
char szFilename[1024];
rContent.m_pData = NULL;
char szFilename[1024];
if (rContent.m_Type & 0x8000) // shared app
{
std::string Filename = CSharedContent::AccessInstance().GetFilenameFromSHA1(rContent.m_SHA1Hash);
strcpy(szFilename, Filename.c_str());
}
else
{
sprintf(szFilename, "%s/%08x.app", _rPath.c_str(), rContent.m_ContentID);
}
if (rContent.m_Type & 0x8000) // shared app
{
std::string Filename = CSharedContent::AccessInstance().GetFilenameFromSHA1(rContent.m_SHA1Hash);
strcpy(szFilename, Filename.c_str());
}
else
{
sprintf(szFilename, "%s/%08x.app", _rPath.c_str(), rContent.m_ContentID);
}
INFO_LOG(DISCIO, "NANDContentLoader: load %s", szFilename);
INFO_LOG(DISCIO, "NANDContentLoader: load %s", szFilename);
FILE* pFile = fopen(szFilename, "rb");
if (pFile != NULL)
{
u64 Size = File::GetSize(szFilename);
rContent.m_pData = new u8[(u32)Size];
FILE* pFile = fopen(szFilename, "rb");
if (pFile != NULL)
{
u64 Size = File::GetSize(szFilename);
rContent.m_pData = new u8[(u32)Size];
_dbg_assert_msg_(BOOT, rContent.m_Size==Size, "TMDLoader: Filesize doesnt fit (%s %i)... prolly you have a bad dump", szFilename, i);
_dbg_assert_msg_(BOOT, rContent.m_Size==Size, "TMDLoader: Filesize doesnt fit (%s %i)... prolly you have a bad dump", szFilename, i);
fread(rContent.m_pData, (size_t)Size, 1, pFile);
fclose(pFile);
}
else
{
fread(rContent.m_pData, (size_t)Size, 1, pFile);
fclose(pFile);
}
else
{
PanicAlert("NANDContentLoader: error opening %s", szFilename);
}
}
}
return true;
return true;
}
void CNANDContentLoader::AESDecode(u8* _pKey, u8* _IV, u8* _pSrc, u32 _Size, u8* _pDest)
{
AES_KEY AESKey;
AES_KEY AESKey;
AES_set_decrypt_key(_pKey, 128, &AESKey);
AES_cbc_encrypt(_pSrc, _pDest, _Size, &AESKey, _IV, AES_DECRYPT);
AES_set_decrypt_key(_pKey, 128, &AESKey);
AES_cbc_encrypt(_pSrc, _pDest, _Size, &AESKey, _IV, AES_DECRYPT);
}
void CNANDContentLoader::GetKeyFromTicket(u8* pTicket, u8* pTicketKey)
{
u8 CommonKey[16] = {0xeb,0xe4,0x2a,0x22,0x5e,0x85,0x93,0xe4,0x48,0xd9,0xc5,0x45,0x73,0x81,0xaa,0xf7};
u8 IV[16];
memset(IV, 0, sizeof IV);
memcpy(IV, pTicket + 0x01dc, 8);
AESDecode(CommonKey, IV, pTicket + 0x01bf, 16, pTicketKey);
u8 IV[16];
memset(IV, 0, sizeof IV);
memcpy(IV, pTicket + 0x01dc, 8);
AESDecode(CommonKey, IV, pTicket + 0x01bf, 16, pTicketKey);
}
bool CNANDContentLoader::ParseTMD(u8* pDataApp, u32 pDataAppSize, u8* pTicket, u8* pTMD)
@ -293,11 +293,11 @@ bool CNANDContentLoader::ParseTMD(u8* pDataApp, u32 pDataAppSize, u8* pTicket, u
GetKeyFromTicket(pTicket, DecryptTitleKey);
memcpy(m_TicketView, pTMD + 0x180, TICKET_VIEW_SIZE);
memcpy(m_TicketView, pTMD + 0x180, TICKET_VIEW_SIZE);
memcpy(m_TmdHeader, pTMD, TMD_HEADER_SIZE);
m_TileVersion = Common::swap16(pTMD + 0x01dc);
m_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_IosVersion = Common::swap16(pTMD + 0x018a);
@ -313,11 +313,11 @@ bool CNANDContentLoader::ParseTMD(u8* pDataApp, u32 pDataAppSize, u8* pTicket, u
rContent.m_ContentID = Common::swap32(pTMD + 0x01e4 + 0x24*i);
rContent.m_Index = Common::swap16(pTMD + 0x01e8 + 0x24*i);
rContent.m_Type = Common::swap16(pTMD + 0x01ea + 0x24*i);
rContent.m_Size= (u32)Common::swap64(pTMD + 0x01ec + 0x24*i);
memcpy(rContent.m_SHA1Hash, pTMD + 0x01f4 + 0x24*i, 20);
memcpy(rContent.m_Header, pTMD + 0x01e4 + 0x24*i, 36);
rContent.m_Size= (u32)Common::swap64(pTMD + 0x01ec + 0x24*i);
memcpy(rContent.m_SHA1Hash, pTMD + 0x01f4 + 0x24*i, 20);
memcpy(rContent.m_Header, pTMD + 0x01e4 + 0x24*i, 36);
u32 RoundedSize = ROUND_UP(rContent.m_Size, 0x40);
u32 RoundedSize = ROUND_UP(rContent.m_Size, 0x40);
rContent.m_pData = new u8[RoundedSize];
memset(IV, 0, sizeof IV);
@ -327,109 +327,53 @@ bool CNANDContentLoader::ParseTMD(u8* pDataApp, u32 pDataAppSize, u8* pTicket, u
p += RoundedSize;
}
return true;
return true;
}
const DiscIO::IVolume::ECountry CNANDContentLoader::GetCountry() const
{
DiscIO::IVolume::ECountry country = DiscIO::IVolume::COUNTRY_UNKNOWN;
if (!IsValid())
return DiscIO::IVolume::COUNTRY_UNKNOWN;
if (IsValid())
{
u64 TitleID = GetTitleID();
char* pTitleID = (char*)&TitleID;
u64 TitleID = GetTitleID();
char* pTitleID = (char*)&TitleID;
switch (pTitleID[0])
{
case 'S':
country = DiscIO::IVolume::COUNTRY_EUROPE;
break; // PAL // <- that is shitty :) zelda demo disc
return CountrySwitch((u8)pTitleID[0]);
case 'P':
country = DiscIO::IVolume::COUNTRY_EUROPE;
break; // PAL
case 'D':
country = DiscIO::IVolume::COUNTRY_EUROPE;
break; // PAL
case 'F':
country = DiscIO::IVolume::COUNTRY_FRANCE;
break; // PAL
case 'I':
country = DiscIO::IVolume::COUNTRY_ITALY;
break; // PAL
case 'X':
country = DiscIO::IVolume::COUNTRY_EUROPE;
break; // XIII <- uses X but is PAL rip
case 'E':
country = DiscIO::IVolume::COUNTRY_USA;
break; // USA
case 'J':
country = DiscIO::IVolume::COUNTRY_JAP;
break; // JAP
case 'K':
country = DiscIO::IVolume::COUNTRY_KOR;
break; // KOR
case 'O':
country = DiscIO::IVolume::COUNTRY_UNKNOWN;
break; // SDK
default:
PanicAlert("Unknown Country Code!");
break;
}
}
return(country);
}
///////////////////
CNANDContentManager CNANDContentManager::m_Instance;
CNANDContentManager::~CNANDContentManager()
{
CNANDContentMap::iterator itr = m_Map.begin();
while (itr != m_Map.end())
{
delete itr->second;
itr++;
}
m_Map.clear();
CNANDContentMap::iterator itr = m_Map.begin();
while (itr != m_Map.end())
{
delete itr->second;
itr++;
}
m_Map.clear();
}
const INANDContentLoader& CNANDContentManager::GetNANDLoader(const std::string& _rName)
{
std::string KeyString(_rName);
std::string KeyString(_rName);
std::transform(KeyString.begin(), KeyString.end(), KeyString.begin(),
(int(*)(int)) toupper);
std::transform(KeyString.begin(), KeyString.end(), KeyString.begin(),
(int(*)(int)) toupper);
CNANDContentMap::iterator itr = m_Map.find(KeyString);
if (itr != m_Map.end())
return *itr->second;
CNANDContentMap::iterator itr = m_Map.find(KeyString);
if (itr != m_Map.end())
return *itr->second;
m_Map[KeyString] = new CNANDContentLoader(KeyString);
return *m_Map[KeyString];
m_Map[KeyString] = new CNANDContentLoader(KeyString);
return *m_Map[KeyString];
}
} // namespace end

View File

@ -14,13 +14,14 @@ files = [
'FileHandlerARC.cpp',
'Filesystem.cpp',
'FileSystemGCWii.cpp',
'VolumeCommon.cpp',
'VolumeCreator.cpp',
'VolumeDirectory.cpp',
'VolumeGC.cpp',
'VolumeWad.cpp',
'VolumeWad.cpp',
'VolumeWiiCrypted.cpp',
'NANDContentLoader.cpp',
'WiiWad.cpp',
'WiiWad.cpp',
'AES/aes_cbc.c',
'AES/aes_core.c',
]

View File

@ -52,9 +52,11 @@ class IVolume
COUNTRY_EUROPE = 0,
COUNTRY_FRANCE = 1,
COUNTRY_USA = 2,
COUNTRY_JAP,
COUNTRY_KOR,
COUNTRY_JAPAN,
COUNTRY_KOREA,
COUNTRY_ITALY,
COUNTRY_TAIWAN,
COUNTRY_SDK,
COUNTRY_UNKNOWN,
NUMBER_OF_COUNTRIES
};
@ -62,6 +64,10 @@ class IVolume
virtual ECountry GetCountry() const = 0;
virtual u64 GetSize() const = 0;
};
// Generic Switch function for all volumes
IVolume::ECountry CountrySwitch(u8 CountryCode);
} // namespace
#endif

View File

@ -163,52 +163,7 @@ IVolume::ECountry CVolumeDirectory::GetCountry() const
u8 CountryCode = m_diskHeader[3];
ECountry country = COUNTRY_UNKNOWN;
switch (CountryCode)
{
case 'S':
country = COUNTRY_EUROPE;
break; // PAL <- that is shitty :) zelda demo disc
case 'P':
country = COUNTRY_EUROPE;
break; // PAL
case 'D':
country = COUNTRY_EUROPE;
break; // PAL
case 'F':
country = COUNTRY_FRANCE;
break; // PAL
case 'I':
country = COUNTRY_ITALY;
break; // PAL
case 'X':
country = COUNTRY_EUROPE;
break; // XIII <- uses X but is PAL rip
case 'E':
country = COUNTRY_USA;
break; // USA
case 'J':
country = COUNTRY_JAP;
break; // JAP
case 'O':
country = COUNTRY_UNKNOWN;
break; // SDK
default:
country = COUNTRY_UNKNOWN;
break;
}
return(country);
return CountrySwitch(CountryCode);
}
std::string CVolumeDirectory::GetMakerID() const
@ -250,18 +205,12 @@ u64 CVolumeDirectory::GetSize() const
return 0;
}
static const char DIR_SEPARATOR =
#ifdef _WIN32
'\\';
#else
'/';
#endif
std::string CVolumeDirectory::ExtractDirectoryName(const std::string& _rDirectory)
{
std::string directoryName = _rDirectory;
size_t lastSep = directoryName.find_last_of(DIR_SEPARATOR);
size_t lastSep = directoryName.find_last_of(DIR_SEP_CHR);
if(lastSep != directoryName.size() - 1)
{

View File

@ -70,53 +70,7 @@ IVolume::ECountry CVolumeGC::GetCountry() const
u8 CountryCode;
m_pReader->Read(3, 1, &CountryCode);
ECountry country = COUNTRY_UNKNOWN;
switch (CountryCode)
{
case 'S':
country = COUNTRY_EUROPE;
break; // PAL // <- that is shitty :) zelda demo disc
case 'P':
country = COUNTRY_EUROPE;
break; // PAL
case 'D':
country = COUNTRY_EUROPE;
break; // PAL
case 'F':
country = COUNTRY_FRANCE;
break; // PAL
case 'I':
country = COUNTRY_ITALY;
break; // PAL
case 'X':
country = COUNTRY_EUROPE;
break; // XIII <- uses X but is PAL
case 'E':
country = COUNTRY_USA;
break; // USA
case 'J':
country = COUNTRY_JAP;
break; // JAP
case 'O':
country = COUNTRY_UNKNOWN;
break; // SDK
default:
// PanicAlert(StringFromFormat("Unknown Country Code!").c_str());
country = COUNTRY_UNKNOWN;
break;
}
return(country);
return CountrySwitch(CountryCode);
}
std::string CVolumeGC::GetMakerID() const

View File

@ -1,202 +1,156 @@
// Copyright (C) 2003-2009 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "stdafx.h"
#include <math.h>
#include "VolumeWad.h"
#include "StringUtil.h"
#include "MathUtil.h"
#define ALIGN_40(x) ROUND_UP(Common::swap32(x), 0x40)
namespace DiscIO
{
CVolumeWAD::CVolumeWAD(IBlobReader* _pReader)
: m_pReader(_pReader), OpeningBnrOffset(0), hdr_size(0), cert_size(0), tick_size(0), tmd_size(0), data_size(0)
{
Read(0x00, 4, (u8*)&hdr_size);
Read(0x08, 4, (u8*)&cert_size);
Read(0x10, 4, (u8*)&tick_size);
Read(0x14, 4, (u8*)&tmd_size);
Read(0x18, 4, (u8*)&data_size);
OpeningBnrOffset = ALIGN_40(hdr_size) + ALIGN_40(cert_size) + ALIGN_40(tick_size) + ALIGN_40(tmd_size) + ALIGN_40(data_size);
}
CVolumeWAD::~CVolumeWAD()
{
delete m_pReader;
}
bool CVolumeWAD::Read(u64 _Offset, u64 _Length, u8* _pBuffer) const
{
if (m_pReader == NULL)
return false;
return m_pReader->Read(_Offset, _Length, _pBuffer);
}
IVolume::ECountry CVolumeWAD::GetCountry() const
{
if (!m_pReader)
return COUNTRY_UNKNOWN;
u8 CountryCode;
u32 Offset = ALIGN_40(hdr_size) + ALIGN_40(cert_size);
// read the last digit of the titleID in the ticket
Read(Offset + 0x01E3, 1, &CountryCode);
ECountry country = COUNTRY_UNKNOWN;
switch (CountryCode)
{
case 'S':
country = COUNTRY_EUROPE;
break; // PAL // <- that is shitty :) zelda demo disc
case 'P':
country = COUNTRY_EUROPE;
break; // PAL
case 'D':
country = COUNTRY_EUROPE;
break; // PAL
case 'F':
country = COUNTRY_FRANCE;
break; // PAL
case 'I':
country = COUNTRY_ITALY;
break; // PAL
case 'X':
country = COUNTRY_EUROPE;
break; // XIII <- uses X but is PAL
case 'E':
country = COUNTRY_USA;
break; // USA
case 'J':
country = COUNTRY_JAP;
break; // JAP
case 'O':
country = COUNTRY_UNKNOWN;
break; // SDK
default:
country = COUNTRY_UNKNOWN;
break;
}
return(country);
}
std::string CVolumeWAD::GetUniqueID() const
{
std::string temp = GetMakerID();
u32 Offset = ALIGN_40(hdr_size) + ALIGN_40(cert_size);
char GameCode[8];
if(!Read(Offset + 0x01E0, 4, (u8*)GameCode))
return "0";
GameCode[4] = temp.at(0);
GameCode[5] = temp.at(1);
GameCode[6] = 0;
return GameCode;
}
std::string CVolumeWAD::GetMakerID() const
{
u32 Offset = ALIGN_40(hdr_size) + ALIGN_40(cert_size) + ALIGN_40(tick_size);
char temp[3] = {1};
// Some weird channels use 0x0000 in place of the MakerID, so we need a check there
if (!Read(0x198 + Offset, 2, (u8*)temp) || temp[0] == 0 || temp[1] == 0)
return "00";
temp[2] = 0;
return temp;
}
bool CVolumeWAD::GetTitleID(u8* _pBuffer) const
{
u32 Offset = ALIGN_40(hdr_size) + ALIGN_40(cert_size);
if(!Read(Offset + 0x01DC, 8, _pBuffer))
return false;
return true;
}
std::string CVolumeWAD::GetName() const
{
u32 footer_size;
if (!Read(0x1C, 4, (u8*)&footer_size))
return "Unknown";
// Offset to the english title
char temp[85];
if (!Read(0xF1 + OpeningBnrOffset, 84, (u8*)&temp) || Common::swap32(footer_size) < 0xF1)
return "Unknown";
char out_temp[43];
int j = 0;
for (int i=0; i < 84; i++)
{
if (!(i & 1))
{
if (temp[i] != 0)
out_temp[j] = temp[i];
else
{
// Some wads have a few consecutive Null chars followed by text
// as i don't know what to do there: replace the frst one with space
if (out_temp[j-1] != 32)
out_temp[j] = 32;
else
continue;
}
j++;
}
}
out_temp[j] = 0;
return out_temp;
}
u64 CVolumeWAD::GetSize() const
{
if (m_pReader)
return (size_t)m_pReader->GetDataSize();
else
return 0;
}
} // namespace
// Copyright (C) 2003-2009 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "stdafx.h"
#include <math.h>
#include "VolumeWad.h"
#include "StringUtil.h"
#include "MathUtil.h"
#define ALIGN_40(x) ROUND_UP(Common::swap32(x), 0x40)
namespace DiscIO
{
CVolumeWAD::CVolumeWAD(IBlobReader* _pReader)
: m_pReader(_pReader), OpeningBnrOffset(0), hdr_size(0), cert_size(0), tick_size(0), tmd_size(0), data_size(0)
{
Read(0x00, 4, (u8*)&hdr_size);
Read(0x08, 4, (u8*)&cert_size);
Read(0x10, 4, (u8*)&tick_size);
Read(0x14, 4, (u8*)&tmd_size);
Read(0x18, 4, (u8*)&data_size);
OpeningBnrOffset = ALIGN_40(hdr_size) + ALIGN_40(cert_size) + ALIGN_40(tick_size) + ALIGN_40(tmd_size) + ALIGN_40(data_size);
}
CVolumeWAD::~CVolumeWAD()
{
delete m_pReader;
}
bool CVolumeWAD::Read(u64 _Offset, u64 _Length, u8* _pBuffer) const
{
if (m_pReader == NULL)
return false;
return m_pReader->Read(_Offset, _Length, _pBuffer);
}
IVolume::ECountry CVolumeWAD::GetCountry() const
{
if (!m_pReader)
return COUNTRY_UNKNOWN;
u8 CountryCode;
u32 Offset = ALIGN_40(hdr_size) + ALIGN_40(cert_size);
// read the last digit of the titleID in the ticket
Read(Offset + 0x01E3, 1, &CountryCode);
return CountrySwitch(CountryCode);
}
std::string CVolumeWAD::GetUniqueID() const
{
std::string temp = GetMakerID();
u32 Offset = ALIGN_40(hdr_size) + ALIGN_40(cert_size);
char GameCode[8];
if(!Read(Offset + 0x01E0, 4, (u8*)GameCode))
return "0";
GameCode[4] = temp.at(0);
GameCode[5] = temp.at(1);
GameCode[6] = 0;
return GameCode;
}
std::string CVolumeWAD::GetMakerID() const
{
u32 Offset = ALIGN_40(hdr_size) + ALIGN_40(cert_size) + ALIGN_40(tick_size);
char temp[3] = {1};
// Some weird channels use 0x0000 in place of the MakerID, so we need a check there
if (!Read(0x198 + Offset, 2, (u8*)temp) || temp[0] == 0 || temp[1] == 0)
return "00";
temp[2] = 0;
return temp;
}
bool CVolumeWAD::GetTitleID(u8* _pBuffer) const
{
u32 Offset = ALIGN_40(hdr_size) + ALIGN_40(cert_size);
if(!Read(Offset + 0x01DC, 8, _pBuffer))
return false;
return true;
}
std::string CVolumeWAD::GetName() const
{
u32 footer_size;
if (!Read(0x1C, 4, (u8*)&footer_size))
return "Unknown";
// Offset to the english title
char temp[85];
if (!Read(0xF1 + OpeningBnrOffset, 84, (u8*)&temp) || Common::swap32(footer_size) < 0xF1)
return "Unknown";
char out_temp[43];
int j = 0;
for (int i=0; i < 84; i++)
{
if (!(i & 1))
{
if (temp[i] != 0)
out_temp[j] = temp[i];
else
{
// Some wads have a few consecutive Null chars followed by text
// as i don't know what to do there: replace the frst one with space
if (out_temp[j-1] != 32)
out_temp[j] = 32;
else
continue;
}
j++;
}
}
out_temp[j] = 0;
return out_temp;
}
u64 CVolumeWAD::GetSize() const
{
if (m_pReader)
return (size_t)m_pReader->GetDataSize();
else
return 0;
}
} // namespace

View File

@ -121,63 +121,12 @@ std::string CVolumeWiiCrypted::GetUniqueID() const
IVolume::ECountry CVolumeWiiCrypted::GetCountry() const
{
if (!m_pReader)
{
return(COUNTRY_UNKNOWN);
}
return COUNTRY_UNKNOWN;
u8 CountryCode;
m_pReader->Read(3, 1, &CountryCode);
ECountry country = COUNTRY_UNKNOWN;
switch (CountryCode)
{
case 'S':
country = COUNTRY_EUROPE;
break; // PAL // <- that is shitty :) zelda demo disc
case 'P':
country = COUNTRY_EUROPE;
break; // PAL
case 'D':
country = COUNTRY_EUROPE;
break; // PAL
case 'F':
country = COUNTRY_FRANCE;
break; // PAL
case 'I':
country = COUNTRY_ITALY;
break; // PAL
case 'X':
country = COUNTRY_EUROPE;
break; // XIII <- uses X but is PAL rip
case 'E':
country = COUNTRY_USA;
break; // USA
case 'J':
country = COUNTRY_JAP;
break; // JAP
case 'K':
country = COUNTRY_KOR;
break; // KOR
case 'O':
country = COUNTRY_UNKNOWN;
break; // SDK
default:
PanicAlert("Unknown Country Code!");
break;
}
return(country);
return CountrySwitch(CountryCode);
}
std::string CVolumeWiiCrypted::GetMakerID() const