#include <graphics/gfxbase.h>
#include <intuition/intuition.h>

struct IntuitionBase   *IntuitionBase;
struct GfxBase         *GfxBase;
struct Window  *win, *OpenWindow();


struct NewWindow windef = {
   0, 0, 320, 200,
   0, 1,
   CLOSEWINDOW,
   NULL,
   NULL, NULL, NULL,
   NULL,
   NULL,
   100, 50, 320, 200,
   CUSTOMSCREEN
};

long window (scr,ti,x,y,x1,y1,type)
long scr,x,y,x1,y1,type;
char *ti;
{
char *OpenLibrary();
long q;

q=0;
if ((type & 1)==1) q=q | WINDOWDRAG;
if ((type & 2)==2) q=q | WINDOWCLOSE;
if ((type & 4)==4) q=q | WINDOWDEPTH;
if ((type & 8)==8) q=q | WINDOWSIZING;
if ((type & 16)==16) q=q | BACKDROP;
if ((type & 32)==32) q=q | ACTIVATE;
if ((type & 64)==64) q=q | REPORTMOUSE;
if ((type & 128)==128) q=q | SIMPLE_REFRESH;
if ((type & 256)==256) q=q | SMART_REFRESH;
if ((type & 512)==512) q=q | NOCAREREFRESH;
if ((type & 1024)==1024) q=q | ACTIVEWINDOW;
if ((type & 2048)==2048) q=q | INACTIVEWINDOW;
if ((type & 4096)==4096) q=q | GIMMEZEROZERO;
if ((type & 8192)==8192) q=q | BORDERLESS;

windef.Flags=q;
windef.LeftEdge=x;
windef.TopEdge=y;
windef.Width=x1;
windef.Height=y1;
windef.Title=ti;


   if (!(IntuitionBase = (struct IntuitionBase *)
      OpenLibrary ("intuition.library", 1L))) {
         exit (FALSE);
   }

   if (!(GfxBase = (struct GfxBase *)
      OpenLibrary ("graphics.library", 1L))) {
         exit (FALSE);
   }

   windef.Screen = scr;
   if (!(win = OpenWindow (&windef))) {
         exit (FALSE);
   }
return (win);
}
