diff options
author | Alexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com> | 2021-04-23 03:57:30 +0300 |
---|---|---|
committer | Alexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com> | 2021-04-23 03:57:30 +0300 |
commit | 526245c8e1298eb0a5cfee0e929f054cf8033158 (patch) | |
tree | 2e8b6398f9b21e7576b0b20566f2caae3b99dd40 | |
parent | 3eeeea564cd5446d3692c16af8c0d19ec674d127 (diff) |
FDS blocks are IEquatable now
-rw-r--r-- | FdsBlockDiskInfo.cs | 11 | ||||
-rw-r--r-- | FdsBlockFileAmount.cs | 7 | ||||
-rw-r--r-- | FdsBlockFileData.cs | 7 | ||||
-rw-r--r-- | FdsBlockFileHeader.cs | 7 |
4 files changed, 26 insertions, 6 deletions
diff --git a/FdsBlockDiskInfo.cs b/FdsBlockDiskInfo.cs index 3bdb0e8..38805d8 100644 --- a/FdsBlockDiskInfo.cs +++ b/FdsBlockDiskInfo.cs @@ -9,7 +9,7 @@ using System.Threading.Tasks; namespace com.clusterrr.Famicom.Containers
{
[StructLayout(LayoutKind.Sequential, Size = 58, Pack = 1, CharSet = CharSet.Ansi)]
- public class FdsBlockDiskInfo : IFdsBlock
+ public class FdsBlockDiskInfo : IFdsBlock, IEquatable<FdsBlockDiskInfo>
{
public enum DiskSides
{
@@ -80,11 +80,11 @@ namespace com.clusterrr.Famicom.Containers public bool IsValid { get => blockType == 1; }
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 14)]
- char[] diskVerification = "*NINTENDO-HVC*".ToCharArray();
+ byte[] diskVerification = Encoding.ASCII.GetBytes("*NINTENDO-HVC*");
/// <summary>
/// Literal ASCII string: *NINTENDO-HVC*
/// </summary>
- public string DiskVerification { get => new string(diskVerification).Trim(new char[] { '\0', ' ' }); /*set => diskVerification = value.PadRight(14).ToCharArray(0, value.Length > 14 ? 14 : value.Length);*/ }
+ public string DiskVerification => Encoding.ASCII.GetString(diskVerification).Trim(new char[] { '\0', ' ' }); /*set => diskVerification = value.PadRight(14).ToCharArray(0, value.Length > 14 ? 14 : value.Length);*/
[MarshalAs(UnmanagedType.U1)]
private byte manufacturerCode;
@@ -349,5 +349,10 @@ namespace com.clusterrr.Famicom.Containers }
public override string ToString() => GameName;
+
+ public bool Equals(FdsBlockDiskInfo other)
+ {
+ return Enumerable.SequenceEqual(this.ToBytes(), other.ToBytes());
+ }
}
}
diff --git a/FdsBlockFileAmount.cs b/FdsBlockFileAmount.cs index ff73bef..c2dd0dd 100644 --- a/FdsBlockFileAmount.cs +++ b/FdsBlockFileAmount.cs @@ -8,7 +8,7 @@ using System.Threading.Tasks; namespace com.clusterrr.Famicom.Containers
{
- public class FdsBlockFileAmount : IFdsBlock
+ public class FdsBlockFileAmount : IFdsBlock, IEquatable<FdsBlockFileAmount>
{
private byte blockType = 2;
/// <summary>
@@ -42,5 +42,10 @@ namespace com.clusterrr.Famicom.Containers public byte[] ToBytes() => new byte[] { blockType, fileAmount };
public override string ToString() => $"{FileAmount}";
+
+ public bool Equals(FdsBlockFileAmount other)
+ {
+ return Enumerable.SequenceEqual(this.ToBytes(), other.ToBytes());
+ }
}
}
diff --git a/FdsBlockFileData.cs b/FdsBlockFileData.cs index cf4f158..452f6ed 100644 --- a/FdsBlockFileData.cs +++ b/FdsBlockFileData.cs @@ -8,7 +8,7 @@ using System.Threading.Tasks; namespace com.clusterrr.Famicom.Containers
{
- public class FdsBlockFileData : IFdsBlock
+ public class FdsBlockFileData : IFdsBlock, IEquatable<FdsBlockFileData>
{
private byte blockType = 4;
/// <summary>
@@ -53,5 +53,10 @@ namespace com.clusterrr.Famicom.Containers }
public override string ToString() => $"{data.Length} bytes";
+
+ public bool Equals(FdsBlockFileData other)
+ {
+ return Enumerable.SequenceEqual(this.ToBytes(), other.ToBytes());
+ }
}
}
diff --git a/FdsBlockFileHeader.cs b/FdsBlockFileHeader.cs index dc11ed4..e005642 100644 --- a/FdsBlockFileHeader.cs +++ b/FdsBlockFileHeader.cs @@ -9,7 +9,7 @@ using System.Threading.Tasks; namespace com.clusterrr.Famicom.Containers
{
[StructLayout(LayoutKind.Sequential, Size = 18, Pack = 1, CharSet = CharSet.Ansi)]
- public class FdsBlockFileHeader : IFdsBlock
+ public class FdsBlockFileHeader : IFdsBlock, IEquatable<FdsBlockFileHeader>
{
public enum Kind
{
@@ -103,5 +103,10 @@ namespace com.clusterrr.Famicom.Containers }
public override string ToString() => $"{FileName} ({FileKind})";
+
+ public bool Equals(FdsBlockFileHeader other)
+ {
+ return Enumerable.SequenceEqual(this.ToBytes(), other.ToBytes());
+ }
}
}
|