docs/templates/pages/sega/hardware/touch.md

347 lines
8.8 KiB
Markdown
Raw Normal View History

2023-06-19 01:37:46 +00:00
# The MaiMai Touchscreen
2022-05-19 00:50:12 +00:00
2023-06-19 01:37:46 +00:00
The touchscreen for MaiMai, pre-DX, is powered by a 838-15221 board, connected to `COM3`.
2022-05-19 00:50:12 +00:00
2023-06-19 01:37:46 +00:00
Unlike other IO boards, this board communicates using a custom, text-based, protocol.
## Serial configuartion
| | |
| ------------- | ---- |
| Port | COM3 |
| Baud Rate | 9600 |
| Bits per byte | 8 |
| Stop bits | 0 |
| Parity bits | 0 |
## Packet format
As previously mentioned, all packets are text. This means, for the most part, values will stay within a normal printable range. More importantly, null bytes are not permitted as they will be interpted as the end of the string.
2022-05-19 00:50:12 +00:00
2023-06-19 01:37:46 +00:00
Packets sent from the game to the board are surrounded in braces, `{like this}`. Packets sent from the board to the game are surrounded in parentheses, `(like this)`.
### `{HALT}`
2022-05-19 00:50:12 +00:00
<table class="code">
<tr>
<td><code>{</code></td>
<td><code>H</code></td>
<td><code>A</code></td>
<td><code>L</code></td>
<td><code>T</code></td>
<td><code>}</code></td>
</tr>
</table>
2023-06-19 01:37:46 +00:00
This instructs the board to stop sending the state of the touchscreen. No response is expected.
### `{STAT}`
2022-05-19 00:50:12 +00:00
<table class="code">
<tr>
<td><code>{</code></td>
<td><code>S</code></td>
<td><code>T</code></td>
<td><code>A</code></td>
<td><code>T</code></td>
<td><code>}</code></td>
</tr>
</table>
2023-06-19 01:37:46 +00:00
This instructs the board to begin sending the state of the touchscreen (detailed below). No response is expected.
### `{??th}`
2022-05-19 00:50:12 +00:00
<table class="code">
<tr>
<td><code>{</code></td>
<td><code>L</code>/<code>R</code></td>
<td>sensor</td>
<td><code>t</code></td>
<td><code>h</code></td>
<td><code>}</code></td>
</tr>
</table>
2023-06-19 01:37:46 +00:00
This requests the configured threshold value for a specific sensor from the board. The expected response is as follows:
2022-05-19 00:50:12 +00:00
<table class="code">
<tr>
<td><code>(</code></td>
<td><code>L</code>/<code>R</code></td>
<td>sensor</td>
<td> </td>
<td>threshold value</td>
<td><code>)</code></td>
</tr>
</table>
2023-06-19 01:37:46 +00:00
### `{??k?}`
2022-05-19 00:50:12 +00:00
<table class="code">
<tr>
<td><code>{</code></td>
<td><code>L</code>/<code>R</code></td>
<td>sensor</td>
<td><code>k</code></td>
<td>threshold</td>
<td><code>}</code></td>
</tr>
</table>
2023-06-19 01:37:46 +00:00
This configures the threshold value for a specific sensor. The expected response is as follows:
2022-05-19 00:50:12 +00:00
<table class="code">
<tr>
<td><code>(</code></td>
<td><code>L</code>/<code>R</code></td>
<td>sensor</td>
<td> </td>
<td> </td>
<td><code>)</code></td>
</tr>
</table>
<h2 id="push">Active mode</h2>
2023-06-19 01:37:46 +00:00
After a `{STAT}` packet is received, the board enters a mode where it begins constantly transmitting the
state of the touchscreen. The data sent is in the following format:
2022-05-19 00:50:12 +00:00
<table class="code">
<tr>
<td><code>(</code></td>
</tr>
<tr>
<td>P1: A1,B1,A2,B2,x</td>
<td>P1: A3,B3,A4,B4,x</td>
<td>P1: A5,B5,A6,B6,x</td>
<td>P1: A7,B7,A8,B8,C</td>
</tr>
<tr>
<td>padding</td>
<td>padding</td>
</tr>
<tr>
<td>P2: A1,B1,A2,B2,x</td>
<td>P2: A3,B3,A4,B4,x</td>
<td>P2: A5,B5,A6,B6,x</td>
<td>P2: A7,B7,A8,B8,C</td>
</tr>
<tr>
<td>padding</td>
<td>padding</td>
</tr>
<tr>
<td><code>)</code></td>
</tr>
</table>
2023-06-19 01:37:46 +00:00
Each data byte is a bit mask of the 5 values it contains, mapped to `1`~h~,
`2`~h~, `4`~h~, `8`~h~, and `10`~h~
respectively. While sending `1f`~h~ would be a valid byte, it is recommended to make use of the
2022-05-19 00:50:12 +00:00
upper bits to keep the value within a printable range. I personally recommend masking with
2023-06-19 01:37:46 +00:00
`40`~h~ (`'@'`) for this purpose. Values will then range from `@` to
`_`. Bits indicated with `x` are unused. It is recommended, but not required, to leave them
2022-05-19 00:50:12 +00:00
unset.
2023-06-19 01:37:46 +00:00
The four bytes marked as padding are unused, with the only requirement being that they are non-null. It is
recommended, but not required, to set them to `40`~h~ (`'@'`).
2022-05-19 00:50:12 +00:00
2022-05-19 01:40:33 +00:00
<details>
<summary>Individual bit breakdown</summary>
<table class="code">
<thead>
<tr>
<td rowspan="2">Byte</td>
<td rowspan="2">Player</td>
<td colspan="8">Bit</td>
<td rowspan="2">ASCII</td>
</tr>
<tr>
<td>7</td>
<td>6</td>
<td>5</td>
<td>4</td>
<td>3</td>
<td>2</td>
<td>1</td>
<td>0</td>
</tr>
</thead>
<tr>
<td>0</td>
<td></td>
<td>0</td>
<td>0</td>
<td>1</td>
<td>0</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>(</td>
</tr>
<tr>
<td>1</td>
<td>P1</td>
<td>0</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>B2</td>
<td>A2</td>
<td>B1</td>
<td>A1</td>
<td><i>varies</i></td>
</tr>
<tr>
<td>2</td>
<td>P1</td>
<td>0</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>B4</td>
<td>A4</td>
<td>B3</td>
<td>A3</td>
<td><i>varies</i></td>
</tr>
<tr>
<td>3</td>
<td>P1</td>
<td>0</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>B6</td>
<td>A6</td>
<td>B5</td>
<td>A5</td>
<td><i>varies</i></td>
</tr>
<tr>
<td>4</td>
<td>P1</td>
<td>0</td>
<td>1</td>
<td>0</td>
2023-05-30 10:16:29 +00:00
<td>C</td>
2022-05-19 01:40:33 +00:00
<td>B8</td>
<td>A8</td>
<td>B7</td>
<td>A7</td>
<td><i>varies</i></td>
</tr>
<tr>
<td>5</td>
<td></td>
<td>0</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>@</td>
</tr>
<tr>
<td>6</td>
<td></td>
<td>0</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>@</td>
</tr>
<tr>
<td>7</td>
<td>P2</td>
<td>0</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>B2</td>
<td>A2</td>
<td>B1</td>
<td>A1</td>
<td><i>varies</i></td>
</tr>
<tr>
<td>8</td>
<td>P2</td>
<td>0</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>B4</td>
<td>A4</td>
<td>B3</td>
<td>A3</td>
<td><i>varies</i></td>
</tr>
<tr>
<td>9</td>
<td>P2</td>
<td>0</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>B6</td>
<td>A6</td>
<td>B5</td>
<td>A5</td>
<td><i>varies</i></td>
</tr>
<tr>
<td>10</td>
<td>P2</td>
<td>0</td>
<td>1</td>
<td>0</td>
2023-05-30 10:16:29 +00:00
<td>C</td>
2022-05-19 01:40:33 +00:00
<td>B8</td>
<td>A8</td>
<td>B7</td>
<td>A7</td>
<td><i>varies</i></td>
</tr>
<tr>
<td>11</td>
<td></td>
<td>0</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>@</td>
</tr>
<tr>
<td>12</td>
<td></td>
<td>0</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>@</td>
</tr>
<tr>
<td>13</td>
<td></td>
<td>0</td>
<td>0</td>
<td>1</td>
<td>0</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>1</td>
<td>)</td>
</tr>
</table>
</details>
2023-06-19 01:37:46 +00:00
An example may aid here. The following image is what transmitting `(FIBT@@@@@@@@)` is interpreted as:
2022-05-19 00:57:05 +00:00
<img src="{{ROOT}}/images/maimai_FIBT.png" class="graphic">