**********************************************************
*
* This is Public Domain ! Do with it whatever you like !!!
*
**********************************************************
;
; PolygrammDemo.s : dreht ein beliebiges Polygramm um beliebige Achse
;                   Anzahl der Ecken sowie veraenderte Drehung sind
;                   im Quelltext zu aendern
;                   siehe ganz unten !!!
;
;
; Autor :      Sascha Groening
;              Blaustr.:    13
;              8360 Deggendorf
;              West-Germany
;
;
; das Programm wurde fuer den A68K  Public Domain Assembler
;                             BLINK Public Domain Linker      geschrieben
;
;                             (A68K : Fish Disk 110)
;                             (BLINK: Fish Disk  40)
;
;
;
;
; Nutzen:
;                 K E I N E R !
;
;
; Es ist ein Beispiel fuer flackerfreie Darstellung von bewegter
; Grafik durch verdecktes Aufbauen der Grafik in einem
; Bufferspeicher und anschliessendes Kopieren ins Window
;
; Ausserdem kann man es als Beispiel fuer die Benutzung von den Mathe
; Libraries benutzen.
; (Ihre Routinen sind zwar nicht besonders schnell,
;  das Ganze ist aber immer noch erheblich einfacher als sich die SIN & COS
;  Routinen selber zu schreiben)
;
;
;
; Assemblieren :      A68K  PolygrammDemo.s
;                     BLINK PolygrammDemo.o
;
;
;
; ACHTUNG : das Programm benoetigt die
;            -mathtrans.library
;           im LIBS: Directory
;
;
;
; (Das Programm ist in Spagetti-Technik aufgebaut
;  also Schritt fuer Schritt gut nachvollziehbar!
;  (um es mal positiv auszudruecken))
;



CALLDOS  macro
         movea.l DOSBase,a6
         jsr    \1(a6)
         endm

CALLEXEC macro
         movea.l SysBase,a6
         jsr    \1(a6)
         endm
CALLINT  macro
         movea.l IntBase,a6
         jsr    \1(a6)
         endm
CALLGRAF macro
         movea.l GfxBase,a6
         jsr    \1(a6)
         endm
CALLMATH macro
         movea.l MathBase,a6
         jsr     \1(a6)
         endm
CALLMATHTRANS macro
              movea.l MathTransBase,a6
              jsr     \1(a6)
              endm

SysBase   equ 4
OldOpenLibrary equ -408
CloseLibrary equ -414
GetMsg equ -372
ReplyMsg equ -378
FreeMem equ -210
AllocMem equ -198

Output equ -60
Write equ -48
Delay equ -198

CloseWindow equ -72
OpenWindow equ -204

BltBitMap equ -30
SetRast equ -234
Move equ -240
PolyDraw equ -336
SetAPen equ -342
AllocRaster equ -492
FreeRaster equ -498
InitBitMap equ -390
ScrollRaster equ -396
InitRastPort equ -198
Text equ -60
DrawEllipse equ -180
WaitTOF equ -270

SPFix equ -30
SPFlt equ -36
SPCmp equ -42
SPNeg equ -60
SPAdd equ -66
SPSub equ -72
SPMul equ -78
SPDiv equ -84
SPAtan equ -30
SPSin equ -36
SPCos equ -42


MEMF_CHIP equ $2
MEMF_CLEAR   equ $10000


wd_RPort     equ $32
wd_UserPort  equ $56
MP_SIGBIT    equ $0f

rp_BitMap equ 4
bm_Plane0 equ 8
bm_Plane1 equ 12
bm_Plane2 equ 14


WINDOWDRAG     equ $0002
WINDOWDEPTH    equ $0004
WINDOWCLOSE    equ $0008
SMART_REFRESH  equ $0000
ACTIVATE       equ $1000
CLOSEWINDOW    equ $00000200
WBENCHSCREEN   equ $0001



**********************************
;               MainProg
**********************************

_main
   move.l a7,stapel

   lea.l    dosname,a1
   CALLEXEC OldOpenLibrary   ;dos.library oeffnen
   move.l   d0,DOSBase
   beq      abbruch

   CALLDOS Output
   move.l d0,OutHandle

