@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 "\BldCPC\program.bin"
rem  -gbz80 -Fbin -o "\BldMSX\boot.bin" -L \RelGB\Listing.txt
if not "%errorlevel%"=="0" goto Abandon
cd \
rem This is an alternative - it will build a custom CPR without using disk emulaton!
copy /B /Y Utils\buildcpr\os.rom+Utils\buildcpr\basic.rom+Utils\buildcpr\amsdos.rom+BldCPC\program.bin  BldCPC\Cart.tmp
\utils\buildcpr.exe BldCPC\Cart.tmp RelCPC\cart.cpr
\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