@DefineProject
	@Name="Return to Zork"
	@Version="1.2"
	@OutDrive=C
	@Subdir="\\RTZ"
	@InDiskBell=1
@EndProject

@If (@Exists("@OutDrive:\\386MAX$$"))
	@Display
 @Text("386MAX")

 @Text("MaySLO", @Name)

 @Pause
	@EndDisplay
@EndIf

@ChDrive @InDrive
// @ChDir "@InDir"

@DefineVars
	@QString @Lang ="TXT"   // Natural language textfile
				// Version (0=FD, 1=regular CD, 2=Reel Magic CD)
	@Integer @Media =0
				// Installing (else reconfiguring)?
	@Integer @Initial =(@Exists("@InDrive:\\DISK.ID"))
	@Integer @ChgCfg =0     // Changing (else showing) configuration?
@EndVars

@If (@Exists("@InDrive:.\\RTZCD.*"))
	@Media=1
	@Name="@Name CD-ROM"
@ElseIf (@Exists("@InDrive:.\\RTZRM.*"))
	@Media=2
	@Name="@Name Reel Magic"
@EndIf

@If (!@Exists("@InDrive:.\\ITXT.@Lang"))
	@If (1)        // 0=international; 1=English only
		@SetOption(1)
	@Else
		@GetOption @Cls @LocalWindow(9,40)
				@Name
			@Option 1="For  ENGLISH,  highlight this line and press ENTER"
			@Option 2="Pour FRANAIS, ..."
			@Option 3="Fr  DEUTSCH,  diese Linie hervvorheben und ENTER drcken"
		  //@Option 4="Para ESPA₯OL,  ..."
		  //@Option 5="Per  ITALIANO, ..."
		@EndOption
	@EndIf
	@If     (1[=@Option) @Lang="ENG"
	@ElseIf (2[=@Option) @Lang="FRA"
	@ElseIf (3[=@Option) @Lang="DEU"
	@ElseIf (4[=@Option) @Lang="ESP"
	@ElseIf (5[=@Option) @Lang="ITA"
	@EndIf
@EndIf
@TextFile="ITXT.@Lang"

@DefineVars
	@Integer @ExtraMem =(@ExtTotal + @EMMTotal)
	@QString @MADECmd ="MADE"
	@QString @FileBase ="RTZ"
	@QString @ReadMe ="README"
	@Integer @PRJM =22
	@Integer @OtherM =2
	@QString @Args =""
	@Drive   @CDDrive =@InDrive     // CD-ROM drive, if any
	@Integer @CDDriveI =@Eval(@CDDrive-A)   // (0=A, ..., 26=Z)
	@QString @OutDir =""
	@QString @ST0  ="LifeSize Sound Enhancer"
	@QString @SF0  ="LSIZE"
	@QString @ST1  ="Creative Labs Sound Blaster"
	@QString @SF1  ="SBLASTER"
	@QString @ST2  ="@ST1 Pro"
	@QString @SF2  ="SBPRO"
	@QString @ST3  =@Text("SBclone")
	@QString @SF3  ="SBCLONE"
	@QString @ST4  ="Disney Sound Source"
	@QString @SF4  ="SOURCE"
	@QString @ST5  ="Tandy SL/TL & Sensation"
	@QString @SF5  ="TANSLTL"
	@QString @ST6  ="Pro AudioSpectrum"
	@QString @SF6  ="PAUDIO"
	@QString @ST7  ="@ST6 16"
	@QString @SF7  ="PAS16"
	@QString @ST8  ="Covox Speech Thing"
	@QString @SF8  ="CVXSND"
	@QString @ST9  ="Windows Sound System"
	@QString @SF9  ="SNDSYS"
	@QString @ST10 ="@ST1 16"
	@QString @SF10 ="SB16"
	@QString @ST11 ="Logitech SoundMan"
	@QString @SF11 =@SF2
	@QString @ST12 ="Advanced Gravis UltraSound"
	@QString @SF12 ="GF166"
	@QString @ST13 =@Text("AdLibG")
	@QString @SF13 ="ADLIBG"
	@QString @SndDrvs ="@SF0=@ST0:@SF1=@ST1:@SF2=@ST2:@SF3=@ST3:@SF4=@ST4:@SF5=@ST5:@SF6=@ST6:@SF7=@ST7:@SF8=@ST8:@SF9=@ST9:@SF10=@ST10:@SF11=@ST11:@SF12=@ST12:@SF13=@ST13"
	@QString @SndDrv =""
	@Integer @SndDrvI =0
	@QString @Snd =""
	@QString @MT0 =@Text("None")
	@QString @MF0 ="NUL"
	@QString @MT1 =@Text("AdLib")
	@QString @MF1 ="ADLIB"
	@QString @MT2 =@ST13
	@QString @MF2 =@SF13
	@QString @MT3 =@ST1
	@QString @MF3 =@MF1
	@QString @MT4 =@ST2
	@QString @MF4 =@MF1
	@QString @MT5 =@Text("PCspkr")
	@QString @MF5 ="PCSPKR"
	@QString @MT6 ="Roland LAPC-I synthesizer"
	@QString @MF6 ="MT32MPU"
//    @QString @MT7 ="Roland MPU-401 MIDI"
	@QString @MT7 ="General Midi/Roland MPU-401"
	@QString @MF7 =@MF6
	@QString @MT8 ="Roland MT-32 synthesizer"
	@QString @MF8 =@MF6
	@QString @MT9 =@ST10
	@QString @MF9 =@MF1
	@QString @MT10 =@ST12
	@QString @MF10 ="GF1MIDI"
	@QString @MT11 =@ST6
	@QString @MF11 =@MF1
	@QString @MT12 =@ST3
	@QString @MF12 =@MF1
	@QString @MT13 =@ST11
	@QString @MF13 =@MF1
	@QString @MT14 ="@ST10 MIDI"
	@QString @MF14 ="SB16MPU"
	@QString @MusDrvs ="@MF0=@MT0:@MF1=@MT1:@MF2=@MT2:@MF3=@MT3:@MF4=@MT4:@MF5=@MT5:@MF6=@MT6:@MF7=@MT7:@MF8=@MT8:@MF9=@MT9:@MF10=@MT10:@MF11=@MT11:@MF12=@MT12:@MF13=@MT13:@MF14=@MT14"
	@QString @MusDrv =""
	@Integer @MusDrvI =0
	@QString @Mus =""
	@QString @SndDflt =""
	@QString @SndDflts ="5:3:4:12:5s:5:11p:11p:5:5:14:13:10!u:2s!"
	@Integer @IOAddr =0
	@QString @IOAddrQS =""
	@Integer @IRQ =0
	@QString @IRQQS =""
	@Integer @DMA =0
	@QString @DMAQS =""
	@QString @LH =""
	@QString @HexDig ="0123456789ABCDEF0123456789abcdef"
	@QString @NY ="~N ~Y"
	@QString @BOn =""
	@QString @BOff =""
	@Integer @TmpI1 =0
	@Integer @TmpI2 =0
	@Integer @TmpI3 =0
	@QString @TmpQS =""
	@Drive   @TmpDr =A
	@Dir     @TmpDi ="\\"
@EndVars

@If (@Media==1)
	@Subdir="@Subdir@!-CD"
	@MADECmd="@MADECmd@!CD"
	@FileBase="@FileBase@!CD"
	@ReadMe="@ReadMe@!CD"
	@PRJM=45
@ElseIf (@Media==2)
	@Subdir="@Subdir@!-RM"
	@MADECmd="@MADECmd@!RM"
	@FileBase="@FileBase@!RM"
	@ReadMe="@ReadMe@!RM"
@EndIf

@Display
	@MoveCStr(0,54,126,"ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ»")
	@MoveCStr(1,54,126,"Ί    INFOCOM     Ί")
	@MoveCStr(2,54,126,"ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ")
	@MoveCStr(3,56,  0,"                  ")
	@MoveCStr(1,72,0,"  ")
	@MoveCStr(2,72,0,"  ")
	@MoveCStr(4,20,95,"ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ»")
	@MoveCStr(5,20,95,"Ί  R E T U R N   T O   Z O R K  Ί")
	@MoveCStr(6,20,95,"ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ")
	@MoveCStr(7,22, 0,"                                 ")
	@MoveCStr(5,53,0,"  ")
	@MoveCStr(6,53,0,"  ")
	@Move(8,0)
	@If (@Initial)
	@Text("HiNew", @Name)
		@If (!@Media)
	@Text("LongTime", @Name)
		@EndIf
	@Text("EscCmd")
	@Else
	@Text("HiOld", @Name)
	@EndIf

	@Pause
@EndDisplay

@If (!@Initial)
	@OutDrive=@InDrive
	@Subdir="@GetCWD(@InDrive)"
	@OutDir="@OutDrive:\\@Subdir"
	@Goto ChooseConfig
@EndIf


ChooseDest:

@FlushOptions()

@TmpI1=@OtherM
@If (!@Media)
	@SetOption(61)
	@TmpI1=(@TmpI1+@PRJM)
@EndIf

@GetOutDrive @LocalWindow(15,40)
	// @Suppress @InDrive // INSTALL only accepts A-Z after @Suppress
	@If (!@DirExists("A:")) @Suppress A @EndIf
	@If (!@DirExists("B:")) @Suppress B @EndIf
	@Cls

 @Text("ProdDrv?1", @Name)

 @Text("ProdDrv?2", "@TmpI1")

 @Text("ProdDrv?3")
	@Move(22,0)@Text("SelectCmds")@Move(0,0)
@EndOutDrive

@TmpI2=(@DiskFree(@OutDrive)/1000000)
@If (@TmpI2<@TmpI1)
	@GetOption @Cls @LocalWindow(13,40)
 @Text("NotEnufDisk", @Name, "@TmpI1", "@OutDrive", "@Eval(@TmpI2+1)")

 @Text("NowWhat?")
		@Option 12="@Text("NewDrv")"
		@Option 13="@Text("TryToInstall")"
		@Option 14="@Text("Abort")"
	@EndOption
	@If     (12[=@Option) @Goto ChooseDest
	@ElseIf (14[=@Option) @Exit
	@EndIf
@EndIf

@If (@Media)
	@GetOption @Cls @LocalWindow(13,40)
 @Text("CopyPRJ1")

 @Text("CopyPRJ2", "@PRJM")
		@If (@TMpI2>=@TmpI1+@PRJM)
 @Text("PRJFits", "@OutDrive")
			@CheckBox
			@Option 61="@Text("CopyPRJ?")"
			@Move(22,0)@Text("CheckBoxCmds")@Move(0,0)
		@Else
 @Text("!PRJFits", "@OutDrive")

 @Text("NowWhat?")
			@Option  0="@Text("!Copy")"
			@Option 61="@Text("TryToCopy")"
			@Option 12="@Text("NewDrv")"
			@Option 14="@Text("Abort")"
		@EndIf
	@EndOption
	@If     (12[=@Option) @Goto ChooseDest
	@ElseIf (14[=@Option) @Exit
	@EndIf
@EndIf

@GetSubdir @Cls @LocalWindow(9,40)
	@Prompt=" @Text("Dir?") "

 @Text("ProdDir?", @Name)

 @Text("CreDir")
@EndSubdir

@OutDir="@OutDrive:\\@Subdir"
@If (@DirExists(@OutDir))
	@GetOption @Cls @LocalWindow(11,40)
 @Text("DirExist", @OutDir)

 @Text("NowWhat?")
		@If (@DirExists("@OutDir\\DRIVERS"))
			@Option 11="@Text("NewCfg")"
		@EndIf
		@Option 12="@Text("NewDrvOrDir")"
		@Option 13="@Text("Overwrite")"
		@Option 14="@Text("Abort")"
	@EndOption
	@If     (11[=@Option) @Goto ChooseConfig
	@ElseIf (12[=@Option) @Goto ChooseDest
	@ElseIf (14[=@Option) @Exit
	@EndIf
@EndIf

@MkDir(@OutDir)

@If ((!@Media) && 61[=@Option)
@DefineDisk @Label="Disk #1"  @BeginLib RTZ.001 @File *.* @EndLib @EndDisk
@DefineDisk @Label="Disk #2"  @BeginLib RTZ.002 @File *.* @EndLib @EndDisk
@DefineDisk @Label="Disk #3"  @BeginLib RTZ.003 @File *.* @EndLib @EndDisk
@DefineDisk @Label="Disk #4"  @BeginLib RTZ.004 @File *.* @EndLib @EndDisk
@DefineDisk @Label="Disk #5"  @BeginLib RTZ.005 @File *.* @EndLib @EndDisk
@DefineDisk @Label="Disk #6"  @BeginLib RTZ.006 @File *.* @EndLib @EndDisk
@DefineDisk @Label="Disk #7"  @BeginLib RTZ.007 @File *.* @EndLib @EndDisk
@DefineDisk @Label="Disk #8"  @BeginLib RTZ.008 @File *.* @EndLib @EndDisk
@DefineDisk @Label="Disk #9"  @BeginLib RTZ.009 @File *.* @EndLib @EndDisk
@DefineDisk @Label="Disk #10" @BeginLib RTZ.010 @File *.* @EndLib @EndDisk
@DefineDisk @Label="Disk #11" @BeginLib RTZ.011 @File *.* @EndLib @EndDisk
@DefineDisk @Label="Disk #12" @BeginLib RTZ.012 @File *.* @EndLib @EndDisk
@EndIf

@DefineDisk @Label="CD-ROM"
	@If (@Media && 61[=@Option)
		@File @FileBase.PRJ
	@EndIf
	@File INSTALL.EXE
	@File INSTALL.DAT
	@File @TextFile @Out ITXT.TXT
	@BeginLib @FileBase@!DRV.RED
		@File *.* @Out DRIVERS\\*.*
//        @File SBPRO.COM @Out DRIVERS\\SB16.*
	@EndLib
	@BeginLib @FileBase.RED
		@If (@Exists("@InDrive:\\READ.ME"))
			@File @ReadMe.@Lang @Out READ.ME
		@EndIf
		@File SAMPLE.*
		@File SAMPLE.AD @Out *.OPL
		@File RTZ*.*
		@File *.EXE
	@EndLib
	@If (@Exists("@InDrive:\\@MADECmd.EXE"))
		@File @MADECmd.EXE
	@EndIf
@EndDisk

@Commit

@ChDrive @OutDrive
@ChDir "@Subdir"

@TmpI1=@PeekF("RTZ.PIF", 1, 1)
@PeekF(, 101, 0)
@TmpI2=0
PIF:
	@TmpI3=(@StrIndex(@OutDir, @TmpI2))
	@PokeF(,, 1, @TmpI3)
	@TmpI1=(@TmpI1+@TmpI3- 32)
	@TmpI2=(@TmpI2+1)
	@If (@TmpI3) @Goto PIF @EndIf
@PokeF(, 1, 1, @TmpI1)

@TmpI1=@PeekF("RTZ.GRP", 4, 2)
@PeekF(, 90, 0)
@TmpQS="@OutDir\\RTZ.PIF"
@TmpI2=0
GRP1:
	@TmpI3=(@StrIndex(@TmpQS, @TmpI2))
	@PokeF(,, 1, @TmpI3)
	@TmpI1=(@TmpI1-(@TmpI3 * ((@TmpI2 & 1)*255 + 1)))
	@TmpI2=(@TmpI2+1)
	@If (@TmpI3) @Goto GRP1 @EndIf

@PeekF(, 158, 0)
@TmpQS="@OutDir\\RTZ.ICO"
@TmpI2=0
GRP2:
	@TmpI3=(@StrIndex(@TmpQS, @TmpI2))
	@PokeF(,, 1, @TmpI3)
	@TmpI1=(@TmpI1-(@TmpI3 * ((@TmpI2 & 1)*255 + 1)))
	@TmpI2=(@TmpI2+1)
	@If (@TmpI3) @Goto GRP2 @EndIf
@PokeF(, 4, 2, @TmpI1)


ChooseWindows:

@GetOption @Cls @CheckBox @LocalWindow(10,40)

 @Text("Win1", @Name)
	@If (!@InWin)
 @Text("Win2")
	@EndIf
	@SetOption(62) @Option 62="@Text("Win?")"
	@Move(22,0)@Text("CheckBoxCmds")@Move(0,0)
@EndOption
@If (62[=@Option)
	@GetOutDrive @TmpDr @LocalWindow(15,40)
		// @Suppress @InDrive // INSTALL only accepts A-Z after @Suppress
		@If (!@DirExists("A:")) @Suppress A @EndIf
		@If (!@DirExists("B:")) @Suppress B @EndIf
		@Cls

 @Text(@StrToken("WinDrv?1 WinDrv?2", !!@InWin))
		@Move(22,0)@Text("SelectCmds")@Move(0,0)
	@EndOutDrive

	@TmpDi="\\WINDOWS"
	@GetSubdir @TmpDi @Cls @LocalWindow(9,40)
		@Prompt=" @Text("Dir?") "

 @Text("WinDir?")
		@If (!@InWin)
 @Text("CreDir")
		@EndIf
	@EndSubdir

	@TmpQS="@TmpDr:\\@TmpDi"
	@If (@InWin && !@DirExists(@TmpQS))
		@Display @Cls

 @Text("!DirExist", @TmpQS)

			@Pause
		@EndDisplay
		@Goto ChooseWindows
	@EndIf
	@MkDir(@TmpQS)
	@TmpQS="@TmpQS\\PROGMAN.INI"
	@If (!@Exists(@TmpQS))
		@Write(@TmpQS, "wt", "[Groups]\n")
	@ElseIf (@Grep(@TmpQS, "\\RTZ.GRP\r\n")+1)
		@Goto ChooseConfig
	@EndIf
	@TmpI1=((@FileSize(@TmpQS)&65535)|8192)
	@Write(@TmpQS,, "Group@TmpI1=@OutDir\\RTZ.GRP\n")
@EndIf


ChooseConfig:

@FlushOptions
@FlushGroups

@TmpQS="@OutDir\\RTZ.CFG"
@TmpI1=32767
@If (@Exists(@TmpQS))
	@TmpI1=@PeekF(@TmpQS, 32, 1)
@EndIf

@If (@TmpI1>2)
	@SetOption(65)
	@SetOption(67)
	@SetGroup(O) @SetGroup(S)
	@If (@ExtraMem)
		@SetGroup(B) @SetGroup(H) @SetGroup(X)
	@EndIf
	@Goto InputConfig
@EndIf

@CDDriveI=@PeekF(,, 1)
@SetOption(20+@PeekF(,, 1))
@SetOption(40+@PeekF(,, 1))
@If (@PeekF(,, 1)) @SetGroup(O) @EndIf
@If (@PeekF(,, 1)) @SetGroup(X) @EndIf
@IOAddr=@PeekF(,, 2)
@IRQ=@PeekF(,, 2)
@DMA=@PeekF(,, 2)
@If (@PeekF(,, 1)) @SetGroup(H) @EndIf
@If (@PeekF(,, 1)) @SetGroup(S) @EndIf

@If (@TmpI1<2)
	@If (X[=@Group) @SetGroup(B) @EndIf
@Else
	@If (@PeekF(,, 1)) @SetGroup(B) @EndIf
@EndIf


InputConfig:

@If (@ChgCfg)
	@FlushOptions
	@GetOption @Cls @LocalWindow(11,40)
 @Text("Snd?"):
	  //@Option 65="@Text("AutoDet")"
		@Option 21="@ST1"
		@Option 22="@ST2"
		@Option 30="@ST10"
		@Option 23="@ST3"
		@Option 20="@ST0"
		@Option 33="@ST13"
		  //@Option 28="@ST8"
		@Option 24="@ST4"
		@Option 32="@ST12"
		@Option 31="@ST11"
		@Option 26="@ST6"
		@Option 27="@ST7"
		//@Option 25="@ST5"
		@If (@Media) @Option 29="@ST9" @EndIf
	@EndOption
@EndIf
@If (65[=@Option)
//  @If (@DetectSoundCard(0))
//      @SetOption(21)
//      @IOAddr=@DetectSoundCard(1)
//      @IRQ=@DetectSoundCard(2)
//      @DMA=@DetectSoundCard(3)
//      @SetOption(66)
//  @Else   // Assume LifeSize
		@SetOption(20)
//  @EndIf
@EndIf

@SndDrvI=0
L2:
@If (@SndDrvI+20[!@Option)
	@SndDrvI=(@SndDrvI+1)
	@Goto L2
@EndIf
@SndDrv=@StrToken(@SndDrvs, @SndDrvI*2, ":=")
@SndDrv="DRIVERS\\@SndDrv"
@Snd=@StrToken(@SndDrvs, @SndDrvI*2 + 1, ":=")

@If (65[=@Option && @ChgCfg)
	@ClearOption(65)
	@GetOption @Cls @CheckBox @LocalWindow(11,40)
		@SetOption(0) @Option 0="@Text("Det", @Snd)"
		@Move(22,0)@Text("CheckBoxCmds")@Move(0,0)
	@EndOption
	@If (0[!@Option) @Goto InputConfig @EndIf
@EndIf

@If (66[!@Option)
	@IOAddr=@PeekF("@OutDir\\@SndDrv.COM", 262, 2)
	@IRQ=@PeekF(,, 2)
	@DMA=@PeekF(,, 2)
@EndIf

@TmpI1=@IOAddr
@IOAddrQS=""
@If (!@TmpI1) @IOAddrQS="0" @EndIf
IOAD2H:
	@TmpI2=(@TmpI1&15)
	@TmpI1=(@TmpI1/16)
	@If (@TmpI1+@TmpI2)
		@IOAddrQS="@StrMid(@HexDig, @TmpI2, 1)@IOAddrQS"
	@EndIf
	@If (@TmpI1) @Goto IOAD2H @EndIf

@If (@ChgCfg)
	@TmpQS=@IOAddrQS
	@TmpI2=@IRQ
	@TmpI3=@DMA
	@If (@DetectSoundCard(0))
		@TmpI1=@DetectSoundCard(1)
		@TmpQS=""
		@If (!@TmpI1) @TmpQS="0" @EndIf
IOAD2H2:
			@TmpI2=(@TmpI1&15)
			@TmpI1=(@TmpI1/16)
			@If (@TmpI1+@TmpI2)
				@TmpQS="@StrMid(@HexDig, @TmpI2, 1)@TmpQS"
			@EndIf
			@If (@TmpI1) @Goto IOAD2H2 @EndIf
		@TmpI2=@DetectSoundCard(2)
		@TmpI3=@DetectSoundCard(3)
	@EndIf

	@If (@IOAddr!=65535)
		@GetString @IOAddrQS @Cls @Prompt=" @Text("Hex?") "
 @Text("IOA?", @TmpQS):

		@EndString
		@IOAddr=0
		@TmpI1=(-1)
		@Goto IOAH2D2
IOAH2D1:
		@IOAddr=(@IOAddr*16 + (@StrFind(@HexDig, @StrMid(@IOAddrQS, @TmpI1, 1)) & 15))
IOAH2D2:
		@TmpI1=(@TmpI1+1)
		@If (@TmpI1<@StrLen(@IOAddrQS)) @Goto IOAH2D1 @EndIf
	@EndIf

	@IRQ=@TmpI2
	@If (@IRQ!=65535)
		@GetInteger @IRQ @Cls @Prompt=" @Text("Dec?") "
 @Text("IRQ?", "@TmpI2"):

		@EndInteger
	@EndIf

	@If (@DMA!=65535)
		@GetInteger @DMA @Cls @Prompt=" @Text("Dec?") "
 @Text("DMA?", "@TmpI3"):

		@EndInteger
	@EndIf
@EndIf

@IOAddr=(@IOAddr&65535)
@IOAddrQS=@StrTail(@IOAddrQS, 4)
@If (@IOAddr==65535) @IOAddrQS=@Text("None") @EndIf

@IRQ=(@IRQ&65535)
@IRQQS="@IRQ"
@If (@IRQ==65535) @IRQQS=@Text("None") @EndIf

@DMA=(@DMA&65535)
@DMAQS="@DMA"
@If (@DMA==65535) @DMAQS=@Text("None") @EndIf


InputMusic:

@SndDflt=@StrToken(@SndDflts, @SndDrvI, ":")
@TmpI1=@StrToInt(@SndDflt)
@If (@StrFind(@SndDflt, "!")+1)
	@SetOption(40+@TmpI1)
	@ClearOption(67)
@ElseIf (@ChgCfg)
	@GetOption @Cls @LocalWindow(12,40)
 @Text("Mus?"):
		@Option 40="@MT0"
	  //@Option 67="@Text("AutoDet")"
		@Option 43="@MT3"
		@Option 44="@MT4"
		@Option 49="@MT9"
	  //@Option 54="@MT14"
		@Option 52="@MT12"
		@Option 48="@MT8"
		@Option 47="@MT7"
		@Option 46="@MT6"
		@Option 41="@MT1"
		@Option 42="@MT2"
		@Option 50="@MT10"
		@Option 53="@MT13"
		@Option 51="@MT11"
		@Option 45="@MT5"
	@EndOption
@EndIf
@If (67[=@Option)
  @If (0)
	@TmpI2=@DetectMusicDriver()
	@If     (@TmpI2==3) @TmpI1=8
	@ElseIf (!@TmpI2)   @TmpI1=5
	@EndIf
  @EndIf
	@SetOption(40+@TmpI1)
@EndIf

@MusDrvI=0
L3:
@If (@MusDrvI+40[!@Option)
   @MusDrvI=(@MusDrvI+1)
   @Goto L3
@EndIf
@MusDrv=@StrToken(@MusDrvs, @MusDrvI*2, ":=")
@Mus=@StrToken(@MusDrvs, @MusDrvI*2 + 1, ":=")

@If (67[=@Option && @ChgCfg)
	@ClearOption(67)
	@GetOption @Cls @CheckBox @LocalWindow(11,40)
		@SetOption(0) @Option 0="@Text("Det", @Mus)"
		@Move(22,0)@Text("CheckBoxCmds")@Move(0,0)
	@EndOption
	@If (0[!@Option) @Goto InputMusic @EndIf
@EndIf

@TmpI1=(@StrFind(@SndDflt, "s")+1)
@If (@TmpI1)
	@ClearGroup(O)
@EndIf
@If (!@ExtraMem)
	@ClearGroup(X)
	@ClearGroup(B)
	@ClearGroup(H)
@EndIf

@If (@ChgCfg)
	@If (@ExtraMem || !@TmpI1 || @Media)
		@GetGroups @Cls @CheckBox @LocalWindow(9,40)
 @Text("Add?")
		@If (!@TmpI1)
			@Set O="@Text("Smooth?")"
		@EndIf
		@If (@ExtraMem)
			@Set X="@Text("EMS?")"
			@Set B="@Text("EMSVideo?")"
			@Set H="@Text("LoadHi?")"
		@EndIf
		@If (@Media==1)
			@Set S="@Text("DigSnd?")"
		@EndIf
		@Move(22,0)@Text("CheckBoxCmds")@Move(0,0)
		@EndGroups
	@EndIf

	@If (@Media)
		@GetOutDrive @CDDrive @LocalWindow(15,40)
		@If (!@DirExists("A:")) @Suppress A @EndIf
		@If (!@DirExists("B:")) @Suppress B @EndIf
		@Cls

 @Text("CD?", @Name):
		@Move(22,0)@Text("SelectCmds")@Move(0,0)
		@EndOutDrive
		@CDDriveI=@Eval(@CDDrive-A)
	@EndIf
@EndIf

@TmpQS="@OutDir\\RTZ.CFG"
@Write(@TmpQS, "wb", "@Name\r\n\x1a               ")
@PokeF(@TmpQS, 32, 1, 2)             // .CFG file version
@PokeF(,, 1, @CDDriveI)
@PokeF(,, 1, @SndDrvI)
@PokeF(,, 1, @MusDrvI)
@PokeF(,, 1, O[=@Group)
@PokeF(,, 1, X[=@Group)
@PokeF(,, 2, @IOAddr)
@PokeF(,, 2, @IRQ)
@PokeF(,, 2, @DMA)
@PokeF(,, 1, H[=@Group)
@PokeF(,, 1, S[=@Group)
@PokeF(,, 1, B[=@Group)

@PokeF("@OutDir\\@SndDrv.COM", 262, 2, @IOAddr)
@PokeF(,, 2, @IRQ)
@PokeF(,, 2, @DMA)

@CDDrive=(@StrIndex("ABCDEFGHIJKLMNOPQRSTUVWXYZ", @CDDriveI))

@GetOption @Cls @CheckBox @LocalWindow(20,40)
		 @Name @Text("SysCfg")

	@Text("Snd"):@Move(3,44)@Snd
	  @Text("IOA"):@Move(4,44)@IOAddrQS
	  @Text("IRQ"):@Move(5,44)@IRQQS
	  @Text("DMA"):@Move(6,44)@DMAQS
	@Text("Mus"):@Move(7,44)@Mus
	@Text("Smooth"):@Move(8,44)@Text(@StrToken(@NY,O[=@Group))
	@Text("EMS"):@Move(9,44)@Text(@StrToken(@NY,X[=@Group))
	@Text("EMSVideo"):@Move(10,44)@Text(@StrToken(@NY,B[=@Group))
	@Text("LoadHi"):@Move(11,44)@Text(@StrToken(@NY,H[=@Group))
	@If (@Media==1)@Text("DigSnd"):@Move(12,44)@Text(@StrToken(@NY,S[=@Group)) @EndIf
	@If (@Media)@Text("CD"):@Move(13,44)@CDDrive: @EndIf

	@Text("ToChg"):
			   @OutDir\INSTALL

	@If (!@ChgCfg) @SetOption(63) @EndIf @Option 63="@Text("Cfg?")"
	@Move(22,0)@Text("CheckBoxCmds")@Move(0,0)
@EndOption
@ChgCfg=1
@If (63[=@Option) @Goto InputConfig @EndIf

@If (O[=@Group)   @Args="@Args -O" @EndIf
@If (X[=@Group)   @Args="@Args -X" @EndIf
@If (B[=@Group)   @Args="@Args -L" @EndIf
@If (S[!@Group)   @Args="@Args -S" @EndIf
@If (H[=@Group)   @LH="LOADHIGH "  @EndIf

@BOn="@@echo off\n@OutDrive:\ncd \\@Subdir\n"
@BOff="@SndDrv u\n"

@If (@StrFind(@SndDflt, "u")+1)
	@BOn="@BOn@LH@!DRIVERS\\ULTRAMID -DDRIVERS\\ -M90 -NMT32.INI\n"
	@BOff="@BOff@!DRIVERS\\ULTRAMID -F\necho.\n"
@EndIf
@BOn="@BOn@LH@SndDrv\n"
/*
@If (@StrFind(@SndDflt, "p")+1)
	@BOn="@BOn@!PAS set fm to 90\nPAS set pcm to 60\nPAS set vol to 60\n"
@EndIf
*/

@If (@Media==1)
	@Write("MECH2.BAT", "wt",
		"@BOn\nDIR @CDDrive: > nul\n@CDDrive:\\MECH2\\MECINTRO @CDDrive:\\MECH2\\\n@BOff")
//        "@BOn@CDDrive:\\MECH2\\MECINTRO @CDDrive:\\MECH2\\\n@BOff")
/*    @Write("RSCARRY.BAT", "wt",
		"@BOn@CDDrive:\\SCARRY\\BEST @CDDrive:\\SCARRY\\BESTDEMO@Args -P:@CDDrive:\\SCARRY\\ -F\n@BOff")
	
	@Write("SIMON.BAT", "wt",
//        "@@echo off\n @CDDrive:\n cd \\SIMON\nCALL SIMON\n")
		"@BOn\nDIR @CDDrive: > nul\n@CDDrive:\n cd \\SIMON\nCALL SIMON\n")
*/
@EndIf

@If (40[!@Option) @Args="@Args -M:DRIVERS\\@MusDrv" @EndIf
@If (@Media)
	@Args="@Args -P:@CDDrive:\\"
	@If (@Exists("@OutDir\\@FileBase.PRJ"))
		@Args="@Args -F"
	@EndIf
	@If (@Media==2)
		@BOn="@BOn@!FMPDRV\n"
	@EndIf
@EndIf

@Write("RTZ.BAT", "wt", "@BOn\nDIR @CDDrive: > nul\n@MADECmd @FileBase@Args\n@BOff")

@TmpQS="@OutDir\\READ.ME"
@If (@Initial && @Exists(@TmpQS))
	@GetOption @Cls @CheckBox @LocalWindow(10,40)

 @Text("README1", @Name)

 @Text("README2")
		@SetOption(64) @Option 64="@Text("VuREADME?")"
		@Move(22,0)@Text("CheckBoxCmds")@Move(0,0)
	@EndOption
	@If (64[=@Option) @Browse(@TmpQS) @EndIf
@EndIf

@Display @Cls
 @Text("Done", @Name)

 @Text("ToPlay"):

	@OutDir\RTZ

 @Text("ToChg"):

	@OutDir\INSTALL

 @If (@Initial && @InWin)@Text("ExitWin", @Name) @EndIf

	@Pause
@EndDisplay

@Finish @Cls
@EndFinish
