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-27 10:33:44 +0300
committerAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2022-10-27 10:33:44 +0300
commit2b9753ec8d5e0157ea2a6fdbfcb35b558ca131db (patch)
tree45665d92f54856371dd83deb799b04f3338c11cd
parent08747248b0fdaa13fbb9ffbc07d9eaa61f7928f0 (diff)
Clean up.
-rw-r--r--NesTiler/CmdArgs.cs8
-rw-r--r--NesTiler/ColorExtensions.cs7
-rw-r--r--NesTiler/ColorFinder.cs (renamed from NesTiler/ColorsFinder.cs)6
-rw-r--r--NesTiler/Config.cs2
-rw-r--r--NesTiler/FastBitmap.cs10
-rw-r--r--NesTiler/Palette.cs5
-rw-r--r--NesTiler/Program.cs3
-rw-r--r--NesTiler/Tile.cs4
8 files changed, 12 insertions, 33 deletions
diff --git a/NesTiler/CmdArgs.cs b/NesTiler/CmdArgs.cs
index f4b5ee7..7eeec5c 100644
--- a/NesTiler/CmdArgs.cs
+++ b/NesTiler/CmdArgs.cs
@@ -1,10 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace com.clusterrr.Famicom.NesTiler
+namespace com.clusterrr.Famicom.NesTiler
{
interface IArg
{
diff --git a/NesTiler/ColorExtensions.cs b/NesTiler/ColorExtensions.cs
index 3a5105b..88f973a 100644
--- a/NesTiler/ColorExtensions.cs
+++ b/NesTiler/ColorExtensions.cs
@@ -1,14 +1,7 @@
using ColorMine.ColorSpaces;
using ColorMine.ColorSpaces.Comparisons;
-using SkiaSharp;
-using System;
using System.Collections.Generic;
-using System.Data.Common;
using System.Drawing;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using static System.Net.Mime.MediaTypeNames;
namespace com.clusterrr.Famicom.NesTiler
{
diff --git a/NesTiler/ColorsFinder.cs b/NesTiler/ColorFinder.cs
index 77ba1f0..d3bea55 100644
--- a/NesTiler/ColorsFinder.cs
+++ b/NesTiler/ColorFinder.cs
@@ -5,20 +5,18 @@ using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
-using System.Text;
using System.Text.Json;
-using System.Threading.Tasks;
namespace com.clusterrr.Famicom.NesTiler
{
- class ColorsFinder
+ class ColorFinder
{
static byte[] FORBIDDEN_COLORS = new byte[] { 0x0D, 0x0E, 0x0F, 0x1E, 0x1F, 0x2E, 0x2F, 0x3E, 0x3F };
public readonly Dictionary<byte, Color> Colors;
private readonly Dictionary<Color, byte> cache = new();
- public ColorsFinder(string filename)
+ public ColorFinder(string filename)
{
this.Colors = LoadColors(filename);
}
diff --git a/NesTiler/Config.cs b/NesTiler/Config.cs
index 60ba891..9916a3b 100644
--- a/NesTiler/Config.cs
+++ b/NesTiler/Config.cs
@@ -3,9 +3,7 @@ using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
-using System.Text;
using System.Text.RegularExpressions;
-using System.Threading.Tasks;
namespace com.clusterrr.Famicom.NesTiler
{
diff --git a/NesTiler/FastBitmap.cs b/NesTiler/FastBitmap.cs
index 8ed84e9..fb92468 100644
--- a/NesTiler/FastBitmap.cs
+++ b/NesTiler/FastBitmap.cs
@@ -1,11 +1,7 @@
using SkiaSharp;
-using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
-using System.Runtime.CompilerServices;
-using System.Text;
-using System.Threading.Tasks;
namespace com.clusterrr.Famicom.NesTiler
{
@@ -35,12 +31,12 @@ namespace com.clusterrr.Famicom.NesTiler
public Color GetPixelColor(int x, int y)
{
- return colors[y * Width + x];
+ return colors[(y * Width) + x];
}
public void SetPixelColor(int x, int y, Color color)
{
- colors[y * Width + x] = color;
+ colors[(y * Width) + x] = color;
}
public byte[] Encode(SKEncodedImageFormat format, int v)
@@ -50,7 +46,7 @@ namespace com.clusterrr.Famicom.NesTiler
{
for (int x = 0; x < Width; x++)
{
- var color = colors[y * Width + x];
+ var color = colors[(y * Width) + x];
var skColor = new SKColor(color.R, color.G, color.B);
skImage.SetPixel(x, y, skColor);
}
diff --git a/NesTiler/Palette.cs b/NesTiler/Palette.cs
index ff4c3c5..5b8703f 100644
--- a/NesTiler/Palette.cs
+++ b/NesTiler/Palette.cs
@@ -1,5 +1,4 @@
-using SkiaSharp;
-using System;
+using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
@@ -141,7 +140,7 @@ namespace com.clusterrr.Famicom.NesTiler
public override int GetHashCode()
{
- return (this[1]?.R ?? 0) + (this[2]?.R ?? 0) + (this[3]?.R ?? 0)
+ return ((this[1]?.R ?? 0) + (this[2]?.R ?? 0) + (this[3]?.R ?? 0))
| (((this[1]?.G ?? 0) + (this[2]?.G ?? 0) + (this[3]?.G ?? 0)) << 10)
| (((this[1]?.B ?? 0) + (this[2]?.B ?? 0) + (this[3]?.B ?? 0)) << 20);
}
diff --git a/NesTiler/Program.cs b/NesTiler/Program.cs
index 7a11d92..09e6519 100644
--- a/NesTiler/Program.cs
+++ b/NesTiler/Program.cs
@@ -77,7 +77,7 @@ namespace com.clusterrr.Famicom.NesTiler
int tileID = 0;
// Loading and parsing palette JSON
- var nesColors = new ColorsFinder(c.ColorsFile);
+ var nesColors = new ColorFinder(c.ColorsFile);
// CSV output
var outTilesCsvLines = !string.IsNullOrEmpty(c.OutTilesCsv) ? new List<string>() : null;
@@ -625,6 +625,7 @@ namespace com.clusterrr.Famicom.NesTiler
}
}
}
+
if (!grouped) break; // Nothing changed, stop iterations
}
diff --git a/NesTiler/Tile.cs b/NesTiler/Tile.cs
index a33f00f..57aca75 100644
--- a/NesTiler/Tile.cs
+++ b/NesTiler/Tile.cs
@@ -31,9 +31,9 @@ namespace com.clusterrr.Famicom.NesTiler
{
// for each pixel
if ((Pixels[(y * Width) + x] & 1) != 0) // check bit 0
- data[y / 8 * 16 + (y % 8)] |= (byte)(1 << bit);
+ data[(y / 8 * 16) + (y % 8)] |= (byte)(1 << bit);
if ((Pixels[(y * Width) + x] & 2) != 0) // check bit 1
- data[y / 8 * 16 + (y % 8) + 8] |= (byte)(1 << bit);
+ data[(y / 8 * 16) + (y % 8) + 8] |= (byte)(1 << bit);
pixel++;
bit = (byte)((byte)(bit - 1) % 8); // decrease bit number, wrap around if need
}