;$VER: IDEfix Install 46.2 (23.08.95)
;Copyright 1993/1994/1995 Elaborate Bytes, Oliver Kastl

( set #ControlDefault 1 )

(onerror
	(makeassign "CacheCDFSInst" (safe))
	(makeassign "CacheCDFS" (safe))
)

(set #autoMount 1)
(set #CDDevice_NC "CD0" )
(set #instEjectCD 1)
(set #ReplaceOld 1 )
(set #DeleteOld 1 )

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

(complete 0)

(if (< #wbversion 37)
	(abort "\n\nAmigaDOS 2.04 or higher is required for CacheCDFS! "
			 "\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." )
)

(makeassign "CacheCDFSInst" "" ( safe) )


(set #theirlevel @user-level )

(set #Match ( run "CacheCDFSInst:CheckIDEfix" ( safe ) ) )

(user 2)

(message "\nWelcome to IDE-fix, CacheCDFS2, CD32-Emulator and PlayCD!"
			"\n\nIMPORTANT: The name \"IDE-fix\" must be printed on your original disk!" 
         "\n\nIf you bought this program and \"IDE-fix\" is NOT printed "
         "directly on the disk (e.g., the disk has a sticker or no label at all) "
         "you are using a pirated copy!"
         "\n\nIn this case please contact us immediately and tell us where you bought it! "
         "Thank you!" )


(set #DefaultDir (tackon @default-dest "IDEfix"))

(set #CDFSDir
	(askdir
		(prompt "\n\nSpecify the directory in which the support programs will be placed:" )
		(help "\n\nIDE-fix and CacheCDFS contain 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 #DefaultDir)
		(newpath)
	)
)

(user #theirlevel)

(if (NOT (exists #CDFSDir ))
	(
	(makedir #CDFSDir
		(safe)
		(infos)
	)
	)
)


(set @default-dest #CDFSDir)


(makeassign "CacheCDFS" #CDFSDir (safe))

(if (= #Match 0)
	(
	(copylib
		(prompt "This will copy the IDEfix program to your C: directory.")
		(help "This will copy the IDEfix program to your C: directory.")
		(source "CacheCDFSInst:C/IDEfix")
		(confirm)
		(dest "C:")
	)
	(copylib
		(prompt "This will copy the LoadIDE program to your C: directory.")
		(help "This will copy the LoadIDE program to your C: directory.")
		(source "CacheCDFSInst:C/LoadIDE")
		(confirm)
		(dest "C:")
	)

	(copylib
		(prompt "This will copy the MountIDE program to your C: directory.")
		(help "This will copy the MountIDE program to your C: directory.")
		(source "CacheCDFSInst:C/MountIDE")
		(confirm)
		(dest "C:")
	)

	(copylib
		(prompt "This will copy the Ship program to your C: directory.")
		(help "This will copy the Ship program to your C: directory.")
		(source "CacheCDFSInst:C/Ship")
		(confirm)
		(dest "C:")
	)

	(copylib
		(prompt "This will copy the AutoPark program to your C: directory.")
		(help "This will copy the AutoPark program to your C: directory.")
		(source "CacheCDFSInst:C/AutoPark")
		(confirm)
		(dest "C:")
	)


	(copyfiles
		(prompt "This will copy Icons for the Ship, Autopark and MountIDE programs "
			"to your Harddisk. You can copy these Icons wherever you like, e.g. in your "
			"SYS:WBStartUp drawer.")
		(help "This will copy Icons for the Ship, Autopark and MountIDE programs "
			"to your Harddisk. You can copy these Icons wherever you like, e.g. in your "
			"SYS:WBStartUp drawer.")
		(source "CacheCDFSInst:Harddisk")
		(infos)
		(all)
		(confirm)
		(dest "CacheCDFS:Harddisk")
	)
	

	(user 2)

	(message "IDEfix, LoadIDE, MountIDE, AutoPark and Ship are installed in your C: "
         	"directory. You must start IDEfix manually, as this program "
         	"will NOT alter your startup-sequence! "
         	"\n\nEnter \"IDEfix\" or \"LoadIDE reset\" behind SetPatch in your startup-sequence "
         	"to use IDEfix! "
         	"\n\nUse \"Ship <unit>\" from the CLI to park your harddisk!"
         	"\nUse \"MountIDE force\" from the CLI to mount additional SyQuest cartridges!"
         	"\n\nClick PROCEED to install CacheCDFS and/or ATAPI. Click ABORT to quit.")

	)
)

(user 2)

(message "\n\nNow the FindCD program will be launched 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\"!"
         "\n\nIf FindCD hangs: Reboot, start the installation again and "
         "click CANCEL within FindCD!")

(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\"!"
         "\n\nIf FindCD hangs: Reboot, start the installation again and "
         "click CANCEL within FindCD!")

(set #Product ( run "CacheCDFSInst:FindCD PATH=CacheCDFSInst:Devs add" ( safe ) ) )


(if ( NOT (= #Product 0) )
	(
	(set #CDROM_Device
		(askstring
			(prompt "\n\nWhat is the name for the exec device driver? " )
			(default "scsi.device" )
			(help "\n\nThis is the name of the device driver to use. "
					"The name is different for different configurations. "
					"\n\nConsult the manual of your SCSI/CD-Rom host adapter "
					"if you don't know the name!" )
		)
	)

	(set #CDROM_Unit
		(asknumber
			(prompt "\n\nWhat is the Unit number of your CD-Rom drive?" )
			(default 5 )
			(help "\n\nThis is the unit # of the CD-Rom drive.  This is usually a "
					"numerical value between 0 and 7." )
		)
	)
	)
)

(if (= #Product 0 )
	(
	( set #CDROM_Device (getenv "CDROM_Device" ))
	( set #CDROM_Unit (+ (getenv "CDROM_Unit" )))
	)
)

( set #SourcePath (tackon "CacheCDFSInst:devs" #CDROM_Device))

(user #theirlevel)

(if (exists #SourcePath )
	(
	(copylib
		(prompt "This will copy the " #CDROM_Device " to your DEVS: directory.")
		(help "This will copy the " #CDROM_Device " to your DEVS: directory.")
		(source #SourcePath)
		(confirm)
		(dest "DEVS:")
	)
	)
)


(set #DevFlags 0)

(set #Match ( run "CacheCDFSInst:MatchPattern NAME="#CDROM_Device" PATTERN=(tandemat#?|#?atapi#?)" ( safe ) ) )

(if (= #Match 0)
	(
	(copylib
		(prompt "This will copy the SetAtapiSpeed program to your C: directory.")
		(help "This will copy the SetAtapiSpeed program to your C: directory.")
		(source "CacheCDFSInst:C/SetAtapiSpeed")
		(confirm)
		(dest "C:")
	)
	(set #DevFlags 1)
	)
)

(set #Match ( run "CacheCDFSInst:MatchPattern NAME="#CDROM_Device" PATTERN=(tandem#?|#?atapi#?|oktagon#?)" ( safe ) ) )

(if (= #Match 0)
	((set #ControlDefault 2))
)

(set #Match ( run "CacheCDFSInst:MatchPattern NAME="#CDROM_Device" PATTERN=(scsi.#?|???.scsi.#?)" ( safe ) ) )

(if (= #Match 0)
	((set #ControlDefault 5))
)

(if (= #CDROM_Device "gvpscsi.device")
	((set #ControlDefault 8))
)


(complete 20 )

(user 2)

(set #ControlMask 
	(askoptions
		(prompt "FileSystem -> Controller Configuration")
		(choices "Use SCSI Direct" 
					"Use Diskchange Interrupt"
					"Use 24 Bit-DMA"
					"Use Motor off" )
		(help	"Here You may define the behaviour of the CacheCDFS accessing the " 
		      #CDROM_Device ". If you are "
				"not sure what option is correct, leave the default settings as they "
				"are. They should work in most cases.\n"
				"These options may later be altered using the CDFSprefs program. "
				"However, wrong settings may lead to crashes if you mount the "
				"FileSystem!\n"
				"IF YOU HAVE A TANDEMCD / CD1200: YOU MUST DISABLE \"USE SCSI DIRECT\"!\n\n"

				"\"Use SCSI Direct\"\n"
				"Choose this option if the SCSI controller using "
				#CDROM_Device " cannot handle DoIO reads with 2048 bytes sectorsize "
				"correctly (e.g. ALFII, controllers from Progressive Peripherals, Emplant).\n"
				"Do NOT choose this option if your controller is a modern, well designed "
				"SCSI controller (ALFIII, Oktagon, A2091, A3000, A4091) or if it is "
				"NO SCSI controller at all (TandemCD)!\n\n"

				"\"Use Diskchange Interrupt\"\n"
				"Choose this option if the controller using "
				#CDROM_Device " does properly handle TD_ADDCHANGEINT and TD_REMCHANGEINT. "
				"All modern controllers should do this (ALFIII, Oktagon, TandemCD, "
				"GVP Series-II)\n"
				"Do NOT choose this option if your controller has problems with diskchange "
				"Interrupts (old ROM versions of A2091, A3000, A4091, controllers from "
				"Progressive Peripherals, Emplant)\n\n"

				"\"Use 24 Bit-DMA\"\n"
				"Choose this option if the SCSI or CD controller using "
				#CDROM_Device " is a 24-Bit (Zorro II) DMA device "
				"(e.g. A2091 from Commodore).\n"
				"Do NOT choose this option if your controller is a 32-Bit "
				"(Zorro III) device (e.g. FastLane, A3000, A4091), or a non-DMA controller "
				"like the majority of controllers (e.g. ALFII/III, Oktagon, "
				"TandemCD, Golem, IVS TrumpCard, Supra) as it will lead to "
				"decreased performance!\n\n"

				"\"Use Motor off\"\n"
				"Choose this option if the SCSI controller using "
				#CDROM_Device " is a GVP controller with \"Faaast\" roms.\n"
				"Do NOT choose this option if your controller is anything else."
			)
		(default #ControlDefault)
	)
)

(set #BufMemType  "1 /* MEMF_PUBLIC */\n" )
(set #BufMemInt  1 )

(if (IN #ControlMask 2)
	(
	(set #BufMemType  "513 /* MEMF_PUBLIC|MEMF_24BITDMA */\n")
	(set #BufMemInt  513 )
	)
)

(set #Control "\"MD=0 LC=1 DC=8 L LV AL LFC=1")


(if (IN #ControlMask 0)
	(
	(set #Control (cat #Control " S"))
	)
)

(if (NOT (IN #ControlMask 1))
	(
	(set #Control (cat #Control " NC"))
	)
)

(if (IN #ControlMask 3)
	(
	(set #Control (cat #Control " M"))
	)
)


(set #Control (cat #Control "\"\n"))


(set #autoMount
	(askbool
		(prompt "\n\nWould you like the CD-Rom drive automatically mounted upon bootup?\n\n"
		        "NOTE: If you are unsure if your controller will work correctly with "
		        "the controller settings, you should select \"NO\"!" )
		(help "\n\nIf you would like, the appropriate commands will be added to your user-startup file to automatically mount CacheCDFS.")
		(default 1)
	)
)


(if #autoMount
	(set #mountDirectory "DEVS:DOSDrivers")
)

(if (not #autoMount)
	(set #mountDirectory "SYS:Storage/DOSDrivers")
)

(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 ":") )


(user #theirlevel)

(if (exists "CacheCDFSInst:C/Mount")
	(
	(copylib
		(source "CacheCDFSInst:C/Mount")
		(dest "C:")
	))
)

(protect "l:CacheCDFS" "rwed" )
(copylib
	(prompt "\n\nCopying CDROM FileSystem to the l: directory.\n" )
	(source "CacheCDFSInst:l/CacheCDFS")
	(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." )
)


(if (exists "L:TandemCacheCDFS" )
	(
	((set #DeleteOld
		(askbool
		(prompt "\n\n\"L:TandemCacheCDFS\" is present from an earlier installation."
		        "\n\nDelete \"L:TandemCacheCDFS\" ?" )
		(help "\n\nClick \"YES\" if \"L:TandemCacheCDFS\" should be "
		      "deleted and \"NO\" if not!")
		(default 1)
		)
	))

	(if #DeleteOld
	((protect "L:TandemCacheCDFS" "rwed" )
	(delete "L:TandemCacheCDFS" )
	))
))

(if (exists "L:DemoCacheCDFS" )
	(
	((set #DeleteOld
		(askbool
		(prompt "\n\n\"L:DemoCacheCDFS\" is present from an earlier installation."
		        "\n\nDelete \"L:DemoCacheCDFS\" ?" )
		(help "\n\nClick \"YES\" if \"L:DemoCacheCDFS\" should be "
		      "deleted and \"NO\" if not!")
		(default 1)
		)
	))

	(if #DeleteOld
	((protect "L:DemoCacheCDFS" "rwed" )
	(delete "L:DemoCacheCDFS" )
	))
))

(complete 30 )


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

		(startup "CacheCDFS"
			(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 CacheCDFS upon bootup." )
		))
	)
	(if (not #autoMount)
		((protect "S:User-Sequence" "srwed" )

		(startup "CacheCDFS"
			(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 CacheCDFS upon bootup." )
		))
	)

	(if (exists (cat "devs:MountList." #CDDevice_NC ) )
		((set #ReplaceOld
			(askbool
			(prompt "\n\nDEVS:MountList." #CDDevice_NC" already exists!\n\n"
			        "Do you want to replace it?" )
			(help "\n\nClick \"YES\" if DEVS:MountList."#CDDevice_NC" should be "
			      "replaced and \"NO\" if not!")
			(default 1)
			)
		))
	)

	(if #ReplaceOld

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

	(textfile
		(dest (cat "devs:MountList." #CDDevice_NC) )
		(append "/***************************************************************/\n"
				  "/*  CacheCDFS mountlist entry  1993 Elaborate Bytes, O. Kastl */\n"
				  "/***************************************************************/\n")
		(append #CDDevice "\n")
		(append "	FileSystem     = L:CacheCDFS /* The name of the game */\n" )
		(append "	Device         = \""#CDROM_Device"\" /* Name of exec device driver */\n" )
		(append "	Unit           = "#CDROM_Unit" /* exec device unit */\n" )
		(append "	Flags          = " #DevFlags " /* OpenDevice flags */\n")
		(append "	BlocksPerTrack = 351000 /* 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        = 0 /* Unused */\n")
		(append "	Surfaces       = 1 /* Unused */\n")
		(append "	Buffers        = 50 /* Number of cache lines */\n")
		(append "	BufMemType     = " #BufMemType )
		(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        = "#Control)
		(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 "   /* AL/S Auto-Lower converts only non-Amiga CDs */\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")
	)
	(protect (cat "devs:MountList." #CDDevice_NC) "-e" )
	)
	)
))



(if (> #wbversion 37)
	(
	(if (exists "CacheCDFSInst:C/SetPatch")
		(
		(copylib
				(source "CacheCDFSInst:C/SetPatch")
				(dest "C:")
		))
	)

	(if (exists (tackon #mountDirectory #CDDevice_NC ) )
		((set #ReplaceOld
			(askbool
			(prompt "\n\n" (tackon #mountDirectory #CDDevice_NC) " already exists!\n\n"
			        "Do you want to replace it?" )
			(help "\n\nClick \"YES\" if " (tackon #mountDirectory #CDDevice_NC) " should be "
			      "replaced and \"NO\" if not!")
			(default 1)
			)
		))
	)

	(if #ReplaceOld

	((protect (tackon #mountDirectory #CDDevice_NC) "rwed" )

	(textfile
		(dest (tackon #mountDirectory #CDDevice_NC) )
		(append "/***************************************************************/\n"
				  "/*  CacheCDFS mountlist entry  1993 Elaborate Bytes, O. Kastl */\n"
				  "/***************************************************************/\n")
		(append "	FileSystem     = L:CacheCDFS /* The name of the game */\n" )
		(append "	Device         = \""#CDROM_Device"\" /* Name of exec device driver */\n" )
		(append "	Unit           = "#CDROM_Unit" /* exec device unit */\n" )
		(append "	Flags          = " #DevFlags " /* OpenDevice flags */\n")
		(append "	BlocksPerTrack = 351000 /* 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        = 0 /* Unused */\n")
		(append "	Surfaces       = 1 /* Unused */\n")
		(append "	Buffers        = 50 /* Number of cache lines */\n")
		(append "	BufMemType     = " #BufMemType )
		(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        = "#Control)
		(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 "   /* AL/S Auto-Lower converts only non-Amiga CDs */\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")
	)

	(protect (tackon #mountDirectory #CDDevice_NC) "-e" )

	(copyfiles
			(prompt "\n\nCopying Mountlist icon")
			(source "CacheCDFSInst: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 "CacheCDFS"
		(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 "CacheCDFS:CDFSprefs" "rwed" )
	(protect "CacheCDFS:CDFSprefs.info" "rwed" )
	(copylib
		(prompt "\n\nCopying the CDFSprefs program to the "
				  "SYS:Prefs directory." )
		(source "CacheCDFSInst: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." )
		(confirm)
	)

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

(complete 60 )

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

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

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

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

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

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

))

(complete 70 )


(if #instEjectCD
	(
	(set #instEjectCD
	(askbool
		(prompt "\n\nShould the EjectCD utility be installed?")
		(help "\n\nThis will copy over the EjectCD utility "
				"to your CDFS 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 "CacheCDFS:EjectCD" "rwed" )
	(protect "CacheCDFS:EjectCD.info" "rwed" )
	(copylib
		(prompt "\n\nCopying EjectCD program to the "
				  "CacheCDFS: directory.\n" )
		(source "CacheCDFSInst:EjectCD")
		(dest "CacheCDFS:")
		(help "\n\nThis will copy over the EjectCD utility "
				"to your CacheCDFS directory\n\nIf you do not "
				"wish the EjectCD program to be transferred to your system, "
				"skip this step.\n" )
		(infos)
		(confirm)
	)

	(tooltype
		(dest "CacheCDFS:EjectCD" )
		(settooltype "DEVICE" #CDROM_Device )
		(settooltype "UNIT" ("%ld" #CDROM_Unit ))
		(noposition)
	)
))

(set #instPlayCD 0)

(if (exists "CacheCDFSInst:PlayCD.lha")

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

(if #instPlayCD
	(

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

	( if (NOT @pretend )
	(( if ( run "CacheCDFSInst:c/lhex -afFqw=CacheCDFS: e CacheCDFSInst:PlayCD.lha" )
		(
		(abort "\n\nUnable to decrunch PlayCD!")
		)
	)))


	(tooltype
		(dest "CacheCDFS:PlayCD/PlayCD" )
		(settooltype "DEVICE" #CDROM_Device )
		(settooltype "UNIT" ("%ld" #CDROM_Unit ))
		(settooltype "BUFMEMTYPE" ("%ld" #BufMemInt ))
	)
	)
)

(complete 80 )

(set #instJukebox 0)

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

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


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

	( if (NOT @pretend )
	(( if ( run "CacheCDFSInst:c/lhex -qafFw=CacheCDFS:Jukebox e CacheCDFSInst:JukeBox.lha" )
		(
		(makeassign "JukeBox")
		(abort "\n\nUnable to decrunch JukeBox!")
		)
	)))


	(tooltype
		(dest "CacheCDFS:Jukebox/JukeBox" )
		(settooltype "DEVICE" #CDROM_Device )
		(settooltype "UNIT" ("%ld" #CDROM_Unit ))
	)

))

(set #instYACDP 0)

(if (AND (AND (exists "CacheCDFSInst:YACDP.lha") (exists "CacheCDFSInst:LIBS/reqtools.library")) (= #DevFlags 0))
((set #instYACDP
	(askbool
		(prompt "\n\nShould the YACDP Audio Player be installed?")
		(help "\n\nThis will copy over the YACDP drawer "
				"to your CacheCDFS directory\n\nIf you do not "
				"wish the YACDP drawer to be transferred to your system, "
				"skip this step." )
		(default 1)
	)
)))

(if #instYACDP
	(

	(protect "LIBS:reqtools.library" "rwed" )

	(copylib
	(source "CacheCDFSInst:LIBS/reqtools.library")
	(dest "LIBS:"))

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

	( if (NOT @pretend )
	(( if ( run "CacheCDFSInst:c/lhex -afFqw=CacheCDFS: e CacheCDFSInst:YACDP.lha" )
		(
		(abort "\n\nUnable to decrunch YACDP!")
		)
	)))


	(tooltype
		(dest "CacheCDFS:YACDP/YACDP" )
		(settooltype "DEVICE" #CDROM_Device )
		(settooltype "UNIT" ("%ld" #CDROM_Unit ))
	)
	)
)


(if (AND (> #wbversion 38) (exists "CacheCDFSInst:CD32.lha"))

	((complete 90 )

	(set #instCD32
		(askbool
			(prompt "\n\nShould the CD32-Emulator be installed?"
			        "\n\nNote that the CD32-Emulator is completely useless "
			        "if you don't have an Amiga with AA/AGA chipset and "
			        "at least Kickstart version 3.0!")
			(help "\n\nThis will copy over the CD32 drawer "
					"to your CacheCDFS directory\n\nIf you do not "
					"wish the CD32 drawer to be transferred to your system, "
					"skip this step.")
			(default 1)
		)
	)

	(if #instCD32
		(
		(working "\n\nDecrunching CD32...."
		         "\n\nPlease Wait!")

		( if (NOT @pretend )
		(( if ( run "CacheCDFSInst:c/lhex -afFqw=CacheCDFS: e CacheCDFSInst:CD32.lha" )
			(
			(abort "\n\nUnable to decrunch CD32!")
			)
		)))

	
		(if (exists "CacheCDFSInst:CD32" )
			((copylib
				(prompt "This will copy the CD32 program.")
				(help "This will copy the CD32 program.")
				(source "CacheCDFSInst:CD32")
				(infos)
				(dest "CacheCDFS:CD32")
				(confirm)
			))
		)


		( set #CDROM_Blocks 2 )

		(if (= #CDROM_Device "tandemcd.device")
			(
			( set #CDROM_Blocks 4 )
			)
		)

		(if (= #CDROM_Device "tandemat.device")
			(
			( set #CDROM_Blocks 4 )
			)
		)

		(if (= #CDROM_Device "tandemcd_pcmcia.device")
			(
			( set #CDROM_Blocks 4 )
			)
		)

		(if (= #CDROM_Device "tandemcd_come.device")
			(
			( set #CDROM_Blocks 4 )
			)
		)

		(tooltype
			(dest "CacheCDFS:CD32/CD32" )
			(settooltype "BLOCKS" ("%ld" #CDROM_Blocks ) )
			(settooltype "DOSDEV" #CDDevice_NC)
			)

		(set #instInst
			(askbool
			(prompt "\n\nShould the Installer utility be installed?"
			        "\n\nNote that you only need to install the Installer "
			        "utility if you don't have it already installed on "
			        "your harddisk in your actual path!")
			(help "\n\nThis will copy over the Installer utility "
					"to your CD32 directory\n\nIf you do not "
					"wish the Installer utility to be transferred to your system, "
					"skip this step." )
			(default 1)
			)
		)

		(if #instInst
			(
			(copyfiles
			(source "CacheCDFSInst:Installer")
			(dest "CacheCDFS:CD32")
			)
		)
		)
	))
))

(complete 100 )

(set #doMount
	(askbool
	(prompt "\n\nMount " #CDDevice " now ?")
	(help "Select, if " #CDDevice " should be mounted now, or not.")
	(default 1)
	)
)

(set #MountError 0)

( if @pretend ((set #doMount 0))) 

(if #doMount
	(
	(run (cat "CacheCDFSInst:KillDev " #CDDevice " Quiet"))
	(if (< #wbversion 38)
		(
		(set #MountError
			(run (cat "C:Mount " #CDDevice " from devs:MountList." #CDDevice_NC ))
		)
		)
	)

	(if (> #wbversion 37)
		(
		(set #MountError
			(run (cat "C:Mount " #CDDevice  ))
		)
		)
	)
	)
)

(if #MountError
	(
	(message "\n\nMounting " #CDDevice " failed!")
	)
)

(makeassign "CacheCDFSInst" (safe))
(makeassign "CacheCDFS" (safe))

