@echo off 
if not exist \Emu\Wabbitemu\Wabbitemu.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\vasmZ80_OldStyle_win32.exe %BuildFile% -chklabels -nocase -Dvasm=1 -L \BldTi\Listing.txt -DBuildTI8=1 -Fbin -o "\BldTi\program.bin"
rem  -gbz80 -Fbin -o "z:\BldMSX\boot.bin" -L Z:\RelGB\Listing.txt
if not "%errorlevel%"=="0" goto Abandon
cd \

cd BldTi
..\Utils\bin28xp.exe program.bin --unprotected --nocomment
copy program.8xp ..\RelTi

if not exist ..\Emu\LaunchWabbitemu.sav goto Setup

cd \Emu\Wabbitemu\
copy ..\LaunchWabbitemu.sav ..\Wabbitemuwabbitemu.sav
Wabbitemu.exe ..\Wabbitemuwabbitemu.sav  ..\..\RelTi\program.8xp

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


rem Show this message if the emulator is missing it's rom
:Setup
@echo off
cls
Echo *** Set up WabbitEmu with a rom - and save a savestate to...  ***
echo *** \Emu\LaunchWabbitemu.sav ***
pause
cd ..\Emu\Wabbitemu\
Wabbitemu.exe
goto Abandon



goto Abandon
:EmulatorFail
echo Error: Can't find \Emu\Wabbitemu\Wabbitemu.exe
:Abandon
if "%3"=="nopause" exit
pause