PWM analog devices for the MSX
The MSX standard has native support for the PWM protocol, and uses it to read analog devices via the General Purpose ports
(AKA joystick ports). This document describes how to build yourself
some devices and adapters that use it, and how to easily read such
devices.
This is the basic circuit of one PWM channel, and will be used as a
building block for all devices for the MSX listed on this page:
The variations on each circuit will be:
- The amount of PWM channels used
- The value for each component
- The pinout to connect to the MSX joystick port
Please note that each 74LS123 chip features two PWM channels. When only
one of its channels is used, the other must be disabled to avoid
interference.
Hardware
1) MSX-Paddle:
It uses a single PWM channel, and can have up to five digital buttons.
It's recommended to assemble them with at least three buttons: A, B and
START. The case of an old NES, SNES or SMS controller can be used for
that, as shown in the pictures below. You just have to install the
potenciometer in the place of the directional buttons.
a) Components
b) DE9 female connector pinout
1: (optional) Digital up or shoulder R1
2: (optional) Digital down or shoulder L1
3: aX (Q-pin of the 74LS123)
4: START button
5: Vcc
6: A button
7: B button
8: B-pin of the 74LS123
9: GND
All digital buttons must be connected to the pin-8 of the DE9 connector, just like a normal MSX 2-button joystick.
Be sure to connect the inputs of the second channel as described below,
to disable it and prefent it from producing spurious oscillations:
- A2: GND
- B2: Vcc
- CLR2: Vcc
- C/Rext2: 10K resistor to Vcc
- Cext2: 10K resistor to GND
2) IBM-PC DA15 joystick adapter (AKA joyDA15 adapter)
This adapter uses two monostable channels.
a) Components for each channel
- C1=47nF
- VR1=100K (inside joystick)
- R2=330R
b) DE9 female connector pinout and connections
1: DA15 pin10
2: 74LS123 pin5
3: 74LS123 pin13
4: DA15 pin14
5: DA15 pins 1,8,9 and 74LS123 pin16
6: DA15 pin2
7: DA15 pin7
8: 74LS123 pins 2 and 10
9: DA15 pins 4,5, and 12
- resistor R2_Y: pin1=74LS123 pin7, pin2=DA15 pin6
- resistor R2_X: pin1=74LS123 pin15, pin2=DA15 pin3
3) Atari-2600 dual-paddle adapter
a) Components
- C1=4.7nF
- VR1=1M (inside the paddle)
- R2=3K3
b) DE9 female connector pinout
1: N/C
2: N/C
3: 74LS123 pin13
4: 74LS123 pin5
5: 74LS123 pin16 and Paddle DE9_pin7
6: Paddle DE9_pin3
7: Paddle DE9_pin4
8: 74LS123 pins 2 and 10, and Paddle DE9_pin8
9: GND
- resistor R2_A: pin1=74LS123 pin15, pin2=Paddle DE9_pin9
- resistor R2_B: pin1=74LS123 pin7, pin2=Paddle DE9_pin5
Software Programming
- Analog channels are addressed by their ID, where ID=CH*2+JP.
- CH=Channel index (0 to 5), and JP=Joystick port (1 or 2).
- The pinouts and channels were arranged to ensure cross
compatibility between the PWM devices, and easier integration with
non-PWM devices on joylib.
1) Channel mapping
The channels will be mapped as follows. See the Assembly and MSX-BASIC sections on how to read each channel.
a) MSX-Paddle
Channel
0 : R1 shoulder button
1 : L1 shoulder button
2 : aX (analog X)
3 : START button
4 : A button
5 : B button
b) joyDA15 adapter
Channel
0 : D button
1 : aY (analog Y)
2 : aX (analog X)
3 : C button
4 : A button
5 : B button
c) Atari-2600 dual-Paddle
Channel
2 : Paddle-1 analog X
3 : Paddle-2 analog X
4 : Paddle-1 button
5 : Paddle-2 button
d) Generic template for a dual-axis joystick
Channel
0 : aZ (analog Z)
1 : aY (analog Y)
2 : aX (analog X)
3 : aC (analog C)
4 : A button
5 : B button
The digital buttons will have the following output: 00=Pressed, FFh=released.
e) Yamaha MMP-01
Check this article for the channel assignment on this device.
2) MSX-BASIC programming
- The Buttons A and B can be read normally with STRIG(N), or also via their respective analog channels as described below.
- All channels can be read using the PDL(ID) function. Analog
channels will return a value between 0 and 255, while digital buttons
will return either 0 (pressed) or 255 (released).
- The MSX-BASIC is too limited to be able to reliably identify the
connected device. When needed, it's better for BASIC programs to have
an option to allow the user to manually select the desired device.
3) Assembly programming
- The analog channels can be read with the GTPDL BIOS function and the same IDs used in MSX-BASIC.
- It's better to obtain the Digital buttons status by reading the PSG R#14 with RDPSG. The bits will be mapped like this:
- Paddle : ?,?,B,A,START,?,TL,TR
- joyDA15 : ?,?,B,A,C,?,?,D
The bits marked with "?" may contain random values and must be masked out from readings.
Be careful to handle devices that are different than the
standard MSX 2-button joystick, to avoid the infamous bug that some
games have, where when a different device is left connected to the
joystick port, the game has undesired collateral effects like
interpreting a stuck direction.
The connected devices can be identifyed in assembler via their
signatures. The best way is to use HIDlib, as it handles both the
detection and the disconnection of all MSX-HID devices.
5) Notes
These are hobbyist projects. Build and use them at your own risk.