summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile22
-rw-r--r--data/predef_pointers.inc2
-rw-r--r--shim.sym1
-rw-r--r--tools/scan_includes.py36
4 files changed, 31 insertions, 30 deletions
diff --git a/Makefile b/Makefile
index 8888cb5..dd6c27a 100644
--- a/Makefile
+++ b/Makefile
@@ -11,7 +11,7 @@ RGBFIX := rgbfix
sort_sym := tools/sort_symfile.sh
#sort_sym := $(PYTHON3) tools/sort_sym.py
-RGBASMFLAGS := -h -E -i build/ -DGOLD -DDEBUG=1
+RGBASMFLAGS := -h -E -i $(BUILD)/ -DGOLD -DDEBUG=1
tools/gfx :=
ROM := pokegold-spaceworld.gb
@@ -21,16 +21,9 @@ CORRECTEDROM := $(ROM:%.gb=%-correctheader.gb)
rwildcard = $(foreach d, $(wildcard $1*), $(filter $(subst *, %, $2), $d) $(call rwildcard, $d/, $2))
DIRS := home engine data audio
-ASMFILES := $(call rwildcard, $(DIRS), *.asm)
-OBJS := $(addprefix $(BUILD)/, gfx.o vram.o sram.o wram.o hram.o shim.o)
-OBJS += $(patsubst %.asm, $(BUILD)/%.o, $(ASMFILES))
-
-GFX := $(patsubst %.png, $(BUILD)/%.2bpp, \
- $(patsubst %.1bpp.png, $(BUILD)/%.1bpp, \
- $(patsubst gfx/pokemon/%/front.png, $(BUILD)/gfx/pokemon/%/front.pic, \
- $(patsubst gfx/pokemon/%/back.png, $(BUILD)/gfx/pokemon/%/back.pic, \
- $(patsubst gfx/trainer/%.png, $(BUILD)/gfx/trainer/%.pic, \
- $(call rwildcard, gfx, *.png))))))
+ASMFILES := $(call rwildcard, $(DIRS), *.asm) gfx.asm vram.asm sram.asm wram.asm hram.asm
+OBJS := $(patsubst %.asm, $(BUILD)/%.o, $(ASMFILES))
+OBJS += $(BUILD)/shim.o
.SECONDEXPANSION:
@@ -48,13 +41,13 @@ tools tools/pkmncompress tools/gfx:
# Remove files generated by the build process.
.PHONY: clean
clean:
- rm -rf $(ROM) $(CORRECTEDROM) $(BUILD) $(ROMS:.gb=.sym) $(ROMS:.gb=.map)
+ rm -rf $(ROM) $(CORRECTEDROM) $(BUILD) $(ROMS:.gb=.sym) $(ROMS:.gb=.map) *.d
"$(MAKE)" -C tools clean
# Remove files except for graphics.
.PHONY: mostlyclean
mostlyclean:
- rm -rf $(ROM) $(CORRECTEDROM) $(OBJS) $(ROMS:.gb=.sym) $(ROMS:.gb=.map)
+ rm -rf $(ROM) $(CORRECTEDROM) $(OBJS) $(ROMS:.gb=.sym) $(ROMS:.gb=.map) *.d
# Utilities
.PHONY: coverage
@@ -86,7 +79,6 @@ $(BASEROM):
$(BUILD)/shim.asm: tools/make_shim.py $(SHIM) | $$(dir $$@)
$(PYTHON3) tools/make_shim.py -w $(filter-out $<, $^) > $@
-$(BUILD)/gfx.o: | $(GFX)
$(BUILD)/%.o: $(BUILD)/%.asm | $$(dir $$@)
$(RGBASM) $(RGBASMFLAGS) $(OUTPUT_OPTION) $<
$(BUILD)/%.o: %.asm | $$(dir $$@)
@@ -124,7 +116,7 @@ $(BUILD)/%.tilemap: %.png | $$(dir $$@)
%/:
mkdir -p $@
-DEPENDENCY_SCAN_EXIT_STATUS := $(shell $(PYTHON3) tools/scan_includes.py $(ASMFILES) > dependencies.d; echo $$?)
+DEPENDENCY_SCAN_EXIT_STATUS := $(shell $(PYTHON3) tools/scan_includes.py $(BUILD:%=-b %) $(ASMFILES) > dependencies.d; echo $$?)
ifneq ($(DEPENDENCY_SCAN_EXIT_STATUS), 0)
$(error Dependency scan failed)
endif
diff --git a/data/predef_pointers.inc b/data/predef_pointers.inc
index 0b39ae2..2463d3f 100644
--- a/data/predef_pointers.inc
+++ b/data/predef_pointers.inc
@@ -23,7 +23,7 @@ PredefPointers:: ; 1:62d3
add_predef Functioncde3_3
add_predef Functioncdf9
add_predef Functionce10_2
- add_predef Functioncd33
+ add_predef SmallFarFlagAction
GiveItemPredef::
dbw 3, GiveItem
add_predef Functionce3c
diff --git a/shim.sym b/shim.sym
index 5b6e8f7..50ef966 100644
--- a/shim.sym
+++ b/shim.sym
@@ -61,7 +61,6 @@
03:4000 Functionc000
03:47D5 SpawnPoints
03:488D Tilesets
-03:4D33 Functioncd33
03:4D6F Functioncd6f
03:4DE3 Functioncde3
03:4DE3 Functioncde3_2
diff --git a/tools/scan_includes.py b/tools/scan_includes.py
index e659dca..34e1f09 100644
--- a/tools/scan_includes.py
+++ b/tools/scan_includes.py
@@ -5,11 +5,12 @@
and output them using Make dependency syntax.
"""
-# Script from the Telefang disassembly / fan translation project.
+# Script adapted from the Telefang disassembly / fan translation project.
from __future__ import print_function
from __future__ import unicode_literals
+import argparse
import os
import re
import sys
@@ -18,19 +19,19 @@ if sys.version_info[0] < 3:
INCLUDE_RE = re.compile(r"^(?:[a-zA-Z0-9_.]+:?:?)?\s*(INC(?:LUDE|BIN))", re.IGNORECASE)
-def dependencies_in(asm_file_paths):
+def dependencies_in(asm_file_paths, build_dirs=[]):
asm_file_paths = list(asm_file_paths)
dependencies = {}
for path in asm_file_paths:
if path not in dependencies:
- asm_dependencies, bin_dependencies = shallow_dependencies_of(path)
+ asm_dependencies, bin_dependencies = shallow_dependencies_of(path, build_dirs)
dependencies[path] = asm_dependencies | bin_dependencies
asm_file_paths += asm_dependencies
return dependencies
-def shallow_dependencies_of(asm_file_path):
+def shallow_dependencies_of(asm_file_path, build_dirs=[]):
asm_dependencies = set()
bin_dependencies = set()
@@ -48,18 +49,27 @@ def shallow_dependencies_of(asm_file_path):
if keyword == 'INCLUDE':
asm_dependencies.add(path)
else:
- if not os.path.isfile(path):
- path = 'build/' + path
- bin_dependencies.add(path)
+ if os.path.isfile(path) or not build_dirs:
+ bin_dependencies.add(path)
+ else:
+ bin_dependencies.update(os.path.join(d, path) for d in build_dirs)
return asm_dependencies, bin_dependencies
-def main():
- if not len(sys.argv) > 1:
- print("Usage: {} <paths to assembly files...>".format(os.path.basename(__file__)))
- sys.exit(1)
+def main(argv):
+ script_name = os.path.basename(__file__)
+ parser = argparse.ArgumentParser(prog=script_name, add_help=False)
+ parser.add_argument('-h', '--help', action='help', help="Show this help and exit.")
+ parser.add_argument('-b', metavar="build directories", action='append', default=[],
+ help="Build directory to generate dependencies for "
+ "if files don't exist at the exact path specified. "
+ "Multiple build directories may be specified.")
+ parser.add_argument('files', metavar='file', nargs='+',
+ help="An assembly file to generate dependencies for.")
- for path, dependencies in dependencies_in(sys.argv[1:]).items():
+ args = parser.parse_args(argv)
+
+ for path, dependencies in dependencies_in(args.files, args.b).items():
# It seems that if A depends on B which depends on C, and
# C is modified, Make needs you to change the modification
# time of B too. That's the reason for the "@touch $@".
@@ -69,4 +79,4 @@ def main():
print("{}: {}\n\t@touch $@".format(path, ' '.join(dependencies)))
if __name__ == '__main__':
- main()
+ main(sys.argv[1:])