/* plot2.h--definitions, etc with a little help from Lattice et al */

#include "exec/types.h"
#include "exec/nodes.h"
#include "exec/lists.h"
#include "exec/ports.h"
#include "exec/devices.h"
#include "devices/keymap.h"
#include "graphics/regions.h"
#include "graphics/copper.h"
#include "graphics/gels.h"
#include "graphics/gfxbase.h"
#include "graphics/gfx.h"
#include "graphics/sprite.h"
#include "graphics/clip.h"
#include "graphics/view.h"
#include "graphics/rastport.h"
#include "graphics/layers.h"
#include "libraries/dos.h"
#include "lattice/stdio.h"
#include "lattice/math.h"
#include "intuition/intuition.h"
#include "hardware/dmabits.h"
#include "hardware/custom.h"
#include "hardware/blit.h"
#include "graphics/text.h"
#define NL 0
long GfxBase = 0;   /* Base of graphics library */
long IntuitionBase = 0;      /* Base of Intuition library */
struct Window *OpenWindow();
struct InputEvent *Intuition();
struct Screen *OpenScreen();
struct TextAttr TestFont = {
   "topaz.font",TOPAZ_SIXTY,FS_NORMAL,FPF_ROMFONT, /* Define text font for screen */
   };
USHORT class;   /* Intu event class */
USHORT code;   /* Intu event code */
struct Window *w;      /* Lots of pointers for lots of things */
struct RastPort *rp;
struct ViewPort *vp;
struct Screen *screen;
#define  height 14
struct SpriteImage {
UWORD posctl[2];
UWORD sprdata[2][height];
UWORD reserved[2];
};

/********************Sprite-Pointer-Defines*********************/

struct SpriteImage PointImage = {
   100,100,
   0x0000, 0x3ffe,
   0x0000, 0x3ffe,
   0x0080, 0x3ffe,
   0x0080, 0x1ffc,
   0x0080, 0x1ffc,
   0x0080, 0x0ff8,
   0x0080, 0x0ff8,
   0x0000, 0x07f0,
   0x0080, 0x07f0,
   0x0080, 0x07f0,
   0x0000, 0x03e0,
   0x0000, 0x03e0,
   0x0000, 0x01c0,
   0x0000, 0x0080,
   NULL,NULL
};
struct SpriteImage CursorImage = {
   100,100,
   0x0000, 0x0000,
   0x0000, 0x0100,
   0x0000, 0x0100,
   0x0000, 0x0100,
   0x0000, 0x0100,
   0x0000, 0x0100,
   0x0000, 0x0100,
   0x0000, 0xffff,
   0x0000, 0x0100,
   0x0000, 0x0100,
   0x0000, 0x0100,
   0x0000, 0x0100,
   0x0000, 0x0100,
   0x0000, 0x0100,
   NULL,NULL
};

int MathBase;
int MathTransBase;
union kludge1
{
   FLOAT num1;
   int i1;
} k1;
union kludge2
{
   FLOAT num2;
   int i2;
} k2;
union kludge3
{
   FLOAT num3;
   int i3;
} k3;
union kludge4
{
   FLOAT num4;
   int i4;
} k4;
union kludge5
{
   FLOAT num5;
   int i5;
} k5;
union kludge6
{
   FLOAT num6;
   int i6;
} k6;
/************************ Screen Defines ***********************************/

struct NewScreen ns = {
   0,0,         /* start pos.*/
   640,400,2,      /* width height depth (2 bit planes) */
   0,1,         /* detail pen, block pen */
   HIRES | LACE,       /* viewing mode (hires interlaced 640x400) */
   CUSTOMSCREEN,      /* screen type */
   &TestFont,      /* font */
   NULL,      /* screen title */
   NULL,
   NULL,      /* gadget pointer */
   };

/************************ Window Defines ***********************************/

struct NewWindow nw = {
      0,0,         /* Starting corner */
      640,400,      /* Width, height */
      0,3,         /* detail, block pens */
      CLOSEWINDOW | MENUPICK
      | REFRESHWINDOW | MOUSEBUTTONS | MOUSEMOVE,         /* IDCMP flags */
      SMART_REFRESH | ACTIVATE | BORDERLESS | WINDOWCLOSE
      | REPORTMOUSE | GIMMEZEROZERO,
               /* Window flags */
      NULL,         /* Pointer to first gadget */
      NULL,         /* Pointer to checkmark */
      "PLOT3D",      /* title */
      NULL,         /* screen pointer */
      NULL,         /* bitmap pointer */
      0,0,0,0,      /* sizing limits */
      CUSTOMSCREEN      /* type of screen */
      };
/************************ Set-Up routine ***********************************
*   This function opens the Intuition and Graphics libraries, then     *
*       opens up our custom screen and window, defining screen colors,     *
*   size, etc...                        *
***************************************************************************/
initwind()
{

   GfxBase = OpenLibrary("graphics.library",0); /* Get graphics driver */
   if(GfxBase == NULL)
   {
      printf("Can't open graphics library...\n");
      exit();
   }
   if((MathBase=OpenLibrary("mathffp.library",0)) < 1) {
      printf("n\n*** ERROR *** Can't open mathffp.library");
      exit();
   }
   if((MathTransBase=OpenLibrary("mathtrans.library",0)) < 1) {
      printf("n\n*** ERROR *** Can't open mathtrans.library");
      exit();
   }
   IntuitionBase = OpenLibrary("intuition.library",0); /*Get Intuition*/  
   if(IntuitionBase == NULL)
   {
      printf("Can't open intuition library...\n");
      exit();
   }
   screen = OpenScreen(&ns); /* Open our new screen */
   if(screen == NULL)
   {
      exit(0);
   }
   nw.Screen = screen;
   w = OpenWindow(&nw);      /* Open our new window */
   rp = w->RPort;         /* Get the raster port pointer */
   vp = &screen->ViewPort;   /* Get the view port pointer */
   SetDrMd(rp,JAM1);
}

