2017-07-19 16:31:08 +01:00
|
|
|
|
// /***************************************************************************
|
2016-04-19 01:17:14 +01:00
|
|
|
|
// The Disc Image Chef
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Filename : Nintendo.cs
|
2016-07-28 18:13:49 +01:00
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
2016-04-19 01:17:14 +01:00
|
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
|
// Component : Nintendo optical filesystems plugin.
|
2016-04-19 01:17:14 +01:00
|
|
|
|
//
|
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
|
// Identifies the Nintendo optical filesystems and shows information.
|
2016-04-19 01:17:14 +01:00
|
|
|
|
//
|
|
|
|
|
|
// --[ License ] --------------------------------------------------------------
|
|
|
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
|
// This library is free software; you can redistribute it and/or modify
|
|
|
|
|
|
// it under the terms of the GNU Lesser General Public License as
|
|
|
|
|
|
// published by the Free Software Foundation; either version 2.1 of the
|
2016-04-19 01:17:14 +01:00
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
|
// This library is distributed in the hope that it will be useful, but
|
|
|
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
|
// Lesser General Public License for more details.
|
2016-04-19 01:17:14 +01:00
|
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
|
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
2016-04-19 01:17:14 +01:00
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2018-12-29 17:34:38 +00:00
|
|
|
|
// Copyright © 2011-2019 Natalia Portillo
|
2016-04-19 01:17:14 +01:00
|
|
|
|
// ****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
2017-07-19 16:31:08 +01:00
|
|
|
|
using System.Text;
|
|
|
|
|
|
using DiscImageChef.CommonTypes;
|
2018-06-25 19:08:16 +01:00
|
|
|
|
using DiscImageChef.CommonTypes.Interfaces;
|
2016-04-19 01:17:14 +01:00
|
|
|
|
using DiscImageChef.Console;
|
2017-12-21 14:30:38 +00:00
|
|
|
|
using Schemas;
|
2016-04-19 01:17:14 +01:00
|
|
|
|
|
2016-07-21 16:15:39 +01:00
|
|
|
|
namespace DiscImageChef.Filesystems
|
2016-04-19 01:17:14 +01:00
|
|
|
|
{
|
2017-12-26 06:05:12 +00:00
|
|
|
|
public class NintendoPlugin : IFilesystem
|
2016-04-19 01:17:14 +01:00
|
|
|
|
{
|
2017-12-26 08:01:40 +00:00
|
|
|
|
public FileSystemType XmlFsType { get; private set; }
|
2018-06-22 08:08:38 +01:00
|
|
|
|
public Encoding Encoding { get; private set; }
|
|
|
|
|
|
public string Name => "Nintendo optical filesystems";
|
|
|
|
|
|
public Guid Id => new Guid("4675fcb4-4418-4288-9e4a-33d6a4ac1126");
|
2018-08-29 22:15:43 +01:00
|
|
|
|
public string Author => "Natalia Portillo";
|
2017-10-12 23:54:02 +01:00
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public bool Identify(IMediaImage imagePlugin, Partition partition)
|
2016-04-19 01:17:14 +01:00
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
|
if(partition.Start != 0) return false;
|
2016-04-19 01:17:14 +01:00
|
|
|
|
|
2017-12-26 06:05:12 +00:00
|
|
|
|
if(imagePlugin.Info.Sectors * imagePlugin.Info.SectorSize < 0x50000) return false;
|
2016-04-19 01:17:14 +01:00
|
|
|
|
|
2017-12-26 06:05:12 +00:00
|
|
|
|
byte[] header = imagePlugin.ReadSectors(0, 0x50000 / imagePlugin.Info.SectorSize);
|
2016-04-19 01:17:14 +01:00
|
|
|
|
|
2018-06-22 08:08:38 +01:00
|
|
|
|
uint magicGc = BigEndianBitConverter.ToUInt32(header, 0x1C);
|
2016-07-28 22:25:26 +01:00
|
|
|
|
uint magicWii = BigEndianBitConverter.ToUInt32(header, 0x18);
|
2016-04-19 01:17:14 +01:00
|
|
|
|
|
2017-12-22 08:43:22 +00:00
|
|
|
|
return magicGc == 0xC2339F3D || magicWii == 0x5D1C9EA3;
|
2016-04-19 01:17:14 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-26 08:01:40 +00:00
|
|
|
|
public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
|
2018-06-22 08:08:38 +01:00
|
|
|
|
Encoding encoding)
|
2016-04-19 01:17:14 +01:00
|
|
|
|
{
|
2017-12-26 08:01:40 +00:00
|
|
|
|
Encoding = encoding ?? Encoding.GetEncoding("shift_jis");
|
2016-04-19 01:17:14 +01:00
|
|
|
|
StringBuilder sbInformation = new StringBuilder();
|
|
|
|
|
|
information = "";
|
2018-06-22 08:08:38 +01:00
|
|
|
|
XmlFsType = new FileSystemType();
|
2016-04-19 01:17:14 +01:00
|
|
|
|
|
|
|
|
|
|
NintendoFields fields = new NintendoFields();
|
|
|
|
|
|
|
2017-12-26 06:05:12 +00:00
|
|
|
|
byte[] header = imagePlugin.ReadSectors(0, 0x50000 / imagePlugin.Info.SectorSize);
|
2016-04-19 01:17:14 +01:00
|
|
|
|
|
|
|
|
|
|
bool wii = false;
|
|
|
|
|
|
|
2018-06-22 08:08:38 +01:00
|
|
|
|
uint magicGc = BigEndianBitConverter.ToUInt32(header, 0x1C);
|
2016-07-28 22:25:26 +01:00
|
|
|
|
uint magicWii = BigEndianBitConverter.ToUInt32(header, 0x18);
|
2016-04-19 01:17:14 +01:00
|
|
|
|
|
2018-06-22 08:08:38 +01:00
|
|
|
|
if(magicWii == 0x5D1C9EA3) wii = true;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
else if(magicGc != 0xC2339F3D) return;
|
2016-04-19 01:17:14 +01:00
|
|
|
|
|
2018-06-22 08:08:38 +01:00
|
|
|
|
fields.DiscType = Encoding.ASCII.GetString(header, 0, 1);
|
|
|
|
|
|
fields.GameCode = Encoding.ASCII.GetString(header, 1, 2);
|
|
|
|
|
|
fields.RegionCode = Encoding.ASCII.GetString(header, 3, 1);
|
|
|
|
|
|
fields.PublisherCode = Encoding.ASCII.GetString(header, 4, 2);
|
|
|
|
|
|
fields.DiscId = Encoding.ASCII.GetString(header, 0, 6);
|
|
|
|
|
|
fields.DiscNumber = header[6];
|
|
|
|
|
|
fields.DiscVersion = header[7];
|
|
|
|
|
|
fields.Streaming |= header[8] > 0;
|
|
|
|
|
|
fields.StreamBufferSize = header[9];
|
2016-04-19 01:17:14 +01:00
|
|
|
|
byte[] temp = new byte[64];
|
|
|
|
|
|
Array.Copy(header, 0x20, temp, 0, 64);
|
2017-12-26 08:01:40 +00:00
|
|
|
|
fields.Title = StringHandlers.CToString(temp, Encoding);
|
2016-04-19 01:17:14 +01:00
|
|
|
|
|
|
|
|
|
|
if(!wii)
|
|
|
|
|
|
{
|
2018-06-22 08:08:38 +01:00
|
|
|
|
fields.DebugOff = BigEndianBitConverter.ToUInt32(header, 0x0400);
|
2017-12-22 08:43:22 +00:00
|
|
|
|
fields.DebugAddr = BigEndianBitConverter.ToUInt32(header, 0x0404);
|
2018-06-22 08:08:38 +01:00
|
|
|
|
fields.DolOff = BigEndianBitConverter.ToUInt32(header, 0x0420);
|
|
|
|
|
|
fields.FstOff = BigEndianBitConverter.ToUInt32(header, 0x0424);
|
|
|
|
|
|
fields.FstSize = BigEndianBitConverter.ToUInt32(header, 0x0428);
|
|
|
|
|
|
fields.FstMax = BigEndianBitConverter.ToUInt32(header, 0x042C);
|
2016-04-19 01:17:14 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(wii)
|
|
|
|
|
|
{
|
2018-06-20 22:22:21 +01:00
|
|
|
|
uint offset1 = BigEndianBitConverter.ToUInt32(header, 0x40004) << 2;
|
|
|
|
|
|
uint offset2 = BigEndianBitConverter.ToUInt32(header, 0x4000C) << 2;
|
|
|
|
|
|
uint offset3 = BigEndianBitConverter.ToUInt32(header, 0x40014) << 2;
|
|
|
|
|
|
uint offset4 = BigEndianBitConverter.ToUInt32(header, 0x4001C) << 2;
|
2016-04-19 01:17:14 +01:00
|
|
|
|
|
2018-06-22 08:08:38 +01:00
|
|
|
|
fields.FirstPartitions = new NintendoPartition[BigEndianBitConverter.ToUInt32(header, 0x40000)];
|
2017-12-22 08:43:22 +00:00
|
|
|
|
fields.SecondPartitions = new NintendoPartition[BigEndianBitConverter.ToUInt32(header, 0x40008)];
|
2018-06-22 08:08:38 +01:00
|
|
|
|
fields.ThirdPartitions = new NintendoPartition[BigEndianBitConverter.ToUInt32(header, 0x40010)];
|
2017-12-22 08:43:22 +00:00
|
|
|
|
fields.FourthPartitions = new NintendoPartition[BigEndianBitConverter.ToUInt32(header, 0x40018)];
|
2016-04-19 01:17:14 +01:00
|
|
|
|
|
2017-12-22 08:43:22 +00:00
|
|
|
|
for(int i = 0; i < fields.FirstPartitions.Length; i++)
|
2017-12-20 17:26:28 +00:00
|
|
|
|
if(offset1 + i * 8 + 8 < 0x50000)
|
2016-04-19 01:17:14 +01:00
|
|
|
|
{
|
2017-12-22 08:43:22 +00:00
|
|
|
|
fields.FirstPartitions[i].Offset =
|
2017-12-19 20:33:03 +00:00
|
|
|
|
BigEndianBitConverter.ToUInt32(header, (int)(offset1 + i * 8 + 0)) << 2;
|
2017-12-22 08:43:22 +00:00
|
|
|
|
fields.FirstPartitions[i].Type =
|
2017-12-19 20:33:03 +00:00
|
|
|
|
BigEndianBitConverter.ToUInt32(header, (int)(offset1 + i * 8 + 4));
|
2016-04-19 01:17:14 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-22 08:43:22 +00:00
|
|
|
|
for(int i = 0; i < fields.SecondPartitions.Length; i++)
|
2017-12-20 17:26:28 +00:00
|
|
|
|
if(offset1 + i * 8 + 8 < 0x50000)
|
2016-04-19 01:17:14 +01:00
|
|
|
|
{
|
2017-12-22 08:43:22 +00:00
|
|
|
|
fields.FirstPartitions[i].Offset =
|
2017-12-19 20:33:03 +00:00
|
|
|
|
BigEndianBitConverter.ToUInt32(header, (int)(offset2 + i * 8 + 0)) << 2;
|
2017-12-22 08:43:22 +00:00
|
|
|
|
fields.FirstPartitions[i].Type =
|
2017-12-19 20:33:03 +00:00
|
|
|
|
BigEndianBitConverter.ToUInt32(header, (int)(offset2 + i * 8 + 4));
|
2016-04-19 01:17:14 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-22 08:43:22 +00:00
|
|
|
|
for(int i = 0; i < fields.ThirdPartitions.Length; i++)
|
2017-12-20 17:26:28 +00:00
|
|
|
|
if(offset1 + i * 8 + 8 < 0x50000)
|
2016-04-19 01:17:14 +01:00
|
|
|
|
{
|
2017-12-22 08:43:22 +00:00
|
|
|
|
fields.FirstPartitions[i].Offset =
|
2017-12-19 20:33:03 +00:00
|
|
|
|
BigEndianBitConverter.ToUInt32(header, (int)(offset3 + i * 8 + 0)) << 2;
|
2017-12-22 08:43:22 +00:00
|
|
|
|
fields.FirstPartitions[i].Type =
|
2017-12-19 20:33:03 +00:00
|
|
|
|
BigEndianBitConverter.ToUInt32(header, (int)(offset3 + i * 8 + 4));
|
2016-04-19 01:17:14 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-22 08:43:22 +00:00
|
|
|
|
for(int i = 0; i < fields.FourthPartitions.Length; i++)
|
2017-12-20 17:26:28 +00:00
|
|
|
|
if(offset1 + i * 8 + 8 < 0x50000)
|
2016-04-19 01:17:14 +01:00
|
|
|
|
{
|
2017-12-22 08:43:22 +00:00
|
|
|
|
fields.FirstPartitions[i].Offset =
|
2017-12-19 20:33:03 +00:00
|
|
|
|
BigEndianBitConverter.ToUInt32(header, (int)(offset4 + i * 8 + 0)) << 2;
|
2017-12-22 08:43:22 +00:00
|
|
|
|
fields.FirstPartitions[i].Type =
|
2017-12-19 20:33:03 +00:00
|
|
|
|
BigEndianBitConverter.ToUInt32(header, (int)(offset4 + i * 8 + 4));
|
2016-04-19 01:17:14 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-06-22 08:08:38 +01:00
|
|
|
|
fields.Region = header[0x4E000];
|
|
|
|
|
|
fields.JapanAge = header[0x4E010];
|
|
|
|
|
|
fields.UsaAge = header[0x4E011];
|
|
|
|
|
|
fields.GermanAge = header[0x4E013];
|
|
|
|
|
|
fields.PegiAge = header[0x4E014];
|
|
|
|
|
|
fields.FinlandAge = header[0x4E015];
|
|
|
|
|
|
fields.PortugalAge = header[0x4E016];
|
|
|
|
|
|
fields.UkAge = header[0x4E017];
|
2017-12-22 08:43:22 +00:00
|
|
|
|
fields.AustraliaAge = header[0x4E018];
|
2018-06-22 08:08:38 +01:00
|
|
|
|
fields.KoreaAge = header[0x4E019];
|
2016-04-19 01:17:14 +01:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2018-06-22 08:08:38 +01:00
|
|
|
|
fields.FirstPartitions = new NintendoPartition[0];
|
2017-12-22 08:43:22 +00:00
|
|
|
|
fields.SecondPartitions = new NintendoPartition[0];
|
2018-06-22 08:08:38 +01:00
|
|
|
|
fields.ThirdPartitions = new NintendoPartition[0];
|
2017-12-22 08:43:22 +00:00
|
|
|
|
fields.FourthPartitions = new NintendoPartition[0];
|
2016-04-19 01:17:14 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-06-22 08:08:38 +01:00
|
|
|
|
DicConsole.DebugWriteLine("Nintendo plugin", "discType = {0}", fields.DiscType);
|
|
|
|
|
|
DicConsole.DebugWriteLine("Nintendo plugin", "gameCode = {0}", fields.GameCode);
|
|
|
|
|
|
DicConsole.DebugWriteLine("Nintendo plugin", "regionCode = {0}", fields.RegionCode);
|
|
|
|
|
|
DicConsole.DebugWriteLine("Nintendo plugin", "publisherCode = {0}", fields.PublisherCode);
|
|
|
|
|
|
DicConsole.DebugWriteLine("Nintendo plugin", "discID = {0}", fields.DiscId);
|
|
|
|
|
|
DicConsole.DebugWriteLine("Nintendo plugin", "discNumber = {0}", fields.DiscNumber);
|
|
|
|
|
|
DicConsole.DebugWriteLine("Nintendo plugin", "discVersion = {0}", fields.DiscVersion);
|
|
|
|
|
|
DicConsole.DebugWriteLine("Nintendo plugin", "streaming = {0}", fields.Streaming);
|
2017-12-22 08:43:22 +00:00
|
|
|
|
DicConsole.DebugWriteLine("Nintendo plugin", "streamBufferSize = {0}", fields.StreamBufferSize);
|
2018-06-22 08:08:38 +01:00
|
|
|
|
DicConsole.DebugWriteLine("Nintendo plugin", "title = \"{0}\"", fields.Title);
|
|
|
|
|
|
DicConsole.DebugWriteLine("Nintendo plugin", "debugOff = 0x{0:X8}", fields.DebugOff);
|
|
|
|
|
|
DicConsole.DebugWriteLine("Nintendo plugin", "debugAddr = 0x{0:X8}", fields.DebugAddr);
|
|
|
|
|
|
DicConsole.DebugWriteLine("Nintendo plugin", "dolOff = 0x{0:X8}", fields.DolOff);
|
|
|
|
|
|
DicConsole.DebugWriteLine("Nintendo plugin", "fstOff = 0x{0:X8}", fields.FstOff);
|
|
|
|
|
|
DicConsole.DebugWriteLine("Nintendo plugin", "fstSize = {0}", fields.FstSize);
|
|
|
|
|
|
DicConsole.DebugWriteLine("Nintendo plugin", "fstMax = {0}", fields.FstMax);
|
2017-12-22 08:43:22 +00:00
|
|
|
|
for(int i = 0; i < fields.FirstPartitions.Length; i++)
|
2016-04-19 01:17:14 +01:00
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
|
DicConsole.DebugWriteLine("Nintendo plugin", "firstPartitions[{1}].offset = {0}",
|
2017-12-22 08:43:22 +00:00
|
|
|
|
fields.FirstPartitions[i].Offset, i);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
DicConsole.DebugWriteLine("Nintendo plugin", "firstPartitions[{1}].type = {0}",
|
2017-12-22 08:43:22 +00:00
|
|
|
|
fields.FirstPartitions[i].Type, i);
|
2016-04-19 01:17:14 +01:00
|
|
|
|
}
|
2018-06-22 08:08:38 +01:00
|
|
|
|
|
2017-12-22 08:43:22 +00:00
|
|
|
|
for(int i = 0; i < fields.SecondPartitions.Length; i++)
|
2016-04-19 01:17:14 +01:00
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
|
DicConsole.DebugWriteLine("Nintendo plugin", "secondPartitions[{1}].offset = {0}",
|
2017-12-22 08:43:22 +00:00
|
|
|
|
fields.SecondPartitions[i].Offset, i);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
DicConsole.DebugWriteLine("Nintendo plugin", "secondPartitions[{1}].type = {0}",
|
2017-12-22 08:43:22 +00:00
|
|
|
|
fields.SecondPartitions[i].Type, i);
|
2016-04-19 01:17:14 +01:00
|
|
|
|
}
|
2018-06-22 08:08:38 +01:00
|
|
|
|
|
2017-12-22 08:43:22 +00:00
|
|
|
|
for(int i = 0; i < fields.ThirdPartitions.Length; i++)
|
2016-04-19 01:17:14 +01:00
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
|
DicConsole.DebugWriteLine("Nintendo plugin", "thirdPartitions[{1}].offset = {0}",
|
2017-12-22 08:43:22 +00:00
|
|
|
|
fields.ThirdPartitions[i].Offset, i);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
DicConsole.DebugWriteLine("Nintendo plugin", "thirdPartitions[{1}].type = {0}",
|
2017-12-22 08:43:22 +00:00
|
|
|
|
fields.ThirdPartitions[i].Type, i);
|
2016-04-19 01:17:14 +01:00
|
|
|
|
}
|
2018-06-22 08:08:38 +01:00
|
|
|
|
|
2017-12-22 08:43:22 +00:00
|
|
|
|
for(int i = 0; i < fields.FourthPartitions.Length; i++)
|
2016-04-19 01:17:14 +01:00
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
|
DicConsole.DebugWriteLine("Nintendo plugin", "fourthPartitions[{1}].offset = {0}",
|
2017-12-22 08:43:22 +00:00
|
|
|
|
fields.FourthPartitions[i].Offset, i);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
DicConsole.DebugWriteLine("Nintendo plugin", "fourthPartitions[{1}].type = {0}",
|
2017-12-22 08:43:22 +00:00
|
|
|
|
fields.FourthPartitions[i].Type, i);
|
2016-04-19 01:17:14 +01:00
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2018-06-22 08:08:38 +01:00
|
|
|
|
DicConsole.DebugWriteLine("Nintendo plugin", "region = {0}", fields.Region);
|
|
|
|
|
|
DicConsole.DebugWriteLine("Nintendo plugin", "japanAge = {0}", fields.JapanAge);
|
|
|
|
|
|
DicConsole.DebugWriteLine("Nintendo plugin", "usaAge = {0}", fields.UsaAge);
|
|
|
|
|
|
DicConsole.DebugWriteLine("Nintendo plugin", "germanAge = {0}", fields.GermanAge);
|
|
|
|
|
|
DicConsole.DebugWriteLine("Nintendo plugin", "pegiAge = {0}", fields.PegiAge);
|
|
|
|
|
|
DicConsole.DebugWriteLine("Nintendo plugin", "finlandAge = {0}", fields.FinlandAge);
|
|
|
|
|
|
DicConsole.DebugWriteLine("Nintendo plugin", "portugalAge = {0}", fields.PortugalAge);
|
|
|
|
|
|
DicConsole.DebugWriteLine("Nintendo plugin", "ukAge = {0}", fields.UkAge);
|
2017-12-22 08:43:22 +00:00
|
|
|
|
DicConsole.DebugWriteLine("Nintendo plugin", "australiaAge = {0}", fields.AustraliaAge);
|
2018-06-22 08:08:38 +01:00
|
|
|
|
DicConsole.DebugWriteLine("Nintendo plugin", "koreaAge = {0}", fields.KoreaAge);
|
2016-04-19 01:17:14 +01:00
|
|
|
|
|
|
|
|
|
|
sbInformation.AppendLine("Nintendo optical filesystem");
|
2017-12-22 08:43:22 +00:00
|
|
|
|
sbInformation.AppendLine(wii ? "Nintendo Wii Optical Disc" : "Nintendo GameCube Optical Disc");
|
|
|
|
|
|
sbInformation.AppendFormat("Disc ID is {0}", fields.DiscId).AppendLine();
|
|
|
|
|
|
sbInformation.AppendFormat("Disc is a {0} disc", DiscTypeToString(fields.DiscType)).AppendLine();
|
|
|
|
|
|
sbInformation.AppendFormat("Disc region is {0}", RegionCodeToString(fields.RegionCode)).AppendLine();
|
|
|
|
|
|
sbInformation.AppendFormat("Published by {0}", PublisherCodeToString(fields.PublisherCode)).AppendLine();
|
|
|
|
|
|
if(fields.DiscNumber > 0)
|
|
|
|
|
|
sbInformation.AppendFormat("Disc number {0} of a multi-disc set", fields.DiscNumber + 1).AppendLine();
|
|
|
|
|
|
if(fields.Streaming) sbInformation.AppendLine("Disc is prepared for audio streaming");
|
|
|
|
|
|
if(fields.StreamBufferSize > 0)
|
|
|
|
|
|
sbInformation.AppendFormat("Audio streaming buffer size is {0} bytes", fields.StreamBufferSize)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
.AppendLine();
|
2017-12-22 08:43:22 +00:00
|
|
|
|
sbInformation.AppendFormat("Title: {0}", fields.Title).AppendLine();
|
2016-04-19 01:17:14 +01:00
|
|
|
|
|
|
|
|
|
|
if(wii)
|
|
|
|
|
|
{
|
2017-12-22 08:43:22 +00:00
|
|
|
|
for(int i = 0; i < fields.FirstPartitions.Length; i++)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
sbInformation.AppendFormat("First {0} partition starts at sector {1}",
|
2017-12-22 08:43:22 +00:00
|
|
|
|
PartitionTypeToString(fields.FirstPartitions[i].Type),
|
|
|
|
|
|
fields.FirstPartitions[i].Offset / 2048).AppendLine();
|
|
|
|
|
|
for(int i = 0; i < fields.SecondPartitions.Length; i++)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
sbInformation.AppendFormat("Second {0} partition starts at sector {1}",
|
2017-12-22 08:43:22 +00:00
|
|
|
|
PartitionTypeToString(fields.SecondPartitions[i].Type),
|
|
|
|
|
|
fields.SecondPartitions[i].Offset / 2048).AppendLine();
|
|
|
|
|
|
for(int i = 0; i < fields.ThirdPartitions.Length; i++)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
sbInformation.AppendFormat("Third {0} partition starts at sector {1}",
|
2017-12-22 08:43:22 +00:00
|
|
|
|
PartitionTypeToString(fields.ThirdPartitions[i].Type),
|
|
|
|
|
|
fields.ThirdPartitions[i].Offset / 2048).AppendLine();
|
|
|
|
|
|
for(int i = 0; i < fields.FourthPartitions.Length; i++)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
sbInformation.AppendFormat("Fourth {0} partition starts at sector {1}",
|
2017-12-22 08:43:22 +00:00
|
|
|
|
PartitionTypeToString(fields.FourthPartitions[i].Type),
|
|
|
|
|
|
fields.FourthPartitions[i].Offset / 2048).AppendLine();
|
2016-04-19 01:17:14 +01:00
|
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
|
// sbInformation.AppendFormat("Region byte is {0}", fields.region).AppendLine();
|
2017-12-22 08:43:22 +00:00
|
|
|
|
if((fields.JapanAge & 0x80) != 0x80)
|
|
|
|
|
|
sbInformation.AppendFormat("Japan age rating is {0}", fields.JapanAge).AppendLine();
|
|
|
|
|
|
if((fields.UsaAge & 0x80) != 0x80)
|
|
|
|
|
|
sbInformation.AppendFormat("ESRB age rating is {0}", fields.UsaAge).AppendLine();
|
|
|
|
|
|
if((fields.GermanAge & 0x80) != 0x80)
|
|
|
|
|
|
sbInformation.AppendFormat("German age rating is {0}", fields.GermanAge).AppendLine();
|
|
|
|
|
|
if((fields.PegiAge & 0x80) != 0x80)
|
|
|
|
|
|
sbInformation.AppendFormat("PEGI age rating is {0}", fields.PegiAge).AppendLine();
|
|
|
|
|
|
if((fields.FinlandAge & 0x80) != 0x80)
|
|
|
|
|
|
sbInformation.AppendFormat("Finland age rating is {0}", fields.FinlandAge).AppendLine();
|
|
|
|
|
|
if((fields.PortugalAge & 0x80) != 0x80)
|
|
|
|
|
|
sbInformation.AppendFormat("Portugal age rating is {0}", fields.PortugalAge).AppendLine();
|
|
|
|
|
|
if((fields.UkAge & 0x80) != 0x80)
|
|
|
|
|
|
sbInformation.AppendFormat("UK age rating is {0}", fields.UkAge).AppendLine();
|
|
|
|
|
|
if((fields.AustraliaAge & 0x80) != 0x80)
|
|
|
|
|
|
sbInformation.AppendFormat("Australia age rating is {0}", fields.AustraliaAge).AppendLine();
|
|
|
|
|
|
if((fields.KoreaAge & 0x80) != 0x80)
|
|
|
|
|
|
sbInformation.AppendFormat("Korea age rating is {0}", fields.KoreaAge).AppendLine();
|
2016-04-19 01:17:14 +01:00
|
|
|
|
}
|
|
|
|
|
|
else
|
2017-12-22 08:43:22 +00:00
|
|
|
|
sbInformation.AppendFormat("FST starts at {0} and has {1} bytes", fields.FstOff, fields.FstSize)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
.AppendLine();
|
2016-04-19 01:17:14 +01:00
|
|
|
|
|
2018-06-22 08:08:38 +01:00
|
|
|
|
information = sbInformation.ToString();
|
|
|
|
|
|
XmlFsType.Bootable = true;
|
2019-04-23 01:38:33 +01:00
|
|
|
|
XmlFsType.Clusters = imagePlugin.Info.Sectors * imagePlugin.Info.SectorSize / 2048;
|
2018-06-22 08:08:38 +01:00
|
|
|
|
XmlFsType.ClusterSize = 2048;
|
|
|
|
|
|
XmlFsType.Type = wii ? "Nintendo Wii filesystem" : "Nintendo Gamecube filesystem";
|
|
|
|
|
|
XmlFsType.VolumeName = fields.Title;
|
2017-12-26 08:01:40 +00:00
|
|
|
|
XmlFsType.VolumeSerial = fields.DiscId;
|
2016-04-19 01:17:14 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-22 08:43:22 +00:00
|
|
|
|
static string DiscTypeToString(string discType)
|
2016-04-19 01:17:14 +01:00
|
|
|
|
{
|
|
|
|
|
|
switch(discType)
|
|
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
|
case "C": return "Commodore 64 Virtual Console";
|
|
|
|
|
|
case "D": return "Demo";
|
|
|
|
|
|
case "E": return "Neo-Geo Virtual Console";
|
|
|
|
|
|
case "F": return "NES Virtual Console";
|
|
|
|
|
|
case "G": return "Gamecube";
|
|
|
|
|
|
case "H": return "Wii channel";
|
|
|
|
|
|
case "J": return "Super Nintendo Virtual Console";
|
|
|
|
|
|
case "L": return "Master System Virtual Console";
|
|
|
|
|
|
case "M": return "Megadrive Virtual Console";
|
|
|
|
|
|
case "N": return "Nintendo 64 Virtual Console";
|
|
|
|
|
|
case "P": return "Promotional or TurboGrafx Virtual Console";
|
|
|
|
|
|
case "Q": return "TurboGrafx CD Virtual Console";
|
2016-04-19 01:17:14 +01:00
|
|
|
|
case "R":
|
2017-12-19 20:33:03 +00:00
|
|
|
|
case "S": return "Wii";
|
|
|
|
|
|
case "U": return "Utility";
|
|
|
|
|
|
case "W": return "WiiWare";
|
|
|
|
|
|
case "X": return "MSX Virtual Console or WiiWare demo";
|
2016-04-19 01:17:14 +01:00
|
|
|
|
case "0":
|
2017-12-19 20:33:03 +00:00
|
|
|
|
case "1": return "Diagnostic";
|
|
|
|
|
|
case "4": return "Wii Backup";
|
|
|
|
|
|
case "_": return "WiiFit";
|
2016-04-19 01:17:14 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-21 17:58:51 +00:00
|
|
|
|
return $"unknown type '{discType}'";
|
2016-04-19 01:17:14 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-22 08:43:22 +00:00
|
|
|
|
static string RegionCodeToString(string regionCode)
|
2016-04-19 01:17:14 +01:00
|
|
|
|
{
|
|
|
|
|
|
switch(regionCode)
|
|
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
|
case "A": return "any region";
|
|
|
|
|
|
case "D": return "Germany";
|
2016-04-19 01:17:14 +01:00
|
|
|
|
case "N":
|
2017-12-19 20:33:03 +00:00
|
|
|
|
case "E": return "USA";
|
|
|
|
|
|
case "F": return "France";
|
|
|
|
|
|
case "I": return "Italy";
|
|
|
|
|
|
case "J": return "Japan";
|
2016-04-19 01:17:14 +01:00
|
|
|
|
case "K":
|
2017-12-19 20:33:03 +00:00
|
|
|
|
case "Q": return "Korea";
|
2016-04-19 01:17:14 +01:00
|
|
|
|
case "L":
|
|
|
|
|
|
case "M":
|
2017-12-19 20:33:03 +00:00
|
|
|
|
case "P": return "PAL";
|
|
|
|
|
|
case "R": return "Russia";
|
|
|
|
|
|
case "S": return "Spain";
|
|
|
|
|
|
case "T": return "Taiwan";
|
|
|
|
|
|
case "U": return "Australia";
|
2016-04-19 01:17:14 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-21 17:58:51 +00:00
|
|
|
|
return $"unknown code '{regionCode}'";
|
2016-04-19 01:17:14 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-22 08:43:22 +00:00
|
|
|
|
static string PublisherCodeToString(string publisherCode)
|
2016-04-19 01:17:14 +01:00
|
|
|
|
{
|
|
|
|
|
|
switch(publisherCode)
|
|
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
|
case "01": return "Nintendo";
|
|
|
|
|
|
case "08": return "CAPCOM";
|
|
|
|
|
|
case "41": return "Ubisoft";
|
|
|
|
|
|
case "4F": return "Eidos";
|
|
|
|
|
|
case "51": return "Acclaim";
|
|
|
|
|
|
case "52": return "Activision";
|
|
|
|
|
|
case "5D": return "Midway";
|
|
|
|
|
|
case "5G": return "Hudson";
|
|
|
|
|
|
case "64": return "LucasArts";
|
|
|
|
|
|
case "69": return "Electronic Arts";
|
|
|
|
|
|
case "6S": return "TDK Mediactive";
|
|
|
|
|
|
case "8P": return "SEGA";
|
|
|
|
|
|
case "A4": return "Mirage Studios";
|
|
|
|
|
|
case "AF": return "Namco";
|
|
|
|
|
|
case "B2": return "Bandai";
|
|
|
|
|
|
case "DA": return "Tomy";
|
|
|
|
|
|
case "EM": return "Konami";
|
|
|
|
|
|
case "70": return "Atari";
|
|
|
|
|
|
case "4Q": return "Disney Interactive";
|
|
|
|
|
|
case "GD": return "Square Enix";
|
|
|
|
|
|
case "7D": return "Sierra";
|
2016-04-19 01:17:14 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-21 17:58:51 +00:00
|
|
|
|
return $"Unknown publisher '{publisherCode}'";
|
2016-04-19 01:17:14 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-22 08:43:22 +00:00
|
|
|
|
static string PartitionTypeToString(uint type)
|
2016-04-19 01:17:14 +01:00
|
|
|
|
{
|
|
|
|
|
|
switch(type)
|
|
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
|
case 0: return "data";
|
|
|
|
|
|
case 1: return "update";
|
|
|
|
|
|
case 2: return "channel";
|
2016-04-19 01:17:14 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-21 17:58:51 +00:00
|
|
|
|
return $"unknown type {type}";
|
2016-04-19 01:17:14 +01:00
|
|
|
|
}
|
2016-07-21 17:16:08 +01:00
|
|
|
|
|
2017-12-24 02:37:41 +00:00
|
|
|
|
struct NintendoFields
|
|
|
|
|
|
{
|
2018-06-22 08:08:38 +01:00
|
|
|
|
public string DiscType;
|
|
|
|
|
|
public string GameCode;
|
|
|
|
|
|
public string RegionCode;
|
|
|
|
|
|
public string PublisherCode;
|
|
|
|
|
|
public string DiscId;
|
|
|
|
|
|
public byte DiscNumber;
|
|
|
|
|
|
public byte DiscVersion;
|
|
|
|
|
|
public bool Streaming;
|
|
|
|
|
|
public byte StreamBufferSize;
|
|
|
|
|
|
public string Title;
|
|
|
|
|
|
public uint DebugOff;
|
|
|
|
|
|
public uint DebugAddr;
|
|
|
|
|
|
public uint DolOff;
|
|
|
|
|
|
public uint FstOff;
|
|
|
|
|
|
public uint FstSize;
|
|
|
|
|
|
public uint FstMax;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
public NintendoPartition[] FirstPartitions;
|
|
|
|
|
|
public NintendoPartition[] SecondPartitions;
|
|
|
|
|
|
public NintendoPartition[] ThirdPartitions;
|
|
|
|
|
|
public NintendoPartition[] FourthPartitions;
|
2018-06-22 08:08:38 +01:00
|
|
|
|
public byte Region;
|
|
|
|
|
|
public byte JapanAge;
|
|
|
|
|
|
public byte UsaAge;
|
|
|
|
|
|
public byte GermanAge;
|
|
|
|
|
|
public byte PegiAge;
|
|
|
|
|
|
public byte FinlandAge;
|
|
|
|
|
|
public byte PortugalAge;
|
|
|
|
|
|
public byte UkAge;
|
|
|
|
|
|
public byte AustraliaAge;
|
|
|
|
|
|
public byte KoreaAge;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct NintendoPartition
|
|
|
|
|
|
{
|
|
|
|
|
|
public uint Offset;
|
|
|
|
|
|
public uint Type;
|
|
|
|
|
|
}
|
2016-04-19 01:17:14 +01:00
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
}
|