From 7245b56b693f1cccc8e2809ca650af6790c5c1ce Mon Sep 17 00:00:00 2001 From: red031000 Date: Mon, 13 Jul 2020 13:54:04 +0100 Subject: palette padding changes --- tools/nitrogfx/main.c | 44 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) (limited to 'tools/nitrogfx/main.c') diff --git a/tools/nitrogfx/main.c b/tools/nitrogfx/main.c index 188bdf0a..12521517 100644 --- a/tools/nitrogfx/main.c +++ b/tools/nitrogfx/main.c @@ -417,6 +417,8 @@ void HandlePngToNtrPaletteCommand(char *inputPath, char *outputPath, int argc, c struct Palette palette; bool ncpr = false; bool ir = false; + bool nopad = false; + int compNum; for (int i = 3; i < argc; i++) { @@ -430,6 +432,23 @@ void HandlePngToNtrPaletteCommand(char *inputPath, char *outputPath, int argc, c { ir = true; } + else if (strcmp(option, "-nopad") == 0) + { + nopad = true; + } + if (strcmp(option, "-comp") == 0) + { + if (i + 1 >= argc) + FATAL_ERROR("No compression value following \"-comp\".\n"); + + i++; + + if (!ParseNumber(argv[i], NULL, 10, &compNum)) + FATAL_ERROR("Failed to parse compression value.\n"); + + if (compNum > 255) + FATAL_ERROR("Compression value must be 255 or below.\n"); + } else { FATAL_ERROR("Unrecognized option \"%s\".\n", option); @@ -437,7 +456,7 @@ void HandlePngToNtrPaletteCommand(char *inputPath, char *outputPath, int argc, c } ReadPngPalette(inputPath, &palette); - WriteNtrPalette(outputPath, &palette, ncpr, ir, palette.bitDepth); + WriteNtrPalette(outputPath, &palette, ncpr, ir, palette.bitDepth, !nopad, compNum); } void HandleGbaToJascPaletteCommand(char *inputPath, char *outputPath, int argc UNUSED, char **argv UNUSED) @@ -522,7 +541,9 @@ void HandleJascToNtrPaletteCommand(char *inputPath, char *outputPath, int argc, int numColors = 0; bool ncpr = false; bool ir = false; + bool nopad = false; int bitdepth = 0; + int compNum = 0; for (int i = 3; i < argc; i++) { @@ -541,7 +562,7 @@ void HandleJascToNtrPaletteCommand(char *inputPath, char *outputPath, int argc, if (numColors < 1) FATAL_ERROR("Number of colors must be positive.\n"); } - if (strcmp(option, "-bitdepth") == 0) + else if (strcmp(option, "-bitdepth") == 0) { if (i + 1 >= argc) FATAL_ERROR("No bitdepth following \"-bitdepth\".\n"); @@ -554,6 +575,19 @@ void HandleJascToNtrPaletteCommand(char *inputPath, char *outputPath, int argc, if (bitdepth != 4 && bitdepth != 8) FATAL_ERROR("Bitdepth must be 4 or 8.\n"); } + else if (strcmp(option, "-comp") == 0) + { + if (i + 1 >= argc) + FATAL_ERROR("No compression value following \"-comp\".\n"); + + i++; + + if (!ParseNumber(argv[i], NULL, 10, &compNum)) + FATAL_ERROR("Failed to parse compression value.\n"); + + if (compNum > 255) + FATAL_ERROR("Compression value must be 255 or below.\n"); + } else if (strcmp(option, "-ncpr") == 0) { ncpr = true; @@ -562,6 +596,10 @@ void HandleJascToNtrPaletteCommand(char *inputPath, char *outputPath, int argc, { ir = true; } + else if (strcmp(option, "-nopad") == 0) + { + nopad = true; + } else { FATAL_ERROR("Unrecognized option \"%s\".\n", option); @@ -575,7 +613,7 @@ void HandleJascToNtrPaletteCommand(char *inputPath, char *outputPath, int argc, if (numColors != 0) palette.numColors = numColors; - WriteNtrPalette(outputPath, &palette, ncpr, ir, bitdepth); + WriteNtrPalette(outputPath, &palette, ncpr, ir, bitdepth, !nopad, compNum); } void HandleLatinFontToPngCommand(char *inputPath, char *outputPath, int argc UNUSED, char **argv UNUSED) -- cgit v1.2.3 From b13e85ee6aa88181e6f3d7a174957c3911a562d3 Mon Sep 17 00:00:00 2001 From: red031000 Date: Mon, 13 Jul 2020 14:32:55 +0100 Subject: turns out I'm just stupid --- tools/nitrogfx/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools/nitrogfx/main.c') diff --git a/tools/nitrogfx/main.c b/tools/nitrogfx/main.c index 12521517..b7136b03 100644 --- a/tools/nitrogfx/main.c +++ b/tools/nitrogfx/main.c @@ -418,7 +418,7 @@ void HandlePngToNtrPaletteCommand(char *inputPath, char *outputPath, int argc, c bool ncpr = false; bool ir = false; bool nopad = false; - int compNum; + int compNum = 0; for (int i = 3; i < argc; i++) { -- cgit v1.2.3