#define TIEFE 1
#define BREITE 640
#define HOEHE 400
#define FARBEN 2
#define PI 3.141592653
#define P 0.03117
#define Q 1.12104
#define FARBWECHSEL 8

#include <exec/types.h>
#include <intuition/intuition.h>
#include <math.h>
#include <graphics/gfxmacros.h>

struct IntuitionBase *IntuitionBase; 
struct GfxBase *GfxBase;

#define INTUITION_REV   29  /* Mindest-Versionsnummer! */
#define GRAPHICS_REV   29

/* Deklaration eines vordefinierten NewScreen Datenblocks */

struct NewScreen NewScreen =
  {
   0, 0,      /* linke obere Ecke */
   BREITE, HOEHE+32,   /* Breite, Hoehe */
   TIEFE,      /* Tiefe */
   0, 1,      /* DetailPen und BlockPen */
   HIRES|LACE,      /* Anzeige-Modi */
   CUSTOMSCREEN,   /* Screen-Typ */
   NULL,      /* Font */
   "Etwas schnelle Liniengrafik 640*400... Adieu, Atari ST!  (C.S)",   /* Titel */
   NULL,      /* Gadgets */
   NULL         /* keine custom bit map */
  };

struct NewWindow NewWindow =
  {
   0, 16,      /* linke, obere Ecke */
   BREITE, HOEHE,   /* Breite, Hoehe */
   0, 1,      /* Detail-, BlockPen Farbe */
   MOUSEBUTTONS,   /* IDCMP Flags */
   ACTIVATE|GIMMEZEROZERO|BORDERLESS,   /* Flags */
   NULL,      /* erstes Gadget */
   NULL,      /* Check Marke */
   NULL,      /* Titelstring */   
   NULL,      /* Bildschirm */
   NULL,      /* Bitmap-Pointer */
   0, 0,      /* min. Breite, Hoehe */
   0, 0,      /* max. Breite, Hoehe */      
   CUSTOMSCREEN      /* Typ */      
  };
   
main()
{
  struct Screen *Screen;
  struct Window *Window;   
  struct IntuiMessage *Message;
  REGISTER struct RastPort *rp;
  UBYTE z;
  FLOAT i=0,s=0,c=0;
  REGISTER LONG x1,x2,y1,y2;

  /* Oeffnen der Library und Ueberpruefung */

  IntuitionBase = (struct IntuitionBase *)
    OpenLibrary("intuition.library",INTUITION_REV);
  if (IntuitionBase == NULL) exit(FALSE);

  GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", GRAPHICS_REV);
  if (GfxBase == NULL) exit(FALSE);

  if ((Screen = (struct Screen *)OpenScreen(&NewScreen)) == NULL) exit(FALSE);
`
  NewWindow.Screen=Screen;   /* Pointer auf Screen fuer das Fenster */
  if (( Window = (struct Window *)OpenWindow(&NewWindow)) == NULL) exit(FALSE);

  rp=Window->RPort;   /* RastPort-Adresse */
  SetDrMd(rp,JAM2);   /* Zeichenmodus */
  SetDrPt(rp,0xFFFF);   /* Linie mit Muster 11001100... zeichnen */
  do  {
   i+=P;
   s=sin(i)+1;
   c=cos(i*Q)+1;
   x1=BREITE/2 * s;
        y1=HOEHE/2 * c;
   x2=BREITE-(BREITE/2 * c);
   y2=HOEHE/2 * s;
   SetAPen(rp,++z);
   Move(rp,x1,y1);
   Draw(rp,x2,y2);
        Message=(struct IntuiMessage *)GetMsg(Window->UserPort);
  } while ((Message->Class) != MOUSEBUTTONS); 
  CloseWindow(Window);
  CloseScreen(Screen);
  exit(TRUE);
}
