;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 Introduction" "Install Game" "Make Boot disk")
			(default %011)
		)
	)
)

(if (OR (IN mask 0) (IN mask 1))
	(
		(set version
			(askchoice
				(prompt "Which version of the game has to be installed ?")
				(help "Select the button relative to the version of the chipset present in your Amiga.\n"
					"ECS/OCS - Amiga 500, 2000, 500+, 600\n"
					"AGA - Amiga 1200, 4000"
				)
				(choices "AGA Version" "ECS/OCS Version")
			)
		)

		(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
			(+ 
				(* (IN mask 0) 800)
				(* (IN mask 1) (select version 1200 1100) )
			)
		)

		(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 the required parts of the %s version of %s requires about %ld Kbytes of free disk space.\n\n"
				(select version "AGA" "ECS")
				@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 \"Intro\" disk")
			(help @askdisk-help)
			(dest "BV.0")
		)
		(copyfiles
			(prompt "Installing \"Intro\"")
			(help @copyfiles-help)
			(source "BV.0:")
			(dest destinazione)
			(choices "BVIntro" "Intro" "IntroDATA" "Music" "Txt" "LSLogo")
		)
		(copyfiles
			(prompt "Installing \"Intro\"")
			(help @copyfiles-help)
			(source "BV.0:Intro.in")
			(dest destinazione)
			(newname "Intro.info")
		)
		(copylib
			(prompt "Installing language library")
			(help @copylib-help)
			(source "BV.0:libs/lsdetect.library")
			(dest "LIBS:")
		)
	)
)

(complete 18)

(if (IN mask 1)
	(
		(askdisk
			(prompt "Insert Disk 1")
			(help @askdisk-help)
			(dest "BV.1")
		)
		(copyfiles
			(prompt "Installing Disk 1")
			(help @copyfiles-help)
			(source 
				("BV.1:%s"
					(select version "BVGame1200" "BVGame500")
				)
			)
			(dest destinazione)
			(newname "BVGame")
		)
		(copyfiles
			(prompt "Installing Disk 1")
			(help @copyfiles-help)
			(source "BV.1:BVGame.in")
			(dest destinazione)
			(newname "BVGame.info")
		)
		(copyfiles
			(prompt "Installing Disk 1")
			(help @copyfiles-help)
			(source "BV.1:")
			(dest destinazione)
			(choices "WinSequence" "LetUsDie")
		)
		(copylib
			(prompt "Installing language library")
			(help @copylib-help)
			(source "BV.1:libs/lsdetect.library")
			(dest "LIBS:")
		)

		(complete 36)

		(askdisk
			(prompt "Insert Disk 2")
			(help @askdisk-help)
			(dest "BV.2")
		)
		(if version
			(
				(copyfiles
					(prompt "Installing Disk 2")
					(help @copyfiles-help)
					(source "BV.2:")
					(dest destinazione)
					(all)
				)
			)
			(
				(copyfiles
					(prompt "Installing Disk 2")
					(help @copyfiles-help)
					(source "BV.2:")
					(dest destinazione)
					(choices "Mappiste" "Modules" "piste" "PisteRK" "RBG01" "RBG02" "RBG03" "RBG07" "ReiContinents")
				)
				(copyfiles
					(prompt "Installing Disk 2")
					(help @copyfiles-help)
					(source "BV.2:")
					(dest (tackon destinazione "ReiEnemies"))
					(choices "ReiEnemies/Block09" "ReiEnemies/BLock06" )
				)
			)
		)

		(complete 54)

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

		(complete 72)

		(askdisk
			(prompt "Insert Disk 4")
			(help @askdisk-help)
			(dest "BV.4")
		)
		(if version
			(
				(copyfiles
					(prompt "Installing Disk 4")
					(help @copyfiles-help)
					(source "BV.4:")
					(dest destinazione)
					(choices "SaveTopScore" "StartSequence" "DeathSequence" "Modules" "RBG05" )
				)
				(copyfiles
					(prompt "Installing Disk 4")
					(help @copyfiles-help)
					(source "BV.4:")
					(dest (tackon destinazione "ReiEnemies"))
					(choices "ReiEnemies/Block11" )
				)
			)
			(
				(copyfiles
					(prompt "Installing Disk 4")
					(help @copyfiles-help)
					(source "BV.4:")
					(dest destinazione)
					(all)
				)
			)
		)
	)
)

(complete 90)

(if (IN mask 0 1)
	(startup "BlackViper"
		(prompt "Updating User-Startup\n")
		(help @startup-help)
		(command ("Assign BV.0: \"%s\"\nAssign BV.1: \"%s\"\nAssign BV.2: \"%s\"\nAssign BV.3: \"%s\"\nAssign BV.4: \"%s\"\n" destinazione destinazione destinazione destinazione destinazione))
	)
)

(if (NOT (IN mask 2))
	(
		(set avchip (/ (database "graphics-mem") 1024))
		(set avfast (- (/ (database "total-mem") 1024) avchip))
		(set nechip (select version 800 512))
		(set nefast 512)

		(if
			(NOT	
				(OR
					(AND
						(>= avchip nechip)
						(>= avfast nefast)
					)
					(>= avchip (+ nechip nefast))
				)
			)
			(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 2)
	(
		(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 "BVGame") ) )
			(set destinazione
				(askdir 
					(prompt ("Please select the drawer where %s is installed" @app-name))
					(help @askdir-help)
					(default destinazione)
				)
			)
		)
		(set btype 1)
		(if (exists (tackon destinazione "BVIntro") )
			(set btype
				(askchoice
					(prompt "Choose the type of Boot:")
					(help @askoptions-help)
					(choices "Introduction and game" "Only game")
				)
			)
		)
		(working "I'm making the necessary files and directories...")
		(makedir "df0:s")
		(makedir "df0:c")
		(makedir "df0:libs")
		(run "Install DF0:")
		(foreach "SYS:C" "(SetPatch|Cd|Assign)"
			(copyfiles
				(prompt "Writing files...")
				(help @copyfiles-help)
				(source ("SYS:C/%s" @each-name))
				(dest "df0:c")
			)
		)
		(copyfiles
			(prompt "Writing files...")
			(help @copyfiles-help)
			(source "LIBS:lsdetect.library")
			(dest "df0:Libs")
		)
		(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\"\nAssign BV.0: \"%s\"\nAssign BV.1: \"%s\"\nAssign BV.2: \"%s\"\nAssign BV.3: \"%s\"\nAssign BV.4: \"%s\"\n" destinazione destinazione destinazione destinazione destinazione destinazione)
			)
			(append
				(select btype
					("LSLogo\nBvIntro\nLetUsDie BvGame\n")
					("LetUsDie BvGame\n")
				)
			)
		)
	)
)

(complete 100)

(exit "Running from HD: Reset your system. Double-click on the BVGame or BVIntro 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." 
)