diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2021-04-08 22:19:24 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2021-04-08 22:19:24 -0700 |
commit | d6d28b8c94b2611407a711899c05eeba86e0be80 (patch) | |
tree | ca7d564b1cca7a01f1ae9f097711c181b2f3a555 /500text-screen.mu | |
parent | 119aea6d06667c63a9b2225e7f5475cd442096b5 (diff) | |
download | mu-d6d28b8c94b2611407a711899c05eeba86e0be80.tar.gz |
shell: create space to display globals
Diffstat (limited to '500text-screen.mu')
-rw-r--r-- | 500text-screen.mu | 54 |
1 files changed, 54 insertions, 0 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 |