mirror of
https://github.com/aaru-dps/Aaru.Decoders.git
synced 2025-12-16 19:24:32 +00:00
Add Lisa tags converters and marshallers.
This commit is contained in:
211
LisaTag.cs
211
LisaTag.cs
@@ -88,6 +88,79 @@ namespace DiscImageChef.Decoders
|
||||
public bool IsFirst;
|
||||
/// <summary>On-memory value for easy last block search.</summary>
|
||||
public bool IsLast;
|
||||
|
||||
/// <summary>
|
||||
/// Converts this tag to Priam DataTower format
|
||||
/// </summary>
|
||||
public PriamTag ToPriam()
|
||||
{
|
||||
return new PriamTag
|
||||
{
|
||||
AbsPage = AbsPage,
|
||||
Checksum = Checksum,
|
||||
FileId = FileId,
|
||||
IsFirst = IsFirst,
|
||||
IsLast = IsLast,
|
||||
Kind = Kind,
|
||||
NextBlock = IsLast ? 0xFFFFFF : NextBlock & 0xFFFFFF,
|
||||
PrevBlock = IsFirst ? 0xFFFFFF : PrevBlock & 0xFFFFFF,
|
||||
RelPage = RelPage,
|
||||
UsedBytes = UsedBytes,
|
||||
ValidChk = ValidChk,
|
||||
Version = Version,
|
||||
Volume = Volume
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts this tag to Sony format
|
||||
/// </summary>
|
||||
public SonyTag Sony()
|
||||
{
|
||||
return new SonyTag
|
||||
{
|
||||
FileId = FileId,
|
||||
IsFirst = IsFirst,
|
||||
IsLast = IsLast,
|
||||
Kind = Kind,
|
||||
NextBlock = (ushort)NextBlock,
|
||||
PrevBlock = (ushort)PrevBlock,
|
||||
RelPage = RelPage,
|
||||
Version = Version,
|
||||
Volume = Volume
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a byte array representation of this tag
|
||||
/// </summary>
|
||||
public byte[] GetBytes()
|
||||
{
|
||||
byte[] tagBytes = new byte[20];
|
||||
|
||||
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
|
||||
|
||||
byte[] tmp = BigEndianBitConverter.GetBytes(Version);
|
||||
Array.Copy(tmp, 0, tagBytes, 0, 2);
|
||||
tagBytes[2] = (byte)(Kind << 6);
|
||||
tagBytes[3] = Volume;
|
||||
tmp = BigEndianBitConverter.GetBytes(FileId);
|
||||
Array.Copy(tmp, 0, tagBytes, 4, 2);
|
||||
tmp = BigEndianBitConverter.GetBytes((ushort)(UsedBytes & 0x7FFF));
|
||||
Array.Copy(tmp, 0, tagBytes, 6, 2);
|
||||
if(ValidChk) tagBytes[6] += 0x80;
|
||||
tmp = BigEndianBitConverter.GetBytes(AbsPage);
|
||||
Array.Copy(tmp, 1, tagBytes, 8, 3);
|
||||
tagBytes[11] = Checksum;
|
||||
tmp = BigEndianBitConverter.GetBytes(RelPage);
|
||||
Array.Copy(tmp, 0, tagBytes, 12, 2);
|
||||
tmp = BigEndianBitConverter.GetBytes(IsLast ? 0xFFFFFF : NextBlock);
|
||||
Array.Copy(tmp, 1, tagBytes, 14, 3);
|
||||
tmp = BigEndianBitConverter.GetBytes(IsFirst ? 0xFFFFFF : PrevBlock);
|
||||
Array.Copy(tmp, 1, tagBytes, 17, 3);
|
||||
|
||||
return tagBytes;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -142,6 +215,81 @@ namespace DiscImageChef.Decoders
|
||||
public bool IsFirst;
|
||||
/// <summary>On-memory value for easy last block search.</summary>
|
||||
public bool IsLast;
|
||||
|
||||
/// <summary>
|
||||
/// Converts this tag to Apple Profile format
|
||||
/// </summary>
|
||||
public ProfileTag Profile()
|
||||
{
|
||||
return new ProfileTag
|
||||
{
|
||||
AbsPage = AbsPage,
|
||||
Checksum = Checksum,
|
||||
FileId = FileId,
|
||||
IsFirst = IsFirst,
|
||||
IsLast = IsLast,
|
||||
Kind = Kind,
|
||||
NextBlock = IsLast ? 0xFFFFFF : NextBlock & 0xFFFFFF,
|
||||
PrevBlock = IsFirst ? 0xFFFFFF : PrevBlock & 0xFFFFFF,
|
||||
RelPage = RelPage,
|
||||
UsedBytes = UsedBytes,
|
||||
ValidChk = ValidChk,
|
||||
Version = Version,
|
||||
Volume = Volume
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts this tag to Sony format
|
||||
/// </summary>
|
||||
public SonyTag ToSony()
|
||||
{
|
||||
return new SonyTag
|
||||
{
|
||||
FileId = FileId,
|
||||
IsFirst = IsFirst,
|
||||
IsLast = IsLast,
|
||||
Kind = Kind,
|
||||
NextBlock = (ushort)(IsLast ? 0x7FF : NextBlock & 0x7FF),
|
||||
PrevBlock = (ushort)(IsFirst ? 0x7FF : PrevBlock & 0x7FF),
|
||||
RelPage = RelPage,
|
||||
Version = Version,
|
||||
Volume = Volume
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a byte array representation of this tag
|
||||
/// </summary>
|
||||
public byte[] GetBytes()
|
||||
{
|
||||
byte[] tagBytes = new byte[24];
|
||||
|
||||
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
|
||||
|
||||
byte[] tmp = BigEndianBitConverter.GetBytes(Version);
|
||||
Array.Copy(tmp, 0, tagBytes, 0, 2);
|
||||
tagBytes[2] = (byte)(Kind << 6);
|
||||
tagBytes[3] = Volume;
|
||||
tmp = BigEndianBitConverter.GetBytes(FileId);
|
||||
Array.Copy(tmp, 0, tagBytes, 4, 2);
|
||||
tmp = BigEndianBitConverter.GetBytes((ushort)(UsedBytes & 0x7FFF));
|
||||
Array.Copy(tmp, 0, tagBytes, 6, 2);
|
||||
if(ValidChk) tagBytes[6] += 0x80;
|
||||
tmp = BigEndianBitConverter.GetBytes(AbsPage);
|
||||
Array.Copy(tmp, 1, tagBytes, 8, 3);
|
||||
tagBytes[11] = Checksum;
|
||||
tmp = BigEndianBitConverter.GetBytes(RelPage);
|
||||
Array.Copy(tmp, 0, tagBytes, 12, 2);
|
||||
tmp = BigEndianBitConverter.GetBytes(IsLast ? 0xFFFFFF : NextBlock);
|
||||
Array.Copy(tmp, 1, tagBytes, 14, 3);
|
||||
tmp = BigEndianBitConverter.GetBytes(IsFirst ? 0xFFFFFF : PrevBlock);
|
||||
Array.Copy(tmp, 1, tagBytes, 17, 3);
|
||||
tmp = BigEndianBitConverter.GetBytes(DiskSize);
|
||||
Array.Copy(tmp, 0, tagBytes, 20, 4);
|
||||
|
||||
return tagBytes;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -176,6 +324,69 @@ namespace DiscImageChef.Decoders
|
||||
public bool IsFirst;
|
||||
/// <summary>On-memory value for easy last block search.</summary>
|
||||
public bool IsLast;
|
||||
|
||||
/// <summary>
|
||||
/// Converts this tag to Apple Profile format
|
||||
/// </summary>
|
||||
public ProfileTag ToProfile()
|
||||
{
|
||||
return new ProfileTag
|
||||
{
|
||||
FileId = FileId,
|
||||
IsFirst = IsFirst,
|
||||
IsLast = IsLast,
|
||||
Kind = Kind,
|
||||
NextBlock = (uint)(IsLast ? 0xFFFFFF : NextBlock & 0xFFFFFF),
|
||||
PrevBlock = (uint)(IsFirst ? 0xFFFFFF : PrevBlock & 0xFFFFFF),
|
||||
RelPage = RelPage,
|
||||
Version = Version,
|
||||
Volume = Volume
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts this tag to Priam DataTower format
|
||||
/// </summary>
|
||||
public PriamTag ToPriam()
|
||||
{
|
||||
return new PriamTag
|
||||
{
|
||||
FileId = FileId,
|
||||
IsFirst = IsFirst,
|
||||
IsLast = IsLast,
|
||||
Kind = Kind,
|
||||
NextBlock = (uint)(IsLast ? 0xFFFFFF : NextBlock & 0xFFFFFF),
|
||||
PrevBlock = (uint)(IsFirst ? 0xFFFFFF : PrevBlock & 0xFFFFFF),
|
||||
RelPage = RelPage,
|
||||
Version = Version,
|
||||
Volume = Volume
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a byte array representation of this tag
|
||||
/// </summary>
|
||||
public byte[] GetBytes()
|
||||
{
|
||||
byte[] tagBytes = new byte[12];
|
||||
|
||||
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
|
||||
|
||||
byte[] tmp = BigEndianBitConverter.GetBytes(Version);
|
||||
Array.Copy(tmp, 0, tagBytes, 0, 2);
|
||||
tagBytes[2] = (byte)(Kind << 6);
|
||||
tagBytes[3] = Volume;
|
||||
tmp = BigEndianBitConverter.GetBytes(FileId);
|
||||
Array.Copy(tmp, 0, tagBytes, 4, 2);
|
||||
tmp = BigEndianBitConverter.GetBytes(RelPage);
|
||||
Array.Copy(tmp, 0, tagBytes, 6, 2);
|
||||
tmp = BigEndianBitConverter.GetBytes(IsLast ? 0x7FF : NextBlock);
|
||||
Array.Copy(tmp, 1, tagBytes, 8, 2);
|
||||
tmp = BigEndianBitConverter.GetBytes(IsFirst ? 0x7FF : PrevBlock);
|
||||
Array.Copy(tmp, 1, tagBytes, 10, 2);
|
||||
|
||||
return tagBytes;
|
||||
}
|
||||
}
|
||||
|
||||
public static SonyTag? DecodeSonyTag(byte[] tag)
|
||||
|
||||
Reference in New Issue
Block a user