-
Notifications
You must be signed in to change notification settings - Fork 9
Thistle Serialized Format [TSF]
TSF is a tag based format used for serializing data between the 6502 Core and Java. It's used for communicating with Components and Signals.
Each type beings with a byte describing what follows. Arrays and Maps are a series of tags followed by an End Tag.
Tag ID | Name | Payload Size | Description |
---|---|---|---|
0 | End | 0 | End tag. Terminates an Array or Map |
1 | Null | 0 | A null |
2 | Boolean | 1 | A boolean value. 0=False, Non Zero=True |
3 | Byte | 1 | A signed 8bit byte |
4 | Short | 2 | A signed 16bit short |
5 | Int | 4 | A signed 32bit int |
6 | Long | 8 | A signed 64bit long |
7 | Double | 8 | A IEEE-754 double-precision floating point number |
8 | Fixed | 4 | A signed 16:16 fixed point number |
9 | Byte[] | ... | A length-prefixed array of bytes. Prefix is an unsigned short |
10 | String | ... | A length-prefixed UTF-8 string. Prefix is an unsigned short |
11 | UUID | 16 | A big endian UUID |
12 | Array | ... | A series of tags terminated by an End Tag |
13 | Map | ... | A series of paired tags terminated by an End Tag |
14 | Value | 4 | An identifier representing an Value object |
All numbers above are signed and stored in little endian order.
The root array does not begin with a Tag ID, but does end with an End Tag.
Although currently unused, other Tag IDs are reserved for future usage.
To simplify parsing/generation of this data, some conversion options are available for use:
6502 -> Java Conversion
Fixed point numbers will be converted to doubles
[00010000] Arrays will be converted to Maps with Integer keys
[00100000] UUIDs will be converted to their String representation
Java -> 6502 Conversion
Optionally request doubles to be converted to fixed point or ints
[00000001] Doubles will be truncated to Ints
[00000010] Doubles will be truncated to Fixed Point
[00000100] Types smaller than an Int will be widened to Ints
[00001000] Detected UUIDs in Strings will be converted to UUID Tags
These bitmasks are used for the Generic Component Wrapper's flag byte.
The Generic IO device will convert detected UUIDs to UUID Tags when parsing signals.
UUID Tags will be converted to Strings when queuing signals.