Skip to content

Commit

Permalink
Added make-patch.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
nstbayless committed Aug 27, 2017
1 parent 30997eb commit f43c087
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 3 deletions.
14 changes: 12 additions & 2 deletions apply.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash
# applies the .ips patch to base.nes, generating working.nes
# Run with -f flag to replace existing working.nes

_force=false
flips="./flips/flips.exe"
Expand All @@ -19,7 +21,8 @@ else
then
if [ "$_force" = false ]
then
>&2 echo "working.nes already exists. Rerun with -f flag to force overwriting working.nes"
>&2 echo "Error: working.nes already exists."
>&2 echo "Rerun with -f flag to force overwriting working.nes"
exit 1;
else
echo "Replacing existing working.nes"
Expand Down Expand Up @@ -49,6 +52,13 @@ else

chmod u+x $flips

chmod u+wr working.nes

$flips --apply patch.ips working.nes
exit $?
err=$?

chmod a-x working.nes
chmod u+wr working.nes

exit $err
fi
15 changes: 14 additions & 1 deletion hooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,18 @@ cd $_rdir
# make sure base.nes and working.nes exist:
if [ ! -f ./base.nes ]
then
echo "Base ROM (base.nes) is not found!"
>&2 echo "Base ROM (base.nes) is not found! Aborting commit."
exit 1;
fi

if [ ! -f ./base.nes ]
then
>&2 echo "Modified ROM (working.nes) is not found! Aborting commit."
>&2 echo "(Did you ever generate working.nes with apply.sh?)"
exit 2;
fi

# generate patch
./make-patch.sh

exit $?
30 changes: 30 additions & 0 deletions make-patch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
# creates a patch based on the difference between base.rom and working.rom

# find flips patcher:
flips="./flips/flips.exe"

if [ "$op" = "Linux" ]
then
flips="./flips/flips-linux"
fi

if [ ! -f $flips ]
then
>&2 echo "flips not found; do you have the flips/ folder?"
exit 2;
fi

echo "Generating patch.ips..."

chmod u+w patch.ips

rm patch.ips

$flips --create --ips base.nes working.nes patch.ips
err=$?

chmod u+r patch.ips
chmod a-wx patch.ips

exit $?
3 changes: 3 additions & 0 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ else
then
echo "Warning: working.nes but no base.nes file; you will not be able to generate patches."
echo "(Perhaps you should delete working.nes and copy in a new base.nes?)"
else
echo "No changes made to base.nes or working.nes"
echo "(If you intended to apply the patch now, then run ./apply.sh)"
fi
fi

Expand Down

0 comments on commit f43c087

Please sign in to comment.