Interpreting the position of the proportional controller normally requires
some preliminary work during the vertical blanking interval.
During vertical blanking , you write a value into an address called
potgo . for a standard x-y joystick, this value is hex 0001. writing to
this register starts the operation of some special hardware that reads the
potentiometer values and sets the values contained in the pot registers
(described below) to zero.
The read circuitry stays in a reset state for the first seven or eight
horizontal video scan lines. Following the reset interval, the circuit
allows a charge to begin building up on a timing capacitor whose charge
rate will be controlled by the position of the external controller
resistance. For each horizontal scan line thereafter, the circuit compares
the charge on the timing capacitor to a preset value. If the charge is
below the preset, the pot counter is incremented. if the charge is above
the preset, the counter value will be held until the next potgo is
issued.
figure 8-5: effects of resistance on charging rate
You normally issue potgo at the beginning of a video screen, then read
the values in the pot registers during the next vertical blanking
period, just before issuing potgo again.
Nothing in the system prevents the counters from overflowing (wrapping
past a count of 255). However, the system is designed to insure that the
counter cannot overflow within the span of a single screen. This allows
you to know for certain whether an overflow is indicated by the controller.