diff options
author | James Williams <j.williams97@outlook.com> | 2021-03-06 16:20:05 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-06 16:20:05 +0000 |
commit | 03645c295df36374ab4f5c6bf464396699512fb9 (patch) | |
tree | 8fe7df4569bde9e90a90650ecc52f58b81bbd166 /tools/nitrogfx/main.c | |
parent | 6b7b7395fbcfd632bf3a3bcbb9dea4480c455ed2 (diff) | |
parent | cb1c7acb520481b63c12f9ff32b503916128f5eb (diff) |
Merge branch 'master' into who-knows-who
Diffstat (limited to 'tools/nitrogfx/main.c')
-rw-r--r-- | tools/nitrogfx/main.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/tools/nitrogfx/main.c b/tools/nitrogfx/main.c index 35f59d0b..171cb5f3 100644 --- a/tools/nitrogfx/main.c +++ b/tools/nitrogfx/main.c @@ -13,6 +13,7 @@ #include "rl.h" #include "font.h" #include "huff.h" +#include "json.h" struct CommandHandler { @@ -674,6 +675,55 @@ void HandleJascToNtrPaletteCommand(char *inputPath, char *outputPath, int argc, WriteNtrPalette(outputPath, &palette, ncpr, ir, bitdepth, !nopad, compNum); } +void HandleJsonToNtrCellCommand(char *inputPath, char *outputPath, int argc UNUSED, char **argv UNUSED) +{ + struct JsonToCellOptions *options; + + options = ParseNCERJson(inputPath); + + WriteNtrCell(outputPath, options); + + FreeNCERCell(options); +} + +void HandleJsonToNtrScreenCommand(char *inputPath, char *outputPath, int argc UNUSED, char **argv UNUSED) +{ + struct JsonToScreenOptions *options; + + options = ParseNSCRJson(inputPath); + + int bitdepth = 4; + + 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); + } + } + + options->bitdepth = bitdepth; + + WriteNtrScreen(outputPath, options); + + FreeNSCRScreen(options); +} + void HandleLatinFontToPngCommand(char *inputPath, char *outputPath, int argc UNUSED, char **argv UNUSED) { struct Image image; @@ -932,6 +982,8 @@ int main(int argc, char **argv) { "png", "hwjpnfont", HandlePngToHalfwidthJapaneseFontCommand }, { "fwjpnfont", "png", HandleFullwidthJapaneseFontToPngCommand }, { "png", "fwjpnfont", HandlePngToFullwidthJapaneseFontCommand }, + { "json", "NCER", HandleJsonToNtrCellCommand }, + { "json", "NSCR", HandleJsonToNtrScreenCommand }, { NULL, "huff", HandleHuffCompressCommand }, { NULL, "lz", HandleLZCompressCommand }, { "huff", NULL, HandleHuffDecompressCommand }, |