--- /dev/null
+' Material simulation, simulates shockwaves propagation in gas.\r
+' made by Svjatoslav Agejenko\r
+' in 2003\r
+' homepage: svjatoslav.eu\r
+' email: svjatoslav@svjatoslav.eu\r
+ \r
+DECLARE SUB saveit ()\r
+DECLARE SUB playit ()\r
+DECLARE SUB frmget ()\r
+DECLARE SUB frmsav ()\r
+DECLARE SUB spot (x!, y!, p!)\r
+DECLARE SUB lin (x1!, y1!, x2!, y2!)\r
+DECLARE SUB disp ()\r
+DECLARE SUB start ()\r
+DIM SHARED wal\r
+wal = 9980\r
+\r
+DIM SHARED press(1 TO 100, 1 TO 100)\r
+DIM SHARED spdx(1 TO 100, 1 TO 100)\r
+DIM SHARED spdy(1 TO 100, 1 TO 100)\r
+DIM SHARED spdxp(1 TO 100, 1 TO 100)\r
+DIM SHARED spdyp(1 TO 100, 1 TO 100)\r
+DIM SHARED nam$, frm\r
+DIM SHARED linb AS STRING * 100\r
+frm = 0\r
+\r
+SCREEN 13\r
+PAINT (1, 1), 1\r
+\r
+OPEN "tst.an0" FOR BINARY AS #1\r
+\r
+\r
+start\r
+\r
+1\r
+'disp\r
+\r
+FOR y = 2 TO 99\r
+ FOR x = 2 TO 99\r
+ IF press(x, y) = wal THEN spdx(x - 1, y) = 0: spdy(x, y - 1) = 0: spdx(x, y) = 0: spdy(x, y) = 0: GOTO 3\r
+ spdy(x, y) = spdy(x, y) - (press(x, y) / 500) ' gravitation\r
+\r
+ IF press(x + 1, y) = wal THEN spdx(x, y) = 0: GOTO 2\r
+ spdx(x, y) = (press(x + 1, y) - press(x, y)) / 20 + spdx(x, y)\r
+ 2\r
+ IF press(x, y + 1) = wal THEN spdy(x, y) = 0: GOTO 3\r
+ spdy(x, y) = (press(x, y + 1) - press(x, y)) / 20 + spdy(x, y)\r
+ 3\r
+ NEXT x\r
+NEXT y\r
+\r
+\r
+4\r
+b = 0\r
+FOR y = 2 TO 99\r
+ FOR x = 2 TO 99\r
+ a = press(x, y) + spdx(x, y) + spdy(x, y) - spdx(x - 1, y) - spdy(x, y - 1)\r
+\r
+ IF a = 0 OR ((a < 0) AND (a > -.0001)) THEN\r
+ IF spdx(x, y) < 0 THEN spdx(x, y) = 0\r
+ IF spdy(x, y) < 0 THEN spdy(x, y) = 0\r
+ IF spdx(x - 1, y) > 0 THEN spdx(x - 1, y) = 0\r
+ IF spdy(x, y - 1) > 0 THEN spdy(x, y - 1) = 0\r
+ END IF\r
+\r
+ IF a < 0 THEN\r
+ IF spdx(x, y) < 0 THEN spdx(x, y) = spdx(x, y) / 1.5\r
+ IF spdy(x, y) < 0 THEN spdy(x, y) = spdy(x, y) / 1.5\r
+ IF spdx(x - 1, y) > 0 THEN spdx(x - 1, y) = spdx(x - 1, y) / 1.5\r
+ IF spdy(x, y - 1) > 0 THEN spdy(x, y - 1) = spdy(x, y - 1) / 1.5\r
+ b = 1\r
+ LOCATE 20, 1\r
+ PRINT a\r
+ END IF\r
+ NEXT x\r
+NEXT y\r
+IF b = 1 THEN GOTO 4\r
+\r
+FOR y = 2 TO 99\r
+ FOR x = 2 TO 99\r
+ IF spdx(x, y) > 0 THEN spdxp(x - 1, y) = ((press(x, y) * spdx(x - 1, y)) + (spdx(x, y) * spdx(x, y))) / (press(x, y) + spdx(x, y)) - spdx(x - 1, y)\r
+ IF spdy(x, y) > 0 THEN spdyp(x, y - 1) = ((press(x, y) * spdy(x, y - 1)) + (spdy(x, y) * spdy(x, y))) / (press(x, y) + spdy(x, y)) - spdy(x, y - 1)\r
+ IF spdx(x - 1, y) < 0 THEN spdxp(x, y) = ((press(x, y) * spdx(x, y)) - (spdx(x - 1, y) * spdx(x - 1, y))) / (press(x, y) - spdx(x - 1, y)) - spdx(x, y)\r
+ IF spdy(x, y - 1) < 0 THEN spdyp(x, y) = ((press(x, y) * spdy(x, y)) - (spdy(x, y - 1) * spdy(x, y - 1))) / (press(x, y) - spdy(x, y - 1)) - spdy(x, y)\r
+ NEXT x\r
+NEXT y\r
+\r
+\r
+FOR y = 2 TO 99\r
+ FOR x = 2 TO 99\r
+ press(x + 1, y) = press(x + 1, y) - spdx(x, y)\r
+ press(x, y + 1) = press(x, y + 1) - spdy(x, y)\r
+ press(x, y) = press(x, y) + spdx(x, y)\r
+ press(x, y) = press(x, y) + spdy(x, y)\r
+ NEXT x\r
+NEXT y\r
+\r
+FOR y = 2 TO 99\r
+ FOR x = 2 TO 99\r
+ spdx(x, y) = spdx(x, y) + spdxp(x, y)\r
+ spdxp(x, y) = 0\r
+ spdy(x, y) = spdy(x, y) + spdyp(x, y)\r
+ spdyp(x, y) = 0\r
+ NEXT x\r
+NEXT y\r
+\r
+\r
+FOR y = 1 TO 100\r
+ FOR x = 1 TO 100\r
+ PSET (x, y), press(x, y) + 16\r
+ NEXT x\r
+NEXT y\r
+\r
+saveit\r
+\r
+\r
+\r
+\r
+GOTO 1\r
+\r
+CLOSE #1\r
+\r
+SUB disp\r
+FOR y = 47 TO 53\r
+ FOR x = 47 TO 53\r
+ LOCATE y - 46, (x - 46) * 4\r
+ PRINT press(x, y)\r
+ NEXT x\r
+NEXT y\r
+\r
+a$ = INPUT$(1)\r
+\r
+END SUB\r
+\r
+SUB lin (x1, y1, x2, y2)\r
+\r
+m = ABS(x1 - x2)\r
+m1 = ABS(y1 - y2)\r
+IF m1 > m THEN m = m1\r
+\r
+x3 = x2 - x1\r
+y3 = y2 - y1\r
+\r
+FOR a = 0 TO m\r
+ x5 = x3 * a / m + x1\r
+ y5 = y3 * a / m + y1\r
+ press(x5, y5) = wal\r
+NEXT a\r
+\r
+\r
+END SUB\r
+\r
+SUB saveit\r
+FOR y = 1 TO 100\r
+ a$ = ""\r
+ FOR x = 1 TO 100\r
+ a$ = a$ + CHR$(POINT(x, y))\r
+ NEXT x\r
+ linb = a$\r
+ PUT #1, , linb\r
+NEXT y\r
+\r
+\r
+END SUB\r
+\r
+SUB spot (x, y, p)\r
+press(x, y) = p\r
+press(x + 1, y) = p\r
+press(x, y + 1) = p\r
+press(x + 1, y + 1) = p\r
+END SUB\r
+\r
+SUB start\r
+frm = 0\r
+\r
+FOR a = 1 TO 100\r
+ FOR b = 1 TO 100\r
+ press(a, b) = 3\r
+ spdx(a, b) = 0\r
+ spdy(a, b) = 0\r
+ spdxp(a, b) = 0\r
+ spdyp(a, b) = 0\r
+ NEXT b\r
+NEXT a\r
+\r
+FOR y = 30 TO 60\r
+ FOR x = 10 TO 50\r
+ spot x, y, 30\r
+ NEXT x\r
+NEXT y\r
+\r
+lin 2, 2, 2, 99\r
+lin 99, 2, 99, 99\r
+lin 2, 99, 99, 99\r
+lin 2, 2, 99, 2\r
+\r
+FOR x = 5 TO 40 STEP 5\r
+ lin x, 80, x + 50, 80 - x\r
+NEXT x\r
+\r
+END SUB\r
+\r
--- /dev/null
+<HTML>\r
+<HEAD><TITLE>explode</TITLE></HEAD>\r
+\r
+<BODY>\r
+\r
+<CENTER><H1>explode</H1></CENTER>\r
+<BR>\r
+<BR>\r
+<BR>Simulates air flow.\r
+Air tries to spread equally around space,\r
+while having is inertial farces, mass and gravitation.\r
+Simulation animates shock waves propagation on\r
+flat space after explosion.\r
+\r
+<BR><IMG SRC="sshot.png">\r
+</BODY>\r
+</HTML>
\ No newline at end of file
--- /dev/null
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+........####......................................\r
+.......#....#.....................................\r
+........####......................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+................................#######...........\r
+...............................#.......#..........\r
+................................#######...........\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+........#####.....................................\r
+.......#.....#....................................\r
+........#####.....................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+................................######............\r
+...............................#......#...........\r
+................................######............\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
--- /dev/null
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+........................###.......................\r
+.....................#.......#....................\r
+....................#.........#...................\r
+........................###.......................\r
+.......................#...#......................\r
+...................#..#.....#..#..................\r
+...................#..#.....#..#..................\r
+...................#..#.....#..#..................\r
+.......................#...#......................\r
+........................###.......................\r
+....................#.........#...................\r
+.....................#.......#....................\r
+........................###.......................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
--- /dev/null
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+........................###.......................\r
+.....................#...#...#....................\r
+....................##...#...##...................\r
+......................#.###.#.....................\r
+.......................#...#......................\r
+...................#..#.....#..#..................\r
+...................####.....####..................\r
+...................#..#.....#..#..................\r
+.......................#...#......................\r
+......................#.###.#.....................\r
+....................##...#...##...................\r
+.....................#...#...#....................\r
+........................###.......................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
--- /dev/null
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+...............##.................................\r
+...............#..................................\r
+.................#................................\r
+.............#####................................\r
+.............#....................................\r
+...........##...##................................\r
+.......##.#....##.#.##............................\r
+........#.#....##.#.#.............................\r
+.......#..##....#.#..#............................\r
+........##..#.#....##.............................\r
+..........#.#######...............................\r
+..........#.......#...............................\r
+...........#######................................\r
+..................................................\r
+.............###..................................\r
+............#..#..................................\r
+............##..................##................\r
+...............................#..#.##............\r
+...............................#.##.#.#...........\r
+..............................##..#.#.#...........\r
+.............................#..#.#...#.##........\r
+.............................##.#.#...#..#........\r
+................................#.#.#..##.........\r
+................................#.#.##.#..........\r
+.................................##.#..#..........\r
+.....................................##...........\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
--- /dev/null
+..................................................\r
+.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
+.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
+..................................................\r
+.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
+.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
+..................................................\r
+.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
+.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
+..................................................\r
+.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
+.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
+..................................................\r
+.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
+.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
+..................................................\r
+.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
+.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
+..................................................\r
+.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
+.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
+..................................................\r
+.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
+.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
+..................................................\r
+.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
+.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
+..................................................\r
+.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
+.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
+..................................................\r
+.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
+.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
+..................................................\r
+.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
+.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
+..................................................\r
+.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
+.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+.##.##.##.##.##.##.##.##.##.##.##.##..............\r
+.##.##.##.##.##.##.##.##.##.##.##.##..............\r
+...........................................###....\r
+.##.##.##.##.##.##.##.##.##.##.##.##.......#......\r
+.##.##.##.##.##.##.##.##.##.##.##.##........#.....\r
+..................................................\r
+..................................................\r
--- /dev/null
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+........................#.........................\r
+.......................###........................\r
+.......................#.#........................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
--- /dev/null
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..............................#...................\r
+.............................###..................\r
+...............................#..................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
--- /dev/null
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+......###.....#...#...#...#...#...#...#...#.......\r
+......#.#.....#...#...#...#...#...#...#...#.......\r
+......###.....#...#...#...#...#...#...#...#.......\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+.............#..#..#..#..#..#..#..#..#............\r
+.............#..#..#..#..#..#..#..#..#............\r
+.............#..#..#..#..#..#..#..#..#............\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
--- /dev/null
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+.......###........................................\r
+.........#........................................\r
+........#.........................................\r
+..................................................\r
+........................................###.......\r
+........................................#.........\r
+.........................................#........\r
+..................................................\r
+..................................................\r
+..................................................\r
--- /dev/null
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................#.#.#.#.#.#.....................\r
+.................#.#.#.#.#.#.#....................\r
+..................#.#.#.#.#.#.....................\r
+.................#.#.#.#.#.#.#....................\r
+..................#.#.#.#.#.#.....................\r
+.................#.#.#.#.#.#.#....................\r
+..................#.#.#.#.#.#.....................\r
+.................#.#.#.#.#.#.#....................\r
+..................#.#.#.#.#.#.....................\r
+.................#.#.#.#.#.#.#....................\r
+..................#.#.#.#.#.#.....................\r
+.................#.#.#.#.#.#.#....................\r
+..................#.#.#.#.#.#.....................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
--- /dev/null
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+....................................##............\r
+..................................##..#...........\r
+............#####.................#..##...........\r
+..........#.......#................##.............\r
+.........#.........#..............................\r
+.............###..................................\r
+........#...#...#...#.............................\r
+........#..#.....#..#.............................\r
+........#..#.....#..#.............................\r
+........#..#.....#..#.............................\r
+........#...#...#...#.............................\r
+.............###..................................\r
+.........#.........#..............................\r
+..........#.......#...............................\r
+............#####.................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+...................................#####..........\r
+.................................##.....##........\r
+................................#.........#.......\r
+................................#...###...#.......\r
+...............................#...#...#...#......\r
+...............................#..#.....#..#......\r
+...............................#..#.....#..#......\r
+........#......................#..#.....#..#......\r
+........##.##..................#...#...#...#......\r
+............#...................#...###...#.......\r
+................................#.........#.......\r
+.................................##.....##........\r
+...................................#####..........\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
--- /dev/null
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+.................####.............####............\r
+.....................#...........#................\r
+...................####.........#.................\r
+.......................#...#...#..................\r
+........................#.#.#.#...................\r
+.................#########...#########............\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
+..................................................\r
--- /dev/null
+<HTML>\r
+<HEAD><TITLE>life</TITLE></HEAD>\r
+\r
+<BODY text=#A0A0ff vLink=#0000ff aLink=#0000ff link=#0000ff bgColor=#000000>\r
+\r
+<CENTER><H1>life</H1></CENTER>\r
+<BR>Conway's game of life. Simple editor with copy and paste\r
+functionality and simulator.\r
+\r
+<BR><IMG SRC="sshot.png">\r
+</BODY>\r
+</HTML>
\ No newline at end of file
--- /dev/null
+' Conway's Game of Life.\r
+' It has world editor, and can save/load worlds.\r
+'\r
+' By Svjatoslav Agejenko.\r
+' Email: svjatoslav@svjatoslav.eu\r
+' Homepage: http://www.svjatoslav.eu\r
+'\r
+' Changelog:\r
+' 2001, Initial version\r
+' 2024.08, Improved program readability using AI\r
+\r
+' in observing mode use keys:\r
+' ---------------------------\r
+\r
+' x - run for 10000 cycles\r
+' s - run for specified amount of cycles\r
+' n - run for 1 cycle\r
+' z - stop running\r
+' c - clear all\r
+' w - write state to file\r
+' l - load state from file\r
+' e - switch to edit mode\r
+' q - quit\r
+\r
+' in edit mode use keys:\r
+' ----------------------\r
+\r
+' cursor keys - move around\r
+' 4 8 6 2 - move arund in large jumps\r
+' s - switch to select mode\r
+' v - paste from copy buffer\r
+' SPACE - toggle cell on/off\r
+' ESC - return to observing mode\r
+\r
+' in select mode use keys:\r
+' ------------------------\r
+\r
+' cursor keys - select area\r
+' 4 8 6 2 - select area in large jumps\r
+' c - copy\r
+' x - cut\r
+' ESC - return to edit mode\r
+\r
+DECLARE SUB loadFile ()\r
+DECLARE SUB writeFile ()\r
+DECLARE SUB showBuffer ()\r
+DEFINT A-Z\r
+\r
+DECLARE SUB selectMode (x, y)\r
+DECLARE SUB clearBuffers ()\r
+DECLARE SUB editMode ()\r
+DECLARE SUB displayGrid ()\r
+DECLARE SUB clearLine ()\r
+DECLARE SUB processLife ()\r
+DECLARE SUB initialize ()\r
+DIM SHARED buffer1(1 TO 50, 1 TO 50)\r
+DIM SHARED buffer2(1 TO 50, 1 TO 50)\r
+DIM SHARED millisecond\r
+DIM SHARED frame\r
+DIM SHARED skip\r
+DIM SHARED buffer3(0 TO 50, 0 TO 50)\r
+DIM SHARED bufferXSize, bufferYSize\r
+initialize\r
+\r
+1\r
+processLife\r
+frame = frame + 1\r
+\r
+2\r
+LOCATE 1, 27\r
+PRINT "frame:" + STR$(frame) + " "\r
+LOCATE 2, 27\r
+PRINT "skip:" + STR$(skip) + " "\r
+\r
+key$ = INKEY$\r
+\r
+IF key$ = "s" THEN\r
+ LOCATE 5, 27\r
+ INPUT "skip ", skip\r
+ clearLine\r
+END IF\r
+\r
+IF key$ = "q" THEN\r
+ SYSTEM\r
+END IF\r
+\r
+IF key$ = "n" THEN GOTO 1\r
+\r
+IF key$ = "c" THEN clearBuffers\r
+\r
+IF key$ = "e" THEN editMode\r
+\r
+IF key$ = "z" THEN skip = 0\r
+\r
+IF key$ = "x" THEN skip = 10000\r
+\r
+IF key$ = "w" THEN writeFile\r
+\r
+IF key$ = "l" THEN loadFile\r
+\r
+IF skip > 0 THEN\r
+ skip = skip - 1\r
+ GOTO 1\r
+END IF\r
+GOTO 2\r
+\r
+SUB clearBuffers\r
+\r
+FOR y = 1 TO 50\r
+ FOR x = 1 TO 50\r
+ buffer1(x, y) = 0\r
+ buffer2(x, y) = 0\r
+ NEXT x\r
+NEXT y\r
+\r
+millisecond = 0\r
+frame = 0\r
+skip = 0\r
+\r
+displayGrid\r
+END SUB\r
+\r
+SUB clearLine\r
+LOCATE 5, 27\r
+PRINT " "\r
+END SUB\r
+\r
+SUB displayGrid\r
+\r
+FOR y = 1 TO 50\r
+ FOR x = 1 TO 50\r
+ IF millisecond = 0 THEN clr = buffer1(x, y) ELSE clr = buffer2(x, y)\r
+ IF clr = 0 THEN clr = 1 ELSE clr = 10\r
+ LINE (x * 4, y * 4)-(x * 4 + 2, y * 4 + 2), clr, BF\r
+ NEXT x\r
+NEXT y\r
+\r
+END SUB\r
+\r
+SUB editMode\r
+x = 25\r
+y = 25\r
+3\r
+IF x < 1 THEN x = 1\r
+IF y < 1 THEN y = 1\r
+IF x > 50 THEN x = 50\r
+IF y > 49 THEN y = 49\r
+\r
+IF millisecond = 0 THEN clr = buffer1(x, y) ELSE clr = buffer2(x, y)\r
+IF clr = 0 THEN clr = 1 ELSE clr = 10\r
+LINE (x * 4, y * 4)-(x * 4 + 2, y * 4 + 2), clr, BF\r
+\r
+LINE (x * 4 - 1, y * 4 - 1)-(x * 4 + 3, y * 4 + 3), 14, B\r
+4\r
+key$ = INKEY$\r
+IF key$ = "" THEN GOTO 4\r
+\r
+LINE (x * 4 - 1, y * 4 - 1)-(x * 4 + 3, y * 4 + 3), 0, B\r
+\r
+IF key$ = CHR$(0) + "M" THEN x = x + 1\r
+IF key$ = CHR$(0) + "K" THEN x = x - 1\r
+IF key$ = CHR$(0) + "P" THEN y = y + 1\r
+IF key$ = CHR$(0) + "H" THEN y = y - 1\r
+IF key$ = "6" THEN x = x + 8\r
+IF key$ = "4" THEN x = x - 8\r
+IF key$ = "2" THEN y = y + 8\r
+IF key$ = "8" THEN y = y - 8\r
+\r
+IF key$ = CHR$(27) THEN GOTO 5\r
+IF key$ = "s" THEN selectMode x, y\r
+\r
+IF key$ = "v" THEN\r
+ FOR y1 = 0 TO bufferYSize\r
+ FOR x1 = 0 TO bufferXSize\r
+ clr = buffer3(x1, y1)\r
+ x2 = x1 + x\r
+ y2 = y1 + y\r
+\r
+ IF (x2 < 50) AND (y2 < 50) THEN\r
+ IF millisecond = 0 THEN buffer1(x2, y2) = clr ELSE buffer2(x2, y2) = clr\r
+ END IF\r
+\r
+ NEXT x1\r
+ NEXT y1\r
+ displayGrid\r
+END IF\r
+\r
+IF key$ = " " THEN\r
+ IF millisecond = 0 THEN clr = buffer1(x, y) ELSE clr = buffer2(x, y)\r
+ IF clr = 1 THEN clr = 0 ELSE clr = 1\r
+ IF millisecond = 0 THEN buffer1(x, y) = clr ELSE buffer2(x, y) = clr\r
+END IF\r
+\r
+GOTO 3\r
+5\r
+\r
+END SUB\r
+\r
+SUB initialize\r
+SCREEN 13\r
+RANDOMIZE TIMER\r
+\r
+bufferXSize = 0\r
+bufferYSize = 0\r
+\r
+clearBuffers\r
+\r
+END SUB\r
+\r
+SUB loadFile\r
+\r
+clearBuffers\r
+LOCATE 5, 27\r
+INPUT "file ", filename$\r
+clearLine\r
+\r
+y = 1\r
+OPEN filename$ FOR INPUT AS #1\r
+9\r
+IF EOF(1) <> 0 THEN GOTO 10\r
+\r
+LINE INPUT #1, line$\r
+\r
+FOR x = 1 TO LEN(line$)\r
+ char$ = RIGHT$(LEFT$(line$, x), 1)\r
+ IF char$ = "#" THEN clr = 1 ELSE clr = 0\r
+ IF millisecond = 0 THEN buffer1(x, y) = clr ELSE buffer2(x, y) = clr\r
+NEXT x\r
+y = y + 1\r
+\r
+GOTO 9\r
+10\r
+CLOSE #1\r
+displayGrid\r
+\r
+END SUB\r
+\r
+SUB processLife\r
+\r
+IF millisecond = 0 THEN\r
+ FOR y = 2 TO 48\r
+ FOR x = 2 TO 49\r
+ IF buffer1(x - 1, y - 1) = 1 THEN count = 1 ELSE count = 0\r
+ IF buffer1(x, y - 1) = 1 THEN count = count + 1\r
+ IF buffer1(x + 1, y - 1) = 1 THEN count = count + 1\r
+ IF buffer1(x - 1, y) = 1 THEN count = count + 1\r
+ IF buffer1(x + 1, y) = 1 THEN count = count + 1\r
+ IF buffer1(x - 1, y + 1) = 1 THEN count = count + 1\r
+ IF buffer1(x, y + 1) = 1 THEN count = count + 1\r
+ IF buffer1(x + 1, y + 1) = 1 THEN count = count + 1\r
+\r
+ IF buffer1(x, y) = 1 THEN\r
+ IF count = 2 OR count = 3 THEN buffer2(x, y) = 1 ELSE buffer2(x, y) = 0\r
+ ELSE\r
+ IF count = 3 THEN buffer2(x, y) = 1 ELSE buffer2(x, y) = 0\r
+ END IF\r
+\r
+ NEXT x\r
+ NEXT y\r
+ millisecond = 1\r
+ displayGrid\r
+ELSE\r
+\r
+ FOR y = 2 TO 48\r
+ FOR x = 2 TO 49\r
+ IF buffer2(x - 1, y - 1) = 1 THEN count = 1 ELSE count = 0\r
+ IF buffer2(x, y - 1) = 1 THEN count = count + 1\r
+ IF buffer2(x + 1, y - 1) = 1 THEN count = count + 1\r
+ IF buffer2(x - 1, y) = 1 THEN count = count + 1\r
+ IF buffer2(x + 1, y) = 1 THEN count = count + 1\r
+ IF buffer2(x - 1, y + 1) = 1 THEN count = count + 1\r
+ IF buffer2(x, y + 1) = 1 THEN count = count + 1\r
+ IF buffer2(x + 1, y + 1) = 1 THEN count = count + 1\r
+\r
+ IF buffer2(x, y) = 1 THEN\r
+ IF count = 2 OR count = 3 THEN buffer1(x, y) = 1 ELSE buffer1(x, y) = 0\r
+ ELSE\r
+ IF count = 3 THEN buffer1(x, y) = 1 ELSE buffer1(x, y) = 0\r
+ END IF\r
+ NEXT x\r
+ NEXT y\r
+\r
+ millisecond = 0\r
+ displayGrid\r
+END IF\r
+\r
+END SUB\r
+\r
+SUB selectMode (x, y)\r
+x1 = x * 4 - 1\r
+y1 = y * 4 - 1\r
+x2 = x + 2\r
+y2 = y + 2\r
+\r
+6\r
+x3 = x2 * 4 + 3\r
+y3 = y2 * 4 + 3\r
+\r
+LINE (x1, y1)-(x3, y3), 14, B\r
+8\r
+key$ = INKEY$\r
+IF key$ = "" THEN GOTO 8\r
+LINE (x1, y1)-(x3, y3), 0, B\r
+\r
+IF key$ = CHR$(0) + "M" THEN x2 = x2 + 1\r
+IF key$ = CHR$(0) + "K" THEN x2 = x2 - 1\r
+IF key$ = CHR$(0) + "P" THEN y2 = y2 + 1\r
+IF key$ = CHR$(0) + "H" THEN y2 = y2 - 1\r
+\r
+IF key$ = "6" THEN x2 = x2 + 8\r
+IF key$ = "4" THEN x2 = x2 - 8\r
+IF key$ = "2" THEN y2 = y2 + 8\r
+IF key$ = "8" THEN y2 = y2 - 8\r
+\r
+IF key$ = CHR$(27) THEN GOTO 7\r
+IF key$ = "c" THEN\r
+ bufferXSize = x2 - x\r
+ bufferYSize = y2 - y\r
+\r
+ FOR y4 = y TO y2\r
+ FOR x4 = x TO x2\r
+ IF millisecond = 0 THEN clr = buffer1(x4, y4) ELSE clr = buffer2(x4, y4)\r
+ buffer3(x4 - x, y4 - y) = clr\r
+ NEXT x4\r
+ NEXT y4\r
+ showBuffer\r
+END IF\r
+\r
+IF key$ = "x" THEN\r
+ bufferXSize = x2 - x\r
+ bufferYSize = y2 - y\r
+\r
+ FOR y4 = y TO y2\r
+ FOR x4 = x TO x2\r
+ IF millisecond = 0 THEN clr = buffer1(x4, y4): buffer1(x4, y4) = 0 ELSE clr = buffer2(x4, y4): buffer2(x4, y4) = 0\r
+ buffer3(x4 - x, y4 - y) = clr\r
+ NEXT x4\r
+ NEXT y4\r
+ showBuffer\r
+ displayGrid\r
+END IF\r
+\r
+GOTO 6\r
+7\r
+\r
+END SUB\r
+\r
+SUB showBuffer\r
+\r
+'PRINT bufxs\r
+'PRINT bufys\r
+\r
+x = bufferXSize\r
+IF x > 15 THEN x = 15\r
+y = bufferYSize\r
+IF y > 15 THEN y = 15\r
+\r
+LINE (204, 99)-(319, 199), 0, BF\r
+LINE (204, 99)-(208 + 4 * bufferXSize, 103 + 4 * bufferYSize), 14, B\r
+\r
+FOR y2 = 0 TO y\r
+ FOR x2 = 0 TO x\r
+ clr = buffer3(x2, y2)\r
+ IF clr = 0 THEN clr = 1 ELSE clr = 10\r
+ LINE (x2 * 4 + 205, y2 * 4 + 100)-(x2 * 4 + 2 + 205, y2 * 4 + 2 + 100), clr, BF\r
+ NEXT x2\r
+NEXT y2\r
+\r
+END SUB\r
+\r
+SUB writeFile\r
+LOCATE 5, 27\r
+INPUT "file ", filename$\r
+clearLine\r
+\r
+OPEN filename$ FOR OUTPUT AS #1\r
+\r
+FOR y = 1 TO 50\r
+ line$ = ""\r
+ FOR x = 1 TO 50\r
+ IF millisecond = 0 THEN clr = buffer1(x, y) ELSE clr = buffer2(x, y)\r
+ IF clr = 0 THEN line$ = line$ + "." ELSE line$ = line$ + "#"\r
+ NEXT x\r
+ PRINT #1, line$\r
+NEXT y\r
+\r
+CLOSE #1\r
+\r
+END SUB\r
+\r
+++ /dev/null
-' Material simulation, simulates shockwaves propagation in gas.\r
-' made by Svjatoslav Agejenko\r
-' in 2003\r
-' homepage: svjatoslav.eu\r
-' email: svjatoslav@svjatoslav.eu\r
- \r
-DECLARE SUB saveit ()\r
-DECLARE SUB playit ()\r
-DECLARE SUB frmget ()\r
-DECLARE SUB frmsav ()\r
-DECLARE SUB spot (x!, y!, p!)\r
-DECLARE SUB lin (x1!, y1!, x2!, y2!)\r
-DECLARE SUB disp ()\r
-DECLARE SUB start ()\r
-DIM SHARED wal\r
-wal = 9980\r
-\r
-DIM SHARED press(1 TO 100, 1 TO 100)\r
-DIM SHARED spdx(1 TO 100, 1 TO 100)\r
-DIM SHARED spdy(1 TO 100, 1 TO 100)\r
-DIM SHARED spdxp(1 TO 100, 1 TO 100)\r
-DIM SHARED spdyp(1 TO 100, 1 TO 100)\r
-DIM SHARED nam$, frm\r
-DIM SHARED linb AS STRING * 100\r
-frm = 0\r
-\r
-SCREEN 13\r
-PAINT (1, 1), 1\r
-\r
-OPEN "tst.an0" FOR BINARY AS #1\r
-\r
-\r
-start\r
-\r
-1\r
-'disp\r
-\r
-FOR y = 2 TO 99\r
- FOR x = 2 TO 99\r
- IF press(x, y) = wal THEN spdx(x - 1, y) = 0: spdy(x, y - 1) = 0: spdx(x, y) = 0: spdy(x, y) = 0: GOTO 3\r
- spdy(x, y) = spdy(x, y) - (press(x, y) / 500) ' gravitation\r
-\r
- IF press(x + 1, y) = wal THEN spdx(x, y) = 0: GOTO 2\r
- spdx(x, y) = (press(x + 1, y) - press(x, y)) / 20 + spdx(x, y)\r
- 2\r
- IF press(x, y + 1) = wal THEN spdy(x, y) = 0: GOTO 3\r
- spdy(x, y) = (press(x, y + 1) - press(x, y)) / 20 + spdy(x, y)\r
- 3\r
- NEXT x\r
-NEXT y\r
-\r
-\r
-4\r
-b = 0\r
-FOR y = 2 TO 99\r
- FOR x = 2 TO 99\r
- a = press(x, y) + spdx(x, y) + spdy(x, y) - spdx(x - 1, y) - spdy(x, y - 1)\r
-\r
- IF a = 0 OR ((a < 0) AND (a > -.0001)) THEN\r
- IF spdx(x, y) < 0 THEN spdx(x, y) = 0\r
- IF spdy(x, y) < 0 THEN spdy(x, y) = 0\r
- IF spdx(x - 1, y) > 0 THEN spdx(x - 1, y) = 0\r
- IF spdy(x, y - 1) > 0 THEN spdy(x, y - 1) = 0\r
- END IF\r
-\r
- IF a < 0 THEN\r
- IF spdx(x, y) < 0 THEN spdx(x, y) = spdx(x, y) / 1.5\r
- IF spdy(x, y) < 0 THEN spdy(x, y) = spdy(x, y) / 1.5\r
- IF spdx(x - 1, y) > 0 THEN spdx(x - 1, y) = spdx(x - 1, y) / 1.5\r
- IF spdy(x, y - 1) > 0 THEN spdy(x, y - 1) = spdy(x, y - 1) / 1.5\r
- b = 1\r
- LOCATE 20, 1\r
- PRINT a\r
- END IF\r
- NEXT x\r
-NEXT y\r
-IF b = 1 THEN GOTO 4\r
-\r
-FOR y = 2 TO 99\r
- FOR x = 2 TO 99\r
- IF spdx(x, y) > 0 THEN spdxp(x - 1, y) = ((press(x, y) * spdx(x - 1, y)) + (spdx(x, y) * spdx(x, y))) / (press(x, y) + spdx(x, y)) - spdx(x - 1, y)\r
- IF spdy(x, y) > 0 THEN spdyp(x, y - 1) = ((press(x, y) * spdy(x, y - 1)) + (spdy(x, y) * spdy(x, y))) / (press(x, y) + spdy(x, y)) - spdy(x, y - 1)\r
- IF spdx(x - 1, y) < 0 THEN spdxp(x, y) = ((press(x, y) * spdx(x, y)) - (spdx(x - 1, y) * spdx(x - 1, y))) / (press(x, y) - spdx(x - 1, y)) - spdx(x, y)\r
- IF spdy(x, y - 1) < 0 THEN spdyp(x, y) = ((press(x, y) * spdy(x, y)) - (spdy(x, y - 1) * spdy(x, y - 1))) / (press(x, y) - spdy(x, y - 1)) - spdy(x, y)\r
- NEXT x\r
-NEXT y\r
-\r
-\r
-FOR y = 2 TO 99\r
- FOR x = 2 TO 99\r
- press(x + 1, y) = press(x + 1, y) - spdx(x, y)\r
- press(x, y + 1) = press(x, y + 1) - spdy(x, y)\r
- press(x, y) = press(x, y) + spdx(x, y)\r
- press(x, y) = press(x, y) + spdy(x, y)\r
- NEXT x\r
-NEXT y\r
-\r
-FOR y = 2 TO 99\r
- FOR x = 2 TO 99\r
- spdx(x, y) = spdx(x, y) + spdxp(x, y)\r
- spdxp(x, y) = 0\r
- spdy(x, y) = spdy(x, y) + spdyp(x, y)\r
- spdyp(x, y) = 0\r
- NEXT x\r
-NEXT y\r
-\r
-\r
-FOR y = 1 TO 100\r
- FOR x = 1 TO 100\r
- PSET (x, y), press(x, y) + 16\r
- NEXT x\r
-NEXT y\r
-\r
-saveit\r
-\r
-\r
-\r
-\r
-GOTO 1\r
-\r
-CLOSE #1\r
-\r
-SUB disp\r
-FOR y = 47 TO 53\r
- FOR x = 47 TO 53\r
- LOCATE y - 46, (x - 46) * 4\r
- PRINT press(x, y)\r
- NEXT x\r
-NEXT y\r
-\r
-a$ = INPUT$(1)\r
-\r
-END SUB\r
-\r
-SUB lin (x1, y1, x2, y2)\r
-\r
-m = ABS(x1 - x2)\r
-m1 = ABS(y1 - y2)\r
-IF m1 > m THEN m = m1\r
-\r
-x3 = x2 - x1\r
-y3 = y2 - y1\r
-\r
-FOR a = 0 TO m\r
- x5 = x3 * a / m + x1\r
- y5 = y3 * a / m + y1\r
- press(x5, y5) = wal\r
-NEXT a\r
-\r
-\r
-END SUB\r
-\r
-SUB saveit\r
-FOR y = 1 TO 100\r
- a$ = ""\r
- FOR x = 1 TO 100\r
- a$ = a$ + CHR$(POINT(x, y))\r
- NEXT x\r
- linb = a$\r
- PUT #1, , linb\r
-NEXT y\r
-\r
-\r
-END SUB\r
-\r
-SUB spot (x, y, p)\r
-press(x, y) = p\r
-press(x + 1, y) = p\r
-press(x, y + 1) = p\r
-press(x + 1, y + 1) = p\r
-END SUB\r
-\r
-SUB start\r
-frm = 0\r
-\r
-FOR a = 1 TO 100\r
- FOR b = 1 TO 100\r
- press(a, b) = 3\r
- spdx(a, b) = 0\r
- spdy(a, b) = 0\r
- spdxp(a, b) = 0\r
- spdyp(a, b) = 0\r
- NEXT b\r
-NEXT a\r
-\r
-FOR y = 30 TO 60\r
- FOR x = 10 TO 50\r
- spot x, y, 30\r
- NEXT x\r
-NEXT y\r
-\r
-lin 2, 2, 2, 99\r
-lin 99, 2, 99, 99\r
-lin 2, 99, 99, 99\r
-lin 2, 2, 99, 2\r
-\r
-FOR x = 5 TO 40 STEP 5\r
- lin x, 80, x + 50, 80 - x\r
-NEXT x\r
-\r
-END SUB\r
-\r
+++ /dev/null
-<HTML>\r
-<HEAD><TITLE>explode</TITLE></HEAD>\r
-\r
-<BODY>\r
-\r
-<CENTER><H1>explode</H1></CENTER>\r
-<BR>\r
-<BR>\r
-<BR>Simulates air flow.\r
-Air tries to spread equally around space,\r
-while having is inertial farces, mass and gravitation.\r
-Simulation animates shock waves propagation on\r
-flat space after explosion.\r
-\r
-<BR><IMG SRC="sshot.png">\r
-</BODY>\r
-</HTML>
\ No newline at end of file
+++ /dev/null
-' Program simulates interference between two slightly different frequencies\r
-' By Svjatoslav Agejenko.\r
-' Email: svjatoslav@svjatoslav.eu\r
-' Homepage: http://www.svjatoslav.eu\r
-'\r
-' Changelog:\r
-' ?, Initial version\r
-' 2024.08, Improved program readability using AI\r
-\r
-DECLARE SUB GetFrequency ()\r
-DECLARE SUB Start ()\r
-DECLARE FUNCTION GetY! (t!)\r
-DIM SHARED freq(1 TO 100)\r
-DIM SHARED phase(1 TO 100)\r
-\r
-Start\r
-1\r
-frame = frame + 1\r
-PSET (0, 0)\r
-FOR x = 0 TO 639\r
-\r
- oldY1 = y1\r
- oldY2 = y2\r
- oldY3 = y3\r
-\r
- y1 = GetY(frame + x / 4) * 20 + 150\r
- y2 = GetY(frame + x / 4 + (x / 50)) * 20 + 150\r
- y3 = y1 + y2\r
-\r
- ' LINE (x + 1, 0)-(x + 1, 479), 12\r
- LINE (x, 0)-(x, 479), 0\r
-\r
- LINE (x - 1, oldY1)-(x, y1), 1\r
- LINE (x - 1, oldY2)-(x, y2), 2\r
- LINE (x - 1, oldY3)-(x, y3), 15\r
-\r
-NEXT x\r
-GOTO 1\r
-\r
-SUB Display\r
-END SUB\r
-\r
-SUB GetFrequency\r
-\r
-FOR a = 1 TO 100\r
- freq(a) = RND / 2 + 1\r
-NEXT a\r
-\r
-FOR a = 1 TO 100\r
- phase(a) = RND * 100\r
-NEXT a\r
-\r
-END SUB\r
-\r
-FUNCTION GetY (t)\r
-\r
-y = 0\r
-FOR a = 1 TO 1\r
- y = y + SIN(t * freq(a) + phase(a))\r
-NEXT a\r
-\r
-GetY = y\r
-\r
-END FUNCTION\r
-\r
-SUB Start\r
-SCREEN 12\r
-GetFrequency\r
-\r
-END SUB\r
+++ /dev/null
-' Program simulates lot of frequencies interfering with itself.\r
-' As a result, interferogram is produced.\r
-'\r
-' By Svjatoslav Agejenko.\r
-' Email: svjatoslav@svjatoslav.eu\r
-' Homepage: http://www.svjatoslav.eu\r
-'\r
-' Changelog:\r
-' ?, Initial version\r
-' 2024.08, Improved program readability using AI\r
-\r
-\r
-DIM SHARED frequency(1 TO 100)\r
-DIM SHARED phaseAngle(1 TO 100)\r
-\r
-SCREEN 12\r
-\r
-PSET (0, 0)\r
-FOR xPos = 0 TO 639\r
-\r
- fs = (xPos - 320) / 5000 + 1\r
- ' fs = (xPos - 320) / 50 + 1\r
-\r
- yVal = 0\r
- FOR timeStep = 1 TO 5000 STEP 5\r
- y1 = SIN(timeStep)\r
- y2 = SIN(timeStep * fs)\r
- yVal = yVal + ABS(y1 + y2)\r
- NEXT timeStep\r
-\r
- yVal = yVal / 5\r
- IF yVal > 470 THEN yVal = 470\r
- IF yVal < 0 THEN yVal = 0\r
-\r
- LINE -(xPos, 479 - yVal), 15\r
-\r
-NEXT xPos\r
-\r
-SUB getFrequencies\r
-\r
- ' Generates random frequencies and phase angles\r
- FOR index = 1 TO 100\r
- frequency(index) = RND / 7 + 1\r
- NEXT index\r
-\r
- FOR index = 1 TO 100\r
- phaseAngle(index) = RND * 100\r
- NEXT index\r
-\r
-END SUB\r
-\r
-SUB getYVal (timeStep)\r
-\r
- yVal = 0\r
- ' Sum of sinusoids with different frequencies and phases\r
- FOR index = 1 TO 100\r
- yVal = yVal + SIN(timeStep * frequency(index) + phaseAngle(index))\r
- NEXT index\r
-\r
-END SUB\r
--- /dev/null
+' Program simulates interference between two slightly different frequencies\r
+' By Svjatoslav Agejenko.\r
+' Email: svjatoslav@svjatoslav.eu\r
+' Homepage: http://www.svjatoslav.eu\r
+'\r
+' Changelog:\r
+' ?, Initial version\r
+' 2024.08, Improved program readability using AI\r
+\r
+DECLARE SUB GetFrequency ()\r
+DECLARE SUB Start ()\r
+DECLARE FUNCTION GetY! (t!)\r
+DIM SHARED freq(1 TO 100)\r
+DIM SHARED phase(1 TO 100)\r
+\r
+Start\r
+1\r
+frame = frame + 1\r
+PSET (0, 0)\r
+FOR x = 0 TO 639\r
+\r
+ oldY1 = y1\r
+ oldY2 = y2\r
+ oldY3 = y3\r
+\r
+ y1 = GetY(frame + x / 4) * 20 + 150\r
+ y2 = GetY(frame + x / 4 + (x / 50)) * 20 + 150\r
+ y3 = y1 + y2\r
+\r
+ ' LINE (x + 1, 0)-(x + 1, 479), 12\r
+ LINE (x, 0)-(x, 479), 0\r
+\r
+ LINE (x - 1, oldY1)-(x, y1), 1\r
+ LINE (x - 1, oldY2)-(x, y2), 2\r
+ LINE (x - 1, oldY3)-(x, y3), 15\r
+\r
+NEXT x\r
+GOTO 1\r
+\r
+SUB Display\r
+END SUB\r
+\r
+SUB GetFrequency\r
+\r
+FOR a = 1 TO 100\r
+ freq(a) = RND / 2 + 1\r
+NEXT a\r
+\r
+FOR a = 1 TO 100\r
+ phase(a) = RND * 100\r
+NEXT a\r
+\r
+END SUB\r
+\r
+FUNCTION GetY (t)\r
+\r
+y = 0\r
+FOR a = 1 TO 1\r
+ y = y + SIN(t * freq(a) + phase(a))\r
+NEXT a\r
+\r
+GetY = y\r
+\r
+END FUNCTION\r
+\r
+SUB Start\r
+SCREEN 12\r
+GetFrequency\r
+\r
+END SUB\r
--- /dev/null
+' Program simulates lot of frequencies interfering with itself.\r
+' As a result, interferogram is produced.\r
+'\r
+' By Svjatoslav Agejenko.\r
+' Email: svjatoslav@svjatoslav.eu\r
+' Homepage: http://www.svjatoslav.eu\r
+'\r
+' Changelog:\r
+' ?, Initial version\r
+' 2024.08, Improved program readability using AI\r
+\r
+\r
+DIM SHARED frequency(1 TO 100)\r
+DIM SHARED phaseAngle(1 TO 100)\r
+\r
+SCREEN 12\r
+\r
+PSET (0, 0)\r
+FOR xPos = 0 TO 639\r
+\r
+ fs = (xPos - 320) / 5000 + 1\r
+ ' fs = (xPos - 320) / 50 + 1\r
+\r
+ yVal = 0\r
+ FOR timeStep = 1 TO 5000 STEP 5\r
+ y1 = SIN(timeStep)\r
+ y2 = SIN(timeStep * fs)\r
+ yVal = yVal + ABS(y1 + y2)\r
+ NEXT timeStep\r
+\r
+ yVal = yVal / 5\r
+ IF yVal > 470 THEN yVal = 470\r
+ IF yVal < 0 THEN yVal = 0\r
+\r
+ LINE -(xPos, 479 - yVal), 15\r
+\r
+NEXT xPos\r
+\r
+SUB getFrequencies\r
+\r
+ ' Generates random frequencies and phase angles\r
+ FOR index = 1 TO 100\r
+ frequency(index) = RND / 7 + 1\r
+ NEXT index\r
+\r
+ FOR index = 1 TO 100\r
+ phaseAngle(index) = RND * 100\r
+ NEXT index\r
+\r
+END SUB\r
+\r
+SUB getYVal (timeStep)\r
+\r
+ yVal = 0\r
+ ' Sum of sinusoids with different frequencies and phases\r
+ FOR index = 1 TO 100\r
+ yVal = yVal + SIN(timeStep * frequency(index) + phaseAngle(index))\r
+ NEXT index\r
+\r
+END SUB\r
+++ /dev/null
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-........####......................................\r
-.......#....#.....................................\r
-........####......................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-................................#######...........\r
-...............................#.......#..........\r
-................................#######...........\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-........#####.....................................\r
-.......#.....#....................................\r
-........#####.....................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-................................######............\r
-...............................#......#...........\r
-................................######............\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
+++ /dev/null
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-........................###.......................\r
-.....................#.......#....................\r
-....................#.........#...................\r
-........................###.......................\r
-.......................#...#......................\r
-...................#..#.....#..#..................\r
-...................#..#.....#..#..................\r
-...................#..#.....#..#..................\r
-.......................#...#......................\r
-........................###.......................\r
-....................#.........#...................\r
-.....................#.......#....................\r
-........................###.......................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
+++ /dev/null
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-........................###.......................\r
-.....................#...#...#....................\r
-....................##...#...##...................\r
-......................#.###.#.....................\r
-.......................#...#......................\r
-...................#..#.....#..#..................\r
-...................####.....####..................\r
-...................#..#.....#..#..................\r
-.......................#...#......................\r
-......................#.###.#.....................\r
-....................##...#...##...................\r
-.....................#...#...#....................\r
-........................###.......................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
+++ /dev/null
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-...............##.................................\r
-...............#..................................\r
-.................#................................\r
-.............#####................................\r
-.............#....................................\r
-...........##...##................................\r
-.......##.#....##.#.##............................\r
-........#.#....##.#.#.............................\r
-.......#..##....#.#..#............................\r
-........##..#.#....##.............................\r
-..........#.#######...............................\r
-..........#.......#...............................\r
-...........#######................................\r
-..................................................\r
-.............###..................................\r
-............#..#..................................\r
-............##..................##................\r
-...............................#..#.##............\r
-...............................#.##.#.#...........\r
-..............................##..#.#.#...........\r
-.............................#..#.#...#.##........\r
-.............................##.#.#...#..#........\r
-................................#.#.#..##.........\r
-................................#.#.##.#..........\r
-.................................##.#..#..........\r
-.....................................##...........\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
+++ /dev/null
-..................................................\r
-.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
-.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
-..................................................\r
-.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
-.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
-..................................................\r
-.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
-.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
-..................................................\r
-.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
-.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
-..................................................\r
-.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
-.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
-..................................................\r
-.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
-.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
-..................................................\r
-.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
-.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
-..................................................\r
-.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
-.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
-..................................................\r
-.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
-.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
-..................................................\r
-.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
-.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
-..................................................\r
-.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
-.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
-..................................................\r
-.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
-.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
-..................................................\r
-.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
-.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##..\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-.##.##.##.##.##.##.##.##.##.##.##.##..............\r
-.##.##.##.##.##.##.##.##.##.##.##.##..............\r
-...........................................###....\r
-.##.##.##.##.##.##.##.##.##.##.##.##.......#......\r
-.##.##.##.##.##.##.##.##.##.##.##.##........#.....\r
-..................................................\r
-..................................................\r
+++ /dev/null
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-........................#.........................\r
-.......................###........................\r
-.......................#.#........................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
+++ /dev/null
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..............................#...................\r
-.............................###..................\r
-...............................#..................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
+++ /dev/null
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-......###.....#...#...#...#...#...#...#...#.......\r
-......#.#.....#...#...#...#...#...#...#...#.......\r
-......###.....#...#...#...#...#...#...#...#.......\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-.............#..#..#..#..#..#..#..#..#............\r
-.............#..#..#..#..#..#..#..#..#............\r
-.............#..#..#..#..#..#..#..#..#............\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
+++ /dev/null
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-.......###........................................\r
-.........#........................................\r
-........#.........................................\r
-..................................................\r
-........................................###.......\r
-........................................#.........\r
-.........................................#........\r
-..................................................\r
-..................................................\r
-..................................................\r
+++ /dev/null
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................#.#.#.#.#.#.....................\r
-.................#.#.#.#.#.#.#....................\r
-..................#.#.#.#.#.#.....................\r
-.................#.#.#.#.#.#.#....................\r
-..................#.#.#.#.#.#.....................\r
-.................#.#.#.#.#.#.#....................\r
-..................#.#.#.#.#.#.....................\r
-.................#.#.#.#.#.#.#....................\r
-..................#.#.#.#.#.#.....................\r
-.................#.#.#.#.#.#.#....................\r
-..................#.#.#.#.#.#.....................\r
-.................#.#.#.#.#.#.#....................\r
-..................#.#.#.#.#.#.....................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
+++ /dev/null
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-....................................##............\r
-..................................##..#...........\r
-............#####.................#..##...........\r
-..........#.......#................##.............\r
-.........#.........#..............................\r
-.............###..................................\r
-........#...#...#...#.............................\r
-........#..#.....#..#.............................\r
-........#..#.....#..#.............................\r
-........#..#.....#..#.............................\r
-........#...#...#...#.............................\r
-.............###..................................\r
-.........#.........#..............................\r
-..........#.......#...............................\r
-............#####.................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-...................................#####..........\r
-.................................##.....##........\r
-................................#.........#.......\r
-................................#...###...#.......\r
-...............................#...#...#...#......\r
-...............................#..#.....#..#......\r
-...............................#..#.....#..#......\r
-........#......................#..#.....#..#......\r
-........##.##..................#...#...#...#......\r
-............#...................#...###...#.......\r
-................................#.........#.......\r
-.................................##.....##........\r
-...................................#####..........\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
+++ /dev/null
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-.................####.............####............\r
-.....................#...........#................\r
-...................####.........#.................\r
-.......................#...#...#..................\r
-........................#.#.#.#...................\r
-.................#########...#########............\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
-..................................................\r
+++ /dev/null
-<HTML>\r
-<HEAD><TITLE>life</TITLE></HEAD>\r
-\r
-<BODY text=#A0A0ff vLink=#0000ff aLink=#0000ff link=#0000ff bgColor=#000000>\r
-\r
-<CENTER><H1>life</H1></CENTER>\r
-<BR>Conway's game of life. Simple editor with copy and paste\r
-functionality and simulator.\r
-\r
-<BR><IMG SRC="sshot.png">\r
-</BODY>\r
-</HTML>
\ No newline at end of file
+++ /dev/null
-' Conway's Game of Life.\r
-' It has world editor, and can save/load worlds.\r
-'\r
-' By Svjatoslav Agejenko.\r
-' Email: svjatoslav@svjatoslav.eu\r
-' Homepage: http://www.svjatoslav.eu\r
-'\r
-' Changelog:\r
-' 2001, Initial version\r
-' 2024.08, Improved program readability using AI\r
-\r
-' in observing mode use keys:\r
-' ---------------------------\r
-\r
-' x - run for 10000 cycles\r
-' s - run for specified amount of cycles\r
-' n - run for 1 cycle\r
-' z - stop running\r
-' c - clear all\r
-' w - write state to file\r
-' l - load state from file\r
-' e - switch to edit mode\r
-' q - quit\r
-\r
-' in edit mode use keys:\r
-' ----------------------\r
-\r
-' cursor keys - move around\r
-' 4 8 6 2 - move arund in large jumps\r
-' s - switch to select mode\r
-' v - paste from copy buffer\r
-' SPACE - toggle cell on/off\r
-' ESC - return to observing mode\r
-\r
-' in select mode use keys:\r
-' ------------------------\r
-\r
-' cursor keys - select area\r
-' 4 8 6 2 - select area in large jumps\r
-' c - copy\r
-' x - cut\r
-' ESC - return to edit mode\r
-\r
-DECLARE SUB loadFile ()\r
-DECLARE SUB writeFile ()\r
-DECLARE SUB showBuffer ()\r
-DEFINT A-Z\r
-\r
-DECLARE SUB selectMode (x, y)\r
-DECLARE SUB clearBuffers ()\r
-DECLARE SUB editMode ()\r
-DECLARE SUB displayGrid ()\r
-DECLARE SUB clearLine ()\r
-DECLARE SUB processLife ()\r
-DECLARE SUB initialize ()\r
-DIM SHARED buffer1(1 TO 50, 1 TO 50)\r
-DIM SHARED buffer2(1 TO 50, 1 TO 50)\r
-DIM SHARED millisecond\r
-DIM SHARED frame\r
-DIM SHARED skip\r
-DIM SHARED buffer3(0 TO 50, 0 TO 50)\r
-DIM SHARED bufferXSize, bufferYSize\r
-initialize\r
-\r
-1\r
-processLife\r
-frame = frame + 1\r
-\r
-2\r
-LOCATE 1, 27\r
-PRINT "frame:" + STR$(frame) + " "\r
-LOCATE 2, 27\r
-PRINT "skip:" + STR$(skip) + " "\r
-\r
-key$ = INKEY$\r
-\r
-IF key$ = "s" THEN\r
- LOCATE 5, 27\r
- INPUT "skip ", skip\r
- clearLine\r
-END IF\r
-\r
-IF key$ = "q" THEN\r
- SYSTEM\r
-END IF\r
-\r
-IF key$ = "n" THEN GOTO 1\r
-\r
-IF key$ = "c" THEN clearBuffers\r
-\r
-IF key$ = "e" THEN editMode\r
-\r
-IF key$ = "z" THEN skip = 0\r
-\r
-IF key$ = "x" THEN skip = 10000\r
-\r
-IF key$ = "w" THEN writeFile\r
-\r
-IF key$ = "l" THEN loadFile\r
-\r
-IF skip > 0 THEN\r
- skip = skip - 1\r
- GOTO 1\r
-END IF\r
-GOTO 2\r
-\r
-SUB clearBuffers\r
-\r
-FOR y = 1 TO 50\r
- FOR x = 1 TO 50\r
- buffer1(x, y) = 0\r
- buffer2(x, y) = 0\r
- NEXT x\r
-NEXT y\r
-\r
-millisecond = 0\r
-frame = 0\r
-skip = 0\r
-\r
-displayGrid\r
-END SUB\r
-\r
-SUB clearLine\r
-LOCATE 5, 27\r
-PRINT " "\r
-END SUB\r
-\r
-SUB displayGrid\r
-\r
-FOR y = 1 TO 50\r
- FOR x = 1 TO 50\r
- IF millisecond = 0 THEN clr = buffer1(x, y) ELSE clr = buffer2(x, y)\r
- IF clr = 0 THEN clr = 1 ELSE clr = 10\r
- LINE (x * 4, y * 4)-(x * 4 + 2, y * 4 + 2), clr, BF\r
- NEXT x\r
-NEXT y\r
-\r
-END SUB\r
-\r
-SUB editMode\r
-x = 25\r
-y = 25\r
-3\r
-IF x < 1 THEN x = 1\r
-IF y < 1 THEN y = 1\r
-IF x > 50 THEN x = 50\r
-IF y > 49 THEN y = 49\r
-\r
-IF millisecond = 0 THEN clr = buffer1(x, y) ELSE clr = buffer2(x, y)\r
-IF clr = 0 THEN clr = 1 ELSE clr = 10\r
-LINE (x * 4, y * 4)-(x * 4 + 2, y * 4 + 2), clr, BF\r
-\r
-LINE (x * 4 - 1, y * 4 - 1)-(x * 4 + 3, y * 4 + 3), 14, B\r
-4\r
-key$ = INKEY$\r
-IF key$ = "" THEN GOTO 4\r
-\r
-LINE (x * 4 - 1, y * 4 - 1)-(x * 4 + 3, y * 4 + 3), 0, B\r
-\r
-IF key$ = CHR$(0) + "M" THEN x = x + 1\r
-IF key$ = CHR$(0) + "K" THEN x = x - 1\r
-IF key$ = CHR$(0) + "P" THEN y = y + 1\r
-IF key$ = CHR$(0) + "H" THEN y = y - 1\r
-IF key$ = "6" THEN x = x + 8\r
-IF key$ = "4" THEN x = x - 8\r
-IF key$ = "2" THEN y = y + 8\r
-IF key$ = "8" THEN y = y - 8\r
-\r
-IF key$ = CHR$(27) THEN GOTO 5\r
-IF key$ = "s" THEN selectMode x, y\r
-\r
-IF key$ = "v" THEN\r
- FOR y1 = 0 TO bufferYSize\r
- FOR x1 = 0 TO bufferXSize\r
- clr = buffer3(x1, y1)\r
- x2 = x1 + x\r
- y2 = y1 + y\r
-\r
- IF (x2 < 50) AND (y2 < 50) THEN\r
- IF millisecond = 0 THEN buffer1(x2, y2) = clr ELSE buffer2(x2, y2) = clr\r
- END IF\r
-\r
- NEXT x1\r
- NEXT y1\r
- displayGrid\r
-END IF\r
-\r
-IF key$ = " " THEN\r
- IF millisecond = 0 THEN clr = buffer1(x, y) ELSE clr = buffer2(x, y)\r
- IF clr = 1 THEN clr = 0 ELSE clr = 1\r
- IF millisecond = 0 THEN buffer1(x, y) = clr ELSE buffer2(x, y) = clr\r
-END IF\r
-\r
-GOTO 3\r
-5\r
-\r
-END SUB\r
-\r
-SUB initialize\r
-SCREEN 13\r
-RANDOMIZE TIMER\r
-\r
-bufferXSize = 0\r
-bufferYSize = 0\r
-\r
-clearBuffers\r
-\r
-END SUB\r
-\r
-SUB loadFile\r
-\r
-clearBuffers\r
-LOCATE 5, 27\r
-INPUT "file ", filename$\r
-clearLine\r
-\r
-y = 1\r
-OPEN filename$ FOR INPUT AS #1\r
-9\r
-IF EOF(1) <> 0 THEN GOTO 10\r
-\r
-LINE INPUT #1, line$\r
-\r
-FOR x = 1 TO LEN(line$)\r
- char$ = RIGHT$(LEFT$(line$, x), 1)\r
- IF char$ = "#" THEN clr = 1 ELSE clr = 0\r
- IF millisecond = 0 THEN buffer1(x, y) = clr ELSE buffer2(x, y) = clr\r
-NEXT x\r
-y = y + 1\r
-\r
-GOTO 9\r
-10\r
-CLOSE #1\r
-displayGrid\r
-\r
-END SUB\r
-\r
-SUB processLife\r
-\r
-IF millisecond = 0 THEN\r
- FOR y = 2 TO 48\r
- FOR x = 2 TO 49\r
- IF buffer1(x - 1, y - 1) = 1 THEN count = 1 ELSE count = 0\r
- IF buffer1(x, y - 1) = 1 THEN count = count + 1\r
- IF buffer1(x + 1, y - 1) = 1 THEN count = count + 1\r
- IF buffer1(x - 1, y) = 1 THEN count = count + 1\r
- IF buffer1(x + 1, y) = 1 THEN count = count + 1\r
- IF buffer1(x - 1, y + 1) = 1 THEN count = count + 1\r
- IF buffer1(x, y + 1) = 1 THEN count = count + 1\r
- IF buffer1(x + 1, y + 1) = 1 THEN count = count + 1\r
-\r
- IF buffer1(x, y) = 1 THEN\r
- IF count = 2 OR count = 3 THEN buffer2(x, y) = 1 ELSE buffer2(x, y) = 0\r
- ELSE\r
- IF count = 3 THEN buffer2(x, y) = 1 ELSE buffer2(x, y) = 0\r
- END IF\r
-\r
- NEXT x\r
- NEXT y\r
- millisecond = 1\r
- displayGrid\r
-ELSE\r
-\r
- FOR y = 2 TO 48\r
- FOR x = 2 TO 49\r
- IF buffer2(x - 1, y - 1) = 1 THEN count = 1 ELSE count = 0\r
- IF buffer2(x, y - 1) = 1 THEN count = count + 1\r
- IF buffer2(x + 1, y - 1) = 1 THEN count = count + 1\r
- IF buffer2(x - 1, y) = 1 THEN count = count + 1\r
- IF buffer2(x + 1, y) = 1 THEN count = count + 1\r
- IF buffer2(x - 1, y + 1) = 1 THEN count = count + 1\r
- IF buffer2(x, y + 1) = 1 THEN count = count + 1\r
- IF buffer2(x + 1, y + 1) = 1 THEN count = count + 1\r
-\r
- IF buffer2(x, y) = 1 THEN\r
- IF count = 2 OR count = 3 THEN buffer1(x, y) = 1 ELSE buffer1(x, y) = 0\r
- ELSE\r
- IF count = 3 THEN buffer1(x, y) = 1 ELSE buffer1(x, y) = 0\r
- END IF\r
- NEXT x\r
- NEXT y\r
-\r
- millisecond = 0\r
- displayGrid\r
-END IF\r
-\r
-END SUB\r
-\r
-SUB selectMode (x, y)\r
-x1 = x * 4 - 1\r
-y1 = y * 4 - 1\r
-x2 = x + 2\r
-y2 = y + 2\r
-\r
-6\r
-x3 = x2 * 4 + 3\r
-y3 = y2 * 4 + 3\r
-\r
-LINE (x1, y1)-(x3, y3), 14, B\r
-8\r
-key$ = INKEY$\r
-IF key$ = "" THEN GOTO 8\r
-LINE (x1, y1)-(x3, y3), 0, B\r
-\r
-IF key$ = CHR$(0) + "M" THEN x2 = x2 + 1\r
-IF key$ = CHR$(0) + "K" THEN x2 = x2 - 1\r
-IF key$ = CHR$(0) + "P" THEN y2 = y2 + 1\r
-IF key$ = CHR$(0) + "H" THEN y2 = y2 - 1\r
-\r
-IF key$ = "6" THEN x2 = x2 + 8\r
-IF key$ = "4" THEN x2 = x2 - 8\r
-IF key$ = "2" THEN y2 = y2 + 8\r
-IF key$ = "8" THEN y2 = y2 - 8\r
-\r
-IF key$ = CHR$(27) THEN GOTO 7\r
-IF key$ = "c" THEN\r
- bufferXSize = x2 - x\r
- bufferYSize = y2 - y\r
-\r
- FOR y4 = y TO y2\r
- FOR x4 = x TO x2\r
- IF millisecond = 0 THEN clr = buffer1(x4, y4) ELSE clr = buffer2(x4, y4)\r
- buffer3(x4 - x, y4 - y) = clr\r
- NEXT x4\r
- NEXT y4\r
- showBuffer\r
-END IF\r
-\r
-IF key$ = "x" THEN\r
- bufferXSize = x2 - x\r
- bufferYSize = y2 - y\r
-\r
- FOR y4 = y TO y2\r
- FOR x4 = x TO x2\r
- IF millisecond = 0 THEN clr = buffer1(x4, y4): buffer1(x4, y4) = 0 ELSE clr = buffer2(x4, y4): buffer2(x4, y4) = 0\r
- buffer3(x4 - x, y4 - y) = clr\r
- NEXT x4\r
- NEXT y4\r
- showBuffer\r
- displayGrid\r
-END IF\r
-\r
-GOTO 6\r
-7\r
-\r
-END SUB\r
-\r
-SUB showBuffer\r
-\r
-'PRINT bufxs\r
-'PRINT bufys\r
-\r
-x = bufferXSize\r
-IF x > 15 THEN x = 15\r
-y = bufferYSize\r
-IF y > 15 THEN y = 15\r
-\r
-LINE (204, 99)-(319, 199), 0, BF\r
-LINE (204, 99)-(208 + 4 * bufferXSize, 103 + 4 * bufferYSize), 14, B\r
-\r
-FOR y2 = 0 TO y\r
- FOR x2 = 0 TO x\r
- clr = buffer3(x2, y2)\r
- IF clr = 0 THEN clr = 1 ELSE clr = 10\r
- LINE (x2 * 4 + 205, y2 * 4 + 100)-(x2 * 4 + 2 + 205, y2 * 4 + 2 + 100), clr, BF\r
- NEXT x2\r
-NEXT y2\r
-\r
-END SUB\r
-\r
-SUB writeFile\r
-LOCATE 5, 27\r
-INPUT "file ", filename$\r
-clearLine\r
-\r
-OPEN filename$ FOR OUTPUT AS #1\r
-\r
-FOR y = 1 TO 50\r
- line$ = ""\r
- FOR x = 1 TO 50\r
- IF millisecond = 0 THEN clr = buffer1(x, y) ELSE clr = buffer2(x, y)\r
- IF clr = 0 THEN line$ = line$ + "." ELSE line$ = line$ + "#"\r
- NEXT x\r
- PRINT #1, line$\r
-NEXT y\r
-\r
-CLOSE #1\r
-\r
-END SUB\r
-\r