summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/gfx.py8
-rw-r--r--tools/pokemontools/gfx.py8
-rw-r--r--tools/scan_includes.py35
-rwxr-xr-xtools/unused_sources.sh15
4 files changed, 62 insertions, 4 deletions
diff --git a/tools/gfx.py b/tools/gfx.py
index e1f5b147..2505499d 100644
--- a/tools/gfx.py
+++ b/tools/gfx.py
@@ -168,6 +168,14 @@ def filepath_rules(filepath):
elif name == 'gfx_17079':
args['width'] = 16
+ elif 'gfx/player' in filedir:
+ if name == 'chris_back':
+ args['pic_dimensions'] = 6, 6
+
+ elif 'gfx/battle' in filedir:
+ if name == 'dude':
+ args['pic_dimensions'] = 6, 6
+
elif os.path.join(filedir, name) in pics:
args['pic'] = True
diff --git a/tools/pokemontools/gfx.py b/tools/pokemontools/gfx.py
index e6c9989d..f3e3ed53 100644
--- a/tools/pokemontools/gfx.py
+++ b/tools/pokemontools/gfx.py
@@ -433,7 +433,7 @@ def convert_2bpp_to_png(image, **kwargs):
# Width must be specified to interleave.
if interleave and width:
- image = interleave_tiles(image, width / 8)
+ image = interleave_tiles(image, width // 8)
# Pad the image by a given number of tiles if asked.
image += pad_color * 0x10 * tile_padding
@@ -766,11 +766,11 @@ def png_to_2bpp(filein, **kwargs):
tiles = get_tiles(image)
pic_length = w * h
- tile_width = width / 8
+ tile_width = width // 8
trailing = len(tiles) % pic_length
new_image = []
- for block in range(len(tiles) / pic_length):
- offset = (h * tile_width) * ((block * w) / tile_width) + ((block * w) % tile_width)
+ for block in range(len(tiles) // pic_length):
+ offset = (h * tile_width) * ((block * w) // tile_width) + ((block * w) % tile_width)
pic = []
for row in range(h):
index = offset + (row * tile_width)
diff --git a/tools/scan_includes.py b/tools/scan_includes.py
new file mode 100644
index 00000000..60929d3f
--- /dev/null
+++ b/tools/scan_includes.py
@@ -0,0 +1,35 @@
+#!/bin/python
+# coding: utf-8
+
+"""
+Recursively scan an asm file for dependencies.
+"""
+
+import sys
+import argparse
+
+includes = set()
+
+def scan_file(filename):
+ for line in open(filename):
+ if 'INC' not in line:
+ continue
+ line = line.split(';')[0]
+ if 'INCLUDE' in line:
+ include = line.split('"')[1]
+ includes.add(include)
+ scan_file(include)
+ elif 'INCBIN' in line:
+ include = line.split('"')[1]
+ includes.add(include)
+
+def main():
+ ap = argparse.ArgumentParser()
+ ap.add_argument('filenames', nargs='*')
+ args = ap.parse_args()
+ for filename in set(args.filenames):
+ scan_file(filename)
+ sys.stdout.write(' '.join(includes))
+
+if __name__ == '__main__':
+ main()
diff --git a/tools/unused_sources.sh b/tools/unused_sources.sh
new file mode 100755
index 00000000..233c032c
--- /dev/null
+++ b/tools/unused_sources.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+# Finds asm sources that aren't included in the build
+
+# top-level sources listed in Makefile
+toplevel='audio.asm data/text/common.asm data/pokemon/dex_entries.asm wram.asm
+main.asm home.asm gfx/sprites.asm gfx/pics_gold.asm gfx/pics_silver.asm'
+
+for asm in $toplevel; do
+ echo "$asm"
+ python tools/scan_includes.py "$asm"
+ echo
+done | tr ' ' '\n' | sort -u > includes.txt
+git ls-files | grep '\.asm$' | sort -u > sources.txt
+comm -23 sources.txt includes.txt
+rm sources.txt includes.txt