make a little noise

This commit is contained in:
Jeremy Penner 2021-01-21 22:54:21 -05:00
parent 16ccafc80f
commit 7b39274ba1
3 changed files with 28 additions and 2 deletions

25
game/boop.fnl Normal file
View file

@ -0,0 +1,25 @@
(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)

View file

@ -8,6 +8,7 @@
(util.reload :game.map) (util.reload :game.map)
(util.reload :game.entity) (util.reload :game.entity)
(util.reload :game.player) (util.reload :game.player)
(util.reload :game.boop)
(tile.appendtiles org.code) (tile.appendtiles org.code)
(org.code:append [:align 0x100] :font) (org.code:append [:align 0x100] :font)
@ -46,7 +47,7 @@
[:vm :hires [:vm :hires
:lit :level1 :load-level :lit :level1 :load-level
(vm:forever (vm:forever
(vm:hotswap-sync :lit :level4 :load-level) (vm:hotswap-sync :lit :level5 :load-level)
:interactive-eval-checkpoint :interactive-eval-checkpoint
:handle-key :handle-key
) )

View file

@ -56,7 +56,7 @@
(vm:word :move ; dir -- dir (vm:word :move ; dir -- dir
:dup :player-yx :get :yx+ :move-player-to 0x300 :snooze) :dup :player-yx :get :yx+ :move-player-to 0x300 :snooze)
(vm:word :explode ; dir -- (vm:word :explode ; dir --
:player-yx :get :yx+ :randomgarbage :update-itile 0x100 :snooze) :player-yx :get :yx+ :randomgarbage :update-itile :snd-explode)
(vm:word :explodingdoor (vm:word :explodingdoor
:dup :door :dup :door