shithub: pokered

Download patch

ref: 0e12eafe6635da8e80ed33f7460e09c567d0e31f
parent: da0a72cdbf45fa624b2d1151afe94a98d7da2ae0
author: yenatch <yenatch@gmail.com>
date: Thu May 29 14:52:37 EDT 2014

Dust off the makefile and prepare to build Yellow.

diff: cannot open b/blue//null: file does not exist: 'b/blue//null' diff: cannot open b/red//null: file does not exist: 'b/red//null' diff: cannot open b/yellow//null: file does not exist: 'b/yellow//null'
--- a/Makefile
+++ b/Makefile
@@ -1,94 +1,81 @@
 PYTHON := python
+MD5    := md5sum -c --quiet
 
 .SUFFIXES:
 .SUFFIXES: .asm .tx .o .gbc
-.PHONY: all clean red blue compare pngs
+.PHONY: all clean red blue yellow compare
 .PRECIOUS: %.2bpp
 .SECONDEXPANSION:
 
-POKEMONTOOLS := extras/pokemontools
-GFX          := $(PYTHON) $(POKEMONTOOLS)/gfx.py
-PIC          := $(PYTHON) $(POKEMONTOOLS)/pic.py
-INCLUDES     := $(PYTHON) $(POKEMONTOOLS)/scan_includes.py
-PREPROCESS   := $(PYTHON) prequeue.py
+poketools := extras/pokemontools
+gfx       := $(PYTHON) $(poketools)/gfx.py
+pic       := $(PYTHON) $(poketools)/pic.py
+includes  := $(PYTHON) $(poketools)/scan_includes.py
+pre       := $(PYTHON) prequeue.py
 
-TEXTQUEUE :=
 
-RED_OBJS  := \
-pokered.o \
-audio_red.o \
-wram.o \
-text.o
+versions := red blue yellow
 
-BLUE_OBJS := \
-pokeblue.o \
-audio_blue.o \
-wram.o \
-text.o
+$(foreach ver, $(versions), \
+	$(eval $(ver)_asm := $(shell find $(ver) -iname '*.asm')) \
+	$(eval $(ver)_obj := $($(ver)_asm:.asm=.o)) \
+	$(eval all_obj += $($(ver)_obj)) \
+)
+$(foreach obj, $(all_obj), \
+	$(eval $(obj:.o=)_dep := $(shell $(includes) $(obj:.o=.asm))) \
+)
 
-OBJS := $(RED_OBJS) $(BLUE_OBJS)
-OBJS := $(sort $(OBJS))
 
-ROMS := pokered.gbc pokeblue.gbc
+roms := pokered.gbc pokeblue.gbc
 
-# object dependencies
-$(shell $(foreach obj, $(OBJS), $(eval $(obj:.o=)_DEPENDENCIES := $(shell $(INCLUDES) $(obj:.o=.asm)))))
+all:    $(roms)
+red:    pokered.gbc
+blue:   pokeblue.gbc
+yellow: pokeyellow.gbc
 
-all: $(ROMS)
-red:  pokered.gbc
-blue: pokeblue.gbc
 compare:
-	@md5sum -c --quiet roms.md5
+	@$(MD5) roms.md5
 clean:
-	rm -f $(ROMS)
-	rm -f $(OBJS)
-	find .   -iname '*.tx'      -exec rm {} +
-	find gfx -iname '*.[12]bpp' -exec rm {} +
-	find pic -iname '*.pic'     -exec rm {} +
-	find pic -iname '*.2bpp'    -exec rm {} +
-	rm -f redrle
+	rm -f $(roms) $(all_obj)
+	find . \( -iname '*.tx' -o -iname '*.1bpp' -o -iname '*.2bpp' -o -iname '*.pic' \) -exec rm {} +
 
 
-redrle: extras/redtools/redrle.c
-	${CC} -o $@ $<
-
-
 %.asm: ;
-.asm.tx:
-	$(eval TEXTQUEUE += $<)
+%.tx: %.asm
+	$(eval txq += $<)
 	@rm -f $@
 
-$(OBJS): $$*.tx $$(patsubst %.asm, %.tx, $$($$*_DEPENDENCIES))
-	@$(PREPROCESS) $(TEXTQUEUE)
-	@$(eval TEXTQUEUE :=)
-	@$(GFX) 2bpp $(2BPPQUEUE)
-	@$(eval 2BPPQUEUE :=)
-	@$(GFX) 1bpp $(1BPPQUEUE)
-	@$(eval 1BPPQUEUE :=)
-	@$(PIC) compress $(PICQUEUE)
-	@$(eval PICQUEUE  :=)
+$(all_obj): $$*.tx $$(patsubst %.asm, %.tx, $$($$*_dep))
+	@$(pre) $(txq);           $(eval txq   :=)
+	@$(gfx) 2bpp $(2bppq);    $(eval 2bppq :=)
+	@$(gfx) 1bpp $(1bppq);    $(eval 1bppq :=)
+	@$(pic) compress $(picq); $(eval picq  :=)
 	rgbasm -o $@ $*.tx
 
 
