patchimage/scripts/kirbywii.sh

112 lines
2.7 KiB
Bash
Raw Normal View History

#!/bin/bash
GAME_TYPE="GENERIC"
2016-08-05 21:09:04 +02:00
GAMENAME="Kirby's Adventure Wii"
WBFS_MASK="SUK[PUJ]01"
PATH_HERO="files/g3d/step/chara/hero/"
show_notes () {
echo -e \
"************************************************
2016-08-05 21:09:04 +02:00
${GAMENAME}
Base Image: Kirby's Adventure Wii (SUK?01)
Supported Versions: EUR, JAP, USA
************************************************"
}
check_input_image_special () {
check_input_image
}
2014-05-16 19:34:12 +02:00
exchange_kirby () {
cp workdir/"${PATH_HERO}"/kirby/base/"${1}".brres.cmp{,_tmp}
cp workdir/"${PATH_HERO}"/kirby/base/Pink.brres.cmp \
workdir/"${PATH_HERO}"/kirby/base/"${1}".brres.cmp
mv workdir/"${PATH_HERO}"/kirby/base/"${1}".brres.cmp_tmp \
workdir/"${PATH_HERO}"/kirby/base/Pink.brres.cmp
2014-05-16 19:34:12 +02:00
}
exchange_hero () {
cp workdir/"${PATH_HERO}"/"${1}"/base/Default.brres.cmp \
workdir/"${PATH_HERO}"/kirby/base/Pink.brres.cmp_temp
cp workdir/"${PATH_HERO}"/kirby/base/Pink.brres.cmp \
workdir/"${PATH_HERO}"/"${1}"/base/Default.brres.cmp
mv workdir/"${PATH_HERO}"/kirby/base/Pink.brres.cmp{_temp,}
for brres in workdir/"${PATH_HERO}"/"${1}"/normal/*.cmp ; do
xfile="${brres##*/}"
cp "${brres}" workdir/"${PATH_HERO}"/kirby/normal/"${xfile}"_temp
cp workdir/"${PATH_HERO}"/kirby/normal/"${xfile}" \
workdir/"${PATH_HERO}"/"${1}"/normal/
mv workdir/"${PATH_HERO}"/kirby/normal/"${xfile}"{_temp,}
2014-05-16 19:34:12 +02:00
done
}
pi_action () {
echo "Choose character for first player
1 Kirby (blue)
2 Kirby (yellow)
3 Kirby (green)
*** options 4 to 6 may crash the game upon start ***
4 King DeDeDe
5 MetaKnight
6 WaddleDee
7 Restore to original
type in a number."
read -r ID
[[ ${ID} != [0-9] ]] && echo "invalid number provided from user-input." && exit 1
rm -rf workdir
2014-05-16 19:34:12 +02:00
echo -e "\n*** 3) extracting image"
"${WIT}" extract "${IMAGE}" --psel=data -d workdir -q || exit 51
if [[ ! -d ${PATCHIMAGE_RIIVOLUTION_DIR}/hero/ ]]; then
2014-05-16 19:34:12 +02:00
echo "*** 4) this is the first run, so backing up all characters
(in ${PATCHIMAGE_RIIVOLUTION_DIR}) for future customizations"
cp -r workdir/"${PATH_HERO}"/ "${PATCHIMAGE_RIIVOLUTION_DIR}"
else
2014-05-16 19:34:12 +02:00
echo "*** 4) restoring original characters"
cp -r "${PATCHIMAGE_RIIVOLUTION_DIR}"/hero/* workdir/"${PATH_HERO}"/
fi
REG=$(gawk '/^SUK/{print $3}' <("${WIT}" ll "${IMAGE}"))
case ${REG} in
PAL) REG=P ;;
NTSC-J) REG=J ;;
NTSC-U) REG=E ;;
esac
[[ ${ID} != 7 ]] && echo "*** 5) exchanging characters"
case ${ID} in
2014-05-16 19:34:12 +02:00
1) exchange_kirby Blue ;;
2) exchange_kirby Yellow ;;
3) exchange_kirby Green ;;
4) exchange_hero dedede ;;
5) exchange_hero meta ;;
6) exchange_hero dee ;;
esac
2014-05-16 19:34:12 +02:00
echo "*** 6) rebuilding the game "
echo " (storing game in ${PATCHIMAGE_GAME_DIR}/SUK${REG}01.wbfs)"
"${WIT}" cp -o -q -B workdir "${PATCHIMAGE_GAME_DIR}"/SUK"${REG}"01.wbfs || exit 51
rm -rf workdir
}