Serial Protocol - Ownasaurus/TAStm32 GitHub Wiki

Commands

Computer to TAStm32

'A' - 'D': Feeds the configured run with a single frame of new data. See below for details
'a' - 'd': Acknowledge completion of bulk transfer when using Bulk Data Mode
'I': Request Info Blob. See below
'P': Manual Power Control
    '0': Power Off
    '1': Power On
    'S': Soft Reset
    'H': Hard Reset
'p': Pause inputs for N64 or GCN, sending only blanks while enabled
    '0': Unpause
    '1': Pause
'Q': Bulk Data Mode
    'A' - 'D': Run to configure
        '0': Disable
        '1': Enable
'V': Controller mode (no buffer, repeat last input on underrun)
    '0': Disable
    '1': Enable
'r': Reset pin mode
    '0': open-drain
    '1': push-pull
'R': Reset/clear all configuration
'S': setup
    'A' - 'D': Run to configure
        'M': N64 run
            0x00: Controller byte
            0x00: Settings byte
        'G': Gamecube run
            0x00: Controller byte
            0x00: Settings byte
        'S': SNES run
            0x00: Controller byte
            0x00: Settings byte
        'N': NES run
            0x00: Controller byte
            0x00: Settings byte
        'J': Genesis run
            0x00: Controller byte
            0x00: Settings byte
'T': Set Trigger
    'A' - 'D': Run to configure
        'A': Set ACE Mode
            4-byte frame number
        'N': Set Normal Mode
            4-byte frame number
        'S': Soft Reset
            4-byte frame number
        'H': Hard Reset
            4-byte frame number
        'R': Rumble (GCN only. Waits for a rumble before proceeding with input.)
            4-byte frame number
'L': Simulate that a latch has occurred / advance the frame
    'A' - 'D': Run to advance
'U': Setup latch train for a run
    'A' - 'D': Run Identifier
        2-byte integer for length of latch train
        1 or more 2-byte integer latch train data
'\xDF': Jump to DFU bootloader code
'\xAA': Ping Command

TAStm32 to Computer

0x01R : Reset successful
0x01S : Setup successful
'A' - 'D': The configured run latched with new data,
           so the buffer wants another frame of input
'a' - 'd': Request 28 frames of data at once for the corresponding run
0x49 : Start of Infoblob marker
0x55 : Pong, Sent in response to Ping Command
0xFA : Bulk transfer command not understood
0xFB : DPCM fix mode (should be 'A' or 'N') not understood
0xFC : Console type (should be 'M','S','N') not understood
0xFD : Controller byte not valid
0xFE : Run number (A,B,C,D) not recognized or supported
0xFF : Prefix (A,B,C,D,a,b,c,d,P,Q,R,S,T) not understood
0xB0 : Buffer is full so more run data could not be added (B0 = Buffer Overrun)
0xB2 : Buffer is empty (B2 = Buffer Underrun)

Data Structures

Info Blob

The Info Blob

Should not be requested during run playback due to the size of the data transferred

The Blob starts with a VarInt encoding the number of fields in the blob,
Followed by a VarInt with the size (in bytes) of the Array of field names,
Then the array itself which is a list of null byte terminated strings,
Then a VarInt with the size (in bytes) of the Array of field values,
And finally the array itself which is also a list of null byte terminated strings

VarInt

Numbers in the Info Blob are encoded as VarInts like so:

Values less than 128 are encoded as is in a single byte.

Values greater than 127 have the first 7 bits encoded in the first byte with the greatest bit set to 1, and the remaining bits in the second byte

Extra

For a TAStm32 supporting protocol version 1.0.0, the following fields are reported:

firmwareVersion: the replay device's firmware version. (Device-dependent; for TAStm32 the Git commit hash is currently used.)
maxSize: the maximum number of latches capable of being held in the device's buffer.
maxControllers: the number of physical controller ports available.
maxDataLanes: the maximum number of simultaneous data lane outputs.
maxTransitions: the maximum number of mid-run transitions allowed.
supportedConsoles: a comma-separated list of supported consoles. TAStm32 reports nes,snes,n64,gcn,genesis.

Controller Byte

