; Install_ProStationAudio
; $VER: 2.2
; by Floyd Diebel/EMRL for Maurizio Ciccione/AudioLabs.
;
; History
;
; v2.2  [04Feb00]
;       * Added the 'ULTRA' option for the CMEM tooltype.
;
; v2.1  [21Dec99]
;       * Added on screen help at all stages of configuration
;
; v2.0  [20Dec99]
;       * Now installs documentation by default
;       * Uses new features for new v44.10 Installer
;       * Added configuration for HTML documentation for user's browser
;
; v1.6  [08Nov99]
;       * Added option for the AHIInOut and SoundStageOut
;
; v1.5  [19Oct99]
;       * Changed some of the installer text to fix a problem with Topaz/8
;
; v1.41 [17Oct99]
;       * Added a bunch of functionality via InstallerFX
;       * Added music.  Plays if AHI's AUDIO: device is found
;
; v1.4  [16Oct99]
;       * Removed all hard-coded paths
;       * Added check for ppc.library
;       * Added chack for PSA version number
;       * Added check for total available memory
;       * Added more thorough comments
;
; v1.3  [10Oct99]
;       * Added HTML/GUIDE installation options
;       * Cleaned up some cosmetics
;       * Added icons for certain items/drawers
;       * Fixed CGFX_DEPTH options
;       * Added DRIVER_PRI option
;
; v1.2 [06Oct99]
;       * Tweaked a few things, minor
;
; v1.1 [12Aug99]
;       * Fixed DUAL_MONITOR tooltype
;
; v1.0 [06Jul99]
;       * First release, for Amiwest99
;
;
; Begin setup
;
; In case of error, execute ERROR sub

(onerror
    (cleanup)
    )

; Here the exit-on-error process is defined

(procedure cleanup
;            (closemedia splash)
;            (closemedia txt)
            (run "status >RAM:theme command=copy")
            (run "break <ram:theme >NIL: ?")
    )

; Learn about this machine, and set some variables

(set cpu (database "cpu"))
(set mem (database "total-mem"))
(set #language (getenv "Language"))
(set #wbversion 0)
(set #wbversion (getversion "libs:version.library"))
(set #wbversion (/ #wbversion 65536))

; Set some Installer Options

(effect "lower_right" "horizontal" $000000 $000000)

; Find out about PowerPC

(if (exists "sys:libs/ppc.library") (set ppcexists 1) )
(set ppcraw (getversion "LIBS:ppc.library"))
                (set ppcprefix (/ ppcraw 65536))
                (set ppcsuffix (- ppcraw (* ppcprefix 65536)))
                (set ppcversion (cat ppcprefix "." ppcsuffix)
        )

; Determine PSA's version number.

(set raw (getversion "PSA_Archives/app/ProStationAudio/ProStationaudio"))
                (set prefix (/ raw 65536))
                (set suffix (- raw (* prefix 65536)))
                (set version (cat prefix "." suffix)
        )

; Look for the AHI AUDIO: device driver.  If found, pipe theme music to it.

(if (exists "sys:devs/dosdrivers/AUDIO") (run "run >NIL: copy  misc/theme.aiff audio:") )

; Display first splash screen

(showmedia 'splash' "misc/PSA1.iff" 'upper_left' 'none' 0)

; Set the various prompt texts

(set #bad-installer ("You need at least Installer v42.9.  Check your  ProstationAudio distribution ")
            )

(set #bad-kick (cat "You need at least kickstart 38 to install ProStationAudio.")
            )

(set #location (cat "\nWhere do you want to install ProStationAudio? "
                "\n"
                "A drawer called 'ProStationAudio' will be created there."
                "\n")
            )

(set #audio (cat "Select Audio Driver"
                "\n\n"
                "Select the audio driver that corresponds with the hardware in your system. "
                "\n")
            )

(set #dma (cat  "Use Fast DMA?"
                "\n\n"
                "This option is only valid when using the SoftMary driver for "
                "the built-in Amiga audio (Paula). "
                "\n")

            )

(set #powerupyes (cat "Use PowerPC?"
                "\n\n"
                "ProStationAudio can take advantage of the Motorola PowerPC "
                "CPU present in this system."
                "\n\n"
                "Make sure you have ppc.library v46.0 or higher installed.  "
                "This machine currently has v"ppcversion" installed."
                "\n")
            )

