aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorB. Watson <yalhcru@gmail.com>2016-02-10 21:40:44 -0500
committerB. Watson <yalhcru@gmail.com>2016-02-10 21:40:44 -0500
commita3b6b98841b832a8cc11ab6a760a4eda2a91839f (patch)
tree7cc20c6a48d5de7516a2d46832ee1807bb5d6817 /Makefile
parent5ea5690f453b2b84f021c539d16b149e33795357 (diff)
downloadtaipan-a3b6b98841b832a8cc11ab6a760a4eda2a91839f.tar.gz
add check for at least 32K to cart, various tinkering
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile122
1 files changed, 84 insertions, 38 deletions
diff --git a/Makefile b/Makefile
index c68cbea..d1d8410 100644
--- a/Makefile
+++ b/Makefile
@@ -2,6 +2,8 @@
# Written for GNU make, but seems to work with BSD make (though
# I don't test BSD make every time I change anything).
+# 'make help' will show the list of targets.
+
# cl65 binary:
CC=cl65
@@ -67,10 +69,14 @@ AS=ca65
ASFLAGS=
AR=ar65
-# C compiler for host system. Currently only used for building convfont.
+# C compiler for host system. Currently only used for building convfont
+# and mkcart.
HOSTCC=gcc
HOSTCFLAGS=-Wall
+# Perl binary. This Makefile relies heavily on perl.
+PERL=perl
+
# A few files have no make rules here. LORCHA.DAT is generated as a
# side-effect of generating taifont.xex. It's a 49-byte (7x7) blob of
# Atari "internal" screen codes.
@@ -103,19 +109,47 @@ BIGNUM_CFLAGS=-DBIGNUM=BIGFLOAT
#BIGNUM_CFLAGS=-DBIGNUM=BIGINT48
# Default rule for plain 'make' command is to build the binary.
-all: $(XEX) tags
+all: checkenv $(XEX) tags
# I have F10 in my editor bound to 'make test', so:
test: all
atari800 -nobasic $(XEX)
+# Check the build environment.
+checkenv:
+ @$(PERL) -e1 && echo "perl found" && exit 0 || echo "perl missing" && exit 1
+ @$(PERL) -MImage::Magick -e1 && echo "perl Image::Magick found" && exit 0 || echo "perl Image::Magick missing" && exit 1
+ @$(CC) --help > /dev/null && echo "cl65 found" && exit 0 || echo "cl65 missing (install cc65)" && exit 1
+ @echo "int main() { return 0; }" > 1.c && exit 0 || echo "can't create files in current directory" && exit 1
+ @$(HOSTCC) -o 1 1.c && echo "host C compiler found" && exit 0 || echo "host C compiler missing or broken" && exit 1
+
# ctags. I forgot it can handle cc65 asm source. One wrinkle: C
# identifiers get prepended with an underscore from the POV of assembly
# code, and asm identifiers need a leading underscore to be used from
# C. There's probably a clever way to get ctags to handle this, but I
# don't know it, so I wrote a perl script to do the job.
tags:
- @ctags $(TAIMAIN_C_SRC) $(TAIMAIN_ASM_SRC) 2>/dev/null && perl fixtags.pl tags || true
+ @ctags $(TAIMAIN_C_SRC) $(TAIMAIN_ASM_SRC) 2>/dev/null && $(PERL) fixtags.pl tags || true
+
+help:
+ @echo "Top-level targets:"
+ @echo "make - builds taipan.xex (disk version)"
+ @echo "make cart - builds taipan.rom and taipan.cart (cartridge version)"
+ @echo "make test - builds & runs taipan.xex in atari800 emulator"
+ @echo "make dos2 - builds & runs taipan.xex in atari800 on a "; \
+ echo " DOS 2.0S floppy image"
+ @echo "make mydos - builds & runs taipan.xex in atari800 on a "; \
+ echo " MyDOS 4.50 floppy image"
+ @echo "make fenders - builds & runs taipan.xex in atari800 on a "; \
+ echo " Fenders 3-sector Loader floppy image"
+ @echo "make testcart - builds & runs taipan.cart in atari800 emulator"
+ @echo
+ @echo "Useful variables to add to the make command:"
+ @echo " CC - path to cl65 binary (default: cl65, searches PATH)"
+ @echo " EXTRACFLAGS - extra options to pass to cl65"
+ @echo " HOSTCC - path to native C compiler (default: gcc, searches PATH)"
+ @echo " HOSTCFLAGS - extra options to pass to HOSTCC (default: -Wall)"
+ @echo " PERL - path to perl binary (default: perl, searches PATH)"
# The above is fast & easy, but from time to time it's necessary
# to test slow loading, make sure the title screen stuff works OK.
@@ -144,8 +178,8 @@ mydos: all
# The game binary is a multi-part binary load file. This rule
# depends on all the pieces, and just concatenates them.
$(XEX): checkmem.xex taimain.xex taifont.xex newtitle.xex comptitle.xex
- perl multixex.pl checkmem.xex comptitle.xex newtitle.xex taifont.xex taimain.xex > $(XEX)
- perl size.pl $(TAIMAIN_ADDR) $(STACK_SIZE)
+ $(PERL) multixex.pl checkmem.xex comptitle.xex newtitle.xex taifont.xex taimain.xex > $(XEX)
+ $(PERL) size.pl $(TAIMAIN_ADDR) $(STACK_SIZE)
# Bitmap data for the title screen, 256x184 = 47104 pixels, 8 bits
# per pixel, or 5888 bytes. Displayed in ANTIC mode F (aka GR.8),
@@ -156,12 +190,12 @@ $(XEX): checkmem.xex taimain.xex taifont.xex newtitle.xex comptitle.xex
# the game binary as-is: it's now used as input for creating
# comptitle.xex, the compressed title screen.
titledata.dat: newtitle.pl newtitle.png
- perl newtitle.pl > titledata.dat
+ $(PERL) newtitle.pl > titledata.dat
# compressed title, for faster loading. see titlecompression.txt
# for gory details.
comptitle.xex: titledata.dat titlecomp.pl comptitle.s.in
- perl titlecomp.pl 133 < titledata.dat
+ $(PERL) titlecomp.pl 133 < titledata.dat
cl65 -l comptitle.lst -o comptitle.xex -t none --asm-define destination=$(TITLE_DATA_ADDR) comptitle.s
# tiny 1-sector memory checker, aborts the laod if a cart is present.
@@ -181,14 +215,14 @@ newtitle.xex: newtitle.s ver.dat help.dat
# Version number in Atari screen-data form
ver.dat: text2screen.pl
- echo "$(VERSION)" | perl text2screen.pl > ver.dat
+ echo "$(VERSION)" | $(PERL) text2screen.pl > ver.dat
# Help text for the title screen
help.dat: help.txt text2screen.pl
- perl text2screen.pl < help.txt > help.dat
+ $(PERL) text2screen.pl < help.txt > help.dat
#ver.dat: mkver.pl
-# perl mkver.pl $(VERSION) > ver.dat
+# $(PERL) mkver.pl $(VERSION) > ver.dat
# The main executable. All the C and asm code goes here, except the init
# segment in newtitle.s.
@@ -216,9 +250,10 @@ taifont.xex: convfont romfont font
cat romfont font | ./convfont -x > taifont.xex
touch draw_lorcha.s
-# Not part of the game binary. This just builds the font without the
-# Atari 6-byte binary load header, for eyeballing it in bitmapdump.pl
-# or converting to other formats.
+# Used by the cartridge build, but not the disk (xex) binary. This just
+# builds the font without the Atari 6-byte binary load header. It ends
+# up at the top of one of the cartridge banks, and is also useful for
+# eyeballing the font in bitmapdump.pl or converting to other formats.
taifont: convfont romfont font
cat romfont font | ./convfont > taifont
@@ -241,9 +276,14 @@ convfont: convfont.c
$(HOSTCC) $(HOSTCFLAGS) -DFONT_ADDR=$(FONT_ADDR) -o convfont convfont.c
-### Cartridge-related targets.
+### Cartridge-related targets. The way I'm doing this isn't 'proper': I should
+# be using cc65's linker with a fancy config script to do the bank layout
+# and such. But it's a lot easier for me to use the tools I know how to use,
+# so that's what I did.
# mkcart turns a raw binary into an atar800 .cart image with 16-byte header.
+# originally I wrote this for use with the DASM assembler, but there's
+# nothing DASM-specific about it.
mkcart: mkcart.c
$(HOSTCC) $(HOSTCFLAGS) -o mkcart mkcart.c
@@ -259,17 +299,17 @@ romable_taimain.raw: $(TAIMAIN_C_SRC) $(TAIMAIN_ASM_SRC) $(TAIMAIN_HDRS)
tail -c+2 taimain.xex > romable_taimain.raw
rm -f taimain.xex
-# 512 bytes of $ff filler, for the last 2 pages of each code bank. Wasting
-# this little bit of space simplifies the copying code in bank7.s, and
-# guarantees I don't accidentally end up with a 0 in the "cart present"
-# byte of the cart trailer.
-fill512:
- perl -Mbytes -e 'print chr(0xff) x 512' > fill512
+# 256 bytes of $ff filler, for the last page of each code bank. Wasting
+# this little bit of space simplifies the copying code in bank7.s (no
+# partial last page to copy), and guarantees I don't accidentally end
+# up with a 0 in the "cart present" byte of the cart trailer.
+fill256:
+ $(PERL) -Mbytes -e 'print chr(0xff) x 256' > fill256
# 8192 bytes of $ff filler, for unused banks. Possibly these will be
# used for something like an interactive game manual/tutorial.
blankbank:
- perl -Mbytes -e 'print chr(0xff) x 8192' > blankbank
+ $(PERL) -Mbytes -e 'print chr(0xff) x 8192' > blankbank
splitrom.raw.0: splitrom.raw.3
@@ -277,36 +317,42 @@ splitrom.raw.1: splitrom.raw.3
splitrom.raw.2: splitrom.raw.3
+# split romable_taimain.raw into bank-sized chunks. if we end up
+# with 4 chunks, the cart won't work correctly, so stop the build here
+# in that case.
splitrom.raw.3: romable_taimain.raw
- split -b 7680 -a 1 -d romable_taimain.raw splitrom.raw.
+ split -b 7936 -a 1 -d romable_taimain.raw splitrom.raw.
+ [ -e splitrom.raw.4 ] && echo "*** romable_taimain.raw too big" && rm -f splitrom.raw.* && exit 1 || exit 0
-bank0: splitrom.raw.0 fill512
- cat splitrom.raw.0 fill512 > bank0
+bank0: splitrom.raw.0 fill256
+ cat splitrom.raw.0 fill256 > bank0
-bank1: splitrom.raw.1 fill512
- cat splitrom.raw.1 fill512 > bank1
+bank1: splitrom.raw.1 fill256
+ cat splitrom.raw.1 fill256 > bank1
-bank2: splitrom.raw.2 fill512
- cat splitrom.raw.2 fill512 > bank2
+bank2: splitrom.raw.2 fill256
+ cat splitrom.raw.2 fill256 > bank2
bank3: splitrom.raw.3 bank3.s taifont
cl65 -l bank3.lst -m bank3.map -t none -o bank3 bank3.s
bank7: bank7.s titledata.dat ver.dat help.dat newtitle.s
- cl65 -l bank7.lst -m bank7.map -t none -o bank7 bank7.s
+ cl65 --asm-define BANK3SIZE=`$(PERL) -e 'print -s "splitrom.raw.3"'` -l bank7.lst -m bank7.map -t none -o bank7 bank7.s
+# raw ROM, for burning to EPROM/flash.
taipan.rom: bank0 bank1 bank2 bank3 bank7 blankbank
cat bank0 bank1 bank2 bank3 blankbank blankbank blankbank bank7 > taipan.rom
-cart: taipan.cart
-
-testcart:
- atari800 taipan.cart
-
+# .cart version with atari800-compatible header.
taipan.cart: taipan.rom mkcart
./mkcart -otaipan.cart -t13 taipan.rom
./mkcart -ctaipan.cart
+cart: checkenv taipan.cart
+
+testcart: cart
+ atari800 taipan.cart
+
### Rules for building various file types with the cc65 toolchain.
.s.o:
@@ -320,16 +366,16 @@ taipan.cart: taipan.rom mkcart
# Obligatory clean and distclean rules.
clean:
- rm -f *.o *.lst convfont *.xex AUTORUN.SYS taipan.atr ver.dat help.dat tags cartmsg.dat splitrom.raw.* taipan.rom taipan.cart bank[0-9] fill512 blankbank romable_taimain.raw
+ rm -f *.o *.lst convfont *.xex AUTORUN.SYS taipan.atr ver.dat help.dat tags cartmsg.dat splitrom.raw.* taipan.rom taipan.cart bank[0-9] fill512 blankbank romable_taimain.raw splitrom.raw.* comptitle.s comptitle.dat
distclean: clean
- rm -f *~ core .*.swp 1.* 2.* 1 2 3 map map.* *.map a b c foo bar baz comptitle.s comptitle.dat
+ rm -f *~ core .*.swp 1.* 2.* 1 2 3 map map.* *.map a b c foo bar baz
push:
sh push.sh
size: clean all
- perl size.pl $(TAIMAIN_ADDR) $(STACK_SIZE)
+ $(PERL) size.pl $(TAIMAIN_ADDR) $(STACK_SIZE)
# Cruft. Was used for testing the enemy ship animation.
lorchatest: lorchatest.c draw_lorcha.s taifont.xex
@@ -364,7 +410,7 @@ soundtest: sounds.c
# former textmode title screen, was generated by TITLE.LST. Replaced
# by graphical title screen.
#title.xex: TITLE.DAT
-# perl title.pl TITLE.DAT > title.xex
+# $(PERL) title.pl TITLE.DAT > title.xex
# old title
#$(XEX): taimain.xex taifont.xex title.xex