From c38ac76ba6a0df757e6d3824ac39041f4324119d Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Fri, 15 Apr 2016 11:43:38 -0700 Subject: [PATCH] ad-hoc building in a build directory --- patch/.gitignore | 7 +------ patch/mm-bq | 27 ++++++++++++++++++--------- patch/oot-widescreen | 19 ++++++++++++++----- patch/patch.lua | 4 ++-- 4 files changed, 35 insertions(+), 22 deletions(-) diff --git a/patch/.gitignore b/patch/.gitignore index d77b3d9..378eac2 100644 --- a/patch/.gitignore +++ b/patch/.gitignore @@ -1,6 +1 @@ -patchme -lips -entrances.asm -crc32.asm -widescreen-either.asm -labels.lua +build diff --git a/patch/mm-bq b/patch/mm-bq index 1eeeae7..551725f 100755 --- a/patch/mm-bq +++ b/patch/mm-bq @@ -10,6 +10,7 @@ sha1=d6133ace5afaa0882cf214cf88daba39e266c078 extracted=../dump/mm-US10-"$sha1" rom=../roms/everything/"Legend of Zelda, The - Majora's Mask (U) [!].z64" lips=../Lua/lib/lips +out=mm-bq.z64 code="0031 V00B3C000" extra="1552 V02EE7040" @@ -23,7 +24,7 @@ ratio() { unc() { [ -e patchme/"$1".Yaz0 ] || return 0 - ../z64yaz0 patchme/"$1".Yaz0 > patchme/"$1" + ../../z64yaz0 patchme/"$1".Yaz0 > patchme/"$1" echo "uncompressed $1" ratio patchme/"$1" patchme/"$1".Yaz0 rm patchme/"$1".Yaz0 @@ -31,26 +32,34 @@ unc() { comp() { [ -e patchme/"$1" ] || return 0 - ../z64yaz0 patchme/"$1" > patchme/"$1".Yaz0 + ../../z64yaz0 patchme/"$1" > patchme/"$1".Yaz0 echo "compressed $1" ratio patchme/"$1" patchme/"$1".Yaz0 rm patchme/"$1" } -[ ! -s ../z64yaz0 ] && cc -O3 ../z64yaz0.c -o ../z64yaz0 +mkdir -p build +cp *.lua build/ +cd build + +[ ! -s ../../z64yaz0 ] && cc -O3 ../../z64yaz0.c -o ../../z64yaz0 if [ $fast -eq 0 ] || [ ! -d patchme ]; then [ -d patchme ] && rm -r patchme - (cd ..; ./z64dump.py -c "$rom") - mv ../"$sha1" patchme + (cd ../../; ./z64dump.py -c "$rom") + mv ../../"$sha1" patchme fi unc "$code" # don't copy entire dir; avoid copying dotfiles (.git) mkdir -p lips -cp "$lips"/* lips -cp "$inject/"{crc32,entrances}.asm . +cp ../"$lips"/* lips + +cp ../"$inject/"{crc32,entrances}.asm . +cp ../extra.asm . +cp ../common.asm . +cp ../code.asm . dd if=/dev/zero of=extra bs=370688 count=1 2>/dev/null @@ -64,6 +73,6 @@ 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 + (cd ../..; ./z64dump.py patch/build/patchme) + dd if=patchme.z64 of="$out" bs=$((1024*1024)) count=32 status=none fi diff --git a/patch/oot-widescreen b/patch/oot-widescreen index 49276b0..48684fb 100755 --- a/patch/oot-widescreen +++ b/patch/oot-widescreen @@ -4,14 +4,23 @@ set -e inject=../Lua/inject rom=../roms/everything/"Legend of Zelda, The - Ocarina of Time - Master Quest (E) (Debug) [f1].z64" lips=../Lua/lib/lips +out=oot-widescreen.z64 -(cd ..; cp "$rom" patch/oot-widescreen.z64) +mkdir -p build +cp *.lua build/ +cd build + +cp ../../"$rom" "$out" # don't copy entire dir; avoid copying dotfiles (.git) mkdir -p lips -cp "$lips"/* lips -cp "$inject/"widescreen-either.asm . +cp ../"$lips"/* lips -luajit patch.lua -o 0 --extra-rom 0x035D0000 --extra-ram 0x80700000 widescreen-inline.asm oot-widescreen.z64 +cp ../"$inject/"widescreen-either.asm . +cp ../widescreen-inline.asm . -(cd ..; ./z64dump.py -f patch/oot-widescreen.z64) +luajit patch.lua -o 0 \ + --extra-rom 0x035D0000 --extra-ram 0x80700000 \ + widescreen-inline.asm "$out" + +(cd ../../; ./z64dump.py -f patch/build/"$out") diff --git a/patch/patch.lua b/patch/patch.lua index c046b9e..f689793 100644 --- a/patch/patch.lua +++ b/patch/patch.lua @@ -34,8 +34,6 @@ local function inject(args) end f:seek('set', pos) - -- TODO: write hex dump format of written bytes - f:write(string.char(b)) end @@ -60,12 +58,14 @@ end local ap = argparse("patch", "patch a binary file with assembly") +-- TODO: option to dump hex or gs codes when no output is given ap:argument("input", "input assembly file") ap:argument("output", "output binary file") ap:option("-o --offset", "offset to pass to lips", "0"):convert(parsenum) ap:option("-i --import", "import state file(s) containing labels"):count("*") ap:option("-e --export", "export state file containing labels") --ap:option("-s --state", "--import and --export to this file") +-- TODO: replace this with a lua table import of associated addresses ap:option("--extra-rom", "dumb stuff"):convert(parsenum) ap:option("--extra-ram", "dumb stuff"):convert(parsenum)