mirror of
https://github.com/zeldaret/tmc
synced 2026-08-20 22:24:01 -04:00
Rename metaTiles
Now the 16x16 tiles are just called tiles and the 8x8 tiles are called subTiles.
This commit is contained in:
Vendored
+5
-5
@@ -1,7 +1,7 @@
|
||||
#include "tileset.h"
|
||||
#include "subtileset.h"
|
||||
#include "util.h"
|
||||
|
||||
std::filesystem::path TilesetAsset::generateAssetPath() {
|
||||
std::filesystem::path SubTileSetAsset::generateAssetPath() {
|
||||
std::filesystem::path pngPath = path;
|
||||
if (pngPath.extension() == ".lz") {
|
||||
pngPath.replace_extension("");
|
||||
@@ -10,7 +10,7 @@ std::filesystem::path TilesetAsset::generateAssetPath() {
|
||||
return pngPath;
|
||||
}
|
||||
|
||||
void TilesetAsset::convertToHumanReadable(const std::vector<char>& baserom) {
|
||||
void SubTileSetAsset::convertToHumanReadable(const std::vector<char>& baserom) {
|
||||
(void)baserom;
|
||||
|
||||
std::filesystem::path toolsPath = "tools";
|
||||
@@ -37,7 +37,7 @@ void TilesetAsset::convertToHumanReadable(const std::vector<char>& baserom) {
|
||||
check_call(cmd);
|
||||
}
|
||||
|
||||
void TilesetAsset::buildToBinary() {
|
||||
void SubTileSetAsset::buildToBinary() {
|
||||
std::filesystem::path toolsPath = "tools";
|
||||
std::vector<std::string> cmd;
|
||||
|
||||
@@ -61,6 +61,6 @@ void TilesetAsset::buildToBinary() {
|
||||
}
|
||||
}
|
||||
|
||||
bool TilesetAsset::isCompressed() {
|
||||
bool SubTileSetAsset::isCompressed() {
|
||||
return path.extension() == ".lz";
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#include "asset.h"
|
||||
|
||||
class TilesetAsset : public BaseAsset {
|
||||
class SubTileSetAsset : public BaseAsset {
|
||||
public:
|
||||
using BaseAsset::BaseAsset;
|
||||
virtual void convertToHumanReadable(const std::vector<char>& baserom);
|
||||
Vendored
+5
-5
@@ -8,7 +8,7 @@
|
||||
#include "assets/midi.h"
|
||||
#include "assets/palette.h"
|
||||
#include "assets/spriteframe.h"
|
||||
#include "assets/tileset.h"
|
||||
#include "assets/subtileset.h"
|
||||
#include "offsets.h"
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
@@ -264,8 +264,8 @@ std::unique_ptr<BaseAsset> getAssetHandlerByType(const std::filesystem::path& pa
|
||||
}
|
||||
|
||||
std::unique_ptr<BaseAsset> assetHandler;
|
||||
if (type == "tileset") {
|
||||
assetHandler = std::make_unique<TilesetAsset>(path, start, size, asset);
|
||||
if (type == "subtileset") {
|
||||
assetHandler = std::make_unique<SubTileSetAsset>(path, start, size, asset);
|
||||
} else if (type == "animation") {
|
||||
assetHandler = std::make_unique<AnimationAsset>(path, start, size, asset);
|
||||
} else if (type == "sprite_frame") {
|
||||
@@ -280,8 +280,8 @@ std::unique_ptr<BaseAsset> getAssetHandlerByType(const std::filesystem::path& pa
|
||||
assetHandler = std::make_unique<GfxAsset>(path, start, size, asset);
|
||||
} else if (type == "palette") {
|
||||
assetHandler = std::make_unique<PaletteAsset>(path, start, size, asset);
|
||||
} else if (type == "metatilemap" ||
|
||||
type == "metatileset_types" || type == "metatileset" ||
|
||||
} else if (type == "tilemap" ||
|
||||
type == "tileset_types" || type == "tileset" ||
|
||||
type == "map_mapping1" || type == "map_mapping2" ||
|
||||
type == "map_collision") {
|
||||
assetHandler = std::make_unique<MapAsset>(path, start, size, asset);
|
||||
|
||||
Vendored
+84
-84
@@ -18,35 +18,35 @@
|
||||
|
||||
#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* subTileX, int* subTileY, int* tileX, int* tileY, int tilesWide,
|
||||
int tileWidth, int tileHeight) {
|
||||
(*subTileX)++;
|
||||
if (*subTileX == metatileWidth) {
|
||||
if (*subTileX == tileWidth) {
|
||||
*subTileX = 0;
|
||||
(*subTileY)++;
|
||||
if (*subTileY == metatileHeight) {
|
||||
if (*subTileY == tileHeight) {
|
||||
*subTileY = 0;
|
||||
(*metatileX)++;
|
||||
if (*metatileX == metatilesWide) {
|
||||
*metatileX = 0;
|
||||
(*metatileY)++;
|
||||
(*tileX)++;
|
||||
if (*tileX == tilesWide) {
|
||||
*tileX = 0;
|
||||
(*tileY)++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 tilesWide,
|
||||
int tileWidth, int tileHeight, bool invertColors) {
|
||||
int subTileX = 0;
|
||||
int subTileY = 0;
|
||||
int metatileX = 0;
|
||||
int metatileY = 0;
|
||||
int pitch = metatilesWide * metatileWidth;
|
||||
int tileX = 0;
|
||||
int tileY = 0;
|
||||
int pitch = tilesWide * tileWidth;
|
||||
|
||||
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 destY = (tileY * tileHeight + subTileY) * 8 + j;
|
||||
int destX = tileX * tileWidth + subTileX;
|
||||
unsigned char srcPixelOctet = *src++;
|
||||
unsigned char* destPixelOctet = &dest[destY * pitch + destX];
|
||||
|
||||
@@ -57,25 +57,25 @@ static void ConvertFromTiles1Bpp(unsigned char* src, unsigned char* dest, int nu
|
||||
}
|
||||
}
|
||||
|
||||
AdvanceMetatilePosition(&subTileX, &subTileY, &metatileX, &metatileY, metatilesWide, metatileWidth,
|
||||
metatileHeight);
|
||||
AdvanceTilePosition(&subTileX, &subTileY, &tileX, &tileY, tilesWide, tileWidth,
|
||||
tileHeight);
|
||||
}
|
||||
}
|
||||
|
||||
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 tilesWide,
|
||||
int tileWidth, int tileHeight, bool invertColors) {
|
||||
int subTileX = 0;
|
||||
int subTileY = 0;
|
||||
int metatileX = 0;
|
||||
int metatileY = 0;
|
||||
int pitch = (metatilesWide * metatileWidth) * 4;
|
||||
int tileX = 0;
|
||||
int tileY = 0;
|
||||
int pitch = (tilesWide * tileWidth) * 4;
|
||||
|
||||
for (int i = 0; i < numTiles; i++) {
|
||||
for (int j = 0; j < 8; j++) {
|
||||
int destY = (metatileY * metatileHeight + subTileY) * 8 + j;
|
||||
int destY = (tileY * tileHeight + subTileY) * 8 + j;
|
||||
|
||||
for (int k = 0; k < 4; k++) {
|
||||
int destX = (metatileX * metatileWidth + subTileX) * 4 + k;
|
||||
int destX = (tileX * tileWidth + subTileX) * 4 + k;
|
||||
unsigned char srcPixelPair = *src++;
|
||||
unsigned char leftPixel = srcPixelPair & 0xF;
|
||||
unsigned char rightPixel = srcPixelPair >> 4;
|
||||
@@ -89,25 +89,25 @@ static void ConvertFromTiles4Bpp(unsigned char* src, unsigned char* dest, int nu
|
||||
}
|
||||
}
|
||||
|
||||
AdvanceMetatilePosition(&subTileX, &subTileY, &metatileX, &metatileY, metatilesWide, metatileWidth,
|
||||
metatileHeight);
|
||||
AdvanceTilePosition(&subTileX, &subTileY, &tileX, &tileY, tilesWide, tileWidth,
|
||||
tileHeight);
|
||||
}
|
||||
}
|
||||
|
||||
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 tilesWide,
|
||||
int tileWidth, int tileHeight, bool invertColors) {
|
||||
int subTileX = 0;
|
||||
int subTileY = 0;
|
||||
int metatileX = 0;
|
||||
int metatileY = 0;
|
||||
int pitch = (metatilesWide * metatileWidth) * 8;
|
||||
int tileX = 0;
|
||||
int tileY = 0;
|
||||
int pitch = (tilesWide * tileWidth) * 8;
|
||||
|
||||
for (int i = 0; i < numTiles; i++) {
|
||||
for (int j = 0; j < 8; j++) {
|
||||
int destY = (metatileY * metatileHeight + subTileY) * 8 + j;
|
||||
int destY = (tileY * tileHeight + subTileY) * 8 + j;
|
||||
|
||||
for (int k = 0; k < 8; k++) {
|
||||
int destX = (metatileX * metatileWidth + subTileX) * 8 + k;
|
||||
int destX = (tileX * tileWidth + subTileX) * 8 + k;
|
||||
unsigned char srcPixel = *src++;
|
||||
|
||||
if (invertColors)
|
||||
@@ -117,23 +117,23 @@ static void ConvertFromTiles8Bpp(unsigned char* src, unsigned char* dest, int nu
|
||||
}
|
||||
}
|
||||
|
||||
AdvanceMetatilePosition(&subTileX, &subTileY, &metatileX, &metatileY, metatilesWide, metatileWidth,
|
||||
metatileHeight);
|
||||
AdvanceTilePosition(&subTileX, &subTileY, &tileX, &tileY, tilesWide, tileWidth,
|
||||
tileHeight);
|
||||
}
|
||||
}
|
||||
|
||||
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 tilesWide,
|
||||
int tileWidth, int tileHeight, bool invertColors) {
|
||||
int subTileX = 0;
|
||||
int subTileY = 0;
|
||||
int metatileX = 0;
|
||||
int metatileY = 0;
|
||||
int pitch = metatilesWide * metatileWidth;
|
||||
int tileX = 0;
|
||||
int tileY = 0;
|
||||
int pitch = tilesWide * tileWidth;
|
||||
|
||||
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;
|
||||
int srcY = (tileY * tileHeight + subTileY) * 8 + j;
|
||||
int srcX = tileX * tileWidth + subTileX;
|
||||
unsigned char srcPixelOctet = src[srcY * pitch + srcX];
|
||||
unsigned char* destPixelOctet = dest++;
|
||||
|
||||
@@ -144,25 +144,25 @@ static void ConvertToTiles1Bpp(unsigned char* src, unsigned char* dest, int numT
|
||||
}
|
||||
}
|
||||
|
||||
AdvanceMetatilePosition(&subTileX, &subTileY, &metatileX, &metatileY, metatilesWide, metatileWidth,
|
||||
metatileHeight);
|
||||
AdvanceTilePosition(&subTileX, &subTileY, &tileX, &tileY, tilesWide, tileWidth,
|
||||
tileHeight);
|
||||
}
|
||||
}
|
||||
|
||||
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 tilesWide,
|
||||
int tileWidth, int tileHeight, bool invertColors) {
|
||||
int subTileX = 0;
|
||||
int subTileY = 0;
|
||||
int metatileX = 0;
|
||||
int metatileY = 0;
|
||||
int pitch = (metatilesWide * metatileWidth) * 4;
|
||||
int tileX = 0;
|
||||
int tileY = 0;
|
||||
int pitch = (tilesWide * tileWidth) * 4;
|
||||
|
||||
for (int i = 0; i < numTiles; i++) {
|
||||
for (int j = 0; j < 8; j++) {
|
||||
int srcY = (metatileY * metatileHeight + subTileY) * 8 + j;
|
||||
int srcY = (tileY * tileHeight + subTileY) * 8 + j;
|
||||
|
||||
for (int k = 0; k < 4; k++) {
|
||||
int srcX = (metatileX * metatileWidth + subTileX) * 4 + k;
|
||||
int srcX = (tileX * tileWidth + subTileX) * 4 + k;
|
||||
unsigned char srcPixelPair = src[srcY * pitch + srcX];
|
||||
unsigned char leftPixel = srcPixelPair >> 4;
|
||||
unsigned char rightPixel = srcPixelPair & 0xF;
|
||||
@@ -176,25 +176,25 @@ static void ConvertToTiles4Bpp(unsigned char* src, unsigned char* dest, int numT
|
||||
}
|
||||
}
|
||||
|
||||
AdvanceMetatilePosition(&subTileX, &subTileY, &metatileX, &metatileY, metatilesWide, metatileWidth,
|
||||
metatileHeight);
|
||||
AdvanceTilePosition(&subTileX, &subTileY, &tileX, &tileY, tilesWide, tileWidth,
|
||||
tileHeight);
|
||||
}
|
||||
}
|
||||
|
||||
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 tilesWide,
|
||||
int tileWidth, int tileHeight, bool invertColors) {
|
||||
int subTileX = 0;
|
||||
int subTileY = 0;
|
||||
int metatileX = 0;
|
||||
int metatileY = 0;
|
||||
int pitch = (metatilesWide * metatileWidth) * 8;
|
||||
int tileX = 0;
|
||||
int tileY = 0;
|
||||
int pitch = (tilesWide * tileWidth) * 8;
|
||||
|
||||
for (int i = 0; i < numTiles; i++) {
|
||||
for (int j = 0; j < 8; j++) {
|
||||
int srcY = (metatileY * metatileHeight + subTileY) * 8 + j;
|
||||
int srcY = (tileY * tileHeight + subTileY) * 8 + j;
|
||||
|
||||
for (int k = 0; k < 8; k++) {
|
||||
int srcX = (metatileX * metatileWidth + subTileX) * 8 + k;
|
||||
int srcX = (tileX * tileWidth + subTileX) * 8 + k;
|
||||
unsigned char srcPixel = src[srcY * pitch + srcX];
|
||||
|
||||
if (invertColors)
|
||||
@@ -204,12 +204,12 @@ static void ConvertToTiles8Bpp(unsigned char* src, unsigned char* dest, int numT
|
||||
}
|
||||
}
|
||||
|
||||
AdvanceMetatilePosition(&subTileX, &subTileY, &metatileX, &metatileY, metatilesWide, metatileWidth,
|
||||
metatileHeight);
|
||||
AdvanceTilePosition(&subTileX, &subTileY, &tileX, &tileY, tilesWide, tileWidth,
|
||||
tileHeight);
|
||||
}
|
||||
}
|
||||
|
||||
void ReadImage(char* path, int tilesWidth, int bitDepth, int metatileWidth, int metatileHeight, struct Image* image,
|
||||
void ReadImage(char* path, int tilesWidth, int bitDepth, int tileWidth, int tileHeight, struct Image* image,
|
||||
bool invertColors) {
|
||||
int tileSize = bitDepth * 8;
|
||||
|
||||
@@ -220,13 +220,13 @@ void ReadImage(char* path, int tilesWidth, int bitDepth, int metatileWidth, int
|
||||
|
||||
int tilesHeight = (numTiles + tilesWidth - 1) / tilesWidth;
|
||||
|
||||
if (tilesWidth % metatileWidth != 0)
|
||||
FATAL_ERROR("The width in tiles (%d) isn't a multiple of the specified metatile width (%d)", tilesWidth,
|
||||
metatileWidth);
|
||||
if (tilesWidth % tileWidth != 0)
|
||||
FATAL_ERROR("The width in tiles (%d) isn't a multiple of the specified tile width (%d)", tilesWidth,
|
||||
tileWidth);
|
||||
|
||||
if (tilesHeight % metatileHeight != 0)
|
||||
FATAL_ERROR("The height in tiles (%d) isn't a multiple of the specified metatile height (%d)", tilesHeight,
|
||||
metatileHeight);
|
||||
if (tilesHeight % tileHeight != 0)
|
||||
FATAL_ERROR("The height in tiles (%d) isn't a multiple of the specified tile height (%d)", tilesHeight,
|
||||
tileHeight);
|
||||
|
||||
image->width = tilesWidth * 8;
|
||||
image->height = tilesHeight * 8;
|
||||
@@ -236,19 +236,19 @@ void ReadImage(char* path, int tilesWidth, int bitDepth, int metatileWidth, int
|
||||
if (image->pixels == NULL)
|
||||
FATAL_ERROR("Failed to allocate memory for pixels.\n");
|
||||
|
||||
int metatilesWide = tilesWidth / metatileWidth;
|
||||
int tilesWide = tilesWidth / tileWidth;
|
||||
|
||||
switch (bitDepth) {
|
||||
case 1:
|
||||
ConvertFromTiles1Bpp(buffer, image->pixels, numTiles, metatilesWide, metatileWidth, metatileHeight,
|
||||
ConvertFromTiles1Bpp(buffer, image->pixels, numTiles, tilesWide, tileWidth, tileHeight,
|
||||
invertColors);
|
||||
break;
|
||||
case 4:
|
||||
ConvertFromTiles4Bpp(buffer, image->pixels, numTiles, metatilesWide, metatileWidth, metatileHeight,
|
||||
ConvertFromTiles4Bpp(buffer, image->pixels, numTiles, tilesWide, tileWidth, tileHeight,
|
||||
invertColors);
|
||||
break;
|
||||
case 8:
|
||||
ConvertFromTiles8Bpp(buffer, image->pixels, numTiles, metatilesWide, metatileWidth, metatileHeight,
|
||||
ConvertFromTiles8Bpp(buffer, image->pixels, numTiles, tilesWide, tileWidth, tileHeight,
|
||||
invertColors);
|
||||
break;
|
||||
}
|
||||
@@ -256,7 +256,7 @@ void ReadImage(char* path, int tilesWidth, int bitDepth, int metatileWidth, int
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
void WriteImage(char* path, int numTiles, int bitDepth, int metatileWidth, int metatileHeight, struct Image* image,
|
||||
void WriteImage(char* path, int numTiles, int bitDepth, int tileWidth, int tileHeight, struct Image* image,
|
||||
bool invertColors) {
|
||||
int tileSize = bitDepth * 8;
|
||||
|
||||
@@ -269,13 +269,13 @@ void WriteImage(char* path, int numTiles, int bitDepth, int metatileWidth, int m
|
||||
int tilesWidth = image->width / 8;
|
||||
int tilesHeight = image->height / 8;
|
||||
|
||||
if (tilesWidth % metatileWidth != 0)
|
||||
FATAL_ERROR("The width in tiles (%d) isn't a multiple of the specified metatile width (%d)", tilesWidth,
|
||||
metatileWidth);
|
||||
if (tilesWidth % tileWidth != 0)
|
||||
FATAL_ERROR("The width in tiles (%d) isn't a multiple of the specified tile width (%d)", tilesWidth,
|
||||
tileWidth);
|
||||
|
||||
if (tilesHeight % metatileHeight != 0)
|
||||
FATAL_ERROR("The height in tiles (%d) isn't a multiple of the specified metatile height (%d)", tilesHeight,
|
||||
metatileHeight);
|
||||
if (tilesHeight % tileHeight != 0)
|
||||
FATAL_ERROR("The height in tiles (%d) isn't a multiple of the specified tile height (%d)", tilesHeight,
|
||||
tileHeight);
|
||||
|
||||
int maxNumTiles = tilesWidth * tilesHeight;
|
||||
|
||||
@@ -291,19 +291,19 @@ 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 tilesWide = tilesWidth / tileWidth;
|
||||
|
||||
switch (bitDepth) {
|
||||
case 1:
|
||||
ConvertToTiles1Bpp(image->pixels, buffer, numTiles, metatilesWide, metatileWidth, metatileHeight,
|
||||
ConvertToTiles1Bpp(image->pixels, buffer, numTiles, tilesWide, tileWidth, tileHeight,
|
||||
invertColors);
|
||||
break;
|
||||
case 4:
|
||||
ConvertToTiles4Bpp(image->pixels, buffer, numTiles, metatilesWide, metatileWidth, metatileHeight,
|
||||
ConvertToTiles4Bpp(image->pixels, buffer, numTiles, tilesWide, tileWidth, tileHeight,
|
||||
invertColors);
|
||||
break;
|
||||
case 8:
|
||||
ConvertToTiles8Bpp(image->pixels, buffer, numTiles, metatilesWide, metatileWidth, metatileHeight,
|
||||
ConvertToTiles8Bpp(image->pixels, buffer, numTiles, tilesWide, tileWidth, tileHeight,
|
||||
invertColors);
|
||||
break;
|
||||
}
|
||||
|
||||
Vendored
+2
-2
@@ -27,9 +27,9 @@ struct Image {
|
||||
bool hasTransparency;
|
||||
};
|
||||
|
||||
void ReadImage(char* path, int tilesWidth, int bitDepth, int metatileWidth, int metatileHeight, struct Image* image,
|
||||
void ReadImage(char* path, int tilesWidth, int bitDepth, int tileWidth, int tileHeight, struct Image* image,
|
||||
bool invertColors);
|
||||
void WriteImage(char* path, int numTiles, int bitDepth, int metatileWidth, int metatileHeight, struct Image* image,
|
||||
void WriteImage(char* path, int numTiles, int bitDepth, int tileWidth, int tileHeight, struct Image* image,
|
||||
bool invertColors);
|
||||
void FreeImage(struct Image* image);
|
||||
void ReadGbaPalette(char* path, struct Palette* palette);
|
||||
|
||||
Vendored
+28
-28
@@ -30,7 +30,7 @@ void ConvertGbaToPng(char* inputPath, char* outputPath, struct GbaToPngOptions*
|
||||
image.hasPalette = false;
|
||||
}
|
||||
|
||||
ReadImage(inputPath, options->width, options->bitDepth, options->metatileWidth, options->metatileHeight, &image,
|
||||
ReadImage(inputPath, options->width, options->bitDepth, options->tileWidth, options->tileHeight, &image,
|
||||
!image.hasPalette);
|
||||
|
||||
image.hasTransparency = options->hasTransparency;
|
||||
@@ -47,7 +47,7 @@ void ConvertPngToGba(char* inputPath, char* outputPath, struct PngToGbaOptions*
|
||||
|
||||
ReadPng(inputPath, &image);
|
||||
|
||||
WriteImage(outputPath, options->numTiles, options->bitDepth, options->metatileWidth, options->metatileHeight,
|
||||
WriteImage(outputPath, options->numTiles, options->bitDepth, options->tileWidth, options->tileHeight,
|
||||
&image, !image.hasPalette);
|
||||
|
||||
FreeImage(&image);
|
||||
@@ -60,8 +60,8 @@ void HandleGbaToPngCommand(char* inputPath, char* outputPath, int argc, char** a
|
||||
options.bitDepth = inputFileExtension[0] - '0';
|
||||
options.hasTransparency = false;
|
||||
options.width = 1;
|
||||
options.metatileWidth = 1;
|
||||
options.metatileHeight = 1;
|
||||
options.tileWidth = 1;
|
||||
options.tileHeight = 1;
|
||||
|
||||
for (int i = 3; i < argc; i++) {
|
||||
char* option = argv[i];
|
||||
@@ -88,33 +88,33 @@ void HandleGbaToPngCommand(char* inputPath, char* outputPath, int argc, char** a
|
||||
FATAL_ERROR("Width must be positive.\n");
|
||||
} else if (strcmp(option, "-mwidth") == 0) {
|
||||
if (i + 1 >= argc)
|
||||
FATAL_ERROR("No metatile width value following \"-mwidth\".\n");
|
||||
FATAL_ERROR("No tile width value following \"-mwidth\".\n");
|
||||
|
||||
i++;
|
||||
|
||||
if (!ParseNumber(argv[i], NULL, 10, &options.metatileWidth))
|
||||
FATAL_ERROR("Failed to parse metatile width.\n");
|
||||
if (!ParseNumber(argv[i], NULL, 10, &options.tileWidth))
|
||||
FATAL_ERROR("Failed to parse tile width.\n");
|
||||
|
||||
if (options.metatileWidth < 1)
|
||||
FATAL_ERROR("metatile width must be positive.\n");
|
||||
if (options.tileWidth < 1)
|
||||
FATAL_ERROR("tile width must be positive.\n");
|
||||
} else if (strcmp(option, "-mheight") == 0) {
|
||||
if (i + 1 >= argc)
|
||||
FATAL_ERROR("No metatile height value following \"-mheight\".\n");
|
||||
FATAL_ERROR("No tile height value following \"-mheight\".\n");
|
||||
|
||||
i++;
|
||||
|
||||
if (!ParseNumber(argv[i], NULL, 10, &options.metatileHeight))
|
||||
FATAL_ERROR("Failed to parse metatile height.\n");
|
||||
if (!ParseNumber(argv[i], NULL, 10, &options.tileHeight))
|
||||
FATAL_ERROR("Failed to parse tile height.\n");
|
||||
|
||||
if (options.metatileHeight < 1)
|
||||
FATAL_ERROR("metatile height must be positive.\n");
|
||||
if (options.tileHeight < 1)
|
||||
FATAL_ERROR("tile height must be positive.\n");
|
||||
} else {
|
||||
FATAL_ERROR("Unrecognized option \"%s\".\n", option);
|
||||
}
|
||||
}
|
||||
|
||||
if (options.metatileWidth > options.width)
|
||||
options.width = options.metatileWidth;
|
||||
if (options.tileWidth > options.width)
|
||||
options.width = options.tileWidth;
|
||||
|
||||
ConvertGbaToPng(inputPath, outputPath, &options);
|
||||
}
|
||||
@@ -125,8 +125,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.tileWidth = 1;
|
||||
options.tileHeight = 1;
|
||||
|
||||
for (int i = 3; i < argc; i++) {
|
||||
char* option = argv[i];
|
||||
@@ -144,26 +144,26 @@ void HandlePngToGbaCommand(char* inputPath, char* outputPath, int argc, char** a
|
||||
FATAL_ERROR("Number of tiles must be positive.\n");
|
||||
} else if (strcmp(option, "-mwidth") == 0) {
|
||||
if (i + 1 >= argc)
|
||||
FATAL_ERROR("No metatile width value following \"-mwidth\".\n");
|
||||
FATAL_ERROR("No tile width value following \"-mwidth\".\n");
|
||||
|
||||
i++;
|
||||
|
||||
if (!ParseNumber(argv[i], NULL, 10, &options.metatileWidth))
|
||||
FATAL_ERROR("Failed to parse metatile width.\n");
|
||||
if (!ParseNumber(argv[i], NULL, 10, &options.tileWidth))
|
||||
FATAL_ERROR("Failed to parse tile width.\n");
|
||||
|
||||
if (options.metatileWidth < 1)
|
||||
FATAL_ERROR("metatile width must be positive.\n");
|
||||
if (options.tileWidth < 1)
|
||||
FATAL_ERROR("tile width must be positive.\n");
|
||||
} else if (strcmp(option, "-mheight") == 0) {
|
||||
if (i + 1 >= argc)
|
||||
FATAL_ERROR("No metatile height value following \"-mheight\".\n");
|
||||
FATAL_ERROR("No tile height value following \"-mheight\".\n");
|
||||
|
||||
i++;
|
||||
|
||||
if (!ParseNumber(argv[i], NULL, 10, &options.metatileHeight))
|
||||
FATAL_ERROR("Failed to parse metatile height.\n");
|
||||
if (!ParseNumber(argv[i], NULL, 10, &options.tileHeight))
|
||||
FATAL_ERROR("Failed to parse tile height.\n");
|
||||
|
||||
if (options.metatileHeight < 1)
|
||||
FATAL_ERROR("metatile height must be positive.\n");
|
||||
if (options.tileHeight < 1)
|
||||
FATAL_ERROR("tile height must be positive.\n");
|
||||
} else {
|
||||
FATAL_ERROR("Unrecognized option \"%s\".\n", option);
|
||||
}
|
||||
|
||||
Vendored
+4
-4
@@ -10,15 +10,15 @@ struct GbaToPngOptions {
|
||||
int bitDepth;
|
||||
bool hasTransparency;
|
||||
int width;
|
||||
int metatileWidth;
|
||||
int metatileHeight;
|
||||
int tileWidth;
|
||||
int tileHeight;
|
||||
};
|
||||
|
||||
struct PngToGbaOptions {
|
||||
int numTiles;
|
||||
int bitDepth;
|
||||
int metatileWidth;
|
||||
int metatileHeight;
|
||||
int tileWidth;
|
||||
int tileHeight;
|
||||
};
|
||||
|
||||
#endif // OPTIONS_H
|
||||
|
||||
Reference in New Issue
Block a user