@echo off
::MultiPatch Menu Wizard by ron975

::xdelta3 test. It won't continue if xdelta isn't found
IF EXIST xdelta3.exe. (
goto test2
) ELSE (
echo xdelta3.exe not found
echo ErrorCode 1 Cannot Continue
echo Press any key to exit.
pause >nul
exit
)
:: Patch file tests, tests to make sure all patch files are present
:test2
IF EXIST cleantorsnail.xdelta. (
goto test3
) ELSE (
echo Patch file not found
echo ErrorCode 2 Cannot Continue
echo Press any key to exit.
pause >nul
exit
)
:test3
IF EXIST bsnailtorsnail.xdelta. (
goto test4
) ELSE (
echo Patch file not found
echo ErrorCode 2 Cannot Continue
echo Press any key to exit.
pause >nul
exit
)
:test4
IF EXIST trimmedtorsnail.xdelta. (
goto test5
) ELSE (
echo Patch file not found
echo ErrorCode 2 Cannot Continue
echo Press any key to exit.
pause >nul
exit
)
:test5
IF EXIST 0.02+torsnail.xdelta. (
goto prestart
) ELSE (
echo Patch file not found
echo ErrorCode 2 Cannot Continue
echo Press any key to exit.
pause >nul
exit
)

:prestart
set game=MapleStory DS
set patchver=0.04 RedSnail
set patchfile=MapleStoryDS_PATCHED.nds
title %game% Patch wizard to %patchver%
:start
cls
echo Welcome to the %game% patch menu for patch version %patchver%
echo What version of %game% are you patching to %patchver%?
echo Please enter a number, followed by Enter, to continue
echo 1 = Clean %game%  rom to %patchver%
echo 2 = Trimmed %game% rom to %patchver%
echo 3 = 0.03 BlueSnail patched %game% rom to %patchver%
echo 4 = Twiztidsinz's 0.02+ patched %game% rom to %patchver%
echo E = Exit
set /p patchset= 
IF "%patchset%" ==  "1" goto clean
IF "%patchset%" ==  "2" goto trimmed
IF "%patchset%" ==  "3" goto bsnail
IF "%patchset%" ==  "4" goto twiz
IF "%patchset%" ==  "E" goto exit
IF "%patchset%" ==  "e" goto exit
goto start
:clean
cls
echo.
echo You are patching a Clean %game% rom to %patchver%
echo If this is wrong, press N to go back
echo otherwise press Enter to continue

set /p cleantest= 
IF "%cleantest%" ==  "N" goto start
IF "%cleantest%" ==  "n" goto start


echo Make sure that there is only one .nds file in the patch folder.
echo Then press any key to continue

pause >nul

ren *.nds MapleStoryDS_CLEAN.nds 2> nul
IF EXIST MapleStoryDS_CLEAN.nds. (
goto patchclean
) ELSE (
echo NDS file not found
echo ErrorCode 3 Cannot Continue
echo Press any key to exit.
pause >nul
exit
)

:patchclean
echo Please wait, %game% is Patching
xdelta3 -d -s MapleStoryDS_CLEAN.nds cleantorsnail.xdelta MapleStoryDS_PATCHED.nds
echo %game% patched sucessfully
echo The new filename is MapleStoryDS_PATCHED.nds
pause
exit

:trimmed
cls
echo.
echo You are patching a Trimmed %game% rom to %patchver%
echo If this is wrong, press N to go back
echo otherwise press Enter to continue

set /p trimmedtest= 
IF "%trimmedtest%" ==  "N" goto start
IF "%trimmedtest%" ==  "n" goto start


echo Make sure that there is only one .nds file in the patch folder.
echo Then press any key to continue

pause >nul

ren *.nds MapleStoryDS_TRIMMED.nds 2> nul
IF EXIST MapleStoryDS_TRIMMED.nds. (
goto patchtrim
) ELSE (
echo NDS file not found
echo ErrorCode 3 Cannot Continue
echo Press any key to exit.
pause >nul
exit
)

:patchtrim
echo Please wait, %game% is Patching
xdelta3 -d -s MapleStoryDS_TRIMMED.nds trimmedtorsnail.xdelta MapleStoryDS_PATCHED.nds
echo %game% patched sucessfully
echo The new filename is MapleStoryDS_PATCHED.nds
pause
exit
:bsnail
cls
echo.
echo You are patching a BlueSnail 0.03 patched %game% rom to %patchver%
echo If this is wrong, press N to go back
echo otherwise press Enter to continue

set /p bsnailtest= 
IF "%bsnailtest%" ==  "N" goto start
IF "%bsnailtest%" ==  "n" goto start


echo Make sure that there is only one .nds file in the patch folder.
echo Then press any key to continue

pause >nul

ren *.nds MapleStoryDS_BSNAIL.nds 2> nul
IF EXIST MapleStoryDS_BSNAIL.nds. (
goto patchbsnail
) ELSE (
echo NDS file not found
echo ErrorCode 3 Cannot Continue
echo Press any key to exit.
pause >nul
exit
)

:patchbsnail
echo Please wait, %game% is Patching
xdelta3 -d -s MapleStoryDS_BSNAIL.nds bsnailtorsnail.xdelta MapleStoryDS_PATCHED.nds
echo %game% patched sucessfully
echo The new filename is MapleStoryDS_PATCHED.nds
pause
exit
:twiz
cls
echo.
echo You are patching a Twiztidsinz's 0.02+ patched %game% rom to %patchver%
echo If this is wrong, press N to go back
echo otherwise press Enter to continue

set /p bsnailtest= 
IF "%bsnailtest%" ==  "N" goto start
IF "%bsnailtest%" ==  "n" goto start


echo Make sure that there is only one .nds file in the patch folder.
echo Then press any key to continue

pause >nul

ren *.nds MapleStoryDS_0.02+.nds 2> nul
IF EXIST MapleStoryDS_0.02+.nds. (
goto patchtwiz
) ELSE (
echo NDS file not found
echo ErrorCode 3 Cannot Continue
echo Press any key to exit.
pause >nul
exit
)

:patchtwiz
echo Please wait, %game% is Patching
xdelta3 -d -s MapleStoryDS_0.02+.nds bsnailtorsnail.xdelta MapleStoryDS_PATCHED.nds
echo %game% patched sucessfully
echo The new filename is MapleStoryDS_PATCHED.nds
pause
exit
:exit
exit