@echo off 
if not exist \Emu\openmsx\openmsx.exe goto EmulatorFail
if not exist \Emu\openmsx\share\systemroms\machines\Sony\hb-f1xdj.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\Vasm\vasmZ80_OldStyle_win32.exe %BuildFile% -chklabels -nocase -Dvasm=1 -DBuildMSX=1 -Fbin -o "\BldMSX\boot.bin" 

rem  -gbz80 -Fbin -o "\BldMSX\boot.bin" -L \RelGB\Listing.txt
if not "%errorlevel%"=="0" goto Abandon
cd \
\Utils\BuildScripts\MSX_Disk.bat >nul

goto Abandon
:RomFail
echo Error: \Emu\openmsx\share\systemroms\machines\Sony\hb-f1xdj.rom
echo You *MUST* Provide your own OS Roms, I cannot provide them!
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\openmsx\openmsx.exe
:Abandon
if "%3"=="nopause" exit
pause
