Merge pull request #1027 from PikalaxALT/gbagfx_tilemap
Add tilemap rendering capability to gbagfx
This commit is contained in:
@@ -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++)
|
||||
{
|
||||
@@ -272,6 +301,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 +312,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 +325,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 +336,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 +349,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 +360,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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user