home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Interactive Guide / c-cplusplus-interactive-guide.iso / c_ref / csource1 / ast40dos / astrolog.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-04  |  29.7 KB  |  931 lines

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