// DIE's signature file
// Author: Jason Hood <jadoxa@yahoo.com.au>

init("compiler","Borland C/C++");

function detect(bShowType,bShowVersion,bShowOptions)
{
    var nOffset=0;
    if(MSDOS.compareEP("FB"))
    {
        nOffset=1;
    }
    if(MSDOS.compareEP("BA....2E8916....B430CD218B2E02008B1E2C008EDA",nOffset))
    {
        var nDataSeg=MSDOS.readWord(MSDOS.getEntryPointOffset(nOffset+1));
        nOffset=MSDOS.AddressToOffset(nDataSeg);
        bDetected=1;
    }
    else if(MSDOS.compareEP("8CCA2E8916....B430CD218B2E02008B1E2C008EDAA3"))
    {
        var nDataOfs=MSDOS.readWord(MSDOS.getEntryPointOffset(22));
        nOffset=MSDOS.AddressToOffset(0,nDataOfs-120);
        bDetected=1;
    }
    nOffset=MSDOS.findString(nOffset,64," - Copyright ");
    if(nOffset!=-1)
    {
        sVersion=MSDOS.getString(nOffset+13,4);
        if(MSDOS.compare("43",nOffset-1))
        {
            sName="Turbo C";
            if(sVersion=="(c) ")
            {
                sVersion=MSDOS.getString(nOffset+17,4);
            }
        }
        else if(MSDOS.compare("'Turbo'",nOffset-9))
        {
            sName="Turbo C/C++";
        }
        else if(sVersion=="1991")
        {
            sVersion="3.1";
        }
        else if(sVersion=="1994")
        {
            sVersion="4.X";
        }
        bDetected=1;
    }
    if(MSDOS.compareEP("b4..cd103c..74..b8....cd10ba....2e8916....8b2e....8b1e....8eda8c06....891e....892e....a1"))
    {
        sVersion="1991";
        bDetected=1;
    }
    else if(MSDOS.compareEP("ba....2e8916....b430cd218b2e....8b1e....8edaa3....8c06....891e....892e....e8"))
    {
        sVersion="1991";
        bDetected=1;
    }
    else if(MSDOS.compareEP("ba....2e8916....b430cd218b2e....8b1e....8edaa3....8c06....891e....892e....c43e....8bc78bd8"))
    {
        sVersion="1988";
        bDetected=1;
    }
//moved from Turbo C.sg
    else if(MSDOS.compareEP("BA....2E89......B4..CD218B......8B......8EDAA3....8C......89......89......C7..........E8....C4......8bc78bd8b9....26........75"))
    {
        sName="Turbo C";
        sVersion="1988";
        bDetected=1;
    }
    else if(MSDOS.compareEP("BA....2E89......B4..CD218B......8B......8EDAA3....8C......89......89......8cd22bea8b3e....81ff....73..bf....893e....b1"))
    {
        sName="Turbo C";
        sVersion="1988";
        bDetected=1;
    }
    else if(MSDOS.compareEP("BA....2E89......B4..CD218B......8B......8EDAA3....8C......89......53E8....0733FF2BDB8BC3B9....FCF2AEE3..4326......75..80"))
    {
        sName="Turbo C";
        sVersion="1990";
        bDetected=1;
    }
    else if(MSDOS.compareEP("FBBA....2E89......B430CD218B......8B......8EDAA3....8C......89......89......C706........E8....C4......8BC78BD8B9....2681"))
    {
        sName="Turbo C";
        sVersion="1987";
        bDetected=1;
    }
    else if(MSDOS.compareEP("FB8cca2E89......B430CD218B......8B......8EDAA3....8C......89......89......C706........E8....C4......8BC78BD8B9....2681"))
    {
        sName="Turbo C";
        sVersion="1987";
        bDetected=1;
    }
    else if(MSDOS.compareEP("BA....2E89......B430CD218B......8B......8EDAA3....8C......89......89......C706........8ec333c0b9....8bf88bd82681......75"))
    {
        sName="Turbo C";
        sVersion="1987";
        bDetected=1;
    }
    else if(MSDOS.compareEP("8cca2E89......B430CD218B......8B......8EDAA3....8C......89......89......C706"))
    {
        sName="Turbo C";
        sVersion="1988";
        bDetected=1;
    }
    else if(MSDOS.compareEP("8cca2E89......B430CD218B......8B......8EDAA3....8C......89......89......E8"))
    {
        sName="Turbo C";
        sVersion="1990";
        bDetected=1;
    }
    else if(MSDOS.compareEP("8cd8bb....8edb8cd38bccfa8e16....bc....fbe8....fa8ed38be1fbea"))
    {
        sName="Turbo C";
        sVersion="1988";
        bDetected=1;
    }

    return result(bShowType,bShowVersion,bShowOptions);
}
