Difference between revisions of "JSX"

From MSX Game Library

(Created page with " == Protocol == === No-communication state === Write R#15 : Pin 8: LOW : Pin 6: ''any value'' Read R#14 : Any available value between 00-3F not already used === Start c...")
 
 
(24 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
== Protocol ==
  
 +
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''' (3 rows of 6 buttons each).
  
 +
Pin 8 is used to synchronize data transmission:
 +
* Leaving Pin 8 LOW for long enough (>1 ms, about 3580 t-states) resets the joystick's internal counter,
 +
* then successive pulses on Pin 8 (LOW > HIGH) are used for data transmission (6 bits per 6 bits).
  
== Protocol ==
+
Pin 7 is used as a data selector:
 
+
* When Pin 7 is pulsed with Pin 8, the Device ID is read.
=== No-communication state ===
+
* When Pin 7 stay HIGH, gamepad data is read.
  
Write R#15
+
Pin 6 is used as input only.
: Pin 8: LOW
 
: Pin 6: ''any value''
 
  
Read R#14
+
Internal counter is used to send successive input data.
: Any available value between 00-3F not already used
 
  
=== Start communication and get ID ===
+
Pin binding for received 6-bit data when reading through R#14:
 +
<syntaxhighlight>
 +
7 6 5 4 3 2 1 0
 +
---------------
 +
0 0 P P P P P P
 +
    │ │ │ │ │ └── Pin 1
 +
    │ │ │ │ └──── Pin 2
 +
    │ │ │ └────── Pin 3
 +
    │ │ └──────── Pin 4
 +
    │ └────────── Pin 6
 +
    └──────────── Pin 7
 +
</syntaxhighlight>
  
Write R#15
+
== States ==
: Pin 8: LOW (in case Pin 8 have been modified by another device)
+
=== Idle state (no-communication) ===
: Pin 6: ''any value''
 
  
 
Write R#15
 
Write R#15
: Pin 8: HIGH (start communication)
+
: Pin 8: HIGH (for >1 ms)
: Pin 6: HIGH
+
: Reset internal data counter
  
 
Read R#14
 
Read R#14
: Get ID
+
: Get 0x0F (JSX idle fingerprint)
<pre>
+
: <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])
7 6 5 4 3 2 1 0
 
-–-–-–-–-–-–-–--
 
x x A A A A B B
 
    │ │ │ │ └─┴── Number of button rows (1-4)
 
    └─┴─┴─┴────── Number of axis (1-16)
 
</pre>
 
  
=== Read bytes ===
+
=== Communication state ===
Repeat this step for each axis, then for each button row.
 
  
 
Write R#15
 
Write R#15
: Pin 8: HIGH
+
: Pin 8: LOW
: Pin 6: LOW
 
  
 
Write R#15
 
Write R#15
: Pin 8: HIGH
+
: Pin 8: HIGH (request data)
: Pin 6: HIGH
 
  
 
Read R#14
 
Read R#14
: Get 6-bits values
+
: Get 6-bit data
:: For axis: signed 6-bits value [-32 ; 31]
 
:: For boutons: bits field for 6 boutons (0: pressed, 1: released)
 
 
 
== Example ==
 
For a Joypad with 2 axis (a stick with X and Y axis), and up to 6 buttons, the reading process would be:
 
 
 
* After starting communication, first read to R#14 return the ID.
 
*: ID: 0x04 [0000 0100] for 2 axis, and 1 button row,
 
* Next reading give X-axis value [-32 ; 31],
 
* Next reading give Y-axis value [-32 ; 31],
 
* Next and last reading button states (for up to 6 boutons).
 
 
 
 
 
  
 +
Write R#15
 +
: Pin 8: LOW
 +
: Increment the internal counter
  
 +
==== Device ID ====
  
 +
First available data is the JSX device ID:
 +
<syntaxhighlight>
 +
7 6 5 4 3 2 1 0
 +
---------------
 +
0 0 A A A A B B
 +
    │ │ │ │ └─┴── Number of button rows (0-3)
 +
    │ │ │ │        0: No button
 +
    │ │ │ │        1: Up to 6 buttons
 +
    │ │ │ │        2: Up to 12 buttons
 +
    │ │ │ │        3: Up to 18 buttons
 +
    └─┴─┴─┴────── Number of axis (0-15)
 +
</syntaxhighlight>
 +
<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.
  
 +
Input number can be computed as:
 +
* Axis number (<tt>Axies</tt>): <tt>ID >> 2</tt>,
 +
* Button rows (<tt>BtnRow</tt>): <tt>ID & 0x03</tt>,
 +
* Total input number (<tt>TotIn</tt>): <tt>Axies + BtnRow</tt>.
  
 +
Repeat data read, for each axis (if any), then for each button row (if any).
 +
The device must be read <tt>TotIn</tt> times to read all data.
  
 +
==== Axis data ====
 +
Get 6-bit values
 +
: unsigned 6-bits value [0:63]
  
 +
==== Button row data ====
 +
Get 6-bit values
 +
: 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.<br/>ID: 0x09 [00 0010 01] for 2 axis, and 1 buttons row,
 +
* Next reading give X-axis value [0:63],
 +
* Next reading give Y-axis value [0:63],
 +
* Next and last reading give button states (for up to 6 boutons).
  
 +
[[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 01:16, 11 February 2025

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 (3 rows of 6 buttons each).

Pin 8 is used to synchronize data transmission:

  • Leaving Pin 8 LOW for long enough (>1 ms, about 3580 t-states) resets the joystick's internal counter,
  • then successive pulses on Pin 8 (LOW > HIGH) are used for data transmission (6 bits per 6 bits).

Pin 7 is used as a data selector:

  • When Pin 7 is pulsed with Pin 8, the Device ID is read.
  • When Pin 7 stay HIGH, gamepad data is read.

Pin 6 is used as input only.

Internal counter is used to send successive input data.

Pin binding for received 6-bit data when reading through R#14:

7 6 5 4 3 2 1 0
---------------
0 0 P P P P P P
    │ │ │ │ │ └── Pin 1
    │ │ │ │ └──── Pin 2
    │ │ │ └────── Pin 3
    │ │ └──────── Pin 4
    │ └────────── Pin 6
    └──────────── Pin 7

States

Idle state (no-communication)

Write R#15

Pin 8: HIGH (for >1 ms)
Reset internal data counter

Read R#14

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

Communication state

Write R#15

Pin 8: LOW

Write R#15

Pin 8: HIGH (request data)

Read R#14

Get 6-bit data

Write R#15

Pin 8: LOW
Increment the internal counter

Device ID

First available data is the JSX device ID:

7 6 5 4 3 2 1 0
---------------
0 0 A A A A B B
    │ │ │ │ └─┴── Number of button rows (0-3)
    │ │ │ │         0: No button
    │ │ │ │         1: Up to 6 buttons
    │ │ │ │         2: Up to 12 buttons
    │ │ │ │         3: Up to 18 buttons
    └─┴─┴─┴────── 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.

Input number can be computed as:

  • Axis number (Axies): ID >> 2,
  • Button rows (BtnRow): ID & 0x03,
  • Total input number (TotIn): Axies + BtnRow.

Repeat data read, for each axis (if any), then for each button row (if any). The device must be read TotIn times to read all data.

Axis data

Get 6-bit values

unsigned 6-bits value [0:63]

Button row data

Get 6-bit values

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 [0:63],
  • Next reading give Y-axis value [0:63],
  • Next and last reading give button states (for up to 6 boutons).

Joystick.png

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