123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529 |
- @ECHO off
- MODE 80,30
- CLS
- echo.
- echo ----- SMG1 Mod ISO Builder (v0.4)
- echo ----- By Humming Owl
- echo.
- :: ===============================
- :: Get to the path the BAT file is
- :: ===============================
- cd %~dp0
- :: ================
- :: mods data storage
- :: ================
- call .\tools\mods_data.bat
- :: =============================
- :: actions before starting patch
- :: =============================
- if exist ".\savefiles" (rmdir /s /q ".\savefiles")
- if exist ".\temp" (rmdir /s /q ".\temp")
- if not exist ".\mods" (mkdir ".\mods")
- for /d %%a in (".\mods\*") do rd "%%a" /q /s
- if exist ".\*.tmp" (del /S *.tmp >nul)
- :: ===================================================
- :: Key command to work with variables inside variables
- :: ===================================================
- SETLOCAL EnableDelayedExpansion
- :: =====
- :: Tools
- :: =====
- set WGET=tools\wget.exe
- set EXTRACT=tools\7z.exe
- set PATCH=tools\patch.exe
- set WIT=tools\wit.exe
- :: ==========
- :: check_file
- :: ==========
- if not "%~x1" == ".iso" (
- if not "%~x1" == ".wbfs" (
- echo.
- echo File dropped IS NOT ISO/WBFS.
- echo Verify file and try again.
- echo.
- echo Press any key to exit.
- echo.
- pause >nul
- exit
- )
- )
- %WIT% verify --test --quiet "%~f1"
- if %ERRORLEVEL% NEQ 0 (
- echo.
- echo File dropped is ISO/WBFS, but not a valid one.
- echo Verify file and try again.
- echo.
- echo Press any key to exit.
- echo.
- pause >nul
- exit
- )
- echo.
- echo File dropped IS a valid ISO/WBFS.
- FOR /F "tokens=*" %%g IN ('%WIT% ID6 "%~f1"') do (set og_gameid=%%g)
- if not "%og_gameid%" == "RMGE01" (
- if not "%og_gameid%" == "RMGP01" (
- if not "%og_gameid%" == "RMGJ01" (
- if not "%og_gameid%" == "RMGK01" (
- echo But is not an original SMG1 file.
- echo Verify the file and try again.
- echo.
- echo Press any key to exit.
- echo.
- pause >nul
- exit
- )
- )
- )
- )
- :: ============
- :: region check
- :: ============
- if "%og_gameid%" == "RMGE01" (set reg=e)
- if "%og_gameid%" == "RMGP01" (set reg=p)
- if "%og_gameid%" == "RMGJ01" (set reg=j)
- if "%og_gameid%" == "RMGK01" (set reg=k)
- :: ============
- echo And its an original SMG1 file.
- echo Ready to go.
- echo.
- echo Press any key if you are ready.
- echo.
- pause
- CLS
- :: ==================
- :: SMG1 Rom Hack List
- :: ==================
- echo.
- echo --- SMG1 Hack list:
- echo.
- echo 1. Kaizo Mario Galaxy (v1.2)
- echo 2. Super Mario Galaxy: Transformationless Challenge (v1.0.1)
- echo 3. Super Mario Galaxy: The Green Stars (v1.1) (has some issues)
- echo 4. Super Mario Galaxy: The Kaizo Green Stars (v1.6.1)
- echo 5. Super Mario Galaxy: Underwater Edition
- echo 6. Super Mario Galaxy: No Gravity Edition (v1.0)
- echo 7. Super Mario Galaxy: Cosmic Caos (v1.3.5)
- echo 8. Super Mario Galaxy: Daredevil Challenge
- echo 9. Super Mario Galaxy: The Green Star Festival (v1.1 - E/P/J/K/W)
- echo 10. Super Mario Galaxy Anti Piracy (v1.0 - E/P)
- echo 11. Superstar Mario Galaxy (2023 - E/P)
- echo.
- set /P apply_mod=Select Mod number to apply to ISO/WBFS image:
- if %apply_mod%==1 (set mod=KMG1)
- if %apply_mod%==2 (set mod=SMG1TC)
- if %apply_mod%==3 (set mod=SMG1TGS)
- if %apply_mod%==4 (set mod=SMG1TKGS)
- if %apply_mod%==5 (set mod=SMG1UE)
- if %apply_mod%==6 (set mod=SMG1NGE)
- if %apply_mod%==7 (set mod=SMG1CC)
- if %apply_mod%==8 (set mod=SMG1DC)
- if %apply_mod%==9 (set mod=SMG1TGSF)
- if %apply_mod%==10 (set mod=SMGAP)
- if %apply_mod%==11 (set mod=SSMG)
- ::=====================
- :: Common build process
- ::=====================
- CLS
- echo.
- echo ----- !%mod%[0]! Mod ISO Builder
- echo ----- !%mod%[1]! !%mod%[2]!
- echo.
- set /P question1=Download Hack files (approx. size !%mod%[4]!)? (y/n):
- echo.
- if %question1%==y GOTO :down_hack
- if %question1%==n GOTO :question2
- :question2
- set /P question2=Already downloaded compressed hack file in the "mods" folder? (y/n):
- echo.
- if %question2%==y GOTO :confirm_file
- if %question2%==n GOTO :exit_1
- :exit_1
- echo Download Rom Hack files and try again.
- echo Terminating program...
- echo Press any key to close program.
- echo.
- pause >nul
- exit
- :down_hack
- echo Downloading Rom Hack files...
- echo.
- %WGET% -q --show-progress -t inf "https://archive.org/download/SMG_1-2_Rom_Hacks/!%mod%[3]!" -P mods >nul
- echo.
- :confirm_file
- if exist ".\mods\!%mod%[3]!" GOTO :extract_file
- echo Rom Hack file not found.
- echo Press any key to close program.
- echo.
- pause > nul
- exit
- :extract_file
- echo Rom Hack file found.
- echo Extracting file contents...
- :: =========================================================
- :: Win11 issue with double backslash extract path workaround
- :: =========================================================
- set "extractpath=.\mods\!%mod%[5]!"
- set "fixextractpath=%extractpath:\\=\%"
- :: =========================================================
- %EXTRACT% x ".\mods\!%mod%[3]!" -o"%fixextractpath%" >nul
- echo.
- :build_iso
- echo Building modded disc image...
- echo This will take a while.
- echo.
- echo Extracting image contents...
- %WIT% EXTRACT "%~f1" ".\temp" >nul
- echo Copying and replacing mod files...
- if exist ".\temp\DATA\" (
- xcopy ".\mods\!%mod%[6]!\!%mod%[7]!\*" ".\temp\DATA\files\" /E /Y >nul
- ) else (
- xcopy ".\mods\!%mod%[6]!\!%mod%[7]!\*" ".\temp\files\" /E /Y >nul)
- :: ==================================
- :: Redirector to mod's unique options
- :: ==================================
- if %mod%==KMG1 GOTO :KMG1_custom
- if %mod%==SMG1TC GOTO :SMG1TC_custom
- if %mod%==SMG1TKGS GOTO :SMG1TKGS_custom
- if %mod%==SMG1CC GOTO :SMG1CC_custom
- if %mod%==SMG1DC GOTO :SMG1DC_custom
- if %mod%==SMGAP GOTO :SMGAP_custom
- if %mod%==SSMG GOTO :SSMG_custom
- :: ==================================
- :final_steps
- echo Assembling game image...
- %WIT% COPY ".\temp" ".\!%mod%[0]!.wbfs" >nul
- echo Removing temp folders...
- rmdir /s /q ".\temp"
- rmdir /s /q ".\mods\!%mod%[6]!"
- echo Editing game IDs...
- %WIT% EDIT --id "!%mod%[8]!" ".\!%mod%[0]!.wbfs" >nul
- %WIT% EDIT --tt-id "!%mod%[9]!" ".\!%mod%[0]!.wbfs" >nul
- %WIT% EDIT --name "!%mod%[1]!" ".\!%mod%[0]!.wbfs" >nul
- if exist ".\!%mod%[0]!.wbfs" GOTO :print-info
- if not exist ".\!%mod%[0]!.wbfs" GOTO :print-error
- :print-error
- echo.
- echo Error while modding the image.
- echo Please try again.
- echo Press any key to continue.
- echo.
- pause >nul
- exit
- :print-info
- echo.
- echo Disc image modded correctly.
- echo.
- echo Game ID: !%mod%[8]!
- echo TMD ID: !%mod%[9]!
- echo Game name: !%mod%[1]!
- echo.
- echo If you want to contribute (New Hack/Improve Tool)
- echo go to my GitHub repository and open an Issue.
- echo Have fun^!
- echo.
- echo Press any key to exit.
- echo.
- pause >nul
- exit
- :: ===============================
- :: Unique options/commands per mod
- :: ===============================
- :: ====
- :: KMG1
- :: ====
- :KMG1_custom
- echo.
- xcopy ".\mods\!%mod%[6]!\US (NTSC)\UsEnglish" ".\temp\files\UsEnglish" /E /Y /I >nul
- xcopy ".\mods\!%mod%[6]!\EU (PAL)\EuEnglish" ".\temp\files\EuEnglish" /E /Y /I >nul
- echo Detected Region: %reg%
- echo Applying hex patches...
- if %reg%==e (set KMG1[8]=KG1E01)
- if %reg%==p (set KMG1[8]=KG1P01)
- if exist ".\temp\DATA" (%PATCH% ".\temp\DATA\sys\main.dol" < ".\patches\!%mod%[8]!.patch" >nul)
- if not exist ".\temp\DATA" (%PATCH% ".\temp\sys\main.dol" < ".\patches\!%mod%[8]!.patch" >nul)
- echo.
- GOTO :final_steps
- :: ======
- :: SMG1TC
- :: ======
- :SMG1TC_custom
- echo.
- echo Detected Region: %reg%
- echo Applying hex patches...
- if %reg%==e (set KMG1[8]=G1TCE1)
- if %reg%==p (set KMG1[8]=G1TCP1)
- if %reg%==j (set KMG1[8]=G1TCJ1)
- echo.
- GOTO :final_steps
- :: ========
- :: SMG1TKGS
- :: ========
- :SMG1TKGS_custom
- echo.
- rmdir /s /q ".\mods\SMGTKGS 1.6.1"
- echo Detected Region: %reg%
- echo Applying hex patches...
- if %reg%==e (set SMG1TKGS[8]=1KGSE1)
- if %reg%==p (set SMG1TKGS[8]=1KGSP1)
- if %reg%==j (set SMG1TKGS[8]=1KGSJ1)
- if exist ".\temp\DATA" (%PATCH% ".\temp\DATA\sys\main.dol" < ".\patches\!%mod%[8]!.patch" >nul)
- if not exist ".\temp\DATA" (%PATCH% ".\temp\sys\main.dol" < ".\patches\!%mod%[8]!.patch" >nul)
- echo.
- GOTO :final_steps
- :: ======
- :: SMG1CC
- :: ======
- :SMG1CC_custom
- echo.
- echo Detected Region: %reg%
- echo Applying hex patches...
- if %reg%==e (set SMG1CC[8]=1CCE01)
- if %reg%==p (set SMG1CC[8]=1CCP01)
- if %reg%==j (set SMG1CC[8]=1CCJ01)
- if exist ".\temp\DATA" (%PATCH% ".\temp\DATA\sys\main.dol" < ".\patches\!%mod%[8]!.patch" >nul)
- if not exist ".\temp\DATA" (%PATCH% ".\temp\sys\main.dol" < ".\patches\!%mod%[8]!.patch" >nul)
- echo.
- GOTO :final_steps
- :: ======
- :: SMG1DC
- :: ======
- :SMG1DC_custom
- echo.
- echo Detected Region: %reg%
- echo Applying hex patches...
- if %reg%==e (set SMG1DC[8]=1DCE01)
- if %reg%==p (set SMG1DC[8]=1DCP01)
- if exist ".\temp\DATA" (%PATCH% ".\temp\DATA\sys\main.dol" < ".\patches\!%mod%[8]!.patch" >nul)
- if not exist ".\temp\DATA" (%PATCH% ".\temp\sys\main.dol" < ".\patches\!%mod%[8]!.patch" >nul)
- echo.
- GOTO :final_steps
- :: =====
- :: SMGAP
- :: =====
- :SMGAP_custom
- echo.
- echo Detected Region: %reg%
- echo Applying hex patches...
- if %reg%==e (set SMGAP[8]=RMEAP1)
- if %reg%==p (set SMGAP[8]=RMPAP1)
- if exist ".\temp\DATA" (%PATCH% ".\temp\DATA\sys\main.dol" < ".\patches\!%mod%[8]!.patch" >nul)
- if not exist ".\temp\DATA" (%PATCH% ".\temp\sys\main.dol" < ".\patches\!%mod%[8]!.patch" >nul)
- echo.
- GOTO :final_steps
- :: ====
- :: SSMG
- :: ====
- :SSMG_custom
- echo.
- xcopy ".\mods\!%mod%[6]!\US (NTSC)\UsEnglish" ".\temp\files\UsEnglish" /E /Y /I >nul
- xcopy ".\mods\!%mod%[6]!\EU (PAL)\EuEnglish" ".\temp\files\EuEnglish" /E /Y /I >nul
- echo Detected Region: %reg%
- echo Applying hex patches...
- if %reg%==e (set SSMG[8]=SSMGE1)
- if %reg%==p (set SSMG[8]=SSMGP1)
- if exist ".\temp\DATA" (%PATCH% ".\temp\DATA\sys\main.dol" < ".\patches\!%mod%[8]!.patch" >nul)
- if not exist ".\temp\DATA" (%PATCH% ".\temp\sys\main.dol" < ".\patches\!%mod%[8]!.patch" >nul)
- echo.
- GOTO :final_steps
|