;*************************************************************************
;*  NewWPA8 Installer by Andre Dörffler                                  *
;*                                                                       *                                *
;*  ©1999 HAAGE & PARTNER Computer GmbH                                  *
;*                                                                       *
;*************************************************************************
;
; $VER: NewWPA8 (24 Mar 99)

(complete 0)

; Version No. and Date

;====================================================================
; Initialisation

(set @default-dest "")

(set os-version (/ (getversion) 65536))
(set os-13 (< os-version 36))
(set os-20 (>= os-version 36))
(set os-21 (>= os-version 38))

(set totalmem (database "total-mem")) ; Diese schöne Funktion vereinfacht einiges

;====================================================================
; Init (English)

    (set #yeskey "Yes")
    (set #nokey "No")

    (set #welcome (cat "\nWelcome to the installation of \n\n"
         "NewWPA8\n\n"
         "This script copies all the files of NewWPA8 "
         " onto your hard disk and modiefies your startup-sequence"
         ))

    (set #prp-wpa8 (cat "\n"
        "Attention:\n\n"
        "If you own a A1200 or A4000 without a graphicsboard (with AGA-chipset) "
        "there might be problems. \nTo solve these, the NewWPA8 patch "
        "will be added to your startup-sequence (your startup-sequence "
        "will be backed up).\n If you don`t want this, "
        "choose SKIP THIS PART."
        ))

    (set #wpa8-help (cat "Attention:\n"
        "AmigaOS knows three functions in graphics.library that output "
        "chunky pixels to a RastPort: WritePixelLine8, WritePixelArray8 "
        "and WriteChunkyPixels. \n"
        "The original versions of these routines in the KickstartROM "
        "are rather slow and have a bug that trashes the chunky source "
        "buffer. \n"
        "This patch installs improved versions that are often faster by "
        "a factor of 10 (on a fast CPU). \n"
        "-- Requirements:\n"
        "AmigaOS3.0 or AmigaOS3.1. The WriteChunkyPixels function exists "
        "only in AmigaOS3.1.\n"
        "An 68020 or higher CPU.\n"
        "-- Operation:\n"
        "The core of the patch are four routines that translate chunky data "
        "into 1..4 bitplanes and that write only complete words into a bitmap. "
        "For destinations with 5..8 bitplanes the planes are written in two "
        "passes translating upper and lower nibbles of the source data. "
        "If the destination rectangle is not aligned to words in the bitmap "
        "the unaligned border words are first converted into a buffer on the "
        "stack and then masked and copied to the destination bitmap. "
        "The patch utilizes the DoHookClipRects() function of AmigaOS3.x to "
        "write directly into the destination bitmap, even for layered RastPorts. "
        "This avoids completely the temporary bitmap you pass to the WPL8 and "
        "WPA8 functions, but of course programs must not rely on this. "
        "-- Installation:\n"
        "Add the newwpa8 command directly after SetPatch in your startup-sequence. "
        "The patch detaches itself from the Shell, there is no need to RUN it. "
        "It is most important that the patch is run before any other patch to "
        "the graphics system like the CyberGraphics driver that intercepts "
        "the calls itself."
        ))


