about summary refs log tree commit diff stats
path: root/103grapheme.subx
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-08-29 00:29:57 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-08-29 00:29:57 -0700
commitbd34858c4e713c12ab1f907087a2fea97703385f (patch)
tree984e450d13977c95ac0fc1f452fe7e4c47eed31c /103grapheme.subx
parenta46cb565ca99174876cbfb637640494dedf8eec1 (diff)
downloadmu-bd34858c4e713c12ab1f907087a2fea97703385f.tar.gz
.
Diffstat (limited to '103grapheme.subx')
-rw-r--r--103grapheme.subx78
1 files changed, 50 insertions, 28 deletions
diff --git a/103grapheme.subx b/103grapheme.subx
index 417914d4..ef7cf538 100644
--- a/103grapheme.subx
+++ b/103grapheme.subx
@@ -153,36 +153,10 @@ draw-narrow-grapheme-on-screen-buffer:  # buffer: (addr byte), letter-bitmap: (a
       # if (ycurr >= ymax) break
       39/compare %edx 7/r32/edi
       0f 8d/jump-if->= break/disp32
-      # var xcurr/eax: int = x*8 + 7
-      8b/-> *(ebp+0x10) 0/r32/eax
-      c1 4/subop/shift-left %eax 3/imm8  # font-width
-      05/add-to-eax 7/imm32  # font-width - 1
-      # var xmin/ecx: int = x*8
-      8b/-> *(ebp+0x10) 1/r32/ecx
-      c1 4/subop/shift-left %ecx 3/imm8
-      # var row-bitmap/ebx: int = *letter-bitmap
+      # var row-bitmap/ebx: byte = *letter-bitmap
       bb/copy-to-ebx 0/imm32
       8a/byte-> *esi 3/r32/BL
-      {
-        # if (xcurr < xmin) break
-        39/compare %eax 1/r32/ecx
-        7c/jump-if-< break/disp8
-        # shift LSB from row-bitmap into carry flag (CF)
-        c1 5/subop/shift-right-logical %ebx 1/imm8
-        # if LSB, draw a pixel in the given color
-        {
-          73/jump-if-not-CF break/disp8
-          (pixel-on-screen-buffer *(ebp+8) %eax %edx *(ebp+0x18) *(ebp+0x20) *(ebp+0x24))
-          eb/jump $draw-grapheme-on-screen-buffer:continue/disp8
-        }
-        # otherwise use the background color
-        (pixel-on-screen-buffer *(ebp+8) %eax %edx *(ebp+0x1c) *(ebp+0x20) *(ebp+0x24))
-$draw-grapheme-on-screen-buffer:continue:
-        # --x
-        48/decrement-eax
-        #
-        eb/jump loop/disp8
-      }
+      (draw-run-of-pixels-from-glyph *(ebp+8) %ebx *(ebp+0x10) %edx *(ebp+0x18) *(ebp+0x1c) *(ebp+0x20) *(ebp+0x24))
       # ++y
       42/increment-edx
       # next bitmap row
@@ -228,6 +202,54 @@ $draw-wide-grapheme-on-screen-buffer:end:
     5d/pop-to-ebp
     c3/return
 
+# draw 8 pixels from a single glyph byte in a font bitmap
+draw-run-of-pixels-from-glyph:  # buffer: (addr byte), glyph-byte: byte, x: int, y: int, color: int, background-color: int, screen-width: int, screen-height: int
+    # . prologue
+    55/push-ebp
+    89/<- %ebp 4/r32/esp
+    # . save registers
+    50/push-eax
+    51/push-ecx
+    56/push-esi
+    # esi = glyph-byte
+    8b/-> *(ebp+0xc) 6/r32/esi
+    # var xcurr/eax: int = x*8 + 7
+    8b/-> *(ebp+0x10) 0/r32/eax
+    c1 4/subop/shift-left %eax 3/imm8
+    05/add-to-eax 7/imm32
+    # var xmin/ecx: int = x*8
+    8b/-> *(ebp+0x10) 1/r32/ecx
+    c1 4/subop/shift-left %ecx 3/imm8
+    {
+      # if (xcurr < xmin) break
+      39/compare %eax 1/r32/ecx
+      7c/jump-if-< break/disp8
+      # shift LSB from row-bitmap into carry flag (CF)
+      c1 5/subop/shift-right-logical %esi 1/imm8
+      # if LSB, draw a pixel in the given color
+      {
+        73/jump-if-not-CF break/disp8
+        (pixel-on-screen-buffer *(ebp+8) %eax *(ebp+0x14) *(ebp+0x18) *(ebp+0x20) *(ebp+0x24))
+        eb/jump $draw-grapheme-on-screen-buffer:continue/disp8
+      }
+      # otherwise use the background color
+      (pixel-on-screen-buffer *(ebp+8) %eax *(ebp+0x14) *(ebp+0x1c) *(ebp+0x20) *(ebp+0x24))
+$draw-grapheme-on-screen-buffer:continue:
+      # --x
+      48/decrement-eax
+      #
+      eb/jump loop/disp8
+    }
+$draw-run-of-pixels-from-glyph:end:
+    # . restore registers
+    5e/pop-to-esi
+    59/pop-to-ecx
+    58/pop-to-eax
+    # . epilogue
+    89/<- %esp 5/r32/ebp
+    5d/pop-to-ebp
+    c3/return
+
 cursor-position-on-real-screen:  # -> _/eax: int, _/ecx: int
     # . prologue
     55/push-ebp