Remove DiscImageChef.CommonTypes dependence on DiscImageChef.Decoders.

This commit is contained in:
2020-01-11 20:55:54 +00:00
parent 785638f5f6
commit 1856c6ddb4
12 changed files with 892 additions and 2685 deletions

View File

@@ -34,6 +34,7 @@ using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using DiscImageChef.CommonTypes.Structs.Devices.SCSI;
namespace DiscImageChef.Decoders.SCSI
{
@@ -67,7 +68,7 @@ namespace DiscImageChef.Decoders.SCSI
for(int i = 0; i < header.BlockDescriptors.Length; i++)
{
if(12 + i * 16 + 8 >= modeResponse.Length)
if(12 + (i * 16) + 8 >= modeResponse.Length)
break;
header.BlockDescriptors[i] = new BlockDescriptor
@@ -76,19 +77,19 @@ namespace DiscImageChef.Decoders.SCSI
};
byte[] temp = new byte[8];
temp[0] = modeResponse[7 + i * 16 + 8];
temp[1] = modeResponse[6 + i * 16 + 8];
temp[2] = modeResponse[5 + i * 16 + 8];
temp[3] = modeResponse[4 + i * 16 + 8];
temp[4] = modeResponse[3 + i * 16 + 8];
temp[5] = modeResponse[2 + i * 16 + 8];
temp[6] = modeResponse[1 + i * 16 + 8];
temp[7] = modeResponse[0 + i * 16 + 8];
temp[0] = modeResponse[7 + (i * 16) + 8];
temp[1] = modeResponse[6 + (i * 16) + 8];
temp[2] = modeResponse[5 + (i * 16) + 8];
temp[3] = modeResponse[4 + (i * 16) + 8];
temp[4] = modeResponse[3 + (i * 16) + 8];
temp[5] = modeResponse[2 + (i * 16) + 8];
temp[6] = modeResponse[1 + (i * 16) + 8];
temp[7] = modeResponse[0 + (i * 16) + 8];
header.BlockDescriptors[i].Blocks = BitConverter.ToUInt64(temp, 0);
header.BlockDescriptors[i].BlockLength += (uint)(modeResponse[15 + i * 16 + 8] << 24);
header.BlockDescriptors[i].BlockLength += (uint)(modeResponse[14 + i * 16 + 8] << 16);
header.BlockDescriptors[i].BlockLength += (uint)(modeResponse[13 + i * 16 + 8] << 8);
header.BlockDescriptors[i].BlockLength += modeResponse[12 + i * 16 + 8];
header.BlockDescriptors[i].BlockLength += (uint)(modeResponse[15 + (i * 16) + 8] << 24);
header.BlockDescriptors[i].BlockLength += (uint)(modeResponse[14 + (i * 16) + 8] << 16);
header.BlockDescriptors[i].BlockLength += (uint)(modeResponse[13 + (i * 16) + 8] << 8);
header.BlockDescriptors[i].BlockLength += modeResponse[12 + (i * 16) + 8];
}
}
else
@@ -97,25 +98,25 @@ namespace DiscImageChef.Decoders.SCSI
for(int i = 0; i < header.BlockDescriptors.Length; i++)
{
if(7 + i * 8 + 8 >= modeResponse.Length)
if(7 + (i * 8) + 8 >= modeResponse.Length)
break;
header.BlockDescriptors[i] = new BlockDescriptor();
if(deviceType != PeripheralDeviceTypes.DirectAccess)
header.BlockDescriptors[i].Density = (DensityType)modeResponse[0 + i * 8 + 8];
header.BlockDescriptors[i].Density = (DensityType)modeResponse[0 + (i * 8) + 8];
else
{
header.BlockDescriptors[i].Density = DensityType.Default;
header.BlockDescriptors[i].Blocks += (ulong)(modeResponse[0 + i * 8 + 8] << 24);
header.BlockDescriptors[i].Blocks += (ulong)(modeResponse[0 + (i * 8) + 8] << 24);
}
header.BlockDescriptors[i].Blocks += (ulong)(modeResponse[1 + i * 8 + 8] << 16);
header.BlockDescriptors[i].Blocks += (ulong)(modeResponse[2 + i * 8 + 8] << 8);
header.BlockDescriptors[i].Blocks += modeResponse[3 + i * 8 + 8];
header.BlockDescriptors[i].BlockLength += (uint)(modeResponse[5 + i * 8 + 8] << 16);
header.BlockDescriptors[i].BlockLength += (uint)(modeResponse[6 + i * 8 + 8] << 8);
header.BlockDescriptors[i].BlockLength += modeResponse[7 + i * 8 + 8];
header.BlockDescriptors[i].Blocks += (ulong)(modeResponse[1 + (i * 8) + 8] << 16);
header.BlockDescriptors[i].Blocks += (ulong)(modeResponse[2 + (i * 8) + 8] << 8);
header.BlockDescriptors[i].Blocks += modeResponse[3 + (i * 8) + 8];
header.BlockDescriptors[i].BlockLength += (uint)(modeResponse[5 + (i * 8) + 8] << 16);
header.BlockDescriptors[i].BlockLength += (uint)(modeResponse[6 + (i * 8) + 8] << 8);
header.BlockDescriptors[i].BlockLength += modeResponse[7 + (i * 8) + 8];
}
}
@@ -171,9 +172,9 @@ namespace DiscImageChef.Decoders.SCSI
blkDrLength = decoded.Header.BlockDescriptors.Length;
if(longlba)
offset = 8 + blkDrLength * 16;
offset = 8 + (blkDrLength * 16);
else
offset = 8 + blkDrLength * 8;
offset = 8 + (blkDrLength * 8);
int length = modeResponse[0] << 8;
length += modeResponse[1];
@@ -240,8 +241,8 @@ namespace DiscImageChef.Decoders.SCSI
byte[] hdr;
if(header.BlockDescriptors != null)
hdr = longLBA ? new byte[8 + header.BlockDescriptors.Length * 16]
: new byte[8 + header.BlockDescriptors.Length * 8];
hdr = longLBA ? new byte[8 + (header.BlockDescriptors.Length * 16)]
: new byte[8 + (header.BlockDescriptors.Length * 8)];
else
hdr = new byte[8];
@@ -293,33 +294,33 @@ namespace DiscImageChef.Decoders.SCSI
for(int i = 0; i < header.BlockDescriptors.Length; i++)
{
byte[] temp = BitConverter.GetBytes(header.BlockDescriptors[i].Blocks);
hdr[7 + i * 16 + 8] = temp[0];
hdr[6 + i * 16 + 8] = temp[1];
hdr[5 + i * 16 + 8] = temp[2];
hdr[4 + i * 16 + 8] = temp[3];
hdr[3 + i * 16 + 8] = temp[4];
hdr[2 + i * 16 + 8] = temp[5];
hdr[1 + i * 16 + 8] = temp[6];
hdr[0 + i * 16 + 8] = temp[7];
hdr[12 + i * 16 + 8] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF000000) >> 24);
hdr[13 + i * 16 + 8] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF0000) >> 16);
hdr[14 + i * 16 + 8] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF00) >> 8);
hdr[15 + i * 16 + 8] = (byte)(header.BlockDescriptors[i].BlockLength & 0xFF);
hdr[7 + (i * 16) + 8] = temp[0];
hdr[6 + (i * 16) + 8] = temp[1];
hdr[5 + (i * 16) + 8] = temp[2];
hdr[4 + (i * 16) + 8] = temp[3];
hdr[3 + (i * 16) + 8] = temp[4];
hdr[2 + (i * 16) + 8] = temp[5];
hdr[1 + (i * 16) + 8] = temp[6];
hdr[0 + (i * 16) + 8] = temp[7];
hdr[12 + (i * 16) + 8] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF000000) >> 24);
hdr[13 + (i * 16) + 8] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF0000) >> 16);
hdr[14 + (i * 16) + 8] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF00) >> 8);
hdr[15 + (i * 16) + 8] = (byte)(header.BlockDescriptors[i].BlockLength & 0xFF);
}
else
for(int i = 0; i < header.BlockDescriptors.Length; i++)
{
if(deviceType != PeripheralDeviceTypes.DirectAccess)
hdr[0 + i * 8 + 8] = (byte)header.BlockDescriptors[i].Density;
hdr[0 + (i * 8) + 8] = (byte)header.BlockDescriptors[i].Density;
else
hdr[0 + i * 8 + 8] = (byte)((header.BlockDescriptors[i].Blocks & 0xFF000000) >> 24);
hdr[0 + (i * 8) + 8] = (byte)((header.BlockDescriptors[i].Blocks & 0xFF000000) >> 24);
hdr[1 + i * 8 + 8] = (byte)((header.BlockDescriptors[i].Blocks & 0xFF0000) >> 16);
hdr[2 + i * 8 + 8] = (byte)((header.BlockDescriptors[i].Blocks & 0xFF00) >> 8);
hdr[3 + i * 8 + 8] = (byte)(header.BlockDescriptors[i].Blocks & 0xFF);
hdr[5 + i * 8 + 8] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF0000) >> 16);
hdr[6 + i * 8 + 8] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF00) >> 8);
hdr[7 + i * 8 + 8] = (byte)(header.BlockDescriptors[i].BlockLength & 0xFF);
hdr[1 + (i * 8) + 8] = (byte)((header.BlockDescriptors[i].Blocks & 0xFF0000) >> 16);
hdr[2 + (i * 8) + 8] = (byte)((header.BlockDescriptors[i].Blocks & 0xFF00) >> 8);
hdr[3 + (i * 8) + 8] = (byte)(header.BlockDescriptors[i].Blocks & 0xFF);
hdr[5 + (i * 8) + 8] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF0000) >> 16);
hdr[6 + (i * 8) + 8] = (byte)((header.BlockDescriptors[i].BlockLength & 0xFF00) >> 8);
hdr[7 + (i * 8) + 8] = (byte)(header.BlockDescriptors[i].BlockLength & 0xFF);
}
return hdr;