
THIS FILE IS OUT OF DATE: CURRENT FILE VERSION NUMBER IS 4
FILES OF VERSIONS 2 OR 3 WILL BE LOADED BY ISIS ON MOST MACHINES.

File format
-----------

Name:    Isis
Type:    &177
Version: 2

Header
------

00:     'Isis'
04:     File version number
08:     Protection type:  0  none
                          1  machine ID
                          2  password
12:     Protection test:  'TEST' encoded using above method
16:     Number of columns in sheet
20:     Number of rows in sheet
24:     Memory estimate (including 4Kb leeway)

Data
----

Fonts
=====

00:     Block length (when unsquashed)
04:...  Fonts block, squashed
--:     Word '-end' signifies end of squashed block

The fonts block, once unsquashed, is in a standard list format, that is:

        00:     Number of items
        04:     Size of each item (64 in this case)
        08:...  Font names, in sequential order from 0 to (n-1)

Columns
=======

00:     Block length (when unsquashed)
04:...  Columns list, squashed

Simply a list of 1-word entries, each one corresponding to the width of each
column on the sheet. Note that the block may be larger than is needed for
the number of columns as it is simply saved directly from the heap.

ColumnsM
========

Identical to columns block but contains the minimum column widths. This block
is present in version 1, or greater, files only.

Rows
====

Identical to the format of the columns list but contains the height of each
row.

RowsM
=====

Identical to rows block but contains the minimum row heights. This block
is present in version 1, or greater, files only.

Title
=====

00:     Block length (when unsquashed)
04:...  Title block, squashed
--:     Word '-end'

Obvious enough, except the length of the block may be longer than the actual
length of the title. The title is control (usually, but not guaranteed to be,
zero) terminated.

Sheet
=====

00:     Block length (when unsquashed)
04:...  Sheet data, squashed
--:     Word '-end'

The sheet block is made up of a small header, like this:

        00:     Number of columns
        04:     Number of rows
        08:     Pointer to columns list anchor (unused in file)
        12:     Pointer to rows list (unused in file)
        16:     Flags:        Bit 0     Evaluation:  1 automatic
                              Bit 1     Grid:        1 show
                              Bit 2     Labels:      1 show
                              Bit 3     Formulae:    1 show
                              Bit 4     Tools:       1 show
                              Bit 5     Fill:        1 update refs.
        20:     Protection, filled in from file header. Either 0 for none,
                1 for machine ID, or pointer to heap block anchor containing
                password.
        24:     Pointer to fonts list anchor (unused in file)
        28:     Pointer to title anchor (unused in file)
        32:     Pointer to overlays block anchor (unused in file)
        36:     Pointer to columnsM list anchor (unused in file, v1+ only)
        40:     Pointer to rowsM list anchor (unused in file, v1+ only)
        44:     Unused
        48:...  Cells
        
The cell data is basically all the sheet cells in sequential order, like this:

        (0,0) (1,0) (2,0) (3,0) ... (0,1) (1,1) (2,1) (3,1) ... (c-1,r-1)
        
So all of row 0 comes first, followd by all of row 1, then row 2 and so on.

Each cell is 256 bytes long (v2) (144 in v0 & v1) and is made up of the
following:

        00:     Type:  0  string
                       1  number
                       2  formula (string)
                       3  formula (number)
        04:     Background colour
        08:     Foreground colour
        12:     Font number (in fonts list)
        16:     Font size
        20:     Unit flags:     Bit 0   Position:    1 after
                                Bit 1   Status:      1 on
        24:     Unit name, three characters and one terminator
        28:     Justification:  0  left
                                1  centre
                                2  right
        32:     Border:         Bit 0   Left:        1 on
                                Bit 1   Bottom:      1 on
                                Bit 2   Right:       1 on
                                Bit 3   Top:         1 on
        36:     Number format, decimal places
        40:     Number flags:   Bit 0   Fixed:       1 yes
                                Bit 1   Negatives:   1 minus sign
        44:...  Cell data
        
The cell data is either a string of between zero and the cell size (256) minus
the start of cell data in length, an extended precision floating point number
or for a formula, the actual value at +44 and the textual formula (in infix
form), at +148.
        
The formula for jumping directly to a cell is:

        p=((y*c)+x)*s

Where y is the row, x is the column, c is the total number of columns and s is
the amount of memory used by each cell, currently 256 bytes.

Constants
=========

00:     Block length (when unsquashed)
04:...  Constants block, squashed
--:     Word '-end'

The constants block is also in standard list format:

        00:     Number of items
        04:     Size of each item (96 in this case)
        08:...  Constants in sequential order

Each constant is made up as follows:

        00:     Type:  'c'  cell
                       'n'  number
                       's'  string
        04:     Name (up to 16 characters, inc. terminator)
        20:     Data

The data is either two words, x and y, for cells, an extended precision fp
number or a string.

Overlays
========        

00:     Number of overlays

If more than 0 overlays:

04:...  Overlay list

Each overlay is made up as follows:

        00:...  Overlay description
        44:...  Length of overlay block when unsquashed
        48:...  Overlay data, squashed

The overlay description is:

        00:     Type:  0  graphic
                       1  text
        04:     Font number (if text, otherwise unused)
        08:     Font size (if text, otherwise unused) 
        12:     Scale (if graphic, otherwise unused)
        16:     X offset from top-left of sheet
        20:     Y offset from top-left of sheet
        24:     Width
        28:     Height
        32:     Flags (unused)
        36:     Fg colour
        40:     Bg colour

Encoding
--------

Most words after and including word 12 in the file are encoding by EORing them
with a special value. If protection is off, this value is 0 ie the word is
left alone. At present this does not include squashed blocks, only their
length words and terminating '-end' string.

If encoding using the machine ID, the two components are found using SWI
OS_ReadSysInfo with r0=2. These words (in r3 and r4) are added together and
the result used as the EOR word.

A password is padded to 24 characters with null bytes and then each word is
read and added onto a total. This total is then used.

File version
------------

If the file version at word 4 is not one that is recognised, an error should
be generated. The current file version number is 2. There is no guarantee that
later file formats will in any way be backwards compatible with earlier types.

FILE VERSIONS 0 AND 1 ARE OBSOLETE AND SHOULD NOT BE USED. They are no longer
supported by the Isis program.
