if %DISKVER%z==z goto fail

set diskfile=RelZX\Disk.dsk

rem taskkill -f -im fuse.exe

rem copy Z:\ResZX\*.* Z:\BldZX

set infile=program.bin
set outfile=program
call :AddOneB_%DISKVER%

set infile=program2.bin
set outfile=program2
call :AddOneB_%DISKVER%

set infile=MusicTest9000.bin
set outfile=MUSIC
call :AddOneB_%DISKVER%

set infile=MusicTest9000.bin
set outfile=X01C1Z01
call :AddOneZB_%DISKVER%
goto Launch_%DISKVER%

:fail
@echo off
cls
@echo --------------------------------------------------------------------------
@echo 	Keith's Z80 Dev Toolkit - Please see the Readme for instructions!
@echo --------------------------------------------------------------------------
@echo 			ZX Spectum File Collector V1.0
@echo. 			
@echo 		This program is used by the other spectrum launchers
@echo it is the common script that collects your files, whatever your disk system
@echo. 
@echo --------------------------------------------------------------------------

Echo This script is used by the other ZX scripts
Echo Please run ZX_goTRD.bat / ZX_goTAP.bat or ZX_goDSK.bat

pause
goto end

rem -----------------------------------------------------

:Launch_TAP
if %altmode%z==48z goto :Launch_TAP48
if %altmode%z==+3z goto :Launch_TAP+3
Utils\mktap -b "Loader" 10 <Emu\zxloader%LoaderVer%.bas >BldZX\Loader.tap
copy /B /Y  BldZX\loader.tap%AddedFiles% %tapefile%
Emu\Fuse\fuse.exe --machine 128 --tape %tapefile% -g 2x
rem    --machine 48
exit

:Launch_TAP48
Utils\mktap -b "Loader" 10 <Emu\zxloader%LoaderVer%.bas >BldZX\Loader.tap
copy /B /Y  BldZX\loader.tap%AddedFiles% %tapefile%
if not "%SpecNext%"=="" goto SpecNext48
Emu\Fuse\fuse.exe --machine 48 --tape %tapefile% -g 2x
exit

:Launch_TAP+3
Utils\mktap -b "Loader" 10 <Emu\zxloader%LoaderVer%.bas >BldZX\Loader.tap
copy /B /Y  BldZX\loader.tap%AddedFiles% %tapefile%
if not "%SpecNext%"=="" goto SpecNext48
Emu\Fuse\fuse.exe  --machine plus3 --tape %tapefile% -g 2x
exit





:SpecNext48
cd \Emu\zesarux
zesarux.exe --configfile .zesaruxrc --machine TBBlue --tape \%tapefile% --tbblue-fast-boot-mode  --nosplash --nowelcomemessage --quickexit
goto eof2

:AddOne_TAP
set OutFile=%infile:~0,8%

:AddOneB_TAP
copy BldZX%Lang%\%infile% BldZX%Lang%\%OutFile%.C
Utils\bintap BldZX%Lang%\%OutFile%.C BldZX%Lang%\%OutFile%.tap "%OutFile%C" 28672
set AddedFiles=%AddedFiles%+BldZX%Lang%\%OutFile%.tap
goto eof2


rem -----------------------------------------------------

:AddOneZ_TAP
set OutFile=%infile:~0,8%

:AddOneZB_TAP
Utils\lz48.exe -i BldZX%Lang%\%infile% -o BldZX%Lang%\%infile%.Z
copy BldZX%Lang%\%infile%.Z BldZX%Lang%\%OutFile%.C
Utils\bintap BldZX%Lang%\%OutFile%.C BldZX%Lang%\%OutFile%.tap "%OutFile%C" 28672
set AddedFiles=%AddedFiles%+BldZX%Lang%\%OutFile%.tap
goto eof2


rem -----------------------------------------------------


:Launch_TRD
copy fusetrd.cfg "%userprofile%\fuse.cfg"
Utils\trdtool.exe %trdfile% 
Emu\Fuse\fuse.exe  --machine 128 --beta128 --betadisk %trdfile% --snapshot Emu\trd.szx -g 2x
exit



:AddOne_TRD
set OutFile=%infile:~0,8%

:AddOneB_TRD
copy BldZX%Lang%\%infile% BldZX%Lang%\%OutFile%.C
Utils\trdtool.exe ! %trdfile% BldZX%Lang%\%OutFile%.C
Utils\trdtool.exe + %trdfile% BldZX%Lang%\%OutFile%.C
goto eof2



rem -----------------------------------------------------




:AddOneZ_TRD
set OutFile=%infile:~0,8%

:AddOneZB_TRD
Utils\lz48.exe -i BldZX%Lang%\%infile% -o BldZX%Lang%\%infile%.Z
copy BldZX%Lang%\%infile%.Z BldZX%Lang%\%OutFile%.C
Utils\trdtool.exe ! %trdfile% BldZX%Lang%\%OutFile%.C
Utils\trdtool.exe + %trdfile% BldZX%Lang%\%OutFile%.C
goto eof2



rem -----------------------------------------------------

:Launch_DSK
Emu\Fuse\fuse.exe --machine plus3 --plus3disk %diskfile% --snapshot Emu\dsk.szx -g 2x
exit

rem -----------------------------------------------------

:AddOne_DSK
set OutFile=%infile:~0,8%

:AddOneB_DSK
Utils\PlusThreeHeader.exe BldZX%Lang%\%infile% BldZX%Lang%\%OutFile%.C
Utils\CPCDiskXP.exe -File BldZX%Lang%\%OutFile%.C -AddToExistingDsk %diskfile%
goto eof2


rem -----------------------------------------------------

:AddOneZ_DSK
set OutFile=%infile:~0,8%

:AddOneZB_DSK
Utils\lz48.exe -i BldZX%Lang%\%infile% -o BldZX%Lang%\%infile%.Z
Utils\PlusThreeHeader.exe BldZX%Lang%\%infile%.Z BldZX%Lang%\%OutFile%.C
Utils\CPCDiskXP.exe -File BldZX%Lang%\%OutFile%.C -AddToExistingDsk %diskfile%
goto eof2

:end
:eof2
