2013-06-15 19:33:43 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2016-08-17 21:26:08 +02:00
|
|
|
PATCHIMAGE_VERSION=7.2.0-devel
|
|
|
|
PATCHIMAGE_RELEASE=2016/08/17+
|
2016-05-16 14:53:30 +02:00
|
|
|
|
2016-08-05 20:52:12 +02:00
|
|
|
[[ -e ${HOME}/.patchimage.rc ]] && source "${HOME}"/.patchimage.rc
|
2016-07-03 20:07:55 +02:00
|
|
|
|
2013-06-15 19:33:43 +02:00
|
|
|
setup_tools () {
|
|
|
|
|
|
|
|
if [[ $(uname -m) == "x86_64" ]]; then
|
2013-08-06 23:53:43 +02:00
|
|
|
SUFFIX=64
|
2016-07-03 20:07:55 +02:00
|
|
|
else SUFFIX=32
|
2013-08-06 23:53:43 +02:00
|
|
|
fi
|
|
|
|
|
2016-08-05 20:52:12 +02:00
|
|
|
export WIT="${PATCHIMAGE_TOOLS_DIR}"/wit."${SUFFIX}"
|
|
|
|
export PPF="${PATCHIMAGE_TOOLS_DIR}"/applyppf3."${SUFFIX}"
|
|
|
|
export IPS="${PATCHIMAGE_TOOLS_DIR}"/uips."${SUFFIX}"
|
|
|
|
export UNP="${PATCHIMAGE_TOOLS_DIR}"/unp
|
|
|
|
export SZS="${PATCHIMAGE_TOOLS_DIR}"/wszst."${SUFFIX}"
|
|
|
|
export XD3="${PATCHIMAGE_TOOLS_DIR}"/xdelta3."${SUFFIX}"
|
|
|
|
export GDOWN="${PATCHIMAGE_TOOLS_DIR}"/gdown.pl
|
|
|
|
export CTRTOOL="${PATCHIMAGE_TOOLS_DIR}"/ctrtool."${SUFFIX}"
|
|
|
|
export FDSTOOL="${PATCHIMAGE_TOOLS_DIR}"/3dstool."${SUFFIX}"
|
2014-05-16 21:38:20 +02:00
|
|
|
|
2013-06-15 19:33:43 +02:00
|
|
|
}
|
|
|
|
|
2016-08-17 21:41:44 +02:00
|
|
|
ALL_NSMB=(NSMB{1..12} NSMB{13..27})
|
|
|
|
ALL_PKMN=(PKMN{1..9})
|
|
|
|
|
2016-08-06 20:10:38 +02:00
|
|
|
ask_game () {
|
|
|
|
|
2016-08-18 10:11:05 +02:00
|
|
|
echo "${SUPPORTED_GAMES_ALL}
|
2016-08-06 20:10:38 +02:00
|
|
|
|
2016-08-06 21:19:21 +02:00
|
|
|
Enter ID or Short Name for the Game you want to build (multiple separated by space):
|
2013-06-20 21:03:40 +02:00
|
|
|
"
|
2013-06-15 19:33:43 +02:00
|
|
|
|
2016-08-05 20:52:12 +02:00
|
|
|
read -r GAME
|
2013-06-15 19:33:43 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-06-20 18:15:08 +02:00
|
|
|
download_soundtrack () {
|
|
|
|
|
2016-08-05 20:52:12 +02:00
|
|
|
if [[ ${SOUNDTRACK_LINK} && ! -f ${PATCHIMAGE_AUDIO_DIR}/${SOUNDTRACK_ZIP} ]]; then
|
2016-08-06 21:34:01 +02:00
|
|
|
wget -q --no-check-certificate "${SOUNDTRACK_LINK}" \
|
2016-08-05 20:52:12 +02:00
|
|
|
-O "${PATCHIMAGE_AUDIO_DIR}"/"${SOUNDTRACK_ZIP}" || exit 57
|
2014-05-11 21:57:19 +02:00
|
|
|
echo -e "\n >>> soundtrack saved to\n >>> ${PATCHIMAGE_AUDIO_DIR}/${SOUNDTRACK_ZIP}"
|
|
|
|
else
|
2014-05-16 20:30:36 +02:00
|
|
|
echo -e "no soundtrack for ${GAMENAME} available."
|
2013-06-20 18:15:08 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-07-01 22:23:32 +02:00
|
|
|
download_banner () {
|
|
|
|
|
2013-07-07 22:36:04 +02:00
|
|
|
if [[ ${PATCHIMAGE_BANNER_DOWNLOAD} == "TRUE" ]]; then
|
2013-07-01 22:23:32 +02:00
|
|
|
if [[ ${CUSTOM_BANNER} ]]; then
|
2016-08-05 20:52:12 +02:00
|
|
|
if [[ ! -f "${PATCHIMAGE_RIIVOLUTION_DIR}"/"${GAMEID}"-custom-banner.bnr ]]; then
|
2016-08-06 21:34:01 +02:00
|
|
|
wget -q --no-check-certificate "${CUSTOM_BANNER}" \
|
2016-08-06 21:36:50 +02:00
|
|
|
-O "${PATCHIMAGE_RIIVOLUTION_DIR}"/"${GAMEID}"-custom-banner.bnr__tmp || \
|
|
|
|
rm -f "${PATCHIMAGE_RIIVOLUTION_DIR}"/"${GAMEID}"-custom-banner.bnr__tmp
|
2016-08-06 21:35:38 +02:00
|
|
|
fi
|
|
|
|
|
2016-08-06 21:36:50 +02:00
|
|
|
if [[ -f "${PATCHIMAGE_RIIVOLUTION_DIR}"/"${GAMEID}"-custom-banner.bnr__tmp ]]; then
|
2016-08-05 20:52:12 +02:00
|
|
|
mv "${PATCHIMAGE_RIIVOLUTION_DIR}"/"${GAMEID}"-custom-banner.bnr__tmp \
|
|
|
|
"${PATCHIMAGE_RIIVOLUTION_DIR}"/"${GAMEID}"-custom-banner.bnr
|
2016-08-06 21:35:38 +02:00
|
|
|
BANNER="${PATCHIMAGE_RIIVOLUTION_DIR}"/"${GAMEID}"-custom-banner.bnr
|
2016-08-06 21:37:42 +02:00
|
|
|
else echo "*** >> could not download custom banner"
|
2013-07-07 22:36:04 +02:00
|
|
|
fi
|
2013-07-01 22:23:32 +02:00
|
|
|
else
|
2013-10-12 10:37:29 +02:00
|
|
|
echo "*** >> no custom banner available"
|
2013-07-01 22:23:32 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-07-07 08:49:52 +02:00
|
|
|
nsmbw_version () {
|
|
|
|
|
|
|
|
if [[ -f ${WORKDIR}/files/COPYDATE_LAST_2009-10-03_232911 ]]; then
|
|
|
|
VERSION=EURv1
|
2016-08-05 20:52:12 +02:00
|
|
|
export REG_LETTER=P
|
2013-07-07 08:49:52 +02:00
|
|
|
elif [[ -f ${WORKDIR}/files/COPYDATE_LAST_2010-01-05_152101 ]]; then
|
|
|
|
VERSION=EURv2
|
2016-08-05 20:52:12 +02:00
|
|
|
export REG_LETTER=P
|
2013-07-07 08:49:52 +02:00
|
|
|
elif [[ -f ${WORKDIR}/files/COPYDATE_LAST_2009-10-03_232303 ]]; then
|
|
|
|
VERSION=USAv1
|
2016-08-05 20:52:12 +02:00
|
|
|
export REG_LETTER=E
|
2013-07-07 08:49:52 +02:00
|
|
|
elif [[ -f ${WORKDIR}/files/COPYDATE_LAST_2010-01-05_143554 ]]; then
|
|
|
|
VERSION=USAv2
|
2016-08-05 20:52:12 +02:00
|
|
|
export REG_LETTER=E
|
2013-07-07 08:49:52 +02:00
|
|
|
elif [[ -f ${WORKDIR}/files/COPYDATE_LAST_2009-10-03_231655 ]]; then
|
|
|
|
VERSION=JPNv1
|
2016-08-05 20:52:12 +02:00
|
|
|
export REG_LETTER=J
|
2013-07-07 08:49:52 +02:00
|
|
|
elif [[ ! ${VERSION} ]]; then
|
|
|
|
echo -e "please specify your games version using --version={EURv1,EURv2,USAv1,USAv2,JPNv1}"
|
2013-10-12 10:37:29 +02:00
|
|
|
exit 27
|
2013-07-07 08:49:52 +02:00
|
|
|
fi
|
2013-10-12 10:37:29 +02:00
|
|
|
echo "*** >> status: ${VERSION}"
|
2013-07-07 08:49:52 +02:00
|
|
|
}
|
|
|
|
|
2013-07-01 22:23:32 +02:00
|
|
|
apply_banner () {
|
|
|
|
|
2013-07-02 20:49:15 +02:00
|
|
|
if [[ ${BANNER} != "" ]]; then
|
|
|
|
if [[ -e ${BANNER} ]]; then
|
|
|
|
cp "${BANNER}" "${BANNER_LOCATION}"
|
|
|
|
else
|
|
|
|
echo "specified banner ${BANNER} does not exist, not modifying"
|
|
|
|
fi
|
2013-07-01 22:23:32 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-10-12 10:37:29 +02:00
|
|
|
check_directories () {
|
|
|
|
|
2016-08-05 20:52:12 +02:00
|
|
|
if [[ ! -d ${PATCHIMAGE_RIIVOLUTION_DIR} && -w $(dirname "${PATCHIMAGE_RIIVOLUTION_DIR}") ]]; then
|
|
|
|
mkdir -p "${PATCHIMAGE_RIIVOLUTION_DIR}" || PATCHIMAGE_RIIVOLUTION_DIR="${HOME}"
|
|
|
|
fi
|
2013-10-12 10:37:29 +02:00
|
|
|
|
2016-08-05 20:52:12 +02:00
|
|
|
[[ ! -w ${PATCHIMAGE_RIIVOLUTION_DIR} ]] && PATCHIMAGE_RIIVOLUTION_DIR="${HOME}"
|
2016-08-03 21:15:35 +02:00
|
|
|
|
2016-08-05 20:52:12 +02:00
|
|
|
if [[ ! -d ${PATCHIMAGE_WBFS_DIR} && -w $(dirname "${PATCHIMAGE_WBFS_DIR}") ]]; then
|
|
|
|
mkdir -p "${PATCHIMAGE_WBFS_DIR}" || PATCHIMAGE_WBFS_DIR="${HOME}"
|
|
|
|
fi
|
2013-10-12 10:37:29 +02:00
|
|
|
|
2016-08-05 20:52:12 +02:00
|
|
|
[[ ! -w "${PATCHIMAGE_WBFS_DIR}" ]] && PATCHIMAGE_WBFS_DIR="${HOME}"
|
2016-08-03 21:15:35 +02:00
|
|
|
|
2016-08-05 20:52:12 +02:00
|
|
|
if [[ ! -d ${PATCHIMAGE_GAME_DIR} && -w $(dirname "${PATCHIMAGE_GAME_DIR}") ]]; then
|
|
|
|
mkdir -p "${PATCHIMAGE_GAME_DIR}" || PATCHIMAGE_GAME_DIR="${HOME}"
|
|
|
|
fi
|
2013-10-12 10:37:29 +02:00
|
|
|
|
2016-08-05 20:52:12 +02:00
|
|
|
[[ ! -w ${PATCHIMAGE_GAME_DIR} ]] && PATCHIMAGE_GAME_DIR="${HOME}"
|
2016-08-03 21:15:35 +02:00
|
|
|
|
2016-08-05 20:52:12 +02:00
|
|
|
if [[ ! -d ${PATCHIMAGE_3DS_DIR} && -w $(dirname "${PATCHIMAGE_3DS_DIR}") ]]; then
|
|
|
|
mkdir -p "${PATCHIMAGE_3DS_DIR}" || PATCHIMAGE_3DS_DIR="${HOME}"
|
|
|
|
fi
|
2013-10-12 10:37:29 +02:00
|
|
|
|
2016-08-05 20:52:12 +02:00
|
|
|
[[ ! -w ${PATCHIMAGE_3DS_DIR} ]] && PATCHIMAGE_3DS_DIR="${HOME}"
|
2016-08-03 21:15:35 +02:00
|
|
|
|
2016-08-05 20:52:12 +02:00
|
|
|
if [[ ! -d ${PATCHIMAGE_ROM_DIR} && -w $(dirname "${PATCHIMAGE_ROM_DIR}") ]]; then
|
|
|
|
mkdir -p "${PATCHIMAGE_ROM_DIR}" || PATCHIMAGE_ROM_DIR="${HOME}"
|
|
|
|
fi
|
2014-05-13 17:49:00 +02:00
|
|
|
|
2016-08-05 20:52:12 +02:00
|
|
|
[[ ! -w ${PATCHIMAGE_ROM_DIR} ]] && PATCHIMAGE_ROM_DIR="${HOME}"
|
2016-08-03 21:15:35 +02:00
|
|
|
|
2016-08-05 20:52:12 +02:00
|
|
|
if [[ ! -d ${PATCHIMAGE_AUDIO_DIR} && -w $(dirname "${PATCHIMAGE_AUDIO_DIR}") ]]; then
|
|
|
|
mkdir -p "${PATCHIMAGE_AUDIO_DIR}" || PATCHIMAGE_AUDIO_DIR="${HOME}"
|
|
|
|
fi
|
2016-08-02 22:22:48 +02:00
|
|
|
|
2016-08-05 20:52:12 +02:00
|
|
|
[[ ! -w ${PATCHIMAGE_AUDIO_DIR} ]] && PATCHIMAGE_AUDIO_DIR="${HOME}"
|
2016-08-03 21:15:35 +02:00
|
|
|
|
2016-08-05 20:52:12 +02:00
|
|
|
if [[ ! -d ${PATCHIMAGE_COVER_DIR} && -w $(dirname "${PATCHIMAGE_COVER_DIR}") ]]; then
|
|
|
|
mkdir -p "${PATCHIMAGE_COVER_DIR}" || PATCHIMAGE_COVER_DIR="${HOME}"
|
|
|
|
fi
|
2013-10-12 10:37:29 +02:00
|
|
|
|
2016-08-05 20:52:12 +02:00
|
|
|
[[ ! -w ${PATCHIMAGE_COVER_DIR} ]] && PATCHIMAGE_COVER_DIR="${HOME}"
|
2016-08-03 21:15:35 +02:00
|
|
|
|
2016-08-02 22:22:48 +02:00
|
|
|
}
|
2013-10-12 10:37:29 +02:00
|
|
|
|
2014-05-15 20:54:19 +02:00
|
|
|
|
2016-08-05 15:57:18 +02:00
|
|
|
check_input_image () {
|
2014-05-11 19:26:58 +02:00
|
|
|
|
|
|
|
x=0
|
|
|
|
if [[ ! ${IMAGE} ]]; then
|
2016-08-06 21:08:16 +02:00
|
|
|
WBFS0=$(find . -maxdepth 1 -name "${WBFS_MASK}".wbfs)
|
|
|
|
WBFS1=$(find "${PATCHIMAGE_WBFS_DIR}" -name "${WBFS_MASK}".wbfs)
|
|
|
|
ISO0=$(find . -maxdepth 1 -name "${WBFS_MASK}".iso)
|
|
|
|
ISO1=$(find "${PATCHIMAGE_WBFS_DIR}" -name "${WBFS_MASK}".iso)
|
|
|
|
|
|
|
|
if [[ -f ${WBFS0} ]]; then
|
2014-05-11 19:26:58 +02:00
|
|
|
x=1
|
2016-08-06 21:08:16 +02:00
|
|
|
IMAGE=${WBFS0}
|
|
|
|
elif [[ -f ${ISO0} ]]; then
|
2014-05-11 19:26:58 +02:00
|
|
|
x=2
|
2016-08-06 21:08:16 +02:00
|
|
|
IMAGE=${ISO0}
|
|
|
|
elif [[ -f ${WBFS1} ]]; then
|
2014-05-11 19:26:58 +02:00
|
|
|
x=3
|
2016-08-06 21:08:16 +02:00
|
|
|
IMAGE=${WBFS1}
|
|
|
|
elif [[ -f ${ISO1} ]]; then
|
2014-05-11 19:26:58 +02:00
|
|
|
x=4
|
2016-08-06 21:08:16 +02:00
|
|
|
IMAGE=${ISO1}
|
2014-05-11 19:26:58 +02:00
|
|
|
else
|
|
|
|
echo -e "please specify image to use with --iso=<path>"
|
|
|
|
exit 15
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
echo "*** >> status: ${x}"
|
|
|
|
|
2016-08-06 21:08:16 +02:00
|
|
|
IMAGE=$(readlink -m "${IMAGE}")
|
|
|
|
|
2014-05-11 19:26:58 +02:00
|
|
|
}
|
|
|
|
|
2016-08-02 22:22:48 +02:00
|
|
|
check_input_rom () {
|
|
|
|
|
|
|
|
x=5
|
2016-08-06 19:46:07 +02:00
|
|
|
if [[ ! ${ROM} ]]; then
|
2016-08-06 21:08:16 +02:00
|
|
|
ROM0=$(find . -maxdepth 1 -name "${ROM_MASK}")
|
|
|
|
ROM1=$(find "${PATCHIMAGE_3DS_DIR}" -name "${ROM_MASK}")
|
|
|
|
|
|
|
|
if [[ -f ${ROM0} ]]; then
|
2016-08-02 22:22:48 +02:00
|
|
|
x=6
|
2016-08-06 21:08:16 +02:00
|
|
|
ROM=${ROM0}
|
|
|
|
elif [[ -f ${ROM1} ]]; then
|
|
|
|
x=7
|
|
|
|
ROM=${ROM1}
|
2016-08-02 22:22:48 +02:00
|
|
|
else
|
2016-08-06 21:08:16 +02:00
|
|
|
if [[ ! ${HANS_MULTI_SOURCE} ]]; then
|
|
|
|
echo -e "error: could not find suitable ROM, specify using --rom"
|
|
|
|
exit 15
|
2016-08-06 20:54:48 +02:00
|
|
|
fi
|
2016-08-02 22:22:48 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
echo "*** >> status: ${x}"
|
2016-08-06 21:08:16 +02:00
|
|
|
|
|
|
|
ROM=$(readlink -m "${ROM}")
|
2016-08-02 22:22:48 +02:00
|
|
|
}
|
|
|
|
|
2015-07-12 19:45:44 +02:00
|
|
|
show_nsmb_db () {
|
2015-07-11 19:58:10 +02:00
|
|
|
|
2015-07-12 19:59:08 +02:00
|
|
|
ID1=${1:0:3}
|
|
|
|
ID2=${1:4:2}
|
2016-08-05 20:52:12 +02:00
|
|
|
gawk -F : "/^${ID1}\*${ID2}/"'{print $2}' \
|
2016-08-04 20:28:09 +02:00
|
|
|
< "${PATCHIMAGE_DATABASE_DIR}"/nsmbw.db || echo "** Unknown **"
|
2015-07-11 19:58:10 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-05-11 21:57:19 +02:00
|
|
|
show_mkwiimm_db () {
|
|
|
|
|
|
|
|
ID=${1:4:2}
|
2016-08-05 20:52:12 +02:00
|
|
|
[[ ${ID} == [0-9][0-9] ]] && \
|
|
|
|
gawk -F : "/^${ID}/"'{print $2}' \
|
|
|
|
< "${PATCHIMAGE_DATABASE_DIR}"/mkwiimm.db \
|
|
|
|
|| echo "** Unknown **"
|
2014-05-11 21:57:19 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ask_input_image_mkwiimm () {
|
|
|
|
|
2015-04-11 21:11:59 +02:00
|
|
|
echo "Choose Mario Kart Wii Image to modify
|
2014-05-11 21:57:19 +02:00
|
|
|
|
|
|
|
ALL patch all images"
|
|
|
|
|
2016-08-05 20:52:12 +02:00
|
|
|
for image in "${PWD}"/RMC???.{iso,wbfs} "${PATCHIMAGE_WBFS_DIR}"/RMC???.{iso,wbfs}; do
|
|
|
|
[[ -f ${image} ]] && echo " ${image##*/} $(show_mkwiimm_db "${image##*/}")"
|
2014-05-11 21:57:19 +02:00
|
|
|
done
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-07-12 19:45:44 +02:00
|
|
|
ask_input_image_nsmb () {
|
2015-07-11 19:58:10 +02:00
|
|
|
|
|
|
|
echo "Choose New Super Mario Bros. Wii Image to modify
|
|
|
|
|
|
|
|
ALL patch all images"
|
|
|
|
|
2016-08-05 20:52:12 +02:00
|
|
|
for image in "${PWD}"/SMN???.{iso,wbfs} \
|
|
|
|
"${PWD}"/SLF???.{iso,wbfs} \
|
2016-08-07 21:26:23 +02:00
|
|
|
"${PWD}"/SLB???.{iso,wbfs} \
|
2016-08-05 20:52:12 +02:00
|
|
|
"${PWD}"/SMM???.{iso,wbfs} \
|
|
|
|
"${PWD}"/SMV???.{iso,wbfs} \
|
|
|
|
"${PWD}"/MRR???.{iso,wbfs} \
|
|
|
|
"${PATCHIMAGE_WBFS_DIR}"/SMN???.{iso,wbfs} \
|
|
|
|
"${PATCHIMAGE_WBFS_DIR}"/SLF???.{iso,wbfs} \
|
2016-08-07 21:26:23 +02:00
|
|
|
"${PATCHIMAGE_WBFS_DIR}"/SLB???.{iso,wbfs} \
|
2016-08-05 20:52:12 +02:00
|
|
|
"${PATCHIMAGE_WBFS_DIR}"/SMM???.{iso,wbfs} \
|
|
|
|
"${PATCHIMAGE_WBFS_DIR}"/SMV???.{iso,wbfs} \
|
|
|
|
"${PATCHIMAGE_WBFS_DIR}"/MRR???.{iso,wbfs}; do
|
|
|
|
[[ -f ${image} ]] && echo " ${image##*/} $(show_nsmb_db "${image##*/}")"
|
2015-07-11 19:58:10 +02:00
|
|
|
done
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-05-13 18:57:58 +02:00
|
|
|
show_titles_db () {
|
|
|
|
|
|
|
|
ID=${1/.*}
|
2016-08-05 20:52:12 +02:00
|
|
|
gawk -F : "/^${ID}/"'{print $2}' \
|
|
|
|
< "${PATCHIMAGE_DATABASE_DIR}"/titles.db \
|
|
|
|
|| echo "** Unknown **"
|
2014-05-13 18:57:58 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-05-13 20:11:13 +02:00
|
|
|
check_wfc () {
|
|
|
|
|
|
|
|
ID=${1/.*}
|
2016-08-05 20:52:12 +02:00
|
|
|
if grep -q "${ID}" "${PATCHIMAGE_DATABASE_DIR}"/wfc.db; then
|
2014-05-13 20:11:13 +02:00
|
|
|
echo TRUE
|
|
|
|
else
|
|
|
|
echo FALSE
|
|
|
|
fi
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-05-13 17:49:00 +02:00
|
|
|
ask_input_image_wiimmfi () {
|
|
|
|
|
|
|
|
echo "Choose Wii Game Image to wiimmfi"
|
|
|
|
|
2016-08-05 20:52:12 +02:00
|
|
|
for image in "${PWD}"/*.{iso,wbfs} \
|
|
|
|
"${PATCHIMAGE_WBFS_DIR}"/*.{iso,wbfs}; do
|
|
|
|
if [[ -e ${image} && ! ${image} == "*/RMC*" && $(check_wfc "${image##*/}") == TRUE ]]; then
|
|
|
|
echo " ${image##*/} $(show_titles_db "${image##*/}")"
|
2014-05-13 17:49:00 +02:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-08-06 21:34:01 +02:00
|
|
|
unpack () {
|
|
|
|
|
|
|
|
if [[ ${UNP_EXTRA_ARGS} ]]; then
|
|
|
|
${UNP} "${1}" -- ${UNP_EXTRA_ARGS} >/dev/null || exit 63
|
|
|
|
else ${UNP} "${1}" >/dev/null || exit 63
|
|
|
|
fi
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-08-07 19:17:31 +02:00
|
|
|
download_riivolution_patch () {
|
|
|
|
|
|
|
|
x=4
|
|
|
|
case ${DOWNLOAD_LINK} in
|
|
|
|
*docs.google* | *drive.google* )
|
|
|
|
x=5
|
|
|
|
echo "*** >> downloading"
|
|
|
|
${GDOWN} "${DOWNLOAD_LINK}" \
|
2016-08-07 20:46:31 +02:00
|
|
|
"${PATCHIMAGE_RIIVOLUTION_DIR}/${RIIVOLUTION_ZIP}"__tmp >/dev/null || \
|
|
|
|
( echo -e "\nDownload failed!" && exit 57 )
|
2016-08-07 19:17:31 +02:00
|
|
|
mv "${PATCHIMAGE_RIIVOLUTION_DIR}/${RIIVOLUTION_ZIP}"__tmp \
|
|
|
|
"${PATCHIMAGE_RIIVOLUTION_DIR}/${RIIVOLUTION_ZIP}"
|
|
|
|
echo "*** >> unpacking"
|
|
|
|
unpack "${PATCHIMAGE_RIIVOLUTION_DIR}/${RIIVOLUTION_ZIP}"
|
|
|
|
;;
|
|
|
|
|
|
|
|
*mega.nz* )
|
|
|
|
x=6
|
|
|
|
echo "can not download from Mega, download manually from:
|
|
|
|
|
|
|
|
${DOWNLOAD_LINK}
|
|
|
|
"
|
2016-08-07 19:34:47 +02:00
|
|
|
exit 21
|
2016-08-07 19:17:31 +02:00
|
|
|
;;
|
|
|
|
|
|
|
|
*medafire* )
|
|
|
|
x=6
|
|
|
|
echo "can not download from Mediafire, download manually from:
|
|
|
|
|
|
|
|
${DOWNLOAD_LINK}
|
|
|
|
"
|
2016-08-07 19:34:47 +02:00
|
|
|
exit 21
|
2016-08-07 19:17:31 +02:00
|
|
|
;;
|
|
|
|
|
|
|
|
*romhacking* )
|
|
|
|
x=6
|
|
|
|
echo "can not download from Romhacking, download manually from:
|
|
|
|
|
|
|
|
${DOWNLOAD_LINK}
|
|
|
|
"
|
|
|
|
|
2016-08-07 19:34:47 +02:00
|
|
|
exit 21
|
2016-08-07 19:17:31 +02:00
|
|
|
;;
|
|
|
|
|
|
|
|
"" )
|
|
|
|
echo "no download link for ${GAMENAME} available."
|
|
|
|
exit 21
|
|
|
|
;;
|
|
|
|
|
|
|
|
* )
|
|
|
|
x=5
|
|
|
|
echo "*** >> downloading"
|
|
|
|
wget -q --no-check-certificate "${DOWNLOAD_LINK}" \
|
2016-08-07 20:46:31 +02:00
|
|
|
-O "${PATCHIMAGE_RIIVOLUTION_DIR}/${RIIVOLUTION_ZIP}"__tmp || \
|
|
|
|
( echo -e "\nDownload failed!" && exit 57 )
|
2016-08-07 19:17:31 +02:00
|
|
|
mv "${PATCHIMAGE_RIIVOLUTION_DIR}/${RIIVOLUTION_ZIP}"__tmp \
|
|
|
|
"${PATCHIMAGE_RIIVOLUTION_DIR}/${RIIVOLUTION_ZIP}"
|
|
|
|
echo "*** >> unpacking"
|
|
|
|
unpack "${PATCHIMAGE_RIIVOLUTION_DIR}/${RIIVOLUTION_ZIP}"
|
|
|
|
;;
|
2016-08-07 19:18:06 +02:00
|
|
|
esac
|
2016-08-07 19:17:31 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-06-15 19:33:43 +02:00
|
|
|
check_riivolution_patch () {
|
|
|
|
|
2013-10-12 10:37:29 +02:00
|
|
|
x=0
|
2013-08-06 22:52:36 +02:00
|
|
|
if [[ ! -d ${RIIVOLUTION_DIR} ]]; then
|
2013-10-12 10:37:29 +02:00
|
|
|
x=1
|
2016-08-06 21:34:01 +02:00
|
|
|
if [[ -f "${PWD}/${RIIVOLUTION_ZIP}" ]]; then
|
2013-10-12 10:37:29 +02:00
|
|
|
echo "*** >> unpacking"
|
|
|
|
x=2
|
2016-08-06 21:34:01 +02:00
|
|
|
unpack "${PWD}/${RIIVOLUTION_ZIP}"
|
2013-10-12 10:37:29 +02:00
|
|
|
elif [[ -f "${PATCHIMAGE_RIIVOLUTION_DIR}/${RIIVOLUTION_ZIP}" ]]; then
|
|
|
|
echo "*** >> unpacking"
|
|
|
|
x=3
|
2016-08-06 21:34:01 +02:00
|
|
|
unpack "${PATCHIMAGE_RIIVOLUTION_DIR}/${RIIVOLUTION_ZIP}"
|
2013-08-06 22:52:36 +02:00
|
|
|
elif [[ ${PATCHIMAGE_RIIVOLUTION_DOWNLOAD} == "TRUE" ]]; then
|
2016-08-07 19:17:31 +02:00
|
|
|
download_riivolution_patch
|
2013-07-03 16:44:13 +02:00
|
|
|
else
|
2016-08-13 19:03:16 +02:00
|
|
|
if [[ ${1} == --nofail ]]; then
|
|
|
|
echo -e "no zip archive found. Skipping to bare patch file detection"
|
|
|
|
else
|
|
|
|
echo -e "please specify zip/rar to use with --riivolution=<path>"
|
|
|
|
exit 21
|
|
|
|
fi
|
2013-06-20 21:31:41 +02:00
|
|
|
fi
|
2013-06-15 19:33:43 +02:00
|
|
|
fi
|
2013-10-12 10:37:29 +02:00
|
|
|
echo "*** >> status: ${x}"
|
2013-06-15 19:33:43 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-05-11 20:43:49 +02:00
|
|
|
download_covers () {
|
|
|
|
|
2016-08-05 20:52:12 +02:00
|
|
|
alt=$(echo "${1}" | sed s/./E/4)
|
2016-08-03 22:20:17 +02:00
|
|
|
|
2014-05-11 20:43:49 +02:00
|
|
|
for path in cover cover3D coverfull disc disccustom; do
|
2016-08-05 20:52:12 +02:00
|
|
|
if [[ ! -f "${PATCHIMAGE_COVER_DIR}"/"${1}"_"${path}".png ]]; then
|
2016-08-06 21:34:01 +02:00
|
|
|
wget -q -O "${PATCHIMAGE_COVER_DIR}"/"${1}"_"${path}".png \
|
|
|
|
http://art.gametdb.com/wii/"${path}"/EN/"${1}".png \
|
2016-08-05 20:52:12 +02:00
|
|
|
|| rm "${PATCHIMAGE_COVER_DIR}"/"${1}"_"${path}".png
|
|
|
|
|
|
|
|
if [[ ! -f "${PATCHIMAGE_COVER_DIR}"/"${1}"_"${path}".png ]]; then
|
2016-08-06 21:34:01 +02:00
|
|
|
wget -q -O "${PATCHIMAGE_COVER_DIR}"/"${1}"_"${path}".png \
|
|
|
|
http://art.gametdb.com/wii/"${path}"/US/"${alt}".png \
|
2016-08-05 20:52:12 +02:00
|
|
|
|| rm "${PATCHIMAGE_COVER_DIR}"/"${1}"_"${path}".png
|
2016-08-03 22:20:17 +02:00
|
|
|
fi
|
|
|
|
|
2016-08-05 20:52:12 +02:00
|
|
|
[[ ! -f "${PATCHIMAGE_COVER_DIR}"/"${1}"_"${path}".png ]] && \
|
2016-08-03 22:20:17 +02:00
|
|
|
echo "Cover (${path}) does not exist for gameid ${1}."
|
|
|
|
fi
|
|
|
|
|
2014-05-11 20:43:49 +02:00
|
|
|
done
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-07-26 23:16:49 +02:00
|
|
|
unpack_3dsrom () {
|
|
|
|
|
|
|
|
${CTRTOOL} -p --romfs=romfs.bin "${1}" &>/dev/null
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
unpack_3dsromfs () {
|
|
|
|
|
|
|
|
${CTRTOOL} -t romfs --romfsdir=romfs "${1}" &>/dev/null
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
repack_3dsromfs () {
|
|
|
|
|
|
|
|
${FDSTOOL} -ctf romfs "${2}" --romfs-dir "${1}" &>/dev/null
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-06-15 19:33:43 +02:00
|
|
|
optparse () {
|
|
|
|
|
|
|
|
xcount=0
|
|
|
|
pcount=$#
|
|
|
|
|
|
|
|
while [[ $xcount -lt $pcount ]]; do
|
2016-07-26 23:16:49 +02:00
|
|
|
case ${1} in
|
2013-06-15 19:33:43 +02:00
|
|
|
|
2016-08-05 20:52:12 +02:00
|
|
|
--iso=* )
|
|
|
|
ISO_PATH="${1/*=}"
|
2013-06-15 19:33:43 +02:00
|
|
|
|
2016-08-05 16:02:10 +02:00
|
|
|
if [[ -f "${ISO_PATH}" ]]; then
|
|
|
|
IMAGE="${ISO_PATH}"
|
2013-06-15 19:33:43 +02:00
|
|
|
else
|
|
|
|
echo -e "ISO not found"
|
2013-10-12 10:37:29 +02:00
|
|
|
exit 15
|
2013-06-15 19:33:43 +02:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
|
2016-08-05 20:52:12 +02:00
|
|
|
--rom=* )
|
|
|
|
ROM_PATH="${1/*=}"
|
2013-06-22 19:15:29 +02:00
|
|
|
|
2016-08-05 16:02:10 +02:00
|
|
|
if [[ -f "${ROM_PATH}" ]]; then
|
2016-08-06 19:46:07 +02:00
|
|
|
ROM="${ROM_PATH}"
|
2013-06-22 19:15:29 +02:00
|
|
|
else
|
|
|
|
echo -e "ROM not found"
|
2013-10-12 10:37:29 +02:00
|
|
|
exit 15
|
2013-06-22 19:15:29 +02:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
|
2016-08-05 20:52:12 +02:00
|
|
|
--riivolution=* )
|
|
|
|
RIIVOLUTION="${1/*=}"
|
2016-08-07 11:25:49 +02:00
|
|
|
if [[ -f "${RIIVOLUTION}" ]]; then
|
2016-08-05 20:52:12 +02:00
|
|
|
"${UNP}" "${RIIVOLUTION}" >/dev/null
|
2013-06-15 19:33:43 +02:00
|
|
|
else
|
|
|
|
echo -e "Riivolution patch ${RIIVOLUTION} not found."
|
2013-10-12 10:37:29 +02:00
|
|
|
exit 21
|
2013-06-15 19:33:43 +02:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
|
2016-08-05 20:52:12 +02:00
|
|
|
--patch=* )
|
|
|
|
PATCH="${1/*=}"
|
2016-08-07 11:25:49 +02:00
|
|
|
if [[ -f "${PATCH}" ]]; then
|
|
|
|
PATCH="${PATCH}"
|
2013-06-22 19:15:29 +02:00
|
|
|
else
|
2016-08-07 11:25:49 +02:00
|
|
|
echo -e "IPS/PPF patch ${PATCH} not found."
|
2013-10-12 10:37:29 +02:00
|
|
|
exit 21
|
2013-06-22 19:15:29 +02:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
|
2016-08-05 20:52:12 +02:00
|
|
|
--customid=* )
|
2013-06-15 19:33:43 +02:00
|
|
|
CUSTOMID=${1/*=}
|
|
|
|
if [[ ${#CUSTOMID} != 6 ]]; then
|
|
|
|
echo -e "CustomID ${CUSTOMID} needs to have 6 digits"
|
2013-10-12 10:37:29 +02:00
|
|
|
exit 39
|
2013-06-15 19:33:43 +02:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
|
2013-06-20 18:01:50 +02:00
|
|
|
--download )
|
2016-08-05 20:52:12 +02:00
|
|
|
export PATCHIMAGE_RIIVOLUTION_DOWNLOAD=TRUE
|
2013-06-20 18:01:50 +02:00
|
|
|
;;
|
|
|
|
|
2016-08-17 22:47:29 +02:00
|
|
|
--show-downloadlink )
|
|
|
|
export PATCHIMAGE_SHOW_DOWNLOAD=TRUE
|
|
|
|
;;
|
|
|
|
|
2013-06-20 18:15:08 +02:00
|
|
|
--soundtrack )
|
2016-08-05 20:52:12 +02:00
|
|
|
export PATCHIMAGE_SOUNDTRACK_DOWNLOAD=TRUE
|
2014-05-11 21:57:19 +02:00
|
|
|
;;
|
|
|
|
|
|
|
|
--only-soundtrack )
|
2016-08-05 20:52:12 +02:00
|
|
|
export PATCHIMAGE_SOUNDTRACK_DOWNLOAD=TRUE
|
|
|
|
export ONLY_SOUNDTRACK=TRUE
|
2013-06-20 18:15:08 +02:00
|
|
|
;;
|
|
|
|
|
2016-08-06 20:30:04 +02:00
|
|
|
--override-szs )
|
|
|
|
export MKWIIMM_OVERRIDE_SZS=TRUE
|
|
|
|
;;
|
|
|
|
|
2013-06-15 19:33:43 +02:00
|
|
|
--version=* )
|
2016-08-05 20:52:12 +02:00
|
|
|
VERSION="${1/*=}"
|
2013-06-15 19:33:43 +02:00
|
|
|
case ${VERSION} in
|
|
|
|
EURv1 )
|
2016-08-05 20:52:12 +02:00
|
|
|
export REG_LETTER=P
|
2013-06-15 19:33:43 +02:00
|
|
|
;;
|
|
|
|
|
|
|
|
EURv2 )
|
2016-08-05 20:52:12 +02:00
|
|
|
export REG_LETTER=P
|
2013-06-15 19:33:43 +02:00
|
|
|
;;
|
|
|
|
|
|
|
|
USAv1 )
|
2016-08-05 20:52:12 +02:00
|
|
|
export REG_LETTER=E
|
2013-06-15 19:33:43 +02:00
|
|
|
;;
|
|
|
|
|
|
|
|
USAv2 )
|
2016-08-05 20:52:12 +02:00
|
|
|
export REG_LETTER=E
|
2013-06-15 19:33:43 +02:00
|
|
|
;;
|
|
|
|
|
|
|
|
JPNv1 )
|
2016-08-05 20:52:12 +02:00
|
|
|
export REG_LETTER=J
|
2013-06-15 19:33:43 +02:00
|
|
|
;;
|
|
|
|
|
|
|
|
* )
|
|
|
|
echo -e "unrecognized game version: ${VERSION}"
|
2013-10-12 10:37:29 +02:00
|
|
|
exit 27
|
2013-06-15 19:33:43 +02:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
|
|
|
|
--sharesave )
|
2016-08-05 20:52:12 +02:00
|
|
|
export PATCHIMAGE_SHARE_SAVE=TRUE
|
2013-06-15 19:33:43 +02:00
|
|
|
;;
|
|
|
|
|
2016-08-05 20:52:12 +02:00
|
|
|
--game=* )
|
|
|
|
export GAME="${1/*=}"
|
2013-06-15 19:33:43 +02:00
|
|
|
;;
|
|
|
|
|
2016-08-06 20:10:38 +02:00
|
|
|
--list-games )
|
2016-08-18 10:11:05 +02:00
|
|
|
echo "${SUPPORTED_GAMES_ALL}"
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
|
|
|
|
--list-games-nsmb )
|
|
|
|
echo "${SUPPORTED_GAMES_NSMB}"
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
|
|
|
|
--list-games-mkwiimmfi )
|
|
|
|
echo "${SUPPORTED_GAMES_MKWIIMMFI}"
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
|
|
|
|
--list-games-tokyo )
|
|
|
|
echo "${SUPPORTED_GAMES_TOKYOMIRAGESESSIONSFE}"
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
|
|
|
|
--list-games-kirby )
|
|
|
|
echo "${SUPPORTED_GAMES_KIRBY}"
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
|
|
|
|
--list-games-pokemon )
|
|
|
|
echo "${SUPPORTED_GAMES_POKEMON}"
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
|
|
|
|
--list-games-3ds )
|
|
|
|
echo "${SUPPORTED_GAMES_3DS}"
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
|
|
|
|
--list-games-other )
|
|
|
|
echo "${SUPPORTED_GAMES_OTHER}"
|
2016-08-06 20:10:38 +02:00
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
|
2016-08-17 22:47:29 +02:00
|
|
|
--list-requirements )
|
2016-08-18 10:11:05 +02:00
|
|
|
echo "${REQUIREMENTS_ALL}"
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
|
|
|
|
--list-requirements-nsmb )
|
|
|
|
echo "${REQUIREMENTS_NSMB}"
|
|
|
|
echo "${REQUIREMENTS_FOOTER}"
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
|
|
|
|
--list-requirements-mkwiimmfi )
|
|
|
|
echo "${REQUIREMENTS_MKWIIMMFI}"
|
|
|
|
echo "${REQUIREMENTS_FOOTER}"
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
|
|
|
|
--list-requirements-tokyo )
|
|
|
|
echo "${REQUIREMENTS_TOKYOMIRAGESESSIONSFE}"
|
|
|
|
echo "${REQUIREMENTS_FOOTER}"
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
|
|
|
|
--list-requirements-kirby )
|
|
|
|
echo "${REQUIREMENTS_KIRBY}"
|
|
|
|
echo "${REQUIREMENTS_FOOTER}"
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
|
|
|
|
--list-requirements-pokemon )
|
|
|
|
echo "${REQUIREMENTS_POKEMON}"
|
|
|
|
echo "${REQUIREMENTS_FOOTER}"
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
|
|
|
|
--list-requirements-3ds )
|
|
|
|
echo "${REQUIREMENTS_3DS}"
|
|
|
|
echo "${REQUIREMENTS_FOOTER}"
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
|
|
|
|
--list-requirements-other )
|
|
|
|
echo "${REQUIREMENTS_OTHER}"
|
|
|
|
echo "${REQUIREMENTS_FOOTER}"
|
2016-08-17 22:47:29 +02:00
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
|
2016-08-05 20:52:12 +02:00
|
|
|
--covers )
|
|
|
|
export PATCHIMAGE_COVER_DOWNLOAD=TRUE
|
2014-05-11 21:57:19 +02:00
|
|
|
;;
|
|
|
|
|
2016-08-05 20:52:12 +02:00
|
|
|
--only-covers=* )
|
|
|
|
export PATCHIMAGE_COVER_DOWNLOAD=TRUE
|
|
|
|
download_covers "${1/*=}"
|
2014-05-11 21:57:19 +02:00
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
|
2013-07-01 22:23:32 +02:00
|
|
|
--banner=* )
|
2016-08-05 20:52:12 +02:00
|
|
|
BANNER="${1/*=}"
|
|
|
|
BANNER_EXT="${BANNER//*./}"
|
2013-07-01 22:23:32 +02:00
|
|
|
if [[ ${BANNER_EXT} != "bnr" ]]; then
|
|
|
|
echo "given banner (${BANNER}) is not a .bnr file!"
|
2013-10-12 10:37:29 +02:00
|
|
|
exit 33
|
2013-07-01 22:23:32 +02:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
|
|
|
|
--download-banner )
|
2016-08-05 20:52:12 +02:00
|
|
|
export PATCHIMAGE_BANNER_DOWNLOAD=TRUE
|
2013-07-01 22:23:32 +02:00
|
|
|
;;
|
|
|
|
|
2016-07-01 21:58:50 +02:00
|
|
|
--xdelta=* )
|
2016-08-05 20:52:12 +02:00
|
|
|
export XDELTA_PATH="${1/*=}"
|
2016-07-01 21:58:50 +02:00
|
|
|
;;
|
|
|
|
|
|
|
|
--cpk=* )
|
2016-08-05 20:52:12 +02:00
|
|
|
export CPK_PATH="${1/*=}"
|
2016-07-01 21:58:50 +02:00
|
|
|
;;
|
|
|
|
|
2014-05-16 20:36:08 +02:00
|
|
|
--help | -h )
|
2016-08-18 10:11:05 +02:00
|
|
|
echo "${PATCHIMAGE_HELP}"
|
2013-06-15 19:33:43 +02:00
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
2016-08-05 20:52:12 +02:00
|
|
|
xcount=$((xcount+1))
|
2013-06-15 19:33:43 +02:00
|
|
|
done
|
|
|
|
|
|
|
|
}
|