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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -6,7 +6,7 @@ RIIVOLUTION_DIR="Eternal X V1.3/Game Files/"
GAMENAME="Pokemon Eternal X" GAMENAME="Pokemon Eternal X"
GAME_TYPE=HANS GAME_TYPE=HANS
CXI_MASK="*0004000000055[dD]00*cxi" ROM_MASK="*0004000000055[dD]00*cxi"
ROMFS="EternalX.romfs" ROMFS="EternalX.romfs"
show_notes () { 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" GAMENAME="Pokemon Neo X"
GAME_TYPE=HANS GAME_TYPE=HANS
CXI_MASK="*0004000000055[dD]00*cxi" ROM_MASK="*0004000000055[dD]00*cxi"
ROMFS="neox.romfs" ROMFS="neox.romfs"
DATA="${PATCHIMAGE_DATA_DIR}/NeoX" 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" GAMENAME="Pokemon Neo Y"
GAME_TYPE=HANS GAME_TYPE=HANS
CXI_MASK="*0004000000055[eE]00*cxi" ROM_MASK="*0004000000055[eE]00*cxi"
ROMFS="neoy.romfs" ROMFS="neoy.romfs"
DATA="${PATCHIMAGE_DATA_DIR}/NeoY" DATA="${PATCHIMAGE_DATA_DIR}/NeoY"

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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