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

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

USHORT bs1smallData[] =
{
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0xffff,0xffff,0xfffF,0xffff,0x0000,
0x0000,0xff11,0x2121,0x1212,0x11ff,0x0000,
0x0000,0xf425,0x0000,0x0000,0x524f,0x0000,
0x0000,0xfa00,0x0000,0x0000,0x00af,0x0000,
0x0000,0xf425,0x0000,0x0000,0x524f,0x0000,
0x0000,0xff11,0x2121,0x1212,0x11ff,0x0000,
0x0000,0xffff,0xffff,0xfffF,0xffff,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,

0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,
0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,
0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,
0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,
0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,
0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,
0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,
0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,
0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,
0xffff,0x0000,0x0000,0x0000,0x0000,0xffff,
0xffff,0x0000,0x0000,0x0000,0x0000,0xffff,
0xffff,0x0000,0x0000,0x0000,0x0000,0xffff,
0xffff,0x0000,0x0000,0x0000,0x0000,0xffff,
0xffff,0x0000,0x0000,0x0000,0x0000,0xffff,
0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,
0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,
0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,
0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,
0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,
0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,
0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,
0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,
0xffff,0xffff,0xffff,0xffff,0xffff,0xffff
};

struct Image bs1small =
{
0,0,          /* LeftEdge, TopEdge */
87,23,2,     /* Width, Height, Depth */
&bs1smallData[0],
3,0,       /* PlanePick, PlaneOnOff */
NULL        /* Pointer to next Image */
};



#define INTUITION_REV 0
#define GRAPHICS_REV 0
main()
{
 ULONG flags,mclass;
 SHORT x,y,w,h,d;
 USHORT mode;
 UBYTE *name,c0,c1;
 VOID OpenALL();
 OpenALL();

 
 /* ======Open een lores custom screen====== */

 y=0;
 w=320;
 h=200;
 d=2; /* max 32 colors ! */
 c0=0x00;
 c1=0x01;
 mode=NULL;

 Scrn=(struct Screen *)
         make_screen(y,w,h,d,c0,c1,mode,NULL);

 /* ======open een borderless window ====== */

 x=y=0;
 w=320;
 h=200;
 flags=ACTIVATE|NOCAREREFRESH|BORDERLESS|GIMMEZEROZERO;
 NoBorder=(struct Window *)
             make_window(x,y,w,h,NULL,flags,Scrn);

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

 ClearMenuStrip(NoBorder);


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

 SetRGB4(r,0,0,0,0);
 SetRGB4(r,1,15,15,15);
 SetRGB4(r,2,0,0,15);
 SetRGB4(r,3,7,7,7);


for(;;)
{
 for(y=0, h=0;h<100;h+=23)
 {
  for(x=h;x<(320-87-h);x+=40)
  {
   DrawImage(r,&bs1small,(LONG) x, (LONG) y );
   DrawImage(r,&bs1small,(LONG) (320-87-x), (LONG) (199-23-y) );
   Delay(1L);
  }
  for(y=h;y<(199-23-h);y+=13)
  {
   DrawImage(r,&bs1small,(LONG) x, (LONG) y );
   DrawImage(r,&bs1small,(LONG) (320-87-x), (LONG) (199-23-y) );
   Delay(1L);
  }
  for(x=(320-87-h);x>=h;x-=40)
  {
   DrawImage(r,&bs1small,(LONG) x, (LONG) y );
   DrawImage(r,&bs1small,(LONG) (320-87-x), (LONG) (199-23-y) );
   Delay(1L);
  }
  for(y=(199-23-h);y>=h;y-=13)
  {
   DrawImage(r,&bs1small,(LONG) x, (LONG) y );
   DrawImage(r,&bs1small,(LONG) (320-87-x), (LONG) (199-23-y) );
   Delay(1L);
  }
 }
 if( (mesg=(struct IntuiMessage *) GetMsg(NoBorder->UserPort)) != NULL)
 {
  ReplyMsg(mesg);
  break;
 }
}


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

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

}
 /*========================================================================*/

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

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

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

 /* ======open the Graphics Library====== */

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

 if(GfxBase==NULL)
   exit(FALSE);
 }
make_window(x,y,w,h,name,flags,screen)
SHORT x,y,w,h;
UBYTE *name;
ULONG flags;
struct Screen *screen;

{
 struct NewWindow NewWindow;

 NewWindow.LeftEdge = x;
 NewWindow.TopEdge = y;
 NewWindow.Width = w;
 NewWindow.Height = h;
 NewWindow.DetailPen = -1;
 NewWindow.BlockPen = -1;
 NewWindow.Title = name;
 NewWindow.Flags = flags;
 NewWindow.IDCMPFlags = MOUSEBUTTONS;
 NewWindow.Type = CUSTOMSCREEN;
 NewWindow.FirstGadget = NULL;
 NewWindow.CheckMark = NULL;
 NewWindow.Screen = screen;
 NewWindow.BitMap = NULL;
 NewWindow.MinWidth = 0;
 NewWindow.MinHeight = 0;
 NewWindow.MaxWidth = 0;
 NewWindow.MaxHeight = 0;

 return(OpenWindow(&NewWindow));

}


make_screen(y,w,h,d,color0,color1,mode,name)
SHORT y,w,h,d;
UBYTE color0,color1,*name;
USHORT mode;
{
 struct NewScreen NewScreen;

 NewScreen.LeftEdge = 0;
 NewScreen.TopEdge = y;
 NewScreen.Width = w;
 NewScreen.Height = h;
 NewScreen.Depth = d;
 NewScreen.DetailPen = color0;
 NewScreen.BlockPen = color1;
 NewScreen.ViewModes = mode;
 NewScreen.Type = CUSTOMSCREEN;
 NewScreen.Font = NULL;
 NewScreen.DefaultTitle = name;
 NewScreen.Gadgets = NULL;
 NewScreen.CustomBitMap = NULL;

 return(OpenScreen(&NewScreen));
}


