internal NintendoOpticalDisc(AssetLoader loader)
: base(loader)
{
BinaryReader reader;
int magic = loader.Reader.ReadInt32();
loader.Reader.BaseStream.Seek(-4, SeekOrigin.Current);
if (magic == DolphinCompressedDisc.Magic) {
var disc = new DolphinCompressedDisc(loader.Reader);
var stream = new DolphinCompressedDiscStream(disc);
loader.Reader = new BigEndianBinaryReader(stream);
} else
loader.MakeBigEndian();
reader = Reader = loader.Reader;
DiscId = (NintendoOpticalDiscId)reader.ReadByte();
DiscGame = (NintendoOpticalDiscGame)reader.ReadInt16();
DiscRegion = (NintendoOpticalDiscRegion)reader.ReadByte();
DiscMaker = (NintendoOpticalDiscMaker)reader.ReadInt16();
DiscNumber = reader.ReadByte();
DiscVersion = reader.ReadByte();
DiscAudioStreaming = reader.ReadByte();
DiscStreamBufferSize = reader.ReadByte();
Unknowns.ReadBytes(reader, 14);
int wiiMagic = reader.ReadInt32();
int gameCubeMagic = reader.ReadInt32();
if (wiiMagic == (int)NintendoOpticalDiscSystem.Wii)
DiscSystem = NintendoOpticalDiscSystem.Wii;
else if (gameCubeMagic == (int)NintendoOpticalDiscSystem.GameCube)
DiscSystem = Wii.NintendoOpticalDiscSystem.GameCube;
else
throw new InvalidDataException();
DiscTitle = reader.ReadStringz(64, Encoding.ASCII);
if (DiscSystem == Wii.NintendoOpticalDiscSystem.GameCube) {
NintendoOpticalDiscPartition.LoadFileTable(this, reader, DiscSystem);
} else {
reader.BaseStream.Position = VolumeTableOffset;
for (int volumeIndex = 0; volumeIndex < 4; volumeIndex++) {
int partitionCount = reader.ReadInt32();
long partitionTableOffset = reader.ReadUInt32() * 4L;
if (partitionCount > 0)
new NintendoOpticalDiscVolume(this, volumeIndex, partitionCount, partitionTableOffset);
}
foreach (NintendoOpticalDiscVolume volume in Children)
volume.LoadPartitions(loader);
foreach (NintendoOpticalDiscVolume volume in Children)
foreach (NintendoOpticalDiscPartition partition in volume.Children)
partition.LoadHeaders(loader);
}
}