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 : Commodore.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 Commodore (pre-Amiga) 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
|
|
|
//
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2020-12-31 23:08:22 +00:00
|
|
|
// Copyright © 2011-2021 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
|
|
|
|
2020-02-27 00:33:24 +00:00
|
|
|
namespace Aaru.Decoders.Floppy
|
2015-10-19 02:04:38 +01:00
|
|
|
{
|
2019-11-25 00:54:38 +00:00
|
|
|
/// <summary>Methods and structures for Commodore GCR floppy decoding</summary>
|
|
|
|
|
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"),
|
|
|
|
|
SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
2015-10-19 02:04:38 +01:00
|
|
|
public static class Commodore
|
|
|
|
|
{
|
2019-11-25 00:54:38 +00:00
|
|
|
/// <summary>Decoded Commodore GCR sector header</summary>
|
2015-10-19 02:13:54 +01:00
|
|
|
public struct SectorHeader
|
2015-10-19 02:04:38 +01:00
|
|
|
{
|
2019-11-25 00:54:38 +00:00
|
|
|
/// <summary>Always 0x08</summary>
|
2015-10-19 02:04:38 +01:00
|
|
|
public byte id;
|
2019-11-25 00:54:38 +00:00
|
|
|
/// <summary>XOR of following fields</summary>
|
2015-10-19 02:04:38 +01:00
|
|
|
public byte checksum;
|
2019-11-25 00:54:38 +00:00
|
|
|
/// <summary>Sector number</summary>
|
2015-10-19 02:04:38 +01:00
|
|
|
public byte sector;
|
2019-11-25 00:54:38 +00:00
|
|
|
/// <summary>Track number</summary>
|
2015-10-19 02:04:38 +01:00
|
|
|
public byte track;
|
2019-11-25 00:54:38 +00:00
|
|
|
/// <summary>Format ID, unknown meaning</summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public ushort format;
|
2019-11-25 00:54:38 +00:00
|
|
|
/// <summary>Filled with 0x0F</summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public ushort fill;
|
2015-10-19 02:04:38 +01:00
|
|
|
}
|
|
|
|
|
|
2019-11-25 00:54:38 +00:00
|
|
|
/// <summary>Decoded Commodore GCR sector data</summary>
|
2015-10-19 02:13:54 +01:00
|
|
|
public struct SectorData
|
2015-10-19 02:04:38 +01:00
|
|
|
{
|
2019-11-25 00:54:38 +00:00
|
|
|
/// <summary>Always 0x07</summary>
|
2015-10-19 02:04:38 +01:00
|
|
|
public byte id;
|
2019-11-25 00:54:38 +00:00
|
|
|
/// <summary>User data</summary>
|
2018-06-22 08:08:38 +01:00
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
|
|
|
|
|
public byte data;
|
2019-11-25 00:54:38 +00:00
|
|
|
/// <summary>XOR of <see cref="data" /></summary>
|
2015-10-19 02:04:38 +01:00
|
|
|
public byte checksum;
|
2019-11-25 00:54:38 +00:00
|
|
|
/// <summary>Filled with 0x0F</summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
public ushort fill;
|
2015-10-19 02:04:38 +01:00
|
|
|
}
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
}
|