honeylisp/game/boop.fnl

26 lines
549 B
Fennel

(local {: vm} (require :game.defs))
(local speaker :0xc030)
(vm:def :blipmem ; count p --
[:block
[:lda [vm.ST1 :x]]
[:tay]
:sample
[:lda speaker]
[:lda [vm.TOP :x]]
[:inc vm.TOP :x]
[:bne :wait]
[:inc vm.TOPH :x]
:wait
[:clc] [:adc 1]
[:bne :wait]
[:dey]
[:bne :sample]]
(vm:drop) (vm:drop))
(var noisebytes "")
(for [i 0 0x40] (set noisebytes (.. noisebytes (string.char (math.random 0 255)))))
(vm.code:append :noise [:bytes noisebytes])
(vm:word :snd-explode 0x40 :lit :noise :blipmem)