[Dashboard\Renault\Master\Master 93C66]

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,"Калькулятор пробега для Renault Master.",0,20);
        Label(lb2,"EEPROM 93C66",0,35);
        Label(lb3,"Введите нужное значение в окне <Пробег>.",0,50);
        Label(lb4,"Нажмите кнопку <Применить>.",0,65);
    }
    Picture(Logo,"Renault.bmp",190,17,0,0);
}


OnShow 
{
	Var0 = 0;
        if(@0x169 != 0x56) {Var0 = 1;}
        if(@0x16a != 0x46) {Var0 = Var0 + 1;}
	if(Var0 != 0)
	{
		msg.Color = 0x0000FF;
		msg.Bold = 1;
		msg = "Неверный дамп!";
		Distance = 0;
	}
	else
	{
		iden = "VIN: "+#c.@0x169+#c.@0x16a+#c.@0x16b+#c.@0x16c+#c.@0x16d+#c.@0x16e+#c.@0x16f+#c.@0x170+#c.@0x171+#c.@0x172+#c.@0x173+#c.@0x174+#c.@0x175+#c.@0x176+#c.@0x177+#c.@0x178+#c.@0x179;
                
                Var1 = (@0x03 <<24) | (@0x02 <<16) | (@0x01 <<8) | @0x00;
        	msg.Color = 0xFF0000;
        	msg.Bold = 1;
        	msg = "Дамп ОК. Введите новый пробег.";
        	Distance = Var1 / 200;
	}
}

OnApply 
{
    Var0 = 0;
        if(@0x169 != 0x56) {Var0 = 1;}
        if(@0x16a != 0x46) {Var0 = Var0 + 1;}
	if(Var0 != 0)
	{
		msg.Color = 0x0000FF;
		msg.Bold = 1;
		msg = "Неверный дамп! Запись прекращена!";
		Distance = 0;
	}
	else
    {
    Var5 = 0;
    Var2 = Distance;
    if(Var2 > 999900) {Var5 = 1;}
    if(Var2 < 100)   {Var5 = 1;}
    if(Var5 != 0)
    {
        msg.Color = 0x0000FF;
        msg.Bold = 1;
        msg = "Пробег должен быть от 100 до 999900 км";
    }
    else
    {
       Var1 = Distance;
       Var1 = Var1 * 200;
       Var3 = 0x00;
        while(Var3 != 0x0a)
        {
            @Var3 = Var1 & 255;
            @Var3.mismatch = 1;
            Var3 = Var3 + 1;

            @Var3 = Var1 >> 8 & 255;
            @Var3.mismatch = 1;
            Var3 = Var3 + 1;
            
            @Var3 = Var1 >> 16 & 255;
            @Var3.mismatch = 1;
            Var3 = Var3 + 1;

            @Var3 = Var1 >>24 & 255;
            @Var3.mismatch = 1;
            Var3 = Var3 + 2;
        }
        Var6 = ((((@0x00 + @0x01) + @0x02) + @0x03)-1) ^ 0xFF;
        @0x04 = Var6;
        @0x09 = Var6;
        msg.Color = 0xFF0000;
        msg.Bold = 1;
        msg = "Дамп OK. Новый пробег записан.";
        
	
    }
    }
}

