@echo off 
if not exist \Emu\openmsx\openmsx.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
cd %BuildPath%

\Utils\Vasm\vasmZ80_OldStyle_win32.exe %BuildFile% -chklabels -nocase -Dvasm=1 -DBuildMSX=1 -L \BldMSX\Listing.txt -DBuildMSX_MSX1=1 -Fbin -o "\RelMSX\cart.rom" 
rem  -gbz80 -Fbin -o "z:\BldMSX\boot.bin" -L Z:\RelGB\Listing.txt
if not "%errorlevel%"=="0" goto Abandon

cd \Emu\openmsx\

ver|find "Windows XP">nul
if %Errorlevel%==0 Goto OSXP
openmsx.exe -machine C-BIOS_MSX2+ -cart ..\..\RelMSX\cart.rom -script \Emu\openmsx\startup.txt
goto Abandon

:OSXP
openmsxXP.exe -machine C-BIOS_MSX2+ -cart ..\..\RelMSX\cart.rom -script \Emu\openmsx\startup.txt

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
