"Have you ever wondered how and why something works?" This question
has been asked by countless books and magazines, mostly as a lead for
them to tell you just How and Why. That question is a little lengthy. "Have
you ever wondered why, when you use the BASIC function STICK (0), that it
doesn't return nice numbers such as 0=LEFT, 2=RIGHT, etc., but instead gives you
weird numbers like 15=NOTHING, 11=LEFT, 7=RIGHT, etc.?".
Now
that I've done my "Andy Rooney talking about his ties" imitation, it
is time to switch scenes again. "Hey Ma! My joystick is BROKE! You'll have
to buy me another one!", the little boy said. "That's the third one
that you've broken. You'll just have to wait till I can get to the store next
week.", was his mother's reply. This, for the little boy, just would not
do. He was very involved in a game of Missile Command (tm) and had already
accumulated well over one hundred and twenty thousand points and would probably
die of old age by next week anyway. Maybe the joystick could be repaired? There
was nothing to loose. He just had to find out.
Did
you ever wonder what is in a joystick? Did you ever wonder how a joystick works?
Did you ever wonder why they call it a joystick? Ever wonder how the little boy
broke all three of his joysticks or why his mother has put up with him for so
long? And did you ever wonder why I am constantly saying "Did you ever
wonder"?
A
joystick is a very simple device. After removing four screws and taking the
bottom Off, one finds only a few plastic parts, some wires, and a circuit board
containing push button switches. A Joystick is just five switches and a
connecting stick. So where do the funny numbers for up, down, left, and right
come from? Well, I am going to tell you all about it. Atari joysticks are
connected into the computer by a parallel input port. This means that when your
program reads information from this parallel port, there is one bit for each
switch. The lowest most significant bit (we will call it bit -0" since
numbering systems using computers start counting with the number "0")
senses the upward push on a joystick. The following table shows the other bit
positions.
Now,
the nibble or four bit subbyte, is not the value returned by the joystick ports.
The value returned is the inverse of the values shown in the previous table. The
correct values are shown in the next table.
The
inverse bit values you receive from the joystick ports are due to the way the
joysticks themselves are wired. The switch contacts are connected to the port
lines with pull-up resistors. These resistors apply a constant 05 volts signal
to the lines
forcing the logic to a high level. When you push on the joystick, the switch or
switches (in a diagonal position) close and bring the signal from 05 volts to 0
volts, bringing the logic at the port to a low logic level. The bit read from
its corresponding switch is changed from a logic 1 to 0. All we need now is a
demonstration in machine language.
Enough
About joysticks
MAPWARE,
written by Harry C. Koons, is on( of the more interesting programs to come out
of APX (Atari Program Exchange). Using this program, it is possible to generate
maps of any section of the earth. The software is written it BASIC and is
distributed on two diskettes. The first disk contains programs to generate maps
using different projection methods and a program to display a previously
generated and stored map. The second disk contains the coordinate data of ever,
important land feature in the world. This disk contains over 640 blocks of
information, which translates to over 80 thousand characters of information. It
even generates the U.S. state boundaries. Since the programs are written in
BASIC, they tend to be on the slow side, usually taking from ten to twenty
minutes to generate a map but the results are well worth it. I strongly
recommend this package to anyone with a 401 system.
Now,
what does this program have to do with joysticks, you might be wondering. What
can a joystick do
to a stationary map? Believe me, these maps won't be stationary for very long!
You've
all seen scrolling. It happens every time you enter a line in a BASIC program
with a full screen. The lines of text before it all move up when you hit RETURN.
This is known as coarse vertical scrolling. Also , coarse horizontal scrolling.
You usually see this when editing text, especially when characters are inserted
or deleted in the middle of line. The rest of the text moves sideways. We have a
seen this happen. It's really no big deal.
What
you may not know is that the ATARI computer has the ability to FINE scroll
vertically and horizontally. Characters and pictures can be moved up and down in
increments of one scan line on the television set. They can also be moved left
an right in increments of one color clock (the width of point in graphics mode 6
or 7). All this power is hidden in your machine, and you probably never know it
unless you played such games as Atari' SPACE INVADERS (horizontal scrolling) or
ANALOG SOFTWARE's Race In Space (vertical scrolling). We, using our map and out
joystick at going to do both!
Now,
it really does not have to be a map. You can use any picture that was drawn in
full screen graphics