home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume42 / astrolog / part02 / astrolog.h next >
C/C++ Source or Header  |  1994-03-25  |  31KB  |  990 lines

  1. /*
  2. ** Astrolog (Version 4.10) File: astrolog.h
  3. **
  4. ** IMPORTANT NOTICE: the graphics database and chart display routines
  5. ** used in this program are Copyright (C) 1991-1994 by Walter D. Pullen
  6. ** (cruiser1@stein.u.washington.edu). Permission is granted to freely
  7. ** use and distribute these routines provided one doesn't sell,
  8. ** restrict, or profit from them in any way. Modification is allowed
  9. ** provided these notices remain with any altered or edited versions of
  10. ** the program.
  11. **
  12. ** The main planetary calculation routines used in this program have
  13. ** been Copyrighted and the core of this program is basically a
  14. ** conversion to C of the routines created by James Neely as listed in
  15. ** Michael Erlewine's 'Manual of Computer Programming for Astrologers',
  16. ** available from Matrix Software. The copyright gives us permission to
  17. ** use the routines for personal use but not to sell them or profit from
  18. ** them in any way.
  19. **
  20. ** The PostScript code within the core graphics routines are programmed
  21. ** and Copyright (C) 1992-1993 by Brian D. Willoughby
  22. ** (brianw@sounds.wa.com). Conditions are identical to those above.
  23. **
  24. ** The extended accurate ephemeris databases and formulas are from the
  25. ** calculation routines in the program "Placalc" and are programmed and
  26. ** Copyright (C) 1989,1991,1993 by Astrodienst AG and Alois Treindl
  27. ** (alois@azur.ch). The use of that source code is subject to
  28. ** regulations made by Astrodienst Zurich, and the code is not in the
  29. ** public domain. This copyright notice must not be changed or removed
  30. ** by any user of this program.
  31. **
  32. ** Initial programming 8/28,30, 9/10,13,16,20,23, 10/3,6,7, 11/7,10,21/1991.
  33. ** X Window graphics initially programmed 10/23-29/1991.
  34. ** PostScript graphics initially programmed 11/29-30/1992.
  35. ** Last code change made 3/19/1994.
  36. */
  37.  
  38. /*
  39. ** TO COMPILE: For most systems, especially Unix and DOS based ones, the only
  40. ** changes that should need to be made to the code are to edit or comment the
  41. ** #define's below to equal the particulars of your own system and locale:
  42. ** 
  43. ** SYSTEM SECTION: These settings describe platform and hardware specifics.
  44. ** They are all required to be set properly or the program likely won't
  45. ** compile or run. Some of these are technically optional and can be
  46. ** commented out even if your system would normally support them, e.g.
  47. ** the X11 features can be disabled even if you are running X windows.
  48. */
  49.  
  50. /*#define PC /* Comment out this #define if you have a Unix or some other */
  51.            /* system that isn't the generic PC running DOS.             */
  52.  
  53. /*#define ATOF /* Comment out this #define if you have a system in which  */
  54.              /* 'atof' and related functions aren't defined in stdio.h, */
  55.              /* such as most PC's, VMS compilers, and NeXT's.           */
  56.  
  57. #define X11 /* Comment out this #define if you don't have X windows, or */
  58.             /* else have them and don't wish to compile in X graphics.  */
  59.  
  60. /*#define MSG /* Comment out this #define if you don't have access to the     */
  61.             /* Microsoft C PC graphics library as in graph.h, or you do and */
  62.             /* have a PC and just don't wish to compile these graphics in.  */
  63.  
  64. #define SWITCHES /* Comment out this #define if your system can not handle */
  65.                  /* parameters on the command line (such as Mac's).        */
  66.  
  67. #define MOUSE /* Comment out this #define if you don't have a mouse, or */
  68.               /* don't wish to compile in mouse tracking features. This */
  69.               /* is only an option if either X11 or MSG above are set.  */
  70.  
  71. #define TIME /* Comment out this #define if your compiler can't take the  */
  72.              /* calls to the 'time' or 'localtime' functions as in time.h */
  73.  
  74. #define ENVIRON /* Comment out this #define if your system doesn't have  */
  75.                 /* environment variables or can't compile calls to them. */
  76.  
  77. /*
  78. ** FEATURES SECTION: These settings describe features that are always
  79. ** available to be compiled into the program no matter what platform or
  80. ** hardware is available. Their settings are always optional.
  81. */
  82.  
  83. #define GRAPH /* Comment out this #define if you don't want any graphics   */
  84.               /* in the program. This switch allows at least generation of */
  85.               /* bitmap files and must be set if any of the more advanced  */
  86.               /* graphics feature additions are also compiled in.          */
  87.  
  88. #define PLACALC /* Comment out this #define if you don't want the more */
  89.                 /* accurate calculation features and formulas to be    */
  90.                 /* compiled into the program (as accessed with -b).    */
  91.  
  92. #define PS /* Comment out this #define if you don't want the ability to */
  93.            /* generate charts in the PostScript graphics format.        */
  94.  
  95. #define META /* Comment out this #define if you don't want the ability to  */
  96.              /* generate charts in the MS Windows metafile picture format. */
  97.  
  98. #define INTERPRET /* Comment out this #define if you don't want the ability */
  99.                   /* to display interpretations of the various chart types. */
  100.  
  101. #define BIORHYTHM /* Comment out this #define if you don't want the    */
  102.                   /* non-astrological biorhythm charts in the program. */
  103.  
  104. /*
  105. ** DATA CONFIGURATION SECTION: These settings describe particulars of
  106. ** your own location and where the program looks for certain info. It is
  107. ** recommended that these values be changed appropriately, although the
  108. ** program will still run if they are left alone.
  109. */
  110.  
  111. #ifndef PC
  112. #define DEFAULT_DIR "~/astrolog"
  113. #else
  114. #define DEFAULT_DIR "C:\\ASTROLOG"
  115. #endif
  116.   /* Change this string to directory path program should look in for the  */
  117.   /* astrolog.dat default file if one is not in the current directory or  */
  118.   /* in the dirs indicated by environment variables. For PC systems, use  */
  119.   /* two backslashes instead of one forward one to divide subdirectories. */
  120.  
  121. #define CHART_DIR DEFAULT_DIR
  122.   /* This string is the directory the program looks in for chart info    */
  123.   /* files (-i switch) if not in the current directory. This is normally */
  124.   /* the default dir above but may be changed to be somewhere else.      */
  125.  
  126. #define EPHE_DIR DEFAULT_DIR
  127.   /* This string is the directory the program looks in for the ephemeris */
  128.   /* files as accessed with the -b switch. This is normally the default  */
  129.   /* dir above but may be changed to be somewhere else.                  */
  130.  
  131. #define DEFAULT_LONG 122.20 /* Change these values to the longitude west    */
  132. #define DEFAULT_LAT   47.36 /* and latitude north of your current location. */
  133.                             /* Use negative values for east/southern areas. */
  134.  
  135. #define DEFAULT_ZONE 8.00 /* Change this number to the time zone of your */
  136.                           /* current location in hours before (west of)  */
  137.                           /* GMT. Use negative values for eastern zones. */
  138.  
  139. /*
  140. ** OPTIONAL CONFIGURATION SECTION: Although not necessary, one may like
  141. ** to change some of the values below: These constants affect some of
  142. ** the default parameters and other such things.
  143. */
  144.  
  145. #define DEFAULT_SYSTEM 0 /* Normally, Placidus houses are used (unless the */
  146.                          /* user specifies otherwise). If you want a       */
  147.                          /* different default system, change this number   */
  148.                          /* to a value from 0..9 (values same as in -c).   */
  149.  
  150. #define DEFAULT_ASPECTS 5 /* Default number of aspects to use in charts. */
  151.  
  152. #define DIVISIONS 12 /* Greater numbers means more accuracy but slower  */
  153.                      /* calculation, of exact aspect and transit times. */
  154.  
  155. #define DEFAULT_INFOFILE "astrolog.dat"
  156.   /* Name of file to look in for default program parameters (which will */
  157.   /* override the compile time values here, if the file exists).        */
  158.  
  159. #define ENVIRONALL "ASTROLOG"
  160. #define ENVIRONVER "ASTR"
  161.   /* Name of environment variables to look in for chart, ephemeris, and  */
  162.   /* default files. The second name is a version specific variable which */
  163.   /* gets the current version appended to it before it is accessed.      */
  164.  
  165. #define WHEELCOLS 15   /* Affects width of each house in wheel display.    */
  166. #define WHEELROWS 11   /* Max no. of objects that can be in a wheel house. */
  167. #define SCREENWIDTH 80 /* Number of columns to print interpretations in.   */
  168. #define MONTHSPACE 3   /* Number of spaces between each calendar column.   */
  169. #define MAXINDAY 100   /* Max number of aspects or transits displayable.   */
  170. #define MAXCROSS 500   /* Max number of latitude crossings displayable.    */
  171.  
  172. #ifdef GRAPH           /* For graphics, this char affects how bitmaps are */
  173. #ifndef PC             /* written. 'N' is written like with the 'bitmap'  */
  174. #define BITMAPMODE 'C' /* program, 'C' is compacted somewhat (files have  */
  175. #else                  /* less spaces), and 'V' is compacted even more.   */
  176. #define BITMAPMODE 'B' /* 'A' means write as rectangular Ascii text file. */
  177. #endif                 /* 'B' means write as Windows bitmap (.bmp) file.  */
  178.  
  179. #ifdef MSG
  180. #define DEFHIRESMODE _MAXRESMODE /* 'High-resolution' PC graphics mode. */
  181. #define DEFLORESMODE _ERESCOLOR  /* 'Flicker-free' PC graphics mode.    */
  182. #endif
  183. #endif /* GRAPH */
  184.  
  185. /*#define TRUENODE /* Comment out this #define if you'd prefer the 'Node' */
  186.                  /* object to refer to the Mean North Node of the Moon  */
  187.                  /* as opposed to the True North Node of the Moon.      */
  188.  
  189. /*
  190. ** By the time you reach here and the above values are customized as
  191. ** desired, Astrolog is ready to be compiled! Be sure to similarly
  192. ** change the values in the astrolog.dat file, which will override any
  193. ** corresponding compile time values here. Don't change any of the
  194. ** values in the section below unless you really know what you're doing.
  195. */
  196.  
  197. #ifdef GRAPH
  198. #define BITMAPX  2730   /* Maximum window size allowed */
  199. #define BITMAPY  2730
  200. #define BITMAPX1 180    /* Minimum window size allowed */
  201. #define BITMAPY1 180
  202. #define DEFAULTX 480    /* Default window size */
  203. #define DEFAULTY 480
  204. #define SIDESIZE 160    /* Size of wheel chart information sidebar.    */
  205. #define MAXMETA 100000L /* Max bytes allowed in a metafile.            */
  206. #define METAMUL   12    /* Metafile coordinate to chart pixel ratio.   */
  207. #define PSMUL     11    /* PostScript coordinate to chart pixel ratio. */
  208. #define CELLSIZE  14    /* Size for each cell in the aspect grid.      */
  209. #define BIODAYS   14    /* Days to include in graphic biorhythms.      */
  210. #define DEGINC     2    /* Number of degrees per line for circles.     */
  211. #define DEFORB   7.0    /* Min distance glyphs can be from each other  */
  212. #endif /* GRAPH */
  213.  
  214. #define BOXH  (ansi ? 196 : '-')    /* Ansi and Ascii characters used to */
  215. #define BOXV  (ansi ? 179 : '|')    /* print text charts.                */
  216. #define BOXC  (ansi ? 197 : '|')
  217. #define BOXNW (ansi ? 218 : '+')
  218. #define BOXNE (ansi ? 191 : '+')
  219. #define BOXSW (ansi ? 192 : '+')
  220. #define BOXSE (ansi ? 217 : '+')
  221. #define BOXJN (ansi ? 193 : '-')
  222. #define BOXJS (ansi ? 194 : '-')
  223. #define BOXJW (ansi ? 180 : '|')
  224. #define BOXJE (ansi ? 195 : '|')
  225. #define DEGR0 (ansi ? 248 : ' ')
  226. #define DEGR1 (ansi ? 248 : ':')
  227.  
  228.  
  229. /*
  230. ** One shouldn't ever need to change anything below this line to compile.
  231. */
  232.  
  233. #define ASTROLOG
  234. #define MATRIX
  235. #include <stdio.h>
  236. #ifndef ATOF
  237. #include <stdlib.h>
  238. #endif
  239. #include <math.h>
  240. #ifdef PC
  241. #include <malloc.h>
  242. #endif
  243. #ifdef TIME
  244. #include <time.h>
  245. #endif
  246. #ifdef X11
  247. #define ISG
  248. #include <X11/Xlib.h>
  249. #include <X11/Xutil.h>
  250. #endif
  251. #ifdef MSG
  252. #define ISG
  253. #include <graph.h>
  254. #include <conio.h>
  255. #ifdef MOUSE
  256. #include <mouse.h>
  257. #endif
  258. #endif /* MSG */
  259.  
  260.  
  261. /*
  262. ** Make sure only legal combinations of the graphics options are active.
  263. */
  264.  
  265. #ifdef X11
  266. #ifndef GRAPH
  267. "If 'X11' is defined 'GRAPH' must be too"
  268. #endif
  269. #ifdef MSG
  270. "If 'X11' is defined 'MSG' must not be as well"
  271. #endif
  272. #ifdef PC
  273. "If 'X11' is defined 'PC' must not be as well"
  274. #endif
  275. #endif /* X11 */
  276.  
  277. #ifdef MSG
  278. #ifndef GRAPH
  279. "If 'MSG' is defined 'GRAPH' must be too"
  280. #endif
  281. #ifdef X11
  282. "If 'MSG' is defined 'X11' must not be as well"
  283. #endif
  284. #ifndef PC
  285. "If 'MSG' is defined 'PC' must be too"
  286. #endif
  287. #endif /* MSG */
  288.  
  289. #ifdef MOUSE
  290. #ifdef GRAPH
  291. #ifndef ISG
  292. "If 'MOUSE' is defined 'X11' or 'MSG' must be too"
  293. #endif
  294. #endif /* GRAPH */
  295. #endif /* MOUSE */
  296.  
  297. #ifdef PS
  298. #ifndef GRAPH
  299. "If 'PS' is defined 'GRAPH' must be too"
  300. #endif
  301. #endif /* PS */
  302.  
  303. #ifdef META
  304. #ifndef GRAPH
  305. "If 'META' is defined 'GRAPH' must be too"
  306. #endif
  307. #endif /* META */
  308.  
  309.  
  310. /*
  311. ******************************************************************************
  312. ** Program Constants.
  313. ******************************************************************************
  314. */
  315.  
  316. #ifndef FALSE
  317. #define FALSE 0
  318. #endif
  319. #ifndef TRUE
  320. #define TRUE  1
  321. #endif
  322. #define APPNAME "Astrolog"
  323. #define VERSION "4.10"
  324. #define DATE    "March 1994"
  325. #define OFF     0
  326. #define ON      1
  327. #define STRING  80
  328. #define DEGD    360
  329. #define PI      3.14159265358979323846
  330. #define DEGREES 360.0
  331. #define DEGHALF 180.0
  332. #define DEGQUAD 90.0
  333. #define DEGRAD  (DEGHALF/PI)
  334. #define G2JYEA  1582
  335. #define G2JMON  _OCT
  336. #define G2JDAY1 4
  337. #define G2JDAY2 15
  338. #define SD2000  -24.736467
  339. #define TROPIC  23.44578889
  340. #define SMALL   (1.7453E-09)
  341. #define LARGE   1000.0
  342. #define ROUND   0.5
  343. #define ESCAPE  '\33'
  344. #define BELL    '\7'
  345. #define SCALE   (scale/100)
  346.  
  347. /* Array index limits */
  348.  
  349. #define SIGNS   12
  350. #define SYSTEMS 11
  351. #define ASPECTS 18
  352. #define ASPECTI 11
  353. #define OBJECTI U_HI
  354. #define TOTAL   79
  355. #define FONTX   6
  356. #define FONTY   10
  357. #define FONTXT  (FONTX*scalet)
  358. #define FONTYT  (FONTY*scalet)
  359. #define SIDET   (SIDESIZE*scalet)
  360.  
  361. /* Object array index values */
  362.  
  363. #define PLANETS 14
  364. #define THINGS  16
  365. #define OBJECTS 20
  366. #define URANIANS 8
  367. #define STARS   47
  368. #define BASE    32
  369. #define C_LO    21
  370. #define C_HI    24
  371. #define U_LO    25
  372. #define U_HI    32
  373. #define S_LO    33
  374. #define S_HI    79
  375.  
  376. /* Other specific index values */
  377.  
  378. #define _JAN 1
  379. #define _FEB 2
  380. #define _MCH 3
  381. #define _APR 4
  382. #define _MAY 5
  383. #define _JUN 6
  384. #define _JUL 7
  385. #define _AUG 8
  386. #define _SEP 9
  387. #define _OCT 10
  388. #define _NOV 11
  389. #define _DEC 12
  390. #define _FIR 0
  391. #define _EAR 1
  392. #define _AIR 2
  393. #define _WAT 3
  394. #define _ARI 1
  395. #define _TAU 2
  396. #define _GEM 3
  397. #define _CAN 4
  398. #define _LEO 5
  399. #define _VIR 6
  400. #define _LIB 7
  401. #define _SCO 8
  402. #define _SAG 9
  403. #define _CAP 10
  404. #define _AQU 11
  405. #define _PIS 12
  406. #define _SUN 1
  407. #define _MOO 2
  408. #define _MER 3
  409. #define _VEN 4
  410. #define _MRS 5
  411. #define _JUP 6
  412. #define _SAT 7
  413. #define _URA 8
  414. #define _NEP 9
  415. #define _PLU 10
  416. #define _CHI 11
  417. #define _NOD 16
  418. #define _FOR 17
  419. #define _MC  18
  420. #define _ASC 19
  421. #define _VTX 20
  422. #define _DIR -2
  423. #define _SIG -1
  424. #define _CON 1
  425. #define _OPP 2
  426. #define _SQU 3
  427. #define _TRI 4
  428. #define _SEX 5
  429. #define _INC 6
  430. #define _SSX 7
  431. #define _SSQ 8
  432. #define _SES 9
  433. #define _QUI 10
  434. #define _BQN 11
  435. #define _PHY 23.0
  436. #define _EMO 28.0
  437. #define _INT 33.0
  438.  
  439. /* Bit mask values for chart specification */
  440.  
  441. #define DASHv 0x1
  442. #define DASHw 0x2
  443. #define DASHg 0x4
  444. #define DASHm 0x8
  445. #define DASHZ 0x10
  446. #define DASHS 0x20
  447. #define DASHj 0x40
  448. #define DASHL 0x80
  449. #define DASHK 0x100
  450. #define DASHd 0x200
  451. #define DASHD 0x400
  452. #define DASHE 0x800
  453. #define DASHt 0x1000
  454. #define DASHT 0x2000
  455. #define DASHe 0xFFF
  456.  
  457. /* Bit mask values for subchart specification */
  458.  
  459. #define DASHv0 0x1
  460. #define DASHw0 0x2
  461. #define DASHg0 0x4
  462. #define DASHga 0x8
  463. #define DASHm0 0x10
  464. #define DASHZ0 0x20
  465. #define DASHZd 0x40
  466. #define DASHj0 0x80
  467. #define DASHL0 0x100
  468. #define DASHKy 0x200
  469. #define DASHdm 0x400
  470. #define DASHEy 0x800
  471. #define DASHXW0 0x1000
  472. #define DASHXP0 0x2000
  473.  
  474. /* Bit mask values for table specification */
  475.  
  476. #define DASHO0 0x1
  477. #define DASHHc 0x2
  478. #define DASHH  0x4
  479. #define DASHH0 0x8
  480. #define DASHO  0x10
  481. #define DASHA  0x20
  482. #define DASHI0 0x40
  483.  
  484. /* Bit mask values for option specification */
  485.  
  486. #define DASHQ 0x1
  487. #define DASHs 0x2
  488. #define DASHC 0x4
  489. #define DASHu 0x8
  490. #define DASHf 0x10
  491. #define DASH3 0x20
  492. #define DASHG 0x40
  493. #define DASHo 0x80
  494. #define DASHX 0x100
  495. #define DASHQ0 0x200
  496. #define DASHs0 0x400
  497. #define DASHp0 0x800
  498. #define DASHo0 0x1000
  499.  
  500. /* Relationship chart modes */
  501.  
  502. #define DASHr  1
  503. #define DASHrc 2
  504. #define DASHrm 3
  505. #define DASHrd 4
  506. #define DASHrb 5
  507. #define DASHr0 -1
  508. #define DASHrp -2
  509.  
  510. /* Graphics chart modes */
  511.  
  512. #define MODEv 'v'
  513. #define MODEw 'w'
  514. #define MODEg 'g'
  515. #define MODEZ 'Z'
  516. #define MODES 'S'
  517. #define MODEL 'L'
  518. #define MODEE 'E'
  519. #define MODEW 'W'
  520. #define MODEG 'G'
  521. #define MODEP 'P'
  522. #define MODEb 'b'
  523.  
  524. /* Ansi colors */
  525.  
  526. #define REVERSE -2
  527. #define DEFAULT -1
  528. #define BLACK   0
  529. #define MAROON  1
  530. #define DKGREEN 2
  531. #define ORANGE  3
  532. #define DKBLUE  4
  533. #define PURPLE  5
  534. #define DKCYAN  6
  535. #define LTGRAY  7
  536. #define DKGRAY  8
  537. #define RED     9
  538. #define GREEN   10
  539. #define YELLOW  11
  540. #define BLUE    12
  541. #define MAGENTA 13
  542. #define CYAN    14
  543. #define WHITE   15
  544.  
  545. /* Termination codes */
  546.  
  547. #define _ERROR -1
  548. #define _OK    0
  549. #define _FATAL 1
  550. #define _FORCE 2
  551.  
  552. #ifndef _ZRES256COLOR
  553. #define _ZRES256COLOR 263
  554. #endif
  555.  
  556.  
  557. /*
  558. ******************************************************************************
  559. ** Macro Functions.
  560. ******************************************************************************
  561. */
  562.  
  563. #define LOBYTE(W) ((byte) (W))
  564. #define HIBYTE(W) ((byte) ((word)(W) >> 8 & 0xFF))
  565. #define LOWORD(L) ((word) (dword)(L))
  566. #define HIWORD(L) ((word) ((dword)(L) >> 16 & 0xFFFF))
  567. #define MAKEWORD(L, H) ((word)LOBYTE(L) | (word)((byte)(H)) << 8)
  568. #define MAKELONG(L, H) ((dword)LOWORD(L) | (dword)((word)(H)) << 16)
  569. #define MAKEQUAD(A, B, C, D) MAKELONG(MAKEWORD(A, B), MAKEWORD(C, D))
  570. #define RGB(R, G, B) ((dword)((byte)(R) | (word)(G)<<8 | (dword)(byte)(B)<<16))
  571. #define RGBR(R) LOBYTE(R)
  572. #define RGBG(G) HIBYTE(G)
  573. #define RGBB(B) ((byte) ((dword)(B) >> 16 & 0xFF))
  574. #define INTTOHEX(I) (char) ((I) < 10 ? '0' + (I) : 'a' + (I) - 10)
  575. #define ISEGA(R) ((R) == _ERESNOCOLOR || (R) == _ERESCOLOR)
  576. #define ISCGA(R) ((R) == _HRESBW || (R) == _HRES16COLOR)
  577. #define EGATOVGA(X) MULTDIV((X), 480, 350)
  578. #define CGATOVGA(X) MULTDIV((X), 480, 200)
  579.  
  580. #define MAX(A, B) ((A) > (B) ? (A) : (B))
  581. #define MIN(A, B) ((A) < (B) ? (A) : (B))
  582. #define SGN(A) ((A) < 0 ? -1 : (A) > 0 ? 1 : 0)
  583. #define SGN2(A) ((A) < 0.0 ? -1.0 : 1.0)
  584. #define FRACT(A) ((A) - floor(A))
  585. #define CAP(C) ((C) >= 'a' && (C) <= 'z' ? (C) - 'a' + 'A' : (C))
  586. #define UNCAP(C) ((C) >= 'A' && (C) <= 'Z' ? (C) - 'A' + 'a' : (C))
  587. #define MULTDIV(X, Y, Z) ((int)((long)(X) * (Y) / (Z)))
  588. #define RATIO(X, Y, Z) ((X) + ((Y) - (X)) * (Z))
  589. #define STOZ(S) ((real)(((S)-1)*30))
  590. #define ZTOS(D) (((int)(D))/30+1)
  591. #define DTOR(D) ((D)/DEGRAD)
  592. #define RTOD(R) ((R)*DEGRAD)
  593. #define ASIN(R) ((R)*(R) == 1.0 ? (R)*PI/2.0 : atan((R)/sqrt(1.0-(R)*(R))))
  594. #define ACOS(R) ((R) == 0.0 ? 0.0 : atan(sqrt(1.0-(R)*(R))/(R)))
  595. #define ATAN(R) atan(R)
  596. #define SIND(D) sin((D)/DEGRAD)
  597. #define COSD(D) cos((D)/DEGRAD)
  598. #define RSIND(R, D) ((int)((real)(R)*SIND((real)D)))
  599. #define RCOSD(R, D) ((int)((real)(R)*COSD((real)D)))
  600. #define SWAP(A, B) (A)^=(B)^=(A)^=(B)
  601. #define SORT(A, B) if ((A) > (B)) SWAP(A, B)
  602.  
  603. #define IsCusp(I) ((I) >= C_LO && (I) <= C_HI)
  604. #define IsObject(I) ((I) < THINGS || (I) > C_HI)
  605. #define IsThing(I) ((I) <= THINGS || (I) > C_HI)
  606. #define IsItem(I) ((I) >= 1 && (I) <= TOTAL)
  607. #define DayInYear(Y) (365-28+DayInMonth(2, Y))
  608. #define DaysInYear(Y) (DayInYear(Y)-((Y) == G2JYEA)*(G2JDAY2-G2JDAY1-1))
  609.  
  610. #define IsValidMon(M) ((M) >= 1 && (M) <= 12)
  611. #define IsValidDay(D, M, Y) ((D) >= 1 && (D) <= DayInMonth(M, Y))
  612. #define IsValidYea(Y) ((Y) >= -20000 && (Y) <= 20000)
  613. #define IsValidTim(T) ((T) > -2.0 && (T) < 24.0)
  614. #define IsValidZon(Z) ((Z) >= -24.0 && (Z) <= 24.0)
  615. #define IsValidLon(O) ((O) >= -DEGHALF && (O) <= DEGHALF)
  616. #define IsValidLat(A) ((A) >= -DEGQUAD && (A) <= DEGQUAD)
  617. #define IsValidAspect(A) ((A) >= 0 && (A) <= ASPECTS)
  618. #define IsValidSystem(H) ((H) >= 0 && (H) <= SYSTEMS)
  619. #define IsValidDivision(D) ((D) > 0 && (D) <= 2880)
  620. #define IsValidWheel(R) ((R) >= 1 && (R) <= WHEELROWS)
  621. #define IsValidScreen(W) ((W) >= 20 && (W) <= 200)
  622. #define IsValidTextrows(R) ((R) == 25 || (R) == 43 || (R) == 50)
  623. #define IsValidGrid(C) ((C) > 0 && (C) <= TOTAL)
  624. #define IsValidScale(S) ((S) >= 100 && (S) <= 400 && (S)%100 == 0)
  625. #define IsValidGraphx(X) ((X) >= BITMAPX1 && (X) <= BITMAPX)
  626. #define IsValidGraphy(Y) ((Y) >= BITMAPY1 && (Y) <= BITMAPY)
  627. #define IsValidResmode(R) ((R) >= _MAXRESMODE && (R) <= _ZRES256COLOR)
  628. #define IsValidBmpmode(M) \
  629.   ((M) == 'N' || (M) == 'C' || (M) == 'V' || (M) == 'A' || (M) == 'B')
  630.  
  631. #define SetCore(M, D, Y, T, Z, O, A) \
  632.   MM = (M); DD = (D); YY = (Y); TT = (T); ZZ = (Z); OO = (O); AA = (A)
  633. #define SetMain(M, D, Y, T, Z, O, A) \
  634.   Mon = (M); Day = (D); Yea = (Y); Tim = (T); Zon = (Z); Lon = (O); Lat = (A)
  635. #define SetSave(M, D, Y, T, Z, O, A) MonX = (M); DayX = (D); YeaX = (Y); \
  636.   TimX = (T); ZonX = (Z); LonX = (O); LatX = (A)
  637. #define SetTwin(M, D, Y, T, Z, O, A) Mon2 = (M); Day2 = (D); Yea2 = (Y); \
  638.   Tim2 = (T); Zon2 = (Z); Lon2 = (O); Lat2 = (A)
  639. #define SIGNAM(A) signname[A][0], signname[A][1], signname[A][2]
  640. #define OBJNAM(A) objectname[A][0], objectname[A][1], objectname[A][2]
  641. #define MONNAM(A) monthname[A][0], monthname[A][1], monthname[A][2]
  642. #define DAYNAM(A) dayname[A][0], dayname[A][1], dayname[A][2]
  643. #define dabs(A) fabs(A)
  644. #define signansi(A) elemansi[(A)-1 & 3]
  645. #define signcolor(A) elemcolor[(A)-1 & 3]
  646. #define printc(A) putc(A, S)
  647. #define printl() printc('\n')
  648. #define printl2() fprintf(S, "\n\n")
  649. #define loop for (;;)
  650.  
  651. #ifndef PC
  652. #define DIR_SEP '/'
  653. #define DASH '-'
  654. #define FAR
  655. #define PTR *
  656. #define Allocate(P, B, T) (P) = (T) malloc(B)
  657. #define Deallocate(P) free(P)
  658. #else
  659. #define DIR_SEP '\\'
  660. #define DASH '/'
  661. #define FAR far
  662. #define PTR huge *
  663. #define Allocate(P, B, T) (P) = (T) halloc((long)(B), sizeof(byte))
  664. #define Deallocate(P) hfree(P)
  665. #endif
  666.  
  667. #ifdef GRAPH
  668. #define epsfile (psfile > TRUE)
  669.  
  670. /* Are particular coordinates on the chart? */
  671. #define ISLEGAL(X, Y, x1, y1, x2, y2) \
  672.   ((X) >= x1 && (X) < x2 && (Y) >= y1 && (Y) < y2)
  673. #define ISCHART(X, Y) ISLEGAL((X), (Y), 0, 0, chartx, charty)
  674.  
  675. /* Get a coordinate based on chart radius, a fraction, and (co)sin value. */
  676. #define POINT(U, R, S) ((int) ((R)*(U)*(S)+Sgn((S))/3.0))
  677.  
  678. /* Determine (co)sin factors based on zodiac angle and chart orientation. */
  679. #define PX(A) COSD(A)
  680. #define PY(A) SIND(A)
  681. #define PZ(A) Mod(DEGHALF-(A)+asc)
  682.  
  683. /* Do settings indicate the current chart should have the info sidebar? */
  684. #define ISSIDEBAR \
  685.   ((modex == MODEv || modex == MODEw) && xtext && !(exdisplay & DASHv0))
  686.  
  687. /* Is the current chart most properly displayed as a square graphic? */
  688. #define ISSQUARE \
  689.   (modex == MODEv || modex == MODEw || modex == MODEg || \
  690.   (modex == MODEZ && (exdisplay & DASHZ0) > 0) || \
  691.   modex == MODES || modex == MODEG || modex == MODEP)
  692. #endif
  693.  
  694.  
  695. /*
  696. ******************************************************************************
  697. ** Type Definitions.
  698. ******************************************************************************
  699. */
  700.  
  701. #define byte  unsigned char
  702. #define word  unsigned short
  703. #define dword unsigned long
  704. #define bool  int
  705. #define _int  unsigned int
  706. #define real  double
  707.  
  708. typedef struct _gridstruct {
  709.   byte  n[TOTAL+1][TOTAL+1];
  710.   short v[TOTAL+1][TOTAL+1];
  711. } gridstruct;
  712.  
  713. typedef struct _crosstruct {
  714.   real lat[MAXCROSS];
  715.   real lon[MAXCROSS];
  716.   int obj1[MAXCROSS];
  717.   int obj2[MAXCROSS];
  718. } crosstruct;
  719.  
  720. #ifdef GRAPH
  721. #define colrgb unsigned long
  722. #define colpal int
  723.  
  724. typedef struct _circlestruct {
  725.   real x[DEGD+1];
  726.   real y[DEGD+1];
  727. } circlestruct;
  728.  
  729. typedef byte PTR bitmap;
  730. #endif /* GRAPH */
  731.  
  732.  
  733. /*
  734. ******************************************************************************
  735. ** Function Declarations.
  736. ******************************************************************************
  737. */
  738.  
  739. /* From data.c */
  740.  
  741. extern FILE *S;
  742. extern int noswitches, total, aspects, universe, centerplanet, placalc,
  743.   seconds, housesystem, ansi, divisions, screenwidth, eurodate, eurotime,
  744.   smartcusp, column80, todisplay, exdisplay, andisplay, operation, relation,
  745.   ratio1, ratio2, interpret, progress, multiplyfactor, onasc,
  746.   wheelrows, graphstep, autom;
  747. extern char *progname, *filename, *filename2, string[];
  748. extern real addfactor, progday, defzone, deflong, deflat, modulus;
  749. extern int MM, DD, YY, Mon, Day, Yea, Mon2, Day2, Yea2, MonX, DayX, YeaX,
  750.   Delta;
  751. extern real TT, ZZ, OO, AA, Tim, Zon, Lon, Lat, Tim2, Zon2, Lon2, Lat2,
  752.   TimX, ZonX, LonX, LatX, SD, T, JD, Jdp, MC, Asc, Vtx;
  753.  
  754. extern real planet[], planetalt[], house[], ret[],
  755.   spacex[], spacey[], spacez[], force[],
  756.   planet1[], planet2[], planetalt1[], planetalt2[],
  757.   house1[], house2[], ret1[], ret2[];
  758. extern gridstruct PTR grid;
  759. extern byte inhouse[], inhouse1[], inhouse2[];
  760. extern int starname[], objectansi[];
  761.  
  762. extern byte ignore[], ignore2[];
  763. extern real aspectangle[], aspectorb[], planetorb[], planetadd[];
  764. extern int ruler1[], ruler2[], exalt[], rules[],
  765.   mainansi[], rainbowansi[], elemansi[], aspectansi[];
  766. extern real objectinf[], houseinf[], aspectinf[], transitinf[];
  767.  
  768. extern char *appname, *signname[], *signabbrev[], *signenglish[],
  769.   *housetradition[], *objectname[], *systemname[], *aspectname[],
  770.   *aspectabbrev[], *aspectglyph[], *element[], *mode[],
  771.   *monthname[], *dayname[], *dirname[], *post[];
  772. extern byte errorcount[];
  773. extern real planetdata[], starbright[], stardata[];
  774. extern char *mindpart[], *description[], *desire[], *lifearea[],
  775.   *interact[], *therefore[], *modifier[3][11];
  776.  
  777. /* From general.c */
  778.  
  779. #define PrintAltitude(D) fprintf(S, "%s", CharAltitude(D))
  780. #define BadVal2(O, V) BadVal(O, (int)V)
  781.  
  782. extern void SwapReal(),
  783.   Terminate(), PrintWarning(), PrintError(), TooFew(), BadVal(),
  784.   PrintTab(), InputString(), AnsiColor(), PrintZodiac(), GetTimeNow();
  785. extern int StringLen(), StringCmp(), Mod12(), DayInMonth(), DaysInMonth(),
  786.   DayOfWeek(), AddDay();
  787. extern long Dvd();
  788. extern real Sgn(), Angle(), Mod(), DecToDeg(), DegToDec(),
  789.   MinDistance(), MinDifference(), Midpoint(), Orb();
  790. extern char Dignify(), *CharZodiac(), *CharAltitude(), *CharDate(),
  791.   *CharTime(), *CharZone(), *CharLocation(), *ProcessProgname();
  792. extern bool InputData();
  793. extern FILE *OpenFile();
  794.  
  795. /* From formulas.c */
  796.  
  797. #define EclToEqu(Z, L) CoorXform(Z, L, DTOR(TROPIC))
  798. #define EquToEcl(Z, L) CoorXform(Z, L, DTOR(-TROPIC))
  799. #define EquToLocal(Z, L, T) CoorXform(Z, L, T)
  800. #define ReadPlanetData() (*datapointer++)
  801. #define Biorhythm(D, R) (sin(((D)/(R))*PI*2.0)*100.0)
  802. #define JulianDayFromTime(T) ((T)*36525.0+2415020.0)
  803.  
  804. extern long MdyToJulian();
  805. extern void JulianToMdy();
  806. extern real ProcessInput();
  807. extern void CoorXform();
  808. extern int HousePlaceIn();
  809. extern void HousePlace();
  810. extern void ComputeStars();
  811. extern real CastChart();
  812.  
  813. /* From charts.c */
  814.  
  815. extern void CreateElemTable();
  816. extern void ChartLocation();
  817. extern void ChartGrid();
  818. extern void PrintGrand();
  819. extern void DisplayGrands();
  820. extern void PrintHouse();
  821. extern void PrintWheelSlot();
  822. extern void ChartWheel();
  823. extern void ChartAspect();
  824. extern void ChartMidpoint();
  825. extern void ChartHorizon();
  826. extern void ChartSpace();
  827. extern void ChartAstroGraph();
  828.  
  829. /* From options.c */
  830.  
  831. extern void CreateGrid();
  832. extern void CreateGridRelation();
  833. extern void CastRelation();
  834. extern void PrintAspect();
  835. extern void DisplayInDaySearch();
  836. extern void DisplayInDayInfluence();
  837. extern void DisplayTransitSearch();
  838. extern void DisplayTransitInfluence();
  839. extern void DisplayEphemeris();
  840. extern void DisplayCalendarMonth();
  841. extern void DisplayCalendarYear();
  842. extern void PrintChart();
  843.  
  844. /* From intrpret.c */
  845.  
  846. extern void FieldWord();
  847. extern void InterpretGeneral();
  848. extern void InterpretAspectGeneral();
  849. extern void InterpretLocation();
  850. extern void InterpretAspect();
  851. extern void InterpretGrid();
  852. extern void InterpretMidpoint();
  853. extern void InterpretInDay();
  854. extern void InterpretTransit();
  855. extern void InterpretSynastry();
  856. extern void InterpretAspectRelation();
  857. extern void InterpretGridRelation();
  858. extern void InterpretMidpointRelation();
  859. extern void SortRank();
  860. extern void ChartInfluence();
  861.  
  862. /* From driver.c */
  863.  
  864. extern void Prints();
  865.  
  866. #ifdef GRAPH
  867. /* From xdata.c */
  868.  
  869. #ifdef X11
  870. extern Colormap cmap;
  871. extern Display *disp;
  872. extern GC gc, pmgc;
  873. extern KeySym key;
  874. extern Pixmap pixmap, icon;
  875. extern Window window, root;
  876. extern XEvent event;
  877. extern XSizeHints hint;
  878. extern int screen, depth;
  879. extern char xkey[];
  880. extern char icon_bits[];
  881. extern char *rgbname[];
  882. extern colrgb rgbind[];
  883. #endif
  884. #ifdef MSG
  885. extern int hiresmode, loresmode;
  886. #endif
  887.  
  888. extern bitmap bm;
  889. extern word PTR metacur;
  890. extern circlestruct PTR circ;
  891. extern char modex, bitmapmode, *outputfile, *dispname;
  892. extern colrgb fg, bg, rgb[], rgbbmp[];
  893. extern colpal colcur, metafillcol, on, off, hilite, gray;
  894. extern colpal maincolor[], rainbowcolor[],
  895.   elemcolor[], aspectcolor[], objectcolor[];
  896. extern int xfile, xbitmap, psfile, metafile, xmono, xcolor, xreverse, 
  897.   xroot, xtext, xbonus, xlabel, xborder, xfont;
  898. extern int bitmaprow, xnow, xeast, scale, textrows, gridobjects, psinchz,
  899.   metawid, offsetx, offsety, turtlex, turtley, chartx, charty, degree, scalet;
  900. extern real psinchx, psinchy, tilt;
  901.  
  902. extern char *signdraw[], *objectdraw[], *housedraw[],
  903.   *aspectdraw[], *asciidraw[], *worlddata[];
  904.  
  905. /* From xgeneral.c */
  906.  
  907. #define AIND(B, X, Y) ((B)[(long)(Y)*(long)(bitmaprow) + ((X) >> 1)])
  908. #define PGET(B, X, Y) (AIND(B, X, Y) >> (((X)&1^1) << 2) & 15)
  909. #define PSET(B, X, Y, O) AIND(B, X, Y) = AIND(B, X, Y) & \
  910.   15 << (((X)&1) << 2) | (O) << (((X)&1^1) << 2)
  911.  
  912. #define PutByte(A) putc((byte) (A), data)
  913. #define PutWord(A) PutByte(LOBYTE(A)); PutByte(HIBYTE(A))
  914. #define PutLong(A) PutWord(LOWORD(A)); PutWord(HIWORD(A))
  915.  
  916. #define DrawEdge(X1, Y1, X2, Y2) DrawBox(X1, Y1, X2, Y2, 1, 1)
  917. #define DrawEdgeAll() DrawEdge(0, 0, chartx-1, charty-1)
  918. #define DrawLine(X1, Y1, X2, Y2) DrawDash(X1, Y1, X2, Y2, 0)
  919. #define DrawCircle(X, Y, RX, RY) \
  920.   DrawEllipse((X)-(RX), (Y)-(RY), (X)+(RX), (Y)+(RY))
  921.  
  922. extern void WriteFile();
  923. extern void PSbegin();
  924. extern void PSend();
  925. extern void WriteMeta();
  926. extern void DrawColor();
  927. extern void DrawPoint();
  928. extern void DrawSpot();
  929. extern void DrawBlock();
  930. extern void DrawBox();
  931. extern void DrawClearScreen();
  932. extern void DrawDash();
  933. extern void DrawWrap();
  934. extern void DrawClip();
  935. extern void DrawEllipse();
  936. extern void DrawText();
  937. extern void DrawSign();
  938. extern void DrawHouse();
  939. extern void DrawObject();
  940. extern void DrawAspect();
  941. extern void DrawTurtle();
  942.  
  943. /* From xcharts.c */
  944.  
  945. extern int DrawPrint();
  946. extern void DrawInfo();
  947. extern void XChartWheel();
  948. extern void XChartAstroGraph();
  949. extern void XChartGrid();
  950. extern void XChartHorizon();
  951. extern void XChartHorizonSky();
  952. extern void XChartSpace();
  953. extern void XChartEphemeris();
  954.  
  955. /* From xoptions.c */
  956.  
  957. extern bool Proper();
  958. extern bool InitCircle();
  959. extern void FillSymbolRing();
  960. extern void FillSymbolLine();
  961. extern int ReadWorldData();
  962. extern int GlobeCalc();
  963. extern void DrawGlobe();
  964. extern void DrawLeyLine();
  965. extern void DrawLeyLines();
  966. extern void DrawWorld();
  967. extern real XHousePlaceIn();
  968. extern void XChartWheelRelation();
  969. extern void XChartGridRelation();
  970. extern void XChartBiorhythm();
  971. extern void XChart();
  972.  
  973. /* From xdriver.c */
  974.  
  975. extern void XColorInit();
  976. extern void XDisplaySwitches();
  977. extern bool XAction();
  978. extern int XProcessSwitches();
  979. #endif /* GRAPH */
  980.  
  981. #ifdef PLACALC
  982. /* From placalc.c */
  983.  
  984. extern int PlacalcPlanet();
  985. extern double julday();
  986. extern void revjul();
  987. #endif
  988.  
  989. /* astrolog.h */
  990.