about summary refs log tree commit diff stats
path: root/apps/ex2.mu
diff options
context:
space:
mode:
Diffstat (limited to 'apps/ex2.mu')
-rw-r--r--apps/ex2.mu28
1 files changed, 28 insertions, 0 deletions
diff --git a/apps/ex2.mu b/apps/ex2.mu
new file mode 100644
index 00000000..be66d883
--- /dev/null
+++ b/apps/ex2.mu
@@ -0,0 +1,28 @@
+# Test out the video mode by filling in the screen with pixels.
+#
+# To build a disk image:
+#   ./translate apps/ex2.mu        # emits code.img
+# To run:
+#   qemu-system-i386 code.img
+# Or:
+#   bochs -f bochsrc               # bochsrc loads code.img
+
+fn main screen: (addr screen), keyboard: (addr keyboard), data-disk: (addr disk) {
+  var y/eax: int <- copy 0
+  {
+    compare y, 0x300/screen-height=768
+    break-if->=
+    var x/edx: int <- copy 0
+    {
+      compare x, 0x400/screen-width=1024
+      break-if->=
+      var color/ecx: int <- copy x
+      color <- and 0xff
+      pixel screen x, y, color
+      x <- increment
+      loop
+    }
+    y <- increment
+    loop
+  }
+}