(set #powerupno (cat "Use PowerPC?"
                "\n\n"
                "ProStationAudio can take advantage of the Motorola PowerPC "
                "CPU if present in your system, but this system does not appear "
                "to have the ppc.library installed."
                "\n")
            )

(set #vmm (cat "Virtual Memory Configuration"
                "\n\n"
                "This setting controls the amount of memory allocated to the "
                "virtual memory manager, and influences the amount of tracks that can be "
                "played in realtime.  "
                "There are currently "mem" bytes free on this machine."
                "\n")
            )

(set #dual (cat "Use Dual Monitors?"
                "\n\n"
                "Would you like ProStationAudio to open on dual monitors? "
                "You'll need two graphics cards, or one card and the onboard "
                "chipset. "
                "\n")
            )

(set #graph (cat "Optimize for Graphics Cards?"
                "\n\n"
                "This setting optimizes PSA for use with graphics cards.  "
                "DO NOT enable this setting if you do not "
                "have a graphics board. "
                "\n")
            )

(set #scr (cat "Show Screen Selector?"
                "\n\n"
                "Would you like ProStationAudio to open a screen selector "
                "at startup?  "
                "PSA supports drivers for every OS compliant retargetable "
                "graphic system."
                "\n")
            )

(set #wgfx (cat "Enable High-Resolution Waveform Graphics?"
                "\n\n"
                "Would you like ProStationAudio to save detailed waveform "
                "graphics inside AudioLabs Support Files?  "
                "Recommended for all systems."
                "\n")
            )

(set #back (cat "Enable Backdrop?"
                "\n\n"
                "This setting can enable/disable the use of PSA's decorative "
                "screen backdrop. "
                "\n")
            )

(set #pri (cat "Set Task Priority"
                "\n\n"
                "What should ProStationAudio's Task Priority be? "
                "\n")
            )

(set #cmem (cat "Set ProStationAudio's Allocated Memory"
                "\n\n"
                "This setting influences the maximum size allowed for a session "
                "to be played or mixed to disc.  It doesn't influence the size of "
                "the session itself, you can add as many objects as your free "
                "memory permits."
                "\n")
            )

; Begin the actual install.  First, look for Workbench.2.1 or higher

