diff options
author | Juan J. Martinez <jjm@usebox.net> | 2023-11-05 11:22:55 +0000 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2023-11-05 11:31:28 +0000 |
commit | 2fbdf974338bde8576efdae40a819a76b2391033 (patch) | |
tree | 64d41a37470143f142344f9a439d96de3e7918c2 /src/Makefile | |
download | kitsunes-curse-2fbdf974338bde8576efdae40a819a76b2391033.tar.gz kitsunes-curse-2fbdf974338bde8576efdae40a819a76b2391033.zip |
Initial import of the open source release
Diffstat (limited to 'src/Makefile')
-rw-r--r-- | src/Makefile | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..eec64ea --- /dev/null +++ b/src/Makefile @@ -0,0 +1,107 @@ +TARGET=kitcurs + +LOADER_ADDR=512 +TMP_ADDR=3072 + +# see splib.h: BUF_ADDR + (TW * TH / 2) * (sprite th * 2 + 2) * max sprites +# 0x0100 + (8 * 8 / 2) * (3 * 2 + 2) * 10 +APP_ADDR=2816 +PAK_SLOP=32 + +LOADER_ADDR_HEX=$(shell printf "%x" $(LOADER_ADDR)) +TMP_ADDR_HEX=$(shell printf "%x" $(TMP_ADDR)) + +CC=sdcc +AS=sdasz80 +AR=sdcclib +CFLAGS=-mz80 --Werror -I../lib -I../generated --fsigned-char --std-sdcc99 --opt-code-speed +LDFLAGS=-L../lib -L. --data-loc 0 --no-std-crt0 --fomit-frame-pointer + +OUTPUT = ../build +OBJS = $(patsubst %.c,$(OUTPUT)/%.rel,$(wildcard *.c)) $(OUTPUT)/int.rel $(OUTPUT)/sound.rel +LIBS = ../lib/cpcrslib/*.lib ../lib/plw.lib ../lib/aplib.lib + +all: CFLAGS := $(CFLAGS) #-DDEBUG -DFENCE_DEBUG -DET_DEBUG +all: $(OUTPUT)/$(TARGET).dsk $(OUTPUT)/$(TARGET).cdt + chksize $(APP_ADDR) $(OUTPUT)/main.map + +release: CFLAGS := $(CFLAGS) --max-allocs-per-node 2000000 +release: $(OUTPUT)/$(TARGET).dsk $(OUTPUT)/$(TARGET).cdt + test -d release || mkdir release + cp $(OUTPUT)/$(TARGET).dsk $(OUTPUT)/$(TARGET).cdt release + chksize $(APP_ADDR) $(OUTPUT)/main.map + +cpce: all + cpce $(OUTPUT)/$(TARGET).dsk + +cpcec: all + cpcec $(OUTPUT)/$(TARGET).dsk + +winape: all + winape $(OUTPUT)/$(TARGET).dsk + +clk: all + clk $(OUTPUT)/$(TARGET).dsk + +rvm: all + rvm -b=cpc6128 -w -p -ns -i $(shell realpath $(OUTPUT)/$(TARGET).dsk) -c='run"$(TARGET)\n' + +$(OUTPUT)/%.rel: %.c + $(CC) $(CFLAGS) $(LDFLAGS) -c $< -o $@ + +$(OUTPUT)/%.rel: %.z80 + $(AS) -g -o $@ $< + +$(OUTPUT)/sound.rel: sound.z80 effects.z80 songs.z80 + +$(OUTPUT)/main.ap: crt0.s $(wildcard *.h) $(LIBS) $(OBJS) ../lib/plw_player.rel + rm -f $(OUTPUT)/main.map + $(AS) -g -o $(OUTPUT)/crt0.rel crt0.s + $(CC) $(CFLAGS) $(LDFLAGS) -laplib -lcpcrslib -lplw --code-loc $(APP_ADDR) $(OUTPUT)/crt0.rel ../lib/plw_player.rel $(OBJS) -o $(OUTPUT)/main.ihx + hex2bin -p 00 $(OUTPUT)/main.ihx + apultra -w 8192 -v $(OUTPUT)/main.bin $@ + +$(OUTPUT)/loader.bin: loader.s turboload.s $(OUTPUT)/loading.bin $(OUTPUT)/main.ap + echo "DISK = 1" > $(OUTPUT)/loader.opt + echo "APP_EP = 0x$(shell awk ' /_main_init/ { print $$1 } ' $(OUTPUT)/main.map)" >> $(OUTPUT)/loader.opt + echo "TMP_ADDR = $(TMP_ADDR)" >> $(OUTPUT)/loader.opt + echo "SCRX_SIZE = $(shell stat -c '%s' $(OUTPUT)/loading.bin)" >> $(OUTPUT)/loader.opt + echo "APP_ADDR = $(APP_ADDR)" >> $(OUTPUT)/loader.opt + echo "APP_SIZE = $(shell stat -c '%s' $(OUTPUT)/main.bin)" >> $(OUTPUT)/loader.opt + echo "APP_SIZE_PAK = $(shell stat -c '%s' $(OUTPUT)/main.ap)" >> $(OUTPUT)/loader.opt + echo "LOADER_ADDR = $(LOADER_ADDR)" >> $(OUTPUT)/loader.opt + echo "PAK_SLOP = $(PAK_SLOP)" >> $(OUTPUT)/loader.opt + $(AS) -g -o $(OUTPUT)/loader.rel $< + $(CC) $(CFLAGS) $(LDFLAGS) --code-loc $(LOADER_ADDR) -laplib -o $(OUTPUT)/loader.ihx $(OUTPUT)/loader.rel + hex2bin -p 00 $(OUTPUT)/loader.ihx + echo "DISK = 0" >> $(OUTPUT)/loader.opt + $(AS) -g -o $(OUTPUT)/loader.rel $< + $(CC) $(CFLAGS) $(LDFLAGS) --code-loc $(LOADER_ADDR) -laplib -o $(OUTPUT)/loader_disk.ihx $(OUTPUT)/loader.rel + hex2bin -p 00 $(OUTPUT)/loader_disk.ihx + +$(OUTPUT)/$(TARGET).dsk: $(OUTPUT)/loader.bin + cp $(OUTPUT)/loader_disk.bin $(OUTPUT)/$(TARGET) + idsk $@ -n -t 1 -i $(OUTPUT)/$(TARGET) -e $(LOADER_ADDR_HEX) -c $(LOADER_ADDR_HEX) > /dev/null + rm -f $(OUTPUT)/$(TARGET) + cp $(OUTPUT)/loading.bin $(OUTPUT)/main.bi0 + idsk $@ -t 1 -i $(OUTPUT)/main.bi0 -c $(TMP_ADDR_HEX) -s > /dev/null + rm -f $(OUTPUT)/main.bi0 + cp $(OUTPUT)/main.ap $(OUTPUT)/main.bi1 + idsk $@ -t 1 -i $(OUTPUT)/main.bi1 -c $(shell printf "%x" $(shell expr $(LOADER_ADDR) + 1024)) -s > /dev/null + rm -f $(OUTPUT)/main.bi1 + +$(OUTPUT)/$(TARGET).cdt: $(OUTPUT)/loader.bin + 2cdt -s 0 -n -X $(LOADER_ADDR) -L $(LOADER_ADDR) -r $(TARGET) $< $@ > /dev/null + 2cdt -m 2 $(OUTPUT)/loading.bin $@ > /dev/null + 2cdt -m 2 $(OUTPUT)/main.ap $@ > /dev/null + +.PHONY: clean all cleanall release +clean: + rm -f $(OUTPUT)/* + +cleanall: + make clean + make -C ../tools clean + make -C ../lib clean + +include Makefile.deps |