I have added some simple tone generation so I can get some beeps out of the games I am developing and porting, but I don’t really understand audio enough to properly emulate the rather simple TIA audio,
I have just done square wave tones of approximately the right frequency, but with no volume control.
I don’t really know how to do the audio volume, how to get a purer tone, and how to do the other waveforms which are described as:
D3 D2 D1 D0 Type of noise or
0 0 0 0 set to 1
0 0 0 1 4 bit poly
0 0 1 0 div 15 -> 4 bit poly
0 0 1 1 5 bit poly -> 4 bit poly
0 1 0 0 div 2 : pure tone
0 1 0 1 div 2 : pure tone
0 1 1 0 div 31 : pure tone
0 1 1 1 5 bit poly -> div 2
1 0 0 0 9 bit poly (white noise)
1 0 0 1 5 bit poly
1 0 1 0 div 31 : pure tone
1 0 1 1 set last 4 bits to 1
1 1 0 0 div 6 : pure tone
1 1 0 1 div 6 : pure tone
1 1 1 0 div 93 : pure tone
1 1 1 1 5 bit poly div 6
I have currently just implemented the ones that say pure tone.
I could probably work out how to do the volume control but as the volume on my earphones is very low anyway, and if I use a powered speaker, it has a volume control, I am not sure how useful that is.
The outputs that are not pure tones need some sort of waveform output, but I am not sure what waveform those descriptions like “set to 1”, “set last 4 bits”, “4-bit poly”, “div 15 -> 4 bit poly” etc. correspond to.
Presumably the tone output would be purer if I used a triangle wave rather than the square wave I am currently using.
I’ve done a little bit of digging. That stella pdf you listed above unfortunately falls short of the kind of details required to implement things, but, there are some other kind people on the interwebs who’ve helped fill in a few more of the details:
… and then, because nothing’s ever as easy as it seems at first glance, there’s some additional information about non-linearities in the volume scaling here:
It looks like basically there are a few different shift registers, some frequency scalers, and a mechanism for combining the outputs together. It should be fairly straightforward to make something like that, but the devil is in the details. For example, I’m not sure what the polynomials are that the shift registers are using, and it’s hard to find documented details anywhere.
Ultimately it might be easiest to look at the schematics - for example available on pages like this:
… and figure out how things are working from there… ?? or maybe find another verilog implementation somewhere?
… I’m looking around as I’m typing this and found a VHDL implementation - this might be a good starting point as they seem to have got the shift registers figured out at least…
I had seen that VHDL implementation and mentioned it in the top post. But I have never looked at it much as I have never learnt VHDL and don’t find it that easy to read and understand. (But I haven’t really tried).
I did not need to look at the VHDL implementation for what I have done so far as the spec is good enough to implement from and the LCD rather than VGA makes our implementation a bit different.
But it looks like I do need to look at it for the audio.
A surprising amount of Pitfall and Adventure seems to be working. Nothing is quite right due to the horizontal timing being wrong, but most of the graphics is there. It might be possible to modify the kernal code to make the games work with this version.
Here is the first screen of Adventure with the portcullis jumped to one side and the key gone missing:
Different games will need different key mappings as some use the fire button on the joysticks, and some use the select, start and reset buttons that were on the Atari 2600 console. Others use two joysticks. There were also some console switches for things like difficulty and black-and-white mode.