diff options
-rw-r--r-- | 500text-screen.mu | 54 | ||||
-rw-r--r-- | shell/global.mu | 4 | ||||
-rw-r--r-- | shell/main.mu | 6 | ||||
-rw-r--r-- | shell/sandbox.mu | 2 |
4 files changed, 61 insertions, 5 deletions
diff --git a/500text-screen.mu b/500text-screen.mu index 0fd7ae9d..92ea1d2f 100644 --- a/500text-screen.mu +++ b/500text-screen.mu @@ -221,6 +221,36 @@ fn clear-screen screen: (addr screen) { set-cursor-position screen, 0, 0 } +fn clear-rect screen: (addr screen), xmin: int, ymin: int, xmax: int, ymax: int, background-color: int { + { + compare screen, 0 + break-if-!= + clear-rect-on-real-screen xmin, ymin, xmax, ymax, background-color + return + } + # fake screen + set-cursor-position screen, 0, 0 + var screen-addr/esi: (addr screen) <- copy screen + var y/eax: int <- copy ymin + var ymax/ecx: int <- copy ymax + { + compare y, ymax + break-if->= + var x/edx: int <- copy xmin + var xmax/ebx: int <- copy xmax + { + compare x, xmax + break-if->= + draw-code-point screen, 0x20/space, x, y, 0/fg, background-color + x <- increment + loop + } + y <- increment + loop + } + set-cursor-position screen, 0, 0 +} + # there's no grapheme that guarantees to cover every pixel, so we'll bump down # to pixels for a real screen fn clear-real-screen { @@ -241,6 +271,30 @@ fn clear-real-screen { } } +fn clear-rect-on-real-screen xmin: int, ymin: int, xmax: int, ymax: int, background-color: int { + var y/eax: int <- copy ymin + y <- shift-left 4/log-font-height + var ymax/ecx: int <- copy ymax + ymax <- shift-left 4/log-font-height + { + compare y, ymax + break-if->= + var x/edx: int <- copy xmin + x <- shift-left 3/log-font-width + var xmax/ebx: int <- copy xmax + xmax <- shift-left 3/log-font-width + { + compare x, xmax + break-if->= + pixel-on-real-screen x, y, background-color + x <- increment + loop + } + y <- increment + loop + } +} + fn screen-grapheme-at screen-on-stack: (addr screen), x: int, y: int -> _/eax: grapheme { var screen-addr/esi: (addr screen) <- copy screen-on-stack var idx/ecx: int <- screen-cell-index screen-addr, x, y diff --git a/shell/global.mu b/shell/global.mu index c87198ee..32142633 100644 --- a/shell/global.mu +++ b/shell/global.mu @@ -22,6 +22,10 @@ fn initialize-globals _self: (addr global-table) { append-primitive self, "cons" } +fn render-globals screen: (addr screen), _self: (addr global-table), xmin: int, ymin: int, xmax: int, ymax: int { + clear-rect screen, xmin, ymin, xmax, ymax, 0x12/bg=grey +} + fn append-primitive _self: (addr global-table), name: (addr array byte) { var self/esi: (addr global-table) <- copy _self var final-index-addr/ecx: (addr int) <- get self, final-index diff --git a/shell/main.mu b/shell/main.mu index 29c815dc..04f64011 100644 --- a/shell/main.mu +++ b/shell/main.mu @@ -9,11 +9,9 @@ fn main screen: (addr screen), keyboard: (addr keyboard), data-disk: (addr disk) var sandbox/esi: (addr sandbox) <- address sandbox-storage initialize-sandbox sandbox load-sandbox data-disk, sandbox - var width/eax: int <- copy 0 - var height/ecx: int <- copy 0 - width, height <- screen-size screen { - render-sandbox screen, sandbox, 2/x, 2/y, width, height + render-globals screen, globals, 0/x, 0/y, 0x40/xmax, 0x30/screen-height + render-sandbox screen, sandbox, 0x40/x, 0/y, 0x80/screen-width, 0x30/screen-height { var key/eax: byte <- read-key keyboard compare key, 0 diff --git a/shell/sandbox.mu b/shell/sandbox.mu index 2b612a13..06bf3656 100644 --- a/shell/sandbox.mu +++ b/shell/sandbox.mu @@ -39,7 +39,7 @@ fn allocate-sandbox-with _out: (addr handle sandbox), s: (addr array byte) { ## fn render-sandbox screen: (addr screen), _self: (addr sandbox), xmin: int, ymin: int, xmax: int, ymax: int { - clear-screen screen + clear-rect screen, xmin, ymin, xmax, ymax, 0/bg=black var self/esi: (addr sandbox) <- copy _self # data var data-ah/eax: (addr handle gap-buffer) <- get self, data |