diff options
| author | Pierre Bourdon <delroth@gmail.com> | 2012-03-22 15:21:52 +0100 |
|---|---|---|
| committer | Pierre Bourdon <delroth@gmail.com> | 2012-03-22 15:21:52 +0100 |
| commit | 0ffc12bbfd6ac44b3030ec30f400a58e951087b7 (patch) | |
| tree | 53a6fac9ec79bcd71fe2046d8fb579478da12fd2 /Source/Core/DiscIO | |
| parent | 006923e871e496a7c6c0fe9ba76da4ee939ce14e (diff) | |
| parent | d95e31af3f779bfa3141047e8b6275e1fd2e4bbb (diff) | |
Merge branch 'master' into zcomploc-support
Conflicts:
Source/Core/VideoCommon/Src/PixelShaderGen.cpp
Diffstat (limited to 'Source/Core/DiscIO')
| -rw-r--r-- | Source/Core/DiscIO/DiscIO.vcxproj | 2 | ||||
| -rw-r--r-- | Source/Core/DiscIO/Src/BannerLoader.h | 3 | ||||
| -rw-r--r-- | Source/Core/DiscIO/Src/BannerLoaderWii.cpp | 73 | ||||
| -rw-r--r-- | Source/Core/DiscIO/Src/BannerLoaderWii.h | 28 | ||||
| -rw-r--r-- | Source/Core/DiscIO/Src/NANDContentLoader.cpp | 32 | ||||
| -rw-r--r-- | Source/Core/DiscIO/Src/NANDContentLoader.h | 2 | ||||
| -rw-r--r-- | Source/Core/DiscIO/Src/Volume.h | 1 | ||||
| -rw-r--r-- | Source/Core/DiscIO/Src/VolumeDirectory.cpp | 4 | ||||
| -rw-r--r-- | Source/Core/DiscIO/Src/VolumeWad.cpp | 45 | ||||
| -rw-r--r-- | Source/Core/DiscIO/Src/VolumeWad.h | 1 |
10 files changed, 141 insertions, 50 deletions
diff --git a/Source/Core/DiscIO/DiscIO.vcxproj b/Source/Core/DiscIO/DiscIO.vcxproj index 8c1f684213..d94ac13212 100644 --- a/Source/Core/DiscIO/DiscIO.vcxproj +++ b/Source/Core/DiscIO/DiscIO.vcxproj @@ -45,7 +45,6 @@ <UseDebugLibraries>false</UseDebugLibraries> <ConfigurationType>StaticLibrary</ConfigurationType> <CharacterSet>MultiByte</CharacterSet> - <WholeProgramOptimization>true</WholeProgramOptimization> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugFast|Win32'" Label="Configuration"> <ConfigurationType>StaticLibrary</ConfigurationType> @@ -56,7 +55,6 @@ <UseDebugLibraries>false</UseDebugLibraries> <ConfigurationType>StaticLibrary</ConfigurationType> <CharacterSet>MultiByte</CharacterSet> - <WholeProgramOptimization>true</WholeProgramOptimization> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugFast|x64'" Label="Configuration"> <ConfigurationType>StaticLibrary</ConfigurationType> diff --git a/Source/Core/DiscIO/Src/BannerLoader.h b/Source/Core/DiscIO/Src/BannerLoader.h index 02d60858e4..1fe48dd364 100644 --- a/Source/Core/DiscIO/Src/BannerLoader.h +++ b/Source/Core/DiscIO/Src/BannerLoader.h @@ -39,10 +39,11 @@ class IBannerLoader virtual bool GetBanner(u32* _pBannerImage) = 0; virtual bool GetName(std::string* _rName) = 0; - + virtual bool GetName(std::vector<std::wstring>& _rNames) {return false;}; virtual bool GetCompany(std::string& _rCompany) = 0; virtual bool GetDescription(std::string* _rDescription) = 0; + virtual bool GetDescription(std::wstring& _rDescription) {return false;}; protected: diff --git a/Source/Core/DiscIO/Src/BannerLoaderWii.cpp b/Source/Core/DiscIO/Src/BannerLoaderWii.cpp index 9c02ef8d08..b23dc4d91a 100644 --- a/Source/Core/DiscIO/Src/BannerLoaderWii.cpp +++ b/Source/Core/DiscIO/Src/BannerLoaderWii.cpp @@ -144,26 +144,59 @@ bool CBannerLoaderWii::GetBanner(u32* _pBannerImage) return true; } -bool CBannerLoaderWii::GetName(std::string* _rName) +bool CBannerLoaderWii::GetStringFromComments(const CommentIndex index, std::string& s) +{ + bool ret = false; + + if (IsValid()) + { + // find Banner type + SWiiBanner *pBanner = (SWiiBanner*)m_pBannerFile; + + // Ensure the string is null-terminating, since the banner format + // doesn't require it + u16 *src = new u16[COMMENT_SIZE + 1]; + memcpy(src, &pBanner->m_Comment[index], COMMENT_SIZE * sizeof(u16)); + src[COMMENT_SIZE] = 0; + + ret = CopyBeUnicodeToString(s, src, COMMENT_SIZE + 1); + + delete [] src; + } + + return ret; +} + +bool CBannerLoaderWii::GetStringFromComments(const CommentIndex index, std::wstring& s) { if (IsValid()) { // find Banner type SWiiBanner* pBanner = (SWiiBanner*)m_pBannerFile; - std::string name; - if (CopyBeUnicodeToString(name, pBanner->m_Comment[0], WII_BANNER_COMMENT_SIZE)) - { - for (int i = 0; i < 6; i++) - { - _rName[i] = name; - } - return true; - } + std::wstring description; + for (int i = 0; i < COMMENT_SIZE; ++i) + description.push_back(Common::swap16(pBanner->m_Comment[index][i])); + + s = description; + return true; } return false; } +bool CBannerLoaderWii::GetName(std::string* _rName) +{ + return GetStringFromComments(NAME_IDX, *_rName); +} + +bool CBannerLoaderWii::GetName(std::vector<std::wstring>& _rNames) +{ + std::wstring temp; + bool ret = GetStringFromComments(NAME_IDX, temp); + _rNames.push_back(temp); + return ret; +} + bool CBannerLoaderWii::GetCompany(std::string& _rCompany) { _rCompany = "N/A"; @@ -172,22 +205,12 @@ bool CBannerLoaderWii::GetCompany(std::string& _rCompany) bool CBannerLoaderWii::GetDescription(std::string* _rDescription) { - if (IsValid()) - { - // find Banner type - SWiiBanner* pBanner = (SWiiBanner*)m_pBannerFile; + return GetStringFromComments(DESC_IDX, *_rDescription); +} - std::string description; - if (CopyBeUnicodeToString(description, pBanner->m_Comment[1], WII_BANNER_COMMENT_SIZE)) - { - for (int i = 0; i< 6; i++) - { - _rDescription[i] = description; - } - return true; - } - } - return false; +bool CBannerLoaderWii::GetDescription(std::wstring& _rDescription) +{ + return GetStringFromComments(DESC_IDX, _rDescription); } void CBannerLoaderWii::decode5A3image(u32* dst, u16* src, int width, int height) diff --git a/Source/Core/DiscIO/Src/BannerLoaderWii.h b/Source/Core/DiscIO/Src/BannerLoaderWii.h index fb28f5a2e0..83733cf5ed 100644 --- a/Source/Core/DiscIO/Src/BannerLoaderWii.h +++ b/Source/Core/DiscIO/Src/BannerLoaderWii.h @@ -37,16 +37,28 @@ class CBannerLoaderWii virtual bool GetName(std::string* _rName); + bool GetName(std::vector<std::wstring>& _rNames); + virtual bool GetCompany(std::string& _rCompany); virtual bool GetDescription(std::string* _rDescription); + bool GetDescription(std::wstring& _rDescription); private: - #define WII_BANNER_TEXTURE_SIZE (192 * 64 * 2) - #define WII_BANNER_ICON_SIZE ( 48 * 48 * 2) - #define WII_BANNER_COMMENT_SIZE 32 + enum + { + TEXTURE_SIZE = 192 * 64 * 2, + ICON_SIZE = 48 * 48 * 2, + COMMENT_SIZE = 32 + }; + + enum CommentIndex + { + NAME_IDX, + DESC_IDX + }; struct SWiiBanner { @@ -56,9 +68,10 @@ class CBannerLoaderWii u16 m_Speed; u8 m_Unknown[22]; - u16 m_Comment[2][WII_BANNER_COMMENT_SIZE]; - u8 m_BannerTexture[WII_BANNER_TEXTURE_SIZE]; - u8 m_IconTexture[8][WII_BANNER_ICON_SIZE]; + // Not null terminated! + u16 m_Comment[2][COMMENT_SIZE]; + u8 m_BannerTexture[TEXTURE_SIZE]; + u8 m_IconTexture[8][ICON_SIZE]; } ; u8* m_pBannerFile; @@ -66,6 +79,9 @@ class CBannerLoaderWii bool m_IsValid; void decode5A3image(u32* dst, u16* src, int width, int height); + + bool GetStringFromComments(const CommentIndex index, std::string& s); + bool GetStringFromComments(const CommentIndex index, std::wstring& s); }; } // namespace diff --git a/Source/Core/DiscIO/Src/NANDContentLoader.cpp b/Source/Core/DiscIO/Src/NANDContentLoader.cpp index c8e409636b..f010b7ed98 100644 --- a/Source/Core/DiscIO/Src/NANDContentLoader.cpp +++ b/Source/Core/DiscIO/Src/NANDContentLoader.cpp @@ -191,6 +191,8 @@ const SNANDContent* CNANDContentLoader::GetContentByIndex(int _Index) const bool CNANDContentLoader::Initialize(const std::string& _rName) { + if (_rName.empty()) + return false; m_Path = _rName; WiiWAD Wad(_rName); u8* pDataApp = NULL; @@ -221,7 +223,7 @@ bool CNANDContentLoader::Initialize(const std::string& _rName) File::IOFile pTMDFile(TMDFileName, "rb"); if (!pTMDFile) { - ERROR_LOG(DISCIO, "CreateFromDirectory: error opening %s", + DEBUG_LOG(DISCIO, "CreateFromDirectory: error opening %s", TMDFileName.c_str()); return false; } @@ -536,20 +538,14 @@ u64 CNANDContentManager::Install_WiiWAD(std::string &fileName) pTMDFile.Close(); - //Extract and copy WAD's ticket to ticket directory - std::string TicketFileName = Common::GetTicketFileName(TitleID); - File::CreateFullPath(TicketFileName); - File::IOFile pTicketFile(TicketFileName, "wb"); - if (!pTicketFile) - { - PanicAlertT("WAD installation failed: error creating %s", TicketFileName.c_str()); - return 0; - } - if (ContentLoader.GetTIK()) + + //Extract and copy WAD's ticket to ticket directory + if (!Add_Ticket(TitleID, ContentLoader.GetTIK(), ContentLoader.GetTIKSize())) { - pTicketFile.WriteBytes(ContentLoader.GetTIK(), ContentLoader.GetTIKSize()); + PanicAlertT("WAD installation failed: error creating ticket"); + return 0; } cUIDsys::AccessInstance().AddTitle(TitleID); @@ -558,6 +554,18 @@ u64 CNANDContentManager::Install_WiiWAD(std::string &fileName) return TitleID; } +bool Add_Ticket(u64 TitleID, const u8 *p_tik, u32 tikSize) +{ + std::string TicketFileName = Common::GetTicketFileName(TitleID); + File::CreateFullPath(TicketFileName); + File::IOFile pTicketFile(TicketFileName, "wb"); + if (!pTicketFile || !p_tik) + { + //PanicAlertT("WAD installation failed: error creating %s", TicketFileName.c_str()); + return false; + } + return pTicketFile.WriteBytes(p_tik, tikSize); +} } // namespace end diff --git a/Source/Core/DiscIO/Src/NANDContentLoader.h b/Source/Core/DiscIO/Src/NANDContentLoader.h index 14a2062641..63135df693 100644 --- a/Source/Core/DiscIO/Src/NANDContentLoader.h +++ b/Source/Core/DiscIO/Src/NANDContentLoader.h @@ -29,7 +29,7 @@ namespace DiscIO { - + bool Add_Ticket(u64 TitleID, const u8 *p_tik, u32 tikSize); struct SNANDContent { u32 m_ContentID; diff --git a/Source/Core/DiscIO/Src/Volume.h b/Source/Core/DiscIO/Src/Volume.h index f1bb5d3773..ec20e47b6c 100644 --- a/Source/Core/DiscIO/Src/Volume.h +++ b/Source/Core/DiscIO/Src/Volume.h @@ -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; diff --git a/Source/Core/DiscIO/Src/VolumeDirectory.cpp b/Source/Core/DiscIO/Src/VolumeDirectory.cpp index 08188bac71..52e9f4389a 100644 --- a/Source/Core/DiscIO/Src/VolumeDirectory.cpp +++ b/Source/Core/DiscIO/Src/VolumeDirectory.cpp @@ -389,8 +389,8 @@ void CVolumeDirectory::BuildFST() // write FST size and location _dbg_assert_(DVDINTERFACE, m_diskHeader); Write32((u32)(FST_ADDRESS >> m_addressShift), 0x0424, m_diskHeader); - Write32((u32)m_fstSize, 0x0428, m_diskHeader); - Write32((u32)m_fstSize, 0x042c, m_diskHeader); + Write32((u32)(m_fstSize >> m_addressShift), 0x0428, m_diskHeader); + Write32((u32)(m_fstSize >> m_addressShift), 0x042c, m_diskHeader); } void CVolumeDirectory::WriteToBuffer(u64 _SrcStartAddress, u64 _SrcLength, u8* _Src, diff --git a/Source/Core/DiscIO/Src/VolumeWad.cpp b/Source/Core/DiscIO/Src/VolumeWad.cpp index 5fd81cca8b..0cdfc85925 100644 --- a/Source/Core/DiscIO/Src/VolumeWad.cpp +++ b/Source/Core/DiscIO/Src/VolumeWad.cpp @@ -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 diff --git a/Source/Core/DiscIO/Src/VolumeWad.h b/Source/Core/DiscIO/Src/VolumeWad.h index 06bd772699..956844acd1 100644 --- a/Source/Core/DiscIO/Src/VolumeWad.h +++ b/Source/Core/DiscIO/Src/VolumeWad.h @@ -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; |
