@echo off
cd /d "%~dp0"
soft\wit extract -s ./ -1 -n G4S.01 . zeldafsa.d --psel=DATA -ovv

setlocal
if exist zeldafsa.d\P-G4SP\files\GC4Sword_pal\msgGerman.arc (
 GOTO PATCH
) else (
MSG * "Legend of Zelda, The - Four Swords Adventures [PAL] (En,Fr,De,Es,It) " not found! Видимо что-то пошло не так... Fail!!!
 GOTO END
)

:END
endlocal
rmdir /S /Q zeldafsa.d
exit /B

:PATCH
soft\xdelta3.0z.x86-32.exe -d -s zeldafsa.d\P-G4SP\sys\main.dol sys\main_dol_rus.delta sys\main.dol
move /Y sys\main.dol zeldafsa.d\P-G4SP\sys\main.dol >nul
ROBOCOPY /E  Root zeldafsa.d\P-G4SP\files >nul
echo Wait... Patching!
ROBOCOPY /E /MOVE zeldafsa.d\P-G4SP\files zeldafsa.d\P-G4SP\root >nul
soft\GCReEx.exe -c zeldafsa.d\P-G4SP >nul
ren out.iso "The Legend of Zelda - Four Swords Adventures [PAL] [RUS 1.0].iso" >nul
GOTO END
