(set #kkversion (getversion))
(set #kkversion (/ #kkversion 65536) )
(set alinstal 1)
(set ilnapedow 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!")
)
(message "\n\n\n\nWelcome to 4xEIDE'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 1)
 (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 lines:\nC:CheckLMB\nIF WARN\n"
      "SYS:Prefs/4xEIDEPrefs\nENDIF\nC:4xEIDE.driver QUIET")
   (choices  "Yes"  "No")
   (default 1)
  )
 )
)

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

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

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


(if (= wybor 1)
   (
      (copyfiles
        (source "S:startup-sequence")
        (dest "RAM:")
      )
      (textfile
        (dest "S:startup-sequence")
        (append "C:CheckLMB\nIF WARN\nSYS:Prefs/4xEIDEPrefs\nENDIF\n")
        (append "C:4xEIDE.driver QUIET\n")
        (include "RAM:startup-sequence")
      )
      (delete "RAM:startup-sequence")
   )
)
(run "4xEIDEPrefs INIT")
(if ( exists "RAM:L0")
 (
  (delete "RAM:L0")
  (set ilnapedow (+ ilnapedow 1))
  (set wybor 
    (askbool
     (prompt "\n\n\n\nI find LS/ZIP connected as Primary Master\n"
          "May I create mountlist?")
     (help )
     (default 0)
    )
  )
  (set zastap 1)
  (if (exists "DEVS:Dosdrivers/PC4")
     (set zastap         
      (askbool
       (prompt "\n\n\n\n\nFile PC4 exists.\nMay I overwrite it?")
       (help )
       (default 0)
      )
    )
  )
  (if (AND zastap wybor) 
     (copyfiles
       (prompt "PC4.info will be copied to DEVS:Dosdrivers/ directory.")
       (help )
       (source "mountlists/PC4")
       (dest "DEVS:Dosdrivers/")
       (infos)
      )
  )
 )
)

(if ( exists "RAM:L1")
 (
  (delete "RAM:L1")
  (set ilnapedow (+ ilnapedow 1))
  (set wybor 
    (askbool
     (prompt "\n\n\n\nI find LS/ZIP connected as Primary Slave\n"
          "May I create mountlist?")
     (help )
     (default 0)
    )
  )
  (set zastap 1)
  (if (exists "DEVS:Dosdrivers/PC5")
     (set zastap         
      (askbool
       (prompt "\n\n\n\n\nFile PC5 exists.\nMay I overwrite it?")
       (help )
       (default 0)
      )
    )
  )
  (if (AND zastap wybor) 
     (copyfiles
       (prompt "PC5.info will be copied to DEVS:Dosdrivers/ directory.")
       (help )
       (source "mountlists/PC5")
       (dest "DEVS:Dosdrivers/")
       (infos)
      )
  )
 )
)

(if ( exists "RAM:L2")
 (
  (delete "RAM:L2")
  (set ilnapedow (+ ilnapedow 1))
  (set wybor 
    (askbool
     (prompt "\n\n\n\nI find LS/ZIP connected as Secondary Master\n"
          "May I create mountlist?")
     (help )
     (default 0)
    )
  )
  (set zastap 1)
  (if (exists "DEVS:Dosdrivers/PC6")
     (set zastap         
      (askbool
       (prompt "\n\n\n\n\nFile PC6 exists.\nMay I overwrite it?")
       (help )
       (default 0)
      )
    )
  )
  (if (AND zastap wybor) 
     (copyfiles
       (prompt "PC6.info will be copied to DEVS:Dosdrivers/ directory.")
       (help )
       (source "mountlists/PC6")
       (dest "DEVS:Dosdrivers/")
       (infos)
      )
  )
 )
)

