-
-
Save requeijaum/a002966c51a50e35620f20db6aae2e21 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ -z "$1" ]; then | |
echo "Syntax: $0 cheat.pnach" | |
exit 0 | |
fi | |
if [ ! -r "$1" ]; then | |
echo "File $i doesn't exist or cant be read." | |
exit -1 | |
fi | |
IFS=$'\n' # new-line is the only 'for' separator! | |
for i in $(cat "$1"); do | |
case $i in | |
gametitle=*) | |
# Extract game info | |
title=$(echo $i | sed -ne 's/gametitle=\(.*\) (.*)/\1/p') | |
gameid=$(echo $i | sed -ne 's/.*(\([^-]*\).*\([0-9]\{3\}\)\([0-9]\{2\}\))/\1_\2.\3/p') | |
# Select region | |
case $gameid in | |
*US*) region=NTSC;; | |
SLP*) region=NTSC;; | |
SCPS*) region=NTSC;; | |
PBPX*) region=NTSC;; | |
*ES*) region=PAL;; | |
PBPS*) region=PAL;; | |
*) region=NTSC;; # Dont know, default to NTSC. | |
esac | |
# Print information | |
echo \"$title $region /ID $gameid\" | |
echo "Master Codes" | |
echo "<fill in>" | |
echo | |
;; | |
comment=*) | |
echo "# $(echo $i | tail -c +9 -)" | |
;; | |
*patch=*) # Absorves | |
# patch=1,EE,0018D5B8,word,3C0243A8 | |
addr=$(echo $i | cut -d',' -f3 -) | |
size=$(echo $i | cut -d',' -f4 -) | |
code=$(echo $i | cut -d',' -f5 -) | |
if [ $size == "extended" ]; then # already a raw cheat! output it. | |
echo $addr $code | |
else | |
# select size hex code | |
case $size in | |
word) size=2;; | |
short) size=1;; | |
byte) size=0;; | |
esac | |
if [[ $i == /* ]]; then | |
echo //$size$(echo $addr | sed -ne 's/[0-9]\(.*\)/\1/p') $code | |
else | |
echo $size$(echo $addr | sed -ne 's/[0-9]\(.*\)/\1/p') $code | |
fi | |
fi | |
;; | |
"//"*) | |
echo $i | |
;; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment