forked from kervinck/gigatron-rom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
239 lines (200 loc) · 6.74 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
#-----------------------------------------------------------------------
#
# Makefile for Gigatron ROM and tooling
#
#-----------------------------------------------------------------------
# Latest development version as default target
gigatron.rom: dev.rom
ln -sf "$<" "$@"
# Allow application-specific SYS extensions to live in Apps/
export PYTHONPATH=Apps
CFLAGS:=-std=c11 -O3 -Wall
#-----------------------------------------------------------------------
# Development
#-----------------------------------------------------------------------
# Development towards "ROM v4"
dev: dev.rom
dev.rom: Core/* Apps/* Images/* Makefile interface.json
python -B Core/dev.py\
packedParrot=Images/Parrot-160x120.rgb\
packedJupiter=Images/Jupiter-160x120.rgb\
SYS_Racer_v1.py\
SYS_Loader_v2.py\
Snake=Apps/Snake.gcl\
zippedRacerHorizon=Images/RacerHorizon-256x16.rgb\
Racer=Apps/Racer.gcl\
Mandelbrot=Apps/Mandelbrot_v1.gcl\
Pictures=Apps/Pictures_v2.gcl\
Credits=Apps/Credits_v2.gcl\
Loader=Apps/Loader_v2.gcl\
Tetronis=Apps/Tetronis_v1.gt1\
Bricks=Apps/Bricks_v1.gt1\
TinyBASIC=Apps/TinyBASIC.gcl\
TicTac=Apps/TicTac_v1.gtb\
WozMon=Apps/WozMon_v2.gt1\
Egg=Apps/Apple1.gt1x\
Main=Apps/Main.gcl\
Reset=Core/Reset.gcl
run: Docs/gtemu dev.rom
# 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.rom | less -p 'line 0'
export jsEmu=Contrib/PhilThomas/src
runjs:
# Run ROM in javascript emulator in web browser (macOS)
cd "$(jsEmu)" && ln -sf ../../../dev.rom gigatron.rom
(sleep 1 && open http://127.0.0.1:8000/src) &
cd "$(jsEmu)" && npm start
test: Docs/gtemu dev.rom
# Check for hSync errors in first ~30 seconds of emulation
Docs/gtemu dev.rom | 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}" Apps; done
time: Docs/gtemu dev.rom
# Run emulation until first sound, typically for benchmarking
Docs/gtemu dev.rom | grep -m 1 'xout [^0]'
burn: dev.rom
# 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 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/* Images/* Makefile interface.json
python Core/ROMv3.py\
Apps/Snake_v2.gcl\
Apps/Racer_v1.gcl\
Apps/Mandelbrot_v1.gcl\
Apps/Pictures_v2.gcl\
Apps/Credits_v2.gcl\
Apps/Loader_v2.gcl\
Apps/Tetronis_v1.gt1\
Apps/Bricks_v1.gt1\
Apps/TinyBASIC_v2.gcl\
Apps/WozMon_v2.gt1\
Egg=Apps/Sprites_v1.gt1\
Apps/Main_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/* Images/* Makefile interface.json
python Core/ROMv2.py\
Apps/Snake_v2.gcl\
Apps/Racer_v1.gcl\
Apps/Mandelbrot_v1.gcl\
Apps/Pictures_v1.gcl\
Apps/Credits_v1.gcl\
Apps/Loader_v1.gcl\
Apps/TinyBASIC_v1.gcl\
Apps/WozMon_v1.gcl\
Apps/Main_v2.gcl\
Core/Reset_v2.gcl
# ROM v1 as shipped with first batches of kits
ROMv1.rom: Core/* Apps/* Images/* Makefile interface.json
python Core/ROMv1.py\
Apps/Snake_v1.gcl\
Apps/Racer_v1.gcl\
Apps/Mandelbrot_v1.gcl\
Apps/Pictures_v1.gcl\
Apps/Credits_v1.gcl\
Apps/Loader_v1.gcl\
Apps/Screen_v1.gcl\
Apps/Main_v1.gcl\
Core/Reset_v1.gcl
#-----------------------------------------------------------------------
# Experimental and temporary (to be removed)
#-----------------------------------------------------------------------
# Test ROM for v6502 testing
mos: v6502.rom
v6502.rom: Core/* Apps/* Images/* Makefile interface.json
rm -f ROMv3x.rom ROMv3x.asm
python Core/ROMv3x.py\
Main=Apps/Apple1.gcl\
Core/Reset.gcl
mv ROMv3x.rom v6502.rom
mv ROMv3x.asm v6502.asm
open http://127.0.0.1:8000/src
burnmos: v6502.rom
minipro -p 'AT27C1024 @DIP40' -w "$<" -y -s
# Adds vCPU slices on scanlines to get 400 cycles per scanline
ROMv3y.rom: Core/* Apps/* Images/* Makefile interface.json
python Core/ROMv3y.py\
Apps/Snake_v2.gcl\
Apps/Racer_v1.gcl\
Apps/Mandelbrot_v1.gcl\
Apps/Pictures_v2.gcl\
Apps/Credits_v2.gcl\
Apps/Loader_v2.gcl\
Apps/Tetronis_v1.gt1\
Apps/Bricks_v1.gt1\
Apps/TinyBASIC_v2.gcl\
Apps/WozMon_v2.gt1\
Egg=Apps/Sprites_v1.gt1\
Apps/Main_v3.gcl\
Core/Reset_v3y.gcl
#-----------------------------------------------------------------------
# Generic rules
#-----------------------------------------------------------------------
%.gt1: %.gcl
Core/compilegcl.py "$<" `dirname "./$@"`
%.gt1x: %.gt1 %.gcl
# Non-compliant files in .gt1 format (see Docs/GT1-files.txt)
mv "$<" "$@"
%.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 "$<" "$@"
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
#-----------------------------------------------------------------------
# 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