about summary refs log tree commit diff stats
path: root/101screen.subx
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-06-12 22:22:54 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-06-12 22:22:54 -0700
commit0511b9fd1170da575170bcde2fa617969cbf6a53 (patch)
tree7296726032ea4bfdcac6bac7e0e139061ee36016 /101screen.subx
parentbda6982ba14e1e5c562d86260ad906d9fb29261b (diff)
downloadmu-0511b9fd1170da575170bcde2fa617969cbf6a53.tar.gz
helper to render fonts outside video RAM, take 2
Diffstat (limited to '101screen.subx')
-rw-r--r--101screen.subx43
1 files changed, 28 insertions, 15 deletions
diff --git a/101screen.subx b/101screen.subx
index 2aab293d..b957d5d2 100644
--- a/101screen.subx
+++ b/101screen.subx
@@ -9,30 +9,43 @@ pixel-on-real-screen:  # x: int, y: int, color: int
     # . prologue
     55/push-ebp
     89/<- %ebp 4/r32/esp
+    #
+    (pixel-on-screen-buffer *Video-memory-addr *(ebp+8) *(ebp+0xc) *(ebp+0x10) 0x400 0x300)
+$pixel-on-real-screen:end:
+    # . epilogue
+    89/<- %esp 5/r32/ebp
+    5d/pop-to-ebp
+    c3/return
+
+# 'buffer' here is not a valid Mu type: a naked address without a length.
+pixel-on-screen-buffer:  # buffer: (addr byte), x: int, y: int, color: int, width: int, height: int
+    # . prologue
+    55/push-ebp
+    89/<- %ebp 4/r32/esp
     # . save registers
     50/push-eax
     51/push-ecx
     # bounds checks
-    8b/-> *(ebp+8) 0/r32/eax
+    8b/-> *(ebp+0xc) 0/r32/eax  # foo
     3d/compare-eax-and 0/imm32
-    7c/jump-if-< $pixel-on-real-screen:end/disp8
-    3d/compare-eax-and 0x400/imm32/screen-width=1024
-    7d/jump-if->= $pixel-on-real-screen:end/disp8
-    8b/-> *(ebp+0xc) 0/r32/eax
+    7c/jump-if-< $pixel-on-screen-buffer:end/disp8
+    3b/compare 0/r32/eax *(ebp+0x18)
+    7d/jump-if->= $pixel-on-screen-buffer:end/disp8
+    8b/-> *(ebp+0x10) 0/r32/eax
     3d/compare-eax-and 0/imm32
-    7c/jump-if-< $pixel-on-real-screen:end/disp8
-    3d/compare-eax-and 0x300/imm32/screen-height=768
-    7d/jump-if->= $pixel-on-real-screen:end/disp8
-    # eax = y*1024 + x
-    8b/-> *(ebp+0xc) 0/r32/eax
-    c1/shift 4/subop/left %eax 0xa/imm8
-    03/add-> *(ebp+8) 0/r32/eax
+    7c/jump-if-< $pixel-on-screen-buffer:end/disp8
+    3b/compare 0/r32/eax *(ebp+0x1c)
+    7d/jump-if->= $pixel-on-screen-buffer:end/disp8
+    # eax = y*width + x
+    8b/-> *(ebp+0x10) 0/r32/eax
+    0f af/multiply-> *(ebp+0x18) 0/r32/eax
+    03/add-> *(ebp+0xc) 0/r32/eax
     # eax += location of frame buffer
-    03/add-> *Video-memory-addr 0/r32/eax
+    03/add-> *(ebp+8) 0/r32/eax
     # *eax = color
-    8b/-> *(ebp+0x10) 1/r32/ecx
+    8b/-> *(ebp+0x14) 1/r32/ecx
     88/byte<- *eax 1/r32/CL
-$pixel-on-real-screen:end:
+$pixel-on-screen-buffer:end:
     # . restore registers
     59/pop-to-ecx
     58/pop-to-eax
k/mu/commit/cpp/termbox/utf8.c?h=main&id=5f1285238b09a5f01836138f5bb94654f78588a7'>5f128523 ^
9a31c34f ^




5f128523 ^
9a31c34f ^
5f128523 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79