about summary refs log tree commit diff stats
path: root/chessboard-cursor.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-01-15 22:03:23 -0800
committerKartik K. Agaram <vc@akkartik.com>2015-01-15 22:03:23 -0800
commitd2db5af7b82a935dc2929a1db2e6d13db660be89 (patch)
tree21d1c6a6e9827f6e167b873f0818ef055d4691e8 /chessboard-cursor.mu
parent732964befbe605be6c697edcf21aa06afaf5b800 (diff)
downloadmu-d2db5af7b82a935dc2929a1db2e6d13db660be89.tar.gz
573 - print-board now takes terminal parameter
Feeling more confident now that prints are being managed right.
Diffstat (limited to 'chessboard-cursor.mu')
-rw-r--r--chessboard-cursor.mu21
1 files changed, 11 insertions, 10 deletions
diff --git a/chessboard-cursor.mu b/chessboard-cursor.mu
index 5ccfacb8..ddd874ec 100644
--- a/chessboard-cursor.mu
+++ b/chessboard-cursor.mu
@@ -48,6 +48,7 @@
 
 (function print-board [
   (default-space:space-address <- new space:literal 30:literal)
+  (screen:terminal-address <- next-input)
   (b:board-address <- next-input)
   (row:integer <- copy 7:literal)
   ; print each row
@@ -56,8 +57,8 @@
     (break-if done?:boolean)
     ; print rank number as a legend
     (rank:integer <- add row:integer 1:literal)
-    (print-primitive nil:literal/terminal rank:integer)
-    (print-primitive nil:literal/terminal ((" | " literal)))
+    (print-primitive screen:terminal-address rank:integer)
+    (print-primitive screen:terminal-address ((" | " literal)))
     ; print each square in the row
     (col:integer <- copy 0:literal)
     { begin
@@ -65,20 +66,20 @@
       (break-if done?:boolean)
       (f:file-address <- index b:board-address/deref col:integer)
       (s:square <- index f:file-address/deref row:integer)
-      (print-primitive nil:literal/terminal s:square)
-      (print-primitive nil:literal/terminal ((" " literal)))
+      (print-primitive screen:terminal-address s:square)
+      (print-primitive screen:terminal-address ((" " literal)))
       (col:integer <- add col:integer 1:literal)
       (loop)
     }
     (row:integer <- subtract row:integer 1:literal)
-    (cursor-to-next-line nil:literal/terminal)
+    (cursor-to-next-line screen:terminal-address)
     (loop)
   }
   ; print file letters as legend
-  (print-primitive nil:literal/terminal (("  +----------------" literal)))
-  (cursor-to-next-line nil:literal/terminal)
-  (print-primitive nil:literal/terminal (("    a b c d e f g h" literal)))
-  (cursor-to-next-line nil:literal/terminal)
+  (print-primitive screen:terminal-address (("  +----------------" literal)))
+  (cursor-to-next-line screen:terminal-address)
+  (print-primitive screen:terminal-address (("    a b c d e f g h" literal)))
+  (cursor-to-next-line screen:terminal-address)
 ])
 
 ;; data structure: move
@@ -229,7 +230,7 @@
     (print-primitive nil:literal/terminal (("Stupid text-mode chessboard. White pieces in uppercase; black pieces in lowercase. No checking for legal moves." literal)))
     (cursor-to-next-line nil:literal/terminal)
     (cursor-to-next-line nil:literal/terminal)
-    (print-board b:board-address)
+    (print-board nil:literal/terminal b:board-address)
     (cursor-to-next-line nil:literal/terminal)
     (print-primitive nil:literal/terminal (("Type in your move as <from square>-<to square>. For example: 'a2-a4'. Currently very unforgiving of typos; exactly five letters, no <Enter>, no uppercase." literal)))
     (cursor-to-next-line nil:literal/terminal)