Read paddles in your spare time
Some gamers love paddles. And for some games, they can be the best form of control.Many 2600 programmers hate paddles. They're a pain in the tush to read, since the programmer has to observe, with about a scan line's precision, when the paddle input changes shape.Fortunately, it's possible to ease the requirements for reading paddles considerably if one uses a little trick: although many games reset the paddle timing circuit at the start or end of VSYNC or VBLANK, there is no requirement that the paddle reset occur at a fixed spot each frame. If a game has a certain area of the screen during which it can afford to read the paddles on every scan line, it may be possible to time the paddle reset to ensure that the paddles timeout within that region.For example, suppose a game has a loop that runs once every eight scan lines. It may be possible to code something like:
cpx paddlecoarse ; Assuming X is a down-counter lda #0 ; Not needed if accumulator bit 3 is guaranteed zero ror sta VBLANK
Eight or ten cycles. Comparable to the nine cycles required for a 'conventional' paddle-reading approach, but with a difference: the above code doesn't need to be run every scan line, but only every eighth.Later in the frame, it will be necessary to read the paddles every scan line, but if there are 32 consecutive scan lines where the paddles can be read, that will suffice. Take a reading to see when the paddle times out within that range (if it does). Add that reading to 8 times paddlecoarse and use that as the current paddle position. Then, if the last reading was within 10 of the end, increase paddlecoarse (so it should happen sooner next frame); if within 10 of the beginning, decrease paddlecoarse.The net effect will be that game can allow the user to move the paddle over a wide range with single-scan-line accuracy, but paddle overhead will be much lower than with conventional approaches.

0 Comments
Recommended Comments
There are no comments to display.