diff --git a/gfx.c b/gfx.c index a87dae4..85a178b 100644 --- a/gfx.c +++ b/gfx.c @@ -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 diff --git a/json.c b/json.c index bcef5c0..1f89d15 100644 --- a/json.c +++ b/json.c @@ -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"); diff --git a/options.h b/options.h index 019b2fb..45015fc 100644 --- a/options.h +++ b/options.h @@ -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;