Casio commuication specifications
=================================

This document is (c)Copyright 1996 Tom Wheeley and Tom Lynn, although I
suppose technically the information contained within isn't :-)  You may
distribute it freely, so long as this message is not removed.  Many sections
are imcomplete, and possibly inaccurate (You Have Been Warned!)

Most of this information was obtained by reading the QBASIC program by
Bob Parish.  Symbolic names for all the `magic numbers' used below are in
the file casport.h

Overview
========

The communication system of the calculator is similar to the .CAS file format,
simply with added control and handshaking signals.

Single Program
==============

Transmitter                         Receiver
------------------------------------------------------------------------
Sends 0x16

                                    Acknowledges with 0x13

Sends colon (0x3a)
Sends 38 byte header
 - bytes 3 and 4 are the data size
   in big-endian:
   size = 256 * (3rd) + (4th)
Sends Checksum.
 - Sum of the 38 bytes of header
   plus the checksum = 0, mod 256

                                    Sends Response code:
                                     0x06 - OK
                                     0x2b - Checksum error
                                     0x24 - Out of memory
                                     0x3f - Bad header?
                                     0x21 - Program area full
If Program area full, sends:
 0x15 - cancel
 0x06 - over write
                                    If over write, sends 0x06 to acknowledge

{After Handshakes}

{If header denotes a PZ Multiple Program file}

Send a ':' (0x3a)

Send the 38 x 5 byte program
headers as described in cas_spec.

Send checksum, calculated in the
same way as for the header.

                                    Send 0x06 if checksum OK,
                                    Unknown if error, probably 0x2b
                                    
{endif}

Send a ":" (0x3a)

Send the data stream

Send checksum, calculated in the
same way as for the header.
                                    Send 0x06 if checksum OK,
                                    Unknown if error, probably 0x2b
{finish}

Conclusion
==========

I expect that all the different types of data can be transmitted in a very
similar fashion, but I haven't attempted it yet.  The largest problem is
working out how large the data is going to be.  If that can be determined
then the data is just treated as meaningless binary data.
