;****************************************************************************
; A4000-060 Install Script
; Version 1.0
; $VER: 1.9 (10 August 1995) © TekMagic
;
; Original       by Jeff Boyer-------- 10 August   1995
; New for 060    by Jeff Boyer         30 January  1996
; new for the A4000-060 		5 August   1996
;
; Copyright 1996 by J Boyer, Inc.
;
; Written for use with Commodore's Installer V1.24
;****************************************************************************

;****************************************************************************
; Some useful variables
;****************************************************************************
(set disklab "A4KT.Install")          ;Source disk for new files
(set disklab2 (cat disklab ":"))      ; Source disk, with colon
(set os_ver
     (/ (getversion) $0000FFFF))      ; version of AmigaDOS...

;****************************************************************************
; Various parts of this install program require AmigaDOS 2.0.
; Then again, GForce requires 2.0.  Prevent usage by those
; running obsolete versions of the operating system.
;****************************************************************************
(if (< os_ver 36)
  (
    (abort "You need AmigaDOS V36 or later to complete the installation "
           "process.  Furthermore, you need AmigaDOS V37 or later to run "
           "using the Motorola 680060.  Please upgrade your system and "
           "try again.")
  ))
;(if (< kickstart_ver 39)
;  (
;    (abort "You need KickStart V40 (3.1 ROM) or later to to run using the" 
;     "Motorola 68060.  Please upgrade your system and try again.")
;  ))
;
;****************************************************************************
; We need to find out where the usual SYS: partition is.  Currently looks
; for WB_2.x:, System2.0:, or dh0:.  Ask user if we can't figure out where
; s/he boots from, and/or for confirmation.
;****************************************************************************
(set target (getassign "wb_2.x" 'd'))             ; Device-only check.
(if (= target "")
    (set target (getassign "System2.0" 'v')))     ; VolumeName-only check.
(if (= target "")
    (set target (getassign "dh0" 'd')))           ; Device-only check.
(if (= target "")
    (set target (getassign "System2.0")))         ; Logical assign check.
(if (= target "")
    (set target (getassign "dh0")))               ; Logical assign check.
(if (= target "")
    (set target (getassign "hd0" 'd')))           ; Device-only check.
(if (= target "")
    (set target (getassign "workbench" 'v')))     ; VolumeName-only check.
(if (= target "")
    (set target (getassign "workbench")))         ; Logical assign check.

;****************************************************************************
; If we're at Wit's End:
;****************************************************************************
(if (= target "")
    (set target @default-dest))                   ; default destination

;****************************************************************************
; Now, make absolutely, positively sure that we go to the right place.
;****************************************************************************
(set target (askdir (prompt "Which partition do you usually boot from?\n"
                            "The required utilities should be installed there.")
                    (help @askdir-help)
                    (default target)))

;****************************************************************************
; Install new SetPatch command.  Use CopyLib so that version numbers are checked.
;****************************************************************************
;(copylib (source (tackon disklab2 "c/SetPatch")) (dest (tackon target "c"))
;         (infos) (confirm)
;         (prompt "Shall I install the new SetPatch command?")
;         (help "You need the very latest SetPatch in order for the '060 "
;               "system to function properly and reliably.  Please check "
;               "the version numbers carefully, and use the newer version.\n\n"
;               @copylib-help))
;
;****************************************************************************
; Install new CPU.   Use CopyLib so that version numbers are checked.
;****************************************************************************
(copyfiles (source (tackon disklab2 "A4KT/68060/CPU060")) 
      (dest (tackon target "c"))
         (infos) (confirm)
         (prompt "Shall I install the new \"CPU060\" CPU control Program?")
         (help "The \"CPU060\" CPU control Program allows the user to control " 
          "the 68060 cache settings.\n\n"
               @copylib-help))
