home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume30 / astrolog / part03 < prev    next >
Encoding:
Text File  |  1992-06-18  |  54.8 KB  |  1,801 lines

  1. Newsgroups: comp.sources.misc
  2. From: cruiser1@u.washington.edu (Walter D. Pullen)
  3. Subject:  v30i064:  astrolog - Generation of astrology charts v2.25, Part03/08
  4. Message-ID: <1992Jun18.185618.12543@sparky.imd.sterling.com>
  5. X-Md4-Signature: 2cf02497839094002869f0377b042646
  6. Date: Thu, 18 Jun 1992 18:56:18 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: cruiser1@u.washington.edu (Walter D. Pullen)
  10. Posting-number: Volume 30, Issue 64
  11. Archive-name: astrolog/part03
  12. Environment: UNIX, VMS
  13. Supersedes: astrolog: Volume 28, Issue 104-109
  14.  
  15. #! /bin/sh
  16. # This is a shell archive.  Remove anything before this line, then unpack
  17. # it by saving it into a file and typing "sh file".  To overwrite existing
  18. # files, type "sh file -c".  You can also feed this as standard input via
  19. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  20. # will see the following message at the end:
  21. #        "End of archive 3 (of 8)."
  22. # Contents:  xcharts.c driver.c
  23. # Wrapped by cruiser1@milton.u.washington.edu on Thu Jun 11 21:53:37 1992
  24. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  25. if test -f 'xcharts.c' -a "${1}" != "-c" ; then 
  26.   echo shar: Will not clobber existing file \"'xcharts.c'\"
  27. else
  28. echo shar: Extracting \"'xcharts.c'\" \(31047 characters\)
  29. sed "s/^X//" >'xcharts.c' <<'END_OF_FILE'
  30. X/*
  31. X** Astrolog (Version 2.25) File: xcharts.c
  32. X** (Initially programmed 10/23-29/1991)
  33. X**
  34. X** IMPORTANT: the graphics database and chart display routines used in
  35. X** this program are Copyright (C) 1991-1992 by Walter D. Pullen. Permission
  36. X** is granted to freely use and distribute these routines provided one
  37. X** doesn't sell, restrict, or profit from them in any way. Modification
  38. X** is allowed provided these notices remain with any altered or edited
  39. X** versions of the program.
  40. X*/
  41. X
  42. X#include "astrolog.h"
  43. X
  44. X#ifdef X11
  45. X#include <X11/Xlib.h>
  46. X#include <X11/Xutil.h>
  47. X
  48. X#define ISLEGAL(X, Y) \
  49. X  ((X) >= 0 && (X) < chartx && (Y) >= 0 && (Y) < chartx)
  50. X#define edge(X1, Y1, X2, Y2, O) \
  51. X  rect(X1, Y1, X2, Y2, 1, 1, O)
  52. X#define rectall(XSIZ, YSIZ, O) \
  53. X  rect(0, 0, chartx-1, charty-1, XSIZ, YSIZ, O)
  54. X
  55. Xchar string[STRING];
  56. Xdouble symbol[TOTAL+1], circx[360+1], circy[360+1];
  57. X
  58. X
  59. X/*
  60. X*******************************************************************************
  61. X** Main subprograms
  62. X*******************************************************************************
  63. X*/
  64. X
  65. Xint proper(i)
  66. Xint i;
  67. X{
  68. X  int j = TRUE;
  69. X  if (modex == 'l')
  70. X    j = (i <= THINGS || i > objects+4);
  71. X  else if (modex == 'z' || modex == 'g')
  72. X    j = (i < THINGS || i > objects+4);
  73. X  else if (modex == 's')
  74. X    j = (i != 2 && (i < THINGS || i > objects+4));
  75. X  return j && !ignore[i];
  76. X}
  77. X
  78. Xdrawobject(i, x, y)
  79. Xint i, x, y;
  80. X{
  81. X  if (!label)
  82. X    return;
  83. X  if (modex != 's' && ((i == centerplanet && i > 2) ||
  84. X               (centerplanet == 0 && i == 1)))
  85. X    i = 0;
  86. X  if (i <= objects)
  87. X    turtle(objectdraw[i], x, y, objectcolor[i]);
  88. X  else if (!xbitmap) {
  89. X    Xcolor(objectcolor[i]);
  90. X    sprintf(string, "%c%c%c", OBJNAM(i));
  91. X    XDrawImageString(disp, pixmap, gc, x-strlen(string)*FONT_X/2, y+FONT_Y/2,
  92. X             string, strlen(string));
  93. X  }
  94. X}
  95. X
  96. Xfillsymbolring(symbol)
  97. Xdouble *symbol;
  98. X{
  99. X  int i, j, k = 1, l, k1, k2;
  100. X  double orb = DEFORB*256.0/(double)charty*(double)scale/100.0, temp;
  101. X  for (l = 0; k && l < 100; l++) {
  102. X    k = 0;
  103. X    for (i = 1; i <= total; i++) if (proper(i)) {
  104. X      k1 = 1000; k2 = -1000;
  105. X      for (j = 1; j <= total; j++)
  106. X    if (proper(j) && i != j) {
  107. X      temp = symbol[j]-symbol[i];
  108. X      if (dabs(temp) > 180.0)
  109. X        temp -= DEGREES*sgn(temp);
  110. X      if (temp<k1 && temp>=0.0)
  111. X        k1 = temp;
  112. X      else if (temp>k2 && temp<=0.0)
  113. X        k2 = temp;
  114. X    }
  115. X      if (k2>-orb && k1>orb) {
  116. X    k = 1; symbol[i] = mod(symbol[i]+orb*0.51+k2*0.49);
  117. X      } else if (k1<orb && k2<-orb) {
  118. X    k = 1; symbol[i] = mod(symbol[i]-orb*0.51+k1*0.49);
  119. X      } else if (k2>-orb && k1<orb) {
  120. X    k = 1; symbol[i] = mod(symbol[i]+(k1+k2)*0.5);
  121. X      }
  122. X    }
  123. X  }
  124. X}
  125. X
  126. X#define POINT(U, R, S) ((int) ((R)*(double)(U)*(S)+0.5))
  127. X#define PX(A) COSD(180.0-(A)+Asc)
  128. X#define PY(A) SIND(180.0-(A)+Asc)
  129. X
  130. Xxchartwheel()
  131. X{
  132. X  int cx = chartx / 2, cy = charty / 2, unit, i, j, count = 0;
  133. X  double Asc, orb = DEFORB*256.0/(double)charty*(double)scale/100.0, temp;
  134. X  if (xbitmap)
  135. X    block(0, 0, chartx - 1, charty - 1, off);
  136. X  rectall(1, 1, hilite);
  137. X  unit = MIN(cx, cy);
  138. X  Asc = house[1];
  139. X  for (i = 0; i < 360; i++) {
  140. X    circx[i] = cos((double) i / DEGTORAD);
  141. X    circy[i] = sin((double) i / DEGTORAD);
  142. X  }
  143. X  circx[360] = circx[0]; circy[360] = circy[0];
  144. X  drawline(cx+POINT(unit, 0.99, PX(house[1])),
  145. X       cy+POINT(unit, 0.99, PY(house[1])),
  146. X       cx+POINT(unit, 0.99, PX(house[7])),
  147. X       cy+POINT(unit, 0.99, PY(house[7])), hilite, 1-xcolor);
  148. X  drawline(cx+POINT(unit, 0.99, PX(house[10])),
  149. X       cy+POINT(unit, 0.99, PY(house[10])),
  150. X       cx+POINT(unit, 0.99, PX(house[4])),
  151. X       cy+POINT(unit, 0.99, PY(house[4])), hilite, 1-xcolor);
  152. X  for (i = 0; i < 360; i += 5-xcolor*4) {
  153. X    temp = (double) i;
  154. X    drawline(cx+POINT(unit, 0.80, PX(temp)), cy+POINT(unit, 0.80, PY(temp)),
  155. X         cx+POINT(unit, 0.75, PX(temp)), cy+POINT(unit, 0.75, PY(temp)),
  156. X         i%5 ? gray : on, 0);
  157. X  }
  158. X  for (i = 0; i < 360; i++) {
  159. X    drawline(cx+POINT(unit, 0.95, circx[i]), cy+POINT(unit, 0.95, circy[i]),
  160. X     cx+POINT(unit, 0.95, circx[i+1]), cy+POINT(unit, 0.95, circy[i+1]),
  161. X     on, 0);
  162. X    drawline(cx+POINT(unit, 0.80, circx[i]), cy+POINT(unit, 0.80, circy[i]),
  163. X     cx+POINT(unit, 0.80, circx[i+1]), cy+POINT(unit, 0.80, circy[i+1]),
  164. X     on, 0);
  165. X    drawline(cx+POINT(unit, 0.75, circx[i]), cy+POINT(unit, 0.75, circy[i]),
  166. X     cx+POINT(unit, 0.75, circx[i+1]), cy+POINT(unit, 0.75, circy[i+1]),
  167. X     on, 0);
  168. X    drawline(cx+POINT(unit, 0.65, circx[i]), cy+POINT(unit, 0.65, circy[i]),
  169. X     cx+POINT(unit, 0.65, circx[i+1]), cy+POINT(unit, 0.65, circy[i+1]),
  170. X     on, 0);
  171. X  }
  172. X  for (i = 1; i <= SIGNS; i++) {
  173. X    temp = (double) (i-1)*30.0;
  174. X    drawline(cx+POINT(unit, 0.95, PX(temp)),
  175. X     cy+POINT(unit, 0.95, PY(temp)),
  176. X     cx+POINT(unit, 0.80, PX(temp)),
  177. X     cy+POINT(unit, 0.80, PY(temp)), on, 0);
  178. X    drawline(cx+POINT(unit, 0.75, PX(house[i])),
  179. X     cy+POINT(unit, 0.75, PY(house[i])),
  180. X     cx+POINT(unit, 0.65, PX(house[i])),
  181. X     cy+POINT(unit, 0.65, PY(house[i])), on, 0);
  182. X    if (xcolor && i%3 != 1)
  183. X      drawline(cx, cy, cx+POINT(unit, 0.65, PX(house[i])),
  184. X           cy+POINT(unit, 0.65, PY(house[i])), gray, 1);
  185. X    temp += 15.0;
  186. X    turtle(signdraw[i], cx+POINT(unit, 0.875, PX(temp)),
  187. X       cy+POINT(unit, 0.875, PY(temp)), elemcolor[(i-1)%4]);
  188. X    temp = midpoint(house[i], house[mod12(i+1)]);
  189. X    turtle(housedraw[i], cx+POINT(unit, 0.70, PX(temp)),
  190. X       cy+POINT(unit, 0.70, PY(temp)), elemcolor[(i-1)%4]);
  191. X  }
  192. X  for (i = 1; i <= total; i++) {
  193. X    symbol[i] = planet[i];
  194. X  }
  195. X  fillsymbolring(symbol);
  196. X  for (i = 1; i <= total; i++) if (proper(i)) {
  197. X    temp = symbol[i];
  198. X    drawline(cx+POINT(unit, 0.52, PX(planet[i])),
  199. X         cy+POINT(unit, 0.52, PY(planet[i])),
  200. X         cx+POINT(unit, 0.56, PX(temp)),
  201. X         cy+POINT(unit, 0.56, PY(temp)),
  202. X         ret[i] < 0.0 ? gray : on, (ret[i] < 0.0 ? 1 : 0) - xcolor);
  203. X    drawobject(i, cx+POINT(unit, 0.60, PX(temp)),
  204. X           cy+POINT(unit, 0.60, PY(temp)));
  205. X    drawpoint(cx+POINT(unit, 0.50, PX(planet[i])),
  206. X          cy+POINT(unit, 0.50, PY(planet[i])), objectcolor[i]);
  207. X  }
  208. X  if (bonus)
  209. X    return;
  210. X  creategrid(FALSE);
  211. X  for (j = total; j >= 2; j--)
  212. X    for (i = j-1; i >= 1; i--)
  213. X      if (gridname[i][j] && proper(i) && proper(j))
  214. X    drawline(cx+POINT(unit, 0.48, PX(planet[i])),
  215. X         cy+POINT(unit, 0.48, PY(planet[i])),
  216. X         cx+POINT(unit, 0.48, PX(planet[j])),
  217. X         cy+POINT(unit, 0.48, PY(planet[j])),
  218. X         aspectcolor[gridname[i][j]], abs(grid[i][j]/20));
  219. X}
  220. X
  221. Xxchartwheelrelation()
  222. X{
  223. X  int cx = chartx / 2, cy = charty / 2, unit, i, j;
  224. X  double Asc, temp;
  225. X  if (xbitmap)
  226. X    block(0, 0, chartx - 1, charty - 1, off);
  227. X  rectall(1, 1, hilite);
  228. X  unit = MIN(cx, cy);
  229. X  Asc = house1[1];
  230. X  for (i = 0; i < 360; i++) {
  231. X    circx[i] = cos((double) i / DEGTORAD);
  232. X    circy[i] = sin((double) i / DEGTORAD);
  233. X  }
  234. X  circx[360] = circx[0]; circy[360] = circy[0];
  235. X  drawline(cx+POINT(unit, 0.99, PX(house1[1])),
  236. X       cy+POINT(unit, 0.99, PY(house1[1])),
  237. X       cx+POINT(unit, 0.99, PX(house1[7])),
  238. X       cy+POINT(unit, 0.99, PY(house1[7])), hilite, 1-xcolor);
  239. X  drawline(cx+POINT(unit, 0.99, PX(house1[10])),
  240. X       cy+POINT(unit, 0.99, PY(house1[10])),
  241. X       cx+POINT(unit, 0.99, PX(house1[4])),
  242. X       cy+POINT(unit, 0.99, PY(house1[4])), hilite, 1-xcolor);
  243. X  for (i = 0; i < 360; i += 5-xcolor*4) {
  244. X    temp = (double) i;
  245. X    drawline(cx+POINT(unit, 0.82, PX(temp)), cy+POINT(unit, 0.82, PY(temp)),
  246. X         cx+POINT(unit, 0.78, PX(temp)), cy+POINT(unit, 0.78, PY(temp)),
  247. X         i%5 ? gray : on, 0);
  248. X  }
  249. X  for (i = 0; i < 360; i++) {
  250. X    drawline(cx+POINT(unit, 0.95, circx[i]), cy+POINT(unit, 0.95, circy[i]),
  251. X     cx+POINT(unit, 0.95, circx[i+1]), cy+POINT(unit, 0.95, circy[i+1]),
  252. X     on, 0);
  253. X    drawline(cx+POINT(unit, 0.82, circx[i]), cy+POINT(unit, 0.82, circy[i]),
  254. X     cx+POINT(unit, 0.82, circx[i+1]), cy+POINT(unit, 0.82, circy[i+1]),
  255. X     on, 0);
  256. X    drawline(cx+POINT(unit, 0.78, circx[i]), cy+POINT(unit, 0.78, circy[i]),
  257. X     cx+POINT(unit, 0.78, circx[i+1]), cy+POINT(unit, 0.78, circy[i+1]),
  258. X     on, 0);
  259. X    drawline(cx+POINT(unit, 0.70, circx[i]), cy+POINT(unit, 0.70, circy[i]),
  260. X     cx+POINT(unit, 0.70, circx[i+1]), cy+POINT(unit, 0.70, circy[i+1]),
  261. X     on, 0);
  262. X  }
  263. X  for (i = 1; i <= SIGNS; i++) {
  264. X    temp = (double) (i-1)*30.0;
  265. X    drawline(cx+POINT(unit, 0.95, PX(temp)),
  266. X     cy+POINT(unit, 0.95, PY(temp)),
  267. X     cx+POINT(unit, 0.82, PX(temp)),
  268. X     cy+POINT(unit, 0.82, PY(temp)), on, 0);
  269. X    drawline(cx+POINT(unit, 0.78, PX(house1[i])),
  270. X     cy+POINT(unit, 0.78, PY(house1[i])),
  271. X     cx+POINT(unit, 0.70, PX(house1[i])),
  272. X     cy+POINT(unit, 0.70, PY(house1[i])), on, 0);
  273. X    if (xcolor && i%3 != 1)
  274. X      drawline(cx, cy, cx+POINT(unit, 0.70, PX(house1[i])),
  275. X           cy+POINT(unit, 0.70, PY(house1[i])), gray, 1);
  276. X    temp += 15.0;
  277. X    turtle(signdraw[i], cx+POINT(unit, 0.885, PX(temp)),
  278. X       cy+POINT(unit, 0.885, PY(temp)), elemcolor[(i-1)%4]);
  279. X    temp = midpoint(house1[i], house1[mod12(i+1)]);
  280. X    turtle(housedraw[i], cx+POINT(unit, 0.74, PX(temp)),
  281. X       cy+POINT(unit, 0.74, PY(temp)), elemcolor[(i-1)%4]);
  282. X  }
  283. X  for (i = 1; i <= total; i++) {
  284. X    symbol[i] = planet2[i];
  285. X  }
  286. X  fillsymbolring(symbol);
  287. X  for (i = 1; i <= total; i++) if (proper(i)) {
  288. X    temp = symbol[i];
  289. X    drawline(cx+POINT(unit, 0.58, PX(planet2[i])),
  290. X         cy+POINT(unit, 0.58, PY(planet2[i])),
  291. X         cx+POINT(unit, 0.61, PX(temp)),
  292. X         cy+POINT(unit, 0.61, PY(temp)),
  293. X         ret2[i] < 0.0 ? gray : on, (ret2[i] < 0.0 ? 1 : 0) - xcolor);
  294. X    drawobject(i, cx+POINT(unit, 0.65, PX(temp)),
  295. X           cy+POINT(unit, 0.65, PY(temp)));
  296. X    drawpoint(cx+POINT(unit, 0.56, PX(planet2[i])),
  297. X          cy+POINT(unit, 0.56, PY(planet2[i])), objectcolor[i]);
  298. X    drawpoint(cx+POINT(unit, 0.43, PX(planet2[i])),
  299. X          cy+POINT(unit, 0.43, PY(planet2[i])), objectcolor[i]);
  300. X    drawline(cx+POINT(unit, 0.45, PX(planet2[i])),
  301. X         cy+POINT(unit, 0.45, PY(planet2[i])),
  302. X         cx+POINT(unit, 0.54, PX(planet2[i])),
  303. X         cy+POINT(unit, 0.54, PY(planet2[i])),
  304. X         ret2[i] < 0.0 ? gray : on, 2-xcolor);
  305. X  }
  306. X  for (i = 1; i <= total; i++) {
  307. X    symbol[i] = planet1[i];
  308. X  }
  309. X  fillsymbolring(symbol);
  310. X  for (i = 1; i <= total; i++) if (proper(i)) {
  311. X    temp = symbol[i];
  312. X    drawline(cx+POINT(unit, 0.45, PX(planet1[i])),
  313. X         cy+POINT(unit, 0.45, PY(planet1[i])),
  314. X         cx+POINT(unit, 0.48, PX(temp)),
  315. X         cy+POINT(unit, 0.48, PY(temp)),
  316. X         ret1[i] < 0.0 ? gray : on, (ret1[i] < 0.0 ? 1 : 0) - xcolor);
  317. X    drawobject(i, cx+POINT(unit, 0.52, PX(temp)),
  318. X           cy+POINT(unit, 0.52, PY(temp)));
  319. X    drawpoint(cx+POINT(unit, 0.43, PX(planet1[i])),
  320. X          cy+POINT(unit, 0.43, PY(planet1[i])), objectcolor[i]);
  321. X  }
  322. X  if (bonus)
  323. X    return;
  324. X  createrelationgrid(FALSE);
  325. X  for (j = total; j >= 1; j--)
  326. X    for (i = total; i >= 1; i--)
  327. X      if (gridname[i][j] && proper(i) && proper(j))
  328. X    drawline(cx+POINT(unit, 0.41, PX(planet1[j])),
  329. X         cy+POINT(unit, 0.41, PY(planet1[j])),
  330. X         cx+POINT(unit, 0.41, PX(planet2[i])),
  331. X         cy+POINT(unit, 0.41, PY(planet2[i])),
  332. X         aspectcolor[gridname[i][j]], abs(grid[i][j]/20));
  333. X}
  334. X
  335. X#define GLOBECALC \
  336. Xif (modex == 'g') { \
  337. X  x1 = mod(x1+(double)deg); \
  338. X  if (tilt != 0.0) { \
  339. X    x1 = DTOR(x1); y1 = DTOR(90.0-y1); \
  340. X    coorxform(&x1, &y1, tilt / DEGTORAD); \
  341. X    x1 = mod(RTOD(x1)); y1 = 90.0-RTOD(y1); } \
  342. X  o = x1 > 180.0; \
  343. X  v = cy + (int) ((double)(ry+1)*-COSD(y1)); \
  344. X  u = cx + (int) ((double)(rx+1)*-COSD(x1)*SIND(y1)); \
  345. X} else { \
  346. X  if (bonus ? y1 < 90.0 : y1 > 90.0) \
  347. X    o = 1; \
  348. X  j = bonus ? 90.0+x1+deg : 270.0-x1-deg; \
  349. X  v = cy + (int) (SIND(y1)*(double)(ry+1)*SIND(j)); \
  350. X  u = cx + (int) (SIND(y1)*(double)(rx+1)*COSD(j)); \
  351. X}
  352. X
  353. Xdrawglobe(deg)
  354. Xint deg;
  355. X{
  356. X  char *nam, *loc, *lin;
  357. X  int X[TOTAL+1], Y[TOTAL+1], M[TOTAL+1], N[TOTAL+1],
  358. X    cx = chartx / 2, cy = charty / 2, rx, ry, lon, lat, unit = 12*scale/100,
  359. X    x, y, m, n, u, v, o = 0, i, J, k, l;
  360. X  double planet1[TOTAL+1], planet2[TOTAL+1], x1, y1, j;
  361. X  color c;
  362. X  if (xbitmap)
  363. X    block(0, 0, chartx - 1, charty - 1, off);
  364. X  rx = cx-1; ry = cy-1;
  365. X  while (readworlddata(&nam, &loc, &lin)) {
  366. X    i = nam[0]-'0';
  367. X    c = (modex == 'g' && bonus) ? gray : (i ? rainbowcolor[i] : maincolor[6]);
  368. X    lon = (loc[0] == '+' ? 1 : -1)*
  369. X      ((loc[1]-'0')*100 + (loc[2]-'0')*10 + (loc[3]-'0'));
  370. X    lat = (loc[4] == '+' ? 1 : -1)*((loc[5]-'0')*10 + (loc[6]-'0'));
  371. X    x = 180-lon;
  372. X    y = 90-lat;
  373. X    x1 = (double) x; y1 = (double) y; GLOBECALC; m = u; n = v;
  374. X    for (i = 0; lin[i]; i++) {
  375. X      if (lin[i] == 'L' || lin[i] == 'H' || lin[i] == 'G')
  376. X    x--;
  377. X      else if (lin[i] == 'R' || lin[i] == 'E' || lin[i] == 'F')
  378. X    x++;
  379. X      if (lin[i] == 'U' || lin[i] == 'H' || lin[i] == 'E')
  380. X    y--;
  381. X      else if (lin[i] == 'D' || lin[i] == 'G' || lin[i] == 'F')
  382. X    y++;
  383. X      if (x > 359)
  384. X    x = 0;
  385. X      else if (x < 0)
  386. X    x = 359;
  387. X      x1 = (double) x; y1 = (double) y; GLOBECALC;
  388. X      if (!o)
  389. X    drawline(m, n, u, v, c, 0);
  390. X      else
  391. X    o = 0;
  392. X      m = u; n = v;
  393. X    }
  394. X  }
  395. X  m = cx+rx+1; n = cy;
  396. X  for (i = 0; i <= 360; i++) {
  397. X    u = cx+(rx+1)*COSD(i); v = cy+(ry+1)*SIND(i);
  398. X    u = MIN(u, cx+rx); v = MIN(v, cy+ry);
  399. X    drawline(m, n, u, v, on, 0); m = u; n = v;
  400. X  }
  401. X  if (modex != 'g' || !bonus)
  402. X    return;
  403. X  j = Lon;
  404. X  if (j < 0.0)
  405. X    j += DEGREES;
  406. X  for (i = 1; i <= total; i++) {
  407. X    planet1[i] = DTOR(planet[i]);
  408. X    planet2[i] = DTOR(planetalt[i]);
  409. X    ecltoequ(&planet1[i], &planet2[i]);
  410. X  }
  411. X  for (i = 1; i <= total; i++) if (proper(i)) {
  412. X    x1 = planet1[18]-planet1[i];
  413. X    if (x1 < 0.0)
  414. X      x1 += 2.0*PI;
  415. X    if (x1 > PI)
  416. X      x1 -= 2.0*PI;
  417. X    x1 = mod(180.0-j-RTOD(x1));
  418. X    y1 = 90.0-RTOD(planet2[i]);
  419. X    GLOBECALC;
  420. X    X[i] = o ? -1000 : u; Y[i] = v; M[i] = X[i]; N[i] = Y[i]+unit/2;
  421. X  }
  422. X  for (i = 1; i <= total; i++) if (proper(i)) {
  423. X    k = l = chartx+charty;
  424. X    for (J = 1; J < i; J++) if (proper(J)) {
  425. X      k = MIN(k, abs(M[i]-M[J])+abs(N[i]-N[J]));
  426. X      l = MIN(l, abs(M[i]-M[J])+abs(N[i]-unit-N[J]));
  427. X    }
  428. X    if (k < unit || l < unit)
  429. X      if (k < l)
  430. X    N[i] -= unit;
  431. X  }
  432. X  for (i = total; i >= 1; i--) if (X[i] >= 0 && proper(i))
  433. X    drawobject(i, M[i], N[i]);
  434. X  for (i = total; i >= 1; i--) if (X[i] >= 0 && proper(i)) {
  435. X    if (!xbitmap)
  436. X      Xcolor(objectcolor[i]);
  437. X    drawspot(X[i], Y[i], objectcolor[i]);
  438. X  }
  439. X}
  440. X
  441. Xdrawleyline(l1, f1, l2, f2, o)
  442. Xdouble l1, f1, l2, f2;
  443. Xbit o;
  444. X{
  445. X  l1 = mod(l1); l2 = mod(l2);
  446. X  f1 = 90.0-ASIN(f1)/(PI/2.0)*90.0; f2 = 90.0-ASIN(f2)/(PI/2.0)*90.0;
  447. X  drawline2((int) (l1*(double)(scale/100)+0.5)+1,
  448. X        (int) (f1*(double)(scale/100)+0.5)+1,
  449. X        (int) (l2*(double)(scale/100)+0.5)+1,
  450. X        (int) (f2*(double)(scale/100)+0.5)+1, o);
  451. X}
  452. X
  453. Xdrawleylines()
  454. X{
  455. X  color icosa, dodeca;
  456. X  float off = 0.0, phi, h, h1, h2, r, i;
  457. X  icosa = aspectcolor[5]; dodeca = hilite;
  458. X  phi = (sqrt(5.0)+1.0)/2.0;
  459. X  h = 1.0/(phi*2.0-1.0);
  460. X  for (i = off; i < DEGREES+off; i += 72.0) {
  461. X    drawleyline(i, h, i+72.0, h, icosa);
  462. X    drawleyline(i-36.0, -h, i+36.0, -h, icosa);
  463. X    drawleyline(i, h, i, 1.0, icosa);
  464. X    drawleyline(i+36.0, -h, i+36.0, -1.0, icosa);
  465. X    drawleyline(i, h, i+36.0, -h, icosa);
  466. X    drawleyline(i, h, i-36.0, -h, icosa);
  467. X  }
  468. X  r = 1.0/sqrt(3.0)/phi/cos(DTOR(54.0));
  469. X  h2 = sqrt(1.0-r*r); h1 = h2/(phi*2.0+1.0);
  470. X  for (i = off; i < DEGREES+off; i += 72.0) {
  471. X    drawleyline(i-36.0, h2, i+36.0, h2, dodeca);
  472. X    drawleyline(i, -h2, i+72.0, -h2, dodeca);
  473. X    drawleyline(i+36.0, h2, i+36.0, h1, dodeca);
  474. X    drawleyline(i, -h2, i, -h1, dodeca);
  475. X    drawleyline(i+36.0, h1, i+72.0, -h1, dodeca);
  476. X    drawleyline(i+36.0, h1, i, -h1, dodeca);
  477. X  }
  478. X}
  479. X
  480. Xdrawworld()
  481. X{
  482. X  char *nam, *loc, *lin;
  483. X  int lon, lat, x, y, xold, yold, i;
  484. X  color c;
  485. X  if (chartx > BITMAPX) {
  486. X    fprintf(stderr, "Scale factor of %d too large for worldmap.\n", scale);
  487. X    exit(1);
  488. X  }
  489. X  if (xbitmap)
  490. X    block(0, 0, chartx - 1, charty - 1, off);
  491. X  rectall(1, 1, hilite);
  492. X  while (readworlddata(&nam, &loc, &lin)) {
  493. X    i = nam[0]-'0';
  494. X    c = modex == 'l' ? on : (i ? rainbowcolor[i] : maincolor[6]);
  495. X    lon = (loc[0] == '+' ? 1 : -1)*
  496. X      ((loc[1]-'0')*100 + (loc[2]-'0')*10 + (loc[3]-'0'));
  497. X    lat = (loc[4] == '+' ? 1 : -1)*((loc[5]-'0')*10 + (loc[6]-'0'));
  498. X    xold = x = 180-lon;
  499. X    yold = y = 91-lat;
  500. X    for (i = 0; lin[i]; i++) {
  501. X      if (lin[i] == 'L' || lin[i] == 'H' || lin[i] == 'G')
  502. X    x--;
  503. X      else if (lin[i] == 'R' || lin[i] == 'E' || lin[i] == 'F')
  504. X    x++;
  505. X      if (lin[i] == 'U' || lin[i] == 'H' || lin[i] == 'E')
  506. X    y--;
  507. X      else if (lin[i] == 'D' || lin[i] == 'G' || lin[i] == 'F')
  508. X    y++;
  509. X      if (x > 360) {
  510. X    x = 1;
  511. X    xold = 0;
  512. X      }
  513. X      drawline(xold*scale/100, yold*scale/100,
  514. X           x*scale/100, y*scale/100, c, 0);
  515. X      if (x < 1)
  516. X    x = 360;
  517. X      xold = x; yold = y;
  518. X    }
  519. X  }
  520. X}
  521. X
  522. Xdrawline2(xold, yold, xnew, ynew, o)
  523. Xint xold, yold, xnew, ynew;
  524. Xbit o;
  525. X{
  526. X  int xmid, ymid, i;
  527. X  if (xold < 0) {
  528. X    drawpoint(xnew, ynew, o);
  529. X    return;
  530. X  }
  531. X  xmid = 180*scale/100;
  532. X  if (dabs((double)(xnew-xold)) < (double) xmid) {
  533. X    drawline(xold, yold, xnew, ynew, o, 0);
  534. X    return;
  535. X  }
  536. X  i = xold < xmid ? xold+chartx-xnew-2 : xnew+chartx-xold-2;
  537. X  ymid = yold+(int)((double)(ynew-yold)*
  538. X    (xold < xmid ? (double)(xold-1) : (double)(chartx-xold-2))/(double)i);
  539. X  drawline(xold, yold, xold < xmid ? 1 : chartx-2, ymid, o, 0);
  540. X  drawline(xnew < xmid ? 1 : chartx-2, ymid, xnew, ynew, o, 0);
  541. X}
  542. X
  543. Xfillsymbolline(symbol)
  544. Xdouble *symbol;
  545. X{
  546. X  double orb = DEFORB*1.35*(double)scale/100.0,
  547. X    max = DEGREES*(double)scale/100.0, temp;
  548. X  int i, j, k = 1, l, k1, k2;
  549. X  for (l = 0; k && l < 100; l++) {
  550. X    k = 0;
  551. X    for (i = 1; i <= TOTAL*2; i++) {
  552. X      if (proper((i+1)/2) && symbol[i] >= 0.0) {
  553. X    k1 = max-symbol[i]; k2 = -symbol[i];
  554. X    for (j = 1; j <= THINGS*2; j++) {
  555. X      if (proper((j+1)/2) && i != j) {
  556. X        temp = symbol[j]-symbol[i];
  557. X        if (temp<k1 && temp>=0.0)
  558. X          k1 = temp;
  559. X        else if (temp>k2 && temp<=0.0)
  560. X          k2 = temp;
  561. X      }
  562. X    }
  563. X    if (k2>-orb && k1>orb) {
  564. X      k = 1; symbol[i] = symbol[i]+orb*0.51+k2*0.49;
  565. X    } else if (k1<orb && k2<-orb) {
  566. X      k = 1; symbol[i] = symbol[i]-orb*0.51+k1*0.49;
  567. X    } else if (k2>-orb && k1<orb) {
  568. X      k = 1; symbol[i] = symbol[i]+(k1+k2)*0.5;
  569. X    }
  570. X      }
  571. X    }
  572. X  }
  573. X}
  574. X
  575. Xxchartastrograph()
  576. X{
  577. X  double planet1[TOTAL+1], planet2[TOTAL+1],
  578. X    end1[TOTAL*2+1], end2[TOTAL*2+1],
  579. X    symbol1[TOTAL*2+1], symbol2[TOTAL*2+1],
  580. X    lon = deflong, longm, x, y, z, ad, oa, am, od, dm, lat;
  581. X  int unit, lat1 = -60, lat2 = 75, y1, y2, xold1, xold2, i, j, k;
  582. X  unit = scale/100;
  583. X  y1 = (91-lat1)*scale/100.0;
  584. X  y2 = (91-lat2)*scale/100.0;
  585. X  block(1, 1, chartx-2, y2-1, off);
  586. X  block(1, charty-2, chartx-2, y1+1, off);
  587. X  drawline(0, charty/2, chartx-2, charty/2, hilite, 4);
  588. X  drawline(1, y2, chartx-2, y2, on, 0);
  589. X  drawline(1, y1, chartx-2, y1, on, 0);
  590. X  for (i = 1; i <= total*2; i++)
  591. X    end1[i] = end2[i] = -1000.0;
  592. X  for (i = lat1; i <= lat2; i += 5) {
  593. X    j = (91-i)*scale/100.0;
  594. X    k = 2+(i/10*10 == i ? 1 : 0)+(i/30*30 == i ? 2 : 0);
  595. X    drawline(1, j, k, j, hilite, 0);
  596. X    drawline(chartx-2, j, chartx-1-k, j, hilite, 0);
  597. X  }
  598. X  for (i = -180; i < 180; i += 5) {
  599. X    j = (180-i)*scale/100.0;
  600. X    k = 2+(i/10*10 == i ? 1 : 0)+(i/30*30 == i ? 2 : 0)+(i/90*90 == i ? 1 : 0);
  601. X    drawline(j, y2+1, j, y2+k, hilite, 0);
  602. X    drawline(j, y1-1, j, y1-k, hilite, 0);
  603. X  }
  604. X  for (i = 1; i <= total; i++) {
  605. X    planet1[i] = DTOR(planet[i]);
  606. X    planet2[i] = DTOR(planetalt[i]);
  607. X    ecltoequ(&planet1[i], &planet2[i]);
  608. X  }
  609. X  if (lon < 0.0)
  610. X    lon += DEGREES;
  611. X  for (i = 1; i <= total; i++) if (proper(i)) {
  612. X    x = planet1[18]-planet1[i];
  613. X    if (x < 0.0)
  614. X      x += 2.0*PI;
  615. X    if (x > PI)
  616. X      x -= 2.0*PI;
  617. X    z = lon+RTOD(x);
  618. X    if (z > 180.0)
  619. X      z -= DEGREES;
  620. X    j = (int) ((180.0-z)*(double)scale/100.0);
  621. X    drawline(j, y1+unit*4, j, y2-unit*1, elemcolor[1], 0);
  622. X    end2[i*2-1] = (double) j;
  623. X    y = RTOD(planet2[i]);
  624. X    k = (int) ((91.0-y)*(double)scale/100.0);
  625. X    block(j-1, k-1, j+1, k+1, hilite);
  626. X    block(j, k, j, k, off);
  627. X    if (!bonus) {
  628. X      j += 180*scale/100;
  629. X      if (j > chartx-2)
  630. X    j -= (chartx-2);
  631. X      end1[i*2-1] = (double) j;
  632. X      drawline(j, y1+unit*2, j, y2-unit*2, elemcolor[3], 0);
  633. X    }
  634. X  }
  635. X  longm = DTOR(mod(RTOD(planet1[18])+lon));
  636. X  if (!bonus) for (i = 1; i <= total; i++) if (proper(i)) {
  637. X    xold1 = xold2 = -1000;
  638. X    for (lat = (double) lat1; lat <= (double) lat2;
  639. X     lat += 100.0/(double)scale) {
  640. X      j = (int) ((91.0-lat)*(double)scale/100.0);
  641. X      ad = tan(planet2[i])*tan(DTOR(lat));
  642. X      if (ad*ad > 1.0)
  643. X    ad = 1000.0;
  644. X      else {
  645. X    ad = ASIN(ad);
  646. X    oa = planet1[i]-ad;
  647. X    if (oa < 0.0)
  648. X      oa += 2.0*PI;
  649. X    am = oa-PI/2.0;
  650. X    if (am < 0.0)
  651. X      am += 2.0*PI;
  652. X    z = longm-am;
  653. X    if (z < 0.0)
  654. X      z += 2.0*PI;
  655. X    if (z > PI)
  656. X      z -= 2.0*PI;
  657. X    z = RTOD(z);
  658. X    k = (int) ((180.0-z)*(double)scale/100.0);
  659. X    drawline2(xold1, j+1, k, j, elemcolor[0]);
  660. X    if (lat == (double) lat1) {
  661. X      drawline(k, y1, k, y1+unit*4, elemcolor[0], 0);
  662. X      end2[i*2] = (double) k;
  663. X    }
  664. X    xold1 = k;
  665. X      }
  666. X      if (ad == 1000.0) {
  667. X    if (xold1 >= 0) {
  668. X      drawline2(xold1, j+1, xold2, j+1, gray);
  669. X      lat = 90.0;
  670. X    }
  671. X      } else {
  672. X    od = planet1[i]+ad;
  673. X    dm = od+PI/2.0;
  674. X    z = longm-dm;
  675. X    if (z < 0.0)
  676. X      z += 2.0*PI;
  677. X    if (z > PI)
  678. X      z -= 2.0*PI;
  679. X    z = RTOD(z);
  680. X    k = (int) ((180.0-z)*(double)scale/100.0);
  681. X    drawline2(xold2, j+1, k, j, elemcolor[2]);
  682. X    if (xold2 < 0)
  683. X      drawline2(xold1, j, k, j, elemcolor[2]);
  684. X    if (lat == (double) lat1)
  685. X      drawline(k, y1, k, y1+unit*2, elemcolor[2], 0);
  686. X    xold2 = k;
  687. X      }
  688. X    }
  689. X    if (ad != 1000.0) {
  690. X      drawline(xold1, y2, xold1, y2-unit*1, elemcolor[0], 0);
  691. X      drawline(k, y2, k, y2-unit*2, elemcolor[2], 0);
  692. X      end1[i*2] = (double) k;
  693. X    }
  694. X    if (!xbitmap)
  695. X      Xcolor(on);
  696. X  }
  697. X  for (i = 1; i <= total*2; i++) {
  698. X    symbol1[i] = end1[i];
  699. X    symbol2[i] = end2[i];
  700. X  }
  701. X  fillsymbolline(symbol1);
  702. X  fillsymbolline(symbol2);
  703. X  for (i = 1; i <= total*2; i++) {
  704. X    j = (i+1)/2;
  705. X    if (proper(j)) {
  706. X      if ((turtlex = (int) symbol1[i]) > 0) {
  707. X    drawline((int) end1[i], y2-unit*2, (int) symbol1[i], y2-unit*4,
  708. X         ret[j] ? gray : on, (ret[i] < 0.0 ? 1 : 0) - xcolor);
  709. X    drawobject(j, turtlex, y2-unit*10);
  710. X      }
  711. X      if ((turtlex = (int) symbol2[i]) > 0) {
  712. X    drawline((int) end2[i], y1+unit*4, (int) symbol2[i], y1+unit*8,
  713. X         ret[j] ? gray : on, (ret[i] < 0.0 ? 1 : 0) - xcolor);
  714. X    drawobject(j, turtlex, y1+unit*14);
  715. X    turtle(objectdraw[i & 1 ? 18 : 19], (int) symbol2[i],
  716. X           y1+unit*24, objectcolor[j]);
  717. X      }
  718. X    }
  719. X  }
  720. X}
  721. X
  722. Xxchartaspectgrid()
  723. X{
  724. X  int unit, siz, x, y, i, j, k;
  725. X  if (chartx > BITMAPX) {
  726. X    fprintf(stderr, "Scale factor of %d too large for aspect grid.\n", scale);
  727. X    exit(1);
  728. X  }
  729. X  unit = CELLSIZE*scale/100; siz = objects*unit;
  730. X  if (xbitmap)
  731. X    block(0, 0, chartx - 1, charty - 1, off);
  732. X  creategrid(TRUE+bonus);
  733. X  for (y = 1, j = 0; y <= objects; y++) {
  734. X    do {
  735. X      j++;
  736. X    } while (ignore[j] && j <= total);
  737. X    drawline(0, y*unit, siz, y*unit, gray, 1-xcolor);
  738. X    drawline(y*unit, 0, y*unit, siz, gray, 1-xcolor);
  739. X    if (j <= total) for (x = 1, i = 0; x <= objects; x++) {
  740. X      do {
  741. X    i++;
  742. X      } while (ignore[i] && i <= total);
  743. X      if (i <= total) {
  744. X    turtlex = x*unit-unit/2;
  745. X    turtley = y*unit-unit/2 - (scale > 200 ? 5 : 0);
  746. X    if (bonus ? x > y : x < y)
  747. X      turtle(aspectdraw[gridname[i][j]], turtlex,
  748. X         turtley, aspectcolor[gridname[i][j]]);
  749. X    else if (bonus ? x < y : x > y)
  750. X      turtle(signdraw[gridname[i][j]], turtlex,
  751. X         turtley, elemcolor[(gridname[i][j]-1)%4]);
  752. X    else {
  753. X      edge((y-1)*unit, (y-1)*unit, y*unit, y*unit, hilite);
  754. X      drawobject(i, turtlex, turtley);
  755. X    }
  756. X    if (!xbitmap && scale > 200 && label) {
  757. X      k = abs(grid[i][j]);
  758. X      if (bonus ? x > y : x < y) {
  759. X        if (gridname[i][j])
  760. X          sprintf(string, "%c%d %d%d'", k != grid[i][j] ? '-' : '+',
  761. X              k/60, (k%60)/10, (k%60)%10);
  762. X        else
  763. X          sprintf(string, "");
  764. X      } else if (bonus ? x < y : x > y)
  765. X        sprintf(string, "%d%d %d%d'",
  766. X            (k/60)/10, (k/60)%10, (k%60)/10, (k%60)%10);
  767. X      else {
  768. X        Xcolor(elemcolor[(gridname[i][j]-1)%4]);
  769. X        sprintf(string, "%c%c%c %d%d", SIGNAM(gridname[i][j]), k/10, k%10);
  770. X      }
  771. X      XDrawImageString(disp, pixmap, gc, x*unit-unit/2-FONT_X*3, y*unit-3,
  772. X               string, strlen(string));
  773. X    }
  774. X      }
  775. X    }
  776. X  }
  777. X  rectall(1, 1, hilite);
  778. X}
  779. X
  780. Xxchartrelationaspectgrid()
  781. X{
  782. X  int unit, siz, x, y, i, j, k, l;
  783. X  if (chartx > BITMAPX) {
  784. X    fprintf(stderr, "Scale factor of %d too large for aspect grid.\n", scale);
  785. X    exit(1);
  786. X  }
  787. X  unit = CELLSIZE*scale/100; siz = (objects+1)*unit;
  788. X  if (xbitmap)
  789. X    block(0, 0, chartx - 1, charty - 1, off);
  790. X  createrelationgrid(TRUE+bonus);
  791. X  for (y = 0, j = -1; y <= objects; y++) {
  792. X    do {
  793. X      j++;
  794. X    } while (ignore[j] && j <= total);
  795. X    drawline(0, (y+1)*unit, siz, (y+1)*unit, gray, 1-xcolor);
  796. X    drawline((y+1)*unit, 0, (y+1)*unit, siz, gray, 1-xcolor);
  797. X    edge(0, y*unit, unit, (y+1)*unit, hilite);
  798. X    edge(y*unit, 0, (y+1)*unit, unit, hilite);
  799. X    if (j <= total) for (x = 0, i = -1; x <= objects; x++) {
  800. X      do {
  801. X    i++;
  802. X      } while (ignore[i] && i <= total);
  803. X      if (i <= total) {
  804. X    turtlex = x*unit+unit/2;
  805. X    turtley = y*unit+unit/2 - (!xbitmap && scale > 200 ? 5 : 0);
  806. X    if (y == 0 || x == 0) {
  807. X      if (x+y > 0)
  808. X        drawobject(j == 0 ? i : j, turtlex, turtley);
  809. X    } else {
  810. X      if (!bonus)
  811. X        turtle(aspectdraw[gridname[i][j]], turtlex, turtley,
  812. X           aspectcolor[gridname[i][j]]);
  813. X      else
  814. X        turtle(signdraw[gridname[i][j]], turtlex, turtley,
  815. X           elemcolor[(gridname[i][j]-1)%4]);
  816. X    }
  817. X    if (!xbitmap && scale > 200 && label) {
  818. X      if (y == 0 || x == 0) {
  819. X        if (x+y > 0) {
  820. X          k = (int)((y == 0 ? planet2[i] : planet1[j])/30.0)+1;
  821. X          l = (int)((y == 0 ? planet2[i] : planet1[j])-(double)(k-1)*30.0);
  822. X          Xcolor(elemcolor[(k-1)%4]);
  823. X          sprintf(string, "%c%c%c %d%d", SIGNAM(k), l/10, l%10);
  824. X        } else {
  825. X          Xcolor(hilite);
  826. X          sprintf(string, "1v 2->");
  827. X        }
  828. X      } else {
  829. X        k = abs(grid[i][j]);
  830. X        if (!bonus)
  831. X          if (gridname[i][j])
  832. X        sprintf(string, "%c%d %d%d'", k != grid[i][j] ? '-' : '+',
  833. X            k/60, (k%60)/10, (k%60)%10);
  834. X          else
  835. X        sprintf(string, "");
  836. X        else
  837. X          sprintf(string, "%d%d %d%d'",
  838. X              (k/60)/10, (k/60)%10, (k%60)/10, (k%60)%10);
  839. X      }
  840. X      XDrawImageString(disp, pixmap, gc, x*unit+unit/2-FONT_X*3,
  841. X               (y+1)*unit-3, string, strlen(string));
  842. X    }
  843. X      }
  844. X    }
  845. X  }
  846. X  rectall(1, 1, hilite);
  847. X}
  848. X
  849. Xdrawspot(x, y, o)
  850. Xint x, y;
  851. Xbit o;
  852. X{
  853. X  drawpoint(x, y, o);
  854. X  drawpoint(x, y-1, o);
  855. X  drawpoint(x-1, y, o);
  856. X  drawpoint(x+1, y, o);
  857. X  drawpoint(x, y+1, o);
  858. X}
  859. X
  860. Xxcharthorizon()
  861. X{
  862. X  double lon, lat,
  863. X    lonz[TOTAL+1], latz[TOTAL+1], azi[TOTAL+1], alt[TOTAL+1];
  864. X  int x[TOTAL+1], y[TOTAL+1], m[TOTAL+1], n[TOTAL+1],
  865. X    cx = chartx / 2, cy = charty / 2, unit = 12*scale/100,
  866. X    x1, y1, x2, y2, xs, ys, i, j, k, l;
  867. X  if (xbitmap)
  868. X    block(0, 0, chartx - 1, charty - 1, off);
  869. X  rectall(1, 1, hilite);
  870. X  x1 = y1 = unit/2; x2 = chartx-x1; y2 = charty-y1;
  871. X  xs = x2-x1; ys = y2-y1;
  872. X  for (i = 0; i < 180; i += 5) {
  873. X    j = y1+(int)((double)(i*ys)/180.0);
  874. X    k = 2+(i/10*10 == i ? 1 : 0)+(i/30*30 == i ? 2 : 0);
  875. X    drawline(x1+1, j, x1+1+k, j, hilite, 0);
  876. X    drawline(x2-1, j, x2-1-k, j, hilite, 0);
  877. X  }
  878. X  for (i = 0; i < 360; i += 5) {
  879. X    j = x1+(int)((double)(i*xs)/DEGREES);
  880. X    k = 2+(i/10*10 == i ? 1 : 0)+(i/30*30 == i ? 2 : 0);
  881. X    drawline(j, y1+1, j, y1+1+k, hilite, 0);
  882. X    drawline(j, y2-1, j, y2-1-k, hilite, 0);
  883. X  }
  884. X  drawline(cx, y1, cx, y2, gray, 1);
  885. X  drawline((cx+x1)/2, y1, (cx+x1)/2, y2, gray, 1);
  886. X  drawline((cx+x2)/2, y1, (cx+x2)/2, y2, gray, 1);
  887. X  edge(x1, y1, x2, y2, on);
  888. X  drawline(x1, cy, x2, cy, on, 1);
  889. X  lon = DTOR(mod(Lon)); lat = DTOR(Lat);
  890. X  for (i = 1; i <= total; i++) {
  891. X    lonz[i] = DTOR(planet[i]); latz[i] = DTOR(planetalt[i]);
  892. X    ecltoequ(&lonz[i], &latz[i]);
  893. X  }
  894. X  for (i = 1; i <= total; i++) if (proper(i)) {
  895. X    lonz[i] = DTOR(mod(RTOD(lonz[18]-lonz[i]+PI/2.0)));
  896. X    equtolocal(&lonz[i], &latz[i], PI/2.0-lat);
  897. X    azi[i] = DEGREES-RTOD(lonz[i]); alt[i] = RTOD(latz[i]);
  898. X    x[i] = x1+(int)((double)xs*(mod(90.0-azi[i]))/DEGREES+0.5);
  899. X    y[i] = y1+(int)((double)ys*(90.0-alt[i])/180.0+0.5);
  900. X    m[i] = x[i]; n[i] = y[i]+unit/2;
  901. X  }
  902. X  for (i = 1; i <= total; i++) if (proper(i)) {
  903. X    k = l = chartx+charty;
  904. X    for (j = 1; j < i; j++) if (proper(j)) {
  905. X      k = MIN(k, abs(m[i]-m[j])+abs(n[i]-n[j]));
  906. X      l = MIN(l, abs(m[i]-m[j])+abs(n[i]-unit-n[j]));
  907. X    }
  908. X    if (k < unit || l < unit)
  909. X      if (k < l)
  910. X    n[i] -= unit;
  911. X  }
  912. X  for (i = total; i >= 1; i--) if (proper(i))
  913. X    drawobject(i, m[i], n[i]);
  914. X  for (i = total; i >= 1; i--) if (proper(i)) {
  915. X    if (!xbitmap)
  916. X      Xcolor(objectcolor[i]);
  917. X    if (!bonus || i > BASE)
  918. X      drawpoint(x[i], y[i], objectcolor[i]);
  919. X    else
  920. X      drawspot(x[i], y[i], objectcolor[i]);
  921. X  }
  922. X}
  923. X
  924. Xdouble angle(x, y)
  925. Xdouble x, y;
  926. X{
  927. X  double a;
  928. X  a = atan(y/x);
  929. X  if (a < 0.0)
  930. X    a += PI;
  931. X  if (y < 0.0)
  932. X    a += PI;
  933. X  return mod(RTOD(a));
  934. X}
  935. X
  936. Xxchartspace()
  937. X{
  938. X  int x[TOTAL+1], y[TOTAL+1], m[TOTAL+1], n[TOTAL+1],
  939. X    cx = chartx / 2, cy = charty / 2, unit = 12*scale/100, i, j, k, l;
  940. X  double sx, sy, sz = 30.0, x1, y1, a;
  941. X  if (scale < 200)
  942. X    sz = 90.0;
  943. X  else if (scale > 200)
  944. X    sz = 6.0;
  945. X  sx = (double)cx/sz; sy = (double)cy/sz;
  946. X  if (xbitmap)
  947. X    block(0, 0, chartx - 1, charty - 1, off);
  948. X  for (i = 0; i <= total; i++) if (proper(i)) {
  949. X    if (centerplanet == 0)
  950. X      j = i < 2 ? 1-i : i;
  951. X    else if (centerplanet == 1)
  952. X      j = i;
  953. X    else
  954. X      j = i == 0 ? centerplanet : (i == centerplanet ? 0 : i);
  955. X    x1 = spacex[j]; y1 = spacey[j];
  956. X    x[i] = cx-(int)(x1*sx); y[i] = cy+(int)(y1*sy);
  957. X    m[i] = x[i]; n[i] = y[i]+unit/2;
  958. X  }
  959. X  for (i = 0; i <= total; i++) if (proper(i)) {
  960. X    k = l = chartx+charty;
  961. X    for (j = 0; j < i; j++) if (proper(j)) {
  962. X      k = MIN(k, abs(m[i]-m[j])+abs(n[i]-n[j]));
  963. X      l = MIN(l, abs(m[i]-m[j])+abs(n[i]-unit-n[j]));
  964. X    }
  965. X    if (k < unit || l < unit)
  966. X      if (k < l)
  967. X    n[i] -= unit;
  968. X  }
  969. X  a = mod(angle(spacex[3], spacey[3])-planet[3]);
  970. X  for (i = 0; i < SIGNS; i++) {
  971. X    k = cx+2*(int)((double)cx*COSD((double)i*30.0+a));
  972. X    l = cy+2*(int)((double)cy*SIND((double)i*30.0+a));
  973. X    drawclip(cx, cy, k, l, gray, 1);
  974. X  }
  975. X  for (i = total; i >= 0; i--) if (proper(i) && ISLEGAL(m[i], n[i]))
  976. X    drawobject(i, m[i], n[i]);
  977. X  for (i = total; i >= 0; i--) if (proper(i) && ISLEGAL(x[i], y[i])) {
  978. X    if (!xbitmap)
  979. X      Xcolor(objectcolor[i]);
  980. X    if (!bonus || i > BASE)
  981. X      drawpoint(x[i], y[i], objectcolor[i]);
  982. X    else
  983. X      drawspot(x[i], y[i], objectcolor[i]);
  984. X  }
  985. X  rectall(1, 1, hilite);
  986. X}
  987. X
  988. Xvoid xchart()
  989. X{
  990. X  int i, j, k, l;
  991. X  switch (modex) {
  992. X  case 'c':
  993. X    if (relation != -1)
  994. X      xchartwheel();
  995. X    else
  996. X      xchartwheelrelation();
  997. X    break;
  998. X  case 'l':
  999. X    drawworld();
  1000. X    xchartastrograph();
  1001. X    break;
  1002. X  case 'a':
  1003. X    if (relation != -1)
  1004. X      xchartaspectgrid();
  1005. X    else
  1006. X      xchartrelationaspectgrid();
  1007. X    break;
  1008. X  case 'z':
  1009. X    xcharthorizon();
  1010. X    break;
  1011. X  case 's':
  1012. X    xchartspace();
  1013. X    break;
  1014. X  case 'w':
  1015. X    drawworld();
  1016. X    if (bonus)
  1017. X      drawleylines();
  1018. X    break;
  1019. X  case 'p':
  1020. X  case 'g':
  1021. X    drawglobe(degree);
  1022. X    break;
  1023. X  }
  1024. X  if (!xbitmap) {
  1025. X    Xcolor(on);
  1026. X    if (xtext && modex != 'w' && modex != 'p' && modex != 'g') {
  1027. X      if (Mon == -1)
  1028. X    sprintf(string, "(no time or space)");
  1029. X      else if (relation == 2)
  1030. X    sprintf(string, "(composite)");
  1031. X      else {
  1032. X    i = (int) Mon; l = (int) ((Tim-floor(Tim))*100.0+0.1);
  1033. X    sprintf(string, "%2.0f %c%c%c %.0f %2.0f:%d%d (%.2f GMT) %s",
  1034. X        Day, monthname[i][0], monthname[i][1], monthname[i][2], Yea,
  1035. X        floor(Tim), l/10, l%10, -Zon, stringlocation(Lon, Lat, 100.0));
  1036. X      }
  1037. X      XDrawImageString(disp, pixmap, gc, (chartx-strlen(string)*FONT_X)/2,
  1038. X               charty-3, string, strlen(string));
  1039. X    }
  1040. X  }
  1041. X}
  1042. X#endif
  1043. X
  1044. X/**/
  1045. END_OF_FILE
  1046. if test 31047 -ne `wc -c <'xcharts.c'`; then
  1047.     echo shar: \"'xcharts.c'\" unpacked with wrong size!
  1048. fi
  1049. # end of 'xcharts.c'
  1050. fi
  1051. if test -f 'driver.c' -a "${1}" != "-c" ; then 
  1052.   echo shar: Will not clobber existing file \"'driver.c'\"
  1053. else
  1054. echo shar: Extracting \"'driver.c'\" \(21062 characters\)
  1055. sed "s/^X//" >'driver.c' <<'END_OF_FILE'
  1056. X/*
  1057. X** Astrolog (Version 2.25) File: driver.c
  1058. X*/
  1059. X
  1060. X#include "astrolog.h"
  1061. X
  1062. Xchar *filenameout, **extralines;
  1063. Xint prog = FALSE, extracount = 0;
  1064. X
  1065. X/*
  1066. X*******************************************************************************
  1067. X** Option processing
  1068. X*******************************************************************************
  1069. X*/
  1070. X
  1071. Xdisplayswitches()
  1072. X{
  1073. X  printf("Astrolog command switches (version %s) (%s):\n", VERSION, DATE); 
  1074. X  printf(" -H: Display this help message.\n");
  1075. X  printf(" -O: Display available planets and other celestial objects.\n");
  1076. X  printf(" -O0: Line -O but ignore any restrictions.\n");
  1077. X  printf(" -R [<obj1> [<obj2> ..]: Restrict specific bodies from displays.\n");
  1078. X  printf(" -R0 [<obj1> ..]: Like -R but restrict everything first.\n");
  1079. X  printf(" -R[C,u,U]: Restrict all minor cusps, all uranians, or stars.\n");
  1080. X  printf(" -C: Include non-angular house cusps in charts.\n");
  1081. X  printf(" -u: Include transneptunian/uranian bodies in charts.\n");
  1082. X  printf(" -U: Include locations of fixed background stars in charts.\n");
  1083. X  printf(" -U[z,l,n,b]: Order by azimuth, altitude, name, or brightness.\n");
  1084. X  printf(" -A [<0-18>]: Display available aspects or limit their number.\n");
  1085. X  printf(" -Ao <orb1> [<orb2> ..]: Specify max orbs for each aspect.\n");
  1086. X  printf(" -AO [..]: Like -Ao but suspend objects' max orb restrictions.\n\n");
  1087. X  printf("Switches which affect how a chart is computed:\n");
  1088. X  printf(" -c <value>: Select a different default system of houses.\n");
  1089. X  printf("     (0 = Placidus, 1 = Koch, 2 = Equal, 3 = Campanus, ");
  1090. X  printf("4 = Meridian,\n     5 = Regiomontanus, 6 = Porphry, ");
  1091. X  printf("7 = Morinus, 8 = Topocentric, 9 = None.)\n");
  1092. X  printf(" -s: Compute siderial instead of the normal tropical chart.\n");
  1093. X  printf(" -s0: Display locations as right ascension instead of degrees.\n");
  1094. X  printf(" -h [<objnum>]: Compute positions centered on specified object.\n");
  1095. X  printf(" -p <month> <day> <year>: Cast progressed chart based for date.\n");
  1096. X#ifdef TIME
  1097. X  printf(" -pn: Cast progressed chart based on current date now.\n");
  1098. X#endif
  1099. X  printf(" -p0 <days>: Set no. of days to progress / day (default 365.25).\n");
  1100. X  printf(" -x <1-360>: Cast harmonic chart based on specified factor.\n");
  1101. X  printf(" -1 [<objnum>]: Cast chart with specified object on ascendant.\n");
  1102. X  printf(" -3: Display objects in their zodiac decan positions.\n");
  1103. X  printf(" -f: Display houses as sign positions (flip them).\n");
  1104. X  printf(" -G: Display houses based on geographic location only.\n");
  1105. X  printf(" -+ <days>: Cast chart for specified no. of days in the future.\n");
  1106. X  printf(" -- <days>: Cast chart for specified no. of days in the past.\n\n");
  1107. X  printf("Switches which determine in what format the chart is displayed:\n");
  1108. X  printf(" -v: Display list of object positions (chosen by default).\n");
  1109. X  printf(" -v0: Like -v but express velocities relative to average speed.\n");
  1110. X  printf(" -w: Display chart on screen in a graphic house wheel format.\n");
  1111. X  printf(" -w0: Like -w but show objects in houses 4..9 in reverse order.\n");
  1112. X  printf(" -g: Display aspect and midpoint grid among planets.\n");
  1113. X  printf(" -g0: Like -g but flag aspect configurations (e.g. Yod's) too.\n");
  1114. X  printf(" -g0: For comparison charts, show midpoints instead of aspects.\n");
  1115. X  printf(" -ga: Like -g but indicate applying instead of difference orbs.\n");
  1116. X  printf(" -Z: Display planet locations with respect to the local horizon.\n");
  1117. X  printf(" -S: Display x,y,z coordinate positions of planets.\n");
  1118. X  printf(" -I: Display interpretation of planetary influences.\n");
  1119. X  printf(" -L [<step>]: Display astro-graph locations of planetary angles.\n");
  1120. X  printf(" -L0 [..]: Like -L but display list of latitude crossings too.\n");
  1121. X  printf(" -d: Print all aspects and changes occurring in a day.\n");
  1122. X  printf(" -d0: Like -d but print all aspects for the entire month.\n");
  1123. X  printf(" -dp <month> <year>: Print aspects within progressed chart.\n");
  1124. X  printf(" -e: Print all options for chart (i.e. -v-w-g0-Z-S-I-L0-d).\n\n");
  1125. X  printf("Switches which affect how the chart parameters are obtained:\n");
  1126. X#ifdef TIME
  1127. X  printf(" -n: Compute chart for this exact moment using current time.\n");
  1128. X#endif
  1129. X  printf(" -a <month> <date> <year> <time> <zone> <long> <lat>:\n");
  1130. X  printf("     Compute chart automatically given specified data.\n");
  1131. X  printf(" -z: Assume Daylight time (change default zone appropriately).\n");
  1132. X  printf(" -z <zone>: Change the default time zone (for -d-q-T-E options).\n");
  1133. X  printf(" -l <long> <lat>: ");
  1134. X  printf("Change the default longitude & latitude.\n");
  1135. X  printf(" -q <month> <date> <year>: Compute chart for noon on date.\n");
  1136. X  printf(" -q0 <month> <date> <year> <time>: Like -q but include time too.\n");
  1137. X  printf(" -i <file>: Compute chart based on info in file.\n");
  1138. X  printf(" -o <file> [..]: Write parameters of current chart to file.\n");
  1139. X  printf(" -o0 <file> [..]: Like -o but output planet/house positions.\n\n");
  1140. X  printf("Other features or major modes:\n");
  1141. X  printf(" -r <file1> <file2>: Compute a relationship synastry chart.\n");
  1142. X  printf(" -rc <file1> <file2>: Compute a composite chart.\n");
  1143. X  printf(" -rm <file1> <file2>: Compute a time space midpoint chart.\n");
  1144. X  printf(" -r0 <file1> <file2>: Keep the charts separate in comparison.\n");
  1145. X#ifdef TIME
  1146. X  printf(" -t <file>: Compute current house transits for particular chart.\n");
  1147. X#endif
  1148. X  printf(" -T <file> <month> <year>: ");
  1149. X  printf("Compute all transits in month for chart.\n");
  1150. X  printf(" -T0 <..>: Like -T but include transits of the Moon as well.\n");
  1151. X  printf(" -Tp <file> <month> <year>: ");
  1152. X  printf("Compute all progressions in month for chart.\n");
  1153. X  printf(" -E <month> <year>: Display ephemeris for given month.\n");
  1154. X  printf(" -E0 <..>: Like -E but include Chiron and the asteroids as well.\n");
  1155. X#ifdef X11
  1156. X  xdisplayswitches();
  1157. X#endif
  1158. X}
  1159. X
  1160. Xprintobjects(all)
  1161. Xint all;
  1162. X{
  1163. X  int i, j;
  1164. X  double Off;
  1165. X  if (!cusp)
  1166. X    for (i = objects+1; i <= objects+4; i++)
  1167. X      ignore[i] = TRUE;
  1168. X  if (!uranian)
  1169. X    for (i = objects+5; i <= BASE; i++)
  1170. X      ignore[i] = TRUE;
  1171. X  printf("Astrolog planets and objects:\n");
  1172. X  printf("No. Name       Rule Co-Rule Fall Co-Fall Exalt Debilitate\n\n");
  1173. X  if (all || universe) {
  1174. X    Off = processinput(TRUE);
  1175. X    caststar(siderial ? 0.0 : Off);
  1176. X  }
  1177. X  for (i = 1; i <= BASE; i++) if (all || !ignore[i]) {
  1178. X    printf("%2d %s", i, objectname[i]);
  1179. X    printtab(' ', 12-stringlen(objectname[i]));
  1180. X    if (i <= objects) {
  1181. X      if (ruler1[i]) {
  1182. X    j = ruler2[i];
  1183. X    printf("%c%c%c  %c%c%c     ", SIGNAM(ruler1[i]),
  1184. X           j ? signname[j][0] : ' ', j ? signname[j][1] : ' ',
  1185. X           j ? signname[j][2] : ' ');
  1186. X    printf("%c%c%c  %c%c%c     ", SIGNAM(mod12(ruler1[i]+6)),
  1187. X           j ? signname[mod12(j+6)][0] : ' ',
  1188. X           j ? signname[mod12(j+6)][1] : ' ',
  1189. X           j ? signname[mod12(j+6)][2] : ' ');
  1190. X    printf("%c%c%c   %c%c%c", SIGNAM(exalt[i]),
  1191. X           SIGNAM(mod12(exalt[i]+6)));
  1192. X      }
  1193. X    } else if (i <= objects+4)
  1194. X      printf("Minor House Cusp #%d", i-objects);
  1195. X    else
  1196. X      printf("Uranian #%d", i-objects-4);
  1197. X    putchar('\n');
  1198. X  }
  1199. X  if (all || universe)
  1200. X    for (i = BASE+1; i <= total; i++) if (all | !ignore[i]) {
  1201. X      j = BASE+starname[i-BASE];
  1202. X      printf("%2d %s", i, objectname[j]);
  1203. X      printtab(' ', 12-stringlen(objectname[j]));
  1204. X      printf("Star #%2d    ", i-BASE);
  1205. X      printminute(planet[j]);
  1206. X      printf("  ");
  1207. X      printaltitude(planetalt[j]);
  1208. X      printf(" %5.2f\n", starbright[j-BASE]);
  1209. X    }
  1210. X}
  1211. X
  1212. Xprintaspects()
  1213. X{
  1214. X  int i;
  1215. X  printf("Astrolog aspects:\nNo. Angle    Orb       Abbrev. Name");
  1216. X  printf("          Description of glyph\n\n");
  1217. X  for (i = 1; i <= ASPECTS; i++) {
  1218. X    printf("%2d %6.2f +/- %1.0f degrees (%s) %s", i,
  1219. X       aspectangle[i], aspectorb[i], aspectabbrev[i], aspectname[i]);
  1220. X    printtab(' ', 15-stringlen(aspectname[i]));
  1221. X    printf("%s\n", aspectglyph[i]);
  1222. X  }
  1223. X}
  1224. X
  1225. X#define NEXTDEFAULT while(getc(data) != '=');
  1226. X
  1227. Xint inputdefaults()
  1228. X{
  1229. X  char name[STRING];
  1230. X  int i;
  1231. X  filename = DEFAULT_INFOFILE;
  1232. X  data = fopen(filename, "r");
  1233. X  if (data == NULL) {
  1234. X    sprintf(name, "%s%s", DEFAULT_DIR, filename);
  1235. X    data = fopen(name, "r");
  1236. X    if (data == NULL)
  1237. X      return FALSE;
  1238. X  }
  1239. X  NEXTDEFAULT; fscanf(data, "%lf", &defzone);
  1240. X  NEXTDEFAULT; fscanf(data, "%lf", &deflong);
  1241. X  NEXTDEFAULT; fscanf(data, "%lf", &deflat);
  1242. X  NEXTDEFAULT; fscanf(data, "%d",  &aspects);
  1243. X  NEXTDEFAULT; fscanf(data, "%d",  &housesystem);
  1244. X  NEXTDEFAULT;
  1245. X  for (i = 1; i <= objects; i++)
  1246. X    fscanf(data, "%d", &ignore[i]);
  1247. X  NEXTDEFAULT;
  1248. X  for (i = 1; i <= ASPECTS; i++)
  1249. X    fscanf(data, "%lf", &aspectorb[i]);
  1250. X  NEXTDEFAULT;
  1251. X  for (i = 1; i <= objects; i++)
  1252. X    fscanf(data, "%lf", &objectinf[i]);
  1253. X  for (i = 1; i <= SIGNS; i++)
  1254. X    fscanf(data, "%lf", &houseinf[i]);
  1255. X  for (i = 1; i <= ASPECTS; i++)
  1256. X    fscanf(data, "%lf", &aspectinf[i]);
  1257. X  fclose(data);
  1258. X  return TRUE;
  1259. X}
  1260. X
  1261. Xoutputdata()
  1262. X{
  1263. X  int i, j;
  1264. X  double k;
  1265. X  data = fopen(filenameout, "w");
  1266. X  if (data == NULL) {
  1267. X    fprintf(stderr, "File %s can not be created.\n", filenameout);
  1268. X    exit(1);
  1269. X  }
  1270. X  if (!(todisplay & 4096)) {
  1271. X    if (Mon < 1) {
  1272. X      fprintf(stderr, "\nCan't output chart with no time/space to file.\n");
  1273. X      fclose(data);
  1274. X      exit(1);
  1275. X    }
  1276. X    fprintf(data, "%.0f\n%.0f\n%.0f\n%.2f\n%.2f\n%.2f\n%.2f\n",
  1277. X        Mon, Day, Yea, Tim, Zon, Lon, Lat);
  1278. X  } else {
  1279. X    for (i = 1; i <= objects; i++) {
  1280. X      j = (int) planet[i];
  1281. X      fprintf(data, "%c%c%c: %2d %2d %10.7f\n", OBJNAM(i),
  1282. X          j%30, j/30+1, (planet[i]-floor(planet[i]))*60.0);
  1283. X      k = planetalt[i];
  1284. X      fprintf(data, "[%c]: %3d %12.8f\n",
  1285. X          ret[i] >= 0.0 ? 'D' : 'R', (int)(sgn(k)*
  1286. X              floor(dabs(k))), (k-(double)(int)k)*60.0);
  1287. X    }
  1288. X    for (i = 1; i <= SIGNS/2; i++) {
  1289. X      j = (int) house[i];
  1290. X      fprintf(data, "H_%c: %2d %2d %10.7f\n",
  1291. X          'a'+i-1, j%30, j/30+1, (house[i]-floor(house[i]))*60.0);
  1292. X    }
  1293. X  }
  1294. X  for (i = 1; i < extracount; i++) {
  1295. X    extralines++;
  1296. X    fprintf(data, "%s\n", extralines[1]);
  1297. X  }
  1298. X  fclose(data);
  1299. X}
  1300. X
  1301. Xaction()
  1302. X{
  1303. X  int i;
  1304. X  if (!cusp)
  1305. X    for (i = objects+1; i <= objects+4; i++)
  1306. X      ignore[i] = TRUE;
  1307. X  if (!uranian)
  1308. X    for (i = objects+5; i <= BASE; i++)
  1309. X      ignore[i] = TRUE;
  1310. X  if (!universe)
  1311. X    for (i = BASE+1; i <= total; i++)
  1312. X      ignore[i] = TRUE;
  1313. X  if (operation & 2)
  1314. X    printtransit(prog);
  1315. X  else if (operation & 4)
  1316. X    printephemeris();
  1317. X  else {
  1318. X    if (!relation) {
  1319. X      if (!autom)
  1320. X    inputdata("tty");
  1321. X      Mon = M; Day = D; Yea = Y; Tim = F; Zon = X; Lon = L5; Lat = LA;
  1322. X      castchart(TRUE);
  1323. X    } else
  1324. X      castrelation();
  1325. X#ifdef X11
  1326. X    if (operation & 8)
  1327. X      xaction();
  1328. X    else
  1329. X#endif
  1330. X      printchart(prog);
  1331. X  }
  1332. X  if (operation & 1)
  1333. X    outputdata();
  1334. X}
  1335. X
  1336. X#ifndef SWITCHES
  1337. X#define MAXSWITCHES 20
  1338. Xint inputswitches(argv)
  1339. Xchar argv[MAXSWITCHES][10];
  1340. X{
  1341. X  int argc = 0;
  1342. X  printf("** Astrolog version %s (cruiser1@milton.u.washington.edu) **\n",
  1343. X    VERSION); 
  1344. X  printf("Enter all the switch parameters below. (Enter -H for help.)\n");
  1345. X  printf("Press return after each switch or number parameter input.\n");
  1346. X  printf("Input a '.' on a line by itself when done.\n\n");
  1347. X  do {
  1348. X    argc++;
  1349. X    printf("Input parameter string #%2d: ", argc);
  1350. X    if (gets(argv[argc]) == (char *) NULL) {
  1351. X      printf("\nAstrolog terminated.\n");
  1352. X      exit(1);
  1353. X    }
  1354. X  } while (argc < MAXSWITCHES && (argv[argc][0] != '.' || argv[argc][1] != 0));
  1355. X  printf("\n");
  1356. X  return argc;
  1357. X}
  1358. X#endif
  1359. X
  1360. X
  1361. X/*
  1362. X*******************************************************************************
  1363. X** Main program
  1364. X*******************************************************************************
  1365. X*/
  1366. X
  1367. Xmain(argc, argv)
  1368. Xint argc;
  1369. Xchar **argv;
  1370. X{
  1371. X#ifdef TIME
  1372. X  struct tm curtime;
  1373. X  int curtimer;
  1374. X#endif
  1375. X  int pos, i, j;
  1376. X  double k;
  1377. X  char c;
  1378. X#ifndef SWITCHES
  1379. X  char strings[MAXSWITCHES][10];
  1380. X  char *pointers[MAXSWITCHES];
  1381. X  inputdefaults();
  1382. X  for (i = 0; i < MAXSWITCHES; i++)
  1383. X    pointers[i] = strings[i];
  1384. X  argc = inputswitches(strings);
  1385. X  argv = pointers;
  1386. X#else
  1387. X  inputdefaults();
  1388. X#endif
  1389. X  argc--; argv++;
  1390. X  while (argc) {
  1391. X    pos = 1;
  1392. X    if (argv[0][0] == '-')
  1393. X      pos++;
  1394. X    switch (argv[0][pos-1]) {
  1395. X    case 'H':
  1396. X      displayswitches();
  1397. X      exit(0);
  1398. X    case 'O':
  1399. X      printobjects(argv[0][pos] == '0');
  1400. X      exit(0);
  1401. X    case 'R':
  1402. X      if (argv[0][pos] == '0')
  1403. X    for (i = 1; i <= total; i++)
  1404. X      ignore[i] = TRUE;
  1405. X      else if (argv[0][pos] == 'C')
  1406. X    for (i = objects+1; i <= objects+4; i++)
  1407. X      ignore[i] = TRUE;
  1408. X      else if (argv[0][pos] == 'u')
  1409. X    for (i = objects+5; i <= BASE; i++)
  1410. X      ignore[i] = TRUE;
  1411. X      else if (argv[0][pos] == 'U')
  1412. X    for (i = BASE+1; i <= total; i++)
  1413. X      ignore[i] = TRUE;
  1414. X      else if (argc <= 1 || (!atoi(argv[1]))) {
  1415. X    for (i = 11; i <= 15; i++)
  1416. X      ignore[i] = 1-ignore[i];
  1417. X    ignore[17] = 1-ignore[17]; ignore[20] = 1-ignore[20];
  1418. X      }
  1419. X      while (argc > 1 && (i = atoi(argv[1])))
  1420. X    if (i < 1 || i > total) {
  1421. X      fprintf(stderr, "Bad value %d to switch -R\n", i);
  1422. X      exit(1);
  1423. X    } else {
  1424. X      ignore[i] = 1-ignore[i];
  1425. X      argc--; argv++;
  1426. X    }
  1427. X      break;
  1428. X    case 'u':
  1429. X      uranian = TRUE;
  1430. X      break;
  1431. X    case 'U':
  1432. X      if (argv[0][pos] == 'n' || argv[0][pos] == 'b' ||
  1433. X      argv[0][pos] == 'z' || argv[0][pos] == 'l')
  1434. X    universe = argv[0][pos];
  1435. X      else
  1436. X    universe = TRUE;
  1437. X      break;
  1438. X    case 'C':
  1439. X      cusp = TRUE;
  1440. X      break;
  1441. X    case 'A':
  1442. X      if (argc <= 1) {
  1443. X    printaspects();
  1444. X    exit(0);
  1445. X      }
  1446. X      if (argv[0][pos] != 'o' && argv[0][pos] != 'O') {
  1447. X    aspects = atoi(argv[1]);
  1448. X    if (aspects < 0 || aspects > ASPECTS) {
  1449. X      fprintf(stderr, "Bad value %d to switch -A\n", aspects);
  1450. X      exit(1);
  1451. X    }
  1452. X    argc--; argv++;
  1453. X      } else {
  1454. X    if (argv[0][pos] == 'O')
  1455. X      orb(0, 0, 0);
  1456. X    i = 1;
  1457. X    while (argc > 1 && ((k = atof(argv[1])) || argv[1][0] == '0'))
  1458. X      if (k < -180.0 || k > 180.0 || i > ASPECTS) {
  1459. X        fprintf(stderr, "Bad value %.1f to switch -Ao\n", k);
  1460. X        exit(1);
  1461. X      } else {
  1462. X        aspectorb[i++] = k;
  1463. X        argc--; argv++;
  1464. X      }
  1465. X      }
  1466. X      break;
  1467. X    case 's':
  1468. X      if (argv[0][pos] == '0')
  1469. X    right = TRUE;
  1470. X      else
  1471. X    siderial = TRUE;
  1472. X      break;
  1473. X    case 'h':
  1474. X      if (argc > 1 && (centerplanet = atoi(argv[1]))) {
  1475. X    argc--; argv++;
  1476. X      } else
  1477. X    centerplanet = 1;
  1478. X      if (centerplanet < 0 || centerplanet == 2 || (centerplanet >= THINGS &&
  1479. X      centerplanet < objects+5) || centerplanet > BASE) {
  1480. X    fprintf(stderr, "Bad value %d to switch -h\n", centerplanet);
  1481. X    exit(1);
  1482. X      }
  1483. X      for (i = 0; i <= 11; i++) {
  1484. X    c = objectname[0][i]; objectname[0][i] = objectname[centerplanet][i];
  1485. X    objectname[centerplanet][i] = c;
  1486. X      }
  1487. X      if (centerplanet < 2)
  1488. X    centerplanet = 1-centerplanet;
  1489. X      break;
  1490. X    case 'c':
  1491. X      if (argc <= 1)
  1492. X    toofew("c");
  1493. X      housesystem = atoi(argv[1]);
  1494. X      if (housesystem < 0 || housesystem >= SYSTEMS) {
  1495. X    fprintf(stderr, "Bad value %d to switch -c\n", housesystem);
  1496. X    exit(1);
  1497. X      }
  1498. X      argc--; argv++;
  1499. X      break;
  1500. X    case 'x':
  1501. X      if (argc <= 1)
  1502. X    toofew("x");
  1503. X      multiplyfactor = atoi(argv[1]);
  1504. X      if (multiplyfactor < 1 || multiplyfactor > DEGREES) {
  1505. X    fprintf(stderr, "Bad value %d to switch -x\n", multiplyfactor);
  1506. X    exit(1);
  1507. X      }
  1508. X      argc--; argv++;
  1509. X      break;
  1510. X    case '1':
  1511. X      if (argc > 1 && (onasc = atoi(argv[1]))) {
  1512. X    argc--; argv++;
  1513. X      } else
  1514. X    onasc = 1;
  1515. X      if (onasc < 1 || onasc > objects) {
  1516. X    fprintf(stderr, "Bad value %d to switch -1\n", onasc);
  1517. X    exit(1);
  1518. X      }
  1519. X      break;
  1520. X    case 'f':
  1521. X      flip = TRUE;
  1522. X      break;
  1523. X    case '3':
  1524. X      decan = TRUE;
  1525. X      break;
  1526. X    case 'G':
  1527. X      geodetic = TRUE;
  1528. X      break;
  1529. X    case 'p':
  1530. X#ifdef TIME
  1531. X      if (argv[0][pos] == 'n') {
  1532. X    progress = TRUE;
  1533. X    curtimer = (int) time((int *) 0);
  1534. X    curtime = *localtime(&curtimer);
  1535. X    Mon = (double) curtime.tm_mon + 1.0;
  1536. X    Day = (double) curtime.tm_mday;
  1537. X    Yea = (double) curtime.tm_year + 1900.0;
  1538. X    Jdp = mdytojulian(Mon, Day, Yea);
  1539. X    break;
  1540. X      }
  1541. X#endif
  1542. X      if (argv[0][pos] == '0') {
  1543. X    if (argc <= 1)
  1544. X      toofew("p0");
  1545. X    progday = atof(argv[1]);
  1546. X    if (progday == 0.0) {
  1547. X      fprintf(stderr, "Bad progression value %.2f to switch -p0\n",
  1548. X          progday);
  1549. X      exit(1);
  1550. X    }
  1551. X    argc--; argv++;
  1552. X    break;
  1553. X      }
  1554. X      if (argc <= 3)
  1555. X    toofew("p");
  1556. X      progress = TRUE;
  1557. X      Mon = atof(argv[1]);
  1558. X      Day = atof(argv[2]);
  1559. X      Yea = atof(argv[3]);
  1560. X      if (Mon < 1.0 || Mon > 12.0 || Day < 1.0 || Day > 31.0) {
  1561. X    fprintf(stderr, "Bad date value %.0f,%.0f,%.0f to switch -p\n",
  1562. X        Mon, Day, Yea);
  1563. X    exit(1);
  1564. X      }
  1565. X      Jdp = mdytojulian(Mon, Day, Yea);
  1566. X      argc -= 3; argv += 3;
  1567. X      break;
  1568. X    case '+':
  1569. X      if (argc <= 1)
  1570. X    toofew("+");
  1571. X      Delta = atof(argv[1]);
  1572. X      argc--; argv++;
  1573. X      break;
  1574. X    case '-': case '\0':
  1575. X      if (argc <= 1)
  1576. X    toofew("-");
  1577. X      Delta = -atof(argv[1]);
  1578. X      argc--; argv++;
  1579. X      break;
  1580. X    case 'v':
  1581. X      if (argv[0][pos] == '0')
  1582. X    todisplay = todisplay | 32768;
  1583. X      todisplay = todisplay | 1;
  1584. X      break;
  1585. X    case 'w':
  1586. X      if (argv[0][pos] == '0')
  1587. X    todisplay = todisplay | 2048;
  1588. X      todisplay = todisplay | 2;
  1589. X      break;
  1590. X    case 'g':
  1591. X      if (argv[0][pos] == '0')
  1592. X    todisplay = todisplay | 8192;
  1593. X      if (argv[0][pos] == 'a') {
  1594. X    todisplay = todisplay | 65536;
  1595. X    if (argv[0][pos+1] == '0')
  1596. X      todisplay = todisplay | 8192;
  1597. X      }
  1598. X      todisplay = todisplay | 4;
  1599. X      break;
  1600. X    case 'Z':
  1601. X      todisplay = todisplay | 8;
  1602. X      break;
  1603. X    case 'S':
  1604. X      todisplay = todisplay | 16;
  1605. X      break;
  1606. X    case 'I':
  1607. X      todisplay = todisplay | 32;
  1608. X      break;
  1609. X    case 'L':
  1610. X      if (argv[0][pos] == '0')
  1611. X    todisplay = todisplay | 16384;
  1612. X      if (argc > 1 && (i = atoi(argv[1]))) {
  1613. X    graphstep = i;
  1614. X    argc--; argv++;
  1615. X      }
  1616. X      if (graphstep < 1 || 160%graphstep > 0) {
  1617. X    fprintf(stderr, "Bad value %d to switch -L\n", graphstep);
  1618. X    exit(1);
  1619. X      }
  1620. X      todisplay = todisplay | 64;
  1621. X      break;
  1622. X    case 'd':
  1623. X      if (argv[0][pos] == 'p') {
  1624. X    if (argc <= 2)
  1625. X      toofew("dp");
  1626. X    prog = TRUE;
  1627. X    todisplay = todisplay | 256;
  1628. X    Mon2 = atof(argv[1]);
  1629. X    Yea2 = atof(argv[2]);
  1630. X    if (Mon2 < 0.0 || Mon2 > 12.0) {
  1631. X      fprintf(stderr, "Bad date value %.0f to switch -dp\n", Mon2);
  1632. X      exit(1);
  1633. X    }
  1634. X    argc -= 2; argv += 2;
  1635. X      } else if (argv[0][pos] == '0')
  1636. X    todisplay = todisplay | 256;
  1637. X      todisplay = todisplay | 128;
  1638. X      break;
  1639. X    case 'e':
  1640. X      todisplay = 255 | 8192 | 16384;
  1641. X      break;
  1642. X#ifdef TIME
  1643. X    case 'n':
  1644. X      inputdata("now");
  1645. X      break;
  1646. X#endif
  1647. X    case 'l':
  1648. X      if (argc <= 2)
  1649. X    toofew("l");
  1650. X      deflong = atof(argv[1]);
  1651. X      deflat  = atof(argv[2]);
  1652. X      argc -= 2; argv += 2;
  1653. X      break;
  1654. X    case 'z':
  1655. X      if (argc <= 1 || atoi(argv[1]) == 0)
  1656. X    defzone--;
  1657. X      else {
  1658. X    defzone = atof(argv[1]);
  1659. X    if (defzone < -24.0 || defzone > 24.0) {
  1660. X      fprintf(stderr, "Bad value %.0f to switch -z\n", defzone);
  1661. X      exit(1);
  1662. X    }
  1663. X    argc--; argv++;
  1664. X      }
  1665. X      break;
  1666. X    case 'a':
  1667. X      if (argc <= 7)
  1668. X    toofew("a");
  1669. X      autom = TRUE;
  1670. X      M = atof(argv[1]); D = atof(argv[2]); Y = atof(argv[3]);
  1671. X      F = atof(argv[4]); X = atof(argv[5]);
  1672. X      L5 = atof(argv[6]); LA = atof(argv[7]);
  1673. X      argc -= 7; argv += 7;
  1674. X      break;
  1675. X    case 'q':
  1676. X      i = (argv[0][pos] == '0');
  1677. X      if (argc <= 3+i)
  1678. X    toofew("q");
  1679. X      autom = TRUE;
  1680. X      M = atof(argv[1]); D = atof(argv[2]); Y = atof(argv[3]);
  1681. X      F = i ? atof(argv[4]) : 12.0; X = defzone; L5 = deflong; LA = deflat;
  1682. X      argc -= 3+i; argv += 3+i;
  1683. X      break;
  1684. X    case 'i':
  1685. X      if (argc <= 1)
  1686. X    toofew("i");
  1687. X      inputdata(argv[1]);
  1688. X      argc--; argv++;
  1689. X      break;
  1690. X    case 'o':
  1691. X      if (argv[0][pos] == '0')
  1692. X    todisplay = todisplay | 4096;
  1693. X      if (argc <= 1)
  1694. X    toofew("o");
  1695. X      operation = operation | 1;
  1696. X      filenameout = argv[1];
  1697. X      extralines = argv;
  1698. X      do {
  1699. X    argc--; argv++;
  1700. X    extracount++;
  1701. X      } while (argc > 1 && argv[1][0] != '-');
  1702. X      break;
  1703. X    case 'r':
  1704. X      if (argc <= 2)
  1705. X    toofew("r");
  1706. X      if (argv[0][pos] == 'c')
  1707. X    relation = 2;
  1708. X      else if (argv[0][pos] == 'm')
  1709. X    relation = 3;
  1710. X      else if (argv[0][pos] == '0')
  1711. X    relation = -1;
  1712. X      else
  1713. X    relation = 1;
  1714. X      filename = argv[1]; filename2 = argv[2];
  1715. X      argc -= 2; argv += 2;
  1716. X      break;
  1717. X#ifdef TIME
  1718. X    case 't':
  1719. X      if (argc <= 1)
  1720. X    toofew("t");
  1721. X      relation = -1;
  1722. X      filename = argv[1]; filename2 = "now";
  1723. X      argc--; argv++;
  1724. X      break;
  1725. X#endif
  1726. X    case 'T':
  1727. X      if (argc <= 3)
  1728. X    toofew("T");
  1729. X      if (argv[0][pos] == 'p') {
  1730. X    prog = TRUE;
  1731. X    todisplay = todisplay | 512;
  1732. X      } else if (argv[0][pos] == '0')
  1733. X    todisplay = todisplay | 512;
  1734. X      operation = 2;
  1735. X      filename = argv[1];
  1736. X      Mon2 = atof(argv[2]);
  1737. X      Yea2 = atof(argv[3]);
  1738. X      if (Mon2 < 0.0 || Mon2 > 12.0) {
  1739. X    fprintf(stderr, "Bad date value %.0f to switch -T\n", Mon2);
  1740. X    exit(1);
  1741. X      }
  1742. X      argc -= 3; argv += 3;
  1743. X      break;
  1744. X    case 'E':
  1745. X      if (argc <= 2)
  1746. X    toofew("E");
  1747. X      if (argv[0][pos] == '0')
  1748. X    todisplay = todisplay | 1024;
  1749. X      operation = 4;
  1750. X      Mon2 = atof(argv[1]);
  1751. X      Yea2 = atof(argv[2]);
  1752. X      if (Mon2 < 0.0 || Mon2 > 12.0) {
  1753. X    fprintf(stderr, "Bad date value %.0f to switch -E\n", Mon2);
  1754. X    exit(1);
  1755. X      }
  1756. X      argc -= 2; argv += 2;
  1757. X      break;
  1758. X#ifdef X11
  1759. X    case 'X':
  1760. X      i = xprocess(argc, argv, pos);
  1761. X      operation = 8;
  1762. X      argc -= i; argv += i;
  1763. X      break;
  1764. X#endif
  1765. X    default:
  1766. X      fprintf(stderr, "Unknown switch '%s'\n", argv[0]);
  1767. X      exit(1);
  1768. X    }
  1769. X    argc--; argv++;
  1770. X  }
  1771. X  action();
  1772. X}
  1773. X
  1774. X/**/
  1775. END_OF_FILE
  1776. if test 21062 -ne `wc -c <'driver.c'`; then
  1777.     echo shar: \"'driver.c'\" unpacked with wrong size!
  1778. fi
  1779. # end of 'driver.c'
  1780. fi
  1781. echo shar: End of archive 3 \(of 8\).
  1782. cp /dev/null ark3isdone
  1783. MISSING=""
  1784. for I in 1 2 3 4 5 6 7 8 ; do
  1785.     if test ! -f ark${I}isdone ; then
  1786.     MISSING="${MISSING} ${I}"
  1787.     fi
  1788. done
  1789. if test "${MISSING}" = "" ; then
  1790.     echo You have unpacked all 8 archives.
  1791.     echo "See the README file for further instructions."
  1792.     rm -f ark[1-9]isdone
  1793. else
  1794.     echo You still need to unpack the following archives:
  1795.     echo "        " ${MISSING}
  1796. fi
  1797. ##  End of shell archive.
  1798. exit 0
  1799.  
  1800. exit 0 # Just in case...
  1801.