@echo off 

if not exist \emu\no$psx\no$psx.exe goto EmulatorFail

set BuildFile=%1
set BuildPath=%2
if exist \utils\SelectedBuildFile.bat call \utils\SelectedBuildFile.bat 

cd %BuildPath%
if not %BuildPath:~0,1%==%CD:~0,1% goto InvalidPath

rem \utils\bass\bass %BuildFile%

\Utils\ArMips\armips.exe %BuildFile% -temp \BldPSX\listing.txt -definelabel buildpsx 1

if not "%errorlevel%"=="0" goto Abandon


\Utils\Bin2Exe\python \Utils\Bin2Exe\bin2exe.py "\BldPSX\Prog.bin" "\RelPSX\Prog.exe"
\emu\no$psx\no$psx.exe "\RelPSX\Prog.exe"

goto Abandon

:InvalidPath
echo Error: ASM file must be on same drive as devtools 
echo File: %BuildPath%\%BuildFile% 
echo Devtools Drive: %CD:~0,1% 
goto Abandon

:EmulatorFail
echo Error: Can't find \emu\no$psx\no$psx.exe

:Abandon
if "%3"=="nopause" exit
pause

