2017-05-19 20:28:49 +01:00
|
|
|
// /***************************************************************************
|
2016-08-26 01:43:15 +01:00
|
|
|
// The Disc Image Chef
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// Filename : Definitions.cs
|
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
//
|
2016-08-26 01:45:58 +01:00
|
|
|
// Component : CP/M filesystem plugin.
|
2016-08-26 01:43:15 +01:00
|
|
|
//
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
//
|
2017-12-21 07:36:47 +00:00
|
|
|
// Handles definitions of known CP/M disks.
|
2016-08-26 01:43:15 +01:00
|
|
|
//
|
|
|
|
|
// --[ 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 <http://www.gnu.org/licenses/>.
|
|
|
|
|
//
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2017-12-19 03:50:57 +00:00
|
|
|
// Copyright © 2011-2018 Natalia Portillo
|
2016-08-26 01:43:15 +01:00
|
|
|
// ****************************************************************************/
|
2016-08-26 01:45:58 +01:00
|
|
|
|
2016-08-26 01:43:15 +01:00
|
|
|
using System;
|
2016-08-26 01:45:58 +01:00
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
using System.Xml;
|
|
|
|
|
using System.Xml.Serialization;
|
|
|
|
|
|
2016-08-26 01:43:15 +01:00
|
|
|
namespace DiscImageChef.Filesystems.CPM
|
|
|
|
|
{
|
2017-12-21 16:27:09 +00:00
|
|
|
partial class CPM
|
2016-08-26 01:43:15 +01:00
|
|
|
{
|
2016-08-26 01:45:58 +01:00
|
|
|
/// <summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
/// Loads all the known CP/M disk definitions from an XML stored as an embedded resource.
|
2016-08-26 01:45:58 +01:00
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>The definitions.</returns>
|
2017-12-20 02:08:37 +00:00
|
|
|
bool LoadDefinitions()
|
2016-08-26 01:43:15 +01:00
|
|
|
{
|
2016-08-26 01:45:58 +01:00
|
|
|
try
|
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
XmlReader defsReader =
|
|
|
|
|
XmlReader.Create(Assembly.GetExecutingAssembly()
|
2017-12-24 02:37:41 +00:00
|
|
|
.GetManifestResourceStream("DiscImageChef.Filesystems.CPM.cpmdefs.xml") ??
|
|
|
|
|
throw new InvalidOperationException());
|
2016-08-26 01:45:58 +01:00
|
|
|
XmlSerializer defsSerializer = new XmlSerializer(typeof(CpmDefinitions));
|
|
|
|
|
definitions = (CpmDefinitions)defsSerializer.Deserialize(defsReader);
|
|
|
|
|
|
|
|
|
|
// Patch definitions
|
|
|
|
|
foreach(CpmDefinition def in definitions.definitions)
|
|
|
|
|
{
|
|
|
|
|
if(def.side1 == null)
|
|
|
|
|
{
|
2017-12-22 08:43:22 +00:00
|
|
|
def.side1 = new Side {sideId = 0, sectorIds = new int[def.sectorsPerTrack]};
|
2017-12-19 20:33:03 +00:00
|
|
|
for(int i = 0; i < def.sectorsPerTrack; i++) def.side1.sectorIds[i] = i + 1;
|
2016-08-26 01:45:58 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-21 06:06:19 +00:00
|
|
|
if(def.sides != 2 || def.side2 != null) continue;
|
|
|
|
|
|
2016-08-26 01:45:58 +01:00
|
|
|
{
|
2017-12-22 08:43:22 +00:00
|
|
|
def.side2 = new Side {sideId = 1, sectorIds = new int[def.sectorsPerTrack]};
|
2017-12-19 20:33:03 +00:00
|
|
|
for(int i = 0; i < def.sectorsPerTrack; i++) def.side2.sectorIds[i] = i + 1;
|
2016-08-26 01:45:58 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
catch { return false; }
|
2016-08-26 01:43:15 +01:00
|
|
|
}
|
|
|
|
|
}
|
2016-08-26 01:45:58 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
/// CP/M disk definitions
|
2016-08-26 01:45:58 +01:00
|
|
|
/// </summary>
|
2017-12-20 02:08:37 +00:00
|
|
|
class CpmDefinitions
|
2016-08-26 01:45:58 +01:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
/// Timestamp of creation of the CP/M disk definitions list
|
2016-08-26 01:45:58 +01:00
|
|
|
/// </summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
public DateTime creation;
|
2016-08-26 01:45:58 +01:00
|
|
|
/// <summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
/// List of all CP/M disk definitions
|
2016-08-26 01:45:58 +01:00
|
|
|
/// </summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
public List<CpmDefinition> definitions;
|
2016-08-26 01:45:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
/// CP/M disk definition
|
2016-08-26 01:45:58 +01:00
|
|
|
/// </summary>
|
2017-12-20 02:08:37 +00:00
|
|
|
class CpmDefinition
|
2016-08-26 01:45:58 +01:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
/// Maps the first 16 allocation blocks for reservation, high byte
|
2016-08-26 01:45:58 +01:00
|
|
|
/// </summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
public int al0;
|
2016-08-26 01:45:58 +01:00
|
|
|
/// <summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
/// Maps the first 16 allocation blocks for reservation, low byte
|
2016-08-26 01:45:58 +01:00
|
|
|
/// </summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
public int al1;
|
2016-08-26 01:45:58 +01:00
|
|
|
/// <summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
/// Controller bitrate
|
2016-08-26 01:45:58 +01:00
|
|
|
/// </summary>
|
|
|
|
|
public string bitrate;
|
|
|
|
|
/// <summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
/// Block mask for <see cref="bsh" />
|
2016-08-26 01:45:58 +01:00
|
|
|
/// </summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
public int blm;
|
2016-08-26 01:45:58 +01:00
|
|
|
/// <summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
/// Left shifts needed to translate allocation block number to lba
|
2016-08-26 01:45:58 +01:00
|
|
|
/// </summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
public int bsh;
|
2016-08-26 01:45:58 +01:00
|
|
|
/// <summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
/// Physical bytes per sector
|
2016-08-26 01:45:58 +01:00
|
|
|
/// </summary>
|
|
|
|
|
public int bytesPerSector;
|
|
|
|
|
/// <summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
/// Comment and description
|
2016-08-26 01:45:58 +01:00
|
|
|
/// </summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
public string comment;
|
2016-08-26 01:45:58 +01:00
|
|
|
/// <summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
/// If true, all bytes written on disk are negated
|
2016-08-26 01:45:58 +01:00
|
|
|
/// </summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
public bool complement;
|
2016-08-26 01:45:58 +01:00
|
|
|
/// <summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
/// Total cylinders
|
2016-08-26 01:45:58 +01:00
|
|
|
/// </summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
public int cylinders;
|
2016-08-26 01:45:58 +01:00
|
|
|
/// <summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
/// Total number of available directory entries
|
2016-08-26 01:45:58 +01:00
|
|
|
/// </summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
public int drm;
|
2016-08-26 01:45:58 +01:00
|
|
|
/// <summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
/// Total number of 128 byte records on disk
|
2016-08-26 01:45:58 +01:00
|
|
|
/// </summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
public int dsm;
|
2016-08-26 01:45:58 +01:00
|
|
|
/// <summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
/// Encoding, "FM", "MFM", "GCR"
|
2016-08-26 01:45:58 +01:00
|
|
|
/// </summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
public string encoding;
|
2016-08-26 01:45:58 +01:00
|
|
|
/// <summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
/// Absolutely unknown?
|
2016-08-26 01:45:58 +01:00
|
|
|
/// </summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
public bool evenOdd;
|
2016-08-26 01:45:58 +01:00
|
|
|
/// <summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
/// Extent mask
|
2016-08-26 01:45:58 +01:00
|
|
|
/// </summary>
|
|
|
|
|
public int exm;
|
|
|
|
|
/// <summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
/// Disk definition label
|
2016-08-26 01:45:58 +01:00
|
|
|
/// </summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
public string label;
|
2016-08-26 01:45:58 +01:00
|
|
|
/// <summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
/// Tracks at the beginning of disk reserved for BIOS/BDOS
|
2016-08-26 01:45:58 +01:00
|
|
|
/// </summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
public int ofs;
|
2016-08-26 01:45:58 +01:00
|
|
|
/// <summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
/// Cylinder/side ordering. SIDES = change side after each track, CYLINDERS = change side after whole side, EAGLE and
|
|
|
|
|
/// COLUMBIA unknown
|
2016-08-26 01:45:58 +01:00
|
|
|
/// </summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
public string order;
|
2016-08-26 01:45:58 +01:00
|
|
|
/// <summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
/// Physical sectors per side
|
2016-08-26 01:45:58 +01:00
|
|
|
/// </summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
public int sectorsPerTrack;
|
2016-08-26 01:45:58 +01:00
|
|
|
/// <summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
/// Description of controller's side 0 (usually, upper side)
|
2016-08-26 01:45:58 +01:00
|
|
|
/// </summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
public Side side1;
|
2016-08-26 01:45:58 +01:00
|
|
|
/// <summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
/// Description of controller's side 1 (usually, lower side)
|
2016-08-26 01:45:58 +01:00
|
|
|
/// </summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
public Side side2;
|
2016-08-26 01:45:58 +01:00
|
|
|
/// <summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
/// Total sides
|
2016-08-26 01:45:58 +01:00
|
|
|
/// </summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
public int sides;
|
2016-08-26 01:45:58 +01:00
|
|
|
/// <summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
/// Physical sector interleaving
|
2016-08-26 01:45:58 +01:00
|
|
|
/// </summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
public int skew;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Sectors at the beginning of disk reserved for BIOS/BDOS
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int sofs;
|
2016-08-26 01:45:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
/// Side descriptions
|
2016-08-26 01:45:58 +01:00
|
|
|
/// </summary>
|
2017-12-20 02:08:37 +00:00
|
|
|
class Side
|
2016-08-26 01:45:58 +01:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
/// Software interleaving mask, [1,3,0,2] means CP/M LBA 0 is physical sector 1, LBA 1 = 3, so on
|
2016-08-26 01:45:58 +01:00
|
|
|
/// </summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
public int[] sectorIds;
|
2016-08-26 01:45:58 +01:00
|
|
|
/// <summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
/// Side ID as found in each sector address mark
|
2016-08-26 01:45:58 +01:00
|
|
|
/// </summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
public int sideId;
|
2016-08-26 01:45:58 +01:00
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
}
|