are being run as screensavers don't need to have any special knowledge
about what it means to be a screensaver.
-The XIDLE or MIT-SCREEN-SAVER server extensions will be used if you have
-them (win win.)
+The XIDLE or MIT-SCREEN-SAVER server extensions will be used if you have them.
Unfortunately, locking doesn't work if you don't have Motif.
things. I snarfed this code from xnlock.
maze - This is the X maze demo modified to take a -root option
so that it works with xscreensaver.
+ lmorph - morphing line drawings.
All of these will pop up their own window unless given that -root option.
See their man pages for more details.
know of (or write) any other interesting programs that can be used as
screensavers, please let me know!
-This program should be updated to take advantage of the new R6 `screensaver'
-server extension instead of XIdle. I didn't have time to do this before the
-deadline for the R6 contrib tape, but by the time you read this, maybe it's
-done - check a later release.
+The latest version of xscreensaver is always ftpable from ftp.x.org. You can
+also get it from my web page at http://www.netscape.com/people/jwz/.
-The latest version of xscreensaver is on FTP.X.ORG.
-
- -- Jamie Zawinski <jwz@mcom.com>
+ -- Jamie Zawinski <jwz@netscape.com>
\f
+Changes since 1.25: Added `lmorph' hack.
+ Added viscosity and mouse-control to attraction.
+ Fixed possible bad color choices in qix and attraction.
+ Added ramp-mode to halo.
+ Added a new RNG, which is faster and more portable
+ than using the RNG in libc.
+ Made locking work on SCO.
+ Various other minor tweaks that I don't remember.
Changes since 1.24: Made it capture the stdout/stderr of its subprocesses
and present them on the screensaver window itself.
Made demo mode work correctly with non-default visuals
* This file is included by the various Imakefiles.
*/
-/* Uncomment the following line if you have the MIT-SCREEN-SAVER extension
- * installed. This extension resides in .../contrib/extensions/screensaver/
- * on the X11R6 contrib tape. (Turning on this flag lets XScreenSaver work
- * better with servers which support this extension; but it will still work
- * with servers which do not suport this extension, so it's a good idea to
- * compile in support for it if you can.)
- */
-/* #define HAVE_SAVER_EXTENSION */
-
/* Uncomment the following line if you have the XIDLE extension installed.
* This extension resides in .../contrib/extensions/xidle/ on the X11R5
* contrib tape. (Turning on this flag lets XScreenSaver work better with
*/
/* #define HAVE_XIDLE_EXTENSION */
+/* Uncomment the following line if you have the MIT-SCREEN-SAVER extension
+ * installed. This extension resides in .../contrib/extensions/screensaver/
+ * on the X11R6 contrib tape.
+ *
+ * This extension does basically the same thing that the XIDLE extension does,
+ * but there are two things wrong with it: first, because of the way the
+ * extension was designed, the `fade' option to XScreenSaver will be uglier:
+ * just before the screen fades out, there will be an unattractive flicker to
+ * black, because this extension blanks the screen *before* telling us that it
+ * is time to do so. Second, this extension is known to be buggy; on the
+ * systems I use, it works, but some people have reported X server crashes as
+ * a result of using it. XScreenSaver uses this extension rather
+ * conservatively, because when I tried to use any of its more complicated
+ * features, I could get it to crash the server at the drop of a hat.
+ *
+ * I wish someone would port the XIDLE extension to R6. Or I wish someone
+ * would make the MIT-SCREEN-SAVER extension not be such a piece of junk.
+ *
+ * Note that the SGI X server also has an extension called SCREEN_SAVER.
+ * That is a completely different extension, and XScreenSaver contains no
+ * support for it (though it probably wouldn't be hard.)
+ */
+/* #define HAVE_SAVER_EXTENSION */
+
/* Uncomment the following line if you have the XPM library installed.
* Some of the demos can make use of this if it is available.
*/
#include "../config.h"
+/* #### If anyone ever finishes the Athena locking code, remove this. */
#if defined(NO_MOTIF) && !defined(NO_LOCKING)
# define NO_LOCKING
#endif
DEFINES = SETUID_DEF XIDLE_DEF SAVER_DEF MOTIF_DEF LOCKING_DEF SHADOW_DEF R5ISMS
SAVERLIBS = $(XMULIB) $(XTOOLLIB) $(EXTENSIONLIB) $(XLIB) -lm
COMMLIBS = $(XLIB) -lm
- UTIL_SRCS = $(UTILS)/resources.c $(UTILS)/fade.c $(UTILS)/usleep.c $(UTILS)/visual.c
- UTIL_OBJS = $(UTILS)/resources.o $(UTILS)/fade.o $(UTILS)/usleep.o $(UTILS)/visual.o
- DBOX_SRCS = dialogs.c demo.c lock.c
- DBOX_OBJS = dialogs.o demo.o lock.o
+ UTIL_SRCS = $(UTILS)/resources.c $(UTILS)/fade.c $(UTILS)/visual.c $(UTILS)/usleep.c $(UTILS)/yarandom.c
+ UTIL_OBJS = $(UTILS)/resources.o $(UTILS)/fade.o $(UTILS)/visual.o $(UTILS)/usleep.o $(UTILS)/yarandom.o
+ DBOX_SRCS = dialogs.c demo.c
+ DBOX_OBJS = dialogs.o demo.o
+ LOCK_SRCS = lock.c
+ LOCK_OBJS = lock.o
SAVERSRCS = xscreensaver.c timers.c subprocs.c windows.c stderr.c
SAVEROBJS = xscreensaver.o timers.o subprocs.o windows.o stderr.o
- SRCS1 = $(SAVERSRCS) MOTIF_SRC $(UTIL_SRCS)
- OBJS1 = $(SAVEROBJS) MOTIF_OBJ $(UTIL_OBJS)
+ SRCS1 = $(SAVERSRCS) MOTIF_SRC $(LOCK_SRCS) $(UTIL_SRCS)
+ OBJS1 = $(SAVEROBJS) MOTIF_OBJ $(LOCK_OBJS) $(UTIL_OBJS)
COMMSRCS = xscreensaver-command.c
COMMOBJS = xscreensaver-command.o
SRCS2 = $(COMMSRCS)
OBJS2 = $(COMMOBJS)
MEN = xscreensaver.man xscreensaver-command.man
- TARFILES = README Imakefile $(SAVERSRCS) $(DBOX_SRCS) $(COMMSRCS) \
- xscreensaver.h XScreenSaver.ad dialogs.xd $(MEN) .gdbinit
+ TARFILES = README Imakefile $(SAVERSRCS) $(DBOX_SRCS) $(LOCK_SRCS) \
+ $(COMMSRCS) xscreensaver.h XScreenSaver.ad dialogs.xd \
+ $(MEN) .gdbinit
#if defined(HPArchitecture) && !defined(NO_LOCKING)
EXTRA_LIBRARIES = -lXhp11 /* for XHPDisableReset() */
#endif
+#if defined(i386ScoArchitecture)
+ SCOLIBS = -lintl -lprot -lx -lcrypt_i
+#endif
+
all:: xscreensaver xscreensaver-command
echo_tarfiles:
#define InstallProgram(p,d) InstallProgramWithFlags(p,d,$(INSTUIDFLAGS))
#endif
-ComplexProgramTarget_1(xscreensaver,MOTIF_LIB $(SAVERLIBS),$(HP_NULL_STR))
+ComplexProgramTarget_1(xscreensaver,MOTIF_LIB $(SAVERLIBS),$(SCOLIBS) $(HP_NULL_STR))
#ifdef INSTALL_SETUID
#undef InstallProgram
clean::
$(RM) XScreenSaver.ad.h
+
+
+#if defined(SparcArchitecture) || defined(SGIArchitecture)
+# undef UsePurify
+# define UsePurify
+#endif
+
+#ifdef UsePurify
+ PURIFY = purify
+ PURIFYOPTIONS =
+
+# undef PurifyProgramTarget
+# define PurifyProgramTarget(program,deplist,linklist) @@\
+program.pure: deplist @@\
+ RemoveTargetProgram($@) @@\
+ $(CCENVSETUP) $(PURIFY) $(PURIFYOPTIONS) $(CC) \
+ -o $@ $(LDOPTIONS) linklist $(EXTRA_LOAD_FLAGS)
+
+PurifyProgramTarget(xscreensaver,$(OBJS1),$(OBJS1) MOTIF_LIB $(SAVERLIBS))
+
+#endif /* Purify */
hypercube -root \n\
halo -root \n\
maze -root \n\
- flame -root \n
+ flame -root \n\
+ lmorph -root \n
! Programs on this list are run only for monochrome screens.
*monoPrograms: qix -root -linear -count 5 -size 200 -spread 30 \
*demoDialog.maxWidth: 600
*label1.labelString: XScreenSaver %s
-*label2.labelString: Copyright © 1991-1995 by Jamie Zawinski <jwz@mcom.com>
+*label2.labelString: Copyright © 1991-1995 by Jamie Zawinski <jwz@netscape.com>
*demoList.visibleItemCount: 10
*demoList.automaticSelection: True
*next.labelString: Run Next
-/* xscreensaver, Copyright (c) 1993-1995 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1993-1995 Jamie Zawinski <jwz@netscape.com>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
Widget spacer;
+void
create_passwd_dialog( parent )
Widget parent;
{
- Display *display = XtDisplay ( parent );
Widget children[8]; /* Children to manage */
Arg al[64]; /* Arg List */
register int ac = 0; /* Arg Count */
- char from_s [256]; /* For font list conversion */
- XrmValue from_value, to_value; /* ditto */
- int fg, bg; /* colour values for pixmaps */
- XmString *list_items; /* For list items */
- int list_item; /* Index for list_items */
- XmString xmstrings[15]; /* temporary storage for XmStrings */
Widget widget4;
Widget widget7;
+void
create_resources_dialog( parent )
Widget parent;
{
- Display *display = XtDisplay ( parent );
Widget children[22]; /* Children to manage */
Arg al[64]; /* Arg List */
register int ac = 0; /* Arg Count */
- char from_s [256]; /* For font list conversion */
- XrmValue from_value, to_value; /* ditto */
- int fg, bg; /* colour values for pixmaps */
- XmString *list_items; /* For list items */
- int list_item; /* Index for list_items */
- XmString xmstrings[15]; /* temporary storage for XmStrings */
Widget widget12;
Widget widget13;
Widget widget14;
+void
create_demo_dialog( parent )
Widget parent;
{
- Display *display = XtDisplay ( parent );
Widget children[11]; /* Children to manage */
Arg al[64]; /* Arg List */
register int ac = 0; /* Arg Count */
- char from_s [256]; /* For font list conversion */
- XrmValue from_value, to_value; /* ditto */
- int fg, bg; /* colour values for pixmaps */
- XmString *list_items; /* For list items */
- int list_item; /* Index for list_items */
XmString xmstrings[15]; /* temporary storage for XmStrings */
object 'label2' : XmLabel {
arguments {
name = 'label2';
- XmNlabelString= 'Copyright © 1991-1994 by Jamie Zawinski <jwz@mcom.com>';
+ XmNlabelString= 'Copyright © 1991-1994 by Jamie Zawinski <jwz@netscape.com>';
};
};
object 'text_area' : XmScrolledList {
-/* xscreensaver, Copyright (c) 1993-1995 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1993-1995 Jamie Zawinski <jwz@netscape.com>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* implied warranty.
*/
+/* #### If anyone ever finishes the Athena locking code, remove this.
+ But until then, locking requires Motif.
+ */
+#if defined(NO_MOTIF) && !defined(NO_LOCKING)
+# define NO_LOCKING
+#endif
+
+
+#ifndef NO_LOCKING
+
#if __STDC__
#include <stdlib.h>
#include <unistd.h>
#include <X11/Intrinsic.h>
+#include "xscreensaver.h"
+
+extern char *screensaver_version;
+extern char *progname;
+extern XtAppContext app;
+extern Bool verbose_p;
+
+#ifdef SCO
+/* SCO has some kind of goofy, nonstandard security crap. This stuff was
+ donated by one of their victims, I mean users, Didier Poirot <dp@chorus.fr>.
+ */
+# include <sys/security.h>
+# include <sys/audit.h>
+# include <prot.h>
+#endif
+
#if !__STDC__
# define _NO_PROTO
#endif
-#include <Xm/Xm.h>
-#include <Xm/List.h>
-#include <Xm/TextF.h>
+#ifdef NO_MOTIF
-#include "xscreensaver.h"
+# include <X11/StringDefs.h>
+# include <X11/Xaw/Text.h>
+# include <X11/Xaw/Label.h>
-#ifndef NO_LOCKING
+#else /* Motif */
-Time passwd_timeout;
+# include <Xm/Xm.h>
+# include <Xm/List.h>
+# include <Xm/TextF.h>
-extern char *screensaver_version;
-extern char *progname;
-extern XtAppContext app;
-extern Bool verbose_p;
+#endif /* Motif */
+
+Time passwd_timeout;
extern Widget passwd_dialog;
extern Widget passwd_form;
# define GETPW getpwnam
#endif
+#ifdef SCO
+# define PRPWTYPE struct pr_passwd *
+# define GETPRPW getprpwnam
+#endif
+
Bool
lock_init ()
{
Bool ok = True;
char *u;
PWTYPE p = GETPW ("root");
+
+#ifdef SCO
+ PRPWTYPE prpwd = GETPRPW ("root");
+ if (prpwd && *prpwd->ufld.fd_encrypt)
+ strcpy (root_passwd, prpwd->ufld.fd_encrypt);
+#else /* !SCO */
if (p && p->PWSLOT && p->PWSLOT[0] != '*')
strcpy (root_passwd, p->PWSLOT);
+#endif /* !SCO */
else
{
fprintf (stderr, "%s: couldn't get root's password\n", progname);
/* It has been reported that getlogin() returns the wrong user id on some
very old SGI systems... */
- u = getlogin ();
+ u = (char *) getlogin ();
if (u)
- p = GETPW (u);
+ {
+#ifdef SCO
+ prpwd = GETPRPW (u);
+#endif /* SCO */
+ p = GETPW (u);
+ }
else
{
/* getlogin() fails if not attached to a terminal;
#endif
}
+#ifdef SCO
+ if (prpwd && *prpwd->ufld.fd_encrypt)
+ strcpy (user_passwd, prpwd->ufld.fd_encrypt);
+#else /* !SCO */
if (p && p->PWSLOT &&
/* p->PWSLOT[0] != '*' */ /* sensible */
(strlen (p->PWSLOT) > 4) /* solaris */
)
strcpy (user_passwd, p->PWSLOT);
+#endif /* !SCO */
else
{
fprintf (stderr, "%s: couldn't get password of \"%s\"\n", progname, u);
\f
-#if (XmVersion >= 1002) /* The `destroy' bug apears to be fixed as */
-# define DESTROY_WORKS /* of Motif 1.2.1, but the `verify-callback' */
-#endif /* bug is still present. */
+#if defined(NO_MOTIF) || (XmVersion >= 1002)
+ /* The `destroy' bug apears to be fixed as of Motif 1.2.1, but
+ the `verify-callback' bug is still present. */
+# define DESTROY_WORKS
+#endif
static void
passwd_cancel_cb (button, client_data, call_data)
passwd_state = pw_fail;
}
-#ifdef VERIFY_CALLBACK_WORKS
+#if !defined(NO_MOTIF) && defined(VERIFY_CALLBACK_WORKS)
/* #### It looks to me like adding any modifyVerify callback causes
#### Motif 1.1.4 to free the the TextF_Value() twice. I can't see
static char translations[] = "<Key>:keypress()";
#endif
+static void
+text_field_set_string (widget, text, position)
+ Widget widget;
+ char *text;
+ int position;
+{
+#ifdef NO_MOTIF
+ XawTextBlock block;
+ block.firstPos = 0;
+ block.length = strlen (text);
+ block.ptr = text;
+ block.format = 0;
+ XawTextReplace (widget, 0, -1, &block);
+ XawTextSetInsertionPoint (widget, position);
+#else /* !NO_MOTIF */
+ XmTextFieldSetString (widget, text);
+ XmTextFieldSetInsertionPosition (widget, position);
+#endif /* !NO_MOTIF */
+}
+
+
static void
keypress (w, event, argv, argc)
Widget w;
s [++i] = 0;
while (i--)
s [i] = '*';
- XmTextFieldSetString (passwd_text, s);
- XmTextFieldSetInsertionPosition (passwd_text, j + 1);
+
+ text_field_set_string (passwd_text, s, j + 1);
}
static void
s [i] = 0;
while (i--)
s [i] = '*';
- XmTextFieldSetString (passwd_text, s);
- XmTextFieldSetInsertionPosition (passwd_text, j + 1);
+
+ text_field_set_string (passwd_text, s, j + 1);
}
static void
Cardinal *argc;
{
memset (typed_passwd, 0, sizeof (typed_passwd));
- XmTextFieldSetString (passwd_text, "");
+ text_field_set_string (passwd_text, "", 0);
}
static void
passwd_done_cb (w, 0, 0);
}
-#endif /* !VERIFY_CALLBACK_WORKS */
+#endif /* !VERIFY_CALLBACK_WORKS || NO_MOTIF */
static void
format_into_label (widget, string)
{
char *label;
char buf [255];
- XmString xm_label = 0;
- XmString new_xm_label;
Arg av[10];
int ac = 0;
+
+#ifdef NO_MOTIF
+ XtSetArg (av [ac], XtNlabel, &label); ac++;
+ XtGetValues (widget, av, ac);
+#else /* Motif */
+ XmString xm_label = 0;
+ XmString new_xm_label;
XtSetArg (av [ac], XmNlabelString, &xm_label); ac++;
XtGetValues (widget, av, ac);
XmStringGetLtoR (xm_label, XmSTRING_DEFAULT_CHARSET, &label);
- if (!strcmp (label, XtName (widget)))
+#endif /* Motif */
+
+ if (!label || !strcmp (label, XtName (widget)))
strcpy (buf, "ERROR: RESOURCES ARE NOT INSTALLED CORRECTLY");
else
sprintf (buf, label, string);
- new_xm_label = XmStringCreate (buf, XmSTRING_DEFAULT_CHARSET);
+
ac = 0;
+
+#ifdef NO_MOTIF
+ XtSetArg (av [ac], XtNlabel, buf); ac++;
+#else /* Motif */
+ new_xm_label = XmStringCreate (buf, XmSTRING_DEFAULT_CHARSET);
XtSetArg (av [ac], XmNlabelString, new_xm_label); ac++;
+#endif /* Motif */
+
XtSetValues (widget, av, ac);
+#ifndef NO_MOTIF
XmStringFree (new_xm_label);
+#endif
XtFree (label);
}
if (size > 40) size -= 30;
x = (xgwa.width - size) / 2;
y = (xgwa.height - size) / 2;
- XtSetArg (av [ac], XmNforeground, &fg); ac++;
- XtSetArg (av [ac], XmNbackground, &bg); ac++;
+ XtSetArg (av [ac], XtNforeground, &fg); ac++;
+ XtSetArg (av [ac], XtNbackground, &bg); ac++;
XtGetValues (button, av, ac);
/* if it's black on white, swap it cause it looks better (hack hack) */
if (fg == BlackPixelOfScreen (screen) && bg == WhitePixelOfScreen (screen))
XFreeGC (dpy, erase_gc);
}
+#ifdef NO_MOTIF
+
+static void
+make_passwd_dialog (parent)
+ Widget parent;
+{
+ abort (); /* #### */
+}
+
+#else /* Motif */
+
static void
make_passwd_dialog (parent)
Widget parent;
XtOverrideTranslations (passwd_text, XtParseTranslationTable (translations));
#endif
-#if (XmVersion >= 1002)
+#if !defined(NO_MOTIF) && (XmVersion >= 1002)
/* The focus stuff changed around; this didn't exist in 1.1.5. */
XtVaSetValues (passwd_form, XmNinitialFocus, passwd_text, 0);
#endif
format_into_label (passwd_label1, screensaver_version);
}
+#endif /* Motif */
extern void idle_timer ();
int ac = 0;
XGCValues gcv;
unsigned long fg, bg;
- XtSetArg (av [ac], XmNheight, &d); ac++;
+ XtSetArg (av [ac], XtNheight, &d); ac++;
XtGetValues (passwd_done, av, ac);
ac = 0;
- XtSetArg (av [ac], XmNwidth, &x); ac++;
- XtSetArg (av [ac], XmNheight, &y); ac++;
- XtSetArg (av [ac], XmNforeground, &fg); ac++;
- XtSetArg (av [ac], XmNbackground, &bg); ac++;
+ XtSetArg (av [ac], XtNwidth, &x); ac++;
+ XtSetArg (av [ac], XtNheight, &y); ac++;
+ XtSetArg (av [ac], XtNforeground, &fg); ac++;
+ XtSetArg (av [ac], XtNbackground, &bg); ac++;
XtGetValues (passwd_form, av, ac);
x -= d;
y -= d;
int revert_to;
typed_passwd [0] = 0;
passwd_state = pw_read;
- XmTextFieldSetString (passwd_text, "");
+ text_field_set_string (passwd_text, "", 0);
XGetInputFocus (dpy, &focus, &revert_to);
#ifndef DESTROY_WORKS
pop_up_dialog_box (passwd_dialog, passwd_form, 2);
XtManageChild (passwd_form);
-#if (XmVersion < 1002)
+#if !defined(NO_MOTIF) && (XmVersion < 1002)
/* The focus stuff changed around; this causes problems in 1.2.1
but is necessary in 1.1.5. */
XmProcessTraversal (passwd_text, XmTRAVERSE_CURRENT);
case pw_cancel: lose = 0; break;
default: abort ();
}
+#ifndef NO_MOTIF
XmProcessTraversal (passwd_cancel, 0); /* turn off I-beam */
+#endif
if (lose)
{
- XmTextFieldSetString (passwd_text, lose);
- XmTextFieldSetInsertionPosition (passwd_text, strlen (lose) + 1);
+ text_field_set_string (passwd_text, lose, strlen (lose) + 1);
passwd_idle_timer_tick = 1;
id = XtAppAddTimeOut (app, 3000, passwd_idle_timer, 0);
while (1)
}
}
memset (typed_passwd, 0, sizeof (typed_passwd));
- XmTextFieldSetString (passwd_text, "");
+ text_field_set_string (passwd_text, "", 0);
XtSetKeyboardFocus (parent, None);
#ifdef DESTROY_WORKS
-/* xscreensaver, Copyright (c) 1991-1995 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1991-1995 Jamie Zawinski <jwz@netscape.com>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
static void
-stderr_callback (XtPointer closure, int *fd, XtIntervalId *id)
+stderr_callback (closure, fd, id)
+ XtPointer closure;
+ int *fd;
+ XtIntervalId *id;
{
char *s;
int left;
-/* xscreensaver, Copyright (c) 1991-1993 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1991, 1992, 1993, 1995
+ * Jamie Zawinski <jwz@netscape.com>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
extern int kill (pid_t, int); /* signal() is in sys/signal.h... */
#endif
-# ifndef random
-# if defined(SVR4) || defined(SYSV)
-# define random() rand()
-# else /* !totally-losing-SYSV */
- extern long random(); /* rand() is in stdlib.h... */
-# endif /* !totally-losing-SYSV */
-# endif /* random defined */
-
+#include "yarandom.h"
#include "xscreensaver.h"
/* this must be `sh', not whatever $SHELL happens to be. */
-/* xscreensaver, Copyright (c) 1991-1995 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1991-1995 Jamie Zawinski <jwz@netscape.com>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
may have been destroyed <30 seconds after it was created.
*/
if (error->error_code == BadWindow ||
+ error->error_code == BadMatch ||
error->error_code == BadDrawable)
return 0;
XmuPrintDefaultErrorMessage (dpy, error, stderr);
-/* xscreensaver, Copyright (c) 1991-1995 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1991-1995 Jamie Zawinski <jwz@netscape.com>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
XInstallColormap (dpy, cmap);
}
+#ifdef __hpux
+ /* Calls to XHPDisableReset and XHPEnableReset must be balanced,
+ or BadAccess errors occur. */
+static Bool hp_locked_p = False;
+#endif /* __hpux */
+
void
blank_screen ()
{
raise_window (False, False);
grab_keyboard_and_mouse ();
#ifdef __hpux
- if (lock_p)
+ if (lock_p && !hp_locked_p)
XHPDisableReset (dpy); /* turn off C-Sh-Reset */
+ hp_locked_p = True;
#endif
}
ungrab_keyboard_and_mouse ();
restore_real_vroot ();
#ifdef __hpux
- if (lock_p)
+ if (lock_p && hp_locked_p)
XHPEnableReset (dpy); /* turn C-Sh-Reset back on */
+ hp_locked_p = False;
#endif
}
-/* xscreensaver-command, Copyright (c) 1991-1995 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver-command, Copyright (c) 1991-1995
+ * Jamie Zawinski <jwz@netscape.com>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
static char *usage = "usage: %s -<switch>\n\
\n\
This program provides external control of a running xscreensaver process.\n\
- Version %s, copyright (c) 1991-1994 Jamie Zawinski <jwz@mcom.com>.\n\
+ Version %s, copyright (c) 1991-1994 Jamie Zawinski <jwz@netscape.com>.\n\
\n\
-demo Enter interactive demo mode.\n\
-deactivate Turns off the screensaver if it is on, as user input would.\n\
suitability of this software for any purpose. It is provided "as is" without
express or implied warranty.
.SH AUTHOR
-Jamie Zawinski <jwz@mcom.com>, 13-aug-92.
+Jamie Zawinski <jwz@netscape.com>, 13-aug-92.
-/* xscreensaver, Copyright (c) 1991-1995 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1991-1995 Jamie Zawinski <jwz@netscape.com>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
#include <X11/extensions/scrnsaver.h>
#endif /* HAVE_SAVER_EXTENSION */
+#include "yarandom.h"
#include "xscreensaver.h"
-#if defined(SVR4) || defined(SYSV)
-# define srandom(i) srand((unsigned int)(i))
-#else
-# ifndef __linux
-extern void srandom P((int)); /* srand() is in stdlib.h... */
-# endif
-#endif
-
extern char *get_string_resource P((char *, char *));
extern Bool get_boolean_resource P((char *, char *));
extern int get_integer_resource P((char *, char *));
#ifdef NO_MOTIF /* kludge */
Bool demo_mode_p = 0;
Bool dbox_up_p = 0;
-#ifndef NO_LOCKING
-Time passwd_timeout = 0;
-#endif
#endif
\f
{ "-timeout", ".timeout", XrmoptionSepArg, 0 },
{ "-cycle", ".cycle", XrmoptionSepArg, 0 },
{ "-idelay", ".initialDelay", XrmoptionSepArg, 0 },
+ { "-nice", ".nice", XrmoptionSepArg, 0 },
{ "-visual", ".visualID", XrmoptionSepArg, 0 },
{ "-lock-timeout", ".lockTimeout", XrmoptionSepArg, 0 },
{ "-install", ".installColormap", XrmoptionNoArg, "on" },
do_help P((void))
{
printf ("\
-xscreensaver %s, copyright (c) 1991-1995 by Jamie Zawinski <jwz@mcom.com>.\n\
+xscreensaver %s, copyright (c) 1991-1995 by Jamie Zawinski <jwz@netscape.com>.\n\
The standard Xt command-line options are accepted; other options include:\n\
\n\
-timeout <minutes> When the screensaver should activate.\n\
-silent Don't.\n\
-xidle-extension Use the R5 XIdle server extension.\n\
-no-xidle-extension Don't.\n\
- -saver-extension Use the R6 MIT-SCREEN-SAVER server extension.\n\
- -no-saver-extension Don't.\n\
+ -ss-extension Use the R6 MIT-SCREEN-SAVER server extension.\n\
+ -no-ss-extension Don't.\n\
-lock Require a password before deactivating.\n\
-no-lock Don't.\n\
-lock-timeout <minutes> Grace period before locking; default 0.\n\
#endif
#if !defined(HAVE_XIDLE_EXTENSION) && !defined(HAVE_SAVER_EXTENSION)
printf ("Support for the XIDLE and MIT-SCREEN-SAVER server extensions\
- was not\n\enabled at compile-time.\n");
+ was not\nenabled at compile-time.\n");
#endif /* !HAVE_XIDLE_EXTENSION && !HAVE_SAVER_EXTENSION */
fflush (stdout);
/* don't set use_saver_extension unless it is explicitly specified */
if (get_string_resource ("saverExtension", "Boolean"))
- use_xidle_extension = get_boolean_resource ("saverExtension", "Boolean");
+ use_saver_extension = get_boolean_resource ("saverExtension", "Boolean");
else
#ifdef HAVE_SAVER_EXTENSION /* pick a default */
use_saver_extension = True;
nolock_reason = "not compiled with locking support";
#else
locking_disabled_p = False;
+
+#ifdef SCO
+ set_auth_parameters(argc, argv);
+#endif
+
if (! lock_init ()) /* before hack_uid() for proper permissions */
{
locking_disabled_p = True;
if (verbose_p)
printf ("\
-%s %s, copyright (c) 1991-1995 by Jamie Zawinski <jwz@mcom.com>.\n\
+%s %s, copyright (c) 1991-1995 by Jamie Zawinski <jwz@netscape.com>.\n\
pid = %d.\n", progname, screensaver_version, getpid ());
ensure_no_screensaver_running ();
blank_screen ();
spawn_screenhack (True);
if (cycle)
- cycle_id = XtAppAddTimeOut (app, cycle, (XtPointer)cycle_timer, 0);
+ cycle_id = XtAppAddTimeOut (app, cycle,
+ (XtTimerCallbackProc)cycle_timer, 0);
#ifndef NO_LOCKING
if (lock_p && lock_timeout == 0)
if (lock_p && !locked_p)
/* locked_p might be true already because of ClientMessage */
lock_id = XtAppAddTimeOut (app,lock_timeout,
- (XtPointer)activate_lock_timer,0);
+ (XtTimerCallbackProc)
+ activate_lock_timer,0);
#endif
PASSWD_INVALID:
XEvent *event;
Bool until_idle_p;
{
- Atom type;
+ Atom type = 0;
if (event->xclient.message_type != XA_SCREENSAVER)
{
char *str;
progname, (verbose_p ? "## " : ""),
(str ? str : "(null)"));
if (str) XFree (str);
+ return False;
}
if (event->xclient.format != 32)
{
fprintf (stderr, "%s: %sClientMessage of format %d received, not 32\n",
progname, (verbose_p ? "## " : ""), event->xclient.format);
+ return False;
}
type = event->xclient.data.l[0];
if (type == XA_ACTIVATE)
{
if (verbose_p)
printf ("%s: ACTIVATE ClientMessage received.\n", progname);
- return True;
+ if (use_saver_extension)
+ {
+ XForceScreenSaver (dpy, ScreenSaverActive);
+ return False;
+ }
+ else
+ {
+ return True;
+ }
}
fprintf (stderr,
"%s: %sClientMessage ACTIVATE received while already active.\n",
{
if (verbose_p)
printf ("%s: DEACTIVATE ClientMessage received.\n", progname);
- return True;
+ if (use_saver_extension)
+ {
+ XForceScreenSaver (dpy, ScreenSaverReset);
+ return False;
+ }
+ else
+ {
+ return True;
+ }
}
fprintf (stderr,
"%s: %sClientMessage DEACTIVATE received while inactive.\n",
}
if (until_idle_p)
- return True;
+ {
+ if (use_saver_extension)
+ {
+ XForceScreenSaver (dpy, ScreenSaverActive);
+ return False;
+ }
+ else
+ {
+ return True;
+ }
+ }
}
#endif
}
else
{
char *str;
- str = XGetAtomName (dpy, type);
+ str = (type ? XGetAtomName(dpy, type) : 0);
if (str)
fprintf (stderr,
"%s: %sunrecognised screensaver ClientMessage %s received\n",
progname, (verbose_p ? "## " : ""), str);
else
fprintf (stderr,
- "%s: %sunrecognised screensaver ClientMessage 0x%x received\n",
+ "%s: %sunrecognised screensaver ClientMessage 0x%x received\n",
progname, (verbose_p ? "## " : ""),
(unsigned int) event->xclient.data.l[0]);
if (str) XFree (str);
-/* xscreensaver, Copyright (c) 1993, 1995 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1993, 1995 Jamie Zawinski <jwz@netscape.com>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
#ifdef NO_MOTIF
# define NO_DEMO_MODE
+
+ /* #### If anyone ever finishes the Athena locking code, remove this.
+ Until then, Locking requires Motif. */
# ifndef NO_LOCKING
# define NO_LOCKING
# endif
+
#endif
extern char *progname, *progclass;
or \fBcaptureStderr\fP are true. Default: Black.
.TP 8
.B programs \fR(class \fBPrograms\fP)
-The graphics hacks which \fIxscreensaver\fP runs when the user is idle.
-The value of this resource is a string, one \fIsh\fP command per line.
-Each line must contain exactly one command -- no semicolons.
+The graphics hacks which \fIxscreensaver\fP runs when the user is idle,
+in addition to those specified in colorPrograms or monoPrograms (as
+appropriate.) The value of this resource is a string, one \fIsh\fP command
+per line. Each line must contain exactly one command -- no semicolons.
When the screensaver starts up, one of these is selected at random, and
run. After the \fIcycle\fP period expires, it is killed, and another
file. Because \fIxdm\fP grabs the keyboard, keypresses will not make
the screensaver deactivate, but any mouse activity will.
.PP
+(If your system does not seem to be executing the \fIXsetup\fP file, you
+may need to configure it to do so -- the traditional way to do this is
+to make that file the value of the \fIDisplayManager*setup\fP resource
+in the \fIxdm-config\fP file. See the man page for
+.BR xdm (1)
+for more details.)
+.PP
Users may want to add \fB"xscreensaver-command -restart"\fP to their
startup scripts, so that the screensaver will be reinitialized with
their private resource settings when they log in.
made about the suitability of this software for any purpose. It is provided
"as is" without express or implied warranty.
.SH AUTHOR
-Jamie Zawinski <jwz@mcom.com>, 13-aug-92.
+Jamie Zawinski <jwz@netscape.com>, 13-aug-92.
Please let me know if you find any bugs or make any improvements.
Thanks to David Wojtowicz for implementing \fIlockTimeout\fP.
UTILS = ../utils
INCLUDES = -I$(UTILS)
DEFINES = R5ISMS XPMDEFS
-EXTRA_LOAD_FLAGS= $(XMULIB) $(XTOOLLIB) XPMLIB $(EXTENSIONLIB) $(XLIB) -lm
+LOCAL_LIBRARIES = $(XMULIB) $(XTOOLLIB) XPMLIB $(EXTENSIONLIB) $(XLIB) -lm
HACKS = attraction.c greynetic.c helix.c hopalong.c xroger-hack.c \
noseguy.c pyro.c qix.c rocks.c rorschach.c blitspin.c \
imsmap.c slidescreen.c decayscreen.c maze.c hypercube.c \
- halo.c flame.c pedal.c
+ halo.c flame.c pedal.c lmorph.c
MEN = attraction.man greynetic.man helix.man hopalong.man \
noseguy.man pyro.man xroger.man qix.man rocks.man \
rorschach.man blitspin.man imsmap.man slidescreen.man \
decayscreen.man maze.man hypercube.man halo.man flame.man \
- pedal.man
+ pedal.man lmorph.man
TARFILES = README Imakefile screenhack.c $(HACKS) screenhack.h \
vroot.h xlock.h default.xbm $(MEN) .gdbinit noses/\*
all:: p @@\
p: deps screenhack.h ps.o $(DEPLIBS) @@\
RemoveTargetProgram($@) @@\
- $(CC) -o $@ $(LDOPTIONS) deps ps.o $(LDLIBS) $(EXTRA_LOAD_FLAGS) @@\
+ $(CCENVSETUP) \
+ $(CC) -o $@ $(LDOPTIONS) deps ps.o $(LOCAL_LIBRARIES) $(LDLIBS) @@\
@@\
InstallProgram(p,$(BINDIR)) @@\
InstallManPage(p,$(MANDIR)) @@\
clean:: @@\
$(RM) p
-HOBJS=screenhack.o $(UTILS)/resources.o $(UTILS)/usleep.o $(UTILS)/visual.o
+HOBJS=screenhack.o $(UTILS)/resources.o $(UTILS)/visual.o \
+ $(UTILS)/usleep.o $(UTILS)/yarandom.o
ScreenhackTarget (qix, qix, $(HOBJS) $(UTILS)/hsv.o)
ScreenhackTarget (helix, helix, $(HOBJS) $(UTILS)/hsv.o)
ScreenhackTarget (halo, halo, $(HOBJS) $(UTILS)/hsv.o)
ScreenhackTarget (flame, flame, $(HOBJS) $(UTILS)/hsv.o)
ScreenhackTarget (pedal, pedal, $(HOBJS) $(UTILS)/hsv.o)
+ScreenhackTarget (lmorph, lmorph, $(HOBJS))
-/* xscreensaver, Copyright (c) 1992 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1992, 1995 Jamie Zawinski <jwz@netscape.com>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
/* Simulation of a pair of quasi-gravitational fields, maybe sorta kinda
a little like the strong and weak electromagnetic forces. Derived from
- a Lispm screensaver by John Pezaris <pz@mit.edu>.
+ a Lispm screensaver by John Pezaris <pz@mit.edu>. Mouse control and
+ viscosity added by "Philip Edward Cutone, III" <pc2d+@andrew.cmu.edu>.
John sez:
The 1/r^2, -1/r^2, -10/r^2 thresholds proved not only robust but also
interesting -- the orbs never collided and the threshold viscosity fixed
the non-conservational problem.
+
+ Philip sez:
+ > An even normal viscosity (rather than the thresholded version to
+ > bleed excess energy) is also not interesting.
+
+ unless you make about 200 points.... set the viscosity to about .8
+ and drag the mouse through it. it makes a nice wave which travels
+ through the field.
*/
-#include "screenhack.h"
-#include "spline.h"
#include <stdio.h>
#include <math.h>
-#if __STDC__
-#include <math.h> /* for M_PI */
-#endif
+#include "screenhack.h"
+#include "spline.h"
struct ball {
float x, y;
static unsigned long *pixel_stack;
static unsigned int color_shift;
+/*flip mods for mouse interaction*/
+static Bool mouse_p;
+int mouse_x, mouse_y, mouse_mass, root_x, root_y;
+static float viscosity;
+
static enum object_mode {
ball_mode, line_mode, polygon_mode, spline_mode, spline_filled_mode,
tail_mode
color_shift = get_integer_resource ("colorShift", "Integer");
if (color_shift >= 360) color_shift = 5;
+ /*flip mods for mouse interaction*/
+ mouse_p = get_boolean_resource ("mouse", "Boolean");
+ mouse_mass = get_integer_resource ("mouseSize", "Integer");
+ mouse_mass = mouse_mass * mouse_mass *10;
+
+ viscosity = get_float_resource ("viscosity", "Float");
+
mode_str = get_string_resource ("mode", "Mode");
if (! mode_str) mode = ball_mode;
else if (!strcmp (mode_str, "balls")) mode = ball_mode;
float *dx_ret, *dy_ret;
{
int j;
+ float x_dist, y_dist, dist, dist2;
*dx_ret = 0;
*dy_ret = 0;
for (j = 0; j < npoints; j++)
*dy_ret += (frand (10.0) - 5.0);
}
}
+
+ if (mouse_p)
+ {
+ x_dist = mouse_x - balls [i].x;
+ y_dist = mouse_y - balls [i].y;
+ dist2 = (x_dist * x_dist) + (y_dist * y_dist);
+ dist = sqrt (dist2);
+
+ if (dist > 0.1) /* the balls are not overlapping */
+ {
+ float new_acc = ((mouse_mass / dist2) *
+ ((dist < threshold) ? -1.0 : 1.0));
+ float new_acc_dist = new_acc / dist;
+ *dx_ret += new_acc_dist * x_dist;
+ *dy_ret += new_acc_dist * y_dist;
+ }
+ else
+ { /* the balls are overlapping; move randomly */
+ *dx_ret += (frand (10.0) - 5.0);
+ *dy_ret += (frand (10.0) - 5.0);
+ }
+ }
}
static void
static Colormap cmap;
int i;
+ /*flip mods for mouse interaction*/
+ Window root1, child1;
+ int mask;
+ if (mouse_p)
+ {
+ XQueryPointer(dpy, window, &root1, &child1,
+ &root_x, &root_y, &mouse_x, &mouse_y, &mask);
+ }
+
if (tick++ == 500)
{
XWindowAttributes xgwa;
balls[i].vx *= 0.9;
balls[i].dx = 0;
}
+ else if (viscosity != 1)
+ {
+ balls[i].vx *= viscosity;
+ }
+
if (balls[i].vy > 10)
{
balls[i].vy *= 0.9;
balls[i].dy = 0;
}
+ else if (viscosity != 1)
+ {
+ balls[i].vy *= viscosity;
+ }
balls[i].x += balls[i].vx;
balls[i].y += balls[i].vy;
abort ();
if (!mono_p)
{
- XColor color2;
+ XColor color2, desired;
color2 = balls [0].color;
switch (cmode)
{
abort ();
}
- if (!XAllocColor (dpy, cmap, &color2))
+ desired = color2;
+ if (XAllocColor (dpy, cmap, &color2))
+ {
+ /* XAllocColor returns the actual RGB that the hardware let us
+ allocate. Restore the requested values into the XColor struct
+ so that limited-resolution hardware doesn't cause cycle_hue to
+ get "stuck". */
+ color2.red = desired.red;
+ color2.green = desired.green;
+ color2.blue = desired.blue;
+ }
+ else
{
color2 = balls [0].color;
if (!XAllocColor (dpy, cmap, &balls [0].color))
"*threshold: 100",
"*delay: 10000",
"*glow: false",
+ "*mouseSize: 10",
+ "*mouse: false",
+ "*viscosity: 1",
"*orbit: false",
"*colorShift: 3",
"*segments: 100",
{ "-vx", ".vx", XrmoptionSepArg, 0 },
{ "-vy", ".vy", XrmoptionSepArg, 0 },
{ "-vmult", ".vMult", XrmoptionSepArg, 0 },
+ { "-mouse-size", ".mouseSize", XrmoptionSepArg, 0 },
+ { "-mouse", ".mouse", XrmoptionNoArg, "true" },
+ { "-nomouse", ".mouse", XrmoptionNoArg, "false" },
+ { "-viscosity", ".viscosity", XrmoptionSepArg, 0 },
{ "-glow", ".glow", XrmoptionNoArg, "true" },
{ "-noglow", ".glow", XrmoptionNoArg, "false" },
{ "-orbit", ".orbit", XrmoptionNoArg, "true" }
-.TH XScreenSaver 1 "22-mar-93" "X Version 11"
+.de EX \"Begin example
+.ne 5
+.if n .sp 1
+.if t .sp .5
+.nf
+.in +.5i
+..
+.de EE
+.fi
+.in -.5i
+.if n .sp 1
+.if t .sp .5
+..
+.TH XScreenSaver 1 "14-Dec-95" "X Version 11"
.SH NAME
attraction - interactions of opposing forces
.SH SYNOPSIS
.B attraction
-[\-display \fIhost:display.screen\fP] [\-foreground \fIcolor\fP] [\-background \fIcolor\fP] [\-window] [\-root] [\-mono] [\-install] [\-visual \fIvisual\fP] [\-points \fIint\fP] [\-threshold \fIint\fP] [\-mode balls | lines | polygons | splines | filled-splines | tails ] [\-color-mode cycle | random] [\-size \fIint\fP] [\-segments \fIint\fP] [\-delay \fIusecs\fP] [\-color-shift \fIdegrees\fP] [\-radius \fIint\fP] [\-vx \fIint\fP] [\-vy \fIint\fP] [\-glow] [\-noglow] [\-orbit]
+[\-display \fIhost:display.screen\fP] [\-foreground \fIcolor\fP] [\-background \fIcolor\fP] [\-window] [\-root] [\-mono] [\-install] [\-visual \fIvisual\fP] [\-points \fIint\fP] [\-threshold \fIint\fP] [\-mode balls | lines | polygons | splines | filled-splines | tails ] [\-color-mode cycle | random] [\-size \fIint\fP] [\-segments \fIint\fP] [\-delay \fIusecs\fP] [\-color-shift \fIdegrees\fP] [\-radius \fIint\fP] [\-vx \fIint\fP] [\-vy \fIint\fP] [\-glow] [\-noglow] [\-orbit] [\-viscosity \fIfloat\fP] [\-mouse] [\-no-mouse] [\-mouse-size]
.SH DESCRIPTION
The \fIattraction\fP program has several visually different modes of
operation, all of which are based on the interactions of a set of control
In orbit mode, the initial velocity of the balls is multiplied by this;
a number less than 1 will make the balls pull closer together, and a larger
number will make them move apart. The default is 1, meaning stability.
+.TP 8
+.B \-viscosity float
+This sets the viscosity of the hypothetical fluid through which the control
+points move; the default is 1, meaning no resistance. Values higher than 1
+aren't interesting; lower values cause less motion.
+
+One interesting thing to try is
+.EX
+attraction -viscosity 0.8 -points 75 \\
+ -mouse -geometry =500x500
+.EE
+Give it a few seconds to settle down into a stable clump, and then move
+the mouse through it to make "waves".
+.TP 8
+.B \-mouse
+This will cause the mouse to be considered a control point; it will not be
+drawn, but it will influence the other points, so you can wave the mouse
+and influence the images being created.
+.TP 8
+.B \-no-mouse
+Turns off \fB\-mouse\fP.
+.TP 8
+.B \-mouse-size integer
+In \fB\-mouse\fP mode, this sets the mass of the mouse (analagously to the
+\fB\-size\fP parameter.)
.SH ENVIRONMENT
.PP
.TP 8
suitability of this software for any purpose. It is provided "as is" without
express or implied warranty.
.SH AUTHOR
-Jamie Zawinski <jwz@mcom.com>, 13-aug-92.
+Jamie Zawinski <jwz@netscape.com>, 13-aug-92.
+
+Viscosity and mouse support by Philip Edward Cutone, III.
-/* xscreensaver, Copyright (c) 1992 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1992 Jamie Zawinski <jwz@netscape.com>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
suitability of this software for any purpose. It is provided "as is" without
express or implied warranty.
.SH AUTHOR
-Jamie Zawinski <jwz@mcom.com>, 17-aug-92.
+Jamie Zawinski <jwz@netscape.com>, 17-aug-92.
Based on SmallTalk code which appeared in the August 1981 issue of Byte
magazine.
-/* xscreensaver, Copyright (c) 1992, 1993, 1994 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1992, 1993, 1994
+ * Jamie Zawinski <jwz@netscape.com>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
-/* xscreensaver, Copyright (c) 1993 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1993, 1995 Jamie Zawinski <jwz@netscape.com>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
#include "screenhack.h"
-/*#include <math.h>*/
-
#define POINT_BUFFER_SIZE 10
#define MAXLEV 4
if (delay) usleep (delay);
}
+
+#ifdef __hpux
+/* I don't understand why this is necessary, but I'm told that this program
+ does nothing at all on HP-sUX without it.
+ */
+#undef random
+#undef srandom
+#include <math.h>
+int matherr(x)
+ register struct exception *x;
+{
+ if (x->type == PLOSS) return 1;
+ else return 0;
+}
+#endif /* __hpux */
+
+
\f
char *progclass = "Flame";
Scott Graves <spot@cs.cmu.edu>, 06-Jun-91.n
Ability to run standalone or with \fIxscreensaver\fP added by
-Jamie Zawinski <jwz@mcom.com>, 18-Oct-93.
+Jamie Zawinski <jwz@netscape.com>, 18-Oct-93.
-/* xscreensaver, Copyright (c) 1992 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1992, 1995 Jamie Zawinski <jwz@netscape.com>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
gcv.stipple = pixmaps [random () % NBITS];
if (mono_p)
{
- if (random () % 1)
+ if (random () & 1)
gcv.foreground = fg, gcv.background = bg;
else
gcv.foreground = bg, gcv.background = fg;
suitability of this software for any purpose. It is provided "as is" without
express or implied warranty.
.SH AUTHOR
-Jamie Zawinski <jwz@mcom.com>, 13-aug-92.
+Jamie Zawinski <jwz@netscape.com>, 13-aug-92.
-/* xscreensaver, Copyright (c) 1993 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1993, 1995 Jamie Zawinski <jwz@netscape.com>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
*/
#include "screenhack.h"
+#include <stdio.h>
struct circle {
int x, y, radius;
int dx, dy;
};
+static enum color_mode {
+ seuss_mode, ramp_mode, random_mode
+} cmode;
+
+
static struct circle *circles;
static int count, global_count;
static Pixmap pixmap, buffer;
static int delay;
static unsigned long fg_pixel, bg_pixel;
static XColor fgc, bgc;
-static Bool xor_p;
static GC draw_gc, erase_gc, copy_gc, merge_gc;
static Bool anim_p;
static Colormap cmap;
{
XGCValues gcv;
XWindowAttributes xgwa;
+ char *mode_str = 0;
XGetWindowAttributes (dpy, window, &xgwa);
cmap = xgwa.colormap;
global_count = get_integer_resource ("count", "Integer");
if (global_count < 0) global_count = 0;
global_inc = get_integer_resource ("increment", "Integer");
if (global_inc < 0) global_inc = 0;
- xor_p = get_boolean_resource ("xor", "Boolean");
-/* if (mono_p) */ xor_p = True;
anim_p = get_boolean_resource ("animate", "Boolean");
delay = get_integer_resource ("delay", "Integer");
+ mode_str = get_string_resource ("colorMode", "ColorMode");
+ if (! mode_str) cmode = random_mode;
+ else if (!strcmp (mode_str, "seuss")) cmode = seuss_mode;
+ else if (!strcmp (mode_str, "ramp")) cmode = ramp_mode;
+ else if (!strcmp (mode_str, "random")) cmode = random_mode;
+ else {
+ fprintf (stderr,
+ "%s: colorMode must be seuss, ramp, or random, not \"%s\"\n",
+ progname, mode_str);
+ exit (1);
+ }
+
+ if (mono_p) cmode = seuss_mode;
+ if (cmode == random_mode)
+ cmode = ((random()&3) == 1) ? ramp_mode : seuss_mode;
+
+ if (cmode == ramp_mode)
+ anim_p = False; /* This combo doesn't work right... */
+
if (mono_p)
{
fg_pixel = get_pixel_resource ("foreground","Foreground", dpy, cmap);
}
else
{
- hsv_to_rgb (0, 0.5, 1.0, &fgc.red, &fgc.green, &fgc.blue);
- hsv_to_rgb (180, 1.0, 0.7, &bgc.red, &bgc.green, &bgc.blue);
+ int r = random() % 360;
+ int r2 = (random() % 180) + 45;
+ double fs, bs;
+ if (cmode == seuss_mode)
+ fs = 0.5, bs = 1.0;
+ else
+ fs = 1.0, bs = 0.1;
+ hsv_to_rgb (r, fs, 1.0, &fgc.red, &fgc.green, &fgc.blue);
+ hsv_to_rgb ((r+r2)%360, bs, 0.7, &bgc.red, &bgc.green, &bgc.blue);
XAllocColor (dpy, cmap, &fgc);
XAllocColor (dpy, cmap, &bgc);
fg_pixel = fgc.pixel;
#endif
pixmap = XCreatePixmap (dpy, window, width, height, 1);
- if (xor_p)
+ if (cmode == seuss_mode)
buffer = XCreatePixmap (dpy, window, width, height, 1);
else
buffer = 0;
gcv.background = bg_pixel;
copy_gc = XCreateGC (dpy, window, GCForeground | GCBackground, &gcv);
- if (xor_p)
+ if (cmode == seuss_mode)
{
gcv.foreground = 1;
gcv.background = 0;
done = True;
}
if (radius > 0 &&
- (xor_p || circles [0].increment < 0))
+ (cmode == seuss_mode || circles [0].increment < 0))
XFillArc (dpy,
- (xor_p ? pixmap : window),
- (xor_p ? draw_gc : merge_gc),
+ (cmode == seuss_mode ? pixmap : window),
+ (cmode == seuss_mode ? draw_gc : merge_gc),
circles [i].x - radius, circles [i].y - radius,
radius * 2, radius * 2, 0, 360*64);
circles [i].radius += inc;
init_circles_1 (dpy, window);
if (! mono_p)
{
+ XColor d1, d2;
cycle_hue (&fgc, 10);
cycle_hue (&bgc, 10);
XFreeColors (dpy, cmap, &fgc.pixel, 1, 0);
XFreeColors (dpy, cmap, &bgc.pixel, 1, 0);
+ d1 = fgc;
+ d2 = bgc;
XAllocColor (dpy, cmap, &fgc);
XAllocColor (dpy, cmap, &bgc);
+ fgc.red = d1.red; fgc.green = d1.green; fgc.blue = d1.blue;
+ bgc.red = d2.red; bgc.green = d2.green; bgc.blue = d2.blue;
XSetForeground (dpy, copy_gc, fgc.pixel);
XSetBackground (dpy, copy_gc, bgc.pixel);
}
if (buffer)
XCopyPlane (dpy, pixmap, buffer, merge_gc, 0, 0, width, height, 0, 0, 1);
- else if (!xor_p)
+ else if (cmode != seuss_mode)
{
static int ncolors = 0;
static XColor *colors = 0;
char *defaults [] = {
"Halo.background: black", /* to placate SGI */
"Halo.foreground: white",
-/* "*xor: false", */
- "*count: 0",
- "*delay: 100000",
+ "*colorMode: random",
+ "*count: 0",
+ "*delay: 100000",
0
};
XrmOptionDescRec options [] = {
{ "-count", ".count", XrmoptionSepArg, 0 },
{ "-delay", ".delay", XrmoptionSepArg, 0 },
- { "-animate", ".animate", XrmoptionNoArg, "True" } /* ,
- { "-xor", ".xor", XrmoptionNoArg, "True" },
- { "-no-xor", ".xor", XrmoptionNoArg, "False" } */
+ { "-animate", ".animate", XrmoptionNoArg, "True" },
+ { "-mode", ".colorMode", XrmoptionSepArg, 0 }
};
int options_size = (sizeof (options) / sizeof (options[0]));
halo - draw circular patterns
.SH SYNOPSIS
.B halo
-[\-display \fIhost:display.screen\fP] [\-foreground \fIcolor\fP] [\-background \fIcolor\fP] [\-window] [\-root] [\-mono] [\-install] [\-visual \fIvisual\fP] [\-count \fIint\fP] [\-delay \fIusecs\fP] [\-animate]
+[\-display \fIhost:display.screen\fP] [\-foreground \fIcolor\fP] [\-background \fIcolor\fP] [\-window] [\-root] [\-mono] [\-install] [\-visual \fIvisual\fP] [\-count \fIint\fP] [\-delay \fIusecs\fP] [\-mode seuss | ramp | random ] [\-animate]
.SH DESCRIPTION
The \fIhalo\fP program draws cool patterns based on circles.
.SH OPTIONS
.B \-count \fIinteger\fP
How many circles to draw. Default 0, meaning random.
.TP 8
+.B \-mode "seuss | ramp | random"
+In \fIseuss\fP mode, alternating striped curves will be drawn.
+
+In \fIramp\fP mode, a color ramp will be drawn.
+
+\fIrandom\fP means pick the mode randomly.
+.TP 8
.B \-delay \fImicroseconds\fP
How much of a delay should be introduced between steps of the animation.
Default 100000, or about 0.1 second.
suitability of this software for any purpose. It is provided "as is" without
express or implied warranty.
.SH AUTHOR
-Jamie Zawinski <jwz@mcom.com>, 6-jul-93.
+Jamie Zawinski <jwz@netscape.com>, 6-jul-93.
-/* xscreensaver, Copyright (c) 1992 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1992, 1995 Jamie Zawinski <jwz@netscape.com>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* implied warranty.
*/
+#include <math.h>
#include "screenhack.h"
-#ifdef __STDC__
-#include <math.h> /* for M_PI */
-#endif
static double sins [360];
static double coss [360];
0
};
-XrmOptionDescRec options [] = { 0 };
+XrmOptionDescRec options [] = { { 0, } };
int options_size = 0;
void
suitability of this software for any purpose. It is provided "as is" without
express or implied warranty.
.SH AUTHOR
-Jamie Zawinski <jwz@mcom.com>, 13-aug-92.
+Jamie Zawinski <jwz@netscape.com>, 13-aug-92.
-/* xscreensaver, Copyright (c) 1992 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1992, 1995 Jamie Zawinski <jwz@netscape.com>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* 23-Mar-88: Coded HOPALONG routines from Scientific American Sept. 86 p. 14.
*/
-#include "screenhack.h"
#include <math.h>
+#include "screenhack.h"
static GC gc;
static int batchcount = 1000;
Patrick J. Naughton <naughton@eng.sun.com>, 23-mar-88.
Ability to run standalone or with \fIxscreensaver\fP added by
-Jamie Zawinski <jwz@mcom.com>, 13-aug-92.
+Jamie Zawinski <jwz@netscape.com>, 13-aug-92.
-/* xscreensaver, Copyright (c) 1992 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1992, 1995 Jamie Zawinski <jwz@netscape.com>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* and Jamie Zawinski.
*/
-#include "screenhack.h"
#include <math.h>
+#include "screenhack.h"
static Display *dpy;
static Window window;
suitability of this software for any purpose. It is provided "as is" without
express or implied warranty.
.SH AUTHOR
-Jamie Zawinski <jwz@mcom.com>, 6-dec-92.
+Jamie Zawinski <jwz@netscape.com>, 6-dec-92.
enum mode_t this_mode;
static Bool rv_p;
static int ncolors = 0;
- int shift;
- double dshift;
+ int shift = 0;
+ double dshift = 0;
XGCValues gcv;
.SH AUTHOR
Juergen Nickelsen <nickel@cs.tu-berlin.de>, 23-aug-92.
-Hacked on by Jamie Zawinski <jwz@mcom.com>, 24-aug-92.
+Hacked on by Jamie Zawinski <jwz@netscape.com>, 24-aug-92.
--- /dev/null
+
+/**************************************************************************
+ *
+ * FILE lmorph.c
+ * MODULE OF xscreensaver
+ *
+ * DESCRIPTION Bilinear interpolation for morphing line shapes.
+ *
+ * WRITTEN BY Sverre H. Huseby Glenn T. Lines
+ * Maridalsvn. 122, leil 101 Frysjavn. 3, 5. etg.
+ * N-0461 Oslo N-0883 Oslo
+ * Norway Norway
+ *
+ * Phone: +47 22 71 99 08 Phone: +47 22 23 71 99
+ * E-mail: sverrehu@ifi.uio.no E-mail: gtl@si.sintef.no
+ *
+ * The original idea, and the bilinear interpolation
+ * mathematics used, emerged in the head of the wise
+ * Glenn Terje Lines.
+ *
+ * MODIFICATIONS march 1995
+ * * Converted from an MS-Windows program to X Window.
+ *
+ **************************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+#include "screenhack.h"
+
+/**************************************************************************
+ * *
+ * P R I V A T E D A T A *
+ * *
+ **************************************************************************/
+
+/* Define MARGINS to make some space around the figure */
+#define MARGINS /**/
+
+#define MAXFIGS 20
+#define TWO_PI (2.0 * M_PI)
+#define RND(x) (random() % (x))
+static int
+ cFig = 0, /* Number of figure arrays. */
+ cPoint, /* Number of points in each array. */
+ nWork, /* Current work array number. */
+ nFrom, /* Current from array number. */
+ nTo; /* Current to array number. */
+static long
+ delay; /* usecs to wait between updates. */
+static XPoint
+ *aWork[2], /* Working arrays. */
+ *a[MAXFIGS], /* The figure arrays. */
+ *aTmp, /* Used as source when interrupting morph */
+ *aPrev, /* Previous points displayed. */
+ *aCurr, /* The current points displayed. */
+ *aFrom, /* Figure converting from. */
+ *aTo; /* Figure converting to. */
+static double
+ gam,
+ maxGamma = 1.0,
+ delta_gam;
+static GC
+ gcDraw, gcClear;
+static Display
+ *dpy;
+static Window
+ window;
+
+
+
+/**************************************************************************
+ * *
+ * P U B L I C D A T A *
+ * *
+ **************************************************************************/
+
+char *progclass = "LMorph";
+
+char *defaults [] = {
+ "LMorph.background: black",
+ "LMorph.foreground: green",
+ "*points: 150",
+ "*steps: 0",
+ "*delay: 50000",
+ 0
+};
+
+XrmOptionDescRec options [] = {
+ { "-points", ".points", XrmoptionSepArg, 0 },
+ { "-steps", ".steps", XrmoptionSepArg, 0 },
+ { "-delay", ".delay", XrmoptionSepArg, 0 },
+};
+int options_size = (sizeof (options) / sizeof (options[0]));
+
+
+
+/**************************************************************************
+ * *
+ * P R I V A T E F U N C T I O N S *
+ * *
+ **************************************************************************/
+
+static void *xmalloc(size)
+ size_t size;
+{
+ void *ret;
+
+ if ((ret = malloc(size)) == NULL) {
+ fprintf(stderr, "lmorph: out of memory\n");
+ exit(1);
+ }
+ return ret;
+}
+
+
+
+static double frnd()
+{
+ /*
+ * Hm. for some reason the second line (using RAND_MAX) didn't
+ * work on some machines, so I always use the first.
+ */
+#undef RAND_MAX
+#ifndef RAND_MAX
+ return (double) (random() & 0x7FFF) / 0x7FFF;
+#else
+ return ((double) random()) / RAND_MAX;
+#endif
+}
+
+
+
+static void initPointArrays()
+{
+ XWindowAttributes wa;
+ int q, w,
+ mx, my, /* Max screen coordinates. */
+ mp, /* Max point number. */
+ s, rx, ry,
+ marginx, marginy;
+ double scalex, scaley;
+
+ XGetWindowAttributes(dpy, window, &wa);
+ mx = wa.width - 1;
+ my = wa.height - 1;
+ mp = cPoint - 1;
+
+ aWork[0] = (XPoint *) xmalloc(cPoint * sizeof(XPoint));
+ aWork[1] = (XPoint *) xmalloc(cPoint * sizeof(XPoint));
+ aTmp = (XPoint *) xmalloc(cPoint * sizeof(XPoint));
+
+
+ /*
+ * Figure 0
+ */
+ a[cFig] = (XPoint *) xmalloc(cPoint * sizeof(XPoint));
+ s = cPoint / 4;
+ for (q = 0; q < s; q++) {
+ a[cFig][q].x = ((double) q / s) * mx;
+ a[cFig][q].y = 0;
+ a[cFig][s + q].x = mx;
+ a[cFig][s + q].y = ((double) q / s) * my;
+ a[cFig][2 * s + q].x = mx - ((double) q / s) * mx;
+ a[cFig][2 * s + q].y = my;
+ a[cFig][3 * s + q].x = 0;
+ a[cFig][3 * s + q].y = my - ((double) q / s) * my;
+ }
+ for (q = 4 * s; q < cPoint; q++)
+ a[cFig][q].x = a[cFig][q].y = 0;
+ a[cFig][mp].x = a[cFig][0].x;
+ a[cFig][mp].y = a[cFig][0].y;
+ ++cFig;
+
+ /*
+ * Figure 1
+ */
+ a[cFig] = (XPoint *) xmalloc(cPoint * sizeof(XPoint));
+ for (q = 0; q < cPoint; q++) {
+ a[cFig][q].x = ((double) q / cPoint) * mx;
+ a[cFig][q].y = (1.0 - sin(((double) q / mp) * TWO_PI)) * my / 2.0;
+ }
+ ++cFig;
+
+ /*
+ * Figure 2
+ */
+ a[cFig] = (XPoint *) xmalloc(cPoint * sizeof(XPoint));
+ rx = mx / 2;
+ ry = my / 2;
+ for (q = 0; q < cPoint; q++) {
+ a[cFig][q].x = mx / 2 + rx * sin(1 * TWO_PI * (double) q / mp);
+ a[cFig][q].y = my / 2 + ry * cos(3 * TWO_PI * (double) q / mp);
+ }
+ a[cFig][mp].x = a[cFig][0].x;
+ a[cFig][mp].y = a[cFig][0].y;
+ ++cFig;
+
+ /*
+ * Figure 3
+ */
+ a[cFig] = (XPoint *) xmalloc(cPoint * sizeof(XPoint));
+ rx = mx / 2;
+ ry = my / 2;
+ for (q = 0; q < cPoint; q++) {
+ a[cFig][q].x = mx / 2 + ry * sin(3 * TWO_PI * (double) q / mp);
+ a[cFig][q].y = my / 2 + ry * cos(1 * TWO_PI * (double) q / mp);
+ }
+ a[cFig][mp].x = a[cFig][0].x;
+ a[cFig][mp].y = a[cFig][0].y;
+ ++cFig;
+
+ /*
+ * Figure 4
+ */
+ a[cFig] = (XPoint *) xmalloc(cPoint * sizeof(XPoint));
+ rx = mx / 2;
+ ry = my / 2;
+ for (q = 0; q < cPoint; q++) {
+ a[cFig][q].x = mx / 2 + ry * (1 - 0.1 * frnd())
+ * sin(TWO_PI * (double) q / mp);
+ a[cFig][q].y = my / 2 + ry * (1 - 0.1 * frnd())
+ * cos(TWO_PI * (double) q / mp);
+ }
+ a[cFig][mp].x = a[cFig][0].x;
+ a[cFig][mp].y = a[cFig][0].y;
+ ++cFig;
+
+ /*
+ * Figure 5
+ */
+ a[cFig] = (XPoint *) xmalloc(cPoint * sizeof(XPoint));
+ rx = mx / 2;
+ ry = my / 2;
+ for (q = 0; q < cPoint; q++) {
+ a[cFig][q].x = mx / 2 + ry * (0.8 - 0.2 * sin(30 * TWO_PI * q / mp))
+ * sin(TWO_PI * (double) q / mp);
+ a[cFig][q].y = my / 2 + ry * (0.8 - 0.2 * sin(30 * TWO_PI * q / mp))
+ * cos(TWO_PI * (double) q / mp);
+ }
+ a[cFig][mp].x = a[cFig][0].x;
+ a[cFig][mp].y = a[cFig][0].y;
+ ++cFig;
+
+ /*
+ * Figure 6
+ */
+ a[cFig] = (XPoint *) xmalloc(cPoint * sizeof(XPoint));
+ rx = mx / 2;
+ ry = my / 2;
+ for (q = 0; q < cPoint; q++) {
+ a[cFig][q].x = mx / 2 + ry * sin(TWO_PI * (double) q / mp);
+ a[cFig][q].y = my / 2 + ry * cos(TWO_PI * (double) q / mp);
+ }
+ a[cFig][mp].x = a[cFig][0].x;
+ a[cFig][mp].y = a[cFig][0].y;
+ ++cFig;
+
+ /*
+ * Figure 7
+ */
+ a[cFig] = (XPoint *) xmalloc(cPoint * sizeof(XPoint));
+ rx = mx / 2;
+ ry = my / 2;
+ for (q = 0; q < cPoint; q++) {
+ a[cFig][q].x = mx / 2 + rx * cos(TWO_PI * (double) q / mp);
+ a[cFig][q].y = my / 2 + ry * sin(TWO_PI * (double) q / mp);
+ }
+ a[cFig][mp].x = a[cFig][0].x;
+ a[cFig][mp].y = a[cFig][0].y;
+ ++cFig;
+
+ /*
+ * Figure 8
+ */
+ a[cFig] = (XPoint *) xmalloc(cPoint * sizeof(XPoint));
+ for (q = 0; q < cPoint; q++) {
+ a[cFig][q].x = ((double) q / mp) * mx;
+ a[cFig][q].y = (1.0 - cos(((double) q / mp) * 3 * TWO_PI)) * my / 2.0;
+ }
+ ++cFig;
+
+ /*
+ * Figure 9
+ */
+ a[cFig] = (XPoint *) xmalloc(cPoint * sizeof(XPoint));
+ rx = mx / 2;
+ ry = my / 2;
+ for (q = 0; q < cPoint; q++) {
+ a[cFig][q].x = mx / 2 + rx * sin(2 * TWO_PI * (double) q / mp);
+ a[cFig][q].y = my / 2 + ry * cos(3 * TWO_PI * (double) q / mp);
+ }
+ a[cFig][mp].x = a[cFig][0].x;
+ a[cFig][mp].y = a[cFig][0].y;
+ ++cFig;
+
+ /*
+ * Figure 10
+ */
+ a[cFig] = (XPoint *) xmalloc(cPoint * sizeof(XPoint));
+ rx = mx / 2;
+ ry = my / 2;
+ for (q = 0; q < cPoint; q++) {
+ a[cFig][q].x = mx / 2 + ry * sin(5 * TWO_PI * (double) q / mp)
+ * ((double) q / mp);
+ a[cFig][q].y = my / 2 + ry * cos(5 * TWO_PI * (double) q / mp)
+ * ((double) q / mp);
+ }
+ ++cFig;
+
+ /*
+ * Figure 11
+ */
+ a[cFig] = (XPoint *) xmalloc(cPoint * sizeof(XPoint));
+ rx = mx / 2;
+ ry = my / 2;
+ for (q = 0; q < cPoint; q++) {
+ a[cFig][q].x = mx / 2 + ry * sin(6 * TWO_PI * (double) q / mp)
+ * ((double) q / mp);
+ a[cFig][q].y = my / 2 - ry * cos(6 * TWO_PI * (double) q / mp)
+ * ((double) q / mp);
+ }
+ ++cFig;
+
+ /*
+ * Figure 12
+ */
+ a[cFig] = (XPoint *) xmalloc(cPoint * sizeof(XPoint));
+ for (q = 0; q < cPoint; q++) {
+ a[cFig][q].x = ((double) q / mp) * mx;
+ a[cFig][q].y = (1.0 - sin(((double) q / mp) * 5 * TWO_PI)) * my / 2.0;
+ }
+ ++cFig;
+
+#ifdef MARGINS
+ /*
+ * Make some space around the figures.
+ */
+ marginx = (mx + 1) / 10;
+ marginy = (my + 1) / 10;
+ scalex = (double) ((mx + 1) - 2.0 * marginx) / (mx + 1.0);
+ scaley = (double) ((my + 1) - 2.0 * marginy) / (my + 1.0);
+ for (q = 0; q < cFig; q++)
+ for (w = 0; w < cPoint; w++) {
+ a[q][w].x = marginx + a[q][w].x * scalex;
+ a[q][w].y = marginy + a[q][w].y * scaley;
+ }
+#endif
+}
+
+
+
+static void createPoints()
+{
+ int q;
+ XPoint *pa = aCurr, *pa1 = aFrom, *pa2 = aTo;
+ long lg, l1g;
+
+
+ lg = 8192L * gam, l1g = 8192L * (1.0 - gam);
+ for (q = 0; q < cPoint; q++) {
+ pa->x = (short) ((l1g * pa1->x + lg * pa2->x) / 8192L);
+ pa->y = (short) ((l1g * pa1->y + lg * pa2->y) / 8192L);
+ ++pa;
+ ++pa1;
+ ++pa2;
+ }
+}
+
+
+static void drawImage()
+{
+ register int q;
+ XPoint *old0, *old1, *new0, *new1;
+
+ /*
+ * Problem: update the window without too much flickering. I do
+ * this by handling each linesegment separately. First remove a
+ * line, then draw the new line. The problem is that this leaves
+ * small black pixels on the figure. To fix this, I draw the
+ * entire figure using XDrawLines() afterwards.
+ */
+ if (aPrev) {
+ old0 = aPrev;
+ old1 = aPrev + 1;
+ new0 = aCurr;
+ new1 = aCurr + 1;
+ for (q = cPoint - 1; q; q--) {
+ XDrawLine(dpy, window, gcClear,
+ old0->x, old0->y, old1->x, old1->y);
+ XDrawLine(dpy, window, gcDraw,
+ new0->x, new0->y, new1->x, new1->y);
+ ++old0;
+ ++old1;
+ ++new0;
+ ++new1;
+ }
+ }
+ XDrawLines(dpy, window, gcDraw, aCurr, cPoint, CoordModeOrigin);
+ XFlush(dpy);
+}
+
+static void initLMorph()
+{
+ int steps;
+ XGCValues gcv;
+ XWindowAttributes wa;
+ Colormap cmap;
+
+ cPoint = get_integer_resource("points", "Integer");
+ steps = get_integer_resource("steps", "Integer");
+ delay = get_integer_resource("delay", "Integer");
+
+ if (steps <= 0)
+ steps = (random() % 400) + 100;
+
+ delta_gam = 1.0 / steps;
+ XGetWindowAttributes(dpy, window, &wa);
+ cmap = wa.colormap;
+ gcv.foreground = get_pixel_resource("foreground", "Foreground", dpy, cmap);
+ gcDraw = XCreateGC(dpy, window, GCForeground, &gcv);
+ XSetForeground(dpy, gcDraw, gcv.foreground);
+ gcv.foreground = get_pixel_resource("background", "Background", dpy, cmap);
+ gcClear = XCreateGC(dpy, window, GCForeground, &gcv);
+ XClearWindow(dpy, window);
+
+ srandom(time(NULL));
+ initPointArrays();
+ aCurr = aWork[nWork = 0];
+ aPrev = NULL;
+ gam = 2.0;
+ nTo = RND(cFig);
+}
+
+static void animateLMorph()
+{
+ if (gam > maxGamma) {
+ gam = 0.0;
+ if (maxGamma == 1.0) {
+ nFrom = nTo;
+ aFrom = a[nFrom];
+ } else {
+ memcpy(aTmp, aCurr, cPoint * sizeof(XPoint));
+ aFrom = aTmp;
+ nFrom = -1;
+ }
+ do {
+ nTo = RND(cFig);
+ } while (nTo == nFrom);
+ aTo = a[nTo];
+ if (RND(2)) {
+ /*
+ * Reverse the array to get more variation.
+ */
+ int i1, i2;
+ XPoint p;
+
+ for (i1 = 0, i2 = cPoint - 1; i1 < cPoint / 2; i1++, i2--) {
+ p = aTo[i1];
+ aTo[i1] = aTo[i2];
+ aTo[i2] = p;
+ }
+ }
+ /*
+ * It may be nice to interrupt the next run.
+ */
+ if (RND(3) > 0)
+ maxGamma = 0.1 + 0.7 * (RND(1001) / 1000.0);
+ else
+ maxGamma = 1.0;
+ }
+
+ createPoints();
+ drawImage();
+ aPrev = aCurr;
+ aCurr = aWork[nWork ^= 1];
+
+ gam += delta_gam;
+}
+
+
+
+/**************************************************************************
+ * *
+ * P U B L I C F U N C T I O N S *
+ * *
+ **************************************************************************/
+
+void screenhack(disp, win)
+ Display *disp;
+ Window win;
+{
+ dpy = disp;
+ window = win;
+ initLMorph();
+ for (;;) {
+ animateLMorph();
+ screenhack_usleep(delay);
+ }
+}
--- /dev/null
+.TH LMORPH 1 "xscreensaver hack"
+.SH NAME
+lmorph \- morphing lines
+.SH SYNOPSIS
+.B lmorph
+[\-display \fIhost:display.screen\fP] [\-foreground \fIcolor\fP] [\-background \fIcolor\fP] [\-window] [\-root] [\-mono] [\-install] [\-visual \fIvisual\fP] [\-points \fIint\fP] [\-steps \fIint\fP] [\-delay \fIusecs\fP]
+.SH DESCRIPTION
+The \fIlmorph\fP program morphs between simple linedrawings using bilinear
+interpolation.
+.SH OPTIONS
+.I lmorph
+accepts the following options:
+.TP 8
+.B \-window
+Draw on a newly-created window. This is the default.
+.TP 8
+.B \-root
+Draw on the root window.
+.TP 8
+.B \-mono
+If on a color display, pretend we're on a monochrome display.
+.TP 8
+.B \-install
+Install a private colormap for the window.
+.TP 8
+.B \-visual \fIvisual\fP
+Specify which visual to use. Legal values are the name of a visual class,
+or the id number (decimal or hex) of a specific visual.
+.TP 8
+.B \-points \fIinteger\fP
+Number of points in each line drawing. Default is 150 points.
+.TP 8
+.B \-steps \fIinteger\fP
+Interpolation steps from one drawing to the next. Default is 0, which
+means a random number between 100 and 500.
+.TP 8
+.B \-delay \fImicroseconds\fP
+How much of a delay should be introduced between steps of the animation.
+Default 50000.
+.SH ENVIRONMENT
+.PP
+.TP 8
+.B DISPLAY
+to get the default host and display number.
+.TP 8
+.B XENVIRONMENT
+to get the name of a resource file that overrides the global resources
+stored in the RESOURCE_MANAGER property.
+.SH SEE ALSO
+.BR X (1),
+.BR xscreensaver (1)
+.SH AUTHOR
+Sverre H. Huseby <sverrehu@ifi.uio.no> and Glenn T. Lines <gtl@si.sintef.no>,
+built on top of the screen saver routines by Jamie Zawinski <jwz@netscape.com>.
/******************************************************************************
* [ maze ] ...
*
- * modified: [ 3-7-93 ] Jamie Zawinski <jwz@mcom.com>
+ * modified: [ 8-11-95 ] Ed James <james@mml.mmc.com>
+ * added fill of dead-end box to solve_maze while loop.
+ * modified: [ 3-7-93 ] Jamie Zawinski <jwz@netscape.com>
* added the XRoger logo, cleaned up resources, made
* grid size a parameter.
* modified: [ 3-3-93 ] Jim Randell <jmr@mddjmr.fc.hp.com>
static void
create_maze() /* create a maze layout given the intiialized maze */
{
- register int i, newdoor;
+ register int i, newdoor = 0;
do {
move_list[sqnum].x = cur_sq_x;
/* do it */
while (1) {
if ( ++path[i].dir >= 4 ) {
+ XFillRectangle(dpy, win, cgc,
+ border_x + bw + grid_width * (int)(path[i].x),
+ border_y + bw + grid_height * (int)(path[i].y),
+ grid_width - (bw+bw), grid_height - (bw+bw));
i--;
draw_solid_square( (int)(path[i].x), (int)(path[i].y),
(int)(path[i].dir), cgc);
/*
- * jmr additions for Jamie Zawinski's <jwz@mcom.com> screensaver stuff,
+ * jmr additions for Jamie Zawinski's <jwz@netscape.com> screensaver stuff,
* note that the code above this has probably been hacked about in some
* arbitrary way.
*/
-/* xscreensaver, Copyright (c) 1992 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1992 Jamie Zawinski <jwz@netscape.com>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
Dan Heller <argv@sun.com>, 1985.
Ability to run standalone or with \fIxscreensaver\fP added by
-Jamie Zawinski <jwz@mcom.com>, 13-aug-92.
+Jamie Zawinski <jwz@netscape.com>, 13-aug-92.
-/nose.0.left/1.1/Mon Dec 19 04:30:41 1994 Thu Aug 25 15:04:28 1994//
-/nose.0.right/1.1/Mon Dec 19 04:30:41 1994 Thu Aug 25 15:04:29 1994//
-/nose.1.left/1.1/Mon Dec 19 04:30:41 1994 Thu Aug 25 15:04:30 1994//
-/nose.1.right/1.1/Mon Dec 19 04:30:41 1994 Thu Aug 25 15:04:31 1994//
-/nose.down/1.1/Mon Dec 19 04:30:41 1994 Thu Aug 25 15:04:32 1994//
-/nose.front/1.1/Mon Dec 19 04:30:41 1994 Thu Aug 25 15:04:33 1994//
-/nose.left.front/1.1/Mon Dec 19 04:30:41 1994 Thu Aug 25 15:04:34 1994//
-/nose.right.front/1.1/Mon Dec 19 04:30:41 1994 Thu Aug 25 15:04:35 1994//
+/nose.0.left/1.1/Fri Mar 17 18:30:19 1995 Thu Aug 25 15:04:28 1994//
+/nose.0.right/1.1/Fri Mar 17 18:30:19 1995 Thu Aug 25 15:04:29 1994//
+/nose.1.left/1.1/Fri Mar 17 18:30:20 1995 Thu Aug 25 15:04:30 1994//
+/nose.1.right/1.1/Fri Mar 17 18:30:20 1995 Thu Aug 25 15:04:31 1994//
+/nose.down/1.1/Fri Mar 17 18:30:20 1995 Thu Aug 25 15:04:32 1994//
+/nose.front/1.1/Fri Mar 17 18:30:20 1995 Thu Aug 25 15:04:33 1994//
+/nose.left.front/1.1/Fri Mar 17 18:30:20 1995 Thu Aug 25 15:04:34 1994//
+/nose.right.front/1.1/Fri Mar 17 18:30:20 1995 Thu Aug 25 15:04:35 1994//
* should be dark.
*/
char *defaults [] = {
+ "Pedal.background: black", /* to placate SGI */
+ "Pedal.foreground: white",
"*delay: 5",
"*fadedelay: 200000",
"*maxlines: 1000",
- "*foreground: white",
- "*background: black",
0
};
-/* xscreensaver, Copyright (c) 1992, 1994 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1992, 1994 Jamie Zawinski <jwz@netscape.com>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
suitability of this software for any purpose. It is provided "as is" without
express or implied warranty.
.SH AUTHOR
-Jamie Zawinski <jwz@mcom.com>, 13-aug-92.
+Jamie Zawinski <jwz@netscape.com>, 13-aug-92.
-/* xscreensaver, Copyright (c) 1992 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1992, 1995 Jamie Zawinski <jwz@netscape.com>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
if (!mono_p && !transparent_p)
{
+ XColor desired;
cycle_hue (&qline->color, color_shift);
qline->color.flags = DoRed | DoGreen | DoBlue;
- if (!XAllocColor (dpy, cmap, &qline->color))
+ desired = qline->color;
+ if (XAllocColor (dpy, cmap, &qline->color))
+ {
+ /* XAllocColor returns the actual RGB that the hardware let us
+ allocate. Restore the requested values into the XColor struct
+ so that limited-resolution hardware doesn't cause cycle_hue to
+ get "stuck". */
+ qline->color.red = desired.red;
+ qline->color.green = desired.green;
+ qline->color.blue = desired.blue;
+ }
+ else
{
qline->color = prev_qline->color;
if (!XAllocColor (dpy, cmap, &qline->color))
suitability of this software for any purpose. It is provided "as is" without
express or implied warranty.
.SH AUTHOR
-Jamie Zawinski <jwz@mcom.com>, 13-aug-92.
+Jamie Zawinski <jwz@netscape.com>, 13-aug-92.
-/* xscreensaver, Copyright (c) 1992 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1992, 1995 Jamie Zawinski <jwz@netscape.com>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
John Nguyen <johnn@hx.lcs.mit.edu>
*/
-#include "screenhack.h"
#include <stdio.h>
#include <math.h>
-#if __STDC__
-#include <math.h> /* for M_PI */
-#endif
+#include "screenhack.h"
#define MIN_DEPTH 2 /* rocks disappar when they get this close */
#define MAX_DEPTH 60 /* this is where rocks appear */
{
int i;
XGCValues gcv;
- GC fg_gc = 0, bg_gc;
+ GC fg_gc = 0, bg_gc = 0;
pixmaps [0] = pixmaps [1] = 0;
for (i = MIN_DEPTH; i < MAX_WIDTH; i++)
{
.SH AUTHOR
Based on Lisp Machine code copyright 1988 John Nguyen <johnn@hx.lcs.mit.edu>.
-Ported to C and X by Jamie Zawinski <jwz@mcom.com>, 13-aug-92.
+Ported to C and X by Jamie Zawinski <jwz@netscape.com>, 13-aug-92.
-/* xscreensaver, Copyright (c) 1992 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1992 Jamie Zawinski <jwz@netscape.com>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
suitability of this software for any purpose. It is provided "as is" without
express or implied warranty.
.SH AUTHOR
-Jamie Zawinski <jwz@mcom.com>, 13-aug-92.
+Jamie Zawinski <jwz@netscape.com>, 13-aug-92.
-/* xscreensaver, Copyright (c) 1992, 1995 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1992, 1995 Jamie Zawinski <jwz@netscape.com>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
-/* xscreensaver, Copyright (c) 1992-1995 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1992-1995 Jamie Zawinski <jwz@netscape.com>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
#include <stdlib.h>
#endif
+#ifdef __hpux
+ /* Which of the ten billion standards does values.h belong to?
+ What systems always have it? */
+# include <values.h>
+#endif
+
#include <X11/Xlib.h>
#include <X11/Xresource.h>
#include <X11/Xos.h>
extern int options_size;
extern char *defaults [];
-#if __STDC__
-# if (defined(SVR4) || defined(SYSV)) && !defined(__sgi)
-# ifndef random
- extern int rand (void);
-# define random() rand()
-# endif
-# ifndef srandom
- extern void srand (unsigned int);
-# define srandom(i) srand((unsigned int)(i))
-# endif
-# else /* !totally-losing-SYSV */
-# ifndef random
- extern long random (void);
-# endif
-# ifndef srandom
- extern int srandom (unsigned int);
-# endif
-# endif /* !totally-losing-SYSV */
-#endif /* __STDC__ */
+/* Screw it, we'll just use our own RNG. See xscreensaver/utils/yarandom.c. */
+#include "yarandom.h"
+
+#undef P
#if __STDC__
# define P(x)x
#else
extern void copy_default_colormap_contents P((Display *dpy, Colormap to_cmap,
Visual *to_visual));
+#if defined (__GNUC__) && (__GNUC__ >= 2)
+ /* Implement frand using GCC's statement-expression extension. */
+
+# define frand(f) \
+ ({ double tmp = (((double) random()) / \
+ (((double) ((unsigned int)~0)) / ((double) (f+f)))); \
+ tmp < 0 ? (-tmp) : tmp; })
+
+#else /* not GCC2 - implement frand using a global variable.*/
+
static double _frand_tmp_;
-#define frand(f) \
- (_frand_tmp_ = (((double) random()) / \
- (((double) ((unsigned int)~0)) / ((double) (f+f)))), \
- _frand_tmp_ < 0 ? (-_frand_tmp_) : _frand_tmp_)
+# define frand(f) \
+ (_frand_tmp_ = (((double) random()) / \
+ (((double) ((unsigned int)~0)) / ((double) (f+f)))), \
+ _frand_tmp_ < 0 ? (-_frand_tmp_) : _frand_tmp_)
+
+#endif /* not GCC2 */
#undef P
#endif /* _SCREENHACK_H_ */
-/* xscreensaver, Copyright (c) 1992, 1993, 1994 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1992, 1993, 1994
+ * Jamie Zawinski <jwz@netscape.com>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
suitability of this software for any purpose. It is provided "as is" without
express or implied warranty.
.SH AUTHOR
-Jamie Zawinski <jwz@mcom.com>, 3-dec-92.
+Jamie Zawinski <jwz@netscape.com>, 3-dec-92.
** for xlock 2.3 and xscreensaver 1.2, 28AUG92
**
**
+** Modified for xlockmore 3.0 by Anthony Thyssen <anthony@cit.gu.edu.au>
+** on August 1995.
+**
** To use, just copy the appropriate file from xlock, add a target
** for it in the Imakefile, and do the following:
**
static int batchcount;
static unsigned int delay;
+static unsigned int cycles;
static double saturation;
+#ifndef min
+#define min(a,b) ((a)<(b)?(a):(b))
+#endif
+
typedef struct {
GC gc;
int npixels;
bg_pixel = get_pixel_resource ("background", "Background", dpy, cmap);
if (! mono_p) {
for (npixels = 0; npixels < i; npixels++) {
- hsv_to_rgb ((360*npixels)/i, saturation, 1.0, &color.red, &color.green, &color.blue);
+ hsv_to_rgb ((360*npixels)/i, saturation, 1.0,
+ &color.red, &color.green, &color.blue);
if (! XAllocColor (dpy, cmap, &color))
break;
pixels[npixels] = color.pixel;
n = get_integer_resource ("count", "Integer");
if (n > 0) batchcount = n;
+ n = get_integer_resource ("cycles", "Integer");
+ if (n >= 0) cycles = n;
+
gcv.foreground = fg_pixel;
gcv.background = bg_pixel;
gc = XCreateGC (dpy, win, GCForeground|GCBackground, &gcv);
"*foreground: white",
"*ncolors: 64",
"*delay: -1",
+ "*count: -1",
+ "*cycles: -1",
0
};
{"-count", ".count", XrmoptionSepArg, 0},
{"-ncolors", ".ncolors", XrmoptionSepArg, 0},
{"-delay", ".delay", XrmoptionSepArg, 0},
+ {"-cycles", ".cycles", XrmoptionSepArg, 0},
};
int options_size = (sizeof (options) / sizeof (options[0]));
-#define PROGRAM(Y,Z,D,B,S) \
+#define PROGRAM(Y,Z,D,B,C,S) \
char *progclass = Y; \
\
void screenhack (dpy, window) \
{ \
batchcount = B; \
delay = D; \
+ cycles = C; \
saturation = S; \
dsp = dpy; \
\
+ init##Z (window); \
while (1) { \
- init##Z (window); \
- for (;;) { \
- draw##Z (window); \
- XSync (dpy, True); \
- if (delay) usleep (delay); \
- } \
+ draw##Z (window); \
+ XSync (dpy, True); \
+ if (delay) usleep (delay); \
} \
}
-/* xscreensaver, Copyright (c) 1991-1994 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1991-1994 Jamie Zawinski <jwz@netscape.com>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
the suitability of fnord this software for any purpose. It is provided "as
is" without express or fnord implied warranty.
.SH AUTHOR
-Jamie Zawinski <jwz@mcom.com>, 13-aug-92.
+Jamie Zawinski <jwz@netscape.com>, 13-aug-92.
DEFINES = R5ISMS
#endif
SRCS = fade.c hsv.c resources.c spline.c usleep.c xroger.c \
- grabscreen.c visual.c
+ grabscreen.c visual.c yarandom.c
OBJS = fade.o hsv.o resources.o spline.o usleep.o xroger.o \
- grabscreen.o visual.o
- TARFILES = README Imakefile ad2c $(SRCS) spline.h version.h
+ grabscreen.o visual.o yarandom.o
+ TARFILES = README Imakefile ad2c $(SRCS) spline.h yarandom.h version.h
all:: $(OBJS)
-/* xscreensaver, Copyright (c) 1992 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1992 Jamie Zawinski <jwz@netscape.com>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
-/* xscreensaver, Copyright (c) 1992, 1993, 1994 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1992, 1993, 1994 Jamie Zawinski <jwz@netscape.com>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
-/* xscreensaver, Copyright (c) 1992 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1992 Jamie Zawinski <jwz@netscape.com>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
-/* xscreensaver, Copyright (c) 1992 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1992 Jamie Zawinski <jwz@netscape.com>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
-/* xscreensaver, Copyright (c) 1992 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1992 Jamie Zawinski <jwz@netscape.com>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
static char *screensaver_id =
- "@(#)xscreensaver 1.25, by Jamie Zawinski (jwz@mcom.com)";
+ "@(#)xscreensaver 1.26, by Jamie Zawinski (jwz@netscape.com)";
-/* xscreensaver, Copyright (c) 1993, 1994, 1995 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1993, 1994, 1995
+ * Jamie Zawinski <jwz@netscape.com>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
-/* xscreensaver, Copyright (c) 1991-1993 Jamie Zawinski <jwz@mcom.com>
+/* xscreensaver, Copyright (c) 1991-1993 Jamie Zawinski <jwz@netscape.com>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
--- /dev/null
+/* ya_random -- Yet Another Random Number Generator.
+
+ The unportable mess that is rand(), random(), drand48() and friends led me
+ to ask Phil Karlton <karlton@netscape.com> what the Right Thing to Do was.
+ He responded with this. It is non-cryptographically secure, reasonably
+ random (more so than anything that is in any C library), and very fast.
+
+ I don't understand how it works at all, but he says "look at Knuth,
+ Vol. 2 (original edition), page 26, Algorithm A. In this case n=55,
+ k=20 and m=2^32."
+
+ So there you have it.
+ */
+
+#include <unistd.h> /* for getpid() */
+#include <sys/time.h> /* for gettimeofday() */
+
+
+/* The following 'random' numbers are taken from CRC, 18th Edition, page 622.
+ Each array element was taken from the corresponding line in the table,
+ except that a[0] was from line 100. 8s and 9s in the table were simply
+ skipped. The high order digit was taken mod 4.
+ */
+#define VectorSize 55
+static unsigned int a[VectorSize] = {
+ 035340171546, 010401501101, 022364657325, 024130436022, 002167303062, /* 5 */
+ 037570375137, 037210607110, 016272055420, 023011770546, 017143426366, /* 10 */
+ 014753657433, 021657231332, 023553406142, 004236526362, 010365611275, /* 14 */
+ 007117336710, 011051276551, 002362132524, 001011540233, 012162531646, /* 20 */
+ 007056762337, 006631245521, 014164542224, 032633236305, 023342700176, /* 25 */
+ 002433062234, 015257225043, 026762051606, 000742573230, 005366042132, /* 30 */
+ 012126416411, 000520471171, 000725646277, 020116577576, 025765742604, /* 35 */
+ 007633473735, 015674255275, 017555634041, 006503154145, 021576344247, /* 40 */
+ 014577627653, 002707523333, 034146376720, 030060227734, 013765414060, /* 45 */
+ 036072251540, 007255221037, 024364674123, 006200353166, 010126373326, /* 50 */
+ 015664104320, 016401041535, 016215305520, 033115351014, 017411670323 /* 55 */
+};
+
+static int i1, i2;
+
+unsigned int ya_random()
+{
+ register int ret = a[i1] + a[i2];
+ a[i1] = ret;
+ i1 = i1 >= VectorSize ? 0 : i1 + 1;
+ i2 = i2 >= VectorSize ? 0 : i2 + 1;
+ return ret;
+}
+
+void ya_rand_init(seed)
+ register unsigned int seed;
+{
+ int i;
+ if (seed == 0)
+ {
+ struct timeval tp;
+ struct timezone tzp;
+ gettimeofday(&tp, &tzp);
+ /* ignore overflow */
+ seed = (999*tp.tv_sec) + (1001*tp.tv_usec) + (1003 * getpid());
+ }
+
+ a[0] += seed;
+ for (i = 1; i < VectorSize; i++)
+ {
+ seed = a[i-1]*1001 + seed*999;
+ a[i] += seed;
+ }
+
+ i1 = a[0] % VectorSize;
+ i2 = (i1 + 024) % VectorSize;
+}
--- /dev/null
+#undef random
+#undef rand
+#undef drand48
+#undef srandom
+#undef srand
+#undef srand48
+
+#define random() ya_random()
+#define srandom(i) ya_rand_init(0)
+
+#undef P
+#if __STDC__
+# define P(x)x
+#else
+# define P(x)()
+#endif
+
+extern unsigned int ya_random P((void));
+extern void ya_rand_init P((unsigned int));