home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / games / volume18 / threedee / part03 < prev    next >
Encoding:
Internet Message Format  |  1993-09-13  |  61.2 KB

  1. Path: uunet!news.tek.com!news.cna.tek.com!not-for-mail
  2. From: billr@saab.cna.tek.com (Bill Randle)
  3. Newsgroups: comp.sources.games
  4. Subject: v18i058:  threedee - two 3d tetris games for X, Part03/04
  5. Date: 30 Aug 1993 08:36:09 -0700
  6. Organization: Tektronix, Inc., Redmond, OR
  7. Lines: 2196
  8. Approved: billr@saab.CNA.TEK.COM
  9. Message-ID: <25t6p9$fmf@saab.cna.tek.com>
  10. NNTP-Posting-Host: saab.cna.tek.com
  11. Xref: uunet comp.sources.games:1858
  12.  
  13. Submitted-by: "Andrew C. Plotkin" <ap1i+@andrew.cmu.edu>
  14. Posting-number: Volume 18, Issue 58
  15. Archive-name: threedee/part03
  16. Environment: X11, Xlib
  17.  
  18.  
  19.  
  20. #! /bin/sh
  21. # This is a shell archive.  Remove anything before this line, then unpack
  22. # it by saving it into a file and typing "sh file".  To overwrite existing
  23. # files, type "sh file -c".  You can also feed this as standard input via
  24. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  25. # will see the following message at the end:
  26. #        "End of archive 3 (of 4)."
  27. # Contents:  spatial/Makefile spatial/README spatial/deco.c
  28. #   spatial/grey01.bm spatial/grey02.bm spatial/grey03.bm
  29. #   spatial/grey04.bm spatial/grey05.bm spatial/grey06.bm
  30. #   spatial/grey07.bm spatial/grey08.bm spatial/grey09.bm
  31. #   spatial/grey10.bm spatial/grey11.bm spatial/grey12.bm
  32. #   spatial/grey13.bm spatial/grey14.bm spatial/grey15.bm
  33. #   spatial/grey16.bm spatial/score.c spatial/spatial.6
  34. #   spatial/spatial.c spatial/spatial.h spheral/README spheral/deco.c
  35. #   spheral/errdi.c spheral/gcgrey.c spheral/grey01.bm
  36. #   spheral/grey02.bm spheral/grey03.bm spheral/grey04.bm
  37. #   spheral/grey05.bm spheral/grey06.bm spheral/grey07.bm
  38. #   spheral/grey08.bm spheral/grey09.bm spheral/grey10.bm
  39. #   spheral/grey11.bm spheral/grey12.bm spheral/grey13.bm
  40. #   spheral/grey14.bm spheral/grey15.bm spheral/grey16.bm
  41. #   spheral/spheral.c spheral/spheral.h spheral/spheral.shp
  42. #   spheral/test.c
  43. # Wrapped by billr@saab on Mon Aug 30 08:05:07 1993
  44. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  45. if test -f 'spatial/Makefile' -a "${1}" != "-c" ; then 
  46.   echo shar: Will not clobber existing file \"'spatial/Makefile'\"
  47. else
  48. echo shar: Extracting \"'spatial/Makefile'\" \(1391 characters\)
  49. sed "s/^X//" >'spatial/Makefile' <<'END_OF_FILE'
  50. X# The next lines define the directories where the executable, piece file,
  51. X# and score file are installed. Change them to whatever is appropriate.
  52. XDESTDIR = /tmp/dest
  53. XDESTLIBDIR = $(DESTDIR)/lib
  54. XDESTBINDIR = $(DESTDIR)/bin
  55. XDESTMANDIR = $(DESTDIR)/man
  56. X
  57. XSCOREFILE = $(DESTLIBDIR)/spatial.sco
  58. XPIECEFILE = $(DESTLIBDIR)/spatial.shp
  59. X
  60. XDEFINES =
  61. X
  62. X# uncomment the next line if your system doesn't have
  63. X# random() and srandom()
  64. X#DEFINES = -Drandom=lrand48 -Dsrandom=srand48
  65. X
  66. X# uncomment the next line for Solaris, which has neither
  67. X# flock() nor random().
  68. X#DEFINES = -DUSELOCKF -Drandom=lrand48 -Dsrandom=srand48
  69. X
  70. XINCLUDES = -I/usr/local/include
  71. XXLIBS = -L/usr/local/lib -lX11
  72. X
  73. XOBJS = spatial.o disp.o game.o rots.o intro.o deco.o score.o
  74. X
  75. XCFLAGS= -O $(DEFINES) $(INCLUDES)  \
  76. X   -DSCOREFILENAME=\"$(SCOREFILE)\"  \
  77. X   -DPIECEFILENAME=\"$(PIECEFILE)\"
  78. X
  79. Xall: spatial
  80. X
  81. Xspatial: $(OBJS)
  82. X    $(CC) $(CFLAGS) $(OBJS) -o spatial $(XLIBS) -lm 
  83. X
  84. Xspatial.o: spatial.c spatial.h
  85. Xdisp.o: disp.c spatial.h
  86. Xgame.o: game.c spatial.h
  87. Xrots.o: rots.c spatial.h
  88. Xintro.o: intro.c spatial.h
  89. Xdeco.o: deco.c spatial.h
  90. Xscore.o: score.c spatial.h
  91. X
  92. Xtargetdirs:
  93. X    -mkdir $(DESTLIBDIR)
  94. X    -mkdir $(DESTBINDIR)
  95. X    -mkdir $(DESTMANDIR)
  96. X    -mkdir $(DESTMANDIR)/man6
  97. X
  98. Xinstall: spatial  targetdirs
  99. X    install -c -s spatial $(DESTBINDIR)
  100. X    install -c spatial.shp  $(PIECEFILE)
  101. X    install -c spatial.6 $(DESTMANDIR)/man6
  102. X
  103. Xclean: 
  104. X    rm -f *.o spatial
  105. X
  106. END_OF_FILE
  107. if test 1391 -ne `wc -c <'spatial/Makefile'`; then
  108.     echo shar: \"'spatial/Makefile'\" unpacked with wrong size!
  109. fi
  110. # end of 'spatial/Makefile'
  111. fi
  112. if test -f 'spatial/README' -a "${1}" != "-c" ; then 
  113.   echo shar: Will not clobber existing file \"'spatial/README'\"
  114. else
  115. echo shar: Extracting \"'spatial/README'\" \(1083 characters\)
  116. sed "s/^X//" >'spatial/README' <<'END_OF_FILE'
  117. XSpatial: three-dimensional tetris.
  118. X
  119. X(C) Copyright 1991-3 Andrew Plotkin. (ap1i+@andrew.cmu.edu) 
  120. XPermission is given to copy and use, as long as this copyright notice 
  121. Xis retained.
  122. X
  123. XTo compile: change the first few lines of the Makefile to reflect
  124. Xwhere you want the game installed.
  125. X
  126. XThe piece shape file *must* be
  127. Xinstalled in the DESTLIBDIR you define in the Makefile.
  128. XType "make install" to do this.
  129. X(The score file, which in earlier versions had to be installed,
  130. Xis now generated automatically if it does not exist.)
  131. X
  132. X------------------
  133. X
  134. XSome comments about porting to various systems: 
  135. X(these are gathered from play-testing comments, and
  136. Xhave not been tested)
  137. X
  138. XIf your system does not have random(), uncomment the line
  139. X#DEFINES = -Drandom=lrand48 -Dsrandom=srand48
  140. X
  141. XIf your system does not have flock(), add -DUSELOCKF
  142. Xto the DEFINES line.
  143. X
  144. XSolaris: Uncomment the line
  145. X#DEFINES = -DUSELOCKF -Drandom=lrand48 -Dsrandom=srand48
  146. Xin the Makefile.
  147. X
  148. XAIX on RS/6000: Add the line
  149. X#include <sys/select.h> 
  150. Xin game.c and intro.c.
  151. X
  152. XYou may have to add
  153. X#include <sys/types.h>
  154. Xon score.c.
  155. X
  156. END_OF_FILE
  157. if test 1083 -ne `wc -c <'spatial/README'`; then
  158.     echo shar: \"'spatial/README'\" unpacked with wrong size!
  159. fi
  160. # end of 'spatial/README'
  161. fi
  162. if test -f 'spatial/deco.c' -a "${1}" != "-c" ; then 
  163.   echo shar: Will not clobber existing file \"'spatial/deco.c'\"
  164. else
  165. echo shar: Extracting \"'spatial/deco.c'\" \(2259 characters\)
  166. sed "s/^X//" >'spatial/deco.c' <<'END_OF_FILE'
  167. X/* (C) Copyright 1991 Andrew Plotkin. Permission is
  168. X given to copy and use, as long as this copyright
  169. X notice is retained. */
  170. X
  171. X#include <stdio.h>
  172. X#include <sys/time.h>
  173. X#include <X11/Xlib.h>
  174. X#include <X11/keysym.h>
  175. X#include "spatial.h"
  176. X
  177. Xextern GC gcblack, gcwhite, gcinv, gccopy, gcline, gcfield, gccubes[]; 
  178. X
  179. Xextern void pause_redraw(), add_cubie();
  180. X
  181. Xvoid pauseloop()
  182. X{
  183. X    short status, res, lev;
  184. X    short droptimer, stattick;
  185. X    Bool eventp;
  186. X    XEvent event, nextevent;
  187. X    long evmasks;
  188. X    char key;
  189. X    KeySym ksym;
  190. X    struct timeval timeout;
  191. X
  192. X    setup_fieldpm();
  193. X    pause_redraw();
  194. X    lev = 0;
  195. X    droptimer=0;
  196. X
  197. X    while (1) {
  198. X    evmasks = (KeyPressMask | ExposureMask | StructureNotifyMask);
  199. X    eventp = XCheckWindowEvent(dpy, win, evmasks, &event);
  200. X    if (eventp) switch (event.type) {
  201. X        case Expose:
  202. X        eventp = XCheckWindowEvent(dpy, win, evmasks, &nextevent);
  203. X        while (eventp && nextevent.type == Expose) {
  204. X            eventp = XCheckWindowEvent(dpy, win, evmasks, &nextevent);
  205. X        };
  206. X        if (eventp) {
  207. X            XPutBackEvent(dpy, &nextevent);
  208. X        };
  209. X        pause_redraw();
  210. X        break;
  211. X        case KeyPress:
  212. X        XLookupString(&event, &key, 1, &ksym, NULL);
  213. X        /*printf("got '%s'\n", XKeysymToString(ksym));*/
  214. X        switch (ksym) {
  215. X            case XK_Escape:
  216. X            case XK_Q:
  217. X            case XK_q:
  218. X            case XK_S:
  219. X            case XK_s:
  220. X            return;
  221. X            break;
  222. X        }
  223. X        break;
  224. X        case ConfigureNotify:
  225. X        if (event.xconfigure.width != dispx || event.xconfigure.height != dispy) {
  226. X            dispx = event.xconfigure.width;
  227. X            dispy = event.xconfigure.height;
  228. X            XFreePixmap(dpy, backpm);
  229. X            XFreePixmap(dpy, fieldpm);
  230. X            backpm = XCreatePixmap(dpy, win, dispx, dispy,
  231. X                       scndepth);   
  232. X            fieldpm = XCreatePixmap(dpy, win, dispx, dispy,
  233. X                        scndepth);   
  234. X            redo_board_globals();
  235. X            setup_cubies();
  236. X            setup_fieldpm();
  237. X            pause_redraw();
  238. X        }
  239. X        break;
  240. X    };
  241. X    timeout.tv_sec = 0;
  242. X    timeout.tv_usec = 50000;
  243. X    select(0, 0, 0, 0, &timeout);    
  244. X    droptimer++;
  245. X    if (droptimer>=5) {
  246. X        droptimer=0;
  247. X        if (lev==fieldz) {
  248. X        lev=0;
  249. X        setup_fieldpm();
  250. X        pause_redraw();
  251. X        }
  252. X        else {
  253. X        add_cubie(random()%fieldx, random()%fieldy, lev);
  254. X        pause_redraw();
  255. X        lev++;
  256. X        }
  257. X    }
  258. X    }
  259. X}
  260. X
  261. Xvoid pause_redraw()
  262. X{
  263. X    XCopyArea(dpy, fieldpm, win, gccopy, 0, 0, dispx, dispy, 0, 0);
  264. X}
  265. END_OF_FILE
  266. if test 2259 -ne `wc -c <'spatial/deco.c'`; then
  267.     echo shar: \"'spatial/deco.c'\" unpacked with wrong size!
  268. fi
  269. # end of 'spatial/deco.c'
  270. fi
  271. if test -f 'spatial/grey01.bm' -a "${1}" != "-c" ; then 
  272.   echo shar: Will not clobber existing file \"'spatial/grey01.bm'\"
  273. else
  274. echo shar: Extracting \"'spatial/grey01.bm'\" \(243 characters\)
  275. sed "s/^X//" >'spatial/grey01.bm' <<'END_OF_FILE'
  276. X#define grey01_width 16
  277. X#define grey01_height 16
  278. Xstatic char grey01_bits[] = {
  279. X0xff,0xff,0xfd,0xfd,0xff,0xff,0xff,0xff,0xff,0xff,0xdf,0xdf,
  280. X0xff,0xff,0xff,0xff,0xff,0xff,0xfd,0xfd,0xff,0xff,0xff,0xff,
  281. X0xff,0xff,0xdf,0xdf,0xff,0xff,0xff,0xff};
  282. END_OF_FILE
  283. if test 243 -ne `wc -c <'spatial/grey01.bm'`; then
  284.     echo shar: \"'spatial/grey01.bm'\" unpacked with wrong size!
  285. fi
  286. # end of 'spatial/grey01.bm'
  287. fi
  288. if test -f 'spatial/grey02.bm' -a "${1}" != "-c" ; then 
  289.   echo shar: Will not clobber existing file \"'spatial/grey02.bm'\"
  290. else
  291. echo shar: Extracting \"'spatial/grey02.bm'\" \(243 characters\)
  292. sed "s/^X//" >'spatial/grey02.bm' <<'END_OF_FILE'
  293. X#define grey02_width 16
  294. X#define grey02_height 16
  295. Xstatic char grey02_bits[] = {
  296. X0xff,0xff,0xdf,0xdf,0xff,0xff,0xfd,0xfd,0xff,0xff,0xdf,0xdf,
  297. X0xff,0xff,0xfd,0xfd,0xff,0xff,0xdf,0xdf,0xff,0xff,0xfd,0xfd,
  298. X0xff,0xff,0xdf,0xdf,0xff,0xff,0xfd,0xfd};
  299. END_OF_FILE
  300. if test 243 -ne `wc -c <'spatial/grey02.bm'`; then
  301.     echo shar: \"'spatial/grey02.bm'\" unpacked with wrong size!
  302. fi
  303. # end of 'spatial/grey02.bm'
  304. fi
  305. if test -f 'spatial/grey03.bm' -a "${1}" != "-c" ; then 
  306.   echo shar: Will not clobber existing file \"'spatial/grey03.bm'\"
  307. else
  308. echo shar: Extracting \"'spatial/grey03.bm'\" \(243 characters\)
  309. sed "s/^X//" >'spatial/grey03.bm' <<'END_OF_FILE'
  310. X#define grey03_width 16
  311. X#define grey03_height 16
  312. Xstatic char grey03_bits[] = {
  313. X0xff,0xff,0xdd,0xdd,0xff,0xff,0xff,0xff,0xff,0xff,0xdd,0xdd,
  314. X0xff,0xff,0xff,0xff,0xff,0xff,0xdd,0xdd,0xff,0xff,0xff,0xff,
  315. X0xff,0xff,0xdd,0xdd,0xff,0xff,0xff,0xff};
  316. END_OF_FILE
  317. if test 243 -ne `wc -c <'spatial/grey03.bm'`; then
  318.     echo shar: \"'spatial/grey03.bm'\" unpacked with wrong size!
  319. fi
  320. # end of 'spatial/grey03.bm'
  321. fi
  322. if test -f 'spatial/grey04.bm' -a "${1}" != "-c" ; then 
  323.   echo shar: Will not clobber existing file \"'spatial/grey04.bm'\"
  324. else
  325. echo shar: Extracting \"'spatial/grey04.bm'\" \(243 characters\)
  326. sed "s/^X//" >'spatial/grey04.bm' <<'END_OF_FILE'
  327. X#define grey04_width 16
  328. X#define grey04_height 16
  329. Xstatic char grey04_bits[] = {
  330. X0xee,0xee,0xff,0xff,0xbb,0xbb,0xff,0xff,0xee,0xee,0xff,0xff,
  331. X0xbb,0xbb,0xff,0xff,0xee,0xee,0xff,0xff,0xbb,0xbb,0xff,0xff,
  332. X0xee,0xee,0xff,0xff,0xbb,0xbb,0xff,0xff};
  333. END_OF_FILE
  334. if test 243 -ne `wc -c <'spatial/grey04.bm'`; then
  335.     echo shar: \"'spatial/grey04.bm'\" unpacked with wrong size!
  336. fi
  337. # end of 'spatial/grey04.bm'
  338. fi
  339. if test -f 'spatial/grey05.bm' -a "${1}" != "-c" ; then 
  340.   echo shar: Will not clobber existing file \"'spatial/grey05.bm'\"
  341. else
  342. echo shar: Extracting \"'spatial/grey05.bm'\" \(243 characters\)
  343. sed "s/^X//" >'spatial/grey05.bm' <<'END_OF_FILE'
  344. X#define grey05_width 16
  345. X#define grey05_height 16
  346. Xstatic char grey05_bits[] = {
  347. X0xff,0xff,0x55,0x55,0xff,0xff,0xdd,0xdd,0xff,0xff,0x55,0x55,
  348. X0xff,0xff,0xdd,0xdd,0xff,0xff,0x55,0x55,0xff,0xff,0xdd,0xdd,
  349. X0xff,0xff,0x55,0x55,0xff,0xff,0xdd,0xdd};
  350. END_OF_FILE
  351. if test 243 -ne `wc -c <'spatial/grey05.bm'`; then
  352.     echo shar: \"'spatial/grey05.bm'\" unpacked with wrong size!
  353. fi
  354. # end of 'spatial/grey05.bm'
  355. fi
  356. if test -f 'spatial/grey06.bm' -a "${1}" != "-c" ; then 
  357.   echo shar: Will not clobber existing file \"'spatial/grey06.bm'\"
  358. else
  359. echo shar: Extracting \"'spatial/grey06.bm'\" \(243 characters\)
  360. sed "s/^X//" >'spatial/grey06.bm' <<'END_OF_FILE'
  361. X#define grey06_width 16
  362. X#define grey06_height 16
  363. Xstatic char grey06_bits[] = {
  364. X0xff,0xff,0x55,0x55,0xff,0xff,0xbb,0xbb,0xff,0xff,0x55,0x55,
  365. X0xff,0xff,0xee,0xee,0xff,0xff,0x55,0x55,0xff,0xff,0xbb,0xbb,
  366. X0xff,0xff,0x55,0x55,0xff,0xff,0xee,0xee};
  367. END_OF_FILE
  368. if test 243 -ne `wc -c <'spatial/grey06.bm'`; then
  369.     echo shar: \"'spatial/grey06.bm'\" unpacked with wrong size!
  370. fi
  371. # end of 'spatial/grey06.bm'
  372. fi
  373. if test -f 'spatial/grey07.bm' -a "${1}" != "-c" ; then 
  374.   echo shar: Will not clobber existing file \"'spatial/grey07.bm'\"
  375. else
  376. echo shar: Extracting \"'spatial/grey07.bm'\" \(243 characters\)
  377. sed "s/^X//" >'spatial/grey07.bm' <<'END_OF_FILE'
  378. X#define grey07_width 16
  379. X#define grey07_height 16
  380. Xstatic char grey07_bits[] = {
  381. X0xff,0xff,0x55,0x55,0xff,0xff,0x55,0x55,0xff,0xff,0x55,0x55,
  382. X0xff,0xff,0x55,0x55,0xff,0xff,0x55,0x55,0xff,0xff,0x55,0x55,
  383. X0xff,0xff,0x55,0x55,0xff,0xff,0x55,0x55};
  384. END_OF_FILE
  385. if test 243 -ne `wc -c <'spatial/grey07.bm'`; then
  386.     echo shar: \"'spatial/grey07.bm'\" unpacked with wrong size!
  387. fi
  388. # end of 'spatial/grey07.bm'
  389. fi
  390. if test -f 'spatial/grey08.bm' -a "${1}" != "-c" ; then 
  391.   echo shar: Will not clobber existing file \"'spatial/grey08.bm'\"
  392. else
  393. echo shar: Extracting \"'spatial/grey08.bm'\" \(243 characters\)
  394. sed "s/^X//" >'spatial/grey08.bm' <<'END_OF_FILE'
  395. X#define grey08_width 16
  396. X#define grey08_height 16
  397. Xstatic char grey08_bits[] = {
  398. X0xdd,0xdd,0x77,0x77,0xdd,0xdd,0x77,0x77,0xdd,0xdd,0x77,0x77,
  399. X0xdd,0xdd,0x77,0x77,0xdd,0xdd,0x77,0x77,0xdd,0xdd,0x77,0x77,
  400. X0xdd,0xdd,0x77,0x77,0xdd,0xdd,0x77,0x77};
  401. END_OF_FILE
  402. if test 243 -ne `wc -c <'spatial/grey08.bm'`; then
  403.     echo shar: \"'spatial/grey08.bm'\" unpacked with wrong size!
  404. fi
  405. # end of 'spatial/grey08.bm'
  406. fi
  407. if test -f 'spatial/grey09.bm' -a "${1}" != "-c" ; then 
  408.   echo shar: Will not clobber existing file \"'spatial/grey09.bm'\"
  409. else
  410. echo shar: Extracting \"'spatial/grey09.bm'\" \(243 characters\)
  411. sed "s/^X//" >'spatial/grey09.bm' <<'END_OF_FILE'
  412. X#define grey09_width 16
  413. X#define grey09_height 16
  414. Xstatic char grey09_bits[] = {
  415. X0xff,0xff,0x55,0x55,0xfb,0xfb,0x55,0x55,0xff,0xff,0x55,0x55,
  416. X0xbf,0xbf,0x55,0x55,0xff,0xff,0x55,0x55,0xfb,0xfb,0x55,0x55,
  417. X0xff,0xff,0x55,0x55,0xbf,0xbf,0x55,0x55};
  418. END_OF_FILE
  419. if test 243 -ne `wc -c <'spatial/grey09.bm'`; then
  420.     echo shar: \"'spatial/grey09.bm'\" unpacked with wrong size!
  421. fi
  422. # end of 'spatial/grey09.bm'
  423. fi
  424. if test -f 'spatial/grey10.bm' -a "${1}" != "-c" ; then 
  425.   echo shar: Will not clobber existing file \"'spatial/grey10.bm'\"
  426. else
  427. echo shar: Extracting \"'spatial/grey10.bm'\" \(243 characters\)
  428. sed "s/^X//" >'spatial/grey10.bm' <<'END_OF_FILE'
  429. X#define grey10_width 16
  430. X#define grey10_height 16
  431. Xstatic char grey10_bits[] = {
  432. X0xee,0xee,0x55,0x55,0xff,0xff,0x55,0x55,0xee,0xee,0x55,0x55,
  433. X0xff,0xff,0x55,0x55,0xee,0xee,0x55,0x55,0xff,0xff,0x55,0x55,
  434. X0xee,0xee,0x55,0x55,0xff,0xff,0x55,0x55};
  435. END_OF_FILE
  436. if test 243 -ne `wc -c <'spatial/grey10.bm'`; then
  437.     echo shar: \"'spatial/grey10.bm'\" unpacked with wrong size!
  438. fi
  439. # end of 'spatial/grey10.bm'
  440. fi
  441. if test -f 'spatial/grey11.bm' -a "${1}" != "-c" ; then 
  442.   echo shar: Will not clobber existing file \"'spatial/grey11.bm'\"
  443. else
  444. echo shar: Extracting \"'spatial/grey11.bm'\" \(243 characters\)
  445. sed "s/^X//" >'spatial/grey11.bm' <<'END_OF_FILE'
  446. X#define grey11_width 16
  447. X#define grey11_height 16
  448. Xstatic char grey11_bits[] = {
  449. X0xee,0xee,0x55,0x55,0xfb,0xfb,0x55,0x55,0xee,0xee,0x55,0x55,
  450. X0xbf,0xbf,0x55,0x55,0xee,0xee,0x55,0x55,0xfb,0xfb,0x55,0x55,
  451. X0xee,0xee,0x55,0x55,0xbf,0xbf,0x55,0x55};
  452. END_OF_FILE
  453. if test 243 -ne `wc -c <'spatial/grey11.bm'`; then
  454.     echo shar: \"'spatial/grey11.bm'\" unpacked with wrong size!
  455. fi
  456. # end of 'spatial/grey11.bm'
  457. fi
  458. if test -f 'spatial/grey12.bm' -a "${1}" != "-c" ; then 
  459.   echo shar: Will not clobber existing file \"'spatial/grey12.bm'\"
  460. else
  461. echo shar: Extracting \"'spatial/grey12.bm'\" \(243 characters\)
  462. sed "s/^X//" >'spatial/grey12.bm' <<'END_OF_FILE'
  463. X#define grey12_width 16
  464. X#define grey12_height 16
  465. Xstatic char grey12_bits[] = {
  466. X0x55,0x55,0xee,0xee,0x55,0x55,0xbb,0xbb,0x55,0x55,0xee,0xee,
  467. X0x55,0x55,0xbb,0xbb,0x55,0x55,0xee,0xee,0x55,0x55,0xbb,0xbb,
  468. X0x55,0x55,0xee,0xee,0x55,0x55,0xbb,0xbb};
  469. END_OF_FILE
  470. if test 243 -ne `wc -c <'spatial/grey12.bm'`; then
  471.     echo shar: \"'spatial/grey12.bm'\" unpacked with wrong size!
  472. fi
  473. # end of 'spatial/grey12.bm'
  474. fi
  475. if test -f 'spatial/grey13.bm' -a "${1}" != "-c" ; then 
  476.   echo shar: Will not clobber existing file \"'spatial/grey13.bm'\"
  477. else
  478. echo shar: Extracting \"'spatial/grey13.bm'\" \(243 characters\)
  479. sed "s/^X//" >'spatial/grey13.bm' <<'END_OF_FILE'
  480. X#define grey13_width 16
  481. X#define grey13_height 16
  482. Xstatic char grey13_bits[] = {
  483. X0x55,0x55,0xee,0xee,0x55,0x55,0xba,0xba,0x55,0x55,0xee,0xee,
  484. X0x55,0x55,0xab,0xab,0x55,0x55,0xee,0xee,0x55,0x55,0xba,0xba,
  485. X0x55,0x55,0xee,0xee,0x55,0x55,0xab,0xab};
  486. END_OF_FILE
  487. if test 243 -ne `wc -c <'spatial/grey13.bm'`; then
  488.     echo shar: \"'spatial/grey13.bm'\" unpacked with wrong size!
  489. fi
  490. # end of 'spatial/grey13.bm'
  491. fi
  492. if test -f 'spatial/grey14.bm' -a "${1}" != "-c" ; then 
  493.   echo shar: Will not clobber existing file \"'spatial/grey14.bm'\"
  494. else
  495. echo shar: Extracting \"'spatial/grey14.bm'\" \(243 characters\)
  496. sed "s/^X//" >'spatial/grey14.bm' <<'END_OF_FILE'
  497. X#define grey14_width 16
  498. X#define grey14_height 16
  499. Xstatic char grey14_bits[] = {
  500. X0x57,0x57,0xaa,0xaa,0x75,0x75,0xaa,0xaa,0x57,0x57,0xaa,0xaa,
  501. X0x75,0x75,0xaa,0xaa,0x57,0x57,0xaa,0xaa,0x75,0x75,0xaa,0xaa,
  502. X0x57,0x57,0xaa,0xaa,0x75,0x75,0xaa,0xaa};
  503. END_OF_FILE
  504. if test 243 -ne `wc -c <'spatial/grey14.bm'`; then
  505.     echo shar: \"'spatial/grey14.bm'\" unpacked with wrong size!
  506. fi
  507. # end of 'spatial/grey14.bm'
  508. fi
  509. if test -f 'spatial/grey15.bm' -a "${1}" != "-c" ; then 
  510.   echo shar: Will not clobber existing file \"'spatial/grey15.bm'\"
  511. else
  512. echo shar: Extracting \"'spatial/grey15.bm'\" \(243 characters\)
  513. sed "s/^X//" >'spatial/grey15.bm' <<'END_OF_FILE'
  514. X#define grey15_width 16
  515. X#define grey15_height 16
  516. Xstatic char grey15_bits[] = {
  517. X0x55,0x55,0xae,0xae,0x55,0x55,0xaa,0xaa,0x55,0x55,0xea,0xea,
  518. X0x55,0x55,0xaa,0xaa,0x55,0x55,0xae,0xae,0x55,0x55,0xaa,0xaa,
  519. X0x55,0x55,0xea,0xea,0x55,0x55,0xaa,0xaa};
  520. END_OF_FILE
  521. if test 243 -ne `wc -c <'spatial/grey15.bm'`; then
  522.     echo shar: \"'spatial/grey15.bm'\" unpacked with wrong size!
  523. fi
  524. # end of 'spatial/grey15.bm'
  525. fi
  526. if test -f 'spatial/grey16.bm' -a "${1}" != "-c" ; then 
  527.   echo shar: Will not clobber existing file \"'spatial/grey16.bm'\"
  528. else
  529. echo shar: Extracting \"'spatial/grey16.bm'\" \(243 characters\)
  530. sed "s/^X//" >'spatial/grey16.bm' <<'END_OF_FILE'
  531. X#define grey16_width 16
  532. X#define grey16_height 16
  533. Xstatic char grey16_bits[] = {
  534. X0x55,0x55,0xaa,0xaa,0x55,0x55,0xaa,0xaa,0x55,0x55,0xaa,0xaa,
  535. X0x55,0x55,0xaa,0xaa,0x55,0x55,0xaa,0xaa,0x55,0x55,0xaa,0xaa,
  536. X0x55,0x55,0xaa,0xaa,0x55,0x55,0xaa,0xaa};
  537. END_OF_FILE
  538. if test 243 -ne `wc -c <'spatial/grey16.bm'`; then
  539.     echo shar: \"'spatial/grey16.bm'\" unpacked with wrong size!
  540. fi
  541. # end of 'spatial/grey16.bm'
  542. fi
  543. if test -f 'spatial/score.c' -a "${1}" != "-c" ; then 
  544.   echo shar: Will not clobber existing file \"'spatial/score.c'\"
  545. else
  546. echo shar: Extracting \"'spatial/score.c'\" \(3766 characters\)
  547. sed "s/^X//" >'spatial/score.c' <<'END_OF_FILE'
  548. X/* (C) Copyright 1991 Andrew Plotkin. Permission is
  549. X given to copy and use, as long as this copyright
  550. X notice is retained. */
  551. X
  552. X#include <stdio.h>
  553. X#include <errno.h>
  554. X#include <ctype.h> 
  555. X#include <pwd.h>    
  556. X#include <sys/file.h>
  557. X#include <X11/Xlib.h>
  558. X#ifdef AFS
  559. X#include <niftyprofile.h>    
  560. X#endif
  561. X#include "spatial.h"
  562. X
  563. Xextern char *getenv();
  564. Xchar ProgramName[] = "spatial";
  565. X
  566. Xgamer hscores[NUMGAMERS];
  567. Xchar hscorefl[512];
  568. Xchar userid[16], gamename[16];
  569. X
  570. Xextern int errno;
  571. X
  572. Xvoid load_hscores(save)
  573. Xint save;
  574. X{
  575. X    FILE *fl;
  576. X    register int ix, jx;
  577. X    int fd, res;
  578. X    char buf[255];
  579. X
  580. X    fl = fopen(hscorefl, "r+");
  581. X    if (!fl) {
  582. X    fprintf(stderr,
  583. X        "spatial: unable to open high score file\n");
  584. X    fprintf(stderr,
  585. X        "spatial: generating empty score file\n");
  586. X
  587. X    fl = fopen(hscorefl, "w");
  588. X    if (!fl) {
  589. X        fprintf(stderr,
  590. X            "spatial: unable to create high score file\n");
  591. X        exit(-1);
  592. X    }
  593. X
  594. X    for (ix=0; ix<NUMGAMERS; ix++) {
  595. X        fprintf(fl, "----\nSpatial\n0\n");
  596. X    }
  597. X    fclose(fl);
  598. X    fl = fopen(hscorefl, "r+");
  599. X    if (!fl) {
  600. X        fprintf(stderr,
  601. X            "spatial: unable to reopen high score file\n");
  602. X        exit(-1);
  603. X    }
  604. X    }
  605. X
  606. X    fd = fileno(fl);
  607. X#ifdef USELOCKF
  608. X    res = lockf(fd, F_LOCK, 0);
  609. X#else
  610. X    res = flock(fd, LOCK_NB | LOCK_EX);
  611. X#endif
  612. X    while (res) {
  613. X    if (errno != EWOULDBLOCK) {
  614. X        fprintf(stderr,
  615. X            "spatial: unable to lock high score file\n");
  616. X        exit(-1);
  617. X    };
  618. X    sleep(1);
  619. X#ifdef USELOCKF
  620. X    res = lockf(fd, F_LOCK, 0);
  621. X#else
  622. X    res = flock(fd, LOCK_NB | LOCK_EX);
  623. X#endif
  624. X    };
  625. X
  626. X    for (ix=0; ix<NUMGAMERS; ix++) {
  627. X    long val;
  628. X
  629. X    fgets(buf, 255, fl);
  630. X    for (jx=0; jx<15 && buf[jx]!='\n'; jx++) 
  631. X        hscores[ix].userid[jx] = buf[jx];
  632. X    hscores[ix].userid[jx] = '\0';
  633. X    
  634. X    fgets(buf, 255, fl);
  635. X    for (jx=0; jx<15 && buf[jx]!='\n'; jx++) 
  636. X        hscores[ix].name[jx] = buf[jx];
  637. X    hscores[ix].name[jx] = '\0';
  638. X    
  639. X    fgets(buf, 255, fl);
  640. X    val=0;
  641. X    for (jx=0; buf[jx]!='\n'; jx++) 
  642. X        val = val*10 + buf[jx] - '0';
  643. X    hscores[ix].score = val;
  644. X    sprintf(hscores[ix].scoret, "%d", val);
  645. X    };
  646. X
  647. X    if (save) {
  648. X    if (checkmod_scores()) {
  649. X        rewind(fl);
  650. X        for (ix=0; ix<NUMGAMERS; ix++) {
  651. X        fprintf(fl, "%s\n%s\n%d\n", hscores[ix].userid,
  652. X            hscores[ix].name, hscores[ix].score);
  653. X        }
  654. X    }
  655. X    }
  656. X
  657. X#ifdef USELOCKF
  658. X    lockf(fd, F_ULOCK, 0);
  659. X#else
  660. X    flock(fd, LOCK_UN);
  661. X#endif
  662. X
  663. X    fclose(fl);
  664. X}
  665. X
  666. Xint checkmod_scores()
  667. X{
  668. X    register int ix;
  669. X    int new, bottom;
  670. X    
  671. X    if (score <= hscores[NUMGAMERS-1].score) return 0;
  672. X    
  673. X    for (ix=0; strcmp(hscores[ix].userid, userid)
  674. X      && ix<NUMGAMERS; ix++);
  675. X    
  676. X    if (ix<NUMGAMERS) { /* was in list */
  677. X    if (score <= hscores[ix].score) return 0;
  678. X    bottom = ix;
  679. X    }
  680. X    else { /* wasn't in list */
  681. X    bottom = NUMGAMERS-1;
  682. X    };
  683. X
  684. X    for (new=0; score<=hscores[new].score; new++);
  685. X    for (ix=bottom; ix>new; ix--) {
  686. X    strcpy(hscores[ix].name, hscores[ix-1].name);
  687. X    strcpy(hscores[ix].userid, hscores[ix-1].userid);
  688. X    strcpy(hscores[ix].scoret, hscores[ix-1].scoret);
  689. X    hscores[ix].score = hscores[ix-1].score;
  690. X    };
  691. X    strcpy(hscores[new].name, gamename);
  692. X    strcpy(hscores[new].userid, userid);
  693. X    hscores[new].score = score;
  694. X    sprintf(hscores[new].scoret, "%d", score);
  695. X
  696. X    return 1;
  697. X}
  698. X
  699. Xvoid get_names()
  700. X{
  701. X    register int ix;
  702. X    struct passwd *tp;
  703. X    char *tcp;
  704. X
  705. X    strcpy(hscorefl, SCOREFILENAME);
  706. X
  707. X    tp = getpwuid(getuid());
  708. X    if (!tp) {
  709. X    printf("unable to get userid!\n");
  710. X    strcpy(userid, "????");
  711. X    }
  712. X    else {
  713. X    strncpy(userid, tp->pw_name, 16);
  714. X    userid[15] = '\0';
  715. X    }
  716. X
  717. X    tcp = getenv("NAME");
  718. X    if (tcp) {
  719. X    strncpy(gamename, tcp, 16);
  720. X    gamename[15] = '\0';
  721. X    }
  722. X    else if (tcp=XGetDefault(dpy, "spatial", "name")) {
  723. X    strncpy(gamename, tcp, 16);
  724. X    gamename[15] = '\0';
  725. X    }
  726. X    else {
  727. X    strcpy(gamename, userid);
  728. X    };
  729. X
  730. X    printf("Welcome, %s (%s)\n", gamename, userid);
  731. X}
  732. END_OF_FILE
  733. if test 3766 -ne `wc -c <'spatial/score.c'`; then
  734.     echo shar: \"'spatial/score.c'\" unpacked with wrong size!
  735. fi
  736. # end of 'spatial/score.c'
  737. fi
  738. if test -f 'spatial/spatial.6' -a "${1}" != "-c" ; then 
  739.   echo shar: Will not clobber existing file \"'spatial/spatial.6'\"
  740. else
  741. echo shar: Extracting \"'spatial/spatial.6'\" \(1953 characters\)
  742. sed "s/^X//" >'spatial/spatial.6' <<'END_OF_FILE'
  743. X.PU
  744. X.TH SPATIAL 6 contributed
  745. X.SH NAME
  746. Xspatial  \-  three-dimensional Tetris on a cubic lattice
  747. X.SH SYNOPSIS
  748. X.B spatial
  749. X[ 
  750. X.I -m
  751. X]
  752. X.PP
  753. X.B -m
  754. X: Force monochrome mode, even on color displays.
  755. X.SH DESCRIPTION
  756. XIf you don't know the rules of Tetris by now, you're beyond hope.
  757. X.PP
  758. XYou are looking down; pieces appear directly in front of you
  759. Xand fall away from you. The current piece is transparent;
  760. Xwhen it lands, it becomes opaque. You must complete an entire
  761. Xlayer (25 cubes) to make it disappear.
  762. X.PP
  763. XThe bottom of the game display shows your score, and also
  764. Xa meter which indicates how high the pieces are stacked on
  765. Xthe board.
  766. X.PP
  767. XYou can resize the window, and the board will be scaled
  768. Xappropriately. (The high-score list doesn't behave so
  769. Xcleverly.)
  770. X.PP
  771. XBy hitting
  772. X.B c
  773. Xat the title screen, you can play the game with a stereoscopic
  774. Xdisplay. Both "normal" stereoscopic mode (where you stare
  775. Xoff into infinity) and "reversed" mode (where you cross your
  776. Xeyes and stare two inches ahead of your nose) are available.
  777. XReducing the window size may make this easier to use.
  778. X.SH CONTROLS
  779. X.B h, l, i, m, j, k
  780. X: rotate the current piece. The control of rotation around three
  781. Xspatial axes is nigh impossible to describe. See the title
  782. Xscreen for a picture that may help.
  783. X.br
  784. X.I ARROW KEYS
  785. X: slide the current piece north, south, east, or west.
  786. X.br
  787. X.B p
  788. X: drop the current piece one space down.
  789. X.br
  790. X.I SPACE
  791. X: drop the current piece all the way to the bottom of the
  792. Xboard.
  793. X.br
  794. X.I ESCAPE
  795. X: pause the game, and draw pretty random cubes until
  796. Xyou hit
  797. X.I ESCAPE
  798. Xagain.
  799. X.br
  800. X.B q
  801. X: quit the current game with your current score. Hitting
  802. X.B q
  803. Xagain, from the title screen, will exit the program.
  804. X.SH BUGS
  805. XThe stereoscopic mode may cause your brain to dump
  806. Xcore.
  807. X.SH AUTHOR
  808. XAndrew Plotkin <ap1i+@andrew.cmu.edu>
  809. X.br
  810. XThis program is (C) Copyright 1991-3 Andrew Plotkin.
  811. X.br
  812. XPermission is given to copy and distribute freely, as long
  813. Xas this copyright notice is retained.
  814. END_OF_FILE
  815. if test 1953 -ne `wc -c <'spatial/spatial.6'`; then
  816.     echo shar: \"'spatial/spatial.6'\" unpacked with wrong size!
  817. fi
  818. # end of 'spatial/spatial.6'
  819. fi
  820. if test -f 'spatial/spatial.c' -a "${1}" != "-c" ; then 
  821.   echo shar: Will not clobber existing file \"'spatial/spatial.c'\"
  822. else
  823. echo shar: Extracting \"'spatial/spatial.c'\" \(1192 characters\)
  824. sed "s/^X//" >'spatial/spatial.c' <<'END_OF_FILE'
  825. X/* (C) Copyright 1991 Andrew Plotkin. Permission is
  826. Xgiven to copy and use, as long as this copyright
  827. X notice is retained. */
  828. X
  829. X#include <stdio.h>
  830. X#include <X11/Xlib.h>
  831. X#include "spatial.h"
  832. X#include "patchlevel.h"
  833. X
  834. X#define INITWINSIZEX (720)
  835. X#define INITWINSIZEY (740)
  836. X
  837. Xextern void srandom();
  838. X
  839. Xextern double focallen;
  840. Xextern int forcemono;
  841. X
  842. Xextern void xinit(), loadpieces(), gameloop(),
  843. Xinitintro(), introloop(), get_names(), load_hscores(),
  844. Xredo_board_globals();
  845. Xextern int checkmod_scores();
  846. X
  847. Xmain(argc, argv)
  848. Xint argc;
  849. Xchar *argv[];
  850. X{
  851. X    int ix;
  852. X
  853. X    srandom(getpid());
  854. X
  855. X    for (ix=1; ix<argc; ix++) {
  856. X    if (strcmp(argv[ix], "-m")) {
  857. X        fprintf(stderr, "usage: spatial [ -m ]\n");
  858. X        exit(-1);
  859. X    }
  860. X    else
  861. X        forcemono = 1;
  862. X    }
  863. X
  864. X    loadpieces(PIECEFILENAME);
  865. X    fieldx = 5;
  866. X    fieldy = 5;
  867. X    fieldz = 11;
  868. X    fieldoffx = -2.5;
  869. X    fieldoffy = -2.5;
  870. X    fieldoffz = -4.0-(double)fieldz;
  871. X    focallen = 1.0;
  872. X    stereo = 0;
  873. X    dispx = INITWINSIZEX;
  874. X    dispy = INITWINSIZEY;
  875. X    redo_board_globals();
  876. X    xinit();
  877. X    get_names();
  878. X    load_hscores(0);
  879. X    while (1) {
  880. X    initintro();
  881. X    introloop();
  882. X    initgame();
  883. X    gameloop();
  884. X    if (checkmod_scores()) {
  885. X        load_hscores(1);
  886. X    }
  887. X    }
  888. X}
  889. END_OF_FILE
  890. if test 1192 -ne `wc -c <'spatial/spatial.c'`; then
  891.     echo shar: \"'spatial/spatial.c'\" unpacked with wrong size!
  892. fi
  893. # end of 'spatial/spatial.c'
  894. fi
  895. if test -f 'spatial/spatial.h' -a "${1}" != "-c" ; then 
  896.   echo shar: Will not clobber existing file \"'spatial/spatial.h'\"
  897. else
  898. echo shar: Extracting \"'spatial/spatial.h'\" \(2394 characters\)
  899. sed "s/^X//" >'spatial/spatial.h' <<'END_OF_FILE'
  900. X/* (C) Copyright 1991 Andrew Plotkin. Permission is
  901. X given to copy and use, as long as this copyright
  902. X notice is retained. */
  903. X
  904. X#define MAXFIELDWIDTH (10)
  905. X#define MAXFIELDDEPTH (10)
  906. X
  907. X#define MAXFIELDXY (10)
  908. X#define MAXFIELDZ (15)
  909. X
  910. X#define MAXCUBES (8)
  911. X#define MAXVERTS (30)
  912. X#define MAXPOINTS (MAXCUBES+MAXVERTS)
  913. X#define MAXEDGES (40)
  914. X#define MAXPIECES (30)
  915. X
  916. X#define NUMGAMERS (20)
  917. X
  918. X#define F_OFF (0)
  919. X#define F_ON (1)
  920. X#define F_TEMP (2)
  921. X
  922. X#define CUF_SIDEX (1)
  923. X#define CUF_SIDEY (2)
  924. X
  925. Xtypedef struct _point {
  926. X    double x, y, z, w;
  927. X} point;
  928. X
  929. Xtypedef struct _edge {
  930. X    short head, tail;
  931. X} edge;
  932. X
  933. Xtypedef double matrix[4][4];
  934. X
  935. Xtypedef XPoint fieldplist[MAXFIELDXY+1][MAXFIELDXY+1][MAXFIELDZ+1];
  936. X
  937. Xtypedef struct _piecelist {
  938. X    short numcubes;
  939. X    short numverts;
  940. X    short numpoints;  /* sum of cubes and verts */
  941. X    short numedges;
  942. X    point *verts;     /* set to &(points[numcubes]) */
  943. X    point points[MAXPOINTS];
  944. X    edge edges[MAXEDGES];
  945. X} piecelist;
  946. X
  947. Xtypedef struct _gamer {
  948. X    char userid[16];
  949. X    char name[16];
  950. X    long score;
  951. X    char scoret[16];
  952. X} gamer;
  953. X
  954. Xextern gamer hscores[NUMGAMERS];
  955. X
  956. Xextern piecelist pieces[MAXPIECES];
  957. X
  958. Xextern unsigned char field[MAXFIELDXY][MAXFIELDXY][MAXFIELDZ];
  959. Xextern fieldplist fieldpts;
  960. Xextern fieldplist fieldpts2;
  961. X
  962. Xextern short fieldx, fieldy, fieldz;
  963. Xextern double fieldoffx, fieldoffx2, fieldoffy, fieldoffz;
  964. Xextern int meterx, meterx2, metery, metersize,
  965. Xmeterlev, meteroldlev, meter_f_b, meter_b_d;
  966. X/* oldlev is level on fieldpm */
  967. X
  968. Xextern short numpieces;
  969. Xextern short curpiece;
  970. X
  971. Xextern int colors[];
  972. X
  973. Xextern Display *dpy;
  974. Xextern Window win;
  975. Xextern int scndepth;
  976. X
  977. Xextern int stereo;
  978. Xextern int dispx, dispy; /* size of window */
  979. Xextern Pixmap backpm; /* size of window */
  980. Xextern int shapex1, shapex2, shapey1, shapey2;
  981. X/* coords of rectangle of backpm that is different from fieldpm */
  982. Xextern int ddispx1, ddispx2, ddispy1, ddispy2;
  983. X/* coords of rectangle of display that is different from fieldpm */
  984. Xextern Pixmap fieldpm; /* size of window */
  985. Xextern long score, dropticks;
  986. Xextern double boardscale;
  987. Xextern int halfboard, halfboard2;
  988. X
  989. Xextern void clearfield();
  990. X/* zero out field[][][] */
  991. Xextern void setup_fieldpm();
  992. X/* clear, draw field box and side text. Also set
  993. X shape{x,y}{1,2} to window size */
  994. Xextern void startpiece();
  995. X/* pick a piece and put it in the pipeline */
  996. Xextern long current_usec();
  997. Xextern int elapsed();
  998. X
  999. Xextern long random();
  1000. END_OF_FILE
  1001. if test 2394 -ne `wc -c <'spatial/spatial.h'`; then
  1002.     echo shar: \"'spatial/spatial.h'\" unpacked with wrong size!
  1003. fi
  1004. # end of 'spatial/spatial.h'
  1005. fi
  1006. if test -f 'spheral/README' -a "${1}" != "-c" ; then 
  1007.   echo shar: Will not clobber existing file \"'spheral/README'\"
  1008. else
  1009. echo shar: Extracting \"'spheral/README'\" \(1113 characters\)
  1010. sed "s/^X//" >'spheral/README' <<'END_OF_FILE'
  1011. XSpheral: three-dimensional tetris based on close-packed spheres.
  1012. X
  1013. X(C) Copyright 1991-3 Andrew Plotkin. (ap1i+@andrew.cmu.edu) 
  1014. XPermission is given to copy and use, as long as this copyright notice 
  1015. Xis retained.
  1016. X
  1017. XTo compile: change the first few lines of the Makefile to reflect
  1018. Xwhere you want the game installed.
  1019. X
  1020. XThe piece shape file *must* be
  1021. Xinstalled in the DESTLIBDIR you define in the Makefile.
  1022. XType "make install" to do this.
  1023. X(The score file, which in earlier versions had to be installed,
  1024. Xis now generated automatically if it does not exist.)
  1025. X
  1026. X------------------
  1027. X
  1028. XSome comments about porting to various systems: 
  1029. X(these are gathered from play-testing comments, and
  1030. Xhave not been tested)
  1031. X
  1032. XIf your system does not have random(), uncomment the line
  1033. X#DEFINES = -Drandom=lrand48 -Dsrandom=srand48
  1034. X
  1035. XIf your system does not have flock(), add -DUSELOCKF
  1036. Xto the DEFINES line.
  1037. X
  1038. XSolaris: Uncomment the line
  1039. X#DEFINES = -DUSELOCKF -Drandom=lrand48 -Dsrandom=srand48
  1040. Xin the Makefile.
  1041. X
  1042. XAIX on RS/6000: Add the line
  1043. X#include <sys/select.h> 
  1044. Xin game.c and intro.c.
  1045. X
  1046. XYou may have to add
  1047. X#include <sys/types.h>
  1048. Xon score.c.
  1049. X
  1050. END_OF_FILE
  1051. if test 1113 -ne `wc -c <'spheral/README'`; then
  1052.     echo shar: \"'spheral/README'\" unpacked with wrong size!
  1053. fi
  1054. # end of 'spheral/README'
  1055. fi
  1056. if test -f 'spheral/deco.c' -a "${1}" != "-c" ; then 
  1057.   echo shar: Will not clobber existing file \"'spheral/deco.c'\"
  1058. else
  1059. echo shar: Extracting \"'spheral/deco.c'\" \(2338 characters\)
  1060. sed "s/^X//" >'spheral/deco.c' <<'END_OF_FILE'
  1061. X/* (C) Copyright 1991 Andrew Plotkin. Permission is
  1062. X given to copy and use, as long as this copyright
  1063. X notice is retained. */
  1064. X
  1065. X#include <stdio.h>
  1066. X#include <sys/time.h>
  1067. X#include <X11/Xlib.h>
  1068. X#include <X11/keysym.h>
  1069. X#include "spheral.h"
  1070. X
  1071. Xextern GC gccopy; 
  1072. X
  1073. Xextern void pause_redraw(), add_ball(), setup_fieldpts(),
  1074. Xsetup_fieldpm();
  1075. X
  1076. Xvoid pauseloop()
  1077. X{
  1078. X    short status, res, lev;
  1079. X    short droptimer, stattick;
  1080. X    Bool eventp;
  1081. X    XEvent event, nextevent;
  1082. X    long evmasks;
  1083. X    char key;
  1084. X    KeySym ksym;
  1085. X    struct timeval timeout;
  1086. X
  1087. X    setup_fieldpm();
  1088. X    pause_redraw();
  1089. X    lev = 0;
  1090. X    droptimer=0;
  1091. X
  1092. X    while (1) {
  1093. X    evmasks = (KeyPressMask | ExposureMask | StructureNotifyMask);
  1094. X    eventp = XCheckWindowEvent(dpy, win, evmasks, &event);
  1095. X    if (eventp) switch (event.type) {
  1096. X        case Expose:
  1097. X        eventp = XCheckWindowEvent(dpy, win, evmasks, &nextevent);
  1098. X        while (eventp && nextevent.type == Expose) {
  1099. X            eventp = XCheckWindowEvent(dpy, win, evmasks, &nextevent);
  1100. X        };
  1101. X        if (eventp) {
  1102. X            XPutBackEvent(dpy, &nextevent);
  1103. X        };
  1104. X        pause_redraw();
  1105. X        break;
  1106. X        case KeyPress:
  1107. X        XLookupString(&event, &key, 1, &ksym, NULL);
  1108. X        /*printf("got '%s'\n", XKeysymToString(ksym));*/
  1109. X        switch (ksym) {
  1110. X            case XK_Escape:
  1111. X            case XK_Q:
  1112. X            case XK_S:
  1113. X            case XK_s:
  1114. X            return;
  1115. X            break;
  1116. X        }
  1117. X        break;
  1118. X        case ConfigureNotify:
  1119. X        if (event.xconfigure.width != dispx
  1120. X            || event.xconfigure.height != dispy) {
  1121. X            dispx = event.xconfigure.width;
  1122. X            dispy = event.xconfigure.height;
  1123. X            XFreePixmap(dpy, backpm);
  1124. X            XFreePixmap(dpy, fieldpm);
  1125. X            backpm = XCreatePixmap(dpy, win, dispx,
  1126. X                       dispy, scndepth);   
  1127. X            fieldpm = XCreatePixmap(dpy, win, dispx,
  1128. X                        dispy, scndepth);   
  1129. X            redo_board_globals();
  1130. X            setup_fieldpts();
  1131. X            setup_fieldpm();
  1132. X            pause_redraw();
  1133. X        }
  1134. X        break;
  1135. X    };
  1136. X    timeout.tv_sec = 0;
  1137. X    timeout.tv_usec = 100000;
  1138. X    select(0, 0, 0, 0, &timeout);    
  1139. X    droptimer++;
  1140. X    if (droptimer>=3) {
  1141. X        droptimer=0;
  1142. X        if (lev==fieldz) {
  1143. X        lev=0;
  1144. X        setup_fieldpm();
  1145. X        pause_redraw();
  1146. X        }
  1147. X        else {
  1148. X        int val;
  1149. X        val = random()%fieldx;
  1150. X        add_ball(val, random()%(fieldx-val), lev);
  1151. X        val = random()%fieldx;
  1152. X        add_ball(val, random()%(fieldx-val), lev);
  1153. X        pause_redraw();
  1154. X        lev++;
  1155. X        }
  1156. X    }
  1157. X    }
  1158. X}
  1159. X
  1160. Xvoid pause_redraw()
  1161. X{
  1162. X    XCopyArea(dpy, fieldpm, win, gccopy, 0, 0,
  1163. X          dispx, dispy, 0, 0);
  1164. X}
  1165. END_OF_FILE
  1166. if test 2338 -ne `wc -c <'spheral/deco.c'`; then
  1167.     echo shar: \"'spheral/deco.c'\" unpacked with wrong size!
  1168. fi
  1169. # end of 'spheral/deco.c'
  1170. fi
  1171. if test -f 'spheral/errdi.c' -a "${1}" != "-c" ; then 
  1172.   echo shar: Will not clobber existing file \"'spheral/errdi.c'\"
  1173. else
  1174. echo shar: Extracting \"'spheral/errdi.c'\" \(2269 characters\)
  1175. sed "s/^X//" >'spheral/errdi.c' <<'END_OF_FILE'
  1176. X/* (C) Copyright 1991 Andrew Plotkin. Permission is
  1177. X given to copy and use, as long as this copyright
  1178. X notice is retained. */
  1179. X
  1180. X#include <stdio.h>
  1181. X#include <math.h>    
  1182. X#include <X11/Xlib.h>
  1183. X#include "spheral.h"
  1184. X
  1185. X#define GRIDSIZE (NUMBALLSIZES)
  1186. X#define GREYS (64)
  1187. X
  1188. XPixmap ballpm[NUMBALLSIZES][NUMSHADES];
  1189. Xshort ballpmflag[NUMBALLSIZES][NUMSHADES];
  1190. X
  1191. Xint errdiflag = 0;
  1192. X
  1193. Xextern GC gcblack, gcwhite;
  1194. X
  1195. Xvoid init_ballpmflags()
  1196. X{
  1197. X    register int ix, jx;
  1198. X
  1199. X    for (ix=0; ix<NUMBALLSIZES; ix++) 
  1200. X    for (jx=0; jx<NUMSHADES; jx++) {
  1201. X        ballpmflag[ix][jx] = 0;
  1202. X    }
  1203. X}
  1204. X
  1205. Xvoid create_ballpm(rad, shad)
  1206. Xint rad, shad;
  1207. X{
  1208. X    static short grid[GRIDSIZE*2][GRIDSIZE*2];
  1209. X    static int shades[NUMSHADES] = {9, 20, 31, 44};
  1210. X    static double xl=0.5, yl=0.3, zl=0.81240384;
  1211. X
  1212. X    static XPoint *pts = NULL;
  1213. X    int numpts = 0;
  1214. X
  1215. X    register int ix, iy;
  1216. X    double r;
  1217. X    int ir;
  1218. X    double xd, yd, zd;
  1219. X    int lowshad = shades[shad];
  1220. X    Pixmap pm;
  1221. X
  1222. X    if (ballpmflag[rad][shad]) return;
  1223. X
  1224. X    if (!pts) {
  1225. X    pts = (XPoint *)malloc(sizeof(XPoint) * 52000);
  1226. X    };
  1227. X
  1228. X    pm = XCreatePixmap(dpy, win, rad*2, rad*2, scndepth);
  1229. X
  1230. X    for (ix=GRIDSIZE-rad; ix<GRIDSIZE+rad; ix++) 
  1231. X    for (iy=GRIDSIZE-rad; iy<GRIDSIZE+rad; iy++) {
  1232. X        r = ((double)((ix-GRIDSIZE)*(ix-GRIDSIZE) +
  1233. X        (iy-GRIDSIZE)*(iy-GRIDSIZE))) / (double)(rad*rad);
  1234. X        if (r>1.0) grid[ix][iy] = 0;
  1235. X        else {
  1236. X        xd = (double)(GRIDSIZE-ix)/(double)rad;
  1237. X        yd = (double)(GRIDSIZE-iy)/(double)rad;
  1238. X        zd = sqrt(1.0001-xd*xd-yd*yd);
  1239. X
  1240. X        ir = (int)(15.0 * (xl*xd+yl*yd+zl*zd));
  1241. X        if (ir<0) ir=0;
  1242. X        else if (ir+lowshad >= GREYS) ir=GREYS-lowshad;
  1243. X        grid[ix][iy] = lowshad + ir;
  1244. X        /*grid[ix][iy] = (ir%2)*GREYS;*/
  1245. X        }
  1246. X        grid[ix][iy] += (7*grid[ix-1][iy] + 1*grid[ix-1][iy-1] +
  1247. X        5*grid[ix][iy-1] + 3*grid[ix+1][iy-1]) / 16;
  1248. X        if (grid[ix][iy]>=(GREYS/2)) {
  1249. X        /*XDrawPoint(dpy, pm, gcwhite, rad+ix-GRIDSIZE,
  1250. X         rad+iy-GRIDSIZE);*/
  1251. X        pts[numpts].x = rad+ix-GRIDSIZE;
  1252. X        pts[numpts].y = rad+iy-GRIDSIZE;
  1253. X        numpts++;
  1254. X        grid[ix][iy] -= GREYS;
  1255. X        }
  1256. X        /*else {
  1257. X        XDrawPoint(dpy, pm, gcblack,
  1258. X            rad+ix-GRIDSIZE, rad+iy-GRIDSIZE);
  1259. X        };*/
  1260. X
  1261. X    }
  1262. X
  1263. X    XFillRectangle(dpy, pm, gcblack, 0, 0, rad*2, rad*2);
  1264. X    XDrawPoints(dpy, pm, gcwhite, pts, numpts,
  1265. X        CoordModeOrigin);
  1266. X
  1267. X    ballpm[rad][shad] = pm;
  1268. X    ballpmflag[rad][shad] = 1;
  1269. X}
  1270. END_OF_FILE
  1271. if test 2269 -ne `wc -c <'spheral/errdi.c'`; then
  1272.     echo shar: \"'spheral/errdi.c'\" unpacked with wrong size!
  1273. fi
  1274. # end of 'spheral/errdi.c'
  1275. fi
  1276. if test -f 'spheral/gcgrey.c' -a "${1}" != "-c" ; then 
  1277.   echo shar: Will not clobber existing file \"'spheral/gcgrey.c'\"
  1278. else
  1279. echo shar: Extracting \"'spheral/gcgrey.c'\" \(3773 characters\)
  1280. sed "s/^X//" >'spheral/gcgrey.c' <<'END_OF_FILE'
  1281. X/* (C) Copyright 1991 Andrew Plotkin. Permission is
  1282. X given to copy and use, as long as this copyright
  1283. X notice is retained. */
  1284. X
  1285. X#include <stdio.h>
  1286. X#include <X11/Xlib.h>
  1287. X#include "spheral.h"
  1288. X#include "grey01.bm"
  1289. X#include "grey02.bm"
  1290. X#include "grey03.bm"
  1291. X#include "grey04.bm"
  1292. X#include "grey05.bm"
  1293. X#include "grey06.bm"
  1294. X#include "grey07.bm"
  1295. X#include "grey08.bm"
  1296. X#include "grey09.bm"
  1297. X#include "grey10.bm"
  1298. X#include "grey11.bm"
  1299. X#include "grey12.bm"
  1300. X#include "grey13.bm"
  1301. X#include "grey14.bm"
  1302. X#include "grey15.bm"
  1303. X#include "grey16.bm"
  1304. X
  1305. Xextern GC gcballs[16];
  1306. X
  1307. Xvoid setup_grey()
  1308. X{
  1309. X    Pixmap greypm[16];
  1310. X    register int ix;
  1311. X    XGCValues gcvalues;
  1312. X    Status res;
  1313. X    XColor col, sccol;
  1314. X    static unsigned short colvalues[16][3] = {
  1315. X    {0x6000, 0xA000, 0x6000}, /* green grey */
  1316. X    {0x6000, 0x6000, 0xA000}, /* blue grey */
  1317. X    {0xC000, 0x0000, 0x0000}, /* red */
  1318. X    {0xAA00, 0x8000, 0x0000}, /* orange */
  1319. X    {0xC000, 0xC000, 0x0000}, /* yellow */
  1320. X    {0x0000, 0xC000, 0x0000}, /* green */
  1321. X    {0x0000, 0x0000, 0xFF00}, /* blue */
  1322. X    {0x8000, 0x0000, 0xC000}, /* purple */
  1323. X    {0xFF00, 0x6000, 0x6000}, /* light red */
  1324. X    {0x8000, 0x8000, 0xFF00}, /* light blue */
  1325. X    {0xC000, 0xC000, 0xC000},  /* light grey */
  1326. X    {0x6000, 0xA000, 0x6000}, /* green grey */
  1327. X    {0x6000, 0x6000, 0xA000}, /* blue grey */
  1328. X    {0xC000, 0x0000, 0x0000}, /* red */
  1329. X    {0xAA00, 0x8000, 0x0000}  /* orange */
  1330. X    };
  1331. X
  1332. X    if (monomode) {
  1333. X    greypm[0] = XCreatePixmapFromBitmapData(dpy, win, grey01_bits,
  1334. X    grey01_width, grey01_height, 0, 1, 1);
  1335. X    greypm[1] = XCreatePixmapFromBitmapData(dpy, win, grey02_bits,
  1336. X    grey02_width, grey02_height, 0, 1, 1);
  1337. X    greypm[2] = XCreatePixmapFromBitmapData(dpy, win, grey03_bits,
  1338. X    grey03_width, grey03_height, 0, 1, 1);
  1339. X    greypm[3] = XCreatePixmapFromBitmapData(dpy, win, grey04_bits,
  1340. X    grey04_width, grey04_height, 0, 1, 1);
  1341. X    greypm[4] = XCreatePixmapFromBitmapData(dpy, win, grey05_bits,
  1342. X    grey05_width, grey05_height, 0, 1, 1);
  1343. X    greypm[5] = XCreatePixmapFromBitmapData(dpy, win, grey06_bits,
  1344. X    grey06_width, grey06_height, 0, 1, 1);
  1345. X    greypm[6] = XCreatePixmapFromBitmapData(dpy, win, grey07_bits,
  1346. X    grey07_width, grey07_height, 0, 1, 1);
  1347. X    greypm[7] = XCreatePixmapFromBitmapData(dpy, win, grey08_bits,
  1348. X    grey08_width, grey08_height, 0, 1, 1);
  1349. X    greypm[8] = XCreatePixmapFromBitmapData(dpy, win, grey09_bits,
  1350. X    grey09_width, grey09_height, 0, 1, 1);
  1351. X    greypm[9] = XCreatePixmapFromBitmapData(dpy, win, grey10_bits,
  1352. X    grey10_width, grey10_height, 0, 1, 1);
  1353. X    greypm[10] = XCreatePixmapFromBitmapData(dpy, win, grey11_bits,
  1354. X     grey11_width, grey11_height, 0, 1, 1);
  1355. X    greypm[11] = XCreatePixmapFromBitmapData(dpy, win, grey12_bits,
  1356. X     grey12_width, grey12_height, 0, 1, 1);
  1357. X    greypm[12] = XCreatePixmapFromBitmapData(dpy, win, grey13_bits,
  1358. X     grey13_width, grey13_height, 0, 1, 1);
  1359. X    greypm[13] = XCreatePixmapFromBitmapData(dpy, win, grey14_bits,
  1360. X     grey14_width, grey14_height, 0, 1, 1);
  1361. X    greypm[14] = XCreatePixmapFromBitmapData(dpy, win, grey15_bits,
  1362. X     grey15_width, grey15_height, 0, 1, 1);
  1363. X    greypm[15] = XCreatePixmapFromBitmapData(dpy, win, grey16_bits,
  1364. X     grey16_width, grey16_height, 0, 1, 1);
  1365. X
  1366. X    gcvalues.foreground = WhitePixel(dpy, scn);
  1367. X    gcvalues.background = BlackPixel(dpy, scn);
  1368. X
  1369. X    gcvalues.fill_style = FillOpaqueStippled;
  1370. X    for (ix=0; ix<16; ix++) {
  1371. X        gcvalues.stipple = greypm[ix];
  1372. X        gcballs[ix] = XCreateGC(dpy, win,
  1373. X        GCForeground|GCBackground|GCFillStyle|GCStipple,
  1374. X         &gcvalues);
  1375. X    };
  1376. X    }
  1377. X    else {
  1378. X    for (ix=0; ix<16; ix++) {
  1379. X        col.red = colvalues[ix][0];
  1380. X        col.green = colvalues[ix][1];
  1381. X        col.blue = colvalues[ix][2];
  1382. X        res = XAllocColor(dpy, DefaultColormap(dpy, scn),
  1383. X        &col);
  1384. X        if (!res) {
  1385. X        fprintf(stderr, "spatial: unable to allocate colors\n");
  1386. X        exit(-1);
  1387. X        }
  1388. X        gcvalues.foreground = col.pixel;
  1389. X        gcballs[ix] = XCreateGC(dpy, win, GCForeground,
  1390. X        &gcvalues);
  1391. X    }
  1392. X    }
  1393. X}
  1394. END_OF_FILE
  1395. if test 3773 -ne `wc -c <'spheral/gcgrey.c'`; then
  1396.     echo shar: \"'spheral/gcgrey.c'\" unpacked with wrong size!
  1397. fi
  1398. # end of 'spheral/gcgrey.c'
  1399. fi
  1400. if test -f 'spheral/grey01.bm' -a "${1}" != "-c" ; then 
  1401.   echo shar: Will not clobber existing file \"'spheral/grey01.bm'\"
  1402. else
  1403. echo shar: Extracting \"'spheral/grey01.bm'\" \(243 characters\)
  1404. sed "s/^X//" >'spheral/grey01.bm' <<'END_OF_FILE'
  1405. X#define grey01_width 16
  1406. X#define grey01_height 16
  1407. Xstatic char grey01_bits[] = {
  1408. X0xff,0xff,0xfd,0xfd,0xff,0xff,0xff,0xff,0xff,0xff,0xdf,0xdf,
  1409. X0xff,0xff,0xff,0xff,0xff,0xff,0xfd,0xfd,0xff,0xff,0xff,0xff,
  1410. X0xff,0xff,0xdf,0xdf,0xff,0xff,0xff,0xff};
  1411. END_OF_FILE
  1412. if test 243 -ne `wc -c <'spheral/grey01.bm'`; then
  1413.     echo shar: \"'spheral/grey01.bm'\" unpacked with wrong size!
  1414. fi
  1415. # end of 'spheral/grey01.bm'
  1416. fi
  1417. if test -f 'spheral/grey02.bm' -a "${1}" != "-c" ; then 
  1418.   echo shar: Will not clobber existing file \"'spheral/grey02.bm'\"
  1419. else
  1420. echo shar: Extracting \"'spheral/grey02.bm'\" \(243 characters\)
  1421. sed "s/^X//" >'spheral/grey02.bm' <<'END_OF_FILE'
  1422. X#define grey02_width 16
  1423. X#define grey02_height 16
  1424. Xstatic char grey02_bits[] = {
  1425. X0xff,0xff,0xdf,0xdf,0xff,0xff,0xfd,0xfd,0xff,0xff,0xdf,0xdf,
  1426. X0xff,0xff,0xfd,0xfd,0xff,0xff,0xdf,0xdf,0xff,0xff,0xfd,0xfd,
  1427. X0xff,0xff,0xdf,0xdf,0xff,0xff,0xfd,0xfd};
  1428. END_OF_FILE
  1429. if test 243 -ne `wc -c <'spheral/grey02.bm'`; then
  1430.     echo shar: \"'spheral/grey02.bm'\" unpacked with wrong size!
  1431. fi
  1432. # end of 'spheral/grey02.bm'
  1433. fi
  1434. if test -f 'spheral/grey03.bm' -a "${1}" != "-c" ; then 
  1435.   echo shar: Will not clobber existing file \"'spheral/grey03.bm'\"
  1436. else
  1437. echo shar: Extracting \"'spheral/grey03.bm'\" \(243 characters\)
  1438. sed "s/^X//" >'spheral/grey03.bm' <<'END_OF_FILE'
  1439. X#define grey03_width 16
  1440. X#define grey03_height 16
  1441. Xstatic char grey03_bits[] = {
  1442. X0xff,0xff,0xdd,0xdd,0xff,0xff,0xff,0xff,0xff,0xff,0xdd,0xdd,
  1443. X0xff,0xff,0xff,0xff,0xff,0xff,0xdd,0xdd,0xff,0xff,0xff,0xff,
  1444. X0xff,0xff,0xdd,0xdd,0xff,0xff,0xff,0xff};
  1445. END_OF_FILE
  1446. if test 243 -ne `wc -c <'spheral/grey03.bm'`; then
  1447.     echo shar: \"'spheral/grey03.bm'\" unpacked with wrong size!
  1448. fi
  1449. # end of 'spheral/grey03.bm'
  1450. fi
  1451. if test -f 'spheral/grey04.bm' -a "${1}" != "-c" ; then 
  1452.   echo shar: Will not clobber existing file \"'spheral/grey04.bm'\"
  1453. else
  1454. echo shar: Extracting \"'spheral/grey04.bm'\" \(243 characters\)
  1455. sed "s/^X//" >'spheral/grey04.bm' <<'END_OF_FILE'
  1456. X#define grey04_width 16
  1457. X#define grey04_height 16
  1458. Xstatic char grey04_bits[] = {
  1459. X0xee,0xee,0xff,0xff,0xbb,0xbb,0xff,0xff,0xee,0xee,0xff,0xff,
  1460. X0xbb,0xbb,0xff,0xff,0xee,0xee,0xff,0xff,0xbb,0xbb,0xff,0xff,
  1461. X0xee,0xee,0xff,0xff,0xbb,0xbb,0xff,0xff};
  1462. END_OF_FILE
  1463. if test 243 -ne `wc -c <'spheral/grey04.bm'`; then
  1464.     echo shar: \"'spheral/grey04.bm'\" unpacked with wrong size!
  1465. fi
  1466. # end of 'spheral/grey04.bm'
  1467. fi
  1468. if test -f 'spheral/grey05.bm' -a "${1}" != "-c" ; then 
  1469.   echo shar: Will not clobber existing file \"'spheral/grey05.bm'\"
  1470. else
  1471. echo shar: Extracting \"'spheral/grey05.bm'\" \(243 characters\)
  1472. sed "s/^X//" >'spheral/grey05.bm' <<'END_OF_FILE'
  1473. X#define grey05_width 16
  1474. X#define grey05_height 16
  1475. Xstatic char grey05_bits[] = {
  1476. X0xff,0xff,0x55,0x55,0xff,0xff,0xdd,0xdd,0xff,0xff,0x55,0x55,
  1477. X0xff,0xff,0xdd,0xdd,0xff,0xff,0x55,0x55,0xff,0xff,0xdd,0xdd,
  1478. X0xff,0xff,0x55,0x55,0xff,0xff,0xdd,0xdd};
  1479. END_OF_FILE
  1480. if test 243 -ne `wc -c <'spheral/grey05.bm'`; then
  1481.     echo shar: \"'spheral/grey05.bm'\" unpacked with wrong size!
  1482. fi
  1483. # end of 'spheral/grey05.bm'
  1484. fi
  1485. if test -f 'spheral/grey06.bm' -a "${1}" != "-c" ; then 
  1486.   echo shar: Will not clobber existing file \"'spheral/grey06.bm'\"
  1487. else
  1488. echo shar: Extracting \"'spheral/grey06.bm'\" \(243 characters\)
  1489. sed "s/^X//" >'spheral/grey06.bm' <<'END_OF_FILE'
  1490. X#define grey06_width 16
  1491. X#define grey06_height 16
  1492. Xstatic char grey06_bits[] = {
  1493. X0xff,0xff,0x55,0x55,0xff,0xff,0xbb,0xbb,0xff,0xff,0x55,0x55,
  1494. X0xff,0xff,0xee,0xee,0xff,0xff,0x55,0x55,0xff,0xff,0xbb,0xbb,
  1495. X0xff,0xff,0x55,0x55,0xff,0xff,0xee,0xee};
  1496. END_OF_FILE
  1497. if test 243 -ne `wc -c <'spheral/grey06.bm'`; then
  1498.     echo shar: \"'spheral/grey06.bm'\" unpacked with wrong size!
  1499. fi
  1500. # end of 'spheral/grey06.bm'
  1501. fi
  1502. if test -f 'spheral/grey07.bm' -a "${1}" != "-c" ; then 
  1503.   echo shar: Will not clobber existing file \"'spheral/grey07.bm'\"
  1504. else
  1505. echo shar: Extracting \"'spheral/grey07.bm'\" \(243 characters\)
  1506. sed "s/^X//" >'spheral/grey07.bm' <<'END_OF_FILE'
  1507. X#define grey07_width 16
  1508. X#define grey07_height 16
  1509. Xstatic char grey07_bits[] = {
  1510. X0xff,0xff,0x55,0x55,0xff,0xff,0x55,0x55,0xff,0xff,0x55,0x55,
  1511. X0xff,0xff,0x55,0x55,0xff,0xff,0x55,0x55,0xff,0xff,0x55,0x55,
  1512. X0xff,0xff,0x55,0x55,0xff,0xff,0x55,0x55};
  1513. END_OF_FILE
  1514. if test 243 -ne `wc -c <'spheral/grey07.bm'`; then
  1515.     echo shar: \"'spheral/grey07.bm'\" unpacked with wrong size!
  1516. fi
  1517. # end of 'spheral/grey07.bm'
  1518. fi
  1519. if test -f 'spheral/grey08.bm' -a "${1}" != "-c" ; then 
  1520.   echo shar: Will not clobber existing file \"'spheral/grey08.bm'\"
  1521. else
  1522. echo shar: Extracting \"'spheral/grey08.bm'\" \(243 characters\)
  1523. sed "s/^X//" >'spheral/grey08.bm' <<'END_OF_FILE'
  1524. X#define grey08_width 16
  1525. X#define grey08_height 16
  1526. Xstatic char grey08_bits[] = {
  1527. X0xdd,0xdd,0x77,0x77,0xdd,0xdd,0x77,0x77,0xdd,0xdd,0x77,0x77,
  1528. X0xdd,0xdd,0x77,0x77,0xdd,0xdd,0x77,0x77,0xdd,0xdd,0x77,0x77,
  1529. X0xdd,0xdd,0x77,0x77,0xdd,0xdd,0x77,0x77};
  1530. END_OF_FILE
  1531. if test 243 -ne `wc -c <'spheral/grey08.bm'`; then
  1532.     echo shar: \"'spheral/grey08.bm'\" unpacked with wrong size!
  1533. fi
  1534. # end of 'spheral/grey08.bm'
  1535. fi
  1536. if test -f 'spheral/grey09.bm' -a "${1}" != "-c" ; then 
  1537.   echo shar: Will not clobber existing file \"'spheral/grey09.bm'\"
  1538. else
  1539. echo shar: Extracting \"'spheral/grey09.bm'\" \(243 characters\)
  1540. sed "s/^X//" >'spheral/grey09.bm' <<'END_OF_FILE'
  1541. X#define grey09_width 16
  1542. X#define grey09_height 16
  1543. Xstatic char grey09_bits[] = {
  1544. X0xff,0xff,0x55,0x55,0xfb,0xfb,0x55,0x55,0xff,0xff,0x55,0x55,
  1545. X0xbf,0xbf,0x55,0x55,0xff,0xff,0x55,0x55,0xfb,0xfb,0x55,0x55,
  1546. X0xff,0xff,0x55,0x55,0xbf,0xbf,0x55,0x55};
  1547. END_OF_FILE
  1548. if test 243 -ne `wc -c <'spheral/grey09.bm'`; then
  1549.     echo shar: \"'spheral/grey09.bm'\" unpacked with wrong size!
  1550. fi
  1551. # end of 'spheral/grey09.bm'
  1552. fi
  1553. if test -f 'spheral/grey10.bm' -a "${1}" != "-c" ; then 
  1554.   echo shar: Will not clobber existing file \"'spheral/grey10.bm'\"
  1555. else
  1556. echo shar: Extracting \"'spheral/grey10.bm'\" \(243 characters\)
  1557. sed "s/^X//" >'spheral/grey10.bm' <<'END_OF_FILE'
  1558. X#define grey10_width 16
  1559. X#define grey10_height 16
  1560. Xstatic char grey10_bits[] = {
  1561. X0xee,0xee,0x55,0x55,0xff,0xff,0x55,0x55,0xee,0xee,0x55,0x55,
  1562. X0xff,0xff,0x55,0x55,0xee,0xee,0x55,0x55,0xff,0xff,0x55,0x55,
  1563. X0xee,0xee,0x55,0x55,0xff,0xff,0x55,0x55};
  1564. END_OF_FILE
  1565. if test 243 -ne `wc -c <'spheral/grey10.bm'`; then
  1566.     echo shar: \"'spheral/grey10.bm'\" unpacked with wrong size!
  1567. fi
  1568. # end of 'spheral/grey10.bm'
  1569. fi
  1570. if test -f 'spheral/grey11.bm' -a "${1}" != "-c" ; then 
  1571.   echo shar: Will not clobber existing file \"'spheral/grey11.bm'\"
  1572. else
  1573. echo shar: Extracting \"'spheral/grey11.bm'\" \(243 characters\)
  1574. sed "s/^X//" >'spheral/grey11.bm' <<'END_OF_FILE'
  1575. X#define grey11_width 16
  1576. X#define grey11_height 16
  1577. Xstatic char grey11_bits[] = {
  1578. X0xee,0xee,0x55,0x55,0xfb,0xfb,0x55,0x55,0xee,0xee,0x55,0x55,
  1579. X0xbf,0xbf,0x55,0x55,0xee,0xee,0x55,0x55,0xfb,0xfb,0x55,0x55,
  1580. X0xee,0xee,0x55,0x55,0xbf,0xbf,0x55,0x55};
  1581. END_OF_FILE
  1582. if test 243 -ne `wc -c <'spheral/grey11.bm'`; then
  1583.     echo shar: \"'spheral/grey11.bm'\" unpacked with wrong size!
  1584. fi
  1585. # end of 'spheral/grey11.bm'
  1586. fi
  1587. if test -f 'spheral/grey12.bm' -a "${1}" != "-c" ; then 
  1588.   echo shar: Will not clobber existing file \"'spheral/grey12.bm'\"
  1589. else
  1590. echo shar: Extracting \"'spheral/grey12.bm'\" \(243 characters\)
  1591. sed "s/^X//" >'spheral/grey12.bm' <<'END_OF_FILE'
  1592. X#define grey12_width 16
  1593. X#define grey12_height 16
  1594. Xstatic char grey12_bits[] = {
  1595. X0x55,0x55,0xee,0xee,0x55,0x55,0xbb,0xbb,0x55,0x55,0xee,0xee,
  1596. X0x55,0x55,0xbb,0xbb,0x55,0x55,0xee,0xee,0x55,0x55,0xbb,0xbb,
  1597. X0x55,0x55,0xee,0xee,0x55,0x55,0xbb,0xbb};
  1598. END_OF_FILE
  1599. if test 243 -ne `wc -c <'spheral/grey12.bm'`; then
  1600.     echo shar: \"'spheral/grey12.bm'\" unpacked with wrong size!
  1601. fi
  1602. # end of 'spheral/grey12.bm'
  1603. fi
  1604. if test -f 'spheral/grey13.bm' -a "${1}" != "-c" ; then 
  1605.   echo shar: Will not clobber existing file \"'spheral/grey13.bm'\"
  1606. else
  1607. echo shar: Extracting \"'spheral/grey13.bm'\" \(243 characters\)
  1608. sed "s/^X//" >'spheral/grey13.bm' <<'END_OF_FILE'
  1609. X#define grey13_width 16
  1610. X#define grey13_height 16
  1611. Xstatic char grey13_bits[] = {
  1612. X0x55,0x55,0xee,0xee,0x55,0x55,0xba,0xba,0x55,0x55,0xee,0xee,
  1613. X0x55,0x55,0xab,0xab,0x55,0x55,0xee,0xee,0x55,0x55,0xba,0xba,
  1614. X0x55,0x55,0xee,0xee,0x55,0x55,0xab,0xab};
  1615. END_OF_FILE
  1616. if test 243 -ne `wc -c <'spheral/grey13.bm'`; then
  1617.     echo shar: \"'spheral/grey13.bm'\" unpacked with wrong size!
  1618. fi
  1619. # end of 'spheral/grey13.bm'
  1620. fi
  1621. if test -f 'spheral/grey14.bm' -a "${1}" != "-c" ; then 
  1622.   echo shar: Will not clobber existing file \"'spheral/grey14.bm'\"
  1623. else
  1624. echo shar: Extracting \"'spheral/grey14.bm'\" \(243 characters\)
  1625. sed "s/^X//" >'spheral/grey14.bm' <<'END_OF_FILE'
  1626. X#define grey14_width 16
  1627. X#define grey14_height 16
  1628. Xstatic char grey14_bits[] = {
  1629. X0x57,0x57,0xaa,0xaa,0x75,0x75,0xaa,0xaa,0x57,0x57,0xaa,0xaa,
  1630. X0x75,0x75,0xaa,0xaa,0x57,0x57,0xaa,0xaa,0x75,0x75,0xaa,0xaa,
  1631. X0x57,0x57,0xaa,0xaa,0x75,0x75,0xaa,0xaa};
  1632. END_OF_FILE
  1633. if test 243 -ne `wc -c <'spheral/grey14.bm'`; then
  1634.     echo shar: \"'spheral/grey14.bm'\" unpacked with wrong size!
  1635. fi
  1636. # end of 'spheral/grey14.bm'
  1637. fi
  1638. if test -f 'spheral/grey15.bm' -a "${1}" != "-c" ; then 
  1639.   echo shar: Will not clobber existing file \"'spheral/grey15.bm'\"
  1640. else
  1641. echo shar: Extracting \"'spheral/grey15.bm'\" \(243 characters\)
  1642. sed "s/^X//" >'spheral/grey15.bm' <<'END_OF_FILE'
  1643. X#define grey15_width 16
  1644. X#define grey15_height 16
  1645. Xstatic char grey15_bits[] = {
  1646. X0x55,0x55,0xae,0xae,0x55,0x55,0xaa,0xaa,0x55,0x55,0xea,0xea,
  1647. X0x55,0x55,0xaa,0xaa,0x55,0x55,0xae,0xae,0x55,0x55,0xaa,0xaa,
  1648. X0x55,0x55,0xea,0xea,0x55,0x55,0xaa,0xaa};
  1649. END_OF_FILE
  1650. if test 243 -ne `wc -c <'spheral/grey15.bm'`; then
  1651.     echo shar: \"'spheral/grey15.bm'\" unpacked with wrong size!
  1652. fi
  1653. # end of 'spheral/grey15.bm'
  1654. fi
  1655. if test -f 'spheral/grey16.bm' -a "${1}" != "-c" ; then 
  1656.   echo shar: Will not clobber existing file \"'spheral/grey16.bm'\"
  1657. else
  1658. echo shar: Extracting \"'spheral/grey16.bm'\" \(243 characters\)
  1659. sed "s/^X//" >'spheral/grey16.bm' <<'END_OF_FILE'
  1660. X#define grey16_width 16
  1661. X#define grey16_height 16
  1662. Xstatic char grey16_bits[] = {
  1663. X0x55,0x55,0xaa,0xaa,0x55,0x55,0xaa,0xaa,0x55,0x55,0xaa,0xaa,
  1664. X0x55,0x55,0xaa,0xaa,0x55,0x55,0xaa,0xaa,0x55,0x55,0xaa,0xaa,
  1665. X0x55,0x55,0xaa,0xaa,0x55,0x55,0xaa,0xaa};
  1666. END_OF_FILE
  1667. if test 243 -ne `wc -c <'spheral/grey16.bm'`; then
  1668.     echo shar: \"'spheral/grey16.bm'\" unpacked with wrong size!
  1669. fi
  1670. # end of 'spheral/grey16.bm'
  1671. fi
  1672. if test -f 'spheral/spheral.c' -a "${1}" != "-c" ; then 
  1673.   echo shar: Will not clobber existing file \"'spheral/spheral.c'\"
  1674. else
  1675. echo shar: Extracting \"'spheral/spheral.c'\" \(1311 characters\)
  1676. sed "s/^X//" >'spheral/spheral.c' <<'END_OF_FILE'
  1677. X/* (C) Copyright 1991 Andrew Plotkin. Permission is
  1678. X given to copy and use, as long as this copyright
  1679. X notice is retained. */
  1680. X
  1681. X#include <stdio.h>
  1682. X#include <X11/Xlib.h>
  1683. X#include "spheral.h"
  1684. X#include "patchlevel.h"
  1685. X
  1686. X#define INITWINSIZEX (800)
  1687. X#define INITWINSIZEY ((int)(800*ROOTHALF))
  1688. X
  1689. Xint monomode = 0;
  1690. X
  1691. Xextern double focallen;
  1692. Xextern void srandom();
  1693. X
  1694. Xextern void xinit(), loadpieces(), gameloop(),
  1695. Xredo_board_globals();
  1696. Xextern void initintro(), initloop();
  1697. Xextern void init_ballpmflags();
  1698. X
  1699. Xmain(argc, argv)
  1700. Xint argc;
  1701. Xchar *argv[];
  1702. X{
  1703. X    int ix;
  1704. X
  1705. X    srandom(getpid());
  1706. X
  1707. X/*    for (ix=1; ix<argc; ix++) {
  1708. X    if (strcmp(argv[ix], "-m")) {
  1709. X        fprintf(stderr, "usage: spheral [ -m ]\n");
  1710. X        exit(-1);
  1711. X    }
  1712. X    else
  1713. X        monomode = 1;
  1714. X    }*/
  1715. X
  1716. X    monomode = 1; /* I'm terribly sorry; color just does not
  1717. X     work for this game. */
  1718. X
  1719. X    loadpieces(PIECEFILENAME);
  1720. X    fieldx = 6;
  1721. X    fieldz = 12;
  1722. X    fieldoffx = -0.5 * (fieldx-1);
  1723. X    fieldoffy = -0.5 * ROOTHALF * (fieldx-2);
  1724. X    fieldoffz = -4.0-(double)fieldz;
  1725. X    focallen = 1.0;
  1726. X    dispx = INITWINSIZEX;
  1727. X    dispy = INITWINSIZEY;
  1728. X    redo_board_globals();
  1729. X    xinit();
  1730. X    init_ballpmflags();
  1731. X    get_names();
  1732. X    load_hscores(0);
  1733. X    while (1) {
  1734. X    initintro();
  1735. X    introloop();
  1736. X    initgame();
  1737. X    gameloop();
  1738. X    if (checkmod_scores()) {
  1739. X        load_hscores(1);
  1740. X    }
  1741. X    }
  1742. X}
  1743. END_OF_FILE
  1744. if test 1311 -ne `wc -c <'spheral/spheral.c'`; then
  1745.     echo shar: \"'spheral/spheral.c'\" unpacked with wrong size!
  1746. fi
  1747. # end of 'spheral/spheral.c'
  1748. fi
  1749. if test -f 'spheral/spheral.h' -a "${1}" != "-c" ; then 
  1750.   echo shar: Will not clobber existing file \"'spheral/spheral.h'\"
  1751. else
  1752. echo shar: Extracting \"'spheral/spheral.h'\" \(2178 characters\)
  1753. sed "s/^X//" >'spheral/spheral.h' <<'END_OF_FILE'
  1754. X/* (C) Copyright 1991 Andrew Plotkin. Permission is
  1755. X given to copy and use, as long as this copyright
  1756. X notice is retained. */
  1757. X
  1758. X
  1759. X#define    PI        (3.14159265)
  1760. X#define    ROOTHALF    (0.70710678)
  1761. X
  1762. X#define MAXFIELDX (10)
  1763. X#define MAXFIELDZ (15)
  1764. X
  1765. X#define MAXBALLS (6)
  1766. X#define MAXPIECES (30)
  1767. X
  1768. X#define NUMGAMERS (20)
  1769. X
  1770. X#define NUMSHADES (4)
  1771. X#define NUMBALLSIZES (128)
  1772. X
  1773. X#define    OUT_COLLIDE    (-1)
  1774. X#define    OUT_NOT        (0)
  1775. X#define    OUT_UP        (1)
  1776. X#define    OUT_DOWN    (2)
  1777. X#define    OUT_SOUTH    (4)
  1778. X#define    OUT_NORTHWEST    (8)
  1779. X#define    OUT_NORTHEAST    (16)
  1780. X
  1781. X#define F_OFF (0)
  1782. X#define F_ON (1)
  1783. X#define F_TEMP (2)
  1784. X
  1785. Xtypedef struct _point {
  1786. X    double x, y, z, w;
  1787. X} point;
  1788. X
  1789. Xtypedef double matrix[4][4];
  1790. X
  1791. Xtypedef XPoint fieldplist[MAXFIELDX][MAXFIELDX][MAXFIELDZ];
  1792. Xtypedef int fieldrlist[MAXFIELDX][MAXFIELDX][MAXFIELDZ];
  1793. X
  1794. Xtypedef struct _piecelist {
  1795. X    short numballs;
  1796. X    point points[MAXBALLS];
  1797. X} piecelist;
  1798. X
  1799. Xtypedef struct _piecesum {
  1800. X    short numballs;
  1801. X    XPoint p[MAXBALLS];
  1802. X    int rad[MAXBALLS];
  1803. X    double scalex, scaley;
  1804. X} piecesum;
  1805. X
  1806. Xtypedef struct _gamer {
  1807. X    char userid[16];
  1808. X    char name[16];
  1809. X    long score;
  1810. X    char scoret[16];
  1811. X} gamer;
  1812. X
  1813. Xextern gamer hscores[NUMGAMERS];
  1814. X
  1815. Xextern piecelist pieces[MAXPIECES];
  1816. X
  1817. Xextern unsigned char field[MAXFIELDX][MAXFIELDX][MAXFIELDZ];
  1818. Xextern fieldplist fieldpts;
  1819. Xextern fieldrlist fieldrads;
  1820. X
  1821. Xextern short fieldx, fieldz;
  1822. Xextern double fieldoffx, fieldoffy, fieldoffz;
  1823. X/*extern int meterx, meterx2, metery, metersize,
  1824. X meterlev, meteroldlev, meter_f_b, meter_b_d; */
  1825. X
  1826. Xextern short numpieces;
  1827. Xextern short curpiece;
  1828. X
  1829. Xextern Display *dpy;
  1830. Xextern Window win;
  1831. Xextern int scn;
  1832. Xextern int scndepth;
  1833. Xextern int monomode;
  1834. X
  1835. Xextern int dispx, dispy; /* size of window */
  1836. Xextern Pixmap backpm; /* size of window */
  1837. Xextern Pixmap fieldpm; /* size of window */
  1838. Xextern int sshapx1, sshapx2, sshapy1, sshapy2;
  1839. X/* size of rectangle that contains shape */
  1840. Xextern int bbackx1, bbackx2, bbacky1, bbacky2;
  1841. X/* coords of rectangle of backpm that is usable */
  1842. Xextern int ddispx1, ddispx2, ddispy1, ddispy2;
  1843. X/* coords of rectangle of display that is different
  1844. X from fieldpm */
  1845. Xextern long score, dropticks;
  1846. Xextern double boardscale;
  1847. Xextern int halfboardx, halfboardy;
  1848. X
  1849. Xextern long random();
  1850. END_OF_FILE
  1851. if test 2178 -ne `wc -c <'spheral/spheral.h'`; then
  1852.     echo shar: \"'spheral/spheral.h'\" unpacked with wrong size!
  1853. fi
  1854. # end of 'spheral/spheral.h'
  1855. fi
  1856. if test -f 'spheral/spheral.shp' -a "${1}" != "-c" ; then 
  1857.   echo shar: Will not clobber existing file \"'spheral/spheral.shp'\"
  1858. else
  1859. echo shar: Extracting \"'spheral/spheral.shp'\" \(973 characters\)
  1860. sed "s/^X//" >'spheral/spheral.shp' <<'END_OF_FILE'
  1861. X22
  1862. X
  1863. X4
  1864. X-.5, 0, .5
  1865. X.5, 0, .5
  1866. X0, .7071, 0
  1867. X0, .7071, 1
  1868. X
  1869. X4
  1870. X-.5, 0, .5
  1871. X.5, 0, .5
  1872. X0, .7071, 0
  1873. X-1, .7071, 0
  1874. X
  1875. X4
  1876. X-.5, 0, .5
  1877. X.5, 0, .5
  1878. X0, .7071, 0
  1879. X-1.5, 0, .5
  1880. X
  1881. X4
  1882. X-.5, 0, .5
  1883. X.5, 0, .5
  1884. X-1.5, 0, .5
  1885. X1, .7071, 0
  1886. X
  1887. X4
  1888. X-.5, 0, .5
  1889. X.5, 0, .5
  1890. X-1.5, 0, .5
  1891. X1.5, 0, .5
  1892. X
  1893. X4
  1894. X-.5, 0, .5
  1895. X.5, 0, .5
  1896. X-1, .7071, 0
  1897. X1, .7071, 0
  1898. X
  1899. X4
  1900. X-.5, 0, .5
  1901. X.5, 0, .5
  1902. X0, .7071, 0
  1903. X0, -.7071, 0
  1904. X
  1905. X4
  1906. X-.5, 0, .5
  1907. X.5, 0, .5
  1908. X-1, .7071, 0
  1909. X0, .7071, 1
  1910. X
  1911. X4
  1912. X-.5, 0, .5
  1913. X.5, 0, .5
  1914. X-1.5, 0, .5
  1915. X1, .7071, 0
  1916. X
  1917. X4
  1918. X-.5, 0, .5
  1919. X.5, 0, .5
  1920. X-1.5, 0, .5
  1921. X.5, 0, -.5
  1922. X
  1923. X4
  1924. X-.5, 0, .5
  1925. X.5, 0, .5
  1926. X-1.5, 0, .5
  1927. X-.5, 0, -.5
  1928. X
  1929. X4
  1930. X-.5, 0, .5
  1931. X.5, 0, .5
  1932. X1, .7071, 0
  1933. X1, -.7071, 0
  1934. X
  1935. X4
  1936. X-.5, 0, .5
  1937. X.5, 0, .5
  1938. X1, .7071, 0
  1939. X-1, -.7071, 1
  1940. X
  1941. X4
  1942. X-.5, 0, .5
  1943. X.5, 0, .5
  1944. X1, .7071, 0
  1945. X-1, .7071, 1
  1946. X
  1947. X4
  1948. X-.5, 0, .5
  1949. X.5, 0, .5
  1950. X-1, .7071, 0
  1951. X1, -.7071, 0
  1952. X
  1953. X4
  1954. X-.5, 0, .5
  1955. X-.5, 0, -.5
  1956. X.5, 0, -.5
  1957. X.5, 0, .5
  1958. X
  1959. X4
  1960. X-.5, 0, .5
  1961. X-.5, 0, -.5
  1962. X.5, 0, -.5
  1963. X1, .7071, 0
  1964. X
  1965. X
  1966. X1
  1967. X.5, 0, .5
  1968. X
  1969. X3
  1970. X-.5, 0, .5
  1971. X.5, 0, .5
  1972. X.5, 0, -.5
  1973. X
  1974. X3
  1975. X-.5, 0, .5
  1976. X.5, 0, .5
  1977. X0, .7071, 0
  1978. X
  1979. X3
  1980. X-.5, 0, .5
  1981. X.5, 0, .5
  1982. X1, .7071, 0
  1983. X
  1984. X2
  1985. X-.5, 0, .5
  1986. X.5, 0, .5
  1987. X
  1988. END_OF_FILE
  1989. if test 973 -ne `wc -c <'spheral/spheral.shp'`; then
  1990.     echo shar: \"'spheral/spheral.shp'\" unpacked with wrong size!
  1991. fi
  1992. # end of 'spheral/spheral.shp'
  1993. fi
  1994. if test -f 'spheral/test.c' -a "${1}" != "-c" ; then 
  1995.   echo shar: Will not clobber existing file \"'spheral/test.c'\"
  1996. else
  1997. echo shar: Extracting \"'spheral/test.c'\" \(3814 characters\)
  1998. sed "s/^X//" >'spheral/test.c' <<'END_OF_FILE'
  1999. X#include <stdio.h>
  2000. X#include <math.h>
  2001. X#include <X11/Xlib.h>
  2002. X
  2003. X#define GRIDSIZE (128)
  2004. X#define GREYS (64)
  2005. X
  2006. XDisplay *dpy;
  2007. XWindow   win;
  2008. XGC       gcwhite, gcblack; 
  2009. XGC gcballs[16];
  2010. Xstatic short grid[GRIDSIZE*2][GRIDSIZE*2];
  2011. X
  2012. Xvoid init()
  2013. X{
  2014. X    int      scn;
  2015. X    XSetWindowAttributes attr;
  2016. X    XGCValues gcvalues;
  2017. X
  2018. X    dpy = XOpenDisplay((char *) NULL);
  2019. X    if ((Display *) NULL == dpy) {
  2020. X    fprintf(stderr, "xbox:  could not open display.\n");
  2021. X    exit(-1);
  2022. X    }
  2023. X
  2024. X    
  2025. X    scn = DefaultScreen(dpy);
  2026. X    win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy),
  2027. X                   200, 200, 500, 500, 1,
  2028. X                   BlackPixel(dpy, scn),
  2029. X                   WhitePixel(dpy, scn));
  2030. X   
  2031. X    attr.event_mask = ButtonPressMask | KeyPressMask | ExposureMask;
  2032. X    XChangeWindowAttributes(dpy, win, CWEventMask, &attr);
  2033. X
  2034. X    XSetWindowBackground(dpy, win, BlackPixel(dpy, scn));
  2035. X
  2036. X    XMapWindow(dpy, win);
  2037. X    
  2038. X    gcvalues.foreground = WhitePixel(dpy, scn);
  2039. X    gcvalues.background = BlackPixel(dpy, scn);
  2040. X    gcwhite = XCreateGC(dpy, win, GCForeground|GCBackground,
  2041. X            &gcvalues);
  2042. X
  2043. X    gcvalues.foreground = BlackPixel(dpy, scn);
  2044. X    gcvalues.background = WhitePixel(dpy, scn);
  2045. X    gcblack = XCreateGC(dpy, win, GCForeground|GCBackground,
  2046. X            &gcvalues);
  2047. X}
  2048. X
  2049. Xvoid disc(x,y,n,rad)
  2050. Xint x,y,n,rad;
  2051. X{
  2052. X    register int ix, iy;
  2053. X    int ir;
  2054. X    double r, theta;
  2055. X    double xn, yn;
  2056. X    double xd, yd, zd;
  2057. X    double xl=0.5, yl=0.3, zl=sqrt(1.0-xl*xl-yl*yl);
  2058. X
  2059. X    printf("shade = %d\n", n);
  2060. X
  2061. X    XFillArc(dpy, win, gcblack, x-rad, y-rad,
  2062. X         rad*2, rad*2, 0, 23040);
  2063. X
  2064. X    bzero(grid, sizeof(short)*GRIDSIZE*2*GRIDSIZE*2);
  2065. X
  2066. X    for (ix=GRIDSIZE-rad; ix<GRIDSIZE+rad; ix++) 
  2067. X    for (iy=GRIDSIZE-rad; iy<GRIDSIZE+rad; iy++) {
  2068. X        r = ((double)((ix-GRIDSIZE)*(ix-GRIDSIZE) +
  2069. X        (iy-GRIDSIZE)*(iy-GRIDSIZE))) / (double)(rad*rad);
  2070. X        if (r>1.0) grid[ix][iy] = 0;
  2071. X        else {
  2072. X        xd = (double)(GRIDSIZE-ix)/(double)rad;
  2073. X        yd = (double)(GRIDSIZE-iy)/(double)rad;
  2074. X        zd = sqrt(1.0-xd*xd-yd*yd);
  2075. X
  2076. X        ir = (int)(11.0 * (xl*xd+yl*yd+zl*zd));
  2077. X        if (ir<0) ir=0;
  2078. X        else if (ir+n >= GREYS) ir=GREYS-n;
  2079. X        grid[ix][iy] = n + ir;
  2080. X        /*grid[ix][iy] = (ir%2)*GREYS;*/
  2081. X        }
  2082. X        grid[ix][iy] += (7*grid[ix-1][iy] + 1*grid[ix-1][iy-1] +
  2083. X        5*grid[ix][iy-1] + 3*grid[ix+1][iy-1]) / 16;
  2084. X        if (grid[ix][iy]>=(GREYS/2)) {
  2085. X        XDrawPoint(dpy, win, gcwhite,
  2086. X            x+ix-GRIDSIZE, y+iy-GRIDSIZE);
  2087. X        grid[ix][iy] -= GREYS;
  2088. X        }
  2089. X        /*else {
  2090. X        XDrawPoint(dpy, win, gcblack,
  2091. X         x+ix-GRIDSIZE, y+iy-GRIDSIZE);
  2092. X        };*/
  2093. X
  2094. X    }
  2095. X}
  2096. X
  2097. Xvoid redraw()
  2098. X{
  2099. X    XClearWindow(dpy, win);
  2100. X}
  2101. X
  2102. Xvoid bye()
  2103. X{
  2104. X    XCloseDisplay(dpy);
  2105. X}
  2106. X
  2107. Xmain()
  2108. X{
  2109. X    Bool   done = False;
  2110. X    XEvent event;
  2111. X    char   c;
  2112. X    int dens = 1;
  2113. X
  2114. X
  2115. X    init();
  2116. X
  2117. X    while (!done) {
  2118. X    XNextEvent(dpy, &event);
  2119. X    switch (event.type) {
  2120. X        case ButtonPress:
  2121. X        printf("button %d at %d %d\n",
  2122. X               event.xbutton.button,
  2123. X               event.xbutton.x, event.xbutton.y);
  2124. X        switch (event.xbutton.button) {
  2125. X            case 1:
  2126. X            disc(event.xbutton.x, event.xbutton.y,
  2127. X                 dens, 30);
  2128. X            break;
  2129. X            case 2:
  2130. X            disc(event.xbutton.x, event.xbutton.y,
  2131. X                 dens, 50);
  2132. X            break;
  2133. X            case 3:
  2134. X            disc(event.xbutton.x, event.xbutton.y,
  2135. X                 dens, 100);
  2136. X            break;
  2137. X            default:
  2138. X            break;
  2139. X        }
  2140. X        break;
  2141. X        case KeyPress:
  2142. X        if (1 == XLookupString(&event, &c, 1, NULL, NULL)) {
  2143. X            printf("key %c\n", c);
  2144. X            switch (c) {
  2145. X            case 'q':
  2146. X                done = True;
  2147. X                break;
  2148. X            case '1':
  2149. X                dens = 9;
  2150. X                break;
  2151. X            case '2':
  2152. X                dens = 20;
  2153. X                break;
  2154. X            case '3':
  2155. X                dens = 31;
  2156. X                break;
  2157. X            case '4':
  2158. X                dens = 44;
  2159. X                break;
  2160. X            case '-':
  2161. X                dens--;
  2162. X                break;
  2163. X            case '+':
  2164. X            case '=':
  2165. X                dens++;
  2166. X                break;                
  2167. X            case 'r':
  2168. X            case 'c':
  2169. X                redraw();
  2170. X                break;
  2171. X            default:
  2172. X                break;
  2173. X            }
  2174. X        }
  2175. X        break;
  2176. X        case Expose:
  2177. X        printf("expose\n");
  2178. X        redraw();
  2179. X        default:
  2180. X        break;
  2181. X    }
  2182. X    }
  2183. X
  2184. X    bye();
  2185. X}
  2186. END_OF_FILE
  2187. if test 3814 -ne `wc -c <'spheral/test.c'`; then
  2188.     echo shar: \"'spheral/test.c'\" unpacked with wrong size!
  2189. fi
  2190. # end of 'spheral/test.c'
  2191. fi
  2192. echo shar: End of archive 3 \(of 4\).
  2193. cp /dev/null ark3isdone
  2194. MISSING=""
  2195. for I in 1 2 3 4 ; do
  2196.     if test ! -f ark${I}isdone ; then
  2197.     MISSING="${MISSING} ${I}"
  2198.     fi
  2199. done
  2200. if test "${MISSING}" = "" ; then
  2201.     echo You have unpacked all 4 archives.
  2202.     rm -f ark[1-9]isdone
  2203. else
  2204.     echo You still need to unpack the following archives:
  2205.     echo "        " ${MISSING}
  2206. fi
  2207. ##  End of shell archive.
  2208. exit 0
  2209.