// /*************************************************************************** // The Disc Image Chef // ---------------------------------------------------------------------------- // // Filename : Structs.cs // Author(s) : Michael Drüing // // Component : Disk image plugins. // // --[ Description ] ---------------------------------------------------------- // // Contains structures for d2f disk images. // // --[ 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 © 2018-2019 Michael Drüing // Copyright © 2011-2019 Natalia Portillo // ****************************************************************************/ using System.Runtime.InteropServices; namespace DiscImageChef.DiscImages { public partial class WCDiskImage { /// /// The expected signature of a proper image file. /// const string fileSignature = "WC DISK IMAGE\x1a\x1a"; /// /// The global header of a WCDiskImage file /// [StructLayout(LayoutKind.Sequential, Pack = 1)] struct WCDiskImageFileHeader { /// /// The signature should be "WC DISK IMAGE\0x1a\0x1a\0x00" /// [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public byte[] signature; /// /// Version (currently only version 0 and 1 is known) /// public byte version; /// /// The number of heads. Only 1 or 2 is supported /// public byte heads; /// /// Sectors per track, maximum is 18 /// public byte sectorsPerTrack; /// /// The number of tracks/cylinders. 80 is the maximum /// public byte cylinders; /// /// The "extra tracks" that are present. What this means is that the /// tracks 81 and 82 might contain data (on an 80-track disk) and that /// this data was dumped too. The order is head0extra1, head1extra1, /// head0extra2, head1extra2. 1 means track is present. /// [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public byte[] extraTracks; /// /// Additional metadata present flags. /// public ExtraFlag extraFlags; /// /// Padding to make the header 32 bytes. /// [MarshalAs(UnmanagedType.ByValArray, SizeConst = 7)] public byte[] reserved; } enum ExtraFlag : byte { /// /// Set if a Comment is present after the image /// Comment = 0x01, /// /// Set if a directory listing is present after the image /// Directory = 0x02, } /// /// The Sector header that precedes each sector /// [StructLayout(LayoutKind.Sequential, Pack = 1)] struct WCDiskImageSectorHeader { /// /// The sector flag (i.e. type) /// public SectorFlag flag; /// /// The head this sector belongs to. /// public byte head; /// /// The sector number within the track. Must be consecutive. /// public byte sector; /// /// The cylinder number this sector belongs to. /// public byte cylinder; /// /// A simple CRC16 over the data, to detect errors. /// public short crc; } enum SectorFlag : byte { /// /// A normal sector /// Normal = 0x00, /// /// A bad sector that could not be read /// BadSector = 0x01, /// /// A sector filled with a repeating byte value. The value /// is encoded in the LSB of the crc field. /// RepeatByte = 0x02, /// /// Not a sector but a comment. Must come after all user data. /// The crc field is the length of the comment data. /// Comment = 0x03, /// /// Not a sector but the directory information. /// The crc field is the length of the data. /// Directory = 0x04, } } }