http://ftp.x.org/contrib/applications/xscreensaver-3.07.tar.gz
authorZygo Blaxell <zblaxell@hungrycats.org>
Mon, 2 Mar 2009 05:42:32 +0000 (00:42 -0500)
committerZygo Blaxell <zblaxell@hungrycats.org>
Mon, 2 Mar 2009 05:42:32 +0000 (00:42 -0500)
-rw-r--r-- 1 zblaxell zblaxell 1010995 Jan  3  1999 xscreensaver-3.07.tar.gz
d4bbafc2a1876164b8fb22a1b9cd4bc6ddced877  xscreensaver-3.07.tar.gz

42 files changed:
Makefile.in
README
configure
configure.in
driver/XScreenSaver.ad.in
driver/XScreenSaver_ad.h
driver/remote.c
driver/xscreensaver-command.man
driver/xscreensaver-demo.man
driver/xscreensaver.c
driver/xscreensaver.man
hacks/Makefile.in
hacks/ant.c
hacks/automata.h [new file with mode: 0644]
hacks/compile_axp.com
hacks/compile_decc.com
hacks/crystal.c
hacks/demon.c [new file with mode: 0644]
hacks/flame.c
hacks/flow.c
hacks/glx/Makefile.in
hacks/glx/cage.c
hacks/glx/moebius.c
hacks/glx/morph3d.c
hacks/glx/pipes.c
hacks/glx/rubik.c
hacks/glx/stairs.c
hacks/glx/xpm-ximage.c
hacks/halo.c
hacks/hopalong.c
hacks/loop.c [new file with mode: 0644]
hacks/rd-bomb.c
hacks/sonar.c
hacks/t3d.c [new file with mode: 0644]
hacks/t3d.man [new file with mode: 0644]
hacks/xlockmore.h
setup.com
utils/Makefile.in
utils/version.h
utils/yarandom.h
xscreensaver.lsm
xscreensaver.spec

index b2e77f14880d98f91f00e389f12ec787c166fa22..0c7821b24365da3150a3d93bcda54a88df86a7f1 100644 (file)
@@ -1,4 +1,4 @@
-# Makefile.in --- xscreensaver, Copyright (c) 1997 Jamie Zawinski.
+# Makefile.in --- xscreensaver, Copyright (c) 1999 Jamie Zawinski.
 # the `../configure' script generates `Makefile' from this file.
 
 @SET_MAKE@
@@ -169,6 +169,12 @@ update_spec_version::
        fi ;                                                                \
        rm $$T
 
+rpm::
+       @                                                                   \
+  VERS=`sed -n 's/[^0-9]*\([0-9]\.[0-9][0-9]*\).*/\1/p' utils/version.h` ;  \
+  cp -p xscreensaver-$$VERS.tar.gz /usr/src/redhat/SOURCES/ ;              \
+  rpm -ba xscreensaver.spec
+
 test-tar::
        @                                                                   \
   VERS=`sed -n 's/[^0-9]*\([0-9]\.[0-9][0-9]*\).*/\1/p' utils/version.h` ;  \
@@ -207,10 +213,9 @@ test-tar::
   ( cd BIN/motif ;                                                         \
     CC=cc ;                                                                \
     export CC ;                                                                    \
-    ../../configure --with-motif=/usr/local/motif ;                        \
+    ../../configure --without-xpm --with-motif=/usr/local/motif ;          \
     echo --------------------------------------------------------------- ;  \
-    ( cd utils; gmake ) ;                                                  \
-    ( cd driver; gmake ) ;                                                 \
+    gmake ;                                                                \
     ( cd driver; gmake xscreensaver-demo-Xaw ) ;                           \
     echo --------------------------------------------------------------- ); \
                                                                            \
diff --git a/README b/README
index 94da385a119a0aad2e8541ce96be801968c0a01f..e3183370819289c927de65e53faa4e04be32660d 100644 (file)
--- a/README
+++ b/README
@@ -77,6 +77,24 @@ http://www.jwz.org/xscreensaver/.
 
                               ============
 
+Changes since 3.06:   * Configure tweaks (sometimes -lXmu wasn't getting linked
+                        in properly; check for _Xsetlocale in -lXintl.)
+                      * Portability fixes for sonar.c.
+                      * Fixed a compilation problem when you have GL but don't
+                        have XPM.
+                      * Made configure notice when MesaGL requires -lpthread.
+                      * Made `flame' ignore SIGFPE (not sure if this is the
+                        right fix; it seems only to be needed on FreeBSD.)
+                      * Kludged `rd-bomb' work on visuals that are of depth 24
+                        but that *do not* support pixmaps of depth 32.
+                      * Fixed `halo' to work properly in TrueColor.
+                      * Changed `xscreensaver.spec' to install the hacks in
+                        /usr/X11R6/lib/xscreensaver/ by default, since that's
+                        where recent Red Hat distributions put them.
+                      * Added `t3d' hack.
+                      * Updated versions of `crystal', `hopalong', and `flow'
+                        from xlockmore.
+                      * Imported `demon' and `loop' modes from xlockmore.
 Changes since 3.05:   * Oops, the "default-n" visual descriptor was broken;
                         it was always installing a colormap if the
                         `installColormap' preference was set, meaning that
index 872e34d46c953c179001e920f77f6b7af033c080..aaf89b17e2a8c7673c164df2087d2a56380dcd0b 100755 (executable)
--- a/configure
+++ b/configure
@@ -1912,13 +1912,16 @@ else
   fi
 fi
 
+# canonicalize slashes.
+HACKDIR=`echo "${HACKDIR}" | sed 's@/$@@;s@//*@/@g'`
+
 
 # If we find X, set shell vars x_includes and x_libraries to the
 # paths, otherwise set no_x=yes.
 # Uses ac_ vars as temps to allow command line to override cache and checks.
 # --without-x overrides everything else, but does not touch the cache.
 echo $ac_n "checking for X""... $ac_c" 1>&6
-echo "configure:1933: checking for X" >&5
+echo "configure:1936: checking for X" >&5
 
 # Check whether --with-x or --without-x was given.
 if test "${with_x+set}" = set; then
@@ -1980,12 +1983,12 @@ if test "$ac_x_includes" = NO; then
 
   # First, try using that file with no special directory specified.
 cat > conftest.$ac_ext <<EOF
-#line 1995 "configure"
+#line 1998 "configure"
 #include "confdefs.h"
 #include <$x_direct_test_include>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2000: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2003: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -2054,14 +2057,14 @@ if test "$ac_x_libraries" = NO; then
   ac_save_LIBS="$LIBS"
   LIBS="-l$x_direct_test_library $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2069 "configure"
+#line 2072 "configure"
 #include "confdefs.h"
 
 int main() {
 ${x_direct_test_function}()
 ; return 0; }
 EOF
-if { (eval echo configure:2076: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2079: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   LIBS="$ac_save_LIBS"
 # We can link X programs with no special library path.
@@ -2167,17 +2170,17 @@ else
     case "`(uname -sr) 2>/dev/null`" in
     "SunOS 5"*)
       echo $ac_n "checking whether -R must be followed by a space""... $ac_c" 1>&6
-echo "configure:2182: checking whether -R must be followed by a space" >&5
+echo "configure:2185: checking whether -R must be followed by a space" >&5
       ac_xsave_LIBS="$LIBS"; LIBS="$LIBS -R$x_libraries"
       cat > conftest.$ac_ext <<EOF
-#line 2185 "configure"
+#line 2188 "configure"
 #include "confdefs.h"
 
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:2192: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2195: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   ac_R_nospace=yes
 else
@@ -2193,14 +2196,14 @@ rm -f conftest*
       else
        LIBS="$ac_xsave_LIBS -R $x_libraries"
        cat > conftest.$ac_ext <<EOF
-#line 2208 "configure"
+#line 2211 "configure"
 #include "confdefs.h"
 
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:2215: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2218: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   ac_R_space=yes
 else
@@ -2232,7 +2235,7 @@ rm -f conftest*
     # libraries were built with DECnet support.  And karl@cs.umb.edu says
     # the Alpha needs dnet_stub (dnet does not exist).
     echo $ac_n "checking for dnet_ntoa in -ldnet""... $ac_c" 1>&6
-echo "configure:2247: checking for dnet_ntoa in -ldnet" >&5
+echo "configure:2250: checking for dnet_ntoa in -ldnet" >&5
 ac_lib_var=`echo dnet'_'dnet_ntoa | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2240,7 +2243,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ldnet  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2255 "configure"
+#line 2258 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -2251,7 +2254,7 @@ int main() {
 dnet_ntoa()
 ; return 0; }
 EOF
-if { (eval echo configure:2266: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2269: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2273,7 +2276,7 @@ fi
 
     if test $ac_cv_lib_dnet_dnet_ntoa = no; then
       echo $ac_n "checking for dnet_ntoa in -ldnet_stub""... $ac_c" 1>&6
-echo "configure:2288: checking for dnet_ntoa in -ldnet_stub" >&5
+echo "configure:2291: checking for dnet_ntoa in -ldnet_stub" >&5
 ac_lib_var=`echo dnet_stub'_'dnet_ntoa | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2281,7 +2284,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ldnet_stub  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2296 "configure"
+#line 2299 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -2292,7 +2295,7 @@ int main() {
 dnet_ntoa()
 ; return 0; }
 EOF
-if { (eval echo configure:2307: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2310: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2321,12 +2324,12 @@ fi
     # The nsl library prevents programs from opening the X display
     # on Irix 5.2, according to dickey@clark.net.
     echo $ac_n "checking for gethostbyname""... $ac_c" 1>&6
-echo "configure:2336: checking for gethostbyname" >&5
+echo "configure:2339: checking for gethostbyname" >&5
 if eval "test \"`echo '$''{'ac_cv_func_gethostbyname'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2341 "configure"
+#line 2344 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char gethostbyname(); below.  */
@@ -2349,7 +2352,7 @@ gethostbyname();
 
 ; return 0; }
 EOF
-if { (eval echo configure:2364: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2367: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_gethostbyname=yes"
 else
@@ -2370,7 +2373,7 @@ fi
 
     if test $ac_cv_func_gethostbyname = no; then
       echo $ac_n "checking for gethostbyname in -lnsl""... $ac_c" 1>&6
-echo "configure:2385: checking for gethostbyname in -lnsl" >&5
+echo "configure:2388: checking for gethostbyname in -lnsl" >&5
 ac_lib_var=`echo nsl'_'gethostbyname | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2378,7 +2381,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lnsl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2393 "configure"
+#line 2396 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -2389,7 +2392,7 @@ int main() {
 gethostbyname()
 ; return 0; }
 EOF
-if { (eval echo configure:2404: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2407: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2419,12 +2422,12 @@ fi
     # -lsocket must be given before -lnsl if both are needed.
     # We assume that if connect needs -lnsl, so does gethostbyname.
     echo $ac_n "checking for connect""... $ac_c" 1>&6
-echo "configure:2434: checking for connect" >&5
+echo "configure:2437: checking for connect" >&5
 if eval "test \"`echo '$''{'ac_cv_func_connect'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2439 "configure"
+#line 2442 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char connect(); below.  */
@@ -2447,7 +2450,7 @@ connect();
 
 ; return 0; }
 EOF
-if { (eval echo configure:2462: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2465: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_connect=yes"
 else
@@ -2468,7 +2471,7 @@ fi
 
     if test $ac_cv_func_connect = no; then
       echo $ac_n "checking for connect in -lsocket""... $ac_c" 1>&6
-echo "configure:2483: checking for connect in -lsocket" >&5
+echo "configure:2486: checking for connect in -lsocket" >&5
 ac_lib_var=`echo socket'_'connect | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2476,7 +2479,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket $X_EXTRA_LIBS $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2491 "configure"
+#line 2494 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -2487,7 +2490,7 @@ int main() {
 connect()
 ; return 0; }
 EOF
-if { (eval echo configure:2502: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2505: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2511,12 +2514,12 @@ fi
 
     # gomez@mi.uni-erlangen.de says -lposix is necessary on A/UX.
     echo $ac_n "checking for remove""... $ac_c" 1>&6
-echo "configure:2526: checking for remove" >&5
+echo "configure:2529: checking for remove" >&5
 if eval "test \"`echo '$''{'ac_cv_func_remove'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2531 "configure"
+#line 2534 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char remove(); below.  */
@@ -2539,7 +2542,7 @@ remove();
 
 ; return 0; }
 EOF
-if { (eval echo configure:2554: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2557: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_remove=yes"
 else
@@ -2560,7 +2563,7 @@ fi
 
     if test $ac_cv_func_remove = no; then
       echo $ac_n "checking for remove in -lposix""... $ac_c" 1>&6
-echo "configure:2575: checking for remove in -lposix" >&5
+echo "configure:2578: checking for remove in -lposix" >&5
 ac_lib_var=`echo posix'_'remove | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2568,7 +2571,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lposix  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2583 "configure"
+#line 2586 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -2579,7 +2582,7 @@ int main() {
 remove()
 ; return 0; }
 EOF
-if { (eval echo configure:2594: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2597: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2603,12 +2606,12 @@ fi
 
     # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay.
     echo $ac_n "checking for shmat""... $ac_c" 1>&6
-echo "configure:2618: checking for shmat" >&5
+echo "configure:2621: checking for shmat" >&5
 if eval "test \"`echo '$''{'ac_cv_func_shmat'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2623 "configure"
+#line 2626 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char shmat(); below.  */
@@ -2631,7 +2634,7 @@ shmat();
 
 ; return 0; }
 EOF
-if { (eval echo configure:2646: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2649: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_shmat=yes"
 else
@@ -2652,7 +2655,7 @@ fi
 
     if test $ac_cv_func_shmat = no; then
       echo $ac_n "checking for shmat in -lipc""... $ac_c" 1>&6
-echo "configure:2667: checking for shmat in -lipc" >&5
+echo "configure:2670: checking for shmat in -lipc" >&5
 ac_lib_var=`echo ipc'_'shmat | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2660,7 +2663,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lipc  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2675 "configure"
+#line 2678 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -2671,7 +2674,7 @@ int main() {
 shmat()
 ; return 0; }
 EOF
-if { (eval echo configure:2686: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2689: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2704,7 +2707,7 @@ fi
   # libraries we check for below, so use a different variable.
   #  --interran@uluru.Stanford.EDU, kb@cs.umb.edu.
   echo $ac_n "checking for IceConnectionNumber in -lICE""... $ac_c" 1>&6
-echo "configure:2719: checking for IceConnectionNumber in -lICE" >&5
+echo "configure:2722: checking for IceConnectionNumber in -lICE" >&5
 ac_lib_var=`echo ICE'_'IceConnectionNumber | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2712,7 +2715,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lICE  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2727 "configure"
+#line 2730 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -2723,7 +2726,7 @@ int main() {
 IceConnectionNumber()
 ; return 0; }
 EOF
-if { (eval echo configure:2738: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2741: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2760,7 +2763,7 @@ fi
 
 
     echo $ac_n "checking for X app-defaults directory""... $ac_c" 1>&6
-echo "configure:2775: checking for X app-defaults directory" >&5
+echo "configure:2778: checking for X app-defaults directory" >&5
 if eval "test \"`echo '$''{'ac_cv_x_app_defaults'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2907,7 +2910,7 @@ APPDEFAULTS=$ac_x_app_defaults
   fi
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   cat > conftest.$ac_ext <<EOF
-#line 2922 "configure"
+#line 2925 "configure"
 #include "confdefs.h"
 #include <X11/XHPlib.h>
 EOF
@@ -2928,7 +2931,7 @@ rm -f conftest*
 # Check for the availability of the XPointer typedef, and define it otherwise.
 #
 echo $ac_n "checking for XPointer""... $ac_c" 1>&6
-echo "configure:2943: checking for XPointer" >&5
+echo "configure:2946: checking for XPointer" >&5
 if eval "test \"`echo '$''{'ac_cv_xpointer'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2939,14 +2942,14 @@ else
   fi
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   cat > conftest.$ac_ext <<EOF
-#line 2954 "configure"
+#line 2957 "configure"
 #include "confdefs.h"
 #include <X11/Xlib.h>
 int main() {
 XPointer foo = (XPointer) 0;
 ; return 0; }
 EOF
-if { (eval echo configure:2961: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2964: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_xpointer=yes
 else
@@ -3080,7 +3083,7 @@ case "$host" in
 
       # Some versions of Slowlaris Motif require -lgen.  But not all.  Why?
       echo $ac_n "checking for regcmp in -lgen""... $ac_c" 1>&6
-echo "configure:3095: checking for regcmp in -lgen" >&5
+echo "configure:3098: checking for regcmp in -lgen" >&5
 ac_lib_var=`echo gen'_'regcmp | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3088,7 +3091,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgen  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3103 "configure"
+#line 3106 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3099,7 +3102,7 @@ int main() {
 regcmp()
 ; return 0; }
 EOF
-if { (eval echo configure:3114: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3117: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3136,17 +3139,17 @@ have_xmu=no
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   ac_safe=`echo "X11/Xmu/Error.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/Xmu/Error.h""... $ac_c" 1>&6
-echo "configure:3151: checking for X11/Xmu/Error.h" >&5
+echo "configure:3154: checking for X11/Xmu/Error.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3156 "configure"
+#line 3159 "configure"
 #include "confdefs.h"
 #include <X11/Xmu/Error.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3161: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3164: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -3176,6 +3179,7 @@ else
   XMU_OBJS=''
   SAVER_LIBS="-lXmu $SAVER_LIBS"
   HACK_LIBS="-lXmu $HACK_LIBS"
+  TOOLKIT_LIBS="-lXmu $TOOLKIT_LIBS"
   cat >> confdefs.h <<\EOF
 #define HAVE_XMU 1
 EOF
@@ -3190,7 +3194,7 @@ if test "$have_xmu" = yes ; then
   case "$host" in
     *-sunos4*)
     echo $ac_n "checking for the SunOS 4.1.x _get_wmShellWidgetClass bug""... $ac_c" 1>&6
-echo "configure:3205: checking for the SunOS 4.1.x _get_wmShellWidgetClass bug" >&5
+echo "configure:3209: checking for the SunOS 4.1.x _get_wmShellWidgetClass bug" >&5
 if eval "test \"`echo '$''{'ac_cv_sunos_xmu_bug'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -3203,14 +3207,14 @@ else
                    # with X libraries because we know it's SunOS.
                    LDFLAGS="$LDFLAGS -lXmu -lXt -lX11 -lXext -lm"
                    cat > conftest.$ac_ext <<EOF
-#line 3218 "configure"
+#line 3222 "configure"
 #include "confdefs.h"
 
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:3225: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3229: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   ac_cv_sunos_xmu_bug=no
 else
@@ -3226,21 +3230,21 @@ fi
 echo "$ac_t""$ac_cv_sunos_xmu_bug" 1>&6
     if test "$ac_cv_sunos_xmu_bug" = yes ; then
       echo $ac_n "checking whether the compiler understands -static""... $ac_c" 1>&6
-echo "configure:3241: checking whether the compiler understands -static" >&5
+echo "configure:3245: checking whether the compiler understands -static" >&5
 if eval "test \"`echo '$''{'ac_cv_ld_static'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   ac_save_LDFLAGS="$LDFLAGS"
                      LDFLAGS="$LDFLAGS -static"
                      cat > conftest.$ac_ext <<EOF
-#line 3248 "configure"
+#line 3252 "configure"
 #include "confdefs.h"
 
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:3255: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3259: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   ac_cv_ld_static=yes
 else
@@ -3285,7 +3289,7 @@ fi
 
     /*)
      echo $ac_n "checking for SGI SCREEN_SAVER headers""... $ac_c" 1>&6
-echo "configure:3300: checking for SGI SCREEN_SAVER headers" >&5
+echo "configure:3304: checking for SGI SCREEN_SAVER headers" >&5
      d=$with_sgi/include
      if test -d $d; then
        X_CFLAGS="-I$d $X_CFLAGS"
@@ -3295,7 +3299,7 @@ echo "configure:3300: checking for SGI SCREEN_SAVER headers" >&5
      fi
 
      echo $ac_n "checking for SGI SCREEN_SAVER libs""... $ac_c" 1>&6
-echo "configure:3310: checking for SGI SCREEN_SAVER libs" >&5
+echo "configure:3314: checking for SGI SCREEN_SAVER libs" >&5
      d=$with_sgi/lib
      if test -d $d; then
        X_LIBS="-L$d $X_LIBS"
@@ -3333,17 +3337,17 @@ if test "$with_sgi" = yes; then
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   ac_safe=`echo "X11/extensions/XScreenSaver.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/extensions/XScreenSaver.h""... $ac_c" 1>&6
-echo "configure:3348: checking for X11/extensions/XScreenSaver.h" >&5
+echo "configure:3352: checking for X11/extensions/XScreenSaver.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3353 "configure"
+#line 3357 "configure"
 #include "confdefs.h"
 #include <X11/extensions/XScreenSaver.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3358: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3362: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -3396,7 +3400,7 @@ fi
 
     /*)
      echo $ac_n "checking for MIT-SCREEN-SAVER headers""... $ac_c" 1>&6
-echo "configure:3411: checking for MIT-SCREEN-SAVER headers" >&5
+echo "configure:3415: checking for MIT-SCREEN-SAVER headers" >&5
      d=$with_mit/include
      if test -d $d; then
        X_CFLAGS="-I$d $X_CFLAGS"
@@ -3406,7 +3410,7 @@ echo "configure:3411: checking for MIT-SCREEN-SAVER headers" >&5
      fi
 
      echo $ac_n "checking for MIT-SCREEN-SAVER libs""... $ac_c" 1>&6
-echo "configure:3421: checking for MIT-SCREEN-SAVER libs" >&5
+echo "configure:3425: checking for MIT-SCREEN-SAVER libs" >&5
      d=$with_mit/lib
      if test -d $d; then
        X_LIBS="-L$d $X_LIBS"
@@ -3445,17 +3449,17 @@ if test "$have_sgi" != yes; then
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   ac_safe=`echo "X11/extensions/scrnsaver.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/extensions/scrnsaver.h""... $ac_c" 1>&6
-echo "configure:3460: checking for X11/extensions/scrnsaver.h" >&5
+echo "configure:3464: checking for X11/extensions/scrnsaver.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3465 "configure"
+#line 3469 "configure"
 #include "confdefs.h"
 #include <X11/extensions/scrnsaver.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3470: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3474: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -3499,7 +3503,7 @@ fi
   LDFLAGS="$LDFLAGS $X_LIBS"
 
   echo $ac_n "checking for XScreenSaverRegister in -lXext""... $ac_c" 1>&6
-echo "configure:3514: checking for XScreenSaverRegister in -lXext" >&5
+echo "configure:3518: checking for XScreenSaverRegister in -lXext" >&5
 ac_lib_var=`echo Xext'_'XScreenSaverRegister | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3507,7 +3511,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lXext -lm $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3522 "configure"
+#line 3526 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3518,7 +3522,7 @@ int main() {
 XScreenSaverRegister()
 ; return 0; }
 EOF
-if { (eval echo configure:3533: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3537: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3569,7 +3573,7 @@ fi
   LDFLAGS="$LDFLAGS $X_LIBS"
 
   echo $ac_n "checking for XScreenSaverRegister in -lXExExt""... $ac_c" 1>&6
-echo "configure:3584: checking for XScreenSaverRegister in -lXExExt" >&5
+echo "configure:3588: checking for XScreenSaverRegister in -lXExExt" >&5
 ac_lib_var=`echo XExExt'_'XScreenSaverRegister | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3577,7 +3581,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lXExExt -lX11 -lXext -lm $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3592 "configure"
+#line 3596 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3588,7 +3592,7 @@ int main() {
 XScreenSaverRegister()
 ; return 0; }
 EOF
-if { (eval echo configure:3603: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3607: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3634,7 +3638,7 @@ fi
   LDFLAGS="$LDFLAGS $X_LIBS"
 
   echo $ac_n "checking for XScreenSaverRegister in -lXss""... $ac_c" 1>&6
-echo "configure:3649: checking for XScreenSaverRegister in -lXss" >&5
+echo "configure:3653: checking for XScreenSaverRegister in -lXss" >&5
 ac_lib_var=`echo Xss'_'XScreenSaverRegister | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3642,7 +3646,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lXss -lX11 -lXext -lm $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3657 "configure"
+#line 3661 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3653,7 +3657,7 @@ int main() {
 XScreenSaverRegister()
 ; return 0; }
 EOF
-if { (eval echo configure:3668: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3672: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3713,7 +3717,7 @@ fi
 
     /*)
      echo $ac_n "checking for XIDLE headers""... $ac_c" 1>&6
-echo "configure:3728: checking for XIDLE headers" >&5
+echo "configure:3732: checking for XIDLE headers" >&5
      d=$with_xidle/include
      if test -d $d; then
        X_CFLAGS="-I$d $X_CFLAGS"
@@ -3723,7 +3727,7 @@ echo "configure:3728: checking for XIDLE headers" >&5
      fi
 
      echo $ac_n "checking for XIDLE libs""... $ac_c" 1>&6
-echo "configure:3738: checking for XIDLE libs" >&5
+echo "configure:3742: checking for XIDLE libs" >&5
      d=$with_xidle/lib
      if test -d $d; then
        X_LIBS="-L$d $X_LIBS"
@@ -3761,17 +3765,17 @@ if test "$with_xidle" = yes; then
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   ac_safe=`echo "X11/extensions/xidle.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/extensions/xidle.h""... $ac_c" 1>&6
-echo "configure:3776: checking for X11/extensions/xidle.h" >&5
+echo "configure:3780: checking for X11/extensions/xidle.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3781 "configure"
+#line 3785 "configure"
 #include "confdefs.h"
 #include <X11/extensions/xidle.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3786: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3790: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -3823,7 +3827,7 @@ fi
 
     /*)
      echo $ac_n "checking for XSHM headers""... $ac_c" 1>&6
-echo "configure:3838: checking for XSHM headers" >&5
+echo "configure:3842: checking for XSHM headers" >&5
      d=$with_xshm/include
      if test -d $d; then
        X_CFLAGS="-I$d $X_CFLAGS"
@@ -3833,7 +3837,7 @@ echo "configure:3838: checking for XSHM headers" >&5
      fi
 
      echo $ac_n "checking for XSHM libs""... $ac_c" 1>&6
-echo "configure:3848: checking for XSHM libs" >&5
+echo "configure:3852: checking for XSHM libs" >&5
      d=$with_xshm/lib
      if test -d $d; then
        X_LIBS="-L$d $X_LIBS"
@@ -3873,17 +3877,17 @@ if test "$with_xshm" = yes; then
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   ac_safe=`echo "X11/extensions/XShm.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/extensions/XShm.h""... $ac_c" 1>&6
-echo "configure:3888: checking for X11/extensions/XShm.h" >&5
+echo "configure:3892: checking for X11/extensions/XShm.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3893 "configure"
+#line 3897 "configure"
 #include "confdefs.h"
 #include <X11/extensions/XShm.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3898: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3902: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -3917,17 +3921,17 @@ fi
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   ac_safe=`echo "sys/ipc.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for sys/ipc.h""... $ac_c" 1>&6
-echo "configure:3932: checking for sys/ipc.h" >&5
+echo "configure:3936: checking for sys/ipc.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3937 "configure"
+#line 3941 "configure"
 #include "confdefs.h"
 #include <sys/ipc.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3942: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3946: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -3962,17 +3966,17 @@ fi
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   ac_safe=`echo "sys/shm.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for sys/shm.h""... $ac_c" 1>&6
-echo "configure:3977: checking for sys/shm.h" >&5
+echo "configure:3981: checking for sys/shm.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3982 "configure"
+#line 3986 "configure"
 #include "confdefs.h"
 #include <sys/shm.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3987: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3991: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -4021,7 +4025,7 @@ fi
   LDFLAGS="$LDFLAGS $X_LIBS"
 
   echo $ac_n "checking for XShmQueryExtension in -lXextSam""... $ac_c" 1>&6
-echo "configure:4036: checking for XShmQueryExtension in -lXextSam" >&5
+echo "configure:4040: checking for XShmQueryExtension in -lXextSam" >&5
 ac_lib_var=`echo XextSam'_'XShmQueryExtension | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -4029,7 +4033,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lXextSam -lX11 -lXext -lm $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4044 "configure"
+#line 4048 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -4040,7 +4044,7 @@ int main() {
 XShmQueryExtension()
 ; return 0; }
 EOF
-if { (eval echo configure:4055: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4059: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4099,7 +4103,7 @@ fi
 
     /*)
      echo $ac_n "checking for SGI-VIDEO-CONTROL headers""... $ac_c" 1>&6
-echo "configure:4114: checking for SGI-VIDEO-CONTROL headers" >&5
+echo "configure:4118: checking for SGI-VIDEO-CONTROL headers" >&5
      d=$with_sgivc/include
      if test -d $d; then
        X_CFLAGS="-I$d $X_CFLAGS"
@@ -4109,7 +4113,7 @@ echo "configure:4114: checking for SGI-VIDEO-CONTROL headers" >&5
      fi
 
      echo $ac_n "checking for SGI-VIDEO-CONTROL libs""... $ac_c" 1>&6
-echo "configure:4124: checking for SGI-VIDEO-CONTROL libs" >&5
+echo "configure:4128: checking for SGI-VIDEO-CONTROL libs" >&5
      d=$with_sgivc/lib
      if test -d $d; then
        X_LIBS="-L$d $X_LIBS"
@@ -4149,17 +4153,17 @@ if test "$with_sgivc" = yes; then
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   ac_safe=`echo "X11/extensions/XSGIvc.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/extensions/XSGIvc.h""... $ac_c" 1>&6
-echo "configure:4164: checking for X11/extensions/XSGIvc.h" >&5
+echo "configure:4168: checking for X11/extensions/XSGIvc.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4169 "configure"
+#line 4173 "configure"
 #include "confdefs.h"
 #include <X11/extensions/XSGIvc.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4174: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4178: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -4202,7 +4206,7 @@ fi
   LDFLAGS="$LDFLAGS $X_LIBS"
 
   echo $ac_n "checking for XSGIvcQueryGammaMap in -lXsgivc""... $ac_c" 1>&6
-echo "configure:4217: checking for XSGIvcQueryGammaMap in -lXsgivc" >&5
+echo "configure:4221: checking for XSGIvcQueryGammaMap in -lXsgivc" >&5
 ac_lib_var=`echo Xsgivc'_'XSGIvcQueryGammaMap | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -4210,7 +4214,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lXsgivc -lXext -lX11 $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4225 "configure"
+#line 4229 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -4221,7 +4225,7 @@ int main() {
 XSGIvcQueryGammaMap()
 ; return 0; }
 EOF
-if { (eval echo configure:4236: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4240: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4279,7 +4283,7 @@ fi
 
     /*)
      echo $ac_n "checking for DPMS headers""... $ac_c" 1>&6
-echo "configure:4294: checking for DPMS headers" >&5
+echo "configure:4298: checking for DPMS headers" >&5
      d=$with_dpms/include
      if test -d $d; then
        X_CFLAGS="-I$d $X_CFLAGS"
@@ -4289,7 +4293,7 @@ echo "configure:4294: checking for DPMS headers" >&5
      fi
 
      echo $ac_n "checking for DPMS libs""... $ac_c" 1>&6
-echo "configure:4304: checking for DPMS libs" >&5
+echo "configure:4308: checking for DPMS libs" >&5
      d=$with_dpms/lib
      if test -d $d; then
        X_LIBS="-L$d $X_LIBS"
@@ -4329,17 +4333,17 @@ if test "$with_dpms" = yes; then
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   ac_safe=`echo "X11/extensions/dpms.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/extensions/dpms.h""... $ac_c" 1>&6
-echo "configure:4344: checking for X11/extensions/dpms.h" >&5
+echo "configure:4348: checking for X11/extensions/dpms.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4349 "configure"
+#line 4353 "configure"
 #include "confdefs.h"
 #include <X11/extensions/dpms.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4354: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4358: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -4382,7 +4386,7 @@ fi
   LDFLAGS="$LDFLAGS $X_LIBS"
 
   echo $ac_n "checking for DPMSInfo in -lXdpms""... $ac_c" 1>&6
-echo "configure:4397: checking for DPMSInfo in -lXdpms" >&5
+echo "configure:4401: checking for DPMSInfo in -lXdpms" >&5
 ac_lib_var=`echo Xdpms'_'DPMSInfo | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -4390,7 +4394,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lXdpms -lXext -lX11 $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4405 "configure"
+#line 4409 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -4401,7 +4405,7 @@ int main() {
 DPMSInfo()
 ; return 0; }
 EOF
-if { (eval echo configure:4416: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4420: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4464,7 +4468,7 @@ fi
 
     /*)
      echo $ac_n "checking for Motif headers""... $ac_c" 1>&6
-echo "configure:4479: checking for Motif headers" >&5
+echo "configure:4483: checking for Motif headers" >&5
      d=$with_motif/include
      if test -d $d; then
        X_CFLAGS="-I$d $X_CFLAGS"
@@ -4474,7 +4478,7 @@ echo "configure:4479: checking for Motif headers" >&5
      fi
 
      echo $ac_n "checking for Motif libs""... $ac_c" 1>&6
-echo "configure:4489: checking for Motif libs" >&5
+echo "configure:4493: checking for Motif libs" >&5
      d=$with_motif/lib
      if test -d $d; then
        X_LIBS="-L$d $X_LIBS"
@@ -4519,7 +4523,7 @@ fi
 
     /*)
      echo $ac_n "checking for Athena headers""... $ac_c" 1>&6
-echo "configure:4534: checking for Athena headers" >&5
+echo "configure:4538: checking for Athena headers" >&5
      d=$with_athena/include
      if test -d $d; then
        X_CFLAGS="-I$d $X_CFLAGS"
@@ -4529,7 +4533,7 @@ echo "configure:4534: checking for Athena headers" >&5
      fi
 
      echo $ac_n "checking for Athena libs""... $ac_c" 1>&6
-echo "configure:4544: checking for Athena libs" >&5
+echo "configure:4548: checking for Athena libs" >&5
      d=$with_athena/lib
      if test -d $d; then
        X_LIBS="-L$d $X_LIBS"
@@ -4592,17 +4596,17 @@ check_motif() {
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   ac_safe=`echo "Xm/Xm.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for Xm/Xm.h""... $ac_c" 1>&6
-echo "configure:4607: checking for Xm/Xm.h" >&5
+echo "configure:4611: checking for Xm/Xm.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4612 "configure"
+#line 4616 "configure"
 #include "confdefs.h"
 #include <Xm/Xm.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4617: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4621: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -4642,17 +4646,17 @@ check_athena() {
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   ac_safe=`echo "X11/Xaw/Dialog.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/Xaw/Dialog.h""... $ac_c" 1>&6
-echo "configure:4657: checking for X11/Xaw/Dialog.h" >&5
+echo "configure:4661: checking for X11/Xaw/Dialog.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4662 "configure"
+#line 4666 "configure"
 #include "confdefs.h"
 #include <X11/Xaw/Dialog.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4667: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4671: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -4692,7 +4696,7 @@ fi
   LDFLAGS="$LDFLAGS $X_LIBS"
 
   echo $ac_n "checking for Xaw3dComputeTopShadowRGB in -lXaw3d""... $ac_c" 1>&6
-echo "configure:4707: checking for Xaw3dComputeTopShadowRGB in -lXaw3d" >&5
+echo "configure:4711: checking for Xaw3dComputeTopShadowRGB in -lXaw3d" >&5
 ac_lib_var=`echo Xaw3d'_'Xaw3dComputeTopShadowRGB | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -4700,7 +4704,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lXaw3d -lXt -lXmu -lXext -lX11 $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4715 "configure"
+#line 4719 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -4711,7 +4715,7 @@ int main() {
 Xaw3dComputeTopShadowRGB()
 ; return 0; }
 EOF
-if { (eval echo configure:4726: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4730: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4788,7 +4792,7 @@ fi
 # XawViewportSetCoordinates in Viewport.h (R3 (or R4?) don't.)
 if test "$have_athena" = yes ; then
   echo $ac_n "checking for XawViewportSetCoordinates in Viewport.h""... $ac_c" 1>&6
-echo "configure:4803: checking for XawViewportSetCoordinates in Viewport.h" >&5
+echo "configure:4807: checking for XawViewportSetCoordinates in Viewport.h" >&5
 if eval "test \"`echo '$''{'ac_cv_have_XawViewportSetCoordinates'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4800,7 +4804,7 @@ else
   fi
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   cat > conftest.$ac_ext <<EOF
-#line 4815 "configure"
+#line 4819 "configure"
 #include "confdefs.h"
 #include <X11/Xaw/Viewport.h>
 EOF
@@ -4829,7 +4833,7 @@ fi
 have_lesstif=no
 if test "$have_motif" = yes ; then
   echo $ac_n "checking whether Motif is really LessTif""... $ac_c" 1>&6
-echo "configure:4844: checking whether Motif is really LessTif" >&5
+echo "configure:4848: checking whether Motif is really LessTif" >&5
 if eval "test \"`echo '$''{'ac_cv_have_lesstif'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4840,14 +4844,14 @@ else
   fi
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   cat > conftest.$ac_ext <<EOF
-#line 4855 "configure"
+#line 4859 "configure"
 #include "confdefs.h"
 #include <Xm/Xm.h>
 int main() {
 long vers = LesstifVersion;
 ; return 0; }
 EOF
-if { (eval echo configure:4862: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4866: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_have_lesstif=yes
 else
@@ -4875,7 +4879,7 @@ if test "$have_lesstif" = yes ; then
   ltv=unknown
   echo unknown > conftest-lt
   echo $ac_n "checking LessTif version number""... $ac_c" 1>&6
-echo "configure:4890: checking LessTif version number" >&5
+echo "configure:4894: checking LessTif version number" >&5
 if eval "test \"`echo '$''{'ac_cv_lesstif_version_string'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4890,7 +4894,7 @@ else
                     ac_cv_lesstif_version_string=unknown
 else
   cat > conftest.$ac_ext <<EOF
-#line 4905 "configure"
+#line 4909 "configure"
 #include "confdefs.h"
 #include <stdio.h>
                     #include <Xm/Xm.h>
@@ -4903,7 +4907,7 @@ else
                       exit(0);
                     }
 EOF
-if { (eval echo configure:4918: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:4922: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
 then
   ltv=`cat conftest-lt`
                     ac_cv_lesstif_version=`echo $ltv | sed 's/ .*//'`
@@ -4953,7 +4957,7 @@ if test "$have_motif" = yes ; then
   LDFLAGS="$LDFLAGS $X_LIBS"
 
   echo $ac_n "checking for XpQueryExtension in -lXp""... $ac_c" 1>&6
-echo "configure:4968: checking for XpQueryExtension in -lXp" >&5
+echo "configure:4972: checking for XpQueryExtension in -lXp" >&5
 ac_lib_var=`echo Xp'_'XpQueryExtension | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -4961,7 +4965,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lXp -lX11 -lXext -lm $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4976 "configure"
+#line 4980 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -4972,7 +4976,7 @@ int main() {
 XpQueryExtension()
 ; return 0; }
 EOF
-if { (eval echo configure:4987: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4991: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4997,6 +5001,76 @@ fi
 fi
 
 
+# Check for _Xsetlocale in -lXintl, since at least some recent versions
+# of Motif (on Linux) need it.
+#
+have_xintl=no
+if test "$have_motif" = yes ; then
+  
+  ac_save_CPPFLAGS="$CPPFLAGS"
+  ac_save_LDFLAGS="$LDFLAGS"
+
+  if test \! -z "$includedir" ; then 
+    CPPFLAGS="$CPPFLAGS -I$includedir"
+  fi
+  # note: $X_CFLAGS includes $x_includes
+  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
+
+  if test \! -z "$libdir" ; then
+    LDFLAGS="$LDFLAGS -L$libdir"
+  fi
+  # note: $X_LIBS includes $x_libraries
+  LDFLAGS="$LDFLAGS $X_LIBS"
+
+  echo $ac_n "checking for _Xsetlocale in -lXintl""... $ac_c" 1>&6
+echo "configure:5038: checking for _Xsetlocale in -lXintl" >&5
+ac_lib_var=`echo Xintl'_'_Xsetlocale | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  ac_save_LIBS="$LIBS"
+LIBS="-lXintl -lX11 -lXext -lm $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 5046 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char _Xsetlocale();
+
+int main() {
+_Xsetlocale()
+; return 0; }
+EOF
+if { (eval echo configure:5057: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  have_xintl=yes
+else
+  echo "$ac_t""no" 1>&6
+have_xintl=no
+fi
+
+  CPPFLAGS="$ac_save_CPPFLAGS"
+  LDFLAGS="$ac_save_LDFLAGS"
+  if test "$have_xintl" = yes; then
+    TOOLKIT_LIBS="$TOOLKIT_LIBS -lXintl"
+  fi
+fi
+
+
 # check for XPM header.
 #
 have_xpm=no
@@ -5017,7 +5091,7 @@ fi
 
     /*)
      echo $ac_n "checking for XPM headers""... $ac_c" 1>&6
-echo "configure:5032: checking for XPM headers" >&5
+echo "configure:5106: checking for XPM headers" >&5
      d=$with_xpm/include
      if test -d $d; then
        X_CFLAGS="-I$d $X_CFLAGS"
@@ -5027,7 +5101,7 @@ echo "configure:5032: checking for XPM headers" >&5
      fi
 
      echo $ac_n "checking for XPM libs""... $ac_c" 1>&6
-echo "configure:5042: checking for XPM libs" >&5
+echo "configure:5116: checking for XPM libs" >&5
      d=$with_xpm/lib
      if test -d $d; then
        X_LIBS="-L$d $X_LIBS"
@@ -5065,17 +5139,17 @@ if test "$with_xpm" = yes; then
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   ac_safe=`echo "X11/xpm.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/xpm.h""... $ac_c" 1>&6
-echo "configure:5080: checking for X11/xpm.h" >&5
+echo "configure:5154: checking for X11/xpm.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5085 "configure"
+#line 5159 "configure"
 #include "confdefs.h"
 #include <X11/xpm.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5090: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5164: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -5129,7 +5203,7 @@ fi
 
     /*)
      echo $ac_n "checking for GL headers""... $ac_c" 1>&6
-echo "configure:5144: checking for GL headers" >&5
+echo "configure:5218: checking for GL headers" >&5
      d=$with_gl/include
      if test -d $d; then
        X_CFLAGS="-I$d $X_CFLAGS"
@@ -5139,7 +5213,7 @@ echo "configure:5144: checking for GL headers" >&5
      fi
 
      echo $ac_n "checking for GL libs""... $ac_c" 1>&6
-echo "configure:5154: checking for GL libs" >&5
+echo "configure:5228: checking for GL libs" >&5
      d=$with_gl/lib
      if test -d $d; then
        X_LIBS="-L$d $X_LIBS"
@@ -5180,17 +5254,17 @@ if test "$with_gl" = yes; then
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   ac_safe=`echo "GL/gl.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for GL/gl.h""... $ac_c" 1>&6
-echo "configure:5195: checking for GL/gl.h" >&5
+echo "configure:5269: checking for GL/gl.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5200 "configure"
+#line 5274 "configure"
 #include "confdefs.h"
 #include <GL/gl.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5205: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5279: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -5221,17 +5295,17 @@ fi
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   ac_safe=`echo "GL/glx.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for GL/glx.h""... $ac_c" 1>&6
-echo "configure:5236: checking for GL/glx.h" >&5
+echo "configure:5310: checking for GL/glx.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5241 "configure"
+#line 5315 "configure"
 #include "confdefs.h"
 #include <GL/glx.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5246: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5320: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -5268,7 +5342,7 @@ EOF
     # to link against.
     #
     echo $ac_n "checking whether GL is really MesaGL""... $ac_c" 1>&6
-echo "configure:5283: checking whether GL is really MesaGL" >&5
+echo "configure:5357: checking whether GL is really MesaGL" >&5
     if eval "test \"`echo '$''{'ac_cv_have_mesa_gl'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -5280,7 +5354,7 @@ else
   fi
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   cat > conftest.$ac_ext <<EOF
-#line 5295 "configure"
+#line 5369 "configure"
 #include "confdefs.h"
 #include <GL/glx.h>
 EOF
@@ -5321,12 +5395,12 @@ EOF
       unset ac_cv_mesagl_version_string
 
       echo $ac_n "checking MesaGL version number""... $ac_c" 1>&6
-echo "configure:5336: checking MesaGL version number" >&5
+echo "configure:5410: checking MesaGL version number" >&5
       if eval "test \"`echo '$''{'ac_cv_mesagl_version_string'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5341 "configure"
+#line 5415 "configure"
 #include "confdefs.h"
 #include <GL/gl.h>
 configure: MESA_MAJOR_VERSION MESA_MINOR_VERSION
@@ -5372,6 +5446,118 @@ fi
     fi
 
 
+    # If it's MesaGL, check to see if it requires -lpthread.
+    #
+    have_pthread=no
+    mesa_requires_pthread=false
+    if test "$ac_have_mesa_gl" = yes; then
+
+      echo $ac_n "checking for pthread_create in -lpthread""... $ac_c" 1>&6
+echo "configure:5468: checking for pthread_create in -lpthread" >&5
+ac_lib_var=`echo pthread'_'pthread_create | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  ac_save_LIBS="$LIBS"
+LIBS="-lpthread  $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 5476 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char pthread_create();
+
+int main() {
+pthread_create()
+; return 0; }
+EOF
+if { (eval echo configure:5487: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  have_pthread=yes
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+      if test "$have_pthread" = yes; then
+        
+  ac_save_CPPFLAGS="$CPPFLAGS"
+  ac_save_LDFLAGS="$LDFLAGS"
+
+  if test \! -z "$includedir" ; then 
+    CPPFLAGS="$CPPFLAGS -I$includedir"
+  fi
+  # note: $X_CFLAGS includes $x_includes
+  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
+
+  if test \! -z "$libdir" ; then
+    LDFLAGS="$LDFLAGS -L$libdir"
+  fi
+  # note: $X_LIBS includes $x_libraries
+  LDFLAGS="$LDFLAGS $X_LIBS"
+
+  echo $ac_n "checking for gl_get_thread_context in -l$gl_lib_1""... $ac_c" 1>&6
+echo "configure:5525: checking for gl_get_thread_context in -l$gl_lib_1" >&5
+ac_lib_var=`echo $gl_lib_1'_'gl_get_thread_context | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  ac_save_LIBS="$LIBS"
+LIBS="-l$gl_lib_1 $GL_LIBS -lpthread -lX11 -lXext -lm $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 5533 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char gl_get_thread_context();
+
+int main() {
+gl_get_thread_context()
+; return 0; }
+EOF
+if { (eval echo configure:5544: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  mesa_requires_pthread=yes
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+  CPPFLAGS="$ac_save_CPPFLAGS"
+  LDFLAGS="$ac_save_LDFLAGS"
+      fi
+
+      if test "$mesa_requires_pthread" = yes; then
+        GL_LIBS="$GL_LIBS -lpthread"
+      fi
+    fi
+
     # Check for OpenGL 1.1 features.
     #
     
@@ -5391,7 +5577,7 @@ fi
   LDFLAGS="$LDFLAGS $X_LIBS"
 
   echo $ac_n "checking for glBindTexture in -l$gl_lib_1""... $ac_c" 1>&6
-echo "configure:5406: checking for glBindTexture in -l$gl_lib_1" >&5
+echo "configure:5592: checking for glBindTexture in -l$gl_lib_1" >&5
 ac_lib_var=`echo $gl_lib_1'_'glBindTexture | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -5399,7 +5585,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$gl_lib_1 $GL_LIBS -lX11 -lXext -lm $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 5414 "configure"
+#line 5600 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -5410,7 +5596,7 @@ int main() {
 glBindTexture()
 ; return 0; }
 EOF
-if { (eval echo configure:5425: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5611: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5464,7 +5650,7 @@ fi
 
     /*)
      echo $ac_n "checking for XReadDisplay headers""... $ac_c" 1>&6
-echo "configure:5479: checking for XReadDisplay headers" >&5
+echo "configure:5665: checking for XReadDisplay headers" >&5
      d=$with_readdisplay/include
      if test -d $d; then
        X_CFLAGS="-I$d $X_CFLAGS"
@@ -5474,7 +5660,7 @@ echo "configure:5479: checking for XReadDisplay headers" >&5
      fi
 
      echo $ac_n "checking for XReadDisplay libs""... $ac_c" 1>&6
-echo "configure:5489: checking for XReadDisplay libs" >&5
+echo "configure:5675: checking for XReadDisplay libs" >&5
      d=$with_readdisplay/lib
      if test -d $d; then
        X_LIBS="-L$d $X_LIBS"
@@ -5512,17 +5698,17 @@ if test "$with_readdisplay" = yes; then
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   ac_safe=`echo "X11/extensions/readdisplay.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for X11/extensions/readdisplay.h""... $ac_c" 1>&6
-echo "configure:5527: checking for X11/extensions/readdisplay.h" >&5
+echo "configure:5713: checking for X11/extensions/readdisplay.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5532 "configure"
+#line 5718 "configure"
 #include "confdefs.h"
 #include <X11/extensions/readdisplay.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5537: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5723: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -5573,7 +5759,7 @@ fi
 
     /*)
      echo $ac_n "checking for Iris Video headers""... $ac_c" 1>&6
-echo "configure:5588: checking for Iris Video headers" >&5
+echo "configure:5774: checking for Iris Video headers" >&5
      d=$with_sgivideo/include
      if test -d $d; then
        X_CFLAGS="-I$d $X_CFLAGS"
@@ -5583,7 +5769,7 @@ echo "configure:5588: checking for Iris Video headers" >&5
      fi
 
      echo $ac_n "checking for Iris Video libs""... $ac_c" 1>&6
-echo "configure:5598: checking for Iris Video libs" >&5
+echo "configure:5784: checking for Iris Video libs" >&5
      d=$with_sgivideo/lib
      if test -d $d; then
        X_LIBS="-L$d $X_LIBS"
@@ -5621,17 +5807,17 @@ if test "$with_sgivideo" = yes; then
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   ac_safe=`echo "dmedia/vl.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for dmedia/vl.h""... $ac_c" 1>&6
-echo "configure:5636: checking for dmedia/vl.h" >&5
+echo "configure:5822: checking for dmedia/vl.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5641 "configure"
+#line 5827 "configure"
 #include "confdefs.h"
 #include <dmedia/vl.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5646: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5832: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -5656,7 +5842,7 @@ fi
   if test "$have_sgivideo" = yes; then
     have_sgivideo=no
     echo $ac_n "checking for vlOpenVideo in -lvl""... $ac_c" 1>&6
-echo "configure:5671: checking for vlOpenVideo in -lvl" >&5
+echo "configure:5857: checking for vlOpenVideo in -lvl" >&5
 ac_lib_var=`echo vl'_'vlOpenVideo | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -5664,7 +5850,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lvl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 5679 "configure"
+#line 5865 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -5675,7 +5861,7 @@ int main() {
 vlOpenVideo()
 ; return 0; }
 EOF
-if { (eval echo configure:5690: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5876: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5743,7 +5929,7 @@ if test -n "$with_zippy_req" ; then
   case "$with_zippy_req" in
     /*)
       echo $ac_n "checking for $with_zippy_req""... $ac_c" 1>&6
-echo "configure:5758: checking for $with_zippy_req" >&5
+echo "configure:5944: checking for $with_zippy_req" >&5
       if test -x "$with_zippy_req" ; then
         echo "$ac_t""yes" 1>&6
       else
@@ -5757,7 +5943,7 @@ echo "configure:5758: checking for $with_zippy_req" >&5
       # Extract the first word of "$with_zippy_req", so it can be a program name with args.
 set dummy $with_zippy_req; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:5772: checking for $ac_word" >&5
+echo "configure:5958: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_zip2'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -5803,7 +5989,7 @@ do
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:5818: checking for $ac_word" >&5
+echo "configure:6004: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_emacs_exe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -5836,7 +6022,7 @@ do
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:5851: checking for $ac_word" >&5
+echo "configure:6037: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_xemacs_exe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -5870,7 +6056,7 @@ done
 
   if test -n "$emacs_exe" ; then
     echo $ac_n "checking for emacs yow""... $ac_c" 1>&6
-echo "configure:5885: checking for emacs yow" >&5
+echo "configure:6071: checking for emacs yow" >&5
     #
     # get emacs to tell us where the libexec directory is.
     #
@@ -5892,7 +6078,7 @@ echo "configure:5885: checking for emacs yow" >&5
 
   if test -z "$ac_cv_zippy_program" ; then
     echo $ac_n "checking for xemacs yow""... $ac_c" 1>&6
-echo "configure:5907: checking for xemacs yow" >&5
+echo "configure:6093: checking for xemacs yow" >&5
     if test -n "$xemacs_exe" ; then
       #
       # get xemacs to tell us where the libexec directory is.
@@ -5938,7 +6124,7 @@ do
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:5953: checking for $ac_word" >&5
+echo "configure:6139: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_fortune'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -5973,7 +6159,7 @@ do
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:5988: checking for $ac_word" >&5
+echo "configure:6174: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_fortune'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -6068,12 +6254,12 @@ fi
 if test "$enable_vt_locking" = yes; then
 
   echo $ac_n "checking for the VT_LOCKSWITCH ioctl""... $ac_c" 1>&6
-echo "configure:6083: checking for the VT_LOCKSWITCH ioctl" >&5
+echo "configure:6269: checking for the VT_LOCKSWITCH ioctl" >&5
   if eval "test \"`echo '$''{'ac_cv_vt_lockswitch'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6088 "configure"
+#line 6274 "configure"
 #include "confdefs.h"
 #include <fcntl.h>
                    #include <sys/ioctl.h>
@@ -6082,7 +6268,7 @@ int main() {
 int x = VT_LOCKSWITCH; int y = VT_UNLOCKSWITCH;
 ; return 0; }
 EOF
-if { (eval echo configure:6097: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6283: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_vt_lockswitch=yes
 else
@@ -6136,7 +6322,7 @@ fi
 
     /*)
      echo $ac_n "checking for Kerberos headers""... $ac_c" 1>&6
-echo "configure:6151: checking for Kerberos headers" >&5
+echo "configure:6337: checking for Kerberos headers" >&5
      d=$with_kerberos/include
      if test -d $d; then
        X_CFLAGS="-I$d $X_CFLAGS"
@@ -6146,7 +6332,7 @@ echo "configure:6151: checking for Kerberos headers" >&5
      fi
 
      echo $ac_n "checking for Kerberos libs""... $ac_c" 1>&6
-echo "configure:6161: checking for Kerberos libs" >&5
+echo "configure:6347: checking for Kerberos libs" >&5
      d=$with_kerberos/lib
      if test -d $d; then
        X_LIBS="-L$d $X_LIBS"
@@ -6177,7 +6363,7 @@ echo "configure:6161: checking for Kerberos libs" >&5
 
   if test "$with_kerberos" = yes; then
     echo $ac_n "checking for Kerberos""... $ac_c" 1>&6
-echo "configure:6192: checking for Kerberos" >&5
+echo "configure:6378: checking for Kerberos" >&5
 if eval "test \"`echo '$''{'ac_cv_kerberos'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -6188,14 +6374,14 @@ else
   fi
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   cat > conftest.$ac_ext <<EOF
-#line 6203 "configure"
+#line 6389 "configure"
 #include "confdefs.h"
 #include <krb.h>
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:6210: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6396: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_kerberos=yes
 else
@@ -6219,12 +6405,12 @@ EOF
       # from Tim Showalter <tjs+@andrew.cmu.edu>
       PASSWD_LIBS="$PASSWD_LIBS -lkrb -ldes"
       echo $ac_n "checking for res_search""... $ac_c" 1>&6
-echo "configure:6234: checking for res_search" >&5
+echo "configure:6420: checking for res_search" >&5
 if eval "test \"`echo '$''{'ac_cv_func_res_search'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6239 "configure"
+#line 6425 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char res_search(); below.  */
@@ -6247,7 +6433,7 @@ res_search();
 
 ; return 0; }
 EOF
-if { (eval echo configure:6262: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6448: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_res_search=yes"
 else
@@ -6265,7 +6451,7 @@ if eval "test \"`echo '$ac_cv_func_'res_search`\" = yes"; then
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for res_search in -lresolv""... $ac_c" 1>&6
-echo "configure:6280: checking for res_search in -lresolv" >&5
+echo "configure:6466: checking for res_search in -lresolv" >&5
 ac_lib_var=`echo resolv'_'res_search | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -6273,7 +6459,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lresolv  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 6288 "configure"
+#line 6474 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -6284,7 +6470,7 @@ int main() {
 res_search()
 ; return 0; }
 EOF
-if { (eval echo configure:6299: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6485: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6334,7 +6520,7 @@ fi
 
     /*)
      echo $ac_n "checking for PAM headers""... $ac_c" 1>&6
-echo "configure:6349: checking for PAM headers" >&5
+echo "configure:6535: checking for PAM headers" >&5
      d=$with_pam/include
      if test -d $d; then
        X_CFLAGS="-I$d $X_CFLAGS"
@@ -6344,7 +6530,7 @@ echo "configure:6349: checking for PAM headers" >&5
      fi
 
      echo $ac_n "checking for PAM libs""... $ac_c" 1>&6
-echo "configure:6359: checking for PAM libs" >&5
+echo "configure:6545: checking for PAM libs" >&5
      d=$with_pam/lib
      if test -d $d; then
        X_LIBS="-L$d $X_LIBS"
@@ -6375,7 +6561,7 @@ echo "configure:6359: checking for PAM libs" >&5
 
   if test "$with_pam" = yes; then
     echo $ac_n "checking for PAM""... $ac_c" 1>&6
-echo "configure:6390: checking for PAM" >&5
+echo "configure:6576: checking for PAM" >&5
 if eval "test \"`echo '$''{'ac_cv_pam'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -6386,14 +6572,14 @@ else
   fi
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   cat > conftest.$ac_ext <<EOF
-#line 6401 "configure"
+#line 6587 "configure"
 #include "confdefs.h"
 #include <security/pam_appl.h>
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:6408: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6594: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_pam=yes
 else
@@ -6439,7 +6625,7 @@ fi
 
     /*)
      echo $ac_n "checking for shadow password headers""... $ac_c" 1>&6
-echo "configure:6454: checking for shadow password headers" >&5
+echo "configure:6640: checking for shadow password headers" >&5
      d=$with_shadow/include
      if test -d $d; then
        X_CFLAGS="-I$d $X_CFLAGS"
@@ -6449,7 +6635,7 @@ echo "configure:6454: checking for shadow password headers" >&5
      fi
 
      echo $ac_n "checking for shadow password libs""... $ac_c" 1>&6
-echo "configure:6464: checking for shadow password libs" >&5
+echo "configure:6650: checking for shadow password libs" >&5
      d=$with_shadow/lib
      if test -d $d; then
        X_LIBS="-L$d $X_LIBS"
@@ -6490,7 +6676,7 @@ echo "configure:6464: checking for shadow password libs" >&5
   #
   if test "$pwent_cruft_done" = no ; then
     echo $ac_n "checking for Sun-style shadow passwords""... $ac_c" 1>&6
-echo "configure:6505: checking for Sun-style shadow passwords" >&5
+echo "configure:6691: checking for Sun-style shadow passwords" >&5
 if eval "test \"`echo '$''{'ac_cv_sun_adjunct'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -6501,7 +6687,7 @@ else
   fi
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   cat > conftest.$ac_ext <<EOF
-#line 6516 "configure"
+#line 6702 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
                                      #include <unistd.h>
@@ -6514,7 +6700,7 @@ struct passwd_adjunct *p = getpwanam("nobody");
                         const char *pw = p->pwa_passwd;
 ; return 0; }
 EOF
-if { (eval echo configure:6529: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6715: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_sun_adjunct=yes
 else
@@ -6543,7 +6729,7 @@ EOF
   #
   if test "$pwent_cruft_done" = no ; then
     echo $ac_n "checking for DEC-style shadow passwords""... $ac_c" 1>&6
-echo "configure:6558: checking for DEC-style shadow passwords" >&5
+echo "configure:6744: checking for DEC-style shadow passwords" >&5
 if eval "test \"`echo '$''{'ac_cv_enhanced_passwd'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -6554,7 +6740,7 @@ else
   fi
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   cat > conftest.$ac_ext <<EOF
-#line 6569 "configure"
+#line 6755 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
                                      #include <unistd.h>
@@ -6571,7 +6757,7 @@ struct pr_passwd *p;
                         pw = p->ufld.fd_encrypt;
 ; return 0; }
 EOF
-if { (eval echo configure:6586: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6772: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_enhanced_passwd=yes
 else
@@ -6597,7 +6783,7 @@ EOF
       # On SCO, getprpwnam() is in -lprot (which uses nap() from -lx)
       # (I'm told it needs -lcurses too, but I don't understand why.)
       echo $ac_n "checking for getprpwnam in -lprot""... $ac_c" 1>&6
-echo "configure:6612: checking for getprpwnam in -lprot" >&5
+echo "configure:6798: checking for getprpwnam in -lprot" >&5
 ac_lib_var=`echo prot'_'getprpwnam | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -6605,7 +6791,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lprot -lx $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 6620 "configure"
+#line 6806 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -6616,7 +6802,7 @@ int main() {
 getprpwnam()
 ; return 0; }
 EOF
-if { (eval echo configure:6631: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6817: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6636,7 +6822,7 @@ else
   echo "$ac_t""no" 1>&6
 # On DEC, getprpwnam() is in -lsecurity
                    echo $ac_n "checking for getprpwnam in -lsecurity""... $ac_c" 1>&6
-echo "configure:6651: checking for getprpwnam in -lsecurity" >&5
+echo "configure:6837: checking for getprpwnam in -lsecurity" >&5
 ac_lib_var=`echo security'_'getprpwnam | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -6644,7 +6830,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsecurity  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 6659 "configure"
+#line 6845 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -6655,7 +6841,7 @@ int main() {
 getprpwnam()
 ; return 0; }
 EOF
-if { (eval echo configure:6670: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6856: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6684,7 +6870,7 @@ fi
   #
   if test "$pwent_cruft_done" = no ; then
     echo $ac_n "checking for HP-style shadow passwords""... $ac_c" 1>&6
-echo "configure:6699: checking for HP-style shadow passwords" >&5
+echo "configure:6885: checking for HP-style shadow passwords" >&5
 if eval "test \"`echo '$''{'ac_cv_hpux_passwd'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -6695,7 +6881,7 @@ else
   fi
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   cat > conftest.$ac_ext <<EOF
-#line 6710 "configure"
+#line 6896 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
                                      #include <unistd.h>
@@ -6708,7 +6894,7 @@ struct s_passwd *p = getspwnam("nobody");
                         const char *pw = p->pw_passwd;
 ; return 0; }
 EOF
-if { (eval echo configure:6723: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6909: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_hpux_passwd=yes
 else
@@ -6733,7 +6919,7 @@ EOF
 
       # on HPUX, bigcrypt is in -lsec
       echo $ac_n "checking for bigcrypt in -lsec""... $ac_c" 1>&6
-echo "configure:6748: checking for bigcrypt in -lsec" >&5
+echo "configure:6934: checking for bigcrypt in -lsec" >&5
 ac_lib_var=`echo sec'_'bigcrypt | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -6741,7 +6927,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsec  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 6756 "configure"
+#line 6942 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -6752,7 +6938,7 @@ int main() {
 bigcrypt()
 ; return 0; }
 EOF
-if { (eval echo configure:6767: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6953: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6779,7 +6965,7 @@ fi
   #
   if test "$pwent_cruft_done" = no ; then
     echo $ac_n "checking for generic shadow passwords""... $ac_c" 1>&6
-echo "configure:6794: checking for generic shadow passwords" >&5
+echo "configure:6980: checking for generic shadow passwords" >&5
 if eval "test \"`echo '$''{'ac_cv_shadow'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -6790,7 +6976,7 @@ else
   fi
   CPPFLAGS="$CPPFLAGS $X_CFLAGS"
   cat > conftest.$ac_ext <<EOF
-#line 6805 "configure"
+#line 6991 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
                                      #include <unistd.h>
@@ -6802,7 +6988,7 @@ struct spwd *p = getspnam("nobody");
                         const char *pw = p->sp_pwdp;
 ; return 0; }
 EOF
-if { (eval echo configure:6817: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:7003: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_shadow=yes
 else
@@ -6828,7 +7014,7 @@ EOF
       # On some systems (UnixWare 2.1), getspnam() is in -lgen instead of -lc.
       have_getspnam=no
       echo $ac_n "checking for getspnam in -lc""... $ac_c" 1>&6
-echo "configure:6843: checking for getspnam in -lc" >&5
+echo "configure:7029: checking for getspnam in -lc" >&5
 ac_lib_var=`echo c'_'getspnam | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -6836,7 +7022,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lc  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 6851 "configure"
+#line 7037 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -6847,7 +7033,7 @@ int main() {
 getspnam()
 ; return 0; }
 EOF
-if { (eval echo configure:6862: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7048: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6869,7 +7055,7 @@ fi
 
       if test "$have_getspnam" = no ; then
         echo $ac_n "checking for getspnam in -lgen""... $ac_c" 1>&6
-echo "configure:6884: checking for getspnam in -lgen" >&5
+echo "configure:7070: checking for getspnam in -lgen" >&5
 ac_lib_var=`echo gen'_'getspnam | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -6877,7 +7063,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lgen  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 6892 "configure"
+#line 7078 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -6888,7 +7074,7 @@ int main() {
 getspnam()
 ; return 0; }
 EOF
-if { (eval echo configure:6903: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7089: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6919,7 +7105,7 @@ fi
   #
   if test "$pwent_cruft_done" = no ; then
     echo $ac_n "checking for FreeBSD-style shadow passwords""... $ac_c" 1>&6
-echo "configure:6934: checking for FreeBSD-style shadow passwords" >&5
+echo "configure:7120: checking for FreeBSD-style shadow passwords" >&5
 if eval "test \"`echo '$''{'ac_cv_master_passwd'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -6940,7 +7126,7 @@ echo "$ac_t""$ac_cv_master_passwd" 1>&6
   # On some systems (UnixWare 2.1), crypt() is in -lcrypt instead of -lc.
   have_crypt=no
   echo $ac_n "checking for crypt in -lc""... $ac_c" 1>&6
-echo "configure:6955: checking for crypt in -lc" >&5
+echo "configure:7141: checking for crypt in -lc" >&5
 ac_lib_var=`echo c'_'crypt | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -6948,7 +7134,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lc  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 6963 "configure"
+#line 7149 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -6959,7 +7145,7 @@ int main() {
 crypt()
 ; return 0; }
 EOF
-if { (eval echo configure:6974: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7160: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6981,7 +7167,7 @@ fi
 
   if test "$have_crypt" = no ; then
     echo $ac_n "checking for crypt in -lcrypt""... $ac_c" 1>&6
-echo "configure:6996: checking for crypt in -lcrypt" >&5
+echo "configure:7182: checking for crypt in -lcrypt" >&5
 ac_lib_var=`echo crypt'_'crypt | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -6989,7 +7175,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lcrypt  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 7004 "configure"
+#line 7190 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -7000,7 +7186,7 @@ int main() {
 crypt()
 ; return 0; }
 EOF
-if { (eval echo configure:7015: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7201: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -7767,20 +7953,26 @@ eval HACKDIR=${HACKDIR}
 eval HACKDIR=${HACKDIR}
 eval HACKDIR=${HACKDIR}
 
-echo ""
-echo "$warnsep"
-echo ""
-echo '      When you run "make install", the "xscreensaver",'
-echo '      "xscreensaver-demo", and "xscreensaver-command" executables'
-echo "      will be installed in ${bindir}."
-echo ""
-echo "      The various graphics demos (80+ different executables) will"
-echo "      be installed in ${HACKDIR}."
-echo ""
-echo "      If you would prefer the demos to be installed elsewhere"
-echo "      (for example, in a dedicated directory) you should re-run"
-echo "      configure with the --enable-subdir=DIR option.  For more"
-echo "      information, run $0 --help."
-echo ""
-echo "$warnsep"
-echo ""
+# canonicalize slashes.
+bindir=`echo  "${bindir}"  | sed 's@/$@@;s@//*@/@g'`
+HACKDIR=`echo "${HACKDIR}" | sed 's@/$@@;s@//*@/@g'`
+
+if test "${bindir}" = "${HACKDIR}" ; then
+  echo ""
+  echo "$warnsep"
+  echo ""
+  echo '      When you run "make install", the "xscreensaver",'
+  echo '      "xscreensaver-demo", and "xscreensaver-command" executables'
+  echo "      will be installed in ${bindir}."
+  echo ""
+  echo "      The various graphics demos (80+ different executables) will"
+  echo "      also be installed in ${HACKDIR}."
+  echo ""
+  echo "      If you would prefer the demos to be installed elsewhere"
+  echo "      (for example, in a dedicated directory) you should re-run"
+  echo "      configure with the --enable-subdir=DIR option.  For more"
+  echo "      information, run $0 --help."
+  echo ""
+  echo "$warnsep"
+  echo ""
+fi
index d2a64ba22c4ea7bd38b1d95ecbb1094877d3783f..0b6cdaf129eb1c464e7e3b60da8173aad4dc16e8 100644 (file)
@@ -183,6 +183,9 @@ else
   fi
 fi
 
+# canonicalize slashes.
+HACKDIR=`echo "${HACKDIR}" | sed 's@/$@@;s@//*@/@g'`
+
 
 AC_PATH_XTRA
 
@@ -567,6 +570,7 @@ else
   XMU_OBJS=''
   SAVER_LIBS="-lXmu $SAVER_LIBS"
   HACK_LIBS="-lXmu $HACK_LIBS"
+  TOOLKIT_LIBS="-lXmu $TOOLKIT_LIBS"
   AC_DEFINE(HAVE_XMU)
 fi
 
@@ -1035,6 +1039,19 @@ if test "$have_motif" = yes ; then
 fi
 
 
+# Check for _Xsetlocale in -lXintl, since at least some recent versions
+# of Motif (on Linux) need it.
+#
+have_xintl=no
+if test "$have_motif" = yes ; then
+  AC_CHECK_X_LIB(Xintl, _Xsetlocale, [have_xintl=yes], [have_xintl=no],
+                 -lX11 -lXext -lm)
+  if test "$have_xintl" = yes; then
+    TOOLKIT_LIBS="$TOOLKIT_LIBS -lXintl"
+  fi
+fi
+
+
 # check for XPM header.
 #
 have_xpm=no
@@ -1165,6 +1182,24 @@ EOF
     fi
 
 
+    # If it's MesaGL, check to see if it requires -lpthread.
+    #
+    have_pthread=no
+    mesa_requires_pthread=false
+    if test "$ac_have_mesa_gl" = yes; then
+
+      AC_CHECK_LIB(pthread, pthread_create, [have_pthread=yes], [],)
+      if test "$have_pthread" = yes; then
+        AC_CHECK_X_LIB($gl_lib_1, gl_get_thread_context,
+                       [mesa_requires_pthread=yes], [],
+                      $GL_LIBS -lpthread -lX11 -lXext -lm)
+      fi
+
+      if test "$mesa_requires_pthread" = yes; then
+        GL_LIBS="$GL_LIBS -lpthread"
+      fi
+    fi
+
     # Check for OpenGL 1.1 features.
     #
     AC_CHECK_X_LIB($gl_lib_1, glBindTexture, [AC_DEFINE(HAVE_GLBINDTEXTURE)],
@@ -2000,20 +2035,26 @@ eval HACKDIR=${HACKDIR}
 eval HACKDIR=${HACKDIR}
 eval HACKDIR=${HACKDIR}
 
-echo ""
-echo "$warnsep"
-echo ""
-echo '      When you run "make install", the "xscreensaver",'
-echo '      "xscreensaver-demo", and "xscreensaver-command" executables'
-echo "      will be installed in ${bindir}."
-echo ""
-echo "      The various graphics demos (80+ different executables) will"
-echo "      be installed in ${HACKDIR}."
-echo ""
-echo "      If you would prefer the demos to be installed elsewhere"
-echo "      (for example, in a dedicated directory) you should re-run"
-echo "      configure with the --enable-subdir=DIR option.  For more"
-echo "      information, run $0 --help."
-echo ""
-echo "$warnsep"
-echo ""
+# canonicalize slashes.
+bindir=`echo  "${bindir}"  | sed 's@/$@@;s@//*@/@g'`
+HACKDIR=`echo "${HACKDIR}" | sed 's@/$@@;s@//*@/@g'`
+
+if test "${bindir}" = "${HACKDIR}" ; then
+  echo ""
+  echo "$warnsep"
+  echo ""
+  echo '      When you run "make install", the "xscreensaver",'
+  echo '      "xscreensaver-demo", and "xscreensaver-command" executables'
+  echo "      will be installed in ${bindir}."
+  echo ""
+  echo "      The various graphics demos (80+ different executables) will"
+  echo "      also be installed in ${HACKDIR}."
+  echo ""
+  echo "      If you would prefer the demos to be installed elsewhere"
+  echo "      (for example, in a dedicated directory) you should re-run"
+  echo "      configure with the --enable-subdir=DIR option.  For more"
+  echo "      information, run $0 --help."
+  echo ""
+  echo "$warnsep"
+  echo ""
+fi
index ce557228ca27c077b0ecf0aa02fc8eaa6b9eab8c..9f6644385987330e8ed7c46c36b15eea209b793e 100644 (file)
@@ -4,8 +4,8 @@
 !            a screen saver and locker for the X window system
 !                            by Jamie Zawinski
 !
-!                              version 3.06
-!                                22-Nov-98
+!                              version 3.07
+!                                04-Jan-99
 !
 ! See "man xscreensaver" for more info.  The latest version is always
 ! available at http://www.jwz.org/xscreensaver/
                worm -root                                              \n\
                rotor -root                                             \n\
                ant -root                                               \n\
+               demon -root                                             \n\
+               loop -root                                              \n\
                vines -root                                             \n\
                kaleidescope -root                                      \n\
                xjack -root                                             \n\
                rd-bomb -root                                           \n\
                rd-bomb -root -speed 1 -size 0.1                        \n\
                sonar -root                                             \n\
+               t3d -root                                               \n\
                                                                          \
        mono:   rocks -root                                             \n\
        color:  rocks -root -fg darksalmon                              \n\
index b49fc28b3acdf1fe13b0dc25351c97831ce66e31..f5e147930d4aedfa4ddca8ce75db932f62768b6e 100644 (file)
@@ -83,6 +83,8 @@
                worm -root                                              \\n\
                rotor -root                                             \\n\
                ant -root                                               \\n\
+               demon -root                                             \\n\
+               loop -root                                              \\n\
                vines -root                                             \\n\
                kaleidescope -root                                      \\n\
                xjack -root                                             \\n\
                rd-bomb -root                                           \\n\
                rd-bomb -root -speed 1 -size 0.1                        \\n\
                sonar -root                                             \\n\
+               t3d -root                                               \\n\
                                                                          \
        mono:   rocks -root                                             \\n\
        color:  rocks -root -fg darksalmon                              \\n\
index 0a262e0f8559a566b585bd1210e569c031f0a074..6eb2cb1415c74f90efec78c0aa0ea14b69be0244 100644 (file)
@@ -50,11 +50,6 @@ static Bool got_badwindow = False;
 static int
 BadWindow_ehandler (Display *dpy, XErrorEvent *error)
 {
-  /* When we notice a window being created, we spawn a timer that waits
-     30 seconds or so, and then selects events on that window.  This error
-     handler is used so that we can cope with the fact that the window
-     may have been destroyed <30 seconds after it was created.
-   */
   if (error->error_code == BadWindow)
     {
       got_badwindow = True;
index 48f81a35da9d84457813063028ed6e13df8b1216..e3a013182e77645a6a9a8b0d2bb8b2a28ba30285 100644 (file)
@@ -11,7 +11,7 @@
 .if n .sp 1
 .if t .sp .5
 ..
-.TH XScreenSaver 1 "22-Nov-98 (3.06)" "X Version 11"
+.TH XScreenSaver 1 "04-Jan-99 (3.07)" "X Version 11"
 .SH NAME
 xscreensaver-command - control a running xscreensaver process
 .SH SYNOPSIS
index aee5d9e213252c856110e5b9dcd804fa595a375e..bc982e57c8e70c85dd1d6ff81a6c08c84d69427a 100644 (file)
@@ -11,7 +11,7 @@
 .if n .sp 1
 .if t .sp .5
 ..
-.TH XScreenSaver 1 "22-Nov-98 (3.06)" "X Version 11"
+.TH XScreenSaver 1 "04-Jan-99 (3.07)" "X Version 11"
 .SH NAME
 xscreensaver-demo - interactively control the background xscreensaver daemon
 .SH SYNOPSIS
index d1fa594705c1aeba36a11a3b55cae5c4a8e1eda2..000b9d91d694b171fa0d0ded9539c75368b41669 100644 (file)
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 1991-1998 Jamie Zawinski <jwz@jwz.org>
+/* xscreensaver, Copyright (c) 1991-1999 Jamie Zawinski <jwz@jwz.org>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
@@ -288,6 +288,8 @@ saver_ehandler (Display *dpy, XErrorEvent *error)
 {
   saver_info *si = global_si_kludge;   /* I hate C so much... */
 
+  if (!real_stderr) real_stderr = stderr;
+
   fprintf (real_stderr, "\n"
           "#######################################"
           "#######################################\n\n"
@@ -304,11 +306,25 @@ saver_ehandler (Display *dpy, XErrorEvent *error)
        }
       else
        {
-         fprintf(real_stderr,
-                 "%s: to dump a core file, re-run with `-sync'.\n"
-                 "%s: see http://www.jwz.org/xscreensaver/bugs.html\n"
-                 "\t\tfor bug reporting information.\n\n",
-                 blurb(), blurb());
+          fprintf (real_stderr,
+                   "#######################################"
+                   "#######################################\n\n");
+          fprintf (real_stderr,
+   "    If at all possible, please re-run xscreensaver with the command line\n"
+   "    arguments `-sync -verbose', and reproduce this bug.  That will cause\n"
+   "    xscreensaver to dump a `core' file to the current directory.  Please\n"
+   "    include the stack trace from that core file in your bug report.\n"
+   "\n"
+   "    http://www.jwz.org/xscreensaver/bugs.html explains how to create the\n"
+   "    most useful bug reports, and how to examine core files.\n"
+   "\n"
+   "    The more information you can provide, the better.  But please report\n"
+   "    report this bug, regardless!\n"
+   "\n");
+          fprintf (real_stderr,
+                   "#######################################"
+                   "#######################################\n\n");
+
          saver_exit (si, -1, 0);
        }
     }
@@ -317,6 +333,50 @@ saver_ehandler (Display *dpy, XErrorEvent *error)
   return 0;
 }
 
+
+/* This error handler is used only while the X connection is being set up;
+   after we've got a connection, we don't use this handler again.  The only
+   reason for having this is so that we can present a more idiot-proof error
+   message than "cannot open display."
+ */
+static void 
+startup_ehandler (String name, String type, String class,
+                  String defalt,  /* one can't even spel properly
+                                     in this joke of a language */
+                  String *av, Cardinal *ac)
+{
+  char fmt[512];
+  String p[10];
+  saver_info *si = global_si_kludge;   /* I hate C so much... */
+  XrmDatabase *db = XtAppGetErrorDatabase(si->app);
+  *fmt = 0;
+  XtAppGetErrorDatabaseText(si->app, name, type, class, defalt,
+                            fmt, sizeof(fmt)-1, *db);
+
+  fprintf (stderr, "%s: ", blurb());
+
+  memset (p, 0, sizeof(p));
+  if (*ac > countof (p)) *ac = countof (p);
+  memcpy ((char *) p, (char *) av, (*ac) * sizeof(*av));
+  fprintf (stderr, fmt,                /* Did I mention that I hate C? */
+           p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8], p[9]);
+  fprintf (stderr, "\n");
+
+  describe_uids (si, stderr);
+  fprintf (stderr, "\n"
+           "%s: Errors at startup are usually authorization problems.\n"
+           "              Did you read the manual?  Specifically, the parts\n"
+           "              that talk about XAUTH, XDM, and root logins?\n"
+           "\n"
+           "              http://www.jwz.org/xscreensaver/man.html\n"
+           "\n",
+           blurb());
+
+  fflush (stderr);
+  fflush (stdout);
+  exit (1);
+}
+
 \f
 /* The zillions of initializations.
  */
@@ -383,9 +443,12 @@ connect_to_server (saver_info *si, int *argc, char **argv)
   Widget toplevel_shell;
 
   XSetErrorHandler (saver_ehandler);
+
+  XtAppSetErrorMsgHandler (si->app, startup_ehandler);
   toplevel_shell = XtAppInitialize (&si->app, progclass,
                                    options, XtNumber (options),
                                    argc, argv, defaults, 0, 0);
+  XtAppSetErrorMsgHandler (si->app, 0);
 
   si->dpy = XtDisplay (toplevel_shell);
   si->prefs.db = XtDatabase (si->dpy);
index ff978401ea6999d355bc3044fde4c7a6ecee74c0..80aa49c46df4dcdc54b0ee83e3099b9af1332f81 100644 (file)
@@ -11,7 +11,7 @@
 .if n .sp 1
 .if t .sp .5
 ..
-.TH XScreenSaver 1 "22-Nov-98 (3.06)" "X Version 11"
+.TH XScreenSaver 1 "04-Jan-99 (3.07)" "X Version 11"
 .SH NAME
 xscreensaver - graphics hack and screen locker, launched when the user is idle
 .SH SYNOPSIS
@@ -1051,6 +1051,30 @@ alleviated by inserting strategic calls to
 in code intended for use as a screensaver.  This prevents too much graphics
 activity from being buffered up.
 .TP 8
+.B XFree86's Magic Keystrokes
+The XFree86 X server traps certain magic keystrokes before client programs ever
+see them.  Two that are of note are Ctrl+Alt+Backspace, which causes 
+the X server to exit; and Ctrl+Alt+F\fIn\fP, which switches virtual consoles.
+The X server will respond to these keystrokes even if xscreensaver has the
+screen locked.  Depending on your setup, you might consider this a problem.
+
+Unfortunately, there is no way for xscreensaver itself to override the
+interpretation of these keys.  If you want to disable Ctrl+Alt+Backspace
+globally, you need to set the \fIDontZap\fP flag in 
+your \fI/etc/X11/XF86Config\fP file.  See the
+.BR XF86Config (5)
+manual for details.
+
+There is no way (as far as I can tell) to disable the VT-switching keystrokes.
+
+Some Linux systems come with a VT_LOCKSWITCH ioctl, that one could 
+theoretically use to prevent VT-switching while the screen is locked; 
+but unfortunately, this ioctl can only be used by root, which means
+that xscreensaver can't use it (since xscreensaver disavows its privileges
+shortly after startup, for security reasons.)
+
+Any suggestions for other solutions to this problem are welcome.
+.TP 8
 .B XView Clients
 Apparently there are some problems with XView programs getting confused
 and thinking that the screensaver window is the real root window even when
@@ -1136,6 +1160,10 @@ time to do 3D.  But this means that accelerated 3D only happens in full-screen
 mode (you can't do it in a window, and you can't see the output of 3D and 2D
 programs simultaniously), and that 3D will probably drive your monitor at a
 lower resolution, as well.  It's bizarre.
+
+If you find that GL programs only work properly when run as root, and not
+as normal users, then the problem is that your \fI/dev/3dfx\fP file is not
+configured properly.  Check the Linux 3Dfx FAQ.
 .TP 8
 .B Extensions
 If you are not making use of one of the server extensions (\fBXIDLE\fP,
@@ -1274,7 +1302,7 @@ http://www.jwz.org/xscreensaver/
 .BR xv (1),
 .BR xwave (1).
 .SH COPYRIGHT
-Copyright \(co 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998
+Copyright \(co 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999
 by Jamie Zawinski.  Permission to use, copy, modify, distribute, and sell
 this software and its documentation for any purpose is hereby granted without
 fee, provided that the above copyright notice appear in all copies and that
index 78726220a56308b69eb6399b98b070bc6d3994a4..cd3b1752f32e6ac3dd59e70bf943deab438b3a80 100644 (file)
@@ -81,7 +81,7 @@ SRCS          = attraction.c blitspin.c bouboule.c braid.c bubbles.c \
                  rotor.c ant.c xjack.c xlyap.c jigsaw.c xscreensaver-sgigl.c \
                  cynosure.c moire2.c flow.c epicycle.c interference.c \
                  truchet.c bsod.c crystal.c discrete.c distort.c kumppa.c \
-                 sonar.c
+                 sonar.c demon.c loop.c t3d.c
 
 OBJS           = attraction.o blitspin.o bouboule.o braid.o bubbles.o \
                  bubbles-default.o decayscreen.o deco.o drift.o flag.o \
@@ -96,7 +96,7 @@ OBJS          = attraction.o blitspin.o bouboule.o braid.o bubbles.o \
                  rotor.o ant.o xjack.o xlyap.o jigsaw.o xscreensaver-sgigl.o \
                  cynosure.o moire2.o flow.o epicycle.o interference.o \
                  truchet.o bsod.o crystal.o discrete.o distort.o kumppa.o \
-                 sonar.o
+                 sonar.o demon.o loop.o t3d.o
 
 EXES           = attraction blitspin bouboule braid bubbles decayscreen deco \
                  drift flag flame forest vines galaxy grav greynetic halo \
@@ -107,7 +107,7 @@ EXES                = attraction blitspin bouboule braid bubbles decayscreen deco \
                  fadeplot rd-bomb coral mountain triangle lissie worm rotor \
                  ant xjack xlyap jigsaw cynosure moire2 flow epicycle \
                  interference truchet bsod crystal discrete distort kumppa \
-                 sonar
+                 sonar demon loop t3d
 
 HACK_OBJS_1    = $(UTILS_BIN)/resources.o $(UTILS_BIN)/visual.o \
                  $(UTILS_BIN)/usleep.o $(UTILS_BIN)/yarandom.o @XMU_OBJS@
@@ -119,7 +119,7 @@ GRAB_OBJS   = $(GRAB_OBJS_1) $(COLOR_OBJS)
 XSHM_OBJS      = $(UTILS_BIN)/xshm.o
 GRAB_LIBS      = $(SGI_VIDEO_LIBS)
 
-HDRS           = bubbles.h screenhack.h xlockmore.h xlockmoreI.h
+HDRS           = bubbles.h screenhack.h xlockmore.h xlockmoreI.h automata.h
 MEN            = attraction.man blitspin.man bouboule.man braid.man \
                  bubbles.man decayscreen.man deco.man drift.man flag.man \
                  flame.man forest.man vines.man galaxy.man grav.man \
@@ -131,7 +131,7 @@ MEN         = attraction.man blitspin.man bouboule.man braid.man \
                  slip.man sphere.man spiral.man strange.man swirl.man \
                  xroger.man goop.man starfish.man munch.man rd-bomb.man \
                  xjack.man xlyap.man jigsaw.man epicycle.man bsod.man \
-                 sonar.man
+                 sonar.man t3d.man
 STAR           = *
 EXTRAS         = README Makefile.in xlock_23.h .gdbinit \
                  vidwhacker \
@@ -339,125 +339,128 @@ xscreensaver-sgigl: xscreensaver-sgigl.c
 # is pretty much useless in the face of more than one dependency, as far
 # as I can tell.
 #
-attraction:             $(HACK_OBJS) attraction.o $(COL) $(SPL)
-       $(CC_HACK) -o $@ $(HACK_OBJS) attraction.o $(COL) $(SPL) $(HACK_LIBS)
+attraction:    attraction.o    $(HACK_OBJS) $(COL) $(SPL)
+       $(CC_HACK) -o $@ $@.o   $(HACK_OBJS) $(COL) $(SPL) $(HACK_LIBS)
 
-blitspin:               $(HACK_OBJS) blitspin.o $(GRAB)
-       $(CC_HACK) -o $@ $(HACK_OBJS) blitspin.o $(GRAB) $(XPM_LIBS) $(GRAB_LIBS)
+blitspin:      blitspin.o      $(HACK_OBJS) $(GRAB)
+       $(CC_HACK) -o $@ $@.o   $(HACK_OBJS) $(GRAB) $(XPM_LIBS) $(GRAB_LIBS)
 
-bubbles:                $(HACK_OBJS) bubbles.o bubbles-default.o 
-       $(CC_HACK) -o $@ $(HACK_OBJS) bubbles.o bubbles-default.o $(XPM_LIBS)
+bubbles:       bubbles.o       $(HACK_OBJS) bubbles-default.o 
+       $(CC_HACK) -o $@ $@.o   $(HACK_OBJS) bubbles-default.o $(XPM_LIBS)
 
-decayscreen:            $(HACK_OBJS) decayscreen.o $(GRAB)
-       $(CC_HACK) -o $@ $(HACK_OBJS) decayscreen.o $(GRAB) $(HACK_LIBS) $(GRAB_LIBS)
+decayscreen:   decayscreen.o   $(HACK_OBJS) $(GRAB)
+       $(CC_HACK) -o $@ $@.o   $(HACK_OBJS) $(GRAB) $(HACK_LIBS) $(GRAB_LIBS)
 
-deco:                   $(HACK_OBJS) deco.o $(COL)
-       $(CC_HACK) -o $@ $(HACK_OBJS) deco.o $(COL) $(HACK_LIBS)
+deco:          deco.o          $(HACK_OBJS) $(COL)
+       $(CC_HACK) -o $@ $@.o   $(HACK_OBJS) $(COL) $(HACK_LIBS)
 
-flame:                  $(HACK_OBJS) flame.o $(COL)
-       $(CC_HACK) -o $@ $(HACK_OBJS) flame.o $(COL) $(HACK_LIBS)
+flame:         flame.o         $(HACK_OBJS) $(COL)
+       $(CC_HACK) -o $@ $@.o   $(HACK_OBJS) $(COL) $(HACK_LIBS)
 
-greynetic:              $(HACK_OBJS) greynetic.o
-       $(CC_HACK) -o $@ $(HACK_OBJS) greynetic.o $(HACK_LIBS)
+greynetic:     greynetic.o     $(HACK_OBJS)
+       $(CC_HACK) -o $@ $@.o   $(HACK_OBJS) $(HACK_LIBS)
 
-halo:                   $(HACK_OBJS) halo.o $(COL)
-       $(CC_HACK) -o $@ $(HACK_OBJS) halo.o $(COL) $(HACK_LIBS)
+halo:          halo.o          $(HACK_OBJS) $(COL)
+       $(CC_HACK) -o $@ $@.o   $(HACK_OBJS) $(COL) $(HACK_LIBS)
 
-helix:                  $(HACK_OBJS) helix.o $(HSV) $(ERASE)
-       $(CC_HACK) -o $@ $(HACK_OBJS) helix.o $(HSV) $(ERASE) $(HACK_LIBS)
+helix:         helix.o         $(HACK_OBJS) $(HSV) $(ERASE)
+       $(CC_HACK) -o $@ $@.o   $(HACK_OBJS) $(HSV) $(ERASE) $(HACK_LIBS)
 
-hypercube:              $(HACK_OBJS) hypercube.o
-       $(CC_HACK) -o $@ $(HACK_OBJS) hypercube.o $(HACK_LIBS)
+hypercube:     hypercube.o     $(HACK_OBJS)
+       $(CC_HACK) -o $@ $@.o   $(HACK_OBJS) $(HACK_LIBS)
 
-imsmap:                         $(HACK_OBJS) imsmap.o $(COL)
-       $(CC_HACK) -o $@ $(HACK_OBJS) imsmap.o $(COL) $(HACK_LIBS)
+imsmap:                imsmap.o        $(HACK_OBJS) $(COL)
+       $(CC_HACK) -o $@ $@.o   $(HACK_OBJS) $(COL) $(HACK_LIBS)
 
-kaleidescope:           $(HACK_OBJS) kaleidescope.o
-       $(CC_HACK) -o $@ $(HACK_OBJS) kaleidescope.o $(HACK_LIBS)
+kaleidescope:  kaleidescope.o  $(HACK_OBJS)
+       $(CC_HACK) -o $@ $@.o   $(HACK_OBJS) $(HACK_LIBS)
 
-lmorph:                         $(HACK_OBJS) lmorph.o
-       $(CC_HACK) -o $@ $(HACK_OBJS) lmorph.o $(HACK_LIBS)
+lmorph:                lmorph.o        $(HACK_OBJS)
+       $(CC_HACK) -o $@ $@.o   $(HACK_OBJS) $(HACK_LIBS)
 
-maze:                   $(HACK_OBJS) maze.o $(ERASE) $(XROG)
-       $(CC_HACK) -o $@ $(HACK_OBJS) maze.o $(ERASE) $(XROG) $(HACK_LIBS)
+maze:          maze.o          $(HACK_OBJS) $(ERASE) $(XROG)
+       $(CC_HACK) -o $@ $@.o   $(HACK_OBJS) $(ERASE) $(XROG) $(HACK_LIBS)
 
-moire:                  $(HACK_OBJS) moire.o $(COL) $(SHM)
-       $(CC_HACK) -o $@ $(HACK_OBJS) moire.o $(COL) $(SHM) $(HACK_LIBS)
+moire:         moire.o         $(HACK_OBJS) $(COL) $(SHM)
+       $(CC_HACK) -o $@ $@.o   $(HACK_OBJS) $(COL) $(SHM) $(HACK_LIBS)
 
-moire2:                         $(HACK_OBJS) moire2.o $(COL)
-       $(CC_HACK) -o $@ $(HACK_OBJS) moire2.o $(COL) $(HACK_LIBS)
+moire2:                moire2.o        $(HACK_OBJS) $(COL)
+       $(CC_HACK) -o $@ $@.o   $(HACK_OBJS) $(COL) $(HACK_LIBS)
 
-noseguy:                $(HACK_OBJS) noseguy.o
-       $(CC_HACK) -o $@ $(HACK_OBJS) noseguy.o $(XPM_LIBS)
+noseguy:       noseguy.o       $(HACK_OBJS)
+       $(CC_HACK) -o $@ $@.o   $(HACK_OBJS) $(XPM_LIBS)
 
-pedal:                  $(HACK_OBJS) pedal.o $(HSV)
-       $(CC_HACK) -o $@ $(HACK_OBJS) pedal.o $(HSV) $(HACK_LIBS)
+pedal:         pedal.o         $(HACK_OBJS) $(HSV)
+       $(CC_HACK) -o $@ $@.o   $(HACK_OBJS) $(HSV) $(HACK_LIBS)
 
-pyro:                   $(HACK_OBJS) pyro.o $(HSV)
-       $(CC_HACK) -o $@ $(HACK_OBJS) pyro.o $(HSV) $(HACK_LIBS)
+pyro:          pyro.o          $(HACK_OBJS) $(HSV)
+       $(CC_HACK) -o $@ $@.o   $(HACK_OBJS) $(HSV) $(HACK_LIBS)
 
-qix:                    $(HACK_OBJS) qix.o $(ALP)
-       $(CC_HACK) -o $@ $(HACK_OBJS) qix.o $(ALP) $(HACK_LIBS)
+qix:           qix.o           $(HACK_OBJS) $(ALP)
+       $(CC_HACK) -o $@ $@.o   $(HACK_OBJS) $(ALP) $(HACK_LIBS)
 
-rocks:                  $(HACK_OBJS) rocks.o $(COL)
-       $(CC_HACK) -o $@ $(HACK_OBJS) rocks.o $(COL) $(HACK_LIBS)
+rocks:         rocks.o         $(HACK_OBJS) $(COL)
+       $(CC_HACK) -o $@ $@.o   $(HACK_OBJS) $(COL) $(HACK_LIBS)
 
-rorschach:              $(HACK_OBJS) rorschach.o $(HSV) $(ERASE)
-       $(CC_HACK) -o $@ $(HACK_OBJS) rorschach.o $(HSV) $(ERASE) $(HACK_LIBS)
+rorschach:     rorschach.o     $(HACK_OBJS) $(HSV) $(ERASE)
+       $(CC_HACK) -o $@ $@.o   $(HACK_OBJS) $(HSV) $(ERASE) $(HACK_LIBS)
 
-slidescreen:            $(HACK_OBJS) slidescreen.o $(GRAB)
-       $(CC_HACK) -o $@ $(HACK_OBJS) slidescreen.o $(GRAB) $(HACK_LIBS) $(GRAB_LIBS)
+slidescreen:   slidescreen.o   $(HACK_OBJS) $(GRAB)
+       $(CC_HACK) -o $@ $@.o   $(HACK_OBJS) $(GRAB) $(HACK_LIBS) $(GRAB_LIBS)
 
-xroger:                         $(HACK_OBJS) xroger-hack.o $(HSV) $(XROG)
-       $(CC_HACK) -o $@ $(HACK_OBJS) xroger-hack.o $(HSV) $(XROG) $(HACK_LIBS)
+xroger:                xroger-hack.o   $(HACK_OBJS) $(HSV) $(XROG)
+       $(CC_HACK) -o $@ xroger-hack.o  $(HACK_OBJS) $(HSV) $(XROG) $(HACK_LIBS)
 
-goop:                   $(HACK_OBJS) goop.o $(ALP) $(SPL)
-       $(CC_HACK) -o $@ $(HACK_OBJS) goop.o $(ALP) $(SPL) $(HACK_LIBS)
+goop:          goop.o          $(HACK_OBJS) $(ALP) $(SPL)
+       $(CC_HACK) -o $@ $@.o   $(HACK_OBJS) $(ALP) $(SPL) $(HACK_LIBS)
 
-starfish:               $(HACK_OBJS) starfish.o $(COL) $(SPL)
-       $(CC_HACK) -o $@ $(HACK_OBJS) starfish.o $(COL) $(SPL) $(HACK_LIBS)
+starfish:      starfish.o      $(HACK_OBJS) $(COL) $(SPL)
+       $(CC_HACK) -o $@ $@.o   $(HACK_OBJS) $(COL) $(SPL) $(HACK_LIBS)
 
-munch:                  $(HACK_OBJS) munch.o $(COL) $(SPL)
-       $(CC_HACK) -o $@ $(HACK_OBJS) munch.o $(COL) $(SPL) $(HACK_LIBS)
+munch:         munch.o         $(HACK_OBJS) $(COL) $(SPL)
+       $(CC_HACK) -o $@ $@.o   $(HACK_OBJS) $(COL) $(SPL) $(HACK_LIBS)
 
-rd-bomb:                $(HACK_OBJS) rd-bomb.o $(COL) $(SHM)
-       $(CC_HACK) -o $@ $(HACK_OBJS) rd-bomb.o $(COL) $(SHM) $(HACK_LIBS)
+rd-bomb:       rd-bomb.o       $(HACK_OBJS) $(COL) $(SHM)
+       $(CC_HACK) -o $@ $@.o   $(HACK_OBJS) $(COL) $(SHM) $(HACK_LIBS)
 
-coral: $(HACK_OBJS) coral.o $(COL) $(ERASE)
-       $(CC_HACK) -o $@ $(HACK_OBJS) coral.o $(COL) $(ERASE) $(HACK_LIBS)
+coral:         coral.o         $(HACK_OBJS) $(COL) $(ERASE)
+       $(CC_HACK) -o $@ $@.o   $(HACK_OBJS) $(COL) $(ERASE) $(HACK_LIBS)
 
-xjack: $(HACK_OBJS) xjack.o
-       $(CC_HACK) -o $@ $(HACK_OBJS) xjack.o $(HACK_LIBS)
+xjack:         xjack.o         $(HACK_OBJS)
+       $(CC_HACK) -o $@ $@.o   $(HACK_OBJS) $(HACK_LIBS)
 
-xlyap: $(HACK_OBJS) xlyap.o $(COL)
-       $(CC_HACK) -o $@ $(HACK_OBJS) xlyap.o $(COL) $(HACK_LIBS)
+xlyap:         xlyap.o         $(HACK_OBJS) $(COL)
+       $(CC_HACK) -o $@ $@.o   $(HACK_OBJS) $(COL) $(HACK_LIBS)
 
-jigsaw: $(HACK_OBJS) jigsaw.o $(GRAB)
-       $(CC_HACK) -o $@ $(HACK_OBJS) jigsaw.o $(GRAB) $(HACK_LIBS) $(GRAB_LIBS)
+jigsaw:                jigsaw.o        $(HACK_OBJS) $(GRAB)
+       $(CC_HACK) -o $@ $@.o   $(HACK_OBJS) $(GRAB) $(HACK_LIBS) $(GRAB_LIBS)
 
-cynosure: $(HACK_OBJS) cynosure.o $(COL)
-       $(CC_HACK) -o $@ $(HACK_OBJS) cynosure.o $(COL) $(HACK_LIBS)
+cynosure:      cynosure.o      $(HACK_OBJS) $(COL)
+       $(CC_HACK) -o $@ $@.o   $(HACK_OBJS) $(COL) $(HACK_LIBS)
 
-epicycle: $(HACK_OBJS) epicycle.o $(COL) $(ERASE)
-       $(CC_HACK) -o $@ $(HACK_OBJS) epicycle.o $(COL) $(ERASE) $(HACK_LIBS)
+epicycle:      epicycle.o      $(HACK_OBJS) $(COL) $(ERASE)
+       $(CC_HACK) -o $@ $@.o   $(HACK_OBJS) $(COL) $(ERASE) $(HACK_LIBS)
 
-interference: $(HACK_OBJS) interference.o $(COL) $(SHM)
-       $(CC_HACK) -o $@ $(HACK_OBJS) interference.o $(COL) $(SHM) $(HACK_LIBS)
+interference:  interference.o  $(HACK_OBJS) $(COL) $(SHM)
+       $(CC_HACK) -o $@ $@.o   $(HACK_OBJS) $(COL) $(SHM) $(HACK_LIBS)
 
-truchet: $(HACK_OBJS) truchet.o $(COL)
-       $(CC_HACK) -o $@ $(HACK_OBJS) truchet.o $(COL) $(HACK_LIBS)
+truchet:        truchet.o      $(HACK_OBJS) $(COL)
+       $(CC_HACK) -o $@ $@.o   $(HACK_OBJS) $(COL) $(HACK_LIBS)
 
-bsod: $(HACK_OBJS) bsod.o $(COL)
-       $(CC_HACK) -o $@ $(HACK_OBJS) bsod.o $(COL) $(HACK_LIBS) $(XPM_LIBS)
+bsod:          bsod.o          $(HACK_OBJS) $(COL)
+       $(CC_HACK) -o $@ $@.o   $(HACK_OBJS) $(COL) $(HACK_LIBS) $(XPM_LIBS)
 
-distort:                $(HACK_OBJS) distort.o $(GRAB) $(SHM)
-       $(CC_HACK) -o $@ $(HACK_OBJS) distort.o $(GRAB) $(SHM) $(HACK_LIBS) $(GRAB_LIBS)
+distort:       distort.o       $(HACK_OBJS) $(GRAB) $(SHM)
+       $(CC_HACK) -o $@ $@.o   $(HACK_OBJS) $(GRAB) $(SHM) $(HACK_LIBS) $(GRAB_LIBS)
 
-kumppa:                 $(HACK_OBJS) kumppa.o
-       $(CC_HACK) -o $@ $(HACK_OBJS) kumppa.o $(HACK_LIBS)
+kumppa:                kumppa.o        $(HACK_OBJS)
+       $(CC_HACK) -o $@ $@.o   $(HACK_OBJS) $(HACK_LIBS)
 
-sonar:          $(HACK_OBJS) sonar.o $(COL)
-       $(CC_HACK) -o $@ $(HACK_OBJS) sonar.o $(COL) $(HACK_LIBS)
+sonar:         sonar.o         $(HACK_OBJS) $(COL)
+       $(CC_HACK) -o $@ $@.o   $(HACK_OBJS) $(COL) $(HACK_LIBS)
+
+t3d:           t3d.o           $(HACK_OBJS) $(COL)
+       $(CC_HACK) -o $@ $@.o   $(HACK_OBJS) $(COL) $(HACK_LIBS)
 
 
 # The rules for those hacks which follow the `xlockmore' API.
@@ -547,6 +550,12 @@ rotor:             rotor.o         $(XLOCK_OBJS)
 ant:           ant.o           $(XLOCK_OBJS) $(ERASE)
        $(CC_HACK) -o $@ $@.o   $(XLOCK_OBJS) $(ERASE) $(HACK_LIBS)
 
+demon:         demon.o         $(XLOCK_OBJS)
+       $(CC_HACK) -o $@ $@.o   $(XLOCK_OBJS) $(HACK_LIBS)
+
+loop:          loop.o          $(XLOCK_OBJS)
+       $(CC_HACK) -o $@ $@.o   $(XLOCK_OBJS) $(HACK_LIBS)
+
 flow:          flow.o          $(XLOCK_OBJS)
        $(CC_HACK) -o $@ $@.o   $(XLOCK_OBJS) $(HACK_LIBS)
 
@@ -1249,6 +1258,7 @@ ant.o: $(UTILS_SRC)/grabscreen.h
 ant.o: $(UTILS_SRC)/visual.h
 ant.o: $(UTILS_SRC)/xshm.h
 ant.o: $(UTILS_SRC)/erase.h
+ant.o: $(srcdir)/automata.h
 xjack.o: $(srcdir)/screenhack.h
 xjack.o: ../config.h
 xjack.o: $(UTILS_SRC)/yarandom.h
@@ -1438,4 +1448,39 @@ sonar.o: $(UTILS_SRC)/hsv.h
 sonar.o: $(UTILS_SRC)/colors.h
 sonar.o: $(UTILS_SRC)/grabscreen.h
 sonar.o: $(UTILS_SRC)/visual.h
+demon.o: $(srcdir)/xlockmore.h
+demon.o: ../config.h
+demon.o: $(srcdir)/xlockmoreI.h
+demon.o: $(srcdir)/screenhack.h
+demon.o: $(UTILS_SRC)/yarandom.h
+demon.o: $(UTILS_SRC)/usleep.h
+demon.o: $(UTILS_SRC)/resources.h
+demon.o: $(UTILS_SRC)/hsv.h
+demon.o: $(UTILS_SRC)/colors.h
+demon.o: $(UTILS_SRC)/grabscreen.h
+demon.o: $(UTILS_SRC)/visual.h
+demon.o: $(UTILS_SRC)/xshm.h
+demon.o: $(srcdir)/automata.h
+loop.o: $(srcdir)/xlockmore.h
+loop.o: ../config.h
+loop.o: $(srcdir)/xlockmoreI.h
+loop.o: $(srcdir)/screenhack.h
+loop.o: $(UTILS_SRC)/yarandom.h
+loop.o: $(UTILS_SRC)/usleep.h
+loop.o: $(UTILS_SRC)/resources.h
+loop.o: $(UTILS_SRC)/hsv.h
+loop.o: $(UTILS_SRC)/colors.h
+loop.o: $(UTILS_SRC)/grabscreen.h
+loop.o: $(UTILS_SRC)/visual.h
+loop.o: $(UTILS_SRC)/xshm.h
+loop.o: $(srcdir)/automata.h
+t3d.o: $(srcdir)/screenhack.h
+t3d.o: ../config.h
+t3d.o: $(UTILS_SRC)/yarandom.h
+t3d.o: $(UTILS_SRC)/usleep.h
+t3d.o: $(UTILS_SRC)/resources.h
+t3d.o: $(UTILS_SRC)/hsv.h
+t3d.o: $(UTILS_SRC)/colors.h
+t3d.o: $(UTILS_SRC)/grabscreen.h
+t3d.o: $(UTILS_SRC)/visual.h
 
index 91be6445c49ea75c555b606dbf13fb4d368e0d7e..db76bfd3cead828c6ab22d9d7abaf6d6a87acfc1 100644 (file)
@@ -68,9 +68,10 @@ static const char sccsid[] = "@(#)ant.c      4.11 98/06/18 xlockmore";
 # include "erase.h"
 #else /* STANDALONE */
 # include "xlock.h"            /* in xlockmore distribution */
-# include "automata.h"
 #endif /* STANDALONE */
 
+#include "automata.h"
+
 /*-
  * neighbors of 0 randomizes it between 3, 4 and 6.
  * 8, 9 12 are available also but not recommended.
@@ -141,52 +142,6 @@ ModStruct   ant_description =
 #define MINRANDOMSIZE 5
 #define ANGLES 360
 
-#ifdef STANDALONE
-
-#define NUMSTIPPLES 11
-#define STIPPLESIZE 8
-
-static XPoint hexagonUnit[6] =
-{
-       {0, 0},
-       {1, 1},
-       {0, 2},
-       {-1, 1},
-       {-1, -1},
-       {0, -2}
-};
-
-static XPoint triangleUnit[2][3] =
-{
-       {
-               {0, 0},
-               {1, -1},
-               {0, 2}
-       },
-       {
-               {0, 0},
-               {-1, 1},
-               {0, -2}
-       }
-};
-
-
-static unsigned char stipples[NUMSTIPPLES][STIPPLESIZE] =
-{
-       {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},       /* white */
-       {0x11, 0x22, 0x11, 0x22, 0x11, 0x22, 0x11, 0x22},       /* grey+white | stripe */
-       {0x00, 0x66, 0x66, 0x00, 0x00, 0x66, 0x66, 0x00},       /* spots */
-       {0x88, 0x44, 0x22, 0x11, 0x88, 0x44, 0x22, 0x11},       /* lt. / stripe */
-       {0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66},       /* | bars */
-       {0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa},       /* 50% grey */
-       {0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00},       /* - bars */
-       {0xee, 0xdd, 0xbb, 0x77, 0xee, 0xdd, 0xbb, 0x77},       /* dark \ stripe */
-       {0xff, 0x99, 0x99, 0xff, 0xff, 0x99, 0x99, 0xff},       /* spots */
-       {0xaa, 0xff, 0xff, 0x55, 0xaa, 0xff, 0xff, 0x55},       /* black+grey - stripe */
-       {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}        /* black */
-};
-
-#endif /* STANDALONE */
 
 typedef struct {
        unsigned char color;
diff --git a/hacks/automata.h b/hacks/automata.h
new file mode 100644 (file)
index 0000000..b35f542
--- /dev/null
@@ -0,0 +1,61 @@
+/* -*- Mode: C; tab-width: 4 -*- */
+/*-
+ * automata.c - special stuff for automata modes
+ *
+ * Copyright (c) 1995 by David Bagley.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation.
+ *
+ * This file is provided AS IS with no warranties of any kind.  The author
+ * shall have no liability with respect to the infringement of copyrights,
+ * trade secrets or any patents by this file or any part thereof.  In no
+ * event will the author be liable for any lost revenue or profits or
+ * other special, indirect and consequential damages.
+ */
+
+#define NUMSTIPPLES 11
+#define STIPPLESIZE 8
+
+static XPoint hexagonUnit[6] =
+{
+       {0, 0},
+       {1, 1},
+       {0, 2},
+       {-1, 1},
+       {-1, -1},
+       {0, -2}
+};
+
+static XPoint triangleUnit[2][3] =
+{
+       {
+               {0, 0},
+               {1, -1},
+               {0, 2}
+       },
+       {
+               {0, 0},
+               {-1, 1},
+               {0, -2}
+       }
+};
+
+
+static unsigned char stipples[NUMSTIPPLES][STIPPLESIZE] =
+{
+       {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},       /* white */
+       {0x11, 0x22, 0x11, 0x22, 0x11, 0x22, 0x11, 0x22},       /* grey+white | stripe */
+       {0x00, 0x66, 0x66, 0x00, 0x00, 0x66, 0x66, 0x00},       /* spots */
+       {0x88, 0x44, 0x22, 0x11, 0x88, 0x44, 0x22, 0x11},       /* lt. / stripe */
+       {0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66},       /* | bars */
+       {0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa},       /* 50% grey */
+       {0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00},       /* - bars */
+       {0xee, 0xdd, 0xbb, 0x77, 0xee, 0xdd, 0xbb, 0x77},       /* dark \ stripe */
+       {0xff, 0x99, 0x99, 0xff, 0xff, 0x99, 0x99, 0xff},       /* spots */
+       {0xaa, 0xff, 0xff, 0x55, 0xaa, 0xff, 0xff, 0x55},       /* black+grey - stripe */
+       {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}        /* black */
+};
index fc329272e07499fea3ba5d77965253a3bb64cf9e..ddd0a496738a5e4e585dbbd2735d6cd618ca66f1 100644 (file)
@@ -11,6 +11,7 @@ $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS
 $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) CYNOSURE.C
 $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) DECAYSCREEN.C
 $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) DECO.C
+$ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) DEMON.C
 $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) DISCRETE.C
 $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) DISTORT.C
 $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) DRIFT.C
@@ -40,6 +41,7 @@ $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS
 $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) LISA.C
 $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) LISSIE.C
 $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) LMORPH.C
+$ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) LOOP.C
 $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) MAZE.C
 $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) MOIRE.C
 $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) MOIRE2.C
@@ -64,6 +66,7 @@ $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS
 $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) STARFISH.C
 $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) STRANGE.C
 $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) SWIRL.C
+$ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) T3D.C
 $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) TRIANGLE.C
 $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) TRUCHET.C
 $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) VINES.C
index fc329272e07499fea3ba5d77965253a3bb64cf9e..ddd0a496738a5e4e585dbbd2735d6cd618ca66f1 100644 (file)
@@ -11,6 +11,7 @@ $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS
 $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) CYNOSURE.C
 $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) DECAYSCREEN.C
 $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) DECO.C
+$ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) DEMON.C
 $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) DISCRETE.C
 $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) DISTORT.C
 $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) DRIFT.C
@@ -40,6 +41,7 @@ $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS
 $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) LISA.C
 $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) LISSIE.C
 $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) LMORPH.C
+$ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) LOOP.C
 $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) MAZE.C
 $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) MOIRE.C
 $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) MOIRE2.C
@@ -64,6 +66,7 @@ $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS
 $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) STARFISH.C
 $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) STRANGE.C
 $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) SWIRL.C
+$ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) T3D.C
 $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) TRIANGLE.C
 $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) TRUCHET.C
 $ CC/DECC/PREFIX=ALL/DEFINE=(VMS,HAVE_CONFIG_H,STANDALONE)/INCL=([],[-],[-.UTILS]) VINES.C
index 4c4d5fbe61707bd8d44c9e00b1801c3c82560917..7041e5c4cccee352aca085963a35f2349d73d42a 100644 (file)
@@ -27,7 +27,14 @@ static const char sccsid[] = "@(#)crystal.c  4.12 98/09/10 xlockmore";
  *
  * A moving polygon-mode. The polygons obey 2D-planegroup symmetry.
  *
+ * The groupings of the cells fall in 3 categories:
+ *   oblique groups 1 and 2 where the angle gamma ranges from 60 to 120 degrees
+ *   square groups 3 through 11 where the angle gamma is 90 degrees
+ *   hexagonal groups 12 through 17 where the angle gamma is 120 degrees
+ *
  * Revision History:
+ * 03-Dec-98: Random inversion of y-axis included to simulate hexagonal groups
+ *             with an angle of 60 degrees.
  * 10-Sep-98: new colour scheme
  * 24-Feb-98: added option centre which turns on/off forcing the centre of
  *              the screen to be used
@@ -77,6 +84,7 @@ static const char sccsid[] = "@(#)crystal.c   4.12 98/09/10 xlockmore";
 # include "xlockmore.h"                /* in xscreensaver distribution */
 #else /* STANDALONE */
 # include "xlock.h"                    /* in xlockmore distribution */
+# include "color.h"
 #endif /* STANDALONE */
 
 #define DEF_CELL "True"                /* Draw unit cell */
@@ -91,7 +99,9 @@ static const char sccsid[] = "@(#)crystal.c   4.12 98/09/10 xlockmore";
 
 #define min(a,b) ((a) <= (b) ? (a) : (b))
 
+#ifdef STANDALONE
 void release_crystal(ModeInfo * mi);
+#endif
 
 static int  nx, ny;
 
@@ -259,7 +269,7 @@ typedef struct {
        int         ncolors;
        Bool        cycle_p, mono_p, no_colors;
        unsigned long blackpixel, whitepixel, fg, bg;
-       int         direction;
+       int         direction, invert;
 } crystalstruct;
 
 static crystalstruct *crystals = NULL;
@@ -279,7 +289,8 @@ trans_coor(XPoint * xyp, XPoint * new_xyp, int num_points,
 
 static void
 trans_coor_back(XPoint * xyp, XPoint * new_xyp,
-               int num_points, float gamma, int offset_w, int offset_h)
+               int num_points, float gamma, int offset_w, int offset_h ,
+               int winheight , int invert )
 {
        int         i;
 
@@ -288,6 +299,7 @@ trans_coor_back(XPoint * xyp, XPoint * new_xyp,
                        offset_h;
                new_xyp[i].x = xyp[i].x - (int) (xyp[i].y * sin((gamma - 90.0)
                                                       * PI_RAD)) + offset_w;
+          if ( invert ) new_xyp[i].y = winheight - new_xyp[i].y;
        }
 }
 
@@ -453,7 +465,10 @@ crystal_drawatom(ModeInfo * mi, crystalatom * atom0)
                                        xy_1[k].y = xy[k].y + m * cryst->b;
                                }
                                trans_coor_back(xy_1, new_xy, atom0->num_point,
-                                               cryst->gamma, cryst->offset_w, cryst->offset_h);
+                                               cryst->gamma, cryst->offset_w,
+                                               cryst->offset_h ,
+                                               cryst->win_height,
+                                               cryst->invert);
                                XFillPolygon(display, window, cryst->gc, new_xy,
                                  atom0->num_point, Convex, CoordModeOrigin);
                        }
@@ -471,7 +486,11 @@ crystal_drawatom(ModeInfo * mi, crystalatom * atom0)
                                                xy_1[k].y = xy[k].y + m * cryst->b;
                                        }
                                        trans_coor_back(xy_1, new_xy, atom0->num_point,
-                                                       cryst->gamma, cryst->offset_w, cryst->offset_h);
+                                                       cryst->gamma,
+                                                       cryst->offset_w,
+                                                       cryst->offset_h ,
+                                                       cryst->win_height ,
+                                                       cryst->invert);
                                        XFillPolygon(display, window, cryst->gc,
                                                     new_xy,
                                                     atom0->num_point, Convex,
@@ -500,7 +519,11 @@ crystal_drawatom(ModeInfo * mi, crystalatom * atom0)
                                                xy_1[k].y = xy[k].y + m * cryst->b;
                                        }
                                        trans_coor_back(xy_1, new_xy, atom0->num_point,
-                                                       cryst->gamma, cryst->offset_w, cryst->offset_h);
+                                                       cryst->gamma,
+                                                       cryst->offset_w,
+                                                       cryst->offset_h ,
+                                                       cryst->win_height,
+                                                       cryst->invert);
                                        XFillPolygon(display, window, cryst->gc,
                                                     new_xy,
                                                     atom0->num_point, Convex,
@@ -522,7 +545,11 @@ crystal_drawatom(ModeInfo * mi, crystalatom * atom0)
                                                        xy_1[k].y = xy1[k].y + m * cryst->b;
                                                }
                                                trans_coor_back(xy_1, new_xy, atom0->num_point,
-                                                               cryst->gamma, cryst->offset_w, cryst->offset_h);
+                                                               cryst->gamma,
+                                                               cryst->offset_w,
+                                                               cryst->offset_h ,
+                                                               cryst->win_height,
+                                                               cryst->invert);
                                                XFillPolygon(display, window,
                                                             cryst->gc,
                                                    new_xy, atom0->num_point,
@@ -561,7 +588,11 @@ draw_crystal(ModeInfo * mi)
                crystalatom *atom0;
 
                atom0 = &cryst->atom[i];
-               XSetForeground(display, cryst->gc, cryst->colors[atom0->colour].pixel);
+               if (MI_IS_INSTALL(mi) && MI_NPIXELS(mi) > 2) {
+                       XSetForeground(display, cryst->gc, cryst->colors[atom0->colour].pixel);
+               } else {
+                       XSetForeground(display, cryst->gc, atom0->colour);
+               }
                crystal_drawatom(mi, atom0);
                atom0->velocity[0] += NRAND(3) - 1;
                atom0->velocity[0] = MAX(-20, MIN(20, atom0->velocity[0]));
@@ -601,74 +632,154 @@ refresh_crystal(ModeInfo * mi)
        XSetFunction(display, cryst->gc, GXxor);
 
        if (cryst->unit_cell) {
+          int y_coor1 , y_coor2;
+          
                if (MI_NPIXELS(mi) > 2)
                        XSetForeground(display, cryst->gc, MI_PIXEL(mi, NRAND(MI_NPIXELS(mi))));
                else
-                       XSetForeground(display, cryst->gc, MI_BLACK_PIXEL(mi));
+                       XSetForeground(display, cryst->gc, MI_WHITE_PIXEL(mi));
                if (cryst->grid_cell) {
                        int         inx, iny;
 
+                  if ( cryst->invert )
+                    y_coor1 = y_coor2 = cryst->win_height - cryst->offset_h;
+                  else
+                    y_coor1 = y_coor2 = cryst->offset_h;
                        XDrawLine(display, window, cryst->gc, cryst->offset_w,
-                                 cryst->offset_h, cryst->offset_w + cryst->nx * cryst->a,
-                                 cryst->offset_h);
+                                 y_coor1, cryst->offset_w + cryst->nx * cryst->a,
+                                 y_coor2);
+                  if ( cryst->invert )
+                    {
+                       y_coor1 = cryst->win_height - cryst->offset_h;
+                       y_coor2 = cryst->win_height - (int) (cryst->ny *
+                                                            cryst->b *
+                                        cos((cryst->gamma - 90) * PI_RAD)) -
+                         cryst->offset_h;
+                    }
+                  else
+                    {
+                       y_coor1 = cryst->offset_h;
+                       y_coor2 = (int) (cryst->ny * cryst->b *
+                                        cos((cryst->gamma - 90) * PI_RAD)) +
+                         cryst->offset_h;
+                    }
                        XDrawLine(display, window, cryst->gc, cryst->offset_w,
-                                 cryst->offset_h, (int) (cryst->offset_w - cryst->ny * cryst->b *
+                                 y_coor1, (int) (cryst->offset_w - cryst->ny * cryst->b *
                                          sin((cryst->gamma - 90) * PI_RAD)),
-                                 (int) (cryst->ny * cryst->b * cos((cryst->gamma - 90) * PI_RAD)) + cryst->offset_h);
+                                 y_coor2);
                        inx = cryst->nx;
                        for (iny = 1; iny <= cryst->ny; iny++) {
+                  if ( cryst->invert )
+                    {
+                       y_coor1 = cryst->win_height -
+                         (int) (iny * cryst->b * cos((cryst->gamma - 90) *
+                                                 PI_RAD)) - cryst->offset_h;
+                       y_coor2 = cryst->win_height -
+                         (int) (iny * cryst->b * cos((cryst->gamma - 90) *
+                                                     PI_RAD)) -
+                         cryst->offset_h;
+                    }
+                  else
+                    {
+                       y_coor1 = (int) (iny * cryst->b * cos((cryst->gamma - 90) *
+                                                 PI_RAD)) + cryst->offset_h;
+                       y_coor2 = (int) (iny * cryst->b * cos((cryst->gamma - 90) * PI_RAD)) +
+                                         cryst->offset_h;
+                    }
                                XDrawLine(display, window, cryst->gc,
                                          (int) (cryst->offset_w +
                                     inx * cryst->a - (int) (iny * cryst->b *
                                         sin((cryst->gamma - 90) * PI_RAD))),
-                                         (int) (iny * cryst->b * cos((cryst->gamma - 90) *
-                                                 PI_RAD)) + cryst->offset_h,
+                                         y_coor1,
                                    (int) (cryst->offset_w - iny * cryst->b *
                                           sin((cryst->gamma - 90) * PI_RAD)),
-                                         (int) (iny * cryst->b * cos((cryst->gamma - 90) * PI_RAD)) +
-                                         cryst->offset_h);
+                                         y_coor2);
                        }
                        iny = cryst->ny;
                        for (inx = 1; inx <= cryst->nx; inx++) {
+                          if ( cryst->invert )
+                            {
+                               y_coor1 =cryst->win_height -
+                                 (int) (iny * cryst->b *
+                                               cos((cryst->gamma - 90) *
+                                                   PI_RAD)) - cryst->offset_h;
+                               y_coor2 =cryst->win_height - cryst->offset_h;
+                            }
+                          else
+                            {
+                               y_coor1 =(int) (iny * cryst->b *
+                                               cos((cryst->gamma - 90) *
+                                                   PI_RAD)) + cryst->offset_h;
+                               y_coor2 =cryst->offset_h;
+                            }
                                XDrawLine(display, window, cryst->gc,
                                          (int) (cryst->offset_w +
                                     inx * cryst->a - (int) (iny * cryst->b *
                                         sin((cryst->gamma - 90) * PI_RAD))),
-                                         (int) (iny * cryst->b * cos((cryst->gamma - 90) * PI_RAD)) + cryst->offset_h,
-                                         cryst->offset_w + inx * cryst->a, cryst->offset_h);
+                                         y_coor1,
+                                         cryst->offset_w + inx * cryst->a,
+                                         y_coor2);
                        }
                } else {
                        int         inx, iny;
 
                        inx = NRAND(cryst->nx);
                        iny = NRAND(cryst->ny);
+                  if ( cryst->invert )
+                    {
+                       y_coor1 =cryst->win_height -
+                         (int) (iny * cryst->b *
+                                                 cos((cryst->gamma - 90) *
+                                                     PI_RAD)) -
+                         cryst->offset_h;
+                       y_coor2 =cryst->win_height -
+                         (int) ( ( iny + 1 ) * cryst->b *
+                                                 cos((cryst->gamma - 90) *
+                                                     PI_RAD)) -
+                         cryst->offset_h;
+                    }
+                  else
+                    {
+                       y_coor1 =(int) (iny * cryst->b *
+                                                 cos((cryst->gamma - 90) *
+                                                     PI_RAD)) +
+                         cryst->offset_h;
+                       y_coor2 =(int) (( iny + 1 ) * cryst->b *
+                                                 cos((cryst->gamma - 90) *
+                                                     PI_RAD)) +
+                         cryst->offset_h;
+                    }
                        XDrawLine(display, window, cryst->gc,
                                  cryst->offset_w + inx * cryst->a - (int) (iny * cryst->b * sin((cryst->gamma - 90) * PI_RAD)),
-                                 (int) (iny * cryst->b * cos((cryst->gamma - 90) * PI_RAD)) + cryst->offset_h,
+                                 y_coor1,
                                  cryst->offset_w + (inx + 1) * cryst->a - (int) (iny * cryst->b * sin((cryst->gamma - 90) * PI_RAD)),
-                                 (int) (iny * cryst->b * cos((cryst->gamma - 90) * PI_RAD)) + cryst->offset_h);
+                                 y_coor1);
                        XDrawLine(display, window, cryst->gc,
                                  cryst->offset_w + inx * cryst->a - (int) (iny * cryst->b * sin((cryst->gamma - 90) * PI_RAD)),
-                                 (int) (iny * cryst->b * cos((cryst->gamma - 90) * PI_RAD)) + cryst->offset_h,
+                                 y_coor1,
                                  cryst->offset_w + inx * cryst->a - (int) ((iny + 1) * cryst->b * sin((cryst->gamma - 90) * PI_RAD)),
-                                 (int) ((iny + 1) * cryst->b * cos((cryst->gamma - 90) * PI_RAD)) + cryst->offset_h);
+                                 y_coor2);
                        XDrawLine(display, window, cryst->gc,
                                  cryst->offset_w + (inx + 1) * cryst->a - (int) (iny * cryst->b * sin((cryst->gamma - 90) * PI_RAD)),
-                                 (int) (iny * cryst->b * cos((cryst->gamma - 90) * PI_RAD)) + cryst->offset_h,
+                                 y_coor1,
                                  cryst->offset_w + (inx + 1) * cryst->a - (int) ((iny + 1) * cryst->b * sin((cryst->gamma - 90) * PI_RAD)),
-                                 (int) ((iny + 1) * cryst->b * cos((cryst->gamma - 90) * PI_RAD)) + cryst->offset_h);
+                                 y_coor2);
                        XDrawLine(display, window, cryst->gc,
                                  cryst->offset_w + inx * cryst->a - (int) ((iny + 1) * cryst->b * sin((cryst->gamma - 90) * PI_RAD)),
-                                 (int) ((iny + 1) * cryst->b * cos((cryst->gamma - 90) * PI_RAD)) + cryst->offset_h,
+                                 y_coor2,
                                  cryst->offset_w + (inx + 1) * cryst->a - (int) ((iny + 1) * cryst->b * sin((cryst->gamma - 90) * PI_RAD)),
-                                 (int) ((iny + 1) * cryst->b * cos((cryst->gamma - 90) * PI_RAD)) + cryst->offset_h);
+                                 y_coor2);
                }
        }
        for (i = 0; i < cryst->num_atom; i++) {
                crystalatom *atom0;
 
                atom0 = &cryst->atom[i];
-               XSetForeground(display, cryst->gc, cryst->colors[atom0->colour].pixel);
+               if (MI_IS_INSTALL(mi) && MI_NPIXELS(mi) > 2) {
+                       XSetForeground(display, cryst->gc, cryst->colors[atom0->colour].pixel);
+               } else {
+                       XSetForeground(display, cryst->gc, atom0->colour);
+               }
                crystal_drawatom(mi, atom0);
        }
        XSetFunction(display, cryst->gc, GXcopy);
@@ -685,17 +796,19 @@ release_crystal(ModeInfo * mi)
                for (screen = 0; screen < MI_NUM_SCREENS(mi); screen++) {
                        crystalstruct *cryst = &crystals[screen];
 
-                       MI_WHITE_PIXEL(mi) = cryst->whitepixel;
-                       MI_BLACK_PIXEL(mi) = cryst->blackpixel;
+                       if (MI_IS_INSTALL(mi) && MI_NPIXELS(mi) > 2) {
+                               MI_WHITE_PIXEL(mi) = cryst->whitepixel;
+                               MI_BLACK_PIXEL(mi) = cryst->blackpixel;
 #ifndef STANDALONE
-                       MI_FG_PIXEL(mi) = cryst->fg;
-                       MI_BG_PIXEL(mi) = cryst->bg;
+                               MI_FG_PIXEL(mi) = cryst->fg;
+                               MI_BG_PIXEL(mi) = cryst->bg;
 #endif
-                       if (cryst->colors && cryst->ncolors && !cryst->no_colors)
-                               free_colors(display, cryst->cmap, cryst->colors, cryst->ncolors);
-                       if (cryst->colors)
-                               (void) free((void *) cryst->colors);
-                       XFreeColormap(display, cryst->cmap);
+                               if (cryst->colors && cryst->ncolors && !cryst->no_colors)
+                                       free_colors(display, cryst->cmap, cryst->colors, cryst->ncolors);
+                               if (cryst->colors)
+                                       (void) free((void *) cryst->colors);
+                               XFreeColormap(display, cryst->cmap);
+                       }
                        if (cryst->gc != NULL)
                                XFreeGC(display, cryst->gc);
                        if (cryst->atom != NULL)
@@ -726,42 +839,38 @@ init_crystal(ModeInfo * mi)
        cryst = &crystals[MI_SCREEN(mi)];
 
        if (!cryst->gc) {
-#ifndef STANDALONE
-               XColor      color;
+               if (MI_IS_INSTALL(mi) && MI_NPIXELS(mi) > 2) {
+                       XColor      color;
 
-               extern char *background;
-               extern char *foreground;
+#ifndef STANDALONE
+                       extern char *background;
+                       extern char *foreground;
 
-               cryst->fg = MI_FG_PIXEL(mi);
-               cryst->bg = MI_BG_PIXEL(mi);
+                       cryst->fg = MI_FG_PIXEL(mi);
+                       cryst->bg = MI_BG_PIXEL(mi);
 #endif
-               cryst->blackpixel = MI_BLACK_PIXEL(mi);
-               cryst->whitepixel = MI_WHITE_PIXEL(mi);
-
-#ifdef STANDALONE
-               cryst->cmap = mi->xgwa.colormap;
-#else /* !STANDALONE */
-               cryst->cmap = XCreateColormap(display, window,
-                                             MI_VISUAL(mi), AllocNone);
-               XSetWindowColormap(display, window, cryst->cmap);
-
-               (void) XParseColor(display, cryst->cmap, "black", &color);
-               (void) XAllocColor(display, cryst->cmap, &color);
-               MI_BLACK_PIXEL(mi) = color.pixel;
-               (void) XParseColor(display, cryst->cmap, "white", &color);
-               (void) XAllocColor(display, cryst->cmap, &color);
-               MI_WHITE_PIXEL(mi) = color.pixel;
-
-               (void) XParseColor(display, cryst->cmap, background, &color);
-               (void) XAllocColor(display, cryst->cmap, &color);
-               MI_BG_PIXEL(mi) = color.pixel;
-               (void) XParseColor(display, cryst->cmap, foreground, &color);
-               (void) XAllocColor(display, cryst->cmap, &color);
-               MI_FG_PIXEL(mi) = color.pixel;
-#endif /* !STANDALONE */
-
-               cryst->colors = 0;
-               cryst->ncolors = 0;
+                       cryst->blackpixel = MI_BLACK_PIXEL(mi);
+                       cryst->whitepixel = MI_WHITE_PIXEL(mi);
+                       cryst->cmap = XCreateColormap(display, window,
+                                                  MI_VISUAL(mi), AllocNone);
+                       XSetWindowColormap(display, window, cryst->cmap);
+                       (void) XParseColor(display, cryst->cmap, "black", &color);
+                       (void) XAllocColor(display, cryst->cmap, &color);
+                       MI_BLACK_PIXEL(mi) = color.pixel;
+                       (void) XParseColor(display, cryst->cmap, "white", &color);
+                       (void) XAllocColor(display, cryst->cmap, &color);
+                       MI_WHITE_PIXEL(mi) = color.pixel;
+#ifndef STANDALONE
+                       (void) XParseColor(display, cryst->cmap, background, &color);
+                       (void) XAllocColor(display, cryst->cmap, &color);
+                       MI_BG_PIXEL(mi) = color.pixel;
+                       (void) XParseColor(display, cryst->cmap, foreground, &color);
+                       (void) XAllocColor(display, cryst->cmap, &color);
+                       MI_FG_PIXEL(mi) = color.pixel;
+#endif
+                       cryst->colors = 0;
+                       cryst->ncolors = 0;
+               }
                if ((cryst->gc = XCreateGC(display, MI_WINDOW(mi),
                             (unsigned long) 0, (XGCValues *) NULL)) == None)
                        return;
@@ -795,6 +904,7 @@ init_crystal(ModeInfo * mi)
        cell_min = min(cryst->win_width / 2 + 1, MIN_CELL);
        cell_min = min(cell_min, cryst->win_height / 2 + 1);
        cryst->planegroup = NRAND(17);
+        cryst->invert = NRAND(2);
        if (MI_IS_VERBOSE(mi))
                (void) fprintf(stdout, "Selected plane group no %d\n",
                               cryst->planegroup + 1);
@@ -910,168 +1020,216 @@ init_crystal(ModeInfo * mi)
        cryst->a = cryst->a / cryst->nx;
        cryst->b = cryst->b / cryst->ny;
        if (cryst->unit_cell) {
+          int y_coor1 , y_coor2;
+          
                if (MI_NPIXELS(mi) > 2)
                        XSetForeground(display, cryst->gc, MI_PIXEL(mi, NRAND(MI_NPIXELS(mi))));
                else
-                       XSetForeground(display, cryst->gc, MI_BLACK_PIXEL(mi));
+                       XSetForeground(display, cryst->gc, MI_WHITE_PIXEL(mi));
                if (cryst->grid_cell) {
                        int         inx, iny;
 
+                  if ( cryst->invert )
+                    y_coor1 = y_coor2 = cryst->win_height - cryst->offset_h;
+                  else
+                    y_coor1 = y_coor2 = cryst->offset_h;
                        XDrawLine(display, window, cryst->gc, cryst->offset_w,
-                                 cryst->offset_h, cryst->offset_w + cryst->nx * cryst->a,
-                                 cryst->offset_h);
+                                 y_coor1, cryst->offset_w + cryst->nx * cryst->a,
+                                 y_coor2);
+                  if ( cryst->invert )
+                    {
+                       y_coor1 = cryst->win_height - cryst->offset_h;
+                       y_coor2 = cryst->win_height - (int) (cryst->ny *
+                                                            cryst->b *
+                                        cos((cryst->gamma - 90) * PI_RAD)) -
+                         cryst->offset_h;
+                    }
+                  else
+                    {
+                       y_coor1 = cryst->offset_h;
+                       y_coor2 = (int) (cryst->ny * cryst->b *
+                                        cos((cryst->gamma - 90) * PI_RAD)) +
+                         cryst->offset_h;
+                    }
                        XDrawLine(display, window, cryst->gc, cryst->offset_w,
-                                 cryst->offset_h, (int) (cryst->offset_w - cryst->ny * cryst->b *
+                                 y_coor1, (int) (cryst->offset_w - cryst->ny * cryst->b *
                                          sin((cryst->gamma - 90) * PI_RAD)),
-                                 (int) (cryst->ny * cryst->b * cos((cryst->gamma - 90) * PI_RAD)) + cryst->offset_h);
+                                 y_coor2);
                        inx = cryst->nx;
                        for (iny = 1; iny <= cryst->ny; iny++) {
+                  if ( cryst->invert )
+                    {
+                       y_coor1 = cryst->win_height -
+                         (int) (iny * cryst->b * cos((cryst->gamma - 90) *
+                                                 PI_RAD)) - cryst->offset_h;
+                       y_coor2 = cryst->win_height -
+                         (int) (iny * cryst->b * cos((cryst->gamma - 90) *
+                                                     PI_RAD)) -
+                         cryst->offset_h;
+                    }
+                  else
+                    {
+                       y_coor1 = (int) (iny * cryst->b * cos((cryst->gamma - 90) *
+                                                 PI_RAD)) + cryst->offset_h;
+                       y_coor2 = (int) (iny * cryst->b * cos((cryst->gamma - 90) * PI_RAD)) +
+                                         cryst->offset_h;
+                    }
                                XDrawLine(display, window, cryst->gc,
                                          (int) (cryst->offset_w +
                                     inx * cryst->a - (int) (iny * cryst->b *
                                         sin((cryst->gamma - 90) * PI_RAD))),
-                                         (int) (iny * cryst->b * cos((cryst->gamma - 90) *
-                                                 PI_RAD)) + cryst->offset_h,
+                                         y_coor1,
                                    (int) (cryst->offset_w - iny * cryst->b *
                                           sin((cryst->gamma - 90) * PI_RAD)),
-                                         (int) (iny * cryst->b * cos((cryst->gamma - 90) * PI_RAD)) +
-                                         cryst->offset_h);
+                                         y_coor2);
                        }
                        iny = cryst->ny;
                        for (inx = 1; inx <= cryst->nx; inx++) {
+                          if ( cryst->invert )
+                            {
+                               y_coor1 =cryst->win_height -
+                                 (int) (iny * cryst->b *
+                                               cos((cryst->gamma - 90) *
+                                                   PI_RAD)) - cryst->offset_h;
+                               y_coor2 =cryst->win_height - cryst->offset_h;
+                            }
+                          else
+                            {
+                               y_coor1 =(int) (iny * cryst->b *
+                                               cos((cryst->gamma - 90) *
+                                                   PI_RAD)) + cryst->offset_h;
+                               y_coor2 =cryst->offset_h;
+                            }
                                XDrawLine(display, window, cryst->gc,
                                          (int) (cryst->offset_w +
                                     inx * cryst->a - (int) (iny * cryst->b *
                                         sin((cryst->gamma - 90) * PI_RAD))),
-                                         (int) (iny * cryst->b * cos((cryst->gamma - 90) * PI_RAD)) + cryst->offset_h,
-                                         cryst->offset_w + inx * cryst->a, cryst->offset_h);
+                                         y_coor1,
+                                         cryst->offset_w + inx * cryst->a,
+                                         y_coor2);
                        }
                } else {
                        int         inx, iny;
 
                        inx = NRAND(cryst->nx);
                        iny = NRAND(cryst->ny);
+                  if ( cryst->invert )
+                    {
+                       y_coor1 =cryst->win_height -
+                         (int) (iny * cryst->b *
+                                                 cos((cryst->gamma - 90) *
+                                                     PI_RAD)) -
+                         cryst->offset_h;
+                       y_coor2 =cryst->win_height -
+                         (int) ( ( iny + 1 ) * cryst->b *
+                                                 cos((cryst->gamma - 90) *
+                                                     PI_RAD)) -
+                         cryst->offset_h;
+                    }
+                  else
+                    {
+                       y_coor1 =(int) (iny * cryst->b *
+                                                 cos((cryst->gamma - 90) *
+                                                     PI_RAD)) +
+                         cryst->offset_h;
+                       y_coor2 =(int) (( iny + 1 ) * cryst->b *
+                                                 cos((cryst->gamma - 90) *
+                                                     PI_RAD)) +
+                         cryst->offset_h;
+                    }
                        XDrawLine(display, window, cryst->gc,
                                  cryst->offset_w + inx * cryst->a - (int) (iny * cryst->b * sin((cryst->gamma - 90) * PI_RAD)),
-                                 (int) (iny * cryst->b * cos((cryst->gamma - 90) * PI_RAD)) + cryst->offset_h,
+                                 y_coor1,
                                  cryst->offset_w + (inx + 1) * cryst->a - (int) (iny * cryst->b * sin((cryst->gamma - 90) * PI_RAD)),
-                                 (int) (iny * cryst->b * cos((cryst->gamma - 90) * PI_RAD)) + cryst->offset_h);
+                                 y_coor1);
                        XDrawLine(display, window, cryst->gc,
                                  cryst->offset_w + inx * cryst->a - (int) (iny * cryst->b * sin((cryst->gamma - 90) * PI_RAD)),
-                                 (int) (iny * cryst->b * cos((cryst->gamma - 90) * PI_RAD)) + cryst->offset_h,
+                                 y_coor1,
                                  cryst->offset_w + inx * cryst->a - (int) ((iny + 1) * cryst->b * sin((cryst->gamma - 90) * PI_RAD)),
-                                 (int) ((iny + 1) * cryst->b * cos((cryst->gamma - 90) * PI_RAD)) + cryst->offset_h);
+                                 y_coor2);
                        XDrawLine(display, window, cryst->gc,
                                  cryst->offset_w + (inx + 1) * cryst->a - (int) (iny * cryst->b * sin((cryst->gamma - 90) * PI_RAD)),
-                                 (int) (iny * cryst->b * cos((cryst->gamma - 90) * PI_RAD)) + cryst->offset_h,
+                                 y_coor1,
                                  cryst->offset_w + (inx + 1) * cryst->a - (int) ((iny + 1) * cryst->b * sin((cryst->gamma - 90) * PI_RAD)),
-                                 (int) ((iny + 1) * cryst->b * cos((cryst->gamma - 90) * PI_RAD)) + cryst->offset_h);
+                                 y_coor2);
                        XDrawLine(display, window, cryst->gc,
                                  cryst->offset_w + inx * cryst->a - (int) ((iny + 1) * cryst->b * sin((cryst->gamma - 90) * PI_RAD)),
-                                 (int) ((iny + 1) * cryst->b * cos((cryst->gamma - 90) * PI_RAD)) + cryst->offset_h,
+                                 y_coor2,
                                  cryst->offset_w + (inx + 1) * cryst->a - (int) ((iny + 1) * cryst->b * sin((cryst->gamma - 90) * PI_RAD)),
-                                 (int) ((iny + 1) * cryst->b * cos((cryst->gamma - 90) * PI_RAD)) + cryst->offset_h);
+                                 y_coor2);
                }
        }
+       if (MI_IS_INSTALL(mi) && MI_NPIXELS(mi) > 2) {
 /* Set up colour map */
-       if (cryst->colors && cryst->ncolors && !cryst->no_colors)
-               free_colors(display, cryst->cmap, cryst->colors, cryst->ncolors);
-       if (cryst->colors)
-               (void) free((void *) cryst->colors);
-       cryst->colors = 0;
-#ifdef STANDALONE
-       cryst->ncolors = get_integer_resource("ncolors", "Integer");
-#else
-       cryst->ncolors = MI_NCOLORS(mi);
-#endif
-       if (cryst->ncolors < 2)
-               cryst->ncolors = 2;
-       if (cryst->ncolors <= 2)
-               cryst->mono_p = True;
-       else
-               cryst->mono_p = False;
-
-       if (cryst->mono_p)
+               if (cryst->colors && cryst->ncolors && !cryst->no_colors)
+                       free_colors(display, cryst->cmap, cryst->colors, cryst->ncolors);
+               if (cryst->colors)
+                       (void) free((void *) cryst->colors);
                cryst->colors = 0;
-       else
-               cryst->colors = (XColor *) malloc(sizeof (*cryst->colors) * (cryst->ncolors + 1));
-#ifdef STANDALONE
-       cryst->cycle_p = has_writable_cells(mi->xgwa.screen, mi->xgwa.visual);
-#else
-       cryst->cycle_p = has_writable_cells(mi);
-#endif
-       if (cryst->cycle_p) {
-               if (MI_IS_FULLRANDOM(mi)) {
-                       if (NRAND(8) == 7)
-                               cryst->cycle_p = False;
+               cryst->ncolors = MI_NCOLORS(mi);
+               if (cryst->ncolors < 2)
+                       cryst->ncolors = 2;
+               if (cryst->ncolors <= 2)
+                       cryst->mono_p = True;
+               else
+                       cryst->mono_p = False;
+
+               if (cryst->mono_p)
+                       cryst->colors = 0;
+               else
+                       cryst->colors = (XColor *) malloc(sizeof (*cryst->colors) * (cryst->ncolors + 1));
+               cryst->cycle_p = has_writable_cells(mi->xgwa.screen, MI_VISUAL(mi));
+               if (cryst->cycle_p) {
+                       if (MI_IS_FULLRANDOM(mi)) {
+                               if (!NRAND(8))
+                                       cryst->cycle_p = False;
+                               else
+                                       cryst->cycle_p = True;
+                       } else {
+                               cryst->cycle_p = cycle_p;
+                       }
+               }
+               if (!cryst->mono_p) {
+                       if (!(LRAND() % 10))
+                               make_random_colormap(MI_DISPLAY(mi), MI_VISUAL(mi), cryst->cmap, cryst->colors, &cryst->ncolors,
+                                               True, True, &cryst->cycle_p, True);
+                       else if (!(LRAND() % 2))
+                               make_uniform_colormap(MI_DISPLAY(mi), MI_VISUAL(mi), cryst->cmap, cryst->colors, &cryst->ncolors,
+                                                     True, &cryst->cycle_p, True);
                        else
-                               cryst->cycle_p = True;
-               } else {
-                       cryst->cycle_p = cycle_p;
+                               make_smooth_colormap(MI_DISPLAY(mi), MI_VISUAL(mi), cryst->cmap, cryst->colors, &cryst->ncolors,
+                                                    True, &cryst->cycle_p, True);
                }
-       }
-       if (!cryst->mono_p) {
-               if (!(LRAND() % 10))
-                       make_random_colormap(
-#ifdef STANDALONE
-                                                                mi->dpy, mi->xgwa.visual,
-#else
-                                                                mi,
-#endif
-                                                                cryst->cmap, cryst->colors, &cryst->ncolors,
-                                                                True, True, &cryst->cycle_p
-#ifdef STANDALONE
-                                                                , False
-#endif
-                                                                );
-               else if (!(LRAND() % 2))
-                       make_uniform_colormap(
-#ifdef STANDALONE
-                                                                 mi->dpy, mi->xgwa.visual,
-#else
-                                                                mi,
-#endif
-                                                                 cryst->cmap, cryst->colors, &cryst->ncolors,
-                                                                 True, &cryst->cycle_p
-#ifdef STANDALONE
-                                                                , False
-#endif
-                                                                );
-               else
-                       make_smooth_colormap(
-#ifdef STANDALONE
-                                                                mi->dpy, mi->xgwa.visual,
-#else
-                                                                mi,
-#endif
-                                                                cryst->cmap, cryst->colors, &cryst->ncolors,
-                                                                True, &cryst->cycle_p
-#ifdef STANDALONE
-                                                                , False
-#endif
-                                                                );
-       }
-       XInstallColormap(display, cryst->cmap);
-       if (cryst->ncolors < 2) {
-               cryst->ncolors = 2;
-               cryst->no_colors = True;
-       } else
-               cryst->no_colors = False;
-       if (cryst->ncolors <= 2)
-               cryst->mono_p = True;
+               XInstallColormap(display, cryst->cmap);
+               if (cryst->ncolors < 2) {
+                       cryst->ncolors = 2;
+                       cryst->no_colors = True;
+               } else
+                       cryst->no_colors = False;
+               if (cryst->ncolors <= 2)
+                       cryst->mono_p = True;
 
-       if (cryst->mono_p)
-               cryst->cycle_p = False;
+               if (cryst->mono_p)
+                       cryst->cycle_p = False;
 
+       }
        for (i = 0; i < cryst->num_atom; i++) {
                crystalatom *atom0;
 
                atom0 = &cryst->atom[i];
-               if (cryst->ncolors > 2)
-                       atom0->colour = NRAND(cryst->ncolors - 2) + 2;
-               else
-                       atom0->colour = 1;      /*Xor'red so WHITE may not be appropriate */
-               XSetForeground(display, cryst->gc, cryst->colors[atom0->colour].pixel);
+               if (MI_IS_INSTALL(mi) && MI_NPIXELS(mi) > 2) {
+                       if (cryst->ncolors > 2)
+                               atom0->colour = NRAND(cryst->ncolors - 2) + 2;
+                       else
+                               atom0->colour = 1;      /* Just in case */
+                       XSetForeground(display, cryst->gc, cryst->colors[atom0->colour].pixel);
+               } else {
+                       if (MI_NPIXELS(mi) > 2)
+                               atom0->colour = MI_PIXEL(mi, NRAND(MI_NPIXELS(mi)));
+                       else
+                               atom0->colour = 1;      /*Xor'red so WHITE may not be appropriate */
+                       XSetForeground(display, cryst->gc, atom0->colour);
+               }
                atom0->x0 = NRAND(cryst->a);
                atom0->y0 = NRAND(cryst->b);
                atom0->velocity[0] = NRAND(7) - 3;
diff --git a/hacks/demon.c b/hacks/demon.c
new file mode 100644 (file)
index 0000000..84581c1
--- /dev/null
@@ -0,0 +1,902 @@
+/* -*- Mode: C; tab-width: 4 -*- */
+/* demon --- David Griffeath's cellular automata */
+
+#if !defined( lint ) && !defined( SABER )
+static const char sccsid[] = "@(#)demon.c      4.07 97/11/24 xlockmore";
+
+#endif
+
+/*-
+ * Copyright (c) 1995 by David Bagley.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation.
+ *
+ * This file is provided AS IS with no warranties of any kind.  The author
+ * shall have no liability with respect to the infringement of copyrights,
+ * trade secrets or any patents by this file or any part thereof.  In no
+ * event will the author be liable for any lost revenue or profits or
+ * other special, indirect and consequential damages.
+ *
+ * Revision History:
+ * 10-May-97: Compatible with xscreensaver
+ * 16-Apr-97: -neighbors 3, 9 (not sound mathematically), 12, and 8 added
+ * 30-May-96: Ron Hitchens <ron@idiom.com>
+ *            Fixed memory management that caused leaks
+ * 14-Apr-96: -neighbors 6 runtime-time option added
+ * 21-Aug-95: Coded from A.K. Dewdney's "Computer Recreations", Scientific
+ *            American Magazine" Aug 1989 pp 102-105.  Also very similar to
+ *            hodgepodge machine described in A.K. Dewdney's "Computer
+ *            Recreations", Scientific American Magazine" Aug 1988 pp 104-107.
+ *            also used life.c as a guide.
+ */
+
+/*-
+ * A cellular universe of 4 phases debris, droplets, defects, and demons.
+ */
+
+/*-
+  Grid     Number of Neigbors
+  ----     ------------------
+  Square   4 or 8
+  Hexagon  6
+  Triangle 3, 9, or 12
+*/
+
+#ifdef STANDALONE
+#define PROGCLASS "Demon"
+#define HACK_INIT init_demon
+#define HACK_DRAW draw_demon
+#define demon_opts xlockmore_opts
+#define DEFAULTS       "*delay:        50000 \n"       \
+                                       "*count:            0 \n"       \
+                                       "*cycles:        1000 \n"       \
+                                       "*size:            -7 \n"       \
+                                       "*ncolors:         64 \n"       \
+                                       "*neighbors:    0 \n"
+# define UNIFORM_COLORS
+# include "xlockmore.h"                /* in xscreensaver distribution */
+#else /* STANDALONE */
+# include "xlock.h"                    /* in xlockmore distribution */
+#endif /* STANDALONE */
+#include "automata.h"
+
+/*-
+ * neighbors of 0 randomizes it between 3, 4, 6, 8, 9, and 12.
+ */
+#ifdef STANDALONE
+static int neighbors;
+#else
+extern int  neighbors;
+#endif /* !STANDALONE */
+
+ModeSpecOpt demon_opts =
+{0, NULL, 0, NULL, NULL};
+
+#ifdef USE_MODULES
+ModStruct   demon_description =
+{"demon", "init_demon", "draw_demon", "release_demon",
+ "refresh_demon", "init_demon", NULL, &demon_opts,
+ 50000, 0, 1000, -7, 64, 1.0, "",
+ "Shows Griffeath's cellular automata", 0, NULL};
+
+#endif
+
+#define DEMONBITS(n,w,h)\
+  dp->pixmaps[dp->init_bits++]=\
+  XCreatePixmapFromBitmapData(display,window,(char *)n,w,h,1,0,1)
+
+#define REDRAWSTEP 2000                /* How many cells to draw per cycle */
+#define MINSTATES 2
+#define MINGRIDSIZE 24
+#define MINSIZE 4
+#define NEIGHBORKINDS 6
+
+/* Singly linked list */
+typedef struct _CellList {
+       XPoint      pt;
+       struct _CellList *next;
+} CellList;
+
+typedef struct {
+       int         generation;
+       int         xs, ys;
+       int         xb, yb;
+       int         nrows, ncols;
+       int         width, height;
+       int         states;
+       int         state;
+       int         redrawing, redrawpos;
+       int        *ncells;
+       CellList  **cellList;
+       unsigned char *oldcell, *newcell;
+       int         neighbors;
+       int         init_bits;
+       GC          stippledGC;
+       Pixmap      pixmaps[NUMSTIPPLES - 1];
+       union {
+               XPoint      hexagon[6];
+               XPoint      triangle[2][3];
+       } shape;
+} demonstruct;
+
+static char plots[2][NEIGHBORKINDS] =
+{
+       {3, 4, 6, 8, 9, 12},    /* Neighborhoods */
+       {12, 16, 18, 20, 22, 24}        /* Number of states */
+};
+
+static demonstruct *demons = NULL;
+
+static void
+drawcell(ModeInfo * mi, int col, int row, unsigned char state)
+{
+       demonstruct *dp = &demons[MI_SCREEN(mi)];
+       GC          gc;
+
+       if (!state) {
+               XSetForeground(MI_DISPLAY(mi), MI_GC(mi), MI_BLACK_PIXEL(mi));
+               gc = MI_GC(mi);
+       } else if (MI_NPIXELS(mi) >= NUMSTIPPLES) {
+               XSetForeground(MI_DISPLAY(mi), MI_GC(mi),
+                          MI_PIXEL(mi, (((int) state - 1) * MI_NPIXELS(mi) /
+                                        (dp->states - 1)) % MI_NPIXELS(mi)));
+               gc = MI_GC(mi);
+       } else {
+               XGCValues   gcv;
+
+               gcv.stipple = dp->pixmaps[(state - 1) % (NUMSTIPPLES - 1)];
+               gcv.foreground = MI_WHITE_PIXEL(mi);
+               gcv.background = MI_BLACK_PIXEL(mi);
+               XChangeGC(MI_DISPLAY(mi), dp->stippledGC,
+                         GCStipple | GCForeground | GCBackground, &gcv);
+               gc = dp->stippledGC;
+       }
+       if (dp->neighbors == 6) {
+               int         ccol = 2 * col + !(row & 1), crow = 2 * row;
+
+               dp->shape.hexagon[0].x = dp->xb + ccol * dp->xs;
+               dp->shape.hexagon[0].y = dp->yb + crow * dp->ys;
+               if (dp->xs == 1 && dp->ys == 1)
+                       XFillRectangle(MI_DISPLAY(mi), MI_WINDOW(mi),
+                                      gc, dp->shape.hexagon[0].x, dp->shape.hexagon[0].y, 1, 1);
+               else
+                       XFillPolygon(MI_DISPLAY(mi), MI_WINDOW(mi), gc,
+                           dp->shape.hexagon, 6, Convex, CoordModePrevious);
+       } else if (dp->neighbors == 4 || dp->neighbors == 8) {
+               XFillRectangle(MI_DISPLAY(mi), MI_WINDOW(mi), gc,
+               dp->xb + dp->xs * col, dp->yb + dp->ys * row,
+               dp->xs - (dp->xs > 3), dp->ys - (dp->ys > 3));
+       } else {                /* TRI */
+               int         orient = (col + row) % 2;   /* O left 1 right */
+
+               dp->shape.triangle[orient][0].x = dp->xb + col * dp->xs;
+               dp->shape.triangle[orient][0].y = dp->yb + row * dp->ys;
+               if (dp->xs <= 3 || dp->ys <= 3)
+                       XFillRectangle(MI_DISPLAY(mi), MI_WINDOW(mi), gc,
+                       ((orient) ? -1 : 1) + dp->shape.triangle[orient][0].x,
+                                      dp->shape.triangle[orient][0].y, 1, 1);
+               else {
+                       if (orient)
+                               dp->shape.triangle[orient][0].x += (dp->xs / 2 - 1);
+                       else
+                               dp->shape.triangle[orient][0].x -= (dp->xs / 2 - 1);
+                       XFillPolygon(MI_DISPLAY(mi), MI_WINDOW(mi), gc,
+                                    dp->shape.triangle[orient], 3, Convex, CoordModePrevious);
+
+               }
+       }
+}
+
+static void
+addtolist(ModeInfo * mi, int col, int row, unsigned char state)
+{
+       demonstruct *dp = &demons[MI_SCREEN(mi)];
+       CellList   *current;
+
+       current = dp->cellList[state];
+       dp->cellList[state] = (CellList *) malloc(sizeof (CellList));
+       dp->cellList[state]->pt.x = col;
+       dp->cellList[state]->pt.y = row;
+       dp->cellList[state]->next = current;
+       dp->ncells[state]++;
+}
+
+#ifdef DEBUG
+static void
+print_state(ModeInfo * mi, int state)
+{
+       demonstruct *dp = &demons[MI_SCREEN(mi)];
+       CellList   *locallist;
+       int         i = 0;
+
+       locallist = dp->cellList[state];
+       (void) printf("state %d\n", state);
+       while (locallist) {
+               (void) printf("%d       x %d, y %d\n", i,
+                             locallist->pt.x, locallist->pt.y);
+               locallist = locallist->next;
+               i++;
+       }
+}
+
+#endif
+
+static void
+free_state(demonstruct * dp, int state)
+{
+       CellList   *current;
+
+       while (dp->cellList[state]) {
+               current = dp->cellList[state];
+               dp->cellList[state] = dp->cellList[state]->next;
+               (void) free((void *) current);
+       }
+       dp->cellList[state] = NULL;
+       if (dp->ncells)
+               dp->ncells[state] = 0;
+}
+
+
+static void
+free_list(demonstruct * dp)
+{
+       int         state;
+
+       for (state = 0; state < dp->states; state++)
+               free_state(dp, state);
+       (void) free((void *) dp->cellList);
+       dp->cellList = NULL;
+}
+
+static void
+free_struct(demonstruct * dp)
+{
+       if (dp->cellList != NULL) {
+               free_list(dp);
+       }
+       if (dp->ncells != NULL) {
+               (void) free((void *) dp->ncells);
+               dp->ncells = NULL;
+       }
+       if (dp->oldcell != NULL) {
+               (void) free((void *) dp->oldcell);
+               dp->oldcell = NULL;
+       }
+       if (dp->newcell != NULL) {
+               (void) free((void *) dp->newcell);
+               dp->newcell = NULL;
+       }
+}
+
+static void
+draw_state(ModeInfo * mi, int state)
+{
+       demonstruct *dp = &demons[MI_SCREEN(mi)];
+       GC          gc;
+       XRectangle *rects;
+       CellList   *current;
+
+       if (!state) {
+               XSetForeground(MI_DISPLAY(mi), MI_GC(mi), MI_BLACK_PIXEL(mi));
+               gc = MI_GC(mi);
+       } else if (MI_NPIXELS(mi) >= NUMSTIPPLES) {
+               XSetForeground(MI_DISPLAY(mi), MI_GC(mi),
+                          MI_PIXEL(mi, (((int) state - 1) * MI_NPIXELS(mi) /
+                                        (dp->states - 1)) % MI_NPIXELS(mi)));
+               gc = MI_GC(mi);
+       } else {
+               XGCValues   gcv;
+
+               gcv.stipple = dp->pixmaps[(state - 1) % (NUMSTIPPLES - 1)];
+               gcv.foreground = MI_WHITE_PIXEL(mi);
+               gcv.background = MI_BLACK_PIXEL(mi);
+               XChangeGC(MI_DISPLAY(mi), dp->stippledGC,
+                         GCStipple | GCForeground | GCBackground, &gcv);
+               gc = dp->stippledGC;
+       }
+       if (dp->neighbors == 6) {       /* Draw right away, slow */
+               current = dp->cellList[state];
+               while (current) {
+                       int         col, row, ccol, crow;
+
+                       col = current->pt.x;
+                       row = current->pt.y;
+                       ccol = 2 * col + !(row & 1), crow = 2 * row;
+                       dp->shape.hexagon[0].x = dp->xb + ccol * dp->xs;
+                       dp->shape.hexagon[0].y = dp->yb + crow * dp->ys;
+                       if (dp->xs == 1 && dp->ys == 1)
+                               XFillRectangle(MI_DISPLAY(mi), MI_WINDOW(mi),
+                                              gc, dp->shape.hexagon[0].x, dp->shape.hexagon[0].y, 1, 1);
+                       else
+                               XFillPolygon(MI_DISPLAY(mi), MI_WINDOW(mi), gc,
+                                            dp->shape.hexagon, 6, Convex, CoordModePrevious);
+                       current = current->next;
+               }
+       } else if (dp->neighbors == 4 || dp->neighbors == 8) {
+               /* Take advantage of XDrawRectangles */
+               int         ncells = 0;
+
+               /* Create Rectangle list from part of the cellList */
+               rects = (XRectangle *) malloc(dp->ncells[state] * sizeof (XRectangle));
+               current = dp->cellList[state];
+               while (current) {
+                       rects[ncells].x = dp->xb + current->pt.x * dp->xs;
+                       rects[ncells].y = dp->yb + current->pt.y * dp->ys;
+                       rects[ncells].width = dp->xs - (dp->xs > 3);
+                       rects[ncells].height = dp->ys - (dp->ys > 3);
+                       current = current->next;
+                       ncells++;
+               }
+               /* Finally get to draw */
+               XFillRectangles(MI_DISPLAY(mi), MI_WINDOW(mi), gc, rects, ncells);
+               /* Free up rects list and the appropriate part of the cellList */
+               (void) free((void *) rects);
+       } else {                /* TRI */
+               current = dp->cellList[state];
+               while (current) {
+                       int         col, row, orient;
+
+                       col = current->pt.x;
+                       row = current->pt.y;
+                       orient = (col + row) % 2;       /* O left 1 right */
+                       dp->shape.triangle[orient][0].x = dp->xb + col * dp->xs;
+                       dp->shape.triangle[orient][0].y = dp->yb + row * dp->ys;
+                       if (dp->xs <= 3 || dp->ys <= 3)
+                               XFillRectangle(MI_DISPLAY(mi), MI_WINDOW(mi), gc,
+                                              ((orient) ? -1 : 1) + dp->shape.triangle[orient][0].x,
+                                     dp->shape.triangle[orient][0].y, 1, 1);
+                       else {
+                               if (orient)
+                                       dp->shape.triangle[orient][0].x += (dp->xs / 2 - 1);
+                               else
+                                       dp->shape.triangle[orient][0].x -= (dp->xs / 2 - 1);
+                               XFillPolygon(MI_DISPLAY(mi), MI_WINDOW(mi), gc,
+                                            dp->shape.triangle[orient], 3, Convex, CoordModePrevious);
+                       }
+                       current = current->next;
+               }
+       }
+       free_state(dp, state);
+       XFlush(MI_DISPLAY(mi));
+}
+
+static void
+RandomSoup(ModeInfo * mi)
+{
+       demonstruct *dp = &demons[MI_SCREEN(mi)];
+       int         row, col, mrow = 0;
+
+       for (row = 0; row < dp->nrows; ++row) {
+               for (col = 0; col < dp->ncols; ++col) {
+                       dp->oldcell[col + mrow] =
+                               (unsigned char) LRAND() % ((unsigned char) dp->states);
+                       addtolist(mi, col, row, dp->oldcell[col + mrow]);
+               }
+               mrow += dp->ncols;
+       }
+}
+
+void
+init_demon(ModeInfo * mi)
+{
+       Display    *display = MI_DISPLAY(mi);
+       Window      window = MI_WINDOW(mi);
+       int         size = MI_SIZE(mi), nk;
+       demonstruct *dp;
+
+       if (demons == NULL) {
+               if ((demons = (demonstruct *) calloc(MI_NUM_SCREENS(mi),
+                                             sizeof (demonstruct))) == NULL)
+                       return;
+       }
+       dp = &demons[MI_SCREEN(mi)];
+       dp->generation = 0;
+       dp->redrawing = 0;
+       if (MI_NPIXELS(mi) < NUMSTIPPLES) {
+               if (dp->stippledGC == None) {
+                       XGCValues   gcv;
+
+                       gcv.fill_style = FillOpaqueStippled;
+                       dp->stippledGC = XCreateGC(display, window, GCFillStyle, &gcv);
+               }
+               if (dp->init_bits == 0) {
+                       int         i;
+
+                       for (i = 1; i < NUMSTIPPLES; i++)
+                               DEMONBITS(stipples[i], STIPPLESIZE, STIPPLESIZE);
+               }
+       }
+       free_struct(dp);
+
+       for (nk = 0; nk < NEIGHBORKINDS; nk++) {
+               if (neighbors == plots[0][nk]) {
+                       dp->neighbors = plots[0][nk];
+                       break;
+               }
+               if (nk == NEIGHBORKINDS - 1) {
+                       nk = NRAND(NEIGHBORKINDS);
+                       dp->neighbors = plots[0][nk];
+                       break;
+               }
+       }
+
+       dp->states = MI_COUNT(mi);
+       if (dp->states < -MINSTATES)
+               dp->states = NRAND(-dp->states - MINSTATES + 1) + MINSTATES;
+       else if (dp->states < MINSTATES)
+               dp->states = plots[1][nk];
+       dp->cellList = (CellList **) calloc(dp->states, sizeof (CellList *));
+       dp->ncells = (int *) calloc(dp->states, sizeof (int));
+
+       dp->state = 0;
+
+       dp->width = MI_WIDTH(mi);
+       dp->height = MI_HEIGHT(mi);
+
+       if (dp->neighbors == 6) {
+               int         nccols, ncrows, i;
+
+               if (dp->width < 2)
+                       dp->width = 2;
+               if (dp->height < 4)
+                       dp->height = 4;
+               if (size < -MINSIZE)
+                       dp->ys = NRAND(MIN(-size, MAX(MINSIZE, MIN(dp->width, dp->height) /
+                                     MINGRIDSIZE)) - MINSIZE + 1) + MINSIZE;
+               else if (size < MINSIZE) {
+                       if (!size)
+                               dp->ys = MAX(MINSIZE, MIN(dp->width, dp->height) / MINGRIDSIZE);
+                       else
+                               dp->ys = MINSIZE;
+               } else
+                       dp->ys = MIN(size, MAX(MINSIZE, MIN(dp->width, dp->height) /
+                                              MINGRIDSIZE));
+               dp->xs = dp->ys;
+               nccols = MAX(dp->width / dp->xs - 2, 2);
+               ncrows = MAX(dp->height / dp->ys - 1, 2);
+               dp->ncols = nccols / 2;
+               dp->nrows = 2 * (ncrows / 4);
+               dp->xb = (dp->width - dp->xs * nccols) / 2 + dp->xs / 2;
+               dp->yb = (dp->height - dp->ys * (ncrows / 2) * 2) / 2 + dp->ys;
+               for (i = 0; i < 6; i++) {
+                       dp->shape.hexagon[i].x = (dp->xs - 1) * hexagonUnit[i].x;
+                       dp->shape.hexagon[i].y = ((dp->ys - 1) * hexagonUnit[i].y / 2) * 4 / 3;
+               }
+       } else if (dp->neighbors == 4 || dp->neighbors == 8) {
+               if (size < -MINSIZE)
+                       dp->ys = NRAND(MIN(-size, MAX(MINSIZE, MIN(dp->width, dp->height) /
+                                     MINGRIDSIZE)) - MINSIZE + 1) + MINSIZE;
+               else if (size < MINSIZE) {
+                       if (!size)
+                               dp->ys = MAX(MINSIZE, MIN(dp->width, dp->height) / MINGRIDSIZE);
+                       else
+                               dp->ys = MINSIZE;
+               } else
+                       dp->ys = MIN(size, MAX(MINSIZE, MIN(dp->width, dp->height) /
+                                              MINGRIDSIZE));
+               dp->xs = dp->ys;
+               dp->ncols = MAX(dp->width / dp->xs, 2);
+               dp->nrows = MAX(dp->height / dp->ys, 2);
+               dp->xb = (dp->width - dp->xs * dp->ncols) / 2;
+               dp->yb = (dp->height - dp->ys * dp->nrows) / 2;
+       } else {                /* TRI */
+               int         orient, i;
+
+               if (dp->width < 2)
+                       dp->width = 2;
+               if (dp->height < 2)
+                       dp->height = 2;
+               if (size < -MINSIZE)
+                       dp->ys = NRAND(MIN(-size, MAX(MINSIZE, MIN(dp->width, dp->height) /
+                                     MINGRIDSIZE)) - MINSIZE + 1) + MINSIZE;
+               else if (size < MINSIZE) {
+                       if (!size)
+                               dp->ys = MAX(MINSIZE, MIN(dp->width, dp->height) / MINGRIDSIZE);
+                       else
+                               dp->ys = MINSIZE;
+               } else
+                       dp->ys = MIN(size, MAX(MINSIZE, MIN(dp->width, dp->height) /
+                                              MINGRIDSIZE));
+               dp->xs = (int) (1.52 * dp->ys);
+               dp->ncols = (MAX(dp->width / dp->xs - 1, 2) / 2) * 2;
+               dp->nrows = (MAX(dp->height / dp->ys - 1, 2) / 2) * 2;
+               dp->xb = (dp->width - dp->xs * dp->ncols) / 2 + dp->xs / 2;
+               dp->yb = (dp->height - dp->ys * dp->nrows) / 2 + dp->ys / 2;
+               for (orient = 0; orient < 2; orient++) {
+                       for (i = 0; i < 3; i++) {
+                               dp->shape.triangle[orient][i].x =
+                                       (dp->xs - 2) * triangleUnit[orient][i].x;
+                               dp->shape.triangle[orient][i].y =
+                                       (dp->ys - 2) * triangleUnit[orient][i].y;
+                       }
+               }
+       }
+
+       MI_CLEARWINDOW(mi);
+
+       dp->oldcell = (unsigned char *)
+               malloc(dp->ncols * dp->nrows * sizeof (unsigned char));
+
+       dp->newcell = (unsigned char *)
+               malloc(dp->ncols * dp->nrows * sizeof (unsigned char));
+
+       RandomSoup(mi);
+}
+
+void
+draw_demon(ModeInfo * mi)
+{
+       demonstruct *dp = &demons[MI_SCREEN(mi)];
+       int         i, j, k, l, mj = 0, ml;
+
+       MI_IS_DRAWN(mi) = True;
+
+       if (dp->state >= dp->states) {
+               (void) memcpy((char *) dp->newcell, (char *) dp->oldcell,
+                             dp->ncols * dp->nrows * sizeof (unsigned char));
+
+               if (dp->neighbors == 6) {
+                       for (j = 0; j < dp->nrows; j++) {
+                               for (i = 0; i < dp->ncols; i++) {
+                                       /* NE */
+                                       if (!(j & 1))
+                                               k = (i + 1 == dp->ncols) ? 0 : i + 1;
+                                       else
+                                               k = i;
+                                       l = (!j) ? dp->nrows - 1 : j - 1;
+                                       ml = l * dp->ncols;
+                                       if (dp->oldcell[k + ml] ==
+                                           (int) (dp->oldcell[i + mj] + 1) % dp->states)
+                                               dp->newcell[i + mj] = dp->oldcell[k + ml];
+                                       /* E */
+                                       k = (i + 1 == dp->ncols) ? 0 : i + 1;
+                                       l = j;
+                                       ml = mj;
+                                       if (dp->oldcell[k + ml] ==
+                                           (int) (dp->oldcell[i + mj] + 1) % dp->states)
+                                               dp->newcell[i + mj] = dp->oldcell[k + ml];
+                                       /* SE */
+                                       if (!(j & 1))
+                                               k = (i + 1 == dp->ncols) ? 0 : i + 1;
+                                       else
+                                               k = i;
+                                       l = (j + 1 == dp->nrows) ? 0 : j + 1;
+                                       ml = l * dp->ncols;
+                                       if (dp->oldcell[k + ml] ==
+                                           (int) (dp->oldcell[i + mj] + 1) % dp->states)
+                                               dp->newcell[i + mj] = dp->oldcell[k + ml];
+                                       /* SW */
+                                       if (j & 1)
+                                               k = (!i) ? dp->ncols - 1 : i - 1;
+                                       else
+                                               k = i;
+                                       l = (j + 1 == dp->nrows) ? 0 : j + 1;
+                                       ml = l * dp->ncols;
+                                       if (dp->oldcell[k + ml] ==
+                                           (int) (dp->oldcell[i + mj] + 1) % dp->states)
+                                               dp->newcell[i + mj] = dp->oldcell[k + ml];
+                                       /* W */
+                                       k = (!i) ? dp->ncols - 1 : i - 1;
+                                       l = j;
+                                       ml = mj;
+                                       if (dp->oldcell[k + ml] ==
+                                           (int) (dp->oldcell[i + mj] + 1) % dp->states)
+                                               dp->newcell[i + mj] = dp->oldcell[k + ml];
+                                       /* NW */
+                                       if (j & 1)
+                                               k = (!i) ? dp->ncols - 1 : i - 1;
+                                       else
+                                               k = i;
+                                       l = (!j) ? dp->nrows - 1 : j - 1;
+                                       ml = l * dp->ncols;
+                                       if (dp->oldcell[k + ml] ==
+                                           (int) (dp->oldcell[i + mj] + 1) % dp->states)
+                                               dp->newcell[i + mj] = dp->oldcell[k + ml];
+                               }
+                               mj += dp->ncols;
+                       }
+               } else if (dp->neighbors == 4 || dp->neighbors == 8) {
+                       for (j = 0; j < dp->nrows; j++) {
+                               for (i = 0; i < dp->ncols; i++) {
+                                       /* N */
+                                       k = i;
+                                       l = (!j) ? dp->nrows - 1 : j - 1;
+                                       ml = l * dp->ncols;
+                                       if (dp->oldcell[k + ml] ==
+                                           (int) (dp->oldcell[i + mj] + 1) % dp->states)
+                                               dp->newcell[i + mj] = dp->oldcell[k + ml];
+                                       /* E */
+                                       k = (i + 1 == dp->ncols) ? 0 : i + 1;
+                                       l = j;
+                                       ml = mj;
+                                       if (dp->oldcell[k + ml] ==
+                                           (int) (dp->oldcell[i + mj] + 1) % dp->states)
+                                               dp->newcell[i + mj] = dp->oldcell[k + ml];
+                                       /* S */
+                                       k = i;
+                                       l = (j + 1 == dp->nrows) ? 0 : j + 1;
+                                       ml = l * dp->ncols;
+                                       if (dp->oldcell[k + ml] ==
+                                           (int) (dp->oldcell[i + mj] + 1) % dp->states)
+                                               dp->newcell[i + mj] = dp->oldcell[k + ml];
+                                       /* W */
+                                       k = (!i) ? dp->ncols - 1 : i - 1;
+                                       l = j;
+                                       ml = mj;
+                                       if (dp->oldcell[k + ml] ==
+                                           (int) (dp->oldcell[i + mj] + 1) % dp->states)
+                                               dp->newcell[i + mj] = dp->oldcell[k + ml];
+                               }
+                               mj += dp->ncols;
+                       }
+                       if (dp->neighbors == 8) {
+                               mj = 0;
+                               for (j = 0; j < dp->nrows; j++) {
+                                       for (i = 0; i < dp->ncols; i++) {
+                                               /* NE */
+                                               k = (i + 1 == dp->ncols) ? 0 : i + 1;
+                                               l = (!j) ? dp->nrows - 1 : j - 1;
+                                               ml = l * dp->ncols;
+                                               if (dp->oldcell[k + ml] ==
+                                                   (int) (dp->oldcell[i + mj] + 1) % dp->states)
+                                                       dp->newcell[i + mj] = dp->oldcell[k + ml];
+                                               /* SE */
+                                               k = (i + 1 == dp->ncols) ? 0 : i + 1;
+                                               l = (j + 1 == dp->nrows) ? 0 : j + 1;
+                                               ml = l * dp->ncols;
+                                               if (dp->oldcell[k + ml] ==
+                                                   (int) (dp->oldcell[i + mj] + 1) % dp->states)
+                                                       dp->newcell[i + mj] = dp->oldcell[k + ml];
+                                               /* SW */
+                                               k = (!i) ? dp->ncols - 1 : i - 1;
+                                               l = (j + 1 == dp->nrows) ? 0 : j + 1;
+                                               ml = l * dp->ncols;
+                                               if (dp->oldcell[k + ml] ==
+                                                   (int) (dp->oldcell[i + mj] + 1) % dp->states)
+                                                       dp->newcell[i + mj] = dp->oldcell[k + ml];
+                                               /* NW */
+                                               k = (!i) ? dp->ncols - 1 : i - 1;
+                                               l = (!j) ? dp->nrows - 1 : j - 1;
+                                               ml = l * dp->ncols;
+                                               if (dp->oldcell[k + ml] ==
+                                                   (int) (dp->oldcell[i + mj] + 1) % dp->states)
+                                                       dp->newcell[i + mj] = dp->oldcell[k + ml];
+                                       }
+                                       mj += dp->ncols;
+                               }
+                       }
+               } else if (dp->neighbors == 3 || dp->neighbors == 9 ||
+                          dp->neighbors == 12) {
+                       for (j = 0; j < dp->nrows; j++) {
+                               for (i = 0; i < dp->ncols; i++) {
+                                       if ((i + j) % 2) {      /* right */
+                                               /* W */
+                                               k = (!i) ? dp->ncols - 1 : i - 1;
+                                               l = j;
+                                               ml = mj;
+                                               if (dp->oldcell[k + ml] ==
+                                                   (int) (dp->oldcell[i + mj] + 1) % dp->states)
+                                                       dp->newcell[i + mj] = dp->oldcell[k + ml];
+                                       } else {        /* left */
+                                               /* E */
+                                               k = (i + 1 == dp->ncols) ? 0 : i + 1;
+                                               l = j;
+                                               ml = mj;
+                                               if (dp->oldcell[k + ml] ==
+                                                   (int) (dp->oldcell[i + mj] + 1) % dp->states)
+                                                       dp->newcell[i + mj] = dp->oldcell[k + ml];
+                                       }
+                                       /* N */
+                                       k = i;
+                                       l = (!j) ? dp->nrows - 1 : j - 1;
+                                       ml = l * dp->ncols;
+                                       if (dp->oldcell[k + ml] ==
+                                           (int) (dp->oldcell[i + mj] + 1) % dp->states)
+                                               dp->newcell[i + mj] = dp->oldcell[k + ml];
+                                       /* S */
+                                       k = i;
+                                       l = (j + 1 == dp->nrows) ? 0 : j + 1;
+                                       ml = l * dp->ncols;
+                                       if (dp->oldcell[k + ml] ==
+                                           (int) (dp->oldcell[i + mj] + 1) % dp->states)
+                                               dp->newcell[i + mj] = dp->oldcell[k + ml];
+                               }
+                               mj += dp->ncols;
+                       }
+                       if (dp->neighbors == 9 || dp->neighbors == 12) {
+                               mj = 0;
+                               for (j = 0; j < dp->nrows; j++) {
+                                       for (i = 0; i < dp->ncols; i++) {
+                                               /* NN */
+                                               k = i;
+                                               if (!j)
+                                                       l = dp->nrows - 2;
+                                               else if (!(j - 1))
+                                                       l = dp->nrows - 1;
+                                               else
+                                                       l = j - 2;
+                                               ml = l * dp->ncols;
+                                               if (dp->oldcell[k + ml] ==
+                                                   (int) (dp->oldcell[i + mj] + 1) % dp->states)
+                                                       dp->newcell[i + mj] = dp->oldcell[k + ml];
+                                               /* SS */
+                                               k = i;
+                                               if (j + 1 == dp->nrows)
+                                                       l = 1;
+                                               else if (j + 2 == dp->nrows)
+                                                       l = 0;
+                                               else
+                                                       l = j + 2;
+                                               ml = l * dp->ncols;
+                                               if (dp->oldcell[k + ml] ==
+                                                   (int) (dp->oldcell[i + mj] + 1) % dp->states)
+                                                       dp->newcell[i + mj] = dp->oldcell[k + ml];
+                                               /* NW */
+                                               k = (!i) ? dp->ncols - 1 : i - 1;
+                                               l = (!j) ? dp->nrows - 1 : j - 1;
+                                               ml = l * dp->ncols;
+                                               if (dp->oldcell[k + ml] ==
+                                                   (int) (dp->oldcell[i + mj] + 1) % dp->states)
+                                                       dp->newcell[i + mj] = dp->oldcell[k + ml];
+                                               /* NE */
+                                               k = (i + 1 == dp->ncols) ? 0 : i + 1;
+                                               l = (!j) ? dp->nrows - 1 : j - 1;
+                                               ml = l * dp->ncols;
+                                               if (dp->oldcell[k + ml] ==
+                                                   (int) (dp->oldcell[i + mj] + 1) % dp->states)
+                                                       dp->newcell[i + mj] = dp->oldcell[k + ml];
+                                               /* SW */
+                                               k = (!i) ? dp->ncols - 1 : i - 1;
+                                               l = (j + 1 == dp->nrows) ? 0 : j + 1;
+                                               ml = l * dp->ncols;
+                                               if (dp->oldcell[k + ml] ==
+                                                   (int) (dp->oldcell[i + mj] + 1) % dp->states)
+                                                       dp->newcell[i + mj] = dp->oldcell[k + ml];
+                                               /* SE */
+                                               k = (i + 1 == dp->ncols) ? 0 : i + 1;
+                                               l = (j + 1 == dp->nrows) ? 0 : j + 1;
+                                               ml = l * dp->ncols;
+                                               if (dp->oldcell[k + ml] ==
+                                                   (int) (dp->oldcell[i + mj] + 1) % dp->states)
+                                                       dp->newcell[i + mj] = dp->oldcell[k + ml];
+                                       }
+                                       mj += dp->ncols;
+                               }
+                               if (dp->neighbors == 12) {
+                                       mj = 0;
+                                       for (j = 0; j < dp->nrows; j++) {
+                                               for (i = 0; i < dp->ncols; i++) {
+                                                       if ((i + j) % 2) {      /* right */
+                                                               /* NNW */
+                                                               k = (!i) ? dp->ncols - 1 : i - 1;
+                                                               if (!j)
+                                                                       l = dp->nrows - 2;
+                                                               else if (!(j - 1))
+                                                                       l = dp->nrows - 1;
+                                                               else
+                                                                       l = j - 2;
+                                                               ml = l * dp->ncols;
+                                                               if (dp->oldcell[k + ml] ==
+                                                                   (int) (dp->oldcell[i + mj] + 1) % dp->states)
+                                                                       dp->newcell[i + mj] = dp->oldcell[k + ml];
+                                                               /* SSW */
+                                                               k = (!i) ? dp->ncols - 1 : i - 1;
+                                                               if (j + 1 == dp->nrows)
+                                                                       l = 1;
+                                                               else if (j + 2 == dp->nrows)
+                                                                       l = 0;
+                                                               else
+                                                                       l = j + 2;
+                                                               ml = l * dp->ncols;
+                                                               if (dp->oldcell[k + ml] ==
+                                                                   (int) (dp->oldcell[i + mj] + 1) % dp->states)
+                                                                       dp->newcell[i + mj] = dp->oldcell[k + ml];
+                                                               /* EE */
+                                                               k = (i + 1 == dp->ncols) ? 0 : i + 1;
+                                                               l = j;
+                                                               ml = mj;
+                                                               if (dp->oldcell[k + ml] ==
+                                                                   (int) (dp->oldcell[i + mj] + 1) % dp->states)
+                                                                       dp->newcell[i + mj] = dp->oldcell[k + ml];
+                                                       } else {        /* left */
+                                                               /* NNE */
+                                                               k = (i + 1 == dp->ncols) ? 0 : i + 1;
+                                                               if (!j)
+                                                                       l = dp->nrows - 2;
+                                                               else if (!(j - 1))
+                                                                       l = dp->nrows - 1;
+                                                               else
+                                                                       l = j - 2;
+                                                               ml = l * dp->ncols;
+                                                               if (dp->oldcell[k + ml] ==
+                                                                   (int) (dp->oldcell[i + mj] + 1) % dp->states)
+                                                                       dp->newcell[i + mj] = dp->oldcell[k + ml];
+                                                               /* SSE */
+                                                               k = (i + 1 == dp->ncols) ? 0 : i + 1;
+                                                               if (j + 1 == dp->nrows)
+                                                                       l = 1;
+                                                               else if (j + 2 == dp->nrows)
+                                                                       l = 0;
+                                                               else
+                                                                       l = j + 2;
+                                                               ml = l * dp->ncols;
+                                                               if (dp->oldcell[k + ml] ==
+                                                                   (int) (dp->oldcell[i + mj] + 1) % dp->states)
+                                                                       dp->newcell[i + mj] = dp->oldcell[k + ml];
+                                                               /* WW */
+                                                               k = (!i) ? dp->ncols - 1 : i - 1;
+                                                               l = j;
+                                                               ml = mj;
+                                                               if (dp->oldcell[k + ml] ==
+                                                                   (int) (dp->oldcell[i + mj] + 1) % dp->states)
+                                                                       dp->newcell[i + mj] = dp->oldcell[k + ml];
+                                                       }
+                                               }
+                                               mj += dp->ncols;
+                                       }
+                               }
+                       }
+               }
+               mj = 0;
+               for (j = 0; j < dp->nrows; j++) {
+                       for (i = 0; i < dp->ncols; i++)
+                               if (dp->oldcell[i + mj] != dp->newcell[i + mj]) {
+                                       dp->oldcell[i + mj] = dp->newcell[i + mj];
+                                       addtolist(mi, i, j, dp->oldcell[i + mj]);
+                               }
+                       mj += dp->ncols;
+               }
+               if (++dp->generation > MI_CYCLES(mi))
+                       init_demon(mi);
+               dp->state = 0;
+       } else {
+               if (dp->ncells[dp->state])
+                       draw_state(mi, dp->state);
+               dp->state++;
+       }
+       if (dp->redrawing) {
+               for (i = 0; i < REDRAWSTEP; i++) {
+                       if (dp->oldcell[dp->redrawpos]) {
+                               drawcell(mi, dp->redrawpos % dp->ncols, dp->redrawpos / dp->ncols,
+                                        dp->oldcell[dp->redrawpos]);
+                       }
+                       if (++(dp->redrawpos) >= dp->ncols * dp->nrows) {
+                               dp->redrawing = 0;
+                               break;
+                       }
+               }
+       }
+}
+void
+release_demon(ModeInfo * mi)
+{
+       if (demons != NULL) {
+               int         screen;
+
+               for (screen = 0; screen < MI_NUM_SCREENS(mi); screen++) {
+                       demonstruct *dp = &demons[screen];
+                       int         shade;
+
+                       if (dp->stippledGC != None) {
+                               XFreeGC(MI_DISPLAY(mi), dp->stippledGC);
+                       }
+                       for (shade = 0; shade < dp->init_bits; shade++)
+                               XFreePixmap(MI_DISPLAY(mi), dp->pixmaps[shade]);
+                       free_struct(dp);
+               }
+               (void) free((void *) demons);
+               demons = NULL;
+       }
+} void
+
+refresh_demon(ModeInfo * mi)
+{
+       demonstruct *dp = &demons[MI_SCREEN(mi)];
+
+       dp->redrawing = 1;
+       dp->redrawpos = 0;
+}
index 0cc7f65970fb5f0f8e1ca7d790319e97fb97504c..ffadb67a601ff5f02cfcc50ebd69709383ff9964 100644 (file)
@@ -52,6 +52,8 @@
 #include <math.h>
 #include "screenhack.h"
 
+#include <signal.h>            /* so we can ignore SIGFPE */
+
 #define POINT_BUFFER_SIZE 10
 #define MAXLEV 4
 #define MAXKINDS  10
@@ -100,6 +102,15 @@ init_flame (Display *dpy, Window window)
   XGCValues gcv;
   XWindowAttributes xgwa;
   Colormap cmap;
+
+#if defined(SIGFPE) && defined(SIG_IGN)
+  /* No doubt a better fix would be to track down where the NaN is coming
+     from, and code around that; but this should do.  Apparently most systems
+     (Linux, Solaris, Irix, ...) ignore FPE by default -- but FreeBSD dumps
+     core by default. */
+  signal (SIGFPE, SIG_IGN);
+#endif
+
   XGetWindowAttributes (dpy, window, &xgwa);
   width = xgwa.width;
   height = xgwa.height;
index 20554824b700bf692d626ada548a2a5d1204f566..f606e05d86cff324d9e440b65d8639eb10232865 100644 (file)
@@ -23,11 +23,21 @@ static const char sccsid[] = "@(#)flow.c 4.10 98/04/24 xlockmore";
  *
  * "flow" shows a variety of continuous phase-space flows around strange
  * attractors.  It includes the well-known Lorentz mask (the "Butterfly"
- * of chaos fame), two forms of Rossler's "Folded Band" and Poincare'
- * section of the "Bagel".
+ * of chaos fame), two forms of Rossler's "Folded Band" and Poincare'
+ * sections of the "Birkhoff Bagel" and Duffing's forced occilator.
  *
  * Revision History:
- * 09-Apr-97: Ported to xlockmore-4
+ * 31-Nov-98: [TDA] Added Duffing  (what a strange day that was :) DAB)
+ *   Duffing's forced oscillator has been added to the formula list and
+ *   the parameters section has been updated to display it in Poincare'
+ *   section.
+ * 30-Nov-98: [TDA] Added travelling perspective option
+ *   A more exciting point-of-view has been added to all autonomous flows.
+ *   This views the flow as seen by a particle moving with the flow.  In the
+ *   metaphor of the original code, I've attached a camera to one of the
+ *   trained bees!
+ * 30-Nov-98: [TDA] Much code cleanup.
+ * 09-Apr-97: [TDA] Ported to xlockmore-4
  * 18-Jul-96: Adapted from swarm.c Copyright (c) 1991 by Patrick J. Naughton.
  * 31-Aug-90: Adapted from xswarm by Jeff Butterworth. (butterwo@ncsc.org)
  */
@@ -49,20 +59,18 @@ static const char sccsid[] = "@(#)flow.c 4.10 98/04/24 xlockmore";
 # include "xlock.h"            /* in xlockmore distribution */
 #endif /* STANDALONE */
 
-ModeSpecOpt flow_opts =
-{0, NULL, 0, NULL, NULL};
+ModeSpecOpt flow_opts = { 0, NULL, 0, NULL, NULL };
 
 #ifdef USE_MODULES
-ModStruct   flow_description =
-{"flow", "init_flow", "draw_flow", "release_flow",
- "refresh_flow", "init_flow", NULL, &flow_opts,
- 1000, 1024, 3000, 1, 64, 1.0, "",
- "Shows dynamic strange attractors", 0, NULL};
+ModStruct   flow_description = {
+       "flow", "init_flow", "draw_flow", "release_flow",
+       "refresh_flow", "init_flow", NULL, &flow_opts,
+       1000, 1024, 3000, 1, 64, 1.0, "",
+       "Shows dynamic strange attractors", 0, NULL
+};
 
 #endif
 
-#define TIMES  2               /* number of time positions recorded */
-
 typedef struct {
        double      x;
        double      y;
@@ -74,81 +82,96 @@ typedef struct {
 } Par;
 
 /* Macros */
-#define X(t,b) (sp->p[(t)*sp->beecount+(b)].x)
-#define Y(t,b) (sp->p[(t)*sp->beecount+(b)].y)
-#define Z(t,b) (sp->p[(t)*sp->beecount+(b)].z)
-#define balance_rand(v)        ((LRAND()/MAXRAND*(v))-((v)/2))         /* random number around 0 */
+#define X(t,b) (sp->p[t][b].x)
+#define Y(t,b) (sp->p[t][b].y)
+#define Z(t,b) (sp->p[t][b].z)
+#define balance_rand(v)        ((LRAND()/MAXRAND*(v))-((v)/2)) /* random around 0 */
+#define SCALE_X(A) (sp->width/2+sp->width/sp->size*(A))
+#define SCALE_Y(A) (sp->height/2+sp->height/sp->size*(A))
 
 typedef struct {
-       int         pix;
        int         width;
        int         height;
        int         count;
        double      size;
-
+       
        int         beecount;   /* number of bees */
-       XSegment   *csegs;      /* bee lines */
+       XSegment   *csegs;          /* bee lines */
        int        *cnsegs;
        XSegment   *old_segs;   /* old bee lines */
+       int         nold_segs;
        double      step;
-       dvector     c;          /* centre */
-       dvector    *p;          /* bee positions x[time][bee#] */
-       double     *t;
-       double      theta;
-       double      dtheta;
-       double      phi;
-       double      dphi;
-       void        (*ODE) (Par par,
-                                               double *dx, double *dy, double *dz,
-                                               double x,   double y,   double z,
-                                               double t);
+       dvector     centre;             /* centre */
+       struct {
+               double  depth;
+               double  height;
+       }           view;
+       dvector    *p[2];   /* bee positions x[time][bee#] */
+       struct {
+               double  theta;
+               double  dtheta;
+               double  phi;
+               double  dphi;
+       }           tumble;
+       dvector  (*ODE) (Par par, double x, double y, double z);
        Par         par;
 } flowstruct;
 
 static flowstruct *flows = NULL;
 
-static void
-Lorentz(Par par,
-               double *dx, double *dy, double *dz,
-               double x,   double y,   double z,
-               double t)
+static dvector
+Lorentz(Par par, double x, double y, double z)
 {
-       *dx = par.a * (y - x);
-       *dy = x * (par.b - z) - y;
-       *dz = x * y - par.c * z;
+       dvector d;
+
+       d.x = par.a * (y - x);
+       d.y = x * (par.b - z) - y;
+       d.z = x * y - par.c * z;
+       return d;
 }
 
-static void
-Rossler(Par par,
-               double *dx, double *dy, double *dz,
-               double x,   double y,   double z,
-               double t)
+static dvector
+Rossler(Par par, double x, double y, double z)
 {
-       *dx = -(y + par.a * z);
-       *dy = x + y * par.b;
-       *dz = par.c + z * (x - 5.7);
+       dvector d;
+
+       d.x = -(y + par.a * z);
+       d.y = x + y * par.b;
+       d.z = par.c + z * (x - 5.7);
+       return d;
 }
 
-static void
-RosslerCone(Par par,
-                       double *dx, double *dy, double *dz,
-                       double x,   double y,   double z,
-                       double t)
+static dvector
+RosslerCone(Par par, double x, double y, double z)
 {
-       *dx = -(y + par.a * z);
-       *dy = x + y * par.b - z * z * par.c;
-       *dz = 0.2 + z * (x - 5.7);
+       dvector d;
+
+       d.x = -(y + par.a * z);
+       d.y = x + y * par.b - z * z * par.c;
+       d.z = 0.2 + z * (x - 5.7);
+       return d;
 }
 
-static void
-Bagel(Par par,
-         double *dx, double *dy, double *dz,
-         double x,   double y,   double z,
-         double t)
+static dvector
+Birkhoff(Par par, double x, double y, double z)
 {
-       *dx = -y + par.b * sin(par.c * t);
-       *dy = 0.7 * x + par.a * y * (0.1 - x * x);
-       *dz = 0;
+       dvector d;
+
+       d.x = -y + par.b * sin(z);
+       d.y = 0.7 * x + par.a * y * (0.1 - x * x);
+       d.z = par.c;
+       return d;
+}
+
+static dvector
+Duffing(Par par, double x, double y, double z)
+{
+       dvector d;
+
+       d.x = -par.a * x - y/2 - y * y * y/8 + par.b * cos(z);
+       d.y = 2*x;
+       d.z = par.c;
+       return d;
 }
 
 void
@@ -156,7 +179,9 @@ init_flow(ModeInfo * mi)
 {
        flowstruct *sp;
        int         b;
+       double      beemult = 1;
        dvector     range;
+       static int  allocated = 0;
 
        if (flows == NULL) {
                if ((flows = (flowstruct *) calloc(MI_NUM_SCREENS(mi),
@@ -165,9 +190,121 @@ init_flow(ModeInfo * mi)
        }
        sp = &flows[MI_SCREEN(mi)];
 
-       sp->beecount = MI_COUNT(mi);
-       if (sp->beecount < 0) {
-               /* if sp->beecount is random ... the size can change */
+       sp->count = 0;
+
+       sp->width = MI_WIDTH(mi);
+       sp->height = MI_HEIGHT(mi);
+
+       sp->tumble.theta = balance_rand(M_PI);
+       sp->tumble.phi = balance_rand(M_PI);
+       sp->tumble.dtheta = 0.002;
+       sp->tumble.dphi = 0.001;
+       sp->view.height = 0;
+       sp->view.depth = 0; /* no perspective view */
+
+       switch (NRAND(8)) {
+       case 0:
+               sp->view.depth = 10;
+               sp->view.height = 0.2;
+               beemult = 3;
+       case 1:
+               sp->ODE = Lorentz;
+               sp->step = 0.02;
+               sp->size = 60;
+               sp->centre.x = 0;
+               sp->centre.y = 0;
+               sp->centre.z = 24;
+               range.x = 5;
+               range.y = 5;
+               range.z = 1;
+               sp->par.a = 10 + balance_rand(5);
+               sp->par.b = 28 + balance_rand(5);
+               sp->par.c = 2 + balance_rand(1);
+               break;
+       case 2:
+               sp->view.depth = 10;
+               sp->view.height = 0.1;
+               beemult = 4;
+       case 3:
+               sp->ODE = Rossler;
+               sp->step = 0.05;
+               sp->size = 24;
+               sp->centre.x = 0;
+               sp->centre.y = 0;
+               sp->centre.z = 3;
+               range.x = 4;
+               range.y = 4;
+               range.z = 7;
+               sp->par.a = 2 + balance_rand(1);
+               sp->par.b = 0.2 + balance_rand(0.1);
+               sp->par.c = 0.2 + balance_rand(0.1);
+               break;
+       case 4:
+               sp->view.depth = 10;
+               sp->view.height = 0.1;
+               beemult = 3;
+       case 5:
+               sp->ODE = RosslerCone;
+               sp->step = 0.05;
+               sp->size = 24;
+               sp->centre.x = 0;
+               sp->centre.y = 0;
+               sp->centre.z = 3;
+               range.x = 4;
+               range.y = 4;
+               range.z = 4;
+               sp->par.a = 2;
+               sp->par.b = 0.2;
+               sp->par.c = 0.25 + balance_rand(0.09);
+               break;
+       case 6:
+               sp->ODE = Birkhoff;
+               sp->step = 0.04;
+               sp->size = 2.6;
+               sp->centre.x = 0;
+               sp->centre.y = 0;
+               sp->centre.z = 0;
+               range.x = 3;
+               range.y = 4;
+               range.z = 0;
+               sp->par.a = 10 + balance_rand(5);
+               sp->par.b = 0.35 + balance_rand(0.25);
+               sp->par.c = 1.57;
+               sp->tumble.theta = 0;
+               sp->tumble.phi = 0;
+               sp->tumble.dtheta = 0;
+               sp->tumble.dphi = 0;
+               break;
+       case 7:
+       default:
+               sp->ODE = Duffing;
+               sp->step = 0.02;
+               sp->size = 30;
+               sp->centre.x = 0;
+               sp->centre.y = 0;
+               sp->centre.z = 0;
+               range.x = 20;
+               range.y = 20;
+               range.z = 0;
+               sp->par.a = 0.2 + balance_rand(0.1);
+               sp->par.b = 27.0 + balance_rand(3.0);
+               sp->par.c = 1.33;
+               sp->tumble.theta = 0;
+               sp->tumble.phi = 0;
+               sp->tumble.dtheta = -NRAND(2)*sp->par.c*sp->step;
+               sp->tumble.dphi = 0;
+               beemult = 0.5;
+               break;
+       }
+
+       sp->beecount = beemult * MI_COUNT(mi);
+       if (sp->beecount < 0)   /* random variations */ 
+               sp->beecount = NRAND(-sp->beecount) + 1; /* Minimum 1 */
+
+       /* Clear the background. */
+       MI_CLEARWINDOW(mi);
+
+       if(!allocated || sp->beecount != allocated){ /* reallocate */
                if (sp->csegs != NULL) {
                        (void) free((void *) sp->csegs);
                        sp->csegs = NULL;
@@ -180,91 +317,15 @@ init_flow(ModeInfo * mi)
                        (void) free((void *) sp->old_segs);
                        sp->old_segs = NULL;
                }
-               if (sp->p != NULL) {
-                       (void) free((void *) sp->p);
-                       sp->p = NULL;
+               if (sp->p[0] != NULL) {
+                       (void) free((void *) sp->p[0]);
+                       sp->p[0] = NULL;
                }
-               if (sp->t != NULL) {
-                       (void) free((void *) sp->t);
-                       sp->t = NULL;
+               if (sp->p[1] != NULL) {
+                       (void) free((void *) sp->p[1]);
+                       sp->p[1] = NULL;
                }
-               sp->beecount = NRAND(-sp->beecount) + 1;        /* Add 1 so its not too boring */
        }
-       sp->count = 0;
-
-       sp->width = MI_WIDTH(mi);
-       sp->height = MI_HEIGHT(mi);
-
-       sp->theta = balance_rand(M_PI);
-       sp->phi = balance_rand(M_PI);
-       sp->dtheta = 0.002;
-       sp->dphi = 0.001;
-       switch (NRAND(4)) {
-               case 0:
-                       sp->ODE = Lorentz;
-                       sp->step = 0.02;
-                       sp->size = 60;
-                       sp->c.x = 0;
-                       sp->c.y = 0;
-                       sp->c.z = 24;
-                       range.x = 5;
-                       range.y = 5;
-                       range.z = 1;
-                       sp->par.a = 10 + balance_rand(5);
-                       sp->par.b = 28 + balance_rand(5);
-                       sp->par.c = 2 + balance_rand(1);
-                       break;
-               case 1:
-                       sp->ODE = Rossler;
-                       sp->step = 0.05;
-                       sp->size = 24;
-                       sp->c.x = 0;
-                       sp->c.y = 0;
-                       sp->c.z = 3;
-                       range.x = 4;
-                       range.y = 4;
-                       range.z = 7;
-                       sp->par.a = 2 + balance_rand(1);
-                       sp->par.b = 0.2 + balance_rand(0.1);
-                       sp->par.c = 0.2 + balance_rand(0.1);
-                       break;
-               case 2:
-                       sp->ODE = RosslerCone;
-                       sp->step = 0.05;
-                       sp->size = 24;
-                       sp->c.x = 0;
-                       sp->c.y = 0;
-                       sp->c.z = 3;
-                       range.x = 4;
-                       range.y = 4;
-                       range.z = 4;
-                       sp->par.a = 2;
-                       sp->par.b = 0.2;
-                       sp->par.c = 0.25 + balance_rand(0.09);
-                       break;
-               case 3:
-               default:
-                       sp->ODE = Bagel;
-                       sp->step = 0.04;
-                       sp->size = 2.6;
-                       sp->c.x = 0 /*-1.0*/ ;
-                       sp->c.y = 0;
-                       sp->c.z = 0;
-                       range.x = 3;
-                       range.y = 4;
-                       range.z = 0;
-                       sp->par.a = 10 + balance_rand(5);
-                       sp->par.b = 0.35 + balance_rand(0.25);
-                       sp->par.c = 1.57;
-                       sp->theta = 0;
-                       sp->phi = 0;
-                       sp->dtheta = 0 /*sp->par.c*sp->step */ ;
-                       sp->dphi = 0;
-                       break;
-       }
-
-       /* Clear the background. */
-       MI_CLEARWINDOW(mi);
 
        /* Allocate memory. */
 
@@ -274,24 +335,19 @@ init_flow(ModeInfo * mi)
                sp->cnsegs = (int *) malloc(sizeof (int) * MI_NPIXELS(mi));
 
                sp->old_segs = (XSegment *) malloc(sizeof (XSegment) * sp->beecount);
-               sp->p = (dvector *) malloc(sizeof (dvector) * sp->beecount * TIMES);
-               sp->t = (double *) malloc(sizeof (double) * sp->beecount);
+               sp->p[0] = (dvector *) malloc(sizeof (dvector) * sp->beecount);
+               sp->p[1] = (dvector *) malloc(sizeof (dvector) * sp->beecount);
        }
+
        /* Initialize point positions, velocities, etc. */
 
-       /* bees */
        for (b = 0; b < sp->beecount; b++) {
-               X(0, b) = balance_rand(range.x);
-               X(1, b) = X(0, b);
-               Y(0, b) = balance_rand(range.y);
-               Y(1, b) = Y(0, b);
-               Z(0, b) = balance_rand(range.z);
-               Z(1, b) = Z(0, b);
-               sp->t[b] = 0;
+               X(1, b) = X(0, b) = balance_rand(range.x);
+               Y(1, b) = Y(0, b) = balance_rand(range.y);
+               Z(1, b) = Z(0, b) = balance_rand(range.z);
        }
 }
 
-
 void
 draw_flow(ModeInfo * mi)
 {
@@ -299,19 +355,33 @@ draw_flow(ModeInfo * mi)
        Window      window = MI_WINDOW(mi);
        GC          gc = MI_GC(mi);
        flowstruct *sp = &flows[MI_SCREEN(mi)];
-       int         b, c;
+       int         b, c, i;
        int         col, ix;
-       double      sint, cost, sinp, cosp;
-
-       sp->theta += sp->dtheta;
-       sp->phi += sp->dphi;
-       sint = sin(sp->theta);
-       cost = cos(sp->theta);
-       sinp = sin(sp->phi);
-       cosp = cos(sp->phi);
+       double      M[3][3]; /* transformation matrix */
+
+       if(!sp->view.depth){ /* simple 3D tumble */
+               double      sint, cost, sinp, cosp;
+               sp->tumble.theta += sp->tumble.dtheta;
+               sp->tumble.phi += sp->tumble.dphi;
+               sint = sin(sp->tumble.theta);
+               cost = cos(sp->tumble.theta);
+               sinp = sin(sp->tumble.phi);
+               cosp = cos(sp->tumble.phi);
+               M[0][0]= cost; M[0][1]=-sint*cosp; M[0][2]= sint*sinp;
+               M[1][0]= sint; M[1][1]= cost*cosp; M[1][2]=-cost*sinp;
+               M[2][0]= 0;    M[2][1]= 0;         M[2][2]= 1;
+       } else { /* initialize matrix */
+               M[0][0]= 0; M[0][1]= 0; M[0][2]= 0;
+               M[1][0]= 0; M[1][1]= 0; M[1][2]= 0;
+               M[2][0]= 0; M[2][1]= 0; M[2][2]= 0;
+
+       }
+
        for (col = 0; col < MI_NPIXELS(mi); col++)
                sp->cnsegs[col] = 0;
 
+       MI_IS_DRAWN(mi) = True;
+
        /* <=- Bees -=> */
        for (b = 0; b < sp->beecount; b++) {
                /* Age the arrays. */
@@ -321,82 +391,148 @@ draw_flow(ModeInfo * mi)
 
                /* 2nd order Kunge Kutta */
                {
-                       double      k1x, k1y, k1z;
-                       double      k2x, k2y, k2z;
-
-                       sp->t[b] += sp->step;   /* tick */
-                       sp->ODE(sp->par, &k1x, &k1y, &k1z,
-                               X(1, b), Y(1, b), Z(1, b), sp->t[b]);
-                       k1x *= sp->step;
-                       k1y *= sp->step;
-                       k1z *= sp->step;
-                       sp->ODE(sp->par, &k2x, &k2y, &k2z,
-                               X(1, b) + k1x, Y(1, b) + k1y, Z(1, b) + k1z, sp->t[b]);
-                       k2x *= sp->step;
-                       k2y *= sp->step;
-                       k2z *= sp->step;
-                       X(0, b) = X(1, b) + (k1x + k2x) / 2.0;
-                       Y(0, b) = Y(1, b) + (k1y + k2y) / 2.0;
-                       Z(0, b) = Z(1, b) + (k1z + k2z) / 2.0;
+                       dvector     k1, k2;
+
+                       k1 = sp->ODE(sp->par, X(1, b), Y(1, b), Z(1, b));
+                       k1.x *= sp->step;
+                       k1.y *= sp->step;
+                       k1.z *= sp->step;
+                       k2 = sp->ODE(sp->par, X(1, b) + k1.x, Y(1, b) + k1.y, Z(1, b) + k1.z);
+                       k2.x *= sp->step;
+                       k2.y *= sp->step;
+                       k2.z *= sp->step;
+                       X(0, b) = X(1, b) + (k1.x + k2.x) / 2.0;
+                       Y(0, b) = Y(1, b) + (k1.y + k2.y) / 2.0;
+                       Z(0, b) = Z(1, b) + (k1.z + k2.z) / 2.0;
                }
 
-               /* Fill the segment lists. */
-
-
-               /* Tumble */
-#define DISPLAYX(A) (sp->width/2+sp->width/sp->size* \
-                    ((X((A),b)-sp->c.x)*cost \
-                     -(Y((A),b)-sp->c.y)*sint*cosp \
-                     +(Z((A),b)-sp->c.z)*sint*sinp))
-#define DISPLAYY(A) (sp->height/2-sp->height/sp->size* \
-                    ((X((A),b)-sp->c.x)*sint \
-                     +(Y((A),b)-sp->c.y)*cost*cosp \
-                     -(Z((A),b)-sp->c.z)*cost*sinp))
-
                /* Colour according to bee */
                col = b % (MI_NPIXELS(mi) - 1);
-
                ix = col * sp->beecount + sp->cnsegs[col];
-               sp->csegs[ix].x1 = DISPLAYX(0);
-               sp->csegs[ix].y1 = DISPLAYY(0);
-               sp->csegs[ix].x2 = DISPLAYX(1);
-               sp->csegs[ix].y2 = DISPLAYY(1);
-               sp->cnsegs[col]++;
-       }
-       if (sp->count) {
+
+               /* Fill the segment lists. */
+
+               if(sp->view.depth) /* perspective view has special points */
+                       if(b==0){ /* point of view */
+                               sp->centre.x=X(0, b);
+                               sp->centre.y=Y(0, b);
+                               sp->centre.z=Z(0, b);
+                       }else if(b==1){ /* neighbour: used to compute local axes */
+                               double x[3], p[3], x2=0, xp=0;
+                               int j;
+
+                               /* forward */                           
+                               x[0] = X(0, 0) - X(1, 0);
+                               x[1] = Y(0, 0) - Y(1, 0);
+                               x[2] = Z(0, 0) - Z(1, 0);
+                       
+                               /* neighbour */
+                               p[0] = X(0, 1) - X(1, 0);
+                               p[1] = Y(0, 1) - Y(1, 0);
+                               p[2] = Z(0, 1) - Z(1, 0);
+
+                               for(i=0; i<3; i++){
+                                       x2+= x[i]*x[i];    /* X . X */
+                                       xp+= x[i]*p[i];    /* X . P */
+                                       M[0][i] = x[i];    /* X */
+                               }
+
+                               for(i=0; i<3; i++)               /* (X x P) x X */
+                                       M[1][i] = x2*p[i] - xp*x[i]; /* == (X . X) P - (X . P) X */
+                               
+                               M[2][0] =  x[1]*p[2] - x[2]*p[1]; /* X x P */
+                               M[2][1] = -x[0]*p[2] + x[2]*p[0];
+                               M[2][2] =  x[0]*p[1] - x[1]*p[0];
+
+                               /* normalise axes */
+                               for(j=0; j<3; j++){
+                                       double A=0;
+                                       for(i=0; i<3; i++) A+=M[j][i]*M[j][i]; /* sum squares */
+                                       A=sqrt(A);
+                                       for(i=0; i<3; i++) M[j][i]/=A;
+                               }
+
+                               X(0, 1)=X(0, 0)+M[1][0]; /* adjust neighbour */
+                               Y(0, 1)=Y(0, 0)+M[1][1];
+                               Z(0, 1)=Z(0, 0)+M[1][2];
+
+#if 0  /* display local axes for testing */
+                               X(1, b)=X(0, 0);
+                               Y(1, b)=Y(0, 0);
+                               Z(1, b)=Z(0, 0);
+                       }else if(b==2){
+                               X(0, b)=X(0, 0)+0.5*M[0][0];
+                               Y(0, b)=Y(0, 0)+0.5*M[0][1];
+                               Z(0, b)=Z(0, 0)+0.5*M[0][2];
+                               X(1, b)=X(0, 0);
+                               Y(1, b)=Y(0, 0);
+                               Z(1, b)=Z(0, 0);
+                       }else if(b==3){
+                               X(0, b)=X(0, 0)+1.5*M[2][0];
+                               Y(0, b)=Y(0, 0)+1.5*M[2][1];
+                               Z(0, b)=Z(0, 0)+1.5*M[2][2];
+                               X(1, b)=X(0, 0);
+                               Y(1, b)=Y(0, 0);
+                               Z(1, b)=Z(0, 0);
+#endif
+                       }
+               
+               for(i=0; i<2; i++){
+                       double x=X(i,b)-sp->centre.x;
+                       double y=Y(i,b)-sp->centre.y;
+                       double z=Z(i,b)-sp->centre.z;
+                       double X=M[0][0]*x + M[0][1]*y + M[0][2]*z;
+                       double Y=M[1][0]*x + M[1][1]*y + M[1][2]*z;
+                       double Z=M[2][0]*x + M[2][1]*y + M[2][2]*z+sp->view.height;
+                       double absx, absy;                              
+                       if(sp->view.depth){
+                               if(X <= 0) break;
+                               absx=SCALE_X(sp->view.depth*Y/X);
+                               absy=SCALE_Y(sp->view.depth*Z/X);
+                               if(absx < -sp->width || absx > 2*sp->width ||
+                                  absy < -sp->height || absy > 2*sp->height)
+                                       break;
+                       }else{
+                               absx=SCALE_X(X);
+                               absy=SCALE_Y(Y);
+                       }
+                       if(i){
+                               sp->csegs[ix].x1 = (short) absx;
+                               sp->csegs[ix].y1 = (short) absy;
+                       }else{
+                               sp->csegs[ix].x2 = (short) absx;
+                               sp->csegs[ix].y2 = (short) absy;
+                       }
+               }
+               if(i == 2) /* both assigned */
+                       sp->cnsegs[col]++;
+    }
+       if (sp->count) { /* erase */
                XSetForeground(display, gc, MI_BLACK_PIXEL(mi));
-               XDrawSegments(display, window, gc, sp->old_segs, sp->beecount);
+               XDrawSegments(display, window, gc, sp->old_segs, sp->nold_segs);
        }
-       XSetForeground(display, gc, MI_WHITE_PIXEL(mi));
-       if (MI_NPIXELS(mi) > 2) {
-               for (col = 0; col < MI_NPIXELS(mi); col++) {
+
+       if (MI_NPIXELS(mi) > 2){ /* render colour */
+               for (col = 0; col < MI_NPIXELS(mi); col++)
                        if (sp->cnsegs[col] > 0) {
                                XSetForeground(display, gc, MI_PIXEL(mi, col));
                                XDrawSegments(display, window, gc,
-                                             sp->csegs + col * sp->beecount,
-                                             sp->cnsegs[col]);
+                                             sp->csegs + col * sp->beecount, sp->cnsegs[col]);
                        }
-               }
-       } else {
-         /* mono */
-         XSetForeground(display, gc, MI_PIXEL(mi, 1));
-         XDrawSegments(display, window, gc,
-                                       sp->csegs + col * sp->beecount,
-                                       sp->cnsegs[col]);
+       } else {                /* render mono */
+               XSetForeground(display, gc, MI_WHITE_PIXEL(mi));
+               XDrawSegments(display, window, gc,
+                                         sp->csegs + col * sp->beecount, sp->cnsegs[col]);
        }
+
+       /* Copy to erase-list */
        for (col = 0, c = 0; col < MI_NPIXELS(mi); col++)
-               for (b = 0; b < sp->cnsegs[col]; b++) {
-                       XSegment    s = (sp->csegs + col * sp->beecount)[b];
-
-                       sp->old_segs[c].x1 = s.x1;
-                       sp->old_segs[c].y1 = s.y1;
-                       sp->old_segs[c].x2 = s.x2;
-                       sp->old_segs[c].y2 = s.y2;
-                       c++;
-               }
-       if (++sp->count > MI_CYCLES(mi)) {
+               for (b = 0; b < sp->cnsegs[col]; b++)
+                       sp->old_segs[c++] = (sp->csegs + col * sp->beecount)[b];
+       sp->nold_segs = c;
+
+       if (++sp->count > MI_CYCLES(mi)) /* pick a new flow */
                init_flow(mi);
-       }
 }
 
 void
@@ -414,10 +550,10 @@ release_flow(ModeInfo * mi)
                                (void) free((void *) sp->cnsegs);
                        if (sp->old_segs != NULL)
                                (void) free((void *) sp->old_segs);
-                       if (sp->p != NULL)
-                               (void) free((void *) sp->p);
-                       if (sp->t != NULL)
-                               (void) free((void *) sp->t);
+                       if (sp->p[0] != NULL)
+                               (void) free((void *) sp->p[0]);
+                       if (sp->p[1] != NULL)
+                               (void) free((void *) sp->p[1]);
                }
                (void) free((void *) flows);
                flows = NULL;
index c15ada915b85b6b2ee7cc0b24d82b6d80fffae7b..16b8bd68e6b661a5d09e440e08b6a2a46de60dab 100644 (file)
@@ -97,7 +97,7 @@ uninstall: uninstall-program uninstall-man
 install-strip:
        $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install
 
-install-program:
+install-program: $(EXES)
        @exes="$(EXES)" ;                                               \
        if [ ! -d $(HACKDIR) ]; then $(INSTALL_DIRS) $(HACKDIR) ; fi ;  \
        for program in $$exes; do                                       \
@@ -105,7 +105,7 @@ install-program:
          $(INSTALL_PROGRAM) $$program $(HACKDIR)/$$program ;           \
        done
 
-install-man:
+install-man: $(MEN)
        @men="$(MEN)" ;                                                 \
        if [ ! -d $(man1dir) ]; then $(INSTALL_DIRS) $(man1dir) ; fi ;  \
        for man in $$men; do                                            \
index 412c719f9398b7f7410094081e85a8ceafa9dbea..26a60b588b26af160eafdd1d07c29667a1026489 100644 (file)
@@ -38,9 +38,7 @@ static const char sccsid[] = "@(#)cage.c      4.07 98/01/04 xlockmore";
  * Since I'm not a native English speaker, my apologies for any grammatical
  * mistake.
  *
- * My e-mail addresses are
- * vianna@cat.cbpf.br 
- *         and
+ * My e-mail address is
  * m-vianna@usa.net
  *
  * Marcelo F. Vianna (Jun-01-1997)
index a265334da55ec2a7a716c7f02bf73919b89a4598..66560fca5448766521580b0374ef620a02ed3657 100644 (file)
@@ -38,9 +38,7 @@ static const char sccsid[] = "@(#)moebius.c   4.08 97/01/04 xlockmore";
  * Since I'm not a native English speaker, my apologies for any grammatical
  * mistake.
  *
- * My e-mail addresses are
- * vianna@cat.cbpf.br 
- *         and
+ * My e-mail address is
  * m-vianna@usa.net
  *
  * Marcelo F. Vianna (Jun-01-1997)
index 1fc3e1b993e06cf0cdd269c14e536e0f9f120c11..d210016e2acae22df807c88d92171e068de8ecde 100644 (file)
@@ -39,9 +39,7 @@ static const char sccsid[] = "@(#)morph3d.c   4.07 97/11/24 xlockmore";
  * Since I'm not a native English speaker, my apologies for any grammatical
  * mistake.
  *
- * My e-mail addresses are
- * vianna@cat.cbpf.br 
- *         and
+ * My e-mail address is
  * m-vianna@usa.net
  *
  * Marcelo F. Vianna (Feb-13-1997)
index c165a748b63e5232830519c2b8120a5d66272486..85d06f3a417e71ea5025bdefed0706d88b7be97a 100644 (file)
@@ -33,10 +33,7 @@ static const char sccsid[] = "@(#)pipes.c    4.07 97/11/24 xlockmore";
  * Since I'm not a native English speaker, my apologies for any grammatical
  * mistake.
  *
- * My e-mail addresses are
- *
- * vianna@cat.cbpf.br 
- *         and
+ * My e-mail address is
  * m-vianna@usa.net
  * Marcelo F. Vianna (Apr-09-1997)
  *
index 69ea19583722f90573ae7d2b1dfc6ed2d1d1295e..3c651a629c8e1b730e2b466213ee518009079e75 100644 (file)
@@ -32,9 +32,7 @@ static const char sccsid[] = "@(#)rubik.c     4.07 97/11/24 xlockmore";
  * Since I'm not a native English speaker, my apologies for any grammatical
  * mistake.
  *
- * My e-mail addresses are
- * vianna@cat.cbpf.br 
- *         and
+ * My e-mail address is
  * m-vianna@usa.net
  *
  * Marcelo F. Vianna (Jul-31-1997)
index 9c9bf0f7d5222f2f52cbc50c084434debb52d6b0..c12316a148251cbe2946f143db156c7d2238e855 100644 (file)
@@ -33,9 +33,7 @@ static const char sccsid[] = "@(#)stairs.c    4.07 97/11/24 xlockmore";
  * Since I'm not a native English speaker, my apologies for any grammatical
  * mistake.
  *
- * My e-mail addresses are
- * vianna@cat.cbpf.br 
- *         and
+ * My e-mail address is
  * m-vianna@usa.net
  *
  * Marcelo F. Vianna (Jun-01-1997)
index 44f64dbf3d97ae2425e03d11ce326fdc9a642045..ded8bbb5567d19bc7d5c210fd34026533aaae9c4 100644 (file)
 # include "config.h"
 #endif
 
-#ifdef HAVE_XPM                /* whole file */
-
 #include <stdlib.h>
 #include <stdio.h>
 #include <X11/Intrinsic.h>
-#include <X11/Xutil.h>
-#include <X11/xpm.h>
 
 extern char *progname;
 
+#ifdef HAVE_XPM                /* whole file */
+
+#include <X11/Xutil.h>
+#include <X11/xpm.h>
+
 static Bool
 bigendian (void)
 {
@@ -135,7 +136,7 @@ xpm_to_ximage (Display *dpy, Visual *visual, Colormap cmap, char **xpm_data)
 
 #else  /* !HAVE_XPM */
 
-static XImage *
+XImage *
 xpm_to_ximage (char **xpm_data)
 {
   fprintf(stderr, "%s: not compiled with XPM support.\n", progname);
index 7e8da8a2b2eead3e65baaa1045d9585eb22b7688..7cab38d68b531bd635b6723b28cf7d6ea29db3a2 100644 (file)
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 1993, 1995, 1996, 1997, 1998
+/* xscreensaver, Copyright (c) 1993, 1995, 1996, 1997, 1998, 1999
  *  Jamie Zawinski <jwz@jwz.org>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
@@ -126,6 +126,11 @@ init_circles (Display *dpy, Window window)
 
   cycle_p = mono_p ? False : get_boolean_resource ("cycle", "Cycle");
 
+  /* If the visual isn't color-indexed, don't bother trying to
+     allocate writable cells. */
+  if (cycle_p && !has_writable_cells (xgwa.screen, xgwa.visual))
+    cycle_p = False;
+
 
   if (mono_p)
     ;
@@ -207,6 +212,8 @@ run_circles (Display *dpy, Window window)
   static Bool first_time_p = True;
   Bool done = False;
   Bool inhibit_sleep = False;
+  static int clear_tick = 0;
+
   XFillRectangle (dpy, pixmap, erase_gc, 0, 0, width, height);
   for (i = 0; i < count; i++)
     {
@@ -307,25 +314,15 @@ run_circles (Display *dpy, Window window)
              XSetBackground (dpy, copy_gc, colors [bg_index].pixel);
            }
        }
-#if 1
       /* Sometimes go out from the inside instead of the outside */
-      else if ((random () % 10) == 0)
+      else if (clear_tick == 0 && ((random () % 3) == 0))
        {
-# if 0
-         if (! mono_p)
-           {
-             unsigned long swap = fg_index;
-             fg_index = bg_index;
-             bg_index = swap;
-             XSetForeground (dpy, copy_gc, colors [fg_index].pixel);
-             XSetBackground (dpy, copy_gc, colors [bg_index].pixel);
-           }
-# endif
          iterations = 0; /* ick */
          for (i = 0; i < count; i++)
            circles [i].radius %= circles [i].increment;
+
+          clear_tick = ((random() % 8) + 4) | 1;   /* must be odd */
        }
-#endif
       else
        {
          oiterations = iterations;
@@ -393,10 +390,9 @@ run_circles (Display *dpy, Window window)
          if (! (random() % 10))
            direction = -1;
        }
-      if (done)
-       really_first_p = False;
 
       XSync(dpy, False);
+      screenhack_handle_events (dpy);
 
       if (cycle_p && cycle_delay)
        {
@@ -405,11 +401,28 @@ run_circles (Display *dpy, Window window)
            {
              rotate_colors (dpy, cmap, colors, ncolors, direction);
              usleep(cycle_delay);
+              screenhack_handle_events (dpy);
              i += cycle_delay;
            }
        }
+      else if (cmode != seuss_mode &&
+               done && !really_first_p && cycle_delay > 0)
+        usleep (cycle_delay * 50);
       else
-       usleep (d);
+        usleep (d);
+
+      if (done)
+       really_first_p = False;
+    }
+
+  if (done && clear_tick > 0)
+    {
+      clear_tick--;
+      if (!clear_tick)
+        {
+          XClearWindow (dpy, window);
+          if (buffer) XFillRectangle (dpy, buffer, erase_gc, 0,0,width,height);
+        }
     }
 }
 
index c762a162f71b044f7a6c4d43538c7998cb0b05ec..7b252e87d77c0e2cb8e39830e3e952b68c1bf61c 100644 (file)
@@ -21,6 +21,10 @@ static const char sccsid[] = "@(#)hop.c      4.02 97/04/01 xlockmore";
  *
  * Revision History:
  * Changes of David Bagley <bagleyd@bigfoot.com>
+ * 24-Jun-97: EJK and RR functions stolen from xmartin2.2
+ *            Ed Kubaitis <ejk@ux2.cso.uiuc.edu> ejk functions and xmartin 
+ *            Renaldo Recuerdo rr function, generalized exponent version
+ *              of the Barry Martin's square root function
  * 10-May-97: jwz@jwz.org: ported from xlockmore 4.03a10 to be a 
  *                       standalone program and thus usable with xscreensaver
  *                       (I threw away my 1992 port and started over.)
@@ -28,7 +32,7 @@ static const char sccsid[] = "@(#)hop.c       4.02 97/04/01 xlockmore";
  *            July 87 p. 111.  Sometimes they are amazing but there are a
  *            few duds (I did not see a pattern in the parameters).
  * 29-Mar-95: changed name from hopalong to hop
- * 09-Dec-94: added sine hop
+ * 09-Dec-94: added Barry Martin's sine hop
  *
  * (12-Aug-92: jwz@lucid.com: made xlock version run standalone.)
  *
@@ -44,6 +48,8 @@ static const char sccsid[] = "@(#)hop.c       4.02 97/04/01 xlockmore";
  * 20-Sep-89: Lint.
  * 31-Aug-88: Forked from xlock.c for modularity.
  * 23-Mar-88: Coded HOPALONG routines from Scientific American Sept. 86 p. 14.
+ *            Hopalong was attributed to Barry Martin of Aston University
+ *            (Birmingham, England)
  */
 
 #ifdef STANDALONE
@@ -52,9 +58,9 @@ static const char sccsid[] = "@(#)hop.c       4.02 97/04/01 xlockmore";
 # define HACK_DRAW                                     draw_hop
 # define HACK_FREE                                     release_hop
 # define hop_opts                                      xlockmore_opts
-# define DEFAULTS      "*count:                1000    \n"                     \
+# define DEFAULTS      "*delay:                10000   \n"                     \
+                                       "*count:                1000    \n"                     \
                                        "*cycles:               2500    \n"                     \
-                                       "*delay:                10000   \n"                     \
                                        "*ncolors:              200     \n"
 # define SMOOTH_COLORS
 # include "xlockmore.h"                                /* from the xscreensaver distribution */
@@ -63,14 +69,50 @@ static const char sccsid[] = "@(#)hop.c     4.02 97/04/01 xlockmore";
 # include "xlock.h"                                    /* from the xlockmore distribution */
 #endif /* !STANDALONE */
 
-static Bool jong;
-static Bool sine;
-
+#define DEF_MARTIN "False"
+#define DEF_POPCORN "False"
+#define DEF_EJK1 "False"
+#define DEF_EJK2 "False"
+#define DEF_EJK3 "False"
+#define DEF_EJK4 "False"
+#define DEF_EJK5 "False"
+#define DEF_EJK6 "False"
+#define DEF_RR "False"
 #define DEF_JONG "False"
 #define DEF_SINE "False"
 
+static Bool martin;
+static Bool popcorn;
+static Bool ejk1;
+static Bool ejk2;
+static Bool ejk3;
+static Bool ejk4;
+static Bool ejk5;
+static Bool ejk6;
+static Bool rr;
+static Bool jong;
+static Bool sine;
+
 static XrmOptionDescRec opts[] =
 {
+       {"-martin", ".hop.martin", XrmoptionNoArg, (caddr_t) "on"},
+       {"+martin", ".hop.martin", XrmoptionNoArg, (caddr_t) "off"},
+       {"-popcorn", ".hop.popcorn", XrmoptionNoArg, (caddr_t) "on"},
+       {"+popcorn", ".hop.popcorn", XrmoptionNoArg, (caddr_t) "off"},
+       {"-ejk1", ".hop.ejk1", XrmoptionNoArg, (caddr_t) "on"},
+       {"+ejk1", ".hop.ejk1", XrmoptionNoArg, (caddr_t) "off"},
+       {"-ejk2", ".hop.ejk2", XrmoptionNoArg, (caddr_t) "on"},
+       {"+ejk2", ".hop.ejk2", XrmoptionNoArg, (caddr_t) "off"},
+       {"-ejk3", ".hop.ejk3", XrmoptionNoArg, (caddr_t) "on"},
+       {"+ejk3", ".hop.ejk3", XrmoptionNoArg, (caddr_t) "off"},
+       {"-ejk4", ".hop.ejk4", XrmoptionNoArg, (caddr_t) "on"},
+       {"+ejk4", ".hop.ejk4", XrmoptionNoArg, (caddr_t) "off"},
+       {"-ejk5", ".hop.ejk5", XrmoptionNoArg, (caddr_t) "on"},
+       {"+ejk5", ".hop.ejk5", XrmoptionNoArg, (caddr_t) "off"},
+       {"-ejk6", ".hop.ejk6", XrmoptionNoArg, (caddr_t) "on"},
+       {"+ejk6", ".hop.ejk6", XrmoptionNoArg, (caddr_t) "off"},
+       {"-rr", ".hop.rr", XrmoptionNoArg, (caddr_t) "on"},
+       {"+rr", ".hop.rr", XrmoptionNoArg, (caddr_t) "off"},
        {"-jong", ".hop.jong", XrmoptionNoArg, (caddr_t) "on"},
        {"+jong", ".hop.jong", XrmoptionNoArg, (caddr_t) "off"},
        {"-sine", ".hop.sine", XrmoptionNoArg, (caddr_t) "on"},
@@ -78,45 +120,75 @@ static XrmOptionDescRec opts[] =
 };
 static argtype vars[] =
 {
+       {(caddr_t *) & martin, "martin", "Martin", DEF_MARTIN, t_Bool},
+       {(caddr_t *) & popcorn, "popcorn", "Popcorn", DEF_POPCORN, t_Bool},
+       {(caddr_t *) & ejk1, "ejk1", "EJK1", DEF_EJK1, t_Bool},
+       {(caddr_t *) & ejk2, "ejk2", "EJK2", DEF_EJK2, t_Bool},
+       {(caddr_t *) & ejk3, "ejk3", "EJK3", DEF_EJK3, t_Bool},
+       {(caddr_t *) & ejk4, "ejk4", "EJK4", DEF_EJK4, t_Bool},
+       {(caddr_t *) & ejk5, "ejk5", "EJK5", DEF_EJK5, t_Bool},
+       {(caddr_t *) & ejk6, "ejk6", "EJK6", DEF_EJK6, t_Bool},
+       {(caddr_t *) & rr, "rr", "RR", DEF_RR, t_Bool},
        {(caddr_t *) & jong, "jong", "Jong", DEF_JONG, t_Bool},
        {(caddr_t *) & sine, "sine", "Sine", DEF_SINE, t_Bool}
 };
 static OptionStruct desc[] =
 {
+       {"-/+martin", "turn on/off sqrt format"},
+       {"-/+popcorn", "turn on/off Clifford A. Pickover's popcorn format"},
+       {"-/+ejk1", "turn on/off ejk1 format"},
+       {"-/+ejk2", "turn on/off ejk2 format"},
+       {"-/+ejk3", "turn on/off ejk3 format"},
+       {"-/+ejk4", "turn on/off ejk4 format"},
+       {"-/+ejk5", "turn on/off ejk5 format"},
+       {"-/+ejk6", "turn on/off ejk6 format"},
+       {"-/+rr", "turn on/off rr format"},
        {"-/+jong", "turn on/off jong format"},
        {"-/+sine", "turn on/off sine format"}
 };
 
-ModeSpecOpt hop_opts = { 4, opts, 2, vars, desc };
+ModeSpecOpt hop_opts =
+{sizeof opts / sizeof opts[0], opts, sizeof vars / sizeof vars[0], vars, desc};
 
+#ifdef USE_MODULES
+ModStruct   hop_description =
+{"hop", "init_hop", "draw_hop", "release_hop",
+ "refresh_hop", "init_hop", NULL, &hop_opts,
+ 10000, 1000, 2500, 1, 64, 1.0, "",
+ "Shows real plane iterated fractals", 0, NULL};
 
-#define SQRT 0
-#define JONG 1
-#define SINE 2
+#endif
+
+#define MARTIN 0
+#define POPCORN 7
+#define SINE 8
+#define EJK1 1
+#define EJK2 2
+#define EJK3 9
+#define EJK4 3
+#define EJK5 4
+#define EJK6 10
+#define RR 5
+#define JONG 6
 #ifdef OFFENDING
-#define OPS 2                  /* Sine might be too close to a Swastika for some... */
+#define OPS 8                  /* 8, 9, 10 might be too close to a swastika for some... */
 #else
-#define OPS 3
+#define OPS 11
 #endif
 
 typedef struct {
-       int         centerx;
-       int         centery;    /* center of the screen */
-       double      a;
-       double      b;
-       double      c;
-       double      d;
-       double      i;
-       double      j;          /* hopalong parameters */
+       int         centerx, centery;   /* center of the screen */
+       double      a, b, c, d;
+       double      i, j;       /* hopalong parameters */
        int         inc;
        int         pix;
        int         op;
        int         count;
        int         bufsize;
+       XPoint     *pointBuffer;        /* pointer for XDrawPoints */
 } hopstruct;
 
 static hopstruct *hops = NULL;
-static XPoint *pointBuffer = 0;        /* pointer for XDrawPoints */
 
 void
 init_hop(ModeInfo * mi)
@@ -133,53 +205,186 @@ init_hop(ModeInfo * mi)
        }
        hp = &hops[MI_SCREEN(mi)];
 
-       hp->centerx = MI_WIN_WIDTH(mi) / 2;
-       hp->centery = MI_WIN_HEIGHT(mi) / 2;
+       hp->centerx = MI_WIDTH(mi) / 2;
+       hp->centery = MI_HEIGHT(mi) / 2;
        /* Make the other operations less common since they are less interesting */
-       if (MI_WIN_IS_FULLRANDOM(mi)) {
-         hp->op = NRAND(OPS+2); /* jwz: make the others a bit more likely. */
-         if (hp->op >= OPS)
-               hp->op = SQRT;
+       if (MI_IS_FULLRANDOM(mi)) {
+               hp->op = NRAND(OPS);
        } else {
-               hp->op = SQRT;
-               if (jong)
+               if (martin)
+                       hp->op = MARTIN;
+               else if (popcorn)
+                       hp->op = POPCORN;
+               else if (ejk1)
+                       hp->op = EJK1;
+               else if (ejk2)
+                       hp->op = EJK2;
+               else if (ejk3)
+                       hp->op = EJK3;
+               else if (ejk4)
+                       hp->op = EJK4;
+               else if (ejk5)
+                       hp->op = EJK5;
+               else if (ejk6)
+                       hp->op = EJK6;
+               else if (rr)
+                       hp->op = RR;
+               else if (jong)
                        hp->op = JONG;
                else if (sine)
                        hp->op = SINE;
+               else
+                       hp->op = NRAND(OPS);
        }
-       switch (hp->op) {
-               case SQRT:
-                       range = sqrt((double) hp->centerx * hp->centerx +
-                                    (double) hp->centery * hp->centery) / (10.0 + NRAND(10));
 
-                       hp->a = (LRAND() / MAXRAND) * range - range / 2.0;
-                       hp->b = (LRAND() / MAXRAND) * range - range / 2.0;
-                       hp->c = (LRAND() / MAXRAND) * range - range / 2.0;
+       range = sqrt((double) hp->centerx * hp->centerx +
+            (double) hp->centery * hp->centery) / (1.0 + LRAND() / MAXRAND);
+       hp->i = hp->j = 0.0;
+       hp->inc = (int) ((LRAND() / MAXRAND) * 200) - 100;
+#undef XMARTIN
+       switch (hp->op) {
+               case MARTIN:
+#ifdef XMARTIN
+                       hp->a = (LRAND() / MAXRAND) * 1500.0 + 40.0;
+                       hp->b = (LRAND() / MAXRAND) * 17.0 + 3.0;
+                       hp->c = (LRAND() / MAXRAND) * 3000.0 + 100.0;
+#else
+                       hp->a = ((LRAND() / MAXRAND) * 2.0 - 1.0) * range / 20.0;
+                       hp->b = ((LRAND() / MAXRAND) * 2.0 - 1.0) * range / 20.0;
                        if (LRAND() & 1)
+                               hp->c = ((LRAND() / MAXRAND) * 2.0 - 1.0) * range / 20.0;
+                       else
                                hp->c = 0.0;
+#endif
+                       if (MI_IS_VERBOSE(mi))
+                               (void) fprintf(stdout, "sqrt a=%g, b=%g, c=%g\n", hp->a, hp->b, hp->c);
+                       break;
+               case EJK1:
+#ifdef XMARTIN
+                       hp->a = (LRAND() / MAXRAND) * 500.0;
+                       hp->c = (LRAND() / MAXRAND) * 100.0 + 10.0;
+#else
+                       hp->a = ((LRAND() / MAXRAND) * 2.0 - 1.0) * range / 30.0;
+                       hp->c = ((LRAND() / MAXRAND) * 2.0 - 1.0) * range / 40.0;
+#endif
+                       hp->b = (LRAND() / MAXRAND) * 0.4;
+                       if (MI_IS_VERBOSE(mi))
+                               (void) fprintf(stdout, "ejk1 a=%g, b=%g, c=%g\n", hp->a, hp->b, hp->c);
+                       break;
+               case EJK2:
+#ifdef XMARTIN
+                       hp->a = (LRAND() / MAXRAND) * 500.0;
+#else
+                       hp->a = ((LRAND() / MAXRAND) * 2.0 - 1.0) * range / 30.0;
+#endif
+                       hp->b = pow(10.0, 6.0 + (LRAND() / MAXRAND) * 24.0);
+                       if (LRAND() & 1)
+                               hp->b = -hp->b;
+                       hp->c = pow(10.0, (LRAND() / MAXRAND) * 9.0);
+                       if (LRAND() & 1)
+                               hp->c = -hp->c;
+                       if (MI_IS_VERBOSE(mi))
+                               (void) fprintf(stdout, "ejk2 a=%g, b=%g, c=%g\n", hp->a, hp->b, hp->c);
+                       break;
+               case EJK3:
+#ifdef XMARTIN
+                       hp->a = (LRAND() / MAXRAND) * 500.0;
+                       hp->c = (LRAND() / MAXRAND) * 80.0 + 30.0;
+#else
+                       hp->a = ((LRAND() / MAXRAND) * 2.0 - 1.0) * range / 30.0;
+                       hp->c = ((LRAND() / MAXRAND) * 2.0 - 1.0) * range / 70.0;
+#endif
+                       hp->b = (LRAND() / MAXRAND) * 0.35 + 0.5;
+                       if (MI_IS_VERBOSE(mi))
+                               (void) fprintf(stdout, "ejk3 a=%g, b=%g, c=%g\n", hp->a, hp->b, hp->c);
+                       break;
+               case EJK4:
+#ifdef XMARTIN
+                       hp->a = (LRAND() / MAXRAND) * 1000.0;
+                       hp->c = (LRAND() / MAXRAND) * 40.0 + 30.0;
+#else
+                       hp->a = ((LRAND() / MAXRAND) * 2.0 - 1.0) * range / 2.0;
+                       hp->c = ((LRAND() / MAXRAND) * 2.0 - 1.0) * range / 200.0;
+#endif
+                       hp->b = (LRAND() / MAXRAND) * 9.0 + 1.0;
+                       if (MI_IS_VERBOSE(mi))
+                               (void) fprintf(stdout, "ejk4 a=%g, b=%g, c=%g\n", hp->a, hp->b, hp->c);
+                       break;
+               case EJK5:
+#ifdef XMARTIN
+                       hp->a = (LRAND() / MAXRAND) * 600.0;
+                       hp->c = (LRAND() / MAXRAND) * 90.0 + 20.0;
+#else
+                       hp->a = ((LRAND() / MAXRAND) * 2.0 - 1.0) * range / 2.0;
+                       hp->c = ((LRAND() / MAXRAND) * 2.0 - 1.0) * range / 200.0;
+#endif
+                       hp->b = (LRAND() / MAXRAND) * 0.3 + 0.1;
+                       if (MI_IS_VERBOSE(mi))
+                               (void) fprintf(stdout, "ejk5 a=%g, b=%g, c=%g\n", hp->a, hp->b, hp->c);
+                       break;
+               case EJK6:
+#ifdef XMARTIN
+                       hp->a = (LRAND() / MAXRAND) * 100.0 + 550.0;
+#else
+                       hp->a = ((LRAND() / MAXRAND) * 2.0 - 1.0) * range / 30.0;
+#endif
+                       hp->b = (LRAND() / MAXRAND) + 0.5;
+                       if (MI_IS_VERBOSE(mi))
+                               (void) fprintf(stdout, "ejk6 a=%g, b=%g\n", hp->a, hp->b);
+                       break;
+               case RR:
+#ifdef XMARTIN
+                       hp->a = (LRAND() / MAXRAND) * 100.0;
+                       hp->b = (LRAND() / MAXRAND) * 20.0;
+                       hp->c = (LRAND() / MAXRAND) * 200.0;
+#else
+                       hp->a = ((LRAND() / MAXRAND) * 2.0 - 1.0) * range / 40.0;
+                       hp->b = ((LRAND() / MAXRAND) * 2.0 - 1.0) * range / 200.0;
+                       hp->c = ((LRAND() / MAXRAND) * 2.0 - 1.0) * range / 20.0;
+#endif
+                       hp->d = (LRAND() / MAXRAND) * 0.9;
+                       if (MI_IS_VERBOSE(mi))
+                               (void) fprintf(stdout, "rr a=%g, b=%g, c=%g, d=%g\n",
+                                              hp->a, hp->b, hp->c, hp->d);
+                       break;
+               case POPCORN:
+                       hp->a = 0.0;
+                       hp->b = 0.0;
+                       hp->c = ((LRAND() / MAXRAND) * 2.0 - 1.0) * 0.24 + 0.25;
+                       hp->inc = 100;
+                       if (MI_IS_VERBOSE(mi))
+                               (void) fprintf(stdout, "popcorn a=%g, b=%g, c=%g, d=%g\n",
+                                              hp->a, hp->b, hp->c, hp->d);
                        break;
                case JONG:
-                       hp->a = (LRAND() / MAXRAND) * 2.0 * M_PI - M_PI;
-                       hp->b = (LRAND() / MAXRAND) * 2.0 * M_PI - M_PI;
-                       hp->c = (LRAND() / MAXRAND) * 2.0 * M_PI - M_PI;
-                       hp->d = (LRAND() / MAXRAND) * 2.0 * M_PI - M_PI;
+                       hp->a = ((LRAND() / MAXRAND) * 2.0 - 1.0) * M_PI;
+                       hp->b = ((LRAND() / MAXRAND) * 2.0 - 1.0) * M_PI;
+                       hp->c = ((LRAND() / MAXRAND) * 2.0 - 1.0) * M_PI;
+                       hp->d = ((LRAND() / MAXRAND) * 2.0 - 1.0) * M_PI;
+                       if (MI_IS_VERBOSE(mi))
+                               (void) fprintf(stdout, "jong a=%g, b=%g, c=%g, d=%g\n",
+                                              hp->a, hp->b, hp->c, hp->d);
                        break;
-               case SINE:
+               case SINE:      /* MARTIN2 */
+#ifdef XMARTIN
+                       hp->a = M_PI + ((LRAND() / MAXRAND) * 2.0 - 1.0) * 0.07;
+#else
                        hp->a = M_PI + ((LRAND() / MAXRAND) * 2.0 - 1.0) * 0.7;
+#endif
+                       if (MI_IS_VERBOSE(mi))
+                               (void) fprintf(stdout, "sine a=%g\n", hp->a);
                        break;
        }
        if (MI_NPIXELS(mi) > 2)
                hp->pix = NRAND(MI_NPIXELS(mi));
-       hp->i = hp->j = 0.0;
-       hp->inc = (int) ((LRAND() / MAXRAND) * 200) - 100;
-       hp->bufsize = MI_BATCHCOUNT(mi);
+       hp->bufsize = MI_COUNT(mi);
 
-       if (!pointBuffer)
-               pointBuffer = (XPoint *) malloc(hp->bufsize * sizeof (XPoint));
+       if (!hp->pointBuffer)
+               hp->pointBuffer = (XPoint *) malloc(hp->bufsize * sizeof (XPoint));
 
-       XClearWindow(display, MI_WINDOW(mi));
+       MI_CLEARWINDOW(mi);
 
-       XSetForeground(display, gc, MI_WIN_WHITE_PIXEL(mi));
+       XSetForeground(display, gc, MI_WHITE_PIXEL(mi));
        hp->count = 0;
 }
 
@@ -189,9 +394,11 @@ draw_hop(ModeInfo * mi)
 {
        hopstruct  *hp = &hops[MI_SCREEN(mi)];
        double      oldj, oldi;
-       XPoint     *xp = pointBuffer;
+       XPoint     *xp = hp->pointBuffer;
        int         k = hp->bufsize;
 
+       MI_IS_DRAWN(mi) = True;
+
        hp->inc++;
        if (MI_NPIXELS(mi) > 2) {
                XSetForeground(MI_DISPLAY(mi), MI_GC(mi), MI_PIXEL(mi, hp->pix));
@@ -201,7 +408,7 @@ draw_hop(ModeInfo * mi)
        while (k--) {
                oldj = hp->j;
                switch (hp->op) {
-                       case SQRT:
+                       case MARTIN:    /* SQRT, MARTIN1 */
                                oldi = hp->i + hp->inc;
                                hp->j = hp->a - hp->i;
                                hp->i = oldj + ((hp->i < 0)
@@ -210,6 +417,86 @@ draw_hop(ModeInfo * mi)
                                xp->x = hp->centerx + (int) (hp->i + hp->j);
                                xp->y = hp->centery - (int) (hp->i - hp->j);
                                break;
+                       case EJK1:
+                               oldi = hp->i + hp->inc;
+                               hp->j = hp->a - hp->i;
+                               hp->i = oldj - ((hp->i > 0) ? (hp->b * oldi - hp->c) :
+                                               -(hp->b * oldi - hp->c));
+                               xp->x = hp->centerx + (int) (hp->i + hp->j);
+                               xp->y = hp->centery - (int) (hp->i - hp->j);
+                               break;
+                       case EJK2:
+                               oldi = hp->i + hp->inc;
+                               hp->j = hp->a - hp->i;
+                               hp->i = oldj - ((hp->i < 0) ? log(fabs(hp->b * oldi - hp->c)) :
+                                          -log(fabs(hp->b * oldi - hp->c)));
+                               xp->x = hp->centerx + (int) (hp->i + hp->j);
+                               xp->y = hp->centery - (int) (hp->i - hp->j);
+                               break;
+                       case EJK3:
+                               oldi = hp->i + hp->inc;
+                               hp->j = hp->a - hp->i;
+                               hp->i = oldj - ((hp->i > 0) ? sin(hp->b * oldi) - hp->c :
+                                               -sin(hp->b * oldi) - hp->c);
+                               xp->x = hp->centerx + (int) (hp->i + hp->j);
+                               xp->y = hp->centery - (int) (hp->i - hp->j);
+                               break;
+                       case EJK4:
+                               oldi = hp->i + hp->inc;
+                               hp->j = hp->a - hp->i;
+                               hp->i = oldj - ((hp->i > 0) ? sin(hp->b * oldi) - hp->c :
+                                         -sqrt(fabs(hp->b * oldi - hp->c)));
+                               xp->x = hp->centerx + (int) (hp->i + hp->j);
+                               xp->y = hp->centery - (int) (hp->i - hp->j);
+                               break;
+                       case EJK5:
+                               oldi = hp->i + hp->inc;
+                               hp->j = hp->a - hp->i;
+                               hp->i = oldj - ((hp->i > 0) ? sin(hp->b * oldi) - hp->c :
+                                               -(hp->b * oldi - hp->c));
+                               xp->x = hp->centerx + (int) (hp->i + hp->j);
+                               xp->y = hp->centery - (int) (hp->i - hp->j);
+                               break;
+                       case EJK6:
+                               oldi = hp->i + hp->inc;
+                               hp->j = hp->a - hp->i;
+                               hp->i = oldj - asin((hp->b * oldi) - (long) (hp->b * oldi));
+                               xp->x = hp->centerx + (int) (hp->i + hp->j);
+                               xp->y = hp->centery - (int) (hp->i - hp->j);
+                               break;
+                       case RR:        /* RR1 */
+                               oldi = hp->i + hp->inc;
+                               hp->j = hp->a - hp->i;
+                               hp->i = oldj - ((hp->i < 0) ? -pow(fabs(hp->b * oldi - hp->c), hp->d) :
+                                    pow(fabs(hp->b * oldi - hp->c), hp->d));
+                               xp->x = hp->centerx + (int) (hp->i + hp->j);
+                               xp->y = hp->centery - (int) (hp->i - hp->j);
+                               break;
+                       case POPCORN:
+#define HVAL 0.05
+#define INCVAL 50
+                               {
+                                       double      tempi, tempj;
+
+                                       if (hp->inc >= 100)
+                                               hp->inc = 0;
+                                       if (hp->inc == 0) {
+                                               if (hp->a++ >= INCVAL) {
+                                                       hp->a = 0;
+                                                       if (hp->b++ >= INCVAL)
+                                                               hp->b = 0;
+                                               }
+                                               hp->i = (-hp->c * INCVAL / 2 + hp->c * hp->a) * M_PI / 180.0;
+                                               hp->j = (-hp->c * INCVAL / 2 + hp->c * hp->b) * M_PI / 180.0;
+                                       }
+                                       tempi = hp->i - HVAL * sin(hp->j + tan(3.0 * hp->j));
+                                       tempj = hp->j - HVAL * sin(hp->i + tan(3.0 * hp->i));
+                                       xp->x = hp->centerx + (int) (MI_WIDTH(mi) / 40 * tempi);
+                                       xp->y = hp->centery + (int) (MI_HEIGHT(mi) / 40 * tempj);
+                                       hp->i = tempi;
+                                       hp->j = tempj;
+                               }
+                               break;
                        case JONG:
                                if (hp->centerx > 0)
                                        oldi = hp->i + 4 * hp->inc / hp->centerx;
@@ -220,7 +507,7 @@ draw_hop(ModeInfo * mi)
                                xp->x = hp->centerx + (int) (hp->centerx * (hp->i + hp->j) / 4.0);
                                xp->y = hp->centery - (int) (hp->centery * (hp->i - hp->j) / 4.0);
                                break;
-                       case SINE:
+                       case SINE:      /* MARTIN2 */
                                oldi = hp->i + hp->inc;
                                hp->j = hp->a - hp->i;
                                hp->i = oldj - sin(oldi);
@@ -231,12 +518,12 @@ draw_hop(ModeInfo * mi)
                xp++;
        }
        XDrawPoints(MI_DISPLAY(mi), MI_WINDOW(mi), MI_GC(mi),
-                   pointBuffer, hp->bufsize, CoordModeOrigin);
+                   hp->pointBuffer, hp->bufsize, CoordModeOrigin);
        if (++hp->count > MI_CYCLES(mi)) {
 #ifdef STANDALONE
-         erase_full_window(MI_DISPLAY(mi), MI_WINDOW(mi));
+           erase_full_window(MI_DISPLAY(mi), MI_WINDOW(mi));
 #endif /* STANDALONE */
-         init_hop(mi);
+               init_hop(mi);
        }
 }
 
@@ -244,17 +531,22 @@ void
 release_hop(ModeInfo * mi)
 {
        if (hops != NULL) {
+               int         screen;
+
+               for (screen = 0; screen < MI_NUM_SCREENS(mi); screen++) {
+                       hopstruct  *hp = &hops[screen];
+
+                       if (hp->pointBuffer)
+                               (void) free((void *) hp->pointBuffer);
+               }
+
                (void) free((void *) hops);
                hops = NULL;
        }
-       if (pointBuffer) {
-               (void) free((void *) pointBuffer);
-               pointBuffer = NULL;
-       }
 }
 
 void
 refresh_hop(ModeInfo * mi)
 {
-       XClearWindow(MI_DISPLAY(mi), MI_WINDOW(mi));
+       MI_CLEARWINDOW(mi);
 }
diff --git a/hacks/loop.c b/hacks/loop.c
new file mode 100644 (file)
index 0000000..c7280ea
--- /dev/null
@@ -0,0 +1,1430 @@
+/* -*- Mode: C; tab-width: 4 -*- */
+/* loop --- Chris Langton's self-producing loops */
+
+#if !defined( lint ) && !defined( SABER )
+static const char sccsid[] = "@(#)loop.c       4.13 98/10/18 xlockmore";
+
+#endif
+
+/*-
+ * Copyright (c) 1996 by David Bagley.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation.
+ *
+ * This file is provided AS IS with no warranties of any kind.  The author
+ * shall have no liability with respect to the infringement of copyrights,
+ * trade secrets or any patents by this file or any part thereof.  In no
+ * event will the author be liable for any lost revenue or profits or
+ * other special, indirect and consequential damages.
+ *
+ * Revision History:
+ * 18-Oct-98: Started creating a hexagon version, probably will not work
+ *            for a while since some work has to go into getting not
+ *            only the program to handle the hexagonal data but the loop
+ *            has to be "programmed" as well.  I suspect it should be easier
+ *            than the original since the loop will have six sides to
+ *            store its genes (data).
+ * 10-May-97: Compatible with xscreensaver
+ * 15-Nov-95: Coded from Chris Langton's Self-Reproduction in Cellular
+ *            Automata Physica 10D 135-144 1984
+ *            also used wire.c as a guide.
+ */
+
+/*-
+  Grid     Number of Neigbors
+  ----     ------------------
+  Square   4
+  Hexagon  6  (currently in development)
+*/
+
+/*-
+ * From Steven Levy's Artificial Life
+ * Chris Langton's cellular automata "loops" reproduce in the spirit of life.
+ * Beginning from a single organism, the loops from a colony.  As the loops
+ * on the outer fringes reproduce, the inner loops -- blocked by their
+ * daughters -- can no longer produce offspring.  These dead progenitors
+ * provide a base for future generations' expansion, much like the formation
+ * of a coral reef.  This self-organizing behavior emerges spontaneously,
+ * from the bottom up -- a key characteristic of artificial life.
+ */
+
+/*-
+   Don't Panic  --  When the artificial life tries to leave its petri
+   dish (ie. the screen) it will (usually) die...
+   The loops are short of "real" life because a general purpose Turing
+   machine is not contained in the loop.  This is a simplification of
+   von Neumann and Codd's self-producing Turing machine.
+   The data spinning around could be viewed as both its DNA and its internal
+   clock.
+ */
+
+#ifdef STANDALONE
+# define PROGCLASS "loop"
+# define HACK_INIT init_loop
+# define HACK_DRAW draw_loop
+# define loop_opts xlockmore_opts
+# define DEFAULTS      "*delay:  100000 \n" \
+                                       "*cycles:   1600 \n" \
+                                       "*size:      -12 \n" \
+                                       "*ncolors:    15 \n" \
+                                       "*neighbors:   0 \n"
+# define SMOOTH_COLORS
+# include "xlockmore.h"                /* in xscreensaver distribution */
+#else /* STANDALONE */
+# include "xlock.h"            /* in xlockmore distribution */
+#endif /* STANDALONE */
+
+#include "automata.h"
+
+/*-
+ * neighbors of 0 randomizes between 4 and 6.
+ */
+#ifdef STANDALONE
+static int neighbors;
+#else
+extern int  neighbors;
+#endif /* !STANDALONE */
+
+ModeSpecOpt loop_opts =
+{0, NULL, 0, NULL, NULL};
+
+#ifdef USE_MODULES
+ModStruct   loop_description =
+{"loop", "init_loop", "draw_loop", "release_loop",
+ "refresh_loop", "init_loop", NULL, &loop_opts,
+ 100000, 1, 1600, -12, 64, 1.0, "",
+ "Shows Langton's self-producing loops", 0, NULL};
+
+#endif
+
+#define LOOPBITS(n,w,h)\
+  lp->pixmaps[lp->init_bits++]=\
+  XCreatePixmapFromBitmapData(display,window,(char *)n,w,h,1,0,1)
+
+static int  local_neighbors = 0;
+static int  neighbor_kind = 0;
+
+#define COLORS 8
+#define REALCOLORS (COLORS-2)
+#define MINLOOPS 1
+#define REDRAWSTEP 2000                /* How many cells to draw per cycle */
+#define ADAM_SIZE 8 /* MIN 5 */
+#if 1
+# define ADAM_LOOPX  (ADAM_SIZE+2)
+# define ADAM_LOOPY  (ADAM_SIZE+2)
+#else
+# define ADAM_LOOPX 16
+# define ADAM_LOOPY 10
+#endif
+#define MINGRIDSIZE (3*ADAM_LOOPX)
+/* TRIA stuff was an attempt to make a triangular lifeform on a
+   hex grid but I got bored.  You probably need an additional 7th
+   state for a coherent step by step process of separation and
+   initial stem development.
+ */
+/* #define TRIA 1 */
+#ifdef TRIA
+# define HEX_ADAM_SIZE 3 /* MIN 3 */
+#else
+# define HEX_ADAM_SIZE 5 /* MIN 3 */
+#endif
+#if 1
+# define HEX_ADAM_LOOPX (2*HEX_ADAM_SIZE+1)
+# define HEX_ADAM_LOOPY (2*HEX_ADAM_SIZE+1)
+#else
+# define HEX_ADAM_LOOPX 3 
+# define HEX_ADAM_LOOPY 7
+#endif
+#define HEX_MINGRIDSIZE (6*HEX_ADAM_LOOPX)
+#define MINSIZE 5                        /* jwz -- really tiny cells don't look good */
+#define NEIGHBORKINDS 2
+#define ANGLES 360
+#define MAXNEIGHBORS 6
+
+/* Singly linked list */
+typedef struct _CellList {
+       XPoint      pt;
+       struct _CellList *next;
+} CellList;
+
+typedef struct {
+       int         init_bits;
+       int         generation;
+       int         xs, ys;
+       int         xb, yb;
+       int         nrows, ncols;
+       int         bx, by, bnrows, bncols;
+       int         mincol, minrow, maxcol, maxrow;
+       int         width, height;
+       int         redrawing, redrawpos;
+       unsigned char *newcells, *oldcells;
+       int         ncells[COLORS];
+       CellList   *cellList[COLORS];
+       unsigned long colors[COLORS];
+       GC          stippledGC;
+       Pixmap      pixmaps[COLORS];
+       union {
+               XPoint      hexagon[6];
+       } shape;
+} loopstruct;
+
+static loopstruct *loops = NULL;
+
+#define TRANSITION(TT,V) V=TT&7;TT>>=3
+#define TABLE(R,T,L,B) (table[((B)<<9)|((L)<<6)|((T)<<3)|(R)])
+#define HEX_TABLE(R,T,t,l,b,B) (table[((B)<<15)|((b)<<12)|((l)<<9)|((t)<<6)|((T)<<3)|(R)])
+#ifdef RAND_RULES              /* Hack, see below */
+#define TABLE_IN(C,R,T,L,B,I) (TABLE(R,T,L,B)&=~(7<<((C)*3)));\
+(TABLE(R,T,L,B)|=((I)<<((C)*3)))
+#define HEX_TABLE_IN(C,R,T,t,l,b,B,I) (HEX_TABLE(R,T,t,l,b,B)&=~(7<<((C)*3)));\
+(HEX_TABLE(R,T,t,l,b,B)|=((I)<<((C)*3)))
+#else
+#define TABLE_IN(C,R,T,L,B,I) (TABLE(R,T,L,B)|=((I)<<((C)*3)))
+#define HEX_TABLE_IN(C,R,T,t,l,b,B,I) (HEX_TABLE(R,T,t,l,b,B)|=((I)<<((C)*3)))
+#endif
+#define TABLE_OUT(C,R,T,L,B) ((TABLE(R,T,L,B)>>((C)*3))&7)
+#define HEX_TABLE_OUT(C,R,T,t,l,b,B) ((HEX_TABLE(R,T,t,l,b,B)>>((C)*3))&7)
+
+static unsigned int *table = NULL;     /* 8*8*8*8 = 2^12 = 2^3^4 = 4K */
+  /* 8*8*8*8*8*8 = too big? */
+
+static char plots[NEIGHBORKINDS] =
+{
+  4, 6 /* Neighborhoods */
+};
+
+static unsigned int transition_table[] =
+{                              /* Octal  CBLTR->I */
+  /* CBLTRI   CBLTRI   CBLTRI   CBLTRI   CBLTRI */
+    0000000, 0025271, 0113221, 0202422, 0301021,
+    0000012, 0100011, 0122244, 0202452, 0301220,
+    0000020, 0100061, 0122277, 0202520, 0302511,
+    0000030, 0100077, 0122434, 0202552, 0401120,
+    0000050, 0100111, 0122547, 0202622, 0401220,
+    0000063, 0100121, 0123244, 0202722, 0401250,
+    0000071, 0100211, 0123277, 0203122, 0402120,
+    0000112, 0100244, 0124255, 0203216, 0402221,
+    0000122, 0100277, 0124267, 0203226, 0402326,
+    0000132, 0100511, 0125275, 0203422, 0402520,
+    0000212, 0101011, 0200012, 0204222, 0403221,
+    0000220, 0101111, 0200022, 0205122, 0500022,
+    0000230, 0101244, 0200042, 0205212, 0500215,
+    0000262, 0101277, 0200071, 0205222, 0500225,
+    0000272, 0102026, 0200122, 0205521, 0500232,
+    0000320, 0102121, 0200152, 0205725, 0500272,
+    0000525, 0102211, 0200212, 0206222, 0500520,
+    0000622, 0102244, 0200222, 0206722, 0502022,
+    0000722, 0102263, 0200232, 0207122, 0502122,
+    0001022, 0102277, 0200242, 0207222, 0502152,
+    0001120, 0102327, 0200250, 0207422, 0502220,
+    0002020, 0102424, 0200262, 0207722, 0502244,
+    0002030, 0102626, 0200272, 0211222, 0502722,
+    0002050, 0102644, 0200326, 0211261, 0512122,
+    0002125, 0102677, 0200423, 0212222, 0512220,
+    0002220, 0102710, 0200517, 0212242, 0512422,
+    0002322, 0102727, 0200522, 0212262, 0512722,
+    0005222, 0105427, 0200575, 0212272, 0600011,
+    0012321, 0111121, 0200722, 0214222, 0600021,
+    0012421, 0111221, 0201022, 0215222, 0602120,
+    0012525, 0111244, 0201122, 0216222, 0612125,
+    0012621, 0111251, 0201222, 0217222, 0612131,
+    0012721, 0111261, 0201422, 0222272, 0612225,
+    0012751, 0111277, 0201722, 0222442, 0700077,
+    0014221, 0111522, 0202022, 0222462, 0701120,
+    0014321, 0112121, 0202032, 0222762, 0701220,
+    0014421, 0112221, 0202052, 0222772, 0701250,
+    0014721, 0112244, 0202073, 0300013, 0702120,
+    0016251, 0112251, 0202122, 0300022, 0702221,
+    0017221, 0112277, 0202152, 0300041, 0702251,
+    0017255, 0112321, 0202212, 0300076, 0702321,
+    0017521, 0112424, 0202222, 0300123, 0702525,
+    0017621, 0112621, 0202272, 0300421, 0702720,
+    0017721, 0112727, 0202321, 0300622
+};
+
+static unsigned int hex_transition_table[] =
+{                              /* Octal CBbltTR->I */
+  /* CBbltTRI   CBbltTRI   CBbltTRI   CBbltTRI   CBbltTRI */
+
+#ifdef TRIA
+    000000000, 000000020, 000000220, 000002220, 000022220,
+    011122121, 011121221, 011122221, 011221221,
+    011222221, 011112121, 011112221,
+    020021122, 020002122, 020211222, 021111222,
+    020221122, 020027122, 020020722, 020021022,
+    001127221,
+    011122727, 011227227, 010122121, 010222211,
+    021117222, 020112272,
+    070221220,
+    001227221,
+    010221121, 011721221, 011222277,
+    020111222, 020221172,
+    070211220,
+    001217221,
+    010212277, 010221221,
+    020122112,
+    070122220,
+    001722221,
+    010221271,
+    020002022, 021122172,
+    070121220,
+    011122277, 011172121,
+    010212177, 011212277,
+    070112220,
+    001772221,
+    021221772,
+    070121270, 070721220,
+    000112721, 000272211,
+    010022211, 012222277,
+    020072272, 020227122, 020217222,
+    010211121,
+    020002727,
+    070222220,
+    001727721,
+    020021072, 020070722,
+    070002072, 070007022,
+    001772721,
+    070002022,
+    000000070, 000000770, 000072220, 000000270,
+    020110222, 020220272, 020220722,
+    070007071, 070002072, 070007022,
+    000000012, 000000122, 000000212, 001277721,
+    020122072, 020202212,
+    010002121,
+    020001122, 020002112,
+    020021722,
+    020122022, 020027022, 020070122, 020020122,
+    010227027,
+    020101222,
+    010227227, 010227277,
+    021722172,
+    001727221,
+    010222277,
+    020702272,
+    070122020,
+    000172721,
+    010022277, 010202177, 010227127,
+
+    001214221,
+    010202244,
+    020024122, 020020422,
+    040122220,
+    001422221,
+    010221241, 010224224,
+    021122142,
+    040121220,
+    001124221,
+    010224274,
+    020112242, 021422172,
+    040221220,
+    001224221, 001427221,
+    010222244,
+    020227042,
+    040122020,
+    000142721,
+    010022244, 010202144, 010224124,
+    040112220,
+    001442221,
+    021221442,
+    040121240, 040421220,
+    000242211, 000112421,
+    020042242, 020214222, 020021422, 020220242, 020024022,
+    011224224,
+    020224122,
+    020220422,
+    012222244,
+    020002424,
+    040222220,
+    001244421, 000000420, 000000440, 000000240, 000000040,
+    020040121, 020021042,
+    040004022, 040004042, 040002042,
+    010021121,
+    020011122, 020002112,
+    001424421,
+    020040422,
+    001442421,
+    040002022,
+    001724221,
+    010227247,
+    020224072, 021417222,
+    000172421,
+    010021721,
+    020017022,
+    020120212,
+    020271727,
+    070207072, 070701220,
+    000001222,
+    020110122,
+    001277221,
+    001777721,
+    020021222, 020202272, 020120222, 020221722,
+    020027227,
+    070070222,
+    000007220,
+    020101272, 020272172, 020721422, 020721722,
+    020011222, 020202242,
+#if 0
+              {2,2,0,0,2,7,0},
+             {2,0,2,0,2,0,2},
+            {2,4,1,2,2,1,2},
+           {2,1,2,1,2,1,2},
+          {2,0,2,2,1,1,2},
+         {2,7,1,1,1,1,2},
+        {0,2,2,2,2,2,2},
+              {2,2,0,0,7,7,0},
+             {2,1,2,0,2,0,7},
+            {2,0,1,2,2,1,2},
+           {2,4,2,1,2,1,2},
+          {2,1,2,2,1,1,2},
+         {2,0,7,1,1,1,2},
+        {0,2,2,2,2,2,2},
+#endif
+#else
+    000000000, 000000020, 000000220, 000002220,
+    011212121, 011212221, 011221221, 011222221,
+    020002122, 020021122, 020211122,
+
+    010221221, 010222121,
+    020002022, 020021022, 020020122, 020112022,
+
+    010202121,
+    020102022, 020202112,
+
+    000000012, 000000122, 000000212,
+    010002121, 
+    020001122, 020002112, 020011122,
+
+
+    001227221, 001272221, 001272721,
+    012212277, 011222727, 011212727,
+    020021722, 020027122, 020020722, 020027022,
+    020211722, 020202172, 020120272,
+    020271122, 020202172, 020207122, 020217122,
+    020120272, 020210722, 020270722,
+    070212220, 070221220, 070212120,
+
+
+    012222277,
+    020002727,
+    070222220,
+
+    001277721, 000000070, 000000270, 000000720, 000000770,
+    020070122, 020021072,
+    070002072, 070007022, 070007071,
+
+    020070722,
+    070002022,
+
+    010227227, 010222727, 010202727,
+    020172022, 020202712,
+
+    001224221, 001242221, 001242421,
+    012212244, 011222424, 011212424,
+    020021422, 020024122, 020020422, 020024022,
+    020211422, 020202142, 020120242,
+    020241122, 020202142, 020204122, 020214122,
+    020120242, 020210422, 020240422,
+    040212220, 040221220, 040212120,
+
+
+    012222244,
+    020002424,
+    040222220,
+
+    001244421, 000000040, 000000240, 000000420, 000000440,
+    020040122, 020021042,
+    040002042,
+    040004021, 040004042,
+
+    020040422,
+    040002022,
+    
+    010224224, 010222424, 010202424,
+    020142022, 020202412,
+    020011722, 020112072, 020172072, 020142072,
+
+
+
+    000210225, 000022015, 000022522,
+    011225521, 
+    020120525, 020020152, 020005122, 020214255, 020021152,
+    020255242,
+    050215222, 050225121,
+
+    000225220, 001254222,
+    010221250, 011221251, 011225221,
+    020025122, 020152152, 020211252, 020214522, 020511125,
+    050212241, 05221120,
+    040521225,
+
+    000000250, 000000520, 000150220, 000220520, 000222210,
+    001224251,
+    010022152, 010251221, 010522121, 011212151, 011221251,
+    011215221,
+    020000220, 020002152, 020020220, 020021020, 020022152,
+    020021422, 020022152, 020022522, 020025425, 020050422,
+    020051022, 020051122, 020211122, 020211222, 020215222,
+    020245122,
+    050021125, 050021025, 050011125, 051242221,
+    041225220,
+
+    000220250, 000220520, 001227521, 001275221,
+    011257227, 011522727,
+    020002052, 020002752, 020021052, 020057125,
+    050020722, 050027125,
+    070215220,
+
+    070212255,
+    071225220,
+    020275122,
+    051272521,
+    020055725,
+    020021552,
+    012252277,
+    050002521,
+    020005725,     
+
+    050011022,
+    000000155,
+    020050722,
+    001227250,
+    010512727,
+    010002151,
+    020027112,
+    001227251,
+    012227257,
+    050002125,
+    020517122,
+    050002025,
+    020050102,
+    050002725,
+    020570722,
+    001252721,
+    020007051,
+    020102052,
+    020271072,
+    050001122,
+    010002151,
+    011227257,
+    020051722,
+    020057022,
+    020050122,
+
+
+    020051422,
+    011224254,
+    012224254,
+
+    020054022,
+    050002425,
+    040252220,
+    020002454,
+
+
+    000000540,
+    001254425,
+    050004024,
+    040004051,
+
+    000000142,
+    040001522,
+    010002547,
+    020045122,
+    051221240,
+    020002512,
+    020021522,
+
+
+    020020022,
+    021125522,
+    020521122,
+    020025022,
+    020025522,
+    020020522, 
+
+    020202222,
+    020212222,
+    021212222,
+    021222722,
+    021222422,
+    020002222,
+    020021222,
+    020022122,
+    020212122,
+    020027222,
+    020024222,
+    020020222,
+    020212722,
+    020212422,
+    020202122,
+    001222221,
+    020002522,
+
+    020017125,
+    010022722,
+    020212052,
+
+    020205052,
+#endif
+};
+
+
+/*-
+Neighborhoods are read as follows (rotations are not listed):
+    T
+  L C R  ==>  I
+    B
+
+   t T
+  l C R  ==>  I
+   b B
+ */
+
+static unsigned char self_reproducing_loop[ADAM_LOOPY][ADAM_LOOPX] =
+{
+/* 10x10 */
+       {0, 2, 2, 2, 2, 2, 2, 2, 2, 0},
+       {2, 4, 0, 1, 4, 0, 1, 1, 1, 2},
+       {2, 1, 2, 2, 2, 2, 2, 2, 1, 2},
+       {2, 0, 2, 0, 0, 0, 0, 2, 1, 2},
+       {2, 7, 2, 0, 0, 0, 0, 2, 7, 2},
+       {2, 1, 2, 0, 0, 0, 0, 2, 0, 2},
+       {2, 0, 2, 0, 0, 0, 0, 2, 1, 2},
+       {2, 7, 2, 2, 2, 2, 2, 2, 7, 2},
+       {2, 1, 0, 6, 1, 0, 7, 1, 0, 2},
+       {0, 2, 2, 2, 2, 2, 2, 2, 2, 0}
+};
+
+static unsigned char hex_self_reproducing_loop[HEX_ADAM_LOOPY][HEX_ADAM_LOOPX] =
+{
+#if 0
+/* Experimental TRIA5:7x7 */
+             {2,2,0,0,0,0,0},
+            {2,1,2,0,2,2,0},
+           {2,0,4,2,2,0,2},
+          {2,7,2,0,2,0,2},
+         {2,1,2,2,1,1,2},
+        {2,0,7,1,0,7,2},
+       {0,2,2,2,2,2,2},
+  /* Stem cells, only "5" will fully reproduce itself */
+/* 3:12x7 */
+             {2,2,2,2,0,0,0,0,0,0,0,0},
+            {2,1,1,1,2,0,0,0,0,0,0,0},
+           {2,1,2,2,1,2,2,2,2,2,2,0},
+          {2,1,2,0,2,7,1,1,1,1,1,2},
+         {0,2,1,2,2,0,2,2,2,2,2,2},
+        {0,0,2,0,4,1,2,0,0,0,0,0},
+       {0,0,0,2,2,2,2,0,0,0,0,0}
+/* 4:14x9 */
+               {2,2,2,2,2,0,0,0,0,0,0,0,0,0},
+              {2,1,1,1,1,2,0,0,0,0,0,0,0,0},
+             {2,1,2,2,2,1,2,0,0,0,0,0,0,0},
+            {2,1,2,0,0,2,1,2,2,2,2,2,2,0},
+           {2,1,2,0,0,0,2,7,1,1,1,1,1,2},
+          {0,2,1,2,0,0,2,0,2,2,2,2,2,2},
+         {0,0,2,0,2,2,2,1,2,0,0,0,0,0},
+        {0,0,0,2,4,1,0,7,2,0,0,0,0,0},
+       {0,0,0,0,2,2,2,2,2,0,0,0,0,0}
+/* 5:16x11 */
+                 {2,2,2,2,2,2,0,0,0,0,0,0,0,0,0,0},
+                {2,1,1,1,1,1,2,0,0,0,0,0,0,0,0,0},
+               {2,1,2,2,2,2,1,2,0,0,0,0,0,0,0,0},
+              {2,1,2,0,0,0,2,1,2,0,0,0,0,0,0,0},
+             {2,1,2,0,0,0,0,2,1,2,2,2,2,2,2,0},
+            {2,1,2,0,0,0,0,0,2,7,1,1,1,1,1,2},
+           {0,2,1,2,0,0,0,0,2,0,2,2,2,2,2,2},
+          {0,0,2,0,2,0,0,0,2,1,2,0,0,0,0,0},
+         {0,0,0,2,4,2,2,2,2,7,2,0,0,0,0,0},
+        {0,0,0,0,2,1,0,7,1,0,2,0,0,0,0,0},
+       {0,0,0,0,0,2,2,2,2,2,2,0,0,0,0,0}
+/* test:3x7  (0,4) is blank  ... very strange.
+          init_adam seems ok something after that I guess */
+                    {2,2,0},
+                   {2,0,2},
+                  {0,2,2},
+                 {0,0,0},
+                {2,2,0},
+               {2,1,2},
+              {0,2,2},
+#else /* this might be better for hexagons, spacewise efficient... */
+#ifdef TRIA
+/* Experimental TRIA5:7x7 */
+             {2,2,0,0,2,2,0},
+            {2,4,2,0,2,7,2},
+           {2,1,0,2,2,0,2},
+          {2,0,2,1,2,1,2},
+         {2,7,2,2,7,7,2},
+        {2,1,0,7,1,0,2},
+       {0,2,2,2,2,2,2},
+#else
+/* 5:11x11 */
+                 {2,2,2,2,2,2,0,0,0,0,0},
+                {2,1,1,7,0,1,2,0,0,0,0},
+               {2,1,2,2,2,2,7,2,0,0,0},
+              {2,1,2,0,0,0,2,0,2,0,0},
+             {2,1,2,0,0,0,0,2,1,2,0},
+            {2,1,2,0,0,0,0,0,2,7,2},
+           {0,2,1,2,0,0,0,0,2,0,2},
+          {0,0,2,1,2,0,0,0,2,1,2},
+         {0,0,0,2,1,2,2,2,2,4,2},
+        {0,0,0,0,2,1,1,1,1,5,2},
+       {0,0,0,0,0,2,2,2,2,2,2}
+#endif
+#endif
+};
+
+static void
+position_of_neighbor(int dir, int *pcol, int *prow)
+{
+       int         col = *pcol, row = *prow;
+
+       /* NO WRAPING */
+
+       if (local_neighbors == 6) {
+               switch (dir) {
+                       case 0:
+                               col = col + 1;
+                               break;
+                       case 60:
+                               if (row & 1)
+                                       col = col + 1;
+                               row = row - 1;
+                               break;
+                       case 120:
+                               if (!(row & 1))
+                                       col = col - 1;
+                               row = row - 1;
+                               break;
+                       case 180:
+                               col = col - 1;
+                               break;
+                       case 240:
+                               if (!(row & 1))
+                                       col = col - 1;
+                               row = row + 1;
+                               break;
+                       case 300:
+                               if (row & 1)
+                                       col = col + 1;
+                               row = row + 1;
+                               break;
+                       default:
+                               (void) fprintf(stderr, "wrong direction %d\n", dir);
+               }
+       } else {
+               switch (dir) {
+                       case 0:
+                               col = col + 1;
+                               break;
+                       case 90:
+                               row = row - 1;
+                               break;
+                       case 180:
+                               col = col - 1;
+                               break;
+                       case 270:
+                               row = row + 1;
+                               break;
+                       default:
+                               (void) fprintf(stderr, "wrong direction %d\n", dir);
+               }
+       }
+       *pcol = col;
+       *prow = row;
+}
+
+static      Bool
+withinBounds(loopstruct * lp, int col, int row)
+{
+       return (row >= 1 && row < lp->bnrows - 1 &&
+               col >= 1 && col < lp->bncols - 1 - (local_neighbors == 6 && (row % 2)));
+}
+
+static void
+fillcell(ModeInfo * mi, GC gc, int col, int row)
+{
+       loopstruct *lp = &loops[MI_SCREEN(mi)];
+
+       if (local_neighbors == 6) {
+               int         ccol = 2 * col + !(row & 1), crow = 2 * row;
+
+               lp->shape.hexagon[0].x = lp->xb + ccol * lp->xs;
+               lp->shape.hexagon[0].y = lp->yb + crow * lp->ys;
+               if (lp->xs == 1 && lp->ys == 1)
+                       XFillRectangle(MI_DISPLAY(mi), MI_WINDOW(mi), gc,
+                               lp->shape.hexagon[0].x, lp->shape.hexagon[0].y, 1, 1);
+               else
+                       XFillPolygon(MI_DISPLAY(mi), MI_WINDOW(mi), gc,
+                               lp->shape.hexagon, 6, Convex, CoordModePrevious);
+       } else {
+               XFillRectangle(MI_DISPLAY(mi), MI_WINDOW(mi), gc,
+                       lp->xb + lp->xs * col, lp->yb + lp->ys * row,
+                       lp->xs - (lp->xs > 3), lp->ys - (lp->ys > 3));
+       }
+}
+
+static void
+drawcell(ModeInfo * mi, int col, int row, int state)
+{
+       loopstruct *lp = &loops[MI_SCREEN(mi)];
+       XGCValues   gcv;
+       GC          gc;
+
+       if (MI_NPIXELS(mi) >= COLORS) {
+               gc = MI_GC(mi);
+               XSetForeground(MI_DISPLAY(mi), gc, lp->colors[state]);
+       } else {
+               gcv.stipple = lp->pixmaps[state];
+               gcv.foreground = MI_WHITE_PIXEL(mi);
+               gcv.background = MI_BLACK_PIXEL(mi);
+               XChangeGC(MI_DISPLAY(mi), lp->stippledGC,
+                         GCStipple | GCForeground | GCBackground, &gcv);
+               gc = lp->stippledGC;
+       }
+       fillcell(mi, gc, col, row);
+}
+
+static void
+addtolist(ModeInfo * mi, int col, int row, unsigned char state)
+{
+       loopstruct *lp = &loops[MI_SCREEN(mi)];
+       CellList   *current = lp->cellList[state];
+
+       lp->cellList[state] = NULL;
+       if ((lp->cellList[state] = (CellList *) malloc(sizeof (CellList))) == NULL) {
+               lp->cellList[state] = current;
+               return;
+       }
+       lp->cellList[state]->pt.x = col;
+       lp->cellList[state]->pt.y = row;
+       lp->cellList[state]->next = current;
+       lp->ncells[state]++;
+}
+
+#ifdef DEBUG
+static void
+print_state(ModeInfo * mi, int state)
+{
+       loopstruct *lp = &loops[MI_SCREEN(mi)];
+       CellList   *locallist = lp->cellList[state];
+       int         i = 0;
+
+       (void) printf("state %d\n", state);
+       while (locallist) {
+               (void) printf("%d x %d, y %d\n", i,
+                             locallist->pt.x, locallist->pt.y);
+               locallist = locallist->next;
+               i++;
+       }
+}
+
+#endif
+
+static void
+free_state(loopstruct * lp, int state)
+{
+       CellList   *current;
+
+       while (lp->cellList[state]) {
+               current = lp->cellList[state];
+               lp->cellList[state] = lp->cellList[state]->next;
+               (void) free((void *) current);
+       }
+       lp->ncells[state] = 0;
+}
+
+static void
+draw_state(ModeInfo * mi, int state)
+{
+       loopstruct *lp = &loops[MI_SCREEN(mi)];
+       GC          gc;
+       XGCValues   gcv;
+       CellList   *current = lp->cellList[state];
+
+       if (MI_NPIXELS(mi) >= COLORS) {
+               gc = MI_GC(mi);
+               XSetForeground(MI_DISPLAY(mi), gc, lp->colors[state]);
+       } else {
+               gcv.stipple = lp->pixmaps[state];
+               gcv.foreground = MI_WHITE_PIXEL(mi);
+               gcv.background = MI_BLACK_PIXEL(mi);
+               XChangeGC(MI_DISPLAY(mi), lp->stippledGC,
+                         GCStipple | GCForeground | GCBackground, &gcv);
+               gc = lp->stippledGC;
+       }
+
+       if (local_neighbors == 6) {       /* Draw right away, slow */
+               while (current) {
+                       int      col, row, ccol, crow;
+
+                       col = current->pt.x;
+                       row = current->pt.y;
+                       ccol = 2 * col + !(row & 1), crow = 2 * row;
+                       lp->shape.hexagon[0].x = lp->xb + ccol * lp->xs;
+                       lp->shape.hexagon[0].y = lp->yb + crow * lp->ys;
+                       if (lp->xs == 1 && lp->ys == 1)
+                               XFillRectangle(MI_DISPLAY(mi), MI_WINDOW(mi), gc,
+                                       lp->shape.hexagon[0].x, lp->shape.hexagon[0].y, 1, 1);
+                       else
+                               XFillPolygon(MI_DISPLAY(mi), MI_WINDOW(mi), gc,
+                                       lp->shape.hexagon, 6, Convex, CoordModePrevious);
+                       current = current->next;
+               }
+       } else {
+               /* Take advantage of XFillRectangles */
+               XRectangle *rects = NULL;
+               int         nrects = 0;
+
+               /* Create Rectangle list from part of the cellList */
+               if ((rects = (XRectangle *) malloc(lp->ncells[state] * sizeof (XRectangle))) == NULL) {
+                       return;
+               }
+
+               while (current) {
+                       rects[nrects].x = lp->xb + current->pt.x * lp->xs;
+                       rects[nrects].y = lp->yb + current->pt.y * lp->ys;
+                       rects[nrects].width = lp->xs - (lp->xs > 3);
+                       rects[nrects].height = lp->ys - (lp->ys > 3);
+                       current = current->next;
+                       nrects++;
+               }
+               /* Finally get to draw */
+               XFillRectangles(MI_DISPLAY(mi), MI_WINDOW(mi), gc, rects, nrects);
+               /* Free up rects list and the appropriate part of the cellList */
+               (void) free((void *) rects);
+       }
+       free_state(lp, state);
+       XFlush(MI_DISPLAY(mi));
+}
+
+static int
+init_table(void)
+{
+       if (table == NULL) {
+               int mult = 1;
+               unsigned int tt, c, n[MAXNEIGHBORS], i;
+               int         j, k;
+               int  size_transition_table = sizeof (transition_table) /
+                       sizeof (unsigned int);
+               int  size_hex_transition_table = sizeof (hex_transition_table) /
+                       sizeof (unsigned int);
+
+               for (j = 0; j < local_neighbors; j++)
+                       mult *= 8;
+
+               if ((table = (unsigned int *) calloc(mult, sizeof (unsigned int))) == NULL) {
+                       return 1;
+               }
+
+#ifdef RAND_RULES
+               /* Here I was interested to see what happens when it hits a wall....
+                  Rules not normally used take over... takes too much time though */
+               {
+                       for (j = 0; j < mult; j++) {
+                               for (k = 0; k < 8; k++)
+                                       table[j] |= (unsigned int) ((unsigned int) (NRAND(8)) << (k * 3));
+                       }
+               }
+#endif
+               if (local_neighbors == 6) {
+                       for (j = 0; j < size_hex_transition_table; j++) {
+                               tt = hex_transition_table[j];
+                               TRANSITION(tt, i);
+                               for (k = 0; k < local_neighbors; k++) {
+                                       TRANSITION(tt, n[k]);
+                               }
+                               TRANSITION(tt, c);
+                               HEX_TABLE_IN(c, n[0], n[1], n[2], n[3], n[4], n[5], i);
+                               HEX_TABLE_IN(c, n[1], n[2], n[3], n[4], n[5], n[0], i);
+                               HEX_TABLE_IN(c, n[2], n[3], n[4], n[5], n[0], n[1], i);
+                               HEX_TABLE_IN(c, n[3], n[4], n[5], n[0], n[1], n[2], i);
+                               HEX_TABLE_IN(c, n[4], n[5], n[0], n[1], n[2], n[3], i);
+                               HEX_TABLE_IN(c, n[5], n[0], n[1], n[2], n[3], n[4], i);
+                       }
+               } else {
+                       for (j = 0; j < size_transition_table; j++) {
+                               tt = transition_table[j];
+                               TRANSITION(tt, i);
+                               for (k = 0; k < local_neighbors; k++) {
+                                       TRANSITION(tt, n[k]);
+                               }
+                               TRANSITION(tt, c);
+                               TABLE_IN(c, n[0], n[1], n[2], n[3], i);
+                               TABLE_IN(c, n[1], n[2], n[3], n[0], i);
+                               TABLE_IN(c, n[2], n[3], n[0], n[1], i);
+                               TABLE_IN(c, n[3], n[0], n[1], n[2], i);
+                       }
+               }
+       }
+       return 0;
+}
+
+static void
+init_adam(ModeInfo * mi)
+{
+       loopstruct *lp = &loops[MI_SCREEN(mi)];
+       XPoint      start, dirx, diry;
+       int         i, j;
+
+  if (local_neighbors == 6) {
+               int k;
+
+               /* switch (0) */
+               switch (NRAND(6)) {
+                       case 0:
+                               start.x = (lp->bncols - HEX_ADAM_LOOPX / 2) / 2;
+                               start.y = (lp->bnrows - HEX_ADAM_LOOPY) / 2;
+                               lp->mincol = start.x - 2;
+                               lp->minrow = start.y - 1;
+                               lp->maxcol = start.x + HEX_ADAM_LOOPX + 1;
+                               lp->maxrow = start.y + HEX_ADAM_LOOPY + 1;
+                               for (j = 0; j < HEX_ADAM_LOOPY; j++) {
+                                       for (i = 0; i < HEX_ADAM_LOOPX; i++) {
+                                               k = (((lp->bnrows / 2 + HEX_ADAM_LOOPY / 2) % 2) ? -j / 2 : -(j + 1) / 2);
+                                               lp->newcells[(start.y + j) * lp->bncols + start.x + i + k] =
+                                                       hex_self_reproducing_loop[j][i];
+                                       }
+                               }
+                               break;
+                       case 1:
+                               start.x = (lp->bncols - (HEX_ADAM_LOOPX + HEX_ADAM_LOOPY) / 2) / 2;
+                               start.y = (lp->bnrows - HEX_ADAM_LOOPX + HEX_ADAM_LOOPY) / 2;
+                               lp->mincol = start.x - 1;
+                               lp->minrow = start.y - HEX_ADAM_LOOPX;
+                               lp->maxcol = start.x + (HEX_ADAM_LOOPX + HEX_ADAM_LOOPY) / 2 + 1;
+                               lp->maxrow = start.y + HEX_ADAM_LOOPY + 1;
+                               for (j = 0; j < HEX_ADAM_LOOPY; j++) {
+                                       for (i = 0; i < HEX_ADAM_LOOPX; i++) {
+                                               k = (((lp->bnrows / 2 + (HEX_ADAM_LOOPX + HEX_ADAM_LOOPY) / 2) % 2)
+              ? -(i + j + 1) / 2 : -(i + j) / 2);
+                                               lp->newcells[(start.y + j - i) * lp->bncols + start.x + i + j + k] =
+                                                       hex_self_reproducing_loop[j][i];
+                                       }
+                               }
+                               break;
+                       case 2:
+                               start.x = (lp->bncols - HEX_ADAM_LOOPY / 2) / 2;
+                               start.y = (lp->bnrows - HEX_ADAM_LOOPX) / 2;
+                               lp->mincol = start.x - 2;
+                               lp->minrow = start.y - 1;
+                               lp->maxcol = start.x + HEX_ADAM_LOOPY + 1;
+                               lp->maxrow = start.y + HEX_ADAM_LOOPX + 1;
+                               for (j = 0; j < HEX_ADAM_LOOPX; j++) {
+                                       for (i = 0; i < HEX_ADAM_LOOPY; i++) {
+                                               k = (((lp->bnrows / 2 + HEX_ADAM_LOOPX / 2) % 2) ? -(HEX_ADAM_LOOPX - j - 1) / 2 : -(HEX_ADAM_LOOPX - j) / 2);
+                                               lp->newcells[(start.y + j) * lp->bncols + start.x + i + k] =
+                                                       hex_self_reproducing_loop[i][HEX_ADAM_LOOPX - j - 1];
+                                       }
+                               }
+                               break;
+                       case 3:
+                               start.x = (lp->bncols - HEX_ADAM_LOOPX / 2) / 2;
+                               start.y = (lp->bnrows - HEX_ADAM_LOOPY) / 2;
+                               lp->mincol = start.x - 1, lp->minrow = start.y - 1;
+                               lp->maxcol = start.x + HEX_ADAM_LOOPX + 1, lp->maxrow = start.y + HEX_ADAM_LOOPY + 1;
+                               for (j = 0; j < HEX_ADAM_LOOPY; j++) {
+                                       for (i = 0; i < HEX_ADAM_LOOPX; i++) {
+                                               k = (((lp->bnrows / 2 + HEX_ADAM_LOOPY / 2) % 2) ? -j / 2 : -(j + 1) / 2);
+                                               lp->newcells[(start.y + j) * lp->bncols + start.x + i + k] =
+                                                       hex_self_reproducing_loop[HEX_ADAM_LOOPY - j - 1][HEX_ADAM_LOOPX - i - 1];
+                                       }
+                               }
+                               break;
+                       case 4:
+                               start.x = (lp->bncols - (HEX_ADAM_LOOPX + HEX_ADAM_LOOPY) / 2) / 2;
+                               start.y = (lp->bnrows - HEX_ADAM_LOOPX + HEX_ADAM_LOOPY) / 2;
+                               lp->mincol = start.x - 1;
+                               lp->minrow = start.y - HEX_ADAM_LOOPX;
+                               lp->maxcol = start.x + (HEX_ADAM_LOOPX + HEX_ADAM_LOOPY) / 2 + 1;
+                               lp->maxrow = start.y + HEX_ADAM_LOOPY + 1;
+                               for (j = 0; j < HEX_ADAM_LOOPY; j++) {
+                                       for (i = 0; i < HEX_ADAM_LOOPX; i++) {
+                                               k = (((lp->bnrows / 2 + (HEX_ADAM_LOOPX + HEX_ADAM_LOOPY) / 2) % 2)
+              ? -(i + j + 1) / 2 : -(i + j) / 2);
+                                               lp->newcells[(start.y + j - i) * lp->bncols + start.x + i + j + k] =
+                                                       hex_self_reproducing_loop[HEX_ADAM_LOOPY - j - 1][HEX_ADAM_LOOPX - i - 1];
+                                       }
+                               }
+                               break;
+                       case 5:
+                               start.x = (lp->bncols - HEX_ADAM_LOOPY / 2) / 2;
+                               start.y = (lp->bnrows - HEX_ADAM_LOOPX) / 2;
+                               lp->mincol = start.x - 2;
+                               lp->minrow = start.y - 1;
+                               lp->maxcol = start.x + HEX_ADAM_LOOPY + 1;
+                               lp->maxrow = start.y + HEX_ADAM_LOOPX + 1;
+                               for (j = 0; j < HEX_ADAM_LOOPX; j++) {
+                                       for (i = 0; i < HEX_ADAM_LOOPY; i++) {
+                                               k = (((lp->bnrows / 2 + HEX_ADAM_LOOPX / 2) % 2) ? -(HEX_ADAM_LOOPX - j - 1) / 2 : -(HEX_ADAM_LOOPX - j) / 2);
+                                               lp->newcells[(start.y + j) * lp->bncols + start.x + i + k] =
+                                                       hex_self_reproducing_loop[HEX_ADAM_LOOPX - i - 1][j];
+                                       }
+                               }
+                               break;
+               }
+#if DEBUGTEST
+                               /* printf ("s %d  s %d \n", start.x, start.y); */
+               printf ("%d %d %d %d %d\t",
+     start.x + i + ((lp->bnrows / 2 % 2) ? -j / 2 : -(j + 1) / 2) - lp->bx,
+                start.y + j - lp->by, i, j, hex_self_reproducing_loop[j][i]);
+               /* Draw right away */
+               drawcell(mi, start.x + i + ((lp->bnrows / 2 % 2) ? -j / 2 : -(j + 1) / 2) - lp->bx,
+                start.y + j - lp->by,
+                hex_self_reproducing_loop[j][i]);
+#endif
+#if DEBUGTEST
+                        printf ("\n");
+#endif
+#if DEBUGTEST
+                        printf ("\n");
+#endif
+  } else {
+               switch (NRAND(4)) {
+                       case 0:
+                               start.x = (lp->bncols - ADAM_LOOPX) / 2;
+                               start.y = (lp->bnrows - ADAM_LOOPY) / 2;
+                               dirx.x = 1, dirx.y = 0;
+                               diry.x = 0, diry.y = 1;
+                               lp->mincol = start.x, lp->minrow = start.y;
+                               lp->maxcol = start.x + ADAM_LOOPX, lp->maxrow = start.y + ADAM_LOOPY;
+                               break;
+                       case 1:
+                               start.x = (lp->bncols + ADAM_LOOPY) / 2;
+                               start.y = (lp->bnrows - ADAM_LOOPX) / 2;
+                               dirx.x = 0, dirx.y = 1;
+                               diry.x = -1, diry.y = 0;
+                               lp->mincol = start.x - ADAM_LOOPY, lp->minrow = start.y;
+                               lp->maxcol = start.x, lp->maxrow = start.y + ADAM_LOOPX;
+                               break;
+                       case 2:
+                               start.x = (lp->bncols + ADAM_LOOPX) / 2;
+                               start.y = (lp->bnrows + ADAM_LOOPY) / 2;
+                               dirx.x = -1, dirx.y = 0;
+                               diry.x = 0, diry.y = -1;
+                               lp->mincol = start.x - ADAM_LOOPX, lp->minrow = start.y - ADAM_LOOPY;
+                               lp->maxcol = start.x, lp->maxrow = start.y;
+                               break;
+                       case 3:
+                               start.x = (lp->bncols - ADAM_LOOPY) / 2;
+                               start.y = (lp->bnrows + ADAM_LOOPX) / 2;
+                               dirx.x = 0, dirx.y = -1;
+                               diry.x = 1, diry.y = 0;
+                               lp->mincol = start.x, lp->minrow = start.y - ADAM_LOOPX;
+                               lp->maxcol = start.x + ADAM_LOOPY, lp->maxrow = start.y;
+                               break;
+               }
+               for (j = 0; j < ADAM_LOOPY; j++)
+                       for (i = 0; i < ADAM_LOOPX; i++)
+                               lp->newcells[(start.y + dirx.y * i + diry.y * j) * lp->bncols +
+                                            start.x + dirx.x * i + diry.x * j] =
+                                       self_reproducing_loop[j][i];
+#if DEBUG
+               /* Draw right away */
+               drawcell(mi, start.x + dirx.x * i + diry.x * j - lp->bx,
+                start.y + dirx.y * i + diry.y * j - lp->by,
+                self_reproducing_loop[j][i]);
+#endif
+       }
+}
+
+
+static void
+do_gen(loopstruct * lp)
+{
+       int         i, j, k;
+       unsigned char *z;
+       unsigned int n[MAXNEIGHBORS];
+       unsigned int c;
+
+#define LOC(X, Y) (*(lp->oldcells + (X) + ((Y) * lp->bncols)))
+
+       for (j = lp->minrow; j <= lp->maxrow; j++) {
+               for (i = lp->mincol; i <= lp->maxcol; i++) {
+                       z = lp->newcells + i + j * lp->bncols;
+                       c = LOC(i, j);
+                       for (k = 0; k < local_neighbors; k++) {
+                               int         newi = i, newj = j;
+
+                               position_of_neighbor(k * ANGLES / local_neighbors, &newi, &newj);
+                               n[k] = 0;
+                   if (withinBounds(lp, newi, newj)) {
+                                       n[k] = LOC(newi, newj);
+                               }
+                       }
+                       if (local_neighbors == 6) {
+                               *z = HEX_TABLE_OUT(c, n[0], n[1], n[2], n[3], n[4], n[5]);
+                       } else {
+                               *z = TABLE_OUT(c, n[0], n[1], n[2], n[3]);
+                       }
+               }
+       }
+}
+
+static void
+free_list(loopstruct * lp)
+{
+       int         state;
+
+       for (state = 0; state < COLORS; state++)
+               free_state(lp, state);
+}
+
+void
+release_loop(ModeInfo * mi)
+{
+       if (loops != NULL) {
+               int         screen;
+
+               for (screen = 0; screen < MI_NUM_SCREENS(mi); screen++) {
+                       loopstruct *lp = &loops[screen];
+                       int         shade;
+
+                       for (shade = 0; shade < lp->init_bits; shade++)
+                               if (lp->pixmaps[shade] != None)
+                                       XFreePixmap(MI_DISPLAY(mi), lp->pixmaps[shade]);
+                       if (lp->stippledGC != None)
+                               XFreeGC(MI_DISPLAY(mi), lp->stippledGC);
+                       if (lp->oldcells != NULL)
+                               (void) free((void *) lp->oldcells);
+                       if (lp->newcells != NULL)
+                               (void) free((void *) lp->newcells);
+                       free_list(lp);
+               }
+               (void) free((void *) loops);
+               loops = NULL;
+       }
+       if (table != NULL) {
+               (void) free((void *) table);
+               table = NULL;
+       }
+}
+
+void
+init_loop(ModeInfo * mi)
+{
+       Display    *display = MI_DISPLAY(mi);
+       Window      window = MI_WINDOW(mi);
+       int         i, size = MI_SIZE(mi);
+       loopstruct *lp;
+       XGCValues   gcv;
+
+       if (loops == NULL) {
+               if ((loops = (loopstruct *) calloc(MI_NUM_SCREENS(mi),
+                                              sizeof (loopstruct))) == NULL)
+                       return;
+       }
+       lp = &loops[MI_SCREEN(mi)];
+
+       lp->redrawing = 0;
+
+       if ((MI_NPIXELS(mi) < COLORS) && (lp->init_bits == 0)) {
+               if (lp->stippledGC == None) {
+                       gcv.fill_style = FillOpaqueStippled;
+                       lp->stippledGC = XCreateGC(display, window, GCFillStyle, &gcv);
+                       if (lp->stippledGC == None) {
+                               release_loop(mi);
+                               return;
+                       }
+               }
+               LOOPBITS(stipples[0], STIPPLESIZE, STIPPLESIZE);
+               LOOPBITS(stipples[2], STIPPLESIZE, STIPPLESIZE);
+               LOOPBITS(stipples[3], STIPPLESIZE, STIPPLESIZE);
+               LOOPBITS(stipples[4], STIPPLESIZE, STIPPLESIZE);
+               LOOPBITS(stipples[6], STIPPLESIZE, STIPPLESIZE);
+               LOOPBITS(stipples[7], STIPPLESIZE, STIPPLESIZE);
+               LOOPBITS(stipples[8], STIPPLESIZE, STIPPLESIZE);
+               LOOPBITS(stipples[10], STIPPLESIZE, STIPPLESIZE);
+       if (lp->pixmaps[COLORS - 1] == None) {
+                       release_loop(mi);
+                       return;
+               }
+       }
+       if (MI_NPIXELS(mi) >= COLORS) {
+               /* Maybe these colors should be randomized */
+               lp->colors[0] = MI_BLACK_PIXEL(mi);
+               lp->colors[1] = MI_PIXEL(mi, 0);        /* RED */
+               lp->colors[5] = MI_PIXEL(mi, MI_NPIXELS(mi) / REALCOLORS);      /* YELLOW */
+               lp->colors[4] = MI_PIXEL(mi, 2 * MI_NPIXELS(mi) / REALCOLORS);  /* GREEN */
+               lp->colors[6] = MI_PIXEL(mi, 3 * MI_NPIXELS(mi) / REALCOLORS);  /* CYAN */
+               lp->colors[2] = MI_PIXEL(mi, 4 * MI_NPIXELS(mi) / REALCOLORS);  /* BLUE */
+               lp->colors[3] = MI_PIXEL(mi, 5 * MI_NPIXELS(mi) / REALCOLORS);  /* MAGENTA */
+               lp->colors[7] = MI_WHITE_PIXEL(mi);
+       }
+       free_list(lp);
+       lp->generation = 0;
+       lp->width = MI_WIDTH(mi);
+       lp->height = MI_HEIGHT(mi);
+
+  if (!local_neighbors) {
+    for (i = 0; i < NEIGHBORKINDS; i++) {
+      if (neighbors == plots[i]) {
+        local_neighbors = neighbors;
+        neighbor_kind = i;
+        break;
+      }
+                       if (i == NEIGHBORKINDS - 1) {
+
+#if 1
+                               local_neighbors = plots[NRAND(NEIGHBORKINDS)];
+                               neighbor_kind = (local_neighbors == 4) ? 0 : 1;
+#else
+                               local_neighbors = 4;
+                               neighbor_kind = 0;
+#endif
+                               break;
+                       }
+               }
+       }
+
+
+  if (local_neighbors == 6) {
+    int         nccols, ncrows;
+
+    if (lp->width < 4)
+      lp->width = 4;
+    if (lp->height < 4)
+      lp->height = 4;
+    if (size < -MINSIZE) {
+      lp->ys = NRAND(MIN(-size, MAX(MINSIZE, MIN(lp->width, lp->height) /
+              HEX_MINGRIDSIZE)) - MINSIZE + 1) + MINSIZE;
+    } else if (size < MINSIZE) {
+      if (!size)
+        lp->ys = MAX(MINSIZE, MIN(lp->width, lp->height) / HEX_MINGRIDSIZE);
+      else
+        lp->ys = MINSIZE;
+    } else
+      lp->ys = MIN(size, MAX(MINSIZE, MIN(lp->width, lp->height) /
+                 HEX_MINGRIDSIZE));
+    lp->xs = lp->ys;
+               nccols = MAX(lp->width / lp->xs - 2, HEX_ADAM_LOOPX + 1);
+               ncrows = MAX(lp->height / lp->ys - 1, HEX_ADAM_LOOPY + 1);
+    lp->ncols = nccols / 2;
+    lp->nrows = ncrows / 2;
+               lp->nrows -= !(lp->nrows & 1);  /* Must be odd */
+    lp->xb = (lp->width - lp->xs * nccols) / 2 + lp->xs;
+    lp->yb = (lp->height - lp->ys * ncrows) / 2 + lp->ys;
+    for (i = 0; i < 6; i++) {
+      lp->shape.hexagon[i].x = (lp->xs - 1) * hexagonUnit[i].x;
+      lp->shape.hexagon[i].y = ((lp->ys - 1) * hexagonUnit[i].y / 2) * 4 / 3;
+    }
+  } else {
+               if (size < -MINSIZE)
+                       lp->ys = NRAND(MIN(-size, MAX(MINSIZE, MIN(lp->width, lp->height) /
+                                             MINGRIDSIZE)) - MINSIZE + 1) + MINSIZE;
+               else if (size < MINSIZE) {
+                       if (!size)
+                               lp->ys = MAX(MINSIZE, MIN(lp->width, lp->height) / MINGRIDSIZE);
+                       else
+                               lp->ys = MINSIZE;
+               } else
+                       lp->ys = MIN(size, MAX(MINSIZE, MIN(lp->width, lp->height) /
+                                              MINGRIDSIZE));
+               lp->xs = lp->ys;
+               lp->ncols = MAX(lp->width / lp->xs, ADAM_LOOPX + 1);
+               lp->nrows = MAX(lp->height / lp->ys, ADAM_LOOPX + 1);
+               lp->xb = (lp->width - lp->xs * lp->ncols) / 2;
+               lp->yb = (lp->height - lp->ys * lp->nrows) / 2;
+       }
+       lp->bx = 1;
+       lp->by = 1;
+       lp->bncols = lp->ncols + 2 * lp->bx;
+       lp->bnrows = lp->nrows + 2 * lp->by;
+
+       MI_CLEARWINDOW(mi);
+
+       if (lp->oldcells != NULL) {
+               (void) free((void *) lp->oldcells);
+               lp->oldcells = NULL;
+       }       
+       if ((lp->oldcells = (unsigned char *) calloc(lp->bncols * lp->bnrows, sizeof (unsigned char))) == NULL) {
+               release_loop(mi);
+               return;
+       }
+       if (lp->newcells != NULL) {
+               (void) free((void *) lp->newcells);
+               lp->newcells = NULL;
+       }
+       if ((lp->newcells = (unsigned char *) calloc(lp->bncols * lp->bnrows, sizeof (unsigned char))) == NULL) {
+               release_loop(mi);
+               return;
+       }
+  if (init_table()) {
+               release_loop(mi);
+               return;
+       }
+       init_adam(mi);
+}
+
+void
+draw_loop(ModeInfo * mi)
+{
+       loopstruct *lp = &loops[MI_SCREEN(mi)];
+       int         offset, i, j, life = 0;
+       unsigned char *z, *znew;
+
+       if (loops == NULL) {
+               init_loop(mi);
+               return;
+       }
+       MI_IS_DRAWN(mi) = True;
+
+       for (j = lp->minrow; j <= lp->maxrow; j++) {
+               for (i = lp->mincol; i <= lp->maxcol; i++) {
+                       offset = j * lp->bncols + i;
+                       z = lp->oldcells + offset;
+                       znew = lp->newcells + offset;
+                       if (*z != *znew) {
+                               *z = *znew;
+                               addtolist(mi, i - lp->bx, j - lp->by, *znew);
+                               life = 1;
+                               if (i == lp->mincol && i > lp->bx)
+                                       lp->mincol--;
+                               if (j == lp->minrow && j > lp->by)
+                                       lp->minrow--;
+                               if (i == lp->maxcol && i < lp->bncols - 2 * lp->bx)
+                                       lp->maxcol++;
+                               if (j == lp->maxrow && j < lp->bnrows - 2 * lp->by)
+                                       lp->maxrow++;
+                       }
+               }
+       }
+       for (i = 0; i < COLORS; i++)
+               draw_state(mi, i);
+       if (++lp->generation > MI_CYCLES(mi) /* || !life */) {
+               init_loop(mi);
+               return;
+       } else
+               do_gen(lp);
+
+       if (lp->redrawing) {
+               for (i = 0; i < REDRAWSTEP; i++) {
+                       if ((*(lp->oldcells + lp->redrawpos))) {
+                               drawcell(mi, lp->redrawpos % lp->bncols - lp->bx,
+                                        lp->redrawpos / lp->bncols - lp->by,
+                                        *(lp->oldcells + lp->redrawpos));
+                       }
+                       if (++(lp->redrawpos) >= lp->bncols * (lp->bnrows - lp->bx)) {
+                               lp->redrawing = 0;
+                               break;
+                       }
+               }
+       }
+}
+
+void
+refresh_loop(ModeInfo * mi)
+{
+       loopstruct *lp = &loops[MI_SCREEN(mi)];
+
+       if (loops == NULL) {
+               init_loop(mi);
+               return;
+       }
+       MI_CLEARWINDOW(mi);
+       lp->redrawing = 1;
+       lp->redrawpos = lp->by * lp->ncols + lp->bx;
+}
index a537eadc6b49168ea367d294326cb61452460f61..3641282f700da31ff161edca61acde5155653987 100644 (file)
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 1992, 1995, 1997, 1998
+/* xscreensaver, Copyright (c) 1992, 1995, 1997, 1998, 1999
  *  Jamie Zawinski <jwz@jwz.org>
  *
  *  reaction/diffusion textures
@@ -436,6 +436,31 @@ screenhack (Display *dpy, Window win)
            vdepth <= 16 ? 16 :
            32);
 
+  /* Ok, this like, sucks and stuff.  There are some XFree86 systems
+     that have depth-24 visuals, that do not accept depth-32 XImages!
+     Which if you ask me is just absurd, since all it would take is
+     for the server to truncate the bits in that case.  So, this crap
+     here detects the specific case of: we have chosen depth 32;
+     and the server does not support depth 32.  In that case, we
+     try and use depth 16 instead.
+
+     The real fix would be to rewrite this program to deal with
+     depth 24 directly (or even better, arbitrary depths, but that
+     would mean going through the XImage routines instead of messing
+     with the XImage->data directly.)
+   */
+  if (pdepth == 32)
+    {
+      int i, pfvc = 0;
+      Bool ok = False;
+      XPixmapFormatValues *pfv = XListPixmapFormats (dpy, &pfvc);
+      for (i = 0; i < pfvc; i++)
+        if (pfv[i].depth == pdepth)
+          ok = True;
+      if (!ok)
+        pdepth = 16;
+    }
+
   cmap = xgwa.colormap;
   ncolors = get_integer_resource ("colors", "Integer");
 
index 3c492189ad505c093a57f8c46a666768892e9b23..4b3aae08652d3cb9a5d0cc590d9e6efd1ecfeb39 100644 (file)
  * of bogies that move around on the scope while the ping sensor can be
  * used to display hosts on your network.
  *
- * The ping code is only compiled in if you define HAVE_PING, because, 
- * unfortunately, creating an ICMP socket is a privileged operation, the
- * program needs to be installed SUID root if you want to use the ping
- * mode. If you check the code you will see that this privilige is given up
- * immediately after the socket is created.
+ * The ping code is only compiled in if you define HAVE_ICMP or HAVE_ICMPHDR,
+ * because, unfortunately, different systems have different ways of creating
+ * these sorts of packets.
+ *
+ * Also: creating an ICMP socket is a privileged operation, so the program
+ * needs to be installed SUID root if you want to use the ping mode.  If you
+ * check the code you will see that this privilige is given up immediately
+ * after the socket is created.
  *
  * It should be easy to extend this code to support other sorts of sensors.
  * Some ideas:
@@ -34,7 +37,7 @@
  * software for any purpose.  It is provided "as is" without express or 
  * implied warranty.
  *
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
  *
  * Version 1.0 April 27, 1998.
  * - Initial version
  * - Now need to define HAVE_PING to compile in the ping stuff.
  */
 
+/* Define one of these, as appropriate.  
+   We should make configure detect this, one of these days.
+ */
+/* #define HAVE_ICMP */
+/* #define HAVE_ICMPHDR */
+
+
 /* Include Files */
 
-#ifdef HAVE_PING
-#include <sys/ipc.h>
-#include <sys/shm.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/time.h>
-#include <netinet/in_systm.h>
-#include <netinet/in.h>
-#include <netinet/ip.h>
-#include <netinet/ip_icmp.h>
-#include <netinet/udp.h>
-#include <arpa/inet.h>
-#include <signal.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <netdb.h>
-#include <signal.h>
-#include <limits.h>
-#endif /* HAVE_PING */
-#include <math.h>
-#include <stdio.h>
 #include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+
+#if defined(HAVE_ICMP) || defined(HAVE_ICMPHDR)
+# include <unistd.h>
+# include <limits.h>
+# include <signal.h>
+# include <fcntl.h>
+# include <sys/types.h>
+# include <sys/time.h>
+# include <sys/ipc.h>
+# include <sys/shm.h>
+# include <sys/socket.h>
+# include <netinet/in_systm.h>
+# include <netinet/in.h>
+# include <netinet/ip.h>
+# include <netinet/ip_icmp.h>
+# include <netinet/udp.h>
+# include <arpa/inet.h>
+# include <netdb.h>
+#endif /* HAVE_ICMP || HAVE_ICMPHDR */
+
 #include "screenhack.h"
 #include "colors.h"
 #include "hsv.h"
+
 #include <X11/extensions/XShm.h>
 
+
 /* Defines */
 
-#ifndef MIN
-#define MIN(a,b) ((a)<(b)?(a - 50):(b - 10))
-#endif /* MIN */
+#undef MY_MIN
+#define MY_MIN(a,b) ((a)<(b)?(a - 50):(b - 10))
+
+/* Frigging icmp */
+
+#if defined(HAVE_ICMP)
+# define HAVE_PING
+# define ICMP             icmp
+# define ICMP_TYPE(p)     (p)->icmp_type
+# define ICMP_CODE(p)     (p)->icmp_code
+# define ICMP_CHECKSUM(p) (p)->icmp_cksum
+# define ICMP_ID(p)       (p)->icmp_id
+# define ICMP_SEQ(p)      (p)->icmp_seq
+#elif defined(HAVE_ICMPHDR)
+# define HAVE_PING
+# define ICMP             icmphdr
+# define ICMP_TYPE(p)     (p)->type
+# define ICMP_CODE(p)     (p)->code
+# define ICMP_CHECKSUM(p) (p)->checksum
+# define ICMP_ID(p)       (p)->un.echo.id
+# define ICMP_SEQ(p)      (p)->un.echo.sequence
+#else
+# undef HAVE_PING
+#endif
 
 /* Forward References */
 
@@ -775,7 +809,7 @@ sendping(ping_info *pi, ping_target *pt)
     /* Local Variables */
 
     u_char *packet;
-    struct icmp *icmph;
+    struct ICMP *icmph;
     int result;
 
     /*
@@ -784,24 +818,24 @@ sendping(ping_info *pi, ping_target *pt)
      * name or do an address lookup when it comes back.
      */
 
-    int pcktsiz = sizeof(struct icmp) + sizeof(struct timeval) +
+    int pcktsiz = sizeof(struct ICMP) + sizeof(struct timeval) +
        strlen(pt->name) + 1;
 
     /* Create the ICMP packet */
 
     if ((packet = (u_char *) malloc(pcktsiz)) == (void *) 0)
        return;  /* Out of memory */
-    icmph = (struct icmp *) packet;
-    icmph->icmp_type = ICMP_ECHO;
-    icmph->icmp_code = 0;
-    icmph->icmp_cksum = 0;
-    icmph->icmp_id = pi->pid;
-    icmph->icmp_seq = pi->seq++;
-    gettimeofday((struct timeval *) &packet[sizeof(struct icmp)],
+    icmph = (struct ICMP *) packet;
+    ICMP_TYPE(icmph) = ICMP_ECHO;
+    ICMP_CODE(icmph) = 0;
+    ICMP_CHECKSUM(icmph) = 0;
+    ICMP_ID(icmph) = pi->pid;
+    ICMP_SEQ(icmph) = pi->seq++;
+    gettimeofday((struct timeval *) &packet[sizeof(struct ICMP)],
                 (struct timezone *) 0);
-    strcpy((char *) &packet[sizeof(struct icmp) + sizeof(struct timeval)],
+    strcpy((char *) &packet[sizeof(struct ICMP) + sizeof(struct timeval)],
           pt->name);
-    icmph->icmp_cksum = checksum((u_short *)packet, pcktsiz);
+    ICMP_CHECKSUM(icmph) = checksum((u_short *)packet, pcktsiz);
 
     /* Send it */
 
@@ -866,6 +900,7 @@ checksum(u_short *packet, int size)
 
     if (nleft == 1) {
        *(u_char *)(&answer) = *(u_char *)w ;
+        *(1 + (u_char *)(&answer)) = 0;
        sum += answer;
     }
 
@@ -908,7 +943,7 @@ getping(sonar_info *si, ping_info *pi, int ttl)
     struct timeval *then;
     struct ip *ip;
     int iphdrlen;
-    struct icmp *icmph;
+    struct ICMP *icmph;
     Bogie *bl = NULL;
     Bogie *new;
     char *name;
@@ -946,18 +981,18 @@ getping(sonar_info *si, ping_info *pi, int ttl)
        gettimeofday(&now, (struct timezone *) 0);
        ip = (struct ip *) packet;
        iphdrlen = ip->ip_hl << 2;
-       icmph = (struct icmp *) &packet[iphdrlen];
+       icmph = (struct ICMP *) &packet[iphdrlen];
 
        /* Was the packet a reply?? */
 
-       if (icmph->icmp_type != ICMP_ECHOREPLY) {
+       if (ICMP_TYPE(icmph) != ICMP_ECHOREPLY) {
            /* Ignore anything but ICMP Replies */
            continue; /* Nope */
        }
 
        /* Was it for us? */
 
-       if (icmph->icmp_id != pi->pid) {
+       if (ICMP_ID(icmph) != pi->pid) {
            /* Ignore packets not set from us */
            continue; /* Nope */
        }
@@ -966,7 +1001,7 @@ getping(sonar_info *si, ping_info *pi, int ttl)
 
        if ((name =
             strdup((char *) &packet[iphdrlen + 
-                                   + sizeof(struct icmp)
+                                   + sizeof(struct ICMP)
                                    + sizeof(struct timeval)])) == NULL) {
            fprintf(stderr, "Out of memory\n");
            return bl;
@@ -1001,7 +1036,7 @@ getping(sonar_info *si, ping_info *pi, int ttl)
        /* Compute the round trip time */
 
        then =  (struct timeval *) &packet[iphdrlen +
-                                         sizeof(struct icmp)];
+                                         sizeof(struct ICMP)];
        new->distance = delta(then, &now) / 100;
        if (new->distance == 0)
                new->distance = 2; /* HACK */
@@ -1088,10 +1123,6 @@ init_sim(void)
     sim_info *si;
     int i;
 
-    /* Seed the random number generator */
-
-    srand((int) time(NULL));
-
     /* Create the simulation info structure */
 
     if ((si = (sim_info *) calloc(1, sizeof(sim_info))) == NULL) {
@@ -1117,8 +1148,8 @@ init_sim(void)
            return NULL;
        }
        sprintf(si->teamA[i].name, "%s%03d", si->teamAID, i+1);
-       si->teamA[i].nexttick = (int) (90.0 * rand() / RAND_MAX);
-       si->teamA[i].nextdist = (int) (100.0 * rand() / RAND_MAX);
+       si->teamA[i].nexttick = (int) (90.0 * random() / RAND_MAX);
+       si->teamA[i].nextdist = (int) (100.0 * random() / RAND_MAX);
     }
 
     /* Team B */
@@ -1139,8 +1170,8 @@ init_sim(void)
            return NULL;
        }
        sprintf(si->teamB[i].name, "%s%03d", si->teamBID, i+1);
-       si->teamB[i].nexttick = (int) (90.0 * rand() / RAND_MAX);
-       si->teamB[i].nextdist = (int) (100.0 * rand() / RAND_MAX);
+       si->teamB[i].nexttick = (int) (90.0 * random() / RAND_MAX);
+       si->teamB[i].nextdist = (int) (100.0 * random() / RAND_MAX);
     }
 
     /* Done */
@@ -1190,10 +1221,10 @@ init_sonar(Display *dpy, Window win)
     si->height = xwa.height;
     si->centrex = si->width / 2;
     si->centrey = si->height / 2;
-    si->maxx = si->centrex + MIN(si->centrex, si->centrey) - 10;
-    si->minx = si->centrex - MIN(si->centrex, si->centrey) + 10;
-    si->maxy = si->centrey + MIN(si->centrex, si->centrey) - 10;
-    si->miny = si->centrey - MIN(si->centrex, si->centrey) + 10;
+    si->maxx = si->centrex + MY_MIN(si->centrex, si->centrey) - 10;
+    si->minx = si->centrex - MY_MIN(si->centrex, si->centrey) + 10;
+    si->maxy = si->centrey + MY_MIN(si->centrex, si->centrey) - 10;
+    si->miny = si->centrey - MY_MIN(si->centrex, si->centrey) + 10;
     si->radius = si->maxx - si->centrex;
     si->current = 0;
 
@@ -1284,8 +1315,8 @@ updateLocation(sim_target *t)
     int xdist, xtick;
 
     t->movedlasttick = 1;
-    xtick = (int) (3.0 * rand() / RAND_MAX) - 1;
-    xdist = (int) (11.0 * rand() / RAND_MAX) - 5;
+    xtick = (int) (3.0 * random() / RAND_MAX) - 1;
+    xdist = (int) (11.0 * random() / RAND_MAX) - 5;
     if (((t->nexttick + xtick) < 90) && ((t->nexttick + xtick) >= 0))
        t->nexttick += xtick;
     else
diff --git a/hacks/t3d.c b/hacks/t3d.c
new file mode 100644 (file)
index 0000000..ae0396e
--- /dev/null
@@ -0,0 +1,937 @@
+/* t3d -- Flying Balls Clock Demo
+   by Bernd Paysan , paysan@informatik.tu-muenchen.de
+
+   Copy, modify, and distribute T3D either under GPL  version 2 or newer, 
+   or under the standard MIT/X license notice.
+
+  partly based on flying balls demo by Georg Acher, 
+  acher@informatik.tu-muenchen.de
+  (developed on HP9000/720 (55 MIPS,20 MFLOPS) )
+  NO warranty at all ! Complaints to /dev/null !
+
+  4-Jan-99 jwz@jwz.org -- adapted to xscreensaver framework, to take advantage
+                          of the command-line options provided by screenhack.c.
+*/
+
+#undef FASTDRAW
+#undef USE_POLYGON
+
+#ifdef FASTDRAW
+# define FASTCOPY
+#endif
+
+#include <stdio.h>
+#include <math.h>
+
+#include "screenhack.h"
+
+
+static int maxk=34;
+
+#define   WIDTH      200
+#define   HEIGHT     200
+#define   norm       20.0
+
+int timewait=40000;
+
+#define   ROOT       0x1
+#define PI M_PI
+#define TWOPI 2*M_PI
+
+#define MIN(i,j) ((i)<(j)?(i):(j))
+
+#define kmax ((minutes?60:24))
+/* Anzahl der Kugeln */
+#define sines 52
+/* Werte in der Sinus-Tabelle */
+/*-----------------------------------------------------------------*/
+#define setink(inkcolor) \
+       XSetForeground (dpy,gc,inkcolor)
+
+#define drawline(xx1,yy1,xx2,yy2) \
+       XDrawLine(dpy,win,gc,xx1,yy1,xx2,yy2) 
+
+#define drawseg(segments,nr_segments) \
+       XDrawSegments(dpy,win,gc,segments,nr_segments) 
+
+
+#define polyfill(ppts,pcount) \
+       XFillPolygon(dpy,win,gc,ppts,pcount,Convex,CoordModeOrigin)
+
+
+#define frac(argument) argument-floor(argument)
+
+#define abs(x) ((x)<0.0 ? -(x) : (x))
+
+static Colormap cmap;
+/* static XColor gray1; */
+static double r=1.0,g=1.0,b=1.0;
+static double hue=0.0,sat=0.0,val=1.0;
+
+typedef struct {
+  double x,y,z,r,d,r1;
+  int x1,y1;
+} kugeldat;
+
+/* Felder fuer 3D */
+
+static kugeldat kugeln[100];
+
+static double  a[3],/*m[3],*/am[3],x[3],y[3],v[3];
+static double zoom,speed,zaehler,vspeed/*,AE*/;
+static double vturn/*,aturn*/;
+/* static XPoint track[sines]; */
+static double sinus[sines];
+static double cosinus[sines];
+
+static int startx,starty;
+static double /*magx,magy,*/mag=10;
+/* static double lastx,lasty,lastz; */
+/* static int lastcx,lastcy,lastcz; */
+/* static int move=1; */
+static int minutes=0;
+static int cycl=0;
+static double hsvcycl=0.0;
+static double movef =0.5, wobber=2.0, cycle=6.0;
+
+/* time */
+
+/* static double sec; */
+
+/* Windows */
+static XWindowAttributes xgwa;
+static GC      gc;
+static GC orgc;
+static GC andgc;
+static Window  win;
+/* static Font font; */
+static Display *dpy;
+static int     screen, scrnWidth = WIDTH, scrnHeight = HEIGHT;
+static Pixmap  buffer;
+#define maxfast 100
+static int fastch=50;
+#ifdef FASTDRAW
+#      ifdef FASTCOPY
+#              define sum1ton(a) (((a)*(a)+1)/2)
+#              define fastcw sum1ton(fastch)
+               static Pixmap fastcircles;
+               static Pixmap fastmask;
+#      else
+               static XImage* fastcircles[maxfast];
+               static XImage* fastmask[maxfast];
+#      endif
+static int fastdraw=0;
+#endif
+
+static int scrnW2,scrnH2;
+/* static unsigned short flags = 0; */
+/* static char *text; */
+static XColor colors[64];
+static struct tm *zeit;
+
+static int planes;
+/* compute time */
+
+static double
+gettime (void)
+{
+  struct timeval time1;
+  struct timezone zone1;
+  struct tm *zeit;
+  
+  gettimeofday(&time1,&zone1);
+  zeit=localtime(&time1.tv_sec);
+  
+  return (zeit->tm_sec+60*(zeit->tm_min+60*(zeit->tm_hour))
+         + time1.tv_usec*1.0E-6);
+}
+
+/* --------------------COLORMAP---------------------*/ 
+
+static void
+hsv2rgb (double h, double s, double v, double *r, double *g, double *b)
+{
+  h/=360.0;    h=6*(h-floor(h));
+
+  if(s==0.0)
+    {
+      *r=*g=*b=v;
+    }
+  else
+    {  int i=(int)h;
+       double t,u,w;
+       
+       h=h-floor(h);
+       
+       u=v*(s*(1.0-h));
+       w=v*(1.0-s);
+       t=v*(s*h+1.0-s);
+       
+       switch(i)
+         {
+         case 0:       *r=v;   *g=t;   *b=w;   break;
+         case 1:       *r=u;   *g=v;   *b=w;   break;
+         case 2:       *r=w;   *g=v;   *b=t;   break;
+         case 3:       *r=w;   *g=u;   *b=v;   break;
+         case 4:       *r=t;   *g=w;   *b=v;   break;
+         case 5:       *r=v;   *g=w;   *b=u;   break;
+         }
+      }
+#ifdef PRTDBX
+  printf("HSV: %f %f %f to\nRGB: %f %f %f\n",h,s,v,*r,*g,*b);
+#endif
+}
+
+static void
+changeColor (double r, double g, double b)
+{
+  int n,n1;
+  
+  n1=0;
+  for(n=30;n<64;n+=3)
+    {
+      colors[n1].red   =1023+ n*(int)(1024.*r);
+      colors[n1].blue  =1023+ n*(int)(1024.*b);
+      colors[n1].green =1023+ n*(int)(1024.*g);
+      
+      n1++;
+    }
+  
+  XStoreColors (dpy, cmap, colors, 12);
+}
+
+static void 
+initColor (double r, double g, double b)
+{
+  int n,n1;
+  unsigned long pixels[12];
+  long dummy;
+  
+  cmap = xgwa.colormap;
+  
+  if(hsvcycl!=0.0 && XAllocColorCells(dpy, cmap, 0, &dummy, 0, pixels, 12))
+    {
+      for(n1=0;n1<12;n1++)
+       {
+         colors[n1].pixel=pixels[n1];
+         colors[n1].flags=DoRed | DoGreen | DoBlue;
+       }
+      
+      changeColor(r,g,b);
+    }
+  else
+    {
+      n1=0;
+      for(n=30;n<64;n+=3)
+       {
+         colors[n1].red   =1023+ n*(int)(1024.*r);
+         colors[n1].blue  =1023+ n*(int)(1024.*b);
+         colors[n1].green =1023+ n*(int)(1024.*g);
+         
+         if (!(XAllocColor (dpy, cmap, &colors[n1]))) {
+           (void) fprintf (stderr, "Error:  Cannot allocate colors\n");
+           exit (1);
+         }
+         
+         n1++;
+       }
+    }
+}
+
+/* ----------------WINDOW-------------------*/
+
+static void
+initialize (void)
+{
+  XGCValues *xgc;
+  XGCValues *xorgc;
+  XGCValues *xandgc;
+
+  XGetWindowAttributes (dpy, win, &xgwa);
+  scrnWidth = xgwa.width;
+  scrnHeight = xgwa.height;
+
+  cycle = 60.0 / get_float_resource ("cycle", "Float");
+  movef = get_float_resource ("move", "Float") / 2;
+  wobber *= get_float_resource ("wobble", "Float");
+
+  {
+    double magfac = get_float_resource ("mag", "Float");
+    mag *= magfac;
+    fastch=(int)(fastch*magfac);
+  }
+
+  if (get_boolean_resource ("minutes", "Boolean")) {
+    minutes=1; maxk+=60-24;
+  }
+
+  timewait = get_integer_resource ("wait", "Integer");
+  fastch = get_integer_resource ("fast", "Integer");
+  cycl = get_boolean_resource ("colcycle", "Integer");
+  hsvcycl = get_float_resource ("hsvcycle", "Integer");
+
+  {
+    char *s = get_string_resource ("rgb", "RGB");
+    char dummy;
+    if (s && *s)
+      {
+        double rr, gg, bb;
+        if (3 == sscanf (s, "%lf %lf %lf %c", &rr, &gg, &bb, &dummy))
+          r = rr, g = gg, b = bb;
+      }
+    if (s) free (s);
+
+    s = get_string_resource ("hsv", "HSV");
+    if (s && *s)
+      {
+        double hh, ss, vv;
+        if (3 == sscanf (s, "%lf %lf %lf", &hh, &ss, &vv, &dummy)) {
+          hue = hh, sat = ss, val = vv;
+          hsv2rgb(hue,sat,val,&r,&g,&b);
+        }
+      }
+    if (s) free (s);
+  }
+
+  if (fastch>maxfast)
+               fastch=maxfast;
+  
+#ifdef PRTDBX
+  printf("Set options:\ndisplay: '%s'\ngeometry: '%s'\n",display,geometry);
+  printf("move\t%.2f\nwobber\t%.2f\nmag\t%.2f\ncycle\t%.4f\n",
+        movef,wobber,mag/10,cycle);
+  printf("nice\t%i\nfast\t%i\nmarks\t%i\nwait\t%i\n",niced,fastch,maxk,timewait);
+#endif
+  
+  xgc=( XGCValues *) malloc(sizeof(XGCValues) );
+  xorgc=( XGCValues *) malloc(sizeof(XGCValues) );
+  xandgc=( XGCValues *) malloc(sizeof(XGCValues) );
+
+  screen = screen_number (xgwa.screen);
+  
+  planes=xgwa.depth;
+
+  gc = XCreateGC (dpy, win, 0,  xgc);
+  xorgc->function =GXor;
+  orgc = XCreateGC (dpy, win, GCFunction,  xorgc);
+  xandgc->function =GXandInverted;
+  andgc = XCreateGC (dpy, win, GCFunction,  xandgc);
+  
+  buffer = XCreatePixmap (dpy, win, scrnWidth, scrnHeight,
+                         xgwa.depth); 
+  
+#ifdef DEBUG
+  printf("Time 3D drawing ");
+#ifdef FASTDRAW
+#      ifdef FASTCOPY
+  puts("fast by Pixmap copy");
+#      else
+  puts("fast by XImage copy");
+#      endif
+#else
+  puts("slow");
+#endif
+#endif /* DEBUG */
+  
+#ifdef FASTCOPY
+  fastcircles = XCreatePixmap (dpy, win, fastcw, fastch+1, xgwa.depth);
+  fastmask    = XCreatePixmap (dpy, win, fastcw, fastch+1, xgwa.depth);
+#endif
+  
+  setink(BlackPixel (dpy, screen));
+  XFillRectangle (dpy, buffer     , gc, 0, 0, scrnWidth, scrnHeight);  
+  
+#ifdef FASTCOPY
+  
+  setink(0);
+  XFillRectangle (dpy, fastcircles, gc, 0, 0, fastcw, fastch+1);
+  XFillRectangle (dpy, fastmask   , gc, 0, 0, fastcw, fastch+1);
+  
+#endif
+}
+
+static void fill_kugel(int i, Pixmap buf, int setcol);
+
+
+/*------------------------------------------------------------------*/
+static void 
+init_kugel(void)
+{
+  
+#ifdef FASTDRAW
+  int i;
+
+  for(i=0; i<fastch; i++)
+    {
+#      ifdef FASTCOPY
+      kugeln[i].r1=-((double) i)/2 -1;
+      kugeln[i].x1=sum1ton(i);
+      kugeln[i].y1=((double) i)/2 +1;
+      
+      fill_kugel(i,fastcircles,1);
+      setink((1<<MIN(24,xgwa.depth))-1);
+      fill_kugel(i,fastmask,0);
+#      else
+      kugeln[i].r1=-((double) i)/2 -1;
+      kugeln[i].x1=kugeln[i].y1=((double) i)/2 +1;
+      
+      fill_kugel(i,buffer,1);
+      fastcircles[i]=XGetImage(dpy,buffer,0,0,i+2,i+2,(1<<planes)-1,ZPixmap);
+      
+      setink((1<<MIN(24,xgwa.depth))-1);
+      fill_kugel(i,buffer,0);
+      fastmask[i]=XGetImage(dpy,buffer,0,0,i+2,i+2,(1<<planes)-1,ZPixmap);
+      
+      setink(0);
+      XFillRectangle (dpy, buffer     , gc, 0, 0, scrnWidth, scrnHeight);      
+#      endif
+    }
+  fastdraw=1;
+#endif
+}
+
+/* Zeiger zeichnen */
+
+static void
+zeiger(double dist,double rad, double z, double sec, int *q)
+{
+  int i,n;
+  double gratio=sqrt(2.0/(1.0+sqrt(5.0)));
+  
+  n = *q;
+  
+  for(i=0;i<3;i++)
+    {
+      kugeln[n].x=dist*cos(sec);
+      kugeln[n].y=-dist*sin(sec);
+      kugeln[n].z=z;
+      kugeln[n].r=rad;
+      n++;
+
+      dist += rad;
+      rad = rad*gratio;
+    }
+  *q = n;
+}
+
+/*-----------------------------------------------------------------*
+ *                           Uhr zeichnen                          *
+ *-----------------------------------------------------------------*/
+
+static void
+manipulate(double k)
+{
+  double i,l,/*xs,*/ys,zs,mod;
+  double /*persec,*/sec,min,hour;
+  int n;
+  
+  sec=TWOPI*modf(k/60,&mod);
+  min=TWOPI*modf(k/3600,&mod);
+  hour=TWOPI*modf(k/43200,&mod);
+  
+  l=TWOPI*modf(k/300,&mod);
+  i=0.0;
+  for (n=0;n<kmax;n++)
+    {
+      
+      kugeln[n].x=4.0*sin(i);
+      kugeln[n].y=4.0*cos(i);
+      kugeln[n].z=wobber* /* (sin(floor(2+2*l/(PI))*i)*sin(2*l)); */
+       cos((i-sec)*floor(2+5*l/(PI)))*sin(5*l);
+      if(minutes)
+       {
+         kugeln[n].r=/* (1.0+0.3*cos(floor(2+2*l/(PI))*i)*sin(2*l))* */
+           ((n % 5!=0) ? 0.3 : 0.6)*
+             ((n % 15 ==0) ? 1.25 : .75);
+       }
+      else
+       {
+         kugeln[n].r=/* (1.0+0.3*cos(floor(2+2*l/(PI))*i)*sin(2*l))* */
+           ((n & 1) ? 0.5 : 1.0)*
+             ((n % 6==0) ? 1.25 : .75);
+       }
+      i+=TWOPI/kmax;
+    }
+
+  kugeln[n].x=0.0;
+  kugeln[n].y=0.0;
+  kugeln[n].z=0.0;
+  kugeln[n].r=2.0+cos(TWOPI*modf(k,&mod))/2;
+  n++;
+  
+  zeiger(2.0,0.75,-2.0,sec,&n);
+  zeiger(1.0,1.0,-1.5,min,&n);
+  zeiger(0.0,1.5,-1.0,hour,&n);
+  
+  for(n=0;n<maxk;n++)
+    {
+      ys=kugeln[n].y*cos(movef*sin(cycle*sec))+
+       kugeln[n].z*sin(movef*sin(cycle*sec));
+      zs=-kugeln[n].y*sin(movef*sin(cycle*sec))+
+       kugeln[n].z*cos(movef*sin(cycle*sec));
+      kugeln[n].y=ys;
+      kugeln[n].z=zs;
+    }
+}
+/*------------------------------------------------------------------*/
+static void
+t3d_sort(int l, int r)
+{
+  int i,j;
+  kugeldat ex;
+  double x;
+  
+  i=l;j=r;
+  x=kugeln[(l+r)/2].d;
+  while(1)
+    {
+      while(kugeln[i].d>x) i++;
+      while(x>kugeln[j].d) j--;
+      if (i<=j)
+       {
+         ex=kugeln[i];kugeln[i]=kugeln[j];kugeln[j]=ex;
+         i++;j--;
+       }
+      if (i>j) break;
+    }
+  if (l<j) t3d_sort(l,j);
+  if (i<r) t3d_sort (i,r);
+}
+
+/*------------------------------------------------------------------*/
+static void
+fill_kugel(int i, Pixmap buf, int setcol)
+{
+  double ra;
+  int m,col,inc=1,inr=3,d;
+  d=(int)((abs(kugeln[i].r1)*2));
+  if (d==0) d=1;
+  
+#ifdef FASTDRAW
+  if(fastdraw && d<fastch)
+    {
+#      ifdef FASTCOPY
+      XCopyArea(dpy, fastmask, buf, andgc, sum1ton(d)-(d+1)/2, 1,d,d,
+               (int)(kugeln[i].x1)-d/2, (int)(kugeln[i].y1)-d/2);
+      XCopyArea(dpy, fastcircles, buf, orgc, sum1ton(d)-(d+1)/2, 1,d,d,
+               (int)(kugeln[i].x1)-d/2, (int)(kugeln[i].y1)-d/2);
+#      else
+      XPutImage(dpy, buf, andgc, fastmask[d-1], 0, 0,
+               (int)(kugeln[i].x1)-d/2, (int)(kugeln[i].y1)-d/2, d, d);
+      XPutImage(dpy, buf, orgc, fastcircles[d-1], 0, 0,
+               (int)(kugeln[i].x1)-d/2, (int)(kugeln[i].y1)-d/2, d, d);
+#      endif
+       }
+  else
+#endif
+    {
+      if(abs(kugeln[i].r1)<6.0) inr=9;
+      
+      for (m=0;m<=28;m+=inr)
+       {
+         ra=kugeln[i].r1*sqrt(1-m*m/(28.0*28.0));
+#ifdef PRTDBX
+         printf("Radius: %f\n",ra);
+#endif
+         if(-ra< 3.0) inc=14;
+         else if(-ra< 6.0) inc=8;
+         else if(-ra<20.0) inc=4;
+         else if(-ra<40.0) inc=2;
+         if(setcol)
+           {
+             if (m==27) col=33;
+             else
+               col=(int)(m);
+             if (col>33) col=33;       col/=3;
+             setink(colors[col].pixel);
+           }
+
+#ifdef USE_POLYGON
+          {
+            int n, nr;
+         for (n=0,nr=0;n<=sines-1;n+=inc,nr++)
+           {
+             track[nr].x=kugeln[i].x1+(int)(ra*sinus[n])+(kugeln[i].r1-ra)/2;
+             track[nr].y=kugeln[i].y1+(int)(ra*cosinus[n])+(kugeln[i].r1-ra)/2;
+           }
+         XFillPolygon(dpy,buf,gc,track,nr,Convex,CoordModeOrigin);
+          }
+#else /* Use XFillArc */
+         XFillArc(dpy, buf, gc,
+                  (int)(kugeln[i].x1+(kugeln[i].r1+ra)/2),
+                  (int)(kugeln[i].y1+(kugeln[i].r1+ra)/2),
+                  (int)-(2*ra+1), (int)-(2*ra+1), 0, 360*64);
+#endif
+       }
+    }
+}
+
+/*------------------------------------------------------------------*/
+
+static void
+init_3d(void)
+{
+  double i;
+  int n=0;
+  
+  a[0]=0.0;
+  a[1]=0.0;
+  a[2]=-10.0;
+  
+  x[0]=10.0;
+  x[1]=0.0;
+  x[2]=0.0;
+  
+  y[0]=0.0;
+  y[1]=10.0;
+  y[2]=0.0;
+  
+  
+  zoom=-10.0;
+  speed=.0;
+  
+  for (i=0.0;n<sines;i+=TWOPI/sines,n++)
+    {
+      sinus[n]=sin(i);
+      cosinus[n]=cos(i);
+    }
+}
+/*------------------------------------------------------------------*/
+
+
+static void
+vektorprodukt(double feld1[], double feld2[], double feld3[])
+{
+  feld3[0]=feld1[1]*feld2[2]-feld1[2]*feld2[1];
+  feld3[1]=feld1[2]*feld2[0]-feld1[0]*feld2[2];
+  feld3[2]=feld1[0]*feld2[1]-feld1[1]*feld2[0];
+}
+/*------------------------------------------------------------------*/
+static void
+turn(double feld1[], double feld2[], double winkel)
+{
+  double temp[3];
+  double s,ca,sa,sx1,sx2,sx3;
+  
+  vektorprodukt(feld1,feld2,temp);
+  
+  s=feld1[0]*feld2[0]+feld1[1]*feld2[1]+feld1[2]*feld2[2];
+  
+  sx1=s*feld2[0];
+  sx2=s*feld2[1];
+  sx3=s*feld2[2];
+  sa=sin(winkel);ca=cos(winkel);
+  feld1[0]=ca*(feld1[0]-sx1)+sa*temp[0]+sx1;
+  feld1[1]=ca*(feld1[1]-sx2)+sa*temp[1]+sx2;
+  feld1[2]=ca*(feld1[2]-sx3)+sa*temp[2]+sx3;
+}
+/*------------------------------------------------------------------*/
+
+/* 1: Blickrichtung v;3:Ebenenmittelpunkt m 
+   double feld1[],feld3[]; */
+static void 
+viewpoint(void)
+{
+  am[0]=-zoom*v[0];
+  am[1]=-zoom*v[1];
+  am[2]=-zoom*v[2];
+  
+  zaehler=norm*norm*zoom;
+}
+/*------------------------------------------------------------------*/
+static void 
+projektion(void)
+{
+  double c1[3],c2[3],k[3],x1,y1;
+  double cno,cnorm/*,magnit*/;
+  int i;
+  
+  for (i=0;i<maxk;i++)
+    {
+      c1[0]=kugeln[i].x-a[0];
+      c1[1]=kugeln[i].y-a[1];
+      c1[2]=kugeln[i].z-a[2];
+      cnorm=sqrt(c1[0]*c1[0]+c1[1]*c1[1]+c1[2]*c1[2]);
+      
+      c2[0]=c1[0];
+      c2[1]=c1[1];
+      c2[2]=c1[2];
+      
+      cno=c2[0]*v[0]+c2[1]*v[1]+c2[2]*v[2];
+      kugeln[i].d=cnorm;
+      if (cno<0) kugeln[i].d=-20.0;
+      
+      
+      kugeln[i].r1=(mag*zoom*kugeln[i].r/cnorm);
+      
+      c2[0]=v[0]/cno;
+      c2[1]=v[1]/cno;
+      c2[2]=v[2]/cno;
+      
+      vektorprodukt(c2,c1,k);
+
+      
+      x1=(startx+(x[0]*k[0]+x[1]*k[1]+x[2]*k[2])*mag);
+      y1=(starty-(y[0]*k[0]+y[1]*k[1]+y[2]*k[2])*mag);
+      if(   (x1>-2000.0)
+        && (x1<scrnWidth+2000.0)
+        && (y1>-2000.0)
+        && (y1<scrnHeight+2000.0))
+       {
+         kugeln[i].x1=(int)x1;
+         kugeln[i].y1=(int)y1;
+       }
+      else
+       {
+         kugeln[i].x1=0;
+         kugeln[i].y1=0;
+         kugeln[i].d=-20.0;
+       }
+    }
+}
+
+/*---------- event-handler ----------------*/
+static void
+event_handler(void)
+{
+  while (XEventsQueued (dpy, QueuedAfterReading))
+    {
+      XEvent event;
+      
+      XNextEvent (dpy, &event);
+      switch (event.type)
+       {
+       case ConfigureNotify:
+         if (event.xconfigure.width != scrnWidth ||
+             event.xconfigure.height != scrnHeight)
+           {
+             XFreePixmap (dpy, buffer); 
+             scrnWidth = event.xconfigure.width;
+             scrnHeight = event.xconfigure.height;
+             buffer = XCreatePixmap (dpy, win, scrnWidth, scrnHeight,
+                                      xgwa.depth);
+             
+             startx=scrnWidth/2;
+             starty=scrnHeight/2;
+             scrnH2=startx;
+             scrnW2=starty;
+           }; break;
+       case KeyPress:
+         {
+           KeySym kpr=XKeycodeToKeysym(dpy,event.xkey.keycode,0);
+           if (kpr=='s') /* s */
+             vspeed=0.5;
+           if (kpr=='a')
+             vspeed=-0.3;
+           if (kpr=='q')
+             {
+               speed=0;vspeed=0;
+             }
+           /*  printf("%i\n",event.xkey.keycode);*/
+           if (kpr=='z') mag*=1.02;
+           if (kpr=='x') mag/=1.02;
+         }
+       default:
+         break;
+       }
+    }
+  /*nap(40);-Ersatz*/ 
+  {
+    struct timeval timeout;
+    timeout.tv_sec=timewait/1000000;
+    timeout.tv_usec=timewait%1000000;
+    (void)select(0,0,0,0,&timeout);
+  }
+}
+
+
+/*-------------------------------------------------*/
+
+char *progclass = "T3D";
+
+char *defaults [] = {
+  ".background:        black",
+  ".foreground:        white",
+  "*move:      0.5",
+  "*wobble:    2.0",
+  "*cycle:     6.0",
+  "*mag:       1",
+  "*minutes:   False",
+  "*timewait:   40000",
+  "*fast:      50",
+  "*ccycle:    False",
+  "*hsvcycle:  0.0",
+  0
+};
+
+XrmOptionDescRec options [] = {
+  { "-move",           ".move",        XrmoptionSepArg, 0 },
+  { "-wobble",         ".wobble",      XrmoptionSepArg, 0 },
+  { "-cycle",          ".cycle",       XrmoptionSepArg, 0 },
+  { "-mag",            ".mag",         XrmoptionSepArg, 0 },
+  { "-minutes",                ".minutes",     XrmoptionSepArg, 0 },
+  { "-timewait",       ".timewait",    XrmoptionSepArg, 0 },
+  { "-fast",           ".fast",        XrmoptionSepArg, 0 },
+  { "-colcycle",       ".colcycle",    XrmoptionSepArg, 0 },
+  { "-hsvcycle",       ".hsvcycle",    XrmoptionSepArg, 0 },
+  { "-rgb",            ".rgb",         XrmoptionSepArg, 0 },
+  { "-hsv",            ".hsv",         XrmoptionSepArg, 0 },
+  { 0, 0, 0, 0 }
+};
+
+
+void
+screenhack (Display *d, Window w)
+{
+  Window junk_win,in_win;
+  
+  int px,py,junk,kb/*,wai*/;
+/*  int act,act1,tc;*/
+  double vnorm;
+  /* double var=0.0; */
+  int color=0/*, dir=1*/;
+  
+  dpy = d;
+  win = w;
+  initialize();
+  
+  initColor(r,g,b);
+  init_3d();
+  zeit=(struct tm *)malloc(sizeof(struct tm));
+  init_kugel();
+  
+  startx=scrnWidth/2;
+  starty=scrnHeight/2;
+  scrnH2=startx;
+  scrnW2=starty;
+  vspeed=0;
+  
+  
+  vektorprodukt(x,y,v);
+  viewpoint(/*m,v*/);
+  
+  setink (BlackPixel (dpy, screen));
+  XFillRectangle (dpy, win, gc, 0, 0, scrnWidth, scrnHeight);
+  XQueryPointer (dpy, win, &junk_win, &junk_win, &junk, &junk,
+                &px, &py, &kb);
+  
+  for (;;)
+    {  double dtime;
+       
+       /*--------------- Zeichenteil --------------*/
+
+       event_handler();
+       
+       vektorprodukt(x,y,v);
+       
+       vnorm=sqrt(v[0]*v[0]+v[1]*v[1]+v[2]*v[2]);
+       v[0]=v[0]*norm/vnorm;
+       v[1]=v[1]*norm/vnorm;
+       v[2]=v[2]*norm/vnorm;
+       vnorm=sqrt(x[0]*x[0]+x[1]*x[1]+x[2]*x[2]);
+       x[0]=x[0]*norm/vnorm;
+       x[1]=x[1]*norm/vnorm;
+       x[2]=x[2]*norm/vnorm;
+       vnorm=sqrt(y[0]*y[0]+y[1]*y[1]+y[2]*y[2]);
+       y[0]=y[0]*norm/vnorm;
+       y[1]=y[1]*norm/vnorm;
+       y[2]=y[2]*norm/vnorm;
+       
+       projektion();
+       t3d_sort (0,maxk-1);
+       
+       dtime=gettime();
+       
+       if(cycl)
+         {
+           color=(int)(64.0*(dtime/60-floor(dtime/60)))-32;
+           
+           if(color<0)
+             color=-color;
+           
+           setink(colors[color/3].pixel);
+         }
+       else
+         setink(BlackPixel (dpy, screen));
+       
+       XFillRectangle(dpy,buffer,gc,0,0,scrnWidth,scrnHeight);
+       
+       {
+         int i;
+         
+         manipulate(dtime);
+         
+         for (i=0;i<maxk;i++)
+           {
+             if (kugeln[i].d>0.0)
+               fill_kugel(i,buffer,1);
+           }
+       }
+
+       XSync(dpy,0);
+       
+       /* manipulate(gettime());
+          var+=PI/500;
+          if (var>=TWOPI) var=PI/500; */
+       
+       /*event_handler();*/
+       
+       if(hsvcycl!=0.0)
+         {
+           dtime=hsvcycl*dtime/10.0+hue/360.0;
+           dtime=360*(dtime-floor(dtime));
+           
+           hsv2rgb(dtime,sat,val,&r,&g,&b);
+           changeColor(r,g,b);
+         }
+
+       XCopyArea (dpy, buffer, win, gc, 0, 0, scrnWidth, scrnHeight, 0, 0);
+       
+       
+       /*-------------------------------------------------*/
+       XSync(dpy,0);
+       
+       event_handler();
+       
+       (void)(XQueryPointer (dpy, win, &junk_win, &in_win, &junk, &junk,
+                             &px, &py, &kb));
+       
+       if ((px>0)&&(px<scrnWidth)&&(py>0)&&(py<scrnHeight) )           
+         {
+           if ((px !=startx)&&(kb&Button2Mask))
+             {
+               /* printf("y=(%f,%f,%f)",y[0],y[1],y[2]);*/
+               turn(y,x,((double)(px-startx))/(8000*mag));
+               /* printf("->(%f,%f,%f)\n",y[0],y[1],y[2]);*/
+             }
+           if ((py !=starty)&&(kb&Button2Mask)) 
+             {
+               /* printf("x=(%f,%f,%f)",x[0],x[1],x[2]);*/
+               turn(x,y,((double)(py-starty))/(-8000*mag));
+               /* printf("->(%f,%f,%f)\n",x[0],x[1],x[2]);*/
+             }
+           if ((kb&Button1Mask)) 
+             {
+               if (vturn==0.0) vturn=.005; else if (vturn<2)  vturn+=.01;
+               turn(x,v,.002*vturn);
+               turn(y,v,.002*vturn); 
+             }
+           if ((kb&Button3Mask)) 
+             {
+               if (vturn==0.0) vturn=.005; else if (vturn<2) vturn+=.01;
+               turn(x,v,-.002*vturn);
+               turn(y,v,-.002*vturn);
+             }
+         }
+       if (!(kb&Button1Mask)&&!(kb&Button3Mask)) 
+         vturn=0;
+       
+       speed=speed+speed*vspeed;
+       if ((speed<0.0000001) &&(vspeed>0.000001)) speed=0.000001;
+       vspeed=.1*vspeed;
+       if (speed>0.01) speed=.01;
+       a[0]=a[0]+speed*v[0];
+       a[1]=a[1]+speed*v[1];
+       a[2]=a[2]+speed*v[2];
+      }
+}
diff --git a/hacks/t3d.man b/hacks/t3d.man
new file mode 100644 (file)
index 0000000..c7755a0
--- /dev/null
@@ -0,0 +1,140 @@
+.TH t3d 1 "Version 1.1" "Time 3D"
+.SH NAME
+t3d \- clock using flying balls to display the time
+.SH SYNOPSIS
+t3d [ \f2 options\f1 ]...
+.SH DESCRIPTION
+.PP
+Time 3D is a clock. It uses flying balls to display the time. This
+balls move and wobble around to give you the impression your
+graphic workstation with its many XStones is doing something.
+.PP
+t3d uses mouse and keyboard to let you fly through the balls. Hit
+.B S
+to speed up, 
+.B A
+to slow down,
+.B Z
+to zoom in and
+.B X
+to zoom out.
+Use the
+.B left mouse button
+to rotate to the left and the
+.B right mouse button
+to rotate the view to the right. Use the
+.B middle mouse button
+to change the optical axis and the moving direction.
+.B Q
+will stop you.
+.PP
+.SH OPTIONS
+.TP
+.BI "-display " "host:dpy"
+Specifys the display in the usual way.
+.TP
+.BI "-geometry " "WxH+X+Y"
+Sets the size and location of the t3d window.
+.TP
+.BI "-move " "factor"
+Modifies the direction move of t3d. The clock looks 30 degrees*
+.I factor
+to the left and to the right periodically.
+.TP
+.BI "-wobble " "factor"
+Modifies the wobbling (sounds nice :-) of t3d by multiplying the
+default deformation of the clock with
+.I factor.
+.TP
+.BI "-nice " "factor"
+Renices t3d by
+.I factor
+because t3d uses your process time. The default renice factor is 20, so
+you can't do anything wrong with not renicing t3d. If you want more speed,
+you should set nice to a smaller value.
+.TP
+.B -minutes
+Shows one small ball for every minute, instead of one for every 2.5 minutes.
+.TP
+.BI "-mag " "factor"
+Changes the magnification of t3d. By default, t3d uses a 200x200 window. A
+.I factor
+of 2 means, it will use a 400x400 window.
+.TP
+.BI "-cycle " "period"
+Sets the moving cycle to
+.I period
+seconds. By default, this value is 10 seconds.
+.TP
+.BI "-wait " "microsec"
+Inserts a wait after drawing one view of the clock. By default, t3d waits
+40 ms after each drawing. This helps you to keep the performance loss
+small.
+.TP
+.BI "-fast " "precalc_radius"
+t3d uses bitmap copy to draw precalculated balls. You can specify the radius
+in pixels up to which t3d should precalculate balls. t3d will set a useful
+range by itself using the magnification when it is started.
+.TP
+.B -colcycle
+Draws cyclic the color scale used for the balls in the background instead
+of the normal black.
+.TP
+.BI "-rgb " "red green blue"
+Selects the color in RGB color space of the lightning spot on the balls.
+All the other colors used for balls or
+.B -colcycle
+are less intensive colors of the same hue and saturation. All values
+in range of 0 to 1.
+.TP
+.BI "-hsv " "hue saturation value"
+Selects the color in HSV color space.
+.I hue
+is in degrees from 0 to 360, all other values in range from 0 to 1. It gives
+nice but rather unpredictable results, if you use a saturation of e.g. 2.
+Try it at your own risk.
+.TP
+.BI "-hsvcycle " "speed"
+Rotates the hue axis every 10 seconds*
+.I speed.
+.TP
+.B -help
+Prints a short usage message.
+
+.PP
+.SH AUTHOR
+.PP
+Bernd Paysan
+
+Email: bernd.paysan@gmx.de
+
+Hacked on by jwz@jwz.org for xscreensaver.
+
+.SH ACKNOWLEDGEMENT
+.PP
+Acknowledgement to Georg Acher, who wrote the initial program displaying
+balls.
+
+.SH COPYING
+.PP
+Copy, modify, and distribute T3D either under GPL version 2 or newer, or
+under the standard MIT/X license notice.
+
+.SH DISCLAIMER
+.PP
+T3D is not related to T3D(tm), the massive parallel Alpha--based
+supercomputer from Cray Research. T3D's name was invented in 1991,
+years before the project at Cray Research started. There is no
+relation from T3D to Cray's T3D, even the balls surrounding T3D on
+some posters weren't an inspiration for T3D. I don't know anything
+about the other way round.
+
+The programming style of T3D isn't intented as example of good style,
+but as example of how a fast prototyped demo may look like. T3D wasn't
+created to be useful, it was created to be nice.
+
+.SH KNOWN BUGS
+.PP
+There are no known bugs in T3D. Maybe there are bugs in X. Slight
+changes in the T3D sources are known to show these bugs, e.g. if
+you remove the (int) casting at the XFillArc x,y,w,h-coordinates...
index 4274aa63e9b6f35b371b765c1cff22ebf0459736..d39119abd38e40968a13ed1d85d8ce8161e3ea0d 100644 (file)
@@ -74,7 +74,8 @@ ERROR!  Sorry, xlockmore.h requires ANSI C (gcc, for example.)
 #define MI_BATCHCOUNT(MI)      ((MI)->batchcount)
 #define MI_SIZE(MI)            ((MI)->size)
 #define MI_IS_DRAWN(MI)                ((MI)->is_drawn)
-#define MI_IS_DEBUG(MI)                (False)
+#define MI_IS_DRAWN(MI)                ((MI)->is_drawn)
+#define MI_NCOLORS(MI)         ((MI)->npixels)
 #define MI_NAME(MI)            (progname)
 
 #define MI_WIDTH(MI)           (MI_WIN_WIDTH((MI)))
@@ -87,6 +88,8 @@ ERROR!  Sorry, xlockmore.h requires ANSI C (gcc, for example.)
 #define MI_WHITE_PIXEL(MI)     (MI_WIN_WHITE_PIXEL(MI))
 #define MI_IS_FULLRANDOM(MI)   (MI_WIN_IS_FULLRANDOM(MI))
 #define MI_IS_VERBOSE(MI)      (MI_WIN_IS_VERBOSE(MI))
+#define MI_IS_INSTALL(MI)      (MI_WIN_IS_INSTALL(MI))
+#define MI_IS_DEBUG(MI)                (False)
 
 #define MI_CLEARWINDOW(mi) XClearWindow(MI_DISPLAY(mi), MI_WINDOW(mi))
 
index b32920af5806c4db7f13fe543d99e966c4e9b686..506bb2739d5f2407b989fef7d05d3d12bf1d226e 100644 (file)
--- a/setup.com
+++ b/setup.com
@@ -15,6 +15,7 @@ $ crystal     :== $'mydir'crystal
 $ cynosure     :== $'mydir'cynosure
 $ decayscreen  :== $'mydir'decayscreen
 $ deco         :== $'mydir'deco
+$ demon                :== $'mydir'demon
 $ discrete     :== $'mydir'discrete
 $ distort      :== $'mydir'distort
 $ drift                :== $'mydir'drift
@@ -44,6 +45,7 @@ $ lightning   :== $'mydir'lightning
 $ lisa         :== $'mydir'lisa
 $ lissie       :== $'mydir'lissie
 $ lmorph       :== $'mydir'lmorph
+$ loop         :== $'mydir'loop
 $ maze         :== $'mydir'maze
 $ moire                :== $'mydir'moire
 $ moire2       :== $'mydir'moire2
@@ -67,6 +69,7 @@ $ spiral      :== $'mydir'spiral
 $ starfish     :== $'mydir'starfish
 $ strange      :== $'mydir'strange
 $ swirl                :== $'mydir'swirl
+$ t3d          :== $'mydir't3d
 $ triangle     :== $'mydir'triangle
 $ truchet      :== $'mydir'truchet
 $ vines                :== $'mydir'vines
index 0a45260d36b83e3b8c3eb8ade97b1fa24c8af0d9..178bf87c687ccfc7dbe18c5ec6ba3834ea4221a0 100644 (file)
@@ -91,6 +91,10 @@ DEPEND_FLAGS = @DEPEND_FLAGS@
 DEPEND_DEFINES = @DEPEND_DEFINES@
 
 SHELL          = /bin/sh
+INSTALL                = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_DATA   = @INSTALL_DATA@
+INSTALL_DIRS   = @INSTALL_DIRS@
 
 X_CFLAGS       = @X_CFLAGS@
 
index 0ef8295f2f24a9ef9e115c00be70db9b2886a298..571f638e3784ae400598b80e1ce73449a1031dea 100644 (file)
@@ -1,2 +1,2 @@
 static const char screensaver_id[] =
-       "@(#)xscreensaver 3.06 (21-Nov-98), by Jamie Zawinski (jwz@jwz.org)";
+       "@(#)xscreensaver 3.07 (02-Jan-99), by Jamie Zawinski (jwz@jwz.org)";
index a77e34bfe7ddade1763bc4bea2fe88d9ef600a4c..abea226dc4c3fb0c5d0d7ddb0ee8b337467bd509 100644 (file)
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 1997 by Jamie Zawinski <jwz@jwz.org>
+/* xscreensaver, Copyright (c) 1997, 1998 by Jamie Zawinski <jwz@jwz.org>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
@@ -19,6 +19,7 @@
 #undef srand
 #undef srand48
 #undef frand
+#undef RAND_MAX
 
 #ifdef VMS
 # include "vms-gtod.h"
@@ -26,6 +27,7 @@
 
 #define random()   ya_random()
 #define srandom(i) ya_rand_init(0)
+#define RAND_MAX   0x7FFFFFFF
 
 extern unsigned int ya_random (void);
 extern void ya_rand_init (unsigned int);
index babdbccb827e1876607a8d184e15322ede64c7ab..6d172881df2bfd7957eebde2e3da66709e52d03b 100644 (file)
@@ -1,7 +1,7 @@
 Begin3
 Title:          xscreensaver
-Version:        3.06
-Entered-date:   22NOV98
+Version:        3.07
+Entered-date:   04JAN99
 Description:    A modular screen saver and locker for the X Window System.
                 Highly customizable: allows the use of any program that
                 can draw on the root window as a display mode.
@@ -10,16 +10,16 @@ Keywords:       screen saver, screen lock, lock, xlock, X11
 Author:         jwz@jwz.org (Jamie Zawinski)
 Maintained-by:  jwz@jwz.org (Jamie Zawinski)
 Primary-site:   http://www.jwz.org/xscreensaver/
-                981K xscreensaver-3.06.tar.gz
-                26K  xscreensaver.README
+                1010K xscreensaver-3.07.tar.gz
+                27K  xscreensaver.README
                 1K   xscreensaver.lsm
 Alternate-site: sunsite.unc.edu /pub/Linux/X11/screensavers/
-                981K xscreensaver-3.06.tar.gz
-                26K  xscreensaver.README
+                1010K xscreensaver-3.07.tar.gz
+                27K  xscreensaver.README
                 1K   xscreensaver.lsm
 Alternate-site: ftp.x.org /contrib/applications/
-                981K xscreensaver-3.06.tar.gz
-                26K  xscreensaver.README
+                1010K xscreensaver-3.07.tar.gz
+                27K  xscreensaver.README
                 1K   xscreensaver.lsm
 Platforms:      Linux, Irix, SunOS, Solaris, HPUX, AIX, FreeBSD, NetBSD,
                 BSDI, SCO, OSF1, Ultrix, VMS.
index 89dd6d9191b9a9abbbc948df540397619fe052d3..bf5b664952ba9b0905b77bba63644e1ed67f6a74 100644 (file)
@@ -1,7 +1,7 @@
 Name: xscreensaver
 Summary: X screen saver and locker
 Vendor: Jamie Zawinski <jwz@jwz.org>
-Version: 3.06
+Version: 3.07
 Release: 1
 URL: http://www.jwz.org/xscreensaver/
 Source: xscreensaver-%{version}.tar.gz
@@ -17,18 +17,22 @@ More than 80 display modes are included in this package.
 
 %prep
 %setup -q
-
 %build
-./configure --prefix=/usr/X11R6
+
+./configure --prefix=/usr/X11R6 \
+     --enable-subdir=/usr/X11R6/lib/xscreensaver
 make
 
 %install
+
 mkdir -p $RPM_BUILD_ROOT/usr/X11R6/bin
+mkdir -p $RPM_BUILD_ROOT/usr/X11R6/lib/xscreensaver
 mkdir -p $RPM_BUILD_ROOT/usr/X11R6/man/man1
 mkdir -p $RPM_BUILD_ROOT/etc/X11/wmconfig
 mkdir -p $RPM_BUILD_ROOT/etc/pam.d
 make  prefix=$RPM_BUILD_ROOT/usr/X11R6 \
       AD_DIR=$RPM_BUILD_ROOT/usr/X11R6/lib/X11/app-defaults \
+     HACKDIR=$RPM_BUILD_ROOT/usr/X11R6/lib/xscreensaver \
      PAM_DIR=$RPM_BUILD_ROOT/etc/pam.d \
      install-strip
 
@@ -56,7 +60,8 @@ rm -rf $RPM_BUILD_ROOT
 %files
 %defattr(-,root,root)
 /usr/X11R6/bin/*
-/usr/X11R6/lib/X11/app-defaults/*
+/usr/X11R6/lib/xscreensaver/*
+%config /usr/X11R6/lib/X11/app-defaults/*
 /usr/X11R6/man/man1/*
 %config(missingok) /etc/X11/wmconfig/*
 %config(missingok) /etc/pam.d/*