about summary refs log tree commit diff stats
path: root/baremetal/501draw-text.mu
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2021-01-12 00:28:25 -0800
committerKartik Agaram <vc@akkartik.com>2021-01-12 00:32:06 -0800
commit0d12f6676bab81d1d68239dcd26089612450232d (patch)
treebe66d577d24437aafffa7553ffe50d825f6183c7 /baremetal/501draw-text.mu
parentbb0e67a308922fc1a1a6972b00fcc37909a028ce (diff)
downloadmu-0d12f6676bab81d1d68239dcd26089612450232d.tar.gz
7502 - baremetal text: better interface
Diffstat (limited to 'baremetal/501draw-text.mu')
-rw-r--r--baremetal/501draw-text.mu9
1 files changed, 5 insertions, 4 deletions
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