static uint32_t lfsr=1; // seed unknown, must be non-zero
SAA1099P noise generator as documented by Jepael
18-bit Galois LFSR
Feedback polynomial = x^18 + x^11 + x^1
Period = 2^18-1 = 262143 bits
Verified to match recorded noise from my SAA1099P
OPLx wrote:Pretty interesting findings! If you have a chance, would you mind elaborating how the undocumented noise at higher frequencies is triggered? I'm only familiar with setting the noise generator control to 0x03 (for generator 0) at address 0x16 to drive the frequencies higher.
Jepael wrote:Thanks, sure thing.
Hmm, I think you can only get lower frequencies than the three presets when the noise is clocked by tone generator.
Fixed rates for clocking the noisegen are X=27965 Hz, X/2, and X/4, while with a tone generator clocking it you can get up to about X/2 maximum as well.
The trick is to set the tone generator reset bit while the tone generator is used to clock the noise.
Apparently that makes the noisegen to be clocked by the undivided octave clock, so lowest octave 0 is same as rate X. And each octave higher doubles the noise frequency. You can't hear much at the highest octaves though, as they are beyond human hearing range
But the downside is, you can't generate any tones when the tonegens are in reset, so it's not a very useful trick.
Lord Nightmare wrote:Jepael: I updated the saa1099 core in MAME to use the correct lfsr polynomial: https://github.com/mamedev/mame/commit/ ... 8ba31786f8
I also added a note about the fact that if the noise channels are set to be clocked by a tone channel, and the 0x1c bit 1 reset bit is set, they get clocked by the undivided octave clocks, but I did not implement this yet.
Are there any other obvious issues I should try to fix from elsewhere in this thread?
superfury wrote:Anyone can see what's going wrong? Why are the tones higher than it's supposed to be?
superfury wrote:I've tried to implement all but that latest post(about tone/noise off/on states, which will be using PWM). I remember it was originally based on Dosbox, but looking at Lord Nightmare's commit and saa1099.cpp code, it seems that either Dosbox uses the same codebase or I've based mine off mame's. Can't remember though(many years ago, before moving to bitbucket and starting to use git).
Stiletto wrote:Yes, DOSBox's code for SAA1099 was based off MAME's.
Don't worry, that code was relicensed in MAME as being licensed under the 3-clause BSD license as of March 30, 2016. Prior to that, DOSBox wasn't following our license.
//Load test wave information for generating samples!
GAMEBLASTER.chips.squarewave.timeout = (uint_32)(__GAMEBLASTER_BASERATE/(double)(500.0f*2.0f)); //New timeout!
GAMEBLASTER.chips.squarewave.timepoint = 0; //Reset!
GAMEBLASTER.chips.squarewave.freq = 500.0f; //We're updated!
testoutput = createWAV("captures/testgameblaster500hz.wav",1,(uint_32)__GAMEBLASTER_BASERATE); //Start the log!
for (i=0;i<__GAMEBLASTER_BASERATE;++i) //Generate one second of data!
signal = getSAA1099SquareWave(&GAMEBLASTER.chips,7);
writeWAVMonoSample(testoutput,signed2unsigned16(signal?(sword)32767:(sword)-32768)); //Write a sample!
closeWAV(&testoutput); //Close the wave file!
Users browsing this forum: No registered users and 1 guest