Cleaned up a little.
[ymamoto.git] / sine-oscillator.s
blob0056d556c53d3a6c0919e46133d78dd0215df7a8
2 * This is a resonant filter (with infinite? resonance),
3 * cutoff/oscillation frequency of 50Hz, so that the step value
4 * will equal 1/8 (IOW, >>3). The step value is usually:
5 * (* 2 (sin (* pi (/ 1 frequency)))) - see resonant-filter.lisp
6 * in my snippets collection.
8 * Actually, this is >>4 now, to make things a bit smoother.
10 section text
12 global reset_sine_oscillator
13 reset_sine_oscillator:
14 MOVE.W #$100, cosine ; Fairly arbitrary max amplitude.
15 MOVE.W #0, sine
16 RTS
18 global step_sine_oscillator
19 step_sine_oscillator:
20 MOVE.W sine, D0
21 ASR.W #4, D0
22 SUB.W D0, cosine
23 MOVE.W cosine, D0
24 ASR.W #4, D0
25 ADD.W D0, sine
26 RTS
28 section data
29 global sine, cosine
30 sine: ds.w 1
31 cosine: ds.w 1