[Dashboard\Opel\Vectra\Vectra B VDO 93C46]
#opel vectra b 93c46.doc

Size(280,300); 

Form 
{
    Group("Пробег",35,13,120,50)
    {
        Digit(Distance," ",5,18,70);
        Label(lbkm,"КМ",90,20);
    }
    Group("Идентификация",5,70,270,45)
    {
        Label(iden," ",0,20);
    }
    Group("Информация",5,120,270,45) 
    {
        Label(msg," ",0,18);
    }    
    Group("Описание",5,170,270,85) 
    {
        Label(lb1,"Калькулятор пробега для Opel Astra.",0,20);
        Label(lb2,"EEPROM 93C46",0,35);
        Label(lb3,"Введите нужное значение в окне <Пробег>.",0,50);
        Label(lb4,"Нажмите кнопку <Применить>.",0,65);
    }
    Picture(Logo,"Opel.bmp",190,17,0,0);
}


OnShow 
{
	Var0 = 0;
	if(Var0 != 0)
	{
		msg.Color = 0x0000FF;
		msg.Bold = 1;
		msg = "Неверный дамп!";
		Distance = 0;
	}
	else
	{
		iden = "OPEL P/N: 90"+#b.@0x18+#b.@0x19+#b.@0x1a;
                
                Var2 = (@0x00 | (@0x01 << 8)) ^ 0xFFFF;
                Var2 = Var2 + ((@0x02 | (@0x03 << 8)) ^ 0xFFFF);
                Var2 = Var2 + ((@0x04 | (@0x05 << 8)) ^ 0xFFFF);
                Var2 = Var2 + ((@0x06 | (@0x07 << 8)) ^ 0xFFFF);
                Var2 = Var2 + ((@0x08 | (@0x09 << 8)) ^ 0xFFFF);
                Var2 = Var2 + ((@0x0a | (@0x0b << 8)) ^ 0xFFFF);
                Var2 = Var2 + ((@0x0c | (@0x0d << 8)) ^ 0xFFFF);
                Var2 = Var2 + ((@0x0e | (@0x0f << 8)) ^ 0xFFFF);
        	msg.Color = 0xFF0000;
        	msg.Bold = 1;
        	msg = "Дамп ОК. Введите новый пробег.";
        	Distance = Var2 * 2;
	}
}

OnApply 
{
    Var5 = 0;
    Var2 = Distance >> 4;
    if(Var2 > 0xFFFF) {Var5 = 1;}
    if(Var2 < 0x06)   {Var5 = 1;}
    if(Var5 != 0)
    {
        msg.Color = 0x0000FF;
        msg.Bold = 1;
        msg = "Пробег должен быть от 100 до 999900 км";
    }
    else
    {
        Var3 = 0x00;
        while(Var3 != 0x10)
        {
            @Var3 = Var2 & 255 ^ 0xFF;		Var3 = Var3 + 1;
            @Var3 = (Var2 >> 8 & 255) ^ 0xFF;	Var3 = Var3 + 1;
        }
        msg.Color = 0xFF0000;
        msg.Bold = 1;
        msg = "Дамп OK. Новый пробег записан.";
        Var2 = Var2 << 4;
	Distance = Var2;
    }
}

