diff options
Diffstat (limited to 'baremetal/103grapheme.subx')
-rw-r--r-- | baremetal/103grapheme.subx | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/baremetal/103grapheme.subx b/baremetal/103grapheme.subx index f854e03d..5b160bfe 100644 --- a/baremetal/103grapheme.subx +++ b/baremetal/103grapheme.subx @@ -2,9 +2,16 @@ # # We need to do this in machine code because Mu doesn't have global variables # yet (for the start of video memory). +# +# There are uncomfortable assumptions baked in here about english/latin +# script. We convert the grid of pixels into a fixed-width grid of graphemes, +# which may not work well with other language families. == code +# The Mu computer's screen is 1024px wide and 768px tall. +# The Mu computer's font is 8px wide and 16px tall. +# Therefore 'x' here is in [0, 128), and 'y' is in [0, 48) draw-grapheme-on-real-screen: # g: grapheme, x: int, y: int, color: int, background-color: int # . prologue 55/push-ebp @@ -22,25 +29,29 @@ draw-grapheme-on-real-screen: # g: grapheme, x: int, y: int, color: int, backgr # if (letter-bitmap >= 0x9000) return # characters beyond ASCII currently not supported 81 7/subop/compare %esi 0x9000/imm32 7d/jump-if->= $draw-grapheme-on-real-screen:end/disp8 - # edx = y + # var ycurr/edx: int = y*16 8b/-> *(ebp+0x10) 2/r32/edx - # var ymax/ebx: int = y + 16 + c1 4/subop/shift-left %edx 4/imm8 + # var ymax/ebx: int = ycurr + 16 8b/-> *(ebp+0x10) 3/r32/ebx + c1 4/subop/shift-left %ebx 4/imm8 81 0/subop/add %ebx 0x10/imm32 { - # if (y >= ymax) break + # if (ycurr >= ymax) break 39/compare %edx 3/r32/ebx 7d/jump-if->= break/disp8 - # eax = x + 7 + # var xcurr/eax: int = x*8 + 7 8b/-> *(ebp+0xc) 0/r32/eax # font-width - 1 + c1 4/subop/shift-left %eax 3/imm8 81 0/subop/add %eax 7/imm32 - # var xmin/ecx: int = x + # var xmin/ecx: int = x*8 8b/-> *(ebp+0xc) 1/r32/ecx + c1 4/subop/shift-left %ecx 3/imm8 # var row-bitmap/ebx: int = *letter-bitmap 53/push-ebx 8b/-> *esi 3/r32/ebx { - # if (x < xmin) break + # if (xcurr < xmin) break 39/compare %eax 1/r32/ecx 7c/jump-if-< break/disp8 # shift LSB from row-bitmap into carry flag (CF) |