; $VER: Installation script for WarpSDL 1.1 (18. Februari 2002)
; © Adam Waldenberg

; check if we are running under correct OS

(if (< (/ (getversion) 65536) 39)

    (
        (abort "Sorry, WarpSDL requires AmigaOS V39 or better!")
    )
)

(if (< (/ (getversion) 65536) 44)

    (
        (effect "center" "horizontal" $889999 $ffffff)
        ;(showmedia "pic" "Pictures/WarpSDL.jpg" "upper_center" "none" 0)
    )
)

; error handling

(onerror

    (if (> @ioerr 0)

        (
            (message
                ("An error occurred during installation.")
            )
        )
    )

    (exit (quiet))
)

(welcome
    "Welcome to the installation of WarpSDL, the SDL compatible "
    "media library for AmigaOS computers.\n\nCopyright © 2002 Adam Waldenberg."
)

    ; code follows.
    (copylib
        (prompt "Installing warpsdl.library.")
        (help "Will copy the main library to your LIBS: directory.")
        (confirm "average")
        (source "warpsdl.library")
        (dest "LIBS:")
            
        (optional
            "fail"
            "askuser"
        )
    )

    (set @default-dest (cat "LIBS:"))

    (makedir "ENV:WarpSDL")
    (makedir "ENVARC:WarpSDL")

    (COMPLETE 40)

    (set #globalstr
        (cat
            "(If you installed a previous version of WarpSDL it is fetched from "
            "your ENV: dir, otherwhise the recommended value is set.)"
        )
    )

    (set #globhelpstr
        (cat
            "On PPC the priority values are translated into NICE values by subtracting "
            "the priority with (priority*2) and then dividing it with 5. So setting "
            "the priority to 5, will give you a PPC task that has the nicevalue -1. "
            "Setting it to 100-128 will give you a PPC task with the nicevalue -20, "
            "and so on.\n\n"
            "Setting the DEF_MOTHERTASK_PRI higher than DEF_SUBTASK_PRI can result in "
            "sound that 'cuts' (if cpu consumption is at max).\n\n"
            "Setting the DEF_SUBTASK_PRI higher than DEF_MOTHERTASK_PRI can result in "
            "the game runing slower (if cpu consumption is at max), as the maintask won't "
            "get all the cpu power it might need.\n\n"
            "Recommended is to set both values the same or just use the defaults."
        )
    )

    (if (= (exists "ENV:warpsdl/DEF_MOTHERTASK_PRI") 0)
        (
            (set #envstr (cat "0"))
        )
        (
            (set #envstr
                (cat
                    (getenv
                        "warpsdl/DEF_MOTHERTASK_PRI"
                    )
                )
            )
        )
    )

    (set #result
        (askstring
            (prompt
                "What do you want to set the warpsdl/DEF_MOTHERTASK_PRI env-variable to? "
                #globalstr
            )

            (help
                "This is what the default priority of the main/mothertasks that use WarpSDL "
                "will be set to. Unless they override it, that priority will be used.\n\n"
                #globhelpstr
            )

            (default #envstr)
        )
    )

    (run "setenv ENV:WarpSDL/DEF_MOTHERTASK_PRI" #result)
    (run "copy ENV:WarpSDL/DEF_MOTHERTASK_PRI" "ENVARC:WarpSDL/DEF_MOTHERTASK_PRI")

    (COMPLETE 70)

    (if (= (exists "ENV:warpsdl/DEF_SUBTASK_PRI") 0)
        (
            (set #envstr (cat "5"))
        )
        (
            (set #envstr
                (cat
                    (getenv
                        "warpsdl/DEF_SUBTASK_PRI"
                    )
                )
            )
        )
    )

    (set #result
        (askstring
            (prompt "What do you want to set the warpsdl/DEF_SUBTASK_PRI env-variable to? "
                    #globalstr
            )

            (help
                "This is what the default priority of the subtasks that use WarpSDL "
                "will be set to. Unless they override it, that priority will be used.\n\n"
                #globhelpstr
            )

            (default #envstr)
        )
    )

    (run "setenv ENV:WarpSDL/DEF_SUBTASK_PRI" #result)
    (run "setenv ENVARC:WarpSDL/DEF_SUBTASK_PRI" #result)

    (COMPLETE 100)

(exit)
