// DIE's signature file
// Author: LinXP

init("image","ZSoft Paintbrush (.PCX)");

function detect(bShowType,bShowVersion,bShowOptions)
{
    if(Binary.getSize()>=0x0E)
    {
        if(Binary.compare("0a"))
        {
            bDetected=true;
            sOption(Binary.read_uint16(0x08)+"x"+Binary.read_uint16(0x0A));
            switch(File.read_uint8(0x02))
            {
                case 0:                 break;
                case 1: sOption("RLE"); break;
                default: bDetected=false;
            }
            switch(File.read_uint8(0x03))
            {
                case 1: sOption("1bpp"); break;
                case 2: sOption("2bpp"); break;
                case 4: sOption("4bpp"); break;
                case 8: sOption("8bpp"); break;
                default: bDetected=false;
            }
            switch(File.read_uint8(0x01))
            {
                case 0: sOption("PC Paintbrush version 2.5 using a fixed EGA palette"); break;
                case 2: sOption("PC Paintbrush version 2.8 using a modifiable EGA palette"); break;
                case 3: sOption("PC Paintbrush version 2.8 using no palette"); break;
                case 4: sOption("PC Paintbrush for Windows"); break;
                case 5: sOption("PC Paintbrush version 3.0, including 24-bit images"); break;
                default: bDetected=false;
            }
        }
    }

    return result(bShowType,bShowVersion,bShowOptions);
}