I was studying the audio frequency divider and got stumped by the details of the "up counter," so I took a break and started looking at other things in the schematics. It's fun now that I at least know enough to figure out some of the things that had puzzled me before.
I decided to start with VSYNC, since it's the first (i.e., lowest-numbered) register in the TIA. Of course, I already knew the gist of what VSYNC does. But it's nice to finally be able to decipher the details for myself. VSYNC affects only two things-- the COMP SYNC (CS) signal that's output through the [SYN] pin, and the COLOR BURST (CB) signal. In turn, VSYNC is affected by only one thing-- the HORIZONTAL SYNC (HS) signal. (Well, technically it's the CS signal that's affected, not the VS signal.) As long as VSYNC is turned off, the CS, HS, and CB signals operate normally. But when VSYNC is turned on, the CB signal is disabled, and the CS signal is inverted from its normal operation-- it will be turned off during the HS period, and turned on for the rest of the scan line. Also, the CB signal gets turned on automatically after the RHS (RESET HORIZONTAL SYNC) signal. So the two types of scan lines are as follows:
With VSYNC turned off:
CC 000 -- HBLANK gets turned on
CC 020 -- CSYNC (i.e., HSYNC) gets turned on
CC 036 -- CSYNC (HSYNC) gets turned off, and CBURST gets turned on
CC 052 -- CBURST gets turned off
CC 068 -- HBLANK gets turned off (assuming HMOVE isn't latched on)
With VSYNC turned on:
CC ??? -- CSYNC gets turned on (depending on when VSYNC is written to)
CC 020 -- CSYNC gets turned off
CC 036 -- CSYNC gets turned on again
Unlike a standard NTSC or PAL "VSYNC" line, the TIA's VSYNC line isn't in the form of a serrated pulse-- i.e., it isn't turned off briefly halfway through the line, but stays on during the entire line, except for the portion of the line when HSYNC would otherwise be on.
Getting back to the audio frequency divider, the bits of the AUDF0 (or AUDF1) register are inverted-- e.g., if you write %00111 to AUDF0, the bits will be stored in the register that way, but will be inverted before they're moved into the up counter, so the up counter will start at %11000 and count up from there. I think the signal coming out of the audio frequency divider will always be 0 if any of the counter's bits are 0, and then goes to 1 when the counter reaches %11111. When the output signal goes to 1, audio clock 2 will generate the tone clock 2 signal, then audio clock 1 will generate the tone clock 1 signal. Finally, the 1 is fed back into the audio frequency divider, resetting it back to the (inverted) starting value so the counter can start counting up again. At least, that's how I think it works.
For example, if you set AUDF0 to %00000, the up counter will be initialized to %11111, and will always output a 1, since it keeps getting reset to %11111.
If you set AUDF0 to %00001, the up counter will count from %11110 to %11111, then reset to %11110 and count up to %11111, so the output will be 0, 1, 0, 1, 0, 1, etc.
If you set AUDF0 to %00010, the up counter will count %11101, %11110, %11111, %11101, %11110, %11111, etc., outputting 0, 0, 1, 0, 0, 1, etc.
And so on and so forth.
The part I'm having trouble with is understanding the details of how each bit inside the up counter interacts with the other bits, as well as the details of how the bits are reset to their starting values. I mean, I see the lines connecting the bits, but that isn't the same thing as understanding what they're doing.
One thing that puzzles me is the line that goes into bit 0 of the up counter, which looks like it's connected to a ground (the circle with a plus inside it). Doesn't that mean the line will always be low (0)? The line goes into a NOR gate, but it also gets inverted and goes into another NOR gate just below the first one. So wouldn't the bottom NOR gate always output a 0? Then the output of the bottom NOR gate goes into the next bit of the up counter, and so on. So wouldn't the bottom NOR gate of each bit always output a 0? But if that's correct, then what's the point of having the feedback line go into the bottom NOR gate as well? Evidently I'm not understanding how that line works, and it's keeping me from understanding the rest of what's happening.
Michael
Edited by SeaGtGruff, Fri Jul 22, 2011 9:22 PM.