summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Makefile6
-rw-r--r--engine/gfx/color.asm4
-rw-r--r--gfx/mobile/electro_ball.pngbin692 -> 695 bytes
-rw-r--r--gfx/mobile/electro_ball_nonmatching.pngbin1401 -> 0 bytes
-rw-r--r--gfx/sgb/sgb_border.binbin1072 -> 1792 bytes
-rw-r--r--gfx/sgb/sgb_border_nonmatching.binbin1792 -> 0 bytes
-rw-r--r--tools/gfx.c52
8 files changed, 50 insertions, 13 deletions
diff --git a/.gitignore b/.gitignore
index c23b42e22..c9036fa4b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -45,6 +45,7 @@ pokecrystal.txt
*.1bpp
*.lz
*.animated.tilemap
+*.sgb.tilemap
gfx/pokemon/*/bitmask.asm
gfx/pokemon/*/frames.asm
!gfx/pokemon/unown/bitmask.asm
diff --git a/Makefile b/Makefile
index 8903a8c3e..4746d399e 100644
--- a/Makefile
+++ b/Makefile
@@ -51,7 +51,7 @@ crystal-au: pokecrystal-au.gbc
clean:
rm -f $(roms) $(crystal_obj) $(crystal11_obj) $(crystal_au_obj) $(roms:.gbc=.map) $(roms:.gbc=.sym)
- find gfx \( -name "*.[12]bpp" -o -name "*.lz" -o -name "*.gbcpal" \) -delete
+ find gfx \( -name "*.[12]bpp" -o -name "*.lz" -o -name "*.gbcpal" -o -name "*.sgb.tilemap" \) -delete
find gfx/pokemon -mindepth 1 ! -path "gfx/pokemon/unown/*" \( -name "bitmask.asm" -o -name "frames.asm" -o -name "front.animated.tilemap" -o -name "front.dimensions" \) -delete
$(MAKE) clean -C tools/
@@ -226,12 +226,12 @@ gfx/battle/dude.2bpp: rgbgfx += -h
gfx/font/unused_bold_font.1bpp: tools/gfx += --trim-whitespace
gfx/sgb/sgb_border.2bpp: tools/gfx += --trim-whitespace
+gfx/sgb/sgb_border.sgb.tilemap: gfx/sgb/sgb_border.bin ; tr < $< -d '\000' > $@
gfx/mobile/ascii_font.2bpp: tools/gfx += --trim-whitespace
gfx/mobile/dialpad.2bpp: tools/gfx += --trim-whitespace
gfx/mobile/dialpad_cursor.2bpp: tools/gfx += --trim-whitespace
-gfx/mobile/electro_ball.2bpp: tools/gfx += --trim-whitespace
-gfx/mobile/electro_ball_nonmatching.2bpp: tools/gfx += --remove-duplicates --remove-xflip
+gfx/mobile/electro_ball.2bpp: tools/gfx += --remove-duplicates --remove-xflip --preserve=0x39
gfx/mobile/mobile_splash.2bpp: tools/gfx += --remove-duplicates --remove-xflip
gfx/mobile/card.2bpp: tools/gfx += --trim-whitespace
gfx/mobile/card_2.2bpp: tools/gfx += --trim-whitespace
diff --git a/engine/gfx/color.asm b/engine/gfx/color.asm
index aa29d413b..35ad66f7f 100644
--- a/engine/gfx/color.asm
+++ b/engine/gfx/color.asm
@@ -1191,8 +1191,8 @@ PredefPals:
INCLUDE "gfx/sgb/predef.pal"
SGBBorderMap:
-; interleaved tile ids and palette ids
-INCBIN "gfx/sgb/sgb_border.bin"
+; interleaved tile ids and palette ids, without the center 20x18 screen area
+INCBIN "gfx/sgb/sgb_border.sgb.tilemap"
SGBBorderPalettes:
; assumed to come after SGBBorderMap
diff --git a/gfx/mobile/electro_ball.png b/gfx/mobile/electro_ball.png
index 3e1c0bb46..b6a9f11c3 100644
--- a/gfx/mobile/electro_ball.png
+++ b/gfx/mobile/electro_ball.png
Binary files differ
diff --git a/gfx/mobile/electro_ball_nonmatching.png b/gfx/mobile/electro_ball_nonmatching.png
deleted file mode 100644
index 52441bd83..000000000
--- a/gfx/mobile/electro_ball_nonmatching.png
+++ /dev/null
Binary files differ
diff --git a/gfx/sgb/sgb_border.bin b/gfx/sgb/sgb_border.bin
index 362eae929..5ad4fb002 100644
--- a/gfx/sgb/sgb_border.bin
+++ b/gfx/sgb/sgb_border.bin
Binary files differ
diff --git a/gfx/sgb/sgb_border_nonmatching.bin b/gfx/sgb/sgb_border_nonmatching.bin
deleted file mode 100644
index 5ad4fb002..000000000
--- a/gfx/sgb/sgb_border_nonmatching.bin
+++ /dev/null
Binary files differ
diff --git a/tools/gfx.c b/tools/gfx.c
index 7ef0d2d91..6dad2f1a8 100644
--- a/tools/gfx.c
+++ b/tools/gfx.c
@@ -8,7 +8,7 @@
#include "common.h"
static void usage(void) {
- fprintf(stderr, "Usage: gfx [--trim-whitespace] [--remove-whitespace] [--interleave] [--remove-duplicates [--keep-whitespace]] [--remove-xflip] [--remove-yflip] [--png filename] [-d depth] [-h] [-o outfile] infile\n");
+ fprintf(stderr, "Usage: gfx [--trim-whitespace] [--remove-whitespace] [--interleave] [--remove-duplicates [--keep-whitespace]] [--remove-xflip] [--remove-yflip] [--preserve indexes] [--png filename] [-d depth] [-h] [-o outfile] infile\n");
}
static void error(char *message) {
@@ -27,6 +27,8 @@ struct Options {
int keep_whitespace;
int remove_xflip;
int remove_yflip;
+ int *preserved;
+ int num_preserved;
char *png_file;
};
@@ -43,11 +45,13 @@ void get_args(int argc, char *argv[]) {
{"keep-whitespace", no_argument, &Options.keep_whitespace, 1},
{"remove-xflip", no_argument, &Options.remove_xflip, 1},
{"remove-yflip", no_argument, &Options.remove_yflip, 1},
+ {"preserve", required_argument, 0, 'r'},
{"png", required_argument, 0, 'p'},
{"depth", required_argument, 0, 'd'},
{"help", no_argument, 0, 'h'},
{0}
};
+ char *token;
for (int opt = 0; opt != -1;) {
switch (opt = getopt_long(argc, argv, "ho:d:p:", long_options)) {
case 'h':
@@ -59,6 +63,15 @@ void get_args(int argc, char *argv[]) {
case 'd':
Options.depth = strtoul(optarg, NULL, 0);
break;
+ case 'r':
+ token = strtok(optarg, ",");
+ while (token) {
+ Options.num_preserved++;
+ Options.preserved = realloc(Options.preserved, Options.num_preserved * sizeof(int));
+ Options.preserved[Options.num_preserved-1] = strtoul(optarg, NULL, 0);
+ token = strtok(NULL, ",");
+ }
+ break;
case 'p':
Options.png_file = optarg;
break;
@@ -73,6 +86,23 @@ void get_args(int argc, char *argv[]) {
}
}
+bool is_preserved(int index) {
+ for (int i = 0; i < Options.num_preserved; i++) {
+ if (Options.preserved[i] == index) {
+ return true;
+ }
+ }
+ return false;
+}
+
+void shift_preserved(int removed_index) {
+ for (int i = 0; i < Options.num_preserved; i++) {
+ if (Options.preserved[i] >= removed_index) {
+ Options.preserved[i]--;
+ }
+ }
+}
+
struct Graphic {
int size;
uint8_t *data;
@@ -91,7 +121,7 @@ bool is_whitespace(uint8_t *tile, int tile_size) {
void trim_whitespace(struct Graphic *graphic) {
int tile_size = Options.depth * 8;
for (int i = graphic->size - tile_size; i > 0; i -= tile_size) {
- if (is_whitespace(&graphic->data[i], tile_size)) {
+ if (is_whitespace(&graphic->data[i], tile_size) && !is_preserved(i / tile_size)) {
graphic->size = i;
} else {
break;
@@ -107,8 +137,10 @@ void remove_whitespace(struct Graphic *graphic) {
graphic->size &= ~(tile_size - 1);
int i = 0;
- for (int j = 0; i < graphic->size && j < graphic->size; i += tile_size, j += tile_size) {
- while (j < graphic->size && is_whitespace(&graphic->data[j], tile_size)) {
+ for (int j = 0, d = 0; i < graphic->size && j < graphic->size; i += tile_size, j += tile_size) {
+ while (j < graphic->size && is_whitespace(&graphic->data[j], tile_size) && !is_preserved(j / tile_size - d)) {
+ shift_preserved(j / tile_size);
+ d++;
j += tile_size;
}
if (j >= graphic->size) {
@@ -144,11 +176,13 @@ void remove_duplicates(struct Graphic *graphic) {
// Make sure we have a whole number of tiles, round down if required
graphic->size &= ~(tile_size - 1);
- for (int i = 0, j = 0; i < graphic->size && j < graphic->size; i += tile_size, j += tile_size) {
+ for (int i = 0, j = 0, d = 0; i < graphic->size && j < graphic->size; i += tile_size, j += tile_size) {
while (j < graphic->size && tile_exists(&graphic->data[j], graphic->data, tile_size, num_tiles)) {
- if (Options.keep_whitespace && is_whitespace(&graphic->data[j], tile_size)) {
+ if ((Options.keep_whitespace && is_whitespace(&graphic->data[j], tile_size)) || is_preserved(j / tile_size - d)) {
break;
}
+ shift_preserved(j / tile_size);
+ d++;
j += tile_size;
}
if (j >= graphic->size) {
@@ -196,11 +230,13 @@ void remove_flip(struct Graphic *graphic, bool xflip, bool yflip) {
// Make sure we have a whole number of tiles, round down if required
graphic->size &= ~(tile_size - 1);
- for (int i = 0, j = 0; i < graphic->size && j < graphic->size; i += tile_size, j += tile_size) {
+ for (int i = 0, j = 0, d = 0; i < graphic->size && j < graphic->size; i += tile_size, j += tile_size) {
while (j < graphic->size && 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)) || is_preserved(j / tile_size - d)) {
break;
}
+ shift_preserved(j / tile_size);
+ d++;
j += tile_size;
}
if (j >= graphic->size) {