mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
[Aaru.Images] Reformat and cleanup.
This commit is contained in:
@@ -37,9 +37,6 @@ namespace Aaru.DiscImages;
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Local")]
|
||||
public sealed partial class D88
|
||||
{
|
||||
const byte READ_ONLY = 0x10;
|
||||
readonly byte[] _reservedEmpty =
|
||||
{
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
const byte READ_ONLY = 0x10;
|
||||
readonly byte[] _reservedEmpty = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
}
|
||||
@@ -44,6 +44,7 @@ namespace Aaru.DiscImages;
|
||||
/// <summary>Implements reading Quasi88 disk images</summary>
|
||||
public sealed partial class D88 : IMediaImage
|
||||
{
|
||||
const string MODULE_NAME = "D88 plugin";
|
||||
ImageInfo _imageInfo;
|
||||
List<byte[]> _sectorsData;
|
||||
|
||||
@@ -70,6 +71,4 @@ public sealed partial class D88 : IMediaImage
|
||||
DriveSerialNumber = null,
|
||||
DriveFirmwareRevision = null
|
||||
};
|
||||
|
||||
const string MODULE_NAME = "D88 plugin";
|
||||
}
|
||||
@@ -34,19 +34,33 @@ using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Aaru.DiscImages;
|
||||
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Local"), SuppressMessage("ReSharper", "UnusedType.Local")]
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Local")]
|
||||
[SuppressMessage("ReSharper", "UnusedType.Local")]
|
||||
public sealed partial class D88
|
||||
{
|
||||
enum DiskType : byte
|
||||
{
|
||||
D2 = 0x00, Dd2 = 0x10, Hd2 = 0x20
|
||||
}
|
||||
#region Nested type: DensityType
|
||||
|
||||
enum DensityType : byte
|
||||
{
|
||||
Mfm = 0x00, Fm = 0x40
|
||||
Mfm = 0x00,
|
||||
Fm = 0x40
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Nested type: DiskType
|
||||
|
||||
enum DiskType : byte
|
||||
{
|
||||
D2 = 0x00,
|
||||
Dd2 = 0x10,
|
||||
Hd2 = 0x20
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Nested type: StatusType
|
||||
|
||||
/// <summary>Status as returned by PC-98 BIOS ステータスは、PC-98x1 のBIOS が返してくるステータスで、</summary>
|
||||
enum StatusType : byte
|
||||
{
|
||||
@@ -63,4 +77,6 @@ public sealed partial class D88
|
||||
/// <summary>Data mark not found データマークなし</summary>
|
||||
DataMarkNotFound = 0xF0
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -41,6 +41,8 @@ namespace Aaru.DiscImages;
|
||||
|
||||
public sealed partial class D88
|
||||
{
|
||||
#region IMediaImage Members
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool Identify(IFilter imageFilter)
|
||||
{
|
||||
@@ -53,7 +55,7 @@ public sealed partial class D88
|
||||
if(stream.Length < Marshal.SizeOf<Header>())
|
||||
return false;
|
||||
|
||||
byte[] hdrB = new byte[Marshal.SizeOf<Header>()];
|
||||
var hdrB = new byte[Marshal.SizeOf<Header>()];
|
||||
stream.EnsureRead(hdrB, 0, hdrB.Length);
|
||||
|
||||
Header hdr = Marshal.ByteArrayToStructureLittleEndian<Header>(hdrB);
|
||||
@@ -80,7 +82,7 @@ public sealed partial class D88
|
||||
if(!hdr.reserved.SequenceEqual(_reservedEmpty))
|
||||
return false;
|
||||
|
||||
int counter = 0;
|
||||
var counter = 0;
|
||||
|
||||
foreach(int t in hdr.track_table)
|
||||
{
|
||||
@@ -96,4 +98,6 @@ public sealed partial class D88
|
||||
|
||||
return counter > 0;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -39,18 +39,28 @@ namespace Aaru.DiscImages;
|
||||
|
||||
public sealed partial class D88
|
||||
{
|
||||
#region IMediaImage Members
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Name => Localization.D88_Name;
|
||||
|
||||
/// <inheritdoc />
|
||||
public Guid Id => new("669EDC77-EC41-4720-A88C-49C38CFFBAA0");
|
||||
|
||||
/// <inheritdoc />
|
||||
public ImageInfo Info => _imageInfo;
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Format => "D88 disk image";
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Author => Authors.NataliaPortillo;
|
||||
|
||||
/// <inheritdoc />
|
||||
public List<DumpHardware> DumpHardware => null;
|
||||
|
||||
/// <inheritdoc />
|
||||
public Metadata AaruMetadata => null;
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -45,6 +45,8 @@ namespace Aaru.DiscImages;
|
||||
|
||||
public sealed partial class D88
|
||||
{
|
||||
#region IMediaImage Members
|
||||
|
||||
/// <inheritdoc />
|
||||
public ErrorNumber Open(IFilter imageFilter)
|
||||
{
|
||||
@@ -57,7 +59,7 @@ public sealed partial class D88
|
||||
if(stream.Length < Marshal.SizeOf<Header>())
|
||||
return ErrorNumber.InvalidArgument;
|
||||
|
||||
byte[] hdrB = new byte[Marshal.SizeOf<Header>()];
|
||||
var hdrB = new byte[Marshal.SizeOf<Header>()];
|
||||
stream.EnsureRead(hdrB, 0, hdrB.Length);
|
||||
Header hdr = Marshal.ByteArrayToStructureLittleEndian<Header>(hdrB);
|
||||
|
||||
@@ -83,7 +85,7 @@ public sealed partial class D88
|
||||
if(!hdr.reserved.SequenceEqual(_reservedEmpty))
|
||||
return ErrorNumber.InvalidArgument;
|
||||
|
||||
int trkCounter = 0;
|
||||
var trkCounter = 0;
|
||||
|
||||
foreach(int t in hdr.track_table)
|
||||
{
|
||||
@@ -106,22 +108,22 @@ public sealed partial class D88
|
||||
|
||||
SectorHeader sechdr = Marshal.ByteArrayToStructureLittleEndian<SectorHeader>(hdrB);
|
||||
|
||||
AaruConsole.DebugWriteLine(MODULE_NAME, "sechdr.c = {0}", sechdr.c);
|
||||
AaruConsole.DebugWriteLine(MODULE_NAME, "sechdr.h = {0}", sechdr.h);
|
||||
AaruConsole.DebugWriteLine(MODULE_NAME, "sechdr.r = {0}", sechdr.r);
|
||||
AaruConsole.DebugWriteLine(MODULE_NAME, "sechdr.n = {0}", sechdr.n);
|
||||
AaruConsole.DebugWriteLine(MODULE_NAME, "sechdr.spt = {0}", sechdr.spt);
|
||||
AaruConsole.DebugWriteLine(MODULE_NAME, "sechdr.density = {0}", sechdr.density);
|
||||
AaruConsole.DebugWriteLine(MODULE_NAME, "sechdr.c = {0}", sechdr.c);
|
||||
AaruConsole.DebugWriteLine(MODULE_NAME, "sechdr.h = {0}", sechdr.h);
|
||||
AaruConsole.DebugWriteLine(MODULE_NAME, "sechdr.r = {0}", sechdr.r);
|
||||
AaruConsole.DebugWriteLine(MODULE_NAME, "sechdr.n = {0}", sechdr.n);
|
||||
AaruConsole.DebugWriteLine(MODULE_NAME, "sechdr.spt = {0}", sechdr.spt);
|
||||
AaruConsole.DebugWriteLine(MODULE_NAME, "sechdr.density = {0}", sechdr.density);
|
||||
AaruConsole.DebugWriteLine(MODULE_NAME, "sechdr.deleted_mark = {0}", sechdr.deleted_mark);
|
||||
AaruConsole.DebugWriteLine(MODULE_NAME, "sechdr.status = {0}", sechdr.status);
|
||||
AaruConsole.DebugWriteLine(MODULE_NAME, "sechdr.status = {0}", sechdr.status);
|
||||
AaruConsole.DebugWriteLine(MODULE_NAME, "sechdr.size_of_data = {0}", sechdr.size_of_data);
|
||||
|
||||
short spt = sechdr.spt;
|
||||
IBMSectorSizeCode bps = sechdr.n;
|
||||
bool allEqual = true;
|
||||
var allEqual = true;
|
||||
_sectorsData = new List<byte[]>();
|
||||
|
||||
for(int i = 0; i < trkCounter; i++)
|
||||
for(var i = 0; i < trkCounter; i++)
|
||||
{
|
||||
stream.Seek(hdr.track_table[i], SeekOrigin.Begin);
|
||||
stream.EnsureRead(hdrB, 0, hdrB.Length);
|
||||
@@ -173,59 +175,63 @@ public sealed partial class D88
|
||||
_imageInfo.MediaType = MediaType.Unknown;
|
||||
|
||||
if(allEqual)
|
||||
{
|
||||
if(trkCounter == 154 &&
|
||||
spt == 26 &&
|
||||
bps == IBMSectorSizeCode.EighthKilo)
|
||||
_imageInfo.MediaType = MediaType.NEC_8_SD;
|
||||
else if(bps == IBMSectorSizeCode.QuarterKilo)
|
||||
{
|
||||
_imageInfo.MediaType = trkCounter switch
|
||||
{
|
||||
35 when spt == 16 => MediaType.MetaFloppy_Mod_I,
|
||||
77 when spt == 16 => MediaType.MetaFloppy_Mod_II,
|
||||
80 when spt == 16 => MediaType.NEC_525_SS,
|
||||
154 when spt == 26 => MediaType.NEC_8_DD,
|
||||
160 when spt == 16 => MediaType.NEC_525_DS,
|
||||
_ => _imageInfo.MediaType
|
||||
};
|
||||
{
|
||||
35 when spt == 16 => MediaType.MetaFloppy_Mod_I,
|
||||
77 when spt == 16 => MediaType.MetaFloppy_Mod_II,
|
||||
80 when spt == 16 => MediaType.NEC_525_SS,
|
||||
154 when spt == 26 => MediaType.NEC_8_DD,
|
||||
160 when spt == 16 => MediaType.NEC_525_DS,
|
||||
_ => _imageInfo.MediaType
|
||||
};
|
||||
}
|
||||
else if(trkCounter == 154 &&
|
||||
spt == 8 &&
|
||||
bps == IBMSectorSizeCode.Kilo)
|
||||
_imageInfo.MediaType = MediaType.NEC_525_HD;
|
||||
else if(bps == IBMSectorSizeCode.HalfKilo)
|
||||
{
|
||||
switch(hdr.track_table.Length)
|
||||
{
|
||||
case 40:
|
||||
{
|
||||
_imageInfo.MediaType = spt switch
|
||||
{
|
||||
8 => MediaType.DOS_525_SS_DD_8,
|
||||
9 => MediaType.DOS_525_SS_DD_9,
|
||||
_ => _imageInfo.MediaType
|
||||
};
|
||||
{
|
||||
8 => MediaType.DOS_525_SS_DD_8,
|
||||
9 => MediaType.DOS_525_SS_DD_9,
|
||||
_ => _imageInfo.MediaType
|
||||
};
|
||||
}
|
||||
|
||||
break;
|
||||
case 80:
|
||||
{
|
||||
_imageInfo.MediaType = spt switch
|
||||
{
|
||||
8 => MediaType.DOS_525_DS_DD_8,
|
||||
9 => MediaType.DOS_525_DS_DD_9,
|
||||
_ => _imageInfo.MediaType
|
||||
};
|
||||
{
|
||||
8 => MediaType.DOS_525_DS_DD_8,
|
||||
9 => MediaType.DOS_525_DS_DD_9,
|
||||
_ => _imageInfo.MediaType
|
||||
};
|
||||
}
|
||||
|
||||
break;
|
||||
case 160:
|
||||
{
|
||||
_imageInfo.MediaType = spt switch
|
||||
{
|
||||
15 => MediaType.NEC_35_HD_15,
|
||||
9 => MediaType.DOS_35_DS_DD_9,
|
||||
18 => MediaType.DOS_35_HD,
|
||||
36 => MediaType.DOS_35_ED,
|
||||
_ => _imageInfo.MediaType
|
||||
};
|
||||
{
|
||||
15 => MediaType.NEC_35_HD_15,
|
||||
9 => MediaType.DOS_35_DS_DD_9,
|
||||
18 => MediaType.DOS_35_HD,
|
||||
36 => MediaType.DOS_35_ED,
|
||||
_ => _imageInfo.MediaType
|
||||
};
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -235,6 +241,8 @@ public sealed partial class D88
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AaruConsole.DebugWriteLine(MODULE_NAME, Localization.MediaType_0, _imageInfo.MediaType);
|
||||
|
||||
@@ -361,11 +369,13 @@ public sealed partial class D88
|
||||
|
||||
var ms = new MemoryStream();
|
||||
|
||||
for(int i = 0; i < length; i++)
|
||||
for(var i = 0; i < length; i++)
|
||||
ms.Write(_sectorsData[(int)sectorAddress + i], 0, _sectorsData[(int)sectorAddress + i].Length);
|
||||
|
||||
buffer = ms.ToArray();
|
||||
|
||||
return ErrorNumber.NoError;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -37,6 +37,8 @@ namespace Aaru.DiscImages;
|
||||
|
||||
public sealed partial class D88
|
||||
{
|
||||
#region Nested type: Header
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
readonly struct Header
|
||||
{
|
||||
@@ -57,6 +59,10 @@ public sealed partial class D88
|
||||
public readonly int[] track_table;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Nested type: SectorHeader
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
readonly struct SectorHeader
|
||||
{
|
||||
@@ -82,4 +88,6 @@ public sealed partial class D88
|
||||
/// <summary>Size of data following this field このセクタ部のデータサイズ</summary>
|
||||
public readonly short size_of_data;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -36,6 +36,8 @@ namespace Aaru.DiscImages;
|
||||
|
||||
public sealed partial class D88
|
||||
{
|
||||
#region IMediaImage Members
|
||||
|
||||
/// <inheritdoc />
|
||||
public ErrorNumber ReadMediaTag(MediaTagType tag, out byte[] buffer)
|
||||
{
|
||||
@@ -75,4 +77,6 @@ public sealed partial class D88
|
||||
|
||||
return ErrorNumber.NotSupported;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
Reference in New Issue
Block a user