[Dashboard\Motobikes\Yamaha\R1 93C56]

Size(280,280); 

Form
{
	Group("Пробег",5,5,120,80)
	{
		Digit(Distance," ",5,18,50);
		Label(lb1,"KM",80,20);
		Digit(Miles," ",5,48,50);
		Label(lb6,"MILES",80,50);
	}
	Group("Информация",5,88,270,45)
	{
		Label(message," ",0,18);
	}
	Group("Описание",5,135,270,100) 
	{
        Label(lb4,"Калькулятор для Yamaha R1.",0,20);
        Label(lb5,"EEPROM 93C56",0,35);
		Label(lb2,"Введите нужное значение в окне ПРОБЕГ",0,55);
		Label(lb3,"и нажмите кнопку <Применить>.",0,70);
	}
	Picture(Picture1,"Yamaha.bmp",170,20,0,0);
}


OnShow 
{
    Message.Bold = 1;
    
   Var0 = 0;
    Var1 = (@0x81 << 8) | @0x80;
    Var2 = (@0x83 << 8) | @0x82;
    Var3 = (@0x85 << 8) | @0x84;
    Var4 = (@0x89 << 8) | @0x88;
    Var5 = (@0x8d << 8) | @0x8c;
    Var6 = (@0x91 << 8) | @0x90;
    Var7 = (@0x95 << 8) | @0x94;
    Var8 = (@0x99 << 8) | @0x98;
    Var9 = (@0x9d << 8) | @0x9c;
    Var11 = (@0xc1 << 8) | @0xc0;
    Var12 = (@0xc3 << 8) | @0xc2;
    Var13 = (@0xc5 << 8) | @0xc4;
    Var14 = (@0xc9 << 8) | @0xc8;
    Var15 = (@0xcd << 8) | @0xcc;
    Var16 = (@0xd1 << 8) | @0xd0;
    Var17 = (@0xd5 << 8) | @0xd4;
    Var18 = (@0xd9 << 8) | @0xd8;
    Var19 = (@0xdd << 8) | @0xdc;

    Var12 = Var12 ^ 0xFFFF;
    Var2 = Var2 ^ 0xFFFF;
    if(Var1 != Var2) { Var0 = Var0 + 1; }
    if(Var11 != Var12) { Var0 = Var0 + 1; }
     if(Var0 != 0)
    {
        message.Color = 0x0000FF; 	
        Message = "Неверный дамп!";     
        Distance = 0;
        Miles = 0;                   
    }
    else
    {
        Var10 = (((((((Var1 + Var3) + Var4) + Var5) + Var6) + Var7) + Var8) + Var9) * 2;
        Var20 = (((((((Var11 + Var13) + Var14) + Var15) + Var16) + Var17) + Var18) + Var19) * 2;
        message.Color = 0xFF0000;                    
        message = "Дамп ОК. Введите новый пробег.";  
        Distance =  Var10;
        Miles = Var20;  
    }                          
}

OnApply
{
	Var1 = Distance;

	Var0 = 1;
	if(Var1 < 100)      { Var0 = Var0 - 1; }
	if(Var1 > 999900)   { Var0 = Var0 - 1; }

	if(Var0 = 0)
	{
		Message.Color = 0x0000FF;
		Message.Bold = 1;
		Message = "Пробег должен быть от 100 до 999900 км"; 
	}
	else
	{
		Var2 = 0x80;
		Var3 = 0x81;
		Var1 = Var1 / 16;
		Var4 = Var1 ^ 0xFFFF;
		while(Var2 != 0xa0)
		{
			@Var2 = Var1;		Var2 = Var2 + 2;
			@Var3 = Var1 >> 8;	Var3 = Var3 + 2;
			@Var2 = Var4;		Var2 = Var2 + 2;
			@Var3 = Var4 >> 8;	Var3 = Var3 + 2;
		}
		Var5 = Distance;
		Var5 =(Var5 / 16) * 10;

		Var2 = 0xC0;
		Var3 = 0xC1;
		Var5 = Var5 / 16;
		Var4 = Var5 ^ 0xFFFF;
		while(Var2 != 0xE0)
		{
			@Var2 = Var5;		Var2 = Var2 + 2;
			@Var3 = Var5 >> 8;	Var3 = Var3 + 2;			
			@Var2 = Var4;		Var2 = Var2 + 2;
			@Var3 = Var4 >> 8;	Var3 = Var3 + 2;
		}

		Message.Color = 0xFF0000;
		Message.Bold = 1;
		Message = "Дамп OK. Новый пробег записан.";
		Distance = Distance;
	}
}