|
A restatement of $4017 behavior from scratch seems the best approach here.
When $4017 is written with $00 or $40, the 4-step looping sequence is used. There is a 1/240 second delay before the first step of the sequence occurs, and a 1/240 second delay between each step.
step 1: clock envelopes and triangle's linear counter step 2: clock envelopes, triangle's linear counter, length counters and sweep units step 3: clock envelopes and triangle's linear counter step 4: clock envelopes, triangle's linear counter, length counters and sweep units, and set interrupt flag step 1: ...
Thus, the envelopes and triangle's linear counter are clocked at 240 Hz, the length counters and sweep units at 120 Hz, and the interrupt flag is set every 1/60 second.
When $4017 is written with $80 or $c0, the 5-step looping sequence is used. The first step of the sequence occurs immediately, with 1/240 second delay between each step.
step 1: clock envelopes, triangle's linear counter, length counters and sweep units step 2: clock envelopes and triangle's linear counter step 3: clock envelopes, triangle's linear counter, length counters and sweep units step 4: clock envelopes and triangle's linear counter step 5: do nothing step 1: ...
Thus, the envelopes and triangle's linear counter are clocked 4 times every 5/240 second, which amounts to 192 Hz with uneven timing. The length counters and sweep units are clocked 2 times every 5/240 second, which amounts to 96 Hz with uneven timing. The interrupt flag is never set in this mode.
I'll have to add this to the things to rewrite whenever I make an update to the APU reference.
Reply if you have any further questions based on the above description.
|