about summary refs log tree commit diff stats
path: root/chessboard.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-01-25 01:41:40 -0800
committerKartik K. Agaram <vc@akkartik.com>2015-01-25 01:41:40 -0800
commitbee53b4b169feab631658b5450328a317779831a (patch)
treeedcbafff1d75e1467586540f5b216ba093e67e6c /chessboard.mu
parenta5fb9d1554bc04fcd0480cf0634855942e045d7b (diff)
downloadmu-bee53b4b169feab631658b5450328a317779831a.tar.gz
619 - chessboard now working right
2 bugs found:
  a) Have to slurp the newlines.
  b) Have to clear the line-buffer at the start of each line.
Diffstat (limited to 'chessboard.mu')
-rw-r--r--chessboard.mu20
1 files changed, 18 insertions, 2 deletions
diff --git a/chessboard.mu b/chessboard.mu
index e976e3ab..9479ab24 100644
--- a/chessboard.mu
+++ b/chessboard.mu
@@ -107,6 +107,7 @@
   (expect-stdin stdin:channel-address ((#\- literal)))
   (to-file:integer <- read-file stdin:channel-address)
   (to-rank:integer <- read-rank stdin:channel-address)
+  (expect-stdin stdin:channel-address ((#\newline literal)))
   ; construct the move object
   (result:move-address <- new move:literal)
   (f:integer-integer-pair-address <- get-address result:move-address/deref from:offset)
@@ -127,9 +128,14 @@
   (default-space:space-address <- new space:literal 30:literal)
   (stdin:channel-address <- next-input)
   (x:tagged-value stdin:channel-address/deref <- read stdin:channel-address)
+;?   (print-primitive-to-host x:tagged-value) ;? 1
+;?   (print-primitive-to-host (("\n" literal))) ;? 1
   (a:character <- copy ((#\a literal)))
   (file-base:integer <- character-to-integer a:character)
   (c:character <- maybe-coerce x:tagged-value character:literal)
+;?   (print-primitive-to-host (("AAA " literal))) ;? 1
+;?   (print-primitive-to-host c:character) ;? 1
+;?   (print-primitive-to-host (("\n" literal))) ;? 1
   { begin
     (quit:boolean <- equal c:character ((#\q literal)))
     (break-unless quit:boolean)
@@ -150,6 +156,9 @@
   (stdin:channel-address <- next-input)
   (x:tagged-value stdin:channel-address/deref <- read stdin:channel-address)
   (c:character <- maybe-coerce x:tagged-value character:literal)
+;?   (print-primitive-to-host (("BBB " literal))) ;? 1
+;?   (print-primitive-to-host c:character) ;? 1
+;?   (print-primitive-to-host (("\n" literal))) ;? 1
   { begin
     (quit:boolean <- equal c:character ((#\q literal)))
     (break-unless quit:boolean)
@@ -167,10 +176,10 @@
   (reply rank:integer)
 ])
 
+; slurp a character and check that it matches
 (function expect-stdin [
   (default-space:space-address <- new space:literal 30:literal)
   (stdin:channel-address <- next-input)
-  ; slurp hyphen
   (x:tagged-value stdin:channel-address/deref <- read stdin:channel-address)
   (c:character <- maybe-coerce x:tagged-value character:literal)
   (expected:character <- next-input)
@@ -223,12 +232,19 @@
     (cursor-to-next-line nil:literal/terminal)
     (print-board nil:literal/terminal b:board-address)
     (cursor-to-next-line nil:literal/terminal)
-    (print-primitive-to-host (("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)))
+    (print-primitive-to-host (("Type in your move as <from square>-<to square>. For example: 'a2-a4'. Then press <enter>." literal)))
     (cursor-to-next-line nil:literal/terminal)
     (print-primitive-to-host (("Hit 'q' to exit." literal)))
     (cursor-to-next-line nil:literal/terminal)
     (print-primitive-to-host (("move: " literal)))
     (m:move-address <- read-move buffered-stdin:channel-address)
+;?     (retro-mode) ;? 1
+;?     (print-primitive-to-host stdin:channel-address) ;? 1
+;?     (print-primitive-to-host (("\n" literal))) ;? 1
+;?     (print-primitive-to-host buffered-stdin:channel-address) ;? 1
+;?     (print-primitive-to-host (("\n" literal))) ;? 1
+;?     (dump-memory) ;? 1
+;?     (cursor-mode) ;? 1
     (break-unless m:move-address)
     (b:board-address <- make-move b:board-address m:move-address)
     (loop)