;   move.l #_main,d2
;   lea.l  hbuf,a0
;   move.b #10,8(a0)
;   bsr    hexasc
;   move.l OutHandle,d1
;   move.l #hbuf,d2
;   move.l #9,d3
;   CALLDOS Write             ;Anfangsadr des Prgs ausgeben

   lea.l  intname,a1
   CALLEXEC OldOpenLibrary
   move.l d0,IntBase         ;intuition.library oeffnen
   beq    closedos

   lea.l  grafname,a1
   CALLEXEC OldOpenLibrary   ;graphics.library oeffnen
   move.l d0,GfxBase
   beq    closeint

   lea.l  mathname,a1
   CALLEXEC OldOpenLibrary   ;mathffp.library oeffnen
   move.l d0,MathBase
   beq    nomath

   lea.l  mathtransname,a1
   CALLEXEC OldOpenLibrary   ;mathtrans.library oeffnen
   move.l d0,MathTransBase
   beq    nomathtrans

   lea.l    windowdef,a0
   CALLINT  OpenWindow       ;window oeffnen
   move.l   d0,windowptr
   beq      closemathtrans

   movea.l d0,a0
   move.l wd_UserPort(a0),UPort   ;UserPort holen
   move.l wd_RPort(a0),RPort      ;RastPort holen

   movea.l RPort,a3
   movea.l rp_BitMap(a3),a3
   move.l  a3,DestBitMap          ;die BitMapstrktr des Windows holen

   movea.l a3,a0
   moveq.l #2,d0
   move.l #630,d1
   move.l #240,d2
   CALLGRAF InitBitMap          ;richtige Werte fordern

   move.l bm_Plane0(a3),Plane0  ;dieselbigen holen
   move.l bm_Plane1(a3),Plane1  ;(just for fun !!)

* 2 BufferPlanes allokieren und sie in unsere eigene Bitmapstrktr
*                      eintragen
*----------------------------------------------------------------

   move.l #384,d0
   move.l #172,d1
   CALLGRAF AllocRaster
   move.l d0,Buffer0     ;Plane0 in Bitmapstrktr eintragen
   beq    nomem

   move.l #384,d0
   move.l #172,d1
   CALLGRAF AllocRaster
   move.l d0,Buffer1     ;Plane1 in Bitmapstrktr eintragen
   beq    nomem

* eigenen RastPort initialisieren, damit wir auch in die Bufferplane
* zeichnen koennen
* ------------------------------------------------------------------

   lea.l OwnRastPort,a1
   CALLGRAF InitRastPort  ;eigenen RastPort mit bestimmten
                          ;Ausgangswerten initialisieren

   lea.l OwnBitMap,a0
   lea.l OwnRastPort,a1

   move.l a0,rp_BitMap(a1) ;Bitmapstrktr in RastPort eintragen

* Planes loeschen
* ---------------

   clr.l d0
   lea.l OwnRastPort,a1
   CALLGRAF SetRast

* Zeichenfarbe fuer window und Bufferplanes setzen
* ------------------------------------------------

   lea.l OwnRastPort,a1
   moveq.l #1,d0
   CALLGRAF SetAPen          ;Zeichenfarbe fuer Window setzen

   movea.l RPort,a1
   moveq.l #1,d0
   CALLGRAF SetAPen          ;Zeichenfarbe fuer Window setzen



* Text im Fenster zeichnen
* ------------------------
   moveq.l #10,d2 ;XStart
   moveq.l #20,d3 ;YStart
   moveq.l #23,d4 ;Anzahl der Zeilen -1

loop1
   move.l d2,d0
   move.l d3,d1
   movea.l  RPort,a1
   CALLGRAF Move

   lea.l  msg,a0
   moveq.l #msglen,d0
   movea.l RPort,a1
   CALLGRAF Text       ;eine Zeile ausgeben

   addi.l #8,d3        ;Y=Y+8

   dbra   d4,loop1     ;naechste Zeile



* Text im Fenster scrollen
* ------------------------
   moveq.l #25,d6   ;26 mal scrollen

loop2
   moveq.l #-8,d0   ;dx
   moveq.l #16,d1   ;dy
   moveq.l #20,d2   ;xmin
   moveq.l #28,d3   ;ymin
   move.l  #400,d4  ;xmax
   move.l  #200,d5  ;ymax
   movea.l RPort,a1       ;_______________________________________________
   CALLGRAF ScrollRaster  ;x(0/0)       Verschiebung um (dx/dy) Richtung |
                          ;           \  Nullpunkt (0/0)                 |
                          ;            \                                 |
                          ;             \                                |
                          ;              \ (xmin/ymin)                   |
                          ;               x________                      |
                          ;               |        |                     |
                          ;               |        |                     |
                          ;               |________x(xmax/ymax)          |
                          ;                                              |
                          ;______________________________________________|

   dbra    d6,loop2

