How I recorded and decoded POKEY's polynomial counters;Open Pokey Recipe for the curious


This is a "reprint" of the comments inside "POKEY.sfz", the chipsounds POKEY configuration file. (the original date is March 2009)


Was I naive to think that POKEY was just "another TIA", and I spent enough evenings to regret it. Making the breadboard and having Pokey spew some tones was the easy part, but soon realized that various frequencies gave me different patterns (sometimes after retriggereing the SAME note!)

So I tried many things, recorded GB's of tests and had a few ideas.

After lots of trials and loss of sanity:
Here is the FINAL methodology that I used to get usable data:

A)Clock a POKEY with a VERY SLOW clock (I used a +- 10Khz 50/50 PWM signal from a PIC)

B)Set Bit 6 of AUDC1 ( "1.79Mhz" or cpu clock)

C)Play the highest notes you can for each pattern: AUDF1=0 then AUDF1=1, (...), AUDF1=4

D)Record each bit pattern and pass it through our patternfinder util.

Now since the results are NOT the source pattern, but a "resampled" pattern made after skipping 4+AUDF source pulses for each destination pulse (according to the POKEY spec's "MODIFIED FORMULA"), we must derive the actual SOURCE pattern from the results.

The trivial thing to try is this:

void Shuffler(const char*in, char*out, size_t len, size_t shufsize){

size_t cnt=0;
(size_t i=0;i<len;++i){

out[i] = in[cnt];

cnt = cnt % len;

In this case my recorded AUDF1=0's 4, 9 and 17 bit patterns gave the exact same results as source OR destination (with added offset before looping of course), which kinda proves that AUDF1=0 can give you the full pattern, and that there is magic somewhere (try that with any other random bit pattern for fun). With this source pattern I was able to verify my own "software resampling" using AUDF1=1,2,3... and so forth from my recordings for a match.

4bit poly: 000011101100101

However, and that's where the fun ends, the 5bit pattern was a pain. Patternfinder kept giving me a 62 bit long repeated pattern:


and NOT a 31 bit pattern like I expected!

I noticed that the former 31 bit half of that pattern was always the inverse of the later (whatever point at which you start).A "hint" that the results im getting use some form of inversion. Schematics show that the source pattern passes through the same circuit logic as the "plain square" so it is used as a "please invert previous bit" matrix

SO: Inverting THAT pattern (fill/skip_4 a 31 bit pattern) gave me the following from my 62 pattern: "1101001100000111001000101011110". Which, as with the 4,9,17 case was used to test for the generation of AUDF1=1 and other frequencies.

chipsounds specific:

A few unique oscillators have been made just for this chip.
One and Two Stream AND-ers and One Stream Differentiators were required to emulate the inner process of the POKEY chip.

Invaluable help from "DeRe Atari Chapter 7", and from the official specs.
And for the various Pinouts/Skematics found online.


  1. I think I still have my copy of De Re Atari. What a great manual that was!

  2. I find your approach inspiring! Thanks for posting :)

  3. Thanks Seb!

    In fact kevtris thought I did that all for nothing when the full schematics are available for the POKEY, but I'm never satisfied with them anyway :)


Post a Comment