@echo off
echo ************************************************************************
echo * Setting up the MUNGA environment, see SETENV.bat for usage
echo ************************************************************************
rem ------------------------------------------------
rem - setenv.bat performs actions that must occur in
rem - the shell prior to execution of rpl4*.exe
rem ------------------------------------------------
rem - there are four arguments that must all be specified
rem -   1= t/r     where t=thrustmaster, r=rio
rem -   2= s/f     where s=slow clock,   f=fast clock
rem -   3= s/n     where s=sound,        n=nosound
rem -   4= p/g/n/r where p=plasma and gauges, g=gauges, n=no gauges, r=review
rem -   5= i/n     where i=intercom,     n=no intercom
rem ------------------------------------------------
rem - setenv with no args is RIO, SLOW, SOUND, NONE, NOINTERCOM
rem ------------------------------------------------
rem

rem *************************************************************************
rem * Controls, anything but t or r goes with preset defaults in L4CONTROLS
rem * if they are not set you will get RIO
rem *************************************************************************
rem
if "%1"=="t" goto THRUSTMASTER
if "%1"=="r" goto RIO
if "%L4CONTROLS%"=="" goto RIO
goto CONTROLSDONE

:RIO
set L4CONTROLS=RIO,KEYBOARD
echo L4CONTROLS set to %L4CONTROLS%
goto CONTROLSDONE

:THRUSTMASTER
set L4CONTROLS=THRUSTMASTER,KEYBOARD
echo L4CONTROLS set to %L4CONTROLS%
goto CONTROLSDONE

:CONTROLSDONE
rem
rem *************************************************************************
rem * Real time clock, anything but s or f goes with preset defaults in 
rem * L4TIMER, if it isn't set you will get slow
rem *************************************************************************
rem 
if "%2"=="s" goto SLOWCLOCK
if "%2"=="f" goto FASTCLOCK
if "%L4TIMER%"=="" goto SLOWCLOCK
goto TIMERDONE

:FASTCLOCK
set L4TIMER=FAST
echo L4TIMER set to FAST
goto TIMERDONE

:SLOWCLOCK
set L4TIMER=
echo L4TIMER set to SLOW
goto TIMERDONE

:TIMERDONE
rem
rem *************************************************************************
rem * GAUGES/PLASMA anything but p,n or g will get you the preset defaults 
rem * in L4GAUGE if that isn't set you will get none.
rem *************************************************************************
rem 
if "%4"=="n" goto NOGAUGE
if "%4"=="g" goto NOPLASMA
if "%4"=="p" goto PLASMA
if "%4"=="r" goto GREVIEW
if "%L4GAUGE%"=="" goto NOGAUGE
goto GAUGEDONE

:GREVIEW
set L4GAUGE=640x480x8
set L4PLASMA=com2
echo L4GAUGE  set to %L4GAUGE%
echo L4PLASMA set to %L4PLASMA%
goto GAUGEDONE

:PLASMA
set L4GAUGE=640x480x16
set L4PLASMA=com2
echo L4GAUGE  set to %L4GAUGE%
echo L4PLASMA set to %L4PLASMA%
goto GAUGEDONE

:NOPLASMA
set L4GAUGE=640x480x16
set L4PLASMA=
echo L4GAUGE  set to %L4GAUGE%
echo L4PLASMA set to off
goto GAUGEDONE

:NOGAUGE
set L4GAUGE=
set L4PLASMA=
echo L4GAUGE  set to off
echo L4PLASMA set to off

:GAUGEDONE
rem
rem *************************************************************************
rem * INTERCOM anything but i or n will get you the preset defaults 
rem * in L4INTERCOM if that isn't set you will get none.
rem *************************************************************************
rem
if "%5"=="n" goto NOINTERCOM
if "%5"=="i" goto INTERCOM
if "%L4INTERCOM%"=="" goto NOINTERCOM
goto ICOMDONE

:NOINTERCOM
set L4INTERCOM=
echo L4INTERCOM set to off
goto ICOMDONE

