; $VER 1.0 05.11.95 PicBoot-Preferences
; for PicBoot Version 2.8 by Michael Becker


(set old-level @user-level)
(set @default-dest "S:")
(set #ausgabe "PicBoot ")
(set picdir "SYS:PicBoot/Bootpics/")
(set filelocation "SYS:PicBoot/")
(set readg "\nRead PicBoot.guide for further information !")

(message	"\nWelcome to\n\n"
		"\nPicBoot-Preferences\n"
                "-------------------\n\n\n\n\n\n"
		" by Michael Becker")

(if (exists filelocation (noreq)) (message "\n\n\nFound PicBoot-Drawer\n\n\n")
    (set filelocation (askdir (prompt "Where can PicBoot be found ?")
			  (help "I have searched for the drawer        \n"
				"SYS:PicBoot\n"
				"but haven't found it, so you have     \n"
				"enter the directory where the Programm\n"
				"PicBoot is located                    \n")
			  (default "SYS:PicBoot/")
		  ))
)

(set picfile
	(askfile
		(prompt	"Choose the Picture for startup\n"
			"(No Pic-File for further selections)")
		(help	"Now you can choose the picture you want\n"
			"to see during your boot. If you don't  \n"
			"choose a picture you will get to the   \n"
			"next window where you can choose a     \n"
			"a pattern for a random showing of pics \n"
			readg)
		(default picdir)
	)
)
(set piclen (strlen picfile))
(set lastchar (substr picfile (- piclen 1) 1))

(set erg (exists picfile))
(if (AND (= erg 2) (<> lastchar "/")) (set picfile (cat picfile "/")))

(if 	(= (fileonly picfile) "")
	((set noend (askstring	(prompt "Now you can enter a pattern to  \n"
					"enable random choice of pictures\n"
					"which mach the given pattern    \n")
				(help readg)
				(default "#?.iff")
		   )
	 )
	(set picfile (cat picfile noend))
	)
)

(set #ausgabe (cat #ausgabe picfile " "))

(complete 30)

(run	(prompt "")
	(help "")
	"c:copy CheckPicStartup RAM: >NIL:"
)

(set i 13)
(set calcdef 0)

(if (exists "S:PicBoot-Startup")(
(working "\n\nChecking for PicBoot-Preferences")

(while (> i 0) ((if (= i 1)  (set runstr "RAM:CheckPicStartup MODEID >ENV:PBenv"))
		(if (= i 2)  (set runstr "RAM:CheckPicStartup CENTER >ENV:PBenv"))
		(if (= i 3)  (set runstr "RAM:CheckPicStartup AUTOSCROLL >ENV:PBenv"))
		(if (= i 4)  (set runstr "RAM:CheckPicStartup VIDEOOVERSCAN >ENV:PBenv"))
		(if (= i 5)  (set runstr "RAM:CheckPicStartup RTG >ENV:PBenv"))
		(if (= i 6)  (set runstr "RAM:CheckPicStartup WRITEPIXELLINE >ENV:PBenv"))
		(if (= i 7)  (set runstr "RAM:CheckPicStartup DELAY >ENV:PBenv"))
		(if (= i 8)  (set runstr "RAM:CheckPicStartup PATCH >ENV:PBenv"))
		(if (= i 9)  (set runstr "RAM:CheckPicStartup DETACH >ENV:PBenv"))
		(if (= i 10) (set runstr "RAM:CheckPicStartup FADEIN >ENV:PBenv"))
		(if (= i 11) (set runstr "RAM:CheckPicStartup FADEOUT >ENV:PBenv"))
		(if (= i 12) (set runstr "RAM:CheckPicStartup FADEWB >ENV:PBenv"))
		(if (= i 13) (set runstr "RAM:CheckPicStartup ACTIVATEWB >ENV:PBenv"))
		(if (= i 14) (set runstr "RAM:CheckPicStartup BORDERBLANK >ENV:PBenv"))
		(if (= i 15) (set runstr "RAM:CheckPicStartup FIXJUMP >ENV:PBenv"))
			
		(run 	(prompt "")
			(help "")
			runstr
		)

			(set Enverg (getenv "PBenv"))
			(if (= i 10) (set fadein Enverg))
			(if (= i 11) (set fadeout Enverg))
			(if (= i 12) (set fadewb Enverg))
			(if (= Enverg "") (set calcdef (shiftleft calcdef 1))
					( (set calcdef (+ calcdef 1))
					  (set calcdef (shiftleft calcdef 1))
					)
			)
			(set i (- i 1))
		)
 )
)

(set calcdef 0) ; Alternativ-Option von if

) ; ende von if

(run	(prompt "")
	(help "")
	"c:delete RAM:CheckPicStartup >NIL:"
)

(complete 50)

(set flags
	(askoptions
		(prompt "\nFlags that can be set:\n\n"
			"* signed Flags need further information\n")
		(help readg)			
		(choices
			"MODEID *"
			"CENTER"
			"AUTOSCROLL"
			"VIDEOOVERSCAN"
			"RTG"
			"WRITEPIXELLINE"
			"DELAY *"
			"PATCH"
			"DETACH"
			"FADEIN *"
			"FADEOUT *"
			"FADEWB *"
			"ACTIVATEWB"
			"BORDERBLANK"
			"FIXJUMP"
		)
		(default (shiftright calcdef 1))
	)
)
(if (IN flags 0)	((set getmode (cat filelocation "GetModeID"))
			 (if (exists getmode)
				(
				 (message "FileLoc : " filelocation "\n\n"
					  "getmode : " getmode)
				 (run getmode" >ENV:ModeID"
					(help "")
					(prompt "")
				 )
			 	 (set #ausgabe (cat #ausgabe "MODEID "))
				 (set erg (getenv "ModeID"))
				 (set erg (substr erg 0 (- (strlen erg) 1)))
				 (set #ausgabe (cat #ausgabe " " erg " "))
				)
				(message "\n\nGetModeID not found\n\n"
					 "ModeID not chooseable !")
			 )
			)
)

(complete 80)

(if (IN flags 1)  (set #ausgabe (cat #ausgabe "CENTER=ON ")))
(if (IN flags 2)  (set #ausgabe (cat #ausgabe "AUTOSCROLL ")))
(if (IN flags 3)  (set #ausgabe (cat #ausgabe "VIDEOOVERSCAN ")))
(if (IN flags 4)  (set #ausgabe (cat #ausgabe "RTG ")))
(if (IN flags 5)  (set #ausgabe (cat #ausgabe "WRITEPIXELLINE ")))
(if (IN flags 6) ((set #ausgabe (cat #ausgabe "DELAY="))
		  (set add   (askstring (help "Enter 0 to enable StopPicBoot in WBStartup !")
			     (prompt "DELAY\n\nEnter 0 to enable StopPicBoot")
			     (default "0")))
		  (set #ausgabe (cat #ausgabe add " ")))
)
(if (IN flags 7)  (set #ausgabe (cat #ausgabe "PATCH ")))
(if (IN flags 8)  (set #ausgabe (cat #ausgabe "DETACH ")))
(if (IN flags 9)	(	(set #ausgabe (cat #ausgabe "FADEIN "))	
				(set erg (askchoice (prompt "FADEIN\n\nBitte geben Sie die Dauer\n"
							    "zum Einfaden an:\n\n")
						(help readg)
						(choices "langsam" "schneller" "noch schneller" "am schnellsten")
						(default (- fadein 1)))
				)
				(set #ausgabe (cat #ausgabe (+ erg 1) " "))
			)
)
(if (IN flags 10) 	(	(set #ausgabe (cat #ausgabe "FADEOUT "))
				(set erg (askchoice (prompt "FADEOUT\n\nBitte geben Sie die Dauer\n"
							    "zum Ausfaden an:\n\n")
						(help readg)
						(choices "langsam" "schneller" "noch schneller" "am schnellsten")
						(default (- fadeout 1)))
				)
				(set #ausgabe (cat #ausgabe (+ erg 1) " "))
			)
)
(if (IN flags 11)	(	(set #ausgabe (cat #ausgabe "FADEWB "))
				(set erg (askchoice (prompt "FADEWB\n\nBitte geben Sie die Dauer\n"
							    "zum Ausfaden auf der Workbench an:\n\n")
						(help readg)
						(choices "langsam" "schneller" "noch schneller" "am schnellsten")
						(default (- fadewb 1)))
				)
				(set #ausgabe (cat #ausgabe (+ erg 1) " "))
			)
)
(if (IN flags 12) (set #ausgabe (cat #ausgabe "ACTIVATEWB ")))
(if (IN flags 13) (set #ausgabe (cat #ausgabe "BORDERBLANK ")))
(if (IN flags 14) (set #ausgabe (cat #ausgabe "FIXJUMP ")))

(set #ausgabe (cat filelocation #ausgabe))
(message	"Now you have the possibility to control your\n"
		"settings:                                   \n"
		"\n" #ausgabe
		"\n\n"
		"If this isn't correct choose 'Abort Install'\n"
		"and restart the Programm again              \n")

(complete 90)

(run	(prompt "I will now save the Preferences")
	(help "Saves the String to S:PicBoot-Startup")
	"echo " #ausgabe ">s:PicBoot-Startup"
)

(run	(help "")
	(prompt "")
	"C:Search s:startup-sequence S:PicBoot-Startup >ENV:PBenv")
(set erg (getenv "PBenv"))

(if (= erg "") (message "ATTENTION !\n\n"
			"You haven't added the necessary lines for\n"
			"this Preferences-Programm to work in your\n"
			"s:startup-sequence. Please add the       \n"
			"following in your startup-sequence       \n"
			"shortly after the 'Setpatch'-Instruction:\n"
			"\n"
			"    if exists S:PicBoot-Startup          \n"
			"       execute S:PicBoot-Startup         \n"
			"    endif                                \n"
			"\n"
			"or if you have already an instruction for\n"
			"PicBoot just replace it by this           \n"))
			
(run (help"")(prompt "") "unsetenv "PBenv"")
(run (help"")(prompt "") "unsetenv "ModeID"")

(complete 100)
(exit " ")
(welcome "")
