removed unused crap

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Daniel Stenberg 2002-03-26 13:44:16 +00:00
parent 3066991c06
commit e35c0b3dbf
4 changed files with 1 additions and 260 deletions

View file

@ -28,8 +28,7 @@ LDFLAGS = -lX11 -lm -lXt -lXmu -lsocket -lnsl
DEPEND = .depends
OBJS= alpha.o screenhack.o yarandom.o uibasic.o resources.o visual.o\
lcd.o lcd-x11.o
OBJS= screenhack.o uibasic.o resources.o visual.o lcd.o lcd-x11.o
SRCS = $(OBJS:%.o=%.c)
HDRS = $(OBJS:%.o=%.h)

View file

@ -1,137 +0,0 @@
/* xscreensaver, Copyright (c) 1992, 1995, 1996, 1997
* 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
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation. No representations are made about the suitability of this
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*/
/* Beauty is only skin deep, unless you've got an alpha channel. */
#include "utils.h"
#include "alpha.h"
#include "visual.h"
#include "hsv.h"
#include "yarandom.h"
#include "resources.h"
#include <X11/Xutil.h>
#ifndef countof
# define countof(x) (sizeof(*(x))/sizeof((x)))
#endif
/* I don't believe this fucking language doesn't have builtin exponentiation.
I further can't believe that the fucking ^ character means fucking XOR!! */
static int
i_exp (int i, int j)
{
int k = 1;
while (j--) k *= i;
return k;
}
static void
merge_colors (int argc, XColor **argv, XColor *into_color, int mask,
Bool additive_p)
{
int j;
*into_color = *argv [0];
into_color->pixel |= mask;
for (j = 1; j < argc; j++)
{
# define SHORT_INC(x,y) (x = ((((x)+(y)) > 0xFFFF) ? 0xFFFF : ((x)+(y))))
# define SHORT_DEC(x,y) (x = ((((x)-(y)) < 0) ? 0 : ((x)-(y))))
if (additive_p)
{
SHORT_INC (into_color->red, argv[j]->red);
SHORT_INC (into_color->green, argv[j]->green);
SHORT_INC (into_color->blue, argv[j]->blue);
}
else
{
SHORT_DEC (into_color->red, argv[j]->red);
SHORT_DEC (into_color->green, argv[j]->green);
SHORT_DEC (into_color->blue, argv[j]->blue);
}
# undef SHORT_INC
# undef SHORT_DEC
}
}
static void
permute_colors (XColor *pcolors, XColor *colors,
int count,
unsigned long *plane_masks,
Bool additive_p)
{
int out = 0;
int max = i_exp (2, count);
if (count > 31) abort ();
for (out = 1; out < max; out++)
{
XColor *argv [32];
int this_mask = 0;
int argc = 0;
int bit;
for (bit = 0; bit < 32; bit++)
if (out & (1<<bit))
{
argv [argc++] = &pcolors [bit];
this_mask |= plane_masks [bit];
}
merge_colors (argc, argv, &colors [out-1], this_mask, additive_p);
}
}
static int
allocate_color_planes (Display *dpy, Colormap cmap,
int nplanes, unsigned long *plane_masks,
unsigned long *base_pixel_ret)
{
while (nplanes > 1 &&
!XAllocColorCells (dpy, cmap, False, plane_masks, nplanes,
base_pixel_ret, 1))
nplanes--;
return nplanes;
}
static void
initialize_transparency_colormap (Display *dpy, Colormap cmap,
int nplanes,
unsigned long base_pixel,
unsigned long *plane_masks,
XColor *colors,
Bool additive_p)
{
int i;
int total_colors = i_exp (2, nplanes);
XColor *all_colors = (XColor *) calloc (total_colors, sizeof (XColor));
for (i = 0; i < nplanes; i++)
colors[i].pixel = base_pixel | plane_masks [i];
permute_colors (colors, all_colors, nplanes, plane_masks, additive_p);
/* clone the default background of the window into our "base" pixel */
all_colors [total_colors - 1].pixel =
get_pixel_resource ("background", "Background", dpy, cmap);
XQueryColor (dpy, cmap, &all_colors [total_colors - 1]);
all_colors [total_colors - 1].pixel = base_pixel;
for (i = 0; i < total_colors; i++)
all_colors[i].flags = DoRed|DoGreen|DoBlue;
XStoreColors (dpy, cmap, all_colors, total_colors);
XFree ((XPointer) all_colors);
}

View file

@ -570,12 +570,6 @@ main (int argc, char **argv)
XSync (dpy, False);
/* This is the one and only place that the random-number generator is
seeded in any screenhack. You do not need to seed the RNG again,
it is done for you before your code is invoked. */
# undef ya_rand_init
ya_rand_init ((int) time ((time_t *) 0));
screenhack (dpy, window); /* doesn't return */
return 0;
}

View file

@ -1,115 +0,0 @@
/* yarandom.c -- 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.
---------------------------
Note: xlockmore 4.03a10 uses this very simple RNG:
if ((seed = seed % 44488 * 48271 - seed / 44488 * 3399) < 0)
seed += 2147483647;
return seed-1;
of which it says
``Dr. Park's algorithm published in the Oct. '88 ACM "Random Number
Generators: Good Ones Are Hard To Find" His version available at
ftp://cs.wm.edu/pub/rngs.tar Present form by many authors.''
Karlton says: ``the usual problem with that kind of RNG turns out to
be unexepected short cycles for some word lengths.''
Karlton's RNG is faster, since it does three adds and two stores, while the
xlockmore RNG does two multiplies, two divides, three adds, and one store.
Compiler optimizations make a big difference here:
gcc -O: difference is 1.2x.
gcc -O2: difference is 1.4x.
gcc -O3: difference is 1.5x.
SGI cc -O: difference is 2.4x.
SGI cc -O2: difference is 2.4x.
SGI cc -O3: difference is 5.1x.
Irix 6.2; Indy r5k; SGI cc version 6; gcc version 2.7.2.1.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h> /* for getpid() */
#endif
#include <sys/time.h> /* for gettimeofday() */
#include "yarandom.h"
# undef ya_rand_init
/* 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 (void)
{
register int ret = a[i1] + a[i2];
a[i1] = ret;
if (++i1 >= VectorSize) i1 = 0;
if (++i2 >= VectorSize) i2 = 0;
return ret;
}
void
ya_rand_init(unsigned int seed)
{
int i;
if (seed == 0)
{
struct timeval tp;
#ifdef GETTIMEOFDAY_TWO_ARGS
struct timezone tzp;
gettimeofday(&tp, &tzp);
#else
gettimeofday(&tp);
#endif
/* 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;
}