;*****************************************************************************
;    ______        __                  ______                     __  __   __
;   / __  /       / /                 / __  /      Update        / /  \ \ / /
;  / /  -'__  __ / /___ ______ _____ / /_ -'_____ ______ ______ / /__  \ \ /
; / /     \ \/ // __  // ____// .__// // \ / .__// __  // __  // __  / /  /  V3
;/ /___    \  // /_/ // __/_ / /   / /_/ // /   / __  // /_/ // / / / / \ \
;\____/    / //_____//_____//_/   /_____//_/   /_/ /_// ____//_/ /_/ /_/ \_\
;         /_/                                        / /
;                                                   /_/
; CyberVision64/3D - CyberVision64
;
; CyberGraphX V3 BETA Update Installer ©1996,1997 by Robert C. Reiswig 
; $VER: V0.53 (April-13-1997)
; 
;--------------------------------------------------------------------------------
; You may not use any part of this installer without asking!
; Installer suggestions, problems or changes: vgr@best.com
;********************************************************************************

;********************************************************************************
; Cyber Release & Boards
;********************************************************************************
(set @user-level 2)
(set #cyberver "V3 41.2")
(set NoBoard 0)
(set whereback "SYS:Storage")
(message (cat "\nCyberGraphX " #cyberver "\n~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
              "\nCyberVision64/3D\n\nCyberVision64"
         )
)

(welcome)
;********************************************************************************
; Read All System information
;********************************************************************************
(set cpu (database "cpu")) (if (> (exists ("sys:libs/68060.library")) 0) (set cpu "68060") )
(set vblank (database "vblank")) (set graphmem (database "graphics-mem"))
(set totmem (database "total-mem")) (set osver (/ (getversion "LIBS:version.library") 65536))
(if (= vblank "60") ((set blank "NTSC")) ((set blank "PAL")))
(set fastmem (- totmem graphmem))
( if (= osver 37) ( (set workbench "2.0")) ( if (= osver 38) ( (set workbench "2.1"))
( if (= osver 39) ( (set workbench "3.0")) ( if (= osver 40) ( (set workbench "3.1"))
( if (= osver 41) ( (set workbench "3.2")) )))))
(set pick 0)

;********************************************************************************
;English Strings
;********************************************************************************
(set #By (cat "\n\nCyberGraphX\n\nRelease Version " #cyberver "\n\n\n\n"
              "by:\n\nVision Factory Development"
          
         )
)
(set #nobackup "\n\nThis installer will copy the correct new V3 Libs and Monitor to the correct places. It will not do any backup while V3 is in beta.\n\nThis will not install V3 for the first time, it just updates V3. A V2->V3 updater is comming soon.")
(set #askzorro "\nWhat type of machine is CyberGraphX V3 installed on?\n")
(set #askcpu "\nWhat CPU does the machine have that you are updating CyberGraphX V3 on? The installer has found:\n")
(set #wherelibs "Where are your CyberGraphX V3 libraries located? The default is 'SYS:Libs'")
(set #whatboard (cat "\nPlease Select the Graphics Board you wish to update CyberGraphX Monitor File for:\n"))
(set #todo-prompt "\nDo you wish to install:\n")
(set #cgxmode-todo " CGXMode - Create & Change Screen Modes")
(set #wheremode "Where do you wish to copy the CGXMode Program?")

;********************************************************************************
;German Strings
;********************************************************************************
(if (= @language "deutsch")
 (

 (set #what "f")

 )
)

;********************************************************************************
; Start Update
;********************************************************************************
;(message #by)
(message #nobackup)


;********************************************************************
; Double Check on the CPU
;********************************************************************
(set cpu (database "cpu"))
(if (= cpu 68000) (set #cpu 0)) (if (= cpu 68010) (set #cpu 0))
(if (= cpu 68020) (set #cpu 0)) (if (= cpu 68030) (set #cpu 0))
(if (= cpu 68040) (set #cpu 1)) (if (= cpu 68006) (set #cpu 1)) 
(if (= @installer-version 0)
  (if (> (exists ("sys:libs/68060.library")) 0) (set #cpu 1) )
  (if (= cpu 68006) (set #cpu 1))
)

(set cpuPick (askchoice (choices "68020 or 68030" "68040 or 68060")
			(prompt #askcpu)
	                (help   #askcpu)
          		(default #cpu)
	  )
)

(if (= cpuPick 0) (set cpuadd ".020")) (if (= cpuPick 1) (set cpuadd ".040"))

;*******************************************************************
;  ASK where cybergfx libs are
;*******************************************************************
(set wherelibs   (askdir (prompt #wherelibs)
			 (help   #wherelibs)
 		         (default "SYS:Libs")
		 )
)

;*******************************************************************
;  Copy libs if there
;*******************************************************************
(if (exists (tackon "cgxsystemlib" (cat "cgxsystem.library" cpuadd)) )
  (copyfiles (source (tackon "cgxsystemlib" (cat "cgxsystem.library" cpuadd))) (dest wherelibs) (newname "cgxsystem.library") (optional "nofail") ) 
)

(if (exists (tackon "cgxmpeglib" (cat "cgxmpeg.library" cpuadd)) )
  (copyfiles (source (tackon "cgxmpeglib" (cat "cgxmpeg.library" cpuadd))) (dest wherelibs) (newname "cgxmpeg.library") (optional "nofail") ) 
)


(if (exists (tackon "cgxbootpiclib" (cat "cgxbootpic.library" cpuadd)) )
  (copyfiles (source (tackon "cgxbootpiclib" (cat "cgxbootpic.library" cpuadd))) (dest wherelibs) (newname "cgxbootpic.library") (optional "nofail") ) 

  (if (exists "cgxbootpiclib/cgxbootpic.library")
    (copyfiles (source "cgxbootpiclib/cgxbootpic.library") (dest wherelibs) (optional "nofail") ) 
  )

)

;*******************************************************************
;  ASK what board to update
;*******************************************************************
(set BGuess 0)

(if (> (exists ("devs:monitors/CVision3D")) 0)  (set BGuess (+ BGuess 1)) )
(if (> (exists ("devs:monitors/CVision64")) 0)  (set BGuess (+ BGuess 2)) )



  (set board (askoptions (choices  "CyberVision64/3D" "CyberVision64"
                          (prompt #whatboard)
	                  (help #whatboard)
                          (default BGuess)
                         )
             )     
  )


  (if (IN board 0)
   (
     (set error (run "tools/ChkCV3DZorro"))
     (if (> error 0) (set guessZ 1) (set guessZ 0) )
  
     (set pickZ (askchoice (choices "zorro2 - Amiga 2000/zorro2 Expansion Box" "zorro3 - Amiga 3000(T)/4000(T)")
	                   (prompt #askzorro)
	                   (help   #askzorro)
                           (default guessZ)
                )
     )
  
     (if (= pickZ 0) (set zadd ".Z2"))   (if (= pickZ 1) (set zadd ".Z3")) 

     (if (exists (tackon "CV3DDriver" (cat "CVision3D" zadd)))
      (if (= (exists (tackon "devs:monitors" "CVision3D.info")) 0)      
       (copyfiles (source (tackon "CV3DDriver" (cat "CVision3D" zadd))) (dest "devs:monitors") (newname "CVision3D") (infos) (optional "nofail") ) 
       (copyfiles (source (tackon "CV3DDriver" (cat "CVision3D" zadd))) (dest "devs:monitors") (newname "CVision3D") (optional "nofail") ) 
      )      
     )

     (if (exists (tackon "cgxvideolib" (cat "cgxvideo.library" cpuadd)) )
       (copyfiles (source (tackon "cgxvideolib" (cat "cgxvideo.library" cpuadd))) (dest wherelibs) (newname "cgxvideo.library") (optional "nofail") ) 
     )

     (if (exists (tackon "cgx3dvirgelib" (cat "cgx3dvirgin.library" cpuadd)) )
       (copyfiles (source (tackon "cgx3dvirgelib" (cat "cgx3dvirgin.library" cpuadd))) (dest wherelibs) (newname "cgx3dvirgin.library") (optional "nofail") ) 
     )

   )
  )


  (if (AND (exists (tackon "CV64Driver" "CVision64")) (IN board 1) )
   (if (= (exists (tackon "devs:monitors" "CVision64.info")) 0)  
    (copyfiles (source (tackon "CV64Driver" "CVision64")) (dest "devs:monitors") (newname "CVision64") (infos) (optional "nofail") ) 
    (copyfiles (source (tackon "CV64Driver" "CVision64")) (dest "devs:monitors") (newname "CVision64") (optional "nofail") ) 
   )
  )


;*********************************************************************************
;* Ask user to install CGXMode 
;*********************************************************************************
(set ToDo (askoptions (choices #cgxmode-todo)
                      (prompt #todo-prompt)
                      (help #todo-prompt)
                      (default 1)
          )
) 

(if (IN ToDo 0) 
  ( 
    (set wheremode   (askdir (prompt #wheremode)
                             (help   #wheremode)
	                     (default "SYS:Prefs")
		     )
    )

    (if (exists "CGXMode/CGXMode")
     (if (= (exists (tackon wheremode "CGXMode.info")) 0)
      (copyfiles (source "CGXMode/CGXMode")  (dest wheremode) (infos) (optional "nofail")) 
      (copyfiles (source "CGXMode/CGXMode")  (dest wheremode) (optional "nofail"))          
     )
    )


    (if (IN board 1) (set TTBOARD "CVision64") )    (if (IN board 0) (set TTBOARD "CVision3D") )
    (if (> board 0)
      (tooltype	(dest (tackon wheremode "CGXMode")) (settooltype "BOARD" TTBOARD) ) 
    )

    (if (= @language "deutsch")
     (
       (if (= (exists "Locale:Catalogs") 0) (makedir "sys:Locale/Catalogs") )
       (if (= (exists (tackon "Locale:Catalogs" "deutsch")) 0) (makedir (tackon "sys:Locale/Catalogs" "deutsch")) )
       (if (exists "CGXMode/catalogs/deutsch/cgxmode.catalog")
         (copyfiles (source "CGXMode/catalogs/deutsch/cgxmode.catalog") (dest "sys:Locale/Catalogs/deutsch") )
       )
     )
    )

  )
)

;*******************************************************************
;  END
;*******************************************************************
(if (> (exists ("c:multiview")) 0) (set #mpath "c:") )
(if (> (exists ("sys:Utilities/multiview")) 0) (set #mpath "sys:Utilities") )

(run (cat "run " #mpath "/multiview Changes.txt") )

(set @default-dest "sys:")

(set #done "Update Complete!")
(if (= @language "deutsch") (set #done "Update fertig!") )

(exit #done)