* Ellipse zeichnen
* ----------------

   movea.l RPort,a1      ;Polygramme werden in Ellipsen einbeschrieben
   move.l #200,d0
   move.l #100,d1        ;in diese Ellipse wird das 1.Polygramm
   move.l rx,d2          ;einbeschrieben
   move.l ry,d3
   CALLGRAF DrawEllipse

********************************************
* Jetzt kommts ........
********************************************


* PI berechnen
* ------------

   move.l #$4,d0
   CALLMATH SPFlt    ;4 in FFP Format umwandeln
   move.l d0,-(a7)   ;FFP = Fast Floating Point (oder so aehnlich)
                     ;(wobei das Fast nicht woertlich zu nehmen
                     ; sondern galaktisch zu sehen ist )
   move.l #$1,d0
   CALLMATH SPFlt    ;1 --> FFP
   CALLMATHTRANS SPAtan
   move.l (a7)+,d1   ;d0 = ATN(1)
   CALLMATH SPMul    ;4*ATN(1)
                     ;*******************************
   move.l d0,PI      ;PI = 4*ATN(1)
                     ;*******************************


* Argh berechnen  (Argh ist eine spezielle Konstante )
* ----------------------------------------------------
*                 (die zur Berechnung von ALPHA dient)
*

   moveq.l #2,d0
   CALLMATH SPFlt
   move.l d0,two    ;2 in FFP wird noch oefter verwendet
                    ;==> speichern

   move.l PI,d0
   move.l two,d1
   CALLMATH SPDiv   ;==> d0 = PI/2
                    ;       = 90° in RAD (wie ja jedermann weiss)
                    ;RAD wird benoetigt ,da es die
                    ;Mathe Routinen in den Libraries so wollen


   move.l d0,stepxcount  ;beginne Darstellung wenn Polygramm bereits
                         ;um 90° um X- & Z-Achse gedreht wurde
   move.l d0,stepzcount


   moveq.l #1,d0
   CALLMATH SPFlt   ;==> d0 = 1 in FFP Format
   move.l two,d1
   CALLMATH SPDiv   ;==> d0 = 1/2 in FFP Format
   move.l d0,-(a7)  ;0.5 in FFP

   move.l n,d0
   CALLMATH SPFlt   ;n-Eckiges-Polygramm
   move.l two,d1
   CALLMATH SPDiv   ;==> d0 = n/2
   move.l (a7)+,d1  ;d0 = 0.5 in FFP Format
   CALLMATH SPSub
                    ;************************
   move.l d0,argh   ;argh = d0 = n/2-0.5
                    ;************************

* ALPHA berechnen   (ist ebenfalls eine Konstante)
* -------------------------------------------------
*                   (die zur Berechnung des Drehungswinkels um
*                    die Y-Achse benoetigt wird)


   move.l two,d0
   move.l PI,d1
   CALLMATH SPMul
                    ;************************
   move.l d0,PI2    ;PI2 = 2 * PI
                    ;************************
   move.l n,d0
   CALLMATH SPFlt   ;==> n in FFP Format
   move.l d0,d1
   move.l PI2,d0
   CALLMATH SPDiv   ;==> d0 = 2*PI/n
   move.l argh,d1
   CALLMATH SPMul   ;**********************************************
   move.l d0,ALPHA  ;==> ALPHA = d0 = 2*PI/n*argh
                    ;               = 2*PI/n*(n/2-0.5)
                    ;                 2*PI    /  n          \
                    ;               = ---- * |  ---  -  0.5  |
                    ;                  n      \  2          /
                    ;**********************************************


* rx,ry,xpos,ypos in FFP umwandeln
* ---------------------------------

   move.l rx,d0
   CALLMATH SPFlt
   move.l d0,rxffp  ;X-Radius der Ellipse --> FFP
   move.l d0,lxffp

   move.l ry,d0
   CALLMATH SPFlt
   move.l d0,ryffp  ;Y-Radius der Ellipse --> FFP
   move.l d0,lyffp

   move.l xpos,d0
   CALLMATH SPFlt
   move.l d0,xposffp  ;Mittelpunkt der Ellipse --> FFP

   move.l ypos,d0
   CALLMATH SPFlt
   move.l d0,yposffp  ;Mittelpunkt der Ellipse --> FFP

