diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2021-07-16 08:09:42 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2021-07-16 08:28:56 -0700 |
commit | 44d26b77c45668c9b0c99894a4294cec004361fe (patch) | |
tree | 68a5dcd4971873efd4ce184e9bf9a531c2161813 /apps/ex6.mu | |
parent | ac45f097153afd3a89f43886e4124c5b2c26b98a (diff) | |
download | mu-44d26b77c45668c9b0c99894a4294cec004361fe.tar.gz |
.
Diffstat (limited to 'apps/ex6.mu')
-rw-r--r-- | apps/ex6.mu | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/apps/ex6.mu b/apps/ex6.mu new file mode 100644 index 00000000..fbad3c13 --- /dev/null +++ b/apps/ex6.mu @@ -0,0 +1,32 @@ +# Drawing ASCII text incrementally. +# +# To build a disk image: +# ./translate apps/ex6.mu # emits code.img +# To run: +# qemu-system-i386 code.img +# Or: +# bochs -f bochsrc # bochsrc loads code.img +# +# Expected output: a box and text that doesn't overflow it + +fn main screen: (addr screen), keyboard: (addr keyboard), data-disk: (addr disk) { + # drawing text within a bounding box + draw-box-on-real-screen 0xf, 0x1f, 0x79, 0x51, 0x4 + var x/eax: int <- copy 0x20 + var y/ecx: int <- copy 0x20 + x, y <- draw-text-wrapping-right-then-down screen, "hello ", 0x10/xmin, 0x20/ymin, 0x78/xmax, 0x50/ymax, x, y, 0xa/fg, 0/bg + x, y <- draw-text-wrapping-right-then-down screen, "from ", 0x10/xmin, 0x20/ymin, 0x78/xmax, 0x50/ymax, x, y, 0xa/fg, 0/bg + x, y <- draw-text-wrapping-right-then-down screen, "baremetal ", 0x10/xmin, 0x20/ymin, 0x78/xmax, 0x50/ymax, x, y, 0xa/fg, 0/bg + x, y <- draw-text-wrapping-right-then-down screen, "Mu!", 0x10/xmin, 0x20/ymin, 0x78/xmax, 0x50/ymax, x, y, 0xa/fg, 0/bg + + # drawing at the cursor in multiple directions + draw-text-wrapping-down-then-right-from-cursor-over-full-screen screen, "abc", 0xa/fg, 0/bg + draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, "def", 0xa/fg, 0/bg + + # test drawing near the edge + x <- draw-text-rightward screen, "R", 0x7f/x, 0x80/xmax=screen-width, 0x18/y, 0xa/fg, 0/bg + draw-text-wrapping-right-then-down-from-cursor-over-full-screen screen, "wrapped from R", 0xa/fg, 0/bg + + x <- draw-text-downward screen, "D", 0x20/x, 0x2f/y, 0x30/ymax=screen-height, 0xa/fg, 0/bg + draw-text-wrapping-down-then-right-from-cursor-over-full-screen screen, "wrapped from D", 0xa/fg, 0/bg +} |