summaryrefslogtreecommitdiff
path: root/tools/nitrogfx/json.c
diff options
context:
space:
mode:
authorRevo <projectrevotpp@hotmail.com>2021-03-03 15:34:34 -0500
committerGitHub <noreply@github.com>2021-03-03 15:34:34 -0500
commit1d422e734eeec12d64cd965baa9aac310876a480 (patch)
treeca8602fde7a700e41a0eaa2a3c64316d41ee393f /tools/nitrogfx/json.c
parent2e2dbd18e4c191474b6582adef02a481451b51d5 (diff)
parent004604ad0146268c6d3d0d69ab6e5fb01ee74b06 (diff)
Merge pull request #323 from red031000/master
convert all 2d graphics in titledemo
Diffstat (limited to 'tools/nitrogfx/json.c')
-rw-r--r--tools/nitrogfx/json.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/tools/nitrogfx/json.c b/tools/nitrogfx/json.c
index fa9f9e5e..7804a2ba 100644
--- a/tools/nitrogfx/json.c
+++ b/tools/nitrogfx/json.c
@@ -174,6 +174,7 @@ struct JsonToScreenOptions *ParseNSCRJson(char *path)
cJSON *layer = NULL;
cJSON *layers = cJSON_GetObjectItemCaseSensitive(json, "layers");
+ int palette = 0;
cJSON_ArrayForEach(layer, layers)
{
cJSON *tile = NULL;
@@ -181,9 +182,19 @@ struct JsonToScreenOptions *ParseNSCRJson(char *path)
int i = 0;
cJSON_ArrayForEach(tile, data)
{
- options->data[i] = (short)(GetInt(tile) - 1); //TODO horizontal and vertical flips
+ int tileInt = GetInt(tile) - 1;
+ if (tileInt != -1)
+ {
+ bool vFlip = tileInt >> 30;
+ bool hFlip = tileInt >> 31;
+ tileInt |= vFlip << 11;
+ tileInt |= hFlip << 10;
+ tileInt |= palette << 12;
+ options->data[i] = (short) (tileInt & 0xFFFF);
+ }
i++;
}
+ palette++;
}
cJSON_Delete(json);