Mercurial > repos > blastem
comparison ym_common.c @ 2565:eb588f22ec76
More work on OPL3 emulation
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 26 Jan 2025 23:32:40 -0800 |
parents | 3f58fec775df |
children |
comparison
equal
deleted
inserted
replaced
2564:553a0b4888db | 2565:eb588f22ec76 |
---|---|
189 } | 189 } |
190 break; | 190 break; |
191 } | 191 } |
192 return output; | 192 return output; |
193 } | 193 } |
194 | |
195 void start_envelope(ym_operator *op, ym_channel *channel) | |
196 { | |
197 //Deal with "infinite" attack rates | |
198 uint8_t rate = op->rates[PHASE_ATTACK]; | |
199 if (rate) { | |
200 uint8_t ks = channel->keycode >> op->key_scaling;; | |
201 rate = rate*2 + ks; | |
202 } | |
203 if (rate >= 62) { | |
204 op->env_phase = PHASE_DECAY; | |
205 op->envelope = 0; | |
206 } else { | |
207 op->env_phase = PHASE_ATTACK; | |
208 } | |
209 } | |
210 | |
211 void keyon(ym_operator *op, ym_channel *channel) | |
212 { | |
213 start_envelope(op, channel); | |
214 op->phase_counter = 0; | |
215 op->inverted = op->ssg & SSG_INVERT; | |
216 } | |
217 | |
218 void keyoff(ym_operator *op) | |
219 { | |
220 op->env_phase = PHASE_RELEASE; | |
221 if (op->inverted) { | |
222 //Nemesis says the inversion state doesn't change here, but I don't see how that is observable either way | |
223 op->inverted = 0; | |
224 op->envelope = (SSG_CENTER - op->envelope) & MAX_ENVELOPE; | |
225 } | |
226 } |