about summary refs log tree commit diff stats
path: root/chessboard.mu
diff options
context:
space:
mode:
Diffstat (limited to 'chessboard.mu')
-rw-r--r--chessboard.mu12
1 files changed, 11 insertions, 1 deletions
diff --git a/chessboard.mu b/chessboard.mu
index 946708e1..3797c805 100644
--- a/chessboard.mu
+++ b/chessboard.mu
@@ -161,7 +161,8 @@ def print screen:&:screen, board:board -> screen:&:screen [
       break-if done?
       f:&:@:char <- index *board, col
       c:char <- index *f, row
-      print screen, c
+      bg:num <- square-color row, col
+      print screen, c, 7/white, bg
       print screen, space
       col <- add col, 1
       loop
@@ -177,6 +178,15 @@ def print screen:&:screen, board:board -> screen:&:screen [
   cursor-to-next-line screen
 ]
 
+def square-color row:num, col:num -> result:num [
+  local-scope
+  load-inputs
+  result <- copy 0/black
+  x:num <- add row, col
+  _, rem:num <- divide-with-remainder x, 2
+  return-if rem, 238
+]
+
 def initial-position -> board:board [
   local-scope
   # layout in memory (in raster order):