Wilf wrote an article how to build a programmable joystick port for the ZX81. Here it is:
Code: Select all
Newsgroups: comp.sys.sinclair
Von: rig...@cafe.net (wilf rigter)
Datum: 1996/12/28
Betreff: ZX RAMKEY
Seasons Greetings to all Sinclair fans,
I have prepared another "easy to build" hardware project for the ZX81 but
this one can easily be adapted to the SPECTRUM (anyone?).
This is ZX RAMKEY for the ZX81, a 2 chip programmable interface to
translate ATARI joystick contacts or PC printer port ASCII code to ZX81
characters. RAMKEY uses a 6264 RAM chip for storing the joystick keycodes
or a 62256 RAM for storing an ASCII lookup table for an IBM printer port
connection. For preprogrammed applications, a 27C256 or larger EPROM can
be used to provide 8 or more translation tables for joystick emulation
of the most popular ZX81 games as well as an ASCII translation table
for a PC printer port interface.
Unlike other interfaces this one requires NO changes to existing ZX game
software since once programmed, the joystick action is indistinguishable
from the ZX keyboard operation.
In order to assign ZX81 scancodes to joystick positions or ASCII
characters, a translation table must be programmed into the RAMKEY RAM.
The EPROM version must be "burned" with the key scancodes and uses a DIP
switch on the high order address lines to select the required translation
table for each game. A block diagram for RAMKEY is included and the text
explains how it all works. The JSBOOT software is self explanatory:
just load and follow screen instructions.
The ASCIIBOOT software is similarly simple to use but will be covered in
the next installment of this article.
Well, I hope you get a kick out of RAMKEY, if not in the flesh, at least
in the spirit of ZX81 simplicity. Part 2 coming soon!
enjoy wilf
------------------ WARNING SOMEWHAT LONG ARTICLE ------------------------
ZX RAMKEY - PROGRAMMABLE KEYBOARD INTERFACE
FOR PC PRINTER PORT OR ATARI JOYSTICK
A ZX81 BREADBOARD PROJECT
1996 - w.rigter
The RAMKEY port provides a simple method for translating digital inputs
into any combination of ZX81 keys. In the simplest example of a 6264 RAM
version, the 17 possible joystick directions North, East, South, West and
Fire and combinations NE,SE,NW,SW, FN,FE,FS,FW,FNE,FSE,FNW,FSW are
translated by RAMKEY to generate ZX81 keyscan codes on CPU data lines
D0-4 just as if keys were pressed on the keyboard.
RAMKEY operation is similar to the normal ZX81 keyboard hardware.
The normal ZX81 keyboard is a matrix of keys with the A8-15 address lines
scanning the keyboard rows one at a time and each row of 5 keys is read on
the D0-4 lines through the ULA input port at I/O address FE.
RAMKEY can be thought of as multiple keyboards of silicon switches each
consisting of 8 bytes with one or more bits set to zero representing
closed key contacts. Each silicon keyboard is selected by a unique combination
of the 5 or more RAMKEY address lines (ie the joystick contacts) and each
silicon keyboard is scanned one byte at a time with A8-15 in the same
way as the ZX81 keyboard is scanned.
RAMKEY is connected to the rear edge connector but operates in parallel with
the existing keyboard. RAMKEY is scanned at the same I/O address as the
keyboard, so the 74HC32 address decoder enables the RAM CE at address
FE. Transistor Q1 enables RAM OE when any joystick contact is closed
and turns on an indication LED to indicate RAMKEY is active.
When the write protect switch S1 is closed, the RAM WR line is enabled
at I/O address 1E to program the "silicon keyboards". A second contact
from S1 disables the RAM OE. If the RAMKEY is only used with the PC printer
port the second S1 contact is not needed. The battery backup for RAMKEY is
optional but simply irresistable: A 3V Lithium battery is connected on the
+ side to the +5V line and through a 1N34A germanium diode to VSS (pin 14)
of the RAM chip. A second 1N34A diode is connected between 0V and the VSS
of the RAM chip. Use a 1uf tantalum capacitor from VDD to VSS. Please
note that the diode cathodes (band) are connected to VSS and ofcourse
you must also connect VDD (pin 28) of the RAM chip to +5V. If the whole
scheme seems upside down compared to conventional battery backup designs
just consider this: when the +5V is turned off +5V=0V and all logic outputs,
RAM inputs and pullup resistors are automatically connected to VDD.
(Whose idea was it anyway to connect diodes on the positive side of the
battery for use with negative logic devices?)
By using a 32K byte RAM chip, this design can be also translate 7 bit ASCII
code. When the PC printer port is hooked up to RAMKEY, the seven LPT data
lines together with the A8-A15 CPU address form the RAMKEY address.
The STROBE signal is used to enable the OE line.
Ofcourse pre-programmed EPROMS can be used instead which do not require the
WR line decoding, write protect switches or backup power. In that case just
the EPROM and a 2 diode address decoder can simplify this design to just a
single chip. The anodes go to A0 and IORQ and the cathodes to the EPROM CE.
Finally, a 4.7K pulldown resistor is connected between CE and 0V.
I have included some software here which, although limited to single or
shifted keys, covers 99% of the joystick applications.
The BASIC program steps the user through the programming procedure.
The program prompts the user to enter a shifted or unshifted key and then
to press and hold the desired joystick position corresponding to that key.
Since the RAM powersupply has battery backup the contents are safe as long
as the WRITE protect switch is open. The software includes a two part machine
code routine the first part of which reads the ZX81 key scancode and saves it
in variable A$. The second part transfers A$ to the selected "silicon
keyboard"
while the joystick position is held. If you wish to type in the program, you
have to create a 1 REM line with 39 characters before poking in the MC bytes.
JSBOOT BASIC PROGRAM
1 REM XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
10 DIM A$(8)
20 PRINT "HOW MANY JOYSTICK POSITIONS?"
30 INPUT A
40 CLS
50 FOR N=1 TO A
60 PRINT AT 0,0;"ENTER KEY ";N
70 IF INKEY$="" THEN GO 70
80 RAND USR 16516
90 IF INKEY$<>"" THEN GOT 90
100 PRINT A$
110 PRINT "HOLD JOYSTICK POSITION FOR 3 SECONDS"
120 PAUSE 180
130 RAND USR 16535
140 GOTO 40
JSBOOT DECIMAL CODE IN 1 REM LINE
16514 - 118,118 ;these make the 1 REM contents invisible
16516 - 1,254,254,42,16,64,17,6,0,25,237,120,119,35,203,0,56,248,201
16535 - 1,246,254,42,16,64,17,6,0,25,126,237,121,35,203,0,56,249,201
JS SOURCE CODE
SCAN LD BC,FEFE ;B=A8-A15 C=KEYBOARD I/O ADDRESS
LD HL,(4010) ;START OF VARIABLES
LD DE,06 ;OFFSET TO FIRST ELEMENT OF A$
ADD HL,DE ;POINT TO A$
SCAN1 IN A,(C) ;SCAN KEYBOARD ROW
LD (HL),A ;SAVE IN A$
INC HL ;NEXT ELEMENT OF A$
RLC B ;NEXT SCAN LINE (A8-A15)
JR C SCAN1 ;LAST ROW?
RET
WRAM LD BC,FE1E ;B=A8-A15 C=KEYBOARD I/O ADDRESS
LD HL,(4010) ;START OF VARIABLES
LD DE,06 ;OFFSET TO FIRST ELEMENT OF A$
ADD HL,DE ;POINT TO A$
WRAM1 LD A,(HL) ;GET KEYBOARD ROW DATA FROM A$
OUT (C),A ;WRITE TO RAMKEY RAM
INC HL ;NEXT ELEMENT OF A$
RLC B ;NEXT SCAN LINE (A8-A15)
JR C WRAM1 ;LAST ROW?
RET
RAMKEY JOYSTICK/PC TO ZX KEYBOARD INTERFACE
ZX81 EDGE
CONNECTOR
ZX81/TS1000 . RAMKEY
.
__________________________ ________________________________
| ADDRESA8-A15 |
S
| | . | | | |
| /8 . /8 /7 /5 /7
| _______|_______ . | | ____|___ ____|____
| | | . | | | ATARI | | D0-7 |
| | ZX81 keyboard | . | | |Joystick| | PC LPT |
| |_______________| . | | |________| |_STB_GND_|
| | . | | | | |
| /5 . | | |__________| 0V
| _______|_______ . | | +5V |
| | | . | | | |
| | SINCLAIR ULA | . | | [10K] x7 +5V |
| |_______________| . | | | | |
| | . | |____| _|_ |
/8 /5 . | | LED _\ /_ |
| | DATA . __|____|____ _ | |
| | . |A0-7 A8-14 | [1K] [100]
| | ___________|D0-4 OE|____________|c |
| | | . | RAM WR|____ 2N3904 \|____|
| | | . | CE|__ | /|b | S1
| | /5 . |_____________| | | |e /
| | | . | | | | | |
| | | . +-{3VBAT}-+ | | 0V 0V
| _______|/_____ . | |
|_|A8-15 D0-4 | . ___ | | +5V
| A0|-----10) \8_________| | |
| IORQ|------9)___ / | [10K] S1
| | . |_______|_____/ ___
| Z80 CPU | . 74HC32 |
| | . ___ ___ ___ |
| A5|-----13) \11___/--1) \3___/--4) \6__|
| A6|-----12)___ / /--2)___ / /--5)___ /
| A7|__________________| |
| WR|_______________________________|
|______________| .
--------- END OF ARTICLE ----------
Pins Atari Joystick
Pin Funktion
1 vor
2 zurück
3 links
4 rechts
5 NC
6 Feuer
7 NC (oder +5V für Elektronik)
8 GND
9 NC
You would have to run a small program to define the keys and then start the game using the programmed keys ....