about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-05-07 11:56:43 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-05-07 11:56:43 -0700
commitd605ba1f9ab08ead61a73f2f102fd8741b4c0352 (patch)
tree1709e67a75d8f71b4fa3a79d6d3fe8a0c51c1f73
parentd8298d1a2af876915cd4ba8d6a7b5ae7dc2dd0e3 (diff)
downloadmu-d605ba1f9ab08ead61a73f2f102fd8741b4c0352.tar.gz
clean up chessboard
We still benefit from some helpers here because of the unrolling and multiple
calls to helpers.
-rw-r--r--shell/data.limg22
-rw-r--r--shell/evaluate.mu4
2 files changed, 15 insertions, 11 deletions
diff --git a/shell/data.limg b/shell/data.limg
index 26b7a27d..070f24fa 100644
--- a/shell/data.limg
+++ b/shell/data.limg
@@ -53,19 +53,21 @@
       (set c (key keyboard))))
   str)))])
   (chessboard . [(def chessboard (fn (screen px)
-  (chessboard1 screen px 0 15)))])
-  (chessboard1 . [(def chessboard1 (fn (screen px y color)
   (clear screen)
-  (while (< y (height screen))
-    (chessboard2 screen px y 0 color)
+  (let xmax (width screen)
+  (let ymax (height screen)
+  (let y 0
+  (while (< y ymax)
+    (chessboard_row screen px y 0 xmax)
     (set y (+ y px))
-    (chessboard2 screen px y px color)
+    (chessboard_row screen px y px xmax)
     (set y (+ y px)))))])
-  (chessboard2 . [(def chessboard2 (fn (screen px y x color)
-  (while (< x (width screen))
-    (fill_rect screen x y (+ x px) (+ y px) color)
-    (set x (+ x px))
-    (set x (+ x px)))))])
+  (chessboard_row . [(def chessboard_row (fn (screen px y x xmax)
+  (while (< x xmax)
+    (fill_rect screen
+               x        y
+               (+ x px) (+ y px) 15)
+    (set x (+ x (* px 2))))))])
   (brcircle . [(def brcircle (fn (screen cx cy r color)
   ((fn (x y err continue)
      (while continue
diff --git a/shell/evaluate.mu b/shell/evaluate.mu
index eb0b1e42..5e0122b0 100644
--- a/shell/evaluate.mu
+++ b/shell/evaluate.mu
@@ -474,11 +474,13 @@ fn evaluate _in-ah: (addr handle cell), _out-ah: (addr handle cell), env-h: (han
     debug-print "B", 4/fg, 0xc5/bg=blue-bg
     # a trip wire in case we're running without a trace (e.g. when loading the initial state from disk)
     {
+      compare trace, 0
+      break-if-!=
       var left-out/eax: (addr cell) <- lookup *left-out-ah
       compare left-out, 0
       {
         break-if-!=
-        abort "unknown variable"
+        abort "error in eval-list"
       }
     }
     #