2018-02-08 21:13:23 +00:00
|
|
|
|
// /***************************************************************************
|
2020-02-27 12:31:25 +00:00
|
|
|
|
// Aaru Data Preservation Suite
|
2018-02-08 21:13:23 +00:00
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
2022-12-07 13:07:31 +00:00
|
|
|
|
// Filename : Info.cs
|
2018-02-08 21:13:23 +00:00
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
|
//
|
|
|
|
|
|
// Component : NEC PC-FX plugin.
|
|
|
|
|
|
//
|
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Identifies the NEC PC-FX track header and shows information.
|
|
|
|
|
|
//
|
|
|
|
|
|
// --[ License ] --------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// 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
|
|
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
|
|
//
|
|
|
|
|
|
// 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.
|
|
|
|
|
|
//
|
|
|
|
|
|
// 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/>.
|
|
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2022-12-03 16:07:10 +00:00
|
|
|
|
// Copyright © 2011-2023 Natalia Portillo
|
2018-02-08 21:13:23 +00:00
|
|
|
|
// ****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Text;
|
2020-02-27 00:33:26 +00:00
|
|
|
|
using Aaru.CommonTypes;
|
|
|
|
|
|
using Aaru.CommonTypes.Enums;
|
|
|
|
|
|
using Aaru.CommonTypes.Interfaces;
|
2020-07-20 15:43:52 +01:00
|
|
|
|
using Aaru.Helpers;
|
2018-02-08 21:13:23 +00:00
|
|
|
|
using Schemas;
|
|
|
|
|
|
|
2022-11-15 15:58:43 +00:00
|
|
|
|
namespace Aaru.Filesystems;
|
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
// Not a filesystem, more like an executable header
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
/// <summary>Implements detection of NEC PC-FX headers</summary>
|
2022-12-07 13:07:31 +00:00
|
|
|
|
public sealed partial class PCFX
|
2018-02-08 21:13:23 +00:00
|
|
|
|
{
|
2021-08-17 14:25:12 +01:00
|
|
|
|
/// <inheritdoc />
|
2022-03-06 13:29:38 +00:00
|
|
|
|
public bool Identify(IMediaImage imagePlugin, Partition partition)
|
2018-02-08 21:13:23 +00:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(2 + partition.Start >= partition.End ||
|
|
|
|
|
|
imagePlugin.Info.XmlMediaType != XmlMediaType.OpticalDisc)
|
|
|
|
|
|
return false;
|
2018-02-08 21:13:23 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, 2, out byte[] sector);
|
2021-09-19 21:16:47 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(errno != ErrorNumber.NoError)
|
|
|
|
|
|
return false;
|
2018-02-08 21:13:23 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
var encoding = Encoding.GetEncoding("shift_jis");
|
2018-02-08 21:13:23 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return encoding.GetString(sector, 0, 16) == IDENTIFIER;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
2022-03-07 07:36:44 +00:00
|
|
|
|
public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding)
|
2022-03-06 13:29:38 +00:00
|
|
|
|
{
|
|
|
|
|
|
// Always Shift-JIS
|
|
|
|
|
|
Encoding = Encoding.GetEncoding("shift_jis");
|
|
|
|
|
|
information = "";
|
|
|
|
|
|
|
|
|
|
|
|
ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, 2, out byte[] sector);
|
2018-02-08 21:13:23 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(errno != ErrorNumber.NoError)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
Header header = Marshal.ByteArrayToStructureLittleEndian<Header>(sector);
|
|
|
|
|
|
|
|
|
|
|
|
string date;
|
|
|
|
|
|
DateTime dateTime = DateTime.MinValue;
|
|
|
|
|
|
|
|
|
|
|
|
try
|
2018-02-08 21:13:23 +00:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
date = Encoding.GetString(header.date);
|
2022-11-15 15:58:43 +00:00
|
|
|
|
int year = int.Parse(date[..4]);
|
|
|
|
|
|
int month = int.Parse(date.Substring(4, 2));
|
|
|
|
|
|
int day = int.Parse(date.Substring(6, 2));
|
2022-03-06 13:29:38 +00:00
|
|
|
|
dateTime = new DateTime(year, month, day);
|
2018-02-08 21:13:23 +00:00
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
catch
|
2018-02-08 21:13:23 +00:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
date = null;
|
2018-02-08 21:13:23 +00:00
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
var sb = new StringBuilder();
|
2022-11-28 02:59:53 +00:00
|
|
|
|
sb.AppendLine(Localization.PC_FX_executable);
|
|
|
|
|
|
sb.AppendFormat(Localization.Identifier_0, StringHandlers.CToString(header.signature, Encoding)).AppendLine();
|
|
|
|
|
|
sb.AppendFormat(Localization.Copyright_0, StringHandlers.CToString(header.copyright, Encoding)).AppendLine();
|
|
|
|
|
|
sb.AppendFormat(Localization.Title_0, StringHandlers.CToString(header.title, Encoding)).AppendLine();
|
|
|
|
|
|
sb.AppendFormat(Localization.Maker_ID_0, StringHandlers.CToString(header.makerId, Encoding)).AppendLine();
|
|
|
|
|
|
sb.AppendFormat(Localization.Maker_name_0, StringHandlers.CToString(header.makerName, Encoding)).AppendLine();
|
|
|
|
|
|
sb.AppendFormat(Localization.Volume_number_0, header.volumeNumber).AppendLine();
|
|
|
|
|
|
sb.AppendFormat(Localization.Country_code_0, header.country).AppendLine();
|
|
|
|
|
|
sb.AppendFormat(Localization.Version_0_1, header.minorVersion, header.majorVersion).AppendLine();
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
if(date != null)
|
2022-11-28 02:59:53 +00:00
|
|
|
|
sb.AppendFormat(Localization.Dated_0, dateTime).AppendLine();
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
2022-11-28 02:59:53 +00:00
|
|
|
|
sb.AppendFormat(Localization.Load_0_sectors_from_sector_1, header.loadCount, header.loadOffset).AppendLine();
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
2022-11-28 02:59:53 +00:00
|
|
|
|
sb.AppendFormat(Localization.Load_at_0_and_jump_to_1, header.loadAddress, header.entryPoint).AppendLine();
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
information = sb.ToString();
|
|
|
|
|
|
|
|
|
|
|
|
XmlFsType = new FileSystemType
|
|
|
|
|
|
{
|
2022-11-28 02:59:53 +00:00
|
|
|
|
Type = FS_TYPE,
|
2022-03-06 13:29:38 +00:00
|
|
|
|
Clusters = partition.Length,
|
|
|
|
|
|
ClusterSize = 2048,
|
|
|
|
|
|
Bootable = true,
|
|
|
|
|
|
CreationDate = dateTime,
|
|
|
|
|
|
CreationDateSpecified = date != null,
|
|
|
|
|
|
PublisherIdentifier = StringHandlers.CToString(header.makerName, Encoding),
|
|
|
|
|
|
VolumeName = StringHandlers.CToString(header.title, Encoding),
|
|
|
|
|
|
SystemIdentifier = "PC-FX"
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
2018-02-08 21:13:23 +00:00
|
|
|
|
}
|