TANDY / RADIO SHACK COLOR COMPUTER
ANALOG / HIRES JOYSTICK INTERFACE
Tom Gunnison
© 1986, 1998, 2013
[email protected]
Revised October 2013
DISCLAIMER
These plans and software are provided "as is" with no guarantee of fitness for the purpose either
explicit or implied. I disclaim any responsibility for losses incurred through the use of these plans.
By using these plans you are deemed to have accepted these conditions of use.
Color Computer Analog / HIRES ADC Joystick Interface
INTRODUCTION
This project was conceived in the mid 1980's before there was a High Resolution Joystick
Interface available from Radio Shack. It may be useful not so much as a Joystick Interface, but
as a general purpose analog to digital converter for measurement and display.
The Analog / Hires ADC Joystick Interface provides for control of a cursor over the entire high
resolution graphics screen (PMODE 4), which has a resolution of 256 x 192 pixels.
A Color Computer Joystick is an analog device, whose output varies from 0 to 5 volts. There are
actually 3 measurements required (for a single-button joystick):
1. Horizontal Position
2. Vertical Position
3. Fire Button.
The button’s output is 5 volts when open, and 0 volts when pressed.
An Analog to Digital converter is required to convert the joystick voltages to a digital value for the
computer to read. The Color Computer contains a 6 bit Analog to Digital converter for the joystick
ports. With 6 bits, the maximum value is only 64 (2^6), thus the joysticks have a resolution of only
64 pixels. This is much to low for precision control in PMODE 4.
For greater control, an 8 bit Analog to Digital converter is required. Eight bits allow for a maximum
value of 256 (2^8), which is exactly the number of horizontal pixels in PMODE 4.
DETAILS
The Analog to Digital converter in this project is a National Semiconductor ADC0809. This chip
features 8 multiplexed analog inputs which may be read one at a time. The analog inputs are
configured as follows:
Input 1
Input 2
Input 3
Inputs 4-8
Horizontal Positioning ( X axis )
Vertical Positioning ( Y axis )
Fire Button
Not used, but could be used for a second stick or other analog signals.
The following is the schematic for the Analog / HIRES ADC Joystick Interface.
Page 2 of 9
Color Computer Analog / HIRES ADC Joystick Interface
Page 3 of 9
Color Computer Analog / HIRES ADC Joystick Interface
A plug in interface for bread boarding used to be available from Group Technology. Their board
plugs into the ROM cartridge port. It has all of the computer's address, data and control lines
brought out to bread boarding sockets which are clearly labeled. You can then run jumper wires
from the sockets to your own breadboard.
Another company, called Speech Systems used to carry a expansion board and case for the
CoCo.
I originally bread boarded the project using the Group Technology board. After testing, I wirewrapped it on a small perf board. I then enclosed the board in an old game cartridge I didn’t use
anymore.
I cut off the game cartridge’s circuit board and left the edge connector in the cartridge’s housing. I
then soldered the necessary connections to the fingers of the edge card connector. Finally I
mounted a 5-pin female DIN connector for the joystick to plug into on the side of the game
cartridge. I wired the connections from the DIN connector to the perf board.
The end result is a cartridge that looks like a normal game cartridge. It can be plugged into the
CoCo’s expansion connector, my 4-Slot Expansion Interface, or the Tandy MPI.
The following shows the completed cartridge:
Page 4 of 9
Color Computer Analog / HIRES ADC Joystick Interface
The following shows the interior of the Analog Interface:
PARTS LIST
The following is a parts list for the converter. Most of the parts can be purchased from electronics
mail order houses such as DigiKey.
1 - National ADC0809 analog to digital converter
1 - 74LS00 Quad 2 Input NAND Gate
1 - 74LS02 quad 2 Input NOR Gate
2 - 1K 1/4 watt resistors
1 - 10K 1/4 watt resistor
1 - 680 pf disc cap
2 - .05 uf disc caps
1 - .1 uf disc cap
1 – 5-pin female DIN Connector
1 – CoCo game cartridge that you can sacrifice
COCO JOYSTICK CONNECTORS
The Color Computer features two DIN-style joystick connectors, depending on the CoCo model -there are five pins for each connector on the CoCo 1 and 2 and six pins on the CoCo 3 as
described on the following page.
Page 5 of 9
Color Computer Analog / HIRES ADC Joystick Interface
CoCo 1 and 2 Joystick wiring to the 5-pin DIN connector is shown below:
On the CoCo3, an additional pin was added in the center of the DIN connector to provide for twobutton joysticks. Two-button Joystick wiring to the 6-pin DIN connector is shown below:
Because the orientation of pins 1-5 is the same as the CoCo 1 and 2 joystick connectors, singlebutton joysticks can also be used on the CoCo3.
Page 6 of 9
Color Computer Analog / HIRES ADC Joystick Interface
SOFTWARE
A machine language driver is used to read and return the Analog/ADC Joystick Interface’s values.
The Interface is setup as a memory mapped device, located at address's $FF40-$FF47, in the
following manner:
ADDRESS
$FF40
$FF41
$FF42
$FF43
$FF44
$FF45
$FF46
$FF47
INPUT
Analog input #1 ( horizontal)
Analog input #2 ( vertical )
Analog input #3 ( button )
Analog input #4 ( not used )
Analog input #5 ( not used )
Analog input #6 ( not used )
Analog input #7 ( not used )
Analog input #8 ( not used )
The machine language driver is called by the BASIC 'USR' call. An argument must be supplied
with the call, to tell the driver which input to read. By using the following statements from BASIC,
you may read the X, Y, and fire button status:
X = USR0(0)
Y = USR0(1)
B = USR0(2)
returns X location of joystick
returns Y location of joystick
returns fire button status (255 or 0)
The following is a listing of the driver in 6809 assembler language:
START
STA
DELAY
BSR
LDX
B,X
PSHS
LDX
LEAX
BNE
PULS
LDA
TFR
CLRA
JMP
END
$B3ED
#$FF40
X
#$48
-1,X
DELAY
X
B,X
A,B
$B4F4
TRANSFER USR ARG. TO D REGISTER
GET ADC BASE ADDRESS
START CONVERTER. B+X = INPUT TO CONVERT
SAVE X BEFORE USING IN DELAY LOOP
DELAY CONSTANT
WAIT FOR CONVERSION
RESTORE X
READ RESULT OF CONVERSION
PLACE RESULT IN LSB OF D REGISTER
CLEAR MSB OF D REGISTER
RETURN D REGISTER TO BASIC
Page 7 of 9
Color Computer Analog / HIRES ADC Joystick Interface
The driver works as follows:
The value supplied from the BASIC USR call gets transferred to the D register by calling the
Integer Convert ROM routine at address $B3ED. The B register then holds the value we passed.
This gets added to the base address of the ADC0809 ($FF40), to form the true address of the
input to read.
By writing to the computed address the ADC0809 starts converting the input requested.
Then we delay for about 200 usec, while the ADC0809 calculates the value of the input. After the
delay, we read the same address, thus putting the result in the A register.
Next we transfer the result to the B register (lower half of D), and clear the upper half of the D
register.
Finally, we jump to the ROM routine at $B4F4 to convert the D register to the variable in the USR
call (X, Y, or B).
TESTING THE ANALOG INTERFACE
After double checking for errors, connect the project to your CoCo with the power off. Next, turn on
your computer, then enter and RUN the following BASIC program. This program will list to the
screen, the joystick position in X and Y and the status of the fire button. The driver program is
relocatable. For users with 16K RAM, change the value of AD in line 60 to 16360 and change line
10 to CLEAR 200,16359.
10 CLEAR 200,32743
20 CLS:PRINT @33,"HIRES ADC JOYSTICK INTERFACE"
30 PRINT @104,"TOM GUNNISON"
40 PRINT @389,"X=";:PRINT@404,"Y=";
50 PRINT @455,"FIRE BUTTON=";
60 AD=32744
70 FOR A=AD TO AD+23
80 READ D
90 POKE A,D
100 NEXT A
110 DEFUSR0=AD
120 X=USR(0):Y=USR(1):B=USR(2)
130 PRINT @391,X;:PRINT @406,Y;:PRINT@467,B
140 GOTO 120
150 DATA 189,179,237,142,255,64
160 DATA 167,133,16,142,0,54,49
170 DATA 63,38,252,166,133,31
180 DATA 137,79,126,180,244
Page 8 of 9
Color Computer Analog / HIRES ADC Joystick Interface
As can be seen, this Analog Interface is fairly simple, but provides much more resolution over the
CoCo's joystick ports. It can be used for precision control in a homebrew graphics program.
The Analog Interface can also be used for other measurement tasks. The inputs can be read, by
using the same USR call – just change the argument to suit the input number you want to read. If
you plan to use the Interface with a disk system, you will need to use my 4-Slot Expansion
Interface or a Tandy Multi-Pak Interface.
Page 9 of 9