diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/nitrogfx/gfx.c | 6 | ||||
-rw-r--r-- | tools/nitrogfx/gfx.h | 2 | ||||
-rw-r--r-- | tools/nitrogfx/main.c | 7 | ||||
-rw-r--r-- | tools/nitrogfx/options.h | 1 | ||||
-rw-r--r-- | tools/nitrogfx/util.c | 7 | ||||
-rw-r--r-- | tools/nitrogfx/util.h | 2 |
6 files changed, 18 insertions, 7 deletions
diff --git a/tools/nitrogfx/gfx.c b/tools/nitrogfx/gfx.c index 3315e00e..a80d341b 100644 --- a/tools/nitrogfx/gfx.c +++ b/tools/nitrogfx/gfx.c @@ -359,7 +359,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, bool invertColors, bool clobberSize, bool byteOrder) +void WriteNtrImage(char *path, int numTiles, int bitDepth, int metatileWidth, int metatileHeight, struct Image *image, bool invertColors, bool clobberSize, bool byteOrder, bool version101) { FILE *fp = fopen(path, "wb"); @@ -407,7 +407,7 @@ void WriteNtrImage(char *path, int numTiles, int bitDepth, int metatileWidth, in break; } - WriteGenericNtrHeader(fp, "RGCN", bufferSize + 0x20, byteOrder); + WriteGenericNtrHeader(fp, "RGCN", bufferSize + 0x20, byteOrder, version101); unsigned char charHeader[0x20] = { 0x52, 0x41, 0x48, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00 }; @@ -545,7 +545,7 @@ void WriteNtrPalette(char *path, struct Palette *palette, bool ncpr) uint32_t extSize = size + (ncpr ? 0x10 : 0x18); //NCLR header - WriteGenericNtrHeader(fp, (ncpr ? "RPCN" : "RLCN"), extSize, !ncpr); + WriteGenericNtrHeader(fp, (ncpr ? "RPCN" : "RLCN"), extSize, !ncpr, false); unsigned char palHeader[0x18] = { diff --git a/tools/nitrogfx/gfx.h b/tools/nitrogfx/gfx.h index da56c5c5..1b097336 100644 --- a/tools/nitrogfx/gfx.h +++ b/tools/nitrogfx/gfx.h @@ -31,7 +31,7 @@ struct Image { void ReadImage(char *path, int tilesWidth, int bitDepth, int metatileWidth, int metatileHeight, struct Image *image, bool invertColors); void ReadNtrImage(char *path, int tilesWidth, int bitDepth, int metatileWidth, int metatileHeight, struct Image *image, bool invertColors); 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, bool invertColors, bool clobberSize, bool byteOrder); +void WriteNtrImage(char *path, int numTiles, int bitDepth, int metatileWidth, int metatileHeight, struct Image *image, bool invertColors, bool clobberSize, bool byteOrder, bool version101); void FreeImage(struct Image *image); void ReadGbaPalette(char *path, struct Palette *palette); void ReadNtrPalette(char *path, struct Palette *palette); diff --git a/tools/nitrogfx/main.c b/tools/nitrogfx/main.c index 2f5b2735..076e7076 100644 --- a/tools/nitrogfx/main.c +++ b/tools/nitrogfx/main.c @@ -88,7 +88,7 @@ void ConvertPngToNtr(char *inputPath, char *outputPath, struct PngToNtrOptions * ReadPng(inputPath, &image); - WriteNtrImage(outputPath, options->numTiles, options->bitDepth, options->metatileWidth, options->metatileHeight, &image, !image.hasPalette, options->clobberSize, options->byteOrder); + WriteNtrImage(outputPath, options->numTiles, options->bitDepth, options->metatileWidth, options->metatileHeight, &image, !image.hasPalette, options->clobberSize, options->byteOrder, options->version101); FreeImage(&image); } @@ -320,6 +320,7 @@ void HandlePngToNtrCommand(char *inputPath, char *outputPath, int argc, char **a options.metatileHeight = 1; options.clobberSize = false; options.byteOrder = true; + options.version101 = false; for (int i = 3; i < argc; i++) { @@ -385,6 +386,10 @@ void HandlePngToNtrCommand(char *inputPath, char *outputPath, int argc, char **a { options.byteOrder = false; } + else if (strcmp(option, "-version101") == 0) + { + options.version101 = true; + } else { FATAL_ERROR("Unrecognized option \"%s\".\n", option); diff --git a/tools/nitrogfx/options.h b/tools/nitrogfx/options.h index 8376348f..77006f21 100644 --- a/tools/nitrogfx/options.h +++ b/tools/nitrogfx/options.h @@ -28,6 +28,7 @@ struct PngToNtrOptions { int metatileHeight; bool clobberSize; bool byteOrder; + bool version101; }; diff --git a/tools/nitrogfx/util.c b/tools/nitrogfx/util.c index 73a128a1..304a2319 100644 --- a/tools/nitrogfx/util.c +++ b/tools/nitrogfx/util.c @@ -124,13 +124,18 @@ void WriteWholeFile(char *path, void *buffer, int bufferSize) fclose(fp); } -void WriteGenericNtrHeader(FILE* fp, const char* magicNumber, uint32_t size, bool byteorder) +void WriteGenericNtrHeader(FILE* fp, const char* magicNumber, uint32_t size, bool byteorder, bool version101) { unsigned char header[0x10] = { 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFE, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x01, 0x00 }; //magic number memcpy(header, magicNumber, 4); + if (version101) + { + header[6] = 0x01; + } + //byte order if (!byteorder) { diff --git a/tools/nitrogfx/util.h b/tools/nitrogfx/util.h index f181b66e..bb1cd4ad 100644 --- a/tools/nitrogfx/util.h +++ b/tools/nitrogfx/util.h @@ -11,6 +11,6 @@ char *GetFileExtension(char *path); unsigned char *ReadWholeFile(char *path, int *size); unsigned char *ReadWholeFileZeroPadded(char *path, int *size, int padAmount); void WriteWholeFile(char *path, void *buffer, int bufferSize); -void WriteGenericNtrHeader(FILE* fp, const char* magicNumber, uint32_t size, bool byteorder); +void WriteGenericNtrHeader(FILE* fp, const char* magicNumber, uint32_t size, bool byteorder, bool version101); #endif // UTIL_H |