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:
JosJuice
2015-06-13 12:51:24 +02:00
parent 74d84c5af2
commit 19b8f1c10a
35 changed files with 622 additions and 639 deletions

View File

@ -50,10 +50,10 @@ static const DiscIO::IVolume* SetDisc(std::unique_ptr<DiscIO::IVolume> volume)
}
bool CBoot::DVDRead(const DiscIO::IVolume& volume, u64 dvd_offset, u32 output_address, u32 length,
bool decrypt)
const DiscIO::Partition& partition)
{
std::vector<u8> buffer(length);
if (!volume.Read(dvd_offset, length, buffer.data(), decrypt))
if (!volume.Read(dvd_offset, length, buffer.data(), partition))
return false;
Memory::CopyToEmu(output_address, buffer.data(), length);
return true;
@ -64,8 +64,10 @@ void CBoot::Load_FST(bool is_wii, const DiscIO::IVolume* volume)
if (!volume)
return;
const DiscIO::Partition partition = volume->GetGamePartition();
// copy first 32 bytes of disc to start of Mem 1
DVDRead(*volume, /*offset*/ 0, /*address*/ 0, /*length*/ 0x20, false);
DVDRead(*volume, /*offset*/ 0, /*address*/ 0, /*length*/ 0x20, DiscIO::PARTITION_NONE);
// copy of game id
Memory::Write_U32(Memory::Read_U32(0x0000), 0x3180);
@ -78,15 +80,15 @@ void CBoot::Load_FST(bool is_wii, const DiscIO::IVolume* volume)
u32 fst_size = 0;
u32 max_fst_size = 0;
volume->ReadSwapped(0x0424, &fst_offset, is_wii);
volume->ReadSwapped(0x0428, &fst_size, is_wii);
volume->ReadSwapped(0x042c, &max_fst_size, is_wii);
volume->ReadSwapped(0x0424, &fst_offset, partition);
volume->ReadSwapped(0x0428, &fst_size, partition);
volume->ReadSwapped(0x042c, &max_fst_size, partition);
u32 arena_high = Common::AlignDown(0x817FFFFF - (max_fst_size << shift), 0x20);
Memory::Write_U32(arena_high, 0x00000034);
// load FST
DVDRead(*volume, fst_offset << shift, arena_high, fst_size << shift, is_wii);
DVDRead(*volume, fst_offset << shift, arena_high, fst_size << shift, partition);
Memory::Write_U32(arena_high, 0x00000038);
Memory::Write_U32(max_fst_size << shift, 0x0000003c);