From bb0e67a308922fc1a1a6972b00fcc37909a028ce Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Tue, 12 Jan 2021 00:20:22 -0800 Subject: 7501 - baremetal: draw text within a rectangle --- baremetal/502manhattan-line.mu | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 baremetal/502manhattan-line.mu (limited to 'baremetal/502manhattan-line.mu') 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 + } +} -- cgit 1.4.1-2-gfad0