mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Add interface to pass dump hardware list and CICM XML metadata to/from images.
This commit is contained in:
@@ -38,55 +38,56 @@ using DiscImageChef.CommonTypes;
|
||||
using DiscImageChef.Console;
|
||||
using DiscImageChef.Decoders.Floppy;
|
||||
using DiscImageChef.Filters;
|
||||
using Schemas;
|
||||
|
||||
namespace DiscImageChef.DiscImages
|
||||
{
|
||||
// TODO: Checksum sectors
|
||||
public class AppleNib : IMediaImage
|
||||
{
|
||||
readonly byte[] apple3_sign = {0x8D, 0xD0, 0x03, 0x4C, 0xC7, 0xA4};
|
||||
readonly byte[] cpm_sign = {0xA2, 0x55, 0xA9, 0x00, 0x9D, 0x00, 0x0D, 0xCA};
|
||||
readonly byte[] dos_sign = {0xA2, 0x02, 0x8E, 0x52};
|
||||
readonly ulong[] dosSkewing = {0, 7, 14, 6, 13, 5, 12, 4, 11, 3, 10, 2, 9, 1, 8, 15};
|
||||
readonly byte[] dri_string =
|
||||
readonly byte[] apple3_sign = {0x8D, 0xD0, 0x03, 0x4C, 0xC7, 0xA4};
|
||||
readonly byte[] cpm_sign = {0xA2, 0x55, 0xA9, 0x00, 0x9D, 0x00, 0x0D, 0xCA};
|
||||
readonly byte[] dos_sign = {0xA2, 0x02, 0x8E, 0x52};
|
||||
readonly ulong[] dosSkewing = {0, 7, 14, 6, 13, 5, 12, 4, 11, 3, 10, 2, 9, 1, 8, 15};
|
||||
readonly byte[] dri_string =
|
||||
{
|
||||
0x43, 0x4F, 0x50, 0x59, 0x52, 0x49, 0x47, 0x48, 0x54, 0x20, 0x28, 0x43, 0x29, 0x20, 0x31, 0x39, 0x37, 0x39,
|
||||
0x2C, 0x20, 0x44, 0x49, 0x47, 0x49, 0x54, 0x41, 0x4C, 0x20, 0x52, 0x45, 0x53, 0x45, 0x41, 0x52, 0x43, 0x48
|
||||
};
|
||||
readonly byte[] pascal_sign = {0x08, 0xA5, 0x0F, 0x29};
|
||||
readonly byte[] pascal_string = {0x53, 0x59, 0x53, 0x54, 0x45, 0x2E, 0x41, 0x50, 0x50, 0x4C, 0x45};
|
||||
readonly byte[] pascal2_sign = {0xFF, 0xA2, 0x00, 0x8E};
|
||||
readonly byte[] prodos_string = {0x50, 0x52, 0x4F, 0x44, 0x4F, 0x53};
|
||||
readonly ulong[] proDosSkewing = {0, 8, 1, 9, 2, 10, 3, 11, 4, 12, 5, 13, 6, 14, 7, 15};
|
||||
readonly byte[] sos_sign = {0xC9, 0x20, 0xF0, 0x3E};
|
||||
readonly byte[] pascal_sign = {0x08, 0xA5, 0x0F, 0x29};
|
||||
readonly byte[] pascal_string = {0x53, 0x59, 0x53, 0x54, 0x45, 0x2E, 0x41, 0x50, 0x50, 0x4C, 0x45};
|
||||
readonly byte[] pascal2_sign = {0xFF, 0xA2, 0x00, 0x8E};
|
||||
readonly byte[] prodos_string = {0x50, 0x52, 0x4F, 0x44, 0x4F, 0x53};
|
||||
readonly ulong[] proDosSkewing = {0, 8, 1, 9, 2, 10, 3, 11, 4, 12, 5, 13, 6, 14, 7, 15};
|
||||
readonly byte[] sos_sign = {0xC9, 0x20, 0xF0, 0x3E};
|
||||
Dictionary<ulong, byte[]> addressFields;
|
||||
Dictionary<ulong, byte[]> cookedSectors;
|
||||
ImageInfo imageInfo;
|
||||
ImageInfo imageInfo;
|
||||
Dictionary<ulong, byte[]> longSectors;
|
||||
|
||||
public AppleNib()
|
||||
{
|
||||
imageInfo = new ImageInfo
|
||||
{
|
||||
ReadableSectorTags = new List<SectorTagType>(),
|
||||
ReadableMediaTags = new List<MediaTagType>(),
|
||||
HasPartitions = false,
|
||||
HasSessions = false,
|
||||
Version = null,
|
||||
Application = null,
|
||||
ApplicationVersion = null,
|
||||
Creator = null,
|
||||
Comments = null,
|
||||
MediaManufacturer = null,
|
||||
MediaModel = null,
|
||||
MediaSerialNumber = null,
|
||||
MediaBarcode = null,
|
||||
MediaPartNumber = null,
|
||||
MediaSequence = 0,
|
||||
LastMediaSequence = 0,
|
||||
DriveManufacturer = null,
|
||||
DriveModel = null,
|
||||
DriveSerialNumber = null,
|
||||
ReadableSectorTags = new List<SectorTagType>(),
|
||||
ReadableMediaTags = new List<MediaTagType>(),
|
||||
HasPartitions = false,
|
||||
HasSessions = false,
|
||||
Version = null,
|
||||
Application = null,
|
||||
ApplicationVersion = null,
|
||||
Creator = null,
|
||||
Comments = null,
|
||||
MediaManufacturer = null,
|
||||
MediaModel = null,
|
||||
MediaSerialNumber = null,
|
||||
MediaBarcode = null,
|
||||
MediaPartNumber = null,
|
||||
MediaSequence = 0,
|
||||
LastMediaSequence = 0,
|
||||
DriveManufacturer = null,
|
||||
DriveModel = null,
|
||||
DriveSerialNumber = null,
|
||||
DriveFirmwareRevision = null
|
||||
};
|
||||
}
|
||||
@@ -94,7 +95,7 @@ namespace DiscImageChef.DiscImages
|
||||
public ImageInfo Info => imageInfo;
|
||||
|
||||
public string Name => "Apple NIB";
|
||||
public Guid Id => new Guid("AE171AE8-6747-49CC-B861-9D450B7CD42E");
|
||||
public Guid Id => new Guid("AE171AE8-6747-49CC-B861-9D450B7CD42E");
|
||||
|
||||
public string Format => "Apple nibbles";
|
||||
|
||||
@@ -136,19 +137,18 @@ namespace DiscImageChef.DiscImages
|
||||
|
||||
Dictionary<ulong, Apple2.RawSector> rawSectors = new Dictionary<ulong, Apple2.RawSector>();
|
||||
|
||||
int spt = 0;
|
||||
int spt = 0;
|
||||
bool allTracksEqual = true;
|
||||
for(int i = 1; i < tracks.Count; i++)
|
||||
for(int i = 1; i < tracks.Count; i++)
|
||||
allTracksEqual &= tracks[i - 1].sectors.Length == tracks[i].sectors.Length;
|
||||
|
||||
if(allTracksEqual) spt = tracks[0].sectors.Length;
|
||||
|
||||
bool skewed = spt == 16;
|
||||
bool skewed = spt == 16;
|
||||
ulong[] skewing = proDosSkewing;
|
||||
|
||||
// Detect ProDOS skewed disks
|
||||
if(skewed)
|
||||
{
|
||||
foreach(Apple2.RawSector sector in tracks[17].sectors)
|
||||
{
|
||||
if(!sector.addressField.sector.SequenceEqual(new byte[] {170, 170})) continue;
|
||||
@@ -162,21 +162,21 @@ namespace DiscImageChef.DiscImages
|
||||
sector0[0x37] == 1;
|
||||
|
||||
if(isDos) skewing = dosSkewing;
|
||||
|
||||
DicConsole.DebugWriteLine("Apple NIB Plugin", "Using {0}DOS skewing", skewing.SequenceEqual(dosSkewing) ? "" : "Pro");
|
||||
|
||||
DicConsole.DebugWriteLine("Apple NIB Plugin", "Using {0}DOS skewing",
|
||||
skewing.SequenceEqual(dosSkewing) ? "" : "Pro");
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < tracks.Count; i++)
|
||||
foreach(Apple2.RawSector sector in tracks[i].sectors)
|
||||
if(skewed && spt != 0)
|
||||
{
|
||||
ulong sectorNo = (ulong)((((sector.addressField.sector[0] & 0x55) << 1) |
|
||||
(sector.addressField.sector[1] & 0x55)) & 0xFF);
|
||||
(sector.addressField.sector[1] & 0x55)) & 0xFF);
|
||||
DicConsole.DebugWriteLine("Apple NIB Plugin",
|
||||
"Hardware sector {0} of track {1} goes to logical sector {2}",
|
||||
sectorNo, i, skewing[sectorNo] + (ulong)(i * spt));
|
||||
rawSectors.Add(skewing[sectorNo] + (ulong)(i * spt), sector);
|
||||
rawSectors.Add(skewing[sectorNo] + (ulong)(i * spt), sector);
|
||||
imageInfo.Sectors++;
|
||||
}
|
||||
else
|
||||
@@ -189,40 +189,43 @@ namespace DiscImageChef.DiscImages
|
||||
|
||||
DicConsole.DebugWriteLine("Apple NIB Plugin", "Cooking sectors");
|
||||
|
||||
longSectors = new Dictionary<ulong, byte[]>();
|
||||
longSectors = new Dictionary<ulong, byte[]>();
|
||||
cookedSectors = new Dictionary<ulong, byte[]>();
|
||||
addressFields = new Dictionary<ulong, byte[]>();
|
||||
|
||||
foreach(KeyValuePair<ulong, Apple2.RawSector> kvp in rawSectors)
|
||||
{
|
||||
byte[] cooked = Apple2.DecodeSector(kvp.Value);
|
||||
byte[] raw = Apple2.MarshalSector(kvp.Value);
|
||||
byte[] addr = Apple2.MarshalAddressField(kvp.Value.addressField);
|
||||
byte[] raw = Apple2.MarshalSector(kvp.Value);
|
||||
byte[] addr = Apple2.MarshalAddressField(kvp.Value.addressField);
|
||||
longSectors.Add(kvp.Key, raw);
|
||||
cookedSectors.Add(kvp.Key, cooked);
|
||||
addressFields.Add(kvp.Key, addr);
|
||||
}
|
||||
|
||||
imageInfo.ImageSize = (ulong)imageFilter.GetDataForkLength();
|
||||
imageInfo.CreationTime = imageFilter.GetCreationTime();
|
||||
imageInfo.ImageSize = (ulong)imageFilter.GetDataForkLength();
|
||||
imageInfo.CreationTime = imageFilter.GetCreationTime();
|
||||
imageInfo.LastModificationTime = imageFilter.GetLastWriteTime();
|
||||
imageInfo.MediaTitle = Path.GetFileNameWithoutExtension(imageFilter.GetFilename());
|
||||
if(imageInfo.Sectors == 455) imageInfo.MediaType = MediaType.Apple32SS;
|
||||
else if(imageInfo.Sectors == 560) imageInfo.MediaType = MediaType.Apple33SS;
|
||||
else imageInfo.MediaType = MediaType.Unknown;
|
||||
imageInfo.SectorSize = 256;
|
||||
imageInfo.XmlMediaType = XmlMediaType.BlockMedia;
|
||||
imageInfo.MediaTitle =
|
||||
Path.GetFileNameWithoutExtension(imageFilter.GetFilename());
|
||||
if(imageInfo.Sectors == 455) imageInfo.MediaType = MediaType.Apple32SS;
|
||||
else if(imageInfo.Sectors == 560)
|
||||
imageInfo.MediaType = MediaType.Apple33SS;
|
||||
else
|
||||
imageInfo.MediaType = MediaType.Unknown;
|
||||
imageInfo.SectorSize = 256;
|
||||
imageInfo.XmlMediaType = XmlMediaType.BlockMedia;
|
||||
imageInfo.ReadableSectorTags.Add(SectorTagType.FloppyAddressMark);
|
||||
switch(imageInfo.MediaType)
|
||||
{
|
||||
case MediaType.Apple32SS:
|
||||
imageInfo.Cylinders = 35;
|
||||
imageInfo.Heads = 1;
|
||||
imageInfo.Cylinders = 35;
|
||||
imageInfo.Heads = 1;
|
||||
imageInfo.SectorsPerTrack = 13;
|
||||
break;
|
||||
case MediaType.Apple33SS:
|
||||
imageInfo.Cylinders = 35;
|
||||
imageInfo.Heads = 1;
|
||||
imageInfo.Cylinders = 35;
|
||||
imageInfo.Heads = 1;
|
||||
imageInfo.SectorsPerTrack = 16;
|
||||
break;
|
||||
}
|
||||
@@ -230,16 +233,6 @@ namespace DiscImageChef.DiscImages
|
||||
return true;
|
||||
}
|
||||
|
||||
MediaType GetMediaType()
|
||||
{
|
||||
switch(imageInfo.Sectors)
|
||||
{
|
||||
case 455: return MediaType.Apple32SS;
|
||||
case 560: return MediaType.Apple33SS;
|
||||
default: return MediaType.Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] ReadSector(ulong sectorAddress)
|
||||
{
|
||||
if(sectorAddress > imageInfo.Sectors - 1)
|
||||
@@ -392,7 +385,7 @@ namespace DiscImageChef.DiscImages
|
||||
}
|
||||
|
||||
public bool? VerifySectors(ulong sectorAddress, uint length, out List<ulong> failingLbas,
|
||||
out List<ulong> unknownLbas)
|
||||
out List<ulong> unknownLbas)
|
||||
{
|
||||
failingLbas = new List<ulong>();
|
||||
unknownLbas = new List<ulong>();
|
||||
@@ -402,7 +395,7 @@ namespace DiscImageChef.DiscImages
|
||||
}
|
||||
|
||||
public bool? VerifySectors(ulong sectorAddress, uint length, uint track, out List<ulong> failingLbas,
|
||||
out List<ulong> unknownLbas)
|
||||
out List<ulong> unknownLbas)
|
||||
{
|
||||
throw new FeatureUnsupportedImageException("Feature not supported by image format");
|
||||
}
|
||||
@@ -411,5 +404,18 @@ namespace DiscImageChef.DiscImages
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<DumpHardwareType> DumpHardware => null;
|
||||
public CICMMetadataType CicmMetadata => null;
|
||||
|
||||
MediaType GetMediaType()
|
||||
{
|
||||
switch(imageInfo.Sectors)
|
||||
{
|
||||
case 455: return MediaType.Apple32SS;
|
||||
case 560: return MediaType.Apple33SS;
|
||||
default: return MediaType.Unknown;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user