From 3120f938c660ab5fcecb579122440d487ccd798e Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Tue, 23 Mar 2021 22:27:46 -0700 Subject: . --- html/ex10.mu.html | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 html/ex10.mu.html (limited to 'html/ex10.mu.html') diff --git a/html/ex10.mu.html b/html/ex10.mu.html new file mode 100644 index 00000000..25753a8f --- /dev/null +++ b/html/ex10.mu.html @@ -0,0 +1,104 @@ + + + + +Mu - ex10.mu + + + + + + + + + + +https://github.com/akkartik/mu/blob/main/ex10.mu +
+ 1 # Demo of mouse, showing deltas in x and y position for every event.
+ 2 #
+ 3 # To build a disk image:
+ 4 #   ./translate ex10.mu            # emits disk.img
+ 5 # To run:
+ 6 #   qemu-system-i386 disk.img
+ 7 # Or:
+ 8 #   bochs -f bochsrc               # bochsrc loads disk.img
+ 9 #
+10 # Expected output:
+11 #   Values between -256 and +255 as you move the mouse over the window.
+12 #   You might need to click on the window once.
+13 
+14 fn main {
+15   # repeatedly print out mouse driver results if non-zero
+16   $main:event-loop: {
+17     var dx/eax: int <- copy 0
+18     var dy/ecx: int <- copy 0
+19     dx, dy <- read-mouse-event
+20     {
+21       compare dx, 0
+22       break-if-!=
+23       compare dy, 0
+24       break-if-!=
+25       loop $main:event-loop
+26     }
+27     {
+28       var dummy1/eax: int <- copy 0
+29       var dummy2/ecx: int <- copy 0
+30       dummy1, dummy2 <- draw-text-wrapping-right-then-down-over-full-screen 0/screen, "         ", 0/x, 0x10/y, 0x31/fg, 0/bg
+31     }
+32     {
+33       var dummy/ecx: int <- copy 0
+34       dx, dummy <- draw-int32-decimal-wrapping-right-then-down-over-full-screen 0/screen, dx, 0/x, 0x10/y, 0x31/fg, 0/bg
+35     }
+36     {
+37       var dummy/eax: int <- copy 0
+38       dummy, dy <- draw-int32-decimal-wrapping-right-then-down-over-full-screen 0/screen, dy, 5/x, 0x10/y, 0x31/fg, 0/bg
+39     }
+40     loop
+41   }
+42 }
+
+ + + -- cgit 1.4.1-2-gfad0