'@echo off 
if not exist Emu\Arnold\Arnold.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


\Utils\Vasm\vasmZ80_OldStyle_win32.exe %BuildFile% -chklabels -nocase -Dvasm=1  -L \BldCPC\Listing.txt -DBuildCPC=1 -Fbin -o "Z:\BldCPC\program.bin"
if not "%errorlevel%"=="0" goto Abandon

\Utils\CPCDiskXP.exe -AddAmsdosHeader 8000 -File \BldCPC%Lang%\program.bin -AddToExistingDsk \RelCPC\disk.dsk
taskkill -im arnold.exe

cd \utils\nocart
nocart32 \RelCPC\disk.dsk \RelCPC\cart.cpr go.bas
cd \
Emu\Arnold\Arnold.exe /as=..\..\RelCPC\cart.cpr /cfg=6128+

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\Arnold\Arnold.exe
:Abandon
if "%3"=="nopause" exit
pause