From d2db5af7b82a935dc2929a1db2e6d13db660be89 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Thu, 15 Jan 2015 22:03:23 -0800 Subject: 573 - print-board now takes terminal parameter Feeling more confident now that prints are being managed right. --- chessboard-cursor.mu | 21 +++++++++++---------- 1 file 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 -. For example: 'a2-a4'. Currently very unforgiving of typos; exactly five letters, no , no uppercase." literal))) (cursor-to-next-line nil:literal/terminal) -- cgit 1.4.1-2-gfad0 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82