(set #kkversion (getversion))
(set #kkversion (/ #kkversion 65536) )
(set #ilnapedow 3)
(set alinstal 0)
(set #proc (database "cpu"))
(if (OR (= #proc "68000") (= #proc "68010"))
    (abort "\n\nProcessor 68020 or higher is required!")
) 
(if (< #kkversion 39)
   (abort "\n\nKickstart 3.0 or higher is required!")
)


(if (= (getsize "ENVARC:ATA3.Prefs") 13)
 (set alinstal 1)
)
(if (= alinstal 1)
(
(message "\n\n\n\nWelcome to AllegroCDFS! ")

(copylib
   (prompt "AllegroCDFS will be copied to L: directory.")
   (help )
   (source "mountlists/orgella")
   (confirm)
   (newname "AllegroCDFS")
   (dest "L:")
)

(set wybor 0)
(set wybor 
  (askbool
   (prompt "\n\n\n\nMay I delete all CDx mountlists in DEVS:Dosdrivers/?\nRecommended: YES.")
   (help )
   (choices  "Yes"  "No")
   (default 1)
  )
)
(if (= wybor 1)      
 (delete "DEVS:dosdrivers/CD#?")
)      

(if (> #ilnapedow 0)
 (
  (set #zastap 1)
  (set #cdrom
   (askchoice
    (prompt "\n\n\My first CD-ROM (CD-R, CD-RW, DVD) is connected as:")
    (choices "None" "Primary Slave" "Secondary Master" "Secondary Slave") 
    (default 1)
    (help )
   )
  )
  (if (> #cdrom 0)
   (   
    (set #ilnapedow (- #ilnapedow 1))
 	(set name (cat "DEVS:DosDrivers/CD" #cdrom))
    (if (exists name)
     (set #zastap 
      (askbool
       (prompt "\n\n\File " name " exists.\nMay I overwrite it?")
       (help )
       (default 0)
      )
     )
    )
    (if (= #zastap 1)
     (
      (set namep (cat "CD" #cdrom))
      (set names (cat "mountlists/" namep))
      (copyfiles
       (prompt namep ".info will be copied to DEVS:Dosdrivers/ directory.")
       (help )
       (source names)
       (dest "DEVS:Dosdrivers/")
       (infos)
      )
     ) 
    ) 
   )  
  )   
 )    
)
(if (AND (> #ilnapedow 0) (> #cdrom 0))
 (
  (set #zastap 1)
  (set #cdrom
   (askchoice
    (prompt "\n\n\My second CD-ROM (CD-R, CD-RW, DVD) is connected as:")
    (choices "None" "Primary Slave" "Secondary Master" "Secondary Slave") 
    (default 2)
    (help )
   )
  )
  (if (> #cdrom 0)
   (   
    (set #ilnapedow (- #ilnapedow 1))
 	(set name (cat "DEVS:DosDrivers/CD" #cdrom))
    (if (exists name)
     (set #zastap 
      (askbool
       (prompt "\n\n\File " name " exists.\nMay I overwrite it?")
       (help )
       (default 0)
      )
     )
    )
    (if (= #zastap 1)
     (
      (set namep (cat "CD" #cdrom))
      (set names (cat "mountlists/" namep))
      (copyfiles
       (prompt namep ".info will be copied to DEVS:Dosdrivers/ directory.")
       (help )
       (source names)
       (dest "DEVS:Dosdrivers/")
       (infos)
      )
     ) 
    ) 
   )  
  )   
 )    
)
(if (AND (> #ilnapedow 0) (> #cdrom 0))
 (
  (set #zastap 1)
  (set #cdrom
   (askchoice
    (prompt "\n\n\My third CD-ROM (CD-R, CD-RW, DVD) is connected as:")
    (choices "None" "Primary Slave" "Secondary Master" "Secondary Slave") 
    (default 3)
    (help )
   )
  )
  (if (> #cdrom 0)
   (   
    (set #ilnapedow (- #ilnapedow 1))
 	(set name (cat "DEVS:DosDrivers/CD" #cdrom))
    (if (exists name)
     (set #zastap 
      (askbool
       (prompt "\n\n\File " name " exists.\nMay I overwrite it?")
       (help )
       (default 0)
      )
     )
    )
    (if (= #zastap 1)
     (
      (set namep (cat "CD" #cdrom))
      (set names (cat "mountlists/" namep))
      (copyfiles
       (prompt namep ".info will be copied to DEVS:Dosdrivers/ directory.")
       (help )
       (source names)
       (dest "DEVS:Dosdrivers/")
       (infos)
      )
     ) 
    ) 
   )  
  )   
 )    
)
(message "\n\n\n\nAllegroCDFS succesfully installed.")
)
)
(message "\n\n\n\nWelcome to FastATA'99! ")

(set reinstalacja
 (askchoice
  (prompt "")
   (help "\nSelect Installation only when you install this software"
     " for the first time on this HDD, otherwise select Reinstallation.")
   (choices "Installation" "Reinstallation")
   (default 0)
 )
)
(if reinstalacja
 (set wybor 0)
 (set wybor 
  (askbool
   (prompt "\n\n\n\nMay I change your s:startup-sequence?")
   (help "\nIf you agree to change your s:startup-sequence, the installer"
      "will add five lines after setpatch:\n\n C:CheckLMB\n"
      " IF WARN\n SYS:Prefs/ATA3Prefs\n ENDIF\n C:ATA3.driver QUIET")
   (choices  "Yes"  "No")
   (default 1)
  )
 )
)

(copylib
   (prompt "ATA3.driver will be copied to C: directory.")
   (help )
   (source "ATA3.driver")
   (confirm)
   (dest "C:")
)

(copylib
   (prompt "ATA3Prefs will be copied to SYS:Prefs directory.")
   (help )
   (source "ATA3Prefs")
   (confirm)
   (infos)
   (dest "SYS:Prefs")
)

(copyfiles
   (prompt "CheckLMB will be copied to C: directory.")
   (source "CheckLMB")
   (help )
   (dest "C:")
)

(if wybor
   (
      (copyfiles
        (source "S:startup-sequence")
        (dest "RAM:")
      )
      (textfile
        (dest "S:startup-sequence")
        (append "C:SetPatch QUIET\nC:CheckLMB\nIF WARN\n")
        (append "SYS:Prefs/ATA3Prefs\nENDIF\nC:ATA3.driver QUIET\n")
        (include "RAM:startup-sequence")
      )
      (delete "RAM:startup-sequence")
   )
)

(if (> #ilnapedow 0)
 (
  (set #zastap 1)
  (set #ls120
   (askchoice
    (prompt "\n\n\My first LS-120 (ZIP, SyQuest) is connected as:")
    (choices "None" "Primary Slave" "Secondary Master" "Secondary Slave") 
    (default 1)
    (help )
   )
  )
  (if (> #ls120 0)
   (   
    (set #ilnapedow (- #ilnapedow 1))
    (set #ls120 (+ #ls120 4))
	(set name (cat "DEVS:DosDrivers/PC" #ls120))
    (if (exists name)
     (set #zastap         
      (askbool
       (prompt "\n\n\File " name " exists.\nMay I overwrite it?")
       (help )
       (default 0)
      )
     )
    )
    (if (= #zastap 1)
     (
      (set namep (cat "PC" #ls120))
      (set names (cat "mountlists/" namep))
      (copyfiles
       (prompt namep ".info will be copied to DEVS:Dosdrivers/ directory.")
       (help )
       (source names)
       (dest "DEVS:Dosdrivers/")
       (infos)
      )
     )
    ) 
   )
  )
 )
)

(if (AND (> #ilnapedow 0) (> #ls120 0))
 (
  (set #zastap 1)
  (set #ls120
   (askchoice
    (prompt "\n\n\My second LS-120 (ZIP, SyQuest) is connected as:")
    (choices "None" "Primary Slave" "Secondary Master" "Secondary Slave") 
    (default 2)
    (help )
   )
  )
  (if (> #ls120 0)
   (   
    (set #ilnapedow (- #ilnapedow 1))
    (set #ls120 (+ #ls120 4))
	(set name (cat "DEVS:DosDrivers/PC" #ls120))
    (if (exists name)
     (set #zastap         
      (askbool
       (prompt "\n\n\File " name " exists.\nMay I overwrite it?")
       (help )
       (default 0)
      )
     )
    )
    (if (= #zastap 1)
     (
      (set namep (cat "PC" #ls120))
      (set names (cat "mountlists/" namep))
      (copyfiles
       (prompt namep ".info will be copied to DEVS:Dosdrivers/ directory.")
       (help )
       (source names)
       (dest "DEVS:Dosdrivers/")
       (infos)
      )
     )
    ) 
   )
  )
 )
)


(if (AND (> #ilnapedow 0) (> #ls120 0))
 (
  (set #zastap 1)
  (set #ls120
   (askchoice
    (prompt "\n\n\My third LS-120 (ZIP, SyQuest) is connected as:")
    (choices "None" "Primary Slave" "Secondary Master" "Secondary Slave") 
    (default 3)
    (help )
   )
  )
  (if (> #ls120 0)
   (   
    (set #ilnapedow (- #ilnapedow 1))
    (set #ls120 (+ #ls120 4))
	(set name (cat "DEVS:DosDrivers/PC" #ls120))
    (if (exists name)
     (set #zastap         
      (askbool
       (prompt "\n\n\File " name " exists.\nMay I overwrite it?")
       (help )
       (default 0)
      )
     )
    )
    (if (= #zastap 1)
     (
      (set namep (cat "PC" #ls120))
      (set names (cat "mountlists/" namep))
      (copyfiles
       (prompt namep ".info will be copied to DEVS:Dosdrivers/ directory.")
       (help )
       (source names)
       (dest "DEVS:Dosdrivers/")
       (infos)
      )
     )
    ) 
   )
  )
 )
)

(exit "\n\n\n\nFastATA'99 succesfully installed.\n\n"
      "Now reboot your machine with left mouse button\npressed. "
      "It will run ATA3Prefs.\n\n"
      "Click SAVE on exit from ATA3Prefs." (quiet))
