[Carradio\GRUNDIG\SMART RADIO MRR]

Size(310,460);  

Form {
    	Digit(Code,"Code ",70,15,100);
    	//CheckBox(ResetCounter,"Обнулить счётчик попыток",82,45);
	ComboBox(CodeRequest,"Запрос кода",72,45,50,"Off","On");
	
	Group("Идентификация",5,70,300,55)	  
    {
        Label(part," ",65,20); 			  
	Label(sn," ",65,35); 			 
    }
    	Group("Информация",5,130,300,50)	 
    {
        Label(message," ",0,18);		 
    }
    	Group("Описание",5,185,300,200) 	
    {
        Label(lb1,"Code calculator for GRUNDIG :",0,15);
    	Label(lb2,"Model:  SMART RADIO MRR",32,30);
    	Label(lb3,"Sec. Type:  CODE 0000-9999",32,45);
	Label(lb4,"Manufacturen:  GRUNDIG.",32,60);
	Label(lb5,"Partnumer:  MC2728",32,75);
    	Label(lb6,"MCU:  NEC MRR-1 ",32,90);
	Label(lb7,"EEPROM:  24C08 ",32,105);
	Label(lb8,"Sec.loc.: EEPROM",32,120);
    	Label(lb9,"Autor:  telik@ukrwest.net   2008",0,200);
    	Label(lb10,"Enter code: ",32,135);
    }
	Picture(Logo,"grundig.bmp",210,15,0,0);
    {
        Label(msg," ",0,395);				 
    } 
}

OnShow {
	msg.Color=0x0000FF; msg.Bold=1;	msg="http://www.eeprom.lg.ua";		
        
    	var1=@0x10; var2=@0x11; var3=var2&0x0F; var0=@0x12; var4=var1^0x34;	
	var10=1;  
    	if(var4!=var0) {var10=0;}	 
	if(var10=0) { message.Bold=1; message.Color=0x0000FF; message="Неверный дамп !"; Code=0; }
    else
    {
	var5=((var1>>4)^(var2>>4))^0x0F; var6=var5&7;
	var7=(var1>>4)^(var1&0x0F); var8=(var2>>4)^var7;
	var9=var7<<4; var10=var6<<8;
	Code=var8|var9|var10;

	if(var3=14){code=code+0x1000;}
	if(var3=13){code=code+0x2000;}
	if(var3=12){code=code+0x3000;}
	if(var3=11){code=code+0x4000;}
	if(var3=10){code=code+0x5000;}
	if(var3=09){code=code+0x6000;}
	if(var3=08){code=code+0x7000;}
	if(var3=07){code=code+0x8000;}
	if(var3=06){code=code+0x9000;}
	if(var3=05){code=code+0xA000;} 
	if(var3=04){code=code+0xB000;}
	if(var3=03){code=code+0xC000;}
	if(var3=02){code=code+0xD000;}
	if(var3=01){code=code+0xE000;}
	if(var3=00){code=code+0xF000;}

	if(code>0xEA5F){code=code-0xEA60;}
	if(code>0xC34F){code=code-0xC350;}
	if(code>0x9C3F){code=code-0x9C40;}
	if(code>0x752F){code=code-0x7530;}
	if(code>0x4E1F){code=code-0x4E20;}
	if(code>0x270F){code=code-0x2710;}
	
	var11=0; CodeRequest=1;
	if(@0x14=0xDC){var11=var11+1;}
	if(@0x15=0x0B){var11=var11+1;}
	if(var11=2){CodeRequest=0;}  
	message.Color=0xFF0000; message.Bold=1; message="Дамп ОК. ";
	sn = "Serial No.: ";
    	part = "PART No.: ";
   }    
}

OnApply {
	var1=@0x10; var2=@0x11; var3=var2&0x0F; var0=@0x12; var4=var1^0x34;	
	var10=1;  
    	if(var4!=var0) {var10=0;}	 
	if(var10=0) { message.Bold=1; message.Color=0x0000FF; message="Неверный дамп !  Запись прекращена !"; Code=0; }
	else
    {
	if(CodeRequest=0) { @0x14=0xDC; @0x15=0x0B; @0x16=0xDC; @0x17=0x0B; 
			    message.Color=0xFF0000; message.Bold=1; message="Запрос кода успешно изменён."; }
	
    }
}
