2017-05-19 20:28:49 +01:00
|
|
|
// /***************************************************************************
|
2020-02-27 12:31:23 +00:00
|
|
|
// Aaru Data Preservation Suite
|
2015-10-19 02:04:38 +01:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// Filename : ISO.cs
|
2016-07-28 18:13:49 +01:00
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
2015-10-19 02:04:38 +01:00
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// Component : Device structures decoders.
|
2015-10-19 02:04:38 +01:00
|
|
|
//
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// Decodes ISO/ECMA floppy structures.
|
2015-10-19 02:04:38 +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
|
2015-10-19 02:04:38 +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.
|
2015-10-19 02:04:38 +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/>.
|
2015-10-19 02:04:38 +01:00
|
|
|
//
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2022-12-03 16:07:08 +00:00
|
|
|
// Copyright © 2011-2023 Natalia Portillo
|
2015-10-19 02:04:38 +01:00
|
|
|
// ****************************************************************************/
|
2016-07-28 18:13:49 +01:00
|
|
|
|
2017-12-22 02:04:18 +00:00
|
|
|
using System.Diagnostics.CodeAnalysis;
|
2015-10-19 02:13:54 +01:00
|
|
|
using System.Runtime.InteropServices;
|
2015-10-19 02:04:38 +01:00
|
|
|
|
2022-11-15 15:58:41 +00:00
|
|
|
namespace Aaru.Decoders.Floppy;
|
|
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
// Information from:
|
|
|
|
|
// National Semiconductor PC87332VLJ datasheet
|
|
|
|
|
// SMsC FDC37C78 datasheet
|
|
|
|
|
// Intel 82078 datasheet
|
|
|
|
|
// Intel 82077AA datasheet
|
|
|
|
|
// Toshiba TC8566AF datasheet
|
|
|
|
|
// Fujitsu MB8876A datasheet
|
|
|
|
|
// ECMA-147
|
|
|
|
|
// ECMA-100
|
2015-10-19 02:04:38 +01:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
/// <summary>Methods and structures for ISO floppy decoding (also used by Atari ST and others)</summary>
|
2023-10-03 23:09:28 +01:00
|
|
|
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
|
|
|
|
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
|
|
|
|
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
2023-10-05 01:05:20 +01:00
|
|
|
[SuppressMessage("ReSharper", "UnusedMember.Global")]
|
|
|
|
|
[SuppressMessage("ReSharper", "UnusedType.Global")]
|
2022-03-06 13:29:37 +00:00
|
|
|
public static class ISO
|
|
|
|
|
{
|
2023-10-03 23:09:28 +01:00
|
|
|
#region Nested type: AddressMark
|
2015-10-19 02:13:54 +01:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
/// <summary>Sector address mark for IBM System 34 floppies, contains sync word</summary>
|
|
|
|
|
public struct AddressMark
|
|
|
|
|
{
|
|
|
|
|
/// <summary>12 bytes set to 0</summary>
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)]
|
|
|
|
|
public byte[] zero;
|
|
|
|
|
/// <summary>3 bytes set to 0xA1</summary>
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
|
|
|
|
|
public byte[] aone;
|
|
|
|
|
/// <summary>Set to <see cref="IBMIdType.AddressMark" /></summary>
|
|
|
|
|
public IBMIdType type;
|
|
|
|
|
/// <summary>Track number</summary>
|
|
|
|
|
public byte track;
|
|
|
|
|
/// <summary>Side number</summary>
|
|
|
|
|
public byte side;
|
|
|
|
|
/// <summary>Sector number</summary>
|
|
|
|
|
public byte sector;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <see cref="IBMSectorSizeCode" />
|
|
|
|
|
/// </summary>
|
|
|
|
|
public IBMSectorSizeCode sectorSize;
|
|
|
|
|
/// <summary>CRC16 from <see cref="aone" /> to end of <see cref="sectorSize" /></summary>
|
|
|
|
|
public ushort crc;
|
|
|
|
|
}
|
2015-10-19 02:13:54 +01:00
|
|
|
|
2023-10-03 23:09:28 +01:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Nested type: DataBlock
|
|
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
/// <summary>Sector data block for IBM System 34 floppies</summary>
|
|
|
|
|
public struct DataBlock
|
|
|
|
|
{
|
|
|
|
|
/// <summary>12 bytes set to 0</summary>
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)]
|
|
|
|
|
public byte[] zero;
|
|
|
|
|
/// <summary>3 bytes set to 0xA1</summary>
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
|
|
|
|
|
public byte[] aone;
|
|
|
|
|
/// <summary>Set to <see cref="IBMIdType.DataMark" /> or to <see cref="IBMIdType.DeletedDataMark" /></summary>
|
|
|
|
|
public IBMIdType type;
|
|
|
|
|
/// <summary>User data</summary>
|
|
|
|
|
public byte[] data;
|
|
|
|
|
/// <summary>CRC16 from <see cref="aone" /> to end of <see cref="data" /></summary>
|
|
|
|
|
public ushort crc;
|
2015-10-19 02:04:38 +01:00
|
|
|
}
|
2023-10-03 23:09:28 +01:00
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Nested type: Sector
|
|
|
|
|
|
|
|
|
|
/// <summary>Raw demodulated format for IBM System 34 floppies</summary>
|
|
|
|
|
public struct Sector
|
|
|
|
|
{
|
|
|
|
|
/// <summary>Sector address mark</summary>
|
|
|
|
|
public AddressMark addressMark;
|
|
|
|
|
/// <summary>22 bytes set to 0x4E, set to 0x22 on Commodore 1581</summary>
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 22)]
|
|
|
|
|
public byte[] innerGap;
|
|
|
|
|
/// <summary>Sector data block</summary>
|
|
|
|
|
public DataBlock dataBlock;
|
|
|
|
|
/// <summary>Variable bytes set to 0x4E, ECMA defines 54</summary>
|
|
|
|
|
public byte[] outerGap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Nested type: Track
|
|
|
|
|
|
|
|
|
|
/// <summary>ISO floppy track, also used by Atari ST and others</summary>
|
|
|
|
|
public struct Track
|
|
|
|
|
{
|
|
|
|
|
/// <summary>Start of track, 32 bytes set to 0x4E</summary>
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
|
|
|
|
|
public byte[] innerGap;
|
|
|
|
|
/// <summary>Track sectors</summary>
|
|
|
|
|
public Sector[] sectors;
|
|
|
|
|
/// <summary>Undefined size</summary>
|
|
|
|
|
public byte[] gap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
2017-12-19 20:33:03 +00:00
|
|
|
}
|