@ECHO OFF
REM	 'nod' (default) to kill list and obj in b dir, 'dls' to bring it out 

cd ..\bupl

del *.a51
del *.c
del *.h

if "%MUSDEB%"=="0" goto setmdb
goto setno

:setmdb
@ECHO ON
REM ********** DEBUG INFO IN FILE **********
@ECHO OFF
copy ..\supl\cond\dbgflad.h dbgflga.inc	>..\trash\trashbin
copy ..\supl\cond\dbgflcd.h debflgc.h		>..\trash\trashbin
goto setdn

:setno
copy ..\supl\cond\dbgflan.h dbgflga.inc	>..\trash\trashbin
copy ..\supl\cond\dbgflcn.h debflgc.h		>..\trash\trashbin


:setdn
copy  ..\supl\*.h  			*.*			>..\trash\trashbin
copy  ..\supl\*.c  			*.*			>..\trash\trashbin
copy  ..\supl\*.a51  		*.*			>..\trash\trashbin
xcopy C:\ams\*.h 			*.*		>..\trash\trashbin

rem hello there
copy C:\aglobal\keil.h 		*.*		>..\trash\trashbin
copy C:\aglobal\cyf120.h 	*.*		>..\trash\trashbin
copy C:\aglobal\cyf120.inc 	*.*		>..\trash\trashbin
copy C:\aglobal\c51s.lib	*.*		>..\trash\trashbin


if not exist  cmplst.txt goto nocmdl
del cmplst.txt
:nocmdl
call batasm UPstart
call batasm UPxdata
call batcmp UPmain 

call batcmp UPccode
call batcmp UPisr	 
 
if not exist cmplst.txt goto naser
echo on
REM /////////////////////////////////
REM ///////// COMPILE ERRORS ////////
REM /////////////////////////////////
type cmplst.txt	| more
REM saved in file cmplst.txt
pause
@ECHO OFF
:naser

if not exist UP.lib goto usliex
del UP.lib
:usliex
c:\tools\keil\c51\bin\lib51 c UP.lib					>..\trash\trashbin
c:\tools\keil\c51\bin\lib51 a UPccode.obj	to UP.lib	>..\trash\trashbin

c:\tools\keil\c51\bin\bl51 UPstart.obj, UPisr.obj, UPmain.obj, UPxdata.obj, UP.lib, c51s.lib TO upl.omf RS(256) IX >protl.log
IF errorlevel=2 GOTO tell
goto show
:tell 
echo on
REM ////////////////////////////////////////
REM //////////// linker ERRORS /////////////
REM ////////////////////////////////////////
REM errors and warnings are in protl.log
REM link map is in upl.m51
pause
:show
echo on
type protl.log | more
pause

if "%NODEL%"=="0" goto nodel

del *.lst 
del *.obj 
del *.lib
del *.txt
del *.log

:nodel

:hexc1
c:\tools\keil\c51\bin\oh51 upl.omf HEXFILE (..\hex\upload.hex)
echo on						 
fc ..\hex\upload.hex ..\mtc\upload.hex
goto hexit					 

:setdbw


:dexc1
c:\tools\keil\c51\bin\oh51 as.omf HEXFILE (..\hex\%MUSTYP%%MUSMFG%%MUSWDT%%MUSHGT%DBG.hex)
echo on
fc ..\hex\%MUSTYP%%MUSMFG%%MUSWDT%%MUSHGT%DBG.hex ..\mtc\%MUSTYP%%MUSMFG%%MUSWDT%%MUSHGT%DBG.hex
goto hexit


:hexit
pause
type x.log
goto getout



:wdtmiss 
echo on
rem ERROR !!!!!!!!wdt!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
goto getout


:hgtmiss
echo on
rem ERROR !!!!!!!hgt!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

:getout
cd ..\mk


