2013-06-15 19:33:43 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2013-07-04 21:39:01 +02:00
|
|
|
TMP_FILES=(Another nsmb.d XmasNewer NewerFiles "Newer*Summer*Sun" \
|
|
|
|
ZPW_1.1.ips Epic_Super_Bowser_World_v1.00 Riivolution Koopa \
|
2013-07-06 18:25:11 +02:00
|
|
|
Cannon_Super_Mario_Bros._Wii_v1.1 riivolution "Readme*" "*.txt" "*.rtf" \
|
2013-08-06 22:30:04 +02:00
|
|
|
"*.dol" "*.elf" nsmb "Retro Remix" WinterMoon WMManual.rtf NSMBW3 )
|
2013-07-07 22:14:05 +02:00
|
|
|
|
2013-07-07 22:36:04 +02:00
|
|
|
PATCHIMAGE_RIIVOLUTION_DIR="."
|
|
|
|
PATCHIMAGE_WBFS_DIR="."
|
|
|
|
PATCHIMAGE_AUDIO_DIR="."
|
|
|
|
|
2013-07-07 22:14:05 +02:00
|
|
|
if [[ -e $HOME/.patchimage.rc ]]; then
|
|
|
|
source $HOME/.patchimage.rc
|
|
|
|
fi
|
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
|
2013-06-15 19:33:43 +02:00
|
|
|
else
|
2013-08-06 23:53:43 +02:00
|
|
|
SUFFIX=32
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $(which wit) ]]; then
|
|
|
|
WIT=$(which wit)
|
|
|
|
else
|
|
|
|
WIT=${PATCHIMAGE_TOOLS_DIR}/wit.${SUFFIX}
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $(which applyppf3) ]]; then
|
|
|
|
PPF=$(which applyppf3)
|
|
|
|
else
|
|
|
|
PPF=${PATCHIMAGE_TOOLS_DIR}/applyppf3.${SUFFIX}
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $(which uips) ]]; then
|
|
|
|
IPS=$(which uips)
|
|
|
|
else
|
|
|
|
IPS=${PATCHIMAGE_TOOLS_DIR}/uips.${SUFFIX}
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $(which unp) ]]; then
|
|
|
|
UNP=$(which unp)
|
|
|
|
else
|
|
|
|
UNP=${PATCHIMAGE_TOOLS_DIR}/unp
|
2013-06-15 19:33:43 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
cleanup () {
|
|
|
|
|
2013-07-01 22:23:32 +02:00
|
|
|
rm -rf ${TMP_FILES[@]} *.wbfs *.bnr
|
2013-06-15 19:33:43 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ask_game () {
|
|
|
|
|
2013-06-20 21:30:26 +02:00
|
|
|
echo -e \
|
|
|
|
"************************************************
|
2013-06-20 18:39:11 +02:00
|
|
|
patchimage.sh
|
2013-06-15 19:33:43 +02:00
|
|
|
|
|
|
|
Enter Letter for the Game you want to create:
|
2013-06-15 19:58:07 +02:00
|
|
|
A NewerSMB
|
2013-06-20 21:03:40 +02:00
|
|
|
B Newer Summer Sun
|
|
|
|
C AnotherSMB
|
2013-06-20 21:22:39 +02:00
|
|
|
D Newer: Holiday Special
|
2013-07-02 21:19:52 +02:00
|
|
|
E Cannon Super Mario Bros.
|
2013-07-02 20:20:20 +02:00
|
|
|
F Epic Super Bowser World
|
2013-07-03 16:44:13 +02:00
|
|
|
G Koopa Country
|
2013-07-06 18:25:11 +02:00
|
|
|
H New Super Mario Bros. 4
|
2013-07-07 09:42:41 +02:00
|
|
|
I New Super Mario Bros. Wii Retro Remix
|
2013-08-06 09:04:27 +02:00
|
|
|
J Super Mario: Mushroom Adventure PLUS - Winter Moon
|
2013-08-06 09:34:30 +02:00
|
|
|
K NSMBW3: The Final Levels
|
2013-06-22 19:30:30 +02:00
|
|
|
|
2013-07-06 18:25:11 +02:00
|
|
|
1 The Legend of Zelda: Parallel Worlds
|
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 () {
|
|
|
|
|
|
|
|
if [[ ${SOUNDTRACK} ]]; then
|
|
|
|
if [[ ${SOUNDTRACK_LINK} ]]; then
|
2013-07-07 22:36:04 +02:00
|
|
|
wget --no-check-certificate "${PATCHIMAGE_AUDIO_DIR}"/"${SOUNDTRACK_LINK}" -O "${PATCHIMAGE_RIIVOLUTION_DIR}"/${SOUNDTRACK_ZIP}
|
|
|
|
echo -e "\n >>> soundtrack saved to\n >>> ${PATCHIMAGE_AUDIO_DIR}/${SOUNDTRACK_ZIP}"
|
2013-06-20 18:15:08 +02:00
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
echo -e "no soundtrack for ${GAME} available."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
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
|
|
|
|
wget --no-check-certificate "${CUSTOM_BANNER}" -O "${PATCHIMAGE_RIIVOLUTION_DIR}"/${GAMEID}-custom-banner.bnr
|
|
|
|
fi
|
|
|
|
BANNER="${PATCHIMAGE_RIIVOLUTION_DIR}"/${GAMEID}-custom-banner.bnr
|
2013-07-01 22:23:32 +02:00
|
|
|
else
|
|
|
|
echo "no custom banner for ${GAMENAME} available, not modifying"
|
|
|
|
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}"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
}
|
|
|
|
|
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-06-15 19:33:43 +02:00
|
|
|
check_input_image () {
|
|
|
|
|
|
|
|
if [[ ! ${IMAGE} ]]; then
|
2013-06-20 20:35:34 +02:00
|
|
|
if [[ -f BASE.wbfs ]]; then
|
|
|
|
IMAGE=BASE.wbfs
|
|
|
|
elif [[ -f BASE.iso ]]; then
|
|
|
|
IMAGE=BASE.iso
|
2013-06-15 19:33:43 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-08-06 23:53:43 +02:00
|
|
|
check_input_image_nsmb () {
|
|
|
|
|
|
|
|
if [[ ! ${IMAGE} ]]; then
|
|
|
|
if test -f SMN?01.wbfs; then
|
|
|
|
IMAGE=$(eval echo SMN?01.wbfs)
|
|
|
|
elif test -f SMN?01.iso; then
|
|
|
|
IMAGE=$(eval echo SMN?01.iso)
|
|
|
|
elif test -f ${PATCHIMAGE_WBFS_DIR}/SMN?01.iso; then
|
|
|
|
IMAGE=$(eval echo ${PATCHIMAGE_WBFS_DIR}/SMN?01.iso)
|
|
|
|
elif test -f ${PATCHIMAGE_WBFS_DIR}/SMN?01.wbfs; then
|
|
|
|
IMAGE=$(eval echo ${PATCHIMAGE_WBFS_DIR}/SMN?01.wbfs)
|
|
|
|
else
|
|
|
|
echo -e "please specify image to use with --iso=<path>"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-06-15 19:33:43 +02:00
|
|
|
check_riivolution_patch () {
|
|
|
|
|
2013-08-06 22:52:36 +02:00
|
|
|
if [[ ! -d ${RIIVOLUTION_DIR} ]]; then
|
|
|
|
if [[ -f "${PATCHIMAGE_RIIVOLUTION_DIR}"/"${RIIVOLUTION_ZIP}" ]]; then
|
2013-08-06 23:53:43 +02:00
|
|
|
${UNP} "${PATCHIMAGE_RIIVOLUTION_DIR}"/"${RIIVOLUTION_ZIP}" >/dev/null
|
2013-08-06 22:52:36 +02:00
|
|
|
elif [[ ${PATCHIMAGE_RIIVOLUTION_DOWNLOAD} == "TRUE" ]]; then
|
|
|
|
if [[ ${DOWNLOAD_LINK} ]]; then
|
|
|
|
if [[ ! -f "${PATCHIMAGE_RIIVOLUTION_DIR}"/"${RIIVOLUTION_ZIP}" ]]; then
|
|
|
|
wget --no-check-certificate ${DOWNLOAD_LINK} -O "${PATCHIMAGE_RIIVOLUTION_DIR}"/"${RIIVOLUTION_ZIP}"
|
2013-08-06 23:53:43 +02:00
|
|
|
${UNP} "${PATCHIMAGE_RIIVOLUTION_DIR}"/"${RIIVOLUTION_ZIP}" >/dev/null
|
2013-08-06 22:52:36 +02:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "no download link for ${GAMENAME} available."
|
|
|
|
exit 1
|
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-07-03 16:44:13 +02:00
|
|
|
exit 1
|
2013-06-20 21:31:41 +02:00
|
|
|
fi
|
2013-06-15 19:33:43 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
optparse () {
|
|
|
|
|
|
|
|
xcount=0
|
|
|
|
pcount=$#
|
|
|
|
|
|
|
|
while [[ $xcount -lt $pcount ]]; do
|
|
|
|
case $1 in
|
|
|
|
|
|
|
|
--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-06-20 21:30:26 +02:00
|
|
|
exit 1
|
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"
|
|
|
|
exit 1
|
|
|
|
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-06-20 21:28:40 +02:00
|
|
|
exit 1
|
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."
|
|
|
|
exit 1
|
|
|
|
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"
|
|
|
|
exit 1
|
|
|
|
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 )
|
|
|
|
SOUNDTRACK=TRUE
|
|
|
|
;;
|
|
|
|
|
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}"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
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/*=}
|
|
|
|
;;
|
|
|
|
|
2013-07-01 21:47:36 +02:00
|
|
|
--clean )
|
|
|
|
cleanup
|
|
|
|
exit $?
|
|
|
|
;;
|
|
|
|
|
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!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
|
|
|
|
--download-banner )
|
2013-07-07 22:36:04 +02:00
|
|
|
PATCHIMAGE_BANNER_DOWNLOAD=TRUE
|
2013-07-01 22:23:32 +02:00
|
|
|
;;
|
|
|
|
|
2013-06-15 19:33:43 +02:00
|
|
|
"" | --help )
|
|
|
|
echo -e "create wbfs images from riivolution patches.\n
|
|
|
|
***** using this script is only allowed, if you own an original copy of the game.
|
|
|
|
***** if you don't, no one can be blamed but you. Shame on you.\n
|
2013-08-06 09:04:27 +02:00
|
|
|
--game={NewerSMB;NewerSummerSun;AnotherSMB;HolidaySpecial;ParallelWorlds...}
|
2013-06-20 21:22:39 +02:00
|
|
|
| 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:01:50 +02:00
|
|
|
--clean | cleanup the build-directory
|
2013-06-20 18:15:42 +02:00
|
|
|
--download | download riivolution patchfiles
|
2013-07-01 22:23:32 +02:00
|
|
|
--soundtrack | download soundtrack (if available) and exit
|
|
|
|
--banner=<banner.bnr> | use a custom banner (riivolution games)
|
|
|
|
--download-banner | download a custom banner (if available)"
|
2013-06-15 19:33:43 +02:00
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
xcount=$(($xcount+1))
|
|
|
|
done
|
|
|
|
|
|
|
|
}
|