clean up chessboard

We still benefit from some helpers here because of the unrolling and multiple
calls to helpers.
This commit is contained in:
Kartik K. Agaram 2021-05-07 11:56:43 -07:00
parent d8298d1a2a
commit d605ba1f9a
2 changed files with 15 additions and 11 deletions

View File

@ -53,19 +53,21 @@
(set c (key keyboard)))) (set c (key keyboard))))
str)))]) str)))])
(chessboard . [(def chessboard (fn (screen px) (chessboard . [(def chessboard (fn (screen px)
(chessboard1 screen px 0 15)))])
(chessboard1 . [(def chessboard1 (fn (screen px y color)
(clear screen) (clear screen)
(while (< y (height screen)) (let xmax (width screen)
(chessboard2 screen px y 0 color) (let ymax (height screen)
(let y 0
(while (< y ymax)
(chessboard_row screen px y 0 xmax)
(set y (+ y px)) (set y (+ y px))
(chessboard2 screen px y px color) (chessboard_row screen px y px xmax)
(set y (+ y px)))))]) (set y (+ y px)))))])
(chessboard2 . [(def chessboard2 (fn (screen px y x color) (chessboard_row . [(def chessboard_row (fn (screen px y x xmax)
(while (< x (width screen)) (while (< x xmax)
(fill_rect screen x y (+ x px) (+ y px) color) (fill_rect screen
(set x (+ x px)) x y
(set x (+ x px)))))]) (+ x px) (+ y px) 15)
(set x (+ x (* px 2))))))])
(brcircle . [(def brcircle (fn (screen cx cy r color) (brcircle . [(def brcircle (fn (screen cx cy r color)
((fn (x y err continue) ((fn (x y err continue)
(while continue (while continue

View File

@ -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 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) # 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 var left-out/eax: (addr cell) <- lookup *left-out-ah
compare left-out, 0 compare left-out, 0
{ {
break-if-!= break-if-!=
abort "unknown variable" abort "error in eval-list"
} }
} }
# #