* stepx,-y,-z in RAD und FFP umrechnen
* ------------------------------------

* stepy berechnen
* ----------------

   move.l #180,d0
   CALLMATH SPFlt
   move.l d0,einsachtzig  ;180 --> FFP Format

   move.l stepy,d0
   CALLMATH SPFlt         ;*****************************************
   move.l einsachtzig,d1  ;         stepy         ;  Umwandlung von
   CALLMATH SPDiv         ; stepy = -----  * PI   ;  Grad in RAD
   move.l PI,d1           ;          180°         ;
   CALLMATH SPMul         ;*****************************************
   move.l d0,stepy        ;in stepy Grad Schritten um Y-Achse drehen

* stepx berechnen
* ---------------

   move.l stepx,d0
   CALLMATH SPFlt         :*****************************************
   move.l einsachtzig,d1  ;         stepx
   CALLMATH SPDiv         ; stepx = ----- * PI
   move.l PI,d1           ;          180°
   CALLMATH SPMul         ;*****************************************
   move.l d0,stepx        ;in stepx Grad Schritten um Y-Achse drehen

* stepz berechnen
* ----------------

   move.l stepz,d0
   CALLMATH SPFlt         ;*****************************************
   move.l einsachtzig,d1  ;         stepz
   CALLMATH SPDiv         ; stepz = ----- * PI
   move.l PI,d1           ;          180°
   CALLMATH SPMul         ;*****************************************
   move.l d0,stepz        ;in stepz Grad Schritten um Y-Achse drehen



* Mem fuer Vektor-Array allokieren
* --------------------------------

   move.l n,d0   ; n Ecken ==> n+1 XY-Paare
   addq.l #1,d0  ;             ==> (n+1)*4 Byte Speicher benoetigt
   lsl.l #2,d0   ;   (ein Punkt benoetigt 1 Word fuer die X - Koordinate
                 ;                      und eins fuer die Y - Koordinate
                 ;
                 ;   1.Punkt = letzter Punkt ==> +1

   move.l #MEMF_CHIP!MEMF_CLEAR,d1
   CALLEXEC AllocMem     ;in dieses Array werden alle Koordinaten
   move.l d0,VArray      ;der Ecken eines Polygramms eingetragen
   beq    nomem

* n.Koord berechnen
* -----------------

loop6
   move.l VArray,a2  ;a2 = Speicher fuer Vektoren
   move.l n,d5       ;d5 = n = Anzahl der Ecken
   clr.l  d4         ;d4 = 0 = 1.Ecke

loop4
   bsr  getxcoord    ; fuer jede Ecke X-,Y-Koordinate errechnen
   bsr  getycoord    ;

   addq.l #1,d4      ;Ecke++
   dbra   d5,loop4   ;naechste Ecke berechnen

* neues Polygramm zeichnen
* -------------------------


                      ; 1.Punkt = letzter Punkt
                      ; ==>
   move.w -4(a2),d0   ;x - Koord. des ersten Punktes
   move.w -2(a2),d1   ;y - Koord. des ersten Punktes
   lea.l OwnRastPort,a1
   CALLGRAF Move      ; GrafikCursor an AnfangsPosition
                      ;    (1.Ecke)

   CALLGRAF WaitTOF   ;vielleicht nuetzt es was ,vielleicht auch nicht

   lea.l OwnRastPort,a1
   movea.l VArray,a0
   move.l  n,d0
   addq.l  #1,d0      ;d0 = Anzahl der zu zeichnenden Punkte
   CALLGRAF PolyDraw  ;  ==> Punkte werden durch Linien verbunden

   movem.l d0-d7/a0-a3,-(a7)

   lea.l OwnBitMap,a0
   movea.l DestBitMap,a1
   clr.l d0              ;Srcx
   clr.l d1              ;SrcY
   move.w destx,d2
   move.w desty,d3
   move.l #380,d4        ;sizex
   move.l #170,d5        ;sizey
   move.b #$c0,d6        ;vanillacopy
   move.b #$ff,d7        ;alle Bits gesetzt ==> alle verfuegbaren
                         ;Planes kopieren
   CALLGRAF BltBitMap    ;BufferBitmap ins Window kopieren

   movem.l (a7)+,d0-d7/a0-a3

