// DIE's signature file

init("compiler","Borland Pascal");

function detect(bShowType,bShowVersion,bShowOptions)
{
    if(MSDOS.compareEP("9AFFFF00009AFFFF00005589E531C09AFFFF0000"))
    {
        sVersion="7.0*";
        bDetected=1;
    }
    else if(MSDOS.compareEP("B8....BB....8ED08BE38CD88EC00E1FA1....25....A3....E8....833E......75"))
    {
        sVersion="7.0*";
        sOptions="Protected Mode";
        bDetected=1;
    }
    else if(MSDOS.compareEP("B8....8ED88C......8CD38CC02BD88BC405....C1....03D8B4..CD210E"))
    {
        sVersion="7.0*";
        bDetected=1;
    }
    else if(MSDOS.compareEP("9a########ba....8eda8c06....33ed8bc405....b1..d3e88cd203c2a3....a3"))
    {
        sVersion="7.0";
        bDetected=1;
    }
    else if(MSDOS.compareEP("9a########ba....8eda8c06....33ede8....e8....8bc405....b1..d3e88cd203c2a3....a3....0306....a3....a3....a3....a3....8e06....26a1....a3....c706"))
    {
        sVersion="6.0";
        bDetected=1;
    }
    else if(MSDOS.compareEP("9a########06ba....8eda268b3e....8ec25b8bef83ed..1eb8....8ed8b9....2bc8d1e1"))
    {
        sVersion="6.0-7.0";
        bDetected=1;
    }
    else if(MSDOS.compareEP("9a########ba....8eda8c06....8bc405....a3....8c16....05....b1..d3e88cd203c2a3....a3"))
    {
        sVersion="6.0-7.0";
        bDetected=1;
    }
    else if(MSDOS.compareEP("9a########ba....8edae8....8c06....33ed8bc405....b1..d3e88cd203c2c706"))
    {
        sVersion="6.0-7.0";
        bDetected=1;
    }
    else if(MSDOS.compareEP("9a########5589e50ee8$$$$5589e583ec..31c0"))
    {
        sVersion="6.0-7.0";
        bDetected=1;
    }
    else if(MSDOS.compareEP("9a########ba....8eda8c06....8bc405....b1..d3e88cd203c2a3....a3....26a1....2d....a3....c706"))
    {
        sVersion="4.0-6.0";
        sOptions="1987";
        bDetected=1;
    }
    else if(MSDOS.compareEP("9a########54583bc475..9c585080cc..509d9c589d80e4..75..bb....e8....b8....cd21ba....8eda"))
    {
        sVersion="6.0-7.0";
        sOptions="1992 by Borland & Eagle Performance Software";
        bDetected=1;
    }
    else if(MSDOS.compareEP("9a........5589e5bf....0e57e8$$$$f9"))
    {
        sName="Turbo Pascal";
        sVersion="6.0-7.0";
        bDetected=1;
    }
    else if(MSDOS.compareEP("9a########b8....8ed88c06....cb"))
    {
        sName="Turbo Pascal";
        sVersion="6.0-7.0";
        bDetected=1;
    }
    else if(MSDOS.compareEP("9a########ba....8eda8c06....b430cd2186c43d....73..0e1f"))
    {
        sName="Turbo Pascal";
        sVersion="6.0-7.0";
        bDetected=1;
    }
    else if(MSDOS.compareEP("31ed9a########2e8e1e....b451cd21891e....803e......74..f706........74..e8"))
    {
        sName="Turbo Pascal";
        sVersion="6.0-7.0";
        bDetected=1;
    }
    if(MSDOS.compareEP("9a########f860f972..8bdc36c51f83c3..807f....74..807f"))
    {
        sName="Turbo Pascal";
        sVersion="6.0-7.0";
        bDetected=1;
    }
    else if(MSDOS.compareEP("9A0000"))
    {
        var nDataSeg=MSDOS.readWord(MSDOS.getEntryPointOffset(3));
        var nOffset=MSDOS.AddressToOffset(nDataSeg);
        nOffset=MSDOS.findSignature(nOffset,Math.min(1024,MSDOS.getSize()-nOffset),
                                    "'Portions Copyr	ight (c) 1983,9'..' Borland'");
        if(nOffset!=-1)
        {
            switch(MSDOS.getString(nOffset+29,1))
            {
            case "0": sVersion="5.0"; sName="Turbo Pascal"; break; // guess
            case "1": sVersion="6.0"; sName="Turbo Pascal"; break; // guess
            case "2": sVersion="7.0"; break;
            }
            bDetected=1;
        }
    }

    return result(bShowType,bShowVersion,bShowOptions);
}
