Spectrum 512 Smooshed file format

From Atari Wiki
Jump to navigation Jump to search
Spectrum 512 (Smooshed), or Anispec, see below    *.SPS

   This format compresses Spectrum 512 pictures better than the standard
method.  There are at least two programs that support this format, SPSLIDEX
and ANISPEC, although the two seem to differ slightly in their interpretation
of the format.
   One point of interest: Shamus McBride deciphered this format without an ST!
 
1 word          5350 (hex) ("SP")
1 word          0 (reserved for future use)
1 long          length of data bit map
1 long          length of color bit map
<= 32092 bytes  compressed data bit map
<= 17910 bytes  compressed color bit map
----------
< 50014  bytes  total

Data compression:

   Compression is via a modified run length encoding (RLE) scheme,
similar to that used in Spectrum Compressed (*.SPC) pictures.

The data map is stored as a sequence of records.  Each record consists of a
header byte followed by one or more data bytes.  The meaning of the header
byte is as follows:

        For a given header byte, x (unsigned):

          0 <= x <= 127    Use the next byte x + 3 times
        128 <= x <= 255    Use the next x - 128 + 1 bytes literally
                           (no repetition)

There are two kinds of *.SPS files.  The type is defined by the least significant 
bit of the last byte in the color bit map.

If the bit is set the data appears in the same order as *.SPC files:

        1. Picture data, bit plane 0, scan lines 1 - 199
        2. Picture data, bit plane 1, scan lines 1 - 199
        3. Picture data, bit plane 2, scan lines 1 - 199
        4. Picture data, bit plane 3, scan lines 1 - 199

If the bit is not set the data is encoded as byte wide vertical strips:

        Picture data, bit plane 0, scan line   1, MSB.
        Picture data, bit plane 0, scan line   2, MSB.
        Picture data, bit plane 0, scan line   3, MSB.
        . . .
        Picture data, bit plane 0, scan line 199, MSB.
        Picture data, bit plane 0, scan line   1, LSB.
        Picture data, bit plane 0, scan line   2, LSB.
        . . .
        Picture data, bit plane 0, scan line 199, LSB.
        Picture data, bit plane 1, scan line   1, MSB.
        . . .
        Picture data, bit plane 3, scan line 198, LSB
        Picture data, bit plane 3, scan line 199, LSB.

A for loop to process that data would look like

        for (plane = 0; plane < 4; plane++)
            for (x = 0; x < 320; x += 8)
                for (y = 1; y < 200; y++)
                    for (x1 = 0; x1 < 8; x1++)
                        image[y, x + x1] = ...

Color map compression:

   Color map compression is similar to *.SPC color map compression, but
the map is compressed as a string of bits, rather than words.  There are
597 records (one for each palette). Each record is composed of a 14-bit
header followed by a number of 9-bit palette entries.  The 14-bit header
specifies which palette entries follow (1 = included, 0 = not included).
The most significant bit of the header refers to palette entry 1, while
the least significant bit refers to palette 14.  Palette entries 0 and 15
are forced to black (zero).  Each palette entry is encoded as "rrrgggbbb".

The format of the palette is described above in the section on uncompressed
Spectrum pictures (*.SPU).

<Spectrum 512 (Anispec)>          *.SPS
Format for animated Spectrum pictures.

1 word          5353 (hex) ("SS")
30 bytes        unknown header bytes
51104 bytes     uncompressed spectrum picture (see SPU format)
?? bytes        animation data (unknown format) 

See also Spectrum 512 file format

Back to ST Picture Formats