;
;$VER: Jet Set Willy II HD Installer script v1.00 (c) 1997 John Girvin
;

(welcome "Welcome to the Jet Set Willy II Hard Drive Installer")
(set @app-name "Jet Set Willy II HD")
(set #JROOTDIR "DH0:")
(set #JDESTDIR #JROOTDIR)
(set #JDATDIR  #JROOTDIR)

(if
	(<> @user-level 2)
	(abort "You must select 'Expert' user level")
)

(message "\n\nWelcome to the Jet Set Willy II Hard Drive Installer\n"
		 "(c) 1997 John Girvin\n\n"
		 "Please read the documentation thoroughly before"
		 " attempting to use this installer!\n\n"
		 "This is version 1.00\n\n"
		 "Click 'Proceed' to begin."
)


;
; Generate names of installation directories
;
(set #JROOTDIR
	(askdir
		(prompt "Where would you like Jet Set Willy II installed?\n"
				"(a new drawer called 'Jet_Set_Willy_II' will be created here)"
		)
		(help @askdir-help)
		(default #JROOTDIR)
	)
)
(set #JDESTDIR (tackon #JROOTDIR "Jet_Set_Willy_II/"))
(set #JDATDIR (tackon #JDESTDIR "data/"))
(set @default-dest #JDESTDIR)
(set @execute-dir #JDESTDIR)


;
; Create installation directories
;
(makedir #JDESTDIR
	(prompt "I will now create the directory '" #JDESTDIR "'")
	(help @makedir-help)
	(infos)
	(confirm)
)

(makedir #JDATDIR
	(prompt "I will now create the directory '" #JDATDIR "'")
	(help @makedir-help)
	(confirm)
)


;
; Copy WHDload and extractor slave to destination
;
(copyfiles
	(prompt "Copying WHDLoad program")
	(help @copyfiles-help)
	(source "WHDLoad")
	(dest #JDESTDIR)
	(nogauge)
	(noposition)
	(optional fail force)
)

(copyfiles
	(prompt "Copying data extractor slave")
	(help @copyfiles-help)
	(source "JSWMakeDat")
	(dest #JDESTDIR)
	(nogauge)
	(noposition)
	(optional fail force)
)

;
; Create data files from game disk
;
(message "\n\n\nPlease insert your Jet Set Willy II game disk in drive DF0:\n\n"
			"*** WARNING ***\n"
			"Multitasking will be disabled while the game files"
			" are being created. After inserting the disk, please"
			" ensure that all disk and network activity has finished"
			" before clicking 'Proceed'.\n\n"
			"Click 'Proceed' when ready."
)


(working
	(cat "Creating game data files in '" #JDATDIR "'\n\n"
   	     "*** Multitasking is disabled. DON`T PANIC! ***"
	)
)


(run
	(cat
		(tackon #JDESTDIR
				"WHDLoad SLAVE=JSWMakeDat NOVBRMOVE NOCACHE NOAUTOVEC NOTRAPHANDLER"
		)
	)
)


;
; Did the data extractor work?
; Check that the last file was created
;
(if (<>	(getsize (tackon #JDATDIR "mansion")) 10216)
	(abort "Could not create data files !")
)


;
; Copy HD drawer icon
;
(copyfiles
	(prompt "Copying HD drawer icon")
	(help @copyfiles-help)
	(source "JSW2.inf")
	(newname "Jet_Set_Willy_II.info")
	(dest #JROOTDIR)
	(nogauge)
	(optional fail force)
)


;
; Copy HD loader slave and icon
;
(copyfiles
	(prompt "Copying HD loader slave icon")
	(help @copyfiles-help)
	(source "Jet_Set_Willy_II.inf")
	(newname "Jet_Set_Willy_II.info")
	(dest #JDESTDIR)
	(nogauge)
	(optional fail force)
)

(tooltype
	(prompt "Setting HD loader slave icon tooltypes")
	(dest (tackon #JDESTDIR "Jet_Set_Willy_II"))
	(setdefaulttool "WHDLoad")
	(settooltype "WHDLOAD" "Jet_Set_Willy_II")
	(settooltype "NOVBRMOVE" "")
	(settooltype "PRELOAD" "")
)

(copyfiles
	(prompt "Copying HD loader slave")
	(help @copyfiles-help)
	(source "Jet_Set_Willy_II")
	(dest #JDESTDIR)
	(nogauge)
	(noposition)
	(optional fail force)
)
