@echo off

::Note: asm5900.exe does NOT return an error code when it fails, the comparisons here will not work
:: unless this is resolved by the author of that software.  Therefore you must watch the output to
:: be sure your project is building correctly.

asm5900 -o:PS1LOGO.BIN PS1LOGO.S
IF NOT %errorlevel%==0 GOTO error

copy PS1LOGO.BIN FILES\BOOT\BM\PS1LOGO.BIN

asm5900 -o:OSDHOOK.BIN OSDHOOK.S
IF NOT %errorlevel%==0 GOTO error

asm5900 -o:LOADER.BIN LOADER.S
IF NOT %errorlevel%==0 GOTO error

ccigen LOADER.BIN OSDHOOK.BIN FIRMWARE.CCI
IF NOT %errorlevel%==0 GOTO error

copy FIRMWARE.CCI FILES\FIRMWARE.CCI

cd-tool -o cc-upgrade.bin -e "main()" cc-upg-builder.lua
IF NOT %errorlevel%==0 GOTO error

echo CC1.0 firmware and upgrade disc image created successfully.
GOTO end

:error
echo !!! Firmware building stopped due to error. !!!

:end
pause
