ewhac@well.UUCP (Leo L. Schwab) (06/27/87)
# This is a shell archive. # Remove everything above and including the cut line. # Then run the rest of the file through sh. #----cut here-----cut here-----cut here-----cut here----# #!/bin/sh # shar: Shell Archiver # Run the following text with /bin/sh to create: # ReadMe # ms2.c # This archive created: Thu Jun 11 01:08:43 1987 # By: Craig Norborg (Purdue University Computing Center) cat << \SHAR_EOF > ReadMe Here is a repost of Munching Squares for the Amiga. Now it does more interesting things. 'ms2' takes a single argument, which is any unsigned 16-bit integer. This is the 'seed' value. Interesting seed values include 1, 2, 257, 4369, 4681, 32769, 32784, 5643. Try odd numbers near powers of two. I would have made it more "user-friendly", but in the process of fiddling with a new algorithm, I found a simply gorgeous new basis for a true display hack. Coming soon to a node near you.... Hope you like the new version. MANUFACTURE: Manx 3.4b cc ms2.c ln ms2.o -lc SHAR_EOF cat << \SHAR_EOF > ms2.c /* :ts=8 bk=0 * * ms2.c: Munching Squares for the Amiga, now actually interesting. * * Leo L. Schwab 8706.4 * With a respectful bow and flurry of my cape to Bill Gosper. * (I wonder if Gosper has an Amiga?) */ #include <exec/types.h> #include <intuition/intuition.h> extern void *OpenLibrary(), *OpenScreen(), *OpenWindow(), *GetMsg(); struct NewScreen scrdef = { 0, 0, 256, 256, 1, 0, 1, LACE, CUSTOMSCREEN, NULL, NULL, NULL, NULL }; struct NewWindow windef = { 0, 0, 256, 256, -1, -1, CLOSEWINDOW, WINDOWCLOSE, NULL, NULL, NULL, NULL, /* Filled in later */ NULL, 0, 0, 0, 0, CUSTOMSCREEN }; struct Screen *scr; struct Window *win; void *IntuitionBase, *GfxBase; main (ac, av) int ac; char **av; { register struct RastPort *rp; register unsigned int acc, x, y, seed; void *msg; openstuff (); rp = &scr -> RastPort; SetRast (rp, 0L); SetDrMd (rp, COMPLEMENT); if (++av, --ac) seed = atoi (*av); else seed = 1; acc = 0; while (1) { if (msg = GetMsg (win -> UserPort)) { /* Close gadget */ ReplyMsg (msg); break; } /* Move (rp, 0L, (long) (0 ^ t)); */ acc += seed; x = acc & 0xff; y = ((acc & 0xff00) >> 8) ^ x; WritePixel (rp, (long) x , (long) y); } closestuff (); } openstuff () { if (!(IntuitionBase = OpenLibrary ("intuition.library", 0L))) die ("-=RJ=- is on vacation."); if (!(GfxBase = OpenLibrary ("graphics.library", 0L))) die ("Dale? Are you there?"); if (!(scr = OpenScreen (&scrdef))) die ("Screens aren't happening."); windef.Screen = scr; if (!(win = OpenWindow (&windef))) die ("Window painted shut."); } closestuff () { if (win) CloseWindow (win); if (scr) CloseScreen (scr); if (GfxBase) CloseLibrary (GfxBase); if (IntuitionBase) CloseLibrary (IntuitionBase); } die (str) char *str; { puts (str); closestuff (); exit (20); } SHAR_EOF # End of shell archive exit 0