* einige Zeit warten oder besser doch nicht!!!
* -----------------------------------------

;   move.l delaytime,d1
;   CALLDOS Delay      ;eine bestimmte Zeit warten


* naechsten Schritt der Drehung des Polygramms berechnen
* ------------------------------------------------------

*  Y - Drehung berechnen
* -----------------------

   move.l stepycount,d0  ; YWinkel =YWinkel + stepy
   move.l stepy,d1       ;==> beim naechsten Zeichnen um stepy Grad gedreht
   CALLMATH SPAdd
   move.l d0,stepycount

*  X - Drehung berechnen
* -----------------------


   move.l stepxcount,d0  ;Rotation um X-Achse
   CALLMATHTRANS SPSin
   move.l lyffp,d1   ;ry = SIN(stepxcount) * ly
   CALLMATH SPMul
   move.l d0,ryffp   ;Y-Radius der Ellipse veraendert sich Sinus-maessig
                     ;         ==> Vortaeuschung einer richtigen Drehung
                     ;             um X-Achse

   move.l stepxcount,d0
   move.l PI,d1
   CALLMATH SPCmp
   bne    cont5
   move.l stepx,d0    ;wenn bereits um 180° um X-Achse gedreht
   CALLMATH SPNeg     ;
   move.l d0,stepx    ;Schrittweite negieren
                      ;==> wird wieder zurueckgedreht
                      ;    trotzdem Effekt : Polygramm dreht sich weiter
                      ;                      in die selbe Richtung


cont5
   move.l stepxcount,d0 ; XWinkel = XWinkel + stepx
   move.l stepx,d1      ;==> beim naechsten Zeichnen um stepx Grad gedreht
   CALLMATH SPAdd
   move.l d0,stepxcount


*  Z - Drehung berechnen
* -----------------------


contz
   move.l stepzcount,d0     ;Rotation um Z-Achse
   CALLMATHTRANS SPSin
   move.l lxffp,d1    ;rx = SIN(stepxcount) * lx
   CALLMATH SPMul     ;X-Radius der Ellipse veraendert sich Sinus-maessig
   move.l d0,rxffp    ;         ==> Vortaeuschung einer richtigen Drehung
                      ;             um Z-Achse



   move.l stepzcount,d0
   move.l PI,d1
   CALLMATH SPCmp
   bne    cont6
   move.l stepz,d0 ;wenn bereits um 180° um Z-Achse gedreht
   CALLMATH SPNeg  ;Schrittweite negieren
   move.l d0,stepz ;==> Polygramm wird wieder zurueckgedreht
                   ;    trotzdem Effekt : Polygramm dreht sich weiter
                   ;                      in die selbe Richtung

cont6
   move.l stepzcount,d0
   move.l stepz,d1
   CALLMATH SPAdd       ; ZWinkel = ZWinkel + stepz
   move.l d0,stepzcount ;==> beim naechsten Zeichnen um stepz Grad gedreht


*  Ende des Berechnens des neuen Polygramms
*  ----------------------------------------
*  altes Polygramm wieder loeschen
*  ----------------------------------------

   lea.l OwnRastPort,a1
   clr.l d0
   CALLGRAF SetRast

   movea.l UPort,a0
   CALLEXEC GetMsg           ;hole Message
   tst.l d0
   beq loop6                 ;wenn keine da weiter drehen

   movea.l   d0,a1           ;muss nach a1
   CALLEXEC ReplyMsg         ;quittiere Msg in a1


*    CCC  L     EEEE    AA    N    N  U   U  PPP
*  C      L     EE     A  A   N N  N  U   U  P  P
*  C      L     E     A AA A  N   NN  U   U  PPP
*    CCC  LLLL  EEEE  A    A  N    N  UUUU   P
*


* Speicher fuer Vektor-Array freigeben
* ------------------------------------
   move.l n,d0
   addq.l #1,d0
   lsl.l #2,d0
   movea.l VArray,a1
   CALLEXEC FreeMem


freeraster1
   tst.l Buffer0
   beq   freeraster2
   move.l #384,d0
   move.l #172,d1
   movea.l Buffer0,a0
   CALLGRAF FreeRaster       ;Bufferplane0 freigeben

