code review, unification:

- rename CXI to ROM (makes --rom command line flag work for 3DS ROMs, too)
- rename CXI_MASK to ROM_MASK
- rename WII_GENERIC to GENERIC
- split functions in patchimage.sh
- other minor changes
This commit is contained in:
Christopher Roy Bratusek 2016-08-06 19:46:07 +02:00
parent b37dd75f84
commit 3f3894ddb0
18 changed files with 163 additions and 133 deletions

View File

@ -235,131 +235,134 @@ case ${GAME} in
esac
case ${GAME_TYPE} in
"RIIVOLUTION" )
show_notes
rm -rf "${WORKDIR}"
if [[ ${PATCHIMAGE_SOUNDTRACK_DOWNLOAD} == TRUE ]]; then
echo -e "\n*** A) download_soundtrack"
download_soundtrack
if [[ ${ONLY_SOUNDTRACK} == TRUE ]]; then
exit 0
fi
patchimage_riivolution () {
show_notes
rm -rf "${WORKDIR}"
if [[ ${PATCHIMAGE_SOUNDTRACK_DOWNLOAD} == TRUE ]]; then
echo -e "\n*** A) download_soundtrack"
download_soundtrack
if [[ ${ONLY_SOUNDTRACK} == TRUE ]]; then
exit 0
fi
fi
echo -e "\n*** 1) check_input_image"
check_input_image
echo "*** 2) check_input_image_special"
check_input_image_special
echo "*** 3) check_riivolution_patch"
check_riivolution_patch
echo -e "\n*** 1) check_input_image"
check_input_image
echo "*** 2) check_input_image_special"
check_input_image_special
echo "*** 3) check_riivolution_patch"
check_riivolution_patch
echo "*** 4) extract game"
${WIT} extract "${IMAGE}" "${WORKDIR}" --psel=DATA -q || exit 51
echo "*** 4) extract game"
${WIT} extract "${IMAGE}" "${WORKDIR}" --psel=DATA -q || exit 51
echo "*** 5) detect_game_version"
detect_game_version
rm -f "${GAMEID}".wbfs "${CUSTOMID}".wbfs
echo "*** 6) place_files"
place_files || exit 45
echo "*** 5) detect_game_version"
detect_game_version
rm -f "${GAMEID}".wbfs "${CUSTOMID}".wbfs
echo "*** 6) place_files"
place_files || exit 45
echo "*** 7) download_banner"
download_banner
echo "*** 8) apply_banner"
apply_banner
echo "*** 7) download_banner"
download_banner
echo "*** 8) apply_banner"
apply_banner
echo "*** 9) dolpatch"
dolpatch
echo "*** 9) dolpatch"
dolpatch
if [[ ${CUSTOMID} ]]; then
GAMEID="${CUSTOMID}"
fi
if [[ ${CUSTOMID} ]]; then
GAMEID="${CUSTOMID}"
fi
if [[ ${PATCHIMAGE_SHARE_SAVE} == "TRUE" ]]; then
TMD_OPTS=""
else
TMD_OPTS="--tt-id=K"
fi
if [[ ${PATCHIMAGE_SHARE_SAVE} == "TRUE" ]]; then
TMD_OPTS=""
else
TMD_OPTS="--tt-id=K"
fi
echo "*** 10) rebuild and store game"
"${WIT}" cp -o -q --disc-id="${GAMEID}" "${TMD_OPTS}" --name "${GAMENAME}" \
-B "${WORKDIR}" "${PATCHIMAGE_GAME_DIR}"/"${GAMEID}".wbfs || exit 51
echo "*** 10) rebuild and store game"
"${WIT}" cp -o -q --disc-id="${GAMEID}" "${TMD_OPTS}" --name "${GAMENAME}" \
-B "${WORKDIR}" "${PATCHIMAGE_GAME_DIR}"/"${GAMEID}".wbfs || exit 51
echo "*** 12) remove workdir"
rm -rf "${WORKDIR}"
echo "*** 12) remove workdir"
rm -rf "${WORKDIR}"
echo -e "\n >>> ${GAMENAME} saved as: ${PATCHIMAGE_GAME_DIR}/${GAMEID}.wbfs\n"
echo -e "\n >>> ${GAMENAME} saved as: ${PATCHIMAGE_GAME_DIR}/${GAMEID}.wbfs\n"
if [[ ${PATCHIMAGE_COVER_DOWNLOAD} == TRUE ]]; then
echo -e "*** Z) download_covers"
download_covers "${GAMEID}"
echo -e "\nCovers downloaded to ${PATCHIMAGE_COVER_DIR}"
fi
if [[ ${PATCHIMAGE_COVER_DOWNLOAD} == TRUE ]]; then
echo -e "*** Z) download_covers"
download_covers "${GAMEID}"
echo -e "\nCovers downloaded to ${PATCHIMAGE_COVER_DIR}"
fi
;;
}
"MKWIIMM")
show_notes
patchimage_mkwiimm () {
echo -e "\n*** 1) check_input_image"
check_input_image
echo -e "\n*** 2) download_wiimm"
download_wiimm
echo -e "\n*** 3) patch_wiimm"
patch_wiimm
;;
show_notes
echo -e "\n*** 1) check_input_image"
check_input_image
echo -e "\n*** 2) download_wiimm"
download_wiimm
echo -e "\n*** 3) patch_wiimm"
patch_wiimm
"WII_GENERIC")
show_notes
}
echo -e "\n*** 1) check_input_image"
check_input_image_special
echo -e "\n*** 2) pi_action"
pi_action
;;
patchimage_generic () {
"IPS" )
show_notes
check_input_rom
show_notes
echo -e "\n*** 1) check_input_image"
check_input_image_special
echo -e "\n*** 2) pi_action"
pi_action
if [[ -f ${PATCH} ]]; then
ext="${ROM/*.}"
cp "${ROM}" "${GAMENAME}.${ext}"
"${IPS}" a "${PATCH}" "${GAMENAME}.${ext}" || exit 51
else
echo -e "error: patch (${PATCH}) could not be found"
exit 21
fi
;;
}
"HANS" )
show_notes
echo -e "\n*** 1) check_input_rom"
if [[ ${HANS_MULTI_SOURCE} ]]; then
check_input_rom_special
else check_input_rom
fi
patchimage_ips () {
show_notes
check_input_rom
rm -rf romfs/ romfs.bin "${ROMFS}"
if [[ -f ${PATCH} ]]; then
ext="${ROM/*.}"
cp "${ROM}" "${GAMENAME}.${ext}"
"${IPS}" a "${PATCH}" "${GAMENAME}.${ext}" || exit 51
else
echo -e "error: patch (${PATCH}) could not be found"
exit 21
fi
}
echo -e "\n*** 2) check_hans_files"
check_hans_files
patchimage_hans () {
echo -e "\n*** 3) unpack_3dsrom"
unpack_3dsrom "${CXI}" || exit 51
show_notes
echo -e "\n*** 1) check_input_rom"
if [[ ${HANS_MULTI_SOURCE} ]]; then
check_input_rom_special
else check_input_rom
fi
echo -e "\n*** 4) unpack_3dsromfs"
unpack_3dsromfs romfs.bin || exit 51
rm -rf romfs/ romfs.bin "${ROMFS}"
echo -e "\n*** 5) patch_romfs"
patch_romfs
echo -e "\n*** 2) check_hans_files"
check_hans_files
echo -e "\n*** 6) repack_romfs"
repack_3dsromfs romfs/ "${ROMFS}" || exit 51
echo -e "\n*** 3) unpack_3dsrom"
unpack_3dsrom "${ROM}" || exit 51
mv "${ROMFS}" "${PATCHIMAGE_ROM_DIR}"
echo -e "\n*** 4) unpack_3dsromfs"
unpack_3dsromfs romfs.bin || exit 51
echo "
echo -e "\n*** 5) patch_romfs"
patch_romfs
echo -e "\n*** 6) repack_romfs"
repack_3dsromfs romfs/ "${ROMFS}" || exit 51
mv "${ROMFS}" "${PATCHIMAGE_ROM_DIR}"
echo "
*** succesfully created new romfs as \"${PATCHIMAGE_ROM_DIR}/${ROMFS}\"
"
@ -370,16 +373,43 @@ case ${GAME_TYPE} in
into the root of your sd card
"
}
patchimage_delta () {
show_notes
echo -e "\n*** 1) menu"
menu || exit 9
echo -e "\n*** 2) patch"
patch || exit 51
}
case ${GAME_TYPE} in
"RIIVOLUTION" )
patchimage_riivolution
;;
"MKWIIMM")
patchimage_mkwiimm
;;
"GENERIC")
patchimage_generic
;;
"IPS" )
patchimage_ips
;;
"HANS" )
patchimage_hans
;;
"DELTA" )
show_notes
echo -e "\n*** 1) menu"
menu || exit 9
echo -e "\n*** 2) patch"
patch || exit 51
patchimage_delta
;;
esac

