https://github.com/akkartik/mu/blob/main/apps/color-game.mu
1
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
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
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 }