@echo off 
if not exist \Emu\yabause\yabause.exe goto EmulatorFail

if not exist \Emu\yabause\bios.bin goto NoBios

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 SH7600  -L -olist \BldSAT\ListingSH2.txt  -D BuildSAT -o \BldSAT\prog.bld

if not "%errorlevel%"=="0" goto Abandon

\Utils\Asw\bin\p2bin \BldSAT\prog.bld \relSAT\Prog.Bin

cd \Emu\yabause
yabause.exe --binary=\RelSat\prog.bin --bios=bios.bin


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

:NoBios
echo Error: can't find \Emu\yabause\bios.bin
echo For legal reasons I cannot provide it.
goto Abandon

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


