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

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

@DefineVars
	@QString @Lang ="TXT"   // Natural language textfile
				// CD version (else FD)?
	@Integer @CD =(@Exists("@InDrive:.\\MADECD.EXE"))
				// Pass through installer:
				//  0=initial install, first time
				//  1=initial install, reconfiguring
				//  2=not initial install, first time
				//  3=not initial install, reconfiguring
	@Integer @Pass =((!@Exists("@InDrive:\\DISK.ID"))*2)
@EndVars

@If (@CD)
	@Name="@Name CD"
@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"
	@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 Enhancer"
	@QString @SF0  ="LSIZE"
	@QString @ST1  ="Creative Labs SoundBlaster"
	@QString @SF1  ="SBLASTER"
	@QString @ST2  ="@ST1 Pro"
	@QString @SF2  ="SBPRO"
	@QString @ST3  =@Text("SBclone")
	@QString @SF3  ="SBCLONE"
	@QString @ST4  ="Disney SoundSource"
	@QString @SF4  ="SOURCE"
	@QString @ST5  ="Tandy SL/TL & Sensation"
	@QString @SF5  ="TANSLTL"
	@QString @ST6  ="ProAudio Spectrum"
	@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 =@SF2
	@QString @ST11 ="Logitech SoundMan"
	@QString @SF11 =@SF7
	@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 @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 @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
	@Integer @IOAddr =0
	@QString @IOAddrQS =""
	@Integer @IRQ =0
	@QString @IRQQS =""
	@Integer @DMA =0
	@QString @DMAQS =""
	@QString @LH =""
	@Integer @TmpI1 =0
	@Integer @TmpI2 =0
	@Integer @TmpI3 =0
	@QString @TmpQS =""
	@Drive   @TmpDr =A
	@Dir     @TmpDi ="\\"
	@QString @HexDig ="0123456789ABCDEF0123456789abcdef"
@EndVars

@If (@CD)
	@Subdir="@Subdir@!-CD"
	@MADECmd="@MadeCMD@!CD"
	@FileBase="@FileBase@!CD"
	@PRJM=40
@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 (!@Pass) 
    @Text("HiNew", @Name)
		@If (!@CD)
    @Text("LongTime", @Name)
		@EndIf
    @Text("EscCmd")        
	@Else
    @Text("HiOld", @Name)
	@EndIf

	@Pause
@EndDisplay

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


ChooseDest:

@FlushOptions()

@TmpI1=@OtherM 
@If (!@CD)
	@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

@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

