From 04134396a353559b6bd6d0e73e23ddcdd160d20b Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Wed, 28 Jul 2021 22:51:31 -0700 Subject: . --- html/apps/color-game.mu.html | 142 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 142 insertions(+) create mode 100644 html/apps/color-game.mu.html (limited to 'html') diff --git a/html/apps/color-game.mu.html b/html/apps/color-game.mu.html new file mode 100644 index 00000000..5aa5ba18 --- /dev/null +++ b/html/apps/color-game.mu.html @@ -0,0 +1,142 @@ + + + + +Mu - apps/color-game.mu + + + + + + + + + + +https://github.com/akkartik/mu/blob/main/apps/color-game.mu +
+ 1 # Guess the result of mixing two colors.
+ 2 
+ 3 fn main screen: (addr screen), keyboard: (addr keyboard), data-disk: (addr disk) {
+ 4   var second-buffer: screen
+ 5   var second-screen/edi: (addr screen) <- address second-buffer
+ 6   initialize-screen second-screen, 0x80, 0x30, 1/include-pixels
+ 7   var leftx/edx: int <- copy 0x80
+ 8   var rightx/ebx: int <- copy 0x380
+ 9   {
+10     compare leftx, rightx
+11     break-if->=
+12     clear-screen second-screen
+13     # interesting value: 9/blue with 0xe/yellow
+14     color-field second-screen, leftx 0x40/y, 0x40/width 0x40/height, 1/blue
+15     color-field second-screen, rightx 0x41/y, 0x40/width 0x40/height, 2/green
+16     copy-pixels second-screen, screen
+17     # on the first iteration, give everyone a chance to make their guess
+18     {
+19       compare leftx, 0x80
+20       break-if->
+21       var x/eax: byte <- read-key keyboard
+22       compare x, 0
+23       loop-if-=
+24     }
+25     leftx <- add 2
+26     rightx <- subtract 2
+27     loop
+28   }
+29 }
+30 
+31 fn color-field screen: (addr screen), xmin: int, ymin: int, width: int, height: int, color: int {
+32   var xmax/esi: int <- copy xmin
+33   xmax <- add width
+34   var ymax/edi: int <- copy ymin
+35   ymax <- add height
+36   var y/eax: int <- copy ymin
+37   {
+38     compare y, ymax
+39     break-if->=
+40     var x/ecx: int <- copy xmin
+41     {
+42       compare x, xmax
+43       break-if->=
+44       pixel screen, x, y, color
+45       x <- add 2
+46       loop
+47     }
+48     y <- increment
+49     compare y, ymax
+50     break-if->=
+51     var x/ecx: int <- copy xmin
+52     x <- increment
+53     {
+54       compare x, xmax
+55       break-if->=
+56       pixel screen, x, y, color
+57       x <- add 2
+58       loop
+59     }
+60     y <- increment
+61     loop
+62   }
+63 }
+64 
+65 fn linger {
+66   var i/ecx: int <- copy 0
+67   {
+68     compare i, 0x40000000  # Kartik's Linux with -accel kvm
+69 #?     compare i, 0x8000000  # Kartik's Mac with -accel tcg
+70     break-if->=
+71     i <- increment
+72     loop
+73   }
+74 }
+
+ + + -- cgit 1.4.1-2-gfad0