mirror of
https://github.com/notwa/mm
synced 2024-11-05 03:39:02 -08:00
71 lines
1.6 KiB
Bash
Executable file
71 lines
1.6 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
set -e
|
|
|
|
fast=0
|
|
[[ "$1" == "fast" ]] && fast=1
|
|
[[ "$1" == "test" ]] && fast=2
|
|
|
|
inject=../Lua/inject
|
|
sha1=d6133ace5afaa0882cf214cf88daba39e266c078
|
|
extracted=../dump/mm-US10-"$sha1"
|
|
rom=../roms/everything/"Legend of Zelda, The - Majora's Mask (U) [!].z64"
|
|
lips=../Lua/lib/lips
|
|
|
|
code="0031 V00B3C000"
|
|
extra="1552 V02EE7040"
|
|
|
|
ratio() {
|
|
len1="$(wc -c < "$1")"
|
|
len2="$(wc -c < "$2")"
|
|
let percent=(len2*100)/len1
|
|
echo "ratio: $percent%"
|
|
}
|
|
|
|
unc() {
|
|
[ -e patchme/"$1".Yaz0 ] || return 0
|
|
../z64yaz0 patchme/"$1".Yaz0 > patchme/"$1"
|
|
echo "uncompressed $1"
|
|
ratio patchme/"$1" patchme/"$1".Yaz0
|
|
rm patchme/"$1".Yaz0
|
|
}
|
|
|
|
comp() {
|
|
[ -e patchme/"$1" ] || return 0
|
|
../z64yaz0 patchme/"$1" > patchme/"$1".Yaz0
|
|
echo "compressed $1"
|
|
ratio patchme/"$1" patchme/"$1".Yaz0
|
|
rm patchme/"$1"
|
|
}
|
|
|
|
#if ! [ -d "$extracted" ]; then
|
|
if [ $fast -eq 0 ] || [ ! -d patchme ]; then
|
|
[ -d patchme ] && rm -r patchme
|
|
(cd ..; ./z64dump.py -c "$rom")
|
|
mv ../"$sha1" patchme
|
|
fi
|
|
#if [ $fast -eq 0 ]; then
|
|
# [ -d patchme ] && rm -r patchme
|
|
# cp -r "$extracted" patchme
|
|
#fi
|
|
|
|
unc "$code"
|
|
|
|
# don't copy entire dir; avoid copying dotfiles (.git)
|
|
mkdir -p lips
|
|
cp "$lips"/* lips
|
|
cp "$inject/"{crc32,entrances}.asm .
|
|
|
|
touch "extra"
|
|
|
|
luajit patch.lua code.asm patchme/"$code" 0
|
|
luajit patch.lua extra.asm extra 0x80780000
|
|
|
|
dd if=extra of=patchme/"$extra" bs=370688 count=1 2>/dev/null
|
|
rm extra
|
|
|
|
if [ $fast -ne 2 ]; then
|
|
comp "$code"
|
|
comp "$extra"
|
|
(cd ..; ./z64dump.py patch/patchme)
|
|
dd if=patchme.z64 of=mm-bq.z64 bs=$((1024*1024)) count=32 status=none
|
|
fi
|