;******************************************************************************
;      ______ ______ __                        
;     / ____// __  // /                       
;    / /___ / /_/ // /  ______ __  __ ______ _____
;   /___  // ____// /  / __  / \ \/ // ____// .__/
;  ____/ // /    / /_ / __  /   \  // __/_ / /
; /_____//_/    /___//_/ /_/    / //_____//_/
;                              /_/       
;
; $VER: SPlayer_Install 0.64 (March-28-1997)
; Changes, suggestions or problems: vgr@best.com
; May not be hacked into any "internet pack"
; If you wish to use any part of this installer you must ask.
; 
; splayer 1996-1997 by Allan Versaevel 
; splayer Installer 1997 by Robert C. Reiswig  
;******************************************************************************
(set osver (/ (getversion "LIBS:version.library") 65536))
(set vernum1 (getversion "splayer"))
(set ver1 (/ vernum1 65536)) (set rev1 (- vernum1 (* ver1 65536) ) )
(set splayerver (cat ver1 "." rev1))

;********************************************************************
; English Strings
;********************************************************************
(set #about (cat "\n\nWelcome to\n\nSPlayer " splayerver "\n\n1996-1997 by\n\nAllan Versaevel\n") )
(set #todo-prompt "\nWhat parts of SPlayer do you wish to install?\n")
(set #splayer " SPlayer")
(set #extrabin " Extra bins (Needed)")
(set #fonts " fonts (Needed)")
(set #play16 " Play16 (Needed)")
(set #gaip16 " GAIP16 (Needed)")

(set #wheresplayer "Where do you wish to install SPlayer. A directory called 'SPlayer' will be created.")
(set #whereplay16 "Where do you wish to install the Play16 program. A directory will not be created.")
(set #wheregaip16 "Where do you wish to install the GAIP16 program. A directory will not be created.")
(set #askcpu "\nWhat version of Play16 would you like to install?\n")

(set #whatdocs "\nWhat SPlayer documentation would you like to install? (The selected ones will be copied over if they are found in this archive.)\n")
(set #wheredocs "Where would you like the SPlayer documentation you selected to be installed?")

(set #doconfig "\nDo you wish to:\n")
(set #yconfig " Make new config file, delete old one.")
(set #nconfig " Use current config file.") 
(set #wheresgapi "Where do you have Gaip16 installed for AHI support?")

(set #byebye (cat "\nSPlayer Install Complete!\n\n" " "))
;********************************************************************
; Hello
;********************************************************************
(message #about)
(welcome) 

;*********************************************************************************
; Ask user what to install
;*********************************************************************************
(set ToDo (askoptions (choices  #splayer #extrabin #fonts #play16 #gaip16) 
                      (prompt #todo-prompt)
                      (help #todo-prompt)
                      (default 31)
          )
) 

;********************************************************************
; Ask where to Install splayer 
;********************************************************************
(set splayerdir (askdir (prompt #wheresplayer)
		        (help   #wheresplayer)
     		        (default "sys:")
                )  
)

(set where splayerdir)
(set @default-dest where)

;********************************************************************
; Make Directory and copy over splayer
;********************************************************************
(if (IN ToDo 0)
 (
  (if (< (exists (tackon where "SPlayer")) 2) (makedir (tackon where "SPlayer") (infos)) )
  (copyfiles (source "SPlayer") (dest (tackon where "splayer")) (infos) (optional "askuser" "force" "nofail") )      
 )
)

(if (IN ToDo 1)
 (
  (if (< (exists "s:SPlayer") 2) (makedir "s:SPlayer"))
  (copyfiles (source "bin/s/SPlayer") (dest "s:splayer") (all) (infos) (optional "askuser" "force" "nofail") )
  (copyfiles (source "bin/led") (dest "c:") (infos) (optional "askuser" "force" "nofail") )
  (if (< osver 39)
    (copyfiles (source "bin/RequestFile") (dest "c:") (infos) (optional "askuser" "force" "nofail") )
  ) 
 )
)

(if (IN ToDo 2)
 (
  (copyfiles (source "fonts") (dest "fonts:") (all) (infos) (optional "askuser" "force" "nofail") )
 )
)


(if (IN ToDo 3)
 (
  (set play16dir (askdir (prompt #whereplay16) (help #whereplay16) (default (tackon where "SPlayer")) ) )
  (set gcpu 0) 
  (if (AND (> #cpu 1) (exists ("Play16_1.7/Play16'020")) ) (set gcpu 1) ) 

  (set cpuPick (askchoice (choices "68000" "68020")
	                  (prompt #askcpu)
	                  (help   #askcpu)
                          (default gcpu)
	       )
  )

   (if (AND (= cpuPick 1) (exists ("Play16_1.7/Play16'020")) )
    ((copyfiles (source "Play16_1.7/Play16'020") (dest play16dir) (newname "Play16") (infos) (optional "askuser" "force" "nofail") )
     (copyfiles (source "Play16_1.7/Play16.info") (dest play16dir) (infos) (optional "askuser" "force" "nofail") ) 
    )
    (copyfiles (source "Play16_1.7/Play16") (dest play16dir) (infos) (optional "askuser" "force" "nofail") )
   )

  (copylib (source "Play16_1.7/libs/asyncio.library") (dest "libs:") (optional "askuser" "force" "nofail") )

 )
)

(if (IN ToDo 4)
 (
  (set gaip16dir (askdir (prompt #wheregaip16) (help #wheregaip16) (default (tackon where "SPlayer")) ) )
  (copyfiles (source "Play16_1.7/GAIP16") (dest play16dir) (infos) (optional "askuser" "force" "nofail") )
 )
)


;********************************************************************
; Ask where and if docs are wanted.
;********************************************************************
(set docs (askoptions (choices " SPlayer.guide" " SPlayer.doc")
		      (prompt #whatdocs)
                      (help #whatdocs)
	              (default 3)
	  )
)

(if (<> docs 0)
 (
   (set docsdir (askdir (prompt #wheredocs)
		       (help   #wheredocs)
     		       (default (tackon where "SPlayer"))
                )  
   )


   (if (AND (exists "splayer.guide") (IN docs 0)) 
    (copyfiles (source "SPlayer.guide") (dest docsdir) (infos) (optional "nofail") )
   )
 
   (if (AND (exists "splayer.doc") (IN docs 1)) 
    (copyfiles (source "SPlayer.doc") (dest docsdir) (infos) (optional "nofail") )
   )
 )
)

;********************************************************************
; Check for S:SPlayer/Splayer.prefs ...
;********************************************************************
(set doconfig 0)

;(if (= (exists "S:SPlayer/Splayer.prefs") 1) 
;  (set doconfig (askchoice (choices #yconfig #nconfig)
;  	  	           (prompt #doconfig)
;                           (help   #doconfig)
;          		   (default docongif)
;                )
;  )
;)

(if (= doconfig 0)
 (
   ;(set gaip16dir (askdir  (prompt #wheresgapi)
   ;	                   (help   #wheresgapi)
   ;  		           (default "SYS:")
   ;               )  
   ;)

   (set configwrite (cat (tackon play16dir "play16") "*" (tackon gaip16dir "GAIP16") "*" "0/0*131082*0000*0000*01"))
   ;(message configwrite)
   (textfile (dest "S:SPlayer/Splayer.prefs") (append configwrite))
 )
)

;********************************************************************
; End Bye 
;********************************************************************
(set @default-dest (tackon where "splayer"))
(exit #byebye)
