drag&drop.bat 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  1. @ECHO off
  2. MODE 80,30
  3. CLS
  4. echo.
  5. echo ----- SMG1 Mod ISO Builder (v0.4)
  6. echo ----- By Humming Owl
  7. echo.
  8. :: ===============================
  9. :: Get to the path the BAT file is
  10. :: ===============================
  11. cd %~dp0
  12. :: ================
  13. :: mods data storage
  14. :: ================
  15. call .\tools\mods_data.bat
  16. :: =============================
  17. :: actions before starting patch
  18. :: =============================
  19. if exist ".\savefiles" (rmdir /s /q ".\savefiles")
  20. if exist ".\temp" (rmdir /s /q ".\temp")
  21. if not exist ".\mods" (mkdir ".\mods")
  22. for /d %%a in (".\mods\*") do rd "%%a" /q /s
  23. if exist ".\*.tmp" (del /S *.tmp >nul)
  24. :: ===================================================
  25. :: Key command to work with variables inside variables
  26. :: ===================================================
  27. SETLOCAL EnableDelayedExpansion
  28. :: =====
  29. :: Tools
  30. :: =====
  31. set WGET=tools\wget.exe
  32. set EXTRACT=tools\7z.exe
  33. set PATCH=tools\patch.exe
  34. set WIT=tools\wit.exe
  35. :: ==========
  36. :: check_file
  37. :: ==========
  38. if not "%~x1" == ".iso" (
  39. if not "%~x1" == ".wbfs" (
  40. echo.
  41. echo File dropped IS NOT ISO/WBFS.
  42. echo Verify file and try again.
  43. echo.
  44. echo Press any key to exit.
  45. echo.
  46. pause >nul
  47. exit
  48. )
  49. )
  50. %WIT% verify --test --quiet "%~f1"
  51. if %ERRORLEVEL% NEQ 0 (
  52. echo.
  53. echo File dropped is ISO/WBFS, but not a valid one.
  54. echo Verify file and try again.
  55. echo.
  56. echo Press any key to exit.
  57. echo.
  58. pause >nul
  59. exit
  60. )
  61. echo.
  62. echo File dropped IS a valid ISO/WBFS.
  63. FOR /F "tokens=*" %%g IN ('%WIT% ID6 "%~f1"') do (set og_gameid=%%g)
  64. if not "%og_gameid%" == "RMGE01" (
  65. if not "%og_gameid%" == "RMGP01" (
  66. if not "%og_gameid%" == "RMGJ01" (
  67. if not "%og_gameid%" == "RMGK01" (
  68. echo But is not an original SMG1 file.
  69. echo Verify the file and try again.
  70. echo.
  71. echo Press any key to exit.
  72. echo.
  73. pause >nul
  74. exit
  75. )
  76. )
  77. )
  78. )
  79. :: ============
  80. :: region check
  81. :: ============
  82. if "%og_gameid%" == "RMGE01" (set reg=e)
  83. if "%og_gameid%" == "RMGP01" (set reg=p)
  84. if "%og_gameid%" == "RMGJ01" (set reg=j)
  85. if "%og_gameid%" == "RMGK01" (set reg=k)
  86. :: ============
  87. echo And its an original SMG1 file.
  88. echo Ready to go.
  89. echo.
  90. echo Press any key if you are ready.
  91. echo.
  92. pause
  93. CLS
  94. :: ==================
  95. :: SMG1 Rom Hack List
  96. :: ==================
  97. echo.
  98. echo --- SMG1 Hack list:
  99. echo.
  100. echo 1. Kaizo Mario Galaxy (v1.2)
  101. echo 2. Super Mario Galaxy: Transformationless Challenge (v1.0.1)
  102. echo 3. Super Mario Galaxy: The Green Stars (v1.1) (has some issues)
  103. echo 4. Super Mario Galaxy: The Kaizo Green Stars (v1.6.1)
  104. echo 5. Super Mario Galaxy: Underwater Edition
  105. echo 6. Super Mario Galaxy: No Gravity Edition (v1.0)
  106. echo 7. Super Mario Galaxy: Cosmic Caos (v1.3.5)
  107. echo 8. Super Mario Galaxy: Daredevil Challenge
  108. echo 9. Super Mario Galaxy: The Green Star Festival (v1.1 - E/P/J/K/W)
  109. echo 10. Super Mario Galaxy Anti Piracy (v1.0 - E/P)
  110. echo 11. Superstar Mario Galaxy (2023 - E/P)
  111. echo.
  112. set /P apply_mod=Select Mod number to apply to ISO/WBFS image:
  113. if %apply_mod%==1 (set mod=KMG1)
  114. if %apply_mod%==2 (set mod=SMG1TC)
  115. if %apply_mod%==3 (set mod=SMG1TGS)
  116. if %apply_mod%==4 (set mod=SMG1TKGS)
  117. if %apply_mod%==5 (set mod=SMG1UE)
  118. if %apply_mod%==6 (set mod=SMG1NGE)
  119. if %apply_mod%==7 (set mod=SMG1CC)
  120. if %apply_mod%==8 (set mod=SMG1DC)
  121. if %apply_mod%==9 (set mod=SMG1TGSF)
  122. if %apply_mod%==10 (set mod=SMGAP)
  123. if %apply_mod%==11 (set mod=SSMG)
  124. ::=====================
  125. :: Common build process
  126. ::=====================
  127. CLS
  128. echo.
  129. echo ----- !%mod%[0]! Mod ISO Builder
  130. echo ----- !%mod%[1]! !%mod%[2]!
  131. echo.
  132. set /P question1=Download Hack files (approx. size !%mod%[4]!)? (y/n):
  133. echo.
  134. if %question1%==y GOTO :down_hack
  135. if %question1%==n GOTO :question2
  136. :question2
  137. set /P question2=Already downloaded compressed hack file in the "mods" folder? (y/n):
  138. echo.
  139. if %question2%==y GOTO :confirm_file
  140. if %question2%==n GOTO :exit_1
  141. :exit_1
  142. echo Download Rom Hack files and try again.
  143. echo Terminating program...
  144. echo Press any key to close program.
  145. echo.
  146. pause >nul
  147. exit
  148. :down_hack
  149. echo Downloading Rom Hack files...
  150. echo.
  151. %WGET% -q --show-progress -t inf "https://archive.org/download/SMG_1-2_Rom_Hacks/!%mod%[3]!" -P mods >nul
  152. echo.
  153. :confirm_file
  154. if exist ".\mods\!%mod%[3]!" GOTO :extract_file
  155. echo Rom Hack file not found.
  156. echo Press any key to close program.
  157. echo.
  158. pause > nul
  159. exit
  160. :extract_file
  161. echo Rom Hack file found.
  162. echo Extracting file contents...
  163. :: =========================================================
  164. :: Win11 issue with double backslash extract path workaround
  165. :: =========================================================
  166. set "extractpath=.\mods\!%mod%[5]!"
  167. set "fixextractpath=%extractpath:\\=\%"
  168. :: =========================================================
  169. %EXTRACT% x ".\mods\!%mod%[3]!" -o"%fixextractpath%" >nul
  170. echo.
  171. :build_iso
  172. echo Building modded disc image...
  173. echo This will take a while.
  174. echo.
  175. echo Extracting image contents...
  176. %WIT% EXTRACT "%~f1" ".\temp" >nul
  177. echo Copying and replacing mod files...
  178. if exist ".\temp\DATA\" (
  179. xcopy ".\mods\!%mod%[6]!\!%mod%[7]!\*" ".\temp\DATA\files\" /E /Y >nul
  180. ) else (
  181. xcopy ".\mods\!%mod%[6]!\!%mod%[7]!\*" ".\temp\files\" /E /Y >nul)
  182. :: ==================================
  183. :: Redirector to mod's unique options
  184. :: ==================================
  185. if %mod%==KMG1 GOTO :KMG1_custom
  186. if %mod%==SMG1TC GOTO :SMG1TC_custom
  187. if %mod%==SMG1TKGS GOTO :SMG1TKGS_custom
  188. if %mod%==SMG1CC GOTO :SMG1CC_custom
  189. if %mod%==SMG1DC GOTO :SMG1DC_custom
  190. if %mod%==SMGAP GOTO :SMGAP_custom
  191. if %mod%==SSMG GOTO :SSMG_custom
  192. :: ==================================
  193. :final_steps
  194. echo Assembling game image...
  195. %WIT% COPY ".\temp" ".\!%mod%[0]!.wbfs" >nul
  196. echo Removing temp folders...
  197. rmdir /s /q ".\temp"
  198. rmdir /s /q ".\mods\!%mod%[6]!"
  199. echo Editing game IDs...
  200. %WIT% EDIT --id "!%mod%[8]!" ".\!%mod%[0]!.wbfs" >nul
  201. %WIT% EDIT --tt-id "!%mod%[9]!" ".\!%mod%[0]!.wbfs" >nul
  202. %WIT% EDIT --name "!%mod%[1]!" ".\!%mod%[0]!.wbfs" >nul
  203. if exist ".\!%mod%[0]!.wbfs" GOTO :print-info
  204. if not exist ".\!%mod%[0]!.wbfs" GOTO :print-error
  205. :print-error
  206. echo.
  207. echo Error while modding the image.
  208. echo Please try again.
  209. echo Press any key to continue.
  210. echo.
  211. pause >nul
  212. exit
  213. :print-info
  214. echo.
  215. echo Disc image modded correctly.
  216. echo.
  217. echo Game ID: !%mod%[8]!
  218. echo TMD ID: !%mod%[9]!
  219. echo Game name: !%mod%[1]!
  220. echo.
  221. echo If you want to contribute (New Hack/Improve Tool)
  222. echo go to my GitHub repository and open an Issue.
  223. echo Have fun^!
  224. echo.
  225. echo Press any key to exit.
  226. echo.
  227. pause >nul
  228. exit
  229. :: ===============================
  230. :: Unique options/commands per mod
  231. :: ===============================
  232. :: ====
  233. :: KMG1
  234. :: ====
  235. :KMG1_custom
  236. echo.
  237. xcopy ".\mods\!%mod%[6]!\US (NTSC)\UsEnglish" ".\temp\files\UsEnglish" /E /Y /I >nul
  238. xcopy ".\mods\!%mod%[6]!\EU (PAL)\EuEnglish" ".\temp\files\EuEnglish" /E /Y /I >nul
  239. echo Detected Region: %reg%
  240. echo Applying hex patches...
  241. if %reg%==e (set KMG1[8]=KG1E01)
  242. if %reg%==p (set KMG1[8]=KG1P01)
  243. if exist ".\temp\DATA" (%PATCH% ".\temp\DATA\sys\main.dol" < ".\patches\!%mod%[8]!.patch" >nul)
  244. if not exist ".\temp\DATA" (%PATCH% ".\temp\sys\main.dol" < ".\patches\!%mod%[8]!.patch" >nul)
  245. echo.
  246. GOTO :final_steps
  247. :: ======
  248. :: SMG1TC
  249. :: ======
  250. :SMG1TC_custom
  251. echo.
  252. echo Detected Region: %reg%
  253. echo Applying hex patches...
  254. if %reg%==e (set KMG1[8]=G1TCE1)
  255. if %reg%==p (set KMG1[8]=G1TCP1)
  256. if %reg%==j (set KMG1[8]=G1TCJ1)
  257. echo.
  258. GOTO :final_steps
  259. :: ========
  260. :: SMG1TKGS
  261. :: ========
  262. :SMG1TKGS_custom
  263. echo.
  264. rmdir /s /q ".\mods\SMGTKGS 1.6.1"
  265. echo Detected Region: %reg%
  266. echo Applying hex patches...
  267. if %reg%==e (set SMG1TKGS[8]=1KGSE1)
  268. if %reg%==p (set SMG1TKGS[8]=1KGSP1)
  269. if %reg%==j (set SMG1TKGS[8]=1KGSJ1)
  270. if exist ".\temp\DATA" (%PATCH% ".\temp\DATA\sys\main.dol" < ".\patches\!%mod%[8]!.patch" >nul)
  271. if not exist ".\temp\DATA" (%PATCH% ".\temp\sys\main.dol" < ".\patches\!%mod%[8]!.patch" >nul)
  272. echo.
  273. GOTO :final_steps
  274. :: ======
  275. :: SMG1CC
  276. :: ======
  277. :SMG1CC_custom
  278. echo.
  279. echo Detected Region: %reg%
  280. echo Applying hex patches...
  281. if %reg%==e (set SMG1CC[8]=1CCE01)
  282. if %reg%==p (set SMG1CC[8]=1CCP01)
  283. if %reg%==j (set SMG1CC[8]=1CCJ01)
  284. if exist ".\temp\DATA" (%PATCH% ".\temp\DATA\sys\main.dol" < ".\patches\!%mod%[8]!.patch" >nul)
  285. if not exist ".\temp\DATA" (%PATCH% ".\temp\sys\main.dol" < ".\patches\!%mod%[8]!.patch" >nul)
  286. echo.
  287. GOTO :final_steps
  288. :: ======
  289. :: SMG1DC
  290. :: ======
  291. :SMG1DC_custom
  292. echo.
  293. echo Detected Region: %reg%
  294. echo Applying hex patches...
  295. if %reg%==e (set SMG1DC[8]=1DCE01)
  296. if %reg%==p (set SMG1DC[8]=1DCP01)
  297. if exist ".\temp\DATA" (%PATCH% ".\temp\DATA\sys\main.dol" < ".\patches\!%mod%[8]!.patch" >nul)
  298. if not exist ".\temp\DATA" (%PATCH% ".\temp\sys\main.dol" < ".\patches\!%mod%[8]!.patch" >nul)
  299. echo.
  300. GOTO :final_steps
  301. :: =====
  302. :: SMGAP
  303. :: =====
  304. :SMGAP_custom
  305. echo.
  306. echo Detected Region: %reg%
  307. echo Applying hex patches...
  308. if %reg%==e (set SMGAP[8]=RMEAP1)
  309. if %reg%==p (set SMGAP[8]=RMPAP1)
  310. if exist ".\temp\DATA" (%PATCH% ".\temp\DATA\sys\main.dol" < ".\patches\!%mod%[8]!.patch" >nul)
  311. if not exist ".\temp\DATA" (%PATCH% ".\temp\sys\main.dol" < ".\patches\!%mod%[8]!.patch" >nul)
  312. echo.
  313. GOTO :final_steps
  314. :: ====
  315. :: SSMG
  316. :: ====
  317. :SSMG_custom
  318. echo.
  319. xcopy ".\mods\!%mod%[6]!\US (NTSC)\UsEnglish" ".\temp\files\UsEnglish" /E /Y /I >nul
  320. xcopy ".\mods\!%mod%[6]!\EU (PAL)\EuEnglish" ".\temp\files\EuEnglish" /E /Y /I >nul
  321. echo Detected Region: %reg%
  322. echo Applying hex patches...
  323. if %reg%==e (set SSMG[8]=SSMGE1)
  324. if %reg%==p (set SSMG[8]=SSMGP1)
  325. if exist ".\temp\DATA" (%PATCH% ".\temp\DATA\sys\main.dol" < ".\patches\!%mod%[8]!.patch" >nul)
  326. if not exist ".\temp\DATA" (%PATCH% ".\temp\sys\main.dol" < ".\patches\!%mod%[8]!.patch" >nul)
  327. echo.
  328. GOTO :final_steps