From e556f01d721d6df03a2679137df0db4cf01eeb3b Mon Sep 17 00:00:00 2001 From: red031000 Date: Sat, 3 Feb 2024 01:43:36 +0000 Subject: [PATCH] update nitrogfx --- tools/nitrogfx/LICENSE | 2 +- tools/nitrogfx/gfx.c | 292 ++++++++++++++++++++------------------- tools/nitrogfx/gfx.h | 31 ++++- tools/nitrogfx/json.c | 11 +- tools/nitrogfx/json.h | 2 +- tools/nitrogfx/main.c | 140 ++++++++++--------- tools/nitrogfx/options.h | 18 +-- 7 files changed, 261 insertions(+), 235 deletions(-) diff --git a/tools/nitrogfx/LICENSE b/tools/nitrogfx/LICENSE index 1575ad654..be4a59938 100644 --- a/tools/nitrogfx/LICENSE +++ b/tools/nitrogfx/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2015 YamaArashi, 2021-2023 red031000 +Copyright (c) 2015 YamaArashi, 2021-2024 red031000 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/tools/nitrogfx/gfx.c b/tools/nitrogfx/gfx.c index 814ae20b6..d8981fa9d 100644 --- a/tools/nitrogfx/gfx.c +++ b/tools/nitrogfx/gfx.c @@ -1,4 +1,4 @@ -// Copyright (c) 2015 YamaArashi, 2021-2023 red031000 +// Copyright (c) 2015 YamaArashi, 2021-2024 red031000 #include #include @@ -19,37 +19,37 @@ #define DOWNCONVERT_BIT_DEPTH(x) ((x) / 8) -static void AdvanceMetatilePosition(int *subTileX, int *subTileY, int *metatileX, int *metatileY, int metatilesWide, int metatileWidth, int metatileHeight) +static void AdvanceTilePosition(int *tilesSoFar, int *rowsSoFar, int *chunkStartX, int *chunkStartY, int chunksWide, int colsPerChunk, int rowsPerChunk) { - (*subTileX)++; - if (*subTileX == metatileWidth) { - *subTileX = 0; - (*subTileY)++; - if (*subTileY == metatileHeight) { - *subTileY = 0; - (*metatileX)++; - if (*metatileX == metatilesWide) { - *metatileX = 0; - (*metatileY)++; + (*tilesSoFar)++; + if (*tilesSoFar == colsPerChunk) { + *tilesSoFar = 0; + (*rowsSoFar)++; + if (*rowsSoFar == rowsPerChunk) { + *rowsSoFar = 0; + (*chunkStartX)++; + if (*chunkStartX == chunksWide) { + *chunkStartX = 0; + (*chunkStartY)++; } } } } -static void ConvertFromTiles1Bpp(unsigned char *src, unsigned char *dest, int numTiles, int metatilesWide, int metatileWidth, int metatileHeight, bool invertColors) +static void ConvertFromTiles1Bpp(unsigned char *src, unsigned char *dest, int numTiles, int chunksWide, int colsPerChunk, int rowsPerChunk, bool invertColors) { - int subTileX = 0; - int subTileY = 0; - int metatileX = 0; - int metatileY = 0; - int pitch = metatilesWide * metatileWidth; + int tilesSoFar = 0; + int rowsSoFar = 0; + int chunkStartX = 0; + int chunkStartY = 0; + int pitch = chunksWide * colsPerChunk; for (int i = 0; i < numTiles; i++) { for (int j = 0; j < 8; j++) { - int destY = (metatileY * metatileHeight + subTileY) * 8 + j; - int destX = metatileX * metatileWidth + subTileX; + int idxComponentY = (chunkStartY * rowsPerChunk + rowsSoFar) * 8 + j; + int idxComponentX = chunkStartX * colsPerChunk + tilesSoFar; unsigned char srcPixelOctet = *src++; - unsigned char *destPixelOctet = &dest[destY * pitch + destX]; + unsigned char *destPixelOctet = &dest[idxComponentY * pitch + idxComponentX]; for (int k = 0; k < 8; k++) { *destPixelOctet <<= 1; @@ -58,24 +58,24 @@ static void ConvertFromTiles1Bpp(unsigned char *src, unsigned char *dest, int nu } } - AdvanceMetatilePosition(&subTileX, &subTileY, &metatileX, &metatileY, metatilesWide, metatileWidth, metatileHeight); + AdvanceTilePosition(&tilesSoFar, &rowsSoFar, &chunkStartX, &chunkStartY, chunksWide, colsPerChunk, rowsPerChunk); } } -static void ConvertFromTiles4Bpp(unsigned char *src, unsigned char *dest, int numTiles, int metatilesWide, int metatileWidth, int metatileHeight, bool invertColors) +static void ConvertFromTiles4Bpp(unsigned char *src, unsigned char *dest, int numTiles, int chunksWide, int colsPerChunk, int rowsPerChunk, bool invertColors) { - int subTileX = 0; - int subTileY = 0; - int metatileX = 0; - int metatileY = 0; - int pitch = (metatilesWide * metatileWidth) * 4; + int tilesSoFar = 0; + int rowsSoFar = 0; + int chunkStartX = 0; + int chunkStartY = 0; + int pitch = (chunksWide * colsPerChunk) * 4; for (int i = 0; i < numTiles; i++) { for (int j = 0; j < 8; j++) { - int destY = (metatileY * metatileHeight + subTileY) * 8 + j; + int idxComponentY = (chunkStartY * rowsPerChunk + rowsSoFar) * 8 + j; for (int k = 0; k < 4; k++) { - int destX = (metatileX * metatileWidth + subTileX) * 4 + k; + int idxComponentX = (chunkStartX * colsPerChunk + tilesSoFar) * 4 + k; unsigned char srcPixelPair = *src++; unsigned char leftPixel = srcPixelPair & 0xF; unsigned char rightPixel = srcPixelPair >> 4; @@ -85,11 +85,11 @@ static void ConvertFromTiles4Bpp(unsigned char *src, unsigned char *dest, int nu rightPixel = 15 - rightPixel; } - dest[destY * pitch + destX] = (leftPixel << 4) | rightPixel; + dest[idxComponentY * pitch + idxComponentX] = (leftPixel << 4) | rightPixel; } } - AdvanceMetatilePosition(&subTileX, &subTileY, &metatileX, &metatileY, metatilesWide, metatileWidth, metatileHeight); + AdvanceTilePosition(&tilesSoFar, &rowsSoFar, &chunkStartX, &chunkStartY, chunksWide, colsPerChunk, rowsPerChunk); } } @@ -135,30 +135,30 @@ static uint32_t ConvertFromScanned4Bpp(unsigned char *src, unsigned char *dest, return encValue; } -static void ConvertFromTiles8Bpp(unsigned char *src, unsigned char *dest, int numTiles, int metatilesWide, int metatileWidth, int metatileHeight, bool invertColors) +static void ConvertFromTiles8Bpp(unsigned char *src, unsigned char *dest, int numTiles, int chunksWide, int colsPerChunk, int rowsPerChunk, bool invertColors) { - int subTileX = 0; - int subTileY = 0; - int metatileX = 0; - int metatileY = 0; - int pitch = (metatilesWide * metatileWidth) * 8; + int tilesSoFar = 0; + int rowsSoFar = 0; + int chunkStartX = 0; + int chunkStartY = 0; + int pitch = (chunksWide * colsPerChunk) * 8; for (int i = 0; i < numTiles; i++) { for (int j = 0; j < 8; j++) { - int destY = (metatileY * metatileHeight + subTileY) * 8 + j; + int idxComponentY = (chunkStartY * rowsPerChunk + rowsSoFar) * 8 + j; for (int k = 0; k < 8; k++) { - int destX = (metatileX * metatileWidth + subTileX) * 8 + k; + int idxComponentX = (chunkStartX * colsPerChunk + tilesSoFar) * 8 + k; unsigned char srcPixel = *src++; if (invertColors) srcPixel = 255 - srcPixel; - dest[destY * pitch + destX] = srcPixel; + dest[idxComponentY * pitch + idxComponentX] = srcPixel; } } - AdvanceMetatilePosition(&subTileX, &subTileY, &metatileX, &metatileY, metatilesWide, metatileWidth, metatileHeight); + AdvanceTilePosition(&tilesSoFar, &rowsSoFar, &chunkStartX, &chunkStartY, chunksWide, colsPerChunk, rowsPerChunk); } } @@ -201,19 +201,19 @@ static uint32_t ConvertFromScanned8Bpp(unsigned char *src, unsigned char *dest, return encValue; } -static void ConvertToTiles1Bpp(unsigned char *src, unsigned char *dest, int numTiles, int metatilesWide, int metatileWidth, int metatileHeight, bool invertColors) +static void ConvertToTiles1Bpp(unsigned char *src, unsigned char *dest, int numTiles, int chunksWide, int colsPerChunk, int rowsPerChunk, bool invertColors) { - int subTileX = 0; - int subTileY = 0; - int metatileX = 0; - int metatileY = 0; - int pitch = metatilesWide * metatileWidth; + int tilesSoFar = 0; + int rowsSoFar = 0; + int chunkStartX = 0; + int chunkStartY = 0; + int pitch = chunksWide * colsPerChunk; for (int i = 0; i < numTiles; i++) { for (int j = 0; j < 8; j++) { - int srcY = (metatileY * metatileHeight + subTileY) * 8 + j; - int srcX = metatileX * metatileWidth + subTileX; - unsigned char srcPixelOctet = src[srcY * pitch + srcX]; + int idxComponentY = (chunkStartY * rowsPerChunk + rowsSoFar) * 8 + j; + int idxComponentX = chunkStartX * colsPerChunk + tilesSoFar; + unsigned char srcPixelOctet = src[idxComponentY * pitch + idxComponentX]; unsigned char *destPixelOctet = dest++; for (int k = 0; k < 8; k++) { @@ -223,25 +223,25 @@ static void ConvertToTiles1Bpp(unsigned char *src, unsigned char *dest, int numT } } - AdvanceMetatilePosition(&subTileX, &subTileY, &metatileX, &metatileY, metatilesWide, metatileWidth, metatileHeight); + AdvanceTilePosition(&tilesSoFar, &rowsSoFar, &chunkStartX, &chunkStartY, chunksWide, colsPerChunk, rowsPerChunk); } } -static void ConvertToTiles4Bpp(unsigned char *src, unsigned char *dest, int numTiles, int metatilesWide, int metatileWidth, int metatileHeight, bool invertColors) +static void ConvertToTiles4Bpp(unsigned char *src, unsigned char *dest, int numTiles, int chunksWide, int colsPerChunk, int rowsPerChunk, bool invertColors) { - int subTileX = 0; - int subTileY = 0; - int metatileX = 0; - int metatileY = 0; - int pitch = (metatilesWide * metatileWidth) * 4; + int tilesSoFar = 0; + int rowsSoFar = 0; + int chunkStartX = 0; + int chunkStartY = 0; + int pitch = (chunksWide * colsPerChunk) * 4; for (int i = 0; i < numTiles; i++) { for (int j = 0; j < 8; j++) { - int srcY = (metatileY * metatileHeight + subTileY) * 8 + j; + int idxComponentY = (chunkStartY * rowsPerChunk + rowsSoFar) * 8 + j; for (int k = 0; k < 4; k++) { - int srcX = (metatileX * metatileWidth + subTileX) * 4 + k; - unsigned char srcPixelPair = src[srcY * pitch + srcX]; + int idxComponentX = (chunkStartX * colsPerChunk + tilesSoFar) * 4 + k; + unsigned char srcPixelPair = src[idxComponentY * pitch + idxComponentX]; unsigned char leftPixel = srcPixelPair >> 4; unsigned char rightPixel = srcPixelPair & 0xF; @@ -254,7 +254,7 @@ static void ConvertToTiles4Bpp(unsigned char *src, unsigned char *dest, int numT } } - AdvanceMetatilePosition(&subTileX, &subTileY, &metatileX, &metatileY, metatilesWide, metatileWidth, metatileHeight); + AdvanceTilePosition(&tilesSoFar, &rowsSoFar, &chunkStartX, &chunkStartY, chunksWide, colsPerChunk, rowsPerChunk); } } @@ -294,21 +294,21 @@ static void ConvertToScanned4Bpp(unsigned char *src, unsigned char *dest, int fi } } -static void ConvertToTiles8Bpp(unsigned char *src, unsigned char *dest, int numTiles, int metatilesWide, int metatileWidth, int metatileHeight, bool invertColors) +static void ConvertToTiles8Bpp(unsigned char *src, unsigned char *dest, int numTiles, int chunksWide, int colsPerChunk, int rowsPerChunk, bool invertColors) { - int subTileX = 0; - int subTileY = 0; - int metatileX = 0; - int metatileY = 0; - int pitch = (metatilesWide * metatileWidth) * 8; + int tilesSoFar = 0; + int rowsSoFar = 0; + int chunkStartX = 0; + int chunkStartY = 0; + int pitch = (chunksWide * colsPerChunk) * 8; for (int i = 0; i < numTiles; i++) { for (int j = 0; j < 8; j++) { - int srcY = (metatileY * metatileHeight + subTileY) * 8 + j; + int idxComponentY = (chunkStartY * rowsPerChunk + rowsSoFar) * 8 + j; for (int k = 0; k < 8; k++) { - int srcX = (metatileX * metatileWidth + subTileX) * 8 + k; - unsigned char srcPixel = src[srcY * pitch + srcX]; + int idxComponentX = (chunkStartX * colsPerChunk + tilesSoFar) * 8 + k; + unsigned char srcPixel = src[idxComponentY * pitch + idxComponentX]; if (invertColors) srcPixel = 255 - srcPixel; @@ -317,53 +317,53 @@ static void ConvertToTiles8Bpp(unsigned char *src, unsigned char *dest, int numT } } - AdvanceMetatilePosition(&subTileX, &subTileY, &metatileX, &metatileY, metatilesWide, metatileWidth, metatileHeight); + AdvanceTilePosition(&tilesSoFar, &rowsSoFar, &chunkStartX, &chunkStartY, chunksWide, colsPerChunk, rowsPerChunk); } } -void ReadImage(char *path, int tilesWidth, int bitDepth, int metatileWidth, int metatileHeight, struct Image *image, bool invertColors) +void ReadImage(char *path, int tilesWide, int bitDepth, int colsPerChunk, int rowsPerChunk, struct Image *image, bool invertColors) { - int tileSize = bitDepth * 8; + int tileSize = bitDepth * 8; // number of bytes per tile int fileSize; unsigned char *buffer = ReadWholeFile(path, &fileSize); int numTiles = fileSize / tileSize; - int tilesHeight = (numTiles + tilesWidth - 1) / tilesWidth; + int tilesTall = (numTiles + tilesWide - 1) / tilesWide; - if (tilesWidth % metatileWidth != 0) - FATAL_ERROR("The width in tiles (%d) isn't a multiple of the specified metatile width (%d)", tilesWidth, metatileWidth); + if (tilesWide % colsPerChunk != 0) + FATAL_ERROR("The width in tiles (%d) isn't a multiple of the specified tiles per row (%d)", tilesWide, colsPerChunk); - if (tilesHeight % metatileHeight != 0) - FATAL_ERROR("The height in tiles (%d) isn't a multiple of the specified metatile height (%d)", tilesHeight, metatileHeight); + if (tilesTall % rowsPerChunk != 0) + FATAL_ERROR("The height in tiles (%d) isn't a multiple of the specified rows per chunk (%d)", tilesTall, rowsPerChunk); - image->width = tilesWidth * 8; - image->height = tilesHeight * 8; + image->width = tilesWide * 8; + image->height = tilesTall * 8; image->bitDepth = bitDepth; - image->pixels = calloc(tilesWidth * tilesHeight, tileSize); + image->pixels = calloc(tilesWide * tilesTall, tileSize); if (image->pixels == NULL) FATAL_ERROR("Failed to allocate memory for pixels.\n"); - int metatilesWide = tilesWidth / metatileWidth; + int chunksWide = tilesWide / colsPerChunk; // how many chunks side-by-side are needed for the full width of the image switch (bitDepth) { case 1: - ConvertFromTiles1Bpp(buffer, image->pixels, numTiles, metatilesWide, metatileWidth, metatileHeight, invertColors); + ConvertFromTiles1Bpp(buffer, image->pixels, numTiles, chunksWide, colsPerChunk, rowsPerChunk, invertColors); break; case 4: - ConvertFromTiles4Bpp(buffer, image->pixels, numTiles, metatilesWide, metatileWidth, metatileHeight, invertColors); + ConvertFromTiles4Bpp(buffer, image->pixels, numTiles, chunksWide, colsPerChunk, rowsPerChunk, invertColors); break; case 8: - ConvertFromTiles8Bpp(buffer, image->pixels, numTiles, metatilesWide, metatileWidth, metatileHeight, invertColors); + ConvertFromTiles8Bpp(buffer, image->pixels, numTiles, chunksWide, colsPerChunk, rowsPerChunk, invertColors); break; } free(buffer); } -uint32_t ReadNtrImage(char *path, int tilesWidth, int bitDepth, int metatileWidth, int metatileHeight, struct Image *image, bool invertColors, bool scanFrontToBack) +uint32_t ReadNtrImage(char *path, int tilesWide, int bitDepth, int colsPerChunk, int rowsPerChunk, struct Image *image, bool invertColors, bool scanFrontToBack) { int fileSize; unsigned char *buffer = ReadWholeFile(path, &fileSize); @@ -391,37 +391,37 @@ uint32_t ReadNtrImage(char *path, int tilesWidth, int bitDepth, int metatileWidt bool scanned = charHeader[0x14]; - int tileSize = bitDepth * 8; + int tileSize = bitDepth * 8; // number of bytes per tile - if (tilesWidth == 0) { - tilesWidth = ReadS16(charHeader, 0xA); - if (tilesWidth < 0) { - tilesWidth = 1; + if (tilesWide == 0) { + tilesWide = ReadS16(charHeader, 0xA); + if (tilesWide < 0) { + tilesWide = 1; } } int numTiles = ReadS32(charHeader, 0x18) / (64 / (8 / bitDepth)); - int tilesHeight = ReadS16(charHeader, 0x8); - if (tilesHeight < 0) - tilesHeight = (numTiles + tilesWidth - 1) / tilesWidth; + int tilesTall = ReadS16(charHeader, 0x8); + if (tilesTall < 0) + tilesTall = (numTiles + tilesWide - 1) / tilesWide; - if (tilesWidth % metatileWidth != 0) - FATAL_ERROR("The width in tiles (%d) isn't a multiple of the specified metatile width (%d)", tilesWidth, metatileWidth); + if (tilesWide % colsPerChunk != 0) + FATAL_ERROR("The width in tiles (%d) isn't a multiple of the specified tiles per row (%d)", tilesWide, colsPerChunk); - if (tilesHeight % metatileHeight != 0) - FATAL_ERROR("The height in tiles (%d) isn't a multiple of the specified metatile height (%d)", tilesHeight, metatileHeight); + if (tilesTall % rowsPerChunk != 0) + FATAL_ERROR("The height in tiles (%d) isn't a multiple of the specified rows per chunk (%d)", tilesTall, rowsPerChunk); - image->width = tilesWidth * 8; - image->height = tilesHeight * 8; + image->width = tilesWide * 8; + image->height = tilesTall * 8; image->bitDepth = bitDepth; - image->pixels = calloc(tilesWidth * tilesHeight, tileSize); + image->pixels = calloc(tilesWide * tilesTall, tileSize); if (image->pixels == NULL) FATAL_ERROR("Failed to allocate memory for pixels.\n"); - int metatilesWide = tilesWidth / metatileWidth; + int chunksWide = tilesWide / colsPerChunk; // how many chunks side-by-side are needed for the full width of the image uint32_t key = 0; if (scanned) @@ -441,11 +441,11 @@ uint32_t ReadNtrImage(char *path, int tilesWidth, int bitDepth, int metatileWidt switch (bitDepth) { case 4: - ConvertFromTiles4Bpp(imageData, image->pixels, numTiles, metatilesWide, metatileWidth, metatileHeight, + ConvertFromTiles4Bpp(imageData, image->pixels, numTiles, chunksWide, colsPerChunk, rowsPerChunk, invertColors); break; case 8: - ConvertFromTiles8Bpp(imageData, image->pixels, numTiles, metatilesWide, metatileWidth, metatileHeight, + ConvertFromTiles8Bpp(imageData, image->pixels, numTiles, chunksWide, colsPerChunk, rowsPerChunk, invertColors); break; } @@ -455,9 +455,9 @@ uint32_t ReadNtrImage(char *path, int tilesWidth, int bitDepth, int metatileWidt return key; } -void WriteImage(char *path, int numTiles, int bitDepth, int metatileWidth, int metatileHeight, struct Image *image, bool invertColors) +void WriteImage(char *path, int numTiles, int bitDepth, int colsPerChunk, int rowsPerChunk, struct Image *image, bool invertColors) { - int tileSize = bitDepth * 8; + int tileSize = bitDepth * 8; // number of bytes per tile if (image->width % 8 != 0) FATAL_ERROR("The width in pixels (%d) isn't a multiple of 8.\n", image->width); @@ -465,16 +465,16 @@ void WriteImage(char *path, int numTiles, int bitDepth, int metatileWidth, int m if (image->height % 8 != 0) FATAL_ERROR("The height in pixels (%d) isn't a multiple of 8.\n", image->height); - int tilesWidth = image->width / 8; - int tilesHeight = image->height / 8; + int tilesWide = image->width / 8; // how many tiles wide the image is + int tilesTall = image->height / 8; // how many tiles tall the image is - if (tilesWidth % metatileWidth != 0) - FATAL_ERROR("The width in tiles (%d) isn't a multiple of the specified metatile width (%d)", tilesWidth, metatileWidth); + if (tilesWide % colsPerChunk != 0) + FATAL_ERROR("The width in tiles (%d) isn't a multiple of the specified tiles per row (%d)", tilesWide, colsPerChunk); - if (tilesHeight % metatileHeight != 0) - FATAL_ERROR("The height in tiles (%d) isn't a multiple of the specified metatile height (%d)", tilesHeight, metatileHeight); + if (tilesTall % rowsPerChunk != 0) + FATAL_ERROR("The height in tiles (%d) isn't a multiple of the specified rows per chunk (%d)", tilesTall, rowsPerChunk); - int maxNumTiles = tilesWidth * tilesHeight; + int maxNumTiles = tilesWide * tilesTall; if (numTiles == 0) numTiles = maxNumTiles; @@ -487,17 +487,17 @@ void WriteImage(char *path, int numTiles, int bitDepth, int metatileWidth, int m if (buffer == NULL) FATAL_ERROR("Failed to allocate memory for pixels.\n"); - int metatilesWide = tilesWidth / metatileWidth; + int chunksWide = tilesWide / colsPerChunk; // how many chunks side-by-side are needed for the full width of the image switch (bitDepth) { case 1: - ConvertToTiles1Bpp(image->pixels, buffer, numTiles, metatilesWide, metatileWidth, metatileHeight, invertColors); + ConvertToTiles1Bpp(image->pixels, buffer, numTiles, chunksWide, colsPerChunk, rowsPerChunk, invertColors); break; case 4: - ConvertToTiles4Bpp(image->pixels, buffer, numTiles, metatilesWide, metatileWidth, metatileHeight, invertColors); + ConvertToTiles4Bpp(image->pixels, buffer, numTiles, chunksWide, colsPerChunk, rowsPerChunk, invertColors); break; case 8: - ConvertToTiles8Bpp(image->pixels, buffer, numTiles, metatilesWide, metatileWidth, metatileHeight, invertColors); + ConvertToTiles8Bpp(image->pixels, buffer, numTiles, chunksWide, colsPerChunk, rowsPerChunk, invertColors); break; } @@ -506,7 +506,7 @@ void WriteImage(char *path, int numTiles, int bitDepth, int metatileWidth, int m free(buffer); } -void WriteNtrImage(char *path, int numTiles, int bitDepth, int metatileWidth, int metatileHeight, struct Image *image, +void WriteNtrImage(char *path, int numTiles, int bitDepth, int colsPerChunk, int rowsPerChunk, struct Image *image, bool invertColors, bool clobberSize, bool byteOrder, bool version101, bool sopc, bool vram, uint32_t scanMode, uint32_t mappingType, uint32_t key, bool wrongSize) { @@ -515,7 +515,7 @@ void WriteNtrImage(char *path, int numTiles, int bitDepth, int metatileWidth, in if (fp == NULL) FATAL_ERROR("Failed to open \"%s\" for writing.\n", path); - int tileSize = bitDepth * 8; + int tileSize = bitDepth * 8; // number of bytes per tile if (image->width % 8 != 0) FATAL_ERROR("The width in pixels (%d) isn't a multiple of 8.\n", image->width); @@ -523,16 +523,16 @@ void WriteNtrImage(char *path, int numTiles, int bitDepth, int metatileWidth, in if (image->height % 8 != 0) FATAL_ERROR("The height in pixels (%d) isn't a multiple of 8.\n", image->height); - int tilesWidth = image->width / 8; - int tilesHeight = image->height / 8; + int tilesWide = image->width / 8; // how many tiles wide the image is + int tilesTall = image->height / 8; // how many tiles tall the image is - if (tilesWidth % metatileWidth != 0) - FATAL_ERROR("The width in tiles (%d) isn't a multiple of the specified metatile width (%d)", tilesWidth, metatileWidth); + if (tilesWide % colsPerChunk != 0) + FATAL_ERROR("The width in tiles (%d) isn't a multiple of the specified tiles per row (%d)", tilesWide, colsPerChunk); - if (tilesHeight % metatileHeight != 0) - FATAL_ERROR("The height in tiles (%d) isn't a multiple of the specified metatile height (%d)", tilesHeight, metatileHeight); + if (tilesTall % rowsPerChunk != 0) + FATAL_ERROR("The height in tiles (%d) isn't a multiple of the specified rows per chunk (%d)", tilesTall, rowsPerChunk); - int maxNumTiles = tilesWidth * tilesHeight; + int maxNumTiles = tilesWide * tilesTall; if (numTiles == 0) numTiles = maxNumTiles; @@ -545,7 +545,7 @@ void WriteNtrImage(char *path, int numTiles, int bitDepth, int metatileWidth, in if (pixelBuffer == NULL) FATAL_ERROR("Failed to allocate memory for pixels.\n"); - int metatilesWide = tilesWidth / metatileWidth; + int chunksWide = tilesWide / colsPerChunk; // how many chunks side-by-side are needed for the full width of the image if (scanMode) { @@ -564,11 +564,11 @@ void WriteNtrImage(char *path, int numTiles, int bitDepth, int metatileWidth, in switch (bitDepth) { case 4: - ConvertToTiles4Bpp(image->pixels, pixelBuffer, numTiles, metatilesWide, metatileWidth, metatileHeight, + ConvertToTiles4Bpp(image->pixels, pixelBuffer, numTiles, chunksWide, colsPerChunk, rowsPerChunk, invertColors); break; case 8: - ConvertToTiles8Bpp(image->pixels, pixelBuffer, numTiles, metatilesWide, metatileWidth, metatileHeight, + ConvertToTiles8Bpp(image->pixels, pixelBuffer, numTiles, chunksWide, colsPerChunk, rowsPerChunk, invertColors); break; } @@ -586,11 +586,11 @@ void WriteNtrImage(char *path, int numTiles, int bitDepth, int metatileWidth, in if (!clobberSize) { - charHeader[8] = tilesHeight & 0xFF; - charHeader[9] = (tilesHeight >> 8) & 0xFF; + charHeader[8] = tilesTall & 0xFF; + charHeader[9] = (tilesTall >> 8) & 0xFF; - charHeader[10] = tilesWidth & 0xFF; - charHeader[11] = (tilesWidth >> 8) & 0xFF; + charHeader[10] = tilesWide & 0xFF; + charHeader[11] = (tilesWide >> 8) & 0xFF; } else { @@ -655,11 +655,11 @@ void WriteNtrImage(char *path, int numTiles, int bitDepth, int metatileWidth, in { unsigned char sopcBuffer[0x10] = { 0x53, 0x4F, 0x50, 0x43, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - sopcBuffer[12] = tilesWidth & 0xFF; - sopcBuffer[13] = (tilesWidth >> 8) & 0xFF; + sopcBuffer[12] = tilesWide & 0xFF; + sopcBuffer[13] = (tilesWide >> 8) & 0xFF; - sopcBuffer[14] = tilesHeight & 0xFF; - sopcBuffer[15] = (tilesHeight >> 8) & 0xFF; + sopcBuffer[14] = tilesTall & 0xFF; + sopcBuffer[15] = (tilesTall >> 8) & 0xFF; fwrite(sopcBuffer, 1, 0x10, fp); } @@ -719,9 +719,11 @@ void ReadNtrPalette(char *path, struct Palette *palette, int bitdepth, int palIn bitdepth = bitdepth ? bitdepth : palette->bitDepth; size_t paletteSize = (paletteHeader[0x10]) | (paletteHeader[0x11] << 8) | (paletteHeader[0x12] << 16) | (paletteHeader[0x13] << 24); - if (palIndex == 0) { + if (palIndex == 0) + { palette->numColors = paletteSize / 2; - } else { + } else + { palette->numColors = bitdepth == 4 ? 16 : 256; //remove header and divide by 2 --palIndex; } @@ -780,10 +782,12 @@ void WriteNtrPalette(char *path, struct Palette *palette, bool ncpr, bool ir, in uint32_t size = colourNum * 2; //todo check if there's a better way to detect :/ uint32_t extSize = size + (ncpr ? 0x10 : 0x18); + int numSections = 1; int pcmpColorNum = 0; uint32_t pcmpSize = 0; - if (pcmp) { + if (pcmp) + { pcmpColorNum = colourNum / (bitdepth == 4 ? 16 : 256); if (pcmpColorNum == 0) { FATAL_ERROR("colourNum=%d palette->bitDepth=%d\n", colourNum, bitdepth); @@ -859,7 +863,8 @@ void WriteNtrPalette(char *path, struct Palette *palette, bool ncpr, bool ir, in fwrite(colours, 1, colourNum * 2, fp); free(colours); - if (pcmp) { + if (pcmp) + { uint8_t pcmp_header[16] = {0x50, 0x4D, 0x43, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xEF, 0xBE, 0x08, 0x00, 0x00, 0x00}; pcmp_header[4] = pcmpSize & 0xFF; pcmp_header[5] = (pcmpSize >> 8) & 0xFF; @@ -870,7 +875,8 @@ void WriteNtrPalette(char *path, struct Palette *palette, bool ncpr, bool ir, in fwrite(pcmp_header, 1, 16, fp); uint8_t *pcmp_data = malloc(2 * pcmpColorNum); - if (pcmp_data == NULL) { + if (pcmp_data == NULL) + { FATAL_ERROR("failed to alloc pcmp_data\n"); } for (int i = 0; i < pcmpColorNum; ++i) { diff --git a/tools/nitrogfx/gfx.h b/tools/nitrogfx/gfx.h index 85315ede2..91f697875 100644 --- a/tools/nitrogfx/gfx.h +++ b/tools/nitrogfx/gfx.h @@ -1,4 +1,4 @@ -// Copyright (c) 2015 YamaArashi, 2021-2023 red031000 +// Copyright (c) 2015 YamaArashi, 2021-2024 red031000 #ifndef GFX_H #define GFX_H @@ -23,16 +23,37 @@ struct Image { int width; int height; int bitDepth; + /** + * Pseudocode for converting index in pixels to coordinates in image is as follows + * (where (0, 0) is the top left corner with the format (x, y) ): + * if (bitDepth == 4) + * for (int i = 0; i < width * height / 2; i++) + * xCoord = i % + * yCoord = i / + * + * leftPixel = pixels[i] & 0xF + * rightPixel = pixels[i] >> 4) + * + * leftPixel coordinates: (xCoord, yCoord) + * rightPixel coordinates: (xCoord + 1, yCoord) + * else if (bitDepth == 8) + * for (int i = 0; i < width * height; i++) + * xCoord = i % + * yCoord = i / + * + * pixel = pixels[i] + * pixel coordinates: (xCoord, yCoord) + */ unsigned char *pixels; bool hasPalette; struct Palette palette; bool hasTransparency; }; -void ReadImage(char *path, int tilesWidth, int bitDepth, int metatileWidth, int metatileHeight, struct Image *image, bool invertColors); -uint32_t ReadNtrImage(char *path, int tilesWidth, int bitDepth, int metatileWidth, int metatileHeight, struct Image *image, bool invertColors, bool scanFrontToBack); -void WriteImage(char *path, int numTiles, int bitDepth, int metatileWidth, int metatileHeight, struct Image *image, bool invertColors); -void WriteNtrImage(char *path, int numTiles, int bitDepth, int metatileWidth, int metatileHeight, struct Image *image, +void ReadImage(char *path, int tilesWide, int bitDepth, int colsPerChunk, int rowsPerChunk, struct Image *image, bool invertColors); +uint32_t ReadNtrImage(char *path, int tilesWide, int bitDepth, int colsPerChunk, int rowsPerChunk, struct Image *image, bool invertColors, bool scanFrontToBack); +void WriteImage(char *path, int numTiles, int bitDepth, int colsPerChunk, int rowsPerChunk, struct Image *image, bool invertColors); +void WriteNtrImage(char *path, int numTiles, int bitDepth, int colsPerChunk, int rowsPerChunk, struct Image *image, bool invertColors, bool clobberSize, bool byteOrder, bool version101, bool sopc, bool vram, uint32_t scanMode, uint32_t mappingType, uint32_t key, bool wrongSize); void FreeImage(struct Image *image); diff --git a/tools/nitrogfx/json.c b/tools/nitrogfx/json.c index 16899a188..12bc8a956 100644 --- a/tools/nitrogfx/json.c +++ b/tools/nitrogfx/json.c @@ -1,4 +1,4 @@ -// Copyright (c) 2021-2023 red031000 +// Copyright (c) 2021-2024 red031000 #include "global.h" #include "cJSON.h" @@ -439,15 +439,13 @@ struct JsonToAnimationOptions *ParseNANRJson(char *path) cJSON *resultType = cJSON_GetObjectItemCaseSensitive(animationResult, "resultType"); options->animationResults[i]->resultType = GetInt(resultType); switch (options->animationResults[i]->resultType) { - case 0: - { //index + case 0: { //index cJSON *index = cJSON_GetObjectItemCaseSensitive(animationResult, "index"); options->animationResults[i]->index = GetInt(index); break; } - case 1: - { //SRT + case 1: { //SRT cJSON *index = cJSON_GetObjectItemCaseSensitive(animationResult, "index"); cJSON *rotation = cJSON_GetObjectItemCaseSensitive(animationResult, "rotation"); cJSON *scaleX = cJSON_GetObjectItemCaseSensitive(animationResult, "scaleX"); @@ -464,8 +462,7 @@ struct JsonToAnimationOptions *ParseNANRJson(char *path) break; } - case 2: - { //T + case 2: { //T cJSON *index = cJSON_GetObjectItemCaseSensitive(animationResult, "index"); //cJSON *rotation = cJSON_GetObjectItemCaseSensitive(animationResult, "rotation"); cJSON *positionX = cJSON_GetObjectItemCaseSensitive(animationResult, "positionX"); diff --git a/tools/nitrogfx/json.h b/tools/nitrogfx/json.h index 7e212a920..eb7e2add7 100644 --- a/tools/nitrogfx/json.h +++ b/tools/nitrogfx/json.h @@ -1,4 +1,4 @@ -// Copyright (c) 2021-2023 red031000 +// Copyright (c) 2021-2024 red031000 #ifndef JSON_H #define JSON_H diff --git a/tools/nitrogfx/main.c b/tools/nitrogfx/main.c index 3a0fcbff1..1f9434927 100644 --- a/tools/nitrogfx/main.c +++ b/tools/nitrogfx/main.c @@ -1,4 +1,4 @@ -// Copyright (c) 2015 YamaArashi, 2021-2023 red031000 +// Copyright (c) 2015 YamaArashi, 2021-2024 red031000 #include #include @@ -37,7 +37,7 @@ void ConvertGbaToPng(char *inputPath, char *outputPath, struct GbaToPngOptions * image.hasPalette = false; } - ReadImage(inputPath, options->width, options->bitDepth, options->metatileWidth, options->metatileHeight, &image, !image.hasPalette); + ReadImage(inputPath, options->width, options->bitDepth, options->colsPerChunk, options->rowsPerChunk, &image, !image.hasPalette); image.hasTransparency = options->hasTransparency; @@ -82,7 +82,7 @@ void ConvertNtrToPng(char *inputPath, char *outputPath, struct NtrToPngOptions * image.hasPalette = false; } - uint32_t key = ReadNtrImage(inputPath, options->width, 0, options->metatileWidth, options->metatileHeight, &image, !image.hasPalette, options->scanFrontToBack); + uint32_t key = ReadNtrImage(inputPath, options->width, 0, options->colsPerChunk, options->rowsPerChunk, &image, !image.hasPalette, options->scanFrontToBack); if (key) { @@ -111,7 +111,7 @@ void ConvertPngToGba(char *inputPath, char *outputPath, struct PngToGbaOptions * ReadPng(inputPath, &image); - WriteImage(outputPath, options->numTiles, options->bitDepth, options->metatileWidth, options->metatileHeight, &image, !image.hasPalette); + WriteImage(outputPath, options->numTiles, options->bitDepth, options->colsPerChunk, options->rowsPerChunk, &image, !image.hasPalette); FreeImage(&image); } @@ -160,7 +160,7 @@ void ConvertPngToNtr(char *inputPath, char *outputPath, struct PngToNtrOptions * free(string); } - WriteNtrImage(outputPath, options->numTiles, image.bitDepth, options->metatileWidth, options->metatileHeight, + WriteNtrImage(outputPath, options->numTiles, image.bitDepth, options->colsPerChunk, options->rowsPerChunk, &image, !image.hasPalette, options->clobberSize, options->byteOrder, options->version101, options->sopc, options->vramTransfer, options->scanMode, options->mappingType, key, options->wrongSize); @@ -172,14 +172,14 @@ void HandleGbaToPngCommand(char *inputPath, char *outputPath, int argc, char **a char *inputFileExtension = GetFileExtension(inputPath); struct GbaToPngOptions options; options.paletteFilePath = NULL; - if (isdigit(inputFileExtension[0])) + if (isdigit((unsigned char)inputFileExtension[0])) options.bitDepth = inputFileExtension[0] - '0'; else options.bitDepth = 4; options.hasTransparency = false; options.width = 1; - options.metatileWidth = 1; - options.metatileHeight = 1; + options.colsPerChunk = 1; + options.rowsPerChunk = 1; for (int i = 3; i < argc; i++) { @@ -211,31 +211,31 @@ void HandleGbaToPngCommand(char *inputPath, char *outputPath, int argc, char **a if (options.width < 1) FATAL_ERROR("Width must be positive.\n"); } - else if (strcmp(option, "-mwidth") == 0) + else if (strcmp(option, "-mwidth") == 0 || strcmp(option, "-cpc") == 0) { if (i + 1 >= argc) - FATAL_ERROR("No metatile width value following \"-mwidth\".\n"); + FATAL_ERROR("No columns per chunk value following \"%s\".\n", option); i++; - if (!ParseNumber(argv[i], NULL, 10, &options.metatileWidth)) - FATAL_ERROR("Failed to parse metatile width.\n"); + if (!ParseNumber(argv[i], NULL, 10, &options.colsPerChunk)) + FATAL_ERROR("Failed to parse columns per chunk.\n"); - if (options.metatileWidth < 1) - FATAL_ERROR("metatile width must be positive.\n"); + if (options.colsPerChunk < 1) + FATAL_ERROR("columns per chunk must be positive.\n"); } - else if (strcmp(option, "-mheight") == 0) + else if (strcmp(option, "-mheight") == 0 || strcmp(option, "-rpc") == 0) { if (i + 1 >= argc) - FATAL_ERROR("No metatile height value following \"-mheight\".\n"); + FATAL_ERROR("No rows per chunk value following \"%s\".\n", option); i++; - if (!ParseNumber(argv[i], NULL, 10, &options.metatileHeight)) - FATAL_ERROR("Failed to parse metatile height.\n"); + if (!ParseNumber(argv[i], NULL, 10, &options.rowsPerChunk)) + FATAL_ERROR("Failed to parse rows per chunk.\n"); - if (options.metatileHeight < 1) - FATAL_ERROR("metatile height must be positive.\n"); + if (options.rowsPerChunk < 1) + FATAL_ERROR("rows per chunk must be positive.\n"); } else { @@ -243,8 +243,8 @@ void HandleGbaToPngCommand(char *inputPath, char *outputPath, int argc, char **a } } - if (options.metatileWidth > options.width) - options.width = options.metatileWidth; + if (options.colsPerChunk > options.width) + options.width = options.colsPerChunk; ConvertGbaToPng(inputPath, outputPath, &options); } @@ -255,8 +255,8 @@ void HandleNtrToPngCommand(char *inputPath, char *outputPath, int argc, char **a options.paletteFilePath = NULL; options.hasTransparency = false; options.width = 0; - options.metatileWidth = 1; - options.metatileHeight = 1; + options.colsPerChunk = 1; + options.rowsPerChunk = 1; options.palIndex = 1; options.scanFrontToBack = false; options.handleEmpty = false; @@ -288,7 +288,7 @@ void HandleNtrToPngCommand(char *inputPath, char *outputPath, int argc, char **a if (!ParseNumber(argv[i], NULL, 10, &options.palIndex)) FATAL_ERROR("Failed to parse palette index.\n"); - if (options.width < 1) + if (options.palIndex < 1) FATAL_ERROR("Palette index must be positive.\n"); } else if (strcmp(option, "-width") == 0) @@ -304,31 +304,31 @@ void HandleNtrToPngCommand(char *inputPath, char *outputPath, int argc, char **a if (options.width < 1) FATAL_ERROR("Width must be positive.\n"); } - else if (strcmp(option, "-mwidth") == 0) + else if (strcmp(option, "-mwidth") == 0 || strcmp(option, "-cpc") == 0) { if (i + 1 >= argc) - FATAL_ERROR("No metatile width value following \"-mwidth\".\n"); + FATAL_ERROR("No columns per chunk value following \"%s\".\n", option); i++; - if (!ParseNumber(argv[i], NULL, 10, &options.metatileWidth)) - FATAL_ERROR("Failed to parse metatile width.\n"); + if (!ParseNumber(argv[i], NULL, 10, &options.colsPerChunk)) + FATAL_ERROR("Failed to parse columns per chunk.\n"); - if (options.metatileWidth < 1) - FATAL_ERROR("metatile width must be positive.\n"); + if (options.colsPerChunk < 1) + FATAL_ERROR("columns per chunk must be positive.\n"); } - else if (strcmp(option, "-mheight") == 0) + else if (strcmp(option, "-mheight") == 0 || strcmp(option, "-rpc") == 0) { if (i + 1 >= argc) - FATAL_ERROR("No metatile height value following \"-mheight\".\n"); + FATAL_ERROR("No rows per chunk value following \"%s\".\n", option); i++; - if (!ParseNumber(argv[i], NULL, 10, &options.metatileHeight)) - FATAL_ERROR("Failed to parse metatile height.\n"); + if (!ParseNumber(argv[i], NULL, 10, &options.rowsPerChunk)) + FATAL_ERROR("Failed to parse rows per chunk.\n"); - if (options.metatileHeight < 1) - FATAL_ERROR("metatile height must be positive.\n"); + if (options.rowsPerChunk < 1) + FATAL_ERROR("rows per chunk must be positive.\n"); } else if (strcmp(option, "-scanfronttoback") == 0) { @@ -344,8 +344,8 @@ void HandleNtrToPngCommand(char *inputPath, char *outputPath, int argc, char **a } } - if (options.width != 0 && options.metatileWidth > options.width) - options.width = options.metatileWidth; + if (options.width != 0 && options.colsPerChunk > options.width) + options.width = options.colsPerChunk; ConvertNtrToPng(inputPath, outputPath, &options); } @@ -361,8 +361,8 @@ void HandlePngToGbaCommand(char *inputPath, char *outputPath, int argc, char **a struct PngToGbaOptions options; options.numTiles = 0; options.bitDepth = bitDepth; - options.metatileWidth = 1; - options.metatileHeight = 1; + options.colsPerChunk = 1; + options.rowsPerChunk = 1; for (int i = 3; i < argc; i++) { @@ -381,31 +381,31 @@ void HandlePngToGbaCommand(char *inputPath, char *outputPath, int argc, char **a if (options.numTiles < 1) FATAL_ERROR("Number of tiles must be positive.\n"); } - else if (strcmp(option, "-mwidth") == 0) + else if (strcmp(option, "-mwidth") == 0 || strcmp(option, "-cpc") == 0) { if (i + 1 >= argc) - FATAL_ERROR("No metatile width value following \"-mwidth\".\n"); + FATAL_ERROR("No columns per chunk value following \"%s\".\n", option); i++; - if (!ParseNumber(argv[i], NULL, 10, &options.metatileWidth)) - FATAL_ERROR("Failed to parse metatile width.\n"); + if (!ParseNumber(argv[i], NULL, 10, &options.colsPerChunk)) + FATAL_ERROR("Failed to parse columns per chunk.\n"); - if (options.metatileWidth < 1) - FATAL_ERROR("metatile width must be positive.\n"); + if (options.colsPerChunk < 1) + FATAL_ERROR("columns per chunk must be positive.\n"); } - else if (strcmp(option, "-mheight") == 0) + else if (strcmp(option, "-mheight") == 0 || strcmp(option, "-rpc") == 0) { if (i + 1 >= argc) - FATAL_ERROR("No metatile height value following \"-mheight\".\n"); + FATAL_ERROR("No rows per chunk value following \"%s\".\n", option); i++; - if (!ParseNumber(argv[i], NULL, 10, &options.metatileHeight)) - FATAL_ERROR("Failed to parse metatile height.\n"); + if (!ParseNumber(argv[i], NULL, 10, &options.rowsPerChunk)) + FATAL_ERROR("Failed to parse rows per chunk.\n"); - if (options.metatileHeight < 1) - FATAL_ERROR("metatile height must be positive.\n"); + if (options.rowsPerChunk < 1) + FATAL_ERROR("rows per chunk must be positive.\n"); } else { @@ -421,8 +421,8 @@ void HandlePngToNtrCommand(char *inputPath, char *outputPath, int argc, char **a struct PngToNtrOptions options; options.numTiles = 0; options.bitDepth = 4; - options.metatileWidth = 1; - options.metatileHeight = 1; + options.colsPerChunk = 1; + options.rowsPerChunk = 1; options.wrongSize = false; options.clobberSize = false; options.byteOrder = true; @@ -450,31 +450,31 @@ void HandlePngToNtrCommand(char *inputPath, char *outputPath, int argc, char **a if (options.numTiles < 1) FATAL_ERROR("Number of tiles must be positive.\n"); } - else if (strcmp(option, "-mwidth") == 0) + else if (strcmp(option, "-mwidth") == 0 || strcmp(option, "-cpc") == 0) { if (i + 1 >= argc) - FATAL_ERROR("No metatile width value following \"-mwidth\".\n"); + FATAL_ERROR("No columns per chunk value following \"%s\".\n", option); i++; - if (!ParseNumber(argv[i], NULL, 10, &options.metatileWidth)) - FATAL_ERROR("Failed to parse metatile width.\n"); + if (!ParseNumber(argv[i], NULL, 10, &options.colsPerChunk)) + FATAL_ERROR("Failed to parse columns per chunk.\n"); - if (options.metatileWidth < 1) - FATAL_ERROR("metatile width must be positive.\n"); + if (options.colsPerChunk < 1) + FATAL_ERROR("columns per chunk must be positive.\n"); } - else if (strcmp(option, "-mheight") == 0) + else if (strcmp(option, "-mheight") == 0 || strcmp(option, "-rpc") == 0) { if (i + 1 >= argc) - FATAL_ERROR("No metatile height value following \"-mheight\".\n"); + FATAL_ERROR("No rows per chunk value following \"%s\".\n", option); i++; - if (!ParseNumber(argv[i], NULL, 10, &options.metatileHeight)) - FATAL_ERROR("Failed to parse metatile height.\n"); + if (!ParseNumber(argv[i], NULL, 10, &options.rowsPerChunk)) + FATAL_ERROR("Failed to parse rows per chunk.\n"); - if (options.metatileHeight < 1) - FATAL_ERROR("metatile height must be positive.\n"); + if (options.rowsPerChunk < 1) + FATAL_ERROR("rows per chunk must be positive.\n"); } else if (strcmp(option, "-bitdepth") == 0) { @@ -609,7 +609,8 @@ void HandlePngToNtrPaletteCommand(char *inputPath, char *outputPath, int argc, c if (compNum > 255) FATAL_ERROR("Compression value must be 255 or below.\n"); } - else if (strcmp(option, "-pcmp") == 0) { + else if (strcmp(option, "-pcmp") == 0) + { pcmp = true; } else @@ -764,7 +765,8 @@ void HandleJascToNtrPaletteCommand(char *inputPath, char *outputPath, int argc, { nopad = true; } - else if (strcmp(option, "-pcmp") == 0) { + else if (strcmp(option, "-pcmp") == 0) + { pcmp = true; } else diff --git a/tools/nitrogfx/options.h b/tools/nitrogfx/options.h index 43ecb5c3a..4304f1eca 100644 --- a/tools/nitrogfx/options.h +++ b/tools/nitrogfx/options.h @@ -1,4 +1,4 @@ -// Copyright (c) 2018 huderlem, 2021-2023 red031000 +// Copyright (c) 2018 huderlem, 2021-2024 red031000 #ifndef OPTIONS_H #define OPTIONS_H @@ -11,23 +11,23 @@ struct GbaToPngOptions { int bitDepth; bool hasTransparency; int width; - int metatileWidth; - int metatileHeight; + int colsPerChunk; + int rowsPerChunk; int palIndex; }; struct PngToGbaOptions { int numTiles; int bitDepth; - int metatileWidth; - int metatileHeight; + int colsPerChunk; + int rowsPerChunk; }; struct PngToNtrOptions { int numTiles; int bitDepth; - int metatileWidth; - int metatileHeight; + int colsPerChunk; + int rowsPerChunk; bool clobberSize; bool byteOrder; bool version101; @@ -44,8 +44,8 @@ struct NtrToPngOptions { int bitDepth; bool hasTransparency; int width; - int metatileWidth; - int metatileHeight; + int colsPerChunk; + int rowsPerChunk; int palIndex; bool scanFrontToBack; bool handleEmpty;