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-15 20:30:07 -0800
committerKartik Agaram <vc@akkartik.com>2021-01-15 20:30:07 -0800
commit6e36ce06dd035408d43a6599b75b933a0709cc78 (patch)
treeb5b90ee59b5387036d311096fed1c96aa588cacb /baremetal/103grapheme.subx
parent20d6be52405130930fde9ca5bb5e95131ba4e659 (diff)
downloadmu-6e36ce06dd035408d43a6599b75b933a0709cc78.tar.gz
7521 - new plan for tests
It's not really manageable to make the fake screen pixel-oriented. Feels
excessive to compare things pixel by pixel when we will mostly be
writing text to screen. It'll also make expected screen assertions
more difficult to manage.

So I'm not sure how to make assertions about pixels for now. Instead
we'll introduce fake screens at draw-grapheme.
Diffstat (limited to 'baremetal/103grapheme.subx')
-rw-r--r--baremetal/103grapheme.subx28
1 files changed, 15 insertions, 13 deletions
diff --git a/baremetal/103grapheme.subx b/baremetal/103grapheme.subx
index 9b19884f..4ee423d7 100644
--- a/baremetal/103grapheme.subx
+++ b/baremetal/103grapheme.subx
@@ -1,8 +1,11 @@
-# Use the built-in font to draw a grapheme to screen.
+# Use the built-in font to draw a grapheme to real screen.
+#
+# We need to do this in machine code because Mu doesn't have global variables
+# yet (for the start of video memory).
 
 == code
 
-draw-grapheme:  # screen: (addr screen), g: grapheme, x: int, y: int, color: int
+draw-grapheme-on-real-screen:  # g: grapheme, x: int, y: int, color: int
     # . prologue
     55/push-ebp
     89/<- %ebp 4/r32/esp
@@ -12,28 +15,27 @@ 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
+    8b/-> *(ebp+8) 6/r32/esi
     c1 4/subop/shift-left %esi 4/imm8
     8d/copy-address *(esi+0x8800) 6/r32/esi  # font-start
     # if (letter-bitmap >= 0x9000) return  # characters beyond ASCII currently not supported
     81 7/subop/compare %esi 0x9000/imm32
     7d/jump-if->= $draw-grapheme:end/disp8
     # edx = y
-    8b/-> *(ebp+0x14) 2/r32/edx
+    8b/-> *(ebp+0x10) 2/r32/edx
     # var ymax/ebx: int = y + 16
-    8b/-> *(ebp+0x14) 3/r32/ebx
+    8b/-> *(ebp+0x10) 3/r32/ebx
     81 0/subop/add %ebx 0x10/imm32
     {
       # if (y >= ymax) break
       39/compare %edx 3/r32/ebx
       7d/jump-if->= break/disp8
       # eax = x + 7
-      8b/-> *(ebp+0x10) 0/r32/eax
+      8b/-> *(ebp+0xc) 0/r32/eax
       81 0/subop/add %eax 7/imm32
       # var xmin/ecx: int = x
-      8b/-> *(ebp+0x10) 1/r32/ecx
+      8b/-> *(ebp+0xc) 1/r32/ecx
       # var row-bitmap/ebx: int = *letter-bitmap
       53/push-ebx
       8b/-> *esi 3/r32/ebx
@@ -46,7 +48,7 @@ draw-grapheme:  # screen: (addr screen), g: grapheme, x: int, y: int, color: int
         # if LSB, draw a pixel
         {
           73/jump-if-not-CF break/disp8
-          (pixel *(ebp+8) %eax %edx *(ebp+0x18))
+          (pixel-on-real-screen %eax %edx *(ebp+0x14))
         }
         # --x
         48/decrement-eax
@@ -74,7 +76,7 @@ $draw-grapheme:end:
     5d/pop-to-ebp
     c3/return
 
-cursor-position:  # screen: (addr screen) -> _/eax: int, _/ecx: int
+cursor-position-on-real-screen:  # -> _/eax: int, _/ecx: int
     # . prologue
     55/push-ebp
     89/<- %ebp 4/r32/esp
@@ -87,16 +89,16 @@ $cursor-position:end:
     5d/pop-to-ebp
     c3/return
 
-set-cursor-position:  # screen: (addr screen), x: int, y: int
+set-cursor-position-on-real-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
+    8b/-> *(ebp+8) 0/r32/eax
     89/<- *Default-next-x 0/r32/eax
-    8b/-> *(ebp+0x10) 0/r32/eax
+    8b/-> *(ebp+0xc) 0/r32/eax
     89/<- *Default-next-y 0/r32/eax
 $set-cursor-position:end:
     # . restore registers