home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 523b.lha / Drawmap_v2.25d / Sources.LZH / Sources / drawmap.h < prev    next >
C/C++ Source or Header  |  1991-06-10  |  13KB  |  485 lines

  1. /*  File drawmap.h  */
  2.  
  3. #define MAX(a,b) ((a)>=(b) ? (a) : (b))
  4. #define ABS(a) ((a)>=0 ? (a) : (-(a)))
  5.  
  6. #define BITVAL(x,n)  ((x>>n)&1)
  7. #define BITSETT(x,n)  (x | bitval[n])
  8. #define BITCLEAR(x,n)  (x & (~bitval[n]))
  9. #define BITSTORE(x,n,val)  ((val==0) ? (x=BITCLEAR(x,n)) : (x=BITSETT(x,n)))
  10.  
  11. #define SHADOW_DISP  4                 /* shadow displacement (pix) */
  12.  
  13. #define WC WINDOWCLOSE
  14. #define WDP WINDOWDEPTH
  15.  
  16. #define IDCMPFLAGS (CLOSEWINDOW | RAWKEY | MOUSEBUTTONS | MENUPICK)
  17.  
  18. #define WYOFFS 10                      /* Y-Offset between 0,0 coord. */
  19.                                        /* on Screen and Window        */
  20. #define WWIDTH 640                     /* window width (pixels)       */
  21. #define WHEIGHT 390                    /* window height (pixels)      */
  22. #define SHEIGHT 400                    /* SCREEN height               */
  23. #define VMODE (HIRES | LACE)           /* view mode                   */
  24. #define DEPTH 2                        /* 4 colors => 2 bitplanes     */
  25.  
  26. #define CENTERX WWIDTH/2               /* place origin at center of   */
  27. #define CENTERY (WHEIGHT)/2            /*   window                    */
  28. #define NUMPTS 2100                    /* max. no. points per area    */
  29. #define MAXVAL 17718                   /* number of words in map      */
  30. #define MAXTIDY 380                    /* number of words in map-tidy */
  31. #define HFACTOR (WWIDTH/360.)          /* horizontal scale (pix/deg)  */
  32. #define VFACTOR ((WHEIGHT)/180.)       /* vertical scale (pix/deg)    */
  33. #define M_VFACTOR ((WHEIGHT)/4.87) /* vertical scale for Mercator */
  34.                                        /*   map (+/- 80 degrees lat.) */
  35. #define ASP_RAT ((640./400.)*(188./260.)) /* screen aspect ratio      */
  36.                                        /*  (max width / max hgt)      */
  37. #define VRADIUS 160                    /* vertical radius of ellipse  */
  38.                                        /*   (pixels)                  */
  39. #define HRADIUS (short)(ASP_RAT * VRADIUS+0.5) /* horiz. radius (pix) */
  40.  
  41. #define FILL   1                       /* fill area outlines       */
  42. #define NOFILL 0                       /* don't fill area outlines */
  43.  
  44. #define OK     1                       /* result flags */
  45. #define NOT_OK 0
  46.  
  47. #define BLUE      0L                   /* workbench colors */
  48. #define BLACK     2L
  49. #define WHITE     3L
  50. #define ORANGE    1L
  51. #define GLOBE_FILL_MIN 5               /* min # points in area to be */
  52.                                        /*   color-filled on globe    */
  53.  
  54. #define RE 6378.165                    /* radius of Earth (kilometers) */
  55. #define VIEW_HEIGHT 600.               /* height above Earth to view   */
  56.                                        /*   globe (km)                 */
  57. #define MIN_HEIGHT 10.                 /* minimum view height (km)     */
  58.  
  59. UWORD mapcolors[] = {
  60.    0x000C, 0x0F60, 0x0002, 0x0FFF,
  61.    0x038f, 0x0b51, 0x0000, 0x0fff,
  62.    0x0f91, 0x0fff, 0x0000, 0x009b,
  63.    0x0e6f, 0x0000, 0x0901, 0x0fff,
  64.    0x0caf, 0x0fff, 0x0000, 0x07e2,
  65.    0x00e2, 0x0f6e, 0x0000, 0x00ef,
  66.    0x0ff0, 0x003f, 0x0520, 0x0ae9,
  67.    0x069e, 0x0192, 0x0000, 0x0fff,
  68.    0x0aaa, 0x0eef, 0x0000, 0x0fff,
  69. };
  70.  
  71. #define num_colors sizeof(mapcolors)/2  /* number of colors in color table */
  72.  
  73. #define mapname      "map.bin"       /* names of files containing */
  74. #define mapname_trig "map-trig.bin"  /*   map data                */
  75. #define tdname       "map-tidy.bin"
  76. #define tdname_trig  "map-tidy-trig.bin"
  77.  
  78. double view_height, eta, etap, facp;   /* declare global constants */
  79.  
  80.  
  81. /*
  82. double pi = 3.141592653589793;
  83. double rad, pi2, twopi;
  84. */
  85.  
  86.  
  87. #define pi 3.141592653589793
  88. #define pi2 (pi/2.)                        /* initialize constants */
  89. #define twopi (2.*pi)
  90. #define rad (pi/180.)
  91. /*   pi2 = pi/2.;                       *  initialize constants *
  92.    twopi = 2.*pi;
  93.    rad = pi/180.; */
  94.  
  95. int lakes[] = { 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
  96.    145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156 };
  97.  
  98. #define num_lakes (sizeof(lakes) / sizeof(int))
  99.  
  100. char fontname[] = "topaz.font";        /* screen font name */
  101.  
  102. struct TextAttr mapfont = {            /* screen font */
  103.    (STRPTR) &fontname, 8, 0, 0
  104. };
  105.  
  106. struct NewScreen mapscreen = {
  107.    0,                                  /* left edge of screen     */
  108.    0,                                  /* top edge of screen      */
  109.    WWIDTH, SHEIGHT,                    /* width, height of screen */
  110.    DEPTH,                              /* 4 colors                */
  111.    2, 1,                               /* detail pen, block pen   */
  112.    VMODE,                              /* view mode               */
  113.    CUSTOMSCREEN,                       /* type of screen          */
  114.    &mapfont,                           /* screen font             */
  115.    "    Drawmap V. 2.30d, by Bryan Brown",   /* screen title            */
  116.    NULL,
  117.    NULL
  118. };
  119.  
  120. struct NewWindow mapWindow = {
  121.    0,
  122.    10,
  123.    WWIDTH, WHEIGHT,                    /* Width, Height of this window  */
  124.    3,
  125.    2,
  126.    NULL,                               /* IDCMP Flags, NONE at the Moment */
  127.    SMART_REFRESH|ACTIVATE|BACKDROP|BORDERLESS|REPORTMOUSE,
  128.                                        /* Window Flags                  */
  129.    NULL,                               /* FirstGadget                   */
  130.    NULL,                               /* CheckMark                     */
  131.    NULL,                               /* Window title                  */
  132.    NULL,                               /* Pointer to Screen if not
  133.                                           workbench                     */
  134.    NULL,                               /* Pointer to BitMap if a
  135.                                           SUPERBITMAP window            */
  136.    10, 10,                             /* minimum width, minimum height */
  137.    WWIDTH, WHEIGHT,                    /* maximum width, maximum height */
  138.    CUSTOMSCREEN
  139. };
  140.  
  141. struct NewWindow maptitleWindow = {
  142.     0, 0,
  143.     24, 10,
  144.     3, 2,
  145.     NULL, /* NO IDCMP, initialized after creating own IDCMPport */
  146.     SMART_REFRESH | BORDERLESS | WINDOWCLOSE | RMBTRAP ,
  147.     0,0,
  148.     NULL,
  149.      0,0, 0,0,0,0,CUSTOMSCREEN };
  150.  
  151.  
  152. #ifdef LATTICE
  153. UWORD chip arrow[] = {                 /* mouse pointer = arrow  */
  154. #define arrow_data arrow
  155. #else
  156. UWORD arrow_data[] = {                 /* mouse pointer = arrow  */
  157. #endif
  158.    0x0000, 0x0000,
  159.  
  160.    0x8000, 0x0000,
  161.    0xc000, 0x0000,
  162.    0xe000, 0x0000,
  163.  
  164.    0xf000, 0x0000,
  165.  
  166.    0xe000, 0x0000,
  167.    0x2000, 0x0000,
  168.    0x0000, 0x0000,
  169.  
  170.    0x0000, 0x0000
  171. };
  172.  
  173. #define arrow_x_offset  -1
  174. #define arrow_y_offset  0
  175. #define arrow_size      sizeof(arrow_data)
  176.  
  177. #ifdef LATTICE
  178. UWORD chip cross[] = {                 /* mouse pointer = cross */
  179. #define cross_data cross
  180. #else
  181. UWORD cross_data[] = {                 /* mouse pointer = cross */
  182. #endif
  183.    0x0000, 0x0000,
  184.    0x0000, 0x0000,
  185.  
  186.  
  187.    0x0400, 0x0000,
  188.    0x0400, 0x0000,
  189.    0x0400, 0x0000,
  190.    0x0400, 0x0000,
  191.    0x0000, 0x0000,
  192.  
  193.    0xf1e0, 0x0000,
  194.  
  195.    0x0000, 0x0000,
  196.    0x0400, 0x0000,
  197.    0x0400, 0x0000,
  198.    0x0400, 0x0000,
  199.    0x0400, 0x0000,
  200.  
  201.    0x0000, 0x0000
  202. };
  203.  
  204. #define cross_x_offset  -6
  205. #define cross_y_offset  -6
  206. #define cross_size      sizeof(cross_data)
  207. #ifdef LATTICE
  208. UWORD chip waiter[] = {                /* mouse pointer = 'wait' */
  209. #define waiter_data waiter
  210. #else
  211. UWORD waiter_data[] = {                /* mouse pointer = 'wait' */
  212. #endif
  213.  
  214.    0x0000, 0x0000,
  215.  
  216.    0x8800, 0x0000,
  217.    0x8800, 0x0000,
  218.    0xa800, 0x0000,
  219.    0xa800, 0x0000,
  220.    0x5000, 0x0000,
  221.  
  222.    0x0e00, 0x0000,
  223.    0x0100, 0x0000,
  224.    0x0700, 0x0000,
  225.    0x0940, 0x0000,
  226.    0x0700, 0x0000,
  227.  
  228.    0x00c0, 0x0000,
  229.    0x0040, 0x0000,
  230.    0x0040, 0x0000,
  231.    0x0048, 0x0000,
  232.    0x00e8, 0x0000,
  233.  
  234.    0x001c, 0x0000,
  235.    0x0008, 0x0000,
  236.    0x0008, 0x0000,
  237.    0x000a, 0x0000,
  238.    0x0004, 0x0000,
  239.  
  240.    0x0000, 0x0000
  241. };
  242.  
  243. #define waiter_x_offset  -1
  244. #define waiter_y_offset  0
  245. #define waiter_size      sizeof(waiter_data)
  246. #ifdef LATTICE
  247. UWORD chip transparent[] = {           /* mouse pointer = transparent  */
  248. #define transparent_data transparent
  249. #else
  250. UWORD transparent_data[] = {           /* mouse pointer = transparent  */
  251. #endif
  252.  
  253.    0x0000, 0x0000,
  254.  
  255.    0x0000, 0x0000,
  256.  
  257.    0x0000, 0x0000
  258. };
  259.  
  260. #define transparent_x_offset  0
  261. #define transparent_y_offset  0
  262. #define transparent_size      sizeof(transparent_data)
  263. #ifdef LATTICE
  264. UWORD chip close_data[] = {
  265. #else
  266. UWORD close_data[] = {
  267. #endif
  268. /*------ plane # 0: --------*/
  269.  
  270.   0xffff,   0xfee0,
  271.   0xffff,   0xfce0,
  272.   0xffff,   0xf8e0,
  273.   0xffff,   0xf8e0,
  274.   0xfff8,   0xf8e0,
  275.   0xfff0,   0xf8e0,
  276.   0xffff,   0xf8e0,
  277.   0xffff,   0xf8e0,
  278.   0xf800,   0xe0,
  279.   0xf000,   0xe0,
  280.  /*------ plane # 1: --------*/
  281.  
  282.   0x1fff,   0xff00,
  283.   0x1bff,   0xff00,
  284.   0x1c00,   0x700,
  285.   0x1c00,   0x700,
  286.   0x1c19,   0x700,
  287.   0x1c13,   0x700,
  288.   0x1c00,   0x700,
  289.   0x1c00,   0x700,
  290.   0x1fff,   0xff00,
  291.   0x1fff,   0xff00
  292.  
  293. };
  294.  
  295.  
  296.  
  297.  
  298. #define close_size      sizeof(close_data)
  299.  
  300.  struct  Image closeimage =
  301.  {
  302.  0,0,
  303.  27 , 10 , 2 ,
  304.  &close_data[0],
  305.  0x1f,0x00,
  306.  NULL,
  307.  };
  308.  
  309. #ifdef LATTICE
  310. UWORD chip ilbm_data[] = {
  311. #else
  312. UWORD ilbm_data[] = {
  313. #endif
  314.  
  315. /*------ plane # 0: --------*/
  316.  
  317.   0x54,   0x0,
  318.   0x503,   0x0,
  319.   0x591,   0xc000,
  320.   0x2700,   0xa000,
  321.   0xde0,   0x1000,
  322.   0x9f80,   0x7800,
  323.   0x8f00,   0xf800,
  324.   0x8900,   0xf800,
  325.   0x400,   0xf800,
  326.   0x83e0,   0x3000,
  327.   0x1f8,   0x0,
  328.   0x20f0,   0x0,
  329.   0x480,   0x0,
  330.   0x0,   0x0,
  331.  /*------ plane # 1: --------*/
  332.  
  333.   0x0,   0x0,
  334.   0x102,   0x8000,
  335.   0x591,   0xf000,
  336.   0x700,   0xb800,
  337.   0xde0,   0x1c00,
  338.   0x1f80,   0x7e00,
  339.   0xf00,   0xfe00,
  340.   0x900,   0xfe00,
  341.   0x400,   0xfe00,
  342.   0x3e0,   0x3e00,
  343.   0x1f8,   0x1800,
  344.   0xf0,   0x3000,
  345.   0x80,   0xc000,
  346.   0xaa,   0x0,
  347.   };
  348.  
  349. #define ilbm_size      sizeof(ilbm_data)
  350.  
  351.  struct  Image ilbmimage =
  352.  {
  353.  0,0,
  354.  23 , 14 , 2 ,
  355.  &ilbm_data[0],
  356.  0x03,0x00,
  357.  NULL,
  358.  };
  359.  
  360. struct DiskObject ILBMobject = {
  361.    WB_DISKMAGIC,
  362.    WB_DISKVERSION,
  363.  
  364.    /* Gadget Structure */
  365.    NULL,                    /* Ptr to next gadget */
  366.    0,0,                     /* Leftedge, Topedge */
  367.    23,14,                   /* Width, Height */
  368.    GADGHCOMP|GADGIMAGE,               /* Flags */
  369.    RELVERIFY|GADGIMMEDIATE, /* Activation */
  370.    BOOLGADGET,              /* Type */
  371.    (APTR)&ilbmimage,        /* Render */
  372.    NULL,                    /* Select Render */
  373.    NULL,                    /* Text */
  374.    NULL,NULL,NULL,NULL,     /* Exclude, Special, ID, UserData */
  375.  
  376.    WBPROJECT,               /* WBObject type */
  377.    ":c/viewilbm",            /* Default tool */
  378.    NULL,                    /* Tool Types */
  379.    NO_ICON_POSITION,        /* Current X */
  380.    NO_ICON_POSITION,        /* Current Y */
  381.    NULL,NULL,NULL,          /* Drawer, ToolWindow, Stack */
  382.    };
  383.  
  384.  
  385. struct IntuiText hailtexte = {
  386.         ORANGE,0,JAM1,
  387.         16,36,
  388.         NULL,
  389.         "Bryan Brown & Ulrich Denker ",
  390.         NULL
  391. };
  392. struct IntuiText hailtextd = {
  393.         BLACK,0,JAM1,
  394.         19,39,
  395.         NULL,
  396.         "Bryan Brown & Ulrich Denker",
  397.         &hailtexte
  398. };
  399.  
  400.  
  401. struct IntuiText hailtextc = {
  402.         WHITE,0,JAM1,
  403.         0,17,
  404.         NULL,
  405.         "Drawmap",
  406.         &hailtextd
  407. };
  408. struct IntuiText hailtextb = {
  409.         BLACK,ORANGE,JAM2,
  410.         2,19,
  411.         NULL,
  412.         "Drawmap - a FREEWARE program by",
  413.         &hailtextc
  414. };
  415.  
  416. struct IntuiText hailtexta = {
  417.         ORANGE,0,JAM1,
  418.         82,0,
  419.         NULL,
  420.         "Welcome to",
  421.         &hailtextb
  422. };
  423.  
  424. struct IntuiText hailtext = {
  425.         BLACK,0,JAM1,
  426.         83,1,
  427.         NULL,
  428.         "Welcome to",
  429.         &hailtexta
  430. };
  431.  
  432. #define TEXTXOFFS -16
  433. #define TEXTYOFFS -22
  434.  
  435. /* -------- stuff for save() (from Commdore IFF Disk Fish 185) ------- */
  436.  
  437. /* For masking unwanted Viewmodes bits */
  438. #define BADFLAGS  (SPRITES|VP_HIDE|GENLOCK_AUDIO|GENLOCK_VIDEO)
  439. #define FLAGMASK  (~BADFLAGS)
  440. #define CAMGMASK  (FLAGMASK & 0x0000FFFFL)
  441.  
  442. /* Other Stuff for saving the picture */
  443. #define bufsize 512
  444.  
  445. /* ------- stuff for displayhelp(): helpwindowdefs, borders and bufsize */
  446. #define HWIDTH  8*75+2    /* pixel per char * chars per line */
  447. #define HHEIGHT 8*45+2
  448. #define HLEFTEDGE   (WWIDTH-HWIDTH)/2
  449. #define HTOPEDGE    (WHEIGHT-HHEIGHT)/2+WYOFFS/2
  450.  
  451. struct NewWindow newhelpw = {
  452.     HLEFTEDGE, HTOPEDGE,
  453.     HWIDTH, HHEIGHT,
  454.     3,2,
  455.     MOUSEBUTTONS,   /*  idcmp */
  456.     REPORTMOUSE|NOCAREREFRESH, /* flags */
  457.     0,0,
  458.     NULL, /* title */
  459.     NULL, /* screen */
  460.     NULL, 0,0,0,0,  /* bitmap, min/max values */
  461.     CUSTOMSCREEN
  462.    };
  463.  
  464.  
  465. SHORT border_data[] = {
  466.     0,0,
  467.     HWIDTH-1, 0,
  468.     HWIDTH-2, 1,
  469.     1, 1,
  470.     1, HHEIGHT-2,
  471.     0, HHEIGHT-1,
  472.     0,0
  473. };
  474.  
  475. struct Border border = {
  476.     0,0,
  477.     WHITE,0, JAM1,
  478.     (sizeof(border_data)/sizeof(SHORT))/2,
  479.     &border_data[0],
  480.     NULL
  481. };
  482.  
  483. #define HELPBUF 128
  484.  
  485.