summaryrefslogtreecommitdiff
path: root/tools/nitrogfx/main.c
diff options
context:
space:
mode:
authorred031000 <rubenru09@aol.com>2021-03-03 17:38:50 +0000
committerGitHub <noreply@github.com>2021-03-03 17:38:50 +0000
commit2e2dbd18e4c191474b6582adef02a481451b51d5 (patch)
tree42adde6c7d740d223dfcaf628800cdf7ff9b1364 /tools/nitrogfx/main.c
parent75dc81c75dc1dc86053303cdae9decdb2f05557d (diff)
parent28d8dc9f335da9e2111f3e2825ebf346b8d3117e (diff)
Merge pull request #322 from red031000/master
NCER and NSCR processing
Diffstat (limited to 'tools/nitrogfx/main.c')
-rw-r--r--tools/nitrogfx/main.c52
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 },