2013-06-15 19:33:43 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2016-08-03 22:21:05 +02:00
|
|
|
PATCHIMAGE_VERSION=7.0.0
|
2016-08-03 20:13:23 +02:00
|
|
|
PATCHIMAGE_RELEASE=2016/08/03
|
2016-05-16 14:53:30 +02:00
|
|
|
|
2016-08-03 22:21:05 +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-03 22:20:17 +02:00
|
|
|
WIT="${PATCHIMAGE_TOOLS_DIR}"/wit.${SUFFIX}
|
|
|
|
PPF="${PATCHIMAGE_TOOLS_DIR}"/applyppf3.${SUFFIX}
|
|
|
|
IPS="${PATCHIMAGE_TOOLS_DIR}"/uips.${SUFFIX}
|
|
|
|
UNP="${PATCHIMAGE_TOOLS_DIR}"/unp
|
|
|
|
SZS="${PATCHIMAGE_TOOLS_DIR}"/wszst.${SUFFIX}
|
|
|
|
XD3="${PATCHIMAGE_TOOLS_DIR}"/xdelta3.${SUFFIX}
|
|
|
|
GDOWN="${PATCHIMAGE_TOOLS_DIR}"/gdown.pl
|
|
|
|
CTRTOOL="${PATCHIMAGE_TOOLS_DIR}"/ctrtool.${SUFFIX}
|
|
|
|
FDSTOOL="${PATCHIMAGE_TOOLS_DIR}"/3dstool.${SUFFIX}
|
2014-05-16 21:38:20 +02:00
|
|
|
|
2013-06-15 19:33:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ask_game () {
|
|
|
|
|
2013-06-20 21:30:26 +02:00
|
|
|
echo -e \
|
|
|
|
"************************************************
|
2016-05-16 14:53:30 +02:00
|
|
|
patchimage v${PATCHIMAGE_VERSION}
|
2014-05-17 10:07:15 +02:00
|
|
|
|
2016-05-16 17:25:17 +02:00
|
|
|
ID Name
|
2014-05-17 10:07:15 +02:00
|
|
|
|
|
|
|
<<<<<< New Super Mario Bros. Wii >>>>>>
|
|
|
|
NSMB1 NewerSMB
|
|
|
|
NSMB2 Newer Summer Sun
|
|
|
|
NSMB3 AnotherSMB
|
|
|
|
NSMB4 Newer: Holiday Special
|
|
|
|
NSMB5 Cannon Super Mario Bros.
|
|
|
|
NSMB6 Epic Super Bowser World
|
|
|
|
NSMB7 Koopa Country
|
|
|
|
NSMB8 New Super Mario Bros. 4
|
|
|
|
NSMB9 New Super Mario Bros. Wii Retro Remix
|
|
|
|
NSMB10 Super Mario: Mushroom Adventure PLUS - Winter Moon
|
|
|
|
NSMB11 NSMBW3: The Final Levels
|
|
|
|
NSMB12 Super Mario Vacation
|
|
|
|
NSMB13 Awesomer Super Luigi Mini
|
|
|
|
NSMB14 Super Mario Skyland
|
|
|
|
NSMB15 RVLution Wii (NewSMB Mod)
|
2014-08-10 21:46:26 +02:00
|
|
|
NSMB16 Midi's Super Mario Wii (Just A Little Adventure)
|
2014-08-10 21:59:28 +02:00
|
|
|
NSMB17 DarkUmbra SMB Anniversary Edition
|
2014-08-10 22:12:50 +02:00
|
|
|
NSMB18 Newer Apocalypse
|
2015-01-20 20:50:53 +01:00
|
|
|
NSMB19 Luigi's Super Yoshi Bros.
|
2015-01-20 21:01:45 +01:00
|
|
|
NSMB20 Newer: Falling Leaf
|
2015-04-11 13:47:31 +02:00
|
|
|
NSMB21 Devil Mario Winter Special
|
2015-04-11 14:02:32 +02:00
|
|
|
NSMB22 New Super Mario Bros. Wii - Other World
|
2016-05-16 17:21:53 +02:00
|
|
|
NSMB23 The Legend of Yoshi
|
2016-05-16 17:25:17 +02:00
|
|
|
NSMB24 Remixed Super Mario Bros. Wii
|
2016-05-16 18:02:42 +02:00
|
|
|
NSMB25 Ghostly Super Ghost Boos. Wii
|
2016-08-03 22:20:17 +02:00
|
|
|
NSMB26 Revised Super Mario Bros. Wii
|
2014-05-17 10:07:15 +02:00
|
|
|
|
2015-07-11 19:58:10 +02:00
|
|
|
NSMB99 Customize Characters
|
|
|
|
|
2014-05-17 10:07:15 +02:00
|
|
|
<<<<<< Mario Kart Wii >>>>>>
|
|
|
|
MKW1 Wiimfi Patcher. Patch Mario Kart to use Wiimm's server
|
|
|
|
MKW2 Wiimfi Patcher. Patch WFC games to use Wiimm's server (exp)
|
|
|
|
MKW3 Mario Kart Wiimm. Custom Mario Kart Distribution
|
|
|
|
MKW4 Custom Items. Replace items in the game
|
2014-05-18 07:51:09 +02:00
|
|
|
MKW5 Custom Font. Replace font in the game
|
2015-04-11 21:01:24 +02:00
|
|
|
MKW6 Custom Karts. Replace characters in the game
|
2014-05-17 10:07:15 +02:00
|
|
|
|
|
|
|
<<<<<< Kirby's Adventure Wii >>>>>>
|
|
|
|
KAW1 Change first player's character
|
|
|
|
|
2016-07-01 20:07:53 +02:00
|
|
|
<<<<<< Tokyo Mirage Sessions #FE >>>>>>
|
|
|
|
TMS1 Uncensor US/EUR version
|
|
|
|
|
2016-07-26 23:16:49 +02:00
|
|
|
<<<<<< 3DS ROMS >>>>>>
|
|
|
|
PKMN1 Pokemon Neo X
|
|
|
|
PKMN2 Pokemon Neo Y
|
2016-07-27 18:22:48 +02:00
|
|
|
PKMN3 Pokemon Rutile Ruby
|
|
|
|
PKMN4 Pokemon Star Sapphire
|
2016-08-02 21:40:04 +02:00
|
|
|
PKMN5 Pokemon Eternal X
|
|
|
|
PKMN6 Pokemon Wilting Y
|
2016-08-03 20:13:23 +02:00
|
|
|
PKMN7 Pokemon Rising Ruby
|
|
|
|
PKMN8 Pokemon Sinking Sapphire
|
2016-07-26 23:16:49 +02:00
|
|
|
|
2016-08-03 22:20:17 +02:00
|
|
|
BSECU Bravely Second Uncensored
|
|
|
|
|
2014-05-17 10:07:15 +02:00
|
|
|
<<<<<< ROMS >>>>>>
|
|
|
|
ZEL1 The Legend of Zelda: Parallel Worlds
|
2016-05-16 17:25:17 +02:00
|
|
|
|
|
|
|
ID Name
|
|
|
|
Enter ID for the Game you want to create:
|
2013-06-20 21:03:40 +02:00
|
|
|
"
|
2013-06-15 19:33:43 +02:00
|
|
|
|
|
|
|
read GAME
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-06-20 18:15:08 +02:00
|
|
|
download_soundtrack () {
|
|
|
|
|
2016-08-03 22:20:17 +02:00
|
|
|
if [[ ${SOUNDTRACK_LINK} && ! -f "${PATCHIMAGE_AUDIO_DIR}"/"${SOUNDTRACK_ZIP}" ]]; then
|
|
|
|
wget --no-check-certificate "${SOUNDTRACK_LINK}" -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
|
2013-07-07 22:36:04 +02:00
|
|
|
if [[ ! -f "${PATCHIMAGE_RIIVOLUTION_DIR}"/${GAMEID}-custom-banner.bnr ]]; then
|
2013-10-12 10:37:29 +02:00
|
|
|
wget --no-check-certificate "${CUSTOM_BANNER}" -O "${PATCHIMAGE_RIIVOLUTION_DIR}"/${GAMEID}-custom-banner.bnr__tmp || exit 57
|
|
|
|
mv "${PATCHIMAGE_RIIVOLUTION_DIR}"/${GAMEID}-custom-banner.bnr__tmp "${PATCHIMAGE_RIIVOLUTION_DIR}"/${GAMEID}-custom-banner.bnr
|
2013-07-07 22:36:04 +02:00
|
|
|
fi
|
|
|
|
BANNER="${PATCHIMAGE_RIIVOLUTION_DIR}"/${GAMEID}-custom-banner.bnr
|
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
|
|
|
|
REG_LETTER=P
|
|
|
|
elif [[ -f ${WORKDIR}/files/COPYDATE_LAST_2010-01-05_152101 ]]; then
|
|
|
|
VERSION=EURv2
|
|
|
|
REG_LETTER=P
|
|
|
|
elif [[ -f ${WORKDIR}/files/COPYDATE_LAST_2009-10-03_232303 ]]; then
|
|
|
|
VERSION=USAv1
|
|
|
|
REG_LETTER=E
|
|
|
|
elif [[ -f ${WORKDIR}/files/COPYDATE_LAST_2010-01-05_143554 ]]; then
|
|
|
|
VERSION=USAv2
|
|
|
|
REG_LETTER=E
|
|
|
|
elif [[ -f ${WORKDIR}/files/COPYDATE_LAST_2009-10-03_231655 ]]; then
|
|
|
|
VERSION=JPNv1
|
|
|
|
REG_LETTER=J
|
|
|
|
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-02 22:22:48 +02:00
|
|
|
[[ ! -d ${PATCHIMAGE_RIIVOLUTION_DIR} && -w $(dirname ${PATCHIMAGE_RIIVOLUTION_DIR}) ]] && \
|
2016-08-03 22:20:17 +02:00
|
|
|
( mkdir -p "${PATCHIMAGE_RIIVOLUTION_DIR}" || PATCHIMAGE_RIIVOLUTION_DIR=${HOME} )
|
2013-10-12 10:37:29 +02:00
|
|
|
|
2016-08-03 21:15:35 +02:00
|
|
|
[[ ! -w ${PATCHIMAGE_RIIVOLUTION_DIR} ]] && PATCHIMAGE_RIIVOLUTION_DIR=${HOME}
|
|
|
|
|
2016-08-02 22:22:48 +02:00
|
|
|
[[ ! -d ${PATCHIMAGE_WBFS_DIR} && -w $(dirname ${PATCHIMAGE_WBFS_DIR}) ]] && \
|
2016-08-03 22:20:17 +02:00
|
|
|
( mkdir -p "${PATCHIMAGE_WBFS_DIR}" || PATCHIMAGE_WBFS_DIR=${HOME} )
|
2013-10-12 10:37:29 +02:00
|
|
|
|
2016-08-03 22:20:17 +02:00
|
|
|
[[ ! -w "${PATCHIMAGE_WBFS_DIR}" ]] && PATCHIMAGE_WBFS_DIR=${HOME}
|
2016-08-03 21:15:35 +02:00
|
|
|
|
2016-08-02 22:22:48 +02:00
|
|
|
[[ ! -d ${PATCHIMAGE_GAME_DIR} && -w $(dirname ${PATCHIMAGE_GAME_DIR}) ]] && \
|
2016-08-03 22:20:17 +02:00
|
|
|
( mkdir -p "${PATCHIMAGE_GAME_DIR}" || PATCHIMAGE_GAME_DIR=${HOME} )
|
2013-10-12 10:37:29 +02:00
|
|
|
|
2016-08-03 21:15:35 +02:00
|
|
|
[[ ! -w ${PATCHIMAGE_GAME_DIR} ]] && PATCHIMAGE_GAME_DIR=${HOME}
|
|
|
|
|
2016-08-02 22:22:48 +02:00
|
|
|
[[ ! -d ${PATCHIMAGE_3DS_DIR} && -w $(dirname ${PATCHIMAGE_3DS_DIR}) ]] && \
|
2016-08-03 22:20:17 +02:00
|
|
|
( mkdir -p "${PATCHIMAGE_3DS_DIR}" || PATCHIMAGE_3DS_DIR=${HOME} )
|
2013-10-12 10:37:29 +02:00
|
|
|
|
2016-08-03 21:15:35 +02:00
|
|
|
[[ ! -w ${PATCHIMAGE_3DS_DIR} ]] && PATCHIMAGE_3DS_DIR=${HOME}
|
|
|
|
|
2016-08-02 22:22:48 +02:00
|
|
|
[[ ! -d ${PATCHIMAGE_ROM_DIR} && -w $(dirname ${PATCHIMAGE_ROM_DIR}) ]] && \
|
2016-08-03 22:20:17 +02:00
|
|
|
( mkdir -p "${PATCHIMAGE_ROM_DIR}" || PATCHIMAGE_ROM_DIR=${HOME} )
|
2014-05-13 17:49:00 +02:00
|
|
|
|
2016-08-03 21:15:35 +02:00
|
|
|
[[ ! -w ${PATCHIMAGE_ROM_DIR} ]] && PATCHIMAGE_ROM_DIR=${HOME}
|
|
|
|
|
2016-08-02 22:22:48 +02:00
|
|
|
[[ ! -d ${PATCHIMAGE_AUDIO_DIR} && -w $(dirname ${PATCHIMAGE_AUDIO_DIR}) ]] && \
|
2016-08-03 22:20:17 +02:00
|
|
|
( mkdir -p "${PATCHIMAGE_AUDIO_DIR}" || PATCHIMAGE_AUDIO_DIR=${HOME} )
|
2016-08-02 22:22:48 +02:00
|
|
|
|
2016-08-03 21:15:35 +02:00
|
|
|
[[ ! -w ${PATCHIMAGE_AUDIO_DIR} ]] && PATCHIMAGE_AUDIO_DIR=${HOME}
|
|
|
|
|
2016-08-03 22:20:17 +02:00
|
|
|
[[ ! -d ${PATCHIMAGE_COVER_DIR} && -w $(dirname "${PATCHIMAGE_COVER_DIR}") ]] && \
|
|
|
|
( mkdir -p "${PATCHIMAGE_COVER_DIR}" || PATCHIMAGE_COVER_DIR=${HOME} )
|
2013-10-12 10:37:29 +02:00
|
|
|
|
2016-08-03 21:15:35 +02:00
|
|
|
[[ ! -w ${PATCHIMAGE_COVER_DIR} ]] && PATCHIMAGE_COVER_DIR=${HOME}
|
|
|
|
|
2016-08-02 22:22:48 +02:00
|
|
|
}
|
2013-10-12 10:37:29 +02:00
|
|
|
|
2013-06-15 19:33:43 +02:00
|
|
|
check_input_image () {
|
|
|
|
|
2013-10-12 10:37:29 +02:00
|
|
|
x=0
|
2013-06-15 19:33:43 +02:00
|
|
|
if [[ ! ${IMAGE} ]]; then
|
2014-05-13 18:57:58 +02:00
|
|
|
if [[ -f BASE.wbfs ]]; then
|
2013-10-12 10:37:29 +02:00
|
|
|
x=1
|
2014-05-13 18:57:58 +02:00
|
|
|
IMAGE=BASE.wbfs
|
|
|
|
elif [[ -f BASE.iso ]]; then
|
2013-10-12 10:37:29 +02:00
|
|
|
x=1
|
2014-05-13 18:57:58 +02:00
|
|
|
IMAGE=BASE.iso
|
2013-06-15 19:33:43 +02:00
|
|
|
fi
|
|
|
|
fi
|
2013-10-12 10:37:29 +02:00
|
|
|
echo "*** >> status: ${x}"
|
2013-06-15 19:33:43 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-08-06 23:53:43 +02:00
|
|
|
check_input_image_nsmb () {
|
|
|
|
|
2013-10-12 10:37:29 +02:00
|
|
|
x=0
|
2013-08-06 23:53:43 +02:00
|
|
|
if [[ ! ${IMAGE} ]]; then
|
|
|
|
if test -f SMN?01.wbfs; then
|
2013-10-12 10:37:29 +02:00
|
|
|
x=1
|
2013-08-07 19:46:33 +02:00
|
|
|
IMAGE=SMN?01.wbfs
|
2013-08-06 23:53:43 +02:00
|
|
|
elif test -f SMN?01.iso; then
|
2013-10-12 10:37:29 +02:00
|
|
|
x=2
|
2013-08-07 19:46:33 +02:00
|
|
|
IMAGE=SMN?01.iso
|
2016-08-03 22:20:17 +02:00
|
|
|
elif test -f "${PATCHIMAGE_WBFS_DIR}"/SMN?01.iso; then
|
2013-10-12 10:37:29 +02:00
|
|
|
x=3
|
2016-08-03 22:20:17 +02:00
|
|
|
IMAGE="${PATCHIMAGE_WBFS_DIR}"/SMN?01.iso
|
|
|
|
elif test -f "${PATCHIMAGE_WBFS_DIR}"/SMN?01.wbfs; then
|
2013-10-12 10:37:29 +02:00
|
|
|
x=4
|
2016-08-03 22:20:17 +02:00
|
|
|
IMAGE="${PATCHIMAGE_WBFS_DIR}"/SMN?01.wbfs
|
2013-08-06 23:53:43 +02:00
|
|
|
else
|
|
|
|
echo -e "please specify image to use with --iso=<path>"
|
2013-10-12 10:37:29 +02:00
|
|
|
exit 15
|
2013-08-06 23:53:43 +02:00
|
|
|
fi
|
|
|
|
fi
|
2013-10-12 10:37:29 +02:00
|
|
|
echo "*** >> status: ${x}"
|
2013-08-06 23:53:43 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-05-15 20:54:19 +02:00
|
|
|
check_input_image_kirby () {
|
|
|
|
|
|
|
|
x=0
|
|
|
|
if [[ ! ${IMAGE} ]]; then
|
|
|
|
if test -f SMN?01.wbfs; then
|
|
|
|
x=1
|
|
|
|
IMAGE=SMN?01.wbfs
|
|
|
|
elif test -f SMN?01.iso; then
|
|
|
|
x=2
|
|
|
|
IMAGE=SMN?01.iso
|
2016-08-03 22:20:17 +02:00
|
|
|
elif test -f "${PATCHIMAGE_WBFS_DIR}"/SUK?01.iso; then
|
2014-05-15 20:54:19 +02:00
|
|
|
x=3
|
2016-08-03 22:20:17 +02:00
|
|
|
IMAGE="${PATCHIMAGE_WBFS_DIR}"/SUK?01.iso
|
|
|
|
elif test -f "${PATCHIMAGE_WBFS_DIR}"/SUK?01.wbfs; then
|
2014-05-15 20:54:19 +02:00
|
|
|
x=4
|
2016-08-03 22:20:17 +02:00
|
|
|
IMAGE="${PATCHIMAGE_WBFS_DIR}"/SUK?01.wbfs
|
2014-05-15 20:54:19 +02:00
|
|
|
else
|
|
|
|
echo -e "please specify image to use with --iso=<path>"
|
|
|
|
exit 15
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
echo "*** >> status: ${x}"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-05-11 19:26:58 +02:00
|
|
|
check_input_image_mkwiimm () {
|
|
|
|
|
|
|
|
x=0
|
|
|
|
if [[ ! ${IMAGE} ]]; then
|
|
|
|
if test -f RMC?01.wbfs; then
|
|
|
|
x=1
|
|
|
|
IMAGE=RMC?01.wbfs
|
|
|
|
elif test -f RMC?01.iso; then
|
|
|
|
x=2
|
|
|
|
IMAGE=RMC?01.iso
|
2016-08-03 22:20:17 +02:00
|
|
|
elif test -f "${PATCHIMAGE_WBFS_DIR}"/RMC?01.iso; then
|
2014-05-11 19:26:58 +02:00
|
|
|
x=3
|
2016-08-03 22:20:17 +02:00
|
|
|
IMAGE="${PATCHIMAGE_WBFS_DIR}"/RMC?01.iso
|
|
|
|
elif test -f "${PATCHIMAGE_WBFS_DIR}"/RMC?01.wbfs; then
|
2014-05-11 19:26:58 +02:00
|
|
|
x=4
|
2016-08-03 22:20:17 +02:00
|
|
|
IMAGE="${PATCHIMAGE_WBFS_DIR}"/RMC?01.wbfs
|
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-02 22:22:48 +02:00
|
|
|
check_input_rom () {
|
|
|
|
|
|
|
|
x=5
|
|
|
|
if [[ ! ${CXI} ]]; then
|
|
|
|
CXI=$(find . -name ${CXI_MASK} | sed -e 's,./,,')
|
|
|
|
if [[ -f ${CXI} ]]; then
|
|
|
|
x=6
|
|
|
|
CXI=${CXI}
|
|
|
|
RFS=${ROMFS}
|
|
|
|
else
|
|
|
|
CXI=$(find ${PATCHIMAGE_3DS_DIR} -name ${CXI_MASK})
|
|
|
|
if [[ -f ${CXI} ]]; then
|
|
|
|
x=7
|
|
|
|
CXI=${CXI}
|
|
|
|
RFS=${ROMFS}
|
|
|
|
else
|
|
|
|
echo -e "error: could not find suitable ROM, specify using --rom"
|
|
|
|
exit 15
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
echo "*** >> status: ${x}"
|
|
|
|
}
|
|
|
|
|
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}
|
|
|
|
gawk -F \: "/^${ID1}\*${ID2}/"'{print $2}' \
|
2016-08-03 22:20:17 +02:00
|
|
|
< "${PATCHIMAGE_SCRIPT_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}
|
|
|
|
[[ ${ID} == [0-9][0-9] ]] && gawk -F \: "/^${ID}/"'{print $2}' \
|
2016-08-03 22:20:17 +02:00
|
|
|
< "${PATCHIMAGE_SCRIPT_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"
|
|
|
|
|
|
|
|
for image in ${1}/RMC???.{iso,wbfs}; do
|
|
|
|
if [[ -e ${image} ]]; then
|
|
|
|
echo " ${image##*/} $(show_mkwiimm_db ${image##*/})"
|
|
|
|
fi
|
|
|
|
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"
|
|
|
|
|
2015-07-12 19:59:08 +02:00
|
|
|
for image in ${1}/SMN???.{iso,wbfs} ${1}/SLF???.{iso,wbfs} ${1}/SMM???.{iso,wbfs} ${1}/SMV???.{iso,wbfs} ${1}/MRR???.{iso,wbfs}; do
|
2015-07-11 19:58:10 +02:00
|
|
|
if [[ -e ${image} ]]; then
|
2015-07-12 19:45:44 +02:00
|
|
|
echo " ${image##*/} $(show_nsmb_db ${image##*/})"
|
2015-07-11 19:58:10 +02:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-05-13 18:57:58 +02:00
|
|
|
show_titles_db () {
|
|
|
|
|
|
|
|
ID=${1/.*}
|
|
|
|
gawk -F \: "/^${ID}/"'{print $2}' \
|
2016-08-03 22:20:17 +02:00
|
|
|
< "${PATCHIMAGE_SCRIPT_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-03 22:20:17 +02:00
|
|
|
if [[ $(grep ${ID} "${PATCHIMAGE_SCRIPT_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"
|
|
|
|
|
2014-05-13 18:20:28 +02:00
|
|
|
for image in ${1}/*.{iso,wbfs}; do
|
2014-05-13 20:11:13 +02:00
|
|
|
if [[ -e ${image} && ! ${image} == "*/RMC*" && $(check_wfc ${image##*/}) == TRUE ]]; then
|
2014-05-13 18:57:58 +02:00
|
|
|
echo " ${image##*/} $(show_titles_db ${image##*/})"
|
2014-05-13 17:49:00 +02:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
if [[ -f "${PWD}/${RIIVOLUTION_DIR}" ]]; then
|
|
|
|
echo "*** >> unpacking"
|
|
|
|
x=2
|
2016-08-04 18:19:57 +02:00
|
|
|
${UNP} "${PWD}/${RIIVOLUTION_ZIP}" ${UNP_EXTRA_ARGS} >/dev/null || exit 63
|
2013-10-12 10:37:29 +02:00
|
|
|
elif [[ -f "${PATCHIMAGE_RIIVOLUTION_DIR}/${RIIVOLUTION_ZIP}" ]]; then
|
|
|
|
echo "*** >> unpacking"
|
|
|
|
x=3
|
2016-08-04 18:19:57 +02:00
|
|
|
${UNP} "${PATCHIMAGE_RIIVOLUTION_DIR}/${RIIVOLUTION_ZIP}" ${UNP_EXTRA_ARGS} >/dev/null || exit 63
|
2013-08-06 22:52:36 +02:00
|
|
|
elif [[ ${PATCHIMAGE_RIIVOLUTION_DOWNLOAD} == "TRUE" ]]; then
|
2013-10-12 10:37:29 +02:00
|
|
|
x=4
|
2016-08-03 22:37:54 +02:00
|
|
|
if [[ ${DOWNLOAD_LINK} == *docs.google* || ${DOWNLOAD_LINK} == *drive.google* ]]; then
|
2014-05-16 21:38:20 +02:00
|
|
|
if [[ ! -f "${PATCHIMAGE_RIIVOLUTION_DIR}/${RIIVOLUTION_ZIP}" ]]; then
|
|
|
|
x=5
|
|
|
|
echo "*** >> downloading"
|
|
|
|
${GDOWN} "${DOWNLOAD_LINK}" "${PATCHIMAGE_RIIVOLUTION_DIR}/${RIIVOLUTION_ZIP}"__tmp >/dev/null || exit 57
|
|
|
|
mv "${PATCHIMAGE_RIIVOLUTION_DIR}/${RIIVOLUTION_ZIP}"__tmp "${PATCHIMAGE_RIIVOLUTION_DIR}/${RIIVOLUTION_ZIP}"
|
|
|
|
echo "*** >> unpacking"
|
2016-08-04 18:19:57 +02:00
|
|
|
${UNP} "${PATCHIMAGE_RIIVOLUTION_DIR}/${RIIVOLUTION_ZIP}" ${UNP_EXTRA_ARGS} >/dev/null || exit 63
|
2014-05-16 21:38:20 +02:00
|
|
|
fi
|
2016-08-03 22:37:54 +02:00
|
|
|
elif [[ ${DOWNLOAD_LINK} == *mega.nz* ]]; then
|
|
|
|
echo "can not download from Mega, download manually from:
|
|
|
|
|
|
|
|
${DOWNLOAD_LINK}
|
|
|
|
"
|
|
|
|
exit 21
|
|
|
|
elif [[ ${DOWNLOAD_LINK} == *mediafire* ]]; then
|
|
|
|
echo "can not download from Mediafire, download manually from:
|
|
|
|
|
|
|
|
${DOWNLOAD_LINK}
|
|
|
|
"
|
|
|
|
exit 21
|
2014-05-16 21:38:20 +02:00
|
|
|
elif [[ ${DOWNLOAD_LINK} ]]; then
|
2013-10-12 10:37:29 +02:00
|
|
|
if [[ ! -f "${PATCHIMAGE_RIIVOLUTION_DIR}/${RIIVOLUTION_ZIP}" ]]; then
|
|
|
|
x=5
|
|
|
|
echo "*** >> downloading"
|
2016-08-03 21:03:54 +02:00
|
|
|
wget --no-check-certificate "${DOWNLOAD_LINK}" -O "${PATCHIMAGE_RIIVOLUTION_DIR}/${RIIVOLUTION_ZIP}"__tmp >/dev/null || exit 57
|
2013-10-12 10:37:29 +02:00
|
|
|
mv "${PATCHIMAGE_RIIVOLUTION_DIR}/${RIIVOLUTION_ZIP}"__tmp "${PATCHIMAGE_RIIVOLUTION_DIR}/${RIIVOLUTION_ZIP}"
|
|
|
|
echo "*** >> unpacking"
|
2016-08-04 18:19:57 +02:00
|
|
|
${UNP} "${PATCHIMAGE_RIIVOLUTION_DIR}/${RIIVOLUTION_ZIP}" ${UNP_EXTRA_ARGS} >/dev/null || exit 63
|
2013-08-06 22:52:36 +02:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "no download link for ${GAMENAME} available."
|
2013-10-12 10:37:29 +02:00
|
|
|
exit 21
|
2013-07-03 16:44:13 +02:00
|
|
|
fi
|
|
|
|
else
|
2013-08-06 22:52:36 +02:00
|
|
|
echo -e "please specify zip/rar to use with --riivolution=<path>"
|
2013-10-12 10:37:29 +02:00
|
|
|
exit 21
|
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-03 22:20:17 +02:00
|
|
|
alt=$(echo $1 | sed s/./E/4)
|
|
|
|
|
2014-05-11 20:43:49 +02:00
|
|
|
for path in cover cover3D coverfull disc disccustom; do
|
2016-08-03 22:20:17 +02:00
|
|
|
if [[ ! -f "${PATCHIMAGE_COVER_DIR}"/${1}_${path}.png ]]; then
|
|
|
|
wget -O "${PATCHIMAGE_COVER_DIR}"/${1}_${path}.png \
|
|
|
|
http://art.gametdb.com/wii/${path}/EN/${1}.png &>/dev/null \
|
|
|
|
|| rm "${PATCHIMAGE_COVER_DIR}"/${1}_${path}.png
|
|
|
|
|
|
|
|
if [[ ! -f "${PATCHIMAGE_COVER_DIR}"/${1}_${path}.png ]]; then
|
|
|
|
wget -O "${PATCHIMAGE_COVER_DIR}"/${1}_${path}.png \
|
|
|
|
http://art.gametdb.com/wii/${path}/US/${alt}.png &>/dev/null \
|
|
|
|
|| rm "${PATCHIMAGE_COVER_DIR}"/${1}_${path}.png
|
|
|
|
fi
|
|
|
|
|
|
|
|
[[ ! -f "${PATCHIMAGE_COVER_DIR}"/${1}_${path}.png ]] && \
|
|
|
|
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
|
|
|
|
|
|
|
--iso* )
|
|
|
|
ISO_PATH=${1/*=}
|
|
|
|
ISO_EXT=${ISO_PATH//*./}
|
|
|
|
|
|
|
|
if [[ -e "${ISO_PATH}" ]]; then
|
2013-06-22 19:15:29 +02:00
|
|
|
ln -sf "${ISO_PATH}" BASE.${ISO_EXT}
|
2013-06-20 20:35:34 +02:00
|
|
|
IMAGE=BASE.${ISO_EXT}
|
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
|
|
|
|
;;
|
|
|
|
|
2013-06-22 19:15:29 +02:00
|
|
|
--rom* )
|
|
|
|
ROM_PATH=${1/*=}
|
|
|
|
ROM_EXT=${ROM_PATH//*./}
|
|
|
|
|
|
|
|
if [[ -e "${ROM_PATH}" ]]; then
|
|
|
|
ln -sf "${ROM_PATH}" BASE.${ROM_EXT}
|
|
|
|
IMAGE=BASE.${ROM_EXT}
|
|
|
|
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
|
|
|
|
;;
|
|
|
|
|
2013-06-20 18:50:02 +02:00
|
|
|
--riivolution* )
|
2013-06-15 19:33:43 +02:00
|
|
|
RIIVOLUTION=${1/*=}
|
|
|
|
if [[ -e "${RIIVOLUTION}" ]]; then
|
2013-08-06 23:53:43 +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
|
|
|
|
;;
|
|
|
|
|
2013-06-22 19:15:29 +02:00
|
|
|
--patch* )
|
|
|
|
PATCH=${1/*=}
|
|
|
|
if [[ -e "${PATCH}" ]]; then
|
2013-08-06 23:53:43 +02:00
|
|
|
${UNP} "${PATCH}" >/dev/null
|
2013-06-22 19:15:29 +02:00
|
|
|
else
|
|
|
|
echo -e "PATCH patch ${PATCH} not found."
|
2013-10-12 10:37:29 +02:00
|
|
|
exit 21
|
2013-06-22 19:15:29 +02:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
|
2013-06-15 19:33:43 +02:00
|
|
|
--customid* )
|
|
|
|
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 )
|
2013-07-07 22:36:04 +02:00
|
|
|
PATCHIMAGE_RIIVOLUTION_DOWNLOAD=TRUE
|
2013-06-20 18:01:50 +02:00
|
|
|
;;
|
|
|
|
|
2013-06-20 18:15:08 +02:00
|
|
|
--soundtrack )
|
2014-05-11 21:57:19 +02:00
|
|
|
PATCHIMAGE_SOUNDTRACK_DOWNLOAD=TRUE
|
|
|
|
;;
|
|
|
|
|
|
|
|
--only-soundtrack )
|
|
|
|
PATCHIMAGE_SOUNDTRACK_DOWNLOAD=TRUE
|
|
|
|
ONLY_SOUNDTRACK=TRUE
|
2013-06-20 18:15:08 +02:00
|
|
|
;;
|
|
|
|
|
2013-06-15 19:33:43 +02:00
|
|
|
--version=* )
|
|
|
|
VERSION=${1/*=}
|
|
|
|
case ${VERSION} in
|
|
|
|
EURv1 )
|
|
|
|
REG_LETTER=P
|
|
|
|
;;
|
|
|
|
|
|
|
|
EURv2 )
|
|
|
|
REG_LETTER=P
|
|
|
|
;;
|
|
|
|
|
|
|
|
USAv1 )
|
|
|
|
REG_LETTER=E
|
|
|
|
;;
|
|
|
|
|
|
|
|
USAv2 )
|
|
|
|
REG_LETTER=E
|
|
|
|
;;
|
|
|
|
|
|
|
|
JPNv1 )
|
|
|
|
REG_LETTER=J
|
|
|
|
;;
|
|
|
|
|
|
|
|
* )
|
|
|
|
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 )
|
2013-07-07 22:36:04 +02:00
|
|
|
PATCHIMAGE_SHARE_SAVE=TRUE
|
2013-06-15 19:33:43 +02:00
|
|
|
;;
|
|
|
|
|
|
|
|
--game* )
|
|
|
|
GAME=${1/*=}
|
|
|
|
;;
|
|
|
|
|
2014-05-11 21:57:19 +02:00
|
|
|
--covers* )
|
|
|
|
PATCHIMAGE_COVER_DOWNLOAD=TRUE
|
|
|
|
;;
|
|
|
|
|
|
|
|
--only-covers* )
|
|
|
|
PATCHIMAGE_COVER_DOWNLOAD=TRUE
|
|
|
|
download_covers ${1/*=}
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
|
2013-07-01 22:23:32 +02:00
|
|
|
--banner=* )
|
|
|
|
BANNER=${1/*=}
|
|
|
|
BANNER_EXT=${BANNER//*./}
|
|
|
|
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 )
|
2013-07-07 22:36:04 +02:00
|
|
|
PATCHIMAGE_BANNER_DOWNLOAD=TRUE
|
2013-07-01 22:23:32 +02:00
|
|
|
;;
|
|
|
|
|
2016-07-01 21:58:50 +02:00
|
|
|
--xdelta=* )
|
|
|
|
XDELTA_PATH=${1/*=}
|
|
|
|
;;
|
|
|
|
|
|
|
|
--cpk=* )
|
|
|
|
CPK_PATH=${1/*=}
|
|
|
|
;;
|
|
|
|
|
2014-05-16 20:36:08 +02:00
|
|
|
--help | -h )
|
2016-05-16 17:21:53 +02:00
|
|
|
echo -e "patchimage ${PATCHIMAGE_VERSION} (${PATCHIMAGE_RELEASE})
|
2013-10-12 10:37:29 +02:00
|
|
|
|
2016-07-01 20:07:53 +02:00
|
|
|
(c) 2013-2016 Christopher Roy Bratusek <nano@jpberlin.de>
|
2013-10-12 10:37:29 +02:00
|
|
|
patchimage creates wbfs images from riivolution patches.
|
|
|
|
|
|
|
|
--game=<gamename/gameletter> | specify game you want to create
|
2013-06-22 19:15:29 +02:00
|
|
|
--iso/--rom=/home/test/<Image> | specify which ISO/ROM to use for building
|
|
|
|
--riivolution/--patch=<Patch> | specify path to Riivolution/Patch files
|
2013-06-15 19:33:43 +02:00
|
|
|
--version=EURv1,EURv2,USAv1,USAv2,JPNv1 | specify your game version
|
|
|
|
--customdid=SMNP02 | specify a custom ID to use for the game
|
|
|
|
--sharesave | let modified game share savegame with original game
|
2013-06-20 18:15:42 +02:00
|
|
|
--download | download riivolution patchfiles
|
2014-05-11 21:57:19 +02:00
|
|
|
--soundtrack | download soundtrack (if available)
|
|
|
|
--only-soundtrack | download soundtrack only (if available) and exit
|
|
|
|
--covers | download covers (if available)
|
|
|
|
--only-covers=SMNP02 | download covers only (if available)
|
2013-07-01 22:23:32 +02:00
|
|
|
--banner=<banner.bnr> | use a custom banner (riivolution games)
|
2016-07-01 21:58:50 +02:00
|
|
|
--download-banner | download a custom banner (if available)
|
|
|
|
--xdelta=<path> | path to xdelta patches
|
|
|
|
--cpk=<path> | path to unpatched xdelta patches"
|
2013-06-15 19:33:43 +02:00
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
xcount=$(($xcount+1))
|
|
|
|
done
|
|
|
|
|
|
|
|
}
|