about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--chessboard.mu34
1 files changed, 18 insertions, 16 deletions
diff --git a/chessboard.mu b/chessboard.mu
index 2d7f9b81..13fd42e4 100644
--- a/chessboard.mu
+++ b/chessboard.mu
@@ -561,46 +561,48 @@ scenario making-a-move [
 
 recipe chessboard [
   default-space:address:array:location <- new location:type, 30:literal
+  screen:address <- next-ingredient
+  keyboard:address <- next-ingredient
   board:address:array:address:array:character <- initial-position
-  switch-to-display
   # hook up stdin
   stdin:address:channel <- init-channel 10:literal/capacity
-  start-running send-keys-to-channel:recipe, 0:literal/keyboard, stdin:address:channel, 0:literal/screen
-  # buffer stdin
+  start-running send-keys-to-channel:recipe, keyboard:address, stdin:address:channel, screen:address
+  # buffer lines in stdin
   buffered-stdin:address:channel <- init-channel 10:literal/capacity
   start-running buffer-lines:recipe, stdin:address:channel, buffered-stdin:address:channel
   {
     msg:address:array:character <- new [Stupid text-mode chessboard. White pieces in uppercase; black pieces in lowercase. No checking for legal moves.
 ]
-    print-string 0:literal/screen, msg:address:array:character
-    cursor-to-next-line 0:literal/screen
-    print-board 0:literal/screen, board:address:array:address:array:character
-    cursor-to-next-line 0:literal/screen
+    print-string screen:address, msg:address:array:character
+    cursor-to-next-line screen:address
+    print-board screen:address, board:address:array:address:array:character
+    cursor-to-next-line screen:address
     msg:address:array:character <- new [Type in your move as <from square>-<to square>. For example: 'a2-a4'. Then press <enter>.
 ]
-    print-string 0:literal/screen, msg:address:array:character
-    cursor-to-next-line 0:literal/screen
+    print-string screen:address, msg:address:array:character
+    cursor-to-next-line screen:address
     msg:address:array:character <- new [Hit 'q' to exit.
 ]
-    print-string 0:literal/screen, msg:address:array:character
+    print-string screen:address, msg:address:array:character
     {
-      cursor-to-next-line 0:literal/screen
+      cursor-to-next-line screen:address
       msg:address:array:character <- new [move: ]
-      print-string 0:literal/screen, msg:address:array:character
-      m:address:move, quit:boolean, error:boolean <- read-move buffered-stdin:address:channel, 0:literal/screen
+      print-string screen:address, msg:address:array:character
+      m:address:move, quit:boolean, error:boolean <- read-move buffered-stdin:address:channel, screen:address
       break-if quit:boolean, +quit:offset
       buffered-stdin:address:channel <- clear-channel buffered-stdin:address:channel  # cleanup after error. todo: test this?
       loop-if error:boolean
     }
     board:address:array:address:array:character <- make-move board:address:array:address:array:character, m:address:move
-    clear-screen 0:literal/screen
+    clear-screen screen:address
     loop
   }
   +quit
 #?   $print [aaa] #? 1
-  return-to-console
 ]
 
 recipe main [
-  chessboard
+  switch-to-display
+  0:literal/real-screen, 0:literal/real-keyboard <- chessboard 0:literal/real-screen, 0:literal/real-keyboard
+  return-to-console
 ]