;****************************************************************************
; Make backup copy of 68040.library
;****************************************************************************
(set mods_ok (askbool (prompt "Your copy of the 68040.library must be replaced"
			      " with a version compatible with the 68060. Do "
			      "you want to make a backup copy of your original"
			      " ? Your backup file name will be "
			      "68040.library_Backup")
                      (choices "Yes" "No")
                      (default "Yes")
                      (help "The normal 68040.libary MUST be replaced with "
			    "a version that is compatible with the 68060 CPU.\n"
                            "For additional security, a copy of your original\n"
                            "68040.library will be made and will be stored as\n"
                            "68040.library_backup.")
             )
)

(if mods_ok
    
       (run (cat
             "c:copy \""
             (tackon target "libs/68040.library") "\" \""
             (tackon target "libs/68040.library_Backup")
              "\" clone")
                   (prompt "Making backup copy of "
                           (tackon target "S/Startup-sequence") ".\n"
                           "It will be called '"
                           (tackon target "S/Startup-Sequence.Backup") "'.")
        )
)
;****************************************************************************
; Install 68060.library
;****************************************************************************
(copyfiles (source (tackon disklab2 "A4KT/68060/libs_060")) 
           (dest (tackon target "libs"))
    (pattern "68#?")
    (infos) (confirm)
         (prompt "These libraries must be installed for the 68060 to run"
       " correctly")
         (help "Both of these libraries are required by the system in "
               "order to function properly and reliably. If you presently "
               "have a 68040.library it needs to be replaced with the " 
               "A4KT 68040.library for the 68060.library to install "
               "properly. \n\n"
               @copylib-help)
)
;****************************************************************************
; Install sys:tekmagic/68040/ksremap
;****************************************************************************
;(copyfiles (source (tackon disklab2 "A4KT/68040"))
;         (dest (tackon target "Utilities"))
;         (pattern "(KSReMap)")
;         (infos) (confirm)
;         (prompt "The following MUST be installed in sys:utilities:\n")
;         (help "KSRemap  - allows for the Remapping of the KickStart ROMS"
;               " into Fast Memory to enhance system performance. \n"
;               	@copyfiles-help))
;
;****************************************************************************
; Install sys:TekMagic /SCSI/(Fast|Expert)Prep
;****************************************************************************
;(copyfiles (source (tackon disklab2 "TekMagic/gvp/SCSI"))
;         (dest (tackon target "Utilities"))
;         (pattern "(SCSI|Fast|Expert)#?")
;         (infos) (confirm)
;         (prompt "The following should be installed in sys:utilities:\n")
;         (help "FastPrep    - Automated Hard Drive Prep-and-    \n"
;               "              Format utility.                   \n"
;               "ExpertPrep  - Advanced Hard Drive Prep-and-     \n"
;               "              Format utility.                   \n"
;               "SCSIMaskFix - See ReadMe file on TekMagic install \n"
;               "              disk                              \n"
;               @copyfiles-help))
;
;
;****************************************************************************
; Alter user-startup and add KSRemap option.
;****************************************************************************
;(startup "68060_KSRemap" 
;         (prompt "Would you like to enhance performance by adding "
;	         "KickStart remap to your user-startup? If so, click; on "
;                 "'Proceed'. Note this will only modify the user-startup "
;		 "file of the device you booted from. If you will be "
;		 "booting from another device add the line \"YOUR_boot_device"
;		 "/utilities/ksremap\" to that boot device's user-startup"
;		 " file. ")
;         (help "This will automatically copy the Kickstart image "
;               "and the Supervisor Stack Pointer into the 68060's "
;               "extremely Fast RAM.  It will be MUCH faster than "
;               "reading from ROM and Chip RAM, and will increase "
;               "system performance greatly.\n")
;         (command "utilities/ksremap"))


