-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathmake.sh
executable file
·56 lines (42 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
55
56
#! /bin/bash
export file_base=Zelda1_Redux
export out_folder=out
export patches_folder=patches
export clean_rom=rom/Zelda1.nes
export patched_rom=$out_folder/$file_base.nes
export asm_file=code/main.asm
export checksum=dab79c84934f9aa5db4e7dad390e5d0c12443fa2
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/Legend\ of\ Zelda\,\ The\ \(USA\).nes ]; then
echo "ROM detected. Verifying name..."; else
export error="ROM name is incorrect. Please, rename the ROM to 'Legend of Zelda, The (USA).nes' for the patching process to begin." && jumpto ERROR; fi
cd rom/ && cp Legend\ of\ Zelda\,\ The\ \(USA\).nes Zelda1.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 'Legend of Zelda, The (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 MMC1 version..."; else
export error="Base ROM checksum is incorrect. Use a Zelda 1 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/asar --no-title-check "$asm_file" "$patched_rom"
bin/flips --create --ips "$clean_rom" "$patched_rom" "$patches_folder/Zelda1_Redux.ips"
jumpto END
ERROR:
echo "ERROR: $error"
END:
rm $clean_rom
sleep 1
exit