Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/nes-containers.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2020-11-29 14:45:30 +0300
committerAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2020-11-29 14:45:30 +0300
commit08cc02895c9b4c6ee73947ce1f5a4c3dedc9713b (patch)
tree9e2ccf317b2ca19ef0489bbf7fa43eb5b0b8e5e4 /FdsBlockFileData.cs
parent448bda7a1feac448d04eaac8ca2997d482eae249 (diff)
More FDS stuff
Diffstat (limited to 'FdsBlockFileData.cs')
-rw-r--r--FdsBlockFileData.cs53
1 files changed, 53 insertions, 0 deletions
diff --git a/FdsBlockFileData.cs b/FdsBlockFileData.cs
new file mode 100644
index 0000000..51345bd
--- /dev/null
+++ b/FdsBlockFileData.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace com.clusterrr.Famicom.Containers
+{
+ public class FdsBlockFileData : IFdsBlock
+ {
+ private byte blockType = 4;
+ /// <summary>
+ /// True if block type ID is valid
+ /// </summary>
+ public bool IsValid { get => blockType == 4; }
+
+ private byte[] data = new byte[0];
+ public IEnumerable<byte> Data
+ {
+ get => Array.AsReadOnly(data);
+ set => data = value.ToArray();
+ }
+
+ /// <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 static FdsBlockFileData FromBytes(byte[] rawData, int position = 0, int size = -1)
+ {
+ var retobj = new FdsBlockFileData();
+ retobj.blockType = rawData[position];
+ retobj.data = new byte[size < 0 ? rawData.Length - position - 1 : size - 1];
+ Array.Copy(rawData, position + 1, retobj.data, 0, retobj.data.Length);
+ return retobj;
+ }
+
+ public byte[] ToBytes()
+ {
+ var result = new List<byte>();
+ result.Add(blockType);
+ result.AddRange(Data);
+ return result.ToArray();
+ }
+ }
+}