about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--101screen.subx43
-rw-r--r--103grapheme.subx41
2 files changed, 56 insertions, 28 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
diff --git a/103grapheme.subx b/103grapheme.subx
index 8f1f9e61..ac0cef95 100644
--- a/103grapheme.subx
+++ b/103grapheme.subx
@@ -18,6 +18,21 @@ draw-grapheme-on-real-screen:  # g: grapheme, x: int, y: int, color: int, backgr
     # . prologue
     55/push-ebp
     89/<- %ebp 4/r32/esp
+    #
+    (draw-grapheme-on-screen-buffer *Video-memory-addr *(ebp+8) *(ebp+0xc) *(ebp+0x10) *(ebp+0x14) *(ebp+0x18) 0x400 0x300)
+$draw-grapheme-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.
+# 'x' and 'y' are in graphemes
+# 'screen-width' and 'screen-height' are in pixels
+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
+    55/push-ebp
+    89/<- %ebp 4/r32/esp
     # . save registers
     50/push-eax
     51/push-ecx
@@ -25,30 +40,30 @@ draw-grapheme-on-real-screen:  # g: grapheme, x: int, y: int, color: int, backgr
     53/push-ebx
     56/push-esi
     # esi = g
-    8b/-> *(ebp+8) 6/r32/esi
+    8b/-> *(ebp+0xc) 6/r32/esi
     # if (g >= 128) return  # characters beyond ASCII currently not supported
     81 7/subop/compare %esi 0x80/imm32
-    7d/jump-if->= $draw-grapheme-on-real-screen:end/disp8
+    0f 8d/jump-if->= $draw-grapheme-on-screen-buffer:end/disp32
     # var letter-bitmap/esi = font[g]
     c1 4/subop/shift-left %esi 4/imm8
     81 0/subop/add %esi Font/imm32
     # var ycurr/edx: int = y*16
-    8b/-> *(ebp+0x10) 2/r32/edx
+    8b/-> *(ebp+0x14) 2/r32/edx
     c1 4/subop/shift-left %edx 4/imm8
     # var ymax/ebx: int = ycurr + 16
-    8b/-> *(ebp+0x10) 3/r32/ebx
+    8b/-> *(ebp+0x14) 3/r32/ebx
     c1 4/subop/shift-left %ebx 4/imm8
     81 0/subop/add %ebx 0x10/imm32
     {
       # if (ycurr >= ymax) break
       39/compare %edx 3/r32/ebx
-      7d/jump-if->= break/disp8
+      0f 8d/jump-if->= break/disp32
       # var xcurr/eax: int = x*8 + 7
-      8b/-> *(ebp+0xc) 0/r32/eax  # font-width - 1
+      8b/-> *(ebp+0x10) 0/r32/eax  # font-width - 1
       c1 4/subop/shift-left %eax 3/imm8
       05/add-to-eax 7/imm32
       # var xmin/ecx: int = x*8
-      8b/-> *(ebp+0xc) 1/r32/ecx
+      8b/-> *(ebp+0x10) 1/r32/ecx
       c1 4/subop/shift-left %ecx 3/imm8
       # var row-bitmap/ebx: int = *letter-bitmap
       53/push-ebx
@@ -62,12 +77,12 @@ draw-grapheme-on-real-screen:  # g: grapheme, x: int, y: int, color: int, backgr
         # if LSB, draw a pixel in the given color
         {
           73/jump-if-not-CF break/disp8
-          (pixel-on-real-screen %eax %edx *(ebp+0x14))
-          eb/jump $draw-grapheme-on-real-screen:continue/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-real-screen %eax %edx *(ebp+0x18))
-$draw-grapheme-on-real-screen:continue:
+        (pixel-on-screen-buffer *(ebp+8) %eax %edx *(ebp+0x1c) *(ebp+0x20) *(ebp+0x24))
+$draw-grapheme-on-screen-buffer:continue:
         # --x
         48/decrement-eax
         #
@@ -80,9 +95,9 @@ $draw-grapheme-on-real-screen:continue:
       # next bitmap row
       46/increment-esi
       #
-      eb/jump loop/disp8
+      e9/jump loop/disp32
     }
-$draw-grapheme-on-real-screen:end:
+$draw-grapheme-on-screen-buffer:end:
     # . restore registers
     5e/pop-to-esi
     5b/pop-to-ebx
s Booth <boothj5@gmail.com> 2012-08-26 00:54:18 +0100 committer James Booth <boothj5@gmail.com> 2012-08-26 00:54:18 +0100 Refactored log' href='/danisanti/profani-tty/commit/src/log.c?id=2bbac1c811ba017512349ff8170aa877b853b2a4'>2bbac1c8 ^
0f3c1e56 ^



2bbac1c8 ^

e6987387 ^
2bbac1c8 ^
6bad38c2 ^
2bbac1c8 ^


0f3c1e56 ^



2bbac1c8 ^

e6987387 ^
2bbac1c8 ^
6bad38c2 ^
2bbac1c8 ^


0f3c1e56 ^



2bbac1c8 ^

e6987387 ^
2bbac1c8 ^
6bad38c2 ^
2bbac1c8 ^


0f3c1e56 ^



2bbac1c8 ^
5eaf687d ^

279737ba ^
2bbac1c8 ^
bbb0fbed ^
2bbac1c8 ^
e4ac23e9 ^
4b73f3d7 ^


74a88ad5 ^


2bbac1c8 ^
74a88ad5 ^
2bbac1c8 ^
4d190a9c ^

279737ba ^

4d190a9c ^
e4ac23e9 ^
4d190a9c ^
bbb0fbed ^
2bbac1c8 ^

0f3c1e56 ^
2bbac1c8 ^

291c6bc3 ^

4b73f3d7 ^
2bbac1c8 ^

6bad38c2 ^
0f3c1e56 ^
2bbac1c8 ^
6bad38c2 ^
2bbac1c8 ^
6d329343 ^
291c6bc3 ^
4b73f3d7 ^
291c6bc3 ^



4b73f3d7 ^
2bbac1c8 ^


291c6bc3 ^


4b73f3d7 ^

291c6bc3 ^

4b73f3d7 ^
291c6bc3 ^




4b73f3d7 ^
291c6bc3 ^


4b73f3d7 ^
291c6bc3 ^

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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166