mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-22 05:40:01 -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:
@ -20,8 +20,8 @@
|
||||
|
||||
namespace DiscIO
|
||||
{
|
||||
CFileSystemGCWii::CFileSystemGCWii(const IVolume* _rVolume)
|
||||
: IFileSystem(_rVolume), m_Initialized(false), m_Valid(false), m_Wii(false)
|
||||
CFileSystemGCWii::CFileSystemGCWii(const IVolume* _rVolume, const Partition& partition)
|
||||
: IFileSystem(_rVolume, partition), m_Initialized(false), m_Valid(false), m_Wii(false)
|
||||
{
|
||||
m_Valid = DetectFileSystem();
|
||||
}
|
||||
@ -80,7 +80,7 @@ u64 CFileSystemGCWii::ReadFile(const std::string& _rFullPath, u8* _pBuffer, u64
|
||||
read_length, _OffsetInFile, _rFullPath.c_str(), pFileInfo->m_Offset,
|
||||
pFileInfo->m_FileSize);
|
||||
|
||||
m_rVolume->Read(pFileInfo->m_Offset + _OffsetInFile, read_length, _pBuffer, m_Wii);
|
||||
m_rVolume->Read(pFileInfo->m_Offset + _OffsetInFile, read_length, _pBuffer, m_partition);
|
||||
return read_length;
|
||||
}
|
||||
|
||||
@ -111,7 +111,7 @@ bool CFileSystemGCWii::ExportFile(const std::string& _rFullPath,
|
||||
|
||||
std::vector<u8> buffer(readSize);
|
||||
|
||||
result = m_rVolume->Read(fileOffset, readSize, &buffer[0], m_Wii);
|
||||
result = m_rVolume->Read(fileOffset, readSize, &buffer[0], m_partition);
|
||||
|
||||
if (!result)
|
||||
break;
|
||||
@ -130,14 +130,14 @@ bool CFileSystemGCWii::ExportApploader(const std::string& _rExportFolder) const
|
||||
u32 apploader_size;
|
||||
u32 trailer_size;
|
||||
const u32 header_size = 0x20;
|
||||
if (!m_rVolume->ReadSwapped(0x2440 + 0x14, &apploader_size, m_Wii) ||
|
||||
!m_rVolume->ReadSwapped(0x2440 + 0x18, &trailer_size, m_Wii))
|
||||
if (!m_rVolume->ReadSwapped(0x2440 + 0x14, &apploader_size, m_partition) ||
|
||||
!m_rVolume->ReadSwapped(0x2440 + 0x18, &trailer_size, m_partition))
|
||||
return false;
|
||||
apploader_size += trailer_size + header_size;
|
||||
DEBUG_LOG(DISCIO, "Apploader size -> %x", apploader_size);
|
||||
|
||||
std::vector<u8> buffer(apploader_size);
|
||||
if (m_rVolume->Read(0x2440, apploader_size, buffer.data(), m_Wii))
|
||||
if (m_rVolume->Read(0x2440, apploader_size, buffer.data(), m_partition))
|
||||
{
|
||||
std::string exportName(_rExportFolder + "/apploader.img");
|
||||
|
||||
@ -155,7 +155,7 @@ bool CFileSystemGCWii::ExportApploader(const std::string& _rExportFolder) const
|
||||
u64 CFileSystemGCWii::GetBootDOLOffset() const
|
||||
{
|
||||
u32 offset = 0;
|
||||
m_rVolume->ReadSwapped(0x420, &offset, m_Wii);
|
||||
m_rVolume->ReadSwapped(0x420, &offset, m_partition);
|
||||
return static_cast<u64>(offset) << GetOffsetShift();
|
||||
}
|
||||
|
||||
@ -173,8 +173,8 @@ u32 CFileSystemGCWii::GetBootDOLSize(u64 dol_offset) const
|
||||
// Iterate through the 7 code segments
|
||||
for (u8 i = 0; i < 7; i++)
|
||||
{
|
||||
if (!m_rVolume->ReadSwapped(dol_offset + 0x00 + i * 4, &offset, m_Wii) ||
|
||||
!m_rVolume->ReadSwapped(dol_offset + 0x90 + i * 4, &size, m_Wii))
|
||||
if (!m_rVolume->ReadSwapped(dol_offset + 0x00 + i * 4, &offset, m_partition) ||
|
||||
!m_rVolume->ReadSwapped(dol_offset + 0x90 + i * 4, &size, m_partition))
|
||||
return 0;
|
||||
dol_size = std::max(offset + size, dol_size);
|
||||
}
|
||||
@ -182,8 +182,8 @@ u32 CFileSystemGCWii::GetBootDOLSize(u64 dol_offset) const
|
||||
// Iterate through the 11 data segments
|
||||
for (u8 i = 0; i < 11; i++)
|
||||
{
|
||||
if (!m_rVolume->ReadSwapped(dol_offset + 0x1c + i * 4, &offset, m_Wii) ||
|
||||
!m_rVolume->ReadSwapped(dol_offset + 0xac + i * 4, &size, m_Wii))
|
||||
if (!m_rVolume->ReadSwapped(dol_offset + 0x1c + i * 4, &offset, m_partition) ||
|
||||
!m_rVolume->ReadSwapped(dol_offset + 0xac + i * 4, &size, m_partition))
|
||||
return 0;
|
||||
dol_size = std::max(offset + size, dol_size);
|
||||
}
|
||||
@ -200,7 +200,7 @@ bool CFileSystemGCWii::ExportDOL(const std::string& _rExportFolder) const
|
||||
return false;
|
||||
|
||||
std::vector<u8> buffer(DolSize);
|
||||
if (m_rVolume->Read(DolOffset, DolSize, &buffer[0], m_Wii))
|
||||
if (m_rVolume->Read(DolOffset, DolSize, &buffer[0], m_partition))
|
||||
{
|
||||
std::string exportName(_rExportFolder + "/boot.dol");
|
||||
|
||||
@ -218,7 +218,7 @@ bool CFileSystemGCWii::ExportDOL(const std::string& _rExportFolder) const
|
||||
std::string CFileSystemGCWii::GetStringFromOffset(u64 _Offset) const
|
||||
{
|
||||
std::string data(255, 0x00);
|
||||
m_rVolume->Read(_Offset, data.size(), (u8*)&data[0], m_Wii);
|
||||
m_rVolume->Read(_Offset, data.size(), (u8*)&data[0], m_partition);
|
||||
data.erase(std::find(data.begin(), data.end(), 0x00), data.end());
|
||||
|
||||
// TODO: Should we really always use SHIFT-JIS?
|
||||
@ -251,12 +251,12 @@ const SFileInfo* CFileSystemGCWii::FindFileInfo(const std::string& _rFullPath)
|
||||
bool CFileSystemGCWii::DetectFileSystem()
|
||||
{
|
||||
u32 magic_bytes;
|
||||
if (m_rVolume->ReadSwapped(0x18, &magic_bytes, false) && magic_bytes == 0x5D1C9EA3)
|
||||
if (m_rVolume->ReadSwapped(0x18, &magic_bytes, m_partition) && magic_bytes == 0x5D1C9EA3)
|
||||
{
|
||||
m_Wii = true;
|
||||
return true;
|
||||
}
|
||||
else if (m_rVolume->ReadSwapped(0x1c, &magic_bytes, false) && magic_bytes == 0xC2339F3D)
|
||||
else if (m_rVolume->ReadSwapped(0x1c, &magic_bytes, m_partition) && magic_bytes == 0xC2339F3D)
|
||||
{
|
||||
m_Wii = false;
|
||||
return true;
|
||||
@ -272,15 +272,15 @@ void CFileSystemGCWii::InitFileSystem()
|
||||
|
||||
// read the whole FST
|
||||
u32 fst_offset_unshifted;
|
||||
if (!m_rVolume->ReadSwapped(0x424, &fst_offset_unshifted, m_Wii))
|
||||
if (!m_rVolume->ReadSwapped(0x424, &fst_offset_unshifted, m_partition))
|
||||
return;
|
||||
u64 FSTOffset = static_cast<u64>(fst_offset_unshifted) << shift;
|
||||
|
||||
// read all fileinfos
|
||||
u32 name_offset, offset, size;
|
||||
if (!m_rVolume->ReadSwapped(FSTOffset + 0x0, &name_offset, m_Wii) ||
|
||||
!m_rVolume->ReadSwapped(FSTOffset + 0x4, &offset, m_Wii) ||
|
||||
!m_rVolume->ReadSwapped(FSTOffset + 0x8, &size, m_Wii))
|
||||
if (!m_rVolume->ReadSwapped(FSTOffset + 0x0, &name_offset, m_partition) ||
|
||||
!m_rVolume->ReadSwapped(FSTOffset + 0x4, &offset, m_partition) ||
|
||||
!m_rVolume->ReadSwapped(FSTOffset + 0x8, &size, m_partition))
|
||||
return;
|
||||
SFileInfo root = {name_offset, static_cast<u64>(offset) << shift, size};
|
||||
|
||||
@ -308,11 +308,11 @@ void CFileSystemGCWii::InitFileSystem()
|
||||
{
|
||||
const u64 read_offset = FSTOffset + (i * 0xC);
|
||||
name_offset = 0;
|
||||
m_rVolume->ReadSwapped(read_offset + 0x0, &name_offset, m_Wii);
|
||||
m_rVolume->ReadSwapped(read_offset + 0x0, &name_offset, m_partition);
|
||||
offset = 0;
|
||||
m_rVolume->ReadSwapped(read_offset + 0x4, &offset, m_Wii);
|
||||
m_rVolume->ReadSwapped(read_offset + 0x4, &offset, m_partition);
|
||||
size = 0;
|
||||
m_rVolume->ReadSwapped(read_offset + 0x8, &size, m_Wii);
|
||||
m_rVolume->ReadSwapped(read_offset + 0x8, &size, m_partition);
|
||||
m_FileInfoVector.emplace_back(name_offset, static_cast<u64>(offset) << shift, size);
|
||||
NameTableOffset += 0xC;
|
||||
}
|
||||
|
Reference in New Issue
Block a user