summaryrefslogtreecommitdiff
path: root/tools/gbagfx/main.c
diff options
context:
space:
mode:
authorPikalaxALT <PikalaxALT@gmail.com>2020-04-24 08:47:22 -0400
committerPikalaxALT <PikalaxALT@gmail.com>2020-04-24 08:47:22 -0400
commit14f76fbe03d740d76c6867a87713fb469ae7eaa7 (patch)
tree804e2e3b537c585aeabea82ddf6e94e4e9f9854c /tools/gbagfx/main.c
parentdc126e30169bd145d28c6d84e4bb466d96394d29 (diff)
Add tilemap rendering capability to gbagfx
Diffstat (limited to 'tools/gbagfx/main.c')
-rw-r--r--tools/gbagfx/main.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/tools/gbagfx/main.c b/tools/gbagfx/main.c
index 9fd72383d..5c9bfd641 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,7 @@ void HandleGbaToPngCommand(char *inputPath, char *outputPath, int argc, char **a
options.width = 1;
options.metatileWidth = 1;
options.metatileHeight = 1;
+ options.isAffineMap = false;
for (int i = 3; i < argc; i++)
{
@@ -134,6 +150,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 +182,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++)
{