forked from Nanolx/patchimage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
patchimage.sh
executable file
·270 lines (209 loc) · 5.57 KB
/
patchimage.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
#!/bin/bash
#
# create wbfs image from riivolution patch
#
# Christopher Roy Bratusek <[email protected]>
#
# License: GPL v3
if [[ -d ${PWD}/script.d ]]; then
PATCHIMAGE_SCRIPT_DIR=${PWD}/script.d
PATCHIMAGE_PATCH_DIR=${PWD}/patches
PATCHIMAGE_TOOLS_DIR=${PWD}/tools
else
PATCHIMAGE_SCRIPT_DIR=/usr/share/patchimage/script.d
PATCHIMAGE_PATCH_DIR=/usr/share/patchimage/patches
PATCHIMAGE_TOOLS_DIR=/usr/share/patchimage/tools
fi
PATCHIMAGE_RIIVOLUTION_DIR=${PWD}
PATCHIMAGE_WBFS_DIR=${PWD}
PATCHIMAGE_AUDIO_DIR=${PWD}
PATCHIMAGE_GAME_DIR=${PWD}
PATCHIMAGE_COVER_DIR=${PWD}
if [[ -e $HOME/.patchimage.rc ]]; then
source $HOME/.patchimage.rc
fi
source ${PATCHIMAGE_SCRIPT_DIR}/common.sh
check_directories
setup_tools
optparse "${@}"
if [[ ! ${GAME} ]]; then
ask_game
fi
case ${GAME} in
NSMB1 | NewerSMB | NewerSMBW )
source ${PATCHIMAGE_SCRIPT_DIR}/newersmb.sh
;;
NSMB2 | NewerSummerSun )
source ${PATCHIMAGE_SCRIPT_DIR}/newersummersun.sh
;;
NSMB3 | ASMBW | AnotherSMBW )
source ${PATCHIMAGE_SCRIPT_DIR}/anothersmb.sh
;;
NSMB4 | HolidaySpecial | "Newer: Holiday Special" )
source ${PATCHIMAGE_SCRIPT_DIR}/newerholiday.sh
;;
NSMB5 | Cannon | "Cannon SMBW" )
source ${PATCHIMAGE_SCRIPT_DIR}/cannon.sh
;;
NSMB6 | ESBW | "Epic Super Bowser World" )
source ${PATCHIMAGE_SCRIPT_DIR}/epicbowserworld.sh
;;
NSMB7 | Koopa | "Koopa Country" )
source ${PATCHIMAGE_SCRIPT_DIR}/koopacountry.sh
;;
NSMB8 | "New Super Mario Bros. 4" )
source ${PATCHIMAGE_SCRIPT_DIR}/nsmbw4.sh
;;
NSMB9 | Retro | "Retro Remix" )
source ${PATCHIMAGE_SCRIPT_DIR}/retroremix.sh
;;
NSMB10 | WinterMoon | "Super Mario: Mushroom Adventure PLUS - Winter Moon" )
source ${PATCHIMAGE_SCRIPT_DIR}/wintermoon.sh
;;
NSMB11 | NSMBW3 | "NSMBW3: The Final Levels" )
source ${PATCHIMAGE_SCRIPT_DIR}/nsmbw3.sh
;;
NSMB12 | SMV | "Super Mario Vacation" )
source ${PATCHIMAGE_SCRIPT_DIR}/summervacation.sh
;;
NSMB13 | ASLM | "Awesomer Super Luigi Mini" )
source ${PATCHIMAGE_SCRIPT_DIR}/awesomersuperluigi.sh
;;
NSMB14 | Sykland )
source ${PATCHIMAGE_SCRIPT_DIR}/skyland.sh
;;
NSMB15 | RVLution )
source ${PATCHIMAGE_SCRIPT_DIR}/rvlution.sh
;;
NSMB16 | Midi )
source ${PATCHIMAGE_SCRIPT_DIR}/midissupermariowii.sh
;;
NSMB17 | DarkUmbra )
source ${PATCHIMAGE_SCRIPT_DIR}/darkumbrasmb.sh
;;
NSMB18 | NewerApocalypse )
source ${PATCHIMAGE_SCRIPT_DIR}/newerapocalypse.sh
;;
NSMB19 | LuigisSuperYoshiBros )
source ${PATCHIMAGE_SCRIPT_DIR}/luigissuperyoshibros.sh
;;
NSMB20 | NewerFallingLeaf )
source ${PATCHIMAGE_SCRIPT_DIR}/newerfallingleaf.sh
;;
NSMB21 | DevilMarioWinterSpecial )
source ${PATCHIMAGE_SCRIPT_DIR}/devilmariowinterspecial.sh
;;
NSMB22 | NewSMBWOtherWorld )
source ${PATCHIMAGE_SCRIPT_DIR}/newsmbwotherworld.sh
;;
NSMB99 | NSMBWCharacters )
source ${PATCHIMAGE_SCRIPT_DIR}/nsmbw_characters.sh
;;
MKW1 | Wiimmfi )
source ${PATCHIMAGE_SCRIPT_DIR}/wiimmfi.sh
;;
MKW2 | Wiimmpatch )
source ${PATCHIMAGE_SCRIPT_DIR}/wiimmfi_generic.sh
;;
MKW3 | Mkwiimm )
source ${PATCHIMAGE_SCRIPT_DIR}/mkwiimm.sh
;;
MKW4 | MkwiimmItems )
source ${PATCHIMAGE_SCRIPT_DIR}/mkwiimm_items.sh
;;
MKW5 | MkwiimmFonts )
source ${PATCHIMAGE_SCRIPT_DIR}/mkwiimm_fonts.sh
;;
MKW6 | MkwiimmKarts )
source ${PATCHIMAGE_SCRIPT_DIR}/mkwiimm_karts.sh
;;
KAW1 | Kirby )
source ${PATCHIMAGE_SCRIPT_DIR}/kirbywii.sh
;;
ZEL1 | ParallelWorlds | "The Legend of Zelda: Parallel Worlds" )
source ${PATCHIMAGE_SCRIPT_DIR}/parallelworlds.sh
;;
* )
echo -e "specified Game ${GAME} not recognized"
exit 9
;;
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
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 "*** 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 "*** 7) download_banner"
download_banner
echo "*** 8) apply_banner"
apply_banner
echo "*** 9) dolpatch"
dolpatch
if [[ ${CUSTOMID} ]]; then
GAMEID=${CUSTOMID}
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 "*** 12) remove workdir"
rm -rf ${WORKDIR}
echo -e "\n >>> ${GAMENAME} saved as: ${PATCHIMAGE_GAME_DIR}/${GAMEID}.wbfs\n"
if [[ ${PATCHIMAGE_COVER_DOWNLOAD} == TRUE ]]; then
echo -e "\n*** Z) download_covers"
download_covers ${GAMEID}
fi
;;
"MKWIIMM")
show_notes
echo -e "\n*** 1) check_input_image"
check_input_image
echo -e "\n*** 2) check_input_image_special"
check_input_image_special
echo -e "\n*** 3) download_wiimm"
download_wiimm
echo -e "\n*** 4) patch_wiimm"
patch_wiimm
;;
"WII_GENERIC")
show_notes
echo -e "\n*** 1) check_input_image"
check_input_image
echo -e "\n*** 2) pi_action"
pi_action
;;
"IPS" )
show_notes
check_input_rom
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"
fi
;;
esac