This document covers the protocol used between hand-helds and ticalcs2 library for ROM dumping.
Copyright (c) 2005-2006 Romain Liévin et Benjamin Moody

This protocol has been designed to be easy, reliable, extendable and resumable.

ROM dumping protocol (LIO or USB are the same):

1°) PC/TI always send data like this:

command | data length | data (if any) | checksum
 word   |  word	      | bytes         | word

The protocol uses words/longs whenever possible (even number of bytes)

Data are sent in Little Endian (LE) format (LSB, MSB) which is the natural format
of Z80 (TI8x) and i86 processors (LSB at first); m68k processor (TI9x) uses 
Big Endian (BE) format (MSB at first).

Checksum is calculated in a byte fashion on the whole block (from command to data).

Possible commands are:
- AA55 (pc): is ready ? (data length is 0)
- 0000 (ti): not ready	(data length is 0)
- 0001 (ti): ready		(data length is 0)
- 0002 (pc): exit		(data length is 0)
- 0003 (pc): request ROM dump size (data length is 0)

- 0005 (pc): request block at addr (this is a base addr, not the real ROM address) (data length is 4 bytes)
- 0006 (ti): data
- 0007 (ti): repeated data

The 0007 command saves :
~ 830 blocks on TI92+ (2048) => 40%
~1730 blocks on TI84+ (2048) => 85%
~1408 blocks on Titanium (4MB) => 35%

2°) TI can reply with the following packets (example of transmission)

PC: AA55 0000 FF00			check whether ready (for sync after a transfer interrupt)
TI: 0001 0000 0001			ready

PC: 0003 0000 0003			request ROM size
TI: 0003 0004 LLLHHLHH chk	returns size as a long

PC: 0005 0004 00000000 0009	request block at addr
TI: 0006 0400 1024 bytes of data chk

PC: 0005 0004 00000400 0409	request block at addr
TI: 0006 0400 1024 bytes of data chk

PC: AA55 0000 FF00			check whether ready (for sync after a transfer interrupt)
TI: 0001 0000 0001			ready

PC: 0005 0004 00000400 000D	request block at addr
TI: 0006 0400 1024 bytes of data chk

PC: 0005 0004 00000800 0011	request block at addr
TI: 0007 0004 0400 00FF 000A		1024 bytes filled with 0x00FF

PC: 0002 0000 0002			exit dumper
TI: 0002 0000 0002

3°) transmission error (timeout with SilverLink for instance)

Send this until dumper replies (used to synchronize again):
PC: AA55 0000 FF00		check whether ready (for sync after a transfer interrupt)
TI: 0001 0000 0001		ready

goes on...

4°) unknown packet

PC: 1234 0000 1234		unknown packet
TI:						error: ignored => wait for next command
