;; LANTERN GARDEN — raw wasm-game@1 payload source ;; Walk with arrows. A plants a lantern; B clears the garden. (module (memory (export "m") 1 16) (global $px (mut i32) (i32.const 80)) (global $py (mut i32) (i32.const 45)) (global $lit (mut i32) (i32.const 0)) (func (export "f") (param $frame i32) (param $input i32) (param $seed i32) (result i32) (local $i i32) (local $x i32) (local $y i32) (local $dx i32) (local $dy i32) (local $d i32) (local $c i32) ;; input bits: left=1 right=2 up=4 down=8 A=16 B=32 (if (i32.and (local.get $input) (i32.const 1)) (then (global.set $px (i32.sub (global.get $px) (i32.const 1))))) (if (i32.and (local.get $input) (i32.const 2)) (then (global.set $px (i32.add (global.get $px) (i32.const 1))))) (if (i32.and (local.get $input) (i32.const 4)) (then (global.set $py (i32.sub (global.get $py) (i32.const 1))))) (if (i32.and (local.get $input) (i32.const 8)) (then (global.set $py (i32.add (global.get $py) (i32.const 1))))) (if (i32.and (local.get $input) (i32.const 16)) (then (global.set $lit (i32.add (global.get $lit) (i32.const 1))))) (if (i32.and (local.get $input) (i32.const 32)) (then (global.set $lit (i32.const 0)))) (if (i32.lt_s (global.get $px) (i32.const 1)) (then (global.set $px (i32.const 1)))) (if (i32.gt_s (global.get $px) (i32.const 158)) (then (global.set $px (i32.const 158)))) (if (i32.lt_s (global.get $py) (i32.const 1)) (then (global.set $py (i32.const 1)))) (if (i32.gt_s (global.get $py) (i32.const 88)) (then (global.set $py (i32.const 88)))) (loop $draw (local.set $x (i32.rem_u (local.get $i) (i32.const 160))) (local.set $y (i32.div_u (local.get $i) (i32.const 160))) (local.set $dx (i32.sub (local.get $x) (global.get $px))) (local.set $dy (i32.sub (local.get $y) (global.get $py))) (if (i32.lt_s (local.get $dx) (i32.const 0)) (then (local.set $dx (i32.sub (i32.const 0) (local.get $dx))))) (if (i32.lt_s (local.get $dy) (i32.const 0)) (then (local.set $dy (i32.sub (i32.const 0) (local.get $dy))))) (local.set $d (i32.add (local.get $dx) (local.get $dy))) ;; midnight garden: a low field of odd flowers around a movable lantern (local.set $c (i32.const 0xff160d06)) (if (i32.gt_u (local.get $y) (i32.const 56)) (then (local.set $c (i32.const 0xff1b2810)))) (if (i32.eqz (i32.and (i32.add (i32.add (i32.add (i32.mul (i32.mul (local.get $x) (local.get $x)) (i32.const 17)) (i32.mul (i32.mul (local.get $y) (local.get $y)) (i32.const 23))) (i32.mul (i32.mul (local.get $x) (local.get $y)) (i32.const 11))) (local.get $seed)) (i32.const 127))) (then (local.set $c (i32.const 0xff8cc850)))) (if (i32.lt_u (local.get $d) (i32.add (i32.const 4) (i32.rem_u (global.get $lit) (i32.const 32)))) (then (local.set $c (i32.or (i32.shl (i32.sub (i32.const 255) (i32.mul (local.get $d) (i32.const 20))) (i32.const 16)) (i32.or (i32.shl (i32.const 170) (i32.const 8)) (i32.const 255)))))) (if (i32.lt_u (local.get $d) (i32.const 2)) (then (local.set $c (i32.const 4294967295)))) (i32.store (i32.shl (local.get $i) (i32.const 2)) (local.get $c)) (local.set $i (i32.add (local.get $i) (i32.const 1))) (br_if $draw (i32.lt_u (local.get $i) (i32.const 14400))) ) (i32.const 0) ) )