-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhighScores.bash
366 lines (349 loc) · 10.6 KB
/
highScores.bash
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
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
#!/bin/bash
# Allow tactig ussage
mkdir -p ~/.wii
echo "ab01b9d8e1622b08afbad84dbfc2a55d" > ~/.wii/sd-key
echo "216712e6aa1f689f95c5a22324dc6a98" > ~/.wii/sd-iv
echo "0e65378199be4517ab06ec22451a5793" > ~/.wii/md5-blanker
xxd -r -p ~/.wii/sd-key ~/.wii/sd-key
xxd -r -p ~/.wii/sd-iv ~/.wii/sd-iv
xxd -r -p ~/.wii/md5-blanker ~/.wii/md5-blanker
# Exits program if first argument is empty
if [ -z "$1" ]; then
echo bash highScores.bash FILE
echo FILE should be: Sports2.dat OR data.bin
exit 1
# Exits program if file does not exist.
elif [ ! -f "$1" ]; then
echo "$1: No such file"
exit 2
elif [ "${1: -3}" == "bin" ]; then
tachtig "$1"
hex=$(xxd -p -c 1000000 00010000525a5445/Sports2.dat)
else
hex=$(xxd -p -c 1000000 $1)
fi
# Colors
DARKGRAY='\033[1;30m'
RED='\033[0;31m'
LIGHTRED='\033[1;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
PURPLE='\033[0;35m'
LIGHTPURPLE='\033[1;35m'
CYAN='\033[0;36m'
WHITE='\033[1;37m'
SET='\033[0m'
echo -e "${RED}Wii ${BLUE}Sports ${PURPLE}Resort ${GREEN}Records${SET}"
echo -e "${GREEN}Wii Records${SET}"
twos() { x=$((16#$1)); [ "$x" -gt 32767 ] && ((x=x-65536)); printf "%+d " $x; }
secs() { printf "%d:%02d" $(($1/60)) $(($1%60));}
toDec() { printf "%d.%01d" $((16#$1/$2)) $((16#$1%$2));}
toDec2() { printf "%d.%02d" $((16#$1/$2)) $((16#$1%$2));}
doc() { x=$((16#$1)); printf "%d" $(($x*2));}
hexToAscii() {
input=$1
x=""
for i in 2 6 10 14 18 22 26 30 34
do
if [ "${input:$i:2}" == "20" ]; then
x+=" "
elif [ "${input:$i:2}" == "00" ]; then
x+=""
else
x+=$(echo ${input:$i:2} | xxd -r -p)
fi
done
names+=($x)
}
hexToAscii4() {
input=$1
x=""
for i in 2 6 10 14 18 22 26 30 34
do
if [ "${input:$i:2}" == "20" ]; then
x+=" "
elif [ "${input:$i:2}" == "00" ]; then
x+=""
else
x+=$(echo ${input:$i:2} | xxd -r -p)
fi
done
if [ "${x}" == "" ]; then
echo "x"
else
echo $x
fi
}
hexToAscii2() {
input=$1
x=""
for i in 2 6 10 14 18 22 26 30 34
do
if [ "${input:$i:2}" == "20" ]; then
x+=" "
elif [ "${input:$i:2}" == "00" ]; then
x+=" "
else
x+=$(echo ${input:$i:2} | xxd -r -p)
fi
done
echo $x
}
toUpper() {
echo ${1^^}
}
hexToBin() {
x=`toUpper $1`
echo "obase=2; ibase=16; $x" | bc
}
hexToBinToCount() {
BIN=`hexToBin $1`
z=$((0))
for (( i=0; i<${#BIN}; i++ )); do
if [ "${BIN:$i:1}" == "1" ]; then
z=$((z+1))
fi
done
echo ${z}
}
declare -a startOfNames=(`doc ffe` `doc 1014` `doc 102a` `doc 1040` `doc 1056` `doc 106c` `doc 1406` `doc 141c` `doc 1432` `doc 180e` `doc 1c16` `doc 201e` `doc 2426` `doc 282e` `doc 2c36` `doc 2c4c` `doc 2c62` `doc 303e` `doc 3446` `doc 345c` `doc 3472` `doc 3c40` `doc 3c56` `doc 3c6c` `doc 3c82` `doc 3c98` `doc 3cae` `doc 3cc4` `doc 3cda` `doc 3d1c` `doc 4048` `doc 4074` `doc 40a0` `doc 408a` `doc 40b6` `doc 40cc` `doc 40f8` `doc 410e` `doc 40e2` `doc 4124` `doc 4466` `doc 447c` `doc 4492` `doc 4492` `doc 44a8` `doc 44be` `doc 44d4` `doc 44ea` `doc 4500` `doc 4516` `doc 486e`)
names=()
# Read first five characters in the name $1
for x in "${startOfNames[@]}"; do
hexToAscii ${hex:${x}:20}
done
# printf(“\033[0;31m”); //Set the text to the color red
# printf(“Hello\n”); //Display Hello in red
# printf(“\033[0m”); //Resets the text to default color
# echo $((0x${hex:6572:4}))
#doc cd6
printf 'Power Crusing: %s %s %s %s %s %s\n' `toDec ${hex:6572:4} 10` `toDec ${hex:6580:4} 10` `toDec ${hex:6588:4} 10` `toDec ${hex:6596:4} 10` `toDec ${hex:6604:4} 10` `toDec ${hex:6612:4} 10`
printf 'Archery: %d %d %d\n' 0x${hex:8636:4} 0x${hex:8644:4} 0x${hex:8652:4}
printf 'Frisbee Dog: %d\n' 0x${hex:10700:4}
printf '3 Point Contest: %s\n' `toDec ${hex:12764:4} 10`
printf 'Bowling: %d %d %d\n' 0x${hex:14828:4} 0x${hex:16892:4} 0x${hex:18956:4}
printf 'Canoeing: %s %s %s\n' `toDec2 ${hex:21020:4} 100` `toDec2 ${hex:21028:4} 100` `toDec2 ${hex:21032:4} 100`
printf 'Return Ping Pong: %d\n' 0x${hex:23084:4}
printf 'Wakeboarding: %d %d %d\n' 0x${hex:25148:4} 0x${hex:25156:4} 0x${hex:25164:4}
printf 'Golf: '
nn=29276
for bb in {1..10}
do
if [[ "${hex:$((nn-4)):1}" == "0" ]]; then
printf "x "
else
twos ${hex:nn:4};
fi
nn=$((nn+8))
done
printf '\n'
printf 'Frisbee Golf: '
z=31340
for aa in {1..10}
do
if [[ "${hex:$((z-4)):1}" == "0" ]]; then
printf "x "
else
twos ${hex:z:4};
fi
z=$((z+8))
done
printf '\n'
printf 'Cycling: '
ll=33403
for z in {1..9}
do
c1=${hex:ll:5}
c1h=$((16#${c1}))
#Code by Aaron Feleke
c1s=${c1h:0:3}
c1ms=${c1h:3:2}
if [[ "$z" == "7" ]]; then
printf '\nCycling (3a,3b,6): '
fi
if [ "${hex:$((ll-3)):1}" == "0" ]; then
printf "x, "
else
printf '%d %s.%02d, ' 0x${hex:$((ll-2)):2} `secs ${c1s}` ${c1ms}
fi
ll=$((ll+8))
done
echo
printf 'Skydiving: %d\n' 0x${hex:35468:4}
echo
echo -e "${GREEN}Wii Record Holders${SET}"
a=`doc ffe`
b=`doc 1014`
c=`doc 102a`
d=`doc 1040`
e=`doc 1056`
f=`doc 106c`
printf 'Power Crusing: %s %s %s %s %s %s\n' `hexToAscii4 ${hex:${a}:20}` `hexToAscii4 ${hex:${b}:20}` `hexToAscii4 ${hex:${c}:20}` `hexToAscii4 ${hex:${d}:20}` `hexToAscii4 ${hex:${e}:20}` `hexToAscii4 ${hex:${f}:20}`
a=`doc 1406`
b=`doc 141c`
c=`doc 1432`
printf 'Archery: %s %s %s\n' `hexToAscii4 ${hex:${a}:20}` `hexToAscii4 ${hex:${b}:20}` `hexToAscii4 ${hex:${c}:20}`
a=`doc 180e`
printf 'Frisbee Dog: %s\n' `hexToAscii4 ${hex:${a}:20}`
a=`doc 1c16`
printf '3 Point Contest: %s\n' `hexToAscii4 ${hex:${a}:20}`
a=`doc 201e`
b=`doc 2426`
c=`doc 282e`
printf 'Bowling: %s %s %s\n' `hexToAscii4 ${hex:${a}:20}` `hexToAscii4 ${hex:${b}:20}` `hexToAscii4 ${hex:${c}:20}`
a=`doc 2c36`
b=`doc 2c4c`
c=`doc 2c62`
printf 'Canoeing: %s %s %s\n' `hexToAscii4 ${hex:${a}:20}` `hexToAscii4 ${hex:${b}:20}` `hexToAscii4 ${hex:${c}:20}`
a=`doc 303e`
printf 'Return Ping Pong: %s\n' `hexToAscii4 ${hex:${a}:20}`
a=`doc 3446`
b=`doc 345c`
c=`doc 3472`
printf 'Wakeboarding: %s %s %s\n' `hexToAscii4 ${hex:${a}:20}` `hexToAscii4 ${hex:${b}:20}` `hexToAscii4 ${hex:${c}:20}`
a=`doc 3c40`
b=`doc 3c56`
c=`doc 3c6c`
d=`doc 3c82`
e=`doc 3c98`
f=`doc 3cae`
g=`doc 3cae`
printf 'Golf: %s %s %s %s %s %s %s\n' `hexToAscii4 ${hex:${a}:20}` `hexToAscii4 ${hex:${b}:20}` `hexToAscii4 ${hex:${c}:20}` `hexToAscii4 ${hex:${d}:20}` `hexToAscii4 ${hex:${e}:20}` `hexToAscii4 ${hex:${f}:20}` `hexToAscii4 ${hex:${g}:20}`
a=`doc 3cc4`
b=`doc 3cda`
c=`doc 3d1c`
printf 'Golf (3a,3b,6): %s %s %s\n' `hexToAscii4 ${hex:${a}:20}` `hexToAscii4 ${hex:${b}:20}` `hexToAscii4 ${hex:${c}:20}`
a=`doc 4048`
b=`doc 4074`
c=`doc 408a`
d=`doc 40a0`
e=`doc 40b6`
f=`doc 40cc`
g=`doc 40e2`
printf 'Frisbee Golf: %s %s %s %s %s %s %s\n' `hexToAscii4 ${hex:${a}:20}` `hexToAscii4 ${hex:${b}:20}` `hexToAscii4 ${hex:${c}:20}` `hexToAscii4 ${hex:${d}:20}` `hexToAscii4 ${hex:${e}:20}` `hexToAscii4 ${hex:${f}:20}` `hexToAscii4 ${hex:${g}:20}`
a=`doc 40f8`
b=`doc 410e`
c=`doc 4124`
printf 'Frisbee Golf (3a,3b,6): %s %s %s\n' `hexToAscii4 ${hex:${a}:20}` `hexToAscii4 ${hex:${b}:20}` `hexToAscii4 ${hex:${c}:20}`
a=`doc 4466`
b=`doc 447c`
c=`doc 4492`
d=`doc 44a8`
e=`doc 44be`
f=`doc 44d4`
printf 'Cycling: %s %s %s %s %s %s\n' `hexToAscii4 ${hex:${a}:20}` `hexToAscii4 ${hex:${b}:20}` `hexToAscii4 ${hex:${c}:20}` `hexToAscii4 ${hex:${d}:20}` `hexToAscii4 ${hex:${e}:20}` `hexToAscii4 ${hex:${f}:20}`
a=`doc 44ea`
b=`doc 4500`
c=`doc 4516`
printf 'Cycling (3a,3b,6): %s %s %s\n' `hexToAscii4 ${hex:${a}:20}` `hexToAscii4 ${hex:${b}:20}` `hexToAscii4 ${hex:${c}:20}`
a=`doc 486e`
printf 'Skydiving: %s\n' `hexToAscii4 ${hex:${a}:20}`
echo
echo -e "${GREEN}Most Wii Records${SET}"
(IFS=$'\n'; sort <<< "${names[*]}") | uniq -c
echo
offset=0
echo -e "${RED}Personal ${PURPLE}Records${SET}"
for i in {1..12}
do
i=$((offset+`doc 82c0`))
name=`hexToAscii2 ${hex:i:30}`
if [ -z "$name" ]; then
break
fi
echo -e "${GREEN}`hexToAscii2 ${hex:i:30}`${SET}"
i=$((`doc 8a6e`+offset))
printf 'Power Crusing: %s %s %s %s %s %s\n' `toDec ${hex:i:4} 10` `toDec ${hex:$((i+8)):4} 10` `toDec ${hex:$((i+16)):4} 10` `toDec ${hex:$((i+24)):4} 10` `toDec ${hex:$((i+32)):4} 10` `toDec ${hex:$((i+40)):4} 10`
i=$((`doc 8a96`+offset))
printf 'Archery: %d %d %d\n' 0x${hex:i:4} 0x${hex:$((i+8)):4} 0x${hex:$((i+16)):4}
i=$((`doc 8abe`+offset))
printf 'Frisbee Dog: %d\n' 0x${hex:i:4}
i=$((`doc 8ae6`+offset))
printf '3 Point Contest: %s\n' `toDec ${hex:i:4} 10`
printf 'Bowling: %d %d %d\n' 0x${hex:$((`doc 8b0e`+offset)):4} 0x${hex:$((`doc 8b36`+offset)):4} 0x${hex:$((`doc 8b5e`+offset)):4}
i=$((`doc 8b86`+offset))
printf 'Canoeing: %s %s %s\n' `toDec2 ${hex:i:4} 100` `toDec2 ${hex:$((i+8)):4} 100` `toDec2 ${hex:$((i+16)):4} 100`
printf 'Canoeing Target Distance: %s %s %s\n' `toDec2 ${hex:$((i+24)):4} 100` `toDec2 ${hex:$((i+32)):4} 100` `toDec2 ${hex:$((i+40)):4} 100`
printf 'Return Table Tennis: %d\n' 0x${hex:$((offset+`doc 8bae`)):4}
i=$((`doc 8bd6`+offset))
printf 'Wakeboarding: %d %d %d\n' 0x${hex:i:4} 0x${hex:$((i+8)):4} 0x${hex:$((i+16)):4}
printf 'Golf: '
nn=$((`doc 8c26`+offset))
for bb in {1..10}
do
if [[ "${hex:$((nn-4)):1}" == "0" ]]; then
printf "x "
else
twos ${hex:nn:4};
fi
nn=$((nn+8))
done
printf '\n'
printf 'Frisbee Golf: '
z=$((`doc 8c4e`+offset))
for aa in {1..10}
do
if [[ "${hex:$((z-4)):1}" == "0" ]]; then
printf "x "
else
twos ${hex:z:4};
fi
z=$((z+8))
done
printf '\n'
printf 'Cycling: '
ll=$((`doc 8c75`+offset))
ll=$((ll+1))
for z in {1..9}
do
c1=${hex:ll:5}
c1h=$((16#${c1}))
c1s=${c1h:0:3}
c1ms=${c1h:3:2}
if [[ "$z" == "7" ]]; then
printf '\nCycling (3a,3b,6): '
fi
if [ "${hex:$((ll-3)):1}" == "0" ]; then
printf "x, "
else
printf '%d %s.%02d, ' 0x${hex:$((ll-2)):2} `secs ${c1s}` ${c1ms}
fi
ll=$((ll+8))
done
echo
i=$((`doc 8c9e`+offset))
printf 'Skydiving: %d\n' 0x${hex:i:4}
printf 'Island Flyover in 5 minutes (I-Points, Baloons): %d %d\n' 0x${hex:$((offset+`doc 8bfe`)):4} 0x${hex:$((offset+`doc 8c02`)):4}
a=`doc 8f88`
b=`doc 8fc8`
c=`doc 9008`
printf 'Island Flyover White Baloons (Day, Evening, Night) %s/372 %s/340 %s/209\n' `hexToBinToCount ${hex:$((offset+${a})):94}` `hexToBinToCount ${hex:$((offset+${b})):86}` `hexToBinToCount ${hex:$((offset+${c})):54}`
POINTS=${hex:$((offset+`doc 8f38`)):160}
total=$((0))
day=$((0))
evening=$((0))
night=$((0))
for (( i=0; i<${#POINTS}; i++ )); do
point=${POINTS:$i:1}
if [ $((point)) -gt 0 ]; then
total=$((total+1))
fi
if [ $((point)) -ge 4 ]; then
night=$((night+1))
point=$((point-4))
fi
if [ $((point)) -ge 2 ]; then
evening=$((evening+1))
point=$((point-2))
fi
if [ $((point)) -ge 1 ]; then
day=$((day+1))
point=$((point-1))
fi
done
printf "Island Flyover I-Points (Total, Day, Evening, Night) %d %d %d %d\n" $total $day $evening $night
interval=`doc df4`
offset=$((offset+interval))
echo
done