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:
-rw-r--r--NesContainers.csproj6
-rw-r--r--NesFile.cs14
-rw-r--r--UnifFile.cs6
3 files changed, 16 insertions, 10 deletions
diff --git a/NesContainers.csproj b/NesContainers.csproj
index b8f22f1..09beae6 100644
--- a/NesContainers.csproj
+++ b/NesContainers.csproj
@@ -16,12 +16,12 @@
<PackageProjectUrl>https://github.com/ClusterM/nes-containers</PackageProjectUrl>
<Copyright>Alexey 'Cluster' Avdyukhin, 2022</Copyright>
<Description>A simple .NET Standard 2.0 library for reading and modifying NES/Famicom ROM containers: .nes (iNES, NES 2.0), .unf (UNIF), and .fds (Famicom Disk System images).</Description>
- <Version>1.1.0</Version>
+ <Version>1.1.1</Version>
<RepositoryUrl>https://github.com/ClusterM/nes-containers</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>nes,famicom,famicom disk system</PackageTags>
- <AssemblyVersion>1.1.0</AssemblyVersion>
- <FileVersion>1.1.0</FileVersion>
+ <AssemblyVersion>1.1.1</AssemblyVersion>
+ <FileVersion>1.1.1</FileVersion>
<Authors>Alexey 'Cluster' Avdyukhin</Authors>
</PropertyGroup>
diff --git a/NesFile.cs b/NesFile.cs
index 1c7bee0..8063d5b 100644
--- a/NesFile.cs
+++ b/NesFile.cs
@@ -933,11 +933,14 @@ namespace com.clusterrr.Famicom.Containers
{
int prgSizeUpPow2 = 1;
int chrSizeUpPow2 = 1;
- while (prgSizeUpPow2 < PRG.Length) prgSizeUpPow2 *= 2;
+ if (PRG.Length == 0)
+ prgSizeUpPow2 = 0; // Is it possible?
+ else
+ while (prgSizeUpPow2 < PRG.Length) prgSizeUpPow2 <<= 1;
if (CHR.Length == 0)
chrSizeUpPow2 = 0;
else
- while (chrSizeUpPow2 < CHR.Length) chrSizeUpPow2 *= 2;
+ while (chrSizeUpPow2 < CHR.Length) chrSizeUpPow2 <<= 1;
using (var md5 = MD5.Create())
{
md5.TransformBlock(prg, 0, prg.Length, null, 0);
@@ -957,11 +960,14 @@ namespace com.clusterrr.Famicom.Containers
{
int prgSizeUpPow2 = 1;
int chrSizeUpPow2 = 1;
- while (prgSizeUpPow2 < PRG.Length) prgSizeUpPow2 *= 2;
+ if (PRG.Length == 0)
+ prgSizeUpPow2 = 0; // Is it possible?
+ else
+ while (prgSizeUpPow2 < PRG.Length) prgSizeUpPow2 <<= 1;
if (CHR.Length == 0)
chrSizeUpPow2 = 0;
else
- while (chrSizeUpPow2 < CHR.Length) chrSizeUpPow2 *= 2;
+ while (chrSizeUpPow2 < CHR.Length) chrSizeUpPow2 <<= 1;
using (var crc32 = new Crc32())
{
crc32.TransformBlock(prg, 0, prg.Length, null, 0);
diff --git a/UnifFile.cs b/UnifFile.cs
index 2921b71..f2ad1e6 100644
--- a/UnifFile.cs
+++ b/UnifFile.cs
@@ -638,7 +638,7 @@ namespace com.clusterrr.Famicom.Containers
if (v.Length > 0)
{
sizeUpPow2 = 1;
- while (sizeUpPow2 < v.Length) sizeUpPow2 *= 2;
+ while (sizeUpPow2 < v.Length) sizeUpPow2 <<= 1;
}
md5.TransformBlock(v, 0, v.Length, null, 0);
md5.TransformBlock(Enumerable.Repeat<byte>(byte.MaxValue, sizeUpPow2 - v.Length).ToArray(), 0, sizeUpPow2 - v.Length, null, 0);
@@ -662,10 +662,10 @@ namespace com.clusterrr.Famicom.Containers
if (v.Length > 0)
{
sizeUpPow2 = 1;
- while (sizeUpPow2 < v.Length) sizeUpPow2 *= 2;
+ while (sizeUpPow2 < v.Length) sizeUpPow2 <<= 1;
}
crc32.TransformBlock(v, 0, v.Length, null, 0);
- crc32.TransformBlock(Enumerable.Repeat<byte>(byte.MaxValue, sizeUpPow2 - v.Length).ToArray(), 0, sizeUpPow2 - v.Length, null, 0);
+ crc32.TransformBlock(Enumerable.Repeat(byte.MaxValue, sizeUpPow2 - v.Length).ToArray(), 0, sizeUpPow2 - v.Length, null, 0);
}
crc32.TransformFinalBlock(new byte[0], 0, 0);
return BitConverter.ToUInt32(crc32.Hash.Reverse().ToArray(), 0);