Paintworks file format

From Atari Wiki
Revision as of 23:09, 28 January 2017 by Lp (talk | contribs) (rewording)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Paintworks    *.SC0 *.CL0 (st low resolution)
              *.SC1 *.CL1 (st medium resolution)
              *.SC2 *.CL2 (st high resolution)
              *.PG0 (st low resolution, double high)
              *.PG1 (st medium resolution, double high)
              *.PG2 (st high resolution, double high)

Early versions of Paintworks were called N-Vision. These are often mistaken as
NEOchrome files. One should not rely on the file extension to determine the contents.

1 word       file id [0x00]
                 recommend using 'secondary file id' for identification
1 word       resolution [0 = low, 1 = medium, 2 = high]
                 recommend using 'flags' to determine resolution
16 words     palette
12 bytes     file name, usually ["        .   "]
1 word       ?
1 word       ?
1 word       ?
9 bytes      secondary file id ["ANvisionA"]
1 byte       flags, bit field: cxrrtttt
                 c = compression flag [1 = compressed]
                 x = not used
                 r = resolution [0 = low, 1 = medium, 2 = high]
                 t = type [0 = page, 1 = screen, 2 = clipart, 4 = pattern]
                     page = double high, thus 320x400, 640x400, 640x800
                     screen = standard st resolutions
                     clipart = standard st resolutions
                     pattern = no documentation at this time
64 bytes     ?
---------
128 bytes    total for header

?            image data:                                      
Uncompressed images are simply screen dumps as one might expect.

Compressed images are a two step process, RLE decoding and re-ordering.
RLE decompression:

/* Written by Lonny Pursell - placed in to Public Domain 1/28/2017 */
void decode_rle(uint8 *data, uint8 *bmap, uint32 bms) {
    uint8   cmd, chr;
    uint16  i;
    uint32  src=0, dst=0, cnt=0;
    do {
        cmd = data[src++];
        if (cmd & 0x80) {                   /* literal? */
            cmd = cmd & 0x7f;
            memcpy(&bmap[dst], &data[src], (uint32)cmd);
            dst = dst + (uint32)cmd;
            src = src + (uint32)cmd;
        } else {                            /* repeat? */
            chr = data[src++];
            for (i=0; i<cmd; i++) {
                bmap[dst++] = chr;
            }
        }
        cnt = cnt + cmd;
    } while (cnt<bms);
}

The uncompressed data is arranged as follows:

ST low resolution:
    All of plane 0..., all of plane 1..., all of plane 2..., all of plane 3...
ST medium resolution
    All of plane 0..., all of plane 1...
ST high resolution: 
    No rendering required.

Back to ST Picture Formats