2015-10-19 02:04:38 +01:00
|
|
|
|
// /***************************************************************************
|
|
|
|
|
|
// The Disc Image Chef
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Filename : AppleSony.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 Apple/Sony 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
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2016-07-28 18:13:49 +01:00
|
|
|
|
// Copyright © 2011-2016 Natalia Portillo
|
2015-10-19 02:04:38 +01:00
|
|
|
|
// ****************************************************************************/
|
2016-07-28 18:13:49 +01:00
|
|
|
|
|
2015-10-19 02:13:54 +01:00
|
|
|
|
using System.Runtime.InteropServices;
|
2015-10-19 02:04:38 +01:00
|
|
|
|
|
|
|
|
|
|
namespace DiscImageChef.Decoders.Floppy
|
|
|
|
|
|
{
|
|
|
|
|
|
// Information from:
|
|
|
|
|
|
// Inside Macintosh, Volume II, ISBN 0-201-17732-3
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Methods and structures for Apple Sony GCR floppy decoding
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static class AppleSony
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// GCR-encoded Apple Sony GCR floppy track
|
|
|
|
|
|
/// </summary>
|
2015-10-19 02:13:54 +01:00
|
|
|
|
public struct RawTrack
|
2015-10-19 02:04:38 +01:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Track preamble, set to self-sync 0xFF, 36 bytes
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public byte[] gap;
|
2015-10-19 02:13:54 +01:00
|
|
|
|
public RawSector[] sectors;
|
2015-10-19 02:04:38 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// GCR-encoded Apple Sony GCR floppy sector
|
|
|
|
|
|
/// </summary>
|
2015-10-19 02:13:54 +01:00
|
|
|
|
public struct RawSector
|
2015-10-19 02:04:38 +01:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Address field
|
|
|
|
|
|
/// </summary>
|
2015-10-19 02:13:54 +01:00
|
|
|
|
public RawAddressField addressField;
|
2015-10-19 02:04:38 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Track preamble, set to self-sync 0xFF, 6 bytes
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public byte[] innerGap;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Data field
|
|
|
|
|
|
/// </summary>
|
2015-10-19 02:13:54 +01:00
|
|
|
|
public RawDataField dataField;
|
2015-10-19 02:04:38 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Track preamble, set to self-sync 0xFF, unknown size
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public byte[] gap;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// GCR-encoded Apple Sony GCR floppy sector address field
|
|
|
|
|
|
/// </summary>
|
2015-10-19 02:13:54 +01:00
|
|
|
|
public struct RawAddressField
|
2015-10-19 02:04:38 +01:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Always 0xD5, 0xAA, 0x96
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
|
|
|
|
|
|
public byte[] prologue;
|
|
|
|
|
|
/// <summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
|
/// Encoded (decodedTrack & 0x3F)
|
2015-10-19 02:04:38 +01:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
public byte track;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Encoded sector number
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public byte sector;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Encoded side number
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public byte side;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Disk format
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public AppleEncodedFormat format;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Checksum
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public byte checksum;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Always 0xDE, 0xAA
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
|
|
|
|
|
|
public byte[] epilogue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// GCR-encoded Apple ][ GCR floppy sector data field
|
|
|
|
|
|
/// </summary>
|
2015-10-19 02:13:54 +01:00
|
|
|
|
public struct RawDataField
|
2015-10-19 02:04:38 +01:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Always 0xD5, 0xAA, 0xAD
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
|
|
|
|
|
|
public byte[] prologue;
|
|
|
|
|
|
/// <summary>
|
2015-10-19 02:13:54 +01:00
|
|
|
|
/// Spare, usually <see cref="RawAddressField.sector"/>
|
2015-10-19 02:04:38 +01:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
public byte spare;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Encoded data bytes.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 698)]
|
|
|
|
|
|
public byte[] data;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Checksum
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
|
|
|
|
|
public byte[] checksum;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Always 0xDE, 0xAA
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
|
|
|
|
|
|
public byte[] epilogue;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|