ay8910.cpp: Fix noise rate regression (#7283)

This commit is contained in:
cam900 2020-09-24 18:50:09 +09:00 committed by GitHub
parent 210d93e33f
commit cfa4fa4ae4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 4 deletions

View File

@ -1125,8 +1125,9 @@ void ay8910_device::sound_stream_update(sound_stream &stream, std::vector<read_s
* channels. * channels.
*/ */
m_count_noise = 0; m_count_noise = 0;
m_prescale_noise ^= 1;
if (!m_prescale_noise) if (!m_prescale_noise || is_expanded_mode()) // AY8930 noise generator rate is twice compares as compatibility mode
{ {
/* The Random Number Generator of the 8910 is a 17-bit shift */ /* The Random Number Generator of the 8910 is a 17-bit shift */
/* register. The input to the shift register is bit0 XOR bit3 */ /* register. The input to the shift register is bit0 XOR bit3 */
@ -1135,9 +1136,7 @@ void ay8910_device::sound_stream_update(sound_stream &stream, std::vector<read_s
// TODO : get actually algorithm for AY8930 // TODO : get actually algorithm for AY8930
m_rng ^= (((m_rng & 1) ^ ((m_rng >> 3) & 1)) << 17); m_rng ^= (((m_rng & 1) ^ ((m_rng >> 3) & 1)) << 17);
m_rng >>= 1; m_rng >>= 1;
m_prescale_noise = 1;
} }
m_prescale_noise--;
} }
for (int chan = 0; chan < NUM_CHANNELS; chan++) for (int chan = 0; chan < NUM_CHANNELS; chan++)

View File

@ -268,7 +268,7 @@ private:
inline u8 get_envelope_chan(int chan) { return is_expanded_mode() ? chan : 0; } inline u8 get_envelope_chan(int chan) { return is_expanded_mode() ? chan : 0; }
inline bool noise_enable(int chan) { return BIT(m_regs[AY_ENABLE], 3 + chan); } inline bool noise_enable(int chan) { return BIT(m_regs[AY_ENABLE], 3 + chan); }
inline u8 noise_period() { return is_expanded_mode() ? m_regs[AY_NOISEPER] & 0xff : (m_regs[AY_NOISEPER] & 0x1f) << 1; } inline u8 noise_period() { return is_expanded_mode() ? m_regs[AY_NOISEPER] & 0xff : m_regs[AY_NOISEPER] & 0x1f; }
inline u8 noise_output() { return m_rng & 1; } inline u8 noise_output() { return m_rng & 1; }
inline bool is_expanded_mode() { return ((m_feature & PSG_HAS_EXPANDED_MODE) && ((m_mode & 0xe) == 0xa)); } inline bool is_expanded_mode() { return ((m_feature & PSG_HAS_EXPANDED_MODE) && ((m_mode & 0xe) == 0xa)); }