From f004fb17d4567c05844a40afb33ab9e9bae5b241 Mon Sep 17 00:00:00 2001 From: "XTra.KrazzY" Date: Sat, 6 Jun 2009 14:33:52 +0000 Subject: [PATCH] Incomplete work on extracting banners from Wii images without savefiles. Please finish my work. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3336 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/DiscIO/Src/BannerLoaderWii.cpp | 37 +++++++++++++++++++++- Source/Core/DiscIO/Src/FileHandlerARC.cpp | 20 ++++++++++-- Source/Core/DiscIO/Src/FileHandlerARC.h | 2 ++ 3 files changed, 55 insertions(+), 4 deletions(-) diff --git a/Source/Core/DiscIO/Src/BannerLoaderWii.cpp b/Source/Core/DiscIO/Src/BannerLoaderWii.cpp index c03287aa28..f919611026 100644 --- a/Source/Core/DiscIO/Src/BannerLoaderWii.cpp +++ b/Source/Core/DiscIO/Src/BannerLoaderWii.cpp @@ -23,6 +23,7 @@ #include "ColorUtil.h" #include "BannerLoaderWii.h" #include "FileUtil.h" +#include "FileHandlerARC.h" namespace DiscIO { @@ -42,11 +43,45 @@ CBannerLoaderWii::CBannerLoaderWii(DiscIO::IFileSystem& _rFileSystem) if (!File::Exists(Filename)) { + // TODO(XK): Finish the 'commented' code. Turns out the banner.bin + // from the savefiles is very different from the banner.bin + // inside opening.bnr +#if 0 + char bnrFilename[260], titleFolder[260]; + + // Creating title folder + sprintf(titleFolder, FULL_WII_USER_DIR "title/%08x/%08x/data/", + (u32)(TitleID>>32), (u32)TitleID); + if(!File::Exists(titleFolder)) + File::CreateFullPath(titleFolder); + + // Extracting banner.bin from opening.bnr + sprintf(bnrFilename, FULL_WII_USER_DIR "title/%08x/%08x/data/opening.bnr", + (u32)(TitleID>>32), (u32)TitleID); + + if(!_rFileSystem.ExportFile("opening.bnr", bnrFilename)) { + m_IsValid = false; + return; + } + + CARCFile bnrArc (bnrFilename, 0x600); + + if(!bnrArc.ExportFile("meta/banner.bin", Filename)) { + m_IsValid = false; + return; + } + + // Now we have an LZ77-compressed file with a short IMD5 header + // TODO: Finish the job + + File::Delete(bnrFilename); +#else m_IsValid = false; return; +#endif } - // load the opening.bnr + // load the banner.bin size_t FileSize = (size_t) File::GetSize(Filename); if (FileSize > 0) diff --git a/Source/Core/DiscIO/Src/FileHandlerARC.cpp b/Source/Core/DiscIO/Src/FileHandlerARC.cpp index d6b5374cc8..71bd32bf08 100644 --- a/Source/Core/DiscIO/Src/FileHandlerARC.cpp +++ b/Source/Core/DiscIO/Src/FileHandlerARC.cpp @@ -43,6 +43,22 @@ CARCFile::CARCFile(const std::string& _rFilename) } } +CARCFile::CARCFile(const std::string& _rFilename, u32 offset) + : m_pBuffer(NULL) + , m_Initialized(false) +{ + DiscIO::IBlobReader* pReader = DiscIO::CreateBlobReader(_rFilename.c_str()); + if (pReader != NULL) + { + u64 FileSize = pReader->GetDataSize() - offset; + m_pBuffer = new u8[(u32)FileSize]; + pReader->Read(offset, FileSize, m_pBuffer); + delete pReader; + + m_Initialized = ParseBuffer(); + } +} + CARCFile::CARCFile(const u8* _pBuffer, size_t _BufferSize) : m_pBuffer(NULL) , m_Initialized(false) @@ -156,9 +172,7 @@ CARCFile::ParseBuffer() u32 ID = Common::swap32(*(u32*)(m_pBuffer)); if (ID != ARC_ID) - { - return(false); - } + return false; // read header u32 FSTOffset = Common::swap32(*(u32*)(m_pBuffer + 0x4)); diff --git a/Source/Core/DiscIO/Src/FileHandlerARC.h b/Source/Core/DiscIO/Src/FileHandlerARC.h index 800f11fa91..75dea4ccf0 100644 --- a/Source/Core/DiscIO/Src/FileHandlerARC.h +++ b/Source/Core/DiscIO/Src/FileHandlerARC.h @@ -32,6 +32,8 @@ class CARCFile CARCFile(const std::string& _rFilename); + CARCFile(const std::string& _rFilename, u32 offset); + CARCFile(const u8* _pBuffer, size_t _BufferSize); virtual ~CARCFile();