about summary refs log tree commit diff stats
path: root/baremetal/103grapheme.subx
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2021-01-13 00:02:35 -0800
committerKartik Agaram <vc@akkartik.com>2021-01-13 00:02:35 -0800
commit422ebaf88c5a04900beb0a68162213ebc94e37c2 (patch)
treef6cffe2276da0a73c9d00716546c7b776586dee5 /baremetal/103grapheme.subx
parent4413168269ad3d3f31fdc60669bb812f54a3d01e (diff)
downloadmu-422ebaf88c5a04900beb0a68162213ebc94e37c2.tar.gz
7508
This is the right way to be direction-independent. Don't save the cursor
when drawing a single grapheme. Where the next char goes is just a
property of the direction-oriented primitives.
Diffstat (limited to 'baremetal/103grapheme.subx')
-rw-r--r--baremetal/103grapheme.subx25
1 files changed, 19 insertions, 6 deletions
diff --git a/baremetal/103grapheme.subx b/baremetal/103grapheme.subx
index 053cd497..a536bfed 100644
--- a/baremetal/103grapheme.subx
+++ b/baremetal/103grapheme.subx
@@ -58,12 +58,6 @@ 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
@@ -89,6 +83,25 @@ $cursor-position:end:
     5d/pop-to-ebp
     c3/return
 
+set-cursor-position:  # screen: (addr screen), x: int, y: int
+    # . prologue
+    55/push-ebp
+    89/<- %ebp 4/r32/esp
+    # . save registers
+    50/push-eax
+    # TODO: support fake screen; we currently assume 'screen' is always 0 (real)
+    8b/-> *(ebp+0xc) 0/r32/eax
+    89/<- *Default-next-x 0/r32/eax
+    8b/-> *(ebp+0x10) 0/r32/eax
+    89/<- *Default-next-y 0/r32/eax
+$set-cursor-position:end:
+    # . restore registers
+    58/pop-to-eax
+    # . epilogue
+    89/<- %esp 5/r32/ebp
+    5d/pop-to-ebp
+    c3/return
+
 == data
 
 Default-next-x: