about summary refs log tree commit diff stats
path: root/baremetal/103grapheme.subx
diff options
context:
space:
mode:
Diffstat (limited to 'baremetal/103grapheme.subx')
-rw-r--r--baremetal/103grapheme.subx28
1 files changed, 28 insertions, 0 deletions
diff --git a/baremetal/103grapheme.subx b/baremetal/103grapheme.subx
index 934aac51..053cd497 100644
--- a/baremetal/103grapheme.subx
+++ b/baremetal/103grapheme.subx
@@ -8,6 +8,7 @@ draw-grapheme:  # screen: (addr screen), g: grapheme, x: int, y: int, color: int
     52/push-edx
     53/push-ebx
     56/push-esi
+    # TODO: support fake screen; we currently assume 'screen' is always 0 (real)
     # var letter-bitmap/esi = font[g]
     8b/-> *(ebp+0xc) 6/r32/esi
     c1 4/subop/shift-left %esi 4/imm8
@@ -57,6 +58,12 @@ draw-grapheme:  # screen: (addr screen), g: grapheme, x: int, y: int, color: int
       #
       eb/jump loop/disp8
     }
+    # Save default coordinates for a future call to draw-grapheme
+    8b/-> *(ebp+0x10) 0/r32/eax
+    81 0/subop/add %eax 8/imm32
+    89/<- *Default-next-x 0/r32/eax
+    8b/-> *(ebp+0x14) 0/r32/eax
+    89/<- *Default-next-y 0/r32/eax
 $draw-grapheme:end:
     # . restore registers
     5e/pop-to-esi
@@ -68,3 +75,24 @@ $draw-grapheme:end:
     89/<- %esp 5/r32/ebp
     5d/pop-to-ebp
     c3/return
+
+cursor-position:  # screen: (addr screen) -> _/eax: int, _/ecx: int
+    # . prologue
+    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
+$cursor-position:end:
+    # . epilogue
+    89/<- %esp 5/r32/ebp
+    5d/pop-to-ebp
+    c3/return
+
+== data
+
+Default-next-x:
+  0/imm32
+
+Default-next-y:
+  0/imm32