pngs in gfx/fx

- gave up on wind.png
- add --remove-yflip
This commit is contained in:
yenatch 2017-06-24 00:45:31 -04:00
parent f42e731d76
commit 41ae3610f6
80 changed files with 33 additions and 11 deletions

View File

@ -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_3a.2bpp: tools/gfx += --interleave --width=16
gfx/slots_3b.2bpp: tools/gfx += --interleave --width=24 --remove-duplicates --keep-whitespace --remove-xflip 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: ; %.bin: ;
%.blk: ; %.blk: ;

BIN
gfx/fx/aeroblast.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 187 B

BIN
gfx/fx/angels.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 363 B

BIN
gfx/fx/beam.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 562 B

BIN
gfx/fx/bubble.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 237 B

BIN
gfx/fx/charge.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 B

BIN
gfx/fx/cut.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 B

BIN
gfx/fx/egg.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 B

BIN
gfx/fx/explosion.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 B

BIN
gfx/fx/fire.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 B

BIN
gfx/fx/flower.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 149 B

BIN
gfx/fx/globe.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 292 B

BIN
gfx/fx/haze.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 B

BIN
gfx/fx/hit.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 306 B

BIN
gfx/fx/horn.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 B

BIN
gfx/fx/ice.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 B

BIN
gfx/fx/lightning.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 820 B

BIN
gfx/fx/misc.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
gfx/fx/noise.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 526 B

BIN
gfx/fx/objects.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 705 B

BIN
gfx/fx/plant.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 293 B

BIN
gfx/fx/poison.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 B

BIN
gfx/fx/pokeball.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 388 B

BIN
gfx/fx/powder.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 B

BIN
gfx/fx/psychic.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 B

BIN
gfx/fx/reflect.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 211 B

BIN
gfx/fx/rocks.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 669 B

BIN
gfx/fx/rope.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 256 B

BIN
gfx/fx/sand.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 384 B

BIN
gfx/fx/shapes.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 237 B

BIN
gfx/fx/shine.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 273 B

BIN
gfx/fx/skyattack.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 393 B

BIN
gfx/fx/smoke.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 B

BIN
gfx/fx/speed.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 B

BIN
gfx/fx/status.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 364 B

BIN
gfx/fx/water.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 277 B

BIN
gfx/fx/wave.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 B

BIN
gfx/fx/web.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 B

BIN
gfx/fx/whip.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 B

BIN
gfx/fx/wind.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 286 B

View File

@ -7,7 +7,7 @@
#include "common.h" #include "common.h"
static void usage(void) { 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) { static void error(char *message) {
@ -26,6 +26,7 @@ struct Options {
int remove_duplicates; int remove_duplicates;
int keep_whitespace; int keep_whitespace;
int remove_xflip; int remove_xflip;
int remove_yflip;
}; };
struct Options Options = { struct Options Options = {
@ -40,6 +41,7 @@ void get_args(int argc, char *argv[]) {
{"remove-duplicates", no_argument, &Options.remove_duplicates, 1}, {"remove-duplicates", no_argument, &Options.remove_duplicates, 1},
{"keep-whitespace", no_argument, &Options.keep_whitespace, 1}, {"keep-whitespace", no_argument, &Options.keep_whitespace, 1},
{"remove-xflip", no_argument, &Options.remove_xflip, 1}, {"remove-xflip", no_argument, &Options.remove_xflip, 1},
{"remove-yflip", no_argument, &Options.remove_yflip, 1},
{"width", required_argument, 0, 'w'}, {"width", required_argument, 0, 'w'},
{"depth", required_argument, 0, 'd'}, {"depth", required_argument, 0, 'd'},
{"help", no_argument, 0, 'h'}, {"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++) { for (int i = 0; i < tile_size; i++) {
int byte = i; int byte = i;
if (yflip) { if (yflip) {
byte = tile_size - 1 - i; byte = tile_size - 1 - (i ^ 1);
if (Options.interleave && i < half_size) { 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++) { for (int bit = 0; bit < 8; bit++) {
flip[byte] |= ((tile[i] >> bit) & 1) << (7 - 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; return false;
} }
bool xflip_exists(uint8_t *tile, uint8_t *tiles, int tile_size, int num_tiles) { void remove_flip(struct Graphic *graphic, bool xflip, bool yflip) {
return flip_exists(tile, tiles, tile_size, num_tiles, true, false);
}
void remove_xflip(struct Graphic *graphic) {
int tile_size = Options.depth * 8; int tile_size = Options.depth * 8;
if (Options.interleave) tile_size *= 2; if (Options.interleave) tile_size *= 2;
int num_tiles = 0; int num_tiles = 0;
for (int i = 0, j = 0; i < graphic->size && j < graphic->size; i += tile_size, j += tile_size) { 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)) { if (Options.keep_whitespace && is_whitespace(&graphic->data[j], tile_size)) {
break; break;
} }
@ -253,7 +251,13 @@ int main(int argc, char *argv[]) {
remove_duplicates(&graphic); remove_duplicates(&graphic);
} }
if (Options.remove_xflip) { 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) { if (Options.remove_whitespace) {
remove_whitespace(&graphic); remove_whitespace(&graphic);