about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-11-07 16:36:47 -0800
committerKartik Agaram <vc@akkartik.com>2020-11-07 16:36:47 -0800
commit5e3927f7e1233e8dd75f19a7cab056ca91ca22c6 (patch)
tree8a8d368a2e6a4e5afe6a15dbe0198e80559ddbf1
parent8338c38698aab9f885af0ddac3a1d47a31991f97 (diff)
downloadmu-5e3927f7e1233e8dd75f19a7cab056ca91ca22c6.tar.gz
7206 - tile: up/down/left/right now print lines
-rw-r--r--apps/tile/rpn.mu77
1 files changed, 57 insertions, 20 deletions
diff --git a/apps/tile/rpn.mu b/apps/tile/rpn.mu
index 2563928f..b0ca353d 100644
--- a/apps/tile/rpn.mu
+++ b/apps/tile/rpn.mu
@@ -384,10 +384,20 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch:
         var target-ah/eax: (addr handle screen) <- get target-val, screen-data
         var _target/eax: (addr screen) <- lookup *target-ah
         var target/edi: (addr screen) <- copy _target
-        var dest/eax: (addr int) <- get target, cursor-row
-        compare *dest, 1
-        break-if-<= $evaluate:process-word
-        subtract-from *dest, d
+        var r/edx: (addr int) <- get target, cursor-row
+        var c/eax: (addr int) <- get target, cursor-col
+        var col/eax: int <- copy *c
+        {
+          compare d, 0
+          break-if-<=
+          compare *r, 1
+          break-if-<=
+          print-string target "│"
+          decrement *r
+          move-cursor target, *r, col
+          d <- decrement
+          loop
+        }
         break $evaluate:process-word
       }
       {
@@ -417,14 +427,22 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch:
         var target-ah/eax: (addr handle screen) <- get target-val, screen-data
         var _target/eax: (addr screen) <- lookup *target-ah
         var target/edi: (addr screen) <- copy _target
-        var dest/eax: (addr int) <- get target, cursor-row
+        var bound-a/ebx: (addr int) <- get target, num-rows
+        var bound/ebx: int <- copy *bound-a
+        var r/edx: (addr int) <- get target, cursor-row
+        var c/eax: (addr int) <- get target, cursor-col
+        var col/eax: int <- copy *c
         {
-          var bound-a/ecx: (addr int) <- get target, num-rows
-          var bound/ecx: int <- copy *bound-a
-          compare *dest, bound
-          break-if->= $evaluate:process-word
+          compare d, 0
+          break-if-<=
+          compare *r, bound
+          break-if->=
+          print-string target "│"
+          increment *r
+          move-cursor target, *r, col
+          d <- decrement
+          loop
         }
-        add-to *dest, d
         break $evaluate:process-word
       }
       {
@@ -454,10 +472,21 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch:
         var target-ah/eax: (addr handle screen) <- get target-val, screen-data
         var _target/eax: (addr screen) <- lookup *target-ah
         var target/edi: (addr screen) <- copy _target
-        var dest/eax: (addr int) <- get target, cursor-col
-        compare *dest, 1
-        break-if-<= $evaluate:process-word
-        subtract-from *dest, d
+        var c/edx: (addr int) <- get target, cursor-col
+        var r/eax: (addr int) <- get target, cursor-row
+        var row/eax: int <- copy *r
+        {
+          compare d, 0
+          break-if-<=
+          compare *c, 1
+          break-if-<=
+          print-string target "─"
+          decrement *c
+          decrement *c  # second one to undo the print above
+          move-cursor target, row, *c
+          d <- decrement
+          loop
+        }
         break $evaluate:process-word
       }
       {
@@ -487,14 +516,22 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch:
         var target-ah/eax: (addr handle screen) <- get target-val, screen-data
         var _target/eax: (addr screen) <- lookup *target-ah
         var target/edi: (addr screen) <- copy _target
-        var dest/eax: (addr int) <- get target, cursor-col
+        var bound-a/ebx: (addr int) <- get target, num-rows
+        var bound/ebx: int <- copy *bound-a
+        var c/edx: (addr int) <- get target, cursor-col
+        var r/eax: (addr int) <- get target, cursor-row
+        var row/eax: int <- copy *r
         {
-          var bound-a/ecx: (addr int) <- get target, num-cols
-          var bound/ecx: int <- copy *bound-a
-          compare *dest, bound
-          break-if->= $evaluate:process-word
+          compare d, 0
+          break-if-<=
+          compare *c, bound
+          break-if->=
+          print-string target "─"
+          increment *c
+          move-cursor target, row, *c
+          d <- decrement
+          loop
         }
-        add-to *dest, d
         break $evaluate:process-word
       }
       ## HACKS: we're trying to avoid turning this into Forth