(if (< (/ (getversion) 65536) 38)
        ( (abort #bad-kick)
                )
        )

; Display first message, ask for path.

(message "\n\n\nWelcome to the ProStationAudio v"version" Installation Utility.\n\n"
                "This utility will install ProStationAudio, related HTML documentation, "
                "and configure PSA for optimum performance on your system. "
                "\n\n"
                "PSA will require about 1.5 megs of hard disk space."
                )

(if (< @installer-version 2752521)
        ( (abort #bad-installer)
                )
        )

(showmedia 'license' "misc/License.GUIDE" 'upper_right' 'medium' 1 'wordwrap')

(complete 0)
(message "\n\n\nPlease read the END USER LICENSE AGREEMENT [EULA] carefully before "
                "proceeding.  Clicking on \"Proceed\" assumes you agree to abide by the "
                "EULA."
                )

(closemedia license)

(set target (askdir (prompt #location)
                (help @set)
                (default "Work:")
                )
        )


(makeassign "PSA_INSTALL" target
        )

(copyfiles
        (prompt "Installing ProStationAudio." )
        (help @copyfiles-help)
        (source "")
        (dest (cat "PSA_INSTALL:") )
        (choices "PSA_Archives/app/")

)

(closemedia splash)(showmedia 'splash' "misc/PSA2.iff" 'upper_left' 'none' 0)

; Change documentation's default tools to reflect this user's system.

(set browser (askfile (prompt "Where is your HTML browser located?"
                        "\n\nThis will configure ProStationAudio's HTML documentation for your system. "
                        "\n"
                 (help "Set this to point to your favorite browser, so that ProStationAudio's "
                        "documentation can be configured accordingly.")
                        (default "Browser_Name")
                 )
         )
)

(tooltype (dest "PSA_INSTALL:ProStationAudio/Documentation/Reference_Manual") (setdefaulttool browser ) )
(tooltype (dest "PSA_INSTALL:ProStationAudio/Documentation/User_Manual") (setdefaulttool browser ) )

; Begin configuration.

(message "\n\n\nNow it's time to configure ProStationAudio..\n\n"
                "To help you choose the best options for your system, Detailed help will be displayed in the upper right "
                "of your screen.")

(showmedia 'txt' "misc/AUDIO.GUIDE" 'upper_right' 'medium' 1 'wordwrap')
(set audio (askchoice (choices  "DelfinInOut"
                                "DelfinaOut"
                                "PreludeOut"
                                "ToccataOut"
                                "MaestroOut"
                                "SoundStageOut"
                                "AHIInOut"
                                "SoftMary (Paula)"
                        (prompt #audio)
                        (help   "ProStationAudio supports a number of Amiga soundcards with external drivers.  "
                                "These drivers are available from http://www.audiolabs.it/files, and should be "
                                "installed in the 'Drivers' drawer in PSA's root directory. "
                                "\n\n"
                                "Available drivers include the following : "
                                "\n\n"
                                "SoftMary  -  for the Amiga's built-in audio.  This driver is internal to PSA, meaning no "
                                "external files are needed."
                                "\n\n"
                                "DelfinaInOut  -  for Petsoff's Delfina Classic, Lite, or Plus.  This is a "
                                "record/playback driver."
                                "\n\n"
                                "DelfinaOut  -  for Petsoff's Delfina Classic, Lite, or Plus.  This is a playback driver. "
                                "\n\n"
                                "PreludeOut  -  for ACT's Prelude.  This is a playback driver."
                                "\n\n"
                                "ToccataOut  -  for MacroSystem's Toccata.  This is a playback driver.  "
                                "Use this driver if you have a Draco Workstation."
                                "\n\n"
                                "MaestroOut  -  for MacroSystem's Maestro.  This is a playback driver."
                                "\n\n"
                                "SoundStageOut - for Applied Magic's SoundStage card.  This is a playback driver."
                                "\n\n"
                                "AHIInOut - for the AHI system.  Allows PSA to use any supported audio hardware."
                                "\n\n")
                        )
                )
        )


(tooltype       (dest "PSA_INSTALL:ProStationAudio/ProStationAudio")
                        (if (= audio 0) (settooltype "OUT_DRIVER" "DelfinaOut") )
                        (if (= audio 1) (settooltype "OUT_DRIVER" "DelfinaOut") )
                        (if (= audio 2) (settooltype "OUT_DRIVER" "PreludeOut") )
                        (if (= audio 3) (settooltype "OUT_DRIVER" "ToccataOut") )
                        (if (= audio 4) (settooltype "OUT_DRIVER" "MaestroOut") )
                        (if (= audio 5) (settooltype "OUT_DRIVER" "SoundStageOut") )
                        (if (= audio 6) (settooltype "OUT_DRIVER" "AHIOut") )
                        (if (= audio 7) (settooltype "OUT_DRIVER" )
                )
        )

(copyfiles      
        (dest (cat "PSA_INSTALL:ProStationAudio/Drivers" ) )
                        (if (= audio 0) (source "PSA_Archives/drivers/DelfinaInOut" ) )
                        (if (= audio 1) (source "PSA_Archives/drivers/DelfinaOut" ) )
                        (if (= audio 2) (source "PSA_Archives/drivers/PreludeOut" ) )
                        (if (= audio 3) (source "PSA_Archives/drivers/ToccataOut" ) )
                        (if (= audio 4) (source "PSA_Archives/drivers/MaestroOut" ) )
                        (if (= audio 5) (source "PSA_Archives/drivers/SoundStageOut" ) )
                        (if (= audio 6) (source "PSA_Archives/drivers/AHIInOut" ) )
                        (if (= audio 7) (source "PSA_Archives/drivers/null" )
                )

        )

(closemedia txt)(showmedia 'txt' "misc/DMA.GUIDE" 'upper_right' 'medium' 1 'wordwrap')
(set dma (askchoice (choices     "Disable Fast DMA"
                                   "Enable Fast DMA"
                        (prompt #dma)
                        (help "Enabling Fast DMA will give better results when using the SoftMary driver."
                        "\n\n"
                        "Note that a 31khz screen driver is REQUIRED for using this feature.  "
                        "Do not enable this feature if using an "
                        "external audio driver.")
                        )
                )
        )

(tooltype       (dest "PSA_INSTALL:ProStationAudio/ProStationAudio")
                        (if (= dma 0) (settooltype "PAULAFASTDMA" ) )
                        (if (= dma 1) (settooltype "PAULAFASTDMA" "" )

                )
        )


(closemedia splash)(showmedia 'splash' "misc/PSA3.iff" 'upper_left' 'none' 0)

(closemedia txt)(showmedia 'txt' "misc/PPC.GUIDE" 'upper_right' 'medium' 1 'wordwrap')
(if (= ppcexists "1")
(set ppc (askchoice (choices    "Disable PowerPC Code"
                                "Enable PowerPC Code"
                        (prompt #powerupyes)                       
                        (help "Pretty self-explanatory.  If you have a PPC processor, enable this feature, "
                        "as it will give you smoother operation and more efficient track playback.")
                )
        )
)
)
(if (= ppcexists "0")
(set ppc (askchoice (choices    "Disable PowerPC Code"
                                "Enable PowerPC Code"
                        (prompt #powerupno)
                        (help "Pretty self-explanatory.  If you have a PPC processor, enable this feature, "
                        "as it will give you smoother operation and more efficient track playback.")
                 )
         )
)
)


(tooltype       (dest "PSA_INSTALL:ProStationAudio/ProStationAudio")
                        (if (= ppc 0) (settooltype "USE_PPC_POWERUP" ) )
                        (if (= ppc 1) (settooltype "USE_PPC_POWERUP" "" )

        )
)

(closemedia txt)(showmedia 'txt' "misc/VMM.GUIDE" 'upper_right' 'medium' 1 'wordwrap')
(set vmm (askchoice (choices    "Small (16mb Systems)"
                                "Medium (32mb Systems)"
                                "Large (64mb+ Systems)"
                        (prompt #vmm)
                        (help "Use this feature to control the amount of memory allocated to PSA's "
                        "virtual memory manager.  This setting influences the amount of tracks that can "
                        "be played in realtime.  Increasing the amount of memory allocated allows to handle "
                        "more tracks at once but also increases the delay between the instant "
                        "you issue the PLAY command and the time the system actually starts playing."
                        "\n\n"
                        "With the maximum setting, the VMM consumes 16MB RAM.")
                )
        )
)


(tooltype       (dest "PSA_INSTALL:ProStationAudio/ProStationAudio")
                        (if (= vmm 0) (settooltype "VMM_BUFFERS" "SMALL") )
                        (if (= vmm 1) (settooltype "VMM_BUFFERS" "MEDIUM") )
                        (if (= vmm 2) (settooltype "VMM_BUFFERS" "LARGE")

        )
)

(closemedia txt)(showmedia 'txt' "misc/Dual.GUIDE" 'upper_right' 'medium' 1 'wordwrap')
(set dual (askchoice (choices    "Disable Dual Monitors"
                                 "Enable Dual Monitors"
                        (prompt #dual)
                        (help  "Enable this feature if you want PSA to open on two monitors at once. "
                               "The Timeline and Transport controls will open on one screen, and the Mixer "
                               "Console and Plugins will open on the second screen."
                               "\n\n"
                               "You'll need two graphic cards, or just one card and the onboard chipset.  "
                               "When using the dual monitor option, PSA will try to close the Workbench in "
                               "order to make screen swapping more comfortable."
                               "\n\n"
                               "NOTE: AmigaOS v3.1 or earlier has a bug that prevents the Workbench from opening "
                               "after it gets closed.  You'll need to install a patch if enabling PSA's dual monitor "
                               "feature to fix this.  One is available with the NewIcons package, called "
                               "'PatchOpenWB'.  If you run 'MCP', this feature is built-in, and merely needs to be "
                               "enabled."
                               "\n\n"
                               "AmigaOS v3.5 or greater does not have this problem.")
                        )
                )
        )



(tooltype       (dest "PSA_INSTALL:ProStationAudio/ProStationAudio")
                        (if (= dual 0) (settooltype "DUAL_MONITOR" ) )
                        (if (= dual 1) (settooltype "DUAL_MONITOR" "" )

                )
        )

(closemedia txt)(showmedia 'txt' "misc/Graph.GUIDE" 'upper_right' 'medium' 1 'wordwrap')
(set graph (askchoice (choices   "Disable Graphics Optimization"
                                 "Optimize Single/First Monitor"
                                 "Optimize Second Monitor"
                                 "Optimize Both Monitors"
                        (prompt #graph)
                        (help   "This feature is for systems retargeting their displays to graphic boards. "
                                "DON'T enable this feature if you are using the standard video display."
                                "\n\n"
                                "Disable Optimization - If you have no graphics cards, choose this option."
                                "\n\n"
                                "Optimize Single/First Monitor - If you have one graphics card, use this option."
                                "\n\n"
                                "Optimize second Monitor - If you are using the 15khz video output along with "
                                "a graphics card, and want the 15khz output to be your 'first monitor' "
                                "[timeline display] and the graphics card to be your 'second monitor' "
                                "[mixer display], choose this option."
                                "\n\n"
                                "Optimize both Monitors - If you have dual screens enabled and two graphics "
                                "cards, choose this option.")
                        )
                )
        )

(tooltype       (dest "PSA_INSTALL:ProStationAudio/ProStationAudio")
                        (if (= graph 0) (settooltype "CGFX_DEPT#?" ) )
                        (if (= graph 1) (settooltype "CGFX_DEPTH" "" ) )
                        (if (= graph 2) (settooltype "CGFX_DEPTH2" "" ) )
                        (if (= graph 3) (settooltype "CGFX_DEPTH" "" ) )
                        (if (= graph 3) (settooltype "CGFX DEPTH2" "" )
                )
        )

(closemedia splash)(showmedia 'splash' "misc/PSA4.iff" 'upper_left' 'none' 0)

(closemedia txt)(showmedia 'txt' "misc/SCR.GUIDE" 'upper_right' 'medium' 1 'wordwrap')
(set scr (askchoice (choices    "Disable Screen Requestor"
                                "Enable Screen Requestor"
                        (prompt #scr)
                        (help  "This feature, if enabled, will tell ProStationAudio to open a screen mode "
                               "selector at each and every launch.  The can be useful to bypass the saved "
                               "screen preferences in order to redefine them.  If you are running PSA in dual "
                               "monitor mode, you will be presented a seperate selector for each monitor."
                               "\n\n"
                               "When running PSA for the first time, screen mode selectors will be launched "
                               "regardless of this setting.")
                )
                )
        )

(tooltype       (dest "PSA_INSTALL:ProStationAudio/ProStationAudio")
                        (if (= scr 0) (settooltype "SHOW_SCR_SELECTOR" ) )
                        (if (= scr 1) (settooltype "SHOW_SCR_SELECTOR" "" )
                )
        )


(closemedia txt)(showmedia 'txt' "misc/WGFX.GUIDE" 'upper_right' 'medium' 1 'wordwrap')
(set wgfx (askchoice (choices   "Disable High-Resolution Waveform Graphics"
                                "Enable High-Resolution Waveform Graphics"
                        (prompt #wgfx)
                        (help "Enabling this setting will allow PSA the handle/store high resolution waveform "
                              "graphics inside ALSF (AudioLabs Support Files) files.  Recommended for all systems.")
                )
                )
        )


(tooltype       (dest "PSA_INSTALL:ProStationAudio/ProStationAudio")
                        (if (= wgfx 0) (settooltype "ULTRA_WGFX" ) )
                        (if (= wgfx 1) (settooltype "ULTRA_WGFX" "" )
                )
        )

(closemedia txt)(showmedia 'txt' "misc/NoBack.GUIDE" 'upper_right' 'medium' 1 'wordwrap')
(set noback (askchoice (choices "Disable Desktop Background"
                                "Enable Desktop Background"
                        (prompt #back)
                        (help "Use this feature to reduce chipram usage.  The solid color screen backdrop will be "
                              "replaced by the color zero.")
                )
                )
        )


(tooltype       (dest "PSA_INSTALL:ProStationAudio/ProStationAudio")
                        (if (= noback 0) (settooltype "NOBACKDROP" "" ) )
                        (if (= noback 1) (settooltype "NOBACKDROP" )
                )
        )

(closemedia txt)(showmedia 'txt' "misc/TaskPRI.GUIDE" 'upper_right' 'medium' 1 'wordwrap')
(set pri (askchoice (choices    "Normal Priority"
                                "High Priority (Recommended)"
                                "Ultra Priority (Can interefere with OS)"
                        (prompt #pri)
                        (help "The setting defines how much of your system's resources are allocated to PSA.")
                )
                )
        )


(tooltype       (dest "PSA_INSTALL:ProStationAudio/ProStationAudio")
                        (if (= pri 0) (settooltype "TASKPRI" ) )
                        (if (= pri 1) (settooltype "TASKPRI" "HIGH") )
                        (if (= pri 2) (settooltype "TASKPRI" "ULTRA")
                )
        )


(closemedia txt)(showmedia 'txt' "misc/CMEM.GUIDE" 'upper_right' 'medium' 1 'wordwrap')
(set cmem (askchoice (choices   "Mini"
                                "Small"
                                "Medium"
                                "Large"
                                "Huge"
        "Ultra"
                         (prompt #cmem)
                         (help  "This setting influences the maximum size allowed for a session to be played or "
                                "mixed to disc.  It doesn't influence the size of the session itself - you can "
                                "add as many objects as your free memory permits."
                                "\n\n"
                                "The 'weight' of a session is determined by the amount of tracks multiplied by "
                                "the timeline duration.  For example, a 5 minute timeline with 8 tracks (5 times 8) "
                                "needs more memory that a 10 minute timeline with 2 tracks (10 times 2).")
                )
        )
        )


(tooltype       (dest "PSA_INSTALL:ProStationAudio/ProStationAudio")
                        (if (= cmem 0) (settooltype "C_MEM_MODEL" "MINI" ) )
                        (if (= cmem 1) (settooltype "C_MEM_MODEL" "SMALL" ) )
                        (if (= cmem 2) (settooltype "C_MEM_MODEL" "MEDIUM" ) )
                        (if (= cmem 3) (settooltype "C_MEM_MODEL" "LARGE" ) )
                        (if (= cmem 4) (settooltype "C_MEM_MODEL" "HUGE" ) )
      (if (= cmem 5) (settooltype "C_MEM_MODEL" "ULTRA")
                )
        )

(closemedia txt)

(set @default-dest target)

; FIN

(if (= ProStationAudioisreallygreat 46) (welcome) )

(cleanup)
(exit)
