From 61ec86b71928afc4a7b0a9c787ba88d5b4b3040b Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Mon, 30 Aug 2021 09:21:52 -0700 Subject: . --- html/apps/ex7.mu.html | 78 +++++++++++++++++++++++++-------------------------- 1 file changed, 38 insertions(+), 40 deletions(-) (limited to 'html/apps/ex7.mu.html') diff --git a/html/apps/ex7.mu.html b/html/apps/ex7.mu.html index 416ced89..6dbd0e24 100644 --- a/html/apps/ex7.mu.html +++ b/html/apps/ex7.mu.html @@ -62,46 +62,44 @@ if ('onhashchange' in window) { 4 # ./translate apps/ex7.mu # emits code.img 5 # To run: 6 # qemu-system-i386 code.img - 7 # Or: - 8 # bochs -f bochsrc # bochsrc loads code.img - 9 # -10 # Expected output: an interactive game a bit like "snakes". Try pressing h, j, -11 # k, l. -12 -13 fn main screen: (addr screen), keyboard: (addr keyboard), data-disk: (addr disk) { -14 var space/eax: grapheme <- copy 0x20 -15 set-cursor-position screen, 0, 0 -16 { -17 draw-cursor screen, space -18 var key/eax: byte <- read-key keyboard -19 { -20 compare key, 0x68/h -21 break-if-!= -22 draw-code-point-at-cursor screen, 0x2d/dash, 0x31/fg, 0/bg -23 move-cursor-left 0 -24 } -25 { -26 compare key, 0x6a/j -27 break-if-!= -28 draw-code-point-at-cursor screen, 0x7c/vertical-bar, 0x31/fg, 0/bg -29 move-cursor-down 0 -30 } -31 { -32 compare key, 0x6b/k -33 break-if-!= -34 draw-code-point-at-cursor screen, 0x7c/vertical-bar, 0x31/fg, 0/bg -35 move-cursor-up 0 -36 } -37 { -38 compare key, 0x6c/l -39 break-if-!= -40 var g/eax: code-point <- copy 0x2d/dash -41 draw-code-point-at-cursor screen, 0x2d/dash, 0x31/fg, 0/bg -42 move-cursor-right 0 -43 } -44 loop -45 } -46 } + 7 # + 8 # Expected output: an interactive game a bit like "snakes". Try pressing h, j, + 9 # k, l. +10 +11 fn main screen: (addr screen), keyboard: (addr keyboard), data-disk: (addr disk) { +12 var space/eax: grapheme <- copy 0x20 +13 set-cursor-position screen, 0, 0 +14 { +15 draw-cursor screen, space +16 var key/eax: byte <- read-key keyboard +17 { +18 compare key, 0x68/h +19 break-if-!= +20 draw-code-point-at-cursor screen, 0x2d/dash, 0x31/fg, 0/bg +21 move-cursor-left 0 +22 } +23 { +24 compare key, 0x6a/j +25 break-if-!= +26 draw-code-point-at-cursor screen, 0x7c/vertical-bar, 0x31/fg, 0/bg +27 move-cursor-down 0 +28 } +29 { +30 compare key, 0x6b/k +31 break-if-!= +32 draw-code-point-at-cursor screen, 0x7c/vertical-bar, 0x31/fg, 0/bg +33 move-cursor-up 0 +34 } +35 { +36 compare key, 0x6c/l +37 break-if-!= +38 var g/eax: code-point <- copy 0x2d/dash +39 draw-code-point-at-cursor screen, 0x2d/dash, 0x31/fg, 0/bg +40 move-cursor-right 0 +41 } +42 loop +43 } +44 } -- cgit 1.4.1-2-gfad0