diff --git a/Makefile b/Makefile index ed74afe5c..b60672e35 100644 --- a/Makefile +++ b/Makefile @@ -135,6 +135,24 @@ gfx/slots_3.2bpp: tools/gfx += --interleave --width=24 --remove-duplicates --kee gfx/slots_3a.2bpp: tools/gfx += --interleave --width=16 gfx/slots_3b.2bpp: tools/gfx += --interleave --width=24 --remove-duplicates --keep-whitespace --remove-xflip +gfx/fx/angels.2bpp: tools/gfx += --trim-whitespace +gfx/fx/beam.2bpp: tools/gfx += --remove-xflip --remove-yflip --remove-whitespace +gfx/fx/bubble.2bpp: tools/gfx += --trim-whitespace +gfx/fx/charge.2bpp: tools/gfx += --trim-whitespace +gfx/fx/egg.2bpp: tools/gfx += --remove-whitespace +gfx/fx/explosion.2bpp: tools/gfx += --remove-whitespace +gfx/fx/hit.2bpp: tools/gfx += --remove-whitespace +gfx/fx/horn.2bpp: tools/gfx += --remove-whitespace +gfx/fx/lightning.2bpp: tools/gfx += --remove-whitespace +gfx/fx/misc.2bpp: tools/gfx += --remove-duplicates --remove-xflip +gfx/fx/noise.2bpp: tools/gfx += --remove-whitespace +gfx/fx/objects.2bpp: tools/gfx += --remove-whitespace --remove-xflip +gfx/fx/pokeball.2bpp: tools/gfx += --remove-xflip --keep-whitespace +gfx/fx/reflect.2bpp: tools/gfx += --remove-whitespace +gfx/fx/rocks.2bpp: tools/gfx += --remove-whitespace +gfx/fx/skyattack.2bpp: tools/gfx += --remove-whitespace +gfx/fx/status.2bpp: tools/gfx += --remove-whitespace + %.bin: ; %.blk: ; diff --git a/gfx/fx/aeroblast.2bpp.lz b/gfx/fx/aeroblast.2bpp.lz.2f07c4ea similarity index 100% rename from gfx/fx/aeroblast.2bpp.lz rename to gfx/fx/aeroblast.2bpp.lz.2f07c4ea diff --git a/gfx/fx/aeroblast.png b/gfx/fx/aeroblast.png new file mode 100644 index 000000000..1fdc07c2f Binary files /dev/null and b/gfx/fx/aeroblast.png differ diff --git a/gfx/fx/angels.2bpp.lz b/gfx/fx/angels.2bpp.lz.b026d81e similarity index 100% rename from gfx/fx/angels.2bpp.lz rename to gfx/fx/angels.2bpp.lz.b026d81e diff --git a/gfx/fx/angels.png b/gfx/fx/angels.png new file mode 100644 index 000000000..ef38c61d2 Binary files /dev/null and b/gfx/fx/angels.png differ diff --git a/gfx/fx/beam.2bpp.lz b/gfx/fx/beam.2bpp.lz.80b6d613 similarity index 100% rename from gfx/fx/beam.2bpp.lz rename to gfx/fx/beam.2bpp.lz.80b6d613 diff --git a/gfx/fx/beam.png b/gfx/fx/beam.png new file mode 100755 index 000000000..32a3b1967 Binary files /dev/null and b/gfx/fx/beam.png differ diff --git a/gfx/fx/bubble.2bpp.lz b/gfx/fx/bubble.2bpp.lz.03b8ac99 similarity index 100% rename from gfx/fx/bubble.2bpp.lz rename to gfx/fx/bubble.2bpp.lz.03b8ac99 diff --git a/gfx/fx/bubble.png b/gfx/fx/bubble.png new file mode 100644 index 000000000..b6febb0a8 Binary files /dev/null and b/gfx/fx/bubble.png differ diff --git a/gfx/fx/charge.2bpp.lz b/gfx/fx/charge.2bpp.lz.95d3ea98 similarity index 100% rename from gfx/fx/charge.2bpp.lz rename to gfx/fx/charge.2bpp.lz.95d3ea98 diff --git a/gfx/fx/charge.png b/gfx/fx/charge.png new file mode 100644 index 000000000..90cb72f9f Binary files /dev/null and b/gfx/fx/charge.png differ diff --git a/gfx/fx/cut.2bpp.lz b/gfx/fx/cut.2bpp.lz.03d343ed similarity index 100% rename from gfx/fx/cut.2bpp.lz rename to gfx/fx/cut.2bpp.lz.03d343ed diff --git a/gfx/fx/cut.png b/gfx/fx/cut.png new file mode 100644 index 000000000..e227ad413 Binary files /dev/null and b/gfx/fx/cut.png differ diff --git a/gfx/fx/egg.2bpp.lz b/gfx/fx/egg.2bpp.lz.41dd1a53 similarity index 100% rename from gfx/fx/egg.2bpp.lz rename to gfx/fx/egg.2bpp.lz.41dd1a53 diff --git a/gfx/fx/egg.png b/gfx/fx/egg.png new file mode 100644 index 000000000..38aab505d Binary files /dev/null and b/gfx/fx/egg.png differ diff --git a/gfx/fx/explosion.2bpp.lz b/gfx/fx/explosion.2bpp.lz.55fc334f similarity index 100% rename from gfx/fx/explosion.2bpp.lz rename to gfx/fx/explosion.2bpp.lz.55fc334f diff --git a/gfx/fx/explosion.png b/gfx/fx/explosion.png new file mode 100644 index 000000000..0af9f1a0d Binary files /dev/null and b/gfx/fx/explosion.png differ diff --git a/gfx/fx/fire.2bpp.lz b/gfx/fx/fire.2bpp.lz.d7701cda similarity index 100% rename from gfx/fx/fire.2bpp.lz rename to gfx/fx/fire.2bpp.lz.d7701cda diff --git a/gfx/fx/fire.png b/gfx/fx/fire.png new file mode 100644 index 000000000..19f01141b Binary files /dev/null and b/gfx/fx/fire.png differ diff --git a/gfx/fx/flower.2bpp.lz b/gfx/fx/flower.2bpp.lz.1bc2e9d2 similarity index 100% rename from gfx/fx/flower.2bpp.lz rename to gfx/fx/flower.2bpp.lz.1bc2e9d2 diff --git a/gfx/fx/flower.png b/gfx/fx/flower.png new file mode 100644 index 000000000..61b4f58ce Binary files /dev/null and b/gfx/fx/flower.png differ diff --git a/gfx/fx/globe.2bpp.lz b/gfx/fx/globe.2bpp.lz.710dbb8e similarity index 100% rename from gfx/fx/globe.2bpp.lz rename to gfx/fx/globe.2bpp.lz.710dbb8e diff --git a/gfx/fx/globe.png b/gfx/fx/globe.png new file mode 100644 index 000000000..8d3a35683 Binary files /dev/null and b/gfx/fx/globe.png differ diff --git a/gfx/fx/haze.2bpp.lz b/gfx/fx/haze.2bpp.lz.91424607 similarity index 100% rename from gfx/fx/haze.2bpp.lz rename to gfx/fx/haze.2bpp.lz.91424607 diff --git a/gfx/fx/haze.png b/gfx/fx/haze.png new file mode 100644 index 000000000..8a870ba98 Binary files /dev/null and b/gfx/fx/haze.png differ diff --git a/gfx/fx/hit.2bpp.lz b/gfx/fx/hit.2bpp.lz.2b3c83f2 similarity index 100% rename from gfx/fx/hit.2bpp.lz rename to gfx/fx/hit.2bpp.lz.2b3c83f2 diff --git a/gfx/fx/hit.png b/gfx/fx/hit.png new file mode 100644 index 000000000..228066331 Binary files /dev/null and b/gfx/fx/hit.png differ diff --git a/gfx/fx/horn.2bpp.lz b/gfx/fx/horn.2bpp.lz.48908aae similarity index 100% rename from gfx/fx/horn.2bpp.lz rename to gfx/fx/horn.2bpp.lz.48908aae diff --git a/gfx/fx/horn.png b/gfx/fx/horn.png new file mode 100644 index 000000000..56e8ca241 Binary files /dev/null and b/gfx/fx/horn.png differ diff --git a/gfx/fx/ice.2bpp.lz b/gfx/fx/ice.2bpp.lz.664d900f similarity index 100% rename from gfx/fx/ice.2bpp.lz rename to gfx/fx/ice.2bpp.lz.664d900f diff --git a/gfx/fx/ice.png b/gfx/fx/ice.png new file mode 100644 index 000000000..62a67641e Binary files /dev/null and b/gfx/fx/ice.png differ diff --git a/gfx/fx/lightning.2bpp.lz b/gfx/fx/lightning.2bpp.lz.a88fc131 similarity index 100% rename from gfx/fx/lightning.2bpp.lz rename to gfx/fx/lightning.2bpp.lz.a88fc131 diff --git a/gfx/fx/lightning.png b/gfx/fx/lightning.png new file mode 100755 index 000000000..6606fad12 Binary files /dev/null and b/gfx/fx/lightning.png differ diff --git a/gfx/fx/misc.2bpp.lz b/gfx/fx/misc.2bpp.lz.4b20c3d7 similarity index 100% rename from gfx/fx/misc.2bpp.lz rename to gfx/fx/misc.2bpp.lz.4b20c3d7 diff --git a/gfx/fx/misc.png b/gfx/fx/misc.png new file mode 100755 index 000000000..d7e67508e Binary files /dev/null and b/gfx/fx/misc.png differ diff --git a/gfx/fx/noise.2bpp.lz b/gfx/fx/noise.2bpp.lz.acb4a76e similarity index 100% rename from gfx/fx/noise.2bpp.lz rename to gfx/fx/noise.2bpp.lz.acb4a76e diff --git a/gfx/fx/noise.png b/gfx/fx/noise.png new file mode 100755 index 000000000..17540a5e8 Binary files /dev/null and b/gfx/fx/noise.png differ diff --git a/gfx/fx/objects.2bpp.lz b/gfx/fx/objects.2bpp.lz.83f812de similarity index 100% rename from gfx/fx/objects.2bpp.lz rename to gfx/fx/objects.2bpp.lz.83f812de diff --git a/gfx/fx/objects.png b/gfx/fx/objects.png new file mode 100755 index 000000000..91ea435b8 Binary files /dev/null and b/gfx/fx/objects.png differ diff --git a/gfx/fx/plant.2bpp.lz b/gfx/fx/plant.2bpp.lz.4a00c417 similarity index 100% rename from gfx/fx/plant.2bpp.lz rename to gfx/fx/plant.2bpp.lz.4a00c417 diff --git a/gfx/fx/plant.png b/gfx/fx/plant.png new file mode 100644 index 000000000..ec1125054 Binary files /dev/null and b/gfx/fx/plant.png differ diff --git a/gfx/fx/poison.2bpp.lz b/gfx/fx/poison.2bpp.lz.fc7dc9c1 similarity index 100% rename from gfx/fx/poison.2bpp.lz rename to gfx/fx/poison.2bpp.lz.fc7dc9c1 diff --git a/gfx/fx/poison.png b/gfx/fx/poison.png new file mode 100755 index 000000000..ebbbc52be Binary files /dev/null and b/gfx/fx/poison.png differ diff --git a/gfx/fx/pokeball.2bpp.lz b/gfx/fx/pokeball.2bpp.lz.c58f7e01 similarity index 100% rename from gfx/fx/pokeball.2bpp.lz rename to gfx/fx/pokeball.2bpp.lz.c58f7e01 diff --git a/gfx/fx/pokeball.png b/gfx/fx/pokeball.png new file mode 100755 index 000000000..47edf2190 Binary files /dev/null and b/gfx/fx/pokeball.png differ diff --git a/gfx/fx/powder.2bpp.lz b/gfx/fx/powder.2bpp.lz.bfd566bb similarity index 100% rename from gfx/fx/powder.2bpp.lz rename to gfx/fx/powder.2bpp.lz.bfd566bb diff --git a/gfx/fx/powder.png b/gfx/fx/powder.png new file mode 100644 index 000000000..b2cb4d459 Binary files /dev/null and b/gfx/fx/powder.png differ diff --git a/gfx/fx/psychic.2bpp.lz b/gfx/fx/psychic.2bpp.lz.d80f285c similarity index 100% rename from gfx/fx/psychic.2bpp.lz rename to gfx/fx/psychic.2bpp.lz.d80f285c diff --git a/gfx/fx/psychic.png b/gfx/fx/psychic.png new file mode 100644 index 000000000..a6d22db2f Binary files /dev/null and b/gfx/fx/psychic.png differ diff --git a/gfx/fx/reflect.2bpp.lz b/gfx/fx/reflect.2bpp.lz.9a9c822d similarity index 100% rename from gfx/fx/reflect.2bpp.lz rename to gfx/fx/reflect.2bpp.lz.9a9c822d diff --git a/gfx/fx/reflect.png b/gfx/fx/reflect.png new file mode 100644 index 000000000..48fbd7d0d Binary files /dev/null and b/gfx/fx/reflect.png differ diff --git a/gfx/fx/rocks.2bpp.lz b/gfx/fx/rocks.2bpp.lz.73d0153e similarity index 100% rename from gfx/fx/rocks.2bpp.lz rename to gfx/fx/rocks.2bpp.lz.73d0153e diff --git a/gfx/fx/rocks.png b/gfx/fx/rocks.png new file mode 100755 index 000000000..d7fe76b2f Binary files /dev/null and b/gfx/fx/rocks.png differ diff --git a/gfx/fx/rope.2bpp.lz b/gfx/fx/rope.2bpp.lz.209d63dd similarity index 100% rename from gfx/fx/rope.2bpp.lz rename to gfx/fx/rope.2bpp.lz.209d63dd diff --git a/gfx/fx/rope.png b/gfx/fx/rope.png new file mode 100644 index 000000000..a12553c7a Binary files /dev/null and b/gfx/fx/rope.png differ diff --git a/gfx/fx/sand.2bpp.lz b/gfx/fx/sand.2bpp.lz.c87c0eaa similarity index 100% rename from gfx/fx/sand.2bpp.lz rename to gfx/fx/sand.2bpp.lz.c87c0eaa diff --git a/gfx/fx/sand.png b/gfx/fx/sand.png new file mode 100755 index 000000000..a54db235d Binary files /dev/null and b/gfx/fx/sand.png differ diff --git a/gfx/fx/shapes.2bpp.lz b/gfx/fx/shapes.2bpp.lz.262d77f0 similarity index 100% rename from gfx/fx/shapes.2bpp.lz rename to gfx/fx/shapes.2bpp.lz.262d77f0 diff --git a/gfx/fx/shapes.png b/gfx/fx/shapes.png new file mode 100644 index 000000000..b99fc601a Binary files /dev/null and b/gfx/fx/shapes.png differ diff --git a/gfx/fx/shine.2bpp.lz b/gfx/fx/shine.2bpp.lz.5fb79056 similarity index 100% rename from gfx/fx/shine.2bpp.lz rename to gfx/fx/shine.2bpp.lz.5fb79056 diff --git a/gfx/fx/shine.png b/gfx/fx/shine.png new file mode 100644 index 000000000..1b7e9834b Binary files /dev/null and b/gfx/fx/shine.png differ diff --git a/gfx/fx/skyattack.2bpp.lz b/gfx/fx/skyattack.2bpp.lz.31738ab8 similarity index 100% rename from gfx/fx/skyattack.2bpp.lz rename to gfx/fx/skyattack.2bpp.lz.31738ab8 diff --git a/gfx/fx/skyattack.png b/gfx/fx/skyattack.png new file mode 100644 index 000000000..e731c691c Binary files /dev/null and b/gfx/fx/skyattack.png differ diff --git a/gfx/fx/smoke.2bpp.lz b/gfx/fx/smoke.2bpp.lz.aa05905e similarity index 100% rename from gfx/fx/smoke.2bpp.lz rename to gfx/fx/smoke.2bpp.lz.aa05905e diff --git a/gfx/fx/smoke.png b/gfx/fx/smoke.png new file mode 100644 index 000000000..1b09874ba Binary files /dev/null and b/gfx/fx/smoke.png differ diff --git a/gfx/fx/speed.2bpp.lz b/gfx/fx/speed.2bpp.lz.1732b364 similarity index 100% rename from gfx/fx/speed.2bpp.lz rename to gfx/fx/speed.2bpp.lz.1732b364 diff --git a/gfx/fx/speed.png b/gfx/fx/speed.png new file mode 100644 index 000000000..e219b38c9 Binary files /dev/null and b/gfx/fx/speed.png differ diff --git a/gfx/fx/status.2bpp.lz b/gfx/fx/status.2bpp.lz.0c0aa13e similarity index 100% rename from gfx/fx/status.2bpp.lz rename to gfx/fx/status.2bpp.lz.0c0aa13e diff --git a/gfx/fx/status.png b/gfx/fx/status.png new file mode 100644 index 000000000..cb8527963 Binary files /dev/null and b/gfx/fx/status.png differ diff --git a/gfx/fx/water.2bpp.lz b/gfx/fx/water.2bpp.lz.7b52ed12 similarity index 100% rename from gfx/fx/water.2bpp.lz rename to gfx/fx/water.2bpp.lz.7b52ed12 diff --git a/gfx/fx/water.png b/gfx/fx/water.png new file mode 100644 index 000000000..4e3c3b719 Binary files /dev/null and b/gfx/fx/water.png differ diff --git a/gfx/fx/wave.2bpp.lz b/gfx/fx/wave.2bpp.lz.bee99402 similarity index 100% rename from gfx/fx/wave.2bpp.lz rename to gfx/fx/wave.2bpp.lz.bee99402 diff --git a/gfx/fx/wave.png b/gfx/fx/wave.png new file mode 100644 index 000000000..55d4faa5f Binary files /dev/null and b/gfx/fx/wave.png differ diff --git a/gfx/fx/web.2bpp.lz b/gfx/fx/web.2bpp.lz.80e3d480 similarity index 100% rename from gfx/fx/web.2bpp.lz rename to gfx/fx/web.2bpp.lz.80e3d480 diff --git a/gfx/fx/web.png b/gfx/fx/web.png new file mode 100644 index 000000000..2aeffef0e Binary files /dev/null and b/gfx/fx/web.png differ diff --git a/gfx/fx/whip.2bpp.lz b/gfx/fx/whip.2bpp.lz.d80d8d6e similarity index 100% rename from gfx/fx/whip.2bpp.lz rename to gfx/fx/whip.2bpp.lz.d80d8d6e diff --git a/gfx/fx/whip.png b/gfx/fx/whip.png new file mode 100644 index 000000000..92d7ded6f Binary files /dev/null and b/gfx/fx/whip.png differ diff --git a/gfx/fx/wind.2bpp.lz b/gfx/fx/wind.2bpp.lz.5a785180 similarity index 100% rename from gfx/fx/wind.2bpp.lz rename to gfx/fx/wind.2bpp.lz.5a785180 diff --git a/gfx/fx/wind.png b/gfx/fx/wind.png new file mode 100644 index 000000000..b02031392 Binary files /dev/null and b/gfx/fx/wind.png differ diff --git a/tools/gfx.c b/tools/gfx.c index 8283d9e73..25de45dbe 100644 --- a/tools/gfx.c +++ b/tools/gfx.c @@ -7,7 +7,7 @@ #include "common.h" static void usage(void) { - fprintf(stderr, "Usage: gfx [--trim-whitespace] [--remove-whitespace] [--interleave] [--remove-duplicates [--keep-whitespace]] [--remove-xflip] [-w width] [-d depth] [-h] [-o outfile] infile\n"); + fprintf(stderr, "Usage: gfx [--trim-whitespace] [--remove-whitespace] [--interleave] [--remove-duplicates [--keep-whitespace]] [--remove-xflip] [--remove-yflip] [-w width] [-d depth] [-h] [-o outfile] infile\n"); } static void error(char *message) { @@ -26,6 +26,7 @@ struct Options { int remove_duplicates; int keep_whitespace; int remove_xflip; + int remove_yflip; }; struct Options Options = { @@ -40,6 +41,7 @@ void get_args(int argc, char *argv[]) { {"remove-duplicates", no_argument, &Options.remove_duplicates, 1}, {"keep-whitespace", no_argument, &Options.keep_whitespace, 1}, {"remove-xflip", no_argument, &Options.remove_xflip, 1}, + {"remove-yflip", no_argument, &Options.remove_yflip, 1}, {"width", required_argument, 0, 'w'}, {"depth", required_argument, 0, 'd'}, {"help", no_argument, 0, 'h'}, @@ -157,12 +159,12 @@ bool flip_exists(uint8_t *tile, uint8_t *tiles, int tile_size, int num_tiles, bo for (int i = 0; i < tile_size; i++) { int byte = i; if (yflip) { - byte = tile_size - 1 - i; + byte = tile_size - 1 - (i ^ 1); if (Options.interleave && i < half_size) { - byte = half_size - 1 - i; + byte = half_size - 1 - (i ^ 1); } } - if (flip) { + if (xflip) { for (int bit = 0; bit < 8; bit++) { flip[byte] |= ((tile[i] >> bit) & 1) << (7 - bit); } @@ -176,16 +178,12 @@ bool flip_exists(uint8_t *tile, uint8_t *tiles, int tile_size, int num_tiles, bo return false; } -bool xflip_exists(uint8_t *tile, uint8_t *tiles, int tile_size, int num_tiles) { - return flip_exists(tile, tiles, tile_size, num_tiles, true, false); -} - -void remove_xflip(struct Graphic *graphic) { +void remove_flip(struct Graphic *graphic, bool xflip, bool yflip) { int tile_size = Options.depth * 8; if (Options.interleave) tile_size *= 2; int num_tiles = 0; for (int i = 0, j = 0; i < graphic->size && j < graphic->size; i += tile_size, j += tile_size) { - while (xflip_exists(&graphic->data[j], graphic->data, tile_size, num_tiles)) { + while (flip_exists(&graphic->data[j], graphic->data, tile_size, num_tiles, xflip, yflip)) { if (Options.keep_whitespace && is_whitespace(&graphic->data[j], tile_size)) { break; } @@ -253,7 +251,13 @@ int main(int argc, char *argv[]) { remove_duplicates(&graphic); } if (Options.remove_xflip) { - remove_xflip(&graphic); + remove_flip(&graphic, true, false); + } + if (Options.remove_yflip) { + remove_flip(&graphic, false, true); + } + if (Options.remove_xflip && Options.remove_yflip) { + remove_flip(&graphic, true, true); } if (Options.remove_whitespace) { remove_whitespace(&graphic);