-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmake.sh
executable file
·54 lines (41 loc) · 1.63 KB
/
make.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
#! /bin/bash
export file_base=Zelda2-Redux
export out_folder=out
export patches_folder=patches
export clean_rom=rom/Zelda2.nes
export patched_rom=$out_folder/$file_base.nes
export asm_file=code/main.asm
export checksum=353489a57f24a429572e76bd455bc51d821f7036
function jumpto
{
label=$1
cmd=$(sed -n "/$label:/{:a;n;p;ba};" $0 | grep -v ':$')
eval "$cmd"
exit
}
start=${1:-"start"}
jumpto $start
start:
if [ -e rom/Zelda\ II\ -\ The\ Adventure\ of\ Link\ \(USA\).nes ]; then
echo "ROM detected. Verifying name..."; else
export error="ROM name is incorrect. Please, rename the ROM to 'Zelda\ II\ -\ The\ Adventure\ of\ Link\ \(USA\).nes' for the patching process to begin." && jumpto ERROR; fi
cd rom/ && cp Zelda\ II\ -\ The\ Adventure\ of\ Link\ \(USA\).nes Zelda2.nes && cd ..
test ! -d "$out_folder" && mkdir "$out_folder"
test -f "$patched_rom" && rm "$patched_rom"
if [ -f "$clean_rom" ]; then
echo "Base ROM detected with proper name. Checking SHA-1..."; else
export error="Base ROM was not found. Place the 'Zelda\ II\ -\ The\ Adventure\ of\ Link\ \(USA\).nes' ROM inside the 'rom' folder." && jumpto ERROR; fi
export sha1=$(sha1sum "$clean_rom" | awk '{ print $1 }')
if [ "$sha1" == "$checksum" ]; then
echo "Base ROM SHA-1 checksum verified. Patching..."; else
export error="Base ROM checksum is incorrect. Use a Zelda 2 ROM with the proper SHA-1 checksum for patching." && jumpto ERROR; fi
cp "$clean_rom" "$patched_rom"
bin/xkas -o "$patched_rom" "$asm_file"
bin/flips --create --ips "$clean_rom" "$patched_rom" "$patches_folder/$file_base.ips"
jumpto END
ERROR:
echo "ERROR: $error"
END:
rm $clean_rom
sleep 1
exit