From 89684e6677afbd6386e5a5a5214348c7ff53074e Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Tue, 22 Sep 2020 22:08:37 -0700 Subject: 6838 Interestingly, erasing the screen partially looks better to me even though it's clearly slower. The divider never being redrawn provides a sense of stability. --- apps/tile/box.mu | 41 +++++++++++++++++++++++++++++++++++++++++ apps/tile/environment.mu | 3 ++- 2 files changed, 43 insertions(+), 1 deletion(-) (limited to 'apps/tile') diff --git a/apps/tile/box.mu b/apps/tile/box.mu index 7cb69206..bc0f58e1 100644 --- a/apps/tile/box.mu +++ b/apps/tile/box.mu @@ -42,3 +42,44 @@ fn draw-vertical-line screen: (addr screen), row1: int, row2: int, col: int { loop } } + +# erase parts of screen the slow way +fn clear-rect screen: (addr screen), row1: int, col1: int, row2: int, col2: int { + var i/eax: int <- copy row1 + { + compare i, row2 + break-if-> + var j/ecx: int <- copy col1 + move-cursor screen, i, j + { + compare j, col2 + break-if-> + print-grapheme screen 0x20 # space + j <- increment + loop + } + i <- increment + loop + } +} + +fn clear-rect2 screen: (addr screen), row1: int, col1: int, w: int, h: int { + var i/eax: int <- copy 0 + var curr-row/esi: int <- copy row1 + { + compare i, w + break-if->= + move-cursor screen, curr-row, col1 + var j/ecx: int <- copy 0 + { + compare j, h + break-if->= + print-grapheme screen 0x20 # space + j <- increment + loop + } + i <- increment + curr-row <- increment + loop + } +} diff --git a/apps/tile/environment.mu b/apps/tile/environment.mu index cd5721b4..5415bf6d 100644 --- a/apps/tile/environment.mu +++ b/apps/tile/environment.mu @@ -163,12 +163,13 @@ fn render _env: (addr environment) { var _screen/eax: (addr screen) <- lookup *screen-ah var screen/edi: (addr screen) <- copy _screen # prepare screen - clear-screen screen var nrows/eax: (addr int) <- get env, nrows var _repl-col/ecx: (addr int) <- get env, code-separator-col var repl-col/ecx: int <- copy *_repl-col draw-vertical-line screen, 1, *nrows, repl-col repl-col <- add 2 # repl-margin-left + var ncols/edx: (addr int) <- get env, ncols + clear-rect screen, 1, repl-col, *nrows, *ncols move-cursor screen, 5, repl-col # input-row + stack-margin-top print-string screen, "stack:" move-cursor screen, 3, repl-col # input-row, input-col -- cgit 1.4.1-2-gfad0