(if (= @language "deutsch") (

    (set #yeskey "Ja")
    (set #nokey "Nein")

    (set #welcome (cat "\nWillkommen bei der Installation von \n\n"
         "NewWPA8\n\n"
         "Dieses Skript kopiert NewWPA8 auf Ihre Festplatte "
         "und ändert die startup-sequence."
         ))

    (set #prp-wpa8 (cat "\n"
        "Aufgepasst:\n\n"
        "Wenn sie einen A1200 oder A4000 ohne Grafikkarte (mit AGA-Chipset) "
        "betreiben, kann es zu Problemen kommen. Der Patch NewWPA8 behebt diese.\n "
        "Dazu wird das Kommando NewWPA8 in ihre startup-sequence eingefügt "
        "(Ihre startup-sequence wird zuvor gesichert).\n "
        "Wenn sie dies nicht wollen, wählen sie ÜBERSPRINGEN. "
        ))

    (set #wpa8c-help (cat "Achtung:\n"
        "Das AmigaOS kennt drei Funktionen in der graphics.library die Chunky-Pixel "
        "auf einen RastPort ausgeben: WritePixelLine8, WritePixelArray8 und "
        "WriteChunkyPixels.\n"
        "Die Original-Versionen dieser Routinen im Kickstart-ROM sind ziemlich "
        "langsam und haben einen Fehler, der den Chunky-Quellbuffer zerstört.\n "
        "Dieser Patch installiert verbesserte Versionen dieser Funktionen, die "
        "mit einem schnellen Prozessor oft 10 mal schneller sind\n"
        "-- Systemvoraussetzungen:\n"
        "AmigaOS 3.0 or AmigaOS 3.1. Die WriteChunkyPixels-Funktion gibt es nur im "
        "AmigaOS 3.1. \n"
        "Einen Prozessor ab 68020.\n"
        "-- Wie funktioniert es?\n"
        "Der Kern des Patches besteht aus vier Routinen die Chunky-Daten in "
        "Bitplanes übersetzen.\n"
        "-- Installation: \n"
        "Fügen sie den NewWPA8-Befehl direkt nach SetPatch in ihre Startup-Sequence "
        "ein. Der Patch löst sich selbständig von der Shell, sie brauchen ihn nicht "
        "mit dem Run-Befehl zu starten. \n"
        "Es ist sehr wichtig, daß der Patch vor allen anderen Patches, die diese "
        "Funktion Grafiksystem betreffen, wie z.B. CyberGraphX und Picasso 96, "
        "gestartet wird."
    ))
))

; // Die Pfadnamen der einzelnen Quell-Dateien.
(set source-insert                  "insert")
(set source-NewWPA8                 "NewWPA8")

;=====================================================================================
; Beginn der Installation
;=====================================================================================

; // needs OS 3.0 !!!
(if (< (/ (getversion) 65536) 39)
    (
        (message #wrongos)
        (exit (quiet))
    )
)

; Intro
(message #welcome)
(welcome)
(complete 10)

; // Alte Version prüfen und entsprechende Abfrage ausgeben!--------------------------------------------

(set act-user-level @user-level)
(user 1)

(complete 20)

; // Nun wird insert ins RAM gehauen, damit es dann nicht nachgeladen werden muss

(copyfiles
        (dest "RAM:")
        (source source-insert)
)

(complete 30)

;// Nun wird der NewWPA8 Patch installiert
;// *** Done by AND

(set #wpa8-skip (cat "Skip this part"))
(set #wpa8-proceed (cat "Insert NewWPA8"))

(if(= @language "deutsch") (
   (set #wpa8-skip (cat "Diesen Teil Überspringen"))
   (set #wpa8-proceed (cat "NewWPA8 einfügen"))
))
(if((askbool (prompt #prp-wpa8)
             (help #wpa8-help)
             (choices #wpa8-proceed #wpa8-skip))) (
    (run "ram:insert s:startup-sequence -i NewWPA8 -p setpatch")
    (complete 50)
    (copyfiles (dest "C:")
               (source source-NewWPA8)
    )
))

(complete 70)

;==================================================================================
; Aufraeumen

(delete "RAM:LHeX")
(delete "RAM:insert")

(complete 100)

; ------- FERTIG

(set #endnow (cat "Installation of NewWPA8 patch completed.\n"
    "If the line:\n\n NewWPA8 \n\ndoesn`t appear "
    "in your Startup-Sequence, you failed the installation. "
    "So please insert it manually.\n\n"
    "Best wishes...\n\n"
    "HAAGE & PARTNER Computer, Germany"
    ))

(if (= @language "deutsch") (

    (set #endnow (cat "\nInstallation von NewWPA8  beendet.\n\n"
        "Falls die Zeile:\n\n NewWPA8\n\nnicht in Ihre Startup-Sequence "
        "eingefügt wurde, dann holen Sie dies bitte nach.\n\n"
        "\n\nWir wünschen ihnen viel Erfolg mit NewWPA8!\n\n"
        "HAAGE & PARTNER Computer"
    ))
))

(message #endnow)
