@echo off 
if not exist \Emu\Steem\Steem.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\vasmm68k_mot_win32.exe %BuildFile% -chklabels -nocase -Dvasm=1  -L \BldAST\Listing.txt -DBuildAST=1 -Felf -o "\BldAST\Prog.ELF"

rem  -gbz80 -Fbin -o "z:\BldMSX\boot.bin" -L Z:\RelGB\Listing.txt
if not "%errorlevel%"=="0" goto Abandon
cd \BldAST

\Utils\Vasm\vlink.exe Prog.ELF -oProg.tos -bataritos

if not "%errorlevel%"=="0" goto Abandon
copy Prog.tos \RelAST

rem Restore settings
copy \Emu\Steem\Restore_auto.sts \Emu\Steem\auto.sts
copy \Emu\Steem\Restore_Steem.ini \Emu\Steem\Steem.ini

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