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>2022-11-08 23:23:06 +0300
committerAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2022-11-08 23:23:06 +0300
commitf7375189b98902a385b97aa0f8dec8d62dd780c4 (patch)
tree1e9e1bedbaf6fbefdbf298ea6222fec2d07edbc6 /NesFile.cs
parentae501934ecec1c0323e2b06ca0a020342b4b94b5 (diff)
RefactoringHEADv1.1.1master
Diffstat (limited to 'NesFile.cs')
-rw-r--r--NesFile.cs14
1 files changed, 10 insertions, 4 deletions
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);