                        /-----------------\
                        | TI-85 LINK info |
                        |      Port 7     |
                        \-----------------/
                                by
                         Branislav Bozgai
                        bozgai@svf.stuba.sk
                               1995
Connector:
----------        _____
Jack 2.5mm stereo  | | - GND (Ground)
                   |_|
                   |_| - W (White wire)
                   |_| - R (Red wire)


Electrical performance:
-----------------------
All data are transmitted in binary form - logical '1' or '0'
	1 = 5V (4.9V)
	0 = 0V
but TI-85 uses 'negative logic' that means: 0 (0V) = active signal
                                            1 (5V) = not active
So when you turn your calculator ON you can measure between W and GND 5V
(also between R and GND 5V) that means everything is in quiet state.


Programming:
------------
Sending:
If you want to make some wire active: OUT(7),$E8 ; W=0, R=1
                                      OUT(7),$D4 ; W=1, R=0
                                      OUT(7),$FC ; W=0, R=0
To deactivate signals:                OUT(7),$C0 ; W=1, R=1

In assembly (e.g. if I want to make W active):  LD   A,$E8
                                                OUT  (7),A

You can use other numbers to out (but may cause abnormal operation,
I think that I can explain how it works) but TI's system is using only 
those above. 

Note: Don't forget to out $C0 at the end of transmittion otherwise
      both sending and receiving calculators slow down.
      TI is using $FC to signalise an error.

Reading:  IN   A,(7)
          AND  3                        ; upper bits are not important
          CP   3
          JR   Z, Nothig_is_active      ; W=1, R=1
          CP   2
          JR   Z, R_is_active           ; W=1, R=0
          CP   1
          JR   Z, W_is_active           ; W=0, R=1
          CP   0
          JR   Z, W_and_R_are_active    ; W=0, R=0

$C0 = 192 = %11000000
$D4 = 212 = %11010100
$E8 = 232 = %11101000
$FC = 252 = %11111100

All routines related to link port are in ROM page 5.
In TALK I'm using ROM_send_byte and ROM_read_byte routines.
ROM_send_byte is at address:    $643B = LD  C,A
                          to    $647C = RET
Input:    A - byte to send
Destroys: DE, BC, HL

ROM_read_byte is at address:    $6559 = LD  B,$08
                          to    $65CB = JR  $6603
Output:   A - received byte
Destroys: DE, BC, HL

But I'm mot calling this routines directly because they both call
function $0A87 (which is error handler I think) which cause crash.
Can somebody help with that?
I've modified them slightly replaced JP to JR and JP $0A87 to RET.

*********************************************************************
There were questions on calc-ti about where can people get from
Dan Eble's ZShell and other asm progs.
So I'm running anonymous FTP server at address:
                       ftp.svf.stuba.sk
There is directory ti and there you'll find everything you want.
Feel free to upload anything you want into ti/incoming.
I'll move it into readable area within a week.
NOTE:If you can't get connection, the server may be down so please
     try later (we are trying to keep it in work non-stop but we have
     some problems)

Any comments or questions to this file mail to: bozgai@svf.stuba.sk
or copy to /dev/null :)

---------------------------------------------------------------------------
TI85/TI82 Link-protocol V2.0 January 1995
---------------------------------------------------------------------------

If anyone have any information about the TI92/95 linkprotocol, please send
it to me so I can add it to this document.

---------------------------------------------------------------------------

You use the information in this document on your own risk!

Per Finander
E-mail:pfimdt93@tufvan.hv.se

Thanks to:

Pascal Bouron (bouron@aaricia.ens-cachan.fr)
for providing additional information about TI82/85 & CBL protocol

TSTENBERG@ntcclu.ntc.nokia.com
for the C routines and information.

Mattias Lindquist (mattias.lindquist@tube.ct.se)
for providing me with a graphlink.

---------------------------------------------------------------------------

Old black link:

The linkinterface uses 2 outputs (RTS/DTR) and 2 inputs (CTS/DSR) on the
serial port to communicate with the TI85/TI82. The bits CTS/DSR can be
read from port $3F8+6, bit 4 (CTS) and bit 5 (DSR). The bits RTS/DTR is
controlled from port $3F8+4, bit 0 (DTR) and bit 1 (RTS). $3F8 is the port-
address for COM1: (or $2F8 if COM2: is used).

New gray graphlink:

The new link uses the serial channel to communicate with the computer. I
haven't any use for the RTS/DTR outputs except they will provide the link
with power. The data is sent in 9600 baud, 1 stop bit, no parity. An
interrupt routine should be used when receiving data from the link.
Otherwise any activity like the smartdrive can cause loss of data when
receiving data from the link.


I've included 5 routines in Pascal to show how to send/receive bytes to/from
the TI85/TI82. These routines are not optimized and doesn't contain any
timeout check. The constant "PortAddr" contains the base-port address to the
com-port. PortAddr=$3F8 if the link-interface is in COM1: or $2F8 if COM2: is
used. The "InitPort" procedure must be called as fast as possible, because
if CTS & DSR isn't set, then the calculator will slow down when the link
is connected. A new variable have been added: "Graphlink". If "Graphlink" is
true the linkprocedures will use the serial channel, otherwise the I/O-
pins will be used.

---------------------------------------------------------------------------

All data is sent in packages. A link-packet looks like this:

ID From: $85=TI85 ($82=TI82), $05 (Computer communicating with TI85) /
|                             $02 (Computer communicating with TI82)
|                             $15 (Unknown - accepted by TI85. If anyone
|                                  finds out the purpuse, send me a note)
|                             The CBL version also accepts other ID:s
|
|   Command:  $06 : Variable-header (used to initiate a variabletransmission)
|   |         $15 : Data part (the datapart of a variable)
|   |         $36 : Answer skip/abort
|   |         $56 : Package received OK (used to acknowledge a package)
|   |         $92 : No more variables to send (used to end a transmission)
|   |         $6D : Send screendump
|   |                                      Low byte
|   |   Data word / Size of DataPart       |  High byte
|   |   |     Data zero or more bytes      |  |
|-- |-- |---- |-----------------           |- |-
$85 $56 00 00 [DataPart:00 .. 00 Checksum: 00 00]

Checksum=(Sum of all bytes in the datapart) and 65535

A transmission can look like this:
a variable: ABC:REAL=3.1415... (PI) from TI85 to computer (all values in hex)



          ID $85=TI85 (byte, $82 for a TI82)
          |  Command (byte): Var-header
          |  |  Packet length (word, 4+NameLength for a Var-header)
          |  |  |
          |  |  |     ------Datapart------
          |  |  |     Variable length (word)
          |  |  |     |     Type (byte 0=Real number)
          |  |  |     |     |  Name Length (byte)
          |  |  |     |     |  |  Name
          |  |  |     |     |  |  |        Checksum,(0A+03+41+42+43) and FFFF
          |- |- |---- |---- |- |- |------- |----
