diff options
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 }, |