Skip to Content
The Alchemy Project

struct SERIAL_STATE

The link cable's runtime: its mode and phase, the consoles heard from, the send position and the packet buffers the interrupt handler fills.

Declared in definitions.h.

Fields

NameDescription
Uint8modeAn SERIAL_MODE; SERIAL_MODE_CLOCKING adds LINK_STATUS_CLOCKING to the link status.
Uint8phaseAn SERIAL_PHASE.
Uint8receivedMaskThe consoles heard from since the link began.
Uint8currentMaskThe consoles heard from this tick.
Uint8channelFlags [4]Each console's SERIAL_CHANNEL_FLAG bits, set by the transfer interrupt and cleared each tick.
Uint8transferEnabledNonzero lets a new packet restart timer 3.
Uint8transferErrorSIOCNT's error bit (SIO_ERROR),
Uint8reserved0awhich multiplayer mode sets when a transfer fails, copied by each transfer interrupt; nonzero adds LINK_STATUS_ERROR to the link status and refuses the packets heard meanwhile.
Uint8packetNumberThe packet number, counted up
Uint8reserved0c [8]each tick once connected.
Sint32sendIndexThe halfword of sendBuf[1] sent next; -1 between packets, when system_serial.c's SERIAL_IDLE_HALFWORD is sent and the two send buffers swap.
Sint32receiveIndex [2]Each console's next halfword in
Uint8reservedAfterReceiveIndex [8]its incomingBuf; -1 after an idle system_serial.c's SERIAL_IDLE_HALFWORD.
Uint16 *sendBuf [2]The packet being built ([0]) and the packet being sent ([1]).
Uint16 *incomingBuf [4]Each console's packet being received; two are used.
Uint16 *readyBuf [4]Each console's last complete packet, swapped in by the interrupt.
Uint16 *pendingBuf [4]The packets the tick code checks and copies, swapped with readyBuf each tick.
Uint8storage [SERIAL_PACKET_BYTES * 8]The buffers' memory: two 32-byte send buffers, then 96 bytes a console for its incoming, ready and pending packets.

Description

The link cable's runtime: its mode and phase, the consoles heard from, the send position and the packet buffers the interrupt handler fills.

struct SERIAL_STATE

Referenced by SerialStateWork, sySerialDisableTransfer(), sySerialEnableTransferTimer(), sySerialInit() and sySerialPrepareSendPacket().

Definition at line 1825 of file definitions.h.

Fields in detail

mode

Uint8 mode

An SERIAL_MODE; SERIAL_MODE_CLOCKING adds LINK_STATUS_CLOCKING to the link status.

phase

Uint8 phase

An SERIAL_PHASE.

receivedMask

Uint8 receivedMask

The consoles heard from since the link began.

currentMask

Uint8 currentMask

The consoles heard from this tick.

channelFlags

Uint8 channelFlags[4]

Each console's SERIAL_CHANNEL_FLAG bits, set by the transfer interrupt and cleared each tick.

transferEnabled

Uint8 transferEnabled

Nonzero lets a new packet restart timer 3.

transferError

Uint8 transferError

SIOCNT's error bit (SIO_ERROR),

reserved0a

Uint8 reserved0a

which multiplayer mode sets when a transfer fails, copied by each transfer interrupt; nonzero adds LINK_STATUS_ERROR to the link status and refuses the packets heard meanwhile.

packetNumber

Uint8 packetNumber

The packet number, counted up

reserved0c

Uint8 reserved0c[8]

each tick once connected.

sendIndex

Sint32 sendIndex

The halfword of sendBuf[1] sent next; -1 between packets, when system_serial.c's SERIAL_IDLE_HALFWORD is sent and the two send buffers swap.

receiveIndex

Sint32 receiveIndex[2]

Each console's next halfword in

reservedAfterReceiveIndex

Uint8 reservedAfterReceiveIndex[8]

its incomingBuf; -1 after an idle system_serial.c's SERIAL_IDLE_HALFWORD.

sendBuf

Uint16 *sendBuf[2]

The packet being built ([0]) and the packet being sent ([1]).

incomingBuf

Uint16 *incomingBuf[4]

Each console's packet being received; two are used.

readyBuf

Uint16 *readyBuf[4]

Each console's last complete packet, swapped in by the interrupt.

pendingBuf

Uint16 *pendingBuf[4]

The packets the tick code checks and copies, swapped with readyBuf each tick.

storage

Uint8 storage[SERIAL_PACKET_BYTES * 8]

The buffers' memory: two 32-byte send buffers, then 96 bytes a console for its incoming, ready and pending packets.