TI85:     85 06 07 00 0A 00 00 03 41 42 43 D3 00
COMPUTER:                                        05 56 00 00
                                                 |- |- |----
                                                 |  |  No packet
                                                 |  Command: Received OK
                                                 ID $05 = Computer <=> TI85
                                                    ($02 = Computer <=> TI82)
                         Received OK
                         |           Command: Data part
                         |           |  Packet length: 10 bytes for a REAL
                         |           |  |     Data (PI)
                         |-          |- |---- |----------------------------
TI85:                 85 56 00 00 85 15 0A 00 00 00 FC 31 41 59 26 53 58 98
COMPUTER: 05 09 00 00
             |- |----
             |  No packet
             Command: Ready to receive data part

          Checksum             Command: No more variables
          |                    |  10 bytes data was sent
          |----                |- |----
TI85:     30 03             85 92 0A 00             "Done..."
COMPUTER:       05 56 00 00             05 56 00 00 END
                   |-                      |-
                   Received OK             Received OK



If a TI82 is used instead of a TI85, the Var-header command changes:
1. The "Type" byte - TI82/TI85 have different variable types
2. The "Name length" byte - don't exists for the TI82. The name is Zero-
   terminated (except system variables - see "name/type data for TI82").

After a Var-header have been sent, then the calculator (or computer) waits
for a "Received OK"-command and an answer. The answer can be one of the
following (the computer sends, TI85 receives and answers) :

85 09 07 00          : Continue (header-datalength: 7 bytes)
85 5A 07 00          : Checksum error, send last package again

The two following answers can occur if the variable already exists in memory:
85 36 01 00 02 02 00 : Variable skipped ("Skip" was pressed)
85 36 01 00 01 01 00 : Variable refused ("Exit" was pressed)
85 36 01 00 03       : Out of memory

If more than one variable is send, then a "Var-header" command when the
reciever (calculator or computer),have acknowledged the datapackage instead
of a "No more variables"-command.

---------------------------------------------------------------------------

The "Type"-byte for a TI85 can have one of the following values (hex):

00    Real
01    Cplx
02    Vectr  03  Vectr complex
04    List   05  List  complex
06    Matrx  07  Matrx complex
08    Const  09  Const complex
0A    Equ
0B    Range
0C    Strng
0D-10 GDB
11    Pict
12    Prgm
13    Range
14    PrtScreen (without Name) !!
15    ?
16    ?
17    Func  (range)
18    Pol   (range)
19    Param (range)
1A    Difeq (range)
1B    ZRCL  (range)
1C    ?
1D    Backup (without Name) !!

---------------------------------------------------------------------------

Note:

The "Send screendump" command can be sent to the TI85/TI82 to download
a screendump to the computer. The TI85 will send a "Received Ok"-command
and the a datapackage of 1024 bytes (768 bytes for the TI82). The data-
package is a copy of the memoryarea $FC00-FFFF (the screen). This works
almost anytime (it's not necessary the calculator is in the LINK-menu),
but it won't work when a program is running (except if the program is
waiting for a key).

---------------------------------------------------------------------------

The var type/name data for a TI82 :

00     :Real
01     :List
       01 5D 00 00 00 00 00 00 00 = L1
       01 5D 01 00 00 00 00 00 00 = L2
       01 5D 02 00 00 00 00 00 00 = L3
       01 5D 03 00 00 00 00 00 00 = L4
       01 5D 04 00 00 00 00 00 00 = L5
02     :Matrix
       02 5C 00 00 00 00 00 00 00 = MA
       02 5C 01 00 00 00 00 00 00 = MB
       02 5C 02 00 00 00 00 00 00 = MC
       02 5C 03 00 00 00 00 00 00 = MD
       02 5C 04 00 00 00 00 00 00 = ME
03     :Y-Var
       03 5E 10 00 00 00 00 00 00 = Y1
       03 5E 11 00 00 00 00 00 00 = Y2
       03 5E 12 00 00 00 00 00 00 = Y3
       03 5E 13 00 00 00 00 00 00 = Y4
       03 5E 14 00 00 00 00 00 00 = Y5
       03 5E 15 00 00 00 00 00 00 = Y6
       03 5E 16 00 00 00 00 00 00 = Y7
       03 5E 17 00 00 00 00 00 00 = Y8
       03 5E 18 00 00 00 00 00 00 = Y9
       03 5E 19 00 00 00 00 00 00 = Y0
       03 5E 20 00 00 00 00 00 00 = Xt1
       03 5E 21 00 00 00 00 00 00 = Yt1
       03 5E 22 00 00 00 00 00 00 = Xt2
       03 5E 23 00 00 00 00 00 00 = Yt2
       03 5E 24 00 00 00 00 00 00 = Xt3
       03 5E 25 00 00 00 00 00 00 = Yt3
       03 5E 26 00 00 00 00 00 00 = Xt4
       03 5E 27 00 00 00 00 00 00 = Yt4
       03 5E 28 00 00 00 00 00 00 = Xt5
       03 5E 29 00 00 00 00 00 00 = Yt5
       03 5E 2A 00 00 00 00 00 00 = Xt6
       03 5E 2B 00 00 00 00 00 00 = Yt6
       03 5E 40 00 00 00 00 00 00 = r1
       03 5E 41 00 00 00 00 00 00 = r2
       03 5E 42 00 00 00 00 00 00 = r3
       03 5E 43 00 00 00 00 00 00 = r4
       03 5E 44 00 00 00 00 00 00 = r5
       03 5E 45 00 00 00 00 00 00 = r6
       03 5E 80 00 00 00 00 00 00 = Un
       03 5E 81 00 00 00 00 00 00 = Vn
05     :Program
07     :Pic
       07 60 00 00 00 00 00 00 00 = Pic1
       07 60 01 00 00 00 00 00 00 = Pic2
       07 60 02 00 00 00 00 00 00 = Pic3
       07 60 03 00 00 00 00 00 00 = Pic4
       07 60 04 00 00 00 00 00 00 = Pic5
       07 60 05 00 00 00 00 00 00 = Pic6
08     :GDB
       08 61 00 00 00 00 00 00 00    = GDB1
       08 61 01 00 00 00 00 00 00 = GDB2
       08 61 02 00 00 00 00 00 00 = GDB3
       08 61 03 00 00 00 00 00 00 = GDB4
       08 61 04 00 00 00 00 00 00 = GDB5
       08 61 05 00 00 00 00 00 00 = GDB6
0B     :WINDW
       0B 5E 81 00 00 00 00 00 00 = Window
0C     :ZSTO
       0C 5E 81 00 00 00 00 00 00 = RclWindow
0D     :TABLE
       0D 5E 81 00 00 00 00 00 00 = TblSet
0E     :PrintScreen
0F     :Backup

---------------------------------------------------------------------------

"Command-byte" for the TI82
C9     :Variable header for "Send(" Command

