546N/A * Copyright (c) 1988-91 by Patrick J. Naughton. 546N/A * Permission to use, copy, modify, and distribute this software and its 546N/A * documentation for any purpose and without fee is hereby granted, 546N/A * provided that the above copyright notice appear in all copies and that 546N/A * both that copyright notice and this permission notice appear in 546N/A * supporting documentation. 546N/A * This file is provided AS IS with no warranties of any kind. The author 546N/A * shall have no liability with respect to the infringement of copyrights, 546N/A * trade secrets or any patents by this file or any part thereof. In no 546N/A * event will the author be liable for any lost revenue or profits or 546N/A * other special, indirect and consequential damages. 1513N/A * Copyright (c) 1994, 2015, Oracle and/or its affiliates. All rights reserved. 546N/A * Permission is hereby granted, free of charge, to any person obtaining a 919N/A * copy of this software and associated documentation files (the "Software"), 919N/A * to deal in the Software without restriction, including without limitation 919N/A * the rights to use, copy, modify, merge, publish, distribute, sublicense, 919N/A * and/or sell copies of the Software, and to permit persons to whom the 919N/A * Software is furnished to do so, subject to the following conditions: 919N/A * The above copyright notice and this permission notice (including the next 919N/A * paragraph) shall be included in all copies or substantial portions of the 919N/A * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 919N/A * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 919N/A * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 919N/A * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 919N/A * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 919N/A * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 919N/A * DEALINGS IN THE SOFTWARE. 546N/A * life.c - Conway's game of Life for xlock, the X Window System lockscreen. 546N/A * Copyright (c) 1991 by Patrick J. Naughton. 546N/A * 24-May-91: Added wraparound code from johnson@bugs.comm.mot.com. 546N/A * Made old cells stay blue. 546N/A * Made batchcount control the number of generations till restart. 546N/A * 29-Jul-90: support for multiple screens. 546N/A * 07-Feb-90: remove bogus semi-colon after #include line. 546N/A * 15-Dec-89: Fix for proper skipping of {White,Black}Pixel() in colors. 546N/A * 08-Oct-89: Moved seconds() to an extern. 546N/A * 20-Sep-89: Written (life algorithm courtesy of Jim Graham, flar@sun.com). 546N/A 0, 0,
/* width, height */ 546N/A/* Buffer stores the data for each cell. Each cell is stored as 546N/A * 8 bits representing the presence of a critter in each of it's 546N/A * surrounding 8 cells. There is an empty row and column around 546N/A * the whole array to allow stores without bounds checking as well 546N/A * as an extra row at the end for the fetches into tempbuf. 546N/A * Tempbuf stores the data for the next two rows so that we know 546N/A * the state of those critter before he was modified by the fate 546N/A * of the critters that have already been processed. 546N/A * Agebuf stores the age of each critter. 546N/A/* Fates is a lookup table for the fate of a critter. The 256 546N/A * entries represent the 256 possible combinations of the 8 546N/A * neighbor cells. Each entry is one of BIRTH (create a cell 546N/A * or leave one alive), SAME (leave the cell alive or dead), 546N/A * or DEATH (kill anything in the cell). 546N/A -
3, -
3, -
2, -
3, -
1, -
3,
546N/A -
3, -
2, -
2, -
2, -
1, -
2,
546N/A -
3, -
1, -
2, -
1, -
1, -
1,
546N/A 1,
1,
2,
1,
3,
1,
4,
1,
5,
1,
546N/A -
7, -
3, -
6, -
3, -
2, -
3, -
1, -
3, 0, -
3,
1, -
3,
5, -
3,
6, -
3,
546N/A -
7, -
2, -
5, -
2, -
3, -
2,
2, -
2,
4, -
2,
6, -
2,
546N/A -
5, -
1, -
3, -
1, -
2, -
1,
2, -
1,
4, -
1,
546N/A -
7, 0, -
5, 0, -
3, 0,
2, 0,
4, 0,
6, 0,
546N/A -
7,
1, -
6,
1, -
2,
1, -
1,
1, 0,
1,
1,
1,
5,
1,
6,
1,
546N/A -
6, -
6, -
5, -
6,
6, -
6,
7, -
6,
546N/A -
6, -
5, -
5, -
5,
6, -
5,
7, -
5,
546N/A -
7,
6, -
5,
6,
6,
6,
8,
6,
546N/A -
7,
7, -
5,
7,
6,
7,
8,
7,
546N/A -
7,
8, -
6,
8,
7,
8,
8,
8,
546N/A -
7, -
5, -
3, -
5, -
2, -
5,
546N/A -
8, -
7, -
7, -
7, -
5, -
7,
546N/A -
8, -
6, -
7, -
6, -
4, -
6, -
1, -
6,
546N/A -
4, -
5, -
3, -
5, -
2, -
5, -
1, -
5,
546N/A -
5, -
4, -
3, -
4, 0, -
4,
2, -
4,
3, -
4,
546N/A -
5, -
3, -
1, -
3, 0, -
3,
2, -
3,
3, -
3,
546N/A -
8, -
2, -
7, -
2, -
5, -
2, -
2, -
2, 0, -
2,
546N/A -
8, -
1, -
7, -
1, -
5, -
1, 0, -
1,
546N/A -
4, 0, -
3, 0, -
2, 0, -
1, 0,
546N/A -
3, -
1, -
2, -
1, -
1, -
1,
1, -
1,
2, -
1,
3, -
1,
546N/A -
3, 0, -
2, 0,
1, 0,
2, 0,
546N/A -
3,
1, -
2,
1, -
1,
1,
1,
1,
2,
1,
3,
1,
546N/A -
3, -
1, -
2, -
1, -
1, -
1,
1, -
1,
2, -
1,
3, -
1,
546N/A -
3, 0, -
2, 0,
2, 0,
3, 0,
546N/A -
3,
1, -
2,
1, -
1,
1,
1,
1,
2,
1,
3,
1,
546N/A -
15, 0, -
14, 0, -
13, 0, -
12, 0, -
11, 0,
546N/A -
10, 0, -
9, 0, -
8, 0, -
7, 0, -
6, 0,
546N/A -
5, 0, -
4, 0, -
3, 0, -
2, 0, -
1, 0,
546N/A 4, 0,
3, 0,
2, 0,
1, 0, 0, 0,
546N/A 9, 0,
8, 0,
7, 0,
6, 0,
5, 0,
546N/A 14, 0,
13, 0,
12, 0,
11, 0,
10, 0,
546N/A -
7, -
2, -
6, -
2, -
5, -
2, -
4, -
2, -
3, -
2,
546N/A -
2, -
2, -
1, -
2, 0, -
2,
1, -
2,
2, -
2,
546N/A -
5, -
1, -
4, -
1, -
3, -
1, -
2, -
1, -
1, -
1,
546N/A 0, -
1,
1, -
1,
2, -
1,
3, -
1,
4, -
1,
546N/A -
3, 0, -
2, 0, -
1, 0, 0, 0,
1, 0,
546N/A 2, 0,
3, 0,
4, 0,
5, 0,
6, 0,
546N/A -
10,
1, -
9,
1, -
8,
1, -
7,
1, -
6,
1,
546N/A -
5,
1, -
4,
1, -
3,
1, -
2,
1, -
1,
1,
546N/A -
10,
2, -
9,
2, -
8,
2, -
7,
2, -
6,
2,
546N/A -
5,
2, -
4,
2, -
3,
2, -
2,
2, -
1,
2,
546N/A -
5, 0, -
4, 0, -
3, 0, -
2, 0, -
1, 0,
4, 0,
3, 0,
2, 0,
1, 0, 0, 0,
546N/A -
4, -
4, -
3, -
4, -
2, -
4, -
1, -
4, 0, -
4,
1, -
4,
2, -
4,
3, -
4,
4, -
4,
546N/A -
4, -
2, -
2, -
2, -
1, -
2, 0, -
2,
1, -
2,
2, -
2,
4, -
2,
546N/A -
4, -
1, -
2, -
1,
2, -
1,
4, -
1,
546N/A -
4, 0, -
2, 0, -
1, 0, 0, 0,
1, 0,
2, 0,
4, 0,
546N/A -
4,
1, -
2,
1,
2,
1,
4,
1,
546N/A -
4,
2, -
2,
2, -
1,
2, 0,
2,
1,
2,
2,
2,
4,
2,
546N/A -
4,
4, -
3,
4, -
2,
4, -
1,
4, 0,
4,
1,
4,
2,
4,
3,
4,
4,
4,
546N/A /* if we aren't up to blue yet, then keep aging the cell. */ 546N/A for (i = 0; i <
256; i++) {
546N/A /* copy the first 2 rows to the tempbuf */ 546N/A /* copy the last row to another buffer for wraparound */ 546N/A * generate a randomized shooter aimed roughly toward the center of the 546N/A * screen after timeout.