mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
VolumeWiiCrypted: Replace ChangePartition with a partition parameter
By removing mutable state in VolumeWiiCrypted, this change makes partition-related code simpler. It also gets rid of other ugly things, like ISOProperties's "over 9000" loop that creates a list of partitions by trying possible combinations, and DiscScrubber's volume swapping that recreates the entire volume when it needs to change partition.
This commit is contained in:
@ -32,21 +32,21 @@ CVolumeGC::~CVolumeGC()
|
||||
{
|
||||
}
|
||||
|
||||
bool CVolumeGC::Read(u64 _Offset, u64 _Length, u8* _pBuffer, bool decrypt) const
|
||||
bool CVolumeGC::Read(u64 _Offset, u64 _Length, u8* _pBuffer, const Partition& partition) const
|
||||
{
|
||||
if (decrypt)
|
||||
PanicAlertT("Tried to decrypt data from a non-Wii volume");
|
||||
if (partition != PARTITION_NONE)
|
||||
return false;
|
||||
|
||||
return m_pReader->Read(_Offset, _Length, _pBuffer);
|
||||
}
|
||||
|
||||
std::string CVolumeGC::GetGameID() const
|
||||
std::string CVolumeGC::GetGameID(const Partition& partition) const
|
||||
{
|
||||
static const std::string NO_UID("NO_UID");
|
||||
|
||||
char ID[6];
|
||||
|
||||
if (!Read(0, sizeof(ID), reinterpret_cast<u8*>(ID)))
|
||||
if (!Read(0, sizeof(ID), reinterpret_cast<u8*>(ID), partition))
|
||||
{
|
||||
PanicAlertT("Failed to read unique ID from disc image");
|
||||
return NO_UID;
|
||||
@ -58,43 +58,43 @@ std::string CVolumeGC::GetGameID() const
|
||||
Region CVolumeGC::GetRegion() const
|
||||
{
|
||||
u8 country_code;
|
||||
if (!ReadSwapped(3, &country_code, false))
|
||||
if (!ReadSwapped(3, &country_code, PARTITION_NONE))
|
||||
return Region::UNKNOWN_REGION;
|
||||
|
||||
return RegionSwitchGC(country_code);
|
||||
}
|
||||
|
||||
Country CVolumeGC::GetCountry() const
|
||||
Country CVolumeGC::GetCountry(const Partition& partition) const
|
||||
{
|
||||
u8 country_code;
|
||||
if (!ReadSwapped(3, &country_code, false))
|
||||
if (!ReadSwapped(3, &country_code, partition))
|
||||
return Country::COUNTRY_UNKNOWN;
|
||||
|
||||
return CountrySwitch(country_code);
|
||||
}
|
||||
|
||||
std::string CVolumeGC::GetMakerID() const
|
||||
std::string CVolumeGC::GetMakerID(const Partition& partition) const
|
||||
{
|
||||
char makerID[2];
|
||||
if (!Read(0x4, 0x2, (u8*)&makerID))
|
||||
if (!Read(0x4, 0x2, (u8*)&makerID, partition))
|
||||
return std::string();
|
||||
|
||||
return DecodeString(makerID);
|
||||
}
|
||||
|
||||
u16 CVolumeGC::GetRevision() const
|
||||
u16 CVolumeGC::GetRevision(const Partition& partition) const
|
||||
{
|
||||
u8 revision;
|
||||
if (!ReadSwapped(7, &revision, false))
|
||||
if (!ReadSwapped(7, &revision, partition))
|
||||
return 0;
|
||||
|
||||
return revision;
|
||||
}
|
||||
|
||||
std::string CVolumeGC::GetInternalName() const
|
||||
std::string CVolumeGC::GetInternalName(const Partition& partition) const
|
||||
{
|
||||
char name[0x60];
|
||||
if (Read(0x20, 0x60, (u8*)name))
|
||||
if (Read(0x20, 0x60, (u8*)name, partition))
|
||||
return DecodeString(name);
|
||||
|
||||
return "";
|
||||
@ -138,19 +138,19 @@ std::vector<u32> CVolumeGC::GetBanner(int* width, int* height) const
|
||||
return m_image_buffer;
|
||||
}
|
||||
|
||||
u64 CVolumeGC::GetFSTSize() const
|
||||
u64 CVolumeGC::GetFSTSize(const Partition& partition) const
|
||||
{
|
||||
u32 size;
|
||||
if (!Read(0x428, 0x4, (u8*)&size))
|
||||
if (!Read(0x428, 0x4, (u8*)&size, partition))
|
||||
return 0;
|
||||
|
||||
return Common::swap32(size);
|
||||
}
|
||||
|
||||
std::string CVolumeGC::GetApploaderDate() const
|
||||
std::string CVolumeGC::GetApploaderDate(const Partition& partition) const
|
||||
{
|
||||
char date[16];
|
||||
if (!Read(0x2440, 0x10, (u8*)&date))
|
||||
if (!Read(0x2440, 0x10, (u8*)&date, partition))
|
||||
return std::string();
|
||||
|
||||
return DecodeString(date);
|
||||
@ -171,10 +171,10 @@ u64 CVolumeGC::GetRawSize() const
|
||||
return m_pReader->GetRawSize();
|
||||
}
|
||||
|
||||
u8 CVolumeGC::GetDiscNumber() const
|
||||
u8 CVolumeGC::GetDiscNumber(const Partition& partition) const
|
||||
{
|
||||
u8 disc_number = 0;
|
||||
ReadSwapped(6, &disc_number, false);
|
||||
ReadSwapped(6, &disc_number, partition);
|
||||
return disc_number;
|
||||
}
|
||||
|
||||
@ -192,8 +192,8 @@ void CVolumeGC::LoadBannerFile() const
|
||||
m_banner_loaded = true;
|
||||
|
||||
GCBanner banner_file;
|
||||
std::unique_ptr<IFileSystem> file_system(CreateFileSystem(this));
|
||||
size_t file_size = (size_t)file_system->GetFileSize("opening.bnr");
|
||||
std::unique_ptr<IFileSystem> file_system(CreateFileSystem(this, PARTITION_NONE));
|
||||
size_t file_size = static_cast<size_t>(file_system->GetFileSize("opening.bnr"));
|
||||
|
||||
constexpr int BNR1_MAGIC = 0x31524e42;
|
||||
constexpr int BNR2_MAGIC = 0x32524e42;
|
||||
|
Reference in New Issue
Block a user