From 7b39274ba17a63c976cf0be20d9f7a73f4193f5f Mon Sep 17 00:00:00 2001 From: Jeremy Penner Date: Thu, 21 Jan 2021 22:54:21 -0500 Subject: [PATCH] make a little noise --- game/boop.fnl | 25 +++++++++++++++++++++++++ game/init.fnl | 3 ++- game/level5.fnl | 2 +- 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 game/boop.fnl diff --git a/game/boop.fnl b/game/boop.fnl new file mode 100644 index 0000000..66becbb --- /dev/null +++ b/game/boop.fnl @@ -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) + diff --git a/game/init.fnl b/game/init.fnl index 0bdfacd..b6916b9 100644 --- a/game/init.fnl +++ b/game/init.fnl @@ -8,6 +8,7 @@ (util.reload :game.map) (util.reload :game.entity) (util.reload :game.player) +(util.reload :game.boop) (tile.appendtiles org.code) (org.code:append [:align 0x100] :font) @@ -46,7 +47,7 @@ [:vm :hires :lit :level1 :load-level (vm:forever - (vm:hotswap-sync :lit :level4 :load-level) + (vm:hotswap-sync :lit :level5 :load-level) :interactive-eval-checkpoint :handle-key ) diff --git a/game/level5.fnl b/game/level5.fnl index 2d93fdd..10d844f 100644 --- a/game/level5.fnl +++ b/game/level5.fnl @@ -56,7 +56,7 @@ (vm:word :move ; dir -- dir :dup :player-yx :get :yx+ :move-player-to 0x300 :snooze) (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 :dup :door