0x80 : controller p1-1
0x40 : controller p1-2
0x20 : controller p1-3
0x10 : controller p1-4
0x08 : controller p2-1
0x04 : controller p2-2
0x02 : controller p2-3
0x01 : controller p2-4

SNES Input Data

0x0001   4 Button
0x0002   3 Button
0x0004   2 Button
0x0008   1 Button
0x0010   R Button
0x0020   L Button
0x0040   X Button
0x0080   A Button

0x0100   Dpad Right
0x0200   Dpad Left
0x0400   Dpad Down
0x0800   Dpad Up
0x1000   Start Button
0x2000   Select Button
0x4000   Y Button
0x8000   B Button

NES Input Data

0x01   Right Button
0x02   Left Button
0x04   Down Button
0x08   Up Button
0x10   Start Button
0x20   Select Button
0x40   B Button
0x80   A Button

SNES/NES Settings Byte

0x80 : dpcm enable flag
0x40 : overread value
0x20 : clock filter bit 5
0x10 : clock filter bit 4
0x08 : clock filter bit 3
0x04 : clock filter bit 2
0x02 : clock filter bit 1
0x01 : clock filter bit 0

The clock filter value is effectively between 0 and 63, inclusive. This number is multiplied by 0.25us.
Therefore, the clock filter value can be between 0us and 15.75 us.

N64 Input Data

0x0001 C-Right
0x0002 C-Left
0x0004 C-Down
0x0008 C-Up
0x0010 R
0x0020 L
0x0040 (reserved/unused)
0x0080 (reserved/unused)

0x0100 Digital Pad Right
0x0200 Digital Pad Left
0x0400 Digital Pad Down
0x0800 Digital Pad Up
0x1000 Start
0x2000 Z
0x4000 B
0x8000 A

1 byte for the X axis

1 byte for the Y axis

Gamecube Input Data

0x0001 A
0x0002 B
0x0004 X
0x0008 Y
0x0010 Start
0x0020 [always 0]
0x0040 [always 0]
0x0080 [always 0]

0x0100 Digital Pad Left
0x0200 Digital Pad Right
0x0400 Digital Pad Down
0x0800 Digital Pad Up
0x1000 Z
0x2000 R (button fully pressed)
0x4000 L (button fully pressed)
0x8000 [always 1]

1 byte for the analog X axis

1 byte for the analog Y axis

1 byte for the C-stick X axis

1 byte for the C-stick Y axis

1 byte for the L trigger axis

1 byte for the R trigger axis

Genesis Input Data

Byte 1 & 2

0x01   Up
0x02   Down
0x04   Left
0x08   Right
0x10   A
0x20   B
0x40   C
0x80   Start

Byte 3

Matches Byte 1 & 2 for 3p runs or uses this format for 6button runs
0x01   Controller 1 X
0x02   Controller 1 Y
0x04   Controller 1 Z
0x08   Controller 1 Mode
0x10   Controller 2 X
0x20   Controller 2 Y
0x40   Controller 2 Z
0x80   Controller 2 Mode

Genesis Settings Byte

0x80   6 Button Mode (1 = True, 0 = False)

Examples

Reset all runs

Send 0x52 ('R')

Reset all runs and program single controller run for NES with dpcm fix

Send 0x52 ('R') 0x53 ('S') 0x41 ('A') 0x4E ('N') 0x80 ('Controller Byte') 0x80 ('Settings Byte')

Reset all runs and program single controller run for N64

Send 0x52 ('R') 0x53 ('S') 0x41 ('A') 0x4D ('M') 0x80 ('Controller Byte') 0x00 ('Settings Byte')

Reset all runs and program dual controller run for N64

Send 0x52 ('R') 0x53 ('S') 0x41 ('A') 0x4D ('M') 0x88 ('Controller Byte') 0x00 ('Settings Byte')

Send data for Run 1/A with 1 controller

Send 0x41 ('A') 0xFF 0xFF 0xFF 0xFF

Latch Train command with 2 data frames [16384, 32768]

Send 0x55 ('U') 0x41 ('A') <0x02 0x00> (length of 2) <0x00 0x40> (16384) <0x00 0x80> (32768)
⚠️ **GitHub.com Fallback** ⚠️