aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorB. Watson <yalhcru@gmail.com>2016-01-01 07:35:12 -0500
committerB. Watson <yalhcru@gmail.com>2016-01-01 07:35:12 -0500
commiteb26be6238c9d9254dbd7b01844e9f0b2a674a93 (patch)
tree138de65cc9c36c791a3aa476dcb1ee44608361b4 /Makefile
parent745aa81b83b9cea5468210bf65601fd3a1090787 (diff)
downloadtaipan-eb26be6238c9d9254dbd7b01844e9f0b2a674a93.tar.gz
graphical title, Makefile clean/documentation
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile141
1 files changed, 104 insertions, 37 deletions
diff --git a/Makefile b/Makefile
index d5faa1e..92b1611 100644
--- a/Makefile
+++ b/Makefile
@@ -1,11 +1,21 @@
+# Makefile for Atari 800 Taipan, by B. Watson
+# Written for GNU make, but seems to work with BSD make (though
+# I don't test BSD make every time I change anything).
+# cl65 binary:
CC=cl65
+
+# System cl65 will compile for. Don't expect this to work if you change it
+# (though possibly atarixl might work, with newer cc65s)
SYS=atari
-# the meaning of the -l flag is different between cc65-2.13.3
-# and the later github cc65, so it's commented out here.
-#COPT=-O -l -T
-COPT=-O -T
+# Optimization flags for cc65.
+#COPT=-Oirs
+COPT=-O
+
+# This is used for embedding the date and git hash in the game binary.
+# It'll appear on the "name your firm" screen.
+VERSION="v0.99alpha-`date +%Y%m%d`-`git rev-parse --short HEAD 2>/dev/null || echo UNKNOWN`"
# for older cc65, we need a custom linker file.
#CFLAGS=-t $(SYS) -C custom.cfg -I. -L. $(COPT)
@@ -13,29 +23,27 @@ COPT=-O -T
# for recent git cc65, we can reserve memory on the command line.
# -D__RESERVED_MEMORY__=1056 because cc65's default end of memory
# is $BC20, and we want it to end just below our font, which starts
-# at $B800.
+# at $B800. cc65's runtime stack starts just below this, and is
+# 2K in size (bottom is at 0xb000).
# -D__SYSTEM_CHECK__=1 stops cl65 from prepending a bit of code that
# checks to make sure there's enough memory. Older cc65 didn't do this,
# and I never missed it.
-CFLAGS=-t $(SYS) -I. -L. -Wl -D__SYSTEM_CHECK__=1 -Wl -D__RESERVED_MEMORY__=1056 $(COPT)
+# The meaning of the -l flag is different between cc65-2.13.3
+# and the later github cc65, so it's been removed here.
+CFLAGS=-t $(SYS) -T -I. -L. -DVERSION=\"$(VERSION)\" -Wl -D__SYSTEM_CHECK__=1 -Wl -D__RESERVED_MEMORY__=1056 $(COPT)
AS=ca65
ASFLAGS=
AR=ar65
-VERSION="v0.99alpha-$(shell date +%Y%m%d)-$(shell git rev-parse --short HEAD 2>/dev/null || echo UNKNOWN)"
+# C compiler for host system. Currently only used for building convfont.
+HOSTCC=gcc
+HOSTCFLAGS=-Wall
# 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.
-# TITLE.DAT is generated by Atari BASIC code in TITLE.LST,
-# except last time I modified it, I exited the emulator without
-# saving the damn BASIC source, so TITLE.LST is outdated. TITLE.DAT
-# is a complete 960-byte dump of GR.0 screen memory, which gets
-# turned into title.xex and prepended to the main .xex. When
-# it loads, it goes straight to screen memory.
-
-# TITLE.DAT, LORCHA.DAT, and PORTSTAT.DAT aren't deleted by a
+# LORCHA.DAT, and PORTSTAT.DAT aren't deleted by a
# 'make clean'.
# romfont is the 1K font extracted from the Atari 800 OS, with a
@@ -43,54 +51,113 @@ VERSION="v0.99alpha-$(shell date +%Y%m%d)-$(shell git rev-parse --short HEAD 2>/
# dd if=atariosb.rom of=1 bs=256 skip=8 count=4
# ...where atariosb.rom comes from e.g. the PC-Xformer 2.5 zip file.
+# The game binary:
XEX=taipan.xex
+# Default rule for plain 'make' command is to build the binary.
all: $(XEX)
-ver:
- @echo $(VERSION)
-
-$(XEX): taimain.xex taifont.xex title.xex
- cat taifont.xex title.xex taimain.xex > $(XEX)
-
-title.xex: TITLE.DAT
- perl title.pl TITLE.DAT > title.xex
-
-taimain.xex: taipan.c rand.s draw_lorcha.s taifont.xex
- cl65 -DVERSION=\"$(VERSION)\" --mapfile taipan.map $(CFLAGS) -o taimain.xex taipan.c rand.s draw_lorcha.s timed_getch.s jsleep.s portstat.s
+# I have F10 in my editor bound to 'make test', so:
+test: all
+ atari800 -nobasic $(XEX)
+# old title
+#$(XEX): taimain.xex taifont.xex title.xex
+# cat taifont.xex title.xex taimain.xex > $(XEX)
+
+# The game binary is a multi-part binary load file. This rule
+# depends on all the pieces, and just concatenates them.
+$(XEX): taimain.xex taifont.xex newtitle.xex titledata.xex
+ cat titledata.xex newtitle.xex taifont.xex taimain.xex > $(XEX)
+
+# Bitmap data for the title screen, 256x184 = 47104 pixels, 8 bits
+# per pixel, or 5888 bytes. Displayed in ANTIC mode F (aka GR.8),
+# using GTIA narrow playfield. The original title screen for the Apple
+# is a 280x192 bitmap with a few blank lines at the top & bottom. I
+# squished it horizontally to 256 pixels and got rid of the blank lines,
+# to save load time.
+titledata.xex: newtitle.pl newtitle.png
+ perl newtitle.pl > titledata.xex
+
+# Init segment that loads after the title screen data. It sets up
+# a custom display list and sets the GTIA for narrow playfield,
+# then waits for a keypress. Afterwards, it restores the OS's
+# display list and sets the GTIA back to normal, then exits.
+# Notice this is built with "-t none" instead of "-t atari",
+# since it's a lot easier to homebrew an init segment than it is
+# to get cc65 to build an init segment (would need a custom linker
+# script at least).
+newtitle.xex: newtitle.s
+ cl65 -o newtitle.xex -t none newtitle.s
+
+# 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
+
+# The main executable. All the C and asm code goes here, except the init
+# segment in newtitle.s.
+taimain.xex: taipan.c rand.s draw_lorcha.s timed_getch.s jsleep.s portstat.s clrtobot.s
+ cl65 --mapfile taipan.map $(CFLAGS) -o taimain.xex taipan.c rand.s draw_lorcha.s timed_getch.s jsleep.s portstat.s clrtobot.s
+
+# With newer cc65s, I have to do this to get an assembly listing of just
+# taipan.c. This rule not used as part of the main build, it's only for
+# debugging.
+taipan.lst: taipan.c
+ cl65 --mapfile taipan.map $(CFLAGS) -c -o /dev/null -l taipan.lst -T taipan.c
+
+# The font gets loaded into RAM, in the area reserved by the
+# -D__RESERVED_MEMORY__ option to cl65. To actually use the font,
+# taimain.xex contains code that sets CHBAS ($02f4).
+# Not mentioned in any make rule: convfont also creates LORCHA.DAT,
+# which draw_lorcha.s depends on (so we touch draw_lorcha.s here).
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.
taifont: convfont romfont font
cat romfont font | ./convfont > taifont
-convfont: convfont.c
- gcc -Wall -o convfont convfont.c
+# PORTSTAT.DAT gets incbin'ed directly in portstat.s. It's screen-code
+# data for the static part of the port status screen, which ends up in
+# an array that the C code can memcpy() into screen RAM as needed.
+# This make rule actually runs atari800. For it to work, you'll need
+# the H: device enabled, pointed at the current directory, and set
+# to writable.
+PORTSTAT.DAT: mkportstats.xex
+ atari800 -nobasic mkportstats.xex
+ touch portstat.s
-test: all
- atari800 -nobasic $(XEX)
+# Host tool that builds our custom font from the data ripped out of
+# the Apple version, plus the Atari OS ROM. Also, all the custom
+# characters for the enemy ships are defined here (as hex data. Yes,
+# I converted them manually from eyeballing a screenshot of the Apple
+# combat screen).
+convfont: convfont.c
+ $(HOSTCC) $(HOSTCFLAGS) -o convfont convfont.c
+# Rules for building various file types with the cc65 toolchain.
.s.o:
$(AS) $(ASFLAGS) -o $@ $<
.c.o:
$(CC) $(CFLAGS) -c -o $@ $<
+%.xex: %.c
+ $(CC) --mapfile map $(CFLAGS) -o $@ $<
+
+# Obligatory clean and distclean rules.
clean:
- rm -f *.o *.lst convfont *.xex
+ rm -f *.o *.lst convfont *.xex AUTORUN.SYS
distclean: clean
rm -f *~ core .*.swp 1.* 2.* 1 2 3 map map.* *.map a b c foo bar baz
-%.xex: %.c
- $(CC) --mapfile map $(CFLAGS) -o $@ $<
-
+# Cruft. Was used for testing the enemy ship animation.
lorchatest: lorchatest.c draw_lorcha.s taifont.xex
cl65 -t atari -O -T -o lorchatest1.xex lorchatest.c draw_lorcha.s
cat taifont.xex lorchatest1.xex > lorchatest.xex
atari800 -nobasic lorchatest.xex
-
-PORTSTAT.DAT: mkportstats.xex
- atari800 -nobasic mkportstats.xex