diff options
author | red031000 <rubenru09@aol.com> | 2020-06-07 17:00:13 +0100 |
---|---|---|
committer | red031000 <rubenru09@aol.com> | 2020-06-07 17:00:13 +0100 |
commit | 292a0f16f5492c0b89b11f4eec9bc8397874f9f0 (patch) | |
tree | fe42d97cfdf9ed72a9c9e8a887fe63006ed04abf /tools/nitrogfx/main.c | |
parent | 76e1f0cc3ae83473d01152202c6b04c2188fac10 (diff) |
cleanup ncpr handling
Diffstat (limited to 'tools/nitrogfx/main.c')
-rw-r--r-- | tools/nitrogfx/main.c | 44 |
1 files changed, 7 insertions, 37 deletions
diff --git a/tools/nitrogfx/main.c b/tools/nitrogfx/main.c index 1c7fc1e1..64f7e8a5 100644 --- a/tools/nitrogfx/main.c +++ b/tools/nitrogfx/main.c @@ -374,6 +374,7 @@ void HandleJascToGbaPaletteCommand(char *inputPath, char *outputPath, int argc, void HandleJascToNtrNCLRPaletteCommand(char *inputPath, char *outputPath, int argc, char **argv) { int numColors = 0; + bool ncpr = false; for (int i = 3; i < argc; i++) { @@ -392,42 +393,9 @@ void HandleJascToNtrNCLRPaletteCommand(char *inputPath, char *outputPath, int ar if (numColors < 1) FATAL_ERROR("Number of colors must be positive.\n"); } - else - { - FATAL_ERROR("Unrecognized option \"%s\".\n", option); - } - } - - struct Palette palette; - - ReadJascPalette(inputPath, &palette); - - if (numColors != 0) - palette.numColors = numColors; - - WriteNtrNCLRPalette(outputPath, &palette); -} - -void HandleJascToNtrNCPRPaletteCommand(char *inputPath, char *outputPath, int argc, char **argv) -{ - int numColors = 0; - - for (int i = 3; i < argc; i++) - { - char *option = argv[i]; - - if (strcmp(option, "-num_colors") == 0) + else if (strcmp(option, "-ncpr") == 0) { - if (i + 1 >= argc) - FATAL_ERROR("No number of colors following \"-num_colors\".\n"); - - i++; - - if (!ParseNumber(argv[i], NULL, 10, &numColors)) - FATAL_ERROR("Failed to parse number of colors.\n"); - - if (numColors < 1) - FATAL_ERROR("Number of colors must be positive.\n"); + ncpr = true; } else { @@ -442,7 +410,10 @@ void HandleJascToNtrNCPRPaletteCommand(char *inputPath, char *outputPath, int ar if (numColors != 0) palette.numColors = numColors; - WriteNtrNCPRPalette(outputPath, &palette); + if (ncpr) + WriteNtrNCPRPalette(outputPath, &palette); + else + WriteNtrNCLRPalette(outputPath, &palette); } void HandleLatinFontToPngCommand(char *inputPath, char *outputPath, int argc UNUSED, char **argv UNUSED) @@ -696,7 +667,6 @@ int main(int argc, char **argv) { "ncpr", "pal", HandleNtrToJascPaletteCommand }, { "pal", "gbapal", HandleJascToGbaPaletteCommand }, { "pal", "nclr", HandleJascToNtrNCLRPaletteCommand }, - { "pal", "ncpr", HandleJascToNtrNCPRPaletteCommand }, { "latfont", "png", HandleLatinFontToPngCommand }, { "png", "latfont", HandlePngToLatinFontCommand }, { "hwjpnfont", "png", HandleHalfwidthJapaneseFontToPngCommand }, |