From 0d12f6676bab81d1d68239dcd26089612450232d Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Tue, 12 Jan 2021 00:28:25 -0800 Subject: 7502 - baremetal text: better interface --- baremetal/501draw-text.mu | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'baremetal/501draw-text.mu') diff --git a/baremetal/501draw-text.mu b/baremetal/501draw-text.mu index af165e78..0f091952 100644 --- a/baremetal/501draw-text.mu +++ b/baremetal/501draw-text.mu @@ -35,10 +35,11 @@ fn draw-text-rightward screen: (addr screen), text: (addr array byte), x: int, x return xcurr } -# draw text from (x, y) to (xmax, ymax), wrapping as necessary +# draw text in the rectangle from (xmin, ymin) to (xmax, ymax), starting from (x, y), wrapping as necessary # return the next (x, y) coordinate in raster order where drawing stopped +# that way the caller can draw more if given the same min and max bounding-box. # if there isn't enough space, return 0 without modifying the screen -fn draw-text-rightward-wrapped screen: (addr screen), text: (addr array byte), x: int, y: int, xmax: int, ymax: int, color: int -> _/eax: int, _/ecx: int { +fn draw-text-wrapping-right-then-down screen: (addr screen), text: (addr array byte), xmin: int, ymin: int, xmax: int, ymax: int, x: int, y: int, color: int -> _/eax: int, _/ecx: int { var stream-storage: (stream byte 0x100) var stream/esi: (addr stream byte) <- address stream-storage write stream, text @@ -55,7 +56,7 @@ fn draw-text-rightward-wrapped screen: (addr screen), text: (addr array byte), x compare xcurr, xmax { break-if-< - xcurr <- copy x + xcurr <- copy xmin ycurr <- add 0x10 # font-height } loop @@ -78,7 +79,7 @@ fn draw-text-rightward-wrapped screen: (addr screen), text: (addr array byte), x compare xcurr, xmax { break-if-< - xcurr <- copy x + xcurr <- copy xmin ycurr <- add 0x10 # font-height } loop -- cgit 1.4.1-2-gfad0