]> www.vanbest.org Git - sasc-ng.git/commitdiff
nagra: simplify map cycles handling
authorleslie <unknown>
Fri, 13 Jun 2008 00:48:57 +0000 (08:48 +0800)
committerleslie <unknown>
Fri, 13 Jun 2008 00:48:57 +0000 (08:48 +0800)
systems/nagra/nagra2-0101.c
systems/nagra/nagra2-0501.c
systems/nagra/nagra2.h

index a45b8a9c3dd0889a01752a0758af0f10fc776252..5bfb805f6f53c2c4a701fc019271a07efbf08081 100644 (file)
@@ -171,6 +171,7 @@ void cMap0101::DoMap(int f, unsigned char *data, int l)
   PRINTF(L_SYS_MAP,"0101: calling function %02X",f);
   l=GetOpSize(l);
   cycles=0; interrupted=false;
+  unsigned int startcycles=MapCycles();
   switch(f) {
     case 0x21:
       MAP_IRQ_BEGIN();
@@ -180,7 +181,7 @@ void cMap0101::DoMap(int f, unsigned char *data, int l)
       AddMapCycles(282);
       BN_clear(C);
       WS_END();
-      AddMapCycles(898-282-288);
+      cycles=898;
       MAP_IRQ_END();
       break;     
     case 0x22:
@@ -355,6 +356,8 @@ void cMap0101::DoMap(int f, unsigned char *data, int l)
         PRINTF(L_SYS_MAP,"0101: unsupported call %02x",f);
       break;
     }
+  if(!interrupted && cycles)
+    cycles-=MapCycles()-startcycles;
 }
 
 // -- cN2Prov0101 --------------------------------------------------------------
@@ -381,6 +384,7 @@ protected:
   virtual void Stepper(void);
   virtual void TimerHandler(unsigned int num);
   virtual void AddMapCycles(unsigned int num);
+  virtual unsigned int MapCycles(void) { return Cycles(); }
 public:
   cN2Prov0101(int Id, int Flags);
   virtual bool PostProcAU(int id, unsigned char *data);
index d249d7620e8ef2dcb7a291b3f8b323b78f03bd07..1bfe95faacfbfd02dfb841a4ffd3c91dbb68c352 100644 (file)
@@ -137,7 +137,6 @@ bool cN2Prov0501::ProcessMap(int f)
   switch(f) {
     case SETSIZE:
       DoMap(f,0,Get(0x48));
-      AddCycles(MapCycles());
       break;
     case IMPORT_J:
     case IMPORT_A:
@@ -147,7 +146,6 @@ bool cN2Prov0501::ProcessMap(int f)
     case IMPORT_LAST:
       addr=HILO(0x44);
       GetMem(addr,tmp,dl,0); DoMap(f,tmp,l);
-      AddCycles(MapCycles());
       break;
     case EXPORT_J:
     case EXPORT_A:
@@ -157,7 +155,6 @@ bool cN2Prov0501::ProcessMap(int f)
     case EXPORT_LAST:
       addr=HILO(0x44);
       DoMap(f,tmp,l); SetMem(addr,tmp,dl,0);
-      AddCycles(MapCycles());
       break;
     case SWAP_A:
     case SWAP_B:
@@ -165,7 +162,6 @@ bool cN2Prov0501::ProcessMap(int f)
     case SWAP_D:
       addr=HILO(0x44);
       GetMem(addr,tmp,dl,0); DoMap(f,tmp,l); SetMem(addr,tmp,dl,0);
-      AddCycles(MapCycles());
       break;
     case CLEAR_A:
     case CLEAR_B:
@@ -178,7 +174,6 @@ bool cN2Prov0501::ProcessMap(int f)
     case COPY_C_D:
     case COPY_D_C:
       DoMap(f);
-      AddCycles(MapCycles());
       break;
     case 0x37:
       GetMem(HILO(0x44),tmp,dl,0);
@@ -199,6 +194,7 @@ bool cN2Prov0501::ProcessMap(int f)
       PRINTF(L_SYS_EMU,"%04x: map call %02x not emulated",id,f);
       return false;
     }
+  if(cycles>0) AddMapCycles(cycles);
   return true;
 }
 
index 1d8db715bf06ff6c08e304f47ac8b6b181d5ef96..19bc5078202ef505fb069b5c7989fe411fc04124 100644 (file)
@@ -160,8 +160,8 @@ protected:
   //
   int GetOpSize(int l);
   bool DoMap(int f, unsigned char *data=0, int l=0);
-  unsigned int MapCycles() { return cycles; }
   virtual void AddMapCycles(unsigned int num) {}
+  virtual unsigned int MapCycles(void) { return 0; }
 public:
   cMapCore(void);
   virtual ~cMapCore() {}