-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
103 lines (81 loc) · 2.61 KB
/
Makefile
File metadata and controls
103 lines (81 loc) · 2.61 KB
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
GAME = river-raid
# Source files
CTL = $(GAME).ctl
T2S = $(GAME).t2s
INI = skoolkit.ini
REF = $(GAME).ref
# Generated files
SKOOL = $(GAME).skool
Z80_PRISTINE = $(GAME).pristine.z80
Z80_FIXED = $(GAME).fixed.z80
BIN_PRISTINE = $(GAME).pristine.bin
BIN_NON_FIXED = $(GAME).non-fixed.bin
BIN_FIXED = $(GAME).fixed.bin
ASM_NON_FIXED = $(GAME).non-fixed.asm
ASM_FIXED = $(GAME).asm
# Disassembly configuration
ORG = 16384
SIZE = 47104
PC = 23762
SP = 65344
.PHONY: clean verify test lint lint-order lint-instruction-order lint-lengths
all: $(ASM_FIXED) $(Z80_FIXED) verify html
# Download and convert original TZX to pristine snapshot
$(Z80_PRISTINE): $(T2S)
tap2sna.py @$(T2S) \
--reg pc=$(PC) \
--reg sp=$(SP) \
$(Z80_PRISTINE)
# Extract program binary from pristine snapshot (for verification)
$(BIN_PRISTINE): $(Z80_PRISTINE)
python3 scripts/extract_bytes.py $(Z80_PRISTINE) $(ORG) $(SIZE) $@
# Disassemble pristine snapshot into skool format
$(SKOOL): $(Z80_PRISTINE) $(CTL)
sna2skool.py --hex $(Z80_PRISTINE) --ctl $(CTL) > $@
# Assemble the skool to binary (intermediate step for verification)
$(BIN_NON_FIXED): $(ASM_NON_FIXED)
pasmo --bin $(ASM_NON_FIXED) $@
verify: test lint
test: $(BIN_PRISTINE) $(BIN_NON_FIXED)
cmp $(BIN_PRISTINE) $(BIN_NON_FIXED)
lint: lint-address-order lint-instruction-order lint-lengths
lint-address-order: $(CTL)
python3 scripts/validate_ctl_address_order.py $(CTL)
lint-instruction-order: $(CTL)
python3 scripts/validate_ctl_instruction_order.py $(CTL)
lint-lengths: $(CTL)
python3 scripts/validate_ctl_lengths.py $(CTL)
# Generate fixed assembly source
$(ASM_FIXED): $(SKOOL) $(INI)
@skool2asm.py --create-labels -f 1 $(SKOOL) > $@.tmp 2> $@.stderr; \
if grep -q WARNING $@.stderr; then \
cat $@.stderr >&2; rm -f $@.tmp $@.stderr; exit 1; \
else \
rm -f $@.stderr; mv $@.tmp $@; \
fi
# Generate fixed object file
$(BIN_FIXED): $(ASM_FIXED)
pasmo --bin $< $@
# Generate fixed snapshot
$(Z80_FIXED): $(BIN_FIXED)
bin2sna.py --border 0 --org $(ORG) --start $(PC) --stack $(SP) $< $@
# Generate non-fixed assembly source
$(ASM_NON_FIXED): $(SKOOL) $(INI)
@skool2asm.py --create-labels $(SKOOL) > $@.tmp 2> $@.stderr; \
if grep -q WARNING $@.stderr; then \
cat $@.stderr >&2; rm -f $@.tmp $@.stderr; exit 1; \
else \
rm -f $@.stderr; mv $@.tmp $@; \
fi
# Generate HTML documentation
html: html/.stamp
html/.stamp: $(SKOOL) $(REF) sound.ref graphics.ref levels.ref trivia.ref bugs.ref notes.ref design.ref design/theme.css design/theme.js
skool2html.py -d html -H -a --rebuild-images --rebuild-audio $(SKOOL) $(REF)
touch $@
clean:
rm -rf \
html \
*.asm \
*.bin \
*.skool \
*.z80