-
Notifications
You must be signed in to change notification settings - Fork 6
/
mkv8.sh
executable file
·60 lines (52 loc) · 1.25 KB
/
mkv8.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
#!/bin/bash
# IGNORE=';VVIEW;VREADKEY;VCHKBOX;'
IGNORE=';;'
if [[ "$(uname)" == "Darwin" ]] ; then
DARWIN=yes
else
unset DARWIN
fi
function filesize () {
if [[ ${DARWIN} ]] ; then
stat -f '%z' "${1}" 2>/dev/null || echo 0
else
stat --format '%s' "${1}" 2>/dev/null || echo 0
fi
}
function assemble () {
[[ ! -d BIN ]] && mkdir -p BIN
local n="${1##*/}"
n="${n%.*}"
local o=$(echo ${n} | tr "[:lower:]" "[:upper:]" )
if [[ "${IGNORE/${n}}" != "${IGNORE}" ]] ; then
echo "${n}, ignored"
return 0
fi
if [[ ! -f "BIN/${o}.COM" ]] ; then
local z=$(filesize "../../BIN/${o}.COM")
else
local z=$(filesize "BIN/${o}.COM")
fi
nasm -ISOURCE/ SOURCE/${n}.ASM -fbin -O9 -o BIN/${o}.COM || {
echo "error assembling ${n}.ASM"
return 1
}
[[ ! -e BIN/${o}.COM ]] && {
echo "missing BIN/${o}.COM"
return 1
}
local x=$(filesize "BIN/${o}.COM")
[[ ${z} -eq ${x} ]] || echo "${n}, ${z} --> ${x}, ${o}"
return 0
}
if [[ "${*}" == '' ]] ; then
for i in SOURCE/*.ASM ; do
[[ "${i}" == "SOURCE/DEMOPARS.ASM" ]] && continue
assemble "${i}" || exit 1
done
else
while [[ "${*}" != '' ]] ; do
assemble "${1}" || exit 1
shift
done
fi