;$VER: TandemCD Install 38.1 (01.06.94)
;Copyright ©1993/1994 Elaborate Bytes, Oliver Kastl

(onerror
	(makeassign "TandemCDInst")
	(makeassign "TandemCD")
)

(set #autoMount 1)
(set #CDDevice_NC "CD0" )

(set #wbversion (getversion "libs:version.library"))
(set #wbversion (/ #wbversion 65536) )

(set #instEjectCD 1)

; (set #TandemUnit 0)
; (set #TandemDevice 0)

(complete 0)

(if (< #wbversion 37)
	(abort "\n\nAmigaDOS 2.04 or higher is required for TandemCD! "
			 "\n\nAn upgrade will be needed for your Amiga." )
)


(if (< (getdiskspace "SYS:") 61440)
	(abort "\n\nApproximately 60K of disk space is needed on your SYS: volume."
			 "\n\nYou only have " (/ (getdiskspace "SYS:") 1024)	"K free.\n\n"
			 "Delete or transfer some files from the SYS: volume and try again." )
)

(askdisk
	(prompt "\n\nPlease insert the disk labeled \"TandemCDInstall\".")
	(help	"\n\nTandemCD driver, FileSystem and other utilities will be copied "
			"from this disk into your system.")
	(dest  "TandemCDInstall")
	(newname "TandemCDInst")
)

(working "\n\nLaunching the FindCD program to find "
         "the Device and Unit of your CD-Rom..."
         "\n\nYou may let the program scan for CD-Roms by clicking \"SCAN\"."
         "\n\nChoose the device and unit and click \"USE\"!")

(set #TandemProduct ( run "TandemCDInst:FindCD tandemcd#? TandemCDInst:devs " ( safe ) ) )

(if ( NOT (= #TandemProduct 0) )
	(
	(abort "\nCould not find your CDROM hardware!"
			 "\n\nYou must select device and unit within the FindCD program "
			 "and click the \"USE\" gadget!" 
          "\n\nYou may let the program scan for CD-Roms by clicking \"SCAN\"."
			 "\n\nPlease check your hardware installation and try again! " )
	)
)


( set #TandemDevice (getenv "CDROM_Device" ))
( set #TandemUnit (+ (getenv "CDROM_Unit" )))

(set #theirlevel @user-level )
(user 2)

(set #CDDevice_NC
	(askstring
		(prompt "\n\nWhat is the name for the AmigaDOS device?\n\n(The trailing colon MUST NOT be present)" )
		(default #CDDevice_NC )
		(help "\n\nThis is the name under which AmigaDOS will reference the "
				"CD-Rom as.  While usually "
				#CDDevice_NC
				", it can be any name you choose. "
				"\n\nThe trailing : (colon) MUST NOT be present." )
	)
)


(set #CDDevice (cat #CDDevice_NC ":") )


(if (= #theirlevel 2 )
	(
	(set #TandemDevice
		(askstring
			(prompt "\n\nWhat is the name for the exec device driver? " )
			(default #TandemDevice )
			(help "\n\nThis is the name of the device driver to use. "
					"The name is different for different configurations. "
					"\n\nDon't alter this name, if you don't know why! " )
		)
	)

	(set #TandemUnit
		(asknumber
			(prompt "\n\nWhat is the Unit number of your CD-Rom drive?" )
			(default #TandemUnit )
			(help "\n\nThis is the unit # of the CD-Rom drive.  This is usually a "
					"numerical value between 0 and 8.\n\n"
					"If you have only one TandemCD, you have no choice: set this to 0." )
		)
	)
	)
)

(set #autoMount
	(askbool
		(prompt "\n\nWould you like the CD-Rom drive automatically mounted upon bootup?" )
		(help "\n\nIf you would like, the appropriate commands will be added to your user-startup file to automatically mount TandemCD.\n")
		(default 1)
	)
)


(if #autoMount
	(set #mountDirectory "devs:DOSDrivers/")
)

(if (not #autoMount)
	(set #mountDirectory "sys:storage/DOSDrivers/")
)


(set #tandemDir
	(askdir
		(prompt "\n\nSpecify the directory in which the TandemCD support programs will be placed:" )
		(help "\n\nTandemCD contains a number of support programs.  This directory will specifiy where the programs will be placed.  If you need, create a separate directory for the files.")
		(default @default-dest)
		(newpath)
	)
)

(set @default-dest #tandemDir)

(makeassign "TandemCD" #tandemDir (safe))

(user #theirlevel)

(protect "l:TandemCacheCDFS" "rwed" )
(copyfiles
	(prompt "\n\nCopying CDROM FileSystem to the l: directory.\n" )
	(source "TandemCDInst:l/TandemCacheCDFS")
	(dest "l:")
	(confirm)
	(help "\n\nThis will copy over the CDROM FileSystem program to your "
		"l: directory\n\nThis is an essential step in the installation "
		"process.\n" )
)



(complete 10 )

(protect (cat "devs:" #TandemDevice ) "rwed" )
(copyfiles
	(prompt "\n\nCopying tandem.device to the devs: directory.\n" )
	(source (cat  "TandemCDInst:devs/" #TandemDevice ))
	(dest "devs:")
	(confirm)
	(help "\n\nThis will copy over the tandemcd.device program to your "
		"devs: directory\n\nThis is an essential step in the installation "
		"process.\n" )
)



(complete 20 )

	(copylib
			(prompt "\n\nCopying 2.1 Mount command")
			(source "TandemCDInst:C/Mount")
			(dest "C:")
			(help "\n\nThis will copy over a new Mount command to your C: directory. "
			      "\n\nThis is an essential step in the installation process "
			      "as the TandemCacheCDFS requires at least version 38.20 of "
			      "the Mount command." )
			(confirm)
	)

(if (< #wbversion 38)
	((set #startupCommand (cat "mount " #CDDevice " from devs:MountList." #CDDevice_NC "\n") )
	(if #autoMount
		((protect "S:User-Sequence" "srwed" )

		(startup "TandemCD"
			(command #startupCommand )
			(prompt "\n\nInserting MOUNT command into the startup-sequence")
			(help "\n\nThe command \"MOUNT " #CDDevice " FROM DEVS:MOUNTLIST." #CDDevice_NC "\" is being inserted into your "
					"\"S:Startup-Sequence\" or \"S:User-Startup\" file to "
					"automatically start TandemCD upon bootup." )
		))
	)
	(if (not #autoMount)
		((protect "S:User-Sequence" "srwed" )

		(startup "TandemCD"
			(prompt "\n\nRemoving MOUNT command from the startup-sequence")
			(help "\n\nThe command \"MOUNT " #CDDevice " FROM DEVS:MOUNTLIST." #CDDevice_NC "\" will be removed from your "
					"\"S:Startup-Sequence\" or \"S:User-Startup\" file because you didn't "
					"want to automatically start TandemCD upon bootup." )
		))
	)

	(protect (cat "devs:MountList." #CDDevice_NC) "rwed" )


	(textfile
		(dest (cat "devs:MountList." #CDDevice_NC) )
		(append "/***************************************************************/\n"
				  "/*  TandemCD mountlist entry © 1993 Elaborate Bytes, O. Kastl  */\n"
				  "/***************************************************************/\n")
		(append #CDDevice "\n")
		(append "	FileSystem     = L:TandemCacheCDFS /* The name of the game */\n" )
		(append "	Device         = "#TandemDevice" /* Name of exec device driver */\n" )
		(append "	Unit           = "#TandemUnit" /* exec device unit */\n" )
		(append "	Flags          = 0 /* OpenDevice flags */\n")
		(append "	BlocksPerTrack = 1 /* Unused */\n")
		(append "	BlockSize      = 2048 /* True, but unused */\n")
		(append "	Mask           = 0x7ffffffe /* Memory mask for direct read */\n")
		(append "	MaxTransfer    = 0x100000 /* Maximum amount of bytes for direct read */\n")
		(append "	Reserved       = 0 /* Unused */\n")
		(append "	Interleave     = 0 /* Unused */\n")
		(append "	LowCyl         = 0 /* Unused */\n")
		(append "	HighCyl        = 5000 /* Unused */\n")
		(append "	Surfaces       = 1 /* Unused */\n")
		(append "	Buffers        = 50 /* Number of cache lines */\n")
		(append "	BufMemType     = 1 /* MEMF_PUBLIC, use whatever you require */\n")
		(append "	GlobVec        = -1 /* Do not change! */\n")
		(append "	Mount          = 1 /* Mount it immediately */\n")
		(append "	Priority       = 10 /* Priority of FileSystem task */\n")
		(append "	DosType        = 0x43443031 /* Currently unused */\n")
		(append "	StackSize      = 3000 /* Minimum stack required is 3000! */\n")
		(append "	Control        = \"MD=0 LC=2 DC=4 L LV LFC=1\"\n")
		(append "   /* The Control field is for special adjustments */\n")
		(append "   /* L/S convert all file names to lowercase */\n")
		(append "   /* LV/S convert volume names to lowercase */\n")
		(append "   /* LFC/N start converting at this character */\n")
		(append "   /* LC/N/A number of blocks per cache line */\n")
		(append "   /* DC/N/A number of cache lines for the data cache */\n")
		(append "   /* MD/N/A number of blocks, when starting direct read, not using */\n")
		(append "   /* the cache. 0 will be a reasonable default (LC*DC+1) */\n")
		(append "   /* S/S Do SCSI direct commands, no Trackdisk like commands! */\n")
		(append "   /* NC/S Do NOT use TD_ADDCHANGEINT, poll for DiskChange! */\n")
		(append "   /* M/S Issue a TD_MOTOR (OFF) command after read */\n")
		(append "#\n")
	)
))



(if (> #wbversion 37)

	((textfile
		(dest (cat #mountDirectory #CDDevice_NC) )
		(append "/***************************************************************/\n"
				  "/*  TandemCD mountlist entry © 1993 Elaborate Bytes, O. Kastl  */\n"
				  "/***************************************************************/\n")
		(append "	FileSystem     = L:TandemCacheCDFS /* The name of the game */\n" )
		(append "	Device         = "#TandemDevice" /* Name of exec device driver */\n" )
		(append "	Unit           = "#TandemUnit" /* exec device unit */\n" )
		(append "	Flags          = 0 /* OpenDevice flags */\n")
		(append "	BlocksPerTrack = 1 /* Unused */\n")
		(append "	BlockSize      = 2048 /* True, but unused */\n")
		(append "	Mask           = 0x7ffffffe /* Memory mask for direct read */\n")
		(append "	MaxTransfer    = 0x100000 /* Maximum amount of bytes for direct read */\n")
		(append "	Reserved       = 0 /* Unused */\n")
		(append "	Interleave     = 0 /* Unused */\n")
		(append "	LowCyl         = 0 /* Unused */\n")
		(append "	HighCyl        = 5000 /* Unused */\n")
		(append "	Surfaces       = 1 /* Unused */\n")
		(append "	Buffers        = 50 /* Number of cache lines */\n")
		(append "	BufMemType     = 1 /* MEMF_PUBLIC, use whatever you require */\n")
		(append "	GlobVec        = -1 /* Do not change! */\n")
		(append "	Mount          = 1 /* Mount it immediately */\n")
		(append "	Priority       = 10 /* Priority of FileSystem task */\n")
		(append "	DosType        = 0x43443031 /* Currently unused */\n")
		(append "	StackSize      = 3000 /* Minimum stack required is 3000! */\n")
		(append "	Control        = \"MD=0 LC=2 DC=4 L LV LFC=1\"\n")
		(append "   /* The Control field is for special adjustments */\n")
		(append "   /* L/S convert all file/volume names to lowercase */\n")
		(append "   /* LV/S convert volume names to lowercase */\n")
		(append "   /* LFC/N start converting at this character */\n")
		(append "   /* LC/N/A number of blocks per cache line */\n")
		(append "   /* DC/N/A number of cache lines for the data cache */\n")
		(append "   /* MD/N/A number of blocks, when starting direct read, not using */\n")
		(append "   /* the cache. 0 will be a reasonable default (LC*DC+1) */\n")
		(append "   /* S/S Do SCSI direct commands, no Trackdisk like commands! */\n")
		(append "   /* NC/S Do NOT use TD_ADDCHANGEINT, poll for DiskChange! */\n")
		(append "   /* M/S Issue a TD_MOTOR (OFF) command after read */\n")
	)

	(copyfiles
			(prompt "\n\nCopying Mountlist icon")
			(source "TandemCDInst:Devs/DOSDrivers/CD0.info")
			(dest #mountDirectory)
			(newname (cat #CDDevice_NC ".info"))
			(help "\n\nThis will copy over an icon for the mountlist file.")
			(confirm)

	)

	(protect "S:User-Sequence" "srwed" )
	(startup "TandemCD"
		(prompt "\n\nRemoving MOUNT command from the startup-sequence")
		(help "\n\nThe command \"MOUNT " #CDDevice " FROM DEVS:MOUNTLIST." #CDDevice_NC "\" will be removed from your "
				"\"S:Startup-Sequence\" or \"S:User-Startup\" file if it is present from "
				"an earlier installation." )
		)

	(if ( exists ( cat "devs:MountList." #CDDevice_NC ) )

		((protect (cat "devs:MountList." #CDDevice_NC) "rwed " )
		(delete (cat "devs:MountList." #CDDevice_NC)
			(prompt "\n\nDeleting file \"DEVS:MOUNTLIST." #CDDevice_NC "\"" )
			(help "\n\nThe file \"DEVS:MOUNTLIST." #CDDevice_NC "\" will be deleted "
					"if it is present from an earlier installation." )
			(confirm)
			)
		))
	)
)


(complete 40 )

(set #instCDFSprefs
	(askbool
		(prompt "\n\nShould the CDFSprefs utility be installed?")
		(help "\n\nThis will copy over the CDFSprefs utility "
				"to your SYS:Prefs directory\n\nIf you do not "
				"wish the CDFSprefs program to be transferred to your system, "
				"skip this step.\n" )
		(default 1)
	)
)

(if #instCDFSprefs
	((protect "SYS:Prefs/CDFSprefs" "rwed" )
	(protect "SYS:Prefs/CDFSprefs.info" "rwed" )
	(copyfiles
		(prompt "\n\nCopying the CDFSprefs program to the "
				  "SYS:Prefs directory.\n" )
		(source "TandemCDInst:CDFSprefs")
		(dest "SYS:Prefs")
		(infos)
		(help "\n\nThis will copy over the CDFSprefs "
				"program to your SYS:Prefs directory\n\nIf you do not "
				"wish the CDFSprefs program to be transferred to your system, "
				"skip this step.\n" )
		(confirm)
	)

	(tooltype
		(dest "SYS:Prefs/CDFSprefs" )
		(noposition)
	)
))

(complete 50 )

(set #instKillDev
	(askbool
		(prompt "\n\nShould the KillDev utility be installed?")
		(help "\n\nThis will copy over the KillDev utility "
				"to your TandemCD directory\n\nIf you do not "
				"wish the KillDev program to be transferred to your system, "
				"skip this step.\n" )
		(default 1)
	)
)

(if #instKillDev
	((protect "TandemCD:KillDev" "rwed" )
	(protect "TandemCD:KillDev.info" "rwed" )
	(copyfiles
		(prompt "\n\nCopying the KillDev program to the "
				  "TandemCD: directory.\n" )
		(source "TandemCDInst:KillDev")
		(dest "TandemCD:")
		(infos)
		(help "\n\nThis will copy over the KillDev "
				"program to your TandemCD: directory\n\nIf you do not "
				"wish the KillDev program to be transferred to your system, "
				"skip this step.\n" )
		(confirm)
	)

	(tooltype
		(dest "TandemCD:KillDev" )
		(settooltype "DOSDEV" #CDDevice )
		(noposition)
	)
))

(complete 60 )

(set #instFindCD
	(askbool
		(prompt "\n\nShould the FindCD utility be installed?")
		(help "\n\nThis will copy over the FindCD utility "
				"to your TandemCD directory\n\nIf you do not "
				"wish the FindCD program to be transferred to your system, "
				"skip this step." )
		(default 1)
	)
)

(if #instFindCD
	((protect "TandemCD:FindCD" "rwed" )
	(protect "TandemCD:FindCD.info" "rwed" )
	(copyfiles
		(prompt "\n\nCopying the FindCD program to the "
				  "TandemCD: directory.\n" )
		(source "TandemCDInst:FindCD")
		(dest "TandemCD:")
		(infos)
		(help "\n\nThis will copy over the FindCD "
				"program to your TandemCD directory\n\nIf you do not "
				"wish the FindCD program to be transferred to your system, "
				"skip this step." )
		(confirm)
	)

	(tooltype
		(dest "TandemCD:FindCD" )
		(noposition)
	)

))

(set #instPlayCD
	(askbool
		(prompt "\n\nShould the PlayCD utility be installed?")
		(help "\n\nThis will copy over the PlayCD utility "
				"to your TandemCD directory\n\nIf you do not "
				"wish the PlayCD program to be transferred to your system, "
				"skip this step.\n" )
		(default 1)
	)
)

(complete 70 )

(if #instPlayCD
	((protect "TandemCD:PlayCD" "rwed" )
	(protect "TandemCD:PlayCD.info" "rwed" )
	(copyfiles
		(prompt "\n\nCopying PlayCD CDAudio controller program to the "
				  "TandemCD: directory.\n" )
		(source "TandemCDInst:PlayCD")
		(dest "TandemCD:")
		(infos)
		(help "\n\nThis will copy over the PlayCD CDAudio controller "
				"program to your TandemCD: directory\n\nIf you do not "
				"wish the PlayCD program to be transferred to your system, "
				"skip this step.\n" )
		(confirm)
	)


	(copyfiles
		(prompt "\n\nCopying PlayCD font to the "
				  "Fonts: directory.\n" )
		(source "TandemCDInst:fonts")
		(dest "fonts:")
		(all)
		(help "\n\nThis will copy over the fonts used by the PlayCD CDAudio controller "
				"program to your Fonts: directory. Note that the PlayCD program will also work "
				"without its fonts copied!\n\nIf you do not "
				"wish the PlayCD fonts to be transferred to your system, "
				"skip this step.\n" )
		(confirm)
	)

	(tooltype
		(dest "TandemCD:PlayCD" )
		(settooltype "DEVICE" #TandemDevice )
		(settooltype "UNIT" ("%ld" #TandemUnit ))
		(noposition)
	)
))


(set #instJukebox
	(askbool
		(prompt "\n\nShould the JukeBox Audio Player be installed?")
		(help "\n\nThis will copy over the JukeBox drawer "
				"to your TandemCD directory\n\nIf you do not "
				"wish the JukeBox drawer to be transferred to your system, "
				"skip this step." )
		(default 1)
	)
)

(complete 80 )

(if #instJukebox
	(
	(protect "TandemCD:JukeBox" "rwed" )
	(protect "TandemCD:JukeBox.info" "rwed" )
	(makedir "TandemCD:JukeBox" 
		(infos)
		(prompt "\n\nCreating drawer for JukeBox\n")
		(help "\n\nThis will create a drawer for the JukeBox "
				"Audio Player." )
	(safe)
	)

(makeassign "JukeBox" "TandemCD:JukeBox")

(working "\n\nDecrunching Jukebox...."
         "\n\nPlease Wait!")

( if ( run "TandemCDInst:c/lha e -a TandemCDInst:JukeBox JukeBox:" )
	(
	(makeassign "JukeBox")
	(abort "\n\nUnable to decrunch JukeBox!")
	)
)


	(tooltype
		(dest "JukeBox:JukeBox" )
		(settooltype "DEVICE" #TandemDevice )
		(settooltype "UNIT" ("%ld" #TandemUnit ))
		(settooltype "PLAYER" ("tandem.player"))
	)

	(makeassign "JukeBox")
))

(complete 90 )


(if #instEjectCD
	(
	(set #instEjectCD
	(askbool
		(prompt "\n\nShould the EjectCD utility be installed?")
		(help "\n\nThis will copy over the EjectCD utility "
				"to your TandemCD directory\n\nIf you do not "
				"wish the EjectCD program to be transferred to your system, "
				"skip this step.\n" )
		(default 1)
	)
	))
)

(if #instEjectCD
	((protect "TandemCD:EjectCD" "rwed" )
	(protect "TandemCD:EjectCD.info" "rwed" )
	(copyfiles
		(prompt "\n\nCopying EjectCD program to the "
				  "TandemCD: directory.\n" )
		(source "TandemCDInst:EjectCD")
		(dest "TandemCD:")
		(help "\n\nThis will copy over the EjectCD utility "
				"to your TandemCD directory\n\nIf you do not "
				"wish the EjectCD program to be transferred to your system, "
				"skip this step.\n" )
		(infos)
		(confirm)
	)

	(tooltype
		(dest "TandemCD:EjectCD" )
		(settooltype "DEVICE" #TandemDevice )
		(settooltype "UNIT" ("%ld" #TandemUnit ))
		(noposition)
	)
))

(complete 100 )

(makeassign "TandemCDInst")
(makeassign "TandemCD")

