;$VER: Buddha Install 48.1 (23.02.97)
;Copyright ©1997 Elaborate Bytes, Oliver Kastl

( set #ControlDefault 1 )

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

(set #autoMount 1)
(set #CDDevice_NC "CD" )
(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:") 409600)
	(abort "\n\nApproximately 400K 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 )

(user 2)

(message "\nWelcome to BuddhaIDE, CacheCDFS2, CD32-Emulator and PlayCD!"
			"\n\nThis package is the complete solution for all your IDE and CD-ROM problems! " 
         "\n\n"
         "BuddhaIDE allows you to use 8 harddisks or SyQuest drives, "
         "buddha_atapi controls IDE CD-Roms, "
         "CacheCDFS, PlayCD and CD32-Emulator power any IDE or SCSI-II CD-Rom!"
         "\n\nEnjoy it! " )

(working "\n\nLoading BuddhaIDE driver...."
         "\n\nPlease Wait!")

(run "CacheCDFSInst:Expansion/BuddhaIDE" ( safe ) )

(message "\nUse HDToolBox to Partition any Harddisks on the BuddhaIDE controller. "
        	"\n\nClick PROCEED to continue installation. Click ABORT to quit.")

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

(set #CDFSDir
	(askdir
		(prompt "\n\nSpecify the directory in which the support programs will be placed:" )
		(help "\n\nBuddhaIDE 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 (NOT (exists "CacheCDFS:Backup" ))
	(

	(copyfiles
		(source "CacheCDFSInst:C/BackupIDEFixInstall")
		(prompt )
		(help )
		(infos)
		(dest "CacheCDFS:")
	)

	(copyfiles
		(source "CacheCDFSInst:C/UnInstall")
		(prompt )
		(help )
		(infos)
		(dest "CacheCDFS:")
	)

	(working "\nBacking up old installation ..." )

	
	(if ( run "CacheCDFS:BackupIDEfixInstall CacheCDFS:Backup save" )
		(
		(abort)
		)
	)

	)
)

(copylib
	(prompt "This will copy the BuddhaIDE driver to your SYS:Expansion directory.")
	(help "This will copy the BuddhaIDE driver to your SYS:Expansion directory.")
	(source "CacheCDFSInst:Expansion/BuddhaIDE")
	(confirm)
	(infos)
	(dest "SYS:Expansion")
)

(tooltype
	(dest "SYS:Expansion/BuddhaIDE" )
	(noposition)
)

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

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

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

(copyfiles
	(prompt "This will copy Icons for the FormatLS120 and MountLS120 programs "
		"to your Harddisk.")
	(help "This will copy Icons for the FormatLS120 and MountLS120 programs "
		"to your Harddisk.")
	(source "CacheCDFSInst:LS120")
	(infos)
	(all)
	(confirm)
	(dest "CacheCDFS:LS120")
)
	

(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 ConvertDrive program to your C: directory.")
	(help "This will copy the ConvertDrive program to your C: directory.")
	(source "CacheCDFSInst:C/ConvertDrive")
	(confirm)
	(dest "C:")
)

(copylib
	(prompt "This will copy the AutoParkPrefs program to your SYS:Prefs directory.")
	(help "This will copy the AutoParkPrefs program to your SYS:Prefs directory.")
	(source "CacheCDFSInst:Prefs/AutoParkPrefs")
	(infos)
	(confirm)
	(dest "SYS:Prefs")
)

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

	(copyfiles
		(prompt "This will copy Icons for the Ship, BuddhaSpeed 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, BuddhaSpeed 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")
	)
	

	(copylib
		(prompt "This will copy the BuddhaSpeed icon to your SYS:WBStartUp directory.")
		(help "This will copy the BuddhaSpeed icon to your SYS:WBStartUp directory.")
		(source "CacheCDFSInst:Harddisk/BuddhaSpeed/BuddhaSpeed.info")
		(confirm)
		(dest "SYS:WBStartUp")
	)

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

(user 2)

	(message "\n\nBuddhaIDE is installed in your SYS:Expansion directory."
	         "\n\nLoadIDE, MountIDE and Ship are installed in your C: "
         	"directory."
         	"\n\nAutoParkPrefs is installed in your SYS:Prefs directory."
         	"\n\nPlease click PROCEED now.")

	(message "\nNote:\n\nEnter \"LoadIDE file SYS:Expansion/BuddhaIDE reset\" behind SetPatch in your startup-sequence "
         	"to load a newer IDE driver without changing the ROM on the BuddhaIDE controller! "
         	"\n\nUse \"Ship\" to park your harddisks!"
         	"\nUse \"MountIDE force\" to mount additional SyQuest cartridges!"
         	"\n\nPlease click PROCEED now.")

	(message "\nNote:\n\nUse \"BuddhaSpeed\" to optimize the performance of your controller! "
         	"Adjust the TIMING ToolType. 0 is slowest, 7 is fastest access!\n\n"
         	"Depending on your Amiga, this may give you a great performance boost! "
         	"\n\nPlease click PROCEED now.")

	(message "\nNote:\n\nYou can use \"ConvertDrive\" to convert drives formatted with old controllers "
         	"like Apollo AT or GVP AT!\n\n"
         	"Enter \"ConvertDrive <device> <unit>\" from the Shell. "
         	"\n\nPlease click PROCEED now.")

	(message "\nNote:\n\nYou can use \"AutoParkPrefs\" in you SYS:Prefs directory to adjust autoparking "
         	"of your harddrives. Autoparking switches off the motor of a drive, if the drive is "
         	"not used for a certain amount of time."
         	"\n\nClick PROCEED to install CacheCDFS and/or ATAPI. Click ABORT to quit.")



(user 2)

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

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

(set #Product ( run "CacheCDFSInst:FindDevice DEVNAME=buddha_atapi#? PATH=CacheCDFSInst:Devs add" ( safe ) ) )


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

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

	(set #CDROM_NumLuns
		(asknumber
			(prompt "\n\nHow many LUNs has your CD-Rom drive?" )
			(default 1 )
			(help "\nThis is the number of logical units of the CD-Rom drive. This is usually a "
					"numerical value between 1 and 8.\n\n"
					"If you have a normal CD-Rom, set this to 1.\n\n"
					"If you have a CD-Rom changer, enter the number of discs that fit in your drive!" )
		)
	)
	)
)


( 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 #startupCommand (cat "MountLS120 DEVICE=" #CDROM_Device " QUIET\n") )

(protect "S:User-Sequence" "srwed" )

(startup (cat "MountLS120_" #CDROM_Device )
	(command #startupCommand )
	(prompt "\n\nInserting MountLS120 command into the user-startup")
	(help "\n\nInserting MountLS120 command into the user-startup")
)

( run "MountLS120 "#CDROM_Device"" )

(set #DevFlags 0)

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

(if (= #Match 0)
	(
	(set #DevFlags 1)
	)
)

(set #ControlMask 2)

(complete 20 )

(user 2)

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

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

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

(user #theirlevel)

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

(copylib
	(source "CacheCDFSInst:Installer")
	(dest "C:")
)

(if (> #wbversion 37)
	(
	(if (exists "CacheCDFSInst:C/SetPatch")
		(
		(copylib
				(source "CacheCDFSInst:C/SetPatch")
				(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 "CacheCDFS:FindCD" )
	(
	(protect "CacheCDFS:FindCD" "rwed" )
	(delete "CacheCDFS:FindCD" )
	)
)

(if (exists "CacheCDFS:FindCD.info" )
	(
	(protect "CacheCDFS:FindCD.info" "rwed" )
	(delete "CacheCDFS:FindCD.info" )
	)
)

(complete 30 )

(user 1)

(set #tempCDDevice_NC #CDDevice_NC )
(set #CDROM_ID (/ #CDROM_Unit 100 ))
(set #CDROM_ID (- #CDROM_Unit (* #CDROM_ID 100 )))

(if (> #CDROM_NumLuns 1 )
	(
	(if
	( NOT (askbool
		(prompt "\nYour CD-Rom changer has " #CDROM_NumLuns " discs.\n\n"
		        "Do you wish to access them through different device names?" )
		(help "\n\nClicking YES will mount every disc individually.")
		(default 1)
	))
	(set #CDROM_NumLuns 1 )
	)
	)
)

(set #SlotNumber 0 )

( until (= #CDROM_NumLuns #SlotNumber )

(set #CD_DeviceUnit (+ #CDROM_ID (* #SlotNumber 10 )))
(set #CDDevice_NC (cat #tempCDDevice_NC #CD_DeviceUnit))

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

(user #theirlevel)

(set #startupCommand (cat "MountLS120 DEVICE=" #CDROM_Device " QUIET\n") )

(protect "S:User-Sequence" "srwed" )

(startup (cat "MountLS120_" #CDROM_Device )
	(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." )
)

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

(if (< #wbversion 38)
	((set #startupCommand (cat "mount " #CDDevice " from devs:MountList." #CDDevice_NC "\n") )

	(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 #autoMount
		((protect "S:User-Sequence" "srwed" )

		(startup ( cat "CacheCDFS_" #CDDevice )
			(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 ( cat "CacheCDFS_" #CDDevice )
			(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           = " #CD_DeviceUnit " /* 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    = 0x1000000 /* 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 (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           = " #CD_DeviceUnit " /* 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    = 0x1000000 /* 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." )
		)

	(protect "S:User-Sequence" "srwed" )
	(startup ( cat "CacheCDFS_" #CDDevice )
		(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)
			)
		))
	)
)

(set #SlotNumber (+ #SlotNumber 1 ))

)

(complete 40 )

(if ( NOT (= #theirlevel 2 ) )
	(
	(set #instChanger ( NOT ( run "CacheCDFSInst:Changer DEVICE="#CDROM_Device" UNIT="#CDROM_Unit" TEST" ( safe ) ) ) )
	)
)

(if (= #theirlevel 2 )
	(
	(set #instChanger 1)
	)
)

(if #instChanger
	((set #instChanger
		(askbool
			(prompt "\n\nShould the ATAPI Changer utility be installed?\n\n"
					  "NOTE: This program is only required, if you have an ATAPI "
					  "CD-ROM changer!" )
			(help "\n\nThis will copy over the ATAPI Changer utility "
					"to your harddisk.\n\nIf you do not "
					"wish the Changer program to be transferred to your system, "
					"skip this step.\n" )
			(default 1)
		)
	)
))

(if #instChanger
	(
	(if (exists "CacheCDFS:AtapiChanger" )
		(
		(protect "CacheCDFS:AtapiChanger" "rwed" )
		(delete "CacheCDFS:AtapiChanger" )
		)
	)

	(if (exists "CacheCDFS:AtapiChanger.info" )
		(
		(protect "CacheCDFS:AtapiChanger.info" "rwed" )
		(delete "CacheCDFS:AtapiChanger.info" )
		)
	)

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

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

(complete 50 )

(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" )
	(copylib
		(prompt "\n\nCopying the CDFSprefs program to the "
				  "SYS:Prefs directory." )
		(source "CacheCDFSInst:Prefs/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 #instFindDevice
	(askbool
		(prompt "\n\nShould the FindDevice utility be installed?")
		(help "\n\nThis will copy over the FindDevice utility "
				"to your CacheCDFS directory\n\nIf you do not "
				"wish the FindDevice program to be transferred to your system, "
				"skip this step." )
		(default 1)
	)
)

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

	(tooltype
		(dest "CacheCDFS:FindDevice" )
		(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 )

	(copyfiles
		(prompt "This will copy additional documentation "
			"to your Harddisk. ")
		(help "This will copy additional documentation "
			"to your Harddisk. ")
		(source "CacheCDFSInst:Docs")
		(infos)
		(all)
		(confirm)
		(dest "CacheCDFS:Docs")
	)
	
(tooltype
	(dest "CacheCDFS:Docs" )
	(noposition)
)

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

	))
))

(complete 100 )

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

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

(if #doMount
	(
	(set #SlotNumber 0 )

	(working "\n\nMounting CD-Rom...."
	         "\n\nPlease Wait!")

	( until (= #CDROM_NumLuns #SlotNumber )

		(set #CD_DeviceUnit (+ #CDROM_ID (* #SlotNumber 10 )))
		(set #CDDevice_NC (cat #tempCDDevice_NC #CD_DeviceUnit))
		(set #CDDevice (cat #CDDevice_NC ":") )

		(run (cat "CacheCDFSInst:KillDev " #CDDevice " Quiet"))

		(if (< #wbversion 38)
			(
			(run (cat "C:Mount " #CDDevice " from devs:MountList." #CDDevice_NC ))
			)
		)

		(if (> #wbversion 37)
			(
				(run (cat "C:Mount " #CDDevice  ))
			)
		)
	(set #SlotNumber (+ #SlotNumber 1 ))
	)
))


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

