diff --git a/src/devices/sound/c6280.cpp b/src/devices/sound/c6280.cpp index 1cae1437d49..8a72c691a3e 100644 --- a/src/devices/sound/c6280.cpp +++ b/src/devices/sound/c6280.cpp @@ -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)); + } } } }