@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 (@CD) 
	@GetOption @Cls @CheckBox @LocalWindow(10,40)
 @Text("CopyPRJ1")

 @Text("CopyPRJ2", "@PRJM")
		@If (@TMpI2>=@TmpI1+@PRJM)
 @Text("PRJFits", "@OutDrive")
			@Option 61="@Text("CopyPRJ?")"
		@Else
 @Text("!PRJFits", "@OutDrive")
			@Option 12="@Text("NewDrv")"
		@EndIf
		@Move(22,0)@Text("CheckBoxCmds")@Move(0,0)
	@EndOption
	@If (12[=@Option) @Goto ChooseDest @EndIf
@EndIf

@MkDir(@OutDir)

@If ((!@CD) && 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="Disk #1"
	@If (@CD && 61[=@Option)
		@File @FileBase.PRJ
	@EndIf
	@File INSTALL.EXE
	@File INSTALL.DAT
	@File @TextFile @Out ITXT.TXT
	@BeginLib @FileBase.RED 
		@File *.ADV @Out DRIVERS\*.*
		@File *.COM @Out DRIVERS\*.*
		@File *.EXE @Out DRIVERS\*.*
		@File *.INI @Out DRIVERS\*.*
		@If (0 && @Exists("@InDrive:.\\READ.ME"))
			@File READ*.@Lang @Out READ.ME
		@EndIf
		@File SAMPLE.*
		@File SAMPLE.AD @Out *.OPL
		@File RTZ*.*
		@File @MADECmd.EXE      // Move after @EndLib for beta
	@EndLib
	@If (1 && @Exists("@InDrive:.\\READ.ME"))
		@File READ.ME
	@EndIf
@EndDisk

@Commit

@ChDrive @OutDrive
@ChDir "@Subdir"

@TmpI1=@PeekF("RTZ.PIF", 1, 1)
@TmpI2=0
@TmpI3=@PeekF(, 100, 1)
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)
@TmpI2=0
@TmpI3=@PeekF(, 89, 1)
@TmpQS="@OutDir\\RTZ.PIF"
GRP1:
	@TmpI3=(@StrIndex(@TmpQS, @TmpI2))
	@PokeF(,, 1, @TmpI3)
	@TmpI1=(@TmpI1-(@TmpI3 * ((@TmpI2 & 1)*255 + 1)))
	@TmpI2=(@TmpI2+1)
	@If (@TmpI3) @Goto GRP1 @EndIf

@TmpI2=0
@TmpI3=@PeekF(, 157, 1)
@TmpQS="@OutDir\\RTZ.ICO"
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)

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

 @Text("Win1", @Name)

 @Text("Win2")
	@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("WinDrv?")
		@Move(22,0)@Text("SelectCmds")@Move(0,0)
	@EndOutDrive

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

 @Text("WinDir?")

 @Text("CreDir")
	@EndSubdir

	@TmpQS="@TmpDr:\\@TmpDi"
	@MkDir(@TmpQS)
	@TmpQS="@TmpQS\\PROGMAN.INI"
	@If (!@Exists(@TmpQS))
		@Write(@TmpQS, "wt", "[Groups]\n")
	@EndIf
	@TmpI1=((@FileSize(@TmpQS)&65535)|16384)
	@Write(@TmpQS, "at",
		"Group@TmpI1=@OutDir\\RTZ.GRP\n")
@EndIf


ChooseConfig:

@FlushOptions
@FlushGroups

@TmpQS="@OutDir\\RTZ.CFG"
@If (@Exists(@TmpQS) && @PeekF(@TmpQS, 32, 1)<2) 
	@PeekF(@TmpQS, 32, 1)
	@CDDriveI=@PeekF(,, 1)
	@SetOption(20+@PeekF(,, 1))
	@SetOption(40+@PeekF(,, 1))
	@If (@PeekF(,, 1)) @SetGroup(S) @EndIf
	@If (@PeekF(,, 1)) @SetGroup(X) @EndIf
	@IOAddr=@PeekF(,, 2)
	@IRQ=@PeekF(,, 2)
	@DMA=@PeekF(,, 2)
	@If (@PeekF(,, 1)) @SetGroup(H) @EndIf
@Else
	@SetOption(65)
	@SetGroup(S)
	@If (@ExtraMem)
		@SetGroup(X)
		@SetGroup(H)
	@EndIf
@EndIf


InputConfig:

@If (@Pass&1)
	@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 (@CD) @Option 29="@ST9" @EndIf
	@EndOption
@EndIf

@If (65[=@Option)
	@If (@DetectSoundCard(0))
		@SetOption(21)
		@IOAddr=@DetectSoundCard(1)
		@IRQ=@DetectSoundCard(2)
		@DMA=@DetectSoundCard(3)
		@SetOption(43)
	@Else   // Assume LifeSize
		@SetOption(20)
		@ClearOption(65)
		@SetOption(66)
	@EndIf
	@Pass=(@Pass& -2)
@EndIf

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

@If (65[!@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 (@IOAddr==65535) 
	@IOAddrQS=@Text("None")
@EndIf

@TmpI1=@IRQ
@IRQQS=""
@If (!@TmpI1) @IRQQS="0" @EndIf
IRQD2H:
	@TmpI2=(@TmpI1 & 15)
	@TmpI1=(@TmpI1 / 16)
	@If (@TmpI1 + @TmpI2) 
		@IRQQS="@StrMid(@HexDig, @TmpI2, 1)@IRQQS"
	@EndIf
	@If (@TmpI1) @Goto IRQD2H @EndIf
@If (@IRQ==65535)
	@IRQQS=@Text("None")
@EndIf

@If (@Pass&1)
	@If (@IOAddr!=65535)
		@GetString @IOAddrQS @Cls @Prompt=" @Text("Hex?") "
 @Text("IOA?"):

		@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
		@IOAddr=(@IOAddr&65535)
	@EndIf

	@If (@IRQ!=65535)
		@GetString @IRQQS @Cls @Prompt=" @Text("Hex?") "
 @Text("IRQ?"):

		@EndString
		@IRQ=0
		@TmpI1=(-1)
		@Goto IRQH2D2
IRQH2D1:
		@IRQ=(@IRQ*16 + (@StrFind(@HexDig, @StrMid(@IRQQS, @TmpI1, 1)) & 15))
IRQH2D2:
		@TmpI1=(@TmpI1+1)
		@If (@TmpI1<@StrLen(@IRQQS)) @Goto IRQH2D1 @EndIf
		@IRQ=(@IRQ&65535)
	@EndIf

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

		@EndInteger
		@DMA=(@DMA&65535)
	@EndIf
@EndIf

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

@If     (32[=@Option) @SetOption(50)
@ElseIf (33[=@Option) @SetOption(42)
@ElseIf ((@Pass&1) && 66[!@Option)
	@GetOption @Cls @LocalWindow(12,40)
 @Text("Mus?"):
		@Option 40="@MT0"
		@Option 66="@Text("AutoDet")"
		@Option 43="@MT3"
		@Option 44="@MT4"
		@Option 49="@MT9"
	      //@Option 54="@MT14"
		@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 52="@MT12"
		@Option 45="@MT5"
	@EndOption
@EndIf
@If (66[=@Option)
	@If (@DetectMusicDriver() == 1)
		@SetOption(41)
	@Else   // MT-32 and LAPC-I are detectable; MIDI isn't
		@SetOption(48)
	@EndIf
@EndIf

@MusDrvI=0
L3:
@If (@MusDrvI+40[!@Option)
   @MusDrvI =(@MusDrvI+1)
   @Goto L3
@EndIf

@If (24[=@Option || 33[=@Option)
	@ClearGroup(S)
@EndIf
@If (!@ExtraMem)
	@ClearGroup(X)
	@ClearGroup(H)
@EndIf

@If (@Pass&1)
	@If ((24[!@Option && 33[!@Option) || @ExtraMem)
		@GetGroups @Cls @CheckBox @LocalWindow(9,40)
 @Text("Add?"):
		@If (24[!@Option && 33[!@Option)
			@Set S="@Text("Smooth?")"
		@EndIf
		@If (@ExtraMem)
			@Set X="@Text("EMS?")"
			@Set H="@Text("LoadHi?")"
		@EndIf
		@Move(22,0)@Text("CheckBoxCmds")@Move(0,0)
		@EndGroups
	@EndIf

	@If (@CD) 
		@GetOutDrive @CDDrive @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("CD?", @Name):
		@Move(22,0)@Text("SelectCmds")@Move(0,0)
		@EndOutDrive
		@CDDriveI=@Eval(@CDDrive-A)
	@EndIf
@EndIf

@Write(@TmpQS, "wb", "@Name\r\n\x1a               ")
@PokeF(@TmpQS, 32, 1, 1)             // .CFG file version
@PokeF(,, 1, @CDDriveI)
@PokeF(,, 1, @SndDrvI)
@PokeF(,, 1, @MusDrvI)
@PokeF(,, 1, (S[=@Group))
@PokeF(,, 1, (X[=@Group))
@PokeF(,, 2, @IOAddr)
@PokeF(,, 2, @IRQ)
@PokeF(,, 2, @DMA)
@PokeF(,, 1, (H[=@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,40)@StrToken(@SndDrvs, @SndDrvI*2 + 1, ":=")
      @Text("IOA"):@Move(4,40)@IOAddrQS 
      @Text("IRQ"):@Move(5,40)@IRQQS
      @Text("DMA"):@Move(6,40)@DMAQS
    @Text("Mus"):@Move(7,40)@StrToken(@MusDrvs, @MusDrvI*2 + 1, ":=")
    @Text("Smooth"):@Move(8,39)@If (S[=@Group) @Text("~Y") @Else @Text("~N") @EndIf
    @Text("EMS"):@Move(9,39)@If (X[=@Group) @Text("~Y") @Else @Text("~N") @EndIf
    @Text("LoadHi"):@Move(10,39)@If (H[=@Group) @Text("~Y") @Else @Text("~N") @EndIf @EndIf
   @If (@CD) @Text("CD"):@Move(11,40)@CDDrive: @EndIf

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

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


@If (40[!@Option)
	@MusDrv=@StrToken(@MusDrvs, @MusDrvI*2, ":=")
	@Args="@Args -M:DRIVERS\\@MusDrv"
@EndIf
@If (S[=@Group)
	@Args="@Args -O"
@EndIf
@If (X[=@Group)
	@Args="@Args -X"
@EndIf
@If (H[=@Group)
	@LH="LOADHIGH"
@EndIf
@If (@CD)
	@Args="@Args -P:@CDDrive:\\"
	@If (@Exists("@OutDir\\@FileBase.PRJ"))
		@Args="@Args -F"
	@EndIf
@EndIf

@Write("RTZ.BAT", "wt",
	"@@echo off\n@OutDrive:\ncd \\@Subdir\n")
@If (@SndDrvI == 12)
	@Write(, "at",
		"@LH DRIVERS\\ULTRAMID -DDRIVERS\\ -M90 -NMT32.INI\n")
@EndIf
@Write(, "at",
	"@LH @SndDrv\n")
@If (@SndDrvI == 6 || @SndDrvI == 7)
	@Write(, "at",
		"PAS set fm to 90\nPAS set pcm to 60\nPAS set vol to 60\n")
@EndIf
@Write(, "at",
	"@MADECmd @FileBase @Args\n@SndDrv u\n")
@If (@SndDrvI == 12)
	@Write(, "at",
		"DRIVERS\\ULTRAMID -F\necho.\n")
@EndIf

@TmpQS="@OutDir\\READ.ME"
@If (@Pass<2 && @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

	@Pause
@EndDisplay

@Finish @Cls
@EndFinish
