Skip to content

Moonshot Protocol

Takashi Toyoshima edited this page Dec 20, 2023 · 21 revisions

The Protocol used over the extended CyberStick protocol

Transport Protocol

Cycle\Description To Device To Host 3 To Host 2 To Host 1 To Host 0
L0 Cycle H Button A/A' Button B/B' Button C Button D
H0 Cycle L Button E1 Button E2 Button F Button G
L1 Cycle H Y Axis[7] Y Axis[6] Y Axis[5] Y Axis[4]
H1 Cycle L X Axis[7] X Axis[6] X Axis[5] X Axis[4]
L2 Cycle Command 1[7] Throttle[7] Throttle[6] Throttle[5] Throttle[4]
H2 Cycle Command 1[6] Reserved[7] Reserved[6] Reserved[5] Reserved[4]
L3 Cycle Command 1[5] Y Axis[3] Y Axis[2] Y Axis[1] Y Axis[0]
H3 Cycle Command 1[4] X Axis[3] X Axis[2] X Axis[1] X Axis[0]
L4 Cycle Command 1[3] Throttle[3] Throttle[2] Throttle[1] Throttle[0]
H4 Cycle Command 1[2] Reserved[3] Reserved[2] Reserved[1] Reserved[0]
L5 Cycle Command 1[1] Button A Button B Button A' Button B'
H5 Cycle Command 1[0] H H H H
L6 extended Cycle Command 2[7] Response 1[7] Response 1[6] Response 1[5] Response 1[4]
H6 extended Cycle Command 2[6] Response 1[3] Response 1[2] Response 1[1] Response 1[0]
L7 extended Cycle Command 2[5] Response 2[7] Response 2[6] Response 2[5] Response 2[4]
H7 extended Cycle Command 2[4] Response 2[3] Response 2[2] Response 2[1] Response 2[0]
L8 extended Cycle Command 2[3] Response 3[7] Response 3[6] Response 3[5] Response 3[4]
H8 extended Cycle Command 2[2] Response 3[3] Response 3[2] Response 3[1] Response 3[0]
L9 extended Cycle Command 2[1] Response 4[7] Response 4[6] Response 4[5] Response 4[4]
H9 extended Cycle Command 2[0] Response 4[3] Response 4[2] Response 4[1] Response 4[0]

Command can continue until the terminal command (0xFF) is sent. The first command is sent behind the original CyberStick protocol, and the next command could be sent behind the current response in the extended cycles.

Application Protocol

Basic Response

Response 1, 2, and 3 are used for each command response. Response 4 is used as a check sum. It should be calculated as Response 4 = Command ^ Response 1 ^ Response 2 ^ Response 3.

Direct Commands

0x00: Get Version

Byte Description
Response 1 Major Version
Response 2 Minor Version
Response 3 Match Version
Response 4 Command ^ Response 1 ^ Response 2 ^ Response3

0x01: Get Raw Digital

Byte Description
Response 1 Up/Down/Left/Right/B1/B2/B3/B4
Response 2 B5/B6/B7/B8/B9/B10/B11/B12
Response 3 0
Response 4 Command ^ Response 1 ^ Response 2 ^ Response3

0x02: Get Raw Analog 1-3

Byte Description
Response 1 Analog 1
Response 2 Analog 2
Response 3 Analog 3
Response 4 Command ^ Response 1 ^ Response 2 ^ Response3

0x03: Get Raw Analog 4-6

Byte Description
Response 1 Analog 4
Response 2 Analog 5
Response 3 Analog 6
Response 4 Command ^ Response 1 ^ Response 2 ^ Response3

0x04: Commit Layout Setting

Byte Description
Response 1 Committed Size
Response 2 0
Response 3 0
Response 4 Command ^ Response 1 ^ Response 2 ^ Response3

Indirect Commands

0x10: Store Operating Player

Byte Description
Response 1 Operating Player
Response 2 0
Response 3 0
Response 4 Command ^ Response 1 ^ Response 2 ^ Response3

Change operating player to ScratchMemory[0].

0x11: Store Layout Settings

Byte Description
Response 1 Stored Size
Response 2 0
Response 3 0
Response 4 Command ^ Response 1 ^ Response 2 ^ Response3

Store ScratchMemory data as user layout settings for the operating player. This doesn't commit the layout into the permanent flash storage, but just keep it while the device is powered on.

0x12: Load Layout Settings

Byte Description
Response 1 Length
Response 2 0
Response 3 0
Response 4 Command ^ Response 1 ^ Response 2 ^ Response3

Load user layout settings for the operating player to ScratchMemory.

0x13: Store Operating Mode

Byte Description
Response 1 Mode
Response 2 0
Response 3 0
Response 4 Command ^ Response 1 ^ Response 2 ^ Response3

Change operating mode to ScratchMemory[0].

Transaction Commands

Transaction Commands will be followed by data bytes.

Response for the command repeats the command to ensure the command is correctly received.

Byte Description
Response 1 Command
Response 2 Command
Response 3 Command
Response 4 Command ^ Response 1 ^ Response 2 ^ Response3 (== 0)

Response for the data uses a different check sum so that each end would not be confused on command and data.

Byte Description
Response 1 Data
Response 2 Data
Response 3 Data
Response 4 Response 1 ^ Response 2 ^ Response3 (== Data)

0xf0: Set Transfer Space

Value Description
0 256B ScratchMemory

0xf1: Set Transfer Address

0xf2: Set Transfer High Address

0xf3: Set Transfer Length

0xf4: Transfer to Device

Multiple data cycles follow. The first data cycle should be ~0xf4 to ensure the command request. Actual data will follow in the size that is specified via Set Transfer Length.

0xf5: Transfer to Host

The command should be followed by ~0xf5 to ensure the command request. In the response, an additional check sum byte will follow. As upstream data transmission is done per 4B units, remaining bytes will be full-filled with padding 0 so that the total length is aligned with 4. Check sum byte is the XOR result of all transferred data that followed after the ~0xf5.