about summary refs log tree commit diff stats
path: root/baremetal/502manhattan-line.mu
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2021-01-12 00:20:22 -0800
committerKartik Agaram <vc@akkartik.com>2021-01-12 00:20:22 -0800
commitbb0e67a308922fc1a1a6972b00fcc37909a028ce (patch)
tree4636ba8cfaad3ad2f3d64c67a08557c2d89cc8b4 /baremetal/502manhattan-line.mu
parent589eba07e2b1f1f3c6dbb3087b306071a2f9809b (diff)
downloadmu-bb0e67a308922fc1a1a6972b00fcc37909a028ce.tar.gz
7501 - baremetal: draw text within a rectangle
Diffstat (limited to 'baremetal/502manhattan-line.mu')
-rw-r--r--baremetal/502manhattan-line.mu28
1 files changed, 28 insertions, 0 deletions
diff --git a/baremetal/502manhattan-line.mu b/baremetal/502manhattan-line.mu
new file mode 100644
index 00000000..0351fcb6
--- /dev/null
+++ b/baremetal/502manhattan-line.mu
@@ -0,0 +1,28 @@
+fn draw-box screen: (addr screen), x1: int, y1: int, x2: int, y2: int, color: int {
+  draw-horizontal-line screen, x1, x2, y1, color
+  draw-vertical-line screen, x1, y1, y2, color
+  draw-horizontal-line screen, x1, x2, y2, color
+  draw-vertical-line screen, x2, y1, y2, color
+}
+
+fn draw-horizontal-line screen: (addr screen), x1: int, x2: int, y: int, color: int {
+  var x/eax: int <- copy x1
+  {
+    compare x, x2
+    break-if->=
+    pixel screen, x, y, color
+    x <- increment
+    loop
+  }
+}
+
+fn draw-vertical-line screen: (addr screen), x: int, y1: int, y2: int, color: int {
+  var y/eax: int <- copy y1
+  {
+    compare y, y2
+    break-if->=
+    pixel screen, x, y, color
+    y <- increment
+    loop
+  }
+}