]> www.vanbest.org Git - sasc-ng.git/commitdiff
nagra-0101: update INT map39/3a/3e
authoranon <unknown>
Sat, 21 Jun 2008 05:55:19 +0000 (13:55 +0800)
committeranon <unknown>
Sat, 21 Jun 2008 05:55:19 +0000 (13:55 +0800)
systems/nagra/nagra2-0101.c
systems/nagra/nagra2.c

index 8eb2d26ba0bf7f88d563a343c35e1fe92055f822..1d450ebf46a73f000bc6975dc116f3f2597f3f16 100644 (file)
@@ -170,7 +170,7 @@ bool cMap0101::Map(int f, unsigned char *data, int l)
       BN_clear(C);
       WS_END();
       cycles=898;
-      break;     
+      break;
     case 0x22:
       if(BN_is_zero(D)) { cycles=639-6; break; }
       l&=0x1fff;
@@ -244,7 +244,17 @@ bool cMap0101::Map(int f, unsigned char *data, int l)
         BN_one(A);
         }
       else {
-        MonInit();
+        MakeJ0(J,D);
+        if(!BN_is_zero(D)) {
+          BN_zero(I);
+          BN_set_bit(I,68*wordsize);
+          BN_mod(B,I,D,ctx);
+          }
+        MonMul0(B,B,B,C,D,J,wordsize);
+        AddMapCycles(2350);
+        MonFin(B,D);
+        for(int i=1; i<4; i++) MonMul(B,B,B);
+//        MonInit();
         MonMul(B,A,B);
         MonExp(scalar);
         }
@@ -841,7 +851,7 @@ void cN2Prov0101::TimerHandler(unsigned int num)
       if(mask&1) {
         DisableTimers(11);
         if(t==2) {
-          PRINTF(L_SYS_EMU,"Timer interrupt %u @ %04x",t,GetPc());
+          PRINTF(L_SYS_EMU,"0101: Timer interrupt %u @ %04x",t,GetPc());
           RaiseException(9);
           if(Interruptible()) throw(t);
           }
index cc5a424bad4e0171ac45ae7a3676ca958c9ae96d..d6c6ce8f5039065c691eb7535d36f4ecea51f630 100644 (file)
@@ -53,6 +53,7 @@ bool cN2Timer::AddCycles(unsigned int count)
       while(cycles<0) cycles+=latch+1;
       }
     else if(stop) {
+      PRINTF(L_SYS_EMU,"n2timer %d: timer stop (cycles=%d remainder=%d)",nr,cycles,remainder);
       cycles=0;
       Stop();
       }
@@ -678,7 +679,11 @@ void cMapCore::DoMap(int f, unsigned char *data, int l)
       unsigned int elapsed=CpuCycles()-startcycles;
       if(cycles>elapsed) AddMapCycles(cycles-elapsed);
       }
-    } catch(int) { interrupted=true; }
+    }
+  catch(int) {
+    interrupted=true;
+    PRINTF(L_SYS_MAP,"%04x: call %02x interrupted (%d cycles)",mapid,f,CpuCycles()-startcycles);
+    }
   interruptible=false;
   cycles=CpuCycles()-startcycles;
 }
@@ -771,23 +776,34 @@ bool cMapCore::MapGeneric(int f, unsigned char *data, int l)
       last=3; C.Set(D,l1); cycles=462+(8*l1+3)/5*5-6; break;
 
     case 0x39:
-    case 0x3a:
-      AddMapCycles(512);
       WS_START(1);
-      MakeJ0(J,D);
-      AddMapCycles(256);
+      MakeJ0(J,D,C);
+      AddMapCycles(860);
+      BN_zero(C);
       WS_END();
-      AddMapCycles(340);
       if(!BN_is_zero(D)) {
         BN_zero(I);
         BN_set_bit(I,68*wordsize);
         BN_mod(B,I,D,ctx);
         }
-      AddMapCycles(320);
+      AddMapCycles(940);
       for(int i=0; i<4; i++) MonMul(B,B,B);
-
-      if(f==0x39) I.GetLE(data,wordsize<<3);
-      MonMul(B,(f==0x39?I:A),B);
+//        MonInit();
+      I.GetLE(data,wordsize<<3);
+      MonMul(B,I,B);
+      MonMul(B,A,B);
+      break;
+    case 0x3a:
+      MakeJ0(J,D);
+      if(!BN_is_zero(D)) {
+        BN_zero(I);
+        BN_set_bit(I,68*wordsize);
+        BN_mod(B,I,D,ctx);
+        }
+      AddMapCycles(2000);
+      for(int i=0; i<4; i++) MonMul(B,B,B);
+//        MonInit();
+      MonMul(B,A,B);
       MonMul(B,A,B);
       break;
     case 0x43: // init SHA1