@echo on
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.bin

if not "%errorlevel%"=="0" goto Abandon
copy \ResDGN\blank.dsk \RelDGN\disk.dsk
\Utils\toolshed\decb.exe copy -b -2 \BldDGN\prog.bin \RelDGN\disk.dsk,PROG.BIN

cd \Emu\xroar\

rem \Emu\xroar\xroar.exe  -default-machine coco -run \BldDGN\prog.bin

\Emu\xroar\xroar.exe  -default-machine coco -run \RelDGN\disk.dsk

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
:RomFailX
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
