Difference between revisions of "JSX"

From MSX Game Library

(No-communication state)
 
(19 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
== Protocol ==
 
== Protocol ==
  
Proposal for a protocol to handle a joypad with a variable number of sticks and buttons, plug in the MSX’s general purpose port.
+
Proposal for a protocol to handle joypads with a variable number of sticks and buttons, plug in the MSX’s [https://www.msx.org/wiki/General_Purpose_port general purpose port].
  
 
This protocol can manage joypads with up to 15 analog axis (one stick requires 2 axis) and 18 buttons.
 
This protocol can manage joypads with up to 15 analog axis (one stick requires 2 axis) and 18 buttons.
  
 +
A pulse on Pin 8 is used to start communication then (while Pin 8 still HIGH) consecutive pulse on Pin 6 is used to synchronize data transmission (6 bits per 6 bits).
 +
 +
Pin binding for received data:
 +
<pre>
 +
Bits 7 6 5 4 3 2 1 0
 +
–-–-–-–-–-–-–-–--–-–-
 +
Pins x x 7 6 4 3 2 1
 +
</pre>
 +
 +
== States ==
 
=== No-communication state ===
 
=== No-communication state ===
  
Line 12: Line 22:
  
 
Read R#14
 
Read R#14
: Any available value between 00-3F not already used
+
: Get 0x0F (JSX idle fingerprint)
 +
: <u>Note</u>: It could be any value between 00-3F not already return by [https://www.msx.org/wiki/MSX-HID#List_of_known_fingerprints other MSX devices])
  
 
=== Start communication and get ID ===
 
=== Start communication and get ID ===
Line 25: Line 36:
  
 
Read R#14
 
Read R#14
: Get ID
+
: Get JSX device ID
 
<pre>
 
<pre>
 
  7 6 5 4 3 2 1 0
 
  7 6 5 4 3 2 1 0
Line 33: Line 44:
 
     └─┴─┴─┴────── Number of axis (0-15)
 
     └─┴─┴─┴────── Number of axis (0-15)
 
</pre>
 
</pre>
 +
:<u>Note</u>: Number of axis or number of button rows can be zero, but not both. So any device ID up to 0x3F is valid except 0x00.
  
 
=== Read bytes ===
 
=== Read bytes ===
Repeat this step for each axis, then for each button row.
+
Repeat this step for each axis (if any), then for each button row (if any). Number of axis and button rows is given by the device ID
  
 
Write R#15
 
Write R#15
Line 51: Line 63:
  
 
== Example ==
 
== Example ==
For a Joypad with 2 axis (a stick with X and Y axis), and up to 6 buttons, the reading process would be:
+
For a Joypad with a stick with X and Y axis (2 axis), and 4 buttons (1 row), the reading process would be:
 
+
* After starting communication, first read to R#14 return the ID.<br/>ID: 0x09 [00 0010 01] for 2 axis, and 1 buttons row,
* After starting communication, first read to R#14 return the ID.
 
*: ID: 0x09 [0000 1001] for 2 axis, and 1 button row,
 
 
* Next reading give X-axis value [-32 ; 31],
 
* Next reading give X-axis value [-32 ; 31],
 
* Next reading give Y-axis value [-32 ; 31],
 
* Next reading give Y-axis value [-32 ; 31],
* Next and last reading button states (for up to 6 boutons).
+
* Next and last reading give button states (for up to 6 boutons).
  
 
[[File:Joystick.png|512px]]
 
[[File:Joystick.png|512px]]
 +
 +
Note: [https://www.msx.org/wiki/MSX-HID MSX-HID] fingerprint would be: 0Fh, 09h, 0Fh
  
 
[[Category:Proposal]][[Category:Proposal/Protocol]]
 
[[Category:Proposal]][[Category:Proposal/Protocol]]

Latest revision as of 08:45, 23 October 2024

Protocol

Proposal for a protocol to handle joypads with a variable number of sticks and buttons, plug in the MSX’s general purpose port.

This protocol can manage joypads with up to 15 analog axis (one stick requires 2 axis) and 18 buttons.

A pulse on Pin 8 is used to start communication then (while Pin 8 still HIGH) consecutive pulse on Pin 6 is used to synchronize data transmission (6 bits per 6 bits).

Pin binding for received data:

Bits 7 6 5 4 3 2 1 0
–-–-–-–-–-–-–-–--–-–-
Pins x x 7 6 4 3 2 1

States

No-communication state

Write R#15

Pin 8: LOW
Pin 6: any value

Read R#14

Get 0x0F (JSX idle fingerprint)
Note: It could be any value between 00-3F not already return by other MSX devices)

Start communication and get ID

Write R#15

Pin 8: LOW (in case Pin 8 have been modified by another device)
Pin 6: any value

Write R#15

Pin 8: HIGH (start communication)
Pin 6: HIGH

Read R#14

Get JSX device ID
 7 6 5 4 3 2 1 0
–-–-–-–-–-–-–-–--
 x x A A A A B B
     │ │ │ │ └─┴── Number of button rows (0-3)
     └─┴─┴─┴────── Number of axis (0-15)
Note: Number of axis or number of button rows can be zero, but not both. So any device ID up to 0x3F is valid except 0x00.

Read bytes

Repeat this step for each axis (if any), then for each button row (if any). Number of axis and button rows is given by the device ID

Write R#15

Pin 8: HIGH
Pin 6: LOW

Write R#15

Pin 8: HIGH
Pin 6: HIGH

Read R#14

Get 6-bits values
For axis: signed 6-bits value [-32 ; 31]
For boutons: bits field for 6 boutons (0: pressed, 1: released)

Example

For a Joypad with a stick with X and Y axis (2 axis), and 4 buttons (1 row), the reading process would be:

  • After starting communication, first read to R#14 return the ID.
    ID: 0x09 [00 0010 01] for 2 axis, and 1 buttons row,
  • Next reading give X-axis value [-32 ; 31],
  • Next reading give Y-axis value [-32 ; 31],
  • Next and last reading give button states (for up to 6 boutons).

Joystick.png

Note: MSX-HID fingerprint would be: 0Fh, 09h, 0Fh