TI-92 Link Protocol Guide - Variable formats

##

Variable Formats

A TI-92 variable has two parts: a header and a data section. While the header may be different, the format of the data section never changes whether the variable is in a file, in a transfer packet, or in the calculator's memory. This section describes the format of the data section for most types of variables. The format for the header is described in the packet format and the file format section.

Often certain variable types such as functions or lists are included in other larger variables. When such nesting occurs, it will be noted by referencing the type of subvariable rather than expanding its components. For example, a list contained in a GDB will be referenced as a list, not as the individual fields that make up a list.

Important note: All 2- and 4-byte values in this section are big-endian (MSB first) unless specified otherwise.

#### Variable Types

There are several types of variables that the TI-92 uses.

Expressions are basic algebraic expressions like the ones entered on the home screen.
Lists are sequences of real or complex numbers used in statistical calculations.
Matrices are two-dimensional matrices with real or complex components.
Data variables are spreadsheets containing values in some cells.
Text variables are files of readable text.
Strings are sequences of text characters.
Graphics Databases (GDB's) are stored sets of graphing functions.
Figures are objects created in the geometry application.
Pictures are stored bitmaps of the graph screen.
Programs are sequences of commands.
Macros are stored command sequences for the geometry application.

#### Expressions

TI-92 expressions are tokenized and in Reverse Polish Notation (RPN). In RPN, each operand and each operator is a "symbol," which can be pushed onto a first-in-first-out (FIFO) "stack." A stack is a data structure that works like a stack of trays: new trays can be pushed onto the stack at any time, and trays on the stack can be popped off at any time, but they always come off in the reverse order than that in which they were pushed.

Operations are read from left to right. Whenever an operand is encountered, it is pushed onto the stack. Whenever an operator is encountered, it pops one or more operands off of the stack, uses them to compute the result, then pushes the result back onto the stack. The final value is the only operand left in the stack after all operations are complete. With this method, storing parenthesis is unnecessary because there are never any ambiguities as to the order of evaluation. Multiple

Click here for a list of tokens.

Offset | Length | Description
--- | --- | ---
0 | 2 bytes | Number of bytes in this expression minus two for this field.
2 | n bytes | Expression operands and operators, tokenized and in RPN.

Example - expression (a+b)*c:
`00 05 0B 0C 8B 0D 8F
a b + c *`

#### Lists

A list is represented as a sequence of numbers. The format is shown below.

Offset | Length | Description
--- | --- | ---
0 | 2 bytes | Number of elements in the list
1 | n bytes | Element values, one by one, first to last. If the list is a real list, then each element is a 10-byte real number. If the list is a complex list, then each element is a 20-byte complex number.

#### Matrices

A matrix is represented as a two-dimensional array of numbers. The format is shown below.

Offset | Length | Description
--- | --- | ---
0 | 1 byte | Number of columns in the matrix (no more than 255)
1 | 1 byte | Number of rows in the matrix (no more than 255)
1 | n bytes | Element values, one by one (see explanation below). If the matrix is a real matrix, then each element is a 10-byte real number. If the matrix is a complex matrix, then each element is a 20-byte complex number.

The element values are arranged in row definitions from top to bottom. Each row consists of a number of real or complex elements from left to right. Under this scheme, would be ordered (1,2,3,4) in memory.

#### Data variables

Data variables consist of a number of lists, functions and strings. They have the following format:

#### Text variables

Text variables have the following format:

Offset | Length | Description
--- | --- | ---
0 | 2 bytes | Offset, in characters, to the cursor position.
2 | n bytes | Text lines (see format below)
2+n | 1 byte | This byte always has a value of E0h.

Each line of text has this format:

Offset | Length | Description
--- | --- | ---
0 | 1 byte | Line type: 0Ch=page break, 20h=normal, 43h=Command, 50h=PrintObj
1 | m bytes | Characters, first to last. The string is not zero-terminated.
1+m | 1 byte | Line delimiter: 0Dh=line break, 00h=end of file

#### Strings

Strings are represented as follows:

Offset | Length | Description
--- | --- | ---
0 | 1 byte | This byte always has a value of 0.
2 | n bytes | Characters, first to last. The string is zero-terminated.
2+n | 1 byte | This byte always has a value of 2Dh.

#### Graphics Databases (GDB's)

GDB's for each graphing mode are different, but they all consist of a window setup portion and a function library portion.

All GDB have the following overall format:

Offset | Length | Description
--- | --- | ---
0 | 2 bytes | Number of bytes in this GDB minus two for this field.
2 | 1 byte | Number of graphs (1 or 2)
3 | 1 byte | Angle mode: 01h=Radians, 02h=Degrees
4 | 1 byte | Complex number mode: 01=Real, 02=Rectangular, 03=Polar
5 | 1 byte | Graph mode: 01h=Function, 02h=Polar, 03h=Parametric, 04h=Sequence, 05h=3D
6 | 1 byte | Active graph number (0 or 1) - Not present when #graphs=1
7 | 1 byte | Graph 2 mode (same possible values as offset 3) - Not present when #graphs=1
8 | 1 byte | Split Screen mode: 01h=Full, 02h=Top/Bottom, 03h=Left/Right - Not present when #graphs=1
9 | 1 byte | Split Screen ratio: 01h=1:1, 02h=1:2, 03h=2:1 - Not present when #graphs=1
6 or 10 (Ah) | n bytes | One or two graphs back to back (see various graph formats below).
6+n or 10 (Ah)+n | 1 byte | This byte always contains DEh.

Note: When two graphs of the same graph mode are included in one GDB, the second graph does not contain any function definitions.

A function-mode graph has this format:

Offset | Length | Description
--- | --- | ---
4 | 10 bytes | A real number: xmin
14 (Eh) | 10 bytes | A real number: xmax
24 (18h) | 10 bytes | A real number: xscl
34 (22h) | 10 bytes | A real number: ymin
44 (2Ch) | 10 bytes | A real number: ymax
54 (36h) | 10 bytes | A real number: yscl
64 (40h) | 10 bytes | A real number: [Delta]x
74 (4Ah) | 10 bytes | A real number: [Delta]y
84 (54h) | 10 bytes | A real number: xres
94 (5Eh) | 2 bytes | Graphing format flags (see graph format flags, below)
96 (60h) | 2 bytes | Reserved; these bytes always have a value of 0h
98 (62h) | 1 byte | The number of functions in this graph
99 (63h) | n bytes | Function definitions, one after another (see function definition format, below).
99 (63h)+n | 1 byte | Number of constants?
100 (64h)+n | 1 byte | Table setup flags?
101 (65h)+n | 10 bytes | A real number: tblStart
111 (6Fh)+n | 10 bytes | A real number: [Delta]tbl
121 (79h)+n | m bytes | A list: tblInput

A polar-mode GDB has the following format

Offset | Length | Description
--- | --- | ---
0 | 2 bytes | Length, in bytes, of GDB, minus two.
2 | 1 byte | Mode settings (see mode setting table below)
3 | 10 bytes | A real number: Min
13 (Dh) | 10 bytes | A real number: Max
23 (17h) | 10 bytes | A real number: Step
33 (21h) | 10 bytes | A real number: xMin
43 (2Bh) | 10 bytes | A real number: xMax
53 (35h) | 10 bytes | A real number: xScl
63 (3Fh) | 10 bytes | A real number: yMin
73 (49h) | 10 bytes | A real number: yMax
83 (53h) | 10 bytes | A real number: yScl
93 (5Dh) | 1 byte | Number of functions defined (up to 99)
94 (5Eh) | n bytes | Function table - several function definitions one after another (see function table below)
94 (5Eh)+n | 50 bytes | Style table - 4 bits per function (see style table below)

A parametric-mode GDB has the following format:

Offset | Length | Description
--- | --- | ---
0 | 2 bytes | Length, in bytes, of GDB, minus two.
2 | 1 byte | Mode settings (see mode setting table below)
3 | 10 bytes | A real number: tMin
13 (Dh) | 10 bytes | A real number: tMax
23 (17h) | 10 bytes | A real number: tStep
33 (21h) | 10 bytes | A real number: xMin
43 (2Bh) | 10 bytes | A real number: xMax
53 (35h) | 10 bytes | A real number: xScl
63 (3Fh) | 10 bytes | A real number: yMin
73 (49h) | 10 bytes | A real number: yMax
83 (53h) | 10 bytes | A real number: yScl
93 (5Dh) | 1 byte | Number of functions defined (up to 99)
94 (5Eh) | n bytes | Function table - several function definitions one after another (see parametric function table below)
94 (5Eh)+n | 50 bytes | Style table - 4 bits per function (see style table below)

A differential-equation-mode GDB has the following format:

Offset | Length | Description
--- | --- | ---
0 | 2 bytes | Length, in bytes, of GDB, minus two.
2 | 1 byte | Mode settings (see mode setting table below)
3 | 1 byte | Extended mode settings (see extended mode settings table below)
4 | 10 bytes | A real number: difTol
14 (Eh) | 10 bytes | A real number: tPlot
24 (18h) | 10 bytes | A real number: tMin
34 (22h) | 10 bytes | A real number: tMax
44 (2Ch) | 10 bytes | A real number: tStep
54 (36h) | 10 bytes | A real number: xMin
64 (40h) | 10 bytes | A real number: xMax
74 (4Ah) | 10 bytes | A real number: xScl
84 (54h) | 10 bytes | A real number: yMin
94 (5Eh) | 10 bytes | A real number: yMax
104 (68h) | 10 bytes | A real number: yScl
114 (72h) | 1 byte | FldOff x Axis (see axis table below)
115 (73h) | 1 byte | FldOff y Axis (see axis table below)
116 (74h) | 1 byte | SlpFld y Axis (see axis table below)
117 (75h) | 1 byte | DirFld x Axis (see axis table below)
118 (76h) | 1 byte | DirFld y Axis (see axis table below)
119 (77h) | 10 bytes | A real number: dTime
129 (81h) | 10 bytes | A real number: fldRes
139 (8Bh) | 10 bytes | A real number: EStep
149 (95h) | 1 byte | Number of functions defined (up to 9)
150 (96h) | n bytes | Function table - several function definitions one after another (see differential function table below)
150 (96h)+n | 50 bytes | Style table - 4 bits per function (see style table below)

The mode setting byte has the following format:

Bit (Mask) | Mode if set (1) | Mode if clear (0)
--- | --- | ---
0 (01h) | DrawDot | DrawLine (unavailable in DifEq)
1 (02h) | SimulG | SeqG (unavailable in DifEq)
2 (04h) | GridOn | GridOff
3 (08h) | PolarGC | RectGC (unavailable in DifEq)
4 (10h) | CoordOff | CoordOn
5 (20h) | AxesOff | AxesOn
6 (40h) | LabelOn | LabelOff
7 (80h) | TI-92 GDB Format | TI-85 GDB Format (See TI-85 documentation)

The extended differential equation setting byte has the following format:

Bit (Mask) | Mode if set (1) | Mode if clear (0)
--- | --- | ---
0 (01h) | SlpFld | DirFld or FldOff, depending on bits 1 and 2
1 (02h) | DirFld | SlpFld or FldOff, depending on bits 0 and 2
2 (04h) | FldOff | SlpFld or DirFld, depending on bits 0 and 1
5 (20h) | Euler | RK

Note: Exactly one of bits 0-2 must be set.

Each nybble in the style table has the following format:

Binary Value | Graph Style
--- | ---
0000 | [solid line]
0001 | [thick line]
0010 | [shade above]
0011 | [shade below]
0100 | [trace]
0101 | [animate]
0110 | [dotted line]

The differential equation axis bytes have the following format:

Value | Axis
--- | ---
0 | t
16 (10h) | Q
17-25 (11h-19h) | Q1 ... Q9
32 (20h) | Q'
33-41 (21h-29h) | Q'1 ... Q'9

Function- and polar-mode function definitions have the following format:

Offset | Length | Description
--- | --- | ---
0 | 1 byte | Function ID (the number of the function) - bit 7 (0x80) is set if the function is selected
1 | n bytes | An equation defining the function

Parametric-mode function definitions have the following format:

Offset | Length | Description
--- | --- | ---
0 | 1 byte | Function ID (the number of the function) - bit 7 (0x80) is set if the function is selected
1 | n bytes | An equation defining the x function
1+n | m bytes | An equation defining the y function

Differential equation function definitions have the following format:

Offset | Length | Description
--- | --- | ---
0 | 1 byte | Function ID (the number of the function) - bit 7 (0x80) is set if the function is selected
1 | n bytes | An equation defining the function
1+n | 1 byte | Unknown
2+n | 10 bytes | Initial condition. If the initial condition is defined, this is a real number representing QIf, where f is the number of the function. If the condition is undefined, the first two bytes are {FFh 03h}, followed by the characters "QIf" (again, f is the number of the function), followed by five 0-valued bytes.

#### Figures

sdf

#### Pictures

Pictures are 128x63-pixel bitmaps. They have the following format:

Offset | Length | Description
--- | --- | ---
0 | 2 bytes | Height, in pixels, of the picture.
2 | 2 bytes | Width, in pixels, of the picture.
4 | n bytes | Monochrome (1 bpp) bitmap. (n = height * ceiling[width/8] )
4+n | 1 byte | This byte always has a value of DFh.

The following figure demonstrates byte ordering of the pixels if the bitmap for a 128x63 picture is in a 1008-element array data[]:

#### Programs

Programs share the same format as strings. Because of this, a program has a maximum length of 65535 bytes, contrary to what Texas Instruments claims in their FAQ; the largest editable program is 65434 characters long. Some programs (those that use the new TI-92 features) cannot be executed by a TI-85.

TI-BASIC programs can be plain-text or tokenized, edit-locked or edit-unlocked.
Z80 assembly programs can be plain-text, tokenized or compiled.

Plain-text unlocked programs start with one NULL character (00h).
Plain-text locked programs start with two NULL characters.
Tokenized unlocked programs start with a valid token other than the edit-lock token.
Tokenized locked programs start with the edit-lock token (8Eh 29h)

Plain-text assembly programs start with one NULL character (00h) and cannot be executed.
Tokenized assembly programs start with the AsmPrgm token (8Eh 27h) and cannot be executed.
Compiled assembly programs start with the Compiled Assembly token (8Eh 28h) and cannot be edited.

Click here for a table of token definitions.

#### Macros

Like GDB's, window setting formats vary with graphing mode. Window settings cannot be sent to a TI-85.

A function-mode window has the following format:

Offset | Length | Description
--- | --- | ---
0 | 2 bytes | Always has a value of 5Bh.
2 | 1 byte | Unknown
3 | 10 bytes | A real number: xMin
13 (Dh) | 10 bytes | A real number: xMax
23 (17h) | 10 bytes | A real number: xScl
33 (21h) | 10 bytes | A real number: yMin
43 (2Bh) | 10 bytes | A real number: yMax
53 (35h) | 10 bytes | A real number: yScl
63 (3Fh) | 20 bytes | Unknown
83 (53h) | 10 bytes | A real number: xRes

A polar-mode window has the following format

Offset | Length | Description
--- | --- | ---
0 | 2 bytes | Always has a value of 5Bh.
2 | 1 byte | Unknown
3 | 10 bytes | A real number: Min
13 (Dh) | 10 bytes | A real number: Max
23 (17h) | 10 bytes | A real number: Step
33 (21h) | 10 bytes | A real number: xMin
43 (2Bh) | 10 bytes | A real number: xMax
53 (35h) | 10 bytes | A real number: xScl
63 (3Fh) | 10 bytes | A real number: yMin
73 (49h) | 10 bytes | A real number: yMax
83 (53h) | 10 bytes | A real number: yScl

A parametric-mode window has the following format:

Offset | Length | Description
--- | --- | ---
0 | 2 bytes | Always has a value of 5Bh.
2 | 1 byte | Unknown
3 | 10 bytes | A real number: tMin
13 (Dh) | 10 bytes | A real number: tMax
23 (17h) | 10 bytes | A real number: tStep
33 (21h) | 10 bytes | A real number: xMin
43 (2Bh) | 10 bytes | A real number: xMax
53 (35h) | 10 bytes | A real number: xScl
63 (3Fh) | 10 bytes | A real number: yMin
73 (49h) | 10 bytes | A real number: yMax
83 (53h) | 10 bytes | A real number: yScl

A differential-equation-mode window has the following format:

Offset | Length | Description
--- | --- | ---
0 | 2 bytes | Always has a value of 92h.
2 | 1 byte | Unknown
3 | 10 bytes | A real number: difTol
13 (Dh) | 10 bytes | A real number: tPlot
23 (17h) | 10 bytes | A real number: tMin
33 (21h) | 10 bytes | A real number: tMax
43 (2Bh) | 10 bytes | A real number: tStep
53 (35h) | 10 bytes | A real number: xMin
63 (3Fh) | 10 bytes | A real number: xMax
73 (49h) | 10 bytes | A real number: xScl
83 (53h) | 10 bytes | A real number: yMin
93 (5Dh) | 10 bytes | A real number: yMax
103 (67h) | 10 bytes | A real number: yScl
113 (71h) | 1 byte | FldOff x Axis (see axis table)
114 (72h) | 1 byte | FldOff y Axis (see axis table)
115 (73h) | 1 byte | SlpFld y Axis (see axis table)
116 (74h) | 1 byte | DirFld x Axis (see axis table)
117 (75h) | 1 byte | DirFld y Axis (see axis table)
118 (76h) | 10 bytes | A real number: dTime
128 (80h) | 10 bytes | A real number: fldRes
138 (8Ah) | 10 bytes | A real number: EStep

A saved window (ZSTO) has the following format:

Offset | Length | Description
--- | --- | ---
0 | 2 bytes | Always has a value of 8Ch.
2 | 10 bytes | A real number: zMin
12 (Ch) | 10 bytes | A real number: zMax
22 (16h) | 10 bytes | A real number: zStep
32 (20h) | 10 bytes | A real number: ztPlot
42 (2Ah) | 10 bytes | A real number: ztMin
52 (34h) | 10 bytes | A real number: ztMax
62 (3Eh) | 10 bytes | A real number: ztStep
72 (48h) | 10 bytes | A real number: zxMin
82 (52h) | 10 bytes | A real number: zxMax
92 (5Ch) | 10 bytes | A real number: zxScl
102 (66h) | 10 bytes | A real number: zyMin
112 (70h) | 10 bytes | A real number: zyMax
122 (7Ah) | 10 bytes | A real number: zyScl
132 (84h) | 10 bytes | A real number: zxRes

Backups | Table of Contents | File Formats

Site maintained by Romain Liévin (roms@lpg.ticalc.org) and Tim Singer (tsinger@gladstone.uoregon.edu)