General Structure :
===================
ID Cd Sl Sh [Data Part] Cl Ch
ID : 82 or 02
Cd : Command :(06,15,36,56,6D,92,C9)
Sl : Size of the data part is:
Sh :              Size = $100*Sh+Sl
Cl : Checksum of the data-part
Ch :          Checksum = $100*Ch+Cl

Example :
---------
02 56 00 00 : Computer -> TI , Package receive ok , no packet
82 56 00 00 : TI -> Computer , Package receive ok , no packet
02 09 00 00 : Computer -> TI , Ready to receive   , no packet
82 92 ll hh : TI -> Computer , No more variable, hhll was sent

Data part :
===========
-> If Cd is 06 or C9 :
----------------------
[..]=Ll Lh Ty {Name = 8 bytes}
Ll: Length of the variable
Lh:             Length = $100*Lh+Ll
Ty:Type-Byte
The names are always 8 bytes:
ABC    = 41 42 43 00 00 00 00 00
L1     = 5D 00 00 00 00 00 00 00

Examples :
==========
Transmission of
PROGRAM:ABC
:[A]
:
:
:
:

         From 82
         |  Command : [here 06=Variable header]
         |  |  Size of data part [here = $000B]
         |  |  |     Size of the variable [here = $0009]
         |  |  |     |     Type [$05=Prgm]
         |  |  |     |        Name and 00
         |  |  |     |        |
         |  |  |     |        |\_________________
         |  |  |\    |        |  |  |  |  |  |  |\
         |  |  | \   |        |  |  |  |  |  |  | \  Checksum
         |  |  |  |  |        A  B  C  |  |  |  |  \  |  |
         |  |  |  | <DATA PART : Type ,Name and Size> |  |
TI82    :82 06 0B 00 09 00 05 41 42 43 00 00 00 00 00 D4 00 ___________
Computer:                                                   02 56 00 00
                           Data part of the variable
                                    |        Length
                     ___________ ___|_______ |      [A]  CR CR CR CR CR
TI82    :___________ 82 56 00 00 82 15 09 00 07 00 5C 00 3F 3F 3F 3F 3F
Computer:02 09 00 00

         Checksum
         |
         |
TI82    :9E 01             82 92 09 00              "Done"
Computer:      02 56 00 00             02 56 00 00  END

---------------------------------------------------------------------------

Pascal/C procedures to communicate with the TI85/TI82 and a demo program
(pascal) to show how to receive a screendump or a variable from a TI85.

Note:
An interruptroutine should be used when receiving data from a graphlink.
The "Receive"-routine can miss data if the smartdrive uses the harddisk
while receiving data (for example) !

var
   GraphLink:Boolean; { True : Graphlink / False : Old black link }

****** Procedure to set/reset RTS/DTR:

 procedure SetPort(Bits:Byte);
 { Input: "Bits", a byte 0 - 3, bit 0 = DTR, bit 1 = RTS }

 begin
   Port[PortAddr+4]:=Bits and 3;
 end;

