Crack Art

From MultimediaWiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
  • Company: Detlef Röttger & Jan Borchers
  • Extensions: .ca1, .ca2, .ca3

Crack Art was an image drawing program for the Atari ST. Here are the m68k assembly compression and decompression routines, provided by the original program.

16-bit words are stored in big-endian order.

File format

typedef crackart_file {
 uint16_t magic;                /* "CA" */
 uint8_t compressed;            /* 0 = no compression, 1 = compressed */
 uint8_t resolution;            /* 0 = low (320x200x16), 1 = medium (640x200x4), 2 = high (640x400x2) */
 uint16_t palette[palsize];     /* palsize = 16 (low res), 4 (med res) or 0 (high res) */
 uint8_t data[]
} crackart_file;

If the file is uncompressed, sizeof(data) == 32000 bytes of raw video memory.

Decompression algorithm

Yet another RLE variant:

data[0] == ESCape character
data[1] == initial value (fill screen memory with this value)

data[2]<<8 + data[3] == offset, this value is constantly added to the current byte position in order to
                                find the next byte position. If the position >= 32000, it jumps back to
                                the first unwritten byte position (initial write is not taken into account).
                                This is used to 'jump' through the data and accomplish plane-by-plane compression.

data[4 ....] == RLE compressed data

[pseudocode]

while (!eof et cetera) {
    a = data[x++]

    if (a != ESC) output a, continue

    b = data[x++]

    if (b == ESC) output ESC, continue

    c = data[x++]

    if (b == 2) {
        if (!c) break               /* end decompression */
        c << 8
        c += data[x++]
        skip c+1 bytes, continue    /* or output c+1 times initial_value */
    }
    if (b == 1) {
        c <<= 8
        c += data[x++]
    }
    if (b <= 1) {                   /* 0 and 1 */
        d = data[x++]
        output c+1 times d, continue
    }

    output b times c                /* b>2 && b!= ESC */
}

Uncompressed data format

The image data is stored in a planar format.

Atarist lowres.png