From f6fd7e1be0780b5b6dee042bef1c4f0264069787 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Wed, 13 Jan 2021 00:08:31 -0800 Subject: 7509 --- html/baremetal/ex6.mu.html | 94 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 html/baremetal/ex6.mu.html (limited to 'html/baremetal/ex6.mu.html') diff --git a/html/baremetal/ex6.mu.html b/html/baremetal/ex6.mu.html new file mode 100644 index 00000000..810b729b --- /dev/null +++ b/html/baremetal/ex6.mu.html @@ -0,0 +1,94 @@ + + + + +Mu - baremetal/ex6.mu + + + + + + + + + + +https://github.com/akkartik/mu/blob/main/baremetal/ex6.mu +
+ 1 # Drawing ASCII text incrementally.
+ 2 #
+ 3 # To build a disk image:
+ 4 #   ./translate_mu_baremetal baremetal/ex6.mu     # emits disk.img
+ 5 # To run:
+ 6 #   qemu-system-i386 disk.img
+ 7 # Or:
+ 8 #   bochs -f baremetal/boot.bochsrc               # boot.bochsrc loads disk.img
+ 9 #
+10 # Expected output: a box and text that doesn't overflow it
+11 
+12 fn main {
+13   # drawing text within a bounding box
+14   draw-box 0, 0xf, 0x1f, 0x79, 0x51, 0x4
+15   var x/eax: int <- copy 0x20
+16   var y/ecx: int <- copy 0x20
+17   x, y <- draw-text-wrapping-right-then-down 0, "hello ",     0x10, 0x20, 0x78, 0x50, x, y, 0xa  # (0x10, 0x20) -> (0x78, 0x50)
+18   x, y <- draw-text-wrapping-right-then-down 0, "from ",      0x10, 0x20, 0x78, 0x50, x, y, 0xa
+19   x, y <- draw-text-wrapping-right-then-down 0, "baremetal ", 0x10, 0x20, 0x78, 0x50, x, y, 0xa
+20   x, y <- draw-text-wrapping-right-then-down 0, "Mu!",        0x10, 0x20, 0x78, 0x50, x, y, 0xa
+21 
+22   # drawing at the cursor in multiple directions
+23   x, y <- draw-text-wrapping-down-then-right-from-cursor-over-full-screen 0, "abc", 0xa
+24   x, y <- draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0, "def", 0xa
+25 
+26   # test drawing near the edge
+27   x <- draw-text-rightward 0, "R", 0x3f8, 0x400, 0x100, 0xa
+28   x, y <- draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0, "wrapped from R", 0xa
+29 
+30   x <- draw-text-downward 0, "D", 0x100, 0x2f0, 0x300, 0xa
+31   x, y <- draw-text-wrapping-down-then-right-from-cursor-over-full-screen 0, "wrapped from D", 0xa
+32 }
+
+ + + -- cgit 1.4.1-2-gfad0