about summary refs log tree commit diff stats
path: root/baremetal/500text-screen.mu
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2021-01-23 08:45:51 -0800
committerKartik Agaram <vc@akkartik.com>2021-01-23 08:45:51 -0800
commit63be7b7d0d5bb6e728d9afbb68e238fcd3bda3a7 (patch)
tree7f26c1430c53e0aec3cbe889bf80e70078db8506 /baremetal/500text-screen.mu
parent0f73127ef1eba0a8ea814c26115523da3590ffe2 (diff)
downloadmu-63be7b7d0d5bb6e728d9afbb68e238fcd3bda3a7.tar.gz
7548 - baremetal: better cursor management
Diffstat (limited to 'baremetal/500text-screen.mu')
-rw-r--r--baremetal/500text-screen.mu23
1 files changed, 16 insertions, 7 deletions
diff --git a/baremetal/500text-screen.mu b/baremetal/500text-screen.mu
index fbc2ef43..f5cd4125 100644
--- a/baremetal/500text-screen.mu
+++ b/baremetal/500text-screen.mu
@@ -112,11 +112,11 @@ fn cursor-position screen: (addr screen) -> _/eax: int, _/ecx: int {
   return *cursor-x-addr, *cursor-y-addr
 }
 
-fn set-cursor-position screen: (addr screen), x: int, y: int, g: grapheme {
+fn set-cursor-position screen: (addr screen), x: int, y: int {
   {
     compare screen, 0
     break-if-!=
-    set-cursor-position-on-real-screen x, y, g
+    set-cursor-position-on-real-screen x, y
     return
   }
   # fake screen
@@ -157,11 +157,20 @@ fn set-cursor-position screen: (addr screen), x: int, y: int, g: grapheme {
   dest <- get screen-addr, cursor-y
   src <- copy y
   copy-to *dest, src
-  #
+}
+
+fn show-cursor screen: (addr screen), g: grapheme {
+  {
+    compare screen, 0
+    break-if-!=
+    show-cursor-on-real-screen g
+    return
+  }
+  # fake screen
   var cursor-x/eax: int <- copy 0
   var cursor-y/ecx: int <- copy 0
-  cursor-x, cursor-y <- cursor-position screen-addr
-  draw-grapheme screen-addr, g, cursor-x, cursor-y, 0  # cursor color not tracked for fake screen
+  cursor-x, cursor-y <- cursor-position screen
+  draw-grapheme screen, g, cursor-x, cursor-y, 0  # cursor color not tracked for fake screen
 }
 
 fn clear-screen screen: (addr screen) {
@@ -173,7 +182,7 @@ fn clear-screen screen: (addr screen) {
   }
   # fake screen
   var space/edi: grapheme <- copy 0x20
-  set-cursor-position screen, 0, 0, space
+  set-cursor-position screen, 0, 0
   var screen-addr/esi: (addr screen) <- copy screen
   var y/eax: int <- copy 1
   var height/ecx: (addr int) <- get screen-addr, height
@@ -192,7 +201,7 @@ fn clear-screen screen: (addr screen) {
     y <- increment
     loop
   }
-  set-cursor-position screen, 0, 0, space
+  set-cursor-position screen, 0, 0
 }
 
 # there's no grapheme that guarantees to cover every pixel, so we'll bump down