summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorred031000 <rubenru09@aol.com>2021-03-03 17:21:01 +0000
committerred031000 <rubenru09@aol.com>2021-03-03 17:21:01 +0000
commiteeddf7382ed11b597814342c719862895dd4412f (patch)
tree05e30480e5db3b677a983ca694cebd98ab33d30f
parent67ca51a9887d16b8d685addf83f9517f2f6b2929 (diff)
NSCR processing
-rw-r--r--Makefile6
-rw-r--r--files/demo/title/op_demo/narc_0068.NSBMD (renamed from files/demo/title/op_demo/narc_0068.bin)bin46160 -> 46160 bytes
-rw-r--r--files/demo/title/op_demo/narc_0069.NSBMD (renamed from files/demo/title/op_demo/narc_0069.bin)bin14116 -> 14116 bytes
-rw-r--r--files/demo/title/op_demo/narc_0070.NSBTX (renamed from files/demo/title/op_demo/narc_0070.bin)bin47100 -> 47100 bytes
-rw-r--r--files/demo/title/titledemo/.gitignore1
-rw-r--r--files/demo/title/titledemo/.knarcignore1
-rw-r--r--files/demo/title/titledemo/narc_0000.NSCRbin2084 -> 0 bytes
-rw-r--r--files/demo/title/titledemo/narc_0000_map.json39
-rw-r--r--files/demo/title/titledemo/narc_0000_tileset.json14
-rw-r--r--filesystem.mk1
-rw-r--r--graphics_rules.mk4
-rw-r--r--tools/nitrogfx/gfx.c94
-rw-r--r--tools/nitrogfx/gfx.h1
-rw-r--r--tools/nitrogfx/json.c49
-rw-r--r--tools/nitrogfx/json.h2
-rw-r--r--tools/nitrogfx/main.c39
-rw-r--r--tools/nitrogfx/options.h7
17 files changed, 231 insertions, 27 deletions
diff --git a/Makefile b/Makefile
index 1cdcca67..19d85350 100644
--- a/Makefile
+++ b/Makefile
@@ -162,7 +162,7 @@ clean: mostlyclean clean-fs clean-tools
clean-fs:
$(RM) $(filter %.narc %.arc,$(HOSTFS_FILES))
- $(RM) $(NCGR_CLEAN_LIST) $(NCLR_CLEAN_LIST) $(NCER_CLEAN_LIST)
+ $(RM) $(NCGR_CLEAN_LIST) $(NCLR_CLEAN_LIST) $(NCER_CLEAN_LIST) $(NSCR_CLEAN_LIST)
find . \( -iname '*.1bpp' -o -iname '*.4bpp' -o -iname '*.8bpp' -o -iname '*.gbapal' -o -iname '*.lz' \) -exec $(RM) {} +
$(RM) files/msgdata/msg/narc_*.bin
@@ -259,6 +259,7 @@ $(SCANNED_NCGR_FILES): GFX_FLAGS = -scanned
$(IR_NCLR_FILES): GFX_FLAGS = -ir
$(4BPP_NCLR_FILES): GFX_FLAGS = -bitdepth 4
+$(8BPP_NSCR_FILES): GFX_FLAGS = -bitdepth 8
$(8BPP_COMP10_NOPAD_NCLR_PNG_FILES): GFX_FLAGS = -bitdepth 8 -nopad -comp 10
$(8BPP_COMP10_NOPAD_NCLR_PAL_FILES): GFX_FLAGS = -bitdepth 8 -nopad -comp 10
@@ -274,6 +275,9 @@ $(8BPP_COMP10_NOPAD_NCLR_PAL_FILES): GFX_FLAGS = -bitdepth 8 -nopad -comp 10
%.NCER: %.json
$(GFX) $< $@
+%.NSCR: %_map.json
+ $(GFX) $< $@ $(GFX_FLAGS)
+
%.png: ;
%.pal: ;
%.json: ;
diff --git a/files/demo/title/op_demo/narc_0068.bin b/files/demo/title/op_demo/narc_0068.NSBMD
index 946ad766..946ad766 100644
--- a/files/demo/title/op_demo/narc_0068.bin
+++ b/files/demo/title/op_demo/narc_0068.NSBMD
Binary files differ
diff --git a/files/demo/title/op_demo/narc_0069.bin b/files/demo/title/op_demo/narc_0069.NSBMD
index 141a7c02..141a7c02 100644
--- a/files/demo/title/op_demo/narc_0069.bin
+++ b/files/demo/title/op_demo/narc_0069.NSBMD
Binary files differ
diff --git a/files/demo/title/op_demo/narc_0070.bin b/files/demo/title/op_demo/narc_0070.NSBTX
index 785fec33..785fec33 100644
--- a/files/demo/title/op_demo/narc_0070.bin
+++ b/files/demo/title/op_demo/narc_0070.NSBTX
Binary files differ
diff --git a/files/demo/title/titledemo/.gitignore b/files/demo/title/titledemo/.gitignore
index e16f0811..618137dd 100644
--- a/files/demo/title/titledemo/.gitignore
+++ b/files/demo/title/titledemo/.gitignore
@@ -1,2 +1,3 @@
+NARC_0000.NSCR
*.NCLR
*.NCGR
diff --git a/files/demo/title/titledemo/.knarcignore b/files/demo/title/titledemo/.knarcignore
index 2856080a..ebdff6e6 100644
--- a/files/demo/title/titledemo/.knarcignore
+++ b/files/demo/title/titledemo/.knarcignore
@@ -1,2 +1,3 @@
*.png
*.pal
+*.json
diff --git a/files/demo/title/titledemo/narc_0000.NSCR b/files/demo/title/titledemo/narc_0000.NSCR
deleted file mode 100644
index 5f25cc5e..00000000
--- a/files/demo/title/titledemo/narc_0000.NSCR
+++ /dev/null
Binary files differ
diff --git a/files/demo/title/titledemo/narc_0000_map.json b/files/demo/title/titledemo/narc_0000_map.json
new file mode 100644
index 00000000..1df9d38b
--- /dev/null
+++ b/files/demo/title/titledemo/narc_0000_map.json
@@ -0,0 +1,39 @@
+{ "compressionlevel":-1,
+ "editorsettings":
+ {
+ "export":
+ {
+ "target":"."
+ }
+ },
+ "height":32,
+ "infinite":false,
+ "layers":[
+ {
+ "data":[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498, 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
+ "height":32,
+ "id":1,
+ "name":"Tile Layer 1",
+ "opacity":1,
+ "type":"tilelayer",
+ "visible":true,
+ "width":32,
+ "x":0,
+ "y":0
+ }],
+ "nextlayerid":2,
+ "nextobjectid":1,
+ "orientation":"orthogonal",
+ "renderorder":"right-down",
+ "tiledversion":"1.4.3",
+ "tileheight":8,
+ "tilesets":[
+ {
+ "firstgid":1,
+ "source":"narc_0000_tileset.json"
+ }],
+ "tilewidth":8,
+ "type":"map",
+ "version":1.4,
+ "width":32
+} \ No newline at end of file
diff --git a/files/demo/title/titledemo/narc_0000_tileset.json b/files/demo/title/titledemo/narc_0000_tileset.json
new file mode 100644
index 00000000..d691e3e1
--- /dev/null
+++ b/files/demo/title/titledemo/narc_0000_tileset.json
@@ -0,0 +1,14 @@
+{ "columns":32,
+ "image":"narc_0001.png",
+ "imageheight":128,
+ "imagewidth":256,
+ "margin":0,
+ "name":"narc_0001",
+ "spacing":0,
+ "tilecount":512,
+ "tiledversion":"1.4.3",
+ "tileheight":8,
+ "tilewidth":8,
+ "type":"tileset",
+ "version":1.4
+} \ No newline at end of file
diff --git a/filesystem.mk b/filesystem.mk
index c6c5cfed..8f78dee6 100644
--- a/filesystem.mk
+++ b/filesystem.mk
@@ -2290,6 +2290,7 @@ files/data/namein.narc: \
files/data/namein/narc_0007.NSCR.lz
files/demo/title/titledemo.narc: \
+ files/demo/title/titledemo/narc_0000.NSCR \
files/demo/title/titledemo/narc_0001.NCGR \
files/demo/title/titledemo/narc_0001.NCLR \
files/demo/title/titledemo/narc_0003.NCGR \
diff --git a/graphics_rules.mk b/graphics_rules.mk
index 0d40af48..bd5c187d 100644
--- a/graphics_rules.mk
+++ b/graphics_rules.mk
@@ -92,6 +92,8 @@ CLOBBER_SIZE_VERSION101_NCGR_FILES := files/graphic/bag_gra/narc_0002.NCGR \
files/demo/title/titledemo/narc_0016.NCLR \
files/poketool/icongra/poke_icon/narc_0000.NCLR
+8BPP_NSCR_FILES := files/demo/title/titledemo/narc_0000.NSCR
+
IR_NCLR_FILES := files/itemtool/itemdata/item_icon/narc_0028.NCLR \
files/itemtool/itemdata/item_icon/narc_0029.NCLR \
files/itemtool/itemdata/item_icon/narc_0032.NCLR \
@@ -879,3 +881,5 @@ NCLR_CLEAN_LIST := files/application/wifi_earth/wifi_earth/narc_0006.NCLR \
files/poketool/trgra/trfgra/narc_0194.NCLR \
NCER_CLEAN_LIST := files/poketool/icongra/poke_icon/narc_0002.NCER
+
+NSCR_CLEAN_LIST := files/demo/title/titledemo/narc_0000.NSCR
diff --git a/tools/nitrogfx/gfx.c b/tools/nitrogfx/gfx.c
index d158069c..be01a456 100644
--- a/tools/nitrogfx/gfx.c
+++ b/tools/nitrogfx/gfx.c
@@ -858,43 +858,85 @@ void WriteNtrCell(char *path, struct JsonToCellOptions *options)
free(KBECContents);
- unsigned int lablSize = 8 + options->cellCount * 4;
- for (i = 0; i < options->cellCount; i++)
- {
- lablSize += strlen(options->cells[i]->label) + 1;
- }
+ if (options->label)
+ {
+ unsigned int lablSize = 8 + options->cellCount * 4;
+ for (i = 0; i < options->cellCount; i++)
+ {
+ lablSize += strlen(options->cells[i]->label) + 1;
+ }
- unsigned char *labl = malloc(lablSize);
+ unsigned char *labl = malloc(lablSize);
- memset(labl, 0, lablSize);
+ memset(labl, 0, lablSize);
- strcpy((char *)labl, "LBAL");
- labl[4] = lablSize & 0xff;
- labl[5] = lablSize >> 8;
+ strcpy((char *) labl, "LBAL");
+ labl[4] = lablSize & 0xff;
+ labl[5] = lablSize >> 8;
- unsigned int position = 0;
+ unsigned int position = 0;
- for (i = 0; i < options->cellCount * 4; i += 4)
- {
- labl[i + 8] = position & 0xff;
- labl[i + 9] = position >> 8;
+ for (i = 0; i < options->cellCount * 4; i += 4)
+ {
+ labl[i + 8] = position & 0xff;
+ labl[i + 9] = position >> 8;
- position += strlen(options->cells[i / 4]->label) + 1;
- }
+ position += strlen(options->cells[i / 4]->label) + 1;
+ }
- for (int j = 0; j < options->cellCount; j++)
- {
- strcpy((char *)(labl + (i + 8)), options->cells[j]->label);
- i += strlen(options->cells[j]->label) + 1;
- }
+ for (int j = 0; j < options->cellCount; j++)
+ {
+ strcpy((char *) (labl + (i + 8)), options->cells[j]->label);
+ i += strlen(options->cells[j]->label) + 1;
+ }
- fwrite(labl, 1, lablSize, fp);
+ fwrite(labl, 1, lablSize, fp);
- free(labl);
+ free(labl);
- unsigned char texu[0xc] = { 0x54, 0x58, 0x45, 0x55, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+ unsigned char texu[0xc] = {0x54, 0x58, 0x45, 0x55, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
- fwrite(texu, 1, 0xc, fp);
+ fwrite(texu, 1, 0xc, fp);
+ }
fclose(fp);
}
+
+void WriteNtrScreen(char *outputPath, struct JsonToScreenOptions *options)
+{
+ FILE *fp = fopen(outputPath, "wb");
+
+ if (fp == NULL)
+ FATAL_ERROR("Failed to open \"%s\" for writing.\n", outputPath);
+
+ int totalSize = options->width * options->height * 2 + 0x14;
+
+ WriteGenericNtrHeader(fp, "RCSN", totalSize, true, false, 1);
+
+ unsigned char NSCRHeader[0x14] = { 0x4E, 0x52, 0x43, 0x53, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00 };
+
+ NSCRHeader[0x4] = totalSize & 0xff;
+ NSCRHeader[0x5] = (totalSize >> 8) & 0xff;
+ NSCRHeader[0x6] = (totalSize >> 16) & 0xff;
+ NSCRHeader[0x7] = totalSize >> 24;
+
+ NSCRHeader[0x8] = (options->width * 8) & 0xff;
+ NSCRHeader[0x9] = (options->width * 8) >> 8;
+
+ NSCRHeader[0xA] = (options->height * 8) & 0xff;
+ NSCRHeader[0xB] = (options->height * 8) >> 8;
+
+ NSCRHeader[0xC] = options->bitdepth == 4 ? 0 : 1;
+
+ NSCRHeader[0x10] = (totalSize - 0x14) & 0xff;
+ NSCRHeader[0x11] = ((totalSize - 0x14) >> 8) & 0xff;
+ NSCRHeader[0x12] = ((totalSize - 0x14) >> 16) & 0xff;
+ NSCRHeader[0x13] = (totalSize - 0x14) >> 24;
+
+ fwrite(NSCRHeader, 1, 0x14, fp);
+
+ fwrite(options->data, 1, totalSize - 0x14, fp);
+
+ fclose(fp);
+}
diff --git a/tools/nitrogfx/gfx.h b/tools/nitrogfx/gfx.h
index 728e8839..d0e6521a 100644
--- a/tools/nitrogfx/gfx.h
+++ b/tools/nitrogfx/gfx.h
@@ -39,5 +39,6 @@ void ReadNtrPalette(char *path, struct Palette *palette, int bitdepth, int palIn
void WriteGbaPalette(char *path, struct Palette *palette);
void WriteNtrPalette(char *path, struct Palette *palette, bool ncpr, bool ir, int bitdepth, bool pad, int compNum);
void WriteNtrCell(char *path, struct JsonToCellOptions *options);
+void WriteNtrScreen(char *outputPath, struct JsonToScreenOptions *options);
#endif // GFX_H
diff --git a/tools/nitrogfx/json.c b/tools/nitrogfx/json.c
index ff52def9..fa9f9e5e 100644
--- a/tools/nitrogfx/json.c
+++ b/tools/nitrogfx/json.c
@@ -149,6 +149,48 @@ struct JsonToCellOptions *ParseNCERJson(char *path)
return options;
}
+struct JsonToScreenOptions *ParseNSCRJson(char *path)
+{
+ int fileLength;
+ unsigned char *jsonString = ReadWholeFile(path, &fileLength);
+
+ cJSON *json = cJSON_Parse((const char *)jsonString);
+
+ struct JsonToScreenOptions *options = malloc(sizeof(struct JsonToScreenOptions));
+
+ if (json == NULL)
+ {
+ const char *errorPtr = cJSON_GetErrorPtr();
+ FATAL_ERROR("Error in line \"%s\"\n", errorPtr);
+ }
+
+ cJSON *Height = cJSON_GetObjectItemCaseSensitive(json, "height");
+ cJSON *Width = cJSON_GetObjectItemCaseSensitive(json, "width");
+
+ options->height = GetInt(Height);
+ options->width = GetInt(Width);
+
+ options->data = malloc(sizeof(unsigned short) * options->height * options->width);
+
+ cJSON *layer = NULL;
+ cJSON *layers = cJSON_GetObjectItemCaseSensitive(json, "layers");
+ cJSON_ArrayForEach(layer, layers)
+ {
+ cJSON *tile = NULL;
+ cJSON *data = cJSON_GetObjectItemCaseSensitive(layer, "data");
+ int i = 0;
+ cJSON_ArrayForEach(tile, data)
+ {
+ options->data[i] = (short)(GetInt(tile) - 1); //TODO horizontal and vertical flips
+ i++;
+ }
+ }
+
+ cJSON_Delete(json);
+ free(jsonString);
+ return options;
+}
+
void FreeNCERCell(struct JsonToCellOptions *options)
{
for (int i = 0; i < options->cellCount; i++)
@@ -161,3 +203,10 @@ void FreeNCERCell(struct JsonToCellOptions *options)
}
free(options);
}
+
+void FreeNSCRScreen(struct JsonToScreenOptions *options)
+{
+ free(options->data);
+ free(options);
+}
+
diff --git a/tools/nitrogfx/json.h b/tools/nitrogfx/json.h
index b7cabf93..f297cf08 100644
--- a/tools/nitrogfx/json.h
+++ b/tools/nitrogfx/json.h
@@ -6,6 +6,8 @@
#include "options.h"
struct JsonToCellOptions *ParseNCERJson(char *path);
+struct JsonToScreenOptions *ParseNSCRJson(char *path);
void FreeNCERCell(struct JsonToCellOptions *options);
+void FreeNSCRScreen(struct JsonToScreenOptions *options);
#endif //JSON_H
diff --git a/tools/nitrogfx/main.c b/tools/nitrogfx/main.c
index a2ddce6f..171cb5f3 100644
--- a/tools/nitrogfx/main.c
+++ b/tools/nitrogfx/main.c
@@ -686,6 +686,44 @@ void HandleJsonToNtrCellCommand(char *inputPath, char *outputPath, int argc UNUS
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;
@@ -945,6 +983,7 @@ int main(int argc, char **argv)
{ "fwjpnfont", "png", HandleFullwidthJapaneseFontToPngCommand },
{ "png", "fwjpnfont", HandlePngToFullwidthJapaneseFontCommand },
{ "json", "NCER", HandleJsonToNtrCellCommand },
+ { "json", "NSCR", HandleJsonToNtrScreenCommand },
{ NULL, "huff", HandleHuffCompressCommand },
{ NULL, "lz", HandleLZCompressCommand },
{ "huff", NULL, HandleHuffDecompressCommand },
diff --git a/tools/nitrogfx/options.h b/tools/nitrogfx/options.h
index 9b97529c..f4626df9 100644
--- a/tools/nitrogfx/options.h
+++ b/tools/nitrogfx/options.h
@@ -81,4 +81,11 @@ struct JsonToCellOptions {
struct Cell **cells;
};
+struct JsonToScreenOptions {
+ int height;
+ int width;
+ unsigned short *data;
+ int bitdepth;
+};
+
#endif // OPTIONS_H