NCER cellAttrs

This commit is contained in:
red031000 2023-07-03 21:55:59 +01:00
parent 9b05753c29
commit 649aa24a6f
No known key found for this signature in database
GPG Key ID: D27E50C050AE0CE1
3 changed files with 31 additions and 5 deletions

7
gfx.c
View File

@ -828,8 +828,11 @@ void WriteNtrCell(char *path, struct JsonToCellOptions *options)
for (i = 0; i < options->cellCount * 0x10; i += 0x10)
{
KBECContents[i] = 0x01; //number of images
KBECContents[i + 2] = options->cells[i / 0x10]->readOnly & 0xff; //unknown
KBECContents[i + 3] = options->cells[i / 0x10]->readOnly >> 8;
short cellAttrs = (options->cells[i / 0x10]->attributes.hFlip << 8) | (options->cells[i / 0x10]->attributes.vFlip << 9)
| (options->cells[i / 0x10]->attributes.hvFlip << 10) | (options->cells[i / 0x10]->attributes.boundingRect << 11)
| (options->cells[i / 0x10]->attributes.boundingSphereRadius & 0x3F);
KBECContents[i + 2] = cellAttrs & 0xff; //cell attributes
KBECContents[i + 3] = cellAttrs >> 8;
KBECContents[i + 4] = (i / 0x10 * 6) & 0xff; //pointer to OAM data
KBECContents[i + 5] = (i / 0x10 * 6) >> 8; //unlikely to be more than 16 bits, but there are 32 allocated, change if necessary
KBECContents[i + 8] = options->cells[i / 0x10]->maxX & 0xff; //maxX

19
json.c
View File

@ -95,9 +95,24 @@ struct JsonToCellOptions *ParseNCERJson(char *path)
if (i > options->cellCount - 1)
FATAL_ERROR("Cell count is incorrect.\n");
cJSON *readOnly = cJSON_GetObjectItemCaseSensitive(cell, "readOnly");
cJSON *cellAttrs = cJSON_GetObjectItemCaseSensitive(cell, "cellAttrs");
cJSON *hFlip = cJSON_GetObjectItemCaseSensitive(cellAttrs, "hFlip");
cJSON *vFlip = cJSON_GetObjectItemCaseSensitive(cellAttrs, "vFlip");
cJSON *hvFlip = cJSON_GetObjectItemCaseSensitive(cellAttrs, "hvFlip");
options->cells[i]->attributes.hFlip = GetBool(hFlip);
options->cells[i]->attributes.vFlip = GetBool(vFlip);
options->cells[i]->attributes.hvFlip = GetBool(hvFlip);
cJSON *boundingRect = cJSON_GetObjectItemCaseSensitive(cellAttrs, "boundingRect");
options->cells[i]->attributes.boundingRect = GetBool(boundingRect);
cJSON *boundingSphereRadius = cJSON_GetObjectItemCaseSensitive(cellAttrs, "boundingSphereRadius");
options->cells[i]->attributes.boundingSphereRadius = GetInt(boundingSphereRadius);
options->cells[i]->readOnly = (short)GetInt(readOnly);
if (options->extended)
{
cJSON *maxX = cJSON_GetObjectItemCaseSensitive(cell, "maxX");

View File

@ -77,8 +77,16 @@ struct OAM {
struct Attr2 attr2;
};
struct CellAttributes {
bool hFlip; // 1 << 8
bool vFlip; // 1 << 9
bool hvFlip; // 1 << 10
bool boundingRect; // 1 << 11
int boundingSphereRadius; // 1 << 0 (6 bits);
};
struct Cell {
short readOnly;
struct CellAttributes attributes;
short maxX;
short maxY;
short minX;