[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Game port
Frank Carney writes ...
>>
Questions:
[1] How do I tell if a button has been pressed?
[2] Is the port grounded by a switch when it is pressed?
[3] Can a TTL signal be accurately read from this port?
Thanks in advance.
P.S. Please do not respond to ask what I am doing. It is a surprise and
will be announced later. Thankyou.
<<
and
>
> Made a mistake that may have misslead people. I am not talking about
> AN0-AN3. I am talking about PB0-PB2. Sorry for the mistake.
....
>[1] How do I tell if a button has been pressed?
For buttons 0-2 (sometimes labeled 1-3), you can look at
$C061-$C063 respectively-- e.g. AD 61 C0 in machine code. If bit 7 is a
"1", the corresponding button is pressed*.
In BASIC, you can do something like* ...
200 If PEEK(49249) > 127 then PRINT "BUTTON 0 IS PRESSED!"
210 If PEEK(49250) > 127 then PRINT "BUTTON 1 IS PRESSED!"
220 If PEEK(49251) > 127 then PRINT "BUTTON 2 IS PRESSED!"
*Note: These examples assume that a joystick, etc. is connected. With no
connection to a switch input, the default condition is a "1" at bit 7.
[2] Is the port grounded by a switch when it is pressed?
No. It is connected to +5V.
On the Apple II stick (see below), each button switch goes to +5V.
The other end goes to GND through a resistor (one resistor for each
button). A button's Output is from the junction of the switch and its
resistor. When the button switch is not closed, its Output is near 0V
(=logic 0). Pressing a button sends +5V to the output (= logic 1).
+5V
|
|
X Button Switch
|
|_____Button output to Apple (Press => "1")
|
Z
Z 680 Ohm resistor
Z
|
GND
Again, the resistor for each button circuit (680 Ohms or so) is
inside the joystick.
Inside the Apple II you have just a wire going from the Game I/O
socket to a TTL or LSTTL IC's input (unless there is some "Shift Key
mod", etc. wired up). A TTL IC normally sees an open input as a "1".
[3] Can a TTL signal be accurately read from this port?
As long as some other circuit is not connected to a button input, a
TTL signal should be readable at a button input.
Rubywand