View File

@ -4,8 +4,8 @@ GAMENAME="Bravely Second Uncensored"
GAME_TYPE=HANS
HANS_MULTI_SOURCE=TRUE
CXI_MASK_EUR="*000400000017[bB][bB]00*cxi"
CXI_MASK_USA="*000400000017[bB][aA]00*cxi"
ROM_MASK_EUR="*000400000017[bB][bB]00*cxi"
ROM_MASK_USA="*000400000017[bB][aA]00*cxi"
UNP_EXTRA_ARGS="-pAsia81"
@ -27,19 +27,19 @@ Supported Versions: US, EU
check_input_rom_special () {
GAME_VERSION=EUR
CXI_MASK=${CXI_MASK_EUR}
ROM_MASK=${ROM_MASK_EUR}
echo "<< trying EUR game version"
check_input_rom
if [[ ! ${CXI} ]]; then
if [[ ! ${ROM} ]]; then
GAME_VERSION=USA
CXI_MASK=${CXI_MASK_USA}
ROM_MASK=${ROM_MASK_USA}
echo "<< trying USA game version"
check_input_rom
fi
if [[ ! ${CXI} ]]; then
if [[ ! ${ROM} ]]; then
echo -e "\nneither EUR nor USA version of Bravely Second found."
exit 15
fi

View File

@ -240,16 +240,16 @@ check_input_image () {
check_input_rom () {
x=5
if [[ ! ${CXI} ]]; then
CXI=$(find . -name "${CXI_MASK}" | sed -e 's,./,,')
if [[ -f ${CXI} ]]; then
if [[ ! ${ROM} ]]; then
ROM=$(find . -name "${ROM_MASK}" | sed -e 's,./,,')
if [[ -f ${ROM} ]]; then
x=6
CXI="${CXI}"
ROM="${ROM}"
else
CXI=$(find "${PATCHIMAGE_3DS_DIR}" -name "${CXI_MASK}")
if [[ -f ${CXI} ]]; then
ROM=$(find "${PATCHIMAGE_3DS_DIR}" -name "${ROM_MASK}")
if [[ -f ${ROM} ]]; then
x=7
CXI="${CXI}"
ROM="${ROM}"
else
if [[ ! ${HANS_MULTI_SOURCE} ]]; then
echo -e "error: could not find suitable ROM, specify using --rom"
@ -475,7 +475,7 @@ while [[ $xcount -lt $pcount ]]; do
ROM_PATH="${1/*=}"
if [[ -f "${ROM_PATH}" ]]; then
IMAGE="${ROM_PATH}"
ROM="${ROM_PATH}"
else
echo -e "ROM not found"
exit 15

View File

@ -1,6 +1,6 @@
#!/bin/bash
GAME_TYPE="WII_GENERIC"
GAME_TYPE="GENERIC"
GAMENAME="Kirby's Adventure Wii"
WBFS_MASK="SUK[PUJ]01"
PATH_HERO="files/g3d/step/chara/hero/"

View File

@ -1,6 +1,6 @@
#!/bin/bash
GAME_TYPE="WII_GENERIC"
GAME_TYPE="GENERIC"
GAMENAME="Mario Kart Wiimm"
FSZS="files/Scene/UI/Font.szs"
WBFS_MASK="RMC[PUJ]01"

View File

@ -1,6 +1,6 @@
#!/bin/bash
GAME_TYPE="WII_GENERIC"
GAME_TYPE="GENERIC"
GAMENAME="Mario Kart Wiimm"
CSZS="files/Race/Common.szs"
CSZD="files/Race/Common.d"

View File

@ -1,6 +1,6 @@
#!/bin/bash
GAME_TYPE="WII_GENERIC"
GAME_TYPE="GENERIC"
GAMENAME="Mario Kart Wiimm"
show_notes () {

View File

@ -1,7 +1,7 @@
#!/bin/bash
DOWNLOAD_LINK="http://download.wiimm.de/wiimmfi/patcher/mkw-wiimmfi-patcher-v3.7z"
GAME_TYPE="WII_GENERIC"
GAME_TYPE="GENERIC"
GAMENAME="Mario Kart Wiimmfi"
show_notes () {

View File

@ -1,6 +1,6 @@
#!/bin/bash
GAME_TYPE="WII_GENERIC"
GAME_TYPE="GENERIC"
GAMENAME="New Super Mario Bros. Wii"
show_notes () {

View File

@ -6,7 +6,7 @@ RIIVOLUTION_DIR="Eternal X V1.3/Game Files/"
GAMENAME="Pokemon Eternal X"
GAME_TYPE=HANS
CXI_MASK="*0004000000055[dD]00*cxi"
ROM_MASK="*0004000000055[dD]00*cxi"
ROMFS="EternalX.romfs"
show_notes () {

View File

@ -6,7 +6,7 @@ RIIVOLUTION_DIR="Neo X and Y Files/Pokemon NeoXY1.4/Installation hub/data/"
GAMENAME="Pokemon Neo X"
GAME_TYPE=HANS
CXI_MASK="*0004000000055[dD]00*cxi"
ROM_MASK="*0004000000055[dD]00*cxi"
ROMFS="neox.romfs"
DATA="${PATCHIMAGE_DATA_DIR}/NeoX"

View File

@ -6,7 +6,7 @@ RIIVOLUTION_DIR="Neo X and Y Files/Pokemon NeoXY1.4/Installation hub/data/"
GAMENAME="Pokemon Neo Y"
GAME_TYPE=HANS
CXI_MASK="*0004000000055[eE]00*cxi"
ROM_MASK="*0004000000055[eE]00*cxi"
ROMFS="neoy.romfs"
DATA="${PATCHIMAGE_DATA_DIR}/NeoY"

View File

@ -6,7 +6,7 @@ RIIVOLUTION_DIR="RRSSFiles 18-11-2015"
GAMENAME="Pokemon Rising Ruby"
GAME_TYPE=HANS
CXI_MASK="*000400000011[cC]400*cxi"
ROM_MASK="*000400000011[cC]400*cxi"
ROMFS="RisingRuby.romfs"
DATA="${PATCHIMAGE_DATA_DIR}/RisingRuby/"

View File

@ -6,7 +6,7 @@ RIIVOLUTION_DIR="Rutile Ruby - Distribution"
GAMENAME="Pokemon Rutile Ruby"
GAME_TYPE=HANS
CXI_MASK="*000400000011[cC]400*cxi"
ROM_MASK="*000400000011[cC]400*cxi"
ROMFS="rruby.romfs"
DATA="${RIIVOLUTION_DIR}/HansPack/"

View File

@ -6,7 +6,7 @@ RIIVOLUTION_DIR="RRSSFiles 18-11-2015"
GAMENAME="Pokemon Sinking Sapphire"
GAME_TYPE=HANS
CXI_MASK="*000400000011[cC]500*cxi"
ROM_MASK="*000400000011[cC]500*cxi"
ROMFS="SinkingSapphire.romfs"
DATA="${PATCHIMAGE_DATA_DIR}/SinkingSapphire/"

View File

@ -6,7 +6,7 @@ RIIVOLUTION_DIR="Star Sapphire - Distribution"
GAMENAME="Pokemon Star Sapphire"
GAME_TYPE=HANS
CXI_MASK="*000400000011[cC]500*cxi"
ROM_MASK="*000400000011[cC]500*cxi"
ROMFS="ssapphire.romfs"
DATA="${RIIVOLUTION_DIR}/HansPack/"

View File

@ -6,7 +6,7 @@ RIIVOLUTION_DIR="Wilting Y V1.3/Game Files/"
GAMENAME="Pokemon Wilting Y"
GAME_TYPE=HANS
CXI_MASK="*0004000000055[eE]00*cxi"
ROM_MASK="*0004000000055[eE]00*cxi"
ROMFS="WiltingY.romfs"
show_notes () {

View File

@ -1,7 +1,7 @@
#!/bin/bash
DOWNLOAD_LINK="http://download.wiimm.de/wiimmfi/patcher/wiimmfi-patcher-v3.7z"
GAME_TYPE="WII_GENERIC"
GAME_TYPE="GENERIC"
GAMENAME="Mario Kart Wiimmfi"
show_notes () {