add the function to read all unicode gamenames from a wad file

This commit is contained in:
LPFaint99 2011-12-18 21:42:20 -08:00
parent 4ecb48eaf8
commit a73ad3554c
3 changed files with 46 additions and 1 deletions

View File

@ -38,6 +38,7 @@ public:
virtual std::string GetUniqueID() const = 0;
virtual std::string GetMakerID() const = 0;
virtual std::string GetName() const = 0;
virtual bool GetWName(std::vector<std::wstring>& _rwNames) const {return false;};
virtual u32 GetFSTSize() const = 0;
virtual std::string GetApploaderDate() const = 0;

View File

@ -107,6 +107,45 @@ bool CVolumeWAD::GetTitleID(u8* _pBuffer) const
return true;
}
bool CVolumeWAD::GetWName(std::vector<std::wstring>& _rwNames) const
{
u32 footer_size;
if (!Read(0x1C, 4, (u8*)&footer_size))
{
return false;
}
//Japanese, English, German, French, Spanish, Italian, Dutch, unknown, unknown, Korean
// Offset to the english title
for (int i = 0; i < 10; i++)
{
u16 temp[42];
std::wstring out_temp;
if (!Read(0x9C + (i*84) + OpeningBnrOffset, 84, (u8*)&temp) || Common::swap32(footer_size) < 0xF1
|| !temp[0])
{
_rwNames.push_back(L"");
continue;
}
for (int i = 0; i < 42; ++i)
{
u16 t = Common::swap16(temp[i]);
if (t == 0 && i > 0)
{
if (out_temp.at(out_temp.size()-1) != ' ')
out_temp.push_back(' ');
}
else
out_temp.push_back(t);
}
_rwNames.push_back(out_temp);
}
return true;
}
std::string CVolumeWAD::GetName() const
{
u32 footer_size;
@ -114,9 +153,13 @@ std::string CVolumeWAD::GetName() const
if (!Read(0x1C, 4, (u8*)&footer_size))
return "";
//Japanese, English, German, French, Spanish, Italian, Dutch, unknown, unknown, Korean
// Offset to the english title
char temp[84];
if (!Read(0xF1 + OpeningBnrOffset, 84, (u8*)&temp) || Common::swap32(footer_size) < 0xF1)
if (!Read(0xF1 + OpeningBnrOffset, 84, (u8*)&temp) || Common::swap32(footer_size) < 0xF1 ||
!Common::swap16(temp[0]))
return "";
// Remove the null bytes due to 16bit char length

View File

@ -39,6 +39,7 @@ public:
std::string GetUniqueID() const;
std::string GetMakerID() const;
std::string GetName() const;
bool GetWName(std::vector<std::wstring>& _rwNames) const;
u32 GetFSTSize() const { return 0; }
std::string GetApploaderDate() const { return "0"; }
ECountry GetCountry() const;