about summary refs log tree commit diff stats
path: root/shell/data.limg
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-07-26 02:27:32 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-07-26 02:27:32 -0700
commit46441d7204cb14e14bc25ff3c43a912281035a1c (patch)
tree615ee983f8c6ed7b62dc6d7c8e66bd6fe38d21dc /shell/data.limg
parent81c3678515e9fe848daeec129918a7baf929bf96 (diff)
downloadmu-46441d7204cb14e14bc25ff3c43a912281035a1c.tar.gz
.
Smoked out some issues by rendering a single frame of Game of Life.
Incredibly slow.
Diffstat (limited to 'shell/data.limg')
-rw-r--r--shell/data.limg35
1 files changed, 30 insertions, 5 deletions
diff --git a/shell/data.limg b/shell/data.limg
index a0dc33c7..88e81da6 100644
--- a/shell/data.limg
+++ b/shell/data.limg
@@ -66,10 +66,6 @@
       (list (list (car xs)))
       (cons (list (car xs) (cadr xs))
             (pair (cddr xs)))])
-    (grid . [def (grid m n val)
-  ret g (populate n ())
-    for i 0 (< i n) ++i
-      iset g i (populate m val)])
     (with . [mac (with bindings . body)
   `((fn ,(map1 car (pair bindings))
       ,@body)
@@ -124,6 +120,14 @@
      (while ,test
        ,@body
        ,update))])
+    (grid . [def (grid m n val)
+  ret g (populate n ())
+    for i 0 (< i n) ++i
+      iset g i (populate m val)])
+    (indexgrid . [def (indexgrid g x y)
+  (index (index g y) x)])
+    (isetgrid . [def (isetgrid g x y val)
+  iset (index g y) x val])
     (hborder . [def (hborder scr y color)
   (hline scr y 0 (width scr) color)])
     (vborder . [def (vborder scr x color)
@@ -162,6 +166,27 @@
         (pixel screen x y (palette Greys x*y))])
     (main . [def (main screen keyboard)
   (pat screen)])
+    (lifreres . [define liferes 8])
+    (life . [def (life screen)
+  let g (grid (/ (width screen) liferes)
+              (/ (height screen) liferes)
+              0)
+    isetgrid g 5 5 1
+    isetgrid g 6 5 1
+    isetgrid g 4 6 1
+    isetgrid g 5 6 1
+    isetgrid g 5 7 1
+    while 1
+      steplife g
+      renderlife screen g])
+    (steplife . [def (steplife g)
+  ])
+    (renderlife . [def (renderlife screen g)
+  with (w (width screen)
+        h (height screen))
+    for y 0 (< y h) ++y
+      for x 0 (< x w) ++x
+        (pixel screen x y (indexgrid g x/liferes y/liferes))])
   ))
-  (sandbox . [pat screen])
+  (sandbox . [life screen])
 )