(if ( exists "RAM:L3")
 (
  (delete "RAM:L3")
  (set ilnapedow (+ ilnapedow 1))
  (set wybor 
    (askbool
     (prompt "\n\n\n\nI find LS/ZIP connected as Secondary Slave\n"
          "May I create mountlist?")
     (help )
     (default 0)
    )
  )
  (set zastap 1)
  (if (exists "DEVS:Dosdrivers/PC7")
     (set zastap         
      (askbool
       (prompt "\n\n\n\n\nFile PC7 exists.\nMay I overwrite it?")
       (help )
       (default 0)
      )
    )
  )
  (if (AND zastap wybor) 
     (copyfiles
       (prompt "PC7.info will be copied to DEVS:Dosdrivers/ directory.")
       (help )
       (source "mountlists/PC7")
       (dest "DEVS:Dosdrivers/")
       (infos)
      )
  )
 )
)
(if (= alinstal 1)
(
(message "\n\n\n\n4xEIDE'99 succesfully installed.")
(message "\n\n\n\nWelcome to AllegroCDFS! ")
(copylib
   (prompt "AllegroCDFS will be copied to L: directory.")
   (help )
   (source "AllegroCDFS")
   (confirm)
   (newname "AllegroCDFS")
   (dest "L:")
)

(copyfiles
   (prompt "def_ISOCDDA.info will be copied to ENVARC: directory.")
   (help )
   (confirm)
   (source "icons/def_ISOCDDA.info")
   (dest "ENVARC:")
)

(copyfiles
   (prompt "def_CDDAdisk.info will be copied to ENVARC: directory.")
   (help )
   (confirm)
   (source "icons/def_CDDAdisk.info")
   (dest "ENVARC:")
)


(set wybor 0)
(set wybor 
  (askbool
   (prompt "\n\n\n\nMay I delete all CDx mountlists in DEVS:Dosdrivers/?\nRecommended: YES.")
   (help )
   (default 1)
  )
)
(if wybor (delete "DEVS:dosdrivers/CD#?"))      
(if ( exists "RAM:C0")
 (
  (delete "RAM:C0")
  (set ilnapedow (+ ilnapedow 1))
  (set wybor 
    (askbool
     (prompt "\n\n\n\nI find CD-ROM connected as Primary Master\n"
          "May I create mountlist?")
     (help )
     (default 0)
    )
  )
  (set zastap 1)
  (if (exists "DEVS:Dosdrivers/CD0")
     (set zastap         
      (askbool
       (prompt "\n\n\n\n\nFile CD0 exists.\nMay I overwrite it?")
       (help )
       (default 0)
      )
    )
  )
  (if (AND zastap wybor) 
     (copyfiles
       (prompt "CD0.info will be copied to DEVS:Dosdrivers/ directory.")
       (help )
       (source "mountlists/CD0")
       (dest "DEVS:Dosdrivers/")
       (infos)
      )
  )
 )
)

(if ( exists "RAM:C1")
 (
  (delete "RAM:C1")
  (set ilnapedow (+ ilnapedow 1))
  (set wybor 
    (askbool
     (prompt "\n\n\n\nI find CD-ROM connected as Primary Slave\n"
          "May I create mountlist?")
     (help )
     (default 0)
    )
  )
  (set zastap 1)
  (if (exists "DEVS:Dosdrivers/CD1")
     (set zastap         
      (askbool
       (prompt "\n\n\n\n\nFile CD1 exists.\nMay I overwrite it?")
       (help )
       (default 0)
      )
    )
  )
  (if (AND zastap wybor) 
     (copyfiles
       (prompt "CD1.info will be copied to DEVS:Dosdrivers/ directory.")
       (help )
       (source "mountlists/CD1")
       (dest "DEVS:Dosdrivers/")
       (infos)
      )
  )
 )
)

(if ( exists "RAM:C2")
 (
  (delete "RAM:C2")
  (set ilnapedow (+ ilnapedow 1))
  (set wybor 
    (askbool
     (prompt "\n\n\n\nI find CD-ROM connected as Secondary Master\n"
          "May I create mountlist?")
     (help )
     (default 0)
    )
  )
  (set zastap 1)
  (if (exists "DEVS:Dosdrivers/CD2")
     (set zastap         
      (askbool
       (prompt "\n\n\n\n\nFile CD2 exists.\nMay I overwrite it?")
       (help )
       (default 0)
      )
    )
  )
  (if (AND zastap wybor) 
     (copyfiles
       (prompt "CD2.info will be copied to DEVS:Dosdrivers/ directory.")
       (help )
       (source "mountlists/CD2")
       (dest "DEVS:Dosdrivers/")
       (infos)
      )
  )
 )
)

(if ( exists "RAM:C3")
 (
  (delete "RAM:C3")
  (set ilnapedow (+ ilnapedow 1))
  (set wybor 
    (askbool
     (prompt "\n\n\n\nI find CD-ROM connected as Secondary Slave\n"
          "May I create mountlist?")
     (help )
     (default 0)
    )
  )
  (set zastap 1)
  (if (exists "DEVS:Dosdrivers/CD3")
     (set zastap         
      (askbool
       (prompt "\n\n\n\n\nFile CD3 exists.\nMay I overwrite it?")
       (help )
       (default 0)
      )
    )
  )
  (if (AND zastap wybor) 
     (copyfiles
       (prompt "CD3.info will be copied to DEVS:Dosdrivers/ directory.")
       (help )
       (source "mountlists/CD3")
       (dest "DEVS:Dosdrivers/")
       (infos)
      )
  )
 )
)

(exit "\n\n\n\nAllegroCDFS succesfully installed." (quiet))
)
(exit "\n\n\n\n4xEIDE'99 succesfully installed." (quiet))
)
