DiscIO: Move magic constants for discs to DiscUtils
This commit is contained in:
parent
b14bf82732
commit
7d570f1edb
|
@ -28,6 +28,7 @@
|
|||
#include "Core/Boot/DolReader.h"
|
||||
#include "Core/IOS/ES/Formats.h"
|
||||
#include "DiscIO/Blob.h"
|
||||
#include "DiscIO/DiscUtils.h"
|
||||
#include "DiscIO/VolumeWii.h"
|
||||
#include "DiscIO/WiiEncryptionCache.h"
|
||||
|
||||
|
@ -653,8 +654,8 @@ void DirectoryBlobPartition::SetDiscHeaderAndDiscType(std::optional<bool> is_wii
|
|||
}
|
||||
else
|
||||
{
|
||||
m_is_wii = Common::swap32(&m_disc_header[0x18]) == 0x5d1c9ea3;
|
||||
const bool is_gc = Common::swap32(&m_disc_header[0x1c]) == 0xc2339f3d;
|
||||
m_is_wii = Common::swap32(&m_disc_header[0x18]) == WII_DISC_MAGIC;
|
||||
const bool is_gc = Common::swap32(&m_disc_header[0x1c]) == GAMECUBE_DISC_MAGIC;
|
||||
if (m_is_wii == is_gc)
|
||||
ERROR_LOG_FMT(DISCIO, "Couldn't detect disc type based on {}", boot_bin_path);
|
||||
}
|
||||
|
|
|
@ -130,10 +130,9 @@ u64 GetBiggestReferencedOffset(const Volume& volume)
|
|||
// This can happen when certain programs that create WBFS files scrub the entirety of
|
||||
// the Masterpiece partitions in Super Smash Bros. Brawl without removing them from
|
||||
// the partition table. https://bugs.dolphin-emu.org/issues/8733
|
||||
constexpr u32 WII_MAGIC = 0x5D1C9EA3;
|
||||
const auto it =
|
||||
std::remove_if(partitions.begin(), partitions.end(), [&](const Partition& partition) {
|
||||
return volume.ReadSwapped<u32>(0x18, partition) != WII_MAGIC;
|
||||
return volume.ReadSwapped<u32>(0x18, partition) != WII_DISC_MAGIC;
|
||||
});
|
||||
partitions.erase(it, partitions.end());
|
||||
|
||||
|
|
|
@ -22,6 +22,9 @@ constexpr u64 SL_DVD_R_SIZE = 4707319808; // Wii RVT-R
|
|||
constexpr u64 DL_DVD_SIZE = 8511160320; // Wii retail
|
||||
constexpr u64 DL_DVD_R_SIZE = 8543666176; // Wii RVT-R
|
||||
|
||||
constexpr u32 GAMECUBE_DISC_MAGIC = 0xC2339F3D;
|
||||
constexpr u32 WII_DISC_MAGIC = 0x5D1C9EA3;
|
||||
|
||||
constexpr u32 PARTITION_DATA = 0;
|
||||
constexpr u32 PARTITION_UPDATE = 1;
|
||||
constexpr u32 PARTITION_CHANNEL = 2; // Mario Kart Wii, Wii Fit, Wii Fit Plus, Rabbids Go Home
|
||||
|
|
|
@ -232,9 +232,9 @@ FileSystemGCWii::FileSystemGCWii(const VolumeDisc* volume, const Partition& part
|
|||
{
|
||||
u8 offset_shift;
|
||||
// Check if this is a GameCube or Wii disc
|
||||
if (volume->ReadSwapped<u32>(0x18, partition) == u32(0x5D1C9EA3))
|
||||
if (volume->ReadSwapped<u32>(0x18, partition) == WII_DISC_MAGIC)
|
||||
offset_shift = 2; // Wii file system
|
||||
else if (volume->ReadSwapped<u32>(0x1c, partition) == u32(0xC2339F3D))
|
||||
else if (volume->ReadSwapped<u32>(0x1c, partition) == GAMECUBE_DISC_MAGIC)
|
||||
offset_shift = 0; // GameCube file system
|
||||
else
|
||||
return; // Invalid partition (maybe someone removed its data but not its partition table entry)
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include "Core/IOS/ES/Formats.h"
|
||||
#include "DiscIO/Blob.h"
|
||||
#include "DiscIO/DiscUtils.h"
|
||||
#include "DiscIO/Enums.h"
|
||||
#include "DiscIO/VolumeDisc.h"
|
||||
#include "DiscIO/VolumeGC.h"
|
||||
|
@ -87,14 +88,10 @@ std::map<Language, std::string> Volume::ReadWiiNames(const std::vector<char16_t>
|
|||
|
||||
static std::unique_ptr<VolumeDisc> CreateDisc(std::unique_ptr<BlobReader>& reader)
|
||||
{
|
||||
// Check for Wii
|
||||
const std::optional<u32> wii_magic = reader->ReadSwapped<u32>(0x18);
|
||||
if (wii_magic == u32(0x5D1C9EA3))
|
||||
if (reader->ReadSwapped<u32>(0x18) == WII_DISC_MAGIC)
|
||||
return std::make_unique<VolumeWii>(std::move(reader));
|
||||
|
||||
// Check for GC
|
||||
const std::optional<u32> gc_magic = reader->ReadSwapped<u32>(0x1C);
|
||||
if (gc_magic == u32(0xC2339F3D))
|
||||
if (reader->ReadSwapped<u32>(0x1C) == GAMECUBE_DISC_MAGIC)
|
||||
return std::make_unique<VolumeGC>(std::move(reader));
|
||||
|
||||
// No known magic words found
|
||||
|
|
|
@ -523,12 +523,11 @@ bool VolumeVerifier::CheckPartition(const Partition& partition)
|
|||
bool invalid_header = false;
|
||||
bool blank_contents = false;
|
||||
std::vector<u8> disc_header(0x80);
|
||||
constexpr u32 WII_MAGIC = 0x5D1C9EA3;
|
||||
if (!m_volume.Read(0, disc_header.size(), disc_header.data(), partition))
|
||||
{
|
||||
invalid_header = true;
|
||||
}
|
||||
else if (Common::swap32(disc_header.data() + 0x18) != WII_MAGIC)
|
||||
else if (Common::swap32(disc_header.data() + 0x18) != WII_DISC_MAGIC)
|
||||
{
|
||||
for (size_t i = 0; i < disc_header.size(); i += 4)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue