// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// Filename : Perpendicular.cs
// Version : 1.0
// Author(s) : Natalia Portillo
//
// Component : Perpendicular MFM floppy decoder
//
// Revision : $Revision$
// Last change by : $Author$
// Date : $Date$
//
// --[ Description ] ----------------------------------------------------------
//
// Methods and structures for perpendicular MFM floppy decoding
//
// --[ License ] --------------------------------------------------------------
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
//
// ----------------------------------------------------------------------------
// Copyright (C) 2011-2015 Claunia.com
// ****************************************************************************/
// //$Id$
using System;
using System.Runtime.InteropServices;
namespace DiscImageChef.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 perpendicular MFM floppy decoding
///
public static class Perpendicular
{
///
/// Perpendicular floppy track
///
public struct Track
{
///
/// Start of track
///
public TrackPreamble trackStart;
///
/// Track sectors
///
public Sector[] sectors;
///
/// Undefined size
///
public byte[] gap;
}
///
/// Raw demodulated format for perpendicular floppies
///
public struct Sector
{
///
/// Sector address mark
///
public AddressMark addressMark;
///
/// 41 bytes set to 0x4E
///
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 41)]
public byte[] innerGap;
///
/// Sector data block
///
public DataBlock dataBlock;
///
/// Variable-sized inter-sector gap, ECMA defines 83 bytes
///
public byte[] outerGap;
}
///
/// Start of IBM PC MFM floppy track
/// Used by IBM PC, Apple Macintosh (high-density only), and a lot others
///
public struct TrackPreamble
{
///
/// Gap from index pulse, 80 bytes set to 0x4E
///
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 80)]
public byte[] gap;
///
/// 12 bytes set to 0x00
///
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)]
public byte[] zero;
///
/// 3 bytes set to 0xC2
///
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
public byte[] ctwo;
///
/// Set to
///
public IBMIdType type;
///
/// Gap until first sector, 50 bytes to 0x4E
///
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 50)]
public byte[] gap1;
}
///
/// 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 UInt16 crc;
}
///
/// 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 UInt16 crc;
}
}
}