about summary refs log tree commit diff stats
path: root/103grapheme.subx
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-06-15 10:33:18 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-06-15 10:33:18 -0700
commitc2c6f4c7ab40356f1138a3f4d8f06464373ad50b (patch)
tree9369a4da0497b7eb70470d4e30ec65e9a611c793 /103grapheme.subx
parentb9fea696871aece599c4ec25ec01ee0c2c00513b (diff)
downloadmu-c2c6f4c7ab40356f1138a3f4d8f06464373ad50b.tar.gz
flickerlessly render fake screens in environment
Font rendering now happens off the real screen, which provides the effect
of double-buffering.

Apps can now also use convert-graphemes-to-pixels for more traditional
double-buffering.
Diffstat (limited to '103grapheme.subx')
-rw-r--r--103grapheme.subx44
1 files changed, 44 insertions, 0 deletions
diff --git a/103grapheme.subx b/103grapheme.subx
index a63e3098..c5615430 100644
--- a/103grapheme.subx
+++ b/103grapheme.subx
@@ -26,6 +26,50 @@ $draw-grapheme-on-real-screen:end:
     5d/pop-to-ebp
     c3/return
 
+draw-grapheme-on-screen-array:  # screen-data: (addr array byte), g: grapheme, 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
+    52/push-edx
+    # if screen-width*screen-height > len(screen-data) abort
+    {
+      # ecx = len(screen-data)
+      8b/-> *(ebp+8) 1/r32/ecx
+      8b/-> *ecx 1/r32/ecx
+      # eax = screen-width*screen-height
+      ba/copy-to-edx 0/imm32
+      8b/-> *(ebp+0x20) 0/r32/eax
+      f7 4/subop/multiply-into-eax *(ebp+0x24)
+      81 7/subop/compare %edx 0/imm32
+      0f 85/jump-if-!= $draw-grapheme-on-screen-array:overflow/disp32
+      # if (eax > ecx) abort
+      39/compare %eax 1/r32/ecx
+      0f 8f/jump-if-> $draw-grapheme-on-screen-array:abort/disp32
+    }
+    # eax = screen-data+4   (skip length)
+    8b/-> *(ebp+8) 0/r32/eax
+    05/add-to-eax 4/imm32
+    #
+    (draw-grapheme-on-screen-buffer %eax *(ebp+0xc) *(ebp+0x10) *(ebp+0x14) *(ebp+0x18) *(ebp+0x1c) *(ebp+0x20) *(ebp+0x24))
+$draw-grapheme-on-screen-array:end:
+    # . restore registers
+    5a/pop-to-edx
+    59/pop-to-ecx
+    58/pop-to-eax
+    # . epilogue
+    89/<- %esp 5/r32/ebp
+    5d/pop-to-ebp
+    c3/return
+
+$draw-grapheme-on-screen-array:overflow:
+    (abort "draw-grapheme-on-screen-array: screen dimensions too large")
+
+$draw-grapheme-on-screen-array:abort:
+    (abort "draw-grapheme-on-screen-array: coordinates are off the screen. Are the screen dimensions correct?")
+
 # 'buffer' here is not a valid Mu type: a naked address without a length.
 draw-grapheme-on-screen-buffer:  # buffer: (addr byte), g: grapheme, x: int, y: int, color: int, background-color: int, screen-width: int, screen-height: int
     # . prologue