@echo off
set CURDIR=%~dp0
cd "%curdir%"
set CURDRIVE=%curdir:~0,2%
%CURDRIVE%

cls
if not exist EBOOT.PBP goto NoEBOOT
set /p pspdir=Input Game/Placeholder directory name [or hit enter PSPP00000 will be used]: 
if /i {%pspdir%}=={} (set pspdir=PSPP00000)
if /i {%pspdir%}=={PSPP00000} (cd tools)
if /i {%pspdir%}=={PSPP00000} (if exist ..\PSPP00000 rd /s /q ..\PSPP00000)
if /i {%pspdir%}=={PSPP00000} (7z.exe x -r -y -o.. PSPP00000.7z)
if /i {%pspdir%}=={PSPP00000} (cd ..)
IF NOT EXIST "%pspdir%" mkdir %pspdir%
IF NOT EXIST "%pspdir%\USRDIR" mkdir %pspdir%\USRDIR
IF NOT EXIST "%pspdir%\save_tmp" mkdir %pspdir%\save_tmp
IF NOT EXIST "%pspdir%\open_tmp" mkdir %pspdir%\open_tmp
IF NOT EXIST "%pspdir%\load_tmp" mkdir %pspdir%\load_tmp
IF NOT EXIST "%pspdir%\USERDIR\CONTENT" mkdir %pspdir%\USRDIR\CONTENT
cls
SET /P ISO=Do you want to extract ISO from EBOOT.PBP? (Y/N):  
if /i {%ISO%}=={y} (goto :iso_yes)
if /i {%ISO%}=={yes} (goto :iso_yes)
if /i {%ISO%}=={n} (goto :iso_no)
if /i {%ISO%}=={no} (goto :iso_no)
:iso_yes
cls
copy tools\mongoose.exe .\mongoose.exe
mongoose 1
del mongoose.exe
goto :rest
:iso_no
cls
copy tools\mongoose.exe .\mongoose.exe
mongoose
del mongoose.exe
:rest
copy tools\make_edata_npdrm.exe .\make_edata_npdrm.exe
make_edata_npdrm ISO.BIN ISO.BIN.EDAT
make_edata_npdrm MINIS.BIN MINIS.EDAT
del make_edata_npdrm.exe
del ISO.BIN
del MINIS.BIN
cls
IF EXIST "%pspdir%\USRDIR\MINIS.EDAT" del %pspdir%\USRDIR\MINIS.EDAT
IF EXIST "%pspdir%\USRDIR\ISO.BIN.EDAT" del %pspdir%\USRDIR\ISO.BIN.EDAT
IF EXIST MINIS.EDAT move /y MINIS.EDAT %pspdir%\USRDIR\MINIS.EDAT
IF EXIST ISO.BIN.EDAT move /y ISO.BIN.EDAT %pspdir%/USRDIR/ISO.BIN.EDAT
IF EXIST EBOOT.PBP move /y EBOOT.PBP %pspdir%/USRDIR/CONTENT/EBOOT.PBP
"MAKE.bat"
goto end

:NoEBOOT
echo ERROR: Missing EBOOT.PBP
echo Make sure to put the EBOOT.PBP Bite folder...
pause
:end
