-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathbuild.sh
executable file
·180 lines (151 loc) · 5.22 KB
/
build.sh
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
#!/bin/bash
rm -rf build
mkdir -p build
if [ $# -eq 0 ]
then
SYSTEMS="MMFS MMFS2"
else
SYSTEMS=$(echo $* | tr '[:lower:]' '[:upper:]')
fi
## Sanity check systems
for system in $SYSTEMS
do
if [ $system != "MMFS" ] && [ $system != "MMFS2" ]
then
echo "Unknown system: $system"
exit
fi
done
VERSION=`grep '#VERSION#' VERSION.asm | cut -d\" -f2`
echo "Building $SYSTEMS version $VERSION"
# Set the BEEBASM executable for the platform
# Let's see if the user already has one on their path
BEEBASM=$(type -path beebasm 2>/dev/null)
if [ "$(uname -s)" == "Darwin" ]; then
BEEBASM=${BEEBASM:-tools/beebasm/beebasm-darwin}
MD5SUM=md5
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
if [ "$(uname -m)" == "x86_64" ]; then
BEEBASM=${BEEBASM:-tools/beebasm/beebasm64}
else
BEEBASM=${BEEBASM:-tools/beebasm/beebasm32}
fi
MD5SUM=md5sum
fi
BEEBASM=${BEEBASM:-tools/beebasm/beebasm.exe}
echo Using $BEEBASM
# Build the two different system:
# MMFS is the original system that uses a BEEB.MMB file
# MMFS2 is the more recent system that uses direct FAT32 access of .ssd/.dsd files
#
for system in $SYSTEMS
do
# Device:
# U is normal User Port VIA based
# T is User Port connected "TurboMMC" interface
# E is Electron Plus One Printer Port connected interface (experimental)
# M is MemoryMapped IO based (typically &FE18, for BeebEm)
# P is Beeb Printer Port connected Interface (experimental)
# C is Master Compact Expansion Port (experimental)
# G is Mega Games Cartridge MKII
# 1 is Pi1MHz
if [ $system == "MMFS2" ]
then
DEVICES="U U2 U3 T T2 T3 E M P C 1"
else
DEVICES="U U2 U3 T T2 T3 E M P C G 1"
fi
for device in $DEVICES
do
build=build/${device}
mkdir -p ${build}
ssd=${build}/$(echo ${system} | tr '[:upper:]' '[:lower:]').ssd
rm -f ${ssd}
# Configure the system/device to be assembled
echo "_DEVICE_ = \""$device"\"" > DEVICE.asm
echo "MACRO SYSTEM_NAME" >> DEVICE.asm
echo " EQUS \"${system}\"" >> DEVICE.asm
echo "ENDMACRO" >> DEVICE.asm
if [ $system == "MMFS2" ]
then
echo "_MM32_ = TRUE" >> DEVICE.asm
echo "_MM32_DEBUG = TRUE" >> DEVICE.asm
echo "_MM32_DDUMP = FALSE" >> DEVICE.asm
else
echo "_MM32_ = FALSE" >> DEVICE.asm
fi
# Create a blank SSD image
tools/mmb_utils/blank_ssd.pl ${ssd}
tools/mmb_utils/title.pl ${ssd} "$system $device $VERSION"
echo
if [ $device == "E" ]
then
filelist="top_E*.asm top_MAMMFS.asm top_MMFS.asm top_ZEMMFS.asm"
elif [ $device == "G" ]
then
filelist="top_MGC*.asm"
elif [ $device == "M" ]
then
filelist="top_MMFS.asm top_MMFSDBG.asm top_SWMMFS.asm top_SWMMFS+.asm top_MAMMFS.asm"
elif [ $device == "P" ]
then
filelist="top_MMFS*.asm top_MAMMFS*.asm top_SWMMFS*.asm top_ZMMFS.asm"
else
filelist="top_*MMFS*.asm"
fi
for top in $filelist
do
name=`echo ${top%.asm} | cut -c5-`
# if [ \
# "${device}/${name}" == "T/SWMMFS" -o \
# "${device}/${name}" == "T/ZMMFS" \
# ]
# then
# echo "Skipping ${device}/$name due to space constraints"
# continue;
# else
echo "Building ${device}/$name..."
# fi
# Assemble the ROM
$BEEBASM -i ${top} -o ${build}/${name} -v >& ${build}/${name}.log
# Check if ROM has been build, otherwise fail early
if [ ! -f ${build}/${name} ]
then
cat ${build}/${name}.log
echo "build failed to create ${device}/${name}"
exit
fi
# Create the .inf file
echo -e "\$."${name}"\t8000\t8000" > ${build}/${name}.inf
# Add into the SSD
tools/mmb_utils/putfile.pl ${ssd} ${build}/${name}
# Delete the .inf file
rm -f ${build}/${name}.inf
# Report end of code
grep "code ends at" ${build}/${name}.log
# Report build checksum
echo " mdsum is "`$MD5SUM <${build}/${name}`
# Add a .rom suffix
mv ${build}/${name} ${build}/${name}.rom
done
# Copy utilities
if [ $system = MMFS ]; then
tools/mmb_utils/putfile.pl ${ssd} utilities/bin/IDTOM
tools/mmb_utils/putfile.pl ${ssd} utilities/bin/IMTOD
else
tools/mmb_utils/putfile.pl ${ssd} utilities/bin/IDTOM2
tools/mmb_utils/putfile.pl ${ssd} utilities/bin/IMTOD2
fi
echo
tools/mmb_utils/info.pl ${ssd}
rm -f DEVICE.asm
done # for device in G U T E M P 1
# Move the files in the build directory to the right system folder
# It would be cleaner to build in the correct directory in the first place
# but ZMMFS sources contain absolute build paths so this is simpler.
mkdir -p build/${system}
for device in $DEVICES
do
mv build/${device} build/${system}
done
done # for system in mmfs mmfs2