[Carradio\Opel\Grundig SC303]
Size(280,260);
Form {
    HexDigit(Code,"Code",65,10,100,4);
    ComboBox(Safe,"Code request",27,40,150,"Safe 1",
                                              "Safe 2",
                                              "Safe 3",
                                              "Safe 4",
                                              "Without code",
                                              "Unknown state");

    Group("",5,60,270,30) { Label(Error,"Dump OK",5,10); }
    Group("Description",5,100,270,90) {
        Label(lbDes1,"Code calculator for carradio Opel SC303 (by Grundig)",7,15);
        Label(lbDes2,"with MCU MC68HC11E9.",70,30);

        Label(lbDes3,"Enter new code and/or code state",50,55);
        Label(lbDes4,"and press APPLY button",75,70);
    }
}

OnShow {
    Code = (@0<<8)|@3;
    Var0 = 0;
    if(@0 != (@1 ^ 255)) { Var0 = 1;}
    if(@0 != (@2 ^ 0x5A)) { Var0 = 1;}
    if(@3 != (@4 ^ 255)) { Var0 = 1;}
    if(@3 != (@5 ^ 0x5A)) { Var0 = 1;}
    if(Var0 = 0)
    {
      Error = "                                Dump OK.";
    }
    else
    {
      Error.Bold = 1;  
      Error.Color = 0x0000FF;
      Error = "                  Warning: wrong dump!";
    }              
    Safe = 5;
    if(@6 = 0x10) { Safe = 4;}
    if(@6 = 0x19) { Safe = 0;}
    if(@6 = 0x29) { Safe = 1;}
    if(@6 = 0x39) { Safe = 2;}
    if(@6 = 0x49) { Safe = 3;}
}

OnApply {
    if(Code > 0x9999) {
        Error = "         Select valid code (0000...9999), please...";   
    }
    else {
        if(Safe < 5)
        {
            var0 = (Code >> 8) & 255;
            @0 = Var0;
            @1 = Var0 ^ 255;
            @2 = Var0 ^ 0x5A;
            var0 = Code & 255;
            @3 = Var0;
            @4 = Var0 ^ 255;
            @5 = Var0 ^ 0x5A;
            var0 = 0xa0;
            if(Safe = 0) { var0 = 0x19;}
            if(Safe = 1) { var0 = 0x29;}
            if(Safe = 2) { var0 = 0x39;}
            if(Safe = 3) { var0 = 0x49;}
            if(Safe = 4) { var0 = 0x10;}
            @6 = Var0;
            @7 = Var0 ^ 255;
            @8 = Var0 ^ 0x5A;
            Error = "                                Dump OK.";
        }
        else {
            Error = "                 Select valid code state, please...";
        }
    }
}
