docs/templates/pages/sega/software/jvs.html
2022-06-27 23:09:04 +01:00

115 lines
4.8 KiB
HTML

{% extends "sega.html" %}
{% block title %}JVS{% endblock %}
{% block body %}
<h1>JAMMA Video Standard</h1>
<a href="{{ROOT}}/static/JVST_VER3.pdf">A copy of the JVS standard can be found here</a>. The astute reader may observe
it is in Japanese. A rather excelent translation can be <a href="http://daifukkat.su/files/jvs_wip.pdf">found here</a>.
<p>JVS is a communication standard designed for I/O devices in arcade macines. It typically operates over RS485 serial,
however the framing format can and sometimes is used outside of this context.</p>
<p>This page documents the canonical JVS structure. Some devices, notably the {{ part("838-14971")|safe }}, use a slight
variant on the format. <a href="./rs232c.html">The differences between the two formats are document here</a>.
</p>
<h2>Escaping</h2>
<p>Every packet sent begins with the <mark>SYNC</mark> byte, <code>0xe0</code>. Read buffers should be continually
flushed until this
byte is observed.</p>
<p>As such, <code>0xe0</code> is reserved, and is escaped. A byte is escaped using <mark>MARK</mark>, <code>0xd0</code>,
followed by
the byte's value subtract one. While any byte can be escaped, the only two that require escaping are
<mark>SYNC</mark> and <mark>MARK</mark>, escaped as <code>D0 DF</code> and <code>D0 CF</code> respectively. All
operations on packets, such as checksums and length calculation, are performed on the <b>unescaped</b> packet.
</p>
<h2 id="frame">Packet framing</h2>
<figure>
<figcaption>Request packet (master->slave)</figcaption>
<table>
<tr>
<td>E0<sub>h</sub></td>
<td>Dest</td>
<td>n</td>
<td><mark>D</mark><sub>0</sub></td>
<td><mark>D</mark><sub>1</sub></td>
<td><mark>D</mark><sub>2</sub></td>
<td>...</td>
<td><mark>D</mark><sub>n-2</sub></td>
<td><mark>SUM</mark></td>
</tr>
</table>
</figure>
<figure>
<figcaption>Response packet (slave->master)</figcaption>
<table>
<tr>
<td>E0<sub>h</sub></td>
<td>Dest</td>
<td><mark>n</mark></td>
<td>Status</td>
<td><mark>D</mark><sub>0</sub></td>
<td><mark>D</mark><sub>1</sub></td>
<td><mark>D</mark><sub>2</sub></td>
<td>...</td>
<td><mark>D</mark><sub>n-3</sub></td>
<td><mark>SUM</mark></td>
</tr>
</table>
</figure>
<p><mark>SUM</mark> is calculated by summing all bytes in the packet, excluding <mark>SYNC</mark> and <mark>SUM</mark>
itself. <code>n</code> indicates the number of bytes succeeding itself. Due to the existance of the checksum,
<code>n=0</code> is nonsensical.
</p>
<h2 id="body">Commands and responses</h2>
<p>A request packet may contain multiple commands within it. <code>D<sub>0</sub></code> always contains the first
command. It is followed by <code>m</code> bytes of data, typically a constant number per command but not always (see
the command reference), at which point either we have consumed <code>n-1</code> bytes and the next byte is
<mark>SUM</mark>, or the next byte is another command and we repeat.
</p>
<table>
<tr>
<td><mark>CMD</mark><sub>0</sub></td>
<td><mark>D</mark><sub>0,0</sub></td>
<td><mark>D</mark><sub>0,1</sub></td>
<td>...</td>
<td><mark>CMD</mark><sub>1</sub></td>
<td><mark>D</mark><sub>1,0</sub></td>
<td><mark>D</mark><sub>1,1</sub></td>
<td>...</td>
<td><mark>CMD</mark><sub>2</sub></td>
<td><mark>D</mark><sub>2,0</sub></td>
<td><mark>D</mark><sub>2,1</sub></td>
<td>...</td>
<td><mark>SUM</mark></td>
</tr>
</table>
<p>Response packets are structured similarly, however the <mark>CMD</mark> byte is not present, instead relying on the
response to be ordered exactly the same as the request. The data of each command is preceeded by a report code,
indicating that individual command's status. The below diagram also includes the entire-packet status byte too for
clarity.</p>
<table>
<tr>
<td>Status</td>
<td>Report<sub>0</sub></td>
<td><mark>D</mark><sub>0,0</sub></td>
<td><mark>D</mark><sub>0,1</sub></td>
<td>...</td>
<td>Report<sub>1</sub></td>
<td><mark>D</mark><sub>1,0</sub></td>
<td><mark>D</mark><sub>1,1</sub></td>
<td>...</td>
<td>Report<sub>2</sub></td>
<td><mark>D</mark><sub>2,0</sub></td>
<td><mark>D</mark><sub>2,1</sub></td>
<td>...</td>
<td><mark>SUM</mark></td>
</tr>
</table>
<h2 id="commands">Individual commands</h2>
<p>I may document these at some point in the future, but honestly the <a
href="http://daifukkat.su/files/jvs_wip.pdf">translated reference</a> linked at the top of this page does a
great job.</p>
{% endblock %}