:INTERCOM
set L4INTERCOM=ON
echo L4INTERCOM set to on

:ICOMDONE
:AUDIOVIDEO
rem
rem *+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*
rem from here on down has not been updated yet, except to make sure sound is
rem set right based on L4INTERCOM
rem *+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*
rem
rem -----------------------------
rem main video
rem -----------------------------
if "%VIDEOFORMAT%"=="" set VIDEOFORMAT=svga
set L4DPLCFG=%A4DPLCFG%
if "%L4DPLCFG%"=="" set L4DPLCFG=btdpl.ini
set A4DPLCFG=
if "%L4VIDEO%"=="OFF" goto VIDEODONE
set DPLARG=/tranny~.\vrendmon.btl~/i860~.\vrnostex.mng~/device~0x150~/video~%VIDEOFORMAT%~/pipes~1~/qual~0x14~/system_tex~0~

:VIDEODONE
rem -----------------------------
rem - AWE settings
rem -----------------------------
if "%3"=="n" goto NOSOUND
if "%3"=="s" goto SOUND
if "%L4SOUND%"=="OFF" goto NOSOUND
if "%L4SOUND%"=="" goto NOSOUND
if "%L4SOUND%"=="ON" goto SOUND
if "%L4SOUND%"=="CAMERA" goto SOUND
goto NOSOUND

:SOUND
if exist c:\setvol.bat call c:\setvol.bat
if not exist c:\setvol.bat set AWE_MASTER_VOLUME=200

set AWE_FRONT=A220 I5 D1 H5 P330 T6
set AWE_REAR=A240 I7 D3 H6 P300 T6

if "%L4INTERCOM%"=="ON" goto AWEINTERCOM

copy /v audio\ctmix.cfg c:\sb16\ctmix.cfg
set BLASTER=%AWE_FRONT%
c:\sb16\sb16set /p /q
set BLASTER=%AWE_REAR%
c:\sb16\sb16set /p /q

if "%REVIEW%"=="1" goto SOUNDREVIEW
if "%L4SOUND%"=="CAMERA" goto SOUNDREVIEW
goto SOUNDCOMMON

:AWEINTERCOM
copy /v audio\icom.cfg c:\sb16\ctmix.cfg
set BLASTER=%AWE_FRONT%
c:\sb16\sb16set /p /q
c:\sb16\sb16set /li:220;0
set BLASTER=%AWE_REAR%
c:\sb16\sb16set /p /q
goto SOUNDCOMMON

:SOUNDCOMMON
set BLASTER=%AWE_FRONT%
c:\sb16\sb16set /ma:%AWE_MASTER_VOLUME%;0 /mi:235;0 /ba:255;0 /tr:90;0
set BLASTER=%AWE_REAR%
c:\sb16\sb16set /ma:%AWE_MASTER_VOLUME%;0 /mi:230;0 /ba:235;0 /tr:110;0
set BLASTER=%AWE_FRONT%
goto SOUNDDONE

:SOUNDREVIEW
set BLASTER=%AWE_FRONT%
c:\sb16\sb16set /ma:240;0 /mi:245;0 /ba:90;0 /tr:90;0
set BLASTER=%AWE_REAR%
c:\sb16\sb16set /ma:240;0 /mi:245;0 /ba:90;0 /tr:90;0
set BLASTER=%AWE_FRONT%
goto SOUNDDONE

:NOSOUND
set L4SOUND=OFF
set AWE_FRONT=
set AWE_REAR=

:SOUNDDONE

rem
rem *************************************************************************
rem * Print a summary of all the environmentals we think are important
rem *************************************************************************
rem
echo ************************************************************************
echo * Environment is setup as follows
echo * L4CONTROLS = %L4CONTROLS%
echo * L4TIMER    = %L4TIMER%
echo * L4SOUND    = %L4SOUND%
echo * L4GAUGE    = %L4GAUGE%
echo * L4VIDEO    = %L4VIDEO%
echo * L4PLASMA   = %L4PLASMA%
echo * L4INTERCOM = %L4INTERCOM%
echo ************************************************************************

