Separate Lisa tag decoding from Lisa filesystem and added

Priam tags.
This commit is contained in:
2016-08-21 19:23:58 +01:00
parent 985dc6333e
commit 8a50d402c5
12 changed files with 406 additions and 91 deletions

View File

@@ -34,6 +34,7 @@
using System;
using System.Collections.Generic;
using System.Text;
using DiscImageChef.Decoders;
namespace DiscImageChef.Filesystems.LisaFS
{
@@ -214,47 +215,15 @@ namespace DiscImageChef.Filesystems.LisaFS
/// <returns>Error number.</returns>
/// <param name="tag">Sector tag.</param>
/// <param name="decoded">Decoded sector tag.</param>
Errno DecodeTag(byte[] tag, out Tag decoded)
Errno DecodeTag(byte[] tag, out LisaTag.PriamTag decoded)
{
decoded = new Tag();
decoded = new LisaTag.PriamTag();
LisaTag.PriamTag? pmTag = LisaTag.DecodeTag(tag);
if(tag.Length == 12)
{
decoded.version = BigEndianBitConverter.ToUInt16(tag, 0x00);
decoded.unknown = BigEndianBitConverter.ToUInt16(tag, 0x02);
decoded.fileID = BigEndianBitConverter.ToInt16(tag, 0x04);
decoded.relBlock = BigEndianBitConverter.ToUInt16(tag, 0x06);
decoded.nextBlock = BigEndianBitConverter.ToUInt16(tag, 0x08);
decoded.nextBlock &= 0x7FF;
decoded.prevBlock = BigEndianBitConverter.ToUInt16(tag, 0x0A);
decoded.prevBlock &= 0x7FF;
if(decoded.nextBlock == 0x7FF)
decoded.isLast = true;
if(decoded.prevBlock == 0x7FF)
decoded.isFirst = true;
}
else
{
decoded.version = BigEndianBitConverter.ToUInt16(tag, 0x00);
decoded.unknown = BigEndianBitConverter.ToUInt16(tag, 0x02);
decoded.fileID = BigEndianBitConverter.ToInt16(tag, 0x04);
decoded.usedBytes = BigEndianBitConverter.ToUInt16(tag, 0x06);
decoded.absoluteBlock = BigEndianBitConverter.ToUInt32(tag, 0x07);
decoded.absoluteBlock &= 0xFFFFFF;
decoded.checksum = tag[0x0B];
decoded.relBlock = BigEndianBitConverter.ToUInt16(tag, 0x0C);
decoded.nextBlock = BigEndianBitConverter.ToUInt32(tag, 0x0D);
decoded.nextBlock &= 0xFFFFFF;
decoded.prevBlock = BigEndianBitConverter.ToUInt32(tag, 0x10);
decoded.prevBlock &= 0xFFFFFF;
if(decoded.nextBlock == 0xFFFFFF)
decoded.isLast = true;
if(decoded.prevBlock == 0xFFFFFF)
decoded.isFirst = true;
}
if(!pmTag.HasValue)
return Errno.InvalidArgument;
decoded = pmTag.Value;
return Errno.NoError;
}
}