forked from kervinck/gigatron-rom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
292 lines (246 loc) · 8.69 KB
/
Makefile
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
#-----------------------------------------------------------------------
#
# Makefile for Gigatron ROM and tooling
#
#-----------------------------------------------------------------------
# Latest development version as default target
DEV:=dev.rom
# Emulators open gigatron.rom as their ROM image
gigatron.rom: $(DEV)
ifdef OS # Windows
copy $< $@
else
ln -sf "$<" "$@"
endif
dev: $(DEV)
# Allow application-specific SYS extensions to live in Apps/
export PYTHONPATH:=Apps/Loader:Apps/Racer
export PYTHONDONTWRITEBYTECODE:=please
ifdef OS # Windows
export PYTHONPATH:=$(subst :,;,$(PYTHONPATH))
endif
CFLAGS:=-std=c11 -O3 -Wall
#-----------------------------------------------------------------------
# Development
#-----------------------------------------------------------------------
# Development towards "ROM v5"
dev.rom: Core/* Apps/*/* Makefile interface.json
python Core/dev.py\
gigatronRaw=Apps/Screen/gigatron.rgb\
Snake=Apps/Snake/Snake_v3.gcl\
SYS_Racer_v1.py\
SYS_Loader.py\
zippedRacerHorizon=Apps/Racer/Horizon-256x16.rgb\
Racer=Apps/Racer/Racer_v2.gcl\
Mandelbrot=Apps/Mandelbrot/Mandelbrot_v1.gcl\
Pictures=Apps/Screen/Screen_v1.gcl\
Credits=Apps/Credits/Credits_v3.gcl\
Loader=Apps/Loader/Loader_v3.gcl\
Tetronis=Apps/Tetronis/Tetronis.gt1\
Bricks=Apps/Bricks/Bricks.gt1\
TinyBASIC=Apps/TinyBASIC/TinyBASIC_v3.gcl\
TicTac=Apps/TicTac/TicTac.gcl\
TicTacGtb=Apps/TicTac/TicTac_v2.gtb\
WozMon=Apps/WozMon/WozMon_v2.gcl\
Apple1=Apps/Apple1/Apple1.gt1\
MSBASIC=Apps/MSBASIC/MSBASIC.gt1\
Egg=Apps/Horizon/Horizon.gt1\
Main=Apps/MainMenu/MainMenu.gcl\
Reset=Core/Reset.gcl
run: Docs/gtemu $(DEV)
# Run ROM in reference emulator on console
# Pipe though less(1) to hop from frame to frame with 'n' (next)
# !!! Set terminal width to >225 chars !!!
Docs/gtemu $(DEV) | less -p 'line 0'
export jsEmu=Contrib/PhilThomas/src
runjs: $(DEV)
# Run ROM in javascript emulator in web browser (macOS)
cd "$(jsEmu)" && ln -sf ../../../$(DEV) gigatron.rom
(sleep 1 && open http://127.0.0.1:8000/src) &
cd "$(jsEmu)" && npm start
test: Docs/gtemu $(DEV)
# Check for hSync errors in first ~30 seconds of emulation
Docs/gtemu $(DEV) | head -999999 | grep \~
compiletest: Apps/*/*.gcl
# Test compilation
# (Use 'git diff' afterwards to detect unwanted changes)
for GCL in Apps/*/*.gcl; do Core/compilegcl.py "$${GCL}" `dirname "./$${GCL}"` ; done
@echo "Use 'git diff' to inspect result (no .gt1 file should have changed)"
time: Docs/gtemu $(DEV)
# Run emulation until first sound, typically for benchmarking
Docs/gtemu $(DEV) | grep -m 1 'xout [^0]'
burn: $(DEV)
# Program 27C1024 EEPROM with ROM image
minipro -p 'AT27C1024 @DIP40' -w "$<" -y -s
burn85:
# Program Pluggy McPlugface
# Set to 8 MHz
minipro -p attiny85 -w Utils/BabelFish/BabelFish.ATtiny85_fuses.txt -c config
# ROM image
minipro -p attiny85 -w Utils/BabelFish/BabelFish.ATtiny85.bin -s
#-----------------------------------------------------------------------
# Released ROM versions
#-----------------------------------------------------------------------
# ROM v4 support `TypeC' game controller signals. There are
# many small changes under the hood, but no new applications.
ROMv4.rom: Core/* Apps/*/* Makefile interface.json
python Core/ROMv4.py\
packedParrot=Apps/Pictures/Parrot-160x120.rgb\
packedJupiter=Apps/Pictures/Jupiter-160x120.rgb\
Apps/Racer/SYS_Racer_v1.py\
Apps/Loader/SYS_Loader_v3.py\
Snake=Apps/Snake/Snake_v3.gcl\
zippedRacerHorizon=Apps/Racer/Horizon-256x16.rgb\
Racer=Apps/Racer/Racer_v2.gcl\
Mandelbrot=Apps/Mandelbrot/Mandelbrot_v1.gcl\
Pictures=Apps/Pictures/Pictures_v2.gcl\
Credits=Apps/Credits/Credits_v3.gcl\
Loader=Apps/Loader/Loader_v3.gcl\
Tetronis=Apps/Tetronis/Tetronis_v1.gt1\
Bricks=Apps/Bricks/Bricks_v1.gt1\
TinyBASIC=Apps/TinyBASIC/TinyBASIC_v3.gcl\
TicTac=Apps/TicTac/TicTac_v2.gtb\
WozMon=Apps/WozMon/WozMon_v2.gt1\
Egg=Apps/Apple1/Apple1_v1.gt1\
Main=Apps/MainMenu/MainMenu_v4.gcl\
Reset=Core/Reset_v4.gcl
burnv4: ROMv4.rom
minipro -p 'AT27C1024 @DIP40' -w "$<" -y -s
# ROM v3 integrates BASIC, WozMon, Tetronis, Bricks, TicTacToe
# vPulse modulation (for SAVE in BASIC), sprite acceleration
# Note: ROM builder still directly incudes TicTac_v1.gtb
ROMv3.rom: Core/* Apps/*/* Makefile interface.json
python Core/ROMv3.py\
Apps/Snake/Snake_v2.gcl\
Apps/Racer/Racer_v1.gcl\
Apps/Mandelbrot/Mandelbrot_v1.gcl\
Apps/Pictures/Pictures_v2.gcl\
Apps/Credits/Credits_v2.gcl\
Apps/Loader/Loader_v2.gcl\
Apps/Tetronis/Tetronis_v1.gt1\
Apps/Bricks/Bricks_v1.gt1\
Apps/TinyBASIC/TinyBASIC_v2.gcl\
Apps/WozMon/WozMon_v2.gt1\
Egg=Apps/Sprites/Sprites_v1.gt1\
Main=Apps/MainMenu/MainMenu_v3.gcl\
Core/Reset_v3.gcl
burnv3: ROMv3.rom
minipro -p 'AT27C1024 @DIP40' -w "$<" -y -s
# ROM v2 minor changes only
ROMv2.rom: Core/* Apps/*/* Makefile interface.json
python Core/ROMv2.py\
Apps/Snake/Snake_v2.gcl\
Apps/Racer/Racer_v1.gcl\
Apps/Mandelbrot/Mandelbrot_v1.gcl\
Apps/Pictures/Pictures_v1.gcl\
Apps/Credits/Credits_v1.gcl\
Apps/Loader/Loader_v1.gcl\
Apps/TinyBASIC/TinyBASIC_v1.gcl\
Apps/WozMon/WozMon_v1.gcl\
Apps/MainMenu/Main_v2.gcl\
Core/Reset_v2.gcl
# ROM v1 as shipped with first batches of kits
ROMv1.rom: Core/* Apps/*/* Makefile interface.json
python Core/ROMv1.py\
Apps/Snake/Snake_v1.gcl\
Apps/Racer/Racer_v1.gcl\
Apps/Mandelbrot/Mandelbrot_v1.gcl\
Apps/Pictures/Pictures_v1.gcl\
Apps/Credits/Credits_v1.gcl\
Apps/Loader/Loader_v1.gcl\
Apps/Screen/Screen_v1.gcl\
Apps/MainMenu/Main_v1.gcl\
Core/Reset_v1.gcl
#-----------------------------------------------------------------------
# Experimental and temporary (to be removed)
#-----------------------------------------------------------------------
# Adds vCPU slices on scanlines to get 400 cycles per scanline
ROMv3y.rom: Core/* Apps/*/* Makefile interface.json
python Core/ROMv3y.py\
Apps/Snake/Snake_v2.gcl\
Apps/Racer/Racer_v1.gcl\
Apps/Mandelbrot/Mandelbrot_v1.gcl\
Apps/Pictures/Pictures_v2.gcl\
Apps/Credits/Credits_v2.gcl\
Apps/Loader/Loader_v2.gcl\
Apps/Tetronis/Tetronis_v1.gt1\
Apps/Bricks/Bricks_v1.gt1\
Apps/TinyBASIC/TinyBASIC_v2.gcl\
Apps/WozMon/WozMon_v2.gt1\
Egg=Apps/Sprites/Sprites_v1.gt1\
Main=Apps/MainMenu/MainMenu_v3.gcl\
Core/Reset_v3y.gcl
#-----------------------------------------------------------------------
# Generic rules
#-----------------------------------------------------------------------
%.gt1: %.gcl
Core/compilegcl.py "$<" `dirname "./$@"`
%.gt1x: %.gcl
Core/compilegcl.py -x "$<" `dirname "./$@"`
%.h: %.gt1
# Convert GT1 file into header for including as PROGMEM data
od -t x1 -v < "$<" |\
awk 'BEGIN {print "// Converted from $< by Makefile"}\
{for (i=2; i<=NF; i++) printf "0x%s,\n", $$i}' > "$@"
%.rgb: %.png
# Uses ImageMagick
convert "$<" "$@"
# 64tass assembler
%.obj: %.asm
64tass -b "$<" -o "$@" -L "$*.lst"
od -An -t x1 -v < "$@" |\
awk '{for(i=1;i<=NF;i++)print" #$$" $$i}' |\
fmt -w 80 > "$*.hex"
# as65 assembler (from cc65)
%.obj: %.s
ca65 "$<" -o "$*.o.tmp" -l "$*.lst"
ld65 -t none -o "$*.obj" "$*.o.tmp"
rm -f "$*.o.tmp"
# Hex dump from object file
%.hex: %.obj
od -An -t x1 -v < "$<" |\
awk '{for(i=1;i<=NF;i++)print" #$$" $$i}' |\
fmt -w 80 > "$@"
Utils/BabelFish/tinyfont.h: Utils/BabelFish/tinyfont.py
python "$<" > "$@"
todo:
@git ls-files | sed 's/ /\\ /g' | xargs grep -I -E '(TODO|XXX)'
# Show simplified git log
log:
git log --oneline --decorate --graph --all
# Get updates from GitHub while preserving work in progress
pull:
git stash push
git pull https://github.com/kervinck/gigatron-rom
git stash pop
#-----------------------------------------------------------------------
# C compiler (LCC retargeted for vCPU)
#-----------------------------------------------------------------------
LCCDIR:=Utils/lcc/build
export LCCDIR
LCC:=$(LCCDIR)/lcc
LCCFLAGS:=-ILibs
#LCCFLAGS:=-ILibs -Wf-d -Wa-d
lcc:
mkdir -p "$(LCCDIR)"
mkdir -p "$(LCCDIR)/tst"
cd Utils/lcc && env HOSTFILE=etc/gt1h.c make all gttest
%.o: %.c $(wildcard Libs/*.h)
$(LCC) $(LCCFLAGS) -c "$<" -o "$@"
libSources:=$(wildcard Libs/*/*.c)
libObjects:=$(libSources:.c=.o)
.SECONDARY: # Instructs 'make' not to delete intermeditate .o files
%.gt1: %.o $(libObjects)
$(LCC) $(LCCFLAGS) $^ -o "$@"
ctest: Libs/Example.gt1
cclean:
rm -f Libs/Example.gt1 Libs/*.o Libs/*/*.o
# Moon shot for C compiler: MSCP 1.4 (Marcel's Simple Chess Program)
# Doesn't work yet. Use as guinea pig to help mature our standard C library
mscp: Contrib/kervinck/mscp.gt1
Contrib/kervinck/mscp.o: Contrib/kervinck/mscp.c $(wildcard Libs/*.h)
$(LCC) $(LCCFLAGS) -N -P -A -v -c "$<" -o "$@"
#-----------------------------------------------------------------------
#
#-----------------------------------------------------------------------
# vi: noexpandtab