2 ; Copyright (C) 2004, 2005 Kent Hansen.
4 ; This file is part of Neotoxin.
6 ; Neotoxin is free software; you can redistribute it and/or modify
7 ; it under the terms of the GNU General Public License as published by
8 ; the Free Software Foundation; either version 2 of the License, or
9 ; (at your option) any later version.
11 ; Neotoxin is distributed in the hope that it will be useful,
12 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ; GNU General Public License for more details.
16 ; You should have received a copy of the GNU General Public License
17 ; along with this program; if not, write to the Free Software
18 ; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 ; Routines for starting and updating sound effects.
33 .
public start_square_sfx
35 .
public start_noise_sfx
38 .extrn
mixer:mixer_state
40 .extrn
mixer_invalidate_period_save:proc
42 ; Starts playing a sound effect on given channel.
50 sta mixer.sfx.
ptr.lo
,x
52 sta mixer.sfx.
ptr.hi
,x
54 sta mixer.sfx.counter
,x
; triggers on next sfx_tick()
58 ; Starts playing a sound effect on square channel 1.
59 ; Params: Y = *_SFX (see sfx.h)
62 .
proc start_square_sfx
65 ldx #
4 ; square channel 1
77 ldx #
8 ; triangle channel
84 ldx #
12 ; noise channel
88 ; Does one "tick" of SFX processing.
89 ; Params: X = offset into sfx array
92 dec mixer.sfx.counter
,x
94 lda mixer.sfx.
ptr.lo
,x
96 lda mixer.sfx.
ptr.hi
,x
102 sta mixer.sfx.
ptr.hi
,x
; NULL
105 ; for square channels, force the mixer to refresh HW regs
106 jmp mixer_invalidate_period_save
108 + sta mixer.sfx.counter
,x
; # of ticks until next update
110 ; write new values to sound regs
112 sta
$4000,x
; this works since sizeof(sfx_state) is 4 bytes
123 ; increment SFX pointer
126 adc mixer.sfx.
ptr.lo
,x
127 sta mixer.sfx.
ptr.lo
,x
129 inc mixer.sfx.
ptr.hi
,x