freeraster2
   tst.l Buffer1
   beq   closewin
   move.l #384,d0
   move.l #172,d1
   movea.l Buffer1,a0
   CALLGRAF FreeRaster       ;Bufferplane1 freigeben


* Fenster schliessen
* ------------------
closewin
   movea.l stapel,a7
   movea.l windowptr,a0
   CALLINT  CloseWindow      ;Fenster schliessen


* Libraries schliessen
* --------------------

closemathtrans
   movea.l stapel,a7
   movea.l MathTransBase,a1
   CALLEXEC CloseLibrary     ;mathtrans.library schliessen

closemath
   movea.l stapel,a7
   movea.l MathBase,a1
   CALLEXEC CloseLibrary     ;mathffp.library schliessen

closegraf
   movea.l stapel,a7
   movea.l GfxBase,a1
   CALLEXEC CloseLibrary     ;graphics.library schliessen

closeint
   movea.l stapel,a7
   movea.l IntBase,a1        ;intuition.library schliessen
   CALLEXEC CloseLibrary

closedos
   movea.l stapel,a7
   movea.l DOSBase,a1        ;dos.library schliessen
   CALLEXEC CloseLibrary
abbruch
   movea.l stapel,a7
   clr.l d0
   rts                       ;Rueckkehr ins CLI



**********************************************
;             Unterprogs
**********************************************


getwinkel
   move.l d4,d0      ;n.Eck berechnen
   CALLMATH SPFlt
   move.l ALPHA,d1
   CALLMATH SPMul
   move.l stepycount,d1
   CALLMATH SPAdd        ; ==> d0 =  ALPHA * Ecke + stepycount
   rts

getxcoord
   bsr.s  getwinkel
   CALLMATHTRANS SPCos
   move.l rxffp,d1
   CALLMATH SPMul        ;d0 = rx * COS(ALPHA * Ecke + stepycount)
   move.l xposffp,d1     ;d0 = xpos + rx*COS(ALPHA * Ecke + stepycount)
gemeinsames
   CALLMATH SPAdd
   CALLMATH SPFix     ;Koordinate von FFP nach normal wandeln
   move.w d0,(a2)+    ;in VArray eintragen
   rts

getycoord
   bsr  getwinkel
   CALLMATHTRANS SPSin
   move.l ryffp,d1
   CALLMATH SPMul      ;d0 = rx * SIN(ALPHA * Ecke + stepycount)
   move.l yposffp,d1   ;d0 = xpos + rx*COS(ALPHA * Ecke + stepycount)
   bra.s  gemeinsames



************************************************************
*
*          Sonstiges.........

;
; Konvertiere d2.l in ASCII-String ab (a0)
;

hexasc
    moveq.l #7,d0                       ;8 Nibble (=Halbbyte) wandeln
    addq.l  #8,a0                       ;Pos der letzten Stelle im Buffer+1
loop5
    moveq   #15,d1                      ;
    and.l   d2,d1                       ;1 Nibble isolieren
    asr.l   #4,d2                       ;naechstes Nibble an 1.Pos
    addi.b  #48,d1                      ;isol. Nibble+48=Zahl in ASCII
    cmpi.b  #57,d1                      ;war Zahl >9 ?
    bls.s   cont4
    addq.l  #7,d1                       ;wenn ja noch 7 dazu ==> A-F
cont4
    move.b  d1,-(a0)                    ;in Buffer eintragen
    dbra    d0,loop5                    ;naechstes Nibble wandeln
    rts

nomath
    move.l OutHandle,d1
    move.l #Fehler1,d2   ;keine mathffp.library
    moveq.l #len1,d3     ;(sehr unwahrscheinlich ,da im ROM)
    CALLDOS Write
    bra    closegraf

nomathtrans
    move.l OutHandle,d1
    move.l #Fehler2,d2    ;keine mathtrans.library im LIBS:
    moveq.l #len2,d3
    CALLDOS Write
    bra    closemath

nomem
    move.l OutHandle,d1
    move.l #Fehler3,d2    ;nicht genuegend Speicher
    moveq.l #len3,d3
    CALLDOS Write
    bra    freeraster1



    DATA constants


