@echo off
rem --- '1_swap.cmd' v1.6 by KdL (2017.06.07)

color 01
pof2pld emsx_top.pof emsx_top.pld
rd /s /q db
rd /s /q incremental_db
del *.done
del *.map
del *.pin
rem.>emsx_top.qpf
del *.rpt
del *.map.summary
del *.sta.summary
del *.qdf
del /s *.bak
if exist emsx_top.pof del recovery.pof
ren emsx_top.pof recovery.pof

:zemmixneo
if not exist emsx_top_304k.hex.backslash.zemmixneo goto msx2plus
ren emsx_top_304k.hex emsx_top_304k.hex.backslash.msx2plus
ren emsx_top_304k.hex.backslash.zemmixneo emsx_top_304k.hex
if exist emsx_top.pld ren emsx_top.pld emsx_top.pld.1chipmsx
if exist recovery.pof ren recovery.pof recovery.pof.1chipmsx
if exist emsx_top.fit.summary ren emsx_top.fit.summary emsx_top.fit.summary.1chipmsx
del "__1chipmsx__"
rem.>"__zemmixneo__"
cd src\peripheral\
ren swioports.vhd swioports.vhd.1chipmsx
ren swioports.vhd.zemmixneo swioports.vhd
cls
color 4f
echo Zemmix Neo is ready to compile!
goto timer

:msx2plus
if not exist emsx_top_304k.hex.backslash.msx2plus goto err_msg
ren emsx_top_304k.hex emsx_top_304k.hex.backslash.zemmixneo
ren emsx_top_304k.hex.backslash.msx2plus emsx_top_304k.hex
if exist emsx_top.pld ren emsx_top.pld emsx_top.pld.zemmixneo
if exist recovery.pof ren recovery.pof recovery.pof.zemmixneo
if exist emsx_top.fit.summary ren emsx_top.fit.summary emsx_top.fit.summary.zemmixneo
del "__zemmixneo__"
rem.>"__1chipmsx__"
cd src\peripheral\
ren swioports.vhd swioports.vhd.zemmixneo
ren swioports.vhd.1chipmsx swioports.vhd
cls
color 1f
echo 1chipMSX is ready to compile!
goto timer

:err_msg
color f0
echo File not found!

:timer
waitfor /T 1 pause 2>NUL
exit
