about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2021-01-22 19:57:33 -0800
committerKartik Agaram <vc@akkartik.com>2021-01-22 19:57:33 -0800
commit121a9eba56d62ef6bd9900bcd771647c0c58e718 (patch)
tree29b19ce63ea7f3e9c733ed847141189e452daf11
parentc316a11ffa6fa184c9c62dc6fccbc0a6aa6c8f63 (diff)
downloadmu-121a9eba56d62ef6bd9900bcd771647c0c58e718.tar.gz
7540 - baremetal: cursor
I spent over a week agonizing over this.

* I had to come to terms with the fact that I don't really know how to
make pixel graphics testable. ASCII art on a pixel by pixel basis feels
inhuman. Just focus on text mode for now.

* I had to set aside the problem of non-English family languages.
Languages like Arabic that can stack complex graphemes together likely
can't be fixed-width. But I don't know enough at the moment to solve for
them.

* I spent a while trying to juggle two cursors, one invisible output
cursor for tracking the most recent print, and one visible one that's
just a hint to the user of what the next keystroke will do. But it looks
like I can fold both into a single cursor. Drawing things updates the
location of the cursor but doesn't display it. Explicitly moving the
cursor displays it, but future drawing can overwrite the cursor.
-rw-r--r--baremetal/103grapheme.subx24
-rw-r--r--baremetal/mu-init.subx4
2 files changed, 19 insertions, 9 deletions
diff --git a/baremetal/103grapheme.subx b/baremetal/103grapheme.subx
index 5b160bfe..97a44315 100644
--- a/baremetal/103grapheme.subx
+++ b/baremetal/103grapheme.subx
@@ -96,8 +96,8 @@ cursor-position-on-real-screen:  # -> _/eax: int, _/ecx: int
     55/push-ebp
     89/<- %ebp 4/r32/esp
     # TODO: support fake screen; we currently assume 'screen' is always 0 (real)
-    8b/-> *Default-next-x 0/r32/eax
-    8b/-> *Default-next-y 1/r32/ecx
+    8b/-> *Real-screen-cursor-x 0/r32/eax
+    8b/-> *Real-screen-cursor-y 1/r32/ecx
 $cursor-position-on-real-screen:end:
     # . epilogue
     89/<- %esp 5/r32/ebp
@@ -110,11 +110,13 @@ set-cursor-position-on-real-screen:  # x: int, y: int
     89/<- %ebp 4/r32/esp
     # . save registers
     50/push-eax
+    #
+    (draw-grapheme-on-real-screen 0x20 *(ebp+8) *(ebp+0xc) 0 7)
     # TODO: support fake screen; we currently assume 'screen' is always 0 (real)
     8b/-> *(ebp+8) 0/r32/eax
-    89/<- *Default-next-x 0/r32/eax
+    89/<- *Real-screen-cursor-x 0/r32/eax
     8b/-> *(ebp+0xc) 0/r32/eax
-    89/<- *Default-next-y 0/r32/eax
+    89/<- *Real-screen-cursor-y 0/r32/eax
 $set-cursor-position-on-real-screen:end:
     # . restore registers
     58/pop-to-eax
@@ -125,8 +127,16 @@ $set-cursor-position-on-real-screen:end:
 
 == data
 
-Default-next-x:
+# The cursor is where certain Mu functions (usually of the form
+# 'draw*cursor*') print to by default. It becomes visible on
+# set-cursor-position, but further drawing might overwrite it.
+# We don't bother displaying the cursor when drawing text. It's up to
+# applications to display the cursor before waiting for a key, and to ensure
+# its location appropriately suggests the effect keystrokes will have.
+#
+# There's no low-level support for blinking, etc. We aren't using any
+# hardware-supported text mode here.
+Real-screen-cursor-x:
   0/imm32
-
-Default-next-y:
+Real-screen-cursor-y:
   0/imm32
diff --git a/baremetal/mu-init.subx b/baremetal/mu-init.subx
index 0ed4f085..26b83451 100644
--- a/baremetal/mu-init.subx
+++ b/baremetal/mu-init.subx
@@ -16,8 +16,8 @@ bd/copy-to-ebp 0/imm32
   3d/compare-eax-and 0/imm32
   75/jump-if-!= break/disp8
   (clear-real-screen)
-  c7 0/subop/copy *Default-next-x 0/imm32
-  c7 0/subop/copy *Default-next-y 0/imm32
+  c7 0/subop/copy *Real-screen-cursor-x 0/imm32
+  c7 0/subop/copy *Real-screen-cursor-y 0/imm32
   (main)
 }