Joystick ports' Pinout & Usage Info

This section is for discussing everything about Next hardware and latest updates.
Post Reply
Szk
Posts: 36
Joined: Mon May 29, 2017 11:20 pm
Location: São Paulo, Brazil

Joystick ports' Pinout & Usage Info

Post by Szk » Wed Mar 07, 2018 7:04 pm

ZX Spectrum Next Joy1 & Joy2 ports are compatible with legacy Atari 1or2-button and modern Sega Genesis/MegaDrive multi-button controllers.
genesiscontroller.jpg
genesiscontroller.jpg (51.96 KiB) Viewed 1643 times
The popular "Atari" spec had +5V power on pin 7. The ZX Next have SELECT on Pin 7 at High Level (+3.3V) by default. You can use Sega Genesis/MegaDrive multi-button gamepads with buttons B and C on the Next without any hardware mods or software reprogramming required, where legacy ZX Spectrum games will work with fire on button B.

Image

To have access to extra buttons Start and A, programmers will need to drive the SELECT (Pin 7) to Low Level, to activate the multiplexing circuit embedded in the controller. But at this time this feature is not implemented. Watch out for a future core update that will allow the Next to fully handle the simpler Sega 3-button controller and possibly even the more complex 6-button controllers.

Image

Reference:

1. Original Atari joysticks specification
2. Sega Master System joypads specification
3. Sega Genesis joypads specification
4. 3-button multiplex circuit in Genesis joypad
5. 6-button Sega Genesis joypad reference

How to drive the joy ports on the Next from the SD v0.8e Distro (Core v.1.10.51):
A second Kempston port (IN 55 – 0x37) has been added which follows the same format as port 31 (0x1F).
Supports Sega Megadrive 3 (and 6) button Joypads. Currently 4 buttons can be used at maximum. The buttons are returned by reading the Kempston joystick ports (IN 31 / IN 55). Sega 6 XYZ buttons are mirrored on ABC. The ‘MODE’ button on a Sega 6 pad cannot be read. Bits 7..0 are as follows:

Code: Select all

7: START
6: A / X
5: C / Z
4: B / Y
3: UP
2: DOWN
1: LEFT
0: RIGHT
The following register has been updated to include these extra joypad modes.
(R/W) 0x05 (05) => Peripheral 1 setting:

Code: Select all

bits 7-6 = joystick 1 mode (LSB)
bits 5-4 = joystick 2 mode (LSB)
bit 3 = joystick 1 mode (MSB)
bit 2 = 50/60 Hz mode (0 = 50Hz, 1 = 60Hz)(0 after a PoR or Hard-reset)
bit 1 = joystick 2 mode (MSB)
bit 0 = Enable Scandoubler (1 = enabled)(1 after a PoR or Hard-reset)
Joysticks modes:

Code: Select all

000 = Sinclair 2 (67890)
001 = Kempston 1 (port 0x1F)
010 = Cursor (56780)
011 = Sinclair 1 (12345)
100 = Kempston 2 (port 0x37)
101 = MD 1 (3 or 6 button joystick port 0x1F)
110 = MD 2 (3 or 6 button joystick port 0x37)
(this post will be updated as new information becomes available)
Last edited by Szk on Wed Oct 03, 2018 3:50 pm, edited 7 times in total.

User avatar
SevenFFF
Posts: 218
Joined: Mon Jun 05, 2017 5:30 pm
Location: USA

Re: Joystick ports' Pinout & Usage Info

Post by SevenFFF » Wed Mar 07, 2018 8:18 pm

I just got a MegaDrive Power Clutch SG 3-button stick.

Nice heavy quality, and realy good value for $10.

https://www.amazon.com/gp/product/B002NRMPOM

I wil try reading the other buttons!
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel Spectron 2084blog

seedy1812
Posts: 67
Joined: Tue May 30, 2017 11:31 am

Re: Joystick ports' Pinout & Usage Info

Post by seedy1812 » Thu Mar 08, 2018 11:28 am

Surely the Genesis controller is not compatible . Atari has its 5v on pin 7 whilst the Genesis is Pin 5 ? https://en.wikipedia.org/wiki/Atari_joystick_port

https://deskthority.net/wiki/Atari_interface

