X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fdemon.c;h=03ddf1f76087341b741709816c59a8c595442d0c;hb=aa75c7476aeaa84cf3abc192b376a8b03c325213;hp=df7ea3e8a501ad1a487a9c09e350c2f86f53b0d8;hpb=a94197e76a5dea5cb60542840809d6c20d0abbf3;p=xscreensaver diff --git a/hacks/demon.c b/hacks/demon.c index df7ea3e8..03ddf1f7 100644 --- a/hacks/demon.c +++ b/hacks/demon.c @@ -1,9 +1,8 @@ /* -*- Mode: C; tab-width: 4 -*- */ /* demon --- David Griffeath's cellular automata */ -#if !defined( lint ) && !defined( SABER ) +#if 0 static const char sccsid[] = "@(#)demon.c 5.00 2000/11/01 xlockmore"; - #endif /*- @@ -47,23 +46,24 @@ static const char sccsid[] = "@(#)demon.c 5.00 2000/11/01 xlockmore"; Triangle 3, 9, or 12 */ +#ifndef HAVE_JWXYZ +# define DO_STIPPLE +#endif + #ifdef STANDALONE -#define MODE_demon -#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 */ +# define MODE_demon +# define DEFAULTS "*delay: 50000 \n" \ + "*count: 0 \n" \ + "*cycles: 1000 \n" \ + "*size: -30 \n" \ + "*ncolors: 64 \n" \ + "*fpsSolid: true \n" \ + "*ignoreRotation: True \n" \ + +# define UNIFORM_COLORS +# include "xlockmore.h" /* in xscreensaver distribution */ #else /* STANDALONE */ -#include "xlock.h" /* in xlockmore distribution */ - +# include "xlock.h" /* in xlockmore distribution */ #endif /* STANDALONE */ #include "automata.h" @@ -78,19 +78,19 @@ static int neighbors; static XrmOptionDescRec opts[] = { - {(char *) "-neighbors", (char *) ".demon.neighbors", XrmoptionSepArg, (caddr_t) NULL} + {"-neighbors", ".demon.neighbors", XrmoptionSepArg, 0} }; static argtype vars[] = { - {(caddr_t *) & neighbors, (char *) "neighbors", (char *) "Neighbors", (char *) DEF_NEIGHBORS, t_Int} + {&neighbors, "neighbors", "Neighbors", DEF_NEIGHBORS, t_Int} }; static OptionStruct desc[] = { - {(char *) "-neighbors num", (char *) "squares 4 or 8, hexagons 6, triangles 3, 9 or 12"} + {"-neighbors num", "squares 4 or 8, hexagons 6, triangles 3, 9 or 12"} }; -ModeSpecOpt demon_opts = +ENTRYPOINT ModeSpecOpt demon_opts = {sizeof opts / sizeof opts[0], opts, sizeof vars / sizeof vars[0], vars, desc}; #ifdef USE_MODULES @@ -165,8 +165,9 @@ drawcell(ModeInfo * mi, int col, int row, unsigned char state) gc = MI_GC(mi); } else { XGCValues gcv; - +#ifdef DO_STIPPLE gcv.stipple = dp->pixmaps[(state - 1) % (NUMSTIPPLES - 1)]; +#endif /* DO_STIPPLE */ gcv.foreground = MI_WHITE_PIXEL(mi); gcv.background = MI_BLACK_PIXEL(mi); XChangeGC(MI_DISPLAY(mi), dp->stippledGC, @@ -227,25 +228,6 @@ addtolist(ModeInfo * mi, int col, int row, unsigned char state) return True; } -#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) @@ -329,7 +311,9 @@ draw_state(ModeInfo * mi, int state) } else { XGCValues gcv; +#ifdef DO_STIPPLE gcv.stipple = dp->pixmaps[(state - 1) % (NUMSTIPPLES - 1)]; +#endif /* DO_STIPPLE */ gcv.foreground = MI_WHITE_PIXEL(mi); gcv.background = MI_BLACK_PIXEL(mi); XChangeGC(MI_DISPLAY(mi), dp->stippledGC, @@ -402,7 +386,6 @@ draw_state(ModeInfo * mi, int state) } } free_state(dp, state); - XFlush(MI_DISPLAY(mi)); return True; } @@ -423,11 +406,10 @@ RandomSoup(ModeInfo * mi) } } -void -init_demon(ModeInfo * mi) +ENTRYPOINT void +init_demon (ModeInfo * mi) { Display *display = MI_DISPLAY(mi); - Window window = MI_WINDOW(mi); int size = MI_SIZE(mi), nk; demonstruct *dp; @@ -440,8 +422,10 @@ init_demon(ModeInfo * mi) dp->generation = 0; dp->redrawing = 0; +#ifdef DO_STIPPLE if (MI_NPIXELS(mi) < NUMSTIPPLES) { - if (dp->stippledGC == None) { + Window window = MI_WINDOW(mi); + if (dp->stippledGC == None) { XGCValues gcv; gcv.fill_style = FillOpaqueStippled; @@ -459,8 +443,13 @@ init_demon(ModeInfo * mi) } } } +#endif /* DO_STIPPLE */ free_struct(dp); +#ifdef HAVE_JWXYZ + jwxyz_XSetAntiAliasing (MI_DISPLAY(mi), MI_GC(mi), False); +#endif + for (nk = 0; nk < NEIGHBORKINDS; nk++) { if (neighbors == plots[0][nk]) { dp->neighbors = plots[0][nk]; @@ -589,8 +578,8 @@ init_demon(ModeInfo * mi) RandomSoup(mi); } -void -draw_demon(ModeInfo * mi) +ENTRYPOINT void +draw_demon (ModeInfo * mi) { int i, j, k, l, mj = 0, ml; demonstruct *dp; @@ -689,7 +678,7 @@ draw_demon(ModeInfo * mi) dp->newcell[i + mj] = dp->oldcell[k + ml]; /* W */ k = (!i) ? dp->ncols - 1 : i - 1; - l = j; + /*l = j;*/ ml = mj; if (dp->oldcell[k + ml] == (int) (dp->oldcell[i + mj] + 1) % dp->states) @@ -859,7 +848,7 @@ draw_demon(ModeInfo * mi) dp->newcell[i + mj] = dp->oldcell[k + ml]; /* EE */ k = (i + 1 == dp->ncols) ? 0 : i + 1; - l = j; + /*l = j;*/ ml = mj; if (dp->oldcell[k + ml] == (int) (dp->oldcell[i + mj] + 1) % dp->states) @@ -891,7 +880,7 @@ draw_demon(ModeInfo * mi) dp->newcell[i + mj] = dp->oldcell[k + ml]; /* WW */ k = (!i) ? dp->ncols - 1 : i - 1; - l = j; + /*l = j;*/ ml = mj; if (dp->oldcell[k + ml] == (int) (dp->oldcell[i + mj] + 1) % dp->states) @@ -939,8 +928,18 @@ draw_demon(ModeInfo * mi) } } } -void -release_demon(ModeInfo * mi) + + +ENTRYPOINT void +reshape_demon(ModeInfo * mi, int width, int height) +{ + XClearWindow (MI_DISPLAY (mi), MI_WINDOW(mi)); + init_demon (mi); +} + + +ENTRYPOINT void +release_demon (ModeInfo * mi) { if (demons != NULL) { int screen; @@ -952,8 +951,8 @@ release_demon(ModeInfo * mi) } } -void -refresh_demon(ModeInfo * mi) +ENTRYPOINT void +refresh_demon (ModeInfo * mi) { demonstruct *dp; @@ -965,4 +964,19 @@ refresh_demon(ModeInfo * mi) dp->redrawpos = 0; } +ENTRYPOINT Bool +demon_handle_event (ModeInfo *mi, XEvent *event) +{ + if (screenhack_event_helper (MI_DISPLAY(mi), MI_WINDOW(mi), event)) + { + reshape_demon (mi, MI_WIDTH(mi), MI_HEIGHT(mi)); + return True; + } + return False; +} + + + +XSCREENSAVER_MODULE ("Demon", demon) + #endif /* MODE_demon */