blob: 21e821161fd7c159cdbb35a9777e085ad529f532 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
using System;
using System.Linq;
namespace com.clusterrr.Famicom.Containers
{
public class FdsBlockFileAmount : IFdsBlock, IEquatable<FdsBlockFileAmount>
{
private byte blockType = 2;
/// <summary>
/// True if block type ID is valid
/// </summary>
public bool IsValid { get => blockType == 2; }
private byte fileAmount;
public byte FileAmount { get => fileAmount; set => fileAmount = value; }
/// <summary>
/// Set by dumper. True when checksum is ok
/// </summary>
public bool CrcOk { get; set; } = true;
/// <summary>
/// Set by dumper. True when "end of head" flag was meet during dumping
/// </summary>
public bool EndOfHeadMeet { get; set; } = false;
public uint Length => 2;
public static FdsBlockFileAmount FromBytes(byte[] rawData, int position = 0)
{
var retobj = new FdsBlockFileAmount();
retobj.blockType = rawData[position];
retobj.fileAmount = rawData[position + 1];
return retobj;
}
public byte[] ToBytes() => new byte[] { blockType, fileAmount };
public override string ToString() => $"{FileAmount}";
public bool Equals(FdsBlockFileAmount other)
{
return Enumerable.SequenceEqual(this.ToBytes(), other.ToBytes());
}
}
}
|