mirror of
https://github.com/digital-jellyfish/Virtu.git
synced 2024-06-02 12:41:31 +00:00
bc4caaf2b1
--HG-- extra : convert_revision : svn%3Affd33b8c-2492-42e0-bdc5-587b920b7d6d/trunk%4046550
53 lines
1.7 KiB
C#
53 lines
1.7 KiB
C#
using System;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
|
|
namespace Jellyfish.Virtu
|
|
{
|
|
public abstract class Disk525
|
|
{
|
|
protected Disk525(string name, byte[] data, bool isWriteProtected)
|
|
{
|
|
Name = name;
|
|
Data = data;
|
|
IsWriteProtected = isWriteProtected;
|
|
}
|
|
|
|
public static Disk525 CreateDisk(string name, byte[] data, bool isWriteProtected)
|
|
{
|
|
if (name == null)
|
|
{
|
|
throw new ArgumentNullException("name");
|
|
}
|
|
if (data == null)
|
|
{
|
|
throw new ArgumentNullException("data");
|
|
}
|
|
|
|
if (name.EndsWith(".nib", StringComparison.OrdinalIgnoreCase) && (data.Length == TrackCount * TrackSize))
|
|
{
|
|
return new DiskNib(name, data, isWriteProtected);
|
|
}
|
|
else if (name.EndsWith(".dsk", StringComparison.OrdinalIgnoreCase) && (data.Length == TrackCount * SectorCount * SectorSize))
|
|
{
|
|
return new DiskDsk(name, data, isWriteProtected);
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
public abstract void ReadTrack(int number, int fraction, byte[] buffer);
|
|
public abstract void WriteTrack(int number, int fraction, byte[] buffer);
|
|
|
|
public string Name { get; private set; }
|
|
public bool IsWriteProtected { get; private set; }
|
|
|
|
[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
|
|
protected byte[] Data { get; private set; }
|
|
|
|
public const int SectorCount = 16;
|
|
public const int SectorSize = 0x100;
|
|
public const int TrackCount = 35;
|
|
public const int TrackSize = 0x1A00;
|
|
}
|
|
}
|