2022-08-18 13:40:41 -04:00
|
|
|
#!/bin/bash
|
2022-08-05 01:59:19 -04:00
|
|
|
|
2022-08-18 13:40:41 -04:00
|
|
|
SNAME="$(dirname $0)"
|
2023-05-05 02:34:07 -04:00
|
|
|
export SHIP_HOME="$HOME/Library/Application Support/com.shipofharkinian.soh"
|
2022-08-18 13:40:41 -04:00
|
|
|
export SNAME
|
|
|
|
export RESPATH="${SNAME%/MacOS*}/Resources"
|
|
|
|
export LIBPATH="${SNAME%/MacOS*}/Frameworks"
|
|
|
|
export DYLD_FALLBACK_LIBRARY_PATH="$LIBPATH"
|
2022-08-05 01:59:19 -04:00
|
|
|
|
2023-09-10 13:20:58 -04:00
|
|
|
remap_hashes ()
|
|
|
|
{
|
2023-09-19 10:30:48 -04:00
|
|
|
# Remap v64 and n64 hashes to their z64 hash equivalent
|
2023-09-10 13:20:58 -04:00
|
|
|
# ZAPD will handle converting the data into z64 format
|
|
|
|
case "$ROMHASH" in
|
|
|
|
a9059b56e761c9034fbe02fe4c24985aaa835dac) # v64
|
|
|
|
ROMHASH=cee6bc3c2a634b41728f2af8da54d9bf8cc14099
|
|
|
|
;;
|
|
|
|
24708102dc504d3f375a37f4ae4e149c167dc515) # n64
|
|
|
|
ROMHASH=cee6bc3c2a634b41728f2af8da54d9bf8cc14099
|
|
|
|
;;
|
|
|
|
580dd0bd1b6d2c51cc20a764eece84dba558964c) # v64
|
|
|
|
ROMHASH=0227d7c0074f2d0ac935631990da8ec5914597b4
|
|
|
|
;;
|
|
|
|
d6342c59007e57c1194661ec6880b2f078403f4e) # n64
|
|
|
|
ROMHASH=0227d7c0074f2d0ac935631990da8ec5914597b4
|
|
|
|
;;
|
2023-10-04 11:05:02 -04:00
|
|
|
d0bdc2eb320668b4ba6893b9aefe4040a73123ff) # v64
|
|
|
|
ROMHASH=328a1f1beba30ce5e178f031662019eb32c5f3b5
|
|
|
|
;;
|
|
|
|
4946ab250f6ac9b32d76b21f309ebb8ebc8103d2) # n64
|
|
|
|
ROMHASH=328a1f1beba30ce5e178f031662019eb32c5f3b5
|
|
|
|
;;
|
2023-09-10 13:20:58 -04:00
|
|
|
663c34f1b2c05a09e5beffe4d0dcd440f7d49dc7) # v64
|
|
|
|
ROMHASH=cfbb98d392e4a9d39da8285d10cbef3974c2f012
|
|
|
|
;;
|
|
|
|
24c73d378b0620a380ce5ef9f2b186c6c157a68b) # n64
|
|
|
|
ROMHASH=cfbb98d392e4a9d39da8285d10cbef3974c2f012
|
|
|
|
;;
|
2023-09-19 10:30:48 -04:00
|
|
|
8ebf2e29313f44f2d49e5b4191971d09919e8e48) # v64
|
|
|
|
ROMHASH=f46239439f59a2a594ef83cf68ef65043b1bffe2
|
|
|
|
;;
|
|
|
|
4264bf7b875737b8fae77d52322a5099d051fc11) # n64
|
|
|
|
ROMHASH=f46239439f59a2a594ef83cf68ef65043b1bffe2
|
|
|
|
;;
|
2023-09-10 13:20:58 -04:00
|
|
|
973bc6fe56010a8d646166a1182a81b4f13b8cf9) # v64
|
|
|
|
ROMHASH=50bebedad9e0f10746a52b07239e47fa6c284d03
|
|
|
|
;;
|
|
|
|
d327752c46edc70ff3668b9514083dbbee08927c) # v64
|
|
|
|
ROMHASH=50bebedad9e0f10746a52b07239e47fa6c284d03
|
|
|
|
;;
|
|
|
|
ecdeb1747560834e079c22243febea7f6f26ba3b) # v64
|
|
|
|
ROMHASH=079b855b943d6ad8bd1eb026c0ed169ecbdac7da
|
|
|
|
;;
|
|
|
|
f19f8662ec7abee29484a272a6fda53e39efe0f1) # n64
|
|
|
|
ROMHASH=079b855b943d6ad8bd1eb026c0ed169ecbdac7da
|
|
|
|
;;
|
|
|
|
ab519ce04a33818ce2c39b3c514a751d807a494a) # v64
|
|
|
|
ROMHASH=cfecfdc58d650e71a200c81f033de4e6d617a9f6
|
|
|
|
;;
|
|
|
|
c19a34f7646305e1755249fca2071e178bd7cd00) # n64
|
|
|
|
ROMHASH=cfecfdc58d650e71a200c81f033de4e6d617a9f6
|
|
|
|
;;
|
|
|
|
25e8ae79ea0839ca5c984473f7460d8040c36f9c) # v64
|
|
|
|
ROMHASH=517bd9714c73cb96c21e7c2ef640d7b55186102f
|
|
|
|
;;
|
|
|
|
166c02770d67fcc3954c443eb400a6a3573d3fc0) # n64
|
|
|
|
ROMHASH=517bd9714c73cb96c21e7c2ef640d7b55186102f
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2023-05-05 02:34:07 -04:00
|
|
|
if [ ! -e "$SHIP_HOME" ]; then mkdir "$SHIP_HOME"; fi
|
2022-10-16 23:07:35 -04:00
|
|
|
|
2023-06-17 13:27:59 -04:00
|
|
|
if [ ! -e "$SHIP_HOME"/mods ]; then
|
|
|
|
mkdir -p "$SHIP_HOME"/mods
|
|
|
|
touch "$SHIP_HOME"/mods/custom_otr_files_go_here.txt
|
|
|
|
fi
|
|
|
|
|
2022-10-16 23:07:35 -04:00
|
|
|
# If either OTR doesn't exist kick off the OTR gen process
|
2023-05-05 02:34:07 -04:00
|
|
|
if [ ! -e "$SHIP_HOME"/oot.otr ] || [ ! -e "$SHIP_HOME"/oot-mq.otr ]; then
|
2022-10-16 23:07:35 -04:00
|
|
|
|
|
|
|
# If no ROMs exist kick off the file selection prompts
|
2023-05-05 02:34:07 -04:00
|
|
|
while [ ! -e "$SHIP_HOME"/*.*64 ] && [ ! -e "$SHIP_HOME"/oot*.otr ]; do
|
2022-10-16 23:07:35 -04:00
|
|
|
|
|
|
|
SHOULD_PROMPT_FOR_ROM=1
|
|
|
|
while [ $SHOULD_PROMPT_FOR_ROM -eq 1 ]; do
|
|
|
|
SHOULD_PROMPT_FOR_ROM=0
|
|
|
|
# Use osascript to prompt the user to chose a file
|
|
|
|
DROPROM=`osascript <<-EOF
|
|
|
|
set romFile to choose file of type {"b64","n64","v64","z64"} with prompt "Please select your ROM:"
|
|
|
|
return POSIX path of romFile
|
|
|
|
EOF`
|
|
|
|
|
|
|
|
# If no rom was selected, the user cancelled, so exit
|
|
|
|
if [[ -z $DROPROM ]] && [[ -z "$UPLOAD_ANOTHER_RESULT" ]]; then
|
|
|
|
echo "No ROM selected. Exiting..."
|
|
|
|
exit 1
|
|
|
|
elif [[ -z $DROPROM ]]; then
|
|
|
|
break;
|
|
|
|
fi
|
|
|
|
|
|
|
|
# If an invalid rom was selected, let the user know and ask to try again
|
|
|
|
ROMHASH="$(shasum "$DROPROM" | awk '{ print $1 }')"
|
2023-09-10 13:20:58 -04:00
|
|
|
|
|
|
|
remap_hashes
|
|
|
|
|
2022-10-16 23:07:35 -04:00
|
|
|
case "$ROMHASH" in
|
|
|
|
cee6bc3c2a634b41728f2af8da54d9bf8cc14099)
|
|
|
|
ROM_TYPE=0;;
|
|
|
|
0227d7c0074f2d0ac935631990da8ec5914597b4)
|
|
|
|
ROM_TYPE=0;;
|
2023-10-04 11:05:02 -04:00
|
|
|
328a1f1beba30ce5e178f031662019eb32c5f3b5)
|
|
|
|
ROM_TYPE=0;;
|
2023-07-12 21:58:43 -04:00
|
|
|
cfbb98d392e4a9d39da8285d10cbef3974c2f012)
|
|
|
|
ROM_TYPE=0;;
|
2023-09-19 10:30:48 -04:00
|
|
|
f46239439f59a2a594ef83cf68ef65043b1bffe2)
|
|
|
|
ROM_TYPE=1;;
|
2022-10-16 23:07:35 -04:00
|
|
|
50bebedad9e0f10746a52b07239e47fa6c284d03)
|
|
|
|
ROM_TYPE=1;;
|
|
|
|
079b855b943d6ad8bd1eb026c0ed169ecbdac7da)
|
|
|
|
ROM_TYPE=1;;
|
2023-07-12 21:58:43 -04:00
|
|
|
cfecfdc58d650e71a200c81f033de4e6d617a9f6)
|
|
|
|
ROM_TYPE=1;;
|
2022-10-16 23:07:35 -04:00
|
|
|
517bd9714c73cb96c21e7c2ef640d7b55186102f)
|
|
|
|
ROM_TYPE=1;;
|
|
|
|
*)
|
|
|
|
TRY_AGAIN_RESULT=`osascript <<-EOF
|
|
|
|
set alertText to "Incompatible ROM hash"
|
|
|
|
set alertMessage to "Incompatible ROM provided, would you like to try again?"
|
|
|
|
return display alert alertText \
|
|
|
|
message alertMessage \
|
|
|
|
as critical \
|
|
|
|
buttons {"Cancel", "Try Again"}
|
|
|
|
EOF`
|
|
|
|
if [[ "$TRY_AGAIN_RESULT" == "button returned:Try Again" ]]; then
|
|
|
|
SHOULD_PROMPT_FOR_ROM=1
|
|
|
|
continue;
|
|
|
|
else
|
|
|
|
echo "No ROM selected. Exiting..."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
esac
|
|
|
|
|
2023-05-05 02:34:07 -04:00
|
|
|
cp "$DROPROM" "$SHIP_HOME"
|
2022-10-16 23:07:35 -04:00
|
|
|
|
|
|
|
# Ask user if they would also like to select the other variant (MQ/Vanilla)
|
|
|
|
if [ $ROM_TYPE -eq 0 ] && [[ -z "$UPLOAD_ANOTHER_RESULT" ]]; then
|
|
|
|
UPLOAD_ANOTHER_RESULT=`osascript <<-EOF
|
|
|
|
set alertText to "Success"
|
|
|
|
set alertMessage to "Would you also like to provide a Master Quest ROM?"
|
|
|
|
return display alert alertText \
|
|
|
|
message alertMessage \
|
|
|
|
buttons {"No", "Yes"}
|
|
|
|
EOF`
|
|
|
|
elif [[ -z "$UPLOAD_ANOTHER_RESULT" ]]; then
|
|
|
|
UPLOAD_ANOTHER_RESULT=`osascript <<-EOF
|
|
|
|
set alertText to "Success"
|
|
|
|
set alertMessage to "Would you also like to provide a Vanilla (Non Master Quest) ROM?"
|
|
|
|
return display alert alertText \
|
|
|
|
message alertMessage \
|
|
|
|
buttons {"No", "Yes"}
|
|
|
|
EOF`
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ "$UPLOAD_ANOTHER_RESULT" == "button returned:Yes" ]]; then
|
|
|
|
UPLOAD_ANOTHER_RESULT="button returned:No"
|
|
|
|
SHOULD_PROMPT_FOR_ROM=1
|
|
|
|
continue;
|
|
|
|
fi
|
|
|
|
break
|
|
|
|
done
|
|
|
|
done
|
|
|
|
|
2023-05-05 02:34:07 -04:00
|
|
|
# At this point we should now have 1 or more valid roms in $SHIP_HOME directory
|
2022-10-16 23:07:35 -04:00
|
|
|
|
|
|
|
# Prepare tmp dir
|
2023-05-05 02:34:07 -04:00
|
|
|
for ROMPATH in "$SHIP_HOME"/*.*64
|
2022-08-18 13:40:41 -04:00
|
|
|
do
|
2022-10-16 23:07:35 -04:00
|
|
|
ASSETDIR="$(mktemp -d /tmp/assets-XXXXX)"
|
|
|
|
export ASSETDIR
|
|
|
|
cp -r "$RESPATH/assets" "$ASSETDIR"
|
|
|
|
mkdir -p "$ASSETDIR"/tmp
|
|
|
|
cp "$ROMPATH" "$ASSETDIR"/tmp/rom.z64
|
|
|
|
cd "$ASSETDIR" || return
|
|
|
|
|
|
|
|
# If an invalid rom was detected, let the user know
|
|
|
|
ROMHASH="$(shasum "$ASSETDIR"/tmp/rom.z64 | awk '{ print $1 }')"
|
2023-09-10 13:20:58 -04:00
|
|
|
|
|
|
|
remap_hashes
|
|
|
|
|
2022-10-16 23:07:35 -04:00
|
|
|
case "$ROMHASH" in
|
|
|
|
cee6bc3c2a634b41728f2af8da54d9bf8cc14099)
|
|
|
|
ROM=GC_NMQ_D
|
|
|
|
OTRNAME="oot.otr";;
|
|
|
|
0227d7c0074f2d0ac935631990da8ec5914597b4)
|
|
|
|
ROM=GC_NMQ_PAL_F
|
|
|
|
OTRNAME="oot.otr";;
|
2023-10-04 11:05:02 -04:00
|
|
|
328a1f1beba30ce5e178f031662019eb32c5f3b5)
|
|
|
|
ROM=N64_PAL_10
|
|
|
|
OTRNAME="oot.otr";;
|
2023-06-05 19:11:22 -04:00
|
|
|
cfbb98d392e4a9d39da8285d10cbef3974c2f012)
|
|
|
|
ROM=N64_PAL_11
|
|
|
|
OTRNAME="oot.otr";;
|
2023-09-19 10:30:48 -04:00
|
|
|
f46239439f59a2a594ef83cf68ef65043b1bffe2)
|
|
|
|
ROM=GC_MQ_PAL_F
|
|
|
|
OTRNAME="oot-mq.otr";;
|
2022-10-16 23:07:35 -04:00
|
|
|
50bebedad9e0f10746a52b07239e47fa6c284d03)
|
|
|
|
ROM=GC_MQ_D
|
|
|
|
OTRNAME="oot-mq.otr";;
|
|
|
|
079b855b943d6ad8bd1eb026c0ed169ecbdac7da)
|
|
|
|
ROM=GC_MQ_D
|
|
|
|
OTRNAME="oot-mq.otr";;
|
2023-07-12 21:58:43 -04:00
|
|
|
cfecfdc58d650e71a200c81f033de4e6d617a9f6)
|
|
|
|
ROM=GC_MQ_D
|
|
|
|
OTRNAME="oot-mq.otr";;
|
2022-10-16 23:07:35 -04:00
|
|
|
517bd9714c73cb96c21e7c2ef640d7b55186102f)
|
|
|
|
ROM=GC_MQ_D
|
|
|
|
OTRNAME="oot-mq.otr";;
|
|
|
|
*)
|
|
|
|
osascript -e 'display notification "One or more invalid ROM provided" with title "Ship Of Harkinian"'
|
|
|
|
rm -r "$ASSETDIR"
|
2023-11-06 17:46:48 -05:00
|
|
|
cd "$SNAME"
|
2022-10-16 23:07:35 -04:00
|
|
|
continue;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# Only generate OTR if we don't have on of this type yet
|
2023-05-05 02:34:07 -04:00
|
|
|
if [ -e "$SHIP_HOME"/"$OTRNAME" ]; then
|
2022-08-18 13:40:41 -04:00
|
|
|
rm -r "$ASSETDIR"
|
2023-11-06 17:46:48 -05:00
|
|
|
cd "$SNAME"
|
2022-10-16 23:07:35 -04:00
|
|
|
continue;
|
2022-09-22 07:30:47 -04:00
|
|
|
fi
|
2022-10-16 23:07:35 -04:00
|
|
|
|
|
|
|
osascript -e 'display notification "Generating OTR..." with title "Ship Of Harkinian"'
|
2023-11-05 12:34:39 -05:00
|
|
|
assets/extractor/ZAPD.out ed -i assets/extractor/xmls/"${ROM}" -b tmp/rom.z64 -fl assets/extractor/filelists -o placeholder -osf placeholder -gsf 1 -rconf assets/extractor/Config_"${ROM}".xml -se OTR --portVer "@CMAKE_PROJECT_VERSION@"
|
2022-10-16 23:07:35 -04:00
|
|
|
if [ -e "$ASSETDIR"/oot.otr ]; then
|
|
|
|
osascript -e 'display notification "OTR successfully generated" with title "Ship Of Harkinian"'
|
2023-05-05 02:34:07 -04:00
|
|
|
cp "$ASSETDIR"/oot.otr "$SHIP_HOME"/"$OTRNAME"
|
2022-08-18 13:40:41 -04:00
|
|
|
rm -r "$ASSETDIR"
|
2023-11-06 17:46:48 -05:00
|
|
|
cd "$SNAME"
|
2022-08-18 13:40:41 -04:00
|
|
|
fi
|
2022-10-16 23:07:35 -04:00
|
|
|
done
|
|
|
|
|
2023-05-05 02:34:07 -04:00
|
|
|
if [ ! -e "$SHIP_HOME"/oot*.otr ]; then
|
2022-10-16 23:07:35 -04:00
|
|
|
osascript -e 'display notification "OTR failed to generate" with title "Ship Of Harkinian"'
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
fi
|
2022-08-18 13:40:41 -04:00
|
|
|
|
2023-11-06 17:46:48 -05:00
|
|
|
cd "$SNAME"
|
|
|
|
|
2023-12-29 18:02:22 -05:00
|
|
|
"$RESPATH"/soh-macos
|
2022-09-22 07:30:47 -04:00
|
|
|
|
2022-08-18 13:40:41 -04:00
|
|
|
exit
|