Szk
Posts: 36
Joined: Mon May 29, 2017 11:20 pm
Location: São Paulo, Brazil

Re: Joystick ports' Pinout & Usage Info

Post by Szk » Thu Mar 08, 2018 3:25 pm

Devices following Sega Genesis/Megadrive standard are compatible with true "Atari DB9" interfaces, and they are backwards compatible when used on older ZX Spectrums' common interfaces (except the Amstrad-hacked +2A/+3). The ZX Spectrum Next is designed to not only accept legacy joysticks, but to also take advantage of Sega multi-button enhanced interface.

The "Atari" spec from 1977 in fact had +5V at pin 7, but joysticks were passive devices with switches that closed to GND. Speccy favorite sticks from the 80's don't require any power supply from the interface port. +5V power at pin 7 was only required by active devices like paddles, and later mouses, auto-firing joysticks etc.

Sega created a clever scheme to add more and more buttons while mantaining backwards compatibility over that same DB9 connector. While Amstrad, Commodore and others made their own modifications breaking compatibility and potentially breaking the devices or CPU's. From the Deskthority source you provided:
The signalling is close enough to the Atari standard that a Sega gamepad could be used in some standard-compliant hosts if the host has the No Connect-pins 5 and 7 high. The Sega controller expects +5V on pin 5, and setting pin 7 high sets the multiplexer in a mode that makes the D-pad work as expected and the A-button work as Fire. [7] The Commodore 64 and 128 computers reused the same physical lines for ports and the keyboard matrix, which could lead to the host's I/O chip (CIA #1) being damaged if a key is pressed while a Sega gamepad is plugged in.
In practice, as far as Spectums are concerned, that means:

- a Sega muti-button gamepad can be used on any Speccy interface (Kempston, IFII, Cursor etc), with only button B active (button C also if the interface supported 2 fire buttons) and other buttons just ignored.

- the Next hardware was designed to take advantage of full Sega Genesis/MegaDrive spec. You can plug a legacy Atari-type joystick to play old games, and you can plug a 3 or 6 button Sega DB9 gamepad and play (yet to be developed) new Next games.

- if you plug a device that need +5V power at pin 7, like a auto-firing joystick, basic (passive) functions should work, but the active electronic circuit inside the device may or may not work depending on it's logic design, as in the Next pin 7 has +3.3V (instead of 5V) set by default. In any case, there's no risk of damaging either the device or the Next.

Szk
Posts: 36
Joined: Mon May 29, 2017 11:20 pm
Location: São Paulo, Brazil

Re: Joystick ports' Pinout & Usage Info

Post by Szk » Wed Sep 26, 2018 8:46 pm

Here's some recently published information on how to drive the joy ports on the Next from the SD v0.8e Distro:
A second Kempston port (IN 55 – 0x37) has been added which follows the same format as port 31 (0x1F).
Supports Sega Megadrive 3 (and 6) button Joypads. Currently 4 buttons can be used at maximum. The buttons are returned by reading the Kempston joystick ports (IN 31 / IN 55). Sega 6 XYZ buttons are mirrored on ABC. The ‘MODE’ button on a Sega 6 pad cannot be read.
Bits 7..0 are as follows:
7: START
6: A / X
5: C / Z
4: B / Y
3: UP
2: DOWN
1: LEFT
0: RIGHT
The following register has been updated to include these extra joypad modes.(R/W) 0x05 (05) => Peripheral 1 setting:
bits 7-6 = joystick 1 mode (LSB)
bits 5-4 = joystick 2 mode (LSB)
bit 3 = joystick 1 mode (MSB)
bit 2 = 50/60 Hz mode (0 = 50Hz, 1 = 60Hz)(0 after a PoR or Hard-reset)
bit 1 = joystick 2 mode (MSB)
bit 0 = Enable Scandoubler (1 = enabled)(1 after a PoR or Hard-reset)
Joysticks modes:
000 = Sinclair 2 (67890)
001 = Kempston 1 (port 0x1F)
010 = Cursor (56780)
011 = Sinclair 1 (12345)
100 = Kempston 2 (port 0x37)
101 = MD 1 (3 or 6 button joystick port 0x1F)
110 = MD 2 (3 or 6 button joystick port 0x37)

Post Reply