// /*************************************************************************** // Aaru Data Preservation Suite // ---------------------------------------------------------------------------- // // Filename : ISO.cs // Author(s) : Natalia Portillo // // Component : Device structures decoders. // // --[ Description ] ---------------------------------------------------------- // // Decodes ISO/ECMA floppy structures. // // --[ 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 . // // ---------------------------------------------------------------------------- // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; namespace Aaru.Decoders.Floppy; // 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 /// Methods and structures for ISO floppy decoding (also used by Atari ST and others) [SuppressMessage("ReSharper", "InconsistentNaming")] [SuppressMessage("ReSharper", "MemberCanBeInternal")] [SuppressMessage("ReSharper", "MemberCanBePrivate.Global")] [SuppressMessage("ReSharper", "UnusedMember.Global")] [SuppressMessage("ReSharper", "UnusedType.Global")] public static class ISO { #region Nested type: AddressMark /// Sector address mark for IBM System 34 floppies, contains sync word public struct AddressMark { /// 12 bytes set to 0 [MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)] public byte[] zero; /// 3 bytes set to 0xA1 [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public byte[] aone; /// Set to public IBMIdType type; /// Track number public byte track; /// Side number public byte side; /// Sector number public byte sector; /// /// /// public IBMSectorSizeCode sectorSize; /// CRC16 from to end of public ushort crc; } #endregion #region Nested type: DataBlock /// Sector data block for IBM System 34 floppies public struct DataBlock { /// 12 bytes set to 0 [MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)] public byte[] zero; /// 3 bytes set to 0xA1 [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] public byte[] aone; /// Set to or to public IBMIdType type; /// User data public byte[] data; /// CRC16 from to end of public ushort crc; } #endregion #region Nested type: Sector /// Raw demodulated format for IBM System 34 floppies public struct Sector { /// Sector address mark public AddressMark addressMark; /// 22 bytes set to 0x4E, set to 0x22 on Commodore 1581 [MarshalAs(UnmanagedType.ByValArray, SizeConst = 22)] public byte[] innerGap; /// Sector data block public DataBlock dataBlock; /// Variable bytes set to 0x4E, ECMA defines 54 public byte[] outerGap; } #endregion #region Nested type: Track /// ISO floppy track, also used by Atari ST and others public struct Track { /// Start of track, 32 bytes set to 0x4E [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public byte[] innerGap; /// Track sectors public Sector[] sectors; /// Undefined size public byte[] gap; } #endregion }