; Montage24 Installer Utility
;
; For Montage24 release 1.0 from InnoVision Technology
;
; (Last updated: Vincent Law 8/26/93)

(set @user-level 2)

(
   ; Which OS are we under?
   (set osver (/ (getversion) 65536))

   ; Ask where to install it...
   (makedir "RAM:ENV")
   (makeassign "ENV" "RAM:ENV")

   (set MT24_flag
      (askchoice
         (prompt "\nWhich platform do you want Montage24 to run on?\n")
         (help "Select a platform on which you want Montage24 to run on.\n")
         (choices "   AGA    " "   IV24   " "OpalVision")
         (default 0)
      )
   )

   (run "Montage24_1:get_best_drive")
   (set default_dir (getenv "MONTAGE24_DRIVE"))
   (if (<> @ioerr 0)
      (abort "ERROR: Installation cannot proceed!\n")
   )

   (set SelectDefault
      (askbool
         (prompt "\nSelect PROCEED to begin Montage24 Installation on\n"
                 "   " default_dir "  \n\n"
                 "If you want to install Montage24 on any other    \n"
                 "drive, select CHANGE DRIVE.                      \n")
         (help "\n\n   Click PROCEED to install Montage24 onto\n"
               "   " default_dir "  \n\n"
               "   Click CHANGE DRIVE if you want to install Montage24 elsewhere.\n"
         )
         (choices "Proceed" "Change Drive")
         (default 1)
      )
   )

   (if SelectDefault
      (
         (set montage_drive default_dir)
         (set Error_code 0)
      )
      (set Error_code 127)
   )

;   (while (<> Error_code 0)
;      (
;         (set montage_drive
;            (askdir
;               (prompt "Click PROCEED to install Montage24 here or type\n"
;                       "in your preferred drive name and press RETURN. \n"
;                       "Click SHOW DRIVES to look at available drives. \n")
;               (help "   This is the default drive name    \n"
;                     "   where Montage24 will be installed.\n")
;               (default default_dir)
;            )
;         )
; to be changed for MT24 ->
;         (execute "delete ENV:MONTAGE24_DRIVE")
;         (run "Montage1:check_where_toaster_is " montage_drive)
;         (set montage_drive (getenv "MONTAGE24_DRIVE"))
;         (if (= montage_drive "")
;            (
;               (message
;                  "ERROR\n\n"
;                  "Cannot install Montage24\n"
;               )
;               (set Error_code 255)
;            )
;            (set Error_code 0)
;         )
; to be changed for MT24 <-
;      )
;   )
   (set montage_drive
      (askdir
         (prompt "Click PROCEED to install Montage24 here or type\n"
                 "in your preferred drive name and press RETURN. \n"
                 "Click SHOW DRIVES to look at available drives. \n")
         (help "   This is the default drive name    \n"
               "   where Montage24 will be installed.\n")
         (default default_dir)
      )
   )

   (set @default-dest (tackon montage_drive "Montage24!"))
   (if (= (exists @default-dest) 0)
      (makedir @default-dest)
   )

   (if (= (exists (tackon @default-dest "MT24SEQ")) 0)
      (makedir (tackon @default-dest "MT24SEQ"))
   )

   (if (= (exists (tackon @default-dest "MT24PIX")) 0)
      (makedir (tackon @default-dest "MT24PIX"))
   )

   (if (= (exists (tackon @default-dest "MT24FONTS")) 0)
      (makedir (tackon @default-dest "MT24FONTS"))
   )

   (if (= (exists (tackon @default-dest "MT24DATA")) 0)
      (makedir (tackon @default-dest "MT24DATA"))
   )

   (set iff_dir
      (askdir
         (prompt "Enter the name of your preferred directory\n"
                 "for loading 24-bit IFF picture files:     \n")
         (help "   This is the default directory where   \n"
               "   IFF pictures will be loaded and saved.\n")
         (default (tackon @default-dest "MT24PIX"))
      )
   )

;   (set framestore_dir
;      (askdir
;         (prompt "Enter the name of default FRAMESTORE directory:\n")
;         (help "This is the directory where the framestore files will be saved.\n")
;         (default iff_dir)
;      )
;   )

   (makeassign "Montage24" @default-dest)
   (makeassign "MT24DATA" (tackon @default-dest "MT24DATA"))
   (makeassign "MT24SEQ" (tackon @default-dest "MT24SEQ"))
   (makeassign "MT24FONTS" (tackon @default-dest "MT24FONTS"))
   (makeassign "MT24PIX" (tackon @default-dest "MT24PIX"))

   (startup "Montage24"
      (prompt "Updating user-startup with necessary\n"
              "Montage24 assigns.                  \n\n"
              "Select PROCEED now.\n")
      (help @startup-help)
      (command "Assign Montage24: " @default-dest "\n")
      (command "Assign MT24DATA: " (tackon @default-dest "MT24DATA\n"))
      (command "Assign MT24SEQ: " (tackon @default-dest "MT24SEQ\n"))
      (command "Assign MT24FONTS: " (tackon @default-dest "MT24FONTS\n"))
      (command "Assign MT24PIX: " (tackon @default-dest "MT24PIX\n"))
   )

   (onerror
      (message
         "Cannot update startup sequence.                     \n"
         "You will need to add the following command manually:\n"
         "'Assign Montage24: " @default-dest "'\n"
         "'Assign MT24DATA: " (tackon @default-dest 'MT24DATA') "'\n"
         "'Assign MT24SEQ: " (tackon @default-dest 'MT24SEQ') "'\n"
         "'Assign MT24FONTS: " (tackon @default-dest 'MT24FONTS') "'\n"
         "'Assign MT24PIX: " (tackon @default-dest 'MT24PIX') "'\n")
   )

   ;----------------------------------------------------------
   ; Prompt for Disk 1.

   (if (= (exists "Montage24_1:") 2)
      (askdisk
         (prompt "Please insert Montage24 Program Disk 1:")
         (help "")
         (dest "Montage24_1")
      )
   )

   (copyfiles
      (prompt "Creating Montage24 Assign file")
      (help @copyfiles-help)
      (source "Montage24_1:Assign_file")
      (dest @default-dest)
   )

   (run "Montage24_1:make_MT24_assign_file " @default-dest " " iff_dir)

   (onerror
      (message
         "Montage24 installation is not complete.\n"
         "Do you want to quit?\n"
      )
   )

   (working "Installing Montage24 Utility Files...")

   (copyfiles
      (prompt "")
      (help @copyfiles-help)
      (source "Montage24_1:data_files")
      (pattern "xxxx.#?")
      (dest (tackon @default-dest "MT24DATA"))
   )

   (if (= MT24_flag 0)
      (
         (copyfiles
            (prompt "")
            (help @copyfiles-help)
            (source "Montage24_1:data_files/Montage_prefs.8")
            (dest (tackon @default-dest "MT24DATA"))
            (newname "Montage_prefs")
         )
         (set G_LOCK_flag
            (askbool
               (prompt "\nDo you have a GVP G_LOCK genlock installed?\n")
               (help "Select YES if you have a GVP G_LOCK genlock,\n"
                     "or otherwise NO.                            \n")
               (choices "YES" "NO")
               (default 0)
            )
         )
         (if (= G_LOCK_flag 1)
            (copyfiles
               (prompt "")
               (help @copyfiles-help)
               (source "Montage24_1:data_files/sync")
               (dest (tackon @default-dest "MT24DATA"))
            )
            (
               (if (= (exists (tackon @default-dest "MT24DATA/sync")) 1)
                  (delete (tackon @default-dest "MT24DATA/sync"))
               )
            )
         )
      )
      (copyfiles
         (prompt "")
         (help @copyfiles-help)
         (source "Montage24_1:data_files/Montage_prefs.24")
         (dest (tackon @default-dest "MT24DATA"))
         (newname "Montage_prefs")
      )
      (if (= (exists "c:IConX") 0)
         (
            (copyfiles
               (prompt "")
               (help @copyfiles-help)
               (source "Montage24_1:IConX")
               (dest @default-dest)
            )
            (copyfiles
               (prompt "")
               (help @copyfiles-help)
               (source "Montage24_1:IConX")
               (dest "c:")
            )
         )
      )
   )

   (copyfiles
      (prompt "")
      (help @copyfiles-help)
      (source "Montage24_1:RESET_MONTAGE24")
      (dest @default-dest)
   )

   ;----------------------------------------------------------
   ; Prompt for Disk 2.

   (askdisk
      (prompt "Please insert Montage24 Program Disk 2:")
      (help "")
      (dest "Montage24_2")
   )

   (working "Installing Montage24 Executables...")

   (copyfiles
      (prompt "")
      (help @copyfiles-help)
      (source "Montage24_2:Montage24!.info")
      (dest montage_drive)
   )

   (copyfiles
      (prompt "")
      (help @copyfiles-help)
      (source "Montage24_2:")
      (pattern "Montage#?")
      (dest @default-dest)
   )
   (delete (tackon @default-dest "Montage24!.info"))

;   (rename (tackon @default-dest "MONTAGE24.BOOT") "ram:MONTAGE24.BOOT")
;   (rename (tackon @default-dest "MONTAGE24.NOBOOT") "ram:MONTAGE24.NOBOOT")
   (textfile
      (prompt "")
      (help @copyfiles-help)
      (dest (tackon @default-dest "MONTAGE24.BOOT"))
      (append "STACK 30000\n"
              "MONTAGE24:MONTAGE_PRO >RAM:TEST " MT24_flag " A\n"
      )
   )

   (makedir "fonts:Menu")
   (copyfiles
      (prompt "")
      (help @copyfiles-help)
      (source "Montage24_2:MMenu")
      (dest "fonts:MMenu")
      (all)
   )
   (copyfiles
      (prompt "")
      (help @copyfiles-help)
      (source "Montage24_2:MMenu.font")
      (dest "fonts:")
   )

   (working "Copying default startup sequence...")

   (copyfiles
      (prompt "")
      (help @copyfiles-help)
      (source "Montage24_2:startup_seq")
      (dest (tackon @default-dest "MT24SEQ"))
      (all)
   )
   (copyfiles
      (prompt "")
      (help @copyfiles-help)
      (source (tackon @default-dest "MT24SEQ/startup_seq.PG.001"))
      (dest (tackon @default-dest "MT24SEQ"))
      (newname "default.PG.001")
   )
   (copyfiles
      (prompt "")
      (help @copyfiles-help)
      (source (tackon @default-dest "MT24SEQ/startup_seq.PG.color"))
      (dest (tackon @default-dest "MT24SEQ"))
      (newname "default.PG.color")
   )
   (copyfiles
      (prompt "")
      (help @copyfiles-help)
      (source (tackon @default-dest "MT24SEQ/startup_seq.PG.preset"))
      (dest (tackon @default-dest "MT24SEQ"))
      (newname "default.PG.preset")
   )
   (copyfiles
      (prompt "")
      (help @copyfiles-help)
      (source (tackon @default-dest "MT24SEQ/startup_seq.PG.color1"))
      (dest (tackon @default-dest "MT24SEQ"))
      (newname "default.PG.color1")
   )
   (copyfiles
      (prompt "")
      (help @copyfiles-help)
      (source (tackon @default-dest "MT24SEQ/startup_seq.PG.001.stamp"))
      (dest (tackon @default-dest "MT24SEQ"))
      (newname "default.PG.001.stamp")
   )

   (working "Copying default startup sequence...")

   (copyfiles
      (prompt "")
      (help @copyfiles-help)
      (source "Montage24_2:Examples")
      (dest (tackon @default-dest "MT24SEQ"))
      (all)
   )

   ;----------------------------------------------------------
   ; Prompt for Disk 3.

   (askdisk
      (prompt "Please insert Montage24 Program Disk 3:")
      (help "")
      (dest "Montage24_3")
   )

   (working "Installing Montage24 Fonts....")

   (copyfiles
      (prompt "")
      (help @copyfiles-help)
      (source "Montage24_3:fonts")
      (dest (tackon @default-dest "MT24FONTS"))
      (all)
   )

   ;----------------------------------------------------------
   ; Prompt for Disk 4.

   (askdisk
      (prompt "Please insert Montage24 Program Disk 4:")
      (help "")
      (dest "Montage24_4")
   )

   (copyfiles
      (prompt "")
      (help @copyfiles-help)
      (source "Montage24_4:fonts")
      (dest (tackon @default-dest "MT24FONTS"))
      (all)
   )

   ;----------------------------------------------------------
   ; Prompt for Disk 5.

   (askdisk
      (prompt "Please insert Montage24 Program Disk 5:")
      (help "")
      (dest "Montage24_5")
   )

   (copyfiles
      (prompt "")
      (help @copyfiles-help)
      (source "Montage24_5:fonts")
      (dest (tackon @default-dest "MT24FONTS"))
      (all)
   )

   (working "Installing required libraries....")

   (if (= (exists "LIBS:kd_freq.library") 0)
      (copyfiles
         (prompt "")
         (help @copyfiles-help)
         (source "Montage24_5:file_interface")
         (pattern "#?.library")
         (dest "LIBS:")
      )
   )

   (working "Installing Tutorial files....")

   (copyfiles
      (prompt "")
      (help @copyfiles-help)
      (source "Montage24_5:Tutorial")
      (pattern "Tutorial.PG#?")
      (dest (tackon @default-dest "MT24SEQ"))
   )

   (copyfiles
      (prompt "")
      (help @copyfiles-help)
      (source "Montage24_5:Tutorial")
      (pattern "#?.IFF#?")
      (dest iff_dir)
   )

   ;----------------------------------------------------------
   ; Prompt for Disk 6.

   (askdisk
      (prompt "Please insert Montage24 Program Disk 6:")
      (help "")
      (dest "Montage24_6")
   )

   (copyfiles
      (prompt "")
      (help @copyfiles-help)
      (source "Montage24_6:")
      (pattern "Tutorial#?.IFF#?")
      (dest iff_dir)
   )

   (set autoMount
      (askbool
         (prompt "Should Montage24 run automatically upon bootup?\n"
                 "For most systems, select NO.                   \n\n")
         (help "\n\nIf you would like, a command will be inserted  "
               "\ninto your \"S:Startup-Sequence\" file to  "
               "\nautomatically start Montage24 upon bootup.\n")
         (default 0)
      )
   )

   (if autoMount
      ((protect "S:Startup-Sequence" "rwed" )
         (startup "Montage-Boot"
            (prompt "Inserting Montage24 command into the startup-sequence\n")
            (help "Montage24 will be launched whenever the system is booted.\n")
            (command "CD MONTAGE:")
            (command 'C:NEWCLI "CON:0/0/640/12/MONTAGE24" FROM MONTAGE24.BOOT')
         )
      )
   )

   (message
      "Remember to remove the last Montage24 disk from\n"
      "the floppy drive after the installation and    \n"
      "store it in a safe place.                      \n"
      (help "\n\n   Click PROCEED to continue.\n   Click CANCEL to abort.\n")
   )
)
