From 929ea2927deb85a8a3bf389c760b0f4966f0723b Mon Sep 17 00:00:00 2001 From: Alexey 'Cluster' Avdyukhin Date: Fri, 14 Oct 2022 23:23:52 +0400 Subject: Shared patterns, more tests --- Tests/Program.cs | 107 +++++++++++++++------ ...ster_left_blaster_master_right_attr_table_0.bin | Bin 0 -> 64 bytes ...ster_left_blaster_master_right_attr_table_1.bin | Bin 0 -> 64 bytes ...ster_left_blaster_master_right_name_table_0.bin | Bin 0 -> 960 bytes ...ster_left_blaster_master_right_name_table_1.bin | Bin 0 -> 960 bytes ..._master_left_blaster_master_right_palette_0.bin | 1 + ..._master_left_blaster_master_right_palette_1.bin | 2 + ..._master_left_blaster_master_right_palette_2.bin | 1 + ..._master_left_blaster_master_right_palette_3.bin | Bin 0 -> 4 bytes ..._master_left_blaster_master_right_pattern_0.bin | Bin 0 -> 4000 bytes .../blaster_master_left_name_table_0.bin | Bin 960 -> 960 bytes .../blaster_master_right_attr_table_0.bin | Bin 64 -> 64 bytes .../blaster_master_right_full_attr_table_0.bin | Bin 64 -> 0 bytes .../blaster_master_right_full_name_table_0.bin | Bin 960 -> 0 bytes .../blaster_master_right_full_palette_0.bin | 1 - .../blaster_master_right_full_palette_1.bin | 2 - .../blaster_master_right_full_palette_2.bin | 1 - .../blaster_master_right_full_palette_3.bin | Bin 4 -> 0 bytes .../blaster_master_right_full_pattern_0.bin | Bin 3552 -> 0 bytes .../blaster_master_right_name_table_0.bin | Bin 960 -> 960 bytes .../References/blaster_master_right_pattern_0.bin | Bin 3408 -> 3200 bytes Tests/Tests.csproj | 34 ++++--- 22 files changed, 103 insertions(+), 46 deletions(-) create mode 100644 Tests/References/blaster_master_left_blaster_master_right_attr_table_0.bin create mode 100644 Tests/References/blaster_master_left_blaster_master_right_attr_table_1.bin create mode 100644 Tests/References/blaster_master_left_blaster_master_right_name_table_0.bin create mode 100644 Tests/References/blaster_master_left_blaster_master_right_name_table_1.bin create mode 100644 Tests/References/blaster_master_left_blaster_master_right_palette_0.bin create mode 100644 Tests/References/blaster_master_left_blaster_master_right_palette_1.bin create mode 100644 Tests/References/blaster_master_left_blaster_master_right_palette_2.bin create mode 100644 Tests/References/blaster_master_left_blaster_master_right_palette_3.bin create mode 100644 Tests/References/blaster_master_left_blaster_master_right_pattern_0.bin delete mode 100644 Tests/References/blaster_master_right_full_attr_table_0.bin delete mode 100644 Tests/References/blaster_master_right_full_name_table_0.bin delete mode 100644 Tests/References/blaster_master_right_full_palette_0.bin delete mode 100644 Tests/References/blaster_master_right_full_palette_1.bin delete mode 100644 Tests/References/blaster_master_right_full_palette_2.bin delete mode 100644 Tests/References/blaster_master_right_full_palette_3.bin delete mode 100644 Tests/References/blaster_master_right_full_pattern_0.bin (limited to 'Tests') diff --git a/Tests/Program.cs b/Tests/Program.cs index 1ed8975..64c084b 100644 --- a/Tests/Program.cs +++ b/Tests/Program.cs @@ -8,129 +8,144 @@ namespace com.clusterrr.Famicom.NesTiler.Benchmarks const string ReferencesDir = "References"; [Test] - public void TestBelayaAkula() + public void BelayaAkula() { var imagePath = Path.Combine(ImagesPath, "belaya_akula.gif"); DoTestSplit4(imagePath); } [Test] - public void TestBuhanka() + public void Buhanka() { var imagePath = Path.Combine(ImagesPath, "buhanka.gif"); DoTestSplit4(imagePath); } [Test] - public void TestChernobyl() + public void Chernobyl() { var imagePath = Path.Combine(ImagesPath, "chernobyl.gif"); DoTestSplit4(imagePath); } [Test] - public void TestDira() + public void Dira() { var imagePath = Path.Combine(ImagesPath, "dira.gif"); DoTestSplit4(imagePath); } [Test] - public void TestGlaza() + public void Glaza() { var imagePath = Path.Combine(ImagesPath, "glaza.gif"); DoTestSplit4(imagePath); } [Test] - public void TestGorgona() + public void Gorgona() { var imagePath = Path.Combine(ImagesPath, "gorgona.gif"); DoTestSplit4(imagePath); } [Test] - public void TestMyatejl() + public void Myatejl() { var imagePath = Path.Combine(ImagesPath, "myatej.gif"); DoTestSplit4(imagePath); } [Test] - public void TestPagoda() + public void Pagoda() { var imagePath = Path.Combine(ImagesPath, "pagoda.gif"); DoTestSplit4(imagePath); } [Test] - public void TestRayon4() + public void Rayon4() { var imagePath = Path.Combine(ImagesPath, "rayon4.gif"); DoTestSplit4(imagePath); } [Test] - public void TestShkola() + public void Shkola() { var imagePath = Path.Combine(ImagesPath, "shkola.gif"); DoTestSplit4(imagePath); } [Test] - public void TestSindikat() + public void Sindikat() { var imagePath = Path.Combine(ImagesPath, "sindikat.gif"); DoTestSplit4(imagePath); } [Test] - public void TestSputnik() + public void Sputnik() { var imagePath = Path.Combine(ImagesPath, "sputnik.gif"); DoTestSplit4(imagePath); } [Test] - public void TestSworm() + public void Sworm() { var imagePath = Path.Combine(ImagesPath, "sworm.gif"); DoTestSplit4(imagePath); } [Test] - public void TestTrailerPark() + public void TrailerPark() { var imagePath = Path.Combine(ImagesPath, "trailer-park.gif"); DoTestSplit4(imagePath); } [Test] - public void TestWarfaceLogo() + public void WarfaceLogo() { var imagePath = Path.Combine(ImagesPath, "warface_logo.gif"); DoTestSplit4(imagePath); } [Test] - public void TestBlasterMasterLeft() + public void Jurassic() + { + var imagePath = Path.Combine(ImagesPath, "jurassic.png"); + DoTestSplit2(imagePath); + } + + [Test] + public void Jurassic2() + { + var imagePath = Path.Combine(ImagesPath, "jurassic2.png"); + DoTestSplit2(imagePath); + } + + [Test] + public void BlasterMasterLeft() { var imagePath = Path.Combine(ImagesPath, "blaster_master_left.png"); DoTestNoSplit(imagePath, "#000000"); } [Test] - public void TestBlasterMasterRight() + public void BlasterMasterRight() { var imagePath = Path.Combine(ImagesPath, "blaster_master_right.png"); DoTestNoSplit(imagePath, "#000000"); } [Test] - public void TestBlasterMasterRightFull() + public void BlasterMasterSharedPattern() { - var imagePath = Path.Combine(ImagesPath, "blaster_master_right_full.png"); - DoTestNoSplit(imagePath, "#000000"); + var imagePath1 = Path.Combine(ImagesPath, "blaster_master_left.png"); + var imagePath2 = Path.Combine(ImagesPath, "blaster_master_right.png"); + DoBenchmarkSharedPattern(imagePath1, imagePath2, "#000000"); } private string PatternTablePath(string prefix, int number) => $"{prefix}_pattern_{number}.bin"; @@ -168,13 +183,49 @@ namespace com.clusterrr.Famicom.NesTiler.Benchmarks Assert.That(File.ReadAllBytes(PalettePath(prefix, 3)), Is.EqualTo(File.ReadAllBytes(Path.Combine(ReferencesDir, PalettePath(prefix, 3))))); } + public void DoBenchmarkSharedPattern(string imagePath1, string imagePath2, string bgColor = "auto") + { + var prefix = Path.GetFileNameWithoutExtension(imagePath1) + "_" + Path.GetFileNameWithoutExtension(imagePath2); + var args = new string[] { + "--enable-palettes", "0,1,2,3", + "-input-0", $"{imagePath1}", + "-input-1", $"{imagePath2}", + "--out-pattern-table", PatternTablePath(prefix, 0), + "--out-name-table-0", NameTablePath(prefix, 0), + "--out-name-table-1", NameTablePath(prefix, 1), + "--out-attribute-table-0", AttrTablePath(prefix, 0), + "--out-attribute-table-1", AttrTablePath(prefix, 1), + "--out-palette-0", PalettePath(prefix, 0), + "--out-palette-1", PalettePath(prefix, 1), + "--out-palette-2", PalettePath(prefix, 2), + "--out-palette-3", PalettePath(prefix, 3), + "--bg-color", bgColor, + "--share-pattern-tables" + }; + var r = Program.Main(args); + if (r != 0) throw new InvalidOperationException($"Return code: {r}"); + + Assert.That(File.ReadAllBytes(PatternTablePath(prefix, 0)), Is.EqualTo(File.ReadAllBytes(Path.Combine(ReferencesDir, PatternTablePath(prefix, 0))))); + + Assert.That(File.ReadAllBytes(NameTablePath(prefix, 0)), Is.EqualTo(File.ReadAllBytes(Path.Combine(ReferencesDir, NameTablePath(prefix, 0))))); + Assert.That(File.ReadAllBytes(NameTablePath(prefix, 1)), Is.EqualTo(File.ReadAllBytes(Path.Combine(ReferencesDir, NameTablePath(prefix, 1))))); + + Assert.That(File.ReadAllBytes(AttrTablePath(prefix, 0)), Is.EqualTo(File.ReadAllBytes(Path.Combine(ReferencesDir, AttrTablePath(prefix, 0))))); + Assert.That(File.ReadAllBytes(AttrTablePath(prefix, 1)), Is.EqualTo(File.ReadAllBytes(Path.Combine(ReferencesDir, AttrTablePath(prefix, 1))))); + + Assert.That(File.ReadAllBytes(PalettePath(prefix, 0)), Is.EqualTo(File.ReadAllBytes(Path.Combine(ReferencesDir, PalettePath(prefix, 0))))); + Assert.That(File.ReadAllBytes(PalettePath(prefix, 1)), Is.EqualTo(File.ReadAllBytes(Path.Combine(ReferencesDir, PalettePath(prefix, 1))))); + Assert.That(File.ReadAllBytes(PalettePath(prefix, 2)), Is.EqualTo(File.ReadAllBytes(Path.Combine(ReferencesDir, PalettePath(prefix, 2))))); + Assert.That(File.ReadAllBytes(PalettePath(prefix, 3)), Is.EqualTo(File.ReadAllBytes(Path.Combine(ReferencesDir, PalettePath(prefix, 3))))); + } + public void DoTestSplit2(string imagePath) { var prefix = Path.GetFileNameWithoutExtension(imagePath); var args = new string[] { "--enable-palettes", "0,1,2,3", - "-input-0", $"{imagePath}:0:64", - "-input-1", $"{imagePath}:64:64", + "-input-0", $"{imagePath}:0:128", + "-input-1", $"{imagePath}:128:112", "--out-pattern-table-0", PatternTablePath(prefix, 0), "--out-pattern-table-1", PatternTablePath(prefix, 1), "--out-name-table-0", NameTablePath(prefix, 0), @@ -195,8 +246,8 @@ namespace com.clusterrr.Famicom.NesTiler.Benchmarks Assert.That(File.ReadAllBytes(NameTablePath(prefix, 0)), Is.EqualTo(File.ReadAllBytes(Path.Combine(ReferencesDir, NameTablePath(prefix, 0))))); Assert.That(File.ReadAllBytes(NameTablePath(prefix, 1)), Is.EqualTo(File.ReadAllBytes(Path.Combine(ReferencesDir, NameTablePath(prefix, 1))))); - Assert.That(File.ReadAllBytes(PatternTablePath(prefix, 0)), Is.EqualTo(File.ReadAllBytes(Path.Combine(ReferencesDir, PatternTablePath(prefix, 0))))); - Assert.That(File.ReadAllBytes(PatternTablePath(prefix, 1)), Is.EqualTo(File.ReadAllBytes(Path.Combine(ReferencesDir, PatternTablePath(prefix, 1))))); + Assert.That(File.ReadAllBytes(AttrTablePath(prefix, 0)), Is.EqualTo(File.ReadAllBytes(Path.Combine(ReferencesDir, AttrTablePath(prefix, 0))))); + Assert.That(File.ReadAllBytes(AttrTablePath(prefix, 1)), Is.EqualTo(File.ReadAllBytes(Path.Combine(ReferencesDir, AttrTablePath(prefix, 1))))); Assert.That(File.ReadAllBytes(PalettePath(prefix, 0)), Is.EqualTo(File.ReadAllBytes(Path.Combine(ReferencesDir, PalettePath(prefix, 0))))); Assert.That(File.ReadAllBytes(PalettePath(prefix, 1)), Is.EqualTo(File.ReadAllBytes(Path.Combine(ReferencesDir, PalettePath(prefix, 1))))); @@ -243,10 +294,10 @@ namespace com.clusterrr.Famicom.NesTiler.Benchmarks Assert.That(File.ReadAllBytes(NameTablePath(prefix, 2)), Is.EqualTo(File.ReadAllBytes(Path.Combine(ReferencesDir, NameTablePath(prefix, 2))))); Assert.That(File.ReadAllBytes(NameTablePath(prefix, 3)), Is.EqualTo(File.ReadAllBytes(Path.Combine(ReferencesDir, NameTablePath(prefix, 3))))); - Assert.That(File.ReadAllBytes(PatternTablePath(prefix, 0)), Is.EqualTo(File.ReadAllBytes(Path.Combine(ReferencesDir, PatternTablePath(prefix, 0))))); - Assert.That(File.ReadAllBytes(PatternTablePath(prefix, 1)), Is.EqualTo(File.ReadAllBytes(Path.Combine(ReferencesDir, PatternTablePath(prefix, 1))))); - Assert.That(File.ReadAllBytes(PatternTablePath(prefix, 2)), Is.EqualTo(File.ReadAllBytes(Path.Combine(ReferencesDir, PatternTablePath(prefix, 2))))); - Assert.That(File.ReadAllBytes(PatternTablePath(prefix, 3)), Is.EqualTo(File.ReadAllBytes(Path.Combine(ReferencesDir, PatternTablePath(prefix, 3))))); + Assert.That(File.ReadAllBytes(AttrTablePath(prefix, 0)), Is.EqualTo(File.ReadAllBytes(Path.Combine(ReferencesDir, AttrTablePath(prefix, 0))))); + Assert.That(File.ReadAllBytes(AttrTablePath(prefix, 1)), Is.EqualTo(File.ReadAllBytes(Path.Combine(ReferencesDir, AttrTablePath(prefix, 1))))); + Assert.That(File.ReadAllBytes(AttrTablePath(prefix, 2)), Is.EqualTo(File.ReadAllBytes(Path.Combine(ReferencesDir, AttrTablePath(prefix, 2))))); + Assert.That(File.ReadAllBytes(AttrTablePath(prefix, 3)), Is.EqualTo(File.ReadAllBytes(Path.Combine(ReferencesDir, AttrTablePath(prefix, 3))))); Assert.That(File.ReadAllBytes(PalettePath(prefix, 0)), Is.EqualTo(File.ReadAllBytes(Path.Combine(ReferencesDir, PalettePath(prefix, 0))))); Assert.That(File.ReadAllBytes(PalettePath(prefix, 1)), Is.EqualTo(File.ReadAllBytes(Path.Combine(ReferencesDir, PalettePath(prefix, 1))))); diff --git a/Tests/References/blaster_master_left_blaster_master_right_attr_table_0.bin b/Tests/References/blaster_master_left_blaster_master_right_attr_table_0.bin new file mode 100644 index 0000000..52467f5 Binary files /dev/null and b/Tests/References/blaster_master_left_blaster_master_right_attr_table_0.bin differ diff --git a/Tests/References/blaster_master_left_blaster_master_right_attr_table_1.bin b/Tests/References/blaster_master_left_blaster_master_right_attr_table_1.bin new file mode 100644 index 0000000..3433614 Binary files /dev/null and b/Tests/References/blaster_master_left_blaster_master_right_attr_table_1.bin differ diff --git a/Tests/References/blaster_master_left_blaster_master_right_name_table_0.bin b/Tests/References/blaster_master_left_blaster_master_right_name_table_0.bin new file mode 100644 index 0000000..0c7c8e7 Binary files /dev/null and b/Tests/References/blaster_master_left_blaster_master_right_name_table_0.bin differ diff --git a/Tests/References/blaster_master_left_blaster_master_right_name_table_1.bin b/Tests/References/blaster_master_left_blaster_master_right_name_table_1.bin new file mode 100644 index 0000000..0dfe2f5 Binary files /dev/null and b/Tests/References/blaster_master_left_blaster_master_right_name_table_1.bin differ diff --git a/Tests/References/blaster_master_left_blaster_master_right_palette_0.bin b/Tests/References/blaster_master_left_blaster_master_right_palette_0.bin new file mode 100644 index 0000000..d083327 --- /dev/null +++ b/Tests/References/blaster_master_left_blaster_master_right_palette_0.bin @@ -0,0 +1 @@ + ! \ No newline at end of file diff --git a/Tests/References/blaster_master_left_blaster_master_right_palette_1.bin b/Tests/References/blaster_master_left_blaster_master_right_palette_1.bin new file mode 100644 index 0000000..66a703a --- /dev/null +++ b/Tests/References/blaster_master_left_blaster_master_right_palette_1.bin @@ -0,0 +1,2 @@ + +* \ No newline at end of file diff --git a/Tests/References/blaster_master_left_blaster_master_right_palette_2.bin b/Tests/References/blaster_master_left_blaster_master_right_palette_2.bin new file mode 100644 index 0000000..e43c33f --- /dev/null +++ b/Tests/References/blaster_master_left_blaster_master_right_palette_2.bin @@ -0,0 +1 @@ +, \ No newline at end of file diff --git a/Tests/References/blaster_master_left_blaster_master_right_palette_3.bin b/Tests/References/blaster_master_left_blaster_master_right_palette_3.bin new file mode 100644 index 0000000..6d9efbb Binary files /dev/null and b/Tests/References/blaster_master_left_blaster_master_right_palette_3.bin differ diff --git a/Tests/References/blaster_master_left_blaster_master_right_pattern_0.bin b/Tests/References/blaster_master_left_blaster_master_right_pattern_0.bin new file mode 100644 index 0000000..f276f84 Binary files /dev/null and b/Tests/References/blaster_master_left_blaster_master_right_pattern_0.bin differ diff --git a/Tests/References/blaster_master_left_name_table_0.bin b/Tests/References/blaster_master_left_name_table_0.bin index 19601a9..0c7c8e7 100644 Binary files a/Tests/References/blaster_master_left_name_table_0.bin and b/Tests/References/blaster_master_left_name_table_0.bin differ diff --git a/Tests/References/blaster_master_right_attr_table_0.bin b/Tests/References/blaster_master_right_attr_table_0.bin index 7499ae4..3433614 100644 Binary files a/Tests/References/blaster_master_right_attr_table_0.bin and b/Tests/References/blaster_master_right_attr_table_0.bin differ diff --git a/Tests/References/blaster_master_right_full_attr_table_0.bin b/Tests/References/blaster_master_right_full_attr_table_0.bin deleted file mode 100644 index 7499ae4..0000000 Binary files a/Tests/References/blaster_master_right_full_attr_table_0.bin and /dev/null differ diff --git a/Tests/References/blaster_master_right_full_name_table_0.bin b/Tests/References/blaster_master_right_full_name_table_0.bin deleted file mode 100644 index 3f8985f..0000000 Binary files a/Tests/References/blaster_master_right_full_name_table_0.bin and /dev/null differ diff --git a/Tests/References/blaster_master_right_full_palette_0.bin b/Tests/References/blaster_master_right_full_palette_0.bin deleted file mode 100644 index d083327..0000000 --- a/Tests/References/blaster_master_right_full_palette_0.bin +++ /dev/null @@ -1 +0,0 @@ - ! \ No newline at end of file diff --git a/Tests/References/blaster_master_right_full_palette_1.bin b/Tests/References/blaster_master_right_full_palette_1.bin deleted file mode 100644 index 66a703a..0000000 --- a/Tests/References/blaster_master_right_full_palette_1.bin +++ /dev/null @@ -1,2 +0,0 @@ - -* \ No newline at end of file diff --git a/Tests/References/blaster_master_right_full_palette_2.bin b/Tests/References/blaster_master_right_full_palette_2.bin deleted file mode 100644 index e43c33f..0000000 --- a/Tests/References/blaster_master_right_full_palette_2.bin +++ /dev/null @@ -1 +0,0 @@ -, \ No newline at end of file diff --git a/Tests/References/blaster_master_right_full_palette_3.bin b/Tests/References/blaster_master_right_full_palette_3.bin deleted file mode 100644 index 6d9efbb..0000000 Binary files a/Tests/References/blaster_master_right_full_palette_3.bin and /dev/null differ diff --git a/Tests/References/blaster_master_right_full_pattern_0.bin b/Tests/References/blaster_master_right_full_pattern_0.bin deleted file mode 100644 index 5e078ca..0000000 Binary files a/Tests/References/blaster_master_right_full_pattern_0.bin and /dev/null differ diff --git a/Tests/References/blaster_master_right_name_table_0.bin b/Tests/References/blaster_master_right_name_table_0.bin index 705cfe4..95b7677 100644 Binary files a/Tests/References/blaster_master_right_name_table_0.bin and b/Tests/References/blaster_master_right_name_table_0.bin differ diff --git a/Tests/References/blaster_master_right_pattern_0.bin b/Tests/References/blaster_master_right_pattern_0.bin index b6a5bb2..8280e0e 100644 Binary files a/Tests/References/blaster_master_right_pattern_0.bin and b/Tests/References/blaster_master_right_pattern_0.bin differ diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj index c5e3379..344b71b 100644 --- a/Tests/Tests.csproj +++ b/Tests/Tests.csproj @@ -72,46 +72,52 @@ PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + + PreserveNewest + + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + + PreserveNewest + + PreserveNewest -- cgit v1.2.3