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 ; Handles pattern commands for channels 0,1,2,3.
24 .
include <common
/tablecall.h
>
32 .
public global_transpose
36 .
public process_tonal_pattern_byte
38 .extrn
mixer:mixer_state
39 .extrn
table_call:proc
40 .extrn
fetch_pattern_byte:proc
41 .extrn
set_track_speed:proc
42 .extrn
set_all_tracks_speed:proc
43 .extrn
period_table_lo:byte
44 .extrn
period_table_hi:byte
45 .extrn
instrument_table:ptr
46 .extrn
tracks:track_state
48 ; Processes one byte received on channel.
50 ; X = offset of channel data
52 .
proc process_tonal_pattern_byte
54 bpl is_note
; if bit 7 clear, it's a note #
56 cmp #
$E0 ; is it a command?
62 sta mixer.tonals.effect.kind
,x
64 jsr fetch_pattern_byte
65 sta mixer.tonals.effect.slide.amount
,x
; this is a union
67 lda mixer.tonals.effect.vibrato.delay
,x
68 sta mixer.tonals.effect.vibrato.counter
,x
69 sta mixer.tonals.effect.vibrato.pos
,x
79 adc tracks.pattern.transpose
,x
81 and #
$7F ; note # in lower 7 bits
82 bpl set_note
; skip the volume & vibrato retrig
86 adc tracks.pattern.transpose
,x
90 sta mixer.tonals.square.period_save
,x
; this is a union
91 lda mixer.envelopes.master
,x
92 lsr
; CF=1 if the volume has been overridden by a previous volume command
96 sta mixer.envelopes.master
,x
98 sta mixer.envelopes.phase
,x
; volume envelope phase = init
100 sta mixer.tonals.effect.vibrato.pos
,x
; reset vibrato position
101 lda mixer.tonals.effect.vibrato.delay
,x
102 sta mixer.tonals.effect.vibrato.counter
,x
; reset vibrato delay
106 ldy mixer.tonals.effect.kind
,x
107 cpy #PORTAMENTO_EFFECT
; if slide parameter present...
108 beq init_slide
; ... slide from old to new note
109 ; no slide, set new period immediately
110 sta mixer.tonals.period_index
,x
112 lda period_table_lo
,y
113 sta mixer.tonals.period.lo
,x
114 lda period_table_hi
,y
115 sta mixer.tonals.period.hi
,x
116 ; channel-specific init
117 ; ### consider making a plain effect
118 lda mixer.tonals.square.duty_ctrl
,x
121 sta mixer.tonals.square.duty
,x
124 sta mixer.tonals.square.counter
,x
130 cmp mixer.tonals.period_index
,x
; CF = slide direction (0=down,1=up)
131 sta mixer.tonals.period_index
,x
133 lda period_table_lo
,y
134 sta mixer.tonals.effect.portamento.target.lo
,x
135 lda period_table_hi
,y
136 sta mixer.tonals.effect.portamento.target.hi
,x
139 rol ; bit 0 = slide direction
140 sta mixer.tonals.effect.portamento.ctrl
,x
144 ; Processes a channel command.
150 TC_SLOT set_mastervol
158 jsr fetch_pattern_byte
159 sta mixer.tonals.instrument
,x
162 asl
; each instrument is 8 bytes long
164 lda
[instrument_table
],y
165 sta mixer.envelopes.
ptr.lo
,x
167 lda
[instrument_table
],y
168 sta mixer.envelopes.
ptr.hi
,x
170 lda
[instrument_table
],y
171 sta mixer.tonals.effect.vibrato.delay
,x
173 lda
[instrument_table
],y
174 sta mixer.tonals.effect.kind
,x
176 lda
[instrument_table
],y
177 sta mixer.tonals.effect.slide.amount
,x
179 lda
[instrument_table
],y
180 sta mixer.tonals.square.duty_ctrl
,x
; this is a union
184 ; Disables volume envelope looping.
188 sta mixer.envelopes.hold
,x
192 ; Sets the envelope master volume.
195 jsr fetch_pattern_byte
196 ora #
1 ; indicates that volume was explicitly set
197 sta mixer.envelopes.master
,x
202 jsr fetch_pattern_byte
207 jsr set_all_tracks_speed
212 ; this command is used when there is no note for the row, only commands
214 lda mixer.envelopes.master
,x
216 sta mixer.envelopes.master
,x