diff options
Diffstat (limited to 'tools/gbagfx/main.c')
-rw-r--r-- | tools/gbagfx/main.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tools/gbagfx/main.c b/tools/gbagfx/main.c index 957918505..cf3031696 100644 --- a/tools/gbagfx/main.c +++ b/tools/gbagfx/main.c @@ -45,6 +45,20 @@ void ConvertGbaToPng(char *inputPath, char *outputPath, struct GbaToPngOptions * image.hasPalette = false; } + if (options->tilemapFilePath != NULL) + { + int fileSize; + image.tilemap.data.affine = ReadWholeFile(options->tilemapFilePath, &fileSize); + if (options->isAffineMap && options->bitDepth != 8) + FATAL_ERROR("affine maps are necessarily 8bpp\n"); + image.isAffine = options->isAffineMap; + image.tilemap.size = fileSize; + } + else + { + image.tilemap.data.affine = NULL; + } + ReadImage(inputPath, options->width, options->bitDepth, options->metatileWidth, options->metatileHeight, &image, !image.hasPalette); image.hasTransparency = options->hasTransparency; @@ -59,6 +73,7 @@ void ConvertPngToGba(char *inputPath, char *outputPath, struct PngToGbaOptions * struct Image image; image.bitDepth = options->bitDepth; + image.tilemap.data.affine = NULL; // initialize to NULL to avoid issues in FreeImage ReadPng(inputPath, &image); @@ -77,6 +92,8 @@ void HandleGbaToPngCommand(char *inputPath, char *outputPath, int argc, char **a options.width = 1; options.metatileWidth = 1; options.metatileHeight = 1; + options.tilemapFilePath = NULL; + options.isAffineMap = false; for (int i = 3; i < argc; i++) { @@ -134,6 +151,17 @@ void HandleGbaToPngCommand(char *inputPath, char *outputPath, int argc, char **a if (options.metatileHeight < 1) FATAL_ERROR("metatile height must be positive.\n"); } + else if (strcmp(option, "-tilemap") == 0) + { + if (i + 1 >= argc) + FATAL_ERROR("No tilemap value following \"-tilemap\".\n"); + i++; + options.tilemapFilePath = argv[i]; + } + else if (strcmp(option, "-affine") == 0) + { + options.isAffineMap = true; + } else { FATAL_ERROR("Unrecognized option \"%s\".\n", option); @@ -155,6 +183,8 @@ void HandlePngToGbaCommand(char *inputPath, char *outputPath, int argc, char **a options.bitDepth = bitDepth; options.metatileWidth = 1; options.metatileHeight = 1; + options.tilemapFilePath = NULL; + options.isAffineMap = false; for (int i = 3; i < argc; i++) { @@ -272,6 +302,7 @@ void HandleJascToGbaPaletteCommand(char *inputPath, char *outputPath, int argc, void HandleLatinFontToPngCommand(char *inputPath, char *outputPath, int argc UNUSED, char **argv UNUSED) { struct Image image; + image.tilemap.data.affine = NULL; // initialize to NULL to avoid issues in FreeImage ReadLatinFont(inputPath, &image); WritePng(outputPath, &image); @@ -282,6 +313,7 @@ void HandleLatinFontToPngCommand(char *inputPath, char *outputPath, int argc UNU void HandlePngToLatinFontCommand(char *inputPath, char *outputPath, int argc UNUSED, char **argv UNUSED) { struct Image image; + image.tilemap.data.affine = NULL; // initialize to NULL to avoid issues in FreeImage image.bitDepth = 2; @@ -294,6 +326,7 @@ void HandlePngToLatinFontCommand(char *inputPath, char *outputPath, int argc UNU void HandleHalfwidthJapaneseFontToPngCommand(char *inputPath, char *outputPath, int argc UNUSED, char **argv UNUSED) { struct Image image; + image.tilemap.data.affine = NULL; // initialize to NULL to avoid issues in FreeImage ReadHalfwidthJapaneseFont(inputPath, &image); WritePng(outputPath, &image); @@ -304,6 +337,7 @@ void HandleHalfwidthJapaneseFontToPngCommand(char *inputPath, char *outputPath, void HandlePngToHalfwidthJapaneseFontCommand(char *inputPath, char *outputPath, int argc UNUSED, char **argv UNUSED) { struct Image image; + image.tilemap.data.affine = NULL; // initialize to NULL to avoid issues in FreeImage image.bitDepth = 2; @@ -316,6 +350,7 @@ void HandlePngToHalfwidthJapaneseFontCommand(char *inputPath, char *outputPath, void HandleFullwidthJapaneseFontToPngCommand(char *inputPath, char *outputPath, int argc UNUSED, char **argv UNUSED) { struct Image image; + image.tilemap.data.affine = NULL; // initialize to NULL to avoid issues in FreeImage ReadFullwidthJapaneseFont(inputPath, &image); WritePng(outputPath, &image); @@ -326,6 +361,7 @@ void HandleFullwidthJapaneseFontToPngCommand(char *inputPath, char *outputPath, void HandlePngToFullwidthJapaneseFontCommand(char *inputPath, char *outputPath, int argc UNUSED, char **argv UNUSED) { struct Image image; + image.tilemap.data.affine = NULL; // initialize to NULL to avoid issues in FreeImage image.bitDepth = 2; |