xroach/ 40755 0 0 0 5555611600 10350 5ustar rootwheelxroach/Makefile100444 0 0 244 5405224000 12047 0ustar rootwheel# @(#)Makefile 8.1 (Berkeley) 6/8/93 PROG= xroach MAN6= xroach.0 CFLAGS+= -I${.CURDIR}/bitmaps DPADD= ${LIBX} ${LIBM} LDADD= -lX11/X11 -lm .include xroach/obj120755 0 0 0 7056401207 15020 2/usr/obj/games/xroachustar rootwheelxroach/roachmap.h100444 0 0 4624 5021040200 12370 0ustar rootwheel#include "roach000.xbm" #include "roach015.xbm" #include "roach030.xbm" #include "roach045.xbm" #include "roach060.xbm" #include "roach075.xbm" #include "roach090.xbm" #include "roach105.xbm" #include "roach120.xbm" #include "roach135.xbm" #include "roach150.xbm" #include "roach165.xbm" #include "roach180.xbm" #include "roach195.xbm" #include "roach210.xbm" #include "roach225.xbm" #include "roach240.xbm" #include "roach255.xbm" #include "roach270.xbm" #include "roach285.xbm" #include "roach300.xbm" #include "roach315.xbm" #include "roach330.xbm" #include "roach345.xbm" #define ROACH_HEADINGS 24 /* number of orientations */ #define ROACH_ANGLE 15 /* angle between orientations */ typedef struct RoachMap { char *roachBits; Pixmap pixmap; int width; int height; float sine; float cosine; } RoachMap; RoachMap roachPix[] = { {roach000_bits, None, roach000_height, roach000_width, 0.0, 0.0}, {roach015_bits, None, roach015_height, roach015_width, 0.0, 0.0}, {roach030_bits, None, roach030_height, roach030_width, 0.0, 0.0}, {roach045_bits, None, roach045_height, roach045_width, 0.0, 0.0}, {roach060_bits, None, roach060_height, roach060_width, 0.0, 0.0}, {roach075_bits, None, roach075_height, roach075_width, 0.0, 0.0}, {roach090_bits, None, roach090_height, roach090_width, 0.0, 0.0}, {roach105_bits, None, roach105_height, roach105_width, 0.0, 0.0}, {roach120_bits, None, roach120_height, roach120_width, 0.0, 0.0}, {roach135_bits, None, roach135_height, roach135_width, 0.0, 0.0}, {roach150_bits, None, roach150_height, roach150_width, 0.0, 0.0}, {roach165_bits, None, roach165_height, roach165_width, 0.0, 0.0}, {roach180_bits, None, roach180_height, roach180_width, 0.0, 0.0}, {roach195_bits, None, roach195_height, roach195_width, 0.0, 0.0}, {roach210_bits, None, roach210_height, roach210_width, 0.0, 0.0}, {roach225_bits, None, roach225_height, roach225_width, 0.0, 0.0}, {roach240_bits, None, roach240_height, roach240_width, 0.0, 0.0}, {roach255_bits, None, roach255_height, roach255_width, 0.0, 0.0}, {roach270_bits, None, roach270_height, roach270_width, 0.0, 0.0}, {roach285_bits, None, roach285_height, roach285_width, 0.0, 0.0}, {roach300_bits, None, roach300_height, roach300_width, 0.0, 0.0}, {roach315_bits, None, roach315_height, roach315_width, 0.0, 0.0}, {roach330_bits, None, roach330_height, roach330_width, 0.0, 0.0}, {roach345_bits, None, roach345_height, roach345_width, 0.0, 0.0}, }; xroach/tags100444 0 0 1344 5760222600 11322 0ustar rootwheelAddRoach xroach.c /^AddRoach()$/ AllocNamedColor xroach.c /^AllocNamedColor(colorName, dfltPix)$/ CalcRootVisible xroach.c /^CalcRootVisible()$/ CoverRoot xroach.c /^CoverRoot()$/ DrawRoaches xroach.c /^DrawRoaches()$/ MarkHiddenRoaches xroach.c /^MarkHiddenRoaches()$/ MoveRoach xroach.c /^MoveRoach(rx)$/ Mxroach xroach.c /^main(ac, av)$/ RandInt xroach.c /^RandInt(maxVal)$/ RoachErrors xroach.c /^RoachErrors(dpy, err)$/ RoachInRect xroach.c /^RoachInRect(roach, rx, ry, x, y, width, height)$/ RoachOverRect xroach.c /^RoachOverRect(roach, rx, ry, x, y, width, height)$/ SigHandler xroach.c /^SigHandler()$/ TurnRoach xroach.c /^TurnRoach(roach)$/ USEPRT xroach.c /^#define USEPRT(msg) fprintf(stderr, msg)$/ Usage xroach.c /^Usage()$/ xroach/xroach.6100444 0 0 6070 5554617400 12024 0ustar rootwheel.\" Copyright (c) 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" from: X Version 11 Release 4, May 30, 1991 .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)xroach.6 8.2 (Berkeley) 4/19/94 .\" .TH XROACH 6 "April 19, 1994" "X Version 11 Release 4" .SH NAME xroach \- cockroaches hide under your windows .SH SYNOPSIS .B xroach [-option .,..] .SH DESCRIPTION .I Xroach displays disgusting cockroaches on your root window. These creepy crawlies scamper around until they find a window to hide under. Whenever you move or iconify a window, the exposed beetles again scamper for cover. .SH OPTIONS .TP 8 .B \-display \fIdisplay_name\fB Drop the roaches on the given display. Make sure the display is nearby, so you can hear the screams. .TP 8 .B \-rc \fIroach_color\fB Use the given string as the color for the bugs instead of the default "black". .TP 8 .B \-speed \fIroach_speed\fB Use the given speed for the insects instead of the default 20.0. For example, in winter the speed should be set to 5.0. In summer, 30.0 might be about right. .TP 8 .B \-roaches \fInum_roaches\fB This is the number of the little critters. Default is 10. .SH BUGS As given by the -roaches option. Default is 10. .SH COPYRIGHT Copyright 1991 by J.T. Anderson .SH AUTHORS J.T. Anderson (jta@locus.com) .SH DEDICATION Greg McFarlane (gregm@otc.otca.oz.au) .SH "SEE ALSO" xroachmotel(1), xddt(1) xroach/xroach.c100444 0 0 27115 5403510200 12103 0ustar rootwheel/* Xroach - A game of skill. Try to find the roaches under your windows. Copyright 1991 by J.T. Anderson jta@locus.com This program may be freely distributed provided that all copyright notices are retained. To build: cc -o xroach roach.c -lX11 [-lsocketorwhatever] [-lm] [-l...] Dedicated to Greg McFarlane. (gregm@otc.otca.oz.au) */ #include #include #include #include #include #include #include char Copyright[] = "Xroach\nCopyright 1991 J.T. Anderson"; #include "roachmap.h" typedef unsigned long Pixel; typedef int ErrorHandler(); #define SCAMPER_EVENT (LASTEvent + 1) #if !defined(GRAB_SERVER) #define GRAB_SERVER 0 #endif Display *display; int screen; Window rootWin; unsigned int display_width, display_height; int center_x, center_y; GC gc; char *display_name = NULL; Pixel black, white; int done = 0; int eventBlock = 0; int errorVal = 0; typedef struct Roach { RoachMap *rp; int index; float x; float y; int intX; int intY; int hidden; int turnLeft; int steps; } Roach; Roach *roaches; int maxRoaches = 10; int curRoaches = 0; float roachSpeed = 20.0; Region rootVisible = NULL; void Usage(); void SigHandler(); void AddRoach(); void MoveRoach(); void DrawRoaches(); void CoverRoot(); int CalcRootVisible(); int MarkHiddenRoaches(); Pixel AllocNamedColor(); void main(ac, av) int ac; char *av[]; { XGCValues xgcv; int ax; char *arg; RoachMap *rp; int rx; float angle; XEvent ev; char *roachColor = "black"; int nVis; int needCalc; /* Process command line options. */ for (ax=1; axpixmap = XCreateBitmapFromData(display, rootWin, rp->roachBits, rp->width, rp->height); rp->sine = sin(angle); rp->cosine = cos(angle); } roaches = (Roach *)malloc(sizeof(Roach) * maxRoaches); gc = XCreateGC(display, rootWin, 0L, &xgcv); XSetForeground(display, gc, AllocNamedColor(roachColor, black)); XSetFillStyle(display, gc, FillStippled); while (curRoaches < maxRoaches) AddRoach(); XSelectInput(display, rootWin, ExposureMask | SubstructureNotifyMask); needCalc = 1; while (!done) { if (XPending(display)) { XNextEvent(display, &ev); } else { if (needCalc) { needCalc = CalcRootVisible(); } nVis = MarkHiddenRoaches(); if (nVis) { ev.type = SCAMPER_EVENT; } else { DrawRoaches(); eventBlock = 1; XNextEvent(display, &ev); eventBlock = 0; } } switch (ev.type) { case SCAMPER_EVENT: for (rx=0; rxrp->width) > (x + width)) return 0; if (ry < y) return 0; if ((ry + roach->rp->height) > (y + height)) return 0; return 1; } /* Check for roach overlapping specified rectangle. */ int RoachOverRect(roach, rx, ry, x, y, width, height) Roach *roach; int rx; int ry; int x; int y; unsigned int width; unsigned int height; { if (rx >= (x + width)) return 0; if ((rx + roach->rp->width) <= x) return 0; if (ry >= (y + height)) return 0; if ((ry + roach->rp->height) <= y) return 0; return 1; } /* Give birth to a roach. */ void AddRoach() { Roach *r; if (curRoaches < maxRoaches) { r = &roaches[curRoaches++]; r->index = RandInt(ROACH_HEADINGS); r->rp = &roachPix[r->index]; r->x = RandInt(display_width - r->rp->width); r->y = RandInt(display_height - r->rp->height); r->intX = -1; r->intY = -1; r->hidden = 0; r->steps = RandInt(200); r->turnLeft = RandInt(100) >= 50; } } /* Turn a roach. */ void TurnRoach(roach) Roach *roach; { if (roach->index != (roach->rp - roachPix)) return; if (roach->turnLeft) { roach->index += (RandInt(30) / 10) + 1; if (roach->index >= ROACH_HEADINGS) roach->index -= ROACH_HEADINGS; } else { roach->index -= (RandInt(30) / 10) + 1; if (roach->index < 0) roach->index += ROACH_HEADINGS; } } /* Move a roach. */ void MoveRoach(rx) int rx; { Roach *roach; Roach *r2; float newX; float newY; int ii; roach = &roaches[rx]; newX = roach->x + (roachSpeed * roach->rp->cosine); newY = roach->y - (roachSpeed * roach->rp->sine); if (RoachInRect(roach, (int)newX, (int)newY, 0, 0, display_width, display_height)) { roach->x = newX; roach->y = newY; if (roach->steps-- <= 0) { TurnRoach(roach); roach->steps = RandInt(200); } for (ii=rx+1; iiintX, r2->intY, r2->rp->width, r2->rp->height)) { TurnRoach(roach); } } } else { TurnRoach(roach); } } /* Draw all roaches. */ void DrawRoaches() { Roach *roach; int rx; for (rx=0; rxintX >= 0) { XClearArea(display, rootWin, roach->intX, roach->intY, roach->rp->width, roach->rp->height, False); } } for (rx=0; rxhidden) { roach->intX = roach->x; roach->intY = roach->y; roach->rp = &roachPix[roach->index]; XSetStipple(display, gc, roach->rp->pixmap); XSetTSOrigin(display, gc, roach->intX, roach->intY); XFillRectangle(display, rootWin, gc, roach->intX, roach->intY, roach->rp->width, roach->rp->height); } else { roach->intX = -1; } } } /* Cover root window to erase roaches. */ void CoverRoot() { XSetWindowAttributes xswa; long wamask; Window roachWin; xswa.background_pixmap = ParentRelative; xswa.override_redirect = True; wamask = CWBackPixmap | CWOverrideRedirect; roachWin = XCreateWindow(display, rootWin, 0, 0, display_width, display_height, 0, CopyFromParent, InputOutput, CopyFromParent, wamask, &xswa); XLowerWindow(display, roachWin); XMapWindow(display, roachWin); XFlush(display); } #if !GRAB_SERVER int RoachErrors(dpy, err) Display *dpy; XErrorEvent *err; { errorVal = err->error_code; return 0; } #endif /* GRAB_SERVER */ /* Calculate Visible region of root window. */ int CalcRootVisible() { Region covered; Region visible; Window *children; int nChildren; Window dummy; XWindowAttributes wa; int wx; XRectangle rect; int winX, winY; unsigned int winHeight, winWidth; unsigned int borderWidth; unsigned int depth; /* If we don't grab the server, the XGetWindowAttribute or XGetGeometry calls can abort us. On the other hand, the server grabs can make for some annoying delays. */ #if GRAB_SERVER XGrabServer(display); #else XSetErrorHandler(RoachErrors); #endif /* Get children of root. */ XQueryTree(display, rootWin, &dummy, &dummy, &children, &nChildren); /* For each mapped child, add the window rectangle to the covered region. */ covered = XCreateRegion(); for (wx=0; wx