@echo off

IF "%1"=="" GOTO Err_Print

REN AFUDOSU.SMC AFUDOSU.EXE

AFUDOSU.EXE %1 /B /P /N /K /R
if errorlevel 35 goto STOP
if errorlevel 34 goto RETRY
if errorlevel 23 goto STOP
if errorlevel 22 goto RETRY
if errorlevel 1 goto STOP
if errorlevel 0 goto NEXT

:RETRY
AFUDOSU.EXE %1 /B /P /N /K /R
if errorlevel 1 goto STOP
if errorlevel 0 goto NEXT

:NEXT
AFUDOSU.EXE %1 /L2

:STOP
REN AFUDOSU.EXE AFUDOSU.SMC
Goto END

:Err_Print
echo *********************************************************
echo   Usage:
echo			flash.bat romfile
echo *********************************************************


:END