W_Gadgets equ   WINDOWDRAG!WINDOWDEPTH!WINDOWCLOSE
W_Extras  equ   SMART_REFRESH!ACTIVATE



windowdef
        dc.w    0,0                 ;links, oben
        dc.w    630,240             ;Breite, Hoehe
        dc.b    -1,-1               ;Pens des Screen
        dc.l    CLOSEWINDOW
        dc.l    W_Gadgets!W_Extras  ;Window Flags
        dc.l    0                   ;erstes User-Gadget
        dc.l    0                   ;keine User-Checkmark
        dc.l    W_Title             ;Titel des Window
        dc.l    0                   ;kein eigener Screen
        dc.l    0                   ;keine Super Bitmap
        dc.w    100,20              ;Min. Groesse
        dc.w    640,200             ;Max.
        dc.w    WBENCHSCREEN        ;Use Workbench Screen

        cnop 0,2
W_Title dc.b    'Polygramm Demo  by   Sascha Groening',0
        cnop 0,2
Fehler1 dc.b 'no mathffp.library',10
len1    equ *-Fehler1
        cnop 0,2
Fehler2 dc.b 'no mathtrans.library',10
len2    equ *-Fehler2
        cnop 0,2
Fehler3 dc.b 'Kauf Dir endlich eine Speichererweiterung !!',10
len3    equ *-Fehler3
        cnop 0,2



 cnop 0,2
msg           dc.b  'Hello,World!YeahYeahYeahYeahYeahHello,World!YeahYeahYeahYeahYeah'
msglen        equ   *-msg
 cnop 0,2

 dc.b 'Polygramm-Demo  by Sascha Groening',10
 dc.b 'This is Public Domain !! Do with it whatever you like !!',10

 cnop 0,2
dosname    dc.b 'dos.library',0
 cnop 0,2
intname    dc.b 'intuition.library',0
 cnop 0,2
grafname   dc.b 'graphics.library',0
 cnop 0,2
mathname   dc.b 'mathffp.library',0
 cnop 0,2
mathtransname dc.b 'mathtrans.library',0
 cnop 0,2

  cnop 0,4

n dc.l 9           ;Anzahl der Ecken
                    ;muss eine ungerade Zahl sein !!!!

rx dc.l 100         ; X-Radius der Ellipse
ry dc.l 50          ; Y-Radius der Ellipse

xpos dc.l 180       ; Mittelpunkt der Ellipse
ypos dc.l 72        ; bei (180/72)

stepz dc.l 3        ; Drehung in 3° Schritten um Z-Achse
stepy dc.l 3        ; keine Drehung um Y-Achse
stepx dc.l 0        ; keine Drehung um X-Achse

delaytime dc.l 8    ; Verzoegerungszeit = 8/50 sec
  cnop 0,4
destx dc.w 20       ; (x/y) Koord des linken oberen Eckes des
desty dc.w 28       ; Windowausschnitts ,in den immer wieder
                    ; die Bufferplane mit fertig gezeichneten
                    ; Polygramm kopiert wird.
  cnop 0,4
OwnBitMap                   ;eigene BitmapStrktr fuer Bufferplanes
  dc.w 48  ;Bytes per Row
  dc.w 172 ;Rows
  dc.b 0 ;flags
  dc.b 2 ;depth     ;==> 2 Planes
  dc.w 0 ;pad
Buffer0  ds.l 1     ;BufferPlane0
Buffer1  ds.l 1     ;BufferPlane1


  BSS storage

DOSBase ds.l 1
OutHandle ds.l 1
IntBase ds.l 1
GfxBase ds.l 1
MathBase ds.l 1
MathTransBase ds.l 1
windowptr ds.l 1
stapel ds.l 1
hbuf ds.l 3
RPort ds.l 1
UPort ds.l 1
Plane0 ds.l 1
Plane1 ds.l 1
DestBitMap ds.l 1
PI ds.l 1
PI2 ds.l 1
ALPHA ds.l 1
VArray ds.l 1
argh ds.l 1
two ds.l 1
stepycount ds.l 1
stepzcount ds.l 1
stepxcount ds.l 1
lyffp ds.l 1
lxffp ds.l 1
einsachtzig ds.l 1
rxffp ds.l 1
ryffp ds.l 1
xposffp ds.l 1
yposffp ds.l 1
OwnRastPort ds.b 100  ;uninitialisierte RastPortStrktr

   END
