2 # https://eugenkiss.github.io/7guis/tasks/#counter
5 # $ ./translate counter.mu
7 # $ qemu-system-i386 code.img
9 fn main screen: (addr screen), keyboard: (addr keyboard), data-disk: (addr disk) {
10 var count/ecx: int <- copy 0
12 set-cursor-position screen, 0x1f/x 0xe/y
13 draw-text-rightward-from-cursor-over-full-screen screen, " Counter ", 0xf/fg 0x16/bg
16 # draw current state to screen
17 clear-rect screen, 0x1f/xmin 0xf/ymin, 0x40/xmax 0x14/ymax, 0xc5/color
18 set-cursor-position screen, 0x20/x 0x10/y
19 draw-int32-decimal-wrapping-right-then-down-from-cursor-over-full-screen screen, count, 7/fg 0xc5/bg
21 set-cursor-position screen, 0x24/x 0x12/y
22 draw-text-rightward-from-cursor-over-full-screen screen, " enter ", 0/fg 0x5c/bg=highlight
23 draw-text-rightward-from-cursor-over-full-screen screen, " increment ", 7/fg 0xc5/bg
24 # process a single keystroke
26 var key/eax: byte <- read-key keyboard
29 compare key, 0xa/newline