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

github.com/ClusterM/NesTiler.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2022-10-23 21:52:02 +0300
committerAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2022-10-23 21:52:02 +0300
commite4e713a1c7e1caff26a74def77f75cb5b2d7dcda (patch)
treedee60aecdab3a674e80d82d312251105b81cc9cd
parent42c26873d1a427b66055912ca9bd77ee5896b3da (diff)
Using CRC32 for hash.
-rw-r--r--NesTiler/NesTiler.csproj1
-rw-r--r--NesTiler/Tile.cs15
-rw-r--r--Samples/nrom_split_lossy/Makefile7
-rw-r--r--Samples/nrom_split_lossy/preview1.pngbin0 -> 5647 bytes
-rw-r--r--Samples/nrom_split_lossy/preview2.pngbin0 -> 4613 bytes
5 files changed, 15 insertions, 8 deletions
diff --git a/NesTiler/NesTiler.csproj b/NesTiler/NesTiler.csproj
index aac25f8..b50eec4 100644
--- a/NesTiler/NesTiler.csproj
+++ b/NesTiler/NesTiler.csproj
@@ -20,6 +20,7 @@
<PackageReference Include="ColorMinePortable" Version="2.0.1" />
<PackageReference Include="SkiaSharp" Version="2.88.3" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="2.88.3" />
+ <PackageReference Include="System.IO.Hashing" Version="6.0.2" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
diff --git a/NesTiler/Tile.cs b/NesTiler/Tile.cs
index c3db539..e20d81d 100644
--- a/NesTiler/Tile.cs
+++ b/NesTiler/Tile.cs
@@ -1,6 +1,6 @@
using System;
+using System.IO.Hashing;
using System.Linq;
-using System.Security.AccessControl;
namespace com.clusterrr.Famicom.NesTiler
{
@@ -29,10 +29,10 @@ namespace com.clusterrr.Famicom.NesTiler
{
for (int x = 0; x < Width; x++)
{
- if ((Pixels[y * Width + x] & 1) != 0)
- data[pixel / 64 * 2 + y] |= (byte)(1 << bit);
- if ((Pixels[y * Width + x] & 2) != 0)
- data[pixel / 64 * 2 + y + 8] |= (byte)(1 << bit);
+ if ((Pixels[(y * Width) + x] & 1) != 0)
+ data[(pixel / 64 * 2) + y] |= (byte)(1 << bit);
+ if ((Pixels[(y * Width) + x] & 2) != 0)
+ data[(pixel / 64 * 2) + y + 8] |= (byte)(1 << bit);
pixel++;
bit = (byte)((byte)(bit - 1) % 8);
}
@@ -51,7 +51,10 @@ namespace com.clusterrr.Famicom.NesTiler
public override int GetHashCode()
{
if (hash != null) return hash.Value;
- hash = GetAsTileData().Sum(v => v);
+ var crc = new Crc32();
+ crc.Append(GetAsTileData());
+ var hashBytes = crc.GetCurrentHash();
+ hash = BitConverter.ToInt32(hashBytes, 0);
return hash.Value;
}
}
diff --git a/Samples/nrom_split_lossy/Makefile b/Samples/nrom_split_lossy/Makefile
index f9bccf0..7d741c0 100644
--- a/Samples/nrom_split_lossy/Makefile
+++ b/Samples/nrom_split_lossy/Makefile
@@ -18,6 +18,8 @@ PALETTE_0_BIN=palette_0.bin
PALETTE_1_BIN=palette_1.bin
PALETTE_2_BIN=palette_2.bin
PALETTE_3_BIN=palette_3.bin
+PREVIEW_1=preview1.png
+PREVIEW_2=preview2.png
build: $(EXECUTABLE)
@@ -41,7 +43,8 @@ $(PATTERN_0_BIN) $(PATTERN_1_BIN) \
$(NAME_TABLE_0_BIN) $(NAME_TABLE_1_BIN) \
$(ATTR_TABLE_0_BIN) $(ATTR_TABLE_1_BIN) \
$(PALETTE_0_BIN) $(PALETTE_1_BIN) \
-$(PALETTE_2_BIN) $(PALETTE_3_BIN): $(IMAGE)
+$(PALETTE_2_BIN) $(PALETTE_3_BIN) \
+$(PREVIEW_1) $(PREVIEW_2): $(IMAGE)
$(TILER) --mode bg --enable-palettes 0,1,2,3 \
--in-0 $(IMAGE):0:$(HEIGHT1) --in-1 $(IMAGE):$(HEIGHT1):$(HEIGHT2) \
--out-pattern-table-0 $(PATTERN_0_BIN) --out-pattern-table-1 $(PATTERN_1_BIN) \
@@ -49,4 +52,4 @@ $(PALETTE_2_BIN) $(PALETTE_3_BIN): $(IMAGE)
--out-attribute-table-0 $(ATTR_TABLE_0_BIN) --out-attribute-table-1 $(ATTR_TABLE_1_BIN) \
--out-palette-0 $(PALETTE_0_BIN) --out-palette-1 $(PALETTE_1_BIN) \
--out-palette-2 $(PALETTE_2_BIN) --out-palette-3 $(PALETTE_3_BIN) \
- --lossy
+ --lossy --out-preview-0 $(PREVIEW_1) --out-preview-1 $(PREVIEW_2)
diff --git a/Samples/nrom_split_lossy/preview1.png b/Samples/nrom_split_lossy/preview1.png
new file mode 100644
index 0000000..f6fac89
--- /dev/null
+++ b/Samples/nrom_split_lossy/preview1.png
Binary files differ
diff --git a/Samples/nrom_split_lossy/preview2.png b/Samples/nrom_split_lossy/preview2.png
new file mode 100644
index 0000000..f1254a3
--- /dev/null
+++ b/Samples/nrom_split_lossy/preview2.png
Binary files differ