summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorred031000 <rubenru09@aol.com>2021-03-30 22:46:46 +0100
committerred031000 <rubenru09@aol.com>2021-03-30 22:46:46 +0100
commit6a869e2a8fd8aab5c45a37ef38e3380c69e216b8 (patch)
tree1b56abf22d96e50a037e38fe93f6e575fb456e4b
parent5feba455f7b44720c5d8428dfdaf6de00faf020c (diff)
NCER multiple label support
-rw-r--r--files/poketool/icongra/poke_icon/.gitignore1
-rw-r--r--files/poketool/icongra/poke_icon/narc_0002.json12
-rw-r--r--files/poketool/icongra/poke_icon/narc_0004.NCERbin202 -> 0 bytes
-rw-r--r--files/poketool/icongra/poke_icon/narc_0004.json67
-rw-r--r--filesystem.mk1
-rw-r--r--graphics_rules.mk3
-rw-r--r--tools/nitrogfx/gfx.c31
-rw-r--r--tools/nitrogfx/json.c42
-rw-r--r--tools/nitrogfx/options.h5
9 files changed, 126 insertions, 36 deletions
diff --git a/files/poketool/icongra/poke_icon/.gitignore b/files/poketool/icongra/poke_icon/.gitignore
index 15216251..8f4afa7f 100644
--- a/files/poketool/icongra/poke_icon/.gitignore
+++ b/files/poketool/icongra/poke_icon/.gitignore
@@ -1,5 +1,6 @@
narc_0000.NCLR
narc_0002.NCER
+narc_0004.NCER
narc_0007.NCGR
narc_0008.NCGR
narc_0009.NCGR
diff --git a/files/poketool/icongra/poke_icon/narc_0002.json b/files/poketool/icongra/poke_icon/narc_0002.json
index a0d15511..defb5b41 100644
--- a/files/poketool/icongra/poke_icon/narc_0002.json
+++ b/files/poketool/icongra/poke_icon/narc_0002.json
@@ -1,5 +1,5 @@
{
- "label": true,
+ "labelEnabled": true,
"extended": true,
"imageHeight": 32,
"imageWidth": 32,
@@ -31,8 +31,7 @@
"Priority": 0,
"Palette": 0
}
- },
- "label": "CellAnime0"
+ }
},
{
"readOnly": 2054,
@@ -60,8 +59,9 @@
"Priority": 0,
"Palette": 0
}
- },
- "label": "CellAnime1"
+ }
}
- ]
+ ],
+ "labels": ["CellAnime0", "CellAnime1"],
+ "labelCount": 2
}
diff --git a/files/poketool/icongra/poke_icon/narc_0004.NCER b/files/poketool/icongra/poke_icon/narc_0004.NCER
deleted file mode 100644
index 10193211..00000000
--- a/files/poketool/icongra/poke_icon/narc_0004.NCER
+++ /dev/null
Binary files differ
diff --git a/files/poketool/icongra/poke_icon/narc_0004.json b/files/poketool/icongra/poke_icon/narc_0004.json
new file mode 100644
index 00000000..3d8b8b80
--- /dev/null
+++ b/files/poketool/icongra/poke_icon/narc_0004.json
@@ -0,0 +1,67 @@
+{
+ "labelEnabled": true,
+ "extended": true,
+ "imageHeight": 32,
+ "imageWidth": 32,
+ "cellCount": 2,
+ "cells": [
+ {
+ "readOnly": 2054,
+ "maxX": 15,
+ "maxY": 15,
+ "minX": 65520,
+ "minY": 65520,
+ "OAM": {
+ "Attr0": {
+ "YCoordinate": 240,
+ "Rotation": false,
+ "SizeDisable": false,
+ "Mode": 0,
+ "Mosaic": false,
+ "Colours": 16,
+ "Shape": 0
+ },
+ "Attr1": {
+ "XCoordinate": 496,
+ "RotationScaling": 0,
+ "Size": 2
+ },
+ "Attr2": {
+ "CharName": 0,
+ "Priority": 0,
+ "Palette": 0
+ }
+ }
+ },
+ {
+ "readOnly": 2054,
+ "maxX": 15,
+ "maxY": 15,
+ "minX": 65520,
+ "minY": 65520,
+ "OAM": {
+ "Attr0": {
+ "YCoordinate": 240,
+ "Rotation": false,
+ "SizeDisable": false,
+ "Mode": 0,
+ "Mosaic": false,
+ "Colours": 16,
+ "Shape": 0
+ },
+ "Attr1": {
+ "XCoordinate": 496,
+ "RotationScaling": 0,
+ "Size": 2
+ },
+ "Attr2": {
+ "CharName": 16,
+ "Priority": 0,
+ "Palette": 0
+ }
+ }
+ }
+ ],
+ "labels": ["CellAnime0", "CellAnime1", "CellAnime2", "CellAnime3", "CellAnime4", "CellAnime5"],
+ "labelCount": 6
+}
diff --git a/filesystem.mk b/filesystem.mk
index 8aaff73f..4264c367 100644
--- a/filesystem.mk
+++ b/filesystem.mk
@@ -2588,6 +2588,7 @@ files/poketool/pokegra/pokegra.narc: \
files/poketool/icongra/poke_icon.narc: \
files/poketool/icongra/poke_icon/narc_0000.NCLR \
files/poketool/icongra/poke_icon/narc_0002.NCER \
+ files/poketool/icongra/poke_icon/narc_0004.NCER \
files/poketool/icongra/poke_icon/narc_0007.NCGR \
files/poketool/icongra/poke_icon/narc_0008.NCGR \
files/poketool/icongra/poke_icon/narc_0009.NCGR \
diff --git a/graphics_rules.mk b/graphics_rules.mk
index dd2525f1..8abbbbaa 100644
--- a/graphics_rules.mk
+++ b/graphics_rules.mk
@@ -880,7 +880,8 @@ NCLR_CLEAN_LIST := files/application/wifi_earth/wifi_earth/narc_0006.NCLR \
files/poketool/trgra/trfgra/narc_0192.NCLR \
files/poketool/trgra/trfgra/narc_0194.NCLR \
-NCER_CLEAN_LIST := files/poketool/icongra/poke_icon/narc_0002.NCER
+NCER_CLEAN_LIST := files/poketool/icongra/poke_icon/narc_0002.NCER \
+ files/poketool/icongra/poke_icon/narc_0004.NCER
NSCR_CLEAN_LIST := files/demo/title/titledemo/narc_0000.NSCR \
files/demo/title/titledemo/narc_0008.NSCR \
diff --git a/tools/nitrogfx/gfx.c b/tools/nitrogfx/gfx.c
index be01a456..305fbeb2 100644
--- a/tools/nitrogfx/gfx.c
+++ b/tools/nitrogfx/gfx.c
@@ -744,16 +744,17 @@ void WriteNtrCell(char *path, struct JsonToCellOptions *options)
if (fp == NULL)
FATAL_ERROR("Failed to open \"%s\" for writing.\n", path);
- unsigned int totalSize = (options->label > 0 ? 0x34 : 0x20) + options->cellCount * (options->extended ? 0x16 : 0xe);
+ unsigned int totalSize = (options->labelEnabled > 0 ? 0x34 : 0x20) + options->cellCount * (options->extended ? 0x16 : 0xe);
- if (options->label)
+ if (options->labelEnabled)
{
- for (int i = 0; i < options->cellCount; i++) {
- totalSize += strlen(options->cells[i]->label) + 5; //strlen + terminator + pointer
+ for (int j = 0; j < options->labelCount; j++)
+ {
+ totalSize += strlen(options->labels[j]) + 5; //strlen + terminator + pointer
}
}
- WriteGenericNtrHeader(fp, "RECN", totalSize, true, false, options->label ? 3 : 1);
+ WriteGenericNtrHeader(fp, "RECN", totalSize, true, false, options->labelEnabled ? 3 : 1);
unsigned char KBECHeader[0x20] =
{
@@ -858,12 +859,12 @@ void WriteNtrCell(char *path, struct JsonToCellOptions *options)
free(KBECContents);
- if (options->label)
+ if (options->labelEnabled)
{
- unsigned int lablSize = 8 + options->cellCount * 4;
- for (i = 0; i < options->cellCount; i++)
+ unsigned int lablSize = 8;
+ for (int j = 0; j < options->labelCount; j++)
{
- lablSize += strlen(options->cells[i]->label) + 1;
+ lablSize += strlen(options->labels[j]) + 5;
}
unsigned char *labl = malloc(lablSize);
@@ -876,18 +877,20 @@ void WriteNtrCell(char *path, struct JsonToCellOptions *options)
unsigned int position = 0;
- for (i = 0; i < options->cellCount * 4; i += 4)
+ i = 0;
+ for (int j = 0; j < options->labelCount; j++)
{
labl[i + 8] = position & 0xff;
labl[i + 9] = position >> 8;
- position += strlen(options->cells[i / 4]->label) + 1;
+ position += strlen(options->labels[j]) + 1;
+ i += 4;
}
- for (int j = 0; j < options->cellCount; j++)
+ for (int j = 0; j < options->labelCount; j++)
{
- strcpy((char *) (labl + (i + 8)), options->cells[j]->label);
- i += strlen(options->cells[j]->label) + 1;
+ strcpy((char *) (labl + (i + 8)), options->labels[j]);
+ i += strlen(options->labels[j]) + 1;
}
fwrite(labl, 1, lablSize, fp);
diff --git a/tools/nitrogfx/json.c b/tools/nitrogfx/json.c
index 53f83ceb..aad325be 100644
--- a/tools/nitrogfx/json.c
+++ b/tools/nitrogfx/json.c
@@ -46,13 +46,13 @@ struct JsonToCellOptions *ParseNCERJson(char *path)
FATAL_ERROR("Error in line \"%s\"\n", errorPtr);
}
- cJSON *labelBool = cJSON_GetObjectItemCaseSensitive(json, "label");
+ cJSON *labelBool = cJSON_GetObjectItemCaseSensitive(json, "labelEnabled");
cJSON *extended = cJSON_GetObjectItemCaseSensitive(json, "extended");
cJSON *imageHeight = cJSON_GetObjectItemCaseSensitive(json, "imageHeight");
cJSON *imageWidth = cJSON_GetObjectItemCaseSensitive(json, "imageWidth");
cJSON *cellCount = cJSON_GetObjectItemCaseSensitive(json, "cellCount");
- options->label = GetBool(labelBool);
+ options->labelEnabled = GetBool(labelBool);
options->extended = GetBool(extended);
options->imageHeight = GetInt(imageHeight);
options->imageWidth = GetInt(imageWidth);
@@ -60,6 +60,26 @@ struct JsonToCellOptions *ParseNCERJson(char *path)
options->cells = malloc(sizeof(struct Cell *) * options->cellCount);
+
+ if (options->labelEnabled)
+ {
+ cJSON *labelCount = cJSON_GetObjectItemCaseSensitive(json, "labelCount");
+ options->labelCount = GetInt(labelCount);
+ options->labels = malloc(sizeof(char *) * options->labelCount);
+
+ cJSON *labels = cJSON_GetObjectItemCaseSensitive(json, "labels");
+ cJSON *label = NULL;
+
+ int j = 0;
+ cJSON_ArrayForEach(label, labels)
+ {
+ char *labelString = GetString(label);
+ options->labels[j] = malloc(strlen(labelString) + 1);
+ strcpy(options->labels[j], labelString);
+ j++;
+ }
+ }
+
for (int i = 0; i < options->cellCount; i++)
{
options->cells[i] = malloc(sizeof(struct Cell));
@@ -89,14 +109,6 @@ struct JsonToCellOptions *ParseNCERJson(char *path)
options->cells[i]->minX = (short)GetInt(minX);
options->cells[i]->minY = (short)GetInt(minY);
}
-
- if (options->label)
- {
- cJSON *label = cJSON_GetObjectItemCaseSensitive(cell, "label");
- char *labelString = GetString(label);
- options->cells[i]->label = malloc(strlen(labelString) + 1);
- strcpy(options->cells[i]->label, labelString);
- }
//OAM data
cJSON *OAM = cJSON_GetObjectItemCaseSensitive(cell, "OAM");
@@ -221,11 +233,15 @@ void FreeNCERCell(struct JsonToCellOptions *options)
{
for (int i = 0; i < options->cellCount; i++)
{
- if (options->label)
+ free(options->cells[i]);
+ }
+ if (options->labelEnabled)
+ {
+ for (int j = 0; j < options->labelCount; j++)
{
- free(options->cells[i]->label);
+ free(options->labels[j]);
}
- free(options->cells[i]);
+ free(options->labels);
}
free(options);
}
diff --git a/tools/nitrogfx/options.h b/tools/nitrogfx/options.h
index f4626df9..780c83e6 100644
--- a/tools/nitrogfx/options.h
+++ b/tools/nitrogfx/options.h
@@ -69,16 +69,17 @@ struct Cell {
short minX;
short minY;
struct OAM oam;
- char *label;
};
struct JsonToCellOptions {
- bool label;
+ bool labelEnabled;
bool extended;
int imageHeight;
int imageWidth;
int cellCount;
struct Cell **cells;
+ char **labels;
+ int labelCount;
};
struct JsonToScreenOptions {