summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpfero <ohpee@loves.dicksinhisan.us>2018-06-03 20:42:34 +0200
committerpfero <ohpee@loves.dicksinhisan.us>2018-06-03 20:46:15 +0200
commit25853364c84f0c05611b501807d75e1a1ec10927 (patch)
treeafbab05e7692976d2e78dab08c64f9c8586e3150
parent63ee9c801200b64108dbfcfbc31fe2f5eda975c9 (diff)
Update tools/sort_symfile.sh and clean up Makefile
Fixed compare being ran before the correctedheader rom was built. Made `mostlyclean` clean up all the .d files it knows about and include the correct .d files.
-rw-r--r--.gitignore2
-rw-r--r--Makefile58
-rw-r--r--config.mk25
-rwxr-xr-xtools/sort_symfile.sh6
4 files changed, 25 insertions, 66 deletions
diff --git a/.gitignore b/.gitignore
index a9a059e..4a5d06b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,7 +13,7 @@
*.pic
*.pcm
*.map
-poke*_spaceworld.sym
+poke*-spaceworld.sym
shim.asm
*~
diff --git a/Makefile b/Makefile
index 11977d0..7f7346b 100644
--- a/Makefile
+++ b/Makefile
@@ -1,34 +1,27 @@
-include config.mk
-
-BUILDBASE := build
-BUILD := $(BUILDBASE)
+BUILD := build
MD5 := md5sum -c
PYTHON := python
-PYTHON3 := python3.6
+PYTHON3 := python3
-RGBASM := rgbasm -D$(GAME_VERSION)=1 -DDEBUG=$(DEBUG)
+RGBASM := rgbasm
RGBGFX := rgbgfx
RGBLINK := rgblink
RGBFIX := rgbfix
-
-RGBASMFLAGS := -h -E -i $(BUILD)/
-tools/gfx :=
-tools/make_shim :=
sort_sym := tools/sort_symfile.sh
#sort_sym := $(PYTHON3) tools/sort_sym.py
-ROM := poke$(BUILD_NAME)-spaceworld.gb
-ROMS := $(foreach r, gold gold-debug silver silver-debug, poke$(r)-spaceworld.gb)
-# Pokemon Gold Debug
+RGBASMFLAGS := -h -E -i $(BUILD)/ -DGOLD -DDEBUG=1
+tools/gfx :=
+
+ROM := pokegold-spaceworld.gb
BASEROM := baserom.gb
-DIRS := home engine data audio
-OBJS := $(addprefix $(BUILD)/, gfx.o sram.o wram.o hram.o shim.o)
SHIM := shim.sym
CORRECTEDROM := $(ROM:%.gb=%-correctheader.gb)
-CORRECTEDROMS := $(ROMS:%.gb=%-correctheader.gb)
rwildcard = $(foreach d, $(wildcard $1*), $(filter $(subst *, %, $2), $d) $(call rwildcard, $d/, $2))
+DIRS := home engine data audio
+OBJS := $(addprefix $(BUILD)/, gfx.o sram.o wram.o hram.o shim.o)
OBJS += $(patsubst %.asm, $(BUILD)/%.o, $(call rwildcard, $(DIRS), *.asm))
GFX := $(patsubst %.png, $(BUILD)/%.2bpp, \
@@ -44,7 +37,7 @@ GFX := $(patsubst %.png, $(BUILD)/%.2bpp, \
all: $(ROM) $(CORRECTEDROM) compare
.PHONY: compare
-compare: $(ROM)
+compare: $(ROM) $(CORRECTEDROM)
$(MD5) roms.md5
.PHONY: tools
@@ -58,29 +51,29 @@ coverage: tools/disasm_coverage.py $(ROM)
# Remove files generated by the build process.
.PHONY: clean
clean:
- rm -rf $(ROMS) $(CORRECTEDROMS) $(BUILDBASE) $(ROMS:.gb=.sym) $(ROMS:.gb=.map) $(CORRECTEDROMS)
+ rm -rf $(ROM) $(CORRECTEDROM) $(BUILD) $(ROMS:.gb=.sym) $(ROMS:.gb=.map)
make -C tools clean
# Remove files except for graphics.
.PHONY: mostlyclean
mostlyclean:
- rm -rf $(ROMS) $(OBJS) $(ROMS:.gb=.sym) $(ROMS:.gb=.map) $(CORRECTEDROMS)
- find . \( -iname '*.d' \) -exec rm {} +
+ rm -rf $(ROM) $(CORRECTEDROM) $(OBJS) $(OBJS:.o=.d) $(ROMS:.gb=.sym) $(ROMS:.gb=.map)
+
+$(CORRECTEDROM): %-correctheader.gb: %.gb
+ cp $< $@
+ $(RGBFIX) -f hg -m 0x10 $@
-$(ROM): $(OBJS) | $(BASEROM)
+$(ROM): poke%-spaceworld.gb: $(OBJS) | $(BASEROM)
$(RGBLINK) -d -n $(@:.gb=.sym) -m $(@:.gb=.map) -O $(BASEROM) -o $@ $^
- $(RGBFIX) -f lh -k 01 -l 0x33 -m 0x03 -p 0 -r 3 -t "POKEMON2$(GAME_VERSION)" $@
+ $(RGBFIX) -f lh -k 01 -l 0x33 -m 0x03 -p 0 -r 3 -t "POKEMON2$(shell echo $* | cut -d _ -f 1 | tr '[:lower:]' '[:upper:]')" $@
$(sort_sym) $(@:.gb=.sym)
$(BASEROM):
@echo "Please obtain a copy of Gold_debug.sgb and put it in this directory as $@"
@exit 1
-$(BUILD)/shim.asm: tools/make_shim $(SHIM) tools/make_shim | $$(dir $$@)
+$(BUILD)/shim.asm: tools/make_shim $(SHIM) | $$(dir $$@)
tools/make_shim -w $(filter-out $<, $^) > $@
-$(CORRECTEDROM): %-correctheader.gb: %.gb
- cp $< $@
- $(RGBFIX) -f hg -m 0x10 $@
$(BUILD)/gfx.o: | $(GFX)
$(BUILD)/%.o: $(BUILD)/%.asm | $$(dir $$@)
@@ -121,15 +114,4 @@ $(BUILD)/%.tilemap: %.png | $$(dir $$@)
%/:
mkdir -p $@
--include $(call rwildcard, $(BUILD)/, *.d)
-
-#gold: ; @$(MAKE) GAME_VERSION=GOLD
-#gold_debug: ; @$(MAKE) GAME_VERSION=GOLD DEBUG=1
-#silver: ; @$(MAKE) GAME_VERSION=SILVER
-#silver_debug: ; @$(MAKE) GAME_VERSION=SILVER DEBUG=1
-#compare: ;
-# @$(MAKE) GAME_VERSION=GOLD COMPARE=1
-# @$(MAKE) GAME_VERSION=GOLD DEBUG=1 COMPARE=1
-# @$(MAKE) GAME_VERSION=SILVER COMPARE=1
-# @$(MAKE) GAME_VERSION=SILVER DEBUG=1 COMPARE=1
-# @$(MD5) roms.md5
+-include $(OBJS:.o=.d)
diff --git a/config.mk b/config.mk
deleted file mode 100644
index 7f52d90..0000000
--- a/config.mk
+++ /dev/null
@@ -1,25 +0,0 @@
-### Build Configuration ###
-
-# Default variables
-GAME_VERSION ?= GOLD
-DEBUG ?= 1
-COMPARE ?= 1
-
-# For now, only support building Gold Debug.
-# Uncomment these to support other ROMs.
-
-## Version
-#ifeq ($(GAME_VERSION), GOLD)
- BUILD_NAME := gold
-#else
-#ifeq ($(GAME_VERSION), SILVER)
-# BUILD_NAME := silver
-#else
-# $(error unknown version $(GAME_VERSION))
-#endif
-#endif
-#
-## Debug
-#ifeq ($(DEBUG), 1)
-# BUILD_NAME := $(BUILD_NAME)_debug
-#endif
diff --git a/tools/sort_symfile.sh b/tools/sort_symfile.sh
index d53150f..82fced5 100755
--- a/tools/sort_symfile.sh
+++ b/tools/sort_symfile.sh
@@ -1,10 +1,12 @@
#!/bin/sh
-sed $1 \
+sed \
-e "s/^..:[0-3]/0_ROM0@&/g" \
-e "s/^..:[4-7]/1_ROMX@&/g" \
-e "s/^..:[8-9]/2_VRAM@&/g" \
-e "s/^..:[A-B]/3_SRAM@&/g" \
-e "s/^00:[C-D]/4_WRAM0@&/g" \
-e "s/^..:[D-D]/5_WRAMX@&/g" \
+ $1 \
| sort -o $1
-sed -i $1 -e "s/^\w*@//g"
+TEMP_FILE=$(mktemp)
+sed -e "s/^.*@//g" $1 > $TEMP_FILE && mv $TEMP_FILE $1