@echo off 
if not exist \Emu\xroar\xroar.exe  goto EmulatorFail
if not exist \Emu\xroar\*.ROM  goto RomFail
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\Asw\bin\asw %BuildFile% -CPU 6809  -L -olist \BldDGN\Listing.txt  -D BuildDGN -o \BldDGN\prog.bld
if not "%errorlevel%"=="0" goto Abandon
\Utils\Asw\bin\p2bin \BldDGN\prog.bld \BldDGN\prog.rom
rem \Utils\Vasm\vasm6502_oldstyle_win32.exe %1 -c02 -chklabels -nocase -Dvasm=1  -L \BldAP2\Listing.txt -DBuildVTX=1 -Fbin -o "\BldVTX\Prog.bin"
if not "%errorlevel%"=="0" goto Abandon

rem cd \Emu\VecGL
rem vecxgl -x 500 \BldVTX\Prog.bin
cd \Emu\xroar\
\Emu\xroar\xroar.exe  -run \BldDGN\prog.rom

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
:RomFail
echo Error: Can't find roms
echo Please put rom files in \Emu\xroar
echo Sorry... For Legal reasons I cannot provide them :-(
goto Abandon
:EmulatorFail
echo Error: Can't find \Emu\xroar\xroar.exe 
:Abandon
if "%3"=="nopause" exit
pause
