// DIE's signature file
// Author: Tembo (http://tembolab.pl/products/executable-image-viewer.html)

init("format", "Guitar Pro");

function detect(bShowType,bShowVersion,bShowOptions)
{
    if (Binary.getSize() > 31)
    {
        if (Binary.compare("'BCFZ'") || Binary.compare("'BCFS'"))
        {
            sVersion = "6.x";
            sOptions = "Tablature";
            bDetected = 1;
        }
        else if (Binary.compare("'GPAR'"))
        {
            sVersion = "6.x";
            sOptions = "Soundbank";
            bDetected = 1;
        }
        else if (Binary.compare("'FSB3'"))
        {
            sVersion = "5.x";
            sOptions = "Soundbank";
            bDetected = 1;
        }
        else
        {
            var sSignature = Binary.getString(1, Binary.readByte(0));

            if (sSignature == "FICHIER GUITAR PRO v5.10")
            {
                 sVersion = "5.1 or 5.2";
                 sOptions = "Tablature";
                 bDetected = 1;
            }
            else if (sSignature == "FICHIER GUITAR PRO v5.00")
            {
                 sVersion = "5.0";
                 sOptions = "Tablature";
                 bDetected = 1;
            }
            else if ((sSignature == "FICHIER GUITAR PRO L4.06") || (sSignature == "FICHIER GUITAR PRO v4.06"))
            {
                 sVersion = "4.6";
                 sOptions = "Tablature";
                 bDetected = 1;
            }
            else if (sSignature == "FICHIER GUITAR PRO v4.00")
            {
                 sVersion = "4.0";
                 sOptions = "Tablature";
                 bDetected = 1;
            }
            else if (sSignature == "FICHIER GUITAR PRO v3.00")
            {
                 sVersion = "3.0";
                 sOptions = "Tablature";
                 bDetected = 1;
            }
            else if (sSignature == "FICHIER GUITAR PRO v2.21")
            {
                 sVersion = "2.21";
                 sOptions = "Tablature";
                 bDetected = 1;
            }
            else if (sSignature == "FICHIER GUITAR PRO v2.20")
            {
                 sVersion = "2.20";
                 sOptions = "Tablature";
                 bDetected = 1;
            }

            else if (sSignature == "FICHIER GUITARE PRO v1.04")
            {
                 sVersion = "1.4";
                 sOptions = "Tablature";
                 bDetected = 1;
            }
            else if (sSignature == "FICHIER GUITARE PRO v1.03")
            {
                 sVersion = "1.3";
                 sOptions = "Tablature";
                 bDetected = 1;
            }
            else if (sSignature == "FICHIER GUITARE PRO v1.02")
            {
                 sVersion = "1.2";
                 sOptions = "Tablature";
                 bDetected = 1;
            }
            else if (sSignature == "FICHIER GUITARE PRO v1.01")
            {
                 sVersion = "1.1";
                 sOptions = "Tablature";
                 bDetected = 1;
            }
            else if (sSignature == "FICHIER GUITARE PRO v1")
            {
                 sVersion = "1.0";
                 sOptions = "Tablature";
                 bDetected = 1;
            }
        }
    }

    return result(bShowType,bShowVersion,bShowOptions);
}
