So the APU clock rate is half the CPU clock rate. But as an additional punch in the balls, the Triangle uses the CPU clock rate instead of the APU. And the frame sequencer uses "half cycles" so conceptually it might as well just use the CPU clock rate as well.
Additionally... the channel period is actually 1+ whatever is written due to the way the counter wraps.
This is all leading to some confusion for me on how DMC and Noise are clocked. The wiki is woefully unclear, so hopefully someone here can clarify:
Since the frame sequencer clocks are outlined on the wiki in the form of "time stamps" and not really periods, I am reasonably sure there isn't a +1. Though I use *2 to convert to CPU cycles so I don't have to deal with half cycles.
Where my confusion comes in is with Noise/DMC. Those values are read from a table and are not used "as written" like Pulse/Tri are.... so would they still have the +1?
EDIT:
Ugh... also I just double-checked the DMC page on the wiki and it says the table numbers are in CPU cycles.... so is the DMC clocked by the CPU clock as well?
Is there ANY point to tracking APU cycles other than dividing the pulse clocks in half?
EDIT 2:
But the DMC wiki does say the table is the number of cycles between clocks... so I guess that answers the question for the DMC. Noise is still unclear, though.
EDIT 3:
So I checked an old emu source and it looks like the Noise numbers on the wiki are in CPU cycles.....
.... so APU cycles are pretty much entirely worthless. I'm saying "screw it" and doing everything in CPU cycles.
Here's a new table to show what I'm doing. If there's a mistake here, please let me know. Also clarification as to whether or not there's a +1 (or +2) to the noise period is still welcome/desired. I'm going to assume it's the same as the DMC and there is no +1.
Additionally... the channel period is actually 1+ whatever is written due to the way the counter wraps.
This is all leading to some confusion for me on how DMC and Noise are clocked. The wiki is woefully unclear, so hopefully someone here can clarify:
Code:
Unit Clock rate Period
-------------------------------------------------------------------
FRAME SEQUENCER: CPU 2 * value as shown on wiki
PULSE: APU 1 + value written
TRIANGLE: CPU 1 + value written
NOISE: APU ??? value from table (+1 or not?)
DMC: CPU value from table
-------------------------------------------------------------------
FRAME SEQUENCER: CPU 2 * value as shown on wiki
PULSE: APU 1 + value written
TRIANGLE: CPU 1 + value written
NOISE: APU ??? value from table (+1 or not?)
DMC: CPU value from table
Since the frame sequencer clocks are outlined on the wiki in the form of "time stamps" and not really periods, I am reasonably sure there isn't a +1. Though I use *2 to convert to CPU cycles so I don't have to deal with half cycles.
Where my confusion comes in is with Noise
EDIT:
Ugh... also I just double-checked the DMC page on the wiki and it says the table numbers are in CPU cycles.... so is the DMC clocked by the CPU clock as well?
Is there ANY point to tracking APU cycles other than dividing the pulse clocks in half?
EDIT 2:
But the DMC wiki does say the table is the number of cycles between clocks... so I guess that answers the question for the DMC. Noise is still unclear, though.
EDIT 3:
So I checked an old emu source and it looks like the Noise numbers on the wiki are in CPU cycles.....
.... so APU cycles are pretty much entirely worthless. I'm saying "screw it" and doing everything in CPU cycles.
Here's a new table to show what I'm doing. If there's a mistake here, please let me know. Also clarification as to whether or not there's a +1 (or +2) to the noise period is still welcome/desired. I'm going to assume it's the same as the DMC and there is no +1.
Code:
Unit Clock rate Period
-------------------------------------------------------------------
FRAME SEQUENCER: CPU 2 * value as shown on wiki (conceptually)
PULSE: CPU 2 * value written + 2
TRIANGLE: CPU value written + 1
NOISE: CPU value from table + ? (I assume +0, but could be +1 or +2?)
DMC: CPU value from table
-------------------------------------------------------------------
FRAME SEQUENCER: CPU 2 * value as shown on wiki (conceptually)
PULSE: CPU 2 * value written + 2
TRIANGLE: CPU value written + 1
NOISE: CPU value from table + ? (I assume +0, but could be +1 or +2?)
DMC: CPU value from table