; SAGADrivers
; $VER: SAGADrivers 2.1 (02.06.2020)

(complete 0)
(set @app-name "SAGADrivers")
(set @default-dest "RAM:")
; Welcome message...
(welcome "Welcome to the SAGA Drivers Package installer. This installer will guide you through the required steps to install drivers for your Vampire product.")

(complete 4)
; Copy most files
(copyfiles
  (prompt "We will now start by copying some files.")
  (help @copyfiles-help)
  (confirm "expert")
  (source "")
  (dest "C:")
  (choices "C/")
)
(copyfiles
  (prompt "We will now start by copying some files.")
  (help @copyfiles-help)
  (confirm "expert")
  (source "")
  (dest "DEVS:Keymaps")
  (choices "Devs/Keymaps/")
)
(copyfiles
  (prompt "We will now start by copying some files.")
  (help @copyfiles-help)
  (confirm "expert")
  (source "")
  (dest "DEVS:Monitors")
  (choices "Devs/Monitors/")
)
(copyfiles
  (prompt "We will now start by copying some files.")
  (help @copyfiles-help)
  (confirm "expert")
  (source "")
  (dest "DEVS:Networks")
  (choices "Devs/Networks/")
)
(copyfiles
  (prompt "We will now start by copying some files.")
  (help @copyfiles-help)
  (confirm "expert")
  (source "")
  (dest "DEVS:")
  (choices "Devs/sagasd.device")
)
(copyfiles
  (prompt "We will now start by copying some files.")
  (help @copyfiles-help)
  (confirm "expert")
  (source "")
  (dest "ENVARC:")
  (choices "ENVARC/")
)
(copyfiles
  (prompt "We will now start by copying some files.")
  (help @copyfiles-help)
  (confirm "expert")
  (source "")
  (dest "L:")
  (choices "L/")
)
(copyfiles
  (prompt "We will now start by copying some files.")
  (help @copyfiles-help)
  (confirm "expert")
  (source "")
  (dest "LIBS:")
  (choices "Libs/i2c.library")
)
(copyfiles
  (prompt "We will now start by copying some files.")
  (help @copyfiles-help)
  (confirm "expert")
  (source "")
  (dest "SYS:Storage")
  (choices "Storage/")
)
(copyfiles
  (prompt "We will now start by copying some files.")
  (help @copyfiles-help)
  (confirm "expert")
  (source "")
  (dest "SYS:System")
  (choices "System/")
)

(complete 7)
; Check for existence of old SAGA monitor file
(set #OLDSAGA
  (exists "DEVS:Monitors/SAGA" (noreq))
)

(complete 11)
; If yes, set OLDSAGA to 1
(if (= #OLDSAGA 1)
(

(complete 15)
; and move it to Storage
(rename "DEVS:Monitors/SAGA" "SYS:Storage/Monitors/SAGA"
  (prompt "")
  (help )
)

)
) ; End If
(complete 19)
; Check for for existence of old SAGA monitor icon file
(set #OLDSAGAICON
  (exists "DEVS:Monitors/SAGA.info" (noreq))
)

(complete 22)
; If yes, set OLDSAGAICON to 1
(if (= #OLDSAGAICON 1)
(

(complete 26)
; and move it to Storage
(rename "DEVS:Monitors/SAGA.info" "SYS:Storage/Monitors/SAGA.info"
  (prompt "")
  (help )
)

)
) ; End If
(complete 30)
; Check for existence of old saga.card
(set #SAGACARD
  (exists "LIBS:Picasso96/saga.card" (noreq))
)

(complete 33)
; If yes, set SAGACARD to 1
(if (= #SAGACARD 1)
(

(complete 37)
; and rename it to saga.card_old
(rename "LIBS:Picasso96/saga.card" "LIBS:Picasso96/saga.card_old"
  (prompt "")
  (help )
)

)
) ; End If
(complete 41)
; Ask user to choose between cores
(set GOLD21x
  (askchoice
    (prompt "Choose driver version")
    (help @askchoice-help)
    (choices "V4 Standalone, GOLD2.12 or newer" "GOLD2.11 or earlier (deprecated)")
    (default 0)
  )
)
(if (= GOLD21x 0) (set #GOLD212 1) (set #GOLD212 0))
(if (= GOLD21x 1) (set #GOLD211 1) (set #GOLD211 0))

(complete 44)
; If user select GOLD2.12 or newer
(if (= #GOLD212 1)
(

(complete 48)
; Copy last driver
(copylib
  (source "Libs/Picasso96/vampiregfx.card")
  (dest "LIBS:Picasso96/")
  (prompt "Copying Libs/Picasso96/vampiregfx.card")
  (help @copylib-help)
)

(complete 52)
; Otherwise...
) ; Else
(

(complete 56)
; Copy G2.11 driver
(copylib
  (source "Libs/Picasso96/vampiregfx.card_gold211")
  (dest "LIBS:Picasso96/")
  (prompt "Copying Libs/Picasso96/vampiregfx.card_gold211")
  (help @copylib-help)
)

; Rename old driver
(rename "LIBS:Picasso96/vampiregfx.card" "LIBS:Picasso96/vampiregfx.card_old"
  (prompt "")
  (help )
)

(complete 59)
; And finally rename
(rename "LIBS:Picasso96/vampiregfx.card_gold211" "LIBS:Picasso96/vampiregfx.card"
  (prompt "")
  (help )
)

)
) ; End If
(complete 63)
; Check for Picasso96Settings existence...
(set #P96FILE
  (exists "DEVS:Picasso96Settings" (noreq))
)

(complete 67)
; If yes, set P96FILE to 1
(if (= #P96FILE 1)
(

(complete 70)
; Rename old file to _old
(rename "DEVS:Picasso96Settings" "DEVS:Picasso96Settings_old"
  (prompt "")
  (help )
)

)
) ; End If
(complete 74)
; Ask user if V2 or V4
(set WHICHP96
  (askchoice
    (prompt "To install set of available screenmodes, please select target Vampire system.")
    (help @askchoice-help)
    (choices "Vampire V4 Standalone" "Vampire V2 family")
    (default 0)
  )
)
(if (= WHICHP96 0) (set #V4 1) (set #V4 0))
(if (= WHICHP96 1) (set #V2 1) (set #V2 0))

(complete 78)
; If user selects V4 as system
(if (= #V4 1)
(

(complete 81)
; Copy V4 P96Settings
(copyfiles
  (prompt "")
  (help @copyfiles-help)
  (source "")
  (dest "DEVS:")
  (choices "Devs/Picasso96Settings.V4")
)

(complete 85)
; And finally rename
(rename "DEVS:Picasso96Settings.V4" "DEVS:Picasso96Settings"
  (prompt "")
  (help )
)

)
) ; End If
(complete 89)
; If user selects V2 as system
(if (= #V2 1)
(

(complete 93)
; Copy V2 P96 Settings
(copyfiles
  (prompt "")
  (help @copyfiles-help)
  (source "")
  (dest "DEVS:")
  (choices "Devs/Picasso96Settings.V2")
)

(complete 96)
; And finally rename
(rename "DEVS:Picasso96Settings.V2" "DEVS:Picasso96Settings"
  (prompt "")
  (help )
)

(complete 59)
; Tadaaa
(exit)

)
) ; End If
