diff options
author | YamaArashi <shadow962@live.com> | 2016-07-29 16:41:13 -0700 |
---|---|---|
committer | YamaArashi <shadow962@live.com> | 2016-07-29 16:41:13 -0700 |
commit | fdcf7a4e3c8b0a579e4cc77ad0b0196ef8ab5f18 (patch) | |
tree | 80e01a7080b08398217c15f30a2460f41b67673f | |
parent | f2aa5b200fe51ed9adf86b05c9ca7dae437babce (diff) |
diploma tilemap/palette
-rw-r--r-- | data/data2.s | 9 | ||||
-rw-r--r-- | graphics/misc/diploma_hoenn.pal | 19 | ||||
-rw-r--r-- | graphics/misc/diploma_map.bin | bin | 0 -> 4096 bytes | |||
-rwxr-xr-x | graphics/misc/diploma_national.pal (renamed from graphics/misc/diploma.pal) | 0 | ||||
-rw-r--r-- | tools/gbagfx/jasc_pal.c | 178 | ||||
-rw-r--r-- | tools/gbagfx/main.c | 449 |
6 files changed, 355 insertions, 300 deletions
diff --git a/data/data2.s b/data/data2.s index 980ba0f5a..346ae77ea 100644 --- a/data/data2.s +++ b/data/data2.s @@ -25370,13 +25370,16 @@ gSpriteTemplate_840CAEC:: @ 840CAEC gUnknown_0840CB04:: @ 840CB04 .incbin "baserom.gba", 0x0040cb04, 0x8 + .align 2 gUnknown_0840CB0C:: @ 840CB0C - .incbin "graphics/misc/diploma.gbapal" - .incbin "baserom.gba", 0x0040cb2c, 0x20 + .incbin "graphics/misc/diploma_national.gbapal" + .incbin "graphics/misc/diploma_hoenn.gbapal" + .align 2 gUnknown_0840CB4C:: @ 840CB4C - .incbin "baserom.gba", 0x0040cb4c, 0x73c + .incbin "graphics/misc/diploma_map.bin.lz" + .align 2 gUnknown_0840D288:: @ 840D288 .incbin "graphics/misc/diploma.4bpp.lz" diff --git a/graphics/misc/diploma_hoenn.pal b/graphics/misc/diploma_hoenn.pal new file mode 100644 index 000000000..2890eb24a --- /dev/null +++ b/graphics/misc/diploma_hoenn.pal @@ -0,0 +1,19 @@ +JASC-PAL +0100 +16 +24 41 82 +255 255 222 +246 238 230 +205 230 139 +172 222 49 +238 238 222 +222 230 230 +255 222 197 +222 222 189 +246 246 180 +238 230 180 +213 213 156 +230 230 139 +255 255 123 +238 238 106 +255 205 172 diff --git a/graphics/misc/diploma_map.bin b/graphics/misc/diploma_map.bin Binary files differnew file mode 100644 index 000000000..e9a47fa44 --- /dev/null +++ b/graphics/misc/diploma_map.bin diff --git a/graphics/misc/diploma.pal b/graphics/misc/diploma_national.pal index 03c37bf22..03c37bf22 100755 --- a/graphics/misc/diploma.pal +++ b/graphics/misc/diploma_national.pal diff --git a/tools/gbagfx/jasc_pal.c b/tools/gbagfx/jasc_pal.c index d003b7649..e5ba9c3c2 100644 --- a/tools/gbagfx/jasc_pal.c +++ b/tools/gbagfx/jasc_pal.c @@ -26,139 +26,147 @@ void ReadJascPaletteLine(FILE *fp, char *line) { - int c; - int length = 0; + int c; + int length = 0; - for (;;) { - c = fgetc(fp); + for (;;) + { + c = fgetc(fp); - if (c == '\r') { - c = fgetc(fp); + if (c == '\r') + { + c = fgetc(fp); - if (c != '\n') - FATAL_ERROR("CR line endings aren't supported.\n"); + if (c != '\n') + FATAL_ERROR("CR line endings aren't supported.\n"); - line[length] = 0; + line[length] = 0; - return; - } + return; + } - if (c == '\n') - FATAL_ERROR("LF line endings aren't supported.\n"); + if (c == '\n') + FATAL_ERROR("LF line endings aren't supported.\n"); - if (c == EOF) - FATAL_ERROR("Unexpected EOF. No CRLF at end of file.\n"); + if (c == EOF) + FATAL_ERROR("Unexpected EOF. No CRLF at end of file.\n"); - if (c == 0) - FATAL_ERROR("NUL character in file.\n"); + if (c == 0) + FATAL_ERROR("NUL character in file.\n"); - if (length == MAX_LINE_LENGTH) { - line[length] = 0; - FATAL_ERROR("The line \"%s\" is too long.\n", line); - } + if (length == MAX_LINE_LENGTH) + { + line[length] = 0; + FATAL_ERROR("The line \"%s\" is too long.\n", line); + } - line[length++] = c; - } + line[length++] = c; + } } void ReadJascPalette(char *path, struct Palette *palette) { - char line[MAX_LINE_LENGTH + 1]; + char line[MAX_LINE_LENGTH + 1]; - FILE *fp = fopen(path, "rb"); + FILE *fp = fopen(path, "rb"); - ReadJascPaletteLine(fp, line); + if (fp == NULL) + FATAL_ERROR("Failed to open JASC-PAL file \"%s\" for reading.\n", path); - if (strcmp(line, "JASC-PAL") != 0) - FATAL_ERROR("Invalid JASC-PAL signature.\n"); + ReadJascPaletteLine(fp, line); - ReadJascPaletteLine(fp, line); + if (strcmp(line, "JASC-PAL") != 0) + FATAL_ERROR("Invalid JASC-PAL signature.\n"); - if (strcmp(line, "0100") != 0) - FATAL_ERROR("Unsuported JASC-PAL version.\n"); + ReadJascPaletteLine(fp, line); - ReadJascPaletteLine(fp, line); + if (strcmp(line, "0100") != 0) + FATAL_ERROR("Unsuported JASC-PAL version.\n"); - if (!ParseNumber(line, NULL, 10, &palette->numColors)) - FATAL_ERROR("Failed to parse number of colors.\n"); + ReadJascPaletteLine(fp, line); - if (palette->numColors < 1 || palette->numColors > 256) - FATAL_ERROR("%d is an invalid number of colors. The number of colors must be in the range [1, 256].\n", palette->numColors); + if (!ParseNumber(line, NULL, 10, &palette->numColors)) + FATAL_ERROR("Failed to parse number of colors.\n"); - for (int i = 0; i < palette->numColors; i++) { - ReadJascPaletteLine(fp, line); + if (palette->numColors < 1 || palette->numColors > 256) + FATAL_ERROR("%d is an invalid number of colors. The number of colors must be in the range [1, 256].\n", palette->numColors); - char *s = line; - char *end; + for (int i = 0; i < palette->numColors; i++) + { + ReadJascPaletteLine(fp, line); - int red; - int green; - int blue; + char *s = line; + char *end; - if (!ParseNumber(s, &end, 10, &red)) - FATAL_ERROR("Failed to parse red color component.\n"); + int red; + int green; + int blue; - s = end; + if (!ParseNumber(s, &end, 10, &red)) + FATAL_ERROR("Failed to parse red color component.\n"); - if (*s != ' ') - FATAL_ERROR("Expected a space after red color component.\n"); + s = end; - s++; + if (*s != ' ') + FATAL_ERROR("Expected a space after red color component.\n"); - if (*s < '0' || *s > '9') - FATAL_ERROR("Expected only a space between red and green color components.\n"); + s++; - if (!ParseNumber(s, &end, 10, &green)) - FATAL_ERROR("Failed to parse green color component.\n"); + if (*s < '0' || *s > '9') + FATAL_ERROR("Expected only a space between red and green color components.\n"); - s = end; + if (!ParseNumber(s, &end, 10, &green)) + FATAL_ERROR("Failed to parse green color component.\n"); - if (*s != ' ') - FATAL_ERROR("Expected a space after green color component.\n"); + s = end; - s++; + if (*s != ' ') + FATAL_ERROR("Expected a space after green color component.\n"); - if (*s < '0' || *s > '9') - FATAL_ERROR("Expected only a space between green and blue color components.\n"); + s++; - if (!ParseNumber(s, &end, 10, &blue)) - FATAL_ERROR("Failed to parse blue color component.\n"); + if (*s < '0' || *s > '9') + FATAL_ERROR("Expected only a space between green and blue color components.\n"); - if (*end != 0) - FATAL_ERROR("Garbage after blue color component.\n"); + if (!ParseNumber(s, &end, 10, &blue)) + FATAL_ERROR("Failed to parse blue color component.\n"); - if (red < 0 || red > 255) - FATAL_ERROR("Red color component (%d) is outside the range [0, 255].\n", red); + if (*end != 0) + FATAL_ERROR("Garbage after blue color component.\n"); - if (green < 0 || green > 255) - FATAL_ERROR("Green color component (%d) is outside the range [0, 255].\n", green); + if (red < 0 || red > 255) + FATAL_ERROR("Red color component (%d) is outside the range [0, 255].\n", red); - if (blue < 0 || blue > 255) - FATAL_ERROR("Blue color component (%d) is outside the range [0, 255].\n", blue); + if (green < 0 || green > 255) + FATAL_ERROR("Green color component (%d) is outside the range [0, 255].\n", green); - palette->colors[i].red = red; - palette->colors[i].green = green; - palette->colors[i].blue = blue; - } + if (blue < 0 || blue > 255) + FATAL_ERROR("Blue color component (%d) is outside the range [0, 255].\n", blue); - if (fgetc(fp) != EOF) - FATAL_ERROR("Garbage after color data.\n"); + palette->colors[i].red = red; + palette->colors[i].green = green; + palette->colors[i].blue = blue; + } - fclose(fp); + if (fgetc(fp) != EOF) + FATAL_ERROR("Garbage after color data.\n"); + + fclose(fp); } void WriteJascPalette(char *path, struct Palette *palette) { - FILE *fp = fopen(path, "wb"); + FILE *fp = fopen(path, "wb"); - fputs("JASC-PAL\r\n", fp); - fputs("0100\r\n", fp); - fprintf(fp, "%d\r\n", palette->numColors); + fputs("JASC-PAL\r\n", fp); + fputs("0100\r\n", fp); + fprintf(fp, "%d\r\n", palette->numColors); - for (int i = 0; i < palette->numColors; i++) { - struct Color *color = &palette->colors[i]; - fprintf(fp, "%d %d %d\r\n", color->red, color->green, color->blue); - } + for (int i = 0; i < palette->numColors; i++) + { + struct Color *color = &palette->colors[i]; + fprintf(fp, "%d %d %d\r\n", color->red, color->green, color->blue); + } - fclose(fp); + fclose(fp); } diff --git a/tools/gbagfx/main.c b/tools/gbagfx/main.c index 54a3c600d..0624201df 100644 --- a/tools/gbagfx/main.c +++ b/tools/gbagfx/main.c @@ -14,280 +14,303 @@ struct CommandHandler { - const char *inputFileExtension; - const char *outputFileExtension; - void(*function)(char *inputPath, char *outputPath, int argc, char **argv); + const char *inputFileExtension; + const char *outputFileExtension; + void(*function)(char *inputPath, char *outputPath, int argc, char **argv); }; void ConvertGbaToPng(char *inputPath, char *outputPath, int width, int bitDepth, char *paletteFilePath, bool hasTransparency) { - struct Image image; + struct Image image; - if (paletteFilePath != NULL) { - ReadGbaPalette(paletteFilePath, &image.palette); - image.hasPalette = true; - } else { - image.hasPalette = false; - } + if (paletteFilePath != NULL) + { + ReadGbaPalette(paletteFilePath, &image.palette); + image.hasPalette = true; + } + else + { + image.hasPalette = false; + } - ReadImage(inputPath, width, bitDepth, &image, !image.hasPalette); + ReadImage(inputPath, width, bitDepth, &image, !image.hasPalette); - image.hasTransparency = hasTransparency; + image.hasTransparency = hasTransparency; - WritePng(outputPath, &image); + WritePng(outputPath, &image); - FreeImage(&image); + FreeImage(&image); } void ConvertPngToGba(char *inputPath, char *outputPath, int numTiles, int bitDepth) { - struct Image image; + struct Image image; - image.bitDepth = bitDepth; + image.bitDepth = bitDepth; - ReadPng(inputPath, &image); + ReadPng(inputPath, &image); - WriteImage(outputPath, numTiles, bitDepth, &image, !image.hasPalette); + WriteImage(outputPath, numTiles, bitDepth, &image, !image.hasPalette); - FreeImage(&image); + FreeImage(&image); } void HandleGbaToPngCommand(char *inputPath, char *outputPath, int argc, char **argv) { - char *inputFileExtension = GetFileExtension(inputPath); - int bitDepth = inputFileExtension[0] - '0'; - char *paletteFilePath; - bool hasPalette = false; - bool hasTransparency = false; - int width = 1; - - for (int i = 3; i < argc; i++) { - char *option = argv[i]; - - if (strcmp(option, "-palette") == 0) { - if (i + 1 >= argc) - FATAL_ERROR("No palette file path following \"-palette\".\n"); - - i++; - - paletteFilePath = argv[i]; - - hasPalette = true; - } else if (strcmp(option, "-object") == 0) { - hasTransparency = true; - } else if (strcmp(option, "-width") == 0) { - if (i + 1 >= argc) - FATAL_ERROR("No width following \"-width\".\n"); - - i++; - - if (!ParseNumber(argv[i], NULL, 10, &width)) - FATAL_ERROR("Failed to parse width.\n"); - - if (width < 1) - FATAL_ERROR("Width must be positive.\n"); - } else { - FATAL_ERROR("Unrecognized option \"%s\".\n", option); - } - } - - ConvertGbaToPng(inputPath, outputPath, width, bitDepth, hasPalette ? paletteFilePath : NULL, hasTransparency); + char *inputFileExtension = GetFileExtension(inputPath); + int bitDepth = inputFileExtension[0] - '0'; + char *paletteFilePath; + bool hasPalette = false; + bool hasTransparency = false; + int width = 1; + + for (int i = 3; i < argc; i++) + { + char *option = argv[i]; + + if (strcmp(option, "-palette") == 0) + { + if (i + 1 >= argc) + FATAL_ERROR("No palette file path following \"-palette\".\n"); + + i++; + + paletteFilePath = argv[i]; + + hasPalette = true; + } + else if (strcmp(option, "-object") == 0) + { + hasTransparency = true; + } + else if (strcmp(option, "-width") == 0) + { + if (i + 1 >= argc) + FATAL_ERROR("No width following \"-width\".\n"); + + i++; + + if (!ParseNumber(argv[i], NULL, 10, &width)) + FATAL_ERROR("Failed to parse width.\n"); + + if (width < 1) + FATAL_ERROR("Width must be positive.\n"); + } + else + { + FATAL_ERROR("Unrecognized option \"%s\".\n", option); + } + } + + ConvertGbaToPng(inputPath, outputPath, width, bitDepth, hasPalette ? paletteFilePath : NULL, hasTransparency); } void HandlePngToGbaCommand(char *inputPath, char *outputPath, int argc, char **argv) { - char *outputFileExtension = GetFileExtension(outputPath); - int bitDepth = outputFileExtension[0] - '0'; - int numTiles = 0; - - for (int i = 3; i < argc; i++) { - char *option = argv[i]; - - if (strcmp(option, "-num_tiles") == 0) { - if (i + 1 >= argc) - FATAL_ERROR("No number of tiles following \"-num_tiles\".\n"); - - i++; - - if (!ParseNumber(argv[i], NULL, 10, &numTiles)) - FATAL_ERROR("Failed to parse number of tiles.\n"); - - if (numTiles < 1) - FATAL_ERROR("Number of tiles must be positive.\n"); - } else { - FATAL_ERROR("Unrecognized option \"%s\".\n", option); - } - } - - ConvertPngToGba(inputPath, outputPath, numTiles, bitDepth); + char *outputFileExtension = GetFileExtension(outputPath); + int bitDepth = outputFileExtension[0] - '0'; + int numTiles = 0; + + for (int i = 3; i < argc; i++) + { + char *option = argv[i]; + + if (strcmp(option, "-num_tiles") == 0) + { + if (i + 1 >= argc) + FATAL_ERROR("No number of tiles following \"-num_tiles\".\n"); + + i++; + + if (!ParseNumber(argv[i], NULL, 10, &numTiles)) + FATAL_ERROR("Failed to parse number of tiles.\n"); + + if (numTiles < 1) + FATAL_ERROR("Number of tiles must be positive.\n"); + } + else + { + FATAL_ERROR("Unrecognized option \"%s\".\n", option); + } + } + + ConvertPngToGba(inputPath, outputPath, numTiles, bitDepth); } void HandleGbaToJascPaletteCommand(char *inputPath, char *outputPath, int argc UNUSED, char **argv UNUSED) { - struct Palette palette; + struct Palette palette; - ReadGbaPalette(inputPath, &palette); - WriteJascPalette(outputPath, &palette); + ReadGbaPalette(inputPath, &palette); + WriteJascPalette(outputPath, &palette); } void HandleJascToGbaPaletteCommand(char *inputPath, char *outputPath, int argc, char **argv) { - int numColors = 0; + int numColors = 0; - for (int i = 3; i < argc; i++) { - char *option = argv[i]; + for (int i = 3; i < argc; i++) + { + char *option = argv[i]; - if (strcmp(option, "-num_colors") == 0) { - if (i + 1 >= argc) - FATAL_ERROR("No number of colors following \"-num_colors\".\n"); + if (strcmp(option, "-num_colors") == 0) + { + if (i + 1 >= argc) + FATAL_ERROR("No number of colors following \"-num_colors\".\n"); - i++; + i++; - if (!ParseNumber(argv[i], NULL, 10, &numColors)) - FATAL_ERROR("Failed to parse number of colors.\n"); + if (!ParseNumber(argv[i], NULL, 10, &numColors)) + FATAL_ERROR("Failed to parse number of colors.\n"); - if (numColors < 1) - FATAL_ERROR("Number of colors must be positive.\n"); - } else { - FATAL_ERROR("Unrecognized option \"%s\".\n", option); - } - } + if (numColors < 1) + FATAL_ERROR("Number of colors must be positive.\n"); + } + else + { + FATAL_ERROR("Unrecognized option \"%s\".\n", option); + } + } - struct Palette palette; + struct Palette palette; - ReadJascPalette(inputPath, &palette); + ReadJascPalette(inputPath, &palette); - if (numColors != 0) - palette.numColors = numColors; + if (numColors != 0) + palette.numColors = numColors; - WriteGbaPalette(outputPath, &palette); + WriteGbaPalette(outputPath, &palette); } void HandleLatinFontToPngCommand(char *inputPath, char *outputPath, int argc UNUSED, char **argv UNUSED) { - struct Image image; + struct Image image; - ReadLatinFont(inputPath, &image); - WritePng(outputPath, &image); + ReadLatinFont(inputPath, &image); + WritePng(outputPath, &image); - FreeImage(&image); + FreeImage(&image); } void HandlePngToLatinFontCommand(char *inputPath, char *outputPath, int argc UNUSED, char **argv UNUSED) { - struct Image image; + struct Image image; - image.bitDepth = 2; + image.bitDepth = 2; - ReadPng(inputPath, &image); - WriteLatinFont(outputPath, &image); + ReadPng(inputPath, &image); + WriteLatinFont(outputPath, &image); - FreeImage(&image); + FreeImage(&image); } void HandleHalfwidthJapaneseFontToPngCommand(char *inputPath, char *outputPath, int argc UNUSED, char **argv UNUSED) { - struct Image image; + struct Image image; - ReadHalfwidthJapaneseFont(inputPath, &image); - WritePng(outputPath, &image); + ReadHalfwidthJapaneseFont(inputPath, &image); + WritePng(outputPath, &image); - FreeImage(&image); + FreeImage(&image); } void HandlePngToHalfwidthJapaneseFontCommand(char *inputPath, char *outputPath, int argc UNUSED, char **argv UNUSED) { - struct Image image; + struct Image image; - image.bitDepth = 2; + image.bitDepth = 2; - ReadPng(inputPath, &image); - WriteHalfwidthJapaneseFont(outputPath, &image); + ReadPng(inputPath, &image); + WriteHalfwidthJapaneseFont(outputPath, &image); - FreeImage(&image); + FreeImage(&image); } void HandleFullwidthJapaneseFontToPngCommand(char *inputPath, char *outputPath, int argc UNUSED, char **argv UNUSED) { - struct Image image; + struct Image image; - ReadFullwidthJapaneseFont(inputPath, &image); - WritePng(outputPath, &image); + ReadFullwidthJapaneseFont(inputPath, &image); + WritePng(outputPath, &image); - FreeImage(&image); + FreeImage(&image); } void HandlePngToFullwidthJapaneseFontCommand(char *inputPath, char *outputPath, int argc UNUSED, char **argv UNUSED) { - struct Image image; + struct Image image; - image.bitDepth = 2; + image.bitDepth = 2; - ReadPng(inputPath, &image); - WriteFullwidthJapaneseFont(outputPath, &image); + ReadPng(inputPath, &image); + WriteFullwidthJapaneseFont(outputPath, &image); - FreeImage(&image); + FreeImage(&image); } void HandleLZCompressCommand(char *inputPath, char *outputPath, int argc, char **argv) { - int overflowSize = 0; + int overflowSize = 0; - for (int i = 3; i < argc; i++) { - char *option = argv[i]; + for (int i = 3; i < argc; i++) + { + char *option = argv[i]; - if (strcmp(option, "-overflow") == 0) { - if (i + 1 >= argc) - FATAL_ERROR("No size following \"-overflow\".\n"); + if (strcmp(option, "-overflow") == 0) + { + if (i + 1 >= argc) + FATAL_ERROR("No size following \"-overflow\".\n"); - i++; + i++; - if (!ParseNumber(argv[i], NULL, 10, &overflowSize)) - FATAL_ERROR("Failed to parse overflow size.\n"); + if (!ParseNumber(argv[i], NULL, 10, &overflowSize)) + FATAL_ERROR("Failed to parse overflow size.\n"); - if (overflowSize < 1) - FATAL_ERROR("Overflow size must be positive.\n"); - } else { - FATAL_ERROR("Unrecognized option \"%s\".\n", option); - } - } + if (overflowSize < 1) + FATAL_ERROR("Overflow size must be positive.\n"); + } + else + { + FATAL_ERROR("Unrecognized option \"%s\".\n", option); + } + } - // The overflow option allows a quirk in some of Ruby/Sapphire's tilesets - // to be reproduced. It works by appending a number of zeros to the data - // before compressing it and then amending the LZ header's size field to - // reflect the expected size. This will cause an overflow when decompressing - // the data. + // The overflow option allows a quirk in some of Ruby/Sapphire's tilesets + // to be reproduced. It works by appending a number of zeros to the data + // before compressing it and then amending the LZ header's size field to + // reflect the expected size. This will cause an overflow when decompressing + // the data. - int fileSize; - unsigned char *buffer = ReadWholeFileZeroPadded(inputPath, &fileSize, overflowSize); + int fileSize; + unsigned char *buffer = ReadWholeFileZeroPadded(inputPath, &fileSize, overflowSize); - int compressedSize; - unsigned char *compressedData = LZCompress(buffer, fileSize + overflowSize, &compressedSize); + int compressedSize; + unsigned char *compressedData = LZCompress(buffer, fileSize + overflowSize, &compressedSize); - compressedData[1] = (unsigned char)fileSize; - compressedData[2] = (unsigned char)(fileSize >> 8); - compressedData[3] = (unsigned char)(fileSize >> 16); + compressedData[1] = (unsigned char)fileSize; + compressedData[2] = (unsigned char)(fileSize >> 8); + compressedData[3] = (unsigned char)(fileSize >> 16); - free(buffer); + free(buffer); - WriteWholeFile(outputPath, compressedData, compressedSize); + WriteWholeFile(outputPath, compressedData, compressedSize); - free(compressedData); + free(compressedData); } void HandleLZDecompressCommand(char *inputPath, char *outputPath, int argc UNUSED, char **argv UNUSED) { - int fileSize; - unsigned char *buffer = ReadWholeFile(inputPath, &fileSize); + int fileSize; + unsigned char *buffer = ReadWholeFile(inputPath, &fileSize); - int uncompressedSize; - unsigned char *uncompressedData = LZDecompress(buffer, fileSize, &uncompressedSize); + int uncompressedSize; + unsigned char *uncompressedData = LZDecompress(buffer, fileSize, &uncompressedSize); - free(buffer); + free(buffer); - WriteWholeFile(outputPath, uncompressedData, uncompressedSize); + WriteWholeFile(outputPath, uncompressedData, uncompressedSize); - free(uncompressedData); + free(uncompressedData); } void HandleRLCompressCommand(char *inputPath, char *outputPath, int argc UNUSED, char **argv UNUSED) @@ -322,50 +345,52 @@ void HandleRLDecompressCommand(char *inputPath, char *outputPath, int argc UNUSE int main(int argc, char **argv) { - if (argc < 3) - FATAL_ERROR("Usage: gbagfx INPUT_PATH OUTPUT_PATH [options...]\n"); - - struct CommandHandler handlers[] = - { - { "1bpp", "png", HandleGbaToPngCommand }, - { "4bpp", "png", HandleGbaToPngCommand }, - { "8bpp", "png", HandleGbaToPngCommand }, - { "png", "1bpp", HandlePngToGbaCommand }, - { "png", "4bpp", HandlePngToGbaCommand }, - { "png", "8bpp", HandlePngToGbaCommand }, - { "gbapal", "pal", HandleGbaToJascPaletteCommand }, - { "pal", "gbapal", HandleJascToGbaPaletteCommand }, - { "latfont", "png", HandleLatinFontToPngCommand }, - { "png", "latfont", HandlePngToLatinFontCommand }, - { "hwjpnfont", "png", HandleHalfwidthJapaneseFontToPngCommand }, - { "png", "hwjpnfont", HandlePngToHalfwidthJapaneseFontCommand }, - { "fwjpnfont", "png", HandleFullwidthJapaneseFontToPngCommand }, - { "png", "fwjpnfont", HandlePngToFullwidthJapaneseFontCommand }, - { NULL, "lz", HandleLZCompressCommand }, - { "lz", NULL, HandleLZDecompressCommand }, + if (argc < 3) + FATAL_ERROR("Usage: gbagfx INPUT_PATH OUTPUT_PATH [options...]\n"); + + struct CommandHandler handlers[] = + { + { "1bpp", "png", HandleGbaToPngCommand }, + { "4bpp", "png", HandleGbaToPngCommand }, + { "8bpp", "png", HandleGbaToPngCommand }, + { "png", "1bpp", HandlePngToGbaCommand }, + { "png", "4bpp", HandlePngToGbaCommand }, + { "png", "8bpp", HandlePngToGbaCommand }, + { "gbapal", "pal", HandleGbaToJascPaletteCommand }, + { "pal", "gbapal", HandleJascToGbaPaletteCommand }, + { "latfont", "png", HandleLatinFontToPngCommand }, + { "png", "latfont", HandlePngToLatinFontCommand }, + { "hwjpnfont", "png", HandleHalfwidthJapaneseFontToPngCommand }, + { "png", "hwjpnfont", HandlePngToHalfwidthJapaneseFontCommand }, + { "fwjpnfont", "png", HandleFullwidthJapaneseFontToPngCommand }, + { "png", "fwjpnfont", HandlePngToFullwidthJapaneseFontCommand }, + { NULL, "lz", HandleLZCompressCommand }, + { "lz", NULL, HandleLZDecompressCommand }, { NULL, "rl", HandleRLCompressCommand }, { "rl", NULL, HandleRLDecompressCommand }, - { NULL, NULL, NULL } - }; - - char *inputPath = argv[1]; - char *outputPath = argv[2]; - char *inputFileExtension = GetFileExtension(inputPath); - char *outputFileExtension = GetFileExtension(outputPath); - - if (inputFileExtension == NULL) - FATAL_ERROR("Input file \"%s\" has no extension.\n", inputPath); - - if (outputFileExtension == NULL) - FATAL_ERROR("Output file \"%s\" has no extension.\n", outputPath); - - for (int i = 0; handlers[i].function != NULL; i++) { - if ((handlers[i].inputFileExtension == NULL || strcmp(handlers[i].inputFileExtension, inputFileExtension) == 0) - && (handlers[i].outputFileExtension == NULL || strcmp(handlers[i].outputFileExtension, outputFileExtension) == 0)) { - handlers[i].function(inputPath, outputPath, argc, argv); - return 0; - } - } - - FATAL_ERROR("Don't know how to convert \"%s\" to \"%s\".\n", inputPath, outputPath); + { NULL, NULL, NULL } + }; + + char *inputPath = argv[1]; + char *outputPath = argv[2]; + char *inputFileExtension = GetFileExtension(inputPath); + char *outputFileExtension = GetFileExtension(outputPath); + + if (inputFileExtension == NULL) + FATAL_ERROR("Input file \"%s\" has no extension.\n", inputPath); + + if (outputFileExtension == NULL) + FATAL_ERROR("Output file \"%s\" has no extension.\n", outputPath); + + for (int i = 0; handlers[i].function != NULL; i++) + { + if ((handlers[i].inputFileExtension == NULL || strcmp(handlers[i].inputFileExtension, inputFileExtension) == 0) + && (handlers[i].outputFileExtension == NULL || strcmp(handlers[i].outputFileExtension, outputFileExtension) == 0)) + { + handlers[i].function(inputPath, outputPath, argc, argv); + return 0; + } + } + + FATAL_ERROR("Don't know how to convert \"%s\" to \"%s\".\n", inputPath, outputPath); } |