Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements several improvements on the mos6561 VIC chip as noted in #26 :
4 bit DAC: by quickly changing the volume register, the VIC-20 can do a 4-bit digital audio. The change I made was simply to output the value
0.5f
when a voice channel is silent (before it was0.0f
). The 0.5 value is what allows the volume register to "modulate" the output and produce a digital waveform.viznut waveforms: the sound generators produce their square waves not by a simple bit flipping, but via an internal 8 bit shift register with feedback. As discovered by viznut/pwp, loading certain values on such register allows the creation of square waveforms whose duty cycles varies according to certain patterns. In this PR I've created that shift register (
voice->sreg
andnoise->sreg
)noise generator: this PR implements correctly the noise generator as discovered by Lance Ewing from his reverse engineering work on the die shot of the chip. There is a 16 bit LFSR that in turn drives the shifting of
noise->sreg
at the positive edge of LSFR's bit 0.counter bug: the frequency counting was not correctly implemented:
POKE 36874, 255
was higher in pitch thanPOKE 36874, 254
differently from a real VIC-20. I fixed the counters, and also changed them to increment instead of decrement as in the real chip. I also introduced adivider_counter
to properly drive the counting.float output
: the channels now have anoutput
field that stores the current output value so that it's not recalculated at each tick but only when the voice output changes.