/* tdp.h */

#include <stdio.h>
#include <exec/types.h>
#include <exec/lists.h>
#include <intuition/intuition.h>
#include <graphics/text.h>
#include "ffp.h"

#define MAXCHAN 64
#define MAXPOINTS (MAXCHAN * MAXCHAN)
#define RLARGE 1.E10
#define DEG2RAD (PI/180.)
#define MAXHORIZ 600
#define MAXVERT 380
#define TOPVERT 400
#define RESET 0
#define UP 1
#define DOWN -1
#define DATA 1
#define INTERP 2
#define BIGINT 2147483000
#define BACKGND_COLOR 0
#define PASS_0_COLOR 1
#define PASS_1_COLOR 3
#define AXIS_COLOR 2

void pen();
void hlplot();
void hlcross();
void plot3d();
void calc();
char *getwrd();
void initwind();
void CleanUp();
extern struct GfxBase *GfxBase;
extern struct IntuitionBase *IntuitionBase;

# ifdef MAIN_MODULE
FFP zd[MAXPOINTS], d2r;
FFP xA[4], yA[4], zA[4]; /* AXES */
int xA_i[4], yA_i[4];
FFP sinp, cosp, sint, cost;
int x[MAXCHAN][MAXCHAN], y[MAXCHAN][MAXCHAN];
short vhicum[MAXHORIZ], vlocum[MAXHORIZ];
int debug = 0, inverse_vid = 0, nsides = 1;
int PlotFile = FALSE, To_mCAD = FALSE;
FILE *pfp, *mfp;
char ans, str[20];
FFP phi, theta;
int nxpts=0, nypts=0;
char netplot='y', axes='n';
struct Window *OpenWindow();
struct Screen *OpenScreen();
USHORT class, code;
struct Window *w;
struct RastPort *rp;
struct ViewPort *vp;
struct IntuiMessage *message;
struct Screen *screen;
# else

extern FFP zd[MAXPOINTS], d2r;
extern FFP xA[], yA[], zA[]; /* AXES */
extern int xA_i[], yA_i[];
extern FFP sinp, cosp, sint, cost;
extern int x[MAXCHAN][MAXCHAN], y[MAXCHAN][MAXCHAN];
extern short vhicum[MAXHORIZ], vlocum[MAXHORIZ];
extern int debug, inverse_vid, nsides;
extern int PlotFile, To_mCAD;
extern FILE *pfp, *mfp;
extern char ans, str[];
extern FFP phi, theta;
extern int nxpts, nypts;
extern char netplot, axes;
extern struct Window *OpenWindow();
extern struct Screen *OpenScreen();
extern USHORT class, code;
extern struct Window *w;
extern struct RastPort *rp;
extern struct ViewPort *vp;
extern struct IntuiMessage *message;
extern struct Screen *screen;
#endif

#ifdef MAIN_MODULE
struct NewScreen ns = {
   0,0,640,400,2,0,3,HIRES | LACE,CUSTOMSCREEN,NULL,"TDP",NULL
};

struct NewWindow nw = {
   0,0,640,400,0,3,MENUPICK,ACTIVATE|BORDERLESS|NOCAREREFRESH,
   NULL,NULL,NULL,NULL,NULL,0,0,0,0,CUSTOMSCREEN
};

#define MIFlags (ITEMENABLED | ITEMTEXT | HIGHCOMP)
#define ChH 8
#define ChW 8

/*** MENU 0 -- PROJECT ****************************************************/
struct IntuiText M_text03 = {1,14,JAM2,0,0,NULL,"Quit    ",NULL};
struct MenuItem M_item03 =
   {NULL,0,3*ChH,ChW*8,ChH,MIFlags,0L,(APTR)&M_text03,NULL,NULL,NULL,0};
#define MI_QUIT 3

struct IntuiText M_text02 = {1,14,JAM2,0,0,NULL,"To mCAD ",NULL};
struct MenuItem M_item02 =
   {&M_item03,0,2*ChH,ChW*8,ChH,MIFlags,0L,(APTR)&M_text02,NULL,NULL,NULL,0};
#define MI_TOMCAD 2

struct IntuiText M_text01 = {1,14,JAM2,0,0,NULL,"Plot    ",NULL};
struct MenuItem M_item01 =
   {&M_item02,0,ChH,ChW*8,ChH,MIFlags,0L,(APTR)&M_text01,NULL,NULL,NULL,0};
#define MI_PLOT 1

struct IntuiText M_text00 = {1,14,JAM2,0,0,NULL,"Open    ",NULL};
struct MenuItem M_item00 =
   {&M_item01,0,0,ChW*8,ChH,MIFlags,0L,(APTR)&M_text00,NULL,NULL,NULL,0};
#define MI_OPEN 0

struct Menu Menu0 =
   {NULL,0,0,ChW*8,ChH,MENUENABLED,"Project ",&M_item00};
#define M_PROJECT 0

void initwind()
{
   if (!(GfxBase = (struct GfxBase *)OpenLibrary("graphics.library",0)))
      {printf("Can't open graphics library...\n"); exit();}
   if (!(IntuitionBase =
         (struct IntuitionBase *)OpenLibrary("intuition.library",0)))
      {printf("Can't open intuition library...\n"); exit();}
   if (!(screen = OpenScreen(&ns)))
      {printf("Can't open screen...\n"); exit(0);}

   nw.Screen = screen;
   if (!(w = OpenWindow(&nw)))
      {printf("Can't open window...\n"); exit(0);}
   rp = w->RPort; vp = &w->WScreen->ViewPort;
   SetRGB4(vp,AXIS_COLOR, 15, 0, 0); SetRGB4(vp,PASS_1_COLOR, 0, 0,15);
   SetDrMd(rp,JAM1); SetAPen(rp,PASS_0_COLOR);
   SetMenuStrip(w,&Menu0); ShowTitle(screen,FALSE);
}

void CleanUp()
{
   ClearMenuStrip(w); CloseWindow(w); CloseScreen(screen);
   CloseLibrary(GfxBase); CloseLibrary(IntuitionBase);
}
#endif
