#include "graphics/gfxmacros.h"
#include "exec/types.h"
#include "intuition/intuition.h"



struct IntuitionBase *IntuitionBase;
struct Window *NoBorder;
struct GfxBase *GfxBase;
struct Screen *Scrn;
struct IntuiMessage *mesg;
struct RastPort *r;
struct ViewPort *vp;

#define MAXW  320 /* max width van window ! */
#define MAXH  200 /* max height van window ! */

struct NewScreen NewScrn = {
        0, 0,           /* LeftEdge, TopEdge */
        320, 200,       /* Width, Height */
        2,              /* Depth */
        0, 1,           /* DetailPen, BlockPen */
        NULL,           /* ViewModes ... value of 0 = low resolution */
        CUSTOMSCREEN,   /* Type of screen */
        NULL,           /* Font to be used as default for this screen */
        NULL,           /* DefaultTitle for its title bar */
        NULL,           /* screens user-gadgets, always NULL, ignored */
        NULL };         /* address of custom bitmap for screen */

struct NewWindow NewNoBorder = {
        0,              /* LeftEdge */
        0,              /* TopEdge  */
        MAXW, MAXH,     /* Width, Height of this window */
        -1,             /* DetailPen */
        -1,             /* BlockPen */
        MOUSEBUTTONS,   /* IDCMP Flags */
        ACTIVATE|SMART_REFRESH|BORDERLESS|GIMMEZEROZERO|BACKDROP,
                        /* Window Flags:  (see below for more info) */
        NULL,           /* FirstGadget */
        NULL,           /* CheckMark   */
        NULL,           /* Window title */
        NULL,           /* Pointer to Screen if not workbench */
        NULL,           /* Pointer to BitMap if a SUPERBITMAP window */
        0, 0,           /* minimum width, minimum height */
        0,0,            /* maximum width, maximum height */
        CUSTOMSCREEN    /* type waarin window opend */
        };


#define INTUITION_REV 29
#define GRAPHICS_REV 29


main()
{
 ULONG mclass;
 SHORT einde,xt,x,i,tw,th,tb,yprintpos,ymin_scrollraster;


 VOID OpenALL();

 OpenALL();

 if((Scrn = (struct Screen *) OpenScreen(&NewScrn)) == 0) exit(10);
 
 NewNoBorder.Screen = Scrn;

 if((NoBorder = (struct Window *) OpenWindow(&NewNoBorder)) == 0) exit(20);

 /* ======geen screentitel====== */

 ShowTitle(Scrn,0);

 /* ======definitie van RPort !====== */

 r=NoBorder->RPort;
 vp=ViewPortAddress(NoBorder);



  SetRGB4(vp,0,0,0,0);
  for(x=1;x<4;x++)
   {
   SetRGB4(vp,   x,12,x-1,x-1);
   SetRGB4(vp,16+x,x+1,x+1,15);
   };
  SetRGB4(vp,0,0,0,0);

 /* scroll */

  tw = r->TxWidth;           /* tw = Text Width */
  th = r->TxHeight;          /* th = Text Height */
  tb = r->TxBaseline;        /* tb = Text BaseLine */

  yprintpos = 199-1-(th-tb);
  ymin_scrollraster = 199-(th+1);

 for(i=0;i<100;i++)
 {
  SetAPen(r,i%5);

  PrintAt(r,319-tw,yprintpos,"w");
  for(xt=0;xt<tw;xt+=(1+i%tw))
  {
    ScrollRaster(r,(1+i%tw),0,tw-xt,ymin_scrollraster,319-xt,199);
    WaitTOF();
  }
 }


 };

 /* ======einde in stijl !====== */
einde=0; /* init einde op 0 ! */
while (einde != 1)
 {
  Wait(1<<NoBorder->UserPort->mp_SigBit);

  while((mesg=(struct IntuiMessage *)
      GetMsg(NoBorder->UserPort))!=NULL)
  {
   ReplyMsg(mesg);
   mclass=mesg->Class;
  }

  if(mclass==MOUSEBUTTONS)
   {
     einde=1;
     Delay(10);

     CloseLibrary(GfxBase);
     CloseWindow(NoBorder);
     CloseScreen(Scrn);

   }
 }

} /********************************** einde van main **********************/

VOID OpenALL()
{
 /*==Intuition==*/

 IntuitionBase=(struct IntuitionBase *)
            OpenLibrary("intuition.library",INTUITION_REV);

 if(IntuitionBase==NULL)
    exit(FALSE);

 /*==Graphics Library==*/

 GfxBase=(struct GfxBase *)
          OpenLibrary("graphics.library",GRAPHICS_REV);

 if(GfxBase==NULL)
    exit(FALSE);

}


PrintAt(rast,x,y,s)
struct RastPort *rast;
int x,y;
char *s;
{
 Move(rast,x,y);
 Text(rast,s,strlen(s));
}

