; $VER DC-Install V1.0

(set DrawerNameParent @default-dest)

(complete 0)
(if (exists "DC:" (NOREQ))
    (
        (set vernum (getversion "DC:DiamondCaves"))

        (set ver (/ vernum 65536))
        (set rev (- vernum (* ver 65536)))

        (set version (+ (* 100 ver) rev))

        (if (> version 100)
            (
                (message "You have already installed a version >1.0!\n")
                (exit (quiet))
            )
            (set DrawerNameParent "DC:")
        )
    )
)


(set DrawerNameParent
     (askdir
         (prompt "In which drawer should Diamond Caves V1.0 be installed?\n(A directory called Diamond Caves will be created)")
         (help @askdir-help)
         (default DrawerNameParent)
     )
)

(set DrawerName DrawerNameParent)

(set DrawerName (tackon DrawerName "DiamondCaves"))

(complete 10)
(makedir DrawerName
    (prompt "I will now create the directory \"" DrawerName "\".")
    (help @makedir-help)
    (infos)
    (confirm)
)


(complete 20)
(copyfiles
    (prompt "Copying necessary files to \"" DrawerName "\".")
    (help @copyfiles-help)
    (source "DiamondCaves")
    (dest DrawerName)
    (all)
    (infos)
    (confirm)
)

(complete 30)
(copyfiles
    (prompt "Copying necessary files to \"" DrawerNameParent "\".")
    (help @copyfiles-help)
    (source "DiamondCaves.info")
    (dest DrawerNameParent)
    (files)
    (infos)
)

(complete 40)
(startup "Diamond Caves"
    (prompt "An assign to \"DC:\" will be added to \"S:user-startup\" so that your system will be properly configured to use Diamond Caves.")
    (help "Sorry, no help-file.")
    (command "assign DC: " DrawerName)
)
(makeassign "DC")
(makeassign "DC" DrawerName)


(complete 50)
(if ((database "vblank") 50)
    (set DefaultMode 0)
    (set DefaultMode 2)
)
(set ScreenModeNum
    (askchoice
        (prompt "Which screenmode do you want the title screen of Dimaond Caves to use?\n(Note that the title was designed to be used on an interlaced screenmode)")
        (choices "PAL:HighRes" "PAL:HighRes Interlace" "NTSC:HighRes" "NTSC:HighRes Interlace")
        (help "Soory, no help-file.")
        (default DefaultMode)
    )
)
(if (= ScreenModeNum 0)
    (set ScreenMode "PAL")
)
(if (= ScreenModeNum 1)
    (set ScreenMode "PAL-LACE")
)
(if (= ScreenModeNum 2)
    (set ScreenMode "NTSC")
)
(if (= ScreenModeNum 3)
    (set ScreenMode "NTSC-LACE")
)
(tooltype 
    (prompt "I will now change the tooltype TITLEMODE to " ScreenMode ".")
    (help "Soory, no help-file.")
    (dest "DC:DiamondCaves")
    (settooltype "TITLEMODE" ScreenMode)
    (confirm)
)


(complete 60)
(set ScreenModeNum
    (askchoice
        (prompt "Which screenmode do you want the game to use?\n(Note that you should only use interlace if you have a 17\" monitor)")
        (choices "PAL:LowRes" "PAL:HighRes Interlace" "NTSC:LowRes" "NTSC:HighRes Interlace")
        (help "Soory, no help-file.")
        (default DefaultMode)
    )
)
(if (= ScreenModeNum 0)
    (set ScreenMode "PAL")
)
(if (= ScreenModeNum 1)
    (set ScreenMode "PAL-LACE")
)
(if (= ScreenModeNum 2)
    (set ScreenMode "NTSC")
)
(if (= ScreenModeNum 3)
    (set ScreenMode "NTSC-LACE")
)
(tooltype 
    (prompt "I will now change the tooltype GAMEMODE to " ScreenMode ".")
    (help "Soory, no help-file.")
    (dest "DC:DiamondCaves")
    (settooltype "GAMEMODE" ScreenMode)
    (noposition)
    (confirm)
)


(complete 70)
(set ControlNum
    (askchoice
        (prompt "Which controlling device do you want Player 1 to use?\n")
        (choices "Joystick Port 1" "Joystick Port 2" "Keyboard")
        (help "Soory, no help-file.")
        (default 1)
    )
)
(if (= ControlNum 0)
    (set ControlMode "JOY1")
)
(if (= ControlNum 1)
    (set ControlMode "JOY2")
)
(if (= ControlNum 2)
    (set ControlMode "KEYS")
)
(tooltype 
    (prompt "I will now change the tooltype PLAYER1 to " ControlMode ".")
    (help "Soory, no help-file.")
    (dest "DC:DiamondCaves")
    (settooltype "PLAYER1" ControlMode)
    (noposition)
    (confirm)
)


(complete 80)
(set ControlNum
    (askchoice
        (prompt "Which controlling device do you want Player 2 to use?\n")
        (choices "Joystick Port 1" "Joystick Port 2" "Keyboard")
        (help "Soory, no help-file.")
        (default 0)
    )
)
(if (= ControlNum 0)
    (set ControlMode "JOY1")
)
(if (= ControlNum 1)
    (set ControlMode "JOY2")
)
(if (= ControlNum 2)
    (set ControlMode "KEYS")
)
(tooltype 
    (prompt "I will now change the tooltype PLAYER2 to " ControlMode ".")
    (help "Soory, no help-file.")
    (dest "DC:DiamondCaves")
    (settooltype "PLAYER2" ControlMode)
    (noposition)
    (confirm)
)

(complete 90)
(if (askbool
        (prompt "Do you want to use the gameport.device instead of accessing the hardware directly?\n(This is slower but OS-friendly)")
        (help "Soory, no help-file.")
        (default 0)
    )
    (set GamePort "ON")
    (set GamePort "OFF")
)
(tooltype 
    (prompt "I will now change the tooltype GAMEPORTDEVICE to " GamePort ".")
    (help "Soory, no help-file.")
    (dest "DC:DiamondCaves")
    (settooltype "GAMEPORTDEVICE" GamePort)
    (noposition)
    (confirm)
)


(complete 100)

(message "\nDimaond Caves installation complete,please make sure to read at least the first chapter of the doc-file.\n\nAnd now enjoy Diamond Caves!")

(exit (quiet))
