@@ -50,15 +50,20 @@ png2chr() {
50
50
51
51
# build CHR if it doesnt already exist
52
52
53
- if [ " $( find src/chr/* .chr 2> /dev/null | wc -l) " = 0 ]; then
53
+ if [ " $( find src/chr/* .chr 2> /dev/null | wc -l | xargs ) " = 0 ]; then
54
54
echo " building CHR for the first time"
55
55
png2chr
56
56
else
57
57
58
58
# if it does exist check if the PNG has been modified
59
-
60
- pngTimes=$( stat -c " %Y" src/chr/* .png)
61
- scriptTime=$( stat -c " %X" " $0 " )
59
+ if [[ $( uname) == " Darwin" ]]; then
60
+ # mac support
61
+ pngTimes=$( stat -f " %m" src/chr/* .png)
62
+ scriptTime=$( stat -f " %m" " $0 " )
63
+ else
64
+ pngTimes=$( stat -c " %Y" src/chr/* .png)
65
+ scriptTime=$( stat -c " %X" " $0 " )
66
+ fi
62
67
63
68
for pngTime in $pngTimes ; do
64
69
if [ " $pngTime " -gt " $scriptTime " ]; then
@@ -84,11 +89,31 @@ ca65 ${compile_flags[*]} -l tetris.lst -g src/main.asm -o main.o
84
89
ld65 -m tetris.map -Ln tetris.lbl --dbgfile tetris.dbg -o tetris.nes -C src/tetris.nes.cfg main.o header.o
85
90
86
91
# create patch
87
-
88
- ./tools/flips-linux --create clean.nes tetris.nes tetris.bps
92
+ if [[ -f clean.nes ]] && [[ $( uname) == " Darwin" ]]; then
93
+ echo " Unable to create patch on mac"
94
+ elif [[ -f clean.nes ]]; then
95
+ ./tools/flips-linux --create clean.nes tetris.nes tetris.bps
96
+ else
97
+ echo " clean.nes not found. Skipping patch creation."
98
+ fi
89
99
90
100
# show some stats
101
+ if command -v sha1sum & > /dev/null; then
102
+ sha1sum tetris.nes
103
+ elif command -v shasum & > /dev/null; then
104
+ # mac support
105
+ shasum tetris.nes
106
+ else
107
+ echo " sha1sum or shasum not found. Unable to get SHA-1 hash of tetris.nes."
108
+ fi
91
109
92
- sha1sum tetris.nes
93
110
sed -n ' 23,27p' < tetris.map
94
- stat -c %s tetris.bps
111
+
112
+ if [[ -f tetris.bps ]]; then
113
+ # mac support
114
+ if [[ $( uname) == " Darwin" ]]; then
115
+ stat -f %z tetris.bps
116
+ else
117
+ stat -c %s tetris.bps
118
+ fi
119
+ fi
0 commit comments