diff options
author | red031000 <rubenru09@aol.com> | 2020-07-12 18:36:54 +0100 |
---|---|---|
committer | red031000 <rubenru09@aol.com> | 2020-07-12 18:36:54 +0100 |
commit | a604bc3b573e2f23bb0eb40e0fc8946b857d6c98 (patch) | |
tree | d96c88f0831353b695ee21e492896d5f618ca819 /tools/nitrogfx/main.c | |
parent | 5f114f5c8413da73f21c9adbfd0165921314e275 (diff) |
fix palette issues, demo/title/titledemo narc fully converted
Diffstat (limited to 'tools/nitrogfx/main.c')
-rw-r--r-- | tools/nitrogfx/main.c | 48 |
1 files changed, 43 insertions, 5 deletions
diff --git a/tools/nitrogfx/main.c b/tools/nitrogfx/main.c index 0aaad201..188bdf0a 100644 --- a/tools/nitrogfx/main.c +++ b/tools/nitrogfx/main.c @@ -50,7 +50,7 @@ void ConvertNtrToPng(char *inputPath, char *outputPath, struct GbaToPngOptions * if (options->paletteFilePath != NULL) { - ReadNtrPalette(options->paletteFilePath, &image.palette); + ReadNtrPalette(options->paletteFilePath, &image.palette, options->bitDepth); image.hasPalette = true; } else @@ -437,7 +437,7 @@ void HandlePngToNtrPaletteCommand(char *inputPath, char *outputPath, int argc, c } ReadPngPalette(inputPath, &palette); - WriteNtrPalette(outputPath, &palette, ncpr, ir); + WriteNtrPalette(outputPath, &palette, ncpr, ir, palette.bitDepth); } void HandleGbaToJascPaletteCommand(char *inputPath, char *outputPath, int argc UNUSED, char **argv UNUSED) @@ -448,11 +448,35 @@ void HandleGbaToJascPaletteCommand(char *inputPath, char *outputPath, int argc U WriteJascPalette(outputPath, &palette); } -void HandleNtrToJascPaletteCommand(char *inputPath, char *outputPath, int argc UNUSED, char **argv UNUSED) +void HandleNtrToJascPaletteCommand(char *inputPath, char *outputPath, int argc, char **argv) { struct Palette palette; + int bitdepth = 0; - ReadNtrPalette(inputPath, &palette); + for (int i = 3; i < argc; i++) + { + char *option = argv[i]; + + if (strcmp(option, "-bitdepth") == 0) + { + if (i + 1 >= argc) + FATAL_ERROR("No bitdepth following \"-bitdepth\".\n"); + + i++; + + if (!ParseNumber(argv[i], NULL, 10, &bitdepth)) + FATAL_ERROR("Failed to parse bitdepth.\n"); + + if (bitdepth != 4 && bitdepth != 8) + FATAL_ERROR("Bitdepth must be 4 or 8.\n"); + } + else + { + FATAL_ERROR("Unrecognized option \"%s\".\n", option); + } + } + + ReadNtrPalette(inputPath, &palette, bitdepth); WriteJascPalette(outputPath, &palette); } @@ -498,6 +522,7 @@ void HandleJascToNtrPaletteCommand(char *inputPath, char *outputPath, int argc, int numColors = 0; bool ncpr = false; bool ir = false; + int bitdepth = 0; for (int i = 3; i < argc; i++) { @@ -516,6 +541,19 @@ 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) + { + if (i + 1 >= argc) + FATAL_ERROR("No bitdepth following \"-bitdepth\".\n"); + + i++; + + if (!ParseNumber(argv[i], NULL, 10, &bitdepth)) + FATAL_ERROR("Failed to parse bitdepth.\n"); + + if (bitdepth != 4 && bitdepth != 8) + FATAL_ERROR("Bitdepth must be 4 or 8.\n"); + } else if (strcmp(option, "-ncpr") == 0) { ncpr = true; @@ -537,7 +575,7 @@ void HandleJascToNtrPaletteCommand(char *inputPath, char *outputPath, int argc, if (numColors != 0) palette.numColors = numColors; - WriteNtrPalette(outputPath, &palette, ncpr, ir); + WriteNtrPalette(outputPath, &palette, ncpr, ir, bitdepth); } void HandleLatinFontToPngCommand(char *inputPath, char *outputPath, int argc UNUSED, char **argv UNUSED) |