;Standard Installer script
;Written by Marco Biondi
;@1995/96 Light Shock software s.n.c

(set destinazione @default-dest)

(set mask 0)

(while (= mask 0)
	(set mask
		(askoptions
			(prompt "Please thick the appropriate choices:")
			(help @askoptions-help)
			(choices "Install Game" "Make Boot disk")
			(default %01)
		)
	)
)

(if (IN mask 0)
	(
		(set destinazione
			(askdir 
				(prompt ("Choose the drawer where %s should be installed:" @app-name))
				(help @askdir-help)
				(default destinazione)
			)
		)

		(if (NOT (exists destinazione (quiet))) 
			(abort "The specified path is not a valid path!")
		)

		(set spaziorichiesto 4000)

		(set disponibile (/ (getdiskspace destinazione) 1024) )

		(if (< disponibile spaziorichiesto)
			(set domanda "WARNING : THE AVAILABLE SPACE IT'S INSUFFICIENT.\nPROCEED WITH INSTALLATION ?"
			)
			(set domanda ""
			)	
		)

		(message 
			("The installation of %s requires about %ld Kbytes of free disk space.\n\n"
				@app-name
				spaziorichiesto
			)
			("In the choosen drawer (%s) there are %ld Kbytes availables.\n\n"
				destinazione
				disponibile
			)
			domanda
		)
	)
)

(if (IN mask 0)
	(
		(askdisk
			(prompt "Insert Disk 1")
			(help @askdisk-help)
			(dest "FSpirit-1")
		)
		(copyfiles
			(prompt "Installing Disk 1")
			(help @copyfiles-help)
			(source "FSpirit-1:")
			(dest destinazione)
			(pattern "~(s|install#?)")
		)

		(complete 18)

		(askdisk
			(prompt "Insert Disk 2")
			(help @askdisk-help)
			(dest "FSpirit-2")
		)
		(copyfiles
			(prompt "Installing Disk 2")
			(help @copyfiles-help)
			(source "FSpirit-2:")
			(dest destinazione)
			(all)
		)

		(complete 36)

		(askdisk
			(prompt "Insert Disk 3")
			(help @askdisk-help)
			(dest "FSpirit-3")
		)
		(copyfiles
			(prompt "Installing Disk 3")
			(help @copyfiles-help)
			(source "FSpirit-3:")
			(dest destinazione)
			(all)
		)

		(complete 54)

		(askdisk
			(prompt "Insert Disk 4")
			(help @askdisk-help)
			(dest "FSpirit-4")
		)
		(copyfiles
			(prompt "Installing Disk 4")
			(help @copyfiles-help)
			(source "FSpirit-4:")
			(dest destinazione)
			(all)
		)
		
		(complete 72)

		(askdisk
			(prompt "Insert Disk 5")
			(help @askdisk-help)
			(dest "FSpirit-5")
		)
		(copyfiles
			(prompt "Installing Disk 5")
			(help @copyfiles-help)
			(source "FSpirit-5:")
			(dest destinazione)
			(all)
		)
		(textfile
			(dest (tackon destinazione "FS.hd"))
			(append (database "cpu"))
		)
	)
)

(complete 90)

(if (NOT (IN mask 1))
	(
		(set avchip (/ (database "graphics-mem") 1024))
		(set nechip 1800)
		(if
			(NOT (>= avchip nechip))
			(if
				(askbool
					(prompt ("WARNING : At this moment there isn't enough memory available to run %s.\n\nDo you wanna create a Boot disk ?" @app-name))
					(help "The low memory condition could be caused by some applications actually in execution.\n"
						"If you want to check that the Boot disk is really necessary, try to start the game immediatly after the Workbench loading.\n\n"
						"You can create a Boot disk later on simply re-executing the installation and choosing the appropriate option."
					)
				)
				(set mask -1)
			)
		)
	)
)

(if (IN mask 1)
	(
		(message "Insert a blank formatted disk in DF0: and click \"Proceed\" to continue."
			(help "To format a disk plaese refer to the WorkBenck manual and/or the AmigaDOS manual.\n\n"
				"You can do the operation in multitasking without exiting the installer."
			)
		)
		(until
			(exists "df0:" (quiet) )
			(working "Waiting for a disk...")
		)
		(while (NOT (exists (tackon destinazione "FS") ) )
			(set destinazione
				(askdir 
					(prompt ("Please select the drawer where %s is installed" @app-name))
					(help @askdir-help)
					(default destinazione)
				)
			)
		)
		(working "I'm making the necessary files and directories...")
		(makedir "df0:s")
		(makedir "df0:c")
		(run "Install DF0:")
		(foreach "SYS:C" "(SetPatch|Cd)"
			(copyfiles
				(prompt "Writing files...")
				(help @copyfiles-help)
				(source ("SYS:C/%s" @each-name))
				(dest "df0:c")
			)
		)
		(textfile
			(dest "df0:s/Startup-sequence")
			(append
				(select	(exists
						"df0:C/SetPatch"
						(noreq)
					)
					(";No SetPatch on your system!\n")
					("SetPatch >NIL: QUIET\n")
				)
			)
			(append
				("CD \"%s\"\nFS\n" destinazione)
			)
		)
	)
)

(complete 100)

(exit "Running from HD: Double-click on FS icon\n\n"
	"Running from Boot disk: Insert Boot disk in df0: and reset\n\n"
	"Have fun!\n\n" "@1995/96 Light Shock software s.n.c." 
)