@call clrsetup
@set TEMPAT=%1
@if "%1x" == "x" goto HELP
@shift
@call atsetup
@call dosetup
@if NOT EXIST %TEMPXM% goto ERR1

@if NOT EXIST %TEMPAT%\. goto ERR4

@if EXIST %TEMPBG% goto DNBG
@if NOT EXIST %TEMPSBG% goto ERR9
@echo Copy %TEMPSBG% to %TEMPBG%
@copy %TEMPSBG% %TEMPBG% > nul
@if NOT EXIST %TEMPSBG% goto ERR9B
:DNBG
@REM echo Got file %TEMPBG%...

@if NOT EXIST %TEMPF% @md %TEMPF%
@if NOT EXIST %TEMPF%\. goto ERR5


@if EXIST %TEMPF1% goto DNF1
@if NOT EXIST %TEMPFS%\. goto ERR6
@if NOT EXIST %TEMPSF1%\. goto ERR7
@echo Copy %TEMPSF1% to %TEMPF1%
@Copy %TEMPSF1% %TEMPF1% > nul
@if NOT EXIST %TEMPF1%\. goto ERR6B
:DNF1
@REM echo Got file %TEMPF1%...

@set TEMPF2=%TEMPF%\Helvetica.100.txf
@if EXIST %TEMPF2% goto DNF2
@if NOT EXIST %TEMPFS%\. goto ERR6
@set TEMPSF2=%TEMPFS%\Helvetica.100.txf
@if NOT EXIST %TEMPSF2%\. goto ERR8
@echo Copy %TEMPSF2% to %TEMPF2%
@Copy %TEMPSF2% %TEMPF2% > nul
@if NOT EXIST %TEMPF2%\. goto ERR8B
:DNF2
@REM echo Got file %TEMPF2%...

@set TEMPAPD=%TEMPAP%\default.ap
@if EXIST %TEMPAPD% goto DNAP
@set TEMPSAPD=%TEMPSAP%\default.ap
@if NOT EXIST %TEMPSAPD% goto ERR10
@if NOT EXIST %TEMPAP%\. @md %TEMPAP%
@if NOT EXIST %TEMPAP%\. goto ERR10A
@echo Copy %TEMPSAPD% to %TEMPAPD%
@Copy %TEMPSAPD% %TEMPAPD% > nul
@if NOT EXIST %TEMPAPD% goto ERR10B
:DNAP
@REM echo Got file %TEMPAPD%...

@REM Add CHUNKS to command - Sydney, Brisbane, and outback, plus Alice, but not Perth!
@set TEMPMCMD=%TEMPMCMD% --chunk=e140s40 --chunk=e140s30 --chunk=e150s40 --chunk=e150s30 --chunk=e130s30
@set TEMPMCMD=%TEMPMCMD% --fg-scenery=C:\FG\Scenery-1.0.1
@REM END Local setup

@type %TEMPROOT%\version
@echo Above is version of FG data...
%TEMPXM% %TEMPMCMD% --test
@echo.
@echo Is that what you want to do?
@echo %TEMPXM% %TEMPMCMD%
@echo *** CONTINUE? *** Ctrl+C to abort...
@pause
%TEMPXM% %TEMPMCMD%
@goto END

:ERRNB
@echo.
@echo ERROR: Can NOT locate the setup batch, dosetup.bat! Check name, location, and adjust...
@goto END


:ERR1
@echo.
@echo ERROR: Can NOT locate the executable %TEMPXM%! Check name, location, and adjust...
@goto END

:ERR2
@echo.
@echo ERROR: Can NOT locate the FG data version file %TEMPROOT%\version! Check name, location, and adjust...
@goto END

:ERR3
@echo.
@echo ERROR: Can NOT locate the palette file %TEMPP%! Check name, location, and adjust...
@goto END

:ERR4
@echo.
@echo ERROR: FAILED to create %TEMPAT% directory! Check why??? Perhaps another files called %TEMPAT%???
@echo This was supposed ot be done in dosetup.bat, called at the beginning...
@goto END

:ERR5
@echo.
@echo ERROR: FAILED to create %TEMPF% directory! Check why??? Perhaps another files called %TEMPF%???
@goto END

:ERR6
@echo.
@echo ERROR: FAILED to locate %TEMPFS% directory! Can not copy FONTS??? Check name. location...
@goto END

:ERR6B
@echo.
@echo ERROR: FAILED to copy %TEMPFS1% to %TEMPF1%! Can not copy FONTS??? Check name. location...
@goto END

:ERR7
@echo.
@echo ERROR: FAILED to locate %TEMPF1% file! Can not copy FONTS??? Check name. location...
@goto END

:ERR8
@echo.
@echo ERROR: FAILED to locate %TEMPF2% file! Can not copy FONTS??? Check name. location...
@goto END

:ERR8B
@echo.
@echo ERROR: FAILED to copy %TEMPF2% file to %TEMPF2%! Can not copy FONTS??? Check name. location...
@goto END

:ERR9
@echo.
@echo ERROR: FAILED to locate %TEMPSBG% file! Can not copy BACKGROUND world??? Check name. location...
@goto END

:ERR9B
@echo.
@echo ERROR: FAILED to copy %TEMPSBG% file! Can not copy BACKGROUND world??? Check name. location...
@goto END

:ERR10
@echo.
@echo ERROR: FAILED to copy %TEMPSAPD% file! Can not copy default PALETTE??? Check name. location...
@goto END

:ERR10A
@echo.
@echo ERROR: FAILED to create %TEMPAP% directory! Can not copy default PALETTE??? Check name. location...
@goto END

:ERR10B
@echo.
@echo ERROR: FAILED to copy %TEMPSAPD% to %TEMPAPD%! Can not copy default PALETTE??? Check name. location...
@goto END

:HELP
@echo.
@set TEMPAT=temp
@call atsetup
@echo HELP
@echo Enter an OUTPUT directory to use...
@echo An attempt to creat this directory will be made,
@echo and the necessary map work data files will be copied there...
@echo Then [%TEMPXM%] will be run, with a command like...
@echo %TEMPMCMD%
@goto END


:END
