diff options
-rw-r--r-- | apps/tile/environment.mu | 2 | ||||
-rw-r--r-- | apps/tile/main.mu | 35 | ||||
-rw-r--r-- | apps/tile/rpn.mu | 12 | ||||
-rw-r--r-- | apps/tile/value.mu | 2 |
4 files changed, 40 insertions, 11 deletions
diff --git a/apps/tile/environment.mu b/apps/tile/environment.mu index 0cd978f3..e0260c23 100644 --- a/apps/tile/environment.mu +++ b/apps/tile/environment.mu @@ -1396,6 +1396,7 @@ fn callee functions: (addr handle function), word: (addr word), out: (addr handl # # Return the farthest column written. fn render-column screen: (addr screen), functions: (addr handle function), bindings: (addr table), first-line: (addr line), line: (addr line), final-word: (addr word), top-row: int, left-col: int -> _/ecx: int { +#? print-string 0, "== " #? print-string 0, "render-column\n" var max-width/esi: int <- copy 0 { @@ -1406,6 +1407,7 @@ fn render-column screen: (addr screen), functions: (addr handle function), bindi var stack: value-stack var stack-addr/edi: (addr value-stack) <- address stack initialize-value-stack stack-addr, 0x10 # max-words + initialize-table bindings, 0x10 evaluate functions, bindings, first-line, final-word, stack-addr # render stack var curr-row/edx: int <- copy top-row diff --git a/apps/tile/main.mu b/apps/tile/main.mu index 1ef1e268..6b18e82e 100644 --- a/apps/tile/main.mu +++ b/apps/tile/main.mu @@ -66,17 +66,30 @@ fn interactive { } fn test { - test-surface-pin-at-origin -#? var env-storage: environment -#? var env/esi: (addr environment) <- address env-storage -#? initialize-environment-with-fake-screen env, 5, 0xa -#? var g/eax: grapheme <- copy 0x22 # '"' -#? process env, g -#? g <- copy 0x61 # 'a' -#? process env, g -#? g <- copy 0x22 # '"' -#? process env, g -#? render env + var env-storage: environment + var env/esi: (addr environment) <- address env-storage + initialize-environment-with-fake-screen env, 0x20, 0xa0 + process-all env, "3 3 fake-screen =s" + process env, 0xc # ctrl-l + process-all env, "s 1 down " + render env +#? var fake-screen-ah/eax: (addr handle screen) <- get env, screen +#? var fake-screen/eax: (addr screen) <- lookup *fake-screen-ah +#? render-screen 0, 1, 1, fake-screen +} + +fn process-all env: (addr environment), cmds: (addr array byte) { + var cmds-stream: (stream byte 0x100) + var cmds-stream-a/esi: (addr stream byte) <- address cmds-stream + write cmds-stream-a, cmds + { + var done?/eax: boolean <- stream-empty? cmds-stream-a + compare done?, 0 # false + break-if-!= + var g/eax: grapheme <- read-grapheme cmds-stream-a + process env, g + loop + } } fn repl { diff --git a/apps/tile/rpn.mu b/apps/tile/rpn.mu index ecde7f0e..2cb61757 100644 --- a/apps/tile/rpn.mu +++ b/apps/tile/rpn.mu @@ -278,6 +278,7 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch: allocate screen-ah var screen/eax: (addr screen) <- lookup screen-h initialize-screen screen, nrows, ncols +#? render-screen 0, 5, 5, screen # push screen to stack var data-ah/eax: (addr handle array value) <- get out2, data var data/eax: (addr array value) <- lookup *data-ah @@ -408,6 +409,7 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch: var top-addr/ebx: (addr int) <- get out2, top compare *top-addr, 0 break-if-<= +#? print-string 0, "DOWN\n" # pop args var _d/eax: int <- pop-int-from-value-stack out2 var d/ecx: int <- copy _d @@ -427,6 +429,8 @@ 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 +#? print-string 0, "before:\n" +#? render-screen 0, 5, 5, target 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 @@ -443,6 +447,8 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch: d <- decrement loop } +#? print-string 0, "after:\n" +#? render-screen 0, 5, 5, target break $evaluate:process-word } { @@ -606,6 +612,9 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch: top <- decrement var dest-offset/edx: (offset value) <- compute-offset data, top var target-val/edx: (addr value) <- index data, dest-offset +#? var tmp-ah/eax: (addr handle screen) <- get target-val, screen-data +#? var tmp/eax: (addr screen) <- lookup *tmp-ah +#? render-screen 0, 5, 5, tmp # create binding from curr-stream to target-val var key-h: (handle array byte) var key/ecx: (addr handle array byte) <- address key-h @@ -640,6 +649,9 @@ fn evaluate functions: (addr handle function), bindings: (addr table), scratch: compare val, 0 break-if-= push-value-stack out, val +#? var tmp-ah/eax: (addr handle screen) <- get val, screen-data +#? var tmp/eax: (addr screen) <- lookup *tmp-ah +#? render-screen 0, 5, 5, tmp break $evaluate:process-word } ### if the word starts with a quote and ends with a quote, turn it into a string diff --git a/apps/tile/value.mu b/apps/tile/value.mu index e5c39cff..9e8c0050 100644 --- a/apps/tile/value.mu +++ b/apps/tile/value.mu @@ -145,6 +145,7 @@ fn render-screen screen: (addr screen), row: int, col: int, _target-screen: (add break-if-> increment row # mutate arg move-cursor screen, row, col +#? print-string screen, "\n" print-string screen, " " var c/edi: int <- copy 1 { @@ -159,6 +160,7 @@ fn render-screen screen: (addr screen), row: int, col: int, _target-screen: (add loop } increment row # mutate arg +#? print-string screen, "\n" move-cursor screen, row, col start-color screen, 0xf2, 7 print-lower-border screen, *ncols-a |