PhotoChrome file format

From Atari Wiki
Jump to navigation Jump to search
PhotoChrome     *.PCS (low resolution only)

1 word          0x0140 (hex) x-resolution (always 320)
1 word          0x00C8 (hex) y-resolution (always 200)
1 byte          00 = single screen mode
                nonzero value's = alternating screen mode,
                bit 0 (0x01) not set: second screen data is xor'ed with first screen
                bit 1 (0x02) not set: second color palette is xor'ed with first
1 byte          bit 0 (0x01) set: 50 Hz mode, when not set 60 Hz mode
?? bytes        compressed screen data
?? bytes        compressed palette
?? bytes        compressed second screen data (in case of alternating screens)
?? bytes        compressed second palette
-------------
 > 18 bytes      total

Screen compression scheme:
1 word          total number of control bytes that follow
1 control byte  x
                x < 0 : copy -x literal bytes (1 - 128)
                x = 0 : next word specifies the number of times the following byte 
                        has to be copied (0-65535)
                x = 1 : next word specifies the number of bytes to be copied (0-65535)
                x > 1 : repeat the next byte x times (2-127)

The 4 bitplanes are separated, first 8000 bytes of the first bitplane, then 8000 bytes 
for the second, 8000 bytes for the third and 8000 bytes for the fourth; a total of 32000 bytes.

Palette compression scheme:
the palette compression scheme is the same as the screen compression but it works with 
16 bit words
1 word          total number of control bytes that follow
1 control byte  x
                x < 0 : copy -x literal words (1 - 128)
                x = 0 : next word specifies the number of times the following word 
                        has to be copied (0-65535)
                x = 1 : next word specifies the number of words to be copied (0-65535)
                x > 1 : repeat the next word x times (2-127)

In total 9616 palette entries are stored. 200 scanlines with 3 palettes
(48 colors) each, plus one final palette (16 colors). PhotoChrome files
with a few extra entries have been found. The first scanline usually
contains no data.

/*
 *  Given an x-coordinate and a color index, returns the corresponding
 *  Photochrome palette index.
 *
 *  by Hans Wessels; placed in the public domain January, 2008.
 */
int find_pcs_index(int x, int c)
{
	int x1=4*c;
	int index = c;
	if(x>=x1)
	{
		index+=16;
	}
	if((x>=(x1+64+12)) && (c<14))
	{
		index+=16;
	}
	if((x>=(132+16)) && (c==14))
	{
		index+=16;
	}
	if((x>=(132+20)) && (c==15))
	{
		index+=16;
	}
	x1=10*c;
	if((c&1)==1)
	{
	  x1-=6;
	}
	if((x>=(176+x1)) && (c<14))
	{
		index+=16;
	}
	return index;
}

Back to ST Picture Formats