c6280.cpp : Add LFO, Add notes (#3380)

* c6280.cpp : Add LFO, Add notes

* c6280.cpp : Fix channel check when lfo is enable
This commit is contained in:
cam900 2018-04-27 10:34:36 +09:00 committed by R. Belmont
parent 88b77caea7
commit 127c21d541

View File

@ -22,7 +22,7 @@
Missing features / things to do:
- Add LFO support. But do any games actually use it?
- Verify LFO frequency from real hardware.
- Add shared index for waveform playback and sample writes. Almost every
game will reset the index prior to playback so this isn't an issue.
@ -114,18 +114,48 @@ void c6280_device::sound_stream_update(sound_stream &stream, stream_sample_t **i
}
else
{
/* Waveform mode */
uint32_t step = m_wave_freq_tab[m_channel[ch].m_frequency];
for (int i = 0; i < samples; i += 1)
if ((m_lfo_control & 0x80) && (ch < 2))
{
int offset;
int16_t data;
offset = (m_channel[ch].m_counter >> 12) & 0x1F;
m_channel[ch].m_counter += step;
m_channel[ch].m_counter &= 0x1FFFF;
data = m_channel[ch].m_waveform[offset];
outputs[0][i] += (int16_t)(vll * (data - 16));
outputs[1][i] += (int16_t)(vlr * (data - 16));
if (ch == 0) // CH 0 only, CH 1 is muted
{
/* Waveform mode with LFO */
uint32_t step = m_channel[0].m_frequency;
uint16_t lfo_step = m_channel[1].m_frequency;
for (int i = 0; i < samples; i += 1)
{
int offset, lfooffset;
int16_t data, lfo_data;
lfooffset = (m_channel[1].m_counter >> 12) & 0x1F;
m_channel[1].m_counter += m_wave_freq_tab[(lfo_step * m_lfo_frequency) & 0xfff]; // TODO : multiply? verify this from real hardware.
m_channel[1].m_counter &= 0x1FFFF;
lfo_data = m_channel[1].m_waveform[lfooffset];
if (m_lfo_control & 3)
step += ((lfo_data - 16) << ((m_lfo_control-1)+1)); // verified from patent, TODO : same in real hardware?
offset = (m_channel[0].m_counter >> 12) & 0x1F;
m_channel[0].m_counter += m_wave_freq_tab[step & 0xfff];
m_channel[0].m_counter &= 0x1FFFF;
data = m_channel[0].m_waveform[offset];
outputs[0][i] += (int16_t)(vll * (data - 16));
outputs[1][i] += (int16_t)(vlr * (data - 16));
}
}
}
else
{
/* Waveform mode */
uint32_t step = m_wave_freq_tab[m_channel[ch].m_frequency];
for (int i = 0; i < samples; i += 1)
{
int offset;
int16_t data;
offset = (m_channel[ch].m_counter >> 12) & 0x1F;
m_channel[ch].m_counter += step;
m_channel[ch].m_counter &= 0x1FFFF;
data = m_channel[ch].m_waveform[offset];
outputs[0][i] += (int16_t)(vll * (data - 16));
outputs[1][i] += (int16_t)(vlr * (data - 16));
}
}
}
}