I compared the two pieces of code (our VICE mod and
@phvic's) and as far as I can tell they are equivalent.
In VICE, the frequency counter do count backwards, so the check is against 0:
Code: Select all
snd.ch[j].ctr--;
if (snd.ch[j].ctr <= 0) {
the 255-low frequency case is achieved by
Code: Select all
int a = (~snd.ch[j].reg) & 127;
a = a ? a : 128;
(when it's 0 the speed becomes 128, the slowest).
Another difference is that in VICE's code the normal shift register is flipped (MSB<->LSB) respect to @phvic's code, but from what I can see, they are equivalent.
BTW, in
@phvic I don't get why there is "& osc->freq" ... shouldn't it be "& (osc->freq >> 7)" ?
Code: Select all
osc->shift_reg = (osc->shift_reg >> 1) | ((!(osc->shift_reg & 1) << 7) & osc->freq);
^
Other than that I have no clue why the implementation in VICE isn't working as expected.
@phvic, the waveform of the noise generator was already known to be a square wave and indeed someone else did use a scope before (check a thread named "DC offset" it's very interesting). What was not known was the way the frequency was made random.
BTW do you have a good recording of a real VIC playing noise? I would like to test the accuracy of our model, seeing when the waveform loops over the same values. I would record it myself, but my CRT display does not have an audio output (earphones or whatever).
P.S. where do I get your emulator?