From e90e70f8e38bafcac50b717f0669de43e9d5e10c Mon Sep 17 00:00:00 2001 From: Jeremy Penner Date: Thu, 4 Feb 2021 19:45:40 -0500 Subject: [PATCH] Musical sound effects! --- NeutTower.dsk | Bin 143360 -> 143360 bytes game/boop.fnl | 57 ++++++++++++++++++++++++++++++++++++++++++++++-- game/entity.fnl | 21 ++++++++++++++---- 3 files changed, 72 insertions(+), 6 deletions(-) diff --git a/NeutTower.dsk b/NeutTower.dsk index 6e5ae402bfd0cb4d31ffe17da76ffbbb3086157c..dd9ef5722afca879a285f863cb389494e8fe5ad4 100644 GIT binary patch delta 9551 zcmZuX33yXgy7#7A(%#diRUf#AMQMlS@ia<>(bv6Am!v7x0v{ltZ6UN!C>ThWd!Y-( zQfzx0TA;|jR-BFn;*5^6YGptfo;vzKX<<}w7)N|>WEh0J|Nl>t+xB}c-kFV0e%XFeo$st0EtPh2*3Z%6*QF<<_2?X_o9SG{`p-Qj)H zmc(?dx^$)P9n;g5sqc+g^ZJ~YJ+mKN^TYD55A}bYwbVK3NKnGB;-acPls}9-I;N+4 z*48J-mSuNI(JA#(mt}?vSjm(8Zi<0jlp298SjYp?e*jSNcc-=2L_a=IaRI6v9meoSEgO<@+d(r~L>< zA5H5=@v+kGG!*ci4k=VocYao+jjd$e*>O+{ALsCFJeqeAB90+C2GO`_U&rbt zq#&8y*^e+Y3lWgb&1U4i%*F>q{KbwozmPW;>T`15I@YZQ?;I%~mh0vnoOtw5b;G$k z@I1WgkkSjoZQl56V)xG<%sY4aH2gqCfyHK)0M6tY=Wz$Xe7%|d5+S1_Fsd~8JkzEc z37H2|a5x?OMFBnQ2k3aanh0fUZ%n*kCsBt0 z=&;A;;3t+C61GFOJK=v>cCEF6#s-LnKsXQ35hJF|M1@vkub1TOxgPeV9f30l*bcxw zS$-HV^)7&=bs~&qH%e~yXFDdNL-N?Pw44PR5Bo3sllEs)8j03d>LU_yty1*Rl1CWw zc1b)#qhw4G+XntVlS{=U;);7X7c;B`pk6ZVNrK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 42b2f27..8a96c44 100644 --- a/game/boop.fnl +++ b/game/boop.fnl @@ -1,7 +1,7 @@ (local {: vm} (require :game.defs)) (local speaker :0xc030) - (vm:def :blipmem ; count p -- +(vm:def :blipmem ; count p -- [:block [:lda [vm.ST1 :x]] [:tay] @@ -18,5 +18,58 @@ [:bne :sample]] (vm:drop) (vm:drop)) -(vm:word :snd-explode 0x40 :lit :randombytes :blipmem) +(vm:def :bliptone ; duration-f1 f2 -- + [:block + [:lda vm.ST1H :x] + [:sta vm.W] + :top + [:lda speaker] + [:ldy vm.ST1 :x] + :wave1 [:dey] [:bne :wave1] + [:lda speaker] + [:lda vm.TOPH :x] + [:ldy vm.TOP :x] [:iny] + :wave2 [:dey] [:bne :wave2] + [:ldy 0xff] + [:sec] [:sbc 1] [:bcs :wave2] + [:dec vm.W] + [:bne :top] + (vm:drop) (vm:drop)]) +; 0x39a "samples" = 440hz +(local notes {}) +(each [i note (ipairs [:a :a# :b :c :c# :d :d# :e :f :f# :g :g#])] + (tset notes note (- i 1))) +(fn wavelength [note] + (-> 0x39a + (/ (math.pow 1.05946 (. notes note))) + (math.floor))) +(fn octave [wvl oct] + (-> wvl + (/ (math.pow 2 (- oct 3))) + (math.floor))) +(fn parse-note [n] + (values (n:sub 1 -2) (tonumber (n:sub -1)))) +(fn note-wavelength [n] + (local (note oct) (parse-note n)) + (-> (wavelength note) + (octave oct))) +(fn note [n ?duration ?timbre] + (local timbre (or ?timbre 0x20)) + (local duration (or ?duration 0x10)) + (local wvl (note-wavelength n)) + [:vm (bit.bor (bit.lshift duration 8) timbre) (- wvl timbre) :bliptone]) +(fn notes [ns ?duration ?timbre] + (local result [:block]) + (each [_ n (ipairs ns)] + (table.insert result (note n ?duration ?timbre))) + result) + +(vm:word :snd-explode 0x40 :lit :randombytes :blipmem) +(vm:word :snd-dooropen (notes [:c1 :e1] 8)) +(vm:word :snd-doorclose (notes [:e1 :c1] 8)) +(vm:word :snd-term-jingle (notes [:e3 :f3 :g3] 0x20)) +(vm:word :snd-termon :snd-term-jingle (note :c4 0x20)) +(vm:word :snd-termoff :snd-term-jingle (note :c3 0x20)) + +{: note : notes} diff --git a/game/entity.fnl b/game/entity.fnl index 2bf2328..e6eff2a 100644 --- a/game/entity.fnl +++ b/game/entity.fnl @@ -72,12 +72,23 @@ :get-responder :get :dup :handle-general-move :swap :over :not (vm:if [:move-player-to] [:drop])) +(vm:var :pre-handled-tile 0) +(vm:var :pre-handled-ev 0) (vm:word :handle-onoff ; ev off on -- - :