;****************************************************************************
; Modify Startup-sequence.  Use plenty of safeguards.
;****************************************************************************
(set mods_ok (askbool (prompt "To maximise system performance with the 68060 "
			      "the command \"SetPatch\"should be added to "
			      "your startup-sequence. Is it ok to modify ?")
                      (choices "Yes" "No")
                      (default "Yes")
                      (help "SetPatch MUST appear as the first line of "
                            "the s:startup-sequence file.\n"
                            "For additional security, a copy of your original\n"
                            "startup-sequence will be made and will be stored "
			    "as\n"
                            "\"s:startup-sequence.backup\".")
             )
)

(if mods_ok
    (
        ; Make backup copy of s:startup-sequence safely...
        ; Do NOT check the return code---this may be an update, or
        ; s/he may already have a delete-protected backup copy.
        (run (cat
             "c:copy \""
             (tackon target "S/Startup-Sequence") "\" \""
             (tackon target "S/Startup-Sequence.Backup")
              "\" clone")
                   (prompt "Making backup copy of "
                           (tackon target "S/Startup-sequence") ".\n"
                           "It will be called '"
                           (tackon target "S/Startup-Sequence.Backup") "'.")
        )

        ; Protect recently made backup copy from re-installations.
        ; Works ONLY for Installer 1.9 or better
        (protect (cat (tackon target "s/Startup-Sequence.Backup") " -d"))

        ; Now patch the beginning of s:startup-sequence.  This requires V36.
        ; fsrc = run "gforce_060:utilities/fixstartup" "target:s/startup-sequence"
        ; BTW, fs_rc stands for FixStartup_ReturnCode...
        (set fs_rc (run (cat "\""
                   (tackon disklab2 "A4KT/68040/FixStartup") "\" \""
                   (tackon target "s/Startup-Sequence")
                   "\" NOREPEAT"
                   )))
        ; Check return code; this operation is vital to proper installation.
        (if (> fs_rc 5)
          (
            (message "WARNING:  there was a problem patching your "
                     "startup-sequence .  Please add the following "
                     "line at the beginning of your s:startup-sequence "
                     " file:\n\n"
                     "c:Setpatch >nil:\n")
          )
        )

        (onerror
            (message "Sorry, but either your startup-sequence is missing "
                     "or is too heavily modified for the Installer program "
                     "to understand and make the change.\n\n"
                     "Modifying the startup-sequence is the last step in "
                     "the A4000T-060 installation; all of the other "
                     "necessary files have been installed.  After "
                     "Installer exits, you must examine your "
                     "startup-sequence file and use a text editor to make "
                     "the following change:\n\n"
                     "<click Proceed for the next screen>")
            (message
                 "Make sure that the first line in the startup-sequence "
                 "is:\n\n"
                 "   c:SetPatch >nil:\n\n")
        )
    )
    ; else
    (
        (message "You will have to make the following change by hand:\n\n"
                 "The first line of your startup-sequence MUST read "
                 "as follows:\n\n"
                 "   c:setpatch >nil:\n\n")
    )
)
;****************************************************************************
; Install "Ksremap" at top of "startup-sequence"
;****************************************************************************
;(textfile (dest (tackon target "s/startup-sequence"))
;       (include (tackon disklab2 "tekmagic/68040/ksremap.script"))
;       (include (tackon target "s/startup-sequence"))
;       (prompt "Do you want to add \"KSREMAP\" to your startup-sequence? "
;	       "The command KSREMAP will enhance performance by remapping "
;	       "your KiskStart ROM to fast memory.")
;       (confirm)
;       (help   "This command will automatically copy the Kickstart "
;               "image into the 68060's extremely Fast RAM.  It will "
;	       "be MUCH faster than reading from ROM and Chip RAM, "
;	       "and will increase system performance greatly.\n"))
;
;****************************************************************************
; For automatic end-of-script message displaying the name of the place where
; the software was installed...
;****************************************************************************
( run "echo >envarc:68060.config fastrom")
        
(run (cat
             "c:copy \""
             (tackon disklab2 "Prefs/env-archive/68060.config") "\" \""
             (tackon target "prefs/env-archive")
              "\" clone"
     )

)


(set @default-dest target)
