blob: 3ca267af9d1efde2feabfb7d12c375e5f23f555f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
TARGET := game
include ../../config.env
CODE := 0x4000
# leaves 222 bytes for AKM player buffer
DATA := 0xc0de
OUTDIR := ../../bin
TMPDIR := ../build
# will automatically include (and compile) any .c or .z80 file
OBJS := $(patsubst %.c,$(TMPDIR)/%.rel,$(wildcard *.c)) $(patsubst %.z80,$(TMPDIR)/%.rel,$(wildcard *.z80))
# crt0.z80 is compiled as requirement of the targets and MUST be linked first,
# so we exclude it from the list of user-provided source
OBJS := $(filter-out $(TMPDIR)/crt0.rel,$(OBJS))
UBOX_LIBS := $(wildcard ../../lib/*.lib)
LIBS := -lubox -lspman -lmplayer -lap
CC := sdcc
AS := sdasz80
AR := sdcclib
CHKSIZE := ../../tools/chksize
CFLAGS := -mz80 --Werror -I../../include -I../generated --fsigned-char --std-sdcc99 --opt-code-speed --fomit-frame-pointer $(EXTRA_CFLAGS)
LDFLAGS := -L../../lib -L. --no-std-crt0
default:
$(error Please use the Makefile from root directory)
all: $(TMPDIR)/$(TARGET).rom
@$(CHKSIZE) $(ROM_MAX) 4000 $(TMPDIR)/$(TARGET).map
@cp $(TMPDIR)/$(TARGET).rom $(OUTDIR)
cas: $(TMPDIR)/$(TARGET).cas
@cp $(TMPDIR)/$(TARGET).cas $(OUTDIR)
openmsx: all
openmsx -carta $(OUTDIR)/$(TARGET).rom -machine msx1
$(TMPDIR)/%.rel: %.c
$(CC) $(CFLAGS) $(LDFLAGS) -c $< -o $@
$(TMPDIR)/%.rel: %.z80
$(AS) -g -o $@ $<
$(TMPDIR)/akm.rel: akm.z80 song.asm effects.asm
rasm akm.z80 -o $(TMPDIR)/akm -s -sl -sq
Disark --sourceProfile sdcc --symbolFile $(TMPDIR)/akm.sym --src16bitsValuesInHex --src8bitsValuesInHex --undocumentedOpcodesToBytes $(TMPDIR)/akm.bin $(TMPDIR)/akm_sdcc.asm
$(AS) -g -o $@ $(TMPDIR)/akm_sdcc.asm
$(TMPDIR)/$(TARGET).rom: $(OBJS) $(TMPDIR)/crt0.rel $(UBOX_LIBS)
$(CC) $(CFLAGS) $(LDFLAGS) $(LIBS) --code-loc $(CODE) --data-loc $(DATA) $(TMPDIR)/crt0.rel $(OBJS) -o $(TMPDIR)/$(TARGET).ihx
hex2bin -e bin -p 00 -l $(ROM_MAX) $(TMPDIR)/$(TARGET).ihx
@cp $(TMPDIR)/$(TARGET).bin $(TMPDIR)/$(TARGET).rom
LOADER_ADDR=0xe000
LOADER_WORK_ADDR=0x8000
$(TMPDIR)/$(TARGET).cas: $(TMPDIR)/$(TARGET).rom cas/loader.bas $(TMPDIR)/loader.bin $(TMPDIR)/loading.ap
apultra -v $(TMPDIR)/$(TARGET).rom $(TMPDIR)/$(TARGET).ap
../../tools/mkcas.py --name $(TARGET) $@ ascii cas/loader.bas
../../tools/mkcas.py -a --name loader --addr $(LOADER_ADDR) --exec $(LOADER_ADDR) $@ binary $(TMPDIR)/loader.bin
../../tools/mkcas.py -a --addr $(LOADER_WORK_ADDR) $@ custom-header $(TMPDIR)/loading.ap
../../tools/mkcas.py -a --addr $(LOADER_WORK_ADDR) $@ custom-header $(TMPDIR)/$(TARGET).ap
$(TMPDIR)/loader.bin: $(TMPDIR)/loader.rel
$(CC) $(CFLAGS) $(LDFLAGS) --code-loc $(LOADER_ADDR) --data-loc 0 -lap $< -o $(TMPDIR)/loader.ihx
hex2bin -p 00 $(TMPDIR)/loader.ihx
$(TMPDIR)/loading.ap: ../data/loading.png
../../tools/png2scr.py ../data/loading.png > $(TMPDIR)/loading.bin
apultra -v $(TMPDIR)/loading.bin $(TMPDIR)/loading.ap
$(TMPDIR)/loader.rel: cas/loader.z80
$(AS) -g -o $@ $<
clean:
rm -f $(TMPDIR)/*
rm -f $(OUTDIR)/$(TARGET).rom
rm -f $(OUTDIR)/$(TARGET).cas
.PHONY: all cas clean
include Makefile.deps
|