****** Function to read CTS/DSR:

 function  GetPort:Byte;
 { Returns a byte 0 - 3, bit 0 = CTS, bit 1 = DSR }
 { if GetPort returns 0, then the calculator have noticed a timeout }

 var
    P:Byte;

 begin
   P:=(Port[PortAddr+6] and 48) div 16;
   if P<>(Port[PortAddr+6] and 48) div 16 then
    P:=(Port[PortAddr+6] and 48) div 16;
   GetPort:=P;
   { if KeyPressed then HALT(1); }
   { Add the line above if you don't add a timeout-check somewhere else. }
   { The program will probably hang in "GetPort" when the calculator     }
   { causes a Timeout }
 end;

****** To send a byte to the TI85/TI82:

const
     Bits:array[0..7] of Byte=(1,2,4,8,16,32,64,128);

procedure Send(V:Byte);

var
   Q:Byte;

begin
     if GraphLink then begin
        Q:=Port[PortAddr+5];
        while (Q and $40)=0 do Q:=Port[PortAddr+5];
        Port[PortAddr]:=V;
     end else begin
        Q:=0;
        repeat
            if GetPort=3 then begin
               if (V and Bits[Q])=0 then begin
                  SetPort(1);
                  while ((GetPort and 2)=2) do ;
                  SetPort(3);
                  while ((GetPort and 2)=0) do ;
               end else begin
                  SetPort(2);
                  while ((GetPort and 1)=1) do ;
                  SetPort(3);
                  while ((GetPort and 1)=0) do ;
               end;
               Inc(Q);
            end;
        until Q=8;
     end;
end;

****** To recieve a byte from the TI85/TI82:

function Receive:Byte;

var
   N,V,P:Byte;

begin
     if GraphLink then begin
        P:=Port[PortAddr+5];
        while (P and 1)=0 do P:=Port[PortAddr+5];
        Receive:=Port[PortAddr];
     end else begin
        N:=0;
        V:=0;
        repeat
           P:=GetPort;
           if P<>3 then begin
              if P=1 then begin
                 SetPort(1);
                 V:=V or Bits[N];
              end;
              if P=2 then begin
                 SetPort(2);
              end;
              while ((GetPort and (3-P))=0) do ;
              SetPort(3);
              while ((GetPort and P)=0) do ;
              Inc(N);
              if N=8 then begin
                 Receive:=V;
                 Exit;
              end;
           end;
        until false;
     end;
end;

****** Initiates the com-port (MUST be called before anything else)

procedure InitPort;

var
   P:Byte;

begin
     Port[PortAddr+4]:=3;

     { Set 9600 baud 1 stopbit No parity. Needed for the graphlink }
     Port[PortAddr+3]:=3+128;
     Port[PortAddr]:=$0C;
     Port[PortAddr+1]:=$00;
     Port[PortAddr+3]:=3;
     SetPort(3);
     { Clear receive register }
     P:=Port[PortAddr+5];
     while (P and 1)>0 do begin
        P:=Port[PortAddr];
        Delay(1);
        P:=Port[PortAddr+5];
     end;
end;

****** C routines

/* ============================ */
typedef unsigned char uchar;
typedef unsigned int uint;

uint port = 0x3f8;  /* = COM1,  0x2f8 for COM2  */

/* ============================ */

void setport(uchar bits) {

    outportb(port + 4, bits & 3);   /* simple enuf to write inline code */
}

/* ============================ */

uchar getport(void) {

    uchar    b;

    b = inportb(port + 6) / 16 & 3;
/*  if (kbhit()) exit(1);   */
    return b;
}

/* ============================ */

void send(uchar b) {

    uchar bits;

    for (bits = 1; bits <= 8; bits++) {
        if (b & 1) outportb(port + 4,2);
        else       outportb(port + 4,1);
        while (getport() != 0);
        outportb(port + 4,3);
        while (getport() != 3);
        b >>= 1;
    }
}

/* ============================ */

uchar recvbyt(void) {

    uchar curbit = 1;
    uchar byt = 0, bits, x;

    for (bits = 1; bits <= 8; bits++) {
        while ((x = getport()) == 3);
        if (x == 1) {
            byt += curbit;
            outportb(port + 4,1);
            x = 2;
        }
        else {
            outportb(port + 4,2);
            x = 1;
        }
        while ((getport() & x) == 0);
        outportb(port + 4,3);
        curbit <<= 1;
    }
    return byt;
}

/* ============================ */

    /* init port: I've found that this is enough */
    outportb(port + 4,3);


*** Demo program to show how to receive vars/screendumps for the TI85 ***

begin 644 link.zip
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
MB"D@2?%@G.,'```M&@``"``````````!`"``````````3$E.2RY005-02P4&
2``````$``0`V````"0@`````
`
end

---------------------------------------------------------------------------

Revision history:

V2.0 - January 1996
       How to communicate with the new graph-link
       IO-routines in C (for old link).
       Info about TI82 CBL format
       Updated IO-routines

V1.1 - November 1995
       New send/receive procedures (works with faster computers)
       Demo program (Link.pas) for the TI85
       New var types bytes for the TI85

         +-------------------------------------------------------+
         |               TI PROTOCOL  INFORMATION                |
         +-------------------------------------------------------+
                   by Pascal BOURON (bouron@ENS-Cachan.fr)
                            Version 1.1   (30/05/96)



                        +-==========================-+
                        |  O   - Table of contents   |
                        +-==========================-+

O   - Table of contents
I   - Protocol Texas Instruments
       11 Generalities
       12 Devicetype
       13 Command
       14 Protocol
       15 Variable Header Format
           151 TI-82
           152 TI-85
           153 TI-92
       16 DataPart Format
           161 TI-82
           162 TI-85
           163 TI-92
II  - Backup
       21 TI-82
       22 TI-85
       23 TI-92
III - Special
       31 TI-85
           311 Screendump
           312 PrtScrn
       32 TI-92
           321 Screendump
           322 SEND command
           323 GET a
           324 Request function
               3241 Backup
               3242 Variable
               3242 Content
           325 Remote control of the TI-92
           326 Command 92 by link port

IV  - Reference documents

Section A : Index
        A1 TI-82
        A2 TI-85
        A3 TI-92
Section B : Examples
        B11 Transmission of Var with the 82
        B12 Transmission of Var with the 85
        B13 Transmission of Var with the 92

       ( B21 Information about the TI-82 Backup )
        B22 Information about the TI-85 Backup
       ( B23 Information about the TI-92 Backup )

Section C : Other informations
       ( C11 Format of Variable in the TI82 )
        C12 Format of Variable in the TI85
        C13 Format of Variable in the TI92





                        +-==========================-+
                        |    I   - Protocol T.I.     |
                        +-==========================-+

 11 Generalities
-===============-

Thanks to Per Finander, Ben Eater and George Nachman.
The TI82/TI85 and TI92 have the same protocol.
All transmissions are in packets.
Format af a packets:
1 Byte   : Devicetype
1 Byte   : Command
1 Word   : Datalength
n bytes  : Data
1 word   : Checksum if n>0
All words are in LLHH format (LSB before MSB)

Datalength : In the 92, Datalength's word can be different of 0 WITHOUT
           data and checksum. In this case, this word in an indormation:
           09 87 xx xx : See 326
           89 56 00 01 : 92 Receive OK but Not ready
           09 09 xx xx : Ready to receive xx xx bytes

Checksum : Exist if n>0. Checksum in the sum of all byte of the data.

 12 Devicetype
-=============-
02 : Computer > TI82
05 : Computer > TI85
09 : Computer > TI92
12 : TI92 > CBL ???
15 : ?? > TI85
82 : TI82>TI82 or TI82>Computer
85 : TI85>TI85 or TI85>Computer
89 : TI92>TI92 or TI92>Computer


 13 Command
-==========-
06 : Variable header
09 : Wait Data/Continue
0D : SEND ???
15 : Data part
36 : Refused                  (Not used on the 92, 92 can accept all var ?)
56 : OK
5A : CHK error , send again
68 : Test if 92 is ready      (See 327) (Only found on the 92)
6D : Screen Dump
78 : Continue                 (See 325) (Only use by TI-92)
87 : Direct command           (See 326) (Only found on the 92)
92 : End of transmission
A2 : Request                  (See 325) (Only found on the 92)


 14 Protocol
-===========-
Transmission of a variable from device1 to device2
1)Device1 : Var header (Name,type,length)
2)Device2 : OK
3)Device2 : WAIT
4)Device1 : OK
5)Device1 : DATAPART
6)Device2 : OK
7)Device1 : END of transmission
8)Device2 : OK

If there are several variable, repeat 1) to 6)


 15 Variable Header Format
-=========================-

151) TI-82
----------
Variable header: Always 11d bytes
Ll Lh Ty [NAME]
$100*Lh+Ll = Size of the Var
Ty         = Type of the variable
NAME       = Always 8 char, zero-terminated if length<8
(See Linkprot.txt by Per Finander for the var-code)

152) TI-85
----------
Variable header: From 5 bytes to 12d bytes
Ll Lh Ty Nl [NAME]
$100*Lh+Ll = Size of the Var
Ty         = Type of the variable
Nl         = Name length
(See Linkprot.txt by Per Finander for the var-code)

153) TI-92
----------

Variable header: From 7 bytes to 23d bytes
LL LH HL HH Ty Nl [NAME]
HH HL LH LL= Size of the Var in Memory (Real Size +2)
Ty         = Type of the variable
Nl         = Name length
(See "TI-92 LINK INTERFACE PROTOCOL" by Ben Eater and George Nachman)

 16 DataPart Format
-===================-

161) TI-82
----------
Same as in Memory
LL HH xx xx xx ....  xx
HHLL : length of the variable

Example: (See Section B-11)

162) TI-85
----------
Same as in Memory
For PRGM,STRING...
LL HH xx xx xx ....  xx
HHLL+4+length(NAME) : length of the variable in the MEM Menu
For REAL,PICT,...
xx xx xx

Example: (See Section B-12)


163) TI-92
--------
00 00 00 00 HH LL .......
HHLL : length of the variable.(real size)
In memory, there are from HH LL to byte before chk

Example: (See Section B-13)


                        +-==========================-+
                        |         II  - BACKUP       |
                        +-==========================-+

 21) TI-82
-=========-
            Sorry , no informations about this.

 22) TI-85
-==========-
Thanks to David Boozer (adb2y@virginia.edu)
TI-85    : 85 06 09 00 B1 08 1D 12 00 23 00 F7 8B 8D 02
Computer : 05 56 00 00
           05 09 00 00
TI-85    : 85 15 B1 08 .. .. Part 1 .. ..
Computer : 05 56 00 00
TI-85    : 85 15 12 00 .. .. Part 2 .. ..
Computer : 05 56 00 00
TI-85    : 85 15 23 00 .. .. Part 3 .. ..
Computer : 05 56 00 00
( These values have been found with a ROM 3.0 after a reset.)

More Detail : See B-22


 23) TI- 92
-===========-
Thanks to David Ellsworth (davidells@aol.com) for his help.

The TI-92 Send backup if "anyone" ask it. Here is the conversation
of the request send by a computer and the answers reply by 92.


WHO?       Byte send                                    TRANSLATE
------------------------------------------------------------------------
Computer : 09 68 00 00                                  Test
TI-92    : 89 56 00 00                                  OK
Computer : 09 A2 11 00 00 00 00 00 1D 0B 6D 61          Send me (Backup)
           69 6E 5C 62 61 63 6B 75 70 9F 04             main/backup
TI-92    : 89 56 00 00                                  OK
           89 06 09 00 00 04 00 00 1D 03 31 2E 33 B6 00 Backup 1kb 1.3
Computer : 09 56 00 00                                  OK
           09 09 00 04                                  Ready to receive 1kb
TI-92    : 89 56 00 00                                  OK
           89 15 00 04 .. .. 1 k Of data .. .. .. CH CL 1kb of data
Computer : 09 56 00 00                                  OK
TI-92    : 89 06 09 00 00 04 00 00 1D 03 31 2E 33 B6 00 Backup 1kb 1.3
Computer : 09 56 00 00                                  OK
           09 09 00 04                                  Ready to receive 1kb
TI-92    : 89 56 00 00                                  OK
           89 15 00 04 .. .. 1 k Of data .. .. .. CH CL 1kb of data
Computer : 09 56 00 00                                  OK
          (* N with N>=38)
TI-92    : 89 06 09 00 ll hh 00 00 1D 03 31 2E 33 B6 00 Backup hhll bytes 1.3
Computer : 09 56 00 00                                  OK
           09 09 hh ll                                  Ready to receive hhll
TI-92    : 89 56 00 00                                  OK
           89 15 00 04 .. hhll bytes of data   .. CH CL 1kb of data
Computer : 09 56 00 00                                  OK
TI-92    : 89 92 00 00                                  END of Transmission
Computer : 09 56 00 00                                  OK

Rem :
1)  When the computer reply 09 09 00 04, the 00 04 is not important, and
can be replaced by another value, with no change.
2) I think that the 1.3 is version of the Rom. If anyone with another version
as the 1.3 can confirm to me.
3) If the first reply of TI92 is 89 56 00 01, then the 92 is not ready.
   (See 327)


                        +-==========================-+
                        |   III - Special Function   |
                        +-==========================-+

 31) TI-85
-==========-

311) Screendump
---------------
Computer : 05 6D 00 00
TI-85    : 85 56 00 00
           85 15 00 04 .. .. Memory part , From FC00 to FFFF ... CHK
Computer : 05 56 00 00

312) PrtScrn
------------
TI-85    : 85 06 03 00 00 04 14 18 00
Computer : 05 56 00 00
           05 09 00 00
TI-85    : 85 56 00 00
           85 15 00 04 .. .. Memory part , From FC00 to FFFF  .. CHK
Computer : 05 56 00 00

 32) TI-92
-==========-

321) Screendump
---------------
Computer : 09 6D 00 00
TI-85    : 89 56 00 00
           89 15 00 0F .. .. .. .. .. .. .. .. .. .. .. .. .. .. CHK
Computer : 09 56 00 00

322) Send {1,3.1}
-----------------
TI-92    : 89 06 07 00 07 00 00 00 04 01 FF 0B 01 (List lenght 7 , name $FF)
Computer : 09 56 00 00
           09 09 00 00
TI-92    : 89 15 0B 00 02 00 00 00 20 31 20 33 2E 31 00 05 01 (02 = # of number)
Computer : 09 56 00 00
TI-92    : 89 92 00 00
Computer : 09 56 00 00

323) Get a
----------
TI-92    : 89 A2 06 00 00 00 00 00 00 00 00 00
Computer : 09 56 00 00
           ???????????
       Can anyone help me for the end of this conversation

324) Request function
---------------------
To ask a variable, backup or content to the 92.

 3241) Backup  : See 23

 3242) Variable
(Example of request : main\abd , type TEXT)
Computer : 09 68 00 00                                  ; TI-92 ready ?
TI-92    : 89 56 00 00                                  ; 0000= yes, 0001= no
Computer : 09 A2 0E 00 00 00 00 00 00 0B 08 6D 61 69 6E ; The request
           5C 61 62 64 3B 03                            ; (0B = TEXT)
TI-92    : 89 56 00 00
If the variable doesn't exist, the conversation stops here.
TI-92    : 89 06 09 00 12 00 00 00 0B 03 61 62 64       ; Var header
Computer : 09 56 00 00
           09 09 00 00
TI-92    : 89 56 00 00
           89 15 16 00 00 00 00 00 00 10 00 0C 20 4A 75 ; The TEXT
           73 74 20 61 20 74 65 73 74 00 E0 23 05
Computer : 09 56 00 00
TI-92    : 09 92 00 00
Computer : 09 56 00 00


 3242) Content (DIR)
Computer : 09 68 00 00                                  ; See 3241
TI-92    : 89 56 00 00                                  ; See 3241
Computer : 09 A2 06 00 00 00 00 00 19 00 19 00          ; Order of DIR ?
TI-92    : 89 56 00 00
           89 06 0A 00 0E 00 00 00 53 04 main 0A 02     ; Current folder=main
Repeat
 Computer: 09 56 00 00                                  ; OK
           09 09 FF FF                                  ; Waiting ...
 TI-92   : 89 56 00 00
           89 15 18 00 00 00 00 00 m a i n 00 00 00 00  ; 31 =<FOLDER>
           31 00 01 00 00 00 C5 01                      ; 01 =# of var in FOLD.
 Computer: 09 56 00 00
 TI-92   : 89 xx 00 00                                  ; xx= 78 :Continue
until xx= 92                                            ; xx= 92 :End
Computer : 09 56 00 00
Each entry of the 92 is in this format :
00 00 00 00
n1 n2 n3 n4 n5 n6 n7 n8 : Name of the variable
ty : Type of the variable
     31 = Folder
     00 = Variable is editing : No type ( Or EXPR)
st : 00 = Variable OK
     01 = Variable is editing
ll lh hl hh : Size of the variable (or # of variable for folder)


325) Remote control of the TI-92
--------------------------------
Press <F5>+<DIAMOND>+<(>+<R>
To control the 92, you must send a word through the link port.
This word is the code of the key (page 484 of the US manual,
Section B8 to B12 of the French manual)
After each word send, the 92 replies by a $FF.
When there is a result (after an ENTER), the 92 send this result
in FF-terminated.
Ex:
Computer : 0031  002B  0041  000D
TI -92         FF    FF    FF    FF 412B31FF
<1> <+> <a> <ENTER> , the 92 reply <a+1>
You can do graph, factor, edit-text...
To leave this mode, send the command of <F5> <DIAMOND + (> <R>


326) Command 92 by link port
----------------------------
To use this mode, not necessary to put the 92 in remote mode.
Format of this mode :
Computer : 09 87 ll hh : Send code of the hhll key
TI-92    : 89 56 00 00 : OK
For example, to do <1> <+> <a> <ENTER>
Computer : 09 87 31 00     <1>
TI-92    : 89 56 00 00
Computer : 09 87 2B 00     <+>
TI-92    : 89 56 00 00
Computer : 09 87 41 00     <a>
TI-92    : 89 56 00 00
Computer : 09 87 0D 00     <ENTER>
TI-92    : 89 56 00 00
=> The result is NOT sent by the link port.
You can use this mode to put the 92 in the remote mode




                        +-==========================-+
                        |  IV  - REFERENCE DOCUMENTS |
                        +-==========================-+



LINKPROT.TXT : V2.0 (January 1995)
               By Per Finander (pfimdt93@tufvan.hv.se)

               In this document, you can find all var-code of the
               TI-82 and TI-85, C  and Pascal IO-routines to send
               or receive variables, and a demo program.

TI-92 LINK INTERFACE PROTOCOL (January 1996)
               By Ben Eater (themouse@wam.umd.edu) and
               George Nachman (ltduck@wam.umd.edu)

               In this document, you can find all(?) var-code of
               the TI-92, C IO-routines to send or receive
               with the parallele link.

Hacking the TI-85 CALCULATOR (September 1994)
               By David Boozer (adb2y@virginia.edu)

               Lot of very interesting informations about the TI85.

TI-RAM.TXT     V0.9 (April 1996)
               By Dan Eble and Rob Taylor
               A description of the 85'RAM

TI-92 Technical Information (1996.03.29)
               by David Ellsworth (davidells@aol.com)
               ftp://users.aol.com/davidells/TI-Calc/TI-92_tech.txt

               Lot of very interesting informations about the TI92.



---------------------------------------------------------------------------
                                                          SECTION A - Index

TI-82 :
  Backup                                        : 21
  Checksum calcul                               : 11
  Command byte                                  : 13
  DataPart                                      : 161
  Devicetype (02 or 82)                         : 12
  Format of .. See this word
  Header format                                 : 151
  Protocol                                      : 11,14
  Transmission                                  : 11,14


TI-85 :
  Backup                                        : 22
  Checksum calcul                               : 11
  Command byte                                  : 13
  DataPart                                      : 162
  Devicetype (05 or 85)                         : 12
  Format of ... See this word
  Header format                                 : 152
  Protocol                                      : 11,14
  PrtScreen                                     : 312
  ScreenDump                                    : 311
  Transmission                                  : 11,14
  Variable format                               : C12
  VAT                                           : C22

TI-92 :
  Backup                                        : 23
  Checksum calcul                               : 11
  Command byte                                  : 13
  DataPart                                      : 163
  DataLength (Special ...)                      : 11
  Devicetype (09 or 89)                         : 12
  Format of ... See this word
  Get (command)                                 : 323
  Header format                                 : 153
  Protocol                                      : 11,14
  Remote                                        : 325,326
  Request                                       : 324
    backup                                      : 23,3241
    content                                     : 3243
    variable                                    : 3242
  ScreenDump                                    : 321
  Send (command)                                : 322
  Transmission                                  : 11,14
  Variable format                               : C13


---------------------------------------------------------------------------
                                                       SECTION B : Examples
                      ------------------------
                      B1 - Transmission of var
                      ------------------------

   B11) Transmission of Var with the 82
   ====================================
Transmission of
ABC:PROGRAM
:[A]
:
:
:
:

1)TI-82    : 82 06 0B 00 09 00 05 41 42 43 00 00 00 00 00 D4 00
2)Computer : 02 56 00 00
3)           02 09 00 00
4)TI-82    : 82 56 00 00
5)           82 15 09 00 07 00 5C 00 3F 3F 3F 3F 3F 9E 01
6)Computer : 02 56 00 00
7)TI-82    : 82 92 09 00
8)Computer : 02 56 00 00

1) Var header (Length 000B)
   09 00 : Size of the var , here 9 bytes
   05    : Type , here PRGM
   41 42 43 00 00 00 00 00 = ABC : Name
   D4 00 : Checksum
2) OK
3) Ready to receive
4) OK
5) Data part (Length 0009)
   07 00 : Length
   5C 00 : [A]
   3F 3F 3F 3F 3F : CR CR CR CR CR
   9E 01 : Ckecksum
6) OK
7) End of transmission, 0009h bytes was sent.
8) OK


   B12) Transmission of Var with the 85
   ====================================

Transmission of ABC:REAL=3.1415926535898
1)TI-85    : 85 06 07 00 0A 00 00 03 41 42 43 D3 00
2)Computer : 05 56 00 00
3)           05 09 00 00
4)TI-85    : 85 56 00 00
5)           85 15 0A 00 00 00 FC 31 41 59 26 53 58 98 30 03
6)Computer : 05 56 00 00
7)TI-85    : 85 92 0A 00
8)Computer : 05 56 00 00

1) Var header (Length 0007)
   0A 00 : Size of the var , here 10d bytes
   00    : Type , here real
   03    : Length of the name
   41 42 43 = ABC : Name
   D3 00 : Checksum
2) OK
3) Ready to receive
4) OK
5) Data part (Length 000A)
   00 00 FC 31 41 59 26 53 58 98 = 3.1415926535898
6) OK
7) End of transmission, 000Ah bytes was sent.
8) OK


   B13) Transmission of Var with the 92
   ====================================

Transmission of a:Expr=1.23
1)TI 92    : 89 06 07 00 0C 00 00 00 00 01 61 6E 00
2)Computer : 09 56 00 00
3)           09 09 00 00
4)TI 92    : 89 56 00 00
5)           89 15 10 00 00 00 00 00 00 0A
             40 00 12 30 00 00 00 00 00 23 AF 00
6)Computer : 09 56 00 00
7)TI-92    : 89 92 00 00
8)Computer : 09 56 00 00

1) Var header (Length 0007)
   0C 00 00 00 : Size of the var , here 12d bytes
   00    : Type , here EXPR
   01    : Length of the name
   61    : a : Name
   6E 00 : Checksum
2) OK
3) Ready to receive
4) OK
5) Data part (Length 0010)
   00 00 00 00 : ???
   00 0A : Length of var
   40 .. : Var (See 163b)
6) OK
7) End of transmission, 000Ah bytes was sent.
8) OK


                      ------------------------
                      B2 - Backup Informations
                      ------------------------


   B22 Information about the TI-85 Backup
   ======================================
In the BACKUP.85B
0000  >0007      **TI85**
0008  >000A      1A 0C 00
000B  >0034      "Backup file dated 04/28/96,17:02",0
0035  >0036      ll hh : # of byte from next to Checksum
0037  >0038      09 00 : Size of the Var header
0039  >003A      Size of Part 1 ($08B1)
003B             Code of Backup (1D)
003C  >003D      Size of Part 2 (n2)
003E  >003F      Size of Part 3 (n3)
0040  >0041      $F7 $8B
0042  >0043      Size of Part 1 (Always? B1 08)
0044  >08F4      Part 1
08F5  >08F6      Size of Part 2 (here 12 00) (n2)
08F7  >08F6+n2   Part 2
nnnn  >nnnn+1    Size of Part 3 (here 23 00) (n3)
nnnn+2>nnnn+1+n3 Part 3
xxxx  >xxxx+1    Checksum

Description of each packet
--------------------------
Part 1 :TI-85 Memory
(0000 is the first byte of this packet)
Size = $08B1 (2225d bytes)
0000->08B0 : Memory from : $8346 -> $8BF6

byte $8B2C : Floating point mode (3=Normal;4=Float0;5=Float1;..;F=Float11)
word $8B2D : Pointer of current Floating point. (07E6)

Part 2 :User Memory ($8BF7)
(0000 is the first byte of this packet)
0000->nnnn-1 : Memory from $8BF7 to $8BF7-1+nnnn

Part 3 :VAT   (From $FA6F downto ($8BEB+1))
(Variable Allocation Table)
(See C22)

---------------------------------------------------------------------------
                                                          SECTION C : Other
                           --------------------
                           C1 - Variable format
                           --------------------

   C11 Information about the TI-82 Variables       ?
   =========================================

   C12 Information about the TI-85 Variables
   =========================================

Format of some variables:
PRGM  : LL HH PROGRAM
STRNG : LL HH STRING
REAL  : El Eh Rg N1 N2 N3 N4 N5 N6 N7
      With EhEl : Exponent    \
           Rg   : Range        > Value =Number*10^(Exponent+100*(Range-$FC))
           Ni   : Number      /
      (See the document of David Boozer for more development)




   C13 Information about the TI-92 Variables
   =========================================

  Expr   (00)
  -----------
00 00 00 00 Th Tl [EXPR]
ThTl : Size of EXPR

* Data part format for an expr
An expression must be read from the end to the begining.
The first byte (Last) is an ID

with number
ID    TYPE      SIZE  Example
------------------------------
1F    INTEGER   Var.  0C 01 1F =12d >> 0C=12 01=1 byte
23    Real      12    40 00 12 30 00 00 00 00 00 23 = 1.23>> Value=<signe><number>*10^[<Exponent>-$4000-$D]

Special ID
----------
02 =  r    03 =  s   04 =  t   05 =  u   06 =  v   07 =  w   08 =  x
09 =  y    0A =  z   0B =  a   0C =  b   0D =  c   0E =  d   0F =  e
10 =  f    11 =  g   12 =  h   13 =  i   14 =  j   15 =  k   16 =  l
17 =  m    18 =  n   19 =  o   1A =  p   1B =  q   26 =  i (i^2=-1)
8B =  +    8F =  *   91 =  /


Example :
00 00 00 00 : ??
00 10 : size = 16 bytes
40    : exponent =(4001$ and 7FFF$)-4000$-$D=-12d
01    : signe =4001$ and $8000 =0 => (+)
12 20 00 00 00 00 00  : number=12200000000000
                  => 12200000000000*10^(-12) =12.2
23   : real

04   : value = 4$    \
01   : size=1         > Integer size 1 , value 4
1F   : integer       /

18   : n
8F   : *
8B   : +
=> +(*(n,4),12.2) = 12.2+4*n

  TEXT   (0B)
  -----------
00 00 00 00 Th Tl Ch Cl [YOUR TEXT] 00 E0
ThTl : Size of text + 4
ChCl : Cursor Pos

! Warning ! The first byte after CR is a command and is put before ":"

  PIC   (10)
  ----------
00 00 00 00 Sh Sl Rh Rl Ch Cl [YOUR PIC] 00 DF
ShSl : Size of Pic + 6
RhRl : # of row
ChCl : # of col
In "Normal" PIC , ShSl = RhRl*INT(((ChCl-1)/8)+1)
But, the 92 don't verify this. RhRl and ChCl is only use when you display
the picture.



                           ---------------
                           C2 - VAT format
                           ---------------

   C21 Information about the TI-82 VAT    ?
   ===================================

   C22 Information about the TI-85 VAT
   ===================================

The format of each entry is :
NN .. NN Ln HH LL Ty
With :
Ty     = Type of variable
HHLL   = Position in RAM
Ln     = Length of the name
NN..NN = NAME

Example of VAT (without Zshell):
43 42 41 03 8C 16 12 43 42 02 8C 13 0C 41 01 8C 09 00 23 01 8C 00 12 21
C  B  A              C  B              A              #              !
01 8B FE 12 73 6E 41 03 8B FB 0C 74 61 74 53 79 05 8B F9 04 74 61 74 53
            s  n  A              t  a  t  S  y              t  a  t  S
78 05 8B F7 04
x

xStat : LIST  $8BF7 (Type $04)
yStat : LIST  $8BF9 (Type $04)
Ans   : STRNG $8BFB (Type $0C)
!     : PRGM  $8BFE (Type $12)
#     : PRGM  $8C01 (Type $12)
A     : REAL  $8C09 (Type $00)
BC    : STRNG $8C13 (Type $0C)
ABC   : PRGM  $8C16 (Type $12)
! and # are used by ENTRY.


   C23 Information about the TI-92 VAT    ?
   ===================================
========================================================================
                          !****FILE FORMATS****!
========================================================================

File format of .85G files
=========================
Compiled by David Brodbeck (gull@cyberspace.com)
Corrections by Magnus Hagander (mha@algonet.se)
Type codes compiled by Per Finander (pfimdt93@hvdc.hv.se)


The .85G files are groups of TI-85 variables.
They are also the general part of all .85x files (see README.TXT for
further information about this).
An 85G file can contain any number of variables, as long as their total
size does not exceed 64Kb.

The format of the .85G file is
------------------------------

Header     - 37h bytes
Entry1
Entry2
  ..
EntryX
Checksum   - 2 bytes


The header has the following format
-----------------------------------

Offset    Length    Comments
======    ======    ========
00h       08h       Signature. Must be "**TI85**"
08h       03h       End-Of-File marker and further signature, must be
                    1Ah 0Ch 00h
0Bh       2Ah       Comment. This is a space- or null-padded string.
                    It may _NOT_ contain any of the special characters
                    on the TI-85. All normal characters are allowed,
                    though.
35h       02h       Word: Number of bytes from [next byte to EOF]-2.
                    This variable is used to calculate the checksum
                    of the file. Read this word. Then calculate the
                    checksum on the n words that follows, where n is
                    the value you just read. After that, append the
                    checksum.


Each entry has the following format
-----------------------------------

Offset    Length    Comments
======    ======    ========
+00h      02h       Word: Bytes from next byte to end of name
                    This can be used for "fast-skipping" of the
                    variable when seeking through the file. The
                    word pointed to by this value is the size of
                    the variable, and therefor the whole thing
                    can be skipped faster.
+02h      02h       Word: Data length
+04h      01h       Byte: Type code (see table below)
+05h      01h       Byte: Name length
+06h       *h       Name (plain data, no terminating null or padding
                    spaces)
*+00h     02h       Word: Data length
*+02h     xxx       Data



The typecodes available are:
----------------------------
00    Real
01    Cplx
02    Vectr  03  Vectr complex
04    List   05  List  complex
06    Matrx  07  Matrx complex
08    Const  09  Const complex
0A    Equ
0B    Range
0C    Strng
0D-10 GDB
11    Pict
12    Prgm
13    Range
14    ?
15-1B Range


The checksum is calculated the following way
--------------------------------------------
Sum up all the words between 37h and (filesize-2), and the
value with FFFFh, and there you are. A little Pascal code
snippet to show the basic idea (programmers in other languages
should probably understand it too):

var checksum:Word;f:file;i:Integer;b:Byte;
begin
   seek(f,$37);
   checksum:=0;
   for i:=1 to filepos(f)-$39 do begin
      blockread(f,b,1);
      checksum:=checksum+b;
   end;
   blockwrite(f,checksum,2);
end;

You could also read the word at address 35h to determine how
much to compute the checksum on, if you don't want to use
the files size.
File format of .85I files
=========================
Compiled by Magnus Hagander (mha@algonet.se)

The .85I files are TI-85 pictures.
The pictures are 128x63 pixels with 1 bit per pixel (monochrome).
They are stored as a bit-map of the screen from top-right to bottom-left,
going left to right, then up to down.

The format of a picture is:

Offset    Length    Comment
======    ======    =======
00h       02h       Word: Size of picture. _ALWAYS_ F003 = 1008 (03F0h)
02h       3F0h      <Picture bitmap>
File format of .85K files
=========================
Compiled by Magnus Hagander (mha@algonet.se)


The .85K files are TI-85 constants. It can contain both real and complex
constants.
The real constants have _EXACTLY_ the same format as real numbers (see 85N.txt)
The complex constants have _EXACTLY_ the same format as complex numbers
  (see 85C.txt)
File format of .85L files
=========================
Compiled by Magnus Hagander (mha@algonet.se)


The .85L files are TI-85 lists. It can contain both real and complex
lists. The only difference is the identifier and the data block size.

The format of a list is:

Offset    Length    Comment
======    ======    =======
00h       02h       Word: List dimension (number of items)
02h       [00h]*BS  Data items. Each item is either a real number (see 85N.txt)
                    or a complex number (see 85C.txt).
                    BS is the block size, which is 10 for real lists and 20 for
                    complex lists.
FIle format of .85M files
=========================
Compiled by Magnus Hagander (mha@algonet.se)


The .85M files are TI-85 matrixes. It can contain both real and complex
matrixes. The only difference is the identifier and the data block size.

The format of a matrix is:

Offset    Length    Comment
======    ======    =======
00h       01h       Byte: Vertical (Y) dimension of matrix
01h       01h       Byte: Horizontal (X) dimension of matrix
02h       [00h]*
          [01h]*BS  Data items. Each item is either a real number (see 85N.txt)
                    or a complex number (see 85C.txt).
                    BS is the block size, which is 10 for real matrixes and 20
                    for complex matrixes.
                    The values are stored in Top-Right, Top-Left, Bottom-Right,
                    Bottom-Left order. This means that the matrix
                    [[1,2]
                     [3,4]]
                    has its values stored in the order 1,2,3,4.
File format of .85N files
=========================
Compiled by Magnus Hagander (mha@algonet.se)


The .85N files are TI-85 real values.
This is the simpliest variable on the TI-85, yet sometimes one of the
hardest to handle. It is also included as "sub-variable" in e.g. lists
and matrixes.

The format of a real value is:

Offset    Length    Comment
======    ======    =======
00h       01h       Byte: Sign. 00h -> Positive number; 80h -> Negative number.
01h       01h       Low order of 10^x value.
02h       01h       High order of 10^x value.
                    The 10^x value is calculated using:
                    x=[01h]+256*([02h]-FCh)
03h       07h       Hexa-decimal interpretion of value. The decimal point
                    lies between Low and High nibble of [03h].

The reason that the 10^x value seems so complicated is that it should handle
values between 10^999 <-> 10^-999.
The "value-part" may seem confusing, but I just didn't know how to say it.
A few examples will illustrate (and hopefully solve) the problem:

                               Storage
Value                 00 01 02 03 04 05 06 07 08 09

10                    00 01 FC 10 00 00 00 00 00 00
Pi                    00 00 FC 31 41 59 26 53 58 98
-Pi                   80 00 FC 31 41 59 25 53 58 98
9.99E999              00 E7 FF 99 90 00 00 00 00 00
2.5E-35               00 DD FB 25 00 00 00 00 00 00
File format of .85P files
=========================
Compiled by Magnus Hagander (mha@algonet.se)

The .85P files are TI-85 programs.
They can appear in two different ways: Tokenized or non-tokenized.
The TI-85 will tokenize a program when it's first run, and de-tokenize
it as soon as the editor is opened. This is because a program will run
faster when tokenized, but can only be edited when non-tokenized.

The format of a tokenized program is:

Offset    Length    Comment
======    ======    =======
00h       02h       Word: Length of program
02h       <xx>      Program data.
   Each line in the program data is terminated by character 6F.
   If the 6F character at the final row of the program is changed into
   FF, the program will be edit-locked.


The format of a non-tokenized program is:

Offset    Length    Comment
======    ======    =======
00h       02h       Word: Length of program
02h       01h       Byte: Always 00h to identify non-tokenized program
03h       <xx>      Program data.
   Each line in the program is terminated by character D6, _NOT_ by
   CR/LF squence(s). A non-tokenized program can't be edit-locked.

File format of .85S files
=========================
Compiled by Magnus Hagander (mha@algonet.se)

The .85S files are TI-85 strings.
They can hold any characters in the TI-85's set, except for 00h.

The format of a string is:

Offset    Length    Comment
======    ======    =======
00h       02h       Word:Length of string
02h       <cc>      String data.

File format of .85V files
=========================
Compiled by Magnus Hagander (mha@algonet.se)


The .85V files are TI-85 vectors. It can contain both real and complex
vectors.

The vectors have exactly the same format as the matrixes (see 85M.txt),
but their vertical dimension (Y dimension) is locked to 1.
