diff --git a/baremetal/500text-screen.mu b/baremetal/500text-screen.mu index 050cf4db..e10b6a8f 100644 --- a/baremetal/500text-screen.mu +++ b/baremetal/500text-screen.mu @@ -90,6 +90,12 @@ fn draw-grapheme screen: (addr screen), g: grapheme, x: int, y: int, color: int, copy-to *dest-color, src-color } +# we can't really render non-ASCII yet, but when we do we'll be ready +fn draw-code-point screen: (addr screen), c: code-point, x: int, y: int, color: int, background-color: int { + var g/eax: grapheme <- copy c + draw-grapheme screen, g, x, y, color, background-color +} + # not really needed for a real screen, though it shouldn't do any harm fn screen-cell-index screen-on-stack: (addr screen), x: int, y: int -> _/ecx: int { var screen/esi: (addr screen) <- copy screen-on-stack @@ -193,7 +199,6 @@ fn clear-screen screen: (addr screen) { return } # fake screen - var space/edi: grapheme <- copy 0x20 set-cursor-position screen, 0, 0 var screen-addr/esi: (addr screen) <- copy screen var y/eax: int <- copy 1 @@ -206,7 +211,7 @@ fn clear-screen screen: (addr screen) { { compare x, *width break-if-> - draw-grapheme screen, space, x, y, 0/fg=black, 0/bg=black + draw-code-point screen, 0x20/space, x, y, 0/fg=black, 0/bg=black x <- increment loop } diff --git a/baremetal/501draw-text.mu b/baremetal/501draw-text.mu index ba1d4805..af3b3a49 100644 --- a/baremetal/501draw-text.mu +++ b/baremetal/501draw-text.mu @@ -69,6 +69,12 @@ fn draw-grapheme-at-cursor screen: (addr screen), g: grapheme, color: int, backg draw-grapheme screen, g, cursor-x, cursor-y, color, background-color } +# we can't really render non-ASCII yet, but when we do we'll be ready +fn draw-code-point-at-cursor screen: (addr screen), c: code-point, color: int, background-color: int { + var g/eax: grapheme <- copy c + draw-grapheme-at-cursor screen, g, color, background-color +} + # draw a single line of text from x, y to xmax # return the next 'x' coordinate # if there isn't enough space, return 0 without modifying the screen diff --git a/baremetal/504test-screen.mu b/baremetal/504test-screen.mu index 0b8514c1..b70b11c7 100644 --- a/baremetal/504test-screen.mu +++ b/baremetal/504test-screen.mu @@ -301,8 +301,7 @@ fn test-draw-single-grapheme { var screen-on-stack: screen var screen/esi: (addr screen) <- address screen-on-stack initialize-screen screen, 5, 4 - var c/eax: grapheme <- copy 0x61/a - draw-grapheme screen, c, 0/x, 0/y, 1/fg, 2/bg + draw-code-point screen, 0x61/a, 0/x, 0/y, 1/fg, 2/bg check-screen-row screen, 0/y, "a", "F - test-draw-single-grapheme" # top-left corner of the screen check-screen-row-in-color screen, 1/fg, 0/y, "a", "F - test-draw-single-grapheme-fg" check-screen-row-in-background-color screen, 2/bg, 0/y, "a", "F - test-draw-single-grapheme-bg" diff --git a/baremetal/ex4.mu b/baremetal/ex4.mu index ede48e09..5b883131 100644 --- a/baremetal/ex4.mu +++ b/baremetal/ex4.mu @@ -10,6 +10,5 @@ # Expected output: letter 'A' in green near the top-left corner of screen fn main { - var g/eax: grapheme <- copy 0x41/A - draw-grapheme 0/screen, g, 2/row, 1/col, 0xa/fg, 0/bg + draw-codepoint 0/screen, 0x41/A, 2/row, 1/col, 0xa/fg, 0/bg } diff --git a/baremetal/ex7.mu b/baremetal/ex7.mu index aa2083c7..30e3c1bc 100644 --- a/baremetal/ex7.mu +++ b/baremetal/ex7.mu @@ -19,29 +19,26 @@ fn main { { compare key, 0x68/h break-if-!= - var g/eax: grapheme <- copy 0x2d/dash - draw-grapheme-at-cursor 0/screen, g, 0x31/fg, 0/bg + draw-code-point-at-cursor 0/screen, 0x2d/dash, 0x31/fg, 0/bg move-cursor-left 0 } { compare key, 0x6a/j break-if-!= - var g/eax: grapheme <- copy 0x7c/vertical-bar - draw-grapheme-at-cursor 0/screen, g, 0x31/fg, 0/bg + draw-code-point-at-cursor 0/screen, 0x7c/vertical-bar, 0x31/fg, 0/bg move-cursor-down 0 } { compare key, 0x6b/k break-if-!= - var g/eax: grapheme <- copy 0x7c/vertical-bar - draw-grapheme-at-cursor 0/screen, g, 0x31/fg, 0/bg + draw-code-point-at-cursor 0/screen, 0x7c/vertical-bar, 0x31/fg, 0/bg move-cursor-up 0 } { compare key, 0x6c/l break-if-!= - var g/eax: grapheme <- copy 0x2d/dash - draw-grapheme-at-cursor 0/screen, g, 0x31/fg, 0/bg + var g/eax: code-point <- copy 0x2d/dash + draw-code-point-at-cursor 0/screen, 0x2d/dash, 0x31/fg, 0/bg move-cursor-right 0 } loop