diff options
author | Alexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com> | 2020-09-16 17:51:22 +0300 |
---|---|---|
committer | Alexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com> | 2020-09-16 17:51:22 +0300 |
commit | 4dad10cc03d5c78ce20a4d79a0f37bc95339649a (patch) | |
tree | 7cdb59fb38d5231ef6e5194f5027a3d12eea7c3a | |
parent | dcb8e5bce763765f2955a44d1fabf75971d24a54 (diff) |
Minor changes to UNIF
-rw-r--r-- | NesContainers.csproj | 1 | ||||
-rw-r--r-- | UnifFile.cs | 15 |
2 files changed, 14 insertions, 2 deletions
diff --git a/NesContainers.csproj b/NesContainers.csproj index 8add0a5..d2c9da2 100644 --- a/NesContainers.csproj +++ b/NesContainers.csproj @@ -42,6 +42,7 @@ <Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
+ <Compile Include="Crc32Calculator.cs" />
<Compile Include="NesFile.cs" />
<Compile Include="NesHeaderFixer.cs" />
<Compile Include="UnifFile.cs" />
diff --git a/UnifFile.cs b/UnifFile.cs index 98d52e0..8ca040e 100644 --- a/UnifFile.cs +++ b/UnifFile.cs @@ -18,6 +18,7 @@ namespace com.clusterrr.Famicom.Containers public UnifFile()
{
+ DumpDate = DateTime.Now;
}
/// <summary>
@@ -290,9 +291,9 @@ namespace com.clusterrr.Famicom.Containers }
/// <summary>
- /// Calculate CRC32 for PRG and CHR fields and fill CRC32 fields
+ /// Calculate CRC32 for PRG and CHR fields and store it into PCKx and CCKx fields
/// </summary>
- public void CalculateCRCs()
+ public void CalculateAndStoreCRCs()
{
foreach (var key in Fields.Keys.Where(k => k.StartsWith("PRG")))
{
@@ -318,6 +319,16 @@ namespace com.clusterrr.Famicom.Containers }
}
+ /// <summary>
+ /// Calculate overall CRC32
+ /// </summary>
+ /// <returns></returns>
+ public uint CalculateCRC32()
+ => Crc32Calculator.CalculateCRC32(
+ Enumerable.Concat(Fields.Where(k => k.Key.StartsWith("PRG")).OrderBy(k => k.Key).SelectMany(i => i.Value),
+ Fields.Where(k => k.Key.StartsWith("CHR")).OrderBy(k => k.Key).SelectMany(i => i.Value)).ToArray()
+ );
+
[Flags]
public enum Controller
{
|