diff options
-rw-r--r-- | boot.subx | 2 | ||||
-rw-r--r-- | hest-life.mu | 46 |
2 files changed, 46 insertions, 2 deletions
diff --git a/boot.subx b/boot.subx index 424e9627..8ad3f2a8 100644 --- a/boot.subx +++ b/boot.subx @@ -565,7 +565,7 @@ Keyboard-ctrl-map: # carriage-return 0d 00 # 1e -# ^a ^s ^d ^f ^g ^h ^j ^j ^l ^\ +# ^a ^s ^d ^f ^g ^h ^j ^k ^l ^\ 01 13 04 06 07 08 0a 0b 0c 00 00 00 00 1c # 2c # ^z ^x ^c ^v ^b ^n ^m ^/ diff --git a/hest-life.mu b/hest-life.mu index 7a373598..8f68a073 100644 --- a/hest-life.mu +++ b/hest-life.mu @@ -200,8 +200,9 @@ fn draw-linear-point screen: (addr screen), u: float, x0: int, y0: int, x1: int, fn edit keyboard: (addr keyboard), _self: (addr environment) { var self/esi: (addr environment) <- copy _self var key/eax: byte <- read-key keyboard - compare key, 0x20/space + # space: play/pause { + compare key, 0x20/space break-if-!= var play?/eax: (addr boolean) <- get self, play? compare *play?, 0/false @@ -213,6 +214,13 @@ fn edit keyboard: (addr keyboard), _self: (addr environment) { copy-to *play?, 1/true return } + # 0: back to start + { + compare key, 0x30/0 + break-if-!= + clear-environment self + return + } } fn pause _self: (addr environment) { @@ -275,6 +283,42 @@ fn initialize-environment _self: (addr environment) { flush self } +fn clear-environment _self: (addr environment) { + var self/esi: (addr environment) <- copy _self + var tick/eax: (addr int) <- get self, tick + copy-to *tick, 0 + var zoom/eax: (addr int) <- get self, zoom +#? copy-to *zoom, 4 + var play?/eax: (addr boolean) <- get self, play? + copy-to *play?, 1/true + var data-ah/eax: (addr handle array handle array cell) <- get self, data + var data/eax: (addr array handle array cell) <- lookup *data-ah + var y/ecx: int <- copy 0 + { + compare y, 0xc0 + break-if->= + var row-ah/eax: (addr handle array cell) <- index data, y + var row/eax: (addr array cell) <- lookup *row-ah + var x/edx: int <- copy 0 + { + compare x, 0x100 + break-if->= + var dest/eax: (addr cell) <- index row, x + clear-object dest + x <- increment + loop + } + y <- increment + loop + } + set self, 0x80, 0x5f, 1/alive + set self, 0x81, 0x5f, 1/alive + set self, 0x7f, 0x60, 1/alive + set self, 0x80, 0x60, 1/alive + set self, 0x80, 0x61, 1/alive + flush self +} + fn set _self: (addr environment), _x: int, _y: int, _val: boolean { var self/esi: (addr environment) <- copy _self var data-ah/eax: (addr handle array handle array cell) <- get self, data |