mirror of
https://github.com/holub/mame
synced 2025-04-20 15:32:45 +03:00
saa1099.cpp: Use the correct LFSR polynomial for the SAA1099 noise generation, and add some notes about an unemulated undocumented feature of the noise clock. [Jepael, Lord Nightmare]
This commit is contained in:
parent
0e73860daa
commit
c11c22b3e8
@ -221,7 +221,7 @@ void saa1099_device::sound_stream_update(sound_stream &stream, stream_sample_t *
|
||||
case 0: m_noise[ch].freq = m_master_clock/256.0 * 2; break;
|
||||
case 1: m_noise[ch].freq = m_master_clock/512.0 * 2; break;
|
||||
case 2: m_noise[ch].freq = m_master_clock/1024.0 * 2; break;
|
||||
case 3: m_noise[ch].freq = m_channels[ch * 3].freq; break;
|
||||
case 3: m_noise[ch].freq = m_channels[ch * 3].freq; break; // todo: this case will be m_master_clock/[ch*3's octave divisor, 0 is = 256*2, higher numbers are higher] * 2 if the tone generator phase reset bit (0x1c bit 1) is set.
|
||||
}
|
||||
}
|
||||
|
||||
@ -280,12 +280,14 @@ void saa1099_device::sound_stream_update(sound_stream &stream, stream_sample_t *
|
||||
|
||||
for (ch = 0; ch < 2; ch++)
|
||||
{
|
||||
/* check the actual position in noise generator */
|
||||
/* update the state of the noise generator
|
||||
* polynomial is x^18 + x^11 + x (i.e. 0x20400) and is a plain XOR, initial state is probably all 1s
|
||||
* see http://www.vogons.org/viewtopic.php?f=9&t=51695 */
|
||||
m_noise[ch].counter -= m_noise[ch].freq;
|
||||
while (m_noise[ch].counter < 0)
|
||||
{
|
||||
m_noise[ch].counter += m_sample_rate;
|
||||
if( ((m_noise[ch].level & 0x4000) == 0) == ((m_noise[ch].level & 0x0040) == 0) )
|
||||
if( ((m_noise[ch].level & 0x20000) == 0) != ((m_noise[ch].level & 0x0400) == 0) )
|
||||
m_noise[ch].level = (m_noise[ch].level << 1) | 1;
|
||||
else
|
||||
m_noise[ch].level <<= 1;
|
||||
|
@ -56,12 +56,12 @@ struct saa1099_noise
|
||||
saa1099_noise() :
|
||||
counter(0.0),
|
||||
freq(0.0),
|
||||
level(0) {}
|
||||
level(0xFFFFFFFF) {}
|
||||
|
||||
/* vars to simulate the noise generator output */
|
||||
double counter;
|
||||
double freq;
|
||||
int level; /* noise polynomial shifter */
|
||||
uint32_t level; /* noise polynomial shifter */
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user