about summary refs log tree commit diff stats
path: root/apps/tile
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-11-06 17:46:42 -0800
committerKartik Agaram <vc@akkartik.com>2020-11-06 17:46:42 -0800
commit7ee2129ef4918283b7b02593251ecab0cc4483eb (patch)
treeb80ff5ecd6869839d4a50aeb180a543e6d37b1cd /apps/tile
parentaa96c23f0cb3b5b18202e755fc7cd2c700b7216a (diff)
downloadmu-7ee2129ef4918283b7b02593251ecab0cc4483eb.tar.gz
7199 - tile: primitive 'move'
Diffstat (limited to 'apps/tile')
-rw-r--r--apps/tile/rpn.mu31
1 files changed, 30 insertions, 1 deletions
diff --git a/apps/tile/rpn.mu b/apps/tile/rpn.mu
index 06d3a57d..71562eaf 100644
--- a/apps/tile/rpn.mu
+++ b/apps/tile/rpn.mu
@@ -311,7 +311,7 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch:
         var top/eax: int <- copy *top-addr
         var dest-offset/edx: (offset value) <- compute-offset data, top
         var s/esi: (addr value) <- index data, dest-offset
-        # select screen from top of out (but don't pop it)
+        # select target screen from top of out (but don't pop it)
         compare *top-addr, 0
         break-if-<=
         var top/eax: int <- copy *top-addr
@@ -321,6 +321,7 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch:
         var type/eax: (addr int) <- get target-val, type
         compare *type, 4  # screen
         break-if-!=
+        # print string to target screen
         var dest-ah/eax: (addr handle screen) <- get target-val, screen-data
         var dest/eax: (addr screen) <- lookup *dest-ah
         var r/ecx: (addr int) <- get dest, cursor-row
@@ -328,6 +329,34 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch:
         render-value-at dest, *r, *c, s, 0
         break $evaluate:process-word
       }
+      {
+        var is-move?/eax: boolean <- stream-data-equal? curr-stream, "move"
+        compare is-move?, 0
+        break-if-=
+        var out2/esi: (addr value-stack) <- copy out
+        var _r/eax: int <- pop-int-from-value-stack out2
+        var r/ecx: int <- copy _r
+        var _c/eax: int <- pop-int-from-value-stack out2
+        var c/edx: int <- copy _c
+        # select screen from top of out (but don't pop it)
+        var top-addr/ebx: (addr int) <- get out2, top
+        compare *top-addr, 0
+        break-if-<=
+        var data-ah/eax: (addr handle array value) <- get out2, data
+        var _data/eax: (addr array value) <- lookup *data-ah
+        var data/edi: (addr array value) <- copy _data
+        var top/eax: int <- copy *top-addr
+        top <- decrement
+        var target-offset/eax: (offset value) <- compute-offset data, top
+        var target-val/ebx: (addr value) <- index data, target-offset
+        var type/eax: (addr int) <- get target-val, type
+        compare *type, 4  # screen
+        break-if-!=
+        var target-ah/eax: (addr handle screen) <- get target-val, screen-data
+        var target/eax: (addr screen) <- lookup *target-ah
+        move-cursor target, r, c
+        break $evaluate:process-word
+      }
       ## HACKS: we're trying to avoid turning this into Forth
       {
         var is-dup?/eax: boolean <- stream-data-equal? curr-stream, "dup"