-OPTIONS = -jsv -k 01 -l 0x33 -m 0x13 -p 0 -r 03
+link    := rgblink -n $*.sym -m $*.map
+dmg_opt :=  -jsv -k 01 -l 0x33 -m 0x13 -p 0 -r 03
+cgb_opt := -cjsv -k 01 -l 0x33 -m 0x1b -p 0 -r 03
 
-pokered.gbc: $(RED_OBJS)
-	rgblink -n $*.sym -m $*.map -o $@ $^
-	rgbfix $(OPTIONS) -t "POKEMON RED" $@
+pokered.gbc: $(red_obj)
+	$(link) -o $@ $^
+	rgbfix $(dmg_opt) -t "POKEMON RED" $@
 
-pokeblue.gbc: $(BLUE_OBJS)
-	rgblink -n $*.sym -m $*.map -o $@ $^
-	rgbfix $(OPTIONS) -t "POKEMON BLUE" $@
+pokeblue.gbc: $(blue_obj)
+	$(link) -o $@ $^
+	rgbfix $(dmg_opt) -t "POKEMON BLUE" $@
 
+pokeyellow.gbc: $(yellow_obj)
+	$(link) -o $@ $^
+	rgbfix $(cgb_opt) -t "POKEMON YELLOW" $@
 
+
 %.2bpp: %.png
-	$(eval 2BPPQUEUE += $<)
+	$(eval 2bppq += $<)
 	@rm -f $@
 %.1bpp: %.png
-	$(eval 1BPPQUEUE += $<)
+	$(eval 1bppq += $<)
 	@rm -f $@
-%.pic: %.2bpp
-	$(eval PICQUEUE  += $<)
+%.pic:  %.2bpp
+	$(eval picq  += $<)
 	@rm -f $@
-
-
--- a/audio_blue.asm
+++ /dev/null
@@ -1,2 +1,0 @@
-INCLUDE "blue.asm"
-INCLUDE "audio.asm"
--- a/audio_red.asm
+++ /dev/null
@@ -1,2 +1,0 @@
-INCLUDE "red.asm"
-INCLUDE "audio.asm"
--- /dev/null
+++ b/blue/audio.asm
@@ -1,0 +1,2 @@
+INCLUDE "blue.asm"
+INCLUDE "audio.asm"
--- /dev/null
+++ b/blue/main.asm
@@ -1,0 +1,2 @@
+INCLUDE "blue.asm"
+INCLUDE "main.asm"
--- /dev/null
+++ b/blue/text.asm
@@ -1,0 +1,2 @@
+INCLUDE "blue.asm"
+INCLUDE "text.asm"
--- /dev/null
+++ b/blue/wram.asm
@@ -1,0 +1,2 @@
+INCLUDE "blue.asm"
+INCLUDE "wram.asm"
--- a/pokeblue.asm
+++ /dev/null
@@ -1,2 +1,0 @@
-INCLUDE "blue.asm"
-INCLUDE "main.asm"
--- a/pokered.asm
+++ /dev/null
@@ -1,2 +1,0 @@
-INCLUDE "red.asm"
-INCLUDE "main.asm"
--- /dev/null
+++ b/red/audio.asm
@@ -1,0 +1,2 @@
+INCLUDE "red.asm"
+INCLUDE "audio.asm"
--- /dev/null
+++ b/red/main.asm
@@ -1,0 +1,2 @@
+INCLUDE "red.asm"
+INCLUDE "main.asm"
--- /dev/null
+++ b/red/text.asm
@@ -1,0 +1,2 @@
+INCLUDE "red.asm"
+INCLUDE "text.asm"
--- /dev/null
+++ b/red/wram.asm
@@ -1,0 +1,2 @@
+INCLUDE "red.asm"
+INCLUDE "wram.asm"
--- /dev/null
+++ b/yellow.asm
@@ -1,0 +1,1 @@
+_YELLOW EQU 1
--- /dev/null
+++ b/yellow/audio.asm
@@ -1,0 +1,2 @@
+INCLUDE "yellow.asm"
+INCLUDE "audio.asm"
--- /dev/null
+++ b/yellow/main.asm
@@ -1,0 +1,2 @@
+INCLUDE "yellow.asm"
+INCLUDE "main.asm"
--- /dev/null
+++ b/yellow/text.asm
@@ -1,0 +1,2 @@
+INCLUDE "yellow.asm"
+INCLUDE "text.asm"
--- /dev/null
+++ b/yellow/wram.asm
@@ -1,0 +1,2 @@
+INCLUDE "yellow.asm"
+INCLUDE "wram.asm"