about summary refs log tree commit diff stats
path: root/baremetal
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-02-22 22:32:12 -0800
committerKartik K. Agaram <vc@akkartik.com>2021-02-22 22:32:12 -0800
commitfdc3df04300f20fac81792d1f5ee1e170a5644ec (patch)
tree939b3d091baa7b62ab1a86ba761bd0c8513921d6 /baremetal
parenta4bc5df0809319e118be77246aa12aa639d82f1a (diff)
downloadmu-fdc3df04300f20fac81792d1f5ee1e170a5644ec.tar.gz
7788
Diffstat (limited to 'baremetal')
-rw-r--r--baremetal/501draw-text.mu19
-rw-r--r--baremetal/502test.mu3
-rw-r--r--baremetal/504test-screen.mu8
3 files changed, 30 insertions, 0 deletions
diff --git a/baremetal/501draw-text.mu b/baremetal/501draw-text.mu
index b2c2136f..b17b54a3 100644
--- a/baremetal/501draw-text.mu
+++ b/baremetal/501draw-text.mu
@@ -62,6 +62,25 @@ fn move-cursor-down screen: (addr screen) {
   set-cursor-position screen, cursor-x, cursor-y
 }
 
+fn move-cursor-to-start-of-next-line screen: (addr screen) {
+  var dummy/eax: int <- copy 0
+  var _height/ecx: int <- copy 0
+  dummy, _height <- screen-size screen
+  var limit/edx: int <- copy _height
+  limit <- decrement
+  var cursor-x/eax: int <- copy 0
+  var cursor-y/ecx: int <- copy 0
+  cursor-x, cursor-y <- cursor-position screen
+  compare cursor-y, limit
+  {
+    break-if-<
+    return
+  }
+  cursor-y <- increment
+  cursor-x <- copy 0
+  set-cursor-position screen, cursor-x, cursor-y
+}
+
 fn draw-grapheme-at-cursor screen: (addr screen), g: grapheme, color: int, background-color: int {
   var cursor-x/eax: int <- copy 0
   var cursor-y/ecx: int <- copy 0
diff --git a/baremetal/502test.mu b/baremetal/502test.mu
index 89d9b0e9..00d55d34 100644
--- a/baremetal/502test.mu
+++ b/baremetal/502test.mu
@@ -8,6 +8,7 @@ fn check-ints-equal _a: int, b: int, msg: (addr array byte) {
     return
   }
   draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, msg, 3/fg/cyan, 0/bg
+  move-cursor-to-start-of-next-line 0/screen
   count-test-failure
 }
 
@@ -24,6 +25,7 @@ fn check _a: boolean, msg: (addr array byte) {
     return
   }
   draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, msg, 3/fg/cyan, 0/bg
+  move-cursor-to-start-of-next-line 0/screen
   count-test-failure
 }
 
@@ -36,5 +38,6 @@ fn check-not _a: boolean, msg: (addr array byte) {
     return
   }
   draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, msg, 3/fg/cyan, 0/bg
+  move-cursor-to-start-of-next-line 0/screen
   count-test-failure
 }
diff --git a/baremetal/504test-screen.mu b/baremetal/504test-screen.mu
index b70b11c7..a409443b 100644
--- a/baremetal/504test-screen.mu
+++ b/baremetal/504test-screen.mu
@@ -52,6 +52,7 @@ fn check-screen-row-from screen-on-stack: (addr screen), x: int, y: int, expecte
       draw-grapheme-at-cursor 0/screen, g, 3/cyan, 0/bg
       move-cursor-rightward-and-downward 0/screen, 0/xmin, 0x80/xmax=screen-width
       draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "'", 3/fg/cyan, 0/bg
+      move-cursor-to-start-of-next-line 0/screen
     }
     idx <- increment
     increment x
@@ -119,6 +120,7 @@ fn check-screen-row-in-color-from screen-on-stack: (addr screen), fg: int, y: in
         draw-grapheme-at-cursor 0/screen, g, 3/cyan, 0/bg
         move-cursor-rightward-and-downward 0/screen, 0/xmin, 0x80/xmax=screen-width
         draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "'", 3/fg/cyan, 0/bg
+        move-cursor-to-start-of-next-line 0/screen
       }
       $check-screen-row-in-color-from:compare-colors: {
         var color/eax: int <- screen-color-at-idx screen, idx
@@ -142,6 +144,7 @@ fn check-screen-row-in-color-from screen-on-stack: (addr screen), fg: int, y: in
         draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, fg, 3/fg/cyan, 0/bg
         draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, " but observed color ", 3/fg/cyan, 0/bg
         draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, color, 3/fg/cyan, 0/bg
+        move-cursor-to-start-of-next-line 0/screen
       }
     }
     idx <- increment
@@ -208,6 +211,8 @@ fn check-screen-row-in-background-color-from screen-on-stack: (addr screen), bg:
         draw-grapheme-at-cursor 0/screen, g, 3/cyan, 0/bg
         move-cursor-rightward-and-downward 0/screen, 0/xmin, 0x80/xmax=screen-width
         draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "'", 3/fg/cyan, 0/bg
+        move-cursor-to-start-of-next-line 0/screen
+        break $check-screen-row-in-background-color-from:compare-graphemes
       }
       $check-screen-row-in-background-color-from:compare-background-colors: {
         var background-color/eax: int <- screen-background-color-at-idx screen, idx
@@ -231,6 +236,7 @@ fn check-screen-row-in-background-color-from screen-on-stack: (addr screen), bg:
         draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, bg, 3/fg/cyan, 0/bg
         draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, " but observed background-color ", 3/fg/cyan, 0/bg
         draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, background-color, 3/fg/cyan, 0/bg
+        move-cursor-to-start-of-next-line 0/screen
       }
     }
     idx <- increment
@@ -275,6 +281,7 @@ fn check-background-color-in-screen-row-from screen-on-stack: (addr screen), bg:
         draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, y, 3/fg/cyan, 0/bg
         draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, ") to not be in background-color ", 3/fg/cyan, 0/bg
         draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, bg, 3/fg/cyan, 0/bg
+        move-cursor-to-start-of-next-line 0/screen
         break $check-background-color-in-screen-row-from:compare-cells
       }
       # otherwise assert that background IS bg
@@ -290,6 +297,7 @@ fn check-background-color-in-screen-row-from screen-on-stack: (addr screen), bg:
       draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, bg, 3/fg/cyan, 0/bg
       draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, " but observed background-color ", 3/fg/cyan, 0/bg
       draw-int32-hex-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, background-color, 3/fg/cyan, 0/bg
+      move-cursor-to-start-of-next-line 0/screen
     }
     idx <- increment
     increment x