/* Definitionen für PlotMap */

#include <stdio.h>
#include <mffp.h>

#define VERSION "0.85"
#define DATE "23.7.92"

//#define REXXPORTNAME "plotmap_rexx"

extern struct ExecBase *SysBase;
//extern struct RxsLib *RexxSysBase;
extern struct IntuitionBase *IntuitionBase;
extern struct GfxBase *GfxBase;
extern struct Library *GadToolsLibrary;

extern UBYTE *screen_title;
extern struct Window *main_wd;
extern UWORD chip mouse_wait_data[], chip mouse_cross_data[];

#define RE     6378.165                /* radius of Earth (kilometers) */
#define PI     3.141592653589793       /* define constants */
#define PI2    (PI/2.0)
#define TWOPI  (2.0*PI)
#define RAD    (PI/180.0)


#define MOUSE_NORMAL ClearPointer(main_wd)
#define MOUSE_WAIT SetPointer(main_wd, mouse_wait_data, 16, 16, -6, 0)
#define MOUSE_CROSS SetPointer(main_wd, mouse_cross_data, 13, 13, -7, -6)

#define TITLE_NORMAL SetWindowTitles(main_wd, (UBYTE *)-1, screen_title)
#define TITLE_MSG(s) SetWindowTitles(main_wd, (UBYTE *)-1, s)
#define TITLE_ERROR(s) { SetWindowTitles(main_wd, (UBYTE *)-1, s); DisplayBeep(NULL); }

#define IDCMP(f) ModifyIDCMP(main_wd, f);
#define NORMAL_IDCMP (IDCMP_MENUPICK | IDCMP_INTUITICKS)

#define RMBTRAP_ON main_wd->Flags |= WFLG_RMBTRAP
#define RMBTRAP_OFF main_wd->Flags &= ~WFLG_RMBTRAP
#define REPORTMOUSE_ON main_wd->Flags |= WFLG_REPORTMOUSE
#define REPORTMOUSE_OFF main_wd->Flags &= ~WFLG_REPORTMOUSE

#define Line(rp, x1,y1, x2,y2) {Move(rp, x1,y1); Draw(rp, x2,y2);}
#define LineTo(rp, x,y) Draw(rp, x,y)

#define DL_HIGH         1              /* defs for detail level */
#define DL_MEDIUMHIGH   2
#define DL_MEDIUM       3
#define DL_MEDIUMLOW    4
#define DL_LOW          5
#define DL_AUTO_HIGH    7              /* 7 because of NM_BARLABEL */
#define DL_AUTO_MEDIUM  8
#define DL_AUTO_LOW     9

#define MAX_DETAIL_LEVEL 5

#define MAP_PLANE (1<<8)
#define MAP_BOX (1<<9)
#define MAP_SPHERE (1<<10)
#define MAP_MASK 0x00ff
#define MAP_FLAT 1
#define MAP_MERCATOR 2
#define MAP_GLOBE 3
#define MAP_ORBITAL 4


struct point
{                                      /* format for each point */
   WORD code;
   WORD lat, lam;
};

struct arc
{                                      /* format for limits in */
   WORD lat_min, lat_max;              /* each segment */
   WORD lam_min, lam_max;
   ULONG first, last;
};

struct mapinfo
{                                      /* format for general map info   */
   char *mapname;                      /* map file name                 */
   ULONG numpts;                       /* number of points in map       */
   UWORD nsegs;                        /* number of segments in map     */
   UWORD first_seg;                    /* location in big segment array */
   struct point *pt;                   /* address of points buffer      */
   struct arc *seg;                    /* address of segment buffer     */
};

#define NUM_MAPS 6
#define NSEGS (208+301+111+344+103+196)   /* number of segments */

struct config
{
   WORD scr_depth;
   BOOL superhires, interlace, overscan;
   WORD mode;
   UBYTE fontname[30];
   UWORD fontsize;
   UWORD colormap[16];
   BOOL cls_before_draw, flood_fill;
   BOOL coord_window, coord_mousexy, coord_degree;
   WORD coord_wdx, coord_wdy;
   double vfac;
   WORD detail_level;
   BOOL loadmap[NUM_MAPS], plotmap[NUM_MAPS];
   UBYTE bg_color, ocean_color, mapcolor[NUM_MAPS];
   UBYTE grid_color, gridhigh_color, shadow_color;
   UBYTE line_color, box_color, text_color, flood_color;
};

