summaryrefslogtreecommitdiff
path: root/Source/Core/DiscIO
diff options
context:
space:
mode:
authorJosJuice <josjuice@gmail.com>2020-05-04 12:41:14 +0200
committerJosJuice <josjuice@gmail.com>2020-06-17 13:47:34 +0200
commite2ae2b3b0b11cc869468bed8a850e2012a68c2d9 (patch)
tree08bee1474f681df23d17cd04e1d6fed5471828be /Source/Core/DiscIO
parentf21a254042d4f92b8ff81684a29e8393ac6231e0 (diff)
Add new file format RVZ based on WIA
Diffstat (limited to 'Source/Core/DiscIO')
-rw-r--r--Source/Core/DiscIO/Blob.cpp1
-rw-r--r--Source/Core/DiscIO/Blob.h5
-rw-r--r--Source/Core/DiscIO/WIABlob.cpp35
-rw-r--r--Source/Core/DiscIO/WIABlob.h16
4 files changed, 39 insertions, 18 deletions
diff --git a/Source/Core/DiscIO/Blob.cpp b/Source/Core/DiscIO/Blob.cpp
index 97e48eb047..c2c44caa60 100644
--- a/Source/Core/DiscIO/Blob.cpp
+++ b/Source/Core/DiscIO/Blob.cpp
@@ -207,6 +207,7 @@ std::unique_ptr<BlobReader> CreateBlobReader(const std::string& filename)
case WBFS_MAGIC:
return WbfsFileReader::Create(std::move(file), filename);
case WIA_MAGIC:
+ case RVZ_MAGIC:
return WIAFileReader::Create(std::move(file), filename);
default:
if (auto directory_blob = DirectoryBlobReader::Create(filename))
diff --git a/Source/Core/DiscIO/Blob.h b/Source/Core/DiscIO/Blob.h
index 49e42e6741..149df2afc3 100644
--- a/Source/Core/DiscIO/Blob.h
+++ b/Source/Core/DiscIO/Blob.h
@@ -37,7 +37,8 @@ enum class BlobType
CISO,
WBFS,
TGC,
- WIA
+ WIA,
+ RVZ,
};
class BlobReader
@@ -176,7 +177,7 @@ bool ConvertToPlain(BlobReader* infile, const std::string& infile_path,
const std::string& outfile_path, CompressCB callback = nullptr,
void* arg = nullptr);
bool ConvertToWIA(BlobReader* infile, const std::string& infile_path,
- const std::string& outfile_path, WIACompressionType compression_type,
+ const std::string& outfile_path, bool rvz, WIACompressionType compression_type,
int compression_level, int chunk_size, CompressCB callback = nullptr,
void* arg = nullptr);
diff --git a/Source/Core/DiscIO/WIABlob.cpp b/Source/Core/DiscIO/WIABlob.cpp
index 1924c7d08d..7414c48221 100644
--- a/Source/Core/DiscIO/WIABlob.cpp
+++ b/Source/Core/DiscIO/WIABlob.cpp
@@ -51,14 +51,21 @@ bool WIAFileReader::Initialize(const std::string& path)
if (!m_file.Seek(0, SEEK_SET) || !m_file.ReadArray(&m_header_1, 1))
return false;
- if (m_header_1.magic != WIA_MAGIC)
+ if (m_header_1.magic != WIA_MAGIC && m_header_1.magic != RVZ_MAGIC)
return false;
- const u32 version = Common::swap32(m_header_1.version);
- const u32 version_compatible = Common::swap32(m_header_1.version_compatible);
- if (WIA_VERSION < version_compatible || WIA_VERSION_READ_COMPATIBLE > version)
+ m_rvz = m_header_1.magic == RVZ_MAGIC;
+
+ const u32 version = m_rvz ? RVZ_VERSION : WIA_VERSION;
+ const u32 version_read_compatible =
+ m_rvz ? RVZ_VERSION_READ_COMPATIBLE : WIA_VERSION_READ_COMPATIBLE;
+
+ const u32 file_version = Common::swap32(m_header_1.version);
+ const u32 file_version_compatible = Common::swap32(m_header_1.version_compatible);
+
+ if (version < file_version_compatible || version_read_compatible > file_version)
{
- ERROR_LOG(DISCIO, "Unsupported WIA version %s in %s", VersionToString(version).c_str(),
+ ERROR_LOG(DISCIO, "Unsupported version %s in %s", VersionToString(file_version).c_str(),
path.c_str());
return false;
}
@@ -229,6 +236,11 @@ std::unique_ptr<WIAFileReader> WIAFileReader::Create(File::IOFile file, const st
return blob->m_valid ? std::move(blob) : nullptr;
}
+BlobType WIAFileReader::GetBlobType() const
+{
+ return m_rvz ? BlobType::RVZ : BlobType::WIA;
+}
+
bool WIAFileReader::Read(u64 offset, u64 size, u8* out_ptr)
{
if (offset + size > Common::swap64(m_header_1.iso_file_size))
@@ -1730,7 +1742,7 @@ bool WIAFileReader::WriteHeader(File::IOFile* file, const u8* data, size_t size,
ConversionResultCode
WIAFileReader::ConvertToWIA(BlobReader* infile, const VolumeDisc* infile_volume,
- File::IOFile* outfile, WIACompressionType compression_type,
+ File::IOFile* outfile, bool rvz, WIACompressionType compression_type,
int compression_level, int chunk_size, CompressCB callback, void* arg)
{
ASSERT(infile->IsDataSizeAccurate());
@@ -1952,9 +1964,10 @@ WIAFileReader::ConvertToWIA(BlobReader* infile, const VolumeDisc* infile_volume,
header_2.group_entries_offset = Common::swap64(group_entries_offset);
header_2.group_entries_size = Common::swap32(static_cast<u32>(compressed_group_entries->size()));
- header_1.magic = WIA_MAGIC;
- header_1.version = Common::swap32(WIA_VERSION);
- header_1.version_compatible = Common::swap32(WIA_VERSION_WRITE_COMPATIBLE);
+ header_1.magic = rvz ? RVZ_MAGIC : WIA_MAGIC;
+ header_1.version = Common::swap32(rvz ? RVZ_VERSION : WIA_VERSION);
+ header_1.version_compatible =
+ Common::swap32(rvz ? RVZ_VERSION_WRITE_COMPATIBLE : WIA_VERSION_WRITE_COMPATIBLE);
header_1.header_2_size = Common::swap32(sizeof(WIAHeader2));
mbedtls_sha1_ret(reinterpret_cast<const u8*>(&header_2), sizeof(header_2),
header_1.header_2_hash.data());
@@ -1975,7 +1988,7 @@ WIAFileReader::ConvertToWIA(BlobReader* infile, const VolumeDisc* infile_volume,
}
bool ConvertToWIA(BlobReader* infile, const std::string& infile_path,
- const std::string& outfile_path, WIACompressionType compression_type,
+ const std::string& outfile_path, bool rvz, WIACompressionType compression_type,
int compression_level, int chunk_size, CompressCB callback, void* arg)
{
File::IOFile outfile(outfile_path, "wb");
@@ -1991,7 +2004,7 @@ bool ConvertToWIA(BlobReader* infile, const std::string& infile_path,
std::unique_ptr<VolumeDisc> infile_volume = CreateDisc(infile_path);
const ConversionResultCode result =
- WIAFileReader::ConvertToWIA(infile, infile_volume.get(), &outfile, compression_type,
+ WIAFileReader::ConvertToWIA(infile, infile_volume.get(), &outfile, rvz, compression_type,
compression_level, chunk_size, callback, arg);
if (result == ConversionResultCode::ReadFailed)
diff --git a/Source/Core/DiscIO/WIABlob.h b/Source/Core/DiscIO/WIABlob.h
index 653f7312f3..356d8a3edb 100644
--- a/Source/Core/DiscIO/WIABlob.h
+++ b/Source/Core/DiscIO/WIABlob.h
@@ -37,6 +37,7 @@ enum class WIACompressionType : u32
};
constexpr u32 WIA_MAGIC = 0x01414957; // "WIA\x1" (byteswapped to little endian)
+constexpr u32 RVZ_MAGIC = 0x015A5652; // "RVZ\x1" (byteswapped to little endian)
class WIAFileReader : public BlobReader
{
@@ -45,7 +46,7 @@ public:
static std::unique_ptr<WIAFileReader> Create(File::IOFile file, const std::string& path);
- BlobType GetBlobType() const override { return BlobType::WIA; }
+ BlobType GetBlobType() const override;
u64 GetRawSize() const override { return Common::swap64(m_header_1.wia_file_size); }
u64 GetDataSize() const override { return Common::swap64(m_header_1.iso_file_size); }
@@ -59,7 +60,7 @@ public:
bool ReadWiiDecrypted(u64 offset, u64 size, u8* out_ptr, u64 partition_data_offset) override;
static ConversionResultCode ConvertToWIA(BlobReader* infile, const VolumeDisc* infile_volume,
- File::IOFile* outfile,
+ File::IOFile* outfile, bool rvz,
WIACompressionType compression_type,
int compression_level, int chunk_size,
CompressCB callback, void* arg);
@@ -489,6 +490,7 @@ private:
}
bool m_valid;
+ bool m_rvz;
WIACompressionType m_compression_type;
File::IOFile m_file;
@@ -504,13 +506,17 @@ private:
std::map<u64, DataEntry> m_data_entries;
+ // Perhaps we could set WIA_VERSION_WRITE_COMPATIBLE to 0.9, but WIA version 0.9 was never in
+ // any official release of wit, and interim versions (either source or binaries) are hard to find.
+ // Since we've been unable to check if we're write compatible with 0.9, we set it 1.0 to be safe.
+
static constexpr u32 WIA_VERSION = 0x01000000;
static constexpr u32 WIA_VERSION_WRITE_COMPATIBLE = 0x01000000;
static constexpr u32 WIA_VERSION_READ_COMPATIBLE = 0x00080000;
- // Perhaps we could set WIA_VERSION_WRITE_COMPATIBLE to 0.9, but WIA version 0.9 was never in
- // any official release of wit, and interim versions (either source or binaries) are hard to find.
- // Since we've been unable to check if we're write compatible with 0.9, we set it 1.0 to be safe.
+ static constexpr u32 RVZ_VERSION = 0x00010000;
+ static constexpr u32 RVZ_VERSION_WRITE_COMPATIBLE = 0x00010000;
+ static constexpr u32 RVZ_VERSION_READ_COMPATIBLE = 0x00010000;
};
} // namespace DiscIO